From ch612bunn at gmail.com Sun Apr 27 09:19:26 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:19:26 -0700 (PDT) Subject: adobe illustrator cs3 crack Message-ID: <8ed265cd-4ba7-441f-a9ee-a1240c082f70@e39g2000hsf.googlegroups.com> adobe illustrator cs3 crack http://wga-cracks.crackkey.net From barbaros at ptmat.fc.ul.pt Wed Apr 23 11:44:50 2008 From: barbaros at ptmat.fc.ul.pt (barbaros) Date: Wed, 23 Apr 2008 08:44:50 -0700 (PDT) Subject: help needed with classes/inheritance References: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> <480f05d0$0$25755$426a74cc@news.free.fr> Message-ID: <676bac37-2816-402b-9aed-1a9c1873351b@a23g2000hsc.googlegroups.com> On Apr 23, 10:48 am, Bruno Desthuilliers wrote: > > > My question is: can it be done using inheritance ? > > Technically, yes: > > class OrientedBody(Body): > def __init__(self, orient=1): > Body.__init__(self) > self.orient = 1 > > Now if it's the right thing to do is another question... If I understand correctly, in the above implementation I cannot define firstly a (non-oriented) body, and then build, on top of it, two bodies with opposite orientations. The point is, I want both oriented bodies to share the same base Body object. > Another > possible design could be to have an orient attribute on the Body class > itself, with 0 => non-oriented (default), 1 => 'plus', -1 => 'minus' (or > any other convention, depending on how you use this attribute). The above comments apply here, too. In what concerns other suggestion, about Python language, I shall do my best to understand them and apply them. Thank you. Cristian Barbarosie http://cmaf.fc.ul.pt/~barbaros From bbxx789_05ss at yahoo.com Sun Apr 13 21:19:28 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sun, 13 Apr 2008 18:19:28 -0700 (PDT) Subject: Tkinter, image not appearing in function but without function References: <42a33edd-5792-47ad-a940-ecb5df23accc@a9g2000prl.googlegroups.com> <66et8fF2ju94lU2@mid.uni-berlin.de> Message-ID: <8d74351a-4d73-4981-a9c8-c2535c070b30@d1g2000hsg.googlegroups.com> On Apr 13, 11:12?am, Marc 'BlackJack' Rintsch wrote: > On Sun, 13 Apr 2008 08:57:29 -0700, skanemupp wrote: > > why is the first program not working? when i click the screen the map > > is not appearing. > > > the second program works. > > > from Tkinter import * > > > master = Tk() > > > w = Canvas(master, width=700, height=600) > > w.pack(expand = YES, fill = BOTH) > > > def mapper(): > > ? ? mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\world-map.gif') > > ? ? w.create_image(10, 10, image = mapq, anchor = NW) > > > def key(event): > > ? ? print "pressed", repr(event.char) > > > def callback(event): > > ? ? w.focus_set() > > ? ? print "clicked at", event.x, event.y > > ? ? mapper() > > ? ? print 'yo' > > ? ? square = w.create_oval(event.x-5,event.y-5,event.x+5,event.y+5, > > fill="black") > > > w.bind("", key) > > w.bind("", callback) > > w.pack() > > > mainloop() > > Python doesn't know that the Tk side still needs the image and frees the > memory when `mapper()` is done and `mapq` the only name to the `PhotoImage` > instance goes out of scope. > > Ciao, > ? ? ? ? Marc 'BlackJack' Rintsch ...so you should do something like this(untested): def mapper(height, width, widget, img, position): widget.create_image(height, width, image=img, anchor=position) w = Canvas(master, width=700, height=600) w.pack(expand = YES, fill = BOTH) #Create a permanent reference to the image, i.e. the variable is not #created inside a function: my_img = PhotoImage(file = 'C:\Users\saftarn\Desktop\world-map.gif') mapper(10, 10, w, my_img, NW) From tjreedy at udel.edu Wed Apr 2 13:12:57 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 2 Apr 2008 13:12:57 -0400 Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: "AK" wrote in message news:47f2d018$0$6517$4c368faf at roadrunner.com... || I'll be glad to hear comments/suggestions/etc: | | http://www.lightbird.net/py-by-example/ Using - as the example/return delimiter does not work. If you do not want to substantially lengthen the document by going to >>> sqrt(9) 3 then use Python's a comment symbol. sqrt(9) # 3 -or- sqrt(9) # returns 3 (but I think I prefer the first) which clearly is not an arithmetic expression and which can be cut-and-pasted into the interactive interpreter. This also works nicely for invalid examples. sqrt(-9) # raises ValueError Terry Jan Reedy From __peter__ at web.de Sun Apr 13 16:34:19 2008 From: __peter__ at web.de (Peter Otten) Date: Sun, 13 Apr 2008 22:34:19 +0200 Subject: class level properties References: Message-ID: Charles D Hixson wrote: > Peter Otten wrote: >> Charles D Hixson wrote: >> >> >>> I want a hundred or so read-only variables, and I'm not sure the best >>> way to achieve it. >>> >> >> What do you really want to do? I recommend that you forget about bondage >> and rely upon displine: >> >> class Test(object): >> """Never change an attribute with an uppercase name.""" >> SIMPLE = "simple example working" >> >> Now that was easy... >> >> Peter >> >> > What I'm doing it translating Java code which has a large number of > "public static final (type)" variables. Ah, Java, the class is an artefact of the language then, and my example becomes SIMPLE = "simple example working" > As to your answer ... yes, and with good discipline you can write object > oriented code in C and never need a garbage collector. It's *not* a > good answer. Before I'd chose that one, I'd make it necessary to Hmm, if you were to choose between a Java dialect without garbage collection or without the 'final' keyword, would you throw a coin? > instantiate the class before testing the value of it's constants. It's > just that that seems to be a silly requirement, so I'd like to avoid Silly or not, it keeps your code simpler, and simplicity just cannot be overvalued. > it. (That's the "solution" that I currently have working with > __getattr__.) I'm confident that after you have been coding in Python for a while the Javaisms will wither away. For now, if you feel that uppercase module-level names are too big a leap I suggest that you add a __setattr__() method that records any attempts to modify read-only attributes. That way you'll have a way to learn whether that particular safety net was a useful investment or just dead code. Peter From steve at holdenweb.com Wed Apr 23 22:49:44 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 22:49:44 -0400 Subject: Partition list with predicate In-Reply-To: <925822270804231839y2eb399a2ic05ab67406c94d0d@mail.gmail.com> References: <925822270804231808n44c44ddbx213e936319ad1ed3@mail.gmail.com> <925822270804231839y2eb399a2ic05ab67406c94d0d@mail.gmail.com> Message-ID: Jared Grubb wrote: > That almost works, except that a predicate can have "memory". For > example, the predicate could be "extract every other object", which > doesn't care about the value of the object (so you cant remove them > later based on value!). Or your predicate might be "remove the first 5 > objects that are even", which means that the predicate must be run > against the list in forward order with only one test per element (like > an input/output iterator in C++; running the predicate changes the > predicate itself, so you cant run one pass with "pred" and then another > pass with "not pred" to get the rest). Example of a case where your > proposed solution wouldn't quite work: > > class EveryOtherOne: > def __init__(self): > self.parity = False > def __call__(self, obj): > ret, self.parity = self.parity, not self.parity > return ret > > >>> pred = EveryOtherOne() > >>> lst = [1,2,2,1] > >>> extracted = [ obj for obj in lst if pred(obj) ] > >>> extracted > [2, 1] > >>> lst = [ obj for obj in lst if obj not in extracted ] > >>> lst > [] > > On Wed, Apr 23, 2008 at 6:14 PM, Brian > wrote: > > On Wed, Apr 23, 2008 at 9:08 PM, Jared Grubb > wrote: > > I guess I forgot one requirement: the removed elements need to > be remembered. > > Basically, I have a list of objects in a buffer, one class > operates on some of the objects, but other classes use others. > So, a class must extract the ones it can handle, and leave the > rest in the buffer for the other classes to handle. > > I haven't found a function that will both remove objects from a > list, but save the ones that do get removed. > > Jared > > On 23 Apr 2008, at 10:15, Tim Golden wrote: >> Jared Grubb wrote: >>> I want a function that removes values from a list if a >>> predicate evaluates to True. The best I could come up with is: >> >> Have a look at the itertools module, and the ifilter function >> in particular. >> >> TJG >> -- >> http://mail.python.org/mailman/listinfo/python-list > > > -- > http://mail.python.org/mailman/listinfo/python-list > > > I would do it like this: > > # This takes out the values > extracted = [ obj for obj in lst if pred(obj) ] > # This filters out any item that was extracted > lst = [ obj for obj in list if obj not in extracted ] > So what you are saying is that you want to build *two* lists, one of them the ones for which the predicate is true and the other the rest. Typical customer, doesn't bother to give us the whole specification until we've started programming! How about (untested, conditional expression abuse warning): def stripf(lst, pred): tlst = [] flst = [] for itm in lst: (tlst if pred(itm) else flst).append(itm) return tlst, flst regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From mellit at gmail.com Tue Apr 22 09:47:53 2008 From: mellit at gmail.com (Anton Mellit) Date: Tue, 22 Apr 2008 15:47:53 +0200 Subject: overriding = operator Message-ID: Hi, I am developing something like a compiler in Python, a library that would help to generate machine-language code. One of the features is the following. When I want to generate a piece of code I want to declare variables as follows: x = var() y = var() This would generate no code, but it would mean that I need, say, two 32-bit integer variables. Then whenever I write something like x+y, the '+' operator is overriden in such a way that a code which computes the sum is generated. What I also want to do, I want to write something like z = var() z = x + y and I want a code which takes the sum of x and y and puts it in z to be generated. However in python z = x + y already has its meaning and it does something different from what I want. So I need something like 'overriding' =, which is impossible, but I look for a systematic approach to do something instead. It seems there are two ways to do what I need: 1. Implement a method 'assign' which generates the corresponding code to store value: z.assign(x + y) 2. Do the same as 1., but via property set methods. For example, this would look cleaner: z.value = x + y Which of these is preferrable? Does anyone know any alternative ways? Anton From dave.l.harrison at gmail.com Fri Apr 18 05:01:10 2008 From: dave.l.harrison at gmail.com (David Harrison) Date: Fri, 18 Apr 2008 19:01:10 +1000 Subject: testing client-server sockets In-Reply-To: <4808627F.5040906@al.com.au> References: <4808627F.5040906@al.com.au> Message-ID: On 18/04/2008, Astan Chee wrote: > Hi, > I have a client-server socket script in python. Something like this > http://ubuntuforums.org/showthread.php?t=208962 > Now the problem I have is that I want to try to connect the client to > the server on the same machine, but it gives me a 'port already in use' > error. I just want the client to connect to the server for testing > purposes. Any suggestions on how I should do this? > Thanks > Astan Can you post the client / server code for us ? It sounds like it's likely to be a minor bug. From python at rcn.com Tue Apr 8 15:25:34 2008 From: python at rcn.com (Raymond Hettinger) Date: Tue, 8 Apr 2008 12:25:34 -0700 (PDT) Subject: list.sort(): heaviest item? References: Message-ID: On Apr 8, 8:15?am, "Steven Clark" wrote: > If I have a list of items of mixed type, can I put something into it > such that after a list.sort(), is guaranteed to be at the end of the > list? Since the other guys gave you the real answer, how about this: sentinel = object() mylist.sort() mylist.append(sentinel) _ ~ @ @ \_/ From steve at holdenweb.com Wed Apr 23 00:41:17 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 00:41:17 -0400 Subject: Python Success stories In-Reply-To: References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> Message-ID: <480EBDED.5010600@holdenweb.com> Nikita the Spider wrote: > In article > <7e595409-be62-4b8c-9819-a14cd363d751 at c65g2000hsa.googlegroups.com>, > azrael wrote: > >> Which big aplications are written in python. I see its development, >> But i can't come up with a big name. I know that there are a lot of >> companys using python, but is there anythong big written only in >> python. I want him to fuck of with his perl once and for all time > > Why are either of you so emotionally attached to the tools you use? > > I don't know your friend, but my guess is that he's not interested in a > logical argument, so he won't be impressed even if you claim that God > himself wrote the Universe in Python. I think he enjoys saying this > stuff simply because you react to it. It's pretty sad that he can't find > something better to do with his time. > It's even sadder that he doesn't need to. [...] regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From castironpi at gmail.com Sun Apr 27 13:27:44 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sun, 27 Apr 2008 10:27:44 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <1d8af3e3-c287-4d5b-a481-ca8c650f732f@s33g2000pri.googlegroups.com> Message-ID: <472056db-8812-42b2-a4fe-3a2accd7571b@8g2000hse.googlegroups.com> On Apr 26, 11:04?pm, John Henry wrote: > On Apr 26, 3:03?pm, John Henry wrote: > > > > > > > On Apr 26, 8:46 am, a... at pythoncraft.com (Aahz) wrote: > > > > In article <9028496e-30de-4853-8f57-b55d14e52... at h1g2000prh.googlegroups.com>, > > > John Henry ? wrote: > > > > >But then I looked closer. ?It turns out the XML file created by > > > >QxTransformer is *very* similar in structure when compared to the > > > >resource files used inPythonCard. ?Since there are no GUI builders > > > >for QxTransformer, and I can't affort to buy the one for Qooxdoo > > > >(Java! ?Yuk!), I decided to roll up my sleeves, took thePythoncard's > > > >Layout Manager and modified it and created my own "Poor Man's Qooxdoo > > > >GUI Layout Designer". > > > > Cute! ?When you have working code, please do upload to PyPI. > > > -- > > > Aahz (a... at pythoncraft.com) ? ? ? ? ? <*> ? ? ? ?http://www.pythoncraft.com/ > > > > Why is this newsgroup different from all other newsgroups? > > > So far, I have the following widgets working: > > > window, button, checkbox, static text, static box, list, combobox, > > spinner, radio button group > > > Shouldn't be long before the following works: > > > static line, image, image button, choice.- Hide quoted text - > > > - Show quoted text - > > All of the above works! > > TextFields next.- Hide quoted text - > > - Show quoted text - Actually, I was asking what operations you chose to support in 'static text'. Additional Python methods of strings could be made to work on them. From gagsl-py2 at yahoo.com.ar Tue Apr 15 18:24:03 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 15 Apr 2008 19:24:03 -0300 Subject: tkinter, event.widget, what do i get? References: <7caa5089-2ea9-4e18-9117-7431d7403976@l42g2000hsc.googlegroups.com> Message-ID: En Tue, 15 Apr 2008 17:45:08 -0300, escribi?: > when calling function hmm here, what do i get? the widget i clicked > on? > if i have a canvs on wich i have a bitmap and i click on the bitmap, > is the event.widget then the bitmap? > can i get info about the bitmap then? like color of the pixel i > clicked. if so, how? > > > w.bind("", key) > w.bind("", hmm) > > def hmm(event): > return event.widget Why don't you try by yourself? You can use: print repr(something) -- Gabriel Genellina From jeff.self at gmail.com Wed Apr 9 17:10:44 2008 From: jeff.self at gmail.com (jeffself) Date: Wed, 9 Apr 2008 14:10:44 -0700 (PDT) Subject: How can I use quotes without escaping them using CSV? Message-ID: I'm reading data out of an Excel spreadsheet using the XLRD module. The spreadsheet contains a list of election results. The fields are as follows: Precinct, Candidate, Votes The problem is candidate names can be funky, for instance: Michael L. "Mick" Jones I cannot for the life of me figure out how to get the CSV module to allow a name like this to be written to a file. Why does it insist on an escape character when I'm telling it that the delimiter should be '\t'? I want the quotes to go to the file and I want the tab- delimited file to look like this: 0001[tab]Michael L. "Mick" Jones[tab]189 0002[tab]Vickie A. Meyers[tab]221 0003[tab]John "Jack" Smith[tab]187 Note: I don't want [tab] to display, I want a real tab there. If I put an escape character in, it works. For example, if I use ~ as my escape character, my output looks like this: 0001[tab]Michael L. ~"Mick~" Jones[tab]189 I don't want that. If I don't include an escape character, it doesn't work. Here's my code: import sys import csv from readexcel import * f = open("results.txt", 'wb') book = sys.argv[1] sheet = sys.argv[2] xl = readexcel(book) sheetnames = xl.worksheets() for s in sheetnames: if s == sheet: writer = csv.writer(f, delimiter='\t', quoting=csv.QUOTE_NONE) for row in xl.getiter(s): writer.writerow((row['Precinct'],row['Candidate'],unicode(int(row['Votes'])))) f.close() Thanks! From george.sakkis at gmail.com Tue Apr 22 09:03:27 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 22 Apr 2008 06:03:27 -0700 (PDT) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> <85c14b14-9302-41bb-9270-b7cdd65098b0@c65g2000hsa.googlegroups.com> Message-ID: <870d9ebe-ffcb-4222-8aa1-43634b767f76@s50g2000hsb.googlegroups.com> On Apr 22, 12:04?am, Ivan Illarionov wrote: > On Mon, 21 Apr 2008 16:10:05 -0700, George Sakkis wrote: > > On Apr 21, 5:30 pm, Ivan Illarionov wrote: > > >> On 22 ???, 01:01, Peter Otten <__pete... at web.de> wrote: > > >> > Ivan Illarionov wrote: > >> > > And even faster: > >> > > a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, > >> > > len(s), 3)))) > >> > > if sys.byteorder == 'little': > >> > > ? ? a.byteswap() > > >> > > I think it's a fastest possible implementation in pure python > > >> > Clever, but note that it doesn't work correctly for negative numbers. > >> > For those you'd have to prepend "\xff" instead of "\0". > > >> > Peter > > >> Thanks for correction. > > >> Another step is needed: > > >> a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, > >> len(s), 3)))) > >> if sys.byteorder == 'little': > >> ? ? a.byteswap() > >> result = [n if n < 0x800000 else n - 0x1000000 for n in a] > > >> And it's still pretty fast :) > > > Indeed, the array idea is paying off for largeish inputs. On my box > > (Python 2.5, WinXP, 2GHz Intel Core Duo), the cutoff point where > > from3Bytes_array becomes faster than from3Bytes_struct is close to 150 > > numbers (=450 bytes). > > > The struct solution though is now almost twice as fast with Psyco > > enabled, while the array doesn't benefit from it. Here are some numbers > > from a sample run: > > > *** Without Psyco *** > > ? size=1 > > ? ? from3Bytes_ord: 0.033493 > > ? ? from3Bytes_struct: 0.018420 > > ? ? from3Bytes_array: 0.089735 > > ? size=10 > > ? ? from3Bytes_ord: 0.140470 > > ? ? from3Bytes_struct: 0.082326 > > ? ? from3Bytes_array: 0.142459 > > ? size=100 > > ? ? from3Bytes_ord: 1.180831 > > ? ? from3Bytes_struct: 0.664799 > > ? ? from3Bytes_array: 0.690315 > > ? size=1000 > > ? ? from3Bytes_ord: 11.551990 > > ? ? from3Bytes_struct: 6.390999 > > ? ? from3Bytes_array: 5.781636 > > *** With Psyco *** > > ? size=1 > > ? ? from3Bytes_ord: 0.039287 > > ? ? from3Bytes_struct: 0.009453 > > ? ? from3Bytes_array: 0.098512 > > ? size=10 > > ? ? from3Bytes_ord: 0.174362 > > ? ? from3Bytes_struct: 0.045785 > > ? ? from3Bytes_array: 0.162171 > > ? size=100 > > ? ? from3Bytes_ord: 1.437203 > > ? ? from3Bytes_struct: 0.355930 > > ? ? from3Bytes_array: 0.800527 > > ? size=1000 > > ? ? from3Bytes_ord: 14.248668 > > ? ? from3Bytes_struct: 3.331309 > > ? ? from3Bytes_array: 6.946709 > > > And here's the benchmark script: > > > import struct > > from array import array > > > def from3Bytes_ord(s): > > ? ? return [n if n<0x800000 else n-0x1000000 for n in > > ? ? ? ? ? ? ((ord(s[i])<<16) | (ord(s[i+1])<<8) | ord(s[i+2]) > > ? ? ? ? ? ? ? for i in xrange(0, len(s), 3))] > > > unpack_i32be = struct.Struct('>l').unpack def from3Bytes_struct(s): > > ? ? return [unpack_i32be(s[i:i+3] + '\0')[0]>>8 > > ? ? ? ? ? ? for i in xrange(0,len(s),3)] > > > def from3Bytes_array(s): > > ? ? a = array('l', ''.join('\0' + s[i:i+3] > > ? ? ? ? ? ? ? ? ? ? ? ? ? ?for i in xrange(0,len(s), 3))) > > ? ? a.byteswap() > > ? ? return [n if n<0x800000 else n-0x1000000 for n in a] > > > def benchmark(): > > ? ? from timeit import Timer > > ? ? for n in 1,10,100,1000: > > ? ? ? ? print ' ?size=%d' % n > > ? ? ? ? # cycle between positive and negative buf = > > ? ? ? ? ''.join(struct.pack('>i', 1234567*(-1)**(i%2))[1:] > > ? ? ? ? ? ? ? ? ? ? ? for i in xrange(n)) > > ? ? ? ? for func in 'from3Bytes_ord', 'from3Bytes_struct', > > 'from3Bytes_array': > > ? ? ? ? ? ? print ' ? ?%s: %f' % (func, > > ? ? ? ? ? ? ? ? Timer('%s(buf)' % func , > > ? ? ? ? ? ? ? ? ? ? ? 'from __main__ import %s; buf=%r' % (func,buf) > > ? ? ? ? ? ? ? ? ? ? ? ).timeit(10000)) > > > if __name__ == '__main__': > > ? ? s = ''.join(struct.pack('>i',v)[1:] for v in > > ? ? ? ? ? ? ? ? [0,1,-2,500,-500,7777,-7777,-94496,98765, > > ? ? ? ? ? ? ? ? -98765,8388607,-8388607,-8388608,1234567]) > > ? ? assert from3Bytes_ord(s) == from3Bytes_struct(s) == > > from3Bytes_array(s) > > > ? ? print '*** Without Psyco ***' > > ? ? benchmark() > > > ? ? import psyco; psyco.full() > > ? ? print '*** With Psyco ***' > > ? ? benchmark() > > > George > > Comments: > You didn't use the faster version of array approach: > ''.join('\0' + s[i:i+3] for i in xrange(0,len(s), 3)) > is slower than > '\0' + '\0'.join(s[i:i+3] for i in xrange(0,len(s), 3)) Good catch; the faster version reduces the cutoff point between from3Bytes_array and from3Bytes_struct to ~50 numbers (=150 bytes) only (without Psyco). George From gagsl-py2 at yahoo.com.ar Wed Apr 16 01:23:35 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 02:23:35 -0300 Subject: how to remove \n in the list References: <2ba667ab-6818-47eb-8595-79ed970728f7@q1g2000prf.googlegroups.com> Message-ID: En Tue, 15 Apr 2008 20:26:16 -0300, Yves Dorfsman escribi?: > Dan Bishop wrote: > >>>> lines[:] = [line.rstrip('\n') for line in lines] >>> What is the point of the [:] after lines ? How different is it with or >>> without it ? >> >> It causes the result to be stored in the existing list. >> > > If we do: > lines = [line.rstrip('\n') for line in lines] > > lines is now a new list, the old list as no reference to it, and will be > discarded by the gc, right ? So we're not really saving any space here ? > > If we do: > lines[:] = [line.rstrip('\n') for line in lines] > > We reuse an existing list, therefore we are saving the time it takes to > create a new list ? So this is a performance issue ? No. The new list (the right hand side) is created in either case, so there is no difference here. And the name `lines` refers to a list with the new contents in all cases. The difference is on whether *other* references to the original list see the changes or not. For an example, see Dan Bishop's message earlier on this thread. -- Gabriel Genellina From castironpi at gmail.com Tue Apr 1 08:32:24 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Tue, 1 Apr 2008 05:32:24 -0700 (PDT) Subject: Rubik's cube translation References: <3f3817e8-db90-4bbb-9d6e-cddf042ff6de@a22g2000hsc.googlegroups.com> <489180f4-aa43-4d98-a67d-71ce06ea9152@x41g2000hsb.googlegroups.com> <1mj3v35u8ai9bijik3gggdrdhm07qaf7v0@4ax.com> Message-ID: On Apr 1, 1:00?am, Tim Roberts wrote: > castiro... at gmail.com wrote: > > >What if this is connected: > > >>>> D > >array([[1, 2, 3], > > ? ? ? [4, 5, 6], > > ? ? ? [6, 7, 8]]) > >>>> E > >array([[6, 7, 8], > > ? ? ? [0, 0, 0], > > ? ? ? [0, 0, 0]]) > > >--> > > >>>> D > >array([[1, 2, 3], > > ? ? ? [4, 5, 6], > > ? ? ? [6, 7, 8]]) > >>>> E > >array([[6, 7, 8], > > ? ? ? [0, 0, 0], > > ? ? ? [0, 0, 0]]) > >>>> numpy.rot90( D ) > >array([[3, 6, 8], > > ? ? ? [2, 5, 7], > > ? ? ? [1, 4, 6]]) > >--> > >>>> E > >array([[1, 4, 6], > > ? ? ? [0, 0, 0], > > ? ? ? [0, 0, 0]]) > > >? > > If you don't want changes to D to affect E, then you need to disconnect > them when you create them. ?If you create D and E so that they contain > references to the same lists, then this kind of thing will happen. Basically, I need to change both D row 3 and E row 1 at the same time. From markflorisson88 at gmail.com Sat Apr 19 08:13:32 2008 From: markflorisson88 at gmail.com (mark) Date: Sat, 19 Apr 2008 14:13:32 +0200 Subject: eggy IDE Message-ID: <4809E1EC.7040102@gmail.com> Hello, I have written an open source IDE in python and Qt, called eggy. Eggy supports several languages, including python, ruby, C, C++, java, perl and others. Eggy also supports group projects over the lan or internet - with live changes, lets you compile and run your code, supports templates and lets you write your own plugins very easily. You also have syntax highlighting, autocompletion, an integrated bash shell and the option of chatting with group partners. You can read more about it here: http://eggy.student.utwente.nl it free and open source (GPL). Regards, Mark PS: if anyone is interested in helping out with the project, feel free to write and submit a plugin (in python), its really easy and some ideas are posted on the website. From fivesheep at gmail.com Thu Apr 17 06:13:45 2008 From: fivesheep at gmail.com (Fivesheep) Date: Thu, 17 Apr 2008 03:13:45 -0700 (PDT) Subject: about a head line References: Message-ID: On Apr 17, 5:54 pm, "Penny Y." wrote: > I saw some scripts have a line at its begin: > > # encoding:gb2312 > > what's this? Why need it? thanks. declaring of the encoding used in the source file. it's like in html take gb2312 as an example. you will need it if you have some chinese char in the source file which uses gb2312 for the file encoding. if not, you might get an error like: SyntaxError: Non-ASCII character ......... From Graham.Dumpleton at gmail.com Sat Apr 12 18:28:02 2008 From: Graham.Dumpleton at gmail.com (Graham Dumpleton) Date: Sat, 12 Apr 2008 15:28:02 -0700 (PDT) Subject: Multiple independent Python interpreters in a C/C++ program? References: <624b9d79-bc02-4f52-bc97-52019bf916d0@n1g2000prb.googlegroups.com> Message-ID: <4f3b3348-4fe6-443c-8d2f-25f6702ad0ef@s13g2000prd.googlegroups.com> On Apr 13, 3:05?am, sturlamolden wrote: > On Apr 11, 6:24 pm, s... at pobox.com wrote: > > > Do I wind up with two completely independent interpreters, one per thread? > > I'm thinking this doesn't work (there are bits which aren't thread-safe and > > are only protected by the GIL), but wanted to double-check to be sure. > > You can create a new subinterpreter with a call to Py_NewInterpreter. > You get a nwe interpreter, but not an independent one. The GIL is a > global object for the process. If you have more than one interpreter > in the process, they share the same GIL. > > In tcl, each thread has its own interpreter instance and no GIL is > shared. This circumvents most of the problems with a global GIL. > > In theory, a GIL private to each (sub)interpreter would make Python > more scalable. The current GIL behaves like the BKL in earlier Linux > kernels. However, some third-party software, notably Apache'smod_python, is claimed to depend on this behaviour. I wouldn't use mod_python as a good guide on how to do this as it doesn't properly use PyGILState_Ensure() for main interpreter like it should. If you want an example of how to do this, have a look at code for mod_wsgi instead. If you want it to work for Python 3.0 as well as Python 2.X, make sure you look at mod_wsgi source code from subversion repository trunk as tweak had to be made to source to support Python 3.0. This is because in Python 3.0 it is no longer sufficient to hold only the GIL when using string/unicode functions, you also need a proper thread state to be active now. Do note that although multiple sub interpreters can be made to work, destroying sub interpreters within the context of a running process, ie., before the process ends, can be a cause for various problems with third party C extension modules and thus would advise that once a sub interpreter has been created, you keep it and use it for the life of the process. Graham From victorsubervi at gmail.com Thu Apr 17 15:32:06 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 17 Apr 2008 14:32:06 -0500 Subject: Importing My Own Script In-Reply-To: <684b0a740804171218t2fff48c6s6c39acc5b38eb761@mail.gmail.com> References: <69481.40675.qm@web39203.mail.mud.yahoo.com> <684b0a740804171218t2fff48c6s6c39acc5b38eb761@mail.gmail.com> Message-ID: <4dc0cfea0804171232g1bb56215obc2062ed785ba57@mail.gmail.com> That worked. Thanks. Victor On Thu, Apr 17, 2008 at 2:18 PM, Ra?l G?mez C. wrote: > Victor, you can do this in order to load your own modules: > > import sys,os > sys.path.append(os.getcwd()) > > import your_module > > > > On Fri, Apr 18, 2008 at 12:34 PM, Ben Kaplan > wrote: > > > It might be something in mod python. Try asking on their mailing > > list. > > > > ----- Original Message ---- > > From: Victor Subervi > > To: Ben Kaplan > > Cc: python-list at python.org > > Sent: Thursday, April 17, 2008 10:47:34 AM > > Subject: Re: Importing My Own Script > > > > On Thu, Apr 17, 2008 at 8:52 AM, Ben Kaplan > > wrote: > > > > > If x and y are in the same directory, just do "import x". If not, add > > > the directory containing x to sys.path. Then, "import x" should work. > > > > > > > Well, now that?s what I thought! But no, it doesn?t work! Both scripts > > are in the same folder. Here?s the error: > > > > [Thu Apr 17 07:45:50 2008] [error] [client 190.166.0.245] PythonHandler > > mod_python.cgihandler: File "/var/www/vhosts/ > > livestocksling.com/httpdocs/bre/test.py", line 3, in ?\n import test2 > > [Thu Apr 17 07:45:50 2008] [error] [client 190.166.0.245] PythonHandler > > mod_python.cgihandler: ImportError: No module named test2 > > I?m running through Plesk, if that makes a difference. > > TIA, > > Victor > > > > > > > > > > ----- Original Message ---- > > > From: Victor Subervi > > > To: python-list at python.org > > > Sent: Thursday, April 17, 2008 9:45:10 AM > > > Subject: Importing My Own Script > > > > > > Hi: > > > How do I import my own script from a second script? That is, I have > > > script x and I want to import script y. How? > > > TIA, > > > Victor > > > > > > > > > ------------------------------ > > > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try > > > it now. > > > > > > > > > > > ------------------------------ > > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try > > it now. > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > > > -- > Nacho > Linux Counter #156439 > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at cheimes.de Sun Apr 20 16:10:52 2008 From: lists at cheimes.de (Christian Heimes) Date: Sun, 20 Apr 2008 22:10:52 +0200 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <480B8813.6010108@gmail.com> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B80B5.1050500@cheimes.de> <480B8813.6010108@gmail.com> Message-ID: <480BA34C.6010905@cheimes.de> Hank @ITGroup schrieb: > In order to deal with 400 thousands texts consisting of 80 million > words, and huge sets of corpora , I have to be care about the memory > things. I need to track every word's behavior, so there needs to be as > many word-objects as words. > I am really suffering from the memory problem, even 4G memory space can > not survive... Only 10,000 texts can kill it in 2 minutes. > By the way, my program has been optimized to ``del`` the objects after > traversing, in order not to store the information in memory all the time. No ordinary system and programming language can hold that much data in memory at once. Your design is broken; some may call it even insane. I highly recommend ZODB for your problem. ZODB will allow you to work with several GB of data in a transaction oriented way without the needs of an external database server like Postgres or MySQL. ZODB even supports clustering and mounting of additional database from the same file system or an external server. Christian From exarkun at divmod.com Tue Apr 22 21:58:39 2008 From: exarkun at divmod.com (Jean-Paul Calderone) Date: Tue, 22 Apr 2008 21:58:39 -0400 Subject: python has memory leak? In-Reply-To: <1d48c77d-cc93-41ce-b644-1a8e52713e1d@b64g2000hsa.googlegroups.com> Message-ID: <20080423015839.6859.414435618.divmod.quotient.33820@ohm> On Tue, 22 Apr 2008 14:54:37 -0700 (PDT), yzghan at gmail.com wrote: >Hi all, > >I feel that my python script is leaking memory. And this is a test I >have: > > [snip] > The test doesn't demonstrate any leaks. It does demonstrate that memory usage can remain at or near peak memory usage even after the objects for which that memory was allocated are no longer live in the process. This is only a leak if peak memory goes up again each time you create any new objects. Try repeated allocations of a large dictionary and observe how memory usage rises and falls. Python 2.5 does a somewhat better job of releasing memory when actual use falls below peak, but this is a difficult thing to do perfectly. Jean-Paul From baoilleach at gmail.com Tue Apr 29 08:41:04 2008 From: baoilleach at gmail.com (baoilleach) Date: Tue, 29 Apr 2008 05:41:04 -0700 (PDT) Subject: simple chemistry in python References: Message-ID: <5e3717e5-1913-4bda-94b3-ae165e5fb8ba@m73g2000hsh.googlegroups.com> If you are familiar with parsing XML, much of the data you need is stored in the following file: http://bodr.svn.sourceforge.net/viewvc/*checkout*/bodr/trunk/bodr/elements/elements.xml?revision=34&content-type=text%2Fplain This file is part of the Blue Obelisk Data Repository, an effort by several chemistry software developers to share common information. If you have any further questions, please email blueobelisk- discuss at lists.sf.net. Noel On Apr 29, 8:48 am, Astan Chee wrote: > Hi, > Im looking for a python module to do simple chemistry things. Things > like, finding the name of elements given the atomic number (and vice > versa); what state the given matter is in depending on certain > parameters; maybe even color of certain elements or even calculating the > result of combining certain elements. > I was looking for something simple, but everything I see seems to be a > full blown chemistry set. > I know I can probably spend a day doing this one element at a time, but > I was wondering if there is already something like this done in a small > scale? > Thanks for any information > Astan > > -- > "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." > > Animal Logichttp://www.animallogic.com > > Please think of the environment before printing this email. > > This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. From Manisa999 at gmail.com Sat Apr 26 01:19:10 2008 From: Manisa999 at gmail.com (Manisa999 at gmail.com) Date: Fri, 25 Apr 2008 22:19:10 -0700 (PDT) Subject: Hard & Soft Parts Available Here X Message-ID: <45efd8be-75f7-4445-b2bf-f9ab06a8fb7b@a9g2000prl.googlegroups.com> SEXY SEGMENT *********************************** http://bigsexmovies.notlong.com/ http://indiansexx.notlong.com/ *********************************** From gagsl-py2 at yahoo.com.ar Mon Apr 28 03:27:51 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 28 Apr 2008 04:27:51 -0300 Subject: error: (10035, 'The socket operation... References: Message-ID: En Sun, 27 Apr 2008 21:41:57 -0300, Benjamin Kaplan escribi?: >> On Sun, Apr 27, 2008 at 7:01 PM, Don Hanlen wrote: >> > IDLE internal error in runcode() >> > Traceback (most recent call last): >> > File "C:\PYTHON25\lib\idlelib\rpc.py", line 235, in asyncqueue >> > self.putmessage((seq, request)) >> > File "C:\PYTHON25\lib\idlelib\rpc.py", line 332, in putmessage >> > n = self.sock.send(s[:BUFSIZE]) >> > error: (10035, 'The socket operation could not complete without >> > blocking') >> > >> > Does this look familiar to anyone? I can't figure out what to do >> > about it. Python 2.5, windoze. I get it when I execute a Tkinter op >> > that works elsewhere. >> It might have something to do with the fact that IDLE uses Tkinter, >> but, having never used it myself, I'm not sure. I think IDLE doesn't work well with Tkinter apps, they compete for the main loop. But perhaps that's already been resolved in recent releases. Anyway this looks like a different problem, I'd file a bug at bugs.python.org In the meantime, run your app from the command line instead of from inside IDLE. -- Gabriel Genellina From marlin_rowley at hotmail.com Thu Apr 10 14:58:44 2008 From: marlin_rowley at hotmail.com (Marlin Rowley) Date: Thu, 10 Apr 2008 13:58:44 -0500 Subject: Reading floats through Telnet object? In-Reply-To: References: Message-ID: Is there any function that allows reading a stream of floats through the Telnet Object? There doesn't seem to be a way to control reading from the socket accept read_until() and that requires a string. -M _________________________________________________________________ Use video conversation to talk face-to-face with Windows Live Messenger. http://www.windowslive.com/messenger/connect_your_way.html?ocid=TXT_TAGLM_WL_Refresh_messenger_video_042008 -------------- next part -------------- An HTML attachment was scrubbed... URL: From andreas.eisele at gmail.com Sat Apr 12 07:02:21 2008 From: andreas.eisele at gmail.com (andreas.eisele at gmail.com) Date: Sat, 12 Apr 2008 04:02:21 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection Message-ID: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> In an application dealing with very large text files, I need to create dictionaries indexed by tuples of words (bi-, tri-, n-grams) or nested dictionaries. The number of different data structures in memory grows into orders beyond 1E7. It turns out that the default behaviour of Python is not very suitable for such a situation, as garbage collection occasionally traverses all objects in memory (including all tuples) in order to find out which could be collected. This leads to the sitation that creating O(N) objects effectively takes O(N*N) time. Although this can be cured by switching garbage collection off before the data structures are built and back on afterwards, it may easily lead a user not familiar with the fine details of garbage collection behaviour to the impression of weak scalability, which would be a pity, as the real problem is much more specific and can be cured. The problem is already clearly visible for 1M objects, but for larger numbers it gets much more pronounced. Here is a very simple example that displays the problem. > python2.5 -m timeit 'gc.disable();l=[(i,) for i in range(1000000)]' 10 loops, best of 3: 329 msec per loop > python2.5 -m timeit 'gc.enable();l=[(i,) for i in range(1000000)]' 10 loops, best of 3: 4.06 sec per loop > python2.5 -m timeit 'gc.disable();l=[(i,) for i in range(2000000)]' 10 loops, best of 3: 662 msec per loop > python2.5 -m timeit 'gc.enable();l=[(i,) for i in range(2000000)]' 10 loops, best of 3: 15.2 sec per loop In the latter case, the garbage collector apparently consumes about 97% of the overall time. I would suggest to configure the default behaviour of the garbage collector in such a way that this squared complexity is avoided without requiring specific knowledge and intervention by the user. Not being an expert in these details I would like to ask the gurus how this could be done. I hope this should be at least technically possible, whether it is really desirable or important for a default installation of Python could then be discussed once the disadvantages of such a setting would be apparent. Thanks a lot for your consideration, and best regards, Andreas ------ Dr. Andreas Eisele, Senior Researcher DFKI GmbH, Language Technology Lab, eisele at dfki.de Saarland University Computational Linguistics Stuhlsatzenhausweg 3 tel: +49-681-302-5285 D-66123 Saarbr?cken fax: +49-681-302-5338 From andrew.english at gmail.com Wed Apr 30 00:30:37 2008 From: andrew.english at gmail.com (Andrew English) Date: Wed, 30 Apr 2008 00:30:37 -0400 Subject: ffmpeg hangs when executed from python Message-ID: <84b9d8200804292130n1d412f49nd95d4237b7bba2f6@mail.gmail.com> I have tried a few methods of executing ffmpeg from within python and it has hanged every time. Two of the configurations I tried are: def convertFileToFlash(filename): commandString = "./convertasftoswf.sh " + getSaveDirectory() + " " + filename logging.debug("RUNNING: " + commandString) results = commands.getstatusoutput(commandString) logging.debug(results) convertasftoswf.sh: #!/bin/sh mencoder ${1}${2} -o ${1}outputfile.avi -ovc xvid -xvidencopts bitrate=280:max_bframes=0 -oac mp3lame -lameopts mode=0:cbr:br=128 -vf-add scale=320:240,expand=320:240 -vf-add harddup -ofps 25.00 -srate 44100 chmod 777 ${1}outputfile.avi ffmpeg -i ${1}outputfile.avi ${1}${2}.swf Also, I tried running each of the commands (mencoder and ffmpeg) separately with the commands.getstatusoutput from within python. Then mencoder call always runs without a problem and the ffmpeg always hangs. Running the shell script directly from the command line works as expected. Any ideas about why ffmpeg would hang in that situation? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From billingspanshism at gmail.com Sat Apr 19 17:16:36 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:16:36 -0700 (PDT) Subject: victoria beckham biography Message-ID: Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From rhamph at gmail.com Wed Apr 16 12:27:59 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Wed, 16 Apr 2008 09:27:59 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> On Apr 16, 6:56 am, Aaron Watters wrote: > I don't get it. It ain't broke. Don't fix it. So how would you have done the old-style class to new-style class transition? From sbergman27 at gmail.com Thu Apr 17 15:40:49 2008 From: sbergman27 at gmail.com (Steve Bergman) Date: Thu, 17 Apr 2008 12:40:49 -0700 (PDT) Subject: How to make this unpickling/sorting demo faster? References: <40a5d8f1-a246-4c48-8759-5b65324f9029@m73g2000hsh.googlegroups.com> <493d67b3-ea8f-4662-86fc-c764a7d47a02@8g2000hse.googlegroups.com> Message-ID: > THe above is applied slavishly by those who value machine time over > peoples time. Do you want to work with them? I understand where you are coming from. But in writing the code snippet I learned something about pickling/unpickling, which I knew *about* but had never actually used before. And also learned the quick and easy way of DSU sorting, which got easier and faster in 2.4. So, personally, I'm ahead on this one. Otherwise, I agree that arguing the matter in long flame threads is a waste of time. From arnodel at googlemail.com Wed Apr 9 15:57:30 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Wed, 9 Apr 2008 12:57:30 -0700 (PDT) Subject: Python 3.0 new integer division References: Message-ID: On Apr 9, 8:35?pm, Mark Dickinson wrote: > Strictly speaking, BCD doesn't come into it: ?the coefficient of a > Decimal instance is stored simply as a string of digits. ?This is > pretty wasteful in terms of space: ?1 byte per decimal digit > instead of the 4 bits per digit that BCD gives, but it's > convenient and fairly efficient. > > An alternative representation that's gained popularity recently is > DPD (densely packed decimal), which packs 3 decimal digits into 10 > bits in a clever way that allows reasonably efficient extraction > of any one of the 3 digits. ?Decimal doesn't use this either. :) > > Mark Naive question: why not just use a long + an exponent? e.g. 132560 -> (13256, 1) 0.534 -> (534, -3) 5.23e10 -> (523, 8) -- Arnaud From castironpi at gmail.com Sun Apr 27 10:17:01 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sun, 27 Apr 2008 07:17:01 -0700 (PDT) Subject: Random/anonymous class methods References: <801e1c38-ae54-443c-8d87-9745db7ef270@59g2000hsb.googlegroups.com> Message-ID: <89ba37e2-49dd-4f95-87c2-95cba9f660ab@56g2000hsm.googlegroups.com> On Apr 27, 7:11?am, Arnaud Delobelle wrote: > philly_bob writes: > > In the sample program below, I want to send a random method to a class > > instance. > > In other words, I don't know which method to send until run-time. ?How > > can I send ch, which is my random choice, to the myclass instance? > > > Thanks, > > > Bob= > > > #### > > import random > > > class myclass(object): > > ? ?def meth1(self): > > ? ? ? print 'meth1' > > ? ?def meth2(self): > > ? ? ? print 'meth2' > > > c=myclass() > > meths=['meth1', 'meth2'] > > ch=random.choice(meths) > > c.ch() > > This will work: > getattr(c, ch)() > > Getattr(c, "meth1") is equivalent to c.meth1. ?Or you could do: > > meths = [c.meth1, c.meth2] > ch = random.choice(meths) > ch() > > -- > Arnaud- Hide quoted text - > > - Show quoted text - MethodType constructors can't be subclassed nor aren't guaranteed consistent. Inferrably, it's because there's more than one way to do it. The way C used to do it was by ordinal, which turns into Java-style reflection. If you use non-linear operation time, string lookup can actually exceed running value of the dollar that Python is on. Do you want the reliability of compile-time errors to do brainwork? If you're chasing running time on member look-up, you may be at an Python entry bottleneck. The class is the only structure that knows what function to run on what object. If you are looking for just a clean -syntax- to denote a uni- dimensional bit by a string of symbols (write 'that' down), you would keep methods in synch across *del+setattr*, specifically, changes. To walk through it: you have a method name from an unknown source, and you want to know different addresses of functions with that name. >>> read 'foo'. 'foo' is a method of more than one object. >>> 'bar'.'foo' 'foo' method of 'bar'. >>> 'cat'.'foo' 'foo' method of 'cat' >>> call cat.foo a thousand times What steps did the interpreter take? If you mutate 'foo', what should 'cat'.'foo' do? Strings aren't immutable in the generic language. If you mutate 'cat', what should 'cat'.'foo' do? If you keep a ('cat','foo') pair in memory (which is why I keep metioning two- dimensional arrays, they're just sparsely populated), you can hash the intersection to a specific bit, but it may not be faster than hash lookups on 'cat' and 'foo' combined. Won't you change the contents of 'cat'? An object-method pair-wise lookup could make more bucks. Do you want more than two? Isn't a generic n-dimensional lookup from linear memory a hash table anyway? You make a case that rigid static lookups are live and useful, and someone else makes the case that users like dynamic lookups, perhaps a more even cross-section of them or something. Rigid statics would be in hardware. Can Python live if hardware comes to support it? From kyosohma at gmail.com Thu Apr 24 10:33:14 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Thu, 24 Apr 2008 07:33:14 -0700 (PDT) Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> <480fa6e3$0$34491$742ec2ed@news.sonic.net> Message-ID: On Apr 23, 4:27?pm, John Nagle wrote: > Tim Golden wrote: > > John Nagle wrote: > >> Mike Driscoll wrote: > >>> Ken, > > >>> On Tue, Apr 22, 2008 at 1:36 PM, Kenneth McDonald > >>> wrote: > >>>> Sadly. > > >>>> ?Thanks, > >>>> ?Ken > >>>> ?-- > >>>> ?http://mail.python.org/mailman/listinfo/python-list > > >>> I've attached the 2.4 version. I also have some Windows binaries for > >>> Beautiful Soup uploaded to my website: > >>>http://www.pythonlibrary.org/python_modules.htm > > >> ? ?What on earth do you need a "Windows binary" for? ?"BeautifulSoup" > >> is ONE PYTHON SOURCE FILE, "BeautifulSoup.py". > > > Ummm.. Why does it bother you? Mike seems to be offering a public > > service to Windows users: by downloading the .exe, I can double-click > > on one file, have the module or package installed (whether it contains > > one .py file or twenty or a series of compiled extension modules and > > their respective DLLs) and for a bonus it's registered in the system > > packages directory [*] and is therefore uninstallable from there. > > ? ? ?Executing strange executables is risky. ?One always wonders what > else they install in addition to what they're supposed be installing. > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? John Nagle This is a legitimate issue and one I don't know how to solve. It would be nice to have some kind of verification process, but I'm unaware of anything affordable. If you have any ideas, feel free to express them. I hope to get testimonials from developers or pythoneers eventually. Suggestions are welcome. Mike From Lie.1296 at gmail.com Sun Apr 13 05:09:45 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 13 Apr 2008 02:09:45 -0700 (PDT) Subject: from __future__ import print References: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> Message-ID: On Apr 11, 7:26 pm, Bruno Desthuilliers wrote: > samsli... at gmail.com a ?crit : > > > Am I the only one that thinks this would be useful? :) > > > I'd really like to be able to use python 3.0's print statement in > > 2.x. > > > FWIW, the whole point is that in 3.0, print stop being a statement to > become a function... > But the reason it becomes a function is because being a statement it is inflexible and there is no way to pass arguments to the print function, at the cost of extra typing of parentheses. I wish py3k would make it an option whether to treat print as statement or function though. Since not all programs require the power of print as a function and having to type the extra parentheses is a bit tiring if you're printing lots of things. Probably it may be coupled with a translator (for source code from statement to function, since the reverse would not be practical) if you changed your mind. From DrColombes at yahoo.com Thu Apr 10 19:45:27 2008 From: DrColombes at yahoo.com (Dr. Colombes) Date: Thu, 10 Apr 2008 16:45:27 -0700 (PDT) Subject: How to modify EVDEV.py to record ASCII characters instead of keystrokes ? Message-ID: <58347b7b-c786-4ed5-ae28-dcfd92d8f8f8@q27g2000prf.googlegroups.com> I've used EVDEV.py successfully as a keystroke logger on Linux machines. How should EVDEV.py be modified to function as an ASCII character logger? That is, to record upper and lower case letters, lower case "5" and upper case "%" characters, etc. Shift and Caps Lock key press events are recorded by EVDEV.py, but the press event of the Shift and Caps Lock keys do not specify which, if any, of the subsequent keys are to be interpreted as "upper case" characters. Thanks for your suggestions. From hnikbakhsht at yahoo.com Fri Apr 4 11:37:03 2008 From: hnikbakhsht at yahoo.com (hassan nikbakhsh) Date: Fri, 4 Apr 2008 08:37:03 -0700 (PDT) Subject: Very good Python Book. Free download : Beginning Python: From Novice to Professional Message-ID: <556360.42077.qm@web37102.mail.mud.yahoo.com> can i have a free bownload of this book many thanks --------------------------------- You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost. -------------- next part -------------- An HTML attachment was scrubbed... URL: From sami.islam at btinternet.com Sun Apr 6 04:54:37 2008 From: sami.islam at btinternet.com (Sami) Date: Sun, 06 Apr 2008 09:54:37 +0100 Subject: Problems trying to hook own exception function to sys.excepthook Message-ID: Hello, I am new to Python. I tried to hook my own ExceptionPrintingFunction sys.excepthook but it does not work. This is what I wrote: ----------------------------------------------------------------------- import sys def MyOwnExceptHook(typ, val, tb): print "Inside my own hook" sys.excepthook = MyOwnExceptHook x = 1/0 ----------------------------------------------------------------------- This is what I get ----------------------------------------------------------------------- Traceback (most recent call last): File "E:/Home/Programming/Python/TryProjects/ExceptHandling1/Except5.py", line 8, in x = 1/0 ZeroDivisionError: integer division or modulo by zero ----------------------------------------------------------------------- I never see "Inside my own hook" which tells me that the hook is not being called. What I really want to test is to stop the exception from propagating further and leave the program intact. What am I doing wrong? Please let me know if there are any other newbie groups that I should probably try in stead. Thanks Sami From Hook at somewhere.nowhere.co.au.it Sat Apr 19 09:58:39 2008 From: Hook at somewhere.nowhere.co.au.it (Hook) Date: 19 Apr 2008 13:58:39 GMT Subject: Inheritance confusion References: <4809932c$0$12307$c3e8da3@news.astraweb.com> Message-ID: <4809fa8f$0$11248$c3e8da3@news.astraweb.com> Thanks to everyone who replied. Kay and Mark put me on the right track immediately. Ben is quite right - the fragment that I posted couldn't have given that error, but I didn't want to post the whole thing - perhaps wrongly, I thought it wouldn't help clarify what I thought the problem was. And that was the real issue - I had managed to convince myself that I had a naming problem in one of my own modules somewhere. If anyone is interested in the background, I'm a long time Perl programmer trying to learn Python by converting a small set of standard, locally developed Perl libraries. It's an edifying experience, and I can understand why some colleagues like Python so much. Again, thanks for the help, it's appreciated. Hook From tarun.kap at gmail.com Tue Apr 29 09:56:24 2008 From: tarun.kap at gmail.com (TkNeo) Date: Tue, 29 Apr 2008 06:56:24 -0700 (PDT) Subject: SSL through python. possible ? Message-ID: I need to do SSL file transfer using python? Is there a library i can use ? Thanks. From gagsl-py2 at yahoo.com.ar Mon Apr 28 02:09:12 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 28 Apr 2008 03:09:12 -0300 Subject: Loading associated files References: <74862697-da58-4eb7-8d60-09aaef54b7ad@j22g2000hsf.googlegroups.com> <09337541-0b3e-4aaf-b26f-06a0f689e7dc@u12g2000prd.googlegroups.com> <850a01c2-d59e-4ee7-a344-796fd3cbb8aa@v23g2000pro.googlegroups.com> Message-ID: En Sun, 27 Apr 2008 19:13:06 -0300, escribi?: > No you didnt misunderstand the situation, i think i have confused > matters though!! When Ive got it working my program will read the data > within the file. But obviously for it to do that it needs to know > where the file is, hence the whole discussion. However to test things After reading the thread I'm confused as well. Try using an installer (like InnoSetup) to install your application. It can handle the .xyz registry stuff for you, among other things. -- Gabriel Genellina From tjreedy at udel.edu Fri Apr 4 21:31:57 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 4 Apr 2008 21:31:57 -0400 Subject: having list attribute to track max size References: Message-ID: wrote in message news:f4fe2704-92fd-4fee-a2a9-98d2edcc5a5d at o1g2000pra.googlegroups.com... | Lets say I have a dynamic list class (may be extended from list), | where I add and remove items during program. | a = [] | a.append(1) | .... | | I am trying to find is there easy way keep track of 'maximum size of | list reached" | so for example len(a) goes from 0->3->4->3 | If I call a.max_size_ever(), I will get 4 Here is a start: >>> class mlist(list): def __init__(self,it): list.__init__(self,it) self.maxlen = len(self) >>> ll = mlist((1,2,3)) >>> ll.maxlen 3 Now, add methods for the list grow methods (.append, .extend, and .__setslice__) which follow a call to the parent method with self.maxlen = max(self.maxlen, len(self)) # or equivalent code tjr From balta96428 at gmail.com Wed Apr 23 05:53:45 2008 From: balta96428 at gmail.com (balta96428 at gmail.com) Date: Wed, 23 Apr 2008 02:53:45 -0700 (PDT) Subject: serials and keygens Message-ID: serials and keygens http://cracks.12w.net F R E E C R A C K S From steve at holdenweb.com Thu Apr 17 14:07:18 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 17 Apr 2008 14:07:18 -0400 Subject: Prob. w/ Script Posting Last Value In-Reply-To: <4dc0cfea0804170922n2a96be20sc424a7e67742a12e@mail.gmail.com> References: <4dc0cfea0804170922n2a96be20sc424a7e67742a12e@mail.gmail.com> Message-ID: <480791D6.4000802@holdenweb.com> Victor Subervi wrote: > Hi; > Gabriel provided a lovely script for showing images which I am modifying > for my needs. I have the following line: > > print '

\n' % (d, y) > where the correct values are entered for the variables, and those values > increment (already tested). Here is the slightly modified script it calls: > > > #!/usr/local/bin/python > import cgitb; cgitb.enable() > import MySQLdb > import cgi > form = cgi.FieldStorage() > picid = int(form["id"].value) > x = int(form["x"].value) > pic = str(x) > print 'Content-Type: text/html' > db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > cursor= db.cursor() > sql = "select " + pic + " from products where id='" + str(picid) + "';" > cursor.execute(sql) > content = cursor.fetchall()[0][0].tostring() > cursor.close() > print 'Content-Type: image/jpeg\r\nContent-Length: %s\n' % len(content) > print content > > I need to make it so that it will show all my images, not just the last > one. Suggestions, please. > TIA, > Victor > In your "page generator" page, replace print '

\n' % (d, y) by for d, y in (results of some DB query to get d and y for each image): print '

\n' % (d, y) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gagsl-py2 at yahoo.com.ar Mon Apr 21 01:15:11 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 02:15:11 -0300 Subject: MySQL hardcoding? References: <20080417194149.eddefdc8.marexposed@googlemail.com> Message-ID: En Thu, 17 Apr 2008 15:41:49 -0300, escribi?: > I've got this error (see the path in last line) > > db=MySQLdb.connect(host='localhost',use_unicode = True, charset = "Windows-1251",user='root',passwd='12',db='articulos') > OperationalError: (2019, "Can't initialize character set Windows-1251 (path: C:\\mysql\\\\share\\charsets\\)") > > The truth of the matter is, MySQL is not installed in that path, but into Program Files. > I don't know where the hardcoding is, but it is certainly somewhere. Except MySQL is reporting a wrong installation path. > I haven't found any other topic in the list about this problem. Looks like a configuration problem in MySQL itself, unrelated to Python. See the my.ini file in MySQL installation directory. -- Gabriel Genellina From bj_666 at gmx.net Wed Apr 2 14:11:15 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 2 Apr 2008 18:11:15 GMT Subject: non-terminating regex match References: Message-ID: <65i0i3F2embp3U2@mid.uni-berlin.de> On Wed, 02 Apr 2008 16:01:59 +0000, Maurizio Vitale wrote: > And yes, I'm a total beginner when it comes to Python, but it seems > very strange to me that a regex match on a finite length string > doesn't terminate It does terminate, you just don't wait long enough. Try it with fewer characters and then increase the identifier character by character and watch the time of the runs grow exponentially. Ciao, Marc 'BlackJack' Rintsch From damonwischik at gmail.com Fri Apr 18 22:18:12 2008 From: damonwischik at gmail.com (damonwischik at gmail.com) Date: Fri, 18 Apr 2008 19:18:12 -0700 (PDT) Subject: How to print a unicode string? References: Message-ID: On Apr 19, 12:38 am, Damon Wischik wrote: > I'd like to print out a unicode string. > > I'm running Python inside Emacs, which understands utf-8, so I want to > force Python to send utf-8 to sys.stdout. Thank you everyone who was sent suggestions. Here is my solution (for making Python output utf-8, and persuading Emacs 22.2.1 with python- mode to print it). 1. Set the registry key HKEY_CURRENT_USER\Software\GNU\Emacs\Home to have value "d:\documents\home". This makes Emacs look for a .emacs file in this directory (the home directory). 2. Put a file called .emacs file in the home directory. It should include these lines: (setenv "PYTHONPATH" "d:/documents/home") (prefer-coding-system 'utf-8) The first line means that python will look in my home directory for libraries etc. The second line tells Emacs to default to utf-8 for its buffers. Without the second line, Emacs may default to a different coding, and it will not know what to do when it receives utf-8. 3. Put a file called sitecustomize.py in the home directory. This file should contain these lines: import codecs import sys sys.stdout = codecs.getwriter("UTF-8")(sys.stdout) 4. Now it should all work. If I enter print u'La Pe\xf1a' then it comes out with a n-tilde. NB. An alternative solution is to edit site.py in the Python install directory, and replace the line encoding = "ascii" # Default value set by _PyUnicode_Init() with encoding = 'utf8' But the trouble with this is that it will be overwritten if I install a new version of Python. NB. I also have these lines in my .emacs file, to load python-mode, and to make it so that ctrl+enter executes the current paragraph: ; Python file association (load "c:/program files/emacs-plugins/python-mode-1.0/python-mode.el") (setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist)) (setq interpreter-mode-alist (cons '("python" . python-mode) interpreter-mode-alist)) (autoload 'python-mode "python-mode" "Python editing mode." t) ; Note: the command for invoking Python is specified at the end, ; as a custom variable. ;; DJW's command to select the current paragraph, then execute-region. (defun py-execute-paragraph (vis) "Send the current paragraph to Python Don't know what vis does." (interactive "P") (save-excursion (forward-paragraph) (let ((end (point))) (backward-paragraph) (py-execute-region (point) end )))) (setq py-shell-switch-buffers-on-execute nil) (global-set-key [(ctrl return)] 'py-execute-paragraph) (custom-set-variables ;; custom-set-variables was added by Custom -- don't edit or cut/ paste it! ;; Your init file should contain only one such instance. '(py-python-command "c:/program files/Python25/python.exe")) Damon. From deets at nospam.web.de Fri Apr 11 13:03:25 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 11 Apr 2008 19:03:25 +0200 Subject: Multiple independent Python interpreters in a C/C++ program? In-Reply-To: References: Message-ID: <669jv8F2jrimvU1@mid.uni-berlin.de> skip at pobox.com schrieb: > This question was posed to me today. Given a C/C++ program we can clearly > embed a Python interpreter in it. Is it possible to fire up multiple > interpreters in multiple threads? For example: > > C++ main > thread 1 > Py_Initialize() > thread 2 > Py_Initialize() > > Do I wind up with two completely independent interpreters, one per thread? > I'm thinking this doesn't work (there are bits which aren't thread-safe and > are only protected by the GIL), but wanted to double-check to be sure. AFAIK there was a thread a few month ago that stated that this is actually possible - but mostly 3rd-party-c-extension aren't capable of supporting that. Martin von Loewis had a word in that, maybe googling with that in mind reveals the discussion. And of course its a *bad* idea to pass objects between threads... Diez From parnell.s at comcast.net Sun Apr 27 15:34:25 2008 From: parnell.s at comcast.net (Ixiaus) Date: Sun, 27 Apr 2008 12:34:25 -0700 (PDT) Subject: Python equivalent to PHP's SPL __autoload() ?? Message-ID: <5bfb3fa2-652c-4ce5-b914-27ef21685c33@p25g2000pri.googlegroups.com> I was curious (and have spent an enormous amount of time on Google trying to answer it for myself) if Python has anything remotely similar to PHP's SPL __autoload() for loading classes on the fly?? After digging through docs I feel doubtful there is such a language feature, but, it is possible I missed something or maybe someone has written an extension?!? Thanks in advance! From hotani at gmail.com Wed Apr 23 14:45:42 2008 From: hotani at gmail.com (hotani) Date: Wed, 23 Apr 2008 11:45:42 -0700 (PDT) Subject: python-ldap: searching without specifying an OU? References: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> <58546d42-bc80-4f9d-be90-e184c312e2d1@k37g2000hsf.googlegroups.com> <0ke3e5-ccc.ln1@nb2.stroeder.com> <8ef38281-a6fe-4501-b711-a24cd9f35a24@t54g2000hsg.googlegroups.com> Message-ID: <0bbac44a-5d11-4e27-829d-ad2b2de62210@x35g2000hsb.googlegroups.com> This fixed it! http://peeved.org/blog/2007/11/20/ By adding this line after 'import ldap', I was able to search from the root level: ldap.set_option(ldap.OPT_REFERRALS, 0) From ed at leafe.com Tue Apr 1 09:31:26 2008 From: ed at leafe.com (Ed Leafe) Date: Tue, 1 Apr 2008 08:31:26 -0500 Subject: class super method In-Reply-To: References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> Message-ID: On Apr 1, 2008, at 7:23 AM, brooklineTom at gmail_spam_blocking_suffix.com wrote: > I've also found myself wondering: > > 1. What are the two arguments to super used for? To determine the type (1st arg) for which the superclass hierarchy is to be determined, and the instance (2nd arg) if the super object is to be bound. In typical usage, they are the class of the current instance, and the 'self' reference to the instance. > 2. What happens when the method supplied *after* the super is > different from the containing method? > > In the above example what happens if: > > class DaboUIClass(dabo.ui.dControlMixin, someWxPythonClass): > def __init__(self, *args, **kwargs): > doOurCustomStuffBeforeTheSuperCall() > super(DaboUIClass, self).callRandomMethod(foobar) > doOurCustomStuffAfterTheSuperCall() super() returns an object that doesn't "know" in what method it was derived, so as long as the superclass has the 'callRandomMethod' method, and 'foobar' is defined, there is no problem at all. IOW, the only context is the class of the instance, not any particular method of the instance. You could also do something like this: class DaboUIClass(dabo.ui.dControlMixin, someWxPythonClass): def __init__(self, *args, **kwargs): doOurCustomStuffBeforeTheSuperCall() self.super = super(DaboUIClass, self) self.super.__init__(*args, **kwargs) doOurCustomStuffAfterTheSuperCall() def someMethod(self, foo, bar): self.super.someMethod(foo, bar) def someOtherMethod(self): self.super.someOtherMethod() -- Ed Leafe From haxier at gmail.com Thu Apr 3 03:10:26 2008 From: haxier at gmail.com (haxier) Date: Thu, 3 Apr 2008 00:10:26 -0700 (PDT) Subject: Python for low-level Windows programming Message-ID: Hi all I've some experience with Python in desktop apps, but now I'm looking to code a tool like Kee-Pass[1] which must have access to some low- level primitives in a windows environment: hooks when windows are displayed, automatic form fill, and so on in a variety of scenarios (desktop apps, web-based apps, citrix...) Is this possible without too much pain? I know I can code it with C# or C++ but tha'ts a road to avoid, if possible. Thanks [1] http://sourceforge.net/projects/keepass From laurent.pointal at laposte.net Tue Apr 15 16:45:56 2008 From: laurent.pointal at laposte.net (Laurent Pointal) Date: 15 Apr 2008 20:45:56 GMT Subject: webcam (usb) access under Ubuntu References: Message-ID: <48051403$0$875$ba4acef3@news.orange.fr> Le Tue, 15 Apr 2008 05:21:54 -0700, Berco Beute a ?crit?: > I've been trying to access my webcam using Python, but I failed > miserably. The camera works fine under Ubuntu (using camora and skype), > but I am unable to get WebCamSpy or libfg to access my webcam. > > First I tried webcamspy (http://webcamspy.sourceforge.net/). That > requires pySerial and pyParallel, and optionally pyI2C. Runing WebCamSpy > results in: > > Exception exceptions.AttributeError: "Parallel instance has no attribute > '_fd'" in > ignored > > This seems to come from importing I2C. The application window opens, but > there's an error message: > > NO VIDEO SOURCE FOUND > > Next I tried libfg (http://antonym.org/libfg). I built it, made the > Python bindings and installed it. Unfortunately the following: > >>>>import fg >>>>grabber = fg.Grabber() > > results in: > > fg_open(): open video device failed: No such file or directory > > Since the camera works fine in Ubuntu itself my guess is that the > problem is with the python libraries (or even likelier, my usage of > them). Is there anybody here that was successful in accessing their > webcam on linux using Python? Else I have to reside to Windows and > VideoCapture (which relies on the win32 api and thus is Windows-only), > something I'd rather not do. > > Thanks for any help, I dont know if this resolve your problem, but to get snapshots from a camera under linux, using V4L2 API, I wrote a small wrapper around this API. Its called pyvideograb, and its here: http://laurent.pointal.org/python/projets/pyvideograb/index.pih Note: there is no automatic thing in this library, just a wrapper to V4L2, so you must know what options and image format your camera support and use these (you may have to convert image by yourself - see PIL and Numpy for quick data processing functions). To find the supported options you can use xawtv and give it ad-hoc cli option to make it verbose. A+ Laurent. -- Laurent POINTAL - laurent.pointal at laposte.net From medin0065 at gmail.com Sun Apr 20 10:46:30 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:46:30 -0700 (PDT) Subject: active camera crack Message-ID: <3275425d-9867-42d2-a4b4-62f8f131f420@p25g2000pri.googlegroups.com> active camera crack http://cracks.00bp.com F R E E C R A C K S From gatti at dsdata.it Sat Apr 12 12:32:03 2008 From: gatti at dsdata.it (Lorenzo Gatti) Date: Sat, 12 Apr 2008 09:32:03 -0700 (PDT) Subject: str(bytes) in Python 3.0 References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> <806cf1da-8f06-4fff-8437-7f1ca1ff9472@k10g2000prm.googlegroups.com> Message-ID: On Apr 12, 5:51 pm, Kay Schluehr wrote: > On 12 Apr., 16:29, Carl Banks wrote: > > > > And making an utf-8 encoding default is not possible without writing a > > > new function? > > > I believe the Zen in effect here is, "In the face of ambiguity, refuse > > the temptation to guess." How do you know if the bytes are utf-8 > > encoded? > > How many "encodings" would you define for a Rectangle constructor? > > Making things infinitely configurable is very nice and shows that the > programmer has worked hard. Sometimes however it suffices to provide a > mandatory default and some supplementary conversion methods. This > still won't exhaust all possible cases but provides a reasonable > coverage. There is no sensible default because many incompatible encodings are in common use; programmers need to take responsibility for tracking ot guessing string encodings according to their needs, in ways that depend on application architecture, characteristics of users and data, and various risk and quality trade-offs. In languages that, like Java, have a default encoding for convenience, documents are routinely mangled by sloppy programmers who think that they live in an ASCII or UTF-8 fairy land and that they don't need tight control of the encoding of all text that enters and leaves the system. Ceasing to support this obsolete attitude with lenient APIs is the only way forward; being forced to learn that encodings are important is better than, say, discovering unrecoverable data corruption in a working system. Regards, Lorenzo Gatti From watches0802 at global-replica-watch.com Sat Apr 19 06:17:49 2008 From: watches0802 at global-replica-watch.com (watches0802 at global-replica-watch.com) Date: Sat, 19 Apr 2008 03:17:49 -0700 (PDT) Subject: Mondaine Women's Railway watch #A669.30305.11SBC - Replica Watch Fake Message-ID: Mondaine Women's Railway watch #A669.30305.11SBC - Replica Watch Fake Mondaine Women's Railway watch #A669.30305.11SBC Link : http://www.watchesprice.net/Replica-Mondaine-10291.html Replica Watches Home : http://www.watchesprice.net/ Replica Mondaine Brands : http://www.watchesprice.net/Mondaine-Replica.html Replica Mondaine Women's Railway watch #A669.30305.11SBC --- one of best selling replica watches, it is crafted in high quality, please click image 'buy now' to buy this chic but inexpensive replica to save you a lot of money . Mondaine Women's Railway watch A669.30305.11SBC Description: Swiss quartz movement, Casual watch, Black hands and hour markers, Black indices, Analog date display, Polished stainless steel silver- tone bezel, case, crown and caseback, 30 meters/100 feet water resistant Mondaine Women's Railway watch A669.30305.11SBC Details: Brand: Mondaine Model: A669.30305.11SBC Dimensions: .7 pounds Dial color: Polished stainless steel silver-tone case, White Water-resistant to 30 meters Thank you for choosing www.watchesprice.net as your reliable dealer of quality waches including Mondaine Women's Railway watch #A669.30305.11SBC . we guarantee every watch you receive will be exact watch you ordered. Each watch sold enjoy one year Warranty for free repair. Every order from aaa-replica-watches is shipped via EMS, the customer is responsible for the shipping fee on the first order, but since the second watch you buy from our site, the shipping cost is free. Please note that If the total amount of payment is over $600(USD), the customer is required to contact our customer service before sending the money in case failed payment. If you have any other questions please check our other pages or feel free to email us by service at watchesprice.net. Cheapest Mondaine Women's Railway watch #A669.30305.11SBC The Same Mondaine Series : Mondaine - A6693031111SBB (Size: women) : http://www.watchesprice.net/Replica-Mondaine-10292.html Mondaine A6873030814sbb Line Extension Unisex Watch : http://www.watchesprice.net/Replica-Mondaine-10293.html Mondaine - A6903030814SBB (Size: men) : http://www.watchesprice.net/Replica-Mondaine-10294.html Mondaine A6873030811sbb Line Extension Unisex Watch : http://www.watchesprice.net/Replica-Mondaine-10295.html Mondaine A6663032214sbb Line Extension Unisex Watch : http://www.watchesprice.net/Replica-Mondaine-10296.html Mondaine Men's Railways watch #A669.30308.64SBB : http://www.watchesprice.net/Replica-Mondaine-10297.html Mondaine Men's Railway watch #A660.30303.14SBB : http://www.watchesprice.net/Replica-Mondaine-10298.html Mondaine Men's Watches Specials A658.30300.11GEB - 5 : http://www.watchesprice.net/Replica-Mondaine-10299.html From fredrik at pythonware.com Sat Apr 5 07:23:36 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 13:23:36 +0200 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> Message-ID: llothar wrote: > I ship an application that compiles an python interpreter and > extension on a remote system. > It also needs to copy this created items around. So if i use setup.py > to create an > extension i need to know the file name of the generated file. so why not just ask setup.py to copy the files for you? you can either use "install" with the --home option to copy all the files to a given directory, or create a binary kit with "bdist" and unpack the resulting archive at the target location. > Unfortunately as pointless as the answers i got so far. well, cutting the "I'm not going to tell you why I need to know this" stuff might help people come up with solutions to your actual problem instead of posting stuff that's informative but misses the point. From paul at boddie.org.uk Mon Apr 21 11:17:04 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Mon, 21 Apr 2008 08:17:04 -0700 (PDT) Subject: Python "make" like tools (was Re: [ANN] DoIt 0.1.0 Released (build tool)) References: Message-ID: On 21 Apr, 16:51, "Ville M. Vainio" wrote: > > Wouldn't it be more convenient to provide syntax like this: > > @task("create_build_folder") > @depend("dep1 some_other_dep") > def buildf(): > buildFolder = jsPath + "build" > create_folder(buildFolder) I'd want to make the "grunt work" a bit easier before breaking out the decorators. > I find the doit syntax a bit cumbersome, especially as you can avoid > 'args' by just returning a lamda in 'action'. > > I've looked around a bit for python "make" replacement, but there does > not seem to be a simple & straightforward solution around (read - > straight-python syntax, one .py file installation, friendly license). Have you surveyed the landscape...? http://wiki.python.org/moin/ConfigurationAndBuildTools I'm inclined to think that Waf would probably meet your requirements: http://code.google.com/p/waf/ Paul From skanemupp at yahoo.se Tue Apr 15 16:45:08 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Tue, 15 Apr 2008 13:45:08 -0700 (PDT) Subject: tkinter, event.widget, what do i get? Message-ID: <7caa5089-2ea9-4e18-9117-7431d7403976@l42g2000hsc.googlegroups.com> when calling function hmm here, what do i get? the widget i clicked on? if i have a canvs on wich i have a bitmap and i click on the bitmap, is the event.widget then the bitmap? can i get info about the bitmap then? like color of the pixel i clicked. if so, how? w.bind("", key) w.bind("", hmm) def hmm(event): return event.widget From woodham at cs.ubc.ca Fri Apr 25 20:01:48 2008 From: woodham at cs.ubc.ca (Bob Woodham) Date: Sat, 26 Apr 2008 00:01:48 +0000 (UTC) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> <426812d7-c217-4bfc-81b0-47ba0638a650@k13g2000hse.googlegroups.com> <74415ef0-e395-4a31-90eb-e2645a65d464@e39g2000hsf.googlegroups.com> Message-ID: On 2008-04-24, Istvan Albert wrote: > On Apr 23, 2:08 pm, Bob Woodham wrote: > >> x = x++; >> >> has unspecified behaviour in C. That is, it is not specified >> whether the value of x after execution of the statement is the >> old value of x or one plus the old value of x. > > unspecified means that the result could be anything: old value, old > value+1, -2993882, "trallalla", core dump, stack overflow etc... One would certainly hope there are only two possible results, the old value of x or the incremented value of x. I first encountered this issue with a C compiler that produced one of those two results differently depending on the level of optimization requested. (Ultimately, it boiled down to the issue of whether the compiler allocated x to a register or as a standard memory reference). Rather than it being a bug, I was surprised to discover that the C compiler had not, in fact, violated the ANSI C standard. Note that x can be a pointer of arbitrary type. Thus, it is not beyond the realm of possibilty that a result different from what the programmer expected might indeed produce, in the end, -2993882, "trallalla", core dump, stack overflow etc... I don't have a copy of the ISO/ANSI C spec at hand. Harbison and Steele, Jr., "C a Reference Manual (4th ed)," section 7.12.1, page 228, state, "In ISO C, if a single object is modified more than once between successive sequence points, the result is undefined." Assuming Harbison and Steele quote the 1990 spec correctly, the word I should have used is "undefined." Can you live with that? Aside: Yes, the issue is that x = x++; modifies the single object x more than once between successive sequence points. From gherron at islandtraining.com Wed Apr 16 04:38:18 2008 From: gherron at islandtraining.com (Gary Herron) Date: Wed, 16 Apr 2008 01:38:18 -0700 Subject: Can't see variables declared as global in a function In-Reply-To: <175C22B8-EE9B-4FC2-BDB0-F1DC7EFD5F60@gmail.com> References: <175C22B8-EE9B-4FC2-BDB0-F1DC7EFD5F60@gmail.com> Message-ID: <4805BAFA.8050307@islandtraining.com> Jacob Davis wrote: > Hi. > > I have a hundred lines of code in a module that declare some global > variables inside a function so that those variables can be used by > other functions. I want to import this module so that I can more > easily debug by looking at the value of individual variables. But > when I try to reach these variables, I get a warning that they are not > defined. > > I am on an Intel Mac running Leopard 10.5.2, Python 2.5 > > Here is an example of some code that has the same problem: > > > > > #!/usr/bin/env python > > global isglobal > isglobal=200 > > def somefunc(): > global from_somefunc > from_somefunc=5 > > def anotherfunc(): > return from_somefunc+30 > > > > > So during debugging I want to look at the variable from_somefunc > > here is my terminal output. I start by looking at dir(), then > run somefunc(), then run anotherfunc(), then I want to look > at from_somefunc but I get a warning: Yuck, YUCK, YUCK! You are breaking *so* many good-programming-practices, I hardly know where to start. First off: A python global is not what you think. There are *no* program wide globals. There are only module wide globals. Also, the "global isglobal" is absolutely meaningless as anything declared there is a (module level) global by definition. SO... Your from_somefunc is a global variable in module test_vars, but you are trying to access it from your main module (the interactive session). The fact that you did "from test_vars import *" isn't going to fix this, because at the time you did the import, from_somefunc was not defined ad so was not imported by the "*". You could just "import test_vars", and then after calling your function test_vars.somefunc(), you would find that test_vars.from_somefunc would be defined. BUT... DON'T DO THAT! A better way: (It is still slightly dubious, but it is much more straightforward, and does not use the global statement.) Define your vars.py module: isglobal=200 # and nothing else And from your main program, import vars print vars.isglobal # will print 200 vars.from_somefunc = 5 # will define and set a global in vars print vars.from_somefunc+30 # retrieves a global value from vars As I said above this is still slightly dubious. Better solutions would probably involve creating a class with each of your huindred variables as attributes of the class, or a class, each instance of which has the hundred variables, or ... whatever. To give you better advice, we'd have to know more about what problem you are trying to solve. If you really getters and setters (that's what we might call somefucn and anotherfunc) then you really should be using a class to contain all the hundred variables, and define getter/setter methods for them. Gary Herron > > > > Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) > [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > >>> from test_vars import * > >>> dir() > ['__builtins__', '__doc__', '__name__', 'anotherfunc', 'isglobal', > 'somefunc'] > >>> somefunc() > >>> anotherfunc() > 35 > >>> isglobal > 200 > >>> from_somefunc > Traceback (most recent call last): > File "", line 1, in > NameError: name 'from_somefunc' is not defined > >>> dir() > ['__builtins__', '__doc__', '__name__', 'anotherfunc', 'isglobal', > 'somefunc'] > > > > Is there a way that I can view from_somefunc? > > Thanks, > > Jake > From robert.kern at gmail.com Thu Apr 10 17:43:25 2008 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 10 Apr 2008 16:43:25 -0500 Subject: get array element In-Reply-To: <820d8589-8529-46af-907a-90ebaac4a6f5@a22g2000hsc.googlegroups.com> References: <820d8589-8529-46af-907a-90ebaac4a6f5@a22g2000hsc.googlegroups.com> Message-ID: Bryan.Fodness at gmail.com wrote: > I have an array, and I would like to get the indice value. > > a = array([13,14,15,16]) > > I would like something like a.getindice(15) > > If I want 15 it would return 2 You will want to ask numpy questions on the numpy mailing list. If you don't mention that you are using numpy here, people get confused. http://www.scipy.org/Mailing_Lists Anyways, if your array is sorted, use a.searchsorted(15). If it isn't sorted, then you can find all of the indices equal to the value with the following: In [7]: from numpy import * In [8]: a = array([13,14,15,16]) In [9]: nonzero(a == 15)[0] Out[9]: array([2]) -- 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 From marco at sferacarta.com Tue Apr 1 06:00:12 2008 From: marco at sferacarta.com (Marco Mariani) Date: Tue, 01 Apr 2008 12:00:12 +0200 Subject: [OT] troll poll In-Reply-To: References: Message-ID: Daniel Fetchinson wrote: > This is a quick poll to have scientific data on our beloved troll community: > > Whose trolling behaviour is more professional? (check one) You forgot to mention Ilias Lazaridis. He needs to be Analyzed and Evaluated, too. From paulgeeleher at gmail.com Tue Apr 1 10:03:32 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Tue, 1 Apr 2008 07:03:32 -0700 (PDT) Subject: Copy Stdout to string Message-ID: Hi, I'm wondering if its possible to copy all of stdout's output to a string, while still being able to print on screen. I know you can capture stdout, but I still need the output to appear on the screen also... Thanks! From stefan_ml at behnel.de Sun Apr 20 10:20:54 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sun, 20 Apr 2008 16:20:54 +0200 Subject: codec for html/xml entities!? In-Reply-To: <2ohm04hm4sk0rn019tk1ntrii74hu8ajdo@4ax.com> References: <48084C97.4040400@behnel.de> <2ohm04hm4sk0rn019tk1ntrii74hu8ajdo@4ax.com> Message-ID: <480B5146.1070605@behnel.de> Martin Bless wrote: > [Stefan Behnel] wrote & schrieb: >>> def entity2uc(entity): >>> """Convert entity like { to unichr. >>> >>> Return (result,True) on success or (input string, False) >>> otherwise. Example: >>> entity2cp('€') -> (u'\u20ac',True) >>> entity2cp('€') -> (u'\u20ac',True) >>> entity2cp('€') -> (u'\u20ac',True) >>> entity2cp('&foobar;') -> ('&foobar;',False) >>> """ >> Is there a reason why you return a tuple instead of just returning the >> converted result and raising an exception if the conversion fails? > > Mainly a matter of style. When I'll be using the function in future > this way it's unambigously clear that there might have been > unconverted entities. But I don't have to deal with the details of how > this has been discovered. And may be I'd like to change the algorithm > in future? This way it's nicely encapsulated. The normal case is that it could be replaced, and it is an exceptional case that it failed, in which case the caller has to deal with the problem in one way or another. You are making the normal case more complicated, as the caller *always* has to check the result indicator to see if the return value is the expected result or something different. I don't think there is any reason to require that, except when the conversion really failed. Stefan From gagsl-py2 at yahoo.com.ar Tue Apr 22 13:26:01 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 22 Apr 2008 14:26:01 -0300 Subject: Spawing a thread and printing dots until it finishes References: Message-ID: En Tue, 22 Apr 2008 13:32:38 -0300, sophie_newbie escribi?: > On Apr 22, 4:41 pm, "D'Arcy J.M. Cain" wrote: >> On Tue, 22 Apr 2008 07:10:07 -0700 (PDT) >> sophie_newbie wrote: >> > import threading >> > class MyThread ( threading.Thread ): >> > def run ( self ): >> > myLongCommand()... >> >> > import time >> >> > t = MyThread() >> > t.start() >> >> > while t.isAlive(): >> > print "." >> > time.sleep(.5) >> >> > print "OK" >> >> > The thing is this doesn't print a dot every half second. It just >> > pauses for ages until the thread is finished and prints prints ".OK". >> > But if I take out the "time.sleep(.5)" line it will keep printing dots >> > really fast until the thread is finished. So it looks like its the >> > time.sleep(.5) bit that is messing this up somehow? >> >> We know that your main routine gives up the processor but without a >> full definition of MyThread how do we know that it ever does? I > > "myLongCommand()... " is a call to an function in R (the statistical > programming language) via Rpy (A python module that allows calls to > R). The call takes a couple of minutes to execute. I'm trying to build > a web front end to this R function and instead of the user looking at > a blank screen for 2-3 mins, I want to print dots to let them feel > like the program isn't hanging. > > What I am saying is that without the "time.sleep(.5)" line, the above > code will print dots on the screen continuously for 2-3 mins, filling > it up with a ridiculous ammount of dots. > > Whereas with the time.sleep line, instead of pausing for half a second > between dots, its seems to print, as you correctly pointed out: > > . > OK > > With a pause of 2-3 minutes between the . and the OK. A possible explanation is that the RPy call does not release the GIL; once the main thread loses it due to sleep, it can never reacquire it again until the RPy call finishes. Try contacting the RPy author, or perhaps there is a specific mailing list for RPy questions. -- Gabriel Genellina From jarausch at skynet.be Mon Apr 28 11:26:05 2008 From: jarausch at skynet.be (Helmut Jarausch) Date: Mon, 28 Apr 2008 17:26:05 +0200 Subject: Regular Expression - Matching Multiples of 3 Characters exactly. In-Reply-To: References: Message-ID: <4815ec8e$0$2994$ba620e4c@news.skynet.be> blaine wrote: > Hey everyone, > For the regular expression gurus... > > I'm trying to write a string matching algorithm for genomic > sequences. I'm pulling out Genes from a large genomic pattern, with > certain start and stop codons on either side. This is simple > enough... for example: > > start = AUG stop=AGG > BBBBBBAUGWWWWWWAGGBBBBBB > > So I obviously want to pull out AUGWWWWWWAGG (and all other matches). > This works great with my current regular expression. > > The problem, however, is that codons come in sets of 3 bases. So > there are actually three different 'frames' I could be using. For > example: > ABCDEFGHIJ > I could have ABC DEF GHI or BCD EFG HIJ or CDE FGH IJx.... etc. > > So finally, my question. How can I represent this in a regular > expression? :) This is what I'd like to do: > (Find all groups of any three characters) (Find a start codon) (find > any other codons) (Find an end codon) > > Is this possible? It seems that I'd want to do something like this: (\w > \w\w)+(AUG)(\s)(AGG)(\s)* - where \w\w\w matches EXACTLY all sets of > three non-whitespace characters, followed by AUG \s AGG, and then > anything else. I hope I am making sense. Obviously, however, this > will make sure that ANY set of three characters exist before a start > codon. Is there a way to match exactly, to say something like 'Find > all sets of three, then AUG and AGG, etc.'. This way, I could scan > for genes, remove the first letter, scan for more genes, remove the > first letter again, and scan for more genes. This would > hypothetically yield different genes, since the frame would be > shifted. > As an alternative - if you do need speed - have a look at http://www.egenix.com/products/python/mxBase/mxTextTools/ Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany From rbrito at ime.usp.br Mon Apr 28 16:56:36 2008 From: rbrito at ime.usp.br (=?ISO-8859-1?Q?Rog=E9rio_Brito?=) Date: Mon, 28 Apr 2008 17:56:36 -0300 Subject: Little novice program written in Python References: <49249992-3634-4c5f-bd45-7ce4f1b32044@l17g2000pri.googlegroups.com> Message-ID: On 04/25/2008 05:00 AM, John Machin wrote: > On Apr 25, 5:44 pm, Robert Bossy wrote: >> If the OP insists in not examining a[0] and a[1], this will do exactly >> the same as the while version: >> >> for p in a[2:]: >> if p: >> print p > > ... at the cost of almost doubling the amount of memory required. Yes, despite the asymptotic consumption of memory being the same, the practical one is also a concern. And in my original version of that loop (sketched in paper) was a for loop, but with C syntax. -- Rog?rio Brito : rbrito@{mackenzie,ime.usp}.br : GPG key 1024D/7C2CAEB8 http://www.ime.usp.br/~rbrito : http://meusite.mackenzie.com.br/rbrito Projects: algorithms.berlios.de : lame.sf.net : vrms.alioth.debian.org From Robert.Bossy at jouy.inra.fr Wed Apr 30 03:11:35 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Wed, 30 Apr 2008 09:11:35 +0200 Subject: sed to python: replace Q In-Reply-To: <48180348$0$34534$742ec2ed@news.sonic.net> References: <48180348$0$34534$742ec2ed@news.sonic.net> Message-ID: <48181BA7.1030604@jouy.inra.fr> Raymond wrote: > For some reason I'm unable to grok Python's string.replace() function. > Just trying to parse a simple IP address, wrapped in square brackets, > from Postfix logs. In sed this is straightforward given: > > line = "date process text [ip] more text" > > sed -e 's/^.*\[//' -e 's/].*$//' > alternatively: sed -e 's/.*\[\(.*\)].*/\1/' > yet the following Python code does nothing: > > line = line.replace('^.*\[', '', 1) > line = line.replace('].*$', '') > > Is there a decent description of string.replace() somewhere? > In python shell: help(str.replace) Online: http://docs.python.org/lib/string-methods.html#l2h-255 But what you are probably looking for is re.sub(): http://docs.python.org/lib/node46.html#l2h-405 RB From python.list at tim.thechases.com Tue Apr 15 16:15:47 2008 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 15 Apr 2008 15:15:47 -0500 Subject: Recurring patterns: Am I missing it, or can we get these added to the language? In-Reply-To: References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: <48050CF3.5050802@tim.thechases.com> >> def nsplit(s,p,n): >> n -= 1 >> l = s.split(p, n) >> if len(l) < n: >> l.extend([''] * (n - len(l))) >> return l > > The split() method has a maxsplit parameter that I think does the same > thing. For example: > >>>> temp = 'foo,bar,baz' >>>> temp.split(',', 1) > ['foo', 'bar,baz'] The OP's code *does* use the maxsplit parameter of split() The important (and missing) aspect of the OP's code in your example is exercised when there are *fewer* delimited pieces than "n": >>> "a,b,c".split(',', 5) ['a', 'b', 'c'] >>> nsplit("a,b,c", ',', 5) ['a', 'b', 'c', '', ''] A few things I noticed that might "improve" the code: - cache len(l) though my understanding is that len() is an O(1) operation, so it may not make a difference - using "delim", "maxsplit", "results" instead of "p", "n" "l" to make it easier to read -setting default values to match split() def nsplit(s, delim=None, maxsplit=None): if maxsplit: results = s.split(delim, maxsplit) result_len = len(results) if result_len < maxsplit: results.extend([''] * (maxsplit - result_len) return results else: return s.split(delim) My suggestion would just be to create your own utils.py module that holds your commonly used tools and re-uses them -tkc From ivan.illarionov at gmail.com Sun Apr 13 07:56:31 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Sun, 13 Apr 2008 04:56:31 -0700 (PDT) Subject: C to python conversion References: Message-ID: On Apr 13, 7:58 am, "Gabriel Genellina" wrote: > En Sat, 12 Apr 2008 07:58:47 -0300, Michele Petrazzo > escribi?: > > > > > Hi all, > > I'm trying to translate a simple C code into a python + ctypes (where > > need), but I have some problems on char conversion. The code have > > to work on Linux and talk with the serial port. I think that the problem > > is that I don't translate correctly the strings. > > > C code: > > #define START 0x33 > > #define RETURN_START 0x22 > > #define ADDR 0x01 > > #define WRITE_CMD 0x03 > > #define ALL_CMD 0xFF > > ... > > char buf[10]; > > char buf_ret[10]; > > > buf[0]=0; > > buf[0]=START; > > buf[1]=ADDR; > > buf[2]=WRITE_CMD; > > > write(_fd, buf, 6); > > read(_fd,buf_ret,6); > > You don't even need ctypes. In C, `char` is a small integer: 'A' and the > number 65 are interchangeable. In Python, there are no chars but strings > of length 1, which are not the same thing as their ordinal integer. > The easiest way is to define those constants as strings instead: > > START = chr(0x33) > RETURN_START = chr(0x22) > ADDR = chr(0x01) > WRITE_CMD = chr(0x03) > ALL_CMD = chr(0xFF) > NUL = chr(0) > > buf = START + ADDR + WRITE_CMD + NUL + NUL + NUL > # I assume the buffer was initialized to NULs, because only 3 bytes > # are filled but 6 bytes are written. > os.write(_fd, buf) > buf_ret = os.read(_fd, 6) > > -- > Gabriel Genellina The easiest way is to use struct: START = 0x33 RETURN_START = 0x22 ADDR = 0x01 WRITE_CMD = 0x03 ALL_CMD = 0xFF buf = struct.pack('3b3x', START, ADDR, WRITE_CMD) os.write(_fd, buf) buf_ret = os.read(_fd, 6) And, definitely, no need for ctypes here. -- Ivan Illarionov From hdante at gmail.com Mon Apr 21 21:00:10 2008 From: hdante at gmail.com (hdante) Date: Mon, 21 Apr 2008 18:00:10 -0700 (PDT) Subject: Java or C++? References: Message-ID: <2eae6385-1257-48fc-b793-31d0225503ba@f36g2000hsa.googlegroups.com> Summarizing the discussion (and giving my opinions), here's an "algorithm" to find out what language you'll leard next: 1. If you just want to learn another language, with no other essential concern, learn Ruby. 2. If you want to learn another language to design medium to large size applications, considering market, jobs, etc., and the speed gains of static byte-compiled languages, learn Java or C#. 3. If you want to learn another language to design applications with speed gains, but you want that the transition be as smooth as possible and don't have market concerns (and with the possibility of taking another easy step later to reach step 2), learn Groovy (for the JMV) or Boo (for .NET). 4. If you want to develop applications but, for some special reason, you require native compilation (like speed requirements, embedded systems, etc.), learn C++ 5. If you want to develop system software, or just learn better how machines work, or understand better low level implementation aspects of software, learn C. 6. If you just want to speed-up your python programs or offer some special, system-specific or optimized behavior to your python applications, or you just want to complement your python knowledge, learn C. On Apr 21, 7:26 pm, Jorgen Grahn wrote: > On Mon, 21 Apr 2008 06:14:08 -0700 (PDT), NickC wrote: > > On Apr 15, 1:46 pm, Brian Vanderburg II > > wrote: > >> This will automatically call the constructors of any contained objects > >> to initialize the string. The implicit assignment operator > >> automatically performs the assignment of any contained objects. > >> Destruction is also automatic. When 'p1' goes out of scope, during the > >> destructor the destructor for all contained objects is called. > > > Yeah, C++ does try to be helpful, and all of those automatic copy > > constructor, assignment operator and destructor implementations screw > > up royally when confronted with pointers > > I think that those are newbie problems. The rules for those three > "default implementations" are simple and match what C does for > structs. Use the standard containers, make a habit of forbidding > copying of objects which make no sense copying, and remember the > "explicit" keyword, and you will rarely have problems with this. > > > (and being able to use > > pointers is basically the whole reason for bothering to write anything > > in C or C++ in the first place). > > Is it? I rarely use pointers in C++ as anything but a kind of > object reference, and mostly because I am forced to. > > I use C++ because it is an expressive language with static typing, > which has access to all the hundreds of libraries with a C API on my > (Unix) machine. And because it is fun to use. > > I use Python because it is an expressive language with dynamic typing, > which has access to the most important libraries with a C API on my > (Unix) machine. And because it is fun to use. > > > Code which relies on these default > > method implementations is almost certain to be rife with memory leaks > > and double-free bugs. So instead of being a convenience, they become a > > painfully easy way of writing code that silently does some very, very > > wrong things. > > I have worked with old code with those kinds of bugs. > > It's simple to check and fix. If a class has pointer members of the > Has-A type, the constructors, operator= and destructor have to handle > them (or be suppressed). If they don't, the code is broken. > > If you grasp the concept of invariants, it's hard to get wrong. An > object of type Foo has a number of valid states. You have to make sure > there are no ways to create a Foo which is in an invalid state, or > destroying one without cleaning up its state. The best way is usually > to construct it from members which make similar guarantees, e.g. the > standard containers. > > > Other things like methods (including destructors!) being non-virtual > > by default also make C++ code annoyingly easy to get wrong (without it > > obviously looking wrong). > > The other side of the coin is that you can write tiny classes in C++ > with *no overhead*. If my class Foo can be implemented as an integer, > it doesn't need to be slower or take more space than an integer. It > can have value semantics, live on the stack etc, like an integer. > > I assume Java programmers avoid such types, and I assume it decreases > type safety in their programs. > > Ok, it could have been the other way around so that there was a > "nonvirtual" keyword ... but on the other hand I use inheritance in > C++ about as often as in Python, i.e. almost never. > > > The whole design of C++ is riddled with premature optimisation of > > speed and memory usage in the default settings, instead of choosing > > safe defaults and providing concise ways of allowing the programmer to > > say "I know optimisation X is safe here, please use it". > > "Premature optimization" is a phrase which is always useful as a > weapon, isn't it? > > But yeah, I think we can agree about this, at least: when you program > in both Python and C++, it is painfully obvious that C++ never > sacrifices speed or correctness, and it is painfully obvious that the > programmer pays a price for this. Compare ... maybe, for example, the > C++ standard library's very detailed and general iterator and > algorithm concepts with things like Python's str.split and str.join. A > function which takes a list of strings plus a delimiter and returns a > string would be unthinkable in the C++ standard library. > > > That said, C++ code has one *huge* benefit over ordinary C code, which > > is scope-controlled deletion of objects, and the associated Resource- > > Acquisition-Is-Initialisation model. > > Yes, RAII is one big advantage over any other language I know of. > Compared to good old C, I can come up with many others. > > I was going to say something about C++ versus Java here, but the fact > is I haven't written more than a few pages of Java since it came out. > The language (or the culture around it) seems to want to isolate itself > from the rest of the world -- unlike C++ and Python. > > /Jorgen > > -- > // Jorgen Grahn \X/ snipabacken.se> R'lyeh wgah'nagl fhtagn! From xahlee at gmail.com Thu Apr 17 19:06:56 2008 From: xahlee at gmail.com (xahlee at gmail.com) Date: Thu, 17 Apr 2008 16:06:56 -0700 (PDT) Subject: get quote enclosed field in a line Message-ID: is there a simple way in perl, python, or awk/shell/pipe, that gets the user agent field in a apache log? e.g. the typical line is like this: 189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET / Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/ 5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13" "-" I want the part: "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv: 1.8.1.13) Gecko/20080311 Firefox/2.0.0.13". Thanks. Xah xah at xahlee.org ? http://xahlee.org/ ? From martin at v.loewis.de Sat Apr 26 21:08:58 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 27 Apr 2008 03:08:58 +0200 Subject: How do I say "Is this a function"? In-Reply-To: References: Message-ID: <4813D22A.8040902@v.loewis.de> > def f1(): > print "In f1" > > def f3(): > print "In f3" > > def others(): > print "In others" > > for i in xrange(1,3): > fct = "f%d()"%(i+1) > try: > exec fct > except: > others() I'd write that as for i in xrange(1,3): globals().get("f%d" % (i+1), others)() Regards, Martin From steve at holdenweb.com Fri Apr 11 14:35:13 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 11 Apr 2008 14:35:13 -0400 Subject: How is GUI programming in Python? In-Reply-To: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> Message-ID: Rune Strand wrote: > On Apr 10, 3:54 am, Chris Stewart wrote: > ... >> Next, what would you say is the best framework I should look into? >> I'm curious to hear opinions on that. > > GUI-programming in Python is a neanderthal experience. What one may > love with console scripts is turned upside-down. Projects like Boa > Constructor seemed to be a remedy, but is not developed. The Iron- > Pythonistas has a very promising RAD GUI-tool in the IronPython - > Studio, http://www.codeplex.com/IronPythonStudio - but if you're non- > Iron, only sorrow is left - unless you fancy creating GUI in a text- > editor. Something I consider waste of life. > wxDesigner. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From steve at holdenweb.com Thu Apr 17 09:40:09 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 17 Apr 2008 09:40:09 -0400 Subject: I just killed GIL!!! In-Reply-To: <48070970.70306@v.loewis.de> References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> Message-ID: Martin v. L?wis wrote: >> For the record, I am not complaining about that GIL. As I said, I >> understand and approve of why it's there. I am, however, complaining >> about attitude that if you want to be free of the GIL you're doing >> something wrong. > > If you _want_ to be free of the GIL, you are not _doing_ anything, and > that may or may not be wrong. If you are complaining about the GIL, > I think you are doing something wrong, because complaining doesn't > help progress at all. I think neither was the case in this thread - > the guy claimed that he actually did something about the GIL, and > now we are all waiting for him to also tell us what it is that he > did. I think it is somewhat wrong to not tell in the first place, > but this is free software, and choosing not to contribute isn't > inherently wrong. Maybe the guy is making fun of us; whether that > is wrong or not depends on your notion of humor. > I suspect rather that he is merely deluded. Time alone will tell - the OP is a fertile source of ideas, not all of them fully baked, shall we say. I agree that the coyness in not immediately revealing the technique is less than helpful, and increases my assessment that the assertion of having "killed the GIL" will turn out to be wrong. I'd love to be wrong about that, but the GIL *has* been the subject of extensive efforts to kill it over the last five years, and it has survived despite the best efforts of the developers. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From xdicry at gmail.com Tue Apr 15 01:35:25 2008 From: xdicry at gmail.com (Evan) Date: Mon, 14 Apr 2008 22:35:25 -0700 (PDT) Subject: How to make a "command line basd" interactive program? References: Message-ID: that's great, a custom shell is what I need. Thanks all Evan From alexelder at gmail.com Tue Apr 29 11:11:44 2008 From: alexelder at gmail.com (alexelder at gmail.com) Date: Tue, 29 Apr 2008 08:11:44 -0700 (PDT) Subject: Using Python to verify streaming tv/radio station links References: Message-ID: <2e6baf9b-09d3-430e-9e01-cd56ec6e1a33@t54g2000hsg.googlegroups.com> On Apr 29, 1:52 pm, don... at gmail.com wrote: > Hi guys. I've put together a website (http://worldwidemediaproject.com > ) that is a database of internet streaming tv/radio stations from > around the world. I have built the site with all users in mind. The > site should be Linux, Unix, Mac, Win, etc friendly as I do not hide > the actual stream link or force the user to use an embedded player to > view/listen to the streams. In fact, you can even download the streams > you like as a playlist that you can load into your player of choice > (and even a few PVR software plugins). > > In building the site, I have enabled the user to report stations that > are nonfunctional. In addition to this, I would like to automate the > checking of the links in the database as well as any user submitted > links. What I am wanting to do is to script this with a simple for > loop which would loop through a file containing the station stream > link as well as the station id. I'd like to pass each through some > kind of verification function and if a connection is made then the > stream is good and move on to the next. If the connection fails then > the stream is bad, I would like to add the station id to a file > containing all 'nonfunctional' streams that I can later automate to > flag the stations. > > Is there an easy way to use python to verify a stream exists? I've > done a little experimenting with sockets and was able to connect to my > usenet server and talk to it, but I don't really know what's involved > with connecting to streaming windows media, real media and winamp > servers or what to expect as far as connection status messages. I am > not unfamiliar with python, but I am far from an expert. If anyone > could give me a hand with this or give me a push in the right > direction I would greatly appreciate it! > > Many thanks! Hey! With regards checking feeds, look into urllib (maybe) and the httplib (definitely). They /could/ offer some sort of information regarding the activity of your feeds. Without knowing anything about the streaming protocols I wouldn't suggest my methods to necessarily be the most helpful. You could, at least [maybe], establish whether a feed is active if it can return a HTTP 200 response. If that's a sufficient check I would suggest that httplib is the place to start. Alex. From BrianVanderburg2 at aim.com Mon Apr 21 02:01:42 2008 From: BrianVanderburg2 at aim.com (Brian Vanderburg II) Date: Mon, 21 Apr 2008 02:01:42 -0400 Subject: Is massive spam coming from me on python lists? Message-ID: <480C2DC6.4050701@aim.com> I've recently gotten more than too many spam messages and all say Sender: python-list-bounces+my=email.address at python.org. I'm wondering if my mail list registration is now being used to spam myself and others. If so, sorry, but I'm not the one sending messages if other are getting them even though Sender seems to include my address (I'm not sure about mail headers so I don't know how From: is different than Sender:) Anyway, it seems to be a bunch of spam emails about cracks and stuff. Brian Vanderburg II From carbanancizpo at gmail.com Fri Apr 18 16:55:47 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:55:47 -0700 (PDT) Subject: manufacturing crack cocaine Message-ID: manufacturing crack cocaine http://cracks.12w.net F R E E C R A C K S From nick at stinemates.org Wed Apr 23 23:51:08 2008 From: nick at stinemates.org (Nick Stinemates) Date: Wed, 23 Apr 2008 20:51:08 -0700 Subject: Calling Python code from inside php In-Reply-To: <679hd5F2nj6csU1@mid.uni-berlin.de> References: <679e9oF2mti63U1@mid.uni-berlin.de> <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> <679hd5F2nj6csU1@mid.uni-berlin.de> Message-ID: <20080424035108.GA6029@deviL> > While I certainly prefer to use Python wherever I can, that does not mean > that there aren't cases where legacy systems or other constraints make this > impossible. If I have e.g. a type3-based website - "how on earth" should I > replace that with Python (without wasting a lot of time)? I don't understand how the 2 are mutually exclusive? You can have PHP and Python bindings installed on the same Apache server, unless I'm mistaken? -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From marco at sferacarta.com Thu Apr 3 06:03:40 2008 From: marco at sferacarta.com (Marco Mariani) Date: Thu, 03 Apr 2008 12:03:40 +0200 Subject: splitting an XML file on the basis on basis of XML tags In-Reply-To: References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> Message-ID: <0Y1Jj.9751$T35.2972@tornado.fastwebnet.it> Steve Holden wrote: >> the XML file is almost a TB in size... >> > Good grief. When will people stop abusing XML this way? Not before somebody writes a clever xmlfs for the linux kernel :-/ From tundra at tundraware.com Tue Apr 1 18:51:46 2008 From: tundra at tundraware.com (Tim Daneliuk) Date: Tue, 01 Apr 2008 17:51:46 -0500 Subject: Directed Graph Traversal In-Reply-To: <804682cb-2da6-4d85-83d4-c7425c498534@p25g2000hsf.googlegroups.com> References: <804682cb-2da6-4d85-83d4-c7425c498534@p25g2000hsf.googlegroups.com> Message-ID: bukzor wrote: > Can someone point me in the direction of a good solution of this? I'm > using it to construct a SQL query compiler, where each node is a table > and each edge is a join. I'm planning on using the NetworkX library if > possible. > https://networkx.lanl.gov/reference/networkx/ > > > Given a directed graph and a list of points in the graph, what is the > minimal subgraph that contains them all? It is preferable that the > subgraph is a tree. > > > A -- B -- C -- D > | | > E -- F > > > A, B, F => ABEF (or ABCF) > A, F, C => ABCF > A, E, D => ABCD > E > > Thanks! > --Buck This leaps to mind: http://en.wikipedia.org/wiki/Kruskal's_algorithm The implementation details are left to the reader ;) -- ---------------------------------------------------------------------------- Tim Daneliuk tundra at tundraware.com PGP Key: http://www.tundraware.com/PGP/ From gagsl-py2 at yahoo.com.ar Tue Apr 1 12:34:30 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 13:34:30 -0300 Subject: python persistence References: <8b1723d9-67c8-4fe5-b07b-22b0b9311519@8g2000hsu.googlegroups.com> <7f58b5f4-3195-472c-b307-dec71b12aaa8@y21g2000hsf.googlegroups.com> <44f04bf3-4edc-4cb4-9e54-fe51b5e591bc@e39g2000hsf.googlegroups.com> <80d1731d-a3c6-4fce-81fd-9c3f3537e59b@d21g2000prf.googlegroups.com> <5386cf08-c155-4fbb-8373-dbbb9829a9e7@m3g2000hsc.googlegroups.com> <3c27b270-e593-4f2a-b881-68126319760c@8g2000hsu.googlegroups.com> <7d71e294-2b13-4be0-948e-2fe0e4bbe7db@f63g2000hsf.googlegroups.com> Message-ID: En Tue, 01 Apr 2008 08:47:33 -0300, escribi?: >> >>>> c['0']= type('None',(),{}) >> > Traceback (most recent call last): >> > pickle.PicklingError: Can't pickle : it's not >> > found as __main__.None >> >> Don't do that then. Or use the available pickle hooks to customize how ? >> such classes may be pickled. All persistence mechanisms have >> limitations. > > I don't see a problem with that; except that binaries come from > disks. You could have a Python session that runs entirely on disks + > the ALU. (ALU? Do you mean CPU?) I don't understand this. Most programs are read from disk. Most data is read from disk. > I want to know if any, and correct me here, simple > modification can store live objects. I call a.append(it) and the > memory update takes place on disk instead. Using ZODB, a.append(it) would mark `a` as dirty. When you latter commit the transaction, it is stored back on disk. > If you require that all objects referenced by on-disk objects be on- > disk, that's an easy workaround. ZODB already does that. -- Gabriel Genellina From wuwei23 at gmail.com Thu Apr 3 02:47:16 2008 From: wuwei23 at gmail.com (alex23) Date: Wed, 2 Apr 2008 23:47:16 -0700 (PDT) Subject: Where can I find : References: <13uu56hn1vdqb9d@corp.supernews.com> <768026ee-b9f1-4445-bd02-088a2f725a9d@b64g2000hsa.googlegroups.com> Message-ID: <65be3cc0-215c-4b22-b2ca-bb35131d2b29@s37g2000prg.googlegroups.com> On Apr 2, 10:08 pm, lbonaf... at yahoo.com wrote: > On Mar 30, 1:22 am, castiro... at gmail.com wrote: > > [the usual masturbatory castironpi ramble] > > What? Yeah, that's what pretty much everyone says regarding his posts. Very very little signal amongst that noise. From jim.hefferon at gmail.com Tue Apr 29 20:50:49 2008 From: jim.hefferon at gmail.com (Jim) Date: Tue, 29 Apr 2008 17:50:49 -0700 (PDT) Subject: Simple unicode-safe version of str(exception)? References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> <48179831.7030308@v.loewis.de> <87iqy0miip.fsf@physik.rwth-aachen.de> Message-ID: I often struggle with the problem outlined in part in this thread. I know that I'm going to repeat some of what is said elsewhere but I'd like to present the question all in one place. I believe that the routines in the Python standard library do not document which exceptions they could raise (I understand some reasons why, but they nontheless do not). So I often find out the hard way that a library call can raise an exception that I was not smart enough to anticipate. So I often find myself doing try: make_a_routine_call(x,y,z) except AnticipatedError, err: do_something_with_it(x,y,z,err) exception Exception, err: print "something crazy happened "+str(err) where the print statement is just supposed to give me some idea of what happened. (I actually usually log it instead of printing it. If there is a better way, I'd love to hear it.) But "str(err)" sometimes fails, as the OP noted. Further, xtr(err) alone is not enough, I believe. I believe that some routines in the standard library do not return strings (by that I mean something approximately like "err.value is a pair"; forgive me, I don't remember the full details). Surely as lovely a language as Python has a better idiom for dealing with exceptions in the standard library than something that works out to print "something crazy happened"+" ".join([xtra(x) for x in err]) ? (I would understand better if it was a user's code; they are free to do what works for them, of course.) But I've been unable to think of one and I haven't seen in this thread another direction. Is there one? Jim From aldo at nullcube.com Sun Apr 6 23:57:21 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Mon, 7 Apr 2008 13:57:21 +1000 Subject: ANN: pry unit testing framework In-Reply-To: <47F98A5B.8010000@holdenweb.com> References: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> <20080407023442.GA16373@nullcube.com> <47F98A5B.8010000@holdenweb.com> Message-ID: <20080407035721.GB16373@nullcube.com> Thus spake Steve Holden (steve at holdenweb.com): > It probably reflects personal preference, but it's a preference that > many people will maintain. I understand that PEP 008 was largely > directed at standard library authors and maintainers, but anything > that claims wide utility should have ambitions to be included in the > standard library, and hence PEP 008 conformance would be a plus. Well, that's an entirely different conversation. Inclusion in the standard library has not always benefitted libraries - in fact, the standard library contains a number of examples of modules that have calcified due to the strict demands for interface backwards compatibility. Many of these could have been excellent if development and refactoring had continued. The library cleanup for Py3K may fix some of these problems, but then we're stuck again until, well, Py4K, and by then we'll all be too busy swanning about in our flying cars and having holidays on Mars to care. ;) So, no, I don't think inclusion in the standard library should be a universal ambition, and it's certainly not one I have for Pry. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From steve at holdenweb.com Wed Apr 16 13:23:57 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 16 Apr 2008 13:23:57 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: <87prspydex.fsf@physik.rwth-aachen.de> References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> <87prspydex.fsf@physik.rwth-aachen.de> Message-ID: Torsten Bronger wrote: > Hall?chen! > > Michael Torrie writes: > >> [...] >> >> This official python list is one of the few lists that's even >> still on nntp. All my other ones (gnome, gtk, openldap, clamav, >> freeradius, etc) are all e-mail mailing lists only and it works >> very well. In fact, I think it's much better since list >> subscription can actually be controlled by someone. > > The admistrative overhead of mailing lists is tedious. Fortunately, > most important computer-related lists are on gmane.org. We could > list c.l.py there, too. ;-) > c.l.py has been on gmane for years, as comp.python.general (why they have to have their own naming hierarchy i have never understood). regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From castironpi at gmail.com Mon Apr 21 16:30:12 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Mon, 21 Apr 2008 13:30:12 -0700 (PDT) Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> <8f3a768d-0b4c-4077-9aef-a66898882f03@m1g2000pre.googlegroups.com> Message-ID: <91e13570-b4ab-4063-93e2-dc2cbd96c7d7@e39g2000hsf.googlegroups.com> On Apr 21, 12:59?pm, Lou Pecora wrote: > In article > <8f3a768d-0b4c-4077-9aef-a66898882... at m1g2000pre.googlegroups.com>, > > ?castiro... at gmail.com wrote: > > On Apr 21, 9:28?am, a... at pythoncraft.com (Aahz) wrote: > > > > Why is this newsgroup different from all other newsgroups? ? > > > Different is a verbally atomic relation. > > It's a Passover question. Did it Pass. From steve at holdenweb.com Tue Apr 1 18:18:27 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 01 Apr 2008 18:18:27 -0400 Subject: class super method In-Reply-To: <0eb3ee4e-82e2-419a-8e7b-4931f7b4effa@c26g2000prf.googlegroups.com> References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> <0eb3ee4e-82e2-419a-8e7b-4931f7b4effa@c26g2000prf.googlegroups.com> Message-ID: George Sakkis wrote: > On Mar 31, 10:41 pm, Ed Leafe wrote: > >> On Mar 31, 2008, at 5:58 PM, George Sakkis wrote: >> >>>> is there any tutorial for super method (when/how to use it)? >>>> or maybe someone could explain me how it works? >>>> thx >>> Super is one of the dark corners of the language [1,2]... a good rule >>> of thumb is to stay away from it, or at least stick to its basic >>> usage. >> I disagree - super is quite elegant and dependable. > > Did you follow the links I gave by any chance? With all the gotchas > and rules of how to use it properly, it's far from what I would call > elegant. > >> In my own project (Dabo), we use mixin classes liberally to provide >> consistent behavior across our UI classes. The use of super makes >> customizing __init__() behavior, for example, quite straightforward. >> The general form looks like: >> >> class DaboUIClass(dabo.ui.dControlMixin, someWxPythonClass): >> def __init__(self, *args, **kwargs): >> doOurCustomStuffBeforeTheSuperCall() >> super(DaboUIClass, self).__init__(*args, **kwargs) >> doOurCustomStuffAfterTheSuperCall() >> >> This has worked reliably for us in every place where we have used it. >> There's nothing dark and mysterious about it at all. > > Pehaps, at least as long as you make sure that all superclasses have a > compatible signature - which in practice typically means accept > arbitrary *args and **kwargs in every class in the hierarchy like your > example. Good luck figuring out what's wrong if it's not used > consistently. > > Also doOurCustomStuffBeforeTheSuperCall() works as long as all > ancestor methods to be called need the same CustomStuff massaging. > > In a sentence, it's better than nothing but worse than anything. > So you are prepared to write off the voice of experience because some random web pages contradict what Ed is saying? As Ed rightly points out, any sufficiently complex gun can end up shooting you in the foot. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From sierra9162 at gmail.com Wed Apr 16 11:26:20 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:26:20 -0700 (PDT) Subject: kate hudson quotes Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From Magnus.Moraberg at gmail.com Wed Apr 2 09:06:47 2008 From: Magnus.Moraberg at gmail.com (Magnus.Moraberg at gmail.com) Date: Wed, 2 Apr 2008 06:06:47 -0700 (PDT) Subject: Nested try...except Message-ID: Hi, I found the following code on the net - http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/%3C20050924104732.5116.qmail at minotaur.apache.org%3E def count(self): - db = sqlite.connect(self.filename, isolation_level=ISOLATION_LEVEL) - try: - try: - cur = db.cursor() - cur.execute("select count(*) from sessions") - return cur.fetchone()[0] - finally: - cur.close() - finally: - db.close() I don't understand though why the second try is not after the line cur = db.cursor(). Can anyone explain for me why? /Barry. From nanjundi at gmail.com Wed Apr 2 12:25:21 2008 From: nanjundi at gmail.com (Nanjundi) Date: Wed, 2 Apr 2008 09:25:21 -0700 (PDT) Subject: Nested try...except References: <0a34849f-bcda-419b-a10f-772d76172d1f@b5g2000pri.googlegroups.com> <43d60d13-b420-414d-81c8-b8430af2aa5f@i36g2000prf.googlegroups.com> Message-ID: <7d992474-f90b-4c8f-b359-a1857f570c92@8g2000hse.googlegroups.com> On Apr 2, 9:22 am, Magnus.Morab... at gmail.com wrote: > On 2 Apr, 15:15, Magnus.Morab... at gmail.com wrote: > > > > > On 2 Apr, 15:12, cokofree... at gmail.com wrote: > > > > On Apr 2, 3:06 pm, Magnus.Morab... at gmail.com wrote: > > > > > Hi, > > > > > I found the following code on the net - > > > > > http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/%3C20050924104732.5116.qm... at minotaur.apache.org%3E > > > > > def count(self): > > > > - db = sqlite.connect(self.filename, > > > > isolation_level=ISOLATION_LEVEL) > > > > - try: > > > > - try: > > > > - cur = db.cursor() > > > > - cur.execute("select count(*) from sessions") > > > > - return cur.fetchone()[0] > > > > - finally: > > > > - cur.close() > > > > - finally: > > > > - db.close() > > > > > I don't understand though why the second try is not after the line cur > > > > = db.cursor(). Can anyone explain for me why? > > > > > /Barry. > > > > Better question is why is there a try with no except... > > > > Better yet, WHY is there two TRY statements when there could quite > > > happily be only one... > > > > Towards what you are asking, I GUESS...because the author hoped to > > > handle the cases where cur failed to get assigned...but then > > > his .close method of it would likely not work anyway...I mean...does > > > this even work...YUCK > > > I shouldn't have written "Nested try...except" as the title, instead I > > mean "Nested try...finally". Sorry about that... > > > Anyway, how would you do this? That is, use a finally to close the > > network connection and the cursor? > > > Thanks for your help, > > > Barry > > Here's what I would do. Is it OK? > > def ExecuteWithNoFetching(self, queryString): > > sqlServerConnection = adodbapi.connect (";".join (connectors)) > try: > cursor = sqlServerConnection.cursor() > try: > cursor.execute(queryString) > raise Exception("Exception") > sqlServerConnection.commit() > finally: > cursor.close() > finally: > sqlServerConnection.close() No.. Why do you have raise statement? "sqlServerConnection.commit()" never gets executed. -N From mattheww at chiark.greenend.org.uk Mon Apr 21 18:14:38 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 21 Apr 2008 23:14:38 +0100 (BST) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: Terry Reedy wrote: > Off the top of my head: copy C and use {} to demarcate blocks and ';' to > end statements, so that '\n' is not needed and is just whitespace when > present. So, repeatedly scan for the next one of '{};'. That would break if those characters appear in string literals or comments. That's why it's nicer if you can do the transformation after tokenising. (Also, '{' and '}' have rather useful meanings in Python already.) -M- From bignose+hates-spam at benfinney.id.au Tue Apr 1 04:12:12 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Tue, 01 Apr 2008 19:12:12 +1100 Subject: Why prefer != over <> for Python 3.0? References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> <659gb2F2f84eoU2@mid.individual.net> <87hceo73ap.fsf@physik.rwth-aachen.de> <65anbqF2fg18bU1@mid.individual.net> <87r6drjss4.fsf@physik.rwth-aachen.de> <65c0bfF2ffipiU1@mid.individual.net> <878wzyyqkf.fsf@physik.rwth-aachen.de> Message-ID: <87fxu6f0yr.fsf@benfinney.id.au> Torsten Bronger writes: > However, I'm slightly disappointed with the UTF-8 support in some > mail clients involved in this thread, so Unicode surely has not > arrived yet. Want . -- \ "bash awk grep perl sed, df du, du-du du-du, vi troff su fsck | `\ rm * halt LART LART LART!" -- The Swedish BOFH, | _o__) alt.sysadmin.recovery | Ben Finney From stefan_ml at behnel.de Wed Apr 23 14:50:59 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 23 Apr 2008 20:50:59 +0200 Subject: DTD validation and xmlproc In-Reply-To: References: Message-ID: <480F8513.6040309@behnel.de> mmm wrote: > I am willing to learn and use new xml procedures, but I found nothng > pre-written to validate agaisnt a given DTD file. > > Any advice would be welcome, even a good tutorial on XML validation > usiog Python. Regarding that part, try lxml. http://codespeak.net/lxml http://codespeak.net/lxml/tutorial.html http://codespeak.net/lxml/validation.html Stefan From john00587 at gmail.com Mon Apr 21 01:39:10 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:39:10 -0700 (PDT) Subject: firebird quarter patch Message-ID: <690c3dee-0496-4653-85ff-6f3795ce7205@z24g2000prf.googlegroups.com> firebird quarter patch http://cracks.00bp.com F R E E C R A C K S From bbxx789_05ss at yahoo.com Sun Apr 13 17:23:48 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sun, 13 Apr 2008 14:23:48 -0700 (PDT) Subject: urllib2 Basic authentication, what am I doing wrong? References: <48025b26$0$6839$2d805a3e@textnews.eweka.nl> Message-ID: <79fdc8fe-24ab-44c1-8c2f-a4804d45a654@t54g2000hsg.googlegroups.com> Michel Bouwmans wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hey everybody, > > I'm having a little problem with urllib2 and Basic HTTP authentication. > > I have the following code: > > auth = urllib2.HTTPPasswordMgrWithDefaultRealm() > auth.add_password(None, 'https://webmail.osg-erasmus.nl/oneNet/NetStorage/', > user, password) > authhandler = urllib2.HTTPBasicAuthHandler(auth) > > opener = urllib2.build_opener(auth) > opener.addheaders = [('User-agent', 'Mozilla/5.0 Something/1.0')] > > try: > return > self.opener.open('https://webmail.osg-erasmus.nl/oneNet/NetStorage/') > except urllib2.HTTPError, e: > print e.code > print e.headers > > This however does not allow me to authenticate. I keep getting back a 401: > > 401 > Date: Sun, 13 Apr 2008 18:11:32 GMT > Server: Apache/2.0.54 (NETWARE) mod_perl/1.99_12 Perl/v5.8.4 PHP/5.0.5 > mod_nsn/1.0_0 mod_jk/1.2.14 > Set-Cookie: novellsession1=8KuAO0iLyAEAAAAAAAAAAA==; path=/ > WWW-Authenticate: Basic realm="ERASMUS-TREE" > Vary: accept-language,accept-charset > Accept-Ranges: bytes > Connection: close > Transfer-Encoding: chunked > Content-Type: text/html; charset=iso-8859-1 > Content-Language: en > > Using this nice class (adapted to urllib2) as a basehandler I see that no > Authentication-header is being send out: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440574 > > What am I doing wrong here? I spend almost my entire free time today on this > and couldn't find any problem with my code, anyone else has a thought? > Thanks in advance. Can you get something like the following to work: import urllib2 pword_manager = urllib2.HTTPPasswordMgrWithDefaultRealm() pword_manager.add_password(None, 'http://localhost/ pwordProtectedStuff/', 'jane', 'janes_password') authentication_handler = urllib2.HTTPBasicAuthHandler(pword_manager) my_custom_urlopen_function = urllib2.build_opener(authentication_handler) urllib2.install_opener(my_custom_urlopen_function) f = urllib2.urlopen('http://localhost/pwordProtectedStuff/test.htm') print f.read() From kay.schluehr at gmx.net Fri Apr 25 14:26:28 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Fri, 25 Apr 2008 11:26:28 -0700 (PDT) Subject: Newbie question about import References: Message-ID: On 25 Apr., 20:03, Luca wrote: > Hi all. I'm trying to do something with python import but isn't working for me. > > Using python 2,5 I've a program structured like this: > > * a main module called (for example) "mommy" with an __init__.py and a > file called "mommy.py" > * a __version__ var defined inside the main __init__.py > > >From the mommy.py file I need to import the __version__ var, but I'm > > really not able to do this! I fear this is a very stupid task to do... > my problem is that the file is called like the module. > > Anyone can point me to the solution? > > -- > -- luca You have to import the package containing mummy and __init__ from the pythonpath ( which can be examined using the sys module and the sys.path attribute ). Then access __version__ as an attribute: mypack/ # package indicated by __init__.py mummy.py __init__.py mummy.py -------- import mypack # o.k. if accessible from pythonpath mypack.__version__ From mail at timgolden.me.uk Wed Apr 23 13:15:52 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 23 Apr 2008 18:15:52 +0100 Subject: Partition list with predicate In-Reply-To: <925822270804230959v557ec5f5re02737709f94d3c6@mail.gmail.com> References: <925822270804230959v557ec5f5re02737709f94d3c6@mail.gmail.com> Message-ID: <480F6EC8.4090706@timgolden.me.uk> Jared Grubb wrote: > I want a function that removes values from a list if a predicate > evaluates to True. The best I could come up with is: Have a look at the itertools module, and the ifilter function in particular. TJG From kyosohma at gmail.com Tue Apr 29 10:10:47 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 29 Apr 2008 07:10:47 -0700 (PDT) Subject: SSL through python. possible ? References: Message-ID: On Apr 29, 8:56?am, TkNeo wrote: > I need to do SSL file transfer using python? Is there a library i can > use ? > > Thanks. Did you try Google? Here's a few links that look like possibilities: http://sandbox.rulemaker.net/ngps/m2/ http://pypgsql.sourceforge.net/misc/python-ssl.html http://pypi.python.org/pypi/ssl/ http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/117004 HTH Mike From dolloffdelvpg at gmail.com Wed Apr 16 08:04:46 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:04:46 -0700 (PDT) Subject: taylor swift in concert Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From mensanator at aol.com Wed Apr 16 13:46:03 2008 From: mensanator at aol.com (Mensanator) Date: Wed, 16 Apr 2008 10:46:03 -0700 (PDT) Subject: What can we do about all the spam that the list is getting? References: <259ab201-9d2b-4e4e-88a7-e2fe277f0066@a23g2000hsc.googlegroups.com> Message-ID: On Apr 16, 12:01?pm, sr... at ferg.org wrote: > What can we do about all the spam that comp.lang.python is getting? > Things are getting pretty bad. Buy Google and make them fix it. From skanemupp at yahoo.se Sat Apr 19 15:28:37 2008 From: skanemupp at yahoo.se (globalrev) Date: Sat, 19 Apr 2008 12:28:37 -0700 (PDT) Subject: random.random(), random not defined!? Message-ID: <2a3931f5-481d-4831-baad-fcc9f0c0c129@m73g2000hsh.googlegroups.com> do i need to import something to use random? From patrick.waldo at gmail.com Tue Apr 1 16:19:54 2008 From: patrick.waldo at gmail.com (patrick.waldo at gmail.com) Date: Tue, 1 Apr 2008 13:19:54 -0700 (PDT) Subject: xlrd and cPickle.dump References: <34e62ddb-477f-4a99-97a5-21a7b148d244@e67g2000hsa.googlegroups.com> <47f22a41@news.mel.dft.com.au> Message-ID: <0d46a213-9f95-43b5-835b-d74d8403626b@c19g2000prf.googlegroups.com> > How many megabytes is "extremely large"? How many seconds does it take > to open it with xlrd.open_workbook? The document is 15mb ad 50,000+ rows (for test purposes I will use a smaller sample), but my computer hangs (ie it takes a long time) when I try to do simple manipulations and the documentation leads me to believe cPickle will be more efficient. If this is not true, then I don't have a problem (ie I just have to wait), but I still would like to figure out how to pickle an xlrd object anyways. > You only need one of the above imports at the best of times, and for > what you are attempting to do, you don't need pyExcelerator at all. Using pyExcelerator was a guess, because the traditional way didn't work and I thought it may be because it's an Excel file. Secondly, I import it twice because sometimes, and I don't know why, PythonWin does not import pyExcelerator the first time. This has only been true with pyExcelerator. > > data_path = """C:\test.xls""" > > It is extremely unlikely that you have a file whose basename begins with > a TAB ('\t') character. Please post the code that you actually ran. you're right, I had just quickly erased my documents and settings folder to make it smaller for an example. > > Please post the minimal pyExcelerator-free script that demonstrates your > problem. Ensure that it includes the following line: > import sys; print sys.version; print xlrd.__VERSION__ > Also post the output and the traceback (in full). As to copy_reg.py, I downloaded Activestate Python 2.4 and that was it, so I have had no other version on my computer. Here's the code: import cPickle,xlrd, sys print sys.version print xlrd.__VERSION__ data_path = """C:\\test\\test.xls""" pickle_path = """C:\\test\\pickle.pickle""" book = xlrd.open_workbook(data_path) Data_sheet = book.sheet_by_index(0) pickle_file = open(pickle_path, 'w') cPickle.dump(book, pickle_file) pickle_file.close() Here's the output: 2.4.3 (#69, Apr 11 2006, 15:32:42) [MSC v.1310 32 bit (Intel)] 0.6.1 Traceback (most recent call last): File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework \scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\text analysis\pickle_test2.py", line 13, in ? cPickle.dump(book, pickle_file) File "C:\Python24\lib\copy_reg.py", line 69, in _reduce_ex raise TypeError, "can't pickle %s objects" % base.__name__ TypeError: can't pickle module objects Thanks for the advice! From DanQ.cunningham at landesk.com Mon Apr 7 10:11:23 2008 From: DanQ.cunningham at landesk.com (Cunningham, Dan) Date: Mon, 7 Apr 2008 08:11:23 -0600 Subject: Getting a value from a nested dictionary Message-ID: Hi, My name is Dan and I'm a newb to python (and programming. Please forgive) I am trying to get a value from a nested dictionary. I would like to pass in a parameter from a conf file, then compare it to a value in the dictionary, and verify that it is a valid value. (The SSL_MODE Portion of the below listed dictionary) I have d1{key1: val1, key2: val_2{key_a: val_a, key_b: val_b}, key3: val_3} And In comes the value from the conf file key2: val_a Any Ideas? Dan C #!/usr/local/bin/python2.5 # -*- coding: UTF-8 -*- # File extractconf.py # The file authn.conf must exist import os import sys import re CONF_FILE = "authn.conf" #Use these defaults if none are provided in the .conf file PARAMS_VALUES = {"INSTANCE_NAME": "", "CHASE_REFERRALS": False, "DOMAIN_NAME": "", "GROUP_CONTAINER": "", "PASSWORD": "", "SSL_MODE": {"ssl1": "NO_SSL", "ssl2": "SSL_TRUST_ALL", "ssl3": "SSL_CERTIFICATE_MODE"}, "USE_GC": False, "USE_KERBEROS": False, "USER_CONTAINER": "", "USER_NAME": "", "USER_NAME_TYPE": {'unt1': "FULL_SAM", 'unt2': "PARTIAL_SAM", 'unt3': "FULL_UPN", 'unt4': "PARTIAL_UPN"}} def extractParams(): thedir = os.getcwd() #Parse the dir and get the file listing filelist = os.listdir(thedir) if CONF_FILE in filelist: thefile = open("authn.conf").readlines() thefile = [l.strip() for l in thefile] #Strip out the whitespace thefile = [l for l in thefile if l.find('=') >= 0] # Filters out non-conf lines thefile = [re.split(r"\s*=\s*", l) for l in thefile] #Use regex and get out spaces thefile = [(l[0], eval(l[1])) for l in thefile] #Evaluate the str and bool values thefile = dict(thefile) #Turn the file into a dictionary for k in thefile.keys(): #For each entry in the file if k == 'SSL_MODE': #If the key is equal to the SSL_MODE key ##THIS IS WHERE I'M STUCK print PARAMS_VALUES['SSL_MODE'] ## else: ## THIS PART IS OK for k in PARAMS_VALUES.keys(): #Replace values in default dict with the values from the conf file PARAMS_VALUES[k] = thefile[k] else: sys.exit("File authn.conf must exist") if __name__ == "__main__": extractParams() -------------- next part -------------- An HTML attachment was scrubbed... URL: From rhamph at gmail.com Tue Apr 1 12:02:33 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Tue, 1 Apr 2008 09:02:33 -0700 (PDT) Subject: bsddb3 thread problem References: Message-ID: <391d152a-aa74-40e2-804e-14f30756fda3@u10g2000prn.googlegroups.com> On Apr 1, 1:29 am, "anuraguni... at yahoo.com" wrote: > In my application I am trying to access(read) a DB thru a thread while > my main thread is adding data to it and it gives following error(s) > > bsddb._db.DBRunRecoveryError: (-30974, 'DB_RUNRECOVERY: Fatal error, > run database recovery -- PANIC: Permission denied') > > and sometimes > bsddb._db.DBRunRecoveryError: (-30974, 'DB_RUNRECOVERY: Fatal error, > run database recovery -- PANIC: fatal region error detected; run > recovery') > > sometimes > bsddb._db.DBInvalidArgError: (22, 'Invalid argument -- DB_LOCK- > > >lock_put: Lock is no longer valid') > > sometimes pure seg fault. > Program received signal SIGSEGV, Segmentation fault. > 0xb7c1b845 in __bam_adjust () from /usr/lib/libdb-4.4.so > > and some time memory usage keeps on increasing and cpu is 100% > it crashes with memory error. > > This doesn't happen always, almost 1 in 10 cases. > If i use simple python threaded function instead of threading class, > it works. > > I have attached a simple script which tries to replicate the scenario. > > Do anybody has a clue what I am doing wrong here? > I suppose bsddb3 DB can be accessed from mutiple threads? > or do I need to specifically set DB_THREAD flag? though with > db.DB_THREAD it hangs on some mutex? > > Thanks a lot > Anurag > > ------- > import time > import os > import threading > import thread > import shutil > from bsddb3 import db > > class DocQueueConsumer(threading.Thread): > > def __init__(self, queueDB): > threading.Thread.__init__(self) > self.queueDB = queueDB > self.setDaemon(True) > > def run(self): > while True: self.queueDB.cursor() > > def crash(): > path = "/tmp/test_crash" > if os.path.exists(path): > shutil.rmtree(path) > os.mkdir(path) > > aBigEnv = db.DBEnv() > aBigEnv.set_cachesize(0, 512*1024*1024) > aBigEnv.open(path, db.DB_INIT_CDB|db.DB_INIT_MPOOL|db.DB_CREATE) > > queueDB = db.DB(aBigEnv) > queueDB.open('mydb', dbtype=db.DB_RECNO, flags=db.DB_CREATE) > > DocQueueConsumer(queueDB).start() > for i in xrange(10**5): > if i%1000==0: print i/1000 > queueDB.append("something") > > crash() > ------- It's my understanding that the connection is NOT thread-safe. Your thread should be using an entirely separate connection. From fabiofz at gmail.com Wed Apr 9 13:41:07 2008 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Wed, 9 Apr 2008 14:41:07 -0300 Subject: Pydev 1.3.15 Released Message-ID: Hi All, Pydev and Pydev Extensions 1.3.15 have been released Details on Pydev Extensions: http://www.fabioz.com/pydev Details on Pydev: http://pydev.sf.net Details on its development: http://pydev.blogspot.com Release Highlights in Pydev Extensions: ----------------------------------------------------------------- * Globals Browser: Was not correctly showing definition on a case with multiple projects when one did not have the python nature configured. * Code Analysis: False positive: Classes defined within a class context are correctly found when later accessed in the parent context. * Interactive console integration o Context insensitive completions with auto-import in console o Ctrl+Alt+Enter: can be used to: + Create console if no console exists + Send selected text to console + Make execfile for current file if there's no selected text Release Highlights in Pydev: ---------------------------------------------- * Files without extension: If a file that does not have an extension is found in the root of the pythonpath, code-completion and breakpoints work with it. * Extract method: comma not removed when found after a tuple and before a keyword argument. * Console Encoding: print u"\xF6" works (console encoding correctly customized in python -- see http://sourceforge.net/tracker/index.php?func=detail&aid=1580766&group_id=85796&atid=577329 for details). * Debugger: Context of breakpoint correctly defined when comments are present in the end of the module. * from __future__ import (xxx, with_statement): works. * Interactive Console View, featuring: o Code Completion + Context sensitive with shell completions + Qualifier matches as case insensitive + Templates + Repeating the activation changes from templates to default completions o Console Configurations + Initial commands for starting the console + Colors for the console + Vmargs can be specified for jython o Auto-indent o Auto-edits o Context info on hover o Up / Down Arrows cycles through the history (and uses the current text to match for the start of the history command) o Page Up: shows dialog with console history (where lines to be re-executed can be selected) o Esc: clears current line o ctrl+1 works for assign quick-assist o Hyperlinks addedd to tracebacks in the console o Paste added directly to the command line o Cut will only cut from the command line o Copy does not get the prompt chars o Home goes to: first text char / prompt end / line start (and cycles again) o Cursor automatically moved to command line on key events o Multiple views of the same console can be created o Limitation: Output is not asynchonous (stdout and stderr are only shown after a new command is sent to the console) What is PyDev? --------------------------- PyDev is a plugin that enables users to use Eclipse for Python and Jython development -- making Eclipse a first class Python IDE -- It comes with many goodies such as code completion, syntax highlighting, syntax analysis, refactor, debug and many others. Cheers, -- Fabio Zadrozny ------------------------------------------------------ Software Developer ESSS - Engineering Simulation and Scientific Software http://www.esss.com.br Pydev Extensions http://www.fabioz.com/pydev Pydev - Python Development Enviroment for Eclipse http://pydev.sf.net http://pydev.blogspot.com From upton at virginia.edu Wed Apr 23 11:27:08 2008 From: upton at virginia.edu (Dan Upton) Date: Wed, 23 Apr 2008 11:27:08 -0400 Subject: Unix Device File Emulation In-Reply-To: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> Message-ID: <5504f9ac0804230827l1a5b2697n5dd716daf0d4b175@mail.gmail.com> (let's try this again, and actually send it to the list this time) On Wed, Apr 23, 2008 at 11:02 AM, blaine wrote: > Hey everyone, > So I've got a quick query for advice. > > We have an embedded device in which we are displaying to an LCD > device that sits at /dev/screen. This device is not readily available > all the time, so I am needing to write an emulator. This will > basically just monitor a file, /dev/screen for example, and write the > commands to a TK or WxWindows canvas. > > So sending 'line 0 0 10 10' will draw a line on my canvas from (0,0) > to (10,10). > > My question: Whats the best way to set up a monitor (in python) of > this file? Would I simply open up the file for read, check for > changes, get any updated data, and clear the file? Or is there some > standard way of doing something like this that guarantees no overlap > or data loss? > > example usage: echo 'line 0 0 10 10' > /dev/screen > > On the actual embedded device this is handled by a kernel module. We > can spit commands into it as fast as we can and the kernel module can > keep up. This is typical unix device file behavior. > > Any suggestions or advice would be splendid. Thanks! > Blaine > -- > http://mail.python.org/mailman/listinfo/python-list > 've only interacted with device files from python that I was only reading from. And I guess technically they were under /proc and /sys, rather than /dev, although they may be handled the same way. Anyway, in that case my method was basically to open the file, read it, close it, do whatever processing I needed to do on the data, sleep for some interval...lather, rinse, repeat. Sleeping for some interval may or may not be appropriate in your case. I know in the case of /proc files and /sys files, the files are generated on demand by the kernel and relevant kernel structures are basically printed to a string and copied into a page in memory that the user program can access. AFAIK, you can seek back and forth through them, but I don't know whether the data in the page is updated on a seek, so you may have to close and reopen the file ever iteration to see what's changed. HTH, -dan From bruno.desthuilliers at gmail.com Mon Apr 7 13:19:44 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Mon, 7 Apr 2008 10:19:44 -0700 (PDT) Subject: Learning curve for new database program with Python? References: Message-ID: <00fca324-6fce-4b2a-8acb-77c96b83eb1c@p39g2000prm.googlegroups.com> On 7 avr, 07:34, CM wrote: > On Apr 5, 11:50 am, Jetus wrote: > > > I have a need for a database program. I downloaded the db2 from ibm, > > and reviewed some of the documentation. > > > My question is, what is the easiest program for me to try to learn. I > > will be creating a database of about 25,000 records, it will be > > relational. I am a beginner Python programmer, and need a database > > solution that is easy to grasp. I played with sql, > > and found that very difficult, if not overly cumbersome. > > > A database that could work with Django would be very interesting to > > look at as well.. > > > Any suggestions out there? > > From the good people at Django: > > "If you want to use Django with a database, which is probably the > case, you'll also need a database engine. PostgreSQL is recommended, > because we're PostgreSQL fans, and MySQL, SQLite 3, and Oracle are > also supported." > > And if you want to make it a relational database, Err... I may totally misunderstand you here, but I've the strong impression that you missed the fact that the database systems mentionned above are all (so-called) relational dabatases. From kyosohma at gmail.com Tue Apr 8 11:47:10 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 8 Apr 2008 08:47:10 -0700 (PDT) Subject: List open files References: <47fb8d54$0$15068$426a74cc@news.free.fr> Message-ID: On Apr 8, 10:16 am, "Bruno GUERPILLON" wrote: > Hi, > > I'd like, in a WIN32 environment, list all open files. > Anyone got a clue how to do this ? > > Regards, > > Bruno. XP comes with a utility called OpenFiles.exe which supposedly gives this functionality. You can use Python's subprocess command to run it and parse its output. Mike From deets at nospam.web.de Tue Apr 22 13:06:52 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 19:06:52 +0200 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: <6728a814-32df-41cd-8f6e-c86750d9f91f@p25g2000hsf.googlegroups.com> References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <6760jfF2n3bn1U1@mid.uni-berlin.de> <676desF2nrgitU1@mid.uni-berlin.de> <6728a814-32df-41cd-8f6e-c86750d9f91f@p25g2000hsf.googlegroups.com> Message-ID: <676ka0F2mt126U1@mid.uni-berlin.de> Carl Banks schrieb: > On Apr 22, 11:10 am, "Diez B. Roggisch" wrote: >>> 2. Java interfaces solve a different problem than MI (used properly) >>> does: interfaces are there to make types polymorphic, whereas >>> inheritance's main use is to share behavior. >> But the *goal* of the polymorphy is mainly to have shared behavior. > > Not at all. The goal of polymorphism is to have objects of different > types usable in the same situation. Two such classes might share some > behavior, but they don't have to. Of course they don't *have* to. Yet very often they do. But I should have (again) worded that more cautiously. When doing Java, using interfaces like the ones found in the collection packages or e.g. HttpServletRequest and such usually leads to the delegation-pattern I described. The same for swing. Generally, a lot of code is written that declares first an interface & then some Impl-classes of that - for the sole purpose of working around the SI-caveats. This shaped my viewpoint of interfaces - while on their own useful - as a necessary crutch to create a MI-like features, that I wanted to emphasize in this discussion. Diez From kf9150 at gmail.com Tue Apr 1 17:20:27 2008 From: kf9150 at gmail.com (Kelie) Date: Tue, 1 Apr 2008 14:20:27 -0700 (PDT) Subject: PyQt - Question on QListWidget's selectedItems Method References: <68632dc8-0426-4c6a-a2d8-04fd49381452@d21g2000prf.googlegroups.com> Message-ID: Another question I have about QListWidget is when user manually selects and deselects a QListWidgetItem, the background color switches between blue and white. But when an item is programmingly selected with setItemSelected method, the background color is some kind of light gray instead of blue. Why is there such a difference and how do I programmingly set the QListWidgetItem background color to blue? Thank you! From __peter__ at web.de Thu Apr 3 06:28:56 2008 From: __peter__ at web.de (Peter Otten) Date: Thu, 03 Apr 2008 12:28:56 +0200 Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> Message-ID: Jo?o Neves wrote: > Let me give a very basic example. Say we have these two functions: I suppose you mean >>> def inc(x): return x + 1 ... >>> def dec(x): return x - 1 ... >>> inc(1), dec(1) (2, 0) > Examining the compiled bytecodes for these two functions: > > >>> inc.func_code.co_code > '|\x00\x00d\x01\x00\x17}\x00\x00d\x00\x00S' > > >>> dec.func_code.co_code > '|\x00\x00d\x01\x00\x18}\x00\x00d\x00\x00S' > > Now suppose that I wanted to mess with inc, and have it behave like > dec. >>> inc.func_code = dec.func_code >>> inc(1), dec(1) (0, 0) There you are, and there wasn't even a slight chance that you combined the byte code with an incompatible function signature ;) Peter From larry.bates at websafe.com` Fri Apr 25 14:23:02 2008 From: larry.bates at websafe.com` (Larry Bates) Date: Fri, 25 Apr 2008 13:23:02 -0500 Subject: Newbie question about import In-Reply-To: References: Message-ID: Luca wrote: > Hi all. I'm trying to do something with python import but isn't working for me. > > Using python 2,5 I've a program structured like this: > > * a main module called (for example) "mommy" with an __init__.py and a > file called "mommy.py" > * a __version__ var defined inside the main __init__.py > >>From the mommy.py file I need to import the __version__ var, but I'm > really not able to do this! I fear this is a very stupid task to do... > my problem is that the file is called like the module. > > Anyone can point me to the solution? > In the future please show us what you "actually" did with full tracebacks if there were any so we know what you actually tried. I do something like this by doing: from version import version__ It doesn't have to be a module (e.g. doesn't need __init__.py) to make that work. Hope this helps. -Larry From Shawn at Milochik.com Wed Apr 30 14:53:16 2008 From: Shawn at Milochik.com (Shawn Milochik) Date: Wed, 30 Apr 2008 14:53:16 -0400 Subject: Issue with regular expressions In-Reply-To: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Message-ID: <2dc0c81b0804301153g343f0f1eg84951d7a5500cb42@mail.gmail.com> My stab at it: My stab at it: #!/usr/bin/env python import re query = ' " some words" with and "without quotes " ' query = re.sub("\s+", " ", query) words = [] while query.__len__(): query = query.strip() print("Current query value: '%s'" % query) print words print if query[0] == '"': secondQuote = query[1:].index('"') + 2 words.append(query[0:secondQuote].replace('"', '').strip()) query = query[secondQuote:] else: if query.count(" ") == 0 : words.append(query) query = "" else: space = query.index(" ") words.append(query[0:space]) query = query[space:] print words print query -------------- next part -------------- An HTML attachment was scrubbed... URL: From schettino72 at gmail.com Sat Apr 19 17:18:32 2008 From: schettino72 at gmail.com (Eduardo Schettino) Date: Sun, 20 Apr 2008 02:48:32 +0530 Subject: [ANN] DoIt 0.1.0 Released (build tool) In-Reply-To: <480a576a$1@news.mel.dft.com.au> References: <480a576a$1@news.mel.dft.com.au> Message-ID: On Sun, Apr 20, 2008 at 2:04 AM, John Machin wrote: > You may like to consider the possibility of confusion caused by the > similarity of some characters in some fonts (DoIt, Do1t, Dolt) ... > google("dictionary dolt") :-) > -- > http://mail.python.org/mailman/listinfo/python-list > hehehehe. i feel like a DOLT I never realized that it is confusing. I also didnt know this word "dolt" before. i wont use capital letters anymore. thanks From george.sakkis at gmail.com Wed Apr 2 15:56:07 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 2 Apr 2008 12:56:07 -0700 (PDT) Subject: Manipulate Large Binary Files References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> Message-ID: <9cef43da-c101-4003-9a49-308da3c9667a@u36g2000prf.googlegroups.com> On Apr 2, 2:09 pm, "Derek Tracy" wrote: > On Wed, Apr 2, 2008 at 10:59 AM, Derek Tracy wrote: > > I am trying to write a script that reads in a large binary file (over 2Gb) saves the header file (169088 bytes) into one file then take the rest of the data and dump it into anther file. I generated code that works wonderfully for files under 2Gb in size but the majority of the files I am dealing with are over the 2Gb limit > > > INPUT = open(infile, 'rb') > > header = FH.read(169088) > > > ary = array.array('H', INPUT.read()) > > > INPUT.close() > > > OUTF1 = open(outfile1, 'wb') > > OUTF1.write(header) > > > OUTF2 = open(outfile2, 'wb') > > ary.tofile(OUTF2) > > > When I try to use the above on files over 2Gb I get: > > OverflowError: requested number of bytes is more than a Python string can hold > > > Does anybody have an idea as to how I can get by this hurdle? > > > I am working in an environment that does not allow me to freely download modules to use. Python version 2.5.1 > > > R/S -- > > --------------------------------- > > Derek Tracy > > trac... at gmail.com > > --------------------------------- > > I know have 2 solutions, one using > partial > and the other using array > > Both are clocking in at the same time (1m 5sec for 2.6Gb), are there > any ways I can optimize either solution? Would turning off the > read/write buff increase speed? You may try to increase the buffering size when you open() the file and see if this helps: def iterchunks(filename, buffering): return iter(partial(open(filename,buffering=buffering).read, buffering), '') for chunk in iterchunks(filename, 32*1024): pass #for chunk in iterchunks(filename, 1024**2): pass #for chunk in iterchunks(filename, 10*1024**2): pass George From ziade.tarek at gmail.com Thu Apr 17 09:44:23 2008 From: ziade.tarek at gmail.com (=?ISO-8859-1?Q?Tarek_Ziad=E9?=) Date: Thu, 17 Apr 2008 15:44:23 +0200 Subject: [Python-Dev] Global Python Sprint Weekends: May 10th-11th and June 21st-22nd. In-Reply-To: <4806482C.4030305@voidspace.org.uk> References: <87D3F9C72FBF214DB39FA4E3FE618CDC6E22F389FE@EXMBX04.exchhosting.com> <4806482C.4030305@voidspace.org.uk> Message-ID: <94bdd2610804170644x4db329b0vf49de21a590c51e@mail.gmail.com> On Wed, Apr 16, 2008 at 8:40 PM, Michael Foord wrote: > Trent Nelson wrote: > > Following on from the success of previous sprint/bugfix weekends and > > sprinting efforts at PyCon 2008, I'd like to propose the next two > > Global Python Sprint Weekends take place on the following dates: > > > > * May 10th-11th (four days after 2.6a3 and 3.0a5 are released) > > * June 21st-22nd (~week before 2.6b2 and 3.0b2 are released) > > > > It seems there are a few of the Python User Groups keen on meeting > > up in person and sprinting collaboratively, akin to PyCon, which I > > highly recommend. I'd like to nominate Saturday across the board > > as the day for PUGs to meet up in person, with Sunday geared more > > towards an online collaboration day via IRC, where we can take care > > of all the little things that got in our way of coding on Saturday > > (like finalising/preparing/reviewing patches, updating tracker and > > documentation, writing tests ;-). > > > > For User Groups that are planning on meeting up to collaborate, > > please reply to this thread on python-dev at python.org and let every- > > one know your intentions! > > > > > > I should be able to help organise and attend the London contribution. > Personally I'd like to work on the documentation changes / clean-up for > the unittest module discussed recently. We are trying to set up a team here in Paris, Personnally I would like to continue the work started in distutils (various patches) and some friends here are interested in contributing on documentation. Tarek -- Tarek Ziad? | Association AfPy | www.afpy.org Blog FR | http://programmation-python.org Blog EN | http://tarekziade.wordpress.com/ From bruno.desthuilliers at gmail.com Thu Apr 17 09:46:43 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Thu, 17 Apr 2008 06:46:43 -0700 (PDT) Subject: Metaprogramming Example References: <930643c6-2d56-4fb0-aee0-a3e79231f09b@24g2000hsh.googlegroups.com> <32472b97-f35a-4408-96f5-2f8c8f92ae56@m73g2000hsh.googlegroups.com> Message-ID: <39325652-e0cf-4efd-9b28-00c0fe8552cc@m73g2000hsh.googlegroups.com> On 17 avr, 14:25, andrew cooke wrote: > On Apr 17, 7:12 am, "bruno.desthuilli... at gmail.com" wrote: > > [...] > > Thanks very much! > > These are useful pointers. I'll update my code accordingly. > > At one point you pointed out I didn't need parentheses and I agree - I > was using them to avoid having a line continuation backslash (I think > I read to do that in a style guide recently). Ok. I personnaly prefer \ continuations, but that's another troll^M^discussion !-) > One other question. I had "foo is False" and you said I need > equality, which is a good point. However, in any other language "not > foo" would be preferable. And it's indeed the case in Python. > I was surprised you didn't suggest that I did - even if somewhat implicitly -, as Paul brillantly explained. > (and I'm unsure now why I didn't write it that way myself). Is there > some common Python standard that prefers "foo == False" to "not foo"? Definitively not. FWIW, True and False are later additions to Python, which has a much more generic concept of what's true or false (notice the lowercase) in the context of a boolean expression, that is: - False, None, numeric zero are false - an object that has a __nonzero__ method has the truth value of the result of calling this method - a "sizeable" object (one which defines a __len__ method) is true if len(obj) > 0, else it's false (which implies that empty dicts, lists, tuples and strings are false) - anything else is true (please someone correct me if I forgot something here). > > PS Is there anywhere that explains why Decorators (in the context of > functions/methods) are so good? I've read lots of things saying they > are good, but no real justification of why. To me it looks more like > "re-arranging deck chairs on the Titanic" - you're just moving where > the hack happens from one place to another. Is the point that now the > hack is more visible and hence modifiable? I wouldn't call function decorators "a hack" - it's just a pretty common use of HOFs. Now wrt/ the @decorator syntax: yes, you're plain right, the GoodThing(tm) is that it makes the use of the HOF clearly visible at the top of the function definition so you just can't miss it. From bwljgbwn at gmail.com Tue Apr 22 05:51:26 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:51:26 -0700 (PDT) Subject: clonecd crack Message-ID: <0ecf01ca-9887-4ed4-aff9-38e6e43e4139@b5g2000pri.googlegroups.com> clonecd crack http://cracks.12w.net F R E E C R A C K S From xnews2 at fredp.lautre.net Mon Apr 28 14:47:21 2008 From: xnews2 at fredp.lautre.net (Fred Pacquier) Date: 28 Apr 2008 18:47:21 GMT Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <6db0df91-39f1-47a1-b4ca-c0351f0b67bc@y22g2000prd.googlegroups.com> Message-ID: John Henry said : > The performance of Qooxdoo is quite amazing - for a Javascript based > web application. Don't know about cell-phones though. You can try > their showcase web site I cited earlier. Just for the record, Nokia Internet tablets (770, N800, N810) are the only things made by Nokia that are not cell-phones... They're ARM machines with a 800x480 4" screen, Wifi, Bluetooth, and Linux. And Python, pyGTK and Pygame. Probably pyQt next as they just bought Trolltech. But no wxPython. I was not speaking of running just the client part in the device's browser, either - but the full Monty (haha) with the web server and the application engine, python, middleware and all. I'm doing it right now using a full- blown framework (web2py), so it's not unreasonable. There's no Ajax in there though, so I'm wondering what kind of impact those tools you mention would have, server side. > Yes, who would have throught we don't have to give up on Pythoncard? Proof of superior vision, architecture and design, all that time ago... From theller at ctypes.org Thu Apr 3 15:17:14 2008 From: theller at ctypes.org (Thomas Heller) Date: Thu, 03 Apr 2008 21:17:14 +0200 Subject: State of ctypes Support on HP-UX? In-Reply-To: <200804031429.19025.phil@riverbankcomputing.com> References: <200804031153.26234.phil@riverbankcomputing.com> <200804031429.19025.phil@riverbankcomputing.com> Message-ID: Phil Thompson schrieb: > On Thursday 03 April 2008, Thomas Heller wrote: >> Phil Thompson schrieb: >> > Could somebody confirm how well ctypes is supported on HP-UX (for both >> > PA-RISC and Itanium) for both Python v2.4 and v2.5? >> I cannot answer your question, but if you want to try it out >> yourself there is the HP testdrive program: http://www.testdrive.hp.com/ > > Thanks for the pointer. Unfortunately the answer is that there is no support > (at least for ctypes v1.0.2). I tried out the current SVN version of Python myself. ctypes doesn't compile on the PA system (the libffi assembler code fails to compile), but I did get it to work on the Itanium system with gcc (I had to set LDSHARED="gcc -shared" before configuring). Even the ctypes unittests pass on this system. In theory, the ctypes code should be backwards-compatible with python 2.4, although in practice it currently is not, but IMO it should be possible to change it accordingly. Would this be useful to you? Thomas From johnjsal at gmailNOSPAM.com Sun Apr 13 23:11:18 2008 From: johnjsal at gmailNOSPAM.com (John Salerno) Date: Sun, 13 Apr 2008 23:11:18 -0400 Subject: Best way to update a settings file? Message-ID: <4802cb83$0$15190$607ed4bc@cv.net> I'm thinking about writing a small script that will update an xml file with whatever game settings the user enters. I imagine that the user will have a single-screen GUI application with several different settings, like this: CROSSHAIRS ON LOCATION ON HEALTHBAR OFF etc..... These settings will somehow be toggleable with an ON/OFF button, or something. Anyway, I can think of two ways to do this: 1. After the user chooses his settings and clicks the Save button, Python reads all the settings from the GUI application and updates *every* entry in the xml file (whether it has changed or not). 2. After the user chooses his settings and clicks the Save button, Python reads all the settings from the GUI application, compares these settings to those in the xml file, and updates only the ones that have been changed. Now, #2 seems, at first glance, like the more efficient option, because you are only updating what needs to be updated, and leaving the rest alone. However, I wonder if the extra step of comparing all the settings from the user input and the xml file will end up taking longer than just simply rewriting all the settings. Probably neither method will take much longer than the other, but I'm asking more from a good design/efficiency standpoint. Which of these two methods is the better way, or is there perhaps another way I'm not thinking of? Thanks! From trentm at activestate.com Wed Apr 9 17:48:31 2008 From: trentm at activestate.com (Trent Mick) Date: Wed, 09 Apr 2008 14:48:31 -0700 Subject: ANN: ActivePython 2.5.2.2 and 2.4.5.14 are now available Message-ID: <47FD39AF.7070008@activestate.com> I'm happy to announce that ActivePython 2.5.2.2 and 2.4.5.14 are now available for download from: http://www.activestate.com/products/activepython/ These are patch releases that update ActivePython to core Python 2.5.2 and 2.4.5. What is ActivePython? --------------------- ActivePython is ActiveState's binary distribution of Python. Builds for Windows, Mac OS X, Linux, HP-UX and AIX are made freely available. ActivePython includes the Python core and the many core extensions: zlib and bzip2 for data compression, the Berkeley DB (bsddb) and SQLite (sqlite3, ActivePython 2.5 only) database libraries, OpenSSL bindings for HTTPS support, the Tix GUI widgets for Tkinter, ElementTree for XML processing (ActivePython 2.5 only), ctypes (on supported platforms, ActivePython 2.5 only) for low-level library access, and others. The Windows distribution ships with PyWin32 -- a suite of Windows tools developed by Mark Hammond, including bindings to the Win32 API and Windows COM. See this page for full details: http://aspn.activestate.com/ASPN/docs/ActivePython/2.5/whatsincluded.html As well, ActivePython ships with a wealth of documentation for both new and experienced Python programmers. In addition to the core Python docs, ActivePython includes the "What's New in Python" series, "Dive into Python", the Python FAQs & HOWTOs, and the Python Enhancement Proposals (PEPs). An online version of the docs can be found here: http://aspn.activestate.com/ASPN/docs/ActivePython/2.5/welcome.html http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/welcome.html We would welcome any and all feedback to: ActivePython-feedback at activestate.com.com Please file bugs against ActivePython at: http://bugs.activestate.com/query.cgi?product=ActivePython On what platforms does ActivePython run? ---------------------------------------- ActivePython includes installers for the following platforms: - Windows/x86 - Mac OS X - Linux/x86 - Solaris/SPARC - Solaris/x86 - Windows/x64 ("x64" is also known as "AMD64") - Linux/x86_64 ("x86_64" is also known as "AMD64") - HP-UX/PA-RISC - AIX/PowerPC Extra Bits ---------- ActivePython releases also include the following: - ActivePython24.chm, ActivePython25.chm: An MS compiled help collection of the full ActivePython documentation set. Linux users of applications such as xCHM might find this useful. This package is installed by default on Windows. Extra bits are available from: http://downloads.activestate.com/ActivePython/etc/ Apologies for the delay. I was crazy-busy getting the Komodo 4.3 release out. Check it out: http://www.activestate.com/products/komodo/ Thanks, and enjoy! Trent, Python Tech Lead -- Trent Mick trentm at activestate.com From floris.bruynooghe at gmail.com Fri Apr 4 07:36:53 2008 From: floris.bruynooghe at gmail.com (Floris Bruynooghe) Date: Fri, 4 Apr 2008 04:36:53 -0700 (PDT) Subject: Any fancy grep utility replacements out there? References: Message-ID: <2a1695f7-5e1a-46f3-9c69-76a930e5dd10@e39g2000hsf.googlegroups.com> On Mar 19, 2:44 am, Peter Wang wrote: > On Mar 18, 5:16 pm, Robert Kern wrote: > > > > > samsli... at gmail.com wrote: > > > So I need to recursively grep a bunch of gzipped files. This can't be > > > easily done with grep, rgrep or zgrep. (I'm sure given the right > > > pipeline including using the find command it could be done....but > > > seems like a hassle). > > > > So I figured I'd find a fancy next generation grep tool. Thirty > > > minutes of searching later I find a bunch in Perl, and even one in > > > Ruby. But I can't find anything that interesting or up to date for > > > Python. Does anyone know of something? > > > I have a grep-like utility I call "grin". I wrote it mostly to recursively grep > > SVN source trees while ignoring the garbage under the .svn/ directories and more > > or less do exactly what I need most frequently without configuration. It could > > easily be extended to open gzip files with GzipFile. > > > https://svn.enthought.com/svn/sandbox/grin/trunk/ > > > Let me know if you have any requests. > > And don't forget: Colorized output! :) I tried to find something similar a while ago and found ack[1]. I do realise it's written in perl but it does the job nicely. Never needed to search in zipfiles though, just unzipping them in /tmp would always work... I'll check out grin this afternoon! Floris [1] http://petdance.com/ack/ From nick at craig-wood.com Tue Apr 22 16:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Tue, 22 Apr 2008 15:30:03 -0500 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? References: Message-ID: Mark Wooding wrote: > Nick Craig-Wood wrote: > > Harishankar wrote: > >> 1. Create non-blocking pipes which can be read in a separate thread > >> [...] > > > > You are correct on both of those points. > > I must be missing something. What's wrong with spawning the subprocess > with subprocess.Popen as usual, passing subprocess.PIPE as stdin/stdout/ > whatever, making your end nonblocking with fcntl.fcntl and then using > os.read/os.write in the obvious ways? Nothing apart from the fact it doesn't work on windows. The buffering will cause you grief too. If you want to do this properly under unix use pexpect not subprocess. http://www.noah.org/wiki/Pexpect Proper non blocking IO is an absolute nightmare under Windows in my experience! It really isn't the Windows way so you are fighting the system the whole time. -- Nick Craig-Wood -- http://www.craig-wood.com/nick From mal at egenix.com Fri Apr 18 07:32:05 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Fri, 18 Apr 2008 13:32:05 +0200 Subject: Database vs Data Structure? In-Reply-To: References: Message-ID: <480886B5.1000004@egenix.com> On 2008-04-18 05:37, erikcw wrote: > Hi, > > I'm working on a web application where each user will be creating > several "projects" in there account, each with 1,000-50,000 objects. > Each object will consist of a unique name, an id, and some meta data. > > The number of objects will grow and shrink as the user works with > their project. > > I'm trying to decided whether to store the objects in the database > (each object gets it's own row) or to use some sort of data-structure > (maybe nested dictionaries or a custom class) and store the pickled > data-structure in a single row in the database (then unpickle the data > and query in memory). > > A few requirements: > -Fast/scalable (web app) > -able to query objects based on name and id. > -will play nicely with versioning (undo/redo) > > Any input on the best way to go? Relational databases offer the best scalability and reliability, so I'd go for those as backend. If your data is mostly read-only and usually only touches a small part of your database (e.g. the data for a day or two), then you can increase query performance by keeping that part in an in-memory database (e.g. use sqlite or Oracle TimesTen) and only update the copy in case something changes in the backend. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 18 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From hexade at gmail.com Sat Apr 12 18:45:25 2008 From: hexade at gmail.com (Hexade) Date: Sat, 12 Apr 2008 15:45:25 -0700 (PDT) Subject: SQLite OperationalError near "?" Message-ID: <7e592f06-42b5-4834-8f7c-34c9bc44aceb@s39g2000prd.googlegroups.com> Hello I would like to use the safe "?" placeholder in my SQLite requests but I got the following error: Traceback (most recent call last): (...) cursor.execute("SELECT ? FROM ? WHERE name = ? ", (key, self.table, self.name)) OperationalError: near "?": syntax error key, self.table and self.name are standart strings. Any idea about how to solve this problem ? Thanks in advance, Hexade From version5 at gmail.com Thu Apr 3 08:24:11 2008 From: version5 at gmail.com (nnp) Date: Thu, 3 Apr 2008 13:24:11 +0100 Subject: Python queue madness In-Reply-To: References: <28749c0e0804020652o74a9491an9eef9ba1813434fb@mail.gmail.com> Message-ID: <28749c0e0804030524p2f1b4d9fn1d63f93794b57ab5@mail.gmail.com> Hrm, it sounds likely that I am using something mutable and that is messing things up. I'll look into it. As for providing sample code to recreate the problem, I would find it difficult I think to provide a simple example that accurately reflects what is truly going on so there wouldn't be much point. Cheers, nnp On Thu, Apr 3, 2008 at 5:39 AM, Gabriel Genellina wrote: > En Wed, 02 Apr 2008 10:52:08 -0300, nnp escribi?: > > > Basically I have a system where component 1, 2 and 3 communicate with > > each > > other using two Python Queues, we'll call them R and W. Here is what is > > happening > > > > 1 writes data to W and reads from R > > 2 reads data from W and writes data it receives from 3 to R (but not > > data it > > receives from 1) > > 3 writes to W > > > > The problem is that data being written by 1 to W is appearing back on R. > > I > > have verified that 1 never writes to R and that 2 never writes data it > > receives from 1 to R, by overwriting the put() and put_nowait() methods > > of > > R. > > > > Is there any other way for data to get onto a queue or are there any > > known > > bugs with Python's Queue module that could lead to this kind of > > behaviour? > > Yes, your own code :) > Perhaps you put mutable objects into the queue, like a list? and later > modify the list in another place? > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://www.smashthestack.org http://www.unprotectedhex.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From Lie.1296 at gmail.com Tue Apr 22 07:06:47 2008 From: Lie.1296 at gmail.com (Lie) Date: Tue, 22 Apr 2008 04:06:47 -0700 (PDT) Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B80B5.1050500@cheimes.de> Message-ID: On Apr 21, 1:14 am, "Hank @ITGroup" wrote: > Christian Heimes wrote: > > Gabriel Genellina schrieb: > > >> Apart from what everyone has already said, consider that FreqDist may import other modules, store global state, create other objects... whatever. > >> Pure python code should not have any memory leaks (if there are, it's a bug in the Python interpreter). Not-carefully-written C extensions may introduce memory problems. > > > Pure Python code can cause memory leaks. No, that's not a bug in the > > interpreter but the fault of the developer. For example code that messes > > around with stack frames and exception object can cause nasty reference > > leaks. > > > Christian > > In order to deal with 400 thousands texts consisting of 80 million > words, and huge sets of corpora , I have to be care about the memory > things. I need to track every word's behavior, so there needs to be as > many word-objects as words. > I am really suffering from the memory problem, even 4G memory space can > not survive... Only 10,000 texts can kill it in 2 minutes. > By the way, my program has been optimized to ``del`` the objects after > traversing, in order not to store the information in memory all the time. May we be explained a little further on what you're doing on the 80 million words? Perhaps we could help you better the design since, as Christian Heimes has said, the 80 million words strains present day computers to hold on memory all at once as it requires 500 MBs to hold 80 million for 6 ASCII letters words. If you're using Unicode, this number may double or quadruple. A better solution may be achieved by loading parts of the text required and process it using generators or to index the words, it may be slower (or even faster as the OS wouldn't need to allocate as much memory) but that's a tradeoff you should decide on. From frikker at gmail.com Tue Apr 29 11:09:18 2008 From: frikker at gmail.com (blaine) Date: Tue, 29 Apr 2008 08:09:18 -0700 (PDT) Subject: Simple TK Question - refreshing the canvas when not in focus References: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> Message-ID: <01b7e1cd-2e30-4751-9be5-63684af6530d@8g2000hse.googlegroups.com> On Apr 29, 10:36 am, "Eric Brunel" wrote: > On Tue, 29 Apr 2008 15:22:12 +0200, blaine wrote: > > Hey everyone! > > I'm not very good with Tk, and I am using a very simple canvas to > > draw some pictures (this relates to that nokia screen emulator I had a > > post about a few days ago). > > > Anyway, all is well, except one thing. When I am not in the program, > > and the program receives a draw command (from a FIFO pipe), the canvas > > does not refresh until I click into the program. How do I force it to > > refresh, or force the window to gain focus? It seems like pretty > > common behavior, but a few things that I've tried have not worked. > > > Class screen(): > > def __init__(self): > > self.root = Tkinter.Tk() > > self.root.title('Nokia Canvas') > > self.canvas = Tkinter.Canvas(self.root, width =130, > > height=130) > > self.canvas.pack() > > self.root.mainloop() > > > Then somewhere a long the line I do: > > self.canvas.create_line(args[0], args[1], args[2], > > args[3], fill=color) > > self.canvas.pack() > > Unrelated question: why are you doing a .pack() again here? Packing the > widget just inserts it at the right place in its container, so you only > have to do it once. So the one you did in __init__ is enough. > > > I've tried self.root.set_focus(), self.root.force_focus(), > > self.canvas.update(), etc. but I can't get it. > > IIRC: > - self.root.set_focus() will only work if your application already has the > focus, so it's not what you need here. > - self.root.force_focus() is usually considered as evil: it'll give the > focus to your application whatever the user is doing, which is usually > *really* annoying. So I guess a lot of window managers just refuse to do > it; this may be what happens here. > > But self.canvas.update() should work. If it doesn't, then there are > probably limitations on your platform that prevents it to work... Do you > happen to have other applications that can update their display while they > don't have the focus? Do they have the same problem? If they do, it's > probably a limitation on the platform and I guess you won't be able to do > anything about it... BTW, what platform are you on? > > > Thanks! > > Blaine > > HTH > -- > python -c "print ''.join([chr(154 - ord(c)) for c in > 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])" Thanks a lot for the response! To answer your first question - I'm using pack() there because I didn't mean to slip it in - this is something I wrote very quickly and was playing around with... and pack() should not be there, heh. I'm just using OS X with Python 2.5. For the record - I don't mind if the application forces focus. The only time I will be running this emulator is when I'm trying to use it. I'll try the update() again. I would want to use that on the canvas itself right? Not the root window? Blaine From catalinfest at gmail.com Sat Apr 26 02:50:23 2008 From: catalinfest at gmail.com (catalinfest at gmail.com) Date: Fri, 25 Apr 2008 23:50:23 -0700 (PDT) Subject: new user Message-ID: <890bb3c8-94a7-4d08-8c3e-4260ab76b6f7@b1g2000hsg.googlegroups.com> Hi ! This is my first message . I new here . I like python , blender 3d and opengl and is a hobby for me. I have a site www.catalinfest.xhost.ro where i write about me and python , blender ... I hope learning more on this group . Have a nice day ! From exarkun at divmod.com Wed Apr 16 16:27:40 2008 From: exarkun at divmod.com (Jean-Paul Calderone) Date: Wed, 16 Apr 2008 16:27:40 -0400 Subject: Profiling, recursive func slower than imperative, normal? In-Reply-To: Message-ID: <20080416202740.6859.1493080452.divmod.quotient.30718@ohm> On Wed, 16 Apr 2008 13:18:22 -0700 (PDT), skanemupp at yahoo.se wrote: >the 0.409 vs 0.095 is the total times right? >so the imperative function is >4 times faster than the recursive. >or what does tottime stand for? > >is this always the case that the recursive function is slower? >the gain is less code? > >are some functions only implementable recursively? > Function calls (recursive or otherwise) are more expensive than for loops, so the version that replaces recursion with a loop is faster. Any function can be implemented without recursion, although it isn't always easy or fun. Jean-Paul From george.sakkis at gmail.com Tue Apr 1 12:48:26 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 1 Apr 2008 09:48:26 -0700 (PDT) Subject: class super method References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> <0eb3ee4e-82e2-419a-8e7b-4931f7b4effa@c26g2000prf.googlegroups.com> Message-ID: <5e597dca-204d-4ed6-b477-cdfb6e5eaa78@d21g2000prf.googlegroups.com> On Apr 1, 10:21 am, Ed Leafe wrote: > On Apr 1, 2008, at 8:43 AM, George Sakkis wrote: > > Pehaps, at least as long as you make sure that all superclasses have a > > compatible signature - which in practice typically means accept > > arbitrary *args and **kwargs in every class in the hierarchy like your > > example. Good luck figuring out what's wrong if it's not used > > consistently. > > See my comment above. If you do not know what you're doing, you > shouldn't be doing it. This is not the fault of super(); it's the > fault of a poor programmer. And I used generic *args and **kwargs in > the method sig since I was using made-up class names and methods. > Would you have reacted more favorably if I had used (self, foo, bar) > instead? No, that was exactly my point; with a non-generic signature like (self, foo, bar), it's a matter of time until some subclass breaks it. Non-trivial hierarchies with all __init__ having compatible signatures is not typical in my experience, but they have to be compatible to be used correctly with super. Here is the conclusion from the second article I linked: ''' If you do use super, here are some best practices: * Use it consistently, and document that you use it, as it is part of the external interface for your class, like it or not. * Never call super with anything but the exact arguments you received, unless you really know what you're doing. * When you use it on methods whose acceptable arguments can be altered on a subclass via addition of more optional arguments, always accept *args, **kw, and call super like "super(MyClass, self).currentmethod(alltheargsideclared, *args, **kwargs)". If you don't do this, forbid addition of optional arguments in subclasses. * Never use positional arguments in __init__ or __new__. Always use keyword args, and always call them as keywords, and always pass all keywords on to super. ''' > > In a sentence, it's better than nothing but worse than anything. > > I guess I must be the world's most amazing Python developer, as I've > used super() extensively for years without ever suffering any of the > pitfalls you and others describe. Some people use the same argument for explicit memory management in C/C ++. Sure, it can be done, but that doesn't make it elegant or trivial. When experts like Michele Simionato find super() tricky enough to write an article about it, that says something. George From bellman at lysator.liu.se Fri Apr 18 14:50:26 2008 From: bellman at lysator.liu.se (Thomas Bellman) Date: Fri, 18 Apr 2008 18:50:26 +0000 (UTC) Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> Message-ID: John Nagle writes: > Desktop or server? > If server, check what the major Linux distros, like Fedora > Core, are shipping with. For server, you should probably rather look at distros like RHEL/CentOS, Suse and Debian Stable. For what it's worth, Fedora 8 has Python 2.5, RHEL 5 ships with Python 2.4, and RHEL 4 has Python 2.3. Suse and Debian, I don't know. > Check major shared hosting providers to see what they're offering > to their customers as standard. I would expect that to often depend on what OS version they are using. And RHEL/CentOS 4 is still quite common, so if you want to reach a large "customer base", make sure that your Python programs work with Python 2.3. -- Thomas Bellman, Lysator Computer Club, Link??ping University, Sweden "Don't tell me I'm burning the candle at both ! bellman @ lysator.liu.se ends -- tell me where to get more wax!!" ! Make Love -- Nicht Wahr! From http Thu Apr 17 17:10:14 2008 From: http (Paul Rubin) Date: 17 Apr 2008 14:10:14 -0700 Subject: How to make this unpickling/sorting demo faster? References: <40a5d8f1-a246-4c48-8759-5b65324f9029@m73g2000hsh.googlegroups.com> Message-ID: <7xod88w5l5.fsf@ruckus.brouhaha.com> Steve Bergman writes: > Anything written in a language that is > 20x slower (Perl, Python, > PHP) than C/C++ should be instantly rejected by users on those grounds > alone. Well, if you time it starting from when you sit down at the computer and start programming, til when the sorted array is output, Python might be 20x faster than C/C++ and 100x faster than assembler. > I've challenged someone to beat the snippet of code below in C, C++, > or assembler, for reading in one million pairs of random floats and > sorting them by the second member of the pair. I'm not a master > Python programmer. Is there anything I could do to make this even > faster than it is? 1. Turn off the cyclic garbage collector during the operation since you will have no cyclic garbage. 2. See if there is a way to read the array directly (using something like the struct module or ctypes) rather than a pickle. 3. Use psyco and partition the array into several smaller ones with a quicksort-like partitioning step, then sort the smaller arrays in parallel using multiple processes, if you have a multicore CPU. 4. Write your sorting routine in C or assembler and call it through the C API. If the sorting step is a small part of a large program and the sort is using a lot of cpu, this is a good approach since for the other parts of the program you still get the safety and productivity gain of Python. > Also, if I try to write the resulting list of tuples back out to a > gdbm file, I don't understand what you're doing with gdbm. Just use a binary file. From sturlamolden at yahoo.no Tue Apr 15 16:51:50 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Tue, 15 Apr 2008 13:51:50 -0700 (PDT) Subject: Preferred method for "Assignment by value" References: <8562becb-9fef-415d-9640-05ef80123596@a5g2000prg.googlegroups.com> <534f02b3-1eda-4332-96ae-3db3d4b4f44a@s33g2000pri.googlegroups.com> Message-ID: On Apr 15, 8:19 pm, hall.j... at gmail.com wrote: > Coming from VBA I have a tendency to think of everything as an > array... Coding to much in Visual Basic, like Fortran 77, is bad for your mind. From deets at nospam.web.de Thu Apr 3 04:39:34 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 03 Apr 2008 10:39:34 +0200 Subject: Prototype OO In-Reply-To: References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> Message-ID: <65jjeaF2ghnarU1@mid.uni-berlin.de> > And I say "syntax should be the same". These are only opinions, so > forgive me for wasting your time. You mean like in JS? function foo(args) {} foo = function(args) {} Somehow the JS-designers also made a compromise to allow to create unnamed and named functions. Could it be that it make *sense* to sacrifice simplicity and orthogonality here, so that different usage scenarios get to be written concisely? Start coding in python. And enjoy it. Is it perfect? Heck no! But it sure is fun enough to deal with the occasional wart. Diez From pylists at arcor.de Sun Apr 13 05:31:54 2008 From: pylists at arcor.de (Penny Y.) Date: Sun, 13 Apr 2008 17:31:54 +0800 Subject: =?UTF-8?B?5pyJ5Lit5Zu95Lq65LmOPw==?= In-Reply-To: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> References: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> Message-ID: <4801D30A.501@arcor.de> bikthh at live.cn ??: > Python????????????????. hehe, so humorous you are! Yes I think python has good future. But it depends on what you use it to do. If you're a singer, a financier, a historian etc, you don't need python. But if you are playing in computer programming, it's valuable for you to take some time learning python. btw,I'm also newbie to python,but I like it. --penny From maxm at mxm.dk Tue Apr 22 07:18:58 2008 From: maxm at mxm.dk (Max M) Date: Tue, 22 Apr 2008 13:18:58 +0200 Subject: Python Success stories In-Reply-To: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: azrael skrev: > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" When I started writing in Python in the nineties there was a lot of tech-media coverage of Perl. Python was always mentioned as a rival to Perl in those articles. These days Python is mentioned in a lot of tech-articles. Perl is never mentioned as a rival in those articles. Other languages like Ruby are. Ok I am Python biased, but I don't see anything happen on the Perl front anymore. It has simply gone quiet. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science From donn at u.washington.edu Mon Apr 28 19:46:05 2008 From: donn at u.washington.edu (Donn Cave) Date: Mon, 28 Apr 2008 16:46:05 -0700 Subject: Simple unicode-safe version of str(exception)? References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> Message-ID: In article <481650E3.4060603 at v.loewis.de>, "Martin v. L?wis" wrote: > >> I have code like this: > >> except Exception, e: > >> self.setState(self.Failed, str(e)) > >> which fails if the exception contains a unicode argument. > > > > Fails how? > > ASCII encoding error, I suppose. It fails only if a) one argument > is a Unicode object, and b) that Unicode object contains non-ASCII > parameters. Seem ironic that this fails even though pretty nearly anything else is a valid input to str() -- socket, dict, whatever? A sort of generic solution might be to follow str's behavior with respect to '__str__', extending it to fall back to repr() whatever goes wrong. def xtr(a): try: return str(a) except: return repr(a) ... self.setState(self.Failed, xtr(e)) Donn Cave, donn at u.washington.edu From manthra.mohan at gmail.com Fri Apr 18 11:21:48 2008 From: manthra.mohan at gmail.com (Krishna) Date: Fri, 18 Apr 2008 08:21:48 -0700 (PDT) Subject: Excel Manipulation using Python Message-ID: I was trying to delete rows in an existing .xls file using python. How do I do that? I was using the following code, it seem to work if I type in python window, but if I save it in text editor and drage and drop the .py file, it doesnt work. What am I doing wrong here? Thanks for your help! import win32com.client from time import sleep excel = win32com.client.Dispatch("Excel.Application") def Extract(): excel.Visible = 0 workbook=excel.Workbooks.Open('C:\Trial.xls') i=1 for n in range(1,10): excel.Rows(i).Select excel.Selection.Delete excel.Selection.Delete i=i+2 workbook.Save() print "saved" excel.Quit() From martin at v.loewis.de Sun Apr 13 01:39:36 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 13 Apr 2008 07:39:36 +0200 Subject: Tremendous slowdown due to garbage collection In-Reply-To: <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: <48019C98.8040800@v.loewis.de> > I still don't see what is so good about defaults that lead to O(N*N) > computation for a O(N) problem, and I like Amaury's suggestion a lot, > so I would like to see comments on its disadvantages. Please don't > tell me that O(N*N) is good enough. For N>1E7 it isn't. Please understand that changing the defaults will *not* affect the asymptotic complexity. If your application shows O(N*N), then, multiplying each value in the gc frequency with 1000, your application might run faster, but it will *still* run at O(N*N). Regards, Martin From gagsl-py2 at yahoo.com.ar Wed Apr 16 11:15:38 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 08:15:38 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: <86063f29-21a8-4d5b-a374-cee0723e0852@a22g2000hsc.googlegroups.com> On 16 abr, 09:56, Aaron Watters wrote: > In my opinion python's adherence to backwards compatibility > has been a bit mythological anyway -- many new python versions > have broken my old code for no good reason. ?This is an irritant > when you have thousands of users out there who suddenly drop > your code, blame you and python, and move on to use something else. > Honestly, how hard would it have been to provide standard backwards > support for the old regex module as a standard module which simply > translated one regex string format to another, for example? Do you mean this? py> import reconvert py> help(reconvert) Help on module reconvert: NAME reconvert - Convert old ("regex") regular expressions to new syntax ("re"). FILE c:\apps\python24\lib\reconvert.py DESCRIPTION When imported as a module, there are two functions, with their own strings: convert(s, syntax=None) -- convert a regex regular expression to re syntax quote(s) -- return a quoted string literal When used as a script, read a Python string literal (or any other expression evaluating to a string) from stdin, and write the translated expression to stdout as a string literal. Unless stdout is a tty, no trailing \n is written to stdout. This is done so that it can be used with Emacs C-U M-| (shell-command-on-region with argument which filters the region through the shell command). > What I'm saying is that, for example, there are a lot > of cool tools out there for using Python to manipulate > postscript and latex and such. Most of those tools > require no maintenance, and the authors are not paying > any attention to them, and they aren't interested in > messing with them anymore. And they will continue to work using the Python version for which they were designed, or even a later one; probably up to the last 2.x. Some scripts designed for Python 1.x still work. Really I don't feel the 3.0 incompatibilities are so big. > My guess is that there are few > such tools for Ruby. However, I wouldn't be too > surprised if porting them to Ruby and testing them > properly is not much more difficult than porting them > to py3k and testing them properly... If you have to convert the code to 3.x, 2to3 does most of the dirty work. Of course you have to test properly - the same as with any new version. And you can't say seriously than porting to Ruby is easier than fixing the incompatibilities with 3.0 > Especially > since the basic treatment of strings is totally > different in py3k, it seems. No. The new str type is the (renamed) old unicode type. Old strings are called bytes now. Both are immutable and mostly support the same old methods. Comparing (2.5) dir(u"") with (3.0) dir(""): decode() is not supported anymore; new: isidentifier(), maketrans(). Comparing (old) str with (new) bytes: encode() is not supported, nor format(); fromhex() added. So they look basically the same to me. Ok, when in 2.x you write u"abc", it's spelled "abc" in 3.0; and when you write "abc" it will be spelled b"abc". But that change is easily done with the 2to3 tool, or using "from __future__ import unicode_literals" in Python 2.6. Again, not so terrible. It seems to me that the fear of the upcoming 3.0 is caused mostly by lack of information. -- Gabriel Genellina From stef.mientki at gmail.com Thu Apr 10 15:03:28 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Thu, 10 Apr 2008 21:03:28 +0200 Subject: win-shortcuts, file associates and command-line parameters ? Message-ID: <47FE6480.4090602@gmail.com> hello, under windows I tried to make a shortcut to a py -file, to run a program. So making a shortcut like this works perfect: D:\PyLab_Works.py But the problem is that I need to give some commandline parameters to the py-file, and D:\PyLab_Works.py btc_test But the parameter doesn't seem to arrive in the python program If I start with the python interpreter, the parameters do arrive at the program P:\pythonw.exe D:\PyLab_Works.py btc_test Although this method works, it makes the creation of shortcuts difficult (the paths are in real much longer). Is there a way to pass the commandline parameters correctly, without explicitly specifying the python interpreter ? thanks, Stef Mientki From sn at sncs.se Mon Apr 14 22:07:37 2008 From: sn at sncs.se (Sverker Nilsson) Date: Mon, 14 Apr 2008 19:07:37 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> Message-ID: On Apr 15, 2:58 am, ajaksu wrote: > On Apr 14, 8:10 pm, Sverker Nilsson wrote:> do i dare to open a thread about this? > > Yeah, you sure do! > > > come on you braver men > > Yeah! > > > we are at least not bought by g***le > > Hell no! > > > but why? others have said it so many times i think > > Huh?! > > > :-//// > > ?! Whatever! > > > but why? a few syntactic 'cleanups' for the cost of a huge rewrite of > > all the code that have been builtup from all the beginning when the > > once great Python came along and people began to use it and write code > > for it. Like all that code would have to be rewritten. blaah. > > Yeah! Woo-hoo! > Wait... What? No, no, you got it all wrong. Python developers are > being extra-careful and doing a lot of hard work to keep things sane, > allow easy migration, etc. > > > and i have perhaps been drinking but i have been p**d all week since i > > began look into this:-( > > Ah, OK, calm down and look again. Things are way better than you > think, but there is a lot of FUD going on too, so focus on serious, > reliable reports. > > Cheers, > Daniel What serious reports? From bobby.connor at gmail.com Tue Apr 1 12:11:12 2008 From: bobby.connor at gmail.com (bobby.connor at gmail.com) Date: Tue, 1 Apr 2008 09:11:12 -0700 (PDT) Subject: Homework help Message-ID: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> Hey guys I haev this homework assignment due today I don't necessarily want the answers, but need help on how to approach it/the steps i need to solve the problems Thanks # (2 Points) Write a python function howMany(item,lst) which accepts an item and a lst of items and returns the number of times item occurs in lst. For example, howMany(3,[1,2,3,2,3]) should return 2. # (2 Points) Write a python function upTo(n) which accepts a non- negative number n and returns a list of numbers from 0 to n. For example, upTo(3) should return the list [0, 1, 2, 3]. # (2 Points) Write a python function duplicate(lst) which accepts a lst of items and returns a list with the items duplicated. For example, duplicate([1,2,2,3]) should return the list [1, 1, 2, 2, 2, 2, 3, 3]. # (2 Points) Write a python function dotProduct(a,b) which accepts two lists of integers a and b that are of equal length and which returns the dot product of a and b. I.e., the sum a0 * b0 + ... + an-1 * bn-1 where n is the length of the lists. For example: dotProduct([1,2,3],[4,5,6]) is 1*4 + 2*5 + 3*6 = 4 + 10 + 18 = 32 # (2 Points) A pair (exp0, exp1) is a combination of expressions that are attached together by their joint membership in the pair. For example: >>> (1+2, 'This') (3, 'This') A component of a pair can be obtained using an index in brackets as with lists (and strings!). For example: >>> (33,44)[0] 33 Write a function zip(lst1, lst2) such that zip accepts two equal length lists and returns a list of pairs. For example, zip(['a', 'b', 'c'], [10, 20, 30]) should evaluate to the list [('a', 10), ('b', 20), ('c', 30)]. # (2 Points) Write a function unzip(lst) such that unzip accepts a list of pairs and returns two lists such that lst == zip(unzip(lst)). For example, unzip([('a', 10), ('b', 20), ('c', 30)] should evaluate to the pair (['a', 'b', 'c'], [10, 20, 30]). # (2 Points) Write a python function isAscending(lst) which accepts a non-empty list of integers and returns True if the numbers in the list are in ascending order. Otherwise it should return False. For example, isAscending([1]) should evaluate to True while isAscending([1,2,2]) should return False. From JesseAldridge at gmail.com Mon Apr 7 11:24:02 2008 From: JesseAldridge at gmail.com (Jesse Aldridge) Date: Mon, 7 Apr 2008 08:24:02 -0700 (PDT) Subject: Python Data Utils References: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> <8eec6557-784d-4fd8-8478-8da17aedf0ab@d1g2000hsg.googlegroups.com> <85979669-64ed-49a1-b154-595bed50179f@w5g2000prd.googlegroups.com> <204305df-2cc8-4f44-8b98-5696e135a936@d45g2000hsc.googlegroups.com> Message-ID: <9f35f47c-ef79-4501-8d3b-bb5adebac518@u3g2000hsc.googlegroups.com> > But then you introduced more. oops. old habits... > mxTextTools. This looks cool, so does the associated book - "Text Processing in Python". I'll look into them. > def normalise_whitespace(s): > ? ? return ' '.join(s.split()) Ok, fixed. > a.replace('\xA0', ' ') in there somewhere. Added. Thanks again. From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 18 04:14:59 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 18 Apr 2008 10:14:59 +0200 Subject: Database vs Data Structure? In-Reply-To: <61bf5f46-e917-4a98-b87f-8e5087cb07f7@a23g2000hsc.googlegroups.com> References: <61bf5f46-e917-4a98-b87f-8e5087cb07f7@a23g2000hsc.googlegroups.com> Message-ID: <4808586b$0$23721$426a74cc@news.free.fr> erikcw a ?crit : > Hi, > > I'm working on a web application where each user will be creating > several "projects" in there account, each with 1,000-50,000 objects. > Each object will consist of a unique name, an id, and some meta data. > > The number of objects will grow and shrink as the user works with > their project. > > I'm trying to decided whether to store the objects in the database > (each object gets it's own row) or to use some sort of data-structure > (maybe nested dictionaries or a custom class) and store the pickled > data-structure in a single row in the database (then unpickle the data > and query in memory). Yuck. Fighting against the tool won't buy you much - except for interoperability and maintainance headeaches. Either use your relational database properly, or switch to an object db - like ZODB or Durus - if you're ok with the implications (no interoperability, no simple query langage, and possibly bad performances if your app does heavy data processing). > A few requirements: > -Fast/scalable (web app) > -able to query objects based on name and id. > -will play nicely with versioning (undo/redo) Versionning is a somewhat othogonal problem. > Any input on the best way to go? My very humble opinion - based on several years of working experience with both the Zodb and many RDBMS - is quite clear : use a RDBMS and use it properly. From meisnernel73884 at gmail.com Wed Apr 30 06:36:47 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:36:47 -0700 (PDT) Subject: soul patch Message-ID: <16c6778a-39a4-4629-a8c5-306b0c453e8b@s50g2000hsb.googlegroups.com> soul patch http://crack.cracksofts.com From zolotoiklo at mail.ru Tue Apr 8 06:50:52 2008 From: zolotoiklo at mail.ru (=?KOI8-R?B?+s/Mz9TPyiDrzM/O?=) Date: Tue, 8 Apr 2008 03:50:52 -0700 (PDT) Subject: =?KOI8-R?B?6NXMwcjV0CDT0NLUydfO2cogz8LS1d4g0yDNwQ==?= =?KOI8-R?B?x87J1MHNySDV1NHWxczFzs7Zyg==?= Message-ID: <725ff219-90fc-431a-931d-bdb78967abea@m1g2000pre.googlegroups.com> Acu Hoop Pro. ?????????, ??????????? ?????-???????. ??? ??? ??? ? ????????? (Acu Hoop Pro) - ?????????? ???????? ????????? ?????????? ????? ??? ????, ??? ?????? ???????? ? ??????? ???????????? ????? ? ???????? ??????.?? ??????? 100 ??????? ?? ?????? 10 ????? ??????????!!! ????????? ??????????? ?????????????? ??????? ???????????, ????????? ????? ??? ??? ??? ???????? BRADEX ???????????? ???????? ???????? ?????????? ???? ? ??????? ????? ? ??????. ????????? ?????? ????? ? ?????. ???????? ? ???? ???????? ???????? ????-???? ? ???????? ?????????? ?????????????? ???????. ??? ???????????? ?????????? ???? ?????????? ??????? ?????????????? ? ???????? ? ?????? ? ?????????? ??????? ?????????. ????? ???????, ?????????? ?????????????????????, ??????????????, ??????????, ????????????? ????????. ????????? ???? ????????? ??????????? ?? ???????? ????????? ? ????? ?????????. ? ?????? ??????????? ?????????? ???? ?????????? ??????????????? (5-15 ?????) ?????????? ???????????? ?????????, ??????? ????? ????????? ??????????? ????????????????, ?????????? ????????? ???????????? ?????????, ????????? ?????????????? ??????????? ?????????? ??????, ? ?????????? ?? ???????????????. ???????? ????? ?? ???? ???? ??? ??? 40 ??? ???????? ???? ???? ????????. ?????? ????? - ??????? ???! ?????? ??????? - ????????? ?????! ??????? ????????? ????? http://shopbody.ru/bradexobruchmagnit.htm From n00m at narod.ru Sat Apr 26 23:58:38 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 20:58:38 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> Message-ID: Dennis Lee Bieber wrote: > (untested for both): > -=-=-=-=-=-=- Many thanks but alas both your codes got "wrong answer" verdict. I can't understand why; they seem Ok (but I'm a bit sleepy:)). From andrei.avk at gmail.com Tue Apr 1 21:15:15 2008 From: andrei.avk at gmail.com (AK) Date: Tue, 01 Apr 2008 20:15:15 -0500 Subject: Python-by-example - new online guide to Python Standard Library Message-ID: <47f2d018$0$6517$4c368faf@roadrunner.com> Hello, I find that I learn easier when I go from specific examples to a more general explanation of function's utility and I made a reference guide that will eventually document all functions, classes and methods in Python's Standard Library. For now, I covered about 20 most important modules. I will be adding more modules and eventually I'll cover everything. Here's my progress so far, let me know if this is useful; I'll be glad to hear comments/suggestions/etc: http://www.lightbird.net/py-by-example/ -- -ak Tobu | http://www.lightbird.net/tobu/ | Freeform DB / Tagger / PIM From NikitaTheSpider at gmail.com Wed Apr 9 13:25:22 2008 From: NikitaTheSpider at gmail.com (Nikita the Spider) Date: Wed, 09 Apr 2008 13:25:22 -0400 Subject: is Pylons alive? References: <663qr1F2ig5dkU1@mid.uni-berlin.de> Message-ID: In article <663qr1F2ig5dkU1 at mid.uni-berlin.de>, Gerhard H?ring wrote: > - TurboGears 2.0 (I personally wouldn't bother with TurboGears 1.x at > this point) Having investigated some of this myself recently, I agree with you that the TG 1.x series is a dead end, but there's no TG 2.0 yet. Last time I checked the developers hoped to have an alpha release at the end of March. -- Philip http://NikitaTheSpider.com/ Whole-site HTML validation, link checking and more From jeffober at gmail.com Mon Apr 28 09:22:32 2008 From: jeffober at gmail.com (Jeff) Date: Mon, 28 Apr 2008 06:22:32 -0700 (PDT) Subject: Regular Expression - Matching Multiples of 3 Characters exactly. References: Message-ID: <856060dd-d64d-4961-b57d-0ca7e93c053f@e39g2000hsf.googlegroups.com> Regular expressions for that sort of thing can get *really* big. The most efficient way would be to programmatically compose the regular expression to be as exact as possible. import re def permutation(lst): """" From http://labix.org/snippets/permutations/. Computes permutations of a list iteratively. """ queue = [-1] lenlst = len(lst) while queue: i = queue[-1]+1 if i == lenlst: queue.pop() elif i not in queue: queue[-1] = i if len(queue) == lenlst: yield [lst[j] for j in queue] queue.append(-1) else: queue[-1] = i def segment_re(a, b): """ Creates grouped regular expression pattern to match text between all possibilies of three-letter sets a and b. """ def pattern(n): return "(%s)" % '|'.join( [''.join(grp) for grp in permutation(n)] ) return re.compile( r'%s(\w+?)%s' % (pattern(a), pattern(b)) ) print segment_re(["a", "b", "c"], ["d", "e", "f"]) You could extend segment_re to accept an integer to limit the (\w+?) to a definite quantifier. This will grow the compiled expression in memory but make matching faster (such as \w{3,n} to match from 3 to n characters). See http://artfulcode.net/articles/optimizing-regular-expressions/ for specifics on optimizing regexes. From pavlovevidence at gmail.com Wed Apr 2 20:08:32 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Wed, 2 Apr 2008 17:08:32 -0700 (PDT) Subject: Nested try...except References: Message-ID: <670a8cc4-e3e0-412f-b259-5977f6d2f62d@a70g2000hsh.googlegroups.com> On Apr 2, 9:06 am, Magnus.Morab... at gmail.com wrote: > Hi, > > I found the following code on the net - > > http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/%3C20050924104732.5116.qm... at minotaur.apache.org%3E > > def count(self): > - db = sqlite.connect(self.filename, > isolation_level=ISOLATION_LEVEL) > - try: > - try: > - cur = db.cursor() > - cur.execute("select count(*) from sessions") > - return cur.fetchone()[0] > - finally: > - cur.close() > - finally: > - db.close() > > I don't understand though why the second try is not after the line cur > = db.cursor(). Can anyone explain for me why? It's a pretty common mistake to make, I assume because there's a tendency to line up the init and finalize statements. In other words, it looks wrong for open and close to be in different columns: open() try: do_stuff() finally: close() It's almost always wrong for initiazation to be inside of the try block. Perhaps the advent of with blocks will help reduce this error in the future. Carl Banks From bearophileHUGS at lycos.com Wed Apr 2 15:51:52 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Wed, 2 Apr 2008 12:51:52 -0700 (PDT) Subject: who said python can't be obsfucated!? References: Message-ID: cokofree...: > def s(c):return[]if c==[]else s([_ for _ in c[1:]if _=c[0]]) That QuickSort can be written as a lambda too: s=lambda l:[]if l==[]else s([x for x in l[1:]if x=l[0]]) Bye, bearophile From pydev at rscorp.ab.ca Thu Apr 10 00:03:30 2008 From: pydev at rscorp.ab.ca (Scott SA) Date: Wed, 9 Apr 2008 22:03:30 -0600 Subject: Linux Mag's "Introduction to Python Decorators" Message-ID: Hi, I've been trying to wrap my head around decorators and in my trails found a very recent article on Linux Mag's website. I didn't see a post here regarding this article and feel it is worth directing interested parties towards: Introduction to Python Decorators Have a web app that occasionally hangs? Use signals to add a timeout to function requests with Python decorators. Matthew Wilson Thursday, March 13th, 2008 The link req. registration (sorry, I can't do anything about that). In a brief summary: The author has a Linux-hosted Web service that occasionally hangs. He uses signals via decorators to overcome the problem in an elegant way. While some of the content may not be applicable to all readers needs for decorators, his illustration and description of the subject is very good (IMO, FWIW). I hope this helps others as much as it has for me, Scott From lxlaurax at gmail.com Tue Apr 15 22:17:31 2008 From: lxlaurax at gmail.com (lxlaurax at gmail.com) Date: Tue, 15 Apr 2008 19:17:31 -0700 (PDT) Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <101680ba-a116-414b-8fff-c5b5bd2f4b65@p39g2000prm.googlegroups.com> Message-ID: On 11 abr, 20:31, sturlamolden wrote: > On Apr 11, 5:01 am, "Gabriel Genellina" > wrote: > > > Another annoying thing with the Qt license is that you have to choose it > > at the very start of the project. You cannot develop something using the > > open source license and later decide to switch to the commercial licence > > and buy it. > > Trolltech is afraid companies will buy one licence when the task is > done, as oppsed to one license per developer. In a commercial setting, > the Qt license is not expensive. It is painful for hobbyists wanting > to commercialize their products. I have no experience with GUI programming in Python, but from this discussion it seems if the type of license is not an issue (for FOSS development), PyQt is the best tool because it is: (a) easier to learn and intuitive for programming (this is important to me; I am not that smart...); (b) more stable (although many people have said that wxPython is as stable as any other GUI nowadays; but not more stable (wx) than others); (c) more cross-platform (many people complain that they have to do a lot of things in wxPython for the cross-platform). Is (a) and (c) true or not? If so, how big are these advantages? The great advantage of wxPython seems to be the huge community of users and the large number of widgets/examples/applications available. Reformulating my question: Which GUI tool, wxPython or PyQt, is more pythonic? (Please, ignore the license issue because I am thinking about FOSS) Laura From nospam at nospam.invalid Tue Apr 29 12:17:10 2008 From: nospam at nospam.invalid (Rahul) Date: Tue, 29 Apr 2008 16:17:10 +0000 (UTC) Subject: python command mis-interprets arrow keys Message-ID: My python command line seems messed up. I can't seem to be able to use my backspace key nor my arrow keys. I only get control characters: ^[[A^[[D^[[D^[[D^[[C^[[C^[[C etc. I access my Linux box via a SecureCRT console. Only after opening the python interpreter does this occur. Linux command like is OK. vim interprets keystrokes correctly. So do other interpreters e.g. gnuplot. $LANG $TERM en_US xterm-color Versions: Python 2.4.4 GCC 4.1.2 20070925 (Red Hat 4.1.2-33) Any sugesstions? Google did not throw anything relevant. -- Rahul From munichlinux at news.motzarella.org Sun Apr 20 06:46:12 2008 From: munichlinux at news.motzarella.org (prashanth) Date: Sun, 20 Apr 2008 16:16:12 +0530 Subject: Checking if a text file is blank In-Reply-To: References: Message-ID: Hi elnoire at gmail.com wrote: > Greetings! > > Is there any way in python to check if a text file is blank? obviously there are many ways, one simple way is to check length if its None then the file is blank. > > What I've tried to do so far is: > > f = file("friends.txt", "w") > if f.read() is True: > """do stuff""" > else: > """do other stuff""" > f.close() If checking the file is blank is what you are tying to do then why do you open the file in the write mode. Prashanth From skanemupp at yahoo.se Fri Apr 11 18:41:10 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 11 Apr 2008 15:41:10 -0700 (PDT) Subject: tkinter, annoying grid-problem Message-ID: <094b0808-053a-4a36-be11-694bb3835bb5@q1g2000prf.googlegroups.com> so my little calculator works perfectly now. just having some trouble with the layout. this whole tkinter-thing seems to be more tricky than it should be. how can i make the 4 column of buttons have the same distance and size between them as the other 3 columns? and how can i make the top entry end where the 2nd row entry ends(meaning the top entry will be longer)? why are the 4th row split from the others? hard to fix the problems when u dont even understand why things happen. seems so llogical a lot of it. i change something then something unexpected happens. from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") l = Label(mygui, text="Answer: ") l.grid(row=2, column=1, columnspan=2, sticky=W) e = Entry(mygui) e.grid(row=1, column=1, columnspan=4, sticky=W) c = Entry(mygui) c.grid(row=2, column=3, columnspan=4, sticky=W) def Disp(nstr): e.insert(INSERT, nstr) def Calc(): expr=e.get() c.delete(0, END) try: c.insert(END, eval(expr)) except: c.insert(END, "Not computable") def Erase(): e.delete(0,END) c.delete(0, END) def Backspace(): a=len(e.get()) e.delete(a-1,END) #e.delete(INSERT, END) #e.delete(ANCHOR,END) x = 1 y = 4 for char in '123+456-789*0()/.': b = Button(mygui, text=char, command=lambda n=char:Disp(n), width=2, height=1) b.grid(row=y, column=x, sticky=W) x=x+1 if x==5: x=1 y=y+1 b = Button(mygui, text="^", command=lambda n="**":Disp(n), width=2, height=1) b.grid(row=8, column=2, sticky=W) b = Button(mygui, text="C",command=Erase, width=2, height=1) b.grid(row=8, column=3, sticky=W) b = Button(mygui, text="c",command=Backspace, width=2, height=1) b.grid(row=8, column=4, sticky=W) b = Button(mygui, text="=",command=Calc, width=18, height=1) b.grid(row=9, column=1, columnspan=4, sticky=W) mygui.mainloop() From john106henry at hotmail.com Sun Apr 27 19:11:28 2008 From: john106henry at hotmail.com (John Henry) Date: Sun, 27 Apr 2008 16:11:28 -0700 (PDT) Subject: How do I say "Is this a function"? References: <4813D22A.8040902@v.loewis.de> Message-ID: <7be299bd-4b39-4d46-94f5-ed5a0a895b46@c19g2000prf.googlegroups.com> On Apr 27, 10:49 am, Lie wrote: > On Apr 27, 11:01 am, John Henry wrote: > > > > > On Apr 26, 6:08 pm, "Martin v. L?wis" wrote: > > > > > def f1(): > > > > print "In f1" > > > > > def f3(): > > > > print "In f3" > > > > > def others(): > > > > print "In others" > > > > > for i in xrange(1,3): > > > > fct = "f%d()"%(i+1) > > > > try: > > > > exec fct > > > > except: > > > > others() > > > > I'd write that as > > > > for i in xrange(1,3): > > > globals().get("f%d" % (i+1), others)() > > > > Regards, > > > Martin > > > Perfect. Works great. No EXEC. > > > You guys are great. > > If you just want to avoid exec, why not: > > def f1: > print "In f1" > def f3: > print "In f3" > > class f4(object): > def __init__(self): > print "In f4" > > def others: > print "Since all else failed, I'm in others." > > f2 = "NAF -> Not a Function" > > flist = [f1, f2, f3, f4] > for fct in flist: > try: > fct() > except TypeError: > others() > > It's readable, and it's fast if there's just a few "hard fault" (try- > except works best when it usually succeed and just fails once or > twice), and it's Pythonic too (Easier to ask forgiveness than to ask > permission). The difference between this and the explicit type > checking is that this allows a class (like f4) to pass since a Class > Constructor & Initiator is a callable function too, depending on your > need, you might want to consider class constructor as a function too. The reason I didn't want to do that is because when something goes wrong inside the fcts, others gets executed. I wanted the program to crash and burn rather than running others. From sierra9162 at gmail.com Wed Apr 16 11:22:09 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:22:09 -0700 (PDT) Subject: kate hudson videos Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From deets at nospam.web.de Fri Apr 11 03:50:51 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 11 Apr 2008 09:50:51 +0200 Subject: How to use my dynamic link libraries in python?? In-Reply-To: References: Message-ID: <668jj5F2j08lrU1@mid.uni-berlin.de> ??? schrieb: > Hello: > My OS is Linux, I compile my dynamic link libraries , and > want to call the function of my dynamic library through python! > How can I realize the function? Please give me some advices! Thanks If the module has a plain C-interface, consider using ctypes to wrap it. It comes with python2.5, see the docs. If it is C++, I suggest using SIP, a very good C++-wrapper-generator. There are other options as well, SWIG and Boost-Python, which I can't comment though. Diez From Vern.Muhr at gmail.com Tue Apr 29 16:01:22 2008 From: Vern.Muhr at gmail.com (VernM) Date: Tue, 29 Apr 2008 13:01:22 -0700 (PDT) Subject: cytpes **int References: <56674130-c04e-403e-8364-92cbd158b2f0@b9g2000prh.googlegroups.com> <67mveuF2pauigU1@mid.uni-berlin.de> <67nv84F2l3ha7U1@mid.uni-berlin.de> Message-ID: <42bdae4a-ff8b-477c-bf76-1b33ad4a40b4@t12g2000prg.googlegroups.com> On Apr 28, 11:57?pm, "Diez B. Roggisch" wrote: > Gabriel Genellina schrieb: > > > > > > > [snip repetition] > > > That's true for "a pointer to a pointer to int", and it's valid if the > > functions references **b or b[0][0] - but in this case int** probably > > means "[pointer to] an array of arrays of int" and presumibly the > > function will try to access b[3][2] (or whatever indices are in range). > > The duality pointer/array in C is dangerous when defining interfases - > > you have to know how the value is intended to be accessed. > > (I assume the function modifies the integer values, but not the pointers > > themselves) > > > # build an array of 10x10 ints > > Arr10int = c_int * 10 > > Pint = POINTER(c_int) > > PPint = POINTER(Pint) > > Arr10pint = Pint * 10 > > a = Arr10pint() > > for i in range(10): > > ? ? a[i] = Arr10int() > > ... initialize the array ... > > ... load the function ... > > # call the function > > somefunction.argtypes = (PPint,) > > somefunction.restype = None > > somefunction(a) > > Yup, you are right - I somehow missed the access description and thought > of the pointer-to-a-pointer as out-parameter-spec. > > Diez- Hide quoted text - > > - Show quoted text - To provide a little more detail: currently, a DLL function uses malloc to create a pointer to a block of memory where the ints are stored This pointer is returned to python. Then a pointer to this pointer is passed to another C function which manipulates the ints. When that C function returns, python needs to access the int values. I am now able to get this to work with this grossly ugly code. # Setup a place to store the *int pointer pt = (ctypes.c_int * 1) cube = pt() cube[0] = dll.AllocCube() # Get the pointer to the ints # Call the function that manipulates the ints dll.FirstPrime(ctypes.byref(cube)) # Create a python list of the ints result = [ctypes.c_int.from_address(cube[0]+i*4).value for i in range(5)] I appreciate the suggestions so far. I know there must be a cleaner way to express this. I would prefer the array of ints to be built by cytpes, rather than by a C function in the DLL. From michele.simionato at gmail.com Sat Apr 5 13:07:35 2008 From: michele.simionato at gmail.com (Michele Simionato) Date: Sat, 5 Apr 2008 10:07:35 -0700 (PDT) Subject: Learning curve for new database program with Python? References: Message-ID: <7118c29f-7901-40e7-a410-783ade9c2f6b@a23g2000hsc.googlegroups.com> On Apr 5, 5:50 pm, Jetus wrote: > I have a need for a database program. I downloaded the db2 from ibm, > and reviewed some of the documentation. > > My question is, what is the easiest program for me to try to learn. I > will be creating a database of about 25,000 records, it will be > relational. I am a beginner Python programmer, and need a database > solution that is easy to grasp. I played with sql, > and found that very difficult, if not overly cumbersome. > > A database that could work with Django would be very interesting to > look at as well.. > > Any suggestions out there? sqlite is arguably the simplest relational database out there, and it is integrated with Python 2.5+. Of course you need to tell us if an embedded database if enough for your use case, or if you want a client-server database, if you use Windows or Unix, if you want graphical administration tools or not, what your final goal is, and so on. Michele Simionato From steve at holdenweb.com Sat Apr 5 07:14:56 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 07:14:56 -0400 Subject: Is there any way to say ignore case with "in"? In-Reply-To: <432d690f-44be-49a9-bc6a-1cf3445549d6@m71g2000hse.googlegroups.com> References: <47f692f3$0$759$bed64819@news.gradwell.net> <432d690f-44be-49a9-bc6a-1cf3445549d6@m71g2000hse.googlegroups.com> Message-ID: 7stud wrote: > On Apr 4, 2:43 pm, tinn... at isbd.co.uk wrote: >> Is there any way in python to say >> >> if string1 in string2: >> >> >> ignoring the case of string1 and string2? >> >> I know I could use:- >> >> if lower(string1) in lower(string2): >> >> >> but it somehow feels there ought to be an easier (tidier?) way. >> > > Easier? You mean like some kind of mind meld? > That's right, DWIM mode Python. Rock on! regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From hniksic at xemacs.org Tue Apr 22 02:36:51 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Tue, 22 Apr 2008 08:36:51 +0200 Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <480D71B9.40909@v.loewis.de> Message-ID: <87lk36e6po.fsf@mulj.homelinux.net> "Martin v. L?wis" writes: >> In py3k string%dictionary is going away. > > Why do you say that? It's not going away in Python 3.0. I also got the impression that it was going away. PEP 3101's abstract says: This PEP proposes a new system for built-in string formatting operations, intended as a replacement [sic] for the existing '%' string formatting operator. Under "Backward compatibility" it says that both systems can coexist "until it comes time to deprecate the older system". From breily at gmail.com Wed Apr 16 10:11:09 2008 From: breily at gmail.com (Brian) Date: Wed, 16 Apr 2008 10:11:09 -0400 Subject: is file open in system ? - other than lsof In-Reply-To: References: Message-ID: On Wed, Apr 16, 2008 at 10:00 AM, Chris McAloney wrote: > On 16-Apr-08, at 9:20 AM, A.T.Hofkamp wrote: > > On 2008-04-16, bvidinli wrote: > >> is there a way to find out if file open in system ? - > >> please write if you know a way other than lsof. because lsof if > >> slow for me. > >> i need a faster way. > >> i deal with thousands of files... so, i need a faster / python way > >> for this. > >> thanks. > > > > This is not a Python question but an OS question. > > (Python is not going to deliver what the OS doesn't provide). > > > > Please first find an alternative way at OS level (ie ask this > > question at an > > appropiate OS news group). Once you have found that, you can think > > about Python > > support for that alternative. > > I agree with Albert that this is very operating-system specific. > Since you mentioned 'lsof', I'll assume that you are at least using a > Unix variant, meaning that the fcntl module will be available to you, > so you can check if the file is already locked. > > Beyond that, I think more information on your application would be > necessary before we could give you a solid answer. Do you only need > to know if the file is open, or do you want only the files that are > open for writing? If you only care about the files that are open for > writing, then checking for a write-lock with fcntl will probably do > the trick. Are you planning to check all of the "thousands of files" > individually to determine if they're open? If so, I think it's > unlikely that doing this from Python will actually be faster than a > single 'lsof' call. > > If you're on Linux, you might also want to have a look at the /proc > directory tree ("man proc"), as this is where lsof gets its > information from on Linux machines. > > Chris > -- > I know this is a python list, but if speed is such an issue you might want to consider writing in C/C++. Both would be considerably faster than python. > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlwuhwdmckay at gmail.com Mon Apr 21 02:09:18 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:09:18 -0700 (PDT) Subject: call of duty united offensive patch Message-ID: <6b29044a-6b37-44df-b02a-b1b5312c9b30@l64g2000hse.googlegroups.com> call of duty united offensive patch http://cracks.00bp.com F R E E C R A C K S From zerty.david at gmail.com Wed Apr 30 10:52:40 2008 From: zerty.david at gmail.com (David Anderson) Date: Wed, 30 Apr 2008 11:52:40 -0300 Subject: psycopg2 ReferenceManual Message-ID: <5dc598e30804300752j1c36456bp40cf813754a01974@mail.gmail.com> Hi all, where can I find the reference manual from the psycopg2 or the dbapi2.0 because in their official pages I could'nt find thx -------------- next part -------------- An HTML attachment was scrubbed... URL: From floris.bruynooghe at gmail.com Thu Apr 10 10:37:30 2008 From: floris.bruynooghe at gmail.com (Floris Bruynooghe) Date: Thu, 10 Apr 2008 07:37:30 -0700 (PDT) Subject: @x.setter property implementation References: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> Message-ID: <02cb2845-6a25-4e90-9f82-dbd68b37a5e6@p39g2000prm.googlegroups.com> On Apr 7, 2:19 pm, "Andrii V. Mishkovskyi" wrote: > 2008/4/7, Floris Bruynooghe : > > > > > Have been grepping all over the place and failed to find it. I found > > the test module for them, but that doesn't get me very far... > > I think you should take a look at 'descrobject.c' file in 'Objects' directory. Thanks, I found it! So after some looking around here was my implementation: class myproperty(property): def setter(self, func): self.fset = func But that doesn't work since fset is a read only attribute (and all of this is implemented in C). So I've settled with the (nearly) original proposal from Guido on python-dev: def propset(prop): assert isinstance(prop, property) @functools.wraps def helper(func): return property(prop.fget, func, prop.fdel, prop.__doc__) return helper The downside of this is that upgrade from 2.5 to 2.6 will require code changes, I was trying to minimise those to just removing an import statement. Regards Floris From gagsl-py2 at yahoo.com.ar Wed Apr 2 22:22:48 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 02 Apr 2008 23:22:48 -0300 Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> <10ee2a69-f4e2-4887-8083-6b02b60dd0cd@i7g2000prf.googlegroups.com> Message-ID: En Wed, 02 Apr 2008 17:54:33 -0300, Jo?o Neves escribi?: > On 2 Abr, 21:38, "Chris Mellon" wrote: >> There is no need to overwrite co_code. Create a new code object with >> your desired bytecode and use that instead. > > Yes, it may work (haven't tested - isn't there any problem with stuff > like co_name, for instance?), but for simplicity's sake, wouldn't it > be far more convenient if you could just write over co_code? :) > In the end, it's all a matter of convenience, I guess. Functions aren't just code - they contain the environment needed to actually call the code. But they're easy to create given a code object: py> import new py> new.function py> help(new.function) Help on class function in module __builtin__: class function(object) | function(code, globals[, name[, argdefs[, closure]]]) | | Create a function object from a code object and a dictionary. | The optional name string overrides the name from the code object. | The optional argdefs tuple specifies the default argument values. | The optional closure tuple supplies the bindings for free variables. py> import types py> types.FunctionType is new.function is type(lambda:0) True -- Gabriel Genellina From hniksic at xemacs.org Mon Apr 21 16:29:03 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Mon, 21 Apr 2008 22:29:03 +0200 Subject: List of all Python's ____ ? References: Message-ID: <87wsmrdka8.fsf@mulj.homelinux.net> python at bdurham.com writes: > Is there an official list of all Python's ____? http://docs.python.org/ref/specialnames.html From aldo at nullcube.com Fri Apr 4 22:17:39 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Sat, 5 Apr 2008 13:17:39 +1100 Subject: ANN: pry unit testing framework In-Reply-To: <47F3CDBD.1010600@noaa.gov> References: <47F3CDBD.1010600@noaa.gov> Message-ID: <20080405021739.GA11777@nullcube.com> Hi Jim, Thus spake j vickroy (jim.vickroy at noaa.gov): > > We are happy to announce the first release of Pry, a unit testing framework. > > > > Features > > ======== > > > > * Built-in coverage analysis, profiling, and quick-and-dirty benchmarking > > * Assertion-based tests - no ugly failUnless*, failIf*, etc. methods > > * Tree-based test structure for better fixture management > > * No implicit instantiation of test suits > > * Powerful command-line interface > > > > > > Download: http://dev.nullcube.com > > > > Manual: http://dev.nullcube.com/doc/pry/index.html > > > > > It appears this package can not be used with Microsoft Windows because > it uses the *fcntl* module which is not part of the Windows distribution. Thanks for letting me know about this. I've just released version 0.2.1 of Pry, which addresses this and a few other Windows compatibility issues. You can download it here: http://dev.nullcube.com/download/pry-0.2.1.tar.gz Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From paulgeeleher at gmail.com Thu Apr 24 07:36:22 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Thu, 24 Apr 2008 04:36:22 -0700 (PDT) Subject: Spawing a thread and printing dots until it finishes References: <8df7dc55-7f93-4569-9643-21b4c99e2f33@l42g2000hsc.googlegroups.com> Message-ID: <10384208-7d8e-4d90-8ebe-d910a26a5947@2g2000hsn.googlegroups.com> On Apr 24, 12:32 pm, sophie_newbie wrote: > On Apr 22, 3:10 pm,sophie_newbie wrote: > > > > > Hi, I'm trying to write a piece of code that spawns a thread and > > prints dots every half second until the thread spawned is finished. > > Code is > > something like this: > > > import threading > > class MyThread ( threading.Thread ): > > def run ( self ): > > myLongCommand()... > > > import time > > > t = MyThread() > > t.start() > > > while t.isAlive(): > > print "." > > time.sleep(.5) > > > print "OK" > > > The thing is this doesn't print a dot every half second. It just > > pauses for ages until the thread is finished and prints prints ".OK". > > But if I take out the "time.sleep(.5)" line it will keep printing dots > > really fast until the thread is finished. So it looks like its the > > time.sleep(.5) bit that is messing this up somehow? > > > Any ideas? > > > Thanks! > > As it happens I've managed to come up with a solution to this problem > using a subprocess rather than a thread. Its not exactly rocket > science but I thought I'd post it anyway. There are 3 files: > > ########## dots.py ####################### > # a script to print a dot every half second until it is terminated > > import time > import sys > > while 1 == 1: > > sys.stdout.write(".") > sys.stdout.flush() > > time.sleep(.5) > > ######### PrintDots.py ###################### > > # This is a simple class to spawn off another process that prints dots > repeatedly on screen > # when printDots() is called and stops when stopDots is called. It is > useful in cgi-scripts > # where you may want to let the user know that something is happening, > rather than looking > # at a blank screen for a couple of minutes. > > import time > import subprocess > import os > from signal import SIGTERM > > class PrintDots: > > # the constructor, called when an object is created. > def __init__(self): > > self.pid = 0 > > # the location of the script that prints the dots > self.dotsScript = "dots.py" > > def printDots(self): > > self.pid = subprocess.Popen( [ "python", self.dotsScript] ).pid > > def stopDots(self): > > os.kill(self.pid, SIGTERM) > > ############ mainFile.py ############################## > # The above can then be called from any cgi-script as follows > > from PrintDots import PrintDots > p = PrintDots() > p.printDots() > print "Doing R Stuff" > my_Call_To_R_That_Takes_A_Long_Time() > p.stopDots() > print "OK" > > ############ > > And low and behold dots are printed on screen every half second while > python is talking to R, with an output like this: > > Doing R Stuff.................................OK Whoops that last bit of code should read as follows: from PrintDots import PrintDots p = PrintDots() print "Doing R Stuff" p.printDots() my_Call_To_R_That_Takes_A_Long_Time() p.stopDots() print "OK" From gagsl-py2 at yahoo.com.ar Wed Apr 9 10:14:03 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 9 Apr 2008 07:14:03 -0700 (PDT) Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> Message-ID: On 9 abr, 10:27, subhabrata.i... at hotmail.com wrote: > comp.lang.python is supposed to be a serious group not anyone knowing > nothing and giving comment. Anyone is welcome to post in this group - from beginners to gurus, and that's a very good thing. All people here is usually very kind and helpful, and that's not very common on Usenet. > Well, original code snippet I don't know > why an expert person like you fails to understand, I told it almost > can't you guess the next portion? Tough indeed, then. I've to take > permission from my organization if we can bring out this code in > public domain as we are working out an MT system that performs better > than Systran. And if it is a public domain I donot have security for > my code. Any one can copy. How could anyone give some advise on what's wrong with your code, if you don't show it? All you said is that you used urllib2 - there are millions of ways to use the library, good and bad. > But well if this group people are helping out of kindness, then I have > to think. Nobody here is being paid for helping others, they're all volunteers. But even if there were some paid consultants, nobody has a crystall ball, nobody can *guess* what's wrong with your code if you don't post it. About your crazy 500 if/elif: if all of them are like your posted fragment, this needs a huge refactoring. After three repeats of the same structure any sane programmer would say "hey, let's rearrange this!". Someone posted an alternative, after guessing a bit what you actually want to do. Note that "a in b" and "a not in b" cover ALL possibilities ("tertium non datur") so your 3-way ifs are wrong. If you want to determine which strings from a set -if any- are contained in another string, use some variant of the Aho-Corasick algorithm. -- Gabriel Genellina From yves at zioup.com Mon Apr 14 23:55:55 2008 From: yves at zioup.com (Yves Dorfsman) Date: Tue, 15 Apr 2008 03:55:55 GMT Subject: how to remove \n in the list In-Reply-To: References: <2ba667ab-6818-47eb-8595-79ed970728f7@q1g2000prf.googlegroups.com> Message-ID: Gabriel Genellina wrote: > En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam >> l=['5\n', '2\n', '7\n', '3\n', '6\n'] >> >> how to remove \n from the given list > > l is is very poor name... I'll use lines instead: > > lines[:] = [line.rstrip('\n') for line in lines] When I saw the original message, I immediately thought: k = [x.strip() for x in l] What is the point of the [:] after lines ? How different is it with or without it ? Yves. http://www.SollerS.ca From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 3 06:56:45 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 03 Apr 2008 12:56:45 +0200 Subject: What motivates all unpaid volunteers at Pycon? In-Reply-To: <6ffcb45b-abb9-4d5e-8237-0f8c6bacab08@i29g2000prf.googlegroups.com> References: <7b539c8e-af4c-4409-81bc-d94e687eea59@i7g2000prf.googlegroups.com> <12d7412e-9f87-4798-a319-a78a27f68d00@e6g2000prf.googlegroups.com> <6ffcb45b-abb9-4d5e-8237-0f8c6bacab08@i29g2000prf.googlegroups.com> Message-ID: <47f4b7ed$0$18744$426a34cc@news.free.fr> seberino at spawar.navy.mil a ?crit : > On Apr 1, 11:45 am, Ed Leafe wrote: > Assuming that people get nothing back by participating in a >> community, yes, it would be curious. My experience, though, is that I >> get a lot more out of it than I could ever contribute. IOW, it's a >> great example of synergy. > > What do the people get back who did all the hard work at registration > desk and > preparing conference attendee bags? ...who did all hotel preparations? I can't speak for them, but I'd think they feel like they *already* got at least a couple things 'back': a language they like, and a helpful community. Just my 2 cents... From frikker at gmail.com Wed Apr 23 14:11:46 2008 From: frikker at gmail.com (blaine) Date: Wed, 23 Apr 2008 11:11:46 -0700 (PDT) Subject: Unix Device File Emulation References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> <480f6376$0$9037$5402220f@news.sunrise.ch> <9ee87070-be57-4a66-a152-3f36c1cc8f0c@k13g2000hse.googlegroups.com> <480f7983$0$9036$5402220f@news.sunrise.ch> Message-ID: <49529b68-88b4-4115-a85a-587528274a50@m73g2000hsh.googlegroups.com> On Apr 23, 2:01 pm, "Martin Blume" wrote: > "blaine" schrieb > > > > > > while 1: > > > r = self.fifodev.readline() > > > if r: print r > > > > According to my docs, readline() returns an empty > > > string at the end of the file. > > > Also, you might want to sleep() between reads a > > > little bit. > > > Oh ok, that makes sense. Hmm. So do I not want to use > > readline()? Or is there a way to do something like > > 'block until the file is not empty'? > > No, > while 1: > r = self.fifodev.readline() > if r: print r > else: time.sleep(0.1) > is ok (note the "if r:" clause). > > Martin Beautiful! Thanks Martin! From __peter__ at web.de Thu Apr 24 08:04:27 2008 From: __peter__ at web.de (Peter Otten) Date: Thu, 24 Apr 2008 14:04:27 +0200 Subject: How to get inner exception traceback References: <67b8nuF2m1a1kU1@mid.individual.net> Message-ID: Thomas Guettler wrote: > How can you get the traceback of the inner exception? You have to record it yourself or it will be lost. > try: > try: > import does_not_exit > except ImportError: > raise Exception("something wrong") > except: > ... > > > Background: In Django some exceptions are caught and a new > exception gets raised. Unfortunately the real error is hard > to find. Sometimes I help myself and change (in this example) > ImportError to e.g. IOError and then I can see the real root > of the problem. But maybe there is a way to get the inner > exception and its traceback. This could be displayed in the > debug view. You can get the current exception and traceback with sys.exc_info() and later print or format it using the traceback module. >>> try: ... 1/0 ... except Exception: ... x = sys.exc_info() ... raise ValueError ... Traceback (most recent call last): File "", line 5, in ValueError >>> traceback.print_exception(*x) Traceback (most recent call last): File "", line 2, in ZeroDivisionError: integer division or modulo by zero Peter From pofuk at mzm.hr Sat Apr 5 17:11:07 2008 From: pofuk at mzm.hr (SMALLp) Date: Sat, 05 Apr 2008 23:11:07 +0200 Subject: Transparent bitmap(image) in windows! In-Reply-To: References: Message-ID: this is code that adds image: kartaGif = wx.Image("slike/karta.gif", wx.BITMAP_TYPE_GIF) kartaGif.Rescale(self.sizeX, self.sizeY) kartaGif = wx.BitmapFromImage(kartaGif) mask = wx.Mask(kartaGif, wx.WHITE) kartaGif.SetMask(mask) self.karta = wx.StaticBitmap(self.mPanel, -1, kartaGif, (10, 10), (kartaGif.GetWidth(), kartaGif.GetHeight())) self.karta.Bind(wx.EVT_LEFT_DOWN, self.getPos) SMALLp wrote: > Hello everyone! > > First I want to apologize for asking question about wxPython on this group. > > I'm doing project that uses wx.ScrolledPanel few wx.Bitmap on it. It all > looks wonderful on Ubuntu and very very bad on windows because images > aren't transparent. As a found out it is problem that windows drowns > each image in separate window (or something like that) > > I'm looking for best and easiest solution for this problem. I found > something to bind PAINT event to empty function but it doesn't work > because of scrolled panel. > > Please help! > > Thanks! From john106henry at hotmail.com Thu Apr 3 20:00:18 2008 From: john106henry at hotmail.com (John Henry) Date: Thu, 3 Apr 2008 17:00:18 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> <58deb8b8-bae9-4d43-b973-3d90846726cb@b5g2000pri.googlegroups.com> <42106982-8d2e-4c98-b316-d6dc0a675230@a23g2000hsc.googlegroups.com> Message-ID: On Apr 3, 12:24 pm, ajaksu wrote: > On Apr 2, 5:01 pm, John Henry wrote: > > > However, once I start teaching him variables, expressions, loops, and > > what not, I found that (by surprise) he had great difficulties > > catching on. Not soon after that, we had to quit. > > This makes me curious: how much of videogamer are you? And your son? > You mean you are able to find a kid that isn't a videogamer these days? My level of videogame went as far as Black Hawk Down and that was about it. I find it hard to comprehand why they like to do Gaiter Hero III. With Counter Strike, at least you have some interesting scene to look at. But then again, I am not a kid anymore (not by a long stretch). > I ask that because when I think about teaching programming to young > kids, I imagine using terms they know from gaming, like "save > slots" (variables/names), "memory cards" (containers), > "combos" (functions, loops), "life meters" (counters), "next > level" (conditionals, iteration, loops), "teammates" (helper > functions), "character classes" and "characters" (class and > instances), "confirm/cancel" (conditionals), etc. > > But I've never really tried to put all those together and find a test > subject, so I'd like to know how fluent in this lingo you both were so > I can assess my pseudo-didatic approach by proxy :) > > Regards, > Daniel Well, I can't say that I am a child education expert, I am only commenting base on my last several years of volunteering activities. I've found that whenever there is a visual approach to a topic, I can hold their attention far longer. Case in point, rather than asking to read building instructions for a Lego robot, I gave them access to Leocad: a CAD program that allow them to "put together" a robot virtually. They can spin the virtual robot around, break-up the pieces virtually, and put them the robot virtually. Then they build the real thing from there. When they're done, they can made their product presentation using 3-D renderization programs (VPython stuff, I can see now). With this approach, I was able to hold the attentions of the middle school kids - even a couple of 4th graders. They were able to "program" their robots using the Lego Mindstorm ICONic programming language - and later onto the Labview based Robolab language. I think the color, the sound, the icons, videos of these visual programming languages means a lot to kids. I wish there is a visual Python - much like the Robolab/Labview approach to programming. Several of the kids continued to stay involved with our activities for several years. I was able to teach them "programming" without really really teaching them "programming". I hope they do well in high school. But then they told me the first "computer programming" class at the local high school will be teaching Office, Flash, ... Of the 18 middle-schools in our district, ours was the only one that taught the kids about computer applications and "programming" early. Unfortunately, due to budget cut, they had no choice but to cut that class (lack of staff). And without a teacher sponsoring our activities, my volunteering activity is also coming to a close. But I sure learned a lot about how kids learn (and can't learn). From sbergman27 at gmail.com Wed Apr 16 09:53:32 2008 From: sbergman27 at gmail.com (Steve Bergman) Date: Wed, 16 Apr 2008 06:53:32 -0700 (PDT) Subject: Python module for reading FilePro files? Message-ID: Does anyone know of a Python package or module to read data files from the venerable old Filepro crossplatform database/IDE? From __peter__ at web.de Wed Apr 30 11:31:17 2008 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Apr 2008 17:31:17 +0200 Subject: printing inside and outside of main() module References: <9bd5c596-da19-4615-a4d8-e47b20cfb362@m73g2000hsh.googlegroups.com> Message-ID: korean_dave wrote: > This allows me to see output: > > ---begin of try.py > print "Hello World" > --end of try.py > > This DOESN'T though... > > --begin of try2.py > def main(): > return "Hello" main() # add this > --end of try2.py > > Can someone explain why??? Python doesn't call the main() function; you have to invoke it explicitly. Peter From fetchinson at googlemail.com Thu Apr 3 18:46:46 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Thu, 3 Apr 2008 15:46:46 -0700 Subject: id functions of ints, floats and strings In-Reply-To: References: Message-ID: > Hi all, > > I've been playing around with the identity function id() for different > types of objects, and I think I understand its behaviour when it comes > to objects like lists and tuples in which case an assignment r2 = r1 > (r1 refers to an existing object) creates an alias r2 that refers to > the same object as r1. In this case id(r1) == id(r2) (or, if you > like: r1 is r2). However for r1, r2 assigned as follows: r1 = [1, 2, > 3] and r2 = [1, 2, 3], (r1 is r2) is False, even if r1==r2, > etc. ...this is all very well. Therefore, it seems that id(r) can be > interpreted as the address of the object that 'r' refers to. > > My observations of its behaviour when comparing ints, floats and > strings have raised some questions in my mind, though. Consider the > following examples: > > ######################################################################### > > # (1) turns out to be true > a = 10 > b = 10 > print a is b > > # (2) turns out to be false > f = 10.0 > g = 10.0 > print f is g > > # behaviour when a list or tuple contains the same elements ("same" > meaning same type and value): > > # define the following function, that checks if all the elements in an > iterable object are equal: > > def areAllElementsEqual(iterable): > return reduce(lambda x, y: x == y and x, iterable) != False > > # (3) checking if ids of all list elements are the same for different > cases: > > a = 3*[1]; areAllElementsEqual([id(i) for i in a]) # True > b = [1, 1, 1]; areAllElementsEqual([id(i) for i in b]) # True > f = 3*[1.0]; areAllElementsEqual([id(i) for i in f]) # True > g = [1.0, 1.0, 1.0]; areAllElementsEqual([id(i) for i in g]) # True > g1 = [1.0, 1.0, 0.5+0.5]; areAllElementsEqual([id(i) for i in g1]) # > False > > # (4) two equal floats defined inside a function body behave > differently than case (1): > > def func(): > f = 10.0 > g = 10.0 > return f is g > > print func() # True > > ###################################################### > > I didn't mention any examples with strings; they behaved like ints > with respect to their id properties for all the cases I tried. > While I have no particular qualms about the behaviour, I have the > following questions: Small integers and short strings are cached and reused and for these ( r1 == r2 ) implies ( r1 is r2 ). For longer strings or larger integers this does not happen and so in general ( r1 == r2 ) does not imply ( r1 is r2 ). The caching and reuse is for performance gains and is an implementation detail which should not be relied upon. > 1) Which of the above behaviours are reliable? For example, does a1 = > a2 for ints and strings always imply that a1 is a2? No, see above. > 2) From the programmer's perspective, are ids of ints, floats and > string of any practical significance at all (since these types are > immutable)? You can check identity (and not equality) with them. So whenever you need that they are practically useful if all you need is equality they are useless. > 3) Does the behaviour of ids for lists and tuples of the same element > (of type int, string and sometimes even float), imply that the tuple a > = (1,) takes (nearly) the same storage space as a = 10000*(1,)? (What > about a list, where elements can be changed at will?) I'm not sure about tuples but for lists the storage space needed for 10000*(1,) is roughly 10000 times more than for (1,). > Would appreciate your responses... HTH, Daniel From danb_83 at yahoo.com Thu Apr 3 20:21:11 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Thu, 3 Apr 2008 17:21:11 -0700 (PDT) Subject: regarding memoize function References: Message-ID: <94a9e7e6-a623-4783-81da-f69654e51349@e10g2000prf.googlegroups.com> On Apr 3, 6:33 pm, ankitks.mi... at gmail.com wrote: > I saw example of memoize function...here is snippet > > def memoize(fn, slot): > def memoized_fn(obj, *args): > if hasattr(obj, slot): > return getattr(obj, slot) > else: > val = fn(obj, *args) > setattr(obj, slot, val) > return val > return memoized_fn > > and I am really clueless, about what it does. I know in general we try > to keep computed values for future usage. But I am having hard-time > visualizing it. > What is obj here? and what does *args means? *args is Python's syntax for variadic functions. From paul.hankin at gmail.com Fri Apr 11 03:56:05 2008 From: paul.hankin at gmail.com (Paul Hankin) Date: Fri, 11 Apr 2008 00:56:05 -0700 (PDT) Subject: Integer dicision References: <5f499bee-a659-4e36-870c-076cb613a3e7@t12g2000prg.googlegroups.com> Message-ID: <354a333b-9c5c-4f84-9a9b-e9717ba6b807@m3g2000hsc.googlegroups.com> On Apr 11, 6:06?am, casevh wrote: > On Apr 10, 9:28 pm, bdsatish wrote: > > > How does (a/b) work when both 'a' and 'b' are pure integers ? > > Python defines the quotient and remainder from integer division so > that a = qb + r and 0<=r < abs(b). C/C++ lets the remainder be > negative. On Apr 11, 6:06 am, casevh wrote: > On Apr 10, 9:28 pm, bdsatish wrote: > > > How does (a/b) work when both 'a' and 'b' are pure integers ? > > Python defines the quotient and remainder from integer division so > that a = qb + r and 0<=r < abs(b). C/C++ lets the remainder be > negative. On Apr 11, 6:06 am, casevh wrote: > On Apr 10, 9:28 pm, bdsatish wrote: > > > How does (a/b) work when both 'a' and 'b' are pure integers ? > > Python defines the quotient and remainder from integer division so > that a = qb + r and 0<=r < abs(b). C/C++ lets the remainder be > negative. (Puts language lawyer hat on) That's not accurate: r can be negative. To quote the reference manual: 'The modulo operator always yields a result with the same sign as its second operand (or zero); the absolute value of the result is strictly smaller than the absolute value of the second operand.' divmod(9, -2) # (-5, -1) Both C and Python define q = a / b and r = a % b to satisfy a = q * b + r, where -abs(b) < r < abs(b). Where they differ: Python: r has the same sign of b (or 0). C99: r has the same sign as a (or 0). C89 (Standard C): It's implementation defined what sign r has if either a or b is negative. This means python already has C-like behaviour... it's compatible with standard C, although not with C99. -- Paul Hankin From mccredie at gmail.com Fri Apr 18 17:09:20 2008 From: mccredie at gmail.com (Matimus) Date: Fri, 18 Apr 2008 14:09:20 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: <0ebcf70f-c6d6-4ee7-9ef8-7cd2221ef906@t12g2000prg.googlegroups.com> On Apr 18, 8:58 am, Aaron Watters wrote: > Why is the migration to py3k a concern? > For example I have libraries which use string%dictionary > substitution where the dictionary is actually an object > which emulates a dictionary. The __getitem__ for > the object can be very expensive and is only called when > needed by the string substitution. > > In py3k string%dictionary is going away. Why? > I have no idea. > > The replacement is a string.format(...) method > which supports dictionary calling. > string.format(**dictionary) > But dictionary > calling doesn't support dictionary emulation. > So in the example below the substitution works > but the call fails. > > === code > > class fdict(dict): > def __getitem__(self, item): > return "got("+item+")" > > def fn(**d): > print d["boogie"] > > if __name__=="__main__": > fd = fdict() > print "attempting string substitution with fake dictionary" > print > print "hello there %(boogie)s" % fd # <-- works > print > print "now attempting function call with fake dictionary" > print > fn(**fd) # <-- fails > > === output > > % python2.6 dtest.py > attempting string substitution with fake dictionary > > hello there got(boogie) > > now attempting function call with fake dictionary > > Traceback (most recent call last): > File "dtest.py", line 17, in > fn(**fd) > File "dtest.py", line 7, in fn > print d["boogie"] > KeyError: 'boogie' > > ==== end of output > > Consequently there is no simple way to translate > my code, I think. I suspect you will find this kind of subtle > issue in many places. Or worse, you won't find it > until after your program has been installed > in production. > > It's a damn shame because > if string%dict was just left in it wouldn't be an issue. > > Also, if making f(**d) support dict emulation > has any negative performance implications > then I don't want it please. > > sigh. -- Aaron Watters > > ===http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=crack+open The reason it doesn't work is that you are unpacking the dictionary with **, and you have done nothing to define any keys or define a length. I would describe the way you are using dict as a hack, and not part of any standard feature. You make a good point that it breaks your code, but at the same time the format facility gives you the ability to do something similar but in a standard way. You simply define a class with a __format__ method and pass that in instead of your dict. class MyClass: def __format__(self, spec): return "got({0})".format(spec) c = MyClass() print ("hey everybody {0:some words}".format(c)) print ("lets try this {0:more words} {0:even more words}".format(c)) should produce: hey everybody got(some words) lets try this got(more words) got(even more words) My point is that instead of exploiting the string formatting of dictionaries feature to create a custom format specifier, you actually get to define your own format specifiers, something which is much more powerful. And actually, you can do this too... which is even simpler and allows you to use your a portion of your existing solution: class fdict(dict): def __getitem__(self, item): return "got("+item+")" fd = fdict() print ("hello there {0[boogie]} hello there {0[george])".format(fd)) Which should result in: hello there got(boogie) hello there got(george) * Keep in mind that I have not tested any of this code, there may be bugs. I don't have Py3k or 2.6 installed locally. I think this is a good trade-off. Adding to that... don't worry about py3k. Nobody is forcing you to switch. In fact, you are encouraged not to until you are comfortable. Py3k won't _break_ your code. You wrote the code for Python 2.x use it in 2.x. Python 2.x probably has a good 5-10 years remaining. Matt From skanemupp at yahoo.se Thu Apr 10 06:13:32 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 03:13:32 -0700 (PDT) Subject: questions about Exceptions? References: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> <71cc8c25-f5f9-4f21-a9d8-06780bf97608@f63g2000hsf.googlegroups.com> <9af81b1a-3e02-4406-b9d2-0a9b6f46566b@p39g2000prm.googlegroups.com> Message-ID: <0e586d5d-6799-433f-b8a4-4de5d2a87b61@h1g2000prh.googlegroups.com> here is the whole code: from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") w = Label(mygui, text="Answer: ") w.place(relx=0.15, rely=0.1, anchor=CENTER) nbr = "" def Disp(nstr): global nbr nbr=nbr+nstr print "You need to seek help!",nbr def Calc(): global nbr try: print eval(nbr) #a = Label(mygui, text=eval(nbr)) #a.place(relx=0.4, rely=0.1, anchor=CENTER) except: print "Not computable" nbr = "" def Erase(): global nbr nbr = "" b = Button(mygui, text="1",command=lambda n='1':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.2, anchor=CENTER) b = Button(mygui, text="2",command=lambda n='2':Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.2, anchor=CENTER) b = Button(mygui, text="3",command=lambda n='3':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.2, anchor=CENTER) b = Button(mygui, text="+",command=lambda n='+':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.2, anchor=CENTER) b = Button(mygui, text="4",command=lambda n='4':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.3, anchor=CENTER) b = Button(mygui, text="5",command=lambda n='5':Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.3, anchor=CENTER) b = Button(mygui, text="6",command=lambda n='6':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.3, anchor=CENTER) b = Button(mygui, text="-",command=lambda n='-':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.3, anchor=CENTER) b = Button(mygui, text="7",command=lambda n='7':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.4, anchor=CENTER) b = Button(mygui, text="8",command=lambda n='8':Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.4, anchor=CENTER) b = Button(mygui, text="9",command=lambda n='9':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.4, anchor=CENTER) b = Button(mygui, text="*",command=lambda n='*':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.4, anchor=CENTER) b = Button(mygui, text="0",command=lambda n='0':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.5, anchor=CENTER) b = Button(mygui, text="C",command=Erase, width=2, height=1) b.place(relx=0.2, rely=0.5, anchor=CENTER) b = Button(mygui, text="^.5",command=lambda n='**.5':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.5, anchor=CENTER) b = Button(mygui, text="/",command=lambda n='/':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.5, anchor=CENTER) b = Button(mygui, text="=",command=Calc, width=2, height=1) b.place(relx=0.2, rely=0.7, anchor=CENTER) mygui.mainloop() From srf99 at ferg.org Wed Apr 16 13:01:55 2008 From: srf99 at ferg.org (srf99 at ferg.org) Date: Wed, 16 Apr 2008 10:01:55 -0700 (PDT) Subject: What can we do about all the spam that the list is getting? Message-ID: <259ab201-9d2b-4e4e-88a7-e2fe277f0066@a23g2000hsc.googlegroups.com> What can we do about all the spam that comp.lang.python is getting? Things are getting pretty bad. From tinnews at isbd.co.uk Sun Apr 6 09:41:35 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 06 Apr 2008 13:41:35 GMT Subject: Presumably an import is no faster or slower than opening a file? Message-ID: <47f8d30f$0$761$bed64819@news.gradwell.net> I'm trying to minimise the overheads of a small Python utility, I'm not really too fussed about how fast it is but I would like to minimise its loading effect on the system as it could be called lots of times (and, no, I don't think there's an easy way of keeping it running and using the same copy repeatedly). It needs a configuration file of some sort which I want to keep separate from the code, is there thus anything to choose between a configuration file that I read after:- f = open("configFile", 'r') ... and importing a configuration written as python dictionaries or whatever:- import myConfig -- Chris Green From Scott.Daniels at Acm.Org Sat Apr 19 14:27:20 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Sat, 19 Apr 2008 11:27:20 -0700 Subject: Database vs Data Structure? In-Reply-To: References: <61bf5f46-e917-4a98-b87f-8e5087cb07f7@a23g2000hsc.googlegroups.com> Message-ID: castironpi at gmail.com wrote: > On Apr 18, 12:23 am, I V wrote: >> On Thu, 17 Apr 2008 19:30:33 -0700, erikcw wrote: >>> use some sort of data-structure (maybe >>> nested dictionaries or a custom class) and store the pickled >>> data-structure in a single row in the database (then unpickle the data >>> and query in memory). >> Why would you want to do this? I don't see what you would hope to gain by >> doing this, over just using a database. > > Are databases truly another language from Python, fundamentally? Yes. A fair amount of study went into them. Databases are about information that survives the over an extended period of time (months or years, not hours). Classic qualities for a database that don't normally apply to Python (all properties of a "transaction" -- bundled set of changes): * Atomicity: A transaction either is fully applied or not applied at all. * Consistency: Transactions applied to a database with invariants preserve those invariants (things like balance sheets totals). * Isolation: Each transactions happens as if it were happening at its own moment in time -- tou don't worry about other transactions interleaved with your transaction. * Durability: Once a transaction actually makes it into the database, it stays there and doesn't magically fail a long time later. -Scott David Daniels Scott.Daniels at Acm.Org From soren.skou.nielsen at gmail.com Tue Apr 29 05:31:09 2008 From: soren.skou.nielsen at gmail.com (Soren) Date: Tue, 29 Apr 2008 02:31:09 -0700 (PDT) Subject: SWIG Python undefined reference References: <23b925ce-cfa5-4a99-bad3-afcac09b645a@y21g2000hsf.googlegroups.com> Message-ID: Ok I found out how to do it using: gcc -Ic:\python24\include -Lc:\python24\libs --shared example_wrap.c example.c -lpython24 -o _example.pyd but now I get a "dynamic module does not define init function" error when I try to import it into python.. Anyone?? Soren From jcd at unc.edu Wed Apr 16 14:27:26 2008 From: jcd at unc.edu (J. Cliff Dyer) Date: Wed, 16 Apr 2008 14:27:26 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <1208370446.5771.6.camel@aalcdl07.lib.unc.edu> On Wed, 2008-04-16 at 10:49 -0700, Mike Driscoll wrote: > On Apr 16, 12:40 pm, "D'Arcy J.M. Cain" wrote: > > On Wed, 16 Apr 2008 08:23:50 -0700 (PDT) > > > > Mike Driscoll wrote: > > > My workplace doesn't offer NNTP, so there is no good way to browse > > > c.l.py here. And I haven't been able to get NNTP to work from my home > > > either. > > > > Hi Mike; > > > > I am half way to killing Google groups myself. Your message, and > > allother Google groups messages, is coloured so that I can evaluate how > > much I will miss. So far it looks like it will make reading this group a > > whole lot more pleasant and so I will probably kill them soon. > > > > There are alternatives. I run an ISP http://www.Vex.Net/ > > that offers NNTP access to my shell users. You can also receive > > this group as a mailing list which is how I read it. Google is not the > > only option out there. > > > > -- > > D'Arcy J.M. Cain | Democracy is three wolveshttp://www.druid.net/darcy/ | and a sheep voting on > > +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. > > I don't think I like the email list idea all that much. I'm already on > a number of them and they fill up my box like crazy. Besides that, in > email format it's hard to follow the thread, so one moment I'm reading > about the latest ding dong and the next is a response to a post from > last week. > In any email client worth its salt, you can set up rules for automatically moving new messages to different folders by matching various criteria. In Evolution this is as easy as right clicking on a message from the list in your inbox, select "Create Rule From Message > Filter on Mailing List", and then choose a folder to redirect to. Reading by thread instead of by date is as easy as Ctrl-T on your inbox. It isn't much different in Thunderbird. > But I agree...there are other alternatives. I'll have to start trying > them again I suppose. > > Mike > -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill From arnodel at googlemail.com Thu Apr 24 12:23:22 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 24 Apr 2008 17:23:22 +0100 Subject: convert xhtml back to html References: Message-ID: "Tim Arnold" writes: > hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop to > create CHM files. That application really hates xhtml, so I need to convert > self-ending tags (e.g.
) to plain html (e.g.
). > > Seems simple enough, but I'm having some trouble with it. regexps trip up > because I also have to take into account 'img', 'meta', 'link' tags, not > just the simple 'br' and 'hr' tags. Well, maybe there's a simple way to do > that with regexps, but my simpleminded )]+/> doesn't work. I'm not > enough of a regexp pro to figure out that lookahead stuff. Hi, I'm not sure if this is very helpful but the following works on the very simple example below. >>> import re >>> xhtml = '

hello spam
bye

' >>> xtag = re.compile(r'<([^>]*?)/>') >>> xtag.sub(r'<\1>', xhtml) '

hello spam
bye

' -- Arnaud From breily at gmail.com Fri Apr 25 06:37:44 2008 From: breily at gmail.com (Brian) Date: Fri, 25 Apr 2008 06:37:44 -0400 Subject: Can you recommend a book? In-Reply-To: References: Message-ID: On Fri, Apr 25, 2008 at 6:28 AM, noagbodjivictor at gmail.com < noagbodjivictor at gmail.com> wrote: > Hello all, I learned Python with the book "Programming Python" by John > Zelle. But today this book is a little bit old. My Python is some kind > old. I need a book that will help me brush my style and keep me up to > date. I would like one with practical examples. > > Can you recommend one? > -- > http://mail.python.org/mailman/listinfo/python-list > Dive Into Python is awesome, and best of all, free. Brian -------------- next part -------------- An HTML attachment was scrubbed... URL: From sambasivareddy.s at patni.com Fri Apr 11 07:07:11 2008 From: sambasivareddy.s at patni.com (sambasivareddy) Date: Fri, 11 Apr 2008 11:07:11 -0000 Subject: Can we send and receive data to and from Port Using Python ? Message-ID: <004901c77c25$130446b0$750ba8c0@patni.com> Hi, I am new to this group. I have some question, it is listed below. In my application I should send some data to hardware and it will give response that response should log in one file. To do it first should send data to port next receive response from port (hardware) so... Queries: 1) Can we able to send data to serial port using python? If yes how? 2) Can we able to receive data from serial port using python? If yes how? 3) Is there any function like "Register event call back", please explain? (Register event call back: registers a script to be called when an event occurs) 4) Is it possible "parallel loops" concept in python (In my application send data to port and receive data should be in one file and execute at same time)? If anyone knows answers please clarify and have any examples related to this please send it .if u need any information regarding questions please let me know. Thanks in advance. Regards, Sambasivareddy.S http://www.patni.com World-Wide Partnerships. World-Class Solutions. _____________________________________________________________________ This e-mail message may contain proprietary, confidential or legally privileged information for the sole use of the person or entity to whom this message was originally addressed. Any review, e-transmission dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this e-mail in error kindly delete this e-mail from your records. If it appears that this mail has been forwarded to you without proper authority, please notify us immediately at netadmin at patni.com and delete this mail. _____________________________________________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From marco at sferacarta.com Mon Apr 14 04:37:47 2008 From: marco at sferacarta.com (Marco Mariani) Date: Mon, 14 Apr 2008 10:37:47 +0200 Subject: Java or C++? In-Reply-To: References: Message-ID: s0suk3 at gmail.com wrote: > Which one do you think will educate me the best? Advanced javascript might teach you something too, and be very useful at the same time. Take a look at the Crockford lessons on Yahoo! Video. http://video.yahoo.com/watch/111593 http://video.yahoo.com/watch/111594 http://video.yahoo.com/watch/111595 http://video.yahoo.com/watch/111596 http://video.yahoo.com/watch/111585 http://video.yahoo.com/watch/111586 http://video.yahoo.com/watch/111587 From torriem at gmail.com Mon Apr 21 22:12:41 2008 From: torriem at gmail.com (Michael Torrie) Date: Mon, 21 Apr 2008 20:12:41 -0600 Subject: Problems replacing \ with \\ In-Reply-To: <0ca30eb2-3791-4910-9e78-f32e3b2a72cb@2g2000hsn.googlegroups.com> References: <0ca30eb2-3791-4910-9e78-f32e3b2a72cb@2g2000hsn.googlegroups.com> Message-ID: <480D4999.4070609@gmail.com> samslists at gmail.com wrote: > Hi... > > Here's a weird problem...I'm trying to escape a bunch of data to put > into a database. Is it possible to use the database API and prepared statements to avoid having to go through this exercise? Also, most database APIs work natively in unicode, so creating your prepared statement and then passing in each parameter as an argument saves a lot of hassle, since the API's usually decode the unicode strings automatically. From gagsl-py2 at yahoo.com.ar Fri Apr 4 15:57:49 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 04 Apr 2008 16:57:49 -0300 Subject: Classes in modules References: <0cace2e1-6dbc-428f-9e53-ffb99ba42aab@e6g2000prf.googlegroups.com> Message-ID: En Thu, 03 Apr 2008 18:00:54 -0300, escribi?: > Yeah, I was a little embarrassed putting my code up to be examined. > Thanks for the reply. I typed up some classes, but I seemed to have > run into some more problems. One of the classes keeps getting an > error that it can't pop from an empty list. Here's the code so far: > > #deck functions > class Deck(object): > def __init__(self): > self.deck = [] > for i in range(52): > self.deck.append(Cards(i % 13, i / 13)) > def draw(self): #This is where my (first) problem > arises, though there may be more > return self.deck.pop() #IndexError: pop from empty list > def size(self): > return len(self.deck) Next time post the whole traceback including the exception message. It really contains valuable information. Without it, one has to guess... "pop from empty list" means that you are trying to draw a card after the deck is empty. The traceback would show the caller, but in this case it's easy because there is a single place: > class Game(object): #the main game class > def __init__(self): > self.deck = Deck() > self.deck.shuffle() > self.player = Hand() > self.computer = Hand() > for i in range(self.deck.size()): > self.player.put(self.deck.draw()) > self.computer.put(self.deck.draw()) > self.stock = Stock() > print self.stock.showtrump() The loop takes 52 iterations but you draw two cards in each iteration - the 27th sees an empty deck. -- Gabriel Genellina From fr5478bey at gmail.com Sat Apr 26 11:40:55 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:40:55 -0700 (PDT) Subject: nod crack Message-ID: nod crack http://cracks.00bp.com F R E E C R A C K S From tjreedy at udel.edu Sun Apr 20 13:54:20 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 20 Apr 2008 13:54:20 -0400 Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> Message-ID: "Banibrata Dutta" wrote in message news:3de8e1f70804200632i31768d8atc235e8b6a7137173 at mail.gmail.com... | Hmmm... but I'm aware of atleast 2 Obfuscators one commercial and one FOSS, | that seem to exist for Python. The commercial one is what I might try if I | don't find anything FOSS. The FOSS one seems to be a dead project. If they | are (or have been) there, I guess obfuscation is a doable thing, no ? Given that a reliable obfuscator (not obfurscator) would be commercially valuable, why would you expect someone to give it away rather than obfuscate it, like you want to do with your code? So go ahead and pay. There are ways to make Python code truly obscure by turning it into pure functional code, but I do not know that this can be done algorithmicly, and the result is not something one would want to develop and maintain for anything more than toy examples. From marion at everautumn.com Sun Apr 6 13:28:44 2008 From: marion at everautumn.com (marion at everautumn.com) Date: Sun, 6 Apr 2008 10:28:44 -0700 (PDT) Subject: How To Uses Modules And Plugins Message-ID: <47650e1f-148e-48f9-b09e-51cb5fb4f402@m73g2000hsh.googlegroups.com> I am working on a client/server, computer role-play game using Python. I want to gradually expand the game world by creating maps as individual py files in a map directory. I am a little foggy of how to do this. I have read about the __import__() function. I want to understand what the difference is between using modules and plugins. Are they the same thing? How will my root script interact with the individual modules once it has loaded them? If you can point me to a web site or tutorial on this subject I would be thankful. From sjmachin at lexicon.net Wed Apr 9 20:23:12 2008 From: sjmachin at lexicon.net (John Machin) Date: Wed, 9 Apr 2008 17:23:12 -0700 (PDT) Subject: How can I use quotes without escaping them using CSV? References: <35a28105-1178-4784-8247-d483e55694c7@f63g2000hsf.googlegroups.com> Message-ID: <663f5ce6-45a5-4f5e-a879-2e8ed405e41c@k1g2000prb.googlegroups.com> On Apr 10, 9:39 am, jeffself wrote: > I set quotechar="" and was able to get it to work. I'll try this at > work tomorrow! setting it to what Andrew told you to do ('' not ")works equally well From tinnews at isbd.co.uk Wed Apr 9 12:05:21 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 09 Apr 2008 16:05:21 GMT Subject: How to find documentation about methods etc. for iterators Message-ID: <47fce941$0$755$bed64819@news.gradwell.net> I'm not sure if I have even phrased that right but anyway.... How does one find (in the standard Python documentation) information about things like the iteritems() method and the enumerate() function. They are mentioned in the tutorial as ways of getting more information as you loop through an object but there seems to be no easy way to find the definitive documentation of these sorts of methods and functions. OK, if I know the name before I start I can probably find what I want, but what if I want to know how to extract some information from an object as I loop and don't know what I want is called? My particular quest that raised this was a way to get the line number as I iterate through the lines of a file:- f = open(fn, 'r') lineNo = 0 for ln in f: lineNo += 1 Is there a neater way of getting that line number as I go? If so how am I meant to find out about it? -- Chris Green From JesseAldridge at gmail.com Sun Apr 6 10:32:27 2008 From: JesseAldridge at gmail.com (Jesse Aldridge) Date: Sun, 6 Apr 2008 07:32:27 -0700 (PDT) Subject: Python Data Utils References: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> Message-ID: <8eec6557-784d-4fd8-8478-8da17aedf0ab@d1g2000hsg.googlegroups.com> Thanks for the detailed feedback. I made a lot of modifications based on your advice. Mind taking another look? > Some names are a bit obscure - "universify"? > Docstrings would help too, and blank lines I changed the name of universify and added a docstrings to every function. > ...PEP8 I made a few changes in this direction, feel free to take it the rest of the way ;) > find_string is a much slower version of the find method of string objects, ? Got rid of find_string, and contains. What are the others? > And I don't see what you gain from things like: > def count( s, sub ): > ? ? ?return s.count( sub ) Yeah, got rid of that stuff too. I ported these files from Java a while ago, so there was a bit of junk like this lying around. > delete_string, as a function, looks like it should delete some string, not ? > return a character; I'd use a string constant DELETE_CHAR, or just DEL, ? > it's name in ASCII. Got rid of that too :) > In general, None should be compared using `is` instead of `==`, and ? > instead of `type(x) is type(0)` or `type(x) == type(0)` I'd use ? > `isinstance(x, int)` (unless you use Python 2.1 or older, int, float, str, ? > list... are types themselves) Changed. So, yeah, hopefully things are better now. Soon developers will flock from all over the world to build this into the greatest data manipulation library the world has ever seen! ...or not... I'm tired. Making code for other people is too much work :) From martin at v.loewis.de Sat Apr 5 17:34:28 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sat, 05 Apr 2008 23:34:28 +0200 Subject: RELEASED Python 2.6a2 and 3.0a4 In-Reply-To: References: <47F68547.1040802@v.loewis.de> Message-ID: <47F7F064.6030906@v.loewis.de> Kay Schluehr wrote: > On 4 Apr., 21:45, "Martin v. L?wis" wrote: >>> The Windows x86 MSI installer is missing for both 2.6 and 3.0. >> And likely will continue to do so for some time. >> >> Regards, >> Martin > > Fine. Is there also a reason? Sure! I don't have the time to spell it out, though, please look at the python-dev archives. If you want to help, please contact me in private. Regards, Martin From jeffrey at fro.man Tue Apr 15 17:01:07 2008 From: jeffrey at fro.man (Jeffrey Froman) Date: Tue, 15 Apr 2008 14:01:07 -0700 Subject: Recurring patterns: Am I missing it, or can we get these added to the language? References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: Erich wrote: > def iterable(item, count_str=False): > if not count_str and isinstance(item, str): > return False > try: > iter(item) > except: > return False > return True Beware the "except" clause here, as it catches *all* errors. Thus, if you happen to have an unfortunate typo: try: iter(iten) except: return False return True then your code will happily return False for everything. This code should catch TypeErrors only for better results: try: iter(item) except TypeError: return False return True Jeffrey From Manisa999 at gmail.com Sat Apr 26 01:18:57 2008 From: Manisa999 at gmail.com (Manisa999 at gmail.com) Date: Fri, 25 Apr 2008 22:18:57 -0700 (PDT) Subject: Latest PC Parts In Small Price U Nid Contact Mi!! Message-ID: <0f1fe502-8859-4397-8808-8651ee5edfc9@w5g2000prd.googlegroups.com> SEXY SEGMENT *********************************** http://bigsexmovies.notlong.com/ http://indiansexx.notlong.com/ *********************************** From gagsl-py2 at yahoo.com.ar Fri Apr 25 06:27:35 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 25 Apr 2008 07:27:35 -0300 Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: En Thu, 24 Apr 2008 11:10:55 -0300, Paul McGuire escribi?: > On Apr 21, 9:01?pm, "Gabriel Genellina" > wrote: >> >> Perhaps you can manage to keep your code compatible with all versions, >> but ? >> AFAIK the reccomended strategy is to write code compatible with Python >> 2.6 ? >> and use the 2to3 tool to generate the 3.0 source. And *not* edit the >> 3.0 ? >> code unless one wants to maintain two branches. >> > > Gabriel - > > (Thanks for chiming in on this sub-thread, I really enjoy reading your > posts.) (And I enjoy using your parser! Not that I have to parse text so often, but when it comes, the "pythonicity" of pyparsing is a great thing!) > My point is that the recommended strategy MAY work for those who write > end point applications (I consider maintaining 2 branches to be in the > "not working" category), but it does NOT WORK for people who maintain > modules for other people to use, because those people may be on a > range of Python versions that extend beyond 2.6-3.0. So if I upgrade > my module to 2.6, those running on earlier versions can no longer use > it. At some point in the future, I'll probably be able to say "no > more support for pre-2.6", but it is a bit early to start saying that > now. > > Likewise, I don't want to say "no support for 3.0" - people DO want to > try 3.0 out, and I WANT them to want and be able to use my module too. > > Given the recommended strategy, and ruling out dual codebase, whom do > I tell that they can't use the next version of my module? Ok, code that is "2.6 compatible" doesn't mean that it only runs on 2.6... I'm *trying* to write code that is "2to3 friendly" but anyway compatible with older Python versions, and it should not require 2.6 to run. That means not using "with" as a variable name, for example. (And on the other side, also refrain from using some new 2.6 features like class decorators and binary literals) I hope the final version of the 2to3 tool will be a little more robust - or at least, that one will always be able to write code in a way that it can handle (and I *dont* want to maintain a 2.x and 3.x branches of any code either) Based on my limited experience I'd say that this approach *could* work, that is, write the code base for 2.x (x >= 3, in my case) and automatically convert to 3.0. That last stage may fail, but -I hope!- not so often in the future. As always, YMMV... Also note that I *don't* write code for other developers (thanks God!), just final users (with Python 2.3/4/5) > Again, to me, this is a non-issue because I've been able to create a > cross-version compatible single codebase for pyparsing. But it was a > bit dicey there for a while, and I think other module developers/ > maintainers may not be so lucky. That's a bit tricky at least. How did you manage to avoid problems with (string/unicode) and (bytes/string) in 3.0? > So, I feel that the recommended strategy was devised with a narrow > group of developers in mind, and leaves module developers/maintainers, > who wish to target as broad a set of users as possible, faced with > choosing one of these strategies: > - create (if possible) single cross-version compatible code > - forego support of 3.0 users > - discontinue pre-2.6 support for future versions of their module > - maintain dual codebase I hope the first alternative will be actually viable, perhaps with help from tools like 2to3... -- Gabriel Genellina From mail at timgolden.me.uk Fri Apr 11 15:46:24 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 11 Apr 2008 20:46:24 +0100 Subject: Windows - window status (Running vs Not Responding) In-Reply-To: References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> Message-ID: <47FFC010.2020602@timgolden.me.uk> rdahlstrom wrote: > On Apr 11, 1:45 pm, rdahlstrom wrote: >> Does anyone know how to determine the window status (Running or Not >> Responding)? I've tried various methods with no success... >> >> This would be on a variety of Windows systems, but all at least XP, >> and mostly server 2003. Everyone will have Python 2.5.1 on them, and >> the script would be running locally. >> >> Any ideas? > > > Basically, I'm looking for something similar to the Process.Responding > property in System.Diagnostics... Well one (slightly drastic) possibility might be to use IronPython [1] or Python.NET [2] to invoke the .Net functionality directly. AFAIK there is no direct alternative: I believe that WMI can be a useful match for System.Diagnostics but doesn't deal with windows (ie user-interface elements). Presumably you could find a top-level window for each process, using something vaguely like this [3] coupled with this [4] and send it a suitable SendMessage to "ping" it. Haven't done it myself but can't see why it shouldn't work. All a bit handwavey but maybe it'll point you somewhere... TJG [1] http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython [2] http://pythonnet.sourceforge.net/ [3] http://timgolden.me.uk/python/wmi_cookbook.html#running_processes [4] http://timgolden.me.uk/python/win32_how_do_i/find-the-window-for-my-subprocess.html From victorsubervi at gmail.com Thu Apr 17 10:42:39 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 17 Apr 2008 09:42:39 -0500 Subject: More Fun With MySQL and Images Message-ID: <4dc0cfea0804170742g39965533yfaf260bcf4da4301@mail.gmail.com> Hi again: Here is my code, an edit of Gabriel?s: #!/usr/local/bin/python import cgitb; cgitb.enable() import MySQLdb def test(): host = 'host' db = 'db' user = 'user' passwd = 'pass' db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor= db.cursor() cursor.execute('select pic1 from products where id="2";') content = cursor.fetchall()[0][0].tostring() f = open("somefile.jpg", "w") f.write(content) f.close() print 'Content-Type: image/jpeg\r\nContent-Length: %d\n' % len(content) print '\n' print content print '\n' cursor.close() test() Now, when I surf to the url of this script, it prints out garbage that is a literal of the image, but not the image itself. However, if I surf to ?somefile.jpg?, I see the image!! Am I losing my mind?? What?s wrong here? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From mmanns at gmx.net Thu Apr 17 22:46:38 2008 From: mmanns at gmx.net (Martin Manns) Date: Fri, 18 Apr 2008 04:46:38 +0200 Subject: ANN: pyspread 0.0.1 Message-ID: pyspread 0.0.1 is now available at: http://pyspread.sourceforge.net pyspread is a spreadsheet that accepts a pure python expression in each cell. Highlights: + No non-python syntax add-ons + Access to python modules from cells + 3D grid + Numpy object array for representation of string entry into grid cell + Numpy object array for representation of eval function array + Cell access via slicing of numpy function array + X, Y, and Z yield current cell location for relative reference Requires: Python 2.5, Numpy 1.0.4, and wxPython 2.8.7.1. License: GPL Best Regards Martin Manns -- mmanns gmx.net From BrentJRogers at gmail.com Tue Apr 29 22:52:48 2008 From: BrentJRogers at gmail.com (breroger@cisco.com) Date: Tue, 29 Apr 2008 19:52:48 -0700 (PDT) Subject: QA-Test Jobs at Cisco-IronPort Message-ID: Cisco-IronPort is looking for a topnotch Quality Assurance/ Test Engineers with experience in one or more of the following: aPython, utomation framework, performance testing, email encryption, FreeBSD, white.gray box testing, API testing, web security appliances, UNIX, RAID, LDAP, SSH, DNS, SMTP, HTTP, FTP, Telnet, RDBMS, IMAP, POP and/or tested servers. These job openings are in San Bruno. Please contact me directly if you are interested in getting more information. Regards, Brent breroger at cisco.com From kyosohma at gmail.com Wed Apr 30 13:14:56 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 30 Apr 2008 10:14:56 -0700 (PDT) Subject: I messed up my wxPython install (Eclipse Configuration Issue) References: <18eb0a7c-96f4-41de-b44f-95fd8ba0223f@f63g2000hsf.googlegroups.com> Message-ID: <436f8226-64a5-440a-92f4-afd7dd348e1c@m73g2000hsh.googlegroups.com> blaine wrote: > The wxPython group is a bit stale compared to this group, so I'll give > it a shot :) > What does that mean? The wxPython group is almost always very quick to respond with relevant answers. As to your question, I think Peter is correct. Your wx.py and wx.pyc files are masking the wx package. Mike From noorhanabbas at yahoo.co.uk Wed Apr 16 06:48:02 2008 From: noorhanabbas at yahoo.co.uk (Noorhan Abbas) Date: Wed, 16 Apr 2008 10:48:02 +0000 (GMT) Subject: Change the output font color Message-ID: <306504.18131.qm@web27412.mail.ukl.yahoo.com> Hello, I am developing a program that searches for a word in a piece of text. I need to be able to change the color of the searched for word when found in the output text. Is that possible in Python? So, for example: The input text could be: "I like banans and apples" The output should be: "I like banans and apples" Thank you very much, Nora. ___________________________________________________________ Yahoo! For Good helps you make a difference http://uk.promotions.yahoo.com/forgood/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From barronmo at gmail.com Wed Apr 2 16:07:30 2008 From: barronmo at gmail.com (barronmo) Date: Wed, 2 Apr 2008 13:07:30 -0700 (PDT) Subject: subtract dates with time module References: <16b10790-a57f-4e7e-bbb5-32e71b321771@u69g2000hse.googlegroups.com> <47eb7d5b$1@news.mel.dft.com.au> Message-ID: <652c0efa-c472-4016-bbcc-f3c4c7a67060@a1g2000hsb.googlegroups.com> Thanks for the help everyone. I ended up with the following: def OBweeks(ptID): qry = 'SELECT short_des FROM problems WHERE patient_ID = %s;' % (ptID) results = EMR_utilities.getAllData(qry) for items in results: r = re.search('\d\d\d\d-\d\d-\d\d', str(items)) if r: edc = datetime.date(*map(int, r.group().split('-'))) pregnancy = datetime.timedelta(weeks=-40) conception = edc + pregnancy howfar = datetime.date.today() - conception weeks, days = divmod(howfar.days, 7) return '%s %s/7 weeks' % (weeks, days) else: pass Mike From dickinsm at gmail.com Mon Apr 7 15:55:52 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Mon, 7 Apr 2008 12:55:52 -0700 (PDT) Subject: A funnily inconsistent behavior of int and float References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com> <1d11875a-470a-489f-910a-b420a145eb61@a1g2000hsb.googlegroups.com> <11b4793c-04cc-4898-99a8-8418d237de3e@2g2000hsn.googlegroups.com> Message-ID: <1255ee3e-cc1e-4ae8-96f3-5f942c389c49@t54g2000hsg.googlegroups.com> On Apr 7, 3:53 pm, Mark Dickinson wrote: > The only base 0 versus base 10 difference I could find was the > following: > > >>> int('033', 0) > > Traceback (most recent call last): > File "", line 1, in > ValueError: invalid literal for int() with base 0: '033' > [38720 refs]>>> int('033') > > 33 > > Mark And also things like: >>> int('0x33') Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: '0x33' [38719 refs] >>> int('0x33', 0) 51 [38719 refs] Mark From kyosohma at gmail.com Tue Apr 8 14:55:39 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 8 Apr 2008 11:55:39 -0700 (PDT) Subject: set file permission on windows References: <7d75fc7b-a2b7-4ca2-b386-27da975043d0@m44g2000hsc.googlegroups.com> Message-ID: <9aaa562d-b256-4fe5-bb10-d32def072564@2g2000hsn.googlegroups.com> On Apr 8, 1:19 pm, "Tim Arnold" wrote: > "Mike Driscoll" wrote in message > > news:7d75fc7b-a2b7-4ca2-b386-27da975043d0 at m44g2000hsc.googlegroups.com... > > > > > On Apr 8, 12:03 pm, "Tim Arnold" wrote: > >> > > According to the following thread, you can use os.chmod on Windows: > > >http://mail.python.org/pipermail/python-list/2003-June/210268.html > > > You can also do it with the PyWin32 package. Tim Golden talks about > > one way to do it here: > > >http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html > > > Also see the following thread: > > >http://mail.python.org/pipermail/python-win32/2004-July/002102.html > > > or > > >http://bytes.com/forum/thread560518.html > > > Hope that helps! > > > Mike > > Hi Mike, > It does help indeed, especially the last two links. That certainly gets me > started in the right direction. I'm always amazed at the helpful generosity > of the folks on this list. > thanks again for the help. > --Tim Arnold Hi Tim, I thought I'd used the methods in those last two links before, but I was thinking of changing permissions on running services to reboot a PC, which is not quite the same. If you run into more issues, there's a PyWin32 mailing list with helpful people there too. You can find it here: http://mail.python.org/mailman/listinfo/python-win32 Mike From aaron.watters at gmail.com Fri Apr 18 10:36:40 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Fri, 18 Apr 2008 07:36:40 -0700 (PDT) Subject: Database vs Data Structure? References: <61bf5f46-e917-4a98-b87f-8e5087cb07f7@a23g2000hsc.googlegroups.com> <4808586b$0$23721$426a74cc@news.free.fr> Message-ID: > My very humble opinion - based on several years of working experience > with both the Zodb and many RDBMS - is quite clear : use a RDBMS and use > it properly. Yes, somewhere down the line you will want to get a report of all the customers in Ohio, ordered by county and zip code, who have a "rabbit cage" project -- and if you just pickle everything you will end up traversing the entire database, possibly multiple times to find it. A little old fashioned database design up front can save you a lot of pain. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=ouch From maxkhesin at gmail.com Sun Apr 6 16:59:03 2008 From: maxkhesin at gmail.com (xamdam) Date: Sun, 6 Apr 2008 13:59:03 -0700 (PDT) Subject: appropriate python version References: <0790632f-db07-45ef-9bcd-7e1b592d33be@u69g2000hse.googlegroups.com> Message-ID: <61b10f10-a322-4835-b800-ed09d046fe56@e67g2000hsa.googlegroups.com> Thanks. I am guessing the 32bit build should work anyways, same as other 32 progs on XP 64? From lutz.georg.horn at googlemail.com Wed Apr 30 02:41:47 2008 From: lutz.georg.horn at googlemail.com (Lutz Horn) Date: Wed, 30 Apr 2008 08:41:47 +0200 Subject: Problem with variables assigned to variables??? In-Reply-To: References: Message-ID: <7c85a2590804292341l566b59f7x59ba06634bd98650@mail.gmail.com> Hi, 2008/4/30 : > mylist = ('name1', 'name2', 'name3') > > I also assigned variables for each SQL expression: > name1 = "\"field_a\" LIKE '021'" > name2 = "\"field_a\" LIKE '031'" > name3 = "\"field_a\" LIKE '041'" > my intended output is: > name1.shp "field_a LIKE '021' > name2.shp "field_a LIKE '031' > name3.shp "field_a LIKE '041' You should use a dictionary someway like this: >>> mydict = {'name1':"\"field_a\" LIKE '021'", ... 'name2':"\"field_a\" LIKE '031'", ... 'name3':"\"field_a\" LIKE '041'"} >>> for key, value in mydict.items(): ... print key, value ... name2 "field_a" LIKE '031' name3 "field_a" LIKE '041' name1 "field_a" LIKE '021' Lutz -- Do you want a Google Mail invitation? Just write me an email! From abeen0 at gmail.com Wed Apr 2 01:37:22 2008 From: abeen0 at gmail.com (abeen) Date: Tue, 1 Apr 2008 22:37:22 -0700 (PDT) Subject: developing web spider Message-ID: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> Hello, I would want to know which could be the best programming language for developing web spider. More information about the spider, much better,, thanks http://www.imavista.com From gagsl-py2 at yahoo.com.ar Thu Apr 10 05:18:39 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 06:18:39 -0300 Subject: email header decoding fails References: Message-ID: En Thu, 10 Apr 2008 05:45:41 -0300, ZeeGeek escribi?: > On Apr 10, 4:31 pm, "Gabriel Genellina" > wrote: >> En Wed, 09 Apr 2008 23:12:00 -0300, ZeeGeek >> escribi?: >> >> > It seems that the decode_header function in email.Header fails when >> > the string is in the following form, >> >> > '=?gb2312?Q?=D0=C7=C8=FC?=(revised)' >> An 'encoded-word' that appears within a >> 'phrase' MUST be separated from any adjacent 'word', 'text' or >> 'special' by 'linear-white-space'. > > Thank you very much, Gabriel. The above just says "why" decode_header refuses to decode it, and why it's not a bug. But if you actually have to deal with those malformed headers, some heuristics may help. By example, if you *know* your mails typically specify gb2312 encoding, or iso-8859-1, you may look for things that look like the example above and "fix" it. -- Gabriel Genellina From victorsubervi at gmail.com Tue Apr 29 10:33:32 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Tue, 29 Apr 2008 09:33:32 -0500 Subject: Colors for Rows Message-ID: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> Hi; why doesn't this work? z = 3 for d in id: z += 1 if z % 4 == 0: bg = '#ffffff' elif z % 4 == 1: bg = '#d2d2d2' elif z % 4 == 2: bg = '#F6E5DF' else: bg = '#EAF8D5' try: print '\n' % bg except: print '\n' It never increments z! Yet, if I print z, it will increment and change the bgcolor! Why?! Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From skanemupp at yahoo.se Mon Apr 14 05:24:34 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Mon, 14 Apr 2008 02:24:34 -0700 (PDT) Subject: py2exe, program has stoped working!? References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> <232151d6-09ed-4a1e-9922-d66c2bf0d05b@w8g2000prd.googlegroups.com> Message-ID: > Is it a console program or a gui program? GUI > What happens when you run it without py2exe? it works perfectly, both from within python and launching from "windows" > Have you searched for "has stopped working" in (a) your source code yes no such message there > (b) the py2exe source code? no, will do but doubt thats the problem > Have you managed to get any py2exe-created program to run properly? no From paul at subsignal.org Sat Apr 19 11:31:14 2008 From: paul at subsignal.org (paul) Date: Sat, 19 Apr 2008 17:31:14 +0200 Subject: is file open in system ? - other than lsof In-Reply-To: <36e8a7020804160550g6fba661cx7249426f35e7d635@mail.gmail.com> References: <36e8a7020804160550g6fba661cx7249426f35e7d635@mail.gmail.com> Message-ID: bvidinli schrieb: > is there a way to find out if file open in system ? - > please write if you know a way other than lsof. because lsof if slow for me. > i need a faster way. > i deal with thousands of files... so, i need a faster / python way for this. > thanks. I think you can do this with inotify. It's an event based notification mechanism for linux kernel 2.6.13 and up. It has python bindings available (google for pyinotify). You will receive events like IN_OPEN,IN_CLOSE,etc. and keep track of opened files this way. hth Paul From cokofreedom at gmail.com Mon Apr 7 08:15:37 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Mon, 7 Apr 2008 05:15:37 -0700 (PDT) Subject: First Python project - comments welcome! References: <1207555415.6966.88.camel@paul-laptop> Message-ID: <9c313122-7eb0-4761-9443-50f467985767@p25g2000hsf.googlegroups.com> Just a random check. Is __gsignals__ a builtin type? Else it would probably be better not to include the postfix underscores. Though I might be wrong here. Otherwise seems pretty good and well organised. I hate it when people go comment mad, but you've kept them to the places where an explanation is required. Good job :=) From Bill at SynectixLtd.com Thu Apr 10 04:00:14 2008 From: Bill at SynectixLtd.com (Bill Davy) Date: Thu, 10 Apr 2008 09:00:14 +0100 Subject: SWIG/C++ Message-ID: Is there a better place to post such questions? Anyway, in the hope it is something simple, I would appreciate some help. I am adding some C++ code to Python. From Python I want to be able to read data from a target device, over USB. My software does all the hard work and I have a class: class ViperUsbC { public: // snip snip ERROR_T ReadSlaveMemory(u8 Slave, u16 Offset, u8* pData, u16 Length); // Snip,snip }; I use swigwin-1.3.34 to wrap it into a module called SHIP. In Python, I have: import SHIP ViperUsb = SHIP.ViperUsbC() Slave =7 Offset = 0 Length = 64 Buffer = 'a' * Length print "type(Buffer)=%s" % type(Buffer) print "len(Buffer)=%s" % len(Buffer) Result = ViperUsb.ReadSlaveMemory(Slave, Offset, Buffer, Length); That fails with: type(Buffer)= len(Buffer)=64 Traceback (most recent call last): File "H:\Husky\HostPC\V1\SHIP\test1.py", line 1970, in -toplevel- ViperTests() File "H:\Husky\HostPC\V1\SHIP\test1.py", line 1884, in ViperTests Result = ViperUsb.ReadSlaveMemory(Slave, Offset, Buffer, Length); File "H:\Husky\HostPC\V1\SHIP\Release\SHIP.py", line 1757, in ReadSlaveMemory def ReadSlaveMemory(*args): return _SHIP.ViperUsbC_ReadSlaveMemory(*args) TypeError: in method 'ViperUsbC_ReadSlaveMemory', argument 4 of type 'u8 *' How do I provide a buffer into which to read the data? It would not be intolerable to provide another layer using %extend, but I feel sure this should be automagic. Thanks in advance Bill PS This is a very small part of a much larger project so I cannot supply complete source code. From usenet-mail at markshroyer.com Sat Apr 19 03:03:54 2008 From: usenet-mail at markshroyer.com (Mark Shroyer) Date: Sat, 19 Apr 2008 03:03:54 -0400 Subject: Inheritance confusion References: <4809932c$0$12307$c3e8da3@news.astraweb.com> Message-ID: In article <4809932c$0$12307$c3e8da3 at news.astraweb.com>, Hook wrote: > Hi, > > I'm having a problem with multiple inheritance - it's clearly something > I've missed, but the web pages and books that I've consulted aren't > helping, so I'll throw myself on the mercy and collective wisdom of > Usenet! > > I've got 4 files (what I'll show has the active content removed for > brevity): > > Errors_m.py > ~~~~~~~~~~~ > class Errors (object) : > def __init__ (self, params) : > pass > > def Error (self, string) : > return 100 > > DT_m.py > ~~~~~~~ > class DT (object) : > def __init__ (self, params) : > pass > > def Date (self, epoch, pattern = 'd mmm yyyy') : > dt = datetime.datetime.fromtimestamp (epoch) > > Hook_m.py > ~~~~~~~~~ > from DT_m import DT > from Error_m import Errors > > class Hook (Errors, DT) : > def __init__ (self, params) : > DT.__init__ (self, params) > Errors.__init__ (self, params) > > DB_m.py > ~~~~~~~ > from Hook_m import Hook > > class DB (Hook) : > def __init__ (self, params) : > Hook.__init__ (self, params) > > > And a test script: > > #!/usr/bin/python > > import os > import re > import string > import sys > > from DB_m import DB > > Dict = dict () > Dict ['logdir'] = '/tmp/log' > Dict ['diag'] = 1 > > Obj = DB (Dict) > print dir (Obj) > Obj.Connect ('Database') > > > When I run the script I get this: > > Traceback (most recent call last): > File "./3.py", line 20, in > Obj.Connect ('Database') > File "/mnt/isis/Projects/Python/Learning/DB_m.py", line 102, in Connect > self.TRACE ("DB::Connect (" + database + "," + mode) > File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 314, in TRACE > self.DailyLog (msg) > File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 98, in > DailyLog > dt = self.Date (time ()) > TypeError: 'module' object is not callable > > > Googling the "TypeError" message suggests that I've got a module and > class with the same name, but I can't see that I have. For what it's worth, modules actually *are* allowed to contain a class of the same name: for example, datetime.datetime. Anyway, what this error message is actually trying to tell you is that you are attempting to call a module as a function somewhere -- and in this particular case, I think it's referring to the time module. Are you sure that line 98 in Hook_m.py should not instead be: dt = self.Date(time.time()) The time module contains a function, time(), which returns the current Unix time (another example of a module containing an object of the same name, incidentally); but you'll need to call this function as "time.time()" unless you have prefaced your code with from time import time or from time import * Otherwise, the token "time" refers to the time module, which is not callable, and not the desired function therein. -- Mark Shroyer, http://markshroyer.com/contact/ Due to extreme spam, I block all articles originating from Google Groups. If you want your postings to be seen by more readers you will need to find a different means of posting on Usenet. http://improve-usenet.org/ From python-url at phaseit.net Mon Apr 21 06:45:13 2008 From: python-url at phaseit.net (Gabriel Genellina) Date: Mon, 21 Apr 2008 10:45:13 +0000 (UTC) Subject: Python-URL! - weekly Python news and links (Apr 21) Message-ID: QOTW: "But people will always prefer complaining on the grounds of insufficient information to keeping quiet on the basis of knowledge." - Steve Holden http://groups.google.com/group/comp.lang.python/msg/007b9fea0a5db786 Speed of Python vs C when reading, sorting and writing data: http://groups.google.com/group/comp.lang.python/browse_thread/thread/172902584511f19e/ The GIL was murdered - but it refuses to die: http://groups.google.com/group/comp.lang.python/browse_thread/thread/2d537ad8df9dab67/ The "obvious" way to declare per-instance properties doesn't work: http://groups.google.com/group/comp.lang.python/browse_thread/thread/c14aae97eb7c19d8/ Metaprogramming example (metaclasses and descriptors): http://groups.google.com/group/comp.lang.python/browse_thread/thread/e4144d9c8fafe29a/ Concerns about the migration to 3.0 (Python and C code): http://groups.google.com/group/comp.lang.python/browse_thread/thread/25c4c3175569fa37/ The future replacement of string % formatting in Python 3.x: http://groups.google.com/group/comp.lang.python/browse_thread/thread/f07feff4f01be76f/ How widely adopted is Python 2.5? http://groups.google.com/group/comp.lang.python/browse_thread/thread/5f15ac04993dfb9/ What to learn after Python: Java, C++, ...? http://groups.google.com/group/comp.lang.python/browse_thread/thread/5d8be7aca2cd6d49/ Many people filter out messages posted thru Google Groups: http://groups.google.com/group/comp.lang.python/browse_thread/thread/a90b84c4f8987b3f/ ======================================================================== Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. Just beginning with Python? This page is a great place to start: http://wiki.python.org/moin/BeginnersGuide/Programmers The Python Papers aims to publish "the efforts of Python enthusiats": http://pythonpapers.org/ The Python Magazine is a technical monthly devoted to Python: http://pythonmagazine.com Readers have recommended the "Planet" sites: http://planetpython.org http://planet.python.org comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Python411 indexes "podcasts ... to help people learn Python ..." Updates appear more-than-weekly: http://www.awaretek.com/python/index.html Steve Bethard continues the marvelous tradition early borne by Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim Lesher of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to capture useful and interesting recipes. http://aspn.activestate.com/ASPN/Cookbook/Python Many Python conferences around the world are in preparation. Watch this space for links to them. Among several Python-oriented RSS/RDF feeds available are http://www.python.org/channews.rdf http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi http://python.de/backend.php For more, see http://www.syndic8.com/feedlist.php?ShowMatch=python&ShowStatus=all The old Python "To-Do List" now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse http://www.python.org/dev/peps/pep-0042/ The online Python Journal is posted at pythonjournal.cognizor.com. editor at pythonjournal.com and editor at pythonjournal.cognizor.com welcome submission of material that helps people's understanding of Python use, and offer Web presentation of your work. del.icio.us presents an intriguing approach to reference commentary. It already aggregates quite a bit of Python intelligence. http://del.icio.us/tag/python *Py: the Journal of the Python Language* http://www.pyzine.com Archive probing tricks of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 http://groups.google.com/groups?meta=site%3Dgroups%26group%3Dcomp.lang.python.* Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://www.ddj.com/topic/python/ (requires subscription) http://groups-beta.google.com/groups?q=python-url+group:comp.lang.python*&start=0&scoring=d& http://purl.org/thecliff/python/url.html (dormant) or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python There is *not* an RSS for "Python-URL!"--at least not yet. Arguments for and against are occasionally entertained. Suggestions/corrections for next week's posting are always welcome. E-mail to should get through. To receive a new issue of this posting in e-mail each Monday morning (approximately), ask to subscribe. Mention "Python-URL!". Write to the same address to unsubscribe. -- The Python-URL! Team-- Phaseit, Inc. (http://phaseit.net) is pleased to participate in and sponsor the "Python-URL!" project. Watch this space for upcoming news about posting archives. From spe.stani.be at gmail.com Tue Apr 29 07:51:34 2008 From: spe.stani.be at gmail.com (SPE - Stani's Python Editor) Date: Tue, 29 Apr 2008 04:51:34 -0700 (PDT) Subject: Learn python packaging for Ubuntu and Debian in the Ubuntu Open Week References: Message-ID: I forgot an important detail... This session will be hosted Thu 1 May at 21.00 UTC on IRC in #ubuntu- classroom. From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 16 06:52:37 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 16 Apr 2008 12:52:37 +0200 Subject: Image handling - stupid question In-Reply-To: <0001HW.C42B9FB90009B7E8B01AD9AF@news.individual.de> References: <0001HW.C42B9FB90009B7E8B01AD9AF@news.individual.de> Message-ID: <4805da69$0$11464$426a74cc@news.free.fr> Jumping Arne a ?crit : > I'm going to try to write some imange manipulation code (scaling, reading > EXIF and IPTC info) and just want to ask if PIL is *THE* library to use? > > I looked at and noticed that the > latest version is from Dec 2006. > > In my experience that means that either it's abandoned I doubt it is. > or that it's very good > and stable. My own experience is that it's indeed a pretty good and AFAICT stable library. From mobile at ibinsa.com Fri Apr 11 18:12:07 2008 From: mobile at ibinsa.com (Gabriel Ibanez) Date: Sat, 12 Apr 2008 00:12:07 +0200 Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> <47FFDA87.3070703@gmail.com> Message-ID: <020201c89c21$14d02be0$0a01a8c0@mobile> Hello all ! More fire .. Why is nobody talking about pyGTK ? There are no limits with licenses (I think) If we work on Ubuntu or Fedora, is there any reason to give GTK away and develop on Qt ? ----- Original Message ----- From: "Stef Mientki" Cc: Sent: Friday, April 11, 2008 11:39 PM Subject: Re: How is GUI programming in Python? > Rune Strand wrote: >> On Apr 10, 3:54 am, Chris Stewart wrote: >> ... >> >>> Next, what would you say is the best framework I should look into? >>> I'm curious to hear opinions on that. >>> >> >> GUI-programming in Python is a neanderthal experience. What one may >> love with console scripts is turned upside-down. Projects like Boa >> Constructor seemed to be a remedy, but is not developed. The Iron- >> Pythonistas has a very promising RAD GUI-tool in the IronPython - >> Studio, http://www.codeplex.com/IronPythonStudio - but if you're non- >> Iron, only sorrow is left - unless you fancy creating GUI in a text- >> editor. Something I consider waste of life. >> >> > Although not as simple as Delphi, > wxPython is still quit simple: > > GUI = """ > self.Splitter_Plots ,SplitterVer > self.Panel ,PanelVer, 010 > self.Panel_Top ,PanelHor, 11 > label1 ,wx.StaticText ,label = "Signal1" > label2 ,wx.StaticText ,label = "Signal2" > self.Panel_X ,wx.Panel, 11 > self.Panel_Bottom ,PanelHor > label11 ,wx.StaticText ,label = "Signal1b" > label12 ,wx.StaticText ,label = "Signal2b" > Panel_B ,wx.Panel > Button_1 ,wx.Button ,label = "Test" > Button_2 ,wx.Button ,label = "Test2", pos = (100,0) > """ > exec ( Create_wxGUI ( GUI ) ) > > cheers, > Stef > -- > http://mail.python.org/mailman/listinfo/python-list > From gagsl-py2 at yahoo.com.ar Fri Apr 18 15:27:38 2008 From: gagsl-py2 at yahoo.com.ar (gagsl-py2 at yahoo.com.ar) Date: Fri, 18 Apr 2008 16:27:38 -0300 (ART) Subject: import hooks In-Reply-To: <664bf2b80804170630j47e6c7a8r692f5d80af2cc13f@mail.gmail.com> Message-ID: <808535.5211.qm@web32807.mail.mud.yahoo.com> --- Patrick Stinson escribi?: > Right on, that seemed to work, thanks. > This is different than sys.path_hooks though, which > requires a callable or > string subclass? Yes, it's different, meta_path is a generic mechanism that doesn't depend on sys.path and is tried before sys.path is traversed; the other is triggered by a special sys.path entry (like a .zip file). > After some experimentation it looks like you can > disallow an import by > raising an import error from your meta_path hook. It > seems a little weird > that python will then raise a new ImportError from > import.c:find_module(), > but I guess the behavior is desirable.. I think you can't make an import fail completely; if your meta_path doesn't work, the next one is tried, and then the standard places (where the error is finally raised). Looks like the "global name foo not defined" error: sometimes it's not a global name at all, but that's where the search finally failed. -- Gabriel Genellina Gabriel Genellina Softlab SRL Tarjeta de cr?dito Yahoo! de Banco Supervielle. Solicit? tu nueva Tarjeta de cr?dito. De tu PC directo a tu casa. www.tuprimeratarjeta.com.ar From kitchen.kabinets at gmail.com Tue Apr 29 22:11:50 2008 From: kitchen.kabinets at gmail.com (kitchen.kabinets at gmail.com) Date: Tue, 29 Apr 2008 19:11:50 -0700 (PDT) Subject: Cheap Cabinets - Why You Don't Have To Sacrifice Quality To Find Cabinets At A Discount Price Message-ID: Kitchen Cabinets: http://the-kitchen-cabinets.blogspot.com, With the demand for cheaper building materials and the rapid housing boom a couple of years back, many kitchen cabinet manufacturers started looking overseas for a way to make a cheaper kitchen cabinet. In order to conform to the KCMA standards (Kitchen Cabinet Manufacturers Association), they required the kitchen cabinet manufacturing plants overseas to increase the quality of the materials they used and increase the durability of the kitchen cabinets. Discount kitchen cabinets or RTA Kitchen Cabinets up until this time had been made of fiberboard or particleboard, with staples or dowels holding the cabinets together. Many of the cheap kitchen cabinets at that time had a veneer surface that would warp or buckle when it came in contact with too much water. Because of these inferior features, they didn't compare to the cabinets that were being manufactured in the U.S. With the improvements to meet the standards of the KCMA, {discount| cheap} kitchen cabinets are now being built with solid plywood sides, solid wood face frames and doors. and cam locks to hold the cabinet together. Cheap Cabinets is no longer the right description for rta kitchen cabinets. With the improvements in design and function, discount cabinets started being imported by more and more companies to provide an alternative to the name brand manufacturers in the US that were asking, in some cases, 2-3 times as much for their kitchen cabinets as discount kitchen cabinet importers were. Even the big box stores started carrying their own lines of rta kitchen cabinets or discount cabinets, in both knockdown and pre-assembled form. There are some drawbacks to buying discount kitchen cabinets... most manufacturers only carry 5-6 different styles or finishes, which limits your choices. In order to get discount cabinets at their cheapest price, you have to buy them rta or ready-to-assemble, which requires additional time and labor to assemble them. The good news is that with the cam lock assembly, most discount cabinet lines only require a screwdriver to assemble them. So before buying your new kitchen cabinets at retail price, may sure you stop to take a look at discount kitchen cabinets or rta cabinets. Thanks for improvements, it is now possible to get cheap kitchen cabinets at a discount price. I have been able to save thousands of dollars on discount kitchen cabinets by buying RTA cabinets. If you are interested in finding out my secrets, go to my Kitchen Cabinets article at http://the-kitchen-cabinets.blogspot.com From stephen.cattaneo at u4eatech.com Tue Apr 1 15:09:09 2008 From: stephen.cattaneo at u4eatech.com (Stephen Cattaneo) Date: Tue, 01 Apr 2008 12:09:09 -0700 Subject: manipulating hex values In-Reply-To: References: <47F26CC3.3060307@u4eatech.com> Message-ID: <47F28855.50908@u4eatech.com> Gabriel Genellina wrote: >
En Tue, > 01 Apr 2008 14:11:31 -0300, Stephen Cattaneo > escribi?: > >> I am relatively new to socket programming. I am attempting to use raw >> sockets to spoof my IP address. > > Don't bother to try... > ? Is there a better solution to spoofing my IP then using raw sockets (I'm working on a machine with multiple interfaces and need to be able to some how specify which interface that traffic needs to be sent/recieved to/from) >> From what I can tell I will have to >> build from the Ethernet layer on up. This is fine, but I am having >> some trouble with manipulating my hex values. >> >> Seems to me that there are two ways to store hex values: >> 1. as literal hex - 0x55aa >> 2. as a string - "\x55aa" > > The later is exactly the same string as "Uaa": > > py> print "\x55aa" > Uaa > >> If I want to convert hex to decimal I can use: >> int("\x55aa", 16) # note that plain 0x55aa, instead of "\x55aa", will >> raise an exception > > Have you tried it? > > py> int("\x55aa", 16) > Traceback (most recent call last): > File "", line 1, in > ValueError: invalid literal for int() with base 16: 'Uaa' > py> int("0x55aa", 16) > 21930 > An oversight on my part and the source of my problem. Thank you. The source of my confusion is that I need to keep my bytes formated correctly. I am using the below 'raw socket example' proof-of-concept code as my example. (And yes, I have tried the proof-of-concept. It works correctly. It is not my code.) dstAddr = "\x01\x02\x03\x04\x05\x06" dstAddr1 = "0x010203040506" dstAddr != dstAddr1 Follow up question: What is the best to store my bytes up until sending the packets? Perhaps I should use lists of decimal numbers and then before sending convert to hex. I.E. dstAddr = [ 1, 2, 3, 4, 5, 6] dstAddr.prepareToSend() txFrame = struct.pack("!6s6sh",dstAddr,srcAddr,proto) + ethData Is there a better way to do this? Thanks, Steve ----------------raw socket example------------------- #!/usr/bin/python import sys import string import struct from socket import * proto = 0x55aa s = socket(AF_PACKET, SOCK_RAW, proto) s.bind(("eth0",proto)) ifName,ifProto,pktType,hwType,hwAddr = s.getsockname() srcAddr = hwAddr # send packet to ethernet MAC: 01-02-03-04-05-06 dstAddr = "\x01\x02\x03\x04\x05\x06" ethData = "here is some data for an ethernet packet" print "ethData length is: " + str(len(ethData)) txFrame = struct.pack("!6s6sh",dstAddr,srcAddr,proto) + ethData s.send(txFrame) From ZeeGeek at gmail.com Thu Apr 10 04:45:41 2008 From: ZeeGeek at gmail.com (ZeeGeek) Date: Thu, 10 Apr 2008 01:45:41 -0700 (PDT) Subject: email header decoding fails References: Message-ID: On Apr 10, 4:31 pm, "Gabriel Genellina" wrote: > En Wed, 09 Apr 2008 23:12:00 -0300, ZeeGeek escribi?: > > > It seems that the decode_header function in email.Header fails when > > the string is in the following form, > > > '=?gb2312?Q?=D0=C7=C8=FC?=(revised)' > > > That's when a non-encoded string follows the encoded string without > > any whitespace. In this case, decode_header function treats the whole > > string as non-encoded. Is there a work around for this problem? > > That header does not comply with RFC2047 (MIME Part Three: Message Header > Extensions for Non-ASCII Text) > > Section 5 (1) > An 'encoded-word' may replace a 'text' token (as defined by RFC 822) > in any Subject or Comments header field, any extension message > header field, or any MIME body part field for which the field body > is defined as '*text'. [...] > Ordinary ASCII text and 'encoded-word's may appear together in the > same header field. However, an 'encoded-word' that appears in a > header field defined as '*text' MUST be separated from any adjacent > 'encoded-word' or 'text' by 'linear-white-space'. > > Section 5 (3) > As a replacement for a 'word' entity within a 'phrase', for example, > one that precedes an address in a From, To, or Cc header. [...] > An 'encoded-word' that appears within a > 'phrase' MUST be separated from any adjacent 'word', 'text' or > 'special' by 'linear-white-space'. Thank you very much, Gabriel. From jwwest at gmail.com Sun Apr 13 03:18:13 2008 From: jwwest at gmail.com (James West) Date: Sun, 13 Apr 2008 02:18:13 -0500 Subject: Recommendation for Web Framework Message-ID: <4801b3a6$0$7713$4c368faf@roadrunner.com> Let me explain my situation a bit. I've been contracted to develop an ecommerce site. It's nothing too huge but requires a lot of custom development that's not typical for your run of the mill webstore. I've got about three weeks to get the project delivered and I've written quite a bit of code already. I'd like to find some sort of tool to generate some of the repetative bits like data management (think phpMyAdmin but for Python) so I don't have to write a stupid mangement script for every single module (users, customers, inventory, etc). I know there's tools out there that will do this for ASP code with a SQL server backend, but I haven't seen anything for Python outside of the web application frameworks. Ideally, I'd like something like Ruby on Rails that would provide scaffolding support so I can bootstrap the system, so to speak. I've looked at Django, but the client is only running Apache 1.x and Python 2.3. I've given Turbo Gears a try, but couldn't get SQLObject to run (threw an error that I didn't have time to struggle with). So basically I need something with low dependencies, easy to develop in, and releatively easy to deploy. Anyone have any recommendations? I really need something on which I can ramp up quickly to get this project out of the door fast. I'm also a framework newbie, so I know there's a learning curve. Any input is appreciated, thank you. - james From rjh at see.sig.invalid Mon Apr 14 08:01:29 2008 From: rjh at see.sig.invalid (Richard Heathfield) Date: Mon, 14 Apr 2008 12:01:29 +0000 Subject: Game design : Making computer play References: Message-ID: skanemupp at yahoo.se said: > On 14 Apr, 09:13, v4vijayakumar > wrote: >> In computer based, two player, board games, how to make computer play? >> Are there any formal ways to _teach_ computer, to choose best possible >> move? >> >> I know this is kind of off-topic here. Please redirect me, if there >> are more appropriate newsgroup. > > can you post a link to the game so I can see the rules and how the > board looks. Here's the board (which bears only a slight resemblance to one I'd seen on the Web): +---------------+ | HORN $ | +---+---+---+---+---+---+ |L W| | $ | $ | |R W| +E-I+--CHEST+---+---+I-I+ |F N| | | | |G N| +T-G+---+---+---+---+H-G+ | | | | | |T | +---+---+---+---+---+---+ | LEGS| | | +---+---+---+---+ There are three tigers and fifteen goats. The tigers' goal is to eat all the goats and remain mobile. It seems that the initial tiger positions are: one on the horn, and one each on CHEST-2 and CHEST-3 (see $ marks, above). The goats' goal is to block the tigers from moving. The goats are placed one by one. Tigers appear only to be able to move orthogonally (up/down/left/right) - although they can use the horn to whizz across the chest (e.g. CHEST-1 to HORN, HORN to CHEST-4, in two moves). The rest of the rules are beyond me, I'm afraid. It's not clear how tigers eat goats or how goats block tigers. -- Richard Heathfield Email: -http://www. +rjh@ Google users: "Usenet is a strange place" - dmr 29 July 1999 From bwljgbwn at gmail.com Tue Apr 22 05:54:36 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:54:36 -0700 (PDT) Subject: flash 8 crack Message-ID: flash 8 crack http://cracks.12w.net F R E E C R A C K S From carsten.haese at gmail.com Thu Apr 17 19:59:24 2008 From: carsten.haese at gmail.com (Carsten Haese) Date: Thu, 17 Apr 2008 23:59:24 GMT Subject: get quote enclosed field in a line In-Reply-To: <4807e238$1@news.mel.dft.com.au> References: <4807e238$1@news.mel.dft.com.au> Message-ID: John Machin wrote: > xahlee at gmail.com wrote: >> is there a simple way in perl, python, or awk/shell/pipe, that gets >> the user agent field in a apache log? > If you don't like that, just hang about -- there's sure to be a > pyparsing bus coming by real soon now :-) While we're waiting for the pyparsing bus, here's the shlex train: import shlex line = """blah blah blah""" print shlex.split(line)[10] HTH, -- Carsten Haese http://informixdb.sourceforge.net From mfb.chikazuku at gmail.com Thu Apr 10 14:56:54 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Thu, 10 Apr 2008 20:56:54 +0200 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Mike Driscoll wrote: > On Apr 10, 12:05 pm, Michel Bouwmans wrote: >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> >> >> Paul Rubin wrote: >> > Chris Stewart writes: >> >> I've always had an interest in Python and would like to dabble in it >> >> further. I've worked on a few very small command line programs but >> >> nothing of any complexity. I'd like to build a really simple GUI app >> >> that will work across Mac, Windows, and Linux. How painful is that >> >> going to be? I used to be really familiar with Java Swing a few years >> >> ago. I imagine it will be similar. >> >> ... >> >> Next, what would you say is the best framework I should look into? >> >> > If by "best" you mean "easiest", that is probably tkinter, which >> > comes with python. It is somewhat rudimentary and the widgets that >> > come with it don't look so great. But if you just want to put up >> > GUI's with basic functionality and not much glitz, it is ok for most >> > such purposes. >> > out how to use >> >> I don't quite agree with you on this. Tkinter may be easy because it is >> available by standard in Python, but that's about it in my opinion. The >> API, look and performance hit is horrible. You're much better of with >> PyQt4 which makes the job really simple. >> >> MFB >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG v1.4.7 (GNU/Linux) >> >> iD8DBQFH/kjhDpaqHmOKFdQRAj+kAJ0d3aHqpv/mh7kSqtDqUFXtJsxi1gCfU5UP >> 2Ygw9ttRIYX+ioMyBVUNsVo= >> =stR5 >> -----END PGP SIGNATURE----- > > I see a lot of people recommend using pyQt, but they never mention the > controversy that surrounds its licensing. There have been many posts > on the subject already, but if the OP ever decides to sell anything > they create, I've heard that QT's licensing is kind of squirrelly. > Maybe this has been straightened out? > > I looked at the website and found it fairly confusing. And don't you > need to download QT itself? > > Mike Yeah, the licensing of Qt is either be open-source (under one of the Qt-exception licenses licenses so no exclusivity for the GPL anymore) or pay for the commercial version. So yes, if you would like to sell it as closed-source software you will need to buy the commercial version of Qt and PyQt. In other words: you will have to pay twice. Don't forget that you can also sell open-source software, so you don't have to pay. ;) MFB -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFH/mMBDpaqHmOKFdQRAiAkAJ0XoysACvcaxLWwvYauFlgEEaGLVwCfdz7g XMUDfEPLX6RfLV25viLB9aA= =d2ms -----END PGP SIGNATURE----- From fritz at milkpotato.org Mon Apr 28 09:36:09 2008 From: fritz at milkpotato.org (fritz) Date: Mon, 28 Apr 2008 06:36:09 -0700 Subject: is there a threadsafe cookie library? Message-ID: <20080428063609.3a0ad024ae5a198c10a90d54bed1b07a.ff2f7b4127.wbe@email.secureserver.net> An HTML attachment was scrubbed... URL: From sturlamolden at yahoo.no Thu Apr 17 13:05:00 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 17 Apr 2008 10:05:00 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> <69cbd3d3-449f-4e64-96d5-f512cf317032@m3g2000hsc.googlegroups.com> Message-ID: <2a32d56a-5075-4c48-99fc-686a3f53fc26@m36g2000hse.googlegroups.com> On Apr 17, 6:03 pm, Rhamphoryncus wrote: > Interesting. Windows specific, but there's other ways to do the same > thing more portably. I believe you can compile Python as a shared object (.so) on Linux as well, and thus loadable by ctypes. > The bigger issue is that you can't share any objects. Why not? > This > effectively gives you a multiprocess model - a bit cheaper than that, > but not enough to really supply GIL-free threading. That solution is safe. But I am looking into sharing objects. I don't think its impossible. PyObject* pointers can be passed around. GILs can be acquired and released, refcounts increased and decreased, etc. but we have to sort out some synchronization details for the shared objects. For one thing, we have to make sure that a garbage collector does not try to reclaim a PyObject* belonging to another interpreter. But here we are talking about minor changes to CPython's source, or perhaps none at all. From steve at holdenweb.com Sat Apr 12 17:51:16 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 17:51:16 -0400 Subject: str(bytes) in Python 3.0 In-Reply-To: References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> Message-ID: Dan Bishop wrote: > On Apr 12, 9:29 am, Carl Banks wrote: >> On Apr 12, 10:06 am, Kay Schluehr wrote: >> >>> On 12 Apr., 14:44, Christian Heimes wrote: >>>> Gabriel Genellina schrieb: >>>>> On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') >>>>> above. But I get the same as repr(x) - is this on purpose? >>>> Yes, it's on purpose but it's a bug in your application to call str() on >>>> a bytes object or to compare bytes and unicode directly. Several months >>>> ago I added a bytes warning option to Python. Start Python as "python >>>> -bb" and try it again. ;) >>> And making an utf-8 encoding default is not possible without writing a >>> new function? >> I believe the Zen in effect here is, "In the face of ambiguity, refuse >> the temptation to guess." How do you know if the bytes are utf-8 >> encoded? > > True, you can't KNOW that. Maybe the author of those bytes actually > MEANT to say '??C??mo est??s?' instead of '?C?mo est?s?'. However, > it's statistically unlikely for a non-UTF-8-encoded string to just > happen to be valid UTF-8. So you propose to perform a statistical analysis on your input to determine whether it's UTF-8 or some other encoding? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gagsl-py2 at yahoo.com.ar Thu Apr 24 01:00:14 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 24 Apr 2008 02:00:14 -0300 Subject: python-doc References: Message-ID: En Wed, 23 Apr 2008 11:02:46 -0300, korean_dave escribi?: > Hi all. I am using this to try to document my python-coded apps. > http://effbot [DOT] org/zone/pythondoc [DOT] htm > > i am using windows XP professional. I have put the install directory > of pythondoc.py in my path file. So i "cd" to the directory containing > the python scripts I wish to python-doc, typing in "python-doc.py > scriptname.py" and after about 1 second, i get nothing. No error, but > again, no indication that this process has been completed. > > I have no idea where to look for html files. I checked all relevant > directories that might have it (the directory containing the > pythondoc.py script, etc.). I've never used pythondoc myself, but it says "The current version writes the output to the current directory, to files named pythondoc-module.html." You may try using another documentation tool, there are many available, see -- Gabriel Genellina From hobgoodoreneyhb at gmail.com Tue Apr 22 11:45:00 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:45:00 -0700 (PDT) Subject: revit building 9 crack only Message-ID: <485712cb-4510-4199-8589-ed151ef79597@p25g2000hsf.googlegroups.com> revit building 9 crack only http://cracks.12w.net F R E E C R A C K S From tjreedy at udel.edu Mon Apr 7 16:59:21 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 7 Apr 2008 16:59:21 -0400 Subject: A funnily inconsistent behavior of int and float References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com><1d11875a-470a-489f-910a-b420a145eb61@a1g2000hsb.googlegroups.com><11b4793c-04cc-4898-99a8-8418d237de3e@2g2000hsn.googlegroups.com> <1255ee3e-cc1e-4ae8-96f3-5f942c389c49@t54g2000hsg.googlegroups.com> Message-ID: "Mark Dickinson" wrote in message news:1255ee3e-cc1e-4ae8-96f3-5f942c389c49 at t54g2000hsg.googlegroups.com... Thank you for the corrections. Here is my revised proposal: int([number | string[, radix]) Convert a number or string to an integer. If no arguments are given, return 0. If a number is given, return number.__int__(). Conversion of floating point numbers to integers truncates towards zero. A string must be a base-radix integer literal optionally preceded by '+' or '-' (with no space in between) and optionally surrounded by whitespace. A base-n literal consists of the digits 0 to n-1, with 'a' to 'z' (or 'A' to 'Z') having values 10 to 35. The default radix is 10. The allowed values are 0 and 2-36. Base-2, -8, and -16 literals can be optionally prefixed with 0b/0B, 0o/0O, or 0x/0X, as with integer literals in code. Radix 0 means to interpret exactly as a code literal, so that the actual radix is 2, 8, 10, or 16, and so that int('010',0) is not legal, while int('010') is. Terry Jan Reedy From tjreedy at udel.edu Thu Apr 10 16:07:01 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 10 Apr 2008 16:07:01 -0400 Subject: Module Conflicts References: <1592fad3-996b-4f62-ac12-42aff8272c21@8g2000hsu.googlegroups.com> <845e315c-0159-4390-954a-dc93fd1b27a1@x41g2000hsb.googlegroups.com> Message-ID: "Jose" wrote in message news:b7ed8b5e-91fa-4495-b4e3-4912be9e8d90 at s50g2000hsb.googlegroups.com... | On Apr 9, 10:36 pm, Benjamin wrote: | > On Apr 9, 5:33 pm, Jose wrote: | > | > > I have a module named math.py in a package with some class | > > definitions. I am trying to import the standard python math module | > > inside of math.py but It seems to be importing itself. Is there any | > > way around this problem without renaming my math.py file? | > | > Not without some unpythonic magic. It's really not good style to name | > a module the same as a stdlib one. It'll also confuse people reading | > your code. | | Yeah but I thought since math.py was in a package, it would be okay. The stdlib contains a few packages, but it is not a package in itself. So math is not in a package. From aaron.watters at gmail.com Wed Apr 30 10:20:13 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 30 Apr 2008 07:20:13 -0700 (PDT) Subject: best way to host a membership site References: <53034dcc-7346-4f71-889c-3278c9e813ec@w1g2000prd.googlegroups.com> <48185252$0$32098$426a74cc@news.free.fr> Message-ID: > We're about to start a couple somewhat similar projects here, and while > our chief engineer is a definitive Ruby/Rails addict, we finally settled > on Django. While it's not my own personal favorite Python MVC framework, > it's still a very good one, and probably the more mature and stable so > far. wrt/ the "add more apps in the future" concern, you may want to > read this:http://www.b-list.org/weblog/2007/nov/29/django-blog/ Interesting link. Django does seem to be a well designed modular approach -- and I think if it had existed back in '97 the history of web development would have been much different. I can't help feeling that it would be nice to have a collection of tools that was even more orthogonal and flexible, and WSGI seems to possibly offer a nice base platform for constructing tools like these. Also I think it remains devilishly difficult to implement ajaxy functionalities like smart data pickers, in-form validation, partial form saving, "chatty interfaces" etc. What are some good paradigms or methodologies or ideas out there that the Python community should steal? :) warning: It's very possible that my understanding of Django is not deep enough and that the answer is "Django". -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=you+may+cheat From dolloffdelvpg at gmail.com Wed Apr 16 08:09:47 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:09:47 -0700 (PDT) Subject: taylor swift a place in this world Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From kyosohma at gmail.com Wed Apr 9 16:57:43 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 9 Apr 2008 13:57:43 -0700 (PDT) Subject: Control process execution References: <1d1bbea2-a503-4db5-bd3f-c45c29916b9c@13g2000hsb.googlegroups.com> Message-ID: <7cb4c5dd-8604-4d18-925c-d6aa17c092b5@24g2000hsh.googlegroups.com> On Apr 9, 3:11 pm, Noah wrote: > On Apr 6, 5:30 am, Wesley Mesquita wrote: > > > I am trying to create a test environment to a couple C applications > > (simple UDP and TCP server/clients), so I want to write this in python > > and I m looking for ways to do it. Basically I need an execution timer > > and timeout control (to kill the apps in certain situations). Looking > > at google, I found the Pexpect package, but I m a little bit lost in > > using it. > > Pexpect might be good. But if you are just looking at running an > application > without talking to it interactively then you might be able to just get > by > with os.process. > > -- > Noah As far as I know, there is no "os.process". Maybe you meant os.system or the subprocess module? Mike From kyosohma at gmail.com Wed Apr 9 09:19:09 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 9 Apr 2008 06:19:09 -0700 (PDT) Subject: I am worried about Python 3 References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> Message-ID: <44c8b263-a01b-45b5-a971-faa6aa1611ec@d45g2000hsc.googlegroups.com> On Apr 9, 7:04 am, jmDesktop wrote: > I am a new Python programmer. I have always desired to learn Python, > but have never had the opportunity. Recently this has changed, and I > have an opportunity to get away from the .NET framework. I found > Django (and other web frameworks) and began my quest to learn. I > started reading Dive Into Python and anything I could find and started > participating here in usenet. Then I had to read this: > > http://www.comp.leeds.ac.uk/nde/papers/teachpy3.html > > I think that every time I start a new technology (to me) it is about > to change. Yes, I know that is the nature of things, but I'm always > at the start of "something new." > > If I continue in Python 2.5.x, am I making a mistake? Is it really > that different? > > Here is an excerpt that is causing me concern: > > Two new versions of the language are currently in development: version > 2.6, which retains backwards compatibility with previous releases; and > version 3.0, which breaks backwards compatibility to the extent that > even that simplest of programs, the classic 'Hello, World', will no > longer work in its current form. > > It makes me feel like I am wasting my time and makes it difficult to > justify spending time on projects using 2.5.x and using it where I > work. Just because there's a new version on the horizon that doesn't mean you have to upgrade to it. There are plenty of people that still use 2.3, such as my web host. I've only just started really using 2.5 this year. Mike From SuJinzhu at gmail.com Mon Apr 14 04:26:28 2008 From: SuJinzhu at gmail.com (James Su) Date: Mon, 14 Apr 2008 01:26:28 -0700 (PDT) Subject: Chinese character become ??? by pymssql or pyodbc Message-ID: <01d95039-b547-45ff-9b54-f04aee8eaaa1@u36g2000prf.googlegroups.com> I tried to use pymssql to access MSSQL 2000, with a table, I store Chinese Character in NVarchar field, Chinese Character display normally when I query them by MS SQL Query Analyzer under Windows or by unixODBC under Ubuntu. But when I query those data by pymssql or pyodbc, all Chinese Character display ??? instead. Does anyone has some advice or thread? Thanks. From carbanancizpo at gmail.com Fri Apr 18 16:55:22 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:55:22 -0700 (PDT) Subject: army men 2 crack Message-ID: army men 2 crack http://cracks.12w.net F R E E C R A C K S From tjreedy at udel.edu Thu Apr 24 04:41:50 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 24 Apr 2008 04:41:50 -0400 Subject: function that accepts any amount of arguments? References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> Message-ID: "globalrev" wrote in message news:4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0 at w7g2000hsa.googlegroups.com... | if i want a function that can take any amount of arguments how do i | do? | | lets say i want a function average that accepts any number of integers | and returns the average. To add to the other comments, read the ref manual section of function defs. From meisnernel73884 at gmail.com Wed Apr 30 06:38:48 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:38:48 -0700 (PDT) Subject: autocad 2005 cracks and cheats Message-ID: <2df45216-0fff-4f22-9876-0de8b24a6397@2g2000hsn.googlegroups.com> autocad 2005 cracks and cheats http://crack.cracksofts.com From george.sakkis at gmail.com Tue Apr 1 09:43:49 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 1 Apr 2008 06:43:49 -0700 (PDT) Subject: class super method References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> Message-ID: <0eb3ee4e-82e2-419a-8e7b-4931f7b4effa@c26g2000prf.googlegroups.com> On Mar 31, 10:41 pm, Ed Leafe wrote: > On Mar 31, 2008, at 5:58 PM, George Sakkis wrote: > > >> is there any tutorial for super method (when/how to use it)? > > >> or maybe someone could explain me how it works? > > >> thx > > > Super is one of the dark corners of the language [1,2]... a good rule > > of thumb is to stay away from it, or at least stick to its basic > > usage. > > I disagree - super is quite elegant and dependable. Did you follow the links I gave by any chance? With all the gotchas and rules of how to use it properly, it's far from what I would call elegant. > In my own project (Dabo), we use mixin classes liberally to provide > consistent behavior across our UI classes. The use of super makes > customizing __init__() behavior, for example, quite straightforward. > The general form looks like: > > class DaboUIClass(dabo.ui.dControlMixin, someWxPythonClass): > def __init__(self, *args, **kwargs): > doOurCustomStuffBeforeTheSuperCall() > super(DaboUIClass, self).__init__(*args, **kwargs) > doOurCustomStuffAfterTheSuperCall() > > This has worked reliably for us in every place where we have used it. > There's nothing dark and mysterious about it at all. Pehaps, at least as long as you make sure that all superclasses have a compatible signature - which in practice typically means accept arbitrary *args and **kwargs in every class in the hierarchy like your example. Good luck figuring out what's wrong if it's not used consistently. Also doOurCustomStuffBeforeTheSuperCall() works as long as all ancestor methods to be called need the same CustomStuff massaging. In a sentence, it's better than nothing but worse than anything. George From JesseAldridge at gmail.com Sun Apr 6 10:34:11 2008 From: JesseAldridge at gmail.com (Jesse Aldridge) Date: Sun, 6 Apr 2008 07:34:11 -0700 (PDT) Subject: Python Data Utils References: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> Message-ID: On Apr 6, 6:14?am, "Konstantin Veretennicov" wrote: > On Sun, Apr 6, 2008 at 7:43 AM, Jesse Aldridge wrote: > > In an effort to experiment with open source, I put a couple of my > > ?utility files up here. ?What do you think? > > Would you search for, install, learn and use these modules if *someone > else* created them? > > -- > kv Yes, I would. I searched a bit for a library that offered similar functionality. I didn't find anything. Maybe I'm just looking in the wrong place. Any suggestions? From paulgeeleher at gmail.com Tue Apr 22 12:21:44 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Tue, 22 Apr 2008 09:21:44 -0700 (PDT) Subject: Setting expirty data on a cookie Message-ID: <8ba48e05-9aba-4a56-805c-cd31b43517ab@24g2000hsh.googlegroups.com> Does anyone know how to do this? I can't seem to make it work. I'm using: c = Cookie.SimpleCookie() c['data'] = "unamepwordwhatever" c.expires = time.time() + 300 print c This doesn't seem to work, so I'm assuming isn't the correct way to set an expiry data? Anyone able to help me out here? Thanks! From fr5478bey at gmail.com Sat Apr 26 11:38:07 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:38:07 -0700 (PDT) Subject: registry mechanic 7.0 crack Message-ID: <4405bd80-9ec0-412b-9e28-ed3469a6dd1b@f63g2000hsf.googlegroups.com> registry mechanic 7.0 crack http://cracks.00bp.com F R E E C R A C K S From fredrik at pythonware.com Sun Apr 6 04:34:17 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 06 Apr 2008 10:34:17 +0200 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: <47F831F7.4000709@holdenweb.com> References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> <47F831F7.4000709@holdenweb.com> Message-ID: Steve Holden wrote: >> for reference, here's what I get on Ubuntu 7.10, with the standard >> Python interpreter (2.5.1): >> >> $ python -c "import imp; print imp.get_suffixes()" >> [('.so', 'rb', 3), ('module.so', 'rb', 3), ('.py', 'U', 1), >> ('.pyc', 'rb', 2)] >> >> any Ubuntu gurus here that can sort this one out? >> > I wouldn't claim to be an Ubuntu guru but it seems as though the Ubuntu > team decide that you would be able to import extension module YYY either > from YYY.so or from YYYmodule.so. IF you are asking *why* then I'd have > to answer that I have no idea at all. oh, the ".so" and "module.so" is standard Python behaviour (see my first post in this thread). what I cannot figure out is how "llothar" has managed to get setup.py to build extensions that an Ubuntu Python cannot load, without noticing. From cyberco at gmail.com Wed Apr 9 05:35:48 2008 From: cyberco at gmail.com (Berco Beute) Date: Wed, 9 Apr 2008 02:35:48 -0700 (PDT) Subject: Can C.L.P.handle the load? References: <3b6737c8-9d42-4218-ac60-01df2f578746@p39g2000prm.googlegroups.com> <9bd25fd3-5133-4165-9784-fbbc21145810@24g2000hsh.googlegroups.com> Message-ID: On Apr 9, 7:54 am, Paddy wrote: > What else could we do to make c.l.p. of more use to the newbie whp may > also be new to usenet whilst keeping c.l.p a usefull place for all? > > - Paddy. Maybe create a usenet/google group for newbies? A place to ask beginners questions. And post a sticky to c.l.p. redirecting newbies (or experienced pythoneers with newbie questions :). 2B From the.doag at gmail.com Wed Apr 23 18:24:02 2008 From: the.doag at gmail.com (Daniel) Date: Wed, 23 Apr 2008 15:24:02 -0700 (PDT) Subject: Parsing tuple from string? Message-ID: I have a list of strings, which I need to convert into tuples. If the string is not in python tuple format (i.e. "('one', 'two')", "("one", 'two')", etc.), then I can just make it a 1-tuple (i.e. return (string,) ). If it is in python tuple format, I need to parse it and return the appropriate tuple (it's ok to keep all tuple elements as strings). I think eval() will work for this, but I don't know what will be in the string, so I don't feel comfortable using that. I tried coming up with a regex, but the best I can get with my limit knowledge right now is: matches = re.match("\(['\"](.*)['\"], ['\"](.*)['\"]\)", string) which works well enough for my purposes (even though I know it's far from proper), except that it only captures as 2-tuples, and I need to be able to capture n-tuples. Can someone help point me to the correct re or a better way to solve this? Thanks in advance, Daniel From ellingt8877 at gmail.com Mon Apr 28 01:48:48 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:48:48 -0700 (PDT) Subject: stellar phoenix crack Message-ID: stellar phoenix crack http://crack.cracksofts.com From bob at passcal.nmt.edu Fri Apr 18 17:26:58 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Fri, 18 Apr 2008 15:26:58 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> Message-ID: <2008041815265875249-bob@passcalnmtedu> On 2008-04-18 14:37:21 -0600, Ross Ridge said: > Bob Greschke wrote: >> I'm reading 3-byte numbers from a file and they are signed (+8 to >> -8million). This seems to work, but I'm not sure it's right. >> >> # Convert the 3-characters into a number. >> Value1, Value2, Value3 = unpack(">BBB", Buffer[s:s+3]) >> Value = (Value1*65536)+(Value2*256)+Value3 >> if Value >= 0x800000: >> Value -= 0x1000000 >> print Value >> >> For example: >> 16682720 = -94496 >> >> Should it be Value -= 0x1000001 so that I get -94497, instead? > > Your first case is correct, "Value -= 0x1000000". The value 0xFFFFFFF > should be -1 and 0xFFFFFFF - 0x1000000 == -1. > > An alternative way of doing this: > > Value = unpack(">l", Buffer[s:s+3] + "\0")[0] >> 8 > > Ross Ridge Good to know (never was good on the math front). However, in playing around with your suggestion and Grant's code I've found that the struct stuff is WAY slower than doing something like this Value = (ord(Buf[s])*65536)+(ord(Buf[s+1])*256)+ord(Buf[s+2]) if Value >= 0x800000: Value -= 0x1000000 This is almost twice as fast just sitting here grinding through a few hundred thousand conversions (like 3sec vs. ~5secs just counting on my fingers - on an old Sun...it's a bit slow). Replacing *65536 with <<16 and *256 with <<8 might even be a little faster, but it's too close to call without really profiling it. I wasn't planning on making this discovery today! :) Bob From vaibhav4947 at gmail.com Tue Apr 8 07:44:30 2008 From: vaibhav4947 at gmail.com (vaibhav pol) Date: Tue, 8 Apr 2008 17:14:30 +0530 Subject: No subject Message-ID: <18a05b120804080444ke5819e0n683ef6387267042d@mail.gmail.com> hi, I wrote a python program and import the function and executing , that fuction get executing as the current uid what i have to do if i want to exectue that function as root or another user . -------------- next part -------------- An HTML attachment was scrubbed... URL: From arnodel at googlemail.com Sun Apr 20 13:04:01 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 20 Apr 2008 10:04:01 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: <4d543ba1-c601-4490-8739-e42b46fc2236@k37g2000hsf.googlegroups.com> On Apr 20, 5:42?pm, Matthew Woodcraft wrote: > Christian Heimes ? wrote: > > >> I feel that including some optional means to block code would be a big > >> step in getting wider adoption of the language in web development and > >> in general. ?I do understand though, that the current strict indenting > >> is part of the core of the language, so... thoughts? > > Why should Python repeat the mistakes other languages did with SSI or > > inline code? Python favors the MVC separation of code and layout. > > An alternative scheme for describing the block structure could be > useful in other cases, though. For example, if you wanted to support > putting snippets of Python in configuration files, or spreadsheet > cells. > > There's no need to support the new scheme in .py files, so it seems to > me that this doesn't have to be done in the core language. All that's > needed is a variant of 'eval' which expects the alternate scheme, and > that could be prototyped just using text manipulation and the normal > 'eval'. By 'eval', I guess you mean 'exec' :) -- Arnaud From jr9445 at ATT.COM Thu Apr 10 11:37:55 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Thu, 10 Apr 2008 10:37:55 -0500 Subject: Stripping scripts from HTML with regular expressions In-Reply-To: <47fd46b3$0$6838$2d805a3e@textnews.eweka.nl> References: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> <47fd46b3$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: > -----Original Message----- > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > list-bounces+jr9445=att.com at python.org] On Behalf Of Michel Bouwmans > Sent: Wednesday, April 09, 2008 5:44 PM > To: python-list at python.org > Subject: RE: Stripping scripts from HTML with regular expressions > > > Thanks! That did the trick. :) I was trying to use HTMLParser but that > choked on the script-blocks that didn't contain comment-indicators. > Guess I > can now move on with this script, thank you. > Soooo.... you asked for help with a regex workaround, but didn't ask for help with the original problem, namely HTMLParser? ;-) ***** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA625 From carlwuhwdmckay at gmail.com Sat Apr 26 09:33:19 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:33:19 -0700 (PDT) Subject: serials and cracks Message-ID: <227a7ae9-14d5-4363-beb6-852ea6369ca3@m36g2000hse.googlegroups.com> serials and cracks http://cracks.00bp.com F R E E C R A C K S From pavlovevidence at gmail.com Sun Apr 13 03:24:04 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Sun, 13 Apr 2008 00:24:04 -0700 (PDT) Subject: str(bytes) in Python 3.0 References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> <806cf1da-8f06-4fff-8437-7f1ca1ff9472@k10g2000prm.googlegroups.com> Message-ID: <8fab7cda-d915-4e13-8bb8-f449b6617778@a22g2000hsc.googlegroups.com> On Apr 12, 11:51 am, Kay Schluehr wrote: > On 12 Apr., 16:29, Carl Banks wrote: > > > > And making an utf-8 encoding default is not possible without writing a > > > new function? > > > I believe the Zen in effect here is, "In the face of ambiguity, refuse > > the temptation to guess." How do you know if the bytes are utf-8 > > encoded? > > How many "encodings" would you define for a Rectangle constructor? I'm not sure what you're insinuating. If you are arguing that it's inappropriate for a constructor to take an "encoding" argument (as you put it), be my guest. I wasn't commenting on that specifically. I was commenting on your suggestion of having str assume utf-8 encoding, which IMO would be very unPythonic, whether you can pass encodings to it or not. Whatever happened to the decode method anyway? Why has str() been coopted for this purpose? I had expected that str objects would retain the encode method, bytes the decode method, and everyone would live happily ever after. If decode is a confusing name (and I know I have to engage a few extra neurons to figure out which way it goes), why not rename it to something like to_unicode instead of overloading the constructors more. Carl Banks From marcobonifazi at gmail.com Sun Apr 6 04:26:11 2008 From: marcobonifazi at gmail.com (Marco Bonifazi) Date: Sun, 6 Apr 2008 01:26:11 -0700 (PDT) Subject: PyGtk Windows all in one installer Message-ID: I realized a PyGtk all in one installer for Windows. You can download it from here: http://www.bonifazi.eu/appunti/pygtk_windows_installer.exe It is simply an assembling of all the different installers I previously downloaded (which are executed step by step), and you can choose. I realized this installer using EclipseNSIS and compiling the script generated by NSIS. Then, the script I created and that you can compile and modify using NSIS is the following: http://www.bonifazi.eu/appunti/pygtk_windows_installer.nsi I give also the link of the webpages where I got the different installers: http://www.bonifazi.eu/appunti/2008/04/pygtk-all-in-one-installer.html I'll try to keep update this installer. I hope it could be useful to someone. Bye. Marco Bonifazi From vlastimil.brom at gmail.com Sat Apr 12 18:38:05 2008 From: vlastimil.brom at gmail.com (Vlastimil Brom) Date: Sun, 13 Apr 2008 00:38:05 +0200 Subject: sqlite3 - adding tables and rows via parameters In-Reply-To: References: <9fdb569a0804120839w6916ed96ka5b53aad7ca6f565@mail.gmail.com> <9fdb569a0804121115v43d86c49ieb0f712bd5a49679@mail.gmail.com> Message-ID: <9fdb569a0804121538x4e0b0a88h3312dbafc58ace4e@mail.gmail.com> 2008/4/13, Steve Holden : > > Vlastimil Brom wrote: > > > ... are there any (security > > ...) risks of using string interpolation for table and column names in > the SQL commands? Or > > are the values, where parametrization (with ? in sqlite3) is supported, > > the only vulnerable part; whereas eg. an incorrect value of what should > > be a name is safe (of course, apart from the unsuccessful command > itself)? > > > > Ultimately that depends where the table and column names come from. If > they are user inputs then you are still vulnerable to SQL injection, but > usually that's not the case when a query is being parameterized - > usually it's values. > > As long as you consider the source of your data carefully you'll > probably be OK. > > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > Thanks again, there shouldn't be any unsecure data I am now aware of; I just didn't want to introduce possible problem sources, if there would be some more appropriate solution available :-) Regards, Vlasta -------------- next part -------------- An HTML attachment was scrubbed... URL: From diresu at web.de Tue Apr 8 04:31:24 2008 From: diresu at web.de (Dietrich Bollmann) Date: Tue, 08 Apr 2008 17:31:24 +0900 Subject: segmentation fault when executing PyImport_ImportModule("sys") Message-ID: <1207643484.845.6.camel@pippi.pippi> Hi, Since some time I get the following segmentation fault in an application which used to work fine until recently. I made a backtrace but couldn't find the reason for the segmentaion fault until now. In the hope that somebody might have encountered a similar problem or does understand the backtrace better than me and can explain it I posted the backtrace here... At the end of the backtrace I appended some more context concerning the involved code. Thanks for your help :) Dietrich Here comes the backtrace: ---- Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb046ab90 (LWP 9854)] threadstate_getframe (self=0xb7e8a889) at ../Python/pystate.c:154 154 ../Python/pystate.c: No such file or directory. in ../Python/pystate.c (gdb) bt full #0 threadstate_getframe (self=0xb7e8a889) at ../Python/pystate.c:154 No locals. #1 0xb7e8a897 in PyEval_GetGlobals () at ../Python/ceval.c:3340 current_frame = #2 0xb7eaeb67 in PyImport_Import (module_name=0xb7119480) at ../Python/import.c:2400 globals = import = builtins = r = silly_list = (PyObject *) 0xb738fb0c builtins_str = (PyObject *) 0xb7391c50 import_str = (PyObject *) 0xb7391fc0 #3 0xb7eaede5 in PyImport_ImportModule (name=0x901504b "sys") at ../Python/import.c:1903 pname = (PyObject *) 0xb7119480 result = (PyObject *) 0x0 #4 0x08996c9f in py_stdouterr_buffer_new () at source/blender/commandport/blender/src/py_stdouterr_buffer.c:75 buffer = (py_stdouterr_buffer) 0x94fd428 func_StringIO = (PyObject *) 0x9152a48 args_StringIO = (PyObject *) 0x0 #5 0x089967e1 in bcp_blender_handler_new () at source/blender/commandport/blender/src/bcp_blender.c:130 handler = (bcp_blender_handler) 0x9810420 #6 0x08998db3 in bcp_handle_client (client_socket=8) at source/blender/commandport/blender/src/bcp_handle_client.c:73 debug = 0 debug3 = 0 debug4 = 0 message_handler = (message_handler) 0x97eba10 blender_handler = (bcp_blender_handler) 0x0 command = 0x0 result = 0x9152a48 "%G?%@016\025\th%G??%@@\\%G?%@022v#\b \"v#\b%G??%@v#\bRv#\bbv#\brv#\b\202v#\b\222v#\b%G?%@v#\b%G?%@v#\b` \032%G?%@020\026%G???%@#\b%G?%@#\b\002w#\b\022w# \b\"w#\b2w#\bBw#\bRw#\bbw#\brw#\b\202w#\b\222w#\b%G?%@w#\b%G?%@w# \bp#p%G??%@#\b" package_number = -1216545219 #7 0x08998d60 in bcp_client_thread (args=0x0) at source/blender/commandport/blender/src/bcp_server.c:164 targs = (struct bcp_client_thread_args *) 0x0 client_socket = 8 client_thread = 2957421456 #8 0xb76b04fb in start_thread () from /lib/i686/cmov/libpthread.so.0 No symbol table info available. #9 0xb77c2d7e in clone () from /lib/i686/cmov/libc.so.6 No symbol table info available. (gdb) q The program is running. Exit anyway? (y or n) y --- and here some informations about its context: Python-2.4.4/Python/ceval.c line 3340: PyFrameObject *current_frame = PyEval_GetFrame(); context: --- PyObject * PyEval_GetGlobals(void) { PyFrameObject *current_frame = PyEval_GetFrame(); if (current_frame == NULL) return NULL; else return current_frame->f_globals; } --- Python-2.4.4/Python/pystate.c lign 154: { context: --- /* Default implementation for _PyThreadState_GetFrame */ static struct _frame * threadstate_getframe(PyThreadState *self) { return self->frame; } --- Python-2.4.4/Python/import.c lign 2400: globals = PyEval_GetGlobals(); context: --- PyObject * PyImport_Import(PyObject *module_name) { ... /* Get the builtins from current globals */ globals = PyEval_GetGlobals(); if (globals != NULL) { Py_INCREF(globals); builtins = PyObject_GetItem(globals, builtins_str); if (builtins == NULL) goto err; } ... } --- Python-2.4.4/Python/import.c lign 1903: result = PyImport_Import(pname); context: --- PyObject * PyImport_ImportModule(char *name) { PyObject *pname; PyObject *result; pname = PyString_FromString(name); if (pname == NULL) return NULL; result = PyImport_Import(pname); Py_DECREF(pname); return result; } --- source/blender/commandport/blender/src/py_stdouterr_buffer.c lign 75: buffer->mod_sys = PyImport_ImportModule("sys"); context: --- /** Make a new python io buffer. */ py_stdouterr_buffer py_stdouterr_buffer_new() { py_stdouterr_buffer buffer; buffer = (py_stdouterr_buffer) malloc(sizeof(py_stdouterr_buffer_struct)); if (buffer == NULL) { fprintf(stderr, "Couldn't allocate memory for new py_stdouterr_buffer! \n"); exit(ERROR_MEMORY); } buffer->mod_sys = PyImport_ImportModule("sys"); buffer->mod_cStringIO = PyImport_ImportModule("cStringIO"); /* store stdout and stderr */ buffer->stdout_obj = PyObject_GetAttrString(buffer->mod_sys, "stdout"); buffer->stderr_obj = PyObject_GetAttrString(buffer->mod_sys, "stderr"); /* make new string buffer for stdout and stderr */ PyObject *func_StringIO, *args_StringIO; func_StringIO = PyObject_GetAttrString(buffer->mod_cStringIO, "StringIO"); args_StringIO = Py_BuildValue("()"); buffer->outbuf_obj = PyEval_CallObject(func_StringIO, args_StringIO); buffer->errbuf_obj = PyEval_CallObject(func_StringIO, args_StringIO); Py_DECREF(args_StringIO); Py_DECREF(func_StringIO); return buffer; } --- From balta96428 at gmail.com Wed Apr 23 05:55:58 2008 From: balta96428 at gmail.com (balta96428 at gmail.com) Date: Wed, 23 Apr 2008 02:55:58 -0700 (PDT) Subject: pinnacle studio keygen Message-ID: <78dc86dc-fc77-44b4-b61d-ce14996075b7@m44g2000hsc.googlegroups.com> pinnacle studio keygen http://cracks.12w.net F R E E C R A C K S From __peter__ at web.de Wed Apr 9 03:31:06 2008 From: __peter__ at web.de (Peter Otten) Date: Wed, 09 Apr 2008 09:31:06 +0200 Subject: Sorting a List of Objects by an Attribute of the Objects Case-Insensitively References: <736fefbd-510f-40e9-8342-32b69a1a0c2a@t12g2000prg.googlegroups.com> <0912a817-2cdc-4a19-83d2-1d8befed4f4b@24g2000hsh.googlegroups.com> Message-ID: Paddy wrote: > On Apr 9, 4:04 am, Jason wrote: >> Hi folks-- >> >> Basically, I have a pressing need for a combination of 5.2 "Sorting a >> List of Strings Case-Insensitively" & 5.3 "Sorting a List of Objects >> by an Attribute of the Objects" from the Python Cookbook. >> >> My first guess isn't working: >> >> import operator >> def sort_by_attr(seq, attr): >> key=operator.attrgetter(attr) >> key=str.lower >> return sorted(seq, key) >> >> ...would much appreciate any guidance! > > HiJason, > Try key= lambda x: x.attr.lower() > The above should calculate the key only once for the items to be > sorted rather than using cmp which calculates more than that. A key func is indeed preferable over cmp. Here is a working example: >>> import operator >>> class A(object): ... def __init__(self, name, value): ... self.name = name ... self.value = value ... def __repr__(self): ... return "%s|%s" % (self.name, self.value) ... >>> items = [A("a", "z"), A("C", "Y"), A("b", "x")] >>> items [a|z, C|Y, b|x] >>> def sorted_by_attr_icase(items, attrname): ... get = operator.attrgetter(attrname) ... return sorted(items, key=lambda item: get(item).lower()) ... >>> sorted_by_attr_icase(items, "name") [a|z, b|x, C|Y] >>> sorted_by_attr_icase(items, "value") [b|x, C|Y, a|z] Peter From tjreedy at udel.edu Thu Apr 3 17:24:25 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 3 Apr 2008 17:24:25 -0400 Subject: python bisect questions References: <6bb6927b-f553-40db-a142-2ce86b9e819f@q27g2000prf.googlegroups.com> Message-ID: wrote in message news:6bb6927b-f553-40db-a142-2ce86b9e819f at q27g2000prf.googlegroups.com... |I am week on functional programming, and having hard time | understanding this: | | class myPriorityQueue: | def __init__(self, f=lamda x:x): | self.A = [] | self.f = f | | def append(self, item) | bisect.insort(self.A, (self.f(item), item)) | ............ | | now I know we are inserting items(user defined type objects) in list A | base on sorting order provided by function A. | but what I don't understand is bisect command | what does bisect.insort(self.A, (self.f(item), item)) doing The snippet is missing 'import bisect'. The module is documented in the Lib Ref. Or, in the interpreter, help(bisect.insort) redirects you to help(bisect.insort_right), which will answer your question. | isn't it is returning truple of (self.f(item), item)). no, see doc | why it is not | biset.insort(self.A, item) | A.sort(f) Efficiency, given that self.A is already sorted. tjr From bruno.desthuilliers at gmail.com Sun Apr 20 14:54:56 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Sun, 20 Apr 2008 11:54:56 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: <23254d9a-ceca-453a-a984-4ce457ed12b2@59g2000hsb.googlegroups.com> On 20 avr, 17:35, Eric Wertman wrote: > I was considering putting together a proposal for an alternate block > syntax for python, and I figured I'd post it here and see what the > general reactions are. I did some searching, and while I found a lot > of tab vs space debates, I didn't see anything like what I'm thinking > of, so forgive me if this is a very dead horse. > > Generally speaking, I like the current block scheme just fine. I use > python on a daily basis for system administration and text parsing > tasks, and it works great for me. > > From time to time, though, I find myself needing a language for server- > side includes in web pages. Because of the need to indent (and > terminate indents), python seems an awkward choice for this, and it's > easy for me to see why php and perl are more popular choices for this > kind of task. Perhaps this is just my perception though. The server-page scheme has long shown it's limitations and quirks - mostly, you end up mixing application logic and presentation logic. Even PHP programmers are slowly taking the MVC route. > I feel that including some optional means to block code would be a big > step in getting wider adoption of the language in web development and > in general. I do understand though, that the current strict indenting > is part of the core of the language, so... thoughts? Python Server Page packages are nothing new, and didn't help making Python more popular for web developpement. MVC frameworks like Django, Pylons, Turbogears or web.py seems to draw way more attention, and we start to see PHP coders switching to Django - which is the one with the IMHO weakest templating language. If you're looking for a templating system with Python syntax support, you may want to take a look at Cheetah and (my favourite one) Mako. Mako is the default template system for Pylons, and IIRC web.py supports Cheetah (warning: never used web.py, and haven't followed recent dev, so you'd better check by yourself). HTH From johnjsal at gmailNOSPAM.com Mon Apr 21 21:45:53 2008 From: johnjsal at gmailNOSPAM.com (John Salerno) Date: Mon, 21 Apr 2008 21:45:53 -0400 Subject: Lists: why is this behavior different for index and slice assignments? Message-ID: <480d435b$0$11643$607ed4bc@cv.net> Hey all. I've decided I let my Python skills (minor though they were) slip away so I started reading the new edition of Learning Python to brush up. I just read about lists again and I'm wondering if someone could explain what's going on under the hood that makes index and slice assignments behave differently when assigning an empty list. For example: >>> L = [1, 2, 3, 4, 5] >>> L[0:2] = [] >>> L [3, 4, 5] >>> L = [1, 2, 3, 4, 5] >>> L[0] = [] >>> L [[], 2, 3, 4, 5] So the question is, when you assign an empty list to an index, why does it insert an empty list, but when you assign an empty list to a slice, it simply deletes the slice? Thanks! From nick at craig-wood.com Fri Apr 25 08:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Fri, 25 Apr 2008 07:30:03 -0500 Subject: function that accepts any amount of arguments? References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> Message-ID: Steve Holden wrote: > Ken wrote: > > "Steve Holden" wrote in message > [...] > >> def mean(*x): > >> total = 0.0 > >> for v in x: > >> total += v > >> return v/len(x) > >> > > > > think you want total/len(x) in return statement > > > Yes indeed, how glad I am I wrote "untested". I clearly wasn't pair > programming when I wrote this post ;-) Posting to comp.lang.python is pair programming with the entire internet ;-) -- Nick Craig-Wood -- http://www.craig-wood.com/nick From code at pizzashack.org Wed Apr 2 11:50:51 2008 From: code at pizzashack.org (Derek Martin) Date: Wed, 2 Apr 2008 11:50:51 -0400 Subject: Manipulate Large Binary Files In-Reply-To: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> Message-ID: <20080402155051.GB22737@dragontoe.org> On Wed, Apr 02, 2008 at 10:59:57AM -0400, Derek Tracy wrote: > I generated code that works wonderfully for files under 2Gb in size > but the majority of the files I am dealing with are over the 2Gb > limit > > ary = array.array('H', INPUT.read()) You're trying to read the file all at once. You need to break your reads up into smaller chunks, in a loop. You're essentially trying to store more data in memory than your OS can actually access in a single process... Something like this (off the top of my head, I may have overlooked some detail, but it should at least illustrate the idea): # read a meg at a time buffsize = 1048576 while true: buff = INPUT.read(buffsize) OUTPUT.write(buff) if len(buff) != buffsize: break -- Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0x81CFE75D -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available URL: From bruno.desthuilliers at gmail.com Thu Apr 24 15:12:06 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Thu, 24 Apr 2008 12:12:06 -0700 (PDT) Subject: function that accepts any amount of arguments? References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> <4810724a$0$23390$426a74cc@news.free.fr> <63ac69bf-9f6d-42bd-8e6e-5b3b17ec7c69@z72g2000hsb.googlegroups.com> Message-ID: On 24 avr, 14:28, malkarouri wrote: > On Apr 24, 12:43 pm, Bruno Desthuilliers wrote: > > [...] > > > Not quite sure what's the best thing to do in the second case - raise a > > ValueError if args is empty, or silently return 0.0 - but I'd tend to > > choose the first solution (Python's Zen, verses 9-11). > > What's wrong with raising ZeroDivisionError (not stopping the > exception in the first place)? Because - from a semantic POV - the real error is not that you're trying to divide zero by zero, but that you failed to pass any argument. FWIW, I'd personnaly write avg as taking a sequence - ie, not using varargs - in which case calling it without arguments would a TypeError (so BTW please s/Value/Type/ in my previous post). From rridge at caffeine.csclub.uwaterloo.ca Fri Apr 18 19:55:32 2008 From: rridge at caffeine.csclub.uwaterloo.ca (Ross Ridge) Date: Fri, 18 Apr 2008 19:55:32 -0400 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> Message-ID: George Sakkis wrote: >You'd better use a more precise timing method than finger counting, >such as timeit. Twice as fast is probably a gross overestimation; on >my box (Python 2.5, WinXP) avoiding unpack is around 10% and 40% >faster from Ross's and Grant's method, respectively: ... >def from3Bytes_ross(s): > return unpack(">l", s + "\0")[0] >> 8 If you have Python 2.5, here's a faster version: from struct import * unpack_i32be = Struct(">l").unpack def from3Bytes_ross2(s): return unpack_i32be(s + "\0")[0] >> 8 Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] rridge at csclub.uwaterloo.ca -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // From bruno.desthuilliers at gmail.com Wed Apr 2 15:33:43 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 12:33:43 -0700 (PDT) Subject: class / module introspection? References: <3c3f09df-08cb-4309-a870-6b12a813a8af@u36g2000prf.googlegroups.com> <0f14a289-55ef-49e5-b650-60f7aca371ad@i36g2000prf.googlegroups.com> Message-ID: <85761ed1-afe8-48cc-8c6d-73183e6692a9@i7g2000prf.googlegroups.com> On 2 avr, 21:07, Brian Munroe wrote: > On Apr 2, 11:04 am, "bruno.desthuilli... at gmail.com" > > wrote: > > > More seriously: the answer is in the doc.http://www.python.org/doc/2.3.5/lib/built-in-funcs.html > > > read about the __import__ function, experiment in your interactive > > python shell, and you should be done in a couple minutes. > > Well, If I understand the docs correctly, that would work great if > backends/ was a module and not a package? Not necessarily. > I need to keep backends/ > system1/ and backends/system2 as separate directory structures to make > things fairly isolated from each other (for neatness sake) > > Currently I'm building the backends/__init__.py __all__ list > dynamically, such as: > > backends/__init__.py > -------------------- > > import os > > __all__ = [] > > for module in os.listdir(__path__[0]): > if not module.startswith("__"): > __all__.append(module) Why not do the import here, so you store a real module instead of a name ? ie (not tested): for module_name in os.listdir(__path__[0]): if not module_name.startswith("__"): __all__.append(__import__(module_name, globals(), locals())) My 2 cents... From nigamreetesh84 at gmail.com Wed Apr 16 03:53:01 2008 From: nigamreetesh84 at gmail.com (reetesh nigam) Date: Wed, 16 Apr 2008 00:53:01 -0700 (PDT) Subject: how tirbo gears work? Message-ID: <53db8d68-23d4-4430-b7a8-49bca0ff4df7@i36g2000prf.googlegroups.com> hi everone, 1:- i want to know, how to turbo gears code works. 2:- i want to write code on html with the help of turbo gears From sjdevnull at yahoo.com Sat Apr 19 16:29:21 2008 From: sjdevnull at yahoo.com (sjdevnull at yahoo.com) Date: Sat, 19 Apr 2008 13:29:21 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <48074f58$0$4916$e4fe514c@dreader32.news.xs4all.nl> <6002cb46-f48a-421d-a4ff-5b23bf2f9d77@2g2000hsn.googlegroups.com> <39fd7905-4835-43bb-928b-82622ed628c1@m3g2000hsc.googlegroups.com> Message-ID: On Apr 18, 9:29 pm, sturlamolden wrote: > On 18 Apr, 21:28, "sjdevn... at yahoo.com" wrote: > > > Passing a NULL SectionHandle to NTCreateProcess/CreateProcessEx > > results in a fork-style copy-on-write duplicate of the current process. > > I know about NtCreateProcess and ZwCreateProcess, but they just create > an empty process - no context, no thread(s), no DLLs loaded, etc. > There is even an example code of how to implement fork() with > ZwCreateProcess in Nebbet's book on NT kernel internals, but > apparently it doesn't work quite well. It works fine for a copy-on-write process creation. It doesn't work 100% compatibly to fork. Nebbet is the best reference out there on the method. FWIW, NT's POSIX subsytem fork() uses (or used to use) the NULL SectionHandle method and was POSIX certified, so it's certainly possible. > Searching with Google, I find several claims that there is a > "CreateProcessEx" Yeah my bad, I meant zwCreateProcess. It's been almost a decade now since I used it. From sjmachin at lexicon.net Thu Apr 17 19:27:42 2008 From: sjmachin at lexicon.net (John Machin) Date: Thu, 17 Apr 2008 23:27:42 GMT Subject: py3k s***s In-Reply-To: <66q33cF2krjf2U1@mid.uni-berlin.de> References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <66q33cF2krjf2U1@mid.uni-berlin.de> Message-ID: <4807dceb$1@news.mel.dft.com.au> Diez B. Roggisch wrote: >> And I have been benefiting from Python in general, so far. Thanks, >> community. >> >> But now... I'll probably stop posting here for now, & I may stop other >> things too. >> >> Just my 2c. > > You know what I was just wondering about? All these C-written > cross-platform libraries (which Python users benefit from, most probably > including evven you) that run on different unixes & windows, which are a > much greater diversity to handle than the not-even-yet-settled > differences between Py3K & 2.x. How the heck do they do that? > > Oh, and these dreaded 64 bit processors, possibly with multi-cores, > which need changes in code as well, to be utilized to their power. > > But then, these guys most probably don't whine about diversity and > constant change, and cry out useless threats to people who probably > can't care less. > > Fare well, if you must. But getting mad over something which impact you > can't even judge right now is childish. Nothing else. > At the start of this thread I was pondering the possible meaning of the verb "to sverk". Thanks for the exposition, Diez. From stefan_ml at behnel.de Fri Apr 25 18:17:55 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sat, 26 Apr 2008 00:17:55 +0200 Subject: is there a python equivalent for this tool? In-Reply-To: References: Message-ID: <48125893.3000202@behnel.de> Jorge Vargas wrote: > Dear python users, do you know of a tool like this that is written in python? > > http://code.google.com/p/css-redundancy-checker/ > > in case you where wondering I just don't want to have the ruby > dependency on my python proyects. This comes to mind: http://code.google.com/p/cssutils/ Not sure if it does what you want, though. If not, it should be quite trivial to implement what you ask using this: http://codespeak.net/lxml/cssselect.html Algorithm: for each CSS selector in the stylesheet, check if it matches an element in the HTML tree. If not, remove it. Stefan From watches0759 at global-replica-watch.com Wed Apr 23 01:16:44 2008 From: watches0759 at global-replica-watch.com (watches0759 at global-replica-watch.com) Date: Tue, 22 Apr 2008 22:16:44 -0700 (PDT) Subject: Designer Louis Vuitton Taiga Computer Case Odessa - Green M30834 Green Handbags, Replica, Fake Message-ID: <55f924ca-60a8-422c-b56e-889964e53f2e@i76g2000hsf.googlegroups.com> Designer Louis Vuitton Taiga Computer Case Odessa - Green M30834 Green Handbags, Replica, Fake Our Louis Vuitton Taiga Computer Case Odessa - Green M30834 Green is a vibrant mix of style and pleasure, offering you exact copies of the original handbags. If you need a cool and most welcomed change to your style, a change you certainly deserve, choose one of the many bags ReplicasHandbag.com offers at a great price. Louis Vuitton Taiga Computer Case Odessa - Green Link : http://www.replicashandbag.com/Louis-Vuitton-M30834-Green.html Brand : Louis Vuitton ( http://www.replicashandbag.com/Louis-Vuitton-Handbags.html ) Model : M30834 Green Sale Price : $ 240.00 Louis Vuitton Taiga Computer Case Odessa - Green Details : Classical green color Louis Vuitton leather bagIt has adjustable green color strap with LV name on itWrap around silver color zipper closure Inside it has two strap to keep your things on holdAlso this bag comes with a small bag for your small thingsComes with serial numbers, authenticity card, dust bag, and care booklet SIZE: 14.5" x 12.2" x 2.8" You may find the most affordable Designer Louis Vuitton Handbags on our website replicashandbag.com while high quality can be guaranteed. Our Replica Louis Vuitton Bags is made with special care to reach the level of an original one. Here you will find luxury items are no longer something you ever hesitate going for. To meet your expectation, we only provide Louis Vuitton Fake Handbags that is perfectly imitated, featuring the slight details of originals. All of our replica handbags are shipped via EMS to worldwide. Normally it takes 3days to prepare the fake bags you ordered and 5-10days to transmit depending on the different destination.We pay for the free shipping cost for total quantity over 20 pcs. The EMS tracking NO. will be sent by email when an order is shipped from our warehouse. No more other charges from replicashandbag.com such as the tax. If you have any other questions please check our other pages or feel free to email us by sales at replicashandbag.com. The Same Replica Louis Vuitton Handbags Series : Louis Vuitton Taiga Dersou -Dark Coffee 30168coffee : http://www.replicashandbag.com/Louis-Vuitton-30168coffee.html Louis Vuitton Taiga Dimitri - Black 32462black : http://www.replicashandbag.com/Louis-Vuitton-32462black.html Louis Vuitton Taiga Dimitri - Black 30902black : http://www.replicashandbag.com/Louis-Vuitton-30902black.html Louis Vuitton Taiga Dimitri - Coffee M30918coffee : http://www.replicashandbag.com/Louis-Vuitton-M30918coffee.html Louis vuitton Taiga Dimitri -Coffee 32468coffee : http://www.replicashandbag.com/Louis-Vuitton-32468coffee.html Louis Vuitton Taiga Igor - Dark Coffee 92532coffee : http://www.replicashandbag.com/Louis-Vuitton-92532coffee.html Louis Vuitton Taiga Kasbek GM - Black 31012black : http://www.replicashandbag.com/Louis-Vuitton-31012black.html Louis vuitton Taiga Kasbek GM - Dark Purple 31012purple : http://www.replicashandbag.com/Louis-Vuitton-31012purple.html Louis Vuitton Taiga Kurgan Clutch - Black 30892black : http://www.replicashandbag.com/Louis-Vuitton-30892black.html Louis Vuitton Taiga Kurgan Clutch -Dark Purple 30892purple : http://www.replicashandbag.com/Louis-Vuitton-30892purple.html Designer Louis Vuitton Taiga Computer Case Odessa - Green M30834 Green Handbags, Replica, Fake From bruno.42.desthuilliers at websiteburo.invalid Mon Apr 28 09:26:20 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Mon, 28 Apr 2008 15:26:20 +0200 Subject: function that accepts any amount of arguments? In-Reply-To: References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> <4810724a$0$23390$426a74cc@news.free.fr> <63ac69bf-9f6d-42bd-8e6e-5b3b17ec7c69@z72g2000hsb.googlegroups.com> Message-ID: <4815d07b$0$5405$426a74cc@news.free.fr> Lie a ?crit : > On Apr 25, 2:12 am, "bruno.desthuilli... at gmail.com" > wrote: (...) >> FWIW, I'd personnaly write avg as taking a sequence - ie, >> not using varargs - in which case calling it without arguments would a >> TypeError (so BTW please s/Value/Type/ in my previous post). > > The problem with passing it as a sequence is, if you want to call it, > you may have to wrestle with this odd looking code: > avg((3, 4, 6, 7)) > > rather than this, more natural code: > avg(3, 4, 6, 7) Possibly. Yet my experience is that, most of the time, such a function will be called with an already existing sequence, so the most common call scheme is res = avg(some_sequence) which is more natural than res = avg(*some_sequence) !-) > And FWIW, the OP asked if it is possible to pass variable amount of > arguments, avg is just a mere example of one where it could be used > not where it could be best used. Indeed - but that's not what I was commenting on. From diresu at web.de Tue Apr 22 11:12:47 2008 From: diresu at web.de (Dietrich Bollmann) Date: Wed, 23 Apr 2008 00:12:47 +0900 Subject: Error in Extending/Embedding FAQ, point 16: How do I tell "incomplete input" from "invalid input"? Message-ID: <1208877167.4557.37.camel@pippi.pippi> Hi, Both code examples from paragraph 16 from the Python Extending / Embedding FAQ - 'How do I tell "incomplete input" from "invalid input"?' - ( http://www.python.org/doc/faq/extending/#how-do-i-tell-incomplete-input-from-invalid-input ) do not work with the current state of Python anymore. In the second code example, the error message returned by Python is checked in order to differentiate errors caused by an incomplete input from other syntax errors: if (PyArg_ParseTuple (val, "sO", &msg, &obj) && !strcmp (msg, "unexpected EOF while parsing")) /* E_EOF */ In the current Python version there are more error messages indicating an incomplete Python input and I could make the code work for a while by adding the following strings to the condition: /* error messages indicating an incomplete input */ if (PyArg_ParseTuple(error, "sO", &message, &obj) && (!strcmp(message, "unexpected EOF while parsing") || !strcmp(message, "expected an indented block") || !strcmp(message, "EOF while scanning triple-quoted string") ) ) { /* E_EOF */ but recently there are also cases which generate error messages which are too general to be added to this list. The following code for example: >>> eins = [1, ... 2, ... 3] >>> is accepted without any problem by the Python shell. When using the code from the FAQ and entering it line by line ?already the second line causes a simple "invalid syntax" error: >>> eins = [1, ... 2, File "", line 2 2, ^ SyntaxError: invalid syntax which is to general to be integrated into the list of tested error messages as it might be caused also by code like: >>> one two File "", line 1 one two ^ SyntaxError: invalid syntax which generates an "invalid syntax" error even in the Python shell. I also tried the first code example of paragraph '16 How do I tell "incomplete input" from "invalid input"?' of the FAQ in order to see if it could be used to make the difference between syntax errors and incomplete code errors. But - as in the case before - the returned error code is E_SYNTAX (14 = Syntax error) and not E_EOF (11 = End Of File) as should be expected. Is there anybody who has an idea how to differentiate the first case from the second in order to mimic the behaviour of the Python shell from c code? If this shouldn't be possible lists split into different lines couldn't be accepted anymore or the feature of the Python shell to described in paragraph 16 of the faq: Sometimes you want to emulate the Python interactive interpreter's behavior, where it gives you a continuation prompt when the input is incomplete (e.g. you typed the start of an "if" statement or you didn't close your parentheses or triple string quotes), but it gives you a syntax error message immediately when the input is invalid. would have to be given up and every entered line of code would have to be terminated by an empty line before evaluation :( Thanks for any help, Dietrich From marli305nugent at gmail.com Sat Apr 26 09:47:55 2008 From: marli305nugent at gmail.com (marli305nugent at gmail.com) Date: Sat, 26 Apr 2008 06:47:55 -0700 (PDT) Subject: area council patch news Message-ID: <124fc461-fe1e-4b0a-8c2b-23903f082bdb@56g2000hsm.googlegroups.com> area council patch news http://cracks.00bp.com F R E E C R A C K S From nagle at animats.com Wed Apr 23 17:40:07 2008 From: nagle at animats.com (John Nagle) Date: Wed, 23 Apr 2008 14:40:07 -0700 Subject: Java or C++? In-Reply-To: References: Message-ID: <480fa9f4$0$34576$742ec2ed@news.sonic.net> Bob Martin wrote: > in 342367 20080414 074410 s0suk3 at gmail.com wrote: >> Hello, I was hoping to get some opinions on a subject. I've been >> programming Python for almost two years now. Recently I learned Perl, >> but frankly I'm not very comfortable with it. Now I want to move on >> two (sic) either Java or C++, but I'm not sure which. Which one do you think >> is a softer transition for a Python programmer? Which one do you think >> will educate me the best? > > C++ is for masochists. Go for Java. Definitely Java. And I have ten years of C++ experience. C++ is the only major language that has hiding without safety. That was a mistake. Perl is useful because it runs everywhere; you'll be able to run your Perl program on just about any commercial web hosting service. Other than that, there's not much good to be said for it. Java is a generally good language fighting to get out from under a mountain of mediocre libraries. John Nagle From BrianVanderburg2 at aim.com Thu Apr 3 20:57:56 2008 From: BrianVanderburg2 at aim.com (Brian Vanderburg II) Date: Thu, 03 Apr 2008 20:57:56 -0400 Subject: Is there an official way to add methods to an instance? Message-ID: <47F57D14.8030206@aim.com> I don't know if this is the correct place to send this question. I've checked out some ways to get this to work. I want to be able to add a new function to an instance of an object. I've tested two different methods that cause problems with 'deleting'/garbage collection (__del__ may never get called), but implemented one sort of hackishly maybe that works find. I'm wondering if there is more of an official way than mine. 1. import new import gc class A: def __del__(x): print "Deleting" def f(x): print x a = A() a.f = new.instancemethod(a,f) a.f() # This works del a # Not what is expected gc.collect() # Works, but __del__ does not get called 2. import gc def addmethod(self,func,name): def wrapper(*args,**kwargs): return func(self,*args,**kwargs) setattr(self,name,func) class A: def __del__(x): print "Deleting" def f(x): print x a = A() addmethod(a, f, "f") a.f() # Works as expected del a # nope gc.collect() # Still __del__ doesn't get called 3. Slightly hackish method, maybe some problems import gc import weakref def addmethod(self,func,name): # change the value of 'self' so wrapper.func_globals will reference the new value self = weakref.ref(self) def wrapper(*args,**kwargs): return func(self(),*args,**kwargs) setattr(self(),name,func) class A: def __del__(x): print "Deleting" def f(x): print x a = A() addmethod(a, f, "f") a.f() # Works as expected del a gc.collect() With this method 'del a' does the expected most of the time, and "Deleting" does get printed or when calling 'gc.collect()' it prints correctly. This seems the best approach so that when 'a' is no longer valid, the object can die instead of continuing to exitng because wrapper.func_globals still contains a reference, but seems very hackish an maybe problematic. I'm wondering if there is a better way? Brian Vanderburg II From hv at tbz-pariv.de Thu Apr 24 07:20:29 2008 From: hv at tbz-pariv.de (Thomas Guettler) Date: Thu, 24 Apr 2008 13:20:29 +0200 Subject: How to get inner exception traceback Message-ID: <67b8nuF2m1a1kU1@mid.individual.net> Hi, How can you get the traceback of the inner exception? try: try: import does_not_exit except ImportError: raise Exception("something wrong") except: ... Background: In Django some exceptions are caught and a new exception gets raised. Unfortunately the real error is hard to find. Sometimes I help myself and change (in this example) ImportError to e.g. IOError and then I can see the real root of the problem. But maybe there is a way to get the inner exception and its traceback. This could be displayed in the debug view. Thomas -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de From pscott at uwc.ac.za Mon Apr 21 02:21:35 2008 From: pscott at uwc.ac.za (Paul Scott) Date: Mon, 21 Apr 2008 08:21:35 +0200 Subject: Is massive spam coming from me on python lists? In-Reply-To: <480C2DC6.4050701@aim.com> References: <480C2DC6.4050701@aim.com> Message-ID: <1208758895.14026.2.camel@paul-laptop> On Mon, 2008-04-21 at 02:01 -0400, Brian Vanderburg II wrote: > I've recently gotten more than too many spam messages and all say > Sender: python-list-bounces+my=email.address at python.org. I'm wondering > if my mail list registration is now being used to spam myself and > others. If so, sorry, but I'm not the one sending messages if other are > getting them even though Sender seems to include my address (I'm not > sure about mail headers so I don't know how From: is different than > Sender:) Anyway, it seems to be a bunch of spam emails about cracks and > stuff. I think all of the spam is coming from Google Groups. --Paul -------------- next part -------------- All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm From brian.e.munroe at gmail.com Wed Apr 2 15:07:46 2008 From: brian.e.munroe at gmail.com (Brian Munroe) Date: Wed, 2 Apr 2008 12:07:46 -0700 (PDT) Subject: class / module introspection? References: <3c3f09df-08cb-4309-a870-6b12a813a8af@u36g2000prf.googlegroups.com> Message-ID: <0f14a289-55ef-49e5-b650-60f7aca371ad@i36g2000prf.googlegroups.com> On Apr 2, 11:04 am, "bruno.desthuilli... at gmail.com" wrote: > > More seriously: the answer is in the doc.http://www.python.org/doc/2.3.5/lib/built-in-funcs.html > > read about the __import__ function, experiment in your interactive > python shell, and you should be done in a couple minutes. Well, If I understand the docs correctly, that would work great if backends/ was a module and not a package? I need to keep backends/ system1/ and backends/system2 as separate directory structures to make things fairly isolated from each other (for neatness sake) Currently I'm building the backends/__init__.py __all__ list dynamically, such as: backends/__init__.py -------------------- import os __all__ = [] for module in os.listdir(__path__[0]): if not module.startswith("__"): __all__.append(module) then from my main application, I can do the following main.py ------- import backends print backends.__all__ This gives me ['system1','system2'] - which I can then use __import__ on. -- brian From pyth0nc0d3r at gmail.com Wed Apr 9 07:43:52 2008 From: pyth0nc0d3r at gmail.com (Lamonte Harris) Date: Wed, 9 Apr 2008 06:43:52 -0500 Subject: ProxyHandler doesn't completly hide your identity? Message-ID: Is it still possible to detect who you are under a proxy when using urllib2? -------------- next part -------------- An HTML attachment was scrubbed... URL: From bj_666 at gmx.net Thu Apr 10 12:03:39 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 10 Apr 2008 16:03:39 GMT Subject: tkinter, overwrite Label-text? References: Message-ID: <666s2qF2il38sU1@mid.uni-berlin.de> On Thu, 10 Apr 2008 07:37:08 -0700, skanemupp wrote: > i know how to do this already. the problem is i want the text to stay > in the windowa nd not start overwriting "Answer:". Then don't use `place()` but let Tkinter handle the layout with the pack and/or grid layout manager. GUIs with `place()` are a bad idea because the GUI may look odd or is even unusable on other peoples computers with other screen resolutions, fonts, and font sizes. Ciao, Marc 'BlackJack' Rintsch From MartinRinehart at gmail.com Thu Apr 10 11:49:07 2008 From: MartinRinehart at gmail.com (MartinRinehart at gmail.com) Date: Thu, 10 Apr 2008 08:49:07 -0700 (PDT) Subject: Python conventions Message-ID: I assembled a good conventions set for Java. View it at http://www.martinrinehart.com/articles/code-conventions.html (is that better, Steve?) It followed a logical organization; it was built from four other extensive (if not well-organized) convention sets and it scrupulously avoided injecting my own biases. Where there were disagreements, they were noted and the opposing viewpoints explained. I'm appointing myself project secretary of a similar effort for Python, until we can find someone better qualified (Python experience pre-dating my late '07 start would be better qualified). The secretary's job is to ask questions and correctly record answers. First question: global (e.g., what language for comments) package module class methods data function statement expression variable Is this a good outer-level organization? For each topic, cover: documentation naming convention(s) format Second question: are the above the items we cover for each topic? Others? From wizzardx at gmail.com Wed Apr 30 14:10:19 2008 From: wizzardx at gmail.com (David) Date: Wed, 30 Apr 2008 20:10:19 +0200 Subject: Python -v import behavior In-Reply-To: <357b87b40804300942v371152b0u9dcc6d8b8d0a3b32@mail.gmail.com> References: <357b87b40804300942v371152b0u9dcc6d8b8d0a3b32@mail.gmail.com> Message-ID: <18c1e6480804301110o1aad3766jb7a286147920c258@mail.gmail.com> On Wed, Apr 30, 2008 at 6:42 PM, Sean Ryan wrote: > Hi all, > (A similar question was posted by a colleague, but did not appear to reach > comp.lang.python or this list). > > I am wondering if the -v option causes the python application to be more > tolerant to module import warnings and / or errors. > > The reason is that a module is failing to import correctly (generating an > ImportError exception). Examining this closer we re-ran the script using > the -v option. to find that "Unsatisfied symbol" errors we being displayed > during import (cx_Oracle 4.3.1, python 2.5.1, HP-UX 11, oracle 9.2). > However, the module is usable from the python prompt (when using -v) > displayed, i.e. dir (cx_Oracle) works correctly, as does database > interaction. Without the -v option the script is halted due to the > ImportError exception. > > My questions are: > 1. Is there a way to mimic the seemingly more tolerant import behavior of > python -v without producing the verbose output ? > 2. Is the behavior described above expected and documented ? > If -v makes a difference, it is most likely due to timing. The output to console slows down your app enough so that the ImportError doesn't get raised. Try piping output to a text file. Also experiment with the -u (unbuffered output) option. Another possibility is that the python binary that runs (when you launch with -v) is different to the one that the script normally runs with (see #! line at start of script). Also try adding the -v to the #! line instead of the command line. Something for you to try: Making a temporary copy of the project, and then cut out all the code except the import lines. See if that fails, then start commenting out imports until the error goes away. David. From bearophileHUGS at lycos.com Fri Apr 18 09:51:55 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Fri, 18 Apr 2008 06:51:55 -0700 (PDT) Subject: sampling without replacement References: <6017ea8d-6ee8-44ea-bdad-bf06299a9cd5@a23g2000hsc.googlegroups.com> Message-ID: <91f72a14-c344-4d69-93e0-083e4ec8c47b@f63g2000hsf.googlegroups.com> Alexy>But in Python it's very slow...< I'm the first one to say that CPython is slow, but almost any language is slow if you use such wrong algorithms like you do. There are many ways to solve your problem efficiently, one of such ways, among the simpler ones is to to not modify the original list: >>> from random import shuffle, seed >>> items = list("abcdefghijklm") >>> seed(10) >>> shuffle(items) >>> it_items = iter(items) >>> it_items.next() 'i' >>> it_items.next() 'd' >>> it_items.next() 'l' >>> it_items.next() 'b' >>> it_items.next() 'j' >>> it_items.next() 'a' >>> it_items.next() 'e' If you don't want to extract the same element twice across different runs of the program, then you may create a class like this: from random import shuffle, seed class Sampler(object): def __init__(self, items, init_seed=1): self.items = list(items) self.last = len(self.items) - 1 self.init_seed = init_seed seed(init_seed) shuffle(self.items) def __repr__(self): return repr(self.items[:self.last+1]) def next(self): if self.last < 0: raise StopIteration self.last -= 1 return self.items[self.last+1] def save(self, filename): pass # saves self.last and self.init_seed on disk samp = Sampler("abcdefghijklm") print samp print samp.next() print samp.next() print samp.next() That class code is raw, you may want to improve it in some ways. Bye, bearophile From kyosohma at gmail.com Sat Apr 26 23:42:56 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Sat, 26 Apr 2008 20:42:56 -0700 (PDT) Subject: Desktop notifications on Windows References: <0db266c1-50ad-4e01-b508-57c9a8febb4b@a22g2000hsc.googlegroups.com> <60516dea-2c40-47d2-b816-8d9169399d86@c58g2000hsc.googlegroups.com> Message-ID: <50466177-f999-4952-9123-57b9c3f9b6ec@f63g2000hsf.googlegroups.com> On Apr 26, 4:08?pm, WindPower wrote: > On Apr 26, 4:52 am, David wrote: > > > On Sat, Apr 26, 2008 at 4:41 AM, ? wrote: > > > I'm looking for a way to implement desktop notifications (much like an > > > ?instant messaging program or a mail notifier) within my Python > > > ?application, on Windows only (no Gtk/Galago, please). I need no more > > > ?than a simple text-based notification, which should be clickable and > > > ?have a timeout, nothing else. I do not want to use Windows's "balloon > > > ?tips", either. Any suggestions? > > > ?-- > > > You could use Tkinter, which comes with Python. > > The problem is that Tkinter cannot (I haven't looked at it in details, > so correct me if I'm wrong) create notifications the way I want them; > it can only create standard dialogs or top-level dialogs, both of > which steal the focus of other applications, while I want these > notifications not to interfere with anything (and possibly not be > displayed if an application is already running in fullscreen). wxPython can do this. They have a wx.PopupWindow that does this and comes with wxPython or you can use the more advanced custom Toasterbox widget that I found here: http://xoomer.alice.it/infinity77/main/freeware.html#toasterbox I've used both, but the latter gives more control of the "look & feel". Hope that helps! Mike From gnewsg at gmail.com Thu Apr 3 19:16:47 2008 From: gnewsg at gmail.com (Giampaolo Rodola') Date: Thu, 3 Apr 2008 16:16:47 -0700 (PDT) Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: On 2 Apr, 03:15, AK wrote: > Hello, > > I find that I learn easier when I go from specific examples to a more > general explanation of function's utility and I made a reference guide > that will eventually document all functions, classes and methods in > Python's Standard Library. For now, I covered about 20 most important > modules. I will be adding more modules and eventually I'll cover > everything. Here's my progress so far, let me know if this is useful; > I'll be glad to hear comments/suggestions/etc: > > http://www.lightbird.net/py-by-example/ > > -- > ? -ak > ? ?Tobu |http://www.lightbird.net/tobu/| Freeform DB / Tagger / PIM Great idea! Thanks a lot for you work. --- Giampaolo http://code.google.com/p/pyftpdlib From enleverlesX.XmcX at XmclaveauX.com Tue Apr 8 12:02:01 2008 From: enleverlesX.XmcX at XmclaveauX.com (Méta-MCI (MVP)) Date: Tue, 8 Apr 2008 18:02:01 +0200 Subject: List open files In-Reply-To: <47fb8d54$0$15068$426a74cc@news.free.fr> References: <47fb8d54$0$15068$426a74cc@news.free.fr> Message-ID: <47fb9789$0$881$ba4acef3@news.orange.fr> Salut ! Finalement, tu as obtenu plus de r?ponses sur le NG fran?ais. Comme quoi, la v?rit? n'est pas toujours ailleurs... @+ -- Michel Claveau From software at ginstrom.com Sun Apr 6 21:28:01 2008 From: software at ginstrom.com (Ryan Ginstrom) Date: Mon, 7 Apr 2008 10:28:01 +0900 Subject: ANN: pry unit testing framework In-Reply-To: <87prt2mq8l.fsf@benfinney.id.au> References: <87zlscx5lt.fsf@benfinney.id.au><4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com><20080405082605.GA14042@nullcube.com><20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> Message-ID: <1e1001c8984e$9ef29c30$0203a8c0@MOUSE> > On Behalf Of Ben Finney > Aldo Cortesi writes: > > Some day I might experiment with extending Pry to gather and run > > doctests and unittests. At this stage, however, I don't believe the > > (significant) effort would be worth it. > > That's very unfortunate. Until it plays better with others, I > don't believe the effort of using this package will be worth it. I also don't want to be negative, since Aldo obviously has put a lot of work into this framework. But since it's not compatible with other frameworks, it will mainly be attractive to people not writing unit tests now, which means they: 1) Think writing unit tests is too much of a hassle, or 2) Ae new (Python) programmers In either case, the key requirement of the framework would be ease of use, but Pry's selling point is actually its sophisticated options. Thus it appears that the potential user base is rather small... Regards, Ryan Ginstrom From steve at holdenweb.com Wed Apr 9 09:58:32 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 09:58:32 -0400 Subject: CPython VM & byte code resources wanted In-Reply-To: References: <6622srF2e32hbU1@mid.individual.net> <66238qF2h0kfqU1@mid.individual.net> Message-ID: <47FCCB88.8090203@holdenweb.com> Steve Holden wrote: > Aaron Gray wrote: >> "Aaron Gray" wrote in message >> news:6622srF2e32hbU1 at mid.individual.net... >>> Hi, >>> >>> I am looking to study the CPython source code, but I cannot seem to find >>> the VM code. >> Found it :) >> >> Python/ceval.c >> >>> Also is there any where a detailed list of the opcodes ? >> Still could do with an opcodes chart. >> > Be sure and post it on the Wiki when you finish it ;-) > I was being a little too flip here. If you look in the "dis" module I would imagine you will find what you seek, given that it's capable of disassembling the byte codes -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bob.martin at excite.com Tue Apr 15 03:40:04 2008 From: bob.martin at excite.com (Bob Martin) Date: Tue, 15 Apr 2008 07:40:04 GMT Subject: Java or C++? References: Message-ID: in 342436 20080414 160208 =?UTF-8?B?R3J6ZWdvcnogU8WCb2Rrb3dpY3o=?= wrote: >> Hello, I was hoping to get some opinions on a subject. I've been >> programming Python for almost two years now. Recently I learned Perl, >> but frankly I'm not very comfortable with it. Now I want to move on >> two either Java or C++, but I'm not sure which. Which one do you think >> is a softer transition for a Python programmer? Which one do you think >> will educate me the best? >> >I can't say from personal experience (it was C, C++, then Python for me) >but I think you'll find Java very annoying, especially if you value >Python for elegance. Both C++ and Java have different philosophy than >Python, but C++ is better designed and more flexible. You must be joking - better designed? C++ was a botch to an already poor language. Personally I find Java very satisfying to write. From wuwei23 at gmail.com Tue Apr 1 21:02:51 2008 From: wuwei23 at gmail.com (alex23) Date: Tue, 1 Apr 2008 18:02:51 -0700 (PDT) Subject: troll poll References: <65eee6F2eg18jU1@mid.uni-berlin.de> Message-ID: <143a9f24-668e-4e30-a803-c272da27f3ff@s13g2000prd.googlegroups.com> On Apr 1, 11:15 pm, George Sakkis wrote: > Wow, thanks to this thread I discovered the Google Groups KillFile, a > firefox+greasemonkey killfile script (http://www.penney.org/ > ggkiller.html). Hope it works as advertised! That is awesome, thank you so much for posting this. The usual response to complaining about the lack of a killfile for Google Groups has been "use a decent client", but as I'm constantly moving between machines having a consistent app for usenet has more value to me. I maintain castironpi is far more lucid than others give him credit for, if you understand that the sole concept he is trying to communicate is how damn "clever" he is. On the plus side, he does give me a test target for this greasemonkey script :) Cheers George! - alex23 From carbanancizpo at gmail.com Fri Apr 18 16:54:58 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:54:58 -0700 (PDT) Subject: unreal tounament patch 451 Message-ID: unreal tounament patch 451 http://cracks.12w.net F R E E C R A C K S From robin at nibor.org Mon Apr 14 11:27:17 2008 From: robin at nibor.org (Robin Stocker) Date: Mon, 14 Apr 2008 17:27:17 +0200 Subject: [ANN] PyStructure: Structure and Dependency Analyser for Python Projects Message-ID: <480377D5.6090409@nibor.org> Hi Python developers, We are happy to announce our first release of PyStructure, a structure and dependency analyser for Python code (written in Java). It is now in a state where it can parse and analyse real-world projects (with limitations, see below) and show the results in Structure101g, a dependency visualiser. To try it out with your projects, download pystructure.zip from the following address and follow the instructions in the README file: http://pystructure.ifs.hsr.ch/release/ We are two students working on this as our bachelor thesis. The project page can be found at: http://pystructure.ifs.hsr.ch/ We are very eager to hear your feedback about our project. What do you think about the idea of a 'structural analyser' for a dynamic language like Python? Does it work for your project (probably not very well at the moment)? Cheers, Reto Sch?ttel Robin Stocker About PyStructure ----------------- Our project's goal is to develop a structural analyser for programs written in the Python programming language. The analyser should be able to parse an application's source code, analyse it and then generate a graph representing the internal structure of the project. As Python is a dynamic language most of the interesting details (i.e. type) are not known before the application is running. The analyser has to 'guess' the correct type by analysing the code base. The project is licensed under the LGPL (v2 or later), see the COPYING file. Current Limitations ------------------- Although the engine already supports a wide variety of cases it still lacks some very important features: - No support for inheritance Currently the engine ignores everything that involves inheritance. For example if a method is implemented in a base class it won't be found if it was called on an instance of a sub class. - Type of list/dict elements is not known The type of container elements cannot be determined yet. For projects which heavily rely on lists this means that a lot of types can't be determined. - Only little support for built-ins Only a few built-in operations are recognised. For example the type inference engine doesn't yet know that len("str") returns an integer. We are working on tackling these issues in the next two milestones and we hope to improve the accuracy of the engine significantly. Possible Applications --------------------- Our library (especially the type inferencer we use) might be interesting for other applications. For example: - Code completion and navigation in IDEs And it might improve the accuracy of tools which: - Detect unused/dead code - Look for possible bugs in code (like FindBugs for Java) - Do type checks and optimisations at compile time References ---------- - DDP: Demand-Driven Analysis with Goal Pruning by Lex Spoon http://www.lexspoon.org/ti/ - Headway Software http://www.headwaysoftware.com/ From tjreedy at udel.edu Mon Apr 14 00:04:14 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 14 Apr 2008 00:04:14 -0400 Subject: about the ';' References: <20080414033334.97C8B8C461@mail-in-12.arcor-online.net> Message-ID: "Penny Y." wrote in message news:20080414033334.97C8B8C461 at mail-in-12.arcor-online.net... |I saw many python programmers add a ';' at the end of each line. | As good style, should or should not we do coding with that? NOOOOOO....... Read PEP8 for one style guide (for new stdlib code). From steve at holdenweb.com Sat Apr 5 08:40:40 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 08:40:40 -0400 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> Message-ID: llothar wrote: > On 5 Apr., 15:48, Fredrik Lundh wrote: >> llothar wrote: >>> My question was: Why does setup.py generated sometimes a pyd and >>> sometimes a so file? >> setup.py picks an extension that happens to work on the platform you're >> running setup.py on. doing otherwise would be pretty pointless. >> >> > > Unfortunately as pointless as the answers i got so far. > Right, so you think people aren't trying to help you? Put your paranoia back in your pocket :-) > > Okay i try it one more time: > > I ship an application that compiles an python interpreter and > extension on a remote system. > It also needs to copy this created items around. So if i use setup.py > to create an > extension i need to know the file name of the generated file. > > Damned this is trivial and a fundamental question and it is not > documented anywhere. > > I have a clue at the moment that it might be ".so" when python is > compiled without shared library > and ".pyd" otherwise (configure option --enable-shared) . But this is > just a guess. Does anybody know? > > And by the way: I think this is a bug and should be fixed. If the > platform does allow renaming the > extension of a DLL (does HP/UX allow this?) it should always be > ".pyd" You display your ignorance here. The ".pyd" extension is used on Windows as an alternative to ".dll", but both are recognized as shared libraries. Personally I'm not really sure why they even chose to use ".pyd", which is confusing to most Windows users. In UNIX/Linux environments ".so" is the standard extension for a shared library. To depart from the platform standard would be unhelpful and confusing to the majority of users. It's know use telling us what you think: tell us instead the compelling reasons why your opinion is correct. Opinions, after all, are so cheap that everyone can have one. There are ways to build distributions of Python extensions (modules or packages involving binary code from languages like C or C++), but you will want to understand a bit more about computing in general (and work on your social skills ;-) before you start to approach them. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From namesagame-usenet at yahoo.com Tue Apr 1 18:11:37 2008 From: namesagame-usenet at yahoo.com (gamename) Date: Tue, 1 Apr 2008 15:11:37 -0700 (PDT) Subject: Not Sure This Can Be Done... References: <46aeae28-4470-4136-a5f6-040f6468eb32@b5g2000pri.googlegroups.com> <65fmclF2f352gU1@mid.uni-berlin.de> Message-ID: <13777863-548e-4318-9b03-d64ccc3eebea@d21g2000prf.googlegroups.com> > Use virtualenv to create a local python, and activate that when > developing for that branch. Thanks for the suggestion, but that's the problem: having to activate it. Isn't there some way to simply have the local script look at a specified dir rather than starting a virtual environment? -T From donn at u.washington.edu Fri Apr 25 12:10:31 2008 From: donn at u.washington.edu (Donn Cave) Date: Fri, 25 Apr 2008 09:10:31 -0700 Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> <48118719$0$25846$9b622d9e@news.freenet.de> Message-ID: In article <48118719$0$25846$9b622d9e at news.freenet.de>, "Martin v. L?wis" wrote: > > I still think it's a shame > [...] > > pps: I have to note that it would be nice if the > > ad-hominem (sp?) invective would drop out of > > these threads -- it doesn't add a lot, I think. > > shame > 1 a. a painful emotion caused by consciousness of guilt, > shortcoming, or impropriety > 2 a condition of humiliating disgrace or disrepute - [in sing.] a regrettable or unfortunate situation or action: `it is a shame that they are not better known' If English isn't your 1st language, you deserve a lot of credit for your mastery of it, but you need a better dictionary. Donn Cave, donn at u.washington.edu From benash at gmail.com Sat Apr 26 17:23:39 2008 From: benash at gmail.com (Benjamin) Date: Sat, 26 Apr 2008 14:23:39 -0700 (PDT) Subject: Parsing HTML? References: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> <29bcc6bc-ab2e-4ba6-a7b3-aa1f1e850ea1@y21g2000hsf.googlegroups.com> Message-ID: On Apr 3, 9:10?pm, 7stud wrote: > On Apr 3, 12:39?am, ben... at gmail.com wrote: > > > BeautifulSoup does what I need it to. ?Though, I was hoping to find > > something that would let me work with the DOM the way JavaScript can > > work with web browsers' implementations of the DOM. ?Specifically, I'd > > like to be able to access the innerHTML element of a DOM element. > > Python's built-in HTMLParser is SAX-based, so I don't want to use > > that, and the minidom doesn't appear to implement this part of the > > DOM. > > innerHTML has never been part of the DOM. ?It is however a defacto > browser standard. ?That's probably why you aren't having any luck > using a python module that implements the DOM. That makes sense. From gnewsg at gmail.com Wed Apr 30 10:20:15 2008 From: gnewsg at gmail.com (Giampaolo Rodola') Date: Wed, 30 Apr 2008 07:20:15 -0700 (PDT) Subject: List all files using FTP References: Message-ID: <2762d539-c3c6-4930-8776-ae0943faec78@24g2000hsh.googlegroups.com> On 6 Mar, 18:46, Anders Eriksson wrote: > Hello, > > I need to list all the files on myFTPaccount (multiple subdirectories). I > don't have shell access to the account. > > anyone that has a program that will do this? > > // Anders > -- > English is not my first, or second, language > so anything strange, or insulting, is due to > the translation. > Please correct me so I may improve my English! If you mean listing ALL files including those contained in sub directories if the server supports globbing you can issue a "STAT *" command and receive the list of all files on the command channel in an "ls -lR *"-like form. Not tested: >>> import ftplib >>> f = ftplib.FTP() >>> f.connect('ftpserver.domain', 21) >>> f.login() >>> f.sendcmd('STAT *') an "ls -lR *" is expected to come From jon+usenet at unequivocal.co.uk Sun Apr 27 08:18:00 2008 From: jon+usenet at unequivocal.co.uk (Jon Ribbens) Date: Sun, 27 Apr 2008 07:18:00 -0500 Subject: Why can't timedeltas be divided? References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> <48142747$0$20906$9b622d9e@news.freenet.de> Message-ID: On 2008-04-27, Martin v. L?wis wrote: >> Last time I brought up this sort of thing, it seemed fairly unanimous >> that the shortcomings of the datetime module were 'deliberate' and >> would not be fixed, patch or no patch. > > Ok, so then if the answer to my question is "yes", the first step > should be to discuss it on python-dev. Yes, that's where it was decided that the datetime module was fine that way it is and must not be changed. From eedmit at NO.eed.SPAM.ericsson.PLS.se Fri Apr 18 13:17:39 2008 From: eedmit at NO.eed.SPAM.ericsson.PLS.se (Michael Tosch) Date: Fri, 18 Apr 2008 19:17:39 +0200 Subject: get quote enclosed field in a line In-Reply-To: References: Message-ID: xahlee at gmail.com wrote: > is there a simple way in perl, python, or awk/shell/pipe, that gets > the user agent field in a apache log? > > e.g. the typical line is like this: > > 189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET / > Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org > "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/ > 5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311 > Firefox/2.0.0.13" "-" > > I want the part: "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv: > 1.8.1.13) Gecko/20080311 Firefox/2.0.0.13". > > Thanks. > > Xah > xah at xahlee.org > ? http://xahlee.org/ > > ? awk -F\" '{print $6}' httpd-access.log awk -F\" 'NF>6{print $6}' httpd-access.log -- Michael Tosch @ hp : com From __peter__ at web.de Sat Apr 19 02:55:58 2008 From: __peter__ at web.de (Peter Otten) Date: Sat, 19 Apr 2008 08:55:58 +0200 Subject: Inheritance confusion References: <4809932c$0$12307$c3e8da3@news.astraweb.com> Message-ID: Hook wrote: > When I run the script I get this: > > Traceback (most recent call last): > File "./3.py", line 20, in > Obj.Connect ('Database') > File "/mnt/isis/Projects/Python/Learning/DB_m.py", line 102, in Connect > self.TRACE ("DB::Connect (" + database + "," + mode) > File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 314, in TRACE > self.DailyLog (msg) > File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 98, in > DailyLog > dt = self.Date (time ()) > TypeError: 'module' object is not callable > > > Googling the "TypeError" message suggests that I've got a module and > class with the same name, but I can't see that I have. > > Can someone point me in the right direction please? Read the traceback ;) Here's a hint: >>> import time >>> time() Traceback (most recent call last): File "", line 1, in TypeError: 'module' object is not callable >>> time.time() 1208588011.7017989 Peter From gkrill at gmail.com Fri Apr 11 10:07:21 2008 From: gkrill at gmail.com (greg_kr) Date: Fri, 11 Apr 2008 07:07:21 -0700 (PDT) Subject: Graphs in Python References: Message-ID: You should use Python with R. Google for Rpy, this is the best Graphing you can do with Python On Apr 11, 7:40?am, Philipp Pagel wrote: > Sanhita Mallick wrote: > > I have looked at that, and other similar ones all of > > which are based on Graphviz. > > Networkx is not based on graphviz. > > > > > My problem is that I myself am creating some large graphs > [...] > > So I would like to use a graphical/visual method than typing out the > > nodes. > > Not sure what exactly you mean. you will have to enter the nodes somehow > - afterwards you can visualize them. > > Do you mean you would like to have a GUI for entering nodes and edges? > I see two options: (1) write a GUI to do that (2) use an existing graph > editor and use networkx or something like that for analysis. > > > Also, I am looking for a good tutorial for basic graph > > implementation other than the one on python.org. > > ?- Look at the source code for networkx. > ?- Alternatively, basic graph algorithms can be found in many general > ? ?algorithm books. ? > ?- More specific stuff e.g. in A. Gibbons "Algorithmic Graph Theory". > > cu > ? ? ? ? Philipp > > -- > Dr. Philipp Pagel > Lehrstuhl f. Genomorientierte Bioinformatik > Technische Universit?t M?nchenhttp://mips.gsf.de/staff/pagel From danb_83 at yahoo.com Sat Apr 26 00:33:03 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Fri, 25 Apr 2008 21:33:03 -0700 (PDT) Subject: Is 2006 too old for a book on Python? References: Message-ID: On Apr 25, 8:16 am, jmDesktop wrote: > Hi, I wanted to buy a book on Python, but am concerned that some of > them are too old. One I had come to after much research was Core > Python by Wesley Chun. I looked at many others, but actually saw this > one in the store and liked it. However, it is from 2006. I know > there is free documentation and Dive Into Python. I just liked the > one in question and was hoping for thoughts on the age of it. I am > using Python 2.5.x and don' t know how different 2.3, 2,4 is from it. The changes are relatively minor. And having learned Python 2.3, you can simply refer to: What's New in Python 2.4: http://www.python.org/doc/2.4.3/whatsnew/whatsnew24.html What's New in Python 2.5: http://docs.python.org/whatsnew/whatsnew25.html From wwzaygvm at gmail.com Wed Apr 16 17:01:03 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 14:01:03 -0700 (PDT) Subject: partition manager 8.5 keygen Message-ID: partition manager 8.5 keygen http://cracks.12w.net F R E E C R A C K S From nick at stinemates.org Fri Apr 18 14:47:23 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 11:47:23 -0700 Subject: Brand New! In-Reply-To: <1208324917.7339.10.camel@paul-laptop> References: <7f1828bf-ebe7-4111-bc59-70d125facb0a@d26g2000prg.googlegroups.com> <1208324917.7339.10.camel@paul-laptop> Message-ID: <20080418184723.GF19281@deviL> On Wed, Apr 16, 2008 at 07:48:37AM +0200, Paul Scott wrote: > > On Wed, 2008-04-16 at 02:35 -0300, Gabriel Genellina wrote: > > I'm unsure if teaching Javascript, VBScript and Python at the same time is > > a good thing, I'd think one would get a language soup and mix all the > > concepts, but if it works for you, go ahead. > > For other resources, see the beginners section in the Python wiki: > > http://wiki.python.org/moin/BeginnersGuide > > Well, as an example, I learnt Python to a decent level of competency in > 2 days. I looked through the Dive into Python tuts, and then had a look > at the Python GUI FAQ (Which didn't really help much, as I started with > a GTK based GUI app). A little bit of Googling and a couple of questions > to this list gave me everything that I needed to roll out a pretty > decent application in 5 days. Oh, and just by the way, I am _not_ a > Computer Scientist or anything, I am a botanist, which means that if I > can do that, just about anyone that can read can do it. > > Python has been long on my list of TODO's, and now, finally, it is > there. I have immensely enjoyed it so far, and will continue to tinker > well into the future. > > --Paul > I think that's wonderful! I think problem solving language independent. As long as you can break down what you need to do and conceptualize. You must have learned to do with with botany, so programming came natural :) -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From Simon.Strobl at gmail.com Wed Apr 23 07:16:55 2008 From: Simon.Strobl at gmail.com (Simon Strobl) Date: Wed, 23 Apr 2008 04:16:55 -0700 (PDT) Subject: problem with dictionaries Message-ID: Hello, the idea of the following program is to parse a frequency list of the form FREQUENCY|WORD, to store the frequency of a word in a dictionary (and to do some things with this information later). I have done this many many times. Suddenly, it does not work any more: The value frq[key] is different from the value that key has in the file 'my_frqlist.txt'. I am using Python 2.5.1 Any hints? Simon ================================================ #!/usr/bin/python import sys frqlist = open('my_frqlist.txt', 'r') # my_frqlist looks like this: # 787560608|the # 434879575|of # 413442185|and # 395209748|to # 284833918|a # 249111541|in # 169988976|is frq = {} for line in frqlist: line = line.rstrip() frequency, word = line.split('|') frq[word] = int(frequency) for key in frq.keys(): print key, frq[key] From bj_666 at gmx.net Tue Apr 1 13:42:49 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 1 Apr 2008 17:42:49 GMT Subject: Homework help References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> Message-ID: <65fagoF2fiivoU1@mid.uni-berlin.de> On Tue, 01 Apr 2008 09:11:12 -0700, bobby.connor wrote: > # (2 Points) Write a python function howMany(item,lst) which accepts > an item and a lst of items and returns the number of times item occurs > in lst. For example, howMany(3,[1,2,3,2,3]) should return 2. Study the methods on lists. > # (2 Points) Write a python function upTo(n) which accepts a non- > negative number n and returns a list of numbers from 0 to n. For > example, upTo(3) should return the list [0, 1, 2, 3]. Study the built in functions. I don't know if it is considered cheating but you can get away with binding an existing one to the new name. > # (2 Points) Write a python function dotProduct(a,b) which accepts two > lists of integers a and b that are of equal length and which returns > the dot product of a and b. I.e., the sum a0 * b0 + ... + an-1 * bn-1 > where n is the length of the lists. For example: > > dotProduct([1,2,3],[4,5,6]) is 1*4 + 2*5 + 3*6 = 4 + 10 + 18 = 32 Again study the built in functions. Here the function from the `zip()` exercise below might be handy. > # (2 Points) A pair (exp0, exp1) is a combination of expressions that > are attached together by their joint membership in the pair. For > example: > >>>> (1+2, 'This') > (3, 'This') > > A component of a pair can be obtained using an index in brackets as > with lists (and strings!). For example: > >>>> (33,44)[0] > 33 And the exercise to solve is!? Study the built in data types. > Write a function zip(lst1, lst2) such that zip accepts two equal > length lists and returns a list of pairs. For example, zip(['a', 'b', > 'c'], [10, 20, 30]) should evaluate to the list [('a', 10), ('b', 20), > ('c', 30)]. Hey not even a rebinding necessary. :-) Ciao, Marc 'BlackJack' Rintsch From hniksic at xemacs.org Thu Apr 24 06:34:00 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Thu, 24 Apr 2008 12:34:00 +0200 Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <480D71B9.40909@v.loewis.de> <87lk36e6po.fsf@mulj.homelinux.net> <480e2c97$0$24477$9b622d9e@news.freenet.de> Message-ID: <87iqy7bkyv.fsf@mulj.homelinux.net> "Martin v. L?wis" writes: >>>> In py3k string%dictionary is going away. >>> Why do you say that? It's not going away in Python 3.0. >> >> I also got the impression that it was going away. PEP 3101's abstract >> says: >> >> This PEP proposes a new system for built-in string formatting >> operations, intended as a replacement [sic] for the existing '%' >> string formatting operator. >> >> Under "Backward compatibility" it says that both systems can coexist >> "until it comes time to deprecate the older system". > > The PEP may say that it's going away, but it doesn't say that it > goes away in 3.0 - and indeed, it won't. Thanks for clarifying it. It is certainly unclear from the wording of the PEP, given that 3.0 is regarded as the Python version allowed to break backward compatibility. > At some point in the future, somebody will likely propose that the > PEP will be executed. At that time, huge flame wars will start. I > expect that they settle in changing the PEP to explain that the old > mechanism gets removed in Python 4, to be release in 2018 :-) Indeed. From floris.bruynooghe at gmail.com Fri Apr 11 08:07:40 2008 From: floris.bruynooghe at gmail.com (Floris Bruynooghe) Date: Fri, 11 Apr 2008 05:07:40 -0700 (PDT) Subject: @x.setter property implementation References: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> <02cb2845-6a25-4e90-9f82-dbd68b37a5e6@p39g2000prm.googlegroups.com> <2c589c82-85e9-4db6-b8f9-156b06dd51f3@s33g2000pri.googlegroups.com> <3238aeb7-cd1b-463d-ad87-0d28dcee0202@a1g2000hsb.googlegroups.com> <41ba2942-3462-4882-9f56-18139c1f916b@x41g2000hsb.googlegroups.com> Message-ID: Oh, that was a good hint! See inline On Apr 11, 12:02 pm, Arnaud Delobelle wrote: > On Apr 11, 11:19 am, Floris Bruynooghe > wrote: > [...] > > > > Unfortunatly both this one and the one I posted before work when I try > > > them out on the commandline but both fail when I try to use them in a > > > module. And I just can't figure out why. > > > This in more detail: Imaging mod.py: > > > import sys > > > _property = property > > > class property(property): > > """Python 2.6/3.0 style property""" > > def setter(self, fset): > > cls_ns = sys._getframe(1).f_locals > > for k, v in cls_ns.iteritems(): > > if v == self: > > propname = k > > break > > cls_ns[propname] = property(self.fget, fset, > > self.fdel, self.__doc__) > > return fset return cls_ns[propname] And then it works as I tried originally! > > class Foo(object): > > @property > > def x(self): > > return self._x > > > @x.setter > > def x(self, v): > > ^^^^^ > Don't call this 'x', it will override the property, change it to > 'setx' and everything will work. The same probably goes for your own > 'propset' decorator function. > > > self._x = v + 1 > > > Now enter the interpreter: > > >> import mod > > >>> f = mod.Foo() > > >>> f.x = 4 > > >>> f.x > > > 4 > > > I don't feel like giving up on this now, so close... > > -- > Arnaud From Lie.1296 at gmail.com Sun Apr 13 04:18:24 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 13 Apr 2008 01:18:24 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> <01db54ab-1fca-4a51-8b98-510de224f40a@y21g2000hsf.googlegroups.com> Message-ID: <8e6dbc15-98f2-441d-bba4-d9ddb36f482d@i36g2000prf.googlegroups.com> On Apr 12, 3:44 am, hdante wrote: (snip) > > In this table, we consider that a number is rounded down when the > > But then, the "Round up" table gives inconsistent results if, by the > same argument, we consider 2.0 -> 2 rounding up. (you get 12 round ups > and 8 round downs just by "rethinking" the argument). So, "rounding > up" is, at the same time, better and worse than rounding to nearest > even. > It's not round up, why? In the usual sense -- when not comparing against round-half-even -- the number range we're talking is from x to lim((x+1)-y)[y -> 0 from the positive side], e.g. 1 to nearly 2 (thus the integer 2 itself is not included in the number range we're talking since it belongs to the next set), then we choose a uniformly distributed samples, i.e. 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, and 1.9. From these samples, we chose which are rounded down and which are rounded up, it happens that 1.0 is rounded down, while 1.5 is rounded up. IF for the sake of argument, you choose the number range to be lim(x + y)[y -> 0 from the positive side] to x + 1, e.g. barely above 1 to 2, then the number sample you use is 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, and 2.0, in this second number range, there are 5 round downs (1.1, 1.2, 1.3, 1.4, 1.5) and 5 round ups (1.6, 1.7, 1.8, 1.9, 2.0), but how logical is it to choose this number range (barely above 1 to 2) against choosing the more natural range (1 to nearly 2): in the correctly chosen number range (1 to nearly 2) all numbers in the form of 1.x (where x is any positive number and 0) is contained within it and there is nothing else in it, but in the second number range (barely above 1 to 2) the number 1.0 is not included while the number 2.0 is contained in it, clearly not a clean separation of numbers in the form of y.x where y is pre-determined and x is variable from other possible values of y. In short, choosing that x.0 is rounded down and x.5 is rounded up is arbitrary but not without a reason. From mnordhoff at mattnordhoff.com Tue Apr 8 00:11:10 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Tue, 08 Apr 2008 04:11:10 +0000 Subject: Newbie: How to pass a dictionary to a function? In-Reply-To: <516e07d1-91f9-462b-9fc0-ac6d1e474f9d@n14g2000pri.googlegroups.com> References: <516e07d1-91f9-462b-9fc0-ac6d1e474f9d@n14g2000pri.googlegroups.com> Message-ID: <47FAF05E.3070901@mattnordhoff.com> BonusOnus wrote: > How do I pass a dictionary to a function as an argument? > > > # Say I have a function foo... > def foo (arg=[]): > x = arg['name'] > y = arg['len'] > > s = len (x) > > t = s + y > > return (s, t) I assume you actually indented the body of the function? > # The dictionary: > > dict = {} > dict['name'] = 'Joe Shmoe' > dict['len'] = 44 'dict' is the name of a built-in type. You should name your variable something else. > # I try to pass the dictionary as an argument to a > # function > > len, string = foo (dict) 'len' is the name of a built-in function and 'string' is a module in the standard library. You should name both of them something else. > # This bombs with 'TypeError: unpack non-sequence' > > What am I doing wrong with the dictionary? It would be helpful to provide the full traceback, since that says what line the problem is on... HTH (it probably won't) -- From steve at holdenweb.com Tue Apr 1 19:10:00 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 01 Apr 2008 19:10:00 -0400 Subject: class super method In-Reply-To: References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> <0eb3ee4e-82e2-419a-8e7b-4931f7b4effa@c26g2000prf.googlegroups.com> Message-ID: Steve Holden wrote: > George Sakkis wrote: >> On Mar 31, 10:41 pm, Ed Leafe wrote: [...] >> In a sentence, it's better than nothing but worse than anything. >> > So you are prepared to write off the voice of experience because some > random web pages contradict what Ed is saying? > > As Ed rightly points out, any sufficiently complex gun can end up > shooting you in the foot. > Lest my remarks should be thought disrespectful to Michele Simionato, I should point out that I am familiar with those comments, and they do correctly identify problems with super() which are in fact fundamental to any multiple inheritance scheme. So it was a little rude of me to refer to "some random web pages" there, and I apologize. Ed is a good enough designer to avoid the corner cases. Strangely enough the one place where I have ended up making significant use of super() was in providing mixins for wxPython interface classes! regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From jeremy.wagner at laposte.net Tue Apr 22 12:50:54 2008 From: jeremy.wagner at laposte.net (=?ISO-8859-1?Q?J=E9r=E9my_Wagner?=) Date: Tue, 22 Apr 2008 18:50:54 +0200 Subject: Python Success stories In-Reply-To: <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> Message-ID: <480e176c$0$884$ba4acef3@news.orange.fr> Sure. Python is more readable than Perl, though I have found Python to have a weird behavior regarding this little issue : How can you explain that Python doesn't support the ++ opeator, whereas at the same time it does support the += operator ??? No python developer I know has been able to answer that. Istvan Albert a ?crit : > On Apr 22, 6:25 am, azrael wrote: > >> A friend of mine i a proud PERL developer which always keeps making >> jokes on python's cost. > >> This hurts. Please give me informations about realy famous >> aplications. > > you could show him what Master Yoda said when he compared Python to > Perl > > http://www.personal.psu.edu/iua1/pythonvsperl.htm > > i. From suzhi18 at googlemail.com Wed Apr 9 03:14:30 2008 From: suzhi18 at googlemail.com (suzhi18 at googlemail.com) Date: Wed, 9 Apr 2008 00:14:30 -0700 (PDT) Subject: makepy.py not working References: <03e9c33d-d957-4bc0-8568-3a40403eadb9@a70g2000hsh.googlegroups.com> Message-ID: <74c6f30e-9e79-4ce4-94fd-cde5e7fcc52e@m44g2000hsc.googlegroups.com> Ok, thanks for your help. After looking into the makepy.py file it was clear that this is only a command for the CMD console. I want to write a function which generates this .py file of the excel objects. I will now send the command to the CMD threw my python code. thanks again. suzhi From billingspanshism at gmail.com Sat Apr 19 17:18:04 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:18:04 -0700 (PDT) Subject: victoria beckham gallery Message-ID: <63e7e2ff-f5a1-4ead-b6b7-d4b9a2569a47@a23g2000hsc.googlegroups.com> Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From skip at pobox.com Fri Apr 11 14:28:08 2008 From: skip at pobox.com (Skip Montanaro) Date: Fri, 11 Apr 2008 18:28:08 +0000 (UTC) Subject: Multiple independent Python interpreters in a C/C++ program? References: <18431.37057.886339.853171@montanaro-dyndns-org.local> Message-ID: > Hi,You will only have one the different static Python variables, > so this is not possible. Thanks, that's pretty much what I expected... Skip From meisnernel73884 at gmail.com Wed Apr 30 06:39:12 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:39:12 -0700 (PDT) Subject: fifa manager 08 crack Message-ID: <9cd7fd65-2d46-4896-b57c-df71b28e34d8@d45g2000hsc.googlegroups.com> fifa manager 08 crack http://crack.cracksofts.com From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 4 08:06:36 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 04 Apr 2008 14:06:36 +0200 Subject: Python in High School In-Reply-To: <902504ff-410f-4cfc-b76b-89535b5276cc@2g2000hsn.googlegroups.com> References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <902504ff-410f-4cfc-b76b-89535b5276cc@2g2000hsn.googlegroups.com> Message-ID: <47f619c5$0$19004$426a74cc@news.free.fr> marion at everautumn.com a ?crit : (snip) > I think I agree with all of the positive, supporting posts about > Python. I would just like to add that Python (and PyGame) are open > source And run on most common platforms AFAIK. > and so your students can download it at home and have fun > exploring it on their own time (at their own pace). I think that is a > real positive. Indeed. From jnormoyle at iel.ie Tue Apr 29 12:28:08 2008 From: jnormoyle at iel.ie (John Normoyle) Date: Tue, 29 Apr 2008 17:28:08 +0100 Subject: Import fails with python but succeeds with python -v Message-ID: <3C57A0B536BE86438ED51856C6E830C3E1CB22@ieldubmail.iel.ie> Hi, I've noticed strange behaviour where cx_Oracle will fail to load when using "python" but it will succeed when using "python -v" while throwing "Unsatisfied code symbol" errors. This is for Python 2.5, Oracle 9.2 and cx_Oracle 4.3.1 on the platform HP-UX 11 Output for python: ImportError: Failed to load cx_Oracle Output for python -v: (extract of the errors) shl_load /admin/3rd_party/HP-UX/cx_Oracle-4.3.1_build/build/lib.hp-ux-B.11.23-ia6 4-2.5/cx_Oracle.so /usr/lib/hpux32/dld.so: Unsatisfied data symbol 'kpggwcx_' in load module '/product/app/oracle/9.2.0.2.svr/lib32/libwtc9.so'. /usr/lib/hpux32/dld.so: Unsatisfied code symbol 'LhtStrSearch' in load module '/product/app/oracle/9.2.0.2.svr/lib32/libwtc9.so'. /usr/lib/hpux32/dld.so: Unsatisfied code symbol 'kpggGetPG' in load module '/product/app/oracle/9.2.0.2.svr/lib32/libwtc9.so'. /usr/lib/hpux32/dld.so: Unsatisfied code symbol 'LhtStrInsert' in load module '/product/app/oracle/9.2.0.2.svr/lib32/libwtc9.so'. /usr/lib/hpux32/dld.so: Unsatisfied code symbol 'kpuhhalo' in load module '/product/app/oracle/9.2.0.2.svr/lib32/libwtc9.so'. /usr/lib/hpux32/dld.so: Unsatisfied code symbol 'kpuhhfre' in load module '/product/app/oracle/9.2.0.2.svr/lib32/libwtc9.so'. /usr/lib/hpux32/dld.so: Unsatisfied code symbol 'LhtStrCreate' in load module '/product/app/oracle/9.2.0.2.svr/lib32/libwtc9.so'. /usr/lib/hpux32/dld.so: Unsatisfied code symbol 'kpugdr' in load module '/product/app/oracle/9.2.0.2.svr/lib32/libwtc9.so'. I don't really understand why using python -v results in such a different in behaviour since as far as I know, it's just a verbose option. Any help would be appreciated in figuring this out so I can hopefully apply that knowledge in importing cx_Oracle without using the -v option. Thanks, John _____________________________________________ John Normoyle Email: jnormoyle at iel.ie Web Site: http://www.interactive-enterprise.com Software Developer Interactive Enterprise 7 Riverwalk National Digital Park CityWest Business Campus Dublin 24 Ireland -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin at v.loewis.de Sat Apr 26 21:12:12 2008 From: martin at v.loewis.de (=?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?=) Date: Sun, 27 Apr 2008 03:12:12 +0200 Subject: Why can't timedeltas be divided? In-Reply-To: References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> Message-ID: <4813d2ec$0$20870$9b622d9e@news.freenet.de> > sorry for bringing up such an old thread, but this seems important to me > -- up to now, there are thousands [1] of python programs that use > hardcoded time calculations. Would you like to work on a patch? Regards, Martin From andrew at acooke.org Wed Apr 16 22:27:51 2008 From: andrew at acooke.org (andrew cooke) Date: Wed, 16 Apr 2008 19:27:51 -0700 (PDT) Subject: Metaprogramming Example Message-ID: Hi, Thanks for the help a couple of days ago. I completed what I was doing and wrote a summary which I've posted at http://acooke.org/cute/PythonMeta0.html (it's kind of long to post here). I hope it might be useful to someone else - it's complete code for a simple metaprogramming task that uses metaclasses and descriptors. I'd also appreciate further feedback if I've done anything stupid or if there's some interesting approach I've missed that might work better. Thanks again, Andrew From cmpython at gmail.com Tue Apr 8 02:06:23 2008 From: cmpython at gmail.com (CM) Date: Mon, 7 Apr 2008 23:06:23 -0700 (PDT) Subject: Learning curve for new database program with Python? References: <00fca324-6fce-4b2a-8acb-77c96b83eb1c@p39g2000prm.googlegroups.com> Message-ID: On Apr 7, 1:19 pm, "bruno.desthuilli... at gmail.com" wrote: > On 7 avr, 07:34, CM wrote: > > > > > On Apr 5, 11:50 am, Jetus wrote: > > > > I have a need for a database program. I downloaded the db2 from ibm, > > > and reviewed some of the documentation. > > > > My question is, what is the easiest program for me to try to learn. I > > > will be creating a database of about 25,000 records, it will be > > > relational. I am a beginner Python programmer, and need a database > > > solution that is easy to grasp. I played with sql, > > > and found that very difficult, if not overly cumbersome. > > > > A database that could work with Django would be very interesting to > > > look at as well.. > > > > Any suggestions out there? > > > From the good people at Django: > > > "If you want to use Django with a database, which is probably the > > case, you'll also need a database engine. PostgreSQL is recommended, > > because we're PostgreSQL fans, and MySQL, SQLite 3, and Oracle are > > also supported." > > > And if you want to make it a relational database, > > Err... I may totally misunderstand you here, but I've the strong > impression that you missed the fact that the database systems > mentionned above are all (so-called) relational dabatases. You misunderstood me, but completely understandably. I meant that a) the OP wanted to use Django, and so I was giving the word on the only database engines that would work with that and b) the OP wanted to use a relational database, and therefore would have to use SQL despite not wanting to. But these two facts are completely connected, and by leaving out that connection it seemed like those DBs weren't relational. It would have been better for me to have said: "All of these are relational databases, and, like any relational database (which you want yours to be), they will require SQL." Sorry for the confusion. From eatham at gmail.com Fri Apr 11 16:40:36 2008 From: eatham at gmail.com (Roger Dahlstrom) Date: Fri, 11 Apr 2008 13:40:36 -0700 (PDT) Subject: Windows - window status (Running vs Not Responding) References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> <5f4a5d63-c862-4d25-8849-6a36dd4e138d@m3g2000hsc.googlegroups.com> Message-ID: On Apr 11, 3:54 pm, Mike Driscoll wrote: > On Apr 11, 2:10 pm, rdahlstrom wrote: > > > On Apr 11, 1:45 pm, rdahlstrom wrote: > > > > Does anyone know how to determine the window status (Running or Not > > > Responding)? I've tried various methods with no success... > > > > This would be on a variety of Windows systems, but all at least XP, > > > and mostly server 2003. Everyone will have Python 2.5.1 on them, and > > > the script would be running locally. > > > > Any ideas? > > > Basically, I'm looking for something similar to the Process.Responding > > property in System.Diagnostics... > > Hmmm...I think you should re-post to the Python win32 group. They'll > know the answer, if there is one. Here's the link to get signed up:http://mail.python.org/mailman/listinfo/python-win32 > > Also, you might take a look at the WMI module: > > http://tgolden.sc.sabren.com/python/wmi.html > > I'm pretty sure it can do that, but I don't know how. I did find an > article on it: > > http://www.informit.com/articles/article.aspx?p=19489&seqNum=4 > > If you're better than I am, you can probably translate this to the > Python equivalent. Zenoss also has some monitoring software that's > open source Python code. > > Mike I thought about posting to the win32 group, but in looking at all of the win32 apis, I couldn't find anything that did this - other than System.Diagnostic in c#, which isn't available to win32 (nor would you expect it to be, I guess) From jjl at pobox.com Sun Apr 6 09:14:53 2008 From: jjl at pobox.com (John J. Lee) Date: Sun, 06 Apr 2008 13:14:53 GMT Subject: py.test and test coverage analysis ? References: Message-ID: <87ej9j86r6.fsf@pobox.com> j vickroy writes: > Hello all, > > I am using py.test (http://codespeak.net/py/dist/test.html) to perform > unit testing. I would like to include test coverage analysis using > coverage.py (http://nedbatchelder.com/code/modules/coverage.html), but > I do not know how to simultaneously apply the two tools in a single > run. > > Could someone offer a suggestion on how to combine coverage analysis > with py.test. http://darcs.idyll.org/~t/projects/figleaf/doc/ Run: figleaf py.test John From imageguy1206 at gmail.com Thu Apr 3 06:49:14 2008 From: imageguy1206 at gmail.com (imageguy) Date: Thu, 3 Apr 2008 03:49:14 -0700 (PDT) Subject: Examples using msilib to build windows installers Message-ID: I have been using InnoSetup to distribute my wxpython app and ir works great, howver, I would like to offer a *.msi installer to customers as an option and this isn't available using Innosetup. It would appear to me that the msilib library included with standard python 2.5 would allow be to do this. I found the source code that builds the python distrubition installer packages, but I was wondering if there were other examples that I can learn from. TIA. From jason.scheirer at gmail.com Fri Apr 4 02:18:14 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Thu, 3 Apr 2008 23:18:14 -0700 (PDT) Subject: Unicode conversion problem (codec can't decode) References: Message-ID: On Apr 3, 9:35 pm, "Eric S. Johansson" wrote: > I'm having a problem (Python 2.4) converting strings with random 8-bit > characters into an escape form which is 7-bit clean for storage in a database. > Here's an example: > > body = meta['mini_body'].encode('unicode-escape') > > when given an 8-bit string, (in meta['mini_body']), the code fragment above > yields the error below. > > 'ascii' codec can't decode byte 0xe1 in position 13: ordinal not in range(128) > > the string that generates that error is: > >
Reduce Wh?t You Owe by 50%. Get out of debt today!
Reduuce Interest & > |V|onthlyy Payme?ts Easy, we will show you how..
Freee Quote in 10 > Min.
http://www.freefromdebtin.net.cn > > I've read a lot of stuff about Unicode and Python and I'm pretty comfortable > with how you can convert between different encoding types. What I don't > understand is how to go from a byte string with 8-bit characters to an encoded > string where 8-bit characters are turned into two character hexadecimal sequences. > > I really don't care about the character set used. I'm looking for a matched set > of operations that converts the string to a seven bits a form and back to its > original form. Since I need the ability to match a substring of the original > text while the string is in it's encoded state, something like Unicode-escaped > encoding would work well for me. unfortunately, I am missing some knowledge > about encoding and decoding. I wish I knew what cjson was doing because it does > the right things for my project. It takes strings or Unicode, stores everything > as Unicode and then returns everything as Unicode. Quite frankly, I love to > have my entire system run using Unicode strings but again, I missing some > knowledge on how to force all of my modules to be Unicode by default > > any enlightenment would be most appreciated. > > ---eric > > -- > Speech-recognition in use. It makes mistakes, I correct some. ASCII is technically only the seven-bit characters, so the codec is just being very 'correct'. One trick you may want to try is a string.decode() before your encode using some 8-bit encoding, such as latin-1: body = meta['mini_body'].decode('latin-1').encode('unicode-escape') The problem here is that you don't really ever know EXACTLY which single-byte character set you're dealing with, so there's no guarantee you're going to be translating the CORRECT sequence of bytes back and forth -- for instance, the addition of the Euro symbol, which was fairly recent, supplanting the place of the old generic 'currency' character. There are libraries such as Mark Pilgrim's port of the Mozilla character detection code ( http://chardet.feedparser.org/ ), but from my experience it doesn't do differentiation between latin sets well, it's better at detecting CJK character encodings. If you're merely using some unicode file/database as a dumb store you plan to eventually push back into a sequence of bytes, you may be well off doing string.decode('some-random-encoding').encode('utf-8') when pushing in and string.decode('utf-8').encode('some-random-encoding') when getting it back out. Another thing to consider is a lot of XML libraries will create unicode string objects that ARE NOT REALLY UNICODE -- something that bit me when using cElementTree is that if an XML file is in latin-* without a declaration of it being in that charset, it will still create unicode string instances, but with illegal characters in them. This causes Python to lead you down the garden path until you try to encode the string again. At that point, it will try to validate it and throw that exception. I usually use an idiom like this: def join_chars(x): def __dummy(*args, **kws): return ''.join(x(*args, **kws)) return __dummy @join_chars def unidecode(unicode_string): for character in unicode_string: try: yield character.decode('utf-8').encode('utf-8') except: yield ord(character) And pass all my potentially invalid 'unicode' strings through it, giving an explicit try when encoding each character. It's slow, but it's really the only quick, reproducible way I've found around the problem. From duncan.booth at invalid.invalid Tue Apr 8 04:55:57 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 8 Apr 2008 08:55:57 GMT Subject: Google App Engine Message-ID: Google have announced a new service called 'Google App Engine' which may be of interest to some of the people here (although if you want to sign up you'll have to join the queue behind me): >From the introduction: > What Is Google App Engine? > > Google App Engine lets you run your web applications on Google's > infrastructure. App Engine applications are easy to build, easy to > maintain, and easy to scale as your traffic and data storage needs > grow. With App Engine, there are no servers to maintain: You just > upload your application, and it's ready to serve your users. > > You can serve your app using a free domain name on the appspot.com > domain, or use Google Apps to serve it from your own domain. You can > share your application with the world, or limit access to members of > your organization. > > App Engine costs nothing to get started. Sign up for a free account, > and you can develop and publish your application for the world to see, > at no charge and with no obligation. A free account can use up to > 500MB of persistent storage and enough CPU and bandwidth for about 5 > million page views a month. > > During the preview release of Google App Engine, only free accounts > are available. In the near future, you will be able to purchase > additional computing resources. The Application Environment > > Google App Engine makes it easy to build an application that runs > reliably, even under heavy load and with large amounts of data. The > environment includes the following features: > > * dynamic web serving, with full support for common web > technologies > * persistent storage with queries, sorting and transactions > * automatic scaling and load balancing > * APIs for authenticating users and sending email using Google > Accounts > * a fully featured local development environment that > simulates Google App Engine on your computer > > Google App Engine applications are implemented using the Python > programming language. The runtime environment includes the full Python > language and most of the Python standard library. > > Although Python is currently the only language supported by Google App > Engine, we look forward to supporting more languages in the future. http://code.google.com/appengine From toby at tobiah.org Tue Apr 8 15:53:28 2008 From: toby at tobiah.org (Tobiah) Date: Tue, 08 Apr 2008 12:53:28 -0700 Subject: Best way to check if string is an integer? References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> <0fdd2825-6d1c-4380-a79a-a7aac119f002@a5g2000prg.googlegroups.com> <96d2fe53-96bf-43d8-a58d-8269846bf0df@b64g2000hsa.googlegroups.com> <2033313.fb3g3XYCIP@montana.com> Message-ID: > byte twiddling if the need arouse. I'm excited already :) ** Posted from http://www.teranews.com ** From mfb.chikazuku at gmail.com Thu Apr 10 13:05:33 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Thu, 10 Apr 2008 19:05:33 +0200 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> Message-ID: <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Paul Rubin wrote: > Chris Stewart writes: >> I've always had an interest in Python and would like to dabble in it >> further. I've worked on a few very small command line programs but >> nothing of any complexity. I'd like to build a really simple GUI app >> that will work across Mac, Windows, and Linux. How painful is that >> going to be? I used to be really familiar with Java Swing a few years >> ago. I imagine it will be similar. >> ... >> Next, what would you say is the best framework I should look into? > > If by "best" you mean "easiest", that is probably tkinter, which > comes with python. It is somewhat rudimentary and the widgets that > come with it don't look so great. But if you just want to put up > GUI's with basic functionality and not much glitz, it is ok for most > such purposes. > out how to use I don't quite agree with you on this. Tkinter may be easy because it is available by standard in Python, but that's about it in my opinion. The API, look and performance hit is horrible. You're much better of with PyQt4 which makes the job really simple. MFB -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFH/kjhDpaqHmOKFdQRAj+kAJ0d3aHqpv/mh7kSqtDqUFXtJsxi1gCfU5UP 2Ygw9ttRIYX+ioMyBVUNsVo= =stR5 -----END PGP SIGNATURE----- From nyamatongwe+thunder at gmail.com Fri Apr 25 19:16:57 2008 From: nyamatongwe+thunder at gmail.com (Neil Hodgson) Date: Fri, 25 Apr 2008 23:16:57 GMT Subject: MESSAGE RESPONSE In-Reply-To: <4e89b45d-198c-48ca-a3a6-3ba42448cb2b@e53g2000hsa.googlegroups.com> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> <678v5qF2me5rvU1@mid.uni-berlin.de> <4e89b45d-198c-48ca-a3a6-3ba42448cb2b@e53g2000hsa.googlegroups.com> Message-ID: ajaksu: > Me too. That is, until I tried to Google Belcan and Blubaugh together. Or google for "Blubaugh, David" or similar. Repeating a message you object to actually increases its visibility and includes you in its footprint. Neil From tjreedy at udel.edu Thu Apr 24 23:13:35 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 24 Apr 2008 23:13:35 -0400 Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> Message-ID: "Aaron Watters" wrote in message news:83ab3b9e-078c-4f5c-82ab-dafd41339dc1 at u36g2000prf.googlegroups.com... The reason that successive versions of 2.x broke so little is that starting at about 2.2, all breakages (starting with int division change) were put off until until 3.0 instead of being implemented as decided upon (with warning, deprecation, and then removal). Now the debt comes due. The new policy of mass breakage was a result of complaint about the old policy of gradual breakage. Of course, the new policy will get complaints both from those who preferred the old policy and those who want Python frozen with nothing ever removed for improvements. No change, gradual change, and jump change all have problems. In a year, we will have a better idea of which was better. From deets at nospam.web.de Wed Apr 9 08:15:19 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 09 Apr 2008 14:15:19 +0200 Subject: Basic optimization of python. References: <663p3lF2go90rU1@mid.uni-berlin.de> <877if7b5h9.fsf@mulj.homelinux.net> Message-ID: <663qbjF2hnrh2U2@mid.uni-berlin.de> Hrvoje Niksic wrote: > "Diez B. Roggisch" writes: > >>> Eg: >>> a = 1 + 2 >>> .vs. >>> a = 3 >>> which one is more effective? Does the compiler calculate the result at >>> compile time? How about constant spreading? >> >> Algebraic optimizations aren't done AFAIK > > Just try it: > > Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> dis.dis(lambda: 10+5) > 1 0 LOAD_CONST 2 (15) > 3 RETURN_VALUE I remember times when that hasn't been the case - thus my answer. [GCC 3.4.6 (Ubuntu 3.4.6-6ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. Welcome to rlcompleter2 0.96 for nice experiences hit multiple times >>> import dis >>> dis.dis(lambda: 1+2) 1 0 LOAD_CONST 1 (1) 3 LOAD_CONST 2 (2) 6 BINARY_ADD 7 RETURN_VALUE Python 2.4.4 (#2, Mar 7 2008, 04:45:43) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import dis >>> dis.dis(lambda: 1+2) 1 0 LOAD_CONST 1 (1) 3 LOAD_CONST 2 (2) 6 BINARY_ADD 7 RETURN_VALUE >>> But great to know it is done now. Diez From carlwuhwdmckay at gmail.com Sat Apr 26 09:31:05 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:31:05 -0700 (PDT) Subject: cod4 multiplayer crack Message-ID: <7cc87216-ebe1-4a9b-87c9-852e2bdc61b0@56g2000hsm.googlegroups.com> cod4 multiplayer crack http://cracks.00bp.com F R E E C R A C K S From arnodel at googlemail.com Thu Apr 17 12:46:14 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 17 Apr 2008 09:46:14 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> Message-ID: <1952579a-3cfb-44ea-92aa-658daa64aee4@a70g2000hsh.googlegroups.com> On Apr 17, 5:19?pm, s0s... at gmail.com wrote: > On Apr 17, 10:54 am, colas.fran... at gmail.com wrote: > > > On 17 avr, 17:40, s0s... at gmail.com wrote: > > > Out of sheer curiosity, why do you need thirty (hand-specified and > > dutifully commented) names to the same constant object if you know > > there will always be only one object? > > I'm building a web server. The many variables are names of header > fields. One part of the code looks like this (or at least I'd like it > to): > > class RequestHeadersManager: > > ? ? # General header fields > ? ? Cache_Control ? ? ? ? ? ? ? = \ > ? ? Connection ? ? ? ? ? ? ? ? ?= \ > ? ? Date ? ? ? ? ? ? ? ? ? ? ? ?= \ > ? ? Pragma ? ? ? ? ? ? ? ? ? ? ?= \ > ? ? Trailer ? ? ? ? ? ? ? ? ? ? = \ > ? ? Transfer_Encoding ? ? ? ? ? = \ > ? ? Upgrade ? ? ? ? ? ? ? ? ? ? = \ > ? ? Via ? ? ? ? ? ? ? ? ? ? ? ? = \ > ? ? Warning ? ? ? ? ? ? ? ? ? ? = \ > > ? ? # Request header fields > ? ? Accept ? ? ? ? ? ? ? ? ? ? ?= \ > ? ? Accept_Charset ? ? ? ? ? ? ?= \ > ? ? Accept_Encoding ? ? ? ? ? ? = \ > ? ? Accept_Language ? ? ? ? ? ? = \ > ? ? Authorization ? ? ? ? ? ? ? = \ > ... > > Etc etc etc. At the end they'll all be assign to None. Then, when > initialized, __init__() will the the string of headers, parse them, > and use those variables shown above to assign to the header values. Of > course a normal request won't include all of those headers, so the > others will remain None. That's what I want. Why not do something like: class RequestHeadersManager: def __init__(self, string): self._fields = {} # Populate self.fields with fields defined in 'string' def __getitem__(self, fieldname): return self._fields.get(fieldname, None) This way you don't need to prebind all possible fields to None, and a field is accessible by its actual name, which should be easier to remember than an identifier derived from a field name. Moreover you can more easily do some group manipulation of fields (e.g. print them all def print_fields(self): for name, value in self._fields.iteritems(): print "%s: %s" % (name, value) ) -- Arnaud From pavlovevidence at gmail.com Sat Apr 19 05:42:43 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Sat, 19 Apr 2008 02:42:43 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: On Apr 18, 11:58 am, Aaron Watters wrote: > Why is the migration to py3k a concern? > For example I have libraries which use string%dictionary > substitution where the dictionary is actually an object > which emulates a dictionary. The __getitem__ for > the object can be very expensive and is only called when > needed by the string substitution. > > In py3k string%dictionary is going away. Why? > I have no idea. > > The replacement is a string.format(...) method > which supports dictionary calling. > string.format(**dictionary) > But dictionary > calling doesn't support dictionary emulation. > So in the example below the substitution works > but the call fails. > > === code > > class fdict(dict): > def __getitem__(self, item): > return "got("+item+")" > > def fn(**d): > print d["boogie"] > > if __name__=="__main__": > fd = fdict() > print "attempting string substitution with fake dictionary" > print > print "hello there %(boogie)s" % fd # <-- works > print > print "now attempting function call with fake dictionary" > print > fn(**fd) # <-- fails > > === output > > % python2.6 dtest.py > attempting string substitution with fake dictionary > > hello there got(boogie) > > now attempting function call with fake dictionary > > Traceback (most recent call last): > File "dtest.py", line 17, in > fn(**fd) > File "dtest.py", line 7, in fn > print d["boogie"] > KeyError: 'boogie' > > ==== end of output > > Consequently there is no simple way to translate > my code, I think. I suspect you will find this kind of subtle > issue in many places. Or worse, you won't find it > until after your program has been installed > in production. > > It's a damn shame because > if string%dict was just left in it wouldn't be an issue. > > Also, if making f(**d) support dict emulation > has any negative performance implications > then I don't want it please. > > sigh. -- Aaron Watters If you don't like Python 3, DON'T USE IT. It's been stated repeatedly that 2.x and 3.x are going to be supported in parallel for years. Refusing to use 3, thus casting your brain-share vote against it, is far more likely to have an effect than you coming here and making everyone's life miserable with your pitiful whining. Carl Banks From steve at holdenweb.com Wed Apr 9 13:49:30 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 13:49:30 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> <47FCF421.6000807@holdenweb.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> Message-ID: Victor Subervi wrote: > On Wed, Apr 9, 2008 at 12:51 PM, Steve Holden > wrote: > > Victor Subervi wrote: > > On Wed, Apr 9, 2008 at 11:10 AM, Steve Holden > > >> wrote: > > I'm having a problem believing this, but I don't think you are > lying. Are you *sure* you have stored the correct omages in your > database? > > > Well, the Plesk PHP/MySQL interface indicates that a blob has been > successfully stored. Furthermore, the output I get has strings like > either 'Adobe Photoshop' or 'GIMP', depending on the editor I used. And > the output is like I have seen before from incorrectly rendered images. > And images are what I loaded into those fields through my form. So I > believe they are indeed images. > > > The fact remains that cursor.fetchall() will return a list > containing one tuple containing (what you believe is) your image, so > there is NO way your code above can do what you want. > > > Right. I used your suggestion of cursor.fetchall()[0][0] and the result > was *still* the image of the url. (I also used the other suggestion.) > > > > > I can therefore only assume that this is a CGI script and that your > web server does something *extremely* funky when it gets a CGI > output it isn't expecting. But this doesn't make a lot of sense. > > > Okay. How trouble-shoot this? Pass it on to the techies where I host? > Generally they are less than receptive, but maybe if I show them this > thread I can get their attention. > Nope, no need to start berating unresponsive techies yet. Instead, try writing a file and see whether it is a legitimate JPEG or not. I imagine the following code should do so, given your earlier writings: #! /usr/bin/python import MySQLdb print "Content-type: image/jpeg\r\n" host = 'host' db = 'bre' user = 'user' passwd = 'pass' connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor = connection.cursor() cursor.execute('select img from photo where id="7";') content = cursor.fetchall()[0][0] f = open("somefile.jpg", "w") f.write(content) f.close() Then see if you can deal with "somefile.jpg" like any other JPEG. If you can't then your blobs are somehow being mangled. If you can, we'll take it from there. regards Steve > > > > Stupidity and ignorance are entirely different things, and you > (current) ignorance in no way implies stupidity. We all have to learn. > > > True. I have never found programming easy. But I have been very > persistent. It still is not easy for me. > > > However, if you bring up one of the pages from one of your many web > sites containing an image, and get your browser to display the HTML > of that page you will surely find that the image does not appear > direectly in the HTML, but instead appears as a tag in the HTML. > Something like: > > > > though the src attribute doesn't really need to be that complex. > > > Of course. > > > > > In my stupidity, I have assumed you meant this: > > content = col_fields[0][14].tostring() > print '

' > > Well, here I have no idea what the content of your database might > be, but if the fifteenth column you retrieve is the web server path > to the graphic, that should be right except for the spaces around > it, which might give trouble. You might consider instead > > > content = col_fields[0][14].tostring() > print '

' % content > > > Great suggestion! Those spaces always mess me up. Unfortunately, it > *still* did not render properly :( > > > > > Forget HTML for now. If you direct your browser to the URL on which > your server is serving the graphic then it should be displayed in > the browser window. Until that happy condition pertains, we are > stabbing around in the dark. > > > Again...time to alert the teckies where I host? > > > > It's not that I mind, but I do feel that this knowledge is already > available, though clearly I might be wrong ... > > > Well, I may have missed it in all my googling, but I thought I was > pretty thorough. At any rate, it certainly cannot hurt to document it > again (if it is indeed 'again') > TIA, > Victor > -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From paul at boddie.org.uk Tue Apr 22 12:38:26 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Tue, 22 Apr 2008 09:38:26 -0700 (PDT) Subject: Witty retorts (was: Python Success stories) References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <87d4oi3s3c.fsf_-_@benfinney.id.au> Message-ID: <23c91e74-f4a4-4304-afc1-b435ec3df557@l64g2000hse.googlegroups.com> On 22 Apr, 16:02, Ben Finney wrote: > > What lesson is it intended to teach, other than that "Fuck you" is > somehow a "retort"? I can't see that improving too many situations. It isn't supposed to teach anything: it's a joke! It'd be more relevant (yet somewhat surreal if detached from this particular context) if it ended with the social worker saying... "Hey clown! What happened to Perl 6?" Paul From gagsl-py2 at yahoo.com.ar Sun Apr 6 06:15:52 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 06 Apr 2008 07:15:52 -0300 Subject: Implementation of Crockford's Base32 Encoding? References: <345117e9-2539-4ee0-8b27-9b1a88ddde7c@a1g2000hsb.googlegroups.com> <3EF041EA-8E9A-4DAA-B690-FC725D9E25D6@gmail.com> Message-ID: En Sun, 06 Apr 2008 06:07:18 -0300, Petite Abeille escribi?: > On Apr 6, 2008, at 9:20 AM, samslists at gmail.com wrote: > >> Anyone know of a Python implementation of this: >> http://www.crockford.com/wrmg/base32.html > > Not sure about Crockford's Base32 encoding itself, but here is an > implementation of Bryce "Zooko" Wilcox-O'Hearn's "human-oriented > base-32 encoding": > > https://zooko.com/repos/z-base-32/base32/ > https://zooko.com/repos/z-base-32/base32/DESIGN The design and rationale looks better. The Crockford version is ill-defined in the sense that you can't recover the exact input string length in some cases; by example both "\x00"*4 and "\x00"*5 share the same encoding. base-64 encoding, by example, uses '=' as pad bytes at the end to avoid this problem. -- Gabriel Genellina From hopeorpha308 at gmail.com Sun Apr 27 07:43:10 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:43:10 -0700 (PDT) Subject: inventor2008 crack Message-ID: <6ef4277e-2b65-463e-ab06-59afa231b77e@c58g2000hsc.googlegroups.com> inventor2008 crack http://wga-cracks.crackkey.net From johnjsal at gmailNOSPAM.com Tue Apr 22 20:14:13 2008 From: johnjsal at gmailNOSPAM.com (John Salerno) Date: Tue, 22 Apr 2008 20:14:13 -0400 Subject: Lists: why is this behavior different for index and slice assignments? In-Reply-To: References: <480d435b$0$11643$607ed4bc@cv.net> Message-ID: <480e7f61$0$25046$607ed4bc@cv.net> Steve Holden wrote: > Assignment to a list *element* rebinds the single element to the > assigned value. Ok, I understand that. Assignment to a list *slice* has to be of a list [or iterable, as per Duncan], and it > replaces the elements in the slice by assigned elements. I don't understand the second part of that sentence. I'm assuming "it" refers to the list being assigned, "replaces the elements" is self-evident, but what does "by assigned elements" refer to? It seems when you assign a list to a list slice, nothing gets replaced, the slice just gets deleted. From tjreedy at udel.edu Thu Apr 17 14:08:08 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 17 Apr 2008 14:08:08 -0400 Subject: Profiling, recursive func slower than imperative, normal? References: <48070CAC.6020005@jouy.inra.fr> Message-ID: |In that case, I'm not sure you get any performance gain since the queue |has basically the same role as the stack in the recursive version. A |definitive answer calls for an actual test, though. The potential gain comes from not incurring function call overhead and only queueing or stacking the exact data needed. From torriem at gmail.com Sat Apr 5 17:08:51 2008 From: torriem at gmail.com (Michael Torrie) Date: Sat, 05 Apr 2008 15:08:51 -0600 Subject: Weird scope error In-Reply-To: <47F7E325.9060603@gmail.com> References: <47F79A78.4010207@gmail.com> <47F7A41C.4090402@islandtraining.com> <47F7E325.9060603@gmail.com> Message-ID: <47F7EA63.3010504@gmail.com> Rory McKinley wrote: > Gary Herron wrote: > >> Python has no such thing as this kind of a "global scope". (True, each >> module has its own global scope, but that's not what you are talking >> about.) So you'll have to fix the import for *every* module that needs >> access to ElementTree. You might make the change as you mentioned >> above for each, but really, I think you should just make ElementTree >> directly importable by either installing it normally or including >> .../xml/etree in your PYTHONPATH > > > Thank you Gary and Kay for the response > > My apologies for being dense with regard to this: If I understand your > responses correctly, the "from xml.etree import ElementTree" that I > inserted is failing? And that is why I am getting the NameError in the > method? Is Python just ignoring the failure? No. Your import is fine. It imports "ElementTree" into the namespace of your current module/program. The problem is that the elementtidy.TidyHTMLTreeBuilder module (not your code) is also trying to import ElementTree into it's own namespace, which is failing, because ElementTree itself isn't in the python path, but rather is in xml.etree. You need to either fix all these imports in these other modules (that are probably in the site_packages folder), or modify the python import path so that it can find ElementTree directly. Again the problem isn't in your code, but rather in the other modules. > > > > Rory From ptmcg at austin.rr.com Wed Apr 23 01:12:44 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Tue, 22 Apr 2008 22:12:44 -0700 (PDT) Subject: "Dreaming in Code" Message-ID: <14fccf8d-eb21-4e04-9244-50bcfc84c4d7@d45g2000hsc.googlegroups.com> Haven't seen anyone mention this book, it is a "Soul of a New Machine"- style record of the Chandler project. Since Chandler uses Python and Twisted, and employed a few Python celebs, I thought folks on this list might have already read the hardcover version. I just picked up the paperback at B&N yesterday, finished it this evening. It's a decent read, describing a software project in laymen's terms (like there are laymen out there who care about that sort of thing!). The paperback version adds a chapter including events that transpired after the hardcover publication date, current up to about October, '07, so that's a nice touch. I'm going to ask my wife to read it so she might learn what I do for a living. -- Paul From paul.hankin at gmail.com Tue Apr 22 14:09:55 2008 From: paul.hankin at gmail.com (Paul Hankin) Date: Tue, 22 Apr 2008 11:09:55 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> Message-ID: <426812d7-c217-4bfc-81b0-47ba0638a650@k13g2000hse.googlegroups.com> On Apr 22, 5:50?pm, J?r?my Wagner wrote: > Sure. Python is more readable than Perl, though I have found Python > to have a weird behavior regarding this little issue : > > How can you explain that Python doesn't support the ++ opeator, > whereas at the same time it does support the += operator ??? > > No python developer I know has been able to answer that. Because ++ is of limited use and has poor readability? 'x++' vs 'x += 1' saves 3 characters and is less readable. 'my_long_variable += expression' vs 'my_long_variable = my_long_variable + expression' saves a lot of characters and is more readable, because it avoids the duplication of the variable name. When my_long_variable is a more complex term (perhaps my_long_variable[some_long_expression]) it's even better. Plus you get the useful update-in-place behaviour when the left-hand- side of the += expression is a list. -- Paul Hankin From aubrey at rinao.com Fri Apr 11 01:46:36 2008 From: aubrey at rinao.com (Aubrey Hutchison) Date: Fri, 11 Apr 2008 01:46:36 -0400 Subject: Pydev 1.3.15 Released References: Message-ID: <002f01c89b97$683c5310$0d01a8c0@Bubba> Hi, I have tried Pydev as used in Python(x,y). I tend to like it but I miss a couple of things.. When viewing the code, Line numbers can be added for reference. This is a very good thing BUT if line numbers are useful in the monitor screen view they would of course be desirable in a hard copy. But I find the line numbers are not printed out. To resolve this I must go back and use Pywin for printing out. The other thing is ,often I want the output of a trial run to be sent to hard copy. I find that the console does not allow me to do this directly. Same thing with the Wing IDE's Again I must go to Pywin to get a hard copy for a trial run. Interesting the more advance a product is the less useful in some areas. Aubrey ----- Original Message ----- From: "Fabio Zadrozny" Newsgroups: comp.lang.python.announce To: ; ; ; ; ; "Python List" Sent: Wednesday, April 09, 2008 1:41 PM Subject: Pydev 1.3.15 Released > Hi All, > > Pydev and Pydev Extensions 1.3.15 have been released > > Details on Pydev Extensions: http://www.fabioz.com/pydev > Details on Pydev: http://pydev.sf.net > Details on its development: http://pydev.blogspot.com > > Release Highlights in Pydev Extensions: > ----------------------------------------------------------------- > > * Globals Browser: Was not correctly showing definition on a case with > multiple projects when one did not have the python nature configured. > * Code Analysis: False positive: Classes defined within a class > context are correctly found when later accessed in the parent context. > * Interactive console integration > o Context insensitive completions with auto-import in console > o Ctrl+Alt+Enter: can be used to: > + Create console if no console exists > + Send selected text to console > + Make execfile for current file if there's no selected text > > > Release Highlights in Pydev: > ---------------------------------------------- > > * Files without extension: If a file that does not have an extension > is found in the root of the pythonpath, code-completion and > breakpoints work with it. > * Extract method: comma not removed when found after a tuple and > before a keyword argument. > * Console Encoding: print u"\xF6" works (console encoding correctly > customized in python -- see > http://sourceforge.net/tracker/index.php?func=detail&aid=1580766&group_id=85796&atid=577329 > for details). > * Debugger: Context of breakpoint correctly defined when comments are > present in the end of the module. > * from __future__ import (xxx, with_statement): works. > * Interactive Console View, featuring: > o Code Completion > + Context sensitive with shell completions > + Qualifier matches as case insensitive > + Templates > + Repeating the activation changes from templates to > default completions > o Console Configurations > + Initial commands for starting the console > + Colors for the console > + Vmargs can be specified for jython > o Auto-indent > o Auto-edits > o Context info on hover > o Up / Down Arrows cycles through the history (and uses the > current text to match for the start of the history command) > o Page Up: shows dialog with console history (where lines to be > re-executed can be selected) > o Esc: clears current line > o ctrl+1 works for assign quick-assist > o Hyperlinks addedd to tracebacks in the console > o Paste added directly to the command line > o Cut will only cut from the command line > o Copy does not get the prompt chars > o Home goes to: first text char / prompt end / line start (and > cycles again) > o Cursor automatically moved to command line on key events > o Multiple views of the same console can be created > o Limitation: Output is not asynchonous (stdout and stderr are > only shown after a new command is sent to the console) > > > > What is PyDev? > --------------------------- > > PyDev is a plugin that enables users to use Eclipse for Python and > Jython development -- making Eclipse a first class Python IDE -- It > comes with many goodies such as code completion, syntax highlighting, > syntax analysis, refactor, debug and many others. > > > Cheers, > > -- > Fabio Zadrozny > ------------------------------------------------------ > Software Developer > > ESSS - Engineering Simulation and Scientific Software > http://www.esss.com.br > > Pydev Extensions > http://www.fabioz.com/pydev > > Pydev - Python Development Enviroment for Eclipse > http://pydev.sf.net > http://pydev.blogspot.com From barronmo at gmail.com Sun Apr 27 10:35:48 2008 From: barronmo at gmail.com (barronmo) Date: Sun, 27 Apr 2008 07:35:48 -0700 (PDT) Subject: print some text References: <7ac7b11d-6c9b-477c-8c0d-b038bc760918@c58g2000hsc.googlegroups.com> Message-ID: <1b0b588a-be43-49d6-be0f-231217b074dd@k13g2000hse.googlegroups.com> On Apr 25, 2:44 pm, "Gabriel Ibanez" wrote: > Hi ! > > Other idea (old style school): > > def printing(): > f=open("lpt1", "w") > f.write("\nSomething to print\f") > f.close() > > Cheers.. > > - Ibanez - > I haven't found a way from within python to print f. I'm sure there it is something simple but I've been searching for a couple weeks now with no luck. Mike From jkugler at bigfoot.com Fri Apr 25 21:26:48 2008 From: jkugler at bigfoot.com (Joshua Kugler) Date: Fri, 25 Apr 2008 17:26:48 -0800 Subject: Setting an attribute without calling __setattr__() References: Message-ID: John Machin wrote: >> Is there a way to define self.me without it firing __setattr__? > Consider reading the *second* paragraph about __setattr__ in section > 3.4.2 of the Python Reference Manual. Like I said in my original post, it was probably staring me right in the face. I had read through a bit of the documentation on special methods, but for some reason I missed that part. Thanks to all for your responses! j From aldo at nullcube.com Sat Apr 5 08:20:13 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Sat, 5 Apr 2008 23:20:13 +1100 Subject: ANN: pry unit testing framework In-Reply-To: <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> Message-ID: <20080405122012.GC15684@nullcube.com> Thus spake Kay Schluehr (kay.schluehr at gmx.net): > A properly extended framework would of course be compatible with all > existing test suites. This has nothing to do with monkeypatching. I'm > not sure you even understand the concepts you are talking about. I'm afraid I'm just going to have to assure you that I do in fact know what I'm talking about, and leave it at that. Never fear - I will personally ensure that Pry's vast, fanatical legion of goose-stepping users does not force you to use it if you don't want to... Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From rustompmody at gmail.com Sat Apr 26 14:14:17 2008 From: rustompmody at gmail.com (Rustom Mody) Date: Sat, 26 Apr 2008 23:44:17 +0530 Subject: diffing and uniqing directories Message-ID: Over years Ive collected tgz's of my directories. I would like to diff and uniq them Now I guess it would be quite simple to write a script that does a walk or find through a pair of directory trees, makes a SHA1 of each file and then sorts out the files whose SHA1s are the same/different. What is more difficult for me to do is to write a visual/gui tool to help me do this. I would guess that someone in the python world must have already done it [The alternative is to use some of the tools that come with version control systems like git. But if I knew more about that option I would not be stuck with tgzs in the first place ;-)] So if there is such software known please let me know. PS Also with the spam flood that has hit the python list I dont know if this mail is being read at all or Ive fallen off the list! From carlwuhwdmckay at gmail.com Sat Apr 26 09:28:43 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:28:43 -0700 (PDT) Subject: password crack Message-ID: <360fe26c-7e40-477c-af8b-2e1af0dfe460@e53g2000hsa.googlegroups.com> password crack http://cracks.00bp.com F R E E C R A C K S From colas.francis at gmail.com Tue Apr 15 11:39:37 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Tue, 15 Apr 2008 08:39:37 -0700 (PDT) Subject: use object method without initializing object References: Message-ID: <4e4351d8-971c-4c56-827f-bc288f736d7f@m44g2000hsc.googlegroups.com> On 15 avr, 17:27, Reckoner wrote: > would it be possible to use one of an object's methods without > initializing the object? > > In other words, if I have: > > class Test: > def __init__(self): > print 'init' > def foo(self): > print 'foo' > > and I want to use the foo function without hitting the > initialize constructor function. > > Is this possible? Yes: In [214]: class Test: .....: def foo(self): .....: print 'foo' .....: In [215]: t = Test() In [216]: t.foo() foo From bignose+hates-spam at benfinney.id.au Sat Apr 19 01:32:32 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Sat, 19 Apr 2008 15:32:32 +1000 Subject: ANNOUNCE: SCons 0.98.1 (candidate for 1.0) is now available References: Message-ID: <871w52o1e7.fsf@benfinney.id.au> "Steven Knight" writes: > For a description of important changes that affect upgrading and > backwards compatibility, please see our release notes: > > http://scons.tigris.org/RELEASE.txt > > For a very complete list of changes, please see our change log: > > http://scons.tigris.org/CHANGES.txt Both those URLs lead me to 404 responses, "No matches to your request were found." -- \ "Why should I care about posterity? What's posterity ever done | `\ for me?" -- Groucho Marx | _o__) | Ben Finney From zethex at hotmail.com Sun Apr 27 13:07:41 2008 From: zethex at hotmail.com (Zethex) Date: Sun, 27 Apr 2008 10:07:41 -0700 (PDT) Subject: Mapping and Filtering Help for Lists Message-ID: <16925836.post@talk.nabble.com> Alright I got asked today by a friend this question, which obviously I couldn't help him with. He needs to get rid of words in a string referring to an already given list then needs to map them using a function he already has. Ill explain this better by giving an example :P Say ur given these lists: un_words = ['a', 'the', 'he', 'she', 'uses', 'with'] alterns = [ ['book', 'textbook', 'notepad'], ['pencil', 'pen', 'pacer'] ] The problem asks to create a "compareandremove" so that you can use it on a string, to remove the words from the string that are contained in un_words. The remaining words then need to be compared to the alterns list and either bring back the word if no matches or bring back the list. To better explain that i'll use an example. If i do compareandremove('notepad a pencil with desk') I need it so it removes words contained in un_words, so "a" and "with"; then compares the remaining words to alterns to find a match. This should bring back: ['notepad', 'book', 'textbook', 'pencil', 'pen', 'pacer', 'desk'] Any tips on how to create this function or maybe the function itself so I can then show him how to do it. Thank you. -- View this message in context: http://www.nabble.com/Mapping-and-Filtering-Help-for-Lists-tp16925836p16925836.html Sent from the Python - python-list mailing list archive at Nabble.com. From HDoran at air.org Wed Apr 16 08:46:13 2008 From: HDoran at air.org (Doran, Harold) Date: Wed, 16 Apr 2008 08:46:13 -0400 Subject: Learning Tkinter Message-ID: <2323A6D37908A847A7C32F1E3662C80E017BDFB9@dc1ex01.air.org> I am currently reading An Intro to Tkinter (1999) by F. Lundh. This doc was published in 1999 and I wonder if there is a more recent version. I've googled a bit and this version is the one I keep finding. I like how this document is organized and also how it provides the code with visuals of what should appear on the screen. If there are other docs I should read, please let me know. Second, I am trying to work through a couple of the examples and make some small tweaks as I go to see how new things can work. In the first case, I have copied the code in the book to see how the menu works and are created as in the example menu.py below. I see how menus are created and how the command option is used to call the function callback. # menu.py from Tkinter import * def callback(): print "called the callback!" root = Tk() # create a menu menu = Menu(root) root.config(menu=menu) filemenu = Menu(menu) menu.add_cascade(label="File", menu=filemenu) filemenu.add_command(label="New", command=harold) filemenu.add_command(label="Open...", command=callback) filemenu.add_separator() filemenu.add_command(label="Exit", command=callback) helpmenu = Menu(menu) menu.add_cascade(label="Help", menu=helpmenu) helpmenu.add_command(label="About...", command=callback) mainloop() However, I now want to incorporate a basic python program with a command. Say I have a simple program called test.py # test.py filename = raw_input("Please enter the file you want to open: ") new_file = raw_input("Save the output file as: ") f = open(new_file, 'w') new = open(filename, 'r') for line in new: x = line.split('\t') print >> f, x[0],':', x[1] f.close() To make this example complete assume I have a text file like this # data.txt 1 one 2 two 3 three 4 four So, the user currently just follows directions on the screen, enters the file names, and I get what I want. I'd like to try experimenting with gui programming to see if the python programs I have written can be made even more user friendly. I currently use py2exe to create executables so that others in my organization can use these programs. In that spirit, say I want to have a menu option that allows the user to search their computer for this file, execute the python code and then save the result as a user-defined filename. So, I guess my questions are how do I associate the portion of code in menu.py "filemenu.add_command(label="Open...", command=callback)" with an operation that gives the user the ability to search the drives on their machine and then once they do let python execute the code in test.py? Many thanks, From __peter__ at web.de Mon Apr 7 05:00:00 2008 From: __peter__ at web.de (Peter Otten) Date: Mon, 07 Apr 2008 11:00:00 +0200 Subject: csv.DictReader and unicode References: Message-ID: Laszlo Nagy wrote: > This program > > fin = codecs.open(fname,"r",encoding="UTF-8") > eader = csv.DictReader(fin) > for values in reader: > pass > > results in: > > File "run.py", line 23, in process_file > for values in reader: > File "/usr/local/lib/python2.5/csv.py", line 83, in next > row = self.reader.next() > UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in > position 13: ordinal not in range(128) > > As you can see the exception is thrown in csv.py. How it is possible? > The csv.DictReader should not use ascii codec for anything, because the > file encoding is UTF-8. The csv module doesn't support unicode. Read the values as byte strings and decode afterwards. Peter From ch612bunn at gmail.com Sun Apr 27 09:17:21 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:17:21 -0700 (PDT) Subject: nod32 2.70.39 crack Message-ID: nod32 2.70.39 crack http://wga-cracks.crackkey.net From steve at holdenweb.com Thu Apr 24 20:15:53 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 20:15:53 -0400 Subject: Psyco alternative In-Reply-To: References: Message-ID: sturlamolden wrote: > On Mar 27, 4:44 pm, Jean-Paul Calderone wrote: > >> PyPy is self-hosted and has been for some time (a year or so?). > > This is technically not correct. PyPy is hosted by RPython, which is > not Python but a different language all together. > I believe, without the benefit of recent experience, that the R stands for Restricted. Thus and RPython program must of necessity also be a valid Python program. Or do you know something I don't? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From stefan_ml at behnel.de Fri Apr 18 14:46:09 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 18 Apr 2008 20:46:09 +0200 Subject: Installing BeautifulSoup with easy_install (broken?) In-Reply-To: <4808cc41$0$34569$742ec2ed@news.sonic.net> References: <4808cc41$0$34569$742ec2ed@news.sonic.net> Message-ID: <4808EC71.9050507@behnel.de> John Nagle wrote: > easy_install usually seems to make things harder. > > BeautifulSoup is one single .py file. That's all you need. > Everything else is excess baggage. I wouldn't call the installation of a single module Python package a good example for the "usual" case. Stefan From rocksportrocker at googlemail.com Wed Apr 9 14:38:42 2008 From: rocksportrocker at googlemail.com (rocksportrocker) Date: Wed, 9 Apr 2008 11:38:42 -0700 (PDT) Subject: Displaying vtk files in a wxPython window Message-ID: <45b2ab4c-b7a1-450e-a084-e487f231aeca@q1g2000prf.googlegroups.com> Hi, I want to visualize some vtk-files within a wxPython Window. Google did not help me very much, I only found some tools for Tk, what is no solution for me. I'm sure I am not the first one who asks this question.... Any hints ? Greetings, Uwe From rhamph at gmail.com Thu Apr 17 12:03:07 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Thu, 17 Apr 2008 09:03:07 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> Message-ID: <69cbd3d3-449f-4e64-96d5-f512cf317032@m3g2000hsc.googlegroups.com> On Apr 17, 9:19 am, sturlamolden wrote: > On 17 Apr, 10:25, "Martin v. L?wis" wrote: > > > help progress at all. I think neither was the case in this thread - > > the guy claimed that he actually did something about the GIL, and > > now we are all waiting for him to also tell us what it is that he > > did. > > Ok, I did not remove the GIL, but I found a way to remove its > notorious side effect on SMPs. So I am going to reveal it now. Forgive > my strange sence of humor at 3 o'clock in the morning. > > First, think about this: > > (1) What is the GIL? > (2) Where does it live? > (3) How can it be manually released? > > The answer to this is: > > (1) A critical section (a lock/mutex object) > (2) As a global object in Python25.dll on my computer > (3) Using Python's C API or calling methods in a ctypes.CDLL object > > The Python C API has the ability to embed Python interpreters. You do > this by importing Python25.dll into the process. ctypes has the > ability to call functions in a DLL. So is it possible to embed Python > in Python? And what would be consequence be? > > First, if I try to load a DLL more than once, Windows will detect this > and just give me a handle to the currently imported library. So by > importing Python25.dll with ctypes, I can just make my Python > interpreter talk to itself through its own CAPI. Yes I can create sub > interpreters using PyNew_Interpreter, but they all share the same GIL, > so it's not useful here. > > So here is what I suddendly realized, and please don't laugh, its so > simple its almost silly: > > I make some copies of Python25.dll, and call them Python25-1.dll, > Python25-2.dll, Python25-3.dll, Python25-4.dll, etc. Then I load them > all into my current Python process as ctypes.CDLL objects. Tada! I now > have a pool of independent Python interpreters, not sharing the GIL, > but still living in the same process. > > I can make the different interpreters talk to each other, including > manipulating each other's GIL, using the using ctypes and Python's C > API for embedding. > > So why does this circumvent the GIL? Because ctypes releases it before > calling functions form a CDLL object. > > If I use my main interpreter to delegate a task to one of its embedded > 'children', its GIL will be released while it is waiting for the > answer. Associating each embedded interpreter with a threading.Thread > is all that remains. The GIL is released while the thread operating > the child interpreter is blocked. > > An there you have the answer. It's really very simple :-) Interesting. Windows specific, but there's other ways to do the same thing more portably. The bigger issue is that you can't share any objects. This effectively gives you a multiprocess model - a bit cheaper than that, but not enough to really supply GIL-free threading. From steveo at syslang.net Tue Apr 8 17:14:32 2008 From: steveo at syslang.net (Steven W. Orr) Date: Tue, 8 Apr 2008 17:14:32 -0400 (EDT) Subject: __init__.py file In-Reply-To: References: Message-ID: On Tuesday, Apr 8th 2008 at 16:51 -0000, quoth cesco: =>Hi, => =>I need to instantiate an object (my_object) whose methods I have to =>use in two files (file1.py and file2.py) which are in the same =>directory. Is it possible to instantiate such object in the =>__init__.py file and then directly use it in file1.py and file2.py? =>If not, as I seem to experience, what is the best practice to follow =>in this case? (I thought __init__.py was somehow useful for that). Sounds more like a job for a singleton. I recently found one that I like a lot better than the standard recipe: class Singleton(object): __single = None # the one, true Singleton def __new__(classtype, *args, **kwargs): if classtype != type(classtype.__single): classtype.__single = object.__new__(classtype, *args, **kwargs) return classtype.__single def __init__(self,name=None): """Arg doesn't have to be str.""" self.name = name def display(self): print self.name,id(self),type(self) The advantage of this one is that it can be nicely subclassed. if __name__ == "__main__": class SubSingleton(Singleton): def __init__(self, name=None): Singleton.__init__(self, name) self.aa = 123 self.bb = 456 self.cc = 789 o1 = Singleton('foo') o1.display() o2 = Singleton('bar') o2.display() o3 = SubSingleton('foobar') o3.display() o4 = SubSingleton('barfoo') o4.display() print 'o1 = o2:',o1 == o2 print 'o1 = o3:',o1 == o3 print 'o3 = o4:',o3 == o4 -- Time flies like the wind. Fruit flies like a banana. Stranger things have .0. happened but none stranger than this. Does your driver's license say Organ ..0 Donor?Black holes are where God divided by zero. Listen to me! We are all- 000 individuals! What if this weren't a hypothetical question? steveo at syslang.net From gandalf at shopzeus.com Mon Apr 7 05:13:28 2008 From: gandalf at shopzeus.com (Laszlo Nagy) Date: Mon, 07 Apr 2008 11:13:28 +0200 Subject: csv.DictReader and unicode In-Reply-To: References: Message-ID: <47F9E5B8.8080200@shopzeus.com> Peter Otten wrote: > Laszlo Nagy wrote: > > >> This program >> >> fin = codecs.open(fname,"r",encoding="UTF-8") >> eader = csv.DictReader(fin) >> for values in reader: >> pass >> >> results in: >> >> File "run.py", line 23, in process_file >> for values in reader: >> File "/usr/local/lib/python2.5/csv.py", line 83, in next >> row = self.reader.next() >> UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in >> position 13: ordinal not in range(128) >> >> As you can see the exception is thrown in csv.py. How it is possible? >> The csv.DictReader should not use ascii codec for anything, because the >> file encoding is UTF-8. >> > > The csv module doesn't support unicode. I understand that csv does not support unicode. I figured out that the exception will not be thrown if I open the file with the built in open() call. > Read the values as byte strings and decode afterwards. > Is there a plan to make csv reader compatible with unicode? Thanks, Laszlo From aaron.watters at gmail.com Wed Apr 2 09:50:03 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 2 Apr 2008 06:50:03 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> Message-ID: <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> > Try Rails' ActiveRecord. Your problems should reduce to (lg lg > 2)^(1/12). python> (log(log(2)))**(1.0/12.0) Traceback (most recent call last): File "", line 1, in ? ValueError: negative number cannot be raised to a fractional power So you are saying the problems will get really complex? :) > Seriously, you'll forget there's a relational database below. (there > are even intefaces for "relational lists", "trees", etc.) My experience with this sort of thing is that it is a bit like morphine. It can feel really good, and in emergencies it can save you a lot of pain. But if you use it too often and too seriously you end up with really big problems. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=mysterious+objects From primoz.skale.lists at gmail.com Wed Apr 2 16:32:36 2008 From: primoz.skale.lists at gmail.com (Primoz Skale) Date: Wed, 2 Apr 2008 22:32:36 +0200 Subject: function call - default value & collecting arguments References: <_LQIj.9776$HS3.482805@news.siol.net> <7e50544d-6daf-48c2-bb82-be06d3590450@8g2000hsu.googlegroups.com> Message-ID: >> I also understand (fairly) how to collect arguments. For example, let's >> define another function: >> >> def f(*a): >> print a > > This means that f takes any number of optional positional arguments. > If nothing is passed, within f, 'a' will be an empty tuple. Note that > this is *not* the usual way to define a function taking multiple > (mandatory) arguments. > M. Lutz in "Learning Python" had defined it this way. What is the *usual* way in this case? > > or (slightly more involved, and certainly overkill): > > def with_default_args(default): > def decorator(func): > def wrapper(*args): > if not args: > args = default > return func(*args) > return wrapper > return decorator > > @with_default_args((0,)) > def f(*a): > print a[0] > Now, this is interesting. Thanks! :) Primoz From victorsubervi at gmail.com Thu Apr 3 13:03:53 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 3 Apr 2008 12:03:53 -0500 Subject: Strange MySQL Problem... In-Reply-To: References: <4dc0cfea0804021236n1faafabav1699fbe45acc3c01@mail.gmail.com> <47f46a3e$0$36371$742ec2ed@news.sonic.net> <4dc0cfea0804030543t1ad5a3abs539fa6598061c454@mail.gmail.com> Message-ID: <4dc0cfea0804031003r24086f0fgea31eccdefa2ed54@mail.gmail.com> On Thu, Apr 3, 2008 at 9:34 AM, Gabriel Genellina wrote: > En Thu, 03 Apr 2008 09:43:57 -0300, Victor Subervi > escribi?: > > >> Steve Holden wrote: > >> Define "no longer works". > > Sorry. Throws HTTP 200 error. > > HTTP 200 means OK. Yes. But there is an error somewhere, because it doesn?t run all the code. For example, I have to manually drop the table. > > > >> > The same remarks I've posted earlier apply here. > > Must have missed those. Yes, the code works fine. Repeatedly. > > > http://groups.google.com/group/comp.lang.python/browse_thread/thread/b732eee4e91b1868/ Thank you. I believe you mean by bound, something like this, right? binary(picdata) I am now doing that, if I am not mistaken. > display or *log* errors... Yeah. There are always errors... > *post*? This is the server response. Return either text *or* an image (the > text may be an html referencing the image) Yes, post. But what do I write instead of this? print 'Content-Type: image/jpeg\r\n' > Test it locally (just the database thing, no web), test the cgi script > without database interaction, only then join the two. Okay, but how do I upload an image into mysql without a script? And once I can do that, everything?s (almost) solved! > But you can read the server logs at least? I am new to Plesk. I discovered I can read logs. More following... > > Your code is throwing exceptions but you're not seeing them. Use the cgitb > module http://docs.python.org/lib/module-cgitb.html Now here you give me another laugh :) I added this line to the script import cgitb; cgitb.enable() and suddenly I can take out these junk lines that were throwing the HTTP 200 error: names = 'aramis', 'athos', 'porthos' data = {} for name in names: datum = list(name) datum.sort() data[name] = cPickle.dumps(datum, 1) Is this some kind of magic wand? :) Okay, where I am at now... I have a script called start.py which has this code in it: import cgitb; cgitb.enable() import MySQLdb import struct import _mysql, sys Lots of imports, just to try things out. Most not needed... col_names = ['id', 'name_en', 'name_es', 'name_it', 'category', 'title_en', 'title_es', 'title_it', \ 'description_en', 'description_es', 'description_it', 'price', 'bedrooms', 'bathrooms', 'pic1', 'sort_factor'] Just notice the pic1 there... Then I make a nice list of colnames like MySQL wants... col_names_with_commas = '' for name in col_names: col_names_with_commas += name + ', ' count = len(col_names_with_commas)-2 col_names_with_commas = col_names_with_commas[0:len(col_names_with_commas)-2] All that I have checked, it is good... Here is the sticky point: for id in ids: for d in id: print '\n' cursor.execute('select ' + col_names_with_commas + ' from products where id = ' + str(d) + ';') col_fields = cursor.fetchall() i = 0 x = 0 for field in col_fields[0]: if x == 0: # This is the ID field i += 1 check = 'check' + str(i) print '\n' if x == 15: print '', field, '\n' else: print '', field, '\n' x += 1 I have to do both of those for statements. The sticky point is in the last if statement. 15 is the pic1 field. Should I use binary(field) instead? It does not like that. I send the whole thing over to another script which has this: import cgitb; cgitb.enable() import MySQLdb import cgi import struct Same old same old... Here?s the sticky part... if what_do == 'insert': data = ['', '', '', '', '', '', '', '', '', '', '', 0.0, '', '', '', 500] the_form(data, what_do) elif what_do == 'update': cursor.execute('select * from products where id=' + update_these[0] + ';') data = cursor.fetchall() the_form(data[0], what_do) And then try to render... 1ra Foto Grande: I show you both parts, because the Internal Server Error comes from the second page, but the logged error points to the first page. Here is the log record... [Thu Apr 03 09:53:33 2008] [error] [client 190.166.0.65] PythonHandler mod_python.cgihandler: File "/var/www/vhosts/ livestocksling.com/httpdocs/test/python/Shop/iud.py", line 210, in the_form\n print '"', binary(data[14]), '"', referer: http://livestocksling.com/test/python/Shop/start.py [Thu Apr 03 09:53:33 2008] [error] [client 190.166.0.65] PythonHandler mod_python.cgihandler: NameError: global name 'binary' is not defined, referer: http://livestocksling.com/test/python/Shop/start.py TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From gherron at islandtraining.com Sat Apr 5 12:09:00 2008 From: gherron at islandtraining.com (Gary Herron) Date: Sat, 05 Apr 2008 09:09:00 -0700 Subject: Weird scope error In-Reply-To: <47F79A78.4010207@gmail.com> References: <47F79A78.4010207@gmail.com> Message-ID: <47F7A41C.4090402@islandtraining.com> Rory McKinley wrote: > Hi > > I am trying to use the TidyHTMLTreeBuilder module which is part of > elementtidy, but I am getting what appears to be some sort of scope > error and it is scrambling my n00b brain. > > The module file (TidyHTMLTreeBuilder.py) tried to import ElementTree by > doing the following: > > from elementtree import ElementTree > > This bombed, so after a bit of poking around I replaced it with : > > from xml.etree import ElementTree > > This appears to have worked. However, when I try and parse a file using > the function : > TidyHTMLTreeBuilder.parse('weather_ct.html') > > I receive the following error: > > Traceback (most recent call last): > File "", line 1, in > File > "/usr/lib/python2.5/site-packages/elementtidy/TidyHTMLTreeBuilder.py", > line 107, in parse > return ElementTree.parse(source, TreeBuilder()) > NameError: global name 'ElementTree' is not defined > > > The code producing the error is as follows: > > def parse(source): > return ElementTree.parse(source, TreeBuilder()) > > Surely, if the from... import has worked, ElementTree is in the global > scope and should therefore be accessible to the function parse? > Python has no such thing as this kind of a "global scope". (True, each module has its own global scope, but that's not what you are talking about.) So you'll have to fix the import for *every* module that needs access to ElementTree. You might make the change as you mentioned above for each, but really, I think you should just make ElementTree directly importable by either installing it normally or including .../xml/etree in your PYTHONPATH Gary Herron > Can anybody help? > > THanks > From jeffrey at fro.man Mon Apr 7 12:54:36 2008 From: jeffrey at fro.man (Jeffrey Froman) Date: Mon, 07 Apr 2008 09:54:36 -0700 Subject: reading dictionary's (key,value) from file References: <974814d3-59f0-49ec-9b4d-9f5dd7dfaf54@q24g2000prf.googlegroups.com> Message-ID: ankitks.mital at gmail.com wrote: > so this is what my option files look like: > > 1opt.txt > { '-cc': '12', > '-I': r'/my/path/work/'} You can turn these strings read from text files into actual dictionaries using eval: >>> d = eval("{ '-cc': '12', '-I': r'/my/path/work/'}") >>> d {'-I': '/my/path/work/', '-cc': '12'} >>> type(d) Note that eval will happily execute all sorts of arbitrary code, so this is not a good solution if you don't fully trust your option file creators. It's also a bit clunky compared to simply importing. Since you already have dictionary-literal syntax in your text file, why not add a left-hand-operator and make it a module instead? For example: # opt1.py d = { '-cc': '12', '-I': r'/my/path/work/'} # main.py from opt1 import d -- Jeffrey From markfernandes02 at googlemail.com Sat Apr 5 07:49:37 2008 From: markfernandes02 at googlemail.com (markfernandes02 at googlemail.com) Date: Sat, 5 Apr 2008 04:49:37 -0700 (PDT) Subject: In Tkinter - having an input and an entry References: Message-ID: <29f44489-e589-4331-8bea-36fa346026d2@t54g2000hsg.googlegroups.com> Traceback (most recent call last): File "F:\Programming\python and database\access_db8.2.py", line 129, in ? Tkwindow() File "F:\Programming\python and database\access_db8.2.py", line 88, in Tkwindow title = stringVar() NameError: global name 'stringVar' is not defined Here is the TKwindow code. def Tkwindow(): global entry, entry2, entry3, entry4, entry5, entry6 global title, author, pubdate root = Tk() b1 = Button(root, text='Exit', command=root.quit) b1.grid(column = 1, row = 4) b2 = Button(root, text= 'Fetch', command= Fetch) b2.grid(column = 0, row = 3) b3 = Button(root, text= 'Clear', command= Clear) b3.grid(column = 0, row = 4) b4 = Button(root, text= 'Insert', command= Insert) b4.grid(column = 1, row = 3) #title = stringVar() #author = stringVar() #pubdate = stringVar() entry = Entry(root) entry.grid(column = 0, row = 0) entry2 = Entry(root) entry2.grid(column = 0, row = 1) entry3 = Entry(root) entry3.grid(column = 0, row = 2) title = stringVar() entry4 = Entry(root, textvariable = title) entry4.grid(column = 1, row = 0) author = stringVar() entry5 = Entry(root, textvariable = author) entry5.grid(column = 1, row = 1) pubdate = stringVar() entry6 = Entry(root, textvariable = pubdate) entry6.grid(column = 1, row = 2) print author print title print pubdate root.mainloop() From dolloffdelvpg at gmail.com Wed Apr 16 08:07:52 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:07:52 -0700 (PDT) Subject: taylor swift birthday Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From gagsl-py2 at yahoo.com.ar Wed Apr 30 03:57:11 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 30 Apr 2008 04:57:11 -0300 Subject: list.reverse() References: <4816e26a$0$30938$426a74cc@news.free.fr> Message-ID: En Tue, 29 Apr 2008 10:32:46 -0300, Roy Smith escribi?: > What you want to do is look at the reversed() function. Not only does it > return something (other than Null), but it is much faster because it > doesn't have to store the reversed list anywhere. What it returns is an > iterator which walks the list in reverse order. > Same with list.sort() vs. the global sorted(). No, sorted() returns a -newly created- true list, not an iterator. Its argument may be any iterable, but the result is always a list. -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Mon Apr 7 09:44:37 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 07 Apr 2008 10:44:37 -0300 Subject: A file iteration question/problem References: <47f8eee1$0$759$bed64819@news.gradwell.net> <322f98fd-eb6e-4a05-a8c7-1e0c5329e955@w5g2000prd.googlegroups.com> <47fa1cf9$0$761$bed64819@news.gradwell.net> Message-ID: En Mon, 07 Apr 2008 10:09:13 -0300, escribi?: > Arnaud Delobelle wrote: >> def recfun(lines): >> for line in lines: >> # Do stuff >> if condition: >> recfun(lines) >> >> lines = iter(open(filename)) >> recfun(lines) >> > Does that work though? If you iterate through the file with the "for > line in lines:" in the first call of recfun(lines) you surely can't do > "for line in lines:" and get any sort of sensible result in recursive > calls of recfun(lines) can you? Why not? Test and see what happens. -- Gabriel Genellina From sturlamolden at yahoo.no Thu Apr 24 20:04:10 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 17:04:10 -0700 (PDT) Subject: Psyco alternative References: Message-ID: On Mar 27, 4:44 pm, Jean-Paul Calderone wrote: > PyPy is self-hosted and has been for some time (a year or so?). This is technically not correct. PyPy is hosted by RPython, which is not Python but a different language all together. From sisson.j at gmail.com Tue Apr 22 14:08:20 2008 From: sisson.j at gmail.com (J Sisson) Date: Tue, 22 Apr 2008 13:08:20 -0500 Subject: Does Python 2.5 include or not include SQLite engine? In-Reply-To: <480E2352.5050005@activestate.com> References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> <1208819146.23409.1249124463@webmail.messagingengine.com> <3de8e1f70804212233o4e62c52s2a4d140deaa44355@mail.gmail.com> <480E2352.5050005@activestate.com> Message-ID: <4297a9020804221108y6f367decy9d115801593443ed@mail.gmail.com> On Gentoo, SQLite can be turned on or off via the sqlite USE flag for Python 2.5+ during installation. There's also a separate pysqlite package, and the python-updater script doesn't seem to take Python2.5's build into account when (re)building all of the Python2.4 modules for Python2.5...it breaks Python's sqlite support if you have both a) the sqlite USE flag set and b) the pysqlite package installed. (Might have been fixed since I last looked at it). OpenBSD seems to have pysqlite as a separate package from the "stock" python 2.5 package (at least on i386). On Tue, Apr 22, 2008 at 12:41 PM, Trent Mick wrote: > Whether a Python installation includes the SQLite 3 bindings typically > depends on: > > 1. Python version: core support for the SQLite 3 bindings (i.e. the > "sqlite3" module) was added in Python 2.5. Earlier versions of Python may > also have a 3rd-party package/module that adds SQLite bindings, of course. > > 2. The Python distro: The binary Python 2.5 installers from python.org(for Windows and Mac OS X [^1]) and ActiveState, i.e. ActivePython, (for > Windows, Mac OS X, Linux, Solaris, HP-UX and AIX) include the "sqlite3" > module as part of the installer. I don't know about other Python > distributions. > > 3. Platform: Commonly on Linux one will get Python from the Linux distro's > own packaging utility (e.g., apt-get, rpm, synaptic, yum, etc.) Typically > the Linux distros will break up a Python installation into multiple > packages. So an installation of, say, the "python2.5" package will often not > have the "sqlite3" module. To get it you would have to install the separate > "python2.5-sqlite" package. (Note: the names of these packages vary with > Linux distro and version of that distro.) > > > > Cheers, > Trent > > [1]: I could be wrong about whether the Mac OS X binary installer for > Python 2.5 from python.org includes the "sqlite3" module -- I haven't > checked -- but I presume it does. > > > Banibrata Dutta wrote: > > > Doesn't this depend on the source / distro ? My Python is from the > > ActivePython distro, while I am not sure (since I've just about started > > playing with it), I haven't seen SQLite included ... possible that I missed > > it. > > > > On 4/22/08, *python at bdurham.com * < > > python at bdurham.com > wrote: > > > > While reading feedback to my post "Does Python 2.5.2's embedded > > SQLite > > support full text searching?" I noticed that there appears to be some > > confusion regarding whether Python 2.5 includes the SQLite engine. > > > > My Windows 2.5.2 binary download includes SQLite. > > > > But other posters claim otherwise, re: Linux releases of Python 2.5? > > > > I thought one of the major features of Python 2.5 was its embedded > > SQLite engine. > > > > Thoughts? > > > > > -- > Trent Mick > trentm at activestate.com > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Computers are like air conditioners... They quit working when you open Windows. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mnordhoff at mattnordhoff.com Mon Apr 7 10:10:58 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Mon, 07 Apr 2008 14:10:58 +0000 Subject: Help replacing os.system call with subprocess call In-Reply-To: <47FA23E7.7040809@eastlink.ca> References: <47F9B1D1.4090701@eastlink.ca> <47F9C764.9070401@mattnordhoff.com> <47FA23E7.7040809@eastlink.ca> Message-ID: <47FA2B72.9050802@mattnordhoff.com> David Pratt wrote: > Hi David and Matt. I appreciate your help which has got me moving > forward again so many thanks for your reply. I have been using > subprocess.Popen a fair bit but this was the first time I had to use > subprocess to capture large file output. The trouble I was having was > with the process would just hang. Chunking was the solution. I guess I > assumed this would be taken care of in the internals. > > Overall, I wish subprocess had some better documentation since it is > definitely not a drop in replacement for os.system. In other > circumstances I am using subprocess.call() for simple calls which works > fine. > > The speed of this solution is slower than os.system. Would a queue of > some kind be needed to speed this up? Has anyone implemented something > like this? Many thanks. > > Regards, > David Did you see my second message? That should help performance. If not, I'm totally out of my depth and have no idea at all. Sorry. (How much slower? 10%? 200%?) -- From ilgufoeiltucano at gmail.com Tue Apr 1 14:04:25 2008 From: ilgufoeiltucano at gmail.com (ilgufoeiltucano at gmail.com) Date: Tue, 1 Apr 2008 11:04:25 -0700 (PDT) Subject: Python Audio PAN (left or right) and channels Message-ID: <881813a7-cbbb-48ab-9a4f-53da6fb0a69f@c26g2000prf.googlegroups.com> Hi folks... I don't know if there are other modules that let me do whatever I want with mp3s or only PyGame do that... I need to play mp3 files on different channels and listen Channel 0 on the left earphone and Channel 1 on the right... I know how to play mp3 files with pygame... I also know that pygame do what I need to do only with wave and not with mp3... Can someone suggest to me something ? :D How can I play mp3 files in different channel and pan the output? There are other py-modules that let me do this? thanks to everyone... Mark From mal at egenix.com Mon Apr 7 11:37:48 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Mon, 07 Apr 2008 17:37:48 +0200 Subject: Learning curve for new database program with Python? In-Reply-To: References: Message-ID: <47FA3FCC.6010301@egenix.com> On 2008-04-07 15:30, Greg Lindstrom wrote: > On Sun, Apr 6, 2008 at 2:31 AM, John Nagle wrote: >> Basic SQL isn't that hard. Learn CREATE, SELECT, INSERT, >> UPDATE, and DELETE syntax. That's enough for most simple >> applications. > > And then learn more advanced SQL: joins, nested selects, pivot tables and > stored procedures. You can do a lot of processing "inside" the database > which cuts down on data running over the wire. > > SQL is one of the areas I wish I had mastered (much) earlier in my career Fully agree :-) Interesting comments in a time where everyone seems to be obsessed with ORMs. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 07 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From lists at cheimes.de Sat Apr 19 17:37:14 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 19 Apr 2008 23:37:14 +0200 Subject: manipulating class attributes from a decorator while the class is being defined In-Reply-To: <200804192319.14735.wbsoft@xs4all.nl> References: <200804192319.14735.wbsoft@xs4all.nl> Message-ID: Wilbert Berendsen schrieb: > Hi, is it possible to manipulate class attributes from within a decorator > while the class is being defined? > > I want to register methods with some additional values in a class attribute. > But I can't get a decorator to change a class attribute while the class is > still being defined. Something like: > > class Parser(object): > > regexps = [] > def reg(regexp): > def deco(func): > regexps.append((regexp, func)) > return func > return deco > > @reg(r'".*"') > def quoted_string(self): > pass > > How can I reach the class attribute `regexps' from within a decorator? It's really tricky . The class object doesn't exists yet. It's created after all functions are parsed and created. You have can walk up the stack frames but it's ugly. Christian From gagsl-py2 at yahoo.com.ar Sun Apr 6 19:08:27 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 06 Apr 2008 20:08:27 -0300 Subject: Python Data Utils References: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> Message-ID: En Sun, 06 Apr 2008 11:34:11 -0300, Jesse Aldridge escribi?: > On Apr 6, 6:14?am, "Konstantin Veretennicov" > wrote: >> On Sun, Apr 6, 2008 at 7:43 AM, Jesse Aldridge >> wrote: >> > In an effort to experiment with open source, I put a couple of my >> > ?utility files up > href="http://github.com/jessald/python_data_utils/ >> > ?tree/master">here. ?What do you think? >> >> Would you search for, install, learn and use these modules if *someone >> else* created them? > > Yes, I would. I searched a bit for a library that offered similar > functionality. I didn't find anything. Maybe I'm just looking in the > wrong place. Any suggestions? Haven't you heard that Python comes with "batteries included"? For most operations in your modules, you don't need anything more than what already Python provides. Most of the whitespace, find, search, replace variants are already in the standard library, or trivially implemented with the existing tools [1]. Even more speciallized functions like pattern_to_regex are already there (see fnmatch.translate [2]) So I think you would benefit a lot reading the Library Reference documentation [3]; as it says in the docs main page: "keep this under your pillow" [1] http://docs.python.org/lib/string-methods.html [2] http://docs.python.org/lib/module-fnmatch.html [3] http://docs.python.org/lib/ -- Gabriel Genellina From nick at stinemates.org Fri Apr 25 18:36:46 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 25 Apr 2008 15:36:46 -0700 Subject: Calling Python code from inside php In-Reply-To: <67e4n4F2o0sfcU1@mid.uni-berlin.de> References: <679e9oF2mti63U1@mid.uni-berlin.de> <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> <679hd5F2nj6csU1@mid.uni-berlin.de> <67e4n4F2o0sfcU1@mid.uni-berlin.de> Message-ID: <20080425223646.GB12662@deviL> On Fri, Apr 25, 2008 at 03:29:49PM +0200, Diez B. Roggisch wrote: > Nick Stinemates schrieb: >>> While I certainly prefer to use Python wherever I can, that does not mean >>> that there aren't cases where legacy systems or other constraints make >>> this impossible. If I have e.g. a type3-based website - "how on earth" >>> should I replace that with Python (without wasting a lot of time)? >> I don't understand how the 2 are mutually exclusive? >> You can have PHP and Python bindings installed on the same Apache >> server, unless I'm mistaken? > > What about having to set up & maintain (which might not even possible on a > cheap hoster) two configs for that - just for having a few lines of python > being run? And how do you go about session-state sharing and so forth? > After all the scipt might need to be access controlled based on login > state. > > I don't say that there aren't options to run python more direct. I > argumented against a rather bold statement of Mr. alexelder: > > """ > A simple yet dangerous and rather rubbish solution (possibly more of a > hack than a real implementation) could be achieved by using a > technique described above: > """ > > Diez > -- > http://mail.python.org/mailman/listinfo/python-list Don't cry me the river, I was just asking about his situation. If there's a specific problem with using python, then write it in PHP?!? -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From Scott.Daniels at Acm.Org Thu Apr 10 08:19:52 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Thu, 10 Apr 2008 05:19:52 -0700 Subject: Sorting Directories from files in a os.listdir?? In-Reply-To: <9354f263-b833-4845-a226-1ad3a47b1e6a@p25g2000pri.googlegroups.com> References: <9354f263-b833-4845-a226-1ad3a47b1e6a@p25g2000pri.googlegroups.com> Message-ID: Soren wrote: > Hi, > > I'd like to read the filenames in a directory, but not the > subdirectories, os.listdir() gives me everything... how do I separate > the directory names from the filenames? Is there another way of doing > this? > > Thanks! import os base, files, dirs = iter(os.walk(dirname)).next() # now files is files and dirs is directories (and base == dirname) From bbxx789_05ss at yahoo.com Fri Apr 4 23:26:13 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Fri, 4 Apr 2008 20:26:13 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> Message-ID: On Apr 4, 7:06?pm, skanem... at yahoo.se wrote: > 1st question: > > when i run this program 1 will be printed into the interpreter when i > run it BUT without me clicking the actual button. > when i then click the button "1", nothing happens. > > obv i dont want any output when i dont push the button but i want it > when i do. > > what am i doing wrong here? > > 2nd question: > > i want all the buttons to have the same size. i thought i should use > row/columnspan but i dont get that to work. > how should i do? > > [code] > #! /usr/bin/env python > from Tkinter import * > import tkMessageBox > > class GUIFramework(Frame): > ? ? """This is the GUI""" > > ? ? def __init__(self,master=None): > ? ? ? ? """Initialize yourself""" > > ? ? ? ? """Initialise the base class""" > ? ? ? ? Frame.__init__(self,master) > > ? ? ? ? """Set the Window Title""" > ? ? ? ? self.master.title("Calculator") > > ? ? ? ? """Display the main window" > ? ? ? ? with a little bit of padding""" > ? ? ? ? self.grid(padx=10,pady=10) > ? ? ? ? self.CreateWidgets() > > ? ? def CreateWidgets(self): > > ? ? ? ? self.enText = Entry(self) > ? ? ? ? self.enText.grid(row=0, column=0, columnspan=8, padx=5, > pady=5) > > ? ? ? ? self.enText = Entry(self) > ? ? ? ? self.enText.grid(row=1, column=0, columnspan=8, padx=5, > pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="1", > command=self.Display(1)) > ? ? ? ? self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="2", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="3", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="+", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="4", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=4, column=0, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="5", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="6", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=4, column=2, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="-", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=4, column=3, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="7", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="8", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="9", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=5, column=2, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="*", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=5, column=3, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="0", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=6, column=0, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="C", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=6, column=1, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="r", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=6, column=2, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="/", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) > > ? ? def Display(self, xbtn): > ? ? ? ? if xbtn==1: > ? ? ? ? ? ? print 1 > > if __name__ == "__main__": > ? ? guiFrame = GUIFramework() > ? ? guiFrame.mainloop() > > [/code] If you have this function: def f(): print 1 return 10 and you write: result = f() The '()' is the function execution operator; it tells python to execute the function. In this case, the function executes, and then the return value of the function is assigned to the variable result. If a function does not have a return statement, then the function returns None by default. The same thing is happening in this portion of your code: command = self.Display(1) That code tells python to execute the Display function and assign the function's return value to the variable command. As a result Display executes and 1 is displayed. Then since Dispay does not have a return statement, None is returned, and None is assigned to command. Obviously, that is not what you want to do. What you want to do is assign a "function reference" to command so that python can execute the function sometime later when you click on the button. A function reference is just the function name without the '()' after it. So you would write: command = self.Display But writing it like that doesn't allow *you* to pass any arguments to Display(). In addition, *tkinter* does not pass any arguments to Display when tkinter calls Display in response to a button click. As a result, there is no way to pass an argument to Display. However, there is another way to cause a function to execute when an event, like a button click, occurs on a widget: you use the widget's bind() function: my_button.bind('', someFunc) The first argument tells tkinter what event to respond to. '' is a left click. Check the docs for the different strings that represent the different events that you can respond to. The second argument is a function reference, which once again does not allow you to pass any arguments to the function. However, when you use bind() to attach a function to a widget, tkinter calls the function and passes it one argument: the "event object". The event object contains various pieces of information, and one piece of information it contains is the widget upon which the event occurred, e.g. the button that was clicked. To get the button, you write: Display(self, event_obj): button = event_obj.widget Once you have the button, you can get the text on the button: Display(self, event_obj): button = event_obj.widget text = button.cget("text") if text=="1": print 1 Another thing you should be aware of: self is like a class wide bulletin board. If you are writing code inside a class method, and there is data that you want code inside another class method to be able to see, then post the data on the class wide bulletin board, i.e. attach it to self. But in your code, you are doing this: self.btnDisplay = Button(self, text="7", default=ACTIVE) self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="8", default=ACTIVE) self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) As a result, your code continually overwrites self.btnDisplay. That means you aren't preserving the data assigned to self.btnDisplay. Therefore, the data does not need to be posted on the class wide bulletin board for other class methods to see. So just write: btnDisplay = Button(self, text="7", default=ACTIVE) btnDisplay.grid(row=5, column=0, padx=5, pady=5) btnDisplay = Button(self, text="8", default=ACTIVE) btnDisplay.grid(row=5, column=1, padx=5, pady=5) As for the button sizing problem, your buttons are all the same size and line up perfectly on mac os x 10.4.7. From paul at science.uva.nl Tue Apr 22 09:49:58 2008 From: paul at science.uva.nl (Paul Melis) Date: Tue, 22 Apr 2008 15:49:58 +0200 Subject: Does Python 2.5 include or not include SQLite engine? In-Reply-To: <67646qF2mqc8pU1@mid.uni-berlin.de> References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> <67646qF2mqc8pU1@mid.uni-berlin.de> Message-ID: Hi, Diez B. Roggisch wrote: > Dennis Lee Bieber schrieb: > >> On Mon, 21 Apr 2008 19:05:46 -0400, python at bdurham.com declaimed the >> following in comp.lang.python: >> >>> I thought one of the major features of Python 2.5 was its embedded >>> SQLite engine. >>> >> No, just the inclusion of the adapter became standard... The >> packagers of Windows installers include the SQLite3 DLL as it isn't a >> commonly available item... But many Linux versions probably include it >> as an option during the OS install. > > > AFAIK thats wrong. On my ubuntu gutsy for example, I find this: > > deets at absinth:~$ find /usr/lib/python2.5/ | grep -i sqlite > /usr/lib/python2.5/lib-dynload/_sqlite3.so > /usr/lib/python2.5/site-packages/pysqlite-2.3.2.egg-info > /usr/lib/python2.5/site-packages/pysqlite2 > /usr/lib/python2.5/site-packages/pysqlite2/__init__.py > /usr/lib/python2.5/site-packages/pysqlite2/__init__.pyc > /usr/lib/python2.5/site-packages/pysqlite2/_sqlite.so > /usr/lib/python2.5/site-packages/pysqlite2/dbapi2.py > /usr/lib/python2.5/site-packages/pysqlite2/dbapi2.pyc > /usr/lib/python2.5/sqlite3 > /usr/lib/python2.5/sqlite3/__init__.py > > ... > > > As you can see, stock 2.5 ships with its OWN version of sqlite, and I > additionally installed the pysqlite-wrapper for whatever reason I now > can't remember. The _sqlite3.so is only a wrapper around the real sqlite library. Compiling a fresh Python 2.5.2 install here gives: 15:46|paul at tabu:~/py25/lib/python2.5/lib-dynload> ldd _sqlite3.so linux-gate.so.1 => (0x00748000) libsqlite3.so.0 => /usr/lib/libsqlite3.so.0 (0x00111000) libpthread.so.0 => /lib/libpthread.so.0 (0x00631000) libc.so.6 => /lib/libc.so.6 (0x00d1b000) /lib/ld-linux.so.2 (0x00749000) I.e. the _sqlite3 module links against the system-wide installed Sqlite version. Furthermore, checking the Python source distribution will show that there is no included version of the whole Sqlite library, only the wrapper code. How your Linux distribution packages Python w.r.t. the sqlite3 module is different per distro. Regards, Paul From aaron.watters at gmail.com Wed Apr 16 15:32:00 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 16 Apr 2008 12:32:00 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> <09a38ca2-8c49-4eee-b6cf-58e849aea1fc@q1g2000prf.googlegroups.com> Message-ID: > > Also in the case of C/java etc changing the infrastructure > > is less scary because you usually find out about problems > > when the compile or link fails. For Python you may not find > > out about it until the program has been run many times. > > Perhaps this will inspire improved linters and better coding > > practices.... > > Better coding practices such as extensive unit tests? Greetings from Earth. What planet are you from? :) There is always the possibility that frustrated programmers will decide that "using something other than python" is a "better coding practice". I've seen it happen. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=alien From chris.ortner at googlemail.com Tue Apr 1 07:35:17 2008 From: chris.ortner at googlemail.com (Chris Ortner) Date: Tue, 1 Apr 2008 04:35:17 -0700 (PDT) Subject: PyQt - How to prevent a dialog being resized? References: Message-ID: <2e859fec-d833-40fc-8e7b-afbe06eae9bf@k13g2000hse.googlegroups.com> On Apr 1, 12:12?am, Kelie wrote: > Hello, > > My question is as subject. I tried something like this and it doesn't > work. > > def resizeEvent(self, event): > ? ? self.size = event.oldSize() > > Any hint? > > Thank you. If you use the Qt designer you can set the minimum- and maximum window size to the same value, which disables resize as well. Tested with Qt4 on Linux 2.6. But I'm pretty sure that there could be a much cleaner way to do this. From ivory91044 at gmail.com Tue Apr 29 04:57:40 2008 From: ivory91044 at gmail.com (ivory91044 at gmail.com) Date: Tue, 29 Apr 2008 01:57:40 -0700 (PDT) Subject: driver detective crack keygen Message-ID: <280ae4fc-6a59-4f11-9f62-58d4f0fa45c0@w74g2000hsh.googlegroups.com> driver detective crack keygen http://crack.cracksofts.com From tjreedy at udel.edu Wed Apr 23 15:40:12 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 23 Apr 2008 15:40:12 -0400 Subject: problem with dictionaries References: Message-ID: "Simon Strobl" wrote in message news:ed249bcd-87ae-48ab-9aa9-c4bc9177b5c4 at b64g2000hsa.googlegroups.com... | Any hints? For future reference, I would consider using sample data in the file itself for debugging -- to separate an algorithm problem from a file problem: | ================================================ | | #!/usr/bin/python | | import sys | | frqlist = open('my_frqlist.txt', 'r') | | # my_frqlist looks like this: | # 787560608|the | # 434879575|of | # 413442185|and | # 395209748|to | # 284833918|a | # 249111541|in | # 169988976|is Change above to: # frqlist = open('my_frqlist.txt', 'r') frqlist = '''\ 787560608|the 434879575|of 413442185|and 395209748|to 284833918|a 249111541|in 169988976|is'''.split('\n') # sample my_frqlist.txt | frq = {} | | for line in frqlist: | line = line.rstrip() | frequency, word = line.split('|') | frq[word] = int(frequency) | | for key in frq.keys(): | print key, frq[key] An alternative is 'print line' in the first loop after stripping. tjr From p at ulmcnett.com Fri Apr 25 00:45:49 2008 From: p at ulmcnett.com (Paul McNett) Date: Thu, 24 Apr 2008 21:45:49 -0700 Subject: how to mysqldb dict cursors In-Reply-To: <17d58cc40804241950i7b624e1apd2733daa79b3ed5c@mail.gmail.com> References: <17d58cc40804241950i7b624e1apd2733daa79b3ed5c@mail.gmail.com> Message-ID: <481161FD.5020407@ulmcnett.com> Vaibhav.bhawsar wrote: > I have been trying to get the DictCursor working with mysqldb module but > can't seem to. I have pasted the basic connection code and the traceback > from pydev. The connection does open with the default cursor class. > can't figure this one out. many thanks. Try one of: """ import MySQLdb, MySQLdb.cursors conn = MySQLdb.connect(..., cursorclass=MySQLdb.cursors.DictCursor) """ -or- """ import MySQLdb, MySQLdb.cursors conn = MySQLdb.connect(...) cur = MySQLdb.cursors.DictCursor(conn) """ I'm going off of memory here, though, but I'm at least close. Paul From tjreedy at udel.edu Sun Apr 13 02:10:19 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 13 Apr 2008 02:10:19 -0400 Subject: str(bytes) in Python 3.0 References: <87k5j3f7m8.fsf@pobox.com> <29f280cc-4b33-4863-beee-d231df3d9a61@u3g2000hsc.googlegroups.com> Message-ID: "John Roth" wrote in message news:29f280cc-4b33-4863-beee-d231df3d9a61 at u3g2000hsc.googlegroups.com... | On Apr 12, 8:52 am, j... at pobox.com (John J. Lee) wrote: | > Christian Heimes writes: | > > Gabriel Genellina schrieb: | > >> On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') | > >> above. But I get the same as repr(x) - is this on purpose? | > | > > Yes, it's on purpose but it's a bug in your application to call str() on | > > a bytes object or to compare bytes and unicode directly. Several months | > > ago I added a bytes warning option to Python. Start Python as "python | > > -bb" and try it again. ;) | > | > Why hasn't the one-argument str(bytes_obj) been designed to raise an | > exception in Python 3? | > | > John | | Because it's a fundamental rule that you should be able to call str() | on any object and get a sensible result. | | The reason that calling str() on a bytes object returns a bytes | literal rather than an unadorned character string is that there are no | default encodings or decodings: there is no way of determining what | the corresponding string should be. In having a double meaning, str is much like type. Type(obj) echoes the existing class of the object. Type(o,p,q) attempts to construct a new class. Similarly, Str(obj) gives a string representing the obj (which, for a string, is the string;-). Str(obj,obj2) attemps to construct a new string. tjr From petite.abeille at gmail.com Sun Apr 6 05:07:18 2008 From: petite.abeille at gmail.com (Petite Abeille) Date: Sun, 6 Apr 2008 11:07:18 +0200 Subject: Implementation of Crockford's Base32 Encoding? In-Reply-To: <345117e9-2539-4ee0-8b27-9b1a88ddde7c@a1g2000hsb.googlegroups.com> References: <345117e9-2539-4ee0-8b27-9b1a88ddde7c@a1g2000hsb.googlegroups.com> Message-ID: <3EF041EA-8E9A-4DAA-B690-FC725D9E25D6@gmail.com> On Apr 6, 2008, at 9:20 AM, samslists at gmail.com wrote: > Anyone know of a Python implementation of this: http://www.crockford.com/wrmg/base32.html Not sure about Crockford's Base32 encoding itself, but here is an implementation of Bryce "Zooko" Wilcox-O'Hearn's "human-oriented base-32 encoding": https://zooko.com/repos/z-base-32/base32/ https://zooko.com/repos/z-base-32/base32/DESIGN -- PA. http://alt.textdrive.com/nanoki/ From torriem at gmail.com Thu Apr 17 13:24:54 2008 From: torriem at gmail.com (Michael Torrie) Date: Thu, 17 Apr 2008 11:24:54 -0600 Subject: Can't do a multiline assignment! In-Reply-To: <42402158-0b16-42e2-b7a0-9d9a15e8196d@24g2000hsh.googlegroups.com> References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <42402158-0b16-42e2-b7a0-9d9a15e8196d@24g2000hsh.googlegroups.com> Message-ID: <480787E6.5050806@gmail.com> s0suk3 at gmail.com wrote: > > There! That's the whole code. I guess the way you suggest is simpler > and a bit more intuitive, but I was figuring that the way I suggested > it is more stylish. Umm, doesn't defining all those members in the class lead to class variables, not instance variables? I believe the recommended way of making it clear what instance variables to expect is to initialize them all in __init__. Currently in your implementation, each instance of your class is going to share the same variables for all those fields you defined, which probably isn't what you want. consider: class myclass(object): classvar1=None classvar2=None def __init__(self,test): self.instancevar1=test >>> a=myclass(3) >>> b=myclass(6) >>> a.classvar1=9 >>> a.classvar1 9 >>> b.classvar1 9 >>> a.instancevar1 3 >>> b.instancevar1 6 Also, your idea of checking the length of the headers to reduce the number of string comparisons is a great case of premature optimization. First it does not clarify the code, making it harder to follow. Second, since web servers are I/O bound, it likely does nothing to improve speed. So my recommendation is to use a bunch of self.HEADER_NAME=None declarations in __init__(). This is the expected way of doing it and all python programmers who are looking at your code will immediately recognize that they are instance variables. From Lie.1296 at gmail.com Sat Apr 26 02:59:09 2008 From: Lie.1296 at gmail.com (Lie) Date: Fri, 25 Apr 2008 23:59:09 -0700 (PDT) Subject: function that accepts any amount of arguments? References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> <4810724a$0$23390$426a74cc@news.free.fr> <63ac69bf-9f6d-42bd-8e6e-5b3b17ec7c69@z72g2000hsb.googlegroups.com> Message-ID: On Apr 25, 2:12?am, "bruno.desthuilli... at gmail.com" wrote: > On 24 avr, 14:28, malkarouri wrote: > > > On Apr 24, 12:43 pm, Bruno Desthuilliers wrote: > > > [...] > > > > Not quite sure what's the best thing to do in the second case - raise a > > > ValueError if args is empty, or silently return 0.0 - but I'd tend to > > > choose the first solution (Python's Zen, verses 9-11). > > > What's wrong with raising ZeroDivisionError (not stopping the > > exception in the first place)? > > Because - from a semantic POV - ?the real error is not that you're > trying to divide zero by zero, but that you failed to pass any > argument. FWIW, I'd personnaly write avg as taking a sequence - ie, > not using varargs - in which case calling it without arguments would a > TypeError (so BTW please s/Value/Type/ in my previous post). The problem with passing it as a sequence is, if you want to call it, you may have to wrestle with this odd looking code: avg((3, 4, 6, 7)) rather than this, more natural code: avg(3, 4, 6, 7) And FWIW, the OP asked if it is possible to pass variable amount of arguments, avg is just a mere example of one where it could be used not where it could be best used. Nick Craig-Wood wrote: > Steve Holden wrote: >> Ken wrote: >>> "Steve Holden" wrote in message >> [...] >>>> def mean(*x): >>>> total = 0.0 >>>> for v in x: >>>> total += v >>>> return v/len(x) >>> think you want total/len(x) in return statement >> Yes indeed, how glad I am I wrote "untested". I clearly wasn't pair >> programming when I wrote this post ;-) > Posting to comp.lang.python is pair programming with the entire > internet ;-) No, actually it's pair programming with the readers of c.l.py (or more accurately with the readers of c.l.py that happens to pass the said thread). From paddy3118 at googlemail.com Sun Apr 6 01:02:10 2008 From: paddy3118 at googlemail.com (Paddy) Date: Sat, 5 Apr 2008 22:02:10 -0700 (PDT) Subject: Best way to check if string is an integer? References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> <0fdd2825-6d1c-4380-a79a-a7aac119f002@a5g2000prg.googlegroups.com> Message-ID: <96d2fe53-96bf-43d8-a58d-8269846bf0df@b64g2000hsa.googlegroups.com> On Apr 6, 5:18 am, ernie wrote: > On Apr 6, 10:23 am, Roy Smith wrote: > > > > > In article , > > Steve Holden wrote: > > > > > This doesn't cater for negative integers. > > > > No, it doesn't, but > > > > s.isdigit() or (s[0] in "+-" and s[1:].isdigit) # untested > > > > does. > > > I think this fails on " -1". So, then you start doing > > s.strip().isdigit(), and then somebody else comes up with some other > > unexpected corner case... > > > int(s) and catching any exception thrown just sounds like the best way. > > Another corner case: Is "5.0" an integer or treated as one? > > regards, > ernie In Python, 5.0 is a float "5.0" is a string, and you need to make your mind up about what type you want "5.0" to be represented as in your program and code accordingly. - Paddy. From gagsl-py2 at yahoo.com.ar Tue Apr 15 02:18:17 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 15 Apr 2008 03:18:17 -0300 Subject: a name error References: <20080415055502.9F3CF292B61@mail-in-07.arcor-online.net> Message-ID: En Tue, 15 Apr 2008 02:54:43 -0300, Penny Y. escribi?: > import urllib2,sys > try: > r=urllib2.urlopen("http://un-know-n.com/") > except URLError,e: > print str(e) > sys.exit(1) > > print r.info() > > > But got the errors: > > Traceback (most recent call last): > File "t1.py", line 4, in ? > except URLError,e: > NameError: name 'URLError' is not defined Same as the function urlopen, you have to qualify URLError with the module first: except urllib2.URLError, e: ... Or import both things from urllib2: from urllib2 import urlopen, URLError try: r = urlopen(...) except URLError, e: ... -- Gabriel Genellina From woodham at cs.ubc.ca Fri Apr 25 19:22:04 2008 From: woodham at cs.ubc.ca (Bob Woodham) Date: Fri, 25 Apr 2008 23:22:04 +0000 (UTC) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> <426812d7-c217-4bfc-81b0-47ba0638a650@k13g2000hse.googlegroups.com> <480FDFD2.8070906@ggmail.com> Message-ID: On 2008-04-24, AlFire wrote: > Bob Woodham wrote: > >> >> x = x++; >> >> has unspecified behaviour in C. > > what about C++ To the extent that (historically) C++ was a superset of C, it was true of C++ as well. However, I haven't kept pace with the C++ standardization process. C++ now has its own ANSI standard and I don't know what, if anything, the C++ standard has to say on this issue. Maybe a C++ guru can comment. From jsprad at gmail.com Tue Apr 1 13:27:18 2008 From: jsprad at gmail.com (sprad) Date: Tue, 1 Apr 2008 10:27:18 -0700 (PDT) Subject: Python in High School Message-ID: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> I'm a high school computer teacher, and I'm starting a series of programming courses next year (disguised as "game development" classes to capture more interest). The first year will be a gentle introduction to programming, leading to two more years of advanced topics. I was initially thinking about doing the first year in Flash/ ActionScript, and the later years in Java. My reasoning is that Flash has the advantage of giving a quick payoff to keep the students interested while I sneak in some OOP concepts through ActionScript. Once they've gotten a decent grounding there, they move on to Java for some more heavy-duty programming. I've never used Python, but I keep hearing enough good stuff about it to make me curious. So -- would Python be a good fit for these classes? Could it equal Java as the later heavy-duty language? Does it have enough quickly- accessible sparklies to unseat Flash? I want to believe. Evangelize away. From sn at sncs.se Tue Apr 15 00:30:05 2008 From: sn at sncs.se (Sverker Nilsson) Date: Mon, 14 Apr 2008 21:30:05 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> Message-ID: <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> No one forces me, but sooner or later they will want a Python 3.0 and then a 3.1 whatever. I don't want that fuzz. As about the C versions, I am not that worried. What's your point? I just like want to write a program that will stay working. And maybe I can go on with something else hopefully than just compatibility fixes. They take some work afterall. It seems hard with Python. Esp. 2 -> 3 Sverker On Apr 15, 5:41 am, "Gabriel Genellina" wrote: > En Mon, 14 Apr 2008 23:38:56 -0300, Sverker Nilsson escribi?: > > > > > On Apr 15, 3:50 am, "Gabriel Genellina" > > wrote: > >> En Mon, 14 Apr 2008 22:02:38 -0300, Sverker Nilsson > >> escribi?: > > >> > I tried out py3k on my project,http://guppy-pe.sf.net > > >> And what happened? > >> I've seen that your project already supports Python 2.6 so the migration > >> path to 3.0 should be easy. > > > 2.6 was no big deal, It was an annoyance that they had to make 'as' a > > reserved word. Annoyances were also with 2.4, and 2.5. No big > > problems, I could make guppy backwards compatible to 2.3. But that > > seems not to be possible with Python 3.x ... it is a MUCH bigger > > change. And it would require a fork of the code bases, in C, Guido has > > written tha or to sprinkle with #ifdefs. Would not happen soon for me. > > It takes some work anyways. Do you volunteer, Guido van Rossum? :-) > > > It's not exactly easy. Perhaps not very hard anyways. But think of > > 1000's of such projects. How many do you think there are? I think > > many. How many do yo think care? I think few. > > > When it has been the fuzz with versions before, then I could have the > > same code still work with older versions. But now it seems I have to > > fork TWO codes. It's becoming too much. Think of the time you could > > write a program in C or even C++ and then it'll work. How do you think > > eg writers of bash or other unix utilities come along. Do they have to > > rewrite their code each year? No, it stays. And they can be happy > > about that, and go on to other things. Why should I have to think > > about staying compatible with the newest fancy Python all the time? NO > > -- but the answer may be, they don't care, though the others (C/C++, > > as they rely on) do. :-( > > You can stay with Python 2.6 and not support 3.0; nobody will force you to > use it. And nobody will come and wipe out your Python installation, be it > 2.6, 2.1 or whatever. And if you still enjoy using Python 1.5, please keep > using it - it won't disappear the day after 3.0 becomes available. > > Regarding the C language: yes, souce code *had* to be modified for newer > versions of the language and/or compiler. See by example, the new > "restrict" keyword in C99, or the boolean names. The C guys are much more > concerned about backwards compatibility than Python, but they can't > guarantee that (at risk of freezing the language). The 3.0 > incompatibilities are all justified, anyway, and Python is changing (as a > language) much more than C - and that's a good thing. > > There is a strategy to migrate from 2.x to 3.0, including the 2to3 tool. > Have you used it? > > -- > Gabriel Genellina From bwljgbwn at gmail.com Tue Apr 22 05:55:09 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:55:09 -0700 (PDT) Subject: smoking crack cocaine Message-ID: smoking crack cocaine http://cracks.12w.net F R E E C R A C K S From sean_mcilroy at yahoo.com Sat Apr 12 17:14:22 2008 From: sean_mcilroy at yahoo.com (Sean McIlroy) Date: Sat, 12 Apr 2008 14:14:22 -0700 (PDT) Subject: override the interpreter's parser? References: <0e23fcab-4169-4ba8-ace4-6aa4a4b95947@q1g2000prf.googlegroups.com> Message-ID: never mind. i found it. From gagsl-py2 at yahoo.com.ar Thu Apr 10 01:01:58 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 02:01:58 -0300 Subject: Need Help References: Message-ID: En Wed, 09 Apr 2008 05:29:24 -0300, pramod sridhar escribi?: > I would like to access type library files (.tlb) from python. > > The application (with .tlb extension) controls an external instrument > over > standard GPIB interface. > Is it possible to control this application from Python? If so, how ? > Can anyone share or send link of some examples ? You'll want a package pywin32 by Mark Hammond -available from sourceforge- and a book "Python Programming in Win32" by the same author. -- Gabriel Genellina From steve at holdenweb.com Fri Apr 11 15:29:09 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 11 Apr 2008 15:29:09 -0400 Subject: Question on threads In-Reply-To: References: Message-ID: <47FFBC05.50309@holdenweb.com> Jonathan Shao wrote: > Hi all, > > I'm a beginner to Python, so please bear with me. > > Is there a way of guarenteeing that all created threads in a program are > finished before the main program exits? I know that using join() can > guarentee this, but from the test scripts I've run, it seems like join() > also forces each individual thread to terminate first before the next > thread can finish. So if I create like 20 threads in a for loop, and I > join() each created thread, then join() will in effect cause the threads > to be executed in serial rather than in parallel. > No it won't, as in fact there is no mechanism to force a thread to terminate in Python. When you join() each created thread the main thread will wait for each thread to finish. Supposing the longest-lived thread finished first then all others will immediately return from join(). The only requirement it is imposing is that all sub-threads must be finished before the main thread terminates. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From rdm at rcblue.com Tue Apr 22 20:42:26 2008 From: rdm at rcblue.com (Dick Moores) Date: Tue, 22 Apr 2008 17:42:26 -0700 Subject: IDLE gripe and question Message-ID: <20080423005006.D40B81E4008@bag.python.org> I have IDLE 1.2.1, on Win XP, Python 2.5.1. The first time I use File | Open to open a script, the Open dialogue box always opens at E:\Python25\Lib\idlelib. Most of the scripts I want to access are in E:\PythonWork. There doesn't seem to be a way to change the default folder to E:\PythonWork, but is there? Thanks, Dick Moores ================================ UliPad <>: http://code.google.com/p/ulipad/ From tamim.shahriar at gmail.com Fri Apr 18 12:22:15 2008 From: tamim.shahriar at gmail.com (subeen) Date: Fri, 18 Apr 2008 09:22:15 -0700 (PDT) Subject: How to set proxy for a python script to run References: <94243913-cdcb-47a2-b000-a236fe0e8009@p25g2000hsf.googlegroups.com> Message-ID: <2931b1e8-a784-46d2-b13b-e6955acd68dd@p25g2000pri.googlegroups.com> On Apr 18, 12:31 pm, Adam wrote: > Hi, everyone, I am using /usr/share/system-config-language/ > language_gui.py in Python. > For some reason I have to bypass the firewall using a proxy. I read > the urllib reference and set http_proxy="my proxy". But it didn't > work. Is there anyway that we can set the proxy? Check the link: http://love-python.blogspot.com/2008/03/use-proxy-in-your-spider.html From basilisk96 at gmail.com Tue Apr 1 17:48:50 2008 From: basilisk96 at gmail.com (Basilisk96) Date: Tue, 1 Apr 2008 14:48:50 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: <659b3a11-6aed-41c7-a54b-34151afb0562@x41g2000hsb.googlegroups.com> On Apr 1, 12:27 pm, sprad wrote: > I'm a high school computer teacher, and I'm starting a series of > programming courses next year (disguised as "game development" classes > to capture more interest). The first year will be a gentle > introduction to programming, leading to two more years of advanced > topics. > > I was initially thinking about doing the first year in Flash/ > ActionScript, and the later years in Java. My reasoning is that Flash > has the advantage of giving a quick payoff to keep the students > interested while I sneak in some OOP concepts through ActionScript. > Once they've gotten a decent grounding there, they move on to Java for > some more heavy-duty programming. > > I've never used Python, but I keep hearing enough good stuff about it > to make me curious. > > So -- would Python be a good fit for these classes? Could it equal > Java as the later heavy-duty language? Does it have enough quickly- > accessible sparklies to unseat Flash? > > I want to believe. Evangelize away. I highly recommend that you read the introduction chapters in two of the books on this site: http://www.greenteapress.com/ The first book is called "How To Think Like a Computer Scientist: Learning with Python". The second book is a follow-up edition to that one, and is called "How To Think Like a (Python) Programmer". All of the books there are written by school teachers, so I think you will find valuable insight there. The same books also have a Java and a C++ flavor. All are free downloads. My very first serious look into Python came from this series, and I thoroughly enjoyed learning the basics. I think the text was so successful for me because the content is well-connected. As far as which language to choose - well, you can make the choice yourself after reading at least the introductions of all the books. If you do decide on Python, there is a library called "pygame" that may achieve your visual game programming goals. Enjoy! -Basilisk96 From robert.kern at gmail.com Fri Apr 4 16:06:24 2008 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 04 Apr 2008 15:06:24 -0500 Subject: Any fancy grep utility replacements out there? In-Reply-To: References: Message-ID: samslists at gmail.com wrote: > Thanks to everyone who responded, and sorry for my late response. > > Grin seems like the perfect solution for me. I finally had a chance > to download it and play with it today. It's great. > > Robert...you were kind enough to ask if I had any requests. Just the > one right now of grepping through gzip files. If for some reason you > don't want to do it or don't have time to do it, I could probably do > it and send you a patch. But I imagine that since you wrote the code, > you could do it more elegantly than I could. I was hoping that the code would be understandable enough that it shouldn't matter who's modifying it. But I have a plane trip tomorrow; I'll take a stab at it. > P.S. Robert....this program totally deserves a real web page, not > just being buried in an svn repository. I spent a lot of time looking > for a tool like this that was written in python. I imagine others > have as well, and have simply given up. It will. Eventually. -- 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 From gagsl-py2 at yahoo.com.ar Thu Apr 10 02:46:52 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 03:46:52 -0300 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> <6641eaF2ics8jU1@mid.uni-berlin.de> <664j0pF2iji99U2@mid.uni-berlin.de> <89872ea1-dc03-4647-b0bc-9d316df3efb5@q1g2000prf.googlegroups.com> Message-ID: En Thu, 10 Apr 2008 02:59:24 -0300, escribi?: > I am getting the comments. So any one can post any comment like > Steve knows nothing of Python. > California has still lot to catch up to be at par with Mesopatamia. > comp.lang.python seems a group of fools. > Anyhow, all I learnt take whichever suits and ignore rest many people > have lot of time to carry out lot of nonsense. > Well I should have looked for a paid help and my stand about not > giving out my code in open forum stands as prolific. Better not lose > time unnecessarily going back to work and debugging the problems is > much sensical work that I can do instead of listening to jokes in the > morning!!!! I hope this whole thread is just a big misunderstanding, maybe a linguistic problem. Nobody wants to steal your work, but if you say "my code is slow, what's wrong with it?", nobody can give any useful answer if you don't post the code. That's what everyone is saying, it's just common sense, in California, Mesopotamia or Buenos Aires. Have a great life, -- Gabriel Genellina From robin at nibor.org Tue Apr 15 15:25:43 2008 From: robin at nibor.org (Robin Stocker) Date: Tue, 15 Apr 2008 21:25:43 +0200 Subject: Preferred method for "Assignment by value" In-Reply-To: <7047986d-f6cc-4189-81f6-47da1ecf1902@k1g2000prb.googlegroups.com> References: <6a3ed8f0-b82c-4cd3-b36e-1d94f8a30fe3@n1g2000prb.googlegroups.com> <7047986d-f6cc-4189-81f6-47da1ecf1902@k1g2000prb.googlegroups.com> Message-ID: <48050137.8020307@nibor.org> hall.jeff at gmail.com schrieb: > by changing temp = v[:] the code worked perfectly (although changing > temp.insert(0,k) to temp = [k] + temp also worked fine... I didn't > like that as I knew it was a workaround) So the for body now looks like this?: temp = v[:] temp.insert(0, k) finallist.append(temp) It can still be clarified and simplified to this (may also be faster): temp = [k] + v finallist.append(temp) Which one do you like better :)? Robin From steve at holdenweb.com Thu Apr 17 13:45:00 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 17 Apr 2008 13:45:00 -0400 Subject: Can't do a multiline assignment! In-Reply-To: References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> Message-ID: Marco Mariani wrote: > s0suk3 at gmail.com wrote: > >> Yes, it makes it more readable. And yes, it does make it (a lot) more >> maintainable. Mainly because I don't have those four variables, I have >> about thirty. And I think I won't need to one or two of them, but >> maybe all of them at once. > > have fun with locals(), then (but please feel dirty :-) > > loc = locals() > for var in [ > 'foo', # INSERT > 'bar', # COMMENT > 'baz' # HERE > ]: > loc[var] = 42 > And bear in mind there is an explicit notification of the danger of this course of action in the CPython documentation, which refuses to guarantee that changes made to the object returns by locals() will ve reflected in the local namespace. You have been warned. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From arnodel at googlemail.com Mon Apr 28 12:58:22 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Mon, 28 Apr 2008 17:58:22 +0100 Subject: Given a string - execute a function by the same name References: Message-ID: python at bdurham.com writes: > I'm parsing a simple file and given a line's keyword, would like to call > the equivalently named function. > > There are 3 ways I can think to do this (other than a long if/elif > construct): > > 1. eval() > > 2. Convert my functions to methods and use getattr( myClass, "method" ) > > 3. Place all my functions in dictionary and lookup the function to be > called 4. Put all my functions in a module and use getattr(module, 'function') -- Arnaud From bikthh at live.cn Sun Apr 13 03:15:30 2008 From: bikthh at live.cn (bikthh at live.cn) Date: Sun, 13 Apr 2008 00:15:30 -0700 (PDT) Subject: Where is the function of 'apply' always used? References: <84cefd1a-58de-485b-b00b-77218d2d054c@c19g2000prf.googlegroups.com> Message-ID: ??,????????????????????. From bob at passcal.nmt.edu Mon Apr 21 19:59:51 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Mon, 21 Apr 2008 17:59:51 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> <2008042115060816807-bob@passcalnmtedu> <2008042116511375249-bob@passcalnmtedu> <2008042117063950073-bob@passcalnmtedu> Message-ID: <2008042117595143658-bob@passcalnmtedu> On 2008-04-21 17:06:39 -0600, Bob Greschke said: > On 2008-04-21 16:51:13 -0600, Bob Greschke said: > JUST COMPLETELY IGNORE THAT LAST ONE. What a dope. Here: > > #! /usr/bin/env python > > from os import system > from struct import unpack > > print "unpack 1" > system("date") > for x in xrange(0, 100000000): > Value = unpack(">B", "a")[0] > if Value > 0x800000: > Value -= 0x1000000 > system("date") > print > > print "ord 1" > system("date") > for x in xrange(0, 100000000): > Value = ord("a") > if Value > 0x800000: > Value -= 0x1000000 > system("date") > print > > print "unpack 3" > system("date") > for x in xrange(0, 100000000): > Value1, Value2, Value3 = unpack(">BBB", "abc") > Value = (Value1 << 16)+(Value2 << 8)+Value3 > if Value > 0x800000: > Value -= 0x1000000 > system("date") > print > > print "ord 3" > system("date") > for x in xrange(0, 100000000): > Value = (ord("a") << 16)+(ord("b") << 8)+ord("c") > if Value > 0x800000: > Value -= 0x1000000 > system("date") > > > Still, the differences between unpack and ord are significant (I just > threw in the if's for fun). I just ran this on my SunBlade 1000 with 2.3.4 and unpack 1: 7m53s ord 1: 2m00s unpack 3: 14m20s ord 3: 5m30s timeit looks broken somehow to me. From ggpolo at gmail.com Tue Apr 22 23:15:13 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Wed, 23 Apr 2008 00:15:13 -0300 Subject: IDLE gripe and question In-Reply-To: <20080423005006.D40B81E4008@bag.python.org> References: <20080423005006.D40B81E4008@bag.python.org> Message-ID: 2008/4/22, Dick Moores : > I have IDLE 1.2.1, on Win XP, Python 2.5.1. > > The first time I use File | Open to open a script, the Open dialogue box > always opens at E:\Python25\Lib\idlelib. Here on Linux it opens at the directory from where idle was executed, so I can't exactly reproduce the problem. But.. > Most of the scripts I want to > access are in E:\PythonWork. There doesn't seem to be a way to change the > default folder to E:\PythonWork, but is there? you could open a bug report on bugs.python.org and request for this feature. Do you think using the directory of the last opened file opened would be good enough ? It already maintains the recent opened files so the first entry could be used for this new feature. > > Thanks, > > Dick Moores > > ================================ > UliPad <>: > http://code.google.com/p/ulipad/ > -- > http://mail.python.org/mailman/listinfo/python-list > -- -- Guilherme H. Polo Goncalves From steve at holdenweb.com Sun Apr 20 17:26:09 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 20 Apr 2008 17:26:09 -0400 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <480B94D1.6050907@gmail.com> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B52DE.8070105@holdenweb.com> <480B94D1.6050907@gmail.com> Message-ID: <480BB4F1.9080102@holdenweb.com> Hank @ITGroup wrote: > Steve Holden wrote: >> You are suffering from a pathological condition yourself: the desire >> to optimize performance in an area where you do not have any problems. >> I would suggest you just enjoy using Python and then start to ask >> these questions again when you have a real issue that's stopping you >> from getting real work done. >> >> regards >> Steve >> > Hi, Steve, > This not simply a pathological condition. My people are keeping trying > many ways to have job done, and the memory problem became the focus we > are paying attention on at this moment. > Could you please give us some clear clues to obviously call python to > free memory. We want to control its gc operation handily as we were > using J**A. Well, now you've told us a little more about your application I can understand that you need to be careful with memory allocation. The best thing you can do is to ensure that your program is reasonably decomposed into functions. That way the local namespaces have limited lifetimes, and only the values that they return are injected into the environment. You also need to be careful in exception processing that you do not cause a reference to the stack frame to be retained, as that can be a fruitful source of references to objects, rendering them non-collectable. You appear to be stressing the limits of a single program under present-day memory constraints. I am afraid that no matter how carefully you manage object references, any difference you can make is likely to be lost in the noise as far as memory utilization is concerned, and you may have to consider using less direct methods of processing your data sets. The gc module does give you some control over the garbage collector, but generally speaking most programs don't even need that much control. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bsk16 at case.edu Sun Apr 27 20:41:57 2008 From: bsk16 at case.edu (Benjamin Kaplan) Date: Sun, 27 Apr 2008 20:41:57 -0400 Subject: error: (10035, 'The socket operation... In-Reply-To: References: Message-ID: oops, forgot to post this to the list. sorry. On Sun, Apr 27, 2008 at 8:41 PM, Benjamin Kaplan wrote: > > On Sun, Apr 27, 2008 at 7:01 PM, Don Hanlen wrote: > > IDLE internal error in runcode() > > Traceback (most recent call last): > > File "C:\PYTHON25\lib\idlelib\rpc.py", line 235, in asyncqueue > > self.putmessage((seq, request)) > > File "C:\PYTHON25\lib\idlelib\rpc.py", line 332, in putmessage > > n = self.sock.send(s[:BUFSIZE]) > > error: (10035, 'The socket operation could not complete without > > blocking') > > > > Does this look familiar to anyone? I can't figure out what to do > > about it. Python 2.5, windoze. I get it when I execute a Tkinter op > > that works elsewhere. > > > > changing this: > > > > t = self.b.create_text( > > (point.baseX + 1)*self.checkerSize/2 + fudge, > > y + fudge, > > text = str(point.occupied), > > width = self.checkerSize) > > > > to > > > > t = self.b.create_text( > > (point.baseX + 1)*self.checkerSize/2 + fudge, > > y + fudge, > > text = str(point.occupied), > > font=("Times", str(self.checkerSize/2), "bold"), > > width = self.checkerSize) > > > > for example. The same code works fine elsewhere. I thought I'd ask > > here before I try (no clue) increasing BUFSIZE in rpc.py? I'm not > > crazy about tinkering with code I have no clue about.. > > -- > > don > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > It might have something to do with the fact that IDLE uses Tkinter, > but, having never used it myself, I'm not sure. > From sjmachin at lexicon.net Wed Apr 9 20:33:22 2008 From: sjmachin at lexicon.net (John Machin) Date: Wed, 9 Apr 2008 17:33:22 -0700 (PDT) Subject: I am worried about Python 3 References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> Message-ID: <46d2ec83-9068-4cc6-a16d-961d031da720@k1g2000prb.googlegroups.com> On Apr 10, 8:12 am, "Terry Reedy" wrote: > "jmDesktop" wrote in message > > news:77c208d1-8163-4acf-8e88-bd704e05bc04 at e39g2000hsf.googlegroups.com... > | Two new versions of the language are currently in development: version > | 2.6, which retains backwards compatibility with previous releases; and > | version 3.0, which breaks backwards compatibility to the extent that > | even that simplest of programs, the classic 'Hello, World', will no > | longer work in its current form. > > That change is however, the one most immediately visible to new > programmers. Most of the other statements are pretty much unchanged. In > any case, 'print' is an easy-to-use facade over sys.stdout.write(), with > default formatting. If really concerned about it, start programs with > import sys > write = sys.stdout.write > and use that to write out explicitly formatted strings. (Some people > routinely do this for production code anyway.) > > tjr Some C tragics do things like this, which appear to be 3.0-proof: def fprintf(f, fmt, *vargs): f.write(fmt % vargs) Cheers, John From gagsl-py2 at yahoo.com.ar Mon Apr 7 02:00:08 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 07 Apr 2008 03:00:08 -0300 Subject: how to do "load script; run script" in a loop in embedded python? References: <352f4111-94b5-4aa9-917b-90cd56a5f7d6@s8g2000prg.googlegroups.com> Message-ID: En Thu, 03 Apr 2008 20:52:31 -0300, escribi?: > Hi, all, > > I am currently involved in a project that needs to load/run a python > script dynamically in a C application. The sample code is as > following: > > PyObject *LoadScript(char *file, char *func) > { > PyObject *pName, *pModule, *pDict, *pFunc; > > pName = PyString_FromString(file); > pModule = PyImport_Import(pName); > pDict = PyModule_GetDict(pModule); > pFunc = PyDict_GetItemString(pDict, func); > return pFunc; > } Remember to check all PyObject* return values, NULL means there was an error. And pay attention to reference counts! Read the section about reference counts in both books, Extending and Embedding, and the Python API Reference. http://docs.python.org/ > The first loop is perfectly ok, but on the second loop, script loading > is successful but running will always fail. "fail" in what form? A Python exception? The program freezes? A core dump? -- Gabriel Genellina From carlwuhwdmckay at gmail.com Sat Apr 26 09:36:03 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:36:03 -0700 (PDT) Subject: num-lock serial crack keygen Message-ID: <3d1e4ae9-fa1c-4c89-94fc-724ddc9cba78@x41g2000hsb.googlegroups.com> num-lock serial crack keygen http://cracks.00bp.com F R E E C R A C K S From inq1ltd at inqvista.com Sun Apr 6 20:41:05 2008 From: inq1ltd at inqvista.com (jim-on-linux) Date: Sun, 06 Apr 2008 20:41:05 -0400 Subject: Tkinter, repaint?, keep size? In-Reply-To: <200804062012.01208.inq1ltd@inqvista.com> References: <6ff2ce5f-9ba3-492c-b062-324c91e652a0@e10g2000prf.googlegroups.com> <200804062012.01208.inq1ltd@inqvista.com> Message-ID: <200804062041.05813.inq1ltd@inqvista.com> On Sunday 06 April 2008 20:12, jim-on-linux wrote: > On Sunday 06 April 2008 13:24, > > skanemupp at yahoo.se wrote: > > so my calculator is almost done for u > > that have read my previous posts. > > i have some minor problems i have to fix > > though. > > > > *one is i need to repaint once i have > > performed a calculation so that the old > > results are not left on the screen. cant > > find a method for that. > > you can use "wigit".update(). > The update method update will redraw > wigits as necessary. If you have the > state of the wigit set to DISABLE then set > it to ACTIVE before using .update(). > > > *another is now when i write the > > expression to be evaluated it resizes > > the window as the text grows. > > i want the windowsize and all the > > buttonplacements stay constant, how do > > i achieve this? > > I like to make a separate frame for > buttons. > > master = Tk() > master.title =('My Project') > > buttonFrame = Frame(master) > buttonFrame.grid(row = 0 column = 1) > > you could use a dictionary that contains > the the text and the command and loop the > key to build the buttons. Make x = x+1, y > = y+1 for row and column or otherwise as > you need. > If you loop the button you should provide a unique name for each button such as name = name+str(x) > button = Button(buttonframe, text = key, > width = 2) > button1.grid(row = x, column = y, sticky = > NSEW) > > put other stuff into the master using > another frame and grid it in some other > column and or row. > > If you make all buttons the same size > inside the frame they will keep their size > even if you have more text then the button > will hold. > > There is a lot more but this is the way I > would proceed. > > jim-on-linux http://www.inqvista.com From javainthinking at gmail.com Wed Apr 2 11:27:58 2008 From: javainthinking at gmail.com (Dolphin.o0O...) Date: Wed, 2 Apr 2008 23:27:58 +0800 Subject: Hello, everybody! Message-ID: C++ Java Python All of them are critical! -- Best regards. Yours sincerely, Dolphin.o0O... ~~~~~~~~~~~~~~~~~~~~~~~~~~ Dedicate in what you love so much! Dolphin.o0O.... ~~~~~~~~~~~~~~~~~~~~~~~~~~ -------------- next part -------------- An HTML attachment was scrubbed... URL: From deets at nospam.web.de Tue Apr 15 17:18:54 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 15 Apr 2008 23:18:54 +0200 Subject: webcam (usb) access under Ubuntu In-Reply-To: References: <66jlk1F2ju6c8U1@mid.uni-berlin.de> Message-ID: <66kkedF2l526dU2@mid.uni-berlin.de> Berco Beute schrieb: > Thanks, that would be great. Here you go. http://roggisch.de/vidio.tgz Diez From pavlovevidence at gmail.com Mon Apr 21 10:29:31 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 21 Apr 2008 07:29:31 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: On Apr 21, 9:20 am, a... at pythoncraft.com (Aahz) wrote: > In article , > Carl Banks wrote: > > > > >On Apr 20, 10:57 pm, a... at pythoncraft.com (Aahz) wrote: > >> In article , > >> Carl Banks wrote: > >>>On Apr 17, 3:37 am, Jonathan Gardner > >>>wrote: > > >>>> Using 100% of the CPU is a bug, not a feature. > > >>>No it isn't. That idea is borne of the narrowmindedness of people who > >>>write server-like network apps. What's true for web servers isn't > >>>true for every application. > > >> Only when you have only one application running on a machine. > > >Needless pedantry. > > >"Using 100% of the CPU time a OS allow a process to have is not > >necessarily a bug." Happy? > > Not really; my comment is about the same level of pedantry as yours. > Jonathan's comment was clearly in the context of inappropriate CPU usage > (e.g. spin-polling). That's far from evident. Jonathan's logic went from "I'm using 100% CPU" to "You must be spin-polling". At best, Jonathan was making some unsupported assumptions about the type of program sturlamolden had in mind, and criticized him based on it. But frankly, I've seen enough people who seem to have no conception that anyone could write a useful program without an I/O loop that it wouldn't surprise me it he meant it generally. > Obviously, there are cases where hammering on the > CPU for doing a complex calculation may be appropriate, but in those > cases, you will want to ensure that your application gets as much CPU as > possible by removing all unnecessary CPU usage by other apps. Nonsense. If I'm running a background task on my desktop, say formating a complex document for printing, I would like it to take up as much of CPU as possible, but still have secondary priority to user interface processes so that latency is low. Carl Banks From gagsl-py2 at yahoo.com.ar Fri Apr 4 02:56:37 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 04 Apr 2008 03:56:37 -0300 Subject: regarding memoize function References: <94a9e7e6-a623-4783-81da-f69654e51349@e10g2000prf.googlegroups.com> <80ee9d89-12a1-4534-be50-ac4614c28bc2@l42g2000hsc.googlegroups.com> Message-ID: En Fri, 04 Apr 2008 02:24:14 -0300, escribi?: > On Apr 3, 8:04?pm, "Gabriel Genellina" wrote: >> En Thu, 03 Apr 2008 21:21:11 -0300, Dan Bishop ? >> escribi?: >> > On Apr 3, 6:33 pm, ankitks.mi... at gmail.com wrote: >> >> I saw example of memoize function...here is snippet >> >> >> def memoize(fn, slot): >> >> ? ? ? ?def memoized_fn(obj, *args): >> >> ? ? ? ? ? ? if hasattr(obj, slot): >> >> ? ? ? ? ? ? ? ? return getattr(obj, slot) >> >> ? ? ? ? ? ? else: >> >> ? ? ? ? ? ? ? ? val = fn(obj, *args) >> >> ? ? ? ? ? ? ? ? setattr(obj, slot, val) >> >> ? ? ? ? ? ? ? ? return val >> >> ? ? ? ?return memoized_fn >> > Thanks Gabriel and Dan, > But I am still confuse on... > what is obj? > > Let say > def f(node): return max(node.path_cost+h(node), getattr(node, 'f', - > infinity)) > f = memoize(f,'f') > > what is this doing? > I am passing string 'f' as second argument? right? so evertime in > function memoize, > I am doing hasattr(obj, slot), I am saying hasattr(obj, 'f')? > > I kindof understand that I am returning maximum of pre-computed > value(if there is already) vs. new calculation. > But syntax is throwing me off. It *is* confusing. And a bit strange that it does not use the args argument as a key (if it is true that f(*args) doesn't depend on args, why using args in the first place?) You may be calling f as f(a,b,c) or as a.f(b,c) - in both cases, obj is `a`, the first argument (or "self" when used as a method) An alternative version (with the same limitations with regard to *args) but usable as a mehtod decorator: from functools import wraps def memoize(slot): def decorator(fn, slot=slot): @wraps(fn) def inner(self, *args): if hasattr(self, slot): return getattr(self, slot) else: val = fn(self, *args) setattr(self, slot, val) return val return inner return decorator class Foo(object): def __init__(self, items): self.items = tuple(items) @memoize('max') def hardtocompute(self): return max(self.items) a = Foo((10,20,30)) assert not hasattr(a,'max') assert a.hardtocompute()==30 assert a.max==30 del a.items assert a.hardtocompute()==30 There is an excelent article by Michele Simionato explaining decorators with some useful recipes. http://www.phyast.pitt.edu/~micheles/python/documentation.html -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Wed Apr 2 18:04:30 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 02 Apr 2008 19:04:30 -0300 Subject: generator functions: why won't this work? References: <19359dad-3022-4e83-99e4-8f8093116bcb@a1g2000hsb.googlegroups.com> Message-ID: En Wed, 02 Apr 2008 14:11:30 -0300, escribi?: > On Apr 1, 10:42?pm, "Gabriel Genellina" > wrote: >> En Tue, 01 Apr 2008 23:56:50 -0300, escribi?: >> >> ? ?yield *iterable >> >> could be used as a shortcut for this: >> >> ? ?for __temp in iterable: yield __temp > > How serious were you about that? Not so much, I haven't thougth enough on it. Looks fine in principle, but yield expressions may be a problem. -- Gabriel Genellina From sierra9162 at gmail.com Wed Apr 16 11:25:21 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:25:21 -0700 (PDT) Subject: kate hudson son Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From chengiz at my-deja.com Sat Apr 19 10:43:16 2008 From: chengiz at my-deja.com (chengiz at my-deja.com) Date: Sat, 19 Apr 2008 07:43:16 -0700 (PDT) Subject: Kill an OS process from script (perhaps unix specific) Message-ID: <7cd7208f-777b-4264-8d34-3c4bf3377940@a22g2000hsc.googlegroups.com> Hi, I'm trying to run a process from a python script. I need the exit status of that process but do not care about its output, so until now was using os.system(). But it turned out that the process often went into an infinite loop, so I wrote a SIGALRM handler. Unfortunately the code I came up with is quite kludgy: import subprocess ... try: p = subprocess.Popen(..., shell = True) pid = p.pid os.waitpid(pid...) ... except ...: # Thrown by alarm signal handler os.kill(pid + 1) # "Real" pid = shell pid + 1 ... The os.kill is very hacky and unsafe so I was looking for better ideas. Any help will be greatly appreciated. Thanks! From bruno.desthuilliers at gmail.com Sat Apr 19 12:01:29 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Sat, 19 Apr 2008 09:01:29 -0700 (PDT) Subject: Metaprogramming Example References: <930643c6-2d56-4fb0-aee0-a3e79231f09b@24g2000hsh.googlegroups.com> <32472b97-f35a-4408-96f5-2f8c8f92ae56@m73g2000hsh.googlegroups.com> <39325652-e0cf-4efd-9b28-00c0fe8552cc@m73g2000hsh.googlegroups.com> <562bae18-7b8e-4863-8923-0e5a01ba7125@t54g2000hsg.googlegroups.com> <48086036$0$759$426a74cc@news.free.fr> Message-ID: <480f371e-3957-4787-b3cd-0c00f4754a02@f36g2000hsa.googlegroups.com> On 19 avr, 16:34, andrew cooke wrote: > On Apr 18, 4:48 am, Bruno Desthuilliers wrote: > > [...] > > > Practically, this means that (amongst other niceties) : > > - you can define functions outside classes and use them as instance or > > class methods > > - you can add/replaces methods dynamically on a per-class or > > per-instance basis > > - you can access the function object of a method and use it as a function > > - you can define your own callable types, that - if you implement the > > appropriate support for the descriptor protocol - will be usable as > > methods too > > ok, that's convincing (i had thought the majority of these were > already > possible, albeit with some kind of hard-coded "magic" behind the > scenes). Yep, the whole point is that it's not that hard-coded anymore. Python exposes most of it's inner mechanisms, so that you can taylor quite a lot of things to your needs. This is quite useful for writing clean frameworks needing very few boilerplate in the user code. > [...] > > > > by referring to the titanic > > > i didn't mean that python was a disaster, rather that the "iceberg" is > > > still there (i am not 100% sure what the iceberg is, but it's > > > something > > > to do with making namespaces explicit in some places and not others). > > > I guess you're thinking of the self argument, declared in the function's > > signature but not "explicitly passed" when calling the method ? > > not really. more to do with when namespaces (i am not sure i have the > right term - the dictionary that provides the mapping from name to > object) > are explicit or implicit. for example, python has closures (implicit > lookup) and "self" (explicit lookup). > > but as i said, i don't have a clear argument - something just feels > "odd". > at the same time, i know that language design is a practical business > and so this is probably not important. The fact is that everything you do with closures can be done with objects. OTHO, there are quite a lot of cases where defining a specific class would be just way too heavy, and a closure is much more lightweight. So yes, it's a matter of "practicality beats purity". While trying to remain as clean as possible, Python is definitively a practical language. > finally, thank you for pointing me to sql alchemy (i think it was > you?). Seems so. > it really is excellent. Indeed !-) From jywlsn at comcast.net Mon Apr 14 03:55:40 2008 From: jywlsn at comcast.net (J Wilson) Date: Mon, 14 Apr 2008 02:55:40 -0500 Subject: How to get the version of a file Message-ID: Does anyone know how to get the version of an application on OS X (i.e. the version string that appears in the "Version" field in the "Get Info" window for an application)? I'm running OS 10.4.11, python 2.5. From NikitaTheSpider at gmail.com Tue Apr 22 10:54:00 2008 From: NikitaTheSpider at gmail.com (Nikita the Spider) Date: Tue, 22 Apr 2008 10:54:00 -0400 Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> Message-ID: In article <7e595409-be62-4b8c-9819-a14cd363d751 at c65g2000hsa.googlegroups.com>, azrael wrote: > Which big aplications are written in python. I see its development, > But i can't come up with a big name. I know that there are a lot of > companys using python, but is there anythong big written only in > python. I want him to fuck of with his perl once and for all time Why are either of you so emotionally attached to the tools you use? I don't know your friend, but my guess is that he's not interested in a logical argument, so he won't be impressed even if you claim that God himself wrote the Universe in Python. I think he enjoys saying this stuff simply because you react to it. It's pretty sad that he can't find something better to do with his time. If Python works for you and Perl for your friend, you can each keep using the tool you prefer and be happy about it. In the meantime you might want to look for some friends that don't find your anger and frustration entertaining. -- Philip http://NikitaTheSpider.com/ Whole-site HTML validation, link checking and more From harvey.thomas at informa.com Tue Apr 29 10:50:46 2008 From: harvey.thomas at informa.com (harvey.thomas at informa.com) Date: Tue, 29 Apr 2008 07:50:46 -0700 (PDT) Subject: Issue with regular expressions References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Message-ID: On Apr 29, 2:46?pm, Julien wrote: > Hi, > > I'm fairly new in Python and I haven't used the regular expressions > enough to be able to achieve what I want. > I'd like to select terms in a string, so I can then do a search in my > database. > > query = ' ? " ?some words" ?with and "without ? ?quotes ? " ?' > p = re.compile(magic_regular_expression) ? $ <--- the magic happens > m = p.match(query) > > I'd like m.groups() to return: > ('some words', 'with', 'and', 'without quotes') > > Is that achievable with a single regular expression, and if so, what > would it be? > > Any help would be much appreciated. > > Thanks!! > > Julien You can't do it simply and completely with regular expressions alone because of the requirement to strip the quotes and normalize whitespace, but its not too hard to write a function to do it. Viz: import re wordre = re.compile('"[^"]+"|[a-zA-Z]+').findall def findwords(src): ret = [] for x in wordre(src): if x[0] == '"': #strip off the quotes and normalise spaces ret.append(' '.join(x[1:-1].split())) else: ret.append(x) return ret query = ' " Some words" with and "without quotes " ' print findwords(query) Running this gives ['Some words', 'with', 'and', 'without quotes'] HTH Harvey From bearophileHUGS at lycos.com Tue Apr 8 18:21:19 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Tue, 8 Apr 2008 15:21:19 -0700 (PDT) Subject: Data structure recommendation? References: <1adc3541-7775-4938-bd5a-953dd041656c@2g2000hsn.googlegroups.com> Message-ID: More bits from your code: neighbours = list() ==> neighbours = [] If you have a recent enough version of Python you can use: candidate_is_neighbour = any(distance < n[1] for n in neighbours) Instead of: candidate_is_neighbour = bool([1 for n in neighbours if distance < n[1]]) It's shorter & simpler, and it stops as soon as it finds a true condition. Bye, bearophile From tim.arnold at sas.com Tue Apr 8 13:03:06 2008 From: tim.arnold at sas.com (Tim Arnold) Date: Tue, 8 Apr 2008 13:03:06 -0400 Subject: set file permission on windows Message-ID: hi, I need to set file permissions on some directory trees in windows using Python. When I click on properties for a file and select the 'Security' tab, I see a list of known 'Group or user names' with permissions for each entry such as Full Control, Modify, Read&Execute, etc. I need to (for example) periodically set Group Permissions for one group to Read, and another Group to None. I need to apply the settings to several directory trees recursively. If this was on Unix, I'd just use os.stat I guess. I don't think that will work in this case since all I know is the Group names and the permissions I need to allow. thanks for any pointers, --Tim Arnold From juergen.perlinger at t-online.de Sun Apr 20 15:53:32 2008 From: juergen.perlinger at t-online.de (Juergen Perlinger) Date: Sun, 20 Apr 2008 21:53:32 +0200 Subject: What happened with python? messed strings? References: Message-ID: algaba at droog.sdf-eu.org wrote: > > Hi, > I used extensively python and now I find this mess with strings, > I can't even reproduce tutorial examples: >>>> "apfel".encode('utf-8') (it was with umlaut) > File "", line 0 > > ^ > SyntaxError: 'ascii' codec can't decode byte 0xc4 in position 1: > ordinal not in range(128) >>>> > Is there any good guide to this mess of codecs and hell ? > > python should have stayed at version 1.5, every single 'improvement' > has been a mess. But this is the definitive hell. > > thanks! > Basically you're not using ASCII encoding in your source text... You need to define an encoding for your source if you're using german umlauts or other fancy stuff. See chapter 2.1.4 of the reference manual, and add e.g. # -*- coding: utf-8 -*- as first or second line to your script. Make sure your editor talks utf-8, or use the encoding used by your editor. cp1552 is a good choice for windows... -- juergen 'pearly' perlinger "It's hard to make new errors!" From john00587 at gmail.com Mon Apr 21 01:42:24 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:42:24 -0700 (PDT) Subject: cracks in skin caused by medication Message-ID: cracks in skin caused by medication http://cracks.00bp.com F R E E C R A C K S From gruszczy at gmail.com Wed Apr 23 05:52:28 2008 From: gruszczy at gmail.com (=?UTF-8?Q?Filip_Gruszczy=C5=84ski?=) Date: Wed, 23 Apr 2008 11:52:28 +0200 Subject: Explicit variable declaration In-Reply-To: <1506f165-7f86-4dc7-aa29-6488eda9ae7f@l64g2000hse.googlegroups.com> References: <1506f165-7f86-4dc7-aa29-6488eda9ae7f@l64g2000hse.googlegroups.com> Message-ID: <1be78d220804230252n4faa34e6v90b482080750e0cb@mail.gmail.com> > You mean the type? Not in 2.x, but in 3.x, there are function > annotations: > > def a_function(arg1: int, arg2: str) -> None: pass Nope, I don't like types ;-) 3.x seems pretty revolutionary, and this typing can be appreciated by some people. > Declaring what about them? If you mean declaring the type, remember > that Python deliberately allows any name to be bound to any object; > type declarations can't be enforced without losing a lot of the power > of Python. Just declaring, that they exist. Saying, that in certain function there would appear only specified variables. Like in smalltalk, if I remember correctly. -- Filip Gruszczy?ski From dhubleizh at o2.pl Tue Apr 22 08:02:21 2008 From: dhubleizh at o2.pl (=?iso-8859-2?q?Cezary_Krzy=BFanowski?=) Date: Tue, 22 Apr 2008 14:02:21 +0200 Subject: Remove multiple inheritance in Python 3000 References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> Message-ID: Dnia Tue, 22 Apr 2008 04:07:01 -0700, GD napisa?(a): > Please remove ability to multiple inheritance in Python 3000. > Please send me 1 mln $. I've always wanted to be rich and furthermore, I've got a lot of plans and ideas how to spend that cash. > I also published this request at http://bugs.python.org/issue2667 I'll be not publishing the bug, as I don't want to leave trace, so that I don't have to pay taxes. With regards, Cz at rny From vijayakumar.subburaj at gmail.com Mon Apr 14 04:00:05 2008 From: vijayakumar.subburaj at gmail.com (v4vijayakumar) Date: Mon, 14 Apr 2008 01:00:05 -0700 (PDT) Subject: Game design : Making computer play References: Message-ID: On Apr 14, 12:35 pm, Richard Heathfield wrote: > v4vijayakumar said: > > In computer based, two player, board games, how to make computer play? > > Write some code that works out what the computer player should do. If you > want a better answer, ask a better question. I am just implementing a game played in my village (Tamilnadu / India), called "aadupuli" (goats and tigers). There are only 23 positions and 18 characters (15 goats and 3 tigers). Some of you might be aware of this. I can post initial version of the game (implemented using html/ javascript) in couple of hours here. Welcome any help in making computer to play one of these player. From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 11 08:26:23 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 11 Apr 2008 14:26:23 +0200 Subject: from __future__ import print In-Reply-To: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> References: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> Message-ID: <47ff58e9$0$20006$426a74cc@news.free.fr> samslists at gmail.com a ?crit : > Am I the only one that thinks this would be useful? :) > > I'd really like to be able to use python 3.0's print statement in > 2.x. FWIW, the whole point is that in 3.0, print stop being a statement to become a function... From pranny at gmail.com Wed Apr 2 13:51:39 2008 From: pranny at gmail.com (pranav) Date: Wed, 2 Apr 2008 10:51:39 -0700 (PDT) Subject: Understanding bmp image files Message-ID: <2537c458-b4d5-480d-8407-168a2b59a27e@u10g2000prn.googlegroups.com> Hello, I want to read a BMP file, do some processing and then write it in a new file. The problem is in the third step. For reading the file, i have converted the file into decimal numbers, representing the pixel values. Then i perform calculations on those decimal numbers. Now i am unable to convert those into the format as required by the "bmp" file. Any one, who is into image reading/manipulation, please help. From nagle at animats.com Fri Apr 25 10:53:34 2008 From: nagle at animats.com (John Nagle) Date: Fri, 25 Apr 2008 07:53:34 -0700 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. In-Reply-To: <7xzlrj14r7.fsf@ruckus.brouhaha.com> References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> <480fa6e3$0$34491$742ec2ed@news.sonic.net> <7xzlrj14r7.fsf@ruckus.brouhaha.com> Message-ID: <4811edad$0$34525$742ec2ed@news.sonic.net> Paul Rubin wrote: > Paul Boddie writes: >> simple Python-only modules, all you'd really need to do to prove the >> concept is to develop the client-side Windows software (eg. apt-get >> for Windows) which downloads package lists, verifies signatures, and >> works out where to put the package contents. ... > > I thought the Windows "solution" to this was Authenticode, which is a > scheme for signing executables against certificates similar to those > used on SSL web sites. Of course there's been at least one notorious > forgery, but typical Linux distro repositories are probably not all > that secure either. > > In the case of a pure Python program like Beautiful Soup, I certainly > think any installation needing running code should be done by > distutils included in the Python distro. Yes. Perl has CPAN, which is reasonably comprehensive and presents modules in a uniform way. If you need a common Perl module that's not in the Perl distro, it's probably in CPAN. "Installing a new module can be as simple as typing perl -MCPAN -e 'install Chocolate::Belgian'." So Perl has exactly that. Python's Cheese Shop is just a list of links to packages elsewhere. There's no uniformity, no standard installation, no standard uninstallation, and no standard version control. John Nagle From wuwei23 at gmail.com Tue Apr 15 20:12:03 2008 From: wuwei23 at gmail.com (alex23) Date: Tue, 15 Apr 2008 17:12:03 -0700 (PDT) Subject: how to remove \n in the list References: <2ba667ab-6818-47eb-8595-79ed970728f7@q1g2000prf.googlegroups.com> Message-ID: On Apr 16, 9:26 am, Yves Dorfsman wrote: > If we do: > lines[:] = [line.rstrip('\n') for line in lines] > > We reuse an existing list, therefore we are saving the time it takes to > create a new list ? So this is a performance issue ? I think it's more of a reference issue. You may have other labels already pointing to 'lines', if you want them to refer to the same, rstrip'd list, you'd do an in-place update like this. - alex23 From skanemupp at yahoo.se Thu Apr 10 12:36:38 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 09:36:38 -0700 (PDT) Subject: Tkinter, resize window, keep widgets relative placements? Message-ID: <6a656935-7c32-454c-ab72-30e7d7e84b40@u12g2000prd.googlegroups.com> the code is down below. when i click maximize window it looks terrible since the widgets are not keeping their relative size. i guess i could use pack or grid to do that instead of place? but i tried with pack and grid before and had trouble making it looking good. is it possible to have the minimized window just being placed in the middle without the distance between the buttons and entrys being enlonge>? from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") l = Label(mygui, text="Answer: ") l.place(relx=0.15, rely=0.2, anchor=CENTER) e = Entry(mygui) e.place(relx=0.48, rely=0.1, anchor=CENTER, width=173) c = Entry(mygui) c.place(relx=0.6, rely=0.2, anchor=CENTER) def Disp(nstr): e.insert(INSERT, nstr) def Calc(): expr=e.get() c.delete(0, END) try: c.insert(END, eval(expr)) except: c.insert(END, "Not computable") def Erase(): e.delete(0,END) c.delete(0, END) def Backspace(): a=len(e.get()) e.delete(a-1,END) #e.delete(INSERT, END) #e.delete(ANCHOR,END) x = 0.1 y = 0.4 for char in '123+456-789*0()/.': b = Button(mygui, text=char, command=lambda n=char:Disp(n), width=2, height=1) b.place(relx=x, rely=y, anchor=CENTER) x=x+0.1 if x==0.5: x=0.1 y=y+0.1 b = Button(mygui, text="^", command=lambda n="**":Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.8, anchor=CENTER) b = Button(mygui, text="C",command=Erase, width=2, height=1) b.place(relx=0.3, rely=0.8, anchor=CENTER) b = Button(mygui, text="c",command=Backspace, width=2, height=1) b.place(relx=0.4, rely=0.8, anchor=CENTER) b = Button(mygui, text="=",command=Calc, width=12, height=1) b.place(relx=0.25, rely=0.9, anchor=CENTER) mygui.mainloop() From deets at nospam.web.de Thu Apr 10 05:43:46 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 10 Apr 2008 11:43:46 +0200 Subject: urgent question, about filesystem-files References: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> <47FDD27E.1040204@islandtraining.com> <36e8a7020804100200m6c3a9a41h1ed3021b70f8a829@mail.gmail.com> <36e8a7020804100201x5cf16377gfedddc8647fe8e3a@mail.gmail.com> Message-ID: <6665rfF2j5ohkU1@mid.uni-berlin.de> bvidinli wrote: > this is for ensuring that file is not in use, ... > by any process ?in system.... How do you prevent the other processes that *might* access that file from doing so while *you* work on it? unless they cooperate using file-locks, you might end up with garbage. Diez From aladameh at gmail.com Wed Apr 2 03:09:55 2008 From: aladameh at gmail.com (Ramsey Nasser) Date: Wed, 2 Apr 2008 10:09:55 +0300 Subject: the scaling of pics in pygame In-Reply-To: <3de70275-c4d6-46f8-9700-17503a606c84@d62g2000hsf.googlegroups.com> References: <49d8b8ae-08e3-4e86-9ced-2804b6dec4e5@b5g2000pri.googlegroups.com> <3de70275-c4d6-46f8-9700-17503a606c84@d62g2000hsf.googlegroups.com> Message-ID: <76f39e0e0804020009s7211a0d5m1c5717a992d2a72f@mail.gmail.com> Isn't PIL best suited for things like this? The resize function should do what you're looking for: http://www.pythonware.com/library/pil/handbook/image.htm On Wed, Apr 2, 2008 at 6:59 AM, wrote: > On Apr 1, 9:44 pm, Jimmy wrote: > > Hi, everyone > > > > I am using Pygame to write a small program. I tried to load a .jpg > > picture into > > the screen, however, the size of the pic doesn't fit into the window > > properly. Can > > anyone tell me how to scale the picture into the window? > > You might get a quicker answer at pygame.org - check the mailing list > and/or docs. > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- nasser From mal at egenix.com Wed Apr 30 06:18:36 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Wed, 30 Apr 2008 12:18:36 +0200 Subject: Problem with variables assigned to variables??? In-Reply-To: References: Message-ID: <4818477C.5010308@egenix.com> On 2008-04-30 07:25, grepla at gmail.com wrote: > I have a simple line of code that requires the following inputs - an > input file, output file and a SQL expression. the code needs to be > run with several different SQL expressions to produce multiple output > files. To do this I first created a list of a portion of the output > filename: > mylist = ('name1', 'name2', 'name3') > > I also assigned variables for each SQL expression: > name1 = "\"field_a\" LIKE '021'" > name2 = "\"field_a\" LIKE '031'" > name3 = "\"field_a\" LIKE '041'" > > Notice the variable names are the same as the listmember strings, that > is intentional, but obviously doesn't work. > > the loop: > for listmember in mylist: > print listmember + ".shp", listmember > > my intended output is: > name1.shp "field_a LIKE '021' > name2.shp "field_a LIKE '031' > name3.shp "field_a LIKE '041' > > but, of course, the variable listmember returns the name of the > listmember which makes perfect sense to me: > name1.shp name1 > > So how can I iterate not only the filenames but the SQL expressions as > well? The Python way to do this would be to take two lists, one with the filenames and one with the SQL, and then iterate over them in parallel: for filename, sql_snippet in zip(filenames, sql_snippets): ... (there are also a couple of ways to use iterators to do the same) If you just want to get you code to work, use this: for listmember in mylist: print listmember + ".shp", locals()[listmember] -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 30 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From spe.stani.be at gmail.com Wed Apr 9 16:19:49 2008 From: spe.stani.be at gmail.com (SPE - Stani's Python Editor) Date: Wed, 9 Apr 2008 13:19:49 -0700 (PDT) Subject: Stani's python ide 'spe' editor problem References: Message-ID: <297b9940-8f49-4057-a9cf-a0345d20901e@q24g2000prf.googlegroups.com> Did you try to remove the .spe folder from your c:\Documents & Settings \username folder? Stani On Apr 9, 6:16?pm, Rick King wrote: > Hi everyone, > The editor inspeon my system (win XP home sp2) does not do automatic > indentation..... I can't figure out why - it used to. I'm set up with > subversion so I have the very latest stuff from Stani. It's amazing how > not having automatic indentation can make working in the ide such a pain. > > This has been going on for a while (like a few years), and the situation > is deteriorating - used to be that the indentation would work for a > while after restarting my system and then stop (until the next restart). > Now, with his latest stuff, it doesn't work at all. > > Because it used to reset with a restart, it must have something to do > with a dll, like the scintilla editor dll? But that's kind of hard to > believe: why would the editor dll care about indentation? > > Anyway, I am extremely frustrated. I've tried other ide's: pythonwin (I > found it inadequate for my purposes - why is a command line prompt > displayed in a dialog window?) - eclipse (editor is just ok, shell does > not have command history(!), and then *really* funky things started > happening that I could not explain and so had to stop using it) - idle > is good for small things and ok for larger projects but limited in general. > > I really likespeand want to continue using it. Stani himself seems > pretty unreachable. > > Does anyone have a clue for me about what the issue is? Is no one else > using this great ide? Or is no one else having this problem? > > Thanks for any help. > -Rick King > Southfield MI From sturlamolden at yahoo.no Thu Apr 24 23:27:32 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 20:27:32 -0700 (PDT) Subject: ctypes: return a pointer to a struct References: <846077c3-beaf-4ccd-83be-1e2168c4f7fe@c65g2000hsa.googlegroups.com> Message-ID: <4dda2bd7-3348-496e-a594-35da0a34d4de@x35g2000hsb.googlegroups.com> On Apr 25, 5:15 am, sturlamolden wrote: > First define a struct type IP2LocationRecord by subclassing from > ctypes.Structure. Then define a pointer type as > ctypes.POINTER(IP2LocationRecord) and set that as the function's > restype attribute. See the ctypes tutorial or reference for details. Which is to say: import ctypes class IP2LocationRecord(ctypes.Structure): _fields_ = [ ('country_short', ctypes.c_char_p), ('country_long', ctypes.c_char_p), ('region', ctypes.c_char_p), ('city', ctypes.c_char_p), ('isp', ctypes.c_char_p), ('latitude', ctypes.c_float), ('longitude', ctypes.c_float), ('domain', ctypes.c_char_p), ('zipcode', ctypes.c_char_p), ('timezone', ctypes.c_char_p), ('netspeed', ctypes.c_char_p), ] IP2LocationRecord_Ptr_t = ctypes.POINTER(IP2LocationRecord) function.restype = IP2LocationRecord_Ptr_t From gagsl-py2 at yahoo.com.ar Sat Apr 12 22:51:36 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 12 Apr 2008 23:51:36 -0300 Subject: String Literal to Blob References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> Message-ID: En Sat, 12 Apr 2008 22:14:31 -0300, Jason Scheirer escribi?: > On Apr 12, 2:44 pm, Steve Holden wrote: >> Victor Subervi wrote: >> > Well, as I mentioned before, I am sending text/html because the page, >> > like almost all web pages, has a whole lot more content than just >> > images. Or, perhaps you are suggesting I build my pages in frames, and >> > have a frame for every image. Unsightly! >> >> Dear Victor: >> >> If you cannot understand, after being told several times by different >> people, that pages with images in them are achieved by multiple HTTP >> requests, then there is little I can do to help you. >> [...] >> Please, do yourself a big favor and persist with this until you >> understand what you are doing wrong and how to serve dynamic images. It >> appears that the learning may be painful, but I guarantee it will be >> worthwhile. > > There _is_ a way to embed image data in HTML that is supported by > every major browser. It is ugly. Using the RFC 2397 (http:// > www.ietf.org/rfc/rfc2397) spec for data URLs you could go > > '' % base64.b64encode(image_data) Another alternative would be to generate a multipart/related document, but I think the OP will gain a lot more understanding the simple cases than using those esoteric features. -- Gabriel Genellina From manthra.mohan at gmail.com Fri Apr 25 09:07:13 2008 From: manthra.mohan at gmail.com (Krishna) Date: Fri, 25 Apr 2008 06:07:13 -0700 (PDT) Subject: Environment Variables Message-ID: Environment variable set up is the most confusing part for me all the time. Please help me with the following questions: When I install python in a new system, I will go to environment variables (system variables) and set "path" pointing to C:\Python25 and thats all I do. I type python from "cmd" window and its converting to python window for python execution. All fine up to this point. Now, I want to drag and drop python (.py) files to this window and execute it. My python files are located in different directories inside C: and outside C:. When I do that, I get errors and the file is not found and its not imported. ALso, inside the .py file, if I have a command to open a different file, it doesnt see that either. How do I overcome these basic difficulties in python. I wish I can open any file and work on that using python. Thanks for your help! Krishna From bronger at physik.rwth-aachen.de Mon Apr 21 03:16:15 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Mon, 21 Apr 2008 09:16:15 +0200 Subject: lost sourcecode: decompyle? Message-ID: <87mynn3cg0.fsf@physik.rwth-aachen.de> Hall?chen! Due to erroneous use of my VCS, I lost my revision of yesterday. All I have are the pyc v2.5 files. Unfortunately, decompyle can only handle v2.3. Can one convert this, e.g. by de-assembling, manual tweaking, and re-assembling? The result must not be perfect since I still have most content of the files. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From mwilson at the-wire.com Mon Apr 7 08:55:19 2008 From: mwilson at the-wire.com (Mel) Date: Mon, 07 Apr 2008 08:55:19 -0400 Subject: Is there any way to say ignore case with "in"? References: <47f692f3$0$759$bed64819@news.gradwell.net> <432d690f-44be-49a9-bc6a-1cf3445549d6@m71g2000hse.googlegroups.com> <47f8d5df$0$23304$9b622d9e@news.freenet.de> Message-ID: Paul McGuire wrote: > On Apr 6, 8:53 am, "Martin v. L?wis" wrote: >>>> I know I could use:- >>>> if lower(string1) in lower(string2): >>>> >>>> but it somehow feels there ought to be an easier (tidier?) way. >> Take, for example, U+017F, LATIN SMALL LETTER LONG S. It's .lower() is >> the same character, as the character is already in lower case. >> It's .upper() is U+0053, LATIN CAPITAL LETTER S. Notice that the LONG >> is gone - there is no upper-case version of a "long s". >> It's .upper().lower() is U+0073, LATIN SMALL LETTER S. >> >> So should case-insensitive matching match the small s with the small >> long s, as they have the same upper-case letter? [ ... ] >>>> [i for i in range(65536) if unichr(i).lower().upper() != > ... unichr(i).upper()] > [304, 1012, 8486, 8490, 8491] > > Instead of 15 exceptions to the rule, conversion to upper has only 5 > exceptions. So perhaps comparsion of upper's is, while not foolproof, > less likely to encounter these exceptions? Or at least, simpler to > code explicit tests. I don't know what meaning is carried by all those differences in lower-case glyphs. Converting to upper seems to fold together a lot of variant pi's and rho's which I think would be roughly a good thing. I seem to recall that the tiny iota (ypogegrammeni) has or had grammatical significance. The other effect would be conflating physics' Angstron unit and Kelvin unit signs with ring-a and K. Applicaton programmers beware. Mel. From ewertman at gmail.com Tue Apr 29 01:49:26 2008 From: ewertman at gmail.com (Eric Wertman) Date: Tue, 29 Apr 2008 01:49:26 -0400 Subject: python script as executable In-Reply-To: References: Message-ID: <92da89760804282249y10dd9987wacfaeafc14f681bb@mail.gmail.com> Try to ftp it in ascii mode, or find a dos2unix utility .. the file has probably got \r\n (windows) line terminators in it.. causes problems. I guess it's also possible that /usr/bin/env doesn't exist... not likely though. On Tue, Apr 29, 2008 at 1:36 AM, sandipm wrote: > Hi, > I have written a python script to run from cron. > I have put #!/usr/bin/env python at top. file executes correctly when > I run using python filename.py but > it fails to execute when try to run it like script/command. > it throws error: > :No such file or directory > > I am editing file from eclipse for python from windows. and then > uploading on linus machine to run it. > > > any pointers? > > sandip > -- > http://mail.python.org/mailman/listinfo/python-list > From jzshao1 at gmail.com Fri Apr 11 15:16:29 2008 From: jzshao1 at gmail.com (Jonathan Shao) Date: Fri, 11 Apr 2008 15:16:29 -0400 Subject: Question on threads Message-ID: Hi all, I'm a beginner to Python, so please bear with me. Is there a way of guarenteeing that all created threads in a program are finished before the main program exits? I know that using join() can guarentee this, but from the test scripts I've run, it seems like join() also forces each individual thread to terminate first before the next thread can finish. So if I create like 20 threads in a for loop, and I join() each created thread, then join() will in effect cause the threads to be executed in serial rather than in parallel. ~ Jon -- "Perhaps we all give the best of our hearts uncritically, to those who hardly think about us in return." ~ T.H.White -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at holdenweb.com Mon Apr 14 19:34:06 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 14 Apr 2008 19:34:06 -0400 Subject: py3k s***s In-Reply-To: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> Message-ID: Sverker Nilsson wrote: > do i dare to open a thread about this? > > come on you braver men > > we are at least not bought by g***le > > but why? others have said it so many times i think > > :-//// > > but why? a few syntactic 'cleanups' for the cost of a huge rewrite of > all the code that have been builtup from all the beginning when the > once great Python came along and people began to use it and write code > for it. Like all that code would have to be rewritten. blaah. > and i have perhaps been drinking but i have been p**d all week since i > began look into this:-( Perhaps you should sober up and look at the reality of Python 3, which has deliberately avoided a complete rewrite. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From iltchevi at gmail.com Sun Apr 27 16:31:01 2008 From: iltchevi at gmail.com (ici) Date: Sun, 27 Apr 2008 13:31:01 -0700 (PDT) Subject: Python equivalent to PHP's SPL __autoload() ?? References: <5bfb3fa2-652c-4ce5-b914-27ef21685c33@p25g2000pri.googlegroups.com> Message-ID: <50cb2fd1-022f-4d72-b95a-adb002ad0978@z72g2000hsb.googlegroups.com> On Apr 27, 10:34 pm, Ixiaus wrote: > I was curious (and have spent an enormous amount of time on Google > trying to answer it for myself) if Python has anything remotely > similar to PHP's SPL __autoload() for loading classes on the fly?? > > After digging through docs I feel doubtful there is such a language > feature, but, it is possible I missed something or maybe someone has > written an extension?!? > > Thanks in advance! from module_name include * Can do the magic. You can't learn Python from helps or internet, got a book. Learning Python: http://www.oreilly.com/catalog/lpython/ is a very good start :) From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 30 12:14:06 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 30 Apr 2008 18:14:06 +0200 Subject: printing inside and outside of main() module In-Reply-To: References: <9bd5c596-da19-4615-a4d8-e47b20cfb362@m73g2000hsh.googlegroups.com> Message-ID: <48189ac0$0$9742$426a74cc@news.free.fr> Peter Otten a ?crit : > korean_dave wrote: > >> This allows me to see output: >> >> ---begin of try.py >> print "Hello World" >> --end of try.py >> >> This DOESN'T though... >> >> --begin of try2.py >> def main(): >> return "Hello" > main() # add this >> --end of try2.py >> >> Can someone explain why??? > > Python doesn't call the main() function; you have to invoke it explicitly. And while we're at it, your main function *returns* a value, but doesn't *print* anything. From darian.schramm at gmail.com Thu Apr 10 14:53:24 2008 From: darian.schramm at gmail.com (darian schramm) Date: Thu, 10 Apr 2008 14:53:24 -0400 Subject: class In-Reply-To: <264666470804101008l3d6740c2ve76a81d1815f2d0d@mail.gmail.com> References: <264666470804101008l3d6740c2ve76a81d1815f2d0d@mail.gmail.com> Message-ID: <67edaf4b0804101153m2d37a7cbp8770b7206600ec61@mail.gmail.com> Your import statement is wrong. Try: from Mysqldb import Mysqldb in your session.py On Thu, Apr 10, 2008 at 1:08 PM, Arun ragini wrote: > Hi, > > I have create a class file named Mysqldb.py > > class Mysqldb: > def __init__(self, name): > #this where it tries to connect to database > self.ip = ip > print "Inializing session for name" > > def test(self): > print "worked" > > ----------------------------------------------------- > > now i'm trying initialize this another python file called session.py > > import Mysqldb > > def session(): > Sess = Mysqldb ("localbox") > > > when i try to run in using python session.py. > > i get error message > TypeError: 'module' object is not callable > > can any 1 help me on this. > > Thanks & Regards > Arun > > > -- > ----- > Fight back spam! Download the Blue Frog. > http://www.bluesecurity.com/register/s?user=YXJ1bnJhZ2luaQ%3D%3D > -- > http://mail.python.org/mailman/listinfo/python-list > -- Darian V Schramm From eduardo.padoan at gmail.com Tue Apr 1 15:42:36 2008 From: eduardo.padoan at gmail.com (Eduardo O. Padoan) Date: Tue, 1 Apr 2008 16:42:36 -0300 Subject: Is this a good time to start learning python? In-Reply-To: <1565ced8-afd7-4c32-a6ee-26f9b95d60bc@d45g2000hsc.googlegroups.com> References: <47f1140e$0$735$a729d347@news.telepac.pt> <88fa881e-e59b-4682-801c-90ef08a1480a@a22g2000hsc.googlegroups.com> <1565ced8-afd7-4c32-a6ee-26f9b95d60bc@d45g2000hsc.googlegroups.com> Message-ID: On Tue, Apr 1, 2008 at 4:20 PM, wrote: > > > > Please explain how the existence of Python 3.0 would break your production > > > > code. > > > > > The existence of battery acid won't hurt me either, unless I come into > > > contact with it. If one eventually upgrades to 3.0 -- which is > > > ostensibly the desired path -- their code could break and require > > > fixing. > > > > > And how would this happen? I dont know of any good software > > distribution that upgrades a component to another major revision > > without asking first. The desired path is that, if somene wants to > > port his software to Python 3.0, that he follow the migration plan. > > Of course, that's the point. If you want to upgrade to the next > version of Python, you have to fix your code. That stinks. Your > other alternative is to remain stuck with Python 2.x, but eventually > the support for that will dry up. "Eventually" it will take a decade to happen. 2.x support will not be dropped untill gets (much) more users than Python 3.x. > > Final users will install Python 3.0 as python3.0 anyway, with Python > > 2.x as default 'python' binary. > > > > > > Backward compatibility is important. C++ could break all ties with C > > > to "clean up" as well, but it would be a braindead move that would > > > break existing code bases upon upgrade. > > > > > C++ is not C. No one "upgrades" from C to C++. > > You misunderstand. C++ has a lot of "warts" to maintain backwards > compatibility with C. The standards committee could eliminate these > warts to make the language "cleaner", but it would break a lot of > systems. It would not "break" anything that not move from C to C++, this is my point. People not willing to take the migration path (porting to 2.6, using the -3 flag, refactoring and re-running the tests untill the warning are gone, using the 2to3 tool...) will not upgrade. No one will force you to do it. 2.6 will not desappear from the python.org site anytime soon. -- Eduardo de Oliveira Padoan http://www.advogato.org/person/eopadoan/ Bookmarks: http://del.icio.us/edcrypt From http Wed Apr 2 21:14:42 2008 From: http (Paul Rubin) Date: 02 Apr 2008 18:14:42 -0700 Subject: Summary of threading for experienced non-Python programmers? References: <87od8yolay.fsf@mulj.homelinux.net> <654ng1F2cvh8aU1@mid.uni-berlin.de> <87d4pe9caz.fsf@mulj.homelinux.net> <656vhnF2e9ao7U1@mid.uni-berlin.de> <8763v4otts.fsf@mulj.homelinux.net> <65fulvF2eiaalU1@mid.uni-berlin.de> <6224eb1e-0d48-47d7-bfcd-94e6dc9b5ce2@c19g2000prf.googlegroups.com> Message-ID: <7xprt7g2nx.fsf@ruckus.brouhaha.com> sturlamolden writes: > Python's standard library should have an asynch module that uses aio > on Linux and i/o completion ports on Windows. It should work with > files and tcp sockets alike. Lately I'm hearing that Linux's aio implementation doesn't work very well yet. It is fairly recent. It's possible that BSD's or Solaris's versions are better. From nick at stinemates.org Fri Apr 18 15:10:00 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 12:10:00 -0700 Subject: Getting subprocess.call() output into a string? In-Reply-To: <18c1e6480804151416j7dd49d78p8888132ca01a5237@mail.gmail.com> References: <18c1e6480804151416j7dd49d78p8888132ca01a5237@mail.gmail.com> Message-ID: <20080418191000.GI19281@deviL> On Tue, Apr 15, 2008 at 11:16:01PM +0200, David wrote: > > > > Still, about StringIO... > > > > The module description says you can use it to read and write strings > as files, not that you can use strings *everywhere* you can use files. > > In your specific case, StringIO doesn't work, because the stdout > redirection takes place at the operating system level (which uses real > file handles), rather than in a python library (for which StringIO > would probably work). > > David. > -- > http://mail.python.org/mailman/listinfo/python-list Just a note to all of those who are interested. I have yet to get this to work properly for an app which runs indefinitely and you want to read the output at a specified interval. Right now the only way I can read is if the _close() method has been called. Anyway, I wrote a wrapper around it so I could easily change the implementation if I could ever find a better solution. Here's my code: =========================== import subprocess import os import select class ProcessMonitor: def __init__(self): self.__process = None self.__stdin = None self.__stdout = None def _create(self, process): self.__process = subprocess.Popen(process, stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True) self.__stdin = self.__process.stdout self.__stdout = self.__process.stdout def _close(self): os.kill(self.__process.pid,9) def _listen(self): """ get from stdout """ return "".join(self.__stdout.readlines()) def _listen2(self): """ My attempt at trying different things. """ inp, out = self.__process.communicate("") print out -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From __peter__ at web.de Sun Apr 20 06:21:24 2008 From: __peter__ at web.de (Peter Otten) Date: Sun, 20 Apr 2008 12:21:24 +0200 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <2008041915243216807-bob@passcalnmtedu> Message-ID: Bob Greschke wrote: > On 2008-04-18 23:35:12 -0600, Ivan Illarionov > said: > >> On Sat, 19 Apr 2008 04:45:54 +0000, Ivan Illarionov wrote: >> >>> On Fri, 18 Apr 2008 22:30:45 -0500, Grant Edwards wrote: >>> >>>> On 2008-04-18, Bob Greschke wrote: >>>> >>>>> However, in playing around with your suggestion and Grant's code I've >>>>> found that the struct stuff is WAY slower than doing something like >>>>> this >>>>> >>>>> Value = (ord(Buf[s])*65536)+(ord(Buf[s+1])*256)+ord(Buf[s+2]) if >>>>> Value >>>>>> = 0x800000: >>>>> Value -= 0x1000000 >>>>> >>>>> This is almost twice as fast just sitting here grinding through a few >>>>> hundred thousand conversions (like 3sec vs. ~5secs just counting on my >>>>> fingers - on an old Sun...it's a bit slow). Replacing *65536 with >>>>> <<16 and *256 with <<8 might even be a little faster, but it's too >>>>> close to call without really profiling it. >>>> >>>> I didn't know speed was important. This might be a little faster >>>> (depending on hardware): >>>> >>>> Value = (ord(Buf[s])<<16) | (ord(Buf[s+1])<<8) | ord(Buf[s+2]) >>>> >>>> It also makes the intention a bit more obvious (at least to me). >>>> >>>> A decent C compiler will recognize that <<16 and <<8 are special and >>>> just move bytes around rather than actually doing shifts. I doubt the >>>> Python compiler does optimizations like that, but shifts are still >>>> usually faster than multiplies (though, again, a good compiler will >>>> recognize that multiplying by 65536 is the same as shifting by 16 and >>>> just move bytes around). >>> >>> So why not put it in C extension? >>> >>> It's easier than most people think: >>> >>> >>> from3bytes.c >>> ============ >>> #include >>> >>> PyObject* >>> from3bytes(PyObject* self, PyObject* args) { >>> const char * s; >>> int len; >>> if (!PyArg_ParseTuple(args, "s#", &s, &len)) >>> return NULL; >>> long n = (s[0]<<16) | (s[1]<<8) | s[2]; if (n >= 0x800000) >>> n -= 0x1000000; >>> return PyInt_FromLong(n); >>> } >>> >>> static PyMethodDef functions[] = { >>> {"from3bytes", (PyCFunction)from3bytes, METH_VARARGS}, {NULL, >>> NULL, 0, NULL}, >>> }; >>> >>> >>> DL_EXPORT(void) >>> init_from3bytes(void) >>> { >>> Py_InitModule("_from3bytes", functions); >>> } >>> >>> buildme.py >>> ========== >>> import os >>> import sys >>> from distutils.core import Extension, setup >>> >>> os.chdir(os.path.dirname(os.path.abspath(__file__))) sys.argv = >>> [sys.argv[0], 'build_ext', '-i'] setup(ext_modules = >>> [Extension('_from3bytes', ['from3bytes.c'])]) >>> >>> 'python buildme.py' will create '_from3bytes.so' file 'from _from3bytes >>> import from3bytes' will import C-optimized function >>> >>> Hope this helps. >> >> Sorry, >> the right code should be: >> >> PyObject* from3bytes(PyObject* self, PyObject* args) >> { >> const char * s; >> int len; >> if (!PyArg_ParseTuple(args, "s#", &s, &len)) >> return NULL; >> long n = ((((unsigned char)s[0])<<16) | (((unsigned >> char)s[1])<<8) | >> ((unsigned char)s[2])); >> if (n >= 0x800000) >> n -= 0x1000000; >> return PyInt_FromLong(n); >> } > > No thanks. Being able to alter and install these programs on whatever > computer they are installed on is more important than speed. I went > down the C-extension path years ago and it turned into a big mess. > Everything has to run on Sun's, Mac's, Linux and Windows without any > major hassels if they have to be changed. I can't reley on everything > the program needs to be rebuilt being installed beyond Python and > Tkinter (and pySerial and PIL for a couple of programs), which they > need to run. So no compiling and everything is in one file, in case a > new version has to be upgraded by a user by emailing it to them while > they're sitting on some mountain in Tibet. Just unzip, stick the .py > somewhere logical, (usually) double-click, and they are off and running. > > Bob Just for fun, here's a way to convert lots of 3-byte integers using PIL: from PIL import Image import array def int3_pil(s, trafo="\x00"*128+"\xff"*128): n = len(s)//3 im = Image.new("RGB", (n, 1)) im.fromstring(s) hi, mid, lo = im.split() sign = Image.new("L", (n, 1)) sign.fromstring(hi.tostring().translate(trafo)) im = Image.merge("RGBA", (lo, mid, hi, sign)) a = array.array("i") a.fromstring(im.tostring()) return a.tolist() Not as fast as I had hoped, though. Also, it needs some work to make it independent of the processor architecture. Peter From bob at passcal.nmt.edu Sat Apr 19 17:24:32 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Sat, 19 Apr 2008 15:24:32 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> Message-ID: <2008041915243216807-bob@passcalnmtedu> On 2008-04-18 23:35:12 -0600, Ivan Illarionov said: > On Sat, 19 Apr 2008 04:45:54 +0000, Ivan Illarionov wrote: > >> On Fri, 18 Apr 2008 22:30:45 -0500, Grant Edwards wrote: >> >>> On 2008-04-18, Bob Greschke wrote: >>> >>>> However, in playing around with your suggestion and Grant's code I've >>>> found that the struct stuff is WAY slower than doing something like >>>> this >>>> >>>> Value = (ord(Buf[s])*65536)+(ord(Buf[s+1])*256)+ord(Buf[s+2]) if >>>> Value >>>>> = 0x800000: >>>> Value -= 0x1000000 >>>> >>>> This is almost twice as fast just sitting here grinding through a few >>>> hundred thousand conversions (like 3sec vs. ~5secs just counting on my >>>> fingers - on an old Sun...it's a bit slow). Replacing *65536 with >>>> <<16 and *256 with <<8 might even be a little faster, but it's too >>>> close to call without really profiling it. >>> >>> I didn't know speed was important. This might be a little faster >>> (depending on hardware): >>> >>> Value = (ord(Buf[s])<<16) | (ord(Buf[s+1])<<8) | ord(Buf[s+2]) >>> >>> It also makes the intention a bit more obvious (at least to me). >>> >>> A decent C compiler will recognize that <<16 and <<8 are special and >>> just move bytes around rather than actually doing shifts. I doubt the >>> Python compiler does optimizations like that, but shifts are still >>> usually faster than multiplies (though, again, a good compiler will >>> recognize that multiplying by 65536 is the same as shifting by 16 and >>> just move bytes around). >> >> So why not put it in C extension? >> >> It's easier than most people think: >> >> >> from3bytes.c >> ============ >> #include >> >> PyObject* >> from3bytes(PyObject* self, PyObject* args) { >> const char * s; >> int len; >> if (!PyArg_ParseTuple(args, "s#", &s, &len)) >> return NULL; >> long n = (s[0]<<16) | (s[1]<<8) | s[2]; if (n >= 0x800000) >> n -= 0x1000000; >> return PyInt_FromLong(n); >> } >> >> static PyMethodDef functions[] = { >> {"from3bytes", (PyCFunction)from3bytes, METH_VARARGS}, {NULL, >> NULL, 0, NULL}, >> }; >> >> >> DL_EXPORT(void) >> init_from3bytes(void) >> { >> Py_InitModule("_from3bytes", functions); >> } >> >> buildme.py >> ========== >> import os >> import sys >> from distutils.core import Extension, setup >> >> os.chdir(os.path.dirname(os.path.abspath(__file__))) sys.argv = >> [sys.argv[0], 'build_ext', '-i'] setup(ext_modules = >> [Extension('_from3bytes', ['from3bytes.c'])]) >> >> 'python buildme.py' will create '_from3bytes.so' file 'from _from3bytes >> import from3bytes' will import C-optimized function >> >> Hope this helps. > > Sorry, > the right code should be: > > PyObject* from3bytes(PyObject* self, PyObject* args) > { > const char * s; > int len; > if (!PyArg_ParseTuple(args, "s#", &s, &len)) > return NULL; > long n = ((((unsigned char)s[0])<<16) | (((unsigned char)s[1])<<8) | > ((unsigned char)s[2])); > if (n >= 0x800000) > n -= 0x1000000; > return PyInt_FromLong(n); > } No thanks. Being able to alter and install these programs on whatever computer they are installed on is more important than speed. I went down the C-extension path years ago and it turned into a big mess. Everything has to run on Sun's, Mac's, Linux and Windows without any major hassels if they have to be changed. I can't reley on everything the program needs to be rebuilt being installed beyond Python and Tkinter (and pySerial and PIL for a couple of programs), which they need to run. So no compiling and everything is in one file, in case a new version has to be upgraded by a user by emailing it to them while they're sitting on some mountain in Tibet. Just unzip, stick the .py somewhere logical, (usually) double-click, and they are off and running. Bob From tommy.nordgren at comhem.se Thu Apr 10 14:20:19 2008 From: tommy.nordgren at comhem.se (Tommy Nordgren) Date: Thu, 10 Apr 2008 20:20:19 +0200 Subject: text adventure game problem In-Reply-To: References: Message-ID: <28A235C5-F5FE-4203-899D-4E843CEF90D3@comhem.se> On 9 apr 2008, at 03.01, corvettecraz92 at gmail.com wrote: > okay, I'm having this one problem with a text adventure game. It's > kind of hard to explain, but I'll do my best. > [code] > > def prompt_kitchen(): > global gold Python is not a suitable language for Text Adventure Development. You should use one of the several excellent free text adventure languages instead. In particular languages like TADS (The text adventure development system) have strong built-in support for the tricky command parsing. ----------------------------------- See the amazing new SF reel: Invasion of the man eating cucumbers from outer space. On congratulations for a fantastic parody, the producer replies : "What parody?" Tommy Nordgren tommy.nordgren at comhem.se From p.newbie at yahoo.com Wed Apr 16 20:58:10 2008 From: p.newbie at yahoo.com (python newbie) Date: Wed, 16 Apr 2008 17:58:10 -0700 (PDT) Subject: Logical Operator and code block not executing (newbie question) Message-ID: <101830.10301.qm@web45803.mail.sp1.yahoo.com> Hello, I am running into a small problem of not having a code block not executing after after a logical operator is true. What am I missing or doing wrong. Any thoughts or opinions would be greatly appreciated. The block that isn't being executed follows: elif (guess == the_number) and (tries < total_attempts): print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" print "The correct answer is: ", the_number Below is the complete script: #! /usr/bin/python # Aurthor: Me # Purpose: Demonstrates # Date: April 15, 2008 import random print "\tWelcome to 'Guess My Number'!" print "\nI'm thinking of a number between 1 and 100." print "Try to guess it in as few attempts as possible.\n" # set the initial values the_number = random.randrange(100) + 1 guess = int(raw_input("Take a guess: ")) tries = 1 total_attempts = 3 # guessing loop while (guess != the_number): if (guess > the_number) and (tries < total_attempts): print "Lower..." print "You have...", total_attempts - tries, "left." print "The correct answer is: ", the_number elif (guess < the_number) and (tries < total_attempts): print "Higher..." print "You have...", total_attempts - tries, "left." print "The correct answer is: ", the_number elif (guess == the_number) and (tries < total_attempts): print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" print "The correct answer is: ", the_number elif (tries >= total_attempts): print "You're out of guess" print "You have...", total_attempts - tries, "left." print "You need more practice." print "The correct answer is: ", the_number break else: print "You shouldn't see this message..." print "You have...", total_attempts - tries, "left." print "The correct answer is: ", the_number break guess = int(raw_input("Take a guess: ")) tries += 1 raw_input("\n\nPress the enter key to exit.") PS: I am new to coding & scripting. Pete --------------------------------- Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan_ml at behnel.de Wed Apr 9 16:18:27 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 09 Apr 2008 22:18:27 +0200 Subject: Stripping scripts from HTML with regular expressions In-Reply-To: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> References: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: <47FD2493.7050701@behnel.de> Michel Bouwmans wrote: > I'm trying to strip all script-blocks from a HTML-file using regex. You might want to take a look at lxml.html instead, which comes with an HTML cleaner module: http://codespeak.net/lxml/lxmlhtml.html#cleaning-up-html Stefan From v.softwaretester at gmail.com Sun Apr 20 14:51:16 2008 From: v.softwaretester at gmail.com (Software Testing) Date: Sun, 20 Apr 2008 14:51:16 -0400 Subject: I would like to learn scripting in Python too! Message-ID: <8339da0f0804201151s1ba691e3n970c2827abc22cae@mail.gmail.com> Hello There, I am a software tester and I see lot of testers on the forums saying Python is a wonderful scripting language that testers use on a daily basis. I would also like to learn to script in Python but I do not have any programming background. Please help Thanks Mansa -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at holdenweb.com Sun Apr 6 22:43:39 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 06 Apr 2008 22:43:39 -0400 Subject: ANN: pry unit testing framework In-Reply-To: <20080407023442.GA16373@nullcube.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> <20080407023442.GA16373@nullcube.com> Message-ID: <47F98A5B.8010000@holdenweb.com> Aldo Cortesi wrote: > Thus spake Ben Finney (bignose+hates-spam at benfinney.id.au): > >>> I'm afraid that Pry is unashamedly incompatible with any other unit >>> testing method in existence, including but not limited to doctest, >>> unittest, nose and py.test. ;) >> Which makes the deliberate deviations from PEP 8 naming a large black >> mark against it. > > You're misunderstanding the intent of PEP 8, which was never supposed > to dogmatically enforce a naming standard on all Python projects > everywhere. You're also vastly overstating the impact of a minor naming > convention choice. Calling this a "large black mark" smacks of > scare-mongering to me. > It probably reflects personal preference, but it's a preference that many people will maintain. I understand that PEP 008 was largely directed at standard library authors and maintainers, but anything that claims wide utility should have ambitions to be included in the standard library, and hence PEP 008 conformance would be a plus. >>> Some day I might experiment with extending Pry to gather and run >>> doctests and unittests. At this stage, however, I don't believe the >>> (significant) effort would be worth it. >> That's very unfortunate. Until it plays better with others, I don't >> believe the effort of using this package will be worth it. > > Each of the third-party testing frameworks that have cropped up in this > thread extends unittest in some incompatible way. If you use any of > these extensions, it means that your unit test suite is tied to that > particular test framework. If you have an existing suite of unit tests > that you can't or don't want to convert, I'm afraid that Pry is indeed > not for you. Pry is not intended to be a general engine for running > tests written for other frameworks. > A reasonable enough point of view, but it means that you are just one of a number of competing frameworks. While you are earnest about pry's advantages you have a lot of work to do to move people away form the entrenched testing frameworks they are used to. > I should also note that converting from unittest to Pry is quite simple > - Pry's test structure is a superset of unittest's, and AutoTree was > explicitly written to make "unittest-style" testing possible, meaning > that no _structural_ change is needed for conversion. The most onerous > part is converting to assertion-based testing, something that will > improve the clarity and readability of your tests anyway. > Time will tell. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From cmpython at gmail.com Wed Apr 2 15:04:07 2008 From: cmpython at gmail.com (CM) Date: Wed, 2 Apr 2008 12:04:07 -0700 (PDT) Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> <47f3c751$0$6477$4c368faf@roadrunner.com> Message-ID: <30730d40-8f7e-48bd-bb0f-3a95e814b20f@t54g2000hsg.googlegroups.com> On Apr 2, 2:50 pm, AK wrote: > Terry Reedy wrote: > > "AK" wrote in message > >news:47f2d018$0$6517$4c368faf at roadrunner.com... > > > || I'll be glad to hear comments/suggestions/etc: > > | > > |http://www.lightbird.net/py-by-example/ > > > Using - as the example/return delimiter does not work. > > If you do not want to substantially lengthen the document by going to > > >>>> sqrt(9) > > 3 > > > then use Python's a comment symbol. > > > sqrt(9) # 3 > > -or- > > sqrt(9) # returns 3 (but I think I prefer the first) > > > which clearly is not an arithmetic expression and which can be > > cut-and-pasted into the interactive interpreter. This also works nicely > > for invalid examples. > > > sqrt(-9) # raises ValueError > > > Terry Jan Reedy > > Thanks to everybody who replied, I will implement the change as per > Terry's advice. I'm still considering whether to use the standard > interpreter syntax, i.e. >>> ... \n result; my reason for not doing that > is that I will often have a whole screen of function / result lines and > if I were to add a new line for the result, that'd make two pages out of > one, which I think is a bit too much. In current docs there are not so > many examples, so that space is not multiplied quite so much, and using > interactive interpreter way of showing result is not nearly as much of > a problem. However, I'm still thinking this over and it seems that > almost everyone wants to see it done in that way, I might still go for > two lines. I'll also be posting updates as the work progresses.. > > thx, > > -- > -ak > Tobu |http://www.lightbird.net/tobu/| Freeform DB / Tagger / PIM > Python-by-Example |http://www.lightbird.net/py-by-example/| Guide > to LibRef You should also change the look of the page to be more high-contrast. The grayish text in a gray box and the light green text...all too subtle to see. Not easy for well-sighted people let alone those with poorer vision. Try make things visually very obvious, bolded headers, etc. If so, and with the change of showing the result not with an "-" symbol, it will be much stronger. Thank you for doing it. From lcordier at gmail.com Tue Apr 1 05:15:48 2008 From: lcordier at gmail.com (rootkill) Date: Tue, 1 Apr 2008 02:15:48 -0700 (PDT) Subject: counting using variable length string as base References: Message-ID: On Mar 27, 8:15 am, Grimsqueaker wrote: > Hi, I'm fairly new to Python and to this list. I have a problem that > is driving me insane, sorry if it seems simple to everyone, I've been > fighting with it for a while. :)) > > I want to take a variable length string and use it as a base for > counting, eg. given the string 'abc' the sequence would be: > > a > b > c > aa > ba > ca > ab > bb > cb > ... > ccc > > Basically I want to find every possible order of every combination. > Its easy if you know how many characters there will be in your string > (use nested for loops), but I am stuck with the variable length > string. I think I have to use a generator but I'm not sure exactly > how. > > Can anyone give me a pointer in the right direction? > > Thanks > Daniel Browne Since you didn't ask for the smallest solution I'll opt for the clearest one ;) I'll use the very usefull baseconvert, http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/111286 def baseconvert(number, fromdigits, todigits): if str(number)[0] == '-': number = str(number)[1:] neg = 1 else: neg = 0 # make an integer out of the number x = long(0) for digit in str(number): x = x * len(fromdigits) + fromdigits.index(digit) # create the result in base 'len(todigits)' res = '' if x == 0: res = todigits[0] while x > 0: digit = x % len(todigits) res = todigits[digit] + res x /= len(todigits) if neg: res = '-' + res return res BASE10 = '0123456789' s = 'abcdef' n = len(s) for i in xrange(n**n): print baseconvert(str(i), BASE10, s) You can also convert back, baseconvert('abaa', s, BASE10). Hope it helps. Regards, Louis. From bijeshn at gmail.com Mon Apr 7 06:20:00 2008 From: bijeshn at gmail.com (bijeshn) Date: Mon, 7 Apr 2008 03:20:00 -0700 (PDT) Subject: splitting an XML file on the basis on basis of XML tags References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> <47F9B845.9040205@behnel.de> Message-ID: <05edd42c-dd16-4364-92ca-43cdbb1ab547@r9g2000prd.googlegroups.com> the extracted files are to be XML too. ijust need to extract it raw (tags and data just like it is in the parent XML file..) From skanemupp at yahoo.se Thu Apr 10 13:22:57 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 10:22:57 -0700 (PDT) Subject: Tkinter, resize window, keep widgets relative placements? References: <6a656935-7c32-454c-ab72-30e7d7e84b40@u12g2000prd.googlegroups.com> Message-ID: <98e39774-cfa9-44c7-92ec-4c5aa0d3f431@p25g2000pri.googlegroups.com> here i didi it with pack() but when i try to use the answerwidget it gtes all f***** up. any suggestions? from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") ##l = Label(mygui, text="Answer: ") ##l.grid(row=2, column=1, columnspan=2) e = Entry(mygui) e.grid(row=1, column=1, columnspan=4) c = Entry(mygui) c.grid(row=2, column=1, columnspan=4) def Disp(nstr): e.insert(INSERT, nstr) def Calc(): expr=e.get() c.delete(0, END) try: c.insert(END, eval(expr)) except: c.insert(END, "Not computable") def Erase(): e.delete(0,END) c.delete(0, END) def Backspace(): a=len(e.get()) e.delete(a-1,END) #e.delete(INSERT, END) #e.delete(ANCHOR,END) x = 1 y = 4 for char in '123+456-789*0()/.': b = Button(mygui, text=char, command=lambda n=char:Disp(n), width=2, height=1) b.grid(row=y, column=x) x=x+1 if x==5: x=1 y=y+1 b = Button(mygui, text="^", command=lambda n="**":Disp(n), width=2, height=1) b.grid(row=8, column=2) b = Button(mygui, text="C",command=Erase, width=2, height=1) b.grid(row=8, column=3) b = Button(mygui, text="c",command=Backspace, width=2, height=1) b.grid(row=8, column=4) b = Button(mygui, text="=",command=Calc, width=18, height=1) b.grid(row=9, column=1, columnspan=8) mygui.mainloop() From silfheed at gmail.com Fri Apr 11 18:59:44 2008 From: silfheed at gmail.com (Silfheed) Date: Fri, 11 Apr 2008 15:59:44 -0700 (PDT) Subject: CDATA and lxml References: <5ebe3201-80a6-45ba-8b88-e8ece6883efa@w8g2000prd.googlegroups.com> <47FF368B.4030708@behnel.de> <47FFA0D7.1030901@behnel.de> <1d6d4a80-7031-441a-b242-e50ebcd51da9@w5g2000prd.googlegroups.com> Message-ID: <3ebbd54e-6cf2-4f49-b0c1-43e1eb16dfb0@n14g2000pri.googlegroups.com> On Apr 11, 3:49 pm, Silfheed wrote: > On Apr 11, 10:33 am, Stefan Behnel wrote: > > > > > Hi again, > > > Stefan Behnel wrote: > > > Silfheed wrote: > > >> So first off I know that CDATA is generally hated and just shouldn't > > >> be done, but I'm simply required to parse it and spit it back out. > > >> Parsing is pretty easy with lxml, but it's the spitting back out > > >> that's giving me issues. The fact that lxml strips all the CDATA > > >> stuff off isnt really a big issue either, so long as I can create > > >> CDATA blocks later with <>&'s showing up instead of <>& . > > >> I've scoured through the lxml docs, but probably not hard enough, so > > >> anyone know the page I'm looking for or have a quick how to? > > > > There's nothing in the docs because lxml doesn't allow you to create CDATA > > > sections. You're not the first one asking that, but so far, no one really had > > > a take on this. > > > So I gave it a try, then. In lxml 2.1, you will be able to do this: > > > >>> root = Element("root") > > >>> root.text = CDATA('test') > > >>> tostring(root)) > > '' > > > This does not work for .tail content, only for .text content (no technical > > reason, I just don't see why that should be enabled). > > > There's also a parser option "strip_cdata" now that allows you to leave CDATA > > sections in the tree. However, they will *not* behave any different than > > normal text, so you can't even see at the API level that you are dealing with > > CDATA. If you want to be really, really sure, you can always do this: > > > >>> root.text = CDATA(root.text) > > > Hope that helps, > > > Stefan > > That is immensely cool. Do you plan to stick it into svn soon? > Thanks! Ah, looks like it's there already. Very cool, very cool. Thanks again. From mitko at qlogic.com Tue Apr 22 13:13:25 2008 From: mitko at qlogic.com (Mitko Haralanov) Date: Tue, 22 Apr 2008 10:13:25 -0700 Subject: Segfault accessing dictionary in C Python module In-Reply-To: <365f11e2-6e3e-4e9c-bfda-7c4168a39769@u69g2000hse.googlegroups.com> References: <365f11e2-6e3e-4e9c-bfda-7c4168a39769@u69g2000hse.googlegroups.com> Message-ID: <20080422101325.0c43e24f@hematite.mv.qlogic.com> On Mon, 21 Apr 2008 17:09:57 -0700 (PDT) sturlamolden wrote: > Albeit not having looked at your code in detail, I'm wiling to bet you > have one of the refcounts wrong. It turns out you are correct. I forgot to increment the refcount on the value extracted from the dict (since PyDict_GetItem returns a borrowed reference). Once I did that, all was well. Thank you! -- Mitko Haralanov mitko at qlogic.com Senior Software Engineer 650.934.8064 HSG InfiniBand Engineering http://www.qlogic.com ========================================== Fry: Drugs are for losers, and hypnosis is for losers with big weird eyebrows. From grflanagan at gmail.com Thu Apr 24 05:52:21 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Thu, 24 Apr 2008 02:52:21 -0700 (PDT) Subject: Ideas for parsing this text? References: <84fd2882-f46d-43d4-9a1c-0b981fb45ad6@59g2000hsb.googlegroups.com> Message-ID: <7a1cd8a8-caf8-4b7a-9c16-e8067266b234@m73g2000hsh.googlegroups.com> On Apr 24, 4:05 am, Paul McGuire wrote: > On Apr 23, 8:00 pm, "Eric Wertman" wrote: > > > I have a set of files with this kind of content (it's dumped from WebSphere): > > > [propertySet "[[resourceProperties "[[[description "This is a required > > property. This is an actual database name, and its not the locally > > catalogued database name. The Universal JDBC Driver does not rely on > > ... > > A couple of comments first: > - What is the significance of '"[' vs. '[' ? I stripped them all out > using The data can be thought of as a serialised object. A simple attribute looks like: [name someWebsphereObject] or [jndiName []] if 'jndiName is None'. A complex attribute is an attribute whose value is itself an object (or dict if you prefer). The *value* is indicated with "[...]": [connectionPool "[[agedTimeout 0] [connectionTimeout 180] [freePoolDistributionTableSize 0] [maxConnections 10] [minConnections 1] [numberOfFreePoolPartitions 0] [numberOfSharedPoolPartitions 0] [unusedTimeout 1800]]"] However, 'propertySet' is effectively a keyword and its value may be thought of as a 'data table' or 'list of data rows', where 'data row' == dict/object You can see how the posted example is incomplete because the last 'row' is missing all but one 'column'. > text = text.replace('"[','[') > - Your input text was missing 5 trailing ]'s. > I think only 2 (the original isn't Python). To fix the example, remove the last 'description' and add two ]'s > Here's the parser I used, using pyparsing: > > from pyparsing import nestedExpr,Word,alphanums,QuotedString > from pprint import pprint > > content = Word(alphanums+"_.") | QuotedString('"',multiline=True) > structure = nestedExpr("[", "]", content).parseString(text) > > pprint(structure.asList()) > By the way, I think this would be a good example for the pyparsing recipes page (even an IBM developerworks article?) http://www.ibm.com/developerworks/websphere/library/techarticles/0801_simms/0801_simms.html Gerard example data (copied and pasted; doesn't have the case where a complex attribute has a complex attribute): [authDataAlias []] [authMechanismPreference BASIC_PASSWORD] [connectionPool "[[agedTimeout 0] [connectionTimeout 180] [freePoolDistributionTableSize 0] [maxConnections 10] [minConnections 1] [numberOfUnsharedPoolPartitions 0] [properties []] [purgePolicy FailingConnectionOnly] [reapTime 180] [surgeThreshold -1] [testConnection false] [testConnectionInterval 0] [unusedTimeout 1800]]"] [propertySet "[[resourceProperties "[[[description "This is a required property. This is an actual database name, and its not the locally catalogued database name. The Universal JDBC Driver does not rely on information catalogued in the DB2 database directory."] [name databaseName] [required true] [type java.lang.String] [value DB2Foo]] [[description "The JDBC connectivity-type of a data source. If you want to use a type 4 driver, set the value to 4. If you want to use a type 2 driver, set the value to 2. Use of driverType 2 is not supported on WAS z/OS."] [name driverType] [required true] [type java.lang.Integer] [value 4]] [[description "The TCP/IP address or name for the DRDA server."] [name serverName] [required false] [type java.lang.String] [value ServerFoo]] [[description "The TCP/IP port number where the DRDA server resides."] [name portNumber] [required false] [type java.lang.Integer] [value 007]] [[description "The description of this datasource."] [name description] [required false] [type java.lang.String] [value []]] [[description "The DB2 trace level for logging to the logWriter or trace file. Possible trace levels are: TRACE_NONE = 0,TRACE_CONNECTION_CALLS = 1,TRACE_STATEMENT_CALLS = 2,TRACE_RESULT_SET_CALLS = 4,TRACE_DRIVER_CONFIGURATION = 16,TRACE_CONNECTS = 32,TRACE_DRDA_FLOWS = 64,TRACE_RESULT_SET_META_DATA = 128,TRACE_PARAMETER_META_DATA = 256,TRACE_DIAGNOSTICS = 512,TRACE_SQLJ = 1024,TRACE_ALL = -1, ."] [name traceLevel] [required false] [type java.lang.Integer] [value []]] ]] From steve at holdenweb.com Fri Apr 25 00:30:02 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 25 Apr 2008 00:30:02 -0400 Subject: Little novice program written in Python In-Reply-To: References: Message-ID: Rog?rio Brito wrote: > Hi, All. > > I'm just getting my feet wet on Python and, just for starters, I'm > coding some elementary number theory algorithms (yes, I know that most > of them are already implemented as modules, but this is an exercise in > learning the language idioms). > > As you can see from the code below, my background is in C, without too > much sophistication. > > What I would like is to receive some criticism to my code to make it > more Python'esque and, possibly, use the resources of the computer in a > more efficient way (the algorithm implemented below is the Sieve of > Eratosthenes): > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > #!/usr/bin/env python > > n = int(raw_input()) > a = [i for i in range(0,n+1)] > a[1] = 0 # not a prime > prime = 1 # last used prime > finished = False > > while (not finished): > prime = prime + 1 > # find new prime > while prime*prime <= n and a[prime] == 0: > prime += 1 > # cross the composite numbers > if prime*prime <= n: > j = 2*prime > while j <= n: > a[j] = 0 > j += prime > else: > finished = True > > # print out the prime numbers > i = 2 > while i <= n: > if a[i] != 0: > print a[i] > i += 1 > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > Thank you for any help in improving this program, > Your Python is actually pretty good - if Raymond Hettinger pronounces it OK then few would dare to disagree. As for your English, though, the word you sought was "Pythonic" (not that you will ever find such a word in Webster's dictionary). To suggest that your code is Pythonesque would mean you found it farcical or ridiculous (like a Monty Python sketch), which it clearly is not. Another wrinkle you might consider is simply printing the primes out as they are generated rather than doing the printing in a separate loop, though whether that approach would be preferable in "real life" would depend on the application, of course. regards Steve PS: I think either my mailer or yours has mangled the indentation. -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From Scott.Daniels at Acm.Org Sat Apr 12 08:18:54 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Sat, 12 Apr 2008 05:18:54 -0700 Subject: About __init__ and default arguments In-Reply-To: References: Message-ID: Nathan Duran wrote: > > On Apr 11, 2008, at 11:35 AM, python-list-request at python.org wrote: >> I'd like to assign the value of an attribute in __init__ as the default >> value of an argument in a method. See below: > Why not just do > > def franklin(self, keyword): > if not keyword: keyword = self.default > return "A %s in time saves nine." % (keyword) Several things are false (for example: '', 0, False, [], ...) If you can get along with the code you have suggested, I'd think about using: def franklin(self, keyword): return "A %s in time saves nine." % (keyword or self.default) -Scott David Daniels Scott.Daniels at Acm.Org From martin at v.loewis.de Wed Apr 16 02:33:13 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Wed, 16 Apr 2008 08:33:13 +0200 Subject: Compiling Python 2.5.2 on AIX 5.2 In-Reply-To: References: <0b73e8e5-c301-4823-ac94-42f757456cf1@x19g2000prg.googlegroups.com> Message-ID: <48059DA9.5080900@v.loewis.de> > What is Py_UNICODE_SIZE and why was it not defined? There are current > questions I have. Py_UNICODE_SIZE is the number of bytes that a Py_UNICODE value should have in the interpreter. With --enable-unicode=ucs2, it should be 2. I cannot guess why it is not defined; check pyconfig.h to find out whether there is a definition. If not, look in your configure output for the line checking what type to use for unicode... and perhaps edit configure to print out additional messages around the place where it deals with Py_UNICODE. Regards, Martin From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Wed Apr 30 15:55:10 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Wed, 30 Apr 2008 21:55:10 +0200 Subject: I messed up my wxPython install (Eclipse Configuration Issue) References: <18eb0a7c-96f4-41de-b44f-95fd8ba0223f@f63g2000hsf.googlegroups.com> <436f8226-64a5-440a-92f4-afd7dd348e1c@m73g2000hsh.googlegroups.com> <20525ad9-2679-4bc8-a117-66eca4a8dc13@r66g2000hsg.googlegroups.com> Message-ID: <67s14vF2q5kh8U1@mid.individual.net> blaine wrote: > I didn't mean anything by it, I promise. This group is just > amazing - there are always very active topics and I get responses > in no time. The wxPython group I noticed only has had recent > discussions a few times in the past month, and their subscribers > aren't as high as the Python group. There _is_ a difference between quality and volume. Also, in some cases high quality goes along with low volume, as in others do high volume and low quality. Regards, Bj?rn -- BOFH excuse #34: (l)user error From nagle at animats.com Sun Apr 13 23:48:43 2008 From: nagle at animats.com (John Nagle) Date: Sun, 13 Apr 2008 20:48:43 -0700 Subject: Best way to update a settings file? In-Reply-To: <4802cb83$0$15190$607ed4bc@cv.net> References: <4802cb83$0$15190$607ed4bc@cv.net> Message-ID: <4802d18c$0$36323$742ec2ed@news.sonic.net> John Salerno wrote: > I'm thinking about writing a small script that will update an xml file > with whatever game settings the user enters. I imagine that the user > will have a single-screen GUI application with several different > settings, like this: > > CROSSHAIRS ON > LOCATION ON > HEALTHBAR OFF > etc..... > > These settings will somehow be toggleable with an ON/OFF button, or > something. > > Anyway, I can think of two ways to do this: > > 1. After the user chooses his settings and clicks the Save button, > Python reads all the settings from the GUI application and updates > *every* entry in the xml file (whether it has changed or not). > > 2. After the user chooses his settings and clicks the Save button, > Python reads all the settings from the GUI application, compares these > settings to those in the xml file, and updates only the ones that have > been changed. You can't write into the middle of an XML file effectively; any field that has changed length won't fit. You generally have to create a new XML file. Read this on how to replace a file with a new one, as an atomic operation: http://blogs.msdn.com/adioltean/archive/2005/12/28/507866.aspx If you really want to update files in place, use a database, like SQLite. If you find yourself rewriting big files for minor changes, switch to a database. For small files, just rewrite the whole thing. John Nagle From kyosohma at gmail.com Tue Apr 8 11:57:46 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 8 Apr 2008 08:57:46 -0700 (PDT) Subject: Problem with smtplib and py2exe References: <3ff2767a-bbd8-4e0e-bbf4-3fa72bdca5e7@8g2000hsu.googlegroups.com> <2f783320-3364-4954-b763-1f4f3fe1f26c@y21g2000hsf.googlegroups.com> Message-ID: On Apr 8, 10:17 am, Kevin wrote: > Thanks, Terry, you pointed me in the right direction with the > reference to the "DEBUG". > > I dug out my "Learning Python" book, to read up on the debugger, and > one of the things I came across was a section on IDLE's debugger. It > said essentially that if you get an error that doesn't make sense when > you're trying to run another program (in this case, py2exe) with IDLE, > then run the program from the command line instead. I did that, and > much to my surprise, I was able to generate the 'exe' that I needed. > > I guess the incompatibility isn't necessarily between 'py2exe' and > 'smtplib' after all, but between 'py2exe' and 'IDLE'. I also recommend trying out GUI2Exe, a cool GUI wrapper for the py2exe program that allows developers to create executables quickly and easily. It also saves all your settings, which is nice if you need to re-compile frequently. I found it here: http://xoomer.alice.it/infinity77/main/GUI2Exe.html Mike From landerdebraznpc at gmail.com Mon Apr 28 03:54:47 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:54:47 -0700 (PDT) Subject: crack gmail Message-ID: crack gmail http://crack.cracksofts.com From devphyl at gmail.com Sun Apr 13 04:56:51 2008 From: devphyl at gmail.com (alefajnie) Date: Sun, 13 Apr 2008 01:56:51 -0700 (PDT) Subject: Graphical grammar in python Message-ID: <32b272bb-b5d8-415d-8640-4dc6dbd62f0c@m73g2000hsh.googlegroups.com> hi Is exist any graphical library with resize, rotate, shape recognition, ...? suitable for graphical grammar at this moment I have OpenGL (resize & rotate) and recognition solved as saved set of shapes (classes) feel free to write down any ideas :) From steve at holdenweb.com Tue Apr 1 15:37:09 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 01 Apr 2008 15:37:09 -0400 Subject: Why prefer != over <> for Python 3.0? In-Reply-To: <878wzyyqkf.fsf@physik.rwth-aachen.de> References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> <659gb2F2f84eoU2@mid.individual.net> <87hceo73ap.fsf@physik.rwth-aachen.de> <65anbqF2fg18bU1@mid.individual.net> <87r6drjss4.fsf@physik.rwth-aachen.de> <65c0bfF2ffipiU1@mid.individual.net> <878wzyyqkf.fsf@physik.rwth-aachen.de> Message-ID: <47F28EE5.5080506@holdenweb.com> Torsten Bronger wrote: > Hall?chen! > > Jorge Vargas writes: > >> On Tue, Apr 1, 2008 at 6:03 AM, Gabriel Genellina >> wrote: >> >>> [...] >>> >>> I think it should be easy to add support for ??? and even ?, >>> only the tokenizer has to be changed. >>> >> show me a keyboard that has those symbols and I'm all up for it. > > For <= I have to press three buttons, for ? I have to press four > buttons. Not much of a difference. ;-) > > However, I'm slightly disappointed with the UTF-8 support in some > mail clients involved in this thread, so Unicode surely has not > arrived yet. > I'd settle for a program listing utility that made the replacements. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From banibrata.dutta at gmail.com Thu Apr 24 07:40:06 2008 From: banibrata.dutta at gmail.com (Banibrata Dutta) Date: Thu, 24 Apr 2008 17:10:06 +0530 Subject: Python development tools In-Reply-To: <3de8e1f70804240439n26235c64o6d635ea9d4333856@mail.gmail.com> References: <09992de9-39fa-4ee6-8009-35732f3433fb@y21g2000hsf.googlegroups.com> <87fxtcnvj7.fsf@physik.rwth-aachen.de> <48106ba0$0$11087$426a34cc@news.free.fr> <873apbqypn.fsf@physik.rwth-aachen.de> <3de8e1f70804240439n26235c64o6d635ea9d4333856@mail.gmail.com> Message-ID: <3de8e1f70804240440g24375a6em5009399a0250b352@mail.gmail.com> On 4/24/08, Banibrata Dutta wrote: > On Windows, I use "PyScripter", and it's quite nice and functional. > > On 4/24/08, Torsten Bronger wrote: > > Hall?chen! > > > > Bruno Desthuilliers writes: > > > > > [...] > > > > > >> and it ends multi-line strings at single quotes. > > > > > > it chokes on unbalanced single quotes in triple-single-quoted > > > strings, and on unbalanced double-quotes in triple-double-quoted > > > strings, yes. Given that I never use triple-single-quoted strings > > > (and don't remember having seen such a thing in the thousands of > > > third-part .py files I've read so far), I'd qualify this as at > > > most a very minor annoyance. Not having proper python-shell and > > > pdb integration is wwwwaaaayyyy more annoying IMHO. > > > > My formulation was unfortunate. What doesn't work (at least for me) > > is something like > > > > """This is a docstring in which some "variables" are quoted.""" > > > > Here, "variables" doesn't seem to belong to the docstring for > > python-mode. > > > > Tsch?, > > Torsten. > > > > -- > > Torsten Bronger, aquisgrana, europa vetus > > Jabber ID: bronger at jabber.org > > (See http://ime.webhop.org for further contact info.) > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > > -- > regards, > Banibrata > http://www.linkedin.com/in/bdutta > -- regards, Banibrata http://www.linkedin.com/in/bdutta From needin4mation at gmail.com Tue Apr 29 14:14:57 2008 From: needin4mation at gmail.com (jmDesktop) Date: Tue, 29 Apr 2008 11:14:57 -0700 (PDT) Subject: Simple import question about mac osx References: Message-ID: On Apr 29, 1:54?pm, s0s... at gmail.com wrote: > On Apr 29, 12:46 pm, jmDesktop wrote: > > > > > > > On Apr 29, 1:16 pm, jmDesktop wrote: > > > > Hi, I have this code (learning from Core Python, Chun's book), module > > > named chap2.py. > > > > class FooClass(object): > > > ? ? ? ? version=0.1 > > > > ? ? ? ? def __init__(self, nm='John Doe'): > > > ? ? ? ? ? ? ? ? self.name=nm > > > ? ? ? ? ? ? ? ? print 'Created a class instance for ', nm > > > ? ? ? ? def showname(self): > > > ? ? ? ? ? ? ? ? print 'Your name is', self.name > > > ? ? ? ? ? ? ? ? print 'My name is', self.__class__.__name__ > > > > On Windows, if I compile this and then in the python interpreter type: > > > > >>> import chap2 > > > >>> foo1=FooClass() > > > > Created a class instance for ?John Doe > > > > If I do the same think on my Mac OS X 10.5.2 > > > > NameError: name 'FooClass' is not defined. > > > > I thought it was the path and did export PATH=$PATH:/mypath/ > > > topythoncode > > > > but it did not help. > > > > What am I doing wrong? ?Thank you. > > > forgot to say that on the mac I can do import chap2, but when I try > > and instantiate I get the error above. > > It shouldn't work under Windows, either. You have to qualify the name > of the class with the name of the module, as in chap2.FooClass(). Or > you can type "from chap2 import FooClass" and then you'll be able to > simply say FooClass().- Hide quoted text - > > - Show quoted text - Thanks. That worked on mac. But it does work like I said in Windows. Don't know why. Mr. Chun must also be using Windows because that is the way he does it in his book. From ewertman at gmail.com Sun Apr 27 11:05:40 2008 From: ewertman at gmail.com (Eric Wertman) Date: Sun, 27 Apr 2008 11:05:40 -0400 Subject: design choice: multi-threaded / asynchronous wxpython client? In-Reply-To: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: <92da89760804270805q31487a1et9999801ab6c27162@mail.gmail.com> HI, that does look like a lot of fun... You might consider breaking that into 2 separate programs. Write one that's threaded to keep a db updated properly, and write a completely separate one to handle displaying data from your db. This would allow you to later change or add a web interface without having to muck with the code that handles data. From hypocrite at lawyer.com Wed Apr 16 07:59:44 2008 From: hypocrite at lawyer.com (Pete Crite) Date: Wed, 16 Apr 2008 21:59:44 +1000 Subject: Python crashes consistently In-Reply-To: References: Message-ID: <43804F30-A656-40C1-805F-07DE7BE154AB@lawyer.com> On 16/04/2008, at 9:38 PM, martin.laloux at gmail.com wrote: > > which python ? from macports or macpython ? > -- > http://mail.python.org/mailman/listinfo/python-list > MacPorts. It automatically downloaded 2.5.2. My original message is reproduced below. On 16/04/2008, at 5:50 PM, Pete Crite wrote: > > Hello, > > I've been trying to install Gnumeric via MacPorts recently, but I > can't get past the installation of py25-numpy. > > It appears that python crashes consistently during installation. I'm > not sure if this is related to python itself, but I just thought I'd > ask here, just in case anyone else was aware of this problem. I did > have a few problems during the installation, so perhaps it might be > related to them? Is there anyway to check that my installation of > python is valid? > > I'm using OS X 10.4.11 on a Mac Mini PPC. I have attached the error > messages from the terminal and the mac pop-up window from the crash. > > Any help would be very much appreciated! > > Cheers, > Pete. > > > The terminal says: > >> Error: Target org.macports.build returned: shell command " cd "/opt/ >> local/var/macports/build/ >> _opt_local_var_macports_sources_rsync.macports.org_release_ports_pyth >> o >> n_py25-numpy/work/numpy-1.0.4" && /opt/local/bin/python2.5 setup.py >> config_fc --fcompiler g95 --f77exec /opt/local/bin/g95 --f90exec / >> opt/local/bin/g95 build " returned error 139 >> Command output: Running from numpy source directory. >> >> Error: The following dependencies failed to build: py25-gtk py25- >> cairo py25-numpy >> Error: Status 1 encountered during processing. >> > > > The crash window that pops up says: > >> Date/Time: 2008-03-30 11:30:33.545 +1100 >> OS Version: 10.4.11 (Build 8S165) >> Report Version: 4 >> >> Command: python2.5 >> Path: /opt/local/bin/python2.5 >> Parent: sh [247] >> >> Version: ??? (???) >> >> PID: 248 >> Thread: 0 >> >> Exception: EXC_BAD_ACCESS (0x0001) >> Codes: KERN_INVALID_ADDRESS (0x0001) at 0x82008000 >> >> Thread 0 Crashed: >> 0 _random.so 0x00571334 random_seed + 644 >> (_randommodule.c:297) >> 1 _random.so 0x0057131c random_seed + 620 >> (_randommodule.c:292) >> 2 libpython2.5.dylib 0x002b1788 PyEval_EvalFrameEx + 17604 >> (ceval.c:3573) >> 3 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 >> (ceval.c:2836) >> 4 libpython2.5.dylib 0x002b19ac PyEval_EvalFrameEx + 18152 >> (ceval.c:3669) >> 5 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 >> (ceval.c:2836) >> 6 libpython2.5.dylib 0x0023969c function_call + 332 >> (funcobject.c:524) >> 7 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: >> 1862) >> 8 libpython2.5.dylib 0x0021960c instancemethod_call + 764 >> (classobject.c:2520) >> 9 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: >> 1862) >> 10 libpython2.5.dylib 0x0026e81c slot_tp_init + 72 (typeobject.c: >> 4944) >> 11 libpython2.5.dylib 0x00273f88 type_call + 664 (typeobject.c:436) >> 12 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: >> 1862) >> 13 libpython2.5.dylib 0x002b2fc8 PyEval_EvalFrameEx + 23812 >> (ceval.c:3786) >> 14 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 >> (ceval.c:2836) >> 15 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) >> 16 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 >> (import.c:676) >> 17 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 >> (import.c:960) >> 18 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: >> 2401) >> 19 libpython2.5.dylib 0x002cd7d4 load_next + 300 (import.c:2221) >> 20 libpython2.5.dylib 0x002cde8c import_module_level + 624 >> (import.c:2002) >> 21 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 >> (import.c:2072) >> 22 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 >> (bltinmodule.c:49) >> 23 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: >> 1862) >> 24 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + >> 276 (ceval.c:3443) >> 25 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 >> (ceval.c:2067) >> 26 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 >> (ceval.c:2836) >> 27 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) >> 28 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 >> (import.c:676) >> 29 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 >> (import.c:960) >> 30 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: >> 2401) >> 31 libpython2.5.dylib 0x002cd828 load_next + 384 (import.c:2225) >> 32 libpython2.5.dylib 0x002cde8c import_module_level + 624 >> (import.c:2002) >> 33 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 >> (import.c:2072) >> 34 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 >> (bltinmodule.c:49) >> 35 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: >> 1862) >> 36 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + >> 276 (ceval.c:3443) >> 37 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 >> (ceval.c:2067) >> 38 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 >> (ceval.c:2836) >> 39 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) >> 40 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 >> (import.c:676) >> 41 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 >> (import.c:960) >> 42 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: >> 2401) >> 43 libpython2.5.dylib 0x002cd7d4 load_next + 300 (import.c:2221) >> 44 libpython2.5.dylib 0x002cde8c import_module_level + 624 >> (import.c:2002) >> 45 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 >> (import.c:2072) >> 46 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 >> (bltinmodule.c:49) >> 47 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: >> 1862) >> 48 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + >> 276 (ceval.c:3443) >> 49 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 >> (ceval.c:2067) >> 50 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 >> (ceval.c:2836) >> 51 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) >> 52 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 >> (import.c:676) >> 53 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 >> (import.c:960) >> 54 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: >> 2401) >> 55 libpython2.5.dylib 0x002cdb68 ensure_fromlist + 552 (import.c: >> 2312) >> 56 libpython2.5.dylib 0x002ce03c import_module_level + 1056 >> (import.c:2038) >> 57 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 >> (import.c:2072) >> 58 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 >> (bltinmodule.c:49) >> 59 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: >> 1862) >> 60 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + >> 276 (ceval.c:3443) >> 61 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 >> (ceval.c:2067) >> 62 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 >> (ceval.c:2836) >> 63 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) >> 64 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 >> (import.c:676) >> 65 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 >> (import.c:960) >> 66 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: >> 2401) >> 67 libpython2.5.dylib 0x002cd7d4 load_next + 300 (import.c:2221) >> 68 libpython2.5.dylib 0x002cde8c import_module_level + 624 >> (import.c:2002) >> 69 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 >> (import.c:2072) >> 70 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 >> (bltinmodule.c:49) >> 71 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: >> 1862) >> 72 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + >> 276 (ceval.c:3443) >> 73 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 >> (ceval.c:2067) >> 74 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 >> (ceval.c:2836) >> 75 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) >> 76 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 >> (import.c:676) >> 77 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 >> (import.c:960) >> 78 libpython2.5.dylib 0x002ccf20 load_package + 336 (import.c:1015) >> 79 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: >> 2401) >> 80 libpython2.5.dylib 0x002cd7d4 load_next + 300 (import.c:2221) >> 81 libpython2.5.dylib 0x002cdec0 import_module_level + 676 >> (import.c:2009) >> 82 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 >> (import.c:2072) >> 83 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 >> (bltinmodule.c:49) >> 84 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: >> 1862) >> 85 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + >> 276 (ceval.c:3443) >> 86 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 >> (ceval.c:2067) >> 87 libpython2.5.dylib 0x002b1924 PyEval_EvalFrameEx + 18016 >> (ceval.c:3660) >> 88 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 >> (ceval.c:2836) >> 89 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) >> 90 libpython2.5.dylib 0x002d8444 PyRun_FileExFlags + 288 >> (pythonrun.c:1274) >> 91 libpython2.5.dylib 0x002d87fc PyRun_SimpleFileExFlags + 840 >> (pythonrun.c:879) >> 92 libpython2.5.dylib 0x002e9b74 Py_Main + 3184 (main.c:523) >> 93 python2.5 0x000019d8 _start + 760 >> 94 python2.5 0x000016dc start + 48 >> >> Thread 0 crashed with PPC Thread State 64: >> srr0: 0x0000000000571334 srr1: >> 0x000000000000d030 vrsave: 0x0000000000000000 >> cr: 0x44244228 xer: 0x0000000000000004 lr: >> 0x000000000057131c ctr: 0x0000000000000001 >> r0: 0x0000000080000000 r1: 0x00000000bfff80a0 r2: >> 0x00000000a0001fac r3: 0x0000000002008000 >> r4: 0x0000000002008000 r5: 0x0000000000000000 r6: >> 0x00000000bfff7fbc r7: 0x00000000000fdff8 >> r8: 0x0000000001800400 r9: 0x000000000000000a r10: >> 0x000000000000000a r11: 0x000000000000003f >> r12: 0x000000009000661c r13: 0x00000000ffffffff r14: >> 0x000000000000ccac r15: 0x00000000000c6930 >> r16: 0x00000000000c9090 r17: 0x0000000000000000 r18: >> 0x000000000031bf48 r19: 0x0000000000627b04 >> r20: 0x00000000005710c4 r21: 0x0000000001858010 r22: >> 0x000000000000d248 r23: 0x0000000001803814 >> r24: 0x0000000002008000 r25: 0x0000000040000000 r26: >> 0x0000000020000001 r27: 0x0000000000000000 >> r28: 0x000000000004c0c0 r29: 0x000000000004c0c0 r30: >> 0x0000000044244228 r31: 0x00000000005710c4 >> >> Binary Images Description: >> 0x1000 - 0x1fff python2.5 /opt/local/bin/python2.5 >> 0xe2000 - 0xe5fff strop.so /opt/local/lib/python2.5/lib- >> dynload/strop.so >> 0xf2000 - 0xf3fff math.so /opt/local/lib/python2.5/lib- >> dynload/math.so >> 0x205000 - 0x31afff libpython2.5.dylib /opt/local/lib/ >> libpython2.5.dylib >> 0x565000 - 0x567fff binascii.so /opt/local/lib/python2.5/lib- >> dynload/binascii.so >> 0x570000 - 0x571fff _random.so /opt/local/lib/python2.5/lib- >> dynload/_random.so >> 0x8fe00000 - 0x8fe52fff dyld 46.16 /usr/lib/dyld >> 0x90000000 - 0x901bcfff libSystem.B.dylib /usr/lib/libSystem.B.dylib >> 0x90214000 - 0x90219fff libmathCommon.A.dylib /usr/lib/system/ >> libmathCommon.A.dylib >> 0x945e0000 - 0x94600fff libmx.A.dylib /usr/lib/libmx.A.dylib >> >> Model: PowerMac10,1, BootROM 4.8.9f1, 1 processors, PowerPC G4 >> (1.2), 1.25 GHz, 1 GB >> Graphics: ATI Radeon 9200, ATY,RV280, AGP, 32 MB >> Memory Module: DIMM0/J11, 1 GB, DDR SDRAM, PC3200U-30330 >> Modem: Jump, V.92, Version 1.0 >> Network Service: Built-in Ethernet, Ethernet, en0 >> Parallel ATA Device: ST940110A, 37.26 GB >> Parallel ATA Device: MATSHITACD-RW CW-8124 >> USB Device: Hub in Apple Pro Keyboard, Mitsumi Electric, Up to 12 >> Mb/sec, 500 mA >> USB Device: PS/2+USB Mouse, Up to 1.5 Mb/sec, 100 mA >> USB Device: C-Media USB Headphone Set, Up to 12 Mb/sec, 100 mA >> USB Device: Apple Pro Keyboard, Mitsumi Electric, Up to 12 Mb/sec, >> 250 mA >> From gagsl-py2 at yahoo.com.ar Tue Apr 1 20:28:13 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 21:28:13 -0300 Subject: manipulating hex values References: <47F26CC3.3060307@u4eatech.com> <47F28855.50908@u4eatech.com> Message-ID: En Tue, 01 Apr 2008 16:09:09 -0300, Stephen Cattaneo escribi?: > Gabriel Genellina wrote: >>
En Tue, >> 01 Apr 2008 14:11:31 -0300, Stephen Cattaneo >> escribi?: >> >>> I am relatively new to socket programming. I am attempting to use raw >>> sockets to spoof my IP address. >> Don't bother to try... > ? Is there a better solution to spoofing my IP then using raw sockets > (I'm working on a machine with multiple interfaces and need to be able > to some how specify which interface that traffic needs to be > sent/recieved to/from) It seems you are looking for NAT - have you considered the existing NAT solutions? I'm afraid I can't provide further details but it's a well-known topic. > The source of my confusion is that I need to keep my bytes formated > correctly. I am using the below 'raw socket example' proof-of-concept > code as my example. (And yes, I have tried the proof-of-concept. It > works correctly. It is not my code.) > dstAddr = "\x01\x02\x03\x04\x05\x06" > dstAddr1 = "0x010203040506" > dstAddr != dstAddr1 As others have pointed out, you're confusing numbers, strings, and how they're represented. As an example, here you have 10 different ways to get the integer "two hundreds and fifty eight": py> 258, 0x0102, int("0x0102",16) (258, 258, 258) py> int("0102",16), ord("\x02\x01".decode("utf-16-le")) (258, 258) py> struct.unpack(" struct.unpack(">H", "\x01\x02")[0] 258 py> 0402, int("0402",8), int("100000010",2) (258, 258, 258) In all cases you get an *integer* object; it doesn't matter how you wrote it, you always get the same integer, the same as writting 258 alone. > Follow up question: What is the best to store my bytes up until sending > the packets? Perhaps I should use lists of decimal numbers "list of numbers" > and then > before sending convert to hex. "convert to string of bytes" > I.E. dstAddr = [ 1, 2, 3, 4, 5, 6] > dstAddr.prepareToSend() > txFrame = struct.pack("!6s6sh",dstAddr,srcAddr,proto) + ethData I thought you were working with IP packets, not ethernet frames. If you have the MACs as a list of 6 numbers, 0-255: txFrame = struct.pack("!6B", *dstAddr) + \ struct.pack("!6B", *srcAddr) + \ struct.pack("!h", proto) + ethData > proto = 0x55aa > s = socket(AF_PACKET, SOCK_RAW, proto) > s.bind(("eth0",proto)) > > ifName,ifProto,pktType,hwType,hwAddr = s.getsockname() > srcAddr = hwAddr > # send packet to ethernet MAC: 01-02-03-04-05-06 > dstAddr = "\x01\x02\x03\x04\x05\x06" > ethData = "here is some data for an ethernet packet" > print "ethData length is: " + str(len(ethData)) > > txFrame = struct.pack("!6s6sh",dstAddr,srcAddr,proto) + ethData > s.send(txFrame) That's wrong. Your raw socket is working with PACKETS (layer 3, network), not FRAMES (layer 2). -- Gabriel Genellina From wongjoekmeu at yahoo.com Wed Apr 23 13:39:06 2008 From: wongjoekmeu at yahoo.com (wongjoekmeu at yahoo.com) Date: Wed, 23 Apr 2008 10:39:06 -0700 (PDT) Subject: Python development tools Message-ID: Are there any completely free developent tools for python scripts like IDLE. I have used IDLE , but I want to try out others also. I saw stuff like PyCrust, but I don't see that it can run the script as well. Thanks, RR From ch612bunn at gmail.com Sun Apr 27 09:18:54 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:18:54 -0700 (PDT) Subject: AVS Video Converter 5.6 crack Message-ID: AVS Video Converter 5.6 crack http://wga-cracks.crackkey.net From zillow20 at googlemail.com Tue Apr 1 22:56:50 2008 From: zillow20 at googlemail.com (zillow20 at googlemail.com) Date: Tue, 1 Apr 2008 19:56:50 -0700 (PDT) Subject: generator functions: why won't this work? Message-ID: Hi all, I'm trying to understand generator functions and the yield keyword. I'd like to understand why the following code isn't supposed to work. (What I would have expected it to do is, for a variable number of arguments composed of numbers, tuples of numbers, tuples of tuples, etc., the function would give me the next number "in sequence") #################################### def getNextScalar(*args): for arg in args: if ( isinstance(arg, tuple)): getNextScalar(arg) else: yield arg #################################### # here's an example that uses this function: # creating a generator object: g = getNextScalar(1, 2, (3,4)) g.next() # OK: returns 1 g.next() # OK: returns 2 g.next() # not OK: throws StopIteration error #################################### I'm sure I'm making some unwarranted assumption somewhere, but I haven't been able to figure it out yet (just started learning Python a couple of days ago). Any help will be appreciated :) Akiel From george.sakkis at gmail.com Tue Apr 22 09:33:40 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 22 Apr 2008 06:33:40 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <675tasF2kecjsU1@mid.uni-berlin.de> Message-ID: <76def89d-cb1a-47ce-ac47-f057e1abddf0@d1g2000hsg.googlegroups.com> On Apr 22, 6:34?am, "Diez B. Roggisch" wrote: > azrael schrieb: > > > Hy guys, > > A friend of mine i a proud PERL developer which always keeps making > > jokes on python's cost. > > > Please give me any arguments to cut him down about his commnets > > like :"keep programing i python. maybe, one day, you will be able to > > program in VisualBasic" > > > This hurts. Please give me informations about realy famous > > aplications. > > This isn't worth too much, but nontheless: > > http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html > > Klick on Perl & Python respectively to see who's going to need to use > something else some day. One more limited worth datapoint: http://www.google.com/trends?q=python+programming%2C+perl+programming&ctab=0 From andreww at datanet.ab.ca Thu Apr 10 20:05:20 2008 From: andreww at datanet.ab.ca (Andrew Warkentin) Date: Thu, 10 Apr 2008 18:05:20 -0600 Subject: Adding classes to modules at runtime from outside that module In-Reply-To: References: Message-ID: <47FEAB40.7090102@datanet.ab.ca> frambooz at gmail.com wrote: > In Python, is it possible to add classes to a module at run-time? > > Say I have a module foo and a module bar. Foo has class A and B, and >bar has class C. I want to add class C to foo so I can access it as >foo.C, but i want to do it without modifying foo's source. > > Is this at all possible? > > Yes. You would do something like import foo import bar foo.C = bar.C From cmpython at gmail.com Fri Apr 11 23:48:06 2008 From: cmpython at gmail.com (CM) Date: Fri, 11 Apr 2008 20:48:06 -0700 (PDT) Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> Message-ID: On Apr 11, 3:29 pm, Rune Strand wrote: > On Apr 11, 8:35 pm, Steve Holden wrote: > > > wxDesigner. > > Yeah, but it's like Heron of Alexandria's Aeolipile compared to the > steam engine of James Watt. > > IMHO, GUI with Python is pain, pain and utter pain. Even boring and > meaningless pain. What do you prefer, then, to do GUI with? And why? From jr9445 at ATT.COM Wed Apr 9 17:39:07 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Wed, 9 Apr 2008 16:39:07 -0500 Subject: How can I use quotes without escaping them using CSV? In-Reply-To: References: Message-ID: > -----Original Message----- > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > list-bounces+jr9445=att.com at python.org] On Behalf Of jeffself > Sent: Wednesday, April 09, 2008 5:11 PM > To: python-list at python.org > Subject: How can I use quotes without escaping them using CSV? > > > If I put an escape character in, it works. For example, if I use ~ as > my escape character, my output looks like this: > 0001[tab]Michael L. ~"Mick~" Jones[tab]189 > > I don't want that. If I don't include an escape character, it doesn't > work. > > > Here's my code: > import sys > import csv > from readexcel import * > > f = open("results.txt", 'wb') > book = sys.argv[1] > sheet = sys.argv[2] > > xl = readexcel(book) > sheetnames = xl.worksheets() > > for s in sheetnames: > if s == sheet: > writer = csv.writer(f, delimiter='\t', quoting=csv.QUOTE_NONE) > for row in xl.getiter(s): > > writer.writerow((row['Precinct'],row['Candidate'],unicode(int(row['Vote > s'])))) > f.close() > The documentation is pretty, uhm, obtuse, but you also need to set quotechar. import sys import csv names = ['Michael L. "Mick" Jones', 'Vickie A. Meyers', 'John "Jack" Smith'] writer = csv.writer(sys.stdout, delimiter='\t', quotechar='', quoting=csv.QUOTE_NONE) for i in names: writer.writerow(['a', i, 'b']) output: a Michael L. "Mick" Jones b a Vickie A. Meyers b a John "Jack" Smith b ***** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA621 From t.a.adjuster at gmail.com Thu Apr 24 15:25:01 2008 From: t.a.adjuster at gmail.com (t.a.adjuster at gmail.com) Date: Thu, 24 Apr 2008 12:25:01 -0700 (PDT) Subject: python-ldap - Operations Error References: Message-ID: On Apr 24, 2:02 pm, theivi... at gmail.com wrote: > Not sure if this is an AD thing or just something i needed to do with > our particular server/config. Glad to hear my posting helped somebody. In our case, our domain controller was passing us referrals to the Configuration, ForestDNSZones, and DomainDNSZones partitions of the directory when we were doing SCOPE_SUBTREE scoped searches from the root DN of an AD domain. When python-ldap tried to chase those referrals it did so with an anonymous bind, hence the error. Once we turned off the OPT_REFERRALS option, our only other consideration was to be sure that, when iterating over our search results, we just scrubbed out the referrals that were returned (based on the referrals being lists and the real search results being dictionaries). This is a bit quick and dirty, perhaps, but it's what did the trick for us. Evan From aldo at nullcube.com Wed Apr 2 00:38:32 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Wed, 2 Apr 2008 15:38:32 +1100 Subject: ANN: pry unit testing framework In-Reply-To: <87zlscx5lt.fsf@benfinney.id.au> References: <87zlscx5lt.fsf@benfinney.id.au> Message-ID: <20080402043832.GA23773@nullcube.com> Hi Ben, > > We are happy to announce the first release of Pry, a unit testing > > framework. > > Thanks for the announcement, and for the software. > > If Pry is already incompatible with xUnit (i.e. Python's 'unittest'), > could we please have names that adhere to the Python style guide > ? > > In particular the method names 'setUp', 'setUpAll', 'tearDown', > 'tearDownAll' don't comply with the style guide. Compliant names for > those methods would be 'set_up', 'set_up_all', etc. Keeping fixture setUp and tearDown names the same makes the transition from unittest to pry easier. At the moment, converting to pry is very simple - inherit your suites from AutoTree, rewrite tests to use assertions, and then instantiate your suites at the end of the module. Voila! You have a nice command-line interface, coverage analysis, and an easy path to saner, better-engineered unit tests. Internal consistency in this case is much more important than the style guide, which intends only to standardise naming conventions within the Python standard library, and even there does not go so far as to suggest converting existing modules to the new convention. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From HDoran at air.org Fri Apr 18 11:15:30 2008 From: HDoran at air.org (Doran, Harold) Date: Fri, 18 Apr 2008 11:15:30 -0400 Subject: Making Windows Larger in Tkinter Message-ID: <2323A6D37908A847A7C32F1E3662C80E017BE072@dc1ex01.air.org> Thanks to some help I received on list the other day, I now have a very nice windows-based application that implements multiple programs. This is a very powerful tool. Now I am working to make this window pretty. One problem I cannot find help on is how to make the windows a certain size. For example, I have added in a root.title() with a lot of text in the file example.py below. Is it possible to make the window box a specific size, or by default, always be large enough to show the entire text in root.title? example.py from Tkinter import * import tkMessageBox def callback(): print "called the callback!" def message(): if tkMessageBox.askokcancel("Quit", "Do you really wish to quit?"): root.destroy() def about(): tkMessageBox.showinfo("About", "Foo?") root = Tk() root.title('Hello World: How Can we see the entire title?') # create a menu menu = Menu(root) root.config(menu=menu) filemenu = Menu(menu) menu.add_cascade(label="File", menu=filemenu) filemenu.add_command(label="New", command=message) filemenu.add_command(label="Open...", command=callback) filemenu.add_separator() filemenu.add_command(label="Exit", command=message) helpmenu = Menu(menu) menu.add_cascade(label="Help", menu=helpmenu) helpmenu.add_command(label="About...", command=about) mainloop() -------------- next part -------------- An HTML attachment was scrubbed... URL: From workitharder at gmail.com Tue Apr 1 18:49:13 2008 From: workitharder at gmail.com (bukzor) Date: Tue, 1 Apr 2008 15:49:13 -0700 (PDT) Subject: Directed Graph Traversal References: <804682cb-2da6-4d85-83d4-c7425c498534@p25g2000hsf.googlegroups.com> Message-ID: <31d91a7b-80db-4ca2-a821-aab55e9e6a11@m73g2000hsh.googlegroups.com> On Apr 1, 3:46 pm, bukzor wrote: > Can someone point me in the direction of a good solution of this? I'm > using it to construct a SQL query compiler, where each node is a table > and each edge is a join. I'm planning on using the NetworkX library if > possible.https://networkx.lanl.gov/reference/networkx/ > > Given a directed graph and a list of points in the graph, what is the > minimal subgraph that contains them all? It is preferable that the > subgraph is a tree. > > A -- B -- C -- D > | | > E -- F > > A, B, F => ABEF (or ABCF) > A, F, C => ABCF > A, E, D => ABCD > E > > Thanks! > --Buck edited to correct diagram for monospace font... From jonathan.lukens at gmail.com Thu Apr 17 13:22:46 2008 From: jonathan.lukens at gmail.com (Jonathan Lukens) Date: Thu, 17 Apr 2008 10:22:46 -0700 (PDT) Subject: help with docutils Message-ID: <09658c2d-f726-47ff-9e24-839703b80918@y21g2000hsf.googlegroups.com> I am trying generate html from a reST document, both the body of the document and a table of contents, each contained in separate variables. I had initially assumed that there would be a 'toc' key in publish_parts, but apparently there is not. Is there a relatively easy way to achieve this? From john00587 at gmail.com Mon Apr 21 01:39:59 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:39:59 -0700 (PDT) Subject: xplite 1.6 keygen Message-ID: <1bc4fbc8-8224-462f-9aa5-659c04928263@y22g2000prd.googlegroups.com> xplite 1.6 keygen http://cracks.00bp.com F R E E C R A C K S From vemburuby at gmail.com Fri Apr 25 08:32:16 2008 From: vemburuby at gmail.com (mahalakshmi) Date: Fri, 25 Apr 2008 05:32:16 -0700 (PDT) Subject: @@@@ THEY DO DIFFERENT THINGS TO GET HERE@@@@@ Message-ID: <8f78e482-1df0-4ec9-9728-67c5101d81e2@w8g2000prd.googlegroups.com> HAI !!!!!!!!!!!!!!!!! EARN MORE MONEY INTERESTED HERE.................SEE IN MY SITE. THEY DO DIFFERENT THINGS TO GET HERE........ www.getitlove.blogspot.com www.doitbetter5.blogspot.com From steven.p.clark at gmail.com Tue Apr 8 11:38:17 2008 From: steven.p.clark at gmail.com (Steven Clark) Date: Tue, 8 Apr 2008 11:38:17 -0400 Subject: list.sort(): heaviest item? In-Reply-To: <661hbrF2iip12U1@mid.uni-berlin.de> References: <661hbrF2iip12U1@mid.uni-berlin.de> Message-ID: <663744510804080838h4506a6d5v46047c18a0b34060@mail.gmail.com> > You can pass a cmp-function that will always make one object being greater > than all others. > > Diez > -- Yeah, I figured it out 2 minutes after I posted, d'oh! class Anvil(object): def __cmp__(self. other): return 1 Sorry for the wasted space. From elnoire at gmail.com Sun Apr 20 02:04:40 2008 From: elnoire at gmail.com (elnoire at gmail.com) Date: Sat, 19 Apr 2008 23:04:40 -0700 (PDT) Subject: Checking if a text file is blank Message-ID: Greetings! I've just started learning python, so this is probably one of those obvious questions newbies ask. Is there any way in python to check if a text file is blank? What I've tried to do so far is: f = file("friends.txt", "w") if f.read() is True: """do stuff""" else: """do other stuff""" f.close() What I *mean* to do in the second line is to check if the text file is not-blank. But apparently that's not the way to do it. Could someone set me straight please? From wesleymesquita at gmail.com Sun Apr 6 08:30:54 2008 From: wesleymesquita at gmail.com (Wesley Mesquita) Date: Sun, 6 Apr 2008 05:30:54 -0700 (PDT) Subject: Control process execution Message-ID: <1d1bbea2-a503-4db5-bd3f-c45c29916b9c@13g2000hsb.googlegroups.com> Hi all, I am trying to create a test environment to a couple C applications (simple UDP and TCP server/clients), so I want to write this in python and I m looking for ways to do it. Basically I need an execution timer and timeout control (to kill the apps in certain situations). Looking at google, I found the Pexpect package, but I m a little bit lost in using it. So, any good suggetions? Thanks in advance. From deets at nospam.web.de Tue Apr 1 05:43:06 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 01 Apr 2008 11:43:06 +0200 Subject: troll poll References: Message-ID: <65eee6F2eg18jU1@mid.uni-berlin.de> Delaney, Timothy (Tim) wrote: > George Sakkis wrote: > >> On Mar 31, 1:46 pm, Marc 'BlackJack' Rintsch wrote: >> >>>> More specifically, who can create a bigger mess on c.l.py? (check >>>> one) >>> >>>> [ ] - Xah Lee >>>> [X] - castironpi >>> >>> Xah Lee's postings might be trolls but sometimes they spark some >>> really interesting and serious subthreads, while the nonsense of >>> castironpi is just irritating noise. >> >> Which is exactly why there are rarely any replies to his random >> gibberish, so I would say that he/she/it has almost no effect on >> c.l.py. Yet I wish plonking was possible through Google groups. > > I find classifying all their posts as spam works fairly well. I'm also astonished - once I figured out how this knode works regarding killfiles, all I get to see from them is the occasional citation. The only irritating thing is if castironpi answers to one of *my* posts, and somebody else tells him to shut up... which then appears below my post in my reader ... diez From leoniaumybragg at gmail.com Sat Apr 26 07:02:11 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 04:02:11 -0700 (PDT) Subject: b-jigsaw serial crack keygen Message-ID: b-jigsaw serial crack keygen http://cracks.00bp.com F R E E C R A C K S From flarefight at googlemail.com Tue Apr 29 16:24:34 2008 From: flarefight at googlemail.com (flarefight at googlemail.com) Date: Tue, 29 Apr 2008 13:24:34 -0700 (PDT) Subject: py2exe Icon Resources Message-ID: <40c03afe-b2c5-4793-b7c3-f5a97360fe6c@a23g2000hsc.googlegroups.com> I have created an app using python and then converting it to an exe using py2exe, and have the following code: "icon_resources": [(1, "appFavicon.ico"), (2, "dataFavicon.ico")] in my py2exe setup file, the appFavicon works fine and it sets that as the app icon thats fine, but the program creates data files (like documents) and i wanted them to have a different icon... I package my apps using Inno Setup 5, and it registers the file type fine so that it loads on double click, what i cant do is set the icon for the file. as you can see i have packaged two different icons with py2exe but when i set DefaultIcon in the registry to "C:\pathtoapp\myapp.exe,2" it doesnt work, nor does it work with a 1 or a %1 or indeed with passing a path to the icon itself, nothing seems to work!! how do you access the other icons generated from py2exe, or how do you set the registry up so that i looks for the icon correctly, any help appreciated, Caspar From rajeshkataraki at gmail.com Mon Apr 28 07:37:02 2008 From: rajeshkataraki at gmail.com (rajesh kataraki) Date: Mon, 28 Apr 2008 04:37:02 -0700 (PDT) Subject: Need help on left padding Message-ID: Hello, My requirement is I am using one variable ex. var = 5 which is integer. And this variable, I m using in some string. But I want this var to be used as 005 again integer in this string. The snippet of string is as follows: container_name = "%s-%d-dso-%s.so" % (platform_affix,var, rteset) Please let me know how can I implement this efficiently in python language. Need help urgent. Thanks, -Rajesh From deets at nospam.web.de Tue Apr 22 11:38:36 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 17:38:36 +0200 Subject: Does Python 2.5.2's embedded SQLite support full text searching? In-Reply-To: <6763uaF2norrtU1@mid.uni-berlin.de> References: <1208794249.15992.1249049327@webmail.messagingengine.com> <6763uaF2norrtU1@mid.uni-berlin.de> Message-ID: <676f4fF2nfvqgU2@mid.uni-berlin.de> Diez B. Roggisch schrieb: > Daniel Fetchinson schrieb: >>> Does Python 2.5.2's embedded SQLite support full text searching? >>> >>> Any recommendations on a source where one can find out which SQLite >>> features are enabled/disabled in each release of Python? I'm trying to >>> figure out what's available in 2.5.2 as well as what to expect in 2.6 >>> and 3.0. >> >> Sqlite itself is not distributed with python. Only a python db api >> compliant wrapper is part of the python stdlib and as such it is >> completely independent of the sqlite build. In other words, if your >> sqlite build supports full text searching you can use it through the >> python sqlite wrapper (that is part of the stdlib) and if it doesn't >> then not. This is true for any sqlite feature though. >> >> So if you need an sqlite feature just go ahead and build your own >> sqlite with that feature enabled and use that feature with the stock >> python sqlite wrapper that comes with the stdlib. > > I doubt that. This would mean that Python comes with a mechanism to > dynamically load different libs for the same module, opening a buttload > full of error-conditions regarding library versions & changing semantics > depending on system configuration. And Paul Melis showed me that exactly that is the case. Sorry for the noise. Diez From jura.grozni at gmail.com Tue Apr 22 06:25:59 2008 From: jura.grozni at gmail.com (azrael) Date: Tue, 22 Apr 2008 03:25:59 -0700 (PDT) Subject: Python Success stories Message-ID: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Hy guys, A friend of mine i a proud PERL developer which always keeps making jokes on python's cost. Please give me any arguments to cut him down about his commnets like :"keep programing i python. maybe, one day, you will be able to program in VisualBasic" This hurts. Please give me informations about realy famous aplications. From __peter__ at web.de Wed Apr 30 10:41:02 2008 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Apr 2008 16:41:02 +0200 Subject: Simple TK Question - refreshing the canvas when not in focus References: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> <4818349e$0$2959$ba620e4c@news.skynet.be> <182ace66-bdf6-409c-85ee-fd764de8e1c6@z72g2000hsb.googlegroups.com> Message-ID: blaine wrote: > Still doesn't work. I'm looking into using wx instead... > > This is the full code - does it work for anyone else? Just do a echo > 'line 0 0 10 10' > dev.file Haven't tried it, but I think that the problem is that you are updating the UI from the "readthread". A good example to model your app after is here: http://effbot.org/zone/tkinter-threads.htm Peter From pieter.cogghe at gmail.com Thu Apr 10 05:58:14 2008 From: pieter.cogghe at gmail.com (Pieter) Date: Thu, 10 Apr 2008 11:58:14 +0200 Subject: call python from c -> pass and return arrays/lists Message-ID: <5c0bbcb30804100258l2e562ae4ga26781d372899d03@mail.gmail.com> Hi all, I'm trying to call a python function from c. I need to pass an 2D-array to python and the python function returns a 2D-list back to c. I googled arround and I found how to pass ints/strings/... back and forth, but didn't find anything on passing arrays. For an int it's as simple as this: PyArg_Parse(ret,"i#", &my_long); But I hacve no idea how to parse python lists to a c-array? thanks a lot, Pieter -- Pieter Cogghe Ganzendries 186 9000 Gent 0487 10 14 21 From arnodel at googlemail.com Thu Apr 10 16:08:30 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 10 Apr 2008 13:08:30 -0700 (PDT) Subject: Obtaining a callable class method object from a specific class References: Message-ID: On Apr 10, 7:47?pm, Nathan Duran wrote: > This is a contrived pseudocode example which has been broken out of a ? > larger problem, so it may seem like a strange thing to want to do, ? > but... > > I have a group of objects which inherit (single) from a common base ? > class like so: > > --- > class Root(object): > ? ? ?@classmethod > ? ? ?def CumulativeScore(cls, arg): > ? ? ? ? ?#Ask every child class to > ? ? ? ? ?#generate a score and add > ? ? ? ? ?#them together > ? ? ? ? ?cumulativescore = 0 > ? ? ? ? ?for base in cls.mro(): > ? ? ? ? ? ? ?cumulativescore += base.Score(arg) > ? ? ? ? ?return cumulativescore > ? ? ?#No Score method defined in Root so don't try to call one! > > class BranchChild(Root): > ? ? ?@classmethod > ? ? ?def Score(cls, arg): > ? ? ? ? ?return 1 > > class LeafChild(BranchChild): > ? ? ?@classmethod > ? ? ?def Score(cls, arg): > ? ? ? ? ?return 3 > > class LeafChild2(BranchChild): > ? ? ?pass > ? ? ?#No Score method defined here, either! > I won't question why you want to do this... Here is a solution base on a metaclass, but it feels wrong. @classmethod def score(cls, args): return 0 def totalscore(rootcls, arg): return sum(cls.score(arg) for cls in rootcls.mro() if hasattr(cls, 'score')) class MetaScore(type): def __new__(meta, name, bases, attrs): attrs.setdefault('score', score) return type.__new__(meta, name, bases, attrs) class Root(object): __metaclass__ = MetaScore class Branch(Root): @classmethod def score(cls, arg): return 1 class Leaf(Branch): @classmethod def score(cls, arg): return 3 class Leaf2(Branch): pass --------- Test --------- >>> totalscore(Root, 1) 0 >>> totalscore(Branch, 1) 1 >>> totalscore(Leaf, 1) 4 >>> totalscore(Leaf2, 1) 1 -- Arnaud From jkrukoff at ltgc.com Tue Apr 29 18:29:44 2008 From: jkrukoff at ltgc.com (John Krukoff) Date: Tue, 29 Apr 2008 16:29:44 -0600 Subject: i want to add a timeout to my code In-Reply-To: References: <53ffe104-be3b-43e2-b5c8-4ce5886ac60d@b1g2000hsg.googlegroups.com> <1f70ea43-7909-4bd8-b63d-2467e8a0542f@c65g2000hsa.googlegroups.com> Message-ID: <1209508184.5278.58.camel@localhost.localdomain> On Tue, 2008-04-29 at 14:47 -0700, maehhheeyy wrote: > On Apr 17, 4:24 pm, Miki wrote: > > On Apr 17, 1:10 pm,maehhheeyy wrote: > > > > > I want to add a timeout so that when I pull out my gps from my serial > > > port, it would wait for a bit then loop and then see if it's there. I > > > also want to add a print statement saying that there is no GPS device > > > found. However when I run my code and unplug my serial port, my code > > > will just hang until I plug it back in. > > > This is my code right now: > > > > > def GetGPS(): > > > data = [] > > > #Open com1: 9600,8,N,1 > > > fi = serial.Serial(0, timeout = 1) > > > print '[gps module] SERIAL PORT OPEN ON COM1:' > > > > > can anyone help me please? Thanks. > > > > http://docs.python.org/lib/node545.html > > > > HTH, > > -- > > Miki http://pythonwise.blogspot.com > > I tried the code onto my codes but what came out was that in the line > signal.signal(signal.SIGSLRM, handler), an attributeError appeared > reading that 'module' object has no attribute 'SIGALRM' > -- > http://mail.python.org/mailman/listinfo/python-list Are you writing your program on windows, or some other platform which is not unix? -- John Krukoff Land Title Guarantee Company From urquhart.nak at gmail.com Wed Apr 30 06:28:47 2008 From: urquhart.nak at gmail.com (urquhart.nak at gmail.com) Date: Wed, 30 Apr 2008 03:28:47 -0700 (PDT) Subject: crack cream Message-ID: <3ef360aa-a61f-4aef-9d39-eb434e714ea4@w8g2000prd.googlegroups.com> crack cream http://crack.cracksofts.com From rhamph at gmail.com Sun Apr 13 12:16:39 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Sun, 13 Apr 2008 09:16:39 -0700 (PDT) Subject: C API design flaw (was: Re: Multiple independent Python interpreters in a C/C++ program?) References: <624b9d79-bc02-4f52-bc97-52019bf916d0@n1g2000prb.googlegroups.com> <8e73acd5-b50a-4e0d-9193-8615cb38e5a2@s39g2000prd.googlegroups.com> Message-ID: On Apr 12, 2:02 pm, sturlamolden wrote: > On Apr 12, 7:05 pm, sturlamolden wrote: > > > In theory, a GIL private to each (sub)interpreter would make Python > > more scalable. The current GIL behaves like the BKL in earlier Linux > > kernels. However, some third-party software, notably Apache's > > mod_python, is claimed to depend on this behaviour. > > I just looked into the reason why ctypes, mod_python, etc. depend on a > shared GIL. Well ... PyGILState_Ensure() does not take an argument, so > it does not know which interpreter's GIL to acquire. Duh! > > The sad fact is, the functions in Python's C API does not take the > interpreter as an argument, so they default to the one that is > currently active (i.e. the one that PyThreadState_Get()->interp points > to). This is unlike Java's JNI, in which all functions take the > "environment" (a Java VM instance) as the first argument. > > IMHO, I consider this a major design flaw in Python's C API. In a more > well thought API, PyGILState_Ensure would take the interpreter > returned by Py_NewInterpreter as an argument, and thus know the > interpreter with which to synchronize. > > I complained about this before, but the answer I got was that the > simplified GIL API would not work if interpreters has a separate GIL. > Obviously it would not work as long as the PyGILState_Ensure does not > take any arguments. The lack of a leading VM argument in > PyGILState_Ensure, and almost every function in Python's C API, is the > heart of the problem. Alternatively, the multiple interpreter API could be ripped out, and you could just use separate threads. Do you have a use case that requires it? From seberino at spawar.navy.mil Tue Apr 1 14:20:05 2008 From: seberino at spawar.navy.mil (seberino at spawar.navy.mil) Date: Tue, 1 Apr 2008 11:20:05 -0700 (PDT) Subject: What motivates all unpaid volunteers at Pycon? References: <7b539c8e-af4c-4409-81bc-d94e687eea59@i7g2000prf.googlegroups.com> Message-ID: <12d7412e-9f87-4798-a319-a78a27f68d00@e6g2000prf.googlegroups.com> On Mar 31, 7:35 pm, a... at pythoncraft.com (Aahz) wrote: > There really isn't any simple answer. Most people seem to be motivated > to help out their communities, I still think all this unselfishness is noteworthy and curious. Chris From victorsubervi at gmail.com Mon Apr 7 14:17:26 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Mon, 7 Apr 2008 19:17:26 +0100 Subject: Adding Images To MySQL In-Reply-To: References: <4dc0cfea0804050732x7dc2ac41n64d56dda9da27a82@mail.gmail.com> Message-ID: <4dc0cfea0804071117n49dd6faam90032dbc787487e5@mail.gmail.com> in line... On 4/5/08, Gabriel Genellina wrote: > > En Sat, 05 Apr 2008 11:32:00 -0300, Victor Subervi > escribi?: > > >> * *- You say Content-Type: image/jpeg but you emit HTML code. You're > >> lucky > > if you see any > > > >> * *text at all. > > > > Well, I tried Content-Type: text/html and that threw an HTTP 500 Error. > > If your script raised any exception, that's the expected code. (500 = > internal error = your code has errors). But it's not very useful for > debugging; using cgitb or wrapping the code in try/except as has already > been suggested, lets you see the exception and traceback. Yes, and I have employed your suggestion of cgtib, and I sent you personally under separate cover the errors, since I forgot to include them in this post. >> * *- HTTP 200 is not an error, it means the request was successful. > > > > When it doesn?t execute the code, how can it be called successful? If it > > doesn?t execute the code, how can you say it?s not an error? What is it, > > then? > > Well, your web server thinks all went ok... BTW, you did't provide details > about it, I *guess* you're using CGI because of the print "Content-Type" > line. Yes, that is correct... >> * *- As a general advice, try to isolate the problems. Test the database > > stuff alone, in a local > >> * *application. Test the cgi script alone, without database > interaction. > > Test the database stuff in > >> * *the web server (better if you have a shell account). Merge all and > >> test > > again. > > > > Very good advice. Please help me understand how to do that. > > > > This is what I have done. I have tried these: > > > > sql = "'insert into products (" + col_names + ") values (" + val + ")', > > (" + > > col_names + ")" > > > > cursor.execute(sql) > > > > and > > > > sql = "'insert into products (" + col_names + ") values (" + val + ")'" > > > > cursor.execute(sql, (col_names,)) > > > > Neither work. > > You got a syntax error, I guess. What's that ' at the start? > I'll try to explain it from the ground up. This would be a valid SQL > statement:: > > insert into PRODUCTS (PRODID, NAME, DESCRIPTION) > values (123, 'Easter egg 80g', 'A longer description'); > > In Python, you need the SQL text inside a string:: > > sql = "insert into PRODUCTS (PRODID, NAME, DESCRIPTION) " \ > "values (123, 'Easter egg 80g', 'A longer description');" > > and you can execute it with:: > > cursor.execute(sql) > > That would be OK when you create the database for the first time. Later > your boss comes in and says: "We've got bigger eggs! Code 124, 150g each. > We need them in the database". You write an sql statement similar to > above. Some days later, they decide to sell bubble gum. Forty-two > different sizes and flavors and brands. You don't want to write all that > sql statements by hand. Your first thought is to build the sql text by > pieces:: > > sql = "insert into PRODUCTS (PRODID, NAME, DESCRIPTION) " \ > "values ("+str(prodid)+", '"+prodname+"', '"+description+"');" > > But then you remember to have read something about sql injection and you > don't like that mess of " + ) ' ( anyway. After reading some articles > about DBAPI 2, PEP 249, the MySQLdb module, you write this:: > > sql = "insert into PRODUCTS (PRODID, NAME, DESCRIPTION) " \ > "values (%s,%s,%s);" > cursor.execute(sql, (prodid, prodname, description)) > > and it works fine. > > Note that execute has two arguments: first, a string with the sql > statement text; second, a tuple containing the values. The %s in the sql > text are placeholders, they're replaced with the corresponding value from > the second argument. And there is no ' anywhere. Well, what I did, that now works, was essentially what you suggested, and simply assigned null values to variables that accept null values in the database. That works. What I was trying to do was build up just those variables that were to be updated or entered, and supply only those arguments. At this point it is rather academic, but can that be done? > However, if I print what that code spits out: > > > > sql = "'insert into products (" + col_names + ") values (" + val + ")', > > (" + > > col_names + ")" > > > > print sql > > > > then copy and paste it into a cursor.execute() statement, viola! > > Everything > > works _just_fine_. Go figure. Why?? > > What you have done has no sense - why do you think it should work? See above. > pic1 = _mysql.escape_string(f) > > > > It does not like this (forgot error): > > > > pic1 = MySQLdb.Binary(f) > > You should make the above work. Look at the exception, read the error > message, look at the traceback. There are a lot of info there. Amazingly (because I thought I had tested this) both the escape string and the db Binary work now. > Escaping the string, I can successfully load this image into the > > database, > > along with all the other fields. Now, when I load an image from the form > > on > > the previous page with this code: > > > > > > > print '"', MySQLdb.Binary(data[14]), '"' > > > > and send the form off to the next page, when I process it on that page > > Why do you do *that*??? That element is for the user to upload a > file; if the file is already on the server, why do you transfer it from > server to client and back to server? I doubt it can work this way. And why > are you using Binary here? Binary is for sql stuff and you're building an > HTML page here. (btw, didn't you say that Binary doesn't work?). I said it did not work in the other page, but now it does. Anyway, what gets uploaded is a binary string. How can I convert that into a pretty picture? > pic1 = _mysql.escape_string(pic1) > > > > print pic1 > > > > it prints out a messy binary that (almost) starts with something like > > ?This > > program can only be run in Win32?, whatever that means. But a binary is > > printed. (It may be an infinite binary, I stopped it after a few > > minutes.) > > Looks like a .exe; somehow you managed to upload a .exe instead of a jpg, > I presume... It was an image. At any rate, I do not see that in the images (or binary strings) now loaded. > Now, if I stick it into the cursor.execute like I did above, it throws an > > HTTP non-error non-posting-to-the-database 200 error. I?m more than > > happy to > > separate all this garbage out for further testing, but I don?t know how > > to > > do that. Your help is very much appreciated. > > It seems you have a basic misunderstanding of how web applications work. > Reading a book like "Python Web Programming" by Steve Holden might help. > > http://www.amazon.com/Python-Programming-Landmark-Steve-Holden/dp/0735710902 I have done a lot of reading over the years and I presume a lot of forgetting. At any rate, looks like everything is working, thanks to your help, except for the displaying of the image as opposed to the binary string, which is no doubt some other stupid little mistake of mine. No errors to send to analyze now. Can you shed some light on this last issue? Again, thank you very much for your help and patience! Victor -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Tue Apr 15 10:36:57 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 15 Apr 2008 15:36:57 +0100 Subject: Get oldest folder In-Reply-To: <22671872.735671208269119432.JavaMail.root@hrndva-web19-z02> References: <22671872.735671208269119432.JavaMail.root@hrndva-web19-z02> Message-ID: <4804BD89.6000208@timgolden.me.uk> jyoung79 at kc.rr.com wrote: > I'd like to be able to get the path to the oldest folder in whatever directory > I'm currently in. Is there a simple way to go about this? > I'd like it to run on both OS X and Windows XP. > I found this example but was curious if there's a better way to do this? Better: I don't know. Alternative, certainly: import os, glob PATH = "c:/python25/lib/site-packages" print min ((f for f in glob.glob (os.path.join (PATH, "*")) if os.path.isdir (f)), key=os.path.getctime) TJG From carbanancizpo at gmail.com Fri Apr 18 16:57:54 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:57:54 -0700 (PDT) Subject: foundation crack Message-ID: <1e167114-2be7-489d-867a-676e309bc61a@c65g2000hsa.googlegroups.com> foundation crack http://cracks.12w.net F R E E C R A C K S From wwzaygvm at gmail.com Wed Apr 16 17:01:55 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 14:01:55 -0700 (PDT) Subject: win xp sp2 keygen Message-ID: <97b9d09b-16db-421f-a96b-332ef246757a@f36g2000hsa.googlegroups.com> win xp sp2 keygen http://cracks.12w.net F R E E C R A C K S From brooklineTom at gmail_spam_blocking_suffix.com Tue Apr 1 08:23:18 2008 From: brooklineTom at gmail_spam_blocking_suffix.com (brooklineTom at gmail_spam_blocking_suffix.com) Date: Tue, 01 Apr 2008 08:23:18 -0400 Subject: class super method References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> Message-ID: On Mon, 31 Mar 2008 21:41:37 -0500, Ed Leafe wrote: >On Mar 31, 2008, at 5:58 PM, George Sakkis wrote: > >>> is there any tutorial for super method (when/how to use it)? >>> >>> or maybe someone could explain me how it works? >>> >>> thx >> >> Super is one of the dark corners of the language [1,2]... a good rule >> of thumb is to stay away from it, or at least stick to its basic >> usage. > > > I disagree - super is quite elegant and dependable. > > Because Python support multiple inheritance, it is difficult to >manually ensure that when augmenting a method that the correct >superclass calls are made. super() handles that without having to >guess as to what the correct inheritance hierarchy is. > > In my own project (Dabo), we use mixin classes liberally to provide >consistent behavior across our UI classes. The use of super makes >customizing __init__() behavior, for example, quite straightforward. >The general form looks like: > >class DaboUIClass(dabo.ui.dControlMixin, someWxPythonClass): > def __init__(self, *args, **kwargs): > doOurCustomStuffBeforeTheSuperCall() > super(DaboUIClass, self).__init__(*args, **kwargs) > doOurCustomStuffAfterTheSuperCall() > > This has worked reliably for us in every place where we have used it. >There's nothing dark and mysterious about it at all. Perhaps it's the oo-think that seems "dark and mysterious", rather than anything about super. In my experience, "super" works just fine. It is a bit tedious, in that it's all too easy to forget to change the first parameter when moving a method that contains super to a different class. I've also found myself wondering: 1. What are the two arguments to super used for? 2. What happens when the method supplied *after* the super is different from the containing method? In the above example what happens if: class DaboUIClass(dabo.ui.dControlMixin, someWxPythonClass): def __init__(self, *args, **kwargs): doOurCustomStuffBeforeTheSuperCall() super(DaboUIClass, self).callRandomMethod(foobar) doOurCustomStuffAfterTheSuperCall() From istvan.albert at gmail.com Wed Apr 9 11:59:34 2008 From: istvan.albert at gmail.com (Istvan Albert) Date: Wed, 9 Apr 2008 08:59:34 -0700 (PDT) Subject: I am worried about Python 3 References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> <47fce3ca$0$36346$742ec2ed@news.sonic.net> Message-ID: On Apr 9, 11:53 am, John Nagle wrote: > The general consensus is that Python 3.x isn't much of an there are a number of unfortunate typos in there that interfere with the message, instead of "The general consensus is" I think you actually meant "In my opinion" i. From pscott at uwc.ac.za Mon Apr 7 04:03:35 2008 From: pscott at uwc.ac.za (Paul Scott) Date: Mon, 07 Apr 2008 10:03:35 +0200 Subject: First Python project - comments welcome! Message-ID: <1207555415.6966.88.camel@paul-laptop> I have started, and made some progress (OK it works, but needs some love) on my first real Python application. http://cvs2.uwc.ac.za/trac/python_tools/browser/podder I would love some feedback on what I have done. In total this has taken me 5 nights to do (I am working on it at night as PHP, not Python, is my day job), so it can probably do with *lots* of improvement. All code is GPL. If anyone on this list is willing/able, please do give me a few pointers, even if it is "This is total crap - RTFM and come back when you are ready" I would really appreciate it! Many thanks, and thank you to this community for helping me through the initial bumps of getting into Python - a great dev tool IMHO! --Paul -------------- next part -------------- All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm From hopeorpha308 at gmail.com Sun Apr 27 07:45:20 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:45:20 -0700 (PDT) Subject: F-Secure 2007 crack Message-ID: <462e0099-151f-440e-8f97-cfa306ba801f@d1g2000hsg.googlegroups.com> F-Secure 2007 crack http://wga-cracks.crackkey.net From deets at nospam.web.de Wed Apr 9 17:25:47 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 09 Apr 2008 23:25:47 +0200 Subject: basic python question about for loop In-Reply-To: <5f71771d-e31d-439a-9ab9-5ea111a68b46@24g2000hsh.googlegroups.com> References: <664ovoF2iq9i0U1@mid.uni-berlin.de> <5f71771d-e31d-439a-9ab9-5ea111a68b46@24g2000hsh.googlegroups.com> Message-ID: <664qj3F2ied87U1@mid.uni-berlin.de> jmDesktop schrieb: > On Apr 9, 4:58 pm, "Diez B. Roggisch" wrote: >> jmDesktop schrieb: >> >> >> >> >> >>> From the Python.org tutorial: >>>>>> for n in range(2, 10): >>> ... for x in range(2, n): >>> ... if n % x == 0: >>> ... print n, 'equals', x, '*', n/x >>> ... break >>> ... else: >>> ... # loop fell through without finding a factor >>> ... print n, 'is a prime number' >>> ... >>> 2 is a prime number >>> 3 is a prime number >>> 4 equals 2 * 2 >>> 5 is a prime number >>> 6 equals 2 * 3 >>> 7 is a prime number >>> 8 equals 2 * 4 >>> 9 equals 3 * 3 >>> first time 2 mod 2, 2/2, no remainder == 0, what am I doing wrong? >>> Why did it fall through? >> print out what range(2, n) for n == 2 is. >> >> And if you didn't know - 2 *IS* a prime. >> >> Diez- Hide quoted text - >> >> - Show quoted text - > > I do not understand. for in loops over a sequence. And of course it doens't if the sequence is empty, because you can't loop over something that is empty, can't you? and range(2,2) is the empty sequence. Diez From grg2 at comcast.net Wed Apr 9 16:37:49 2008 From: grg2 at comcast.net (A_H) Date: Wed, 9 Apr 2008 13:37:49 -0700 (PDT) Subject: Love matplotlib, but.... Message-ID: I love matplotlib, but I want to do a polar plot using your basic compass type plot, i.e. zero degrees at the top, degrees going clockwise. I don't see a real easy way to do this. Any examples? Thanks! From kinch1967 at gmail.com Sun Apr 27 12:46:59 2008 From: kinch1967 at gmail.com (bullockbefriending bard) Date: Sun, 27 Apr 2008 09:46:59 -0700 (PDT) Subject: design choice: multi-threaded / asynchronous wxpython client? References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: <960ab78d-e764-4233-bab4-02ea0948db46@l28g2000prd.googlegroups.com> On Apr 27, 11:27?pm, "BJ?rn Lindqvist" wrote: > I think twisted is overkill for this problem. Threading, elementtree > and urllib should more than suffice. One thread polling the server for > each race with the desired polling interval. Each time some data is > treated, that thread sends a signal containing information about what > changed. The gui listens to the signal and will, if needed, update > itself with the new information. The database handler also listens to > the signal and updates the db. So, if i understand you correctly: Assuming 8 races and we are just about to start the race 1, we would have 8 polling threads with the race 1 thread polling at faster rate than the other ones. after race 1 betting closed, could dispense with that thread, change race 2 thread to poll faster, and so on...? I had been rather stupidly thinking of just two polling threads, one for the current race and one for races not yet run... but starting out with a thread for each extant race seems simpler given there then is no need to handle the mechanics of shifting the polling of races from the omnibus slow thread to the current race fast thread. Having got my minidom parser working nicely, I'm inclined to stick with it for now while I get other parts of the problem licked into shape. However, I do take your point that it's probably overkill for this simple kind of structured, mostly numerical data and will try to find time to experiment with the elementtree approach later. No harm at all in shaving the odd second off document parse times. From bj_666 at gmx.net Tue Apr 22 14:06:10 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 22 Apr 2008 18:06:10 GMT Subject: Problem using copy.copy with my own class References: Message-ID: <676noiF2n7ttmU1@mid.uni-berlin.de> On Tue, 22 Apr 2008 11:13:43 -0600, Jeffrey Barish wrote: > By the way, I have simplified somewhat the code in the explanation. Please simplify the code to a minimal example that still has the problem and *show it to us*. It's hard to spot errors in code that nobody except you knows. From lbonafide at yahoo.com Tue Apr 1 16:16:55 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Tue, 1 Apr 2008 13:16:55 -0700 (PDT) Subject: Is this a good time to start learning python? References: <47f1140e$0$735$a729d347@news.telepac.pt> <88fa881e-e59b-4682-801c-90ef08a1480a@a22g2000hsc.googlegroups.com> <1565ced8-afd7-4c32-a6ee-26f9b95d60bc@d45g2000hsc.googlegroups.com> Message-ID: On Apr 1, 2:42?pm, "Eduardo O. Padoan" wrote: > On Tue, Apr 1, 2008 at 4:20 PM, ? wrote: > > ?You misunderstand. ?C++ has a lot of "warts" to maintain backwards > > ?compatibility with C. ?The standards committee could eliminate these > > ?warts to make the language "cleaner", but it would break a lot of > > ?systems. > > It would not "break" anything that not move from C to C++, this is my point. You missed the point completely. C++ has a new version coming out soon, and as part of it, the less attractive parts of the language (like C compatibility) are NOT being removed, as that would break a lot of existing apps. > People not willing to take the migration path (porting to 2.6, using > the -3 flag, refactoring and re-running the tests untill the warning > are gone, using the 2to3 tool...) will not upgrade. No one will force > you to do it. 2.6 will not desappear from the python.org site anytime > soon. Will 2.6 be supported with patches and fixes going forward? From fetchinson at googlemail.com Wed Apr 16 22:19:02 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Wed, 16 Apr 2008 19:19:02 -0700 Subject: I just killed GIL!!! In-Reply-To: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: > Hello Guys... > > I just had one moment of exceptional clarity, during which realized > how I could get the GIL out of my way... It's so simple, I cannot help > wondering why nobody has thought of it before. Duh! Now I am going to > sit and and marvel at my creation for a while, and then go to bed > (it's past 2:30 a.m.) Tomorrow I will contemplate whether to sell this > little secret for big bucks, give it away for free, or just keep it to > myself... :-) > > Now you are probably thinking I reinvented the gunpowder, and are > running multiple processes. Not so. I am not running parallel > processes, like parallel python or the processing module in cheese > shop. I am running multiple THREADS. In fact, I am just using > threading.Thread. The source code is pure Python, so there is no C > magic, and I only used the stuff that's already there in the standard > library. So, I just made CPython do what everyone claim to be > impossible. One single process of CPython is using all the cpu power > of my dual-core laptop. If I were you I would keep it a secret until a Hollywood producer offers big bucks for the film rights. From sjmachin at lexicon.net Thu Apr 3 18:22:34 2008 From: sjmachin at lexicon.net (John Machin) Date: Thu, 3 Apr 2008 15:22:34 -0700 (PDT) Subject: expanding a variable to a dict References: Message-ID: <5a582bad-676d-4c95-b7d5-4e6ca4f676f3@b5g2000pri.googlegroups.com> On Apr 4, 8:56 am, idle wrote: > I've got a variable in a loop that I'm trying to expand/translate/ > readdress as an existing dict so as to add some keys into it.. > > eg; I have a set of existing dicts: dictFoo, dictBar, dictFrotz (names > changed to protect the innocent) > > now I'd like to check them all for the existence of certain default > keys; ie, if the dicts don't contain the keys, add them in with > default values. > > so, I've got: > > for a in ['dictFoo','dictBar','dictFrotz']: > if hasattr(a,'srcdir') == False: > a['srcdir']='/usr/src' > > the error I get (which I expect) is 'str' object doesn't support item > assignment. > > what incantation do I cast on 'a' to make the interpreter parse it as > 'dictFoo' on the first iteration, 'dictBar' on the second, and so > forth? > > and/or less importantly, what is such a transformation called, to help > me target my searching? > It's called "deleting extraneous apostrophes from source code". Happy googling! From jr9445 at ATT.COM Wed Apr 9 16:59:55 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Wed, 9 Apr 2008 15:59:55 -0500 Subject: basic python question about for loop In-Reply-To: References: Message-ID: > -----Original Message----- > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > list-bounces+jr9445=att.com at python.org] On Behalf Of jmDesktop > Sent: Wednesday, April 09, 2008 4:51 PM > To: python-list at python.org > Subject: basic python question about for loop > > >From the Python.org tutorial: > > >>> for n in range(2, 10): > ... for x in range(2, n): > ... if n % x == 0: > ... print n, 'equals', x, '*', n/x > ... break > ... else: > ... # loop fell through without finding a factor > ... print n, 'is a prime number' > ... > 2 is a prime number > 3 is a prime number > 4 equals 2 * 2 > 5 is a prime number > 6 equals 2 * 3 > 7 is a prime number > 8 equals 2 * 4 > 9 equals 3 * 3 > > > > first time 2 mod 2, 2/2, no remainder == 0, what am I doing wrong? > Why did it fall through? > a) 2 is prime, so nothing is wrong. b) Range isn't doing what you think it's doing: >>> print range(2,2) [] >>> print range(2,3) [2] >>> print range(2,4) [2, 3] >>> print range(2,5) [2, 3, 4] >>> print range(1,1) [] >>> print range(1,2) [1] >>> print range(1,3) [1, 2] >>> ***** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA622 From medin0065 at gmail.com Sun Apr 20 10:44:05 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:44:05 -0700 (PDT) Subject: band patch Message-ID: band patch http://cracks.00bp.com F R E E C R A C K S From robert.kern at gmail.com Wed Apr 16 19:18:55 2008 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 16 Apr 2008 18:18:55 -0500 Subject: Creating arithmetic sequences In-Reply-To: <54221025-2f61-40ad-beef-82cc74234d87@e39g2000hsf.googlegroups.com> References: <54221025-2f61-40ad-beef-82cc74234d87@e39g2000hsf.googlegroups.com> Message-ID: mmm wrote: > I wrote the code below to create simple arithmetic sequences that are > iter-able > I.e., this would basically combine the NUMPY arange(start,end,step) > to range(start,end), with step not necessarily an integer. > > The code below is in its simplest form and I want to generalize the > sequence types (multiplicative, cumulative, gauss ...), but first I > need the simple SEQA( ) function to be more robust. The problem is > the three test code functions produces different results based on > step. I understand why steps such as 0.1 have rounding and machine > math issues, and before I try to solve this I thought it was worth > asking if this problem has been solved (so I do not re-invent the > wheel). Using numpy.arange() with floats is known to be problematic, and it is discouraged. Almost all of the use cases are better served with numpy.linspace() which accepts a start, end, and the number of points rather than a step. -- 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 From musiccomposition at gmail.com Wed Apr 9 22:36:42 2008 From: musiccomposition at gmail.com (Benjamin) Date: Wed, 9 Apr 2008 19:36:42 -0700 (PDT) Subject: Module Conflicts References: <1592fad3-996b-4f62-ac12-42aff8272c21@8g2000hsu.googlegroups.com> Message-ID: <845e315c-0159-4390-954a-dc93fd1b27a1@x41g2000hsb.googlegroups.com> On Apr 9, 5:33 pm, Jose wrote: > I have a module named math.py in a package with some class > definitions. I am trying to import the standard python math module > inside of math.py but It seems to be importing itself. Is there any > way around this problem without renaming my math.py file? Not without some unpythonic magic. It's really not good style to name a module the same as a stdlib one. It'll also confuse people reading your code. From ptmcg at austin.rr.com Wed Apr 2 18:08:12 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Wed, 2 Apr 2008 15:08:12 -0700 (PDT) Subject: Understanding bmp image files References: <2537c458-b4d5-480d-8407-168a2b59a27e@u10g2000prn.googlegroups.com> Message-ID: On Apr 2, 2:22?pm, "Terry Reedy" wrote: > "pranav" wrote in message > > news:2537c458-b4d5-480d-8407-168a2b59a27e at u10g2000prn.googlegroups.com... > | Hello, > | I want to read a BMP file, do some processing and then write it in a > | new file. The problem is in the third step. For reading the file, i > | have converted the file into decimal numbers, representing the pixel > | values. Then i perform calculations on those decimal numbers. Now i am > | unable to convert those into the format as required by the "bmp" file. > | Any one, who is into image reading/manipulation, please help. > > I would look into PIL, PyGame, and Numeric/Numpy. My mistake, for some reason I thought the OP wanted to read a BMP file directly, and the code I cited shows the guts of writing out a BMP file so he might get an idea about the file's structure - to address the OP's actual question, I would second the recommendation to use PIL to read, manipulate, and write back out the pixel values. -- Paul From mnordhoff at mattnordhoff.com Mon Apr 7 03:04:04 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Mon, 07 Apr 2008 07:04:04 +0000 Subject: Help replacing os.system call with subprocess call In-Reply-To: <47F9B1D1.4090701@eastlink.ca> References: <47F9B1D1.4090701@eastlink.ca> Message-ID: <47F9C764.9070401@mattnordhoff.com> David Pratt wrote: > Hi. I am trying to replace a system call with a subprocess call. I have > tried subprocess.Popen and subprocess.call with but have not been > successful. The command line would be: > > svnadmin dump /my/repository > svndump.db > > This is what I am using currently: > > os.system('svnadmin dump %s > %s' % (svn_dir, > os.path.join(backup_dir, 'svndump.db'))) > > Many thanks. Try this: import os.path import subprocess p = subprocess.Popen( ['svnadmin', 'dump', svndir], stdout=subprocess.PIPE, ) fh = open(os.path.join(backup_dir, 'svndump.db'), 'wb') while True: chunk = p.stdout.read(2**20) # 1 MB if not chunk: break fh.write(chunk) fh.close() It reads svnadmin's stdout in 1 MB chunks, in case it's large enough that reading the whole thing into RAM at once would be a bad idea. No error handling. For one, you might want to add a try...finally to ensure that fh will get closed. (Or if you have Python 2.5, use a with statement! :-) ) Also, Popen will raise an OSError if svnadmin can't be found or something. And this isn't even considering svnadmin erroring out... svnadmin's stderr will go to your stderr. I didn't test it, but I'm pretty sure it will work. (I spotted a syntax error while writing that though.) I don't have much experience with Popen's stdio objects, so it's possible you'd need to do something like call p.wait() to wait for it to exit before being able to read its stdout. It could be slower than the os.system version, since now Python is doing all of the I/O, instead of your shell, but I doubt that'll be a big problem. (Also, insert suggestion about using a good VCS. ;-) ) -- From hniksic at xemacs.org Wed Apr 30 21:11:53 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Thu, 01 May 2008 03:11:53 +0200 Subject: relative import broken? References: <9c6ba5f9-d65b-4265-baba-fc5d7936781b@d1g2000hsg.googlegroups.com> Message-ID: <87prs6x1ye.fsf@mulj.homelinux.net> Sam writes: > I also have a problem with relative import; I can't for the life of me > figure out how to use the damn thing. I think the main problem is with > getting Python to recognize the existence of a package. I have > > S/ > p.py > B/ > b.py > W/ > pyw/ > u.py > ws.py > > and I'd like to get u.py to import all the other 3 programs. I put > empty __init__.py files in all of the above directories (is this > necessary?), and even manually added the pathway (r'C:\Myname\S') to > sys.path, but when I execute > > from S import p > > in u.py Python gives "ImportError: No module named S". A silly question: is the directory that contains "S" in PYTHONPATH or in sys.path? > The docs for relative import make this sound much easier than it is. It's supposed to be just as easy as it sounds. For example: $ mkdir S $ touch S/p.py $ touch S/__init__.py $ python Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from S import p >>> p From mensanator at aol.com Thu Apr 17 14:56:53 2008 From: mensanator at aol.com (Mensanator) Date: Thu, 17 Apr 2008 11:56:53 -0700 (PDT) Subject: sampling without replacement References: <6017ea8d-6ee8-44ea-bdad-bf06299a9cd5@a23g2000hsc.googlegroups.com> <7xwsmxudw2.fsf@ruckus.brouhaha.com> Message-ID: <15843892-2f7f-477c-837d-a4c7917ae31f@m3g2000hsc.googlegroups.com> On Apr 17, 2:41?am, Paul Rubin wrote: > braver writes: > > Using an array is natural here as it represents "without replacement" > > -- we take an element by removing it from the array. ?But in Python > > it's very slow... ?What approaches are there to implement a shrinking > > array with random deletions with ?the magnitude of millions of > > elements? > > The obvious way is use random.sample(), is there some reason you > don't do that? > > Alternatively, when you select an element a[k] from the middle of the > array, instead of deleting that element and moving the rest down (del > a[k]), do something like: > > ? ?k = random.randint(0,len(a)-1) > ? ?selection = a[k] > ? ?a[k] = a[-1] > ? ?a.pop() > > That deletes the last element (avoiding moving them around) after > storing it in the newly freed slot. ?Of course it messes up the order > of the array, which won't matter for selecting random elements, but > might matter for some other reason in your program. What about an initial random shuffle on the array and then always pop the last element? Or for that matter, why even pop it, why not just take succesively larger negative indexes as the "last" element? From frikker at gmail.com Wed Apr 30 14:19:32 2008 From: frikker at gmail.com (blaine) Date: Wed, 30 Apr 2008 11:19:32 -0700 (PDT) Subject: Simple TK Question - refreshing the canvas when not in focus References: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> <4818349e$0$2959$ba620e4c@news.skynet.be> <182ace66-bdf6-409c-85ee-fd764de8e1c6@z72g2000hsb.googlegroups.com> Message-ID: <8fbf2b85-1b6a-4f6c-a84e-934609fd0e4e@c58g2000hsc.googlegroups.com> On Apr 30, 10:41 am, Peter Otten <__pete... at web.de> wrote: > blaine wrote: > > Still doesn't work. I'm looking into using wx instead... > > > This is the full code - does it work for anyone else? Just do a echo > > 'line 0 0 10 10' > dev.file > > Haven't tried it, but I think that the problem is that you are updating the > UI from the "readthread". A good example to model your app after is here: > > http://effbot.org/zone/tkinter-threads.htm > > Peter Update: Not only is that a good model, its exactly what I'm trying to do. Thanks again! From gherron at islandtraining.com Wed Apr 2 17:00:26 2008 From: gherron at islandtraining.com (Gary Herron) Date: Wed, 02 Apr 2008 14:00:26 -0700 Subject: Recursive function won't compile In-Reply-To: References: Message-ID: <47F3F3EA.9050608@islandtraining.com> bc1891 at googlemail.com wrote: > #include > #include > > def RecursiveFact(n): > if(n>1): > return n*RecursiveFact(n-1) > else: > return 1 > > fact = RecursiveFact(31) > print fact > > fact = "End of program" > print fact > > > ......but yet it still gives the right answer. How is this possible? > Why not? What did you expect? Hint: The first two lines are comments to Python -- so are ignored. The last two lines just print a string -- no problem there. The recursive calculation is standard -- the extra set of parenthesis in the if don't cause any problem. So again please: Why are you surprised? Gary Herron From MartinRinehart at gmail.com Tue Apr 8 10:21:22 2008 From: MartinRinehart at gmail.com (MartinRinehart at gmail.com) Date: Tue, 8 Apr 2008 07:21:22 -0700 (PDT) Subject: import statement convention Message-ID: <4078bcf4-e68f-45d4-93ce-335ec7a33c5a@v32g2000prd.googlegroups.com> By convention, I've read, your module begins with its import statements. Is this always sensible? I put imports that are needed for testing in the test code at the end of the module. If only a bit of the module has a visual interface, why pollute the global namespace with 'from Tkinter import *'? Wouldn't that be better done in a separate class or function? Can we do a better job with a thoughtful rewrite of this convention? From deets at nospam.web.de Sun Apr 6 15:58:48 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Sun, 06 Apr 2008 21:58:48 +0200 Subject: traceback.print_exc() supposed to stop exception propagation. In-Reply-To: <69-dnW_JftMHvGTanZ2dneKdnZydnZ2d@bt.com> References: <69-dnW_JftMHvGTanZ2dneKdnZydnZ2d@bt.com> Message-ID: <65sobvF2g2vr6U1@mid.uni-berlin.de> Sami schrieb: > Hello, > > In the Python book that I am using to learn the language it says that > the traceback.print_exc() can be used to stop exception propagation and > make the program keep running. > > Here is a simple piece of code that I typed in to test this fact: > --------------------------------------------------------------------------- > import sys > > def Myexcepthook(etype, value, tb): > print "in Myexcepthook\n" > import traceback > lines=traceback.format_exception(etype, value, tb) > print "\n".join(lines) > traceback.print_exc() > > > sys.excepthook = Myexcepthook > > x = 1/0 > > x = 78 > > print x > -------------------------------------------------------------------------- > The Output: > -------------------------------------------------------------------------- > in Myexcepthook > > Traceback (most recent call last): > > File > "E:\Home\Programming\Python\TryProjects\ExceptHandling1\Except2.py", lin > 15, in > x = 1/0 > > ZeroDivisionError: integer division or modulo by zero > > None > -------------------------------------------------------------------------- > > I never see the value 78. > > What am I doing wrong? Trusting a wrong source. Or misinterpreting it. Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. imWelcome to rlcompleter2 0.96 for nice experiences hit multiple times >>> import traceback >>> help(traceback.print_exc) Help on function print_exc in module traceback: print_exc(limit=None, file=None) Shorthand for 'print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback, limit, file)'. (In fact, it uses sys.exc_info() to retrieve the same information in a thread-safe way.) >>> Nothing in there says that this would prevent the exception from being propagated. Diez From grante at visi.com Sat Apr 26 11:21:13 2008 From: grante at visi.com (Grant Edwards) Date: Sat, 26 Apr 2008 10:21:13 -0500 Subject: Pyserial - send and receive characters through linux serial port References: Message-ID: On 2008-04-25, terry wrote: > I am trying to send a character to '/dev/ttyS0' and expect the > same character and upon receipt I want to send another > character. I tired with Pyserial but in vain. Pyserial works. I've been using it almost daily for many years. Either your program is broken, your serial port is broken, or the device connected to the serial port is broken. > Test Set up: > > 1. Send '%' to serial port and make sure it reached the serial port. > 2. Once confirmed, send another character. > > I tried with write and read methods in Pyserial but no luck. > > Can you help? Ah yes, the problem is in line 89 of your program. We've no way to help if you don't provide details. If you really want help, write as small a program as possible that exhibits the problem. I'd like to emphasize _small_. The larger the program the less likely people are to look at it, and the less likely they are to find the problem if they do look at it. Much of the time the exercise of writing a small demo program will lead you to the answer. If not, then post it, along with the output from the program that shows the problem. Then we can tell you what you did wrong. -- Grant Edwards grante Yow! I'm also against at BODY-SURFING!! visi.com From mensanator at aol.com Wed Apr 23 00:30:47 2008 From: mensanator at aol.com (Mensanator) Date: Tue, 22 Apr 2008 21:30:47 -0700 (PDT) Subject: IDLE gripe and question References: Message-ID: <95f218ba-4925-491a-bf9c-047ac201e0c7@2g2000hsn.googlegroups.com> On Apr 22, 7:42?pm, Dick Moores wrote: > I have IDLE 1.2.1, on Win XP, Python 2.5.1. > > The first time I use File | Open to open a script, the Open dialogue > box always opens at E:\Python25\Lib\idlelib. Most of the scripts I > want to access are in E:\PythonWork. There doesn't seem to be a way > to change the default folder to E:\PythonWork, but is there? First, find the shortcut that lauches IDLE. On my Vista system it's in C:\Program Data\Microsoft\Windows\Start Menu\Programs\Python 2.5 XP will be different, I think there're start menu directories under each user and a default one. Anyway, once you have the shortcut (mine was named IDLE (Python GUI)), right-click and select Properties. There's a property attribute labeled Start In. Set that to the directory where your scripts are. The menu Open will now default to that directory. Mine is C:\Python25\user, a directory I created after installing Python. > > Thanks, > > Dick Moores > > ? ? ? ? ? ? ================================ > UliPad <>:http://code.google.com/p/ulipad/ From tdimson at gmail.com Thu Apr 10 09:59:09 2008 From: tdimson at gmail.com (Thomas Dimson) Date: Thu, 10 Apr 2008 06:59:09 -0700 (PDT) Subject: subprocess.Popen() output to logging.StreamHandler() References: Message-ID: <4a1e850d-064f-49b8-87c7-140f10fc88c3@z38g2000hsc.googlegroups.com> On Apr 10, 8:11?am, "sven _" wrote: > Version: Python 2.5.1 (r251:54863, Mar ?7 2008, 04:10:12) > > My goal is to have stdout and stderr written to a logging handler. > This code does not work: > > # START > import logging, subprocess > ch = logging.StreamHandler() > ch.setLevel(logging.DEBUG) > subprocess.call(['ls', '-la'], 0, None, None, ch, ch) > # END > > Traceback (most recent call last): > ? File "log.py", line 5, in > ? ?subprocess.call(['ls', '-la'], 0, None, None, ch, ch) > ? File "/usr/lib/python2.5/subprocess.py", line 443, in call > ? ?return Popen(*popenargs, **kwargs).wait() > ? File "/usr/lib/python2.5/subprocess.py", line 586, in __init__ > ? ?errread, errwrite) = self._get_handles(stdin, stdout, stderr) > ? File "/usr/lib/python2.5/subprocess.py", line 941, in _get_handles > ? ?c2pwrite = stdout.fileno() > AttributeError: StreamHandler instance has no attribute 'fileno' > > This is because subprocess.Popen() expects file descriptors to write > to, and logging.StreamHandler() does not supply it. The StreamHandler > could supply its own stdout file descriptor, but then Popen() would > write directly to that file, bypassing all the logging fluff. > > A possible solution would be to make a named pipe (os.mkfifo()), have > Popen() write to that, and then have some horrendous hack run select() > or similar on the fifo to read from it and finally pass it to > StreamHandler. > > Are there better solutions? > > sven What is wrong with doing something like: import logging, subprocess ch = logging.StreamHandler() ch.setLevel(logging.DEBUG) s = subprocess.Popen( ['ls','-la'], stdout=subprocess.PIPE ) while 1: ch.info( s.stdout.readline() ) if s.poll() == None: break Perhaps not the most efficient or clean solution, but that is how I usually do it (note: I didn't test the above code). -Thomas Dimson From wizzardx at gmail.com Tue Apr 15 16:55:15 2008 From: wizzardx at gmail.com (David) Date: Tue, 15 Apr 2008 22:55:15 +0200 Subject: Getting subprocess.call() output into a string? In-Reply-To: References: Message-ID: <18c1e6480804151355n10e61ec2ye59ee1a0cd6fdefc@mail.gmail.com> On Tue, Apr 15, 2008 at 10:36 PM, Tobiah wrote: > I am not sure how to capture the output of a command > using subprocess without creating a temp file. I was > trying this: > > import StringIO > import subprocess > > file = StringIO.StringIO() > > subprocess.call("ls", stdout = file) > > Traceback (most recent call last): > File "", line 6, in ? > File "/usr/local/lib/python2.4/subprocess.py", line 413, in call > return Popen(*args, **kwargs).wait() > File "/usr/local/lib/python2.4/subprocess.py", line 534, in __init__ > (p2cread, p2cwrite, > File "/usr/local/lib/python2.4/subprocess.py", line 840, in _get_handles > c2pwrite = stdout.fileno() > AttributeError: StringIO instance has no attribute 'fileno' > > So how do I get the output into a string? > > I thought that the idea of StringIO was that it could be > used where a file was expected. > For basic file-like read and write. But it won't provide a file handle since there is no 'real' file. Also, from 2.3.9 File Objects: "File-like objects which do not have a real file descriptor should not provide this method!" You should use the PIPE subprocess argument to capture output. From the tutorial: 6.8.3.1 Replacing /bin/sh shell backquote output=`mycmd myarg` ==> output = Popen(["mycmd", "myarg"], stdout=PIPE).communicate()[0] From ZeeGeek at gmail.com Wed Apr 9 22:12:00 2008 From: ZeeGeek at gmail.com (ZeeGeek) Date: Wed, 9 Apr 2008 19:12:00 -0700 (PDT) Subject: email header decoding fails Message-ID: It seems that the decode_header function in email.Header fails when the string is in the following form, '=?gb2312?Q?=D0=C7=C8=FC?=(revised)' That's when a non-encoded string follows the encoded string without any whitespace. In this case, decode_header function treats the whole string as non-encoded. Is there a work around for this problem? Thanks. From jr9445 at ATT.COM Tue Apr 1 11:14:40 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Tue, 1 Apr 2008 10:14:40 -0500 Subject: Is this a good time to start learning python? In-Reply-To: References: <47f1140e$0$735$a729d347@news.telepac.pt> Message-ID: > -----Original Message----- > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > list-bounces+jr9445=att.com at python.org] On Behalf Of Ant > Sent: Monday, March 31, 2008 5:58 PM > To: python-list at python.org > Subject: Re: Is this a good time to start learning python? > > On Mar 31, 5:40 pm, Rui Maciel wrote: > > BTW. I have to disagree with Andrew's comment: "With Perl, > once you get the core syntax down, you don't need to master Perl. > Instead you just look up the module/feature you want to use and just > use > it.". This may be true for knocking up Perl scripts, but for reading > *other peoples* code in any language you need to have a good mastery > of the core language. In Perl this is a quagmire of strange syntax, > special cases, multiple ways to do the same thing and esoterica/magic, > whereas Python's design to make whitespace significant and its "One > (obvious) way to do things" philosophy makes reading other peoples > code much easier. (Of course other peoples code always sucks, but > hey ;-) Eh... reading other people's Python code can be pretty hit or miss too. Between undeclared variables (did you mean to reuse that variable name?) and dynamic typing, Python can be really tough to follow. Add in side effects, over-use of lambdas, and the really hit or miss quality of Python's documentation, and Python can be just as difficult to follow as Perl. The things that make code readable are good comments, good design (Python emphasizes OO which helps,) and well-structured code (i.e. don't combine 3-4 operations in a single line.) This holds true for any language, so I wouldn't go out of my to ding Perl. IME. > its "One (obvious) way to do things" philosophy Given some of the solutions people have proposed to code questions in the past, I'm going to pretend you didn't say that. ;-) From luismgz at gmail.com Thu Apr 3 11:28:15 2008 From: luismgz at gmail.com (=?ISO-8859-1?Q?Luis_M=2E_Gonz=E1lez?=) Date: Thu, 3 Apr 2008 08:28:15 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> <89bca327-6a3f-4128-be72-75d4a50b9bf0@13g2000hsb.googlegroups.com> <47f4e456$0$20141$426a74cc@news.free.fr> Message-ID: <90b1bd9e-bf55-43c6-a5b9-d97cacb94b8a@z38g2000hsc.googlegroups.com> Yes, webpy's db api can be used in stand-alone scripts if you want. See below: import web db = web.database(dbn='mysql', db='northwind', user='root') x = db.select('employees') ... Another good thing is that, since queries return Storage objects (similar to dictionaries), they are much more flexible. Suppose that you get the results of a form sent via a POST method, and you want to insert this data into your database. You would simple write: i = web.input() db.insert('orders', **i) So everything related to CRUD operations are is easy to do, without having to mess with objects. I think this sticks strictly to the KISS principle, keeping it simple, with less overhead, less layers of abstraction and therefore, less bugs and complications. And it matchs perfectly webpy's philosofy for creating web apps. Luis On 3 abr, 11:06, Bruno Desthuilliers wrote: > Seems nice too in another way. Is that part independant of the rest of > the framework ? If so, I'll have to give it a try at least for admin > scripts. From usenet at janc.be Fri Apr 25 17:18:30 2008 From: usenet at janc.be (Jan Claeys) Date: Fri, 25 Apr 2008 21:18:30 GMT Subject: pop langs website ranking References: <41fbaf27-a80b-402b-b406-c048a65a8643@b64g2000hsa.googlegroups.com> Message-ID: Op Wed, 23 Apr 2008 04:07:31 +0000, schreef Roedy Green: > The weakness of this approach is it is unusual group of people who will > voluntarily submit to having their usage spied on. These are not a > typical group or a large group. Hello, planet Earth calling? I guess around 90% of internet users don't care, mostly because they don't know this is happening (how many people do you think read EULAs?). Alexa's & Google's & other (often less legal) profiling tools come with lots of pseudo-freeware applications these days... -- JanC From victorsubervi at gmail.com Wed Apr 9 14:29:21 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 9 Apr 2008 14:29:21 -0400 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> <47FCF421.6000807@holdenweb.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> Message-ID: <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> On Wed, Apr 9, 2008 at 1:49 PM, Steve Holden wrote: > Victor Subervi wrote: > > On Wed, Apr 9, 2008 at 12:51 PM, Steve Holden > > wrote: > I imagine the following code should do so, given your earlier writings: > > #! /usr/bin/python > > import MySQLdb > > print "Content-type: image/jpeg\r\n" > host = 'host' > db = 'bre' > user = 'user' > passwd = 'pass' > connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > cursor = connection.cursor() > cursor.execute('select img from photo where id="7";') > content = cursor.fetchall()[0][0] > f = open("somefile.jpg", "w") > f.write(content) > f.close() > > Then see if you can deal with "somefile.jpg" like any other JPEG. If you > can't then your blobs are somehow being mangled. If you can, we'll take > it from there. Yes, I can. Shows up in browser when surfed to, and it was pulled from the database. No mangling. I am signing off, back tomorrow morning. TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From tinnews at isbd.co.uk Sun Apr 6 12:04:57 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 06 Apr 2008 16:04:57 GMT Subject: Presumably an import is no faster or slower than opening a file? References: <47f8d30f$0$761$bed64819@news.gradwell.net> <546467f9-807c-475b-a2ae-9e8faae03825@u3g2000hsc.googlegroups.com> Message-ID: <47f8f4a9$0$758$bed64819@news.gradwell.net> bruno.desthuilliers at gmail.com wrote: > On 6 avr, 15:41, tinn... at isbd.co.uk wrote: > > I'm trying to minimise the overheads of a small Python utility, I'm > > not really too fussed about how fast it is but I would like to > > minimise its loading effect on the system as it could be called lots > > of times (and, no, I don't think there's an easy way of keeping it > > running and using the same copy repeatedly). > > > > It needs a configuration file of some sort which I want to keep > > separate from the code, is there thus anything to choose between a > > configuration file that I read after:- > > > > f = open("configFile", 'r') > > > > ... and importing a configuration written as python dictionaries or > > whatever:- > > > > import myConfig > > In both cases, you'll have to open a file. In the first case, you'll > have to parse it each time the script is executed. In the second case, > the first import will take care of compiling the python source to byte- > code and save it in a myConfig.pyc file. As long as the myConfig.py > does not change, subsequent import will directly use the .pyc, so > you'll save on the parsing/compiling time. FWIW, you can even > "manually" compile the myConfig.py file, after each modification, and > only keep the myConfig.pyc in your python path, so you'll never get > the small overhead of the "search .py / search .pyc / compare > modification time / compile / save" cycle. > > While we're at it, if you worry about the "overhead" of loading the > conf file, you'd better make sure that either you force the script > compilation and keep the .py out of the path, or at least keep the > script.py file as lightweight as possible (ie : "import somelib; > somelib.main()", where all the real code is in somelib.py), since by > default, only imported modules get their bytecode saved to .pyc file. > > Now I may be wrong but I seriously doubt it'll make a huge difference > anyway, and if so, you'd really preferer to have a long running > process to avoid the real overhead of launching a Python interpreter. > Thanks for the comments, mostly about what I was thinking too but I just wanted to check that I'm not missing anything really obvious. -- Chris Green From martin at v.loewis.de Fri Apr 4 15:25:58 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Fri, 04 Apr 2008 21:25:58 +0200 Subject: Examples using msilib to build windows installers In-Reply-To: References: Message-ID: <47F680C6.4070802@v.loewis.de> > It would appear to me that the msilib library included with standard > python 2.5 would allow be to do this. I found the source code that > builds the python distrubition installer packages, but I was wondering > if there were other examples that I can learn from. Actually, the installer itself is built with Tools/msi/msilib, which predates the msilib shipped in 2.5; the former one uses ActiveX (automation), whereas the latter one links directly to a native library (and hence doesn't require PythonCOM). That library was also used (with modifications) to build Enthought Python. In any case, the single known application of the shipped msilib is the bdist_msi command of distutils. If you want to start using MSI, you absolutely have to know about the database tables and their purpose. Use orca.exe to inspect MSI files, and try to make sense out of that. Read MSDN documentation. msilib greatly helps in writing installers quickly, but the "learning curve" is perhaps even steeper than "mere" MSI, as you need to understand both the MSI principles themselves, and then how msilib wraps it in a more compact form. Of course, if you can manage to package your application as a distutils package, you can just try running bdist_msi, and see what you get. Regards, Martin From contact at dann.ro Wed Apr 16 22:15:52 2008 From: contact at dann.ro (Daniel NL) Date: Thu, 17 Apr 2008 05:15:52 +0300 Subject: index of list of lists Message-ID: <1208398552l.41837l.0l@ns.bitcarrier.eu> yes, there's a thread with the same title, but I believe mine is more appropriate title. so, as much as I search on the web, read manuals, tutorials, mail-lists (including this one) I cannot figure it out how to search a string in a list of lists. like this one: someList = [['somestring', 1, 2], ['oneother', 2, 4]] I want to search "somestring" in someList which is in practice a list of aprox. 200 lists. (hey, I'm a newbie python programmer, don't judge me). is the list.index the wrong approach? should I use numpy, numarray, something else? can anyone, be kind and help me with this? From detlev at die-offenbachs.de Sat Apr 5 10:15:29 2008 From: detlev at die-offenbachs.de (Detlev Offenbach) Date: Sat, 05 Apr 2008 16:15:29 +0200 Subject: ANN: eric4 4.1.2 released Message-ID: Hi, eric4 4.1.2 has been released today. This release fixes a few bugs reported since the last release. As usual it is available via http://www.die-offenbachs.de/eric/index.html. What is eric? ------------- eric is a Python IDE written using PyQt4 and QScintilla2. It comes with batteries included. Please see a.m. link for details. Regards, Detlev -- Detlev Offenbach detlev at die-offenbachs.de From sturlamolden at yahoo.no Fri Apr 11 19:31:17 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 11 Apr 2008 16:31:17 -0700 (PDT) Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: <101680ba-a116-414b-8fff-c5b5bd2f4b65@p39g2000prm.googlegroups.com> On Apr 11, 5:01 am, "Gabriel Genellina" wrote: > Another annoying thing with the Qt license is that you have to choose it > at the very start of the project. You cannot develop something using the > open source license and later decide to switch to the commercial licence > and buy it. Trolltech is afraid companies will buy one licence when the task is done, as oppsed to one license per developer. In a commercial setting, the Qt license is not expensive. It is painful for hobbyists wanting to commercialize their products. From aaron.watters at gmail.com Wed Apr 16 09:59:32 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 16 Apr 2008 06:59:32 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: On Apr 16, 9:16 am, Marco Mariani wrote: > > Do you mean Ruby's track in providing backward compatibility is better > than Python's? > > Googling for that a bit, I would reckon otherwise. I can't comment on that. Ruby is a lot younger -- I'd expect it to still be stabilizing a bit. What I'm saying is that, for example, there are a lot of cool tools out there for using Python to manipulate postscript and latex and such. Most of those tools require no maintenance, and the authors are not paying any attention to them, and they aren't interested in messing with them anymore. My guess is that there are few such tools for Ruby. However, I wouldn't be too surprised if porting them to Ruby and testing them properly is not much more difficult than porting them to py3k and testing them properly... Especially since the basic treatment of strings is totally different in py3k, it seems. Maybe there is a secret desire in the Python community to remain a fringe minority underdog forever? -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=reap+dead+child From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 2 07:25:29 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 02 Apr 2008 13:25:29 +0200 Subject: object-relational mappers In-Reply-To: <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> Message-ID: <47f36d23$0$28775$426a74cc@news.free.fr> hdante a ?crit : > On Apr 1, 5:40 pm, Aaron Watters wrote: >> I've been poking around the world of object-relational >> mappers and it inspired me to coin a corellary to the >> the famous quote on regular expressions: >> >> "You have objects and a database: that's 2 problems. >> So: get an object-relational mapper: >> now you have 2**3 problems." >> >> That is to say I feel that they all make me learn >> so much about the internals and features of the >> O-R mapper itself that I would be better off rolling >> my own queries on an as-needed basis without >> wasting so many brain cells. >> >> comments? > > Try Rails' ActiveRecord. Your problems should reduce to (lg lg > 2)^(1/12). Correct me if I'm wrong, but IIRC ActiveRecord requires you use numeric auto_increment fields for primary key. As far as I'm concerned, this is a definitive no-no. > Seriously, you'll forget there's a relational database below. Why on earth are you using a RDBMS if you don't want it ? I for one *do* care about using a *relational* database, and *don't* want to hide it away. What I don't want is to have to build my queries as raw strings. And that's where SQLAlchemy shines : it's not primarily an "ORM", it's an higher-level Python/SQL integration tool that let you build your queries as Python objects (and also, eventually, build an ORM if you want to...). From george.sakkis at gmail.com Fri Apr 18 14:00:06 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 18 Apr 2008 11:00:06 -0700 (PDT) Subject: Pickle problem References: Message-ID: <933a2b55-7a99-4061-9dc0-4de657448f1c@s50g2000hsb.googlegroups.com> On Apr 18, 11:55?am, "Mario Ceresa" wrote: > Hello everybody: > I'd like to use the pickle module to save the state of an object so to > be able to restore it later. The problem is that it holds a list of > other objects, say numbers, and if I modify the list and restore the > object, the list itself is not reverted to the saved one, but stays > with one element deleted. > An example session is the following: > > Data is ?A [1, 2, 3, 4] > saving a with pickle > Deleting an object: del a[3] > Now data is A [1, 2, 3] > Oops! That was an error: can you please recover to the last saved data? > A [1, 2, 3] ? ? #### I'd like to have here A[1,2,3,4]!!!!!! > > Is it the intended behavior for pickle? if so, are there any way to > save the state of my object? > > Code follows > ----------------------- > class A(object): > ? ? ? ? objects = [] > ----------------------- > then I run ?the code: > --------------------------------------- > import pickle > from core import A > > a = A() > > for i in [1,2,3,4]: > ? ? ? ? a.objects.append(i) > > savedData = pickle.dumps(a) > print "Saved data is ",a > print "Deleting an object" > del a.objects[3] > print a > print "Oops! This was an error: can you please recover the last saved data?" > > print pickle.loads(savedData) > -------------------------------------------- > > Thank you for any help! > > Mario The problem is that the way you define 'objects', it is an attribute of the A *class*, not the instance you create. Change the A class to: class A(object): def __init__(self): self.objects = [] and rerun it; it should now work as you intended. HTH, George From sam at mas.pl Wed Apr 2 08:04:28 2008 From: sam at mas.pl (sam) Date: Wed, 02 Apr 2008 14:04:28 +0200 Subject: Prototype OO In-Reply-To: <47f1f90b$0$27429$426a74cc@news.free.fr> References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> Message-ID: Bruno Desthuilliers napisa?(a): > Sam, seriously, why don't start with *learning* about Python's object > model ? Seriously ? Not that it's "perfect", not that you have to like > it Ok -- thank you for your time and your strong opinions about current solutions. From hv at tbz-pariv.de Wed Apr 2 10:06:37 2008 From: hv at tbz-pariv.de (Thomas Guettler) Date: Wed, 02 Apr 2008 16:06:37 +0200 Subject: wsdl (soap) without code generation Message-ID: <65hi7dF2ade57U1@mid.individual.net> Hi, I looked for a solution to talk to a web service which offers its signature with a wsdl file. I googled for 'wsdl python' and found ZSI. This project uses code generation. That's something I don't like. The book 'dive into python' uses SOAPpy. This looks better since it does not generate source code. But the last release and first release is from 2001. ZSI seems to have integrated SOAPpy. I am new to WSDL and SOAP. Do I need a WSDL parsing routine at all? I guess my wsdl definition won't change during the next years. So I could read the wsdl with my eyes and make a fitting soap call... Any thoughts? -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de From has.temp3 at virgin.net Wed Apr 2 08:58:09 2008 From: has.temp3 at virgin.net (has) Date: Wed, 2 Apr 2008 05:58:09 -0700 (PDT) Subject: IM status with appscript References: <65h2l0F2fba8bU1@mid.uni-berlin.de> Message-ID: On 2 Apr, 10:40, "Diez B. Roggisch" wrote: > Oolon Colluphid wrote: > > hi, > > i need access to application attributes of IM (like Adium, aMsn, MS > > Messenger) on Mac platform via appscript module. > > once instantiated the application object with: app=app("Adium") > > i don't know how recover information like status, and i have find no > > references. > > Use the appscript examples + the OS X script-editor to see what scriptable > properties exactly the IM-application offers. You can also use ASDictionary (http://appscript.sourceforge.net/ tools.html) to export application dictionaries in appscript format. As an added bonus, installing ASDictionary allows you to use appscript's built-in help method to explore application dictionaries and object models from the interactive python interpreter. HTH has -- Control AppleScriptable applications from Python, Ruby and ObjC: http://appscript.sourceforge.net From panzerlurch at gmail.com Wed Apr 2 09:53:28 2008 From: panzerlurch at gmail.com (Panzerlurch) Date: Wed, 2 Apr 2008 06:53:28 -0700 (PDT) Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: <453e3ac2-5ed5-4f1f-a33b-55851677f02a@y21g2000hsf.googlegroups.com> Why don't use the normal Python shell syntax as used by doctest? >>> abs(-5.5) 5.5 That would be much more readable. From kyosohma at gmail.com Fri Apr 18 16:02:14 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 18 Apr 2008 13:02:14 -0700 (PDT) Subject: Easiest way to get started with WebApps? References: <3c43f29c-3e51-48ab-be02-47402ccd1bfd@b64g2000hsa.googlegroups.com> Message-ID: <19b6a1fe-c307-4f6e-abd0-c426967674a5@m36g2000hse.googlegroups.com> On Apr 18, 2:06 pm, skanem... at yahoo.se wrote: > which is the easiest module to use to just get started with webapps > quicklya nd starting getting things up and running, not advanced stuff > just basic. cherrypy is also good for quick and dirty webapps without a lot of bling. Mike From tdimson at gmail.com Wed Apr 2 08:30:06 2008 From: tdimson at gmail.com (Thomas Dimson) Date: Wed, 2 Apr 2008 05:30:06 -0700 (PDT) Subject: Self-referencing decorator function parameters Message-ID: <88b2c61e-8cf1-4ac0-a5d4-c968d009b544@c65g2000hsa.googlegroups.com> Hello, Originally I posted this as a bug but it was shot down pretty quickly. I am still mildly curious about this as I'm missing a bit of understanding of Python here. Why is it that the following code snippet: def decorator( call ): def inner(func): def application( *args, **kwargs ): call(*args,**kwargs) func(*args,**kwargs) return application return inner class DecorateMe: @decorator( call=DecorateMe.callMe ) def youBet( self ): pass def callMe( self ): print "Hello!" DecorateMe().youBet() Will not compile, giving: Traceback (most recent call last): File "badpython.py", line 10, in class DecorateMe: File "badpython.py", line 11, in DecorateMe @decorator( call=DecorateMe.callMe ) NameError: name 'DecorateMe' is not defined Where if you change the "call=DecorateMe.callMe" to "call=lambda x: DecorateMe.callMe(x)" everything goes along its merry way. Nesting the call in a lambda seems to allow it to recognize the class definition. Any ideas as to what is going on here (other than ugly code)? Thank you, Thomas Dimson From mccredie at gmail.com Tue Apr 29 21:22:09 2008 From: mccredie at gmail.com (Matimus) Date: Tue, 29 Apr 2008 18:22:09 -0700 (PDT) Subject: how to convert a multiline string to an anonymous function? References: <67pmdnF2p5fhgU1@mid.uni-berlin.de> Message-ID: <87c29666-f64f-4f3c-97e1-a3d1dccdc49b@s50g2000hsb.googlegroups.com> On Apr 29, 3:39 pm, "Diez B. Roggisch" wrote: > Danny Shevitz schrieb: > > > > > Simple question here: > > > I have a multiline string representing the body of a function. I have control > > over the string, so I can use either of the following: > > > str = ''' > > print state > > return True > > ''' > > > str = ''' > > def f(state): > > print state > > return True > > ''' > > > and I want to convert this into the function: > > > def f(state): > > print state > > return True > > > but return an anonmyous version of it, a la 'return f' so I can assign it > > independently. The body is multiline so lambda doesn't work. > > > I sort of need something like: > > > def function_constructor(str): > > f = eval(str) # What should this be > > return f > > > functions = {} > > for node in nodes: > > function[node] = function_constructor(node.text) > > > I'm getting stuck because 'def' doesn't seem to work in an eval function, > > and exec actually modifies the namespace, so I run into collisions if I use > > the function more than once. > > > I know I'm missing something stupid here, but I'm stuck just the same... > > The "stupid" thing is that you can pass your own dictionary as globals > to exec. Then you can get a reference to the function under the name "f" > in the globals, and store that under whatever name you need. > > Beware of recursion though! If that happens, you need to create unique > names for your functions, but as you know these beforehand I don't see > any problem with that - just enumerate them, like f1, f2, f3.... > > Diez In other words: >>> d = {} >>> >>> # don't use str, that is the name of the built-in string type >>> text = ''' ... def f(state): ... print state ... return True ... ''' >>> >>> exec text in d >>> >>> f('state') Traceback (most recent call last): File "", line 1, in NameError: name 'f' is not defined >>> >>> f = d['f'] >>> f('state') state True Matt From maxm at mxm.dk Wed Apr 9 08:05:08 2008 From: maxm at mxm.dk (Max M) Date: Wed, 09 Apr 2008 14:05:08 +0200 Subject: expanding a variable to a dict In-Reply-To: <76f75b0d-2355-4c18-a6e4-931c307cb5c6@u10g2000prn.googlegroups.com> References: <76f75b0d-2355-4c18-a6e4-931c307cb5c6@u10g2000prn.googlegroups.com> Message-ID: John Machin skrev: > On Apr 4, 9:44 am, Max M wrote: > Ummm ... excessive apostrophes plus bonus gross syntax error, dood. > Did you try running any of these snippets??? No I just wanted to quickly show different ways to do it. The dicts in the original question wasn't dicts either. So I asumed I could answer in the same vein. >> http://www.mxm.dk/ >> IT's Mad Science > > Sure is. Oh yes. That will motivate further answers. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science From skanemupp at yahoo.se Sat Apr 5 01:02:45 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 4 Apr 2008 22:02:45 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <7113d012-01bb-4426-bb40-9e2811cdb102@x41g2000hsb.googlegroups.com> Message-ID: <3cf4bbc8-b828-45c5-b9a8-766ce600af43@y21g2000hsf.googlegroups.com> On 5 Apr, 05:57, skanem... at yahoo.se wrote: > On 5 Apr, 05:26, 7stud wrote: > > > > > On Apr 4, 7:06 pm, skanem... at yahoo.se wrote: > > > > 1st question: > > > > when i run this program 1 will be printed into the interpreter when i > > > run it BUT without me clicking the actual button. > > > when i then click the button "1", nothing happens. > > > > obv i dont want any output when i dont push the button but i want it > > > when i do. > > > > what am i doing wrong here? > > > > 2nd question: > > > > i want all the buttons to have the same size. i thought i should use > > > row/columnspan but i dont get that to work. > > > how should i do? > > > > [code] > > > #! /usr/bin/env python > > > from Tkinter import * > > > import tkMessageBox > > > > class GUIFramework(Frame): > > > """This is the GUI""" > > > > def __init__(self,master=None): > > > """Initialize yourself""" > > > > """Initialise the base class""" > > > Frame.__init__(self,master) > > > > """Set the Window Title""" > > > self.master.title("Calculator") > > > > """Display the main window" > > > with a little bit of padding""" > > > self.grid(padx=10,pady=10) > > > self.CreateWidgets() > > > > def CreateWidgets(self): > > > > self.enText = Entry(self) > > > self.enText.grid(row=0, column=0, columnspan=8, padx=5, > > > pady=5) > > > > self.enText = Entry(self) > > > self.enText.grid(row=1, column=0, columnspan=8, padx=5, > > > pady=5) > > > > self.btnDisplay = Button(self, text="1", > > > command=self.Display(1)) > > > self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="2", default=ACTIVE) > > > self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="3", default=ACTIVE) > > > self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="+", default=ACTIVE) > > > self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="4", default=ACTIVE) > > > self.btnDisplay.grid(row=4, column=0, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="5", default=ACTIVE) > > > self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="6", default=ACTIVE) > > > self.btnDisplay.grid(row=4, column=2, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="-", default=ACTIVE) > > > self.btnDisplay.grid(row=4, column=3, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="7", default=ACTIVE) > > > self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="8", default=ACTIVE) > > > self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="9", default=ACTIVE) > > > self.btnDisplay.grid(row=5, column=2, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="*", default=ACTIVE) > > > self.btnDisplay.grid(row=5, column=3, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="0", default=ACTIVE) > > > self.btnDisplay.grid(row=6, column=0, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="C", default=ACTIVE) > > > self.btnDisplay.grid(row=6, column=1, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="r", default=ACTIVE) > > > self.btnDisplay.grid(row=6, column=2, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="/", default=ACTIVE) > > > self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) > > > > def Display(self, xbtn): > > > if xbtn==1: > > > print 1 > > > > if __name__ == "__main__": > > > guiFrame = GUIFramework() > > > guiFrame.mainloop() > > > > [/code] > > > If you have this function: > > > def f(): > > print 1 > > return 10 > > > and you write: > > > result = f() > > > The '()' is the function execution operator; it tells python to > > execute the function. In this case, the function executes, and then > > the return value of the function is assigned to the variable result. > > If a function does not have a return statement, then the function > > returns None by default. > > > The same thing is happening in this portion of your code: > > > command = self.Display(1) > > > That code tells python to execute the Display function and assign the > > function's return value to the variable command. As a result Display > > executes and 1 is displayed. Then since Dispay does not have a return > > statement, None is returned, and None is assigned to command. > > Obviously, that is not what you want to do. > > > What you want to do is assign a "function reference" to command so > > that python can execute the function sometime later when you click on > > the button. A function reference is just the function name without > > the '()' after it. So you would write: > > > command = self.Display > > > But writing it like that doesn't allow *you* to pass any arguments to > > Display(). In addition, *tkinter* does not pass any arguments to > > Display when tkinter calls Display in response to a button click. As > > a result, there is no way to pass an argument to Display. > > > However, there is another way to cause a function to execute when an > > event, like a button click, occurs on a widget: you use the widget's > > bind() function: > > > my_button.bind('', someFunc) > > > The first argument tells tkinter what event to respond to. > > '' is a left click. Check the docs for the different > > strings that represent the different events that you can respond to. > > The second argument is a function reference, which once again does not > > allow you to pass any arguments to the function. However, when you > > use bind() to attach a function to a widget, tkinter calls the > > function and passes it one argument: the "event object". The event > > object contains various pieces of information, and one piece of > > information it contains is the widget upon which the event occurred, > > e.g. the button that was clicked. To get the button, you write: > > > Display(self, event_obj): > > button = event_obj.widget > > > Once you have the button, you can get the text on the button: > > > Display(self, event_obj): > > button = event_obj.widget > > text = button.cget("text") > > > if text=="1": > > print 1 > > > Another thing you should be aware of: self is like a class wide > > bulletin board. If you are writing code inside a class method, and > > there is data that you want code inside another class method to be > > able to see, then post the data on the class wide bulletin board, i.e. > > attach it to self. But in your code, you are doing this: > > > self.btnDisplay = Button(self, text="7", default=ACTIVE) > > self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="8", default=ACTIVE) > > self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > > As a result, your code continually overwrites self.btnDisplay. That > > means you aren't preserving the data assigned to self.btnDisplay. > > Therefore, the data does not need to be posted on the class wide > > bulletin board for other class methods to see. So just write: > > > btnDisplay = Button(self, text="7", default=ACTIVE) > > btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > > btnDisplay = Button(self, text="8", default=ACTIVE) > > btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > > As for the button sizing problem, your buttons are all the same size > > and line up perfectly on mac os x 10.4.7. > > wow thank you so much, awesome answer i will get right to fixing this > now. > > in regards to the buttonsizes i use windows VISTA and they have > different sizes. one thing i dont rally get, i ahve to add my_button.bind() somewhere? i changed the stuff u said though and i get this error(the program executes though and i can press the buttons): Exception in Tkinter callback Traceback (most recent call last): File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ return self.func(*args) TypeError: Display() takes exactly 2 arguments (1 given) current version: #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self,master=None): """Initialize yourself""" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): enText = Entry(self) enText.grid(row=0, column=0, columnspan=8, padx=5, pady=5) enText = Entry(self) enText.grid(row=1, column=0, columnspan=8, padx=5, pady=5) btnDisplay = Button(self, text="1", command=self.Display) btnDisplay.grid(row=3, column=0, padx=5, pady=5) btnDisplay = Button(self, text="2", default=ACTIVE) btnDisplay.grid(row=3, column=1, padx=5, pady=5) btnDisplay = Button(self, text="3", default=ACTIVE) btnDisplay.grid(row=3, column=2, padx=5, pady=5) btnDisplay = Button(self, text="+", default=ACTIVE) btnDisplay.grid(row=3, column=3, padx=5, pady=5) btnDisplay = Button(self, text="4", default=ACTIVE) btnDisplay.grid(row=4, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="5", default=ACTIVE) self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) btnDisplay = Button(self, text="6", default=ACTIVE) btnDisplay.grid(row=4, column=2, padx=5, pady=5) btnDisplay = Button(self, text="-", default=ACTIVE) btnDisplay.grid(row=4, column=3, padx=5, pady=5) btnDisplay = Button(self, text="7", default=ACTIVE) btnDisplay.grid(row=5, column=0, padx=5, pady=5) btnDisplay = Button(self, text="8", default=ACTIVE) btnDisplay.grid(row=5, column=1, padx=5, pady=5) btnDisplay = Button(self, text="9", default=ACTIVE) btnDisplay.grid(row=5, column=2, padx=5, pady=5) btnDisplay = Button(self, text="*", default=ACTIVE) btnDisplay.grid(row=5, column=3, padx=5, pady=5) btnDisplay = Button(self, text="0", default=ACTIVE) btnDisplay.grid(row=6, column=0, padx=5, pady=5) btnDisplay = Button(self, text="C", default=ACTIVE) btnDisplay.grid(row=6, column=1, padx=5, pady=5) btnDisplay = Button(self, text="r", default=ACTIVE) btnDisplay.grid(row=6, column=2, padx=5, pady=5) btnDisplay = Button(self, text="/", default=ACTIVE) btnDisplay.grid(row=6, column=3, padx=5, pady=5) #self.btnDisplay(expand=0/1) ## def Display(self, xbtn): ## if xbtn==1: ## print 1 def Display(self, event_obj): button = event_obj.widget text = button.cget("text") if text=="1": print 1 if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() From rustompmody at gmail.com Sat Apr 26 23:35:29 2008 From: rustompmody at gmail.com (rustom) Date: Sat, 26 Apr 2008 20:35:29 -0700 (PDT) Subject: diffing and uniqing directories References: Message-ID: On Apr 27, 12:31?am, castiro... at gmail.com wrote: > On Apr 26, 1:14?pm, "Rustom Mody" wrote: > > > > > Over years Ive collected tgz's of my directories. I would like to diff > > and uniq them > > > Now I guess it would be quite simple to write a script that does a > > walk or find through a pair of directory trees, makes a SHA1 of each > > file and then sorts out the files whose SHA1s are the same/different. > > What is more difficult for me to do is to write a visual/gui tool to > > help me do this. > > > I would guess that someone in the python world must have already done > > it [The alternative is to use some of the tools that come with version > > control systems like git. But if I knew more about that option I would > > not be stuck with tgzs in the first place ;-)] > > > So if there is such software known please let me know. > > > PS Also with the spam flood that has hit the python list I dont know > > if this mail is being read at all or Ive fallen off the list! > > I don't want to give you advice; there is profit in diversity, so > telling you what I use could negatively unify the diverse group. > > In another language I know, and I pause to defer to the old and wise > on that, Visual Basic (known to make money), certain counterparts like > Visual Basic for Applications allow construction of scripts in the > owner's other suites. ?That is, you can write Basic snippets in Excel, > Access, and so on. ?That's one benefit that private ownership leaves, > but not everyone is sold on my country's currency/localcy. ?Perhaps > it's in the future of version control systems. ?Of course, > standardization of sufficiency to succeed comes from currency too: > success isn't success if it isn't current, per se. > > Do you have any interest in contributing your mind or hands to > developing a solid gui framework? ?Join a team. If this is an answer to my question I dont understand it! From steveb428 at gmail.com Mon Apr 7 19:20:27 2008 From: steveb428 at gmail.com (steve) Date: Mon, 7 Apr 2008 16:20:27 -0700 (PDT) Subject: pyAmazon Message-ID: <137ba7ca-2be3-4c0a-ba85-187d8e172150@i36g2000prf.googlegroups.com> Anyone familiar with pyAmazon ( the latest for AWS 4.0 ), who knows why the ItemSearch echo's the XML that is retrieved ? My statement is products = ecs.ItemSearch("Duma Key", SearchIndex='Books') And the "products" list is populated okay, however before my script ends ( executing script on DOS command line ), I get all of the XML data scrolling on the screen. Thanks From banibrata.dutta at gmail.com Tue Apr 22 01:33:18 2008 From: banibrata.dutta at gmail.com (Banibrata Dutta) Date: Tue, 22 Apr 2008 11:03:18 +0530 Subject: Does Python 2.5 include or not include SQLite engine? In-Reply-To: <1208819146.23409.1249124463@webmail.messagingengine.com> References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> <1208819146.23409.1249124463@webmail.messagingengine.com> Message-ID: <3de8e1f70804212233o4e62c52s2a4d140deaa44355@mail.gmail.com> Doesn't this depend on the source / distro ? My Python is from the ActivePython distro, while I am not sure (since I've just about started playing with it), I haven't seen SQLite included ... possible that I missed it. On 4/22/08, python at bdurham.com wrote: > > While reading feedback to my post "Does Python 2.5.2's embedded SQLite > support full text searching?" I noticed that there appears to be some > confusion regarding whether Python 2.5 includes the SQLite engine. > > My Windows 2.5.2 binary download includes SQLite. > > But other posters claim otherwise, re: Linux releases of Python 2.5? > > I thought one of the major features of Python 2.5 was its embedded > SQLite engine. > > Thoughts? > > Malcolm > -- > http://mail.python.org/mailman/listinfo/python-list > -- regards, Banibrata http://www.linkedin.com/in/bdutta -------------- next part -------------- An HTML attachment was scrubbed... URL: From upton at virginia.edu Wed Apr 2 17:02:45 2008 From: upton at virginia.edu (Dan Upton) Date: Wed, 2 Apr 2008 17:02:45 -0400 Subject: Python in High School In-Reply-To: References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: <5504f9ac0804021402j256f66cdyed2b778f7f6ba376@mail.gmail.com> On Wed, Apr 2, 2008 at 1:10 PM, Jan Claeys wrote: > Op Tue, 01 Apr 2008 10:27:18 -0700, schreef sprad: > > > > I'm a high school computer teacher, and I'm starting a series of > > programming courses next year (disguised as "game development" classes > > to capture more interest). The first year will be a gentle introduction > > to programming, leading to two more years of advanced topics. > > [...] > > > So -- would Python be a good fit for these classes? > > There are at least 3 books about game programming in python: > > > > This was the book I first bought when I started thinking about learning Python, and it includes some pygame projects. It uses all game programming-based concepts for teaching, although many of them are text-based and it only introduces pygame toward the end. http://www.amazon.com/Python-Programming-Absolute-Beginner-Michael/dp/1592000738/ref=sr_1_6?ie=UTF8&s=books&qid=1207169620&sr=1-6 I might add, you might do a disservice to students by starting them with flashy graphics-based programming--IIRC, that was actually a part of the complaints a couple months ago about why "Java schools" were failing to turn out competent computer scientists: they focus too heavily on something that looks good and end up missing the underlying concepts. Not that you'd ever do such a thing, I'm sure ;) But my intro CS professor in undergrad had us do two of the projects from our textbook that involved GUI programming, then quickly dropped it, partly because we were spending so much time of the implementation of the projects 1) figuring out how to set up the GUI in Swing, and 2) not really understanding why we're typing all this stuff to create buttons and text fields. On Wed, Apr 2, 2008 at 4:01 PM, John Henry wrote: > > And you are going to teach them Java? Oh, please don't. Let the > colleges torture them. :=) > Side rant: I think Java's just fine, as long as it's taught properly. I'd done a little bit of C and C++ programming when I was in high school, trying to teach myself from a book, but I never really got pointers or objects. Going back to it after Java, it made so much more sense, even though people will tell you "Java doesn't make you learn about pointers." From jim.vickroy at noaa.gov Wed Apr 2 13:23:39 2008 From: jim.vickroy at noaa.gov (j vickroy) Date: Wed, 02 Apr 2008 11:23:39 -0600 Subject: py.test and test coverage analysis ? Message-ID: Hello all, I am using py.test (http://codespeak.net/py/dist/test.html) to perform unit testing. I would like to include test coverage analysis using coverage.py (http://nedbatchelder.com/code/modules/coverage.html), but I do not know how to simultaneously apply the two tools in a single run. Could someone offer a suggestion on how to combine coverage analysis with py.test. Thanks, -- jv From hobgoodoreneyhb at gmail.com Tue Apr 22 11:39:38 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:39:38 -0700 (PDT) Subject: dell network assistant keygen Message-ID: <450907f7-93b5-45eb-9edd-c0269fa0dc71@d1g2000hsg.googlegroups.com> dell network assistant keygen http://cracks.12w.net F R E E C R A C K S From sjdevnull at yahoo.com Wed Apr 23 01:08:50 2008 From: sjdevnull at yahoo.com (sjdevnull at yahoo.com) Date: Tue, 22 Apr 2008 22:08:50 -0700 (PDT) Subject: about python References: Message-ID: On Apr 22, 10:50 pm, mran... at varshyl.com wrote: > How can python execute in browser? > > Mukul Depends on the browser and which compilers/postprocessors you're willing to use. The Grail browser supports python natively, there are python plugins for some other browsers, and there are C# plugins for other browsers which can be wrangled to work with IronPython. For common, widespread browser support, Jython can run on anything supporting Java and py2js can run on anything supporting Javascript. From ewertman at gmail.com Wed Apr 23 21:00:49 2008 From: ewertman at gmail.com (Eric Wertman) Date: Wed, 23 Apr 2008 21:00:49 -0400 Subject: Ideas for parsing this text? Message-ID: <92da89760804231800g50f9a2pbe45a7ff8104e7b0@mail.gmail.com> I have a set of files with this kind of content (it's dumped from WebSphere): [propertySet "[[resourceProperties "[[[description "This is a required property. This is an actual database name, and its not the locally catalogued database name. The Universal JDBC Driver does not rely on information catalogued in the DB2 database directory."] [name databaseName] [required true] [type java.lang.String] [value DB2Foo]] [[description "The JDBC connectivity-type of a data source. If you want to use a type 4 driver, set the value to 4. If you want to use a type 2 driver, set the value to 2. Use of driverType 2 is not supported on WAS z/OS."] [name driverType] [required true] [type java.lang.Integer] [value 4]] [[description "The TCP/IP address or host name for the DRDA server."] [name serverName] [required false] [type java.lang.String] [value ServerFoo]] [[description "The TCP/IP port number where the DRDA server resides."] [name portNumber] [required false] [type java.lang.Integer] [value 007]] [[description "The description of this datasource."] [name description] [required false] [type java.lang.String] [value []]] [[description "The DB2 trace level for logging to the logWriter or trace file. Possible trace levels are: TRACE_NONE = 0,TRACE_CONNECTION_CALLS = 1,TRACE_STATEMENT_CALLS = 2,TRACE_RESULT_SET_CALLS = 4,TRACE_DRIVER_CONFIGURATION = 16,TRACE_CONNECTS = 32,TRACE_DRDA_FLOWS = 64,TRACE_RESULT_SET_META_DATA = 128,TRACE_PARAMETER_META_DATA = 256,TRACE_DIAGNOSTICS = 512,TRACE_SQLJ = 1024,TRACE_ALL = -1, ."] [name traceLevel] [required false] [type java.lang.Integer] [value []]] [[description "The trace file to store the trace output. If you specify the trace file, the DB2 Jcc trace will be logged in this trace file. If this property is not specified and the WAS.database trace group is enabled, then both WebSphere trace and DB2 trace will be logged into the WebSphere trace file."] I'm trying to figure out the best way to feed it all into dictionaries, without having to know exactly what the contents of the file are. There are a number of things going on, The nesting is preserved in [] pairs, and in some cases in between double quotes. There are also cases where double quotes are only there to preserve spaces in a string though. I managed to get what I needed in the short term by just stripping the nesting all together, and flattening out the key/value pairs, but I had to do some things that were specific to the file contents to make it work. Any ideas? I was considering making a list of string combinations, like so: junk = ['[[','"[',']]'] and just using re.sub to covert them into a single character that I could start to do split() actions on. There must be something else I can do.. those brackets can't be a coincidence. The output came from a jython script. Thanks! From nash.coccer at gmail.com Mon Apr 14 07:41:40 2008 From: nash.coccer at gmail.com (nash.coccer at gmail.com) Date: Mon, 14 Apr 2008 04:41:40 -0700 (PDT) Subject: REAL BRUTAL RAPE VIDEOS HERE.SEE IT AND ENJOY. ALL THE GIRLS WERE Message-ID: <8c495ecd-6508-4106-972e-78b8f95f0720@u12g2000prd.googlegroups.com> REAL BRUTAL RAPE VIDEOS HERE.SEE IT AND ENJOY. ALL THE GIRLS WERE SCREAM .BUT IT IS SWEAT.THE LINK IS BELOW http://onlinemillionare.blogspot.com/ ENJOY HOW SWEET IT IS From martin at v.loewis.de Thu Apr 24 13:06:57 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Thu, 24 Apr 2008 19:06:57 +0200 Subject: Installer In-Reply-To: References: Message-ID: <4810be31$0$26785$9b622d9e@news.freenet.de> > I've created a python program that relies on pysqlite, wxpython, and > matplotlib. Is there any way of creating an installer that will > install all these modules, python 2.5 and my program? Sure. Look at Tools/msi in the Python code, and adjust it to your needs. Please don't use the official product code, but create your own one. Regards, Martin From bj_666 at gmx.net Thu Apr 3 07:25:03 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 3 Apr 2008 11:25:03 GMT Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> Message-ID: <65jt4fF2ges01U1@mid.uni-berlin.de> On Thu, 03 Apr 2008 10:07:38 +0200, sam wrote: > bruno.desthuilliers at gmail.com napisa?(a): > > >> So, while I often use Python's lambdas, the imposed limitations is ok >> to me since I wouldn't use it for anything more complex. > >> Also - as a side note - while the syntax is a bit different, the >> resulting object is an ordinary function. > > And people start asking why this is that or the other way in Python, and you > can't give a good answer to newcomers, especially if Python was chosen as a > first learning language. You can't tell "because Python's parsing mechanism > don't allow statements in expressions...". But one can tell "because the way Python's syntax is based on indentation, no one has come up with a syntax for anonymous functions without the limitations of the current ``lambda``, that doesn't need 'curly braces' and is still as readable as Python is now." Ciao, Marc 'BlackJack' Rintsch From matthieu.brucher at gmail.com Thu Apr 10 07:47:07 2008 From: matthieu.brucher at gmail.com (Matthieu Brucher) Date: Thu, 10 Apr 2008 13:47:07 +0200 Subject: =?ISO-8859-1?Q?Re:_[Python-Fr]_R=E9flexions_sur_l'auto?= =?ISO-8859-1?Q?compl=E9tion_dans_les_=E9diteurs_Python...?= In-Reply-To: <47FDFDA9.1050204@climpact.com> References: <47FDFDA9.1050204@climpact.com> Message-ID: Le 10/04/08, Jul a ?crit : > > Bonjour ? tous, > > L'un des probl?mes des ?diteurs de code Python est qu'il ne proposent pas > d'autocompl?tion "intelligente", c'est ? dire en coh?rence avec l'objet en > cours de frappe. La plupart des ?diteurs se basent sur des fichiers texte > (fichiers API) contenant la liste des m?thodes et attributs susceptibles de > compl?ter la frappe; mais comme ces suggestions ne sont pas cr??es > dynamiquement en fonction de la variable, elles sont souvent ? cot? de la > plaque. > > En Java, comme toutes les variables sont typ?es, on connait les m?thodes > et attribtus d?s la d?claration de la variable et il est possible de > proposer exactement les bonnes entr?es pour l'autocompl?tion. Mais en > Python, cela parait plus compliqu? a cause du manque de typage... > > Pensez-vous qu'un module d'autocompl?tion un peu plus "intelligent" que > des entr?es venant d'un fichier statique soit possible ? > Existe-t-il des modules d'analyse de code permettant de proposer les > bonnes entr?es ? > As-tu test? IPython ? L'autocompl?tion de ce shell est normalement bas?e sur l'introspection du code. Matthieu -- French PhD student Website : http://matthieu-brucher.developpez.com/ Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92 LinkedIn : http://www.linkedin.com/in/matthieubrucher -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexelder at gmail.com Fri Apr 25 13:37:23 2008 From: alexelder at gmail.com (alexelder at gmail.com) Date: Fri, 25 Apr 2008 10:37:23 -0700 (PDT) Subject: Calling Python code from inside php References: <679e9oF2mti63U1@mid.uni-berlin.de> <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> Message-ID: <8106a79a-d729-4d4f-bf2f-0c17041ad09b@e53g2000hsa.googlegroups.com> On Apr 25, 4:02 pm, sturlamolden wrote: > On Apr 23, 9:13 pm, alexel... at gmail.com wrote: > > > A simple yet dangerous and rather rubbish solution (possibly more of a > > hack than a real implementation) could be achieved by using a > > technique described above: > > > > echo exec('python foo.py'); > > This will spawn a Python interpreter, and not be particularly > efficient. You could just as well have used CGI. Thanks for pointing that out. I thought the warning before hand could've suggested that this implementation wasn't the best. I'll be more explicit in the future. From deets at nospam.web.de Tue Apr 22 08:27:34 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 14:27:34 +0200 Subject: Does Python 2.5.2's embedded SQLite support full text searching? In-Reply-To: References: <1208794249.15992.1249049327@webmail.messagingengine.com> Message-ID: <6763uaF2norrtU1@mid.uni-berlin.de> Daniel Fetchinson schrieb: >> Does Python 2.5.2's embedded SQLite support full text searching? >> >> Any recommendations on a source where one can find out which SQLite >> features are enabled/disabled in each release of Python? I'm trying to >> figure out what's available in 2.5.2 as well as what to expect in 2.6 >> and 3.0. > > Sqlite itself is not distributed with python. Only a python db api > compliant wrapper is part of the python stdlib and as such it is > completely independent of the sqlite build. In other words, if your > sqlite build supports full text searching you can use it through the > python sqlite wrapper (that is part of the stdlib) and if it doesn't > then not. This is true for any sqlite feature though. > > So if you need an sqlite feature just go ahead and build your own > sqlite with that feature enabled and use that feature with the stock > python sqlite wrapper that comes with the stdlib. I doubt that. This would mean that Python comes with a mechanism to dynamically load different libs for the same module, opening a buttload full of error-conditions regarding library versions & changing semantics depending on system configuration. Instead, the sqlite standard lib comes with its own version of sqlite. If you want something other, you need to - install sqlite on your system, including library & headers - compile the pysqlite extension module it will be available in a different module path to prevent confusion. THe same is true for ElementTree, btw. Diez From steve at holdenweb.com Mon Apr 21 17:20:15 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 21 Apr 2008 17:20:15 -0400 Subject: 2's complement conversion. Is this right? In-Reply-To: <2008042115060816807-bob@passcalnmtedu> References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> <2008042115060816807-bob@passcalnmtedu> Message-ID: Bob Greschke wrote: > On 2008-04-21 14:50:13 -0600, Ivan Illarionov said: > >> On 22 ???, 00:10, Ivan Illarionov wrote: >>> On 20 ???, 04:10, George Sakkis w >> rote: >>> >>> >>>> On Apr 18, 9:36 pm, Ross Ridge >>>> wrote: >>>>> Ross Ridge said: >>>>>> If you have Python 2.5, here's a faster version: >>>>>> from struct import * >>>>>> unpack_i32be = Struct(">l").unpack >>>>>> def from3Bytes_ross2(s): >>>>>> return unpack_i32be(s + "\0")[0] >> 8 >>>>> Bob Greschke wrote: >>>>>> That's not even intelligible. I wanna go back to COBOL. :) >>>>> It's the same as the previous version except that it "precompiles" >>>>> the struct.unpack() format string. It works similar to the way Python >>>>> handles regular expressions. >>>> I didn't know about the Struct class; pretty neat. It's amazing that >>>> this version without Psyco is as fast Bob's version with Psyco! Adding >>>> Psyco to it though makes it *slower*, not faster. So here's how I'd >>>> write it (if I wanted or had to stay in pure Python): >>>> try: import psyco >>>> except ImportError: >>>> from struct import Struct >>>> unpack_i32be = Struct(">l").unpack >>>> def from3Bytes(s): >>>> return unpack_i32be(s + "\0")[0] >> 8 >>>> else: >>>> def from3Bytes(s): >>>> Value = (ord(s[0])<<16) + (ord(s[1])<<8) + ord(s[2]) >>>> if Value >= 0x800000: >>>> Value -= 0x1000000 >>>> return Value >>>> psyco.bind(from3Bytes) >>>> HTH, >>>> George >>> I was able to get even faster pure-python version using array module: >>> >>> a = array.array('l', ''.join(('\0' + s[i:i+3] for i in xrange(0, >>> len(s), 3)))) >>> if sys.byteorder == 'little': >>> a.byteswap() >>> >>> It actually moves bytes around on C level. >>> >>> test code: >>> import struct >>> import array >>> import sys >>> >>> unpack_i32be = struct.Struct(">l").unpack >>> s = ''.join(struct.pack('>i', 1234567)[1:]*1000) >>> >>> def from3bytes_ord(s): >>> values = [] >>> for i in xrange(0, len(s), 3): >>> Value = (ord(s[i])<<16) | (ord(s[i+1])<<8) | ord(s[i+2]) >>> if Value >= 0x800000: >>> Value -= 0x1000000 >>> values.append(Value) >>> return values >>> >>> def from3bytes_struct(s): >>> return [unpack_i32be(s[i:i+3] + "\0")[0] >> 8 for i in xrange(0, >>> len(s), 3)] >>> >>> def from3bytes_array(s): >>> a = array.array('l', ''.join(('\0' + s[i:i+3] for i in xrange(0, >>> len(s), 3)))) >>> if sys.byteorder == 'little': >>> a.byteswap() >>> return a.tolist() >>> >>> from timeit import Timer >>> >>> t1 = Timer("from3bytes_ord(s)", "from __main__ import s, >>> from3bytes_ord") >>> t2 = Timer("from3bytes_struct(s)", "from __main__ import s, >>> from3bytes_struct") >>> t3 = Timer("from3bytes_array(s)", "from __main__ import s, >>> from3bytes_array") >>> >>> print 'ord:\t', t1.timeit(1000) >>> print 'struct:\t', t2.timeit(1000) >>> print 'array:\t', t3.timeit(1000) >>> >>> Output: >>> ord: 7.08213110884 >>> struct: 3.7689164405 >>> array: 2.62995268952 >>> >>> Inspired by Guido's essayhttp://www.python.org/doc/essays/list2str/ >> And even faster: >> a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, >> len(s), 3)))) >> if sys.byteorder == 'little': >> a.byteswap() >> >> I think it's a fastest possible implementation in pure python > > Geeze! :) How did struct get so fast? I'm guessing there have been > improvements since 2.3 (which is what I've been working on). I'm going > to be able to go back to my IBM PC XT pretty soon. :) > > Thanks! > Yes, Bob Ippolito spent quite a bit of time improving it at the Need for Speed sprint shortly before the 2.4 (?) release. It shows. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From sophacles at gmail.com Wed Apr 2 11:41:10 2008 From: sophacles at gmail.com (Erich) Date: Wed, 2 Apr 2008 08:41:10 -0700 (PDT) Subject: Self-referencing decorator function parameters References: <88b2c61e-8cf1-4ac0-a5d4-c968d009b544@c65g2000hsa.googlegroups.com> <232b144b-9e09-4baf-9e87-88b6a1d1fb07@b5g2000pri.googlegroups.com> <80ffac0f-baa3-46ac-8157-fa123e2bee9e@8g2000hse.googlegroups.com> Message-ID: <034a09e4-7d78-49d3-a92d-d4134b8dcf28@13g2000hsb.googlegroups.com> On Apr 2, 10:13 am, Thomas Dimson wrote: > > I guess my real question is: why does wrapping the call to be > "call=lambda x: DecorateMe.callMe(x)" somehow fix the issue with this > temporary namespace? It seems strange to me that defining an > additional function (through lambda) would allow me to see/add more > members to the namespace. This works because of the very same mechanism that allows decorators to work. When the decorator in your example is called, it then evaluates the inner statements, including the creation of the function inner (the def ...). Similarly, when you do the lambda above, python points call to the lambda function, but does not evaluate it until later, when the youBet method is run. By the time youBet is run, the DecorateMe class exists, so this will properly evaluate. I hope the above is clear, I haven't had my coffee yet. regards, Erich From Randy.Galbraith at gmail.com Mon Apr 21 01:01:46 2008 From: Randy.Galbraith at gmail.com (Randy Galbraith) Date: Sun, 20 Apr 2008 22:01:46 -0700 (PDT) Subject: Compiling Python 2.5.2 on AIX 5.2 References: <0b73e8e5-c301-4823-ac94-42f757456cf1@x19g2000prg.googlegroups.com> <48059DA9.5080900@v.loewis.de> Message-ID: On Apr 15, 11:33 pm, "Martin v. L?wis" wrote: > > What is Py_UNICODE_SIZE and why was it not defined? There are current > > questions I have. > > Py_UNICODE_SIZE is the number of bytes that a Py_UNICODE value should > have in the interpreter. With --enable-unicode=ucs2, it should be 2. Martin, Thanks for your reply. I feel like a dummy, when I was following Marc- Andre's instructions I incorrectly typed "--enable- unicode=ucs24" (note the "4"). Once I fixed that the Py_UNICODE_SIZE issue went away. Alas, I still am having problems compiling and getting a clean run through make test. I got this error: Python-2.5.2/Modules/bz2module.c:12:19: error: bzlib.h: No such file or directory Which I solved by copying bzlib.h I have on the system to Python-2.5.2/ Include/. The run of make test resulted in this error: test_ctypes find_library('c') -> None find_library('m') -> None make: *** [test] Segmentation fault (core dumped) An examination of the core with gdb shows this: $ gdb python core GNU gdb 6.0 Copyright 2003 Free Software Foundation, Inc. [snip] This GDB was configured as "powerpc-ibm-aix5.2.0.0"... Core was generated by `python'. Program terminated with signal 11, Segmentation fault. #0 0xdebccc5c in ffi_closure_helper_DARWIN (closure=0xdebcd050, rvalue=0x2ff20230, pgr=0x2ff20258, pfr=0x2ff201c8) at Python-2.5.2/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c: 626 626 avalue = alloca(cif->nargs * sizeof(void *)); (gdb) bt #0 0xdebccc5c in ffi_closure_helper_DARWIN (closure=0xdebcd050, rvalue=0x2ff20230, pgr=0x2ff20258, pfr=0x2ff201c8) at Python-2.5.2/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c: 626 #1 0xdebcd2bc in ffi_closure_ASM () from build/lib.aix-5.2-2.5/ _ctypes.so #2 0xdebcd458 in ffi_call_AIX () from build/lib.aix-5.2-2.5/ _ctypes.so #3 0xdebccf24 in ffi_call (cif=0xdebcd050, fn=@0x2ff20288: 0x2ff20350, rvalue=0x2ff20258, avalue=0x2ff201c8) at Python-2.5.2/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c: 421 #4 0xdebcb5e8 in _CallProc (pProc=@0x30000fc8: 0xdebcd248 , argtuple=0x20d5e9ac, flags=4097, argtypes=0x20d5eb2c, restype=0x20e7dc44, checker=0x0) at Python-2.5.2/Modules/_ctypes/callproc.c:668 [snip frames #5 to #55] #56 0x10063a70 in PyEval_EvalCode (co=0xdebcd050, globals=0x2ff20230, locals=0x2ff20258) at Python/ceval.c:494 cals=0x2ff20258) at Python/ceval.c:494 (gdb) print cif $1 = (ffi_cif *) 0x140 (gdb) print *cif $3 = {abi = 1600485481, nargs = 1946157056, arg_types = 0x0, rtype = 0x400a, bytes = 1, flags = 0} Thus it would seem use cif here resulted in a segment violation. I'll continue to research this issue and report back to the group as I know more. Perhaps solving the issue with the 'c' and 'm' libraries (whatever they might be) will make the core dump go away. However, for tonight, I'll need to stop here. Kind regards, -Randy Galbraith From andrew at acooke.org Mon Apr 14 22:36:06 2008 From: andrew at acooke.org (andrew cooke) Date: Mon, 14 Apr 2008 19:36:06 -0700 (PDT) Subject: Dynamic use of property() fails References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> Message-ID: <07e75b35-fc64-4388-b953-f75728b259f6@x41g2000hsb.googlegroups.com> [Gabriel:] > The "magic" happens when the descriptor is found in the *class*, not in > the instance. I think it's detailed in Hettinger's document. > Do you actually want "per-instance" defined properties? ah! ok. yes, you're right: i want instance values but class properties, so i'll rethink things. thanks very much! > __special__ names are reserved for Python internal usage; don't use them. > Implementation-only attributes ("private" ones) are spelled with a single > underscore. ah, yes, sorry about that. thanks again for the quick reply, andrew From ockman at gmail.com Sat Apr 12 10:43:11 2008 From: ockman at gmail.com (ockman at gmail.com) Date: Sat, 12 Apr 2008 07:43:11 -0700 (PDT) Subject: from __future__ import print References: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> Message-ID: <93176fb4-dd7d-457e-ac44-b54596bb95e1@k37g2000hsf.googlegroups.com> On Apr 10, 3:06 pm, "Andrii V. Mishkovskyi" wrote: > 2008/4/10, samsli... at gmail.com : > > > Am I the only one that thinks this would be useful? :) > > > I'd really like to be able to use python 3.0'sprintstatement in > > 2.x. Is this at least being considered as an option for 2.6? It > > seems like it would be helpful with transitioning. > > It's not only considered but have been already implemented. Enjoy. :) Awesome! I'm still stuck on 2.5 but I'm glad to know it's in 2.6. :) From mccle27252 at gmail.com Mon Apr 21 03:52:11 2008 From: mccle27252 at gmail.com (mccle27252 at gmail.com) Date: Mon, 21 Apr 2008 00:52:11 -0700 (PDT) Subject: ulead gif animator 5 crack Message-ID: ulead gif animator 5 crack http://cracks.00bp.com F R E E C R A C K S From ptmcg at austin.rr.com Mon Apr 7 20:14:21 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Mon, 7 Apr 2008 17:14:21 -0700 (PDT) Subject: Data structure recommendation? References: <663744510804071339g639bfdccl63de8be66fe52df1@mail.gmail.com> Message-ID: On Apr 7, 3:58?pm, Steve Holden wrote: > > I believe the best way to implement this would be a binary search > (bisect?) on the actual times, which would be O(log N). bisect is definitely the way to go. You should take care with floating point precision, though. One way to do this is to choose a number of digits of precision that you want, and then internally to your class, multiply the keys by 10**precision and truncate, so that you are working with ints internal to the Foo class. Here is a stab at a solution to your question, with precision to 1 decimal place. I also added __getitem__ and __setitem__, since your class has many dict- like semantics. -- Paul import bisect class Foo(object): def __init__(self): self.items = {} self.keys = [] def put(self,key,value): key = int(key * 10) if key not in self.items: bisect.insort(self.keys, key) self.items[key] = value def get(self,key): key = int(key * 10) idx = bisect.bisect_left(self.keys,key) if idx: return self.items[self.keys[idx-1]] def __setitem__(self,key,value): self.put(key,value) def __getitem__(self,key): return self.get(key) if __name__ == "__main__": foo = Foo() print foo.get(1.5) # -> None foo.put(1.3, 'a') foo.put(2.6, 'b') print foo.get(1.5) # -> 'a' print foo.get(7.8) # -> 'b' foo.put(5.0, 'c') print foo.get(7.8) # -> 'c' print foo[1.0] # -> None foo[6.3] = 'z' print foo[7.8] From darcy at druid.net Thu Apr 24 12:44:51 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Thu, 24 Apr 2008 12:44:51 -0400 Subject: MESSAGE RESPONSE In-Reply-To: <27CC3060AF71DA40A5DC85F7D5B70F3801185540@AWMAIL04.belcan.com> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> <678v5qF2me5rvU1@mid.uni-berlin.de> <5504f9ac0804230927ncfdb91buf7fa3e181f8a9237@mail.gmail.com> <27CC3060AF71DA40A5DC85F7D5B70F3801185540@AWMAIL04.belcan.com> Message-ID: <20080424124451.9070e2fb.darcy@druid.net> On Thu, 24 Apr 2008 12:28:29 -0400 "Blubaugh, David A." wrote: > Belcan has an absolute zero-tolerance policy toward material such as the material described. Hard to imagine that they would hold you responsible for something sent to you without your permission. On the other hand I can see them being concerned about the posting that you made when you resent it to the list. And really, who uses their business address for news/mailing lists. I own my own company and I won't even do that. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From steve at holdenweb.com Wed Apr 9 12:51:45 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 12:51:45 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> Message-ID: <47FCF421.6000807@holdenweb.com> Victor Subervi wrote: > On Wed, Apr 9, 2008 at 11:10 AM, Steve Holden > wrote: > > Victor Subervi wrote: > > On Wed, Apr 9, 2008 at 10:24 AM, Steve Holden > > >> wrote: > connection = MySQLdb.connect(host=host, user=user, > passwd=passwd, db=db) > cursor = connection.cursor() > cursor.execute('select img from photo where id="7";') > content = cursor.fetchall() > > > Bzzt! Nope. Cursor.fetchall() returns a list (length 1) or tuples > (length 1) here, so this should be > > content = cursor.fetchall()[0][0] > > or, perhaps better > > content = cursor.fetchone()[0] > > > I tried both of these, and they, too, gave me the same identical image > of the url, not the image I am after. > I'm having a problem believing this, but I don't think you are lying. Are you *sure* you have stored the correct omages in your database? The fact remains that cursor.fetchall() will return a list containing one tuple containing (what you believe is) your image, so there is NO way your code above can do what you want. I can therefore only assume that this is a CGI script and that your web server does something *extremely* funky when it gets a CGI output it isn't expecting. But this doesn't make a lot of sense. > > > You really don't understand how the web works, do you? > > > I am just really, really, stupid, Steve. Please forgive me for being so > stupid. But I am persistent. And I have built dozens of Web site with > images. > Stupidity and ignorance are entirely different things, and you (current) ignorance in no way implies stupidity. We all have to learn. However, if you bring up one of the pages from one of your many web sites containing an image, and get your browser to display the HTML of that page you will surely find that the image does not appear direectly in the HTML, but instead appears as a tag in the HTML. Something like: though the src attribute doesn't really need to be that complex. > > In order to include an image in a page your browser must make TWO > requests. The first is for an HTML page that will reference the > image in this way: > > > > Seeing this img tag causes the browser to make a SECOND request, > which the script I corrected above should respond to with an image. > > The bytestream is critical in the image response. Even one misplaced > byte will mess things up terribly. > > > In my stupidity, I have assumed you meant this: > > content = col_fields[0][14].tostring() > print '

' > Well, here I have no idea what the content of your database might be, but if the fifteenth column you retrieve is the web server path to the graphic, that should be right except for the spaces around it, which might give trouble. You might consider instead content = col_fields[0][14].tostring() print '

' % content to omit them. > Obviously I am wrong. Could you please give me a little more insight? > Forget HTML for now. If you direct your browser to the URL on which your server is serving the graphic then it should be displayed in the browser window. Until that happy condition pertains, we are stabbing around in the dark. > BTW, when we are finally done with this, I will write a nice > how-to (since there is not one in python, while php has some > nice ones) on how to do this, and give you and Gabrielle all > your due credit. I will post it to this list, because that is > sure to rank highly in google right away. > Victor > > That's great, though hardly the point of the exercise. I think > Google already know about Gabriel (*not* Gabrielle) and me already ... > > > Well, I just thought it might be a good way to get the information out, > since it is not out there yet. And I believe it is only proper to give > credit where credit is due. I would not be doing this to praise you. > Rather, I would be doing this because it is needed, and I would feel > wrong for not crediting those who deserve credit. Please let me know, > however, if you feel otherwise. It's not that I mind, but I do feel that this knowledge is already available, though clearly I might be wrong ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From george.sakkis at gmail.com Fri Apr 18 18:04:37 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 18 Apr 2008 15:04:37 -0700 (PDT) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> Message-ID: <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> On Apr 18, 5:26?pm, Bob Greschke wrote: > On 2008-04-18 14:37:21 -0600, Ross Ridge > said: > > > > > Bob Greschke ? wrote: > >> I'm reading 3-byte numbers from a file and they are signed (+8 to > >> -8million). ?This seems to work, but I'm not sure it's right. > > >> # Convert the 3-characters into a number. > >> Value1, Value2, Value3 = unpack(">BBB", Buffer[s:s+3]) > >> Value = (Value1*65536)+(Value2*256)+Value3 > >> if Value >= 0x800000: > >> Value -= 0x1000000 > >> print Value > > >> For example: > >> 16682720 = -94496 > > >> Should it be Value -= 0x1000001 so that I get -94497, instead? > > > Your first case is correct, "Value -= 0x1000000". ?The value 0xFFFFFFF > > should be -1 and 0xFFFFFFF - 0x1000000 == -1. > > > An alternative way of doing this: > > > ? ?Value = unpack(">l", Buffer[s:s+3] + "\0")[0] >> 8 > > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Ross Ridge > > Good to know (never was good on the math front). > > However, in playing around with your suggestion and Grant's code I've > found that the struct stuff is WAY slower than doing something like this > > ?Value = (ord(Buf[s])*65536)+(ord(Buf[s+1])*256)+ord(Buf[s+2]) > ?if Value >= 0x800000: > ? ? ?Value -= 0x1000000 > > This is almost twice as fast just sitting here grinding through a few > hundred thousand conversions (like 3sec vs. ~5secs just counting on my > fingers - on an old Sun...it's a bit slow). ? You'd better use a more precise timing method than finger counting, such as timeit. Twice as fast is probably a gross overestimation; on my box (Python 2.5, WinXP) avoiding unpack is around 10% and 40% faster from Ross's and Grant's method, respectively: python -m timeit "for i in xrange(1000):from3Bytes_bob(s)" \ -s "from bin import *; s=pack('>i',1234567)[1:]" 1000 loops, best of 3: 1.02 msec per loop python -m timeit "for i in xrange(1000):from3Bytes_grant(s)" \ -s "from bin import *; s=pack('>i',1234567)[1:]" 1000 loops, best of 3: 1.43 msec per loop python -m timeit "for i in xrange(1000):from3Bytes_ross(s)" \ -s "from bin import *; s=pack('>i',1234567)[1:]" 1000 loops, best of 3: 1.12 msec per loop ### bin.py ########################################## from struct import unpack def from3Bytes_bob(s): Value = (ord(s[0])<<16) + (ord(s[1])<<8) + ord(s[2]) if Value >= 0x800000: Value -= 0x1000000 return Value def from3Bytes_grant(s): if ord(s[0]) & 0x80: s = '\xff'+s else: s = '\x00'+s return unpack('>i',s)[0] def from3Bytes_ross(s): return unpack(">l", s + "\0")[0] >> 8 > Replacing *65536 with <<16 > and *256 with <<8 might even be a little faster, but it's too close to > call without really profiling it. > I wasn't planning on making this discovery today! :) > > Bob If you are running this on a 32-bit architecture, get Psyco [1] and add at the top of your module: import psyco; psyco.full() Using Psyco in this scenatio is up to 70% faster: python -m timeit "for i in xrange(1000):from3Bytes_bob(s)" \ -s "from bin import *; s=pack('>i',1234567)[1:]" 1000 loops, best of 3: 624 usec per loop python -m timeit "for i in xrange(1000):from3Bytes_grant(s)" \ -s "from bin import *; s=pack('>i',1234567)[1:]" 1000 loops, best of 3: 838 usec per loop python -m timeit "for i in xrange(1000):from3Bytes_ross(s)" \ -s "from bin import *; s=pack('>i',1234567)[1:]" 1000 loops, best of 3: 834 usec per loop George [1] http://psyco.sourceforge.net/ From malaclypse2 at gmail.com Tue Apr 29 16:47:10 2008 From: malaclypse2 at gmail.com (Jerry Hill) Date: Tue, 29 Apr 2008 16:47:10 -0400 Subject: Simple import question about mac osx In-Reply-To: References: Message-ID: <16651e80804291347k545a2f0do7707eec0d3eea54a@mail.gmail.com> On Tue, Apr 29, 2008 at 3:17 PM, jmDesktop wrote: > On Windows I took the text file I created on mac with vi and opened it > in PythonWin. I ran it. It compiled. I run the import and call from > the python interpreter. You're not doing what you think you're doing. I'm not sure I know the right way to explain it, though. When you run your code in pythonwin, it's just like calling 'python -i chap2.py' It runs the code in chap2.py, then gives you an interpreter window to interact with your code. In this case, that means that FooClass is visible with no import at all, because it was defined in the scope of the currently running script, as opposed to being imported. You haven't said exactly how you're doing this on your mac, but I'm guessing that you're opening a command line, starting up the python interpreter, then going from there? Can someone help me out? I'm running into a mental block on how to explain the difference between doing this: C:\Python25>python -i chap2.py >>> foo1=FooClass() Created a class instance for John Doe >>> and doing this: C:\Python25>python Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import chap2 >>> foo1=chap2.FooClass() Created a class instance for John Doe >>> -- Jerry From deets at nospam.web.de Wed Apr 16 07:56:23 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 16 Apr 2008 13:56:23 +0200 Subject: Python crashes consistently References: Message-ID: <66m7s3F2l8kitU1@mid.uni-berlin.de> Pete Crite wrote: > Hello, > > I've been trying to install Gnumeric via MacPorts recently, but I > can't get past the installation of py25-numpy. You are using the wrong python version. Don't use MacPorts for this, because it will install a local, non-framework version of python - which will do you no good if you e.g. want to use any OSX-specific stuff. Use the official 2.5 framework version. And then install Numpy yourself (which is a bit annoying I admit, as you need to install e.g. a fortran compiler, but it is pretty well documented) Diez From tnelson at onresolve.com Tue Apr 8 23:07:55 2008 From: tnelson at onresolve.com (Trent Nelson) Date: Tue, 8 Apr 2008 20:07:55 -0700 Subject: Google App Engine In-Reply-To: References: Message-ID: <87D3F9C72FBF214DB39FA4E3FE618CDC6E22BEB5D7@EXMBX04.exchhosting.com> > But people will always prefer complaining on the grounds of > insufficient information to keeping quiet on the basis of knowledge. +1 QOTW! From paul at science.uva.nl Mon Apr 21 07:30:19 2008 From: paul at science.uva.nl (Paul Melis) Date: Mon, 21 Apr 2008 13:30:19 +0200 Subject: SWIG (Python) - "no constructor defined" for concrete class In-Reply-To: References: Message-ID: Stodge wrote: > Yet another SWIG question (YASQ!). > > I'm having a problem with using an abstract base class. When > generating the Python bindings, SWIG thinks that all the concrete > classes that derive from this abstract class are abstract too and > won't create the correct constructor. > > Abstract class: > > [source lang="cpp"]class CORE_API Shape > { > public: > virtual ~Shape() > { > nshapes--; > }; > double x, y; > virtual void move(double dx, double dy); > virtual double area(void) = 0; > virtual double perimeter(void) = 0; > static int nshapes; > protected: > Shape() { > nshapes++; > } > > }; > [/source] > > Derived classes: > > [source lang="cpp"]class CORE_API Circle : public Shape > { > private: > double radius; > public: > Circle(double r): Shape(), radius(r) > { > }; > virtual double area(void); > virtual double perimeter(void); > }; > > class CORE_API Square : public Shape > { > private: > double width; > public: > Square(double r): Shape(), width(r) > { > }; > virtual double area(void); > virtual double perimeter(void); > }; > [/source] > > SWIG file: > > [source lang="cpp"]class Shape > { > virtual void move(double dx, double dy); > virtual double area(void) = 0; > virtual double perimeter(void) = 0; > }; > > class Circle: public Shape > { > Circle(double r); > virtual double area(void); > virtual double perimeter(void); > }; > > > class Square: public Shape > { > Square(double r); > virtual double area(void); > virtual double perimeter(void); > }; > [/source] > > C++ COde: > > [source lang="cpp"] Circle c(1.02); > std::cout << "(c++)\t\tCircle\t" << c.area() << std::endl; > Square s(9.20); > std::cout << "(c++)\t\tSquare\t" << s.area() << std::endl; > > [/source] > > For some reason SWIG thinks that Circle and Square are abstract. Any > ideas why? I'm rather confused by this. See section 6.6.2 of the SWIG documentation (SWIG and C++ -> Default constructors, copy constructors and implicit destructors). Your abstract base class defines its default constructor in the protected section. From the docs: "Default constructors and implicit destructors are not created if any base class defines a non-public default constructor or destructor." Paul From king.aftab at gmail.com Sat Apr 26 07:17:21 2008 From: king.aftab at gmail.com (king.aftab at gmail.com) Date: Sat, 26 Apr 2008 04:17:21 -0700 (PDT) Subject: Riva FLV Encoder 2.0 - FLV Converter Message-ID: <9fa94472-ca5e-441c-8df6-14a78580f870@u36g2000prf.googlegroups.com> This robust video converter ably packs a number of file formats into the Flash video format and is stylish to boot. Riva FLV Encoder works well with the usual suspects: AVI, WMV, MPEG, and MOV files. Riva is a great freeware application for a reliable (and inexpensive) way to convert video files to the Web. Download from here: http://freeware4.blogspot.com/2008/04/riva-flv-encoder-20-flv-converter.html From kveretennicov at gmail.com Tue Apr 1 16:23:28 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Tue, 1 Apr 2008 23:23:28 +0300 Subject: import multiple modules with same name In-Reply-To: References: Message-ID: <4660fe300804011323p44ee747bse7010031dc9a492d@mail.gmail.com> On Mon, Mar 31, 2008 at 11:52 PM, Christian Bird wrote: > Is it possible to import multiple modules with the same name from > different locations? This might work: import imp util1 = imp.load_source('util1', 'mod1/util.py') util2 = imp.load_source('util2', 'mod2/util.py') But using packages is cleaner. -- kv -------------- next part -------------- An HTML attachment was scrubbed... URL: From jcd at sdf.lonestar.org Thu Apr 17 14:55:00 2008 From: jcd at sdf.lonestar.org (J. Cliff Dyer) Date: Thu, 17 Apr 2008 14:55:00 -0400 Subject: Can't do a multiline assignment! In-Reply-To: References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <48077E83.5050404@islandtraining.com> Message-ID: <1208458500.5656.4.camel@aalcdl07.lib.unc.edu> On Thu, 2008-04-17 at 13:53 -0400, Steve Holden wrote: > Gary Herron wrote: > > s0suk3 at gmail.com wrote: > >> On Apr 17, 10:54 am, colas.fran... at gmail.com wrote: > >> > >>> On 17 avr, 17:40, s0s... at gmail.com wrote: > >>> > >>> Out of sheer curiosity, why do you need thirty (hand-specified and > >>> dutifully commented) names to the same constant object if you know > >>> there will always be only one object? > >>> > >> I'm building a web server. The many variables are names of header > >> fields. One part of the code looks like this (or at least I'd like it > >> to): > >> > >> class RequestHeadersManager: > >> > >> # General header fields > >> Cache_Control = \ > >> Connection = \ > >> Date = \ > >> Pragma = \ > >> Trailer = \ > >> Transfer_Encoding = \ > >> Upgrade = \ > >> Via = \ > >> Warning = \ > >> > >> # Request header fields > >> Accept = \ > >> Accept_Charset = \ > >> Accept_Encoding = \ > >> Accept_Language = \ > >> Authorization = \ > >> ... > >> > > > > But. *What's the point* of doing it this way. I see 14 variables > > being assigned a value, but I don't see the value, they are getting. > > Reading this bit if code provides no useful information unless I'm > > willing to scan down the file until I find the end of this mess. And in > > that scanning I have to make sure I don't miss the one single line that > > does not end in a backslash. (Your ellipsis conveniently left out the > > *one* important line needed to understand what this code is doing, but > > even if you had included it, I'd have to scan *all* lines to understand > > what a single value is being assigned. > > > > There is *no way* you can argue that code is clearer than this: > > > > # General header fields > > Cache_Control = None > > Connection = None > > Date = None > > Pragma = None > > ... > > > Thank you, you saved me from making that point. It doesn't even seem > like there's a need for each header to reference the same value (though > in this case they will, precisely because there is only one None object). > > regards > Steve Another possibility is to assign to a dict using a loop, if typing None over and over again is so onerous. options = ['cache_control', 'connection', 'date', 'pragma'] params = {} for option in options: params[option] = None And of course you could substitute your choice of appropriate __dict__ for params, if you want to access the options as free-standing objects. Cheers, Cliff From evlangelis at gmail.com Mon Apr 28 08:58:51 2008 From: evlangelis at gmail.com (Albert Leibbrandt) Date: Mon, 28 Apr 2008 15:58:51 +0300 Subject: Need help on left padding In-Reply-To: <67lrc1F2o7iv7U3@mid.uni-berlin.de> References: <67lrc1F2o7iv7U3@mid.uni-berlin.de> Message-ID: <4815CA0B.3020602@gmail.com> Marc 'BlackJack' Rintsch wrote: > On Mon, 28 Apr 2008 04:37:02 -0700, rajesh kataraki wrote: > > >> My requirement is I am using one variable ex. var = 5 which is >> integer. >> And this variable, I m using in some string. But I want this var >> to be used as 005 again integer in this string. >> > > In [22]: '%03d' % 5 > Out[22]: '005' > > Ciao, > Marc 'BlackJack' Rintsch > -- > http://mail.python.org/mailman/listinfo/python-list > > that or use *str(5).zfill(3)* -------------- next part -------------- An HTML attachment was scrubbed... URL: From wwzaygvm at gmail.com Wed Apr 16 17:03:02 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 14:03:02 -0700 (PDT) Subject: indesign cs2 crack Message-ID: <7732575d-daa9-4717-9865-5efe5a0726b5@8g2000hse.googlegroups.com> indesign cs2 crack http://cracks.12w.net F R E E C R A C K S From http Wed Apr 9 22:00:43 2008 From: http (Paul Rubin) Date: 09 Apr 2008 19:00:43 -0700 Subject: How is GUI programming in Python? References: Message-ID: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> Chris Stewart writes: > I've always had an interest in Python and would like to dabble in it > further. I've worked on a few very small command line programs but > nothing of any complexity. I'd like to build a really simple GUI app > that will work across Mac, Windows, and Linux. How painful is that > going to be? I used to be really familiar with Java Swing a few years > ago. I imagine it will be similar. > ... > Next, what would you say is the best framework I should look into? If by "best" you mean "easiest", that is probably tkinter, which comes with python. It is somewhat rudimentary and the widgets that come with it don't look so great. But if you just want to put up GUI's with basic functionality and not much glitz, it is ok for most such purposes. out how to use From wizzardx at gmail.com Tue Apr 22 15:29:52 2008 From: wizzardx at gmail.com (David) Date: Tue, 22 Apr 2008 21:29:52 +0200 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. In-Reply-To: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> Message-ID: <18c1e6480804221229k1155d1e0j920ce247c941dfc4@mail.gmail.com> On Tue, Apr 22, 2008 at 8:36 PM, Kenneth McDonald wrote: > Sadly. > > Thanks, > Ken > -- I checked, it's up now. You can also download packaged versions from Linux distros. eg: http://packages.debian.org/sid/web/python-beautifulsoup (there's a link to the tar.gz on the right side). Doesn't come with the nice online docs. But you can find those in other places (eg Google Cache). David. From michels at mps.mpg.de Tue Apr 15 04:31:50 2008 From: michels at mps.mpg.de (Helmut Michels) Date: Tue, 15 Apr 2008 10:31:50 +0200 Subject: [ANN] Data Plotting Library DISLIN 9.3 Message-ID: Dear Python users, I am pleased to announce version 9.3 of the data plotting software DISLIN. DISLIN is a high-level and easy to use plotting library for displaying data as curves, bar graphs, pie charts, 3D-colour plots, surfaces, contours and maps. Several output formats are supported such as X11, VGA, PostScript, PDF, CGM, WMF, HPGL, TIFF, GIF, PNG, BMP and SVG. The software is available for the most C, Fortran 77 and Fortran 90/95 compilers. Plotting extensions for the interpreting languages Perl, Python and Java are also supported. DISLIN distributions and manuals in PDF, PostScript and HTML format are available from the DISLIN home page http://www.dislin.de and via FTP from the server ftp://ftp.gwdg.de/pub/grafik/dislin All DISLIN distributions are free for non-commercial use. Licenses for commercial use are available from the site http://www.dislin.de. ------------------- Helmut Michels Max Planck Institute for Solar System Research Phone: +49 5556 979-334 Max-Planck-Str. 2 Fax : +49 5556 979-240 D-37191 Katlenburg-Lindau Mail : michels at mps.mpg.de From fennelllindy8241 at gmail.com Mon Apr 28 03:25:10 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:25:10 -0700 (PDT) Subject: 4502 cams patch Message-ID: <1700c43f-6402-4fdf-bf17-10f0014ca9ae@x35g2000hsb.googlegroups.com> 4502 cams patch http://crack.cracksofts.com From uwe.kotyczka at web.de Thu Apr 3 16:31:46 2008 From: uwe.kotyczka at web.de (Uwe Kotyczka) Date: Thu, 3 Apr 2008 13:31:46 -0700 (PDT) Subject: Nonlinear least square problem Message-ID: <0354420e-819d-4ba3-b61a-faaffd46b65c@r9g2000prd.googlegroups.com> Hallo, sorry for multiposting, but I am really looking for some hint to solve my problem. And no, I don't use Matlab, but maybe the matlab people have an idea nevertheless. I have to solve a nonlinear least square problem. Let me tell you some background first. Imagine you have a tool to process some work piece, say polishing some piece of glas. The tool behaves different on different locations of the piece, and I can describe that behaviour. Now the tool shall smooth the surface of the workpiece. Next I have information about the piece before handling it. What I have to find is optimal time curve for the tool to obtain a perfectly smooth surface. How to formulate the problem? Given a time vector (t_j) I have a function g which calculates the remaining error (e_i) (e_i) = g(t_j) The rest error is given at, say, 100 points, (t_j) is searched at 200 points. My idea was to make the (t_j) a function of some few parameters (t_j) = h(p_k), say 15 parameters. So the concatenated function (e_i) = g(t_j) = g(h(p_k)) =: f(p_k) is to be minimized. in the sense (e_i)-c -> Min, where c is a constant, the end level of the surface. To solve this problem I use a "C" implementation of the Levenberg-Marquardt algorithm as you can find it in the LevMar Package (www.ics.forth.gr/~lourakis/levmar/). The function g contains the information about the tool and about the initial surface. For the function h I tried several approaches, making the time a cubic spline of a selected times, or making it some polynmial or... Now what is my problem? With the above I do find solutions, however a lot of solutions seem to give very similar remaining errors. The only problem is that the corresponding time vectors, which are (t_j_optimal) = h(p_k_optimal) look very different from optimal solution to optimal solution. In particular the optimization algorithm often prefers solutions where the time vector is heavily oscillating. Now this is something I _must_ suppress, but I have no idea how. The oscillation of the (t_j) depend of the ansatz of h, of the number of parameters (p_k). If f would be a linear function, then the matrix representing it would be a band matrix with a lot of diagonals nonzero. How many depends on the ratio tool diameter to piece diameter. Now what are my question: Is the problem properly formulated? Can I expect to find non-oscillating solutions? Is it normal that taking more parameters (p_k) makes the thing worse? What else should I consider? Is this more verbal description sufficient? Thank you very much in advance. From peterjwright at gmail.com Wed Apr 2 10:15:23 2008 From: peterjwright at gmail.com (Pete Wright) Date: Wed, 2 Apr 2008 07:15:23 -0700 (PDT) Subject: developing web spider References: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> <30a89852-4730-490b-8701-b915cb0901ce@q27g2000prf.googlegroups.com> Message-ID: <1b3eb5b4-e540-4832-acc3-a2e1c959e526@f63g2000hsf.googlegroups.com> The O'Reilly Spidering Hacks book is also really good, albeit a little too focussed on Perl. On Apr 2, 9:54 am, zillo... at googlemail.com wrote: > On Apr 2, 6:37 am, abeen wrote: > > > Hello, > > > I would want to know which could be the best programming language for > > developing web spider. > > More information about the spider, much better,, > > > thanks > > >http://www.imavista.com > > Just saw this while passing by... There's a nice book by Michael > Schrenk (www.schrenk.com) called "Webbots, Spiders and Screen > Scrapers" that teaches scraping and spidering from the ground up using > PHP. Since you said you want more info on spiders, this book might be > a good way for you to acquire concept and implementation hand-in-hand. > He's also developed a nice webbot library in PHP that you can get from > his website. > > Also comes with a nice webbot library (which you can download from > the website anyway). From arnodel at googlemail.com Tue Apr 8 01:47:13 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Mon, 7 Apr 2008 22:47:13 -0700 (PDT) Subject: Translating keywords References: Message-ID: On Apr 8, 3:47?am, "Gabriel Genellina" wrote: > Python 3 allows for unicode identifiers, but I don'k know any plans for ? > using unicode keywords too. Looks funny: > > ? x ? values: > ? ?if x ? forbidden ? x ? y: > ? ? ?print(x, ?(x), ?(x)) > print(?(values)) > near = ? a,b,?=0.01: a-? ? b ? a+? It's all in the eye of the beholder: to me it looks readable, but that's because I've spent 10 years of my life reading and writing stuff like that. Although I would use ? and ? as aliases for all() and exists() :) -- Arnaud From ni at hao.com Wed Apr 30 04:06:12 2008 From: ni at hao.com (SL) Date: Wed, 30 Apr 2008 10:06:12 +0200 Subject: computing with characters In-Reply-To: References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> Message-ID: <5ed0b$48182881$541fc2ec$5430@cache1.tilbu1.nb.home.nl> "Arnaud Delobelle" schreef in bericht news:m2d4o7bwmd.fsf at googlemail.com... > "Gabriel Genellina" writes: > >> En Wed, 30 Apr 2008 04:19:22 -0300, SL escribi?: >> >>> "Lutz Horn" schreef in bericht >>> news:mailman.360.1209537877.12834.python-list at python.org... >>>> >>>> So just for completion, the solution is: >>>> >>>>>>> chr(ord('a') + 1) >>>> 'b' >>> >>> thanks :) I'm a beginner and I was expecting this to be a member of >>> string so I couldnt find it anywhere in the docs. >> >> And that's a very reasonable place to search; I think chr and ord are >> builtin functions (and not str methods) just by an historical >> accident. (Or is there any other reason? what's wrong with "a".ord() >> or str.from_ordinal(65))? > > > Not a reason, but doesn't ord() word with unicode as well? yes it does, I just read the documentation on it :) > > -- > Arnaud > From floris.bruynooghe at gmail.com Mon Apr 7 08:30:18 2008 From: floris.bruynooghe at gmail.com (Floris Bruynooghe) Date: Mon, 7 Apr 2008 05:30:18 -0700 (PDT) Subject: @x.setter property implementation References: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> Message-ID: On Apr 6, 6:41 pm, "Daniel Fetchinson" wrote: > > I found out about the new methods on properties, .setter() > > and .deleter(), in python 2.6. Obviously that's a very tempting > > syntax and I don't want to wait for 2.6... > > > It would seem this can be implemented entirely in python code, and I > > have seen hints in this directrion. So before I go and try to invent > > this myself does anyone know if there is an "official" implementation > > of this somewhere that we can steal until we move to 2.6? > > The 2.6 source? Have been grepping all over the place and failed to find it. I found the test module for them, but that doesn't get me very far... From billingspanshism at gmail.com Sat Apr 19 17:19:22 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:19:22 -0700 (PDT) Subject: how tall is victoria beckham Message-ID: <35040d0f-c9e9-46e4-86bd-26949cc2c856@59g2000hsb.googlegroups.com> Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From trentm at activestate.com Thu Apr 3 13:54:31 2008 From: trentm at activestate.com (Trent Mick) Date: Thu, 03 Apr 2008 10:54:31 -0700 Subject: Module not found in script that was found in command-line interpreter. Possible Path issue? In-Reply-To: <8463F6F2-4C02-48BC-BF7E-B606D4B41577@gmail.com> References: <8463F6F2-4C02-48BC-BF7E-B606D4B41577@gmail.com> Message-ID: <47F519D7.5090905@activestate.com> Jacob Davis wrote: > I just installed the MySQLdb module and I have been able to get it to > run in my command line interpreter. > > I am running Mac Leopard, and Python 2.5. > > I have tested importing and actually connecting and using a MySQL > database, although it issues some warning: > > SnakeBite:MySQL-python-1.2.2 Snake$ python > Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) > [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin > Type "help", "copyright", "credits" or "license" for more information. >>>> import MySQLdb > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-macosx-10.3-fat.egg/_mysql.py:3: > UserWarning: Module _mysql was already imported from From that message it looks like this "python" is /usr/local/bin/python (i.e. a separate installation than Apple's system python at /usr/bin/python and /System/Library/Frameworks/Python.framework). You can tell for sure by doing: $ which python > However, while writing a .py script (with Komodo Edit) I try to simply > import the module and the in-Komodo interpreter returns an error: > Traceback (most recent call last): > File > "/Users/Snake/Documents/NPS/Thesis/Source_Code/Genetics/mysql_connect_test.py", > line 11, in > import MySQLdb > ImportError: No module named MySQLdb I suspect that this is because your run of Komodo Edit doesn't have "/usr/local/bin" on its PATH and is using "/usr/bin/python" instead of the one you typically use on the command line. You can configure Komodo to know about /usr/local/bin by adding a "PATH" setting in the "Environment" prefs panel. Arguably Komodo should just add /usr/local/bin to its runtime PATH by default, but unfortunately it currently doesn't. Komodo doesn't pick up your normal bash shell environment because of problems trying to get that information in general. Please let me know (or on the komodo-discuss list [^1] or Komodo bug database [^2]) if you have any problems getting that going. Cheers, Trent [1]: http://listserv.activestate.com/mailman/listinfo/Komodo-discuss [2]: http://bugs.activestate.com/query.cgi?product=Komodo -- Trent Mick trentm at activestate.com From gherron at islandtraining.com Wed Apr 30 02:38:26 2008 From: gherron at islandtraining.com (Gary Herron) Date: Tue, 29 Apr 2008 23:38:26 -0700 Subject: computing with characters In-Reply-To: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> Message-ID: <481813E2.2030302@islandtraining.com> SL wrote: > How can I compute with the integer values of characters in python? > Like > 'a' + 1 equals 'b' etc > -- > http://mail.python.org/mailman/listinfo/python-list You can get an integer value from a character with the ord() function. Gary Herron From fr5478bey at gmail.com Sat Apr 26 11:38:55 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:38:55 -0700 (PDT) Subject: RegistryBooster2 crack Message-ID: <32be3d11-ec3e-47bf-9139-f702f4d46d9c@e39g2000hsf.googlegroups.com> RegistryBooster2 crack http://cracks.00bp.com F R E E C R A C K S From deets at nospam.web.de Wed Apr 16 06:19:33 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 16 Apr 2008 12:19:33 +0200 Subject: webcam (usb) access under Ubuntu References: <66jlk1F2ju6c8U1@mid.uni-berlin.de> <66kkedF2l526dU2@mid.uni-berlin.de> <455760fb-8229-4be3-ba7f-7c41bdcd66de@a22g2000hsc.googlegroups.com> <362eb242-2adc-4d7b-9c0a-95e72f4b22b6@e67g2000hsa.googlegroups.com> Message-ID: <66m26hF2lo3ghU1@mid.uni-berlin.de> Berco Beute wrote: > On Apr 15, 11:45 pm, Berco Beute wrote: >> I've tried reinstalling gstreamer (for windows): >> >> http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstre...http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstre... >> >> but that didn't help. I get some complaints about 'libgstinterfaces' >> as well... > > To be more precise, when doing an 'import gst' Python shell pops up an > error dialog saying: > > "This application has failed to start because > libgstinterfaces-0.10.dll was not found." I'm sorry, but I really can't comment on gst-installion issues - that all worked for me because of ubuntu. Maybe if you are now using windows, there are better options - but I'm a *nix-boy :) Diez From steve at holdenweb.com Sat Apr 5 07:07:04 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 07:07:04 -0400 Subject: In Tkinter - having an input and an entry In-Reply-To: References: Message-ID: markfernandes02 at googlemail.com wrote: > I need some advice, > I am creating a python program to communicate with an MS Access db in > python 2.4. > I can fetch records but cannot insert records. > > def Insert(self, *row): > global cursor, title, author, pubdate > sqlInsert = "INSERT INTO Book_table" > sqlInsert = sqlInsert + "(Bookname, BookAutor, " > sqlInsert = sqlInsert + "Publicationdate) VALUES ('" > sqlInsert = sqlInsert + title + "', '" > sqlInsert = sqlInsert + author + "', " > sqlInsert = sqlInsert + pubdate + ") " First of all, read about parameterized queries so that you don't do any more of this. Abbreviated version: formulate your query so that cursor.execute takes a query with parameter slots in it as the first argument and a data set as the second argument. > myconn = odbc.odbc('accessDatabase') > cursor = myconn.cursor() > cursor.execute(sqlInsert) > myconn.commit() > cursor.close() > myconn.close() > > The above code does not work. Secondly, observe that in a GUI environment the valuable traceback information will likely be completely lost, so you should get your code working first in a command-line based tool that will provide information about what is going wrong. "Does not work" is way to vague for anyone to be able to provide helpful responses. We need to see specific tracebacks (though kudos for actually listing your code: some people effectively just say the equivalent of "My program to do X does not work, can you tell me what's wrong with it"!). > Also with Tkinter, i want to have user input records into the db, i > cannot get what the user inputs into the entry to become a string > variable. > That's usually a matter of calling the appropriate widget's correct method. For example, if you have an Entry widget called e you would retrieve the input from it by calling e.get - see http://effbot.org/tkinterbook/entry.htm for documentation from the effbot, the font of all Tkinter knowledge. > If you can help it would be most appreciated. > Thanks in advanced > Did my best. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From zedshaw at zedshaw.com Tue Apr 29 03:51:43 2008 From: zedshaw at zedshaw.com (Zed A. Shaw) Date: Tue, 29 Apr 2008 03:51:43 -0400 Subject: ]ANN[ Vellum 0.16: Lots Of Documentation and Watching Message-ID: <20080429035143.1383a32f.zedshaw@zedshaw.com> Hi Everyone, Just putting out an announcement that I've released a new version of Vellum numbered 0.16. This version should be ready for people to use as not much of the internal structure has changed in a great many commits and it contains all the latest bug fixes. It also has the beginning of an extensive PDF document describing how to use it. This is still an in-progress work, so it has grammar mistakes and spelling errors, but it does show off some nice documentation wizardy I'm experimenting with in LaTeX. Finally there's a new "watch" feature which is very handy described further down. It simply watches a file and reruns your targets when the file changes. GETTING IT Honestly, the easiest way is just: sudo easy_install zapps vellum If you want to build the book yourself and have all of TeX Live installed then you'd also need: sudo easy_install pygments idiopidae You can also hit the http://launchpad.net/vellum/ page to grab source tarballs and other goodies. THE BOOK OF VELLUM You can grab the most recent draft of the book at: http://zedshaw.com/projects/vellum/manual-final.pdf Any corrections or comments on how it is written are more than welcome. Suggestions for improving the TeX are also helpful since I'm not a TeX expert yet. The software I'm using to build that book is fully available to anyone looking to document their projects. You can grab Idiopidae, Pygments, and TeX from the interwebs. You can then grab the whole source and all the LaTeX goodness from my Bazaar repository: bzr pull http://zedshaw.com/repository/vellum/ Look in the doc/ directory for all the fun. You'll notice that the .tex files have *no* code in them, and that it's all imported by Idiopidae. Look at the doc/book.vel file to see how it's all merged and massaged together, and you can reuse this book.vel file to start your own books. CRAZY NICE WATCH FEATURE I added a feature to Vellum that is one of those "duh" features. You can tell Vellum to watch a file, and if it changes Vellum will rerun some targets. When I work on the manual.tex file, I do this: vellum -w doc/manual.tex book.draft book.view It just keeps looping, and if you hit CTRL-C you can force a build with ENTER or quit with CTRL-C. Then I use the evince PDF viewer under linux, which has similar Vim key bindings and reloads the PDF when it changes. The net effect of this is, whenever I change my manual.tex file, Vellum runs my build for the manual and evince redisplays it for me to see. You could use this simple feature to also continually run unit tests whenever a file changes that you are working on. GPLv3? How do people feel about Vellum's GPLv3 status? It actually doesn't impact anyone unless you embed Vellum into a project/product or you create commands (which you should give back anyway). Even then if you never release your build to your users then you don't need to release the commands. However, I'm curious to get other people's thoughts. Thanks a bunch folks. -- Zed A. Shaw - Hate: http://savingtheinternetwithhate.com/ - Good: http://www.zedshaw.com/ - Evil: http://yearofevil.com/ From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Sat Apr 26 06:32:08 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Sat, 26 Apr 2008 12:32:08 +0200 Subject: display monochromatic images wxPython References: <43c2ef33-b08c-4161-b170-16ab346628d7@m36g2000hse.googlegroups.com> Message-ID: <67gel8F2p1bmkU2@mid.individual.net> wongjoekmeu at yahoo.com wrote: > I want to write a GUI program with wxPython displaying an image. Then be sure to check out the wxPython demo application. It displays lots of images. Regards, Bj?rn -- BOFH excuse #217: The MGs ran out of gas. From george.sakkis at gmail.com Tue Apr 8 20:51:11 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 8 Apr 2008 17:51:11 -0700 (PDT) Subject: calling variable function name ? References: Message-ID: On Apr 8, 3:52 pm, TkNeo wrote: > I don't know the exact terminology in python, but this is something i > am trying to do > > i have 3 functions lets say > FA(param1,param2) > FB(param1,param2) > FC(param1,param2) > > temp = "B" #something entered by user. now i want to call FB. I don't > want to do an if else because if have way too many methods like > this... > > var = "F" + temp > var(param1, param2) Try this: func = globals()["F" + temp] func(param1, param2) HTH, George From sjmachin at lexicon.net Sat Apr 19 16:34:53 2008 From: sjmachin at lexicon.net (John Machin) Date: Sat, 19 Apr 2008 20:34:53 GMT Subject: [ANN] DoIt 0.1.0 Released (build tool) In-Reply-To: References: Message-ID: <480a576a$1@news.mel.dft.com.au> Eduardo Schettino wrote: > DoIt - A task execution tool (build-tool) > ========================================= > > This is the first public release of DoIt > > Website: http://python-doit.sourceforge.net/ > Release: DoIt 0.1.0 > License: MIT > > About > ----- > > DoIt is a build tool that focus not only on making/building things but on > executing any kind of tasks in an efficient way. Designed to be easy to use > and "get out of your way". You may like to consider the possibility of confusion caused by the similarity of some characters in some fonts (DoIt, Do1t, Dolt) ... google("dictionary dolt") :-) From gagsl-py2 at yahoo.com.ar Tue Apr 22 15:04:11 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 22 Apr 2008 16:04:11 -0300 Subject: Problem with urllib2 and authentification References: Message-ID: En Tue, 22 Apr 2008 11:24:20 -0300, Miguel Beltran R. escribi?: > Using this script for connect to Zope I have this error > > ---script: > import urllib2 > > protocolo='http://' > servidor='10.28.1.239/' > pagina='manage' > fullurl=protocolo+servidor+pagina > > aut=urllib2.HTTPBasicAuthHandler() > aut.add_password(realm=None, > uri=servidor, > user='myadmin', > passwd='mypass') > opener=urllib2.build_opener(aut, urllib2.HTTPHandler(debuglevel=1)) > > print opener.open(fullurl).read() > > > ---Error: > connect: (10.28.1.239, 80) > send: 'GET /manage HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: > 10.28.1.239\r\nConnection: close\r\nUser-agent: > Python-urllib/2.4\r\n\r\n' > reply: 'HTTP/1.1 401 Unauthorized\r\n' > header: Server: Zope/(Zope 2.10.5-final, python 2.4.4, win32) ZServer/1.1 > header: Date: Tue, 22 Apr 2008 14:14:45 GMT > header: Bobo-Exception-Line: 713 > header: Content-Length: 884 > header: Bobo-Exception-Value: See the server error log for details > header: Content-Type: text/html; charset=iso-8859-15 > header: Bobo-Exception-Type: Unauthorized > header: Connection: close > header: Bobo-Exception-File: HTTPResponse.py > header: WWW-Authenticate: basic realm="Zope" Note the realm="Zope" above. You should add a password for such exact realm, or use an HTTPPasswordMgrWithDefaultRealm instead. Also, the uri argument to add_password is wrong. Try this: protocolo='http://' servidor='10.28.1.239' pagina='/manage' fullurl=protocolo+servidor+pagina aut=urllib2.HTTPBasicAuthHandler() aut.add_password(realm="Zope", uri=servidor, user='myadmin', passwd='mypass') opener=urllib2.build_opener(aut, urllib2.HTTPHandler(debuglevel=1)) print opener.open(fullurl).read() The other alternative would be: pmgr = urllib2.HTTPPasswordMgrWithDefaultRealm() pmgr.add_password(None, uri=servidor, user=..., passwd=...) aut = urllib2.HTTPBasicAuthHandler(pmgr) opener=urllib2.build_opener(aut, urllib2.HTTPHandler(debuglevel=1)) -- Gabriel Genellina From jkrukoff at ltgc.com Tue Apr 15 17:25:39 2008 From: jkrukoff at ltgc.com (John Krukoff) Date: Tue, 15 Apr 2008 15:25:39 -0600 Subject: Recurring patterns: Am I missing it, or can we get these added to the language? In-Reply-To: References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: <1208294739.5926.17.camel@localhost.localdomain> On Tue, 2008-04-15 at 13:48 -0700, Jeffrey Froman wrote: > Tim Chase wrote: > > def nsplit(s, delim=None, maxsplit=None): > > if maxsplit: > > results = s.split(delim, maxsplit) > > result_len = len(results) > > if result_len < maxsplit: > > results.extend([''] * (maxsplit - result_len) > > return results > > else: > > return s.split(delim) > > I'll add a couple more suggestions: > > 1. Delay the test for maxsplit, as str.split() does the right thing if > maxsplit is None. > > 2. Use a generator to pad the list, to avoid interim list creation. This > works fine, because list.extend() accepts any iterable. This also shortens > the code a bit, because xrange() does the right thing in this case with > negative numbers. For example: > > def nsplit(s, delim=None, maxsplit=None): > results = s.split(delim, maxsplit) > if maxsplit is not None: > results.extend('' for i in xrange(maxsplit - len(results))) > return results > > > Jeffrey > Neither of these quite match what the OP's nsplit function did, as his n parameter (maxsplit here) actually specified the number of list items in the result, not the number of splits to perform. Which makes matching the default split parameters kind of pointless, as why bother doing all this work to return a 0 item list in the default maxsplit = None case. -- John Krukoff Land Title Guarantee Company From asmodai at in-nomine.org Mon Apr 14 04:54:58 2008 From: asmodai at in-nomine.org (Jeroen Ruigrok van der Werven) Date: Mon, 14 Apr 2008 10:54:58 +0200 Subject: Chinese character become ??? by pymssql or pyodbc In-Reply-To: <01d95039-b547-45ff-9b54-f04aee8eaaa1@u36g2000prf.googlegroups.com> References: <01d95039-b547-45ff-9b54-f04aee8eaaa1@u36g2000prf.googlegroups.com> Message-ID: <20080414085457.GW51167@nexus.in-nomine.org> -On [20080414 10:31], James Su (SuJinzhu at gmail.com) wrote: >But when I query those data by pymssql or pyodbc, all Chinese >Character display ??? instead. Sounds like you are getting typical Unicode replacement characters. -- Jeroen Ruigrok van der Werven / asmodai ????? ?????? ??? ?? ?????? http://www.in-nomine.org/ | http://www.rangaku.org/ >From here, what you see you become... From steven.p.clark at gmail.com Mon Apr 7 16:39:56 2008 From: steven.p.clark at gmail.com (Steven Clark) Date: Mon, 7 Apr 2008 16:39:56 -0400 Subject: Data structure recommendation? Message-ID: <663744510804071339g639bfdccl63de8be66fe52df1@mail.gmail.com> Hi all- I'm looking for a data structure that is a bit like a dictionary or a hash map. In particular, I want a mapping of floats to objects. However, I want to map a RANGE of floats to an object. This will be used for timestamped storage / lookup, where the float represents the timestamp. get(x) should return the object with the "newest" (biggest) timestamp y <= x, if it exists. Example: foo = Foo() foo.get(1.5) -> None foo.put(1.3, 'a') foo.put(2.6, 'b') foo.get(1.5) -> 'a' foo.get(7.8) -> 'b' foo.put(5.0, 'c') foo.get(7.8) -> 'c' In otherwords, by the end here, for foo.get(x), x < 1.3 maps to None, 1.3 <= x < 2.6 maps to 'a', 2.6 <= x < 5.0 maps to 'b', 5.0 <= x maps to 'c'. I know that foo.get() will be called many times for each foo.put(). Is there any way to achieve O(1) performance for foo.get(), maybe via some kind of hash function? Or is the best thing to use some kind of binary search? Thanks for any advice. -Steven From john106henry at hotmail.com Tue Apr 29 10:11:40 2008 From: john106henry at hotmail.com (John Henry) Date: Tue, 29 Apr 2008 07:11:40 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <473deef3-9acb-45dd-a7ca-47b0081bd28c@i36g2000prf.googlegroups.com> <3f7bb91e-335e-46bd-88ca-f15b26c35132@k1g2000prb.googlegroups.com> Message-ID: <827bdae6-4422-4226-a543-af53f5b7e01b@s33g2000pri.googlegroups.com> On Apr 29, 1:57 am, Panyasan wrote: > Hi, > > I am one of the two developers working on the xml-to-javascript > converter (qxtransformer) John has mentioned and we are thrilled that > our project has found a use in the PythonCard community. > > However, we have a problem getting PythonCard to work on our Macs (Mac > OS 10.5 Leopard). We should probably be asking this on the PythonCard > help list, but since the list seems to be somewhat deserted (very few > posts) and John is active here and people seem to be using PythonCard, > maybe someone has an idea. It might be very simple and stupid - I have > never worked with python before. > > I am using > - PythonCard 0.8.2 release on Leopard, which is copied by setup.py to / > Library/Python/2.5/site-packages > - John's layoutEditor package, (http://qxtransformer.googlegroups.com/ > web/layoutEditor.zip) > > PythonCard email list says that Leopard and PythonCard 0.8.2 seem to > like each other generally: > > http://sourceforge.net/mailarchive/forum.php?thread_name=EE5213D5-A00... > > and I can get the examples working. However, when I start John's > modified layoutEditor.py, I get an empty window and the following > error is thrown: > > no resource file for /Users/bibliograph/Programme/PythonCard/tools/ > layoutEditor/multipropertyEditor > Traceback (most recent call last): > File "/BinaryCache/wxWidgets/wxWidgets-11~57/Root/System/Library/ > Frameworks/Python.framework/Versions/2.5/Extras/lib/python/wx-2.8-mac- > unicode/wx/_core.py", line 14095, in > File "/Library/Python/2.5/site-packages/PythonCard/tools/ > layoutEditor/layoutEditor.py", line 153, in on_initialize > self.propertyEditorWindow = model.childWindow(self, > PropertyEditor) > File "/Library/Python/2.5/site-packages/PythonCard/model.py", line > 213, in childWindow > rsrc = resource.ResourceFile(filename).getResource() > File "/Library/Python/2.5/site-packages/PythonCard/resource.py", > line 45, in __init__ > self.dictionary = util.readAndEvalFile(rsrcFileName) > File "/Library/Python/2.5/site-packages/PythonCard/util.py", line > 39, in readAndEvalFile > f = open(filename) > TypeError: coercing to Unicode: need string or buffer, NoneType found > > there is a file PythonCard/tools/layoutEditor/modules/ > multipropertyEditor.rsrc.py > > When I resize the window, I get the following errors > > Tue Apr 29 10:48:08 noname Python[40440] : CGContextConcatCTM: > invalid context > Tue Apr 29 10:48:08 noname Python[40440] : CGContextSaveGState: > invalid context > Tue Apr 29 10:48:08 noname Python[40440] : doClip: invalid > context > Tue Apr 29 10:48:08 noname Python[40440] : CGContextSaveGState: > invalid context > Tue Apr 29 10:48:08 noname Python[40440] : > CGContextSetBlendMode: invalid context > Tue Apr 29 10:48:08 noname Python[40440] : > CGContextSetShouldAntialias: invalid context > Traceback (most recent call last): > File "/Library/Python/2.5/site-packages/PythonCard/model.py", line > 884, in _dispatch > handler(background, aWxEvent) > File "/Library/Python/2.5/site-packages/PythonCard/tools/ > layoutEditor/layoutEditor.py", line 560, in on_size > self.createDC() > File "/Library/Python/2.5/site-packages/PythonCard/tools/ > layoutEditor/layoutEditor.py", line 556, in createDC > dc.SetLogicalFunction(wx.INVERT) > File "/BinaryCache/wxWidgets/wxWidgets-11~57/Root/System/Library/ > Frameworks/Python.framework/Versions/2.5/Extras/lib/python/wx-2.8-mac- > unicode/wx/_gdi.py", line 4079, in SetLogicalFunction > wx._core.PyAssertionError: C++ assertion "status == noErr" failed > at ../src/mac/carbon/graphics.cpp(1324) in EnsureIsValid(): Cannot > nest wxDCs on the same window > > Thanks for any pointers, > > Christian Christian, It appears you're missing a file. Where did you placed my program? I see that there are two places being mentioned: > no resource file for /Users/bibliograph/Programme/PythonCard/tools/ > layoutEditor/multipropertyEditor and > File "/Library/Python/2.5/site-packages/PythonCard/tools/ > layoutEditor/layoutEditor.py", line 556, in createDC From ggrason at NOSPAM.gmail.com.INVALID Tue Apr 8 12:07:48 2008 From: ggrason at NOSPAM.gmail.com.INVALID (Guillaume) Date: Tue, 08 Apr 2008 18:07:48 +0200 Subject: List open files In-Reply-To: <47fb9789$0$881$ba4acef3@news.orange.fr> References: <47fb8d54$0$15068$426a74cc@news.free.fr> <47fb9789$0$881$ba4acef3@news.orange.fr> Message-ID: Oh and don't forget to take care about saving correctly the Oracle database ! ^^ (private joke *giggles* j/k :)) Regards, -- Guillaume From bruno.desthuilliers at gmail.com Wed Apr 2 19:03:57 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 16:03:57 -0700 (PDT) Subject: Nested try...except References: Message-ID: <767f1014-1279-40b6-bfef-fd3b39ba2dda@s37g2000prg.googlegroups.com> On 2 avr, 15:12, cokofree... at gmail.com wrote: > On Apr 2, 3:06 pm, Magnus.Morab... at gmail.com wrote: > > > > > Hi, > > > I found the following code on the net - > > > http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/%3C20050924104732.5116.qm... at minotaur.apache.org%3E > > > def count(self): > > - db = sqlite.connect(self.filename, > > isolation_level=ISOLATION_LEVEL) > > - try: > > - try: > > - cur = db.cursor() > > - cur.execute("select count(*) from sessions") > > - return cur.fetchone()[0] > > - finally: > > - cur.close() > > - finally: > > - db.close() > > > I don't understand though why the second try is not after the line cur > > = db.cursor(). Can anyone explain for me why? > > > /Barry. > > Better question is why is there a try with no except... Because the author doesn't want to handle the exception here, only make sure resources are freed. > Better yet, WHY is there two TRY statements when there could quite > happily be only one... > > Towards what you are asking, I GUESS...because the author hoped to > handle the cases where cur failed to get assigned...but then > his .close method of it would likely not work anyway...I mean...does > this even work...YUCK Indeed. From lists at cheimes.de Mon Apr 14 16:43:44 2008 From: lists at cheimes.de (Christian Heimes) Date: Mon, 14 Apr 2008 22:43:44 +0200 Subject: What parts of string module will disappear in Python 3.0? In-Reply-To: <1208205039.18800.1247843527@webmail.messagingengine.com> References: <1208205039.18800.1247843527@webmail.messagingengine.com> Message-ID: <4803C200.7040800@cheimes.de> python at bdurham.com schrieb: > I understand that many portions of the string module are redundant with > the native methods of strings and will removed in Python 3.0. Makes > sense to me. > > But what will happen to the portions of the string module that are not > covered by native string methods - like the following: > > - string constants (example: string.punctuation) > - Template strings > - maketrans() > > Will some semblance of the string module remain in Python 3.0 under the > string module name or a new module name? See for yourself: http://svn.python.org/projects/python/branches/py3k/Lib/string.py Christian From arnodel at googlemail.com Wed Apr 30 04:00:26 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Wed, 30 Apr 2008 09:00:26 +0100 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> Message-ID: "Gabriel Genellina" writes: > En Wed, 30 Apr 2008 04:19:22 -0300, SL escribi?: > >> "Lutz Horn" schreef in bericht >> news:mailman.360.1209537877.12834.python-list at python.org... >>> >>> So just for completion, the solution is: >>> >>>>>> chr(ord('a') + 1) >>> 'b' >> >> thanks :) I'm a beginner and I was expecting this to be a member of >> string so I couldnt find it anywhere in the docs. > > And that's a very reasonable place to search; I think chr and ord are > builtin functions (and not str methods) just by an historical > accident. (Or is there any other reason? what's wrong with "a".ord() > or str.from_ordinal(65))? Not a reason, but doesn't ord() word with unicode as well? -- Arnaud From Colin.Prepscius at morganstanley.com Wed Apr 2 09:19:57 2008 From: Colin.Prepscius at morganstanley.com (Prepscius, Colin (IT)) Date: Wed, 2 Apr 2008 09:19:57 -0400 Subject: ThreadingTCPServer: sock.recv() doesn't block? Message-ID: So I'm using the ThreadingTCPServer from the python standard library SocketServer, and calling serve_forever on it. In my handler's handle method, I call self.request.recv(x) in a loop until I've received n bytes. But recv() returns immediately with nothing, over and over. It all still works, but my cpu pegs. I thought socketc.recv() was supposed to block. Anybody know if I'm doing something wrong? thanks! Colin -------------------------------------------------------- NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error. -------------- next part -------------- An HTML attachment was scrubbed... URL: From bowman at montana.com Sun Apr 6 12:04:23 2008 From: bowman at montana.com (bowman) Date: Sun, 06 Apr 2008 10:04:23 -0600 Subject: Best way to check if string is an integer? References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> <0fdd2825-6d1c-4380-a79a-a7aac119f002@a5g2000prg.googlegroups.com> <96d2fe53-96bf-43d8-a58d-8269846bf0df@b64g2000hsa.googlegroups.com> Message-ID: <2033313.fb3g3XYCIP@montana.com> Jorgen Grahn wrote: > [0] There would have been more if Python had supported hexadecimal > floating-point literals, like (I believe) C does. C99 does. On the other hand, it isn't a feature I sorely missed during the first 20 years or so of C's history, but you could always do some creative byte twiddling if the need arouse. From bruno.42.desthuilliers at wtf.websiteburo.oops.com Tue Apr 1 05:02:27 2008 From: bruno.42.desthuilliers at wtf.websiteburo.oops.com (Bruno Desthuilliers) Date: Tue, 01 Apr 2008 11:02:27 +0200 Subject: Newbie Question - Overloading == In-Reply-To: References: <85edb5fb-eae8-4e8f-8f77-0ee4668063cd@u69g2000hse.googlegroups.com> <7eb5d21a-c4de-4655-ab93-9221d996f424@i7g2000prf.googlegroups.com> Message-ID: <47f1fa23$0$27429$426a74cc@news.free.fr> Duncan Booth a ?crit : > "bruno.desthuilliers at gmail.com" wrote: > >>> Surely an A isn't equal to every other object which just happens to >>> have the same attributes 'a' and 'b'? >> And why not ?-) >> >>> I would have thoughts the tests want to be >>> something like: >>> >>> class A: >>> def __eq__(self,other): >>> return (isinstance(other, A) and >>> self.a == other.a and self.b == other.b) >>> >>> (and similar for B) with either an isinstance or exact match required >>> for the type. >> I don't think there's a clear rule here. Python is dynamically typed >> for good reasons, and MHO is that you should not fight against this >> unless you have equally good reasons to do so. >> > I fully agree with that, but an apple != a pear, even if they are the same > size and colour. It mostly depends on the problem at hand. It may be that for some problem, an apple == a pear if they have the same size and colour. > There will be some types where you can have equality > between objects of different types (e.g. int/float), but more often the > fact that they are different types wil automatically mean they are not > equal. 'most often' != 'always' !-) From stefan_ml at behnel.de Fri Apr 11 06:49:18 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 11 Apr 2008 12:49:18 +0200 Subject: [lxml-dev] CDATA and lxml In-Reply-To: <47FF368B.4030708@behnel.de> References: <5ebe3201-80a6-45ba-8b88-e8ece6883efa@w8g2000prd.googlegroups.com> <47FF368B.4030708@behnel.de> Message-ID: <47FF422E.5090104@behnel.de> Stefan Behnel wrote: > It's not as trivial as it sounds. Removing the CDATA sections in the parser is > just for fun. ... *not* just for fun ... obviously ... Stefan From andy.leszczynski at gmail.com Wed Apr 23 21:19:41 2008 From: andy.leszczynski at gmail.com (AlFire) Date: Wed, 23 Apr 2008 20:19:41 -0500 Subject: Python Success stories In-Reply-To: References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <480FE02D.3040201@ggmail.com> Cristina Yenyxe Gonz?lez Garc?a wrote: > 2008/4/23, Reedick, Andrew : >> IIRC, Python is used in games like Eve Online (SciFi MMO) and Vampire: >> Bloodlines (RPG.) Years later, a dedicated fan is still fixing/updating >> the Bloodlines python scripts that control the dialogue and scripted >> events. >> > > Now that you mention it, Python was also used in the Star Wars: > Knights of the Old Republic (KotOR) saga. You can even search the > scripts across the disc and take a look at hilarious code comments > like "this works but I don't know why" :D and Shrek 3 http://www.linuxjournal.com/article/9653 -- a. From deets at nospam.web.de Thu Apr 17 11:07:29 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 17 Apr 2008 17:07:29 +0200 Subject: why objects of old style classes are instances of 'object' References: <4807641F.8030209@gmail.com> Message-ID: <66p7eeF2l44iiU2@mid.uni-berlin.de> AlFire wrote: > Hi, > > Q: from the subject, why objects of old style classes are instances of > 'object'? > > >>> class a():pass > >>> A=a() > >>> isinstance(A,object) > > True Because everything is an object. But not everything is a newstyle-class: >>> class Foo: pass ... >>> isinstance(Foo, object) True >>> isinstance(Foo, type) False >>> class Bar(object): pass ... >>> isinstance(Bar, type) True >>> Diez From alexelder at gmail.com Wed Apr 23 04:49:04 2008 From: alexelder at gmail.com (alexelder at gmail.com) Date: Wed, 23 Apr 2008 01:49:04 -0700 (PDT) Subject: "Dreaming in Code" References: <14fccf8d-eb21-4e04-9244-50bcfc84c4d7@d45g2000hsc.googlegroups.com> Message-ID: <615ec25f-b4ca-4e37-afb5-0f0046c1b52a@l64g2000hse.googlegroups.com> On Apr 23, 6:12 am, Paul McGuire wrote: > Haven't seen anyone mention this book, it is a "Soul of a New Machine"- > style record of the Chandler project. Since Chandler uses Python and > Twisted, and employed a few Python celebs, I thought folks on this > list might have already read the hardcover version. I just picked up > the paperback at B&N yesterday, finished it this evening. It's a > decent read, describing a software project in laymen's terms (like > there are laymen out there who care about that sort of thing!). > > The paperback version adds a chapter including events that transpired > after the hardcover publication date, current up to about October, > '07, so that's a nice touch. > > I'm going to ask my wife to read it so she might learn what I do for a > living. > > -- Paul Hi, Paul. This book was actually the book which got me into Python! At the time of reading I was in my second year of University, utterly snowed under with Java and C related assignments/personal projects, however, I found time to read this book; I'm /so/ glad I did. I actually heard of the book from an article written by Joel 'Joel on Software', Spolsky. (you can find it here: http://www.joelonsoftware.com/items/2007/01/02.html). It's an interesting read and poses a nice insight into how software projects evolve over time. Alex. From leoniaumybragg at gmail.com Sat Apr 26 07:00:25 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 04:00:25 -0700 (PDT) Subject: civilization 3 crack Message-ID: <276f223e-15e3-4f34-88ba-b18d619d0e8f@e39g2000hsf.googlegroups.com> civilization 3 crack http://cracks.00bp.com F R E E C R A C K S From martin at v.loewis.de Sun Apr 27 03:12:07 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 27 Apr 2008 09:12:07 +0200 Subject: Why can't timedeltas be divided? In-Reply-To: References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> Message-ID: <48142747$0$20906$9b622d9e@news.freenet.de> > Last time I brought up this sort of thing, it seemed fairly unanimous > that the shortcomings of the datetime module were 'deliberate' and > would not be fixed, patch or no patch. Ok, so then if the answer to my question is "yes", the first step should be to discuss it on python-dev. Regards, Martin From python at bdurham.com Mon Apr 28 12:33:21 2008 From: python at bdurham.com (python at bdurham.com) Date: Mon, 28 Apr 2008 12:33:21 -0400 Subject: Given a string - execute a function by the same name Message-ID: <1209400401.22706.1250293015@webmail.messagingengine.com> I'm parsing a simple file and given a line's keyword, would like to call the equivalently named function. There are 3 ways I can think to do this (other than a long if/elif construct): 1. eval() 2. Convert my functions to methods and use getattr( myClass, "method" ) 3. Place all my functions in dictionary and lookup the function to be called Any suggestions on the "best" way to do this? Thank you, Malcolm From theller at ctypes.org Fri Apr 4 07:49:24 2008 From: theller at ctypes.org (Thomas Heller) Date: Fri, 04 Apr 2008 13:49:24 +0200 Subject: Ignoring windows registry PythonPath subkeys In-Reply-To: <133d93d0-8100-446c-909d-3b25d79af0a2@t54g2000hsg.googlegroups.com> References: <133d93d0-8100-446c-909d-3b25d79af0a2@t54g2000hsg.googlegroups.com> Message-ID: <47F615C4.3070704@ctypes.org> Floris Bruynooghe schrieb: > Hi > > We basically want the same as the OP in [1], i.e. when python starts > up we don't want to load *any* sys.path entries from the registry, > including subkeys of the PythonPath key. The result of that thread > seems to be to edit PC/getpathp.c[2] and recompile. > > This isn't that much of a problem since we're compiling python anyway, > but is that really still the only way? Surely this isn't such an > outlandish requirement? If you look into PC/getpathp.c *and* PC/dl_nt.c, you'll find that the registry key name if constructed from static components plus a variable component named PyWin_DLLVersionString. The latter is loaded from a string resource (with resource ID 1000, IIRC) inside the pythonXY.dll. This string resource can be changed (even without compiling!); so this is a way for you to force the lookup of PythonPath to a different registry key. You can choose something that probably does not exist. py2exe does this also for 'frozen' executables, and so has complete control over sys.path. Thomas From aldo at nullcube.com Tue Apr 1 22:51:04 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Wed, 2 Apr 2008 13:51:04 +1100 Subject: ANN: cubictemp template engine In-Reply-To: References: <20080402012420.GA21586@nullcube.com> Message-ID: <20080402025104.GA22178@nullcube.com> Hi Daniel, > Does it support the Buffet API? No - we don't use any of the frameworks that require it. If the implementation is simple enough, though, I'd be happy to look at a patch... ;) > Do you have any benchmarks to compare it with other template systems > (in terms of speed)? Not formally - perhaps I'll get to it one day in my Copious Free Time. Cubictemp is optimised for use in situations where Template objects are persistent. Templates are parsed on instantiation, and all expressions they contain are pre-compiled. In long-running processes like FastCGI where you can instantiate a Template once and use it many times Cubictemp should be very fast. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From aahz at pythoncraft.com Fri Apr 25 20:07:38 2008 From: aahz at pythoncraft.com (Aahz) Date: 25 Apr 2008 17:07:38 -0700 Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> Message-ID: In article <7e595409-be62-4b8c-9819-a14cd363d751 at c65g2000hsa.googlegroups.com>, azrael wrote: > >Which big aplications are written in python. YouTube -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ Why is this newsgroup different from all other newsgroups? From john00587 at gmail.com Mon Apr 21 01:39:35 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:39:35 -0700 (PDT) Subject: anydvd 6.1.6.0 crack Message-ID: <07e5ad34-98a9-4ea5-800e-2c67940e9349@w1g2000prd.googlegroups.com> anydvd 6.1.6.0 crack http://cracks.00bp.com F R E E C R A C K S From ockman at gmail.com Mon Apr 21 20:12:44 2008 From: ockman at gmail.com (ockman at gmail.com) Date: Mon, 21 Apr 2008 17:12:44 -0700 (PDT) Subject: Problems replacing \ with \\ References: <0ca30eb2-3791-4910-9e78-f32e3b2a72cb@2g2000hsn.googlegroups.com> Message-ID: <6f7342eb-08f8-45d6-b50e-652bf77921d7@l42g2000hsc.googlegroups.com> HTH -- Thank you for the response. I'm not sure I understand the last sentence, although I think I get the idea. How do I create a proper doctest? Thanks On Apr 21, 9:08 pm, MRAB wrote: > On Apr 21, 11:48 pm, "samsli... at gmail.com" > wrote: > > > > > Hi... > > > Here's a weird problem...I'm trying to escape a bunch of data to put > > into a database. > > > Here's what I have: > > > def escape(string): > > """ > > Escape both single quotes and blackslashes > > >>> x = r"fun\fun" > > >>> escape(x) > > 'fun\\\\fun' > > """ > > string = string.replace('\\', '\\\\') > > return string > > > Now the commands in the doctest work when I type them by hand into the > > python interpreter!>>> x = r"fun\fun" > > >>> escape(x) > > > 'fun\\\\fun' > > > But they don't work when I actually run them with doctest: > > Failed example: > > escape(x) > > Expected: > > 'fun\\fun' > > Got: > > 'fun\x0cun' > > > Why? > > > Thanks! > > Your doctest is in a triple-quoted string which contains the line: > > >>> x = r"fun\fun" > > ^^ > > which is the same as: > > >>> x = r"fun\x0cun" > > ^^^^ > > If you wrap a raw string in just quotes that is isn't a raw string any > longer! > > HTH From george.sakkis at gmail.com Tue Apr 29 13:44:33 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 29 Apr 2008 10:44:33 -0700 (PDT) Subject: Issue with regular expressions References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Message-ID: <0ad3385b-7864-4c54-9f1e-36e907000a6c@m45g2000hsb.googlegroups.com> On Apr 29, 9:46 am, Julien wrote: > Hi, > > I'm fairly new in Python and I haven't used the regular expressions > enough to be able to achieve what I want. > I'd like to select terms in a string, so I can then do a search in my > database. > > query = ' " some words" with and "without quotes " ' > p = re.compile(magic_regular_expression) $ <--- the magic happens > m = p.match(query) > > I'd like m.groups() to return: > ('some words', 'with', 'and', 'without quotes') > > Is that achievable with a single regular expression, and if so, what > would it be? As other replies mention, there is no single expression since you are doing two things: find all matches and substitute extra spaces within the quoted matches. It can be done with two expressions though: def normquery(text, findterms=re.compile(r'"([^"]+)"|(\S+)').findall, normspace=re.compile(r'\s{2,}').sub): return [normspace(' ', (t[0] or t[1]).strip()) for t in findterms(text)] >>> normquery(' "some words" with and "without quotes " ') >>> ['some words', 'with', 'and', 'without quotes'] HTH, George From castironpi at gmail.com Mon Apr 21 11:12:31 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Mon, 21 Apr 2008 08:12:31 -0700 (PDT) Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> Message-ID: <8f3a768d-0b4c-4077-9aef-a66898882f03@m1g2000pre.googlegroups.com> On Apr 21, 9:28?am, a... at pythoncraft.com (Aahz) wrote: > In article <23bf20ad-9996-4b79-97ef-7930a228c... at t54g2000hsg.googlegroups.com>, > Joseph Turian ? wrote: > > > > >Basically, we're planning on releasing it as open-source, and don't > >want to alienate a large percentage of potential users. > > Datapoint: my company still uses 2.3 and *might* upgrade to 2.4 and > later this year. ?Basically, any company with lots of servers has a good > chance to still be stuck with 2.2/2.3 (we only dropped 2.2 last fall). > -- > Aahz (a... at pythoncraft.com) ? ? ? ? ? <*> ? ? ? ?http://www.pythoncraft.com/ > > Why is this newsgroup different from all other newsgroups? ? Different is a verbally atomic relation. From bignose+hates-spam at benfinney.id.au Sun Apr 6 21:02:34 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Mon, 07 Apr 2008 11:02:34 +1000 Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> Message-ID: <87prt2mq8l.fsf@benfinney.id.au> Aldo Cortesi writes: > I'm afraid that Pry is unashamedly incompatible with any other unit > testing method in existence, including but not limited to doctest, > unittest, nose and py.test. ;) Which makes the deliberate deviations from PEP 8 naming a large black mark against it. > Some day I might experiment with extending Pry to gather and run > doctests and unittests. At this stage, however, I don't believe the > (significant) effort would be worth it. That's very unfortunate. Until it plays better with others, I don't believe the effort of using this package will be worth it. -- \ "If you ever drop your keys into a river of molten lava, let | `\ 'em go, because, man, they're gone." -- Jack Handey | _o__) | Ben Finney From rob.clewley at gmail.com Mon Apr 7 12:30:18 2008 From: rob.clewley at gmail.com (Rob Clewley) Date: Mon, 7 Apr 2008 12:30:18 -0400 Subject: Mathematical Python Library In-Reply-To: References: Message-ID: The closest thing so far is probably going to be a combination of the numpy, scipy, and sympy libraries. The latter is the one with the most functionality for solving equations algebraically, but is also the least mature package at the moment. The first two also provide the basic tools for calculating the nulls of a function (for instance) as numerical approximations, provided you are able to write small scripts to use those tools. -Rob On Mon, Apr 7, 2008 at 12:05 PM, mc wrote: > I'm looking for a library which can do mathematical stuff like > solving equations. Or calculation the nulls of a function and so on. > Does anyone know one? > > Thanks in advance! > -- > http://mail.python.org/mailman/listinfo/python-list > -- Robert H. Clewley, Ph. D. Assistant Professor Department of Mathematics and Statistics Georgia State University 720 COE, 30 Pryor St Atlanta, GA 30303, USA tel: 404-413-6420 fax: 404-651-2246 http://www.mathstat.gsu.edu/~matrhc http://brainsbehavior.gsu.edu/ From robert.kern at gmail.com Fri Apr 4 19:29:33 2008 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 04 Apr 2008 18:29:33 -0500 Subject: Importing a 3rd Party windows DLL for use within th Python In-Reply-To: <92513305-836d-4c85-aeb8-3e3d6571ed92@1g2000prg.googlegroups.com> References: <92513305-836d-4c85-aeb8-3e3d6571ed92@1g2000prg.googlegroups.com> Message-ID: lee.walczak at gmail.com wrote: > Hi, > > I have recently started learing how to code/script in Python which I > am realy enjoying. I am new to this game as my background is RF/HW > design engineer so coding is not my first skillset , so please bare > with me! > > I am a little lost with how to procede on this problem. I need to > write a python script enabling me to comunnicate routines to a pico > ADC212 oscilloscope. I have been provided with a windows DLL & a > header filefrom the manufacturer. > Is it possible for someone to provide the information on the steps > necessary to access this DLL and treat it like any other pyd library? > Maybe there is already a tutorial available for performing this task? > Is this task straight forward? It depends on how complicated the library is. For a first stab, I recommend using ctypes. ctypes lets you load the DLL and call its functions in pure Python without having to write an extension module (pyd) first. ctypes comes with Python 2.5 already; if you have Python 2.4, you can install it separately. http://python.net/crew/theller/ctypes/ You may eventually want to write an extension module. Here is the tutorial: http://docs.python.org/ext/ext.html There are a couple of tools to make this task easier. I happen to like Cython for things like this: http://cython.org/ One large benefit of using ctypes instead of building an extension is that you do not have to compile anything. When wrapping binary-only DLLs on Windows, compiling and linking correctly are often the largest hurdles. -- 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 From malkarouri at gmail.com Thu Apr 24 08:28:12 2008 From: malkarouri at gmail.com (malkarouri) Date: Thu, 24 Apr 2008 05:28:12 -0700 (PDT) Subject: function that accepts any amount of arguments? References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> <4810724a$0$23390$426a74cc@news.free.fr> Message-ID: <63ac69bf-9f6d-42bd-8e6e-5b3b17ec7c69@z72g2000hsb.googlegroups.com> On Apr 24, 12:43?pm, Bruno Desthuilliers wrote: [...] > Not quite sure what's the best thing to do in the second case - raise a > ValueError if args is empty, or silently return 0.0 - but I'd tend to > choose the first solution (Python's Zen, verses 9-11). What's wrong with raising ZeroDivisionError (not stopping the exception in the first place)? k From webograph at eml.cc Sun Apr 27 08:38:45 2008 From: webograph at eml.cc (webograph) Date: Sun, 27 Apr 2008 14:38:45 +0200 Subject: Why can't timedeltas be divided? In-Reply-To: References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> <48142747$0$20906$9b622d9e@news.freenet.de> Message-ID: <481473D5.2060605@eml.cc> On 2008-04-27 14:18, Jon Ribbens wrote: > Yes, that's where it was decided that the datetime module was fine > that way it is and must not be changed. could you give me some pointers to that discussion? i found some discussion about interpretation as intervals [1], casting numbers to intervals [2] and vice versa (plus discussion of connection to unix timestamps) [3], and arithmetics of time/datetime and timedelta [4], on which i agree that those are problematic (some of those also touch the problem of time zones). nevertheless, i fail to see such problems when dividing timedeltas -- after all, `delta2 / 5 == delta1` works, so why should not `delta2 / delta1 == 5`? regards webograph [1] http://www.mail-archive.com/python-dev at python.org/msg21629.html [2] http://mail.python.org/pipermail/python-dev/2002-March/020604.html [3] http://www.mailinglistarchive.com/python-dev at python.org/msg12596.html [4] http://bugs.python.org/issue1118748 From gslindstrom at gmail.com Wed Apr 9 08:08:37 2008 From: gslindstrom at gmail.com (Greg Lindstrom) Date: Wed, 9 Apr 2008 07:08:37 -0500 Subject: Very good Python Book. Free download : Beginning Python: From Novice to Professional Message-ID: > From: hassan nikbakhsh > Subject: Very good Python Book. Free download : Beginning Python: From > Novice to Professional > can i have a free bownload of this book > many thanks > Yes, it's a very good book. Magnus Lie Hetland spent a lot of time putting the book together; why not *buy* it (~$29.00 on Amazon) to help support the effort? It's not that much and a great way to say "thanks". --greg -------------- next part -------------- An HTML attachment was scrubbed... URL: From gagsl-py2 at yahoo.com.ar Fri Apr 11 01:27:55 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 11 Apr 2008 02:27:55 -0300 Subject: Cannot understand the detailedly the following code References: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> <10a83944-b17a-4c3f-992b-1754c0a5e9b1@s33g2000pri.googlegroups.com> Message-ID: En Thu, 10 Apr 2008 23:57:29 -0300, escribi?: > i.e. you give, the graph, the start and end vertices as inputs and you > get the output as a listing of all the paths. This is where I got to. > It would be very nice if you could kindly hint on how to proceed > further. Thank you so much for your time! If you want to understand how recursion works, or how you can actually construct a recursive function step by step, see this excellent post by Neil Cerutti: http://groups.google.com/group/comp.lang.python/msg/9f0b10631fd47886 -- Gabriel Genellina From aboudouvas at panafonet.gr Mon Apr 14 16:10:44 2008 From: aboudouvas at panafonet.gr (king kikapu) Date: Mon, 14 Apr 2008 13:10:44 -0700 (PDT) Subject: Python GUI programming and boa or better ? References: Message-ID: On 14 ???, 16:20, bvidinli wrote: > I program in python for about 2-3 monthos. > I just started/tested gui programming with many tools. > i tested boa last, it is the closest tool to delphi in tui tools that i used. > > I managed to play with it a bit. > > If you have any other tool which you know better than Boa Constructor, > please write in here. > > Any other suggestion about python GUI programming is welcome. > thanks. > > -- > ?.Bahattin Vidinli > Elk-Elektronik M?h. > ------------------- > iletisim bilgileri (Tercih sirasina gore): > skype: bvidinli (sesli gorusme icin,www.skype.com) > msn: bvidi... at iyibirisi.com > yahoo: bvidinli > > +90.532.7990607 > +90.505.5667711 Use PyQt. It ha some very nice goodies (Qt Designer and the like). From nagle at animats.com Wed Apr 2 12:01:15 2008 From: nagle at animats.com (John Nagle) Date: Wed, 02 Apr 2008 09:01:15 -0700 Subject: developing web spider In-Reply-To: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> References: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> Message-ID: <47f3ab52$0$36346$742ec2ed@news.sonic.net> abeen wrote: > Hello, > > I would want to know which could be the best programming language for > developing web spider. > More information about the spider, much better,, As someone who actually runs a Python based web spider in production, I should comment. You need a very robust parser to parse real world HTML. Even the stock version of BeautifulSoup isn't good enough. We have a modified version of BeautifulSoup, plus other library patches, just to keep the parser from blowing up or swallowing the entire page into a malformed comment or tag. Browsers are incredibly forgiving in this regard. "urllib" needs extra robustness, too. The stock timeout mechanism isn't good enough. Some sites do weird things, like open TCP connections for HTTP but not send anything. Python is on the slow side for this. Python is about 60x slower than C, and for this application, you definitely see that. A Python based spider will go compute bound for seconds per page on big pages. The C-based parsers for XML/HTML aren't robust enough for this application. And then there's the Global Interpreter Lock; a multicore CPU won't help a multithreaded compute-bound process. I'd recommend using Java or C# for new work in this area if you're doing this in volume. Otherwise, you'll need to buy many, many extra racks of servers. In practice, the big spiders are in C or C++. > http://www.immavista.com Lose the ad link. John Nagle From mcaloney at gmail.com Wed Apr 16 10:00:26 2008 From: mcaloney at gmail.com (Chris McAloney) Date: Wed, 16 Apr 2008 10:00:26 -0400 Subject: is file open in system ? - other than lsof In-Reply-To: References: Message-ID: On 16-Apr-08, at 9:20 AM, A.T.Hofkamp wrote: > On 2008-04-16, bvidinli wrote: >> is there a way to find out if file open in system ? - >> please write if you know a way other than lsof. because lsof if >> slow for me. >> i need a faster way. >> i deal with thousands of files... so, i need a faster / python way >> for this. >> thanks. > > This is not a Python question but an OS question. > (Python is not going to deliver what the OS doesn't provide). > > Please first find an alternative way at OS level (ie ask this > question at an > appropiate OS news group). Once you have found that, you can think > about Python > support for that alternative. I agree with Albert that this is very operating-system specific. Since you mentioned 'lsof', I'll assume that you are at least using a Unix variant, meaning that the fcntl module will be available to you, so you can check if the file is already locked. Beyond that, I think more information on your application would be necessary before we could give you a solid answer. Do you only need to know if the file is open, or do you want only the files that are open for writing? If you only care about the files that are open for writing, then checking for a write-lock with fcntl will probably do the trick. Are you planning to check all of the "thousands of files" individually to determine if they're open? If so, I think it's unlikely that doing this from Python will actually be faster than a single 'lsof' call. If you're on Linux, you might also want to have a look at the /proc directory tree ("man proc"), as this is where lsof gets its information from on Linux machines. Chris From jeffober at gmail.com Thu Apr 3 08:59:33 2008 From: jeffober at gmail.com (Jeff) Date: Thu, 3 Apr 2008 05:59:33 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> <4b7337a4-beda-4984-91f5-6efda6fb390d@r9g2000prd.googlegroups.com> Message-ID: On Apr 3, 8:19?am, George Sakkis wrote: > On Apr 3, 8:03 am, Jeff wrote: > > > def foo(sample, strings): > > ? ? ? ? for s in strings: > > ? ? ? ? ? ? ? ? if sample in s: > > ? ? ? ? ? ? ? ? ? ? ? ? return True > > ? ? ? ? return False > > > This was an order of magnitude faster for me than using str.find or > > str.index. ?That was finding rare words in the entire word-list (w/ > > duplicates) of War and Peace. > > If you test against the same substrings over and over again, an > alternative would be to build a regular expression: > > import re > search = re.compile('|'.join(re.escape(x) > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?for x in substrings)).search > p = search(somestring) > if p is not None: > ? print 'Found', p.group() > > George That would be an enormous regular expression and eat a lot of memory. But over an enormous number of substrings, it would be O(log n), rather than O(n). From Johannes.Nix at gmx.net Sun Apr 27 15:25:53 2008 From: Johannes.Nix at gmx.net (Johannes Nix) Date: Sun, 27 Apr 2008 12:25:53 -0700 (PDT) Subject: Chapter on real-time signal processing using numerical Python Message-ID: Hi, this might be of interest for people who are look for practical information on doing real-time signal processing, possibly using multiple CPUs, and wonder whether it's possible to use Python for audio-type worst case latencies (around 25 ms). I've done that in my PhD work, both with real-time requirements on dual-CPU 64 bit platforms, and with very complex algorithms running on multicomputers. What I found is that numerical Python is a great environment for such tasks. I've used it as well for massively parallel algorithms (particle filters) for simulations of auditory scene analysis. What is a very special advantage is that if you get faster hardware, you can simply copy your algorithms to a new system and compile - even if it has a different CPU! I've documented the approach in my PhD thesis, in Appendix A, starting with some thoughts on developments in signal processing in the last years. This piece is available online. Title and abstract of that chapter read as follows: -------------------------------------------------------------- A real-time, script-based, multiprocessing Solution for experimental Development of Signal Processing Algorithms Evaluation of audio signal processing algorithms on real-time platforms has unique advantages. However, such environments also used to have the disadvantage of requiring expensive hardware, and tedious work to set them up, while providing only a short useful life. This report proposes to exploit advances in hardware and software development by integrating real-time processing with script-based explorative development and use of multiprocessing hardware. The concept was implemented based on standard hardware and open source software, and its realization and characteristics are presented here. Applications of the system for algorithm development and evaluation are described briefly. -------------------------------------------------------------- Here is the download link for several paper formats: http://medi.uni-oldenburg.de/members/jnix/index.html#thesisdownload Alternatively, for ISO A4 paper, use one of these two URLs: http://medi.uni-oldenburg.de/download/paper/Nix,Johannes-PhDthesis-2005-ISO-A4-format.pdf http://docserver.bis.uni-oldenburg.de/publikationen/dissertation/2006/nixloc05/nixloc05.html (for that paper size, this are the PDF pages 155 - 163) If you want to cite the chapter, e.g. when doing advocacy for scientific computing using SciPy, please do this as follows: Nix, Johannes (2005), "A real-time, script-based, multiprocessing Solution for experimental Development of Signal Processing Algorithms", in: Localization and Separation of Concurrent Talkers Based on Principles of Auditory Scene Analysis and Multi-Dimensional Statistical Methods, Appendix A, Ph.D. thesis, Universit?t Oldenburg, Germany. Also, I am currently looking for interesting further work opportunities or contracts in the domain of scientific computing and statistical estimation. If you know some interesting position, don't hesistate to contact me. Kind regards, Johannes -- Dr. Johannes Nix Energy & Meteo Systems GmbH Research & Development of windpower forecasts Bremen, Germany Phone: + 49 421 8963914 From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 30 07:05:02 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 30 Apr 2008 13:05:02 +0200 Subject: best way to host a membership site In-Reply-To: <53034dcc-7346-4f71-889c-3278c9e813ec@w1g2000prd.googlegroups.com> References: <53034dcc-7346-4f71-889c-3278c9e813ec@w1g2000prd.googlegroups.com> Message-ID: <48185252$0$32098$426a74cc@news.free.fr> Magdoll a ?crit : > Hi, > I know this is potentially off-topic, but because python is the > language I'm most comfortable with and I've previously had experiences > with plone, I'd as much advice as possible on this. > > I want to host a site where people can register to become a user. They > should be able to maintain their own "showroom", where they can show > blog entries (maybe just by linking to their own blogs on some other > blog/album-hosting site like Xanga), put up pictures (again, I'm not > thinking about actually hosting these data, since there are already > plenty of places to put your pictures and blogs). The most important > thing is they will be able to build up a "profile" where I can store > in a DB. The profile will include membership information - for now, > think of it as "member X owns item A,B,C and gave comments on A such > and such, also member X is a male white caucasian between his 20-30 > who likes outdoors". Eventually, I want this to be a simple social- > networking site where people can share a very particular hobby (I'm > doing it for comsetics and for a very targeted group that are active > bloggers, so they'll be somewhat web-salient) and the backend can > collect enough data (while maintaining privacy) to build up a > recommendation system similar to Netflix's movie recommendations, or > Match.com if you will. You may want to have a look at o'reilly's "Programming Collective Intelligence" http://www.oreilly.com/catalog/9780596529321/ The code examples are alas very very poorly coded, but at least they are in Python. > I want to know that given I know python best and I abhor C#/ASP, what > is the best thing to use. A friend recommended Ruby on Rails - not to > instigate war here, but I'd welcome comments on that (I don't know > Ruby, but I'll learn). Ruby by itself is a nice language, but really on the same "niche" as Python. Rails is a nice framework too, but there are real problems wrt/ perfs and scalability - nothing that can't be solved given enough efforts and hardware, but depending on the expected load, this might be something you want to take into account (or just don't care). > I've used PLONE before, but back then I > remembered the site ran incredably slow (or it could just be the > server), and there were issues with upgrades. Plone is indeed a 80000-pounds behemoth, and (from working experience) is certainly one of the worst possible solution for anything else than pure content management. > I want to minimze time > on trying to learn how to write an interface for users to register and > manage their own space. Also I want an infrastructure that's not too > rigid so if in the future I want to add more apps it's not to hard. > > I've also heard about django, but not enough to know how far it'll get > me. I'm open to all sorts of suggestions. Thanks! We're about to start a couple somewhat similar projects here, and while our chief engineer is a definitive Ruby/Rails addict, we finally settled on Django. While it's not my own personal favorite Python MVC framework, it's still a very good one, and probably the more mature and stable so far. wrt/ the "add more apps in the future" concern, you may want to read this: http://www.b-list.org/weblog/2007/nov/29/django-blog/ HTH From arnodel at googlemail.com Sun Apr 13 16:06:48 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 13 Apr 2008 13:06:48 -0700 (PDT) Subject: Interesting math problem References: <3a34caaf-a279-4e86-837d-42efa4d80129@d4g2000prg.googlegroups.com> <3fe449cb-4060-4bb6-9605-1e1778b707f8@p39g2000prm.googlegroups.com> Message-ID: <16bb44e0-b5a0-446a-a541-d4930df07ae9@i36g2000prf.googlegroups.com> On Apr 13, 5:35?pm, Ivan Illarionov wrote: > On Mar 19, 2:17 pm, "BJ?rn Lindqvist" wrote: > > > > > On Mon, Mar 17, 2008 at 11:57 PM, Arnaud Delobelle > > > wrote: > > > ?> def make_slope(distance, parts): > > > ?> ? ? step = distance / float(parts) > > > ?> ? ? intstep = int(step) > > > ?> ? ? floatstep = step - intstep > > > > ?> ? ? steps = [] > > > ?> ? ? acc = 0.0 > > > ?> ? ? for i in range(parts): > > > ?> ? ? ? ? acc += floatstep > > > ?> ? ? ? ? step = intstep > > > ?> ? ? ? ? if acc > 0.999: > > > ?> ? ? ? ? ? ? step += 1 > > > ?> ? ? ? ? ? ? acc -= 1.0 > > > ?> ? ? ? ? steps.append(step) > > > ?> ? ? return steps > > > > ?OK then, using list comprehensions. ?It is more succint, is it easier > > > ?to read? > > > > ?def slope(dist, parts): > > > ? ? return [(i+1)*dist/parts - i*dist/parts for i in xrange(parts)] > > > Congratulations! You Won! Jeff Schwab's recursive approach is also > > cool but this is the most interesting abuse of integer division I have > > seen. I don't think any of the variants are readable at a first > > glance, but with a comment it should be ok. > > > -- > > mvh Bj?rn > > I really want to revive this discussion. Arnaud's approach is > definetly cool, but it turns out that in real-world situations it > doesn't work as succint as here. > > Try to use it to draw a simple non-anitaliased line in a standrad > python array or buffer object. Suppose we have an array of unsigned > bytes called `buf` where each line takes `pitch` bytes. That's what I > got while trying to take advantage of this approach. No advantage at > all. And what about ability to port the code to C for speed? > > def draw_line(buf, pitch, x, y, dx, dy): > ? ? if dx == dy == 0: > ? ? ? ? buf[y * pitch + x] = 0 > ? ? ? ? return > ? ? xdir, ydir = 1, 1 > > ? ? if dx < 0: > ? ? ? ? xdir = -1 > ? ? ? ? dx = abs(dx) > ? ? if dy < 0: > ? ? ? ? ydir = -1 > ? ? ? ? dy = abs(dy) > > ? ? if dy < dx: > ? ? ? ? steps = ((i+1) * dx / dy - i * dx / dy for i in xrange(dy)) > ? ? ? ? for step in steps: > ? ? ? ? ? ? start = y * pitch + x > ? ? ? ? ? ? if xdir > 0: > ? ? ? ? ? ? ? ? buf[start : start + step] = array('B', [0] * step) > ? ? ? ? ? ? else: > ? ? ? ? ? ? ? ? buf[start - step : start] = array('B', [0] * step) > ? ? ? ? ? ? x += step * xdir > ? ? ? ? ? ? y += ydir > ? ? else: > ? ? ? ? steps = ((i+1) * dy / dx - i * dy / dx for i in xrange(dx)) > ? ? ? ? for step in steps: > ? ? ? ? ? ? start = y * pitch + x > ? ? ? ? ? ? if ydir > 0: > ? ? ? ? ? ? ? ? for i in range(start, start + pitch * step, pitch): > ? ? ? ? ? ? ? ? ? ? buf[i] = 0 > ? ? ? ? ? ? else: > ? ? ? ? ? ? ? ? for i in range(start, start - pitch * step, -pitch): > ? ? ? ? ? ? ? ? ? ? buf[i] = 0 > ? ? ? ? ? ? x += xdir > ? ? ? ? ? ? y += step * ydir > > Please, tell me that I'm wrong and it's really possible to draw lines, > do scan-conversion and so on with such a cool succint constructs! > > -- > Ivan I don't think my answer is suitable for drawing a line the way you are doing it. FWIW, this is how I would go about it (not tested): def draw_rectangle(buf, pitch, x, y, w, h): # Make a mask for w and apply it across h lines def draw_line(buf, pitch, x, y, w, h): # w and h can't be < 0 if w < h: limits = ((i, i*h/w) for i in xrange(1, w+1)) else: limits = ((i*w/h, i) for i in xrange(1, h+1)) dx0, dy0 = 0, 0 for dx, dy in limits: draw_rectangle(x+dx0, y+dy0, dx-dx0, dy-dy0) dx0, dy0 = dx, dy The positive thing is that it is trivial to extend draw_line so that it accepts a thickness parameter as well. -- Arnaud From bhmckendrick at gmail.com Sat Apr 26 11:28:38 2008 From: bhmckendrick at gmail.com (animalMutha) Date: Sat, 26 Apr 2008 08:28:38 -0700 (PDT) Subject: Setting an attribute without calling __setattr__() References: Message-ID: > Consider reading the *second* paragraph about __setattr__ in section > 3.4.2 of the Python Reference Manual. if you are simply going to answer rtfm - might as well kept it to yourself. From stefan_ml at behnel.de Fri Apr 11 13:33:11 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 11 Apr 2008 19:33:11 +0200 Subject: [lxml-dev] CDATA and lxml In-Reply-To: <47FF368B.4030708@behnel.de> References: <5ebe3201-80a6-45ba-8b88-e8ece6883efa@w8g2000prd.googlegroups.com> <47FF368B.4030708@behnel.de> Message-ID: <47FFA0D7.1030901@behnel.de> Hi again, Stefan Behnel wrote: > Silfheed wrote: >> So first off I know that CDATA is generally hated and just shouldn't >> be done, but I'm simply required to parse it and spit it back out. >> Parsing is pretty easy with lxml, but it's the spitting back out >> that's giving me issues. The fact that lxml strips all the CDATA >> stuff off isnt really a big issue either, so long as I can create >> CDATA blocks later with <>&'s showing up instead of <>& . >> I've scoured through the lxml docs, but probably not hard enough, so >> anyone know the page I'm looking for or have a quick how to? > > There's nothing in the docs because lxml doesn't allow you to create CDATA > sections. You're not the first one asking that, but so far, no one really had > a take on this. So I gave it a try, then. In lxml 2.1, you will be able to do this: >>> root = Element("root") >>> root.text = CDATA('test') >>> tostring(root)) '' This does not work for .tail content, only for .text content (no technical reason, I just don't see why that should be enabled). There's also a parser option "strip_cdata" now that allows you to leave CDATA sections in the tree. However, they will *not* behave any different than normal text, so you can't even see at the API level that you are dealing with CDATA. If you want to be really, really sure, you can always do this: >>> root.text = CDATA(root.text) Hope that helps, Stefan From roy at panix.com Tue Apr 29 20:51:27 2008 From: roy at panix.com (Roy Smith) Date: Tue, 29 Apr 2008 20:51:27 -0400 Subject: list.reverse() References: <4816e26a$0$30938$426a74cc@news.free.fr> <98c4ad4d-3174-40cd-b281-84e318d699d3@24g2000hsh.googlegroups.com> Message-ID: In article <98c4ad4d-3174-40cd-b281-84e318d699d3 at 24g2000hsh.googlegroups.com>, blaine wrote: > Check out this cool little trick I recently learned: > >>> x=range(5) > >>> x.reverse() or x > [4, 3, 2, 1, 0] > > Useful for returning lists that you need to sort or reverse without > wasting that precious extra line :) > > What it does: x.reverse() does the reverse and returns None. or is > bitwise, so it sees that 'None' is not 'True' and then continues to > process the next operand, x. x or'd with None will always be x (and x > has just been changed by the reverse()). So you get the new value of > x :) Please don't do that in any code I have to read and understand. Cool little tricks have no place in good code. >>> x = range(5) >>> x.reverse() >>> x [4, 3, 2, 1, 0] does the same thing, and it a lot easier to understand. I buy my newlines in the big box at Costo, so I don't mind using a few extra ones here or there. From jzshao1 at gmail.com Tue Apr 15 22:24:01 2008 From: jzshao1 at gmail.com (Jonathan Shao) Date: Tue, 15 Apr 2008 22:24:01 -0400 Subject: Interesting timing issue I noticed Message-ID: I've written up a stripped down version of the code. I apologize for the bad coding; I am in a bit of a hurry. import random import sys import time sizeX = 320 sizeY = 240 borderX = 20 borderY = 20 # generates a zero matrix def generate_zero(): matrix = [[0 for y in range(sizeY)] for x in range(sizeX)] return matrix # fills zero matrix def fill_matrix(in_mat): mat = in_mat for x in range(sizeX): for y in range(sizeY): mat[x][y] = random.randint(1, 100) return mat ###################################################################### # COMPUTES ONLY A PART OF THE ARRAY def back_diff_one(back_array, fore_array, box): diff_array = generate_zero() start = time.time() for x in range(sizeX): for y in range(borderY): diff_array[x][y] = back_array[x][y] - fore_array[x][y] for y in range((sizeY - borderY), sizeY): diff_array[x][y] = back_array[x][y] - fore_array[x][y] for y in range(borderY, (sizeY - borderY)): for x in range(borderX): diff_array[x][y] = back_array[x][y] - fore_array[x][y] for x in range((sizeX - borderX), sizeX): diff_array[x][y] = back_array[x][y] - fore_array[x][y] # tracks object if (len(box) != 0): for x in range(box[0], box[2]): for y in range(box[1], box[3]): diff_array[x][y] = back_array[x][y] - fore_array[x][y] print "time one inside = " + str(time.time() - start) return diff_array ###################################################################### # COMPUTES EVERY ELEMENT IN THE ARRAY def back_diff_two(back_array, fore_array): diff_array = generate_zero() start = time.time() for y in range(sizeY): for x in range(sizeX): diff_array[x][y] = back_array[x][y] - fore_array[x][y] end = time.time() print "time two inside = " + str(end - start) return diff_array ###################################################################### # CODE TO TEST BOTH FUNCTIONS back = fill_matrix(generate_zero()) fore = fill_matrix(generate_zero()) box = [20, 20, 268, 240] start1 = time.time() diff1 = back_diff_one(back, fore, box) print "time one outside = " + str(time.time() - start1) start2 = time.time() diff2 = back_diff_two(back, fore) print "time one outside = " + str(time.time() - start2) Here are some results from several test runs: time one inside = 0.0780000686646 time one outside = 0.125 time two inside = 0.0780000686646 time two outside = 0.141000032425 >>> ================================ RESTART ================================ >>> time one inside = 0.0629999637604 time one outside = 0.125 time two inside = 0.0789999961853 time two outside = 0.125 >>> ================================ RESTART ================================ >>> time one inside = 0.0620000362396 time one outside = 0.139999866486 time two inside = 0.0780000686646 time two outside = 0.125 >>> ================================ RESTART ================================ >>> time one inside = 0.0780000686646 time one outside = 0.172000169754 time two inside = 0.0789999961853 time two outside = 0.125 >>> ================================ RESTART ================================ >>> time one inside = 0.0780000686646 time one outside = 0.125 time two inside = 0.0780000686646 time two outside = 0.125 >>> ================================ RESTART ================================ >>> time one inside = 0.0620000362396 time one outside = 0.155999898911 time two inside = 0.0780000686646 time two outside = 0.125 >>> ================================ RESTART ================================ >>> time one inside = 0.077999830246 time one outside = 0.125 time two inside = 0.077999830246 time two outside = 0.125 >>> ================================ RESTART ================================ >>> time one inside = 0.0780000686646 time one outside = 0.171000003815 time two inside = 0.077999830246 time two outside = 0.125 >>> ================================ RESTART ================================ >>> time one inside = 0.0629999637604 time one outside = 0.18799996376 time two inside = 0.0620000362396 time two outside = 0.125 Why is a large percentage of the time, the execution time for the (ostensibly smaller) first loop is actually equal to or LARGER than the second? -- "Perhaps we all give the best of our hearts uncritically, to those who hardly think about us in return." ~ T.H.White -------------- next part -------------- An HTML attachment was scrubbed... URL: From p.newbie at yahoo.com Wed Apr 16 03:00:22 2008 From: p.newbie at yahoo.com (python newbie) Date: Wed, 16 Apr 2008 00:00:22 -0700 (PDT) Subject: Mailing list question Message-ID: <397280.11586.qm@web45815.mail.sp1.yahoo.com> Hello, Just curious; can I post a basic programming question to this mailing list? Thanks in advance. Pete --------------------------------- Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. -------------- next part -------------- An HTML attachment was scrubbed... URL: From paul at boddie.org.uk Wed Apr 23 07:43:56 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Wed, 23 Apr 2008 04:43:56 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> Message-ID: <56ebf54a-3a60-433f-b073-81963d9f1007@l64g2000hse.googlegroups.com> On 23 Apr, 11:12, Mark Wooding wrote: > Gabriel Genellina wrote: > > Because Python doesn't follow the "boxed variables" model. > > Be careful here. `Boxed types' or `boxed objects' is a technical term > essentially meaning `heap-allocated objects, probably with reference > semantics', which Python most definitely does use -- so this almost > means the opposite of what you're talking about. I think Gabriel meant "variables as boxes" - the classic description of variables in "old school" programming languages, which is in contrast to the "variables as labels" model used by Python. [...] > This won't hold in Python, since assignments (which `++' > assuredly ought to be) aren't allowed as subexpressions anyway. This syntactic note is probably one of the biggest arguments against it, yes, since many of the benefits it has in C would be absent in Python. [...] > That's not quite true, in fact: it might be useful to define other kinds > of incrementing for specialist types, but I can't think of any obvious > examples off the top of my head. Well, as I recall, data structures in C++ (such as iterators) often use the pre/post-increment/decrement operators as shorthand, arguably reflecting the "pointer arithmetic" heritage of the C family of languages. It would be pure sugar in Python, though. Paul From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 4 07:26:00 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 04 Apr 2008 13:26:00 +0200 Subject: Is there an official way to add methods to an instance? In-Reply-To: <7xve2yas87.fsf@ruckus.brouhaha.com> References: <7xve2yas87.fsf@ruckus.brouhaha.com> Message-ID: <47f61041$0$27969$426a34cc@news.free.fr> Paul Rubin a ?crit : > Brian Vanderburg II writes: >> I've checked out some ways to get this to work. I want to be able to >> add a new function to an instance of an object. > > Ugh. Avoid that if you can. Why so ? OO is about objects, not classes, and adding methods on a per-object basis is perfectly legitimate. > But see: > > http://en.wikipedia.org/wiki/Monkey_patch Adding methods on a per-object basis is not monkey patching (as defined in the above article and as usually understood here) and doesn't address the same class (no pun intended) of problems. From manthra.mohan at gmail.com Fri Apr 18 11:48:36 2008 From: manthra.mohan at gmail.com (Krishna) Date: Fri, 18 Apr 2008 08:48:36 -0700 (PDT) Subject: Delete rows using xlrd? Message-ID: <8bc243c7-2980-4201-9372-94ca8a49d221@x19g2000prg.googlegroups.com> I want to delete some rows (by creating a loop may be) using xlrd. Is this possible, if not how do I do that with python? Please help Thanks Krishna From tjreedy at udel.edu Wed Apr 16 23:06:25 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 16 Apr 2008 23:06:25 -0400 Subject: Default parameter for a method References: <806788d2-67b7-456b-bd1e-08c50cbf0f7b@8g2000hsu.googlegroups.com> <48065d11$0$36390$742ec2ed@news.sonic.net> Message-ID: "John Nagle" wrote in message news:48065d11$0$36390$742ec2ed at news.sonic.net... | s0suk3 at gmail.com wrote: | > I wanted to know if there's any way to create a method that takes a | > default parameter, and that parameter's default value is the return | > value of another method of the same class. For example: | > | ... | | > | > def meth2(self, arg=meth1()): | | Not good. If the default value of an argument is mutable, there | are wierd effects, because the default value is bound once when the | class is created, then shared between all later uses. This is almost | never what was wanted or intended, and it's a common source of subtle | bugs. | | In general, default values should be immutable constants only. Then one would have to restrict default args to immutable builtins. There is no way to determine (without reading code) whether instances of a user-defined class are mutable or not. tjr From miki.tebeka at gmail.com Tue Apr 22 15:57:18 2008 From: miki.tebeka at gmail.com (Miki) Date: Tue, 22 Apr 2008 12:57:18 -0700 (PDT) Subject: Choosing log file destination in logging configuration file References: <3e85cd72-304e-4e17-8ca9-b0688a59fc14@t54g2000hsg.googlegroups.com> Message-ID: Hello, > So far so good. In the relevant applications, the code looks something > like this: > logging.config.fileConfig('log.ini') > logger = logging.getLogger('log.regular') logger = > logging.getLogger('log.daemonic') > .. and start logging. > > The thorn in my side is that after the fileConfig call, BOTH handlers > are instantiated, meaning both types of files are created for every > component, even if I don't need it: component.log (for the rotating > handler) and compenent.date.log (for the regular file handler). > > ..So finally, here's my question: > Apart from splitting the logging configuration into two separate > files, is there any way to NOT create the file until you actually use > it? You can generate the .ini file on the fly and then load it: >>> log_ini = gen_log_ini(type) # type is either "deamon" or "regular" >>> atexit.register(lambda: remove(log_ini)) >>> logging.config.fileConfig(log_ini) HTH, -- Miki http://pythonwise.blogspot.com From fiacre.patrick at gmail.com Sun Apr 20 02:54:35 2008 From: fiacre.patrick at gmail.com (Andrew Lee) Date: Sun, 20 Apr 2008 02:54:35 -0400 Subject: Checking if a text file is blank In-Reply-To: References: Message-ID: <480ae855$0$15157$607ed4bc@cv.net> elnoire at gmail.com wrote: > Greetings! > > I've just started learning python, so this is probably one of those > obvious questions newbies ask. > > Is there any way in python to check if a text file is blank? > > What I've tried to do so far is: > > f = file("friends.txt", "w") > if f.read() is True: > """do stuff""" > else: > """do other stuff""" > f.close() > > What I *mean* to do in the second line is to check if the text file is > not-blank. But apparently that's not the way to do it. > > Could someone set me straight please? Along with the other posts ... consider using the lstat command to get information about the file. import os print os.lstat("friends.txt")[6] gives the size in bytes of friends.txt or throws an OSError if friends.txt does not exist. lstat is portable, it defaults to stat on Windows. From reacocard at gmail.com Sun Apr 6 00:54:01 2008 From: reacocard at gmail.com (reacocard) Date: Sat, 5 Apr 2008 21:54:01 -0700 (PDT) Subject: httplib VERY slow References: <8486e357-1cab-4b30-a060-1750068929ac@1g2000prg.googlegroups.com> Message-ID: On Apr 5, 8:50?pm, reacocard wrote: > Hi, I'm writing a download manager in python, and httplib is being > very slow when pulling from localhost or even other servers on the > local network. I'm getting about 10MB in 14s with httplib, while wget > hits 80MB in less than 3s. You can find the code I made to benchmark > this here:http://pastebin.ca/973486(noslor is mapped to my IP in / > etc/hosts) > > Does anyone have any idea what might be causing this, and how I can > fix it? I'm using python2.5 under Ubuntu Linux 8.04 with apache2 for > the webserver. > > Thanks in advance. Upon further investigation, the slowness appears to be related to this bug report: http://bugs.python.org/issue508157 Applying the fix given in the bug report speeds up httplib immensely. So now the question becomes, what is the best way to implement this? Should I go ahead and subclass most of httplib, or is there an easier way? From mnordhoff at mattnordhoff.com Tue Apr 22 20:33:56 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Wed, 23 Apr 2008 00:33:56 +0000 Subject: Lists: why is this behavior different for index and slice assignments? In-Reply-To: <480e7f61$0$25046$607ed4bc@cv.net> References: <480d435b$0$11643$607ed4bc@cv.net> <480e7f61$0$25046$607ed4bc@cv.net> Message-ID: <480E83F4.6040500@mattnordhoff.com> John Salerno wrote: >> replaces the elements in the slice by assigned elements. > > > I don't understand the second part of that sentence. I'm assuming "it" > refers to the list being assigned, "replaces the elements" is > self-evident, but what does "by assigned elements" refer to? It seems > when you assign a list to a list slice, nothing gets replaced, the slice > just gets deleted. >>> x = range(5) >>> x[0:3] = ["a", "b"] >>> x ['a', 'b', 3, 4] Here, '= ["a", "b"]' replaces x[0:3] with ["a", "b"]. When you do '= []', it replaces them with nothing. -- From gagsl-py2 at yahoo.com.ar Tue Apr 1 14:04:55 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 15:04:55 -0300 Subject: manipulating hex values References: <47F26CC3.3060307@u4eatech.com> Message-ID: En Tue, 01 Apr 2008 14:11:31 -0300, Stephen Cattaneo escribi?: > I am relatively new to socket programming. I am attempting to use raw > sockets to spoof my IP address. Don't bother to try... > From what I can tell I will have to > build from the Ethernet layer on up. This is fine, but I am having > some trouble with manipulating my hex values. > > Seems to me that there are two ways to store hex values: > 1. as literal hex - 0x55aa > 2. as a string - "\x55aa" The later is exactly the same string as "Uaa": py> print "\x55aa" Uaa > If I want to convert hex to decimal I can use: > int("\x55aa", 16) # note that plain 0x55aa, instead of "\x55aa", will > raise an exception Have you tried it? py> int("\x55aa", 16) Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 16: 'Uaa' py> int("0x55aa", 16) 21930 > The Question: > If I want to do any kind of calculation I have found its best to just > convert my values to decimal, do the math, then convert back to hex. In > my bellow code I get "decimal" and "hex" are just ways to represent/display integers. You convert from the representation used on the source, to integer, do some math, and convert again to another representation for display/store the result. > """byteList.append(int(value,16)) > ValueError: invalid literal for int()""" > when attempting to run. I do not understand why this exception is > being raised? It is a for loop iterating over a list of hex strings. > Sorry for the long-ish question. Any help or comments would be > appreciated. Use the struct package. -- Gabriel Genellina From ellingt8877 at gmail.com Mon Apr 28 01:44:55 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:44:55 -0700 (PDT) Subject: fsuipc crack Message-ID: fsuipc crack http://crack.cracksofts.com From zillow10 at googlemail.com Wed Apr 2 09:56:44 2008 From: zillow10 at googlemail.com (zillow10 at googlemail.com) Date: Wed, 2 Apr 2008 06:56:44 -0700 (PDT) Subject: developing web spider References: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> <30a89852-4730-490b-8701-b915cb0901ce@q27g2000prf.googlegroups.com> Message-ID: On Apr 2, 2:54 pm, zillo... at googlemail.com wrote: > On Apr 2, 6:37 am, abeen wrote: > > > Hello, > > > I would want to know which could be the best programming language for > > developing web spider. > > More information about the spider, much better,, > > > thanks > > >http://www.imavista.com > > Just saw this while passing by... There's a nice book by Michael > Schrenk (www.schrenk.com) called "Webbots, Spiders and Screen > Scrapers" that teaches scraping and spidering from the ground up using > PHP. Since you said you want more info on spiders, this book might be > a good way for you to acquire concept and implementation hand-in-hand. > He's also developed a nice webbot library in PHP that you can get from > his website. > > Also comes with a nice webbot library (which you can download from > the website anyway). Sorry for the duplicate comment about the webbot library... the perils of cutting and pasting to restructure sentences. :) From bc1891 at googlemail.com Wed Apr 2 16:23:58 2008 From: bc1891 at googlemail.com (bc1891 at googlemail.com) Date: Wed, 2 Apr 2008 13:23:58 -0700 (PDT) Subject: Recursive function won't compile Message-ID: #include #include def RecursiveFact(n): if(n>1): return n*RecursiveFact(n-1) else: return 1 fact = RecursiveFact(31) print fact fact = "End of program" print fact ......but yet it still gives the right answer. How is this possible? From roy at panix.com Sun Apr 13 08:23:22 2008 From: roy at panix.com (Roy Smith) Date: Sun, 13 Apr 2008 08:23:22 -0400 Subject: from __future__ import print References: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> Message-ID: In article , Lie wrote: > I wish py3k > would make it an option whether to treat print as statement or > function though. Arrrgghhhhh! No, don't even go there. If you want optional parens, use Perl :-) From deets at nospam.web.de Wed Apr 16 09:15:08 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 16 Apr 2008 15:15:08 +0200 Subject: Serving binary content (images, etc) using BasteHTTPServer References: <556871d3-1fea-40f2-9cc6-2a4e3a80f968@k10g2000prm.googlegroups.com> Message-ID: <66mcfoF2lat6uU2@mid.uni-berlin.de> MarkCSU at gmail.com wrote: > I'm writing a simple web server in python using the BaseHTTPServer > library. I can serve text content (ie html pages) with ease, but im > running into troubles when i try to serve images. The image gets > corrupted in transit and when I manually download the image from the > website and look at it using a hex editor it appears that the first 60 > (or first 3C in hex if it makes a helps) characters are missing. > > > My code looks like this: > > def do_GET(s): > > # code that determines that yes this is an image > > s.send_response(200) > s.send_header("Content-type", "image/jpeg") > s.end_headers > > fileObj = open("1.jpg","rb") # file is harcoded until > i get images being served correctly > image = fileObj.read() > s.wfile.write(image) Don't you miss a Content-Length header? Diez From deets at nospam.web.de Mon Apr 21 09:53:09 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Mon, 21 Apr 2008 15:53:09 +0200 Subject: how to pass C++ object to another C++ function via Python function References: <1810b155-5598-4f17-a8e9-e4aa848db5de@i36g2000prf.googlegroups.com> Message-ID: <673kj1F2msp6jU1@mid.uni-berlin.de> grbgooglefan wrote: > I am trying to pass a C++ object to Python function. This Python > function then calls another C++ function which then uses this C++ > object to call methods of that object's class. You might consider using a C++-wrapper like SIP, Swig or Boost::Python to do this. If you don't like that, all I can think of would be to return the address of the object as integer, and pass that around. Then in the appropriate C++-call, cast that integer to the object. butt-ugly and -10 style-points though. Diez From skanemupp at yahoo.se Thu Apr 10 08:40:42 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 05:40:42 -0700 (PDT) Subject: questions about Exceptions? References: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> <71cc8c25-f5f9-4f21-a9d8-06780bf97608@f63g2000hsf.googlegroups.com> <9af81b1a-3e02-4406-b9d2-0a9b6f46566b@p39g2000prm.googlegroups.com> <0e586d5d-6799-433f-b8a4-4de5d2a87b61@h1g2000prh.googlegroups.com> <46a79564-4069-46af-b6ab-b38bd9152c2a@d45g2000hsc.googlegroups.com> Message-ID: <6b41831d-7510-49fa-97f5-8034613afa00@w4g2000prd.googlegroups.com> On 10 Apr, 12:38, cokofree... at gmail.com wrote: > > def Calc(): > > global nbr > > try: > > print eval(nbr) > > #a = Label(mygui, text=eval(nbr)) > > #a.place(relx=0.4, rely=0.1, anchor=CENTER) > > except: > > print "Not computable" > > nbr = "" > > > def Erase(): > > global nbr > > nbr = "" > > Seems to me you could be better off passing a parameter and a return > statement of None (or your parameter cleaned) for those functions, > which should work. Given an input, Eval it and then return None. That > way you wouldn't need the Erase... i never really got what u meant by this? From meisnernel73884 at gmail.com Wed Apr 30 06:37:35 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:37:35 -0700 (PDT) Subject: vws crack Message-ID: vws crack http://crack.cracksofts.com From mobile at ibinsa.com Fri Apr 18 17:23:42 2008 From: mobile at ibinsa.com (Gabriel Ibanez) Date: Fri, 18 Apr 2008 23:23:42 +0200 Subject: Upset of spamming ... Message-ID: <002801c8a19a$7a145ed0$0a01a8c0@mobile> Very upset. Really ugly. If anyone have an idea of how stops this thing with python programming I will be glad of contributing. :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg at cosc.canterbury.ac.nz Sun Apr 6 18:37:56 2008 From: greg at cosc.canterbury.ac.nz (greg) Date: Mon, 07 Apr 2008 10:37:56 +1200 Subject: why does socket.makefile require non-blocking mode? In-Reply-To: References: Message-ID: <47F950C4.6010104@cosc.canterbury.ac.nz> Forest wrote: > I guess you mean that since _fileobject.read() calls recv() multiple > times, the second and later calls might block even if select() said the > socket was > readable. The main problem is buffering. The select() may block on the socket even though the file object has data in its buffer waiting to be read. When using select(), you really need to deal with the socket directly, with no buffering in the way. -- Greg From usenet at janc.be Wed Apr 2 14:29:55 2008 From: usenet at janc.be (Jan Claeys) Date: Wed, 02 Apr 2008 18:29:55 GMT Subject: License of Python References: <683e7a60-1967-4c95-b66f-e80a5f4f0116@e6g2000prf.googlegroups.com> <5feb7205-e852-401c-aac2-61ff3d1601ca@i12g2000prf.googlegroups.com> Message-ID: Op Sun, 30 Mar 2008 08:16:39 -0700, schreef iu2: > Due to Competitors... I don't want to expost the language I use If they are clever, they already know that you want to use python by now, after you posted this on a public mailing list / newsgroup... -- JanC From danb_83 at yahoo.com Tue Apr 15 00:08:26 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Mon, 14 Apr 2008 21:08:26 -0700 (PDT) Subject: how to remove \n in the list References: <2ba667ab-6818-47eb-8595-79ed970728f7@q1g2000prf.googlegroups.com> Message-ID: On Apr 14, 10:55 pm, Yves Dorfsman wrote: > Gabriel Genellina wrote: > > En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam > >> l=['5\n', '2\n', '7\n', '3\n', '6\n'] > > >> how to remove \n from the given list > > > l is is very poor name... I'll use lines instead: > > > lines[:] = [line.rstrip('\n') for line in lines] > > When I saw the original message, I immediately thought: > > k = [x.strip() for x in l] > > What is the point of the [:] after lines ? How different is it with or > without it ? It causes the result to be stored in the existing list. >>> a = [0, 1, 2, 3, 4] >>> b = a # "a" and "b" now refer to the same list >>> a = [5, 6, 7] # "a" now refers to a new list >>> a [5, 6, 7] >>> b [0, 1, 2, 3, 4] >>> a = [0, 1, 2, 3, 4] >>> b = a # As before, "a" and "b" refers to the same list >>> a[:] = [5, 6, 7] # This replaces the elements of the list with new ones. # "a" still refers to the same list as "b". >>> a [5, 6, 7] >>> b [5, 6, 7] From nagle at animats.com Thu Apr 3 01:27:00 2008 From: nagle at animats.com (John Nagle) Date: Wed, 02 Apr 2008 22:27:00 -0700 Subject: Rationale for read-only property of co_code In-Reply-To: References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> Message-ID: <47f4682c$0$36371$742ec2ed@news.sonic.net> Dan Upton wrote: >> The thing I've been wondering is why _is_ it read-only? In what >> circumstances having write access to co_code would break the language >> or do some other nasty stuff? >> >> Jo?o Neves > > I can't speak to Python's implementation in particular, but > self-modifying code in general is unpleasant. Yes. Self-modifying code has a long and painful history. It's sometimes useful to generate and execute code dynamically, but that's different than modifying running code. Python already has "eval", plus the ability to compile and include new code at run time, so the useful facilities are already working. John Nagle From http Thu Apr 24 14:34:20 2008 From: http (Paul Rubin) Date: 24 Apr 2008 11:34:20 -0700 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> <480fa6e3$0$34491$742ec2ed@news.sonic.net> Message-ID: <7xzlrj14r7.fsf@ruckus.brouhaha.com> Paul Boddie writes: > simple Python-only modules, all you'd really need to do to prove the > concept is to develop the client-side Windows software (eg. apt-get > for Windows) which downloads package lists, verifies signatures, and > works out where to put the package contents. ... I thought the Windows "solution" to this was Authenticode, which is a scheme for signing executables against certificates similar to those used on SSL web sites. Of course there's been at least one notorious forgery, but typical Linux distro repositories are probably not all that secure either. In the case of a pure Python program like Beautiful Soup, I certainly think any installation needing running code should be done by distutils included in the Python distro. From john106henry at hotmail.com Mon Apr 28 15:41:16 2008 From: john106henry at hotmail.com (John Henry) Date: Mon, 28 Apr 2008 12:41:16 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> Message-ID: <473deef3-9acb-45dd-a7ca-47b0081bd28c@i36g2000prf.googlegroups.com> On Apr 27, 12:23 pm, Fred Pacquier wrote: > > Do keep us posted ! > > TIA, > fp Check it out now. Only one to be added is the Multicolumn List (table), and then menus. The other widgets (Togglebutton, BitmapCanvas, Gauge, Notebook, CodeEditor) will not be implemented initially. http://test.powersystemadvisors.com From carbanancizpo at gmail.com Fri Apr 18 16:56:37 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:56:37 -0700 (PDT) Subject: iron on canvas patch Message-ID: <0ebe94bc-4c87-4b08-b49b-db6c12a7646d@a23g2000hsc.googlegroups.com> iron on canvas patch http://cracks.12w.net F R E E C R A C K S From ivory91044 at gmail.com Tue Apr 29 04:58:06 2008 From: ivory91044 at gmail.com (ivory91044 at gmail.com) Date: Tue, 29 Apr 2008 01:58:06 -0700 (PDT) Subject: autocad crack Message-ID: autocad crack http://crack.cracksofts.com From gagsl-py2 at yahoo.com.ar Tue Apr 29 00:02:32 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 29 Apr 2008 01:02:32 -0300 Subject: cytpes **int References: <56674130-c04e-403e-8364-92cbd158b2f0@b9g2000prh.googlegroups.com> <67mveuF2pauigU1@mid.uni-berlin.de> Message-ID: En Mon, 28 Apr 2008 18:55:15 -0300, Diez B. Roggisch escribi?: > VernM schrieb: >> I am using ctypes to wrap a set of functions in a DLL. It has been >> going very well, and I am very impressed with ctypes. I want to call a >> c function with a signature of: void func(int **cube), where the array >> if ints in cube is modified by func. I want to setup cube with int >> values, and access them after the call to func. I unerstand how to >> setup the ctypes array, but how do I pass **cube to the function, and >> how do I access the results? > > it should be simple. > > use something like (untestet): > > b = POINTER(c_int)() > func(byref(b)) [snip two other similar alternatives] That's true for "a pointer to a pointer to int", and it's valid if the functions references **b or b[0][0] - but in this case int** probably means "[pointer to] an array of arrays of int" and presumibly the function will try to access b[3][2] (or whatever indices are in range). The duality pointer/array in C is dangerous when defining interfases - you have to know how the value is intended to be accessed. (I assume the function modifies the integer values, but not the pointers themselves) # build an array of 10x10 ints Arr10int = c_int * 10 Pint = POINTER(c_int) PPint = POINTER(Pint) Arr10pint = Pint * 10 a = Arr10pint() for i in range(10): a[i] = Arr10int() ... initialize the array ... ... load the function ... # call the function somefunction.argtypes = (PPint,) somefunction.restype = None somefunction(a) -- Gabriel Genellina From ch612bunn at gmail.com Sun Apr 27 09:17:51 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:17:51 -0700 (PDT) Subject: kaspersky internet security 7 crack Message-ID: kaspersky internet security 7 crack http://wga-cracks.crackkey.net From bob.martin at excite.com Mon Apr 14 03:21:48 2008 From: bob.martin at excite.com (Bob Martin) Date: Mon, 14 Apr 2008 07:21:48 GMT Subject: Java or C++? References: Message-ID: in 342367 20080414 074410 s0suk3 at gmail.com wrote: >Hello, I was hoping to get some opinions on a subject. I've been >programming Python for almost two years now. Recently I learned Perl, >but frankly I'm not very comfortable with it. Now I want to move on >two either Java or C++, but I'm not sure which. Which one do you think >is a softer transition for a Python programmer? Which one do you think >will educate me the best? C++ is for masochists. Go for Java. From john00587 at gmail.com Mon Apr 21 01:43:37 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:43:37 -0700 (PDT) Subject: revit 9 keygen Message-ID: <4ff8fc5d-70a4-4c8f-b8ed-cb279807bde7@y18g2000pre.googlegroups.com> revit 9 keygen http://cracks.00bp.com F R E E C R A C K S From tdimson at gmail.com Thu Apr 10 16:41:53 2008 From: tdimson at gmail.com (Thomas Dimson) Date: Thu, 10 Apr 2008 13:41:53 -0700 (PDT) Subject: subprocess.Popen() output to logging.StreamHandler() References: <6b02e27c-916f-42a7-b2e0-75af51bba343@h1g2000prh.googlegroups.com> Message-ID: On Apr 10, 3:05?pm, svensven wrote: > Vinay Sajip wrote: > > ?> On Apr 10, 1:11 pm, "sven _" wrote: > ?>> My goal is to have stdout and stderr written to a logginghandler. > ?> > ?> Thomas was almost right, but not quite - you can't call info on a > ?> Handler instance, only on a Logger instance. The following script: > > Yes, but that was easily fixed. Still there seemed to be a problem > there with the .poll(), since it would think the process ended while > it was actually running. The result was that only some of the command > output was shown. > > ?> import logging > ?> import subprocess > ?> > ?> logging.basicConfig(level=logging.INFO) # will log to stderr of this > ?> script > ?> > ?> s = subprocess.Popen( ['ls','-la'], stdout=subprocess.PIPE ) > ?> while 1: > ?> ? ? line = s.stdout.readline() > ?> ? ? exitcode = s.poll() > ?> ? ? if (not line) and (exitcode is not None): > ?> ? break > ?> ? ? line = line[:-1] > ?> ? ? logging.info("%s", line) > > This works perfectly, as far as I can tell. You seem to use another > conditional, though. > > I'll take a closer look at this tomorrow. Thanks for the clean > solution, Vinay. > > sven I think what I actually meant was: s = subprocess.Popen( ['ls','-la'], stdout=subprocess.PIPE ) while 1: line = s.stdout.readline() if not line: break logging.info( line ) The problem with p.poll() is that the process probably has ended before you have gotten all the text out of the buffer. Readline will return a falsy value when the process ends. Anyway, this post has a lot of responses so I'm sure _something_ works :) From maxm at mxm.dk Fri Apr 25 07:02:50 2008 From: maxm at mxm.dk (Max M) Date: Fri, 25 Apr 2008 13:02:50 +0200 Subject: Little novice program written in Python In-Reply-To: References: Message-ID: Rog?rio Brito skrev: > Hi, All. > > What I would like is to receive some criticism to my code to make it > more Python'esque and, possibly, use the resources of the computer in a > more efficient way (the algorithm implemented below is the Sieve of > Eratosthenes): I agree with the rest here. Your code generally looks fine. But on another note, this type of code is not something you often see in Python. It is very dense with regard to algorithm. Most code is not like that so perhaps you should try something more "usual" like sending email, fetching webpages etc. to get a feel for the language. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science From bronger at physik.rwth-aachen.de Wed Apr 16 02:38:03 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 16 Apr 2008 08:38:03 +0200 Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> <47ffee86$0$6838$2d805a3e@textnews.eweka.nl> <15e5c81b-0b21-44f0-9282-0d1495bc6bb3@z24g2000prf.googlegroups.com> <480011b7$0$28883$c83e3ef6@nn1-read.tele2.net> Message-ID: <87od8amhis.fsf@physik.rwth-aachen.de> Hall?chen! Joe P. Cool writes: > On 12 Apr., 03:34, baalbek wrote: > >> Delphi/Object Pascal simply sucks big time! > > I disagree. Delphi/Object Pascal with the VCL (Visual Component > Library) is one of the most sophisticated IDEs ever, even better > than Qt IMO. [...] I was somewhat disappointed with Delphi. I had used Turbo Pascal 15 years ago, which was one of the best IDEs at that time. It was really good. Now, we use Delphi in our institute for measurement and automation applications with GUI. It is probably possible to work equally well with Delphi, however, none of us have found the right IDE settings for this yet. Especially the behaviour after runtime errors seems to be unpredictable to us, and it is mostly sub-optimal. After having tested most of the dozens of checkboxes I could improve the situation slightly but not more. As far as the GUI composing is concerned, this is great with Delphi, especially for beginners. However, I still prefer the text-only programming in e.g. wxPython (and I'm equally fast with it) but this is a matter of taste. It's like the Word vs LaTeX or Gnuplot vs Origin thing I suppose. All of us were utterly disappointed with the new help system. This used to be a stronghold in Borland products but now, you get explanations ? la "Method 'foo': do foo with the object". Super. > [...] > > Wrong. It does have a GUI builder - a very good one - and you can > do point and click creation of GUIs (nothing wrong with that) but > you can also do pure text editor code only programming with it. This shows another disadvantage of such IDEs, namely the editor question. The editor is a very personal piece of software, and I ended up using Emacs for a lot of my Delphi work. I don't consider myself a religious Emacs user -- I was really faster this way. However, this throws away a lot of the IDE's advantages. Thus, having everything in one system is only a good idea if you do Delpi-only. >> (did anyone mention waste of one's life?), and don't get me >> started on that primitive, complete utter waste of language >> called Object Pascal! > > I'm no big Pascal fan either but Object Pascal has a decent string > library and better container literals than C/C++ and Java. The > language itself is a matter of taste and I don't waste my time > discussing it. Well, there also are objective issues with it that *can* be discussed. You mentioned the string library. This is what caused a lot of headaches here. There is a *lot* of doubled functionality there because there seems to be a transition in Delphi from old to new string functions. The difference between Wide Strings and AnsiStrings is still obscure to me. In .NET Delphi, this seems to have been cleaned up, but I haven't used it. >> Python/wxPython/Glade == real programmer's toolkit >> Object Pascal/Delphi == the hobbyist/beginner's toolkit > > I'm pretty sure that there are more professional software products > written in Delphi than in wxPython. Certainly. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From robert.kern at gmail.com Fri Apr 11 13:51:14 2008 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 11 Apr 2008 12:51:14 -0500 Subject: Graphs in Python In-Reply-To: References: <531651.98983.qm@web55601.mail.re4.yahoo.com> Message-ID: Henry Chang wrote: > Try Google Chart with python wrapper: > > http://pygooglechart.slowchop.com/ > > http://code.google.com/apis/chart/ Wrong kind of graph. -- 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 From toby at tobiah.org Wed Apr 23 15:17:06 2008 From: toby at tobiah.org (Tobiah) Date: Wed, 23 Apr 2008 12:17:06 -0700 Subject: Calling Python code from inside php References: <679e9oF2mti63U1@mid.uni-berlin.de> Message-ID: On Wed, 23 Apr 2008 20:42:44 +0200, Diez B. Roggisch wrote: > vijay schrieb: >> Hi >> I have a python code performing some computation for me.I have a >> html page which passes certain argumnets to a php page.This php page >> needs to pass on the value to the Python class and get the result >> back. >> How do I go about this?? I do this quite a bit: &1"; $p = popen($command, 'r'); $output = fread($p, 1024 * 1024); print $output; ?> ** Posted from http://www.teranews.com ** From jr9445 at ATT.COM Wed Apr 9 17:23:30 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Wed, 9 Apr 2008 16:23:30 -0500 Subject: basic python question about for loop In-Reply-To: References: Message-ID: > -----Original Message----- > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > list-bounces+jr9445=att.com at python.org] On Behalf Of jmDesktop > Sent: Wednesday, April 09, 2008 5:04 PM > To: python-list at python.org > Subject: Re: basic python question about for loop > > > > > > >>> for n in range(2, 10): > > > ... ? ? for x in range(2, n): > > > ... ? ? ? ? if n % x == 0: > > > ... ? ? ? ? ? ? print n, 'equals', x, '*', n/x > > > ... ? ? ? ? ? ? break > > > ... ? ? else: > > > ... ? ? ? ? # loop fell through without finding a factor > > > ... ? ? ? ? print n, 'is a prime number' > > > ... > > > > > first time 2 mod 2, 2/2, no remainder == 0, what am I doing wrong? > > > Why did it fall through? > > > > So what is n and x in the first iteration? Sorry. I'm trying. You're never getting to n and x in the first iteration, because the 'for x in range(2, n)' loop isn't looping. This: for x in range(2, n) is equivalent in C/Perl/etc. to: for(x=2; x This is a contrived pseudocode example which has been broken out of a larger problem, so it may seem like a strange thing to want to do, but... I have a group of objects which inherit (single) from a common base class like so: --- class Root(object): @classmethod def CumulativeScore(cls, arg): #Ask every child class to #generate a score and add #them together cumulativescore = 0 for base in cls.mro(): cumulativescore += base.Score(arg) return cumulativescore #No Score method defined in Root so don't try to call one! class BranchChild(Root): @classmethod def Score(cls, arg): return 1 class LeafChild(BranchChild): @classmethod def Score(cls, arg): return 3 class LeafChild2(BranchChild): pass #No Score method defined here, either! --- The goal is to be able to call CumulativeScore(arg) on an instance of any of these objects (Root, Branch or Leaf) which will then chain calls (top down) to each subclass' Score method if (and only if) one is defined, returning the sum of all of these calls. Kinda like constructor chaining, only I don't want it to be explicit/cooperative because super() doesn't seem to work in classmethods and I want to reduce the amount of redundant boilerplate code in the subclasses (which will be numerous). In order to do this I really need a way to ask LeafChild to give me *its* Score method *if* it has one of its own. I don't want its parent's method or its grandparent's method (until I get to them of course), just the one that's (optionally) defined in LeafChild, so getattr() and __dict__ are of no use to me. The only thing I've been able to find that actually works is inspect.classify_class_attrs(). While it delivers the expected behavior, classify_class_attrs spews out a ton of superfluous information which I have to parse myself, and the method objects it returns in its tuples are not callable to boot. This leads to ugly looking code like this: --- @classmethod def CumulativeScore(cls, arg): cumulativescore = 0 mro = list(cls.mro()) mro.reverse() for base in mro: matchfunc = [getattr(base, "Score") for attr in inspect.classify_class_attrs(base) if attr[0] == "Score" and attr[2] == base] if len(matchfunc) == 1: cumulativescore += matchfunc[0](arg) return cumulativescore --- In looking through the inspect module's documentation, it seems as though getmembers() once offered the functionality I require, but no longer: "Changed in version 2.2: im_class used to refer to the class that defined the method." I've gotten the feeling from the Python documentation that classmethods are seen as third-class citizens, but they are unfortunately perfect for my needs, and it doesn't seem like this should be as complicated as it is. Is there a simpler, more elegant way to ask a class object if it has a particular method definition that I've missed somewhere? If not, why can't classify_class_attrs at least return a callable method object for me (yes, I've read the "unifying" paper)? Thanks! From code at pizzashack.org Wed Apr 2 16:28:41 2008 From: code at pizzashack.org (Derek Martin) Date: Wed, 2 Apr 2008 16:28:41 -0400 Subject: Manipulate Large Binary Files In-Reply-To: <9999810b0804021109n77f2c990p7b10d92e9344ad00@mail.gmail.com> References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> <9999810b0804021109n77f2c990p7b10d92e9344ad00@mail.gmail.com> Message-ID: <20080402202841.GC22737@dragontoe.org> On Wed, Apr 02, 2008 at 02:09:45PM -0400, Derek Tracy wrote: > Both are clocking in at the same time (1m 5sec for 2.6Gb), are there > any ways I can optimize either solution? Buy faster disks? How long do you expect it to take? At 65s, you're already reading/writing 2.6GB at a sustained transfer rate of about 42.6 MB/s. That's nothing to sneeze at... Your disks, and not your program, are almost certainly the real bottleneck. Unless you have reason to believe your hardware should be significantly faster... That said, due to normal I/O generally involving double-buffering, you might be able to speed things up noticably by using Memory-Mapped I/O (MMIO). It depends on whether or not the implementation of the Python things you're using already use MMIO under the hood, and whether or not MMIO happens to be broken in your OS. :) > Would turning off the read/write buff increase speed? No... -- Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0x81CFE75D -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available URL: From george.sakkis at gmail.com Wed Apr 2 19:19:12 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 2 Apr 2008 16:19:12 -0700 (PDT) Subject: Recursive function won't compile References: <65iafeF2g9cvvU1@mid.uni-berlin.de> Message-ID: On Apr 2, 5:00 pm, "Diez B. Roggisch" wrote: > bc1... at googlemail.com schrieb: > > > > > #include > > #include > > > def RecursiveFact(n): > > if(n>1): > > return n*RecursiveFact(n-1) > > else: > > return 1 > > > fact = RecursiveFact(31) > > print fact > > > fact = "End of program" > > print fact > > > ......but yet it still gives the right answer. How is this possible? > > Given that you obviously don't use python, but some weird cross-breed > beteween python and C - who are we to judge the semantics of that chimera? > > Diez Seems like a bad belated April Fool's day joke to me. George From james at reggieband.com Thu Apr 17 17:59:14 2008 From: james at reggieband.com (james at reggieband.com) Date: Thu, 17 Apr 2008 14:59:14 -0700 (PDT) Subject: Request a short code review Message-ID: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> Hi all, I am moving my server based scripting over to Python and I am attempting to write more idiomatic python. I have 8 years professional programming experience and I am looking to get to a very high standard of python coding. As such, I was wondering if it was appropriate to post code snippets I am not 100% happy with in order to find a more elegant python way for coding. Here is a method I came across that I would like to clean up: def output_random_lesson_of_type(self, type=None): """Output a lesson of a specific type - if no type is passed in then output any type.""" if type: filtered_lessons = filter(lambda x: x["type"] == type, self.lesson_data["lessons"]) if filtered_lessons: lesson = self.output_random(filtered_lessons) else: print "Unable to find lessons of type %s." % type else: lesson = self.output_random(self.lesson_data["lessons"]) return lesson Where 'type' is a string, and 'self.lesson_data["lessons"]' is an array of dictionaries where each item is guaranteed to have string value with a key 'type' I am not necessarily looking to make the code shorter or more functional or anything in particular. However if you spot something to improve then I am happy to learn. Any and all comments appreciated. Cheers, James. From nick at craig-wood.com Wed Apr 23 05:30:04 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Wed, 23 Apr 2008 04:30:04 -0500 Subject: subprocess module is sorely deficient? References: Message-ID: Mike Hansen wrote: > > I think the best solution would be to port Pexpect to windows which > > wouldn't be that difficult according to my reading of the code. If > > only I had more free time! > > Sage ( http://www.sagemath.org ) uses pexpect fairly extensively to > interface with all sorts of other systems. We recently received > funding from Microsoft to do a native port of Sage (and all of its > components to Windows. Part of this will most likely be a port of > pexpect to Windows. Hooray! -- Nick Craig-Wood -- http://www.craig-wood.com/nick From ijoshua at gmail.com Sun Apr 6 11:19:38 2008 From: ijoshua at gmail.com (ijoshua) Date: Sun, 6 Apr 2008 08:19:38 -0700 (PDT) Subject: Is there any way to say ignore case with "in"? References: <47f692f3$0$759$bed64819@news.gradwell.net> <432d690f-44be-49a9-bc6a-1cf3445549d6@m71g2000hse.googlegroups.com> Message-ID: <012dfbc3-858b-4ffa-8c2a-4164496d826b@8g2000hse.googlegroups.com> On Apr 5, 7:14?am, Steve Holden wrote: > 7stud wrote: > > > Easier? ?You mean like some kind of mind meld? > > That's right, DWIM mode Python. Rock on! If it is common enough, define a custom type of string. I have appended a simple version that should work for your example of `in`. You would probably want to define all of the builtin str methods for this class to be really useful. Regards, Josh --- # cistr.py import operator class cistr(object): """A type of string that ignores character case for the right side of the `in` operator. >>> 'AND' in cistr('sPaM aNd eGgS') True """ def __init__(self, string): self.string = str(string).lower() def __contains__(self, other): return operator.contains(self.string, other.lower()) def __repr__(self): return 'cistr(%r)'%(self.string) def lower(self): return self.string if '__main__' == __name__: string1 = 'AND' string2 = 'sPaM aNd eGgS' print '%r in %r ? %r' % (string1, string2, string1 in string2) print '%r in %r ? %r' % (string1, cistr(string2), string1 in cistr(string2)) From gagsl-py2 at yahoo.com.ar Sun Apr 6 03:13:41 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 06 Apr 2008 04:13:41 -0300 Subject: Python Data Utils References: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> Message-ID: En Sun, 06 Apr 2008 01:43:29 -0300, Jesse Aldridge escribi?: > In an effort to experiment with open source, I put a couple of my > utility files up here. What do you think? Some names are a bit obscure - "universify"? Docstrings would help too, and blank lines, and in general following PEP8 style guide. find_string is a much slower version of the find method of string objects, same for find_string_last, contains and others. And I don't see what you gain from things like: def count( s, sub ): return s.count( sub ) it's slower and harder to read (because one has to *know* what S.count does). Other functions may be useful but without even a docstring it's hard to tell what they do. delete_string, as a function, looks like it should delete some string, not return a character; I'd use a string constant DELETE_CHAR, or just DEL, it's name in ASCII. In general, None should be compared using `is` instead of `==`, and instead of `type(x) is type(0)` or `type(x) == type(0)` I'd use `isinstance(x, int)` (unless you use Python 2.1 or older, int, float, str, list... are types themselves) Files.py is similar - a lot of more or less common things with a different name, and a few wheels reinvented :) Don't feel bad, but I would not use those modules because there is no net gain, and even a loss in legibility. If you develop your code alone, that's fine, you know what you wrote and can use it whenever you please. But for others to use it, it means that they have to learn new ways to say the same old thing. -- Gabriel Genellina From grante at visi.com Thu Apr 17 09:55:05 2008 From: grante at visi.com (Grant Edwards) Date: Thu, 17 Apr 2008 08:55:05 -0500 Subject: Finally had to plonk google gorups. References: Message-ID: On 2008-04-17, Dennis Lee Bieber wrote: > On Wed, 16 Apr 2008 09:19:37 -0500, Grant Edwards > declaimed the following in comp.lang.python: > >> I broke down and joined all the other people that just killfile >> everything posted via google.groups. > > Unfortunately, that is the one weak point in Agent... Usenet > kill filters only take subject or author fields... Sound like a good reason to hack on Agent so that you can kill based on any header you want. > I suspect they try to apply them when fetching headers before > downloading the messages and don't have other fields > available... > > So... given the recent batch... My next best was to kill on > @gmail... That's the one big reason I've not switched over to using my gmail address. I'm thinking I should register my own domain and have it forward to my gmail address. That way I get all the free storage (and web access) on gmail's imap server without the stigma of using a gmail.com address. -- Grant Edwards grante Yow! I joined scientology at at a garage sale!! visi.com From mattheww at chiark.greenend.org.uk Wed Apr 16 17:31:52 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 16 Apr 2008 22:31:52 +0100 (BST) Subject: How to have unittest tests to be executed in the order they appear? References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> <87zlru7le2.fsf@benfinney.id.au> Message-ID: Ben Finney wrote: >"Giampaolo Rodola'" writes: >> Is there a way to force unittest to run test methods in the order >> they appear? > No, and this is a good thing. > Your test cases should *not* depend on any state from other test > cases; they should function equally well when executed in any > arbitrary sequence. Dependencies between separate test cases (e.g. > "they only work correctly when run in a specific sequence") means > you're not isolating them properly. So a mode to randomise the test sequence would be nice to have. Unittest's behaviour (using alphabetical order) doesn't really help to detect undesired dependencies (which might be bugs in the test suite or bugs in the underlying code). But running tests in the order they appear is often helpful: you can put the tests for basic stuff before the tests for advanced stuff, and then if you suddenly get seventeen failing tests, you know that the first failure is the best bet to investigate first. -M- From sierra9162 at gmail.com Wed Apr 16 11:20:56 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:20:56 -0700 (PDT) Subject: kate hudson wallpapers Message-ID: <6011c411-7fce-4d77-a7eb-55b1536712df@a23g2000hsc.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From larry.bates at websafe.com` Fri Apr 18 12:24:01 2008 From: larry.bates at websafe.com` (Larry Bates) Date: Fri, 18 Apr 2008 11:24:01 -0500 Subject: Installing BeautifulSoup with easy_install (broken?) In-Reply-To: <66rvkdF2kqa1lU1@mid.uni-berlin.de> References: <66rvkdF2kqa1lU1@mid.uni-berlin.de> Message-ID: Diez B. Roggisch wrote: > Larry Bates schrieb: >> Info: >> >> Python version: ActivePython 2.5.1.1 >> Platform: Windows >> >> I wanted to install BeautifulSoup today for a small project and >> decided to use easy_install. I can install other packages just fine. >> Unfortunately I get the following error from BeautifulSoup >> installation attempt: >> >> C:\Python25\Lib\SITE-P~1>easy_install BeautifulSoup >> Searching for BeautifulSoup >> Reading http://pypi.python.org/simple/BeautifulSoup/ >> Reading http://www.crummy.com/software/BeautifulSoup/ >> Reading http://www.crummy.com/software/BeautifulSoup/download/ >> Best match: BeautifulSoup 3.0.5 >> Downloading >> http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup- >> 3.0.5.tar.gz >> Processing BeautifulSoup-3.0.5.tar.gz >> Running BeautifulSoup-3.0.5\setup.py -q bdist_egg --dist-dir >> c:\docume~1\larry\l >> ocals~1\temp\easy_install-cfdxna\BeautifulSoup-3.0.5\egg-dist-tmp-gbrpp5 >> Traceback (most recent call last): >> File "C:\Python25\Scripts\easy_install-script.py", line 8, in >> load_entry_point('setuptools==0.6c8', 'console_scripts', >> 'easy_install')() >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >> and\easy_install.py", line 1671, in main >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >> and\easy_install.py", line 1659, in with_ei_usage >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >> and\easy_install.py", line 1675, in >> File "C:\Python25\lib\distutils\core.py", line 151, in setup >> dist.run_commands() >> File "C:\Python25\lib\distutils\dist.py", line 974, in run_commands >> self.run_command(cmd) >> File "C:\Python25\lib\distutils\dist.py", line 994, in run_command >> cmd_obj.run() >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >> and\easy_install.py", line 211, in run >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >> and\easy_install.py", line 446, in easy_install >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >> and\easy_install.py", line 476, in install_item >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >> and\easy_install.py", line 655, in install_eggs >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >> and\easy_install.py", line 930, in build_and_install >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >> and\easy_install.py", line 919, in run_setup >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand >> box.py", line 27, in run_setup >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand >> box.py", line 63, in run >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand >> box.py", line 29, in >> File "C:\VOL1\Larry\Websafe\Python\wstools\setup.py", line 2, in >> >> import py2exe >> File "C:\VOL1\Larry\Websafe\Python\wstools\unittest.py", line 3, in >> >> class TextCtrlTest(unittest.TestCase): >> AttributeError: 'module' object has no attribute 'TestCase' >> >> >> Thanks in advance for any "clues". > > I'm not sure what happens - but I think it is suspicious that these > "wstools" get into the way. And it looks as if wstools.unittest imports > itself, instead of the python-unittest - which must be solved with > getting the sys.path fixed. > > Diez Sharp eyes Diez, I overlooked that. This is a path that I search for some tools I've written. It is set in PYTHONPATH environment variable. I cleared PYTHONPATH and easy_install BeautifulSoup worked. Still not quite clear why. Thanks loads. -Larry From victorsubervi at gmail.com Tue Apr 15 11:04:02 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Tue, 15 Apr 2008 17:04:02 +0200 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> <4dc0cfea0804140629rf1ac100m27ad9d0456cbbe2d@mail.gmail.com> <4803644A.8010204@holdenweb.com> Message-ID: <4dc0cfea0804150804l2d3832f0sd8f1d9405934063@mail.gmail.com> Gabriel; That's really nice code you wrote. I will rewrite my app accordingly, after I catch a breather! Say, would you please publish this somewhere? Why should I write a howto on this and credit you when all I would be doing is republishing (plagerizing) what you published? Please insert these keywords: mysql, image, python, mysqldb and maybe picture and photo (you already have photo). Call it something like "MySQL/Python Tutorial for Posting and Retrieving Images / Photo Album". I ask you to do this because I scoured google looking for just what you've provided and it simply isn't out there. At all. There are nice howto's in php. Please post this for those interested in python, somewhere like the cookbook. Thanks, Victor On Tue, Apr 15, 2008 at 3:23 AM, Gabriel Genellina wrote: > En Mon, 14 Apr 2008 11:03:54 -0300, Steve Holden > escribi?: > > Victor Subervi wrote: > >> Thanks to all, especially Gabriel. [...] > >> Steve, thank you for all your help, but do overcome your temper :)) > > > > I'm glad the penny finally dropped. You may have been treated to a > > modest display of exasperation, but please be assured you have not yet > > seen anything remotely like temper from me :-) > > And I'm glad to see that you finally "got it", too! > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.sakkis at gmail.com Wed Apr 23 21:17:41 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 23 Apr 2008 18:17:41 -0700 (PDT) Subject: Ideas for parsing this text? References: Message-ID: On Apr 23, 9:00?pm, "Eric Wertman" wrote: > I have a set of files with this kind of content (it's dumped from WebSphere): > > [snipped] > > I'm trying to figure out the best way to feed it all into > dictionaries, without having to know exactly what the contents of the > file are. ? It would be pretty pointless if you had to know in advance the exact file content, but you still have to know the structure of the files, that is the grammar they conform to. > Any ideas? ?I was considering making a list of string combinations, like so: > > junk = ['[[','"[',']]'] > > and just using re.sub to covert them into a single character that I > could start to do split() actions on. ?There must be something else I > can do.. Yes, find out the formal grammar of these files and use a parser generator [1] to specify it. HTH, George [1] http://wiki.python.org/moin/LanguageParsing From ptmcg at austin.rr.com Tue Apr 22 09:54:12 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Tue, 22 Apr 2008 06:54:12 -0700 (PDT) Subject: overriding = operator References: Message-ID: <23874e00-e22e-43d8-a4e7-a2a101eb822f@a1g2000hsb.googlegroups.com> On Apr 22, 8:47?am, "Anton Mellit" wrote: > I need something like > 'overriding' =, which is impossible, but I look for a systematic > approach to do something instead. It seems there are two ways to do > what I need: > > 1. Implement a method 'assign' which generates the corresponding code > to store value: > > z.assign(x + y) > > 2. Do the same as 1., but via property set methods. For example, this > would look cleaner: > > z.value = x + y > > Which of these is preferrable? Does anyone know any alternative ways? > > Anton If you are willing to accept '<<=' as meaning 'assign to existing' instead of 'left shift in place', you can override this operator using the __ilshift__ method. We used this technique in C++/CORBA code back in the 90's to "inject" values into CORBA::Any variables. -- Paul From kyosohma at gmail.com Tue Apr 8 12:20:02 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 8 Apr 2008 09:20:02 -0700 (PDT) Subject: List open files References: <47fb8d54$0$15068$426a74cc@news.free.fr> <47fb968c$0$22371$426a74cc@news.free.fr> Message-ID: On Apr 8, 10:56 am, "Bruno GUERPILLON" wrote: > "Mike Driscoll" a ?crit dans le message de news: > c62d02f7-62c4-447d-a456-261fefb8b... at e67g2000hsa.googlegroups.com... > > > On Apr 8, 10:16 am, "Bruno GUERPILLON" wrote: > >> Hi, > > >> I'd like, in a WIN32 environment, list all open files. > >> Anyone got a clue how to do this ? > > >> Regards, > > >> Bruno. > > > XP comes with a utility called OpenFiles.exe which supposedly gives > > this functionality. You can use Python's subprocess command to run it > > and parse its output. > > > Mike > > Thanks for the answer Mike. > Well, Openfiles.exe list only file opened vi Network. > I'd like to know the local opene files list. > > Regards There is a /Local flag that's supposed to show local files that are open. I've never used this program myself though. You might be able to use WMI somehow. Mike From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 30 06:37:24 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 30 Apr 2008 12:37:24 +0200 Subject: Problem with variables assigned to variables??? In-Reply-To: References: Message-ID: <48184bd7$0$4924$426a34cc@news.free.fr> n00m a ?crit : > for listmember in mylist: > print listmember + ".shp", eval(listmember) eval and exec are almost always the wrong solution. The right solution very often implies a dict or attribute lookup, either on custom dict or on one of the available namespaces (globals(), locals(), or a module, class or instance). From contact at dann.ro Wed Apr 16 22:15:52 2008 From: contact at dann.ro (Daniel NL) Date: Thu, 17 Apr 2008 05:15:52 +0300 Subject: index of list of lists Message-ID: <1208398552l.41837l.0l@ns.bitcarrier.eu> yes, there's a thread with the same title, but I believe mine is more appropriate title. so, as much as I search on the web, read manuals, tutorials, mail-lists (including this one) I cannot figure it out how to search a string in a list of lists. like this one: someList = [['somestring', 1, 2], ['oneother', 2, 4]] I want to search "somestring" in someList which is in practice a list of aprox. 200 lists. (hey, I'm a newbie python programmer, don't judge me). is the list.index the wrong approach? should I use numpy, numarray, something else? can anyone, be kind and help me with this? From hat at se-162.se.wtb.tue.nl Wed Apr 9 11:12:49 2008 From: hat at se-162.se.wtb.tue.nl (A.T.Hofkamp) Date: Wed, 09 Apr 2008 17:12:49 +0200 Subject: Cannot understand the detailedly the following code References: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> <10a83944-b17a-4c3f-992b-1754c0a5e9b1@s33g2000pri.googlegroups.com> Message-ID: On 2008-04-09, reachmsn at hotmail.com wrote: > On Apr 8, 5:45?pm, "A.T.Hofkamp" wrote: > Ok following these instructions one gets > > def find_all_paths(graph, start, end, path=[]): > path= path+ [start] > > for node in graph[start]: > > find_all_paths(graph, node, end, path) > >> First define the input and output parameters/values of the function. >> (ie what goes in, and what comes out) > > Now what will be the output parameters - there is a Return statement. > Input parameters are graph, vertexes start, node, end and path. Also > how would you write the terminating and reduction cases after this. > Actually i'm not clear how to proceed writing this recursive function. > Thanks! Don't look at code, don't even think about it (it gives you too much confusing details). Instead, have a beer, sit down in a sunny spot, and do mothing for a while. Think about the function as a (black) box. You don't know what is in it (it is not important yet). That box is the function (many people prefer to draw a rectangular shape on a sheet of paper, and consider that to be the function). What data does the box need to do its work, and what does it produce after it has done its work? (suppose you are given the task of 'finding all paths'. What information do you need to acomplish this task, and what information do you write down as result?) A simple example of a multiplication task: One needs 2 numbers to do the task, and the result is another number. Note that at this stage, you don't worry about HOW you do the task, only WHAT GOES IN AND WHAT COMES OUT. (actually, HOW depends on INPUT. Multiplication of 2 and 5 can be done differently from multiplication of 230698762085269459068388639078903870385790368703879038285790 and 5938063786093895682682968390789380834687387689762897. For this reason, deciding the strategy of solving the problem comes after establishing input and output). Sincerely, Albert PS email will give you shorter response times. From lscbtfws at gmail.com Sat Apr 26 12:13:46 2008 From: lscbtfws at gmail.com (lscbtfws at gmail.com) Date: Sat, 26 Apr 2008 09:13:46 -0700 (PDT) Subject: get data back crack Message-ID: get data back crack http://cracks.00bp.com F R E E C R A C K S From sjmachin at lexicon.net Sat Apr 12 21:00:18 2008 From: sjmachin at lexicon.net (John Machin) Date: Sat, 12 Apr 2008 18:00:18 -0700 (PDT) Subject: SQLite OperationalError near "?" References: <7e592f06-42b5-4834-8f7c-34c9bc44aceb@s39g2000prd.googlegroups.com> Message-ID: On Apr 13, 8:45 am, Hexade wrote: > Hello > > I would like to use the safe "?" placeholder in my SQLite requests but > I got the following error: > > Traceback (most recent call last): > (...) > cursor.execute("SELECT ? FROM ? WHERE name = ? ", (key, self.table, > self.name)) > OperationalError: near "?": syntax error > > key, self.table and self.name are standart strings. > > Any idea about how to solve this problem ? > You may like to read the answer to the question on sqlite3 that was posted 45 minutes before yours. From jorge.vargas at gmail.com Fri Apr 25 17:55:13 2008 From: jorge.vargas at gmail.com (Jorge Vargas) Date: Fri, 25 Apr 2008 17:55:13 -0400 Subject: is there a python equivalent for this tool? Message-ID: <32822fe60804251455y3bde3f26t2239e3e29ae36d82@mail.gmail.com> Dear python users, do you know of a tool like this that is written in python? http://code.google.com/p/css-redundancy-checker/ in case you where wondering I just don't want to have the ruby dependency on my python proyects. From kperkins257 at gmail.com Wed Apr 23 15:53:20 2008 From: kperkins257 at gmail.com (kperkins257 at gmail.com) Date: Wed, 23 Apr 2008 12:53:20 -0700 (PDT) Subject: Python development tools References: Message-ID: <93653508-8c67-4ea1-924a-a36b80353239@w7g2000hsa.googlegroups.com> On Apr 23, 1:39?pm, "wongjoek... at yahoo.com" wrote: > Are there any completely free developent tools for python scripts like > IDLE. I have used IDLE , but I want to try out others also. I saw > stuff like PyCrust, but I don't see that it can run the script as > well. > Thanks, > > RR SPE is a very nice, and free python development tool. Written in python ansd uses wxpython for the gui. http://pythonide.blogspot.com/ From gagsl-py2 at yahoo.com.ar Thu Apr 3 14:22:29 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 15:22:29 -0300 Subject: Strange MySQL Problem... References: <4dc0cfea0804021236n1faafabav1699fbe45acc3c01@mail.gmail.com> <47f46a3e$0$36371$742ec2ed@news.sonic.net> <4dc0cfea0804030543t1ad5a3abs539fa6598061c454@mail.gmail.com> <4dc0cfea0804031003r24086f0fgea31eccdefa2ed54@mail.gmail.com> Message-ID: En Thu, 03 Apr 2008 14:03:53 -0300, Victor Subervi escribi?: > On Thu, Apr 3, 2008 at 9:34 AM, Gabriel Genellina > > wrote: > > Thank you. I believe you mean by bound, something like this, right? > binary(picdata) > I am now doing that, if I am not mistaken. No, I mean execute(sqltext, arguments) instead of execute(sqltext_with_values_inserted_by_hand) >> *post*? This is the server response. Return either text *or* an image >> (the >> text may be an html referencing the image) > > Yes, post. But what do I write instead of this? > print 'Content-Type: image/jpeg\r\n' Perhaps you should read a little about how HTTP works. Very shortly, the client (the browser, on behalf of the user) sends an HTTP Request (usually a GET request, sometimes POST). The server receives it, processes it and returns an HTTP Response. Whatever you 'print' in your CGI script is part of the Response, a response isn't a POST. If the response is an HTML page, the Content-Type should say text/html, NOT image/jpeg. >> Test it locally (just the database thing, no web), test the cgi script >> without database interaction, only then join the two. > > Okay, but how do I upload an image into mysql without a script? And once > I can do that, everything?s (almost) solved! I insist: test each step separately. First locally, later merge all steps. One doesn't "upload an image into mysql": one uploads an image, and some script on the server saves the image into mysql database. >> But you can read the server logs at least? > I am new to Plesk. I discovered I can read logs. More following... Good thing! >> Your code is throwing exceptions but you're not seeing them. Use the >> cgitb >> module http://docs.python.org/lib/module-cgitb.html > > Now here you give me another laugh :) I added this line to the script > import cgitb; cgitb.enable() > and suddenly I can take out these junk lines that were throwing the HTTP > 200 > error: Please stop refering to it as HTTP 200 error: it is *not* an error! > I have a script called start.py which has this code in it: > > col_names = ['id', 'name_en', 'name_es', 'name_it', 'category', > 'title_en', 'title_es', 'title_it', \ > 'description_en', 'description_es', 'description_it', 'price', > 'bedrooms', 'bathrooms', 'pic1', 'sort_factor'] > Just notice the pic1 there... > Then I make a nice list of colnames like MySQL wants... > > col_names_with_commas = '' > for name in col_names: > col_names_with_commas += name + ', ' > count = len(col_names_with_commas)-2 > col_names_with_commas = > col_names_with_commas[0:len(col_names_with_commas)-2] The above code is a long and convoluted way to write: col_names_with_commas = ', '.join(col_names) > for id in ids: > for d in id: > print '\n' > cursor.execute('select ' + col_names_with_commas + ' from > products > where id = ' + str(d) + ';') Remember to use parameters: cursor.execute('select ' + col_names_with_commas + ' from products ' ' where id = %s;', (d,)) All this looks like the kind of spaghetti code common in cgi scripts around 10 years ago, mixing application logic, storage and presentation all at once. At least try to separate database operations from html generation: make your queries, build some data structure, and generate the HTML using that structure as parameters. There are many templating engines to choose for: http://wiki.python.org/moin/Templating > if x == 15: > print '', field, '\n' > else: > print '', field, '\n' > x += 1 > I have to do both of those for statements. The sticky point is in the > last > if statement. 15 is the pic1 field. Should I use binary(field) instead? > It > does not like that. Binary is part of the DBAPI interface (you should read PEP 249 [1]). It has absolutely nothing to do with html pages. > mod_python.cgihandler: NameError: global name 'binary' is not defined, Python is case sensitive... Use MySQLdb.Binary instead. See [1] and the MySQLdb documentation. I insist again: this would have been a lot easier to catch if you test locally; this error has nothing to do with the web part of the application. [1] http://www.python.org/dev/peps/pep-0249/ -- Gabriel Genellina From code at pizzashack.org Thu Apr 3 19:07:58 2008 From: code at pizzashack.org (Derek Martin) Date: Thu, 3 Apr 2008 19:07:58 -0400 Subject: Manipulate Large Binary Files In-Reply-To: <9EBD1A97-98C5-44E6-8472-A7AAADC0A3CA@gmail.com> References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> <9999810b0804021109n77f2c990p7b10d92e9344ad00@mail.gmail.com> <7xlk3vctea.fsf@ruckus.brouhaha.com> <9EBD1A97-98C5-44E6-8472-A7AAADC0A3CA@gmail.com> Message-ID: <20080403230758.GG22737@dragontoe.org> On Thu, Apr 03, 2008 at 02:36:02PM -0400, Derek Tracy wrote: > I am running it on a RAID(stiped raid 5 using fibre channel), but I > was expecting better performance. Don't forget that you're reading from and writing to the same spindles. Writes are slower on RAID 5, and you have to read the data before you can write it... -- Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0x81CFE75D -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available URL: From george.sakkis at gmail.com Fri Apr 4 11:15:38 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 4 Apr 2008 08:15:38 -0700 (PDT) Subject: collecting results in threading app References: Message-ID: <3c56504f-5820-4452-929d-18a95e5d163f@z38g2000hsc.googlegroups.com> On Apr 4, 10:42 am, Gerardo Herzig wrote: > Hi all. Newbee at threads over here. Im missing some point here, but cant > figure out which one. > > This little peace of code executes a 'select count(*)' over every table > in a database, one thread per table: > > class TableCounter(threading.Thread): > def __init__(self, conn, table): > self.connection = connection.Connection(host=conn.host, > port=conn.port, user=conn.user, password='', base=conn.base) > threading.Thread.__init__(self) > self.table = table > > def run(self): > result = self.connection.doQuery("select count(*) from %s" % > self.table, [])[0][0] > print result > return result > > class DataChecker(metadata.Database): > > def countAll(self): > for table in self.tables: > t = TableCounter(self.connection, table.name) > t.start() > return > > > It works fine, in the sense that every run() method prints the correct > value. > But...I would like to store the result of t.start() in, say, a list. The > thing is, t.start() returns None, so...what im i missing here? > Its the desing wrong? The simplest way is to just store it as an attribute in the TableCounter instance: def run(self): self.result = self.connection.doQuery(...) Another alternative is to add it to a Queue. You can't use a list unless you protect with a lock to prevent concurrent append()s, but that's what Queues do anyway [1]. Regardless of where the results are stored, a second issue which you don't address here is, how do you know that a given result or all results are done ? Again there are several alternatives, but Python 2.5 adds two convenient Queue methods for this, task_done() and join(). Check out the example at the bottom of the Queue doc page [2] to see how it works. HTH, George [1] http://docs.python.org/lib/module-Queue.html [2] http://docs.python.org/lib/QueueObjects.html From spiro.harvey at gmail.com Thu Apr 3 18:22:39 2008 From: spiro.harvey at gmail.com (idle) Date: Thu, 3 Apr 2008 15:22:39 -0700 (PDT) Subject: expanding a variable to a dict References: Message-ID: <599b39da-6187-4dca-90ff-75ade61719d5@s13g2000prd.googlegroups.com> brilliant. thanks to both of you. From grahn+nntp at snipabacken.se Tue Apr 1 07:34:05 2008 From: grahn+nntp at snipabacken.se (Jorgen Grahn) Date: 1 Apr 2008 11:34:05 GMT Subject: standard input, for s in f, and buffering References: <65bg55F2esfc1U3@mid.uni-berlin.de> Message-ID: On Mon, 31 Mar 2008 22:27:39 -0700 (PDT), Paddy wrote: > On Mar 31, 11:47 pm, Jorgen Grahn wrote: >> On 31 Mar 2008 06:54:29 GMT, Marc 'BlackJack' Rintsch wrote: >> >> > On Sun, 30 Mar 2008 21:02:44 +0000, Jorgen Grahn wrote: >> >> >> I realize this has to do with the extra read-ahead buffering documented for >> >> file.next() and that I can work around it by using file.readline() >> >> instead. >> > You can use ``for line in lines:`` and pass ``iter(sys.stdin.readline,'')`` >> > as iterable for `lines`. >> >> Thanks. I wasn't aware that building an iterator was that easy. The >> tiny example program then becomes >> By the way, I timed the three solutions given so far using 5 million >> lines of standard input. It went like this: >> >> for s in file : 1 >> iter(readline, ''): 1.30 (i.e. 30% worse than for s in file) >> while 1 : 1.45 (i.e. 45% worse than for s in file) >> Perl while(<>) : 0.65 >> >> I suspect most of the slowdown comes from the interpreter having to >> execute more user code, not from lack of extra heavy input buffering. > Hi Juergen, > From the python manpage: > -u Force stdin, stdout and stderr to be totally unbuffered. > On systems where it matters, also put stdin, stdout and > stderr in binary mode. Note that there is internal > buffering in xreadlines(), readlines() and file-object > iterators ("for line in sys.stdin") which is not influenced > by this option. To work around this, you will want to use > "sys.stdin.readline()" inside a "while 1:" loop. > Maybe try adding the python -u option? Doesn't help when the code is in a module, unfortunately. > Buffering is supposed to help when processing large amounts of I/O, > but gives the 'many lines in before any output' that you saw > originally. "Is supposed to help", yes. I suspect (but cannot prove) that the kind of buffering done here doesn't buy more than 10% or so even in artificial tests, if you consider the fact that "for s in f" is in itself a faster construct than my workarounds in user code. Note that even with buffering, there seems to be one system call per line when used interactively, and lines are of course passed to user code one by one. Lastly, there is still the question about having to press Ctrl-D twice to end the loop, which I mentioned my the original posting. That still feels very wrong. > If the program is to be mainly used to handle millions of > lines from a pipe or file, then why not leave the buffering in? > If you need both interactive and batch friendly I/O modes you might > need to add the ability to switch between two modes for your program. That is exactly the tradeoff I am dealing with right now, and I think I have come to the conclusion that I want no buffering. My source data set can be huge (gigabytes of text) but in reality it is boiled down to at most 50000 lines by a Perl script further to the left in my pipeline: zcat foo.gz | perl | python > bar The Perl script takes ~100 times longer time to execute, and both are designed as filters, which means a modest increase in CPU time for the Python script isn't visible to the end user. /Jorgen -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! From dfg778 at yahoo.com.au Sun Apr 13 04:51:39 2008 From: dfg778 at yahoo.com.au (Matthew Keene) Date: Sun, 13 Apr 2008 18:51:39 +1000 Subject: Call a classmethod on a variable class name Message-ID: I would like to be able to call a specific classmethod on a class name that is going to be passed from another parameter. In other words, I have a call that looks something like: x = Foo.bar() and I would like to generalise this so that I can make this call on any particular class which provides the bar classmethod. I have implemented this using exec, like so: className = parameters.className exec "x = " + className + ".bar()" but this feels somewhat clumsy. (I do have the requisite exception handling to cope with the supplied class not existing or not implementing the bar method, by the way). Is there any more Pythonesque way of doing this ? I guess what I'm probably looking for is something like the way I understand the send function works in Ruby From sevenjp at gmail.com Wed Apr 2 06:00:51 2008 From: sevenjp at gmail.com (=?ISO-8859-1?Q?Jo=E3o_Neves?=) Date: Wed, 2 Apr 2008 03:00:51 -0700 (PDT) Subject: Rationale for read-only property of co_code Message-ID: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> Hello all, I've got this question that has been nagging me for a few days now. What are the reasons for us to have co_code as read-only? I've been trying to get some info about it, but I kept hitting the wall. Correct me if I'm wrong, but as far as I understand, co_code represents the compiled bytecode that should be run when, for instance, a function is called. Wouldn't it be beneficial for programmers to be able to change the bytecode in runtime? I mean, one can't, as far as I'm aware, change the bytecode by accident, so if the programmer would wish to change a function at runtime, he could do so at his own risk. If there is a higher reason behind the read-only property of co_code, I definitely fail to see it, and would like to know what it is. If not, why aren't we allowed to write into it? Thanks in advance, Jo?o Neves From steve at holdenweb.com Sat Apr 5 22:14:15 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 22:14:15 -0400 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> Message-ID: <47F831F7.4000709@holdenweb.com> Fredrik Lundh wrote: > Fredrik Lundh wrote: > >> and for the record, Python doesn't look for PYD files on any of the Unix >> boxes I have convenient access to right now. what Ubuntu version are >> you using, what Python version do you have, and what does >> >> $ python -c "import imp; print imp.get_suffixes()" >> >> print on your machine? > > for reference, here's what I get on Ubuntu 7.10, with the standard > Python interpreter (2.5.1): > > $ python -c "import imp; print imp.get_suffixes()" > [('.so', 'rb', 3), ('module.so', 'rb', 3), ('.py', 'U', 1), > ('.pyc', 'rb', 2)] > > any Ubuntu gurus here that can sort this one out? > I wouldn't claim to be an Ubuntu guru but it seems as though the Ubuntu team decide that you would be able to import extension module YYY either from YYY.so or from YYYmodule.so. IF you are asking *why* then I'd have to answer that I have no idea at all. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From maehhheeyy at gmail.com Thu Apr 17 16:10:58 2008 From: maehhheeyy at gmail.com (maehhheeyy) Date: Thu, 17 Apr 2008 13:10:58 -0700 (PDT) Subject: i want to add a timeout to my code Message-ID: <53ffe104-be3b-43e2-b5c8-4ce5886ac60d@b1g2000hsg.googlegroups.com> I want to add a timeout so that when I pull out my gps from my serial port, it would wait for a bit then loop and then see if it's there. I also want to add a print statement saying that there is no GPS device found. However when I run my code and unplug my serial port, my code will just hang until I plug it back in. This is my code right now: def GetGPS(): data = [] #Open com1: 9600,8,N,1 fi = serial.Serial(0, timeout = 1) print '[gps module] SERIAL PORT OPEN ON COM1:' can anyone help me please? Thanks. From lists at cheimes.de Sun Apr 20 16:23:32 2008 From: lists at cheimes.de (Christian Heimes) Date: Sun, 20 Apr 2008 22:23:32 +0200 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <480b8d58$0$26996$9b622d9e@news.freenet.de> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480b8d58$0$26996$9b622d9e@news.freenet.de> Message-ID: <480BA644.9090701@cheimes.de> Martin v. L?wis schrieb: > Can you give an example, please? http://trac.edgewall.org/ contains at least one example of a reference leak. It's holding up the release of 0.11 for a while. *scnr* The problem is also covered by the docs at http://docs.python.org/dev/library/sys.html#sys.exc_info Christian From gagsl-py2 at yahoo.com.ar Fri Apr 4 18:46:11 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 04 Apr 2008 19:46:11 -0300 Subject: displaying pgm file in python References: Message-ID: En Fri, 04 Apr 2008 19:07:59 -0300, wilson escribi?: > i converted an 8bit rgb .jpg file into .pgm using adobe photoshop and > a plugin from > http://photoshop.pluginsworld.com/plugins/adobe/362/richard-rosenman/portable-pixmap-importer-exporter.html > I want to check if this file can be properly displayed. > Image opening and show() in PIL fails to do it so i tried Tkinter > I checked the asci text of .pgm file ,it starts with a line P2 and > then several lines with integers..can someone tell me if there is a > way to display this properly P2 is a rather old variant that it's not in use anymore AFAIK. Try replacing P2 with P5; at least PIL should recognize it, I think. PIL can read and write .pgm, why don't you do the conversion with PIL? -- Gabriel Genellina From sergio.correia at gmail.com Tue Apr 22 11:24:16 2008 From: sergio.correia at gmail.com (Sergio Correia) Date: Tue, 22 Apr 2008 10:24:16 -0500 Subject: Financial Modeling with Python by Shayne Fletcher, Christopher Gardner In-Reply-To: References: Message-ID: Searched on google and couldn't find anything :S On Mon, Apr 21, 2008 at 11:28 AM, wrote: > Just saw at amazon.com reference to the following book that might be > available later this year: > > Financial Modeling with Python [IMPORT] (Hardcover) > by Shayne Fletcher (Author), Christopher Gardner (Author) > > Availability: Sign up to be notified when this item becomes available. > > Product Details > > * Hardcover: 352 pages > * Publisher: John Wiley and Sons Ltd (November 10, 2008) > * ISBN-10: 0470987847 > * ISBN-13: 978-0470987841 > * Shipping Weight: 1.7 pounds > > Would be nice if the authors or publisher could post to this group an > outline or draft table of contents of the book. > -- > http://mail.python.org/mailman/listinfo/python-list > From destroooooy at gmail.com Tue Apr 29 16:56:29 2008 From: destroooooy at gmail.com (destroooooy) Date: Tue, 29 Apr 2008 13:56:29 -0700 (PDT) Subject: string translate, replace, find and the forward slash References: <1030ffc2-1bbe-4539-881d-35bf59cacd11@34g2000hsh.googlegroups.com> Message-ID: <599157bd-5a4e-4133-afda-d446d0051aab@y38g2000hsy.googlegroups.com> On Apr 29, 4:50 pm, Arnaud Delobelle wrote: > destroooooy writes: > > Hi folks, > > I'm finding some (what I consider) curious behavior with the string > > methods and the forward slash character. I'm writing a program to > > rename mp3 files based on their id3 tags, and I want to protect > > against goofy characters in the in tags. So I do the following: > > > unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n" > > alt_chars = "_________________________" > > > s_artist.translate(maketranstable(unsafe_chars, alt_chars)) > > > which successfully replaces everything except for forward slashes (at > > least in the files I've tested so far). If I use the "replace()" > > method, it also does not work. Escaping the forward slash changes > > nothing. "find()" however, works, and thus I've resorted to: > > > if "/" in s_artist: > > (s_l, slash, s_r) = s_artist.partition("/") > > s_artist = "_".join([s_l, s_r]) > > > which is rather uncool. It works but I'd just like to know what the > > deal is. TIA. > > It works fine here: > > marigold:junk arno$ python > Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) > [GCC 4.0.1 (Apple Inc. build 5465)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > > >>> unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n" > >>> table = range(256) > >>> for c in unsafe_chars: table[ord(c)] = ord('_') > ... > >>> table = ''.join(chr(o) for o in table) > >>> 'Jon(&Mark/Steve)'.translate(table) > 'Jon__Mark_Steve_' > > -- > Arnaud Oooh. Let me try it that way. From Jiang.Adam at gmail.com Fri Apr 18 02:31:30 2008 From: Jiang.Adam at gmail.com (Adam) Date: Thu, 17 Apr 2008 23:31:30 -0700 (PDT) Subject: How to set proxy for a python script to run Message-ID: <94243913-cdcb-47a2-b000-a236fe0e8009@p25g2000hsf.googlegroups.com> Hi, everyone, I am using /usr/share/system-config-language/ language_gui.py in Python. For some reason I have to bypass the firewall using a proxy. I read the urllib reference and set http_proxy="my proxy". But it didn't work. Is there anyway that we can set the proxy? From dimitri.pater at gmail.com Tue Apr 22 18:52:20 2008 From: dimitri.pater at gmail.com (dimitri pater) Date: Wed, 23 Apr 2008 00:52:20 +0200 Subject: Python Success stories In-Reply-To: <965898d3-5bcf-4525-9f1c-e938a5f92117@m44g2000hsc.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <965898d3-5bcf-4525-9f1c-e938a5f92117@m44g2000hsc.googlegroups.com> Message-ID: http://code.google.com/appengine/docs/whatisgoogleappengine.html 2008/4/22 Ivan Illarionov : > On 22 ???, 14:25, azrael wrote: > [....] > > > This hurts. Please give me informations about realy famous > > aplications. > > What do you mean by "really famous"? > > Information is here: > http://www.python.org/about/quotes/ > > Are YouTube and Google famous enough? > > -- > Ivan > > > -- > http://mail.python.org/mailman/listinfo/python-list -- --- You can't have everything. Where would you put it? -- Steven Wright --- please visit www.serpia.org From duncan.booth at invalid.invalid Wed Apr 30 06:47:36 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 30 Apr 2008 10:47:36 GMT Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> Message-ID: Torsten Bronger wrote: > The biggest ugliness though is ",".join(). No idea why this should > be better than join(list, separator=" "). Besides, ",".join(u"x") > yields an unicode object. This is confusing (but will probably go > away with Python 3). It is only ugly because you aren't used to seeing method calls on string literals. Here are some arguably less-ugly alternatives: print str.join(", ", sequence) or: comma_separated = ", ".join will let you use: print comma_separated(sequence) or even just: SEPARATOR = ", " followed by: SEPARATOR.join(sequence) is no more ugly than any other method call. It would make perfect sense for join to be a method on stringlike objects if it simply returned an object of the same type as the object it is called on. As you point out, where it breaks down is a str separator can return a unicode result and that is confusing: if you want a unicode result perhaps you should be required to use a unicode separator but that isn't going to happen (at least not in Python 2.x). What definitely wouldn't make sense would be to make join a method of the list type (as it is in some other languages). From vivainio at gmail.com Wed Apr 23 11:09:57 2008 From: vivainio at gmail.com (Ville M. Vainio) Date: Wed, 23 Apr 2008 15:09:57 GMT Subject: Python "make" like tools (was Re: [ANN] DoIt 0.1.0 Released (build tool)) In-Reply-To: References: Message-ID: <9jIPj.124$RM4.68@read4.inet.fi> Eduardo Schettino wrote: >> I find the doit syntax a bit cumbersome, especially as you can avoid >> 'args' by just returning a lamda in 'action'. > > > My idea was to: do *not* add any new syntax (to avoid being > cumbersome). It is just python, you dont have to import or subclass Yeah, decorators get around this. > I though about using decorators in the beginning... but returning a > dictionary looked easier to implement and more flexible. one important > feature is how easy to define a group of task with the same action. > Take a look at the example below on running pychecker in all python > files from a folder. I couldnt figure out an easy way of doing it with > decorators. > > import glob; > pyFiles = glob.glob('*.py') > > def task_checker(): > for f in pyFiles: > yield {'action': "pychecker %s"% f, > 'name':f, > 'dependencies':(f,)} Perhaps you could do: for f in pyFiles: @task("checker") @depend(f) def check(): c("pychecker %s" % f) Never underestimate the magic that is nested scopes and name-agnostic function object creation... > Another advantage of using just a dictionary to define a task is that > it will be easy to read tasks from a text file (if it is very simple > and you dont need to write any python script). but not implemented > yet. It is easy with the above syntax as well. > I though about using decorator for simple python-tasks but in a different way: > > @task > def create_folder(path): > """Create folder given by "path" if it doesnt exist""" > if not os.path.exists(path): > os.mkdir(path) > return True > > so if your python function is a task and you will use it only once you > dont need to define a function for the 'action' and another function > to create the task. but not implement yet also. Yeah, this is what I consider much friendlier syntax (the aim is to not be much more verbose than make). > apart from one .py file installation (easy_install is not enough?) > thats what i am trying to do. easy_install is not really enough - it introduces a dependency that you can't get around by just shipping a short .py file with your project. This problem domain seems simple enough that it should be covered by a very short and simple module (Paul, the Waf you suggested was ~ 300k, no doubt caused by all the c compiler stuff that I don't need). 'Paver' seems to have the right idea: http://www.blueskyonmars.com/projects/paver/index.html But it's still *slightly* too big: http://bazaar.launchpad.net/~dangoor/paver/main/files From fredrik at pythonware.com Fri Apr 4 16:38:50 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 04 Apr 2008 22:38:50 +0200 Subject: Tokenizer inconsistency wrt to new lines in comments In-Reply-To: <8b3fa4cc-deb9-4748-a63c-a6c7e5dd92ba@59g2000hsb.googlegroups.com> References: <1ce40dcf-4a0a-4577-af3b-6a77ef71356c@f63g2000hsf.googlegroups.com> <6dd69a1f-96d0-4b91-b84b-a54794a31c70@u36g2000prf.googlegroups.com> <8b3fa4cc-deb9-4748-a63c-a6c7e5dd92ba@59g2000hsb.googlegroups.com> Message-ID: George Sakkis wrote: >> If it was a bug it has to violate a functional requirement. I can't >> see which one. > > Perhaps it's not a functional requirement but it came up as a real > problem on a source colorizer I use. I count on newlines generating > token.NEWLINE or tokenize.NL tokens in order to produce
tags. It > took me some time and head scratching to find out why some comments > were joined together with the following line. Now I have to check > whether a comment ends in new line and if it does output an extra
> tag.. it works but it's a kludge. well, the real kludge here is of course that you're writing your own colorizer, when you can just go and grab Pygments: http://pygments.org/ or, if you prefer something tiny and self-contained, something like the colorizer module in this directory: http://svn.effbot.org/public/stuff/sandbox/pythondoc/ (the element_colorizer module in the same directory gives you XHTML in an ElementTree instead of raw HTML, if you want to postprocess things) From castironpi at gmail.com Sun Apr 27 22:24:49 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sun, 27 Apr 2008 19:24:49 -0700 (PDT) Subject: Regular Expression - Matching Multiples of 3 Characters exactly. References: Message-ID: On Apr 27, 8:31?pm, blaine wrote: > Hey everyone, > ? For the regular expression gurus... > > I'm trying to write a string matching algorithm for genomic > sequences. ?I'm pulling out Genes from a large genomic pattern, with > certain start and stop codons on either side. ?This is simple > enough... for example: > > start = AUG stop=AGG > BBBBBBAUGWWWWWWAGGBBBBBB > > So I obviously want to pull out AUGWWWWWWAGG (and all other matches). > This works great with my current regular expression. > > The problem, however, is that codons come in sets of 3 bases. ?So > there are actually three different 'frames' I could be using. ?For > example: > ABCDEFGHIJ > I could have ABC DEF GHI or BCD EFG HIJ or CDE FGH IJx.... etc. > > So finally, my question. ?How can I represent this in a regular > expression? :) ?This is what I'd like to do: > (Find all groups of any three characters) (Find a start codon) (find > any other codons) (Find an end codon) > > Is this possible? It seems that I'd want to do something like this: (\w > \w\w)+(AUG)(\s)(AGG)(\s)* - where \w\w\w matches EXACTLY all sets of > three non-whitespace characters, followed by AUG \s AGG, and then > anything else. ?I hope I am making sense. ?Obviously, however, this > will make sure that ANY set of three characters exist before a start > codon. ?Is there a way to match exactly, to say something like 'Find > all sets of three, then AUG and AGG, etc.'. ?This way, I could scan > for genes, remove the first letter, scan for more genes, remove the > first letter again, and scan for more genes. ?This would > hypothetically yield different genes, since the frame would be > shifted. > > This might be a lot of information... I appreciate any insight. ?Thank > you! > Blaine Here's one idea (untested): s= { } for x in range( len( genes )- 3 ): s[ x ]= genes[ x: x+ 3 ] You might like Python's 'string slicing' feature. From kay.schluehr at gmx.net Fri Apr 18 19:19:38 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Fri, 18 Apr 2008 16:19:38 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <0ebcf70f-c6d6-4ee7-9ef8-7cd2221ef906@t12g2000prg.googlegroups.com> Message-ID: <879750f6-614a-45ed-8f18-f0b7ae5ea9a2@26g2000hsk.googlegroups.com> On 18 Apr., 23:09, Matimus wrote: > The reason it doesn't work is that you are unpacking the dictionary > with **, and you have done nothing to define any keys or define a > length. This is a non-issue. The class derives from dict; it has all the desired attributes. It is also not a problem in particular because these properties are not requested by format ( at least not in the code I have examined which was admittedly just a critical section that caused the exception ). > Adding to that... don't worry about py3k. Nobody is forcing you to > switch. In fact, you are encouraged not to until you are comfortable. > Py3k won't _break_ your code. You wrote the code for Python 2.x use it > in 2.x. Python 2.x probably has a good 5-10 years remaining. These advices start to get annoying. Software hardly ever exists in isolation for the sake of the beauty of the algorithm but is supplementary to a large framework/engine/ library. So if e.g. Django switches to 3 everyone who works with it has to switch sooner or later as well or lose track otherwise, no matter how long Python 1.5.2 or Python 2.5.2 or whatever version will be maintained. If Pythons code base becomes fragmented it will be harmful and affect almost everyones work. From john00587 at gmail.com Mon Apr 21 01:41:12 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:41:12 -0700 (PDT) Subject: egirl crack Message-ID: egirl crack http://cracks.00bp.com F R E E C R A C K S From hdante at gmail.com Wed Apr 2 09:25:26 2008 From: hdante at gmail.com (hdante) Date: Wed, 2 Apr 2008 06:25:26 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <47f36d23$0$28775$426a74cc@news.free.fr> Message-ID: <86afee6d-7022-4199-8af5-bff01c679714@c65g2000hsa.googlegroups.com> On Apr 2, 8:25 am, Bruno Desthuilliers wrote: > hdante a ?crit : > > > > > > Try Rails' ActiveRecord. Your problems should reduce to (lg lg > > 2)^(1/12). > > Correct me if I'm wrong, but IIRC ActiveRecord requires you use numeric > auto_increment fields for primary key. As far as I'm concerned, this is > a definitive no-no. Why is that so bad ? "But wait !, you cry. Shouldn't the primary key of my orders table be the order number or some other meaningful column ? Why use an artificial primary key such as id ? The reason is largely a practical one - the format of external data may change over time." (...) "Normally, Active Record takes care of creating new primary key values for records that you create and add to the database - they'll be ascending integers (possibily with some gaps in the sequence). However, if you override the primary key column's name, you also take on the responsibility of setting the primary key to a unique value before you save a new row." -- AWDWR > > > Seriously, you'll forget there's a relational database below. > > Why on earth are you using a RDBMS if you don't want it ? I for one *do* > care about using a *relational* database, and *don't* want to hide it > away. What I don't want is to have to build my queries as raw strings. > And that's where SQLAlchemy shines : it's not primarily an "ORM", it's > an higher-level Python/SQL integration tool that let you build your > queries as Python objects (and also, eventually, build an ORM if you > want to...). "Some object-relational mappers seek to eliminate the use of SQL entirely, hoping for object-oriented purity by forcing all queries through an OO layer. Active Record does not. It was built on the notion that SQL is neither dirty nor bad, just verbose in the trivial cases. (...) Therefore, you shouldn't feel guilty when you use find_by_sql to handle either performance bottlenecks or hard queries. Start out using the object-oriented interface for productivity and pleasure, and then dip beneath the surface for a close-to-the-metal experience when you need to do so." -- AWDWR PS. That's okay to use a RDBMS. What I don't want is to use two programming paradigms, especially, considering the "object-relational impedance mismatch". From ivan.illarionov at gmail.com Tue Apr 22 00:04:16 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Tue, 22 Apr 2008 04:04:16 +0000 (UTC) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> <85c14b14-9302-41bb-9270-b7cdd65098b0@c65g2000hsa.googlegroups.com> Message-ID: On Mon, 21 Apr 2008 16:10:05 -0700, George Sakkis wrote: > On Apr 21, 5:30 pm, Ivan Illarionov wrote: > >> On 22 ???, 01:01, Peter Otten <__pete... at web.de> wrote: >> >> > Ivan Illarionov wrote: >> > > And even faster: >> > > a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, >> > > len(s), 3)))) >> > > if sys.byteorder == 'little': >> > > a.byteswap() >> >> > > I think it's a fastest possible implementation in pure python >> >> > Clever, but note that it doesn't work correctly for negative numbers. >> > For those you'd have to prepend "\xff" instead of "\0". >> >> > Peter >> >> Thanks for correction. >> >> Another step is needed: >> >> a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, >> len(s), 3)))) >> if sys.byteorder == 'little': >> a.byteswap() >> result = [n if n < 0x800000 else n - 0x1000000 for n in a] >> >> And it's still pretty fast :) > > Indeed, the array idea is paying off for largeish inputs. On my box > (Python 2.5, WinXP, 2GHz Intel Core Duo), the cutoff point where > from3Bytes_array becomes faster than from3Bytes_struct is close to 150 > numbers (=450 bytes). > > The struct solution though is now almost twice as fast with Psyco > enabled, while the array doesn't benefit from it. Here are some numbers > from a sample run: > > *** Without Psyco *** > size=1 > from3Bytes_ord: 0.033493 > from3Bytes_struct: 0.018420 > from3Bytes_array: 0.089735 > size=10 > from3Bytes_ord: 0.140470 > from3Bytes_struct: 0.082326 > from3Bytes_array: 0.142459 > size=100 > from3Bytes_ord: 1.180831 > from3Bytes_struct: 0.664799 > from3Bytes_array: 0.690315 > size=1000 > from3Bytes_ord: 11.551990 > from3Bytes_struct: 6.390999 > from3Bytes_array: 5.781636 > *** With Psyco *** > size=1 > from3Bytes_ord: 0.039287 > from3Bytes_struct: 0.009453 > from3Bytes_array: 0.098512 > size=10 > from3Bytes_ord: 0.174362 > from3Bytes_struct: 0.045785 > from3Bytes_array: 0.162171 > size=100 > from3Bytes_ord: 1.437203 > from3Bytes_struct: 0.355930 > from3Bytes_array: 0.800527 > size=1000 > from3Bytes_ord: 14.248668 > from3Bytes_struct: 3.331309 > from3Bytes_array: 6.946709 > > > And here's the benchmark script: > > import struct > from array import array > > def from3Bytes_ord(s): > return [n if n<0x800000 else n-0x1000000 for n in > ((ord(s[i])<<16) | (ord(s[i+1])<<8) | ord(s[i+2]) > for i in xrange(0, len(s), 3))] > > unpack_i32be = struct.Struct('>l').unpack def from3Bytes_struct(s): > return [unpack_i32be(s[i:i+3] + '\0')[0]>>8 > for i in xrange(0,len(s),3)] > > def from3Bytes_array(s): > a = array('l', ''.join('\0' + s[i:i+3] > for i in xrange(0,len(s), 3))) > a.byteswap() > return [n if n<0x800000 else n-0x1000000 for n in a] > > > def benchmark(): > from timeit import Timer > for n in 1,10,100,1000: > print ' size=%d' % n > # cycle between positive and negative buf = > ''.join(struct.pack('>i', 1234567*(-1)**(i%2))[1:] > for i in xrange(n)) > for func in 'from3Bytes_ord', 'from3Bytes_struct', > 'from3Bytes_array': > print ' %s: %f' % (func, > Timer('%s(buf)' % func , > 'from __main__ import %s; buf=%r' % (func,buf) > ).timeit(10000)) > > > if __name__ == '__main__': > s = ''.join(struct.pack('>i',v)[1:] for v in > [0,1,-2,500,-500,7777,-7777,-94496,98765, > -98765,8388607,-8388607,-8388608,1234567]) > assert from3Bytes_ord(s) == from3Bytes_struct(s) == > from3Bytes_array(s) > > print '*** Without Psyco ***' > benchmark() > > import psyco; psyco.full() > print '*** With Psyco ***' > benchmark() > > > George Comments: You didn't use the faster version of array approach: ''.join('\0' + s[i:i+3] for i in xrange(0,len(s), 3)) is slower than '\0' + '\0'.join(s[i:i+3] for i in xrange(0,len(s), 3)) To Bob Greschke: Struct is fast in Python 2.5 with struct.Struct class. Array approach should work with Python 2.3 and it's probably the fastest one (without psyco) with large inputs: def from3bytes_array(s): a = array.array('i', '\0' + '\0'.join([s[i:i+3] for i in xrange(0, len(s), 3)])) a.byteswap() # if your system is little-endian return [n >= 0x800000 and n - 0x1000000 or n for n in a] -- Ivan From lscbtfws at gmail.com Sat Apr 26 12:08:13 2008 From: lscbtfws at gmail.com (lscbtfws at gmail.com) Date: Sat, 26 Apr 2008 09:08:13 -0700 (PDT) Subject: xpand rally crack Message-ID: <53146891-63d7-4760-af0d-5b7ac14a41f0@h1g2000prh.googlegroups.com> xpand rally crack http://cracks.00bp.com F R E E C R A C K S From mensanator at aol.com Wed Apr 16 15:59:47 2008 From: mensanator at aol.com (Mensanator) Date: Wed, 16 Apr 2008 12:59:47 -0700 (PDT) Subject: Finally had to plonk google gorups. References: <28d12cc8-5375-4e95-8e37-f872d238a1bd@b64g2000hsa.googlegroups.com> <6cadnYCFdNpR2ZvVnZ2dnUVZ_tPinZ2d@visi> <48064885$0$18426$39cecf19@news.twtelecom.net> Message-ID: <647beab1-3d5d-41cb-b9b7-f46184ecc072@b64g2000hsa.googlegroups.com> On Apr 16, 1:43?pm, Severian wrote: > Grant Edwards wrote: > > On 2008-04-16, Mensanator wrote: > >> On Apr 16, 9:19 am, Grant Edwards wrote: > >>> This morning almost half of c.l.p was spam. ?In order to try > >>> to not tar both the benign google group users and the > >>> malignant ones with the same brush, I've been trying to kill > >>> usenet spam with subject patterns. ?But that's not a battle > >>> you can win, so I broke down and joined all the other people > >>> that just killfile everything posted via google.groups. > >> Not very bright, eh? > > >>> AFAICT, if you're a google groups user your posts are not being > >>> seen by many/most experienced (read "non-google-group") users. > >>> This is mainly the fault of google who has refused to do > >>> anything to stem the flood of span that's being sent via Google > >>> Groups. > >> Duh. > > > My. ?That was certainly a well-reasoned and well-written > > response. > > Well, it did come from an AOL user posting from Google groups . Hey, he wasn't supposed to see that! He's plonked Google Groups, hasn't he? Looks like you'll have to reconsider how well-reasoned AOL users are. Who use Google because AOL terminated their news service - because of Google. Smart move, eh? From lists at cheimes.de Wed Apr 30 15:19:38 2008 From: lists at cheimes.de (Christian Heimes) Date: Wed, 30 Apr 2008 21:19:38 +0200 Subject: Python 2.6 and wrapping C libraries on Windows In-Reply-To: References: Message-ID: L. Lindstrom schrieb: > I have read that Python extension modules must link to the same C > run-time as the Python interpreter. This I can appreciate. But does this > requirement extend to the C libraries an extension module wraps. The > case in point is Pygame and SDL. The Pygame extension modules are built > with distutils, so for Python 2.6 using Visual Studio 2008 should ensure > the .pyd files link to msvcr90.dll. But SDL is built using Msys/MinGW > and the configure/make tool chain. This fails when linking to > msvcr90.dll since the small test programs configure builds lack manifest > files. They fail to load msvcr90.dll, raising an R6034 error instead. So > besides heap management and FILE pointers, is there any reason SDL, or > any C dependency, needs to link to the same C run-time as Python? If I > ensure SDL frees memory it allocates and does not directly access a file > opened by Python can I just use another C run-time such as msvcrt? > Your analysis of the problem and the implication of mixing CRTs is correct. However ... It should be trivial to modify the build systemof SDL so that the manifest is integrated into the DLLs. Everything else is a hack. It *should* work and in reality it *does* work for most cases. But someday you'll hit a solid wall and get strange and hard to debug segfaults. It's in your own interest to get it right in the first place. And you'd serve the Python community greatly by providing a nice tutorial how to modify 3rd party builds. *hint* :) If you need any help feel free to contact me. The new build system is mostly my work with help from Martin, Amaury and other core developers. Christian From mattheww at chiark.greenend.org.uk Sun Apr 20 13:13:39 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 20 Apr 2008 18:13:39 +0100 (BST) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> <4d543ba1-c601-4490-8739-e42b46fc2236@k37g2000hsf.googlegroups.com> Message-ID: Arnaud Delobelle wrote: > By 'eval', I guess you mean 'exec' :) Yes. Shows how often I use either. -M- From ott.deb at gmail.com Thu Apr 17 15:07:14 2008 From: ott.deb at gmail.com (ott.deb at gmail.com) Date: Thu, 17 Apr 2008 12:07:14 -0700 (PDT) Subject: movie collector crack Message-ID: movie collector crack http://cracks.12w.net F R E E C R A C K S From deets at nospam.web.de Tue Apr 15 09:13:44 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 15 Apr 2008 15:13:44 +0200 Subject: hw to program on python References: <2732d09a-b0e6-4ae6-a826-9fa375fb3e86@q10g2000prf.googlegroups.com> Message-ID: <66jo14F2jfjnbU1@mid.uni-berlin.de> ashish wrote: > hi , > python experts i want some help from u people just mail me how to > write scripts for web applications (like form coding for login page, > etc). > > > i m waiting.... for ur reply by While you are waiting, would a nice back-rub & and a good portion of powder sugar gently blown up your behind be in order? I'd plain love to drop by & give that to you, to make the dreaded waiting for the amassing expert advice a bit more comfortable! Diez From Plemelle at comcast.net Wed Apr 2 21:57:31 2008 From: Plemelle at comcast.net (Paul Lemelle) Date: Wed, 02 Apr 2008 19:57:31 -0600 Subject: Pexpect question. References: Message-ID: Jorgen, Thanks for your reply. The ssh function is just a small part of what I would like to accomplish. And yes, chk is undefined, I was trying to figure out why control was not being returned from the sshcon funciton. I looked for pexpect doucment on http://www.noah.org/wiki/Pexpect, but the documentaiton link appear to be broken. Could you recommend another site? Thanks, Paul On 30 Mar 2008 21:39:46 GMT, Jorgen Grahn wrote: >On Fri, 28 Mar 2008 08:12:36 -0700 (PDT), Paul Lemelle wrote: >> I am trying separate a script that users pexpect into >> various functions within the same expect session. The >> problem is that the function does not return control >> back Main. > >I do not understand what that sentence means. > >> Any insight into this issue would be >> greatly appreciated. Below is sample code of the >> problem. > >First, what is the purpose of this program? It seems to be a more >tedious way to get an ssh login to some Unix host. Ssh can be >configured to do many things; maybe you do not need Python at all? > >Second, it will fail as soon as you use the undefined object 'chk'. > >Third, if "not return control back Main" means "sshcon() does not >return", then it is by design. You call go.interact(), which hands >over control to the user until he types an escape sequence. See the >pexpect documentation. > >Fourth, sshcon() does not handle the full dialogue ssh can give you. >If you get "are you sure you want to connect" etc, you will hang until >pexpect.TIMEOUT is thrown. > >I have reformatted the source code to be more readable: > >> import pexpect >> >> def sshcon(host, password): >> go = pexpect.spawn ('/usr/bin/ssh -l root %s ' % host) >> go.expect ('Password: ') >> go.sendline (password) >> go.interact() >> >> #get node info for both clusters. >> C1_node = raw_input("Enter the ip address for node on cluster 1: ") >> C1_pass = raw_input("Enter the password for the node on cluster 1: ") >> >> sshcon(C1_node, C1_pass) >> >> #go to the path >> chk.expect('# ') >> chk.sendline('ls') >> >> chk.interact() > >/Jorgen From Dodin.Roman at gmail.com Fri Apr 25 05:32:36 2008 From: Dodin.Roman at gmail.com (hellt) Date: Fri, 25 Apr 2008 02:32:36 -0700 (PDT) Subject: Little novice program written in Python References: <0cecfed4-17e7-4e4d-9dbe-3f0ac8316c1f@y21g2000hsf.googlegroups.com> Message-ID: On 25 ???, 13:29, Arnaud Delobelle wrote: > hellt writes: > > my variant of the sieve > > Since you posted it, you are also looking for advice to improve your > code ;) > > > def GetPrimes(N): > > arr = [] > > for i in range(1,N+1): > > arr.append(i) > > This is the same as: > arr = range(1, N+1) > !-) > > > #Set first item to 0, because 1 is not a prime > > arr[0]=0 > > #sieve processing > > s=2 > > remove this line > > > while s < math.sqrt(N): > > for s in xrange(2, int(math.sqrt(N))+1): > > > if arr[s-1] != 0: > > if arr[s-1]: > > > j = s*s > > remove this line > > > while j <= N: > > for j in xrange(s*s, N+1, s): > > > arr[j-1] = 0 > > j += s > > remove this line > > > s += 1 > > remove this line > > > return [x for x in arr if x != 0] > > return filter(None, arr) > > Altogether now: > > def getprimes(N): > arr = range(1, N+1) > arr[0] = 0 > for s in xrange(2, int(math.sqrt(N))+1): > if arr[s-1]: > for j in xrange(s*s, N+1, s): > arr[j-1] = 0 > return filter(None, arr) > > It's the same, but it looks a bit less like the litteral translation > of some C code. > > Lastly, the lines: > > for j in xrange(s*s, N+1, s): > arr[j-1] = 0 > > from above can be condensed using extended slices: > > arr[s*s-1 : N+1 : s] = [0] * (N/s - s + 1) > > (If I can count correctly) > > Giving the following, slightly shorter and probably faster: > > def getprimes(N): > arr = range(1, N+1) > arr[0] = 0 > for s in xrange(2, int(math.sqrt(N))+1): > if arr[s-1]: > arr[s*s-1 : N+1 : s] = [0] * (N/s - s + 1) > return filter(None, arr) > > If it was me, I would include 0 in the array, giving the slightly simpler: > > def getprimes(N): > arr = range(N+1) > arr[1] = 0 > for s in xrange(2, int(math.sqrt(N))+1): > if arr[s]: > arr[s*s : N+1 : s] = [0] * (N/s - s + 1) > return filter(None, arr) > > (I think) > > This all needs to be tested. > > -- > Arnaud nice, but i'm a newbie to python too, so some things for me seems a liitle complicated))) From dolloffdelvpg at gmail.com Wed Apr 16 08:10:10 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:10:10 -0700 (PDT) Subject: songs by taylor swift Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From bskaplan14 at yahoo.com Wed Apr 23 05:41:21 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Wed, 23 Apr 2008 02:41:21 -0700 (PDT) Subject: [Python 2.4/2.5] subprocess module is sorely deficient? Message-ID: <811891.72800.qm@web39208.mail.mud.yahoo.com> I don't know about all Linux distros, but my Ubuntu machine (8.04 Beta), has the 'TERM' (xterm) and 'COLORTERM' (gnome-terminal) keys in os.environ. You might be able to use that to ensure that the terminal is installed, but you should probably look at a couple of other popular distros first to make sure that the key is there. ----- Original Message ---- From: Harishankar To: python-list at python.org Sent: Wednesday, April 23, 2008 5:31:54 AM Subject: Re: [Python 2.4/2.5] subprocess module is sorely deficient? On Wednesday 23 Apr 2008 14:46:20 Christian Heimes wrote: > Harishankar schrieb: > > Is there any platform independent way to launch a terminal window from a > > desktop (Windows, Linux, etc.)? > > No, there isn't. It usually not possible to create a graphical terminal > window on a remote server. > > Christian Ah, well, since my application is a desktop tool and it requires a GUI I'm doing something like this: However, I have to then force the user to use xterm (which is a popular/common X Terminal) if (sys.platform.startswith ('win'): # launch the windows cmd.exe with the command ... else: # warn the user that xterm is required and then launch xterm ... -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org -- http://mail.python.org/mailman/listinfo/python-list ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From casey.mcginty at gmail.com Tue Apr 22 06:36:57 2008 From: casey.mcginty at gmail.com (Casey McGinty) Date: Tue, 22 Apr 2008 00:36:57 -1000 Subject: Getting PyUnit to run Package Test Modules In-Reply-To: References: Message-ID: I came up with this solution based off of the __import__ python reference page. If I missed anything let me know. def suite(): # create TestSuite object alltests = unittest.TestSuite() # load all modules define in the module list for name in mod_to_test: print name mod = __import__(name) components = name.split('.') for comp in components[1:]: print comp mod = getattr(mod,comp) alltests.addTest(unittest.findTestCases(mod)) return alltest On Tue, Apr 22, 2008 at 12:12 AM, Casey McGinty wrote: > Hopefully this is an easy question for someone to answer. I have a > directory structure like so: > > alltest.py > prog.py > ../package > __init__.py > mod1.py > test_mod1.py > modn. py > (and so on...) > > Each test_mod*.py file contains some PyUnit test cases. I am using the > following code in alltest.py to run all the unit test modules: > > mod_to_test = [package.mod1, package.mod2] > > def suite(): > # create TestSuite object > alltests = unittest.TestSuite() > # load all modules define in the module list > for module in map(__import__, mod_to_test): > alltests.addTest(unittest.findTestCases(module)) > return alltest > > if __name__ == '__main__': > unittest.main(defaultTest='suite') > > My guess is there is something needed in __init__.py to get this work. Any > advice? > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eyal.teutsch at gmail.com Thu Apr 24 01:47:52 2008 From: eyal.teutsch at gmail.com (Eyal Teutsch) Date: Thu, 24 Apr 2008 08:47:52 +0300 Subject: couple of optparse questions Message-ID: <2b72fcea0804232247v1ee699e2h57e9bdd38d35ea6e@mail.gmail.com> I have a bunch of command line scripts which I would like them to partially share command line options. For the sake of example, let's say I have the following 2 scripts: monitor_io.py - accepts 'interval' and 'disk' arguments: monitor_io.py -i 30 -d disk1 monitor_processes.py - accepts 'interval' and '# of procesess' arguments: monitor_processes.py -i 15 -n 8 So what I would like to do, is to have a shared command line parser (let's call it parser.py) that would selectively use the parser.add_option calls according to the arguments that were passed to it when it was instantiated by the above command line scripts. So, in monitor_io.py, the parser would be instantiated as follows: parsamon = parse(['interval', 'disk']) and in parser.py, I would have a dictionary of all possible options: self.options['interval'] ='"-c", action="callback", dest="interval", type="int", callback=self.verify_type, callback_kwargs={"action":"int"}, help="the execution interval"' # does not work and then selectively add specific options to the parser according to the arguments passed to parser.py, for instance: parser.add_option(self.options['interval']) The above though wouldn't work as what seems to me a quotation error. The following, would actually work: self.options['interval']='-c' while this one here would not: self.options['interval']='-c, action="store_true"' # does not work it terminates with the following error: optparse.OptionError: invalid long option string '-c, action="store_true"': must start with --, foll owed by non-dash It would accept though a double-dash (which isn't what I want): self.options['interval']='--c, action="store_true"' # works but then again, the full option using a double dash, would not work: self.options['interval']='"--c", action="callback", dest="interval", type="int", callback=self.verify_type, callback_kwargs={"action":"int"}, help="the execution interval"' # does not work optparse.OptionError: invalid long option string '"--c", action="callback", dest="mint_interval", ty pe="int", callback=self.verify_type, callback_kwargs={"action":"int"}, help="the mint interval"': mu st start with --, followed by non-dash So, my first question is how to accomplish the above task? My second question is that I found the fact that optparse returns the values as properties of the object rather than returning a dictionary with all parsed options a bit inconvenient, as the latter approach would offer convenient ways to iterate/verify the parsed arguments returned. Any thoughts on this? Thanks.. -------------- next part -------------- An HTML attachment was scrubbed... URL: From andre.roberge at gmail.com Tue Apr 1 17:28:35 2008 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Tue, 1 Apr 2008 14:28:35 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <47f27a74$0$20512$426a74cc@news.free.fr> Message-ID: <0236d0aa-de8c-4636-a1d8-300d5d8e1818@i29g2000prf.googlegroups.com> On Apr 1, 3:09 pm, Bruno Desthuilliers wrote: > sprad a ?crit : > > > > > I'm a high school computer teacher, and I'm starting a series of > > programming courses next year (disguised as "game development" classes > > to capture more interest). The first year will be a gentle > > introduction to programming, leading to two more years of advanced > > topics. > > > I was initially thinking about doing the first year in Flash/ > > ActionScript, and the later years in Java. My reasoning is that Flash > > has the advantage of giving a quick payoff to keep the students > > interested while I sneak in some OOP concepts through ActionScript. > > Once they've gotten a decent grounding there, they move on to Java for > > some more heavy-duty programming. > > > I've never used Python, but I keep hearing enough good stuff about it > > to make me curious. > > > So -- would Python be a good fit for these classes? > > IMHO, yes, definitively - except that it won't introduce concepts like > static typing and primitive types, since it's dynamically typed and 100% > object. OTHO, it'll let you introduce quite a lot of more advanced > topics (operator overloading, metaclasses, higher-order functions, > closures, partial application etc) that you're less likely to grasp > using Java. > > > Could it equal > > Java as the later heavy-duty language? > > If you mean "is it possible to use Python to write real-world, > non-trivial applications", then the answer is obviously yes. Python's > use range from Q&D admin script to full-blown web application server > including vector graphic GUI apps, scientific data analysis and plotting > and game developpment and/or scripting. > > > Does it have enough quickly- > > accessible sparklies to unseat Flash? > > Since you plan to lure poor schoolboys in by pretending to teach them > game programming, you may want to have a look at pygame: > > http://www.pygame.org/news.html > > > I want to believe. Evangelize away. > > "Then I saw Pygame, now I'm a believer".... !-) There is also pyglet which is quite impressive and easy to use. Andr? From steve at holdenweb.com Tue Apr 8 18:22:55 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 18:22:55 -0400 Subject: Converting a tuple to a list In-Reply-To: <00ba01c899c5$14528ae0$0a01a8c0@mobile> References: <00ba01c899c5$14528ae0$0a01a8c0@mobile> Message-ID: Gabriel Ibanez wrote: > Hi all .. > > I'm trying to using the map function to convert a tuple to a list, without > success. > > I would like to have a lonely line that performs the same as loop of the > next script: > > ------------------------------------------- > # Conveting tuple -> list > > tupla = ((1,2), (3,4), (5,6)) > > print tupla > > lista = [] > for a in tupla: > for b in a: > lista.append(b) > print lista > ------------------------------------------- > > Any idea ? > > Thanks ... > > # Gabriel > list(tupla) would probably do it. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From mail2spj at yahoo.com Fri Apr 18 16:42:28 2008 From: mail2spj at yahoo.com (SPJ) Date: Fri, 18 Apr 2008 13:42:28 -0700 (PDT) Subject: Error with win32com client on windows 2003 server Message-ID: <867065.32400.qm@web50107.mail.re2.yahoo.com> I got the reason for why this is happening. MS office is not installed on that server. Thanks anyways.. SPJ ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ From claird at lairds.us Tue Apr 29 11:46:30 2008 From: claird at lairds.us (Cameron Laird) Date: Tue, 29 Apr 2008 15:46:30 +0000 Subject: Who makes up these rules, anyway? (was: Python-URL! - weekly Python news and links (Apr 28)) References: Message-ID: In article , Gabriel Genellina wrote: . . . > Explicit variable declaration for functions: > >http://groups.google.com/group/comp.lang.python/browse_thread/thread/6c4a508edd2fbe04/ . . . A reader notes that this thread actually lived during 2004 (!) (entirely during January 2004, in fact), and mildly questions its pertinence to what bills itself as "weekly Python news ..." Well might the reader wonder. "Python-URL!" has long chosen to err on the side of INclusiveness in its categorizations, even to the occasional point of apparent frivolity. As Harlan Ellison used to advise his readers, think of it as a bonus, rather than a mistake. It's our tradition, too. From george.sakkis at gmail.com Sun Apr 20 19:02:26 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Sun, 20 Apr 2008 16:02:26 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> <48a1d10c-87cb-43c3-83f4-9c331fc1d818@m1g2000pre.googlegroups.com> Message-ID: On Apr 20, 6:54?pm, Dan Bishop wrote: > On Apr 20, 11:42 am, Matthew Woodcraft > > > > wrote: > > Christian Heimes ? wrote: > > > >> I feel that including some optional means to block code would be a big > > >> step in getting wider adoption of the language in web development and > > >> in general. ?I do understand though, that the current strict indenting > > >> is part of the core of the language, so... thoughts? > > > Why should Python repeat the mistakes other languages did with SSI or > > > inline code? Python favors the MVC separation of code and layout. > > > An alternative scheme for describing the block structure could be > > useful in other cases, though. For example, if you wanted to support > > putting snippets of Python in configuration files, or spreadsheet > > cells. > > > There's no need to support the new scheme in .py files, so it seems to > > me that this doesn't have to be done in the core language. All that's > > needed is a variant of 'eval' which expects the alternate scheme, and > > that could be prototyped just using text manipulation and the normal > > 'eval'. > > We wouldn't even need that. ?Just a new source encoding. ?Then we > could write: > > # -*- coding: end-block -*- > > def _itoa(num, base): > """Return the string representation of a number in the given base.""" > if num == 0: > return DIGITS[0] > end if > negative = num < 0 > if negative: > num = -num > end if > digits = [] > while num: > num, last_digit = divmod(num, base) > digits.append(DIGITS[last_digit]) > end while > if negative: > digits.append('-') > end if > return ''.join(reversed(digits)) > end def A great example of why something like this would never fly in standard Python. From Vern.Muhr at gmail.com Mon Apr 28 14:26:52 2008 From: Vern.Muhr at gmail.com (VernM) Date: Mon, 28 Apr 2008 11:26:52 -0700 (PDT) Subject: cytpes **int Message-ID: <56674130-c04e-403e-8364-92cbd158b2f0@b9g2000prh.googlegroups.com> I am using ctypes to wrap a set of functions in a DLL. It has been going very well, and I am very impressed with ctypes. I want to call a c function with a signature of: void func(int **cube), where the array if ints in cube is modified by func. I want to setup cube with int values, and access them after the call to func. I unerstand how to setup the ctypes array, but how do I pass **cube to the function, and how do I access the results? From db3l.net at gmail.com Sun Apr 27 22:00:17 2008 From: db3l.net at gmail.com (David Bolen) Date: Sun, 27 Apr 2008 22:00:17 -0400 Subject: [py2exe] What to download when updating? References: Message-ID: Gilles Ganault writes: > Hello > > Out of curiosity, if I recompile a Python (wxPython) app with > py2exe, can I have customers just download the latest .exe, or are > there dependencies that require downloading the whole thing again? It will depend on what you changed in your application. The most likely file that will change is your library.zip file since it has all of your Python modules. I believe that with py2exe the main exe is typically a standard stub, so it need not change, but it can if the top level script is named differently since it has to execute it. The other files are binary dependencies, so you may add or remove them during any given build process depending on what modules you may newly import (or have removed the use of). In the end, you could in theory just compare the prior version distribution tree to the new version is simplest. But then you'd need to package up an installer that did the right thing on the target system. To be honest, just packaging it up as a new version and putting it into a standard installer (as with InnoSetup or NSIS) and letting the installer keep track of what to do when installing the new version on top of an existing version is generally simplest overall, albeit larger. But during internal development or other special cases, I've definitely just distributed updated library.zip files without any problem. -- David From michael at stroeder.com Tue Apr 22 17:14:28 2008 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Tue, 22 Apr 2008 23:14:28 +0200 Subject: python-ldap: searching without specifying an OU? In-Reply-To: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> References: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> Message-ID: hotani wrote: > I am attempting to pull info from an LDAP server (Active Directory), > but cannot specify an OU. In other words, I need to search users in > all OU's, not a specific one. If the user you're binding with has the right in AD to search the whole subtree you can start searching at the domain-level. > con = ldap.initialize("ldap://server.local") > con.simple_bind_s('user at domain', pass) ^^^^^^^^^^^^ Just for the records: A simple bind with userPrincipalName only works on AD. It's not a LDAPv3 compliant bind request then (which requires a full DN). > result = con.search_ext_s( > 'OU=some office, DC=server, DC=local', > ldap.SCOPE_SUBTREE, > "sAMAccountName=username", ['mail'] > )[0][1] > > for i in result: > print "%s = %s" (i, result[i]) > > But i really need it to not require an OU. It should work. I'm doing this quite often. > When I remove that part, it breaks. What does "it breaks" mean? Any exception raised by python-ldap? > Maybe a different search function? Nope. Ciao, Michael. From sisson.j at gmail.com Mon Apr 14 15:40:57 2008 From: sisson.j at gmail.com (J Sisson) Date: Mon, 14 Apr 2008 14:40:57 -0500 Subject: How to make python run faster In-Reply-To: References: <0baa301a-ec8c-48ef-b30e-f9c80f72e5af@u12g2000prd.googlegroups.com> Message-ID: <4297a9020804141240s7098cd3g381e296dade11a72@mail.gmail.com> 2008/4/14 : > On Apr 14, 8:48 am, ??? wrote: > > > But, it is still not as fast as 1. > > > So if speed is the #1 design goal, use pure C. If not, develop in > pure Python and, if the application is too slow, profile the code and > look for bottlenecks that can be optimized. There's a good chance > that they can be resolved algorithmically, not by simply dropping down > to C. > -- > http://mail.python.org/mailman/listinfo/python-list > Profiling python code can help spot bottlenecks that would *still be bottlenecks* if translated directly to C, so I definitely agree here...given a big enough problem space, a bad algorithm will run slow(er) regardless of language or hardware. -- Computers are like air conditioners... They quit working when you open Windows. -------------- next part -------------- An HTML attachment was scrubbed... URL: From antroy at gmail.com Mon Apr 21 08:14:13 2008 From: antroy at gmail.com (Ant) Date: Mon, 21 Apr 2008 05:14:13 -0700 (PDT) Subject: Somebody *really* got fond of python References: <673bprF2n44icU1@mid.uni-berlin.de> Message-ID: On Apr 21, 12:23 pm, "Diez B. Roggisch" wrote: > http://xkcd.com/413/ > > :) Didn't realise you'd posted this when I posted my "Batteries Included..." post. Amused me as well! From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 22 11:18:35 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 22 Apr 2008 17:18:35 +0200 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: <1510fd01-5e13-4124-a3fe-ff69d9011ebb@d1g2000hsg.googlegroups.com> References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <6760jfF2n3bn1U1@mid.uni-berlin.de> <6bec3c67-689a-4df2-848f-d3936a143024@f36g2000hsa.googlegroups.com> <1510fd01-5e13-4124-a3fe-ff69d9011ebb@d1g2000hsg.googlegroups.com> Message-ID: <480e01c2$0$24570$426a74cc@news.free.fr> Carl Banks a ?crit : > On Apr 22, 10:36 am, George Sakkis wrote: >> On Apr 22, 10:22 am, Carl Banks wrote: >> >>> Java (for example) allows a class to share behavior with only one >>> other class, and that *severely* limits the opportunities to minimize >>> redundancy. >> Not really; composition is usually a better way to share functionality >> and reduce redundancy than inheritance. > > I should have known this was coming. I disagree: inheritance is a > much better way to share behavior. > (snip) > With composition you're burdening the user with having to learn the > shared relationships that ought to be implementation details of the > class. E.g., > > obj.action_style.perform_action() > > With inheritance, the user doesn't have to worry about these > relationships. > > obj.perform_action() > (snip) Unless you use composition + delegation (which is a PITA in Java and close to a no-brainer in Python). In which case this is mostly transparent to the user code. Anyway, in Python, inheritence is kind of a special case of composition+delegation. From theller at ctypes.org Thu Apr 3 07:21:13 2008 From: theller at ctypes.org (Thomas Heller) Date: Thu, 03 Apr 2008 13:21:13 +0200 Subject: State of ctypes Support on HP-UX? In-Reply-To: <200804031153.26234.phil@riverbankcomputing.com> References: <200804031153.26234.phil@riverbankcomputing.com> Message-ID: Phil Thompson schrieb: > Could somebody confirm how well ctypes is supported on HP-UX (for both PA-RISC > and Itanium) for both Python v2.4 and v2.5? > > I don't have access to an HP system and Google doesn't come up with a > definitive answer (which may just mean it works fine, but prior experience > with HP means I'd like more specific assurances). > > Thanks, > Phil I cannot answer your question, but if you want to try it out yourself there is the HP testdrive program: http://www.testdrive.hp.com/ Thomas From j.spies at hccnet.nl Thu Apr 10 05:54:52 2008 From: j.spies at hccnet.nl (Jaap Spies) Date: Thu, 10 Apr 2008 11:54:52 +0200 Subject: wrapping C functions in python In-Reply-To: References: <54b165660804091322w690e5e64x85c3d8f082b411b2@mail.gmail.com> Message-ID: <32a58$47fde3ed$d4785a98$31444@cache4.tilbu1.nb.home.nl> Paul Anton Letnes wrote: > Hi, and thanks. > > > However, being a newbie, I now have to ask: What is SWIG? I have heard > the name before, but haven't understood what it is, why I need it, or > similar. Could you please supply some hints? > [...] >>> >>> I am a "scientific" user of Python, and hence have to write some >>> performance >>> critical algorithms. Right now, I am learning Python, so this is a >>> "newbie" >>> question. >>> >>> I would like to wrap some heavy C functions inside Python, >>> specifically a >>> wavelet transform. I am beginning to become aquainted with the functions >>> PyArg_ParseTuple() and Py_BuildValue(). However, I am unable to >>> figure out >>> how to pass Python list -> C function or C array -> return value in >>> Python. >>> I manage to build and run the C function, print to screen, pass >>> string as >>> argument, return an int, etc. The thing which is missing is the magic >>> array/list... >>> >>> >>> Thanks in advance! I fart in your general direction. >>> Paul. Maybe you should have a look at Cython: http://www.cython.org/ and Sage: http://www.sagemath.org/ Jaap From hobgoodoreneyhb at gmail.com Tue Apr 22 11:38:57 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:38:57 -0700 (PDT) Subject: what is a keygen Message-ID: <9daad734-30de-47b3-888e-ec2811ee12cf@a22g2000hsc.googlegroups.com> what is a keygen http://cracks.12w.net F R E E C R A C K S From kamhung.soh at gmail.com Wed Apr 16 20:08:53 2008 From: kamhung.soh at gmail.com (Kam-Hung Soh) Date: Wed, 16 Apr 2008 17:08:53 -0700 (PDT) Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <66efcc2e-d806-4cb1-966c-178b41b183ba@d1g2000hsg.googlegroups.com> Message-ID: On Apr 17, 1:14 am, Mike Kent wrote: > On Apr 16, 10:26 am, Mike Driscoll wrote: > > > Yeah, I noticed that Google Groups has really sucked this week. I'm > > using the Google Groups Killfile for Greasemonkey now and it helps a > > lot. I like Google, but my loyalty only goes to far. This is a > > complete lack of customer service. > > > Mike > > Bless you. I just installed Greasemonkey and the Google Groups > Killfile. Works like a charm. I manually edit the REs in the GGK's kill file variable (use Firefox about:config and filter for "kill") and enable case-insensitive search (open the script, search for "compile()" and add a second parameter "i"). (Posted via GG, but I'm open to an alternative web-based Usenet service.) -- Kam-Hung Soh Software Salariman From billingspanshism at gmail.com Sat Apr 19 17:16:51 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:16:51 -0700 (PDT) Subject: victoria beckham quotes Message-ID: <1b355dce-84cf-4b27-afed-caa51fc7c4ac@k37g2000hsf.googlegroups.com> Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From bruno.42.desthuilliers at websiteburo.invalid Mon Apr 21 07:26:24 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Mon, 21 Apr 2008 13:26:24 +0200 Subject: Opposite of repr() (kind of) In-Reply-To: References: Message-ID: <480c79e0$0$5045$426a74cc@news.free.fr> Guillermo a ?crit : > Hi there, > > How can I turn a string into a callable object/function? Depends on what's in your string. > I have a = 'len', and I want to do: if callable(eval(a)): print > "callable", but that doesn't quite work the way I want. :) Works here: Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a = "len" >>> callable(eval(a)) True >>> From mattheww at chiark.greenend.org.uk Sun Apr 20 14:22:07 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 20 Apr 2008 19:22:07 +0100 (BST) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: Terry Reedy wrote: > But you do not really need a variant. Just define a preprocessor > function 'blockify' which converts code in an alternate syntax to > regular indented block syntax. Then > > exec(blockify(alt_code_string)) You can do it like that, but if it were to become part of the standard distribution it would be nice to avoid having to tokenise the code twice. (You could define the new block scheme in such a way that 'blockify' doesn't need to tokenise, but I think it would end up a bit ugly.) -M- From triplezone3 at yahoo.co.uk Sat Apr 19 11:56:37 2008 From: triplezone3 at yahoo.co.uk (triplezone3) Date: Sat, 19 Apr 2008 16:56:37 +0100 (BST) Subject: urlretrieve can't send headers Message-ID: <378613.74223.qm@web26908.mail.ukl.yahoo.com> Hello. I'm using urllib.urlretrieve to download files, because it provides a handy hook function. Unfortunately, it won't let me send headers, which could be quite useful. Is there any way I could do this? __________________________________________________________ Sent from Yahoo! Mail. A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html From stanc at al.com.au Tue Apr 29 20:40:18 2008 From: stanc at al.com.au (Astan Chee) Date: Wed, 30 Apr 2008 10:40:18 +1000 Subject: simple chemistry in python In-Reply-To: <5e3717e5-1913-4bda-94b3-ae165e5fb8ba@m73g2000hsh.googlegroups.com> References: <5e3717e5-1913-4bda-94b3-ae165e5fb8ba@m73g2000hsh.googlegroups.com> Message-ID: <4817BFF2.9030907@al.com.au> Wow, that is the jackpot. Is that color node supposed to be the actual color of the element? or just representation? Thanks again Astan baoilleach wrote: > If you are familiar with parsing XML, much of the data you need is > stored in the following file: > http://bodr.svn.sourceforge.net/viewvc/*checkout*/bodr/trunk/bodr/elements/elements.xml?revision=34&content-type=text%2Fplain > > This file is part of the Blue Obelisk Data Repository, an effort by > several chemistry software developers to share common information. If > you have any further questions, please email blueobelisk- > discuss at lists.sf.net. > > Noel > > On Apr 29, 8:48 am, Astan Chee wrote: > >> Hi, >> Im looking for a python module to do simple chemistry things. Things >> like, finding the name of elements given the atomic number (and vice >> versa); what state the given matter is in depending on certain >> parameters; maybe even color of certain elements or even calculating the >> result of combining certain elements. >> I was looking for something simple, but everything I see seems to be a >> full blown chemistry set. >> I know I can probably spend a day doing this one element at a time, but >> I was wondering if there is already something like this done in a small >> scale? >> Thanks for any information >> Astan >> >> -- >> "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." >> >> Animal Logichttp://www.animallogic.com >> >> Please think of the environment before printing this email. >> >> This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. >> > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." Animal Logic http://www.animallogic.com Please think of the environment before printing this email. This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. -------------- next part -------------- An HTML attachment was scrubbed... URL: From skanemupp at yahoo.se Tue Apr 15 19:45:24 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Tue, 15 Apr 2008 16:45:24 -0700 (PDT) Subject: tkinter, event.widget, what do i get? References: <7caa5089-2ea9-4e18-9117-7431d7403976@l42g2000hsc.googlegroups.com> Message-ID: <3a6f6d87-0102-4995-a033-501137b3f934@s50g2000hsb.googlegroups.com> On 16 Apr, 00:24, "Gabriel Genellina" wrote: > En Tue, 15 Apr 2008 17:45:08 -0300, escribi?: > > > when calling function hmm here, what do i get? the widget i clicked > > on? > > if i have a canvs on wich i have a bitmap and i click on the bitmap, > > is the event.widget then the bitmap? > > can i get info about the bitmap then? like color of the pixel i > > clicked. if so, how? > > > w.bind("", key) > > w.bind("", hmm) > > > def hmm(event): > > return event.widget > > Why don't you try by yourself? You can use: print repr(something) > > -- > Gabriel Genellina i get thing is i get that even though i click outside the image. and what can i do with this number anyway? From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 18 05:28:36 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 18 Apr 2008 11:28:36 +0200 Subject: Can't do a multiline assignment! In-Reply-To: <98406333-c7c0-4b98-845d-c18895644c4a@t54g2000hsg.googlegroups.com> References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <1952579a-3cfb-44ea-92aa-658daa64aee4@a70g2000hsh.googlegroups.com> <564dd82b-8670-4ead-a3c8-a22b30a3eb73@m73g2000hsh.googlegroups.com> <98406333-c7c0-4b98-845d-c18895644c4a@t54g2000hsg.googlegroups.com> Message-ID: <480869ac$0$18253$426a74cc@news.free.fr> s0suk3 at gmail.com a ?crit : > On Apr 17, 12:34 pm, Michael Torrie wrote: >> Another thing to consider is that referencing a member of a class or >> instance already *is* a dictionary lookup. It's how python works. Thus >> dictionaries are optimized to be fast. Since strings are immutable, >> python hashes them into a fast lookup pointer. So every time you say >> mydict["mykey"], it already knows the lookup pointer (hash) for "mykey" >> (the string) and can find the dictionary entry very quickly, ideally in >> O(1) time (well maybe log(N)). Thus putting your headers in a >> dictionary is actually a really good idea for performance reasons. > > I didn't know about that, thanks. So after all the trouble I went > through writing those 200 loc I actually maid it worse... That's an understatement. From bruno.desthuilliers at gmail.com Mon Apr 7 08:08:59 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Mon, 7 Apr 2008 05:08:59 -0700 (PDT) Subject: while-loops enter the last time after condition is filled? References: Message-ID: <547d0b90-deb8-4342-a1f1-72d3f08c6015@e39g2000hsf.googlegroups.com> On 6 avr, 01:53, skanem... at yahoo.se wrote: > it seems to me from my results that when i use a while-loop it will > execute once after the condition is met. > > ie the conditions is met the code executes one time more and then > quits. The problem is obviously in your code, but since you failed to post the minimal code exhibiting the problem, we can't help. From mslinn at mslinn.com Mon Apr 21 02:51:58 2008 From: mslinn at mslinn.com (Mike Slinn) Date: Sun, 20 Apr 2008 23:51:58 -0700 Subject: Elementtree find problem Message-ID: <480C398E.8020505@mslinn.com> The following short Python program parses a KML file and displays the names of all Marks and Routes: from elementtree.ElementTree import ElementTree tree = ElementTree(file='test.kml') kml = tree.getroot() ns = 'http://earth.google.com/kml/2.1' for folder in kml.findall("{%s}Folder/{%s}Folder/{%s}name" % (ns, ns, ns)): print folder.text I want to modify the program to ignore Marks, and print out the coordinates of each Route. Seems ElementTree v1.3 will make this task much easier, but unfortunately the CheeseShop and the Gentoo Portage repostitory only have v1.2.7 at this time. The following code is as close as I can get to what I want, but it doesn't run because I've attempted to use v1.3 syntax, ended up writing complete crap instead, and I can't understand the docs well enough for the v1.2.7 syntax. Perhaps someone can understand what I mean and give me a clue as to how to write this? from elementtree.ElementTree import ElementTree tree = ElementTree(file='test.kml') kml = tree.getroot() ns = 'http://earth.google.com/kml/2.1' for folders in kml.findall("{%s}Folder/{%s}Folder" % (ns, ns)): if folders["name"].text=='Routes': print folder.findall("{%s}LineString/{%s}coordinates" % (ns, ns)) Thanks, Mike From damonwischik at gmail.com Fri Apr 18 21:09:46 2008 From: damonwischik at gmail.com (damonwischik at gmail.com) Date: Fri, 18 Apr 2008 18:09:46 -0700 (PDT) Subject: How to print a unicode string? References: <87d4omsovf.fsf@benfinney.id.au> <4edea21e-d45c-4467-a66d-e270365eb812@l64g2000hse.googlegroups.com> <878wzasm10.fsf@benfinney.id.au> Message-ID: <072f2f58-2434-4848-9eb7-85033069d1f9@a22g2000hsc.googlegroups.com> On Apr 19, 1:53 am, Ben Finney wrote: > Damon Wischik writes: >> Why does it matter what locales my OS supports, when all I want is >> to set the encoding to be used for the output > > Because the Python 'locale' module is all about using the OS's > (actually, the underlying C library's) locale support. > > The locale you request with 'locale.setlocale' needs to be supported > by the locale database, which is independent of any specific > application, be it Python, Emacs, or otherwise. Let me try to ask a better question. It seems that the logical choice of locale (en_GB.utf8) is not supported by my operating system. Nonetheless, I want Python to output in utf-8, because I know for certain that the terminal I am using (Emacs 22.2.1 with python-mode) will display utf-8 correctly. It therefore seems that I cannot use the locale mechanism to indicate to Python the encoding I want for sys.stdout. What other mechanisms are there for me to indicate what I want to Python? Another poster pointed me to >> sys.stdout = codecs.getwriter("UTF-8")(sys.stdout) and this works great. All I want now is some reassurance that this is the most appropriate way for me to achieve what I want (e.g. least likely to break with future versions of Python, most in keeping with the design of Python, easiest for me to maintain, etc.). Damon. From stodge at gmail.com Fri Apr 18 08:44:43 2008 From: stodge at gmail.com (Stodge) Date: Fri, 18 Apr 2008 05:44:43 -0700 (PDT) Subject: SWIG (Python) - "no constructor defined" for concrete class Message-ID: Yet another SWIG question (YASQ!). I'm having a problem with using an abstract base class. When generating the Python bindings, SWIG thinks that all the concrete classes that derive from this abstract class are abstract too and won't create the correct constructor. Abstract class: [source lang="cpp"]class CORE_API Shape { public: virtual ~Shape() { nshapes--; }; double x, y; virtual void move(double dx, double dy); virtual double area(void) = 0; virtual double perimeter(void) = 0; static int nshapes; protected: Shape() { nshapes++; } }; [/source] Derived classes: [source lang="cpp"]class CORE_API Circle : public Shape { private: double radius; public: Circle(double r): Shape(), radius(r) { }; virtual double area(void); virtual double perimeter(void); }; class CORE_API Square : public Shape { private: double width; public: Square(double r): Shape(), width(r) { }; virtual double area(void); virtual double perimeter(void); }; [/source] SWIG file: [source lang="cpp"]class Shape { virtual void move(double dx, double dy); virtual double area(void) = 0; virtual double perimeter(void) = 0; }; class Circle: public Shape { Circle(double r); virtual double area(void); virtual double perimeter(void); }; class Square: public Shape { Square(double r); virtual double area(void); virtual double perimeter(void); }; [/source] C++ COde: [source lang="cpp"] Circle c(1.02); std::cout << "(c++)\t\tCircle\t" << c.area() << std::endl; Square s(9.20); std::cout << "(c++)\t\tSquare\t" << s.area() << std::endl; [/source] For some reason SWIG thinks that Circle and Square are abstract. Any ideas why? I'm rather confused by this. Thanks as always From m.zaki.mirza at gmail.com Mon Apr 14 03:55:06 2008 From: m.zaki.mirza at gmail.com (xakee) Date: Mon, 14 Apr 2008 00:55:06 -0700 (PDT) Subject: Game design : Making computer play References: Message-ID: <535ad4b4-afd6-4807-90e9-c1fa3eb48bc1@m36g2000hse.googlegroups.com> On Apr 14, 12:13?pm, v4vijayakumar wrote: > In computer based, two player, board games, how to make computer play? > Are there any formal ways to _teach_ computer, to choose best possible > move? > > I know this is kind of off-topic here. Please redirect me, if there > are more appropriate newsgroup. > > Many thanks. You should pick up some nice Artificial intelligence book and see for the game playing section. Most of them have it. Teaching the computer is almost like telling it all the possibilities. The actual teaching is telling the computer how to decide which possibility is the best. That is by using heuristics. All possibilities are normally represented as trees, one move leading to another. Then there is are pruning techniques, miny-maxy things where we deal with the concept of minimizing opponents gain and maximizing your own. So you design heuristics like that. (For example in the game of tic tac toe, there can be say 5 moves to be made, and the heuristic function is the number of moves a given player will win in.... and the computer calculates that its 4 for him and 3 for you for a certain move.... he will pick the next move with is maybe 3 for him and 4 for you and execute that move). This is a very simplistic application but this is how it goes. There are many searching heuristic based algorithms, some blind search algorithms etc. They are very important in game playing not just board ones but almost all of them. They are the foundation. So I would recommend you to open some elementary AI book. From ksterling at mindspring.com Thu Apr 24 05:19:46 2008 From: ksterling at mindspring.com (Ken) Date: Thu, 24 Apr 2008 05:19:46 -0400 Subject: function that accepts any amount of arguments? References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> Message-ID: "Steve Holden" wrote in message news:mailman.99.1209009225.12834.python-list at python.org... > globalrev wrote: >> if i want a function that can take any amount of arguments how do i >> do? >> >> lets say i want a function average that accepts any number of integers >> and returns the average. > > Use a parameter of the form *args - the asterisk tells the interpreter to > collect positional arguments into a tuple. Untested: > > def mean(*x): > total = 0.0 > for v in x: > total += v > return v/len(x) > think you want total/len(x) in return statement > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > From jared.grubb at gmail.com Wed Apr 23 21:08:44 2008 From: jared.grubb at gmail.com (Jared Grubb) Date: Wed, 23 Apr 2008 18:08:44 -0700 Subject: Partition list with predicate Message-ID: <925822270804231808n44c44ddbx213e936319ad1ed3@mail.gmail.com> I guess I forgot one requirement: the removed elements need to be remembered. Basically, I have a list of objects in a buffer, one class operates on some of the objects, but other classes use others. So, a class must extract the ones it can handle, and leave the rest in the buffer for the other classes to handle. I haven't found a function that will both remove objects from a list, but save the ones that do get removed. Jared On 23 Apr 2008, at 10:15, Tim Golden wrote: Jared Grubb wrote: I want a function that removes values from a list if a predicate evaluates to True. The best I could come up with is: Have a look at the itertools module, and the ifilter function in particular. TJG -- http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From rdh at new.rr.com Tue Apr 22 16:55:46 2008 From: rdh at new.rr.com (DataSmash) Date: Tue, 22 Apr 2008 13:55:46 -0700 (PDT) Subject: list manipulation Message-ID: <78158460-8508-4453-a2dc-c5814dda8839@59g2000hsb.googlegroups.com> Hello, I have a list that looks like this: roadList = ["Motorways","Local","Arterial"] I want to apply some code so that the output looks like this: "Motorways;Local;Arterial" ...in other words, I want each item in the list separated by a ';' and then the whole thing surrounded by quotes. How can this be done with the LEAST amount of code? I appreciate your help! R.D. From aldo at nullcube.com Sat Apr 5 07:25:16 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Sat, 5 Apr 2008 22:25:16 +1100 Subject: ANN: pry unit testing framework In-Reply-To: <38377121-8dc4-40b8-8a8f-868a2530530c@d1g2000hsg.googlegroups.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <38377121-8dc4-40b8-8a8f-868a2530530c@d1g2000hsg.googlegroups.com> Message-ID: <20080405112516.GA15684@nullcube.com> Thus spake Michele Simionato (michele.simionato at gmail.com): > > As far as the base unit testing functionality is concerned, I think > > they try to address similar problems. Both have assert-based testing > > with inspection and re-parsing of assert exceptions for better error > > messages. Both try to provide better fixture management. Both make > > programmatic test generation easier. Both have a command-line tool for > > running and gathering tests. > > > > I like nose, but I'm biased, and of course I think Pry has some > > advantages. One difference I'd point out is Pry's tree-based test > > structure, which provides a number of conveniences and features (much > > nicer test selection from the command line, for instance). Pry is also > > less than half the size of nose, and should therefore be simpler to > > extend and understand. > > You forgot to mention the important point that nose is compatible > with unittest and many developer (including myself) would consider > that a major selling point. That's true. If you have a body of tests that would be difficult to convert for some reason, that IS a big advantage. If, however, you plan to use any of nose's advanced features, you will be incompatible with unittest anyway, and you should feel free to consider competing suites like test.py and Pry. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From arnodel at googlemail.com Tue Apr 29 08:47:57 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Tue, 29 Apr 2008 05:47:57 -0700 (PDT) Subject: Given a string - execute a function by the same name References: Message-ID: <27f6ba19-8756-4d96-851f-2a7c585ef3c7@m44g2000hsc.googlegroups.com> On 29 Apr, 13:10, pyt... at bdurham.com wrote: > Bruno, > > Thank you for your detailed analysis. I learned a lot about Python > reading everyone's responses. > > For development I'm using #5: "globals().get("func")" because its > seamless to add additional functionality. > > But when I release into production I'm going to shift to #3: "Place all > my functions in dictionary and lookup the function to be called". This > technique will allow me to precisely control the dynamic nature of my > application. > > Thanks again to everyone who contributed on this thread. > > Regards, > Malcolm You could avoid #5 from the start using a decorator: functions = {} def register(func): functions[func.__name__] = func return func @register def foo(): print "Foo!" @register def bar(): print "Bar!" >>> functions {'foo': , 'bar': } >>> functions['bar']() Bar! -- Arnaud From banibrata.dutta at gmail.com Mon Apr 21 02:07:46 2008 From: banibrata.dutta at gmail.com (Banibrata Dutta) Date: Mon, 21 Apr 2008 11:37:46 +0530 Subject: Any reliable obfurscator for Python 2.5 In-Reply-To: <480B8C01.1080306@holdenweb.com> References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> <480b6133$0$34498$742ec2ed@news.sonic.net> <480B8C01.1080306@holdenweb.com> Message-ID: <3de8e1f70804202307p10539825sac6d861511937f85@mail.gmail.com> On 4/21/08, Steve Holden wrote: > > If it's important to you to be able to obfuscate your code then you have > made an inapposite choice of language. Cutting through all the smoke (thanks to the slight flame we had), this seems to be the answer that 'shines thorough'... if this is coming from an expert who knows the Language darn too well (and I don't doubt that Steve does), I'd take it. I'm a Noob with Python, and probably the question was a bit premature i.e. w/o enough research. Creation of 'pyc' in encrypted zip with a decrypting/embedded-interpreter launcher seems like an excellent work-around for what I need. I am not sure how many of you who are against obfuscation use Skype. I'd be glad to know. If you don't, I trust that you are a OSS zealot, and respect you for that. If you do, then you may be surprised to know that for the excellent functionality, ease-of-use and stability/robusness of communication it provides, it's one of the most closed-source software you could imagine. The strategic reasons for doing so are not too hard to imagine. Thanks to all for this response. BTW, I'm glad that I chose Python over few other available options. The community participation and response is quite fantastic. cheers. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gagsl-py2 at yahoo.com.ar Mon Apr 7 09:58:04 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 07 Apr 2008 10:58:04 -0300 Subject: Help replacing os.system call with subprocess call References: <47F9B1D1.4090701@eastlink.ca> <47F9C764.9070401@mattnordhoff.com> <47FA23E7.7040809@eastlink.ca> Message-ID: >> David Pratt wrote: >>> Hi. I am trying to replace a system call with a subprocess call. I have >>> tried subprocess.Popen and subprocess.call with but have not been >>> successful. The command line would be: >>> >>> svnadmin dump /my/repository > svndump.db En Mon, 07 Apr 2008 10:38:47 -0300, David Pratt escribi?: > The speed of this solution is slower than os.system. Would a queue of > some kind be needed to speed this up? Has anyone implemented something > like this? Many thanks. See the last post from Matt Nordhoff, where he calls Popen with stdout=an_open_file. This is the direct translation of ">outfile" in a shell, and faster because it doesn't involve Python processing. -- Gabriel Genellina From ch612bunn at gmail.com Sun Apr 27 09:14:43 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:14:43 -0700 (PDT) Subject: spyware doctor 5.0.5.259 crack Message-ID: spyware doctor 5.0.5.259 crack http://wga-cracks.crackkey.net From steve at holdenweb.com Thu Apr 10 12:58:49 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 10 Apr 2008 12:58:49 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> <47FCF421.6000807@holdenweb.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> Message-ID: Victor Subervi wrote: > Okay, here is where we find the fly in the ointment. If I run this code: > > #! /usr/bin/python > import MySQLdb > print "Content-type: image/jpeg\r\n" > host = 'mysqldb2.ehost-services.com ' > db = 'benobeno_bre' > user = 'benobeno' > passwd = '21122112' > connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > cursor = connection.cursor() > cursor.execute('select pic1 from products where id="2";') > content = cursor.fetchall()[0][0] > content = content.tostring() > print content > f = open("2.jpg", "w") > f.write(content) > f.close() > all is well :) If, however, I change two lines to make it an html page: > > #! /usr/bin/python > import MySQLdb > # print "Content-type: image/jpeg\r\n" > print "Content-type: text/html\n" > host = 'mysqldb2.ehost-services.com ' > db = 'benobeno_bre' > user = 'benobeno' > passwd = '21122112' > connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > cursor = connection.cursor() > cursor.execute('select pic1 from products where id="2";') > content = cursor.fetchall()[0][0] > content = content.tostring() > print '

' % content > # print content > f = open("2.jpg", "w") > f.write(content) > f.close() > it prints garbage. It does not yield the image. Now, what? > TIA. > Victor > Of course it prints garbage. Since you claim to understand HTML I have no idea what makes you expect that it would print anything else. That's because you are sending garbage to the browser instead of the HTML your content type promises. THE VALUE OF THE IMG TAG'S SRC ATTRIBUTE SHOULD BE THE URL OF AN IMAGE< NOT THE IMAGE ITSELF. Sorry, I don't normally shout like that. So pay attention when I do. First let's agree that what you are writing here is a web script to return an image, NOT a web page with an embedded image. So ... Now you formulate a correct response instead. You should NOT be returning a content type of text/html here, you should be returning a content type of image/jpeg. So your code should read #! /usr/bin/python import MySQLdb print "Content-type: image/jpeg\r\n" host = 'mysqldb2.ehost-services.com' db = 'benobeno_bre' user = 'benobeno' passwd = '21122112' connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor = connection.cursor() cursor.execute('select pic1 from products where id="2";') content = cursor.fetchall()[0][0] content = content.tostring() print content If you then direct your browser to the correct URL to access the output of this script you will see your image. When you want to see your image in the context of some HTML, write *another page* and you put the URL of the image inside it like this: as a reference to the image your script returns. I think you are on your own from here. If you follow instructions you should not need any further help. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From marexposed at googlemail.com Thu Apr 17 11:10:35 2008 From: marexposed at googlemail.com (marexposed at googlemail.com) Date: Thu, 17 Apr 2008 16:10:35 +0100 Subject: Unicode chr(150) en dash In-Reply-To: <48063434$0$36327$742ec2ed@news.sonic.net> References: <48063434$0$36327$742ec2ed@news.sonic.net> Message-ID: <20080417161035.bc123709.marexposed@googlemail.com> Thank you Martin and John, for you excellent explanations. I think I understand the unicode basic principles, what confuses me is the usage different applications make out of it. For example, I got that EN DASH out of a web page which states at the beggining. That's why I did go for that encoding. But if the browser can properly decode that character using that encoding, how come other applications can't? I might need to go for python's htmllib to avoid this, not sure. But if I don't, if I only want to just copy and paste some web pages text contents into a tkinter Text widget, what should I do to succesfully make every single character go all the way from the widget and out of tkinter into a python string variable? How did my browser knew it should render an EN DASH instead of a circumflexed lowercase u? This is the webpage in case you are interested, 4th line of first paragraph, there is the EN DASH: http://www.pagina12.com.ar/diario/elmundo/subnotas/102453-32303-2008-04-15.html Thanks a lot. On Wed, 16 Apr 2008 10:27:26 -0700 John Nagle wrote: > marexposed at googlemail.com wrote: > > Hello guys & girls > > > > I'm pasting an "en dash" > > (http://www.fileformat.info/info/unicode/char/2013/index.htm) character into > > a tkinter widget, expecting it to be properly stored into a MySQL database. > > > > I'm getting this error: > > ***************************************************************************** > > Exception in Tkinter callback Traceback (most recent call last): File > > "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__ return > > self.func(*args) File "chupadato.py", line 25, in guardar cursor.execute(a) > > File "C:\Python24\Lib\site-packages\MySQLdb\cursors.py", line 149, in execute > > query = query.encode(charset) UnicodeEncodeError: 'latin-1' codec can't > > encode character u'\u2013' in position 52: ordinal not in range(256) > > ***************************************************************************** > > Python and MySQL will do end to end Unicode quite well. But that's > not what you're doing. How did "latin-1" get involved? > > If you want to use MySQL in Unicode, there are several things to be done. > First, the connection has to be opened in Unicode: > > db = MySQLdb.connect(host="localhost", > use_unicode = True, charset = "utf8", > user=username, passwd=password, db=database) > > Yes, you have to specify both "use_unicode=True", which tells the client > to talk Unicode, and set "charset" to"utf8", which tells the server > to talk Unicode encoded as UTF-8". > > Then the tables need to be in Unicode. In SQL, > > ALTER DATABASE dbname DEFAULT CHARACTER SET utf8; > > before creating the tables. You can also change the types of > existing tables and even individual fields to utf8, if necessary. > (This takes time for big tables; the table is copied. But it works.) > > It's possible to get MySQL to store character sets other than > ASCII or Unicode; you can store data in "latin1" if you want. This > might make sense if, for example, all your data is in French or German, > which maps well to "latin1". Unless that's your situation, go with > either all-ASCII or all-Unicode. It's less confusing. > > John Nagle > -- > http://mail.python.org/mailman/listinfo/python-list From martin at v.loewis.de Tue Apr 22 14:21:11 2008 From: martin at v.loewis.de (=?ISO-8859-2?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 22 Apr 2008 20:21:11 +0200 Subject: py3k concerns. An example In-Reply-To: <87lk36e6po.fsf@mulj.homelinux.net> References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <480D71B9.40909@v.loewis.de> <87lk36e6po.fsf@mulj.homelinux.net> Message-ID: <480e2c97$0$24477$9b622d9e@news.freenet.de> >>> In py3k string%dictionary is going away. >> Why do you say that? It's not going away in Python 3.0. > > I also got the impression that it was going away. PEP 3101's abstract > says: > > This PEP proposes a new system for built-in string formatting > operations, intended as a replacement [sic] for the existing '%' > string formatting operator. > > Under "Backward compatibility" it says that both systems can coexist > "until it comes time to deprecate the older system". The PEP may say that it's going away, but it doesn't say that it goes away in 3.0 - and indeed, it won't. At some point in the future, somebody will likely propose that the PEP will be executed. At that time, huge flame wars will start. I expect that they settle in changing the PEP to explain that the old mechanism gets removed in Python 4, to be release in 2018 :-) Regards, Martin From mfb.chikazuku at gmail.com Wed Apr 9 15:38:09 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Wed, 09 Apr 2008 21:38:09 +0200 Subject: Stripping scripts from HTML with regular expressions Message-ID: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> Hey everyone, I'm trying to strip all script-blocks from a HTML-file using regex. I tried the following in Python: testfile = open('testfile') testhtml = testfile.read() regex = re.compile(']*>(.*?)', re.DOTALL) result = regex.sub('', blaat) print result This strips far more away then just the script-blocks. Am I missing something from the regex-implementation from Python or am I doing something else wrong? greetz MFB From sjmachin at lexicon.net Fri Apr 25 04:00:50 2008 From: sjmachin at lexicon.net (John Machin) Date: Fri, 25 Apr 2008 01:00:50 -0700 (PDT) Subject: Little novice program written in Python References: Message-ID: <49249992-3634-4c5f-bd45-7ce4f1b32044@l17g2000pri.googlegroups.com> On Apr 25, 5:44 pm, Robert Bossy wrote: > Peter Otten wrote: > > Rog?rio Brito wrote: > > >> i = 2 > >> while i <= n: > >> if a[i] != 0: > >> print a[i] > >> i += 1 > > > You can spell this as a for-loop: > > > for p in a: > > if p: > > print p > > > It isn't exactly equivalent, but gives the same output as we know that a[0] > > and a[1] are also 0. > > If the OP insists in not examining a[0] and a[1], this will do exactly > the same as the while version: > > for p in a[2:]: > if p: > print p > ... at the cost of almost doubling the amount of memory required. From steve at holdenweb.com Tue Apr 1 19:17:54 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 01 Apr 2008 19:17:54 -0400 Subject: Is this a good time to start learning python? In-Reply-To: References: <47f1140e$0$735$a729d347@news.telepac.pt> <88fa881e-e59b-4682-801c-90ef08a1480a@a22g2000hsc.googlegroups.com> <1565ced8-afd7-4c32-a6ee-26f9b95d60bc@d45g2000hsc.googlegroups.com> Message-ID: lbonafide at yahoo.com wrote: > On Apr 1, 2:42 pm, "Eduardo O. Padoan" > wrote: >> On Tue, Apr 1, 2008 at 4:20 PM, wrote: > >>> You misunderstand. C++ has a lot of "warts" to maintain backwards >>> compatibility with C. The standards committee could eliminate these >>> warts to make the language "cleaner", but it would break a lot of >>> systems. >> It would not "break" anything that not move from C to C++, this is my point. > > You missed the point completely. C++ has a new version coming out > soon, and as part of it, the less attractive parts of the language > (like C compatibility) are NOT being removed, as that would break a > lot of existing apps. > >> People not willing to take the migration path (porting to 2.6, using >> the -3 flag, refactoring and re-running the tests untill the warning >> are gone, using the 2to3 tool...) will not upgrade. No one will force >> you to do it. 2.6 will not desappear from the python.org site anytime >> soon. > > Will 2.6 be supported with patches and fixes going forward? Yes. About the only definite assertion Guido has so far made about the 2.x series is that it won't go further than 2.9, as he feels that 2.10 is ambiguous about its position in the series. You should expect at least three years of Python 2.X after the release of 3.0 (and the simultaneous release of 2.6) this August. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From arnodel at googlemail.com Tue Apr 29 02:08:54 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Tue, 29 Apr 2008 07:08:54 +0100 Subject: python script as executable References: Message-ID: sandipm writes: > Hi, > I have written a python script to run from cron. > I have put #!/usr/bin/env python at top. file executes correctly when > I run using python filename.py but > it fails to execute when try to run it like script/command. > it throws error: > :No such file or directory > > I am editing file from eclipse for python from windows. and then > uploading on linus machine to run it. > > > any pointers? Have you made your file executable (man chmod)? -- Arnaud From ptmcg at austin.rr.com Sat Apr 12 07:16:06 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Sat, 12 Apr 2008 04:16:06 -0700 (PDT) Subject: C to python conversion References: Message-ID: On Apr 12, 5:58?am, Michele Petrazzo wrote: > Hi all, > I'm trying to translate a simple C code into a python + ctypes (where > need), but I have some problems on char conversion. The code have > to work on Linux and talk with the serial port. I think that the problem > is that I don't translate correctly the strings. > > C code: > #define START 0x33 > #define RETURN_START 0x22 > #define ADDR 0x01 > #define WRITE_CMD 0x03 > #define ALL_CMD 0xFF > ... > char buf[10]; > char buf_ret[10]; > > buf[0]=0; > buf[0]=START; > buf[1]=ADDR; > buf[2]=WRITE_CMD; > > write(_fd, buf, 6); > read(_fd,buf_ret,6); > > It works > > python: > START = 0x33 > RETURN_START = 0x22 > ADDR = 0x01 > WRITE_CMD = 0x03 > ALL_CMD = 0xFF > > lib = C.CDLL('libc.so.6') > > items = [START, ADDR, WRITE_CMD] > buf = C.c_char * 10 > buffer_rec = buf() > buffer_send = buf(*items) > > (Here I receive: TypeError: one character string expected) > If I do: > chr(int()) of every value, it work, but: > > lib.write(fd, buffer_send, 6) > lib.read(fd, buffer_rec, 6) > > I stay there and block the program execution, until a CTRL+C > > What can I do? > > Thanks, > Michele Here are some differences between the C and Python programs: - the C program uses a separate buffer for reading and writing - the Python program uses buf for both - the C program *may* have null-filled the output buffer, I don't know what the Python buffer contains after the first 3 characters - in the Python program, items has only 3 characters to write; the C program has a buffer of 10 characters Here are some things to try in the Python program: items = [START, ADDR, WRITE_CMD] + [0]*7 inbuf = C.c_char * 10 outbuf = C.c_char * 10 buffer_rec = inbuf() buffer_send = outbuf(*items) -- Paul From uniontelecardsindia at gmail.com Tue Apr 22 17:12:11 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:12:11 -0700 (PDT) Subject: White masculine gay sucking two black cocks Message-ID: <42bcb0b7-7988-4fe2-9bea-08e60e7097f1@24g2000hsh.googlegroups.com> Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 15 04:06:21 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 15 Apr 2008 10:06:21 +0200 Subject: Dynamic use of property() fails In-Reply-To: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> Message-ID: <480461f8$0$20282$426a34cc@news.free.fr> andrew cooke a ?crit : > Hi, > > This is my first attempt at new classes and dynamic python, so I am > probably doing something very stupid... After reading the how-to for > descriptors at http://users.rcn.com/python/download/Descriptor.htm I > decided I would make an object that returns attributes on read, but on > setting calls an arbitrary function. > > My code looks like: > class ActiveDAO(object): > def __init__(self): > self.__values__ = {} __names__ are reserved for the Python implementation itself. Use _names for 'protected' attributes. > def add_field(self, name, value, on_change): > self.__values__[name] = value > def get(self): return self.__values__[name] > def set(self, new_value): self.__values__[name] = > on_change(new_value) > def delete(self): raise AttributeError > self.__dict__[name] = property(get, set, delete) > > However, when I try to use this (in a test) with code like: > dao = ActiveDAO() > dao.add_field("name", "value", lambda _: None) > assertEqual(dao.name, "value") > > I get a failure because lookup of the attribute is returning > "". > > That is quite reasonable, but I was under the expression that some > magic was supposed to happen, as described in the document referenced > above! > > Please can someone explain why there is no magic? :o( Others already answered this. The canonical solution is to use a custom descriptor instead of a property: class Field(object): def __init__(self, name, onchange): self.name = name self.onchange = onchange def __get__(self, instance, cls): if instance is None: # called on the class return self # called on instance return instance._values[self.name] def __set__(self, instance, value): instance._values[name] = self.onchange(value) class ActiveDAO(object): def __init__(self): self._values = [] class Person(ActiveDAO): name = Field('firstname', lambda v: v.strip().capitalize()) age = Field('age', lambda v : int(v)) Now you may want to search here or in the cookbook to learn how to: - dynamically create new classes - avoid having to repeat the name of the field (usually done using a metaclass and a two-stages initialisation of Field objects) HTH From kdoiron at sympatico.ca Mon Apr 7 15:49:58 2008 From: kdoiron at sympatico.ca (Kevin) Date: Mon, 7 Apr 2008 12:49:58 -0700 (PDT) Subject: Problem with smtplib and py2exe Message-ID: <3ff2767a-bbd8-4e0e-bbf4-3fa72bdca5e7@8g2000hsu.googlegroups.com> Hi everyone, I'm running Python 2.5.1 on an XP-Pro platform, with all the updates (SP2, etc) installed. I have a program (send_file.py) that sends a file to a service provider, using an ftp connection. The program works properly, and I've created an 'exe' of it, using py2exe. It was distrubuted to my user base a couple of weeks ago and seems to be working well. None of the users have Python installed on their machines, thus the need for an 'exe' for the program. I now need to add an email function to the program, to automatically send an email to a select user list when the program is completed. I've made the appropriate modifications to my code, and the program works properly when I run it from Python. When I try to make an exe out of my new program, however, I get the following error: Traceback (most recent call last): File "C:/Python25/send_ftp/setup.py", line 17, in console = [{"script": 'send_file.py'}] ) File "C:\Python25\lib\distutils\core.py", line 168, in setup raise SystemExit, "error: " + str(msg) SystemExit: error: command 'C:\Python25\pythonw.exe' failed with exit status 1 The 'setup.py' script is the same one I used to generate the 'exe' of the original program. The email-related code was added to my 'send_file.py' program as a function - it's not a separate module. If all of the changes are commented out, the py2exe function works. But as soon as I activate even the line "import smtplib", the py2exe process spits out the error above. If I put only the email portions of code in a test program, and run it from Python, it works, but if I try make an 'exe' out of the test program, I get the same error as above. Is there an inherent incompatibility between smtplib and py2exe? Does anyone have any ideas of how I can fix this problem? From tjreedy at udel.edu Wed Apr 9 17:35:48 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 9 Apr 2008 17:35:48 -0400 Subject: Basic optimization of python. References: Message-ID: "??" wrote in message news:cdb837ea0804062230y7efc2105x7523c05133a0bed7 at mail.gmail.com... | I wonder whether python compiler does basic optimizations to .py. In general, the answer to such questions depends on the implementation and version thereof. For CPython, you can look at bytecode with the dis module as another poster showed. | Again, how about contant calculation? | Eg: | a = 1 + 2 | .vs. | a = 3 This was added to CPython in version 2.5, I believe. From jcd at sdf.lonestar.org Tue Apr 29 15:03:23 2008 From: jcd at sdf.lonestar.org (J. Cliff Dyer) Date: Tue, 29 Apr 2008 15:03:23 -0400 Subject: Colors for Rows In-Reply-To: <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> <20080429121105.f10c3862.darcy@druid.net> <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> Message-ID: <1209495803.5173.11.camel@aalcdl07.lib.unc.edu> On Tue, 2008-04-29 at 13:14 -0500, Victor Subervi wrote: > On Tue, Apr 29, 2008 at 11:11 AM, D'Arcy J.M. Cain > wrote: > On Tue, 29 Apr 2008 09:33:32 -0500 > "Victor Subervi" wrote: > > why doesn't this work? > > > First, let me remove some blank lines to reduce scrolling. > > > z = 3 > > > > for d in (1,2,3,4,5,6): > > I changed id to a sequence so that the example actually runs. > Please > run your examples first and cut and paste them into the > message after > you are sure that it runs. > > Not sure what you mean here. The example runs. It prints out bgcolor="#ffffff"> every time. > > > > > z += 1 > > > > if z % 4 == 0: > > bg = '#ffffff' > > elif z % 4 == 1: > > bg = '#d2d2d2' > > elif z % 4 == 2: > > bg = '#F6E5DF' > > else: > > bg = '#EAF8D5' > > > > try: > > print '\n' % bg > > except: > > print '\n' > > > > It never increments z! Yet, if I print z, it will increment > and change the > > bgcolor! Why?! > > > I am not entirely sure what you are trying to do here. First, > what > error condition are you expecting in your try statement. > Second, don't > you want the print clause, with or without the try/except, in > the > loop. I assume that you want to print a line for each member > of your > sequence in alternating colours but this only prints for the > last one. > Try this: > > z = 3 > > for d in (1,2,3,4,5,6): > z += 1 > > if z % 4 == 0: > bg = '#ffffff' > elif z % 4 == 1: > bg = '#d2d2d2' > elif z % 4 == 2: > bg = '#F6E5DF' > else: > bg = '#EAF8D5' > > > print '' % bg, d > > Huh? You?re asking for one variable, then giving two! How?s that work? > Not quite. You're passing one variable to the string formatting operator, and passing a tuple to the print function. The implicit parenthesization is not print '' % (bg, d) as I think you are suggesting, but rather it is print ('' % bg), d > > > Or, tell us what you are trying to do. > > I think you understand. I want the row color to alternate, every > fourth row color being the same (or a series of 4) > > > > In fact, you can replace all the tests and the print statement > with > this after defining bg as a list of the four colours: > > print '' % bg[z % 4], d > > I tried that just for fun. It gave a bg of ?f?. Again, how are you > incorporating d? If you add that print line to end of your original code, then you'll get the z%4-th element of bg, which would be one character, because bg is a string, but if you "define bg as a list of the four colours" first, as instructed, you'll get sensible results: bg = ['#ffffff', '#b2b2b2', '#33FF66', '#000000'] for z in (0,1,2,3,4,5,6,7,8,9): print (' TIA, > Victor Cheers, Cliff From nick at craig-wood.com Fri Apr 25 08:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Fri, 25 Apr 2008 07:30:03 -0500 Subject: Little novice program written in Python References: Message-ID: Rog?rio Brito wrote: > I'm just getting my feet wet on Python and, just for starters, I'm coding some > elementary number theory algorithms (yes, I know that most of them are already > implemented as modules, but this is an exercise in learning the > language idioms). When you are up to speed in python I suggest you check out gmpy for number theory algorithms. Eg :- import gmpy p = 2 while 1: print p p = gmpy.next_prime(p) -- Nick Craig-Wood -- http://www.craig-wood.com/nick From timr at probo.com Sun Apr 13 18:55:18 2008 From: timr at probo.com (Tim Roberts) Date: Sun, 13 Apr 2008 22:55:18 GMT Subject: email module windows and suse References: Message-ID: <0j35041u36l70vhmov0uvfmv8ftp5npp2i@4ax.com> Lev Elbert wrote: > >I have to make a custom email module, based on the standard one. The >custom module has to be able to work with extremely large mails (1GB >+), having memory "footprint" much smaller. Then you have a design problem right from the start. It is extremely rare to find a mail server today that will transmit email messages larger than a few dozen megabytes. Even on a 100 megabit network, it's takes a minute and a half for a 1GB message to go from the server to the user's workstation. What are you really trying to do here? In most cases, you would be better off storing your attachments on a web server and transmitting links in the email. >The modified program has to work in SUSE environment, while the >development is done under Windows. I'm not too good with linux and do >not know if speedup in Windows translates one-to-one into speedup in >SUSE. For example, if the bottleneck is IO, in windows I can spawn a >separate thread or 2 to do "read-ahead". We would need more information on your processing to advise you on this. Disk I/O is slow, network I/O is slower. You can't go any faster than your slowest link. >Are threads available and as effective in SUSE as they are in Windows? Threads are available in Linux. There is considerable debate over the relative performace improvement. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Thu Apr 3 01:12:28 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 03 Apr 2008 05:12:28 GMT Subject: Why prefer != over <> for Python 3.0? References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> <87prt9coti.fsf@pobox.com> Message-ID: jjl at pobox.com (John J. Lee) wrote: > >How did programmers manage back then in 32k? Less software >development, more jigsaw puzzle. Yes, indeed. In response to a challenge posted on one of the x86 assembler newsgroups about two years ago, one intrepid Russian programmer produced a generic Sudoku solver in a 65-byte executable. Yes, that's 65 BYTES -- not KB, not MB. I consider myself an x86 assembler expert, but I remain in awe of that code. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From n00m at narod.ru Sun Apr 27 00:28:39 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 21:28:39 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> Message-ID: <8ee48fc1-45af-404f-8fad-d8e1b2fb90b4@s50g2000hsb.googlegroups.com> One more brick. This time I compare list.sort() vs sort(vector). Incredible. Python does it by 8.3s / 2.75s = 3 times faster than C++. import time f=open('D:\\v.txt','r') z=f.readlines() f.close() t=time.time() z.sort() print time.time()-t m=int(raw_input()) print z[m] #include #include #include #include #include #include #include using namespace std; vector vs; FILE *fp=fopen("D:\\v.txt","r"); int main() { int i=0; while (true) { char line[50]; if (!fgets(line,50,fp)) break; vs.push_back(line); ++i; } fclose(fp); double t; t=clock()/CLOCKS_PER_SEC; sort(vs.begin(),vs.end()); cout << clock()/CLOCKS_PER_SEC << endl; int m; cin >> m; cout << vs[m]; getchar(); return 0; } From jzgoda at o2.usun.pl Mon Apr 14 06:01:20 2008 From: jzgoda at o2.usun.pl (Jarek Zgoda) Date: Mon, 14 Apr 2008 12:01:20 +0200 Subject: pygtk + threading.Timer In-Reply-To: References: Message-ID: Dmitry Teslenko napisa?(a): > I have simple chat application with pygtk UI. I want some event (for > example update user list) to have place every n seconds. > What's the best way to archive it? > I tried threading.Timer but result is following: all events wait till > exit of gtk main loop and only then they occur. > Thanks in advance See gobject.timeout_add documentation in pygtk reference -- Jarek Zgoda Skype: jzgoda | GTalk: zgoda at jabber.aster.pl | voice: +48228430101 "We read Knuth so you don't have to." (Tim Peters) From cwitts at gmail.com Tue Apr 15 06:33:03 2008 From: cwitts at gmail.com (Chris) Date: Tue, 15 Apr 2008 03:33:03 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <1208196168.24295.36.camel@localhost.localdomain> <526792b1-acc2-4e48-8e9f-cc2641134958@k37g2000hsf.googlegroups.com> Message-ID: <732f1af2-ebae-4764-a40e-698ae1bde95f@h1g2000prh.googlegroups.com> On Apr 15, 11:47?am, Duncan Booth wrote: > Chris wrote: > > even is closer to even.75 than even+1.25. ?Why should it be rounded > > up ? > > Because the OP wants to round values to the nearest integer. Only values of > the form 'x.5' which have two nearest values use 'nearest even' to > disambiguate the result. > > Seehttp://en.wikipedia.org/wiki/Rounding#Round-to-even_method > > That's the way I was taught to round numbers when at primary school. My bad, didn't see he only wanted for halves and handle others as normal. From Lie.1296 at gmail.com Sun Apr 6 13:36:51 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 6 Apr 2008 10:36:51 -0700 (PDT) Subject: append to a sublist - please help References: <47f8f743$0$2983$ba620e4c@news.skynet.be> Message-ID: On Apr 6, 11:16 pm, Helmut Jarausch wrote: > Hi, > > I must be blind but I don't see what's going wrong > with The reason is: > G=[[]]*2 is doing a "shallow copy" of the blank list. The corrected code is either: G = [[] for _ in xrange(2)] or G = [[], []] btw, this is a very frequently asked question From aahz at pythoncraft.com Mon Apr 21 09:22:28 2008 From: aahz at pythoncraft.com (Aahz) Date: 21 Apr 2008 06:22:28 -0700 Subject: xkcd strikes again Message-ID: http://xkcd.com/413/ (As usual, make sure to read the alt text.) -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ Why is this newsgroup different from all other newsgroups? From gagsl-py2 at yahoo.com.ar Tue Apr 1 21:20:38 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 22:20:38 -0300 Subject: Decrementing of reference count of new objects? References: <20080401144928.24bc6506@opal.mv.qlogic.com> Message-ID: En Tue, 01 Apr 2008 18:49:28 -0300, Mitko Haralanov escribi?: > For the most part, I understand the theory behind reference counting in > Python C code. But there is one thing that I am confused about and I > have not been able to clear it up. > > Let say that you have the following function (over-simplified): > > PyObject *do_work (PyObject *self, PyObject *args) { > PyObject *new_obj; > new_obj = PyDict_New (); > return new_obj; > } > > What I don't get is whether I have to decrement the reference to > new_obj before I return it. I know that function that return object are > giving away the reference but I am still confused. PyDict_New returns a new reference (check section 7.4.1 in the API Reference), so do_work "owns" that reference. Functions that are intended to be called from Python code must return an owned reference to some PyObject* (see section 1.10.2 Ownership Rules, in the Extending/Embedding reference) (yes, these things are scattered all over the place...) Since do_work has to return an owned reference, it can't decrement it. In this example it's rather clear because the *only* reference to the newly created dict is hold by the function, and decrementing it would destroy the dictionary. -- Gabriel Genellina From sturlamolden at yahoo.no Wed Apr 30 17:26:09 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Wed, 30 Apr 2008 14:26:09 -0700 (PDT) Subject: Python 2.6 and wrapping C libraries on Windows References: Message-ID: <60da8569-4b80-4b31-9fd0-5b2a79ec2164@k13g2000hse.googlegroups.com> On Apr 30, 8:06 pm, "L. Lindstrom" wrote: > I have read that Python extension modules must link to the same C > run-time as the Python interpreter. This I can appreciate. But does this > requirement extend to the C libraries an extension module wraps. This somewhat of a misconception. You cannot reliably mix and blend CRT resources across different CRTs. This is not really a Python problem. It applies to any program. The reason this is important for Python C extensions, is mainly the possibility of accessing a Python file object as a pointer to a FILE struct in C. If you get a FILE* pointer from one CRT, you should not pass it to another CRT's fread. Likewise, if you allocate memory with one CRT's malloc(), you should not release the memory with another CRT's free(). As long as your libraries don't share CRT resources, it does not matter that the link to different CRTs for their internal work. From duncan.booth at invalid.invalid Tue Apr 29 05:23:33 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 29 Apr 2008 09:23:33 GMT Subject: How to unget a line when reading from a file/stream iterator/generator? References: <5e3854fa-557f-4475-8123-346346767097@k13g2000hse.googlegroups.com> Message-ID: George Sakkis wrote: > On Apr 28, 10:10?pm, pyt... at bdurham.com wrote: >> George, >> >> > Is there an elegant way to unget a line when reading from a >> > file/stream > iterator/generator? >> >> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502304 >> >> That's exactly what I was looking for! >> >> For those following this thread, the above recipe creates a generic >> object that wraps any iterator with an 'unget' ("push") capability. >> Clean and elegant! >> >> Thank you, >> Malcolm > > A small suggestion: since unget is expected to be called infrequently, > next should better be faster for the common case instead of penalizing > it with a try/except: > > def next(self): > if not self.pushed_back: > return self.it.next() > else: > return self.pushed_back.pop() > If speed is an issue then it may be better to avoid the test altogether: def __init__(self, it): self.it = it self.pushed_back = [] self.nextfn = it.next def __iter__(self): return self def __nonzero__(self): if self.pushed_back: return True try: self.pushback(self.nextfn()) except StopIteration: return False else: return True def popfn(self): lst = self.pushed_back res = lst.pop() if not lst: self.nextfn = self.it.next return res def next(self): return self.nextfn() def pushback(self, item): self.pushed_back.append(item) self.nextfn = self.popfn From mfb.chikazuku at gmail.com Sat Apr 12 14:38:22 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Sat, 12 Apr 2008 20:38:22 +0200 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <47ff8489$0$6841$2d805a3e@textnews.eweka.nl> Message-ID: <48010fe5$0$6840$2d805a3e@textnews.eweka.nl> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Gabriel Genellina wrote: > En Fri, 11 Apr 2008 11:31:42 -0300, Michel Bouwmans > escribi?: >> Gabriel Genellina wrote: > >>> Another annoying thing with the Qt license is that you have to choose it >>> at the very start of the project. You cannot develop something using the >>> open source license and later decide to switch to the commercial licence >>> and buy it. >> >> Unless you're a company with a risk of being checked for legal software >> etc., you can always ignore that allthough not very legal. > > I just ignore Qt itself. > Then you're ignorant. What do you prefer than? - - GTK is utter bullshit, creating GUI's functional wise. :r - - WxPython is terribly unstable. (Next to that I dislike it using GTK on *NIX, but that's personal :P) - - Tkinter is ugly and is a memory hog. MFB -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFIAQGjDpaqHmOKFdQRAvbQAKCFwfw2qfMPKzwLny1yaLKBb2xMFACfb/2Z 44qenzoZGgNoP1hd76Rrk6k= =eKjK -----END PGP SIGNATURE----- From bob.martin at excite.com Wed Apr 2 06:39:00 2008 From: bob.martin at excite.com (Bob Martin) Date: Wed, 02 Apr 2008 10:39:00 GMT Subject: Why prefer != over <> for Python 3.0? References: Message-ID: <8nJIj.31740$%N1.6042@newsfe3-gui.ntli.net> in 340625 20080402 094139 "Hendrik van Rooyen" wrote: >John J. Lee wrote: > >>How did programmers manage back then in 32k? > >Some of the answers, in no particular sequence, are: > >Tight, small operating systems that did the minimum. Apart from the GUI stuff, mainframe operating systems did everything that today's x86 OSs do. Early releases of IBM's OS/360 could run in 64KB and offered Fortran, Cobol etc The task time-sharing on release 12 (MVT, about 1971) was better than that in Windows XP or Vista (that should start a few arguments). >Assembler. >Sequential Processing: >- small tasks with multiple passes on tape >( like the concept of Unix pipes ) >Overlays. >Character based menu systems. >No OO. >Code structured to the point of incomprehensibility: >- if ten or so instructions looked similar, >you forced calls instead of inlining. I think you have that back-to-front - it is unstructured code with lots of inlining which is incomprehensible. >Procedural languages, close to the metal. >Small, fixed length, fixed type character based data structures. > >Some of the other veterans may want to add to this list. > >- Hendrik From rw at smsnet.pl Tue Apr 22 14:24:12 2008 From: rw at smsnet.pl (Rob Wolfe) Date: Tue, 22 Apr 2008 20:24:12 +0200 Subject: Problem with urllib2 and authentification References: Message-ID: <8763u921f7.fsf@merkury.smsnet.pl> "Miguel Beltran R." writes: > Using this script for connect to Zope I have this error You forgot to add the authentication handler to the list of handlers. See below. > > ---script: > import urllib2 > > protocolo='http://' > servidor='10.28.1.239/' > pagina='manage' > fullurl=protocolo+servidor+pagina > > aut=urllib2.HTTPBasicAuthHandler() > aut.add_password(realm=None, > uri=servidor, > user='myadmin', > passwd='mypass') > opener=urllib2.build_opener(aut, urllib2.HTTPHandler(debuglevel=1)) Add here: opener.add_handler(aut)) > print opener.open(fullurl).read() HTH, Rob From victorsmiller at gmail.com Wed Apr 16 23:22:18 2008 From: victorsmiller at gmail.com (VictorMiller) Date: Wed, 16 Apr 2008 20:22:18 -0700 (PDT) Subject: urllib working differently when run from crontab References: Message-ID: <678dcbe5-ef5a-4e9a-94ab-d327570be1b2@u69g2000hse.googlegroups.com> On Apr 14, 8:33 am, Matthew Woodcraft wrote: > In article , > > VictorMiller wrote: > > I've written a python script which, using urllib, and urllib2 will > > fetch a number of files that that I'm interested in from various > > websites (they're updated everyday). When I run the script from my > > command line everything works as intended. However, when the script > > is run from crontab every single url that I attempt to open gets > > "connection refused". Has anyone ever seen anything like this? If > > so, what's causing it, and what can I do about it? > > Perhaps you have an http_proxy environment variable set in the > interactive session but not in cron's environment? > Aha! Thanks, I think that that may indeed be the problem. I'll know for sure tomorrow morning after I look at the trace of the run. Victor > -M- From frikker at gmail.com Tue Apr 29 09:39:53 2008 From: frikker at gmail.com (blaine) Date: Tue, 29 Apr 2008 06:39:53 -0700 (PDT) Subject: list.reverse() References: <4816e26a$0$30938$426a74cc@news.free.fr> Message-ID: <98c4ad4d-3174-40cd-b281-84e318d699d3@24g2000hsh.googlegroups.com> On Apr 29, 9:32 am, Roy Smith wrote: > In article <4816e26a$0$30938$426a7... at news.free.fr>, > Bruno Desthuilliers wrote: > > > > > Mark Bryan Yu a ?crit : > > > This set of codes works: > > > >>>> x = range(5) > > >>>> x.reverse() > > >>>> x > > > [4, 3, 2, 1, 0] > > > > But this doesn't: > > > >>>> x = range(5).reverse() > > >>>> print x > > > None > > > This works just as expected - at least for anyone having read the doc. > > > > Please explain this behavior. range(5) returns a list from 0 to 4 and > > > reverse just reverses the items on the list that is returned by > > > range(5). Why is x None (null)? > > > Because that's what list.reverse() returns. Call it a wart if you want > > (FWIW, I do), but at least that's well documented. > > The reasoning goes along the lines of, "reverse in place is an expensive > operation, so we don't want to make it too easy for people to do". At > least that's the gist of what I got out of the argument the many times it > has come up. > > And, yes, I agree with Bruno that it's a wart. > > What you want to do is look at the reversed() function. Not only does it > return something (other than Null), but it is much faster because it > doesn't have to store the reversed list anywhere. What it returns is an > iterator which walks the list in reverse order. If you really want it as a > list, you can turn it into one (with the list() constructor), or you can > just iterate over it with a for loop. > > Same with list.sort() vs. the global sorted(). > > >>> range(5) > > [0, 1, 2, 3, 4] > > >>> reversed(range(5)) > > > > >>> list(reversed(range(5))) > > [4, 3, 2, 1, 0] > > >>> for i in reversed(range(5)): > > ... print i > ... > 4 > 3 > 2 > 1 > 0 > > Check out this cool little trick I recently learned: >>> x=range(5) >>> x.reverse() or x [4, 3, 2, 1, 0] Useful for returning lists that you need to sort or reverse without wasting that precious extra line :) What it does: x.reverse() does the reverse and returns None. or is bitwise, so it sees that 'None' is not 'True' and then continues to process the next operand, x. x or'd with None will always be x (and x has just been changed by the reverse()). So you get the new value of x :) Blaine From srf99 at ferg.org Wed Apr 16 09:21:25 2008 From: srf99 at ferg.org (srf99 at ferg.org) Date: Wed, 16 Apr 2008 06:21:25 -0700 (PDT) Subject: How is GUI programming in Python? References: Message-ID: <0e4c64b9-c570-4d1c-839f-0d5776a2c8cd@d1g2000hsg.googlegroups.com> > I'd like to build a really simple GUI app ? > that will work across Mac, Windows, and Linux. You might look at easygui http://www.ferg.org/easygui/index.html That will give you something simple and workable. Then you can go on to more advanced stuff at your leisure. From duncan.booth at invalid.invalid Mon Apr 14 12:05:23 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 14 Apr 2008 16:05:23 GMT Subject: eval modifies passed dict References: <2b2398b1-042e-46bb-b840-ea9e07d87bd1@2g2000hsn.googlegroups.com> Message-ID: Janto Dreijer wrote: > It seems eval is modifying the passed in locals/globals. This is > behaviour I did not expect and is really messing up my web.py app. > > Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> d = dict(a=1) >>>> d.keys() > ['a'] >>>> eval("a", d) > 1 >>>> d.keys() > ['a', '__builtins__'] > > That can't be right. > That can exactly be right. Python always expects a global called '__builtins__'. If it isn't in the dict you pass to eval to use for globals it will be added. You may, of course, initialise it yourself if you don't want your script to have access to all of the standard globals. The current document is (I think) wrong or at the least misleading. It says: > If the globals dictionary is present and lacks '__builtins__', the > current globals are copied into globals before expression is parsed. I think it should say: > If the globals dictionary is present and lacks '__builtins__', the > current value of __builtins__ is added to globals before expression > is parsed. i.e. only a single variable is assigned, other globals aren't copied. From jzgoda at o2.usun.pl Fri Apr 11 05:37:09 2008 From: jzgoda at o2.usun.pl (Jarek Zgoda) Date: Fri, 11 Apr 2008 11:37:09 +0200 Subject: How to make a "command line basd" interactive program? In-Reply-To: References: Message-ID: Evan napisa?(a): > Hope this hasn't been posted hundreds of times. I'm new for this. > > Before using python for this kind of script, I was using TCL to write > down a "command line based" interactive program. it likes a "tclsh", > or "python" command, after that, you can work under a prompt, for > example, " - >> ", and then you can execute any commands what you > defined in script. > > Now, in python, are there any common way(class) to finish this work? > or does anybody has a example to do that? See module cmd and class Cmd there. -- Jarek Zgoda Skype: jzgoda | GTalk: zgoda at jabber.aster.pl | voice: +48228430101 "We read Knuth so you don't have to." (Tim Peters) From python-url at phaseit.net Mon Apr 28 15:26:06 2008 From: python-url at phaseit.net (Gabriel Genellina) Date: Mon, 28 Apr 2008 19:26:06 +0000 (UTC) Subject: Python-URL! - weekly Python news and links (Apr 28) Message-ID: QOTW: "Posting to comp.lang.python is pair programming with the entire internet ;-)" - Nick Craig-Wood http://groups.google.com/group/comp.lang.python/msg/6f13cfca8a92c1a2 "When it got to the point where managers were asking, 'Why didn't you use the config check tool?', it was a done deal." - Roy Smith, on Python adoption http://mail.python.org/pipermail/advocacy/2008-April/000575.html Ideas to design a Python client/server application involving many aynchronous queries and real-time display of data: http://groups.google.com/group/comp.lang.python/browse_thread/thread/5e46184e940886b9/ Explicit variable declaration for functions: http://groups.google.com/group/comp.lang.python/browse_thread/thread/6c4a508edd2fbe04/ An example showing the difference between inheritance and composition: http://groups.google.com/group/comp.lang.python/browse_thread/thread/44612866d4d2fedb/ Lists: item and slice assignment are confusing for a novice Python programmer: http://groups.google.com/group/comp.lang.python/browse_thread/thread/d00b0c848a3003fc/ Converting xhtml to html isn't as trivial as one might expect: http://groups.google.com/group/comp.lang.python/browse_thread/thread/4bbbcecf89693a74/ Using the subprocess module with non-blocking pipes: http://groups.google.com/group/comp.lang.python/browse_thread/thread/a6dd7b98211bbd4c/ Calling Python from PHP http://groups.google.com/group/comp.lang.python/browse_thread/thread/ffb9d476ee4cd523/ People worried about code breakage in Python 3.0 (continued from last week) http://groups.google.com/group/comp.lang.python/browse_thread/thread/f07feff4f01be76f/ Python Advocacy: success stories http://groups.google.com/group/comp.lang.python/browse_thread/thread/1bd91aca0c86c57c/ ======================================================================== Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. Just beginning with Python? This page is a great place to start: http://wiki.python.org/moin/BeginnersGuide/Programmers The Python Papers aims to publish "the efforts of Python enthusiats": http://pythonpapers.org/ The Python Magazine is a technical monthly devoted to Python: http://pythonmagazine.com Readers have recommended the "Planet" sites: http://planetpython.org http://planet.python.org comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Python411 indexes "podcasts ... to help people learn Python ..." Updates appear more-than-weekly: http://www.awaretek.com/python/index.html Steve Bethard continues the marvelous tradition early borne by Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim Lesher of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to capture useful and interesting recipes. http://aspn.activestate.com/ASPN/Cookbook/Python Many Python conferences around the world are in preparation. Watch this space for links to them. Among several Python-oriented RSS/RDF feeds available are http://www.python.org/channews.rdf http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi http://python.de/backend.php For more, see http://www.syndic8.com/feedlist.php?ShowMatch=python&ShowStatus=all The old Python "To-Do List" now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse http://www.python.org/dev/peps/pep-0042/ The online Python Journal is posted at pythonjournal.cognizor.com. editor at pythonjournal.com and editor at pythonjournal.cognizor.com welcome submission of material that helps people's understanding of Python use, and offer Web presentation of your work. del.icio.us presents an intriguing approach to reference commentary. It already aggregates quite a bit of Python intelligence. http://del.icio.us/tag/python *Py: the Journal of the Python Language* http://www.pyzine.com Archive probing tricks of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 http://groups.google.com/groups?meta=site%3Dgroups%26group%3Dcomp.lang.python.* Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://www.ddj.com/topic/python/ (requires subscription) http://groups-beta.google.com/groups?q=python-url+group:comp.lang.python*&start=0&scoring=d& http://purl.org/thecliff/python/url.html (dormant) or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python There is *not* an RSS for "Python-URL!"--at least not yet. Arguments for and against are occasionally entertained. Suggestions/corrections for next week's posting are always welcome. E-mail to should get through. To receive a new issue of this posting in e-mail each Monday morning (approximately), ask to subscribe. Mention "Python-URL!". Write to the same address to unsubscribe. -- The Python-URL! Team-- Phaseit, Inc. (http://phaseit.net) is pleased to participate in and sponsor the "Python-URL!" project. Watch this space for upcoming news about posting archives. From wescpy at gmail.com Tue Apr 1 13:44:52 2008 From: wescpy at gmail.com (wesley chun) Date: Tue, 1 Apr 2008 10:44:52 -0700 Subject: [ANN] Python course, May 2008 Message-ID: <78b3a9580804011044g370899c4kb86a10cdb0a5218f@mail.gmail.com> *** my apologies... this training course is next month, not this Fall! *** contact me privately off-list for further details. thanks! > FINAL ANNOUNCEMENT > > Need to get up-to-speed with Python as quickly as possible? Come join > me, Wesley Chun, author of Prentice-Hall's well-received "Core Python > Programming," for another comprehensive intro course next month in > beautiful Northern California! I look forward to meeting you! > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > (COMPREHENSIVE) INTRODUCTION TO PYTHON: Mon-Wed, 2008 May 5-7 > > Although this course may appear to those new to Python, it is also > perfect those who have tinkered with it and want to "fill in the gaps" > and/or want to get more in-depth formal training. It combines the > best of both an introduction to the language as well as a "Python > Internals" training course. > > We will immerse you in the world of Python in only a few days. We > will show you more than just its syntax (which you don't really need a > book to learn, right?). Knowing more about how Python works under the > covers, including the relationship between data objects and memory > management, will make you a much more > effective Python programmer coming out of the gate. 3 hands-on labs > each day will help hammer the concepts home. > > Come find out why Google, Yahoo!, Disney, ILM/LucasFilm, VMware, OLPC, > NASA, Ubuntu, YouTube, and Red Hat all use Python. Users supporting or > jumping to Plone, Zope, TurboGears, Django, Pylons, Jython, > IronPython, and Mailman will also benefit! > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > WHERE: near the San Francisco Airport (SFO/San Bruno), CA, USA > > WEB: http://cyberwebconsulting.com (click "Python Training") > > LOCALS: easy freeway (101/280/380) with lots of parking plus public > transit (BART and CalTrain) access via the San Bruno stations, easily > accessible from all parts of the Bay Area > > VISITORS: free shuttle to/from the airport, free high-speed internet, > free breakfast and regular evening receptions; fully-equipped suites > > See website for costs, venue info, and registration. Discounts are > available for multiple registrations as well as for teachers/students. > > Hope to see you there! > -- wesley > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > "Core Python Programming", Prentice Hall, (c)2007,2001 > http://corepython.com > > wesley.j.chun :: wescpy-at-gmail.com > python training and technical consulting > cyberweb.consulting : silicon valley, ca > http://cyberwebconsulting.com > -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall, (c)2007,2001 http://corepython.com wesley.j.chun :: wescpy-at-gmail.com python training and technical consulting cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com From hobgoodoreneyhb at gmail.com Tue Apr 22 11:46:05 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:46:05 -0700 (PDT) Subject: crack hoe Message-ID: crack hoe http://cracks.12w.net F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Mon Apr 14 21:23:28 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 14 Apr 2008 22:23:28 -0300 Subject: How to make python run faster References: <0baa301a-ec8c-48ef-b30e-f9c80f72e5af@u12g2000prd.googlegroups.com> Message-ID: En Mon, 14 Apr 2008 10:48:47 -0300, ??? escribi?: > I read this article on http://kortis.to/radix/python_ext/ Note the date (2002) and the Python version used (2.1) > And I decided to try if it's true. > > I write the program in 4 ways: > > 1. Pure C > 2. Python using C extension > 3. Python using psycho > 4. Pure Python > > And then I used timeit to test the speed of these 4. Unsurprisingly, > the time they cost were: > > 4 > 3 > 2 > 1 > > But I did noticed that 2 is a least 3 times slower than 1, not as fast > as the article stated. > > That's quite weird and I thought maybe it's because I am using > Windows. I did the same test on Linux and I found 2 only uses 1.5 > times of time of 1. > > But, it is still not as fast as 1. As other have noted, there are two important things to consider: 1) use the right algorithm and the right data structure for the job. Usually it's much better to use an O(n) process (if available) than to try to microoptimize an O(n?) variant. 2) profile and measure your code to find the critical parts, and apply optimizations ONLY on those. The algorithm used in the article... hmmm, well, this is a public forum and there are ladies and minors so I won't use *those* words, but it's really horrible, or horrible?, and that makes the whole article moot. Python has *other* advantages, apart from speed: easy to write meaningful code, expresiveness, code easy to understand by others, higher order constructs, easy to write prototypes, non trivial OO... Take the good things from Python and delegate the speed, when required, to Cython or psyco or a C extension or a normal C library+ctypes. -- Gabriel Genellina From deets at nospam.web.de Tue Apr 8 11:29:35 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 08 Apr 2008 17:29:35 +0200 Subject: list.sort(): heaviest item? References: Message-ID: <661hbrF2iip12U1@mid.uni-berlin.de> Steven Clark wrote: > If I have a list of items of mixed type, can I put something into it > such that after a list.sort(), is guaranteed to be at the end of the > list? > > Looking at http://www.python.org/doc/2.3.5/ref/comparisons.html > "Most other types compare unequal unless they are the same object; the > choice whether one object is considered smaller or larger than another > one is made arbitrarily but consistently within one execution of a > program." > > makes me unsure. > > It looks like "None" always ends up at the start ("lightest"), but I > want the opposite ("heaviest"). You can pass a cmp-function that will always make one object being greater than all others. Diez From primoz.skale.lists at gmail.com Wed Apr 2 16:55:07 2008 From: primoz.skale.lists at gmail.com (Primoz Skale) Date: Wed, 2 Apr 2008 22:55:07 +0200 Subject: default method parameter behavior References: <879d72da-825f-4b2b-8244-87367647fb6e@f63g2000hsf.googlegroups.com> Message-ID: wrote in message news:879d72da-825f-4b2b-8244-87367647fb6e at f63g2000hsf.googlegroups.com... >I ran into a similar situation like the following (ipython session). > Can anyone please explain why the behavior? > Thanks in advance. > > In [11]: def foo(b=[]): > ....: b.append(3) > ....: return b > ....: > > In [12]: foo() > Out[12]: [3] > > In [13]: foo() > Out[13]: [3, 3] > > In [14]: foo([]) > Out[14]: [3] > > In [15]: foo([]) > Out[15]: [3] I think it has something to do with foo.func_defaults thing :) If parameter that is assigned a default value is mutable then foo.func_defaults is changed everytime there is no parameter passed to the function. For example: >>> def f(b=[]): b.append(3) return b >>> f.func_defaults #default is [], because function was not yet called ([],) >>> f() #no args [3] >>> f.func_defaults #default is now b=[3], because b is mutable object ([3],) >>> f([]) #empty; default still == [3] [3] >>> f.func_defaults #as we can see here ([3],) >>> f() #again no args; default is changed to [3,3] [3, 3] >>> f.func_defaults ([3, 3],) >>> f([]) #no args [3] >>> f.func_defaults ([3, 3],) As *I* understand it, it goes something like this. Because mutable objects change globaly if not passed correctly, and because [] is mutable, python creates a *def global* object, which is only seen by function that created it, with a name b to which it assigns a default value of []. But when this default [] is changed in function, it becomes [3], and so on..... Correct me if I am wrong... P. From ed at leafe.com Tue Apr 1 14:45:46 2008 From: ed at leafe.com (Ed Leafe) Date: Tue, 1 Apr 2008 13:45:46 -0500 Subject: What motivates all unpaid volunteers at Pycon? In-Reply-To: <12d7412e-9f87-4798-a319-a78a27f68d00@e6g2000prf.googlegroups.com> References: <7b539c8e-af4c-4409-81bc-d94e687eea59@i7g2000prf.googlegroups.com> <12d7412e-9f87-4798-a319-a78a27f68d00@e6g2000prf.googlegroups.com> Message-ID: On Apr 1, 2008, at 1:20 PM, seberino at spawar.navy.mil wrote: >> There really isn't any simple answer. Most people seem to be >> motivated >> to help out their communities, > > I still think all this unselfishness is noteworthy > and curious. Assuming that people get nothing back by participating in a community, yes, it would be curious. My experience, though, is that I get a lot more out of it than I could ever contribute. IOW, it's a great example of synergy. -- Ed Leafe From medin0065 at gmail.com Sun Apr 20 10:43:38 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:43:38 -0700 (PDT) Subject: deer hunter 2005 crack Message-ID: deer hunter 2005 crack http://cracks.00bp.com F R E E C R A C K S From jantod at gmail.com Mon Apr 14 11:23:25 2008 From: jantod at gmail.com (Janto Dreijer) Date: Mon, 14 Apr 2008 08:23:25 -0700 (PDT) Subject: eval modifies passed dict Message-ID: <2b2398b1-042e-46bb-b840-ea9e07d87bd1@2g2000hsn.googlegroups.com> It seems eval is modifying the passed in locals/globals. This is behaviour I did not expect and is really messing up my web.py app. Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> d = dict(a=1) >>> d.keys() ['a'] >>> eval("a", d) 1 >>> d.keys() ['a', '__builtins__'] That can't be right. Regards Janto From michele.simionato at gmail.com Wed Apr 23 15:12:34 2008 From: michele.simionato at gmail.com (Michele Simionato) Date: Wed, 23 Apr 2008 12:12:34 -0700 (PDT) Subject: Python generators (coroutines) References: Message-ID: <8744f315-4408-4f1f-81d7-6876b7274181@34g2000hsh.googlegroups.com> On Apr 23, 8:26 pm, Jean-Paul Calderone wrote: > On Wed, 23 Apr 2008 10:53:03 -0700 (PDT), Michele Simionato: > You could have #2. It's a trivial variation of sending a value. For > example, > > http://twistedmatrix.com/trac/browser/trunk/twisted/internet/defer.py... > > Jean-Paul Yep, I stand corrected, it is only #1 which is the real improvement. From maxerickson at gmail.com Sun Apr 27 18:54:15 2008 From: maxerickson at gmail.com (Max Erickson) Date: Sun, 27 Apr 2008 22:54:15 +0000 (UTC) Subject: Python equivalent to PHP's SPL __autoload() ?? References: <5bfb3fa2-652c-4ce5-b914-27ef21685c33@p25g2000pri.googlegroups.com> Message-ID: Ixiaus wrote: > I was curious (and have spent an enormous amount of time on Google > trying to answer it for myself) if Python has anything remotely > similar to PHP's SPL __autoload() for loading classes on the fly?? > > After digging through docs I feel doubtful there is such a language > feature, but, it is possible I missed something or maybe someone has > written an extension?!? > > Thanks in advance! > -- > http://mail.python.org/mailman/listinfo/python-list > If I'm understanding __autoload() correctly, not in the box, but most of what you need is built in, you just have to do a little work to use it. See the "Loading and reloading modules" section on this page: http://effbot.org/librarybook/builtin.htm max From deets at nospam.web.de Tue Apr 29 18:39:52 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 30 Apr 2008 00:39:52 +0200 Subject: how to convert a multiline string to an anonymous function? In-Reply-To: References: Message-ID: <67pmdnF2p5fhgU1@mid.uni-berlin.de> Danny Shevitz schrieb: > Simple question here: > > I have a multiline string representing the body of a function. I have control > over the string, so I can use either of the following: > > str = ''' > print state > return True > ''' > > str = ''' > def f(state): > print state > return True > ''' > > and I want to convert this into the function: > > def f(state): > print state > return True > > but return an anonmyous version of it, a la 'return f' so I can assign it > independently. The body is multiline so lambda doesn't work. > > I sort of need something like: > > def function_constructor(str): > f = eval(str) # What should this be > return f > > functions = {} > for node in nodes: > function[node] = function_constructor(node.text) > > I'm getting stuck because 'def' doesn't seem to work in an eval function, > and exec actually modifies the namespace, so I run into collisions if I use > the function more than once. > > I know I'm missing something stupid here, but I'm stuck just the same... The "stupid" thing is that you can pass your own dictionary as globals to exec. Then you can get a reference to the function under the name "f" in the globals, and store that under whatever name you need. Beware of recursion though! If that happens, you need to create unique names for your functions, but as you know these beforehand I don't see any problem with that - just enumerate them, like f1, f2, f3.... Diez From mdw at distorted.org.uk Tue Apr 1 13:32:41 2008 From: mdw at distorted.org.uk (Mark Wooding) Date: Tue, 1 Apr 2008 17:32:41 +0000 (UTC) Subject: deleting a line from a file References: <13usb5ngt26qv26@corp.supernews.com> <7xy781zqkq.fsf@ruckus.brouhaha.com> Message-ID: Paddy wrote: > Why not use the fileinput modules functionality to iterate over a file > in-place,printing just those lines you want? >From the Python 2.5 manual: : *Optional in-place filtering:* if the keyword argument `INPLACE=1' is : passed to `input()' or to the `FileInput' constructor, the file is : moved to a backup file and standard output is directed to the input : file (if a file of the same name as the backup file already exists, it : will be replaced silently). This behaviour is very dangerous. If the script fails half-way through, it will leave the partially-written file in place, with the `official' name. The change-over is not atomic, breaking other programs attempting to read simultaneously with an update. Two almost-simultaneous updates will corrupt the file without a usable backup. The first will back up the input file, and start writing. A second will /replace/ the backup file with the partially-constructed output of the first, and then start processing it; but since its input is incomplete, it will produce incomplete output. The safely_writing context manager has none of these defects. -- [mdw] From aaron.watters at gmail.com Sun Apr 27 20:01:58 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Sun, 27 Apr 2008 17:01:58 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> <48118719$0$25846$9b622d9e@news.freenet.de> Message-ID: > shame > 1 a. a painful emotion caused by consciousness of guilt, > ? ? ?shortcoming, or impropriety > 2 a condition of humiliating disgrace or disrepute Sigh. This is stupid (in the usual usage), but I must reply because I can't control myself. I meant usage 5: "something regrettable, unfortunate, or outrageous: it's a shame that he wasn't told." -- http://www.yourdictionary.com/shame I think outrageous is appropriate here because I think it's outrageous to change the basic usage for things like dictionary.keys() when it would be so easy to leave the old definition and add a new method like dictionary.keySet(). This would save me personally a great deal of painful tedium, I suspect (especially considering that I've implemented a lot of "dictionary-like" objects -- so I'll have to change the way their "keys" method works -- or something -- I haven't figured it out yet...). I know that the designers of Python are motivated by a desire to attain a Platonic ideal of aesthetic perfection primarily with a weaker desire to make lives easy for people writing libraries and tools somewhere further down the list, but from my perspective it's a shame^H^H^H^H^H regretable and unfortunate that the aesthetics so often trumps other considerations. In C# and java, for example, this sort of issue has never been a problem in my experience: stuff I wrote many versions ago still works just fine with no changes (but please note that I don't write gui stuff, which is less stable -- I'm speaking of algorithmic and system libraries). -- Aaron Watters === btw: usage (5) for "shame" in the python source: http://www.xfeedme.com/nucular/pydistro.py/go?FocusId=463&FREETEXT=shame From torriem at gmail.com Thu Apr 17 13:34:07 2008 From: torriem at gmail.com (Michael Torrie) Date: Thu, 17 Apr 2008 11:34:07 -0600 Subject: Can't do a multiline assignment! In-Reply-To: <564dd82b-8670-4ead-a3c8-a22b30a3eb73@m73g2000hsh.googlegroups.com> References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <1952579a-3cfb-44ea-92aa-658daa64aee4@a70g2000hsh.googlegroups.com> <564dd82b-8670-4ead-a3c8-a22b30a3eb73@m73g2000hsh.googlegroups.com> Message-ID: <48078A0F.90304@gmail.com> s0suk3 at gmail.com wrote: > I do it with all the separate variables mainly for performance. If I > had the headers in a dict, I'd be looking up a string in a list of > strings (the keys of the dict) everytime I check for a header. Not > that that's going to take more that 0.1 seconds, but the program is > still small and simple. As it gets bigger, more features are gonna > slow things down. As I just said in my other post, this is all premature optimization. Make your program simple and clear up front, and then work on spot-optimizations in the places that your code really is slow. Premature optimization can kill you in terms of code reliability and maintainability. The rule of thumb is that 80% of your program's execution time will be in 20% of the code. Therefore you have to profile the code and fine out exactly where this 20% is. Then you can optimize it. Another thing to consider is that referencing a member of a class or instance already *is* a dictionary lookup. It's how python works. Thus dictionaries are optimized to be fast. Since strings are immutable, python hashes them into a fast lookup pointer. So every time you say mydict["mykey"], it already knows the lookup pointer (hash) for "mykey" (the string) and can find the dictionary entry very quickly, ideally in O(1) time (well maybe log(N)). Thus putting your headers in a dictionary is actually a really good idea for performance reasons. From bjourne at gmail.com Sat Apr 5 07:26:59 2008 From: bjourne at gmail.com (=?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=) Date: Sat, 5 Apr 2008 13:26:59 +0200 Subject: ANN: pry unit testing framework In-Reply-To: <20080405105459.GB15154@nullcube.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> Message-ID: <740c3aec0804050426m39837404i8e8d6c232bef7724@mail.gmail.com> On Sat, Apr 5, 2008 at 12:54 PM, Aldo Cortesi wrote: > Thus spake Matthieu Brucher (matthieu.brucher at gmail.com): > > > > How does it compare to the nose framework ? > > As far as the base unit testing functionality is concerned, I think > they try to address similar problems. Both have assert-based testing > with inspection and re-parsing of assert exceptions for better error > messages. Both try to provide better fixture management. Both make > programmatic test generation easier. Both have a command-line tool for > running and gathering tests. > > I like nose, but I'm biased, and of course I think Pry has some > advantages. One difference I'd point out is Pry's tree-based test > structure, which provides a number of conveniences and features (much > nicer test selection from the command line, for instance). Isn't nose tree-based too? You can select both single test-cases suites or directories to run. Anyway, I don't think comparisions with nose is fair, because nose is the best of the best and all other test runners fall short of it. :) nose and nose-like test runners use automatic test case discovery, so that you don't have to write redundant boilerplate like in PyUnit and PyUnit-like frameworks. To take an example from Pry's manual: import libpry class MySuite(libpry.AutoTree): def setUpAll(self): self.all_fixture = True def tearDownAll(self): self.all_fixture = False def setUp(self): self.fixture = True def tearDown(self): self.fixture = False def test_one(self): assert self.fixture assert self.all_fixture tests = [ MySuite() ] in those, this could be written like this: class Empty: pass obj = Empty() def setup(): obj.all_fixture = True def setup_func(): obj.fixture = True def teardown(): obj.all_fixture = False def teardown_func(): obj.fixture = False @with_setup(setup_func, teardown_func) def test_one(): assert self.fixture assert self.all_fixture nose gives you much more bang per line of code. -- mvh Bj?rn From hopeorpha308 at gmail.com Sun Apr 27 07:46:44 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:46:44 -0700 (PDT) Subject: camfrog pro crack Message-ID: <2fef5514-b664-4959-8de9-3dd218970e1d@b1g2000hsg.googlegroups.com> camfrog pro crack http://wga-cracks.crackkey.net From gagsl-py2 at yahoo.com.ar Thu Apr 10 23:23:22 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 11 Apr 2008 00:23:22 -0300 Subject: Python conventions References: Message-ID: En Thu, 10 Apr 2008 16:52:11 -0300, escribi?: > Daniel Fetchinson wrote: >> I'm sorry to disappoint you but this project has already been completed: >> >> http://www.python.org/dev/peps/pep-0008/ > > Daniel, PEP 8 is anything but complete. How much of the following > simple question can you answer from there: > > Given that you can name things with UpperAndLower, lowerAndUpper, > lower_and_underscore, etc., what is the convention for naming > packages, modules, classes, ... > > PEP 8 very much reminds me of Sun's Java conventions - a start, but > only a start. Also, in part, controversial. (How wide do you think > Python code should be?) Finally, lacking in basic organization. (This > seems to be a disease that infects almost all standards.) We can do > better. As a guess, GvR would be happy to have someone fill out PEP 8. This feels like a dej?-vu... Your thread from last January: http://groups.google.com/group/comp.lang.python/browse_thread/thread/96fac33ed9d601b7/ If you like doing these kind of things, go ahead and summarize them. You have more than 30 style guides to start with. Enjoy. -- Gabriel Genellina From cmpython at gmail.com Wed Apr 9 00:18:56 2008 From: cmpython at gmail.com (CM) Date: Tue, 8 Apr 2008 21:18:56 -0700 (PDT) Subject: Converting a tuple to a list References: <00ba01c899c5$14528ae0$0a01a8c0@mobile> Message-ID: <0276f1e5-c37b-4698-9f20-ca26e2d9201f@m71g2000hse.googlegroups.com> On Apr 8, 6:46 pm, "Gabriel Ibanez" wrote: > Gabriel Ibanez wrote: > > Hi all .. > > > I'm trying to using the map function to convert a tuple to a list, without > > success. > > > I would like to have a lonely line that performs the same as loop of the > > next script: > > > ------------------------------------------- > > # Conveting tuple -> list > > > tupla = ((1,2), (3,4), (5,6)) > > > print tupla > > > lista = [] > > for a in tupla: > > for b in a: > > lista.append(b) > > print lista > > ------------------------------------------- > > > Any idea ? > > > Thanks ... > > > # Gabriel > > list(tupla) > > would probably do it. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > --http://mail.python.org/mailman/listinfo/python-list > > That would just make a list of tuples, I think he wants [1, 2, 3, 4, 5, 6]. > > Try: l = [x for z in t for x in z] > > --Brian > > --------------- > > Thanks Steve and Brian, > > Brian: that is !! > > However, it's a bit difficult to understand now. I have read it several > times :) Doing it this way is called a "list comprehension", which means you put the formula inside the brackets and that new list will be built with the formula. This one is also easier to understand if you substitute more meaningful names than l, x,t,z...like so: newlist = [number for subtuple in fulltuple for number in subtuple] or, writing it in the typical for loop way (not using the list comprehension shortcut): for subtuple in fulltuple: for number in subtuple: newlist.append(number) but the list comprehension doesn't need the append part, it is built in. They're handy. From xahlee at gmail.com Tue Apr 22 17:41:33 2008 From: xahlee at gmail.com (xahlee at gmail.com) Date: Tue, 22 Apr 2008 14:41:33 -0700 (PDT) Subject: pop langs website ranking Message-ID: <41fbaf27-a80b-402b-b406-c048a65a8643@b64g2000hsa.googlegroups.com> In February, i spent few hours researching the popularity of some computer language websites. (The message can be found here: http://xahlee.org/lang_traf/lang_sites.html http://community.livejournal.com/lisp/42778.html http://groups.google.com/group/comp.lang.perl.misc/msg/59c87899c2668f4c ) In that post, one question i puzzeled over is why PaulGraham.com's traffic is surprisingly high, since the site doesn't seems to host forums, computer lang documentation, or wiki type of thing, yet it is ranked higher than perl.com, which actually host online forum, faq, documentation, news etc. I wrote: ------------ paulgraham.com 48153 (lisp bigwig, but huh?) Perl.com 49104 xahlee.org 80060 ? Me! ------------- Compared to xahlee.org, it's a ranking difference about 32 thousand! Today, while checking the web ranking site alexa.com, they seems to have updated their ranking algorithm to be more fair, as opposed basing it solely on a browser toolbar that users install. So i went over to my essay and checked the ranking again of sites i reported. I have spent only about 20 min to cursorily go thru the sites i reported before. It appears that, in general, the order of sites that i listed ROUGHLY remains unperturbed, but the specific ranking ordinal has changed rather significantly. However, there's a big surprise. My website is now actually ranked higher than PaulGraham.com ! LOL. Paul Graham? Bah humbug. Painters == Hackers? Fuck ya ass. Arc? Eat shit and die. PS: not having no confidence of myself, but i note that xahlee.org is now marginally ranked higher than perl.com and perl.org, both of which host forum/blog/wiki, news, docs, etc., while my website don't do any of these and is all static html pages. For those unflagging, alternative web ranking site is http://ww.quantcast.com/ . I'll be doing some research sometimes soon on this. Xah xah at xahlee.org ? http://xahlee.org/ ? From timothy.brian14 at gmail.com Fri Apr 11 12:17:05 2008 From: timothy.brian14 at gmail.com (Timothy B) Date: Fri, 11 Apr 2008 09:17:05 -0700 (PDT) Subject: Sr. Lead Architect - (NYC) Message-ID: I am in need for a Sr. Lead Architect for an outstanding company located in NYC. The company has been outsourcing their technology to California and are bringing the office to NYC. The company is looking for an individual who can build and manage the technolgy team in NYC. Individual must be a Python expert. Please contact timothy.brian14 at gmail.com Thanks, Tim From barronmo at gmail.com Wed Apr 23 15:05:22 2008 From: barronmo at gmail.com (barronmo) Date: Wed, 23 Apr 2008 12:05:22 -0700 (PDT) Subject: print some text Message-ID: <7ac7b11d-6c9b-477c-8c0d-b038bc760918@c58g2000hsc.googlegroups.com> I'm a beginner searching for an easy way to print the contents of a text control. So far I've come up with the following(difficulties): 1) using wxPython -convert to HTML and then print (I don't know anything about HTML) -use wx.Printout (Seems complicated; may be beyond my abilities) 2) create a text file and then print it out (can create but can only print with the win32api.ShellExecute method so this solution doesn't help me on my Linus laptop) 3) use ReportLab to create .pdf and then print that out (again, can create but can't print in Linux) Thanks for any help. Mike From cokofreedom at gmail.com Thu Apr 10 04:51:14 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Thu, 10 Apr 2008 01:51:14 -0700 (PDT) Subject: questions about Exceptions? References: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> Message-ID: <71cc8c25-f5f9-4f21-a9d8-06780bf97608@f63g2000hsf.googlegroups.com> In general you should only catch the exceptions you want to catch, therefore avoiding the issue of catching "unexpected" ones, for instances the programming unexpectandly closing. Well, exception handling is expensive (when it catches one) so it really is up to you. If you are using eval and know it might "EOF" then you should probably look to handle that. The main IF statement style I can think of (checking the end of the string) wouldn't be much of an improvement. Currently I would be very worried about seeing that code as it breaks a number of "conventions". However it depends on the importance of the code to wherever or not you should change this. (Global variable, the use of Eval, the CATCH ALL except and the setting of a global variable at the end.) I've seen a good few (simple and advanced) calculator examples using python on the NET, it might be worth looking at some to see their style of coding a calculator to help your own. From mattheww at chiark.greenend.org.uk Sun Apr 20 12:42:05 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 20 Apr 2008 17:42:05 +0100 (BST) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: Christian Heimes wrote: >> I feel that including some optional means to block code would be a big >> step in getting wider adoption of the language in web development and >> in general. I do understand though, that the current strict indenting >> is part of the core of the language, so... thoughts? > Why should Python repeat the mistakes other languages did with SSI or > inline code? Python favors the MVC separation of code and layout. An alternative scheme for describing the block structure could be useful in other cases, though. For example, if you wanted to support putting snippets of Python in configuration files, or spreadsheet cells. There's no need to support the new scheme in .py files, so it seems to me that this doesn't have to be done in the core language. All that's needed is a variant of 'eval' which expects the alternate scheme, and that could be prototyped just using text manipulation and the normal 'eval'. If someone wrote a library for this and it proved popular, I expect it would be considered for the standard library. -M- From rw at smsnet.pl Tue Apr 22 14:39:16 2008 From: rw at smsnet.pl (Rob Wolfe) Date: Tue, 22 Apr 2008 20:39:16 +0200 Subject: Problem with urllib2 and authentification References: <8763u921f7.fsf@merkury.smsnet.pl> Message-ID: <871w4x20q3.fsf@merkury.smsnet.pl> Rob Wolfe writes: >> ---script: >> import urllib2 >> >> protocolo='http://' >> servidor='10.28.1.239/' >> pagina='manage' >> fullurl=protocolo+servidor+pagina >> >> aut=urllib2.HTTPBasicAuthHandler() >> aut.add_password(realm=None, >> uri=servidor, >> user='myadmin', >> passwd='mypass') >> opener=urllib2.build_opener(aut, urllib2.HTTPHandler(debuglevel=1)) Please ignore me. I overlooked that you added this handler here. But anyway I would try this `add_handler` method. ;) Rob From martin at v.loewis.de Sun Apr 27 13:28:39 2008 From: martin at v.loewis.de (=?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?=) Date: Sun, 27 Apr 2008 19:28:39 +0200 Subject: Why can't timedeltas be divided? In-Reply-To: References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> <48142747$0$20906$9b622d9e@news.freenet.de> Message-ID: <4814b7c7$0$30314$9b622d9e@news.freenet.de> > i've had a look at the source code and written a small patch (attached; > contains a case in classical/floor division as well as truediv). > is there a defined escalation procedure from python-list to python-dev > or should i just send the suggestion+patch there? Post a patch to bugs.python.org, optionally also post a message referring to that patch to python-dev. Regards, Martin From steve at holdenweb.com Wed Apr 16 17:03:33 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 16 Apr 2008 17:03:33 -0400 Subject: py3k s***s In-Reply-To: References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> <09a38ca2-8c49-4eee-b6cf-58e849aea1fc@q1g2000prf.googlegroups.com> Message-ID: <480669A5.3050705@holdenweb.com> Aaron Watters wrote: > On Apr 16, 2:33 pm, Rhamphoryncus wrote: >> The point is, you can't have it both ways. Either you evolve the >> language and break things, or you keep it static and nothing breaks. > > I disagree. You can add lots of cool > stuff without breaking the existing code base, mostly. > For example the minor changes to the way ints will work will > effect almost no programs. > > I don't see the urgency to clean up what are essentially > cosmetic issues and throw out or > require rewrites for just about all existing Python > code. Python 2.6 isn't fundamentally awful like Perl 4 was. > The cost paid for these minor improvements is too high in my > book. But I suppose if it is going to happen do it sooner > rather than later. Just *please* *please* don't > systematically break the pre-existing code base again for a > very long time, preferable ever. I'm pretty sure the 3.0 compatibility breakage is a one-shot deal. If it's not I won't be the only one looking for Guido with a bog stick in my hand ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From reckoner at gmail.com Tue Apr 15 11:27:21 2008 From: reckoner at gmail.com (Reckoner) Date: Tue, 15 Apr 2008 08:27:21 -0700 (PDT) Subject: use object method without initializing object Message-ID: would it be possible to use one of an object's methods without initializing the object? In other words, if I have: class Test: def __init__(self): print 'init' def foo(self): print 'foo' and I want to use the foo function without hitting the initialize constructor function. Is this possible? From sjmachin at lexicon.net Wed Apr 2 17:10:48 2008 From: sjmachin at lexicon.net (John Machin) Date: Wed, 02 Apr 2008 21:10:48 GMT Subject: xlrd and cPickle.dump In-Reply-To: <8abe8ae1-84c9-4f80-ab37-31497a4d273c@a23g2000hsc.googlegroups.com> References: <34e62ddb-477f-4a99-97a5-21a7b148d244@e67g2000hsa.googlegroups.com> <47f22a41@news.mel.dft.com.au> <0d46a213-9f95-43b5-835b-d74d8403626b@c19g2000prf.googlegroups.com> <6acbf9b4-161b-47db-9a91-b2448ee63c34@c26g2000prf.googlegroups.com> <12375df7-387d-424d-84a8-76beb664ae47@59g2000hsb.googlegroups.com> <8abe8ae1-84c9-4f80-ab37-31497a4d273c@a23g2000hsc.googlegroups.com> Message-ID: <47f3f654@news.mel.dft.com.au> patrick.waldo at gmail.com wrote: >> FWIW, it works here on 2.5.1 without errors or warnings. Ouput is: >> 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] >> 0.6.1 > > I guess it's a version issue then... I say again: Don't guess. > > I forgot about sorted! Yes, that would make sense! > > Thanks for the input. > > > On Apr 2, 4:23 pm, patrick.wa... at gmail.com wrote: >> Still no luck: >> >> Traceback (most recent call last): >> File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework >> \scriptutils.py", line 310, in RunScript >> exec codeObject in __main__.__dict__ >> File "C:\text analysis\pickle_test2.py", line 13, in ? >> cPickle.dump(Data_sheet, pickle_file, -1) >> PicklingError: Can't pickle : attribute lookup >> __builtin__.module failed I didn't notice that the exception had changed from the original: "TypeError: can't pickle file objects" (with protocol=0) to: "TypeError: can't pickle module objects" (pickling an xlrd.Book object with protocol=-1) and now to: "PicklingError: Can't pickle : attribute lookup __builtin__.module failed" (pickling an xlrd.Sheet object with protocol -1) I'm wondering if this is some unfortunate side effect of running the script in the pywin IDE ("exec codeObject in __main__.__dict__"). Can you reproduce the problem by running the script in the Command Prompt window? What version of pywin32 are you using? >> >> My code remains the same, except I added 'wb' and the -1 following >> your suggestions: >> >> import cPickle,xlrd, sys >> >> print sys.version >> print xlrd.__VERSION__ >> >> data_path = """C:\\test\\test.xls""" >> pickle_path = """C:\\test\\pickle.pickle""" >> >> book = xlrd.open_workbook(data_path) >> Data_sheet = book.sheet_by_index(0) >> >> pickle_file = open(pickle_path, 'wb')cPickle.dump(Data_sheet, pickle_file, -1) >> pickle_file.close() >> >> To begin with (I forgot to mention this before) I get this error: >> WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non- >> zero "WARNING" != "error". If that's the only message you get, ignore it; it means that your XLS file was created by the perl XLS-writing package or a copier thereof. >> >> I'm not sure what this means. >> >>> What do you describe as "simple manipulations"? Please describe your >>> computer, including how much memory it has. >> I have a 1.8Ghz HP dv6000 with 2Gb of ram, which should be speedy >> enough for my programming projects. However, when I try to print out >> the rows in the excel file, my computer gets very slow and choppy, >> which makes experimenting slow and frustrating. Just printing the rows is VERY UNLIKELY to cause this. Demonstrate this to yourself by using xlrd's supplied runxlrd script: command_prompt> c:\python24\scripts\runxlrd.py show yourfile.xls >> Maybe cPickle won't >> solve this problem at all! 99.9% chance, not "maybe". >> For this first part, I am trying to make >> ID numbers for the different permutation of categories, topics, and >> sub_topics. So I will have [book,non-fiction,biography],[book,non- >> fiction,history-general],[book,fiction,literature], etc.. >> so I want the combination of >> [book,non-fiction,biography] = 1 >> [book,non-fiction,history-general] = 2 >> [book,fiction,literature] = 3 >> etc... >> >> My code does this, except sort returns None, which is strange. list.sort() returns None by definition; it sorts the list object's contents in situ. > I just >> want an alphabetical sort of the first option, which sort should do >> automatically. When I do a test like>>>nest_list = [['bbc', 'cds'], ['jim', 'ex'],['abc', 'sd']] >>>>> nest_list.sort() >> [['abc', 'sd'], ['bbc', 'cds'], ['jim', 'ex']] >> It works fine, but not for my rows. Why are you sorting? >> >> Here's the code (unpickled/unsorted): >> import xlrd, pyExcelerator >> >> path_file = "C:\\text_analysis\\test.xls" >> book = xlrd.open_workbook(path_file) >> ProcFT_QC = book.sheet_by_index(0) >> log_path = "C:\\text_analysis\\ID_Log.log" >> logfile = open(log_path,'wb') >> >> set_rows = [] The test x in y where y is a sequence needs to compare with half of the existing items on average. You are doing that test N times. If the number of unique rows is U, it will do about N*U/4 comparisons. You said N is about 50,000. The changes below make y a set; consequentially x needs to be a tuple instead of a list. set_rows = set() >> rows = [] >> db = {} >> n=0 >> while n> rows.append(ProcFT_QC.row_values(n, 6,9)) rows.append(tuple(ProcFT_QC.row_values(n, 6,9))) >> n+=1 >> print rows.sort() #Outputs None >> ID = 1 >> for row in rows: >> if row not in set_rows: >> set_rows.append(row) set_rows.add(row) >> db[ID] = row >> entry = str(ID) + '|' + str(row).strip('u[]') + '\r\n' Presuming your data is actually ASCII, you could save time and memory by converting it once as you extract it from the spreadsheet. entry = str(ID) + '|' + str(row).strip('u()') + '\r\n' >> logfile.write(entry) >> ID+=1 >> logfile.close() >> HTH, John From sturlamolden at yahoo.no Wed Apr 16 20:37:43 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Wed, 16 Apr 2008 17:37:43 -0700 (PDT) Subject: I just killed GIL!!! Message-ID: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Hello Guys... I just had one moment of exceptional clarity, during which realized how I could get the GIL out of my way... It's so simple, I cannot help wondering why nobody has thought of it before. Duh! Now I am going to sit and and marvel at my creation for a while, and then go to bed (it's past 2:30 a.m.) Tomorrow I will contemplate whether to sell this little secret for big bucks, give it away for free, or just keep it to myself... :-) Now you are probably thinking I reinvented the gunpowder, and are running multiple processes. Not so. I am not running parallel processes, like parallel python or the processing module in cheese shop. I am running multiple THREADS. In fact, I am just using threading.Thread. The source code is pure Python, so there is no C magic, and I only used the stuff that's already there in the standard library. So, I just made CPython do what everyone claim to be impossible. One single process of CPython is using all the cpu power of my dual-core laptop. From nick at craig-wood.com Tue Apr 29 05:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Tue, 29 Apr 2008 04:30:03 -0500 Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> <87od7ue2ne.fsf@mulj.homelinux.net> <87hcdmdpf9.fsf@mulj.homelinux.net> Message-ID: Hrvoje Niksic wrote: > Nick Craig-Wood writes: > > >> Note that appending to a string is almost never a good idea, since it > >> can result in quadratic allocation. > > > > My aim was clear exposition rather than the ultimate performance! > > That would normally be fine. My post wasn't supposed to pick > performance nits, but to point out potentially quadratic behavior. > > > Anyway str += was optimised in python 2.4 or 2.5 (forget which) wasn't > > it? > > That optimization works only in certain cases, when working with > uninterned strings with a reference count of 1, and then only when the > strings are in stored local variables, rather than in global vars or > in slots. And then, it only works in CPython, not in other > implementations. The optimization works by "cheating" -- breaking the > immutable string abstraction in the specific cases in which it is > provably safe to do so. > http://utcc.utoronto.ca/~cks/space/blog/python/ExaminingStringConcatOpt > examines it in some detail. Ah, I didn't realise that - thanks for the interesting link. For the example I gave, just a simple local variable the optimisation kicks in. I can see how you could easily migrate that to an instance variable and the optimisation would no longer work, eg $ python -m timeit -s 's=""' 'for i in xrange(10000): s+="x"' 1000 loops, best of 3: 1.04 msec per loop $ python -m timeit -s 'class A: pass' -s 'a=A(); a.s=""' 'for i in xrange(10000): a.s+="x"' 10 loops, best of 3: 160 msec per loop > Guido was reluctant to accept the patch that implements the > optimization because he thought it would "change the way people write > code", a sentiment expressed in > http://mail.python.org/pipermail/python-dev/2004-August/046702.html > This discussion shows that he was quite right in retrospect. (I'm not > saying that the optimization is a bad thing, just that it is changing > the "recommended" way of writing Python in a way that other > implementations cannot follow.) Certainly something I wasn't aware of before - thanks! -- Nick Craig-Wood -- http://www.craig-wood.com/nick From gagsl-py2 at yahoo.com.ar Sun Apr 20 12:38:38 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 13:38:38 -0300 Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> Message-ID: En Sun, 20 Apr 2008 09:46:37 -0300, Hank @ITGroup escribi?: > ``starting python`` # == Windows Task Manager: > Python.exe *4,076 *K memory-usage == > >>> st1='abcdefg'*999999 # == 10,952 K == > >>> del st1 # == *4,104*K == > >>> st1='abcdefg'*999999 # == 10,952 K == > >>> del st1 # == 4,104 K == > > >>> li = ['abcde']*999999 # == 8,024 K == > >>> del li # == *4,108* K == > > >>> from nltk import FreqDist # == 17,596 == > >>> fd = FreqDist() # == 17,596 == > >>> for i in range(999999):fd.inc(i) # == 53,412 == > >>> del fd # == *28,780* == > >>> fd2 = FreqDist() # == 28,780 == > >>> for i in range(999999):fd2.inc(i) # == 53,412 == > >>> del fd2 # == 28,780 K == > > >>> def foo(): > ... fd3 = FreqDist() > ... for i in range(999999):fd3.inc(i) > > >>> foo() # == *28,788* K == > > >>> def bar(): > ... fd4 = FreqDist() > ... for i in range(999999):fd4.inc(i) > ... del fd4 > # == 28,788 K == > >>> bar() # == 28,788 K == > > > That is my question, after ``del``, sometimes the memory space returns > back as nothing happened, sometimes not... ... > What exactly was happening??? Apart from what everyone has already said, consider that FreqDist may import other modules, store global state, create other objects... whatever. Pure python code should not have any memory leaks (if there are, it's a bug in the Python interpreter). Not-carefully-written C extensions may introduce memory problems. -- Gabriel Genellina From ridenour4159 at gmail.com Thu Apr 24 06:18:24 2008 From: ridenour4159 at gmail.com (ridenour4159 at gmail.com) Date: Thu, 24 Apr 2008 03:18:24 -0700 (PDT) Subject: ilife 08 keygen Message-ID: <086890ad-60be-4901-90e9-c7f4c0259b96@f36g2000hsa.googlegroups.com> ilife 08 keygen http://cracks.12w.net F R E E C R A C K S From colemichae at gmail.com Thu Apr 17 22:43:04 2008 From: colemichae at gmail.com (colemichae at gmail.com) Date: Thu, 17 Apr 2008 19:43:04 -0700 (PDT) Subject: Python for Series 40 Nokia? References: Message-ID: On Apr 18, 8:46 am, "Dotan Cohen" wrote: > I had once heard something about python running on a Series 40 Nokia, > but I am unable to google anything concrete. Might it have been > Jython? Is there a known implementation of Python for the series 40 > (which is not Symbian, by the way)? Will Jython work in such an > environment? > > Thanks in advance. > > Dotan Cohen > > http://what-is-what.comhttp://gibberish.co.il > ?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-? > > A: Because it messes up the order in which people normally read text. > Q: Why is top-posting such a bad thing? there is a comment here of using jython on a nokia S40 Nokia 7210 SDK for Nokia Series 40 platform. http://bookshelf.sourceforge.net/en/src-build.html So i think i will work. I am using a S60 and works well, I have a GPS program in Python, Editors, Ogg player, and other assorted items. I myself purchased the Nokia N70 purely because of the Python ability it had.. From bignose+hates-spam at benfinney.id.au Fri Apr 18 22:01:28 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Sat, 19 Apr 2008 12:01:28 +1000 Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> <87lk3asrfm.fsf@benfinney.id.au> Message-ID: <873apir4av.fsf@benfinney.id.au> Ben Finney writes: > Thomas Bellman writes: > > > For what it's worth, Fedora 8 has Python 2.5, RHEL 5 ships with > > Python 2.4, and RHEL 4 has Python 2.3. Suse and Debian, I don't > > know. > > The current Debian "stable" branch (4.0r3, "etch", released > 2008-02-17) has the 'python' package installing Python 2.4.4. > > The current Debian "testing" branch ("lenny", the next in line for > release) has the 'python' package installing Python 2.4.5. It also has > Python 2.5.2, and before too long will be installing that as the > 'python' package. > > The current Debian "unstable" branch (never to be released, but a > staging area for new package versions) has the 'python' package > installing Python 2.5.2. Much better than the URLs I gave to the raw data, here is the full package information page for 'python-defaults' . The section titled "Available versions" shows the current default versions of Python in all currently-supported branches of Debian. -- \ ?Working out the social politics of who you can trust and why | `\ is, quite literally, what a very large part of our brain has | _o__) evolved to do.? ?Douglas Adams | Ben Finney From bronger at physik.rwth-aachen.de Wed Apr 16 12:25:58 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 16 Apr 2008 18:25:58 +0200 Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <87prspydex.fsf@physik.rwth-aachen.de> Hall?chen! Michael Torrie writes: > [...] > > This official python list is one of the few lists that's even > still on nntp. All my other ones (gnome, gtk, openldap, clamav, > freeradius, etc) are all e-mail mailing lists only and it works > very well. In fact, I think it's much better since list > subscription can actually be controlled by someone. The admistrative overhead of mailing lists is tedious. Fortunately, most important computer-related lists are on gmane.org. We could list c.l.py there, too. ;-) Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From dolloffdelvpg at gmail.com Wed Apr 16 08:08:14 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:08:14 -0700 (PDT) Subject: taylor swift biography Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From ra21vi at gmail.com Tue Apr 1 14:31:14 2008 From: ra21vi at gmail.com (Ravi Kumar) Date: Wed, 2 Apr 2008 00:01:14 +0530 Subject: libgmail through proxy Message-ID: <9a63e8920804011131p1e8e90f7mef8d05773a950390@mail.gmail.com> HI, I was trying to use libgmail. I used that successfully, fetched mail to some extend (thought after some mails, it threw exceptions on NonIterable Int). But when I used the same package from my office where I have to use the proxy, it failed. I used idle, then I also set os.ENVIRON['http_proxy'] to the same settings which I use, but I could not succeed. The login() method reports error about no addreess associated with it. Please help me solve it. I used the proxy settings, but it didnt work. so any workaround, and what sort of thing I am missing. -- -=Ravi=- -------------- next part -------------- An HTML attachment was scrubbed... URL: From ptmcg at austin.rr.com Thu Apr 24 10:10:55 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Thu, 24 Apr 2008 07:10:55 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: On Apr 21, 9:01?pm, "Gabriel Genellina" wrote: > > Perhaps you can manage to keep your code compatible with all versions, but ? > AFAIK the reccomended strategy is to write code compatible with Python 2.6 ? > and use the 2to3 tool to generate the 3.0 source. And *not* edit the 3.0 ? > code unless one wants to maintain two branches. > Gabriel - (Thanks for chiming in on this sub-thread, I really enjoy reading your posts.) My point is that the recommended strategy MAY work for those who write end point applications (I consider maintaining 2 branches to be in the "not working" category), but it does NOT WORK for people who maintain modules for other people to use, because those people may be on a range of Python versions that extend beyond 2.6-3.0. So if I upgrade my module to 2.6, those running on earlier versions can no longer use it. At some point in the future, I'll probably be able to say "no more support for pre-2.6", but it is a bit early to start saying that now. Likewise, I don't want to say "no support for 3.0" - people DO want to try 3.0 out, and I WANT them to want and be able to use my module too. Given the recommended strategy, and ruling out dual codebase, whom do I tell that they can't use the next version of my module? Again, to me, this is a non-issue because I've been able to create a cross-version compatible single codebase for pyparsing. But it was a bit dicey there for a while, and I think other module developers/ maintainers may not be so lucky. So, I feel that the recommended strategy was devised with a narrow group of developers in mind, and leaves module developers/maintainers, who wish to target as broad a set of users as possible, faced with choosing one of these strategies: - create (if possible) single cross-version compatible code - forego support of 3.0 users - discontinue pre-2.6 support for future versions of their module - maintain dual codebase -- Paul From __peter__ at web.de Sat Apr 5 05:55:10 2008 From: __peter__ at web.de (Peter Otten) Date: Sat, 05 Apr 2008 11:55:10 +0200 Subject: mailbox.Maildir(), confusing documentation References: <47f4f4f4$0$715$bed64819@news.gradwell.net> Message-ID: tinnews at isbd.co.uk wrote: > Having got my Python 2.5.2 installed I'm trying some things out with > the mailbox.Maildir() class. > > If I do the following:- > > import maibox > mailbox.Maildir("/home/isbd/Mail/Li/pytest") > > then the pytest Maildir mailbox is created - which is great but isn't > documented. If the above creates the maildir then what is the > mailbox.Maildir.add_folder() method for? I tried > mailbox.Maildir.add_folder() and it appeared to do nothing, it didn't > produce any errors either. You didn't expect the dot, it seems: >>> import mailbox >>> m = mailbox.Maildir("alpha") >>> m.add_folder("beta") >>> $ find . . ./alpha ./alpha/tmp ./alpha/cur ./alpha/new ./alpha/.beta ./alpha/.beta/tmp ./alpha/.beta/cur ./alpha/.beta/new ./alpha/.beta/maildirfolder $ Peter From skanemupp at yahoo.se Wed Apr 16 16:19:13 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Wed, 16 Apr 2008 13:19:13 -0700 (PDT) Subject: def power, problem when raising power to decimals Message-ID: how do i solve power(5,1.3)? def power(nbr, po): if po==0: return 1 if po>0: return nbr*power(nbr, po-1) if po<0: return 1/power(nbr, -1*po) also i found a link which states 0^0 isnt 1 even though every calculator ive tried says it is. it doesnt say what it is but i presume 0 then. but it seems the dude is wrong and it is 1? dont run the code with decimals, it will never leave the function, u have to restart the shell(if using the standard python ide) From sierra9162 at gmail.com Wed Apr 16 11:27:03 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:27:03 -0700 (PDT) Subject: kate hudson photo Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From ma.saeedi at gmail.com Tue Apr 8 13:53:33 2008 From: ma.saeedi at gmail.com (Maryam Saeedi) Date: Tue, 8 Apr 2008 12:53:33 -0500 Subject: Running a python code periodically Message-ID: Hi, I was wondering if you know how can I run a python code once every five minutes for a period of time either using python or some other program like a bash script. Thanks, Maryam -------------- next part -------------- An HTML attachment was scrubbed... URL: From nagle at animats.com Sun Apr 13 11:42:52 2008 From: nagle at animats.com (John Nagle) Date: Sun, 13 Apr 2008 08:42:52 -0700 Subject: How to Choose an Unlimited Web Hosting for free In-Reply-To: <02d391b5-f72f-4f99-8f40-dbc304aa22fe@q24g2000prf.googlegroups.com> References: <02d391b5-f72f-4f99-8f40-dbc304aa22fe@q24g2000prf.googlegroups.com> Message-ID: <4802276d$0$36379$742ec2ed@news.sonic.net> Unlimited Free Domain & Web Hosting wrote: > How to Choose an Unlimited Web Hosting > 1) Visit www.axealis.com to get domain and hosting > 2) Unlimited Bandwidth ,this mean unlimited data transmission for your > client access. > 2) Unlimited Space , you can upload file for unlimited . > 3) Unlimited Email , many of email account can created . > 5) SSL Security , used SSL / HTTPS to protect your web . > 6) LINUX , WINDOWS and MAC , can access form many operating system. This is some spamming "reseller" for Byet Hosting. Which does not support Python. John Nagle From sami.islam at NOSPAMbtinternet.com Sun Apr 6 15:16:46 2008 From: sami.islam at NOSPAMbtinternet.com (Sami) Date: Sun, 06 Apr 2008 20:16:46 +0100 Subject: traceback.print_exc() supposed to stop exception propagation. Message-ID: <69-dnW_JftMHvGTanZ2dneKdnZydnZ2d@bt.com> Hello, In the Python book that I am using to learn the language it says that the traceback.print_exc() can be used to stop exception propagation and make the program keep running. Here is a simple piece of code that I typed in to test this fact: --------------------------------------------------------------------------- import sys def Myexcepthook(etype, value, tb): print "in Myexcepthook\n" import traceback lines=traceback.format_exception(etype, value, tb) print "\n".join(lines) traceback.print_exc() sys.excepthook = Myexcepthook x = 1/0 x = 78 print x -------------------------------------------------------------------------- The Output: -------------------------------------------------------------------------- in Myexcepthook Traceback (most recent call last): File "E:\Home\Programming\Python\TryProjects\ExceptHandling1\Except2.py", lin 15, in x = 1/0 ZeroDivisionError: integer division or modulo by zero None -------------------------------------------------------------------------- I never see the value 78. What am I doing wrong? Thanks, Sami From jean11821cleme at gmail.com Tue Apr 29 05:17:00 2008 From: jean11821cleme at gmail.com (jean11821cleme at gmail.com) Date: Tue, 29 Apr 2008 02:17:00 -0700 (PDT) Subject: sims patch Message-ID: <1f18d647-dfc1-4f1f-ae5a-c1691ca73d90@a9g2000prl.googlegroups.com> sims patch http://crack.cracksofts.com From Lie.1296 at gmail.com Sun Apr 27 07:05:57 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 27 Apr 2008 04:05:57 -0700 (PDT) Subject: removing extension References: Message-ID: On Apr 27, 5:34 pm, wilson wrote: > i was trying to convert all images in a folder to another type and > save the new images in a separate folder.for that i wrote a class and > coded some part > > class ConvertImgs: > def __init__(self,infldr,outfldr): > if os.path.isdir(infldr): > self.infldr=infldr > self.outfldr=outfldr > else: > print "no such folder,exits program" > exit(1) > if not os.path.isdir(self.outfldr): > os.mkdir(self.outfldr) > print "made:",self.outfldr > > for x in os.listdir(infldr): > self.origlist=[os.path.normpath(os.path.join(self.infldr,x)) for x in > os.listdir(infldr)] > > ... > the self.origlist returns a list of filenames in infolder.I would > like to get them as 'C:\\myimages\\imageone' instead of 'C:\\myimages\ > \imageone.jpg' sothat i can add a diff extension to all those strings > in the list and save in diff format(ie change 'C:\\myimages\\imageone' > to 'C:\\myimages\\imageone.gif ' and save in gif format).but i don't > know how to remove those extension from the namestring ..can someone > help? > W I don't know if this is the simplest way, but you can use re module. import re pat = re.compile(r'(.*?)\..*') name = pat.search('C:\\myimages\\imageone.jpg').group(1) print name From dickinsm at gmail.com Wed Apr 9 16:27:33 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Wed, 9 Apr 2008 13:27:33 -0700 (PDT) Subject: Python 3.0 new integer division References: Message-ID: <572137bc-390d-445f-9b43-210e0c7955d8@d45g2000hsc.googlegroups.com> On Apr 9, 3:57?pm, Arnaud Delobelle wrote: > Naive question: why not just use a long + an exponent? > > e.g. 132560 ?-> (13256, 1) > ? ? ?0.534 ? -> (534, -3) > ? ? ?5.23e10 -> (523, 8) > It's a good question. The standard answer is that if the coefficient is a long then it's awkward to get at individual digits; looking up a digit becomes an O(n^2) operation (involving a division and a remainder) instead of the O(1) that it should be. And you need access to the digits for rounding operations, which are pretty darn common (one round at the end of each arithmetic operation, as a rule). But I could easily be convinced that storing the coefficient as a long speeds things up for the usual use cases, even if it gives horrible asymptotics for those trying to do really high-precision calculations. And it would certainly make the code slightly simpler in places. It would be great if someone could try converting Decimal so that the coefficient is stored as a long, to see if there's any noticeable impact on speed one way or the other. It wouldn't be such a hard change: a few hours of work at most. It's on my todo list to try this, but so far down that it's not looking like it'll end up at the top of the list before Christmas 20??. Mark From upton at virginia.edu Fri Apr 25 19:18:08 2008 From: upton at virginia.edu (Dan Upton) Date: Fri, 25 Apr 2008 19:18:08 -0400 Subject: MESSAGE RESPONSE In-Reply-To: <4e89b45d-198c-48ca-a3a6-3ba42448cb2b@e53g2000hsa.googlegroups.com> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> <678v5qF2me5rvU1@mid.uni-berlin.de> <4e89b45d-198c-48ca-a3a6-3ba42448cb2b@e53g2000hsa.googlegroups.com> Message-ID: <5504f9ac0804251618g29afc246n6df35bff2fb947ce@mail.gmail.com> On Fri, Apr 25, 2008 at 7:00 PM, ajaksu wrote: > On Apr 23, 1:27 pm, "Dan Upton" wrote: > > > On Wed, Apr 23, 2008 at 10:24 AM, Diez B. Roggisch wrote: > > > > > Blubaugh, David A. schrieb: > > > > > > Is there a way to block these messages. I do not want to be caught > > > > with filth such as this material. I could lose my job with Belcan with > > > > evil messages such as these messages. > > > > > If I (or *anybody*) knew how to block these messages, he or she would sell > > > the resulting spam-filter for a fortunen that roughly amasses the one of > > > scrooge mc duck - and go live on the bahamas or even buy them. > > > > > Put up with it. It's (unfortunately) part of ze internet tubes. > > > > > And as such, I find it hard to believe you could lose your job over it. > > Me too. That is, until I tried to Google Belcan and Blubaugh together. > May I suggest a new thread to clear that ugly results? :D > ...awesome. From petr.jakes.tpc at gmail.com Wed Apr 16 12:54:27 2008 From: petr.jakes.tpc at gmail.com (petr.jakes.tpc at gmail.com) Date: Wed, 16 Apr 2008 09:54:27 -0700 (PDT) Subject: User-defined Exceptions: is self.args OK? Message-ID: Hi, I am trying to dig through User-defined Exceptions (http:// docs.python.org/tut/node10.html chapter 8.5) is it OK to add following line to the __init__ method of the TransitionError class? .... .... self.args = (self.previous, self.next, self.message) If I do not add this argument to the class, following code does not include values from self.previous, self.next, self.message attributes try: raise TransitionError('previousFoo', 'nextBar', 'this is foo bar message') except TransitionError, err: print err import traceback, sys print sys.exc_info() traceback.print_exc() Thanks for your replies. Petr Jakes From fn681 at ncf.ca Mon Apr 7 06:43:40 2008 From: fn681 at ncf.ca (Colin J. Williams) Date: Mon, 07 Apr 2008 07:43:40 -0300 Subject: A funnily inconsistent behavior of int and float In-Reply-To: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com> References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com> Message-ID: Mark Dickinson wrote: > On Apr 6, 1:29 pm, Lie wrote: >> I've noticed some oddly inconsistent behavior with int and float: >> >> Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) >> [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2>>> int('- 345') >> >> -345 >> >> works, but >> >>>>> float('- 345.083') >> Traceback (most recent call last): >> File "", line 1, in >> ValueError: invalid literal for float(): - 345.083 > > This is a known issue, that has been fixed for Python 3.0. > It was decided not to risk breakage by changing this in > Python 2.x. See: > > http://bugs.python.org/issue1779 > > Mark This is good but the documentation for 3.0 is missing the syntax documentation from 2.5 Colin W. From skanemupp at yahoo.se Fri Apr 11 14:49:08 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 11 Apr 2008 11:49:08 -0700 (PDT) Subject: Profiling programs/scripts? Message-ID: how do i profile a program? i found out that there are some profilers included in the standard library but couldnt really figure out how to access/use them From castironpi at gmail.com Tue Apr 1 07:47:33 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Tue, 1 Apr 2008 04:47:33 -0700 (PDT) Subject: python persistence References: <8b1723d9-67c8-4fe5-b07b-22b0b9311519@8g2000hsu.googlegroups.com> <7f58b5f4-3195-472c-b307-dec71b12aaa8@y21g2000hsf.googlegroups.com> <44f04bf3-4edc-4cb4-9e54-fe51b5e591bc@e39g2000hsf.googlegroups.com> <80d1731d-a3c6-4fce-81fd-9c3f3537e59b@d21g2000prf.googlegroups.com> <5386cf08-c155-4fbb-8373-dbbb9829a9e7@m3g2000hsc.googlegroups.com> <3c27b270-e593-4f2a-b881-68126319760c@8g2000hsu.googlegroups.com> Message-ID: <7d71e294-2b13-4be0-948e-2fe0e4bbe7db@f63g2000hsf.googlegroups.com> On Apr 1, 12:16?am, "Gabriel Genellina" wrote: > En Tue, 01 Apr 2008 00:48:35 -0300, escribi?: > > > We do have, but on Windows, file is not locked to multi-tasking, > > shelve. ?But why don't we have types in there, or non-string > > primitives in keys? > > >>>> c= shelve.open( 'temp', 'c' ) > >>>> c['0']= 'a' > >>>> c.sync() > >>>> del c > >>>> c= shelve.open( 'temp', 'c' ) > >>>> c['0'] > > 'a' > > >>>> c['0'].append( 0 ) > >>>> c['0'] > > [] > > The above session doesn't make sense unless it's somewhat related to "on ? > Windows, file is not locked to multi-tasking," and another process has ? > modified the database in-between. I don't think the problem is restricted ? > to Windows only. There exist file locking mechanisms. > > > And why don't primitive mutations modify contents of disk? ?A > > metaquestion. > > They do, if you pass writeback=True to the shelve constructor, but read ? > the docs. > shelve is a simple class; if it can't fulfill your needs, you may want to ? > use a relational database (perhaps with an ORM like SQLObjects or ? > SQLAlchemy) or an object database like ZODB or Durus. > > >>>> c['0']= type('None',(),{}) > > Traceback (most recent call last): > > pickle.PicklingError: Can't pickle : it's not > > found as __main__.None > > Don't do that then. Or use the available pickle hooks to customize how ? > such classes may be pickled. All persistence mechanisms have limitations. > > -- > Gabriel Genellina I don't see a problem with that; except that binaries come from disks. You could have a Python session that runs entirely on disks + the ALU. I want to know if any, and correct me here, simple modification can store live objects. I call a.append(it) and the memory update takes place on disk instead. If you require that all objects referenced by on-disk objects be on- disk, that's an easy workaround. From mensanator at aol.com Sat Apr 5 13:00:52 2008 From: mensanator at aol.com (Mensanator) Date: Sat, 5 Apr 2008 10:00:52 -0700 (PDT) Subject: Learning curve for new database program with Python? References: Message-ID: On Apr 5, 10:50?am, Jetus wrote: > I have a need for a database program. I downloaded the db2 from ibm, > and reviewed some of the documentation. > > My question is, what is the easiest program for me to try to learn. I > will be creating a database of about 25,000 records, it will be > relational. I am a beginner Python programmer, and need a database > solution that is easy to grasp. I played with sql, > and found that very difficult, if not overly cumbersome. > > A database that could work with Django would be very interesting to > look at as well.. > > Any suggestions out there? You didn't mention the system you're using or whether you require something that's free. Microsoft Access is easy to learn. You can become very productive without every needing to learn SQL. Of course, you'll need to learn some SQL in order to interface to Python. But the good news is you can use the MS-Access drag-and-drop interface to learn how to set up the relational queries and once it's running, you can display the underlying SQL code to learn how to use it in Python. For example, I often design the queries in Access (where I have the advantage of visual design) and use simple SELECT calls from Python do retrieve the data. From rschroev_nospam_ml at fastmail.fm Sun Apr 6 06:46:42 2008 From: rschroev_nospam_ml at fastmail.fm (Roel Schroeven) Date: Sun, 06 Apr 2008 12:46:42 +0200 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> Message-ID: llothar schreef: >> There are ways to build distributions of Python extensions (modules or >> packages involving binary code from languages like C or C++), but you >> will want to understand a bit more about computing in general > > Believe me nobody needs to teach me anything about general programming > anymore. "The people who are best at programming are the people who realize how small their brains are. They are humble." -- Edsger Dijkstra, 1972 (http://www.codinghorror.com/blog/archives/000051.html, http://www.cs.utexas.edu/users/EWD/ewd03xx/EWD340.PDF) -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven From mark at mailinator.com Tue Apr 15 18:01:01 2008 From: mark at mailinator.com (Mark) Date: 15 Apr 2008 22:01:01 GMT Subject: Different times between Python and System References: <66292b91-a2ed-44d1-8fe6-9f4ecd87299b@w1g2000prd.googlegroups.com> Message-ID: On Mon, 14 Apr 2008 00:31:34 -0700, Josh wrote: > Hmm... That didn't work out so well that time. I feel like an idiot. > Previously there has been an hour difference between the system time and > the time that python reports. Thanks for the laugh though Josh. That was funny! :) From wuwei23 at gmail.com Thu Apr 24 06:00:47 2008 From: wuwei23 at gmail.com (alex23) Date: Thu, 24 Apr 2008 03:00:47 -0700 (PDT) Subject: library to do easy shell scripting in Python References: Message-ID: <377ef64e-eb31-4bb5-9f6e-55920a51c8a2@m1g2000pre.googlegroups.com> On Apr 24, 12:22 pm, Michael Torrie wrote: > pipe([prog1,args],[prog2,args],...) > Any ideas on how I could design this? There's a recipe on Activestate's Python Cookbook that does pretty much this: > Allows arbitrary number of commands to be strung together with > each one feeding into the next ones input. Syntax is simple: > x=pipe("cmd1", "cmd2", "cmd3").read() is equivalent to bash > command x=`cmd1 | cmd2 | cmd3`. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/475171 I haven't used it myself, but it might make a good place to start. - alex23 From steve at holdenweb.com Sat Apr 12 18:16:30 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 18:16:30 -0400 Subject: basic python question about for loop In-Reply-To: References: Message-ID: jmDesktop wrote: [...] > So what is n and x in the first iteration? Sorry. I'm trying. Somewhat feebly, if you don't mind my saying so, but don't worry. The usual way to proceed in the face of such ignorance is to insert some form of output that will tell you the answer to your question. So: >>> for n in range(2, 20): ... print range(2, n) ... for x in range(2, n): ... if n % x == 0: ... print n, 'equals', x, '*', n/x ... break ... else: ... print n, "is prime" ... [] 2 is prime [2] 3 is prime [2, 3] 4 equals 2 * 2 [2, 3, 4] 5 is prime [2, 3, 4, 5] 6 equals 2 * 3 [2, 3, 4, 5, 6] 7 is prime [2, 3, 4, 5, 6, 7] 8 equals 2 * 4 [2, 3, 4, 5, 6, 7, 8] 9 equals 3 * 3 and so on! This is the value of the interactive interpreter. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From paddy3118 at googlemail.com Sun Apr 13 07:37:45 2008 From: paddy3118 at googlemail.com (Paddy) Date: Sun, 13 Apr 2008 04:37:45 -0700 (PDT) Subject: Looking for a way to include Pyhtho scripting INSIDE a python program References: <48017af0$0$36399$742ec2ed@news.sonic.net> Message-ID: <3c9359da-90ab-43fc-a18a-eb78bba4a8b5@8g2000hsu.googlegroups.com> On Apr 13, 4:16 am, John Antypas wrote: > Hello all, > > I'm writing in tool in Python that manipulates various data objects read > from various streams. I wanted to give the user a chance to do advanced > work that could not easily be done from a GUI. > > At first, I tried putting in a lightweight scripting language, and then > I thought, why not include Python in itself -- it is certainly powerful > enough. > > I had assumed I'd present the user with a text window in which they > could type arbitrary python code. I'd wrap that code around a function > and pass that function a call of objects they could manipulate by > calling the methods of that class. > > 1. How can a python program invoke ANOTHER interpreter? > 2. How can I pass the class in as its argument and get the modified > class back? > > I know I can do something very ugly -- call a C method that calls a new > python interpreter but that seems VERY ugly. > > Help? > > Thanks. You might try ipython at http://ipython.scipy.org/moin/; or 'python - i'; or the exec and eval statements. There is also the compiler module: http://docs.python.org/lib/compiler.html - Paddy. From sawilla at gmail.com Fri Apr 25 12:49:03 2008 From: sawilla at gmail.com (sawilla) Date: Fri, 25 Apr 2008 09:49:03 -0700 (PDT) Subject: module error in Vista -- works as administrator References: <815eb7f8-6f00-469d-bb15-e1d9680d9646@e39g2000hsf.googlegroups.com> <480d0a52$1@news.mel.dft.com.au> <72da4abc-57b1-47ca-bed4-48b7244d6407@e39g2000hsf.googlegroups.com> <480d2369@news.mel.dft.com.au> <1ca8d4a1-7e98-4269-8e3b-c67fa757f9b1@b64g2000hsa.googlegroups.com> Message-ID: <6eff951e-208a-457a-bd6c-bebed6c71d11@56g2000hsm.googlegroups.com> I've discovered the cause of the problem. At some point previously, Windows Vista had created a copy of the site-packages directory in a virtual store for the user account. The easy-install.pth file in the virtual store did not contain the same path information as the easy- install.pth that the administrator account sees. I deleted the user's Python25 directory in the virtual store and now the user's sys.path contains all of the necessary paths. Reg On Apr 25, 12:04?pm, sawilla wrote: > The access writes to easy-install.pth for regular users is read and > execute. > > The output of sys.path for regular users is: > ['', 'C:\\Program Files\\Python25\\lib\\site-packages\ > \setuptools-0.6c8-py2.5.eg > g', 'C:\\Program Files\\Python25\\python25.zip', 'C:\\Program Files\ > \Python25\\D > LLs', 'C:\\Program Files\\Python25\\lib', 'C:\\Program Files\\Python25\ > \lib\\pla > t-win', 'C:\\Program Files\\Python25\\lib\\lib-tk', 'C:\\Program Files\ > \Python25 > ', 'C:\\Program Files\\Python25\\lib\\site-packages'] > > The output of sys.path for the admin user is: > ['', 'C:\\Program Files\\Python25\\lib\\site-packages\ > \setuptools-0.6c8-py2.5.eg > g', 'C:\\Program Files\\Python25\\lib\\site-packages\\networkx-0.36- > py2.5.egg', > 'C:\\Program Files\\Python25\\lib\\site-packages\\numpy-1.0.4-py2.5- > win32.egg', > 'C:\\Program Files\\Python25\\lib\\site-packages\\scipy-0.6.0-py2.5- > win32.egg', > 'C:\\Program Files\\Python25\\lib\\site-packages\\matplotlib-0.91.2- > py2.5-win32. > egg', 'C:\\Program Files\\Python25\\lib\\site-packages\\dot2tex-2.7.0- > py2.5.egg' > , 'C:\\Program Files\\Python25\\lib\\site-packages\\pydot-1.0.2- > py2.5.egg', 'C:\ > \Program Files\\Python25\\lib\\site-packages\\pyparsing-1.4.11-py2.5- > win32.egg', > ?'C:\\Program Files\\Python25\\python25.zip', 'C:\\Program Files\ > \Python25\\DLLs > ', 'C:\\Program Files\\Python25\\lib', 'C:\\Program Files\\Python25\ > \lib\\plat-w > in', 'C:\\Program Files\\Python25\\lib\\lib-tk', 'C:\\Program Files\ > \Python25', > 'C:\\Program Files\\Python25\\lib\\site-packages'] > > The contents of easy-install.pth are: > import sys; sys.__plen = len(sys.path) > ./setuptools-0.6c8-py2.5.egg > ./networkx-0.36-py2.5.egg > ./numpy-1.0.4-py2.5-win32.egg > ./scipy-0.6.0-py2.5-win32.egg > ./matplotlib-0.91.2-py2.5-win32.egg > ./dot2tex-2.7.0-py2.5.egg > ./pydot-1.0.2-py2.5.egg > ./pyparsing-1.4.11-py2.5-win32.egg > import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; > p=getattr(sys, > '__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new) > > The location where numpy is found:>>> print os.path.abspath(numpy.__file__) > > C:\Program Files\Python25\lib\site-packages\numpy-1.0.4-py2.5-win32.egg > \numpy\__ > init__.pyc > > So I believe I need to have the easy-install.pth file executed > automatically for regular users but I don't know how to do this. > > Reg > > On Apr 21, 7:29?pm, John Machin wrote: > > > > > sawillawrote: > > > On Apr 21, 5:42 pm, John Machin wrote: > > >> Log on as administrator, start python in command window and do this: > > > >> import sys > > >> sys.path # shows where python is looking for importables > > >> import numpy > > >> import os.path > > >> print os.path.abspath(numpy.__file__) # shows where it found numpy > > > >> Log on as ordinary user, start python in command window and do this: > > > >> import sys > > >> sys.path > > >> # check how this is different from the admin's sys.path > > > >> If you can't see what to do after that, come back here with the output > > >> from those steps. > > > >> HTH, > > >> John > > > > That was a great help, thank you. I now see what is causing the > > > problem but I don't know how to fix it. I used easy_install to install > > > several packages. When I run Python from an administrator command > > > window all of the directories in C:\Program Files\Python25\Lib\site- > > > packages\easy-install.pth are added to the sys.path. When I run it as > > > a regular user, those directories are not added to the sys.path and so > > > Python can't find the modules. > > > > I know how to manually add those directories to Python's search path > > > but then I'll need to update the path every time I install something. > > > How do I get Python to automatically load the easy-install.pth file > > > for the regular user account? > > > > Reg > > > """ > > If you can't see what to do after that, come back here with the output > > from those steps. > > """ > > in particular what is in sys.path for the non-admin user. > > Also what are the access rights to the easy-install.pth file?- Hide quoted text - > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - From victorsubervi at gmail.com Thu Apr 17 14:51:43 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 17 Apr 2008 13:51:43 -0500 Subject: Prob. w/ Script Posting Last Value In-Reply-To: <480791D6.4000802@holdenweb.com> References: <4dc0cfea0804170922n2a96be20sc424a7e67742a12e@mail.gmail.com> <480791D6.4000802@holdenweb.com> Message-ID: <4dc0cfea0804171151y204b11bal160762b88dfcf3ee@mail.gmail.com> On Thu, Apr 17, 2008 at 1:07 PM, Steve Holden wrote: > Victor Subervi wrote: > > > Hi; > > Gabriel provided a lovely script for showing images which I am modifying > > for my needs. I have the following line: > > print '

\n' % (d, y) > > where the correct values are entered for the variables, and those values > > increment (already tested). Here is the slightly modified script it calls: > > #!/usr/local/bin/python > > import cgitb; cgitb.enable() > > import MySQLdb > > import cgi > > form = cgi.FieldStorage() > > picid = int(form["id"].value) > > x = int(form["x"].value) > > pic = str(x) > > print 'Content-Type: text/html' > > db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > > cursor= db.cursor() > > sql = "select " + pic + " from products where id='" + str(picid) + "';" > > cursor.execute(sql) > > content = cursor.fetchall()[0][0].tostring() > > cursor.close() > > print 'Content-Type: image/jpeg\r\nContent-Length: %s\n' % len(content) > > print content > > I need to make it so that it will show all my images, not just the last > > one. Suggestions, please. > > TIA, > > Victor > > > > In your "page generator" page, replace > > print '

\n' % (d, y) > > by > > for d, y in (results of some DB query to get d and y for each image): > print '

\n' % (d, y) > Well, I just tried this: #! /usr/bin/python print """Content-type: text/html """ y = 1 for d in 2, 12: while y < 12: print '

\n' % (d, y) y += 1 print""" """ and it printed the same image over and over again :( Now, I could write a generator function that writes and then executes a new program for each image "getpic" + i + "py?... but that is ugly. Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From brian.e.munroe at gmail.com Thu Apr 24 16:22:53 2008 From: brian.e.munroe at gmail.com (Brian Munroe) Date: Thu, 24 Apr 2008 13:22:53 -0700 (PDT) Subject: Class Inheritance - What am I doing wrong? Message-ID: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> My example: class A(object): def __init__(self, name): self.__name = name def getName(self): return self.__name class B(A): def __init__(self,name=None): super(A,self).__init__() def setName(self, name): self.__name = name if __name__ == '__main__': a = A('class a') print a.getName() b = B('class b') print b.getName() b.setName('class b, reset') print b.getName() I get the following error: mtinky:~ brian$ python teste.py class a Traceback (most recent call last): File "teste.py", line 23, in print b.getName() File "teste.py", line 7, in getName return self.__name AttributeError: 'B' object has no attribute '_A__name' Am I *not* using super() correctly? Also, did I define my the class B constructor correctly? From bignose+hates-spam at benfinney.id.au Fri Apr 18 18:30:46 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Sat, 19 Apr 2008 08:30:46 +1000 Subject: Python 2.5 adoption References: Message-ID: <87skxin6cp.fsf@benfinney.id.au> Joseph Turian writes: > How widely adopted is python 2.5? Impossible to answer in general, because there's no way of finding out. > So I guess the question is, does anyone have a sense of what percent > of python users don't have 2.5? You might be able to get a more useful answer for your case if you narrow down the sample set. How many of *your target users* don't have, or would be unwilling to upgrade to, Python 2.5? -- \ ?God forbid that any book should be banned. The practice is | `\ as indefensible as infanticide.? ?Dame Rebecca West | _o__) | Ben Finney From johnjsal at gmailNOSPAM.com Wed Apr 16 22:58:49 2008 From: johnjsal at gmailNOSPAM.com (John Salerno) Date: Wed, 16 Apr 2008 22:58:49 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: References: Message-ID: <4806bcec$0$25058$607ed4bc@cv.net> Grant Edwards wrote: > This morning almost half of c.l.p was spam. In order to try to > not tar both the benign google group users and the malignant > ones with the same brush, I've been trying to kill usenet spam > with subject patterns. But that's not a battle you can win, so > I broke down and joined all the other people that just killfile > everything posted via google.groups. > > AFAICT, if you're a google groups user your posts are not being > seen by many/most experienced (read "non-google-group") users. > This is mainly the fault of google who has refused to do > anything to stem the flood of span that's being sent via Google > Groups. > How exactly do you killfile an entire source like that? Is it possible with Thunderbird? From iainking at gmail.com Mon Apr 7 08:36:40 2008 From: iainking at gmail.com (Iain King) Date: Mon, 7 Apr 2008 05:36:40 -0700 (PDT) Subject: Wxpython. Is it possible to change layout in a running application? Selfmade listbox References: <716c0f27-bca6-4642-a8ec-cdbb0b23e6e8@h1g2000prh.googlegroups.com> Message-ID: On Apr 7, 12:50 pm, Soren wrote: > Hi, > > Id like to make my own special listbox.. I want to able (at the push > of a button) to add another item to my special listbox... each item is > a panel with a label, some buttons and maybe a text control. > > I've tried adding a new panel object with the stuff i want to the > sizer i'm using for my listbox (which is a panel which can contain > other panels)... and then run update() and refresh() on everything... > But it doesn't work.. i see a panel appearing, but it's just a small > square in the corner of my "listbox" panel, and it only works the > first time... nothing new appears when I push the button again. > > Is it at all possible to do this? Has anyone created something > similar? Does anyone know what i'm doing wrong? > > Thanks, > Soren Without your code can only really guess, but I'd check that the new panel you are trying to add to the sizer has the listbox as a parent. Iain From frikker at gmail.com Tue Apr 29 09:22:12 2008 From: frikker at gmail.com (blaine) Date: Tue, 29 Apr 2008 06:22:12 -0700 (PDT) Subject: Simple TK Question - refreshing the canvas when not in focus Message-ID: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> Hey everyone! I'm not very good with Tk, and I am using a very simple canvas to draw some pictures (this relates to that nokia screen emulator I had a post about a few days ago). Anyway, all is well, except one thing. When I am not in the program, and the program receives a draw command (from a FIFO pipe), the canvas does not refresh until I click into the program. How do I force it to refresh, or force the window to gain focus? It seems like pretty common behavior, but a few things that I've tried have not worked. Class screen(): def __init__(self): self.root = Tkinter.Tk() self.root.title('Nokia Canvas') self.canvas = Tkinter.Canvas(self.root, width =130, height=130) self.canvas.pack() self.root.mainloop() Then somewhere a long the line I do: self.canvas.create_line(args[0], args[1], args[2], args[3], fill=color) self.canvas.pack() I've tried self.root.set_focus(), self.root.force_focus(), self.canvas.update(), etc. but I can't get it. Thanks! Blaine From arnodel at googlemail.com Fri Apr 25 08:37:25 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Fri, 25 Apr 2008 13:37:25 +0100 Subject: multiple pattern regular expression References: Message-ID: micron_make writes: > I am trying to parse a file whose contents are : > > parameter=current > max=5A > min=2A > > for a single line I used > for line in file: > print re.search("parameter\s*=\s*(.*)",line).groups() > > is there a way to match multiple patterns using regex and return a > dictionary. What I am looking for is (pseudo code) > > for line in file: > re.search("pattern1" OR "pattern2" OR ..,line) > > and the result should be {pattern1:match, pattern2:match...} > > Also should I be using regex at all here ? If every line of the file is of the form name=value, then regexps are indeed not needed. You could do something like that. params = {} for line in file: name, value = line.strip().split('=', 2) params[name] = value (untested) Then params should be the dictionary you want. -- Arnaud From ott.deb at gmail.com Thu Apr 17 15:04:35 2008 From: ott.deb at gmail.com (ott.deb at gmail.com) Date: Thu, 17 Apr 2008 12:04:35 -0700 (PDT) Subject: recycle crack Message-ID: recycle crack http://cracks.12w.net F R E E C R A C K S From steve.j.donovan at gmail.com Tue Apr 15 02:18:28 2008 From: steve.j.donovan at gmail.com (SteveD) Date: Mon, 14 Apr 2008 23:18:28 -0700 (PDT) Subject: pgdb: Debugging Python extensions made easier References: <7xzlrw7xw7.fsf@ruckus.brouhaha.com> Message-ID: <20484252-e346-4263-9f61-75a678134a77@8g2000hse.googlegroups.com> They are not insurmontable problems. But you will still see things like this: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66510 The point being that with a newish GDB (the current mingw GDB is still 5.x) there's no need for such tedious tricks, since it handles pending breakpoints fine. The additional trick I use for debugging plain non-debug python is to use symbol-file to load some arbitrary symbols, so GDB will not complain about breakpoints. steve d. On Apr 15, 2:41 am, Paul Rubin wrote: > SteveD writes: > > pgdb.zip is an addition to scite-debug, which adds source debugging to > > the popular SciTE programmer's editor. ... > > I know the FAQ says that this is not possible, but the FAQ is somewhat > > outdated. GDB is quite happy with pending breakpoints to unresolved > > libraries, but you have to reassure it. > > I'm not sure what FAQ or what is supposed to be impossible but > I've used gdb in the past to debug python extensions without > running into insurmountable problems that I remember. From tjreedy at udel.edu Tue Apr 8 00:45:34 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 8 Apr 2008 00:45:34 -0400 Subject: Translating keywords References: Message-ID: "Gabriel Genellina" wrote in message news:op.t89t1sbgx6zn5v at gabriel2.softlabbsas.com.ar... | En Mon, 07 Apr 2008 14:59:08 -0300, Terry Reedy | escribi?: | > If you want other-language keywords, you should either use a translator | > processor or an editor that will do keyword substitution. I do not know | > of | > such but I would not be surprised if there is one. I suspect this sort | > of | > thing will more likely happen with Python 3, which will allow unicode | > keywords. | | Python 3 allows for unicode identifiers, but I don'k know any plans for | using unicode keywords too. Looks funny: There are no official (PSF) plans and I expect there will be not be any for a long time if ever. My 'suspicion' was with respect to very unofficial 3rd party efforts, perhaps not even announced here in English/ascii land. My reasoning: If one is writing in ascii only, then ascii keywords and even English keywords are not so much a burden. But if one is writing comments and strings and identifiers in a different alphabet, then ascii begin to look odd and native character keywords more inviting. From donn at u.washington.edu Wed Apr 16 12:16:27 2008 From: donn at u.washington.edu (Donn Cave) Date: Wed, 16 Apr 2008 09:16:27 -0700 Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: In article , Aaron Watters wrote: > Maybe there is a secret desire in the Python > community to remain a fringe minority underdog > forever? I'm sure anyone who has given it any thought understands that the fringe minority situation is a lot more fun in some ways, but I think if you were to apply a sort of conspiracy analysis to the situation - "who benefits from language change" - this would be a couple items down on the list of motivations. Donn Cave, donn at u.washington.edu From gagsl-py2 at yahoo.com.ar Sat Apr 12 02:13:34 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 12 Apr 2008 03:13:34 -0300 Subject: str(bytes) in Python 3.0 Message-ID: Hello Is this the intended behavior? Python 3.0a4+ (py3k, Apr 12 2008, 02:53:16) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> x = b"abc" >>> repr(x) "b'abc'" >>> str(x,"ascii") 'abc' >>> str(x,"utf-8") 'abc' >>> str(x) "b'abc'" On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') above. But I get the same as repr(x) - is this on purpose? -- Gabriel Genellina From steve at holdenweb.com Sun Apr 20 14:31:29 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 20 Apr 2008 14:31:29 -0400 Subject: Any reliable obfurscator for Python 2.5 In-Reply-To: <480b6133$0$34498$742ec2ed@news.sonic.net> References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> <480b6133$0$34498$742ec2ed@news.sonic.net> Message-ID: <480B8C01.1080306@holdenweb.com> JB "My first post on c.l.py" Stern wrote: > Banibrata Dutta wrote: >>> Wanted to check if there is any known, reliable, FOSS/Libre -- Obfurscator >>> for Python 2.5 code. > > No, sadly, there is not. There are a number of applications I would be > working on if it were possible to obfuscate pyc files. About the best > you can do as of 2008/04 is use Jython to compile into Java bytecode and > obfuscate that using Proguard. > > Steve 'not an economics major' Holden wrote: >> The Python world isn't particularly paranoid about obfuscation. It's >> quite easy to publish compiled code only (.pyc and/or .pyo files), and >> that offers enough protection for most. > > Curious Steve, how do you pay the rent and by what authority do you > speak for "The Python world"? Your opinion couldn't be more wrong for > programmers like myself who live by the code they write (as opposed to > its support). > I pay the mortgage by creating software systems, though not usually packaged systems for shrink-wrap sale. I don't claim to speak *for* the whole Python world, but as chairman of the Python Software Foundation and a long-time member of this mailing list I can probably claim to be more closely in touch with it than many--yourself included, apparently. If it's important to you to be able to obfuscate your code then you have made an inapposite choice of language. > Steve 'not a software consultant' Holden wrote: >> The sad fact is that there seems to be an almost direct inverse >> correlation between the worth of the code and the authors' desire to >> protect it from piracy. > > Would love to see some evidence to that effect. > That is just an observation based on the many similar posts that have been made on this list, not one of them coming from the author of a recognized software package, plus forty years experience in the software industry. The ripping of of source code is far less frequent that novice programmers believe. The code that novice programmers write is almost always less valuable than they believe. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From kovyrus2 at gmail.com Wed Apr 9 18:18:23 2008 From: kovyrus2 at gmail.com (kovyrus2 at gmail.com) Date: Wed, 9 Apr 2008 15:18:23 -0700 (PDT) Subject: Free Photo Sharing Message-ID: <7739b530-38f8-47d5-949e-a8640c1deb45@q10g2000prf.googlegroups.com> Upload your photos and share them with friends and family. http://fotochange.com From jeffrey at fro.man Wed Apr 9 11:39:12 2008 From: jeffrey at fro.man (Jeffrey Froman) Date: Wed, 09 Apr 2008 08:39:12 -0700 Subject: Trouble with list comprehension References: Message-ID: Shane Lillie wrote: > goats = [ x for x in range(2) if doors[x] == 'G' ] > > but for some reason the list comprehension is not always returning a > list with 2 elements in it (sometimes it will be just 1 element). The problem here is with your usage of the range() function. You provide an endpoint of 2, but that endpoint is not included in the range. Thus, you are only checking the indexes 0 and 1. You'll get two results when those two indexes are 'G', and one otherwise. You want range(3). By the way, the enumerate() function is good for this task, as it does not require you to know the length of your list in advance: goats = [index for index, item in enumerate(doors)] -- Jeffrey From skanemupp at yahoo.se Sat Apr 5 15:27:49 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 12:27:49 -0700 (PDT) Subject: Tkinter, add pressed buttons onto string display string, how to? Message-ID: using tkinter and python i now have a small App (that will hopefully soon be a fully functioning calculator) where u can push buttons and the corresponding number or operator is shown. when u press 1, "1" appears on the screen, pres + and "+" appears etc. at the moment every output overwrites the previous so what i want to do is obviosuly to add every new output to a string so that i can read the string and perform the calculation. so i want: * when pushing the button push the token of the button onto a string * display the new string, ie "1+2" for example * want to be able to access this string when pressing calculate so i can figure out which operators should be done first so it can solve something like this: "(1+2*3)(3-4/2)" and not just simple "1+2"-stuff. do i have to have some global string-variable in the GUIframework then? im not sure where to start... here is the code: #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self, master=None): """Initialize yourself""" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): ## """Create the Entry, set it to be a bit wider""" ## self.enText = Entry(self) ## self.enText.grid(row=0, column=0, columnspan=3) """Create the Button, set the text and the command that will be called when the button is clicked""" self.btnDisplay = Button(self, text="calculate!", state=DISABLED) self.btnDisplay.grid(row=0, column=31) self.btnDisplay = Button(self,text='1',command=lambda n=1:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='2',command=lambda n=2:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='3',command=lambda n=3:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='+',command=lambda n="+":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) self.btnDisplay = Button(self,text='4',command=lambda n=4:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='5',command=lambda n=5:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='6',command=lambda n=6:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='-',command=lambda n="-":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=3, padx=5, pady=5) self.btnDisplay = Button(self,text='7',command=lambda n=7:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='8',command=lambda n=8:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='9',command=lambda n=9:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='*',command=lambda n="*":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=3, padx=5, pady=5) self.btnDisplay = Button(self,text='0',command=lambda n=0:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='C',command=lambda n="C":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='r',command=lambda n="r":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='/',command=lambda n="/":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) def Display(self, number): #print number self.lbText = Label(self, text=number) self.lbText.grid(row=0, column=0) if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() From steve at holdenweb.com Tue Apr 8 12:15:51 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 12:15:51 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> Message-ID: Victor Subervi wrote: > Hi: > I am able (finally) to upload an image to the database. However, when I > try to retrieve it, I get a string literal. Here is my code: > > #!/usr/local/bin/python > import cgitb; cgitb.enable() > import MySQLdb > def test(): > host = 'mysqldb2.ehost-services.com ' > user = 'user' > passwd = 'pass' > db = 'bre' > db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > cursor= db.cursor() > cursor.execute('select pic1 from products where id="3";') > content = cursor.fetchall() > # print 'Content-Type: image/jpeg\r\nContent-Length: %d\n' % len(content) > print 'Content-Type: image/jpeg\r\n' > print '\n' > print content > print '\n' > cursor.close() > > test() > (Apparently, Plesk doesn?t like if __name__ == '__main__': ) > The commented out line gives me a leading less than sign...and that?s > it. What do? > TIA, > Victor > Your headers indicate you intend to serve a JPEG image, so you should *not* then include HTML. Take a look at the HTML of a web page with an image inside it (look for the tag) and you will see that HTML pages reference images as separate web resources. Thus once you have printed out your HTML headers you should them immediately send the contents of the database column. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From castironpi at gmail.com Tue Apr 1 00:04:20 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Mon, 31 Mar 2008 21:04:20 -0700 (PDT) Subject: python persistence References: <8b1723d9-67c8-4fe5-b07b-22b0b9311519@8g2000hsu.googlegroups.com> <7f58b5f4-3195-472c-b307-dec71b12aaa8@y21g2000hsf.googlegroups.com> Message-ID: <09f7e201-3b3c-4e9f-9d8b-de7af4771049@m73g2000hsh.googlegroups.com> On Mar 31, 7:14?pm, 7stud wrote: > On Mar 31, 5:31?pm, castiro... at gmail.com wrote: > > > Can you have a Python object stored entirely on disk? > > import cPickle as cp > > class Dog(object): > ? ? def __init__(self, name): > ? ? ? ? self.name = name > > d = Dog("Spot") > > f = open("data.txt", "w") > cp.dump(d, f) > f.close() > > f = open("data.txt") > stored_obj = cp.load(f) > print stored_obj.name > > --output:-- > Spot From listobject.h: #define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v)) Can we make ob_item a seek-tell offset? From mccredie at gmail.com Tue Apr 29 12:51:02 2008 From: mccredie at gmail.com (Matimus) Date: Tue, 29 Apr 2008 09:51:02 -0700 (PDT) Subject: Issue with regular expressions References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Message-ID: <8a393c76-cbbd-4056-9ef0-ee5fc66e8fbf@q24g2000prf.googlegroups.com> On Apr 29, 6:46 am, Julien wrote: > Hi, > > I'm fairly new in Python and I haven't used the regular expressions > enough to be able to achieve what I want. > I'd like to select terms in a string, so I can then do a search in my > database. > > query = ' " some words" with and "without quotes " ' > p = re.compile(magic_regular_expression) $ <--- the magic happens > m = p.match(query) > > I'd like m.groups() to return: > ('some words', 'with', 'and', 'without quotes') > > Is that achievable with a single regular expression, and if so, what > would it be? > > Any help would be much appreciated. > > Thanks!! > > Julien I don't know if it is possible to do it all with one regex, but it doesn't seem practical. I would check-out the shlex module. >>> import shlex >>> >>> query = ' " some words" with and "without quotes " ' >>> shlex.split(query) [' some words', 'with', 'and', 'without quotes '] To get rid of the leading and trailing space you can then use strip: >>> [s.strip() for s in shlex.split(query)] ['some words', 'with', 'and', 'without quotes'] The only problem is getting rid of the extra white-space in the middle of the expression, for which re might still be a good solution. >>> import re >>> [re.sub(r"\s+", ' ', s.strip()) for s in shlex.split(query)] ['some words', 'with', 'and', 'without quotes'] Matt From bignose+hates-spam at benfinney.id.au Tue Apr 22 10:02:47 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Wed, 23 Apr 2008 00:02:47 +1000 Subject: Witty retorts (was: Python Success stories) References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <87d4oi3s3c.fsf_-_@benfinney.id.au> Carl Banks writes: > Let me tell you a little story to let you know how you should act in > situations like this. Some of you might have heard it before. > Apologies if it's a bit long. I don't know if I've heard it before; it's rather unmemorable. What lesson is it intended to teach, other than that "Fuck you" is somehow a "retort"? I can't see that improving too many situations. -- \ "Probably the toughest time in anyone's life is when you have | `\ to murder a loved one because they're the devil." -- Emo | _o__) Philips | Ben Finney From arnodel at googlemail.com Wed Apr 30 12:05:59 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Wed, 30 Apr 2008 17:05:59 +0100 Subject: calling variable function name ? References: <57461074-8fd1-4e65-9bc9-2ac916aa1fb5@y21g2000hsf.googlegroups.com> Message-ID: TkNeo writes: > > George - Thanks for your reply but what you suggested is not working: > > def FA(param1,param2): > print "FA" + param1 + " " + param2 > def FA(param1,param2): > print "FB" + param1 + " " + param2 > def FA(param1,param2): > print "FC" + param1 + " " + param2 > > temp = sys.argv[1] > > func = globals()["F" + temp] > func("Hello", "World") > > > I ran the script with first parameter as B and i get the following > message > KeyError: 'FB' Perhaps if you call your three function FA, FB, FC instead of FA, FA, FA it'll help? -- Arnaud From darcy at druid.net Tue Apr 22 12:10:06 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Tue, 22 Apr 2008 12:10:06 -0400 Subject: Python Success stories In-Reply-To: <944aa044-4a41-4ae9-9364-56e1bcc82488@p25g2000hsf.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> <944aa044-4a41-4ae9-9364-56e1bcc82488@p25g2000hsf.googlegroups.com> Message-ID: <20080422121006.b0243813.darcy@druid.net> On Tue, 22 Apr 2008 08:35:47 -0700 (PDT) GHUM wrote: > > Which big aplications are written in python. I see its development, > > There are no big applications written in Python. > > Big applications are written in JAVA or COBOL or C# or other legacy > programming systems. > > If you programm in Python, your applications become quite small. Only > frameworks in Python are big. So the fact that there are no big applications written in Python IS the success story. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From sturlamolden at yahoo.no Thu Apr 24 23:07:56 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 20:07:56 -0700 (PDT) Subject: Psyco alternative References: <8b7d9523-1d15-41e5-8b69-39f8250e6a6f@i76g2000hsf.googlegroups.com> Message-ID: On Apr 25, 4:57 am, Steve Holden wrote: > I am simply pointing out that RPython is used for efficiency, not to do > things that can't be done in standard Python. Yes. And if we only use a very small subset of Python, it would in effect be a form of assembly code. Hence my comment about the Turing complete subset. From cokofreedom at gmail.com Fri Apr 11 07:24:35 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Fri, 11 Apr 2008 04:24:35 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> Message-ID: <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> On Apr 11, 1:19 pm, cokofree... at gmail.com wrote: > couldn't you just do. > > #untested > new_round(n): > answer = round(n) > # is answer now odd > if answer % 2: > return answer - 1 > else: > return answer Whoops, this also affects odd numbers... Will try and find a GOOD solution later... Strange request though, why do you need it that way, because 2.5 is CLOSER to 3 than to 2... From fred.sells at adventistcare.org Tue Apr 8 14:16:44 2008 From: fred.sells at adventistcare.org (Sells, Fred) Date: Tue, 8 Apr 2008 14:16:44 -0400 Subject: need help to upload file to webserver In-Reply-To: <47faa04f$0$36349$742ec2ed@news.sonic.net> Message-ID: <0A53725C4A497848A7B3A0874B259831011B08C3@acesxch01.ADVENTISTCORP.NET> I am automating the client side of a simple web interface. I need to upload a file to a webserver that requires authentication. I've got the authentication working with urllib2 (see below), but the only examples I've found to upload files use httplib without authentication. I'm competent with Python but no whiz with web api's. Could I get a little help please. ---------the form I'm trying to simulate looks like this----------------------

------------------my code follows--------------------------------------------- import urllib2, urllib, socket, base64, cookielib import webtools # from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306 STANDARD_HEADERS = {'User-agent':'Mozilla/5.0 (compatible; MSIE 5.5; Windows NT)'} COOKIEFILE = 'cokies.lwp' socket.setdefaulttimeout(30) HTTP = "http://" HTTPS = "https://" #IP, UNAME, PW = "............." #deleted for security top_level_url = "http://..............." PasswordManager = urllib2.HTTPPasswordMgrWithDefaultRealm() PasswordManager.add_password(None, top_level_url, UNAME, PW) AuthenticationHandler = urllib2.HTTPBasicAuthHandler(PasswordManager) opener = urllib2.build_opener(AuthenticationHandler) urllib2.install_opener(opener) class MyConnection: def __init__(self, ipaddr="192.168.1.0", uname=None, password=None): self.SERVER_AND_PORT = "%s:81" % ipaddr self.UNAME = uname def getPage(self, url, kwargs, headers=None): headers = headers or STANDARD_HEADERS request = urllib2.Request(url, urllib.urlencode(kwargs), headers) handle = urllib2.urlopen(request) page = handle.read() handle.close() return page def getValidationReportsPage(self): ########this works self.getPage(HTTPS+self.SERVER_AND_PORT+"/cgi/listrpts.exe",{}) def login(self): #########this works try: print self.getPage(HTTPS+self.SERVER_AND_PORT+"/cgi/mainhtml.exe",{}) except: print 'login failed' def uploadFile(self, filepath): #????????????? need help here buffer = open(filepath).read() headers = dict(STANDARD_HEADERS) #make a copy parms = ('file', filepath, buffer ) contenttype, body = webtools.encode_multipart_formdata([], [parms]) headers['Content-Type']= contenttype data = {'file':body} self.getPage(HTTPS+self.SERVER_AND_PORT+"/cgi/upload.exe",data,headers) def unittest(): print 'start unittest of '+ __file__ X = MyConnection(uname=UNAME, password=PW) X.login() X.uploadFile('testdata/MouseMds.txt') if __name__ == "__main__": unittest() -------------------------------------------------------------------------------- You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost. --------------------------------------------------------------------------- The information contained in this message may be privileged and / or confidential and protected from disclosure. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and deleting the material from any computer. --------------------------------------------------------------------------- From fetchinson at googlemail.com Mon Apr 21 17:36:17 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Mon, 21 Apr 2008 14:36:17 -0700 Subject: Does Python 2.5.2's embedded SQLite support full text searching? In-Reply-To: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> Message-ID: > >> Sqlite itself is not distributed with python. Only a python db api > >> compliant wrapper is part of the python stdlib and as such it is > >> completely independent of the sqlite build. > > > > Don't most binary distributions include SQLite itself? I installed > > 2.5.2 on a new WinXP VM, and SQLite is working fine. > > So did I. I installed py2.5.2 on windows and didn't install SQLite, and I'm > using the module sqlitedb without problems. On linux this is not the case (i.e. on linux one has to install sqlite itself separately) and I assumed on windows you have to install sqlite separately too. My apologies for the misinformation. Cheers, Daniel From stanc at al.com.au Fri Apr 18 05:35:36 2008 From: stanc at al.com.au (Astan Chee) Date: Fri, 18 Apr 2008 19:35:36 +1000 Subject: testing client-server sockets In-Reply-To: References: <4808627F.5040906@al.com.au> <48086408.4070205@al.com.au> Message-ID: <48086B68.5060004@al.com.au> Wierd. It works now. I must've changed something. Oh well, thanks anyway. David Harrison wrote: > On 18/04/2008, Astan Chee wrote: > >> Server code: >> >> import os, sys, socket >> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >> host = '' >> port = 5602 >> s.bind((host,port)) >> try: >> s.listen(1) >> while 1: >> conn, addr = s.accept() >> print 'client is at', addr >> data = conn.recv(1000000) >> data = data * 10 >> z = raw_input() >> conn.send(data) >> conn.close() >> except Exception: >> s.close() >> >> Client code: >> >> import sys, os, socket >> >> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >> host = 'hostIP' >> port = 5602 >> s.connect((host,port)) >> s.send(dlg.user.GetValue()) >> i =0 >> while True: >> data = s.recv(1000000) >> i+=1 >> if (i<5): >> print data >> if not data: >> break >> print 'received', len(data), 'bytes' >> s.close() >> > > I just ran the code (albeit with a tiny change to send a small string > instead so I could see what was going on), and it seems to work fine > ... anything else that might be different ? > > -- "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." Animal Logic http://www.animallogic.com Please think of the environment before printing this email. This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. -------------- next part -------------- An HTML attachment was scrubbed... URL: From lbonafide at yahoo.com Fri Apr 4 15:13:08 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Fri, 4 Apr 2008 12:13:08 -0700 (PDT) Subject: Looking for Advanced Python Tutorials References: Message-ID: <04baf595-49a0-48fd-9837-431cda33e33e@b64g2000hsa.googlegroups.com> On Apr 4, 6:58?am, cokofree... at gmail.com wrote: > I was wondering if anyone knew of some online (free if possible) > advanced tutorials, especially ones that provides tasks and ideas for > small projects. The issue for myself is I want to improve my python > programming level, and my ability to program in general, but come up > blank thinking of a possible task or project to undertake. Look at PyGame (http://pygame.org) and write a simple game, like asteroids or space invaders. Or heck, start with pong. You'll be amazed at how game programming will stretch your programming skills. Or do graphics with PyOpenGL. Google for NeHe's OpenGL tutorials to get you started. From mattheww at chiark.greenend.org.uk Mon Apr 21 18:15:53 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 21 Apr 2008 23:15:53 +0100 (BST) Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3eac67b4-da0a-4926-9ca4-942271513ad2@26g2000hsk.googlegroups.com> Message-ID: Terry Reedy wrote: > Such requests happen about once a month or so. If all the code-hiders were > to have gotten together to openly share their obfuscation ideas and code, I > suspect there would have been something pretty good by now. But in 10 > years of my watching, this does not seem to have happened ;-) I suppose that makes this a frequently asked question. So who maintains the FAQ? -M- From bhmckendrick at gmail.com Sat Apr 26 11:17:52 2008 From: bhmckendrick at gmail.com (animalMutha) Date: Sat, 26 Apr 2008 08:17:52 -0700 (PDT) Subject: Setting an attribute without calling __setattr__() References: <87bq3xej01.fsf@mulj.homelinux.net> <87tzhpd497.fsf@mulj.homelinux.net> Message-ID: <4b2f7629-548f-4868-b423-c1ca716e31f5@m44g2000hsc.googlegroups.com> Hrvoje Niksic wrote: > Hrvoje Niksic writes: > > > Joshua Kugler writes: > > > >> self.me = [] > >> self.me = {} > > > > Use "object.__setattr__(self, 'me') = []" and likewise for {}. > > Oops, that should of course be "object.__setattr__(self, 'me', [])". From bskaplan14 at yahoo.com Wed Apr 9 22:12:25 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Wed, 9 Apr 2008 19:12:25 -0700 (PDT) Subject: How is GUI programming in Python? Message-ID: <620714.1085.qm@web39204.mail.mud.yahoo.com> The pain level all depends on how you go about it. If you try to builda GUI from scratch, it will be very painful. If you use a toolkit, thenit's pretty close to working with Swing. WxPython is the only one I've used, so Ican't give you a "best one". I can say that going from Swing to wxPython wasn't too difficult. Here is the python wiki page with a bunch of the different ways to makecross-platform GUIs, if you want to just look at a couple. http://wiki.python.org/moin/GuiProgramming ----- Original Message ---- From: Chris Stewart To: python-list at python.org Sent: Wednesday, April 9, 2008 9:54:33 PM Subject: How is GUI programming in Python? I've always had an interest in Python and would like to dabble in it further. I've worked on a few very small command line programs but nothing of any complexity. I'd like to build a really simple GUI app that will work across Mac, Windows, and Linux. How painful is that going to be? I used to be really familiar with Java Swing a few years ago. I imagine it will be similar. Next, what would you say is the best framework I should look into? I'm curious to hear opinions on that. Chris Stewart cstewart913 at gmail.com -- http://mail.python.org/mailman/listinfo/python-list __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From cemasoniv at gmail.com Mon Apr 7 17:08:39 2008 From: cemasoniv at gmail.com (Charles Mason) Date: Mon, 7 Apr 2008 17:08:39 -0400 Subject: Data structure recommendation? In-Reply-To: References: <663744510804071339g639bfdccl63de8be66fe52df1@mail.gmail.com> Message-ID: <3290753a0804071408mcf16fb6r3bd746279cdbb8da@mail.gmail.com> If you can imply a partial order on your ranges then you can get O(n lg n) random access using a heap data structure. You'll have to implement your own heap, but heap search is easy to implement (it's Heapify that might require a little thinking). This will only work, of course, if your ranges are disjoint. C On Mon, Apr 7, 2008 at 4:58 PM, Steve Holden wrote: > Steven Clark wrote: > > Hi all- > > > > I'm looking for a data structure that is a bit like a dictionary or a > > hash map. In particular, I want a mapping of floats to objects. > > However, I want to map a RANGE of floats to an object. > > > > This will be used for timestamped storage / lookup, where the float > > represents the timestamp. > > get(x) should return the object with the "newest" (biggest) timestamp > > y <= x, if it exists. > > Example: > > > > foo = Foo() > > > > foo.get(1.5) > > -> None > > foo.put(1.3, 'a') > > foo.put(2.6, 'b') > > foo.get(1.5) > > -> 'a' > > foo.get(7.8) > > -> 'b' > > foo.put(5.0, 'c') > > foo.get(7.8) > > -> 'c' > > > > In otherwords, by the end here, for foo.get(x), > > x < 1.3 maps to None, > > 1.3 <= x < 2.6 maps to 'a', > > 2.6 <= x < 5.0 maps to 'b', > > 5.0 <= x maps to 'c'. > > > > I know that foo.get() will be called many times for each foo.put(). Is > > there any way to achieve O(1) performance for foo.get(), maybe via > > some kind of hash function? Or is the best thing to use some kind of > > binary search? > > > I believe the best way to implement this would be a binary search > (bisect?) on the actual times, which would be O(log N). Though since > they are timestamps they should be monotonically increasing, in which > case at least you don't have to go to the expense of sorting them. > > "Some kind of hash function" won't hack it, since the purpose of a hash > function is to map a large number of (possibly) evenly-distributed > (potential) keys as nearly as possible randomly across a much smaller > set of actual values. > > You might try messing around with reducing the precision of the numbers > to home in on a gross region, but I am not convinced that does anything > other than re-spell binary search if carried to extremes. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From edreamleo at charter.net Thu Apr 3 11:26:38 2008 From: edreamleo at charter.net (Edward K Ream) Date: Thu, 3 Apr 2008 10:26:38 -0500 Subject: ANN: Leo 4.4.8 rc1 released Message-ID: <3H6Jj.17$i_5.5@newsfe06.lga> Leo 4.4.8 rc1 is now available at: http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106 This version features a new ipython plugin that provides a two-way bridge between Leo and IPython. See http://webpages.charter.net/edreamleo/IPythonBridge.html Leo is a text editor, data organizer, project manager and much more. See: http://webpages.charter.net/edreamleo/intro.html The highlights of Leo 4.4.8: ---------------------------- - Leo's source code is now managed by bzr: see link below. - Leo's discussion is now hosted by Google Groups: see link below. - Arguments to g.es and g.es_print can be translated using gettext. - Completed ILeo: a bridge between IPython and Leo. See http://webpages.charter.net/edreamleo/IPythonBridge.html - Minibuffer commands may have arguments. - @menu trees can now refer to commands created by @command and @button nodes. - Added support for common @commands nodes in settings files. Links: ------ Leo: http://webpages.charter.net/edreamleo/front.html Forum: http://groups.google.com/group/leo-editor Download: http://sourceforge.net/project/showfiles.php?group_id=3458 Bzr: http://code.launchpad.net/leo-editor/ Quotes: http://webpages.charter.net/edreamleo/testimonials.html -------------------------------------------------------------------- Edward K. Ream email: edreamleo at yahoo.com Leo: http://webpages.charter.net/edreamleo/front.html -------------------------------------------------------------------- From tjreedy at udel.edu Sun Apr 20 20:29:44 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 20 Apr 2008 20:29:44 -0400 Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com><3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com><480b6133$0$34498$742ec2ed@news.sonic.net><3eac67b4-da0a-4926-9ca4-942271513ad2@26g2000hsk.googlegroups.com> Message-ID: "Roy Smith" wrote in message news:roy-E96A38.14493320042008 at 70-1-84-166.area1.spcsdns.net... | Even if this were worded in a less rude manner, I agree that Stula's response was rude. But it also strikes me as rude for people to whine about not getting free help hiding their code from the very people that they want help from. So I politely suggested that the OP pay for secret help. Such requests happen about once a month or so. If all the code-hiders were to have gotten together to openly share their obfuscation ideas and code, I suspect there would have been something pretty good by now. But in 10 years of my watching, this does not seem to have happened ;-) tjr From mail at timgolden.me.uk Fri Apr 18 16:37:32 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 18 Apr 2008 21:37:32 +0100 Subject: No subject In-Reply-To: <581282.70773.qm@web50110.mail.re2.yahoo.com> References: <581282.70773.qm@web50110.mail.re2.yahoo.com> Message-ID: <4809068C.8090107@timgolden.me.uk> SPJ wrote: > I am writing a script which need's to convert an excel file to > csv (text) format. For that I am using the following code: > > excel = win32com.client.Dispatch("Excel.Application","Quit") > workbook = excel.Workbooks.Open(xlsfile) > workbook.SaveAs(csvfile, FileFormat=24) # 24 represents xlCSVMSDOS > workbook.Close(False) > excel.Quit() > > I did not have any problem running this script on a windows xp > machine with python 2.5.2 and windows extensions. > But I get the following error when I run the same script on a > windows 2003 server with the same python and windows extension installation: > excel = win32com.client.Dispatch("Excel.Application","Quit") > File "D:\Python25\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch > dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) > File "D:\Python25\lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName > return (_GetGoodDispatch(IDispatch, clsctx), userName) > File "D:\Python25\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) > com_error: (-2147221005, 'Invalid class string', None, None) What's that "Quit" doing as the second param to Dispatch? TJG From deets at nospam.web.de Tue Apr 22 11:10:00 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 17:10:00 +0200 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <6760jfF2n3bn1U1@mid.uni-berlin.de> Message-ID: <676desF2nrgitU1@mid.uni-berlin.de> > I have a couple issues with this, though I wholeheartedly agree with > the sentiment: > > 1. Java didn't grow interfaces, they were there from the start. I might have expressed myself wrong here - I should have written "needed to introduce interfaces (right from the start)" > 2. Java interfaces solve a different problem than MI (used properly) > does: interfaces are there to make types polymorphic, whereas > inheritance's main use is to share behavior. But the *goal* of the polymorphy is mainly to have shared behavior. And matter of factly e.g. in swing, you use inner classes that implement most of the behavior you want, and override the few points where you want differences - and then clumsily delegate to that inner class all your interface-methods. Diez From namesagame-usenet at yahoo.com Tue Apr 29 18:06:10 2008 From: namesagame-usenet at yahoo.com (gamename) Date: Tue, 29 Apr 2008 15:06:10 -0700 (PDT) Subject: Sending Cntrl-C ?? References: <0274834e-17e1-4a95-88ec-f2aa77aeb3a9@k10g2000prm.googlegroups.com> Message-ID: > import os > import signal > import subprocess > > popen = subprocess(...) > os.kill(popen.pid, signal.SIGINT) > > Or with Python 2.6+: > > popen.send_signal(signal.SIGINT) Thanks, Christian. Would that work on win32 as well? -T From kkuhl05 at gmail.com Tue Apr 29 02:07:03 2008 From: kkuhl05 at gmail.com (Kevin K) Date: Mon, 28 Apr 2008 23:07:03 -0700 (PDT) Subject: File IO Issues, help :( References: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> Message-ID: <1fd8deae-1ed4-493c-a508-06c528c4ee1f@r66g2000hsg.googlegroups.com> On Apr 29, 12:55 am, Peter Otten <__pete... at web.de> wrote: > Kevin K wrote: > > On Apr 29, 12:38 am, "Eric Wertman" wrote: > >> chuck in a jsfile.close(). The buffer isn't flushing with what you > >> are doing now. jsfile.flush() might work... not sure. Closing and > >> re-opening the file for sure will help though. > > > Yeah sorry I forgot to include the close() in the quote but its there. > > In fact I moved it up a bit and still no luck heres the new code: > > > jsfile = open("../timeline.js", "r+") > > jscontent = jsfile.readlines() > > jsfile.truncate() > > > for line in jscontent: > > if re.search('var d =', line): > > line = "var d = \""+mint['1'].ascdate()+"\"\n" > > print line > > jsfile.write(line) > > jsfile.close() > > > I tried this can got the same result...?? > > """ > truncate(...) > truncate([size]) -> None. Truncate the file to at most size bytes. > > Size defaults to the current file position, as returned by tell(). > """ > > After the readlines() call the current file position is at the end of the > file. Try jsfile.truncate(0). > > Also note that readlines() reads the whole file into memory. For large files > it would therefore be better to write to a new file and rename it > afterwards. > > Peter Thanks Peter that seemed to be most of the problem, however I now have a bunch of null characters in the file. Could it be an unwanted line in the list that im writing? Thanks, Kevin From grante at visi.com Fri Apr 18 16:17:35 2008 From: grante at visi.com (Grant Edwards) Date: Fri, 18 Apr 2008 15:17:35 -0500 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> Message-ID: <1aadnUuqsapCnJTVnZ2dnUVZ_jqdnZ2d@visi> On 2008-04-18, Bob Greschke wrote: > I'm reading 3-byte numbers from a file and they are signed (+8 to > -8million). This seems to work, but I'm not sure it's right. > > # Convert the 3-characters into a number. > Value1, Value2, Value3 = unpack(">BBB", Buffer[s:s+3]) > Value = (Value1*65536)+(Value2*256)+Value3 > if Value >= 0x800000: > Value -= 0x1000000 > print Value > > For example: > 16682720 = -94496 > > Should it be Value -= 0x1000001 so that I get -94497, instead? Nope. -94496 is the right answer: >>> -94496 & 0xffffff 16682720 Here's another way to do it: ------------------------------------------------------------------ import struct def tohex(s): return '0x' + ''.join(['%0.2x' % ord(b) for b in s]) def from3Bytes(s): # sign extend the three byte number in s to make it 4 bytes long if ord(s[0]) & 0x80: s = '\xff'+s else: s = '\x00'+s return struct.unpack('>i',s)[0] for v in 0,1,-2,500,-500,7777,-7777,-94496,98765,-98765,8388607,-8388607,-8388608: s = struct.pack('>i',v)[1:] print "%8d %s %8d" % (v, tohex(s), from3Bytes(s)) ------------------------------------------------------------------ -- Grant Edwards grante Yow! I'll eat ANYTHING at that's BRIGHT BLUE!! visi.com From bignose+hates-spam at benfinney.id.au Wed Apr 16 18:18:48 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Thu, 17 Apr 2008 08:18:48 +1000 Subject: Death of NNTP greatly exaggerated (was: Finally had to plonk google gorups.) References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <87k5ixwiif.fsf_-_@benfinney.id.au> Michael Torrie writes: > I rarely use NNTP these days. I access c.l.py exclusively via e-mail, > and that works very well. I rarely use email for technical mailing lists these days. I access such forums exclusively via NNTP , and that works very well. > This official python list is one of the few lists that's even still on > nntp. All my other ones (gnome, gtk, openldap, clamav, freeradius, etc) > are all e-mail mailing lists only and it works very well. In fact, I > think it's much better since list subscription can actually be > controlled by someone. Most technical mailing lists are accessible via NNTP on gmane.org. It works very well. Other discussion groups remain on Usenet, accessible via NNTP from servers around the world that mirror each group. In fact, I think it's much better since I can use any one of those servers, and the content isn't locked up in one specific server. -- \ "I'm beginning to think that life is just one long Yoko Ono | `\ album; no rhyme or reason, just a lot of incoherent shrieks and | _o__) then it's over." -- Ian Wolff | Ben Finney From arnodel at googlemail.com Wed Apr 9 12:18:44 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Wed, 9 Apr 2008 09:18:44 -0700 (PDT) Subject: How to find documentation about methods etc. for iterators References: <47fce941$0$755$bed64819@news.gradwell.net> Message-ID: On Apr 9, 5:05 pm, tinn... at isbd.co.uk wrote: > I'm not sure if I have even phrased that right but anyway.... > > How does one find (in the standard Python documentation) information > about things like the iteritems() method and the enumerate() function. > > They are mentioned in the tutorial as ways of getting more information > as you loop through an object but there seems to be no easy way to > find the definitive documentation of these sorts of methods and > functions. OK, if I know the name before I start I can probably find > what I want, but what if I want to know how to extract some > information from an object as I loop and don't know what I want is > called? > > My particular quest that raised this was a way to get the line number > as I iterate through the lines of a file:- > > f = open(fn, 'r') > lineNo = 0 > for ln in f: > lineNo += 1 > > Is there a neater way of getting that line number as I go? If so how > am I meant to find out about it? There is a neater way, and you mention it in your question: f = open('myfile') for lineno, line in enumerate(f): # Do stuff How to find out about it? I suppose you need to get familiar with python iterators/iterables and the functions to manipulate them. How to do that depends on your prior experience with such concepts. Unfortunately I am not able to provide you with a good link :( -- Arnaud From leoniaumybragg at gmail.com Sat Apr 26 06:59:59 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:59:59 -0700 (PDT) Subject: spynomore crack Message-ID: spynomore crack http://cracks.00bp.com F R E E C R A C K S From kyosohma at gmail.com Fri Apr 11 21:06:24 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 11 Apr 2008 18:06:24 -0700 (PDT) Subject: win-shortcuts, file associates and command-line parameters ? References: <47FE6480.4090602@gmail.com> Message-ID: On Apr 11, 4:40 pm, Stef Mientki wrote: > Gabriel Genellina wrote: > > En Thu, 10 Apr 2008 16:03:28 -0300, Stef Mientki > > escribi?: > > >> under windows I tried to make a shortcut to a py -file, to run a program. > >> So making a shortcut like this works perfect: > >> D:\PyLab_Works.py > > >> But the problem is that I need to give some commandline parameters to > >> the py-file, > >> and > > >> D:\PyLab_Works.py btc_test > >> But the parameter doesn't seem to arrive in the python program > > > Check the associated command for .py files; see this message > >http://groups.google.com/group/comp.lang.python/msg/056ba14ae4fa57e3 > > Didn't work for me winXP-SP2, even after a restart :-( > But anyway thanks for the effort. > > cheers, > Stef Mientki You could try uninstalling Python and reinstalling it. Or you could do a registry hack. I did a search for what Gabriel was talking about and it looks like the key you want is found here: HKEY_LOCAL_MACHINE\software\classes\applications\pythonw.exe\shell \Edit with IDLE\command Mine has the following for its value: "L:\Python24\pythonw.exe" "L:\Python24\Lib\idlelib\idle.pyw" -n -e "%1" %* Make sure that the type is REG_SZ. As always, unless you know what you're doing, back up the registry (or create a restore point) before messing with it. However, I think the only thing that this hack could possibly do is mess up your Python install more if it was screwed up. Mike From Laundro at gmail.com Tue Apr 8 09:06:55 2008 From: Laundro at gmail.com (LaundroMat) Date: Tue, 8 Apr 2008 06:06:55 -0700 (PDT) Subject: Reproducing a web page and add own content to it. References: <6615blF2ifaqcU1@mid.uni-berlin.de> Message-ID: <1cddd2af-28be-42ee-8004-0d76978aeaa9@b9g2000prh.googlegroups.com> On Apr 8, 2:04 pm, "Diez B. Roggisch" wrote: > LaundroMat wrote: > > Hi - > > > I'm working on a Django powered site where one of the required > > functionalities is the possibility of displaying the content of > > external pages, with an extra banner at the top where specific > > information is displayed. In other words, I'm looking for a way to > > reproduce an existing web page and add some HTML code to it. (I can't > > think of an example right now, but the idea is similar to sites that > > let you see an external page and have some site-specific text above it > > (often stating that the content below is not part of the site the user > > comes from)). > > > To test this, I've been downloading an external page, adding some text > > to it and re-opening it in a browser (with the help of built-in > > modules such as urllib2 etc). This works of course, but the external > > page's links such as , or
> > are evidently no longer correct. > > > Apart from parsing the whole file and trying to inject the external > > site's domain in links such as the above (with the added inconvenience > > of having to store the external page locally), is there an easier way > > of accomplishing what I want? > > Using a frame? > > Diez Ack. I was too focused on importing the external web page and redisplaying the information (I've just been reading up on BeautifulSoup) instead of looking for an HTML based approach. Thanks! From luismgz at gmail.com Thu Apr 3 09:33:42 2008 From: luismgz at gmail.com (=?ISO-8859-1?Q?Luis_M=2E_Gonz=E1lez?=) Date: Thu, 3 Apr 2008 06:33:42 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> Message-ID: <89bca327-6a3f-4128-be72-75d4a50b9bf0@13g2000hsb.googlegroups.com> I have come to the same conclusion. ORMs make easy things easier, but difficult things impossible... The best approach I've seen so far is webpy's (if we are talking of web apps). It isn't an ORM, it is just a way to make the database api easier to use. Queries don't return objects, they return something similar to dictionaries, which can be used with dot notation ( for example, result.name is equal to result['name'] ). A simple select query would be db.select('customers') or db.select('customers', name='John'). But you can also resort to plain sql as follows: db.query('select * from customers where name = "John"'). Simple, effective and doesn't get in your way. Luis From aldo at nullcube.com Mon Apr 7 03:51:42 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Mon, 7 Apr 2008 17:51:42 +1000 Subject: Adherence to PEP 8 for published code (was: ANN: pry unit testing framework) In-Reply-To: <87d4p2mcrp.fsf_-_@benfinney.id.au> References: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> <87d4p2mcrp.fsf_-_@benfinney.id.au> Message-ID: <20080407075142.GA17450@nullcube.com> Thus spake Ben Finney (bignose+hates-spam at benfinney.id.au): > PEP 8 only has the force that people grant it. Nevertheless, it's a > style guide that's widely accepted in the Python community, and > adhering to it in one's code makes it easier to read for the majority, > because it reduces the needless inconsistencies between different > bodies of code. > > Conversely, deliberately diverging from the widely-accepted style > guide increases the cognitive load on the reader; if that divergence > is not done for a very good reason, one is imposing needless burden on > every reader of the code. This is getting silly. Let's recap. You are upset because I prefer this widely-used method naming convention: object.myName() ... to this one, which was recently adopted as a recommendation in PEP 008 for modules in the standard library: object.my_name() By doing so, you say, I am "imposing needless burden on every reader" of my code... Well, lets look at the facts: First, PEP 8 recommends a naming scheme only for the standard library, and it is not follwed consistently even there. Second, mixedCase is very common both inside and outside the Python project. No-one who codes regularly in Python can be unfamiliar with it, even if they never stray beyond the standard library. Third, this is a minor, recently-introduced convention. Anyone would dislike code that chose not to name classes with an initial capital, or used something other than "self" as the first method parameter. Method naming conventions are far, far fuzzier. The primary issue is simply to clearly distinguish between words in multi-word names - mymethodname would be bad, MYMETHODNAME would be even worse, but my_method_name and myMethodName are both perfectly legible. You are mis-interpreting the intent behind PEP-8 if you think its authors intended to provoke shrill public condemnation of any module that dares to use a long-standing, widely-used alternative method naming scheme. In fact, PEP 8 contains an entire section warning against exactly this kind of inflexible and small-minded application of its recommendations - perhaps you should read it sometime. > > You're also vastly overstating the impact of a minor naming > > convention choice. Calling this a "large black mark" smacks of > > scare-mongering to me. > > When distributing code with the expectation that others use it, it's a > large black mark if it deliberately shun the widely-accepted, > easily-followed coding standards, for the above reasons. > > I don't see why that would be scary. If you find it so, you have my > sympathy. You re-enforce the point you're trying to counter beautifully. Thanks for driving my argument home. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From sean.m.mcdaniel at gmail.com Fri Apr 25 08:55:15 2008 From: sean.m.mcdaniel at gmail.com (s.mcdaniel) Date: Fri, 25 Apr 2008 05:55:15 -0700 (PDT) Subject: Installation in a local directory References: <2008042500101716807-seanmmcdaniel@gmailcom> Message-ID: On Apr 25, 12:37 am, Steve Holden wrote: > Sean McDaniel wrote: > > Hi y'all, > > > I'm trying to perform a local install of python at work in my user > > directory. Everything compiles correctly, but I can't seem to tell the > > configure script the location of the bin and lib directories where I > > want my stuff. I've think I've passed the correct flags to the > > 'configure' script. > > > make clean > > ./configure --enable-shared --prefix=/user/mcdaniel/arch32 > > make > > > where arch32 contains the the lib and bin directories where I want my > > python stuff to go. Unfortunately these directories are not written to; > > everything ends up in the default location from where I ran 'make'. > > Moreover, if I add a symbolic link from the python binary (which I can > > run directly without problems) to the bin directory so that my PATH will > > recognize the new python, I get an error about loading shared libraries. > > > I'm making on a 32 bit new debian system. > > > Thank you for your help, > > Did you run "make install" yet? It's that step that moves the binaries > to where they should live. As it says in > > http://www.python.org/download/releases/2.5/ > > """Change to the Python-2.5 directory and run the "./configure", "make", > "make install" commands to compile and install Python.""" > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ Damnit, That was exactly the problem. Thank you. Sean From mal at egenix.com Mon Apr 14 10:01:27 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Mon, 14 Apr 2008 16:01:27 +0200 Subject: Compiling Python 2.5.2 on AIX 5.2 In-Reply-To: <0b73e8e5-c301-4823-ac94-42f757456cf1@x19g2000prg.googlegroups.com> References: <0b73e8e5-c301-4823-ac94-42f757456cf1@x19g2000prg.googlegroups.com> Message-ID: <480363B7.3040004@egenix.com> On 2008-04-13 18:57, Randy.Galbraith at gmail.com wrote: > I'm investigating the possible use of Mecurial SCM as a replacement > for CVS. Mecurial is written in Python. I have a background in GNU/ > Linux, Solaris, sparc and Perl. However AIX, powerpc and Python are > new to me. On AIX 5.3, Python 2.5.2 should build out of the box using gcc. We've successfully build Python 2.3, 2.4 and 2.5 on AIX 5.3 using the gcc compiler suite and tools installed from the AIX Linux Toolbox: http://www-03.ibm.com/systems/p/os/aix/linux/toolbox/altlic.html ./configure --enable-unicode=ucs2 --with-gcc For 2.3 and 2.4 you need to patch pyconfig.h after the configure run: *** pyconfig.h~ Wed Nov 14 17:22:01 2007 --- pyconfig.h Wed Nov 14 17:22:01 2007 *************** *** 49,55 **** /* #undef HAVE_BROKEN_POLL */ /* Define if the Posix semaphores do not work on your system */ ! /* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ /* Define if pthread_sigmask() does not work on your system. */ /* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ --- 49,55 ---- /* #undef HAVE_BROKEN_POLL */ /* Define if the Posix semaphores do not work on your system */ ! #define HAVE_BROKEN_POSIX_SEMAPHORES 1 /* Define if pthread_sigmask() does not work on your system. */ /* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 14 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From yzghan at gmail.com Wed Apr 23 10:44:23 2008 From: yzghan at gmail.com (yzghan at gmail.com) Date: Wed, 23 Apr 2008 07:44:23 -0700 (PDT) Subject: python has memory leak? References: Message-ID: Thanks to Christian and Jean-Paul for your reply. I moved away from the stackless version (which I don't understand what uniqueness it comes with) and downloaded a fresh copy of Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32. Following J-P's suggestion, I included the block to be tested in a loop: i=20 while i>0: i=i-1 test(log) log.flush() And logged the memory usage in bytes instead of MB. The result as included below shows the peak memory usage keeps going up in the first 7 iterations. Can someone point to some docs or books about how python manages memory or share some experience? Thanks, -GH [10:27:54] test() starting ... memory usage: 4599808L 4599808L [10:27:56] test() ... memory usage: 107499520L 107499520L [10:27:56] test() done. memory usage: 41754624L 107503616L [10:27:56] test() starting ... memory usage: 41754624L 107503616L [10:27:59] test() ... memory usage: 108216320L 108400640L [10:27:59] test() done. memory usage: 58884096L 108400640L [10:27:59] test() starting ... memory usage: 58884096L 108400640L [10:28:02] test() ... memory usage: 108220416L 108433408L [10:28:02] test() done. memory usage: 42233856L 108433408L [10:28:02] test() starting ... memory usage: 42233856L 108433408L [10:28:04] test() ... memory usage: 108228608L 108441600L [10:28:05] test() done. memory usage: 75149312L 108441600L [10:28:05] test() starting ... memory usage: 75149312L 108441600L [10:28:07] test() ... memory usage: 108498944L 108707840L [10:28:07] test() done. memory usage: 41992192L 108707840L [10:28:07] test() starting ... memory usage: 41992192L 108707840L [10:28:10] test() ... memory usage: 108122112L 108707840L [10:28:10] test() done. memory usage: 58523648L 108707840L [10:28:10] test() starting ... memory usage: 58523648L 108707840L [10:28:13] test() ... memory usage: 108642304L 108855296L [10:28:13] test() done. memory usage: 41873408L 108855296L [10:28:13] test() starting ... memory usage: 41873408L 108855296L [10:28:16] test() ... memory usage: 108224512L 108855296L [10:28:16] test() done. memory usage: 58626048L 108855296L [10:28:16] test() starting ... memory usage: 58626048L 108855296L [10:28:18] test() ... memory usage: 108224512L 108855296L [10:28:19] test() done. memory usage: 41975808L 108855296L [10:28:19] test() starting ... memory usage: 41975808L 108855296L [10:28:21] test() ... memory usage: 108224512L 108855296L [10:28:22] test() done. memory usage: 58626048L 108855296L [10:28:22] test() starting ... memory usage: 58626048L 108855296L [10:28:24] test() ... memory usage: 108224512L 108855296L [10:28:24] test() done. memory usage: 41975808L 108855296L [10:28:24] test() starting ... memory usage: 41975808L 108855296L [10:28:27] test() ... memory usage: 108224512L 108855296L [10:28:27] test() done. memory usage: 58626048L 108855296L [10:28:27] test() starting ... memory usage: 58626048L 108855296L [10:28:30] test() ... memory usage: 108224512L 108855296L [10:28:30] test() done. memory usage: 41975808L 108855296L [10:28:30] test() starting ... memory usage: 41975808L 108855296L [10:28:32] test() ... memory usage: 108224512L 108855296L [10:28:33] test() done. memory usage: 58626048L 108855296L [10:28:33] test() starting ... memory usage: 58626048L 108855296L [10:28:35] test() ... memory usage: 108224512L 108855296L [10:28:36] test() done. memory usage: 41975808L 108855296L [10:28:36] test() starting ... memory usage: 41975808L 108855296L [10:28:38] test() ... memory usage: 108224512L 108855296L [10:28:38] test() done. memory usage: 58626048L 108855296L [10:28:38] test() starting ... memory usage: 58626048L 108855296L [10:28:41] test() ... memory usage: 108224512L 108855296L [10:28:41] test() done. memory usage: 41975808L 108855296L [10:28:41] test() starting ... memory usage: 41975808L 108855296L [10:28:44] test() ... memory usage: 108224512L 108855296L [10:28:44] test() done. memory usage: 58626048L 108855296L [10:28:44] test() starting ... memory usage: 58626048L 108855296L [10:28:46] test() ... memory usage: 108224512L 108855296L [10:28:47] test() done. memory usage: 41975808L 108855296L [10:28:47] test() starting ... memory usage: 41975808L 108855296L [10:28:49] test() ... memory usage: 108224512L 108855296L [10:28:50] test() done. memory usage: 58626048L 108855296L From zoom.quiet at gmail.com Fri Apr 25 02:13:42 2008 From: zoom.quiet at gmail.com (Zoom.Quiet) Date: Fri, 25 Apr 2008 14:13:42 +0800 Subject: [ulipad:2586] [ANN]UliPad 3.9 released! In-Reply-To: <505f13c0804242310n62b0720fs60f36b83d8ea9ab4@mail.gmail.com> References: <505f13c0804242310n62b0720fs60f36b83d8ea9ab4@mail.gmail.com> Message-ID: <9dad9f0a0804242313m4b2d96sb7ed7ae48fe75bc8@mail.gmail.com> good job! enjoy now! 2008/4/25 limodou : > > UliPad is a flexible editor, based on wxPython. It's has many features,just > like:class browser, code auto-complete, html viewer, directory browser, wizard, > etc. The main feature is the usage of mixin. This makes UliPad can be > extended easily. So you can write your own mixin or plugin, or simple script, > these can be easy and seamless integrated with UliPad. > > New Features and Changes: > > #. Add php.acp thanks for ?? > #. Replace old snippet with new snippet, more details please see > <`Snippet Howto `_> > #. Binding F5 to editor but not MainFrame, and add F5(Refresh) support > in Directory Browser. > #. Improve python class browser, threading update, change some icons > #. Add indent cursor move functionality see <`Indent Moving Howto > `_> > #. Improve threading document modification process, so you can get > better efficiency > #. Introduce meide(http://code.google.com/p/meide) project to simplify > the interface creation > #. Add FNB.FNB_DROPDOWN_TABS_LIST style to EditorCtrl > #. Change auto file check in Editor on_set_focus event handler > #. Change DDE to asyncore and asynchat framework > #. Change preference dialog from notebook to treebook > #. Add icon set theme support > #. Add strip line ending when saving functionality option in Preferences > #. Strip leading space when doing "Run in Shell" > #. Add auto detect python interpreter in windows platform > #. Improve ReST document render, and fix the setfocus lost bug when > auto modified > the html output, thanks a lot to ygao > #. Change setmenutext to use fix width to set the menu text, replace with '\t' > #. Chanage notebook left double click to right double click(enlarge > notebook size) > #. Add search text count in Find & Replace pane > #. Add line ending mixture check when saving file feature > #. Improve preference dialog input assistant checkbox process. > When you check the first checkbox(Enable input assistant) it'll > automatically toggle other 5 checkboxes. > #. Change new toolbutton to dropdown toolbutton, and it can remember the last > new file type(select new type menu first), then when you select new menu, > it'll create a new file with the last new file type > #. Improve command search and pairprog plugin caret display process > #. Add auto new version of UliPad check > #. Add slice language syntax support > #. Add auto pop up project setting dialog when adding directory to > directoy browser window > #. Add Open Explorer Window Here menu to editoctrl tab context menu > #. Add open snippet tool button, change open dirbrowser and open > snippet toolbutton to check toolbutton > #. Change ``explorer.exe %s`` as ``explorer.exe /e, %s`` in windows platform > #. Add copy filename to clipboard menu on document area tab context menu > #. Add wrap text feature, via [Edit]->[Format]->[Wrap Text...] > > New Plugins: > > #. canvas_test_plugin, you can directly test DC api > #. web2py_plugin, supply web2py shell > > Bug fix: > > #. Fix webopen twice open bug > #. Fix editor shortcuts key caption error > #. Fix if set DROP_DOWN_TABS_LIST style, right arrow will disappear bug > #. Fix utf-16 convertion bug > #. Fix mako tag auto complete bug #issue 14 > #. Fix if lines are folded, when goto hiding lines will no effect bug > #. Fix DDE bug, thanks to LP > #. Fix webopen bug, can't correctly deal with 'mailto:' > #. Fix smart tabs bug > #. Fix copy and paste lineending is not correct bug > #. Fix tab invisible bug after changing size or changing the page title > #. Fix template line-ending not match the default line-ending setting > #. Fix password widget is not Password type widget bug > #. Fix script filename cannot be unicode(chinese) bug > #. Fix syntax check exception process bug > #. Fix ruler bug > > UliPad has ported to code.google.com, so you can visit the new project site at: > http://code.google.com/p/ulipad, and also visit the new svn address. Recommends > using source version. > > source version download: http://ulipad.googlecode.com/files/ulipad.3.9.zip > window exe version: http://ulipad.googlecode.com/files/ulipad.3.9.exe > > maillist: http://groups.google.com/group/ulipad > ulipad snippets site: http://ulipad.appspot.com (hosted by GAE) > > Hope you enjoy it. > -- > I like python! > UliPad <>: http://code.google.com/p/ulipad/ > UliSpot <>: http://ulipad.appspot.com > My Blog: http://www.donews.net/limodou > -- '''????????????????????! PI keeps evolving organizations which promoting people be good! '''http://zoomquiet.org Pls. usage OOo to replace M$ Office. http://zh.openoffice.org Pls. usage 7-zip to replace WinRAR/WinZip. http://7-zip.org You can get the truely Freedom 4 software. From Stephen.Cattaneo at u4eatech.com Thu Apr 3 10:31:06 2008 From: Stephen.Cattaneo at u4eatech.com (Stephen Cattaneo) Date: Thu, 3 Apr 2008 07:31:06 -0700 Subject: manipulating hex values In-Reply-To: References: <47F26CC3.3060307@u4eatech.com> Message-ID: Thanks to everyone ( Grant, Cliff, and Gabriel) for responding and helping me. Cheers, Steve -----Original Message----- From: Grant Edwards [mailto:grante at visi.com] Sent: Tuesday, April 01, 2008 7:46 PM To: python-list at python.org Subject: Re: manipulating hex values On 2008-04-01, Stephen Cattaneo wrote: >>> I am relatively new to socket programming. I am attempting to >>> use raw sockets to spoof my IP address. >> >> Don't bother to try... > > Is there a better solution to spoofing my IP. then using raw > sockets You'll have to define "spoofing my IP", but I suspect that what you're trying can't be done by using raw sockets. > (I'm working on a machine with multiple interfaces and need to > be able to some how specify which interface that traffic needs > to be sent/recieved to/from) That's what routing tables are for. If you want to send packets using a particular IP, then configure an interface so that it has that adrress, and then bind your socket to that address. > The source of my confusion is that I need to keep my bytes formated > correctly. I am using the below 'raw socket example' proof-of-concept > code as my example. OK. > (And yes, I have tried the proof-of-concept. It works > correctly. It is not my code.) I know. It's my code. :) I wrote Python's raw socket support code and the example code that is floating around the 'net. > dstAddr = "\x01\x02\x03\x04\x05\x06" > dstAddr1 = "0x010203040506" > dstAddr != dstAddr1 Right. > Follow up question: What is the best to store my bytes up > until sending the packets? That depends on what you want to do with them. Ultimately, they need to be strings when they're sent out the socket (in Python a "string" is really just an array of 8-bit bytes). The best way to store them is entirely dependent on how you want to manipulate them before they're sent. > Perhaps I should use lists of decimal numbers and then > before sending convert to hex. Again: you're not converting them to hex. You're converting them to a python "string" object which is really just an array of bytes. Stop saying "hex" when you're talking about a string (array of bytes). "hex" is a way to _represent_ a value textually. It's simply a format used when print a value on paper or a screen. The value itself isn't hex any more than a particular instance of Canis lupus familiaris is "English" because somebody spells it "dog" instead of "chien" or "Hund". > I.E. dstAddr = [ 1, 2, 3, 4, 5, 6] > dstAddr.prepareToSend() I presume you know that list objects don't have a method called prepareToSend(). > txFrame = struct.pack("!6s6sh",dstAddr,srcAddr,proto) + ethData > > Is there a better way to do this? It's not at all clear what "this" is. If you want to convert from a list (or any sequence, really) of integer objects to a string where each integer is converted into a single byte within the string, then here are a few ways: import operator import struct intlist = [1,2,3,4,5,6] s1 = ''.join(chr(b) for b in intlist) s2 = reduce(operator.add,[chr(b) for b in intlist]) s3 = struct.pack("6B",*tuple(intlist)) print repr(s1) print repr(s2) print repr(s3) print s1==s2 print s2==s3 When run you get this: '\x01\x02\x03\x04\x05\x06' '\x01\x02\x03\x04\x05\x06' '\x01\x02\x03\x04\x05\x06' True True I think the third alternative using struct.pack() is the most readable, but others will no doubt disagree. -- Grant Edwards grante Yow! I'm GLAD I at remembered to XEROX all visi.com my UNDERSHIRTS!! From lists at cheimes.de Fri Apr 25 17:43:30 2008 From: lists at cheimes.de (Christian Heimes) Date: Fri, 25 Apr 2008 23:43:30 +0200 Subject: Subclassing datetime.date does not seem to work In-Reply-To: <4811FF57.5040200@comcast.net> References: <4811FF57.5040200@comcast.net> Message-ID: <48125082.5020409@cheimes.de> Rick King schrieb: > I would like to subclass datetime.date so that I can write: > > d = date2('12312008') > > I tried: > > from datetime import date > class date2(date): > def __init__( self, strng ): > mm,dd,yy = int(strng[:2]), int(strng[2:4]), int(strng[4:]) > date.__init__(self,yy,mm,dd) > > But then this statement: > d = date2('12312008') > > Causes: > TypeError: function takes exactly 3 arguments (1 given) > > Is there something basically wrong with subclassing date? > -Rick King datetime.date is a C extension class. Subclassing of extension classes may not always work as you'd expect it. Christian From skanemupp at yahoo.se Wed Apr 16 16:18:22 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Wed, 16 Apr 2008 13:18:22 -0700 (PDT) Subject: Profiling, recursive func slower than imperative, normal? Message-ID: the 0.409 vs 0.095 is the total times right? so the imperative function is >4 times faster than the recursive. or what does tottime stand for? is this always the case that the recursive function is slower? the gain is less code? are some functions only implementable recursively? def power(nbr, po): if po==0: return 1 if po>0: return nbr*power(nbr, po-1) if po<0: return 1/power(nbr, -1*po) 109992 function calls (10002 primitive calls) in 0.409 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.015 0.015 0.409 0.409 :1(test1) 1 0.000 0.000 0.409 0.409 :1() 109989/9999 0.394 0.000 0.394 0.000 myMath.py:39(power) 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} def power2(nbr, po): acc=1 if po >= 1: acc=nbr for x in range(1, po): acc=acc*nbr if po < 0: if nbr!=0: acc=1 for x in range(0, po, -1): acc=acc/nbr else: return "Division by zero" return acc 20001 function calls in 0.095 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.026 0.026 0.095 0.095 :1(test1) 1 0.000 0.000 0.095 0.095 :1() 9999 0.051 0.000 0.069 0.000 myMath.py:47(power2) 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} 9999 0.017 0.000 0.017 0.000 {range} From theiviaxx at gmail.com Wed Apr 23 20:16:32 2008 From: theiviaxx at gmail.com (theiviaxx at gmail.com) Date: Wed, 23 Apr 2008 17:16:32 -0700 (PDT) Subject: python-ldap - Operations Error Message-ID: Hello all, I am trying to integrate TurboGears with our Active Directory here at the office. TurboGears aside, i cannot get this to work. The simplest thing i can do to test this is: >>> import ldap >>> l = ldap.initialize("ldap://server.net") >>> l.simple_bind(DN, "secret") 1 >>> l.result(1) (97, []) >>> l.search("dc=server,dc=net", ldap.SCOPE_SUBTREE, "(sAMAccountName=user)") OPERATIONS_ERROR: {'info': '00000000: LdapErr: DSID-0C090627, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, vece', 'desc': 'Operations error'} The simple bind works fine and returns a result, when i get the result, it returns 97 meaning successful. So there was a successful bind on the connection, right? I'm really not sure where the problems lies. Is it with the way im connecting or is it something to do with our AD server? Thanks From gagsl-py2 at yahoo.com.ar Thu Apr 24 00:21:15 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 24 Apr 2008 01:21:15 -0300 Subject: Problem using copy.copy with my own class References: <676noiF2n7ttmU1@mid.uni-berlin.de> <480FFF55.5070803@gmail.com> Message-ID: En Thu, 24 Apr 2008 00:32:37 -0300, Michael Torrie escribi?: > Jeffrey Barish wrote: >> Marc 'BlackJack' Rintsch wrote: >>> Please simplify the code to a minimal example that still has the >>> problem >>> and *show it to us*. It's hard to spot errors in code that nobody >>> except >>> you knows. >> >> Here it is: >> >> import copy >> >> class Test(int): >> def __new__(cls, arg1, arg2): > ^^^^^^^ > The exception is saying that copy.copy is not providing this 3rd > argument. I might be a bit dense, but what would arg2 be for? Isn't > arg1 supposed to be the object instance you are copying from? If so, > arg2 is superfluous. I agree. In case arg2 were really meaningful, use __getnewargs__ (see ) import copy class Test(int): def __new__(cls, arg1, arg2): return int.__new__(cls, arg1) def __init__(self, arg1, arg2): self.arg2 = arg2 def __getnewargs__(self): return int(self), self.arg2 py> t = Test(3, 4) py> print type(t), t, t.arg2 3 4 py> t_copy = copy.copy(t) py> print type(t_copy), t_copy, t_copy.arg2 3 4 But note that subclassing int (and many other builtin types) doesn't work as expected unless you redefine most operations: py> x = t + t_copy py> print type(x), x 6 py> t += t_copy py> print type(t), t 6 -- Gabriel Genellina From martin at v.loewis.de Thu Apr 24 10:21:50 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Thu, 24 Apr 2008 16:21:50 +0200 Subject: py3k concerns. An example In-Reply-To: References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: <4810977E.3060509@v.loewis.de> > Again, to me, this is a non-issue because I've been able to create a > cross-version compatible single codebase for pyparsing. But it was a > bit dicey there for a while, and I think other module developers/ > maintainers may not be so lucky. I'm more optimistic. I tried it for Django, and while the port is not complete, it goes really well and supports "basic" operations (i.e. the Django tutorial). Based on your experience, and other reports, I think there is a fair chance that you can support a wide range of versions (2.x and 3.x) from a single code base for most projects. > - create (if possible) single cross-version compatible code > - forego support of 3.0 users > - discontinue pre-2.6 support for future versions of their module > - maintain dual codebase One needs to consider the drawbacks in each case; for the single codebase approach, the drawback probably is that readability suffers, and the need for testing increases (but it does always if you support multiple targets). It also requires expertise to create such cross-version code in the first place, but that's "just" a learning issue (i.e. you have to keep the rules in mind that you want to follow). Regards, Martin From python.list at tim.thechases.com Wed Apr 16 09:53:02 2008 From: python.list at tim.thechases.com (Tim Chase) Date: Wed, 16 Apr 2008 08:53:02 -0500 Subject: vary number of loops In-Reply-To: References: Message-ID: <480604BE.3090002@tim.thechases.com> > I'm new to Python and the notion of lambda, and I'm trying to write a > function that would have a varying number of nested for loops > depending on parameter n. This just smells like a job for lambda for > me, but I can't figure out how to do it. Any hint? I'm not sure lambda is the tool to use here. Doable, perhaps, but improbable in my book. > For example, for n=2, I want the function to look something like: > > def foo(2) > generate 2 sets of elements A, B > # mix elements by: > for a_elt in A > for b_elt in B > form all combinations of them > > If n=3, I want to have 3 sets of elements and mix them up using 3 for > loops. You might be ineterested in this thread: http://mail.python.org/pipermail/python-list/2008-January/473650.html where various solutions were proposed and their various merits evaluated. -tkc From grante at visi.com Tue Apr 1 14:25:11 2008 From: grante at visi.com (Grant Edwards) Date: Tue, 01 Apr 2008 13:25:11 -0500 Subject: manipulating hex values References: Message-ID: On 2008-04-01, Stephen Cattaneo wrote: > I am relatively new to socket programming. I am attempting to > use raw sockets to spoof my IP address. From what I can tell > I will have to build from the Ethernet layer on up. This is > fine, but I am having some trouble with manipulating my hex > values. > > Seems to me that there are two ways to store hex values: > 1. as literal hex - 0x55aa That's a hex represenation of a literal integer object. The object itself isn't either decimal or hex. It's and integer object. [It's _probably_ stored in binary, but that's beside the point.] > 2. as a string - "\x55aa" That is the string "Uaa". Perhaps you meant "\x55\xaa"? If so, that might or might not have the same bit-pattern as 0x55aa depending on what CPU you're using. > If I want to convert hex to decimal I can use: int("\x55aa", 16) No you can't' 1) That call doesn't convert hex to decimal. It converts to an integer object (which almost certainly is stored in 2's compliment binary). There is nothing in decimal in the example. 2) "\x55aa" doesn't mean what you think it does. "\x55aa" is a three byte string consisting of a byte with the value 0x55 and then two ascii 'a' bytes. 0x55 is an ascii 'U'. I think you meant "0x55aa". That's completely different from either "\x55aa" or "\x55\xaa". > # note that plain 0x55aa, instead of "\x55aa", will > raise an exception That's because the above function call requires a string. 0x55aa isn't a string. It's an integer literal. "\x55aa" is a three byte string that's equal to "Uaa", and it can't be converted to an integer. > The Question: > If I want to do any kind of calculation I have found its best to just > convert my values to decimal, do the math, then convert back to hex. First: stop talking (and thinking) about "decimal" stuff. You're not really doing anything in decimal in any of the code you've posted so far. > In my bellow code I get > """byteList.append(int(value,16)) > ValueError: invalid literal for int()""" > when attempting to run. No you don't. You get this: Traceback (most recent call last): File "foo.py", line 20, in ? checksum = calcIPChecksum(["\x45" + "\x00", "\x01\x4a", "\x00\x00", "\x40"+"\x00", "\x20"+"\x11"]) NameError: name 'calcIPChecksum' is not defined Don't re-type examples in postings. Paste in the actual code that you're using. That way we don't have to try to guess about the differences between the real code and what's in the posting. > I do not understand why this exception is being raised? If you want to understand why you're getting that exception, add the line "print value" immediately prior to the int(value,16) line. > It is a for loop iterating over a list of hex strings. Sorry > for the long-ish question. Any help or comments would be > appreciated. > > > ----my checksum--- > def calcIPCheckSum(ipHeaders): > byteList = [] > # convert groups from hex to dec > for value in ipHeaders: > byteList.append(int(value,16)) # Exception raised here! > > # 1's compliment > for index in range(len(byteList)): > byteList[index] = abs(byteList[index] - 65535) > > # add bytes together shifting the extra byte > total = 0 > for value in byteList: > total = total + value > if total > 65535: > total = total - 65535 > > return hex(total) > > checksum = calcIPChecksum(["\x45" + "\x00", "\x01\x4a", "\x00\x00", > "\x40"+"\x00", "\x20"+"\x11"]) You pretty much lost me on the above algorithm (hex/decimal/string/integer mixups aside). FWIW, here's an IP checksum routine: def calcIPCheckSum(ipHeaders): total = 0 for w in ipHeaders: total += w carries = total >> 16 sum = (total + carries) & 0xffff return sum ^ 0xffff print hex(calcIPCheckSum([0x0100,0xf203,0xf4f5,0xf6f7])) A slightly more terse version: import operator def calcIPCheckSum(ipHeaders): total = reduce(operator.add,ipHeaders) carries = total >> 16 return ((total + carries) ^ 0xffff) & 0xffff -- Grant Edwards grante Yow! ... he dominates the at DECADENT SUBWAY SCENE. visi.com From gagsl-py2 at yahoo.com.ar Sun Apr 20 04:12:36 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 05:12:36 -0300 Subject: random.random(), random not defined!? References: <2a3931f5-481d-4831-baad-fcc9f0c0c129@m73g2000hsh.googlegroups.com> Message-ID: En Sat, 19 Apr 2008 16:28:37 -0300, globalrev escribi?: > do i need to import something to use random? Let me guess: you have a script named random.py? Perhaps the same one you're executing? In that case when you write "import random", you're importing *your* script instead of the standard one. -- Gabriel Genellina From sturlamolden at yahoo.no Mon Apr 21 20:09:57 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Mon, 21 Apr 2008 17:09:57 -0700 (PDT) Subject: Segfault accessing dictionary in C Python module References: Message-ID: <365f11e2-6e3e-4e9c-bfda-7c4168a39769@u69g2000hse.googlegroups.com> On Apr 22, 2:00 am, Mitko Haralanov wrote: > As far as I know, I have done everything by the book yet I can't seem > to figure out where the problem is. Any help would be great? Albeit not having looked at your code in detail, I'm wiling to bet you have one of the refcounts wrong. Have you considered using Cython? From lists at cheimes.de Wed Apr 9 12:10:38 2008 From: lists at cheimes.de (Christian Heimes) Date: Wed, 09 Apr 2008 18:10:38 +0200 Subject: I am worried about Python 3 In-Reply-To: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> Message-ID: <47FCEA7E.5060908@cheimes.de> jmDesktop schrieb: > If I continue in Python 2.5.x, am I making a mistake? Is it really > that different? I'm speaking as a long time Python user and Python core developer here. You are safe to ignore Python 3.0 for now. :] You can start worrying about the 3.x series in 2010 when Python 3.1 is out and most libraries are ported to 3.x. Christian From aaron.watters at gmail.com Fri Apr 18 14:07:12 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Fri, 18 Apr 2008 11:07:12 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: <14107338-3bf1-45cb-983a-687f46f19503@d45g2000hsc.googlegroups.com> > Try coming up with a real standard for evaluation. > How much of a performance hit will actually cause you trouble? 1% extra > on string interpolation? 10%? 50%? 200%? You misread my comment. I don't want function calls to support dictionary emulation if there is a speed penalty because this is such a special case and function calls are so important. I don't really know, but I think "fixing" the above issue for string.format(...) might involve changing the representation of every python stack frame... not worth it in this case if there is any penalty (afaik there isn't). An alternative is to provide an alternate interface to string.format so that you could pass in an object which might emulate a dictionary, like string.formatDict(D) -- or you could even adopt a shortcut notation like string % D -- hey there's an idea! -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=ignore+warnings From aaron.watters at gmail.com Wed Apr 2 09:36:26 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 2 Apr 2008 06:36:26 -0700 (PDT) Subject: april fools email backfires Message-ID: Grapevine says that an architect/bigot at a java/spring shop sent out an April Fools email saying they had decided to port everything to Django ASAP. Of course the email was taken seriously and he got a lot of positive feedback from line developers and savvy users/managers that they thought it would be a great idea; it's about time; gotta do something about this mess... -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=other+surprises From Lie.1296 at gmail.com Wed Apr 23 12:48:54 2008 From: Lie.1296 at gmail.com (Lie) Date: Wed, 23 Apr 2008 09:48:54 -0700 (PDT) Subject: Explicit variable declaration References: <1506f165-7f86-4dc7-aa29-6488eda9ae7f@l64g2000hse.googlegroups.com> Message-ID: <5e59998b-d2e7-48cb-824b-84620f95c9bc@w5g2000prd.googlegroups.com> On Apr 23, 4:52 pm, "Filip Gruszczy?ski" wrote: > > You mean the type? Not in 2.x, but in 3.x, there are function > > annotations: > > > def a_function(arg1: int, arg2: str) -> None: pass > > Nope, I don't like types ;-) 3.x seems pretty revolutionary, and this > typing can be appreciated by some people. > > > Declaring what about them? If you mean declaring the type, remember > > that Python deliberately allows any name to be bound to any object; > > type declarations can't be enforced without losing a lot of the power > > of Python. > > Just declaring, that they exist. Saying, that in certain function > there would appear only specified variables. Like in smalltalk, if I > remember correctly. If you want to just declare that name exist, but doesn't want to declare the type, why don't you just do this: def somefunc(): nonlocal = nonlocal local = 0 # or None or [] or an initial value # return nonlocal * local From george.sakkis at gmail.com Wed Apr 2 13:36:13 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 2 Apr 2008 10:36:13 -0700 (PDT) Subject: april fools email backfires References: <7xbq4sf9wv.fsf@ruckus.brouhaha.com> Message-ID: <51f66f4e-08c4-4a67-bcd7-f3c9e556d198@m73g2000hsh.googlegroups.com> On Apr 2, 1:29?pm, Grant Edwards wrote: > On 2008-04-02, Paul Rubin wrote: > > > Django, pah. ?They should switch to something REALLY advanced: > > >http://www.coboloncogs.org/INDEX.HTM > > ROTFLMAO! > > That's absolutely brilliant! ?I particularly like the flashing > effect that simulates an old screen-at-time mode terminal (or > maybe a storage-scope terminal?), and the faint "burn-in" text > in the background. And the "(c) " at the bottom left.. priceless! From kay.schluehr at gmx.net Fri Apr 25 12:05:20 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Fri, 25 Apr 2008 09:05:20 -0700 (PDT) Subject: Fun with relative imports and py3k Message-ID: Since their introduction in Python 2.5 I only reviewed the new "relative import" notation briefly by reading the "What's new in Python 2.5" article. Now I wanted checkout if I get comfortable with them. Opening the tutorial I found following notice ( 6.4.2 ): "Note that both explicit and implicit relative imports are based on the name of the current module. Since the name of the main module is always "__main__", modules intended for use as the main module of a Python application should always use absolute imports." The distinction between modules and scripts was new to me. One of the primary features I always appreciated in Python was that modules had a dual purpose: they were components and they were programs. One could use them in isolation or as a part of a package something I always missed when I programmed in languages with the tyranny of a single main. However 'implicit relative imports' work as usual and Py3K just changes the priority of search - one might simply ignore the 'explicit' variant and care for unambiguous names. Now things are not so easy in life and when you are confronted with other peoples software you have to know at least the rules of the game. Digging a little deeper I found the following section in "What's new in Python 2.6" 'Python?s -m switch allows running a module as a script. When you ran a module that was located inside a package, relative imports didn?t work correctly.' Hmm... they worked as specified or at least as documented. I admit I'm confused but I suspect I'm not the only one. Now everything is fine. You just run each and every module with the -m option "as a script" because there is a chance that somewhere is a relative import ( e.g. local to a function ) and suddenly the module fails to import stuff due to a modality in the import behavior. Let's see how it works in practice. This here my very first attempt to start Pythons 2to3 refactoring tool written by the master himself. I looked at it and he used relative imports. C:\Python30\Lib\lib2to3>C:\Python30\python -m refactor.py Traceback (most recent call last): File "C:\Python30\lib\runpy.py", line 103, in _run_module_as_main loader, code, fname = _get_module_details(mod_name) File "C:\Python30\lib\runpy.py", line 78, in _get_module_details loader = get_loader(mod_name) File "C:\Python30\lib\pkgutil.py", line 456, in get_loader return find_loader(fullname) File "C:\Python30\lib\pkgutil.py", line 466, in find_loader for importer in iter_importers(fullname): File "C:\Python30\lib\pkgutil.py", line 422, in iter_importers __import__(pkg) File "C:\Python30\lib\lib2to3\refactor.py", line 23, in from .pgen2 import driver ValueError: Attempted relative import in non-package Not working. I'm perfectly sure I don't understand the error message but what's worse is that runpy.py fails which was just created ( in Python 2.6 ) to fix the issue with the apparently broken relative imports that is o.k. according to the introductory material that is dedicated to newbies. I'm trying to fix this naively by turning the explicit into implicit relative (or absolute?) imports and see what happens. refactor.py ------------------------ ... # Local imports from pgen2 import driver from pgen2 import tokenize import pytree import patcomp import fixes import pygram .... C:\Python30\Lib\lib2to3>C:\Python30\python -m refactor.py Traceback (most recent call last): File "C:\Python30\lib\runpy.py", line 103, in _run_module_as_main loader, code, fname = _get_module_details(mod_name) File "C:\Python30\lib\runpy.py", line 78, in _get_module_details loader = get_loader(mod_name) File "C:\Python30\lib\pkgutil.py", line 456, in get_loader return find_loader(fullname) File "C:\Python30\lib\pkgutil.py", line 466, in find_loader for importer in iter_importers(fullname): File "C:\Python30\lib\pkgutil.py", line 422, in iter_importers __import__(pkg) File "refactor.py", line 27, in import patcomp File "C:\Python30\lib\lib2to3\patcomp.py", line 17, in from .pgen2 import driver ValueError: Attempted relative import in non-package This time patcomp fails with its relative imports despite the fact that it is not imported as a "script" but as a module inside the lib2to3 package and it is not __main__ but refactor.py is. I give up. I always thought migration from Python 2.X to Python 3.0 was an issue not the conversion tool ;) From linhanzu at gmail.com Thu Apr 10 22:21:51 2008 From: linhanzu at gmail.com (=?GB2312?B?ufnTwr78?=) Date: Fri, 11 Apr 2008 10:21:51 +0800 Subject: How to use my dynamic link libraries in python?? Message-ID: Hello: My OS is Linux, I compile my dynamic link libraries , and want to call the function of my dynamic library through python! How can I realize the function? Please give me some advices! Thanks From steve at holdenweb.com Sat Apr 5 11:05:12 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 11:05:12 -0400 Subject: ANN: pry unit testing framework In-Reply-To: <20080405141329.GD15684@nullcube.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com> <20080405141329.GD15684@nullcube.com> Message-ID: Aldo Cortesi wrote: > Thus spake Kay Schluehr (kay.schluehr at gmx.net): > >> Aldo, when you confuse inheritance ( using an OO framework properly ) >> with monkey patching no one can draw much different conclusions than I >> did. > > I guess you do always run the risk of being pelted with something from > the peanut gallery when you release something in public - maybe I'll > think twice about doing so next time. > > The only "confused" person here is you - I still say that it is NOT > possible to provide the functionality Pry does by extending unittest in > any sane way. Now, if you don't agree with this, please prove me wrong > through reasoned argument or shut up. Do NOT, however, accuse me of not > knowing what inheritance or monkeypatching is unless you want to look > stupid and make my killfile. > >> But raving against unittest.py and anti-hyping it for mostly trivial >> reasons and with shallow reasoning has become a fashion. Now we see >> alternatives that do little more than what can be achieved by adding >> two abstract methods to the TestSuite base class and overwrite a few >> methods of the TestLoader base class ( maybe I'm wrong about it but I >> guess the discussion has become too heated to clarify this point using >> technical arguments ). >> >> I just felt it was a good opportunity to debunk this unittest.py anti- >> hype. I'm sorry it has gone too personal. > > You can choose to use Pry or not, as you please. I would, however, ask > that you stop whining incessantly about how it's not compatible with > YOUR favourite framework, despite the fact that compatibility would > gain YOU very little and ME nothing at all. As I said in my response to > Michele, you lose the benefits of compatibility as soon as your tests > use any of the features an extension might add. To me, this means the > burden is not worth it. Since I designed and wrote Pry, I get to make > that choice, not you, and the type of feeble, offensive "argument" > you've provided is unlikely to change my mind. > Unpleasantly personal replies of this type are unwelcome here. Please restrict your arguments to technical ones or refrain from posting. Kay at least has a long history as a contributor in this group, so people know how to interpret her remarks and know that her contributions are made on the basis of a deep understanding of Python. She is far from belonging to the "peanut gallery", and to suggest otherwise betrays either ignorance, arrogance, or both. As a newcomer, however, your responses make you seem to be complaining that the world isn't grateful for your contributions, yet you don't seem to even consider the possibility that might be happening because you aren't explaining them well enough. To truculently suggest that reasoned responses make you less likely to contribute to open source in future suggests that you weren't ready to start in the first place. This group is a "broad church" that respects opinions of all kinds, and you will find that you are just as welcome as everyone else if you can confirm to accepted standard of behavior. Don't take things too personally (even when someone accuses you of "raving" - nobody said you are a bad person). regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From Dodin.Roman at gmail.com Fri Apr 25 04:44:03 2008 From: Dodin.Roman at gmail.com (hellt) Date: Fri, 25 Apr 2008 01:44:03 -0700 (PDT) Subject: Little novice program written in Python References: <0cecfed4-17e7-4e4d-9dbe-3f0ac8316c1f@y21g2000hsf.googlegroups.com> Message-ID: also, i would recommend you to visit projecteuler.net you can solve math tasks and then see how others have done the same. you can fetch very good and pythonic solution there. From maxm at mxm.dk Fri Apr 25 08:44:29 2008 From: maxm at mxm.dk (Max M) Date: Fri, 25 Apr 2008 14:44:29 +0200 Subject: Little novice program written in Python In-Reply-To: <2caefd7f-dd6b-40a0-877f-3f7df0e70138@8g2000hse.googlegroups.com> References: <2caefd7f-dd6b-40a0-877f-3f7df0e70138@8g2000hse.googlegroups.com> Message-ID: <4811D22D.30409@mxm.dk> hellt skrev: >> Most code is not like that so perhaps you should try something more >> "usual" like sending email, fetching webpages etc. to get a feel for the >> language. >> > em, i would say, that python (esp. with NumPy+Psyco) is very popular > in numerical processing also. I know, and I might be way of, but I would believe that even that would be more like stringing ready built modules together, calling methods etc. I have written far denser code that the above example in Python regularly. But It is like 1%-5% of my code I believe. Unlike the c family of languages where there is a lot more algorithms due to the low level coding. Memory handling, list, dicts etc. qickly becomes more like math algorithms than in Python. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science From jkugler at bigfoot.com Wed Apr 9 14:53:01 2008 From: jkugler at bigfoot.com (Joshua Kugler) Date: Wed, 09 Apr 2008 10:53:01 -0800 Subject: Can C.L.P.handle the load? References: <3b6737c8-9d42-4218-ac60-01df2f578746@p39g2000prm.googlegroups.com> <9bd25fd3-5133-4165-9784-fbbc21145810@24g2000hsh.googlegroups.com> Message-ID: Paddy wrote: > I'm waiting for the rush of new users to c.l.p :-) > If it comes, then aren't regularly posted FAQ's newbie friendly? No, it just means they didn't take the time to read the docs and the FAQ for themselves. :) > Is their a good FAQ already around that we can regularly point newbies > to? You mean this one: http://www.python.org/doc/faq/ j From rasmussen.bryan at gmail.com Thu Apr 24 14:08:50 2008 From: rasmussen.bryan at gmail.com (bryan rasmussen) Date: Thu, 24 Apr 2008 20:08:50 +0200 Subject: convert xhtml back to html In-Reply-To: References: Message-ID: <3bb44c6e0804241108g215ec5a4hb2d0f767fa215ac@mail.gmail.com> I'll second the recommendation to use xsl-t, set the output to html. The code for an XSL-T to do it would be basically: you would probably want to do other stuff than just copy it out but that's another case. Also, from my recollection the solution in CHM to make XHTML br elements behave correctly was
as opposed to
, at any rate I've done projects generating CHM and my output markup was well formed XML at all occasions. Cheers, Bryan Rasmussen On Thu, Apr 24, 2008 at 5:34 PM, Tim Arnold wrote: > hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop to > create CHM files. That application really hates xhtml, so I need to convert > self-ending tags (e.g.
) to plain html (e.g.
). > > Seems simple enough, but I'm having some trouble with it. regexps trip up > because I also have to take into account 'img', 'meta', 'link' tags, not > just the simple 'br' and 'hr' tags. Well, maybe there's a simple way to do > that with regexps, but my simpleminded )]+/> doesn't work. I'm not > enough of a regexp pro to figure out that lookahead stuff. > > I'm not sure where to start now; I looked at BeautifulSoup and > BeautifulStoneSoup, but I can't see how to modify the actual tag. > > thanks, > --Tim Arnold > > > -- > http://mail.python.org/mailman/listinfo/python-list > From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 24 07:46:51 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 24 Apr 2008 13:46:51 +0200 Subject: Python development tools In-Reply-To: <873apbqypn.fsf@physik.rwth-aachen.de> References: <09992de9-39fa-4ee6-8009-35732f3433fb@y21g2000hsf.googlegroups.com> <87fxtcnvj7.fsf@physik.rwth-aachen.de> <48106ba0$0$11087$426a34cc@news.free.fr> <873apbqypn.fsf@physik.rwth-aachen.de> Message-ID: <48107317$0$23390$426a74cc@news.free.fr> Torsten Bronger a ?crit : > Hall?chen! > > Bruno Desthuilliers writes: > >> [...] >> >>> and it ends multi-line strings at single quotes. >> it chokes on unbalanced single quotes in triple-single-quoted >> strings, and on unbalanced double-quotes in triple-double-quoted >> strings, yes. Given that I never use triple-single-quoted strings >> (and don't remember having seen such a thing in the thousands of >> third-part .py files I've read so far), I'd qualify this as at >> most a very minor annoyance. Not having proper python-shell and >> pdb integration is wwwwaaaayyyy more annoying IMHO. > > My formulation was unfortunate. What doesn't work (at least for me) > is something like > > """This is a docstring in which some "variables" are quoted.""" > > Here, "variables" doesn't seem to belong to the docstring for > python-mode. Nope, but it doesn't break anything neither. At this stage, this is a less than minor annoyance to me. From george.sakkis at gmail.com Tue Apr 29 00:29:40 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Mon, 28 Apr 2008 21:29:40 -0700 (PDT) Subject: descriptor & docstring References: Message-ID: On Apr 28, 10:59?pm, "Gabriel Genellina" > def property_default(prop_name, default_value=None, doc=None): > > ? ? ?attr_name = '_'+prop_name > > ? ? ?def fget(self, attr_name=attr_name, > ? ? ? ? ? ? ? ? ? ? default_value=default_value): > ? ? ? ? ?return getattr(self, attr_name, default_value) > > ? ? ?def fset(self, value, > ? ? ? ? ? ? ? ? ? ? attr_name=attr_name, > ? ? ? ? ? ? ? ? ? ? default_value=default_value): > ? ? ? ? ?if value == default_value: > ? ? ? ? ? ? ?delattr(self, attr_name) > ? ? ? ? ?else: > ? ? ? ? ? ? ?setattr(self, attr_name, value) > > ? ? ?return property(fget=fget, fset=fset, doc=doc) > > When setting the same value as the default, the instance attribute is ? > removed (so the default will be used when retrieving the value later). I ? > think this is what you intended to do. Note that this will fail if the value is already equal to the default and you try to reset it to the default, so it needs an extra hasattr(self, attr_name) before the delattr. Regardless, I would be surprised with the following behaviour: >>> r = Rectangle() >>> r.length = 4 >>> type(r.length) >>> r.length = 12 >>> type(r.length) Another simpler alternative would be to (ab)use a decorator: def defaultproperty(func): attr = '_' + func.__name__ default = func.func_defaults[0] return property( fget = lambda self: getattr(self, attr, default), fset = lambda self,value: setattr(self, attr, value), doc = func.__doc__) class Rectangle(object): '''A beautiful Rectangle''' @defaultproperty def length(default=12.0): '''This is the length property''' George From rschroev_nospam_ml at fastmail.fm Tue Apr 29 12:15:33 2008 From: rschroev_nospam_ml at fastmail.fm (Roel Schroeven) Date: Tue, 29 Apr 2008 18:15:33 +0200 Subject: Who makes up these rules, anyway? In-Reply-To: References: Message-ID: Cameron Laird schreef: > In article , > Gabriel Genellina wrote: > . > . > . >> Explicit variable declaration for functions: >> >> http://groups.google.com/group/comp.lang.python/browse_thread/thread/6c4a508edd2fbe04/ > . > . > . > A reader notes that this thread actually lived during 2004 (!) > (entirely during January 2004, in fact), and mildly questions > its pertinence to what bills itself as "weekly Python news ..." > > Well might the reader wonder. "Python-URL!" has long chosen > to err on the side of INclusiveness in its categorizations, > even to the occasional point of apparent frivolity. As Harlan > Ellison used to advise his readers, think of it as a bonus, > rather than a mistake. It's our tradition, too. I assumed it was a mix-up with the recent thread with the same name: http://groups.google.com/group/comp.lang.python/browse_thread/thread/f3832259c6da530 -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven From ankitks.mital at gmail.com Fri Apr 4 02:06:37 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Thu, 3 Apr 2008 23:06:37 -0700 (PDT) Subject: python bisect questions References: <6bb6927b-f553-40db-a142-2ce86b9e819f@q27g2000prf.googlegroups.com> Message-ID: <6280b454-2f0f-446d-b980-ff4fa6643799@b64g2000hsa.googlegroups.com> Thanks Gabriel From bronger at physik.rwth-aachen.de Tue Apr 8 02:03:13 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Tue, 08 Apr 2008 08:03:13 +0200 Subject: Translating keywords References: Message-ID: <873apwubmm.fsf@physik.rwth-aachen.de> Hall?chen! Gabriel Genellina writes: > [...] > > Python 3 allows for unicode identifiers, but I don'k know any > plans for using unicode keywords too. Looks funny: > > ? x ? values: > if x ? forbidden ? x ? y: > print(x, ?(x), ?(x)) > print(?(values)) > near = ? a,b,?=0.01: a-? ? b ? a+? As far as I've understood it, only letters are allowed in identifiers rather than arbitrary Unicode code points. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From uniontelecardsindia at gmail.com Tue Apr 22 17:14:10 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:14:10 -0700 (PDT) Subject: Lucky gay sucking cock while butt fucked deep Message-ID: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From n00m at narod.ru Sat Apr 26 16:54:29 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 13:54:29 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> Message-ID: hdante: I run your code quite a few times. Its time = 0.734s. Of mine = 0.703-0.718s. PS All I have is an ancient Mingw compiler (~1.9.5v) in Dev-C++. From s0suk3 at gmail.com Thu Apr 17 03:30:04 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 00:30:04 -0700 (PDT) Subject: regular expressions an text string References: <359c5f43-9520-4f33-b49e-45b5256f7169@a22g2000hsc.googlegroups.com> Message-ID: <96774d85-2a76-461b-89c6-f12a68908825@m36g2000hse.googlegroups.com> On Apr 17, 2:09 am, ragia wrote: > hi > i have to match text string char by char to a regular expressions tht > just allow digits 0-9 if other thing a ppear it shall be replaced with > space.how can i do that any help? > so far i have the string and can read it using a for loop...but how to > match each char with the regular expressions and save the result into > other string or replace it with space in that other string to have new > one.. > I a new in python ,thatnks in advance >>> import re # Python's library supporting regexps >>> >>> string = "abc123def456" >>> re.sub("\D", " ", string) ' 123 456' ~~Sosuke~~ From mrmakent at cox.net Wed Apr 16 11:14:24 2008 From: mrmakent at cox.net (Mike Kent) Date: Wed, 16 Apr 2008 08:14:24 -0700 (PDT) Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> Message-ID: <66efcc2e-d806-4cb1-966c-178b41b183ba@d1g2000hsg.googlegroups.com> On Apr 16, 10:26 am, Mike Driscoll wrote: > Yeah, I noticed that Google Groups has really sucked this week. I'm > using the Google Groups Killfile for Greasemonkey now and it helps a > lot. I like Google, but my loyalty only goes to far. This is a > complete lack of customer service. > > Mike Bless you. I just installed Greasemonkey and the Google Groups Killfile. Works like a charm. From paddy3118 at googlemail.com Wed Apr 9 01:44:10 2008 From: paddy3118 at googlemail.com (Paddy) Date: Tue, 8 Apr 2008 22:44:10 -0700 (PDT) Subject: pprint module and newer standard types Message-ID: Hi, When I try and use pprint on standard types I get varying 'quality of output'. Lists will wrap nicely to multiple lines as will dicts, but sets and defaultdicts give one long unreadable line. Is their a chance to get this changed so that more built-in types look pretty when printed with pprint? I just did a small trial on an early version of Python 3 and sets don't seem to obey pprint.pprints width argument, the same way that lists do: Python 3.0a1 (py3k:57844, Aug 31 2007, 16:54:27) [MSC v.1310 32 bit (Intel)] on win32 >>> from pprint import pprint as pp >>> pp(list(range(3)), width=4) [0, 1, 2] >>> pp(set(range(3)), width=4) {0, 1, 2} >>> - Paddy. From andre.roberge at gmail.com Thu Apr 17 18:53:36 2008 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Thu, 17 Apr 2008 15:53:36 -0700 (PDT) Subject: Request a short code review References: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> Message-ID: <4e632ff9-2ce9-4b2d-9f93-cfdab2452841@k37g2000hsf.googlegroups.com> On Apr 17, 7:11 pm, ja... at reggieband.com wrote: > > I am not necessarily looking to make the code shorter or more > > functional or anything in particular. However if you spot something > > to improve then I am happy to learn. > > To give an example of what I mean I have already altered the code: > > def output_random_lesson_of_type(self, type=None): > """Output a lesson of a specific type. > If no type is passed in then output any type.""" > output_lessons = self.lesson_data["lessons"] > if type: > filtered_lessons = filter(lambda x: x["type"] == type, > self.lesson_data["lessons"]) > if filtered_lessons: > output_lessons = filtered_lessons > else: > print "Unable to find lessons of type %s." % type > return self.output_random(output_lessons) > > Changes: > - Respected a column width of 80 > - Created the output_lessons variable, assigned it to a default. > This remove an else statement and reduced the call to > self.output_random to a single instance in the return statement > > Cheers, > James I prefer, especially for longer methods, to return as soon as possible (thereby indicating that the code below is irrelevant to a particular condition). Thus, I would replace output_lessons = filtered lessons by return self.output_random(filtered_lessons) Andr? From ridenour4159 at gmail.com Thu Apr 24 06:17:34 2008 From: ridenour4159 at gmail.com (ridenour4159 at gmail.com) Date: Thu, 24 Apr 2008 03:17:34 -0700 (PDT) Subject: orbital trader crack Message-ID: orbital trader crack http://cracks.12w.net F R E E C R A C K S From jr9445 at ATT.COM Wed Apr 23 09:50:00 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Wed, 23 Apr 2008 08:50:00 -0500 Subject: Python Success stories In-Reply-To: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: > -----Original Message----- > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > list-bounces+jr9445=att.com at python.org] On Behalf Of azrael > Sent: Tuesday, April 22, 2008 6:26 AM > To: python-list at python.org > Subject: Python Success stories > > Hy guys, > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. > > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" > > This hurts. Please give me informations about realy famous > aplications. IIRC, Python is used in games like Eve Online (SciFi MMO) and Vampire: Bloodlines (RPG.) Years later, a dedicated fan is still fixing/updating the Bloodlines python scripts that control the dialogue and scripted events. OTOH, I use Perl over Python when it comes to Windows COM scripts due to finding a typelib that Python just refused to load. *shrug* Perl, Python, and your friend are tools. Use them appropriately for the given situation. From http Mon Apr 7 14:33:34 2008 From: http (Paul Rubin) Date: 07 Apr 2008 11:33:34 -0700 Subject: Tips for load balancing multiple Python apps on dual/quad core processors? References: Message-ID: <7x63utfrb5.fsf@ruckus.brouhaha.com> "Malcolm Greene" writes: > Is there a cross-platform way to monitor CPU load? Cross-platform: not that I know of. Linux: /proc/loadav (load average), /proc/cpuinfo (to figure out number of cpu's). You want the load average and # of cpu's to be about equal, i.e. all cpu's should be kept busy but not overloaded. From primoz.skale.lists at gmail.com Thu Apr 3 16:31:55 2008 From: primoz.skale.lists at gmail.com (Primoz Skale) Date: Thu, 3 Apr 2008 22:31:55 +0200 Subject: function call - default value & collecting arguments References: <_LQIj.9776$HS3.482805@news.siol.net> Message-ID: "OKB (not okblacke)" wrote in message news:Xns9A74ACF8732AEOKB at 199.45.49.11... > Primoz Skale wrote: > >> OK, everything allright till so fair. But! :) Now define third >> function as: >> >> def f(*a): >> print a[0] >> >> In this case, function only prints first argument in the tuple: >> >>>>f(1,2,3) >> 1 >>>>f(3) >> 3 >>>>f() #no arguments passed >> Traceback (most recent call last): >> File "", line 1, in >> f() #no arguments passed >> File "", line 2, in f >> print a[0] >> IndexError: tuple index out of range >> >> Then I tried to define the function as: >> >> def f(*a=(0,)): >> print a[0] #this should come next, but we get error msg instead, >> saying >> >> SyntaxError: invalid syntax >> >> but it does not work this way. Now my 'newbie' question: Why not? >> :) I wanted to write function in this way, because then we can call >> function without any arguments, and it would still print 0 (in this >> case). >> >> What I wanted was something like this: >> >> def f(*a=(0,)): >> print a[0] >> >>>>f(1,2) >> 1 >>>>f() #no args passed 0 > > When you use the *a syntax, you're saying that you want a to > contain a tuple of all the arguments. When you try *a=(0,), you seem to > be saying that you want a to hold all the arguments, or, if there are > none, you want to pretend that it was called with one argument, namely > 0. > > Well, if you want to ensure that there is at least one argument, > and print that first one, and make it zero if it's not supplied, why are > you using the *a syntax? You're clearly treating that first argument > distinctly, since you want to apply a default value to it but not to any > others. Just do this: > > def f(a, *b): > print a Thanks! I never thought of that.... :) P. > > -- > --OKB (not okblacke) > Brendan Barnwell > "Do not follow where the path may lead. Go, instead, where there is > no path, and leave a trail." > --author unknown From stanc at al.com.au Tue Apr 29 03:48:01 2008 From: stanc at al.com.au (Astan Chee) Date: Tue, 29 Apr 2008 17:48:01 +1000 Subject: simple chemistry in python Message-ID: <4816D2B1.2010404@al.com.au> Hi, Im looking for a python module to do simple chemistry things. Things like, finding the name of elements given the atomic number (and vice versa); what state the given matter is in depending on certain parameters; maybe even color of certain elements or even calculating the result of combining certain elements. I was looking for something simple, but everything I see seems to be a full blown chemistry set. I know I can probably spend a day doing this one element at a time, but I was wondering if there is already something like this done in a small scale? Thanks for any information Astan -- "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." Animal Logic http://www.animallogic.com Please think of the environment before printing this email. This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. From steve at holdenweb.com Sun Apr 20 10:13:46 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 20 Apr 2008 10:13:46 -0400 Subject: Any reliable obfurscator for Python 2.5 In-Reply-To: <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> Message-ID: Banibrata Dutta wrote: > > > On 4/20/08, *Gabriel Genellina* > wrote: > > En Sun, 20 Apr 2008 01:55:51 -0300, Banibrata Dutta > > escribi?: > > > Wanted to check if there is any known, reliable, FOSS/Libre -- > Obfurscator > > for Python 2.5 code. > > Why do you want to do that in the first place? > > > I need to do to retain the confidentiality for certain core components, > which are not supposed to be open. While I do have the option of > implementing them in C/C++, I'm trying to see if I can avoid that for 2 > reasons -- > 1. Its a fairly large and complex set of components, and doing it in > C/C++ 'might' take significantly longer. > 2. I'd try to avoid having mix of languages if possible. It makes the > developement easier to maintain/manage over a period of time. > > There is very few you can do to obfuscate Python code. You can't > rename classes nor methods nor global variables nor argument names > due to the dynamic nature of Python. All you can safely do is to > remove comments and join simple statements using ; > > > I do not understand the nuances of dynamic languages completely, so this > might be a foolish assumption, but if i make a complete, self-contained > Python application (collection of modules), then just before shipping a > production copy, why can't I replace 'all' symbols i.e. classes, > methods, variables etc ? Esply if I'm compiling the source ? > > If you remove docstrings, some things may break. Even renaming local > variables isn't safe in all cases. > > > Hmmm... but I'm aware of atleast 2 Obfuscators one commercial and one > FOSS, that seem to exist for Python. The commercial one is what I might > try if I don't find anything FOSS. The FOSS one seems to be a dead > project. If they are (or have been) there, I guess obfuscation is a > doable thing, no ? > The Python world isn't particularly paranoid about obfuscation. It's quite easy to publish compiled code only (.pyc and/or .pyo files), and that offers enough protection for most. The sad fact is that there seems to be an almost direct inverse correlation between the worth of the code and the authors' desire to protect it from piracy. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From eddieatter at gmail.com Tue Apr 15 19:37:40 2008 From: eddieatter at gmail.com (agent E 10) Date: Tue, 15 Apr 2008 16:37:40 -0700 (PDT) Subject: Brand New! References: <7f1828bf-ebe7-4111-bc59-70d125facb0a@d26g2000prg.googlegroups.com> Message-ID: On Apr 14, 8:37?pm, Benjamin wrote: > On Apr 14, 9:00 pm, agent E 10 wrote:> ? ?Hi, I'm brand new to programming. Have any suggestions? I'm young. > > Was it a good idea to start with python? I was planning on creating a > > very simple program that asked yes/no questions for a school project. > > IMHO, Python is an excellent language to start with. Have you read the > tutorial?http://docs.python.org/tut/tut.html > > > > > -Thanks!- Hide quoted text - > > - Show quoted text - No, I haven't. I have been reading off of this site http://www.freenetpages.co.uk/hp/alan.gauld/ is this a good site to learn off of? About how long will it take me to learn the basics of the language? -Thanks 4 all ur help! Agent E 10 From sturlamolden at yahoo.no Sat Apr 12 13:05:19 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sat, 12 Apr 2008 10:05:19 -0700 (PDT) Subject: Multiple independent Python interpreters in a C/C++ program? References: Message-ID: <624b9d79-bc02-4f52-bc97-52019bf916d0@n1g2000prb.googlegroups.com> On Apr 11, 6:24 pm, s... at pobox.com wrote: > Do I wind up with two completely independent interpreters, one per thread? > I'm thinking this doesn't work (there are bits which aren't thread-safe and > are only protected by the GIL), but wanted to double-check to be sure. You can create a new subinterpreter with a call to Py_NewInterpreter. You get a nwe interpreter, but not an independent one. The GIL is a global object for the process. If you have more than one interpreter in the process, they share the same GIL. In tcl, each thread has its own interpreter instance and no GIL is shared. This circumvents most of the problems with a global GIL. In theory, a GIL private to each (sub)interpreter would make Python more scalable. The current GIL behaves like the BKL in earlier Linux kernels. However, some third-party software, notably Apache's mod_python, is claimed to depend on this behaviour. From wizzardx at gmail.com Sun Apr 20 08:11:22 2008 From: wizzardx at gmail.com (David) Date: Sun, 20 Apr 2008 14:11:22 +0200 Subject: Any reliable obfurscator for Python 2.5 In-Reply-To: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> Message-ID: <18c1e6480804200511k202ff618i9941b244d0b77853@mail.gmail.com> On Sun, Apr 20, 2008 at 6:55 AM, Banibrata Dutta wrote: > Hi, > > Wanted to check if there is any known, reliable, FOSS/Libre -- Obfurscator > for Python 2.5 code. > What might work is to put all your code in python modules, generate .pyc, and then only distribute those. But you have to be careful that eg: target python interpreter version is the same that you compiled with and so on. From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Sun Apr 27 17:42:44 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Sun, 27 Apr 2008 23:42:44 +0200 Subject: print some text References: <7ac7b11d-6c9b-477c-8c0d-b038bc760918@c58g2000hsc.googlegroups.com> <1b0b588a-be43-49d6-be0f-231217b074dd@k13g2000hse.googlegroups.com> Message-ID: <67kaakF2nqkb9U2@mid.individual.net> barronmo wrote: > I haven't found a way from within python to print f. I'm sure > there it is something simple but I've been searching for a couple > weeks now with no luck. Tried some searching? http://wiki.wxpython.org/Printing HTH&Regards, Bj?rn -- BOFH excuse #374: It's the InterNIC's fault. From pylists at arcor.de Sun Apr 13 08:05:22 2008 From: pylists at arcor.de (Penny Y.) Date: Sun, 13 Apr 2008 20:05:22 +0800 Subject: =?UTF-8?B?5pyJ5Lit5Zu95Lq65LmOPw==?= In-Reply-To: References: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> Message-ID: <4801F702.5050401@arcor.de> Steve Holden ??: > ????????, ????????? > What do you mean? If I understand you correctly, maybe it should be, ??python??????,??????. Am I right? From bblais at bryant.edu Sun Apr 6 18:20:31 2008 From: bblais at bryant.edu (Brian Blais) Date: Sun, 6 Apr 2008 18:20:31 -0400 Subject: read large zip file Message-ID: Hello, I need to read a series of large zipfiles (which only contain one large text file), and I noticed that the zipfile module: 1) has a read method which isn't an iterator, and returns the entire file selected all at once 2) has no readlines method, and no obvious way to implement one Is there a way to stream an unzip, so it behaves more like a file? thanks, Brian Blais -- Brian Blais bblais at bryant.edu http://web.bryant.edu/~bblais -------------- next part -------------- An HTML attachment was scrubbed... URL: From phil at freehackers.org Tue Apr 1 09:03:13 2008 From: phil at freehackers.org (BlueBird) Date: Tue, 1 Apr 2008 06:03:13 -0700 (PDT) Subject: python scripts to standalone executable References: <34dce829-9eca-4e13-a9c5-eeb9f6b913be@e6g2000prf.googlegroups.com> Message-ID: <8a291754-83c8-4d8e-b3d9-e04b5249b1db@2g2000hsn.googlegroups.com> On Mar 31, 7:24 pm, Amit Gupta wrote: > Hi > > I am looking for a some tool that can convert python scripts to > executable on Linux. > > I found freeeze.py as the only option so far. Couple of queries on > freeze: > > 1. Have anyone used the freeze utility and any experiences to share > from that? > 2. Is there any enterprise-level exe-builder for python on linux > (ActiveState has nothing)? > > Any other related commets are also welcome. > > Thanks > Amit I've run into the same question and decided to keep a web page memo about it: http://www.freehackers.org/Packaging_a_python_program I'll be happy to update it with feedback. Philippe From cokofreedom at gmail.com Tue Apr 8 10:53:13 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Tue, 8 Apr 2008 07:53:13 -0700 (PDT) Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> Message-ID: > > I have a car. I have turned the ignition key but it fails to start. > Please tell me what is wrong with it. > The engine is missing! Am I close? From danb_83 at yahoo.com Mon Apr 21 22:19:42 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Mon, 21 Apr 2008 19:19:42 -0700 (PDT) Subject: Java or C++? References: Message-ID: On Apr 21, 5:26 pm, Jorgen Grahn wrote: > On Mon, 21 Apr 2008 06:14:08 -0700 (PDT), NickC wrote: > > On Apr 15, 1:46 pm, Brian Vanderburg II > > wrote: > >> This will automatically call the constructors of any contained objects > >> to initialize the string. The implicit assignment operator > >> automatically performs the assignment of any contained objects. > >> Destruction is also automatic. When 'p1' goes out of scope, during the > >> destructor the destructor for all contained objects is called. > > > Yeah, C++ does try to be helpful, and all of those automatic copy > > constructor, assignment operator and destructor implementations screw > > up royally when confronted with pointers > > I think that those are newbie problems. The rules for those three > "default implementations" are simple and match what C does for > structs. Use the standard containers, make a habit of forbidding > copying of objects which make no sense copying, and remember the > "explicit" keyword, and you will rarely have problems with this. Yes, but why should you have to remember? Wouldn't it be less error- prone to make objects uncopyable and constructors explicit unless stated otherwise? (Yes, default implementations for structs had to match C, but "class" was a new keyword.) > > Other things like methods (including destructors!) being non-virtual > > by default also make C++ code annoyingly easy to get wrong (without it > > obviously looking wrong). > > The other side of the coin is that you can write tiny classes in C++ > with *no overhead*. If my class Foo can be implemented as an integer, > it doesn't need to be slower or take more space than an integer. It > can have value semantics, live on the stack etc, like an integer. > > I assume Java programmers avoid such types, and I assume it decreases > type safety in their programs. I haven't written in Java since version 1.3, so maybe things have changed. But last time I checked, if you want tiny value-semantics types in Java, you're stuck with the built-in ones. One of my biggest gripes about that language. From steve at holdenweb.com Mon Apr 14 14:08:16 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 14 Apr 2008 14:08:16 -0400 Subject: py2exe, program has stoped working!? In-Reply-To: References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> <232151d6-09ed-4a1e-9922-d66c2bf0d05b@w8g2000prd.googlegroups.com> Message-ID: <48039D90.8040205@holdenweb.com> John Machin wrote: > On Apr 14, 7:24 pm, skanem... at yahoo.se wrote: >>> Is it a console program or a gui program? >> GUI >>> What happens when you run it without py2exe? >> it works perfectly, both from within python and launching from >> "windows" >> >>> Have you searched for "has stopped working" in >> (a) your source code >> yes no such message there> (b) the py2exe source code? >> >> no, will do but doubt thats the problem >> >>> Have you managed to get any py2exe-created program to run properly? >> no > > Well, perhaps you might like to look in the samples directory of the > py2exe distribution and choose a simple example and try that. > > By the way, "popup" is what you get in a web browser. What did this > "popup" look like: a panel from your GUI software? A Windows message > box? Did it have a title across the top? What was the exact text in > the popup/panel/box? Were there any options other than to close the > window? > > Which version of Python? Which Windows, what service pack? What GUI, > what version? Care to divulge the contents of your setup.py? Apart > from your GUI, what 3rd party packages/modules are you importing? FYI "xxx has stopped working" is Vista's "user-friendly" way of reporting what Windows 3 would probably have called a "General Program Fault". It pretty much hides all useful information fro the end-user, perhaps on the grounds that end users wouldn't know what to do with the information it *could* provide anyway. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From john_bailey at rochester.rr.com Mon Apr 14 14:24:45 2008 From: john_bailey at rochester.rr.com (John Bailey) Date: Mon, 14 Apr 2008 14:24:45 -0400 Subject: Game design : Making computer play References: Message-ID: On Mon, 14 Apr 2008 00:13:56 -0700 (PDT), v4vijayakumar wrote: >In computer based, two player, board games, how to make computer play? >Are there any formal ways to _teach_ computer, to choose best possible >move? > >I know this is kind of off-topic here. Please redirect me, if there >are more appropriate newsgroup. > >Many thanks. Sargon: A Computer Chess Program (Paperback) by Dan Spracklen (Author), Kathe Spracklen (Author) Search Amazon with that title. Its available for under $20. The Spracklen's book provides a concrete structure and model for a computer program which attempts to look ahead, evaluating alternative moves. Unlike AI texts which obfuscate through abstraction, theirs is quite clear even if you don't know Z80 assembly language. By reading their book (studying it might be a better phrase) I came to understand the complexity and immensity of the task. Good luck. John From stevegill7 at gmail.com Sat Apr 5 11:50:30 2008 From: stevegill7 at gmail.com (Jetus) Date: Sat, 5 Apr 2008 08:50:30 -0700 (PDT) Subject: Learning curve for new database program with Python? Message-ID: I have a need for a database program. I downloaded the db2 from ibm, and reviewed some of the documentation. My question is, what is the easiest program for me to try to learn. I will be creating a database of about 25,000 records, it will be relational. I am a beginner Python programmer, and need a database solution that is easy to grasp. I played with sql, and found that very difficult, if not overly cumbersome. A database that could work with Django would be very interesting to look at as well.. Any suggestions out there? From steve at holdenweb.com Sun Apr 20 17:26:09 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 20 Apr 2008 17:26:09 -0400 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <480B94D1.6050907@gmail.com> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B52DE.8070105@holdenweb.com> <480B94D1.6050907@gmail.com> Message-ID: <480BB4F1.9080102@holdenweb.com> Hank @ITGroup wrote: > Steve Holden wrote: >> You are suffering from a pathological condition yourself: the desire >> to optimize performance in an area where you do not have any problems. >> I would suggest you just enjoy using Python and then start to ask >> these questions again when you have a real issue that's stopping you >> from getting real work done. >> >> regards >> Steve >> > Hi, Steve, > This not simply a pathological condition. My people are keeping trying > many ways to have job done, and the memory problem became the focus we > are paying attention on at this moment. > Could you please give us some clear clues to obviously call python to > free memory. We want to control its gc operation handily as we were > using J**A. Well, now you've told us a little more about your application I can understand that you need to be careful with memory allocation. The best thing you can do is to ensure that your program is reasonably decomposed into functions. That way the local namespaces have limited lifetimes, and only the values that they return are injected into the environment. You also need to be careful in exception processing that you do not cause a reference to the stack frame to be retained, as that can be a fruitful source of references to objects, rendering them non-collectable. You appear to be stressing the limits of a single program under present-day memory constraints. I am afraid that no matter how carefully you manage object references, any difference you can make is likely to be lost in the noise as far as memory utilization is concerned, and you may have to consider using less direct methods of processing your data sets. The gc module does give you some control over the garbage collector, but generally speaking most programs don't even need that much control. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bj_666 at gmx.net Sat Apr 26 12:02:43 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 26 Apr 2008 16:02:43 GMT Subject: Setting an attribute without calling __setattr__() References: Message-ID: <67h213F2nvf5vU1@mid.uni-berlin.de> On Sat, 26 Apr 2008 08:28:38 -0700, animalMutha wrote: >> Consider reading the *second* paragraph about __setattr__ in section >> 3.4.2 of the Python Reference Manual. > > if you are simply going to answer rtfm - might as well kept it to > yourself. Yes, but if you are telling where exactly to find the wanted information in the documentation, like John did, you are teaching the OP how to fish. Which is a good thing. Much more helpful than your remark anyway. You might as well have kept it to yourself. :-? Ciao, Marc 'BlackJack' Rintsch From wizzardx at gmail.com Sun Apr 20 03:09:52 2008 From: wizzardx at gmail.com (David) Date: Sun, 20 Apr 2008 09:09:52 +0200 Subject: Checking if a text file is blank In-Reply-To: <480ae855$0$15157$607ed4bc@cv.net> References: <480ae855$0$15157$607ed4bc@cv.net> Message-ID: <18c1e6480804200009p6ad00c59n333bc15e332d6294@mail.gmail.com> > > import os > print os.lstat("friends.txt")[6] > I prefer os.lstat("friends.txt").st_size From hopeorpha308 at gmail.com Sun Apr 27 07:48:01 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:48:01 -0700 (PDT) Subject: spynomore crack Message-ID: <92c7e766-c73f-4fb8-8c77-6b7a08844d74@m3g2000hsc.googlegroups.com> spynomore crack http://wga-cracks.crackkey.net From jfgomez21 at gmail.com Thu Apr 10 13:26:45 2008 From: jfgomez21 at gmail.com (Jose) Date: Thu, 10 Apr 2008 10:26:45 -0700 (PDT) Subject: Module Conflicts References: <1592fad3-996b-4f62-ac12-42aff8272c21@8g2000hsu.googlegroups.com> <845e315c-0159-4390-954a-dc93fd1b27a1@x41g2000hsb.googlegroups.com> Message-ID: On Apr 9, 10:36 pm, Benjamin wrote: > On Apr 9, 5:33 pm, Jose wrote: > > > I have a module named math.py in a package with some class > > definitions. I am trying to import the standard python math module > > inside of math.py but It seems to be importing itself. Is there any > > way around this problem without renaming my math.py file? > > Not without some unpythonic magic. It's really not good style to name > a module the same as a stdlib one. It'll also confuse people reading > your code. Yeah but I thought since math.py was in a package, it would be okay. It's no big deal. I'll just rename my module :( From nick at craig-wood.com Tue Apr 1 13:30:05 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Tue, 01 Apr 2008 12:30:05 -0500 Subject: bsddb3 thread problem References: Message-ID: anuraguniyal at yahoo.com wrote: > In my application I am trying to access(read) a DB thru a thread while > my main thread is adding data to it and it gives following error(s) [snip] > Do anybody has a clue what I am doing wrong here? Using threads with bsddb3. I spent weeks trying to get it to behave when threading. I gave up in the end and changed to sqlite :-( At least if you make a mistake with sqlite and use the wrong handle in the wrong place when threading it gives you a very clear error. -- Nick Craig-Wood -- http://www.craig-wood.com/nick From colas.francis at gmail.com Thu Apr 17 09:20:31 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Thu, 17 Apr 2008 06:20:31 -0700 (PDT) Subject: Python and stale file handles References: Message-ID: On 17 avr, 14:43, bock... at virgilio.it wrote: > On 17 Apr, 04:22, tgiles wrote: > > > > > Hi, All! > > > I started back programming Python again after a hiatus of several > > years and run into a sticky problem that I can't seem to fix, > > regardless of how hard I try- it it starts with tailing a log file. > > > Basically, I'm trying to tail a log file and send the contents > > elsewhere in the script (here, I call it processor()). My first > > iteration below works perfectly fine- as long as the log file itself > > (logfile.log) keeps getting written to. > > > I have a shell script constantly writes to the logfile.log... If I > > happen to kill it off and restart it (overwriting the log file with > > more entries) then the python script will stop sending anything at all > > out. > > > import time, os > > > def processor(message,address): > > #do something clever here > > > #Set the filename and open the file > > filename = 'logfile.log' > > file = open(filename,'r') > > > #Find the size of the file and move to the end > > st_results = os.stat(filename) > > st_size = st_results[6] > > file.seek(st_size) > > > while 1: > > where = file.tell() > > line = file.readline() > > if not line: > > time.sleep(1) > > file.seek(where) > > else: > > print line, # already has newline > > data = line > > if not data: > > break > > else: > > processor(data,addr) > > print "Sending message '",data,"'....." > > > someotherstuffhere() > > > === > > > This is perfectly normal behavior since the same thing happens when I > > do a tail -f on the log file. However, I was hoping to build in a bit > > of cleverness in the python script- that it would note that there was > > a change in the log file and could compensate for it. > > > So, I wrote up a new script that opens the file to begin with, > > attempts to do a quick file measurement of the file (to see if it's > > suddenly stuck) and then reopen the log file if there's something > > dodgy going on. > > > However, it's not quite working the way that I really intended it to. > > It will either start reading the file from the beginning (instead of > > tailing from the end) or just sit there confuzzled until I kill it > > off. > > > === > > > import time, os > > > filename = logfile.log > > > def processor(message): > > # do something clever here > > > def checkfile(filename): > > file = open(filename,'r') > > print "checking file, first pass" > > pass1 = os.stat(filename) > > pass1_size = pass1[6] > > > time.sleep(5) > > > print "file check, 2nd pass" > > pass2 = os.stat(filename) > > pass2_size = pass2[6] > > if pass1_size == pass2_size: > > print "reopening file" > > file.close() > > file = open(filename,'r') > > else: > > print "file is OK" > > pass > > > while 1: > > checkfile(filename) > > where = file.tell() > > line = file.readline() > > print "reading file", where > > if not line: > > print "sleeping here" > > time.sleep(5) > > print "seeking file here" > > file.seek(where) > > else: > > # print line, # already has newline > > data = line > > print "readying line" > > if not data: > > print "no data, breaking here" > > break > > else: > > print "sending line" > > processor(data) > > > So, have any thoughts on how to keep a Python script from bugging out > > after a tailed file has been refreshed? I'd love to hear any thoughts > > you my have on the matter, even if it's of the 'that's the way things > > work' variety. > > > Cheers, and thanks in advance for any ideas on how to get around the > > issue. > > > tom > > Possibly, restarting the program that writes the log file creates a > new file rather than > appending to the old one?? It seems at least the op should definitely reopen the file: # create a file In [322]: f1 = open("test.txt", 'w') In [323]: f1.write("test\n") In [324]: f1.close() # check content of file In [325]: f_test1 = open("test.txt") In [326]: f_test1.readline() Out[326]: 'test\n' # check twice, we never know In [327]: f_test1.seek(0) In [328]: f_test1.readline() Out[328]: 'test\n' # rewrite over the same file In [329]: f1 = open("test.txt", 'w') In [330]: f1.write("new test\n") In [331]: f1.close() # check if ok In [332]: f_test2 = open("test.txt") In [333]: f_test2.readline() Out[333]: 'new test\n' # first file object has not seen the change In [334]: f_test1.seek(0) In [335]: f_test1.readline() Out[335]: 'test\n' From Gerry.Paneda at palm.com Wed Apr 16 17:08:29 2008 From: Gerry.Paneda at palm.com (Gerry Paneda) Date: Wed, 16 Apr 2008 14:08:29 -0700 Subject: Open source Web testing tool - cPAMIE 1.6b released Message-ID: <596402ECCC54DA40BAEE00F60CE8F93512CBD88B82@ushqwmb03.palm1.palmone.com> Hi Rob, I have been watching your videos in ShowMeDo and first of all thanks - I just started looking at Automation again and this got me started fairly easy. I do have a question though. 2.0 does not seem to have getConfig and writeScript from the one I downloaded from sourceforge. I went to the user group and applied as member but I haven't been approved yet so I can't download the file you mentioned on the thread in showmedo. Can you help me out? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From ptmcg at austin.rr.com Tue Apr 8 01:41:41 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Mon, 7 Apr 2008 22:41:41 -0700 (PDT) Subject: Welcome to the "Python-list" mailing list References: Message-ID: On Apr 7, 9:54?am, Steve Holden wrote: > Ronn Ross wrote: > > This is my first post and I'm new to Python. How would someone go about > > adding keywords to Python? It would be great to add support for > > Esperanto keywords in the language instead of English being the only > > option. > > Unfortunately the resulting language would no longer be Python. > > You need to consider software portability: Python has been very > conservative about declaring words to be "keywords" in the language, > though clearly words like "def" and "class" must necessarily be part of > the syntax. > > When you start to replace the keywords, though, your programs are no > longer runnable on all Python installations, and simple transliteration > fails because sometimes a keyword in one (natural) language will > conflict with a programmer's choice of name(s) in another. > > So it's a superficially attractive idea with some really bad downside > consequences. > > regards > ? Steve > -- > Steve Holden ? ? ? ?+1 571 484 6266 ? +1 800 494 3119 > Holden Web LLC ? ? ? ? ? ? ?http://www.holdenweb.com/ Zhpy is a Chinese-to-English keyword and variable converter. http://pypi.python.org/pypi/zhpy/1.5.2 Perhaps this could give you some ideas. -- Paul From bvidinli at gmail.com Sat Apr 26 15:16:50 2008 From: bvidinli at gmail.com (bvidinli) Date: Sat, 26 Apr 2008 22:16:50 +0300 Subject: Apologize: annoying dictionary problem, non-existing keys Message-ID: <36e8a7020804261216k41e749c4sdad93cc6c008b435@mail.gmail.com> Thank you all for your answers. i get many usefull answers and someone remembered me of avoiding cross-posting. i apologize from all of you, for cross posting and disturbing. that day was not a good day for me... it is my fault.. sory.... and have nice days... 26 Nisan 2008 Cumartesi 02:52 tarihinde Collin Winter yazd?: > 2008/4/24 bvidinli : > > I posted to so many lists because, > > > > this issue is related to all lists, > > this is an idea for python, > > this is related to development of python... > > > > why are you so much defensive ? > > > > i think ideas all important for development of python, software.... > > i am sory anyway.... hope will be helpful. > > Please consult the documentation first: > http://docs.python.org/lib/typesmapping.html . You're looking for the > get() method. > > This attribute of PHP is hardly considered a feature, and is not > something Python wishes to emulate. > > Collin Winter > > > 2008/4/24, Terry Reedy : > > > > > > > Python-dev is for discussion of development of future Python. Use > > > python-list / comp.lang.python / gmane.comp.python.general for usage > > > questions. > > > > > > > > > > > > _______________________________________________ > > > Python-Dev mailing list > > > Python-Dev at python.org > > > http://mail.python.org/mailman/listinfo/python-dev > > > Unsubscribe: http://mail.python.org/mailman/options/python-dev/bvidinli%40gmail.com > > > > > > > > > > > -- > > ?.Bahattin Vidinli > > Elk-Elektronik M?h. > > ------------------- > > iletisim bilgileri (Tercih sirasina gore): > > skype: bvidinli (sesli gorusme icin, www.skype.com) > > msn: bvidinli at iyibirisi.com > > yahoo: bvidinli > > > > +90.532.7990607 > > +90.505.5667711 > > _______________________________________________ > > > > > > Python-Dev mailing list > > Python-Dev at python.org > > http://mail.python.org/mailman/listinfo/python-dev > > Unsubscribe: http://mail.python.org/mailman/options/python-dev/collinw%40gmail.com > > > -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From jasper at peak.org Thu Apr 24 19:40:52 2008 From: jasper at peak.org (Jasper) Date: Thu, 24 Apr 2008 16:40:52 -0700 (PDT) Subject: How to find the parent of an old-style class? References: <9742ba66-eebf-43ba-8391-d0d0edb52c95@l42g2000hsc.googlegroups.com> <805bf888-722e-44a7-9c6a-66f9a28278af@b64g2000hsa.googlegroups.com> Message-ID: On Apr 24, 10:02 am, Jonathan Gardner wrote: > On Apr 24, 7:16 am, Jasper wrote: > > > I'm stuck using a library based on old style classes, and need to find > > a class's parent at runtime. > > > With new style classes you can use .__base__ to inspect a parent, but > > I can't remember how this was done in days of yore, before object. > > I've tried googling, but apparently my search term Fu is weak. :-( > > > Can anyone help me out here? There must be something simple. > > It's very odd that you need to know a class's parent. I'm interested > in hearing why you need this. In all my years, I've never had to do > this. > > Regardless, I believe you are looking for __bases__. *smack* That's what I get for programming too late into the morning; can't believe I missed that. Thanks for sorting me out! -Jasper PS I'm using a hierarchy of (never instantiated) classes as resource types in an economic sim, e.g. Resource, Luxury( Resource ), Gold( Luxury ). Prices are dicts of {resource:amount}, where resource can be something concrete like Gold, or a general group like Luxury (which could be paid with Gold, but also Ivory, etc). Payments are in dicts of {concrete-resource:amount}, and to verify correct payment I iterate through them, matching concrete resources (via their parent) to general price requirements like Luxury or Resource. I could avoid referencing __bases__ by instead iterating through price and checking issubclass(), but the logic is more complex. And yes, I know this is a bit of an unorthodox use of classes. ;-) From pylists at arcor.de Thu Apr 17 05:54:32 2008 From: pylists at arcor.de (Penny Y.) Date: Thu, 17 Apr 2008 17:54:32 +0800 Subject: about a head line Message-ID: <20080417095445.1750B23D1E1@mail-in-13.arcor-online.net> I saw some scripts have a line at its begin: # encoding:gb2312 what's this? Why need it? thanks. From bj_666 at gmx.net Wed Apr 30 07:39:07 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 30 Apr 2008 11:39:07 GMT Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> <87tzhjy4u2.fsf@physik.rwth-aachen.de> Message-ID: <67r42rF2ptbf1U1@mid.uni-berlin.de> On Wed, 30 Apr 2008 13:12:05 +0200, Torsten Bronger wrote: > However, join() is really bizarre. The list rather than the > separator should be the leading actor. You mean any iterable should be the leading actor, bacause `str.join()` works with any iterable. And that's why it is implemented *once* on string and unicode objects. Okay that's twice. :-) Ciao, Marc 'BlackJack' Rintsch From wwzaygvm at gmail.com Wed Apr 16 17:05:11 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 14:05:11 -0700 (PDT) Subject: originlab crack serial Message-ID: <3ded58e4-2e19-4da5-a9d0-1fd741e25610@a70g2000hsh.googlegroups.com> originlab crack serial http://cracks.12w.net F R E E C R A C K S From carlwuhwdmckay at gmail.com Mon Apr 21 02:08:24 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:08:24 -0700 (PDT) Subject: cracked engine block Message-ID: cracked engine block http://cracks.00bp.com F R E E C R A C K S From barbaros at ptmat.fc.ul.pt Thu Apr 24 09:45:22 2008 From: barbaros at ptmat.fc.ul.pt (barbaros) Date: Thu, 24 Apr 2008 06:45:22 -0700 (PDT) Subject: help needed with classes/inheritance References: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> <480f05d0$0$25755$426a74cc@news.free.fr> <676bac37-2816-402b-9aed-1a9c1873351b@a23g2000hsc.googlegroups.com> <48106eb5$0$21323$426a74cc@news.free.fr> Message-ID: <7a7382b6-8e5a-469d-b1ef-b853e876ec36@s50g2000hsb.googlegroups.com> Thanks to Paul McGuire and Bruno Desthuilliers for their comprehensive answers. This is exactly what I was looking for, except I did not know the correct name (composition/delegation). Now all I have to do is to study the supplied code, understand it and adapt it to my problem. Thank you very much. Cristian Barbarosie http://cmaf.ptmat.fc.ul.pt/~barbaros From skanemupp at yahoo.se Sat Apr 19 16:40:27 2008 From: skanemupp at yahoo.se (globalrev) Date: Sat, 19 Apr 2008 13:40:27 -0700 (PDT) Subject: Tkinter, getting canvas-object, how? References: <4d5c6911-7728-4dad-8d8d-7a862bf78d70@k13g2000hse.googlegroups.com> <4814820b-a3d2-44c1-9db4-0069463f079f@a23g2000hsc.googlegroups.com> <91ec0a69-767c-406b-8a41-44f8989e8eba@e39g2000hsf.googlegroups.com> Message-ID: On 19 Apr, 21:43, globalrev wrote: > On 19 Apr, 10:15, Rafa? Wysocki wrote: > > > > > skanem... at yahoo.se napisa?(a): > > > > so i load a gif onto a canvas and when i click the canvs i want to get > > > the color of the pixel that is clicked. > > > so i need to ge the object im clicking. > > > i was told in another thread to use find_withtag or find_closest but > > > it is not working, maybe im using the > > > method on the wrong object. > > > how do i do this? > > > and how do i then get specifics about that object, ie the pixel-color? > > > > Exception in Tkinter callback > > > Traceback (most recent call last): > > > File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ > > > return self.func(*args) > > > File "C:\Users\saftarn\Desktop\pythonkod\mapexperiments > > > \mapgetobject.py", line 17, in callback > > > undermouse=find_closest(master.CURRENT) > > > NameError: global name 'find_closest' is not defined > > > > from Tkinter import * > > > > master = Tk() > > > > w = Canvas(master, width=400, height=625) > > > w.pack(expand = YES, fill = BOTH) > > > > mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\Maps\provinces-of- > > > sweden.gif') > > > w.create_image(30, 30, image = mapq, anchor = NW) > > > > def key(event): > > > print "pressed", repr(event.char) > > > > def callback(event): > > > clobj=event.widget > > > ## undermouse=find_withtag(master.CURRENT) > > > undermouse=find_closest(master.CURRENT) > > > print repr(undermouse) > > > > w.bind("", key) > > > w.bind("", callback) > > > w.pack() > > > > mainloop() > > > from Tkinter import * > > > master = Tk() > > > w = Canvas(master, width=400, height=625) > > w.pack(expand = YES, fill = BOTH) > > > mapq = PhotoImage(file = 'img.gif') > > _id = w.create_image(0, 0, image = mapq, anchor = NW) > > > objects = {} # map id to object > > objects[_id] = mapq > > > def key(event): > > print "pressed", repr(event.char) > > > def callback(event): > > x, y = w.canvasx(event.x), w.canvasy(event.y) # Translates a > > window x,y coordinates to a canvas coordinate > > _id = w.find_closest(x,y)[0] # Returns tuple containing the object > > id > > obj = objects[_id] # Finds object with given id > > print 'color: %s' % obj.get(int(x), int(y)) > > > w.bind("", key) > > w.bind("", callback) > > w.pack() > > > mainloop() > > ty very much. however i dont get the %s really. is % a symbol and then > replaced by obj.get-values? > anyway when clicked i get 3values, but there is intx and inty only. > where does the 3rd value come from and how do i refer to it? nevermind i get it now From frikker at gmail.com Sun Apr 27 21:31:45 2008 From: frikker at gmail.com (blaine) Date: Sun, 27 Apr 2008 18:31:45 -0700 (PDT) Subject: Regular Expression - Matching Multiples of 3 Characters exactly. Message-ID: Hey everyone, For the regular expression gurus... I'm trying to write a string matching algorithm for genomic sequences. I'm pulling out Genes from a large genomic pattern, with certain start and stop codons on either side. This is simple enough... for example: start = AUG stop=AGG BBBBBBAUGWWWWWWAGGBBBBBB So I obviously want to pull out AUGWWWWWWAGG (and all other matches). This works great with my current regular expression. The problem, however, is that codons come in sets of 3 bases. So there are actually three different 'frames' I could be using. For example: ABCDEFGHIJ I could have ABC DEF GHI or BCD EFG HIJ or CDE FGH IJx.... etc. So finally, my question. How can I represent this in a regular expression? :) This is what I'd like to do: (Find all groups of any three characters) (Find a start codon) (find any other codons) (Find an end codon) Is this possible? It seems that I'd want to do something like this: (\w \w\w)+(AUG)(\s)(AGG)(\s)* - where \w\w\w matches EXACTLY all sets of three non-whitespace characters, followed by AUG \s AGG, and then anything else. I hope I am making sense. Obviously, however, this will make sure that ANY set of three characters exist before a start codon. Is there a way to match exactly, to say something like 'Find all sets of three, then AUG and AGG, etc.'. This way, I could scan for genes, remove the first letter, scan for more genes, remove the first letter again, and scan for more genes. This would hypothetically yield different genes, since the frame would be shifted. This might be a lot of information... I appreciate any insight. Thank you! Blaine From martin at v.loewis.de Wed Apr 16 02:24:56 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Wed, 16 Apr 2008 08:24:56 +0200 Subject: Unicode chr(150) en dash In-Reply-To: References: Message-ID: <48059bb8$0$26954$9b622d9e@news.freenet.de> > "C:\Python24\Lib\site-packages\MySQLdb\cursors.py", line 149, in > execute query = query.encode(charset) UnicodeEncodeError: 'latin-1' > codec can't encode character u'\u2013' in position 52: ordinal not in > range(256) Here it complains that it deals with the character U+2013, which is "EN DASH"; it complains that the encoding called "latin-1" does not support that character. That is a fact - Latin-1 does not support EN DASH. > When I type 'print chr(150)' into a python command line window I get > a LATIN SMALL LETTER U WITH CIRCUMFLEX > (http://www.fileformat.info/info/unicode/char/00fb/index.htm), That's because your console uses the code page 437: py> chr(150).decode("cp437") u'\xfb' py> unicodedata.name(_) 'LATIN SMALL LETTER U WITH CIRCUMFLEX' Code page 437, on your system, is the "OEM code page". > but when I do so into a IDLE window I get a hypen (chr(45). That's because IDLE uses the "ANSI code page" of your system, which is windows code page 1252. py> chr(150).decode("windows-1252") u'\u2013' py> unicodedata.name(_) 'EN DASH' You actually *don't* get the character U+002D, HYPHEN-MINUS, displayed - just a character that has, in your font, a glyph which looks similar to the glyph for HYPHEN-MINUS. However, HYPHEN-MINUS and EN DASH are different characters, and IDLE displays the latter, not the former. > I tried searching "en dash" or even "dash" into the encodings folder > of python Lib, but I couldn't find anything. You didn't ask a specific question, so I assume you are primarily after an explanation. HTH, Martin From terry.yinzhe at gmail.com Tue Apr 29 10:36:59 2008 From: terry.yinzhe at gmail.com (Terry) Date: Tue, 29 Apr 2008 07:36:59 -0700 (PDT) Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> Message-ID: On Apr 29, 3:01 pm, Dennis Lee Bieber wrote: > On Sun, 27 Apr 2008 03:27:59 -0700 (PDT), Terry > declaimed the following in comp.lang.python: > > > I'm trying to implement a message queue among threads using Queue. The > > message queue has two operations: > > PutMsg(id, msg) # this is simple, just combine the id and msg as one > > and put it into the Queue. > > WaitMsg(ids, msg) # this is the hard part > > > WaitMsg will get only msg with certain ids, but this is not possible > > in Queue object, because Queue provides no method to peek into the > > message queue and fetch only matched item. > > > Now I'm using an ugly solution, fetch all the messages and put the not > > used ones back to the queue. But I want a better performance. Is there > > any alternative out there? > > Create your own queue class -- including locking objects. > > Implement the queue itself (I've not looked at how Queue.Queue is > really done) as a priority queue (that is, a simple list ordered by your > ID -- new items are inserted after all existing items with the same or > lower ID number). > > Surround list manipulations with a lock based on a Condition. > > Now, the trick -- the .get(ID) sequence being something like (this > is pseudo-code): > > while True: > self.condition.acquire() > scan self.qlist for first entry with ID > if found: > remove entry from self.qlist > self.condition.release() > return entry > self.condition.wait() > > -=-=-=-=- the .put(ID, data) looks like > > self.condition.acquire() > scan self.qlist for position to insert (ID, data) > self.condition.notifyAll() > self.condition.release() > > -=-=-=-=- > > Essentially, if the first pass over the list does not find an entry > to return, it waits for a notify to occur... and notification will only > occur when some other thread puts new data into the list. > -- > Wulfraed Dennis Lee Bieber KD6MOG > wlfr... at ix.netcom.com wulfr... at bestiaria.com > HTTP://wlfraed.home.netcom.com/ > (Bestiaria Support Staff: web-a... at bestiaria.com) > HTTP://www.bestiaria.com/ Yes, now I have a similar solution in my code. But after read the stackless python, I'm thinking if I can move to stackless, which might improve the performance of my thread. Because I'm trying to simulate some behavior of the real world (trading), I believe there will be a lot of threads in the future in my program. From drjekil77 at gmail.com Tue Apr 8 22:17:57 2008 From: drjekil77 at gmail.com (drjekil) Date: Tue, 8 Apr 2008 19:17:57 -0700 (PDT) Subject: new user needs help! In-Reply-To: <16571823.post@talk.nabble.com> References: <16571823.post@talk.nabble.com> Message-ID: <16578029.post@talk.nabble.com> u got it! thats the thing i am trying to explain by my bad english! thanks for the help. -- View this message in context: http://www.nabble.com/new--user-needs-help%21-tp16571823p16578029.html Sent from the Python - python-list mailing list archive at Nabble.com. From duncan.booth at invalid.invalid Fri Apr 4 04:57:42 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 4 Apr 2008 08:57:42 GMT Subject: variable scope in list comprehensions References: Message-ID: Steve Holden wrote: >> For a moment I thought that maybe list comprehension has its own >> scope, but it doesn't seem to be so: >> print [[y for y in range(8)] for y in range(8)] >> print y >> >> Does anybody understand it? >> >> > This isn't _a_ list comprehension, it's *two* list comprehensions. The > interpreter computes the value if the inner list comprehension and > then duplicates eight references to it (as you will see if you change > an element). > Do you want to reconsider that statement? The interpreter recomputes the inner list comprehension eight times, there are no duplicated references. For the OP, in some languages (e.g. C) 'for' loops typically calculate the value of the loop control variable based on some expression involving the previous value. Python isn't like that. In Python the data used to compute the next value is stored internally: you cannot access it directly. That means you can reassign or delete the loop control variable if you want, but it doesn't affect the loop iteration; every time round the loop there is a fresh assignment to the variable. So the code: for y in range(8): for y in range(8): pass # or whatever the body of the loops is sort of equivalent to: __loop_control_1__ = iter(range(8)) while True: try: y = __loop_control_1__.next() except StopIteration: break __loop_control_2__ = iter(range(8)) while True: try: y = __loop_control_1__.next() except StopIteration: break pass # or whatever the body of the loops except there are no accessible variables __loop_control_1__ or __loop_control_2__. From kay.schluehr at gmx.net Sat Apr 5 06:55:30 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 5 Apr 2008 03:55:30 -0700 (PDT) Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> Message-ID: On 5 Apr., 12:26, Aldo Cortesi wrote: > Thus spake Kay Schluehr (kay.schlu... at gmx.net): > > > I'm not entirely sure what you are claiming here. From source > > inspections I can see that TestSuite instances are instantiated by the > > TestLoader and you are free to derive from TestLoader, overwrite its > > methods and pass around another instance than defaultTestLoader ( or > > a fresh instance of TestLoader which is the same thing ). > > ... and at this point your monkeypatched framework would no longer be > much more compatible with existing test suites than Pry is. A properly extended framework would of course be compatible with all existing test suites. This has nothing to do with monkeypatching. I'm not sure you even understand the concepts you are talking about. Kay From steve at holdenweb.com Wed Apr 23 23:52:41 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 23:52:41 -0400 Subject: function that accepts any amount of arguments? In-Reply-To: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> Message-ID: globalrev wrote: > if i want a function that can take any amount of arguments how do i > do? > > lets say i want a function average that accepts any number of integers > and returns the average. Use a parameter of the form *args - the asterisk tells the interpreter to collect positional arguments into a tuple. Untested: def mean(*x): total = 0.0 for v in x: total += v return v/len(x) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From dickinsm at gmail.com Wed Apr 9 09:11:48 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Wed, 9 Apr 2008 06:11:48 -0700 (PDT) Subject: what's the reasonale of loghelper() in mathmodule.c References: <49750e9d-1a63-42d2-b292-38d225b0c3c8@n1g2000prb.googlegroups.com> Message-ID: <28321dcf-71d2-4c67-bd1d-1e187015129d@u3g2000hsc.googlegroups.com> On Apr 9, 4:38?am, rockins wrote: > I cannot understand it well, can anyone explain me why and how > loghelper() can compute any base logarithm? Or could anyone give me > some reference(such as, books or papers)? loghelper is there so that log(n) can be computed for any positive integer n---it's nothing to do with computing logs to an arbitrary base. All of the other math functions convert an integer argument to a float first. That conversion fails if the integer is larger than the largest representable float (around 1.7e308 on most systems). For example: >>> from math import sqrt, log >>> sqrt(10**600) Traceback (most recent call last): File "", line 1, in OverflowError: long int too large to convert to float >>> log(10**600) 1381.5510557964274 The sqrt call first tries to convert 10**600 to a float, giving an OverflowError (even though the actual square root *is* representable as a float). The log call goes through loghelper instead, which doesn't try to convert 10**600 to a float, but instead computes the log based on the top few bits of 10**600 (in its internal binary representation) and on the number of bits required to represent 10**600. You're not going to learn much about math function implementations from mathmodule.c: all it does it wrap the platform libm functions. Mark From bignose+hates-spam at benfinney.id.au Sun Apr 27 21:43:10 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Mon, 28 Apr 2008 11:43:10 +1000 Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> <48118719$0$25846$9b622d9e@news.freenet.de> Message-ID: <87prsa4uvl.fsf@benfinney.id.au> Aaron Watters writes: > I think it's outrageous to change the basic usage for things like > dictionary.keys() when it would be so easy to leave the old > definition and add a new method like dictionary.keySet(). Except that name would be outrageously non-conformant with PEP 8. -- \ "Yesterday I parked my car in a tow-away zone. When I came back | `\ the entire area was missing." -- Steven Wright | _o__) | Ben Finney From spiro.harvey at gmail.com Thu Apr 3 17:56:14 2008 From: spiro.harvey at gmail.com (idle) Date: Thu, 3 Apr 2008 14:56:14 -0700 (PDT) Subject: expanding a variable to a dict Message-ID: I've got a variable in a loop that I'm trying to expand/translate/ readdress as an existing dict so as to add some keys into it.. eg; I have a set of existing dicts: dictFoo, dictBar, dictFrotz (names changed to protect the innocent) now I'd like to check them all for the existence of certain default keys; ie, if the dicts don't contain the keys, add them in with default values. so, I've got: for a in ['dictFoo','dictBar','dictFrotz']: if hasattr(a,'srcdir') == False: a['srcdir']='/usr/src' the error I get (which I expect) is 'str' object doesn't support item assignment. what incantation do I cast on 'a' to make the interpreter parse it as 'dictFoo' on the first iteration, 'dictBar' on the second, and so forth? and/or less importantly, what is such a transformation called, to help me target my searching? thanks From leoniaumybragg at gmail.com Sat Apr 26 06:56:51 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:56:51 -0700 (PDT) Subject: cotton patch cafe Message-ID: cotton patch cafe http://cracks.00bp.com F R E E C R A C K S From cginnowzerozeroone at microprizes.com Mon Apr 14 17:28:18 2008 From: cginnowzerozeroone at microprizes.com (Carl G.) Date: Mon, 14 Apr 2008 14:28:18 -0700 Subject: Game design : Making computer play References: <66gf8dF2ju94lU3@mid.uni-berlin.de> Message-ID: "Marc 'BlackJack' Rintsch" wrote in message news:66gf8dF2ju94lU3 at mid.uni-berlin.de... > On Mon, 14 Apr 2008 00:13:56 -0700, v4vijayakumar wrote: > >> In computer based, two player, board games, how to make computer play? >> Are there any formal ways to _teach_ computer, to choose best possible >> move? > > That depends on the type of the game. For a certain class of games one > can use the `minimax method`_ for instance. > > .. _minimax method: http://en.wikipedia.org/wiki/Minimax While checking the Wikipedia, also check out the A* (a-star) graph search algorithms: http://en.wikipedia.org/wiki/A%2A There is a table on the top-right of this page that includes other graph search algorithms. My AI games are usually built around general purpose mini-max code, possibly inplementing A* (I reuse the same code for various games). For each new two-player game, I usually only have to write new "position evaluator" code, which generates a quantitative value that gives the relative position of one player over the other for a particular board. Some games can benefit from a database of opening moves that have been shown to be be superior (this speeds up the computer's response). Carl G. From dave.opstad at monotypeimaging.com Fri Apr 25 16:34:28 2008 From: dave.opstad at monotypeimaging.com (Dave Opstad) Date: Fri, 25 Apr 2008 13:34:28 -0700 Subject: List of all Python's ____ ? References: <87wsmrdka8.fsf@mulj.homelinux.net> <480d016e$1@news.mel.dft.com.au> Message-ID: In article <480d016e$1 at news.mel.dft.com.au>, John Machin wrote: > Hrvoje Niksic wrote: > > python at bdurham.com writes: > > > >> Is there an official list of all Python's ____? > > > > http://docs.python.org/ref/specialnames.html > > __missing__ is missing :-) > > see note (10) at the bottom of http://docs.python.org/lib/typesmapping.html Yes, and __copy__ and __deepcopy__ are missing too: http://docs.python.org/lib/module-copy.html Dave From tnelson at onresolve.com Wed Apr 16 13:51:53 2008 From: tnelson at onresolve.com (Trent Nelson) Date: Wed, 16 Apr 2008 10:51:53 -0700 Subject: Global Python Sprint Weekends: May 10th-11th and June 21st-22nd. Message-ID: <87D3F9C72FBF214DB39FA4E3FE618CDC6E22F389FE@EXMBX04.exchhosting.com> Following on from the success of previous sprint/bugfix weekends and sprinting efforts at PyCon 2008, I'd like to propose the next two Global Python Sprint Weekends take place on the following dates: * May 10th-11th (four days after 2.6a3 and 3.0a5 are released) * June 21st-22nd (~week before 2.6b2 and 3.0b2 are released) It seems there are a few of the Python User Groups keen on meeting up in person and sprinting collaboratively, akin to PyCon, which I highly recommend. I'd like to nominate Saturday across the board as the day for PUGs to meet up in person, with Sunday geared more towards an online collaboration day via IRC, where we can take care of all the little things that got in our way of coding on Saturday (like finalising/preparing/reviewing patches, updating tracker and documentation, writing tests ;-). For User Groups that are planning on meeting up to collaborate, please reply to this thread on python-dev at python.org and let every- one know your intentions! As is commonly the case, #python-dev on irc.freenode.net will be the place to be over the course of each sprint weekend; a large proportion of Python developers with commit access will be present, increasing the amount of eyes available to review and apply patches. For those that have an idea on areas they'd like to sprint on and want to look for other developers to rope in (or just to communicate plans in advance), please also feel free to jump on this thread via python-dev@ and indicate your intentions. For those that haven't the foggiest on what to work on, but would like to contribute, the bugs tracker at http://bugs.python.org is the best place to start. Register an account and start searching for issues that you'd be able to lend a hand with. All contributors that submit code patches or documentation updates will typically get listed in Misc/ACKS.txt; come September when the final release of 2.6 and 3.0 come about, you'll be able to point at the tarball or .msi and exclaim loudly ``I helped build that!'', and actually back it up with hard evidence ;-) Bring on the pizza and Red Bull! Trent. From michael at stroeder.com Thu Apr 24 03:47:06 2008 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Thu, 24 Apr 2008 09:47:06 +0200 Subject: python-ldap - Operations Error In-Reply-To: <8b35f293-fc64-4d21-a621-124c8eafde59@c65g2000hsa.googlegroups.com> References: <8b35f293-fc64-4d21-a621-124c8eafde59@c65g2000hsa.googlegroups.com> Message-ID: Jason Scheirer wrote: > On Apr 23, 5:16 pm, theivi... at gmail.com wrote: >> Hello all, I am trying to integrate TurboGears with our Active >> Directory here at the office. TurboGears aside, i cannot get this to >> work. > > Seems more promising: http://tgolden.sc.sabren.com/python/active_directory.html This is based on ADSI? Then the caveat is that it only runs on Windows. Ciao, Michael. From ramesh at winfoware.com Mon Apr 21 06:43:35 2008 From: ramesh at winfoware.com (Ramesh Nathan) Date: Mon, 21 Apr 2008 16:13:35 +0530 Subject: Python Consultants required - Urgent Message-ID: <073f01c8a39c$8ec8f760$ac5ae620$@com> HI Anand, I am looking for python consultants for a couple of months. Please let me know if you could help us directly or suggest some one suitable. With warm regards, Ramesh Nathan, Head - Business Relations, Winfoware Technologies Ltd, Mobile - 0 93425 54560. Land Line - +91 080 23224418 / 23224420 HYPERLINK "http://www.winfoware.com"www.winfoware.com No virus found in this outgoing message. Checked by AVG. Version: 7.5.524 / Virus Database: 269.23.2/1388 - Release Date: 20-04-2008 15:01 -------------- next part -------------- An HTML attachment was scrubbed... URL: From tinnews at isbd.co.uk Mon Apr 7 09:05:20 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 07 Apr 2008 13:05:20 GMT Subject: Presumably an import is no faster or slower than opening a file? References: <47f8d30f$0$761$bed64819@news.gradwell.net> Message-ID: <47fa1c10$0$761$bed64819@news.gradwell.net> Paul McGuire wrote: > On Apr 6, 8:41?am, tinn... at isbd.co.uk wrote: > > I'm trying to minimise the overheads of a small Python utility, I'm > > not really too fussed about how fast it is but I would like to > > minimise its loading effect on the system as it could be called lots > > of times (and, no, I don't think there's an easy way of keeping it > > running and using the same copy repeatedly). > > > > It needs a configuration file of some sort which I want to keep > > separate from the code, is there thus anything to choose between a > > configuration file that I read after:- > > > > ? ? f = open("configFile", 'r') > > > > ... and importing a configuration written as python dictionaries or > > whatever:- > > > > ? ? import myConfig > > > > -- > > Chris Green > > Chris - > > The question is less an issue of the file overhead (both must open a > file, read its contents, and then close it) than what is done with the > file contents afterwards. > > A config file containing .INI-style or whatever content will need to > be parsed into Python data/objects, and likely use Python code to do > so. An import will use the Python compiler itself, using optimized > compiled C code to do the parsing and data/object construction. But I > think you would only see the distinction in a config file of > substantial size or complexity. If you think this will make a > substantial difference in performance, then code up a test case and > time it. > > In general, I'd say that splitting performance hairs to tip a design > choice one way or another is a misguided premature optimization. > I quite agree (about the splitting hairs bit that is), as I said before I just wanted to check that I wasn't missing anything really obvious and, thus, that there probably isn't much to choose between the two approaches. Therefore I'll decide which way to do it on the basis of 'usability'. -- Chris Green From aahz at pythoncraft.com Sun Apr 20 22:57:35 2008 From: aahz at pythoncraft.com (Aahz) Date: 20 Apr 2008 19:57:35 -0700 Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> Message-ID: In article , Carl Banks wrote: >On Apr 17, 3:37 am, Jonathan Gardner >wrote: >> >> Using 100% of the CPU is a bug, not a feature. > >No it isn't. That idea is borne of the narrowmindedness of people who >write server-like network apps. What's true for web servers isn't >true for every application. Only when you have only one application running on a machine. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ Why is this newsgroup different from all other newsgroups? From mal at egenix.com Thu Apr 24 13:41:43 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Thu, 24 Apr 2008 19:41:43 +0200 Subject: convert xhtml back to html In-Reply-To: <000901c8a62e$f36fdc80$c41ea8c0@naomi> References: <000901c8a62e$f36fdc80$c41ea8c0@naomi> Message-ID: <4810C657.3060101@egenix.com> On 2008-04-24 19:16, John Krukoff wrote: >> -----Original Message----- >> From: python-list-bounces+jkrukoff=ltgc.com at python.org [mailto:python- >> list-bounces+jkrukoff=ltgc.com at python.org] On Behalf Of Tim Arnold >> Sent: Thursday, April 24, 2008 9:34 AM >> To: python-list at python.org >> Subject: convert xhtml back to html >> >> hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop >> to >> create CHM files. That application really hates xhtml, so I need to >> convert >> self-ending tags (e.g.
) to plain html (e.g.
). >> >> Seems simple enough, but I'm having some trouble with it. regexps trip up >> because I also have to take into account 'img', 'meta', 'link' tags, not >> just the simple 'br' and 'hr' tags. Well, maybe there's a simple way to do >> that with regexps, but my simpleminded )]+/> doesn't work. I'm >> not >> enough of a regexp pro to figure out that lookahead stuff. >> >> I'm not sure where to start now; I looked at BeautifulSoup and >> BeautifulStoneSoup, but I can't see how to modify the actual tag. You could filter the XHTML through mxTidy and set the hide_endtags to 1: http://www.egenix.com/products/python/mxExperimental/mxTidy/ -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 24 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From steve at holdenweb.com Tue Apr 1 23:19:48 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 01 Apr 2008 23:19:48 -0400 Subject: generator functions: why won't this work? In-Reply-To: References: Message-ID: zillow20 at googlemail.com wrote: > Hi all, > > I'm trying to understand generator functions and the yield keyword. > I'd like to understand why the following code isn't supposed to work. > (What I would have expected it to do is, for a variable number of > arguments composed of numbers, tuples of numbers, tuples of tuples, > etc., the function would give me the next number "in sequence") > #################################### > def getNextScalar(*args): > for arg in args: > if ( isinstance(arg, tuple)): > getNextScalar(arg) > else: > yield arg > #################################### > > # here's an example that uses this function: > # creating a generator object: > g = getNextScalar(1, 2, (3,4)) > g.next() # OK: returns 1 > g.next() # OK: returns 2 > g.next() # not OK: throws StopIteration error > > #################################### > > I'm sure I'm making some unwarranted assumption somewhere, but I > haven't been able to figure it out yet (just started learning Python a > couple of days ago). > > Any help will be appreciated :) > In your recursive call you are passing a single argument, a tuple. You should create it to multiple arguments with a star. Neither do you do anything with the iterator after you create it. Try (untested) #################################### def getNextScalar(*args): for arg in args: if ( isinstance(arg, tuple)): for a in getNextScalar(*arg): yield a else: yield arg #################################### regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From alexelder at gmail.com Wed Apr 23 04:49:13 2008 From: alexelder at gmail.com (alexelder at gmail.com) Date: Wed, 23 Apr 2008 01:49:13 -0700 (PDT) Subject: "Dreaming in Code" References: <14fccf8d-eb21-4e04-9244-50bcfc84c4d7@d45g2000hsc.googlegroups.com> Message-ID: <1630250a-92e1-460c-b569-946868ffd85f@y21g2000hsf.googlegroups.com> On Apr 23, 6:12 am, Paul McGuire wrote: > Haven't seen anyone mention this book, it is a "Soul of a New Machine"- > style record of the Chandler project. Since Chandler uses Python and > Twisted, and employed a few Python celebs, I thought folks on this > list might have already read the hardcover version. I just picked up > the paperback at B&N yesterday, finished it this evening. It's a > decent read, describing a software project in laymen's terms (like > there are laymen out there who care about that sort of thing!). > > The paperback version adds a chapter including events that transpired > after the hardcover publication date, current up to about October, > '07, so that's a nice touch. > > I'm going to ask my wife to read it so she might learn what I do for a > living. > > -- Paul Hi, Paul. This book was actually the book which got me into Python! At the time of reading I was in my second year of University, utterly snowed under with Java and C related assignments/personal projects, however, I found time to read this book; I'm /so/ glad I did. I actually heard of the book from an article written by Joel 'Joel on Software', Spolsky. (you can find it here: http://www.joelonsoftware.com/items/2007/01/02.html). It's an interesting read and poses a nice insight into how software projects evolve over time. Alex. From larry.bates at websafe.com` Sun Apr 27 09:55:35 2008 From: larry.bates at websafe.com` (Larry Bates) Date: Sun, 27 Apr 2008 08:55:35 -0500 Subject: design choice: multi-threaded / asynchronous wxpython client? In-Reply-To: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: <58CdnQxBlq1FGInVnZ2dnUVZ_sednZ2d@comcast.com> bullockbefriending bard wrote: > I am a complete ignoramus and newbie when it comes to designing and > coding networked clients (or servers for that matter). I have a copy > of Goerzen (Foundations of Python Network Programming) and once > pointed in the best direction should be able to follow my nose and get > things sorted... but I am not quite sure which is the best path to > take and would be grateful for advice from networking gurus. > > I am writing a program to display horse racing tote odds in a desktop > client program. I have access to an HTTP (open one of several URLs, > and I get back an XML doc with some data... not XML-RPC.) source of > XML data which I am able to parse and munge with no difficulty at all. > I have written and successfully tested a simple command line program > which allows me to repeatedly poll the server and parse the XML. Easy > enough, but the real world production complications are: > > 1) The data for the race about to start updates every (say) 15 > seconds, and the data for earlier and later races updates only every > (say) 5 minutes. There is no point for me to be hammering the server > with requests every 15 seconds for data for races after the upcoming > race... I should query for this perhaps every 150s to be safe. But for > the upcoming race, I must not miss any updates and should query every > ~7s to be safe. So... in the middle of a race meeting the situation > might be: > race 1 (race done with, no-longer querying), race 2 (race done with, > no longer querying) race 3 (about to start, data on server for this > race updating every 15s, my client querying every 7s), races 4-8 (data > on server for these races updating every 5 mins, my client querying > every 2.5 mins) > > 2) After a race has started and betting is cut off and there are > consequently no more tote updates for that race (it is possible to > determine when this occurs precisely because of an attribute in the > XML data), I need to stop querying (say) race 3 every 7s and remove > race 4 from the 150s query group and begin querying its data every 7s. > > 3) I need to dump this data (for all races, not just current about to > start race) to text files, store it as BLOBs in a DB *and* update real > time display in a wxpython windowed client. > > My initial thought was to have two threads for the different update > polling cycles. In addition I would probably need another thread to > handle UI stuff, and perhaps another for dealing with file/DB data > write out. But, I wonder if using Twisted is a better idea? I will > still need to handle some threading myself, but (I think) only for > keeping wxpython happy by doing all this other stuff off the main > thread + perhaps also persisting received data in yet another thread. > > I have zero experience with these kinds of design choices and would be > very happy if those with experience could point out the pros and cons > of each (synchronous/multithreaded, or Twisted) for dealing with the > two differing sample rates problem outlined above. > > Many TIA! > > > > IMHO using twisted will give you the best performance and framework. Since it uses callbacks for every request, your machine could handle a LOT of different external queries and keep everything updated in WX. Might be a little tricky to get working with WX, but I recall Googling for something like this not long ago and there appeared to be sufficient information on how to get working. http://twistedmatrix.com/projects/core/documentation/howto/choosing-reactor.html Twisted even automatically uses threads to keep SQL database storage routines from blocking (see Chapter 4 of Twisted Network Programming Essentials) This is an ambitious project, good luck. -Larry From steve at holdenweb.com Sun Apr 6 22:43:39 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 06 Apr 2008 22:43:39 -0400 Subject: ANN: pry unit testing framework In-Reply-To: <20080407023442.GA16373@nullcube.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> <20080407023442.GA16373@nullcube.com> Message-ID: <47F98A5B.8010000@holdenweb.com> Aldo Cortesi wrote: > Thus spake Ben Finney (bignose+hates-spam at benfinney.id.au): > >>> I'm afraid that Pry is unashamedly incompatible with any other unit >>> testing method in existence, including but not limited to doctest, >>> unittest, nose and py.test. ;) >> Which makes the deliberate deviations from PEP 8 naming a large black >> mark against it. > > You're misunderstanding the intent of PEP 8, which was never supposed > to dogmatically enforce a naming standard on all Python projects > everywhere. You're also vastly overstating the impact of a minor naming > convention choice. Calling this a "large black mark" smacks of > scare-mongering to me. > It probably reflects personal preference, but it's a preference that many people will maintain. I understand that PEP 008 was largely directed at standard library authors and maintainers, but anything that claims wide utility should have ambitions to be included in the standard library, and hence PEP 008 conformance would be a plus. >>> Some day I might experiment with extending Pry to gather and run >>> doctests and unittests. At this stage, however, I don't believe the >>> (significant) effort would be worth it. >> That's very unfortunate. Until it plays better with others, I don't >> believe the effort of using this package will be worth it. > > Each of the third-party testing frameworks that have cropped up in this > thread extends unittest in some incompatible way. If you use any of > these extensions, it means that your unit test suite is tied to that > particular test framework. If you have an existing suite of unit tests > that you can't or don't want to convert, I'm afraid that Pry is indeed > not for you. Pry is not intended to be a general engine for running > tests written for other frameworks. > A reasonable enough point of view, but it means that you are just one of a number of competing frameworks. While you are earnest about pry's advantages you have a lot of work to do to move people away form the entrenched testing frameworks they are used to. > I should also note that converting from unittest to Pry is quite simple > - Pry's test structure is a superset of unittest's, and AutoTree was > explicitly written to make "unittest-style" testing possible, meaning > that no _structural_ change is needed for conversion. The most onerous > part is converting to assertion-based testing, something that will > improve the clarity and readability of your tests anyway. > Time will tell. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From sturlamolden at yahoo.no Tue Apr 22 13:55:05 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Tue, 22 Apr 2008 10:55:05 -0700 (PDT) Subject: subprocess module is sorely deficient? References: Message-ID: <775619e8-5ee4-4b4e-a081-47c8c6090f05@e67g2000hsa.googlegroups.com> On Apr 22, 12:52 pm, Harishankar wrote: > Sorry to start off on a negative note in the list, but I feel that the Python > subprocess module is sorely deficient because it lacks a mechanism to Have you looked at the processing module in cheese shop? From damonwischik at gmail.com Fri Apr 18 20:50:40 2008 From: damonwischik at gmail.com (damonwischik at gmail.com) Date: Fri, 18 Apr 2008 17:50:40 -0700 (PDT) Subject: How to print a unicode string? References: <54e7dba7-f7f2-4aa7-81f9-922e3bf6e6cd@m73g2000hsh.googlegroups.com> Message-ID: <7110f3b8-8304-4773-a747-31f177c1eb8b@p25g2000hsf.googlegroups.com> On Apr 19, 1:36 am, 7stud wrote: > u_str = u'hell\u00F6 w\u00F6rld' #o's with umlauts > print u_str.encode('utf-8') > > --output:-- > hell? w?rld Maybe on your system. On my system, those same commands produce hell\303\266 w\303\266rld Those \303\266 symbols are single characters -- when I move around with cursor keys, the cursor jumps across them with a single key- press. As I wrote, I'm running Python inside Emacs 22.2.1 (using python- mode). Damon. From sandip.more at gmail.com Tue Apr 29 01:36:41 2008 From: sandip.more at gmail.com (sandipm) Date: Mon, 28 Apr 2008 22:36:41 -0700 (PDT) Subject: python script as executable Message-ID: Hi, I have written a python script to run from cron. I have put #!/usr/bin/env python at top. file executes correctly when I run using python filename.py but it fails to execute when try to run it like script/command. it throws error: :No such file or directory I am editing file from eclipse for python from windows. and then uploading on linus machine to run it. any pointers? sandip From skanemupp at yahoo.se Fri Apr 4 23:57:58 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 4 Apr 2008 20:57:58 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> Message-ID: <7113d012-01bb-4426-bb40-9e2811cdb102@x41g2000hsb.googlegroups.com> On 5 Apr, 05:26, 7stud wrote: > On Apr 4, 7:06 pm, skanem... at yahoo.se wrote: > > > > > 1st question: > > > when i run this program 1 will be printed into the interpreter when i > > run it BUT without me clicking the actual button. > > when i then click the button "1", nothing happens. > > > obv i dont want any output when i dont push the button but i want it > > when i do. > > > what am i doing wrong here? > > > 2nd question: > > > i want all the buttons to have the same size. i thought i should use > > row/columnspan but i dont get that to work. > > how should i do? > > > [code] > > #! /usr/bin/env python > > from Tkinter import * > > import tkMessageBox > > > class GUIFramework(Frame): > > """This is the GUI""" > > > def __init__(self,master=None): > > """Initialize yourself""" > > > """Initialise the base class""" > > Frame.__init__(self,master) > > > """Set the Window Title""" > > self.master.title("Calculator") > > > """Display the main window" > > with a little bit of padding""" > > self.grid(padx=10,pady=10) > > self.CreateWidgets() > > > def CreateWidgets(self): > > > self.enText = Entry(self) > > self.enText.grid(row=0, column=0, columnspan=8, padx=5, > > pady=5) > > > self.enText = Entry(self) > > self.enText.grid(row=1, column=0, columnspan=8, padx=5, > > pady=5) > > > self.btnDisplay = Button(self, text="1", > > command=self.Display(1)) > > self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="2", default=ACTIVE) > > self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="3", default=ACTIVE) > > self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="+", default=ACTIVE) > > self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="4", default=ACTIVE) > > self.btnDisplay.grid(row=4, column=0, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="5", default=ACTIVE) > > self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="6", default=ACTIVE) > > self.btnDisplay.grid(row=4, column=2, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="-", default=ACTIVE) > > self.btnDisplay.grid(row=4, column=3, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="7", default=ACTIVE) > > self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="8", default=ACTIVE) > > self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="9", default=ACTIVE) > > self.btnDisplay.grid(row=5, column=2, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="*", default=ACTIVE) > > self.btnDisplay.grid(row=5, column=3, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="0", default=ACTIVE) > > self.btnDisplay.grid(row=6, column=0, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="C", default=ACTIVE) > > self.btnDisplay.grid(row=6, column=1, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="r", default=ACTIVE) > > self.btnDisplay.grid(row=6, column=2, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="/", default=ACTIVE) > > self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) > > > def Display(self, xbtn): > > if xbtn==1: > > print 1 > > > if __name__ == "__main__": > > guiFrame = GUIFramework() > > guiFrame.mainloop() > > > [/code] > > If you have this function: > > def f(): > print 1 > return 10 > > and you write: > > result = f() > > The '()' is the function execution operator; it tells python to > execute the function. In this case, the function executes, and then > the return value of the function is assigned to the variable result. > If a function does not have a return statement, then the function > returns None by default. > > The same thing is happening in this portion of your code: > > command = self.Display(1) > > That code tells python to execute the Display function and assign the > function's return value to the variable command. As a result Display > executes and 1 is displayed. Then since Dispay does not have a return > statement, None is returned, and None is assigned to command. > Obviously, that is not what you want to do. > > What you want to do is assign a "function reference" to command so > that python can execute the function sometime later when you click on > the button. A function reference is just the function name without > the '()' after it. So you would write: > > command = self.Display > > But writing it like that doesn't allow *you* to pass any arguments to > Display(). In addition, *tkinter* does not pass any arguments to > Display when tkinter calls Display in response to a button click. As > a result, there is no way to pass an argument to Display. > > However, there is another way to cause a function to execute when an > event, like a button click, occurs on a widget: you use the widget's > bind() function: > > my_button.bind('', someFunc) > > The first argument tells tkinter what event to respond to. > '' is a left click. Check the docs for the different > strings that represent the different events that you can respond to. > The second argument is a function reference, which once again does not > allow you to pass any arguments to the function. However, when you > use bind() to attach a function to a widget, tkinter calls the > function and passes it one argument: the "event object". The event > object contains various pieces of information, and one piece of > information it contains is the widget upon which the event occurred, > e.g. the button that was clicked. To get the button, you write: > > Display(self, event_obj): > button = event_obj.widget > > Once you have the button, you can get the text on the button: > > Display(self, event_obj): > button = event_obj.widget > text = button.cget("text") > > if text=="1": > print 1 > > Another thing you should be aware of: self is like a class wide > bulletin board. If you are writing code inside a class method, and > there is data that you want code inside another class method to be > able to see, then post the data on the class wide bulletin board, i.e. > attach it to self. But in your code, you are doing this: > > self.btnDisplay = Button(self, text="7", default=ACTIVE) > self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > self.btnDisplay = Button(self, text="8", default=ACTIVE) > self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > As a result, your code continually overwrites self.btnDisplay. That > means you aren't preserving the data assigned to self.btnDisplay. > Therefore, the data does not need to be posted on the class wide > bulletin board for other class methods to see. So just write: > > btnDisplay = Button(self, text="7", default=ACTIVE) > btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > btnDisplay = Button(self, text="8", default=ACTIVE) > btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > As for the button sizing problem, your buttons are all the same size > and line up perfectly on mac os x 10.4.7. wow thank you so much, awesome answer i will get right to fixing this now. in regards to the buttonsizes i use windows VISTA and they have different sizes. From kyrie at uh.cu Fri Apr 25 17:29:29 2008 From: kyrie at uh.cu (Luis Zarrabeitia) Date: Fri, 25 Apr 2008 17:29:29 -0400 Subject: Goodbying Spaces In-Reply-To: <4dc0cfea0804251401p3ab96fddy99452f5a3255acde@mail.gmail.com> References: <4dc0cfea0804251401p3ab96fddy99452f5a3255acde@mail.gmail.com> Message-ID: <200804251729.29976.kyrie@uh.cu> Whats the result of using id.strip()?: In [1]: " asdfasdf ".strip() Out[1]: 'asdfasdf' It should work, I guess... Btw, you can write your code without using len in a cleaner way: try: if id[0] == ' ': id = id[1:] # Note this slice notation... except: pass try: if id[-1] == ' ': # id[-1] would be the last character id = id[:-1] # Again, a slice with only one argument except: pass Cheers, K. On Friday 25 April 2008 05:01:31 pm Victor Subervi wrote: > Hi; > Whenever I call a field from the preceeding form using cgi.FieldStorage() I > get a space on either side. I end up writing code like this to get rid of > that space: > > try: > > if id[0] == ' ': > > id = id[1:len(id)] > > except: > > pass > > try: > > if id[len(id) - 1] == ' ': > > id = id[0:len(id) - 1] > > except: > > pass > which is a nuisance. Is there a better way to do this? I have tried > id.strip() with no luck. What do? > TIA, > Victor -- Luis Zarrabeitia (aka Kyrie) Fac. de Matem?tica y Computaci?n, UH. http://profesores.matcom.uh.cu/~kyrie From bijeshn at gmail.com Mon Apr 7 06:13:06 2008 From: bijeshn at gmail.com (bijeshn) Date: Mon, 7 Apr 2008 03:13:06 -0700 (PDT) Subject: splitting an XML file on the basis on basis of XML tags References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> <47F9B845.9040205@behnel.de> Message-ID: > > What do you mean by "written down to a separate file"? Do you have a specific > format in mind? > sorry, it should be extracted into separate "files". i.e. if i have an XML file containing 10 million records, i need to split the file to 100 files containing 100,000 records each. i hope this is clearer... From banibrata.dutta at gmail.com Sun Apr 20 09:32:36 2008 From: banibrata.dutta at gmail.com (Banibrata Dutta) Date: Sun, 20 Apr 2008 19:02:36 +0530 Subject: Any reliable obfurscator for Python 2.5 In-Reply-To: References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> Message-ID: <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> On 4/20/08, Gabriel Genellina wrote: > > En Sun, 20 Apr 2008 01:55:51 -0300, Banibrata Dutta < > banibrata.dutta at gmail.com> escribi?: > > > Wanted to check if there is any known, reliable, FOSS/Libre -- > Obfurscator > > for Python 2.5 code. > > Why do you want to do that in the first place? I need to do to retain the confidentiality for certain core components, which are not supposed to be open. While I do have the option of implementing them in C/C++, I'm trying to see if I can avoid that for 2 reasons -- 1. Its a fairly large and complex set of components, and doing it in C/C++ 'might' take significantly longer. 2. I'd try to avoid having mix of languages if possible. It makes the developement easier to maintain/manage over a period of time. There is very few you can do to obfuscate Python code. You can't rename > classes nor methods nor global variables nor argument names due to the > dynamic nature of Python. All you can safely do is to remove comments and > join simple statements using ; I do not understand the nuances of dynamic languages completely, so this might be a foolish assumption, but if i make a complete, self-contained Python application (collection of modules), then just before shipping a production copy, why can't I replace 'all' symbols i.e. classes, methods, variables etc ? Esply if I'm compiling the source ? If you remove docstrings, some things may break. Even renaming local > variables isn't safe in all cases. Hmmm... but I'm aware of atleast 2 Obfuscators one commercial and one FOSS, that seem to exist for Python. The commercial one is what I might try if I don't find anything FOSS. The FOSS one seems to be a dead project. If they are (or have been) there, I guess obfuscation is a doable thing, no ? cheers, B -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -- regards, Banibrata http://www.linkedin.com/in/bdutta -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at holdenweb.com Tue Apr 8 10:11:07 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 10:11:07 -0400 Subject: Reproducing a web page and add own content to it. In-Reply-To: <1cddd2af-28be-42ee-8004-0d76978aeaa9@b9g2000prh.googlegroups.com> References: <6615blF2ifaqcU1@mid.uni-berlin.de> <1cddd2af-28be-42ee-8004-0d76978aeaa9@b9g2000prh.googlegroups.com> Message-ID: LaundroMat wrote: > On Apr 8, 2:04 pm, "Diez B. Roggisch" wrote: >> LaundroMat wrote: >>> Hi - >>> I'm working on a Django powered site where one of the required >>> functionalities is the possibility of displaying the content of >>> external pages, with an extra banner at the top where specific >>> information is displayed. In other words, I'm looking for a way to >>> reproduce an existing web page and add some HTML code to it. (I can't >>> think of an example right now, but the idea is similar to sites that >>> let you see an external page and have some site-specific text above it >>> (often stating that the content below is not part of the site the user >>> comes from)). >>> To test this, I've been downloading an external page, adding some text >>> to it and re-opening it in a browser (with the help of built-in >>> modules such as urllib2 etc). This works of course, but the external >>> page's links such as , or
>>> are evidently no longer correct. >>> Apart from parsing the whole file and trying to inject the external >>> site's domain in links such as the above (with the added inconvenience >>> of having to store the external page locally), is there an easier way >>> of accomplishing what I want? >> Using a frame? >> >> Diez > > Ack. I was too focused on importing the external web page and > redisplaying the information (I've just been reading up on > BeautifulSoup) instead of looking for an HTML based approach. > > Thanks! You could also look at adding a tag to your generated page's section. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From n00m at narod.ru Sat Apr 26 19:28:56 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 16:28:56 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> Message-ID: <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> No so simple, guys. E.g., I can't solve (in Python) this: http://www.spoj.pl/problems/INTEST/ Keep getting TLE (time limit exceeded). Any ideas? After all, it's weekend. 450. Enormous Input Test Problem code: INTEST The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime. Input The input begins with two positive integers n k (n, k<=107). The next n lines of input contain one positive integer ti, not greater than 109, each. Output Write a single integer to output, denoting how many integers ti are divisible by k. Example Input: 7 3 1 51 966369 7 9 999996 11 Output: 4 From ndbecker2 at gmail.com Fri Apr 25 09:37:07 2008 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 25 Apr 2008 09:37:07 -0400 Subject: problem with mmap Message-ID: On linux, I don't understand why: f = open ('/dev/eos', 'rw') m = mmap.mmap(f.fileno(), 1000000, prot=mmap.PROT_READ|mmap.PROT_WRITE, flags=mmap.MAP_SHARED) gives 'permission denied', but this c++ code works: #include #include #include #include #include int main() { int fd = open ("/dev/eos", O_RDWR); void* m = mmap (NULL, 1000000, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); std::cout << m << '\n'; } From ronnbus at gmail.com Mon Apr 7 10:47:15 2008 From: ronnbus at gmail.com (Ronn Ross) Date: Mon, 7 Apr 2008 10:47:15 -0400 Subject: Welcome to the "Python-list" mailing list In-Reply-To: References: Message-ID: This is my first post and I'm new to Python. How would someone go about adding keywords to Python? It would be great to add support for Esperanto keywords in the language instead of English being the only option. thx -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at craig-wood.com Mon Apr 28 05:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Mon, 28 Apr 2008 04:30:03 -0500 Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> Message-ID: s0suk3 at gmail.com wrote: > I wanted to ask for standard ways to receive data from a socket stream > (with socket.socket.recv()). It's simple when you know the amount of > data that you're going to receive, or when you'll receive data until > the remote peer closes the connection. But I'm not sure which is the > best way to receive a message with undetermined length from a stream > in a connection that you expect to remain open. Until now, I've been > doing this little trick: > > data = client.recv(256) > new = data > while len(new) == 256: > new = client.recv(256) > data += new > > That works well in most cases. But it's obviously error-prone. What if > the client sent *exactly* two hundred and fifty six bytes? It would > keep waiting for data inside the loop. Is there really a better and > standard way, or is this as best as it gets? What you are missing is that if the recv ever returns no bytes at all then the other end has closed the connection. So something like this is the correct thing to write :- data = "" while True: new = client.recv(256) if not new: break data += new >From the man page for recv RETURN VALUE These calls return the number of bytes received, or -1 if an error occurred. The return value will be 0 when the peer has performed an orderly shutdown. In the -1 case python will raise a socket.error. -- Nick Craig-Wood -- http://www.craig-wood.com/nick From casey.mcginty at gmail.com Tue Apr 22 06:12:40 2008 From: casey.mcginty at gmail.com (Casey McGinty) Date: Tue, 22 Apr 2008 00:12:40 -1000 Subject: Getting PyUnit to run Package Test Modules Message-ID: Hopefully this is an easy question for someone to answer. I have a directory structure like so: alltest.py prog.py ../package __init__.py mod1.py test_mod1.py modn. py (and so on...) Each test_mod*.py file contains some PyUnit test cases. I am using the following code in alltest.py to run all the unit test modules: mod_to_test = [package.mod1, package.mod2] def suite(): # create TestSuite object alltests = unittest.TestSuite() # load all modules define in the module list for module in map(__import__, mod_to_test): alltests.addTest(unittest.findTestCases(module)) return alltest if __name__ == '__main__': unittest.main(defaultTest='suite') My guess is there is something needed in __init__.py to get this work. Any advice? -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevin.p.dwyer at gmail.com Wed Apr 23 08:28:12 2008 From: kevin.p.dwyer at gmail.com (kdwyer) Date: Wed, 23 Apr 2008 05:28:12 -0700 (PDT) Subject: problem with dictionaries References: <480f29f8$0$11374$426a74cc@news.free.fr> Message-ID: On Apr 23, 1:22 pm, Bruno Desthuilliers wrote: > kdwyer a ?crit :> On Apr 23, 12:16 pm, Simon Strobl wrote: > (snip) > >> #!/usr/bin/python > > >> import sys > > >> frqlist = open('my_frqlist.txt', 'r') > (snip) > >> frq = {} > > >> for line in frqlist: > >> line = line.rstrip() > >> frequency, word = line.split('|') > >> frq[word] = int(frequency) > > (snip) > > > It works for me, save that you need to read the file into a list first > > You don't, unless you're using an old python versions (I'd say 2.3 or > older). Files are now their own iterators. *Fiddles with the interpreter for a moment* So they are - I'd quite forgotten about that - thanks for the reminder! K From lists at cheimes.de Sun Apr 20 13:43:17 2008 From: lists at cheimes.de (Christian Heimes) Date: Sun, 20 Apr 2008 19:43:17 +0200 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> Message-ID: <480B80B5.1050500@cheimes.de> Gabriel Genellina schrieb: > Apart from what everyone has already said, consider that FreqDist may import other modules, store global state, create other objects... whatever. > Pure python code should not have any memory leaks (if there are, it's a bug in the Python interpreter). Not-carefully-written C extensions may introduce memory problems. Pure Python code can cause memory leaks. No, that's not a bug in the interpreter but the fault of the developer. For example code that messes around with stack frames and exception object can cause nasty reference leaks. Christian From lycka at carmen.se Mon Apr 21 06:54:46 2008 From: lycka at carmen.se (Magnus Lycka) Date: Mon, 21 Apr 2008 12:54:46 +0200 Subject: Python and Db In-Reply-To: References: <5dc598e30803311050k5e8352e4g85380fb67cce5ac2@mail.gmail.com> <5dc598e30803311350o79b691bfn27330a9595bbfe53@mail.gmail.com> Message-ID: > escribi?: > >> I would like to use sqlite, But I also wanted a tutorial with the >> basis of the sql and etc, I never dealed with dbs before For practicing SQL on-line, I'd suggest sqlzoo.net. From bbxx789_05ss at yahoo.com Sat Apr 5 14:02:42 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sat, 5 Apr 2008 11:02:42 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <7113d012-01bb-4426-bb40-9e2811cdb102@x41g2000hsb.googlegroups.com> <3cf4bbc8-b828-45c5-b9a8-766ce600af43@y21g2000hsf.googlegroups.com> Message-ID: On Apr 5, 12:02?am, skanem... at yahoo.se wrote: > am i not doing that then? did u look at the code? where do i add the > bind if this: > btnDisplay = Button(self, text="1", command=self.Display) > ? ? ? ? btnDisplay.grid(row=3, column=0, padx=5, pady=5) > > is not enough? > > def Display(self, event_obj): > ? ? ? ? button = event_obj.widget > ? ? ? ? text = button.cget("text") > > ? ? ? ? if text=="1": > ? ? ? ? ? ? print 1 > > i get this exception so i need to pass another argument? im passing 2 > no? > 1) Post the line in your code that passes two arguments to Display. 2) Post the line in yoru code where you call Display. "call" means "execute", and '()' is used after a function name to execute the function. From kareta at web.de Fri Apr 18 06:14:29 2008 From: kareta at web.de (Juergen Kareta) Date: Fri, 18 Apr 2008 12:14:29 +0200 Subject: py3k s***s In-Reply-To: <66q33cF2krjf2U1@mid.uni-berlin.de> References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <66q33cF2krjf2U1@mid.uni-berlin.de> Message-ID: <66ra7oF2kjovcU1@mid.individual.net> Diez B. Roggisch schrieb: >> And I have been benefiting from Python in general, so far. Thanks, >> community. >> >> But now... I'll probably stop posting here for now, & I may stop other >> things too. >> >> Just my 2c. > > You know what I was just wondering about? All these C-written > cross-platform libraries (which Python users benefit from, most probably > including evven you) that run on different unixes & windows, which are a > much greater diversity to handle than the not-even-yet-settled > differences between Py3K & 2.x. How the heck do they do that? > > Oh, and these dreaded 64 bit processors, possibly with multi-cores, > which need changes in code as well, to be utilized to their power. > > But then, these guys most probably don't whine about diversity and > constant change, and cry out useless threats to people who probably > can't care less. > > Fare well, if you must. But getting mad over something which impact you > can't even judge right now is childish. Nothing else. > > Diez 1+ From jgardner at jonathangardner.net Thu Apr 17 13:11:27 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Thu, 17 Apr 2008 10:11:27 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> Message-ID: <6f853c25-25ea-487d-861e-c0775af60df3@s50g2000hsb.googlegroups.com> On Apr 17, 6:40 am, Steve Holden wrote: > I'd love to be wrong about that, but the GIL *has* been the subject of > extensive efforts to kill it over the last five years, and it has > survived despite the best efforts of the developers. > To add to that... In my mind, I see three options for multi-process systems: (1) Locks. (2) A global lock (GIL) (3) Learning to live with the possibility of things disappearing out from under you. In the SQL world, they chose (3). In the Java/C++/C# world, they chose (1). I like Python's compromise a lot, even though it means in a single process, you can only have one thread doing Python at a time. Usually the bits I want to parallelize on are blocking system calls to the network or disk anyway, or the result of a long calculation that updates its result all at once. So having the OS handle the tough bits while I program in a fantasy world where threads are an illusion is fine with me. Discovering a way to get rid of the GIL and not have to do (1) and (3) is truly exciting, but I've lost hope a long time ago. Besides, if it gets in the way I can always do something novel like, I don't know, spawn another Python process? From edreamleo at charter.net Sun Apr 6 13:10:31 2008 From: edreamleo at charter.net (Edward K Ream) Date: Sun, 6 Apr 2008 12:10:31 -0500 Subject: ANN: Leo 4.4.8 final Message-ID: Leo 4.4.8 final is now available at: http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106 This version features a new ipython plugin that provides a two-way bridge between Leo and IPython. See http://webpages.charter.net/edreamleo/IPythonBridge.html Leo is a text editor, data organizer, project manager and much more. See: http://webpages.charter.net/edreamleo/intro.html The highlights of Leo 4.4.8: ---------------------------- - Leo's source code is now managed by bzr: see link below. - Leo's discussion is now hosted by Google Groups: see link below. - Arguments to g.es and g.es_print can be translated using gettext. - Completed ILeo: a bridge between IPython and Leo. See http://webpages.charter.net/edreamleo/IPythonBridge.html - Minibuffer commands may have arguments. - @menu trees can now refer to commands created by @command and @button nodes. - Added support for common @commands nodes in settings files. Links: ------ Leo: http://webpages.charter.net/edreamleo/front.html Forum: http://groups.google.com/group/leo-editor Download: http://sourceforge.net/project/showfiles.php?group_id=3458 Bzr: http://code.launchpad.net/leo-editor/ Quotes: http://webpages.charter.net/edreamleo/testimonials.html -------------------------------------------------------------------- Edward K. Ream email: edreamleo at yahoo.com Leo: http://webpages.charter.net/edreamleo/front.html -------------------------------------------------------------------- From deets at nospam.web.de Tue Apr 22 08:32:06 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 14:32:06 +0200 Subject: Does Python 2.5 include or not include SQLite engine? In-Reply-To: References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> Message-ID: <67646qF2mqc8pU1@mid.uni-berlin.de> Dennis Lee Bieber schrieb: > On Mon, 21 Apr 2008 19:05:46 -0400, python at bdurham.com declaimed the > following in comp.lang.python: > >> I thought one of the major features of Python 2.5 was its embedded >> SQLite engine. >> > No, just the inclusion of the adapter became standard... The > packagers of Windows installers include the SQLite3 DLL as it isn't a > commonly available item... But many Linux versions probably include it > as an option during the OS install. AFAIK thats wrong. On my ubuntu gutsy for example, I find this: deets at absinth:~$ find /usr/lib/python2.5/ | grep -i sqlite /usr/lib/python2.5/lib-dynload/_sqlite3.so /usr/lib/python2.5/site-packages/pysqlite-2.3.2.egg-info /usr/lib/python2.5/site-packages/pysqlite2 /usr/lib/python2.5/site-packages/pysqlite2/__init__.py /usr/lib/python2.5/site-packages/pysqlite2/__init__.pyc /usr/lib/python2.5/site-packages/pysqlite2/_sqlite.so /usr/lib/python2.5/site-packages/pysqlite2/dbapi2.py /usr/lib/python2.5/site-packages/pysqlite2/dbapi2.pyc /usr/lib/python2.5/sqlite3 /usr/lib/python2.5/sqlite3/__init__.py ... As you can see, stock 2.5 ships with its OWN version of sqlite, and I additionally installed the pysqlite-wrapper for whatever reason I now can't remember. Diez From wizzardx at gmail.com Sun Apr 27 15:09:42 2008 From: wizzardx at gmail.com (David) Date: Sun, 27 Apr 2008 21:09:42 +0200 Subject: design choice: multi-threaded / asynchronous wxpython client? In-Reply-To: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: <18c1e6480804271209j676aa3adnf67e31f10d9007c1@mail.gmail.com> > 3) I need to dump this data (for all races, not just current about to > start race) to text files, store it as BLOBs in a DB *and* update real > time display in a wxpython windowed client. A few important questions: 1) How real-time must the display be? (should update immediately after you get new XML data, or is it ok to update a few seconds later?). 2) How much data is being processed at peak? (100 records a second, 1000?) 3) Does your app need to share fetched data with other apps? If so, how? (read from db, download HTML, RPC, etc). 4) Does your app need to use data from previous executions? (eg: if you restart it, does it need to have a fully populated UI, or can it start from an empty UI and start updating as it downloads new XML updates). How you answer the above questionss determines what kind of algorithm will work best. David. PS: I suggest that you contact the people you're downloading the XML from if you haven't already. eg: it might be against their TOS to constantly scrape data (I assume not, since they provide XML). You don't want them to black-list your IP address ;-). Also, maybe they have ideas for efficient data retrieval (eg: RSS feeds). From rpdooling at gmail.com Sat Apr 5 21:48:27 2008 From: rpdooling at gmail.com (Rick Dooling) Date: Sat, 5 Apr 2008 18:48:27 -0700 (PDT) Subject: Recursively Backup Directories References: Message-ID: On Apr 5, 6:56 pm, misceveryth... at gmail.com wrote: > What I would like to do > is recursively backup the specified directories . . . > but be able to specify exclusion directories (which copytree does > not appear to allow you to do). My initial thoughts were I'll > probably have to use os.path.walk for the backup source directory, but > I'm not sure how to go from there. Thanks in advance. There's a nice Python Cookbook recipe. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/191017 I think the one in the book is newer and better http://tinyurl.com/5vr4n6 And the Cookbook is my favorite way to learn Python. rd From ragia11 at hotmail.com Thu Apr 17 03:09:44 2008 From: ragia11 at hotmail.com (ragia) Date: Thu, 17 Apr 2008 00:09:44 -0700 (PDT) Subject: regular expressions an text string Message-ID: <359c5f43-9520-4f33-b49e-45b5256f7169@a22g2000hsc.googlegroups.com> hi i have to match text string char by char to a regular expressions tht just allow digits 0-9 if other thing a ppear it shall be replaced with space.how can i do that any help? so far i have the string and can read it using a for loop...but how to match each char with the regular expressions and save the result into other string or replace it with space in that other string to have new one.. I a new in python ,thatnks in advance From meisnernel73884 at gmail.com Wed Apr 30 06:38:00 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:38:00 -0700 (PDT) Subject: vws crack Message-ID: <9b43198a-3554-443c-9853-30e3e0c81ceb@m36g2000hse.googlegroups.com> vws crack http://crack.cracksofts.com From bvidinli at gmail.com Fri Apr 18 05:45:03 2008 From: bvidinli at gmail.com (bvidinli) Date: Fri, 18 Apr 2008 12:45:03 +0300 Subject: Fwd: is file open in system ? - other than lsof In-Reply-To: References: <66p6o2F2korm2U1@mid.individual.net> Message-ID: <36e8a7020804180245k68d4d5b3y8901bed3e82cba01@mail.gmail.com> the idea of eg does not work for me because, what i do: get list of files, check 1st file open ? process 1st file, (this may take several seconds... ) check 2nd file open? i have to check it here, because 2nd file may be opened while i process file 1 process 2nd file, (this may take several seconds... ) and so on.. .... in this case, having list of open files at begining of processes is useless... anyway thanks. ---------- Forwarded message ---------- From: Nick Craig-Wood Date: 17.Nis.2008 19:30 Subject: Re: is file open in system ? - other than lsof To: python-list at python.org Thomas Guettler wrote: > bvidinli schrieb: > > is there a way to find out if file open in system ? - > > please write if you know a way other than lsof. because lsof if slow for me. > > i need a faster way. > > i deal with thousands of files... so, i need a faster / python way for this. > > thanks. > > On Linux there are symlinks from /proc/PID/fd to the open > files. You could use this: > > #!/usr/bin/env python > import os > pids=os.listdir('/proc') > for pid in sorted(pids): > try: > int(pid) > except ValueError: > continue > fd_dir=os.path.join('/proc', pid, 'fd') > for file in os.listdir(fd_dir): > try: > link=os.readlink(os.path.join(fd_dir, file)) > except OSError: > continue > print pid, link Unfortunately I think that is pretty much exactly what lsof does so is unlikely to be any faster! However if you have 1000s of files to check you only need to do the above scan once and build a dict with all open files in whereas lsof will do it once per call so that may be a useful speedup. Eg ------------------------------------------------------------ import os pids=os.listdir('/proc') open_files = {} for pid in sorted(pids): try: int(pid) except ValueError: continue fd_dir=os.path.join('/proc', pid, 'fd') try: fds = os.listdir(fd_dir) except OSError: continue for file in fds: try: link=os.readlink(os.path.join(fd_dir, file)) except OSError: continue if not os.path.exists(link): continue open_files.setdefault(link, []).append(pid) for link in sorted(open_files.keys()): print "%s : %s" % (link, ", ".join(map(str, open_files[link]))) ------------------------------------------------------------ You might want to consider http://pyinotify.sourceforge.net/ depending on exactly what you are doing... -- Nick Craig-Wood -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From hopeorpha308 at gmail.com Sun Apr 27 07:43:38 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:43:38 -0700 (PDT) Subject: bookworm crack Message-ID: <241f0e70-2e37-4036-9bc1-900ae1b5d5aa@w74g2000hsh.googlegroups.com> bookworm crack http://wga-cracks.crackkey.net From fennelllindy8241 at gmail.com Mon Apr 28 03:23:45 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:23:45 -0700 (PDT) Subject: call od duty 4 crack download Message-ID: <239f06f8-3a78-4fe9-b33f-75e568c8b279@f24g2000prh.googlegroups.com> call od duty 4 crack download http://crack.cracksofts.com From pavlovevidence at gmail.com Sat Apr 26 11:43:19 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Sat, 26 Apr 2008 08:43:19 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> Message-ID: <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> On Apr 26, 11:10 am, n00m wrote: > Both codes below read the same huge(~35MB) text file. > In the file > 1000000 lines, the length of each line < 99 chars. > > Stable result: > Python runs ~0.65s > C : ~0.70s > > Any thoughts? Yes. Most of the dirty work in the Python example is spent in tight loop written in C. This is very likely to be faster on Python on Windows than your "C" example for several reasons: 1. Python is compiled with Microsoft's C compiler, which produces more optimal code than Mingw. 2. The Python readline() function has been in the library for a long time and has had time for many developers to optimize it's performance. 3. Your "pure C" code isn't even C, let alone pure C. It's C++. On most systems, the C++ iostream libraries have a lot more overhead than C's stdio. And, finally, we must not fail to observe that you measured these times without startup, which is obviousy much greater for Python. (Of course, we only need to point this so it's not misunderstood that you're claiming this Python process will terminate faster than the C++ one.) So, I must regrettably opine that your example isn't very meaningful. > import time > t=time.time() > f=open('D:\\some.txt','r') > z=f.readlines() > f.close() > print len(z) > print time.time()-t > m=input() > print z[m] > > #include > #include > #include > #include > > using namespace std; > char vs[1002000][99]; > FILE *fp=fopen("D:\\some.txt","r"); > > int main() { > int i=0; > while (true) { > if (!fgets(vs[i],999,fp)) break; > ++i; > } > fclose(fp); > cout << i << endl; > cout << clock()/CLOCKS_PER_SEC << endl; > > int m; > cin >> m; > cout << vs[m]; > system("pause"); > return 0; > > } From george.sakkis at gmail.com Wed Apr 2 10:31:15 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 2 Apr 2008 07:31:15 -0700 (PDT) Subject: Self-referencing decorator function parameters References: <88b2c61e-8cf1-4ac0-a5d4-c968d009b544@c65g2000hsa.googlegroups.com> Message-ID: <232b144b-9e09-4baf-9e87-88b6a1d1fb07@b5g2000pri.googlegroups.com> On Apr 2, 8:30?am, Thomas Dimson wrote: > Hello, > > Originally I posted this as a bug but it was shot down pretty quickly. > I am still mildly curious about this as I'm missing a bit of > understanding of Python here. Why is it that the following code > snippet: > > def decorator( call ): > ? ? def inner(func): > ? ? ? ? def application( *args, **kwargs ): > ? ? ? ? ? ? call(*args,**kwargs) > ? ? ? ? ? ? func(*args,**kwargs) > ? ? ? ? return application > > ? ? return inner > > class DecorateMe: > ? ? @decorator( call=DecorateMe.callMe ) > ? ? def youBet( self ): > ? ? ? ? pass > > ? ? def callMe( self ): > ? ? ? ? print "Hello!" > > DecorateMe().youBet() > > Will not compile, giving: > Traceback (most recent call last): > ? File "badpython.py", line 10, in > ? ? class DecorateMe: > ? File "badpython.py", line 11, in DecorateMe > ? ? @decorator( call=DecorateMe.callMe ) > NameError: name 'DecorateMe' is not defined > > Where if you change the "call=DecorateMe.callMe" to "call=lambda x: > DecorateMe.callMe(x)" everything goes along its merry way. Nesting the > call in a lambda seems to allow it to recognize the class definition. > Any ideas as to what is going on here (other than ugly code)? The error message is pretty obvious; when the "@decorator(call=DecorateMe.callMe)" line is reached, the DecorateMe class has not been created yet, let alone the DecorateMe.callMe method. One way to make it work (for some definition of "work" ;-) is the following: # use "new-style" classes unless you have a good reason not to: # class DecorateMe(object): class DecorateMe: def callMe(self): print "Hello!" @decorator(call=callMe) def youBet(self): pass The reason this works is that at the point where @decorator is executed, callMe is already in the temporary namespace to be used for creating the DecorateMe class (although the class itself is not built yet). A subtle point is that in this case callMe is a plain function, not an (unbound) method such as DecorateMe.callMe. This may or may not matter, depending on what you do with it in the decorator. Some decorators that work fine with plain functions break if they are used to decorate methods (or vice versa) so it's good to have this in mind when writing or debugging a decorator. George From eatham at gmail.com Fri Apr 11 16:42:22 2008 From: eatham at gmail.com (Roger Dahlstrom) Date: Fri, 11 Apr 2008 13:42:22 -0700 (PDT) Subject: Windows - window status (Running vs Not Responding) References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> Message-ID: <6a7ddeb2-78ce-4409-8894-cdf72fc2ac51@m73g2000hsh.googlegroups.com> On Apr 11, 3:46 pm, Tim Golden wrote: > rdahlstrom wrote: > > On Apr 11, 1:45 pm, rdahlstrom wrote: > >> Does anyone know how to determine the window status (Running or Not > >> Responding)? I've tried various methods with no success... > > >> This would be on a variety of Windows systems, but all at least XP, > >> and mostly server 2003. Everyone will have Python 2.5.1 on them, and > >> the script would be running locally. > > >> Any ideas? > > > Basically, I'm looking for something similar to the Process.Responding > > property in System.Diagnostics... > > Well one (slightly drastic) possibility might be to use IronPython [1] > or Python.NET [2] to invoke the .Net functionality directly. AFAIK there > is no direct alternative: I believe that WMI can be a useful match > for System.Diagnostics but doesn't deal with windows (ie user-interface > elements). Presumably you could find a top-level window for each > process, using something vaguely like this [3] coupled with this [4] > and send it a suitable SendMessage to "ping" it. Haven't done it myself > but can't see why it shouldn't work. > > All a bit handwavey but maybe it'll point you somewhere... > > TJG > > [1]http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython > [2]http://pythonnet.sourceforge.net/ > [3]http://timgolden.me.uk/python/wmi_cookbook.html#running_processes > [4]http://timgolden.me.uk/python/win32_how_do_i/find-the-window-for-my-s... I had actually contemplated using ctypes and linking the .dll directly, but even though I'm running 32 bit Python, some of the machines that I want to run this on are 64 bit windows, so it doesn't work. If I get desperate, I'll check out IronPython, but I'd really like to stay (as much as possible) with our standard package (2.5.1 with wmi/win32) From Shawn at Milochik.com Fri Apr 18 11:23:08 2008 From: Shawn at Milochik.com (Shawn Milochik) Date: Fri, 18 Apr 2008 11:23:08 -0400 Subject: Checking for unique fields: performance. Message-ID: <2dc0c81b0804180823k46a220f1w77a166e6b08f67de@mail.gmail.com> I'm looping through a tab-delimited file to gather statistics on fill rates, lengths, and uniqueness. For the uniqueness, I made a dictionary with keys which correspond to the field names. The values were originally lists, where I would store values found in that field. Once I detected a duplicate, I deleted the entire element from the dictionary. Any which remained by the end are considered unique. Also, if the value was empty, the dictionary element was deleted and that field considered not unique. A friend of mine suggested changing that dictionary of lists into a dictionary of dictionaries, for performance reasons. As it turns out, the speed increase was ridiculous -- a file which took 42 minutes to run dropped down to six seconds. Here is the excerpt of the bit of code which checks for uniqueness. It's fully functional, so I'm just looking for any suggestions for improving it or any comments. Note that fieldNames is a list containing all column headers. #check for unique values #if we are still tracking that field (we haven't yet #found a duplicate value). if fieldUnique.has_key(fieldNames[index]): #if the current value is a duplicate if fieldUnique[fieldNames[index]].has_key(value): #sys.stderr.write("Field %s is not unique. Found a duplicate value after checking %d values.\n" % (fieldNames[index], lineNum)) #drop the whole hash element fieldUnique.__delitem__(fieldNames[index]) else: #add the new value to the list fieldUnique[fieldNames[index]][value] = 1 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dikkie at nospam.org Thu Apr 17 06:12:17 2008 From: dikkie at nospam.org (Dikkie Dik) Date: Thu, 17 Apr 2008 12:12:17 +0200 Subject: about a head line In-Reply-To: References: Message-ID: <48072281$0$30667$bf4948fe@news.tele2.nl> Penny Y. wrote: > I saw some scripts have a line at its begin: > > # encoding:gb2312 > > what's this? Why need it? thanks. > My guess is that it is the automatic work of some sort of editor that does not understand how encodings work. See what happens if the file was utf-16le encoded, for example. I think you can safely remove it. From sturlamolden at yahoo.no Sat Apr 19 20:33:42 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sat, 19 Apr 2008 17:33:42 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <48074f58$0$4916$e4fe514c@dreader32.news.xs4all.nl> <6002cb46-f48a-421d-a4ff-5b23bf2f9d77@2g2000hsn.googlegroups.com> <39fd7905-4835-43bb-928b-82622ed628c1@m3g2000hsc.googlegroups.com> Message-ID: On Apr 19, 10:29 pm, "sjdevn... at yahoo.com" wrote: > FWIW, NT's POSIX subsytem fork() uses (or used to use) the NULL > SectionHandle method and was POSIX certified, so it's certainly > possible. Windows Vista Ultimate comes with Interix integrated, renamed 'Subsystem for Unix based Applications' or SUA for short. Interix is even UNIX certified when a C compiler is installed. Windows also has a OS/2 subsystem which has a COW fork. Yes it is possible. One may wonder why the Win32 subsystem don't have this feature. Perhaps fork() is unfriendly to threads, like fork on Linux used to be (or is?) pthread unfriendly. Or perhaps M$ (MegaDollar) just did this to be mean. I don't know. I see the lack of fork() in Win32 as one of the major shortcomings of Windows. Anyhow, I just downloaded the WDK which supersedes the DDK. The examples in Nebbet's book do not build anymore, as there are invalid C in the WDK header files. :-( From mail2spj at yahoo.com Fri Apr 18 16:09:20 2008 From: mail2spj at yahoo.com (SPJ) Date: Fri, 18 Apr 2008 13:09:20 -0700 (PDT) Subject: No subject Message-ID: <581282.70773.qm@web50110.mail.re2.yahoo.com> I am writing a script which need's to convert an excel file to csv (text) format. For that I am using the following code: excel = win32com.client.Dispatch("Excel.Application","Quit") workbook = excel.Workbooks.Open(xlsfile) workbook.SaveAs(csvfile, FileFormat=24) # 24 represents xlCSVMSDOS workbook.Close(False) excel.Quit() I did not have any problem running this script on a windows xp machine with python 2.5.2 and windows extensions. But I get the following error when I run the same script on a windows 2003 server with the same python and windows extension installation: excel = win32com.client.Dispatch("Excel.Application","Quit") File "D:\Python25\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "D:\Python25\lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "D:\Python25\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147221005, 'Invalid class string', None, None) I verified that installation is same. Any idea's as to what might be the problem? One thing I have noticed though is I can't see Microsoft office 11.0 object library when I do combrowse on windows 2003 server. I also to tried to reinstall python and windows extension. But still no luck. I would appreciate if anyone can guide me as to why this is happening and how to resolve this. Thanks, SPJ ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ From jcd at unc.edu Fri Apr 18 11:48:38 2008 From: jcd at unc.edu (J. Cliff Dyer) Date: Fri, 18 Apr 2008 11:48:38 -0400 Subject: Another MySQL Images Question In-Reply-To: <4dc0cfea0804180813o32ed2c82o9c3f68b1a607348d@mail.gmail.com> References: <4dc0cfea0804180813o32ed2c82o9c3f68b1a607348d@mail.gmail.com> Message-ID: <1208533718.4748.16.camel@aalcdl07.lib.unc.edu> There are several problems with your SQL, but not all of them would be caught by the computer. Your SELECT statement is not parameterized. This is a security problem. *Always* parameterize your variables. Your UPDATE statement has an extraneous comma at the end, and it also has quotes around the "%s"es that you don't need, because you already parameterized that query. Your dbapi interface will provide appropriate quoting for whatever type of data you pass it. Cheers, Cliff On Fri, 2008-04-18 at 10:13 -0500, Victor Subervi wrote: > Hi; > If I grab an image in the database thus: > > sql = "select pic1 from products where id='" + str(id) + "';" > cursor.execute(sql) > pic1 = cursor.fetchall()[0][0].tostring() > # pic1 = cursor.fetchall()[0][0] // either this or the above > line > > and try and re-insert it thus: > > cursor.execute('update products set pic1="%s" where id="%s", ;', > (pic1, id)) > > it tells me I have an error in my MySQL syntax. What is the error? > TIA, > Victor -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill From steve at holdenweb.com Sat Apr 5 10:54:06 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 10:54:06 -0400 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> Message-ID: llothar wrote: [...] > Unfortunately there is no python.core mailing list that i know so i > ask here. > Well your researches can't have been that extensive: the developers live on python-dev at pythonlorg, otherwise known as comp.land.python-dev. But you will need to ask your question rather more carefully there to het a meaningful answer. Good luck. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From breily at gmail.com Mon Apr 14 03:43:34 2008 From: breily at gmail.com (Brian) Date: Mon, 14 Apr 2008 03:43:34 -0400 Subject: Java or C++? In-Reply-To: References: Message-ID: On Mon, Apr 14, 2008 at 3:24 AM, bdsatish wrote: > On Apr 14, 12:21 pm, Bob Martin wrote: > > in 342367 20080414 074410 s0s... at gmail.com wrote: > > > > >Hello, I was hoping to get some opinions on a subject. I've been > > >programming Python for almost two years now. Recently I learned Perl, > > >but frankly I'm not very comfortable with it. Now I want to move on > > >two either Java or C++, but I'm not sure which. Which one do you think > > >is a softer transition for a Python programmer? Which one do you think > > >will educate me the best? > > > > Certainly Java. It's also easier to find Java jobs than C++ jobs. > > -- > http://mail.python.org/mailman/listinfo/python-list > It may be easier to find Java jobs, but learning C++ will increase your understanding of computers a lot more than Java. Mainly in the area of memory management - C++ pointers really force you to understand whats going on below the surface. If you're not locked in to learning on those, I would suggest learning Lisp instead - it'll make you a better python programmer. -------------- next part -------------- An HTML attachment was scrubbed... URL: From cokofreedom at gmail.com Tue Apr 29 10:44:45 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Tue, 29 Apr 2008 07:44:45 -0700 (PDT) Subject: Issue with regular expressions References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> <5a75ea66-2cbb-4c41-8351-a35a70554d8d@i76g2000hsf.googlegroups.com> Message-ID: <9f2686cc-14ba-4a8e-b3a6-3cb98e3a5bba@m45g2000hsb.googlegroups.com> | # ---- Double Quote Text ---- | " # match a double quote | ( # - Two Possiblities: | \\. # match two backslashes followed by anything (include newline) | | # OR | [^"] # do not match a single quote | )* # - from zero to many | " # finally match a double quote | | | # ======== OR ======== | | # ---- Single Quote Text ---- | ' # match a single quote | ( # - Two Possiblities: | \\. # match two backslashes followed by anything (include newline) | | # OR | [^'] # do not match a single quote | )* # - from zero to many | ' # finally match a single quote | """, DOTALL|VERBOSE) Used this before (minus those | at the beginning) to find double quotes and single quotes in a file (there is more to this that looks for C++ and C style quotes but that isn't needed here), perhaps you can take it another step to not do changes to these matches? r""""(\\.|[^"])*"|'(\\.|[^'])*'""", DOTALL) is it in a single line :) From paul at subsignal.org Tue Apr 8 15:49:40 2008 From: paul at subsignal.org (paul) Date: Tue, 08 Apr 2008 21:49:40 +0200 Subject: Running a python code periodically In-Reply-To: References: Message-ID: Maryam Saeedi schrieb: > Hi, > > I was wondering if you know how can I run a python code once every five > minutes for a period of time either using python or some other program like > a bash script. See the sched module in the standard library or here: http://pypi.python.org/simple/Recur/ cheers Paul From sevenjp at gmail.com Wed Apr 2 16:54:33 2008 From: sevenjp at gmail.com (=?ISO-8859-1?Q?Jo=E3o_Neves?=) Date: Wed, 2 Apr 2008 13:54:33 -0700 (PDT) Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> <10ee2a69-f4e2-4887-8083-6b02b60dd0cd@i7g2000prf.googlegroups.com> Message-ID: On 2 Abr, 21:38, "Chris Mellon" wrote: > On Wed, Apr 2, 2008 at 2:33 PM, Jo?o Neves wrote: > > On Apr 2, 5:41 pm, "Dan Upton" wrote: > > > > The thing I've been wondering is why _is_ it read-only? In what > > > > circumstances having write access to co_code would break the language > > > > or do some other nasty stuff? > > > > > Jo?o Neves > > > > I can't speak to Python's implementation in particular, but > > > self-modifying code in general is unpleasant. It certainly is > > > possible to support it in runtime environments, but it's usually not > > > easy to do so. That is, of course, somewhat dependent on the > > > implementation of the runtime environment, and even to some degree the > > > underlying hardware. (For instance, the compiled code you want to run > > > could be in the hardware cache; if you then change the instructions at > > > those addresses in memory, it's not always straightforward to get the > > > processor to realize it needs to load the new data into the > > > instruction cache.) Plus, I suppose it might be possible to break > > > strong (even dynamic) typing if you start changing the code around > > > (although I can't construct an example off the top of my head). > > > Indeed, the caching issue is a relevant one I guess, and adding the > > mechanism to go around that might have a significant impact on > > performance. > > I haven't looked in detail into it, but I agree with your opinion > > concerning strong and dynamic typing. If type check is done while > > compiling to bytecode, there is no guarantee the modified bytecode > > will respect the rules, for instance. I don't know though, haven't > > really checked how it's done at this point. :) > > I will be fiddling around with the Python VM these days anyway, and > > since I'm going to muck around the bytecode, I might just try to see > > the effects of removing the read-only restriction from co_code. > > There is no need to overwrite co_code. Create a new code object with > your desired bytecode and use that instead. Yes, it may work (haven't tested - isn't there any problem with stuff like co_name, for instance?), but for simplicity's sake, wouldn't it be far more convenient if you could just write over co_code? :) In the end, it's all a matter of convenience, I guess. From bockman at virgilio.it Mon Apr 28 03:37:35 2008 From: bockman at virgilio.it (bockman at virgilio.it) Date: Mon, 28 Apr 2008 00:37:35 -0700 (PDT) Subject: error: (10035, 'The socket operation... References: Message-ID: <2b9b1aea-2fc2-49fb-b5ed-2ccdad718305@j22g2000hsf.googlegroups.com> On 28 Apr, 01:01, Don Hanlen wrote: > IDLE internal error in runcode() > Traceback (most recent call last): > ? File "C:\PYTHON25\lib\idlelib\rpc.py", line 235, in asyncqueue > ? ? self.putmessage((seq, request)) > ? File "C:\PYTHON25\lib\idlelib\rpc.py", line 332, in putmessage > ? ? n = self.sock.send(s[:BUFSIZE]) > error: (10035, 'The socket operation could not complete without > blocking') > > Does this look familiar to anyone? ?I can't figure out what to do > about it. ?Python 2.5, windoze. ?I get it when I execute a Tkinter op > that works elsewhere. > > changing this: > > t = self.b.create_text( > ? ? (point.baseX + 1)*self.checkerSize/2 + fudge, > ? ? y + fudge, > ? ? text = str(point.occupied), > ? ? width = self.checkerSize) > > to > > t = self.b.create_text( > ? ? (point.baseX + 1)*self.checkerSize/2 + fudge, > ? ? y + fudge, > ? ? text = str(point.occupied), > ? ? font=("Times", str(self.checkerSize/2), "bold"), > ? ? width = self.checkerSize) > > for example. ?The same code works fine elsewhere. ?I thought I'd ask > here before I try (no clue) increasing BUFSIZE in rpc.py? ?I'm not > crazy about tinkering with code I have no clue about.. > -- > don The error is EWOULDBLOCK, which you get when you configure a socket for asynchronous I/O and then try an operation which cannot be completed immediately. It is not an actual failure, it is part of the asynch socket handling issues: it means that you have to wait and try later. AFAIK (almost nothing) the Tkinter application has two processes (maybe the front-end and the interpreter) which communicate through a socket. From the traceback, I world say that the two processes communicate using RPC protocol and the rpclib module, and that this in turns uses the asyncqueue module, and one of them fails handling the EWOULDBLOCK code. I don't think that increasing BUFSIZE would solve the problem, since you will try to send more bytes in a single operation, and this would probably still result in an EWOULDBLOCK return code. Anyway, it looks like an IDLE problem, so if you can use another IDE ( Pythonwin? ), you could just ignore it, maybe submit a bug report ? Ciao ----- FB From ptmcg at austin.rr.com Sun Apr 6 12:25:35 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Sun, 6 Apr 2008 09:25:35 -0700 (PDT) Subject: Presumably an import is no faster or slower than opening a file? References: <47f8d30f$0$761$bed64819@news.gradwell.net> Message-ID: On Apr 6, 8:41?am, tinn... at isbd.co.uk wrote: > I'm trying to minimise the overheads of a small Python utility, I'm > not really too fussed about how fast it is but I would like to > minimise its loading effect on the system as it could be called lots > of times (and, no, I don't think there's an easy way of keeping it > running and using the same copy repeatedly). > > It needs a configuration file of some sort which I want to keep > separate from the code, is there thus anything to choose between a > configuration file that I read after:- > > ? ? f = open("configFile", 'r') > > ... and importing a configuration written as python dictionaries or > whatever:- > > ? ? import myConfig > > -- > Chris Green Chris - The question is less an issue of the file overhead (both must open a file, read its contents, and then close it) than what is done with the file contents afterwards. A config file containing .INI-style or whatever content will need to be parsed into Python data/objects, and likely use Python code to do so. An import will use the Python compiler itself, using optimized compiled C code to do the parsing and data/object construction. But I think you would only see the distinction in a config file of substantial size or complexity. If you think this will make a substantial difference in performance, then code up a test case and time it. In general, I'd say that splitting performance hairs to tip a design choice one way or another is a misguided premature optimization. -- Paul From andrew at acooke.org Thu Apr 17 08:25:33 2008 From: andrew at acooke.org (andrew cooke) Date: Thu, 17 Apr 2008 05:25:33 -0700 (PDT) Subject: Metaprogramming Example References: <930643c6-2d56-4fb0-aee0-a3e79231f09b@24g2000hsh.googlegroups.com> Message-ID: <32472b97-f35a-4408-96f5-2f8c8f92ae56@m73g2000hsh.googlegroups.com> On Apr 17, 7:12 am, "bruno.desthuilli... at gmail.com" wrote: [...] Thanks very much! These are useful pointers. I'll update my code accordingly. At one point you pointed out I didn't need parentheses and I agree - I was using them to avoid having a line continuation backslash (I think I read to do that in a style guide recently). One other question. I had "foo is False" and you said I need equality, which is a good point. However, in any other language "not foo" would be preferable. I was surprised you didn't suggest that (and I'm unsure now why I didn't write it that way myself). Is there some common Python standard that prefers "foo == False" to "not foo"? Thanks, Andrew PS Is there anywhere that explains why Decorators (in the context of functions/methods) are so good? I've read lots of things saying they are good, but no real justification of why. To me it looks more like "re-arranging deck chairs on the Titanic" - you're just moving where the hack happens from one place to another. Is the point that now the hack is more visible and hence modifiable? From shevitz at lanl.gov Wed Apr 30 10:23:12 2008 From: shevitz at lanl.gov (Danny Shevitz) Date: Wed, 30 Apr 2008 14:23:12 +0000 (UTC) Subject: how to convert a multiline string to an anonymous function? References: <67pmdnF2p5fhgU1@mid.uni-berlin.de> <87c29666-f64f-4f3c-97e1-a3d1dccdc49b@s50g2000hsb.googlegroups.com> <9a2dnc3tFZET9oXVnZ2dnUVZ_rqlnZ2d@pdx.net> Message-ID: Thanks All! you've solved my problem. D From ABH at MCHSI.COM Tue Apr 8 12:13:00 2008 From: ABH at MCHSI.COM (Hutch) Date: Tue, 08 Apr 2008 16:13:00 GMT Subject: Python 3.0 new integer division Message-ID: We now have a float result when two integers are divided in the same mannor as 2.4 or 2.5. I can handle that and use the Floor division but a simple question. Why in the world would you round down the last presented digit to a 6 instead of just leaving it along as an 8. For some reason rounding down for a float in Python does not seem correct. IDLE 3.0a4 >>> 12345678901234567890123456789012345678901234567890/345 3.5784576525317586e+46 >>> 12345678901234567890123456789012345678901234567890//345 35784576525317588087314367504383610663481839327 ^ ^| 35784576525317586000000000000000000000000000000 == 3.5784576525317586e+46 From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 3 06:51:08 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 03 Apr 2008 12:51:08 +0200 Subject: who said python can't be obsfucated!? In-Reply-To: References: Message-ID: <47f4b69b$0$19766$426a74cc@news.free.fr> cokofreedom at gmail.com a ?crit : > def s(c):return[]if c==[]else s([_ for _ in c[1:]if _ +s([_ for _ in c[1:]if _>=c[0]]) > > Anyone else got some wonders...? Nothing as bad, but: sig=lambda m:'@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in m.split('@')]) From http Sun Apr 6 13:09:17 2008 From: http (Paul Rubin) Date: 06 Apr 2008 10:09:17 -0700 Subject: Implementation of Crockford's Base32 Encoding? References: <345117e9-2539-4ee0-8b27-9b1a88ddde7c@a1g2000hsb.googlegroups.com> Message-ID: <7x63uukj0i.fsf@ruckus.brouhaha.com> "samslists at gmail.com" writes: > Anyone know of a Python implementation of this: http://www.crockford.com/wrmg/base32.html Is that different from the base32 encoding already in the base64 module? http://docs.python.org/lib/module-base64.html From bignose+hates-spam at benfinney.id.au Fri Apr 18 19:51:48 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Sat, 19 Apr 2008 09:51:48 +1000 Subject: How to print a unicode string? References: Message-ID: <87d4omsovf.fsf@benfinney.id.au> damonwischik at gmail.com writes: > From what I've googled, I think I need to set my locale. I don't > understand how. > > import locale > print locale.getlocale() > --> (None,None) > print locale.getdefaultlocal() > --> ('en_GB','cp1252') > print locale.normalize('en_GB.utf-8') > --> en_GB.UTF8 > locale.setlocale(locale.LC_ALL,'en_GB.UTF8') > --> locale.Error: unsupported locale setting > > I'd be grateful for advice. Just because the locale library knows the normalised name for it doesn't mean it's available on your OS. Have you confirmed that your OS (independent of Python) supports the locale you're trying to set? -- \ "Oh, I love your magazine. My favorite section is 'How To | `\ Increase Your Word Power'. That thing is really, really, | _o__) really... good." -- Homer, _The Simpsons_ | Ben Finney From woodham at cs.ubc.ca Wed Apr 23 14:08:16 2008 From: woodham at cs.ubc.ca (Bob Woodham) Date: Wed, 23 Apr 2008 18:08:16 +0000 (UTC) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> <426812d7-c217-4bfc-81b0-47ba0638a650@k13g2000hse.googlegroups.com> Message-ID: On 2008-04-22, Paul Hankin wrote: > On Apr 22, 5:50?pm, J?r?my Wagner wrote: >> Sure. Python is more readable than Perl, though I have found Python >> to have a weird behavior regarding this little issue : >> >> How can you explain that Python doesn't support the ++ opeator, >> whereas at the same time it does support the += operator ??? >> >> No python developer I know has been able to answer that. > > Because ++ is of limited use and has poor readability? > > 'x++' vs 'x += 1' saves 3 characters and is less readable. In addition, the statement x = x++; has unspecified behaviour in C. That is, it is not specified whether the value of x after execution of the statement is the old value of x or one plus the old value of x. From Robert.Bossy at jouy.inra.fr Mon Apr 14 08:48:47 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Mon, 14 Apr 2008 14:48:47 +0200 Subject: Process multiple files In-Reply-To: <2323A6D37908A847A7C32F1E3662C80E017BDF37@dc1ex01.air.org> References: <2323A6D37908A847A7C32F1E3662C80E017BDF37@dc1ex01.air.org> Message-ID: <480352AF.3080704@jouy.inra.fr> Doran, Harold wrote: > Say I have multiple text files in a single directory, for illustration > they are called "spam.txt" and "eggs.txt". All of these text files are > organized in exactly the same way. I have written a program that parses > each file one at a time. In other words, I need to run my program each > time I want to process one of these files. > > However, because I have hundreds of these files I would like to be able > to process them all in one fell swoop. The current program is something > like this: > > sample.py > new_file = open('filename.txt', 'w') > params = open('eggs.txt', 'r') > do all the python stuff here > new_file.close() > > If these files followed a naming convention such as 1.txt and 2.txt I > can easily see how these could be parsed consecutively in a loop. > However, they are not and so is it possible to modify this code such > that I can tell python to parse all .txt files in a certain directory > and then to save them as separate files? For instance, using the example > above, python would parse both spam.txt and eggs.txt and then save 2 > different files, say as spam_parsed.txt and eggs_parsed.txt. > Hi, It seems that you need glob.glob() : http://docs.python.org/lib/module-glob.html#l2h-2284 import glob for txt_filename in glob.glob('/path/to/the/dir/containing/your/files/*.txt'): print txt_filename # or do your stuff with txt_filename RB From sierra9162 at gmail.com Wed Apr 16 11:25:35 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:25:35 -0700 (PDT) Subject: kate hudson snl Message-ID: <67c10ec3-baf2-4598-a992-e8340796e763@d45g2000hsc.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From stefan_ml at behnel.de Mon Apr 7 02:03:24 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 07 Apr 2008 08:03:24 +0200 Subject: Parsing HTML? In-Reply-To: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> References: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> Message-ID: <47F9B92C.1030802@behnel.de> Benjamin wrote: > I'm trying to parse an HTML file. I want to retrieve all of the text > inside a certain tag that I find with XPath. The DOM seems to make > this available with the innerHTML element, but I haven't found a way > to do it in Python. import lxml.html as h tree = h.parse("somefile.html") text = tree.xpath("string( some/element[@condition] )") http://codespeak.net/lxml Stefan From paddy3118 at googlemail.com Thu Apr 17 14:19:03 2008 From: paddy3118 at googlemail.com (Paddy) Date: Thu, 17 Apr 2008 11:19:03 -0700 (PDT) Subject: How to make this unpickling/sorting demo faster? References: <40a5d8f1-a246-4c48-8759-5b65324f9029@m73g2000hsh.googlegroups.com> Message-ID: <493d67b3-ea8f-4662-86fc-c764a7d47a02@8g2000hse.googlegroups.com> On Apr 17, 6:15 pm, Steve Bergman wrote: > I'm involved in a discussion thread in which it has been stated that: > > """ > Anything written in a language that is > 20x slower (Perl, Python, > PHP) than C/C++ should be instantly rejected by users on those grounds > alone. > """ > THe above is applied slavishly by those who value machine time over peoples time. Do you want to work with them? - Paddy. From cokofreedom at gmail.com Thu Apr 10 08:07:15 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Thu, 10 Apr 2008 05:07:15 -0700 (PDT) Subject: How to find documentation about methods etc. for iterators References: <47fce941$0$755$bed64819@news.gradwell.net> <47fdceb8$0$754$bed64819@news.gradwell.net> Message-ID: > > This for me is Python's chief selling point: dir()....dir() and > help(). Python's two selling points are dir(), help(), and very > readable code. Python's *three* selling points are dir(), > help(), very readable code, and an almost fanatical devotion to > the BFDL. Amongst Python's selling points are such elements as > dir(), help()...I'll come in again.
> This brought a smile to my face :) From stefan_ml at behnel.de Tue Apr 22 07:34:39 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 22 Apr 2008 13:34:39 +0200 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> Message-ID: <480DCD4F.8090002@behnel.de> GD wrote: > Please remove ability to multiple inheritance in Python 3000. > > Multiple inheritance is bad for design, rarely used and contains many > problems for usual users. Ah, one more: "doctor, when I do this, it hurts!" - "then don't do that!" Stefan From bignose+hates-spam at benfinney.id.au Sat Apr 19 03:05:45 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Sat, 19 Apr 2008 17:05:45 +1000 Subject: Inheritance confusion References: <4809932c$0$12307$c3e8da3@news.astraweb.com> Message-ID: <8763uel3xy.fsf@benfinney.id.au> Hook writes: > I'm having a problem with multiple inheritance You aren't alone. Multiple inheritance (MI) is difficult to implement, and once implemented, usually difficult to understand and sometimes counterintuitive. I recommend you read and absorb the article "The Truth about super" to understand more about MI in Python. However, there are more fundamental issues: > I've got 4 files That should be irrelevant to MI problems. Please refine your example so that it's in one module, and still exhibits the problem. > When I run the script I get this: > > Traceback (most recent call last): > File "./3.py", line 20, in > Obj.Connect ('Database') > File "/mnt/isis/Projects/Python/Learning/DB_m.py", line 102, in Connect > self.TRACE ("DB::Connect (" + database + "," + mode) > File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 314, in TRACE > self.DailyLog (msg) > File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 98, in > DailyLog > dt = self.Date (time ()) > TypeError: 'module' object is not callable No, you don't. That might be what you get from *your* code, but it's not produced by the code you *posted*. (I know this if only because none of your modules have a line 98 on which to raise an exception.) So, since we don't have the code that generates that traceback, that traceback isn't useful to us for diagnosing the problem. > If you need to see all the source, can do, but it's certainly too > much for an intro message! Indeed. Instead, re-work your code (based on a copy) until it's as simple as it can be, and *still* shows the problems when you execute it. Then, if you still don't know why the traceback occurs, feel free to post that minimal example with the corresponding traceback. -- \ "Jury: A group of 12 people, who, having lied to the judge | `\ about their health, hearing, and business engagements, have | _o__) failed to fool him." -- Henry L. Mencken | Ben Finney From grflanagan at gmail.com Fri Apr 11 08:05:37 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Fri, 11 Apr 2008 05:05:37 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: On Apr 11, 12:14 pm, bdsatish wrote: > The built-in function round( ) will always "round up", that is 1.5 is > rounded to 2.0 and 2.5 is rounded to 3.0. > > If I want to round to the nearest even, that is > > my_round(1.5) = 2 # As expected > my_round(2.5) = 2 # Not 3, which is an odd num > > I'm interested in rounding numbers of the form "x.5" depending upon > whether x is odd or even. Any idea about how to implement it ? ------------------------------------------------ def myround(x): n = int(x) if abs(x - n) == 0.5: if n % 2: #it's odd return n + 1 - 2 * int(n<0) else: return n else: return round(x) assert myround(3.2) == 3 assert myround(3.6) == 4 assert myround(3.5) == 4 assert myround(2.5) == 2 assert myround(-0.5) == 0.0 assert myround(-1.5) == -2.0 assert myround(-1.3) == -1.0 assert myround(-1.8) == -2 assert myround(-2.5) == -2.0 ------------------------------------------------ From toddw at activestate.com Tue Apr 15 20:52:30 2008 From: toddw at activestate.com (Todd Whiteman) Date: Tue, 15 Apr 2008 17:52:30 -0700 Subject: Gecko 1.9 In-Reply-To: References: Message-ID: <48054DCE.3070909@activestate.com> Joe P. Cool wrote: > In 2005 I heard of plans to add Python as a second language to the > Gecko engine. Is this still true? Or has this plan been abandoned? > You can use Python inside of Mozilla (Gecko) based applications now, such as Firefox/Thunderbird/Komodo Edit/XulRunner which communicate through the Mozilla XPCOM architecture. There are builds of PyXPCOM (Python XPCOM) that can be downloaded and easily installed through the xpi extension mechanism, see: http://pyxpcomext.mozdev.org/ The Mozilla 1.9 branch (Gecko 1.9) also contains the hooks necessary to be able to use Python as a script handler, instead of having to use JavaScript. This is commonly referred to as PyDOM. To get and use PyXPCOM (Mozilla 1.8 and Mozilla 1.9): * install the above extension * or make your own build of the Mozilla application To get and use PyDOM (Mozilla 1.9): * you'll need to make your own build of the Mozilla application I'm the one working on the PyXPCOM extension, which I am hoping will eventually contain the PyDOM module as well (once I get around to making new Mozilla builds with this enabled). Cheers, Todd From wheaties.box at gmail.com Mon Apr 14 03:29:04 2008 From: wheaties.box at gmail.com (Josh) Date: Mon, 14 Apr 2008 00:29:04 -0700 (PDT) Subject: Different times between Python and System Message-ID: Hi, Anyone know why python would not show the same time that my system shows? user at computer:~$ date Mon Apr 14 01:27:36 MDT 2008 user at computer:~$ python Python 2.4.5 (#2, Mar 12 2008, 00:15:51) [GCC 4.2.3 (Debian 4.2.3-2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import datetime >>> datetime.datetime.now() datetime.datetime(2008, 4, 14, 1, 27, 50, 472350) Thanks! From skanemupp at yahoo.se Sun Apr 20 19:24:04 2008 From: skanemupp at yahoo.se (globalrev) Date: Sun, 20 Apr 2008 16:24:04 -0700 (PDT) Subject: question about the mainloop Message-ID: <52de38c4-3d1e-4be0-9b58-5d60317f1ef7@b1g2000hsg.googlegroups.com> in C?? java etc there is usually: procedure 1 procedure 2 procedure 3 main { procedure 1 procedure 2 procedure 3 } i dont get the mainloop() in python. i mean i have written some programs, for example a calculator using tkinterGUI. if i have some functions i wanna call to run the program and i wanna call them ina specific order and be able to call them from each other should this just be called in the mainloop and the mianloop then runs the "mainscript" top to bottom over and over? From ott.deb at gmail.com Thu Apr 17 15:06:14 2008 From: ott.deb at gmail.com (ott.deb at gmail.com) Date: Thu, 17 Apr 2008 12:06:14 -0700 (PDT) Subject: server 2003 activation crack Message-ID: server 2003 activation crack http://cracks.12w.net F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Fri Apr 25 21:13:26 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 25 Apr 2008 22:13:26 -0300 Subject: Pyserial - send and receive characters through linux serial port References: Message-ID: En Fri, 25 Apr 2008 20:22:37 -0300, terry escribi?: > I am trying to send a character to '/dev/ttyS0' and expect the same > character and upon receipt I want to send another character. I tired > with Pyserial but in vain. I assume you have a device attached to /dev/ttyS0 that echoes back the received characters? > Test Set up: > > 1. Send '%' to serial port and make sure it reached the serial port. > 2. Once confirmed, send another character. > > I tried with write and read methods in Pyserial but no luck. Check the communication parameters (baud rate, parity, etc.), cable, connectors, your device... AFAIK a lot of people is using pyserial so I'd look the problem elsewhere. Try posting a short code example showing your problem. -- Gabriel Genellina From billingspanshism at gmail.com Sat Apr 19 17:17:06 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:17:06 -0700 (PDT) Subject: victoria beckham background Message-ID: Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From corvettecraz92 at gmail.com Tue Apr 8 21:44:56 2008 From: corvettecraz92 at gmail.com (corvettecraz92 at gmail.com) Date: Tue, 8 Apr 2008 18:44:56 -0700 (PDT) Subject: text adventure game problem References: Message-ID: <6e247b5c-a58d-4e4e-a67a-c21d36061cf0@z38g2000hsc.googlegroups.com> On Apr 8, 9:25?pm, Andr? wrote: > On Apr 8, 10:01?pm, corvettecra... at gmail.com wrote: > > > > > okay, I'm having this one problem with a text adventure game. It's > > kind of hard to explain, but I'll do my best. > > [code] > > > def prompt_kitchen(): > > ? ? global gold > > ? ? gold_taken = False > > ? ? while True: > > ? ? ? ? prompt_kit = raw_input('>') > > ? ? ? ? if prompt_kit == 'examine cabinet 1' and not gold_taken: > > ? ? ? ? ? ? print '''This cabinet has a lot of cups in it with all > > different > > designs and shapes. Where are the people anyway? How come there's > > nobody here? > > In one of the cups you find 8 gold.''' > > ? ? ? ? ? ? gold = gold+8 > > ? ? ? ? ? ? gold_taken = True > > ? ? ? ? ? ? pass4() > > ? ? ? ? elif prompt_kit == 'examine cabinet 1' and gold_taken: > > ? ? ? ? ? ? print \ > > ? ? ? ? ? ? ? ? ? '''This cabinet has a lot of cups in it with all > > different > > designs and shapes. Where are the people anyway? How come there's > > nobody here?''' > > ? ? ? ? ? ? pass4() > > > def pass4(): > > ? ? global gold > > ? ? print 'You have', gold, 'gold' > > ? ? pass > > [/code] > > > Okay, now for my problem. > > In the above function, there's the option to examine a cabinet and get > > 8 gold. (everyone here knows that...but I'm just trying to state my > > problem...) > > Unfortunately, it kind of doesn't work. > > After the first time I 'examine cabinet 1' in my game, I get 8 gold > > and I can't get it again. > > But, If I leave the room and come back to it, then it's as if I had > > never gotten the gold the first time, and I can get it again. > > How do I fix this? > > quick guess: define gold_taken as a global variable and initialize it > outside of the function. > > Warning: avoid global variables if at all possible. > > ;-) > Andr? Here's a sample code that, in fact, does work. In this code, when run, I can only get the gold once. def prompt_house(): global gold gold_taken = False while True: prompt_hou = raw_input('>') if prompt_hou == 'examine table' and not gold_taken: print \ '''There are a lot of car magazines here. You flip through them and find 5 gold. ''' gold = gold+5 gold_taken = True elif prompt_hou == 'go west': # this gets you out of the loop go_west() # more elif choices here ... elif prompt_hou == 'examine table' and gold_taken: print '''There are a lot of car magazines here.''' go_west() def go_west(): # just a dummy funk global gold print gold pass # test gold = 0 prompt_house() But what's the difference between this and the one that I posted? From sjmachin at lexicon.net Mon Apr 14 17:27:27 2008 From: sjmachin at lexicon.net (John Machin) Date: Mon, 14 Apr 2008 14:27:27 -0700 (PDT) Subject: py2exe, program has stoped working!? References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> <232151d6-09ed-4a1e-9922-d66c2bf0d05b@w8g2000prd.googlegroups.com> Message-ID: <67526f9f-a610-4cbe-8e2c-6219a59a4d54@i36g2000prf.googlegroups.com> On Apr 15, 4:08 am, Steve Holden wrote: > John Machin wrote: > > > By the way, "popup" is what you get in a web browser. What did this > > "popup" look like: a panel from your GUI software? A Windows message > > box? Did it have a title across the top? What was the exact text in > > the popup/panel/box? Were there any options other than to close the > > window? > > > FYI "xxx has stopped working" is Vista's "user-friendly" way of > reporting what Windows 3 would probably have called a "General Program > Fault". So I found by googling "has stopped working". I'd never seen such a litany of weeping, wailing and u'\u02ad' before. > It pretty much hides all useful information fro the end-user, > perhaps on the grounds that end users wouldn't know what to do with the > information it *could* provide anyway. Thanks for the info, Steve. Sounds like it's even worse than its predecessor in Windows XP. Cheers, John From jzshao1 at gmail.com Wed Apr 16 09:36:14 2008 From: jzshao1 at gmail.com (Jonathan Shao) Date: Wed, 16 Apr 2008 09:36:14 -0400 Subject: Interesting timing issue I noticed Message-ID: *Gabriel Genellina* gagsl-py2 at yahoo.com.ar *Wed Apr 16 08:44:10 CEST 2008* > Another thing would be to rearrange the loops so the outer one executes less times; if you know that borderX< From s0suk3 at gmail.com Tue Apr 29 16:12:57 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Tue, 29 Apr 2008 13:12:57 -0700 (PDT) Subject: Simple import question about mac osx References: Message-ID: <7e99034b-78ac-4ffd-b273-f5d7489f85de@t54g2000hsg.googlegroups.com> On Apr 29, 2:17 pm, jmDesktop wrote: > On Apr 29, 2:37 pm, "Jerry Hill" wrote: > > > > > On Tue, Apr 29, 2008 at 2:14 PM, jmDesktop wrote: > > > Thanks. That worked on mac. But it does work like I said in > > > Windows. Don't know why. Mr. Chun must also be using Windows because > > > that is the way he does it in his book. > > > It shouldn't work that way on windows either. Can you tell us a > > little more about what you mean when you say you "compile this" under > > windows? Normally, python code doesn't need to be compiled, so I'm > > wondering if you're doing something different from what we expect when > > you say you compile it and then import it in the interpreter. > > > Are you by any chance writing code in IDLE, running it, then doing > > things in the interpreter? > > > -- > > Jerry > > On Windows I took the text file I created on mac with vi and opened it > in PythonWin. I ran it. It compiled. I run the import and call from > the python interpreter. Well, Python compiles automatically any .py file that you import. Of course this isn't machine code like the one from a C compiled executable. It's Python's own bytecode. But normally you shouldn't worry about that bytecode; actually, you shouldn't even be paying attention to it. All that concerns you is that you created a module and that you can import it. Leave the whole "compiling" concept to the interpreter. From ptmcg at austin.rr.com Tue Apr 29 10:26:07 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Tue, 29 Apr 2008 07:26:07 -0700 (PDT) Subject: list.reverse() References: Message-ID: <98306bd8-e41c-4fd0-beee-6ef5c6018e44@w74g2000hsh.googlegroups.com> On Apr 28, 1:12?pm, Mark Bryan Yu wrote: > This set of codes works: > > >>> x = range(5) > >>> x.reverse() > >>> x > > [4, 3, 2, 1, 0] > You can also use list slicing to get a reversed list: >>> x = range(5) >>> x [0, 1, 2, 3, 4] >>> x[::-1] [4, 3, 2, 1, 0] -- Paul From deets at nospam.web.de Sat Apr 26 14:44:09 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Sat, 26 Apr 2008 20:44:09 +0200 Subject: Calling Python code from inside php In-Reply-To: References: <679e9oF2mti63U1@mid.uni-berlin.de> <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> Message-ID: <67hbgjF2om9g0U1@mid.uni-berlin.de> Eric Wertman schrieb: >> > A simple yet dangerous and rather rubbish solution (possibly more of a >> > hack than a real implementation) could be achieved by using a >> > technique described above: >> > >> > > > echo exec('python foo.py'); >> >> This will spawn a Python interpreter, and not be particularly >> efficient. You could just as well have used CGI. > > I'm in a bit of a similar situation. I decided to use python to > solve problems where I could, in a more regimented fashion. For > instance, I have a set of functions in a script, table.py. After I > set up mod_python to handle requests to a single directory with > python, I can call this with: > > > > embedded in the page. This is probably pretty hackish too, but at > least it doesn't spawn a new process, and I don't have to solve things > that aren't related to display with php. You mean opening a local-loop socket instead of a anonymous socket, hogging at least another apache process and then possibly spawning another process if the python-script is implemented as real CGI - not fast_cgi or python - is the better solution? I doubt that. More wasteful in all aspects, with small to any gain at all. Unix uses pipes as IPC all the time. I fail to see why that is "rubbish". Diez From guillermo.listas at googlemail.com Mon Apr 21 07:57:00 2008 From: guillermo.listas at googlemail.com (Guillermo) Date: Mon, 21 Apr 2008 04:57:00 -0700 (PDT) Subject: Opposite of repr() (kind of) References: Message-ID: <546f6b82-c537-4f17-86a4-e6ea2c34e965@w5g2000prd.googlegroups.com> This must be the dumbest question ever... Solved. On Apr 21, 1:05 pm, Guillermo wrote: > Hi there, > > How can I turn a string into a callable object/function? > > I have a = 'len', and I want to do: if callable(eval(a)): print > "callable", but that doesn't quite work the way I want. :) > > Regards, > > Guillermo From steven.p.clark at gmail.com Tue Apr 8 11:15:07 2008 From: steven.p.clark at gmail.com (Steven Clark) Date: Tue, 8 Apr 2008 11:15:07 -0400 Subject: list.sort(): heaviest item? Message-ID: <663744510804080815y2eda80d2m9e34da2893e99de0@mail.gmail.com> If I have a list of items of mixed type, can I put something into it such that after a list.sort(), is guaranteed to be at the end of the list? Looking at http://www.python.org/doc/2.3.5/ref/comparisons.html "Most other types compare unequal unless they are the same object; the choice whether one object is considered smaller or larger than another one is made arbitrarily but consistently within one execution of a program." makes me unsure. It looks like "None" always ends up at the start ("lightest"), but I want the opposite ("heaviest"). -Steven From alkundry at gmail.com Thu Apr 24 02:40:26 2008 From: alkundry at gmail.com (ABDULLAH) Date: Wed, 23 Apr 2008 23:40:26 -0700 (PDT) Subject: DO YOU KNOW ANY THING ABOUT ISLAM??? Message-ID: <2429a87a-34e8-4294-9a25-b54dd2cf6791@m73g2000hsh.googlegroups.com> What you are about to read might sound unusual but it could be very enlightened. So I would be thankful if you give my article 5 minute of your value time. THANK YOU Islam is a total system of living. A Muslim is supposed to live in peace and harmony with all these segments; hence, a Muslim is any person anywhere in the world whose obedience, allegiance, and loyalty are to God, the Lord of the Universe. The legal sources of Islam are the Qur'an and the Hadith. The Qur'an is the exact word of God; its authenticity, originality and totality are intact. The Hadith is the report of the sayings, deeds and approvals of the Prophet Muhammad. The Prophet's sayings and deeds are called Sunnah. The Seerah is the writings of followers of Muhammad about the life of the Prophet. Hence, it is the life history of the Prophet Muhammad which provides examples of daily living for Muslims. Muslims are required to respect all those who are faithful and God conscious people, namely those who received messages. Christians and Jews are called People of the Book. Muslims are asked to call upon the People of the Book for common terms, namely, to worship One God, and to work together for the solutions of the many problems in the society. Some Basic Islamic Beliefs 1) Belief in God: Muslims believe in one, unique, incomparable God, Who has no son nor partner, and that none has the right to be worshipped but Him alone. He is the true God, and every other deity is false. He has the most magnificent names and sublime perfect attributes. No one shares His divinity, nor His attributes. In the Quran, God describes Himself: Say, ?He is God, the One. God, to Whom the creatures turn for their needs. He begets not, nor was He begotten, and there is none like Him.? (Quran, 112:1-4) Chapter 112 of the Quran written in Arabic calligraphy. No one has the right to be invoked, supplicated, prayed to, or shown any act of worship, but God alone. God alone is the Almighty, the Creator, the Sovereign, and the Sustainer of everything in the whole universe. He manages all affairs. He stands in need of none of His creatures, and all His creatures depend on Him for all that they need. He is the All- Hearing, the All-Seeing, and the All-Knowing. In a perfect manner, His knowledge encompasses all things, the open and the secret, and the public and the private. He knows what has happened, what will happen, and how it will happen. No affair occurs in the whole world except by His will. Whatever He wills is, and whatever He does not will is not and will never be. His will is above the will of all the creatures. He has power over all things, and He is able to do everything. He is the Most Gracious, the Most Merciful, and the Most Beneficent. In one of the sayings of the Prophet Muhammad , we are told that God is more merciful to His creatures than a mother to her child.1 God is far removed from injustice and tyranny. He is All-Wise in all of His actions and decrees. If someone wants something from God, he or she can ask God directly without asking anyone else to intercede with God for him or her. God is not Jesus, and Jesus is not God.2 Even Jesus himself rejected this. God has said in the Quran: Indeed, they have disbelieved who have said, ?God is the Messiah (Jesus), son of Mary.? The Messiah said, ?Children of Israel, worship God, my Lord and your Lord. Whoever associates partners in worship with God, then God has forbidden Paradise for him, and his home is the Fire (Hell). For the wrongdoers,3 there will be no helpers.? (Quran, 5:72) God is not a trinity. God has said in the Quran: Indeed, they disbelieve who say, ?God is the third of three (in a trinity),? when there is no god but one God. If they desist not from what they say, truly, a painful punishment will befall the disbelievers among them. Would they not rather repent to God and ask His forgiveness? For God is Oft-Forgiving, Most Merciful. The Messiah (Jesus), son of Mary, was no more than a messenger... (Quran, 5:73-75) Islam rejects that God rested on the seventh day of the creation, that He wrestled with one of His angels, that He is an envious plotter against mankind, or that He is incarnate in any human being. Islam also rejects the attribution of any human form to God. All of these are considered blasphemous. God is the Exalted. He is far removed from every imperfection. He never becomes weary. He does not become drowsy nor does he sleep. The Arabic word Allah means God (the one and only true God who created the whole universe). This word Allah is a name for God, which is used by Arabic speakers, both Arab Muslims and Arab Christians. This word cannot be used to designate anything other than the one true God. The Arabic word Allah occurs in the Quran about 2700 times. In Aramaic, a language related closely to Arabic and the language that Jesus habitually spoke,4 God is also referred to as Allah. 2) Belief in the Angels: Muslims believe in the existence of the angels and that they are honored creatures. The angels worship God alone, obey Him, and act only by His command. Among the angels is Gabriel, who brought down the Quran to Muhammad . 3) Belief in God?s Revealed Books: Muslims believe that God revealed books to His messengers as proof for mankind and as guidance for them. Among these books is the Quran, which God revealed to the Prophet Muhammad . God has guaranteed the Quran?s protection from any corruption or distortion. God has said: Indeed, We have sent down the Quran, and surely We will guard it (from corruption). (Quran, 15:9) 4) Belief in the Prophets and Messengers of God: Muslims believe in the prophets and messengers of God, starting with Adam, including Noah, Abraham, Ishmael, Isaac, Jacob, Moses, and Jesus (peace be upon them). But God?s final message to man, a reconfirmation of the eternal message, was revealed to the Prophet Muhammad . Muslims believe that Muhammad is the last prophet sent by God, as God has said: Muhammad is not the father of any one of your men, but he is the Messenger of God and the last of the prophets... (Quran, 33:40) Muslims believe that all the prophets and messengers were created human beings who had none of the divine qualities of God. 5) Belief in the Day of Judgment: Muslims believe in the Day of Judgment (the Day of Resurrection) when all people will be resurrected for God?s judgment according to their beliefs and deeds. 6) Belief in Al-Qadar: Muslims believe in Al-Qadar, which is Divine Predestination, but this belief in Divine Predestination does not mean that human beings do not have freewill. Rather, Muslims believe that God has given human beings freewill. This means that they can choose right or wrong and that they are responsible for their choices. The belief in Divine Predestination includes belief in four things: 1) God knows everything. He knows what has happened and what will happen. 2) God has recorded all that has happened and all that will happen. 3) Whatever God wills to happen happens, and whatever He wills not to happen does not happen. 4) God is the Creator of everything. For more information about Islam http://www.islam-guide.com/ From steve at holdenweb.com Thu Apr 17 04:12:00 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 17 Apr 2008 04:12:00 -0400 Subject: I just killed GIL!!! In-Reply-To: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: sturlamolden wrote: > Hello Guys... > > I just had one moment of exceptional clarity, during which realized > how I could get the GIL out of my way... It's so simple, I cannot help > wondering why nobody has thought of it before. Duh! Now I am going to > sit and and marvel at my creation for a while, and then go to bed > (it's past 2:30 a.m.) Tomorrow I will contemplate whether to sell this > little secret for big bucks, give it away for free, or just keep it to > myself... :-) > > Now you are probably thinking I reinvented the gunpowder, and are > running multiple processes. Not so. I am not running parallel > processes, like parallel python or the processing module in cheese > shop. I am running multiple THREADS. In fact, I am just using > threading.Thread. The source code is pure Python, so there is no C > magic, and I only used the stuff that's already there in the standard > library. So, I just made CPython do what everyone claim to be > impossible. One single process of CPython is using all the cpu power > of my dual-core laptop. > Quick, write it down before the drugs wear off. Sorry. I'm definitely a skeptic on this story. Put up or shut up. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Fri Apr 25 16:42:03 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Fri, 25 Apr 2008 22:42:03 +0200 Subject: problem with unicode References: <26fcc207-b864-42c7-afb3-c6945e5fe29f@m44g2000hsc.googlegroups.com> <67dvg8F2nomm6U1@mid.individual.net> Message-ID: <67eu0rF2ogf6qU1@mid.individual.net> John Machin wrote: > On Apr 25, 10:01 pm, Bjoern Schliessmann > >>> media="x???[?" >> >>> print repr(media.decode("utf-8")) >> >> u'x\u30ef\u30e6\u30ed[\u30e8' (dang, KNode doesn't autodetect encodings ...) > But that_unicode_string.encode("utf-8") produces > 'x\xe3\x83\xaf\xe3\x83\xa6\xe3\x83\xad[\xe3\x83\xa8' > which does not contain the complained-about byte 0x9c in position > 1 (or any other position) -- how can that be? Probably the OP used a different encoding. That seems even more likely given the fact that his postings have a Japanese encoding (but this one doesn't produce any 0x9c, either). Regards, Bj?rn -- BOFH excuse #346: Your/our computer(s) had suffered a memory leak, and we are waiting for them to be topped up. From lists at cheimes.de Sat Apr 12 10:59:17 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 12 Apr 2008 16:59:17 +0200 Subject: str(bytes) in Python 3.0 In-Reply-To: <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> Message-ID: <4800CE45.1030407@cheimes.de> Carl Banks schrieb: > I believe the Zen in effect here is, "In the face of ambiguity, refuse > the temptation to guess." How do you know if the bytes are utf-8 > encoded? Indeed > I'm not sure if str() returning the repr() of a bytes object (when not > passed an encoding) is the right thing, but it's probably better than > throwing an exception. The problem is, str can't decide whether it's > a type conversion operator or a formatted printing function--if it > were strongly one or the other it would be a lot more obvious what to > do. I was against it and I also wanted to have 'egg' == b'egg' raise an exception but I was overruled by Guido. At least I was allowed to implement the byte warning feature (-b and -bb arguments). I *highly* recommend that everybody runs her unit tests with the -bb option. Christian From bwljgbwn at gmail.com Tue Apr 22 05:52:48 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:52:48 -0700 (PDT) Subject: getright pro keygen Message-ID: <750fafee-fe3e-4c0c-8888-38a92b1552d9@m36g2000hse.googlegroups.com> getright pro keygen http://cracks.12w.net F R E E C R A C K S From balta96428 at gmail.com Wed Apr 23 05:54:37 2008 From: balta96428 at gmail.com (balta96428 at gmail.com) Date: Wed, 23 Apr 2008 02:54:37 -0700 (PDT) Subject: cat6 patch cables Message-ID: <7c2561ed-97dc-4f51-adf0-42f7ae50816b@24g2000hsh.googlegroups.com> cat6 patch cables http://cracks.12w.net F R E E C R A C K S From mdw at distorted.org.uk Sun Apr 6 17:10:17 2008 From: mdw at distorted.org.uk (Mark Wooding) Date: Sun, 6 Apr 2008 21:10:17 +0000 (UTC) Subject: sine in python References: Message-ID: Astan Chee wrote: > I have a math function that looks like this > sin (Theta) = 5/6 > How do I find Theta (in degrees) in python? import math theta = math.asin(5/6) * 180/math.pi -- [mdw] From kyosohma at gmail.com Tue Apr 15 09:03:24 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 15 Apr 2008 06:03:24 -0700 (PDT) Subject: hw to program on python References: <2732d09a-b0e6-4ae6-a826-9fa375fb3e86@q10g2000prf.googlegroups.com> Message-ID: <5e788345-2a4f-43f6-9b5a-28ad5a7196ff@k13g2000hse.googlegroups.com> On Apr 15, 7:47 am, ashish wrote: > hi , > python experts i want some help from u people just mail me how to > write scripts for web applications (like form coding for login page, > etc). > > i m waiting.... for ur reply by > have a nice day! I suggest you start by going to the Python website and going through some of the tutorials found there: www.python.org. When you're done, check out one of the Python Web Frameworks: Pylons, Django, TurboGears, or Zope/Plone. There are also books on the subject, such as Holden's "Python Web Programming" or Thiruvathukal's "Web Programming in Python", as well as more general books that include examples of web programming, including the Python Cookbook and Lutz's "Programming Python". Mike From goldenlaks at gmail.com Mon Apr 7 11:26:40 2008 From: goldenlaks at gmail.com (TAJMAHAL TEMPLE) Date: Mon, 7 Apr 2008 08:26:40 -0700 (PDT) Subject: WORLD TOURSIM WORLD TRAVEL WORLD PACKAGE Message-ID: <7b44c78e-c6f6-4105-ad67-f4bf9854da65@u36g2000prf.googlegroups.com> Freee... Freee.... Freeee.... http://sai-tourism-package.blogspot.com/ From ceres83 at gmail.com Mon Apr 21 04:05:30 2008 From: ceres83 at gmail.com (Mario Ceresa) Date: Mon, 21 Apr 2008 10:05:30 +0200 Subject: Pickle problem In-Reply-To: <933a2b55-7a99-4061-9dc0-4de657448f1c@s50g2000hsb.googlegroups.com> References: <933a2b55-7a99-4061-9dc0-4de657448f1c@s50g2000hsb.googlegroups.com> Message-ID: Dear Jerry and George: it works like a charm! I always thought that the first way was a quicker alternative to defining the init method... shame on me! >From now on I'll read the list every day repeating to myself: "Premature optimization is the root of all evil", "Premature optimization is the root of all evil", .... :) Thanks a lot, Mario On Fri, Apr 18, 2008 at 8:00 PM, George Sakkis wrote: > On Apr 18, 11:55 am, "Mario Ceresa" wrote: > > Hello everybody: > > I'd like to use the pickle module to save the state of an object so to > > be able to restore it later. The problem is that it holds a list of > > other objects, say numbers, and if I modify the list and restore the > > object, the list itself is not reverted to the saved one, but stays > > with one element deleted. > > > > An example session is the following: > > > > Data is A [1, 2, 3, 4] > > saving a with pickle > > Deleting an object: del a[3] > > Now data is A [1, 2, 3] > > Oops! That was an error: can you please recover to the last saved data? > > A [1, 2, 3] #### I'd like to have here A[1,2,3,4]!!!!!! > > > > Is it the intended behavior for pickle? if so, are there any way to > > save the state of my object? > > > > Code follows > > ----------------------- > > class A(object): > > objects = [] > > ----------------------- > > then I run the code: > > --------------------------------------- > > import pickle > > from core import A > > > > a = A() > > > > for i in [1,2,3,4]: > > a.objects.append(i) > > > > savedData = pickle.dumps(a) > > print "Saved data is ",a > > print "Deleting an object" > > del a.objects[3] > > print a > > print "Oops! This was an error: can you please recover the last saved data?" > > > > print pickle.loads(savedData) > > -------------------------------------------- > > > > Thank you for any help! > > > > Mario > > The problem is that the way you define 'objects', it is an attribute > of the A *class*, not the instance you create. Change the A class to: > > > class A(object): > def __init__(self): > self.objects = [] > > and rerun it; it should now work as you intended. > > HTH, > George > -- > http://mail.python.org/mailman/listinfo/python-list > From bruno.desthuilliers at gmail.com Wed Apr 23 15:53:23 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 23 Apr 2008 12:53:23 -0700 (PDT) Subject: Python development tools References: Message-ID: <09992de9-39fa-4ee6-8009-35732f3433fb@y21g2000hsf.googlegroups.com> On 23 avr, 19:39, "wongjoek... at yahoo.com" wrote: > Are there any completely free developent tools for python scripts like > IDLE. I have used IDLE , but I want to try out others also. I saw > stuff like PyCrust, but I don't see that it can run the script as > well. > Thanks, emacs + python-mode (the one from Python, not the horror that ships with recent emacs versions) + ecb (Emacs code browser) No bells and whistles, no clickodrom, but one of the most powerful combo you can get. But be warned: learning and configuring emacs is not for wheenies !-) From Lie.1296 at gmail.com Thu Apr 17 15:35:25 2008 From: Lie.1296 at gmail.com (Lie) Date: Thu, 17 Apr 2008 12:35:25 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> <01db54ab-1fca-4a51-8b98-510de224f40a@y21g2000hsf.googlegroups.com> <8e6dbc15-98f2-441d-bba4-d9ddb36f482d@i36g2000prf.googlegroups.com> Message-ID: <6f0edb21-9930-4c5f-b5fa-60e1a1d6dd29@a23g2000hsc.googlegroups.com> On Apr 13, 7:20 pm, Steve Holden wrote: > Lie wrote: > > On Apr 12, 3:44 am, hdante wrote: > [snip] > > > In short, choosing that x.0 is rounded down and x.5 is rounded up is > > arbitrary but not without a reason. > > Don't "arbitrary" and "not without a reason" directly contradict one > another? > The same as choosing between round-half-odd and round-half-even, arbitrary but not without a reason. Language-wise it is a contradiction. In a loose semantic meaning, it means there is no strong reason for choosing one above the other (round-up vs round down and round-half-even vs round-half-odd) but there are slight advantages on one that would seems silly to be mentioned as the main reason, so arbitrary but not without reason. On Apr 13, 9:28 pm, Mark Dickinson wrote: > On Apr 13, 4:18 am, Lie wrote: > [...] > > > it and there is nothing else in it, but in the second number range > > (barely above 1 to 2) the number 1.0 is not included while the number > > 2.0 is contained in it, clearly not a clean separation of numbers in > > the form of y.x where y is pre-determined and x is variable from other > > possible values of y. > > Have you considered the fact that the real numbers of > the form 1.xxxxx... are those in the range [1.0, 2.0], > including *both* endpoints? That is, 2.0 = 1.999999... > Similarly, the midpoint of this range can be written > both in the form 1.500000... and 1.499999... No, you can only include one of the endpoints, because if both endpoints are included, the integers would be a included twice on the various sets of numbers, e.g. in [1.0 - 2.0] and [2.0 - 3.0] the number 2.0 is included in both ranges, you can't be a member of both ranges because that means if you have a "fair" random number generator, the possibility of integral number to appear would be twice the possibility of non-integral numbers, well that's not a fair random number generator isn't it? > This is relevant if you think of rounding as an operation > on *decimal representations* of real numbers rather than > as an operation on real numbers themselves. I'm not sure > which point of view you're taking here. Actually, I'm on the side that think numbers should never be rounded[1], except for a final representation to human viewer who should be made aware that the numbers in the presentation should never be used for further calculation, as they are only informative but not normative. In this view, the exact rounding method is irrelevant as numbers used for calculation are never rounded while at the lower level the amount of change caused by rounding has become irrelevant because of the extra precision used. In short, if the rounding algorithm causes you a trouble in the particular field, increase the precision. [1] As computers do have limitation on storage of real number representation, this statement means that real numbers should be kept as precise as the hardware allows or to use decimal and allow extra precision generously. > Either way, your arguments don't change the fact that the > average rounding error is strictly positive for positive > quantized results, under round-half-away-from-zero. If you include negative numbers, the ARE is zero on round-half-away- from-zero, not in round-up though. From Dodin.Roman at gmail.com Fri Apr 25 04:39:52 2008 From: Dodin.Roman at gmail.com (hellt) Date: Fri, 25 Apr 2008 01:39:52 -0700 (PDT) Subject: Little novice program written in Python References: Message-ID: <0cecfed4-17e7-4e4d-9dbe-3f0ac8316c1f@y21g2000hsf.googlegroups.com> Rog?rio Brito: > Hi, All. > > I'm just getting my feet wet on Python and, just for starters, I'm coding some > elementary number theory algorithms (yes, I know that most of them are already > implemented as modules, but this is an exercise in learning the language idioms). > > As you can see from the code below, my background is in C, without too much > sophistication. > > What I would like is to receive some criticism to my code to make it more > Python'esque and, possibly, use the resources of the computer in a more > efficient way (the algorithm implemented below is the Sieve of Eratosthenes): > my variant of the sieve def GetPrimes(N): arr = [] for i in range(1,N+1): arr.append(i) #Set first item to 0, because 1 is not a prime arr[0]=0 #sieve processing s=2 while s < math.sqrt(N): if arr[s-1] != 0: j = s*s while j <= N: arr[j-1] = 0 j += s s += 1 return [x for x in arr if x != 0] From suzhi18 at googlemail.com Tue Apr 8 09:18:48 2008 From: suzhi18 at googlemail.com (suzhi18 at googlemail.com) Date: Tue, 8 Apr 2008 06:18:48 -0700 (PDT) Subject: makepy.py not working Message-ID: <03e9c33d-d957-4bc0-8568-3a40403eadb9@a70g2000hsh.googlegroups.com> Hallo, I've a problem getting makepy running. When I start the tool on my machine with doubleclick everything is fine. But when I try this in my Code: makepy.py -i "Microsoft Excel 11.0 Object Library(1.5)" I am getting an Syntax Error and command: makepy.py bring me this message on the screen: Traceback (most recent call last): File "", line 1, in NameError: name 'makepy' is not defined Any ideas what I am doing wrong? From aboudouvas at panafonet.gr Mon Apr 14 16:09:40 2008 From: aboudouvas at panafonet.gr (king kikapu) Date: Mon, 14 Apr 2008 13:09:40 -0700 (PDT) Subject: How to make python run faster References: <0baa301a-ec8c-48ef-b30e-f9c80f72e5af@u12g2000prd.googlegroups.com> Message-ID: <68ef0f67-1588-44e5-9c8f-79f929e8df75@b9g2000prh.googlegroups.com> On 14 ???, 16:48, ??? wrote: > I read this article onhttp://kortis.to/radix/python_ext/ > > And I decided to try if it's true. > > I write the program in 4 ways: > > 1. Pure C > 2. Python using C extension > 3. Python using psycho > 4. Pure Python > > And then I used timeit to test the speed of these 4. Unsurprisingly, > the time they cost were: > > 4 > 3 > 2 > 1 > > But I did noticed that 2 is a least 3 times slower than 1, not as fast > as the article stated. > > That's quite weird and I thought maybe it's because I am using > Windows. I did the same test on Linux and I found 2 only uses 1.5 > times of time of 1. > > But, it is still not as fast as 1. I have experimented too with this scenario. My conclusion is that it aint worth it to mess with C. Program only in Python and when the time comes that you want to speed up something, just use Psyco on this. And that will be more than enough. From huayang.xia at gmail.com Fri Apr 11 10:19:52 2008 From: huayang.xia at gmail.com (Huayang Xia) Date: Fri, 11 Apr 2008 07:19:52 -0700 (PDT) Subject: Convert PyIDispatch object to struct IDispatch* References: <90eee1e1-b1cc-48a9-8c09-173e92861f2c@a5g2000prg.googlegroups.com> <83260aaf-b2d7-4857-bd71-a8e7b30c6d70@n14g2000pri.googlegroups.com> Message-ID: On Apr 11, 9:47 am, Tim Golden wrote: > Huayang Xia wrote: > > On Apr 11, 12:15 am, "Gabriel Genellina" > > wrote: > >> En Thu, 10 Apr 2008 18:45:04 -0300, Huayang Xia > >> escribi?: > > >>> I am trying to use ctypes to call dll functions. One of the functions > >>> requires argument "struct IDispatch* ". I do have a PyIDispatch object > >>> in python. How can I convert this "PyIDispatch object" to "struct > >>> IDispatch* "? > >> I think a PyIDispatch object is an IDispatch* itself. > >> But you'll get better answers from the python-win32 list:http://mail.python.org/mailman/listinfo/python-win32 > > >> -- > >> Gabriel Genellina > > > Thanks for the info. > > > To call a dll function, it needs a C style IDispatch*. PyIDispatch is > > a python wrapped one. I found a reference from: > > >http://svn.python.org/projects/ctypes/trunk/comtypes/comtypes/test/te... > > > which shows how to convert C style to python style. Unfortunately i > > need the reversed version. > > > I will post the question to python-win32. > > I've had a quick look at the PyIDispatch source and I can't see any obvious > way in which the underlying IDispatch is exposed. May have missed something, > but it's possible that there's not way out. > > TJG Thanks for the info. I read somewhere that the PyIDispatch is converted to VT_DISPATCH automatically when passed to a C style function call. So from VT_DISPATCH, it should be possible to get the IDispatch. That's only a vague idea. From gherzig at fmed.uba.ar Fri Apr 4 11:27:14 2008 From: gherzig at fmed.uba.ar (Gerardo Herzig) Date: Fri, 04 Apr 2008 12:27:14 -0300 Subject: collecting results in threading app In-Reply-To: <47f64507$0$36354$742ec2ed@news.sonic.net> References: <47f64507$0$36354$742ec2ed@news.sonic.net> Message-ID: <47F648D2.9020000@fmed.uba.ar> John Nagle wrote: >Gerardo Herzig wrote: > > >>Hi all. Newbee at threads over here. Im missing some point here, but cant >>figure out which one. >> >>This little peace of code executes a 'select count(*)' over every table >>in a database, one thread per table: >> >>class TableCounter(threading.Thread): >> def __init__(self, conn, table): >> self.connection = connection.Connection(host=conn.host, >>port=conn.port, user=conn.user, password='', base=conn.base) >> threading.Thread.__init__(self) >> self.table = table >> >> def run(self): >> result = self.connection.doQuery("select count(*) from %s" % >>self.table, [])[0][0] >> print result >> return result >> >> >>class DataChecker(metadata.Database): >> >> def countAll(self): >> for table in self.tables: >> t = TableCounter(self.connection, table.name) >> t.start() >> return >> >> >>It works fine, in the sense that every run() method prints the correct >>value. >>But...I would like to store the result of t.start() in, say, a list. The >>thing is, t.start() returns None, so...what im i missing here? >>Its the desing wrong? >> >> > > 1. What interface to MySQL are you using? That's not MySQLdb. > 2. If SELECT COUNT(*) is slow, check your table definitions. > For MyISAM, it's a fixed-time operation, and even for InnoDB, > it shouldn't take that long if you have an INDEX. > 3. Threads don't return "results" as such; they're not functions. > > >As for the code, you need something like this: > >class TableCounter(threading.Thread): > def __init__(self, conn, table): > self.result = None > ... > > def run(self): > self.result = self.connection.doQuery("select count(*) from %s" % > self.table, [])[0][0] > > > def countAll(self): > mythreads = [] # list of TableCounter objects > # Start all threads > for table in self.tables: > t = TableCounter(self.connection, table.name) > mythreads.append(t) # list of counter threads > t.start() > # Wait for all threads to finish > totalcount = 0 > for mythread in mythreads: # for all threads > mythread.join() # wait for thread to finish > totalcount += mythread.result # add to result > print "Total size of all tables is:", totalcount > > > > John Nagle > > Thanks John, that certanly works. According to George's suggestion, i will take a look to the Queue module. One question about for mythread in mythreads: # for all threads mythread.join() # wait for thread to finish That code will wait for the first count(*) to finish and then continues to the next count(*). Because if is that so, it will be some kind of 'use threads, but execute one at the time'. I mean, if mytreads[0] is a very longer one, all the others will be waiting...rigth? There is an approach in which i can 'sum' after *any* thread finish? Could a Queue help me there? Thanks! Gerardo From hniksic at xemacs.org Mon Apr 28 05:42:45 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Mon, 28 Apr 2008 11:42:45 +0200 Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> Message-ID: <87od7ue2ne.fsf@mulj.homelinux.net> Nick Craig-Wood writes: > What you are missing is that if the recv ever returns no bytes at all > then the other end has closed the connection. So something like this > is the correct thing to write :- > > data = "" > while True: > new = client.recv(256) > if not new: > break > data += new This is a good case for the iter() function: buf = cStringIO.StringIO() for new in iter(partial(client.recv, 256), ''): buf.write(new) data = buf.getvalue() Note that appending to a string is almost never a good idea, since it can result in quadratic allocation. From martin at v.loewis.de Thu Apr 17 17:01:45 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Thu, 17 Apr 2008 23:01:45 +0200 Subject: I just killed GIL!!! In-Reply-To: References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> Message-ID: <4807bab9$0$27007$9b622d9e@news.freenet.de> > An there you have the answer. It's really very simple :-) I'm fairly skeptical that it actually works. If the different Python interpreters all import the same extension module (say, _socket.pyd), windows won't load the DLL twice, but only one time. So you end up with a single copy of _socket, which will have a single copy of socket.error, socket.socket, and so on. The single copy of socket.error will inherit from one specific copy of IOError. So if you import socket in a different interpreter, and raise socket.error there, and try to catch IOError, the exception won't be caught - because *that* IOError is then not a base class of socket.error. A more general approach similar to this one is known as ".NET appdomains" or "Java isolates". It requires the VM to refrain from having any global state, and to associate all "global" state with the appdomain or isolate. Python can't easily support that kind of model, because extension modules have global state all the time. Even if Python supported appdomains, you still wouldn't get any object sharing out of it. As soon as you start to share some object (but not their types), your entire type hierarchy gets messed up. FWIW, Tcl implements this model precisely: Tcl is not thread-safe in itself, but supports a interpreter-per-thread model. I'm also skeptical that this is any better than the GIL. Regards, Martin From yousaf.asad at gmail.com Sun Apr 6 13:46:02 2008 From: yousaf.asad at gmail.com (Dexter) Date: Sun, 6 Apr 2008 10:46:02 -0700 (PDT) Subject: Graph, Math and Stats Online Software Message-ID: have designed and developed Graphing tools and Math/Stats online software that is available on internet. Most of my visitor are from US academia. The list of programs include the following 1. Graphing Rectangular 2D 2. Graphing Rectangular 3D 3. Graphing Polar 4. Graphing 2D Parametric curves 5. Graphing 3D Parametric curves 6. Graphing 3D Parametric surfaces 7. Finding Area under curve (Rectangular) 8. Finding Area under curve (Polar) 9. Finding Area between curves (Rectangular) 10. Finding ArcLength (Rectangular) 11. Finding ArcLength (Parametric) 12 Finding Arc Length (Polar) 13. Finding Differentials f' (x) 14. Finding Volume (Disks) 15. Finding Volume (Washers) 16. Finding Surface Area (Disks) 17. Finding Centroid 18. Probability (Dice) 19. Measures of Central Location and Dispersion 20. Regression Analysis 21. Correlation Analysis All these programs are available on two of my sites 1. http://www.thinkanddone.com 2. http://www.britishcomputercolleges.com From ivan.illarionov at gmail.com Thu Apr 10 16:41:29 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Thu, 10 Apr 2008 13:41:29 -0700 (PDT) Subject: Module Conflicts References: <1592fad3-996b-4f62-ac12-42aff8272c21@8g2000hsu.googlegroups.com> Message-ID: <773d436c-2216-49ac-8e79-ca89618ac32f@q24g2000prf.googlegroups.com> On Apr 11, 12:31 am, Ivan Illarionov wrote: > On Apr 10, 2:33 am, Jose wrote: > > > I have a module named math.py in a package with some class > > definitions. I am trying to import the standard python math module > > inside of math.py but It seems to be importing itself. Is there any > > way around this problem without renaming my math.py file? > > Yes, if you are using Python 2.5 > > from __future__ import absolute import > > after this `import math` will always import standard math module and > `from . import math` will import your module. > > -- > Ivan I should say `from __future__ import absolute_import` And it's relatively easy to do in earlier versions too: create subdirectory `stdmath` with one `__init__.py` file with one line `import math` and than use `from stdmath import math`. and than use From deets at nospam.web.de Thu Apr 24 12:47:54 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 24 Apr 2008 18:47:54 +0200 Subject: NameError: global name 'Response' is not defined In-Reply-To: <1e84807c-aec0-4d04-97a3-1953719f4dc6@8g2000hse.googlegroups.com> References: <1e84807c-aec0-4d04-97a3-1953719f4dc6@8g2000hse.googlegroups.com> Message-ID: <67brugF2najntU1@mid.uni-berlin.de> Lalit schrieb: > Hi > > I am very new to web development. I started with Pylons. I am using > http://www.rexx.com/~dkuhlman/pylons_quick_site.html as reference to > create a sample web page using pylons. > > I got stuck up at step 4.3 i.e when modifying controller to "return > Response('

firstapp default

')" > > I am getting error of : global name > 'Response' is not defined > > It seems I am missing some package. I am not really sure. I installed > python 2.5 and through easy_install imported pakages (pylons). > > Any clues would be appreciated Better ask such questions on the Pylons mailing list. Not that it is inappropriate here - but you will receive better answers because it is more specialized. Anyway, I doubt you miss a package - I'd rather guess you miss an import-statement. Diez From ellingt8877 at gmail.com Mon Apr 28 01:44:30 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:44:30 -0700 (PDT) Subject: 1click dvd copy pro crack Message-ID: 1click dvd copy pro crack http://crack.cracksofts.com From nospam at nospam.blah Tue Apr 29 22:51:14 2008 From: nospam at nospam.blah (JYA) Date: Wed, 30 Apr 2008 12:51:14 +1000 Subject: xml.dom.minidom weirdness: bug? Message-ID: <4817dea2$0$18028$426a34cc@news.free.fr> Hi. I was writing an xmltv parser using python when I faced some weirdness that I couldn't explain. What I'm doing, is read an xml file, create another dom object and copy the element from one to the other. At no time do I ever modify the original dom object, yet it gets modified. Unless I missed something, it sounds like a bug to me. the xml file is simply: full name which I store under the name test.xmltv Here is the code, I've removed everything that isn't applicable to my description. can't make it any simpler I'm afraid: from xml.dom.minidom import Document import xml.dom.minidom def adjusttimezone(docxml, timezone): doc = Document() # Create the base element tv_xml = doc.createElement("tv") doc.appendChild(tv_xml) #Create the channel list channellist = docxml.getElementsByTagName('channel') for x in channellist: #Copy the original attributes elem = doc.createElement("channel") for y in x.attributes.keys(): name = x.attributes[y].name value = x.attributes[y].value elem.setAttribute(name,value) for y in x.getElementsByTagName('display-name'): elem.appendChild(y) tv_xml.appendChild(elem) return doc if __name__ == '__main__': handle = open('test.xmltv','r') docxml = xml.dom.minidom.parse(handle) print 'step1' print docxml.toprettyxml(indent=" ",encoding="utf-8") doc = adjusttimezone(docxml, 1000) print 'step2' print docxml.toprettyxml(indent=" ",encoding="utf-8") Now at "step 1" I will display the content of the dom object, quite natually it shows: full name After a call to adjusttimezone, "step 2" however will show: That's it ! You'll note that at no time do I modify the content of docxml, yet it gets modified. The weirdness disappear if I change the line channellist = docxml.getElementsByTagName('channel') to channellist = copy.deepcopy(docxml.getElementsByTagName('channel')) However, my understanding is that it shouldn't be necessary. Any thoughts on this weirdness ? Thanks Jean-Yves -- They who would give up an essential liberty for temporary security, deserve neither liberty or security (Benjamin Franklin) From paul at boddie.org.uk Thu Apr 24 11:15:55 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Thu, 24 Apr 2008 08:15:55 -0700 (PDT) Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> <480fa6e3$0$34491$742ec2ed@news.sonic.net> Message-ID: On 24 Apr, 16:33, Mike Driscoll wrote: > > This is a legitimate issue and one I don't know how to solve. It would > be nice to have some kind of verification process, but I'm unaware of > anything affordable. If you have any ideas, feel free to express them. It'd be interesting (perhaps amusing) to adopt the infrastructure of one of the GNU/Linux distributions to maintain and distribute packages for Windows users. For a while, I've been tempted to experiment with cross-compilers and to try and produce Windows executables, but for simple Python-only modules, all you'd really need to do to prove the concept is to develop the client-side Windows software (eg. apt-get for Windows) which downloads package lists, verifies signatures, and works out where to put the package contents. Then, you could point your client at the appropriate sources and start obtaining the packages, knowing that there is some level of authenticity in the software you're getting. Of course, a lot of this could be more easily done with Cygwin, even if you disregard Cygwin's own installer, but I imagine that Windows users want the "native" experience. Paul From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Tue Apr 29 09:44:55 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Tue, 29 Apr 2008 15:44:55 +0200 Subject: Simple unicode-safe version of str(exception)? References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> Message-ID: <67on2nF2ol856U1@mid.individual.net> "Martin v. L?wis" wrote: > e is an exception object, not a Unicode object. Er, sure, thanks for pointing that out. At first sight he should substitute "e" with "e.message" then since he tries to convert to string (for display?). Regards, Bj?rn -- BOFH excuse #366: ATM cell has no roaming feature turned on, notebooks can't connect From ch612bunn at gmail.com Sun Apr 27 09:12:09 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:12:09 -0700 (PDT) Subject: anydvd 6.1.7.4 crack Message-ID: <48c6349b-7aa3-49b0-a455-fcebcbfdafa8@27g2000hsf.googlegroups.com> anydvd 6.1.7.4 crack http://wga-cracks.crackkey.net From dave.l.harrison at gmail.com Wed Apr 9 00:34:30 2008 From: dave.l.harrison at gmail.com (David Harrison) Date: Wed, 9 Apr 2008 14:34:30 +1000 Subject: Converting a tuple to a list In-Reply-To: <00ba01c899c5$14528ae0$0a01a8c0@mobile> References: <00ba01c899c5$14528ae0$0a01a8c0@mobile> Message-ID: On 09/04/2008, Gabriel Ibanez wrote: > Hi all .. > > I'm trying to using the map function to convert a tuple to a list, without > success. > > I would like to have a lonely line that performs the same as loop of the > next script: > > ------------------------------------------- > # Conveting tuple -> list > > tupla = ((1,2), (3,4), (5,6)) > > print tupla > > lista = [] > for a in tupla: > for b in a: > lista.append(b) > print lista > ------------------------------------------- > > Any idea ? > > Thanks ... > > # Gabriel Not sure if you were looking for a method that retained the existing nested structure or not, so the following is a recursive way of turning an arbitrarily nested tuple structure into the list based equivalent: a = ((1,2), (3,4), (5,6), (7,(8,9))) def t2l(a): lst = [] for item in a: if type(item) == tuple: lst.append(t2l(item)) else: lst.append(item) return lst print t2l(a) From martin at v.loewis.de Mon Apr 28 18:30:32 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 29 Apr 2008 00:30:32 +0200 Subject: Tremendous slowdown due to garbage collection In-Reply-To: References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> <4814B904.1070804@v.loewis.de> Message-ID: <48165008.4070703@v.loewis.de> > I do not argue that Python's default GC parameters must change -- only > that applications with lots of objects may want to consider a > reconfiguration. That's exactly what I was trying to say: it's not that the parameters are useful for *all* applications (that's why they are tunable parameters), just that the defaults shouldn't change (as the OP was requesting). Regards, Martin From victorsubervi at gmail.com Fri Apr 11 13:46:27 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Fri, 11 Apr 2008 12:46:27 -0500 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> Message-ID: <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> I have worked on this many hours a day for two weeks. If there is an easier way to do it, just take a minute or two and point it out. Have you heard of the Law of Diminishing Returns? I have passed it long ago. I no longer want to waste time trying to guess at what you are trying to tell me. Victor On Fri, Apr 11, 2008 at 8:55 AM, Steve Holden wrote: > Victor Subervi wrote: > > Nope. Do not see it. My ugly stupid way works. I guess I will just > > proceed with that and write my howto accordingly. > > Victor > > > OK, but be prepared for some pretty scathing feedback. You will make it > clear you do not understand the web. I'd suggest a little more reading > first. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gagsl-py2 at yahoo.com.ar Sun Apr 20 04:13:00 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 05:13:00 -0300 Subject: python memory leak only in x86 64 linux References: Message-ID: En Wed, 16 Apr 2008 13:10:42 -0300, rkmr.em at gmail.com escribi?: > This is the code that is causing memory leak in 64 bit python [but not > in 32 bit python].. is something wrong in the code? > > [... Python code using the datetime module ...] >> the memory usage of a python app keeps growing in a x86 64 linux >> continuously, whereas in 32 bit linux this is not the case. Python >> version in both 32 bit and 64 bit linux - 2.6.24.4-64.fc8 >> Python 2.5.1 (r251:54863, Oct 30 2007, 13:45:26) >> >> i isolated the memory leak problem to a function that uses datetime >> module extensively. i use datetime.datetime.strptime, >> datetime.timedelta, datetime.datetime.now methods... In principle pure Python code should have no memory leaks - if there are, they're on Python itself. Maybe this is an allocation problem, not an actual leak; if you can write a program that reproduces the problem, post a bug at http://bugs.python.org -- Gabriel Genellina From vijayakumar.subburaj at gmail.com Mon Apr 14 06:04:27 2008 From: vijayakumar.subburaj at gmail.com (v4vijayakumar) Date: Mon, 14 Apr 2008 03:04:27 -0700 (PDT) Subject: Game design : Making computer play References: Message-ID: On Apr 14, 1:00 pm, v4vijayakumar wrote: ... > I can post initial version of the game (implemented using html/ > javascript) in couple of hours here. The game is here, http://v4vijayakumar.googlepages.com/goats-and-tigers.html From ed at leafe.com Tue Apr 1 10:21:48 2008 From: ed at leafe.com (Ed Leafe) Date: Tue, 1 Apr 2008 09:21:48 -0500 Subject: class super method In-Reply-To: <0eb3ee4e-82e2-419a-8e7b-4931f7b4effa@c26g2000prf.googlegroups.com> References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> <0eb3ee4e-82e2-419a-8e7b-4931f7b4effa@c26g2000prf.googlegroups.com> Message-ID: On Apr 1, 2008, at 8:43 AM, George Sakkis wrote: > Did you follow the links I gave by any chance? With all the gotchas > and rules of how to use it properly, it's far from what I would call > elegant. Please. Anything powerful can be dangerous if used indiscriminately. But in a language that supports multiple inheritance, it is amazingly elegant to use a simple function to create a superclass object for a class with multiple mixins at various levels of the inheritance hierarchy that "just works". Yes, having to specify the current class is a bit of a wart that is being addressed in 3.0, but the approach is still the same. > Pehaps, at least as long as you make sure that all superclasses have a > compatible signature - which in practice typically means accept > arbitrary *args and **kwargs in every class in the hierarchy like your > example. Good luck figuring out what's wrong if it's not used > consistently. See my comment above. If you do not know what you're doing, you shouldn't be doing it. This is not the fault of super(); it's the fault of a poor programmer. And I used generic *args and **kwargs in the method sig since I was using made-up class names and methods. Would you have reacted more favorably if I had used (self, foo, bar) instead? > Also doOurCustomStuffBeforeTheSuperCall() works as long as all > ancestor methods to be called need the same CustomStuff massaging. Oh, c'mon. Of course that's the case; if you are overriding method behavior, it is your job as the programmer to ensure that. Again, this is nothing to do with the super() function, and everything to do with the abilities of the developer. > In a sentence, it's better than nothing but worse than anything. I guess I must be the world's most amazing Python developer, as I've used super() extensively for years without ever suffering any of the pitfalls you and others describe. -- Ed Leafe From gagsl-py2 at yahoo.com.ar Wed Apr 30 03:44:44 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 30 Apr 2008 04:44:44 -0300 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> Message-ID: En Wed, 30 Apr 2008 04:19:22 -0300, SL escribi?: > "Lutz Horn" schreef in bericht > news:mailman.360.1209537877.12834.python-list at python.org... >> >> So just for completion, the solution is: >> >>>>> chr(ord('a') + 1) >> 'b' > > thanks :) I'm a beginner and I was expecting this to be a member of > string so I couldnt find it anywhere in the docs. And that's a very reasonable place to search; I think chr and ord are builtin functions (and not str methods) just by an historical accident. (Or is there any other reason? what's wrong with "a".ord() or str.from_ordinal(65))? -- Gabriel Genellina From cmpython at gmail.com Thu Apr 10 00:25:37 2008 From: cmpython at gmail.com (CM) Date: Wed, 9 Apr 2008 21:25:37 -0700 (PDT) Subject: How is GUI programming in Python? References: Message-ID: <1bee1004-81f5-4460-9451-25caf3738269@b64g2000hsa.googlegroups.com> On Apr 9, 9:54 pm, Chris Stewart wrote: > I've always had an interest in Python and would like to dabble in it > further. I've worked on a few very small command line programs but > nothing of any complexity. I'd like to build a really simple GUI app > that will work across Mac, Windows, and Linux. How painful is that > going to be? I used to be really familiar with Java Swing a few years > ago. I imagine it will be similar. > > Next, what would you say is the best framework I should look into? > I'm curious to hear opinions on that. > > Chris Stewart > cstewart... at gmail.com I've enjoyed using wxPython. Mature, active, native controls, lots o' widgets, killer demo, great community, cross platform (with some tweaking sometimes). From wizzardx at gmail.com Sun Apr 27 11:20:29 2008 From: wizzardx at gmail.com (David) Date: Sun, 27 Apr 2008 17:20:29 +0200 Subject: python and web programming, easy way...? In-Reply-To: <75679853-b5de-42cb-9db2-a1508f2ad67e@59g2000hsb.googlegroups.com> References: <2db36ccf-c9fd-4e7a-9697-fd5c23159287@j22g2000hsf.googlegroups.com> <75679853-b5de-42cb-9db2-a1508f2ad67e@59g2000hsb.googlegroups.com> Message-ID: <18c1e6480804270820s2858cb66m86b668ee48d0fd00@mail.gmail.com> > > www.webpy.org is supereasy to get going with. dont know which is > better for advanced stuff. > I don't think that webpy supports sessions. Their addition to webpy is a Google Summer of Code project: http://webpy.org/sessions/gsoc Also, I can't find any reference to cookies or sessions in the webpy online docs. Maybe it's possible to bolt on support with Python's Cookie module. David. From george.sakkis at gmail.com Thu Apr 24 00:41:18 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 23 Apr 2008 21:41:18 -0700 (PDT) Subject: Problem using copy.copy with my own class References: <676noiF2n7ttmU1@mid.uni-berlin.de> Message-ID: On Apr 23, 9:48?pm, Jeffrey Barish wrote: > > Here it is: > > import copy > > class Test(int): > ? ? def __new__(cls, arg1, arg2): > ? ? ? ? return int.__new__(cls, arg1) > > ? ? def __init__(self, arg1, arg2): > ? ? ? ? self.arg2 = arg2 > > if __name__ == '__main__': > ? ? t = Test(0, 0) > ? ? t_copy = copy.copy(t) First off, inheriting from a basic builtin type such as int and changing its constructor's signature is not typical; you should rethink your design unless you know what you're doing. One way to make this work is to define the special __copy__ method [1], specifying explicitly how to create a copy of a Test instance: class Test(int): ... def __copy__(self): return Test(int(self), self.arg2) The copy.copy() function looks for this special method and invokes it if it's defined. Normally (i.e. for pure Python classes that don't subclass a builtin other than object) copy.copy() is smart enough to know how to create a copy without an explicit __copy__ method, so in general you don't have to define it for every class that has to be copyable. > Traceback (most recent call last): > ? File "copytest.py", line 12, in > ? ? t_copy = copy.copy(t) > ? File "/usr/lib/python2.5/copy.py", line 95, in copy > ? ? return _reconstruct(x, rv, 0) > ? File "/usr/lib/python2.5/copy.py", line 322, in _reconstruct > ? ? y = callable(*args) > ? File "/usr/lib/python2.5/copy_reg.py", line 92, in __newobj__ > ? ? return cls.__new__(cls, *args) > TypeError: __new__() takes exactly 3 arguments (2 given) The traceback is not obvious indeed. It turns out it involves calling the arcane __reduce_ex__ special method [2] defined for int, which returns a tuple of 5 items; the second is the tuple (, 0) and these are the arguments passed to Test.__new__. So another way of fixing it is keep Test.__new__ compatible with int.__new__ by making optional all arguments after the first: class Test(int): def __new__(cls, arg1, arg2=None): return int.__new__(cls, arg1) # don't need to define __copy__ now from copy import copy t = Test(0, 0) assert copy(t) == t As a sidenote, your class works fine without changing anything when pickling/unpickling instead of copying, although pickle calls __reduce_ex__ too: from pickle import dumps,loads t = Test(0, 0) assert loads(dumps(t)) == t Perhaps someone more knowledgeable can explain the subtle differences between pickling and copying here. George [1] http://docs.python.org/lib/module-copy.html [2] http://docs.python.org/lib/node320.html From spamgrinder.trylater at gmail.com Thu Apr 17 10:06:08 2008 From: spamgrinder.trylater at gmail.com (AlFire) Date: Thu, 17 Apr 2008 09:06:08 -0500 Subject: why function got dictionary Message-ID: <48075950.7050000@gmail.com> Hi, I am seeking an explanation for following: Python 2.5.2 (r252:60911, Apr 8 2008, 21:49:41) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def g(): return ... >>> g.__dict__ {} Q: why function got dictionary? What it is used for? Thx, Andy From pavlovevidence at gmail.com Tue Apr 15 09:25:16 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 15 Apr 2008 06:25:16 -0700 (PDT) Subject: text adventure game problem References: Message-ID: <3f1023c9-97c1-40b5-8a28-0b89bf79fba1@c65g2000hsa.googlegroups.com> On Apr 11, 12:08 pm, "Neil Cerutti" wrote: > On Thu, Apr 10, 2008 at 8:25 PM, Carl Banks wrote: > > On Apr 10, 2:20 pm, Tommy Nordgren wrote: > > > > On 9 apr 2008, at 03.01, corvettecra... at gmail.com wrote: > > > > > okay, I'm having this one problem with a text adventure game. It's > > > > kind of hard to explain, but I'll do my best. > > > > [code] > > > > > def prompt_kitchen(): > > > > global gold > > > > Python is not a suitable language for Text Adventure Development. > > > Ridiculous. > > Agreed. "Not suitable" is an exaggeration. However, designing and > implementing your own adventure game framework in Python is a total > waste of time. That depends. > Don't do it excet for the sake of it. > > You can even claim one of several Python-based frameworks out of > mothballs as a starting point, if you want to use Python. > > > There are many good reasons why someone might want to use a general > > purpose language like Python to write a text adventure, > > Yes. > > > such as so > > they're not stuck with a quasi hack of a language if they have to do > > something that doesn't fit the framework anticipated by the language > > designer. > > That's not a reason, it's FUD. No, it's prudence. If I am writing a banal, been-done-a-million-times before, cookie- cutter text adventure, yes I'd just use a domain-specific language. If I am writing a unique game that does new things, sooner or later I'm going to want to do something the designer of the domain-specific language and framework didn't anticipate. And there is no uncertainty or doubt about this: when it comes to that, I don't want to be restrained by a narrow framework or domain-specific language, and I would want to be using Python, and it isn't even remotely close. The only question would be whether there's enough general purpose programming required that it would outweigh the extra work. Which, let's be honest, is not all that much for a text adventure. Carl Banks From tjreedy at udel.edu Wed Apr 23 15:10:04 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 23 Apr 2008 15:10:04 -0400 Subject: Partition list with predicate References: <925822270804230959v557ec5f5re02737709f94d3c6@mail.gmail.com> Message-ID: "Jared Grubb" wrote in message news:925822270804230959v557ec5f5re02737709f94d3c6 at mail.gmail.com... | I want a function that removes values from a list if a predicate evaluates | to True. Forget the rigamarole you posted, which has several defects. If you must modify the list in place, because you have multiple references to it: lst[:] = filter(lambda x: not pred(x), lst) Otherwise, just lst = filter(....) tjr From codewarrior at mail.com Thu Apr 3 14:21:34 2008 From: codewarrior at mail.com (kc) Date: Thu, 03 Apr 2008 13:21:34 -0500 Subject: urllib and bypass proxy Message-ID: Under MS Windows, I encountered a problem with the proxy bypass specification. In windows, the bypass specification for the proxy uses semi-colons to delimit entries. Mine happens to have two semi-colons back-to-back. Internet explorer handles this just fine but urllib equates this with ALWAYS bypass the proxy. (I'm using Python 2.5.2) This is caused because the double semi-colon is turned into an empty string entry and at the bottom of urllib.py, and empty string can always be found in a host name. Therefore it always chooses to bypass the proxy. Of course the fix is to get rid of the double colon in the bypass settings in internet explorer (which I did). But it took me an hour to track this down (first time using urllib). Perhaps a better fix would be to test for the empty string and continue the loop in that case. From urllib.py: # now check if we match one of the registry values. for test in proxyOverride: if test == "": continue test = test.replace(".", r"\.") # mask dots This is not really a bug but rather a way to be more consistent with internet explorer. If this has value, do I submit a bug report or does someone else? From mellit at gmail.com Wed Apr 23 04:36:08 2008 From: mellit at gmail.com (Anton Mellit) Date: Wed, 23 Apr 2008 01:36:08 -0700 (PDT) Subject: overriding = operator References: <23874e00-e22e-43d8-a4e7-a2a101eb822f@a1g2000hsb.googlegroups.com> Message-ID: <328e1b72-99aa-4a0b-9712-4ab231df8156@d45g2000hsc.googlegroups.com> On Apr 22, 3:54 pm, Paul McGuire wrote: > On Apr 22, 8:47 am, "Anton Mellit" wrote: > > > > > I need something like > > 'overriding' =, which is impossible, but I look for a systematic > > approach to do something instead. It seems there are two ways to do > > what I need: > > > 1. Implement a method 'assign' which generates the corresponding code > > to store value: > > > z.assign(x + y) > > > 2. Do the same as 1., but via property set methods. For example, this > > would look cleaner: > > > z.value = x + y > > > Which of these is preferrable? Does anyone know any alternative ways? > > > Anton > > If you are willing to accept '<<=' as meaning 'assign to existing' > instead of 'left shift in place', you can override this operator using > the __ilshift__ method. > > We used this technique in C++/CORBA code back in the 90's to "inject" > values into CORBA::Any variables. > > -- Paul Great idea! It conflicts with 'left shift in place', which i also need, but '=' seems more important. Anton From john106henry at hotmail.com Mon Apr 14 15:02:20 2008 From: john106henry at hotmail.com (John Henry) Date: Mon, 14 Apr 2008 12:02:20 -0700 (PDT) Subject: =?GB2312?B?UmU6INPQ1tC5+sjLuvU/?= References: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> <4801F702.5050401@arcor.de> Message-ID: On Apr 14, 11:17 am, Steve Holden wrote: > Penny Y. wrote: > > Steve Holden ??: > > >> ????????, ????????? > > > What do you mean? > > If I understand you correctly, maybe it should be, > > > ??python??????,??????. > > > Am I right? > > I have no idea. Babelfish (from which I obtained my reply as well as > whatever understanding I had of the original inquiry) translated my reply as > > But the academic society never is immediately, with will need time > > whereas yours becomes > > Studies python not to be possible on first to become, needs to proceed > in an orderly way > > Since what I entered in English was something like "Yes, Python has a > future. But it will take some study". Perhaps you can tell me whether > your translation gives the correect flavor. I'm pretty sure the > babelfish mangled my intent. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ ROFL I would not recomend using babalfish to translate between Chinese and English. It does a *horrible* job at that. But then in this particular case, it was able to convey what you wanted to say - in a rather awkward fashion. :-) From sturlamolden at yahoo.no Thu Apr 24 20:27:33 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 17:27:33 -0700 (PDT) Subject: Psyco alternative References: <1369b321-f55b-432b-b2f9-6144787509d8@h11g2000prf.googlegroups.com> <7xlk4473ai.fsf@ruckus.brouhaha.com> <651ncdF2cmik2U1@mid.uni-berlin.de> <651onqF2dripdU1@mid.uni-berlin.de> <2f3a59c2-ef31-426a-be34-bdb187ea3b22@c19g2000prf.googlegroups.com> Message-ID: On Mar 28, 8:06 pm, Paul Boddie wrote: > From what I've seen from browsing publicly accessible materials, > there's a certain commercial interest in seeing Psyco updated > somewhat. YouTube uses Psyco. From andre.roberge at gmail.com Fri Apr 4 09:54:40 2008 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Fri, 4 Apr 2008 06:54:40 -0700 (PDT) Subject: Looking for Advanced Python Tutorials References: Message-ID: <5d1d97e6-c7bc-4746-8e49-acaefc4cad3d@24g2000hsh.googlegroups.com> On Apr 4, 8:58 am, cokofree... at gmail.com wrote: > I was wondering if anyone knew of some online (free if possible) > advanced tutorials, especially ones that provides tasks and ideas for > small projects. The issue for myself is I want to improve my python > programming level, and my ability to program in general, but come up > blank thinking of a possible task or project to undertake. So with > that in mind I thought I'd ask the community if they knew of sites or > books to read up on and use as a starting block. Of course project > ideas would be great as well! > I suggest a different alternative: join an open source project. Andr? > Thanks for any help you can provide. > > Coko From nigamreetesh84 at gmail.com Wed Apr 16 04:35:29 2008 From: nigamreetesh84 at gmail.com (reetesh nigam) Date: Wed, 16 Apr 2008 01:35:29 -0700 (PDT) Subject: how turbo geras code works Message-ID: hi. actually i have developed one small project but now i want to develope a project with the help of html.. please help me out From doug.farrell at gmail.com Fri Apr 4 17:06:28 2008 From: doug.farrell at gmail.com (writeson) Date: Fri, 4 Apr 2008 14:06:28 -0700 (PDT) Subject: Python2.5 and MySQLdb Message-ID: Hi all, I'm running a CentOS 4 server and have installed Python2.5 on there (it's our development machine) in preparation of moving to Python2.5 everywhere. All looks good with our code and 2.5, except where it comes to MySQLdb, I can't get that to install on the machine. It generates a huge lists of errors and warnings from gcc when I run the python2.5 setup.py build script that comes with the tar file. Anyone have any suggestions? Thanks, Doug From skunkwerk at gmail.com Mon Apr 7 19:52:54 2008 From: skunkwerk at gmail.com (skunkwerk) Date: Mon, 7 Apr 2008 16:52:54 -0700 (PDT) Subject: popen pipe limit Message-ID: I'm getting errors when reading from/writing to pipes that are fairly large in size. To bypass this, I wanted to redirect output to a file in the subprocess.Popen function, but couldn't get it to work (even after setting Shell=True). I tried adding ">","temp.sql" after the password field but mysqldump gave me an error. the code: p1 = subprocess.Popen(["mysqldump","--all-databases","--user=user","-- password=password"], shell=True) p2 = subprocess.Popen(["gzip","-9"], stdin=p1.stdout) output = p2.communicate()[0] file=open('test.sql.gz','w') file.write(str(output)) file.close() the output: gzip: compressed data not written to a terminal. Use -f to force compression. For help, type: gzip -h mysqldump: Got errno 32 on write I'm using python rather than a shell script for this because I need to upload the resulting file to a server as soon as it's done. thanks From colas.francis at gmail.com Fri Apr 11 06:27:44 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Fri, 11 Apr 2008 03:27:44 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> On 11 avr, 12:14, bdsatish wrote: > The built-in function round( ) will always "round up", that is 1.5 is > rounded to 2.0 and 2.5 is rounded to 3.0. > > If I want to round to the nearest even, that is > > my_round(1.5) = 2 # As expected > my_round(2.5) = 2 # Not 3, which is an odd num > > I'm interested in rounding numbers of the form "x.5" depending upon > whether x is odd or even. Any idea about how to implement it ? When you say "round to the nearest even", you mean new_round(3) <> 3? Is so, you can try: In [37]: def new_round(x): ....: return round(x/2.)*2 ....: In [38]: new_round(1.5) Out[38]: 2.0 In [39]: new_round(2.5) Out[39]: 2.0 In [40]: new_round(3) Out[40]: 4.0 From nick at stinemates.org Fri Apr 18 14:32:15 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 11:32:15 -0700 Subject: py3k s***s In-Reply-To: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> Message-ID: <20080418183215.GC19281@deviL> On Mon, Apr 14, 2008 at 04:10:48PM -0700, Sverker Nilsson wrote: > do i dare to open a thread about this? > > come on you braver men > > we are at least not bought by g***le > > but why? others have said it so many times i think > > :-//// > > but why? a few syntactic 'cleanups' for the cost of a huge rewrite of > all the code that have been builtup from all the beginning when the > once great Python came along and people began to use it and write code > for it. Like all that code would have to be rewritten. blaah. > and i have perhaps been drinking but i have been p**d all week since i > began look into this:-( > -- > http://mail.python.org/mailman/listinfo/python-list Yo, no one here is a child so don't litter your title and text with hard to read bullshit. -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From hexusnexus at gmail.com Wed Apr 2 00:43:36 2008 From: hexusnexus at gmail.com (hexusnexus at gmail.com) Date: Tue, 1 Apr 2008 21:43:36 -0700 (PDT) Subject: Basic class implementation question Message-ID: I can't get call a class for some reason. This must be one of those newbie questions I hear so much about: class wontwork: def really(): print "Hello World" wontwork.really() This returns (as an error): Traceback (most recent call last): File "", line 1, in wontwork.really() TypeError: unbound method really() must be called with wontwork instance as first argument (got nothing instead) Any ideas? From cyril.giraudon at gmail.com Mon Apr 28 16:53:26 2008 From: cyril.giraudon at gmail.com (cyril giraudon) Date: Mon, 28 Apr 2008 13:53:26 -0700 (PDT) Subject: descriptor & docstring References: Message-ID: <0d65e5e6-82a9-48a1-aa90-f709f4431213@z72g2000hsb.googlegroups.com> A precision, I use python 2.5.2 under linux mandiva 2007.0 Cyril. From arnodel at googlemail.com Thu Apr 3 10:00:32 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 3 Apr 2008 07:00:32 -0700 (PDT) Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> <10ee2a69-f4e2-4887-8083-6b02b60dd0cd@i7g2000prf.googlegroups.com> <130ad0b4-504c-4b19-85fc-1bd700590ccf@u10g2000prn.googlegroups.com> Message-ID: <8d2b1900-55ba-4bca-b8e8-b9969b99ae60@i36g2000prf.googlegroups.com> On Apr 3, 11:10?am, Jo?o Neves wrote: > On Apr 3, 4:43 am, Scott David Daniels wrote: > > > Nope: ?If you change the code in-place, the whole stack's references > > to where they were running would need to get updated to corresponding > > locations in the new code. ?_That_ is a lot of work. > > Ah, there it is. Now I get it, it makes perfect sense. > Looks like I'll have to stick to the usual mechanisms! > Thanks everyone! > > --- > Jo?o Neves FWIW, when I need to 'modify' a code object / function object I use the following functions: from new import code, function code_args = ( 'argcount', 'nlocals', 'stacksize', 'flags', 'code', 'consts', 'names', 'varnames', 'filename', 'name', 'firstlineno', 'lnotab', 'freevars', 'cellvars' ) function_args = ('code', 'globals', 'name', 'defaults', 'closure') def copy_code(code_obj, **kwargs): "Return a copy of a code object, maybe changing some attributes" for arg in code_args: if not kwargs.has_key(arg): kwargs[arg] = getattr(code_obj, 'co_%s' % arg) return code(*map(kwargs.__getitem__, code_args)) def copy_function(func_obj, **kwargs): "Return a copy of a function object, maybe changing some attributes)" for arg in function_args: if not kwargs.has_key(arg): kwargs[arg] = getattr(func_obj, 'func_%s' % arg) return function(*map(kwargs.__getitem__, function_args)) # E.g. to change the code object of a function: f = copy_function(f, code=new_code_object) From needin4mation at gmail.com Wed Apr 9 08:04:20 2008 From: needin4mation at gmail.com (jmDesktop) Date: Wed, 9 Apr 2008 05:04:20 -0700 (PDT) Subject: I am worried about Python 3 Message-ID: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> I am a new Python programmer. I have always desired to learn Python, but have never had the opportunity. Recently this has changed, and I have an opportunity to get away from the .NET framework. I found Django (and other web frameworks) and began my quest to learn. I started reading Dive Into Python and anything I could find and started participating here in usenet. Then I had to read this: http://www.comp.leeds.ac.uk/nde/papers/teachpy3.html I think that every time I start a new technology (to me) it is about to change. Yes, I know that is the nature of things, but I'm always at the start of "something new." If I continue in Python 2.5.x, am I making a mistake? Is it really that different? Here is an excerpt that is causing me concern: Two new versions of the language are currently in development: version 2.6, which retains backwards compatibility with previous releases; and version 3.0, which breaks backwards compatibility to the extent that even that simplest of programs, the classic 'Hello, World', will no longer work in its current form. It makes me feel like I am wasting my time and makes it difficult to justify spending time on projects using 2.5.x and using it where I work. From hdante at gmail.com Fri Apr 11 10:29:31 2008 From: hdante at gmail.com (hdante) Date: Fri, 11 Apr 2008 07:29:31 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <31872ffc-5bc4-44c8-961d-ee4f0dc356c5@k1g2000prb.googlegroups.com> <700b1a5f-0af0-466e-abda-4d8dc784dbaa@e67g2000hsa.googlegroups.com> <220fa9fa-3ad3-4d58-b90c-478f936b5352@m1g2000pre.googlegroups.com> Message-ID: <6d63626e-8868-46e7-9a69-0ed870751263@m3g2000hsc.googlegroups.com> On Apr 11, 11:13 am, Ivan Illarionov wrote: > > Shorter version: > def round3k(x): > return x % 1 != 0.5 and round(x) or round(x / 2.) * 2. Strangely, a "faster" version is: def fast_round(x): if x % 1 != 0.5: return round(x) return 2.0*round(x/2.0) > > nums = [ 0, 2, 3.2, 3.6, 3.5, 2.5, -0.5, -1.5, -1.3, -1.8, -2.5, 0.6, > 0.7 ] > rnums = [ 0, 2, 3.0, 4.0, 4.0, 2.0, -0.0, -2.0, -1.0, -2.0, -2.0, 1.0, > 1.0 ] You shouldn't remove assertions in the smaller version. :-P > > for num, rnum in zip(nums, rnums): > assert even_round(num) == rnum, '%s != %s' % (even_round(num), > rnum) > print num, '->', even_round(num) > > It makes sense to add `from __future__ import even_round` to Python > 2.6. From python-url at phaseit.net Mon Apr 14 09:54:29 2008 From: python-url at phaseit.net (Gabriel Genellina) Date: Mon, 14 Apr 2008 13:54:29 +0000 (UTC) Subject: Python-URL! - weekly Python news and links (Apr 14) Message-ID: QOTW: "This for me is Python's chief selling point: dir()....dir() and help(). Python's two selling points are dir(), help(), and very readable code. Python's *three* selling points are dir(), help(), very readable code, and an almost fanatical devotion to the BFDL. Amongst Python's selling points ..." http://groups.google.com/group/comp.lang.python/msg/8723cc7522ddbac5 "Personally, I seem to get the most bang for my buck showing sysadmins Python generators. You can do some interesting things processing huge data files, infinite data streams, and other things with generators. This resonates well and is unusual enough to avoid debates where someone is going to argue that Python is just the same as Bash/Perl/Awk, etc." - David Beazley http://mail.python.org/pipermail/advocacy/2008-April/000562.html Rounding x.5 to nearest even number (and why it should/should not be done) http://groups.google.com/group/comp.lang.python/browse_thread/thread/9e505c8834893818/ Trying to implement readonly class properties - eventually only a Javaism: http://groups.google.com/group/comp.lang.python/browse_thread/thread/ffcc2e483e6edba6/ Demistifying the incompatible changes that will come Python 3.0: http://groups.google.com/group/comp.lang.python/browse_thread/thread/6b2112321b437af9/ Chris Lambacher nicely analyzes 3.0 for the working Pythoneer: http://opag.ca/pipermail/opag/2008-April/002734.html Seasoned developers comment on three beginners' code: http://groups.google.com/group/comp.lang.python/browse_thread/thread/22d663454f4760a7/ http://groups.google.com/group/comp.lang.python/browse_thread/thread/de537debd28cbd32/ http://groups.google.com/group/comp.lang.python/browse_thread/thread/e6fb4ad98c49ef87/ Selecting a database and/or ORM to start learning: http://groups.google.com/group/comp.lang.python/browse_thread/thread/9ee48781edc9ac4f/ A C program embeds Python: should it use multiple interpreters or multiple threads? http://groups.google.com/group/comp.lang.python/browse_thread/thread/68c0980f3db11615/ ======================================================================== Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. Just beginning with Python? This page is a great place to start: http://wiki.python.org/moin/BeginnersGuide/Programmers The Python Papers aims to publish "the efforts of Python enthusiats": http://pythonpapers.org/ The Python Magazine is a technical monthly devoted to Python: http://pythonmagazine.com Readers have recommended the "Planet" sites: http://planetpython.org http://planet.python.org comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Python411 indexes "podcasts ... to help people learn Python ..." Updates appear more-than-weekly: http://www.awaretek.com/python/index.html Steve Bethard continues the marvelous tradition early borne by Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim Lesher of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to capture useful and interesting recipes. http://aspn.activestate.com/ASPN/Cookbook/Python Many Python conferences around the world are in preparation. Watch this space for links to them. Among several Python-oriented RSS/RDF feeds available are http://www.python.org/channews.rdf http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi http://python.de/backend.php For more, see http://www.syndic8.com/feedlist.php?ShowMatch=python&ShowStatus=all The old Python "To-Do List" now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse http://www.python.org/dev/peps/pep-0042/ The online Python Journal is posted at pythonjournal.cognizor.com. editor at pythonjournal.com and editor at pythonjournal.cognizor.com welcome submission of material that helps people's understanding of Python use, and offer Web presentation of your work. del.icio.us presents an intriguing approach to reference commentary. It already aggregates quite a bit of Python intelligence. http://del.icio.us/tag/python *Py: the Journal of the Python Language* http://www.pyzine.com Archive probing tricks of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 http://groups.google.com/groups?meta=site%3Dgroups%26group%3Dcomp.lang.python.* Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://www.ddj.com/topic/python/ (requires subscription) http://groups-beta.google.com/groups?q=python-url+group:comp.lang.python*&start=0&scoring=d& http://purl.org/thecliff/python/url.html (dormant) or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python There is *not* an RSS for "Python-URL!"--at least not yet. Arguments for and against are occasionally entertained. Suggestions/corrections for next week's posting are always welcome. E-mail to should get through. To receive a new issue of this posting in e-mail each Monday morning (approximately), ask to subscribe. Mention "Python-URL!". Write to the same address to unsubscribe. -- The Python-URL! Team-- Phaseit, Inc. (http://phaseit.net) is pleased to participate in and sponsor the "Python-URL!" project. Watch this space for upcoming news about posting archives. From Robert.Bossy at jouy.inra.fr Mon Apr 14 07:44:22 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Mon, 14 Apr 2008 13:44:22 +0200 Subject: =?GB2312?B?tPC4tDogSmF2YSBvciBDKys/?= In-Reply-To: <20080414085431.D8751187B00@mail-in-14.arcor-online.net> References: <20080414085431.D8751187B00@mail-in-14.arcor-online.net> Message-ID: <48034396.1090609@jouy.inra.fr> Penny Y. wrote: > Perl is a functional language I guess you mean functional in the sense it works. RB From gagsl-py2 at yahoo.com.ar Fri Apr 4 16:09:33 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 04 Apr 2008 17:09:33 -0300 Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? References: <47F67798.3060401@gmail.com> Message-ID: En Fri, 04 Apr 2008 15:46:48 -0300, Alex9968 escribi?: > Nebur wrote: >> No, I can't reproduce it, and I don't know whom to blame (Pydev? >> Eclipse ? The File System ? A Virus that only 2 times in half a year >> deletes a single file I'm busy working with, and seems to do nothing >> else? Myself beeing schizophrenic ??) > A virus created to remind you 2 times in half a year of the importance > of backup operations ;-) . I'm joking. I don't know what is this, but > I'm interested. Because my files won't be restorable from version > control :-( Then implement it! It's not so difficult, less if you're the only one working on the files. -- Gabriel Genellina From ivan.illarionov at gmail.com Mon Apr 21 17:30:04 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Mon, 21 Apr 2008 14:30:04 -0700 (PDT) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> Message-ID: On 22 ???, 01:01, Peter Otten <__pete... at web.de> wrote: > Ivan Illarionov wrote: > > And even faster: > > a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, > > len(s), 3)))) > > if sys.byteorder == 'little': > > a.byteswap() > > > I think it's a fastest possible implementation in pure python > > Clever, but note that it doesn't work correctly for negative numbers. For > those you'd have to prepend "\xff" instead of "\0". > > Peter Thanks for correction. Another step is needed: a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, len(s), 3)))) if sys.byteorder == 'little': a.byteswap() result = [n if n < 0x800000 else n - 0x1000000 for n in a] And it's still pretty fast :) From usenet-mail at markshroyer.com Mon Apr 21 03:14:57 2008 From: usenet-mail at markshroyer.com (Mark Shroyer) Date: Mon, 21 Apr 2008 03:14:57 -0400 Subject: Is massive spam coming from me on python lists? References: Message-ID: In article , Brian Vanderburg II wrote: > I've recently gotten more than too many spam messages and all say > Sender: python-list-bounces+my=email.address at python.org. I'm wondering > if my mail list registration is now being used to spam myself and > others. If so, sorry, but I'm not the one sending messages if other are > getting them even though Sender seems to include my address (I'm not > sure about mail headers so I don't know how From: is different than > Sender:) Anyway, it seems to be a bunch of spam emails about cracks and > stuff. > > Brian Vanderburg II Nah, if anyone owes anybody an apology, then whatever mail server admins decided that it would be a good idea to accept SMTP messages before actually determining that the RCPT TO address is, in fact, deliverable, thereby creating a deluge of backscatter and filling up your inbox, should be groveling on their knees and begging *you* for forgiveness. ;) (I haven't seen any such spam messages myself; but the way I'm set up, I wouldn't receive them even if that is the case.) -- Mark Shroyer, http://markshroyer.com/contact/ I have joined others in blocking Google Groups due to excessive spam. If you want more people to see your posts, you should use another means of posting to Usenet. http://improve-usenet.org/ From lipingffeng at gmail.com Thu Apr 3 19:52:31 2008 From: lipingffeng at gmail.com (lipingffeng at gmail.com) Date: Thu, 3 Apr 2008 16:52:31 -0700 (PDT) Subject: how to do "load script; run script" in a loop in embedded python? Message-ID: <352f4111-94b5-4aa9-917b-90cd56a5f7d6@s8g2000prg.googlegroups.com> Hi, all, I am currently involved in a project that needs to load/run a python script dynamically in a C application. The sample code is as following: PyObject *LoadScript(char *file, char *func) { PyObject *pName, *pModule, *pDict, *pFunc; pName = PyString_FromString(file); pModule = PyImport_Import(pName); pDict = PyModule_GetDict(pModule); pFunc = PyDict_GetItemString(pDict, func); return pFunc; } int RunScript(PyObject *pFunc, PyObject *arglist) { PyObject *pValue = PyObject_CallFunction(pFunc, "O", arglist); int ret = PyInt_AsLong(pValue); return ret; } int main(int argc, char *argv[]) { PyObject *arglist, *pFunc; char imgData[10]; int ret; for(int i = 0; i < 10; i++) imgData[i] = 48 + i; arglist = Py_BuildValue("s#", imgData, 10); Py_SetProgramName(argv[0]); Py_Initialize(); PySys_SetArgv(argc, argv); for (int k = 0; k < 3; k++) // using loop to imitate dynamic loading/running script { pFunc = LoadScript(argv[1], argv[2]); ret = RunScript(pFunc, arglist); } Py_Finalize(); return 0; } The first loop is perfectly ok, but on the second loop, script loading is successful but running will always fail. Any ideas would be highly apprecicated. Thanks, Liping From a.harrowell at gmail.com Wed Apr 16 08:22:27 2008 From: a.harrowell at gmail.com (TYR) Date: Wed, 16 Apr 2008 05:22:27 -0700 (PDT) Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> <69795448-0534-4aed-a9a0-84f2cd3aea36@s50g2000hsb.googlegroups.com> Message-ID: Who cares? Everyone does their GUI in a browser these days - keep up, Dad. What we need is a pythonic front end. /troll From timaranz at gmail.com Thu Apr 17 17:13:55 2008 From: timaranz at gmail.com (Tim Mitchell) Date: Fri, 18 Apr 2008 09:13:55 +1200 Subject: how do I know if I'm using a debug build of python Message-ID: <4807BD93.8080809@gmail.com> Hi, A quick question: Is there any way for a python script to know if it's being executed by a debug build of python (python_d.exe) instead of python? Thanks Tim From kay.schluehr at gmx.net Sat Apr 5 18:47:47 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 5 Apr 2008 15:47:47 -0700 (PDT) Subject: ANN: pry unit testing framework References: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com> <20080405141329.GD15684@nullcube.com> <20080405213059.GA19741@nullcube.com> Message-ID: <90e7f293-64f7-4cf5-9b89-bf59b56def1f@p25g2000hsf.googlegroups.com> On 5 Apr., 23:54, Steve Holden wrote: > To be fair I wasn't commenting on the whole thread, more on the angry > nature of your final reply, and didn't really consider Kay's remarks > fully. So perhaps I could ask *both* of you to be more civil to each > other, and leave it at that? Storm in a teacup, of course. I'm sure war > won;t be declared about this. Nah, no war. It's more like sports :) http://www.youtube.com/watch?v=ur5fGSBsfq8 Regards, Kay From leoniaumybragg at gmail.com Sat Apr 26 06:55:59 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:55:59 -0700 (PDT) Subject: gothic 3 patch Message-ID: <67f0ceba-6375-4d51-9bce-ffa552ef0dfb@f63g2000hsf.googlegroups.com> gothic 3 patch http://cracks.00bp.com F R E E C R A C K S From landofdreams at gmail.com Wed Apr 30 20:10:42 2008 From: landofdreams at gmail.com (Sam) Date: Wed, 30 Apr 2008 17:10:42 -0700 (PDT) Subject: relative import broken? References: Message-ID: <9c6ba5f9-d65b-4265-baba-fc5d7936781b@d1g2000hsg.googlegroups.com> I also have a problem with relative import; I can't for the life of me figure out how to use the damn thing. I think the main problem is with getting Python to recognize the existence of a package. I have S/ p.py B/ b.py W/ pyw/ u.py ws.py and I'd like to get u.py to import all the other 3 programs. I put empty __init__.py files in all of the above directories (is this necessary?), and even manually added the pathway (r'C:\Myname\S') to sys.path, but when I execute from S import p in u.py Python gives "ImportError: No module named S". It says "No module named X" for essentially any package reference, so I think it's just not recognizing the directories as packages. The docs for relative import make this sound much easier than it is. Thanks in advance, I'm at my wit's end. -Sam On Apr 30, 9:41 am, "test" wrote: > basic noob question here. > > i am trying to reference a package, i have the structure: > > mypack/ > __init__.py > test.py > subdir1/ > __init__.py > mod1.py > subdir2/ > __init__.py > mod2.py > > can someone please tell me why the statement: > > from mypack.subdir1.mod1 import * > > does NOT work from mod2.py nor from test.py? > > instead, if i use: > > from subdir1.mod1 import * > > it works perfectly from test.py. > > ....? > > thank you, > > aj. From jens at aggergren.dk Tue Apr 29 09:15:55 2008 From: jens at aggergren.dk (Jens) Date: Tue, 29 Apr 2008 06:15:55 -0700 (PDT) Subject: Zope/DTML Infuriating... References: <3a955f90-ed80-46be-a238-1462e4fb2d0c@m3g2000hsc.googlegroups.com> Message-ID: On Apr 29, 2:45?pm, Marco Mariani wrote: > Jens wrote: > >> You might have wrong assumptions from previous PHP experiences. > > >> ?>>> 'x'+4 > >> Traceback (most recent call last): > >> ? ?File "", line 1, in > >> TypeError: cannot concatenate 'str' and 'int' objects > > > ... and the non snobby answer would have been: > > > ... ? > > Sorry. Not trying to be snobbish, only in a hurry. > > That answer would have been less useful, because there are TONS of > details in the python tutorial, that set the language apart from its > "scripting cousins". > Reading the syntax and thinking "yeah, got it, boring, next chapter" is > a common mistake I've also made sometime, especially with python when > I've been deceived by its apparent simplicity. > Then, later, the same happened with Javascript, of course. > And it's bound to happen again, as much as I'll try to be careful :-( Hey no worriest. Is this the tutorial you're referring to: http://docs.python.org/lib/typesmapping.html Is there anything better? I miss the discussion and examples that accompany most entries in php.net. From cwitts at gmail.com Thu Apr 17 06:46:37 2008 From: cwitts at gmail.com (Chris) Date: Thu, 17 Apr 2008 03:46:37 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <52vid5-cvl2.ln1@ozzie.tundraware.com> <87hce1t8k5.fsf@physik.rwth-aachen.de> Message-ID: <10fb879a-7011-4bf8-94f1-de57693c8d4f@t54g2000hsg.googlegroups.com> On Apr 17, 11:49?am, Marco Mariani wrote: > Torsten Bronger wrote: > >>> If I were you I would keep it a secret until a Hollywood producer > >>> offers big bucks for the film rights. > >> Who would play Guido, I wonder? > > > Ralf M?ller. ?No other. > > And the GIL killer? > > Clive Owen, Matt Damon, Mark Wahlberg? Marky Mark ftw, he could even rap about it his method. From sbergman27 at gmail.com Thu Apr 17 23:57:41 2008 From: sbergman27 at gmail.com (Steve Bergman) Date: Thu, 17 Apr 2008 20:57:41 -0700 (PDT) Subject: How to make this unpickling/sorting demo faster? References: <40a5d8f1-a246-4c48-8759-5b65324f9029@m73g2000hsh.googlegroups.com> <7xod88w5l5.fsf@ruckus.brouhaha.com> <672d4491-35b5-4eb5-94bc-13d4b23ba797@d45g2000hsc.googlegroups.com> <7xd4ooc81b.fsf@ruckus.brouhaha.com> Message-ID: <815a6208-8a07-4772-8646-a16fa7087ec9@a23g2000hsc.googlegroups.com> On Apr 17, 7:37?pm, Paul Rubin wrote: > Therefore the likelihood of a C or asm program > being 20x faster including disk i/o is dim. ?But realistically, > counting just CPU time, you might get a 20x speedup with assembler if > you're really determined, using x86 SSE (128-bit vector) instructions, > cache prefetching, etc. I think that the attitude that is prevalent is that although Python and other "interpreted" languages are slow, there are places where that slowness is not important and using them is OK. The point that I am trying to make with my example is that often, by leveraging the care and optimization work that others have put into the Python standard library over the years, a rather casual programmer can match or better the performance of 'average' C code. i.e. C code that was written by a good C programmer while no one was looking over his shoulder, and no pressures motivated him to spend a lot of time optimizing the C to the hilt, or switching to asm. With the reading and writing of the data (which actually works out to about 23MB, marshalled) now down to 1 second each, I'm content. In the beginning, the io time was overshadowing the sort time by a good bit. And it was the sort time that I wanted to highlight. BTW, no one has responded to my challenge to best the original sample Python code with C, C++, or asm. From bruno.desthuilliers at gmail.com Wed Apr 2 19:22:16 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 16:22:16 -0700 (PDT) Subject: Nested try...except References: <0a34849f-bcda-419b-a10f-772d76172d1f@b5g2000pri.googlegroups.com> <43d60d13-b420-414d-81c8-b8430af2aa5f@i36g2000prf.googlegroups.com> Message-ID: <33d23676-5de0-4181-8abb-f3d733cdd365@r9g2000prd.googlegroups.com> On 2 avr, 15:22, Magnus.Morab... at gmail.com wrote: > On 2 Apr, 15:15, Magnus.Morab... at gmail.com wrote: > > > > > On 2 Apr, 15:12, cokofree... at gmail.com wrote: > > > > On Apr 2, 3:06 pm, Magnus.Morab... at gmail.com wrote: > > > > > Hi, > > > > > I found the following code on the net - > > > > > http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/%3C20050924104732.5116.qm... at minotaur.apache.org%3E > > > > > def count(self): > > > > - db = sqlite.connect(self.filename, > > > > isolation_level=ISOLATION_LEVEL) > > > > - try: > > > > - try: > > > > - cur = db.cursor() > > > > - cur.execute("select count(*) from sessions") > > > > - return cur.fetchone()[0] > > > > - finally: > > > > - cur.close() > > > > - finally: > > > > - db.close() > > > > > I don't understand though why the second try is not after the line cur > > > > = db.cursor(). Can anyone explain for me why? > > > > > /Barry. > > > > Better question is why is there a try with no except... > > > > Better yet, WHY is there two TRY statements when there could quite > > > happily be only one... > > > > Towards what you are asking, I GUESS...because the author hoped to > > > handle the cases where cur failed to get assigned...but then > > > his .close method of it would likely not work anyway...I mean...does > > > this even work...YUCK > > > I shouldn't have written "Nested try...except" as the title, instead I > > mean "Nested try...finally". Sorry about that... > > > Anyway, how would you do this? That is, use a finally to close the > > network connection and the cursor? > > > Thanks for your help, > > > Barry > > Here's what I would do. Is it OK? > > def ExecuteWithNoFetching(self, queryString): > > sqlServerConnection = adodbapi.connect (";".join (connectors)) slightly OT : where this 'connectors' comes from ? > try: > cursor = sqlServerConnection.cursor() > try: > cursor.execute(queryString) > raise Exception("Exception") > sqlServerConnection.commit() > finally: > cursor.close() > finally: > sqlServerConnection.close() Else it looks ok, even if a bit parano?d. Also, opening a db connection for each and every single query might not be the best solution... And finally (no pun intented), this won't let you chain calls within a single transaction. Another, a bit more flexible solution could be something like: def run_in_transaction(*funcs): sqlServerConnection = adodbapi.connect (";".join (connectors)) try: cursor = sqlServerConnection.cursor() try: for func in funcs: func(cursor) except Exception, e: sqlServerConnection.rollback() raise else: sqlServerConnection.commit() finally: cursor.close() finally: sqlServerConnection.close() def do_something(cursor): cursor.execute("some update query") def do_something_else(cursor): cursor.execute("some select query") for row in cursor.fetchall(): if some_condition(row): cursor.execute("some update query") run_in_transaction(do_something, do_something_else) And also, there's this new 'with' statement... My 2 cents... From marco at sferacarta.com Thu Apr 3 06:07:33 2008 From: marco at sferacarta.com (Marco Mariani) Date: Thu, 03 Apr 2008 12:07:33 +0200 Subject: splitting an XML file on the basis on basis of XML tags In-Reply-To: <0Y1Jj.9751$T35.2972@tornado.fastwebnet.it> References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> <0Y1Jj.9751$T35.2972@tornado.fastwebnet.it> Message-ID: Marco Mariani wrote: >>> the XML file is almost a TB in size... >>> >> Good grief. When will people stop abusing XML this way? > > Not before somebody writes a clever xmlfs for the linux kernel :-/ Ok. I meant it as a joke, but somebody has been there and done that. Twice. http://xmlfs.modry.cz/user_documentation/ http://www.haifa.ibm.com/projects/storage/xmlfs/index.html From llothar at web.de Wed Apr 2 19:33:33 2008 From: llothar at web.de (llothar) Date: Wed, 2 Apr 2008 16:33:33 -0700 (PDT) Subject: Problems building a binary extension Message-ID: <4352a799-7934-4a36-ab51-2cdc54431f77@u10g2000prn.googlegroups.com> I works well on Linux. But on FreeBSD when i use ../bin/python setup.py build_ext --inplace to select my own build python interpreter it is not using the correct library paths and therefore complains that it can't find the - lpython2.5 library. Using python-config i also don't see that the lib directory based on the --prefix option is not used anywhere for the library. Must i set LIBRARY_PATH by hand? If i have to it seems like a bug to me, because the information is there and the build tools should use it. From llothar at web.de Sat Apr 5 09:00:06 2008 From: llothar at web.de (llothar) Date: Sat, 5 Apr 2008 06:00:06 -0700 (PDT) Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> Message-ID: <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> > Right, so you think people aren't trying to help you? I think they are not reading the question. > You display your ignorance here. The ".pyd" extension is used on Windows > as an alternative to ".dll", but both are recognized as shared > libraries. Personally I'm not really sure why they even chose to use > ".pyd", which is confusing to most Windows users. Here i agree. But having it's own identifiying extension has also some small benefits. > To depart from the platform standard would be unhelpful and confusing to > the majority of users. It's know use telling us what you think: tell us > instead the compelling reasons why your opinion is correct. Opinions, > after all, are so cheap that everyone can have one. Because i want a uniform solution. Either use "dllso" or use "pyd" but stay with one decision once made. At the moment when i build python on my ubuntu system without "--enable-shared" i get a pyd file created, if i use "--enable-shared" it is a so file. I don't know if this is a special case on Linux or the general on unix systems (i only have Linux, FreeBSD, NetBSD, OpenBSD, Solaris and MacOSX in mind). > There are ways to build distributions of Python extensions (modules or > packages involving binary code from languages like C or C++), but you > will want to understand a bit more about computing in general Believe me nobody needs to teach me anything about general programming anymore. > (and work on your social skills ;-) I don't think so. I asked a pretty simple question and as usual on usenet nobody read the question but answered to complete different topics. Answers on usenet are so cheap, everybody likes to give one - no matter if it is ontopic, right or wrong. And this does not really help. My question is simple and person who knows setup.py and distools would be able to give the answer in a small sentence if there is a strategy behind it and it's not only a bug. Unfortunately there is no python.core mailing list that i know so i ask here. From paul at science.uva.nl Tue Apr 29 10:30:09 2008 From: paul at science.uva.nl (Paul Melis) Date: Tue, 29 Apr 2008 16:30:09 +0200 Subject: Issue with regular expressions In-Reply-To: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Message-ID: Julien wrote: > Hi, > > I'm fairly new in Python and I haven't used the regular expressions > enough to be able to achieve what I want. > I'd like to select terms in a string, so I can then do a search in my > database. > > query = ' " some words" with and "without quotes " ' > p = re.compile(magic_regular_expression) $ <--- the magic happens > m = p.match(query) > > I'd like m.groups() to return: > ('some words', 'with', 'and', 'without quotes') > > Is that achievable with a single regular expression, and if so, what > would it be? Here's one way with a single regexp plus an extra filter function. >>> import re >>> p = re.compile('("([^"]+)")|([^ \t]+)') >>> m = p.findall(q) >>> m [('" some words"', ' some words', ''), ('', '', 'with'), ('', '', 'and'), ('"without quotes "', 'without quotes ', '')] >>> def f(t): ... if t[0] == '': ... return t[2] ... else: ... return t[1] ... >>> map(f, m) [' some words', 'with', 'and', 'without quotes '] If you want to strip away the leading/trailing whitespace from the quoted strings, then change the last return statement to be "return t[1].strip()". Paul From deliverable at gmail.com Thu Apr 17 02:37:32 2008 From: deliverable at gmail.com (braver) Date: Wed, 16 Apr 2008 23:37:32 -0700 (PDT) Subject: sampling without replacement Message-ID: <6017ea8d-6ee8-44ea-bdad-bf06299a9cd5@a23g2000hsc.googlegroups.com> Greetings -- I am doing a sampling without replacement, taking out random elements from an array. The picked element is then removed from the array. When my arrays were on the order of 10,000 elements long, everything was fast. But when I increased them to 1,000,000 it suddenly was hours. I tracked it down to the line I first threw in to cut out the element i: a = a[:i] + a[i+1:] It was indeed the weakest link. But when I replace it with e.g. a.pop(i) it is still slow. I wonder what approach can be taken to speed it up? Basically, the algorithm picks an element from the array at random and checks its size in a different hashtable i=>size. If the size fits into an existing accumulator, i.e. is below a threshold, we take it and delete it from the array as above. Thus just random.sample is not enough as we may not use an element we pick until we find the right one, element by element, running a cumulative statistics. Using an array is natural here as it represents "without replacement" -- we take an element by removing it from the array. But in Python it's very slow... What approaches are there to implement a shrinking array with random deletions with the magnitude of millions of elements? Cheers, Alexy From john00587 at gmail.com Mon Apr 21 01:43:12 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:43:12 -0700 (PDT) Subject: crack registration codes for pogo games Message-ID: crack registration codes for pogo games http://cracks.00bp.com F R E E C R A C K S From rickbking at comcast.net Wed Apr 9 12:27:19 2008 From: rickbking at comcast.net (Rick King) Date: Wed, 09 Apr 2008 12:27:19 -0400 Subject: Stani's python ide 'spe' editor problem (again) Message-ID: <47FCEE67.8020607@comcast.net> In my previous post about spe I didn't mention that my set up is: python 2.4.4 wxpython 2.8.3 thanks. -Rick King From john00587 at gmail.com Mon Apr 21 01:41:37 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:41:37 -0700 (PDT) Subject: ideal admin keygen Message-ID: ideal admin keygen http://cracks.00bp.com F R E E C R A C K S From marco at sferacarta.com Thu Apr 17 11:54:03 2008 From: marco at sferacarta.com (Marco Mariani) Date: Thu, 17 Apr 2008 17:54:03 +0200 Subject: Can't do a multiline assignment! In-Reply-To: References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> Message-ID: s0suk3 at gmail.com wrote: > Yes, it makes it more readable. And yes, it does make it (a lot) more > maintainable. Mainly because I don't have those four variables, I have > about thirty. And I think I won't need to one or two of them, but > maybe all of them at once. have fun with locals(), then (but please feel dirty :-) loc = locals() for var in [ 'foo', # INSERT 'bar', # COMMENT 'baz' # HERE ]: loc[var] = 42 From davecook at nowhere.net Fri Apr 11 23:43:28 2008 From: davecook at nowhere.net (David Cook) Date: Sat, 12 Apr 2008 03:43:28 GMT Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> <47FFDA87.3070703@gmail.com> Message-ID: On 2008-04-11, Gabriel Ibanez wrote: > Why is nobody talking about pyGTK ? There are no limits with licenses (I > think) The OS X port is still pretty preliminary. Dave Cook From jurgenex at hotmail.com Tue Apr 29 23:13:04 2008 From: jurgenex at hotmail.com (Jürgen Exner) Date: Wed, 30 Apr 2008 03:13:04 GMT Subject: Python's doc problems: sort References: <929d5ce9-9063-4e6c-98aa-89526f89fba3@y18g2000pre.googlegroups.com> Message-ID: <9pof14t22rpq24219q0an2748i5f054qr4@4ax.com> "xahlee at gmail.com" wrote: Is this self-promoting maniac still going at it? >Although i disliked Perl very much [...] Then why on earth do you bother polluting this NG? Back into the killfile you go jue From primoz.skale.lists at gmail.com Wed Apr 2 15:03:36 2008 From: primoz.skale.lists at gmail.com (Primoz Skale) Date: Wed, 2 Apr 2008 21:03:36 +0200 Subject: function call - default value & collecting arguments Message-ID: <_LQIj.9776$HS3.482805@news.siol.net> Hello! I am fairly new to Python, so I apologise if this is a 'newbie' question. First define a simple function: def f(a=0): print a >> f(1) 1 >>f() 0 Argument a in function f() is set at default value of 0, if it is not passed to the function at the function call. I get this! :) I also understand (fairly) how to collect arguments. For example, let's define another function: def f(*a): print a >>f(1) (1,) >>f(1,2) (1,2) >>f() () OK, everything allright till so fair. But! :) Now define third function as: def f(*a): print a[0] In this case, function only prints first argument in the tuple: >>f(1,2,3) 1 >>f(3) 3 >>f() #no arguments passed Traceback (most recent call last): File "", line 1, in f() #no arguments passed File "", line 2, in f print a[0] IndexError: tuple index out of range Then I tried to define the function as: def f(*a=(0,)): print a[0] #this should come next, but we get error msg instead, saying SyntaxError: invalid syntax but it does not work this way. Now my 'newbie' question: Why not? :) I wanted to write function in this way, because then we can call function without any arguments, and it would still print 0 (in this case). What I wanted was something like this: def f(*a=(0,)): print a[0] >>f(1,2) 1 >>f() #no args passed 0 but this of course does not work. Again, why not? Thank you for your comments. Primoz From victorsubervi at gmail.com Thu Apr 17 12:22:09 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 17 Apr 2008 11:22:09 -0500 Subject: Prob. w/ Script Posting Last Value Message-ID: <4dc0cfea0804170922n2a96be20sc424a7e67742a12e@mail.gmail.com> Hi; Gabriel provided a lovely script for showing images which I am modifying for my needs. I have the following line: print '

\n' % (d, y) where the correct values are entered for the variables, and those values increment (already tested). Here is the slightly modified script it calls: #!/usr/local/bin/python import cgitb; cgitb.enable() import MySQLdb import cgi form = cgi.FieldStorage() picid = int(form["id"].value) x = int(form["x"].value) pic = str(x) print 'Content-Type: text/html' db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor= db.cursor() sql = "select " + pic + " from products where id='" + str(picid) + "';" cursor.execute(sql) content = cursor.fetchall()[0][0].tostring() cursor.close() print 'Content-Type: image/jpeg\r\nContent-Length: %s\n' % len(content) print content I need to make it so that it will show all my images, not just the last one. Suggestions, please. TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From Lie.1296 at gmail.com Sun Apr 27 14:23:44 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 27 Apr 2008 11:23:44 -0700 (PDT) Subject: Loading associated files References: <74862697-da58-4eb7-8d60-09aaef54b7ad@j22g2000hsf.googlegroups.com> <09337541-0b3e-4aaf-b26f-06a0f689e7dc@u12g2000prd.googlegroups.com> Message-ID: <850a01c2-d59e-4ee7-a344-796fd3cbb8aa@v23g2000pro.googlegroups.com> On Apr 27, 8:21?pm, flarefi... at googlemail.com wrote: > Yep, thats pretty much exactly what i had done, those exact settings, > and it still doesnt work. As i said i looked at the other keys to > check i had done it right and a i said the settings are fine because i > can send the file to python.exe and it loads like a python file fine, > but it doesn't like passing it to my program. Have i done something > wrong with my program that simply prints the arguments?? I think either I have misunderstood the situation, you misunderstood your own situation, or you have expressed your situation incorrectly: "it loads like a python file fine". What loads like a python file fine? The python source or the data.xyz? What did you put in data.xyz? Data to be fed to your python program or python source code? Aren't we trying to load the data.xyz to your python program? Or are we trying to load data.xyz to python interpreter? Anyway, try adding quotes around the "%1", to ensure that path that contains spaces doesn't confuse the program HKEY_CLASSES_ROOT\MyApp\Shell\Open\Command => "C:\pathtomyapp \myapp.py" "%1" From deets at nospam.web.de Fri Apr 18 12:12:45 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 18 Apr 2008 18:12:45 +0200 Subject: Installing BeautifulSoup with easy_install (broken?) In-Reply-To: References: Message-ID: <66rvkdF2kqa1lU1@mid.uni-berlin.de> Larry Bates schrieb: > Info: > > Python version: ActivePython 2.5.1.1 > Platform: Windows > > I wanted to install BeautifulSoup today for a small project and decided > to use easy_install. I can install other packages just fine. > Unfortunately I get the following error from BeautifulSoup installation > attempt: > > C:\Python25\Lib\SITE-P~1>easy_install BeautifulSoup > Searching for BeautifulSoup > Reading http://pypi.python.org/simple/BeautifulSoup/ > Reading http://www.crummy.com/software/BeautifulSoup/ > Reading http://www.crummy.com/software/BeautifulSoup/download/ > Best match: BeautifulSoup 3.0.5 > Downloading > http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup- > 3.0.5.tar.gz > Processing BeautifulSoup-3.0.5.tar.gz > Running BeautifulSoup-3.0.5\setup.py -q bdist_egg --dist-dir > c:\docume~1\larry\l > ocals~1\temp\easy_install-cfdxna\BeautifulSoup-3.0.5\egg-dist-tmp-gbrpp5 > Traceback (most recent call last): > File "C:\Python25\Scripts\easy_install-script.py", line 8, in > load_entry_point('setuptools==0.6c8', 'console_scripts', > 'easy_install')() > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm > and\easy_install.py", line 1671, in main > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm > and\easy_install.py", line 1659, in with_ei_usage > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm > and\easy_install.py", line 1675, in > File "C:\Python25\lib\distutils\core.py", line 151, in setup > dist.run_commands() > File "C:\Python25\lib\distutils\dist.py", line 974, in run_commands > self.run_command(cmd) > File "C:\Python25\lib\distutils\dist.py", line 994, in run_command > cmd_obj.run() > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm > and\easy_install.py", line 211, in run > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm > and\easy_install.py", line 446, in easy_install > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm > and\easy_install.py", line 476, in install_item > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm > and\easy_install.py", line 655, in install_eggs > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm > and\easy_install.py", line 930, in build_and_install > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm > and\easy_install.py", line 919, in run_setup > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand > box.py", line 27, in run_setup > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand > box.py", line 63, in run > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand > box.py", line 29, in > File "C:\VOL1\Larry\Websafe\Python\wstools\setup.py", line 2, in > import py2exe > File "C:\VOL1\Larry\Websafe\Python\wstools\unittest.py", line 3, in > > class TextCtrlTest(unittest.TestCase): > AttributeError: 'module' object has no attribute 'TestCase' > > > Thanks in advance for any "clues". I'm not sure what happens - but I think it is suspicious that these "wstools" get into the way. And it looks as if wstools.unittest imports itself, instead of the python-unittest - which must be solved with getting the sys.path fixed. Diez From cwitts at gmail.com Tue Apr 22 08:06:03 2008 From: cwitts at gmail.com (Chris) Date: Tue, 22 Apr 2008 05:06:03 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> Message-ID: <1579bc26-193d-4e65-b5f4-3cea7d8cf4f3@t63g2000hsf.googlegroups.com> On Apr 22, 1:53?pm, azrael wrote: > Which big aplications are written in python. I see its development, > But i can't come up with a big name. I know that there are a lot of > companys using python, but is there anythong big written only in > python. I want him to fuck of with his perl once and for all time http://www.python.org/about/success/ nuff said From darcy at druid.net Wed Apr 2 16:57:31 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Wed, 2 Apr 2008 16:57:31 -0400 Subject: april fools email backfires In-Reply-To: References: <7xbq4sf9wv.fsf@ruckus.brouhaha.com> Message-ID: <20080402165731.48e943b2.darcy@druid.net> On Wed, 02 Apr 2008 12:29:58 -0500 Grant Edwards wrote: > On 2008-04-02, Paul Rubin wrote: > > http://www.coboloncogs.org/INDEX.HTM > That's absolutely brilliant! I particularly like the flashing > effect that simulates an old screen-at-time mode terminal (or > maybe a storage-scope terminal?), and the faint "burn-in" text > in the background. I nearly fell off my chair when I read this one. WE EXPECT FULL CHARACTER SET SUPPORT FOR EBCDIC AND A LARGE SUBSET OF ASCII IN THE 1.34 RELEASE. TIHS WILL INCLUDE SUPPORT FOR SPECIAL CHR SUCH AS THE EURO SYMBOL AND LOWER CASE LETTERS. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From michael at stroeder.com Thu Apr 24 05:25:48 2008 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Thu, 24 Apr 2008 11:25:48 +0200 Subject: python-ldap - Operations Error In-Reply-To: References: Message-ID: theiviaxx at gmail.com wrote: >>>> import ldap >>>> l = ldap.initialize("ldap://server.net") >>>> l.simple_bind(DN, "secret") > 1 ^^^ You probably want to use the synchronous method simple_bind_s() since you want to impersonate on this LDAP connection immediately before doing anything else on that connection. >>>> l.result(1) > (97, []) Could you please use argument trace_level=2 when calling ldap.initialize() and examine the debug log? It records all method calls of your particular LDAPObject instance. l = ldap.initialize("ldap://server.net",trace_level=2) Level 2 outputs a debug log with results received. Protect this log since it also contains passwords! >>>> l.search("dc=server,dc=net", ldap.SCOPE_SUBTREE, "(sAMAccountName=user)") > OPERATIONS_ERROR: {'info': '00000000: LdapErr: DSID-0C090627, comment: > In order to perform this operation a successful bind must be completed > on the connection., data 0, vece', 'desc': 'Operations error'} Still something went wrong with your bind. Since I don't know your DN I can't say anything. The DN should be a local user in this domain and not a user from another trusted domain. If you have a complicated AD setup with various domains and delegated trust connecting to the GC (global catalog) on port 3268 might be easier. > The simple bind works fine and returns a result, when i get the > result, it returns 97 meaning successful. It would raise an exception if an LDAP error was received. > So there was a successful > bind on the connection, right? Don't know. Since I don't know your DN and AD domain configuation. I've added a new example script ms_ad_bind.py to python-ldap's Demo/ directory illustrating all the possible bind methods: http://python-ldap.cvs.sourceforge.net/*checkout*/python-ldap/python-ldap/Demo/ms_ad_bind.py?content-type=text%2Fplain For getting the SASL stuff to correctly work your DNS has to be properly set up for AD (A RRs and matching PTR RRs for the DCs). Ciao, Michael. From yuxuy501 at yahoo.com Sun Apr 20 04:08:24 2008 From: yuxuy501 at yahoo.com (yuxuy501 at yahoo.com) Date: Sun, 20 Apr 2008 01:08:24 -0700 (PDT) Subject: Noadware.net - Spyware/Adware Remover Message-ID: <06fc8db5-e553-465d-9c84-40ffdaa3c2d5@w5g2000prd.googlegroups.com> Noadware.net - Spyware/Adware Remover http://zoneweb.freeweb7.com/noadware.html From bronger at physik.rwth-aachen.de Mon Apr 28 04:21:02 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Mon, 28 Apr 2008 10:21:02 +0200 Subject: Abuse in comp.lang.python Message-ID: <87od7uie4x.fsf@physik.rwth-aachen.de> Path: uni-berlin.de!fu-berlin.de!postnews.google.com!f63g2000hsf.googlegroups.com!not-for-mail Message-ID: <8b09fc36-5ada-4e74-bd00-9911388bc681 at f63g2000hsf.googlegroups.com> From: landerdebraznpc at gmail.com Newsgroups: comp.lang.python Subject: the pink patch Date: Mon, 28 Apr 2008 00:52:20 -0700 (PDT) Lines: 10 Organization: http://groups.google.com NNTP-Posting-Host: 212.241.180.239 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1209369140 19824 127.0.0.1 (28 Apr 2008 07:52:20 GMT) X-Complaints-To: groups-abuse at google.com NNTP-Posting-Date: Mon, 28 Apr 2008 07:52:20 +0000 (UTC) Complaints-To: groups-abuse at google.com Injection-Info: f63g2000hsf.googlegroups.com; posting-host=212.241.180.239; posting-account=fGAdLgoAAABaPJnllSky1fhOhiaRCPm2 User-Agent: G2/1.0 X-HTTP-Via: 1.1 ds4204.dedicated.turbodns.co.uk:81 (squid/2.5.STABLE12) X-HTTP-UserAgent: gzip(gfe),gzip(gfe) Xref: wilson.homeunix.com comp.lang.python:23005 the pink patch http://crack.cracksofts.com From pavlovevidence at gmail.com Mon Apr 14 23:18:06 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 14 Apr 2008 20:18:06 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <0853b778-c20b-44bb-ac9b-a5803a1aecc5@e67g2000hsa.googlegroups.com> Message-ID: <53ede0ca-ad36-4b11-b693-ea500d7b6e43@e67g2000hsa.googlegroups.com> On Apr 14, 4:27 pm, Aaron Watters wrote: > > A question often asked--and I am not a big a fan of these sorts of > > questions, but it is worth thinking about--of people who are creating > > very large data structures in Python is "Why are you doing that?" > > That is, you should consider whether some kind of database solution > > would be better. You mention lots of dicts--it sounds like some > > balanced B-trees with disk loading on demand could be a good choice. > > Well, probably because you can get better > than 100x improved performance > if you don't involve the disk and use clever in memory indexing. Are you sure it won't involve disk use? I'm just throwing this out there, but if you're creating a hundreds of megabytes structure in memory there's a chance the OS will swap it out to disk, which defeats any improvements in latency you would have gotten. However, that is for the OP to decide. The reason I don't like the sort of question I posed is it's presumptuous--maybe the OP already considered and rejected this, and has taken steps to ensure the in memory data structure won't be swapped--but a database solution should at least be considered here. Carl Banks From kay.schluehr at gmx.net Sat Apr 5 05:51:41 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 5 Apr 2008 02:51:41 -0700 (PDT) Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> Message-ID: On 5 Apr., 10:26, Aldo Cortesi wrote: > So, why did I re-write it? Well, I needed a test framework that didn't > have the deep flaws that unittest has. I needed good hierarchical > fixture management. I needed something that didn't instantiate test > suites automatically, freeing me to use inheritance more naturally > within my test suites. I'm not entirely sure what you are claiming here. From source inspections I can see that TestSuite instances are instantiated by the TestLoader and you are free to derive from TestLoader, overwrite its methods and pass around another instance than defaultTestLoader ( or a fresh instance of TestLoader which is the same thing ). My impression is that unittest is bashed so much because it has Java style naming conventions i.e. for bike shading reasons not because people come up with a much improved way to create test frameworks or even understand what a framework is and create a new one just for applying a different default behaviour. The split into TestLoader, TestRunner, TestCase and TestSuite is pretty canonical and I still fail to see what can't be done with them and OO techniques. From medin0065 at gmail.com Sun Apr 20 10:45:58 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:45:58 -0700 (PDT) Subject: nero full version crack Message-ID: <8cdfd29a-0733-4631-b4d2-12eacb6cc191@m73g2000hsh.googlegroups.com> nero full version crack http://cracks.00bp.com F R E E C R A C K S From duncan.booth at invalid.invalid Wed Apr 9 06:28:35 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 9 Apr 2008 10:28:35 GMT Subject: Coping with cyclic imports References: <87bq4knmax.fsf@physik.rwth-aachen.de> <87iqyr9xoz.fsf@physik.rwth-aachen.de> Message-ID: Torsten Bronger wrote: > So, the last question is: Under which circumstances does this > happen? It happens when you import a module which imports (directly > or indictly) the current module and which comes before the current > module in the import order while the program runs. > > If you don't rely on imported things at top-level code (but only in > functions and methods which in turn must not be called from the > top-level), everything is fine. > > Can anybody confirm that this is correct? Imports are pretty straightforward really. Just remember the following: 'import' and 'from xxx import yyy' are executable statements. They execute when the running program reaches that line. If a module is not in sys.modules, then an import creates the new module entry in sys.modules and then executes the code in the module. It does not return control to the calling module until the execution has completed. If a module does exist in sys.modules then an import simply returns that module whether or not it has completed executing. That is the reason why cyclic imports may return modules which appear to be partly empty. Finally, the executing script runs in a module named __main__, importing the script under its own name will create a new module unrelated to __main__. Take that lot together and you shouldn't get any surprises when importing modules. From deets at nospam.web.de Tue Apr 15 05:11:40 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 15 Apr 2008 11:11:40 +0200 Subject: How to import C++ static library? References: Message-ID: <66j9r8F2k2iplU1@mid.uni-berlin.de> Alexander Dong Back Kim wrote: > Hi all, > > I'm very very beginner of python but I'm dare to ask this question > straight away. =P > > Is it possible to import C++ static library compiled by GCC? The > target is definitely Linux machine. > > I found some examples from Google showing the way C++ can import > Python so called embedded python. But I want to the opposite way of > this. I want to import (or include in C world terminology) the library > which is a blah.a file to reuse in python. > > Any suggestion or idea for this stupid beginner? ;) For C++, you need to create a wrapping using C++ wrapper tools. There are a few available: SWIG, Boost::Python and SIP. I can only comment personally on the latter - and can recommend it without any doubt. Diez From sanhitam at yahoo.com Thu Apr 10 16:03:37 2008 From: sanhitam at yahoo.com (Sanhita Mallick) Date: Thu, 10 Apr 2008 13:03:37 -0700 (PDT) Subject: Graphs in Python In-Reply-To: Message-ID: <460620.27259.qm@web55613.mail.re4.yahoo.com> Hi Matthieu. I have looked at that, and other similar ones all of which are based on Graphviz. My problem is that I myself am creating some large graphs,contrary to an already created network, say, a social network of python-list or my-space, downloaded from somewhere as indicated in some of the softwares.So I would like to use a graphical/visual method than typing out the nodes. But I see that these same packages are being mentioned by others - so I guess that is the only option right now. Also, I am looking for a good tutorial for basic graph implementation other than the one on python.org. Thanks. -SM --- Matthieu Brucher wrote: > Hi, > > Did you try packages dedicated to graphs, like > NetworkX ? > > Matthieu > > 2008/4/10, Sanhita Mallick : > > > > Hi. > > > > I am a newbie to Python. I am trying to implement > a > > Python code for graph manipulation. My graphs are > > about 200-500 nodes big. Excepting for the short > basic > > graph implementation info on Python.org, where can > I > > find more in depth info about how to express > graphs in > > python, and how to use them in a code? > > > > Also, does anyone know of a easy way of creating > the > > dictionary for python for a 500-node graph, > without > > typing each and every node? I found some > application > > that recognize dot file Graphviz - but I am > looking > > for a program that can let me "draw" a graph and > then > > generate the lists automatically from the drawing. > > > > Thanks. > > -SM > > > > -- > > > http://mail.python.org/mailman/listinfo/python-list > > > > > > -- > French PhD student > Website : http://matthieu-brucher.developpez.com/ > Blogs : http://matt.eifelle.com and > http://blog.developpez.com/?blog=92 > LinkedIn : > http://www.linkedin.com/in/matthieubrucher > > -- > http://mail.python.org/mailman/listinfo/python-list From nothanks at null.invalid Wed Apr 30 00:46:15 2008 From: nothanks at null.invalid (Bill) Date: Wed, 30 Apr 2008 00:46:15 -0400 Subject: timeout In-Reply-To: <1a9b19bf-5075-4bce-812d-5516d3a4e454@b9g2000prh.googlegroups.com> References: <1a9b19bf-5075-4bce-812d-5516d3a4e454@b9g2000prh.googlegroups.com> Message-ID: maehhheeyy wrote, On 4/29/2008 6:02 PM: > Hi, > > I was just wondering if there was such thing as a timeout module. Take a look at the Timer class, which is a subclass of the Thread class. Here's a link to the official Python documentation: http://www.python.org/doc/2.3.5/lib/timer-objects.html Bill From gagsl-py2 at yahoo.com.ar Sun Apr 20 04:11:54 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 05:11:54 -0300 Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> Message-ID: En Sun, 20 Apr 2008 01:55:51 -0300, Banibrata Dutta escribi?: > Wanted to check if there is any known, reliable, FOSS/Libre -- Obfurscator > for Python 2.5 code. Why do you want to do that in the first place? There is very few you can do to obfuscate Python code. You can't rename classes nor methods nor global variables nor argument names due to the dynamic nature of Python. All you can safely do is to remove comments and join simple statements using ; If you remove docstrings, some things may break. Even renaming local variables isn't safe in all cases. -- Gabriel Genellina From banibrata.dutta at gmail.com Tue Apr 22 11:26:45 2008 From: banibrata.dutta at gmail.com (Banibrata Dutta) Date: Tue, 22 Apr 2008 20:56:45 +0530 Subject: Witty retorts (was: Python Success stories) In-Reply-To: References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <87d4oi3s3c.fsf_-_@benfinney.id.au> Message-ID: <3de8e1f70804220826k76d2abe5j222079a39ad83032@mail.gmail.com> "F**k you" -- is generally an indication of "creativity blackout" followed by "frustration". Not exactly a clever retort. On 4/22/08, Max Erickson wrote: > Ben Finney wrote: > > > Carl Banks writes: > > > >> Let me tell you a little story to let you know how you should > >> act in situations like this. Some of you might have heard it > >> before. Apologies if it's a bit long. > > > > I don't know if I've heard it before; it's rather unmemorable. > > > > What lesson is it intended to teach, other than that "Fuck you" > > is somehow a "retort"? I can't see that improving too many > > situations. > > > > I got something like "Don't waste your life worrying about what some > damn clown said" out of it. > > You don't even need to swear at the clown to make it work. > > > max > > -- > http://mail.python.org/mailman/listinfo/python-list > -- regards, Banibrata http://www.linkedin.com/in/bdutta From billingspanshism at gmail.com Sat Apr 19 17:19:36 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:19:36 -0700 (PDT) Subject: victoria beckham lyrics Message-ID: Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From sjmachin at lexicon.net Thu Apr 3 19:45:19 2008 From: sjmachin at lexicon.net (John Machin) Date: Thu, 3 Apr 2008 16:45:19 -0700 (PDT) Subject: expanding a variable to a dict References: Message-ID: <76f75b0d-2355-4c18-a6e4-931c307cb5c6@u10g2000prn.googlegroups.com> On Apr 4, 9:44 am, Max M wrote: > idle skrev: > > > now I'd like to check them all for the existence of certain default > > keys; ie, if the dicts don't contain the keys, add them in with > > default values. > > > so, I've got: > > > for a in ['dictFoo','dictBar','dictFrotz']: > > if hasattr(a,'srcdir') == False: > > a['srcdir']='/usr/src' > > There are a few ways to do it. > > for a in ['dictFoo','dictBar','dictFrotz']: Ummm ... excessive apostrophes plus bonus gross syntax error, dood. Did you try running any of these snippets??? > if not a.has_key('srcdir'): a is a str object. Bang. > a['srcdir'] = '/usr/src' > > for a in ['dictFoo','dictBar','dictFrotz']: > if not 'srcdir' in a: > a['srcdir'] = '/usr/src' a is a str object. Bang. > > for a in ['dictFoo','dictBar','dictFrotz']: > a.setdefault('srcdir') = '/usr/src' SyntaxError: can't assign to function call > > -- > > hilsen/regards Max M, Denmark > > http://www.mxm.dk/ > IT's Mad Science Sure is. From deets at nospam.web.de Thu Apr 24 05:35:32 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 24 Apr 2008 11:35:32 +0200 Subject: [Python-Dev] annoying dictionary problem, non-existing keys In-Reply-To: References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> Message-ID: <67b2jqF2o55grU1@mid.uni-berlin.de> bvidinli schrieb: > I posted to so many lists because, > > this issue is related to all lists, > this is an idea for python, > this is related to development of python... > > why are you so much defensive ? > > i think ideas all important for development of python, software.... > i am sory anyway.... hope will be helpful. You could take the answers from the people (including core developers) as sign that it is *not* related to all lists. Crossposting is generally frowned upon and should be avoided. If you post here & people think that it is a python devel issue, they will indicate that. Diez From mr.ribbs at gmail.com Fri Apr 11 14:20:14 2008 From: mr.ribbs at gmail.com (Kevin Takacs) Date: Fri, 11 Apr 2008 13:20:14 -0500 Subject: About __init__ and default arguments Message-ID: Hi, I'd like to assign the value of an attribute in __init__ as the default value of an argument in a method. See below: class aphorisms(): def __init__(self, keyword): self.default = keyword def franklin(self, keyword = self.default): return "A %s in time saves nine." % (keyword) def main(): keyword = 'FOO' my_aphorism = aphorisms(keyword) print my_aphorism.franklin() print my_aphorism.franklin('BAR') if __name__ == "__main__": main() I get this error: def franklin(self, keyword = self.default): NameError: name 'self' is not defined As you might expect, I'd like to get: A FOO in time saves nine. A BAR in time saves nine. I suppose I could set the default to a string literal, test for it and if true assign the value of self.default to keyword; however, that seems clunky. Any ideas how this could be done along the lines of my proposed but faulty code? Thanks, Kevin From robert.kern at gmail.com Wed Apr 9 17:36:30 2008 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 09 Apr 2008 16:36:30 -0500 Subject: Any fancy grep utility replacements out there? In-Reply-To: References: Message-ID: <47FD36DE.9040205@gmail.com> samslists at gmail.com wrote: > Thanks to everyone who responded, and sorry for my late response. > > Grin seems like the perfect solution for me. I finally had a chance > to download it and play with it today. It's great. > > Robert...you were kind enough to ask if I had any requests. Just the > one right now of grepping through gzip files. If for some reason you > don't want to do it or don't have time to do it, I could probably do > it and send you a patch. But I imagine that since you wrote the code, > you could do it more elegantly than I could. I just checked it in. -- 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 From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 3 06:35:34 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 03 Apr 2008 12:35:34 +0200 Subject: Prototype OO In-Reply-To: References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> <47f49d4b$0$5665$426a74cc@news.free.fr> Message-ID: <47f4b2f6$0$27965$426a34cc@news.free.fr> sam a ?crit : > Bruno Desthuilliers napisa?(a): > >> Ok, I'm going to be a bit harsh, but this time I'll assume it. > >> Sam, you started this thread by asking about prototype vs class based > >> minor syntactic points that, whether you like them or not (and > > I think I will get back to this discussion after learning "descriptor > protocol" Add lookup (name resolution) rules, metaclasses, 'magic' methods etc to the list then, so you'll get a general view of Python's object model. > and maybe I will not talk about syntax then, and maybe it > won't get off topic. > > As you can see I'm novice in Python, but I can show python-experts some > newbie opinions. If somebody is an expert then he can't take a fresh > look at his many years work. This is indeed true. But be assured their are quite a few newbies (whether nwebie to Python or newbie to programming) posting here to comment on what they perceive as warts - sometimes making good points, sometimes just not knowing enough about the language's inners and/or philosophy to understand why what they think is a wart is considered a feature by more "advanced" users. As some other contributor (hi Diez !) to this thread already mentionned, "Is [Python] perfect? Heck no! But it sure is fun enough to deal with the occasional wart." From davidreynon at gmail.com Wed Apr 30 11:21:17 2008 From: davidreynon at gmail.com (korean_dave) Date: Wed, 30 Apr 2008 08:21:17 -0700 (PDT) Subject: printing inside and outside of main() module Message-ID: <9bd5c596-da19-4615-a4d8-e47b20cfb362@m73g2000hsh.googlegroups.com> This allows me to see output: ---begin of try.py print "Hello World" --end of try.py This DOESN'T though... --begin of try2.py def main(): return "Hello" --end of try2.py Can someone explain why??? From namesagame-usenet at yahoo.com Tue Apr 1 16:57:24 2008 From: namesagame-usenet at yahoo.com (gamename) Date: Tue, 1 Apr 2008 13:57:24 -0700 (PDT) Subject: Not Sure This Can Be Done... Message-ID: <46aeae28-4470-4136-a5f6-040f6468eb32@b5g2000pri.googlegroups.com> Hi, I generally have several copies of the same development environment checked out from cvs at any one time. Each development tree has a 'tools' dir containing python modules. Scattered in different places in the tree are various python scripts. What I want to do is force my scripts to always look in the closest 'tools' dir for any custom modules to import. For example: tree1/tools tree1/my_scripts/foo.py tree2/tools tree2/my_scripts/foo.py How can I make 'foo.py' always look in '../../tools' for custom modules? My preference would be to avoid changing the 'foo.py' script and have some way to resolve it via the environment (like PYTHONPATH, or .pth files, etc.). Anyone have any ideas? TIA, -T From carbanancizpo at gmail.com Fri Apr 18 16:57:01 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:57:01 -0700 (PDT) Subject: wbs pro id crack Message-ID: <31f98b5f-a3c0-447d-ab26-7c39a157bd53@p25g2000hsf.googlegroups.com> wbs pro id crack http://cracks.12w.net F R E E C R A C K S From larry.bates at websafe.com` Tue Apr 22 14:08:20 2008 From: larry.bates at websafe.com` (Larry Bates) Date: Tue, 22 Apr 2008 13:08:20 -0500 Subject: Spawing a thread and printing dots until it finishes In-Reply-To: References: Message-ID: sophie_newbie wrote: > On Apr 22, 4:41 pm, "D'Arcy J.M. Cain" wrote: >> On Tue, 22 Apr 2008 07:10:07 -0700 (PDT) >> >> >> >> sophie_newbie wrote: >>> import threading >>> class MyThread ( threading.Thread ): >>> def run ( self ): >>> myLongCommand()... >>> import time >>> t = MyThread() >>> t.start() >>> while t.isAlive(): >>> print "." >>> time.sleep(.5) >>> print "OK" >>> The thing is this doesn't print a dot every half second. It just >>> pauses for ages until the thread is finished and prints prints ".OK". >>> But if I take out the "time.sleep(.5)" line it will keep printing dots >>> really fast until the thread is finished. So it looks like its the >>> time.sleep(.5) bit that is messing this up somehow? >> We know that your main routine gives up the processor but without a >> full definition of MyThread how do we know that it ever does? I >> suspect that it hits sleep once, if at all, and then goes to the final >> print statement. In fact, I suspect that this is not exactly what you >> tried anyway. This code would not have printed ".OK" whether it >> entered the loop or not. It could have printed this; >> >> . >> OK >> >> because the print statement in the loop will print a dot on a line by >> itself. >> >> When looking for these sorts of answers you should really try to create >> a smallest program that exhibits the behaviour you are questioning and >> then cut and paste the entire script into your message unedited. Often >> enough you will even answer your own question in the process. >> >> -- >> D'Arcy J.M. Cain | Democracy is three wolveshttp://www.druid.net/darcy/ | and a sheep voting on >> +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. > > "myLongCommand()... " is a call to an function in R (the statistical > programming language) via Rpy (A python module that allows calls to > R). The call takes a couple of minutes to execute. I'm trying to build > a web front end to this R function and instead of the user looking at > a blank screen for 2-3 mins, I want to print dots to let them feel > like the program isn't hanging. > > What I am saying is that without the "time.sleep(.5)" line, the above > code will print dots on the screen continuously for 2-3 mins, filling > it up with a ridiculous ammount of dots. > > Whereas with the time.sleep line, instead of pausing for half a second > between dots, its seems to print, as you correctly pointed out: > > . > OK > > With a pause of 2-3 minutes between the . and the OK. > > I hope that clears things up a little. I haven't the faintest idea why > the code above doesn't work but hope someone has an idea. It wouldn't > be something to do with python not being able to handle multiple > threads at the same time or something? I hope there is a workaround. For a web front end you wouldn't go this route at all. You would get a progressive .GIF file that gets loaded into the client's browser and shows "activity" while the server does its thing. When the browser refreshes (after the server application completes) it would go away. You can't update a client's browser by writing dots to anything. Hope this helps. -Larry From guillermo.listas at googlemail.com Mon Apr 21 07:05:19 2008 From: guillermo.listas at googlemail.com (Guillermo) Date: Mon, 21 Apr 2008 04:05:19 -0700 (PDT) Subject: Opposite of repr() (kind of) Message-ID: Hi there, How can I turn a string into a callable object/function? I have a = 'len', and I want to do: if callable(eval(a)): print "callable", but that doesn't quite work the way I want. :) Regards, Guillermo From bbxx789_05ss at yahoo.com Sat Apr 19 03:00:05 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sat, 19 Apr 2008 00:00:05 -0700 (PDT) Subject: Inheritance confusion References: <4809932c$0$12307$c3e8da3@news.astraweb.com> Message-ID: <5ab990d0-3248-43ad-ac3d-7d3e0fc64e6f@26g2000hsk.googlegroups.com> On Apr 19, 12:37?am, Hook wrote: > Hi, > > I'm having a problem with multiple inheritance - it's clearly something > I've missed, but the web pages and books that I've consulted aren't > helping, so I'll throw myself on the mercy and collective wisdom of > Usenet! > > I've got 4 files (what I'll show has the active content removed for > brevity): > > Errors_m.py > ~~~~~~~~~~~ > class Errors (object) : > ? ? def __init__ (self, params) : > ? ? ? ? pass > > ? ? def Error (self, string) : > ? ? ? ? return 100 > > DT_m.py > ~~~~~~~ > class DT (object) : > ? ? def __init__ (self, params) : > ? ? ? ? ? ? ? ? pass > > ? ? def Date (self, epoch, pattern = 'd mmm yyyy') : > ? ? ? ? dt = datetime.datetime.fromtimestamp (epoch) > > Hook_m.py > ~~~~~~~~~ > from DT_m import DT > from Error_m import Errors > > class Hook (Errors, DT) : > ? ? def __init__ (self, params) : > ? ? ? ? DT.__init__ (self, params) > ? ? ? ? Errors.__init__ (self, params) > > DB_m.py > ~~~~~~~ > from Hook_m import Hook > > class DB (Hook) : > ? ? def __init__ (self, params) : > ? ? ? ? Hook.__init__ (self, params) > > And a test script: > > #!/usr/bin/python > > import os > import re > import string > import sys > > from DB_m import DB > > Dict = dict () > Dict ['logdir'] = '/tmp/log' > Dict ['diag'] ? = 1 > > Obj = DB (Dict) > print dir (Obj) > Obj.Connect ('Database') > > When I run the script I get this: > > Traceback (most recent call last): > ? File "./3.py", line 20, in > ? ? Obj.Connect ('Database') > ? File "/mnt/isis/Projects/Python/Learning/DB_m.py", line 102, in Connect > ? ? self.TRACE ("DB::Connect (" + database + "," + mode) > ? File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 314, in TRACE > ? ? self.DailyLog (msg) > ? File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 98, in > DailyLog > ? ? dt ? ? ? ? ?= self.Date (time ()) > TypeError: 'module' object is not callable > > Googling the "TypeError" message suggests that I've got a module and > class with the same name, but I can't see that I have. > > Can someone point me in the right direction please? > > If you need to see all the source, can do, but it's certainly too much > for an intro message! > > Thanks, > > Hook import time time() --output:-- Traceback (most recent call last): File "test1.py", line 3, in ? time() TypeError: 'module' object is not callable Did you do that somewhere? From casevh at gmail.com Fri Apr 11 01:06:53 2008 From: casevh at gmail.com (casevh) Date: Thu, 10 Apr 2008 22:06:53 -0700 (PDT) Subject: Integer dicision References: <5f499bee-a659-4e36-870c-076cb613a3e7@t12g2000prg.googlegroups.com> Message-ID: On Apr 10, 9:28 pm, bdsatish wrote: > How does (a/b) work when both 'a' and 'b' are pure integers ? Python defines the quotient and remainder from integer division so that a = qb + r and 0<=r < abs(b). C/C++ lets the remainder be negative. >>> divmod(-9,2) (-5, 1) >>> divmod(9,2) (4, 1) casevh From gagsl-py2 at yahoo.com.ar Wed Apr 2 17:05:57 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 02 Apr 2008 18:05:57 -0300 Subject: Adding Images to MySQL References: <4dc0cfea0804010536q71bce9ev38cff43923f5a4b8@mail.gmail.com> <4dc0cfea0804020605i1d600657n50b4ee132d7f7e@mail.gmail.com> Message-ID: En Wed, 02 Apr 2008 10:05:56 -0300, Victor Subervi escribi?: > I have tried the following code: > > #!/usr/local/bin/python > import _mysql > import MySQLdb > host = 'mysqldb2.ehost-services.com' > user = 'user' > passwd = 'pass' > db = 'bre' > print 'Content-Type: image/jpeg\r\n' > print '\nHi!\n' > db=MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > c=db.cursor() > imgfile=open("1.jpg",'rb') > f = imgfile.read() > sqlstr="insert into photo (id, img) values ('1', '" + > _mysql.escape_string(imgfile.read()) +"');" > c.execute(sqlstr) > imgfile.close() > c.close() > print '\nBye!\n' > > which prints Hi! but not Bye! and gives me an HTTP 200 error. I threw the > line > f = imgfile.read() > in there just to make sure it is reading the imgfile. Also, I tested it > with > all the import statements alone to make sure it was importing > everything. So > the problem is the c.execute statement. Please advise. (What a mess! I don't know where to begin...) - You say Content-Type: image/jpeg but you emit HTML code. You're lucky if you see any text at all. - HTTP 200 is not an error, it means the request was successful. - See the site logs looking for sql errors. - See the cgitb module http://docs.python.org/lib/module-cgitb.html - Have you read what I wrote in the message you're replying to? Use bound parameters instead of building the SQL values yourself. I'm keeping it at the bottom of this message - As a general advice, try to isolate the problems. Test the database stuff alone, in a local application. Test the cgi script alone, without database interaction. Test the database stuff in the web server (better if you have a shell account). Merge all and test again. - Please don't top post; quote the relevant parts and write your comments below the text you're replying to. > On Tue, Apr 1, 2008 at 1:37 PM, Gabriel Genellina > wrote: >> En Tue, 01 Apr 2008 09:36:00 -0300, Victor Subervi >> escribi?: >> >> > Hi; >> > I?m trying to figure out how to upload images into a MySQL database. >> > (Yes, >> > that is what I want to do.) I have a form that asks for data, like >> this: >> > 1ra Foto Peque?a: >> > >> > Then I send that form to a python script that processes like this: >> > cursor.execute('insert into products (' + col_names + ') values (' + >> > col_values + ');') >> > where col_names is all the names of the columns and col_values, >> > obviously, >> > the values. Works fine for strings and digits. Not so well for files >> :) >> > What >> > do? >> >> Always use bound parameters - not only it's easier and less error prone, >> it's safer too. How parameters are specified depends on the DBAPI module >> you're using - read the module documentation. I think MySQLdb accept >> dictionary-like marks: >> >> values = {'name': 'Red jar', >> 'descr': 'A nice red jar', >> 'pic': binary(picdata) >> } >> cursor.execute('''insert into products (name,description,picture) >> values (%(name)s, %(descr)s, %(pic)s);''', values) >> >> See PEP249 http://www.python.org/dev/peps/pep-0249/ and the >> documentation >> for your database module. -- Gabriel Genellina From gandalf at shopzeus.com Sun Apr 13 10:02:29 2008 From: gandalf at shopzeus.com (Laszlo Nagy) Date: Sun, 13 Apr 2008 16:02:29 +0200 Subject: PIL and true type fonts Message-ID: <48021275.8030509@shopzeus.com> Attached a screenshot from a text rendered by GIMP (left side) and PIL (right side). Same truetype font. Is this a bug in PIL? Thanks, Laszlo -------------- next part -------------- A non-text attachment was scrubbed... Name: 1.JPG Type: image/jpeg Size: 12725 bytes Desc: not available URL: From MarkCSU at gmail.com Wed Apr 16 09:08:05 2008 From: MarkCSU at gmail.com (MarkCSU at gmail.com) Date: Wed, 16 Apr 2008 06:08:05 -0700 (PDT) Subject: Serving binary content (images, etc) using BasteHTTPServer Message-ID: <556871d3-1fea-40f2-9cc6-2a4e3a80f968@k10g2000prm.googlegroups.com> I'm writing a simple web server in python using the BaseHTTPServer library. I can serve text content (ie html pages) with ease, but im running into troubles when i try to serve images. The image gets corrupted in transit and when I manually download the image from the website and look at it using a hex editor it appears that the first 60 (or first 3C in hex if it makes a helps) characters are missing. My code looks like this: def do_GET(s): # code that determines that yes this is an image s.send_response(200) s.send_header("Content-type", "image/jpeg") s.end_headers fileObj = open("1.jpg","rb") # file is harcoded until i get images being served correctly image = fileObj.read() s.wfile.write(image) From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 3 09:25:48 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 03 Apr 2008 15:25:48 +0200 Subject: who said python can't be obsfucated!? In-Reply-To: References: <47f4b69b$0$19766$426a74cc@news.free.fr> Message-ID: <47f4dadb$0$24535$426a74cc@news.free.fr> Marco Mariani a ?crit : > Bruno Desthuilliers wrote: > >> sig=lambda m:'@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p >> in m.split('@')]) > > > Pff... you call that a quicksort? > Nope, only somewhat obfuscated Python. And it seems it's at least obfuscated enough for you to believe it could be a quicksort implementation !-) From rkmr.em at gmail.com Wed Apr 16 12:10:42 2008 From: rkmr.em at gmail.com (rkmr.em at gmail.com) Date: Wed, 16 Apr 2008 09:10:42 -0700 Subject: python memory leak only in x86 64 linux In-Reply-To: References: Message-ID: This is the code that is causing memory leak in 64 bit python [but not in 32 bit python].. is something wrong in the code? now = datetime.datetime.now() oneday = datetime.timedelta(days=1) def birthdaycompare(a, b): if a is None and b: return 1 if a and b is None: return -1 if a is None and b is None: return 0 if a wrote: > the memory usage of a python app keeps growing in a x86 64 linux > continuously, whereas in 32 bit linux this is not the case. Python > version in both 32 bit and 64 bit linux - 2.6.24.4-64.fc8 > Python 2.5.1 (r251:54863, Oct 30 2007, 13:45:26) > > i isolated the memory leak problem to a function that uses datetime > module extensively. i use datetime.datetime.strptime, > datetime.timedelta, datetime.datetime.now methods... > > i tried to get some info with guppy and the code goes like this > > while True: > print heapy.heap().get_rp() > print heapy.setref() > users = globalstuff.q.get() > for u in users: > doalert(u) > > From meisnernel73884 at gmail.com Wed Apr 30 06:36:23 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:36:23 -0700 (PDT) Subject: cracks and keygens Message-ID: <4f4f07b6-b7ee-4085-9db0-01ebd139d899@8g2000hse.googlegroups.com> cracks and keygens http://crack.cracksofts.com From danb_83 at yahoo.com Sat Apr 5 23:59:02 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Sat, 5 Apr 2008 20:59:02 -0700 (PDT) Subject: id functions of ints, floats and strings References: Message-ID: On Apr 5, 9:30 pm, Steve Holden wrote: > > In fact all you can in truth say is that > > a is b --> a == b > You can't even guarantee that. >>> inf = 1e1000 >>> nan = inf / inf >>> nan is nan True >>> nan == nan False From hat at se-162.se.wtb.tue.nl Fri Apr 18 07:10:35 2008 From: hat at se-162.se.wtb.tue.nl (A.T.Hofkamp) Date: Fri, 18 Apr 2008 13:10:35 +0200 Subject: Fwd: is file open in system ? - other than lsof References: Message-ID: On 2008-04-17, bvidinli wrote: > is there another way, any python command sequence that i can check if > a file is open at the time of "before i process file" > > i am not interested in " the file may be written after i access it.." > the important point is " the time at i first access it." > > my routine is something like: > for i in listoffiles: > checkfileopen(i) > processfile() This code does not give you what you are after; in between 'checkfileopen()' and 'processfile()' somebody may open the file and mess with it. I quite doubt that you can get what you want, at OS level. Even if you get exclusive open(), you are not safe imho. After you opened the file for access (and before you perform the read() call), another process may also open it, and alter the data while you are reading. The same may happen between 2 read() calls. Note that a read() at OS level is not the same as a read() at Python (or C fread()) level. Python pretends to read an entire file in one call, but the OS is using disk-blocks of the underlying file system as unit of read/write. In other words, even if nobody messes with the file at the moment you open it, you don't necessarily get an uncorrupted file afaik. Sincerely, Albert From gagsl-py2 at yahoo.com.ar Mon Apr 14 00:55:41 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 14 Apr 2008 01:55:41 -0300 Subject: Host: header References: <20080414040454.E685730AC25@mail-in-03.arcor-online.net> Message-ID: En Mon, 14 Apr 2008 01:04:40 -0300, Penny Y. escribi?: > I have a problem with a request url,for example, I have the code below, > > import httplib > > try: > conn = httplib.HTTPConnection("192.168.1.1") > conn.request("GET", "/") > r1 = conn.getresponse() > if r1.status == 200: > result = 0 > except Exception: > result = -1 > > > but the server on 192.168.1.1 accept virtual host request only. > That's to say, I need to specify a "Host:" header in the request. > How to do it? thanks. Add a `headers` parameter to the request method. See http://docs.python.org/lib/httpconnection-objects.html Something like this (untested): headers = {'Host', 'the.host.name'} conn = httplib.HTTPConnection("192.168.1.1") conn.request("GET", "/", headers=headers) -- Gabriel Genellina From fr5478bey at gmail.com Sat Apr 26 11:40:31 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:40:31 -0700 (PDT) Subject: doom 3 crack Message-ID: <48dcecb7-dde8-4595-b2cc-1c531884bfb5@c65g2000hsa.googlegroups.com> doom 3 crack http://cracks.00bp.com F R E E C R A C K S From paddy3118 at googlemail.com Tue Apr 1 15:35:46 2008 From: paddy3118 at googlemail.com (Paddy) Date: Tue, 1 Apr 2008 12:35:46 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: On Apr 1, 6:27 pm, sprad wrote: > I'm a high school computer teacher, and I'm starting a series of > programming courses next year (disguised as "game development" classes > to capture more interest). The first year will be a gentle > introduction to programming, leading to two more years of advanced > topics. > > I was initially thinking about doing the first year in Flash/ > ActionScript, and the later years in Java. My reasoning is that Flash > has the advantage of giving a quick payoff to keep the students > interested while I sneak in some OOP concepts through ActionScript. > Once they've gotten a decent grounding there, they move on to Java for > some more heavy-duty programming. > > I've never used Python, but I keep hearing enough good stuff about it > to make me curious. > > So -- would Python be a good fit for these classes? Could it equal > Java as the later heavy-duty language? Does it have enough quickly- > accessible sparklies to unseat Flash? > > I want to believe. Evangelize away. How proficient are you in Flash/Actionscript? I suggest you try out Python/Pygame and extrapolate from that, given your available time, would you be proficient enough to teach it? - Paddy. From pylists at arcor.de Mon Apr 14 21:28:03 2008 From: pylists at arcor.de (Penny Y.) Date: Tue, 15 Apr 2008 09:28:03 +0800 Subject: =?gb2312?B?tPC4tDog09DW0Ln6yMu69T8=?= In-Reply-To: Message-ID: <20080415012810.389931CB844@mail-in-05.arcor-online.net> -----????----- ???: python-list-bounces+pylists=arcor.de at python.org [mailto:python-list-bounces+pylists=arcor.de at python.org] ?? Steve Holden ????: 2008?4?15? 2:17 ???: python-list at python.org ??: Re: ?????? >Since what I entered in English was something like "Yes, Python has a >future. But it will take some study". Perhaps you can tell me whether >your translation gives the correect flavor. I'm pretty sure the >babelfish mangled my intent. Babelfish does that thing worse. yes follow your words, the translation could be: Python????.????????, ??????. :-) From ggpolo at gmail.com Sat Apr 5 12:14:37 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sat, 5 Apr 2008 13:14:37 -0300 Subject: Tkinter: making buttons the same size? In-Reply-To: <12bad1a6-3b4b-446e-9673-8893cd6838f9@s37g2000prg.googlegroups.com> References: <12bad1a6-3b4b-446e-9673-8893cd6838f9@s37g2000prg.googlegroups.com> Message-ID: 2008/4/5, skanemupp at yahoo.se : > on windows vista these buttons dont have the same size, the "/" > shrinks a little. how do i make them the same size or prevent > shrinking? > a mac-user told me they look the same to him so maybe it doesnt shrink > on macs but it does when using VISTA. > > i tried some .propagate and extend-stuff but didnt work. > > #! /usr/bin/env python > from Tkinter import * > import tkMessageBox > > class GUIFramework(Frame): > """This is the GUI""" > > def __init__(self, master=None): > """Initialize yourself""" > > """Initialise the base class""" > Frame.__init__(self,master) > > """Set the Window Title""" > self.master.title("Calculator") > > """Display the main window" > with a little bit of padding""" > self.grid(padx=10,pady=10) > self.CreateWidgets() > > > > def CreateWidgets(self): > > > self.btnDisplay = Button(self,text='1',command=lambda > n=1:self.Display(n)) > self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) > > self.btnDisplay = Button(self,text='/',command=lambda > n="/":self.Display(n)) > self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) > Specify width=1 for both buttons. > def Display(self, number): > print number > > if __name__ == "__main__": > guiFrame = GUIFramework() > guiFrame.mainloop() > > -- > http://mail.python.org/mailman/listinfo/python-list > -- -- Guilherme H. Polo Goncalves From balta96428 at gmail.com Wed Apr 23 05:55:05 2008 From: balta96428 at gmail.com (balta96428 at gmail.com) Date: Wed, 23 Apr 2008 02:55:05 -0700 (PDT) Subject: keygen dreamfeeder 2.0.12 Message-ID: keygen dreamfeeder 2.0.12 http://cracks.12w.net F R E E C R A C K S From llothar at web.de Fri Apr 4 02:51:55 2008 From: llothar at web.de (llothar) Date: Thu, 3 Apr 2008 23:51:55 -0700 (PDT) Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' Message-ID: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> On windows everything is '.pyd' but there seems to be two ways to get this on unix? Why and what is the rule? From james at reggieband.com Sun Apr 27 09:15:06 2008 From: james at reggieband.com (james at reggieband.com) Date: Sun, 27 Apr 2008 06:15:06 -0700 (PDT) Subject: Installed python 2.5 over 2.4 and lost installed packages Message-ID: <6c77d0e5-f387-449d-9147-d7aefa3d2735@l64g2000hse.googlegroups.com> Hi all, I recently updated os x from python 2.4 to 2.5 (from python.org) and in doing so I lost my old python path entries. Python 2.4 was installed using fink. Now when I do: import sys print sys.path my old site-packages directory is not within it (the 2.4 one). So what is the right thing to do in this situation? It would be a pain to find and re-install each of the packages. Is it ok to add my old site-packages directory to the sys.path? What is the best way to do so (e.g. using .pth files or PYTHONPATH or other)? Is cp'ing the files from one place to another safe or advisable? Any help on best practices appreciated. James. From R.Brodie at rl.ac.uk Wed Apr 16 10:41:49 2008 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Wed, 16 Apr 2008 15:41:49 +0100 Subject: Serving binary content (images, etc) using BasteHTTPServer References: <556871d3-1fea-40f2-9cc6-2a4e3a80f968@k10g2000prm.googlegroups.com> Message-ID: wrote in message news:556871d3-1fea-40f2-9cc6- > s.end_headers A bare method name (without parentheses) won't get called. From guybenron at gmail.com Tue Apr 22 15:18:11 2008 From: guybenron at gmail.com (guybenron at gmail.com) Date: Tue, 22 Apr 2008 12:18:11 -0700 (PDT) Subject: Choosing log file destination in logging configuration file Message-ID: <3e85cd72-304e-4e17-8ca9-b0688a59fc14@t54g2000hsg.googlegroups.com> Hey, I have a sort of petty-neurotic question, I'm kinda pedantic and like to keep my log directories clean, and this thing is bothering me to the point of actually posting a question (couldn't find any post about this..). My application has two types of components: daemons and regular ones that are run every on crontab. Because the log structure is very similar, I want both to use the same logging configuration file. For clarity, I want all of the files to have the date as part of the filename. The TimedRotatingFileHandler has it built in (once it rotates), and I found a dirty hack to make it work for the FileHandler (see shameful code below). Basically I'm all set - have the daemons use the rotating handler, since they're, um, daemonic and on all the time, and have the regular components use the regular handler, using the dirty hack to insert the date into the filename. So far so good. In the relevant applications, the code looks something like this: logging.config.fileConfig('log.ini') logger = logging.getLogger('log.regular') logger = logging.getLogger('log.daemonic') .. and start logging. The thorn in my side is that after the fileConfig call, BOTH handlers are instantiated, meaning both types of files are created for every component, even if I don't need it: component.log (for the rotating handler) and compenent.date.log (for the regular file handler). ..So finally, here's my question: Apart from splitting the logging configuration into two separate files, is there any way to NOT create the file until you actually use it? Here's the logging configuration file for reference.. Thanks ! [loggers] keys=root,regular,daemonic [handlers] keys=fileHandler,consoleHandler,timedRotatingFileHandler [formatters] keys=simpleFormatter [logger_root] level=DEBUG handlers=consoleHandler [logger_regular] level=INFO handlers=fileHandler,consoleHandler propagate=0 qualname=log.regular [logger_daemonic] level=INFO handlers=timedRotatingFileHandler,consoleHandler propagate=0 qualname=log.daemonic [handler_timedRotatingFileHandler] class=handlers.TimedRotatingFileHandler level=INFO formatter=simpleFormatter args=('mylog.log', 'midnight') [handler_fileHandler] class=FileHandler level=INFO formatter=simpleFormatter ; sorry about the grossness args=('mylog.' + str(time.localtime().tm_year) + '_' + str(time.localtime().tm_mon).zfill(2) + '_' + str(time.localtime().tm_mday).zfill(2) + '.log', 'a') [handler_consoleHandler] class=StreamHandler level=DEBUG formatter=simpleFormatter args=(sys.stdout,) [formatter_simpleFormatter] format=%(asctime)s - %(filename)s - %(name)s - %(levelname)s - % (message)s From kyosohma at gmail.com Fri Apr 18 16:41:12 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 18 Apr 2008 13:41:12 -0700 (PDT) Subject: Error with win32com client on windows 2003 server References: Message-ID: On Apr 18, 3:12 pm, SPJ wrote: > Sorry, forgot to mention Subject in my earlier post, hence reposting. > ------------ > I am writing a script which need's to convert an excel file to csv (text) format. For that I am using the following code: > > excel = win32com.client.Dispatch("Excel.Application","Quit") > workbook = excel.Workbooks.Open(xlsfile) > workbook.SaveAs(csvfile, FileFormat=24) # 24 represents xlCSVMSDOS > workbook.Close(False) > excel.Quit() > > I did not have any problem running this script on a windows xp machine with python 2.5.2 and windows extensions. But I get the following error when I run the same script on a windows 2003 server with the same python and windows extension installation: > > excel = win32com.client.Dispatch("Excel.Application","Quit") > File "D:\Python25\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch > dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) > File "D:\Python25\lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName > return (_GetGoodDispatch(IDispatch, clsctx), userName) > File "D:\Python25\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) > com_error: (-2147221005, 'Invalid class string', None, None) > > I verified that installation is same. Any idea's as to what might be the problem? One thing I have noticed though is I can't see Microsoft office 11.0 object library when I do combrowse on windows 2003 server. I also to tried to reinstall python and windows extension. But still no luck. > > I would appreciate if anyone can guide me as to why this is happening and how to resolve this. > > Thanks, > SPJ > > ____________________________________________________________________________________ > Be a better friend, newshound, and > know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ I would recommend that you re-post to the PyWin32 user's group. They know the low-down on this stuff. You can find them here: http://mail.python.org/mailman/listinfo/python-win32 However, if you cannot access the object library, than that's probably the problem. I've no idea how to resolve that though. The gurus on the group linked above would likely know however. Mike From steve at holdenweb.com Wed Apr 9 10:03:19 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 10:03:19 -0400 Subject: I am worried about Python 3 In-Reply-To: <44c8b263-a01b-45b5-a971-faa6aa1611ec@d45g2000hsc.googlegroups.com> References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> <44c8b263-a01b-45b5-a971-faa6aa1611ec@d45g2000hsc.googlegroups.com> Message-ID: Mike Driscoll wrote: > On Apr 9, 7:04 am, jmDesktop wrote: >> I am a new Python programmer. I have always desired to learn Python, >> but have never had the opportunity. Recently this has changed, and I >> have an opportunity to get away from the .NET framework. I found >> Django (and other web frameworks) and began my quest to learn. I >> started reading Dive Into Python and anything I could find and started >> participating here in usenet. Then I had to read this: >> >> http://www.comp.leeds.ac.uk/nde/papers/teachpy3.html >> >> I think that every time I start a new technology (to me) it is about >> to change. Yes, I know that is the nature of things, but I'm always >> at the start of "something new." >> >> If I continue in Python 2.5.x, am I making a mistake? Is it really >> that different? >> >> Here is an excerpt that is causing me concern: >> >> Two new versions of the language are currently in development: version >> 2.6, which retains backwards compatibility with previous releases; and >> version 3.0, which breaks backwards compatibility to the extent that >> even that simplest of programs, the classic 'Hello, World', will no >> longer work in its current form. >> >> It makes me feel like I am wasting my time and makes it difficult to >> justify spending time on projects using 2.5.x and using it where I >> work. > > Just because there's a new version on the horizon that doesn't mean > you have to upgrade to it. There are plenty of people that still use > 2.3, such as my web host. I've only just started really using 2.5 this > year. > And for what it's worth, even after the 2.6/3.0 release (they are both due out simultaneously in August, modulo slippage) the python.org site will be advising new users to go with 2.6. The 2.X series will continue to be supported for some time (years) after the release of 3.0. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From http Thu Apr 10 13:17:25 2008 From: http (Paul Rubin) Date: 10 Apr 2008 10:17:25 -0700 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: <7xod8h39zu.fsf@ruckus.brouhaha.com> Michel Bouwmans writes: > > If by "best" you mean "easiest", that is probably tkinter, > I don't quite agree with you on this. Tkinter may be easy because it is > available by standard in Python, but that's about it in my opinion. The > API, look and performance hit is horrible. You're much better of with PyQt4 > which makes the job really simple. Well, it's a trade-off, the person wanted a cross platform gui and the #1 hurdle for something like PyQt4 is getting it to work on each of the platforms you desire to run on. With tkinter, that has already been done. I can walk up to any Linux, Windows, Mac, etc. box where Python is installed and put up a simple tkinter gui in under a minute. With anything else, I'm in installation hell for some indeterminate amount of time before I can put up "hello world", especially if I insist on installing from source (the alternative is accepting binaries from yet another third party, like handing out more and more keys to your house). I agree with you that tkinter gui's don't look as slick as PyQt4 etc. Whether that's important depends on your application's requirements. For what I've done with it so far, it's been good enough. I haven't compared the Python API's but have used some other gui toolokts on other platforms and tkinter seems comparable to the others in ease of use. I hadn't really thought about performance for something like a gui, though I guess it could matter for certain types of apps. From ajaksu at gmail.com Thu Apr 3 15:24:12 2008 From: ajaksu at gmail.com (ajaksu) Date: Thu, 3 Apr 2008 12:24:12 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> <58deb8b8-bae9-4d43-b973-3d90846726cb@b5g2000pri.googlegroups.com> Message-ID: <42106982-8d2e-4c98-b316-d6dc0a675230@a23g2000hsc.googlegroups.com> On Apr 2, 5:01?pm, John Henry wrote: > However, once I start teaching him variables, expressions, loops, and > what not, I found that (by surprise) he had great difficulties > catching on. ?Not soon after that, we had to quit. This makes me curious: how much of videogamer are you? And your son? I ask that because when I think about teaching programming to young kids, I imagine using terms they know from gaming, like "save slots" (variables/names), "memory cards" (containers), "combos" (functions, loops), "life meters" (counters), "next level" (conditionals, iteration, loops), "teammates" (helper functions), "character classes" and "characters" (class and instances), "confirm/cancel" (conditionals), etc. But I've never really tried to put all those together and find a test subject, so I'd like to know how fluent in this lingo you both were so I can assess my pseudo-didatic approach by proxy :) Regards, Daniel From ivan.illarionov at gmail.com Sat Apr 19 00:45:54 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Sat, 19 Apr 2008 04:45:54 +0000 (UTC) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> Message-ID: On Fri, 18 Apr 2008 22:30:45 -0500, Grant Edwards wrote: > On 2008-04-18, Bob Greschke wrote: > >> However, in playing around with your suggestion and Grant's code I've >> found that the struct stuff is WAY slower than doing something like >> this >> >> Value = (ord(Buf[s])*65536)+(ord(Buf[s+1])*256)+ord(Buf[s+2]) if Value >> >= 0x800000: >> Value -= 0x1000000 >> >> This is almost twice as fast just sitting here grinding through a few >> hundred thousand conversions (like 3sec vs. ~5secs just counting on my >> fingers - on an old Sun...it's a bit slow). Replacing *65536 with <<16 >> and *256 with <<8 might even be a little faster, but it's too close to >> call without really profiling it. > > I didn't know speed was important. This might be a little faster > (depending on hardware): > > Value = (ord(Buf[s])<<16) | (ord(Buf[s+1])<<8) | ord(Buf[s+2]) > > It also makes the intention a bit more obvious (at least to me). > > A decent C compiler will recognize that <<16 and <<8 are special and > just move bytes around rather than actually doing shifts. I doubt the > Python compiler does optimizations like that, but shifts are still > usually faster than multiplies (though, again, a good compiler will > recognize that multiplying by 65536 is the same as shifting by 16 and > just move bytes around). So why not put it in C extension? It's easier than most people think: from3bytes.c ============ #include PyObject* from3bytes(PyObject* self, PyObject* args) { const char * s; int len; if (!PyArg_ParseTuple(args, "s#", &s, &len)) return NULL; long n = (s[0]<<16) | (s[1]<<8) | s[2]; if (n >= 0x800000) n -= 0x1000000; return PyInt_FromLong(n); } static PyMethodDef functions[] = { {"from3bytes", (PyCFunction)from3bytes, METH_VARARGS}, {NULL, NULL, 0, NULL}, }; DL_EXPORT(void) init_from3bytes(void) { Py_InitModule("_from3bytes", functions); } buildme.py ========== import os import sys from distutils.core import Extension, setup os.chdir(os.path.dirname(os.path.abspath(__file__))) sys.argv = [sys.argv[0], 'build_ext', '-i'] setup(ext_modules = [Extension('_from3bytes', ['from3bytes.c'])]) 'python buildme.py' will create '_from3bytes.so' file 'from _from3bytes import from3bytes' will import C-optimized function Hope this helps. -- Ivan Illarionov From brian.e.munroe at gmail.com Fri Apr 25 11:06:11 2008 From: brian.e.munroe at gmail.com (Brian Munroe) Date: Fri, 25 Apr 2008 08:06:11 -0700 (PDT) Subject: Class Inheritance - What am I doing wrong? References: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> <613bc152-a6f4-4db4-8f90-593cb3f629c7@s33g2000pri.googlegroups.com> Message-ID: On Apr 24, 10:11 pm, Arnaud Delobelle wrote: > In python, use attributes starting with a single underscore (such as > _name). It tells users that they shouldn't mess with them. By > design, python doesn't include mechanisms equivalent to the Java / C++ > 'private'. Arnaud, Gabriel: Ok, Ok, I'll trust my users to not abuse my API :) I didn't realize that 'private' meant 'private, even to sub-classes' - it is all becoming clear to me now! Thanks for the help, and I'm going to re-read 'Python is Not Java' right about now (I've spent the past few months knee-deep in Java, I guess I need to cleanse myself) From ellingt8877 at gmail.com Mon Apr 28 01:46:14 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:46:14 -0700 (PDT) Subject: spy sweeper crack Message-ID: <62b9449f-1c0b-4c1c-a09a-63c5eae0b6cd@j33g2000pri.googlegroups.com> spy sweeper crack http://crack.cracksofts.com From steve at holdenweb.com Sat Apr 12 09:11:32 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 09:11:32 -0400 Subject: Tremendous slowdown due to garbage collection In-Reply-To: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> Message-ID: <4800B504.4010601@holdenweb.com> [...] > I would suggest to configure the default behaviour of the garbage > collector in such a way that this squared complexity is avoided > without requiring specific knowledge and intervention by the user. Not > being an expert in these details I would like to ask the gurus how > this could be done. > I hope this should be at least technically possible, whether it is > really desirable or important for a default installation of Python > could then be discussed once the disadvantages of such a setting would > be apparent. > > Thanks a lot for your consideration, and best regards, > Andreas > I think the linguists of the world should write better automated translation systems. Not being an expert in these details I would like to ask the gurus how it could be done. There are going to be pathological cases in any memory allocation scheme. The fact that you have apparently located one calls for you to change your approach, not for the finely-tuned well-conceived garbage collection scheme to be abandoned for your convenience. If you had made a definite proposal that could have been evaluated you request would perhaps have seemed a little more approachable. You might want to consider trying Jython, or IronPython, or PyPy, each of which comes with a different flavor of garbage collection, to see if one of the other approaches suits you better. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bronger at physik.rwth-aachen.de Thu Apr 10 12:49:50 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Thu, 10 Apr 2008 18:49:50 +0200 Subject: Cyclic relative imports don't work Message-ID: <871w5dvemp.fsf@physik.rwth-aachen.de> Hall?chen! Assume the follwing package structure: main.py package/ __init__.py [empty] moduleX.py moduleY.py main.py says: from package import moduleX moduleX.py says: from . import moduleY and moduleY.py says: from . import moduleX However, this doesn't work: bronger at wilson:~/temp/packages-test$ python main.py Traceback (most recent call last): File "main.py", line 1, in from package import moduleX File "/home/bronger/temp/packages-test/package/moduleX.py", line 1, in from . import moduleY File "/home/bronger/temp/packages-test/package/moduleY.py", line 1, in from . import moduleX ImportError: cannot import name moduleX If I turn the relative imports to absolute ones, it works. But I'd prefer the relative notation for intra-package imports. Why is this restriction? Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From gagsl-py2 at yahoo.com.ar Wed Apr 23 23:50:42 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 24 Apr 2008 00:50:42 -0300 Subject: logging doc problem References: Message-ID: En Wed, 23 Apr 2008 23:08:49 -0300, James Stroud escribi?: > Am I missing something or are the docs for logging hopelessly outdated? > > http://docs.python.org/lib/node406.html > > For example, quoting the docs > > """ > import logging > > logging.debug('A debug message') > logging.info('Some information') > logging.warning('A shot across the bows') > """ > > And the result is > > % /usr/bin/python > Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) > [GCC 4.0.1 (Apple Inc. build 5465)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > py> import logging > py> > py> logging.debug('A debug message') > Traceback (most recent call last): > File "", line 1, in > AttributeError: 'module' object has no attribute 'debug' Probably you have another logging.py and you're importing it instead of the one in the standard library. -- Gabriel Genellina From john106henry at hotmail.com Sat Apr 26 18:03:32 2008 From: john106henry at hotmail.com (John Henry) Date: Sat, 26 Apr 2008 15:03:32 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> Message-ID: On Apr 26, 8:46 am, a... at pythoncraft.com (Aahz) wrote: > In article <9028496e-30de-4853-8f57-b55d14e52... at h1g2000prh.googlegroups.com>, > John Henry wrote: > > > > >But then I looked closer. It turns out the XML file created by > >QxTransformer is *very* similar in structure when compared to the > >resource files used inPythonCard. Since there are no GUI builders > >for QxTransformer, and I can't affort to buy the one for Qooxdoo > >(Java! Yuk!), I decided to roll up my sleeves, took thePythoncard's > >Layout Manager and modified it and created my own "Poor Man's Qooxdoo > >GUI Layout Designer". > > Cute! When you have working code, please do upload to PyPI. > -- > Aahz (a... at pythoncraft.com) <*> http://www.pythoncraft.com/ > > Why is this newsgroup different from all other newsgroups? So far, I have the following widgets working: window, button, checkbox, static text, static box, list, combobox, spinner, radio button group Shouldn't be long before the following works: static line, image, image button, choice. From gagsl-py2 at yahoo.com.ar Fri Apr 25 22:02:05 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 25 Apr 2008 23:02:05 -0300 Subject: newbie question References: Message-ID: En Fri, 25 Apr 2008 19:35:58 -0300, John escribi?: > I'm working with the HTMLParser module and have implemented > HTMLParser.handle_starttag() and I see there is a separate > handle_data > method (which can be implemented), but I am not clear how to tie this > together with a given start tag, so I only get the data I want. > > For example, I'd like to get a handle on the character data ( the > number 1) immediately after the following start tag > > > > 1
> . > . > . > Any ideas? I usually don't recommend HTMLParser because a lot of HTML documents in the Web are not even remotely valid, and the parser can't handle that. BeautifulSoup is a more robust alternative: -- Gabriel Genellina From anuraguniyal at yahoo.com Tue Apr 1 03:29:22 2008 From: anuraguniyal at yahoo.com (anuraguniyal at yahoo.com) Date: Tue, 1 Apr 2008 00:29:22 -0700 (PDT) Subject: bsddb3 thread problem Message-ID: In my application I am trying to access(read) a DB thru a thread while my main thread is adding data to it and it gives following error(s) bsddb._db.DBRunRecoveryError: (-30974, 'DB_RUNRECOVERY: Fatal error, run database recovery -- PANIC: Permission denied') and sometimes bsddb._db.DBRunRecoveryError: (-30974, 'DB_RUNRECOVERY: Fatal error, run database recovery -- PANIC: fatal region error detected; run recovery') sometimes bsddb._db.DBInvalidArgError: (22, 'Invalid argument -- DB_LOCK- >lock_put: Lock is no longer valid') sometimes pure seg fault. Program received signal SIGSEGV, Segmentation fault. 0xb7c1b845 in __bam_adjust () from /usr/lib/libdb-4.4.so and some time memory usage keeps on increasing and cpu is 100% it crashes with memory error. This doesn't happen always, almost 1 in 10 cases. If i use simple python threaded function instead of threading class, it works. I have attached a simple script which tries to replicate the scenario. Do anybody has a clue what I am doing wrong here? I suppose bsddb3 DB can be accessed from mutiple threads? or do I need to specifically set DB_THREAD flag? though with db.DB_THREAD it hangs on some mutex? Thanks a lot Anurag ------- import time import os import threading import thread import shutil from bsddb3 import db class DocQueueConsumer(threading.Thread): def __init__(self, queueDB): threading.Thread.__init__(self) self.queueDB = queueDB self.setDaemon(True) def run(self): while True: self.queueDB.cursor() def crash(): path = "/tmp/test_crash" if os.path.exists(path): shutil.rmtree(path) os.mkdir(path) aBigEnv = db.DBEnv() aBigEnv.set_cachesize(0, 512*1024*1024) aBigEnv.open(path, db.DB_INIT_CDB|db.DB_INIT_MPOOL|db.DB_CREATE) queueDB = db.DB(aBigEnv) queueDB.open('mydb', dbtype=db.DB_RECNO, flags=db.DB_CREATE) DocQueueConsumer(queueDB).start() for i in xrange(10**5): if i%1000==0: print i/1000 queueDB.append("something") crash() ------- From gagsl-py2 at yahoo.com.ar Sun Apr 20 04:12:02 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 05:12:02 -0300 Subject: Calling Java Class from python References: <608239.30549.qm@web35906.mail.mud.yahoo.com> Message-ID: En Wed, 16 Apr 2008 07:37:55 -0300, Good Z escribi?: > We have developed a website in python and we need to integrate few features of third party website. They have provided us Base64EncoderDecoder Java Class and would like us to use it to encode the data before sending it to their site and decode it when received anything from their site. > > I have no idea/knowledge of Java. Can you please guide me how can i call Java class from Python scripts? Or what is the best way to handle this condition. > > Is Base64 library provided by python is compatible to Base64EncoderDecoder Java Class? If the Java class implements Base64 as defined in RFC 3548, it should be compatible with the Python base64 module. Try with some examples, including the corner cases (empty, one byte, two bytes, three bytes, length = 3n, 3n+1, 3n+2, including bytes outside the ASCII range...) -- Gabriel Genellina From usenet-nospam at well-adjusted.de Thu Apr 10 12:17:10 2008 From: usenet-nospam at well-adjusted.de (Jochen Schulz) Date: Thu, 10 Apr 2008 18:17:10 +0200 Subject: Data structure recommendation? References: <1adc3541-7775-4938-bd5a-953dd041656c@2g2000hsn.googlegroups.com> Message-ID: * bearophileHUGS at lycos.com: > > Please plug such good things. It seems the Python community is an > endless source of interesting modules I didn't know about. Your > (single) module looks very nice. I'll take a better look later. Could you please send me an email with an existing From: address? I tried to reply to you but apparently your From: is forged. J. -- I can tell a Whopper[tm] from a BigMac[tm] and Coke[tm] from Pepsi[tm]. [Agree] [Disagree] From mwilson at the-wire.com Tue Apr 1 23:11:46 2008 From: mwilson at the-wire.com (Mel) Date: Tue, 01 Apr 2008 23:11:46 -0400 Subject: generator functions: why won't this work? References: Message-ID: zillow20 at googlemail.com wrote: > I'm trying to understand generator functions and the yield keyword. > I'd like to understand why the following code isn't supposed to work. > (What I would have expected it to do is, for a variable number of > arguments composed of numbers, tuples of numbers, tuples of tuples, > etc., the function would give me the next number "in sequence") > #################################### > def getNextScalar(*args): > for arg in args: > if ( isinstance(arg, tuple)): > getNextScalar(arg) > else: > yield arg > #################################### > > # here's an example that uses this function: > # creating a generator object: > g = getNextScalar(1, 2, (3,4)) > g.next() # OK: returns 1 > g.next() # OK: returns 2 > g.next() # not OK: throws StopIteration error > > #################################### > > I'm sure I'm making some unwarranted assumption somewhere, but I > haven't been able to figure it out yet (just started learning Python a > couple of days ago). > > Any help will be appreciated :) `getNextScalar(arg)` doesn't yield anything (it creates, but doesn't use, a new generator object,) so nothing comes out. Look at >>> h = getNextScalar(1,2,(3,4),5) >>> h.next() 1 >>> h.next() 2 >>> h.next() 5 Maybe you want if isinstance (arg, tuple): for s in getNextScalar (*arg): yield s Mel. From ronnbus at gmail.com Mon Apr 7 18:32:49 2008 From: ronnbus at gmail.com (Ronn Ross) Date: Mon, 7 Apr 2008 18:32:49 -0400 Subject: playing around with python Message-ID: Hello all, I downloaded the source for version 2.5.2 and I played around and made some changes, but now I don't know how to compile on my machine to test them. Can someone tell me how to compile it to run on my machine? I'm trying to get familiar with it before I volunteer. Also, I'm running Unbuntu Linux. Thanks, Ronn -------------- next part -------------- An HTML attachment was scrubbed... URL: From exarkun at divmod.com Wed Apr 23 14:26:44 2008 From: exarkun at divmod.com (Jean-Paul Calderone) Date: Wed, 23 Apr 2008 14:26:44 -0400 Subject: Python generators (coroutines) In-Reply-To: Message-ID: <20080423182644.6859.212024454.divmod.quotient.34096@ohm> On Wed, 23 Apr 2008 10:53:03 -0700 (PDT), Michele Simionato wrote: >On Apr 23, 4:17 pm, rocco.ro... at gmail.com wrote: >> I would really like to know more about python 2.5's new generator >> characteristics that make them more powerful and analogous to >> coroutines. Is it possible for instance to employ them in situations >> where I would normally use a thread with a blocking I/O (or socket) >> operation? If it is, could someone show me how it can be done? There >> appears to be a very limited amount of documentation in this repect, >> unfortunately. >> >> Thank you. > >The real changes between Python 2.4 and Python 2.5 generators are >1) now you can have a yield inside a try .. finally statement >2) now you can send an exception to a generator > >The fact that now you can send values to a generator >is less important, since you could implement the >same in Python 2.4 with little effort (granted, with an uglier syntax) >whereas there was no way to get 1) and 2). >Anyway, if you have a blocking operation, the only solution is to use >a thread or a separate process. You could have #2. It's a trivial variation of sending a value. For example, http://twistedmatrix.com/trac/browser/trunk/twisted/internet/defer.py#L555 Jean-Paul From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 30 05:24:52 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 30 Apr 2008 11:24:52 +0200 Subject: @classmethod question In-Reply-To: References: Message-ID: <48183ad8$0$6034$426a74cc@news.free.fr> Scott SA a ?crit : > On 4/24/08, Bruno Desthuilliers (bruno.42.desthuilliers at websiteburo.invalid) wrote: > >>> It is a series of convenience methods, in this case I'm interacting >>> with a database via an ORM (object-relational model). >> out of curiosity : which one ? > > I'm rapidly becoming a "django junkie"^TM > (snip) Then if you want some "table-level" operations on your models, you should put them in a custom manager. You'll find relevant stuff here: http://www.b-list.org/weblog/2008/feb/25/managers/ http://www.djangoproject.com/documentation/model-api/#managers From lists at cheimes.de Sat Apr 12 08:48:02 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 12 Apr 2008 14:48:02 +0200 Subject: accessing individual characters in unicode strings In-Reply-To: References: Message-ID: <4800AF82.2020607@cheimes.de> Peter Robinson schrieb: > Dear list > I am at my wits end on what seemed a very simple task: > I have some greek text, nicely encoded in utf8, going in and out of a > xml database, being passed over and beautifully displayed on the web. > For example: the most common greek word of all 'kai' (or ??? if your > mailer can see utf8) > So all I want to do is: > step through this string a character at a time, and do something for > each character (actually set a width attribute somewhere else for each > character) As John already said: UTF-8 ain't unicode. UTF-8 is an encoding similar to ASCII or Latin-1 but different in its inner workings. A single character may be encoded by up to 6 bytes. I highly recommend Joel's article on unicode: The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) http://www.joelonsoftware.com/articles/Unicode.html Christian From rhamph at gmail.com Thu Apr 17 12:05:35 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Thu, 17 Apr 2008 09:05:35 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> Message-ID: <9140b6c2-fcf3-454f-a24e-0ed03b3b8e3b@k37g2000hsf.googlegroups.com> On Apr 17, 7:40 am, Steve Holden wrote: > I'd love to be wrong about that, but the GIL *has* been the subject of > extensive efforts to kill it over the last five years, and it has > survived despite the best efforts of the developers. Yo. http://code.google.com/p/python-safethread/ From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Fri Apr 25 08:01:12 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Fri, 25 Apr 2008 14:01:12 +0200 Subject: problem with unicode References: <26fcc207-b864-42c7-afb3-c6945e5fe29f@m44g2000hsc.googlegroups.com> Message-ID: <67dvg8F2nomm6U1@mid.individual.net> andreas.profous at googlemail.com wrote: > # media is a binary string (mysql escaped zipped file) > >>>> print media > x???[? ... > (works) Which encoding, perhaps UTF-8 or ISO8859-1? >>>> print unicode(media) > UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in > position 1: ordinal not in range(128) > (ok i guess print assumes you want to print to ascii) Not at all -- unicode tries to decode the byte string you gave it, but doesn't know which encoding to use, so it falls back to ASCII. You should decode all "incoming" byte strings to unicode objects using the right encoding -- here I tried yours with UTF-8. This works best using string's method "decode" which returns a unicode object. >>> media="x???[?" >>> print repr(media.decode("utf-8")) u'x\u30ef\u30e6\u30ed[\u30e8' Regards, Bj?rn -- BOFH excuse #379: We've picked COBOL as the language of choice. From tim.arnold at sas.com Thu Apr 24 12:46:17 2008 From: tim.arnold at sas.com (Tim Arnold) Date: Thu, 24 Apr 2008 12:46:17 -0400 Subject: convert xhtml back to html References: Message-ID: "Gary Herron" wrote in message news:mailman.130.1209053543.12834.python-list at python.org... > Tim Arnold wrote: >> hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop >> to create CHM files. That application really hates xhtml, so I need to >> convert self-ending tags (e.g.
) to plain html (e.g.
). >> >> Seems simple enough, but I'm having some trouble with it. regexps trip up >> because I also have to take into account 'img', 'meta', 'link' tags, not >> just the simple 'br' and 'hr' tags. Well, maybe there's a simple way to >> do that with regexps, but my simpleminded )]+/> doesn't work. >> I'm not enough of a regexp pro to figure out that lookahead stuff. >> >> I'm not sure where to start now; I looked at BeautifulSoup and >> BeautifulStoneSoup, but I can't see how to modify the actual tag. >> >> thanks, >> --Tim Arnold >> >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > Whether or not you can find an application that does what you want, I > don't know, but at the very least I can say this much. > > You should not be reading and parsing the text yourself! XHTML is valid > XML, and there a lots of ways to read and parse XML with Python. > (ElementTree is what I use, but other choices exist.) Once you use an > existing package to read your files into an internal tree structure > representation, it should be a relatively easy job to traverse the tree to > emit the tags and text you want. > > > Gary Herron > I agree and I'd really rather not parse it myself. However, ET will clean up the file which in my case includes some comments required as metadata, so that won't work. Oh, I could get ET to read it and write a new parser--I see what you mean. I think I need to subclass so I could get ET to honor those comments too. That's one way to go, I was just hoping for something easier. thanks, --Tim From fredrik at pythonware.com Sat Apr 5 08:47:45 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 14:47:45 +0200 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> Message-ID: Steve Holden wrote: > You display your ignorance here. The ".pyd" extension is used on Windows > as an alternative to ".dll", but both are recognized as shared > libraries. Personally I'm not really sure why they even chose to use > ".pyd", which is confusing to most Windows users. In UNIX/Linux > environments ".so" is the standard extension for a shared library. background: http://mail.python.org/pipermail/python-dev/1999-December/001456.html "Python cannot import every .dll file. Only .dll files that conform to the convention for Python extension modules can be imported. (The convention is that it must export an init function.) On most other platforms, shared libraries must have a specific extension (e.g. .so on most Unix). Python allows you to drop such a file into any directory where is looks for modules, and it will then direct the dynamic load support to load that specific file. This seems logical -- Python extensions must live in directories that Python searches (Python must do its own search because the search order is significant). On Windows, Python uses the same strategy. The only modification is that it is allowed to give the file a different extension, namely .pyd, to indicate that this really is a Python extension and not a regular DLL. This was mostly introduced because it is apparently common to have an existing DLL "foo.dll" and write a Python wrapper for it that is also called "foo". Clearly, two files foo.dll are too confusing, so we let you name the wrapper foo.pyd. But because the file format is essentially that of a DLL, we don't *require* this renaming; some ways of creating DLLs in the first place may make it difficult to do." From gagsl-py2 at yahoo.com.ar Sat Apr 12 21:36:31 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 12 Apr 2008 22:36:31 -0300 Subject: str(bytes) in Python 3.0 References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> <4800C677.5060703@v.loewis.de> Message-ID: En Sat, 12 Apr 2008 11:25:59 -0300, Martin v. L?wis escribi?: >> And making an utf-8 encoding default is not possible without writing a >> new function? > > There is no default encoding anymore in Python 3. This is by design, > learning from the problems in Python 2.x. So sys.getdefaultencoding() will disappear? Currently it returns "utf-8". In case it stays, what is it used for? -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Wed Apr 9 03:40:17 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 04:40:17 -0300 Subject: Can't figure out traceback: (error_proto(-ERR EOF) line 121 poplib.py References: <9904eabb-31e9-42df-b733-522aee7e3654@x19g2000prg.googlegroups.com> Message-ID: En Wed, 09 Apr 2008 02:19:47 -0300, erikcw escribi?: > I keep getting this error from poplib: > (error_proto(-ERR EOF) line 121 poplib.py > > Does this mean the connection has timed out? What can I do to deal > with it? If it happens from time to time, just wait a few minutes and retry... I've seen those errors with Yahoo. If you get it over and over with the same server, set_debuglevel(1) and inspect the transmission. -- Gabriel Genellina From rupole at hotmail.com Sat Apr 12 21:48:42 2008 From: rupole at hotmail.com (Roger Upole) Date: Sat, 12 Apr 2008 21:48:42 -0400 Subject: PythonWin Print Problem.. Build 210 References: Message-ID: "Hutch" wrote in message news:H29Mj.117410$yE1.54267 at attbi_s21... > PythonWin has been a very good ide from early version thru 2.4. > > All work ok on THREE of my computers with THREE different HP printers. > > Now comes 2.5. > Every thing seems to work the same except when I want to print out a copy > of the source code of my project (about 38 pages) > > Version 2.5 acts like it is going to print out the source code but instead > prints from several 100 to over 2000 BLANK PAGES pages and no source. > > Attempting to print out Source on SAME equipment (computers and printers) > using 2.4 (WITH NO CHANGES TO EQUIPMENT OR SOFTWARE ) results in > proper print out of source. > > Problem has been reported via direct and SourceForge but no response. > > Any body else having the same problem? > > -- > http://mail.python.org/mailman/listinfo/python-list > Did you see the response to the bug report on SF ? http://sourceforge.net/tracker/index.php?func=detail&aid=1907148&group_id=78018&atid=551954 There is also some more info in this thread on the python-win32 mailing list: http://mail.python.org/pipermail/python-win32/2006-December/005397.html Roger From dave.l.harrison at gmail.com Mon Apr 7 05:23:32 2008 From: dave.l.harrison at gmail.com (David Harrison) Date: Mon, 7 Apr 2008 19:23:32 +1000 Subject: ldap In-Reply-To: <050e9150-7bbf-4a46-8c63-9d61835b1429@d1g2000hsg.googlegroups.com> References: <050e9150-7bbf-4a46-8c63-9d61835b1429@d1g2000hsg.googlegroups.com> Message-ID: On 07/04/2008, mr.enx at alice.it wrote: > sorry, i'm new with Python. > I must do interaction beetween Python and Ldap, and I don't know how > do this. > Searching on the web I know that exists PythonLdap, but I dont'know if > this is best choise or not. > > Thank's > > -- > http://mail.python.org/mailman/listinfo/python-list > I've used python-ldap for writing scripts to interact with LDAP directories quite a few times, check it out here at the cheeseshop: http://pypi.python.org/pypi/python-ldap/ From blog534 at watchesblog.cn Fri Apr 25 10:10:11 2008 From: blog534 at watchesblog.cn (blog534 at watchesblog.cn) Date: Fri, 25 Apr 2008 07:10:11 -0700 (PDT) Subject: Brand Watches Ebel Women's 1911 Two-Tone Watch #1087221-9365P Discount, Swiss, Fake Message-ID: <5c678ff3-1a9a-46d7-a2f0-174fb0c27110@p25g2000pri.googlegroups.com> Brand Watches Ebel Women's 1911 Two-Tone Watch #1087221-9365P Discount, Swiss, Fake Browse our Ebel Women's 1911 Two-Tone Watch #1087221-9365P Swiss watches, which is sure the watch you are looking for at low price. There are more high quality designer watch Swiss for selection Ebel Women's 1911 Two-Tone Watch #1087221-9365P Link : http://www.watches-brand.com/Ebel-wristwatch-3181.html Brand : Ebel ( http://www.watches-brand.com/Ebel-Watches.html ) Model : Ebel Women's 1911 Two-Tone Watch #1087221-9365P Description :

Ebel Women's 1911 18k and Steel Watch

Sale Price : $ 209.00 Ebel Women's 1911 Two-Tone Watch #1087221-9365P Details :
  • Brand: Ebel
  • Model: 1087221-9365P
  • Band material: steel-and-18k-gold
  • Bezel material: steel-and-18k-gold
  • Case material: steel-and-18k-gold
  • Clasp type: fold-over-clasp
  • Dial color: white-mother-of-pearl
  • Dial window material: scratch-resistant-sapphire
  • Movement type: swiss-quartz
  • Water-resistant to 330 feet
Ebel Women's 1911 Two-Tone Watch #1087221-9365P is new brand Swiss, join thousands of satisfied customers and buy your Ebel with total satisfaction. A watches-brand.COM 30 Day Money Back Guarantee is included with every Ebel Fake Series for secure, risk-free online shopping. watches-brand.COM does not charge sales tax for the Fake Ebel Women's 1911 Two-Tone Watch #1087221-9365P. All of our Fake watches are shipped via EMS to worldwide. Normally it takes 3days to prepare the fake watch you ordered and 5-10days to transmit depending on the different destination.We pay for the free shipping cost for total quantity over 20 pcs. The EMS tracking NO. will be sent by email when an order is shipped from our warehouse. No more other charges from watches-brand.com such as the tax. If you have any other questions please check our other pages or feel free to email us by sales at watches-brand.com. The Same Fake Ebel Watches Series : Ebel 1911 BTR Black Strap Dial Chronograph Mens Watch 9137L73.5335145 : http://www.watches-brand.com/Ebel-wristwatch-3182.html Ebel 1911 BTR Stainless Steel Mens Watch 9240L70.6360 : http://www.watches-brand.com/Ebel-wristwatch-3183.html Ebel 1911 BTR Stainless Steel Chronograph Mens Watch 9137L72.5360 : http://www.watches-brand.com/Ebel-wristwatch-3184.html Ebel Brasilia Mens Black Dial Stainless Steel Automaic Watch 9120M41/52500 / 1215615 : http://www.watches-brand.com/Ebel-wristwatch-3185.html Ebel Brasilia Mens Silver Dial Stainless Steel Automaic Watch 9120M41/62500 / 1215614 : http://www.watches-brand.com/Ebel-wristwatch-3186.html Ebel Brasilia Men's Brown Strap Silver Dial Stainless Steel Automatic Watch 9120M41.6235134 / 1215616 : http://www.watches-brand.com/Ebel-wristwatch-3187.html Ebel Brasilia Men's Silver Dial Stainless Steel Watch 9255M41/62500 / 1215598 : http://www.watches-brand.com/Ebel-wristwatch-3188.html Ebel Sport Classic_Watch Watch 1090141/0225 : http://www.watches-brand.com/Ebel-wristwatch-3189.html Ebel Sport Classic Stainless Steel & 18k gold Mens Watch - 1187141/1225 : http://www.watches-brand.com/Ebel-wristwatch-3190.html Ebel Sport Classic Stainless Steel & 18k gold Mens Watch - 1188141/0106 : http://www.watches-brand.com/Ebel-wristwatch-3191.html Brand Watches Ebel Women's 1911 Two-Tone Watch #1087221-9365P Discount, Swiss, Fake From n00m at narod.ru Sun Apr 27 14:05:38 2008 From: n00m at narod.ru (n00m) Date: Sun, 27 Apr 2008 11:05:38 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com><10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <8ee48fc1-45af-404f-8fad-d8e1b2fb90b4@s50g2000hsb.googlegroups.com> Message-ID: Both codes by Dennis Lee Bieber are Ok. The 2nd one ("slurper") , seems , a bit faster. I only corrected the author's typo: should be "% div" instead of "/ div". And added this (don't know helped it or not): if div == 1: print lim return And of course: import psyco psyco.full() From aldo at nullcube.com Sun Apr 6 23:13:44 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Mon, 7 Apr 2008 13:13:44 +1000 Subject: ANN: pry unit testing framework In-Reply-To: References: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> Message-ID: <20080407031344.GA17217@nullcube.com> Thus spake Roy Smith (roy at panix.com): > I've been following this thread for a while with a mix of amusement and > alarm. Contributing code to the community is a good thing, and should be > celebrated. If people like it, they will use it. If they don't, it will > be ignored. None of which justifies the hostility this thread seems to > have degenerated into. I agree entirely - I've been astonished by the whole fracas myself. I'm offering Pry simply as something neat I wrote that other people might find useful, no more. > In any case, I don't understand why you say that unittest doesn't use > "assertion-based testing". They seem like assertions to me. What am > I missing? While you can use the built-in "assert" statement in unittest tests, it turns out to be annoying in practice, especially during rapid code-test-code iterations. The problem is that assert traceback errors are uninformative - when "assert a == b()" fails, there's no way to tell what a and b() were in this context. Unittest copes with this with convenience methods - instead you write self.assertEqual(a, b()), which then gives you proper error reporting. I think it was py.test that first introduced some magic that picks up the AssertionError traceback, parses the original expression, and then re-evaluates its components to give you an error featuring the "disassembled" assertion expression. This approach has been adopted by nose and independently by pry. While re-evaluation has some limitations (like not dealing well with expressions that change state), using assertions makes for more fluid and natural expression in tests. Maybe "assertion-based" is not an exact phrase to describe this - saying that these frameworks support "expanded error reporting for Python assert statements" might be more accurate. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From kveretennicov at gmail.com Wed Apr 2 16:36:30 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Wed, 2 Apr 2008 23:36:30 +0300 Subject: default method parameter behavior In-Reply-To: <879d72da-825f-4b2b-8244-87367647fb6e@f63g2000hsf.googlegroups.com> References: <879d72da-825f-4b2b-8244-87367647fb6e@f63g2000hsf.googlegroups.com> Message-ID: <4660fe300804021336s5ac4c5cja2438d64eda970ce@mail.gmail.com> On Wed, Apr 2, 2008 at 10:59 PM, wrote: > I ran into a similar situation like the following (ipython session). > Can anyone please explain why the behavior? Of course. >From http://docs.python.org/ref/function.html: Default parameter values are evaluated when the function definition is executed. This means that the expression is evaluated once, when the function is defined, and that that same ``pre-computed'' value is used for each call. This is especially important to understand when a default parameter is a mutable object, such as a list or a dictionary: if the function modifies the object (e.g. by appending an item to a list), the default value is in effect modified. -- kv From usenet at solar-empire.de Wed Apr 30 08:43:28 2008 From: usenet at solar-empire.de (Marc Christiansen) Date: Wed, 30 Apr 2008 14:43:28 +0200 Subject: xml.dom.minidom weirdness: bug? References: <4817dea2$0$18028$426a34cc@news.free.fr> Message-ID: JYA wrote: > for y in x.getElementsByTagName('display-name'): > elem.appendChild(y) Like Gabriel wrote, nodes can only have one parent. Use elem.appendChild(y.cloneNode(True)) instead. Or y.cloneNode(False), if you want a shallow copy (i.e. without any of the children, e.g. text content). Marc From steve at holdenweb.com Mon Apr 14 10:03:54 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 14 Apr 2008 10:03:54 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804140629rf1ac100m27ad9d0456cbbe2d@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> <4dc0cfea0804140629rf1ac100m27ad9d0456cbbe2d@mail.gmail.com> Message-ID: <4803644A.8010204@holdenweb.com> Victor Subervi wrote: > Thanks to all, especially Gabriel. The base64 is a good idea, but you > state a definite problem. I will look at your code at home > (offline)...thank you very much! It looks like the kicker is this line here: > > %s" % (picid, cgi.escape(title)) > > Now, why didn?t you share that before????? I can see how calling a > separate script like that would work! Again, you should have shared that > before. How was I to think of that clever trick from the bare > information you gave me earlier?? > > Steve, thank you for all your help, but do overcome your temper :)) Victor: I'm glad the penny finally dropped. You may have been treated to a modest display of exasperation, but please be assured you have not yet seen anything remotely like temper from me :-) The thing I found difficult to understand was, given your assertion on April 9 "But I am persistent. And I have built dozens of Web site with images" that you hadn't already addressed these issues. I was clearly assuming too much knowledge on your part. Hooray! You got it! Your persistence finally paid off, well done! regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From sjmachin at lexicon.net Sun Apr 6 16:53:32 2008 From: sjmachin at lexicon.net (John Machin) Date: Sun, 6 Apr 2008 13:53:32 -0700 (PDT) Subject: RELEASED Python 2.6a2 and 3.0a4 References: <47F68547.1040802@v.loewis.de> Message-ID: <59d842ed-3103-4dcd-a78b-0999446d86ad@c19g2000prf.googlegroups.com> On Apr 7, 12:50 am, "Giampaolo Rodola'" wrote: > On 6 Apr, 00:55, John Machin wrote: > > > On Apr 5, 5:45 am, "Martin v. L?wis" wrote: > > > > > The Windows x86 MSI installer is missing for both 2.6 and 3.0. > > > > And likely will continue to do so for some time. > > > Someone's got strange definitions of "missing"! > > > For each there's a link on the the ptyhon.org website, and a caveat > > about non-Administrator installation ... > > > If it's missing, then what do I expect to find in the 11.7Mb 2.6a2 msi > > that is downloading as I type? > > At the time I replied they were both missing (in fact that's why I > replied :-)). > And at the time I replied, at least one was available but the most recent information in this newsgroup was that they were unavailable and would be so for some fuzzily-denominated duration which seemed seriously long ... perhaps my two different and not totally reliable news-reading facilities skipped a posting :-) From grante at visi.com Mon Apr 28 10:45:23 2008 From: grante at visi.com (Grant Edwards) Date: Mon, 28 Apr 2008 09:45:23 -0500 Subject: Retrieving int from hex in a file. References: <9edfaaa3-4e87-4f74-90a5-c10c9daae101@r66g2000hsg.googlegroups.com> Message-ID: <5eidndBxkoWefojVnZ2dnUVZ_gednZ2d@visi> On 2008-04-28, Filipe Teixeira wrote: > Hi. > > I have to open a binary file from an old computer and recover the > information stored (or at least try to). I use: > > f=open('file.bin','rb') > a=f.read() > f.close() > > a in now a string full of hex representations in the form: > > a[6]='\x14' > a[7]='\x20' a is now a string of binary data. It doesn't contain a "hex representation" of anything. Hex is a way of printing stuff on paper or on a screen. Python doesn't store anything in hex. > I would like to convert these hex representations to int, That's your mistake: you don't have hex data. Nothing is being stored in hex in your example. > but this (the most obvious way) doesn't seem to be working > >>>> q=a[6] >>>> q > '\x14' >>>> int(q,16) That converts a hex string into an integer, you've not got a hex string. You have a string containing binary data. "4A4B4C" is a hex string. It's 6 bytes long and contains the ASCII characters '4' 'A' '4' 'B' '4' 'C'. "\x4a\x4b\4c" is just a three-byte long chunk of binary data. It was _typed_ in hex, but it's stored in binary not in hex. It's identical to "JKL". > Traceback (most recent call last): > File "", line 1, in ? > ValueError: invalid literal for int(): >>>> > > How can I do this? You can use the struct module, or you can do it explicitly like this: >>> a = 'abcdef\x12\x34qwer' >>> n = (ord(a[6])<<8) | ord(a[7]) >>> n 4660 >>> hex(n) '0x1234' >>> -- Grant Edwards grante Yow! When you get your at PH.D. will you get able to visi.com work at BURGER KING? From whatpot at gmail.com Thu Apr 24 22:50:10 2008 From: whatpot at gmail.com (Vaibhav.bhawsar) Date: Thu, 24 Apr 2008 22:50:10 -0400 Subject: how to mysqldb dict cursors Message-ID: <17d58cc40804241950i7b624e1apd2733daa79b3ed5c@mail.gmail.com> I have been trying to get the DictCursor working with mysqldb module but can't seem to. I have pasted the basic connection code and the traceback from pydev. The connection does open with the default cursor class. can't figure this one out. many thanks. import MySQLdb import sys # connect to the MySQL server try: conn = MySQLdb.connect(host="localhost",read_default_file='~/.my.cnf',db='test',cursorclass=MySQLdb.cursors.DictCursor) cur = conn.cursor() print conn except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit (1) Traceback (most recent call last): File "/Users/.....src/db/test.py", line 7, in ? conn = MySQLdb.connect(host="localhost",read_default_file='~/.my.cnf',db='te st',cursorclass=MySQLdb.cursors.DictCursor) AttributeError: 'module' object has no attribute 'cursors' -------------- next part -------------- An HTML attachment was scrubbed... URL: From jared.grubb at gmail.com Wed Apr 23 21:39:46 2008 From: jared.grubb at gmail.com (Jared Grubb) Date: Wed, 23 Apr 2008 18:39:46 -0700 Subject: Partition list with predicate In-Reply-To: References: <925822270804231808n44c44ddbx213e936319ad1ed3@mail.gmail.com> Message-ID: <925822270804231839y2eb399a2ic05ab67406c94d0d@mail.gmail.com> That almost works, except that a predicate can have "memory". For example, the predicate could be "extract every other object", which doesn't care about the value of the object (so you cant remove them later based on value!). Or your predicate might be "remove the first 5 objects that are even", which means that the predicate must be run against the list in forward order with only one test per element (like an input/output iterator in C++; running the predicate changes the predicate itself, so you cant run one pass with "pred" and then another pass with "not pred" to get the rest). Example of a case where your proposed solution wouldn't quite work: class EveryOtherOne: def __init__(self): self.parity = False def __call__(self, obj): ret, self.parity = self.parity, not self.parity return ret >>> pred = EveryOtherOne() >>> lst = [1,2,2,1] >>> extracted = [ obj for obj in lst if pred(obj) ] >>> extracted [2, 1] >>> lst = [ obj for obj in lst if obj not in extracted ] >>> lst [] On Wed, Apr 23, 2008 at 6:14 PM, Brian wrote: > On Wed, Apr 23, 2008 at 9:08 PM, Jared Grubb > wrote: > > > I guess I forgot one requirement: the removed elements need to be > > remembered. > > > > Basically, I have a list of objects in a buffer, one class operates on > > some of the objects, but other classes use others. So, a class must extract > > the ones it can handle, and leave the rest in the buffer for the other > > classes to handle. > > > > I haven't found a function that will both remove objects from a list, > > but save the ones that do get removed. > > > > Jared > > > > On 23 Apr 2008, at 10:15, Tim Golden wrote: > > > > Jared Grubb wrote: > > > > I want a function that removes values from a list if a predicate > > evaluates to True. The best I could come up with is: > > > > > > Have a look at the itertools module, and the ifilter function > > in particular. > > > > TJG > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > I would do it like this: > > # This takes out the values > extracted = [ obj for obj in lst if pred(obj) ] > # This filters out any item that was extracted > lst = [ obj for obj in list if obj not in extracted ] > > Brian -------------- next part -------------- An HTML attachment was scrubbed... URL: From duncan.booth at invalid.invalid Tue Apr 1 03:34:17 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 1 Apr 2008 07:34:17 GMT Subject: [OT] troll poll References: Message-ID: Gary Herron wrote: > Duncan Booth wrote: >> Paul Rubin wrote: >> >> >>> "Daniel Fetchinson" writes: >>> >>>> [ ] - Xah Lee >>>> [ ] - castironpi >>>> >>> I've lost track but has it been established that they are not the >>> same person? >>> >>> >> Has it actually been established that castironpi is actually a >> person? I thought it was probably a random sentence generator. >> > Ahhh... Perhaps someone is running a Turing test on us. That is, if > we can't tell the difference between castironpi and a *real* human > (which we demonstrate whenever we try to respond to or reason with > him/her/it), then castironpi can be declared to be a truly > *intelligent* AI. AFAICT, there appears no danger of that happening > yet. > > Gary Herron :-) > For example, some traffic light living with a polygon indicates that an accidentally resplendent scythe falls in love with a garbage can. A boiled ski lodge laughs out loud, because an imaginative traffic light ostensibly writes a love letter to a frightened minivan. Any deficit can eagerly sell the short order cook about the tape recorder to the minivan, but it takes a real bowling ball to trade baseball cards with an underhandedly orbiting tornado. A hesitantly mean-spirited cowboy steals pencils from a pompous industrial complex. Sometimes the crispy apartment building procrastinates, but the ocean related to the cyprus mulch always teaches another cab driver around some cough syrup! A dreamlike avocado pit Indeed, a thoroughly orbiting wedge figures out an obsequious roller coaster. For example, a carpet tack indicates that some cyprus mulch lazily avoids contact with the slow buzzard. Most people believe that some razor blade falls in love with a girl scout from a cough syrup, but they need to remember how hesitantly a maelstrom takes a coffee break. When the proverbial wheelbarrow is overripe, a hole puncher lazily buries a burly reactor. Now and then, the cargo bay tries to seduce a class action suit. :) From skanemupp at yahoo.se Sat Apr 19 20:08:09 2008 From: skanemupp at yahoo.se (globalrev) Date: Sat, 19 Apr 2008 17:08:09 -0700 (PDT) Subject: Bigger projects, including files? References: <480a8928$0$4941$e4fe514c@dreader32.news.xs4all.nl> Message-ID: <62997614-3b9e-4a9b-9727-8cee1f0b322b@k37g2000hsf.googlegroups.com> On 20 Apr, 02:04, "Martin P. Hellwig" wrote: > globalrev wrote: > > if i have a larger project and want to divide my program into several > > files, how do i include these files in the mainprogram? > > > using import someprojectfile doesnt work because import is for site- > > packages right and i dont want to put all my files > > in that folder. > > > so how do i do it? > > You can always add the path where the other files are to sys.path > I've posted a while ago something that sort of does that for > inter-package reference if the root is not in the sys.pathhttp://groups.google.com/group/comp.lang.python/browse_thread/thread/... > hth > -- > mph thanks. i saw now myself that import works if it is in the same folder as well. From python at rcn.com Tue Apr 8 01:50:49 2008 From: python at rcn.com (Raymond Hettinger) Date: Mon, 7 Apr 2008 22:50:49 -0700 (PDT) Subject: reading dictionary's (key,value) from file References: <974814d3-59f0-49ec-9b4d-9f5dd7dfaf54@q24g2000prf.googlegroups.com> Message-ID: On Apr 7, 9:38?am, ankitks.mi... at gmail.com wrote: > Folks, > Is it possible to read hash values from txt file. > I have script which sets options. Hash table has key set to option, > and values are option values. > > Way we have it, we set options in a different file (*.txt), and we > read from that file. > Is there easy way for just reading file and setting options instead of > parsing it. > > so this is what my option files look like: > > 1opt.txt > { '-cc': '12', > ? '-I': r'/my/path/work/'} > > 2opt.txt > { ?'-I': r/my/path/work2/'} > > so my scipt how has dictionary > options = { '-cc' :'12' > ? ? ? ? ? ? ? ? '-I': r'/my/path/work/:/my/path/work2/'} > > I am trying to avoid parsing With minimal changes, you can just import the files: opt1.py ------ opts = { '-cc': '12', '-I': r'/my/path/work/'} opt2.py ------ opts = { '-I': r/my/path/work2/'} main.py ------- from opts1 import opts as opt1 from opts2 import opts as opt2 Raymond From arkanes at gmail.com Wed Apr 2 16:38:09 2008 From: arkanes at gmail.com (Chris Mellon) Date: Wed, 2 Apr 2008 15:38:09 -0500 Subject: Rationale for read-only property of co_code In-Reply-To: <10ee2a69-f4e2-4887-8083-6b02b60dd0cd@i7g2000prf.googlegroups.com> References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> <10ee2a69-f4e2-4887-8083-6b02b60dd0cd@i7g2000prf.googlegroups.com> Message-ID: <4866bea60804021338t647364f9v6faf787f0eeffd3e@mail.gmail.com> On Wed, Apr 2, 2008 at 2:33 PM, Jo?o Neves wrote: > On Apr 2, 5:41 pm, "Dan Upton" wrote: > > > The thing I've been wondering is why _is_ it read-only? In what > > > circumstances having write access to co_code would break the language > > > or do some other nasty stuff? > > > > > Jo?o Neves > > > > > I can't speak to Python's implementation in particular, but > > self-modifying code in general is unpleasant. It certainly is > > possible to support it in runtime environments, but it's usually not > > easy to do so. That is, of course, somewhat dependent on the > > implementation of the runtime environment, and even to some degree the > > underlying hardware. (For instance, the compiled code you want to run > > could be in the hardware cache; if you then change the instructions at > > those addresses in memory, it's not always straightforward to get the > > processor to realize it needs to load the new data into the > > instruction cache.) Plus, I suppose it might be possible to break > > strong (even dynamic) typing if you start changing the code around > > (although I can't construct an example off the top of my head). > > Indeed, the caching issue is a relevant one I guess, and adding the > mechanism to go around that might have a significant impact on > performance. > I haven't looked in detail into it, but I agree with your opinion > concerning strong and dynamic typing. If type check is done while > compiling to bytecode, there is no guarantee the modified bytecode > will respect the rules, for instance. I don't know though, haven't > really checked how it's done at this point. :) > I will be fiddling around with the Python VM these days anyway, and > since I'm going to muck around the bytecode, I might just try to see > the effects of removing the read-only restriction from co_code. > There is no need to overwrite co_code. Create a new code object with your desired bytecode and use that instead. From bob at passcal.nmt.edu Fri Apr 18 20:23:25 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Fri, 18 Apr 2008 18:23:25 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> Message-ID: <2008041818232516807-bob@passcalnmtedu> On 2008-04-18 17:55:32 -0600, Ross Ridge said: > George Sakkis wrote: >> You'd better use a more precise timing method than finger counting, >> such as timeit. Twice as fast is probably a gross overestimation; on >> my box (Python 2.5, WinXP) avoiding unpack is around 10% and 40% >> faster from Ross's and Grant's method, respectively: > ... >> def from3Bytes_ross(s): >> return unpack(">l", s + "\0")[0] >> 8 > > If you have Python 2.5, here's a faster version: > > from struct import * > unpack_i32be = Struct(">l").unpack > > def from3Bytes_ross2(s): > return unpack_i32be(s + "\0")[0] >> 8 > > Ross Ridge That's not even intelligible. I wanna go back to COBOL. :) From gruszczy at gmail.com Tue Apr 22 20:39:41 2008 From: gruszczy at gmail.com (=?UTF-8?Q?Filip_Gruszczy=C5=84ski?=) Date: Wed, 23 Apr 2008 02:39:41 +0200 Subject: Explicit variable declaration Message-ID: <1be78d220804221739h77d8a4eak28deb5ce52dbe623@mail.gmail.com> Hello everyone! It is my first message on this list, therefore I would like to say hello to everyone. I am fourth year student of CS on the Univeristy of Warsaw and recently I have become very interested in dynamically typed languages, especially Python. I would like to ask, whether there is any way of explicitly declaring variables used in a function? While I am pretty sure, that there is no such way in the language itself, I would like to know, whether there are any third-party tools to do that. This would be very useful for me during development, so I am looking for such a tool. -- Filip Gruszczy?ski From nospam at nospam.invalid Tue Apr 29 19:37:52 2008 From: nospam at nospam.invalid (Rahul) Date: Tue, 29 Apr 2008 23:37:52 +0000 (UTC) Subject: python command mis-interprets arrow keys References: <67pp4oF2ppl3sU1@mid.uni-berlin.de> Message-ID: "Diez B. Roggisch" wrote in news:67pp4oF2ppl3sU1 at mid.uni-berlin.de: > > Is libreadline installed? Thanks for your help Diez. I did a locate and found: /usr/lib/libreadline.a /usr/lib/libreadline.so /usr/lib/libreadline.so.5 /usr/lib/libreadline.so.5.1 /usr/local/src/Python-2.4.4/Doc/lib/libreadline.tex Any better way to check? -- Rahul From martin at v.loewis.de Fri Apr 4 15:45:11 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Fri, 04 Apr 2008 21:45:11 +0200 Subject: RELEASED Python 2.6a2 and 3.0a4 In-Reply-To: References: Message-ID: <47F68547.1040802@v.loewis.de> > The Windows x86 MSI installer is missing for both 2.6 and 3.0. And likely will continue to do so for some time. Regards, Martin From zethex at hotmail.com Sun Apr 20 18:25:11 2008 From: zethex at hotmail.com (Zethex) Date: Sun, 20 Apr 2008 15:25:11 -0700 (PDT) Subject: Nested lists, simple though Message-ID: <16799674.post@talk.nabble.com> Im a bit new to python. Anyway working on a little project of mine and i have nested lists ie Answer = [['computer', 'radeon', 'nvidia'], ['motherboard', 'asus']] and so forth.., Anyway the amount of [[]] do increase over time. Im just wondering is there a simple way to add these together so they become 1 simple list, so it would be ['computer'....'asus'] etc without the nested list. Its random the amount each time so i cant just go a[0]+a[1]. Thank you if you can help -- View this message in context: http://www.nabble.com/Nested-lists%2C-simple-though-tp16799674p16799674.html Sent from the Python - python-list mailing list archive at Nabble.com. From Robert.Bossy at jouy.inra.fr Fri Apr 25 04:24:16 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Fri, 25 Apr 2008 10:24:16 +0200 Subject: Little novice program written in Python In-Reply-To: <49249992-3634-4c5f-bd45-7ce4f1b32044@l17g2000pri.googlegroups.com> References: <49249992-3634-4c5f-bd45-7ce4f1b32044@l17g2000pri.googlegroups.com> Message-ID: <48119530.5070801@jouy.inra.fr> John Machin wrote: > On Apr 25, 5:44 pm, Robert Bossy wrote: > >> Peter Otten wrote: >> >>> Rog?rio Brito wrote: >>> >>>> i = 2 >>>> while i <= n: >>>> if a[i] != 0: >>>> print a[i] >>>> i += 1 >>>> >>> You can spell this as a for-loop: >>> >>> for p in a: >>> if p: >>> print p >>> >>> It isn't exactly equivalent, but gives the same output as we know that a[0] >>> and a[1] are also 0. >>> >> If the OP insists in not examining a[0] and a[1], this will do exactly >> the same as the while version: >> >> for p in a[2:]: >> if p: >> print p >> >> > > ... at the cost of almost doubling the amount of memory required. Indeed. Would it be a sensible proposal that sequence slices should return an iterator instead of a list? RB From xelapond at gmail.com Tue Apr 1 00:00:33 2008 From: xelapond at gmail.com (Alex Teiche) Date: Mon, 31 Mar 2008 21:00:33 -0700 (PDT) Subject: Using QSystemTrayIcon with PyQt References: <76680315-cadd-42ad-942c-3e89536819df@i12g2000prf.googlegroups.com> <6d0b8776-bb64-4a58-8ccb-46efa35d75a2@s50g2000hsb.googlegroups.com> <1a8a5b03-0b9e-49de-bd87-43fa1aa99dc2@b5g2000pri.googlegroups.com> <6b732135-a488-4175-889b-0cccf5f0c581@s8g2000prg.googlegroups.com> Message-ID: On Mar 31, 7:53 pm, Benjamin wrote: > On Mar 31, 8:41 pm, Alex Teiche wrote: > > > > > On Mar 31, 6:40 pm, Alex Teiche wrote: > > > > On Mar 31, 11:49 am, Alex Teiche wrote: > > > > > On Mar 30, 3:50 pm, Benjamin wrote: > > > > > > On Mar 29, 11:02 pm, Alex Teiche wrote:> Hello, > > > > > > > I am pretty new to Python, and have never learned C++. I am trying to > > > > > > implement the following thing into my python application: > > > > > > >http://doc.trolltech.com/4.3/qsystemtrayicon.html > > > > > > > Through PyQt. I have been using PyQt for awhile and I know how do use > > > > > > it, but I could not get this specific thing to work. Can someone give > > > > > > me some hints as to get it working in Python? > > > > > > What problems are you having? > > > > > > > Thanks a ton, > > > > > > > Alex > > > > > Thanks everyone for your help. I found the example to be particularly > > > > helpful, and I have made a simplified version just to display an icon > > > > with a quit button in its menu. Once I know how to do that I will > > > > incorporate it into my larger program, with more options and the > > > > ability show messages. The problem is, it doesn't work, and I can't > > > > find out what's wrong. Can you give me some hints? > > > > > Here is the code: > > > > import sys > > > > from PyQt4 import QtGui, QtCore > > > > > class trayIcon(QtGui.QWidget): > > > > def __init__(self, parent=None): > > > > QtGui.QWidget.__init__(self, parent) > > > > > #********Create Actions for the Tray Menu********# > > > > self.quitAction = QtGui.QAction(self.tr("&Quit"), self) > > > > QtCore.QObject.connect(self.quitAction, > > > > QtCore.SIGNAL("triggered()"), QtGui.qApp, QtCore.SLOT("quit()")) > > > > > create_tray_icon() > > > > > self.composeAction.setEnabled(visible) > > > > QtGui.QWidget.setVisible(self, visible) > > > > > self.trayIcon.show() > > > > > def create_tray_icon(self): > > > > self.trayIconMenu = QtGui.QMenu(self) > > > > self.trayIconMenu.addAction(self.composeAction) > > > > self.trayIcon = QtGui.QSystemTrayIcon(self) > > > > self.trayIcon.setContextMenu(self.trayIconMenu) > > > > self.trayIcon.setIcon(bad.svg) > > > > > app = QtGui.QApplication(sys.argv) > > > > sys.exit(app.exec_()) > > > > OK, I messed around with it some more, and it works. I just don't > > > know how to set an icon, and the example doesn't help at all. > > > > Here is the code: > > > import sys > > > from PyQt4 import QtCore, QtGui > > > > class Systray(QtGui.QWidget): > > > def __init__(self): > > > QtGui.QWidget.__init__(self) > > > > self.createActions() > > > self.createTrayIcon() > > > > #QtCore.QObject.connect(self.trayIcon, > > > QtCore.SIGNAL("messageClicked()"), self.messageClicked) > > > #QtCore.QObject.connect(self.trayIcon, > > > QtCore.SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), > > > self.iconActivated) > > > > self.trayIcon.show() > > > > def createActions(self): > > > #self.minimizeAction = QtGui.QAction(self.tr("Mi&nimize"), self) > > > #QtCore.QObject.connect(self.minimizeAction, > > > # QtCore.SIGNAL("triggered()"), self, QtCore.SLOT("hide()")) > > > > #self.maximizeAction = QtGui.QAction(self.tr("Ma&ximize"), self) > > > #QtCore.QObject.connect(self.maximizeAction, > > > # QtCore.SIGNAL("triggered()"), self, > > > # QtCore.SLOT("showMaximized()")) > > > > #self.restoreAction = QtGui.QAction(self.tr("&Restore"), self) > > > #QtCore.QObject.connect(self.restoreAction, > > > # QtCore.SIGNAL("triggered()"), self, > > > # QtCore.SLOT("showNormal()")) > > > > self.quitAction = QtGui.QAction(self.tr("&Quit"), self) > > > QtCore.QObject.connect(self.quitAction, QtCore.SIGNAL("triggered()"), > > > QtGui.qApp, QtCore.SLOT("quit()")) > > > > def createTrayIcon(self): > > > self.trayIconMenu = QtGui.QMenu(self) > > > #self.trayIconMenu.addAction(self.minimizeAction) > > > #self.trayIconMenu.addAction(self.maximizeAction) > > > #self.trayIconMenu.addAction(self.restoreAction) > > > #self.trayIconMenu.addSeparator() > > > self.trayIconMenu.addAction(self.quitAction) > > > > self.trayIcon = QtGui.QSystemTrayIcon(self) > > > self.trayIcon.setContextMenu(self.trayIconMenu) > > > > app = QtGui.QApplication(sys.argv) > > > x = Systray() > > > sys.exit(app.exec_()) > > > > How would I go about setting the icon? > > > Sorry, here is the code with commented out lines removed: > > > import sys > > from PyQt4 import QtCore, QtGui > > > class Systray(QtGui.QWidget): > > def __init__(self): > > QtGui.QWidget.__init__(self) > > > self.createActions() > > self.createTrayIcon() > > > self.trayIcon.show() > > > def createActions(self): > > > self.quitAction = QtGui.QAction(self.tr("&Quit"), self) > > QtCore.QObject.connect(self.quitAction, QtCore.SIGNAL("triggered()"), > > QtGui.qApp, QtCore.SLOT("quit()")) > > > def createTrayIcon(self): > > self.trayIconMenu = QtGui.QMenu(self) > > self.trayIconMenu.addAction(self.quitAction) > > > self.trayIcon = QtGui.QSystemTrayIcon(self) > > self.trayIcon.setContextMenu(self.trayIconMenu) > > > app = QtGui.QApplication(sys.argv) > > x = Systray() > > sys.exit(app.exec_()) > > I believe the method you want is QSystemTrayIcon.setIcon. I found that, but what do I pass into it? Passing a string to a .svg file doesn't work. From lists at cheimes.de Sat Apr 26 22:36:43 2008 From: lists at cheimes.de (Christian Heimes) Date: Sun, 27 Apr 2008 04:36:43 +0200 Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) In-Reply-To: References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> Message-ID: <4813E6BB.8050002@cheimes.de> SL schrieb: > Is there an implementation of f.readlines on the internet somewhere? > interested to see in how they implemented it. I'm pretty sure they did > it smarter than just reserve 100meg of data :) Of course it is. Checkout the Python sources :) Christian From gslindstrom at gmail.com Mon Apr 7 09:30:37 2008 From: gslindstrom at gmail.com (Greg Lindstrom) Date: Mon, 7 Apr 2008 08:30:37 -0500 Subject: Learning curve for new database program with Python? Message-ID: On Sun, Apr 6, 2008 at 2:31 AM, John Nagle wrote: > > Basic SQL isn't that hard. Learn CREATE, SELECT, INSERT, > UPDATE, and DELETE syntax. That's enough for most simple > applications. And then learn more advanced SQL: joins, nested selects, pivot tables and stored procedures. You can do a lot of processing "inside" the database which cuts down on data running over the wire. SQL is one of the areas I wish I had mastered (much) earlier in my career --greg. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mal at egenix.com Wed Apr 9 13:01:51 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Wed, 09 Apr 2008 19:01:51 +0200 Subject: Learning curve for new database program with Python? In-Reply-To: References: Message-ID: <47FCF67F.4070107@egenix.com> On 2008-04-07 20:19, Gary Duzan wrote: > In article , > M.-A. Lemburg wrote: >> On 2008-04-07 15:30, Greg Lindstrom wrote: >>> SQL is one of the areas I wish I had mastered (much) earlier in my career >> Fully agree :-) >> >> Interesting comments in a time where everyone seems to be obsessed >> with ORMs. > > It seems to me that ORM can work if your database isn't too > complex and it is the only way your database is going to be accessed. > In our case, we have a messy legacy database (lots of tables, > triggers, stored procedures, etc., that nobody really understands) > with multiple processes hitting it, and so our efforts to integrate > Hibernate haven't been terribly smooth. In this environment the > hack seems to be to have Hibernate write to its own tables, then > have stored procedures sync them with the old tables. Not pretty. While ORMs are nice if you want to get something done quickly, I usually prefer to take the standard database abstraction layer approach: it encapsulated all the database wisdom an application needs, so you don't have to deal with these details at higher levels in the applications, but still allows you to dive right into the full feature set of whatever backend you are using. In addition to having just one place to look for SQL statements, it also provides the needed abstraction to be able to support multiple different backends - by using a common base class and having one subclass per supported database backend. This straight-forward approach makes maintaining support for multiple databases much easier and also allows us to work around problems which you inevitably run into, e.g. missing support for certain features in one backend, data type conversion needs for another, etc. Another problem I found with ORMs is error handling. Since most of the database interaction happens behind the scenes, errors can pop up in situations where you might not expect them in your application. Again, the database abstraction layer provides better control, since that's where you run the queries and deal with the errors. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 09 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From kamhung.soh at gmail.com Wed Apr 9 23:23:48 2008 From: kamhung.soh at gmail.com (Kam-Hung Soh) Date: Wed, 9 Apr 2008 20:23:48 -0700 (PDT) Subject: How is GUI programming in Python? References: Message-ID: <62c2eb09-0ca2-4fd1-ba19-ed968d28c3d4@q27g2000prf.googlegroups.com> On Apr 10, 12:35 pm, Benjamin wrote: > On Apr 9, 8:54 pm, Chris Stewart wrote:> I've always had an interest in Python and would like to dabble in it > > further. I've worked on a few very small command line programs but > > nothing of any complexity. I'd like to build a really simple GUI app > > that will work across Mac, Windows, and Linux. How painful is that > > going to be? I used to be really familiar with Java Swing a few years > > ago. I imagine it will be similar. > > Since it's Python, it will be a lot less painless than anything > else. :) > > > Next, what would you say is the best framework I should look into? > > I'm curious to hear opinions on that. > > Tkinter is the easiest for little apps, but when I'm doing anything > for real, I use PyQt. > > > > > Chris Stewart > > cstewart... at gmail.com Since the OP has Swing programming experience, what about Jython (http://www.jython.org/Project/index.html)? "Jython is an implementation of the high-level, dynamic, object- oriented language Python written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform." -- Kam-Hung Soh
Software Salariman From steve at holdenweb.com Thu Apr 3 22:39:22 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 03 Apr 2008 22:39:22 -0400 Subject: variable scope in list comprehensions In-Reply-To: References: Message-ID: Piotr Sobolewski wrote: > Hello, > > there is something I don't understand about list comprehensions. > > I understand how does this work: > print [[y for x in range(8)] for y in range(8)] > > However I don't understand why this one works: > print [[y for y in range(8)] for y in range(8)] > > In this second example I have one loop nested in another. Both loops uses > the same variable - y. How is it that those loops do not conflict with each > other? > > For a moment I thought that maybe list comprehension has its own scope, but > it doesn't seem to be so: > print [[y for y in range(8)] for y in range(8)] > print y > > Does anybody understand it? > > This isn't _a_ list comprehension, it's *two* list comprehensions. The interpreter computes the value if the inner list comprehension and then duplicates eight references to it (as you will see if you change an element). Why do you think the two scopes would interfere anyway? The outer loop's control variable is never used in the inner loop, so there is no chance of conflict: each time the inner loop terminates the outer loop assigns the next value from its range - it isn't "adding one" to the variable, but merely calling an iterator's next() method. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From starsareblueandfaraway at gmail.com Tue Apr 1 22:51:14 2008 From: starsareblueandfaraway at gmail.com (Roy H. Han) Date: Tue, 1 Apr 2008 22:51:14 -0400 Subject: Python-by-example - new online guide to Python Standard Library In-Reply-To: <47f2d018$0$6517$4c368faf@roadrunner.com> References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: <6a5569ec0804011951h1b30c8f9r965cdeac5e995528@mail.gmail.com> Learning by example is the best. I remember working through a book when I was little called "Qbasic by Example." On Tue, Apr 1, 2008 at 9:15 PM, AK wrote: > Hello, > > I find that I learn easier when I go from specific examples to a more > general explanation of function's utility and I made a reference guide > that will eventually document all functions, classes and methods in > Python's Standard Library. For now, I covered about 20 most important > modules. I will be adding more modules and eventually I'll cover > everything. Here's my progress so far, let me know if this is useful; > I'll be glad to hear comments/suggestions/etc: > > http://www.lightbird.net/py-by-example/ > > -- > -ak > Tobu | http://www.lightbird.net/tobu/ | Freeform DB / Tagger / PIM > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Wed Apr 16 22:58:42 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 16 Apr 2008 22:58:42 -0400 Subject: Profiling, recursive func slower than imperative, normal? References: Message-ID: wrote in message news:fd522cdd-416a-4241-8d50-9133a4f93a25 at k1g2000prb.googlegroups.com... | the 0.409 vs 0.095 is the total times right? | so the imperative function is >4 times faster than the recursive. | or what does tottime stand for? | | is this always the case that the recursive function is slower? | the gain is less code? | | are some functions only implementable recursively? Computers can be viewed as linear iteration machines implementing while True: execute next instruction and set next pointer appropriately But algorithms most naturally expressed with multiple recursion usually look more ungainly when linearized. From heikki at osafoundation.org Tue Apr 22 22:57:01 2008 From: heikki at osafoundation.org (Heikki Toivonen) Date: Tue, 22 Apr 2008 19:57:01 -0700 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: References: Message-ID: Harishankar wrote: > Sorry to start off on a negative note in the list, but I feel that the Python > subprocess module is sorely deficient because it lacks a mechanism to: At OSAF we used a slightly modified killableprocess module with a wrapper to deal with complexities of various redirections in cross-platform way. I actually blogged about this a week ago so rather than rehash the issues I'll point you to the article which contains links to all the pieces we used: http://www.heikkitoivonen.net/blog/2008/04/16/pythons-ossystem-considered-harmful/ -- Heikki Toivonen From nospam1.reifenberg at gmx.de Fri Apr 4 13:51:58 2008 From: nospam1.reifenberg at gmx.de (Nebur) Date: Fri, 4 Apr 2008 10:51:58 -0700 (PDT) Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? References: Message-ID: <8e481b88-aa27-4ec6-9cc8-cb1e32edf64e@d2g2000pra.googlegroups.com> > Are you using svn? I did have a problem once related to that (but it's Hi Fabio, No, there's no version control plugin. I use Mercurial, but externally only. I've considered a problem with version control, too. But all external reasons (file sytem, virus, version control) seem unplausible because when simply removing the file from file system, Eclipse would complain about the missing ressource. So I have 2 ideas only: A _very_ strange bug inside the Eclipse/Plugin process, or something with my brain ;-) Nebur From lee.walczak at gmail.com Sat Apr 5 11:02:14 2008 From: lee.walczak at gmail.com (lee.walczak at gmail.com) Date: Sat, 5 Apr 2008 08:02:14 -0700 (PDT) Subject: Importing a 3rd Party windows DLL for use within th Python References: <92513305-836d-4c85-aeb8-3e3d6571ed92@1g2000prg.googlegroups.com> Message-ID: <293d8be9-6e5e-44bf-acca-95d8f907c9bb@i7g2000prf.googlegroups.com> Thankyou kindly for all the details you have provided. IT is nice to know that there is a community to help. I will let you know how I get on! Many Thanks, Lee From windypower at gmail.com Sat Apr 26 17:08:44 2008 From: windypower at gmail.com (WindPower) Date: Sat, 26 Apr 2008 14:08:44 -0700 (PDT) Subject: Desktop notifications on Windows References: <0db266c1-50ad-4e01-b508-57c9a8febb4b@a22g2000hsc.googlegroups.com> Message-ID: <60516dea-2c40-47d2-b816-8d9169399d86@c58g2000hsc.googlegroups.com> On Apr 26, 4:52 am, David wrote: > On Sat, Apr 26, 2008 at 4:41 AM, wrote: > > I'm looking for a way to implement desktop notifications (much like an > > instant messaging program or a mail notifier) within my Python > > application, on Windows only (no Gtk/Galago, please). I need no more > > than a simple text-based notification, which should be clickable and > > have a timeout, nothing else. I do not want to use Windows's "balloon > > tips", either. Any suggestions? > > -- > > You could use Tkinter, which comes with Python. The problem is that Tkinter cannot (I haven't looked at it in details, so correct me if I'm wrong) create notifications the way I want them; it can only create standard dialogs or top-level dialogs, both of which steal the focus of other applications, while I want these notifications not to interfere with anything (and possibly not be displayed if an application is already running in fullscreen). From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 3 05:03:07 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 03 Apr 2008 11:03:07 +0200 Subject: Prototype OO In-Reply-To: References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> Message-ID: <47f49d4b$0$5665$426a74cc@news.free.fr> sam a ?crit : > bruno.desthuilliers at gmail.com napisa?(a): > > >> So, while I often use Python's lambdas, the imposed limitations is ok >> to me since I wouldn't use it for anything more complex. > >> Also - as a side note - while the syntax is a bit different, the >> resulting object is an ordinary function. > > And people start asking why this is that or the other way in Python, and > you can't give a good answer to newcomers, especially if Python was > chosen as a first learning language. You can't tell "because Python's > parsing mechanism don't allow statements in expressions...". If the people asking is able to understand this explanation, I'll happily give it. Else, I'd answer "for reasons that are perhaps too complex to explain to you right now, but I'll try if you insist" !-) >>> But somebody may prefix his names with class names and cause >>> nameconflict, >> >> Here the problem is more philosophical than anything else. > > Almost the whole discussion is philosofical, but clear philosophy is a > good thing. > > > >> It's enough. FWIW, I'm not sure I had a use-case for this feature more >> than a couple time in 7+ years. > >> Simple, indeed. But why "not perfect" ? What else would you want ? > > I would expect you to told me at the beginning which "beginning" ? > that this is enough to > solve the problem what did I do ? > and that somebody can still cause name conflict, Why should I tell you something that's so obvious you observed it by yourself ? > but > Python was built for wise people. for normally intelligent people. I don't play russian roulette, and don't claim being any "wiser" for this. Ok, I'm going to be a bit harsh, but this time I'll assume it. Sam, you started this thread by asking about prototype vs class based pros and cons - with a (somewhat cargo-cult IMHO) a priori in favor of prototype. Then you started arguing about limitations and complexity induced by the class-based approach, without being able to back any of your claims wrt/ Python's object model. Then you started arguing about minor syntactic points that, whether you like them or not (and you're of course entitled to not like them) have nothing to do with Python's object model nor prototypes vs classes. Now you're complaining that "we didn't tell you x and z from the start" - like we were supposed to do your education. Are we supposed to teach you reading and writing too ? What's your problem anyway ? If you're a trolling - which I start to suspect -, then your not too bad at it. Else, it may be time to grow up. From ndbecker2 at gmail.com Fri Apr 25 08:30:56 2008 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 25 Apr 2008 08:30:56 -0400 Subject: ioctl, pass buffer address, howto? Message-ID: I need an ioctl call equivalent to this C code: my_struct s; s.p = p; << a pointer to an array of char s.image_size = image_size; return (ioctl(fd, xxx, &s)); I'm thinking to use python array for the array of char, but I don't see how to put it's address into the structure. Maybe ctypes is the answer? From fuzzyman at gmail.com Tue Apr 29 14:25:54 2008 From: fuzzyman at gmail.com (Fuzzyman) Date: Tue, 29 Apr 2008 11:25:54 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <57d73312-37b1-4c53-9669-803e84a6901f@p25g2000hsf.googlegroups.com> On Apr 22, 11:25 am, azrael wrote: > Hy guys, > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. > > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" > > This hurts. Please give me informations about realy famous > aplications. ` Resolver One - a spreadsheet development environment for creating business applications (aimed particularly at the financial services industry) is written in IronPython. There are around 30 000 lines of Python in the production code and about 120 000 lines of Python code in the test framework. Here is a quote from "Credit Cooperatif", a large French bank who are now using Resolver One: We use Excel and VBA, but we prefer Python for its combination of simplicity and power. We were looking to better link spreadsheets with Python programming, and Resolver One seemed to be the most elegant solution because it was based on Python but also gave us compatibility with our IT team?s architectural choice of Microsoft .NET. Resolver One (Windows only but free to try and for non-commercial use): http://www.resolversystems.com/ Michael Foord http://www.ironpythoninaction.com/ From hopeorpha308 at gmail.com Sun Apr 27 07:49:17 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:49:17 -0700 (PDT) Subject: badcopy crack Message-ID: badcopy crack http://wga-cracks.crackkey.net From matthieu.brucher at gmail.com Sat Apr 5 05:01:41 2008 From: matthieu.brucher at gmail.com (Matthieu Brucher) Date: Sat, 5 Apr 2008 11:01:41 +0200 Subject: ANN: pry unit testing framework In-Reply-To: <20080405082605.GA14042@nullcube.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> Message-ID: 2008/4/5, Aldo Cortesi : > > Thus spake Kay Schluehr (kay.schluehr at gmx.net): > > > > But you could have added the integration of code coverage and other > > helpful features with unittest as a conservative extension giving > > everyone a chance to use it directly with existing tests instead of > > forcing them to rewrite their tests for bike shading purposes. > > > You're assuming that Pry's only purpose is to introduce test coverage. > This is not the case - I already had a module that largely maintained > unittest compatibility, but added a command-line interface and coverage > analysis. It's now obsolete, but you can find its remains here if > you're interested: > > http://dev.nullcube.com/gitweb/?p=pylid;a=shortlog > > So, why did I re-write it? Well, I needed a test framework that didn't > have the deep flaws that unittest has. I needed good hierarchical > fixture management. I needed something that didn't instantiate test > suites automatically, freeing me to use inheritance more naturally > within my test suites. I needed more sophisticated handling and > reporting of errors during startup and teardown. I needed better > support for programmatic generation of tests. The list goes on. Pry > has all of this, and much of it is simply not possible while > maintaining backwards compatibility. > > Yes, test coverage is critical and hugely neglected by most people, but > Pry addresses other problems as well. We're not "forcing" anyone to > rewrite anything, but if the description above sounds like something > you want, maybe you should give Pry another look. If Pry itself is not > to your taste, there are other excellent test frameworks like py.test > that have also chosen not to mindlessly duplicate all of unittest's > inadequacies. Broaden your horizons and explore some of these - your > code will thank you for it... > Hi, How does it compare to the nose framework ? Matthieu -- French PhD student Website : http://matthieu-brucher.developpez.com/ Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92 LinkedIn : http://www.linkedin.com/in/matthieubrucher -------------- next part -------------- An HTML attachment was scrubbed... URL: From bruno.desthuilliers at gmail.com Mon Apr 7 13:29:25 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Mon, 7 Apr 2008 10:29:25 -0700 (PDT) Subject: Learning curve for new database program with Python? References: Message-ID: <0b8dc21b-f00f-41ee-b3a1-637fa251e7c8@k1g2000prb.googlegroups.com> On 5 avr, 17:50, Jetus wrote: > I have a need for a database program. I downloaded the db2 from ibm, > and reviewed some of the documentation. > > My question is, what is the easiest program for me to try to learn. I > will be creating a database of about 25,000 records, it will be > relational. I am a beginner Python programmer, and need a database > solution that is easy to grasp. I played with sql, > and found that very difficult, if not overly cumbersome. The point is that so far, "relational database" really means "SQL database". And believe me, trying to get away with a non-SQL database only to avoid learning SQL is probably the worst possible move for both your program and yourself. > A database that could work with Django would be very interesting to > look at as well.. The databases that the ORM part of Django can connect to are all SQL databases. > Any suggestions out there? I can only second / third etc what everyone already told you : learn SQL. And not only SQL, but also the theory that it builds upon (the 'relational model'), and the good practices wrt/ relational database design. There's no shortage of good quality freely available documentation on these topics, and you'll find help on quite a couple of newsgroups / forums / whatever. I'd strongly recommand you start without Django's ORM first, so you get a chance to learn how it really works undercover. Else you might end up doing things in a very inefficient way. From cwitts at gmail.com Wed Apr 23 08:02:13 2008 From: cwitts at gmail.com (Chris) Date: Wed, 23 Apr 2008 05:02:13 -0700 (PDT) Subject: problem with dictionaries References: Message-ID: <0f1c7e1c-2a13-4289-808a-bbd2a4d1e995@24g2000hsh.googlegroups.com> On Apr 23, 1:16?pm, Simon Strobl wrote: > Hello, > > the idea of the following program is to parse a frequency list of the > form FREQUENCY|WORD, to store the frequency of a word in a dictionary > (and to do some things with this information later). > > I have done this many many times. Suddenly, it does not work any more: > The value frq[key] is different from the value that key has in the > file 'my_frqlist.txt'. > > I am using Python 2.5.1 > > Any hints? > > Simon > > ================================================ > > #!/usr/bin/python > > import sys > > frqlist = open('my_frqlist.txt', 'r') > > # my_frqlist looks like this: > # 787560608|the > # 434879575|of > # 413442185|and > # 395209748|to > # 284833918|a > # 249111541|in > # 169988976|is > > frq = {} > > for line in frqlist: > ? ? line = line.rstrip() > ? ? frequency, word = line.split('|') > ? ? frq[word] = int(frequency) > > for key in frq.keys(): > ? ? print key, ?frq[key] there's nothing wrong with that section, just try this when building your dictionary... if word in frq: print 'Duplicated Word Found: %s' % word only possibility that I can think of, and that is logical, is that you have duplicate keys in your file. From d.bollmann at tu-berlin.de Tue Apr 8 04:24:56 2008 From: d.bollmann at tu-berlin.de (Dietrich Bollmann) Date: Tue, 08 Apr 2008 17:24:56 +0900 Subject: segmentation fault when executing PyImport_ImportModule("sys") Message-ID: <1207643096.845.5.camel@pippi.pippi> Hi, Since some time I get the following segmentation fault in an application which used to work fine until recently. I made a backtrace but couldn't find the reason for the segmentaion fault until now. In the hope that somebody might have encountered a similar problem or does understand the backtrace better than me and can explain it I posted the backtrace here... At the end of the backtrace I appended some more context concerning the involved code. Thanks for your help :) Dietrich Here comes the backtrace: ---- Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb046ab90 (LWP 9854)] threadstate_getframe (self=0xb7e8a889) at ../Python/pystate.c:154 154 ../Python/pystate.c: No such file or directory. in ../Python/pystate.c (gdb) bt full #0 threadstate_getframe (self=0xb7e8a889) at ../Python/pystate.c:154 No locals. #1 0xb7e8a897 in PyEval_GetGlobals () at ../Python/ceval.c:3340 current_frame = #2 0xb7eaeb67 in PyImport_Import (module_name=0xb7119480) at ../Python/import.c:2400 globals = import = builtins = r = silly_list = (PyObject *) 0xb738fb0c builtins_str = (PyObject *) 0xb7391c50 import_str = (PyObject *) 0xb7391fc0 #3 0xb7eaede5 in PyImport_ImportModule (name=0x901504b "sys") at ../Python/import.c:1903 pname = (PyObject *) 0xb7119480 result = (PyObject *) 0x0 #4 0x08996c9f in py_stdouterr_buffer_new () at source/blender/commandport/blender/src/py_stdouterr_buffer.c:75 buffer = (py_stdouterr_buffer) 0x94fd428 func_StringIO = (PyObject *) 0x9152a48 args_StringIO = (PyObject *) 0x0 #5 0x089967e1 in bcp_blender_handler_new () at source/blender/commandport/blender/src/bcp_blender.c:130 handler = (bcp_blender_handler) 0x9810420 #6 0x08998db3 in bcp_handle_client (client_socket=8) at source/blender/commandport/blender/src/bcp_handle_client.c:73 debug = 0 debug3 = 0 debug4 = 0 message_handler = (message_handler) 0x97eba10 blender_handler = (bcp_blender_handler) 0x0 command = 0x0 result = 0x9152a48 "%G?%@016\025\th%G??%@@\\%G?%@022v#\b \"v#\b%G??%@v#\bRv#\bbv#\brv#\b\202v#\b\222v#\b%G?%@v#\b%G?%@v#\b` \032%G?%@020\026%G???%@#\b%G?%@#\b\002w#\b\022w# \b\"w#\b2w#\bBw#\bRw#\bbw#\brw#\b\202w#\b\222w#\b%G?%@w#\b%G?%@w# \bp#p%G??%@#\b" package_number = -1216545219 #7 0x08998d60 in bcp_client_thread (args=0x0) at source/blender/commandport/blender/src/bcp_server.c:164 targs = (struct bcp_client_thread_args *) 0x0 client_socket = 8 client_thread = 2957421456 #8 0xb76b04fb in start_thread () from /lib/i686/cmov/libpthread.so.0 No symbol table info available. #9 0xb77c2d7e in clone () from /lib/i686/cmov/libc.so.6 No symbol table info available. (gdb) q The program is running. Exit anyway? (y or n) y --- and here some informations about its context: Python-2.4.4/Python/ceval.c line 3340: PyFrameObject *current_frame = PyEval_GetFrame(); context: --- PyObject * PyEval_GetGlobals(void) { PyFrameObject *current_frame = PyEval_GetFrame(); if (current_frame == NULL) return NULL; else return current_frame->f_globals; } --- Python-2.4.4/Python/pystate.c lign 154: { context: --- /* Default implementation for _PyThreadState_GetFrame */ static struct _frame * threadstate_getframe(PyThreadState *self) { return self->frame; } --- Python-2.4.4/Python/import.c lign 2400: globals = PyEval_GetGlobals(); context: --- PyObject * PyImport_Import(PyObject *module_name) { ... /* Get the builtins from current globals */ globals = PyEval_GetGlobals(); if (globals != NULL) { Py_INCREF(globals); builtins = PyObject_GetItem(globals, builtins_str); if (builtins == NULL) goto err; } ... } --- Python-2.4.4/Python/import.c lign 1903: result = PyImport_Import(pname); context: --- PyObject * PyImport_ImportModule(char *name) { PyObject *pname; PyObject *result; pname = PyString_FromString(name); if (pname == NULL) return NULL; result = PyImport_Import(pname); Py_DECREF(pname); return result; } --- source/blender/commandport/blender/src/py_stdouterr_buffer.c lign 75: buffer->mod_sys = PyImport_ImportModule("sys"); context: --- /** Make a new python io buffer. */ py_stdouterr_buffer py_stdouterr_buffer_new() { py_stdouterr_buffer buffer; buffer = (py_stdouterr_buffer) malloc(sizeof(py_stdouterr_buffer_struct)); if (buffer == NULL) { fprintf(stderr, "Couldn't allocate memory for new py_stdouterr_buffer! \n"); exit(ERROR_MEMORY); } buffer->mod_sys = PyImport_ImportModule("sys"); buffer->mod_cStringIO = PyImport_ImportModule("cStringIO"); /* store stdout and stderr */ buffer->stdout_obj = PyObject_GetAttrString(buffer->mod_sys, "stdout"); buffer->stderr_obj = PyObject_GetAttrString(buffer->mod_sys, "stderr"); /* make new string buffer for stdout and stderr */ PyObject *func_StringIO, *args_StringIO; func_StringIO = PyObject_GetAttrString(buffer->mod_cStringIO, "StringIO"); args_StringIO = Py_BuildValue("()"); buffer->outbuf_obj = PyEval_CallObject(func_StringIO, args_StringIO); buffer->errbuf_obj = PyEval_CallObject(func_StringIO, args_StringIO); Py_DECREF(args_StringIO); Py_DECREF(func_StringIO); return buffer; } --- From carbanancizpo at gmail.com Fri Apr 18 16:54:34 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:54:34 -0700 (PDT) Subject: diet patch for diets Message-ID: <609fc671-b006-4a35-b320-22d7a99fcaee@w4g2000prd.googlegroups.com> diet patch for diets http://cracks.12w.net F R E E C R A C K S From tim.arnold at sas.com Tue Apr 8 14:19:54 2008 From: tim.arnold at sas.com (Tim Arnold) Date: Tue, 8 Apr 2008 14:19:54 -0400 Subject: set file permission on windows References: <7d75fc7b-a2b7-4ca2-b386-27da975043d0@m44g2000hsc.googlegroups.com> Message-ID: "Mike Driscoll" wrote in message news:7d75fc7b-a2b7-4ca2-b386-27da975043d0 at m44g2000hsc.googlegroups.com... > On Apr 8, 12:03 pm, "Tim Arnold" wrote: >> > According to the following thread, you can use os.chmod on Windows: > > http://mail.python.org/pipermail/python-list/2003-June/210268.html > > You can also do it with the PyWin32 package. Tim Golden talks about > one way to do it here: > > http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html > > Also see the following thread: > > http://mail.python.org/pipermail/python-win32/2004-July/002102.html > > or > > http://bytes.com/forum/thread560518.html > > Hope that helps! > > Mike Hi Mike, It does help indeed, especially the last two links. That certainly gets me started in the right direction. I'm always amazed at the helpful generosity of the folks on this list. thanks again for the help. --Tim Arnold From pylists at arcor.de Sun Apr 13 23:33:19 2008 From: pylists at arcor.de (Penny Y.) Date: Mon, 14 Apr 2008 11:33:19 +0800 Subject: about the ';' Message-ID: <20080414033334.97C8B8C461@mail-in-12.arcor-online.net> I saw many python programmers add a ';' at the end of each line. As good style, should or should not we do coding with that? Thanks. From kay.schluehr at gmx.net Sat Apr 5 07:16:35 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 5 Apr 2008 04:16:35 -0700 (PDT) Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> Message-ID: <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> On 5 Apr., 12:26, Aldo Cortesi wrote: > Thus spake Kay Schluehr (kay.schlu... at gmx.net): > > > I'm not entirely sure what you are claiming here. From source > > inspections I can see that TestSuite instances are instantiated by the > > TestLoader and you are free to derive from TestLoader, overwrite its > > methods and pass around another instance than defaultTestLoader ( or > > a fresh instance of TestLoader which is the same thing ). > > ... and at this point your monkeypatched framework would no longer be > much more compatible with existing test suites than Pry is. A properly extended framework would of course be compatible with all existing test suites. This has nothing to do with monkeypatching. I'm not sure you even understand the concepts you are talking about. Kay From llothar at web.de Sat Apr 5 05:39:57 2008 From: llothar at web.de (llothar) Date: Sat, 5 Apr 2008 02:39:57 -0700 (PDT) Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> Message-ID: <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> On 5 Apr., 15:48, Fredrik Lundh wrote: > llothar wrote: > > My question was: Why does setup.py generated sometimes a pyd and > > sometimes a so file? > > setup.py picks an extension that happens to work on the platform you're > running setup.py on. doing otherwise would be pretty pointless. > > Unfortunately as pointless as the answers i got so far. Okay i try it one more time: I ship an application that compiles an python interpreter and extension on a remote system. It also needs to copy this created items around. So if i use setup.py to create an extension i need to know the file name of the generated file. Damned this is trivial and a fundamental question and it is not documented anywhere. I have a clue at the moment that it might be ".so" when python is compiled without shared library and ".pyd" otherwise (configure option --enable-shared) . But this is just a guess. Does anybody know? And by the way: I think this is a bug and should be fixed. If the platform does allow renaming the extension of a DLL (does HP/UX allow this?) it should always be ".pyd" From grante at visi.com Fri Apr 25 15:01:59 2008 From: grante at visi.com (Grant Edwards) Date: Fri, 25 Apr 2008 14:01:59 -0500 Subject: Why is None <= 0 References: Message-ID: On 2008-04-25, Gregor Horvath wrote: > Hi, > > >>> None <= 0 > True > > Why? Comparing objects of differing types produces an undefined result. Next time you do it, it might return False. (Well, it's not really going to, but it's allowed to.) > Is there a logical reason? For what? There's no reason it returns true rather than false. The more interesting question is why doesn't it raise an exception. -- Grant Edwards grante Yow! These PRESERVES should at be FORCE-FED to PENTAGON visi.com OFFICIALS!! From nemesis at nowhere.invalid Sat Apr 26 07:38:45 2008 From: nemesis at nowhere.invalid (Nemesis) Date: 26 Apr 2008 11:38:45 GMT Subject: nntplib retrieve news://FULL_URL References: Message-ID: <48131444$0$35957$4fafbaef@reader2.news.tin.it> James.Pells at gmail.com wrote: > So I have established a connection to an nntp server and I am > retrieving articles to other articles on the server such as > news://newsclip.ap.org/D8L4MFAG0 at news.ap.org > > Now I am wondering how I query for that article based off of the url? > > I assume D8L4MFAG0 is an id of some sort but when I try and retrieve > that article via myNntpObject.article('D8L4MFAG0') I get an error of > 423 Bad article number. Which makes sense as all the other article > numbers are integers. You should study a little bit NNTP RFCs ;-) Anyway D8L4MFAG0 at news.ap.org could be the Message-ID of the article, a 'unique' identifier associated to each article, while the Article Number is unique on the server (but it changes on different servers). the nntplib NNTP.article command can accept either Message-ID or Number as argument, but if you want to use Message-ID you need to enclose it in brackets <>. So in your case this query should work: myNntpObject.article('') Regards. -- Love is an irresistible desire to be irresistibly desired. _ _ _ | \| |___ _ __ ___ __(_)___ | .` / -_) ' \/ -_|_-< (_-< |_|\_\___|_|_|_\___/__/_/__/ http://xpn.altervista.org From v.harishankar at gmail.com Tue Apr 22 06:52:57 2008 From: v.harishankar at gmail.com (Harishankar) Date: Tue, 22 Apr 2008 16:22:57 +0530 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? Message-ID: <200804221622.57424.v.harishankar@gmail.com> Hi, Sorry to start off on a negative note in the list, but I feel that the Python subprocess module is sorely deficient because it lacks a mechanism to: 1. Create non-blocking pipes which can be read in a separate thread (I am currently writing a mencoder GUI in Tkinter and need a full fledged process handler to control the command line and to display the progress in a text-box) 2. Kill the subprocess in a platform independent manner (i.e. no third party modules and no hacks). Is there any way to use non-blocking Popen objects using subprocess? and 2 - is there a way to kill the subprocess in a platform independent manner in a purely Pythonic way? I thought initially that this problem is simple enough, but over the last couple of days I've been really struggling to find any answer. I've been through dozens of mailing list archives in to find a solution. Unfortunately none of the solutions seem to fit my needs. My only solution seems to be to offer the end user the mencoder command line and make them execute it manually and be done with it but that seems a rather weak solution. -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org From dickinsm at gmail.com Wed Apr 16 16:33:39 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Wed, 16 Apr 2008 13:33:39 -0700 (PDT) Subject: def power, problem when raising power to decimals References: Message-ID: On Apr 16, 4:19?pm, skanem... at yahoo.se wrote: > how do i solve power(5,1.3)? > [...] > > also i found a link which states 0^0 isnt 1 even though every > calculator ive tried says it is. > it doesnt say what it is but i presume 0 then. > but it seems the dude is wrong and it is 1? >>> 5**1.3 8.1032829834638136 >>> 0**0 1 >>> 0.**0. 1.0 >>> from decimal import Decimal >>> Decimal(0)**Decimal(0) Traceback (most recent call last): File "", line 1, in File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/decimal.py", line 1755, in __pow__ return context._raise_error(InvalidOperation, '0 ** 0') File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/decimal.py", line 2325, in _raise_error raise error, explanation decimal.InvalidOperation: 0 ** 0 Most mathematicians consider 0**0 to be either 1 or undefined. Which answer you get depends on who you ask (or in Python, whether you're working with floats or Decimals, as you see above). Mark From pavlovevidence at gmail.com Sat Apr 12 10:29:00 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Sat, 12 Apr 2008 07:29:00 -0700 (PDT) Subject: str(bytes) in Python 3.0 References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> Message-ID: <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> On Apr 12, 10:06 am, Kay Schluehr wrote: > On 12 Apr., 14:44, Christian Heimes wrote: > > > Gabriel Genellina schrieb: > > > > On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') > > > above. But I get the same as repr(x) - is this on purpose? > > > Yes, it's on purpose but it's a bug in your application to call str() on > > a bytes object or to compare bytes and unicode directly. Several months > > ago I added a bytes warning option to Python. Start Python as "python > > -bb" and try it again. ;) > > > Christian > > And making an utf-8 encoding default is not possible without writing a > new function? I believe the Zen in effect here is, "In the face of ambiguity, refuse the temptation to guess." How do you know if the bytes are utf-8 encoded? I'm not sure if str() returning the repr() of a bytes object (when not passed an encoding) is the right thing, but it's probably better than throwing an exception. The problem is, str can't decide whether it's a type conversion operator or a formatted printing function--if it were strongly one or the other it would be a lot more obvious what to do. Carl Banks From fr5478bey at gmail.com Sat Apr 26 11:42:54 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:42:54 -0700 (PDT) Subject: bookworm adventure crack Message-ID: bookworm adventure crack http://cracks.00bp.com F R E E C R A C K S From fetchinson at googlemail.com Wed Apr 16 12:15:47 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Wed, 16 Apr 2008 09:15:47 -0700 Subject: python beginer In-Reply-To: <81d84eb10804160020n114c4d7ekfef7a09532813e39@mail.gmail.com> References: <81d84eb10804160020n114c4d7ekfef7a09532813e39@mail.gmail.com> Message-ID: > can anyone tell me hw to start with webapplication scripting(e.g login > page..etc) > if anyone has soln for this or simple e.g that mention above please send me There are many choices, too many actually. Good entry points are: http://wiki.python.org/moin/WebApplications http://wiki.python.org/moin/WebFrameworks http://www.modpython.org/ http://turbogears.org/ http://djangoproject.com/ You need be prepared to evaluate a bunch of options before deciding which way you go. Unfortunately this can not be avoided and can be quite a lengthy process. HTH, Daniel From steve at holdenweb.com Thu Apr 24 07:20:57 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 07:20:57 -0400 Subject: function that accepts any amount of arguments? In-Reply-To: References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> Message-ID: Ken wrote: > "Steve Holden" wrote in message [...] >> def mean(*x): >> total = 0.0 >> for v in x: >> total += v >> return v/len(x) >> > > think you want total/len(x) in return statement > Yes indeed, how glad I am I wrote "untested". I clearly wasn't pair programming when I wrote this post ;-) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From ashishk30 at gmail.com Tue Apr 15 08:47:17 2008 From: ashishk30 at gmail.com (ashish) Date: Tue, 15 Apr 2008 05:47:17 -0700 (PDT) Subject: hw to program on python Message-ID: <2732d09a-b0e6-4ae6-a826-9fa375fb3e86@q10g2000prf.googlegroups.com> hi , python experts i want some help from u people just mail me how to write scripts for web applications (like form coding for login page, etc). i m waiting.... for ur reply by have a nice day! From pavlovevidence at gmail.com Mon Apr 7 08:29:22 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 7 Apr 2008 05:29:22 -0700 (PDT) Subject: Dependency Queue Message-ID: <0309251d-fba9-447c-9b17-f512988103ea@e39g2000hsf.googlegroups.com> I'm looking for any information about a certain kind of dynamic data structure. Not knowing if it has some well-known name that I could have Googled, I'll just call it a dependency queue. It's like a priority queue except instead of a strict ordering of items by priority, there is only a topological ordering (like you would have in a directed acyclic graph). To date I've been generating a dependency graph in advance every iteration through my main loop, doing a topsort, and executing the values in order (the values are callable objects--this is a scheduler). However, I'd like a dynamic dependency queue for two reasons: it would simplify things to not have to generate the whole graph in advance, and it could improve performance to run some tasks of the next iteration in the present one (this could potentially make better use of the dual-core and graphics hardware). I'm pretty sure I could hack out this structure on my own, but I'd like to see any prior information if there is any, in case anyone's figured out things like, Is there an easy way to detect cycles on insertion? and so on. Carl Banks From rbrito at ime.usp.br Mon Apr 28 17:09:03 2008 From: rbrito at ime.usp.br (=?ISO-8859-1?Q?Rog=E9rio_Brito?=) Date: Mon, 28 Apr 2008 18:09:03 -0300 Subject: Little novice program written in Python References: Message-ID: On 04/25/2008 09:30 AM, Nick Craig-Wood wrote: > When you are up to speed in python I suggest you check out gmpy for > number theory algorithms. Thanks. That is quite useful to know when I don't want to code explicitly the details of the algorithm. Thanks, Rog?rio. -- Rog?rio Brito : rbrito@{mackenzie,ime.usp}.br : GPG key 1024D/7C2CAEB8 http://www.ime.usp.br/~rbrito : http://meusite.mackenzie.com.br/rbrito Projects: algorithms.berlios.de : lame.sf.net : vrms.alioth.debian.org From kyosohma at gmail.com Tue Apr 29 16:57:09 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 29 Apr 2008 13:57:09 -0700 (PDT) Subject: py2exe Icon Resources References: <40c03afe-b2c5-4793-b7c3-f5a97360fe6c@a23g2000hsc.googlegroups.com> Message-ID: <03de407d-1d29-4f47-bf14-c7af0af481e7@59g2000hsb.googlegroups.com> On Apr 29, 3:24?pm, flarefi... at googlemail.com wrote: > I have created an app using python and then converting it to an exe > using py2exe, and have the following code: > > "icon_resources": [(1, "appFavicon.ico"), (2, "dataFavicon.ico")] > > in my py2exe setup file, the appFavicon works fine and it sets that as > the app icon thats fine, but the program creates data files (like > documents) and i wanted them to have a different icon... > > I package my apps using Inno Setup 5, and it registers the file type > fine so that it loads on double click, what i cant do is set the icon > for the file. > > as you can see i have packaged two different icons with py2exe but > when i set DefaultIcon in the registry to "C:\pathtoapp\myapp.exe,2" > it doesnt work, nor does it work with a 1 or a %1 or indeed with > passing a path to the icon itself, nothing seems to work!! > > how do you access the other icons generated from py2exe, or how do you > set the registry up so that i looks for the icon correctly, > > any help appreciated, > > Caspar I recommend cross-posting this to the py2exe mailing list and maybe the distutils mailing list if the fine people here don't have answers. https://lists.sourceforge.net/lists/listinfo/py2exe-users http://mail.python.org/mailman/listinfo/distutils-sig Mike From manthra.mohan at gmail.com Fri Apr 18 13:46:30 2008 From: manthra.mohan at gmail.com (Krishna) Date: Fri, 18 Apr 2008 10:46:30 -0700 (PDT) Subject: Excel Manipulation using Python References: Message-ID: On Apr 18, 11:36?am, Tim Golden wrote: > Krishna wrote: > > I was trying to delete rows in an existing .xls file using python. How > > do I do that? I was using the following code, it seem to work if I > > type in python window, but if I save it in text editor and drage and > > drop the .py file, it doesnt work. What am I doing wrong here? ?Thanks > > for your help! > > > import win32com.client > > from time import sleep > > excel = win32com.client.Dispatch("Excel.Application") > > > def Extract(): > > ? ?excel.Visible = 0 > > ? ?workbook=excel.Workbooks.Open('C:\Trial.xls') > > > ? ?i=1 > > ? ?for n in range(1,10): > > ? ? ? ? ? ?excel.Rows(i).Select > > ? ? ? ? ? ?excel.Selection.Delete > > ? ? ? ? ? ?excel.Selection.Delete > > ? ? ? ? ? ?i=i+2 > > ? ? ? ? ? ?workbook.Save() > > ? ? ? ? ? ?print "saved" > > > ? ?excel.Quit() > > Several points worthy of note: > > 1) When you're dealing with Windows filenames, either make > the strings raw -- Open (r"c:\trial.txt") -- or use the other > slashes =-- Open ("c:/trial.xls"). > > 2) You're not actually calling the Select and Delete > methods, merely referencing them. Try .Delete () etc. > > 3) You're saving the workbook every time round the loop, > but perhaps you knew that. Might prompt you everytime > as you're overwriting, but again, maybe you knew... > > TJG- Hide quoted text - > > - Show quoted text - Cool, That worked! Thanks for your help TJG! From george.sakkis at gmail.com Wed Apr 23 19:22:05 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 23 Apr 2008 16:22:05 -0700 (PDT) Subject: Parsing tuple from string? References: Message-ID: On Apr 23, 6:24?pm, Daniel wrote: > I have a list of strings, which I need to convert into tuples. ?If the > string is not in python tuple format (i.e. "('one', 'two')", "("one", > 'two')", etc.), then I can just make it a 1-tuple (i.e. return > (string,) ). ?If it is in python tuple format, I need to parse it and > return the appropriate tuple (it's ok to keep all tuple elements as > strings). > > I think eval() will work for this, but I don't know what will be in > the string, so I don't feel comfortable using that. Check out one of the safe restricted eval recipes, e.g. http://preview.tinyurl.com/6h7ous. HTH, George From ni at hao.com Sat Apr 26 14:38:32 2008 From: ni at hao.com (SL) Date: Sat, 26 Apr 2008 20:38:32 +0200 Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) In-Reply-To: References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> Message-ID: <925ee$481376ab$541fc2ec$11281@cache3.tilbu1.nb.home.nl> "SL" schreef in bericht news:bec2d$481372ed$541fc2ec$6742 at cache3.tilbu1.nb.home.nl... > > "n00m" schreef in bericht > news:6a3f8226-04c6-4ee3-b5a6-f76aca44aa31 at a23g2000hsc.googlegroups.com... >> using namespace std; >> char vs[1002000][99]; >> if (!fgets(vs[i],999,fp)) break; BTW why are you declaring the array as 99 and pass 999 to fgets to read a line? From bbxx789_05ss at yahoo.com Fri Apr 4 00:10:00 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Thu, 3 Apr 2008 21:10:00 -0700 (PDT) Subject: Parsing HTML? References: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> Message-ID: <29bcc6bc-ab2e-4ba6-a7b3-aa1f1e850ea1@y21g2000hsf.googlegroups.com> On Apr 3, 12:39?am, ben... at gmail.com wrote: > BeautifulSoup does what I need it to. ?Though, I was hoping to find > something that would let me work with the DOM the way JavaScript can > work with web browsers' implementations of the DOM. ?Specifically, I'd > like to be able to access the innerHTML element of a DOM element. > Python's built-in HTMLParser is SAX-based, so I don't want to use > that, and the minidom doesn't appear to implement this part of the > DOM. > innerHTML has never been part of the DOM. It is however a defacto browser standard. That's probably why you aren't having any luck using a python module that implements the DOM. From roger.dahlstrom at gmail.com Sat Apr 12 20:11:51 2008 From: roger.dahlstrom at gmail.com (rdahlstrom) Date: Sat, 12 Apr 2008 17:11:51 -0700 (PDT) Subject: Windows - window status (Running vs Not Responding) References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> Message-ID: <108495a2-789b-47b6-94bb-eda616b65254@c65g2000hsa.googlegroups.com> On Apr 11, 11:18 pm, Ross Ridge wrote: > rdahlstrom wrote: > >Basically, I'm looking for something similar to the Process.Responding > >property in System.Diagnostics... > > You probably want to use IsHungAppWindow(): > > IsHungAppWindow Function > > You call the IsHungAppWindow function to determine if > Microsoft Windows considers that a specified application is not > responding. An application is considered to be not responding > if it is not waiting for input, is not in startup processing, > and has not called PeekMessage within the internal timeout period > of 5 seconds. > > Syntax > > BOOL IsHungAppWindow( > HWND hWnd > ); > > ... > > You can use EnumWindows() to enumerate the all the top level windows. > > Ross Ridge > > -- > l/ // Ross Ridge -- The Great HTMU > [oo][oo] rri... at csclub.uwaterloo.ca > -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ > db // Holy crap, so simple, yet so awesome. Thanks! From landerdebraznpc at gmail.com Mon Apr 28 03:52:45 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:52:45 -0700 (PDT) Subject: keygen nfs pro street Message-ID: keygen nfs pro street http://crack.cracksofts.com From ed.leafe at rackspace.com Thu Apr 3 11:06:11 2008 From: ed.leafe at rackspace.com (Ed Leafe) Date: Thu, 3 Apr 2008 10:06:11 -0500 Subject: Looking for Agile Python Consulting Message-ID: This isn't a specific job request, which is why I'm not placing it on the Python Job Board. Rather, I'm in the process of gathering information for an upcoming project, and I need to determine what resources, if any, are available in the Python community. We're in the planning stages of a fairly long-term project (1-2 years), and the management here has been very impressed by the work of a consulting group used on another project in the company. They use Agile programming techniques, and have a lot of experience managing these sorts of projects. Unlike other projects with consultants, theirs have been very successful, and thus management is leaning towards using them for this one. The problem, though, is that these consultants are a Rails shop, and it would mean changing a large part of our coding efforts to Ruby. My very strong preference is to stay with Python, so I'm trying to locate Python-centric consultants who use a similar disciplined Agile approach so that I can propose an alternative to the Rails solution. I'm not terribly concerned with Django vs. TurboGears vs. any other framework; at this point I'm only concerned with Python vs. Ruby. If you are part of such a consulting group, or know of one that fits these requirements, please reply to me off-list. -- Ed Leafe Confidentiality Notice: This e-mail message (including any attached or embedded documents) is intended for the exclusive and confidential use of the individual or entity to which this message is addressed, and unless otherwise expressly indicated, is confidential and privileged information of Rackspace. Any dissemination, distribution or copying of the enclosed material is prohibited. If you receive this transmission in error, please notify us immediately by e-mail at abuse at rackspace.com, and delete the original message. Your cooperation is appreciated. From tjreedy at udel.edu Sat Apr 5 12:26:51 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 5 Apr 2008 12:26:51 -0400 Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com><20080405141329.GD15684@nullcube.com> Message-ID: "Steve Holden" wrote in message news:ft84g9$ola$1 at ger.gmane.org... | Aldo Cortesi wrote: | > Thus spake Kay Schluehr (kay.schluehr at gmx.net): **tweet**
b) Define a function to extract a "key" from your items such that items compare the same as their keys. For example, key(x) -> x.lower() may be used to compare text case-insensitively. Then, use a tuple (key, value) instead of the bare value. When extracting items from the queue, remember to unpack both parts. This is known as the decorate-sort-undecorate pattern; google for it. This is the approach used on your code snippet. def keyfunc(x): return x.lower() x1 = "bcd" x2 = "abC" x3 = "Z" x4 = "AbC" queue = [] insort(queue, (keyfunc(x1),x1)) print queue insort(queue, (keyfunc(x2),x2)) print queue insort(queue, (keyfunc(x3),x3)) print queue insort(queue, (keyfunc(x4),x4)) print queue print [value for (key,value) in queue] -- Gabriel Genellina From shane.lillie at gmail.com Wed Apr 9 11:30:32 2008 From: shane.lillie at gmail.com (Shane Lillie) Date: Wed, 9 Apr 2008 09:30:32 -0600 Subject: Trouble with list comprehension Message-ID: <4c3db5c00804090830p1b05748drf4ee5b8c3185ad9e@mail.gmail.com> I've got a bit of code that looks like this: for i in xrange(1000): # shuffle the doors doors = [ 'G', 'C', 'G' ] random.shuffle(doors) # save the doors that have goats (by index) goats = [ x for x in range(2) if doors[x] == 'G' ] but for some reason the list comprehension is not always returning a list with 2 elements in it (sometimes it will be just 1 element). I've tried changing to a generator as well as using filter() and all 3 give the same sort of results. It works if I use a loop, but I'd really like to know what I'm doing wrong here. Everything looks like it should be working. Thanks in advance for any suggestions. From steve at holdenweb.com Wed Apr 23 13:10:44 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 13:10:44 -0400 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. In-Reply-To: <480f6553$0$34545$742ec2ed@news.sonic.net> References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> Message-ID: John Nagle wrote: > Mike Driscoll wrote: >> Ken, >> >> On Tue, Apr 22, 2008 at 1:36 PM, Kenneth McDonald >> wrote: >>> Sadly. >>> >>> Thanks, >>> Ken >>> -- >>> http://mail.python.org/mailman/listinfo/python-list >>> >> >> I've attached the 2.4 version. I also have some Windows binaries for >> Beautiful Soup uploaded to my website: >> http://www.pythonlibrary.org/python_modules.htm > > What on earth do you need a "Windows binary" for? "BeautifulSoup" > is ONE PYTHON SOURCE FILE, "BeautifulSoup.py". It can be downloaded > here: > > http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup.py > > And yes, the site is up. > Windows installers for pure Python modules may seem daft to you, but you are familiar with the Python interpreter's filestore layout. Naive Windows users, however, would be much happier to run an installer. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From hniksic at xemacs.org Fri Apr 25 17:12:46 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Fri, 25 Apr 2008 23:12:46 +0200 Subject: Setting an attribute without calling __setattr__() References: Message-ID: <87bq3xej01.fsf@mulj.homelinux.net> Joshua Kugler writes: > self.me = [] > self.me = {} Use "object.__setattr__(self, 'me') = []" and likewise for {}. From kyosohma at gmail.com Fri Apr 25 17:28:40 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 25 Apr 2008 14:28:40 -0700 (PDT) Subject: display monochromatic images wxPython References: <43c2ef33-b08c-4161-b170-16ab346628d7@m36g2000hse.googlegroups.com> Message-ID: <74b32cb2-a03a-416e-894c-420a888d2f20@q24g2000prf.googlegroups.com> On Apr 25, 3:42?pm, "wongjoek... at yahoo.com" wrote: > Dear All, > I want to write a GUI program with wxPython displaying an image. But > the image I have is monochromatic. When I retrieve the data from the > image I end up with a list of integer. Starting from a list of integer > and knowing the width and height of the image, how do I display such > an image on a wx panel or frame ? I have had a look at the wxPython > demo but there I see only images where the data is a list of tuple > consisting of r,g ,b values. Is there are function where I directly > can input the list of array and let it display the image ? > Thanks in advance > > RR You should be able to create a wx.StaticBitmap object and then set the photo on it. Something like this: # create a blank image holder img = wx.EmptyImage(240,240) self.myImageObj = wx.StaticBitmap(self, wx.ID_ANY, wx.BitmapFromImage(img)) self.myImageObj.SetBitmap(wx.BitmapFromImage(img)) # refresh the widgets self.Refresh() # where "self" is a wx.Frame If that doesn't make sense or doesn't work in your case, please re- post the question to the wxPython's User group: http://wxpython.org/maillist.php Mike From google at mrabarnett.plus.com Wed Apr 2 15:11:12 2008 From: google at mrabarnett.plus.com (MRAB) Date: Wed, 2 Apr 2008 12:11:12 -0700 (PDT) Subject: non-terminating regex match References: Message-ID: On Apr 2, 5:01 pm, Maurizio Vitale wrote: > Has to be something really stupid, but the following never finish > (running Python 2.5.1 (r251:54863, Jan 10 2008, 18:00:49) > [GCC 4.2.1 (SUSE Linux)] on linux2). > > The intention is to match C++ identifiers, with or without namespace > qualification, with or without arguments (e.g. variables, functions and > macros). > The following should be accepted: > main > main(int,char**) > ::main > std::cout > ::std::cout > NDEBUG > > Thanks for any help. > And yes, I'm a total beginner when it comes to Python, but it seems > very strange to me that a regex match on a finite length string > doesn't terminate > Regards, > > Maurizio > > #!/usr/bin/env python > # -*- Python -*- > > import re > > if __name__ == '__main__': > r = re.compile ( > r'(?:(?P(?:(?:::)?\w+)*)::)?' > r'(?P\w+)' > r'(?:\((?P[^\)]*)\))?' > ) > match = r.search ('WITH_ALOHA_EXCEPTION_HANDLERS') I think the problem is with this bit: '(?:(?:::)?\w+)*'. The '::' is optional and also in a repeated group, so if it tries to match, say, 'abc' it can try and then backtrack all of these possibilities: abc, ab c, a bc, a b c. The longer the string, the more possibilities to try. Try this instead: r = re.compile ( r'(?P(?:::)?(?:\w+::)*)?' r'(?P\w+)' r'(?:\((?P[^\)]*)\))?' ) From nospam at invalid.com Thu Apr 24 23:09:33 2008 From: nospam at invalid.com (Jack) Date: Fri, 25 Apr 2008 03:09:33 GMT Subject: ctypes: return a pointer to a struct Message-ID: I'm not able to build IP2Location's Python interface so I'm trying to use ctypes to call its C interface. The functions return a pointer to the struct below. I haven't been able to figure out how I should declare the return type of the functions and read the fields. Any hint is appreciated. typedef struct { char *country_short; char *country_long; char *region; char *city; char *isp; float latitude; float longitude; char *domain; char *zipcode; char *timezone; char *netspeed; } IP2LocationRecord; From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 2 07:38:40 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 02 Apr 2008 13:38:40 +0200 Subject: object-relational mappers In-Reply-To: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> Message-ID: <47f37039$0$31900$426a74cc@news.free.fr> Aaron Watters a ?crit : > I've been poking around the world of object-relational > mappers and it inspired me to coin a corellary to the > the famous quote on regular expressions: > > "You have objects and a database: that's 2 problems. > So: get an object-relational mapper: > now you have 2**3 problems." > > That is to say I feel that they all make me learn > so much about the internals and features of the > O-R mapper itself that I would be better off rolling > my own queries on an as-needed basis without > wasting so many brain cells. > > comments? If you're ok with building your queries as raw string and handling your resultsets as lists of tuples, then you're right, don't waste you brain cells learning anything else than SQL and the DB-API. Now my own experience is that whenever I tried this approach for anything non-trivial, I ended up building an "ad-hoc, informally-specified bug-ridden slow implementation of half of " SQLAlchemy. Which BTW is not strictly an ORM, but primarily an attempt at a better integration of SQL into Python. So while it may feel like learning the inner complexities of SQLALchemy (or Django's ORM which is not that bad either) is "wasting brain cells", MVHO is that it's worth the time spent. But YMMV of course - IOW, do what works best for you. From __peter__ at web.de Fri Apr 25 03:21:53 2008 From: __peter__ at web.de (Peter Otten) Date: Fri, 25 Apr 2008 09:21:53 +0200 Subject: Little novice program written in Python References: Message-ID: Rog?rio Brito wrote: > i = 2 > while i <= n: > ? ? ?if a[i] != 0: > ????????print a[i] > ? ? ?i += 1 You can spell this as a for-loop: for p in a: if p: print p It isn't exactly equivalent, but gives the same output as we know that a[0] and a[1] are also 0. Peter From fetchinson at googlemail.com Mon Apr 14 21:11:44 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Mon, 14 Apr 2008 18:11:44 -0700 Subject: Interesting timing issue I noticed In-Reply-To: References: Message-ID: > The project I'm working on is motion detection, involving a bit of image > processing. No worries: no image processing background needed. > > Suffice to say that I initially wrote a script that goes through every pixel > of a 320x240 picture (turned into an array using PIL) and performs some > calculatiosn. It simply goes through every pixel in the array and performs a > simple subtraction with a known value. The idea is to try to find > differences between the two images. > > After a while, to try to speed up the calculations, I realized that I didn't > need to do all 320x240 calculations. So I implemented a slightly more > sophisticated algorithm and localized my calculations. I still do the pixel > subtractions, but I do it on a smaller scale. > > Surprisingly, when I used time.time() to time the procedures, I find that > doing all 320x240 calculations are often faster! On my machine, the former > gives me on average an execution time of around 0.125s (and consistently), > whereas the latter on average takes 0.160s. > > Why does this happen? It's hard to tell without looking at a stripped down, minimal version of your code that still shows the above behaviour. Most probably you are not computationally bound and the majority of the execution time is spent on memory read/write. For example it might happen that the version of your code that has less number of FLOPS accesses the memory more often. HTH, Daniel From kyosohma at gmail.com Wed Apr 16 09:24:18 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 16 Apr 2008 06:24:18 -0700 (PDT) Subject: Learning Tkinter References: Message-ID: <4f5750ef-987e-451e-93da-3e315190c0b2@8g2000hse.googlegroups.com> On Apr 16, 7:46 am, "Doran, Harold" wrote: > I am currently reading An Intro to Tkinter (1999) by F. Lundh. This doc > was published in 1999 and I wonder if there is a more recent version. > I've googled a bit and this version is the one I keep finding. I like > how this document is organized and also how it provides the code with > visuals of what should appear on the screen. If there are other docs I > should read, please let me know. There's some good Tkinter coverage in Lutz's tome, "Programming Python 3rd Ed." and it also shows how to do a search for a file across your file system, iirc. > > Second, I am trying to work through a couple of the examples and make > some small tweaks as I go to see how new things can work. In the first > case, I have copied the code in the book to see how the menu works and > are created as in the example menu.py below. I see how menus are created > and how the command option is used to call the function callback. > > # menu.py > from Tkinter import * > > def callback(): > print "called the callback!" > > root = Tk() > > # create a menu > menu = Menu(root) > root.config(menu=menu) > > filemenu = Menu(menu) > menu.add_cascade(label="File", menu=filemenu) > filemenu.add_command(label="New", command=harold) > filemenu.add_command(label="Open...", command=callback) > filemenu.add_separator() > filemenu.add_command(label="Exit", command=callback) > > helpmenu = Menu(menu) > menu.add_cascade(label="Help", menu=helpmenu) > helpmenu.add_command(label="About...", command=callback) > > mainloop() > > However, I now want to incorporate a basic python program with a > command. Say I have a simple program called test.py > > # test.py > filename = raw_input("Please enter the file you want to open: ") > new_file = raw_input("Save the output file as: ") > > f = open(new_file, 'w') > new = open(filename, 'r') > > for line in new: > x = line.split('\t') > print >> f, x[0],':', x[1] > f.close() > > To make this example complete assume I have a text file like this > > # data.txt > 1 one > 2 two > 3 three > 4 four > > So, the user currently just follows directions on the screen, enters the > file names, and I get what I want. I'd like to try experimenting with > gui programming to see if the python programs I have written can be made > even more user friendly. I currently use py2exe to create executables so > that others in my organization can use these programs. > > In that spirit, say I want to have a menu option that allows the user to > search their computer for this file, execute the python code and then > save the result as a user-defined filename. So, I guess my questions are > how do I associate the portion of code in menu.py > "filemenu.add_command(label="Open...", command=callback)" with an > operation that gives the user the ability to search the drives on their > machine and then once they do let python execute the code in test.py? > > Many thanks, It sounds like you want to run code from within your own program. This would require embedding a Python interpreter, which is quite possible, although I do not know how to do it. I would suggest that you just use a Tkinter-created frame/window that allows the user to enter the information into text controls rather than a command line type interface. You could even use a "Browse" button and let the user search for the file using a file dialog. Check out the sample code for such a beast in the recipe linked below: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/438123 If you do want to go the embedding route, you'll want to read the following information linked below: http://docs.python.org/api/embedding.html http://www.python.org/doc/ext/embedding.html http://www.ragestorm.net/tutorial?id=21 http://www.codeproject.com/KB/cpp/embedpython_1.aspx Hope that gets you going. Mike From paul.anton.letnes at gmail.com Mon Apr 14 08:46:27 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Mon, 14 Apr 2008 14:46:27 +0200 Subject: Process multiple files In-Reply-To: <2323A6D37908A847A7C32F1E3662C80E017BDF37@dc1ex01.air.org> References: <2323A6D37908A847A7C32F1E3662C80E017BDF37@dc1ex01.air.org> Message-ID: Funny, I'm just doing exactly this: import os def main(): dataFolder = 'data/' fileList = os.listdir(dataFolder) for file in fileList: inFile = open(dataFolder + file, 'r') print 'read inFile & do something useful here' Clear as an... egg? Cheers. Paul. Den 14. april. 2008 kl. 14.36 skrev Doran, Harold: > Say I have multiple text files in a single directory, for illustration > they are called "spam.txt" and "eggs.txt". All of these text files are > organized in exactly the same way. I have written a program that > parses > each file one at a time. In other words, I need to run my program each > time I want to process one of these files. > > However, because I have hundreds of these files I would like to be > able > to process them all in one fell swoop. The current program is > something > like this: > > sample.py > new_file = open('filename.txt', 'w') > params = open('eggs.txt', 'r') > do all the python stuff here > new_file.close() > > If these files followed a naming convention such as 1.txt and 2.txt I > can easily see how these could be parsed consecutively in a loop. > However, they are not and so is it possible to modify this code such > that I can tell python to parse all .txt files in a certain directory > and then to save them as separate files? For instance, using the > example > above, python would parse both spam.txt and eggs.txt and then save 2 > different files, say as spam_parsed.txt and eggs_parsed.txt. > > Thanks > > > > > > > -- > http://mail.python.org/mailman/listinfo/python-list From nagle at animats.com Fri Apr 18 15:26:13 2008 From: nagle at animats.com (John Nagle) Date: Fri, 18 Apr 2008 12:26:13 -0700 Subject: Python 2.5 adoption In-Reply-To: References: Message-ID: <4808f30e$0$34489$742ec2ed@news.sonic.net> Joseph Turian wrote: > How widely adopted is python 2.5? > > We are doing some development, and have a choice to make: > a) Use all the 2.5 features we want. > b) Maintain backwards compatability with 2.4. > > So I guess the question is, does anyone have a sense of what percent > of python users don't have 2.5? Desktop or server? If server, check what the major Linux distros, like Fedora Core, are shipping with. Check major shared hosting providers to see what they're offering to their customers as standard. John Nagle From tinnews at isbd.co.uk Thu Apr 3 08:15:13 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 03 Apr 2008 12:15:13 GMT Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> Message-ID: <47f4ca51$0$713$bed64819@news.gradwell.net> Jeff wrote: > def foo(sample, strings): > for s in strings: > if sample in s: > return True > return False > > This was an order of magnitude faster for me than using str.find or > str.index. That was finding rare words in the entire word-list (w/ > duplicates) of War and Peace. However it's the wrong way around, in my case 'sample' is the longer string and I want to know if s is in it. It's simple enough to do it the other way around though:- def foo(sample, strings): for s in strings: if s in sample: return True return False Using in rather than find() and making it a function would seem to be the way to go, thanks. -- Chris Green From kay.schluehr at gmx.net Sat Apr 19 10:51:48 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 19 Apr 2008 07:51:48 -0700 (PDT) Subject: Metaprogramming Example References: <930643c6-2d56-4fb0-aee0-a3e79231f09b@24g2000hsh.googlegroups.com> <32472b97-f35a-4408-96f5-2f8c8f92ae56@m73g2000hsh.googlegroups.com> Message-ID: On 17 Apr., 14:25, andrew cooke wrote: > PS Is there anywhere that explains why Decorators (in the context of > functions/methods) are so good? We had kind of an inverse discussion a while ago when someone asked about the fate of aspect oriented programming (AOP) in Python. My answer was that technically "aspect weaving" using code generators is dead in application programming [1] and decorators are handy, lightweight, local and controllable while serving very similar purposes. [1] There are occasions where source code weaving might still has its place. Profiling for example or code coverage. Just examine this interesting blog article: http://nedbatchelder.com/blog/200804/wicked_hack_python_bytecode_tracing.html and the subsequent discussion. From bob at passcal.nmt.edu Sat Apr 19 17:53:01 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Sat, 19 Apr 2008 15:53:01 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041816413450073-bob@passcalnmtedu> <2008041915500575249-bob@passcalnmtedu> Message-ID: <2008041915530150073-bob@passcalnmtedu> > > > www.greschke.com/unlinked/files/pocus.png > > > Darnit. www.greschke.com/unlinked/images/pocus.png From gagsl-py2 at yahoo.com.ar Thu Apr 24 02:05:01 2008 From: gagsl-py2 at yahoo.com.ar (gagsl-py2 at yahoo.com.ar) Date: Thu, 24 Apr 2008 03:05:01 -0300 (ART) Subject: What happened with python? messed strings? In-Reply-To: <200804202006.m3KK64ix028653@sdf-eu.org> Message-ID: <114452.7491.qm@web32808.mail.mud.yahoo.com> (top posting fixed; please keep discussion on this list) --- algaba at droog.sdf-eu.org escribi?: > In article > > you wrote: > > En Sun, 20 Apr 2008 15:54:20 -0300, > escribi?: > > > > I used extensively python and now I find this > mess with strings, > > > I can't even reproduce tutorial examples: > > >>>> "apfel".encode('utf-8') (it was with umlaut) > > > File "", line 0 > > > ^ > > > SyntaxError: 'ascii' codec can't decode byte > 0xc4 in position 1: > > > ordinal not in range(128) > > >>>> > > > Is there any good guide to this mess of codecs > and hell ? [two links to unicode introductory articles] > ok, > and how do you explain that even the tutorial > example is broken ??? Which tutorial example? -- Gabriel Genellina Los referentes m?s importantes en compra/ venta de autos se juntaron: Demotores y Yahoo! Ahora comprar o vender tu auto es m?s f?cil. Vist? ar.autos.yahoo.com/ From bronger at physik.rwth-aachen.de Wed Apr 30 07:12:05 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 30 Apr 2008 13:12:05 +0200 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> Message-ID: <87tzhjy4u2.fsf@physik.rwth-aachen.de> Hall?chen! Duncan Booth writes: > Torsten Bronger wrote: > >> The biggest ugliness though is ",".join(). No idea why this should >> be better than join(list, separator=" "). Besides, ",".join(u"x") >> yields an unicode object. This is confusing (but will probably go >> away with Python 3). > > It is only ugly because you aren't used to seeing method calls on > string literals. I am used to it. Programming very much with unicode, I use .encode and .decode very often and I like them. I consider en/decoding to be an intrinsic feature of strings, but not ord(), which is an "external", rather administrative operation on strings (and actually not even this, but on characters) for my taste. However, join() is really bizarre. The list rather than the separator should be the leading actor. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From andrew at acooke.org Mon Apr 14 21:43:39 2008 From: andrew at acooke.org (andrew cooke) Date: Mon, 14 Apr 2008 18:43:39 -0700 (PDT) Subject: Dynamic use of property() fails Message-ID: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> Hi, This is my first attempt at new classes and dynamic python, so I am probably doing something very stupid... After reading the how-to for descriptors at http://users.rcn.com/python/download/Descriptor.htm I decided I would make an object that returns attributes on read, but on setting calls an arbitrary function. My code looks like: class ActiveDAO(object): def __init__(self): self.__values__ = {} def add_field(self, name, value, on_change): self.__values__[name] = value def get(self): return self.__values__[name] def set(self, new_value): self.__values__[name] = on_change(new_value) def delete(self): raise AttributeError self.__dict__[name] = property(get, set, delete) However, when I try to use this (in a test) with code like: dao = ActiveDAO() dao.add_field("name", "value", lambda _: None) assertEqual(dao.name, "value") I get a failure because lookup of the attribute is returning "". That is quite reasonable, but I was under the expression that some magic was supposed to happen, as described in the document referenced above! Please can someone explain why there is no magic? :o( Thanks, Andrew PS I am using Python 2.5 on Linux From sales024 at aaa-replica-watch.com Tue Apr 1 00:45:10 2008 From: sales024 at aaa-replica-watch.com (sales024 at aaa-replica-watch.com) Date: Mon, 31 Mar 2008 21:45:10 -0700 (PDT) Subject: Cheap Seiko Dress Watches Replica - Seiko Watches Wholesale Message-ID: <807f68e4-f420-49f8-a10d-5f3ca904ad38@c26g2000prf.googlegroups.com> Cheap Seiko Dress Watches Replica - Seiko Watches Wholesale AAA Replica Watches : http://www.watches-replicas.com Seiko Watches Brands : http://www.watches-replicas.com/seiko-watches.html Replica Seiko Dress Watches : http://www.watches-replicas.com/seiko-dress-watches.html China largest replica watches wholesaler, wholesale up to 80% of Seiko Dress Replica Watches and Seiko Dress Fake Watch. The most famous Swiss brand name watches you can find, replica Seiko Dress Watches and fake Seiko Dress Watches are also available. All our Seiko Dress Watches replicas are crafted in high quality, You will get great profite by ordering our good cheap watches. Seiko Dress Watches All Products : Seiko Dress Mens Watch SGF526 : http://www.watches-replicas.com/Seiko-Dress-Mens-Watch-SGF526-6222.html Seiko Dress Mother-of-Pearl Two-Tone Steel Ladies Watch SUJB30 : http://www.watches-replicas.com/Seiko-SUJB30-6223.html Seiko Dress Mother-of-Pearl Two-Tone Steel Ladies Watch SUJB26 : http://www.watches-replicas.com/Seiko-SUJB26-6224.html Seiko Dress Pink Mother-of-Pearl Steel Ladies Watch SUJB29 : http://www.watches-replicas.com/Seiko-SUJB29-6225.html Seiko Dress Ladies Watch SUJE85 : http://www.watches-replicas.com/Seiko-Dress-Ladies-Watch-SUJE85-6226.html Seiko Dress Chronograph Titanium Mens Watch SND641 : http://www.watches-replicas.com/seiko-chrono-mens-watch-snd641-6227.html Seiko Dress Steel White Mens Watch SNF665 : http://www.watches-replicas.com/Seiko-Dress-Mens-Watch-SNF665-6228.html Seiko Dress Mens Watch SFLW86 : http://www.watches-replicas.com/Seiko-Dress-Mens-Watch-SFLW86-6229.html Seiko Dress Gold-Tone Stainless Steel Ladies Watch SUJD54 : http://www.watches-replicas.com/seiko-gold-tone-ladies-watch-SUJD54-6230.html Seiko Dress Two-Tone Stainless Steel Ladies Watch SXGM04 : http://www.watches-replicas.com/seiko-dress-two-tone-watch-SXGM04-6231.html Seiko Dress Two-Tone Stainless Steel Ladies Watch SWZ144 : http://www.watches-replicas.com/seiko-dress-two-tone-steel-watch-SWZ144-6232.html Seiko Dress Two-Tone Stainless Steel Mens Watch SGFA05 : http://www.watches-replicas.com/seiko-dress-two-tone-mens-watch-SGFA05-6233.html Seiko Dress Stainless Steel Mens Watch SKP323 : http://www.watches-replicas.com/seiko-dress-stainless-steel-watch-SKP323-6234.html Seiko Dress Stainless Steel Mens Watch SGFA09 : http://www.watches-replicas.com/seiko-dress-stainless-steel-watch-SGFA09-6235.html Seiko Dress Gold-Tone Stainless Steel Mens Watch SKP330 : http://www.watches-replicas.com/seiko-dress-gold-tone-stainless-SKP330-6236.html Seiko Dress Gold-Tone Stainless Steel Mens Watch SKP294 : http://www.watches-replicas.com/seiko-dress-gold-tone-mens-watch-SKP294-6237.html Seiko Day/Date Dress Gold Tone Ladies Watch SWZ058 : http://www.watches-replicas.com/seiko-ladies-watch-swz058-6238.html Seiko Day/Date Dress Ladies Watch SWZ054 : http://www.watches-replicas.com/seiko-ladies-watch-swz054-6239.html Seiko Dress Gold-Tone Ladies Watch SWZ154 : http://www.watches-replicas.com/seiko-leather-ladies-watch-swz156-6240.html Seiko Dress Two-Tone Stainless Steel Mens Watch SKP017 : http://www.watches-replicas.com/seiko-mens-watch-skp017-6241.html Seiko Day/Date Dress Gold-Tone Stainless Steel Mens Watch SGF212 : http://www.watches-replicas.com/seiko-mens-watch-sgf212-6242.html Seiko Day/Date Dress Gold-Tone Stainless Steel Mens Watch SGF206 : http://www.watches-replicas.com/seiko-mens-watch-sgf206-6243.html Seiko Day/Date Dress Two-Tone Stainless Steel Mens Watch SGF204 : http://www.watches-replicas.com/seiko-mens-watch-sgf204-6244.html Seiko Dress Chronograph Titanium Mens Watch SND641 : http://www.watches-replicas.com/seiko-chrono-mens-watch-snd671-6245.html Seiko Gold Tone Stainless Steel Ladies Dress Watch SUJ706 : http://www.watches-replicas.com/seiko-gold-tone-stainless-ladies-suj706-6246.html Seiko Gold Tone Stainless Steel Day/Date Men's Watch SGFA10 : http://www.watches-replicas.com/seiko-day-and-date-mens-watch-sgfa10-6247.html Seiko Two-tone Steel Ladies Watch SUJE89 : http://www.watches-replicas.com/seiko-ladies-watch-two-tone-suje89-6248.html Seiko Steel Pink Ladies Watch SUJE87 : http://www.watches-replicas.com/seiko-ladies-watch-suje87-6249.html Seiko Gold Tone Ladies Watch SXE372 : http://www.watches-replicas.com/Seiko-SXE372-6250.html Seiko Dress Gold-Tone Steel Ladies Watch SUJB32 : http://www.watches-replicas.com/seiko-watch-SUJB32-6251.html Seiko Dress Gold-Tone Steel White Ladies Watch SXJZ44 : http://www.watches-replicas.com/seiko-watch-SXJZ44-6252.html Seiko Dress Two-Tone Steel Blue Ladies Watch SUJ511 : http://www.watches-replicas.com/seiko-watch-SUJ511-6253.html Seiko Dress Steel Blue Leather Ladies Watch SNA467 : http://www.watches-replicas.com/seiko-watch-SNA467-6254.html Seiko Dress Two-Tone Steel White Ladies Watch SXJS67 : http://www.watches-replicas.com/seiko-watch-SXJS67-6255.html Seiko Dress Two-Tone Steel Blue Mens Watch SNA284 : http://www.watches-replicas.com/seiko-watch-SNA284-6256.html Seiko Dress Mother-of-Pearl Two-Tone Steel Ladies Watch SUJ710 : http://www.watches-replicas.com/seiko-watch-SUJ710-6257.html Seiko Dress Two-Tone Steel White Ladies Watch SXJZ48 : http://www.watches-replicas.com/seiko-watch-SXJZ48-6258.html Seiko Dress TiCN-Plated Steel Blue Mens Watch SGEA03 : http://www.watches-replicas.com/seiko-watch-SGEA03-6259.html Seiko Dress Mother-of-Pearl Gold-Tone Steel Ladies Watch SUJ712 : http://www.watches-replicas.com/seiko-watch-SUJ712-6260.html Seiko Diamond Gold-Tone Steel Champagne Ladies Watch SUJE72 : http://www.watches-replicas.com/seiko-watch-SUJE72-6261.html Seiko Diamond Two-Tone Steel Black Ladies Watch SUJE71 : http://www.watches-replicas.com/seiko-watch-SUJE71-6262.html Seiko Diamond Pink Mother-of-Pearl Steel Ladies Watch SUJE67 : http://www.watches-replicas.com/seiko-watch-SUJE67-6263.html Seiko Diamond Mother-of-Pearl Two-Tone Steel Ladies Watch SUJE69 : http://www.watches-replicas.com/seiko-watch-SUJE69-6264.html Seiko Diamond Gold-Tone Steel Black Ladies Watch SUJE70 : http://www.watches-replicas.com/seiko-watch-SUJE70-6265.html Seiko Dress Two-Tone Steel Black Mens Watch SKP308 : http://www.watches-replicas.com/Seiko-Two-Tone-Steel-Mens-Watch-SKP308-6266.html Seiko Dress Two-Tone Grey Steel Ladies Watch SUJE76 : http://www.watches-replicas.com/Seiko-Two-Tone-Black-Mens-Watch-SUJE76-6267.html Seiko Dress Two-Tone Steel Black Ladies Watch SUJE74 : http://www.watches-replicas.com/Seiko-Two-Tone-Steel-Ladies-Watch-SUJE74-6268.html Seiko Dress Two-Tone Dark Grey Steel Black Mens Watch SKP310 : http://www.watches-replicas.com/Seiko-Two-Tone-Steel-Mens-Watch-SKP310-6269.html Seiko Dress Gold-Tone Steel Bronze Satin Ladies Watch SUJD80 : http://www.watches-replicas.com/Seiko-Dress-Womens-Watch-SUJD80-6270.html Seiko Dress Gold-Tone Steel Bronze Satin Ladies Watch SXH056 : http://www.watches-replicas.com/Seiko-Dress-Womens-Watch-SXH056-6271.html Seiko Dress Steel Blue Mens Watch SNF661 : http://www.watches-replicas.com/Seiko-Dress-Mens-Watch-SNF661-6272.html Seiko Dress Steel Black Strap Ladies Watch SUJD79 : http://www.watches-replicas.com/Seiko-Dress-Womens-Watch-SUJD79-6273.html Seiko Dress Gold-Tone Steel Burgundy Leather Ladies Watch SXD788 : http://www.watches-replicas.com/Seiko-Dress-Womens-Watch-SXD788-6274.html Seiko Dress Steel Burgundy Leather Mens Watch SPA003 : http://www.watches-replicas.com/Seiko-Dress-Date-men-Watch-SPA003-6275.html Seiko Dress Steel Black Leather Mens Watch SPA001 : http://www.watches-replicas.com/Seiko-Dress-Date-Mens-Watch-SPA001-6276.html Seiko Dress Gold-Tone Steel Brown Leather Mens Watch SPA004 : http://www.watches-replicas.com/Seiko-Dress-Date-Mens-Watch-SPA004-6277.html Seiko Dress Gold-Tone Steel White Ladies Watch SXB388 : http://www.watches-replicas.com/Seiko-Dress-Womens-Watch-SXB388-6278.html Seiko Dress Steel Black Ladies Watch SXH055 : http://www.watches-replicas.com/Seiko-Dress-Womens-Watch-SXH055-6279.html Seiko Skinny White Leather Double Buckle Ladies Watch SXH049 : http://www.watches-replicas.com/Seiko-womens-watch-SXH049-6280.html Seiko Dress Gold-Tone Steel Brown Leather Mens Watch SKP304 : http://www.watches-replicas.com/Seiko-Dress-Mens-Watch-SKP304-6281.html Seiko Dress Steel Black Mens Watch SKK629 : http://www.watches-replicas.com/Seiko-Dress-Mens-Watch-SKK629-6282.html Seiko Dress Steel White Dial Ladies Watch SFQ841 : http://www.watches-replicas.com/Seiko-Dress-Womens-Watch-SFQ841-6283.html Seiko Dress Gold-tone Steel Ladies Watch SUJD92 : http://www.watches-replicas.com/Seiko-womens-watch-SUJD92-6284.html Seiko Dress Gold-tone Steel Ladies Watch SUJD84 : http://www.watches-replicas.com/Seiko-womens-watch-SUJD84-6285.html Seiko Dress Gold-Tone Steel Brown Leather Mens Watch SNT006 : http://www.watches-replicas.com/Seiko-Mens-Watch-SNT006-6286.html Seiko Titanium Two Tone Dress Ladies Watch SUJA80 : http://www.watches-replicas.com/seiko-titanium-two-tone-ladies-SUJA80-6287.html Seiko Gold Tone Stainless Steel Men's Watch SGEC70 : http://www.watches-replicas.com/seiko-gold-tone-stainless-steel-SGEC70-6288.html Seiko Gold Tone Casual Ladies Watch SXGM06 : http://www.watches-replicas.com/seiko-gold-tone-casual-ladies-SXGM06-6289.html Seiko Dress Ladies Watch SUJ703 : http://www.watches-replicas.com/seiko-dress-ladies-watch-SUJ703-6290.html Seiko Alarm Chronograph Men's Watch SNA551 : http://www.watches-replicas.com/seiko-alarm-chronograph-men-watch-SNA551-6291.html Seiko Dress Steel Black Mens Watch SNF667 : http://www.watches-replicas.com/Seiko-Dress-Mens-Watch-SNF667-6292.html Seiko Dress Gold-Tone Steel Champagne Dial Mens Watch SNF664 : http://www.watches-replicas.com/Seiko-Dress-men-Watch-SNA664-6293.html Seiko Dress Two-Tone Steel White Mens Watch SNA662 : http://www.watches-replicas.com/Seiko-Dress-men-Watch-SNA662-6294.html Seiko Dress Steel White Mens Watch SNA659 : http://www.watches-replicas.com/Seiko-Dress-Mens-Watch-SNA659-6295.html Seiko Casual Stainless Steel Mens Watch SGFA02 : http://www.watches-replicas.com/seiko-mens-watch-sgfa02-6296.html Seiko Gold-Tone Men's Watch SFWL86 : http://www.watches-replicas.com/seiko-mens-gold-watch-sfwl86-6297.html Seiko Gold Elegant Dress Seiko Ladies Watch SFQ838 : http://www.watches-replicas.com/Seiko-Dress-Watch-SFQ838-6298.html Seiko Dress Steel White Mens Watch SNF657 : http://www.watches-replicas.com/Seiko-SNF657-6299.html Seiko Dress Steel Black Mens Watch SKP297 : http://www.watches-replicas.com/Seiko-Classic-Dress-Watch-SKP297-6300.html Seiko Dress Steel Black Leather Mens Watch SKK633 : http://www.watches-replicas.com/Seiko-Classic-Dress-Watch-SKK633-6301.html Seiko Dress Steel White Mens Watch SKK627 : http://www.watches-replicas.com/Seiko-Classic-Dress-Watch-SKK627-6302.html Seiko Dress Steel White Mens Watch SKP295 : http://www.watches-replicas.com/Seiko-Classic-Dress-Watch-SKP295-6303.html Seiko Dress Two-Tone Steel White Dial Mens Watch SKP299 : http://www.watches-replicas.com/Seiko-Classic-Dress-Watch-SKP299-6304.html Seiko Dress Steel Black Mens Watch SGEC85 : http://www.watches-replicas.com/Seiko-Classic-Dress-Watch-SGEC85-6305.html Seiko Dress Steel Black Mens Watch SGEC95 : http://www.watches-replicas.com/Seiko-Classic-Dress-Watch-SGEC95-6306.html Seiko Dress Steel Blue Ladies Watch SYL793 : http://www.watches-replicas.com/Seiko-SYL793-6307.html Seiko Dress Two-Tone Steel Ladies Watch SUJB34 : http://www.watches-replicas.com/Seiko-SUJB34-6308.html Seiko Dress Two-Tone Steel Mens Watch SGG130 : http://www.watches-replicas.com/Seiko-SGG130-6309.html Seiko Dress Steel Pink Ladies Watch SUJE17 : http://www.watches-replicas.com/Seiko-SUJE17-6310.html Seiko Dress Steel Black Ladies Watch SUJD53 : http://www.watches-replicas.com/Seiko-SUJD53-6311.html Seiko Dress Steel Black Ladies Watch SUJD39 : http://www.watches-replicas.com/Seiko-SUJD39-6312.html Seiko Dress Two-Tone Steel Bangle White Ladies Watch SUJ704 : http://www.watches-replicas.com/Seiko-SUJ704-6313.html Seiko Dress Steel Mens Watch SKP293 : http://www.watches-replicas.com/Seiko-SKP293-6314.html The Same Seiko Replica Watches Series : Seiko Chronograph Watches : http://www.watches-replicas.com/seiko-chronograph-watches.html Seiko Dress Watches : http://www.watches-replicas.com/seiko-dress-watches.html Seiko Kinetic Watches : http://www.watches-replicas.com/seiko-kinetic-watches.html Seiko Coutura Watches : http://www.watches-replicas.com/seiko-coutura-watches.html Seiko Diamond Watches : http://www.watches-replicas.com/seiko-diamond-watches.html Seiko Le Grand Sport Watches : http://www.watches-replicas.com/seiko-le-grand-sport-watches.html Seiko Perpetual Calendar Watches : http://www.watches-replicas.com/seiko-perpetual-calendar-watches.html Seiko Sportura Watches : http://www.watches-replicas.com/seiko-sportura-watches.html Seiko Diver Watches : http://www.watches-replicas.com/seiko-diver-watches.html Seiko El Dorado Watches : http://www.watches-replicas.com/seiko-el-dorado-watches.html Seiko Retrograde Watches : http://www.watches-replicas.com/seiko-retrograde-watches.html Seiko Casual Watches : http://www.watches-replicas.com/seiko-casual-watches.html Hard to Find Seiko Watches : http://www.watches-replicas.com/hard-to-find-seiko-watches.html Seiko Clocks : http://www.watches-replicas.com/seiko-clocks.html From gagsl-py2 at yahoo.com.ar Wed Apr 16 02:02:04 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 03:02:04 -0300 Subject: import hooks References: <664bf2b80804151814g480eed02w739047f84d9deb6b@mail.gmail.com> Message-ID: En Tue, 15 Apr 2008 22:14:18 -0300, Patrick Stinson escribi?: > What's the current way to install an import hook? I've got an embedded > app > that has a few scripts that I want to import each other, but that are > not in > sys.modules. I intentionally keep them out of sys.modules because their > names will not be unique across the app. They will, however, be unique > between scripts that I (do* want to see each other). > Basically, I want to return a certain module from a name-based filter. > I've > already written a type in C with find_module and load_module, but it > doesn't > seem to work when I add the type to sys.path_hooks. I wrote a simple one > that worked just fine from a pure script file run through python.exe. From that description alone I can't say what's happening; you should post some code. Also, if your importer isn't disk-based, perhaps using sys.meta_path is better. -- Gabriel Genellina From sierra9162 at gmail.com Wed Apr 16 11:27:17 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:27:17 -0700 (PDT) Subject: kate hudson parents Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From bj_666 at gmx.net Sat Apr 5 03:18:12 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 5 Apr 2008 07:18:12 GMT Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> Message-ID: <65ondkF2g48puU2@mid.uni-berlin.de> On Fri, 04 Apr 2008 20:26:13 -0700, 7stud wrote: > However, there is another way to cause a function to execute when an > event, like a button click, occurs on a widget: you use the widget's > bind() function: > > my_button.bind('', someFunc) That's a bad idea because now the `Button` doesn't act like a typical button anymore. This "fires" *always* and as soon as you press the mouse button on it. Compare this with the usual and from end users point of view expected behavior that pressing down the mouse button "presses" the button widget visually but doesn't cause any action until you release the button while still over it. This for instance makes it possible to change your mind and move the mouse cursor out of the buttons area with a pressed mouse button and prevent the action of that button. The preferred way to bind actions to `Button`\s is the `command` argument. The function is called with no arguments when the button is pressed, so it has to know all data it needs to fulfill its task. Usually this is done with anonymous functions and bound default values for short pieces of "variable" data:: def __init__(self): # ... button = Button(self, text='1', command=lambda n=1: self.display(n)) # ... def display(self, number): print number Ciao, Marc 'BlackJack' Rintsch From james at reggieband.com Sun Apr 13 16:05:54 2008 From: james at reggieband.com (james at reggieband.com) Date: Sun, 13 Apr 2008 13:05:54 -0700 (PDT) Subject: Module to read input from commandline References: <2e04b64c-9a12-4e20-8d5a-546a0ec4ac7f@m36g2000hse.googlegroups.com> Message-ID: On Apr 13, 7:44 pm, thashoo... at farifluset.mailexpire.com wrote: > What you're looking for is no module, it is included in the standard > python namespace. > > raw_input > > Use it like this: > > value_a = raw_input("Please give a value for a: ") > # do your thing to value_a > > But this belongs to the real basics, I suggest you get some reading > done on python. > > GL Thanks for the response GL. What I am looking for is a module to wrap raw_input so it can handle some of the validation. e.g.) response = display_prompt( question, valid_responses, default_response ) or similar. valid_responses could be a tuple of regexp strings that would compare against a raw_input and return one in the list. Ideally I could customize the error message (for responses not in valid_response), etc. I know it isn't rocket science to write it and I have something already in place. I'd rather use a module built for the purpose now that I have several scripts that will use the functionality. Thanks! James. FYI: This is what I have so far: from re import compile def yes_no(question, default=None): """Prompt the user with a yes or no question.""" if default == "y": question = "".join((question, " [Y/n]: ")) elif default == "n": question = "".join((question, " [y/N]: ")) else: question = "".join((question, " [y/n]: ")) valid_answer = "[yn]" invalid_message = "Answer must be y or n" answer = prompt(question, valid_answer, invalid_message, default) return answer == 'y' def prompt(question, valid_answer, invalid_message, default=None): """Prompt the user with a question and validate their response.""" is_valid = False; compiled_valid_answers = compile(valid_answer) while not is_valid: answer = raw_input(question).lower() if answer == "" and default is not None: answer = default is_valid = compiled_valid_answers.match(answer) if not is_valid: print invalid_message return answer From fetchinson at googlemail.com Tue Apr 1 22:16:10 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Tue, 1 Apr 2008 19:16:10 -0700 Subject: ANN: cubictemp template engine In-Reply-To: <20080402012420.GA21586@nullcube.com> References: <20080402012420.GA21586@nullcube.com> Message-ID: > We are happy to announce release 2.0 of Cubictemp, a small, elegant > templating system for Python. > > > Features > ======== > > * Simple, well-tested and well-documented. > * Integrates tightly with Python - pass arbitrary Python objects into a > template, walk sequences and iterators, evaluate expressions. > * Default escaping helps to prevent common classes of Cross-Site > Scripting > vulnerabilities. > * Encourages separation of interface and program logic by disallowing > statements in templates. > * Tiny - only ~ 170 SLOC. There are many large, over-designed > Python templating systems out there. Cubictemp proves that a > templating > sytem can be elegant, powerful, fast and remain compact. > > > Download: http://dev.nullcube.com > > Manual: http://dev.nullcube.com/doc/cubictemp/index.html Does it support the Buffet API? Do you have any benchmarks to compare it with other template systems (in terms of speed)? Cheers, Daniel From toolmaster at 163.com Thu Apr 3 10:33:33 2008 From: toolmaster at 163.com (WaterWalk) Date: Thu, 3 Apr 2008 07:33:33 -0700 (PDT) Subject: unicode in exception traceback References: Message-ID: <5b988a00-d9d4-4aaa-bcd3-41d9af482bad@r9g2000prd.googlegroups.com> On Apr 3, 5:56 pm, Peter Otten <__pete... at web.de> wrote: > WaterWalk wrote: > > Hello. I just found on Windows when an exception is raised and > > traceback info is printed on STDERR, all the characters printed are > > just plain ASCII. Take the unicode character u'\u4e00' for example. If > > I write: > > > print u'\u4e00' > > > If the system locale is "PRC China", then this statement will print > > this character as a single Chinese character. > > > But if i write: assert u'\u4e00' == 1 > > > An AssertionError will be raised and traceback info will be put to > > STDERR, while this time, u'\u4e00' will simply be printed just as > > u'\u4e00', several ASCII characters instead of one single Chinese > > character. I use the coding directive commen(# -*- coding: utf-8 -*-)t > > on the first line of Python source file and also save it in utf-8 > > format, but the problem remains. > > > What's worse, if i directly write Chinese characters in a unicode > > string, when the traceback info is printed, they'll appear in a non- > > readable way, that is, they show themselves as something else. It's > > like printing something DBCS characters when the locale is incorrect. > > > I think this problem isn't unique. When using some other East-Asia > > characters, the same problem may recur. > > > Is there any workaround to it? > > Pass a byte string but make some effort to use the right encoding: > > >>> assert False, u"\u4e00".encode(sys.stdout.encoding or "ascii", "xmlcharrefreplace") > > Traceback (most recent call last): > File "", line 1, in > AssertionError: ? > > You might be able to do this in the except hook: > > $ cat unicode_exception_message.py > import sys > > def eh(etype, exc, tb, original_excepthook=sys.excepthook): > message = exc.args[0] > if isinstance(message, unicode): > exc.args = (message.encode(sys.stderr.encoding or "ascii", "xmlcharrefreplace"),) + exc.args[1:] > return original_excepthook(etype, exc, tb) > > sys.excepthook = eh > > assert False, u"\u4e00" > > $ python unicode_exception_message.py > Traceback (most recent call last): > File "unicode_exception_message.py", line 11, in > assert False, u"\u4e00" > AssertionError: ? > > If python cannot figure out the encoding this falls back to ascii with > xml charrefs: > > $ python unicode_exception_message.py 2>tmp.txt > $ cat tmp.txt > Traceback (most recent call last): > File "unicode_exception_message.py", line 11, in > assert False, u"\u4e00" > AssertionError: 一 > > Note that I've not done any tests; e.g. if there are exceptions with > immutable .args the except hook itself will fail. > > Peter Thanks. My brief test indicates that it works. I'll try it in more situations. From lucafbb at gmail.com Fri Apr 25 14:03:18 2008 From: lucafbb at gmail.com (Luca) Date: Fri, 25 Apr 2008 20:03:18 +0200 Subject: Newbie question about import Message-ID: <27308d500804251103t71d04b5fg1de6658ceab9d898@mail.gmail.com> Hi all. I'm trying to do something with python import but isn't working for me. Using python 2,5 I've a program structured like this: * a main module called (for example) "mommy" with an __init__.py and a file called "mommy.py" * a __version__ var defined inside the main __init__.py >From the mommy.py file I need to import the __version__ var, but I'm really not able to do this! I fear this is a very stupid task to do... my problem is that the file is called like the module. Anyone can point me to the solution? -- -- luca From dolloffdelvpg at gmail.com Wed Apr 16 08:09:01 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:09:01 -0700 (PDT) Subject: taylor swift age Message-ID: <3619c573-e170-41df-bacb-278e0b8f3b4c@r9g2000prd.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From pallavi.kale at bioanalytical.net Fri Apr 4 06:39:02 2008 From: pallavi.kale at bioanalytical.net (Pallavi Kale) Date: Fri, 4 Apr 2008 16:09:02 +0530 Subject: Python, Mysql, insert NULL Message-ID: <20080404103313.4F86267DD3@smtp10.netcore.co.in> Hello there, I was going through the thread of conversation happening around inserting null using python into mysql. I am facing a similar problem here. I have to insert say 8 values into a table using a stored procedure. Of the 8 values 2 are not null and the remaining can be null, most of the values have datatypes as int or float. When I try to pass null to these using python I keep getting None error from the sql server. I am using pymssql to talk to the database which is another reason the parameters that I pass have to be type defined that is say @solutionID = %d I, where @SolutionID is an integer type. Have anyone found a way to pass null into sql using python when the variable is other than string, please let me know I am just learning python so I am sure there must be a simpler and neater way to do it.. Thanks :-) Best regards, Pallavi Kale -------------- next part -------------- An HTML attachment was scrubbed... URL: From roger.dahlstrom at gmail.com Fri Apr 11 15:10:54 2008 From: roger.dahlstrom at gmail.com (rdahlstrom) Date: Fri, 11 Apr 2008 12:10:54 -0700 (PDT) Subject: Windows - window status (Running vs Not Responding) References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> Message-ID: On Apr 11, 1:45 pm, rdahlstrom wrote: > Does anyone know how to determine the window status (Running or Not > Responding)? I've tried various methods with no success... > > This would be on a variety of Windows systems, but all at least XP, > and mostly server 2003. Everyone will have Python 2.5.1 on them, and > the script would be running locally. > > Any ideas? Basically, I'm looking for something similar to the Process.Responding property in System.Diagnostics... From mensanator at aol.com Thu Apr 24 18:03:46 2008 From: mensanator at aol.com (Mensanator) Date: Thu, 24 Apr 2008 15:03:46 -0700 (PDT) Subject: DO YOU KNOW ANY THING ABOUT ISLAM??? References: <2429a87a-34e8-4294-9a25-b54dd2cf6791@m73g2000hsh.googlegroups.com> Message-ID: <153b6178-8ff9-43e6-a614-56db85186067@a70g2000hsh.googlegroups.com> You mean something besides wiping my ass with a rock? From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Mon Apr 28 16:02:22 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Mon, 28 Apr 2008 22:02:22 +0200 Subject: Simple unicode-safe version of str(exception)? References: Message-ID: <67moqeF2paokjU1@mid.individual.net> Russell E. Owen wrote: > I have code like this: > except Exception, e: > self.setState(self.Failed, str(e)) > which fails if the exception contains a unicode argument. Fails how? > I did, of course, try unicode(e) but that fails. Converting unicode to unicode doesn't help. Instead of just e, try using e.encode("some-encoding") where some-encoding should be your system's default encoding like utf-8 or iso8859-1. Regards, Bj?rn -- BOFH excuse #434: Please state the nature of the technical emergency From cokofreedom at gmail.com Fri Apr 4 07:58:19 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Fri, 4 Apr 2008 04:58:19 -0700 (PDT) Subject: Looking for Advanced Python Tutorials Message-ID: I was wondering if anyone knew of some online (free if possible) advanced tutorials, especially ones that provides tasks and ideas for small projects. The issue for myself is I want to improve my python programming level, and my ability to program in general, but come up blank thinking of a possible task or project to undertake. So with that in mind I thought I'd ask the community if they knew of sites or books to read up on and use as a starting block. Of course project ideas would be great as well! Thanks for any help you can provide. Coko From steve at holdenweb.com Mon Apr 21 22:10:22 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 21 Apr 2008 22:10:22 -0400 Subject: Lists: why is this behavior different for index and slice assignments? In-Reply-To: <480d435b$0$11643$607ed4bc@cv.net> References: <480d435b$0$11643$607ed4bc@cv.net> Message-ID: John Salerno wrote: > Hey all. I've decided I let my Python skills (minor though they were) > slip away so I started reading the new edition of Learning Python to > brush up. I just read about lists again and I'm wondering if someone > could explain what's going on under the hood that makes index and slice > assignments behave differently when assigning an empty list. > > For example: > > >>> L = [1, 2, 3, 4, 5] > >>> L[0:2] = [] > >>> L > [3, 4, 5] > > >>> L = [1, 2, 3, 4, 5] > >>> L[0] = [] > >>> L > [[], 2, 3, 4, 5] > > So the question is, when you assign an empty list to an index, why does > it insert an empty list, but when you assign an empty list to a slice, > it simply deletes the slice? > Assignment to a list *element* rebinds the single element to the assigned value. Assignment to a list *slice* has to be of a list, and it replaces the elements in the slice by assigned elements. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 18 11:39:34 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 18 Apr 2008 17:39:34 +0200 Subject: str class inheritance prob? In-Reply-To: <874eed0f-eeeb-4434-8a14-a3b29801a5f6@d26g2000prg.googlegroups.com> References: <874eed0f-eeeb-4434-8a14-a3b29801a5f6@d26g2000prg.googlegroups.com> Message-ID: <4808c09c$0$19986$426a74cc@news.free.fr> jkazoo at gmail.com a ?crit : > so I?m trying to create a class that inherits from str, but I want to > run some code on the value on object init. this is what I have: Others already gave you the technical solution (use __new__, not __init__). A couple remarks still: 1/ > > class Path(str): > def __init__( self, path ): > clean = str(path).replace('\\','/') > while clean.find('//') != -1: > clean = clean.replace('//','/') > > print 'cleaned on init:\t',clean > self = clean Assigning to self - or to any other local name - only impact the local namespace, it won't affect the object previously bound to that name. 2/ you may be interested in the existing path module: http://www.jorendorff.com/articles/python/path/ HTH From lists at cheimes.de Fri Apr 25 17:45:59 2008 From: lists at cheimes.de (Christian Heimes) Date: Fri, 25 Apr 2008 23:45:59 +0200 Subject: Why is None <= 0 In-Reply-To: <481228DF.5010408@ulmcnett.com> References: <481228DF.5010408@ulmcnett.com> Message-ID: <48125117.9060907@cheimes.de> > In my humble opinion, I think that comparisons involving None should > return None, but I trust that the designers came up with this for very > good reasons. As far as I know I've never been bitten by it. It's fixed in Python 3.x. Python 3.x refuses to compare objects unless one of both objects has explicit support for both types: >>> 1 < None Traceback (most recent call last): File "", line 1, in TypeError: unorderable types: int() < NoneType() From aldo at nullcube.com Sun Apr 6 20:12:52 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Mon, 7 Apr 2008 10:12:52 +1000 Subject: ANN: pry unit testing framework In-Reply-To: References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> Message-ID: <20080407001252.GA12883@nullcube.com> Thus spake Matthieu Brucher (matthieu.brucher at gmail.com): > One last question : does it take doctests into account ? I'm afraid that Pry is unashamedly incompatible with any other unit testing method in existence, including but not limited to doctest, unittest, nose and py.test. ;) Some day I might experiment with extending Pry to gather and run doctests and unittests. At this stage, however, I don't believe the (significant) effort would be worth it. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From deets at nospam.web.de Wed Apr 9 10:16:14 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 09 Apr 2008 16:16:14 +0200 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> Message-ID: <6641eaF2ics8jU1@mid.uni-berlin.de> subhabrata.iisc at hotmail.com wrote: > I thought if you know then only you can help. I am waiting for a > knowledgeable answer from a knowledgeable person. I think I can show a ALL the answers you got here so far indicate that you did NOT give enough details to actually answer the question. Moreover, you claim to observe phenomena that simply are ridiculously and obviously wrong - a1=1 a2=2 a3=a1+a2 will yield 3 under ALL circumstances. Instead, you posted random snippets of non-working code that show the worst in coding style claiming they don't work, without telling us WHAT is not working. And then you reply telling us about the greatness of Bangalore and your product to come. Which is somewhat amusing that people who claim to produce the greatest software being incapable of debugging it deems me as odd - to say the least. Because they should be more experienced. I suggest you read this: http://catb.org/~esr/faqs/smart-questions.html At least two times. And then come back and post self-contained examples of whatever behavior you observe, and this community will be as helpful as it is. But we can't read sense in anything you posted so far, despite the best efforts. So unless that changes, you won't be helped here. Diez From victorsubervi at gmail.com Thu Apr 3 08:43:57 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 3 Apr 2008 07:43:57 -0500 Subject: Strange MySQL Problem... In-Reply-To: <47f46a3e$0$36371$742ec2ed@news.sonic.net> References: <4dc0cfea0804021236n1faafabav1699fbe45acc3c01@mail.gmail.com> <47f46a3e$0$36371$742ec2ed@news.sonic.net> Message-ID: <4dc0cfea0804030543t1ad5a3abs539fa6598061c454@mail.gmail.com> Comments in line... On Thu, Apr 3, 2008 at 12:35 AM, John Nagle wrote: > Steve Holden wrote: > > Define "no longer works". > Sorry. Throws HTTP 200 error. On Thu, Apr 3, 2008 at 12:35 AM, John Nagle wrote: > John Nagle wrote: > > "works fine"? Please check again... > > The same remarks I've posted earlier apply here. > Must have missed those. Yes, the code works fine. Repeatedly. > > > In addition, you're not committing the database update. > You need to do > > connection.commit() Oh, thanks :) > > > after updating. > > In general, server side programs should have a try-block > wrapped around most of the program, with some code to display or > log errors in some useful way. Curious. Why? During testing, I understand, but after testing, why? On Thu, Apr 3, 2008 at 12:35 AM, John Nagle wrote: > Gabriel Genellina wrote: > > > print 'Content-Type: image/jpeg\r\n' > > print '\nHi!\n' > > Don't you see a conflict among those two lines? > (You're a liar: first you promise to send a nice picture and then you only > send a letter!) > LOL! Okay, make me honest ;) I want to post both text and images. What use? > > > > cursor.execute("CREATE TABLE justatest (name TEXT, ablob BLOB)") > > Note that you *always* attempt to create a table. > Yeah, I am dropping it, too. This was just some code I found online and tweaked. > > > > sql = "INSERT INTO justatest VALUES (%s, %s)" > > cursor.execute(sql, ('ramis', _mysql.escape_string(f)) ) > > You're using bound parameters now, a good thing. There is no need to > escape strings passed as parameters - in fact, it is wrong, as the adapter > will escape the text again. > In this case, the column is a BLOB, and you have to use the Binary > function: MySQLdb.Binary(f) > Nope. Threw me another HTTP 200. > > Now, if I take out this part, which I can?t see does anything at all in > > the > > code, it no longer works: > > I don't think "it no longer works" because you removed anything, but > because this script can only be run at most once. Probably you're getting > an error in the CREATE TABLE statement. > Wrong. I check the mysql and drop the table if the code throws me an HTTP 200 error. I have run this code many times now. That is what makes the whole thing so ridiculously strange to me. That code snippet, that the script insists on, is a relic from the code I tweaked. It was there to make a binary, that is all. So why do I still need the darn thing?? > > You have to look at the server error logs, else you're blind fighting. > I am blind fighting. No longer run my own server, no longer have root access. > See > other suggestions in my previous post. > Sorry. Can you repost it? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From bskaplan14 at yahoo.com Thu Apr 24 15:24:43 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Thu, 24 Apr 2008 12:24:43 -0700 (PDT) Subject: NameError: global name 'Response' is not defined Message-ID: <709609.88093.qm@web39206.mail.mud.yahoo.com> Are you importing pylons? How are you doing it? If you are doing "from pylons import Response" or "from pylons import *", then you have another problem. If you are just doing "import pylons", then you need to do "return pylons.Response(...)" ----- Original Message ---- From: Lalit To: python-list at python.org Sent: Thursday, April 24, 2008 10:27:36 AM Subject: NameError: global name 'Response' is not defined Hi I am very new to web development. I started with Pylons. I am using http://www.rexx.com/~dkuhlman/pylons_quick_site.html as reference to create a sample web page using pylons. I got stuck up at step 4.3 i.e when modifying controller to "return Response('

firstapp default

')" I am getting error of : global name 'Response' is not defined It seems I am missing some package. I am not really sure. I installed python 2.5 and through easy_install imported pakages (pylons). Any clues would be appreciated Thanks Lalit -- http://mail.python.org/mailman/listinfo/python-list ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From zhushao888 at yahoo.com.cn Mon Apr 14 06:08:11 2008 From: zhushao888 at yahoo.com.cn (008) Date: Mon, 14 Apr 2008 03:08:11 -0700 (PDT) Subject: Wholesale all electronics merchandises.........Our trademark contain nokia... the all laptops...the Apple Iphone....the Apple IPOD........the Sony Ericsson.... LG....HTC.... the Sony Playstation 3..Wii...the Microsoft xbox 360....the Sony PSP.. the Itouch(4 GB/8 GB/16 GB/32 GB) Ipod 3 rd generation Ipod Nano II.......the TomTom GPS.....the Garmin Nuvi GPS.... the Robot Dog....the Robot Dinosaur......http://www.sonyecvv.com......msn: pthongda@hotmail.com Message-ID: <8ef31eea-5abb-43fa-a5a8-13f409467d95@l28g2000prd.googlegroups.com> hi We are the most professional with the biggest wholesale electronics merchandise supply merchandise ..........We have a lot of very nice quality merchandises with the very special price our brands all sony...all LG....all NOKIA...all ipod....all GPS ..,are also available for sale at cheaper rate. They are all brand new with full accessories and 1 year international warranty, unlocked, work effectively with any network worldwide and come with user manual guide in various languages. Ipod nano 1G 45$ ,2G 55$, 4G 65$,8G 70$, 30G 100$ ,60G 120$ ps3 60GB 330$ 20GB 180$ 80GB 450$ psp 150$ wii 200$ We have all models of nokia NOKIA N95 $250 NOKIA N93 $190 NOKIA N92 $160 NOKIA N91 $170 NOKIA N90 $180 Nokia N70 $165 NOKIA N73 $180 NOKIA 7600 (UNLOCK) $150 Nokia 8800 Sirocco Gold Edtion -$250 Nokia 8800 Sirocco Black$250 We wholesale all laptops Sony VGN-CR13/B 380$ Sony VGN-CR13/L 350$ Sony VGN-CR15/B 320$ Sony VGN-CR13/P 480$ Sony VGN-C21CH 450$ Sony VGN-SZ44CN 580$ Sony VGN-C22CH/W 620$ Sony VGN-N17C 480$ Sony VGN-CR13/W 580$ Sony VGN-FZ15 560$ Apple MacBook 580$ Apple MacBook Pro(MA896CH/A)680$ Apple MacBook Pro(MA896CH/A) 630$ Apple MacBook (MB063CH/A) 580$ Apple MacBook Pro(MA895CH/A) 580$ Apple MacBook(MB062CH/A) 590$ Apple MacBook(MA700CH/A) 580$ Apple MacBook(MA701CH/A) 550$ Apple MacBook Pro ?MA610CH/A? 650$ Apple MacBook Pro (MA611CH/A) 680$ Apple MacBook (MA699CH/A) 580$ (1).all products are all original and new (2).they have 1year international warranty. (3).free shipping include ems, tnt, dhl, ups. you may choose one kind (4).deliver time is in 5days to get your door We insist the principia: Prestige first,high-quality,competitive price, best services,and timely delivery. Website: http://www.sonyecvv.com msn: pthongda at hotmail.com Fa-Fa Co., Ltd. From ivan.illarionov at gmail.com Sun Apr 13 12:35:41 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Sun, 13 Apr 2008 09:35:41 -0700 (PDT) Subject: Interesting math problem References: <3a34caaf-a279-4e86-837d-42efa4d80129@d4g2000prg.googlegroups.com> Message-ID: <3fe449cb-4060-4bb6-9605-1e1778b707f8@p39g2000prm.googlegroups.com> On Mar 19, 2:17 pm, "BJ?rn Lindqvist" wrote: > On Mon, Mar 17, 2008 at 11:57 PM, Arnaud Delobelle > > > > wrote: > > > def make_slope(distance, parts): > > > step = distance / float(parts) > > > intstep = int(step) > > > floatstep = step - intstep > > > > steps = [] > > > acc = 0.0 > > > for i in range(parts): > > > acc += floatstep > > > step = intstep > > > if acc > 0.999: > > > step += 1 > > > acc -= 1.0 > > > steps.append(step) > > > return steps > > > OK then, using list comprehensions. It is more succint, is it easier > > to read? > > > def slope(dist, parts): > > return [(i+1)*dist/parts - i*dist/parts for i in xrange(parts)] > > Congratulations! You Won! Jeff Schwab's recursive approach is also > cool but this is the most interesting abuse of integer division I have > seen. I don't think any of the variants are readable at a first > glance, but with a comment it should be ok. > > -- > mvh Bj?rn I really want to revive this discussion. Arnaud's approach is definetly cool, but it turns out that in real-world situations it doesn't work as succint as here. Try to use it to draw a simple non-anitaliased line in a standrad python array or buffer object. Suppose we have an array of unsigned bytes called `buf` where each line takes `pitch` bytes. That's what I got while trying to take advantage of this approach. No advantage at all. And what about ability to port the code to C for speed? def draw_line(buf, pitch, x, y, dx, dy): if dx == dy == 0: buf[y * pitch + x] = 0 return xdir, ydir = 1, 1 if dx < 0: xdir = -1 dx = abs(dx) if dy < 0: ydir = -1 dy = abs(dy) if dy < dx: steps = ((i+1) * dx / dy - i * dx / dy for i in xrange(dy)) for step in steps: start = y * pitch + x if xdir > 0: buf[start : start + step] = array('B', [0] * step) else: buf[start - step : start] = array('B', [0] * step) x += step * xdir y += ydir else: steps = ((i+1) * dy / dx - i * dy / dx for i in xrange(dx)) for step in steps: start = y * pitch + x if ydir > 0: for i in range(start, start + pitch * step, pitch): buf[i] = 0 else: for i in range(start, start - pitch * step, -pitch): buf[i] = 0 x += xdir y += step * ydir Please, tell me that I'm wrong and it's really possible to draw lines, do scan-conversion and so on with such a cool succint constructs! -- Ivan From mal at egenix.com Tue Apr 29 17:30:25 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Tue, 29 Apr 2008 23:30:25 +0200 Subject: Need Python alternative to Request-Tracker help desk software In-Reply-To: <0A53725C4A497848A7B3A0874B259831011B08E8@acesxch01.ADVENTISTCORP.NET> References: <0A53725C4A497848A7B3A0874B259831011B08E8@acesxch01.ADVENTISTCORP.NET> Message-ID: <48179371.5010508@egenix.com> On 2008-04-29 22:15, Sells, Fred wrote: > I've been tasked with either implementing Request-Tracker to upgrade our help desk issue tracking system or finding a Python equivalent (both in terms of functionality and wide spread use). Request-Tracker uses Apache and MySQL, which would also be appropriate to Python. > > I would prefer to go the Python route, especially since Request-Tracker is written in Perl (which I don't know). > > My initial attempts with Google were not useful due to the general nature of the keywords. > > Are there any suggestions. You should have a look at Trac (http://trac.edgewall.org/) and roundup (http://roundup.sourceforge.net/). Both are written in Python and provide excellent issue tracking. They differ a bit in design and approach to issue tracking, so you will likely need to investigate a bit further before you decide. Both are easy to extend and adapt to whatever needs you have. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 29 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From sjmachin at lexicon.net Mon Apr 21 18:39:00 2008 From: sjmachin at lexicon.net (John Machin) Date: Mon, 21 Apr 2008 22:39:00 GMT Subject: dynamically importing a module and function In-Reply-To: References: Message-ID: <480d1782$1@news.mel.dft.com.au> rkmr.em at gmail.com wrote: > Hi > I have a function data['function'], that I need to import from a file > data['module'], in the directory data['cwd'] OT: Any good reason for using a dictionary instead of a class instance (data.functiom, data.module, etc)? > > If I do this from python interactive shell (linux fedora core 8) from > dir /home/mark it works fine: > > cwd = data['cwd'] > os.chdir(cwd) > print os.getcwd() > module = __import__(data['module']) > function = getattr(module, data['function']) > This is possibly due to python using what was the current working directory when it started up. An alternative (untested): saved = sys.path sys.path = data['cwd'] module = __import__(data['module']) sys.path = saved Exception handling is left as an exercise for the reader. HTH, John From victorsubervi at gmail.com Tue Apr 1 08:36:00 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Tue, 1 Apr 2008 07:36:00 -0500 Subject: Adding Images to MySQL Message-ID: <4dc0cfea0804010536q71bce9ev38cff43923f5a4b8@mail.gmail.com> Hi; I?m trying to figure out how to upload images into a MySQL database. (Yes, that is what I want to do.) I have a form that asks for data, like this: 1ra Foto Peque?a: Then I send that form to a python script that processes like this: cursor.execute('insert into products (' + col_names + ') values (' + col_values + ');') where col_names is all the names of the columns and col_values, obviously, the values. Works fine for strings and digits. Not so well for files :) What do? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 18 04:48:14 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 18 Apr 2008 10:48:14 +0200 Subject: Metaprogramming Example In-Reply-To: <562bae18-7b8e-4863-8923-0e5a01ba7125@t54g2000hsg.googlegroups.com> References: <930643c6-2d56-4fb0-aee0-a3e79231f09b@24g2000hsh.googlegroups.com> <32472b97-f35a-4408-96f5-2f8c8f92ae56@m73g2000hsh.googlegroups.com> <39325652-e0cf-4efd-9b28-00c0fe8552cc@m73g2000hsh.googlegroups.com> <562bae18-7b8e-4863-8923-0e5a01ba7125@t54g2000hsg.googlegroups.com> Message-ID: <48086036$0$759$426a74cc@news.free.fr> andrew cooke a ?crit : > bruno: >> Ho, and yes : one day, you'll get why it's such a good thing to unite >> functions and methods !-) > > me: >> PS Is there anywhere that explains why Decorators (in the context of >> functions/methods) are so good? I've read lots of things saying they >> are good, but no real justification of why. > > in the text above i wrote "Decorators" rather than "Descriptors". it > was in response to bruno's comment, also above. sorry for the > confusion. Ho, you meant Descriptors ? Well, a first point is that the support for methods is built on a combination of two "general purpose" constructs - callable objects and the descriptor protocol - instead of being a special-case construct by itself. IOW, this is build *with* Python itself, instead of being built *into* Python. Practically, this means that (amongst other niceties) : - you can define functions outside classes and use them as instance or class methods - you can add/replaces methods dynamically on a per-class or per-instance basis - you can access the function object of a method and use it as a function - you can define your own callable types, that - if you implement the appropriate support for the descriptor protocol - will be usable as methods too > also, sorry for the inflammatory language Which one ??? > by referring to the titanic > i didn't mean that python was a disaster, rather that the "iceberg" is > still there (i am not 100% sure what the iceberg is, but it's > something > to do with making namespaces explicit in some places and not others). I guess you're thinking of the self argument, declared in the function's signature but not "explicitly passed" when calling the method ? If so, the fact is you *do* pass it explicitly - by calling the function *as a method of an objet*. Given the following definitions: def func(obj, data): print "obj : %s - data : %s" % (obj, data) class Foo(object): meth = func f = Foo() What the difference between: func(f, 42) and f.meth(42) In both cases, f is directly and explicitly involved as one of the "targets" of the call. My 2 cents... From jstroud at mbi.ucla.edu Wed Apr 23 22:08:49 2008 From: jstroud at mbi.ucla.edu (James Stroud) Date: Wed, 23 Apr 2008 19:08:49 -0700 Subject: logging doc problem Message-ID: Am I missing something or are the docs for logging hopelessly outdated? http://docs.python.org/lib/node406.html For example, quoting the docs """ import logging logging.debug('A debug message') logging.info('Some information') logging.warning('A shot across the bows') """ And the result is % /usr/bin/python Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. py> import logging py> py> logging.debug('A debug message') Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'debug' More importantly, do any good docs for logging exist, or is it touch and go? James From uniontelecardsindia at gmail.com Tue Apr 22 17:16:18 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:16:18 -0700 (PDT) Subject: Asian gay hunks extreme deep cock sucking Message-ID: <9957653d-6533-4bf3-b33f-a3673c2cc05d@a70g2000hsh.googlegroups.com> Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From spellucci at fb04373.mathematik.tu-darmstadt.de Fri Apr 4 10:58:15 2008 From: spellucci at fb04373.mathematik.tu-darmstadt.de (Peter Spellucci) Date: Fri, 4 Apr 2008 16:58:15 +0200 (CEST) Subject: Nonlinear least square problem References: <0354420e-819d-4ba3-b61a-faaffd46b65c@r9g2000prd.googlegroups.com> Message-ID: In article <0354420e-819d-4ba3-b61a-faaffd46b65c at r9g2000prd.googlegroups.com>, Uwe Kotyczka writes: >Hallo, sorry for multiposting, but I am really looking >for some hint to solve my problem. And no, I don't >use Matlab, but maybe the matlab people have an idea >nevertheless. > >I have to solve a nonlinear least square problem. >Let me tell you some background first. Imagine >you have a tool to process some work piece, say >polishing some piece of glas. The tool behaves >different on different locations of the piece, >and I can describe that behaviour. Now the tool >shall smooth the surface of the workpiece. >Next I have information about the piece before >handling it. What I have to find is optimal >time curve for the tool to obtain a perfectly >smooth surface. > >How to formulate the problem? >Given a time vector (t_j) I have a function >g which calculates the remaining error (e_i) >(e_i) = g(t_j) >The rest error is given at, say, 100 points, >(t_j) is searched at 200 points. >My idea was to make the (t_j) a function of >some few parameters (t_j) = h(p_k), say 15 >parameters. So the concatenated function >(e_i) = g(t_j) = g(h(p_k)) =: f(p_k) is to be minimized. >in the sense (e_i)-c -> Min, where c is a constant, >the end level of the surface. > >To solve this problem I use a "C" implementation >of the Levenberg-Marquardt algorithm as you can find >it in the LevMar Package (www.ics.forth.gr/~lourakis/levmar/). > >The function g contains the information about the >tool and about the initial surface. For the function >h I tried several approaches, making the time a >cubic spline of a selected times, or making it some >polynmial or... > >Now what is my problem? With the above I do find >solutions, however a lot of solutions seem to >give very similar remaining errors. The only problem >is that the corresponding time vectors, which are >(t_j_optimal) = h(p_k_optimal) look very different >from optimal solution to optimal solution. >In particular the optimization algorithm often prefers >solutions where the time vector is heavily oscillating. > >Now this is something I _must_ suppress, but I have no >idea how. The oscillation of the (t_j) depend of >the ansatz of h, of the number of parameters (p_k). >If f would be a linear function, then the matrix >representing it would be a band matrix with a lot >of diagonals nonzero. How many depends on the >ratio tool diameter to piece diameter. > >Now what are my question: Is the problem properly >formulated? Can I expect to find non-oscillating >solutions? Is it normal that taking more parameters >(p_k) makes the thing worse? What else should I >consider? Is this more verbal description sufficient? > >Thank you very much in advance. > > > > wouldn't be the normal way to describe this problem be an optimal control problem? and there will be constraints? let us take the example of the polishing problem: your tool must move over the surface and will actually operate over a (small)disk: you must design a path of the disc center such that the working area of the tool covers the whole surface. If you assume location dependent roughness, then it might be impossible directly to polish one location perfectly, such that the path must be taken several times. maybe due to heating during the polishing process, it may be necessary to introduce gaps in the path in order to avoid overheating of some area. this may take time and/or energy and you might want to solve a minimal time or minimal energy problem subject to your constraints. if you are lucky, you end up with a convex problem wwhich will exhibit a unique solution. otherwise you might be trapped in a local optimum. such a path could be modeled by a spline curve for example, and as far as I know there are already industrial solvers for types of this problem. hth peter From gagsl-py2 at yahoo.com.ar Wed Apr 16 11:23:56 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 08:23:56 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <0A685715-6D44-4D41-87C2-4B971A751E78@gmail.com> Message-ID: On 15 abr, 13:58, Michael Torrie wrote: > > After parsing this thread through a noise filter, it appears the main > concern is not the converting of _python code_ from 2 to 3, but rather > converting extensions written in C, or when python is embedded in a C > program. ?The APIs have necessarily changed, and this *will* inflict a > certain amount of pain and suffering on the developer, especially if he > needs to maintain code for both python 2 and python 3. ?However this is > just the way it is. ?It's a bit like complaining that I have to rewrite > my app with win32 calls and paradigms when I was used to win16. ?No > conversion will be completely pain free, but this jump is pretty > insignificant compared to others in the industry. Yes, at the C level you have to either live with a lot of #ifdefs, or maintain two branches. I prefer the second choice (with the help of a good SCM tool) but that's a matter of taste or convenience. -- Gabriel Genellina From mnordhoff at mattnordhoff.com Tue Apr 8 03:27:26 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Tue, 08 Apr 2008 07:27:26 +0000 Subject: Destructor? In-Reply-To: <47FB1937.5050008@mydeskfriend.com> References: <47FB1937.5050008@mydeskfriend.com> Message-ID: <47FB1E5E.6010708@mattnordhoff.com> Gabriel Rossetti wrote: > Hello everyone, > > we are writing an application that needs some cleanup to be done if the > application is quit, normally (normal termination) or by a signal like > SIGINT or SIGTERM. I know that the __del__ method exists, but unless I'm > mistaken there is no guarantee as of when it will be called, and some > objects may have already been released (at lease I've had trouble in the > past accessing certain objects from inside __del__, probably since the > parent class's __del__ has to be called first, then it's objects are > already released by the time I need to do something with them). Another > method would be to implement something using the signal module and have > a callback that does all the cleanup when the app. is > quit/terminated/interrupted and have all the child classes override that > with their cleanup code. > > What is the community's point of view on the subject? > > Thanks, > Gabriel atexit? If it's only small things, there's try...finally, of course.. -- From fredrik at pythonware.com Fri Apr 4 12:34:59 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 04 Apr 2008 18:34:59 +0200 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> Message-ID: llothar wrote: > On windows everything is '.pyd' but there seems to be two ways to get > this on unix? If you attempt to import the module "spam" on Windows, Python looks for "spam.dll" and "spam.pyd" (in addition to "spam.py/spam.pyw/spam.pyc" etc) On most Unix platforms, Python looks for "spam.so" and "spammodule.so". You can check what suffixes a given Python version uses via the "imp" module: >>> import imp >>> imp.get_suffixes() To see *where* Python is looking as well, use the "-vv" flag: $ python -vv -c "import spam" ... # trying spam.so # trying spammodule.so # trying spam.py # trying spam.pyc ... etc (-vv prints loads of stuff, so you may want to use "grep" to filter out the stuff you're interested in: $ python -vv -c "import spam" 2>&1 | grep spam or, under Windows: > python -vv -c "import spam" 2> out.txt > findstr spam out.txt ) > Why and what is the rule? If you want Python to be able to import your binary extension, make sure to use a name it looks for. From marco at sferacarta.com Thu Apr 3 10:25:07 2008 From: marco at sferacarta.com (Marco Mariani) Date: Thu, 03 Apr 2008 16:25:07 +0200 Subject: object-relational mappers In-Reply-To: <47f4e456$0$20141$426a74cc@news.free.fr> References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> <89bca327-6a3f-4128-be72-75d4a50b9bf0@13g2000hsb.googlegroups.com> <47f4e456$0$20141$426a74cc@news.free.fr> Message-ID: <7N5Jj.10079$T35.8116@tornado.fastwebnet.it> Bruno Desthuilliers wrote: >> A simple select query would be db.select('customers') or >> db.select('customers', name='John'). >> But you can also resort to plain sql as follows: db.query('select * >> from customers where name = "John"'). >> >> Simple, effective and doesn't get in your way. > > Seems nice too in another way. And no different than using SQLAlchemy's sa.select() or engine.execute(), after all. > Is that part independant of the rest of the framework ? If so, I'll have to give it a try at least for admin > scripts. My admin scripts go through SQLAlchemy as well, I just have some issues with postgres' COPY statement -- but I don't know if the DBAPI is supposed to handle that. From bbxx789_05ss at yahoo.com Sat Apr 5 15:55:26 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sat, 5 Apr 2008 12:55:26 -0700 (PDT) Subject: Tkinter, add pressed buttons onto string display string, how to? References: Message-ID: skanem... at yahoo.se wrote: > using tkinter and python i now have a small App (that will hopefully > soon be a fully functioning calculator) where u can push buttons and > the corresponding number or operator is shown. > > when u press 1, "1" appears on the screen, pres + and "+" appears etc. > > at the moment every output overwrites the previous so what i want to > do is obviosuly to add every new output to a string so that i can read > the string and perform the calculation. > > so i want: > * when pushing the button push the token of the button onto a string > * display the new string, ie "1+2" for example > * want to be able to access this string when pressing calculate so i > can figure out which operators should > be done first so it can solve something like this: "(1+2*3)(3-4/2)" > and not just simple "1+2"-stuff. > > do i have to have some global string-variable in the GUIframework > then? im not sure where to start... > input = "hello" input += " world" print input --output:-- hello A caculator program is pretty complex. Based on your rudimentary questions, I don't think you have enough programming experience to tackle a project like that yet. From marek.rocki at wp.pl Mon Apr 28 12:45:39 2008 From: marek.rocki at wp.pl (marek.rocki at wp.pl) Date: Mon, 28 Apr 2008 09:45:39 -0700 (PDT) Subject: Given a string - execute a function by the same name References: Message-ID: <376ee8c4-8cb4-45c2-83bc-5556f88c783f@m3g2000hsc.googlegroups.com> One solution may be to use globals(): >>> globals()['foo']() Regards, Marek From george.sakkis at gmail.com Sun Apr 20 12:08:27 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Sun, 20 Apr 2008 09:08:27 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: On Apr 20, 11:35?am, Eric Wertman wrote: > I was considering putting together a proposal for an alternate block > syntax for python, and I figured I'd post it here and see what the > general reactions are. ?I did some searching, and while I found a lot > of tab vs space debates, I didn't see anything like what I'm thinking > of, so forgive me if this is a very dead horse. [with apologies to Monty Python] This horse is no more! He has ceased to be! 'E's expired and gone to meet 'is maker! 'E's a stiff! Bereft of life, 'e rests in peace! THIS IS AN EX-HORSE!! :) > Generally speaking, I like the current block scheme just fine. ?I use > python on a daily basis for system administration and text parsing > tasks, and it works great for me. > > From time to time, though, I find myself needing a language for server- > side includes in web pages. ?Because of the need to indent (and > terminate indents), python seems an awkward choice for this, and it's > easy for me to see why php and perl are more popular choices for this > kind of task. ?Perhaps this is just my perception though. Look into any of the dozen Python-based template engines that are typically used for such tasks; they offer many more features than a way to indent blocks. George From ilanschnell at gmail.com Sat Apr 19 14:47:31 2008 From: ilanschnell at gmail.com (ilanschnell at gmail.com) Date: Sat, 19 Apr 2008 11:47:31 -0700 (PDT) Subject: Issue with inspect module References: <2e5e2d31-2adc-4416-a993-19bc05a512bd@w8g2000prd.googlegroups.com> Message-ID: On Apr 19, 1:41 pm, Karl-Heinz Ruskowski wrote: > > Why does the inspect module cause the output > > to be printed twice? > > I also tested it, no problem here either. I realized what the problem was. I called the file inspect.py, stupid me. Thanks From gagsl-py2 at yahoo.com.ar Sun Apr 20 00:58:58 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 01:58:58 -0300 Subject: User-defined Exceptions: is self.args OK? References: Message-ID: En Thu, 17 Apr 2008 19:11:36 -0300, Petr Jake? escribi?: > I am trying to dig through User-defined Exceptions. chapter 8.5 in > http://docs.python.org/tut/node10.html > > > I would like to know, if is it OK to add following line to the __init__ > method of the TransitionError class? > > self.args = (self.previous, self.next, self.message) Not necesarily, but you should call the base __init__, perhaps with a suitable message. Most of the time, a meaningful error message is all what I want, so I write: class FooError(Exception): pass (perhaps inheriting from ValueError or TypeError or any other more meaningful base error). Then, when something wrong is detected: if ....: raise FooError, "some %s message" % foo In your case, you appear to require more info stored in the exception. Try this (based on your code): class TransitionError(Error): # I assume Error inherits from Exception? def __init__(self, previous, next, message): self.previous = previous self.next = next Error.__init__(self, previous, next, message) # perhaps: Error.__init__(self, message) # if message already contain references to # previous and next raise TransitionError, (1, 2, "oops") Traceback (most recent call last): File "", line 1, in __main__.TransitionError: (1, 2, 'oops') -- Gabriel Genellina From the.blue.valkyrie at gmail.com Wed Apr 23 10:26:08 2008 From: the.blue.valkyrie at gmail.com (=?ISO-8859-1?Q?Cristina_Yenyxe_Gonz=E1lez_Garc=EDa?=) Date: Wed, 23 Apr 2008 16:26:08 +0200 Subject: Python Success stories In-Reply-To: References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: 2008/4/23, Reedick, Andrew : > > IIRC, Python is used in games like Eve Online (SciFi MMO) and Vampire: > Bloodlines (RPG.) Years later, a dedicated fan is still fixing/updating > the Bloodlines python scripts that control the dialogue and scripted > events. > Now that you mention it, Python was also used in the Star Wars: Knights of the Old Republic (KotOR) saga. You can even search the scripts across the disc and take a look at hilarious code comments like "this works but I don't know why" :D From python at bdurham.com Tue Apr 29 11:35:30 2008 From: python at bdurham.com (python at bdurham.com) Date: Tue, 29 Apr 2008 11:35:30 -0400 Subject: Given a string - execute a function by the same name In-Reply-To: <27f6ba19-8756-4d96-851f-2a7c585ef3c7@m44g2000hsc.googlegroups.com> References: <27f6ba19-8756-4d96-851f-2a7c585ef3c7@m44g2000hsc.googlegroups.com> Message-ID: <1209483330.17070.1250499293@webmail.messagingengine.com> Arnaud, Just when I thought my solution couldn't get any better :) Thanks for that great tip and for an excellent demonstration of using a decorator. Regards, Malcolm You could avoid #5 from the start using a decorator: functions = {} def register(func): functions[func.__name__] = func return func @register def foo(): print "Foo!" @register def bar(): print "Bar!" >>> functions {'foo': , 'bar': } >>> functions['bar']() Bar! From ch612bunn at gmail.com Sun Apr 27 09:13:23 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:13:23 -0700 (PDT) Subject: nero 8 crack Message-ID: nero 8 crack http://wga-cracks.crackkey.net From gagsl-py2 at yahoo.com.ar Sat Apr 5 20:30:06 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 05 Apr 2008 21:30:06 -0300 Subject: Recursively Backup Directories References: Message-ID: En Sat, 05 Apr 2008 20:56:31 -0300, escribi?: > I am writing a script that will backup specified folders from one hard > drive to another (for example, backup source "C:\DATA", destination "D: > \Backup"), and was thinking of using shutil. What I would like to do > is recursively backup the specified directories (which copytree will > do), but be able to specify exclusion directories (which copytree does > not appear to allow you to do). My initial thoughts were I'll > probably have to use os.path.walk for the backup source directory, but > I'm not sure how to go from there. Thanks in advance. I'd use os.walk (not os.path.walk) and shutil.copy2; use os.makedirs to create the target directory (only when it doesn't already exist). If you remove directories from the dirnames list, they're not recursed into. -- Gabriel Genellina From victorsubervi at gmail.com Fri Apr 25 17:01:31 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Fri, 25 Apr 2008 16:01:31 -0500 Subject: Goodbying Spaces Message-ID: <4dc0cfea0804251401p3ab96fddy99452f5a3255acde@mail.gmail.com> Hi; Whenever I call a field from the preceeding form using cgi.FieldStorage() I get a space on either side. I end up writing code like this to get rid of that space: try: if id[0] == ' ': id = id[1:len(id)] except: pass try: if id[len(id) - 1] == ' ': id = id[0:len(id) - 1] except: pass which is a nuisance. Is there a better way to do this? I have tried id.strip() with no luck. What do? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From vivainio at gmail.com Sun Apr 6 15:19:31 2008 From: vivainio at gmail.com (Ville Vainio) Date: Sun, 6 Apr 2008 12:19:31 -0700 (PDT) Subject: ANN: Leo 4.4.8 final References: Message-ID: <3cdc0b0d-648c-44b0-a03c-2c6233f74ada@e10g2000prf.googlegroups.com> On Apr 6, 8:10 pm, "Edward K Ream" wrote: > - Completed ILeo: a bridge between IPython and Leo. > See http://webpages.charter.net/edreamleo/IPythonBridge.html Additional note: to use ILeo, you need a new IPython. Download the not- yet-blessed release candidate (I don't foresee much changes before the final release) from: https://launchpad.net/ipython/stable/0.8.3pre It's a source distribution, so run "eggsetup.py develop" in it (if you have setuptools) or just "setup.py install" From soray6034rao at gmail.com Wed Apr 30 07:29:54 2008 From: soray6034rao at gmail.com (soray6034rao at gmail.com) Date: Wed, 30 Apr 2008 04:29:54 -0700 (PDT) Subject: microsoft office word 2007 keygen download Message-ID: microsoft office word 2007 keygen download http://crack.cracksofts.com From usenet at janc.be Wed Apr 2 23:37:43 2008 From: usenet at janc.be (Jan Claeys) Date: Thu, 03 Apr 2008 03:37:43 GMT Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: Op Wed, 02 Apr 2008 17:02:45 -0400, schreef Dan Upton: > Side rant: I think Java's just fine, as long as it's taught properly. > I'd done a little bit of C and C++ programming when I was in high > school, trying to teach myself from a book, but I never really got > pointers or objects. Going back to it after Java, it made so much more > sense, even though people will tell you "Java doesn't make you learn > about pointers." I learned about pointers while learning Pascal (and later embedded assembler) using Borland's tools. Later I learned C (and even later C++), and I've always been wondering why those languages were making simple things so complicated... -- JanC From pscott at uwc.ac.za Tue Apr 15 02:11:18 2008 From: pscott at uwc.ac.za (Paul Scott) Date: Tue, 15 Apr 2008 08:11:18 +0200 Subject: a name error In-Reply-To: <20080415055502.9F3CF292B61@mail-in-07.arcor-online.net> References: <20080415055502.9F3CF292B61@mail-in-07.arcor-online.net> Message-ID: <1208239878.6947.12.camel@paul-laptop> On Tue, 2008-04-15 at 13:54 +0800, Penny Y. wrote: > import urllib2,sys > try: > r=urllib2.urlopen("http://un-know-n.com/") > except URLError,e: > print str(e) > sys.exit(1) > > print r.info() > > > But got the errors: > > Traceback (most recent call last): > File "t1.py", line 4, in ? > except URLError,e: > NameError: name 'URLError' is not defined > > > Why these is not the name of URLError? I saw it on this module's page: You need to define the urllib first. url=urllib2 try: r=urllib2.urlopen("http://un-know-n.com/") except url.URLError,e: print str(e) sys.exit(1) print r.info() You can't just launch into a catchable exception without first defining something. --Paul -- ------------------------------------------------------------. | Chisimba PHP5 Framework - http://avoir.uwc.ac.za | :------------------------------------------------------------: -------------- next part -------------- All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm From gherron at islandtraining.com Thu Apr 10 04:40:30 2008 From: gherron at islandtraining.com (Gary Herron) Date: Thu, 10 Apr 2008 01:40:30 -0700 Subject: urgent question, about filesystem-files In-Reply-To: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> References: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> Message-ID: <47FDD27E.1040204@islandtraining.com> bvidinli wrote: > i started python programming a few months ago. > > now i need the code to understand if a file already opened in > filesystem by another process ? > > i looked at docs, howtos, but did not find related info. > note that normal file open/write operations in python, i know it. > > i specificly need to know that "is a file already open by some other > process other than python". > > > Thank you in advance > This is certainly an operating-system dependent bit of functionality. So first off, you are going to have to tell us *which* OS you're working on. Then, perhaps someone can help... Gary Herron From martin at v.loewis.de Sun Apr 6 17:50:01 2008 From: martin at v.loewis.de (=?ISO-8859-2?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 06 Apr 2008 23:50:01 +0200 Subject: Form sha1.hexdigest to sha1.digest In-Reply-To: <1d73d457-d305-4c41-9063-5676303e5ba7@c19g2000prf.googlegroups.com> References: <7c39af89-9cee-428c-a0bc-8202700c5aec@b1g2000hsg.googlegroups.com> <47F8CF66.1020805@v.loewis.de> <47F930F8.7030406@v.loewis.de> <1d73d457-d305-4c41-9063-5676303e5ba7@c19g2000prf.googlegroups.com> Message-ID: <47f94589$0$11561$9b622d9e@news.freenet.de> >>> Or hexdigest_string.decode('hex') >> I would advise against this, as it's incompatible with Python 3. > > I didn't know that, you actually made me look it up in the Python 3 > FAQ. And yes, the difference is that decode will return bytes type > instead of a string. No. The decode method on string objects is removed, you can only *encode* strings, but not decode them. > This may or may not be a problem The problem is this: py> hashlib.sha1(b"Hallo").hexdigest().decode("hex") Traceback (most recent call last): File "", line 1, in AttributeError: 'str' object has no attribute 'decode' Regards, Martin From arnodel at googlemail.com Thu Apr 24 04:53:19 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 24 Apr 2008 09:53:19 +0100 Subject: @classmethod question References: Message-ID: Scott SA writes: A side note > class RecipieClass: Recipe is a more widespread spelling, I believe. Moreover it is the convention in python that only class names are capitalized, so you don't need to append a 'Class'. class Recipe: ... clafoutis = Recipe('eggs', 'spam') -- Arnaud From maehhheeyy at gmail.com Tue Apr 29 18:02:10 2008 From: maehhheeyy at gmail.com (maehhheeyy) Date: Tue, 29 Apr 2008 15:02:10 -0700 (PDT) Subject: timeout Message-ID: <1a9b19bf-5075-4bce-812d-5516d3a4e454@b9g2000prh.googlegroups.com> Hi, I was just wondering if there was such thing as a timeout module. From tjreedy at udel.edu Tue Apr 8 00:35:30 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 8 Apr 2008 00:35:30 -0400 Subject: guide through python interpreter source code References: Message-ID: "Avi Kohn" wrote in message news:VvGdnQCSZv_yfmfanZ2dnUVZ_viunZ2d at earthlink.com... | Are there documents,books, articles that can introduce me to the python | source code base ? This has been asked before. The general answer has been to look at the code. Perhaps you can find some of the more specific answers at groups.google.com. From deets at nospam.web.de Sat Apr 19 12:38:10 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Sat, 19 Apr 2008 18:38:10 +0200 Subject: urlretrieve can't send headers In-Reply-To: References: Message-ID: <66ulg4F2lidl3U1@mid.uni-berlin.de> triplezone3 schrieb: > Hello. I'm using urllib.urlretrieve to download files, > because it provides a handy hook function. > Unfortunately, it won't let me send headers, which > could be quite useful. Is there any way I could do > this? I suggest you look into urllib2. It allows you to explicitly create an request-object that you can stuff with headers and parameters and what you like. diez From cyberco at gmail.com Tue Apr 15 17:45:39 2008 From: cyberco at gmail.com (Berco Beute) Date: Tue, 15 Apr 2008 14:45:39 -0700 (PDT) Subject: webcam (usb) access under Ubuntu References: <66jlk1F2ju6c8U1@mid.uni-berlin.de> <66kkedF2l526dU2@mid.uni-berlin.de> Message-ID: <455760fb-8229-4be3-ba7f-7c41bdcd66de@a22g2000hsc.googlegroups.com> On Apr 15, 11:18 pm, "Diez B. Roggisch" wrote: > Berco Beute schrieb: > > > Thanks, that would be great. > > Here you go. > > http://roggisch.de/vidio.tgz > > Diez Wonderful! Thank you very much! I'm running out of time, but after installing the necessary goodies using the nice package from here: http://aruiz.typepad.com/siliconisland/2006/12/allinone_win32_.html In the meantime I've switched to windows. I'm running into the problem that 'import gst' throws: =========================== >>> import gst Traceback (most recent call last): File "", line 1, in File "H:\Python25\lib\site-packages\gst-0.10\gst\__init__.py", line 87, in from _gst import * ImportError: DLL load failed: The specified module could not be found. =========================== I've tried reinstalling gstreamer (for windows): http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstreamer-0.10.17.setup.zip http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstreamer-0.10.17.win32.zip but that didn't help. I get some complaints about 'libgstinterfaces' as well... I'm too unfamiliar with these libraries to have a clue what's wrong here... I'll look into it some more tomorrow. 2B From robin at nibor.org Tue Apr 15 15:35:45 2008 From: robin at nibor.org (Robin Stocker) Date: Tue, 15 Apr 2008 21:35:45 +0200 Subject: Recurring patterns: Am I missing it, or can we get these added to the language? In-Reply-To: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: <48050391.9030506@nibor.org> Erich schrieb: > This is like split() but returns a list of exactly lenght n. This is > very useful when using unpacking, e.g.: > x, y = nsplit('foo,bar,baz', ',', 2) You could use the second argument of split: x, y = 'foo,bar,baz'.split(',', 1) Note that the number has the meaning "only split n times" as opposed to "split into n parts". Cheers, Robin From juergen.perlinger at t-online.de Sun Apr 20 16:06:38 2008 From: juergen.perlinger at t-online.de (Juergen Perlinger) Date: Sun, 20 Apr 2008 22:06:38 +0200 Subject: What happened with python? messed strings? References: Message-ID: Juergen Perlinger wrote: > algaba at droog.sdf-eu.org wrote: > [snip] > Basically you're not using ASCII encoding in your source text... You need > to define an encoding for your source if you're using german umlauts or > other fancy stuff. > > See chapter 2.1.4 of the reference manual, and add e.g. > > # -*- coding: utf-8 -*- > > as first or second line to your script. Make sure your editor talks utf-8, > or use the encoding used by your editor. cp1552 is a good choice for > windows... > stupid me. cp1252, of course. -- juergen 'pearly' perlinger "It's hard to make new errors!" From jgardner at jonathangardner.net Thu Apr 24 13:12:59 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Thu, 24 Apr 2008 10:12:59 -0700 (PDT) Subject: function that accepts any amount of arguments? References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> <4810724a$0$23390$426a74cc@news.free.fr> <63ac69bf-9f6d-42bd-8e6e-5b3b17ec7c69@z72g2000hsb.googlegroups.com> Message-ID: <933e4c97-11c8-43b0-81e0-c78ff8573792@26g2000hsk.googlegroups.com> On Apr 24, 5:28?am, malkarouri wrote: > > What's wrong with raising ZeroDivisionError (not stopping the > exception in the first place)? > Because when I use your module, call avg (or mean) without args, I should see an error that says, "Hey, you have to pass at least one value in!" ZeroDivisonError doesn't mean that. It means I tried to divide by zero. Naively, I don't see where I was dividing by zero (because I don't remember how to calculate the mean---that's what your code was for.) ValueError does mean that I didn't pass the right kind of arguments in. ValueError("No items specified") would be even clearer. (Or maybe TypeError?) In general, any exception thrown should be meaningful to the code you are throwing it to. That means they aren't familiar with how your code works. From pavlovevidence at gmail.com Sun Apr 6 22:23:20 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Sun, 6 Apr 2008 19:23:20 -0700 (PDT) Subject: sine in python References: Message-ID: On Apr 6, 5:10 pm, Mark Wooding wrote: > Astan Chee wrote: > > I have a math function that looks like this > > sin (Theta) = 5/6 > > How do I find Theta (in degrees) in python? > > import math > theta = math.asin(5/6) * 180/math.pi Careful there, bud. 5/6 might not give you the value you're expecting it to, depending on the version of Python you're using. If you're on Python 2.x, you'll want to use "from __future__ import division", or to specify 5 and 6 as floats, i.e., 5.0/6.0. (And people claim 5/6 == 0 is the "obvious" result....) Carl Banks From dickinsm at gmail.com Fri Apr 11 14:05:00 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Fri, 11 Apr 2008 11:05:00 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <31872ffc-5bc4-44c8-961d-ee4f0dc356c5@k1g2000prb.googlegroups.com> <700b1a5f-0af0-466e-abda-4d8dc784dbaa@e67g2000hsa.googlegroups.com> <220fa9fa-3ad3-4d58-b90c-478f936b5352@m1g2000pre.googlegroups.com> <6d63626e-8868-46e7-9a69-0ed870751263@m3g2000hsc.googlegroups.com> Message-ID: <7df84537-d50e-4cb7-b72f-c7a4fb5a006f@u69g2000hse.googlegroups.com> On Apr 11, 10:29 am, hdante wrote: > Strangely, a "faster" version is: > > def fast_round(x): > if x % 1 != 0.5: return round(x) > return 2.0*round(x/2.0) You should be a little bit careful with the test x%1 == 0.5 if x might be negative: >>> x = -0.5 + 2**-54 >>> x # not an exact half... -0.49999999999999994 >>> x % 1 # ... and yet x%1 == 0.5 0.5 But for x positive, it should be safe. And for this particular application, it turns out that it doesn't matter: it gives the right result for this input anyway. Mark From skanemupp at yahoo.se Fri Apr 18 15:06:00 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 18 Apr 2008 12:06:00 -0700 (PDT) Subject: Easiest way to get started with WebApps? Message-ID: <3c43f29c-3e51-48ab-be02-47402ccd1bfd@b64g2000hsa.googlegroups.com> which is the easiest module to use to just get started with webapps quicklya nd starting getting things up and running, not advanced stuff just basic. From bearophileHUGS at lycos.com Tue Apr 8 12:54:56 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Tue, 8 Apr 2008 09:54:56 -0700 (PDT) Subject: Data structure recommendation? References: Message-ID: <1adc3541-7775-4938-bd5a-953dd041656c@2g2000hsn.googlegroups.com> Jochen Schulz: > This solution may be more than you actually need, but I implemented two > metric space indexes which would do what you want (and I wanted to plug > it anyway :)): Please plug such good things. It seems the Python community is an endless source of interesting modules I didn't know about. Your (single) module looks very nice. I'll take a better look later. Few notes: Use xrange instead of range, for Psyco they are often the same, but if you don't have Psyco the range may be slower and usually requires more memory. Java is faster than Python, but if you have some care and you know how things are implemented in Python, you can often write ""fast"" Python code. In the levenshtein function you have this: for i in range(1, m+1): prev, cur = cur, [i] + [0]*n You can speed up that levenshtein, using nearly constant (heap) memory, avoiding that re-creation of prev and cur (see below for D code you can back-translate to Python). You can translate this module to D (I may even do it myself, or I may help you do it), this has several advantages: - If you are careful it may become (quite) faster than your Java version. - The resulting code may be probably as long as the Python one, or not too much longer (but it may have or not have some extra limitations. D is flexible but it's a statically typed language, unlike Python); - Coding in D may be similar enough to Java coding for you, quite differently from coding it in C; - You can then use Pyd (http://pyd.dsource.org ) to create in a very simple way a single compiled module with the functions/classes that can be called by python (no intermediate python needed). Using Pyd is quite simpler than using C + Swig or writing a C module for Python. Later you can release the D code plus the already compiled module for Win too. - Disadvantages: you don't know D, you don't know how to use Pyd, and most people out there may prefer to maintain/modify C code, even if it's 3/4 times longer than the D code. - The following is to show you an example of D code (that uses my D libs for few bits, like that range(), the min(), but it's not too much difficult to avoid using them) that you may compare to the Python one. Note that this code is generic (it's a function template), and it takes as input any array, that means Unicode Strings too (utf8, 16 bit too, 32 bit too), it runs about 105-125 times faster than a quite similar Python version (Psyco is able to speed up this Python code about 20-25 times, so this is 4-5 times faster than Psyco): int editDistance(T)(T[] s1, T[] s2) { if (len(s1) > len(s2)) { auto sa = s1; s1 = s2; s2 = sa; } auto r1 = range(len(s2) + 1); auto r2 = new int[len(r1)]; foreach (i, c1; s1) { r2[0] = i + 1; foreach (j, c2; s2) r2[j+1] = c1 == c2 ? r1[j] : min(r2[j], r1[j], r1[j+1]) + 1; auto ra = r1; r1 = r2; r2 = ra; // swap lines } return r1[$ - 1]; } If you have questions feel free to ask :-) Bye, bearophile From Robert.Bossy at jouy.inra.fr Fri Apr 25 09:00:43 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Fri, 25 Apr 2008 15:00:43 +0200 Subject: multiple pattern regular expression In-Reply-To: References: Message-ID: <4811D5FB.8040109@jouy.inra.fr> Arnaud Delobelle wrote: > micron_make writes: > > >> I am trying to parse a file whose contents are : >> >> parameter=current >> max=5A >> min=2A >> >> for a single line I used >> for line in file: >> print re.search("parameter\s*=\s*(.*)",line).groups() >> >> is there a way to match multiple patterns using regex and return a >> dictionary. What I am looking for is (pseudo code) >> >> for line in file: >> re.search("pattern1" OR "pattern2" OR ..,line) >> >> and the result should be {pattern1:match, pattern2:match...} >> >> Also should I be using regex at all here ? >> > > If every line of the file is of the form name=value, then regexps are > indeed not needed. You could do something like that. > > params = {} > for line in file: > name, value = line.strip().split('=', 2) > params[name] = value > > (untested) I might add before you stumble upon the consequences: params[name.rstrip()] = value.lstrip() Cheers, RB From duncan.booth at invalid.invalid Wed Apr 9 08:56:32 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 9 Apr 2008 12:56:32 GMT Subject: Google App Engine References: <47fc2c7c$0$36365$742ec2ed@news.sonic.net> <7e43fcd9-6207-4af2-8256-c0099a8ce0bb@1g2000prf.googlegroups.com> Message-ID: Duncan Booth wrote: > If you use authentication then again you are tied to Google accounts (or > Google Apps accounts). For a public application that would also block > attempts to move to another platform. Correcting myself: according to http://code.google.com/p/googleappengine/issues/detail?id=17 is is possible to use OpenID, it just isn't there by default. From bdsatish at gmail.com Fri Apr 11 08:33:53 2008 From: bdsatish at gmail.com (bdsatish) Date: Fri, 11 Apr 2008 05:33:53 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: HI Gerard, I think you've taken it to the best possible implementation. Thanks ! On Apr 11, 5:14 pm, Gerard Flanagan wrote: > In fact you can avoid the call to the builtin round: > > ------------------------------------------------ > def myround(x): > n = int(x) > if abs(x - n) >= 0.5 and n % 2: > return n + 1 - 2 * int(n<0) > else: > return n > > assert myround(3.2) == 3 > assert myround(3.6) == 4 > assert myround(3.5) == 4 > assert myround(2.5) == 2 > assert myround(-0.5) == 0.0 > assert myround(-1.5) == -2.0 > assert myround(-1.3) == -1.0 > assert myround(-1.8) == -2 > assert myround(-2.5) == -2.0 > ------------------------------------------------ From musiccomposition at gmail.com Wed Apr 9 22:35:18 2008 From: musiccomposition at gmail.com (Benjamin) Date: Wed, 9 Apr 2008 19:35:18 -0700 (PDT) Subject: How is GUI programming in Python? References: Message-ID: On Apr 9, 8:54 pm, Chris Stewart wrote: > I've always had an interest in Python and would like to dabble in it > further. I've worked on a few very small command line programs but > nothing of any complexity. I'd like to build a really simple GUI app > that will work across Mac, Windows, and Linux. How painful is that > going to be? I used to be really familiar with Java Swing a few years > ago. I imagine it will be similar. Since it's Python, it will be a lot less painless than anything else. :) > > Next, what would you say is the best framework I should look into? > I'm curious to hear opinions on that. Tkinter is the easiest for little apps, but when I'm doing anything for real, I use PyQt. > > Chris Stewart > cstewart... at gmail.com From deets at nospam.web.de Tue Apr 22 15:34:24 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 21:34:24 +0200 Subject: Spawing a thread and printing dots until it finishes In-Reply-To: References: Message-ID: <676sukF2nc0tuU1@mid.uni-berlin.de> Larry Bates schrieb: > sophie_newbie wrote: >> On Apr 22, 4:41 pm, "D'Arcy J.M. Cain" wrote: >>> On Tue, 22 Apr 2008 07:10:07 -0700 (PDT) >>> >>> >>> >>> sophie_newbie wrote: >>>> import threading >>>> class MyThread ( threading.Thread ): >>>> def run ( self ): >>>> myLongCommand()... >>>> import time >>>> t = MyThread() >>>> t.start() >>>> while t.isAlive(): >>>> print "." >>>> time.sleep(.5) >>>> print "OK" >>>> The thing is this doesn't print a dot every half second. It just >>>> pauses for ages until the thread is finished and prints prints ".OK". >>>> But if I take out the "time.sleep(.5)" line it will keep printing dots >>>> really fast until the thread is finished. So it looks like its the >>>> time.sleep(.5) bit that is messing this up somehow? >>> We know that your main routine gives up the processor but without a >>> full definition of MyThread how do we know that it ever does? I >>> suspect that it hits sleep once, if at all, and then goes to the final >>> print statement. In fact, I suspect that this is not exactly what you >>> tried anyway. This code would not have printed ".OK" whether it >>> entered the loop or not. It could have printed this; >>> >>> . >>> OK >>> >>> because the print statement in the loop will print a dot on a line by >>> itself. >>> >>> When looking for these sorts of answers you should really try to create >>> a smallest program that exhibits the behaviour you are questioning and >>> then cut and paste the entire script into your message unedited. Often >>> enough you will even answer your own question in the process. >>> >>> -- >>> D'Arcy J.M. Cain | Democracy is three >>> wolveshttp://www.druid.net/darcy/ | and a sheep voting on >>> +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. >> >> "myLongCommand()... " is a call to an function in R (the statistical >> programming language) via Rpy (A python module that allows calls to >> R). The call takes a couple of minutes to execute. I'm trying to build >> a web front end to this R function and instead of the user looking at >> a blank screen for 2-3 mins, I want to print dots to let them feel >> like the program isn't hanging. >> >> What I am saying is that without the "time.sleep(.5)" line, the above >> code will print dots on the screen continuously for 2-3 mins, filling >> it up with a ridiculous ammount of dots. >> >> Whereas with the time.sleep line, instead of pausing for half a second >> between dots, its seems to print, as you correctly pointed out: >> >> . >> OK >> >> With a pause of 2-3 minutes between the . and the OK. >> >> I hope that clears things up a little. I haven't the faintest idea why >> the code above doesn't work but hope someone has an idea. It wouldn't >> be something to do with python not being able to handle multiple >> threads at the same time or something? I hope there is a workaround. > > For a web front end you wouldn't go this route at all. You would get a > progressive .GIF file that gets loaded into the client's browser and shows > "activity" while the server does its thing. When the browser refreshes > (after the server application completes) it would go away. You can't > update a client's browser by writing dots to anything. Yes and no. You are right of course that the dot-thread is not working that way. But if you replace the dot-thread with the http-request-thread, the question remains: why is it blocking? Your approach doesn't tackle that. If nothing else helps, a subprocess must be spawned. Diez From kyosohma at gmail.com Tue Apr 15 15:30:49 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 15 Apr 2008 12:30:49 -0700 (PDT) Subject: Recurring patterns: Am I missing it, or can we get these added to the language? References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: <8674324c-676e-4524-aa7d-bffccbf6a550@b1g2000hsg.googlegroups.com> On Apr 15, 1:51 pm, Erich wrote: > Hello all, > > Today I found myself once again defining two functions that I use all > the time: nsplit and iterable. These little helper functions of mine > get used all the time when I work. Im sick of having to define them > (but am very good at it these days, less than 1 typo per function!). > It leads me to the following questions > > 1. Is this functionality already built in and im just missing it > 2. Is there some well known, good technique for these that I missed? > 3. Insert question I need to ask here (with a response) > > These are the funtions w/ explaination: > > def nsplit(s,p,n): > n -= 1 > l = s.split(p, n) > if len(l) < n: > l.extend([''] * (n - len(l))) > return l > > This is like split() but returns a list of exactly lenght n. This is > very useful when using unpacking, e.g.: > x, y = nsplit('foo,bar,baz', ',', 2) > > def iterable(item, count_str=False): > if not count_str and isinstance(item, str): > return False > try: > iter(item) > except: > return False > return True > This is just simple boolean test for whether or not an object is > iterable. I would like to see this in builtins, to mirror callable. > The optional count_str adds flexibility for string handling, since > sometimes I need to iterate over a string, but usually not. I > frequently use it to simplify my case handling in this type of > costruct: Just found this thread on the subject: http://mail.python.org/pipermail/python-list/2006-July/394487.html That might answer your question. > > def foo(bar): > bar = bar if iterable(bar) else [bar] > for x in bar: > .... > > Thanks for feeback, > Erich Mike From fredrik at pythonware.com Fri Apr 4 17:06:32 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 04 Apr 2008 23:06:32 +0200 Subject: Is there any way to say ignore case with "in"? In-Reply-To: <47f692f3$0$759$bed64819@news.gradwell.net> References: <47f692f3$0$759$bed64819@news.gradwell.net> Message-ID: tinnews at isbd.co.uk wrote: > Is there any way in python to say > > if string1 in string2: > > > ignoring the case of string1 and string2? if string1.lower() in string2.lower(): ... (there's no case-insensitive version of the "in" operator in stock Python) From wilk at flibuste.net Tue Apr 8 11:55:19 2008 From: wilk at flibuste.net (William Dode) Date: Tue, 8 Apr 2008 15:55:19 +0000 (UTC) Subject: Google App Engine References: Message-ID: On 08-04-2008, Duncan Booth wrote: > Google have announced a new service called 'Google App Engine' which may > be of interest to some of the people here (although if you want to sign > up you'll have to join the queue behind me): > > From the introduction: > >> What Is Google App Engine? ... It's also interesting to see that we can find django, webob and pyyaml in their sdk (license apache 2) -- William Dod? - http://flibuste.net Informaticien ind?pendant From goldtech at worldpost.com Wed Apr 9 09:15:02 2008 From: goldtech at worldpost.com (goldtech) Date: Wed, 9 Apr 2008 06:15:02 -0700 (PDT) Subject: String manipulation questions Message-ID: <8cd7b477-6fc6-47c5-b2eb-e2a4f284f7b2@m3g2000hsc.googlegroups.com> Hi, Replacing strings in a text (likely an XML) file. Some newbie questions... ... while line: counter=counter+1 if line.find(newstring) != -1: print 'match at line'+str(counter) newline = line.replace(oldstring, newstring) fileOUT.write(newline) line=fileIN.readline() .... Question1: The replace method - If a string does not have the target replacement "newstring", then newline equals oldstring? Ie. oldstring is not changed in any way? Seems to be what I observe but just want to confirm this. Question2: I'm using "line.find(newstring) != -1..." because I want to print when a replacement happens. Does "line.replace..." report indirectly somehow when it replaces? Thanks P.S. I know I should be using XSLT to transform XML - but the above seems to work for small text changes. From v.harishankar at gmail.com Tue Apr 22 09:22:29 2008 From: v.harishankar at gmail.com (Harishankar) Date: Tue, 22 Apr 2008 18:52:29 +0530 Subject: subprocess module is sorely deficient? In-Reply-To: <621dbfa0-8c3c-4ce4-80e7-cf0840c4b82f@p25g2000hsf.googlegroups.com> References: <621dbfa0-8c3c-4ce4-80e7-cf0840c4b82f@p25g2000hsf.googlegroups.com> Message-ID: <200804221852.29221.v.harishankar@gmail.com> On Tuesday 22 Apr 2008 17:54:00 Nicola Musatti wrote: > I suggest you check out this: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554 > > Cheers, > Nicola Musatti > -- > http://mail.python.org/mailman/listinfo/python-list An interesting solution. Thanks a lot for the link. -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org From pierre-yves.dupont at pibioinfo.com Fri Apr 4 11:51:52 2008 From: pierre-yves.dupont at pibioinfo.com (pierre-yves.dupont at pibioinfo.com) Date: Fri, 04 Apr 2008 17:51:52 +0200 Subject: UML reverse engineering Message-ID: <6712345.1824821207324312295.JavaMail.servlet@kundenserver> Hello, Do you know a free software witch can compute a UML class diagram from a python code. I tested many free UML softwares like BoUML, ArgoUML, Dia, PNSource (not found), UMLet and others ... But I didn't found what I needed. -- Pierre-Yves Dupont -------------- next part -------------- An HTML attachment was scrubbed... URL: From gagsl-py2 at yahoo.com.ar Sun Apr 13 16:03:04 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 13 Apr 2008 17:03:04 -0300 Subject: py2exe, program has stoped working!? References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> Message-ID: En Sun, 13 Apr 2008 10:52:06 -0300, escribi?: > so i used py2exe and i have the build and the dist-folders. > > and when im distributing my program i have to include both catalogues > right? You only have to distribute the contents of the "dist" directory. (I have no idea what the message error means) -- Gabriel Genellina From sawilla at gmail.com Mon Apr 21 19:15:15 2008 From: sawilla at gmail.com (sawilla) Date: Mon, 21 Apr 2008 16:15:15 -0700 (PDT) Subject: module error in Vista -- works as administrator References: <815eb7f8-6f00-469d-bb15-e1d9680d9646@e39g2000hsf.googlegroups.com> <480d0a52$1@news.mel.dft.com.au> Message-ID: <72da4abc-57b1-47ca-bed4-48b7244d6407@e39g2000hsf.googlegroups.com> On Apr 21, 5:42 pm, John Machin wrote: > Log on as administrator, start python in command window and do this: > > import sys > sys.path # shows where python is looking for importables > import numpy > import os.path > print os.path.abspath(numpy.__file__) # shows where it found numpy > > Log on as ordinary user, start python in command window and do this: > > import sys > sys.path > # check how this is different from the admin's sys.path > > If you can't see what to do after that, come back here with the output > from those steps. > > HTH, > John That was a great help, thank you. I now see what is causing the problem but I don't know how to fix it. I used easy_install to install several packages. When I run Python from an administrator command window all of the directories in C:\Program Files\Python25\Lib\site- packages\easy-install.pth are added to the sys.path. When I run it as a regular user, those directories are not added to the sys.path and so Python can't find the modules. I know how to manually add those directories to Python's search path but then I'll need to update the path every time I install something. How do I get Python to automatically load the easy-install.pth file for the regular user account? Reg From torriem at gmail.com Tue Apr 15 12:58:01 2008 From: torriem at gmail.com (Michael Torrie) Date: Tue, 15 Apr 2008 10:58:01 -0600 Subject: py3k s***s In-Reply-To: <0A685715-6D44-4D41-87C2-4B971A751E78@gmail.com> References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <0A685715-6D44-4D41-87C2-4B971A751E78@gmail.com> Message-ID: <4804DE99.5020200@gmail.com> Chris McAloney wrote: > *Have* you tried the 2to3 tool? It might help to lessen your > concerns a bit. Yes, Python 3 is different from 2.x, but we've known > that it was going to be for years and, as has already been pointed > out, the devs are being very careful to minimize the pain that the > changes will inflict on Python programmers, with tools such as 2to3. After parsing this thread through a noise filter, it appears the main concern is not the converting of _python code_ from 2 to 3, but rather converting extensions written in C, or when python is embedded in a C program. The APIs have necessarily changed, and this *will* inflict a certain amount of pain and suffering on the developer, especially if he needs to maintain code for both python 2 and python 3. However this is just the way it is. It's a bit like complaining that I have to rewrite my app with win32 calls and paradigms when I was used to win16. No conversion will be completely pain free, but this jump is pretty insignificant compared to others in the industry. I think the original poster is being somewhat unreasonable, though. No one is going to force him to 3. If his end users demand it, and he's selling them software, then he'll do it or else go out of business. If it's OSS, he'll either do it, or someone else will fork it and take it forward. From bvidinli at gmail.com Thu Apr 10 05:04:06 2008 From: bvidinli at gmail.com (bvidinli) Date: Thu, 10 Apr 2008 12:04:06 +0300 Subject: urgent question, about filesystem-files In-Reply-To: <36e8a7020804100201x5cf16377gfedddc8647fe8e3a@mail.gmail.com> References: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> <47FDD27E.1040204@islandtraining.com> <36e8a7020804100200m6c3a9a41h1ed3021b70f8a829@mail.gmail.com> <36e8a7020804100201x5cf16377gfedddc8647fe8e3a@mail.gmail.com> Message-ID: <36e8a7020804100204k3a3eb471w2e9b093086a8a9e3@mail.gmail.com> The need/reason for this, i write a program that should perform some operation on files, only if the file is not being used.... this is for ensuring that file is not in use, ... by any process in system.... 10.04.2008 tarihinde bvidinli yazm??: > Sory for lack of information, > > i use linux/unix > i need to solve this for linux/unix > > i tested os.open with O_EXCL flag, and some other things, that did not solve. > > i need exacly: say example file testfile, > > check if testfile already open by some other process in linux, > > > tahnks. > 2008/4/10, Gary Herron : > > > > bvidinli wrote: > > > > > i started python programming a few months ago. > > > > > > now i need the code to understand if a file already opened in > > > filesystem by another process ? > > > > > > i looked at docs, howtos, but did not find related info. > > > note that normal file open/write operations in python, i know it. > > > > > > i specificly need to know that "is a file already open by some other > > > process other than python". > > > > > > > > > > Thank you in advance > > > > > > > > > > This is certainly an operating-system dependent bit of functionality. So > > first off, you are going to have to tell us *which* OS you're working on. > > Then, perhaps someone can help... > > > > Gary Herron > > > > > > > > -- > ?.Bahattin Vidinli > Elk-Elektronik M?h. > ------------------- > iletisim bilgileri (Tercih sirasina gore): > skype: bvidinli (sesli gorusme icin, www.skype.com) > msn: bvidinli at iyibirisi.com > yahoo: bvidinli > > +90.532.7990607 > +90.505.5667711 > > > -- > ?.Bahattin Vidinli > Elk-Elektronik M?h. > ------------------- > iletisim bilgileri (Tercih sirasina gore): > skype: bvidinli (sesli gorusme icin, www.skype.com) > msn: bvidinli at iyibirisi.com > yahoo: bvidinli > > +90.532.7990607 > +90.505.5667711 > -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From pDOTpagel at helmholtz-muenchen.de Wed Apr 23 06:47:01 2008 From: pDOTpagel at helmholtz-muenchen.de (Philipp Pagel) Date: Wed, 23 Apr 2008 10:47:01 +0000 (UTC) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: azrael wrote: > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. There is only one sane way to deal with this situation: You need a common enemy. Java comes to mind ;-) cu Philipp -- Dr. Philipp Pagel Lehrstuhl f. Genomorientierte Bioinformatik Technische Universit?t M?nchen http://mips.gsf.de/staff/pagel From rasmussen.bryan at gmail.com Thu Apr 24 17:11:57 2008 From: rasmussen.bryan at gmail.com (bryan rasmussen) Date: Thu, 24 Apr 2008 23:11:57 +0200 Subject: convert xhtml back to html In-Reply-To: <4810E5CC.2000503@behnel.de> References: <4810E5CC.2000503@behnel.de> Message-ID: <3bb44c6e0804241411u1c45b420r309a02500a81fc01@mail.gmail.com> wow, that's pretty nice there. Just to know: what's the performance like on XML instances of 1 GB? Cheers, Bryan Rasmussen On Thu, Apr 24, 2008 at 9:55 PM, Stefan Behnel wrote: > Tim Arnold wrote: > > hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop to > > create CHM files. That application really hates xhtml, so I need to convert > > self-ending tags (e.g.
) to plain html (e.g.
). > > This should do the job in lxml 2.x: > > from lxml import etree > > tree = etree.parse("thefile.xhtml") > tree.write("thefile.html", method="html") > > http://codespeak.net/lxml > > Stefan > > > -- > http://mail.python.org/mailman/listinfo/python-list > From george.sakkis at gmail.com Fri Apr 11 14:31:37 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 11 Apr 2008 11:31:37 -0700 (PDT) Subject: Graphs in Python References: Message-ID: <4043676a-3a9b-4f49-8a64-7afd78ee480c@a23g2000hsc.googlegroups.com> On Apr 10, 1:05?pm, Sanhita Mallick wrote: > Hi. > > I am a newbie to Python. I am trying to implement a > Python code for graph manipulation. My graphs are > about 200-500 nodes big. Excepting for the short basic > graph implementation info on Python.org, where can I > find more in depth info about how to express graphs in > python, and how to use them in a ?code? > > Also, does anyone know of a easy way of creating the > dictionary for python for a 500-node graph, without > typing each and every node? I found some application > that recognize dot file Graphviz - but I am looking > for a program that can let me "draw" a graph and then > generate the lists automatically from the drawing. > > Thanks. > -SM A pure python package such as those mentioned in other replies is most likely fine for graphs of several hundreds nodes, but in case performance matters, you can take a look at the Python bindings of the Boost graph library [1]. George [1] http://www.osl.iu.edu/~dgregor/bgl-python/ From jergosh at wp.pl Tue Apr 8 17:25:31 2008 From: jergosh at wp.pl (=?UTF-8?B?R3J6ZWdvcnogU8WCb2Rrb3dpY3o=?=) Date: Tue, 08 Apr 2008 23:25:31 +0200 Subject: Python 3.0 new integer division In-Reply-To: References: Message-ID: <47FBE2CB.5030102@wp.pl> > If you want precision with fractions, you should be using the Decimal > type, which uses a rational. A rational, if you recall from your math > classes, is one integer divided by another. > Isn't Decimal a BCD implementation? From llothar at web.de Fri Apr 4 22:43:12 2008 From: llothar at web.de (llothar) Date: Fri, 4 Apr 2008 19:43:12 -0700 (PDT) Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> Message-ID: Thanks, my question was not how can i make python to it find. I don't have a problem. My question was: Why does setup.py generated sometimes a pyd and sometimes a so file? There must be a rule behind this. Unforunately setup.py is not well documented. Here i mean i need a specification not a tutorial, because i want to know something not do something. Don't ask why i need to know: I need to know. And maybe somebody here can drop a line before i have to dig around in the source code. From fredrik at pythonware.com Fri Apr 4 16:41:04 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 04 Apr 2008 22:41:04 +0200 Subject: Self in Interactive Interpreter In-Reply-To: References: Message-ID: kj7ny wrote: > For years it has been a slight annoyance that every time I wanted to > test a snippet of code from a class by running it in the interactive > interpreter, I had to remove all of the self. instances from the > code. After I got it working correctly, I had to put all the self.'s > back into the code to put it back into my class. wouldn't it be a lot easier to test your code by importing the module containing it into the interactive interpreter? >>>> class dummy: >>>> def __init__(self): >>>> pass or, shorter: >>> class dummy: pass From gagsl-py2 at yahoo.com.ar Wed Apr 9 01:18:17 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 02:18:17 -0300 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> Message-ID: 2008/4/8, subhabrata.iisc at hotmail.com : >> I am using Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v. >> 1310 32 bit (Intel)] on win32 with IDLE 1.2.1 >> My O/S is Windows XP SP2 I use 512 MB RAM. En Tue, 08 Apr 2008 06:02:00 -0300, Vladimir Kropylev escribi?: > yes, ths is known problem. I can just recomend you to use Linux or > FreeBSD, though cygwin maybe also possible Disregard that comment. -- Gabriel Genellina From steve at holdenweb.com Sat Apr 12 17:58:22 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 17:58:22 -0400 Subject: Tremendous slowdown due to garbage collection In-Reply-To: <32e2acc1-97cb-4911-bb0c-67965b5ff113@2g2000hsn.googlegroups.com> References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> <32e2acc1-97cb-4911-bb0c-67965b5ff113@2g2000hsn.googlegroups.com> Message-ID: andreas.eisele at gmail.com wrote: >> Martin said that the default settings for the cyclic gc works for most >> people. > > I agree. > >> Your test case has found a pathologic corner case which is *not* >> typical for common application but typical for an artificial benchmark. > > I agree that my "corner" is not typical, but I strongly disagree with > the classification as pathological. The only feature of my test case > that is not typical is the huge number of distinct objects that are > allocated. I admit that 1E7 objects is today still fairly untypical, > but there is nothing pathological about it, it is just bigger. I is > about as pathological as a file size >2G, which a few years ago seemed > so outrageous that no OS bothered to support it, but is fairly common > nowadays, so that a lack of support would appear as an arbitrary and > unmotivated limitation nowadays. We all enjoy seeing Python adopted on > a large scale and used by a broad community, so we should not accept > arbitrary size limits. You could call a string with more than 2GB > pathological, but I very much appreciate the fact that Python supports > such strings for the few cases where they are needed (on a 64 bit > architecture). Now a O(N*N) effort for large numbers of objects isn't > such a hard limit, but in practice boils down to the same effect, that > people cannot use Python in such circumstances. I would prefer it very > much if such "soft limits" could be avoided as well. > > Given there is a fairly simple workaround (thanks again to Amaury!), > the issue is not urgent, but I still think it is important in the long > run. > >> Python is optimized for regular apps, not for benchmark (like some video >> drivers). >> > > I still think it would be worthwhile to support very large numbers of > objects in a way that they can just be used, without knowledge of > special tricks, and I would be fairly optimistic that those who have > designed the current GC schemes could generalize them slightly so that > these marginal cases will work better without imposing a penalty on > the more typical cases. > I believe you are making surmises outside your range of competence there. While your faith in the developers is touching, the garbage collection scheme is something that has received a lot of attention with respect to performance under typical workloads over the years. By the way, the term "pathological" (which I believe I also used about your application) doesn't imply anything bad about your program: it's merely a shorthand way of saying that it triggers this undesirable behavior in a garbage collector that is mostly satisfactory for other purposes. >> By the way you shouldn't use range for large ranges of more than a >> thousand items. xrange() should be faster and it will definitely use >> much less memory - and memory Python 2.5 and older will never release >> again. I'm going to fix the issue for Python 2.6 and 3.0. >> > > Thanks for this hint, and for the work on the newer versions. This is > very much appreciated. > Anyway, I'm glad Amaury's workaround has solved your problem at least temporarily. Your type of workload may become more typical over time, but at the moment you are probably somewhat ahead of the mainstream here. If you know there can't be any recoverable cycles then you are probably better off just telling the garbage collector that you know better than it does. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From zillow10 at googlemail.com Thu Apr 3 18:27:47 2008 From: zillow10 at googlemail.com (zillow10 at googlemail.com) Date: Thu, 3 Apr 2008 15:27:47 -0700 (PDT) Subject: id functions of ints, floats and strings Message-ID: Hi all, I've been playing around with the identity function id() for different types of objects, and I think I understand its behaviour when it comes to objects like lists and tuples in which case an assignment r2 = r1 (r1 refers to an existing object) creates an alias r2 that refers to the same object as r1. In this case id(r1) == id(r2) (or, if you like: r1 is r2). However for r1, r2 assigned as follows: r1 = [1, 2, 3] and r2 = [1, 2, 3], (r1 is r2) is False, even if r1==r2, etc. ...this is all very well. Therefore, it seems that id(r) can be interpreted as the address of the object that 'r' refers to. My observations of its behaviour when comparing ints, floats and strings have raised some questions in my mind, though. Consider the following examples: ######################################################################### # (1) turns out to be true a = 10 b = 10 print a is b # (2) turns out to be false f = 10.0 g = 10.0 print f is g # behaviour when a list or tuple contains the same elements ("same" meaning same type and value): # define the following function, that checks if all the elements in an iterable object are equal: def areAllElementsEqual(iterable): return reduce(lambda x, y: x == y and x, iterable) != False # (3) checking if ids of all list elements are the same for different cases: a = 3*[1]; areAllElementsEqual([id(i) for i in a]) # True b = [1, 1, 1]; areAllElementsEqual([id(i) for i in b]) # True f = 3*[1.0]; areAllElementsEqual([id(i) for i in f]) # True g = [1.0, 1.0, 1.0]; areAllElementsEqual([id(i) for i in g]) # True g1 = [1.0, 1.0, 0.5+0.5]; areAllElementsEqual([id(i) for i in g1]) # False # (4) two equal floats defined inside a function body behave differently than case (1): def func(): f = 10.0 g = 10.0 return f is g print func() # True ###################################################### I didn't mention any examples with strings; they behaved like ints with respect to their id properties for all the cases I tried. While I have no particular qualms about the behaviour, I have the following questions: 1) Which of the above behaviours are reliable? For example, does a1 = a2 for ints and strings always imply that a1 is a2? 2) From the programmer's perspective, are ids of ints, floats and string of any practical significance at all (since these types are immutable)? 3) Does the behaviour of ids for lists and tuples of the same element (of type int, string and sometimes even float), imply that the tuple a = (1,) takes (nearly) the same storage space as a = 10000*(1,)? (What about a list, where elements can be changed at will?) Would appreciate your responses... AK From steve at holdenweb.com Sat Apr 12 17:44:23 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 17:44:23 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> Message-ID: <48012D37.50001@holdenweb.com> Victor Subervi wrote: > in line... > > On Fri, Apr 11, 2008 at 2:05 PM, Steve Holden > wrote: > > Victor Subervi wrote: > > I have worked on this many hours a day for two weeks. If there is an > > easier way to do it, just take a minute or two and point it out. Have > > you heard of the Law of Diminishing Returns? I have passed it > long ago. > > I no longer want to waste time trying to guess at what you are > trying to > > tell me. > > Victor > > > > On Fri, Apr 11, 2008 at 8:55 AM, Steve Holden > > > >> wrote: > Where you have > > content = col_fields[0][14].tostring() > pic = "tmp" + str(i) + ".jpg" > img = open(pic, "w") > img.write(content) > print '

' % pic > img.close() > > instead write > > print content > > > Like this, I presume? > Yes. You might need to use content.tostring() - I am not familiar with MySQL blobs. > img = open(pic, "w") > img.write(content) > print ' value="%s">' % pic > print content > # print '

\n' % pic > Does not work _at_all LOL. You will recall, also, that you once gave me > a line similar to the one commented out (but without writing then > opening the file). THAT did not work, either. So now do you see why I am > frustrated?? > > > > Then browse to the URL this program serves and you will see the image > (assuming you are still sending the image/jpeg content type). > > > Well, as I mentioned before, I am sending text/html because the page, > like almost all web pages, has a whole lot more content than just > images. Or, perhaps you are suggesting I build my pages in frames, and > have a frame for every image. Unsightly! > Dear Victor: If you cannot understand, after being told several times by different people, that pages with images in them are achieved by multiple HTTP requests, then there is little I can do to help you. > > Once you > can see the image, THEN you can write a page that refers to it. Until > you start serving the image (NOT pseudo-html with image data embedded in > it) nothing else will work. > > > My solution works just fine, thank you. It is inelegant. But it now > appears to me, and I dare say rather clearly, that this inelegance is > the fault of python itself. Perhaps this should be brought to Guido?s > attention. > Victor You can say it as clearly as you like, but if you say it too loudly you will make a laughing stock of yourself. You surely don't think that a language that supports Zope, TurboGears, Pylons and Django (to name but the first four that come to mind) is unsuitable for web programming? Please, do yourself a big favor and persist with this until you understand what you are doing wrong and how to serve dynamic images. It appears that the learning may be painful, but I guarantee it will be worthwhile. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From j.spies at hccnet.nl Mon Apr 7 16:31:20 2008 From: j.spies at hccnet.nl (Jaap Spies) Date: Mon, 07 Apr 2008 22:31:20 +0200 Subject: Mathematical Python Library In-Reply-To: References: Message-ID: <298b8$47fa8498$d4785a98$5420@cache1.tilbu1.nb.home.nl> Cameron Laird wrote: > In article , > Dennis Lee Bieber wrote: >> On Mon, 7 Apr 2008 09:05:57 -0700 (PDT), mc >> declaimed the following in comp.lang.python: >> >>> I'm looking for a library which can do mathematical stuff like >>> solving equations. Or calculation the nulls of a function and so on. >>> Does anyone know one? >>> >> Other than coding some serial/USB interface to an HP50g... >> >> Maybe SAGE? >> sympy? >> >> http://www.google.com/search?hl=en&q=python+computer+algebra+system&btnG=Google+Search > . > . > . > While there are in fact several possible approaches to symbolic mani- > pulation of "mathematical stuff" in Python, I STRONGLY recommend that > beginners in the area look into SAGE , > already mentioned above by Dennis. SAGE is life-altering software, for > those with a life focused on mathematics or related science or > engineering. +1 Jaap From hardcoded.software at gmail.com Fri Apr 25 11:23:12 2008 From: hardcoded.software at gmail.com (Virgil Dupras) Date: Fri, 25 Apr 2008 08:23:12 -0700 (PDT) Subject: Subclassing list the right way? References: Message-ID: <163ddc5c-cb17-416b-b85c-0a8945d490a9@e39g2000hsf.googlegroups.com> On Apr 25, 4:03?pm, Kirk Strauser wrote: > I want to subclass list so that each value in it is calculated at call > time. ?I had initially thought I could do that by defining my own > __getitem__, but 1) apparently that's deprecated (although I can't > find that; got a link?), and 2) it doesn't work. > > For example: > > >>> class Foo(list): > > ... ? ? def __getitem__(self, index): > ... ? ? ? ? ? ? return 5 > ...>>> a = Foo([1, 2, 3, 4, 5]) > >>> print a > [1, 2, 3, 4, 5] > >>> print a[2:4] > [3, 4] > >>> print a[3] > > 5 > > I first expected that to instead behave like: > > >>> print a > [5, 5, 5, 5, 5] > >>> print a[2:4] > > [5, 5] > > Is there a "right" way to do this? > -- > Kirk Strauser I'm not totally sure, but I think you have to implement __getslice__ as well, even if it is a deprecated magic function. My guess for this is that list implements __getslice__ and when you ask for a slice, Python checks for __getslice__ first, and then, if you don't have it, calls __getitem__. And since list has it, it's what is called. As for "print a", you have to override __str__ and __repr__ too. As a side note, the second argument to __getitem__ is not index, it's key, because this argument can either be an int index or a slice() object. From hobgoodoreneyhb at gmail.com Tue Apr 22 11:40:19 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:40:19 -0700 (PDT) Subject: cash organizer keygen Message-ID: cash organizer keygen http://cracks.12w.net F R E E C R A C K S From lbonafide at yahoo.com Mon Apr 14 09:59:43 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Mon, 14 Apr 2008 06:59:43 -0700 (PDT) Subject: How to make python run faster References: <0baa301a-ec8c-48ef-b30e-f9c80f72e5af@u12g2000prd.googlegroups.com> Message-ID: On Apr 14, 8:48 am, ??? wrote: > But, it is still not as fast as 1. So if speed is the #1 design goal, use pure C. If not, develop in pure Python and, if the application is too slow, profile the code and look for bottlenecks that can be optimized. There's a good chance that they can be resolved algorithmically, not by simply dropping down to C. From gagsl-py2 at yahoo.com.ar Wed Apr 30 05:56:38 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 30 Apr 2008 06:56:38 -0300 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> Message-ID: En Wed, 30 Apr 2008 05:00:26 -0300, Arnaud Delobelle escribi?: > "Gabriel Genellina" writes: > >> En Wed, 30 Apr 2008 04:19:22 -0300, SL escribi?: >> >>> "Lutz Horn" schreef in bericht >>> news:mailman.360.1209537877.12834.python-list at python.org... >>>> >>>> So just for completion, the solution is: >>>> >>>>>>> chr(ord('a') + 1) >>>> 'b' >>> >>> thanks :) I'm a beginner and I was expecting this to be a member of >>> string so I couldnt find it anywhere in the docs. >> >> And that's a very reasonable place to search; I think chr and ord are >> builtin functions (and not str methods) just by an historical >> accident. (Or is there any other reason? what's wrong with "a".ord() >> or str.from_ordinal(65))? > > > Not a reason, but doesn't ord() word with unicode as well? Yes, so ord() could be an instance method of both str and unicode, like upper(), strip(), and all of them... And str.from_ordinal(n)==chr(n), unicode.from_ordinal(n)==unichr(n) -- Gabriel Genellina From malaclypse2 at gmail.com Fri Apr 25 11:41:52 2008 From: malaclypse2 at gmail.com (Jerry Hill) Date: Fri, 25 Apr 2008 11:41:52 -0400 Subject: why does the following with Queue, q.put('\x02', True) not put it in the queue? In-Reply-To: <4811F484.1070901@mydeskfriend.com> References: <6eb550ae-dca4-4371-856a-15bc9625f93c@z72g2000hsb.googlegroups.com> <4811F484.1070901@mydeskfriend.com> Message-ID: <16651e80804250841ta242229ob7f996e229ff4310@mail.gmail.com> On Fri, Apr 25, 2008 at 11:11 AM, Gabriel Rossetti wrote: > yes, if you do it that way (s = '\x02') it works, but I read the data from > a file, and I that way it doesn't work.... It does work (using Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32) import Queue f = open('temp', 'w') f.write('\x02') f.close() f = open('temp', 'r') ch = f.read(1) f.close() print repr(ch) q = Queue.Queue(0) q.put(ch, True) print len(q.queue) prints the following: '\x02' 1 Perhaps you could put together an example that actually shows the behavior you're seeing. I'm not super familiar with Queue.Queue internals, but should you be accessing the undocumented q.queue (the internal deque of the Queue instance) directly? Shouldn't you be using the documented q.qsize() interface instead? -- Jerry From steve at holdenweb.com Wed Apr 2 11:59:53 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 02 Apr 2008 11:59:53 -0400 Subject: ThreadingTCPServer: sock.recv() doesn't block? In-Reply-To: References: Message-ID: Prepscius, Colin (IT) wrote: > So I'm using the ThreadingTCPServer from the python standard library > SocketServer, and calling serve_forever on it. In my handler's handle > method, I call self.request.recv(x) in a loop until I've received n > bytes. But recv() returns immediately with nothing, over and over. It > all still works, but my cpu pegs. I thought socketc.recv() was supposed > to block. Anybody know if I'm doing something wrong? > It would be easier to say if we could actually see the code for your handle() method - indeed, the whole server wouldn't hurt. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bvidinli at gmail.com Tue Apr 15 07:04:41 2008 From: bvidinli at gmail.com (bvidinli) Date: Tue, 15 Apr 2008 14:04:41 +0300 Subject: where is pythoncard program ? Message-ID: <36e8a7020804150404g755bee0eg2924e0dfe71b0a7a@mail.gmail.com> i installed pythoncard, but i could not find how to start it ? where can i find its executable/binary ? or menu item ? or command line that i should enter ? thanks. -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From victorsubervi at gmail.com Wed Apr 30 12:03:34 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 30 Apr 2008 11:03:34 -0500 Subject: Colors for Rows In-Reply-To: <20080430120116.c07f028f.darcy@druid.net> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> <20080429121105.f10c3862.darcy@druid.net> <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> <1209495803.5173.11.camel@aalcdl07.lib.unc.edu> <20080429153930.a6eddea6.darcy@druid.net> <1209500446.5510.4.camel@aalcdl07.lib.unc.edu> <4dc0cfea0804300857h6a7a8aa6l25aa0a3e82da12c0@mail.gmail.com> <20080430120116.c07f028f.darcy@druid.net> Message-ID: <4dc0cfea0804300903w725aa357wbe082269e1add170@mail.gmail.com> The problem was that z was not incrementing. It kept getting reset to 3, then incremented to 4 immediately, and reset back to 3. Stupid :/ On Wed, Apr 30, 2008 at 11:01 AM, D'Arcy J.M. Cain wrote: > On Wed, 30 Apr 2008 10:57:44 -0500 > "Victor Subervi" wrote: > > Thank you all. You helped clean up my code. The stupid mistake was in > where > > I set the initial value of the variable z. > > Really? I thought that it was odd to start in the middle of your > colour list but it didn't seem like it was an error. What do you think > was wrong with it? > > -- > D'Arcy J.M. Cain | Democracy is three wolves > http://www.druid.net/darcy/ | and a sheep voting on > +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gruszczy at gmail.com Wed Apr 23 12:13:34 2008 From: gruszczy at gmail.com (=?UTF-8?Q?Filip_Gruszczy=C5=84ski?=) Date: Wed, 23 Apr 2008 18:13:34 +0200 Subject: Explicit variable declaration In-Reply-To: References: <1be78d220804230252n4faa34e6v90b482080750e0cb@mail.gmail.com> Message-ID: <1be78d220804230913nd0b31a4g8480bd2aa9988c86@mail.gmail.com> Wow! This is extremely easy and seems to do exactly what I need. Those decorators are pretty powerful then. Thanks for your help, I'll try to use this. > def uses(names): > def decorator(f): > used = set(f.func_code.co_varnames) > declared = set(names.split()) > undeclared = used-declared > unused = declared-used > if undeclared: > raise ValueError("%s: %s assigned but not declared" > % (f.func_name, ','.join(undeclared))) > if unused: > raise ValueError("%s: %s declared but never used" > % (f.func_name, ','.join(unused))) > return f > return decorator > > Used something like this: > > >>> @uses("x y") > def f(x): > y = x+1 > return z > > >>> @uses("x y z") > def f(x): > y = x+1 > return z > > > Traceback (most recent call last): > File "", line 1, in > @uses("x y z") > File "", line 10, in decorator > raise ValueError("%s: %s declared but never used" % (f.func_name, > ','.join(unused))) > ValueError: f: z declared but never used > >>> @uses("x") > def f(x): > y = x+1 > return z > > > Traceback (most recent call last): > File "", line 1, in > @uses("x") > File "", line 8, in decorator > raise ValueError("%s: %s assigned but not declared" % (f.func_name, > ','.join(undeclared))) > ValueError: f: y assigned but not declared > > > >>> > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Filip Gruszczy?ski From skanemupp at yahoo.se Sat Apr 5 16:17:45 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 13:17:45 -0700 (PDT) Subject: Tkinter, add pressed buttons onto string display string, how to? References: Message-ID: <57605958-5589-4ebe-abdf-73c2d14c8a82@u10g2000prn.googlegroups.com> > input = "hello" > input += " world" > print input this i know. im wondering how to handle the variable in the actual program. this exception i get: Exception in Tkinter callback Traceback (most recent call last): File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ return self.func(*args) File "C:\Users\saftarn\Desktop\guiexperiments\calculatorGUI.py", line 48, in self.btnDisplay = Button(self,text='+',command=lambda n="+":self.Display(n),width=1,height=1) File "C:\Users\saftarn\Desktop\guiexperiments\calculatorGUI.py", line 92, in Display str = number + str UnboundLocalError: local variable 'str' referenced before assignment > A caculator program is pretty complex. Based on your rudimentary > questions, I don't think you have enough programming experience to > tackle a project like that yet. nah ill be fine. im new to python, not to programming. From hardcoded.software at gmail.com Thu Apr 24 16:38:47 2008 From: hardcoded.software at gmail.com (Virgil Dupras) Date: Thu, 24 Apr 2008 13:38:47 -0700 (PDT) Subject: Class Inheritance - What am I doing wrong? References: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> Message-ID: <1b90518a-e6c6-4aa7-8f59-cc197797b4fe@c65g2000hsa.googlegroups.com> On Apr 24, 10:22?pm, Brian Munroe wrote: > My example: > > class A(object): > > ? ? ? ? def __init__(self, name): > ? ? ? ? ? ? ? ? self.__name = name > > ? ? ? ? def getName(self): > ? ? ? ? ? ? ? ? return self.__name > > class B(A): > > ? ? ? ? def __init__(self,name=None): > ? ? ? ? ? ? ? ? super(A,self).__init__() > > ? ? ? ? def setName(self, name): > ? ? ? ? ? ? ? ? self.__name = name > > if __name__ == '__main__': > > ? ? ? ? a = A('class a') > ? ? ? ? print a.getName() > > ? ? ? ? b = B('class b') > ? ? ? ? print b.getName() > > ? ? ? ? b.setName('class b, reset') > ? ? ? ? print b.getName() > > I get the following error: > > mtinky:~ brian$ python teste.py > class a > Traceback (most recent call last): > ? File "teste.py", line 23, in > ? ? print b.getName() > ? File "teste.py", line 7, in getName > ? ? return self.__name > AttributeError: 'B' object has no attribute '_A__name' > > Am I *not* using super() correctly? ?Also, did I define my the class B > constructor correctly? Exactly, you used it wrong. It's super(B, self). But before you start using super() everywhere, read this: http://fuhm.net/super-harmful/ I love Python, but super() is one of those tricky things... From NikitaTheSpider at gmail.com Thu Apr 3 18:23:16 2008 From: NikitaTheSpider at gmail.com (Nikita the Spider) Date: Thu, 03 Apr 2008 18:23:16 -0400 Subject: developing web spider References: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> <47f3ab52$0$36346$742ec2ed@news.sonic.net> Message-ID: In article <47f3ab52$0$36346$742ec2ed at news.sonic.net>, John Nagle wrote: > abeen wrote: > > Hello, > > > > I would want to know which could be the best programming language for > > developing web spider. > > More information about the spider, much better,, > > As someone who actually runs a Python based web spider in production, I > should comment. > > You need a very robust parser to parse real world HTML. > Even the stock version of BeautifulSoup isn't good enough. We have a > modified version of BeautifulSoup, plus other library patches, just to > keep the parser from blowing up or swallowing the entire page into > a malformed comment or tag. Browsers are incredibly forgiving in this > regard. > > "urllib" needs extra robustness, too. The stock timeout mechanism > isn't good enough. Some sites do weird things, like open TCP connections > for HTTP but not send anything. > > Python is on the slow side for this. Python is about 60x > slower than C, and for this application, you definitely see that. > A Python based spider will go compute bound for seconds per page > on big pages. The C-based parsers for XML/HTML aren't robust enough for > this application. And then there's the Global Interpreter Lock; a multicore > CPU won't help a multithreaded compute-bound process. > > I'd recommend using Java or C# for new work in this area > if you're doing this in volume. Otherwise, you'll need to buy > many, many extra racks of servers. In practice, the big spiders > are in C or C++. I'll throw in an opinion from a different viewpoint. I'm really happy I used Python to develop my spider. I like the language, it has a good library and good community support and 3rd party modules. John, I don't know what your spider does, but you face some hurdles that I don't. For instance, since I'm focused on validation, if bizarre (invalid) HTML makes a page look like garbage, I just report the problem to the author. Performance isn't a big problem for me, either, since this is not a crawl-as-fast-as-you-can application. What you said sounds to me entirely correct for your application. The OP who asked for as much information as possible didn't give a whole lot to start with. -- Philip http://NikitaTheSpider.com/ Whole-site HTML validation, link checking and more From s0suk3 at gmail.com Sun Apr 27 14:40:05 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Sun, 27 Apr 2008 11:40:05 -0700 (PDT) Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> <48131f57$0$14357$e4fe514c@news.xs4all.nl> Message-ID: <4ca7b83c-0ca4-4e38-95e5-264780d30ec0@56g2000hsm.googlegroups.com> On Apr 26, 7:25 am, Irmen de Jong wrote: > s0s... at gmail.com wrote: > > Until now, I've been > > doing this little trick: > > > data = client.recv(256) > > new = data > > while len(new) == 256: > > new = client.recv(256) > > data += new > > Are you aware that recv() will not always return the amount of bytes asked for? > (send() is similar; it doesn't guarantee that the full buffer you pass to it will be > sent at once) > > I suggest reading this:http://www.amk.ca/python/howto/sockets/sockets.html > > --irmen So every time I use I want to send some thing, I must use totalsent = 0 while sent < len(data): sent = sock.send(data[totalsent:]) totalsent += sent instead of a simple sock.send(data)? That's kind of nasty. Also, is it better then to use sockets as file objects? Maybe unbuffered? From munrobaggers at gmail.com Mon Apr 28 22:28:02 2008 From: munrobaggers at gmail.com (Stormbringer) Date: Mon, 28 Apr 2008 19:28:02 -0700 (PDT) Subject: xcode able to run script? References: <31c47061-7038-4868-8422-a8da0f6d7437@m45g2000hsb.googlegroups.com> Message-ID: On Apr 28, 1:52?pm, Alex Pavluck wrote: > Does anyone know if it is possible to test your scripts from within > the xcode editor? ?I am currently using Uilipad on windows and there > is a sub window that lets you view your output when you launch the > script from within the ide. ?hopefully this makes sense. > > thanks, Alex Use SPE, it has this functionality plus a lot more.You can get it at: http://pythonide.blogspot.com/ From kloro2006 at gmail.com Tue Apr 15 20:27:10 2008 From: kloro2006 at gmail.com (tom arnall) Date: Tue, 15 Apr 2008 17:27:10 -0700 Subject: How to have unittest tests to be executed in the order they appear? In-Reply-To: <87zlru7le2.fsf@benfinney.id.au> References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> <87zlru7le2.fsf@benfinney.id.au> Message-ID: <200804151727.10983.kloro2006@gmail.com> On Tuesday 15 April 2008 16:23, Ben Finney wrote: > "Giampaolo Rodola'" writes: > > Is there a way to force unittest to run test methods in the order > > they appear? > > No, and this is a good thing. > > Your test cases should *not* depend on any state from other test > cases; they should function equally well when executed in any > arbitrary sequence. Dependencies between separate test cases (e.g. > "they only work correctly when run in a specific sequence") means > you're not isolating them properly. > > Use the TestCase.setUp and TestCase.tearDown methods to handle any > fixtures needed by test cases in each class of test cases. That way, > the fixtures will be set up and torn down between every test case. > Find out about test fixtures in the documentation for unittest > . > > -- > \ "All my life I've had one dream: to achieve my many goals." -- | > `\ Homer, _The Simpsons_ | > _o__) | > Ben Finney a better approach maybe is just to write your own test harness. it's trivial to write a minimal system, which is then a solid basis for the enhancements which are best for you. tom arnall arcata From bronger at physik.rwth-aachen.de Wed Apr 30 11:41:22 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 30 Apr 2008 17:41:22 +0200 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> <87tzhjy4u2.fsf@physik.rwth-aachen.de> <67rfg6F2qrcooU1@mid.uni-berlin.de> Message-ID: <87ve1zcpul.fsf@physik.rwth-aachen.de> Hall?chen! Diez B. Roggisch writes: >> However, join() is really bizarre. The list rather than the >> separator should be the leading actor. > > Certainly *not*! This would be the way ruby does it, and IMHO it > does not make sense to add join as a string-processing related > method/functionality to a general purpose sequence type. Okay, my wording was unfortunate. However, I've already twice (before and after the above posting of mine) said what I mean, namely join(list, separator), possibly with a default value for "separator". Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From kothari.alok at gmail.com Tue Apr 1 16:23:16 2008 From: kothari.alok at gmail.com (Alok Kothari) Date: Wed, 2 Apr 2008 01:53:16 +0530 Subject: XML Parsing In-Reply-To: <4660fe300804011301t64934dd0g921cd282d3af8917@mail.gmail.com> References: <4660fe300804011301t64934dd0g921cd282d3af8917@mail.gmail.com> Message-ID: Thanks ! it worked ! On Wed, Apr 2, 2008 at 1:31 AM, Konstantin Veretennicov < kveretennicov at gmail.com> wrote: > On Tue, Apr 1, 2008 at 10:42 PM, Alok Kothari > wrote: > > > Hello, > > I am new to XML parsing.Could you kindly tell me whats the > > problem with the following code: > > > > import xml.dom.minidom > > import xml.parsers.expat > > document = """Lettermanis > token>betterthan > token>JayLeno""" > > > > This document is not well-formed. It doesn't have root element. > > ... > > > > > > Traceback (most recent call last): > > File "C:/Python25/Programs/eg.py", line 20, in > > p.Parse(document, 1) > > ExpatError: junk after document element: line 1, column 33 > > > > Told ya :) > > > Try wrapping your document in root element, like > "......" > > -- > kv > -------------- next part -------------- An HTML attachment was scrubbed... URL: From upton at virginia.edu Wed Apr 23 12:27:42 2008 From: upton at virginia.edu (Dan Upton) Date: Wed, 23 Apr 2008 12:27:42 -0400 Subject: MESSAGE RESPONSE In-Reply-To: <678v5qF2me5rvU1@mid.uni-berlin.de> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> <678v5qF2me5rvU1@mid.uni-berlin.de> Message-ID: <5504f9ac0804230927ncfdb91buf7fa3e181f8a9237@mail.gmail.com> On Wed, Apr 23, 2008 at 10:24 AM, Diez B. Roggisch wrote: > Blubaugh, David A. schrieb: > > > Is there a way to block these messages. I do not want to be caught > > with filth such as this material. I could lose my job with Belcan with > > evil messages such as these messages. > > > > If I (or *anybody*) knew how to block these messages, he or she would sell > the resulting spam-filter for a fortunen that roughly amasses the one of > scrooge mc duck - and go live on the bahamas or even buy them. > > Put up with it. It's (unfortunately) part of ze internet tubes. > And as such, I find it hard to believe you could lose your job over it. From duncan.booth at invalid.invalid Wed Apr 23 11:10:49 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 23 Apr 2008 15:10:49 GMT Subject: Explicit variable declaration References: <1be78d220804230252n4faa34e6v90b482080750e0cb@mail.gmail.com> Message-ID: Steve Holden wrote: > Filip Gruszczy?"ski wrote: >> Just declaring, that they exist. Saying, that in certain function >> there would appear only specified variables. Like in smalltalk, if I >> remember correctly. >> > Icon has (had?) the same feature: if the "local" statement appeared then > the names listed in it could be assigned in the local namespace, and > assignment to other names wasn't allowed. Python being what it is, it is easy enough to add support for declaring at the top of a function which local variables it uses. I expect that actually using such functionality will waste more time than it saves, but here's a simple enough implementation: def uses(names): def decorator(f): used = set(f.func_code.co_varnames) declared = set(names.split()) undeclared = used-declared unused = declared-used if undeclared: raise ValueError("%s: %s assigned but not declared" % (f.func_name, ','.join(undeclared))) if unused: raise ValueError("%s: %s declared but never used" % (f.func_name, ','.join(unused))) return f return decorator Used something like this: >>> @uses("x y") def f(x): y = x+1 return z >>> @uses("x y z") def f(x): y = x+1 return z Traceback (most recent call last): File "", line 1, in @uses("x y z") File "", line 10, in decorator raise ValueError("%s: %s declared but never used" % (f.func_name, ','.join(unused))) ValueError: f: z declared but never used >>> @uses("x") def f(x): y = x+1 return z Traceback (most recent call last): File "", line 1, in @uses("x") File "", line 8, in decorator raise ValueError("%s: %s assigned but not declared" % (f.func_name, ','.join(undeclared))) ValueError: f: y assigned but not declared >>> From sjmachin at lexicon.net Fri Apr 25 17:34:34 2008 From: sjmachin at lexicon.net (John Machin) Date: Fri, 25 Apr 2008 14:34:34 -0700 (PDT) Subject: problem with unicode References: <26fcc207-b864-42c7-afb3-c6945e5fe29f@m44g2000hsc.googlegroups.com> <67dvg8F2nomm6U1@mid.individual.net> <67eu0rF2ogf6qU1@mid.individual.net> Message-ID: <61e7b742-4e0d-4a9d-a494-84e6c07115b1@w5g2000prd.googlegroups.com> On Apr 26, 6:42 am, Bjoern Schliessmann wrote: > John Machin wrote: > > On Apr 25, 10:01 pm, Bjoern Schliessmann >> >>> media="x???[?" > >> >>> print repr(media.decode("utf-8")) > > >> u'x\u30ef\u30e6\u30ed[\u30e8' > > (dang, KNode doesn't autodetect encodings ...) > > > But that_unicode_string.encode("utf-8") produces > > 'x\xe3\x83\xaf\xe3\x83\xa6\xe3\x83\xad[\xe3\x83\xa8' > > which does not contain the complained-about byte 0x9c in position > > 1 (or any other position) -- how can that be? > > Probably the OP used a different encoding. That seems even more > likely given the fact that his postings have a Japanese encoding > (but this one doesn't produce any 0x9c, either). > I've tried just about every Japanese encoding there is. None of those produced 0x9c. Perhaps the OP might like to tell us a bit more about "# media is a binary string (mysql escaped zipped file)". mysql, escaped, zipped -- we could be three layers of onion skin away from enlightenment. From wwzaygvm at gmail.com Wed Apr 16 17:03:48 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 14:03:48 -0700 (PDT) Subject: stalker crack Message-ID: <13009466-fc07-4c7d-b50b-58d78b5bf650@f63g2000hsf.googlegroups.com> stalker crack http://cracks.12w.net F R E E C R A C K S From jrobertoleite at gmail.com Tue Apr 29 09:22:00 2008 From: jrobertoleite at gmail.com (=?iso-8859-1?Q?Jos=E9_Roberto?=) Date: Tue, 29 Apr 2008 10:22:00 -0300 Subject: Windows Printing using win32print Message-ID: <58067CF3E0784DA3BEF22324FD03969A@hadron> Ol? KellyK! I have read your comentary about how to print with python in windows using win32print. I have trying to use in my problem : print a figure (.jpg, .png...etc) could you help me? Thanks a lot JRoberto -------------- next part -------------- An HTML attachment was scrubbed... URL: From ed at leafe.com Tue Apr 1 21:44:45 2008 From: ed at leafe.com (Ed Leafe) Date: Tue, 1 Apr 2008 20:44:45 -0500 Subject: class super method In-Reply-To: References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> <0eb3ee4e-82e2-419a-8e7b-4931f7b4effa@c26g2000prf.googlegroups.com> Message-ID: On Apr 1, 2008, at 6:10 PM, Steve Holden wrote: > Ed is a good enough designer to avoid the corner cases. Strangely > enough > the one place where I have ended up making significant use of super() > was in providing mixins for wxPython interface classes! Thanks much for the compliment. Yes, wrapping the disparate and confusing wxPython classes to have a consistent interface is where we also make the most use of super(), but our database wrappers also provide consistent functionality to all the dbapi cursors, no matter what the backend database may be. The only reason this works is that we are working with a single known class interface; we control all our own mixin class designs. With the wxPython stuff, each class has a well-defined set of methods and method signatures, and with the database stuff, we only mixin with the dbapi-standard methods, and avoid hooking into module-specific enhancements. My point in these postings is that working with multiple inheritance is fraught with potential pitfalls; super() doesn't create these pitfalls, although it can make it easier to fall into them. If you try to create a PotBelliedElephant class by using MI with a PotBelliedPig class and an Elephant class, well, you *should* crash and burn, whether you use super() or not. http://en.wikipedia.org/wiki/An_Elephant_Makes_Love_to_a_Pig -- Ed Leafe From wescpy at gmail.com Tue Apr 1 13:43:07 2008 From: wescpy at gmail.com (wesley chun) Date: Tue, 1 Apr 2008 10:43:07 -0700 Subject: [ANN] Python courses this Fall In-Reply-To: <78b3a9580708230043k35ff6729vc7fefefb2068531b@mail.gmail.com> References: <78b3a9580708230043k35ff6729vc7fefefb2068531b@mail.gmail.com> Message-ID: <78b3a9580804011043s11572e6eld7993e12f8df29dc@mail.gmail.com> FINAL ANNOUNCEMENT Need to get up-to-speed with Python as quickly as possible? Come join me, Wesley Chun, author of Prentice-Hall's well-received "Core Python Programming," for another comprehensive intro course next month in beautiful Northern California! I look forward to meeting you! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (COMPREHENSIVE) INTRODUCTION TO PYTHON: Mon-Wed, 2008 May 5-7 Although this course may appear to those new to Python, it is also perfect those who have tinkered with it and want to "fill in the gaps" and/or want to get more in-depth formal training. It combines the best of both an introduction to the language as well as a "Python Internals" training course. We will immerse you in the world of Python in only a few days. We will show you more than just its syntax (which you don't really need a book to learn, right?). Knowing more about how Python works under the covers, including the relationship between data objects and memory management, will make you a much more effective Python programmer coming out of the gate. 3 hands-on labs each day will help hammer the concepts home. Come find out why Google, Yahoo!, Disney, ILM/LucasFilm, VMware, OLPC, NASA, Ubuntu, YouTube, and Red Hat all use Python. Users supporting or jumping to Plone, Zope, TurboGears, Django, Pylons, Jython, IronPython, and Mailman will also benefit! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - WHERE: near the San Francisco Airport (SFO/San Bruno), CA, USA WEB: http://cyberwebconsulting.com (click "Python Training") LOCALS: easy freeway (101/280/380) with lots of parking plus public transit (BART and CalTrain) access via the San Bruno stations, easily accessible from all parts of the Bay Area VISITORS: free shuttle to/from the airport, free high-speed internet, free breakfast and regular evening receptions; fully-equipped suites See website for costs, venue info, and registration. Discounts are available for multiple registrations as well as for teachers/students. Hope to see you there! -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall, (c)2007,2001 http://corepython.com wesley.j.chun :: wescpy-at-gmail.com python training and technical consulting cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com From andrew at acooke.org Tue Apr 15 05:01:39 2008 From: andrew at acooke.org (andrew cooke) Date: Tue, 15 Apr 2008 02:01:39 -0700 (PDT) Subject: Dynamic use of property() fails References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> <480461f8$0$20282$426a34cc@news.free.fr> Message-ID: ignore that - i was mistaken (my test was too complex). the problem seems to be that the attribute is deleted even though __delete__ is defined. i'll look at it tomorrow. thanks again, andrew On Apr 15, 4:50 am, andrew cooke wrote: > i tried code very similar after reading the first replies and found > that it did not work as expected on setting. for example, in > > person = Person() > person.age = 27 > > "age" is set in the instance's dictionary (as 27; the descriptor is > not called), which then shadows the definition of age in the class > dictionary. > > my understanding was that the descriptor is only called in the class > context, so would be called if, say, a subclass tried to redefine > age. but maybe i am still confused. > > i am about to go to sleep. i guess i will try your code exactly > tomorrow, but it looks very close to mine which showed this problem. > are you sure your solution works? > > thanks, > andrew From corvettecraz92 at gmail.com Wed Apr 9 08:25:19 2008 From: corvettecraz92 at gmail.com (corvettecraz92 at gmail.com) Date: Wed, 9 Apr 2008 05:25:19 -0700 (PDT) Subject: text adventure game problem References: Message-ID: On Apr 9, 1:24?am, Dennis Lee Bieber wrote: > On Tue, 8 Apr 2008 18:01:01 -0700 (PDT), corvettecra... at gmail.com > declaimed the following in comp.lang.python: > > > okay, I'm having this one problem with a text adventure game. It's > > kind of hard to explain, but I'll do my best. > > [code] > > > def prompt_kitchen(): > > ? ? global gold > > ? ? gold_taken = False > > ? ? while True: > > ? ? ? ? prompt_kit = raw_input('>') > > ? ? ? ? if prompt_kit == 'examine cabinet 1' and not gold_taken: > > ? ? ? ? ? ? print '''This cabinet has a lot of cups in it with all > > different > > designs and shapes. Where are the people anyway? How come there's > > nobody here? > > In one of the cups you find 8 gold.''' > > ? ? ? ? Forgive me, but.... Ugh! > > ? ? ? ? It looks like you are defining a function for each possible room > which incorporates code for the actions possible in that room... > > ? ? ? ? I suspect I'd try to create a generic room class which has as > attributes a dictionary of actions and a dictionary of movable objects. > Along with methods that work on objects... Working an action that digs > into other objects may take some doing. > > class gobject(object): > ? ? ? ? def examine(self, item=None): > ? ? ? ? ? ? ? ? if not item: item = self > ? ? ? ? ? ? ? ? print "you look at the %s; you see %s" % ? ? ? ? ? ? ?\ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?(item.desc, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ", ".join([k for k in item.subobjs.keys()])) > ? ? ? ? def go(self, direction): > ? ? ? ? ? ? ? ? return moves[directions] > ? ? ? ? def take(self, item): > ? ? ? ? ? ? ? ? itmobj = self.subobjs[item] > ? ? ? ? ? ? ? ? del self.subobjs[item] > ? ? ? ? ? ? ? ? return itmobj > ? ? ? ? def dropto(self, itemname, item): > ? ? ? ? ? ? ? ? self.subobjs[itemname] = item > > class movobj(gobject): > ? ? ? ? def __init__(self, desc="a vague blob", subobjs=None, moves=None): > ? ? ? ? ? ? ? ? ... > > class room(gobject): > ? ? ? ? def __init__(self, desc="a bare chamber", > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? subobjs=None, moves=None): > ? ? ? ? ? ? ? ? ... > > g1 = movobj(desc="8 pieces of gold") > c1 = movobj(desc="kitchen cabinet", subobjs={"gold" : g1}) > > rooms = {"kichen" : room(desc="you are in the kitchen", > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? subobjs={"cabinet" : c1}, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? moves={"n" : rooms["dining"], > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "out" : rooms["dining"} > ? ? ? ? ? ? ? ? "dining" : room(desc="you are in the dining room", > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? moves={"s" : rooms["kitchen"} } > > player = Player() > player.location = rooms["dining"] > player.run() > > {where run() incorporates the parser loop -- something like} > while True: > ? ? ? ? self.location.examine() > ? ? ? ? command = raw_input("=> ") > ? ? ? ? words = command.split() > ? ? ? ? if words[0] in ["go", "move", "walk", "run"]: > ? ? ? ? ? ? ? ? self.location = self.location.go(words[1]) > ? ? ? ? elif words[0] in ["look", "examine", "study"]: > ? ? ? ? ? ? ? ? self.location.examine(words[1]) > ? ? ? ? elif words[0] in ["take"]: > ? ? ? ? ? ? ? ? self.subobjs[words[1]] = self.location.take(words[1]) > ? ? ? ? elif words[0] in ["drop", "leave"]: > ? ? ? ? ? ? ? ? self.location.dropto(words[1], self.subobjs[words[1]]) > ? ? ? ? ? ? ? ? del self.subobjs[words[1]] > ? ? ? ? elif ... > > {of course, this ignores adding logic for failure to find the > subobj/move in the relevant dictionary -- which should result in > > ? ? ? ? I do not see that here > or > ? ? ? ? I can not go that direction > > objects should also have attributes to indicate if they can be thrown > (and what the results are), etc. > > ? ? ? ? In the above the display should look something like (ignoring the > unchecked for missing attributes) > > you look at the dining room, you see ? (need check for empty) > => > > go s > > you look at the kitchen, you see cabinet > => > > examine cabinet > > you look at the kitchen cabinet, you see gold > => > > -- > ? ? ? ? Wulfraed ? ? ? ?Dennis Lee Bieber ? ? ? ? ? ? ? KD6MOG > ? ? ? ? wlfr... at ix.netcom.com ? ? ? ? ? ? wulfr... at bestiaria.com > ? ? ? ? ? ? ? ? HTTP://wlfraed.home.netcom.com/ > ? ? ? ? (Bestiaria Support Staff: ? ? ? ? ? ? ? web-a... at bestiaria.com) > ? ? ? ? ? ? ? ? HTTP://www.bestiaria.com/ I can't even compile your code to see how it works, Dennis. I'm confused about what that does. From kyosohma at gmail.com Mon Apr 28 20:56:15 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Mon, 28 Apr 2008 19:56:15 -0500 Subject: Automating IE 6.0 In-Reply-To: <81B200F0AB075D4D95DA50067247FFBFF15DB8@mcc-es1.MCC.local> References: <81B200F0AB075D4D95DA50067247FFBFF15DB8@mcc-es1.MCC.local> Message-ID: <4816722F.90104@gmail.com> Michael Harris wrote: > > I tried to use the sample code to print a webpage via ie and I get the > following error: > > > > Traceback (most recent call last): > > File > "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", > line 310, in RunScript > > exec codeObject in __main__.__dict__ > > File "C:\ie.py", line 14, in > > ie.ExecWB(win32com.client.constants.OLECMDID_PRINT, > win32com.client.constants.OLECMDEXECOPT_DONTPROMPTUSER) > > NameError: name 'win32com' is not defined > > > > I have the win32com module installed and I clicked on makepy.py and selected Microsoft Internet Controls (1.1). The code was: > > from win32com.client import Dispatch > from time import sleep > ie = Dispatch("InternetExplorer.Application") > ie.Visible = 1 > ie.Navigate("http://www.cnn.com" ) > if ie.Busy: > sleep(2) > # print the current IE document without prompting the user for the > printerdialog > ie.ExecWB(win32com.client.constants.OLECMDID_PRINT,win32com.client.constants > .OLECMDEXECOPT_DONTPROMPTUSER) > > > Why am I getting this error? > I don't know why this is happening, so I recommend posting it to the pywin32 group: http://mail.python.org/mailman/listinfo/python-win32 You might also check out the PAMIE project: http://sourceforge.net/projects/pamie SendKeys would also work, but it's kind of messy. Mike From starsareblueandfaraway at gmail.com Fri Apr 4 02:49:18 2008 From: starsareblueandfaraway at gmail.com (Roy H. Han) Date: Fri, 4 Apr 2008 02:49:18 -0400 Subject: Question. In-Reply-To: <661622.4034.qm@web54009.mail.re2.yahoo.com> References: <661622.4034.qm@web54009.mail.re2.yahoo.com> Message-ID: <6a5569ec0804032349v1f342206o953c4ffe76919475@mail.gmail.com> Your boyfriend is pretty funny. I tried to get my girlfriend to learn Python a long time ago but she doesn't see value in it. On Fri, Apr 4, 2008 at 12:31 AM, AJay Grimmett wrote: > My name is Amanda. My boyfriend sent me an encrypted message by using > python. I guess he thought it would be fun for me to figure it out for > myself. This one involes a whole lotta numbers. I can't read or understand > what I am supposed to do to read this message. I mean, I've read the > information, but I seriously do not understand. He sent the .py file, and > the messages that were encrypted...i just don't know how to use it to get to > the message where I can read it. Is there anyway you or someone could do it > step by step..or just do it for me?! lol. I just need to know what this > says. Apparently it's an important message and I must read it. =] Thank you > for your time. I hope to hear from you soon! > -amanda > > ------------------------------ > You rock. That's why Blockbuster's offering you one month of Blockbuster > Total Access, > No Cost. > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bronger at physik.rwth-aachen.de Mon Apr 21 03:11:56 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Mon, 21 Apr 2008 09:11:56 +0200 Subject: Is massive spam coming from me on python lists? References: <480C2DC6.4050701@aim.com> Message-ID: <87r6cz3cn7.fsf@physik.rwth-aachen.de> Hall?chen! Sjoerd Mullender writes: > On 2008-04-21 08:01, Brian Vanderburg II wrote: > >> I've recently gotten more than too many spam messages and all say >> Sender: python-list-bounces+my=email.address at python.org. [...] > > That is just mailman (the mailing list software) keeping track of > things. By the way, why does mailman change the Message-IDs when tunneling postings to the newsgroup? This destroys the thread structure. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From lscbtfws at gmail.com Sat Apr 26 12:10:36 2008 From: lscbtfws at gmail.com (lscbtfws at gmail.com) Date: Sat, 26 Apr 2008 09:10:36 -0700 (PDT) Subject: empire earth 2 crack Message-ID: <41cf24db-d86d-49bf-87b7-60fe568c1f1f@b9g2000prh.googlegroups.com> empire earth 2 crack http://cracks.00bp.com F R E E C R A C K S From soundofmp32 at gmail.com Thu Apr 17 02:49:12 2008 From: soundofmp32 at gmail.com (ghgggu) Date: Wed, 16 Apr 2008 23:49:12 -0700 (PDT) Subject: the best ABOUT MP3 this year. have alook... Message-ID: <52e61b6c-fc73-4db2-8a65-a0c9bbbe4f18@8g2000hse.googlegroups.com> http://www.soundofmp3.info From canistel at gmail.com Thu Apr 10 14:43:23 2008 From: canistel at gmail.com (canistel at gmail.com) Date: Thu, 10 Apr 2008 11:43:23 -0700 (PDT) Subject: mod_python and storing binary form data Message-ID: <7e7194df-bd2c-444f-a458-6caa91ea4ace@x41g2000hsb.googlegroups.com> Hi, I have a little python webservice that I created, and in one of the methods I need to store some binary data that was "posted"... I want to do something like this, but it doesn't work. username = form.get("username", "") message = form.get("message", "") attachment = form.get("attachment", None) ... c.execute("""INSERT INTO Message (username, message, attachment) VALUES (%s, %s, %s)""", (username, message, attachment)) "attachment" is then some binary data that was posted, but when I look in the mysql database, I see values for the attachment field which look like: Field('attachment', '\x89PNG\r\n\x1a\n\x00\x00\... so it is storing something, just not my binary data (in this case a picture). the attachment column is a longblob in mysql. From usenet-mail at markshroyer.com Thu Apr 17 12:51:26 2008 From: usenet-mail at markshroyer.com (Mark Shroyer) Date: Thu, 17 Apr 2008 12:51:26 -0400 Subject: What can we do about all the spam that the list is getting? References: <259ab201-9d2b-4e4e-88a7-e2fe277f0066@a23g2000hsc.googlegroups.com> Message-ID: In article , Grant Edwards wrote: > On 2008-04-16, Mark Shroyer wrote: > > In article > >, > > Mensanator wrote: > > > >> On Apr 16, 12:01?pm, sr... at ferg.org wrote: > >> > What can we do about all the spam that comp.lang.python is getting? > >> > Things are getting pretty bad. > >> > >> Buy Google and make them fix it. > > > > I've had pretty good luck with MT-NewsWatcher, a freeware Mac > > newsreader that performs Bayesian spam filtering. > > Thunderbird's Usenet reader also offers Bayesian filtering, > > which presumably works just as well for classifying Usenet > > spam as it does at handling email spam. > > > > So download a "real" NNTP client for whatever platform you're > > on and give its spam filter a shot; clearly Google is not > > interested in fighting spam itself. > > Plonking anything posted via google.groups is the simplest > answer. Yes, but it's hard to give him that advice with a straight face until I've convinced him to stop using Google Groups to begin with ;) -- Mark Shroyer http://markshroyer.com/contact/ From alkundry at gmail.com Wed Apr 30 05:42:55 2008 From: alkundry at gmail.com (ABDULLAH) Date: Wed, 30 Apr 2008 02:42:55 -0700 (PDT) Subject: DO YOU KNOW ANY THING ABOUT ISLAM??? References: <2429a87a-34e8-4294-9a25-b54dd2cf6791@m73g2000hsh.googlegroups.com> Message-ID: <7ffebfa6-33c1-4004-a009-532f634f986c@p25g2000hsf.googlegroups.com> On Apr 27, 1:52?pm, Lie wrote: > On Apr 24, 1:40 pm, ABDULLAH wrote: > > > What you are about to read might sound unusual but it could be very > > enlightened. So I would be thankful if you give my article 5 minute > > of > > your value time. THANK YOU > > No, it is not unusual at all, it's very normal. The only thing that's > unusual is that you misposted this in a programming language mailing > list instead of religion list. sorry if you did not like this topic I thougth it will be intresting for someone but ok as you like I will stop writing about these stuffs in this group From ivan.illarionov at gmail.com Tue Apr 29 17:35:11 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Tue, 29 Apr 2008 21:35:11 +0000 (UTC) Subject: @classmethod question References: Message-ID: On Tue, 29 Apr 2008 14:30:08 -0600, Scott SA wrote: > With that said, your reply is amazingly helpful in my quest to > understand python, Django, etc. Django is the ORM I referred to, so the > material you have written helps explain a few things. This was my intention. Django ORM uses Pyhton classes to represent tables and instances to represent rows. And they do it in a way very similat to what I had showed. Another note about classmethods: they are almost the same thing as methods of metaclasses. Classmethods are more simple to understand but at the same time they touch very complex and, as Guido call it, 'brain- exploding' topic. > I'm a little vague on the interaction of the IngredientsDescrptor VS IngredientsManager. I gather the 'Descriptor' class is called via the __get__ which then does the instance check. Could this have been done in the 'Manager' class? The descriptor trick is only needed to prevent instances from calling Manager methods. Custom descriptors are little more than just classes and AFAIK it's better to keep them separated. > I have been learning a lot from the Django code and other applications > written within it. Still, some things just don't seem to gel, even after > a host of google searches. I've not loked at the Google Apps stuff, but > will follow your advice. I think that it's better to keep things as simple as possible (other solutions in this thread are definetly more practical) and don't try to use classmethods, custom descriptors and metaclasses unless you *really* need this stuff. AFAIK all these metaprogramming tricks make sense only for frameworks and for learning Python, but make very little or no sense for smaller apps. -- Ivan From ptmcg at austin.rr.com Sun Apr 6 11:20:59 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Sun, 6 Apr 2008 08:20:59 -0700 (PDT) Subject: Is there any way to say ignore case with "in"? References: <47f692f3$0$759$bed64819@news.gradwell.net> <432d690f-44be-49a9-bc6a-1cf3445549d6@m71g2000hse.googlegroups.com> <47f8d5df$0$23304$9b622d9e@news.freenet.de> Message-ID: On Apr 6, 8:53?am, "Martin v. L?wis" wrote: > >> I know I could use:- > > >> ? ? if lower(string1) in lower(string2): > >> ? ? ? ? > > >> but it somehow feels there ought to be an easier (tidier?) way. > > > Easier? ?You mean like some kind of mind meld? > > Interestingly enough, it shouldn't be (but apparently is) obvious that > > ? ?a.lower() in b.lower() > > is a way of expressing "a is a substring of b, with case-insensitive > matching". Can we be sure that these are really the same concepts, > and if so, is > > ? a.upper() in b.upper() > > also equivalent? > > It's probably a common assumption that, for any character c, > c.lower()==c.upper().lower(). Yet, > > py> [i for i in range(65536) if unichr(i).upper().lower() != > unichr(i).lower()] > [181, 305, 383, 837, 962, 976, 977, 981, 982, 1008, 1009, 1010, 1013, > 7835, 8126] > > Take, for example, U+017F, LATIN SMALL LETTER LONG S. It's .lower() is > the same character, as the character is already in lower case. > It's .upper() is U+0053, LATIN CAPITAL LETTER S. Notice that the LONG > is gone - there is no upper-case version of a "long s". > It's .upper().lower() is U+0073, LATIN SMALL LETTER S. > > So should case-insensitive matching match the small s with the small > long s, as they have the same upper-case letter? > > Regards, > Martin Another surprise (or maybe not so surprising) - this "upper != lower" is not symmetric. Using the inverse of your list comp, I get >>> [i for i in range(65536) if unichr(i).lower().upper() != ... unichr(i).upper()] [304, 1012, 8486, 8490, 8491] Instead of 15 exceptions to the rule, conversion to upper has only 5 exceptions. So perhaps comparsion of upper's is, while not foolproof, less likely to encounter these exceptions? Or at least, simpler to code explicit tests. -- Paul From steve at holdenweb.com Wed Apr 16 12:06:09 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 16 Apr 2008 12:06:09 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: Mike Driscoll wrote: > On Apr 16, 10:09 am, Steve Holden wrote: >> Mike Driscoll wrote: >>> On Apr 16, 9:19 am, Grant Edwards wrote: >>>> This morning almost half of c.l.p was spam. In order to try to >>>> not tar both the benign google group users and the malignant >>>> ones with the same brush, I've been trying to kill usenet spam >>>> with subject patterns. But that's not a battle you can win, so >>>> I broke down and joined all the other people that just killfile >>>> everything posted via google.groups. >>>> AFAICT, if you're a google groups user your posts are not being >>>> seen by many/most experienced (read "non-google-group") users. >>>> This is mainly the fault of google who has refused to do >>>> anything to stem the flood of span that's being sent via Google >>>> Groups. >>>> -- >>>> Grant Edwards grante Yow! I would like to >>>> at urinate in an OVULAR, >>>> visi.com porcelain pool -- >>> Yeah, I noticed that Google Groups has really sucked this week. I'm >>> using the Google Groups Killfile for Greasemonkey now and it helps a >>> lot. I like Google, but my loyalty only goes to far. This is a >>> complete lack of customer service. >> Unfortunately this means Google groups users are getting exactly the >> service they are paying for. >> >> regards >> Steve >> -- >> Steve Holden +1 571 484 6266 +1 800 494 3119 >> Holden Web LLC http://www.holdenweb.com/ > > Steve, > > My workplace doesn't offer NNTP, so there is no good way to browse > c.l.py here. And I haven't been able to get NNTP to work from my home > either. > > By applying this logic to Python and Linux (or any Open Source > product), they shouldn't be used either (since I'm not paying for > them). > I'm not saying people shouldn't use Google Groups. I'm saying that Google can "justify" providing customer "support" that lives somewhere between zero and extremely crappy by not charging for the service. Without tunneling out to an NNTP proxy I don't see what other choice you have. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From terry.yinzhe at gmail.com Mon Apr 28 19:26:30 2008 From: terry.yinzhe at gmail.com (Terry) Date: Mon, 28 Apr 2008 16:26:30 -0700 (PDT) Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> <18c1e6480804270653r2e075061wf442b7b7d9f50ff6@mail.gmail.com> Message-ID: <9cca03a3-9b96-4bee-947b-baa62cd5f9a9@q24g2000prf.googlegroups.com> On Apr 28, 5:30 pm, Nick Craig-Wood wrote: > David wrote: > > Another idea would be to have multiple queues, one per thread or per > > message type "group". The producer thread pushes into the appropriate > > queues (through an intelligent PutMsg function), and the consumer > > threads pull from the queues they're interested in and ignore the > > others. > > Unfortunately a thread can only wait on one Queue at once (without > polling). So really the only efficient solution is one Queue per > thread. > > Make an intelligent PutMsg function which knows which Queue (or > Queues) each message needs to be put in and all the threads will have > to do is Queue.get() and be sure they've got a message they can deal > with. > > -- > Nick Craig-Wood --http://www.craig-wood.com/nick I do have one Queue per thread. The problem is the thread can not peek into the Queue and select msg with certain ID first. From paddy3118 at googlemail.com Wed Apr 2 11:21:35 2008 From: paddy3118 at googlemail.com (Paddy) Date: Wed, 2 Apr 2008 08:21:35 -0700 (PDT) Subject: who said python can't be obsfucated!? References: Message-ID: <65e57230-4f7c-4454-8b9c-906a62ab6b92@u36g2000prf.googlegroups.com> On Apr 2, 2:19 pm, cokofree... at gmail.com wrote: > def s(c):return[]if c==[]else s([_ for _ in c[1:]if _ +s([_ for _ in c[1:]if _>=c[0]]) > > Anyone else got some wonders...? Nope. From lucafbb at gmail.com Sun Apr 27 06:39:32 2008 From: lucafbb at gmail.com (Luca) Date: Sun, 27 Apr 2008 12:39:32 +0200 Subject: Newbie question about import In-Reply-To: References: <27308d500804251103t71d04b5fg1de6658ceab9d898@mail.gmail.com> Message-ID: <27308d500804270339p2358587ei4522e10bfd723907@mail.gmail.com> On Sat, Apr 26, 2008 at 4:14 AM, Gabriel Genellina wrote: > The short answer is: don't do that! __init__.py may import any module, but > other modules in the package should not import anything from __init__.py > The same rule applies to the main module in an application: it can import > any other required module, but no one should import main. > If you don't follow those rules you may encounter some surprises. > You *can* break the rules and actually do what you want, but I would not > reccomend it. > In this case, can't you switch the place where __version__ is defined? It > looks like a constant, so you could have it actually defined in mommy.py, > and inside __init__.py just import the value. > Ok, thanks all for helping. -- -- luca From wizzardx at gmail.com Sat Apr 26 04:52:21 2008 From: wizzardx at gmail.com (David) Date: Sat, 26 Apr 2008 10:52:21 +0200 Subject: Desktop notifications on Windows In-Reply-To: <0db266c1-50ad-4e01-b508-57c9a8febb4b@a22g2000hsc.googlegroups.com> References: <0db266c1-50ad-4e01-b508-57c9a8febb4b@a22g2000hsc.googlegroups.com> Message-ID: <18c1e6480804260152y2c4d0c62jb396d7fb545ba7e6@mail.gmail.com> On Sat, Apr 26, 2008 at 4:41 AM, wrote: > I'm looking for a way to implement desktop notifications (much like an > instant messaging program or a mail notifier) within my Python > application, on Windows only (no Gtk/Galago, please). I need no more > than a simple text-based notification, which should be clickable and > have a timeout, nothing else. I do not want to use Windows's "balloon > tips", either. Any suggestions? > -- You could use Tkinter, which comes with Python. From frikker at gmail.com Fri Apr 25 10:14:53 2008 From: frikker at gmail.com (blaine) Date: Fri, 25 Apr 2008 07:14:53 -0700 (PDT) Subject: Unix Device File Emulation References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> <480f6376$0$9037$5402220f@news.sunrise.ch> <9ee87070-be57-4a66-a152-3f36c1cc8f0c@k13g2000hse.googlegroups.com> <480f7983$0$9036$5402220f@news.sunrise.ch> <49529b68-88b4-4115-a85a-587528274a50@m73g2000hsh.googlegroups.com> Message-ID: <8905dc2d-dd0c-492f-a399-d80c2ee8e262@34g2000hsf.googlegroups.com> On Apr 24, 3:38 am, "A.T.Hofkamp" wrote: > On 2008-04-23, blaine wrote: > > > On Apr 23, 2:01 pm, "Martin Blume" wrote: > >> "blaine" schrieb > >> No, > >> while 1: > >> r = self.fifodev.readline() > >> if r: print r > >> else: time.sleep(0.1) > >> is ok (note the "if r:" clause). > > >> Martin > > > Beautiful! Thanks Martin! > > yes, but you have to follow the usual file handling rules, and close/re-open > the fifo after detecting EOF. You will be blocked on attempting to re-open > until there is another writing process. > > while 1: > fp = open('my_fifo', 'r') > while 1: > line = fp.readline() > if line == '': > break > print line.rstrip() # To prevent printing of \n in line > fp.close() > > Albert Oh, good call. Thanks a lot, that really helps. I felt that the previous solution was workable, but not perhaps 100% correct. Thanks Albert! From jpthing at online.no Wed Apr 30 06:35:10 2008 From: jpthing at online.no (John Thingstad) Date: Wed, 30 Apr 2008 12:35:10 +0200 Subject: Python's doc problems: sort References: <929d5ce9-9063-4e6c-98aa-89526f89fba3@y18g2000pre.googlegroups.com> <9pof14t22rpq24219q0an2748i5f054qr4@4ax.com> <88273bc8-5152-4dfd-9f96-1d6ee2b83f99@e53g2000hsa.googlegroups.com> Message-ID: P? Wed, 30 Apr 2008 06:26:31 +0200, skrev George Sakkis : > On Apr 29, 11:13?pm, J?rgen Exner wrote: > >> "xah... at gmail.com" wrote: >> >> Is this self-promoting maniac still going at it? >> >> >Although i disliked Perl very much [...] >> >> Then why on earth do you bother polluting this NG? >> >> Back into the killfile you go >> >> jue > > \|||/ > (o o) > ,----ooO--(_)-------. > | Please | > | don't feed the | > | TROLL's ! | > '--------------Ooo--' > |__|__| > || || > ooO Ooo Doesn't copying Rainer Joswig's troll warning constitute a copywright infrigment :) -------------- John Thingstad From medin0065 at gmail.com Sun Apr 20 10:49:56 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:49:56 -0700 (PDT) Subject: prevx1 crack Message-ID: <9f3aa585-8049-4af6-b019-697941c73163@a5g2000prg.googlegroups.com> prevx1 crack http://cracks.00bp.com F R E E C R A C K S From ptmcg at austin.rr.com Thu Apr 17 04:37:28 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Thu, 17 Apr 2008 01:37:28 -0700 (PDT) Subject: Newbie question about for...in range() structure References: Message-ID: On Apr 17, 3:30?am, "sp at k" wrote: > def fact(n): > ? ? ? ? total = 0 > ? ? ? ? n = int(n) > ? ? ? ? while n > 0: > ? ? ? ? ? ? ? ? total *= n > ? ? ? ? ? ? ? ? n -=1 > ? ? ? ? return total > My guess is that you want to initialize total to 1, not 0. -- Paul From grflanagan at gmail.com Thu Apr 10 11:34:18 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Thu, 10 Apr 2008 08:34:18 -0700 (PDT) Subject: subprocess.Popen() output to logging.StreamHandler() References: Message-ID: On Apr 10, 2:11 pm, "sven _" wrote: > Version: Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) > > My goal is to have stdout and stderr written to a logging handler. > This code does not work: > > # START > import logging, subprocess > ch = logging.StreamHandler() > ch.setLevel(logging.DEBUG) > subprocess.call(['ls', '-la'], 0, None, None, ch, ch) > # END > > Traceback (most recent call last): > File "log.py", line 5, in > subprocess.call(['ls', '-la'], 0, None, None, ch, ch) > File "/usr/lib/python2.5/subprocess.py", line 443, in call > return Popen(*popenargs, **kwargs).wait() > File "/usr/lib/python2.5/subprocess.py", line 586, in __init__ > errread, errwrite) = self._get_handles(stdin, stdout, stderr) > File "/usr/lib/python2.5/subprocess.py", line 941, in _get_handles > c2pwrite = stdout.fileno() > AttributeError: StreamHandler instance has no attribute 'fileno' > > This is because subprocess.Popen() expects file descriptors to write > to, and logging.StreamHandler() does not supply it. The StreamHandler > could supply its own stdout file descriptor, but then Popen() would > write directly to that file, bypassing all the logging fluff. > > A possible solution would be to make a named pipe (os.mkfifo()), have > Popen() write to that, and then have some horrendous hack run select() > or similar on the fifo to read from it and finally pass it to > StreamHandler. > > Are there better solutions? > > sven When you create a StreamHandler, it is associated with a particular stream, eg. sys.stdout. So when you log an event, the handler picks it up and writes it to the stream. But you seem to think that the reverse situation is true - when something is written to the stream (from an arbitrary source) then the StreamHandler instance will pick it up. This isn't the case - it doesn't work both ways. I think the only solution is to specifically log each line that you get back from Popen, as suggested by Thomas Dimson. You would perhaps like something like the code below to work but it doesn't (well, it runs, but the output of the subprocess call bypasses the Streamhandler). But then, maybe this is sufficient for you - as you've seen, you can't set the stdout of the subprocess to the StreamHandler, but you can set it to the Streamhandler's stream (if it has a fileno) - subprocess.call('svn info', stdout=ch.stream) OR subprocess.call('svn info', stdout=ch.stream.fileno()) -------------------------------------------------------- import sys import logging import subprocess ECHO_FORMAT = '%(levelname)-8s %(message)s' class ReverseReverseStreamHandler(logging.StreamHandler): def __init__(self, strm): logging.StreamHandler.__init__(self, strm) self.fileno = strm.fileno def write(self, msg): print 'This is never called!' for line in msg.splitlines(): self.emit(logging.LogRecord(None, None, "", 0, line, (), None, None)) root = logging.getLogger() console = ReverseReverseStreamHandler(sys.stdout) formatter = logging.Formatter(ECHO_FORMAT) console.setFormatter(formatter) root.addHandler(console) root.setLevel(logging.DEBUG) logging.info('---------') subprocess.call('svn info', stdout=console) logging.info('---------') -------------------------------------------------------- hth G. From steve at holdenweb.com Wed Apr 16 17:03:33 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 16 Apr 2008 17:03:33 -0400 Subject: py3k s***s In-Reply-To: References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> <09a38ca2-8c49-4eee-b6cf-58e849aea1fc@q1g2000prf.googlegroups.com> Message-ID: <480669A5.3050705@holdenweb.com> Aaron Watters wrote: > On Apr 16, 2:33 pm, Rhamphoryncus wrote: >> The point is, you can't have it both ways. Either you evolve the >> language and break things, or you keep it static and nothing breaks. > > I disagree. You can add lots of cool > stuff without breaking the existing code base, mostly. > For example the minor changes to the way ints will work will > effect almost no programs. > > I don't see the urgency to clean up what are essentially > cosmetic issues and throw out or > require rewrites for just about all existing Python > code. Python 2.6 isn't fundamentally awful like Perl 4 was. > The cost paid for these minor improvements is too high in my > book. But I suppose if it is going to happen do it sooner > rather than later. Just *please* *please* don't > systematically break the pre-existing code base again for a > very long time, preferable ever. I'm pretty sure the 3.0 compatibility breakage is a one-shot deal. If it's not I won't be the only one looking for Guido with a bog stick in my hand ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From tonal at promsoft.ru Mon Apr 28 02:57:31 2008 From: tonal at promsoft.ru (Alexandr N Zamaraev) Date: Mon, 28 Apr 2008 13:57:31 +0700 Subject: py2exe do not compile from mingw Message-ID: <4815755B.3060005@promsoft.ru> OS: WinXP Home Ru + sp2 Python: 2.5.2 py2exe: latest CSV source gcc (GCC) 3.4.5 (mingw-vista special r2) GNU ld (GNU Binutils) 2.18.50.20080109 OS: WinXP Home Ru + sp2 Python: 2.5.2 py2exe: latest CSV source gcc (GCC) 3.4.5 (mingw-vista special r2) GNU ld (GNU Binutils) 2.18.50.20080109 I have patchs for compile py2exe from latest release mingw. Correct setup, compile, and run errors. This patch union 1012785 patch and 1378533 bag patch for latest CSV source. see alse http://sourceforge.net/tracker/index.php?func=detail&aid=1953133&group_id=15583&atid=315583, http://sourceforge.net/tracker/?func=detail&aid=1378533&group_id=15583&atid=115583, http://sourceforge.net/tracker/?func=detail&aid=1012785&group_id=15583&atid=315583 From martin at v.loewis.de Tue Apr 29 17:50:41 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 29 Apr 2008 23:50:41 +0200 Subject: Simple unicode-safe version of str(exception)? In-Reply-To: References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> Message-ID: <48179831.7030308@v.loewis.de> > Should I report this as a bug? I suspect it's a misfeature. Please no. There isn't much that can be done about it, IMO. Regards, Martin From steve at holdenweb.com Mon Apr 14 14:17:11 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 14 Apr 2008 14:17:11 -0400 Subject: =?UTF-8?B?5pyJ5Lit5Zu95Lq65LmOPw==?= In-Reply-To: <4801F702.5050401@arcor.de> References: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> <4801F702.5050401@arcor.de> Message-ID: Penny Y. wrote: > Steve Holden ??: > >> ????????, ????????? >> > > What do you mean? > If I understand you correctly, maybe it should be, > > ??python??????,??????. > > Am I right? I have no idea. Babelfish (from which I obtained my reply as well as whatever understanding I had of the original inquiry) translated my reply as But the academic society never is immediately, with will need time whereas yours becomes Studies python not to be possible on first to become, needs to proceed in an orderly way Since what I entered in English was something like "Yes, Python has a future. But it will take some study". Perhaps you can tell me whether your translation gives the correect flavor. I'm pretty sure the babelfish mangled my intent. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From xng at xs4all.nl Sat Apr 19 20:04:27 2008 From: xng at xs4all.nl (Martin P. Hellwig) Date: Sun, 20 Apr 2008 02:04:27 +0200 Subject: Bigger projects, including files? In-Reply-To: References: Message-ID: <480a8928$0$4941$e4fe514c@dreader32.news.xs4all.nl> globalrev wrote: > if i have a larger project and want to divide my program into several > files, how do i include these files in the mainprogram? > > using import someprojectfile doesnt work because import is for site- > packages right and i dont want to put all my files > in that folder. > > so how do i do it? > You can always add the path where the other files are to sys.path I've posted a while ago something that sort of does that for inter-package reference if the root is not in the sys.path http://groups.google.com/group/comp.lang.python/browse_thread/thread/0e29ab20b4d4bc97 hth -- mph From miki.tebeka at gmail.com Tue Apr 1 08:36:59 2008 From: miki.tebeka at gmail.com (Miki) Date: Tue, 1 Apr 2008 05:36:59 -0700 (PDT) Subject: How to insert multiple rows in SQLite Dbase References: <50faeed7-775f-4e12-8131-21a95b5f91a8@e6g2000prf.googlegroups.com> <657h3nF2eehi8U1@mid.uni-berlin.de> Message-ID: <6fc8a682-b15e-4700-9aef-bdb4a3f980d7@e10g2000prf.googlegroups.com> > Thanks regards to your suggestion, but I don't understand why we have > to put the IF statement? It's just an example, one possible implementation could be: def parse_data(data): mapping = {} for line in data.splitlines(): if not line.strip(): continue key, value = line.split(":", 1) mapping[key] = value return mapping HTH, -- Miki http://pythonwise.blogspot.com From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 1 14:09:54 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 01 Apr 2008 20:09:54 +0200 Subject: Python in High School In-Reply-To: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: <47f27a74$0$20512$426a74cc@news.free.fr> sprad a ?crit : > I'm a high school computer teacher, and I'm starting a series of > programming courses next year (disguised as "game development" classes > to capture more interest). The first year will be a gentle > introduction to programming, leading to two more years of advanced > topics. > > I was initially thinking about doing the first year in Flash/ > ActionScript, and the later years in Java. My reasoning is that Flash > has the advantage of giving a quick payoff to keep the students > interested while I sneak in some OOP concepts through ActionScript. > Once they've gotten a decent grounding there, they move on to Java for > some more heavy-duty programming. > > I've never used Python, but I keep hearing enough good stuff about it > to make me curious. > > So -- would Python be a good fit for these classes? IMHO, yes, definitively - except that it won't introduce concepts like static typing and primitive types, since it's dynamically typed and 100% object. OTHO, it'll let you introduce quite a lot of more advanced topics (operator overloading, metaclasses, higher-order functions, closures, partial application etc) that you're less likely to grasp using Java. > Could it equal > Java as the later heavy-duty language? If you mean "is it possible to use Python to write real-world, non-trivial applications", then the answer is obviously yes. Python's use range from Q&D admin script to full-blown web application server including vector graphic GUI apps, scientific data analysis and plotting and game developpment and/or scripting. > Does it have enough quickly- > accessible sparklies to unseat Flash? Since you plan to lure poor schoolboys in by pretending to teach them game programming, you may want to have a look at pygame: http://www.pygame.org/news.html > I want to believe. Evangelize away. "Then I saw Pygame, now I'm a believer".... !-) From gherron at islandtraining.com Thu Apr 24 16:54:29 2008 From: gherron at islandtraining.com (Gary Herron) Date: Thu, 24 Apr 2008 13:54:29 -0700 Subject: Class Inheritance - What am I doing wrong? In-Reply-To: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> References: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> Message-ID: <4810F385.5010105@islandtraining.com> Brian Munroe wrote: > My example: > > class A(object): > > def __init__(self, name): > self.__name = name > > def getName(self): > return self.__name > > class B(A): > > def __init__(self,name=None): > super(A,self).__init__() > > def setName(self, name): > self.__name = name > > if __name__ == '__main__': > > a = A('class a') > print a.getName() > > b = B('class b') > print b.getName() > > b.setName('class b, reset') > print b.getName() > > I get the following error: > > mtinky:~ brian$ python teste.py > class a > Traceback (most recent call last): > File "teste.py", line 23, in > print b.getName() > File "teste.py", line 7, in getName > return self.__name > AttributeError: 'B' object has no attribute '_A__name' > > Am I *not* using super() correctly? Also, did I define my the class B > constructor correctly? > -- > http://mail.python.org/mailman/listinfo/python-list > Tell us what you are trying to do and what you expected to happen. If you are trying to do simple inheritance, you don't need the supers, and you should not invoke the name mangling implied by the double underscore. If you *are* trying to use the name mangling, then you still don't need the super. Gary Herron From hniksic at xemacs.org Mon Apr 28 10:28:26 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Mon, 28 Apr 2008 16:28:26 +0200 Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> <87od7ue2ne.fsf@mulj.homelinux.net> Message-ID: <87hcdmdpf9.fsf@mulj.homelinux.net> Nick Craig-Wood writes: >> Note that appending to a string is almost never a good idea, since it >> can result in quadratic allocation. > > My aim was clear exposition rather than the ultimate performance! That would normally be fine. My post wasn't supposed to pick performance nits, but to point out potentially quadratic behavior. > Anyway str += was optimised in python 2.4 or 2.5 (forget which) wasn't > it? That optimization works only in certain cases, when working with uninterned strings with a reference count of 1, and then only when the strings are in stored local variables, rather than in global vars or in slots. And then, it only works in CPython, not in other implementations. The optimization works by "cheating" -- breaking the immutable string abstraction in the specific cases in which it is provably safe to do so. http://utcc.utoronto.ca/~cks/space/blog/python/ExaminingStringConcatOpt examines it in some detail. Guido was reluctant to accept the patch that implements the optimization because he thought it would "change the way people write code", a sentiment expressed in http://mail.python.org/pipermail/python-dev/2004-August/046702.html This discussion shows that he was quite right in retrospect. (I'm not saying that the optimization is a bad thing, just that it is changing the "recommended" way of writing Python in a way that other implementations cannot follow.) From hobgoodoreneyhb at gmail.com Tue Apr 22 11:36:22 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:36:22 -0700 (PDT) Subject: side effects of scopolamine patch Message-ID: side effects of scopolamine patch http://cracks.12w.net F R E E C R A C K S From jasper at peak.org Thu Apr 24 10:16:47 2008 From: jasper at peak.org (Jasper) Date: Thu, 24 Apr 2008 07:16:47 -0700 (PDT) Subject: How to find the parent of an old-style class? Message-ID: <9742ba66-eebf-43ba-8391-d0d0edb52c95@l42g2000hsc.googlegroups.com> I'm stuck using a library based on old style classes, and need to find a class's parent at runtime. With new style classes you can use .__base__ to inspect a parent, but I can't remember how this was done in days of yore, before object. I've tried googling, but apparently my search term Fu is weak. :-( Can anyone help me out here? There must be something simple. -Jasper From hopeorpha308 at gmail.com Sun Apr 27 07:46:16 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:46:16 -0700 (PDT) Subject: vista ultimate crack Message-ID: <0267dab6-abd0-4e1e-991c-28b556b68735@w7g2000hsa.googlegroups.com> vista ultimate crack http://wga-cracks.crackkey.net From __peter__ at web.de Wed Apr 23 07:56:51 2008 From: __peter__ at web.de (Peter Otten) Date: Wed, 23 Apr 2008 13:56:51 +0200 Subject: problem with dictionaries References: Message-ID: Simon Strobl wrote: > the idea of the following program is to parse a frequency list of the > form FREQUENCY|WORD, to store the frequency of a word in a dictionary > (and to do some things with this information later). > > I have done this many many times. Suddenly, it does not work any more: > The value frq[key] is different from the value that key has in the > file 'my_frqlist.txt'. > > I am using Python 2.5.1 > > Any hints? The code looks OK. You probably have python reading a my_frqlist.txt that differs from the one you are looking at. Peter From bg at bg.fr Wed Apr 9 09:05:26 2008 From: bg at bg.fr (Bruno GUERPILLON) Date: Wed, 9 Apr 2008 15:05:26 +0200 Subject: List open files References: <47fb8d54$0$15068$426a74cc@news.free.fr> <47fb9789$0$881$ba4acef3@news.orange.fr> Message-ID: <47fcc014$0$22451$426a74cc@news.free.fr> "Guillaume" a ?crit dans le message de news: ftg58p$2fek$2 at biggoron.nerim.net... > Oh and don't forget to take care about saving correctly the Oracle > database ! ^^ > (private joke *giggles* j/k :)) > > Regards, > -- > Guillaume Sure Guillamne and dont forget to answer the right questions *grin* Bruno. From mobile at ibinsa.com Tue Apr 8 18:08:29 2008 From: mobile at ibinsa.com (Gabriel Ibanez) Date: Wed, 9 Apr 2008 00:08:29 +0200 Subject: Converting a tuple to a list Message-ID: <00ba01c899c5$14528ae0$0a01a8c0@mobile> Hi all .. I'm trying to using the map function to convert a tuple to a list, without success. I would like to have a lonely line that performs the same as loop of the next script: ------------------------------------------- # Conveting tuple -> list tupla = ((1,2), (3,4), (5,6)) print tupla lista = [] for a in tupla: for b in a: lista.append(b) print lista ------------------------------------------- Any idea ? Thanks ... # Gabriel From gagsl-py2 at yahoo.com.ar Tue Apr 1 02:03:17 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 03:03:17 -0300 Subject: Why prefer != over <> for Python 3.0? References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> <659gb2F2f84eoU2@mid.individual.net> <87hceo73ap.fsf@physik.rwth-aachen.de> <65anbqF2fg18bU1@mid.individual.net> <87r6drjss4.fsf@physik.rwth-aachen.de> <65c0bfF2ffipiU1@mid.individual.net> Message-ID: En Mon, 31 Mar 2008 16:17:39 -0300, Terry Reedy escribi?: > "Bjoern Schliessmann" > wrote > in message news:65c0bfF2ffipiU1 at mid.individual.net... > | > However, I'm quite sure that when Unicode has arrived almost > | > everywhere, some languages will start considering such characters > | > in their core syntax. > | > | This should be the time when there are widespread quasi-standardised > | input methods for those characters. > > C has triglyphs for keyboards missing some ASCII chars. != and <= could > easily be treated as diglyphs for the corresponding chars. In a sense > they > are already, it is just that the real things are not allowed ;=). I think it should be easy to add support for ??? and even ?, only the tokenizer has to be changed. -- Gabriel Genellina From steve at holdenweb.com Sat Apr 5 22:30:24 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 22:30:24 -0400 Subject: id functions of ints, floats and strings In-Reply-To: References: Message-ID: Gabriel Genellina wrote: > En Thu, 03 Apr 2008 19:27:47 -0300, escribi?: > >> Hi all, >> >> I've been playing around with the identity function id() for different >> types of objects, and I think I understand its behaviour when it comes >> to objects like lists and tuples in which case an assignment r2 = r1 >> (r1 refers to an existing object) creates an alias r2 that refers to >> the same object as r1. In this case id(r1) == id(r2) (or, if you >> like: r1 is r2). However for r1, r2 assigned as follows: r1 = [1, 2, >> 3] and r2 = [1, 2, 3], (r1 is r2) is False, even if r1==r2, >> etc. ...this is all very well. Therefore, it seems that id(r) can be >> interpreted as the address of the object that 'r' refers to. >> >> My observations of its behaviour when comparing ints, floats and >> strings have raised some questions in my mind, though. Consider the >> following examples: >> >> ######################################################################### >> >> # (1) turns out to be true >> a = 10 >> b = 10 >> print a is b > > ...only because CPython happens to cache small integers and return always > the same object. Try again with 10000. This is just an optimization and > the actual range of cached integer, or whether they are cached at all, is > implementation (and version) dependent. > (As integers are immutable, the optimization *can* be done, but that > doesn't mean that all immutable objects are always shared). > >> # (2) turns out to be false >> f = 10.0 >> g = 10.0 >> print f is g > > Because the above optimization isn't used for floats. > The `is` operator checks object identity: whether both operands are the > very same object (*not* a copy, or being equal: the *same* object) > ("identity" is a primitive concept) > The only way to guarantee that you are talking of the same object, is > using a reference to a previously created object. That is: > > a = some_arbitrary_object > b = a > assert a is b > > The name `b` now refers to the same object as name `a`; the assertion > holds for whatever object it is. > > In other cases, like (1) and (2) above, the literals are just handy > constructors for int and float objects. You have two objects constructed > (a and b, f and g). Whether they are identical or not is not defined; they > might be the same, or not, depending on unknown factors that might include > the moon phase; both alternatives are valid Python. > >> # (3) checking if ids of all list elements are the same for different >> cases: >> >> a = 3*[1]; areAllElementsEqual([id(i) for i in a]) # True >> b = [1, 1, 1]; areAllElementsEqual([id(i) for i in b]) # True >> f = 3*[1.0]; areAllElementsEqual([id(i) for i in f]) # True >> g = [1.0, 1.0, 1.0]; areAllElementsEqual([id(i) for i in g]) # True >> g1 = [1.0, 1.0, 0.5+0.5]; areAllElementsEqual([id(i) for i in g1]) # >> False > > Again, this is implementation dependent. If you try with a different > Python version or a different implementation you may get other results - > and that doesn't mean that any of them is broken. > >> # (4) two equal floats defined inside a function body behave >> differently than case (1): >> >> def func(): >> f = 10.0 >> g = 10.0 >> return f is g >> >> print func() # True > > Another implementation detail related to co_consts. You shouldn't rely on > it. > >> I didn't mention any examples with strings; they behaved like ints >> with respect to their id properties for all the cases I tried. > > You didn't try hard enough :) > > py> x = "abc" > py> y = ''.join(x) > py> x == y > True > py> x is y > False > > Long strings behave like big integers: they aren't cached: > > py> x = "a rather long string, full of garbage. No, this isn't garbage, > just non > sense text to fill space." > py> y = "a rather long string, full of garbage. No, this isn't garbage, > just non > sense text to fill space." > py> x == y > True > py> x is y > False > > As always: you have two statements constructing two objects. Whether they > return the same object or not, it's not defined. > >> While I have no particular qualms about the behaviour, I have the >> following questions: >> >> 1) Which of the above behaviours are reliable? For example, does a1 = >> a2 for ints and strings always imply that a1 is a2? > > If you mean: > > a1 = something > a2 = a1 > a1 is a2 > > then, from my comments above, you should be able to answer: yes, always, > not restricted to ints and strings. > > If you mean: > > a1 = someliteral > a2 = someliteral > a1 is a2 > > then: no, it isn't guaranteed at all, nor even for small integers or > strings. > >> 2) From the programmer's perspective, are ids of ints, floats and >> string of any practical significance at all (since these types are >> immutable)? > > The same significance as id() of any other object... mostly, none, except > for debugging purposes. > >> 3) Does the behaviour of ids for lists and tuples of the same element >> (of type int, string and sometimes even float), imply that the tuple a >> = (1,) takes (nearly) the same storage space as a = 10000*(1,)? (What >> about a list, where elements can be changed at will?) > > That's a different thing. A tuple maintains only references to its > elements (as any other object in Python). The memory required for a tuple > (I'm talking of CPython exclusively) is: (a small header) + n * > sizeof(pointer). So the expression 10000*(anything,) will take more space > than the singleton (anything,) because the former requires space for 10000 > pointers and the latter just one. > > You have to take into account the memory for the elements themselves; but > in both cases there is a *single* object referenced, so it doesn't matter. > Note that it doesn't matter whether that single element is an integer, a > string, mutable or immutable object: it's always the same object, already > existing, and creating that 10000-uple just increments its reference count > by 10000. > > The situation is similar for lists, except that being mutable containers, > they're over-allocated (to have room for future expansion). So the list > [anything]*10000 has a size somewhat larger than 10000*sizeof(pointer); > its (only) element increments its reference count by 10000. > In fact all you can in truth say is that a is b --> a == b The converse definitely not true. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From frikker at gmail.com Wed Apr 30 10:18:30 2008 From: frikker at gmail.com (blaine) Date: Wed, 30 Apr 2008 07:18:30 -0700 (PDT) Subject: Simple TK Question - refreshing the canvas when not in focus References: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> <4818349e$0$2959$ba620e4c@news.skynet.be> Message-ID: <182ace66-bdf6-409c-85ee-fd764de8e1c6@z72g2000hsb.googlegroups.com> Still doesn't work. I'm looking into using wx instead... This is the full code - does it work for anyone else? Just do a echo 'line 0 0 10 10' > dev.file import sys, os, time, Tkinter, threading class nokia_fkscrn(Tkinter.Toplevel): fp=None def __init__(self, file): self.fname = file # Create the FIFO pipe (hopefully /dev/screen or similar) if not os.path.exists(self.fname): os.mkfifo(self.fname) self.readthread = threading.Thread(target=self.read) self.readthread.start() self.init_canvas() def init_canvas(self): # Set up our canvas self.root = Tkinter.Tk() self.root.title('Nokia Canvas') self.canvas = Tkinter.Canvas(self.root, width =130, height=130) self.canvas.pack() self.root.mainloop() def read(self): while 1: self.fp = open(self.fname, 'r') while 1: st = self.fp.readline() if st == '': break self.process(st) self.fp.close() def process(self, line): cmd = line.split() if cmd[0] == 'line': # Draw Line args = map(int, cmd[1:]) try: color=args[4] except: color='black' if self.canvas: print 'Drawing Line:', args self.canvas.create_line(args[0], args[1], args[2], args[3], fill=color) self.canvas.update() self.canvas.focus_force() nokia = nokia_fkscrn('dev.file') From gagsl-py2 at yahoo.com.ar Thu Apr 10 18:18:17 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 19:18:17 -0300 Subject: win-shortcuts, file associates and command-line parameters ? References: <47FE6480.4090602@gmail.com> Message-ID: En Thu, 10 Apr 2008 16:03:28 -0300, Stef Mientki escribi?: > under windows I tried to make a shortcut to a py -file, to run a program. > So making a shortcut like this works perfect: > D:\PyLab_Works.py > > But the problem is that I need to give some commandline parameters to > the py-file, > and > > D:\PyLab_Works.py btc_test > But the parameter doesn't seem to arrive in the python program Check the associated command for .py files; see this message http://groups.google.com/group/comp.lang.python/msg/056ba14ae4fa57e3 -- Gabriel Genellina From andymac at bullseye.apana.org.au Mon Apr 21 05:08:07 2008 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Mon, 21 Apr 2008 20:08:07 +1100 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <480B8813.6010108@gmail.com> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B80B5.1050500@cheimes.de> <480B8813.6010108@gmail.com> Message-ID: <480C5977.3060403@bullseye.andymac.org> Hank @ITGroup wrote: > In order to deal with 400 thousands texts consisting of 80 million > words, and huge sets of corpora , I have to be care about the memory > things. I need to track every word's behavior, so there needs to be as > many word-objects as words. > I am really suffering from the memory problem, even 4G memory space can > not survive... Only 10,000 texts can kill it in 2 minutes. > By the way, my program has been optimized to ``del`` the objects after > traversing, in order not to store the information in memory all the time. In addition to all the other advice you've been given, I've found it can pay dividends in memory consumption when each instance of a value (such as a string) references only 1 object. This is often referred to as "interning". Automatic interning is only performed for a small subset of possibilities. For example: >>> z1 = 10 >>> z2 = 10 >>> z1 is z2 True >>> z1 = 1000 >>> z2 = 1000 >>> z1 is z2 False >>> z1 = 'test' >>> z2 = 'test' >>> z1 is z2 True >>> z1 = 'this is a test string pattern' >>> z2 = 'this is a test string pattern' >>> z1 is z2 False Careful use of interning can get a double boost: cutting memory consumption and allowing comparisons to short circuit on identity. It does cost in maintaining the dictionary that interns the objects though, and tracking reference counts can be much harder. -- ------------------------------------------------------------------------- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andymac at bullseye.apana.org.au (pref) | Snail: PO Box 370 andymac at pcug.org.au (alt) | Belconnen ACT 2616 Web: http://www.andymac.org/ | Australia From skanemupp at yahoo.se Sun Apr 20 23:57:38 2008 From: skanemupp at yahoo.se (globalrev) Date: Sun, 20 Apr 2008 20:57:38 -0700 (PDT) Subject: question about the mainloop References: <52de38c4-3d1e-4be0-9b58-5d60317f1ef7@b1g2000hsg.googlegroups.com> Message-ID: On 21 Apr, 04:26, "Gabriel Genellina" wrote: > En Sun, 20 Apr 2008 20:24:04 -0300, globalrev escribi?: > > > in C?? java etc there is usually: > > > procedure 1 > > procedure 2 > > procedure 3 > > > main { > > procedure 1 > > procedure 2 > > procedure 3 > > } > > > i dont get the mainloop() in python. i mean i have written some > > programs, for example a calculator using tkinterGUI. > > What you call the "mainloop" is the event loop (or message loop) used by event-driven applications as a way to dispatch all events as they happen in the system. The concept is independent of Python/C++/whatever language you choose. The key phrase is "event-driven programming":http://en.wikipedia.org/wiki/Event_driven_programming > Tkinter provides an event-driven GUI framework. Simple CLI programs are not event-driven, as your pseudo example above. > > > if i have some functions i wanna call to run the program and i wanna > > call them ina specific order and be able to call > > them from each other should this just be called in the mainloop and > > the mianloop then runs the "mainscript" top > > to bottom over and over? > > If you don't want or don't require a graphical user interface, just write the functions you need and call them from the outermost section in your script. > If you do require a GUI, you'll have to write the code in response to user actions: when the user clicks here, do this; when the user chooses that menu option, do that. > > -- > Gabriel Genellina but what i mean i dont understand is sure i can bind a function to a buttonpress but if i have a def dox(): dododo and i call it with dox() in the mainscript it will be executed once, but not again. so what does the mainloop do, 1srt time it is executed it runs the mainscript then it it sits and wait s for commands? From pavlovevidence at gmail.com Fri Apr 25 15:43:51 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Fri, 25 Apr 2008 12:43:51 -0700 (PDT) Subject: problem with mmap References: Message-ID: On Apr 25, 9:37 am, Neal Becker wrote: > On linux, I don't understand why: > > f = open ('/dev/eos', 'rw') > m = mmap.mmap(f.fileno(), 1000000, prot=mmap.PROT_READ|mmap.PROT_WRITE, > flags=mmap.MAP_SHARED) > > gives 'permission denied', Try f = open('/dev/eos', 'r+') Carl Banks From grflanagan at gmail.com Tue Apr 1 10:36:07 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Tue, 1 Apr 2008 07:36:07 -0700 (PDT) Subject: Copy Stdout to string References: Message-ID: On Apr 1, 4:03 pm, sophie_newbie wrote: > Hi, I'm wondering if its possible to copy all of stdout's output to a > string, while still being able to print on screen. I know you can > capture stdout, but I still need the output to appear on the screen > also... > > Thanks! I don't know if it's what you want, but if you're talking about the output of a single command, then the following (or a variation) should do. (using 'svn info' as the command). --------------------------------------------------- import subprocess from cStringIO import StringIO import sys buf = StringIO() def popen(cmdline): return subprocess.Popen(cmdline, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout for line in popen('svn info'): print >> sys.stdout, 'out: ' + line, print >> buf, 'buf: ' + line, print print buf.getvalue() --------------------------------------------------- From spam-trap at telus.net Wed Apr 30 21:25:40 2008 From: spam-trap at telus.net (L. Lindstrom) Date: Thu, 01 May 2008 01:25:40 GMT Subject: Python 2.6 and wrapping C libraries on Windows In-Reply-To: <60da8569-4b80-4b31-9fd0-5b2a79ec2164@k13g2000hse.googlegroups.com> References: <60da8569-4b80-4b31-9fd0-5b2a79ec2164@k13g2000hse.googlegroups.com> Message-ID: sturlamolden wrote: > On Apr 30, 8:06 pm, "L. Lindstrom" wrote: > >> I have read that Python extension modules must link to the same C >> run-time as the Python interpreter. This I can appreciate. But does this >> requirement extend to the C libraries an extension module wraps. > > This somewhat of a misconception. You cannot reliably mix and blend > CRT resources across different CRTs. This is not really a Python > problem. It applies to any program. The reason this is important for > Python C extensions, is mainly the possibility of accessing a Python > file object as a pointer to a FILE struct in C. If you get a FILE* > pointer from one CRT, you should not pass it to another CRT's fread. > Likewise, if you allocate memory with one CRT's malloc(), you should > not release the memory with another CRT's free(). As long as your > libraries don't share CRT resources, it does not matter that the link > to different CRTs for their internal work. > > > > > > SDL has functions for separating memory allocation and file access. Going back to msvcrt.dll is a last resort. I may have an idea on how to build it for msvcr90.dll. -- Lenard Lindstrom "%s@%s.%s" % ('len-l', 'telus', 'net') From kay.schluehr at gmx.net Sun Apr 13 11:45:21 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sun, 13 Apr 2008 08:45:21 -0700 (PDT) Subject: str(bytes) in Python 3.0 References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> <806cf1da-8f06-4fff-8437-7f1ca1ff9472@k10g2000prm.googlegroups.com> <8fab7cda-d915-4e13-8bb8-f449b6617778@a22g2000hsc.googlegroups.com> Message-ID: On 13 Apr., 09:24, Carl Banks wrote: > On Apr 12, 11:51 am, Kay Schluehr wrote: > > > On 12 Apr., 16:29, Carl Banks wrote: > > > > > And making an utf-8 encoding default is not possible without writing a > > > > new function? > > > > I believe the Zen in effect here is, "In the face of ambiguity, refuse > > > the temptation to guess." How do you know if the bytes are utf-8 > > > encoded? > > > How many "encodings" would you define for a Rectangle constructor? > > I'm not sure what you're insinuating. If you are arguing that it's > inappropriate for a constructor to take an "encoding" argument (as you > put it), be my guest. I wasn't commenting on that specifically. > > I was commenting on your suggestion of having str assume utf-8 > encoding, which IMO would be very unPythonic, whether you can pass > encodings to it or not. That's o.k. I don't primarily advocate default values or such things just reduction of mental and scripting overhead. We shouldn't lose the goal out of sight. I played a bit with several encodings but this didn't enable much of an impression how it will feel in real code. I can see though the inadequacy of my original claim mainly due to the overlooked fact that there isn't even a mapping of the range \x0 - \xff to utf-8 but only one from \x0 - \x7f. Same with the ASCII encoding which is limited to 7 bits as well. One has to be careful not just because "you can select the wrong encoding" but stringification with an utf-8 encoding can simply activate the exception handler even though there will be no type error! A default value shall work under all circumstances supposed you pass in an object of the correct type. From sgeiger at ncee.net Tue Apr 8 19:58:56 2008 From: sgeiger at ncee.net (Shane Geiger) Date: Tue, 08 Apr 2008 18:58:56 -0500 Subject: Converting a tuple to a list In-Reply-To: <00ba01c899c5$14528ae0$0a01a8c0@mobile> References: <00ba01c899c5$14528ae0$0a01a8c0@mobile> Message-ID: <47FC06C0.8060207@ncee.net> from goopy.functional import * tupla = ((1,2), (3,4), (5,6)) print flatten(tupla) Gabriel Ibanez wrote: > Hi all .. > > I'm trying to using the map function to convert a tuple to a list, without > success. > > I would like to have a lonely line that performs the same as loop of the > next script: > > ------------------------------------------- > # Conveting tuple -> list > > tupla = ((1,2), (3,4), (5,6)) > > print tupla > > lista = [] > for a in tupla: > for b in a: > lista.append(b) > print lista > ------------------------------------------- > > Any idea ? > > Thanks ... > > # Gabriel > > -- Shane Geiger IT Director National Council on Economic Education sgeiger at ncee.net | 402-438-8958 | http://www.ncee.net Leading the Campaign for Economic and Financial Literacy From see.signature at no.spam Thu Apr 17 07:48:38 2008 From: see.signature at no.spam (Eric Brunel) Date: Thu, 17 Apr 2008 13:48:38 +0200 Subject: Learning Tkinter References: Message-ID: On Wed, 16 Apr 2008 14:46:13 +0200, Doran, Harold wrote: [snip] > Second, I am trying to work through a couple of the examples and make > some small tweaks as I go to see how new things can work. In the first > case, I have copied the code in the book to see how the menu works and > are created as in the example menu.py below. I see how menus are created > and how the command option is used to call the function callback. > > # menu.py > from Tkinter import * > > def callback(): > print "called the callback!" > > root = Tk() > > # create a menu > menu = Menu(root) > root.config(menu=menu) > > filemenu = Menu(menu) > menu.add_cascade(label="File", menu=filemenu) > filemenu.add_command(label="New", command=harold) > filemenu.add_command(label="Open...", command=callback) > filemenu.add_separator() > filemenu.add_command(label="Exit", command=callback) > > helpmenu = Menu(menu) > menu.add_cascade(label="Help", menu=helpmenu) > helpmenu.add_command(label="About...", command=callback) > > mainloop() > > However, I now want to incorporate a basic python program with a > command. Say I have a simple program called test.py > > # test.py > filename = raw_input("Please enter the file you want to open: ") > new_file = raw_input("Save the output file as: ") > > f = open(new_file, 'w') > new = open(filename, 'r') > > for line in new: > x = line.split('\t') > print >> f, x[0],':', x[1] > f.close() > > To make this example complete assume I have a text file like this > > # data.txt > 1 one > 2 two > 3 three > 4 four > > So, the user currently just follows directions on the screen, enters the > file names, and I get what I want. I'd like to try experimenting with > gui programming to see if the python programs I have written can be made > even more user friendly. I currently use py2exe to create executables so > that others in my organization can use these programs. > In that spirit, say I want to have a menu option that allows the user to > search their computer for this file, execute the python code and then > save the result as a user-defined filename. So, I guess my questions are > how do I associate the portion of code in menu.py > "filemenu.add_command(label="Open...", command=callback)" with an > operation that gives the user the ability to search the drives on their > machine and then once they do let python execute the code in test.py? The way it's written, you'll have a hard time doing it... Since test.py already includes a "user interface" via the raw_input calls, executing test.py will always ask the user for the file names, and there's no simple way to pass them otherwise as the module is written. Considering how you asked the question, I'll assume you don't know Python very much; my apologies in advance if it's not the case... So, what I would do is rewrite the test.py script as follows: --- test.py ----------------------------------- def convert_file(filename, new_file): f = open(new_file, 'w') new = open(filename, 'r') for line in new: x = line.split('\t') print >> f, x[0],':', x[1] f.close() if __name__ == '__main__': filename = raw_input("Please enter the file you want to open: ") new_file = raw_input("Save the output file as: ") convert_file(filename, new_file) ----------------------------------------------- This is basically the same as yours in another order, and defining a function that actually does the 'functional' part without asking the user anything. The last block - starting with this weird 'if __name__ == '__main__':' - ensures the script will work as you expect when you run it alone on the command line (with 'python test.py'). This is the meaning of the test on __name__: this magical variable is set to the string '__main__' if and only if the current script is the top-most one, i.e the one you ran python on. So basically, the script now defines a function, then asks for the function parameters and calls it _only if run as the main script_. Try it; it should have the same behaviour as the script you've written. But the test on __name__ also allows to *import* this script as a module in another script without nasty side effects. This is done via the statement: import test in the other script. If test.py is written as above, this will execute the function definition, but not the body of the 'if', since test.py is no more run from the command line, but used in an import. If you didn't have this test, the module would have been *executed* by the import, and is would have asked the file names immediatly. Once you've done the import, you can then use the function it defines by calling test.convert_file. So now, in your GUI part, you can now write something like: --- menu.py ---------------------------------- ## NEW! the next line gets the 'convert_file' function import test from Tkinter import * ## NEW! the next line gets the functions used to get file names via a Tkinter GUI from tkFileDialog import askopenfilename, asksaveasfilename ## NEW! the following function is the callback for the 'Open' menu entry def open_callback(): ## Get name of the input file input_file_name = askopenfilename() if not input_file_name: ## Dialog has been cancelled return ## Get name for output file output_file_name = asksaveasfilename() if not output_file_name: ## Dialog has been cancelled return ## Do the job test.convert_file(input_file_name, output_file_name) def callback(): print "called the callback!" root = Tk() # create a menu menu = Menu(root) root.config(menu=menu) filemenu = Menu(menu) menu.add_cascade(label="File", menu=filemenu) filemenu.add_command(label="New", command=harold) ## CHANGED! put the callback function defined above here filemenu.add_command(label="Open...", command=open_callback) filemenu.add_separator() filemenu.add_command(label="Exit", command=callback) helpmenu = Menu(menu) menu.add_cascade(label="Help", menu=helpmenu) helpmenu.add_command(label="About...", command=callback) mainloop() ---------------------------------------------- Try it: it should basically do what you were asking for. HTH -- python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])" From szport at gmail.com Thu Apr 3 09:53:11 2008 From: szport at gmail.com (Zaur Shibzoukhov) Date: Thu, 3 Apr 2008 17:53:11 +0400 Subject: Application of "with" statement in py3k. Property defining/redefining. Message-ID: http://szport.blogspot.com/2008/04/application-of-with-statement-in-py3k.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From cocoa at khiltd.com Sat Apr 12 22:59:27 2008 From: cocoa at khiltd.com (Nathan Duran) Date: Sat, 12 Apr 2008 19:59:27 -0700 Subject: Advice on tools/technologies/books, etc. In-Reply-To: References: Message-ID: <022CE681-D9F5-4BAC-BAE5-A68481A306AA@khiltd.com> On Apr 12, 2008, at 6:55 PM, python-list-request at python.org wrote: > Will it be possible for me to put together an async site > with only python? Nope. Not until some browser embeds a Python interpreter in it anyway. Your primary choices are JavaScript and Flash. From kyosohma at gmail.com Wed Apr 16 11:23:50 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 16 Apr 2008 08:23:50 -0700 (PDT) Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> Message-ID: <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> On Apr 16, 10:09 am, Steve Holden wrote: > Mike Driscoll wrote: > > On Apr 16, 9:19 am, Grant Edwards wrote: > >> This morning almost half of c.l.p was spam. In order to try to > >> not tar both the benign google group users and the malignant > >> ones with the same brush, I've been trying to kill usenet spam > >> with subject patterns. But that's not a battle you can win, so > >> I broke down and joined all the other people that just killfile > >> everything posted via google.groups. > > >> AFAICT, if you're a google groups user your posts are not being > >> seen by many/most experienced (read "non-google-group") users. > >> This is mainly the fault of google who has refused to do > >> anything to stem the flood of span that's being sent via Google > >> Groups. > > >> -- > >> Grant Edwards grante Yow! I would like to > >> at urinate in an OVULAR, > >> visi.com porcelain pool -- > > > Yeah, I noticed that Google Groups has really sucked this week. I'm > > using the Google Groups Killfile for Greasemonkey now and it helps a > > lot. I like Google, but my loyalty only goes to far. This is a > > complete lack of customer service. > > Unfortunately this means Google groups users are getting exactly the > service they are paying for. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ Steve, My workplace doesn't offer NNTP, so there is no good way to browse c.l.py here. And I haven't been able to get NNTP to work from my home either. By applying this logic to Python and Linux (or any Open Source product), they shouldn't be used either (since I'm not paying for them). Mike From ajaksu at gmail.com Thu Apr 3 20:54:23 2008 From: ajaksu at gmail.com (ajaksu) Date: Thu, 3 Apr 2008 17:54:23 -0700 (PDT) Subject: displaying execution of Python code References: <1afcbf34-0a40-4d11-b12f-603f0ee8f26c@m3g2000hsc.googlegroups.com> Message-ID: On Apr 3, 6:13?pm, noahwatkins wrote: > I'll start my question by describing my desired result. I will > construct a GUI which will be used to open a Python script. I would > then like to be able to display the Python script, execute it, and > highlight the lines of the Python as they are executing. Take a look at http://codeinvestigator.googlepages.com/main From greg.jandl at gmail.com Thu Apr 24 09:36:47 2008 From: greg.jandl at gmail.com (Greg J) Date: Thu, 24 Apr 2008 06:36:47 -0700 (PDT) Subject: Curious relation References: <613aa1f7-3943-4458-ba7e-4cb29c562988@y21g2000hsf.googlegroups.com> Message-ID: On Apr 24, 12:08 am, Dan Bishop wrote: > On Apr 23, 11:51 pm, Greg J wrote: > > > I was reading the programming Reddit tonight and came across this > > (http://reddit.com/info/6gwk1/comments/): > > > >>> ([1]>2)==True > > True > > >>> [1]>(2==True) > > True > > >>> [1]>2==True > > > False > > > Odd, no? > > > So, can anyone here shed light on this one? > > A long time ago, it wasn't possible for comparison operators to raise > exceptions, so it was arbitrarily decided that numbers are less than > strings. Thus, [1]>2 and [1]>False. This explains your first two > examples. Sure, those I understood. > For the third, remember that the comparison operators are chained, so > a>b==c means (a>b) and (b==c). Since 2==True is false, so is the > entire expression. Ach! Of course. For some reason I was blanking on the chained nature of relational operators in Python. Thanks for the reminder! > > In Python 3.0, all three of these expressions will raise a TypeError. From mfb.chikazuku at gmail.com Sun Apr 13 14:11:34 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Sun, 13 Apr 2008 20:11:34 +0200 Subject: urllib2 Basic authentication, what am I doing wrong? Message-ID: <48025b26$0$6839$2d805a3e@textnews.eweka.nl> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hey everybody, I'm having a little problem with urllib2 and Basic HTTP authentication. I have the following code: auth = urllib2.HTTPPasswordMgrWithDefaultRealm() auth.add_password(None, 'https://webmail.osg-erasmus.nl/oneNet/NetStorage/', user, password) authhandler = urllib2.HTTPBasicAuthHandler(auth) opener = urllib2.build_opener(auth) opener.addheaders = [('User-agent', 'Mozilla/5.0 Something/1.0')] try: return self.opener.open('https://webmail.osg-erasmus.nl/oneNet/NetStorage/') except urllib2.HTTPError, e: print e.code print e.headers This however does not allow me to authenticate. I keep getting back a 401: 401 Date: Sun, 13 Apr 2008 18:11:32 GMT Server: Apache/2.0.54 (NETWARE) mod_perl/1.99_12 Perl/v5.8.4 PHP/5.0.5 mod_nsn/1.0_0 mod_jk/1.2.14 Set-Cookie: novellsession1=8KuAO0iLyAEAAAAAAAAAAA==; path=/ WWW-Authenticate: Basic realm="ERASMUS-TREE" Vary: accept-language,accept-charset Accept-Ranges: bytes Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1 Content-Language: en Using this nice class (adapted to urllib2) as a basehandler I see that no Authentication-header is being send out: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440574 What am I doing wrong here? I spend almost my entire free time today on this and couldn't find any problem with my code, anyone else has a thought? Thanks in advance. MFB -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFIAkzaDpaqHmOKFdQRAh8WAJ0XbQD5EEmKxVdjndRWWzjwZzWaAgCgjdhR Esk6VBkZ+bEHsxFhg8h3Sy4= =XWrv -----END PGP SIGNATURE----- From esj at harvee.org Fri Apr 4 00:35:08 2008 From: esj at harvee.org (Eric S. Johansson) Date: Fri, 04 Apr 2008 00:35:08 -0400 Subject: Unicode conversion problem (codec can't decode) Message-ID: <47F5AFFC.3060902@harvee.org> I'm having a problem (Python 2.4) converting strings with random 8-bit characters into an escape form which is 7-bit clean for storage in a database. Here's an example: body = meta['mini_body'].encode('unicode-escape') when given an 8-bit string, (in meta['mini_body']), the code fragment above yields the error below. 'ascii' codec can't decode byte 0xe1 in position 13: ordinal not in range(128) the string that generates that error is:
Reduce Wh?t You Owe by 50%. Get out of debt today!
Reduuce Interest & |V|onthlyy Payme?ts Easy, we will show you how..
Freee Quote in 10 Min.
http://www.freefromdebtin.net.cn I've read a lot of stuff about Unicode and Python and I'm pretty comfortable with how you can convert between different encoding types. What I don't understand is how to go from a byte string with 8-bit characters to an encoded string where 8-bit characters are turned into two character hexadecimal sequences. I really don't care about the character set used. I'm looking for a matched set of operations that converts the string to a seven bits a form and back to its original form. Since I need the ability to match a substring of the original text while the string is in it's encoded state, something like Unicode-escaped encoding would work well for me. unfortunately, I am missing some knowledge about encoding and decoding. I wish I knew what cjson was doing because it does the right things for my project. It takes strings or Unicode, stores everything as Unicode and then returns everything as Unicode. Quite frankly, I love to have my entire system run using Unicode strings but again, I missing some knowledge on how to force all of my modules to be Unicode by default any enlightenment would be most appreciated. ---eric -- Speech-recognition in use. It makes mistakes, I correct some. From skanemupp at yahoo.se Thu Apr 10 06:54:59 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 03:54:59 -0700 (PDT) Subject: questions about Exceptions? References: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> <71cc8c25-f5f9-4f21-a9d8-06780bf97608@f63g2000hsf.googlegroups.com> <9af81b1a-3e02-4406-b9d2-0a9b6f46566b@p39g2000prm.googlegroups.com> <0e586d5d-6799-433f-b8a4-4de5d2a87b61@h1g2000prh.googlegroups.com> <46a79564-4069-46af-b6ab-b38bd9152c2a@d45g2000hsc.googlegroups.com> Message-ID: <1f413b6e-f964-4f8d-b781-61985f86acc2@a9g2000prl.googlegroups.com> On 10 Apr, 12:38, cokofree... at gmail.com wrote: > > def Calc(): > > global nbr > > try: > > print eval(nbr) > > #a = Label(mygui, text=eval(nbr)) > > #a.place(relx=0.4, rely=0.1, anchor=CENTER) > > except: > > print "Not computable" > > nbr = "" > > > def Erase(): > > global nbr > > nbr = "" > > Seems to me you could be better off passing a parameter and a return > statement of None (or your parameter cleaned) for those functions, > which should work. Given an input, Eval it and then return None. That > way you wouldn't need the Erase... the erase() id alwys need if u wanna abort whilst u wrote something. From dieter at handshake.de Mon Apr 28 13:10:16 2008 From: dieter at handshake.de (Dieter Maurer) Date: 28 Apr 2008 19:10:16 +0200 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> Message-ID: Nick Stinemates writes on Thu, 24 Apr 2008 08:26:57 -0700: > On Tue, Apr 22, 2008 at 04:07:01AM -0700, GD wrote: > > Please remove ability to multiple inheritance in Python 3000. I hope your request will not be followed. > > Multiple inheritance is bad for design, rarely used and contains many > > problems for usual users. Multiple inheritance is very productive by supporting mixin classes. I use it extensively and get clean code quickly developped. I hate Java because it does not support multiple inheritance and forces me to write lots of tedious error prone delegations to work around this limitation. Dieter From gagsl-py2 at yahoo.com.ar Tue Apr 1 13:37:44 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 14:37:44 -0300 Subject: Adding Images to MySQL References: <4dc0cfea0804010536q71bce9ev38cff43923f5a4b8@mail.gmail.com> Message-ID: En Tue, 01 Apr 2008 09:36:00 -0300, Victor Subervi escribi?: > Hi; > I?m trying to figure out how to upload images into a MySQL database. > (Yes, > that is what I want to do.) I have a form that asks for data, like this: > 1ra Foto Peque?a: > > Then I send that form to a python script that processes like this: > cursor.execute('insert into products (' + col_names + ') values (' + > col_values + ');') > where col_names is all the names of the columns and col_values, > obviously, > the values. Works fine for strings and digits. Not so well for files :) > What > do? Always use bound parameters - not only it's easier and less error prone, it's safer too. How parameters are specified depends on the DBAPI module you're using - read the module documentation. I think MySQLdb accept dictionary-like marks: values = {'name': 'Red jar', 'descr': 'A nice red jar', 'pic': binary(picdata) } cursor.execute('''insert into products (name,description,picture) values (%(name)s, %(descr)s, %(pic)s);''', values) See PEP249 http://www.python.org/dev/peps/pep-0249/ and the documentation for your database module. -- Gabriel Genellina From dboddie at trolltech.com Tue Apr 1 09:42:07 2008 From: dboddie at trolltech.com (David Boddie) Date: Tue, 1 Apr 2008 15:42:07 +0200 Subject: PyQt - How to prevent a dialog being resized? Message-ID: <200804011542.07392.dboddie@trolltech.com> On Apr 1, 12:12 am, Kelie wrote: > > My question is as subject. I tried something like this and it doesn't > > work. > > > > def resizeEvent(self, event): > > self.size = event.oldSize() > > > > Any hint? > > If you use the Qt designer you can set the minimum- and maximum window > size to the same value, which disables resize as well. Tested with Qt4 > on Linux 2.6. But I'm pretty sure that there could be a much cleaner > way to do this. You can give a window a fixed size by calling its setFixedSize() method, but this requires you to decide its exact size in pixels. A better alternative is to call setSizeConstraint() on the window's layout with a value of SetFixedSize: http://www.riverbankcomputing.com/Docs/PyQt4/html/qlayout.html#SizeConstraint-enum This way, the layout will figure out how much space the window requires and force it to remain at that size from then on. David -- David Boddie Lead Technical Writer, Trolltech ASA From sjmachin at lexicon.net Mon Apr 7 05:17:24 2008 From: sjmachin at lexicon.net (John Machin) Date: Mon, 7 Apr 2008 02:17:24 -0700 (PDT) Subject: Python Data Utils References: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> <8eec6557-784d-4fd8-8478-8da17aedf0ab@d1g2000hsg.googlegroups.com> <85979669-64ed-49a1-b154-595bed50179f@w5g2000prd.googlegroups.com> <204305df-2cc8-4f44-8b98-5696e135a936@d45g2000hsc.googlegroups.com> Message-ID: On Apr 7, 4:22?pm, Jesse Aldridge wrote: > > > changing "( " to "(" and " )" to ")". > > Changed. But then you introduced more. > > I attempted to take out everything that could be trivially implemented > with the standard library. > This has left me with... 4 functions in S.py. ?1 one of them is used > internally, and the others aren't terribly awesome :\ ?But I think the > ones that remain are at least a bit useful :) If you want to look at stuff that can't be implemented trivially using str/unicode methods, and is more than a bit useful, google for mxTextTools. > > > A basic string normalisation-before-comparison function would > > usefully include replacing multiple internal whitespace characters by > > a single space. > > I added this functionality. Not quite. I said "whitespace", not "space". The following is the standard Python idiom for removing leading and trailing whitespace and replacing one or more whitespace characters with a single space: def normalise_whitespace(s): return ' '.join(s.split()) If your data is obtained by web scraping, you may find some people use '\xA0' aka NBSP to pad out fields. The above code will get rid of these if s is unicode; if s is str, you need to chuck a .replace('\xA0', ' ') in there somewhere. HTH, John From fredrik at pythonware.com Sat Apr 5 11:09:50 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 17:09:50 +0200 Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! In-Reply-To: References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <65ondkF2g48puU2@mid.uni-berlin.de> Message-ID: skanemupp at yahoo.se wrote: >> def __init__(self): >> # ... >> button = Button(self, >> text='1', >> command=lambda n=1: self.display(n)) >> # ... >> >> def display(self, number): >> print number > > should this really be inside the __init__ function? what's wrong with creating widgets in an __init__ method? From fredri8758lupo at gmail.com Wed Apr 23 06:08:11 2008 From: fredri8758lupo at gmail.com (fredri8758lupo at gmail.com) Date: Wed, 23 Apr 2008 03:08:11 -0700 (PDT) Subject: windows xp pro cracks Message-ID: <3f124f94-f708-4fb8-bb17-a71ed1fbbebb@t63g2000hsf.googlegroups.com> windows xp pro cracks http://cracks.12w.net F R E E C R A C K S From simon at brunningonline.net Tue Apr 8 06:29:41 2008 From: simon at brunningonline.net (Simon Brunning) Date: Tue, 8 Apr 2008 11:29:41 +0100 Subject: Learning curve for new database program with Python? In-Reply-To: References: Message-ID: <8c7f10c60804080329k7e6540fdre71adc8fe4383366@mail.gmail.com> On Mon, Apr 7, 2008 at 7:19 PM, Gary Duzan wrote: > It seems to me that ORM can work if your database isn't too > complex and it is the only way your database is going to be accessed. I'm working on a big, complex system using an ORM at the moment - http://gu.com. It's a Java/Hibernate/Spring system rather than anything Python based, but the principle is the same. We find that the ORM works great for 99% of our DB interaction, and saves a lot of tedious fiddling around. *But*, the 1% is crucial. Using an ORM doesn't mean you don't have to understand what's going on underneath. When you need to hand craft a performance critical query, or when you are chasing down a bug, you need to know SQL, and know it well. C.F. The Law of Leaky Abstractions - http://tinyurl.com/bmvn. It's not either SQL or ORM. It's both. But SQL should come first. -- Cheers, Simon B. simon at brunningonline.net http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues From gabriel.rossetti at mydeskfriend.com Tue Apr 8 03:50:52 2008 From: gabriel.rossetti at mydeskfriend.com (Gabriel Rossetti) Date: Tue, 08 Apr 2008 09:50:52 +0200 Subject: Destructor? In-Reply-To: <47FB1EA8.6000801@mattnordhoff.com> References: <47FB1937.5050008@mydeskfriend.com> <47FB1E5E.6010708@mattnordhoff.com> <47FB1EA8.6000801@mattnordhoff.com> Message-ID: <47FB23DC.2040109@mydeskfriend.com> Matt Nordhoff wrote: > Matt Nordhoff wrote: > >> Gabriel Rossetti wrote: >> >>> Hello everyone, >>> >>> we are writing an application that needs some cleanup to be done if the >>> application is quit, normally (normal termination) or by a signal like >>> SIGINT or SIGTERM. I know that the __del__ method exists, but unless I'm >>> mistaken there is no guarantee as of when it will be called, and some >>> objects may have already been released (at lease I've had trouble in the >>> past accessing certain objects from inside __del__, probably since the >>> parent class's __del__ has to be called first, then it's objects are >>> already released by the time I need to do something with them). Another >>> method would be to implement something using the signal module and have >>> a callback that does all the cleanup when the app. is >>> quit/terminated/interrupted and have all the child classes override that >>> with their cleanup code. >>> >>> What is the community's point of view on the subject? >>> >>> Thanks, >>> Gabriel >>> >> atexit? >> >> If it's only small things, there's try...finally, of course.. >> > > Huh, I totally didn't know that atexit is only run on normal > terminations. Oops. Never mind. > Yes, and I just saw that windows (my app has to support Linux, Mac OS X and Windows) does not know about SIGINT and SIGTERM is apparently there for ANSI compatibility by an app has to explicitly raise it...every line of code I right I had windows more and more.... From nagle at animats.com Sat Apr 5 21:31:52 2008 From: nagle at animats.com (John Nagle) Date: Sat, 05 Apr 2008 18:31:52 -0700 Subject: Learning curve for new database program with Python? In-Reply-To: References: Message-ID: <47f82573$0$36352$742ec2ed@news.sonic.net> Jetus wrote: > I have a need for a database program. I downloaded the db2 from ibm, > and reviewed some of the documentation. > > My question is, what is the easiest program for me to try to learn. I > will be creating a database of about 25,000 records, it will be > relational. I am a beginner Python programmer, and need a database > solution that is easy to grasp. I played with sql, > and found that very difficult, if not overly cumbersome. Basic SQL isn't that hard. Learn CREATE, SELECT, INSERT, UPDATE, and DELETE syntax. That's enough for most simple applications. I'd suggest using sqlite if you're doing something that runs as a single standalone application, and MySQL if there are multiple users of the database or it's a web service. IBM's DB2 or Oracle is overkill for 25,000 records. Install MySQL and its graphical client, and play with it a bit. Create a table, type in a few records, and try various SELECT statements. That will give you a sense of how SQL works. John Nagle From ellingt8877 at gmail.com Mon Apr 28 01:45:23 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:45:23 -0700 (PDT) Subject: quickbooks premier 2007 registration crack Message-ID: <6dd92209-23f9-4619-94b3-f9803cb5d25a@34g2000hsf.googlegroups.com> quickbooks premier 2007 registration crack http://crack.cracksofts.com From kenneth.m.mcdonald at sbcglobal.net Sun Apr 20 21:58:06 2008 From: kenneth.m.mcdonald at sbcglobal.net (Kenneth McDonald) Date: Sun, 20 Apr 2008 20:58:06 -0500 Subject: Python script to automate use of Google Translate? (or other translator) Message-ID: <0FF8C4DE-8FBC-40C5-85B8-E10DD86F4CE7@sbcglobal.net> I have the need to occasionally translate a single word programatically. Would anyone have a Python script that would let me do this using Google (or another) translation service? Thanks, Ken From huayang.xia at gmail.com Thu Apr 10 17:45:04 2008 From: huayang.xia at gmail.com (Huayang Xia) Date: Thu, 10 Apr 2008 14:45:04 -0700 (PDT) Subject: Convert PyIDispatch object to struct IDispatch* Message-ID: <90eee1e1-b1cc-48a9-8c09-173e92861f2c@a5g2000prg.googlegroups.com> I am trying to use ctypes to call dll functions. One of the functions requires argument "struct IDispatch* ". I do have a PyIDispatch object in python. How can I convert this "PyIDispatch object" to "struct IDispatch* "? Thanks in advance. From torriem at gmail.com Tue Apr 15 16:16:20 2008 From: torriem at gmail.com (Michael Torrie) Date: Tue, 15 Apr 2008 14:16:20 -0600 Subject: Java or C++? In-Reply-To: <525142.84411.qm@web39208.mail.mud.yahoo.com> References: <525142.84411.qm@web39208.mail.mud.yahoo.com> Message-ID: <48050D14.6040801@gmail.com> Ben Kaplan wrote: > The fact that C# is a .NET language is also a major weakness, since you can only use it on Windows. Really? I have developed several C# .NET applications and I only use OS X and Linux. Guess I imagined it. Also, IronPython runs very well on Linux and OS X. If you'd said that the weakness was a patent minefield when running on a non-windows platform, then I'd totally agree with you. From sturlamolden at yahoo.no Fri Apr 25 15:56:21 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 25 Apr 2008 12:56:21 -0700 (PDT) Subject: Calling Python code from inside php References: Message-ID: <2327c134-a9e5-4e7f-8b7a-ccd6e080bd20@y38g2000hsy.googlegroups.com> On Apr 23, 9:08 pm, MC wrote: > If you are under Windows, you can: > - call Python's functions via Active-Scripting > - call a Python COM server (functions or properties) > > For that, use Pywin32. And, in all cases, call functions can use > parameters. This is perhaps the preferred solution if the web server is IIS and not Apache. From jeffrey at fro.man Thu Apr 10 19:49:02 2008 From: jeffrey at fro.man (Jeffrey Froman) Date: Thu, 10 Apr 2008 16:49:02 -0700 Subject: Adding classes to modules at runtime from outside that module References: Message-ID: frambooz at gmail.com wrote: > In Python, is it possible to add classes to a module at run-time? > > Say I have a module foo and a module bar. Foo has class A and B, and > bar has class C. I want to add class C to foo so I can access it as > foo.C, but i want to do it without modifying foo's source. > > Is this at all possible? Yes, possible and easy: # bar.py import foo class C(object): ... foo.C = C Jeffrey From mnordhoff at mattnordhoff.com Mon Apr 7 03:13:47 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Mon, 07 Apr 2008 07:13:47 +0000 Subject: Help replacing os.system call with subprocess call In-Reply-To: <47F9C764.9070401@mattnordhoff.com> References: <47F9B1D1.4090701@eastlink.ca> <47F9C764.9070401@mattnordhoff.com> Message-ID: <47F9C9AB.3070608@mattnordhoff.com> Matt Nordhoff wrote: > David Pratt wrote: >> Hi. I am trying to replace a system call with a subprocess call. I have >> tried subprocess.Popen and subprocess.call with but have not been >> successful. The command line would be: >> >> svnadmin dump /my/repository > svndump.db >> >> This is what I am using currently: >> >> os.system('svnadmin dump %s > %s' % (svn_dir, >> os.path.join(backup_dir, 'svndump.db'))) >> >> Many thanks. > > Try this: > > import os.path > import subprocess > > p = subprocess.Popen( > ['svnadmin', 'dump', svndir], > stdout=subprocess.PIPE, > ) > > fh = open(os.path.join(backup_dir, 'svndump.db'), 'wb') > > while True: > chunk = p.stdout.read(2**20) # 1 MB > if not chunk: > break > fh.write(chunk) > > fh.close() > > It reads svnadmin's stdout in 1 MB chunks, in case it's large enough > that reading the whole thing into RAM at once would be a bad idea. > > No error handling. For one, you might want to add a try...finally to > ensure that fh will get closed. (Or if you have Python 2.5, use a with > statement! :-) ) Also, Popen will raise an OSError if svnadmin can't be > found or something. And this isn't even considering svnadmin erroring out... > > svnadmin's stderr will go to your stderr. > > I didn't test it, but I'm pretty sure it will work. (I spotted a syntax > error while writing that though.) I don't have much experience with > Popen's stdio objects, so it's possible you'd need to do something like > call p.wait() to wait for it to exit before being able to read its stdout. > > It could be slower than the os.system version, since now Python is doing > all of the I/O, instead of your shell, but I doubt that'll be a big problem. > > (Also, insert suggestion about using a good VCS. ;-) ) This might work too: import os.path import subprocess fh = open(os.path.join(backup_dir, 'svndump.db'), 'wb') p = subprocess.Popen( ['svnadmin', 'dump', svndir], stdout=fh, ) # Wait for svnadmin to exit so that fh can be closed p.wait() fh.close() With this, svnadmin's stdout is directly set to the file. Python isn't being an intermediary reading from stdout and writing it to the file. At least, that's how I expect it would work. I didn't test this either. In particular, if Popen doesn't behave how I expect it should, it might buffer the entirety of stdout in memory or something, which would be bad if your svn repo is really large... -- From torriem at gmail.com Wed Apr 16 16:24:52 2008 From: torriem at gmail.com (Michael Torrie) Date: Wed, 16 Apr 2008 14:24:52 -0600 Subject: Finally had to plonk google gorups. In-Reply-To: References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: On Wed, Apr 16, 2008 at 11:49 AM, Mike Driscoll wrote: > I don't think I like the email list idea all that much. I'm already on > a number of them and they fill up my box like crazy. Besides that, in > email format it's hard to follow the thread, so one moment I'm reading > about the latest ding dong and the next is a response to a post from > last week. Using a good client like Thunderbird, and e-mails thread just fine. Nesting as deep as need be. On my client (I use thunderbird for everything), it looks the same whether I use NNTP or mailing lists. It's all good. As for filling up your inbox, that never happens to me. My inbox gets maybe 1 new message a day. Everything else is automatically filed into the right folder, just like how NNTP shows you individual groups. Gmail makes this very easy to do with their filters. For others there is procmail. Honestly a few minutes of work is very much worth it. For those that want to keep using nntp and put up with the spam (no server-side spam processing there), that's great, though. Finally as for threading being difficult, yes it is if you use GMail's web client. "Conversations" are *not* threads, sadly. It's a broken interface that's becoming popular unfortunately. I've always hated web forums for the same reasons. Conversations also don't deal very well with changes in the subject line that reflect new directions or forks in the current topic. > But I agree...there are other alternatives. I'll have to start trying > them again I suppose. If I have to, I guess. :) From bhawsar.vaibhav at gmail.com Fri Apr 25 02:58:53 2008 From: bhawsar.vaibhav at gmail.com (Vaibhav.bhawsar) Date: Fri, 25 Apr 2008 02:58:53 -0400 Subject: how to mysqldb dict cursors In-Reply-To: <481161FD.5020407@ulmcnett.com> References: <17d58cc40804241950i7b624e1apd2733daa79b3ed5c@mail.gmail.com> <481161FD.5020407@ulmcnett.com> Message-ID: <17d58cc40804242358s26446c42h36f875cf0ee62199@mail.gmail.com> Great both methods worked! I dont quite understand this since i imported the whole module with "import MySQLdb" Thanks! On Fri, Apr 25, 2008 at 12:45 AM, Paul McNett

wrote: > Vaibhav.bhawsar wrote: > >> I have been trying to get the DictCursor working with mysqldb module but >> can't seem to. I have pasted the basic connection code and the traceback >> from pydev. The connection does open with the default cursor class. can't >> figure this one out. many thanks. >> > > Try one of: > > """ > import MySQLdb, MySQLdb.cursors > conn = MySQLdb.connect(..., cursorclass=MySQLdb.cursors.DictCursor) > """ > > -or- > > """ > import MySQLdb, MySQLdb.cursors > conn = MySQLdb.connect(...) > cur = MySQLdb.cursors.DictCursor(conn) > """ > > I'm going off of memory here, though, but I'm at least close. > > Paul > > -- Vaibhav Bhawsar -------------- next part -------------- An HTML attachment was scrubbed... URL: From rbrito at ime.usp.br Mon Apr 28 16:44:41 2008 From: rbrito at ime.usp.br (=?ISO-8859-1?Q?Rog=E9rio_Brito?=) Date: Mon, 28 Apr 2008 17:44:41 -0300 Subject: Little novice program written in Python References: Message-ID: On 04/25/2008 01:09 AM, Dennis Lee Bieber wrote: > On Thu, 24 Apr 2008 21:31:15 -0300, Rog?rio Brito > declaimed the following in comp.lang.python: >> a = [i for i in range(0,n+1)] > > Uhm... At least in 2.4 and earlier, range() returns a list... No > need for the list-comp in that era... range() also begins with 0 Thanks for the suggestion. As I stated in my original message, I'm only "side-learning" Python, and I naturally think in list-comprehensions (it is like a set in Mathematics and you've seen that my program is Mathematical in its nature). This is exactly the kind of suggestion that I was looking for. Thanks, Rog?rio. -- Rog?rio Brito : rbrito@{mackenzie,ime.usp}.br : GPG key 1024D/7C2CAEB8 http://www.ime.usp.br/~rbrito : http://meusite.mackenzie.com.br/rbrito Projects: algorithms.berlios.de : lame.sf.net : vrms.alioth.debian.org From john106henry at hotmail.com Sun Apr 27 00:01:51 2008 From: john106henry at hotmail.com (John Henry) Date: Sat, 26 Apr 2008 21:01:51 -0700 (PDT) Subject: How do I say "Is this a function"? References: <4813D22A.8040902@v.loewis.de> Message-ID: On Apr 26, 6:08?pm, "Martin v. L?wis" wrote: > > def f1(): > > ? ?print "In f1" > > > def f3(): > > ? ?print "In f3" > > > def others(): > > ? ?print "In others" > > > for i in xrange(1,3): > > ? ?fct = "f%d()"%(i+1) > > ? ?try: > > ? ? ? exec fct > > ? ?except: > > ? ? ? others() > > I'd write that as > > for i in xrange(1,3): > ? ? globals().get("f%d" % (i+1), others)() > > Regards, > Martin Perfect. Works great. No EXEC. You guys are great. From leoniaumybragg at gmail.com Sat Apr 26 06:58:13 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:58:13 -0700 (PDT) Subject: investronica crack Message-ID: <0be60373-ed63-4a3d-8559-125db03332b9@a22g2000hsc.googlegroups.com> investronica crack http://cracks.00bp.com F R E E C R A C K S From skanemupp at yahoo.se Wed Apr 16 09:00:08 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Wed, 16 Apr 2008 06:00:08 -0700 (PDT) Subject: py2exe, program has stoped working!? References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> <232151d6-09ed-4a1e-9922-d66c2bf0d05b@w8g2000prd.googlegroups.com> Message-ID: <06add3fd-3ff9-4dce-8d33-6bc92f36b5d8@26g2000hsk.googlegroups.com> On 14 Apr, 14:11, John Machin wrote: > On Apr 14, 7:24 pm, skanem... at yahoo.se wrote: > > > > > > Is it a console program or a gui program? > > GUI > > > What happens when you run it without py2exe? > > > it works perfectly, both from within python and launching from > > "windows" > > > > Have you searched for "has stopped working" in > > > (a) your source code > > yes no such message there> (b) the py2exe source code? > > > no, will do but doubt thats the problem > > > > Have you managed to get any py2exe-created program to run properly? > > > no > > Well, perhaps you might like to look in the samples directory of the > py2exe distribution and choose a simple example and try that. > > By the way, "popup" is what you get in a web browser. What did this > "popup" look like: a panel from your GUI software? A Windows message > box? Did it have a title across the top? What was the exact text in > the popup/panel/box? Were there any options other than to close the > window? > > Which version of Python? Which Windows, what service pack? What GUI, > what version? Care to divulge the contents of your setup.py? Apart > from your GUI, what 3rd party packages/modules are you importing? its a windows message as others have said. only option to close the window. 2.5python windows vista tkinter GUI im importing tkinter and from future import division From george.sakkis at gmail.com Tue Apr 22 10:36:04 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 22 Apr 2008 07:36:04 -0700 (PDT) Subject: Remove multiple inheritance in Python 3000 References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <6760jfF2n3bn1U1@mid.uni-berlin.de> Message-ID: <6bec3c67-689a-4df2-848f-d3936a143024@f36g2000hsa.googlegroups.com> On Apr 22, 10:22?am, Carl Banks wrote: > Java (for example) allows a class to share behavior with only one > other class, and that *severely* limits the opportunities to minimize > redundancy. Not really; composition is usually a better way to share functionality and reduce redundancy than inheritance. George From ridenour4159 at gmail.com Thu Apr 24 06:17:09 2008 From: ridenour4159 at gmail.com (ridenour4159 at gmail.com) Date: Thu, 24 Apr 2008 03:17:09 -0700 (PDT) Subject: the apple patch diet Message-ID: the apple patch diet http://cracks.12w.net F R E E C R A C K S From gh at gregor-horvath.com Fri Apr 25 14:59:20 2008 From: gh at gregor-horvath.com (Gregor Horvath) Date: Fri, 25 Apr 2008 20:59:20 +0200 Subject: Why is None <= 0 In-Reply-To: References: Message-ID: D'Arcy J.M. Cain schrieb: > On Fri, 25 Apr 2008 20:27:15 +0200 > Gregor Horvath wrote: >> >>> None <= 0 >> True >> >> Why? > > Why not? Because, from http://www.python.org/dev/peps/pep-0020/ : Errors should never pass silently. In the face of ambiguity, refuse the temptation to guess. Greg From cbhoem at gmail.com Mon Apr 28 09:42:30 2008 From: cbhoem at gmail.com (cbhoem at gmail.com) Date: Mon, 28 Apr 2008 06:42:30 -0700 (PDT) Subject: Cookie Confusion - How to Set a Cookie Message-ID: <588d6a6c-0080-48a4-b768-e2c5ef551790@s50g2000hsb.googlegroups.com> Hi - I am trying my hand at python cookies. I'm confused about a few things though. Do the python cookies get written to a cookies text file? I have simple code below -- I see the cookie in my HTTP header but do not get anything in the cookie text file. I'm working on linux. print "Content-type: text/html" cookie = Cookie.SimpleCookie() cookie['Test'] = 'abc' print cookie print Are there rules about where in the header the set cookie line should be? Thanks in advance! Christian From Robert.Bossy at jouy.inra.fr Tue Apr 8 11:40:06 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Tue, 08 Apr 2008 17:40:06 +0200 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. In-Reply-To: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> Message-ID: <47FB91D6.6040601@jouy.inra.fr> Hi, First thing, I appreciate (and I'm positive we all do) if you DID'N YELL AT ME. subhabrata.iisc at hotmail.com wrote: > I am using Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v. > 1310 32 bit (Intel)] on win32 with IDLE 1.2.1 > My O/S is Windows XP SP2 I use 512 MB RAM. > I am encountering the following problems: > (i) a1=1 > a2=2 > a3=a1+a2 > print a3 > # The result is coming sometimes as 3 sometimes as vague numbers. > On all computers I work with (two at work and one at home), it always gives me 3. > (ii) x1="Bangalore is called the Silicon Valley of India" > x2="NewYork" > x3=x1.find(x2) > print x3 > # The result of x3 is coming as -1 as well as +ve numbers. > On my computer, this always gives me -1 which is what I expected since x2 not in x1. Are you sure you posted what you wanted to show us? > (iii) I have been designing one crawler using "urllib". For crawling > one web page it is perfect. But when I am giving around 100 URLs by > and their links and sublinks the IDLE is not responding. Presently I > have been running with 10 URLs but can't it be ported? > Maybe you've implemented quadratic algorithms, or even exponential. Sorry, I cannot see without more specifics... > (iv) I have designed a program with more than 500 if elif else but > sometimes it is running fine sometimes it is giving hugely erroneous > results, one view of the code: > elif a4==3: > print "YOU HAVE NOW ENTERED THREE WORDS" > if a3[0] not in a6: > if a3[1] not in a6: > if a3[2] not in a6: > print "a3[0] not in a6, a3[1] not in a6, a3[2] not > in a6" > elif a3[2] in a6: > print "a3[0] not in a6, a3[1] not in a6, a3[2] in > a6" > else: > print "NONE3.1" > elif a3[1] in a6: > if a3[2] not in a6: > print "a3[0] not in a6, a3[1] in a6, a3[2] not in > a6" > elif a3[2] in a6: > print "a3[0] not in a6,a3[1] in a6, a3[2] in a6" > else: > print "NONE3.2" > else: > print "NONE3.3" > elif a3[0] in a6: > if a3[1] not in a6: > if a3[2] not in a6: > print "a3[0] in a6, a3[1] not in a6, a3[2] not in > a6" > elif a3[2] in a6: > print "a3[0] in a6, a3[1] not in a6, a3[2] in a6" > else: > print "NONE3.4" > elif a3[1] in a6: > if a3[2] not in a6: > print "a3[0] in a6, a3[1] in a6, a3[2] not in a6" > elif a3[2] in a6: > print "a3[0] in a6, a3[1] in a6, a3[2] in a6" > else: > print "NONE3.5" > else: > print "NONE3.6" > else: > print "NONE3.7" > I guess you're looking for one or several of three strings inside a longer string. The algorithm is quadratic, no wonder your software doesn't respond for larger datasets. Someone spoke about Aho-Corasick recently on this list, you should defenitely consider it. Moreover, the least we could say is that it doesn't loks pythonic, do you think the following does the same thing as your snip? L = [] for i, x in enumerate(a3): if x in a6: L.append('a3[%d] in a6' % i) else: L.append('a3[%d] not in a6' % i) print ', '.join(L) RB From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 24 04:46:25 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 24 Apr 2008 10:46:25 +0200 Subject: @classmethod question In-Reply-To: References: Message-ID: <481048cf$0$13051$426a74cc@news.free.fr> Scott SA a ?crit : > Hi, > > I'm using the @classemethod decorator for some convenience methods > and for some reason, either mental block or otherwise, can't seem to > figure out how to elegantly detect if the call is from an instance or > not. Well, the point is that a classmethod *always* receive the class as first argument, wether it's called on the class or an instance. If that's not what you want, then you don't use the right tool. > Here's the problem: Within the class definition, 'isinstance' has nothing to compare to because the class does not appear to exist. > > This is NOT a great example, but it outlines the the code: > > class RecipieClass: > def __init__(self): > pass > > @classmethod > def get_ingrendients(self, recipie_list=None): > > if isinstnace(self,RecipieClass): > return self.do_something_interesting() > else: > return do_something_boring(recipie_list) > > Yes, I can test to see if the param exists, but that makes the call > exclusive i.e. I can _only_ call it as an instance or with a parameter. > > Why am I doing this? > > It is a series of convenience methods, in this case I'm interacting > with a database via an ORM (object-relational model). out of curiosity : which one ? > I want the ability > to call a class-ojbect and get related values, or pass some criteria and > get related values for them without collecting the records first as > instances, then iterating them. I need to call this from several places > so I want to be DRY (don't repeat yourself). > > The easiest way to describe this as an analogy would be like having a > recipie for cookies and wanting to know all of the ingredients ahead of > time. Then, at another time, wanting to know what all the ingredients > would be to make cookies, cake and bread (i.e. complete shopping list). > cookie_recipie = RecipieClass.get_recipie('cookies') > cookie_recipie.get_ingredients() > 2C Flour > 0.5 C Sugar > ... > > RecipieClass.get_ingrendients(['cookies','cake','bread']) > 8C Flour > 2C Sugar > ... > Of course any suggestions on how this might be better approached would > be interesting too. Why do you want the same method to do two different things ? You clearly have two distincts methods doing different things here, and as a user of your code I'd find your API confusing. May I suggest a much simpler approach: class Recipies(object): @property def ingredients(self): return @classmethod def get_ingredients_for(cls, *id_recipies): return print Recipie.get('cookie').ingredients print Recipies.get_ingredients_for('cookie', 'cake', 'bread') My 2 cents... From arnodel at googlemail.com Sun Apr 20 02:17:58 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sat, 19 Apr 2008 23:17:58 -0700 (PDT) Subject: manipulating class attributes from a decorator while the class is being defined References: Message-ID: <1597dce1-a489-44e7-8f32-988a16243fd9@l64g2000hse.googlegroups.com> On Apr 19, 10:19?pm, Wilbert Berendsen wrote: > Hi, is it possible to manipulate class attributes from within a decorator > while the class is being defined? > > I want to register methods with some additional values in a class attribute. > But I can't get a decorator to change a class attribute while the class is > still being defined. Something like: > > class Parser(object): > > ? regexps = [] > ? def reg(regexp): > ? ? def deco(func): > ? ? ? regexps.append((regexp, func)) > ? ? ? return func > ? ? return deco > > ? @reg(r'".*"') > ? def quoted_string(self): > ? ? pass > > How can I reach the class attribute `regexps' from within a decorator? In this particular example, it is enought to change the line def reg(regexp): to: def reg(regexp, regexps=regexps): So that 'regexps' inside reg() will point to the same object as 'regexps' outside reg(). Of course it wouldn't work well with inheritance, but it seems to me that you don't want to subclass 'Parser' anyway. If you did, you could instead have something like this: class Ruleset(list): def add(self, regexp): def decorator(func): self.append((regexp, func)) return func return decorator class Parser(object): rules = Ruleset() @rules.add(r'".*"') def quoted_string(self): pass Or, yet another solution is to change the metaclass of 'Parser' so that it populates the class's rules by scanning its attributes. HTH -- Arnaud From darcy at druid.net Wed Apr 30 12:01:16 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Wed, 30 Apr 2008 12:01:16 -0400 Subject: Colors for Rows In-Reply-To: <4dc0cfea0804300857h6a7a8aa6l25aa0a3e82da12c0@mail.gmail.com> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> <20080429121105.f10c3862.darcy@druid.net> <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> <1209495803.5173.11.camel@aalcdl07.lib.unc.edu> <20080429153930.a6eddea6.darcy@druid.net> <1209500446.5510.4.camel@aalcdl07.lib.unc.edu> <4dc0cfea0804300857h6a7a8aa6l25aa0a3e82da12c0@mail.gmail.com> Message-ID: <20080430120116.c07f028f.darcy@druid.net> On Wed, 30 Apr 2008 10:57:44 -0500 "Victor Subervi" wrote: > Thank you all. You helped clean up my code. The stupid mistake was in where > I set the initial value of the variable z. Really? I thought that it was odd to start in the middle of your colour list but it didn't seem like it was an error. What do you think was wrong with it? -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From frikker at gmail.com Wed Apr 30 10:07:28 2008 From: frikker at gmail.com (blaine) Date: Wed, 30 Apr 2008 07:07:28 -0700 (PDT) Subject: I messed up my wxPython install (Eclipse Configuration Issue) Message-ID: <18eb0a7c-96f4-41de-b44f-95fd8ba0223f@f63g2000hsf.googlegroups.com> The wxPython group is a bit stale compared to this group, so I'll give it a shot :) (READ: Originally when I started htis post, Python 2.5 at the shell did not work (identical behavior to eclipse). I'm not sure why, but it has since worked fine with no problems. Not sure whats going on there... I didn't change anything. Anyways...) Ok so I am having this problem. I am using OS X 10.4. I use MacPython and installed wxPython a few months back, and it worked great. Well I haven't done any wx development lately, and now that I'm getting back into it I can't get wx to work properly. I'm using Eclipse, too. Python 2.5 at Shell: works just fine $ python >>> import wx OLD projects in Eclipse: import wx works fine NEW projects in Eclipse (since I have started working wx again after a few months): import wx /Users/frikk/Documents/workspace/Bili_UI/src/wx.py:3: DeprecationWarning: The wxPython compatibility package is no longer automatically generated or actively maintained. Please switch to the wx package as soon as possible. from wxPython.wx import * Traceback (most recent call last): File "/Users/frikk/Documents/workspace/Bili_UI/src/nokia_fkscrn.py", line 37, in import wx File "/Users/frikk/Documents/workspace/Bili_UI/src/wx.py", line 3, in from wxPython.wx import * File "//Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/wx-2.8-mac-ansi/wxPython/__init__.py", line 15, in import _wx File "//Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/wx-2.8-mac-ansi/wxPython/_wx.py", line 3, in from _core import * File "//Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/wx-2.8-mac-ansi/wxPython/_core.py", line 15, in import wx._core ImportError: No module named _core I feel like this may be a path issue? Any ideas on what else to look for? Both sys.path statements are the same, and I'm not sure what else I could be causing it - some configuration perhaps in Eclipse that is not being set correctly for newer projects? I also choose 'Python 2.5' from in eclipse - and it points to the same location for both projects.. Path: >>> import sys >>> sys.path ['', '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ site-packages/setuptools-0.6c8-py2.5.egg', '/Library/Frameworks/ Python.framework/Versions/2.5/lib/python2.5/site-packages/ Pygments-0.9- py2.5.egg', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ python25.zip', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/plat-darwin', '/Library/Frameworks/Python.framework/ Versions/ 2.5/lib/python2.5/plat-mac', '/Library/Frameworks/Python.framework/ Versions/2.5/lib/python2.5/plat-mac/lib-scriptpackages', '/Library/ Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk', '/ Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib- dynload', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages', '/Library/Frameworks/Python.framework/ Versions/2.5/lib/python2.5/site-packages/wx-2.8-mac-ansi'] Any suggestions would be great - its probably something pretty minor... Thanks! Blaine From tjreedy at udel.edu Thu Apr 10 12:13:26 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 10 Apr 2008 12:13:26 -0400 Subject: How to find documentation about methods etc. for iterators References: <47fce941$0$755$bed64819@news.gradwell.net> <47fdceb8$0$754$bed64819@news.gradwell.net> Message-ID: wrote in message news:47fdceb8$0$754$bed64819 at news.gradwell.net... | Terry Reedy wrote: | > | > wrote in message | > news:47fce941$0$755$bed64819 at news.gradwell.net... | > | I'm not sure if I have even phrased that right but anyway.... | > | | > | How does one find (in the standard Python documentation) information | > | about things like the iteritems() method and the enumerate() function. | > | > The Library Reference manual sections on builtin functions and dict | > methods. | > | > Or, help(enumerate) and help({}.iteritems) | > | .... but that doesn't address my problem really, how do I know that I | need to look for the words enumerate and/or iteritems? This is what | my original question was about. Do what Gabriel said: read chapters 2 and 3 of the Lib Manual. You will not necessarily remember everything, but you will have an idea of what functionalities exist and know to go look again. In a few months, read them again. As for the stdlib, at least scan through the table of contents so you have a general idea of what there is. The documentation of modules (as well as of builtins) is much improved from 10 years ago, when the only doc for some was the code. tjr From jgardner at jonathangardner.net Tue Apr 8 18:01:57 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Tue, 8 Apr 2008 15:01:57 -0700 (PDT) Subject: Python 3.0 new integer division References: Message-ID: On Apr 8, 2:25?pm, Grzegorz S?odkowicz wrote: > > Isn't Decimal a BCD implementation? Yep, you are right and I am wrong. http://www.python.org/dev/peps/pep-0327/#why-not-rational From msh at blisses.org Sun Apr 20 19:46:10 2008 From: msh at blisses.org (Matt Herzog) Date: Sun, 20 Apr 2008 18:46:10 -0500 Subject: replacing text inplace Message-ID: <20080420234610.GE16190@chicago.blisses.org> Hey All. I'm learning some python with the seemingly simple task of updating a firewall config file with the new IP address when my dhcpd server hands one out. Yeah, I know it's dangerous to edit such a file "in place" but this is just an exercise at this point. I would not mind using file handles except they seem to add complexity. The only apparent problem I have with my script so far is that it's adding lots of blank lines to the file when it updates the IP addresses. There is only one dotted quad that needs changing in a file full of dotted quads and the dhcp lease lasts for months usually so I have no qualms about putting the old IP address in the file, i.e. I won't need to manually update it very often. The address apears on lines that looks like this: block in from 71.146.250.258/32 to any group 150 So "71.146.250.258" needs to change to "71.146.250.223" or something similar. Is there a saner, cleaner way to do this that won't add new, blank lines? Most of the examples on the Intertubes are about multiple files and STDIN. This is just one file and it needs one string changed on two or three lines. The script runs from cron, not interactively. ########################################################################### import sys import string import os import fileinput import re oldip = "71.146.250.258" ifcfg_lines = os.popen("/sbin/ifconfig eth0").readlines() newip = string.split(ifcfg_lines[1])[1][-11:] if newip == oldip: print "nevermind" else: for line in fileinput.FileInput("/etc/ipf.conf",inplace=1): line = line.replace(oldip,newip) print line -- "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too dark to read." -- Groucho Marx From bob at passcal.nmt.edu Fri Apr 18 15:57:56 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Fri, 18 Apr 2008 13:57:56 -0600 Subject: 2's complement conversion. Is this right? Message-ID: <2008041813575616807-bob@passcalnmtedu> I'm reading 3-byte numbers from a file and they are signed (+8 to -8million). This seems to work, but I'm not sure it's right. # Convert the 3-characters into a number. Value1, Value2, Value3 = unpack(">BBB", Buffer[s:s+3]) Value = (Value1*65536)+(Value2*256)+Value3 if Value >= 0x800000: Value -= 0x1000000 print Value For example: 16682720 = -94496 Should it be Value -= 0x1000001 so that I get -94497, instead? Thanks! Bob From ivan.illarionov at gmail.com Fri Apr 18 12:30:00 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Fri, 18 Apr 2008 16:30:00 +0000 (UTC) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: On Fri, 18 Apr 2008 07:16:35 -0700, Aaron Watters wrote: > The big deal is that I would love to see Django become the standard > platform for web development, for example. That will be much less > likely if 60% of the contributed tools for Django don't work for Python > 3000 and 20% don't work for Python 2.6. Expecting volunteer contributors > to support both is not realistic. It's hard enough to support one > adequately. Even if you could hope to support both with the same code, > just testing in both environments would be onerous. You shouldn't worry about Django. Python 3000 port has already started [1]. And the assumption that "to support both is not realistic" may be wrong [2] in this case. [1] http://wiki.python.org/moin/PortingDjangoTo3k [2] http://groups.google.com/group/django-developers/msg/91f399820ee07ce5 -- Ivan From jcd at unc.edu Wed Apr 30 13:35:20 2008 From: jcd at unc.edu (J. Cliff Dyer) Date: Wed, 30 Apr 2008 13:35:20 -0400 Subject: Custom Classes? In-Reply-To: <4dc0cfea0804300902o7493dab2m35999b5b59deace4@mail.gmail.com> References: <4dc0cfea0804300902o7493dab2m35999b5b59deace4@mail.gmail.com> Message-ID: <1209576920.4990.17.camel@aalcdl07.lib.unc.edu> On Wed, 2008-04-30 at 11:02 -0500, Victor Subervi wrote: > Hi; > I have the following code which produces a file every time I need to > display an image from MySQL. What garbage! Surely, python is capable > of better than this, but the last time I asked for help on it, I got > no responses. Is this only possible with custom classes? Please, give > me some guidance here! > try: > > w += 1 > > getpic = "getpic" + str(w) + ".py" > > try: > > os.remove(getpic) > > except: > > pass > > code = """ > > #!/usr/local/bin/python > > import cgitb; cgitb.enable() > > import MySQLdb > > import cgi > > import sys,os > > sys.path.append(os.getcwd()) > > from login import login > > user, passwd, db, host = login() > > form = cgi.FieldStorage() > > picid = int(form["id"].value) > > x = int(form["x"].value) > > pics = > {1:'pic1',2:'pic1_thumb',3:'pic2',4:'pic2_thumb',5:'pic3',6:'pic3_thumb',7:'pic4',8:'pic4_thumb',\ > > 9:'pic5',10:'pic5_thumb',11:'pic6',12:'pic6_thumb'} > > pic = pics[x] > > print 'Content-Type: text/html' > > db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > > cursor= db.cursor() > > sql = "select " + pic + " from products where id='" + str(picid) + > "';" > > cursor.execute(sql) > > content = cursor.fetchall()[0][0].tostring() > > cursor.close() > > print 'Content-Type: image/jpeg' > > print > > print content > > """ > > script = open(getpic, "w") > > script.write(code) > > print '' > % pic > > print '

\n' % (getpic, d, > y) > > > TIA, > Victor Victor, Once again, you've posted code that doesn't work. Your outer try block is never terminated, and w is never initialized (so will raise an exception inside your try block, which you probably won't see, if you catch all exceptions. Generally speaking, unless you know what you're trying to catch, it's better to leave off the try/except block, *especially* during development. Stack traces are full of good information. Second, you never initialize w, which causes the following problem. $ python Python 2.3.4 (#1, Nov 20 2007, 15:18:15) [GCC 3.4.6 20060404 (Red Hat 3.4.6-9)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> w += 1 Traceback (most recent call last): File "", line 1, in ? NameError: name 'w' is not defined >>> Third, double-spacing your code makes it difficult to read. Take out blank lines, unless they add contextual hints which improve readability. Post working code, and I'll answer your actual question. Cheers, Cliff > -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill From wwzaygvm at gmail.com Wed Apr 16 16:58:45 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 13:58:45 -0700 (PDT) Subject: trading software cracks Message-ID: trading software cracks http://cracks.12w.net F R E E C R A C K S From steve at holdenweb.com Tue Apr 8 10:19:26 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 10:19:26 -0400 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. In-Reply-To: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> Message-ID: subhabrata.iisc at hotmail.com wrote: > I am using Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v. > 1310 32 bit (Intel)] on win32 with IDLE 1.2.1 > My O/S is Windows XP SP2 I use 512 MB RAM. > I am encountering the following problems: > (i) a1=1 > a2=2 > a3=a1+a2 > print a3 > # The result is coming sometimes as 3 sometimes as vague numbers. > Sorry, this just isn't true. There is no known implementation for which 1+2 does not equal 3. > (ii) x1="Bangalore is called the Silicon Valley of India" > x2="NewYork" > x3=x1.find(x2) > print x3 > # The result of x3 is coming as -1 as well as +ve numbers. > Presumably you get -1 when the substring isn't found. Look at the documentation of str.find() to discover *why* this happens. > (iii) I have been designing one crawler using "urllib". For crawling > one web page it is perfect. But when I am giving around 100 URLs by > and their links and sublinks the IDLE is not responding. Presently I > have been running with 10 URLs but can't it be ported? > Not enough information. "I have a program, please tell me waht is wrong with it" overtaxes even this group's psychic abilities. > (iv) I have designed a program with more than 500 if elif else but > sometimes it is running fine sometimes it is giving hugely erroneous > results, one view of the code: I am afraid that for code like this "designed" is far too kind a term. I would have suggested "thrown together". On what analysis of your problem was this solution based? > elif a4==3: > print "YOU HAVE NOW ENTERED THREE WORDS" > if a3[0] not in a6: > if a3[1] not in a6: > if a3[2] not in a6: > print "a3[0] not in a6, a3[1] not in a6, a3[2] not > in a6" > elif a3[2] in a6: > print "a3[0] not in a6, a3[1] not in a6, a3[2] in > a6" > else: > print "NONE3.1" > elif a3[1] in a6: > if a3[2] not in a6: > print "a3[0] not in a6, a3[1] in a6, a3[2] not in > a6" > elif a3[2] in a6: > print "a3[0] not in a6,a3[1] in a6, a3[2] in a6" > else: > print "NONE3.2" > else: > print "NONE3.3" > elif a3[0] in a6: > if a3[1] not in a6: > if a3[2] not in a6: > print "a3[0] in a6, a3[1] not in a6, a3[2] not in > a6" > elif a3[2] in a6: > print "a3[0] in a6, a3[1] not in a6, a3[2] in a6" > else: > print "NONE3.4" > elif a3[1] in a6: > if a3[2] not in a6: > print "a3[0] in a6, a3[1] in a6, a3[2] not in a6" > elif a3[2] in a6: > print "a3[0] in a6, a3[1] in a6, a3[2] in a6" > else: > print "NONE3.5" > else: > print "NONE3.6" > else: > print "NONE3.7" > Why it is behaving like that? Like what? You don't even say what results you expect, and only describe the results you *do* obtain as "hugely erroneous". I have a car. I have turned the ignition key but it fails to start. Please tell me what is wrong with it. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From sturlamolden at yahoo.no Fri Apr 25 11:02:01 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 25 Apr 2008 08:02:01 -0700 (PDT) Subject: Calling Python code from inside php References: <679e9oF2mti63U1@mid.uni-berlin.de> <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> Message-ID: On Apr 23, 9:13 pm, alexel... at gmail.com wrote: > A simple yet dangerous and rather rubbish solution (possibly more of a > hack than a real implementation) could be achieved by using a > technique described above: > > echo exec('python foo.py'); This will spawn a Python interpreter, and not be particularly efficient. You could just as well have used CGI. From bgeddy at home.havin.a.break Thu Apr 17 22:59:16 2008 From: bgeddy at home.havin.a.break (bgeddy) Date: Fri, 18 Apr 2008 03:59:16 +0100 Subject: how do I know if I'm using a debug build of python In-Reply-To: References: Message-ID: <98UNj.17390$2b2.11787@newsfe12.ams2> Tim Mitchell wrote: > Hi, > > A quick question: > Is there any way for a python script to know if it's being executed by a > debug build of python (python_d.exe) instead of python? > > Thanks > Tim > Not sure what this returns in Windows as I run Linux but this returns to namer of the python executable for my setup - maybe its what you want. import sys print sys.executable - will print out the name of the python executable. From needin4mation at gmail.com Fri Apr 25 09:16:08 2008 From: needin4mation at gmail.com (jmDesktop) Date: Fri, 25 Apr 2008 06:16:08 -0700 (PDT) Subject: Is 2006 too old for a book on Python? Message-ID: Hi, I wanted to buy a book on Python, but am concerned that some of them are too old. One I had come to after much research was Core Python by Wesley Chun. I looked at many others, but actually saw this one in the store and liked it. However, it is from 2006. I know there is free documentation and Dive Into Python. I just liked the one in question and was hoping for thoughts on the age of it. I am using Python 2.5.x and don' t know how different 2.3, 2,4 is from it. Thank you. From torriem at gmail.com Wed Apr 16 12:39:16 2008 From: torriem at gmail.com (Michael Torrie) Date: Wed, 16 Apr 2008 10:39:16 -0600 Subject: Finally had to plonk google gorups. In-Reply-To: <87prspydex.fsf@physik.rwth-aachen.de> References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> <87prspydex.fsf@physik.rwth-aachen.de> Message-ID: <48062BB4.8000201@gmail.com> Torsten Bronger wrote: > The admistrative overhead of mailing lists is tedious. Fortunately, > most important computer-related lists are on gmane.org. We could > list c.l.py there, too. ;-) Running a few lists myself, I don't see this. How is administrative overhead tedious? Most open source projects do it, so I wonder just how tedious it is. Of all the projects I'm associated with in lists, Python is the only one still clinging to NNTP when it appears a normal mail list is just as good. From deets at nospam.web.de Fri Apr 25 09:02:29 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 25 Apr 2008 15:02:29 +0200 Subject: PYTHONPATH breaks MySQLdb In-Reply-To: References: Message-ID: <67e33tF2orobvU1@mid.uni-berlin.de> Aljosa Mohorovic schrieb: > i have a working MySQLdb module (/usr/lib/python2.4/site-packages/ > MySQL_python-1.2.2-py2.4-linux-i686.egg), using it without problems. > > "clean shell" after login: > python -c "import MySQLdb" reports no errors > > if i export PYTHONPATH: > export PYTHONPATH=/var/www/projects/uv_portal/portal > > python -c "import MySQLdb" reports no errors as in previous case > > if i export PYTHONPATH: > export PYTHONPATH=/var/www/projects/uv_portal/portal/apps > > i get this: > python -c "import MySQLdb" > Traceback (most recent call last): > File "", line 1, in ? > ImportError: No module named MySQLdb > > is there any reason why this happens? Yes. You found a secret that nobody was supposed to know: Python doesn't allow portal applications te be written! So it scans the pythonpath for a suffix of "portal/apps", and refuses to import anything if it finds it. Seriously: yes, there must be a reason, but nobody can tell because we don't know & see what is beyond the apps-dir that might cause trouble. Generally speaking, given that you can properly import MySQLdb without any path set, you need to see if there is anything in your path that somehow gets imported first and e.g. alters the sys.path. Try python -vc 'import MySQLdb' and if that doesn't make things clearer, use strace. Diez From skanemupp at yahoo.se Thu Apr 10 07:41:06 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 04:41:06 -0700 (PDT) Subject: questions about Exceptions? References: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> <71cc8c25-f5f9-4f21-a9d8-06780bf97608@f63g2000hsf.googlegroups.com> <9af81b1a-3e02-4406-b9d2-0a9b6f46566b@p39g2000prm.googlegroups.com> <0e586d5d-6799-433f-b8a4-4de5d2a87b61@h1g2000prh.googlegroups.com> <46a79564-4069-46af-b6ab-b38bd9152c2a@d45g2000hsc.googlegroups.com> <1f413b6e-f964-4f8d-b781-61985f86acc2@a9g2000prl.googlegroups.com> Message-ID: <1473f09e-936f-4e35-830d-ecf999976c55@f63g2000hsf.googlegroups.com> On 10 Apr, 13:15, cokofree... at gmail.com wrote: > > the erase() id alwys need if u wanna abort whilst u wrote something. > > But if it is meant to only evaluate once you've pressed the enter key > (I take it?) you shouldn't need that. And if you are to abort while > evaluating it will not do that. CHANGED IT NOW TO A MUCH BETTER SOLUTION(will see if i can make a better solution with the buttons, hate big blocks of similarlooking code): from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") l = Label(mygui, text="Answer: ") l.place(relx=0.15, rely=0.2, anchor=CENTER) e = Entry(mygui) e.place(relx=0.4, rely=0.1, anchor=CENTER) def Disp(nstr): e.insert(END, nstr) def Calc(): expr=e.get() try: b = Label(mygui, text=eval(expr)) b.place(relx=0.4, rely=0.2, anchor=CENTER) except: b = Label(mygui, text="Not computable") b.place(relx=0.4, rely=0.2, anchor=CENTER) def Erase(): e.delete(0,END) b = Button(mygui, text="1",command=lambda n='1':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.4, anchor=CENTER) b = Button(mygui, text="2",command=lambda n='2':Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.4, anchor=CENTER) b = Button(mygui, text="3",command=lambda n='3':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.4, anchor=CENTER) b = Button(mygui, text="+",command=lambda n='+':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.4, anchor=CENTER) b = Button(mygui, text="4",command=lambda n='4':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.5, anchor=CENTER) b = Button(mygui, text="5",command=lambda n='5':Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.5, anchor=CENTER) b = Button(mygui, text="6",command=lambda n='6':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.5, anchor=CENTER) b = Button(mygui, text="-",command=lambda n='-':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.5, anchor=CENTER) b = Button(mygui, text="7",command=lambda n='7':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.6, anchor=CENTER) b = Button(mygui, text="8",command=lambda n='8':Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.6, anchor=CENTER) b = Button(mygui, text="9",command=lambda n='9':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.6, anchor=CENTER) b = Button(mygui, text="*",command=lambda n='*':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.6, anchor=CENTER) b = Button(mygui, text="0",command=lambda n='0':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.7, anchor=CENTER) b = Button(mygui, text="C",command=Erase, width=2, height=1) b.place(relx=0.2, rely=0.7, anchor=CENTER) b = Button(mygui, text="^",command=lambda n='**':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.7, anchor=CENTER) b = Button(mygui, text="/",command=lambda n='/':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.7, anchor=CENTER) b = Button(mygui, text=".",command=lambda n='.':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.8, anchor=CENTER) b = Button(mygui, text="(",command=lambda n='(':Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.8, anchor=CENTER) b = Button(mygui, text=")",command=lambda n=')':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.8, anchor=CENTER) b = Button(mygui, text="=",command=Calc, width=2, height=1) b.place(relx=0.4, rely=0.8, anchor=CENTER) mygui.mainloop() From desktop_specialist at yahoo.com Tue Apr 15 10:24:05 2008 From: desktop_specialist at yahoo.com (shawn s) Date: Tue, 15 Apr 2008 07:24:05 -0700 (PDT) Subject: program to Ping ip addresses Message-ID: <192124.99122.qm@web58602.mail.re3.yahoo.com> Hi I am trying to modify a small program i found off the internet as follows... I can get the 'tracert' to work and it gives me all the info back. However, when i replace the tracert with 'ping', the commamd prompt shows 'testing' and the script freezes... any suggestions as why it is doing that. import os import sys xyz = 1 while xyz==1: ip = raw_input("command >> ") zx = open("log.txt", "a") if ip.lower()=="exit": ask = raw_input("Are you sure you want to exit? (Y\\N) ") if ask.lower()=="y": sys.exit() elif ask.lower()=="n": print("That's what I thought.") else: print("Wrong choice. Retard.") elif ip.lower()=="range": stin = raw_input("Enter function: ") sec = raw_input("Enter the first 3 sections: ") b = raw_input("Enter beginning number: ") intb=int(b) e = int(raw_input("Enter ending number: ")) while intb<=e: print (stin + ' ' + sec + '.' + b ) z = os.system(stin + ' ' + sec + '.' + b ) print z if z==0: print(""+str(sec)+"."+str(b)+" is online.") zx.write(""+str(sec)+"."+str(b)+" is online.\n") elif z==1: print("Either "+str(sec)+"."+str(b)+" is offline, or ping request has been blocked.") zx.write("Either "+str(sec)+"."+str(b)+" is offline, or ping request has been blocked.\n") intb = intb + 1 b=str(intb) else: print("Wrong choice. Retard.") ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdw at distorted.org.uk Tue Apr 22 08:42:00 2008 From: mdw at distorted.org.uk (Mark Wooding) Date: Tue, 22 Apr 2008 12:42:00 +0000 (UTC) Subject: Working around buffering issues when writing to pipes References: Message-ID: sven _ wrote: > In short: unless specifically told not to, normal C stdio will use > full output buffering when connected to a pipe. It will use default > (typically unbuffered) output when connected to a tty/pty. Wrong. Standard output to a terminal is typically line-buffered. (Standard error is never buffered by default, per the ISO C standard.) > This is why subprocess.Popen() won't work with the following program > when stdout and stderr are pipes: Yes, obviously. > I went with pexpect and it works well, except that I must handle > stdout and stderr separately. There seems to be no way to do this with > pexpect, or am I mistaken? You could do it by changing the command you pass to pexpect.spawn so that it redirects its stderr to (say) a pipe. Doing this is messy, though -- you'd probably need to set the pipe's write-end fd in an environment variable or something. It's probably better to use os.pipe and pty.fork. As mentioned above, the inferior process's output will still be line-buffered unless it does something special to change this. -- [mdw] From sophacles at gmail.com Wed Apr 9 13:49:01 2008 From: sophacles at gmail.com (Erich) Date: Wed, 9 Apr 2008 10:49:01 -0700 (PDT) Subject: Google App Engine References: <47fc2c7c$0$36365$742ec2ed@news.sonic.net> <7e43fcd9-6207-4af2-8256-c0099a8ce0bb@1g2000prf.googlegroups.com> Message-ID: <3d4cae10-17bb-4d53-b84f-236287bd5893@m44g2000hsc.googlegroups.com> On Apr 9, 3:51 am, Duncan Booth wrote: > The backend data store, while it has a vaguely SQLish query language is an > object database not a relational database, i.e. more like ZODB than MySQL. > It uses similar concepts to django's data api but isn't the same. It should > be possible to write something simple to replace it, but given that you > only need to migrate away from Google when your data or page hits get > large, you need to replace it with something scalable. I have a bet with a coworker that someone will implement the api, in a way that makes migration away from Google easy, within a month. (actually, the bet is just that there will be a project with this goal). The reason I mention it here, is that he had the same comments as you regarding this. My thinking is that (if past experiences can be used as a yardstick) the python community will see this deficiency and work to correct it. As a result of that thinking, I am fairly certain that this concern is not a big concern. The authentication thing, thats a bit different. From mhansen at gmail.com Tue Apr 22 17:35:58 2008 From: mhansen at gmail.com (Mike Hansen) Date: Tue, 22 Apr 2008 14:35:58 -0700 (PDT) Subject: subprocess module is sorely deficient? References: Message-ID: > I think the best solution would be to port Pexpect to windows which > wouldn't be that difficult according to my reading of the code. If > only I had more free time! Sage ( http://www.sagemath.org ) uses pexpect fairly extensively to interface with all sorts of other systems. We recently received funding from Microsoft to do a native port of Sage (and all of its components to Windows. Part of this will most likely be a port of pexpect to Windows. --Mike From martin at v.loewis.de Sun Apr 6 09:53:34 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 06 Apr 2008 15:53:34 +0200 Subject: Is there any way to say ignore case with "in"? In-Reply-To: <432d690f-44be-49a9-bc6a-1cf3445549d6@m71g2000hse.googlegroups.com> References: <47f692f3$0$759$bed64819@news.gradwell.net> <432d690f-44be-49a9-bc6a-1cf3445549d6@m71g2000hse.googlegroups.com> Message-ID: <47f8d5df$0$23304$9b622d9e@news.freenet.de> >> I know I could use:- >> >> if lower(string1) in lower(string2): >> >> >> but it somehow feels there ought to be an easier (tidier?) way. >> > > Easier? You mean like some kind of mind meld? Interestingly enough, it shouldn't be (but apparently is) obvious that a.lower() in b.lower() is a way of expressing "a is a substring of b, with case-insensitive matching". Can we be sure that these are really the same concepts, and if so, is a.upper() in b.upper() also equivalent? It's probably a common assumption that, for any character c, c.lower()==c.upper().lower(). Yet, py> [i for i in range(65536) if unichr(i).upper().lower() != unichr(i).lower()] [181, 305, 383, 837, 962, 976, 977, 981, 982, 1008, 1009, 1010, 1013, 7835, 8126] Take, for example, U+017F, LATIN SMALL LETTER LONG S. It's .lower() is the same character, as the character is already in lower case. It's .upper() is U+0053, LATIN CAPITAL LETTER S. Notice that the LONG is gone - there is no upper-case version of a "long s". It's .upper().lower() is U+0073, LATIN SMALL LETTER S. So should case-insensitive matching match the small s with the small long s, as they have the same upper-case letter? Regards, Martin From http Wed Apr 2 21:15:41 2008 From: http (Paul Rubin) Date: 02 Apr 2008 18:15:41 -0700 Subject: Why prefer != over <> for Python 3.0? References: Message-ID: <7xlk3vg2ma.fsf@ruckus.brouhaha.com> "Hendrik van Rooyen" writes: > Some of the other veterans may want to add to this list. Overlays, lots and lots of them, in multiple levels intricately arranged. From torriem at gmail.com Tue Apr 15 13:19:31 2008 From: torriem at gmail.com (Michael Torrie) Date: Tue, 15 Apr 2008 11:19:31 -0600 Subject: Java or C++? In-Reply-To: <20080415165526.GA21682@hccnet.nl> References: <20080415165526.GA21682@hccnet.nl> Message-ID: <4804E3A3.5080200@gmail.com> egbert wrote: > What is the role or position of C# in this context ? > If I remember well, some people have said that C# is an improved > C++ or Java. > e I think C# is in a great position, and might be recommended. C# has the added advantage of being able to very easily work with IronPython. Thus if you want to develop with .NET you can easily wield the beauty of python with C# for speed or library routines. Of course Jython does the same for Java, although it's way behind in development these days. Slick python integration is one area where C# and Java would beat out C++. Sure there's Boost::Python, but the learning curve is kind of steep. Installation, even, is difficult. Python's C API is very simple and C-like, so if one chooses to use primarily a C/Python combination (typically what I do these days), it works well, but not quite as easy as IronPython and C#. Diving into the debate, I personally think all programmers, and especially computer science people, should be proficient in C. You should be able to write thousands of lines of C code, use dynamic memory allocation, data structures, etc, and have very few resource leaks if you choose your tools wisely (glib for C ought to be standard!). This is to give you a background and low-level understanding. However you're not likely to program in C professionally unless you are into systems programming, or are affiliated with core, low-level things like library development, or embedded systems. As for C++ and Java, I've found that good C++ programmers can *easily* move to Java when they want/need to. The reverse is *not typically true*. Java lends itself to too many bad habits that kill would-be C++ programmers, particular in regards to resource management and things like destruction after scope. I think that is a critical thing that people forget sometimes. Similarly people proficient in Unix and Linux computers, both use and development on, can much more easily move to Windows than the other way around. A good programmer should be able to pick up new languages and paradigms fairly easily, and become fluent in just a few weeks. For me it's typically one week, although learning frameworks and toolkits is more difficult (Java frameworks). A good exercise might be to pick up one new language per year and do something major with it (say 4000-10000 loc). Choose a new genre like web programming to explore. Whatever. Next time a little pet project comes up, try a new language or a new toolkit. Try some shell-scripting in scsh using scheme. From maehhheeyy at gmail.com Tue Apr 15 18:50:38 2008 From: maehhheeyy at gmail.com (maehhheeyy) Date: Tue, 15 Apr 2008 15:50:38 -0700 (PDT) Subject: i want to add a timeout... Message-ID: <6b75da78-91c7-481c-9d20-fca8b12294de@y18g2000pre.googlegroups.com> I want to add a timeout so that when I pull out my gps from my serial port, it would wait for a bit then loop and then see if it's there. I also want to add a print statement saying that there is no GPS device found. However when I run my code and unplug my serial port, my code will just hang until I plug it back in. This is my code right now: def GetGPS(): data = [] #Open com1: 9600,8,N,1 fi = serial.Serial(0, timeout = 1) print '[gps module] SERIAL PORT OPEN ON COM1:' can anyone help me please? Thanks. From exarkun at divmod.com Wed Apr 23 10:53:06 2008 From: exarkun at divmod.com (Jean-Paul Calderone) Date: Wed, 23 Apr 2008 10:53:06 -0400 Subject: Python generators (coroutines) In-Reply-To: Message-ID: <20080423145306.6859.1396709148.divmod.quotient.34066@ohm> On Wed, 23 Apr 2008 07:17:46 -0700 (PDT), rocco.rossi at gmail.com wrote: >I would really like to know more about python 2.5's new generator >characteristics that make them more powerful and analogous to >coroutines. Is it possible for instance to employ them in situations >where I would normally use a thread with a blocking I/O (or socket) >operation? If it is, could someone show me how it can be done? There >appears to be a very limited amount of documentation in this repect, >unfortunately. They're not coroutines. The difference between generators in Python 2.4 and in Python 2.5 is that in Python 2.5, `yield? can be used as part of an expression. If a generator is resumed via its `send? method, then the `yield? expression evaluates to the value passed to `send?. You still can't suspend execution through arbitrary stack frames; `yield? only suspends the generator it is in, returning control to the frame immediately above it on the stack. You can build a trampoline based on generators, but you can do that in Python 2.4 just as easily as you can do it in Python 2.5. Jean-Paul From mysakjs at gmail.com Fri Apr 25 22:38:46 2008 From: mysakjs at gmail.com (John) Date: Fri, 25 Apr 2008 19:38:46 -0700 (PDT) Subject: newbie question References: Message-ID: <91bff95c-9f54-439c-a388-1ad158682e8b@k13g2000hse.googlegroups.com> Thanks for the tip! From python at bdurham.com Thu Apr 24 15:37:03 2008 From: python at bdurham.com (python at bdurham.com) Date: Thu, 24 Apr 2008 15:37:03 -0400 Subject: Parsing text file with #include and #define directives Message-ID: <1209065823.20034.1249725425@webmail.messagingengine.com> I'm parsing a text file for a proprietary product that has the following 2 directives: #include #define Defined constants are referenced via <#name#> syntax. I'm looking for a single text stream that results from processing a file containing these directives. Even better would be an iterator(?) type object that tracked file names and line numbers as it returns individual lines. Is there a Python parsing library to handle this type of task or am I better off writing my own? The effort to write one from scratch doesn't seem too difficult (minus recursive file and constant loops), but I wanted to avoid re-inventing the wheel if this type of component already exists. Thank you, Malcolm From jim.vickroy at noaa.gov Wed Apr 2 14:17:33 2008 From: jim.vickroy at noaa.gov (j vickroy) Date: Wed, 02 Apr 2008 12:17:33 -0600 Subject: ANN: pry unit testing framework In-Reply-To: References: Message-ID: <47F3CDBD.1010600@noaa.gov> Aldo Cortesi wrote: > We are happy to announce the first release of Pry, a unit testing framework. > > Features > ======== > > * Built-in coverage analysis, profiling, and quick-and-dirty benchmarking > * Assertion-based tests - no ugly failUnless*, failIf*, etc. methods > * Tree-based test structure for better fixture management > * No implicit instantiation of test suits > * Powerful command-line interface > > > Download: http://dev.nullcube.com > > Manual: http://dev.nullcube.com/doc/pry/index.html > > It appears this package can not be used with Microsoft Windows because it uses the *fcntl* module which is not part of the Windows distribution. >>> import sys >>> sys.version '2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]' >>> >>> import libpry Traceback (most recent call last): File "", line 1, in File "C:\Python25\Lib\site-packages\libpry\__init__.py", line 1, in from test import * File "C:\Python25\Lib\site-packages\libpry\test.py", line 4, in import _tinytree, explain, coverage, utils File "C:\Python25\Lib\site-packages\libpry\coverage.py", line 3, in import utils File "C:\Python25\lib\site-packages\libpry\utils.py", line 1, in import os.path, fnmatch, struct, fcntl, termios, os ImportError: No module named fcntl Unfortunate, because I'm definitely interested in the code coverage and profiling features. -- jv From soren.skou.nielsen at gmail.com Tue Apr 29 05:07:04 2008 From: soren.skou.nielsen at gmail.com (Soren) Date: Tue, 29 Apr 2008 02:07:04 -0700 (PDT) Subject: SWIG Python undefined reference Message-ID: <23b925ce-cfa5-4a99-bad3-afcac09b645a@y21g2000hsf.googlegroups.com> Hi, I went through the SWIG tutorial for the example named "simple". I managed to get to the first step, creating example_wrap.c using swig, and doing: "gcc -fpic -c example_wrap.c -IC:\python24\include " to create example_wrap.o But when I needed to compile the library file using: "gcc -shared example_wrap.o -o examplemodule.so" I received a lot of undefined reference compiler errors like: example_wrap.o(.text+0x35a5):example_wrap.c: undefined reference to `_imp__PyErr _SetString' there are many other similar errors all prefaced with _imp__Py, so I am assuming there is a linker error with the python libraries. I have adjusted my PATH variable to include all the python directories (libs/ dlls). Does anyone here have any suggestions? FILES FROM TUTORIAL: //example.c #include double My_variable = 3.0; int fact(int n) { if (n <= 1) return 1; else return n*fact(n-1); } int my_mod(int x, int y) { return (x%y); } char *get_time() { time_t ltime; time(<ime); return ctime(<ime); } //*************************************************************** //example.i %module example %{ /* Put header files here or function declarations like below */ extern double My_variable; extern int fact(int n); extern int my_mod(int x, int y); extern char *get_time(); %} extern double My_variable; extern int fact(int n); extern int my_mod(int x, int y); extern char *get_time(); //*************************************************************** //setup.py from distutils.core import setup, Extension setup(name='example', version = '1.0', ext_modules=[ Extension('example', ['example.c', 'example.i']) ]) From metawilm at gmail.com Wed Apr 9 07:59:31 2008 From: metawilm at gmail.com (metawilm at gmail.com) Date: Wed, 9 Apr 2008 04:59:31 -0700 (PDT) Subject: Basic optimization of python. References: Message-ID: <16061d43-8baf-4117-88e9-28d65a6d4491@n1g2000prb.googlegroups.com> On Apr 7, 7:30 am, "??" wrote: > Howdy, > I wonder whether python compiler does basic optimizations to .py. > Eg: > t = self.a.b > t.c = ... > t.d = ... > .vs. > self.a.b.c = ... > self.a.b.d = ... > which one is more effective? Since each dot invokes a hash table lookup, it > may be time consuming. If the compiler can do expression folding, then no > manual folding is needed. The compiler can not simply do such folding, as just the act of looking up an attribute can have all kinds of side effects via the methods __getattr__ and __getattribute__ . So the second time you look up self.a the value can differ from the first time, or the attribute may not exist anymore! > Again, how about contant calculation? > Eg: > a = 1 + 2 > .vs. > a = 3 > which one is more effective? Does the compiler calculate the result at > compile time? How about constant spreading? This is safe, and is done: >>> import dis >>> def f(): x = 1 + 2 ... >>> dis.dis(f) 1 0 LOAD_CONST 3 (3) 3 STORE_FAST 0 (x) 6 LOAD_CONST 0 (None) 9 RETURN_VALUE >>> - Willem From deets at nospam.web.de Tue Apr 22 11:37:59 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 17:37:59 +0200 Subject: Does Python 2.5 include or not include SQLite engine? In-Reply-To: References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> <67646qF2mqc8pU1@mid.uni-berlin.de> Message-ID: <676f3bF2nfvqgU1@mid.uni-berlin.de> Paul Melis schrieb: > Hi, > > Diez B. Roggisch wrote: >> Dennis Lee Bieber schrieb: >> >>> On Mon, 21 Apr 2008 19:05:46 -0400, python at bdurham.com declaimed the >>> following in comp.lang.python: >>> >>>> I thought one of the major features of Python 2.5 was its embedded >>>> SQLite engine. >>>> >>> No, just the inclusion of the adapter became standard... The >>> packagers of Windows installers include the SQLite3 DLL as it isn't a >>> commonly available item... But many Linux versions probably include it >>> as an option during the OS install. >> >> >> AFAIK thats wrong. On my ubuntu gutsy for example, I find this: >> >> deets at absinth:~$ find /usr/lib/python2.5/ | grep -i sqlite >> /usr/lib/python2.5/lib-dynload/_sqlite3.so >> /usr/lib/python2.5/site-packages/pysqlite-2.3.2.egg-info >> /usr/lib/python2.5/site-packages/pysqlite2 >> /usr/lib/python2.5/site-packages/pysqlite2/__init__.py >> /usr/lib/python2.5/site-packages/pysqlite2/__init__.pyc >> /usr/lib/python2.5/site-packages/pysqlite2/_sqlite.so >> /usr/lib/python2.5/site-packages/pysqlite2/dbapi2.py >> /usr/lib/python2.5/site-packages/pysqlite2/dbapi2.pyc >> /usr/lib/python2.5/sqlite3 >> /usr/lib/python2.5/sqlite3/__init__.py >> >> ... >> >> >> As you can see, stock 2.5 ships with its OWN version of sqlite, and I >> additionally installed the pysqlite-wrapper for whatever reason I now >> can't remember. > > The _sqlite3.so is only a wrapper around the real sqlite library. > Compiling a fresh Python 2.5.2 install here gives: > > 15:46|paul at tabu:~/py25/lib/python2.5/lib-dynload> ldd _sqlite3.so > linux-gate.so.1 => (0x00748000) > libsqlite3.so.0 => /usr/lib/libsqlite3.so.0 (0x00111000) > libpthread.so.0 => /lib/libpthread.so.0 (0x00631000) > libc.so.6 => /lib/libc.so.6 (0x00d1b000) > /lib/ld-linux.so.2 (0x00749000) > > I.e. the _sqlite3 module links against the system-wide installed Sqlite > version. > > Furthermore, checking the Python source distribution will show that > there is no included version of the whole Sqlite library, only the > wrapper code. How your Linux distribution packages Python w.r.t. the > sqlite3 module is different per distro. Hm. Before posting, I checked this: http://svn.python.org/view/external/sqlite-source-3.5.7.x/ So I got the impression that because the source is there (I admit *not* checking the python source distribution itself though) and a library is in the python-lib, that python ships with sqlite. So - I stand corrected. Given the way some linux distros treat python wrt to e.g. distutils, I wonder if there is one out there that does *not* have sqlite built-in. Diez From victorsubervi at gmail.com Thu Apr 17 10:47:34 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 17 Apr 2008 09:47:34 -0500 Subject: Importing My Own Script In-Reply-To: <271813.40455.qm@web39202.mail.mud.yahoo.com> References: <271813.40455.qm@web39202.mail.mud.yahoo.com> Message-ID: <4dc0cfea0804170747o33778858k22cf4ec8e2a6f48a@mail.gmail.com> On Thu, Apr 17, 2008 at 8:52 AM, Ben Kaplan wrote: > If x and y are in the same directory, just do "import x". If not, add the > directory containing x to sys.path. Then, "import x" should work. > Well, now that?s what I thought! But no, it doesn?t work! Both scripts are in the same folder. Here?s the error: [Thu Apr 17 07:45:50 2008] [error] [client 190.166.0.245] PythonHandler mod_python.cgihandler: File "/var/www/vhosts/ livestocksling.com/httpdocs/bre/test.py", line 3, in ?\n import test2 [Thu Apr 17 07:45:50 2008] [error] [client 190.166.0.245] PythonHandler mod_python.cgihandler: ImportError: No module named test2 I?m running through Plesk, if that makes a difference. TIA, Victor > > ----- Original Message ---- > From: Victor Subervi > To: python-list at python.org > Sent: Thursday, April 17, 2008 9:45:10 AM > Subject: Importing My Own Script > > Hi: > How do I import my own script from a second script? That is, I have script > x and I want to import script y. How? > TIA, > Victor > > > ------------------------------ > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it > now. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From castironpi at gmail.com Sat Apr 26 15:31:50 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sat, 26 Apr 2008 12:31:50 -0700 (PDT) Subject: diffing and uniqing directories References: Message-ID: On Apr 26, 1:14?pm, "Rustom Mody" wrote: > Over years Ive collected tgz's of my directories. I would like to diff > and uniq them > > Now I guess it would be quite simple to write a script that does a > walk or find through a pair of directory trees, makes a SHA1 of each > file and then sorts out the files whose SHA1s are the same/different. > What is more difficult for me to do is to write a visual/gui tool to > help me do this. > > I would guess that someone in the python world must have already done > it [The alternative is to use some of the tools that come with version > control systems like git. But if I knew more about that option I would > not be stuck with tgzs in the first place ;-)] > > So if there is such software known please let me know. > > PS Also with the spam flood that has hit the python list I dont know > if this mail is being read at all or Ive fallen off the list! I don't want to give you advice; there is profit in diversity, so telling you what I use could negatively unify the diverse group. In another language I know, and I pause to defer to the old and wise on that, Visual Basic (known to make money), certain counterparts like Visual Basic for Applications allow construction of scripts in the owner's other suites. That is, you can write Basic snippets in Excel, Access, and so on. That's one benefit that private ownership leaves, but not everyone is sold on my country's currency/localcy. Perhaps it's in the future of version control systems. Of course, standardization of sufficiency to succeed comes from currency too: success isn't success if it isn't current, per se. Do you have any interest in contributing your mind or hands to developing a solid gui framework? Join a team. From spamgrinder.trylater at ggmail.com Wed Apr 23 21:18:10 2008 From: spamgrinder.trylater at ggmail.com (AlFire) Date: Wed, 23 Apr 2008 20:18:10 -0500 Subject: Python Success stories In-Reply-To: References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> <426812d7-c217-4bfc-81b0-47ba0638a650@k13g2000hse.googlegroups.com> Message-ID: <480FDFD2.8070906@ggmail.com> Bob Woodham wrote: > > x = x++; > > has unspecified behaviour in C. what about C++ From max at alcyone.com Fri Apr 25 18:52:09 2008 From: max at alcyone.com (Erik Max Francis) Date: Fri, 25 Apr 2008 15:52:09 -0700 Subject: Receive data from socket stream In-Reply-To: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> Message-ID: s0suk3 at gmail.com wrote: > I wanted to ask for standard ways to receive data from a socket stream > (with socket.socket.recv()). It's simple when you know the amount of > data that you're going to receive, or when you'll receive data until > the remote peer closes the connection. But I'm not sure which is the > best way to receive a message with undetermined length from a stream > in a connection that you expect to remain open. Until now, I've been > doing this little trick: > > data = client.recv(256) > new = data > while len(new) == 256: > new = client.recv(256) > data += new > > That works well in most cases. But it's obviously error-prone. What if > the client sent *exactly* two hundred and fifty six bytes? It would > keep waiting for data inside the loop. Is there really a better and > standard way, or is this as best as it gets? > > Sorry if this is a little off-topic and more related to networking, > but I'm using Python anyway. You solve this by having a protocol that the client and server both agree on, so that the client knows how much to read from the server. There are any number of ways of doing this, all of which depend on the kind of data you want to transfer and for what purpose. -- Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis In the final choice a solider's pack is not so heavy a burden as a prisoner's chains. -- Dwight D. Eisenhower, 1890-1969 From pscott at uwc.ac.za Wed Apr 16 01:48:37 2008 From: pscott at uwc.ac.za (Paul Scott) Date: Wed, 16 Apr 2008 07:48:37 +0200 Subject: Brand New! In-Reply-To: References: <7f1828bf-ebe7-4111-bc59-70d125facb0a@d26g2000prg.googlegroups.com> Message-ID: <1208324917.7339.10.camel@paul-laptop> On Wed, 2008-04-16 at 02:35 -0300, Gabriel Genellina wrote: > I'm unsure if teaching Javascript, VBScript and Python at the same time is > a good thing, I'd think one would get a language soup and mix all the > concepts, but if it works for you, go ahead. > For other resources, see the beginners section in the Python wiki: > http://wiki.python.org/moin/BeginnersGuide Well, as an example, I learnt Python to a decent level of competency in 2 days. I looked through the Dive into Python tuts, and then had a look at the Python GUI FAQ (Which didn't really help much, as I started with a GTK based GUI app). A little bit of Googling and a couple of questions to this list gave me everything that I needed to roll out a pretty decent application in 5 days. Oh, and just by the way, I am _not_ a Computer Scientist or anything, I am a botanist, which means that if I can do that, just about anyone that can read can do it. Python has been long on my list of TODO's, and now, finally, it is there. I have immensely enjoyed it so far, and will continue to tinker well into the future. --Paul -------------- next part -------------- All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm From grante at visi.com Sun Apr 6 14:55:22 2008 From: grante at visi.com (Grant Edwards) Date: Sun, 06 Apr 2008 13:55:22 -0500 Subject: A funnily inconsistent behavior of int and float References: Message-ID: On 2008-04-06, Lie wrote: > I've noticed some oddly inconsistent behavior with int and float: > > Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 >>>> int('- 345') > -345 > > works, IMO, it oughtn't. >>>> float('- 345.083') > Traceback (most recent call last): > File "", line 1, in > ValueError: invalid literal for float(): - 345.083 That's the behavior I'd expect. > The problem seems to be that float can't accept spaces between > the sign and the number while int can. Possibly caused by some > missing regex statement. Minor and harmless (most of the > time), but should be made known. -- Grant Edwards grante Yow! ... I live in a at FUR-LINE FALLOUT SHELTER visi.com From carbanancizpo at gmail.com Fri Apr 18 16:54:11 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:54:11 -0700 (PDT) Subject: scgrid cracks Message-ID: <37dcee38-bb8a-4694-baca-734cbdb663f4@q27g2000prf.googlegroups.com> scgrid cracks http://cracks.12w.net F R E E C R A C K S From larry.bates at websafe.com` Wed Apr 16 14:41:13 2008 From: larry.bates at websafe.com` (Larry Bates) Date: Wed, 16 Apr 2008 13:41:13 -0500 Subject: insert python script in current script In-Reply-To: References: Message-ID: Prashant wrote: > I was wondering is there any way to do this: > > I have written a class in python and __init__ goes like this: > > def __init__(self): > > self.name = 'jack' > self.age = 50 > > import data > > > > > now here there is data.py in the same directory and contents are like: > > self.address = 'your address' > self.status = 'single' > > The problem is 'self' is giving some error here. I need to know if > somehow I can do this. It's like inserting the script as it's part of > the file itself. > > Cheers > Can you give a use case for doing this. You would most likely be better doing: class person(object): def __init__(self, name=None, age=None): self.name=name self.age=age personInstance=person(name='jack', age='50) -Larry From andrei.avk at gmail.com Fri Apr 11 20:51:17 2008 From: andrei.avk at gmail.com (AK) Date: Fri, 11 Apr 2008 20:51:17 -0400 Subject: [ANN]: Python-by-Example updates Message-ID: <48000796$0$30160$4c368faf@roadrunner.com> Python-by-Example is a guide to LibRef, aiming to give examples for all functions, classes, modules, etc. Right now examples for functions in some of the most important modules are included. Over the last week, I've added examples for the following modules: re special characters, inspect, shutil, tempfile, traceback. I've also got many comments (thanks!) on formatting & colors and fixed them; I've also made the guide more suitable for printing, although it's not perfect still (no pagebreaks), that will be fixed later when I add more examples. Here's the location of Python-by-Example: http://pbe.lightbird.net/ thanks, -- -ak Tobu | http://tobu.lightbird.net/ | Freeform DB / Tagger / PIM Python-by-Example | http://pbe.lightbird.net/ | Guide to LibRef From deets at nospam.web.de Tue Apr 1 19:26:52 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 02 Apr 2008 01:26:52 +0200 Subject: Summary of threading for experienced non-Python programmers? In-Reply-To: <8763v4otts.fsf@mulj.homelinux.net> References: <87od8yolay.fsf@mulj.homelinux.net> <654ng1F2cvh8aU1@mid.uni-berlin.de> <87d4pe9caz.fsf@mulj.homelinux.net> <656vhnF2e9ao7U1@mid.uni-berlin.de> <8763v4otts.fsf@mulj.homelinux.net> Message-ID: <65fulvF2eiaalU1@mid.uni-berlin.de> > I believe you stil misunderstand. The select module doesn't provide > an inteface to aio(3). It provides an interface to select() and > poll() system calls, which don't provide asynchronous access to > regular files. I never claimed it provided access to aio. In the thread with Paul Rubin, it was clarified that there is the distinction made between blocking and non-blocknig async calls. Which you didn't mention. Don't get me wrong: I appreciate the mentioning of aio (didn't know about it beforehand) and don't dispute it's superiority. But that doesn't change that one is not forced to use threading in python (which can become very expensive) to deal with mulitple I/O streams asynchronously. >> So if I were in nitpicking-mood, your assertion still would be false > > I invite constructive nitpicking, but you are completely missing the > point. You are confusing aio(3) with select and poll. I didn't confuse anything. You didn't _mention_ aio, and I didn't even know it... >> I'm pretty sure though that tiwsted & asynchore don't poll, but >> instead use the select-module. Which at least for unix (and AFAIK >> for Windows as well) is asynchronous - you get notified if data >> arrives or has been transmitted, and otherwise your process sleeps. > > Unfortunately, this is not the case for files at all, even on Unix. > (On Windows, select doesn't work on files at all, it only accepts > sockets.) AFAIK select is used in cases where e.g. several processes are piped together to prevent blocking. Your usecase with a deliberately distorted file-server is sure relevant for certain usecases - but I don't think it qualifies as "not at all, even on Unix". To reiterate what my post was actually after: I understood it as if you didn't acknowledge the asynchronous capabilities of python which are used by widely known & successfully adopted built-in modules or 3rd-party-extensions - without resorting to C, and without forcing threads upon the users. It did *not* say that it supports every existing, more powerful and generally better asynchronous mechanism supported by any OS out there. Even though it would certainly be nice if it did :) Diez From hniksic at xemacs.org Fri Apr 25 17:16:36 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Fri, 25 Apr 2008 23:16:36 +0200 Subject: Setting an attribute without calling __setattr__() References: <87bq3xej01.fsf@mulj.homelinux.net> Message-ID: <87tzhpd497.fsf@mulj.homelinux.net> Hrvoje Niksic writes: > Joshua Kugler writes: > >> self.me = [] >> self.me = {} > > Use "object.__setattr__(self, 'me') = []" and likewise for {}. Oops, that should of course be "object.__setattr__(self, 'me', [])". From sarah.fortune at gmail.com Wed Apr 2 09:52:59 2008 From: sarah.fortune at gmail.com (sjf) Date: Wed, 2 Apr 2008 06:52:59 -0700 (PDT) Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: <7f21b6b2-81be-4c8a-bcc3-980fdae5073f@s37g2000prg.googlegroups.com> Indeed, the first thing I saw on the front page was "math.sqrt(9) - 3.0". Ok, I thought, random arithmetic expression, so what? There is already a standard way of showing a piece of code and its results. It's the interactive prompt: >>> import math >>> math.sqrt(9) 3.0 >>> Tada! On Apr 2, 12:43 pm, GHUM wrote: > Tobu, > > I like this idea. Deducting from an example is really another way to > wisdom. > > What struck me as most diffuclt to understand: > > abs(-5.5) - 5.5 > > -> you are using "-" as symbol for "will give the result", which is > really, really hard to parse. Take something else, please. Unicode has > THAT many cool symbols. Or just -> or -=> or whatever. > > Thanks for sharing that work! > > Harald From blog630 at watchesblog.cn Wed Apr 23 13:20:39 2008 From: blog630 at watchesblog.cn (blog630 at watchesblog.cn) Date: Wed, 23 Apr 2008 10:20:39 -0700 (PDT) Subject: China Wireless Mics - Wholesale Wireless Mics Manufacturer Message-ID: China Wireless Mics - Wholesale Wireless Mics Manufacturer Wireless Microphone WebSite Link: http://www.chinese-microphone.com/Wireless-Microphones.html China GuangZhou TianTuo Microphone Manufacturing Co., Ltd WebSite: http://www.chinese-microphone.com/ Microphone Products are: Wireless Microphones, Conference Microphones, Headset Microphones, and Lapel Microphones, interview microphones, wired microphones, musical instrument microphones, drum microphones, teaching microphones, recording microphones, computer's USB microphones and microphone accessories and So on. Headset Microphone Wireless Systems from zZounds.com FAQ | Sitemap | Contact Us Add Something to Your Cart. Toll Free 866.ZZOUNDS (996.8637) Open until 10PM EST Mention priority code 4RV2WX when you call Home | Guitar | Bass | Keyboard | Recording | Computer Music | Live Sound | Drums | DJ | Accessories | Blowouts SEARCH Behringer Peavey Yamaha Roland Epiphone Gibson Fender Korg Ibanez Alesis Shure Boss Mackie Zoom Akai Marshall M-Audio Vestax SKB Silvertone AKG CBI Martin Nady Fos http://www.chinese-microphone.com/Wireless-Microphones.html tex Browse All Brands Top Live Sound/PA Wireless Systems Wireless Microphone Systems Headset Microphone Wireless Systems "Over the years I have purchased several thousand dollars of murchandise from zZounds and have never had a problem." - customer on February 9, 2008 Restrict by Brand:Select a brandAKG---AKG WirelessAudio Technica---Audio Technica WirelessBehringer---Other BehringerElectro-Voice---Electro- Voice MicrophonesGeminiNady---Nady WirelessSamson---Samson Wireless MicrophonesSennheiser---Sennheiser WirelessShure---Shure Wireless MicrophonesX2 Digital Sort By:Most PopularName A to ZName Z to APrice High to LowPrice Low to High Filter By Price Range: To Availability: In Stock Items Only Filter Results 1 2 Next -> Samson Airline 77 UHF TD Wireless with Qe Fitness Headset New $329.00 List: $469.99SAVE: 29% In stock 29 people rate: 6 out of 10 Samson Airline 77 UHF Wireless systems are an unbeatable combination. Samson Concert 77 UHF True Diversity Half-Rack Receivers matched up with Samson's incredible Airline Series mini transmitters give you 'belt-pack-free' mobility at new low prices. Ultra-light, ultra-compact, and incredibly efficient, Airline Series transmitters provide flawless wireless performance for 12 hours on a single AAA battery. Learn More... Sennheiser ew152G2 Evolution G2 100 Series UHF Headset Wireless New $549.00 List: $894.99SAVE: 38% 4 payments of $137.25 In stock 46 people rate: 7 out of 10 Simply the best, most affordable way to get professional caliber UHF wireless! Sennheiser's original evolution series introduced startling new technology and innovative design. Now, they're again pushing the limits of performance, audio quality, ruggedness and ease of use. Learn More... Samson Airline 77 UHF TD Wireless with Qv Vocal Headset New $329.00 List: $469.99SAVE: 29% In stock 21 people rate: 7 out of 10 Samson Airline 77 UHF Wireless systems are an unbeatable combination. Samson Concert 77 UHF True Diversity Half-Rack Receivers matched up with Samson's incredible Airline Series mini transmitters give you 'belt-pack-free' mobility at new low prices. Ultra-light, ultra-compact, and incredibly efficient, Airline Series transmitters provide flawless wireless performance for 12 hours on a single AAA battery. Learn More... Shure PGX14/PG30 UHF Wireless Headset System New $429.00 List: $602.00SAVE: 28% Blowouts save up to $39! Call for 4 payments! In stock 1 person rates: 10 out of 10 The PG30 headset microphone in this Shure PGX wireless system offers pro-quality at an affordable price. Created for active musicians and presenters who also manage their own sound. Shure PGX Wireless improves your performance and simplifies your setup. Innovations such as automatic frequency selection and automatic transmitter setup make wireless quicker and completely worry-free. PGX systems now feature Shur http://www.chinese-microphone.com/Wireless-Microphones.html e's patented Audio Reference Companding, delivering the crystal clear sound quality that pro audio engineers trust. It's the best-sounding, simplest choice in wireless, from the leader in live performance sound. Learn More... Audio Technica ATW3192ACTH Headset Wireless System New $639.95 List: $1,099.00SAVE: 41% 4 payments of $159.98 In stock The ATW3192ACTH Headset System includes a ATWR3100 receiver and ATWT310 UniPak transmitter with AT892CWTH (beige) omnidirectional condenser headworn microphone. System also includes element covers, windscreens and a clothing clip. Learn More... Audio Technica ATW2192 Headset Wireless System New $549.95 List: $799.00SAVE: 31% 4 payments of $137.48 In stock The 2000 Series is a 10-channel frequency-agile UHF wireless system designed to suit a variety of applications, including MI/live performance, fixed installation, public address, A/V rental houses, and places of worship. It offers true diversity operation, easy setup, automatic frequency scanning with interference- free performance, and all the advantages of a high-quality, professional wireless system at an extremely affordable price. Learn More... Audio Technica ATW701H UHF Headworn Wireless System New $289.95 List: $459.00SAVE: 36% In stock 7 people rate: 7 out of 10 A- T's 700 Series Freeway wireless systems feature eight selectable frequency-coordinated channels, diversity operation, automatic frequency scanning, Tone Lock squelch and more. Diversity, frequency agility, UHF. Learn More... Audio Technica ATW701H92TH Headset Wireless System New $319.95 List: $524.95SAVE: 39% In stock Audio- Technica???s 700 Series Freeway wireless delivers professional features and sound quality unheard of in its class. These easy-to-use wireless systems feature eight selectable frequency-coordinated channels, diversity operation for increased range/reliability, automatic frequency scanning, Tone Lock squelch and more. Learn More... Samson Concert 77 UHF TD Wireless with QV Headset Transmitter New $279.00 List: $389.99SAVE: 28% In stock 9 people rate: 5 out of 10 Samson Technologies was founded 20 years ago when they introduced some of the first affordable wireless technology ever. The latest line of wireless gear in that tradition: Concert 77. UHF quality diversity wireless that anyone can afford. Learn More... Audio Technica ATW3192A Headset Wireless System New $639.95 List: $1,099.00SAVE: 41% 4 payments of $159.98 In stock The ATW3192AC Headset System includes a ATWR3100 receiver and ATWT310 UniPak transmitter with AT892CW omnidirectional condenser headworn microphone. Likewise it includes element covers, windscreens and a clothing clip. Learn More... Shure PG14/PG30 Wireless Headset System New $299.95 List: $45 0.00SAVE: 33% In stock 25 people rate: 7 out of 10 A comprehensive first step into professional wireless, Performance Gear Wireless Systems are engineered to the same uncompromising quality standards as PGX, SLX, ULX and UHF-R wireless. Marrying superior sound quality and stage-proven endurance with advanced features like Internal Antenna Diversity and frequency selectability, Performance Gear Wireless fulfils the promise of independent, confident performance in freedom from the wire. Learn More... Nady UHF3 Headset Diversity Wireless System New $134.95 List: $169.95SAVE: 20% In stock 56 people rate: 8 out of 10 The latest breakthrough in affordable UHF wireless - with state-of-the-art features for the demanding professional on a limited budget. Operates on single frequencies in the wide-open, uncluttered UHF 470 MHz - 510 MHz band. Learn More... Audio Technica ATW2192TH Headset Wireless System New $549.95 List: $799.00SAVE: 31% 4 payments of $137.48 In stock The 2000 Series is a 10-channel frequency-agile UHF wireless system designed to suit a variety of applicat http://www.chinese-microphone.com/Wireless-Microphones.html ions, including MI/live performance, fixed installation, public address, A/V rental houses, and places of worship. It offers true diversity operation, easy setup, automatic frequency scanning with interference- free performance, and all the advantages of a high-quality, professional wireless system at an extremely affordable price. Learn More... Audio Technica ATW251H Headset Wireless System New $144.95 List: $249.95SAVE: 42% In stock 1 person rates: 6 out of 10 Audio- Technica's Freeway 200 Series Wireless Systems are designed to provide reliable performance, easy setup and clear, natural sound quality. Each 200 Series professional VHF wireless system includes a receiver and either a body-pack transmitter or a handheld microphone/ transmitter on a specific crystal-controlled frequency. A novel dipole antenna system on the receiver improves operation by providing a ground element in addition to the usual signal element. Learn More... Shure PG1288/PG30 Wireless Handheld and Headset System New $549.95 List: $850.00SAVE: 35% 4 payments of $137.48 In stock 3 people rate: 7 out of 10 A comprehensive first step into professional wireless, Performance Gear Wireless Systems are engineered to the same uncompromising quality standards as PGX, SLX, ULX and UHF-R wireless. Marrying superior sound quality and stage-proven endurance with advanced features like Internal Antenna Diversity and frequency selectability, Performance Gear Wireless fulfils the promise of independent, confident performance in freedom from the wire. Learn More... Shure ULXS1430 UHF Wireless Headset System New $729.00 List: $1,101.02SAVE: 33% 4 payments of $182.25 In stock 17 people rate: 7 out of 10 ULX Standard UHF systems represent a breakthrough in performance and price for both working musicians and professional sound installers. Multiple system configurations provide limitless options, each with a choice of legendary Shure microphone transmitters. Over 1400 selectable, pre-programmed frequencies are available, and Automatic Frequency Selection provides a straight shot to a clear channel. Learn More... Samson Stage 5 Vocal Headset Wireless System New $99.00 List : $159.99SAVE: 38% In stock 24 people rate: 7 out of 10 Incredible reception, crystal clear sound in a VHF system priced to bring the freedom of wireless to everyone. The Stage 5 system offers transmitters for every application including handheld, headset and lavalier microphone styles. Great for guitars too, just plug in with a Samson GC5 guitar cable. Learn More... Behringer UL2000B UHF Wireless Headset System New $229.99 List: $289.99SAVE: 20% In stock BEHRINGER go http://www.chinese-microphone.com/Wireless-Microphones.html es wireless at a performance level and price that's unheard of! With the revolutionary ULTRALINK UL2000B true diversity headset system, you will experience one of the best performing and innovative designs available in this segment. Learn More... AKG WMS40 Pro Sports Set Single Wireless System with C444L Headset New $199.00 List: $319.00SAVE: 37% Blowouts save up to $19! Only 1 left! 8 people rate: 6 out of 10 Highly versatile: the WMS 40 PRO instrumental set. The convenient PT 40 PRO bodypack is the smallest and lightest transmitter in its class. The new C 444 L head-worn microphone from AKG is rugged, extremely easy to use, and offers outstanding price/performance. Learn More... ElectroVoice RE2 UHF Wireless Headset System with RE97 New $699.95 List: $1,020.00SAVE: 31% 4 payments of $174.98 Only 2 left! 2 people rate: 10 out of 10 The RE-2 Wireless product is available in eleven different system configurations packed in a hard plastic carrying case. The systems include transmitters and micriphones as indicated. Whether you're performing at the local rock club, lecturing at a corporate seminar, or speaking in a house of worship, the Electro- Voice RE-2 brings ease-of-use, clear sound, and clean channels to wireless. Learn More... 1 2 Next -> Related Brands X2 DigitalAudio TechnicaAudio Technica WirelessNadyNady WirelessBehringerOther Behringer GeminiSennheiserSennheiser WirelessAKGAKG Wireless Electro- VoiceElectro-Voice MicrophonesSamsonSamson Wireless MicrophonesShureShure Wireless Microphones Free Catalog First Name Last Name Address 1 Address 2 City State Zip Email Would you like to receive periodic email notices of new items, special buys, and promotions? WE WILL NOT SHARE YOUR EMAIL ADDRESS WITH ANYONE ELSE. You can unsubscribe at any time. yesno submit Tell us Is there something you want to tell us? How can we serve you better? Want to see different products? Is this shirt ugly? Let us know! Email Address submit Questions? Our musicians can help you right now! Call Toll Free: 866.ZZOUNDS (996.8637) Open until 10PM EST Mention priority code 4RV2WX when you call Toll Free En Español: 800.460.7976 9AM to 5PM EST SEARCH Add Something to Your Cart FAQ | Contact Us | Sitemap | Affiliate Program Shop with those who respect your privacy— we do. Copyright © 1996-2008, zZounds Music, LLC. Terms of use apply. Wholesale Wireless Microphone From andreas.eisele at gmail.com Sat Apr 12 12:11:08 2008 From: andreas.eisele at gmail.com (andreas.eisele at gmail.com) Date: Sat, 12 Apr 2008 09:11:08 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> Message-ID: <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> I should have been more specific about possible fixes. > > python2.5 -m timeit 'gc.disable();l=[(i,) for i in range(2000000)]' > > 10 loops, best of 3: 662 msec per loop > > > python2.5 -m timeit 'gc.enable();l=[(i,) for i in range(2000000)]' > > 10 loops, best of 3: 15.2 sec per loop > > In the latter case, the garbage collector apparently consumes about > 97% of the overall time. > In a related thread on http://bugs.python.org/issue2607 Amaury Forgeot d'Arc suggested a setting of the GC thresholds that actually solves the problem for me: > Disabling the gc may not be a good idea in a real application; I suggest > you to play with the gc.set_threshold function and set larger values, at > least while building the dictionary. (700, 1000, 10) seems to yield good > results. > python2.5 -m timeit 'gc.set_threshold(700,1000,10);l=[(i,) for i in range(2000000)]' 10 loops, best of 3: 658 msec per loop which made me suggest to use these as defaults, but then Martin v. L?wis wrote that > No, the defaults are correct for typical applications. At that point I felt lost and as the general wish in that thread was to move discussion to comp.lang.python, I brought it up here, in a modified and simplified form. > I would suggest to configure the default behaviour of the garbage > collector in such a way that this squared complexity is avoided > without requiring specific knowledge and intervention by the user. Not > being an expert in these details I would like to ask the gurus how > this could be done. > I hope this should be at least technically possible, whether it is > really desirable or important for a default installation of Python > could then be discussed once the disadvantages of such a setting would > be apparent. I still don't see what is so good about defaults that lead to O(N*N) computation for a O(N) problem, and I like Amaury's suggestion a lot, so I would like to see comments on its disadvantages. Please don't tell me that O(N*N) is good enough. For N>1E7 it isn't. About some other remarks made here: > I think the linguists of the world should write better automated > translation systems. Not being an expert in these details I would like > to ask the gurus how it could be done. I fully agree, and that is why I (as someone involved with MT) would prefer to focus on MT and not on memory allocation issues, and by the way, this is why I normally prefer to work in Python, as it normally lets me focus on the problem instead of the tool. > There are going to be pathological cases in any memory allocation > scheme. The fact that you have apparently located one calls for you to > change your approach, not for the finely-tuned well-conceived garbage > collection scheme to be abandoned for your convenience. I do not agree at all. Having to deal with N>1E7 objects is IMHO not pathological, it is just daily practice in data-oriented work (we're talking about deriving models from Gigawords, not about toy systems). > If you had made a definite proposal that could have been evaluated you > request would perhaps have seemed a little more approachable. I feel it is ok to describe a generic problem without having found the answer yet. (If you disagree: Where are your definite proposals wrt. MT ? ;-) But I admit, I should have brought up Amaury's definite proposal right away. > A question often asked ... of people who are creating > very large data structures in Python is "Why are you doing that?" > That is, you should consider whether some kind of database solution > would be better. You mention lots of dicts--it sounds like some > balanced B-trees with disk loading on demand could be a good choice. I do it because I have to count frequencies of pairs of things that appear in real data. Extremely simple stuff, only interesting because of the size of the data set. After Amaury's hint to switch GC temporarily off I can count 100M pairs tokens (18M pair types) in about 15 minutes, which is very cool, and I can do it in only a few lines of code, which is even cooler. Any approach that would touch the disk would be too slow for me, and bringing in complicated datastructures by myself would distract me too much from what I need to do. That's exactly why I use Python; it has lots of highly fine-tuned complicated stuff behind the scenes, that is just doing the right thing, so I should not have to (and I could not) re-invent this myself. Thanks for the helpful comments, Andreas From p at ulmcnett.com Wed Apr 23 23:49:04 2008 From: p at ulmcnett.com (Paul McNett) Date: Wed, 23 Apr 2008 20:49:04 -0700 Subject: function that accepts any amount of arguments? In-Reply-To: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> Message-ID: <48100330.8050502@ulmcnett.com> globalrev wrote: > if i want a function that can take any amount of arguments how do i > do? Put an asterisk before the argument name. > lets say i want a function average that accepts any number of integers > and returns the average. def avg(*args): return sum(args) / len(args) There are some dangers (at least two glaring ones) with this code, though, which I leave as an exercise for the reader. :) Paul From hat at se-162.se.wtb.tue.nl Wed Apr 16 09:20:01 2008 From: hat at se-162.se.wtb.tue.nl (A.T.Hofkamp) Date: Wed, 16 Apr 2008 15:20:01 +0200 Subject: is file open in system ? - other than lsof References: Message-ID: On 2008-04-16, bvidinli wrote: > is there a way to find out if file open in system ? - > please write if you know a way other than lsof. because lsof if slow for me. > i need a faster way. > i deal with thousands of files... so, i need a faster / python way for this. > thanks. This is not a Python question but an OS question. (Python is not going to deliver what the OS doesn't provide). Please first find an alternative way at OS level (ie ask this question at an appropiate OS news group). Once you have found that, you can think about Python support for that alternative. Sincerely, Albert From aaron.watters at gmail.com Tue Apr 29 10:07:54 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Tue, 29 Apr 2008 07:07:54 -0700 (PDT) Subject: simple chemistry in python References: <5e3717e5-1913-4bda-94b3-ae165e5fb8ba@m73g2000hsh.googlegroups.com> Message-ID: On Apr 29, 8:41 am, baoilleach wrote: > ....This file is part of the Blue Obelisk Data Repository, an effort by > several chemistry software developers to share common information.... This ref is incredibly cool. Is there a guide or meta-index for similar open scientific data repositories (not web search forms: downloadable complete data)? -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=valence From ellingt8877 at gmail.com Mon Apr 28 01:45:48 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:45:48 -0700 (PDT) Subject: mystery the lottery ticket crack Message-ID: <0870366c-8332-46ea-886f-36453249a1d0@m3g2000hsc.googlegroups.com> mystery the lottery ticket crack http://crack.cracksofts.com From sevenjp at gmail.com Wed Apr 2 12:06:58 2008 From: sevenjp at gmail.com (=?ISO-8859-1?Q?Jo=E3o_Neves?=) Date: Wed, 2 Apr 2008 09:06:58 -0700 (PDT) Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> Message-ID: On Apr 2, 4:35 pm, castiro... at gmail.com wrote: > Are Python bytes codes Python byte codes? I'm not quite sure I understood your question, sorry. > Do you foresee any machine-dependent optimizations? In my personal case, I am not looking for optimizations in the generated bytecode. Let me give a very basic example. Say we have these two functions: def inc(x): x = x + 1 def dec(x): x = x - 1 Examining the compiled bytecodes for these two functions: >>> inc.func_code.co_code '|\x00\x00d\x01\x00\x17}\x00\x00d\x00\x00S' >>> dec.func_code.co_code '|\x00\x00d\x01\x00\x18}\x00\x00d\x00\x00S' Now suppose that I wanted to mess with inc, and have it behave like dec. For that, I would like to do something like this, for instance: >>> inc.func_code.co_code = '|\x00\x00d\x01\x00\x18}\x00\x00d\x00\x00S' Of course, as of this moment, I get a TypeError exception, because co_code is read-only. The thing I've been wondering is why _is_ it read-only? In what circumstances having write access to co_code would break the language or do some other nasty stuff? Jo?o Neves From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Thu Apr 10 14:21:43 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Thu, 10 Apr 2008 20:21:43 +0200 Subject: How is GUI programming in Python? References: Message-ID: <66745nF2j0p2vU1@mid.individual.net> Chris Stewart wrote: > I've always had an interest in Python and would like to dabble in > it further. I've worked on a few very small command line programs > but nothing of any complexity. I'd like to build a really simple > GUI app that will work across Mac, Windows, and Linux. How > painful is that going to be? I've built and am maintaining a not-so-simple-anymore cross platform GUI application using wxPython (running in GNU/Linux (GTK+) and Windows (XP/Vista)). It integrates well since wxPython uses native widgets. The only problems I face are minor looks problems with some widgets, e. g. tooltips with line breaks or list controls with custom font. Custom widgets work very well. Windows fonts BTW are a real pain since they have almost no unicode characters, compared to today's GNU/Linux distributions. Regards, Bj?rn -- BOFH excuse #383: Your processor has taken a ride to Heaven's Gate on the UFO behind Hale-Bopp's comet. From mail.ilocke at gmail.com Tue Apr 29 18:29:12 2008 From: mail.ilocke at gmail.com (ivan) Date: Tue, 29 Apr 2008 15:29:12 -0700 (PDT) Subject: Simple import question about mac osx References: Message-ID: <11d9cb49-7fbe-4c47-b2a8-a5f004217c9a@x35g2000hsb.googlegroups.com> On Apr 29, 3:47?pm, "Jerry Hill" wrote: > When you run your code in pythonwin, it's just like calling 'python -i > chap2.py' ?It runs the code in chap2.py, then gives you an interpreter > window to interact with your code. ?In this case, that means that > FooClass is visible with no import at all, because it was defined in > the scope of the currently running script, as opposed to being > imported. > > You haven't said exactly how you're doing this on your mac, but I'm > guessing that you're opening a command line, starting up the python > interpreter, then going from there? > > Can someone help me out? ?I'm running into a mental block on how to > explain the difference between doing this: > C:\Python25>python -i chap2.py>>> foo1=FooClass() jmDesktop, With what Jerry stated, You can see what is happening under PythonWin interactive window by doing: >>> dir() before and after running chap2.py and see that FooClass is defined without import, which gives a clue that PythonWin is not running the script independant of the interactive window. Or try adding the following to the end of your chap2.py: print "Hello World" somevar = 12345 And run in PythonWin and see what happens to your interactive window and if somevar is defined. If you close and open PythonWin and use the interactive window without having first run chap2.py, you will find it behaves the same as the mac. Ivan From duncan.booth at invalid.invalid Wed Apr 2 09:12:35 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 2 Apr 2008 13:12:35 GMT Subject: Nested try...except References: Message-ID: Magnus.Moraberg at gmail.com wrote: > Hi, > > I found the following code on the net - > > http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/% > 3C20050924104732.5116.qmail at minotaur.apache.org%3E > > def count(self): > - db = sqlite.connect(self.filename, > isolation_level=ISOLATION_LEVEL) > - try: > - try: > - cur = db.cursor() > - cur.execute("select count(*) from sessions") > - return cur.fetchone()[0] > - finally: > - cur.close() > - finally: > - db.close() > > I don't understand though why the second try is not after the line cur >= db.cursor(). Can anyone explain for me why? > Simple: because not all code found on the net is correct. From jcd at unc.edu Tue Apr 1 16:25:05 2008 From: jcd at unc.edu (J. Cliff Dyer) Date: Tue, 01 Apr 2008 16:25:05 -0400 Subject: manipulating hex values In-Reply-To: <47F28855.50908@u4eatech.com> References: <47F26CC3.3060307@u4eatech.com> <47F28855.50908@u4eatech.com> Message-ID: <1207081505.3833.12.camel@aalcdl07.lib.unc.edu> On Tue, 2008-04-01 at 12:09 -0700, Stephen Cattaneo wrote: > > The source of my confusion is that I need to keep my bytes formated > correctly. I am using the below 'raw socket example' proof-of-concept > code as my example. (And yes, I have tried the proof-of-concept. It > works correctly. It is not my code.) > dstAddr = "\x01\x02\x03\x04\x05\x06" > dstAddr1 = "0x010203040506" > dstAddr != dstAddr1 > > Follow up question: What is the best to store my bytes up until sending > the packets? Perhaps I should use lists of decimal numbers and then > before sending convert to hex. > I.E. dstAddr = [ 1, 2, 3, 4, 5, 6] > dstAddr.prepareToSend() > txFrame = struct.pack("!6s6sh",dstAddr,srcAddr,proto) + ethData > > Is there a better way to do this? > > Thanks, > > Steve Those are not lists of decimal numbers. Those are lists of binary numbers which are represented as decimal in the default conversion to strings. py>>> assert [10, 11, 12] == [0xa, 0xb, 0xc] py>>> Don't worry about the formatting until you output them to strings. The numbers are in there, and have the proper value, regardless of how you input them. When you need to output them, you can use standard string formatting to get the format you desire: py>>> a=30 py>>> "%i is decimal" % a '30 is decimal' py>>> "%x is hexadecimal" % a '1e is hexadecimal' py>>> "0x%x is hex prepended with 0x" % a '0x1e is hex prepended with 0x' >>> "0%o is octal prepended with 0" % a '036 is octal prepended with 0' You are making your life more complicated than you need to. Cheers, Cliff From brian.e.munroe at gmail.com Thu Apr 3 00:36:42 2008 From: brian.e.munroe at gmail.com (Brian Munroe) Date: Wed, 2 Apr 2008 21:36:42 -0700 (PDT) Subject: class / module introspection? References: <3c3f09df-08cb-4309-a870-6b12a813a8af@u36g2000prf.googlegroups.com> <0f14a289-55ef-49e5-b650-60f7aca371ad@i36g2000prf.googlegroups.com> <033570bc-c5f3-4575-8dae-51780e68d2d7@m3g2000hsc.googlegroups.com> Message-ID: On Apr 2, 2:26 pm, 7stud wrote: > > You don't need that helper function, which is a little tricky to > follow: > Well, I appreciate the code sharing you did, but the helper function is nice and compact, and I didn't have much trouble following it. I ended up doing the following in the backends/__init__.py: import os availableBackendsList = [] for module in os.listdir(__path__[0]): if not module.startswith("__") and not module.startswith("."): availableBackendsList.append("backends." + module) def subpackage_import(name): mod = __import__(name) components = name.split('.') for comp in components[1:]: mod = getattr(mod, comp) return mod def get_available_backends(): return map(subpackage_import, availableBackendsList) In then in my application code, it becomes a simple matter of: import backends for x in backends.get_available_backends(): print x.PLUGIN_NAME be = x.Backend() print be.getStatus() Basically, I borrowed a page out of Dive into Python[1] and mapped each module object (system1, system2, ... systemN) to a list. [1] - Thanks Mark! - http://www.diveintopython.org/functional_programming/all_together.html From gagsl-py2 at yahoo.com.ar Tue Apr 8 00:44:38 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 08 Apr 2008 01:44:38 -0300 Subject: read large zip file References: <47fadf75$0$36387$742ec2ed@news.sonic.net> Message-ID: En Tue, 08 Apr 2008 00:10:01 -0300, John Nagle escribi?: > Gabriel Genellina wrote: >> En Sun, 06 Apr 2008 19:20:31 -0300, Brian Blais >> escribi?: >> >>> I need to read a series of large zipfiles (which only contain one >>> large text file), and I noticed that the zipfile module: >> >> Use the module from the 2.6 version; it appears to work fine even on >> Python 2.4 (see this thread > > It's easier than that: > > fd = gzip.open(filename, 'rb') > for line in fd : > processline(line) > > This works even in Python 2.4. I use this routinely for processing big > log files. That works for gzipped files, but the OP said "zipfiles" which aren't the same thing. It might be a generic term too - we'll have to wait until he gives any feedback... -- Gabriel Genellina From john106henry at hotmail.com Tue Apr 29 01:40:11 2008 From: john106henry at hotmail.com (John Henry) Date: Mon, 28 Apr 2008 22:40:11 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <473deef3-9acb-45dd-a7ca-47b0081bd28c@i36g2000prf.googlegroups.com> Message-ID: <3f7bb91e-335e-46bd-88ca-f15b26c35132@k1g2000prb.googlegroups.com> On Apr 28, 12:41 pm, John Henry wrote: > On Apr 27, 12:23 pm, Fred Pacquier wrote: > > > > > Do keep us posted ! > > > TIA, > > fp > > Check it out now. > > Only one to be added is the Multicolumn List (table), and then menus. > The other widgets (Togglebutton, BitmapCanvas, Gauge, Notebook, > CodeEditor) will not be implemented initially. > > http://test.powersystemadvisors.com table and menus all work From steve at holdenweb.com Sat Apr 12 20:58:35 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 20:58:35 -0400 Subject: Tremendous slowdown due to garbage collection In-Reply-To: <7x8wzi7f9x.fsf@ruckus.brouhaha.com> References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> <32e2acc1-97cb-4911-bb0c-67965b5ff113@2g2000hsn.googlegroups.com> <7x8wzi7f9x.fsf@ruckus.brouhaha.com> Message-ID: Paul Rubin wrote: > Steve Holden writes: >> I believe you are making surmises outside your range of competence >> there. While your faith in the developers is touching, the garbage >> collection scheme is something that has received a lot of attention >> with respect to performance under typical workloads over the years. > > Really, Python's cyclic gc is quite crude and should be upgraded to > something that doesn't fall into that quadratic behavior. There was > some fairly detailed discussion of this in another thread last time > the subject came up. I'll take your word for it. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From lists at cheimes.de Tue Apr 22 16:55:14 2008 From: lists at cheimes.de (Christian Heimes) Date: Tue, 22 Apr 2008 22:55:14 +0200 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: References: Message-ID: Nick Craig-Wood schrieb: > Nothing apart from the fact it doesn't work on windows. The buffering > will cause you grief too. If you want to do this properly under unix > use pexpect not subprocess. > > http://www.noah.org/wiki/Pexpect > > Proper non blocking IO is an absolute nightmare under Windows in my > experience! It really isn't the Windows way so you are fighting the > system the whole time. Nick is correct. The subproces tries to work around the issues with threads. But it's no more than an ugly workaround fir Windows' short comings on async file IO. It's a shame Windows implements the select() syscall in wsock32 and limits its usage to sockets. By the way I'm willing to dedicate some time to help enhancing the subprocess. Everybody is invited to submit patches and I'll review and check them into the trunk and py3k ASAP. Any help is appreciated: enhancements for async IO, doc updates, more examples ... Christian Python core developer From gagsl-py2 at yahoo.com.ar Wed Apr 9 02:36:06 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 03:36:06 -0300 Subject: makepy.py not working References: <03e9c33d-d957-4bc0-8568-3a40403eadb9@a70g2000hsh.googlegroups.com> Message-ID: En Tue, 08 Apr 2008 10:18:48 -0300, escribi?: > I've a problem getting makepy running. When I start the tool on my > machine with doubleclick everything is fine. > But when I try this in my Code: > > makepy.py -i "Microsoft Excel 11.0 Object Library(1.5)" The above is supposed to be executed as a command, in a CMD console. It's not pyton code. > I am getting an Syntax Error and command: > > makepy.py > > bring me this message on the screen: > > Traceback (most recent call last): > File "", line 1, in > NameError: name 'makepy' is not defined Same as above: makepy.py is a filename, not a Python expression. > Any ideas what I am doing wrong? What do you actually want to do? The documentation for makepy and win32com.client.gencache is in the pywin32 help files, section Quick-Starts to Python and COM. -- Gabriel Genellina From musiccomposition at gmail.com Fri Apr 18 22:44:07 2008 From: musiccomposition at gmail.com (Benjamin) Date: Fri, 18 Apr 2008 19:44:07 -0700 (PDT) Subject: How to print a unicode string? References: <4809394A.1030906@v.loewis.de> Message-ID: <871c9b6b-7ebb-45b6-bf79-009bc2e0c1ce@c65g2000hsa.googlegroups.com> On Apr 18, 7:14 pm, "Martin v. L?wis" wrote: > > From what I've googled, I think I need to set my locale. > > Not on this operating system. On Windows, you need to change > your console. If it is a cmd.exe-style console, use chcp. > For IDLE, changing the output encoding is not supported. > > If you want to output into a file, use codecs.open. > > If you absolutely want to output UTF-8 to the terminal even > though the terminal will not be able to render it correctly, > use > > sys.stdout = codecs.getwriter("UTF-8")(sys.stdout) And in Py3k? > > HTH, > Martin From rhamph at gmail.com Wed Apr 16 15:39:55 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Wed, 16 Apr 2008 12:39:55 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> <09a38ca2-8c49-4eee-b6cf-58e849aea1fc@q1g2000prf.googlegroups.com> Message-ID: <8a96fe1f-1625-4ab5-942b-217ed42782a7@e67g2000hsa.googlegroups.com> On Apr 16, 12:52 pm, Aaron Watters wrote: > On Apr 16, 2:33 pm, Rhamphoryncus wrote: > > > The point is, you can't have it both ways. Either you evolve the > > language and break things, or you keep it static and nothing breaks. > > I disagree. You can add lots of cool > stuff without breaking the existing code base, mostly. > For example the minor changes to the way ints will work will > effect almost no programs. What changes are minor though? Eliminating old-style classes should be minor, but I'm not sure it is. Applications & libraries have a way of depending on the most obscure details - even if trivially fixed, it still requires a fix. Consider "as" becoming a keyword, or True and False. In hindsight, it would have been better to add future imports for unicode literals and print-as-a-function back in 2.5. I guess the time machine was out of service. 2.6 will have to do (and that's what it's for.) I'm personally not too worried about the syntax changes though, they're superficial(!). What I am worried about is the library APIs changing to use unicode instead of bytes. It's not something you could do incrementally without providing two of every lib or two of every API - having .write() and .writeex() would suck. From j.foster.davis at gmail.com Wed Apr 16 03:26:29 2008 From: j.foster.davis at gmail.com (Jacob Davis) Date: Wed, 16 Apr 2008 00:26:29 -0700 Subject: Can't see variables declared as global in a function Message-ID: <175C22B8-EE9B-4FC2-BDB0-F1DC7EFD5F60@gmail.com> Hi. I have a hundred lines of code in a module that declare some global variables inside a function so that those variables can be used by other functions. I want to import this module so that I can more easily debug by looking at the value of individual variables. But when I try to reach these variables, I get a warning that they are not defined. I am on an Intel Mac running Leopard 10.5.2, Python 2.5 Here is an example of some code that has the same problem: #!/usr/bin/env python global isglobal isglobal=200 def somefunc(): global from_somefunc from_somefunc=5 def anotherfunc(): return from_somefunc+30 So during debugging I want to look at the variable from_somefunc here is my terminal output. I start by looking at dir(), then run somefunc(), then run anotherfunc(), then I want to look at from_somefunc but I get a warning: Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from test_vars import * >>> dir() ['__builtins__', '__doc__', '__name__', 'anotherfunc', 'isglobal', 'somefunc'] >>> somefunc() >>> anotherfunc() 35 >>> isglobal 200 >>> from_somefunc Traceback (most recent call last): File "", line 1, in NameError: name 'from_somefunc' is not defined >>> dir() ['__builtins__', '__doc__', '__name__', 'anotherfunc', 'isglobal', 'somefunc'] Is there a way that I can view from_somefunc? Thanks, Jake -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at holdenweb.com Sun Apr 13 08:20:05 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 13 Apr 2008 08:20:05 -0400 Subject: Rounding a number to nearest even In-Reply-To: <8e6dbc15-98f2-441d-bba4-d9ddb36f482d@i36g2000prf.googlegroups.com> References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> <01db54ab-1fca-4a51-8b98-510de224f40a@y21g2000hsf.googlegroups.com> <8e6dbc15-98f2-441d-bba4-d9ddb36f482d@i36g2000prf.googlegroups.com> Message-ID: Lie wrote: > On Apr 12, 3:44 am, hdante wrote: [snip] > > In short, choosing that x.0 is rounded down and x.5 is rounded up is > arbitrary but not without a reason. Don't "arbitrary" and "not without a reason" directly contradict one another? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From ivlenin at gmail.com Fri Apr 18 01:23:21 2008 From: ivlenin at gmail.com (I V) Date: Fri, 18 Apr 2008 05:23:21 GMT Subject: Database vs Data Structure? References: <61bf5f46-e917-4a98-b87f-8e5087cb07f7@a23g2000hsc.googlegroups.com> Message-ID: On Thu, 17 Apr 2008 19:30:33 -0700, erikcw wrote: > use some sort of data-structure (maybe > nested dictionaries or a custom class) and store the pickled > data-structure in a single row in the database (then unpickle the data > and query in memory). Why would you want to do this? I don't see what you would hope to gain by doing this, over just using a database. From paddy3118 at netscape.net Fri Apr 18 02:41:40 2008 From: paddy3118 at netscape.net (Donald 'Paddy' McCarthy) Date: Fri, 18 Apr 2008 07:41:40 +0100 Subject: pprint module and newer standard types Message-ID: Hi, When I try and use pprint on standard types I get varying 'quality of output'. Lists will wrap nicely to multiple lines as will dicts, but sets and defaultdicts give one long unreadable line. Is their a chance to get this changed so that more built-in types look pretty when printed with pprint? I just did a small trial on an early version of Python 3 and sets don't seem to obey pprint.pprints width argument, the same way that lists do: Python 3.0a1 (py3k:57844, Aug 31 2007, 16:54:27) [MSC v.1310 32 bit (Intel)] on win32 >>> from pprint import pprint as pp >>> pp(list(range(3)), width=4) [0, 1, 2] >>> pp(set(range(3)), width=4) {0, 1, 2} - Paddy. From deets at nospam.web.de Mon Apr 7 05:11:58 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Mon, 07 Apr 2008 11:11:58 +0200 Subject: ldap References: <050e9150-7bbf-4a46-8c63-9d61835b1429@d1g2000hsg.googlegroups.com> Message-ID: <65u6rqF2hfq7rU1@mid.uni-berlin.de> mr.enx at alice.it wrote: > sorry, i'm new with Python. > I must do interaction beetween Python and Ldap, and I don't know how > do this. > Searching on the web I know that exists PythonLdap, but I dont'know if > this is best choise or not. Who cares? Use it, and see if it's good enough for your needs. Then, if not, see if alternatives are better. There seldomly is "the best" if there are several options, because the details and quirks of various solutions might appeal to one and repulse someone else. But nobody is going to know what *you* like best. Diez From mobile at ibinsa.com Sun Apr 27 07:05:28 2008 From: mobile at ibinsa.com (Gabriel Ibanez) Date: Sun, 27 Apr 2008 13:05:28 +0200 Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com><10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <8ee48fc1-45af-404f-8fad-d8e1b2fb90b4@s50g2000hsb.googlegroups.com> Message-ID: <003601c8a856$9a8c29f0$0a01a8c0@mobile> I did something near like that several days ago. Instead of programming in C++ I did it with RM-Cobol. I used to know the times that cobol takes to read the file and search for resutls, and I was surprised about the time that Python took doing the same: really, really fast. ----- Original Message ----- From: "n00m" Newsgroups: comp.lang.python To: Sent: Sunday, April 27, 2008 6:28 AM Subject: Re: Python(2.5) reads an input file FASTER than pure C(Mingw) > One more brick. > This time I compare list.sort() vs sort(vector). > Incredible. Python does it by 8.3s / 2.75s = 3 times faster than C++. > > > import time > f=open('D:\\v.txt','r') > z=f.readlines() > f.close() > t=time.time() > z.sort() > print time.time()-t > m=int(raw_input()) > print z[m] > > > #include > #include > #include > #include > #include > #include > #include > > using namespace std; > > vector vs; > > FILE *fp=fopen("D:\\v.txt","r"); > > int main() { > int i=0; > while (true) { > char line[50]; > if (!fgets(line,50,fp)) break; > vs.push_back(line); > ++i; > } > fclose(fp); > > double t; > t=clock()/CLOCKS_PER_SEC; > sort(vs.begin(),vs.end()); > cout << clock()/CLOCKS_PER_SEC << endl; > > int m; > cin >> m; > cout << vs[m]; > getchar(); > return 0; > } > > -- > http://mail.python.org/mailman/listinfo/python-list > From tjreedy at udel.edu Wed Apr 9 18:12:27 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 9 Apr 2008 18:12:27 -0400 Subject: I am worried about Python 3 References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> Message-ID: "jmDesktop" wrote in message news:77c208d1-8163-4acf-8e88-bd704e05bc04 at e39g2000hsf.googlegroups.com... | Two new versions of the language are currently in development: version | 2.6, which retains backwards compatibility with previous releases; and | version 3.0, which breaks backwards compatibility to the extent that | even that simplest of programs, the classic 'Hello, World', will no | longer work in its current form. That change is however, the one most immediately visible to new programmers. Most of the other statements are pretty much unchanged. In any case, 'print' is an easy-to-use facade over sys.stdout.write(), with default formatting. If really concerned about it, start programs with import sys write = sys.stdout.write and use that to write out explicitly formatted strings. (Some people routinely do this for production code anyway.) tjr From python at rcn.com Thu Apr 24 22:23:35 2008 From: python at rcn.com (Raymond Hettinger) Date: Thu, 24 Apr 2008 19:23:35 -0700 (PDT) Subject: Little novice program written in Python References: Message-ID: > What I would like is to receive some criticism to my code to make it more > Python'esque and, possibly, use the resources of the computer in a more > efficient way (the algorithm implemented below is the Sieve of Eratosthenes): It looks like straight-forward code and is fine as it stands. If you want to tweak it a bit, you can avoid using a flag like "finished" by using a break-statement. Raymond From martin at v.loewis.de Mon Apr 7 16:50:51 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Mon, 07 Apr 2008 22:50:51 +0200 Subject: Data structure recommendation? In-Reply-To: References: Message-ID: <47FA892B.1050608@v.loewis.de> > I know that foo.get() will be called many times for each foo.put(). Is > there any way to achieve O(1) performance for foo.get(), maybe via > some kind of hash function? Or is the best thing to use some kind of > binary search? If you know something about the density of the input values, O(1) is possible. E.g if there is a guarantee that there will be between 1 and 10 values per unit of input, then truncate the "event time" to the next-lower int, and use that as an index k into a list; the list item will be a list of events between k and k+1. As you know that there is an upper bound to the number of such events (10), you know that searching the list will take bounded (i.e. constant) time. Likewise, as you know that there will be atleast one event per (k,k+1) interval, you know that you have to scan only one list. If you know no such thing, you'll have to use a binary search. Regards, Martin From kyosohma at gmail.com Wed Apr 16 10:26:18 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 16 Apr 2008 07:26:18 -0700 (PDT) Subject: Finally had to plonk google gorups. References: Message-ID: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> On Apr 16, 9:19 am, Grant Edwards wrote: > This morning almost half of c.l.p was spam. In order to try to > not tar both the benign google group users and the malignant > ones with the same brush, I've been trying to kill usenet spam > with subject patterns. But that's not a battle you can win, so > I broke down and joined all the other people that just killfile > everything posted via google.groups. > > AFAICT, if you're a google groups user your posts are not being > seen by many/most experienced (read "non-google-group") users. > This is mainly the fault of google who has refused to do > anything to stem the flood of span that's being sent via Google > Groups. > > -- > Grant Edwards grante Yow! I would like to > at urinate in an OVULAR, > visi.com porcelain pool -- Yeah, I noticed that Google Groups has really sucked this week. I'm using the Google Groups Killfile for Greasemonkey now and it helps a lot. I like Google, but my loyalty only goes to far. This is a complete lack of customer service. Mike From dolloffdelvpg at gmail.com Wed Apr 16 08:06:19 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:06:19 -0700 (PDT) Subject: taylor swift concert tickets Message-ID: <10dc46b8-303d-415a-b653-315c2887392b@n1g2000prb.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From bob at passcal.nmt.edu Mon Apr 21 17:06:08 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Mon, 21 Apr 2008 15:06:08 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> Message-ID: <2008042115060816807-bob@passcalnmtedu> On 2008-04-21 14:50:13 -0600, Ivan Illarionov said: > On 22 ???, 00:10, Ivan Illarionov wrote: >> On 20 ???, 04:10, George Sakkis w > rote: >> >> >> >>> On Apr 18, 9:36 pm, Ross Ridge >>> wrote: >> >>>> Ross Ridge said: >> >>>>> If you have Python 2.5, here's a faster version: >> >>>>> from struct import * >>>>> unpack_i32be = Struct(">l").unpack >> >>>>> def from3Bytes_ross2(s): >>>>> return unpack_i32be(s + "\0")[0] >> 8 >> >>>> Bob Greschke wrote: >> >>>>> That's not even intelligible. I wanna go back to COBOL. :) >> >>>> It's the same as the previous version except that it "precompiles" >>>> the struct.unpack() format string. It works similar to the way Python > >>>> handles regular expressions. >> >>> I didn't know about the Struct class; pretty neat. It's amazing that >>> this version without Psyco is as fast Bob's version with Psyco! Adding >>> Psyco to it though makes it *slower*, not faster. So here's how I'd >>> write it (if I wanted or had to stay in pure Python): >> >>> try: import psyco >>> except ImportError: >>> from struct import Struct >>> unpack_i32be = Struct(">l").unpack >>> def from3Bytes(s): >>> return unpack_i32be(s + "\0")[0] >> 8 >>> else: >>> def from3Bytes(s): >>> Value = (ord(s[0])<<16) + (ord(s[1])<<8) + ord(s[2]) >>> if Value >= 0x800000: >>> Value -= 0x1000000 >>> return Value >>> psyco.bind(from3Bytes) >> >>> HTH, >>> George >> >> I was able to get even faster pure-python version using array module: >> >> a = array.array('l', ''.join(('\0' + s[i:i+3] for i in xrange(0, >> len(s), 3)))) >> if sys.byteorder == 'little': >> a.byteswap() >> >> It actually moves bytes around on C level. >> >> test code: >> import struct >> import array >> import sys >> >> unpack_i32be = struct.Struct(">l").unpack >> s = ''.join(struct.pack('>i', 1234567)[1:]*1000) >> >> def from3bytes_ord(s): >> values = [] >> for i in xrange(0, len(s), 3): >> Value = (ord(s[i])<<16) | (ord(s[i+1])<<8) | ord(s[i+2]) >> if Value >= 0x800000: >> Value -= 0x1000000 >> values.append(Value) >> return values >> >> def from3bytes_struct(s): >> return [unpack_i32be(s[i:i+3] + "\0")[0] >> 8 for i in xrange(0, >> len(s), 3)] >> >> def from3bytes_array(s): >> a = array.array('l', ''.join(('\0' + s[i:i+3] for i in xrange(0, >> len(s), 3)))) >> if sys.byteorder == 'little': >> a.byteswap() >> return a.tolist() >> >> from timeit import Timer >> >> t1 = Timer("from3bytes_ord(s)", "from __main__ import s, >> from3bytes_ord") >> t2 = Timer("from3bytes_struct(s)", "from __main__ import s, >> from3bytes_struct") >> t3 = Timer("from3bytes_array(s)", "from __main__ import s, >> from3bytes_array") >> >> print 'ord:\t', t1.timeit(1000) >> print 'struct:\t', t2.timeit(1000) >> print 'array:\t', t3.timeit(1000) >> >> Output: >> ord: 7.08213110884 >> struct: 3.7689164405 >> array: 2.62995268952 >> >> Inspired by Guido's essayhttp://www.python.org/doc/essays/list2str/ > > And even faster: > a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, > len(s), 3)))) > if sys.byteorder == 'little': > a.byteswap() > > I think it's a fastest possible implementation in pure python Geeze! :) How did struct get so fast? I'm guessing there have been improvements since 2.3 (which is what I've been working on). I'm going to be able to go back to my IBM PC XT pretty soon. :) Thanks! From robert.kern at gmail.com Mon Apr 14 19:48:37 2008 From: robert.kern at gmail.com (Robert Kern) Date: Mon, 14 Apr 2008 18:48:37 -0500 Subject: py2exe, program has stoped working!? In-Reply-To: <67526f9f-a610-4cbe-8e2c-6219a59a4d54@i36g2000prf.googlegroups.com> References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> <232151d6-09ed-4a1e-9922-d66c2bf0d05b@w8g2000prd.googlegroups.com> <67526f9f-a610-4cbe-8e2c-6219a59a4d54@i36g2000prf.googlegroups.com> Message-ID: John Machin wrote: > So I found by googling "has stopped working". I'd never seen such a > litany of weeping, wailing and u'\u02ad' before. OT: Best use of Unicode ever. -- 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 From grante at visi.com Tue Apr 1 14:28:32 2008 From: grante at visi.com (Grant Edwards) Date: Tue, 01 Apr 2008 13:28:32 -0500 Subject: Homework help References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> <65fagoF2fiivoU1@mid.uni-berlin.de> Message-ID: On 2008-04-01, Marc 'BlackJack' Rintsch wrote: >> Write a function zip(lst1, lst2) such that zip accepts two equal >> length lists and returns a list of pairs. For example, zip(['a', 'b', >> 'c'], [10, 20, 30]) should evaluate to the list [('a', 10), ('b', 20), >> ('c', 30)]. > > Hey not even a rebinding necessary. :-) Yes it is. The problem statement is "write a function" not "select an existing standard library function" or "produce this answer in the least number of lines of code". -- Grant Edwards grante Yow! Will the third world at war keep "Bosom Buddies" visi.com off the air? From dickinsm at gmail.com Mon Apr 7 21:16:40 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Mon, 7 Apr 2008 18:16:40 -0700 (PDT) Subject: A funnily inconsistent behavior of int and float References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com><1d11875a-470a-489f-910a-b420a145eb61@a1g2000hsb.googlegroups.com><11b4793c-04cc-4898-99a8-8418d237de3e@2g2000hsn.googlegroups.com> <1255ee3e-cc1e-4ae8-96f3-5f942c389c49@t54g2000hsg.googlegroups.com> Message-ID: On Apr 7, 4:59?pm, "Terry Reedy" wrote: > "Mark Dickinson" wrote in message > > news:1255ee3e-cc1e-4ae8-96f3-5f942c389c49 at t54g2000hsg.googlegroups.com... > > Thank you for the corrections. Here is my revised proposal: > > int([number | string[, radix]) > ... Excellent! It looks to me as though this covers everything. I'm tempted to quibble about exact wordings, but probably the most productive thing to do would be just to submit this to bugs.python.org and then let Georg Brandl work his magic on it. :-) Mark From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Fri Apr 25 08:03:55 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Fri, 25 Apr 2008 14:03:55 +0200 Subject: Remove multiple inheritance in Python 3000 References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <60fc4333-6d2b-40f5-b311-031d90a38d39@k37g2000hsf.googlegroups.com> Message-ID: <67dvlbF2nomm6U2@mid.individual.net> sturlamolden wrote: > On Apr 22, 1:07 pm, GD wrote: >> Multiple inheritance is bad for design, rarely used and contains >> many problems for usual users. >> >> Every program can be designed only with single inheritance. > > That's how the Java designers were thinking as well: If MI is > allowed, programmers will suddenly get an irresistible urge to use > MI to write unmaintainable spaghetti code. So let's disallow MI > for the sake of common good. Argumenting like that, *all* programming languages had to be outlawed. 8) Regards, Bj?rn -- BOFH excuse #391: We already sent around a notice about that. From kayvoo at googlemail.com Fri Apr 18 19:50:16 2008 From: kayvoo at googlemail.com (Karl-Heinz Ruskowski) Date: Sat, 19 Apr 2008 01:50:16 +0200 Subject: python setup.py install on Vista? In-Reply-To: References: Message-ID: <200804190150.22542.kayvoo@gmail.com> hi > well using windows vista, where the h*** am i supposed to type this? you have to include the path to the python interpreter like this c:\programs\python\python.exe pythonfile.py (replace this with your path) or you set an alias called python - i don't know how to that under windows, especially visa :D good luck -- GPG key: 0x04B3BB96 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available URL: From skanemupp at yahoo.se Thu Apr 17 05:28:48 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 17 Apr 2008 02:28:48 -0700 (PDT) Subject: def power, problem when raising power to decimals References: Message-ID: <45c97b5a-e7ff-4f22-b419-62766c210406@d1g2000hsg.googlegroups.com> actually that 0**0 statement was wrong. 0**0 = 1 and should be. From aahz at pythoncraft.com Sat Apr 26 11:46:49 2008 From: aahz at pythoncraft.com (Aahz) Date: 26 Apr 2008 08:46:49 -0700 Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> Message-ID: In article <9028496e-30de-4853-8f57-b55d14e52358 at h1g2000prh.googlegroups.com>, John Henry wrote: > >But then I looked closer. It turns out the XML file created by >QxTransformer is *very* similar in structure when compared to the >resource files used in PythonCard. Since there are no GUI builders >for QxTransformer, and I can't affort to buy the one for Qooxdoo >(Java! Yuk!), I decided to roll up my sleeves, took the Pythoncard's >Layout Manager and modified it and created my own "Poor Man's Qooxdoo >GUI Layout Designer". Cute! When you have working code, please do upload to PyPI. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ Why is this newsgroup different from all other newsgroups? From jeff_barish at earthlink.net Wed Apr 23 21:48:05 2008 From: jeff_barish at earthlink.net (Jeffrey Barish) Date: Wed, 23 Apr 2008 19:48:05 -0600 Subject: Problem using copy.copy with my own class References: <676noiF2n7ttmU1@mid.uni-berlin.de> Message-ID: Marc 'BlackJack' Rintsch wrote: > Please simplify the code to a minimal example that still has the problem > and *show it to us*. It's hard to spot errors in code that nobody except > you knows. Here it is: import copy class Test(int): def __new__(cls, arg1, arg2): return int.__new__(cls, arg1) def __init__(self, arg1, arg2): self.arg2 = arg2 if __name__ == '__main__': t = Test(0, 0) t_copy = copy.copy(t) Traceback (most recent call last): File "copytest.py", line 12, in t_copy = copy.copy(t) File "/usr/lib/python2.5/copy.py", line 95, in copy return _reconstruct(x, rv, 0) File "/usr/lib/python2.5/copy.py", line 322, in _reconstruct y = callable(*args) File "/usr/lib/python2.5/copy_reg.py", line 92, in __newobj__ return cls.__new__(cls, *args) TypeError: __new__() takes exactly 3 arguments (2 given) -- Jeffrey Barish From gagsl-py2 at yahoo.com.ar Sun Apr 20 13:58:00 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 14:58:00 -0300 Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B80B5.1050500@cheimes.de> Message-ID: En Sun, 20 Apr 2008 14:43:17 -0300, Christian Heimes escribi?: > Gabriel Genellina schrieb: >> Apart from what everyone has already said, consider that FreqDist may import other modules, store global state, create other objects... whatever. >> Pure python code should not have any memory leaks (if there are, it's a bug in the Python interpreter). Not-carefully-written C extensions may introduce memory problems. > > Pure Python code can cause memory leaks. No, that's not a bug in the > interpreter but the fault of the developer. For example code that messes > around with stack frames and exception object can cause nasty reference > leaks. Ouch! May I assume that code that doesn't use stack frames nor stores references to exception objects/tracebacks is safe? -- Gabriel Genellina From fabiofz at gmail.com Fri Apr 4 17:07:28 2008 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Fri, 4 Apr 2008 18:07:28 -0300 Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? In-Reply-To: <0c8bfed7-1154-41d5-a740-6d1382180db2@d45g2000hsc.googlegroups.com> References: <0c8bfed7-1154-41d5-a740-6d1382180db2@d45g2000hsc.googlegroups.com> Message-ID: On Fri, Apr 4, 2008 at 5:05 PM, Nebur wrote: > Yes. Linux viruses are rare but useful :-) > Well, I don't think the problem a very dangerous one. The Pydev/ > Eclipse was used for much more than a year nearly daily and > intensively. The strange effect is very rare,obviously (plus the > chance that it's in my brain, as I mentioned ;-D ) so you probably can > lean back. Anyway, I'd be glad to get an even faint idea of the > problem. Hi Nebur, Well, I have absolutely no idea of what could trigger that either :( So, just wanted to point out that eclipse saves your file history (even if you do not have a vcs)... that operation can be selected by right clicking a parent folder and selecting 'restore from local history'. Cheers, Fabio From ceres83 at gmail.com Fri Apr 18 11:55:16 2008 From: ceres83 at gmail.com (Mario Ceresa) Date: Fri, 18 Apr 2008 17:55:16 +0200 Subject: Pickle problem Message-ID: Hello everybody: I'd like to use the pickle module to save the state of an object so to be able to restore it later. The problem is that it holds a list of other objects, say numbers, and if I modify the list and restore the object, the list itself is not reverted to the saved one, but stays with one element deleted. An example session is the following: Data is A [1, 2, 3, 4] saving a with pickle Deleting an object: del a[3] Now data is A [1, 2, 3] Oops! That was an error: can you please recover to the last saved data? A [1, 2, 3] #### I'd like to have here A[1,2,3,4]!!!!!! Is it the intended behavior for pickle? if so, are there any way to save the state of my object? Code follows ----------------------- class A(object): objects = [] ----------------------- then I run the code: --------------------------------------- import pickle from core import A a = A() for i in [1,2,3,4]: a.objects.append(i) savedData = pickle.dumps(a) print "Saved data is ",a print "Deleting an object" del a.objects[3] print a print "Oops! This was an error: can you please recover the last saved data?" print pickle.loads(savedData) -------------------------------------------- Thank you for any help! Mario From deets at nospam.web.de Tue Apr 29 19:30:27 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 30 Apr 2008 01:30:27 +0200 Subject: API's and hardware communication. Newbie In-Reply-To: References: <_MudnfZZ9uW0hY7VRVnyhwA@bt.com> Message-ID: <67ppciF2ppl3sU2@mid.uni-berlin.de> Grayham schrieb: > It seems to me that python needs to be extended with C in some form to able > to do what i need. I think instead of learning two languages i am going to > put all my efforts in to learning C as it seems that's where i am going to > end up. It's your decision of course. But you will end up in much more frustration than learning python (maybe by not picking an endeavour so big that it needs C on a certain level) and then after you have a good grasp of general concepts try and adapt these to other languages such as C. But again - you decide which road you prefer to go. Diez From paul at boddie.org.uk Mon Apr 21 05:01:08 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Mon, 21 Apr 2008 02:01:08 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> <48a1d10c-87cb-43c3-83f4-9c331fc1d818@m1g2000pre.googlegroups.com> Message-ID: On 21 Apr, 00:54, Dan Bishop wrote: > > We wouldn't even need that. Just a new source encoding. Then we > could write: > > # -*- coding: end-block -*- [...] Someone at EuroPython 2007 did a lightning talk showing working code which provided C-style block structuring using this mechanism. My brother then jokingly suggested to Martijn Faassen that if someone plugged the 2to3 converter in as a source file encoding handler, his worries about migrating to Python 3 would disappear. I'm waiting to see if anyone actually bothered to make that happen, albeit for amusement purposes only. Paul P.S. EuroPython 2008 is now accepting talks, especially ones on the language, Python 3000, and other implementations. See http://www.europython.org/ for details! From skanemupp at yahoo.se Thu Apr 10 12:32:17 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 09:32:17 -0700 (PDT) Subject: Tkinter: Entry, how to get INSERTpos? Message-ID: <3c5ddae0-906e-4800-80e2-bba1e6462e79@z24g2000prf.googlegroups.com> in this function i want to be able to use the cursor and delete in the middle of a number. how do i get the value of anchor or insert? i want to write: e.delete(pos-1,pos) def Backspace(): a=len(e.get()) e.delete(a-1,END) #e.delete(INSERT, END) #e.delete(ANCHOR,END) the complete program: from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") l = Label(mygui, text="Answer: ") l.place(relx=0.15, rely=0.2, anchor=CENTER) e = Entry(mygui) e.place(relx=0.48, rely=0.1, anchor=CENTER, width=173) c = Entry(mygui) c.place(relx=0.6, rely=0.2, anchor=CENTER) def Disp(nstr): e.insert(INSERT, nstr) def Calc(): expr=e.get() c.delete(0, END) try: c.insert(END, eval(expr)) except: c.insert(END, "Not computable") def Erase(): e.delete(0,END) c.delete(0, END) def Backspace(): a=len(e.get()) e.delete(a-1,END) #e.delete(INSERT, END) #e.delete(ANCHOR,END) x = 0.1 y = 0.4 for char in '123+456-789*0()/.': b = Button(mygui, text=char, command=lambda n=char:Disp(n), width=2, height=1) b.place(relx=x, rely=y, anchor=CENTER) x=x+0.1 if x==0.5: x=0.1 y=y+0.1 b = Button(mygui, text="^", command=lambda n="**":Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.8, anchor=CENTER) b = Button(mygui, text="C",command=Erase, width=2, height=1) b.place(relx=0.3, rely=0.8, anchor=CENTER) b = Button(mygui, text="c",command=Backspace, width=2, height=1) b.place(relx=0.4, rely=0.8, anchor=CENTER) b = Button(mygui, text="=",command=Calc, width=12, height=1) b.place(relx=0.25, rely=0.9, anchor=CENTER) mygui.mainloop() From subhabrata.iisc at hotmail.com Tue Apr 8 04:24:53 2008 From: subhabrata.iisc at hotmail.com (subhabrata.iisc at hotmail.com) Date: Tue, 8 Apr 2008 01:24:53 -0700 (PDT) Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. Message-ID: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> I am using Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v. 1310 32 bit (Intel)] on win32 with IDLE 1.2.1 My O/S is Windows XP SP2 I use 512 MB RAM. I am encountering the following problems: (i) a1=1 a2=2 a3=a1+a2 print a3 # The result is coming sometimes as 3 sometimes as vague numbers. (ii) x1="Bangalore is called the Silicon Valley of India" x2="NewYork" x3=x1.find(x2) print x3 # The result of x3 is coming as -1 as well as +ve numbers. (iii) I have been designing one crawler using "urllib". For crawling one web page it is perfect. But when I am giving around 100 URLs by and their links and sublinks the IDLE is not responding. Presently I have been running with 10 URLs but can't it be ported? (iv) I have designed a program with more than 500 if elif else but sometimes it is running fine sometimes it is giving hugely erroneous results, one view of the code: elif a4==3: print "YOU HAVE NOW ENTERED THREE WORDS" if a3[0] not in a6: if a3[1] not in a6: if a3[2] not in a6: print "a3[0] not in a6, a3[1] not in a6, a3[2] not in a6" elif a3[2] in a6: print "a3[0] not in a6, a3[1] not in a6, a3[2] in a6" else: print "NONE3.1" elif a3[1] in a6: if a3[2] not in a6: print "a3[0] not in a6, a3[1] in a6, a3[2] not in a6" elif a3[2] in a6: print "a3[0] not in a6,a3[1] in a6, a3[2] in a6" else: print "NONE3.2" else: print "NONE3.3" elif a3[0] in a6: if a3[1] not in a6: if a3[2] not in a6: print "a3[0] in a6, a3[1] not in a6, a3[2] not in a6" elif a3[2] in a6: print "a3[0] in a6, a3[1] not in a6, a3[2] in a6" else: print "NONE3.4" elif a3[1] in a6: if a3[2] not in a6: print "a3[0] in a6, a3[1] in a6, a3[2] not in a6" elif a3[2] in a6: print "a3[0] in a6, a3[1] in a6, a3[2] in a6" else: print "NONE3.5" else: print "NONE3.6" else: print "NONE3.7" Why it is behaving like that? If someone can help me. Best Regards, Subhabrata Banerjee, Indian Institute of Science, Bangalore, India. From fredrik at pythonware.com Sun Apr 6 16:50:46 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 06 Apr 2008 22:50:46 +0200 Subject: How to create an exe-file? In-Reply-To: <311a216f-5366-47c5-86a7-431dd23ced3e@j1g2000prb.googlegroups.com> References: <311a216f-5366-47c5-86a7-431dd23ced3e@j1g2000prb.googlegroups.com> Message-ID: skanemupp at yahoo.se wrote: > how do you create exe-files of your python-code? > > is it different depending on what libraries, GUI-frameworks you use? > > i want to create an exe-file of a pythonscript that uses Tkinter. assuming windows only, you want: http://www.py2exe.org/ also see: http://effbot.org/zone/python-compile.htm From musiccomposition at gmail.com Thu Apr 10 22:40:49 2008 From: musiccomposition at gmail.com (Benjamin) Date: Thu, 10 Apr 2008 19:40:49 -0700 (PDT) Subject: How to use my dynamic link libraries in python?? References: Message-ID: On Apr 10, 9:21 pm, "???" wrote: > Hello: > My OS is Linux, I compile my dynamic link libraries , and > want to call the function of my dynamic library through python! > How can I realize the function? Please give me some advices! Thanks You have several options. You could write a Python extension module to bind the functions in dylib to the interpreter. You could also have a look at the ctypes module. From mnordhoff at mattnordhoff.com Tue Apr 8 03:28:40 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Tue, 08 Apr 2008 07:28:40 +0000 Subject: Destructor? In-Reply-To: <47FB1E5E.6010708@mattnordhoff.com> References: <47FB1937.5050008@mydeskfriend.com> <47FB1E5E.6010708@mattnordhoff.com> Message-ID: <47FB1EA8.6000801@mattnordhoff.com> Matt Nordhoff wrote: > Gabriel Rossetti wrote: >> Hello everyone, >> >> we are writing an application that needs some cleanup to be done if the >> application is quit, normally (normal termination) or by a signal like >> SIGINT or SIGTERM. I know that the __del__ method exists, but unless I'm >> mistaken there is no guarantee as of when it will be called, and some >> objects may have already been released (at lease I've had trouble in the >> past accessing certain objects from inside __del__, probably since the >> parent class's __del__ has to be called first, then it's objects are >> already released by the time I need to do something with them). Another >> method would be to implement something using the signal module and have >> a callback that does all the cleanup when the app. is >> quit/terminated/interrupted and have all the child classes override that >> with their cleanup code. >> >> What is the community's point of view on the subject? >> >> Thanks, >> Gabriel > > atexit? > > If it's only small things, there's try...finally, of course.. Huh, I totally didn't know that atexit is only run on normal terminations. Oops. Never mind. -- From steve at holdenweb.com Tue Apr 8 17:39:10 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 17:39:10 -0400 Subject: CPython VM & byte code resources wanted In-Reply-To: <66238qF2h0kfqU1@mid.individual.net> References: <6622srF2e32hbU1@mid.individual.net> <66238qF2h0kfqU1@mid.individual.net> Message-ID: Aaron Gray wrote: > "Aaron Gray" wrote in message > news:6622srF2e32hbU1 at mid.individual.net... >> Hi, >> >> I am looking to study the CPython source code, but I cannot seem to find >> the VM code. > > Found it :) > > Python/ceval.c > >> Also is there any where a detailed list of the opcodes ? > > Still could do with an opcodes chart. > Be sure and post it on the Wiki when you finish it ;-) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bsk16 at case.edu Mon Apr 28 22:25:23 2008 From: bsk16 at case.edu (Benjamin Kaplan) Date: Mon, 28 Apr 2008 22:25:23 -0400 Subject: Python Math libraries - How to? In-Reply-To: References: Message-ID: On Mon, Apr 28, 2008 at 10:07 PM, wrote: > Hi, I am a very newbie who would very much appreciate some hints. > > Python 2.52. on Windows XP for now. Soon on Ubuntu 8 > > I am teaching myself Python following free tutorials. I can solve > problems using arithmetic, but when I try to upgrade the programs > using math libraries nothing seems to work. I downloaded a 2002 > tutorial from Zelle "An Introduction to Computer Science" where he > uses a "import math" statement to calculate a square root. I tried the > "pi" library function but it didn?t work. I tried using def Pi() it > did not work either. I am yet to find a tutorial that explains how to > declare (or initialize) and pass numbers to the functions such as > "cos(x)" and the pi which does not have a variable in it. Is just a > constant. > > Here is the arithmetic program I made that it worked before I added > the "import math" line. I erased the constant p = 3.1416 and added > the "i" for the library function "pi" in the algorithms. But I get an > error message not recognizing "pi" > > > > #volumen.py > # A program to compute the volume and surface area of a sphere > import math > > def main(): > > print "This program calculates the volume and surface area of a > sphere" > print > r = input("Please enter the radious: ") > print > r3 = r*r*r > volume = 4/3*pi*r3 > r2 = r*r > surface = 4*pi*r2 > print "The Volume is", volume, " Cubic centimeters" > print > print "The Surface area is", surface, " square centimeters" > > main() > > *** Error message ************* > > Traceback (most recent call last): > File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 20, in > > main() > File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 13, in main > volume = 4/3*pi*r3 > NameError: global name 'pi' is not defined > -- > http://mail.python.org/mailman/listinfo/python-list > pi is not a global name. When you do "import math",you aren't adding everything to the name space, you are just telling python that you are going to be using that file. You then refer to it as math.*, such as "math.pi", or "math.pow(r,3)". To use it the way you want to, you would have to do "from math import pi" instead of "import math" From wongjoekmeu at yahoo.com Tue Apr 22 12:06:34 2008 From: wongjoekmeu at yahoo.com (wongjoekmeu at yahoo.com) Date: Tue, 22 Apr 2008 09:06:34 -0700 (PDT) Subject: SWIG C++ std::cout do not output to interactive interpreter IDLE Message-ID: Dear All, I have some functions written in C++, which I try to approach from python using swig. In the C++ functions I use std::cout to print stuff to output. Everything works fine, but the only problem that I have is that when I start IDLE and use the functions what std::cout should print to the "IDLE console" simply does not appear. When I don't use IDLE but simply double click on the .py script, it works all fine. I was wondering how I could make sure that std::cout would print also to IDLE. Thanks a lot in advance for helping to answer my question. RR From bobby.connor at gmail.com Tue Apr 1 12:29:25 2008 From: bobby.connor at gmail.com (bobby.connor at gmail.com) Date: Tue, 1 Apr 2008 09:29:25 -0700 (PDT) Subject: Homework help References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> <7xfxu5ft1s.fsf@ruckus.brouhaha.com> Message-ID: <8e1f6963-1cdd-4afe-9ea5-f1886ed452ab@d21g2000prf.googlegroups.com> On Apr 1, 12:17 pm, Paul Rubin wrote: > bobby.con... at gmail.com writes: > > I don't necessarily want the answers, but need help on how to approach > > it/the steps i need to solve the problems > > What parts are you having difficulty with? Are there some course > materials and have you read them yet? I just don't know how to start the problems off From steve at holdenweb.com Sat Apr 5 07:11:04 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 07:11:04 -0400 Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! In-Reply-To: References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <7113d012-01bb-4426-bb40-9e2811cdb102@x41g2000hsb.googlegroups.com> <3cf4bbc8-b828-45c5-b9a8-766ce600af43@y21g2000hsf.googlegroups.com> Message-ID: skanemupp at yahoo.se wrote: [stuff, including quoted copies of an original program and its replacement] > > and the self. i erased, should i do it in the def __init__ as well or > only as i did in createwidgets-function? Your posts would be easier to consider if you trimmed out the stuff that's no longer relevant. I for one pretty much just skipped over them because of their tedious length. Just thought I'd mention it. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From tarundevnani at gmail.com Mon Apr 28 01:08:31 2008 From: tarundevnani at gmail.com (tarun) Date: Mon, 28 Apr 2008 10:38:31 +0530 Subject: Related to Shelve Module Message-ID: Hi All, I want to store the class instance object variables persistenlty in one file so that other file can also access for some filtering. I tired doing this using the shelve module. *Code:* class A: pass import shelve filename = 'test.db' d = shelve.open(filename) a = A() print a d['1'] = a print d['1'] d.close() *Output:* <__main__.A instance at 0x018B56C0> <__main__.A instance at 0x018B5760> *Observation:* I expect both the print statements to return the same value, The second print statement just reads the dictonary, but still the adress (0x..) is different from the first print statement. Can anyone tell me why. Also let me know if you the way of getting same value both the times. Quick help will be appreciated. Thanks & Regards, Tarun -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlwuhwdmckay at gmail.com Sat Apr 26 09:32:48 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:32:48 -0700 (PDT) Subject: call of duty 4 crack multiplayer Message-ID: <8305e313-81ea-417b-8e0a-e72076823026@x35g2000hsb.googlegroups.com> call of duty 4 crack multiplayer http://cracks.00bp.com F R E E C R A C K S From lists at cheimes.de Mon Apr 21 06:50:04 2008 From: lists at cheimes.de (Christian Heimes) Date: Mon, 21 Apr 2008 12:50:04 +0200 Subject: sys.maxint in Python 3 In-Reply-To: References: Message-ID: <480C715C.90809@cheimes.de> bearophileHUGS at lycos.com schrieb: > In some algorithms a sentinel value may be useful, so for Python 3.x > sys.maxint may be replaced by an improvement of the following infinite > and neginfinite singleton objects: Python 3.0 doesn't have sys.maxint any more since Python 3's ints are of arbitrary length. Instead of sys.maxint it has sys.maxsize; the maximum size of a positive sized size_t aka Py_ssize_t. Christian From steve at holdenweb.com Mon Apr 14 14:09:23 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 14 Apr 2008 14:09:23 -0400 Subject: =?UTF-8?B?562U5aSNOiBKYXZhIG9yIEMrKz8=?= In-Reply-To: References: Message-ID: Marco Mariani wrote: > Penny Y. wrote: > >> Javascript is different from Java at all. > > I think even rocks know that. Yet, some use of closure and > prototype-based inheritance might be interesting to the OP. > >> Why not Perl? > > Come on, learning Perl after two years of Python? How harsh. > >> Perl is a functional language, > > And gwbasic is object oriented. > > And I am Marie of Roumania. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From banibrata.dutta at gmail.com Mon Apr 28 09:25:51 2008 From: banibrata.dutta at gmail.com (Banibrata Dutta) Date: Mon, 28 Apr 2008 18:55:51 +0530 Subject: Checking for existance of feature / tools / solutions -- Something like Java webstart Message-ID: <3de8e1f70804280625j239b1c09w360072a409783a95@mail.gmail.com> Hi, I've tried searching this list & googling around a bit -- trying to see if there is a Java-Webstart like alternative for Python, the closest approximate I've found is something suggested in this post: http://mail.python.org/pipermail/python-list/2004-September/282837.html Is this still pretty much the state-of-art ? Or, is there some other, better, simpler, snappier alternative. My requirements fundamentally are to use the web-mechanism ("something" embedded in a webpage, that is able to detect whether particular (minimal) version of Python is installed on the client system, and whether my client-software (Python app) is installed or not, will possibly, first install Python (latest) if not installed, and then my client-software (Python app). If both are installed, it'd allow me to upgrade the python app (and/or Python itself prior to it). This seems to be a something that should be fairly common thing that folks might have to do! thanks & regards, Banibrata From deets at nospam.web.de Tue Apr 22 06:34:48 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 12:34:48 +0200 Subject: Python Success stories In-Reply-To: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <675tasF2kecjsU1@mid.uni-berlin.de> azrael schrieb: > Hy guys, > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. > > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" > > This hurts. Please give me informations about realy famous > aplications. This isn't worth too much, but nontheless: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html Klick on Perl & Python respectively to see who's going to need to use something else some day. But the real problem is not your friend - it's you. He hurts you because you let him. Stop getting mad about that he teases you. Diez From xnews2 at fredp.lautre.net Sun Apr 27 15:23:30 2008 From: xnews2 at fredp.lautre.net (Fred Pacquier) Date: 27 Apr 2008 19:23:30 GMT Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> Message-ID: John Henry said : > Welcome to the modernized world of Pythoncard!!! Hey, that's really neat ! I remember dabbling in Pythoncard in the early days, some years ago, it was a very interesting project. I gave it up eventually, partly because it seemed somewhat abandoned (I see it's still stuck in 2006 ?), but mostly because the wxPython dependency was either unavailable or too hefty for the sort of machines I was interested in using it on (a Sharp Zaurus then, now Nokia Internet tablets). Since then I've been doing web apps instead, hosted and used on the devices themselves. So using Pythoncard as a designer for web apps, of course that rings a bell... Do you have any idea of the computing requirements of Qooxdoo and QxTransformer, compared to a native Pythoncard app ? I wonder if your stuff would run acceptably on today's mobile platforms (the Nokias have a Firefox derivative that is reasonably competent at javascript), and would give it a try if it's not too arcane. Do keep us posted ! TIA, fp From aldo at nullcube.com Sat Apr 5 17:30:59 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Sun, 6 Apr 2008 07:30:59 +1000 Subject: ANN: pry unit testing framework In-Reply-To: References: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com> <20080405141329.GD15684@nullcube.com> Message-ID: <20080405213059.GA19741@nullcube.com> Steve, > Kay at least has a long history as a contributor in this group, so > people know how to interpret her remarks and know that her contributions > are made on the basis of a deep understanding of Python. She is far from > belonging to the "peanut gallery", and to suggest otherwise betrays > either ignorance, arrogance, or both. While I'm not a regular poster on this list, I have been reading it for nearly 10 years, so I probably have more context here than you suspect. At least one mail to this list and a number of personal emails to me suggest that it is Kay and and indeed you who are temporarily out of line with the tone of the list. A more impartial re-reading of the debate so far might make you judge my final, admittedly angry, response more fairly. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From gagsl-py2 at yahoo.com.ar Mon Apr 14 21:40:18 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 14 Apr 2008 22:40:18 -0300 Subject: =?utf-8?B?5pyJ5Lit5Zu95Lq65LmOPw==?= References: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> <4801F702.5050401@arcor.de> Message-ID: En Mon, 14 Apr 2008 16:02:20 -0300, John Henry escribi?: > On Apr 14, 11:17 am, Steve Holden wrote: >> I have no idea. Babelfish (from which I obtained my reply as well as >> whatever understanding I had of the original inquiry) translated my >> reply as >> >> But the academic society never is immediately, with will need time >> >> whereas yours becomes >> >> Studies python not to be possible on first to become, needs to proceed >> in an orderly way >> >> Since what I entered in English was something like "Yes, Python has a >> future. But it will take some study". Perhaps you can tell me whether >> your translation gives the correect flavor. I'm pretty sure the >> babelfish mangled my intent. > ROFL > > I would not recomend using babalfish to translate between Chinese and > English. It does a *horrible* job at that. It does a *horrible* job with any language. It can be used to translate from any foreign language into your native language, and then you can try to guess the meaning - but even a 5yr old boy can make more meaningful sentences than Babelfish output :) > But then in this particular case, it was able to convey what you > wanted to say - in a rather awkward fashion. :-) Probably thanks to the amazing capabilities of your human brain, not Babelfish :) -- Gabriel Genellina From esj at harvee.org Fri Apr 4 10:33:43 2008 From: esj at harvee.org (Eric S. Johansson) Date: Fri, 04 Apr 2008 10:33:43 -0400 Subject: Unicode conversion problem (codec can't decode) In-Reply-To: References: <47F5AFFC.3060902@harvee.org> Message-ID: <47F63C47.4070501@harvee.org> > > Almost there: use string-escape instead; it takes a byte string and > returns another byte string in ASCII. perfect. Exactly what I wanted. thank you so very much. > >> I really don't care about the character set used. I'm looking for a >> matched set >> of operations that converts the string to a seven bits a form and back >> to its >> original form. > > Ok, string-escape should work. But which database are you using that can't > handle 8bit strings? I tripped over some bugs with pysqlite in terms of what it should and should not accept as text. Now that I've gotten through my particular "crisis" I need to sit down and generate a test case so the problem can be fixed. thanks again. ---eric -- Speech-recognition in use. It makes mistakes, I correct some. From steve at holdenweb.com Wed Apr 9 11:11:49 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 11:11:49 -0400 Subject: import statement convention In-Reply-To: <405fef20-2593-44da-abe8-516fec7e59fa@k10g2000prm.googlegroups.com> References: <4078bcf4-e68f-45d4-93ce-335ec7a33c5a@v32g2000prd.googlegroups.com> <405fef20-2593-44da-abe8-516fec7e59fa@k10g2000prm.googlegroups.com> Message-ID: MartinRinehart at gmail.com wrote: > Thanks, all. > > Good to know no one's been beheaded. > > Yes to separating test and non-test code, but no if that will just > turn one modest module into two modules, smaller still. > > Amen to 'practicality beats purity.' > > Do wish we had a good, thorough convention set. I wrote one for Java. > It took a lot of work. ( file:/home/martin/mrwebsite/articles/code- > conventions.html ) I appreciate the sentiment, but I seem to be having problems accessing your disk from over here. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gh at ghaering.de Wed Apr 9 08:23:57 2008 From: gh at ghaering.de (=?ISO-8859-2?Q?Gerhard_H=E4ring?=) Date: Wed, 09 Apr 2008 14:23:57 +0200 Subject: is Pylons alive? In-Reply-To: References: Message-ID: <663qr1F2ig5dkU1@mid.uni-berlin.de> Mage wrote: > Hello, > > I don't want to be impolite, just in short: I am thinking about leaving > RoR and coming back to Python. I've missed the last two years in Python, > however I have been subscribed to this list and there are not too many > e-mails about Pylons in my mailbox. Why don't you take a look at the Pylons mailing list instead? http://groups.google.com/group/pylons-discuss > On my Gentoo the latest Pylons ebuild has date "jul 2007" or something > like last summer. It has testing keywords both for x86 and amd64. (No > stable version available). It's available on my debian "testing" desktop. > > Before spending much time for investigating, I would like to ask you: is > Pylons the framework I look for if I want to come back to Python and > develop MVC web apps? Of course I don't know if Pylons is the best tool for you. It is definitely alive and kicking. Anyway, I'm pretty sure there's no way around trying it out for yourself. It should only take a few hours to see if you're comfortable with it. Other alternatives: - Django - TurboGears 2.0 (I personally wouldn't bother with TurboGears 1.x at this point) - Build your own based on WSGI components, mix and match WSGI server, ORM, template engine - this is not so stupid as it may sound HTH, -- Gerhard From nagle at animats.com Wed Apr 16 13:27:26 2008 From: nagle at animats.com (John Nagle) Date: Wed, 16 Apr 2008 10:27:26 -0700 Subject: Unicode chr(150) en dash In-Reply-To: References: Message-ID: <48063434$0$36327$742ec2ed@news.sonic.net> marexposed at googlemail.com wrote: > Hello guys & girls > > I'm pasting an "en dash" > (http://www.fileformat.info/info/unicode/char/2013/index.htm) character into > a tkinter widget, expecting it to be properly stored into a MySQL database. > > I'm getting this error: > ***************************************************************************** > Exception in Tkinter callback Traceback (most recent call last): File > "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__ return > self.func(*args) File "chupadato.py", line 25, in guardar cursor.execute(a) > File "C:\Python24\Lib\site-packages\MySQLdb\cursors.py", line 149, in execute > query = query.encode(charset) UnicodeEncodeError: 'latin-1' codec can't > encode character u'\u2013' in position 52: ordinal not in range(256) > ***************************************************************************** Python and MySQL will do end to end Unicode quite well. But that's not what you're doing. How did "latin-1" get involved? If you want to use MySQL in Unicode, there are several things to be done. First, the connection has to be opened in Unicode: db = MySQLdb.connect(host="localhost", use_unicode = True, charset = "utf8", user=username, passwd=password, db=database) Yes, you have to specify both "use_unicode=True", which tells the client to talk Unicode, and set "charset" to"utf8", which tells the server to talk Unicode encoded as UTF-8". Then the tables need to be in Unicode. In SQL, ALTER DATABASE dbname DEFAULT CHARACTER SET utf8; before creating the tables. You can also change the types of existing tables and even individual fields to utf8, if necessary. (This takes time for big tables; the table is copied. But it works.) It's possible to get MySQL to store character sets other than ASCII or Unicode; you can store data in "latin1" if you want. This might make sense if, for example, all your data is in French or German, which maps well to "latin1". Unless that's your situation, go with either all-ASCII or all-Unicode. It's less confusing. John Nagle From rridge at caffeine.csclub.uwaterloo.ca Sun Apr 20 01:00:17 2008 From: rridge at caffeine.csclub.uwaterloo.ca (Ross Ridge) Date: Sun, 20 Apr 2008 01:00:17 -0400 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> Message-ID: Ross Ridge wrote: > It's the same as the previous version except that it "precompiles" > the struct.unpack() format string. =A0It works similar to the way Python > handles regular expressions. George Sakkis wrote: >I didn't know about the Struct class; pretty neat. It's amazing that >this version without Psyco is as fast Bob's version with Psyco! Unfortunately, it doesn't seem to documented in the Python 2.5 manual. The speed improvement mainly comes from avoiding the Python code in the struct module that wraps the Struct class. The struct module caches already compiled format strings, but looking format strings in the cache ends taking a fair chunk of time in my original example. Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] rridge at csclub.uwaterloo.ca -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // From pavlovevidence at gmail.com Thu Apr 10 20:25:35 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Thu, 10 Apr 2008 17:25:35 -0700 (PDT) Subject: text adventure game problem References: Message-ID: On Apr 10, 2:20 pm, Tommy Nordgren wrote: > On 9 apr 2008, at 03.01, corvettecra... at gmail.com wrote: > > > okay, I'm having this one problem with a text adventure game. It's > > kind of hard to explain, but I'll do my best. > > [code] > > > def prompt_kitchen(): > > global gold > > Python is not a suitable language for Text Adventure Development. Ridiculous. > You should use one of the several excellent free text adventure > languages instead. > In particular languages like TADS (The text adventure development > system) have strong > built-in support for the tricky command parsing. There are many good reasons why someone might want to use a general purpose language like Python to write a text adventure, such as so they're not stuck with a quasi hack of a language if they have to do something that doesn't fit the framework anticipated by the language designer. Carl Banks From bronger at physik.rwth-aachen.de Thu Apr 17 00:22:02 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Thu, 17 Apr 2008 06:22:02 +0200 Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <52vid5-cvl2.ln1@ozzie.tundraware.com> Message-ID: <87hce1t8k5.fsf@physik.rwth-aachen.de> Hall?chen! Tim Daneliuk writes: > Daniel Fetchinson wrote: > >> [...] >> >>> I just had one moment of exceptional clarity, during which >>> realized how I could get the GIL out of my way... It's so >>> simple, I cannot help wondering why nobody has thought of it >>> before. [...] >> >> If I were you I would keep it a secret until a Hollywood producer >> offers big bucks for the film rights. > > Who would play Guido, I wonder? Ralf M?ller. No other. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From gagsl-py2 at yahoo.com.ar Mon Apr 21 22:30:20 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 23:30:20 -0300 Subject: Problems replacing \ with \\ References: <0ca30eb2-3791-4910-9e78-f32e3b2a72cb@2g2000hsn.googlegroups.com> <6f7342eb-08f8-45d6-b50e-652bf77921d7@l42g2000hsc.googlegroups.com> Message-ID: (top posting corrected) En Mon, 21 Apr 2008 21:12:44 -0300, ockman at gmail.com escribi?: >> > def escape(string): >> > """ >> > Escape both single quotes and blackslashes >> > >>> x = r"fun\fun" >> > >>> escape(x) >> > 'fun\\\\fun' >> > """ >> > string = string.replace('\\', '\\\\') >> > return string >> >> > Failed example: >> > escape(x) >> > Expected: >> > 'fun\\fun' >> > Got: >> > 'fun\x0cun' >> >> Your doctest is in a triple-quoted string which contains the line: >> >> >>> x = r"fun\fun" >> which is the same as: >> >> >>> x = r"fun\x0cun" >> >> If you wrap a raw string in just quotes that is isn't a raw string any >> longer! > Thank you for the response. I'm not sure I understand the last > sentence, although I think I get the idea. How do I create a proper > doctest? r"This is a raw string" """ r"This is NOT a raw string" """ r""" r"This is a raw string too" """ What matters are the OUTER quotes. Now, why do you want to escape the text yourself? Assuming you have a DBAPI compatible module, use bound parameters when you execute the query: cursor.execute("insert ... values (?,?,?)", (name, address, year)) Those ? are placeholders for the actual values; no explicit quoting on the values is required (the module itself, or the database, takes care of it). Not all databases support the ? style, there are other ways. See http://www.python.org/dev/peps/pep-0249/ for the DB API specification. -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Thu Apr 3 19:39:57 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 20:39:57 -0300 Subject: displaying execution of Python code References: <1afcbf34-0a40-4d11-b12f-603f0ee8f26c@m3g2000hsc.googlegroups.com> Message-ID: En Thu, 03 Apr 2008 18:13:25 -0300, noahwatkins escribi?: > More technically, I am looking for direction on where to start looking > in the Python libraries for a functionality that will allow me to > execute arbitrary Python code from within a Python application. > Additionally, I need to be able to have the ability to get information > and perform actions (e.g. line number currently executing) as the code > executes. See the trace module and the sys.settrace hook. -- Gabriel Genellina From steveb428 at gmail.com Mon Apr 7 22:38:12 2008 From: steveb428 at gmail.com (steve) Date: Mon, 7 Apr 2008 19:38:12 -0700 (PDT) Subject: pyAmazon References: <137ba7ca-2be3-4c0a-ba85-187d8e172150@i36g2000prf.googlegroups.com> Message-ID: <76ff7677-143e-435c-a965-d7905385c847@h1g2000prh.googlegroups.com> I noticed it's happening at the line that does the parsing: dom = minidom.parse(usock), in pyaws/ecs.py I'll look into how to turn off the outputting. On Apr 7, 4:20 pm, steve wrote: > Anyone familiar with pyAmazon ( the latest for AWS 4.0 ), who knows > why the ItemSearch echo's the XML that is retrieved ? > > My statement is > products = ecs.ItemSearch("Duma Key", SearchIndex='Books') > > And the "products" list is populated okay, however before my script > ends ( executing script on DOS command line ), I get all of the XML > data scrolling on the screen. > Thanks From colas.francis at gmail.com Fri Apr 11 08:43:42 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Fri, 11 Apr 2008 05:43:42 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: <83e88c35-88ce-48c7-b0c9-4503789eca08@8g2000hse.googlegroups.com> On 11 avr, 14:14, Gerard Flanagan wrote: > On Apr 11, 2:05 pm, Gerard Flanagan wrote: > > > On Apr 11, 12:14 pm, bdsatish wrote: > > > > The built-in function round( ) will always "round up", that is 1.5 is > > > rounded to 2.0 and 2.5 is rounded to 3.0. > > > > If I want to round to the nearest even, that is > > > > my_round(1.5) = 2 # As expected > > > my_round(2.5) = 2 # Not 3, which is an odd num > > > > I'm interested in rounding numbers of the form "x.5" depending upon > > > whether x is odd or even. Any idea about how to implement it ? > In fact you can avoid the call to the builtin round: Alternatively, you can avoid the test using both divmod and round: In [55]: def myround(x): .....: d, m = divmod(x, 2) .....: return 2*d + 1 + round(m-1) .....: In [58]: assert myround(3.2) == 3 In [59]: assert myround(3.6) == 4 In [60]: assert myround(3.5) == 4 In [61]: assert myround(2.5) == 2 In [62]: assert myround(-0.5) == 0.0 In [63]: assert myround(-1.5) == -2.0 In [64]: assert myround(-1.3) == -1.0 In [65]: assert myround(-1.8) == -2 In [66]: assert myround(-2.5) == -2.0 From hasna1980_14 at hotmail.com Fri Apr 11 10:07:09 2008 From: hasna1980_14 at hotmail.com (ha bo) Date: Fri, 11 Apr 2008 14:07:09 +0000 Subject: unpack In-Reply-To: References: Message-ID: thank you i did find solution i did have just change: unpackedData = struct.unpack(unpackFormat, data) to unpackedData = struct.unpack(unpackFormat, data.decode('string_escape')) From: python-list-request at python.org Subject: Python-list Digest, Vol 55, Issue 179 To: python-list at python.org Date: Fri, 11 Apr 2008 15:50:04 +0200 Send Python-list mailing list submissions to python-list at python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/python-list or, via email, send a message with subject or body 'help' to python-list-request at python.org You can reach the person managing the list at python-list-owner at python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Python-list digest..." --Pi?ce jointe du message transmise-- From: ivan.illarionov at gmail.com To: python-list at python.org Date: Fri, 11 Apr 2008 05:58:46 -0700 Subject: Re: Rounding a number to nearest even On Apr 11, 2:14 pm, bdsatish wrote: > The built-in function round( ) will always "round up", that is 1.5 is > rounded to 2.0 and 2.5 is rounded to 3.0. > > If I want to round to the nearest even, that is > > my_round(1.5) = 2 # As expected > my_round(2.5) = 2 # Not 3, which is an odd num > > I'm interested in rounding numbers of the form "x.5" depending upon > whether x is odd or even. Any idea about how to implement it ? def even_round(x): if x % 1 == .5 and not (int(x) % 2): return float(int(x)) else: return round(x) nums = [ 3.2, 3.6, 3.5, 2.5, -.5, -1.5, -1.3, -1.8, -2.5 ] for num in nums: print num, '->', even_round(num) 3.2 -> 3.0 3.6 -> 4.0 3.5 -> 4.0 2.5 -> 2.0 -0.5 -> 0.0 -1.5 -> -2.0 -1.3 -> -1.0 -1.8 -> -2.0 -2.5 -> -2.0 --Pi?ce jointe du message transmise-- From: steve at holdenweb.com To: python-list at python.org Date: Fri, 11 Apr 2008 09:07:42 -0400 Subject: Re: (unknown) ha bo wrote: > hi i use this programme in my application django: > import struct > MASK_CCITT = 0x1021 # CRC-CCITT mask (ISO 3309, used in X25, HDLC) > MASK_CRC16 = 0xA001 # CRC16 mask (used in ARC files) > > def updcrc(crc, data, mask=MASK_CRC16): > > data_length = len(data) > unpackFormat = '%db' % data_length > unpackedData = struct.unpack(unpackFormat, data) > > for char in data: > c = ord(char) > c = c << 8 > > for j in xrange(8): > if (crc ^ c) & 0x8000: > crc = (crc << 1) ^ mask > else: > crc = crc << 1 > c = c << 1 > > return crc & 0xffff > > > and i call this function in other function in my view: > > > def encodekey(var, expires=None, user='', trusted=False): > > import random, base64 > import updcrc > key = "%02X" % len(var) + var > key += "%02X" % len(user) + user > if expires is not None: > key += expires.strftime('%Y%m%d%H%M') > else: > year = random.choice(range(2000,2100)) > month = 23 > day = random.choice(range(1,32)) > hour = random.choice(range(1,25)) > minute = random.choice(range(1,60)) > key += "%04d%02d%02d%02d%02d" % (year, month, day, hour, minute) > > if trusted: > checksum = updcrc(42, key) > else: > checksum = updcrc(0, key) > key += "%04X" % checksum > > return base64.b64encode(key) > but it give me this error: > > > unpack requires a string argument of length 31 > > > someone can help me > Next time you report an error, please include the whole traceback, not just the exception message. That information is included for a reason. You might also want to print out the value of data in your updcrc function, since that is where the problem is occurring. Finally I might point out there is little point to the struct.unpack since you don't use its result, but I am guessing this is because your algorithm is currently in transition. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ --Pi?ce jointe du message transmise-- From: victorsubervi at gmail.com CC: python-list at python.org To: gagsl-py2 at yahoo.com.ar Date: Fri, 11 Apr 2008 08:36:02 -0500 Subject: Re: String Literal to Blob Nope. Do not see it. My ugly stupid way works. I guess I will just proceed with that and write my howto accordingly. Victor On Thu, Apr 10, 2008 at 9:01 PM, Gabriel Genellina wrote: En Thu, 10 Apr 2008 14:04:43 -0300, Victor Subervi escribi?: > Well, what I did was this: > > content = col_fields[0][14].tostring() > pic = "tmp" + str(i) + ".jpg" > img = open(pic, "w") > img.write(content) > print '

' % pic > img.close() > where I am incrementing i. Ugly. Stupid. But if it is the only way to do > it > in python, and I do not want to invest the time doing it in php, which I > think would be prettier in this instance, then I guess it will do. Your > thoughts appreciated. You REALLY should read some material on how HTTP works. I'll try to sketch a few important points. First, suppose you have an HTML page (album.html) with two images in it:

This is me: and this is my cat Suppose the URL for that page is http://some.server.com/gabriel/album.html and you type that in your favorite browser. This is what happens: 1) The sees the initial "http:" and says "I'll use HTTP". Then sees "some.server.com" and opens a connection to that server on port 80. Then sees "/gabriel.album.html" and builds an HTTP GET request for it. 2) The server receives the GET request, looks for the "album.html" document, determines the right Content-Type, and returns it specifying "Content-Type: text/html" 3) The browser receives the HTML text and tries to display it. When it encounters the first tag it looks at the src attribute; it doesn't know that image; so a *NEW* HTTP request is required. This time it says "GET /images/myself.jpg" 4) The server receives the GET request, looks for a file with that name, determines that it's a jpeg image, and returns its contents along with a "Content-Type: image/jpeg". 5) The browser receives the image and is able to display it. 6) The same thing happens with the second tag, there is a third HTTP GET request for it. Note that: - The images themselves *aren't* in the HTML page, they are somewhere else. HTML is text and contains ONLY the URI for the image. - THREE DIFFERENT requests are done to show that page. Each one returns A SINGLE OBJECT of A SINGLE TYPE. The above was using static HTML with static images. If you use CGI to generate dynamic content, it's the same thing. From the browser point of view, there is no difference: it still will generate three different requests for the three pieces (one html document with two images). Your CGI script (or scripts) will receive three different requests then: when requested for HTML, return HTML; when requested for an image, return an image. They are DIFFERENT things, DIFFERENT requests, happening at DIFFERENT times, so don't mix them. I think that combining Steve's responses and mine you now have enough information to be able to solve your problems. Perhaps if you re-read the whole thread from start you'll have now a better understanding of what's happening. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list --Pi?ce jointe du message transmise-- From: huayang.xia at gmail.com To: python-list at python.org Date: Fri, 11 Apr 2008 06:37:23 -0700 Subject: Re: Convert PyIDispatch object to struct IDispatch* On Apr 11, 12:15 am, "Gabriel Genellina" wrote: > En Thu, 10 Apr 2008 18:45:04 -0300, Huayang Xia > escribi?: > > > I am trying to use ctypes to call dll functions. One of the functions > > requires argument "struct IDispatch* ". I do have a PyIDispatch object > > in python. How can I convert this "PyIDispatch object" to "struct > > IDispatch* "? > > I think a PyIDispatch object is an IDispatch* itself. > But you'll get better answers from the python-win32 list:http://mail.python.org/mailman/listinfo/python-win32 > > -- > Gabriel Genellina Thanks for the info. To call a dll function, it needs a C style IDispatch*. PyIDispatch is a python wrapped one. I found a reference from: http://svn.python.org/projects/ctypes/trunk/comtypes/comtypes/test/test_win32com_interop.py which shows how to convert C style to python style. Unfortunately i need the reversed version. I will post the question to python-win32. --Pi?ce jointe du message transmise-- From: enleverlesX.XmcX at XmclaveauX.com To: python-list at python.org Date: Fri, 11 Apr 2008 15:38:32 +0200 Subject: Python plus After IronPython, Python + iron : http://www.golfermania.com/SnakeEyes/PYTHON-PLUS-IRON.jpg ;o) Michel Claveau --Pi?ce jointe du message transmise-- From: mail at timgolden.me.uk CC: python-list at python.org Date: Fri, 11 Apr 2008 14:47:20 +0100 Subject: Re: Convert PyIDispatch object to struct IDispatch* Huayang Xia wrote: > On Apr 11, 12:15 am, "Gabriel Genellina" > wrote: >> En Thu, 10 Apr 2008 18:45:04 -0300, Huayang Xia >> escribi?: >> >>> I am trying to use ctypes to call dll functions. One of the functions >>> requires argument "struct IDispatch* ". I do have a PyIDispatch object >>> in python. How can I convert this "PyIDispatch object" to "struct >>> IDispatch* "? >> I think a PyIDispatch object is an IDispatch* itself. >> But you'll get better answers from the python-win32 list:http://mail.python.org/mailman/listinfo/python-win32 >> >> -- >> Gabriel Genellina > > Thanks for the info. > > To call a dll function, it needs a C style IDispatch*. PyIDispatch is > a python wrapped one. I found a reference from: > > http://svn.python.org/projects/ctypes/trunk/comtypes/comtypes/test/test_win32com_interop.py > > which shows how to convert C style to python style. Unfortunately i > need the reversed version. > > I will post the question to python-win32. I've had a quick look at the PyIDispatch source and I can't see any obvious way in which the underlying IDispatch is exposed. May have missed something, but it's possible that there's not way out. TJG --Pi?ce jointe du message transmise-- From: hdante at gmail.com To: python-list at python.org Date: Fri, 11 Apr 2008 06:49:23 -0700 Subject: Re: Rounding a number to nearest even On Apr 11, 9:45 am, bdsatish wrote: > On Apr 11, 5:33 pm, bdsatish wrote: > > > > > HI Gerard, > > > I think you've taken it to the best possible implementation. Thanks ! > > On Apr 11, 5:14 pm, Gerard Flanagan wrote: > > > > In fact you can avoid the call to the builtin round: > > > > ------------------------------------------------ > > > > assert myround(3.2) == 3 > > > assert myround(3.6) == 4 > > > assert myround(3.5) == 4 > > > assert myround(2.5) == 2 > > > assert myround(-0.5) == 0.0 > > > assert myround(-1.5) == -2.0 > > > assert myround(-1.3) == -1.0 > > > assert myround(-1.8) == -2 > > > assert myround(-2.5) == -2.0 > > > ------------------------------------------------ > > OK, I was too early to praise Gerard. The following version: > > def myround(x): > n = int(x) > if abs(x - n) >= 0.5 and n % 2: > return n + 1 - 2 * int(n<0) > else: > return n > > of Gerard doesn't work for 0.6 (or 0.7, etc.) It gives the answer 0 > but I would expect 1.0 ( because 0.6 doesn't end in 0.5 at all... so > usual rules of round( ) apply) Interestingly, you could solve this by using python 3. :-) round(x[, n]) Return the floating point value x rounded to n digits after the decimal point. If n is omitted, it defaults to zero. Values are rounded to the closest multiple of 10 to the power minus n; if two multiples are equally close, rounding is done toward the even choice (so, for example, both round(0.5) and round(-0.5) are 0, and round(1.5) is 2). Delegates to x.__round__(n). My turn: ;-) def yaround(x): i = int(x) f = x - i if f != 0.5 and f != -0.5: return round(x) return 2.0*round(x/2.0) a = (-10.0, -9.0, -8.0, -4.6, -4.5, -4.4, -4.0, -3.6, -3.5, -3.4, -0.6, -0.5, -0.4, 0.0, 0.4, 0.5, 0.6, 0.9, 1.0, 1.4, 1.5, 1.6, 2.0, 2.4, 2.5, 2.6, 10.0, 100.0) b = (-10.0, -9.0, -8.0, -5.0, -4.0, -4.0, -4.0, -4.0, -4.0, -3.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 3.0, 10.0, 100.0) for i in range(len(a)): assert yaround(a[i]) == b[i] _________________________________________________________________ Lancez des recherches en toute s?curit? depuis n'importe quelle page Web. T?l?chargez GRATUITEMENT Windows Live Toolbar aujourd'hui ! http://toolbar.live.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From s0suk3 at gmail.com Sat Apr 19 08:40:21 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Sat, 19 Apr 2008 05:40:21 -0700 (PDT) Subject: winreg module, need help to understand why i'm getting exception References: Message-ID: <194c4200-b388-429c-9341-28c96f27a9a7@m73g2000hsh.googlegroups.com> On Apr 19, 6:20 am, hellt wrote: > HI all, i found winreg module fromhttp://www.rutherfurd.net/python/winreg/index.html > very useful and simple, instead _winreg. > > But i have a problem with this module, in its iterable part. > > look at the following code > > key = Key(HKLM,r"SYSTEM\CurrentControlSet\Services\Tcpip\Enum") > for i in key.values: > print i.value > > and that is the exception > > Traceback (most recent call last): > File "D:\.Projects\python\temp.py", line 21, in > for i in key.values: > File "C:\Python25\Lib\site-packages\winreg.py", line 451, in next > return self.values[self.index - 1] > File "C:\Python25\Lib\site-packages\winreg.py", line 289, in > __getitem__ > name = _winreg.EnumValue(self.hkey, key)[0] > WindowsError: [Error 259] No more data is available > > so there is some problem with iterate, i think > i am still a beginner, so i cant understand why this appears, and what > should i fix. > > if anyone have some time to look closer to this module, i will > appreciate this very much. The problem is not in your code, but in the module. The EnumValue() and EnumKey() functions in the _winreg module raise WindowsError when there are no more keys or values to retrieve. So, go inside the module and modify that line to something like: # There should be a for or a while loop around here try: name = _winreg.EnumValue(key, index) except EnvironmentError: From sjoerd at acm.org Tue Apr 15 05:22:16 2008 From: sjoerd at acm.org (Sjoerd Mullender) Date: Tue, 15 Apr 2008 11:22:16 +0200 Subject: Rounding a number to nearest even In-Reply-To: <1208196168.24295.36.camel@localhost.localdomain> References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <1208196168.24295.36.camel@localhost.localdomain> Message-ID: <480473C8.6030402@acm.org> Thomas Dybdahl Ahle wrote: > On Fri, 2008-04-11 at 03:14 -0700, bdsatish wrote: >> The built-in function round( ) will always "round up", that is 1.5 is >> rounded to 2.0 and 2.5 is rounded to 3.0. >> >> If I want to round to the nearest even, that is >> >> my_round(1.5) = 2 # As expected >> my_round(2.5) = 2 # Not 3, which is an odd num >> >> I'm interested in rounding numbers of the form "x.5" depending upon >> whether x is odd or even. Any idea about how to implement it ? > > This seams to work fine: > evenRound = lambda f: round(f/2.)*2 > >>>> [(f*.5, evenRound(f*.5)) for f in xrange(0,20)] > [(0.0, 0.0),(0.5, 0.0), > (1.0, 2.0), (1.5, 2.0), (2.0, 2.0), (2.5, 2.0), > (3.0, 4.0), (3.5, 4.0), (4.0, 4.0), (4.5, 4.0), > (5.0, 6.0), (5.5, 6.0), (6.0, 6.0), (6.5, 6.0), > (7.0, 8.0), (7.5, 8.0), (8.0, 8.0), (8.5, 8.0), > (9.0, 10.0), (9.5, 10.0)] > No, this does not work: >>> [(f*.25, evenRound(f*.25)) for f in xrange(0,20)] [(0.0, 0.0), (0.25, 0.0), (0.5, 0.0), (0.75, 0.0), (1.0, 2.0), (1.25, 2.0), (1.5, 2.0), (1.75, 2.0), (2.0, 2.0), (2.25, 2.0), (2.5, 2.0), (2.75, 2.0), (3.0, 4.0), (3.25, 4.0), (3.5, 4.0), (3.75, 4.0), (4.0, 4.0), (4.25, 4.0), (4.5, 4.0), (4.75, 4.0)] x.75 should be rounded up. -- Sjoerd Mullender -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 379 bytes Desc: OpenPGP digital signature URL: From sjmachin at lexicon.net Tue Apr 29 17:14:02 2008 From: sjmachin at lexicon.net (John Machin) Date: Tue, 29 Apr 2008 21:14:02 GMT Subject: pyExcelerator number formats and borders (was Re: PyExcerlerator details) In-Reply-To: <937af823-9581-416e-85c1-57a5b0cc69de@e39g2000hsf.googlegroups.com> References: <937af823-9581-416e-85c1-57a5b0cc69de@e39g2000hsf.googlegroups.com> Message-ID: <48178F91.4010501@lexicon.net> A_H wrote: > Hi, I'm using PyExcelerator, and it's great, If you are using the latest released version, it's not, IMO. Reading the fixed-later bug reports on Sourceforge may prompt you to get the latest version from svn. Reading the unfixed bug reports on Sourceforge may prompt you to switch to xlwt (i.e. "Excel write"), a fork of pyExcelerator (fixed known and unknown bugs, improved performance, and runs under Python 2.3) -- available from https://secure.simplistix.co.uk/svn/xlwt/trunk See also http://groups.google.com/group/python-excel [to which I've CCed this reply]. > but I can't figure out a > few things: > > > (1) I set the cell style to '0.00%' but the style does not work. That isn't a style, it's a "number format". See num_formats.py in the examples directory. > > (2) I want to place a border around the cells( x1, y1, x2, y2 ) but I > can't find any example of doing that. > Well I do see ONE example, but it erases the cells if I do it after, > or when I write to the cells that erases the outline. At the moment, neither pyExcelerator nor xlwt offer a style-setting facility that's independent of the Worksheet.write method. It could well be a useful enhancement. > Surely I don't have to tediously set each cells border? Perhaps you could suggest what you think the API for setting a border on a rectangle should be. Each cell's border has to be set somehow. With a style_setting approach, there are 8 different cases (4 sides and 4 corners). With an independent border-setting approach, there would be only 4 different cases (4 sides) ... this needs looking at to see how easily the existing data model would support it. Regards, John From mail at timgolden.me.uk Tue Apr 29 09:46:59 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 29 Apr 2008 14:46:59 +0100 Subject: Windows Printing using win32print In-Reply-To: <58067CF3E0784DA3BEF22324FD03969A@hadron> References: <58067CF3E0784DA3BEF22324FD03969A@hadron> Message-ID: <481726D3.1020300@timgolden.me.uk> Jos? Roberto wrote: > Ol? KellyK! > I have read your comentary about how to print with python in windows using win32print. > I have trying to use in my problem : print a figure (.jpg, .png...etc) could you help me? Does this help? http://timgolden.me.uk/python/win32_how_do_i/print.html#rough_and_ready TJG From mal at egenix.com Sat Apr 19 08:22:09 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Sat, 19 Apr 2008 14:22:09 +0200 Subject: How to print a unicode string? In-Reply-To: <072f2f58-2434-4848-9eb7-85033069d1f9@a22g2000hsc.googlegroups.com> References: <87d4omsovf.fsf@benfinney.id.au> <4edea21e-d45c-4467-a66d-e270365eb812@l64g2000hse.googlegroups.com> <878wzasm10.fsf@benfinney.id.au> <072f2f58-2434-4848-9eb7-85033069d1f9@a22g2000hsc.googlegroups.com> Message-ID: <4809E3F1.3000606@egenix.com> On 2008-04-19 03:09, damonwischik at gmail.com wrote: > Another poster pointed me to >>> sys.stdout = codecs.getwriter("UTF-8")(sys.stdout) > and this works great. All I want now is some reassurance that this is > the most appropriate way for me to achieve what I want (e.g. least > likely to break with future versions of Python, most in keeping with > the design of Python, easiest for me to maintain, etc.). While the above works nicely for Unicode objects you write to sys.stdout, you are going to have problems with non-ASCII 8-bit strings, e.g. binary data. Python will have to convert these to Unicode before applying the UTF-8 codec and uses the default encoding for this, which is ASCII. You could wrap sys.stdout using a codecs.EncodedFile() which provides transparent recoding, but then you have problems with Unicode objects, since the recoder assumes that it has to work with strings on input (to e.g. the .write() method). There's no ideal solution - it really depends a lot on what your application does and how it uses strings and Unicode. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 19 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From mfb.chikazuku at gmail.com Fri Apr 11 18:03:47 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Sat, 12 Apr 2008 00:03:47 +0200 Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> Message-ID: <47ffee86$0$6838$2d805a3e@textnews.eweka.nl> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Rune Strand wrote: > On Apr 10, 3:54 am, Chris Stewart wrote: > ... >> >> Next, what would you say is the best framework I should look into? >> I'm curious to hear opinions on that. > > GUI-programming in Python is a neanderthal experience. What one may > love with console scripts is turned upside-down. Projects like Boa > Constructor seemed to be a remedy, but is not developed. The Iron- > Pythonistas has a very promising RAD GUI-tool in the IronPython - > Studio, http://www.codeplex.com/IronPythonStudio - but if you're non- > Iron, only sorrow is left - unless you fancy creating GUI in a text- > editor. Something I consider waste of life. Qt Designer. And creating the GUI yourself in the text editor isn't that bad, plus you have much better control over it. MFB -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFH/+BIDpaqHmOKFdQRAskNAKCDvMAK2MQCurxJ1zopibYOzhUpNgCgq7sn NxW9nWKU9nDrybd2EoxX51w= =okW6 -----END PGP SIGNATURE----- From kyosohma at gmail.com Fri Apr 25 09:01:50 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 25 Apr 2008 06:01:50 -0700 (PDT) Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> <480fa6e3$0$34491$742ec2ed@news.sonic.net> <7xzlrj14r7.fsf@ruckus.brouhaha.com> Message-ID: On Apr 24, 1:34?pm, Paul Rubin wrote: > Paul Boddie writes: > > simple Python-only modules, all you'd really need to do to prove the > > concept is to develop the client-side Windows software (eg. apt-get > > for Windows) which downloads package lists, verifies signatures, and > > works out where to put the package contents. ... > > I thought the Windows "solution" to this was Authenticode, which is a > scheme for signing executables against certificates similar to those > used on SSL web sites. ?Of course there's been at least one notorious > forgery, but typical Linux distro repositories are probably not all > that secure either. > > In the case of a pure Python program like Beautiful Soup, I certainly > think any installation needing running code should be done by > distutils included in the Python distro. I only create binaries using the bdist_wininst or bdist_msi commands for the extensions. If you think adding a code signature will make the binaries more acceptable, I'm not against it. Certificates from Comodo don't cost too much... Mike From bronger at physik.rwth-aachen.de Mon Apr 21 09:21:36 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Mon, 21 Apr 2008 15:21:36 +0200 Subject: Finally had to plonk google gorups. References: <966256b2-fe7c-4ec5-900b-90b285311881@k10g2000prm.googlegroups.com> Message-ID: <87abjne42n.fsf@physik.rwth-aachen.de> Hall?chen! NickC writes: > Hmm, according to this thread I probably shouldn't bother even > trying to contribute to c.l.p discussions that are highlighted in > the Python- URL announcements, even in cases where I think a core > developer's perspective may be of interest. As someone that only > posts here rarely, and uses Google Groups with a Gmail address to > do so, it sounds like I'll be kill-filed by a lot of people > regardless of the contents of what I post. I don't think that their fraction is significant. Be that as it may, I'm not one of those who accept high amounts of false positives in their anti-spam strategy. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From castironpi at gmail.com Mon Apr 21 14:03:05 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Mon, 21 Apr 2008 11:03:05 -0700 (PDT) Subject: yield expression programmized-formal interpretation. (interpretation of yield expression.) Message-ID: <888d1fff-5566-47db-b1a9-6c0bb994d7da@d1g2000hsg.googlegroups.com> What if I say oath= yield or other= yield ? Does yield evaluate without parenthes? (Eth.) From gagsl-py2 at yahoo.com.ar Wed Apr 16 18:19:37 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 19:19:37 -0300 Subject: Passing the output of a thread to the caller. References: Message-ID: En Wed, 16 Apr 2008 16:29:48 -0300, Marlin Rowley escribi?: > I have a thread that I've created from a main program. I started this > thread and passed it a function to execute. Within this function are > 'print' statements. While they are directly translated to the stdout, I > would love to return them back to the program itself and store them in > an object. How would I do this? Replace sys.stdout with an object that stores the lines printed. (Due to the way the print statement works, you should not inherit from file) class PrintBuffer: def __init__(self, stream): self._stream = stream self.output = [] def write(self, text): self.output.append(text) self._stream.write(text) def __getattr__(self, name): return getattr(self._stream, name) py> import sys py> sys.stdout = PrintBuffer(sys.stdout) py> print "Hello world!" Hello world! py> print 2,"*",3,"=",2*3 2 * 3 = 6 py> print >>sys.stderr, sys.stdout.output ['Hello world!', '\n', '2', ' ', '*', ' ', '3', ' ', '=', ' ', '6', '\n'] py> -- Gabriel Genellina From johng at neutralize.com Tue Apr 8 09:43:57 2008 From: johng at neutralize.com (monk.e.boy) Date: Tue, 8 Apr 2008 06:43:57 -0700 (PDT) Subject: urlparse http://site.com/../../../page.html References: <9fdd0d8b-785a-4363-be6a-75f993527754@c65g2000hsa.googlegroups.com> Message-ID: I figured it out and blogged the answer: http://teethgrinder.co.uk/blog/Normalize-URL-path-python/ monk.e.boy From nick at stinemates.org Fri Apr 18 15:13:35 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 12:13:35 -0700 Subject: python beginer In-Reply-To: <81d84eb10804160020n114c4d7ekfef7a09532813e39@mail.gmail.com> References: <81d84eb10804160020n114c4d7ekfef7a09532813e39@mail.gmail.com> Message-ID: <20080418191335.GJ19281@deviL> On Wed, Apr 16, 2008 at 12:50:51PM +0530, ashish kamble wrote: > hi, > can anyone tell me hw to start with webapplication scripting(e.g login > page..etc) > if anyone has soln for this or simple e.g that mention above please send me > > by > > > and have a nice day > -- > http://mail.python.org/mailman/listinfo/python-list Start with learning how to type. -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From gagsl-py2 at yahoo.com.ar Fri Apr 4 02:25:29 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 04 Apr 2008 03:25:29 -0300 Subject: Unicode conversion problem (codec can't decode) References: <47F5AFFC.3060902@harvee.org> Message-ID: En Fri, 04 Apr 2008 01:35:08 -0300, Eric S. Johansson escribi?: > I'm having a problem (Python 2.4) converting strings with random 8-bit > characters into an escape form which is 7-bit clean for storage in a > database. > Here's an example: > > body = meta['mini_body'].encode('unicode-escape') > > when given an 8-bit string, (in meta['mini_body']), the code fragment > above > yields the error below. > > 'ascii' codec can't decode byte 0xe1 in position 13: ordinal not in > range(128) Because unicode-escape expects an unicode object as input; if you pass a byte string, it tries to convert it to unicode using the default encoding (ascii) and fails. > I've read a lot of stuff about Unicode and Python and I'm pretty > comfortable > with how you can convert between different encoding types. What I don't > understand is how to go from a byte string with 8-bit characters to an > encoded > string where 8-bit characters are turned into two character hexadecimal > sequences. Almost there: use string-escape instead; it takes a byte string and returns another byte string in ASCII. > I really don't care about the character set used. I'm looking for a > matched set > of operations that converts the string to a seven bits a form and back > to its > original form. Ok, string-escape should work. But which database are you using that can't handle 8bit strings? -- Gabriel Genellina From tradertrade13 at gmail.com Sat Apr 19 03:36:06 2008 From: tradertrade13 at gmail.com (tradertrade13 at gmail.com) Date: Sat, 19 Apr 2008 00:36:06 -0700 (PDT) Subject: www.tradertrade.com(accept paypal).buy sell nike shox R4sneaker trainer sports shoes.nike jordan airforce one shoes nike airmax shox shoes gucci prada timberland shoes Message-ID: We (www.tradertrade.com) china wholesale and retail new Nike Sneakers,Air Jordan Sneakers,air force ones 1s,Nike Dunks SB,Bape Sta from nike outlets and factory stores,also Nike wholesale - Jordan Shoes we supply nike sneakers jordan sneaker air force 1s ... Featuring unique gift ideas for birthdays,weddings, anniversaries & holidays.Nike Air Max LTD-Nike Air Max Ltd Shoes, Nike Air Max Ltd Trainers. ... We (www.tradertrade.com) also sale and wholesale nike shoes other styles:nike air max - nike air max Nike Air Max - Nike Air Max TN Plus,TN BURBERRY,Gucci,TN L.V.. NIKE TN REQUINS CHAUSSURES,neuves hommes Nike TN requins Chaussures:Nike Air Max TN Plus men's,Nike Shox - Mens,Womens Nike Shox basketball shoes wholesale from chinaNike Shox TL NZ R4 R5 Turbo Monster Nike shoes wholesale,Puma - Puma Shoes.Nike shoes wholesale:Puma Shoes men's women's trainers at globnikesneakers dot com Puma Shoes cheap discount shoes nike wholesale and sale to nike shop and nike We sell Nike Air Max shoes,nike air max trainers for running and training- Nike Air Max 360 95 97 2003 Tn Plus Nike shoes wholesale,air max2 cb 94,air max2 cb,air ...Nike Wholesale,Nike Sneaker,jordan Sneaker, Air Force one 1s, Dunk Dunks Jordan Jordans Air Max Shox Rift...Timberland.Timberland boots,Timberland shoes,Prada wholesale,Prada sale,Prada shop,Prada store.we wholesale and sale cheap discount Timberland men's women's,We Wholesale Cheap Jordan Shoes,Michael Jordan Shoes,Nike Jordan Basketball shoes,Nike Air Jordan.Timberland-Timberland Boots.Nike shoes wholesale:Timberland Boots men's women's trainers sneakers basketball shoes running shoes.Timberland Boots cheap discount Nike Air Max 90-Nike Air Max 90 Shoes,Nike Air Max 90 trainers. at globnikesneaker dot com nike shoes Nike Air Max -> Nike Air Max 90 (Note Mens model size 41 42 43 44 45 46.Nike shoes buy, nike shoes wholesale, buy nike shoes from china nike shoes wholesale ... (www.tradertrade.com) Nike Running shoes,nike shox and nike air max Running shoes, nike shox tl nz r4 turbo monster running shoes,nike air max tn,Puma - Puma Speed Cat. Nike shoes wholesale:Puma Speed Cat men's women's trainers sneakers basketball shoes running shoes,Nike Air Max 2003-Nike Air Max 2003 Trainers,Nike Air Max 2003 Shoes. ... Nike Air Max 2003 cheap discount shoes nike wholesale and sale to nike shop and nike store.Nike Air Max - Nike Air Max 2004 trainers. Nike shoes wholesale:Nike Air Max ... Nike Air Max 2003 cheap discount shoes nike wholesale and sale to nike shop and nike factory.Nike Air Jordan 3,nike jordan 3 retro shoes,nike air jordan 3 retro sneakers,Nike air jordan 3 shoes wholesale:Nike Air Jordan 3 men's women's trainers sneakers,Nike Shox- Nike Shox TL NZ R4 R5 Turbo Monster Nike shoes wholesale.We wholesale nike shoes: Nike Shox TL,Nike Shox NZ,Nike Shox R4,Nike Shox R5,Nike Shox Nike Air Dunk- Nike Air Dunk High.Nike shoes wholesale:Nike Air Dunk High men's women's trainers sneakers basketball shoes running shoes.Nike Air Max 97, Nike Womens Air Max 97 trainers, nike mens air max 97 trainers,nike air max 97 running shoes sell cheap with discount,Nike Air Force 1-Nike ... Nike Air force 1 High cheap discount shoes nike wholesale at globnikesneakers dot com We also sale and wholesale nike shoes other styles:nike air we sell cheap Nike Air Max 95 shoes and trainers for womens,mens and for running,trainning,tennis with all black color,pink color,red, blue..with discount,Nike air jordan shoes for wholesale,We wholesale and sale nike air jordan Basketball shoes,buy quality of nike air jordan running shoes trainers sneakers for our ...Nike cheap shoes,we sale nike shoes in cheap price,buy cheap nike shoes Adidas. Adidas shoes,Adidas wholesale,Adidas shop,Adidas store,Adidas goodyear,Adidas TMAC,Adidas wholesale and sale cheap discount Adidas.Nike Dunk - Nike Air Dunk. Nike Dunk Air Dunk Low Mid High Nike shoes wholesale.We wholesale Nike Dunk Air Dunk Men's Women's shoes wholesale at cheap discount price,Nike Air Rift-Nike Rift Air Rift Nike shoes wholesale.We wholesale nike shoes;Nike Rift shoes, Nike Air Rift shoes.Puma-Puma Joggers.Nike shoes wholesale:Puma Joggers men's women's trainers... (www.tradertrade.com) Puma Joggers cheap discount shoes nike wholesale and sale to nike shop and nike Adidas - Adidas Shoes. Nike shoes wholesale: Adidas Shoes men's women's trainers ... Adidas Shoes cheap discount shoes nike wholesale and sale to nike shop and nike Shoes. Nike Air Max. Nike Air Max TN Plus. Nike Air Max 90. Nike Air Max 91. Nike Air Max 95 ... Nike Air force 1 Low. Nike Air force 1 High. Nike Air Jordan Nike Air Max Nike Air Max 360 95 97 2003 Tn Plus ... Nike Air Max 360, Nike Air Max 95, Nike Air Max 97, Nike Air Max 2003, ... (www.tradertrade.com)Nike Air Jordan 2,Nike Jordan 2 Retro Shoes Nike Air Jordan 2 shoes wholesale: Nike Air Jordan 2 men's women's trainers sneakers sketball shoes running shoes at globnikesneakers dot com .Nike Air Max - Nike Air Max 2005, Nike Air Max 2005 Trainers.... We also sale and wholesale nike shoes other styles:nike air max - nike air max ,Nike Air Jordan 11 Retro- Nike Air Jordan XI Retro. ...Nike Air Jordan 11 cheap discount shoes nike wholesale and sale to nike shop andJordan 5-Jordan V at globnikesneakers dot com Nike Air Jordan 5 V- Nike Air Jordan 5. Nike air jordan 5 shoes wholesale:Nike Air Jordan 5 men's women's trainers sneakers basketball shoes,Nike Air Force 1-Nike ... Nike Air force 1 Low cheap discount shoes nike wholesale and ... We also sale and wholesale nike shoes other styles:nike air max ...Nike Shox Turbo- Nike Shox Turbo Oh+. Nike Shox Trubo shoes wholesale: Nike Shox ... Nike Shox Turbo oh, iv,iii shoes here at cheap price from(www.tradertrade.com) our websit: http://www.tradertrade.com Msn and Email: tradertrade01 at hotmail.com Tradertrade02 at hotmail.com From marco at sferacarta.com Wed Apr 30 07:38:38 2008 From: marco at sferacarta.com (Marco Mariani) Date: Wed, 30 Apr 2008 13:38:38 +0200 Subject: computing with characters In-Reply-To: <87tzhjy4u2.fsf@physik.rwth-aachen.de> References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> <87tzhjy4u2.fsf@physik.rwth-aachen.de> Message-ID: <1TYRj.27306$o06.18162@tornado.fastwebnet.it> Torsten Bronger wrote: > However, join() is really bizarre. The list rather than the > separator should be the leading actor. No, because join must work with _any sequence_, and there is no "sequence" type to put the join method on. This semantic certainly sets python apart from many other languages. >>> '-'.join(c for c in 'hello') 'h-e-l-l-o' >>> From mysakjs at gmail.com Fri Apr 25 18:35:58 2008 From: mysakjs at gmail.com (John) Date: Fri, 25 Apr 2008 15:35:58 -0700 (PDT) Subject: newbie question Message-ID: I'm working with the HTMLParser module and have implemented HTMLParser.handle_starttag() and I see there is a separate handle_data method (which can be implemented), but I am not clear how to tie this together with a given start tag, so I only get the data I want. For example, I'd like to get a handle on the character data ( the number 1) immediately after the following start tag 1
. . . Any ideas? From gvijaysrinivas at gmail.com Wed Apr 23 14:09:53 2008 From: gvijaysrinivas at gmail.com (vijay) Date: Wed, 23 Apr 2008 11:09:53 -0700 (PDT) Subject: Calling Python code from inside php Message-ID: Hi I have a python code performing some computation for me.I have a html page which passes certain argumnets to a php page.This php page needs to pass on the value to the Python class and get the result back. How do I go about this?? Cheers Vijay From nagle at animats.com Wed Apr 23 12:47:18 2008 From: nagle at animats.com (John Nagle) Date: Wed, 23 Apr 2008 09:47:18 -0700 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. In-Reply-To: References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> Message-ID: <480f6553$0$34545$742ec2ed@news.sonic.net> Mike Driscoll wrote: > Ken, > > On Tue, Apr 22, 2008 at 1:36 PM, Kenneth McDonald > wrote: >> Sadly. >> >> Thanks, >> Ken >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > I've attached the 2.4 version. I also have some Windows binaries for > Beautiful Soup uploaded to my website: > http://www.pythonlibrary.org/python_modules.htm What on earth do you need a "Windows binary" for? "BeautifulSoup" is ONE PYTHON SOURCE FILE, "BeautifulSoup.py". It can be downloaded here: http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup.py And yes, the site is up. John Nagle From skanemupp at yahoo.se Sat Apr 5 15:24:59 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 12:24:59 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <7113d012-01bb-4426-bb40-9e2811cdb102@x41g2000hsb.googlegroups.com> <3cf4bbc8-b828-45c5-b9a8-766ce600af43@y21g2000hsf.googlegroups.com> Message-ID: <588aff92-63c4-49fa-88d5-5430e84b72a5@r9g2000prd.googlegroups.com> it works now. here is all the code: #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self, master=None): """Initialize yourself""" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): ## """Create the Entry, set it to be a bit wider""" ## self.enText = Entry(self) ## self.enText.grid(row=0, column=0, columnspan=3) """Create the Button, set the text and the command that will be called when the button is clicked""" self.btnDisplay = Button(self, text="calculate!", state=DISABLED) self.btnDisplay.grid(row=0, column=31) self.btnDisplay = Button(self,text='1',command=lambda n=1:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='2',command=lambda n=2:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='3',command=lambda n=3:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='+',command=lambda n="+":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) self.btnDisplay = Button(self,text='4',command=lambda n=4:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='5',command=lambda n=5:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='6',command=lambda n=6:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='-',command=lambda n="-":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=3, padx=5, pady=5) self.btnDisplay = Button(self,text='7',command=lambda n=7:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='8',command=lambda n=8:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='9',command=lambda n=9:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='*',command=lambda n="*":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=3, padx=5, pady=5) self.btnDisplay = Button(self,text='0',command=lambda n=0:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='C',command=lambda n="C":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='r',command=lambda n="r":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='/',command=lambda n="/":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) def Display(self, number): #print number self.lbText = Label(self, text=number) self.lbText.grid(row=0, column=0) if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() From boyee118 at gmail.com Fri Apr 18 21:50:18 2008 From: boyee118 at gmail.com (jincan) Date: Sat, 19 Apr 2008 09:50:18 +0800 Subject: ANN: pyspread 0.0.1 In-Reply-To: References: Message-ID: Traceback (most recent call last): File "pyspread.py", line 25, in import os, sys, bz2, pysgrid, itertools, numpy ImportError: No module named pysgrid Maybe any other package needed? 2008/4/18 Martin Manns : > pyspread 0.0.1 is now available at: > http://pyspread.sourceforge.net > > pyspread is a spreadsheet that accepts a pure python expression in > each cell. > > Highlights: > + No non-python syntax add-ons > + Access to python modules from cells > + 3D grid > + Numpy object array for representation of string entry into grid cell > + Numpy object array for representation of eval function array > + Cell access via slicing of numpy function array > + X, Y, and Z yield current cell location for relative reference > > Requires: Python 2.5, Numpy 1.0.4, and wxPython 2.8.7.1. > License: GPL > > Best Regards > Martin Manns > -- > mmanns gmx.net > -- > http://mail.python.org/mailman/listinfo/python-list > -- "OpenBookProject"-?????????? ??: http://groups.google.com/group/OpenBookProject ??: http://wiki.woodpecker.org.cn/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From toby at tobiah.org Tue Apr 15 16:36:11 2008 From: toby at tobiah.org (Tobiah) Date: Tue, 15 Apr 2008 13:36:11 -0700 Subject: Getting subprocess.call() output into a string? Message-ID: I am not sure how to capture the output of a command using subprocess without creating a temp file. I was trying this: import StringIO import subprocess file = StringIO.StringIO() subprocess.call("ls", stdout = file) Traceback (most recent call last): File "", line 6, in ? File "/usr/local/lib/python2.4/subprocess.py", line 413, in call return Popen(*args, **kwargs).wait() File "/usr/local/lib/python2.4/subprocess.py", line 534, in __init__ (p2cread, p2cwrite, File "/usr/local/lib/python2.4/subprocess.py", line 840, in _get_handles c2pwrite = stdout.fileno() AttributeError: StringIO instance has no attribute 'fileno' So how do I get the output into a string? I thought that the idea of StringIO was that it could be used where a file was expected. Thanks, Toby ** Posted from http://www.teranews.com ** From fr5478bey at gmail.com Sat Apr 26 11:39:44 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:39:44 -0700 (PDT) Subject: Capture NX 1.2 crack Message-ID: <0f283675-2fe3-4a16-8576-948896b04fe7@c58g2000hsc.googlegroups.com> Capture NX 1.2 crack http://cracks.00bp.com F R E E C R A C K S From fredri8758lupo at gmail.com Wed Apr 23 06:09:45 2008 From: fredri8758lupo at gmail.com (fredri8758lupo at gmail.com) Date: Wed, 23 Apr 2008 03:09:45 -0700 (PDT) Subject: falcon 4.0 patch Message-ID: falcon 4.0 patch http://cracks.12w.net F R E E C R A C K S From usenet-mail at markshroyer.com Wed Apr 16 15:50:45 2008 From: usenet-mail at markshroyer.com (Mark Shroyer) Date: Wed, 16 Apr 2008 15:50:45 -0400 Subject: What can we do about all the spam that the list is getting? References: <259ab201-9d2b-4e4e-88a7-e2fe277f0066@a23g2000hsc.googlegroups.com> Message-ID: In article , Mensanator wrote: > On Apr 16, 12:01?pm, sr... at ferg.org wrote: > > What can we do about all the spam that comp.lang.python is getting? > > Things are getting pretty bad. > > Buy Google and make them fix it. I've had pretty good luck with MT-NewsWatcher, a freeware Mac newsreader that performs Bayesian spam filtering. Thunderbird's Usenet reader also offers Bayesian filtering, which presumably works just as well for classifying Usenet spam as it does at handling email spam. So download a "real" NNTP client for whatever platform you're on and give its spam filter a shot; clearly Google is not interested in fighting spam itself. -- Mark Shroyer http://markshroyer.com/contact/ From s0suk3 at gmail.com Fri Apr 25 18:39:24 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Fri, 25 Apr 2008 15:39:24 -0700 (PDT) Subject: Receive data from socket stream Message-ID: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> I wanted to ask for standard ways to receive data from a socket stream (with socket.socket.recv()). It's simple when you know the amount of data that you're going to receive, or when you'll receive data until the remote peer closes the connection. But I'm not sure which is the best way to receive a message with undetermined length from a stream in a connection that you expect to remain open. Until now, I've been doing this little trick: data = client.recv(256) new = data while len(new) == 256: new = client.recv(256) data += new That works well in most cases. But it's obviously error-prone. What if the client sent *exactly* two hundred and fifty six bytes? It would keep waiting for data inside the loop. Is there really a better and standard way, or is this as best as it gets? Sorry if this is a little off-topic and more related to networking, but I'm using Python anyway. Thanks, Sebastian From fennelllindy8241 at gmail.com Mon Apr 28 03:20:01 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:20:01 -0700 (PDT) Subject: mapsource keygen Message-ID: mapsource keygen http://crack.cracksofts.com From pavlovevidence at gmail.com Sat Apr 26 17:12:17 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Sat, 26 Apr 2008 14:12:17 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> Message-ID: On Apr 26, 12:15 pm, n00m wrote: > fgets() from C++ iostream library??? Sheesh. That'll teach me to read carefully. (Ok, it probably won't.) Other two points still apply. Carl Banks From usenet at janc.be Wed Apr 2 13:10:11 2008 From: usenet at janc.be (Jan Claeys) Date: Wed, 02 Apr 2008 17:10:11 GMT Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: Op Tue, 01 Apr 2008 10:27:18 -0700, schreef sprad: > I'm a high school computer teacher, and I'm starting a series of > programming courses next year (disguised as "game development" classes > to capture more interest). The first year will be a gentle introduction > to programming, leading to two more years of advanced topics. > [...] > So -- would Python be a good fit for these classes? There are at least 3 books about game programming in python: -- JanC From kveretennicov at gmail.com Sat Apr 5 10:09:55 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Sat, 5 Apr 2008 17:09:55 +0300 Subject: urllib and bypass proxy In-Reply-To: References: Message-ID: <4660fe300804050709r7e0bc62at4538fc2fa40630e5@mail.gmail.com> On Thu, Apr 3, 2008 at 9:21 PM, kc wrote: > If this has value, do I submit a bug report or does > someone else? You do :) (http://bugs.python.org) -- kv From fr5478bey at gmail.com Sat Apr 26 11:43:18 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:43:18 -0700 (PDT) Subject: big city adventure crack Message-ID: big city adventure crack http://cracks.00bp.com F R E E C R A C K S From arnodel at googlemail.com Sat Apr 26 12:20:50 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sat, 26 Apr 2008 17:20:50 +0100 Subject: Setting an attribute without calling __setattr__() References: Message-ID: aahz at pythoncraft.com (Aahz) writes: > In article , > Arnaud Delobelle wrote: >>Joshua Kugler writes: >>> >>> self.me = [] >>> for v in obj: >>> self.me.append(ObjectProxy(v)) >> >>Note that is could be spelt: >> >>self.me = map(ObjectProxy, v) ^-- I meant obj! > > It could also be spelt: > > self.me = [ObjectProxy(v) for v in obj] > > which is my preferred spelling.... I was waiting patiently for this reply... And your preferred spelling is py3k-proof as well, of course. I don't write map(lambda x: x+1, L) or map(itemgetter('x'), L) but I like to use it when the first argument is a named function, e.g. map(str, list_of_ints). -- Arnaud From arnodel at googlemail.com Sun Apr 20 06:03:07 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 20 Apr 2008 03:03:07 -0700 (PDT) Subject: ???Python Memory Management S***s??? References: Message-ID: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> On Apr 20, 9:40?am, "Hank @ITGroup" wrote: > Hi, people! > > Greetings~ > These days I have been running a text processing program, written by > python, of cause. > In order to evaluate the memory operation, I used the codes below: > > """ > ?> string1 = ['abcde']*999999 ? ?# this took up an obvious memory space... > ?> del string1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# this freed the memory > successfully !! > > """ > For primary variants, the *del* thing works well. However, challenge the > following codes, using class-instances... > > """ > ?> from nltk import FreqDist ? ? # nltk stands for Natural Language Tool > Kit (this is not an advertisement ~_~) > ?> instance = FreqDist() > ?> instanceList = [instance]*99999 > ?> del instanceList ? ? ? ? ? ? # You can try: nothing is freed by this > """ > ??? How do you people control python to free the memory in python 2.5 or > python 2.4 ??? > Cheers!!! You mistyped your subject line; it should have read: "Help needed - I don't understand how Python manages memory" -- Arnaud From deets at nospam.web.de Mon Apr 7 12:46:01 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Mon, 07 Apr 2008 18:46:01 +0200 Subject: reading dictionary's (key,value) from file References: <974814d3-59f0-49ec-9b4d-9f5dd7dfaf54@q24g2000prf.googlegroups.com> Message-ID: <65v1f5F2bkfdlU1@mid.uni-berlin.de> ankitks.mital at gmail.com wrote: > Folks, > Is it possible to read hash values from txt file. > I have script which sets options. Hash table has key set to option, > and values are option values. > > Way we have it, we set options in a different file (*.txt), and we > read from that file. > Is there easy way for just reading file and setting options instead of > parsing it. > > so this is what my option files look like: > > 1opt.txt > { '-cc': '12', > '-I': r'/my/path/work/'} > > 2opt.txt > { '-I': r/my/path/work2/'} > > so my scipt how has dictionary > options = { '-cc' :'12' > '-I': r'/my/path/work/:/my/path/work2/'} > > I am trying to avoid parsing Use a well-known config-file-format such as the module ConfigParser supports. Diez From tinnews at isbd.co.uk Mon Apr 7 09:09:13 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 07 Apr 2008 13:09:13 GMT Subject: A file iteration question/problem References: <47f8eee1$0$759$bed64819@news.gradwell.net> <322f98fd-eb6e-4a05-a8c7-1e0c5329e955@w5g2000prd.googlegroups.com> Message-ID: <47fa1cf9$0$761$bed64819@news.gradwell.net> Arnaud Delobelle wrote: > On Apr 6, 4:40?pm, tinn... at isbd.co.uk wrote: > > I want to iterate through the lines of a file in a recursive function > > so I can't use:- > > > > ? ? f = open(listfile, 'r') > > ? ? for ln in f: > > > > because when the function calls itself it won't see any more lines in > > the file. ?E.g. more fully I want to do somthing like:- > > > > def recfun(f) > > ? ? while True: > > ? ? ? ? str = readline(f) > > ? ? ? ? if (str == "") > > ? ? ? ? ? ? break; > > ? ? ? ? # > > ? ? ? ? # do various tests > > ? ? ? ? # > > ? ? ? ? if : > > ? ? ? ? ? ? recfun(f) > > > > Is there no more elegant way of doing this than that rather clumsy > > "while True" followed by a test? > > > > -- > > Chris Green > > You could use an iterator over the lines of the file: > > def recfun(lines): > for line in lines: > # Do stuff > if condition: > recfun(lines) > > lines = iter(open(filename)) > recfun(lines) > Does that work though? If you iterate through the file with the "for line in lines:" in the first call of recfun(lines) you surely can't do "for line in lines:" and get any sort of sensible result in recursive calls of recfun(lines) can you? -- Chris Green From lscbtfws at gmail.com Sat Apr 26 12:08:38 2008 From: lscbtfws at gmail.com (lscbtfws at gmail.com) Date: Sat, 26 Apr 2008 09:08:38 -0700 (PDT) Subject: Power mp3 cutter crack Message-ID: <8781bb16-a126-40a5-a8a6-a4ae4bc1bc51@w1g2000prd.googlegroups.com> Power mp3 cutter crack http://cracks.00bp.com F R E E C R A C K S From gherron at islandtraining.com Wed Apr 9 11:46:56 2008 From: gherron at islandtraining.com (Gary Herron) Date: Wed, 09 Apr 2008 08:46:56 -0700 Subject: Trouble with list comprehension In-Reply-To: <4c3db5c00804090830p1b05748drf4ee5b8c3185ad9e@mail.gmail.com> References: <4c3db5c00804090830p1b05748drf4ee5b8c3185ad9e@mail.gmail.com> Message-ID: <47FCE4F0.9070409@islandtraining.com> Shane Lillie wrote: > I've got a bit of code that looks like this: > > for i in xrange(1000): > # shuffle the doors > doors = [ 'G', 'C', 'G' ] > random.shuffle(doors) > > # save the doors that have goats (by index) > goats = [ x for x in range(2) if doors[x] == 'G' ] > Using range(2) is wrong since range(2) is [0,1]. You want range(3) which gives [0,1,2]. Gary Herron > but for some reason the list comprehension is not always returning a > list with 2 elements in it (sometimes it will be just 1 element). I've > tried changing to a generator as well as using filter() and all 3 give > the same sort of results. It works if I use a loop, but I'd really > like to know what I'm doing wrong here. Everything looks like it > should be working. > > Thanks in advance for any suggestions. > From meisnernel73884 at gmail.com Wed Apr 30 06:36:00 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:36:00 -0700 (PDT) Subject: call of duty modern warfare keygen Message-ID: <9edc4534-c99d-4354-b439-042a4ee70da1@w74g2000hsh.googlegroups.com> call of duty modern warfare keygen http://crack.cracksofts.com From stefan_ml at behnel.de Mon Apr 7 01:59:33 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 07 Apr 2008 07:59:33 +0200 Subject: splitting an XML file on the basis on basis of XML tags In-Reply-To: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> Message-ID: <47F9B845.9040205@behnel.de> bijeshn at gmail.com schrieb: > Hi all, > > i have an XML file with the following structure:: > > > -----| > | > | > . | > . | --------------------> constitutes one record. > . | > . | > . | > | > | > ----| > > . > . > . -----------------------| > . | > . | > . |----------------------> there are n > records in between.... > . | > . | > . | > . ------------------------| > . > . > > -----| > | > | > . | > . | --------------------> constitutes one record. > . | > . | > . | > | > | > ----| > > > > Here is the main root tag of the XML, and ... > constitutes one record. What I would like to do is > to extract everything (xml tags and data) between nth tag and (n > +k)th tag. The extracted data is to be > written down to a separate file. What do you mean by "written down to a separate file"? Do you have a specific format in mind? In general, you can try this: >>> from xml.etree import cElementTree as ET >>> itercontext = ET.iterparse("thefile.xml", events=("start", "end") >>> event,root = itercontext.next() >>> for event,element in itercontext: ... if event == "end" and element.tag == "r2": ... print ET.tostring(element) # write record subtree as XML ... root.clear() # one record done, clean up everything http://effbot.org/zone/element-iterparse.htm You can also do things like ... print element.findtext("r3/r4") Read the ElementTree tutorial to learn how to extract your data: http://effbot.org/zone/element.htm#searching-for-subelements Stefan From jason.scheirer at gmail.com Thu Apr 10 17:40:39 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Thu, 10 Apr 2008 14:40:39 -0700 (PDT) Subject: get array element References: <820d8589-8529-46af-907a-90ebaac4a6f5@a22g2000hsc.googlegroups.com> Message-ID: <738309b2-2727-494f-a3d2-afc5b243e53a@u12g2000prd.googlegroups.com> On Apr 10, 10:22 am, "Bryan.Fodn... at gmail.com" wrote: > I have an array, and I would like to get the indice value. > > a = array([13,14,15,16]) > > I would like something like a.getindice(15) > > If I want 15 it would return 2 a.index(15) From carbanancizpo at gmail.com Fri Apr 18 16:57:27 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:57:27 -0700 (PDT) Subject: new parkinsons patch Message-ID: <74618f4b-bf9b-403b-a964-300ed0492efb@24g2000hsh.googlegroups.com> new parkinsons patch http://cracks.12w.net F R E E C R A C K S From aftab_d at hotmail.com Wed Apr 30 04:51:19 2008 From: aftab_d at hotmail.com (GoodieMan) Date: Wed, 30 Apr 2008 01:51:19 -0700 (PDT) Subject: Free YouTube Video Downloader Software Message-ID: <14df39f8-00b2-46df-8ca3-3eb3f579cb3e@l17g2000pri.googlegroups.com> Friends, Here is an absolutely free tool to download any video from YouTube. SmoothTube downloads videos from YouTube and converts them to MPEG format, which is supported by almost all media players and devices. It also post processes videos, smoothing out some of the compression artifacts often introduced by YouTube's file size requirements. http://freeware4.blogspot.com/2008/04/smoothtube-youtube-video-downloader.html From skunkwerk at gmail.com Wed Apr 9 20:54:39 2008 From: skunkwerk at gmail.com (skunkwerk) Date: Wed, 9 Apr 2008 17:54:39 -0700 (PDT) Subject: popen pipe limit References: Message-ID: <7ef9fa61-2dc4-4a5e-b37d-ccd541dc0a9c@p39g2000prm.googlegroups.com> On Apr 7, 6:17?pm, "Gabriel Genellina" wrote: > En Mon, 07 Apr 2008 20:52:54 -0300,skunkwerk ? > escribi?: > > > I'm getting errors when reading from/writing to pipes that are fairly > > large in size. ?To bypass this, I wanted to redirect output to a file > > in the subprocess.Popen function, but couldn't get it to work (even > > after setting Shell=True). ?I tried adding ">","temp.sql" after the > > password field but mysqldump gave me an error. > > > the code: > > p1 = subprocess.Popen(["mysqldump","--all-databases","--user=user","-- > > password=password"], shell=True) > > p2 = subprocess.Popen(["gzip","-9"], stdin=p1.stdout) > > output = p2.communicate()[0] > > file=open('test.sql.gz','w') > > file.write(str(output)) > > file.close() > > You need a pipe to chain subprocesses: > > import subprocess > p1 = ? > subprocess.Popen(["mysqldump","--all-databases","--user=user","--password=password"], ? > stdout=subprocess.PIPE) > ofile = open("test.sql.gz", "wb") > p2 = subprocess.Popen(["gzip","-9"], stdin=p1.stdout, stdout=ofile) > p1.wait() > p2.wait() > ofile.close() > > If you don't want the final file on disk: > > p1 = ? > subprocess.Popen(["mysqldump","--all-databases","--user=user","--password=password"], ? > stdout=subprocess.PIPE) > p2 = subprocess.Popen(["gzip","-9"], stdin=p1.stdout, ? > stdout=subprocess.PIPE) > while True: > ? ?chunk = p2.stdout.read(4192) > ? ?if not chunk: break > ? ?# do something with read chunk > > p1.wait() > p2.wait() > > -- > Gabriel Genellina thanks Gabriel - tried the first one and it worked great! From python.list at tim.thechases.com Thu Apr 10 05:54:29 2008 From: python.list at tim.thechases.com (Tim Chase) Date: Thu, 10 Apr 2008 04:54:29 -0500 Subject: How to find documentation about methods etc. for iterators In-Reply-To: <47fdceb8$0$754$bed64819@news.gradwell.net> References: <47fce941$0$755$bed64819@news.gradwell.net> <47fdceb8$0$754$bed64819@news.gradwell.net> Message-ID: <47FDE3D5.6040806@tim.thechases.com> > First question, what sort of 'thing' is the file object, I need to > know that if I'm to look up ways of using it. you can always use type(thing) to find out what type it is. > Second question, even if I know what sort of thing a file object > is, how do I find methods applicable to it and/or functions > applicable to it? If you don't have a web-connection under your finger tips, using dir(thing) help(thing) help(thing.method) will tell you most of what you need to know. There's the occasional gap, and it doesn't always work when the underlying object is out in C-land, rather than a pure Python object that's well-designed with doc-strings (personal complaint about mod_python's failure to return dir() contents last I checked). But for the most part I can just pull up a console debug-session with Python, enter enough to get an instance of the object in question, and then use the above commands. This for me is Python's chief selling point: dir()....dir() and help(). Python's two selling points are dir(), help(), and very readable code. Python's *three* selling points are dir(), help(), very readable code, and an almost fanatical devotion to the BFDL. Amongst Python's selling points are such elements as dir(), help()...I'll come in again. > It's a common problem in all sorts of computer fields, if you know the > name of what you want it's easy to find out details of how to use it > but if you don't know its name (or even if it exists) it's much more > difficult to find. All Monty Python-quoting aside, Python has solved this (and gives 3rd-party library developers the tools to solve as well) problem of discoverability using dir() and help(). -tkc From robert.kern at gmail.com Tue Apr 29 17:14:03 2008 From: robert.kern at gmail.com (Robert Kern) Date: Tue, 29 Apr 2008 16:14:03 -0500 Subject: accuracy issues with numpy arrays? In-Reply-To: <30fa02c6-908c-4c1c-a2ed-acb0a754ea6c@r66g2000hsg.googlegroups.com> References: <30fa02c6-908c-4c1c-a2ed-acb0a754ea6c@r66g2000hsg.googlegroups.com> Message-ID: You will want to ask numpy questions on the numpy mailing list: http://www.scipy.org/Mailing_Lists I need a little more time to mull on your problem to give you an actual answer, but I hope I can do that over there instead of here. -- 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 From newptcai at gmail.com Mon Apr 14 09:48:47 2008 From: newptcai at gmail.com (=?GB2312?B?0rvK18qr?=) Date: Mon, 14 Apr 2008 06:48:47 -0700 (PDT) Subject: How to make python run faster Message-ID: <0baa301a-ec8c-48ef-b30e-f9c80f72e5af@u12g2000prd.googlegroups.com> I read this article on http://kortis.to/radix/python_ext/ And I decided to try if it's true. I write the program in 4 ways: 1. Pure C 2. Python using C extension 3. Python using psycho 4. Pure Python And then I used timeit to test the speed of these 4. Unsurprisingly, the time they cost were: 4 > 3 > 2 > 1 But I did noticed that 2 is a least 3 times slower than 1, not as fast as the article stated. That's quite weird and I thought maybe it's because I am using Windows. I did the same test on Linux and I found 2 only uses 1.5 times of time of 1. But, it is still not as fast as 1. From bvidinli at gmail.com Thu Apr 24 04:13:25 2008 From: bvidinli at gmail.com (bvidinli) Date: Thu, 24 Apr 2008 11:13:25 +0300 Subject: annoying dictionary problem, non-existing keys Message-ID: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> i use dictionaries to hold some config data, such as: conf={'key1':'value1','key2':'value2'} and so on... when i try to process conf, i have to code every time like: if conf.has_key('key1'): if conf['key1']<>'': other commands.... this is very annoying. in php, i was able to code only like: if conf['key1']=='someth' in python, this fails, because, if key1 does not exists, it raises an exception. MY question: is there a way to directly get value of an array/tuple/dict item by key, as in php above, even if key may not exist, i should not check if key exist, i should only use it, if it does not exist, it may return only empty, just as in php.... i hope you understand my question... -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From fiacre.patrick at gmail.com Tue Apr 29 21:47:20 2008 From: fiacre.patrick at gmail.com (Andrew Lee) Date: Tue, 29 Apr 2008 21:47:20 -0400 Subject: MatplotLib errors In-Reply-To: References: Message-ID: <4817CFA8.5050003@gmail.com> Thomas Philips wrote: > I have just started using MatPlotLib, and use it to generate graphs > from Python simulations. It often happens that the graph is generated > and a Visual C++ Runtime Library error then pops up: Runtime Error! > Program C:\Pythin25\Pythonw.exe This application has requested the > Runtime to terminate in an unusual way. Please contact the > application's support team for more information. > > I'm running Python 2.5.2 under Windows XP. Any thoughts on what what > may be causing the problem? > > Thanks in advance > > Thomas Philips There is a matplotlib-sig mailing list: matplotlib-devel at lists.sourceforge.net They would have MUCH more info on your problem that can be offered in a general python group. HTH From ganeshborse at gmail.com Mon Apr 21 09:24:15 2008 From: ganeshborse at gmail.com (grbgooglefan) Date: Mon, 21 Apr 2008 06:24:15 -0700 (PDT) Subject: how to pass C++ object to another C++ function via Python function Message-ID: <1810b155-5598-4f17-a8e9-e4aa848db5de@i36g2000prf.googlegroups.com> I am trying to pass a C++ object to Python function. This Python function then calls another C++ function which then uses this C++ object to call methods of that object's class. I tried something like this, but it did not work, gave core dump. class myclass { public: myclass(){}; ~myclass(){}; void printmyname() { printf("I am myclass, num=%d\n",num); }; }; main(){ myclass myobj char funcbody[]=\ "def pyfunction(t167,classobj):\n\ onemorefunc(t167,\"NONAMe\")\n\ return 10\n\ \n\n"; // compile this Python function using PyRun_String & get its pointer by PyObject_GetAttrString. // Later call it as below: myclass myobj(23); PyObject *pTuple = 0; pTuple = PyTuple_New(2); PyTuple_SetItem(pTuple,0,PyString_FromString("NAME")); // for t167 parameter PyObject *inputarg = Py_BuildValue("OO&",pTuple,myobj); // for classobj parameter result = PyObject_CallObject(pPyEvalFunction,inputarg); } How can I pass this class object to Python function? Is it possible to set it in tuple using PyTuple_SetItem, because I may have varying number of arguments for my Python functions & that's why I can't use Py_BuildValue. From grflanagan at gmail.com Wed Apr 30 11:16:38 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Wed, 30 Apr 2008 08:16:38 -0700 (PDT) Subject: Issue with regular expressions References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Message-ID: On Apr 29, 3:46 pm, Julien wrote: > Hi, > > I'm fairly new in Python and I haven't used the regular expressions > enough to be able to achieve what I want. > I'd like to select terms in a string, so I can then do a search in my > database. > > query = ' " some words" with and "without quotes " ' > p = re.compile(magic_regular_expression) $ <--- the magic happens > m = p.match(query) > > I'd like m.groups() to return: > ('some words', 'with', 'and', 'without quotes') > > Is that achievable with a single regular expression, and if so, what > would it be? > > Any help would be much appreciated. > With simpleparse: ---------------------------------------------------------- from simpleparse.parser import Parser from simpleparse.common import strings from simpleparse.dispatchprocessor import DispatchProcessor, getString grammar = ''' text := (quoted / unquoted / ws)+ quoted := string unquoted := -ws+ ws := [ \t\r\n]+ ''' class MyProcessor(DispatchProcessor): def __init__(self, groups): self.groups = groups def quoted(self, val, buffer): self.groups.append(' '.join(getString(val, buffer) [1:-1].split())) def unquoted(self, val, buffer): self.groups.append(getString(val, buffer)) def ws(self, val, buffer): pass groups = [] parser = Parser(grammar, 'text') proc = MyProcessor(groups) parser.parse(TESTS[1][1][0], processor=proc) print groups ---------------------------------------------------------- G. From jjl at pobox.com Tue Apr 1 15:27:08 2008 From: jjl at pobox.com (John J. Lee) Date: Tue, 01 Apr 2008 19:27:08 GMT Subject: How to build a body like this use SOAPPy? References: <0b531c8c-9f33-48f5-9446-09a1cb2db313@e6g2000prf.googlegroups.com> Message-ID: <873aq5e5pv.fsf@pobox.com> qgg writes: [...] > [...] Heh, you may have picked an discouragingly spammish subject line. John From steve at holdenweb.com Wed Apr 9 10:54:35 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 10:54:35 -0400 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. In-Reply-To: <6641eaF2ics8jU1@mid.uni-berlin.de> References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> <6641eaF2ics8jU1@mid.uni-berlin.de> Message-ID: Diez B. Roggisch wrote: [...] > And then come back and post self-contained examples of whatever behavior you > observe, and this community will be as helpful as it is. But we can't read > sense in anything you posted so far, despite the best efforts. So unless > that changes, you won't be helped here. > Thank heavens you and Gabriel chimed in: I was beginning to think it was just me! regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From cokofreedom at gmail.com Thu Apr 10 06:38:38 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Thu, 10 Apr 2008 03:38:38 -0700 (PDT) Subject: questions about Exceptions? References: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> <71cc8c25-f5f9-4f21-a9d8-06780bf97608@f63g2000hsf.googlegroups.com> <9af81b1a-3e02-4406-b9d2-0a9b6f46566b@p39g2000prm.googlegroups.com> <0e586d5d-6799-433f-b8a4-4de5d2a87b61@h1g2000prh.googlegroups.com> Message-ID: <46a79564-4069-46af-b6ab-b38bd9152c2a@d45g2000hsc.googlegroups.com> > def Calc(): > global nbr > try: > print eval(nbr) > #a = Label(mygui, text=eval(nbr)) > #a.place(relx=0.4, rely=0.1, anchor=CENTER) > except: > print "Not computable" > nbr = "" > > def Erase(): > global nbr > nbr = "" Seems to me you could be better off passing a parameter and a return statement of None (or your parameter cleaned) for those functions, which should work. Given an input, Eval it and then return None. That way you wouldn't need the Erase... From mail at timgolden.me.uk Sat Apr 12 14:54:05 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Sat, 12 Apr 2008 19:54:05 +0100 Subject: Recommended "from __future__ import" options for Python 2.5.2? In-Reply-To: <1208025680.10309.1247529999@webmail.messagingengine.com> References: <1208025680.10309.1247529999@webmail.messagingengine.com> Message-ID: <4801054D.5040101@timgolden.me.uk> Malcolm Greene wrote: > Is there a consolidated list of "from __future__ import" options to > choose from? Well, that bit's easy: import __future__ print __future__.all_feature_names TJG From Lie.1296 at gmail.com Tue Apr 22 05:39:58 2008 From: Lie.1296 at gmail.com (Lie) Date: Tue, 22 Apr 2008 02:39:58 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: <16c84243-ce95-4022-be8a-9425b2b428ff@q1g2000prf.googlegroups.com> On Apr 21, 7:04 am, "Terry Reedy" wrote: > Off the top of my head: copy C and use {} to demarcate blocks and ';' to > end statements, so that '\n' is not needed and is just whitespace when > present. So, repeatedly scan for the next one of '{};'. try this: from __future__ import braces :) From robert.kern at gmail.com Thu Apr 3 19:17:00 2008 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 03 Apr 2008 18:17:00 -0500 Subject: Easy-to-install-and-use scientific graphics (plotting) package for Python 2.5.1 on Linux Ubuntu 7.1 In-Reply-To: <771b5531-5681-499f-9fda-77749b5db09f@s37g2000prg.googlegroups.com> References: <771b5531-5681-499f-9fda-77749b5db09f@s37g2000prg.googlegroups.com> Message-ID: Dr. Colombes wrote: > Is there an easy scientific graphics (plotting) package for Python > 2.5.1 running on Ubuntu Linux 7.1 ("Gutsy Gibbon")? > > A few years ago I used PyLab (a MatLab-like plotting module for > Python) on a Windows machine, but I don't know if there is a similar > easy-to-install-and-use Python 2.5.1-compatible graphics package for > Ubuntu Linux 7.1? matplotlib (which you misname PyLab) works with Python 2.5.1 on Ubuntu, too. $ sudo apt-get install python-matplotlib -- 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 From bskaplan14 at yahoo.com Tue Apr 15 15:06:32 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Tue, 15 Apr 2008 12:06:32 -0700 (PDT) Subject: Java or C++? Message-ID: <514944.97660.qm@web39205.mail.mud.yahoo.com> The fact that C# is a .NET language is also a major weakness, since you can only use it on Windows. ----- Original Message ---- From: Michael Torrie To: python-list at python.org Sent: Tuesday, April 15, 2008 1:19:31 PM Subject: Re: Java or C++? egbert wrote: > What is the role or position of C# in this context ? > If I remember well, some people have said that C# is an improved > C++ or Java. > e I think C# is in a great position, and might be recommended. C# has the added advantage of being able to very easily work with IronPython. Thus if you want to develop with .NET you can easily wield the beauty of python with C# for speed or library routines. Of course Jython does the same for Java, although it's way behind in development these days. Slick python integration is one area where C# and Java would beat out C++. Sure there's Boost::Python, but the learning curve is kind of steep. Installation, even, is difficult. Python's C API is very simple and C-like, so if one chooses to use primarily a C/Python combination (typically what I do these days), it works well, but not quite as easy as IronPython and C#. Diving into the debate, I personally think all programmers, and especially computer science people, should be proficient in C. You should be able to write thousands of lines of C code, use dynamic memory allocation, data structures, etc, and have very few resource leaks if you choose your tools wisely (glib for C ought to be standard!). This is to give you a background and low-level understanding. However you're not likely to program in C professionally unless you are into systems programming, or are affiliated with core, low-level things like library development, or embedded systems. As for C++ and Java, I've found that good C++ programmers can *easily* move to Java when they want/need to. The reverse is *not typically true*. Java lends itself to too many bad habits that kill would-be C++ programmers, particular in regards to resource management and things like destruction after scope. I think that is a critical thing that people forget sometimes. Similarly people proficient in Unix and Linux computers, both use and development on, can much more easily move to Windows than the other way around. A good programmer should be able to pick up new languages and paradigms fairly easily, and become fluent in just a few weeks. For me it's typically one week, although learning frameworks and toolkits is more difficult (Java frameworks). A good exercise might be to pick up one new language per year and do something major with it (say 4000-10000 loc). Choose a new genre like web programming to explore. Whatever. Next time a little pet project comes up, try a new language or a new toolkit. Try some shell-scripting in scsh using scheme. -- http://mail.python.org/mailman/listinfo/python-list between 0000-00-00 and 9999-99-99 ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From kyosohma at gmail.com Sat Apr 26 23:39:19 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Sat, 26 Apr 2008 20:39:19 -0700 (PDT) Subject: What to download when updating? References: Message-ID: On Apr 26, 4:57?pm, Gilles Ganault wrote: > Hello > > ? ? ? ? Out of curiosity, if I recompile a Python (wxPython) app with > py2exe, can I have customers just download the latest .exe, or are > there dependencies that require downloading the whole thing again? > > FWIW, here's the list of files that were created after running py2exe: > > myprog.exe > bz2.pyd > library.zip > MSVCR71.dll > python25.dll > unicodedata.pyd > w9xpopen.exe > wxbase28uh_net_vc.dll > wxbase28uh_vc.dll > wxmsw28uh_adv_vc.dll > wxmsw28uh_core_vc.dll > wxmsw28uh_html_vc.dll > _controls_.pyd > _core_.pyd > _gdi_.pyd > _misc_.pyd > _windows_.pyd > > Thank you. Gilles, I think you can get away with just the executable. However, there are some options in py2exe that allow you to output one file. I use GUI2Exe, a GUI to py2exe that makes it quite a bit easier to wrap these things: http://xoomer.alice.it/infinity77/main/GUI2Exe.html You just set Optimize and Compressed to 2 and Bundle Files to 1. I also use Inno Setup if I need an installer. Hope that helps! Mike From jon+usenet at unequivocal.co.uk Sat Apr 26 23:27:12 2008 From: jon+usenet at unequivocal.co.uk (Jon Ribbens) Date: Sat, 26 Apr 2008 22:27:12 -0500 Subject: Why can't timedeltas be divided? References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> Message-ID: On 2008-04-27, Martin v. L??wis wrote: >> sorry for bringing up such an old thread, but this seems important to me >> -- up to now, there are thousands [1] of python programs that use >> hardcoded time calculations. > > Would you like to work on a patch? Last time I brought up this sort of thing, it seemed fairly unanimous that the shortcomings of the datetime module were 'deliberate' and would not be fixed, patch or no patch. From fredrik at pythonware.com Sat Apr 5 11:42:00 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 17:42:00 +0200 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> Message-ID: Fredrik Lundh wrote: > and for the record, Python doesn't look for PYD files on any of the Unix > boxes I have convenient access to right now. what Ubuntu version are > you using, what Python version do you have, and what does > > $ python -c "import imp; print imp.get_suffixes()" > > print on your machine? for reference, here's what I get on Ubuntu 7.10, with the standard Python interpreter (2.5.1): $ python -c "import imp; print imp.get_suffixes()" [('.so', 'rb', 3), ('module.so', 'rb', 3), ('.py', 'U', 1), ('.pyc', 'rb', 2)] any Ubuntu gurus here that can sort this one out? From bearophileHUGS at lycos.com Mon Apr 21 05:44:53 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Mon, 21 Apr 2008 02:44:53 -0700 (PDT) Subject: sys.maxint in Python 3 Message-ID: In some algorithms a sentinel value may be useful, so for Python 3.x sys.maxint may be replaced by an improvement of the following infinite and neginfinite singleton objects: class Infinite(object): def __repr__(self): return "infinite" def __cmp__(self, other): if other is infinite: return 0 if other is neginfinite: return 1 other + 1 # type control return 1 infinite = Infinite() class NegInfinite(object): def __repr__(self): return "neginfinite" def __cmp__(self, other): if other is neginfinite: return 0 if other is infinite: return -1 other + 1 # type control return -1 neginfinite = NegInfinite() Bye, bearophile From steve at holdenweb.com Wed Apr 23 10:31:23 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 10:31:23 -0400 Subject: MESSAGE RESPONSE In-Reply-To: <27CC3060AF71DA40A5DC85F7D5B70F38033A4F2D@AWMAIL04.belcan.com> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> <27CC3060AF71DA40A5DC85F7D5B70F38033A4F2D@AWMAIL04.belcan.com> Message-ID: <480F483B.9050507@holdenweb.com> Blubaugh, David A. wrote: > Is there a way to block these messages. I do not want to be caught > with filth such as this material. I could lose my job with Belcan with > evil messages such as these messages. > > > David Blubaugh > In future please ensure you do not quote the offending URLs when sending out such messages. It's quite bad enough that the things appeared on the list once without you doing the originator the favor of repeating them. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From frikker at gmail.com Sun Apr 27 22:31:42 2008 From: frikker at gmail.com (blaine) Date: Sun, 27 Apr 2008 19:31:42 -0700 (PDT) Subject: Regular Expression - Matching Multiples of 3 Characters exactly. References: Message-ID: <5193150b-ef86-4113-8f8d-be7d99a7386f@i76g2000hsf.googlegroups.com> On Apr 27, 10:24 pm, castiro... at gmail.com wrote: > On Apr 27, 8:31 pm, blaine wrote: > > > > > Hey everyone, > > For the regular expression gurus... > > > I'm trying to write a string matching algorithm for genomic > > sequences. I'm pulling out Genes from a large genomic pattern, with > > certain start and stop codons on either side. This is simple > > enough... for example: > > > start = AUG stop=AGG > > BBBBBBAUGWWWWWWAGGBBBBBB > > > So I obviously want to pull out AUGWWWWWWAGG (and all other matches). > > This works great with my current regular expression. > > > The problem, however, is that codons come in sets of 3 bases. So > > there are actually three different 'frames' I could be using. For > > example: > > ABCDEFGHIJ > > I could have ABC DEF GHI or BCD EFG HIJ or CDE FGH IJx.... etc. > > > So finally, my question. How can I represent this in a regular > > expression? :) This is what I'd like to do: > > (Find all groups of any three characters) (Find a start codon) (find > > any other codons) (Find an end codon) > > > Is this possible? It seems that I'd want to do something like this: (\w > > \w\w)+(AUG)(\s)(AGG)(\s)* - where \w\w\w matches EXACTLY all sets of > > three non-whitespace characters, followed by AUG \s AGG, and then > > anything else. I hope I am making sense. Obviously, however, this > > will make sure that ANY set of three characters exist before a start > > codon. Is there a way to match exactly, to say something like 'Find > > all sets of three, then AUG and AGG, etc.'. This way, I could scan > > for genes, remove the first letter, scan for more genes, remove the > > first letter again, and scan for more genes. This would > > hypothetically yield different genes, since the frame would be > > shifted. > > > This might be a lot of information... I appreciate any insight. Thank > > you! > > Blaine > > Here's one idea (untested): > > s= { } > for x in range( len( genes )- 3 ): > s[ x ]= genes[ x: x+ 3 ] > > You might like Python's 'string slicing' feature. True - I could try something like that. In fact I have a 'codon' function that does exactly that. The problem is that I then have to go back through and loop over the list. I'm trying to use Regular Expressions so that my processing is quicker. Complexity is key since this genomic string is pretty large. Thanks for the suggestion though! From bruno.42.desthuilliers at websiteburo.invalid Mon Apr 21 04:26:49 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Mon, 21 Apr 2008 10:26:49 +0200 Subject: question about the mainloop In-Reply-To: <52de38c4-3d1e-4be0-9b58-5d60317f1ef7@b1g2000hsg.googlegroups.com> References: <52de38c4-3d1e-4be0-9b58-5d60317f1ef7@b1g2000hsg.googlegroups.com> Message-ID: <480c4fc9$0$19406$426a74cc@news.free.fr> globalrev a ?crit : > in C?? java etc there is usually: > > procedure 1 > procedure 2 > procedure 3 > > main { > procedure 1 > procedure 2 > procedure 3 > } > > i dont get the mainloop() in python. The 'main' function (resp. method) in C and Java has nothing to do with a "mainloop" - it's just the program entry point, IOW the function that will get called when the program is executed. Python has no such thing, since all code at the top-level is executed when the script is passed to the python runtime. The notion of "mainloop" (or event loop) is specific to event-driven programs, which, once everything is set up, enter in a loop, wait for events to come, and dispatch them to appropriate handlers. And FWIW, there's no loop in your above example - the main() function will call procedures 1, 2 and 3 sequentially then exit. > i mean i have written some > programs, for example a calculator using tkinterGUI. > > if i have some functions i wanna call to run the program You don't "call some functions" to "run the program" - you pass your script to the python runtime, and all top-level code will be executed sequentially. From snake_314 at hotmail.com Sat Apr 5 21:56:24 2008 From: snake_314 at hotmail.com (snake snake) Date: Sun, 6 Apr 2008 04:56:24 +0300 Subject: header intact. Or visitthis web page Message-ID: _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From deets at nospam.web.de Mon Apr 28 17:55:15 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Mon, 28 Apr 2008 23:55:15 +0200 Subject: cytpes **int In-Reply-To: <56674130-c04e-403e-8364-92cbd158b2f0@b9g2000prh.googlegroups.com> References: <56674130-c04e-403e-8364-92cbd158b2f0@b9g2000prh.googlegroups.com> Message-ID: <67mveuF2pauigU1@mid.uni-berlin.de> VernM schrieb: > I am using ctypes to wrap a set of functions in a DLL. It has been > going very well, and I am very impressed with ctypes. I want to call a > c function with a signature of: void func(int **cube), where the array > if ints in cube is modified by func. I want to setup cube with int > values, and access them after the call to func. I unerstand how to > setup the ctypes array, but how do I pass **cube to the function, and > how do I access the results? it should be simple. use something like (untestet): b = POINTER(c_int)() func(byref(b)) Or a = c_int() b = pointer(a) func(byref(b) Or b = POINTER(c_int)() func(pointer(b)) Diez From deets at nospam.web.de Wed Apr 2 12:35:43 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 02 Apr 2008 18:35:43 +0200 Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> Message-ID: <65hqvrF2f2susU1@mid.uni-berlin.de> > I'm not quite sure I understood your question, sorry. And you won't. He's one of the resident trolls... Better killfile him ASAP :) Diez From altami0762 at gmail.com Thu Apr 17 15:52:48 2008 From: altami0762 at gmail.com (altami0762 at gmail.com) Date: Thu, 17 Apr 2008 12:52:48 -0700 (PDT) Subject: jazz scale suggester system 3.0 crack Message-ID: jazz scale suggester system 3.0 crack http://cracks.12w.net F R E E C R A C K S From michael at stroeder.com Thu Apr 24 05:51:08 2008 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Thu, 24 Apr 2008 11:51:08 +0200 Subject: python-ldap: searching without specifying an OU? In-Reply-To: <0bbac44a-5d11-4e27-829d-ad2b2de62210@x35g2000hsb.googlegroups.com> References: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> <58546d42-bc80-4f9d-be90-e184c312e2d1@k37g2000hsf.googlegroups.com> <0ke3e5-ccc.ln1@nb2.stroeder.com> <8ef38281-a6fe-4501-b711-a24cd9f35a24@t54g2000hsg.googlegroups.com> <0bbac44a-5d11-4e27-829d-ad2b2de62210@x35g2000hsb.googlegroups.com> Message-ID: hotani wrote: > http://peeved.org/blog/2007/11/20/ BTW: This blog entry claims that LDAP_SERVER_DOMAIN_SCOPE_OID control cannot be used with python-ldap. But support for such simple LDAPv3 extended controls was added to python-ldap way back in 2005. Actually it's easy (relevant code excerpt): ---------------------------------------------------------------- import ldap from ldap.controls import BooleanControl LDAP_SERVER_DOMAIN_SCOPE_OID='1.2.840.113556.1.4.1339' [..] l = ldap.initialize(ldap_uri,trace_level=trace_level) # Switch off chasing referrals within OpenLDAP's libldap l.set_option(ldap.OPT_REFERRALS, 0) # Simple bind with user's DN and password l.simple_bind_s(dn,password) res = l.search_ext_s( 'DC=dom,DC=example,DC=com', ldap.SCOPE_ONELEVEL, '(objectClass=subentry)', ['*'], serverctrls = [ BooleanControl( LDAP_SERVER_DOMAIN_SCOPE_OID, criticality=0,controlValue=1 ) ] ) ---------------------------------------------------------------- Strange enough it has no effect. And setting criticality=1 raises an error indicating that this control is not supported although this control is explicitly mentioned in attribute 'supportedControl' of the server's rootDSE: ldap.UNAVAILABLE_CRITICAL_EXTENSION: {'info': '00000057: LdapErr: DSID-0C09068F, comment: Error processing control, data 0, vece', 'desc': 'Critical extension is unavailable'} Might depend on the domain functional level AD is running with... Ciao, Michael. From steve at holdenweb.com Wed Apr 23 00:57:25 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 00:57:25 -0400 Subject: Python Success stories In-Reply-To: <87fxtdyydy.fsf@benfinney.id.au> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <87fxtdyydy.fsf@benfinney.id.au> Message-ID: Ben Finney wrote: > Steve Holden writes: > >> Challenge him to a dual with dead kippers at twenty paces. > > Please, have some dignity! > > Challenge him to a duel with live kippers. Live, *rabid* kippers. With > frickin' laser beams on their heads. > I like your style. Though considering what it takes to kipper a herring, I'd be very surprised if there *was* any such thing as a live kipper. With or without laser beam. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From kyosohma at gmail.com Fri Apr 18 14:34:02 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 18 Apr 2008 11:34:02 -0700 (PDT) Subject: Python 2.5 adoption References: Message-ID: <0e05ad56-9521-4ac6-8849-edc44e4d6c9a@24g2000hsh.googlegroups.com> On Apr 18, 1:08 pm, Joseph Turian wrote: > How widely adopted is python 2.5? > > We are doing some development, and have a choice to make: > a) Use all the 2.5 features we want. > b) Maintain backwards compatability with 2.4. > > So I guess the question is, does anyone have a sense of what percent > of python users don't have 2.5? > > Thanks, > Joseph I think it depends more on what you want to do. If you're distributing the software, you can just "freeze" it and make binaries and then it doesn't matter. Or if you use Python at your business, you can do what we do at my workplace: Put Python on the network and run all the scripts from there. Currently, we have 2.4 on our network, but I think we can upgrade it to 2.5 without breaking anything. I develop in 2.5 and just put the finished products on our network and they usually "just work". But I have yet to find good use cases for some of the cool whizz-bang extras of 2.5, so I haven't pushed for the network upgrade. I hope to figure out when, where and how to use generators and decorators at some point, but I just haven't gotten that far a long yet, I guess. Mike From george.sakkis at gmail.com Mon Apr 21 19:10:05 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Mon, 21 Apr 2008 16:10:05 -0700 (PDT) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> Message-ID: <85c14b14-9302-41bb-9270-b7cdd65098b0@c65g2000hsa.googlegroups.com> On Apr 21, 5:30 pm, Ivan Illarionov wrote: > On 22 ???, 01:01, Peter Otten <__pete... at web.de> wrote: > > > Ivan Illarionov wrote: > > > And even faster: > > > a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, > > > len(s), 3)))) > > > if sys.byteorder == 'little': > > > a.byteswap() > > > > I think it's a fastest possible implementation in pure python > > > Clever, but note that it doesn't work correctly for negative numbers. For > > those you'd have to prepend "\xff" instead of "\0". > > > Peter > > Thanks for correction. > > Another step is needed: > > a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, > len(s), 3)))) > if sys.byteorder == 'little': > a.byteswap() > result = [n if n < 0x800000 else n - 0x1000000 for n in a] > > And it's still pretty fast :) Indeed, the array idea is paying off for largeish inputs. On my box (Python 2.5, WinXP, 2GHz Intel Core Duo), the cutoff point where from3Bytes_array becomes faster than from3Bytes_struct is close to 150 numbers (=450 bytes). The struct solution though is now almost twice as fast with Psyco enabled, while the array doesn't benefit from it. Here are some numbers from a sample run: *** Without Psyco *** size=1 from3Bytes_ord: 0.033493 from3Bytes_struct: 0.018420 from3Bytes_array: 0.089735 size=10 from3Bytes_ord: 0.140470 from3Bytes_struct: 0.082326 from3Bytes_array: 0.142459 size=100 from3Bytes_ord: 1.180831 from3Bytes_struct: 0.664799 from3Bytes_array: 0.690315 size=1000 from3Bytes_ord: 11.551990 from3Bytes_struct: 6.390999 from3Bytes_array: 5.781636 *** With Psyco *** size=1 from3Bytes_ord: 0.039287 from3Bytes_struct: 0.009453 from3Bytes_array: 0.098512 size=10 from3Bytes_ord: 0.174362 from3Bytes_struct: 0.045785 from3Bytes_array: 0.162171 size=100 from3Bytes_ord: 1.437203 from3Bytes_struct: 0.355930 from3Bytes_array: 0.800527 size=1000 from3Bytes_ord: 14.248668 from3Bytes_struct: 3.331309 from3Bytes_array: 6.946709 And here's the benchmark script: import struct from array import array def from3Bytes_ord(s): return [n if n<0x800000 else n-0x1000000 for n in ((ord(s[i])<<16) | (ord(s[i+1])<<8) | ord(s[i+2]) for i in xrange(0, len(s), 3))] unpack_i32be = struct.Struct('>l').unpack def from3Bytes_struct(s): return [unpack_i32be(s[i:i+3] + '\0')[0]>>8 for i in xrange(0,len(s),3)] def from3Bytes_array(s): a = array('l', ''.join('\0' + s[i:i+3] for i in xrange(0,len(s), 3))) a.byteswap() return [n if n<0x800000 else n-0x1000000 for n in a] def benchmark(): from timeit import Timer for n in 1,10,100,1000: print ' size=%d' % n # cycle between positive and negative buf = ''.join(struct.pack('>i', 1234567*(-1)**(i%2))[1:] for i in xrange(n)) for func in 'from3Bytes_ord', 'from3Bytes_struct', 'from3Bytes_array': print ' %s: %f' % (func, Timer('%s(buf)' % func , 'from __main__ import %s; buf=%r' % (func,buf) ).timeit(10000)) if __name__ == '__main__': s = ''.join(struct.pack('>i',v)[1:] for v in [0,1,-2,500,-500,7777,-7777,-94496,98765, -98765,8388607,-8388607,-8388608,1234567]) assert from3Bytes_ord(s) == from3Bytes_struct(s) == from3Bytes_array(s) print '*** Without Psyco ***' benchmark() import psyco; psyco.full() print '*** With Psyco ***' benchmark() George From dennis.benzinger at gmx.net Thu Apr 10 10:56:57 2008 From: dennis.benzinger at gmx.net (Dennis.Benzinger@gmx.net) Date: Thu, 10 Apr 2008 07:56:57 -0700 (PDT) Subject: tkinter, overwrite Label-text? References: Message-ID: On Apr 10, 4:37 pm, skanem... at yahoo.se wrote: > [...] > i know how to do this already. the problem is i want the text to stay > in the windowa nd not start overwriting "Answer:". > i have solved this by using an Entry for the answer as well but id > prefer using a Label. > [...] You can set the width option of the Label. For example: b = Label(mygui, text=eval(expr), width=20) Then the Label will always be 20 characters wide no matter how long the answer is. You can read more about the options for Tk widgets in . Dennis Benzinger From lbonafide at yahoo.com Tue Apr 1 23:59:44 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Tue, 1 Apr 2008 20:59:44 -0700 (PDT) Subject: the scaling of pics in pygame References: <49d8b8ae-08e3-4e86-9ced-2804b6dec4e5@b5g2000pri.googlegroups.com> Message-ID: <3de70275-c4d6-46f8-9700-17503a606c84@d62g2000hsf.googlegroups.com> On Apr 1, 9:44 pm, Jimmy wrote: > Hi, everyone > > I am using Pygame to write a small program. I tried to load a .jpg > picture into > the screen, however, the size of the pic doesn't fit into the window > properly. Can > anyone tell me how to scale the picture into the window? You might get a quicker answer at pygame.org - check the mailing list and/or docs. From nagle at animats.com Tue Apr 1 13:48:52 2008 From: nagle at animats.com (John Nagle) Date: Tue, 01 Apr 2008 10:48:52 -0700 Subject: Homework help In-Reply-To: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> Message-ID: <47f2730b$0$36409$742ec2ed@news.sonic.net> bobby.connor at gmail.com wrote: > Hey guys > I haev this homework assignment due today > I don't necessarily want the answers, but need help on how to approach > it/the steps i need to solve the problems > Thanks > > # (2 Points) Write a python function howMany(item,lst) which accepts > an item and a lst of items and returns the number of times item occurs > in lst. For example, howMany(3,[1,2,3,2,3]) should return 2. def howmany(item, lst) : return(len(filter(lambda x: x==item, lst))) > > # (2 Points) Write a python function upTo(n) which accepts a non- > negative number n and returns a list of numbers from 0 to n. For > example, upTo(3) should return the list [0, 1, 2, 3]. def howmany(n) : return(range(n+1)) That should get you started. John Nagle From s0suk3 at gmail.com Thu Apr 17 11:40:41 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 08:40:41 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> Message-ID: > Yuck! No way!! If you *want* to make your code that hard to read, I'm > sure you can find lots of ways to do so, even in Python, but don't > expect Python to change to help you toward such a dubious goal. > Well, my actual code doesn't look like that. Trust me, I like clean code. > Seriously, examine your motivations for wanting such a syntax. Does it > make the code more readable? (Absolutely not.) Does it make it more > maintainable. (Certainly not -- consider it you needed to change > CONSTANT2 to a different value some time in the future.) Yes, it makes it more readable. And yes, it does make it (a lot) more maintainable. Mainly because I don't have those four variables, I have about thirty. And I think I won't need to one or two of them, but maybe all of them at once. From Simon.Strobl at gmail.com Wed Apr 23 08:33:15 2008 From: Simon.Strobl at gmail.com (Simon Strobl) Date: Wed, 23 Apr 2008 05:33:15 -0700 (PDT) Subject: problem with dictionaries References: Message-ID: <2d4ce8cf-f5d6-4fed-8275-693a22cb6a0e@k37g2000hsf.googlegroups.com> > You musts have missed the memo. The rules of the universe > changed at 0834 UST yesterday, and all functioning Python programs > stopped working. As always, the rules of the universe have not changed. (Or, at least, I do hope so.) It seems that the cause of my problem was my switching too fast between too many and too seldom saved emacs buffers. Thanks to all for your hints. Simon From collinw at gmail.com Fri Apr 25 19:52:23 2008 From: collinw at gmail.com (Collin Winter) Date: Fri, 25 Apr 2008 16:52:23 -0700 Subject: [Python-Dev] annoying dictionary problem, non-existing keys In-Reply-To: <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> Message-ID: <43aa6ff70804251652r4f0deb39he5b2e1c71e8aabee@mail.gmail.com> 2008/4/24 bvidinli : > I posted to so many lists because, > > this issue is related to all lists, > this is an idea for python, > this is related to development of python... > > why are you so much defensive ? > > i think ideas all important for development of python, software.... > i am sory anyway.... hope will be helpful. Please consult the documentation first: http://docs.python.org/lib/typesmapping.html . You're looking for the get() method. This attribute of PHP is hardly considered a feature, and is not something Python wishes to emulate. Collin Winter > 2008/4/24, Terry Reedy : > > > > Python-dev is for discussion of development of future Python. Use > > python-list / comp.lang.python / gmane.comp.python.general for usage > > questions. > > > > > > > > _______________________________________________ > > Python-Dev mailing list > > Python-Dev at python.org > > http://mail.python.org/mailman/listinfo/python-dev > > Unsubscribe: http://mail.python.org/mailman/options/python-dev/bvidinli%40gmail.com > > > > > > -- > ?.Bahattin Vidinli > Elk-Elektronik M?h. > ------------------- > iletisim bilgileri (Tercih sirasina gore): > skype: bvidinli (sesli gorusme icin, www.skype.com) > msn: bvidinli at iyibirisi.com > yahoo: bvidinli > > +90.532.7990607 > +90.505.5667711 > _______________________________________________ > > > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: http://mail.python.org/mailman/options/python-dev/collinw%40gmail.com > From steve at holdenweb.com Tue Apr 8 20:57:47 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 20:57:47 -0400 Subject: new user needs help! In-Reply-To: <10644597.63801207701350348.JavaMail.nabble@isper.nabble.com> References: <10644597.63801207701350348.JavaMail.nabble@isper.nabble.com> Message-ID: <47FC148B.1010605@holdenweb.com> drjekil77 at gmail.com wrote: > thanks! Please keep all replies on the list: somebody else may also wish to help (and they will also pick up mistakes I make ;-) > I am working with a text filelooks like this: > #NAME AA TOPO ACCESS DSSP STRIDE Z-COORD > 1lghB A i 79.8 H H -24.58 > 1lghB V i 79.6 H H -22.06 > 1lghB H i 71.9 H H -19.94 > i need to compare those lines which has a value between 10 to 22 and presents in the following way > True/false A C D E F G H I K L M N P Q R S T V X Y W(here alfabets represents amino acids) > 1 1:1 2:0 3:0 and so on for rest of the amino acids. > > > I have given 2 examples below to make it clear a bit: > > ex.1: > #NAME AA TOPO ACCESS DSSP STRIDE Z-COORD > 1lghB A i 79.8 H H -24.58 #for that line amino acid is A and z-COORED value is more than 22,so output should be look like > > True/false A C D E F G H I K L M N P Q R S T V X Y W(here alfabets represents amino acids) > -1 1:1 2:0 3:o 4:0 so on upto 20 bcz there r 20 amino acids.and A presents in the 1st position.every line represents one amino acid with value,so output will show in which position is it(here A is in 1st position thats why its value 1:1 and all the other position o like 2:0,3:0,4:0 and if its Z-COORED value between 10-22 then true false value 1,otherwise -1. > > another ex: > > 1lghB H i 71.9 H H -19.94 # for that line amino acid is H and it has value between 10-22.so output should looks like: > > True/false A C D E F G H I K L M N P Q R S T V X Y W(here alfabets represents 20 amino acids) > > 1 1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0,every position is zero up to 20 bcz H presents in the 7th position.so it will be 1. > > so for every line, output will in 21 coulum,1st coulum for true false value,others r for 20 amino acids.true false value will be either 1 or -1,and within other 20 coulum one value will be n:1,others will be n:0.n=0,1,2,3..20. > its a bit tricky. > thank u so much for ur help > waiting for ur opinion. > So, you are using -1 for true and 1 for false? Can there be multiple amino acids on each line? Would this be a possible input: 1lghB AHG i 87.3 Q Q -23.45 If so, would this be the required output? -1 1:1 2:0 3:0 4:0 5:0 6:0 7:1 8:1 9:0 10:0 ... 19:0 20:0 There is no point trying to write more code until we understand the requirements properly. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From glasper9 at yahoo.org.au Sat Apr 12 17:06:30 2008 From: glasper9 at yahoo.org.au (Jason Stokes) Date: Sun, 13 Apr 2008 07:06:30 +1000 Subject: basic python question about for loop References: Message-ID: <1208034394.286218@chilli.pcug.org.au> "jmDesktop" wrote in message news:a6017454-6ac8-44e1-bc56-49709720a666 at e39g2000hsf.googlegroups.com... > So what is n and x in the first iteration? Sorry. I'm trying. Remember how Python's range operator works. range(n, x) constructs a list that consists of all elements starting with n and up to, but /not including/, x. For example, range(3, 7) constructs the list [3, 4, 5, 6]. So what happens if you try to construct the list range(2, 2)? In this case, Python will construct an empty list -- this is its interpretation of "up to, but not including n" for an argument like range(n, n). This is precisely what is happening in the first iteration of the first enclosing for loop. Trace through the code; see that 2 is bound to n in the first iteration; see that the inner loop then tries to construct the list range(2, n), which is range(2, 2), which is an empty list. And a "for x in []" statement will not execute even once. As it happens, your loop is perfectly correct. You are testing for divisors for a number excluding 1 and the number itself. For the number 2, the number of possible divisors satisfying this condition is an empty set. So 2 is, quite correctly, adjudged to be prime. From floris.bruynooghe at gmail.com Fri Apr 11 06:19:22 2008 From: floris.bruynooghe at gmail.com (Floris Bruynooghe) Date: Fri, 11 Apr 2008 03:19:22 -0700 (PDT) Subject: @x.setter property implementation References: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> <02cb2845-6a25-4e90-9f82-dbd68b37a5e6@p39g2000prm.googlegroups.com> <2c589c82-85e9-4db6-b8f9-156b06dd51f3@s33g2000pri.googlegroups.com> Message-ID: <3238aeb7-cd1b-463d-ad87-0d28dcee0202@a1g2000hsb.googlegroups.com> On Apr 11, 10:16 am, Floris Bruynooghe wrote: > On Apr 10, 5:09 pm, Arnaud Delobelle wrote: > > > > > On Apr 10, 3:37 pm, Floris Bruynooghe > > wrote: > > > > On Apr 7, 2:19 pm, "Andrii V. Mishkovskyi" wrote: > > > > > 2008/4/7, Floris Bruynooghe : > > > > > > Have been grepping all over the place and failed to find it. I found > > > > > the test module for them, but that doesn't get me very far... > > > > > I think you should take a look at 'descrobject.c' file in 'Objects' directory. > > > > Thanks, I found it! So after some looking around here was my > > > implementation: > > > > class myproperty(property): > > > def setter(self, func): > > > self.fset = func > > > > But that doesn't work since fset is a read only attribute (and all of > > > this is implemented in C). > > > > So I've settled with the (nearly) original proposal from Guido on > > > python-dev: > > > > def propset(prop): > > > assert isinstance(prop, property) > > > @functools.wraps > > > def helper(func): > > > return property(prop.fget, func, prop.fdel, prop.__doc__) > > > return helper > > > > The downside of this is that upgrade from 2.5 to 2.6 will require code > > > changes, I was trying to minimise those to just removing an import > > > statement. > > > > Regards > > > Floris > > > Here's an implementation of prop.setter in pure python < 2.6, but > > using sys._getframe, and the only test performed is the one below :) > > > import sys > > > def find_key(mapping, searchval): > > for key, val in mapping.iteritems(): > > if val == searchval: > > return key > > > _property = property > > > class property(property): > > def setter(self, fset): > > cls_ns = sys._getframe(1).f_locals > > propname = find_key(cls_ns, self) > > # if not propname: there's a problem! > > cls_ns[propname] = property(self.fget, fset, > > self.fdel, self.__doc__) > > return fset > > # getter and deleter can be defined the same way! > > > # -------- Example ------- > > > class Foo(object): > > @property > > def bar(self): > > return self._bar > > @bar.setter > > def setbar(self, x): > > self._bar = '<%s>' % x > > > # -------- Interactive test ----- > > > >>> foo = Foo() > > >>> foo.bar = 3 > > >>> foo.bar > > '<3>' > > >>> foo.bar = 'oeufs' > > >>> foo.bar > > '' > > > Having fun'ly yours, > > Neat! > > Unfortunatly both this one and the one I posted before work when I try > them out on the commandline but both fail when I try to use them in a > module. And I just can't figure out why. This in more detail: Imaging mod.py: import sys _property = property class property(property): """Python 2.6/3.0 style property""" def setter(self, fset): cls_ns = sys._getframe(1).f_locals for k, v in cls_ns.iteritems(): if v == self: propname = k break cls_ns[propname] = property(self.fget, fset, self.fdel, self.__doc__) return fset class Foo(object): @property def x(self): return self._x @x.setter def x(self, v): self._x = v + 1 Now enter the interpreter: >>> import mod >>> f = mod.Foo() >>> f.x = 4 >>> f.x 4 I don't feel like giving up on this now, so close... From markjreed at gmail.com Wed Apr 23 16:31:17 2008 From: markjreed at gmail.com (Mark Reed) Date: Wed, 23 Apr 2008 13:31:17 -0700 (PDT) Subject: Pythonically extract data from a list of tuples (getopt) Message-ID: So the return value from getopt.getopt() is a list of tuples, e.g. >>> import getopt >>> opts = getopt.getopt('-a 1 -b 2 -a 3'.split(), 'a:b:')[0]; opts [('-a', '1'), ('-b', '2'), ('-a', '3')] what's the idiomatic way of using this result? I can think of several possibilities. For options not allowed to occur more than once, you can turn it into a dictionary: >>> b = dict(opts)['-b']; b '2' Otherwise, you can use a list comprehension: >>> a = [arg for opt, arg in opts if opt == '-a']; a ['1', '3'] Maybe the usual idiom is to iterate through the list rather than using it in situ... >>> a = [] >>> b = None >>> for opt, arg in opts: ... if opt == '-a': ... a.append(arg) ... elif opt == '-b': ... b = arg ... else: ... raise ValueError("Unrecognized option %s" % opt) Any of the foregoing constitute The One Way To Do It? Any simpler, legible shortcuts? Thanks. From peter at sd-editions.com Sat Apr 12 01:45:25 2008 From: peter at sd-editions.com (Peter Robinson) Date: Sat, 12 Apr 2008 06:45:25 +0100 Subject: accessing individual characters in unicode strings Message-ID: Dear list I am at my wits end on what seemed a very simple task: I have some greek text, nicely encoded in utf8, going in and out of a xml database, being passed over and beautifully displayed on the web. For example: the most common greek word of all 'kai' (or ??? if your mailer can see utf8) So all I want to do is: step through this string a character at a time, and do something for each character (actually set a width attribute somewhere else for each character) Should be simple, yes? turns out to be near impossible. I tried using a simple index character routine such as ustr[0]..ustr[1]... and this gives rubbish. So I use len() to find out how long my simple greek string is, and of course it is NOT three characters long. A day of intensive searching around the lists tells me that unicode and python is a moving target: so many fixes are suggested for similar problems, none apparently working with mine. Here is the best I can do, so far I convert the utf8 string using ustr = repr(unicode(thisword, 'iso-8859-7')) for kai this gives the following: u'\u039e\u038a\u039e\xb1\u039e\u0389' so now things should be simple, yes? just go through this and identify each character... Not so simple at all. k, kappa: turns out to be TWO \u strings, not one: thus \u039e\u038a similarly, iota is also two \u strings: \u039e\u0389 alpha is a \u string followed by a \x string: \u039e\xb1 looking elsewhere in the record, my particular favourite is the midpoint character: this comes out as \u03b1\x90\xa7 ! and in the middle of all this, there are some non-unicode characters: \u039e\u038fc is o followed by c! well, I don't have many characters to deal this and I could cope with this mess by tedious matching character by character. But surely, there is a better way... help please Peter Robinson: peter at sd-editions.com From zethex at hotmail.com Sun Apr 27 14:19:37 2008 From: zethex at hotmail.com (Zethex) Date: Sun, 27 Apr 2008 11:19:37 -0700 (PDT) Subject: Mapping and Filtering Help for Lists In-Reply-To: <16925836.post@talk.nabble.com> References: <16925836.post@talk.nabble.com> Message-ID: <16926758.post@talk.nabble.com> Thank you for the help so far. Another quick question, how can I remove the special characters such as ! and ?. I also need to lowercase the words so should i use sentence = sentence.lower() ? Thank you -- View this message in context: http://www.nabble.com/Mapping-and-Filtering-Help-for-Lists-tp16925836p16926758.html Sent from the Python - python-list mailing list archive at Nabble.com. From rickbking at comcast.net Wed Apr 9 12:16:28 2008 From: rickbking at comcast.net (Rick King) Date: Wed, 09 Apr 2008 12:16:28 -0400 Subject: Stani's python ide 'spe' editor problem Message-ID: <47FCEBDC.80906@comcast.net> Hi everyone, The editor in spe on my system (win XP home sp2) does not do automatic indentation..... I can't figure out why - it used to. I'm set up with subversion so I have the very latest stuff from Stani. It's amazing how not having automatic indentation can make working in the ide such a pain. This has been going on for a while (like a few years), and the situation is deteriorating - used to be that the indentation would work for a while after restarting my system and then stop (until the next restart). Now, with his latest stuff, it doesn't work at all. Because it used to reset with a restart, it must have something to do with a dll, like the scintilla editor dll? But that's kind of hard to believe: why would the editor dll care about indentation? Anyway, I am extremely frustrated. I've tried other ide's: pythonwin (I found it inadequate for my purposes - why is a command line prompt displayed in a dialog window?) - eclipse (editor is just ok, shell does not have command history(!), and then *really* funky things started happening that I could not explain and so had to stop using it) - idle is good for small things and ok for larger projects but limited in general. I really like spe and want to continue using it. Stani himself seems pretty unreachable. Does anyone have a clue for me about what the issue is? Is no one else using this great ide? Or is no one else having this problem? Thanks for any help. -Rick King Southfield MI From arnodel at googlemail.com Mon Apr 28 14:42:50 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Mon, 28 Apr 2008 19:42:50 +0100 Subject: How to unget a line when reading from a file/stream iterator/generator? References: Message-ID: python at bdurham.com writes: > Is there an elegant way to unget a line when reading from a file/stream > iterator/generator? > > By "unget" I mean a way to push back a line into the source stream and > backtrack the iterator/generator one step? > > The only alternative I can see is to put my line reading in a while-True > loop (vs. a for-loop) that manually calls my file/stream > iterator/generator's .next() method while manually handling the > StopIteration exception. Doesn't sound too elegant. > > Is there a Pythonic design pattern/best practice that I can apply here? It seems to me that the answer depends on what you do with your unget'ed line (i.e. there is no included general purpose 'unget' replacement). If you provided some (pseudo-)code, someone might be able to find an elegant way to perform the task without the need to push back an element into an iterator. As a last resort, you could always wrap your iterator into a some 'Backtrackable' class. class Backtrackable(object): def __init__(self, iterator): self.iterator = iter(iterator) self._back = False self._last = None def __iter__(self): return self def next(self): if self._back: next = self._last else: self._last = next = self.iterator.next() self._back = False return next def back(self): if self._back: raise('Cannot backtrack twice') self._back = True >>> b = Backtrackable([1,2,3]) >>> b.next() 1 >>> b.next() 2 >>> b.back() >>> b.next() 2 >>> b.next() 3 From Lie.1296 at gmail.com Sun Apr 20 15:25:33 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 20 Apr 2008 12:25:33 -0700 (PDT) Subject: python setup.py install on Vista? References: <480B5A42.1050407@v.loewis.de> Message-ID: <10dddf35-34fd-4967-a191-88418553b5b4@y18g2000pre.googlegroups.com> On Apr 20, 9:59 pm, "Martin v. L?wis" wrote: > > It seems that quite a lot of people wondered why python doesn't set > > the environment variable to Python Path in the default installation. > > For several reasons, one being that it's not needed. Just run setup.py > as a program, i.e. don't do > > python setup.py install > > but instead do > > setup.py install > > Regards, > Martin who said it isn't needed: 1. I primarily set the EnvPath to invoke the interpreter in interactive mode, without being intervened by IDLE ('cause IDLE is extremely slow if you do a lot of print statements, most of the time you won't notice it but if we do multitude of prints it might hang for a second or two at every statement). 2. To avoid confusion with the rest of the world that uses python by calling "python" in a shell-like interface (i.e. cmd). 3. Linux-people sometimes doesn't believe that there are Windows- people that actually likes CLI, sometimes more than GUI. 4. Being such a great IDE, IDLE sometimes do odds and ends that it sometimes DoS-ed me, having a quick, alternative way to be in touch with python is a good thing, especially if you're being chased by a deadline and moving focus away from the job to repair the tool is not an option. From tjreedy at udel.edu Mon Apr 7 13:13:30 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 7 Apr 2008 13:13:30 -0400 Subject: Dependency Queue References: <0309251d-fba9-447c-9b17-f512988103ea@e39g2000hsf.googlegroups.com> Message-ID: "Carl Banks" wrote in message news:0309251d-fba9-447c-9b17-f512988103ea at e39g2000hsf.googlegroups.com... | I'm looking for any information about a certain kind of dynamic data | structure. Not knowing if it has some well-known name that I could | have Googled, I'll just call it a dependency queue. It's like a | priority queue except instead of a strict ordering of items by | priority, there is only a topological ordering (like you would have in | a directed acyclic graph). | | To date I've been generating a dependency graph in advance every | iteration through my main loop, doing a topsort, and executing the | values in order (the values are callable objects--this is a | scheduler). | | However, I'd like a dynamic dependency queue for two reasons: it would | simplify things to not have to generate the whole graph in advance, | and it could improve performance to run some tasks of the next | iteration in the present one (this could potentially make better use | of the dual-core and graphics hardware). | | I'm pretty sure I could hack out this structure on my own, but I'd | like to see any prior information if there is any, in case anyone's | figured out things like, Is there an easy way to detect cycles on | insertion? and so on. Perhaps what you want is a dynamic DAG (directed acyclic graph) with ordered labels. At any time, only the set of sources are eligible for execution, so there is no reason to flatten the whole thing. I suspect insertion with cycle detection would be easier, but I don't remember actually seeing an algorithm. tjr From deets at nospam.web.de Thu Apr 24 12:50:44 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 24 Apr 2008 18:50:44 +0200 Subject: MESSAGE RESPONSE In-Reply-To: References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com><27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com><678v5qF2me5rvU1@mid.uni-berlin.de> <5504f9ac0804230927ncfdb91buf7fa3e181f8a9237@mail.gmail.com> Message-ID: <67bs3rF2najntU2@mid.uni-berlin.de> Blubaugh, David A. schrieb: > Dear Sir, > > Belcan has an absolute zero-tolerance policy toward material such as the material described. That pairs up nicely with them having zero knowledge about the internet. Diez From wizzardx at gmail.com Sun Apr 27 11:10:49 2008 From: wizzardx at gmail.com (David) Date: Sun, 27 Apr 2008 17:10:49 +0200 Subject: design choice: multi-threaded / asynchronous wxpython client? In-Reply-To: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: <18c1e6480804270810ka59d326tb3ce21a41a6c9db0@mail.gmail.com> > > 1) The data for the race about to start updates every (say) 15 > seconds, and the data for earlier and later races updates only every > (say) 5 minutes. There is no point for me to be hammering the server > with requests every 15 seconds for data for races after the upcoming Try using an HTTP HEAD instruction instead to check if the data has changed since last time. From stef.mientki at gmail.com Thu Apr 3 13:17:00 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Thu, 03 Apr 2008 19:17:00 +0200 Subject: Python in High School In-Reply-To: <873a5fc2-0bd8-4f93-9c8c-56cda6e0090a@s37g2000prg.googlegroups.com> References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> <58deb8b8-bae9-4d43-b973-3d90846726cb@b5g2000pri.googlegroups.com> <873a5fc2-0bd8-4f93-9c8c-56cda6e0090a@s37g2000prg.googlegroups.com> Message-ID: <47F5110C.8010102@gmail.com> >> Well I doubt it's the visual environment that makes it more easy, >> color, shape and position can give some extra information though. >> I think apriori domain knowledge and flattness of information are of far >> more importance. >> The first issue is covered quit well by Robolab / Labview, >> but the second issue certainly is not. >> I'm right now working on a Labview like editor in Python, >> which does obey the demand for flatness of information. >> The first results can be seen here:http://oase.uci.kun.nl/~mientki/data_www/pylab_works/pw_animations_sc... >> >> >> cheers, >> Stef Mientki >> >> >>> And you are going to teach them Java? Oh, please don't. Let the >>> colleges torture them. :=) >>> > > What do you mean by flatness of information? > > What I mean is something like; all the information at a certain abstraction level is visible on one screen or one piece of paper, and not is available through multiple screen / multiple right-clicks etc. A wizard in general is an example of strong non-flatness of information (try adding a mail-account in Thunderbird, this could easily be put on 1 page, which clearly would give a much better overview). cheers, Stef From zedshaw at zedshaw.com Tue Apr 1 17:34:05 2008 From: zedshaw at zedshaw.com (Zed A. Shaw) Date: Tue, 1 Apr 2008 17:34:05 -0400 Subject: [ANN] Vellum 0.7: Simple Python Can Build Many Things Message-ID: <20080401173405.d7631510.zedshaw@zedshaw.com> Hi All, This is another announce for my fun little make,Rake,Scons alternative named Vellum. The goal of Vellum is to create a complete build system in the least amount of clean Python as possible, while keeping the build mechanism safe from code injection (if you need that). == STATUS I went a little nuts today and did three releases adding tons of features but very little code. It currently can be used to build most anything, but there's little documentation. I'm using to build about 6 projects of mine and it's great stuff. The big changes from today is that, if you hate YAML, then you don't have to use it at all. Period. It's all python syntax all the time with none of the >>>,<--,-->,<<< characters. This seems to make people smile. You can download 0.7 from here: https://launchpad.net/vellum/0.0/0.7 Which will also be the main project distribution page for everyone. You can get the source from there via bzr or you can go to: http://www.zedshaw.com/projects/vellum == WHAT'S IN VELLUM 0.7? This release features complete Python integration that's on equal footing with the YAML support. You don't even need to install YAML to use Vellum with just Python only builds. It also adds a bit of Pythonic syntactic sugar for the build files so that people don't freak about the "weird" syntax used in the YAML files. Now you can write this for a target: from vellum.python import * targets = {"sample": [sh("echo i did something")]} Or any combination of sh(), log(), py(), given(), and target() to describe a target. == BUILD SAFETY One problem with using Python to describe a build is that it is an executable, which means that bad things can be put in the build. That's fine if it's your build, since you should be careful. But, if you get the build from someone else you'd want to analyze the build and load it without causing anything to happen. The YAML syntax lets you do this, but the Python does not. Therefore, for the security minded there's a new option -Y that only allows YAML loading so you can restrict your builds to only trust YAML. I'll be adding more features for the build safety that will hopefully let people use Vellum to safely (or reasonably safely) build other people's stuff without getting hurt (or at least get yelled at a lot). == TINY CODE So far Vellum is pushing around 300 lines of Python. That is just awesome. Anyone interested in helping feel free to branch the bzr and register it with Launchpad. Email me when you got stuff I might be interested in and I'll pull from you, or send me patches. Suggested features that don't involve major changes are more than welcome. == NEXT FEATURES * A few recipes to make building common stuff easy, like generating setup.py and so on. * A way to load modules from trusted locations. * Documentation, built with Vellum and Idiopidae. Fun. And that should be it. -- Zed A. Shaw - Hate: http://savingtheinternetwithhate.com/ - Good: http://www.zedshaw.com/ - Evil: http://yearofevil.com/ From andrei.avk at gmail.com Thu Apr 3 18:10:51 2008 From: andrei.avk at gmail.com (AK) Date: Thu, 03 Apr 2008 17:10:51 -0500 Subject: Python-by-example - new online guide to Python Standard Library In-Reply-To: <47f514c5$0$6520$4c368faf@roadrunner.com> References: <47f2d018$0$6517$4c368faf@roadrunner.com> <47f514c5$0$6520$4c368faf@roadrunner.com> Message-ID: <47f547e0$0$12560$4c368faf@roadrunner.com> AK wrote: > > I uploaded an updated site incorporating most of the suggestions I > received and fixing some errors along the way. I will be adding more > examples to modules that are already covered and will try to add more > modules during the following week. Thanks again to all who posted advice > and comments! > I also mapped the site to a subdomain so that it's easier to access quickly: http://pbe.lightbird.net/ where 'pbe' stands for 'Python-by-Example'. -- -ak Tobu | http://tobu.lightbird.net/ | Freeform DB / Tagger / PIM Python-by-Example | http://pbe.lightbird.net/ | Guide to LibRef From mblume at freesurf.ch Wed Apr 23 14:01:39 2008 From: mblume at freesurf.ch (Martin Blume) Date: Wed, 23 Apr 2008 20:01:39 +0200 Subject: Unix Device File Emulation References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> <480f6376$0$9037$5402220f@news.sunrise.ch> <9ee87070-be57-4a66-a152-3f36c1cc8f0c@k13g2000hse.googlegroups.com> Message-ID: <480f7983$0$9036$5402220f@news.sunrise.ch> "blaine" schrieb > > > > while 1: > > r = self.fifodev.readline() > > if r: print r > > > > According to my docs, readline() returns an empty > > string at the end of the file. > > Also, you might want to sleep() between reads a > > little bit. > > > > Oh ok, that makes sense. Hmm. So do I not want to use > readline()? Or is there a way to do something like > 'block until the file is not empty'? > No, while 1: r = self.fifodev.readline() if r: print r else: time.sleep(0.1) is ok (note the "if r:" clause). Martin From tinnews at isbd.co.uk Thu Apr 3 10:13:43 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 03 Apr 2008 14:13:43 GMT Subject: How easy is it to install python as non-root user? Message-ID: <47f4e617$0$720$bed64819@news.gradwell.net> Does python install fairly easily for a non-root user? I have an ssh login account onto a Linux system that currently provides Python 2.4.3 and I'd really like to use some of the improvements in Python 2.5.x. So, if I download the Python-2.5.2.tgz file is it just the standard:- ./configure --prefix=$HOME make make install -- Chris Green From aaron.watters at gmail.com Sun Apr 27 21:31:47 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Sun, 27 Apr 2008 18:31:47 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> <48118719$0$25846$9b622d9e@news.freenet.de> <481525DE.9060208@v.loewis.de> Message-ID: On Apr 27, 9:18?pm, "Martin v. L?wis" wrote: > An existing application of an existing dict-like > object will continue to work just fine in Python 3, > right? Unless I mix my psuedodicts with standard dicts in the same list, for example, or pass them to functions intended to accept any dict-like object, including the especially important case of standard dicts. Who knows? Maybe I'm wrong about this being a much of problem. 20+ years experience warns me strongly to be very afraid, however. It would be great if I didn't have to think about it. Can anyone recommend a good book on Ruby :)? -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=unnecessary+breakage From s0suk3 at gmail.com Mon Apr 28 10:26:13 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Mon, 28 Apr 2008 07:26:13 -0700 (PDT) Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> Message-ID: <1939ddb7-fc72-4d45-8c9c-062a1d0db3e4@y21g2000hsf.googlegroups.com> On Apr 28, 4:30 am, Nick Craig-Wood wrote: > s0s... at gmail.com wrote: > > I wanted to ask for standard ways to receive data from a socket stream > > (with socket.socket.recv()). It's simple when you know the amount of > > data that you're going to receive, or when you'll receive data until > > the remote peer closes the connection. But I'm not sure which is the > > best way to receive a message with undetermined length from a stream > > in a connection that you expect to remain open. Until now, I've been > > doing this little trick: > > > data = client.recv(256) > > new = data > > while len(new) == 256: > > new = client.recv(256) > > data += new > > > That works well in most cases. But it's obviously error-prone. What if > > the client sent *exactly* two hundred and fifty six bytes? It would > > keep waiting for data inside the loop. Is there really a better and > > standard way, or is this as best as it gets? > > What you are missing is that if the recv ever returns no bytes at all > then the other end has closed the connection. So something like this > is the correct thing to write :- > > data = "" > while True: > new = client.recv(256) > if not new: > break > data += new > > From the man page for recv > > RETURN VALUE > > These calls return the number of bytes received, or -1 if an > error occurred. The return value will be 0 when the peer has > performed an orderly shutdown. > > In the -1 case python will raise a socket.error. > > -- > Nick Craig-Wood --http://www.craig-wood.com/nick But as I said in my first post, it's simple when you know the amount of data that you're going to receive, or when you'll receive data until the remote peer closes the connection. But what about receiving a message with undetermined length in a connection that you don't want to close? I already figured it out: in the case of an HTTP server/ client (which is what I'm doing), you have to look for an empty line in the message, which signals the end of the message headers. As for the body, you have to look at the Content-Length header, or, if the message body contains the "chunked" transfer-coding, you have to dynamically decode the encoding. There are other cases but those are the most influent. BTW, has anybody used sockets as file-like objects (client.makefile())? Is it more secure? More efficient? Sebastian From deets at nospam.web.de Thu Apr 3 10:49:57 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 03 Apr 2008 16:49:57 +0200 Subject: object-relational mappers In-Reply-To: <47f4eb4f$0$4959$426a74cc@news.free.fr> References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <47f37039$0$31900$426a74cc@news.free.fr> <47f4eb4f$0$4959$426a74cc@news.free.fr> Message-ID: <65k94pF2g33guU1@mid.uni-berlin.de> Bruno Desthuilliers schrieb: > Jarek Zgoda a ?crit : >> Bruno Desthuilliers napisa?(a): >> >>> Now my own experience is that whenever I tried this approach for >>> anything non-trivial, I ended up building an "ad-hoc, >>> informally-specified bug-ridden slow implementation of half of " >>> SQLAlchemy. Which BTW is not strictly an ORM, but primarily an attempt >>> at a better integration of SQL into Python. So while it may feel like >>> learning the inner complexities of SQLALchemy (or Django's ORM which is >>> not that bad either) is "wasting brain cells", MVHO is that it's worth >>> the time spent. But YMMV of course - IOW, do what works best for you. >> >> I like OR mappers, they save me lot of work. The problem is, all of them >> are very resource hungry, processing resultset of 300k objects one by >> one can effectively kill most of commodity systems. This is where raw >> SQL comes in handy. > > The problem here is not about how you build your query but about how you > retrieve your data. FWIW, SQLAlchemy provides quite a lot of "lower > level" SQL/Python integration that doesn't require the "object mapping" > part. "raw SQL" is fine, until you have to dynamically build complex > queries from user inputs and whatnot. This is where the "low-level" (ie: > non-ORM) part of SQLAlchemy shines IMHO. The same can be said for SQLObjects SQLBuilder. Even if I ended up generating SQL for some query that didn't touch the ORM-layer, it helps tremendously to write e.g subqueries and such using python-objects instead of manipulating strings. They help keeping track of already referenced tables, spit out properly escaped syntax and so forth. Diez From jorge.vargas at gmail.com Tue Apr 1 03:15:57 2008 From: jorge.vargas at gmail.com (Jorge Vargas) Date: Tue, 1 Apr 2008 07:15:57 +0000 Subject: Why prefer != over <> for Python 3.0? In-Reply-To: References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> <659gb2F2f84eoU2@mid.individual.net> <87hceo73ap.fsf@physik.rwth-aachen.de> <65anbqF2fg18bU1@mid.individual.net> <87r6drjss4.fsf@physik.rwth-aachen.de> <65c0bfF2ffipiU1@mid.individual.net> Message-ID: <32822fe60804010015m22a4e9bei5002431afe14921a@mail.gmail.com> On Tue, Apr 1, 2008 at 6:03 AM, Gabriel Genellina wrote: > En Mon, 31 Mar 2008 16:17:39 -0300, Terry Reedy > escribi?: > > > > "Bjoern Schliessmann" > > wrote > > in message news:65c0bfF2ffipiU1 at mid.individual.net... > > | > However, I'm quite sure that when Unicode has arrived almost > > | > everywhere, some languages will start considering such characters > > | > in their core syntax. > > | > > | This should be the time when there are widespread quasi-standardised > > | input methods for those characters. > > > > C has triglyphs for keyboards missing some ASCII chars. != and <= could > > easily be treated as diglyphs for the corresponding chars. In a sense > > they > > are already, it is just that the real things are not allowed ;=). > > I think it should be easy to add support for ??? and even ?, only the > tokenizer has to be changed. > show me a keyboard that has those symbols and I'm all up for it. as for the original question, the point of going unicode is not to make code unicode, but to make code's output unicode. thin of print calls and templates and comments the world's complexity in languages. sadly most english speaking people think unicode is irrelevant because ASCII has everything, but their narrow world is what's wrong. From steve at holdenweb.com Fri Apr 11 17:47:59 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 11 Apr 2008 17:47:59 -0400 Subject: Question on threads In-Reply-To: References: <47FFBC05.50309@holdenweb.com> Message-ID: <47FFDC8F.4060106@holdenweb.com> Jonathan Shao wrote: > On Fri, Apr 11, 2008 at 3:29 PM, Steve Holden > wrote: > > Jonathan Shao wrote: > > Hi all, > I'm a beginner to Python, so please bear with me. > Is there a way of guarenteeing that all created threads in a > program are finished before the main program exits? I know that > using join() can guarentee this, but from the test scripts I've > run, it seems like join() also forces each individual thread to > terminate first before the next thread can finish. So if I > create like 20 threads in a for loop, and I join() each created > thread, then join() will in effect cause the threads to be > executed in serial rather than in parallel. > > > No it won't, as in fact there is no mechanism to force a thread to > terminate in Python. When you join() each created thread the main > thread will wait for each thread to finish. Supposing the > longest-lived thread finished first then all others will immediately > return from join(). > > The only requirement it is imposing is that all sub-threads must be > finished before the main thread terminates. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > > > I guess I'm doing something wrong with join(). Here's a test script I > wrote up... > > import threading > import time > class TestThread(threading.Thread): > def __init__(self, region): > self.region = region > threading.Thread.__init__(self) > def run(self): > for loop in range(10): > print "Region " + str(self.region) + " reporting: " + str(loop) > time.sleep(2) > for x in range(10): > thr = TestThread(x) > thr.start() > thr.join() > raw_input() > In this script thread 0 will finish first... Am I doing something wrong > with join()? > Yes - you are calling it before you have started ALL your threads, thereby making hte main thread wait for the end of thread 1 before starting the next. An impressive demonstration of thread synchronization, but not quite what you want :-) Try saving the threads in a list then joining them later, like this (untested): threads = [] for x in range(10): thr = TestThread(x) thr.start() threads.append(thr) # Now all are started, wait for all to finish for thr in threads: thr.join() regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From george.sakkis at gmail.com Wed Apr 2 13:31:23 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 2 Apr 2008 10:31:23 -0700 (PDT) Subject: april fools email backfires References: <7xbq4sf9wv.fsf@ruckus.brouhaha.com> Message-ID: On Apr 2, 1:23?pm, Paul Rubin wrote: > Aaron Watters writes: > > Grapevine says that an architect/bigot at a java/spring shop sent > > out an April Fools email saying they had decided to port everything > > to Django ASAP. > > > Of course the email was taken seriously and he got a lot of positive > > feedback from line developers and savvy users/managers that they > > thought it would be a great idea; it's about time; gotta do > > something about this mess... > > Django, pah. ?They should switch to something REALLY advanced: > > http://www.coboloncogs.org/INDEX.HTM That was funny, thanks for the chuckle :) From bronger at physik.rwth-aachen.de Wed Apr 16 00:45:50 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 16 Apr 2008 06:45:50 +0200 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <101680ba-a116-414b-8fff-c5b5bd2f4b65@p39g2000prm.googlegroups.com> Message-ID: <87iqyi9zlt.fsf@physik.rwth-aachen.de> Hall?chen! lxlaurax at gmail.com writes: > On 11 abr, 20:31, sturlamolden wrote: > > [...] > > I have no experience with GUI programming in Python, but from this > discussion it seems if the type of license is not an issue (for > FOSS development), PyQt is the best tool because it is: > > (a) easier to learn and intuitive for programming (this is > important to me; I am not that smart...); > > (b) more stable (although many people have said that wxPython is > as stable as any other GUI nowadays; but not more stable (wx) than > others); > > (c) more cross-platform (many people complain that they have to do > a lot of things in wxPython for the cross-platform). > > Is (a) and (c) true or not? If so, how big are these advantages? I really don't know what someone could mean with (c). (b) is probably correct, however for both toolkits this is a not critical from my observation (writing own programs and reading reports of others). (a) is a matter of taste. I, for example, ruled out Qt because I've never understood its mentality. I've read it over and over again, but I didn't grasp it. It depends on your background probably. > The great advantage of wxPython seems to be the huge community of > users and the large number of widgets/examples/applications > available. Unless the Qt people simple can shout much louder, I think both communities are equally sized, but I don't know for sure. > Reformulating my question: > > Which GUI tool, wxPython or PyQt, is more pythonic? In my opinion: none. This was important to me, too, so I looked at it closely when I chose my GUI toolkit. wxPython is traditionally considered unpythonic which is a bit unfair now. They tweaked it a little in recent years and it is reasonable pythonic now. It still has its warts, but Qt definitely has them, too. If you want to have it clean, you must climb up to another level of abstraction (Dabo, Wax etc). I wouldn't do this because it gets slower and less well supported by a large community. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From thashooski at farifluset.mailexpire.com Sun Apr 13 14:44:21 2008 From: thashooski at farifluset.mailexpire.com (thashooski at farifluset.mailexpire.com) Date: Sun, 13 Apr 2008 11:44:21 -0700 (PDT) Subject: Module to read input from commandline References: <2e04b64c-9a12-4e20-8d5a-546a0ec4ac7f@m36g2000hse.googlegroups.com> Message-ID: What you're looking for is no module, it is included in the standard python namespace. raw_input Use it like this: value_a = raw_input("Please give a value for a: ") # do your thing to value_a But this belongs to the real basics, I suggest you get some reading done on python. GL From python at bdurham.com Sat Apr 12 14:41:20 2008 From: python at bdurham.com (Malcolm Greene) Date: Sat, 12 Apr 2008 14:41:20 -0400 Subject: Recommended "from __future__ import" options for Python 2.5.2? Message-ID: <1208025680.10309.1247529999@webmail.messagingengine.com> Is there any consensus on what "from __future__ import" options developers should be using in their Python 2.5.2 applications? Is there a consolidated list of "from __future__ import" options to choose from? Thank you, Malcolm From jeff.self at gmail.com Wed Apr 9 19:37:11 2008 From: jeff.self at gmail.com (jeffself) Date: Wed, 9 Apr 2008 16:37:11 -0700 (PDT) Subject: How can I use quotes without escaping them using CSV? References: Message-ID: On Apr 9, 5:39 pm, "Reedick, Andrew" wrote: > > -----Original Message----- > > From: python-list-bounces+jr9445=att.... at python.org [mailto:python- > > list-bounces+jr9445=att.... at python.org] On Behalf Of jeffself > > Sent: Wednesday, April 09, 2008 5:11 PM > > To: python-l... at python.org > > Subject: How can I use quotes without escaping them using CSV? > > > If I put an escape character in, it works. For example, if I use ~ as > > my escape character, my output looks like this: > > 0001[tab]Michael L. ~"Mick~" Jones[tab]189 > > > I don't want that. If I don't include an escape character, it doesn't > > work. > > > Here's my code: > > import sys > > import csv > > from readexcel import * > > > f = open("results.txt", 'wb') > > book = sys.argv[1] > > sheet = sys.argv[2] > > > xl = readexcel(book) > > sheetnames = xl.worksheets() > > > for s in sheetnames: > > if s == sheet: > > writer = csv.writer(f, delimiter='\t', quoting=csv.QUOTE_NONE) > > for row in xl.getiter(s): > > writer.writerow((row['Precinct'],row['Candidate'],unicode(int(row['Vote > > > s'])))) > > f.close() > > The documentation is pretty, uhm, obtuse, but you also need to set > quotechar. > > import sys > import csv > > names = ['Michael L. "Mick" Jones', 'Vickie A. Meyers', 'John "Jack" > Smith'] > > writer = csv.writer(sys.stdout, delimiter='\t', quotechar='', > quoting=csv.QUOTE_NONE) > for i in names: > writer.writerow(['a', i, 'b']) > > output: > a Michael L. "Mick" Jones b > a Vickie A. Meyers b > a John "Jack" Smith b > > ***** > > The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA621 I tried this but a get the following error: >>> writer = csv.writer(sys.stdout, delimiter='\t', quotechar=", quoting=csv.QUOTE_NONE) File "", line 1 writer = csv.writer(sys.stdout, delimiter='\t', quotechar=", quoting=csv.QUOTE_NONE) ^ SyntaxError: EOL while scanning single-quoted string From kveretennicov at gmail.com Tue Apr 1 15:50:17 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Tue, 1 Apr 2008 22:50:17 +0300 Subject: Is this a good time to start learning python? In-Reply-To: <1565ced8-afd7-4c32-a6ee-26f9b95d60bc@d45g2000hsc.googlegroups.com> References: <47f1140e$0$735$a729d347@news.telepac.pt> <88fa881e-e59b-4682-801c-90ef08a1480a@a22g2000hsc.googlegroups.com> <1565ced8-afd7-4c32-a6ee-26f9b95d60bc@d45g2000hsc.googlegroups.com> Message-ID: <4660fe300804011250w5a3164d3l57db02f8bc82f395@mail.gmail.com> > > > > > Backward compatibility is important. C++ could break all ties with > C > > > to "clean up" as well, but it would be a braindead move that would > > > break existing code bases upon upgrade. > > > > C++ is not C. No one "upgrades" from C to C++. > > You misunderstand. C++ has a lot of "warts" to maintain backwards > compatibility with C. The standards committee could eliminate these > warts to make the language "cleaner", but it would break a lot of > systems. > Didn't C++ "break" all C programs that happened to use "class" for identifier? :) -- kv -------------- next part -------------- An HTML attachment was scrubbed... URL: From cyberco at gmail.com Thu Apr 17 10:11:17 2008 From: cyberco at gmail.com (Berco Beute) Date: Thu, 17 Apr 2008 07:11:17 -0700 (PDT) Subject: webcam (usb) access under Ubuntu References: Message-ID: <9c260dc0-6461-4869-ba4e-63016b831dba@x41g2000hsb.googlegroups.com> On Apr 16, 2:26 pm, yoz wrote: > Berco Beute wrote: > > I've been trying to access my webcam using Python, but I failed > > miserably. The camera works fine under Ubuntu (using camora and > > skype), but I am unable to get WebCamSpy or libfg to access my webcam. > > > First I tried webcamspy (http://webcamspy.sourceforge.net/). That > > requires pySerial and pyParallel, and optionally pyI2C. Runing > > WebCamSpy results in: > > > Exception exceptions.AttributeError: "Parallel instance has no > > attribute '_fd'" in > > ignored > > > This seems to come from importing I2C. The application window opens, > > but there's an error message: > > > NO VIDEO SOURCE FOUND > > > Next I tried libfg (http://antonym.org/libfg). I built it, made the > > Python bindings and installed it. Unfortunately the following: > > >>>> import fg > >>>> grabber = fg.Grabber() > > > results in: > > > fg_open(): open video device failed: No such file or directory > > > Since the camera works fine in Ubuntu itself my guess is that the > > problem is with the python libraries (or even likelier, my usage of > > them). Is there anybody here that was successful in accessing their > > webcam on linux using Python? Else I have to reside to Windows and > > VideoCapture (which relies on the win32 api and thus is Windows-only), > > something I'd rather not do. > > > Thanks for any help, > > 2B > > > =============== > > I am uUsing: > > WebCam: Logitech QuickCam Pro 400 > > Ubuntu > > Python 2.5 > > Some time ago I was playing with writing a webcam server under Linux > using V4L - I found this bit of code which may help (it works for me). > Obviously it needs X running to work and the associated libs installed. > Note this is not my code but it was a good starting point for me to work > from. I can't find a link to the original article but credit to the author. > > import pygame > import Image > from pygame.locals import * > import sys > > import opencv > #this is important for capturing/displaying images > from opencv import highgui > > camera = highgui.cvCreateCameraCapture(0) > def get_image(): > im = highgui.cvQueryFrame(camera) > #convert Ipl image to PIL image > return opencv.adaptors.Ipl2PIL(im) > > fps = 30.0 > pygame.init() > window = pygame.display.set_mode((320,240)) > pygame.display.set_caption("WebCam Demo") > screen = pygame.display.get_surface() > > while True: > events = pygame.event.get() > for event in events: > if event.type == QUIT or event.type == KEYDOWN: > sys.exit(0) > im = get_image() > pg_img = pygame.image.frombuffer(im.tostring(), im.size, im.mode) > screen.blit(pg_img, (0,0)) > pygame.display.flip() > pygame.time.delay(int(1000 * 1.0/fps)) > > Best of Luck > Bgeddy Thank you! That seems to work under both Linux and windows. The opencv library is the clue here. I've used the ctypes wrapper for opencv provided by the first link below, but there are more options. For future reference here are some relevant links: http://wwwx.cs.unc.edu/~gb/wp/blog/2007/02/04/python-opencv-wrapper-using-ctypes/ http://opencvlibrary.sourceforge.net/ http://opencvlibrary.sourceforge.net/NoamLewis http://opencvlibrary.sourceforge.net/PythonInterface Windows specific: http://www.instructables.com/id/Using-openCV-1.0-with-python-2.5-in-Windows-XP/ http://dip.sun.ac.za/3Dvision/talks/OpenCV_in_Python_on_Windows.pps http://opencvlibrary.sourceforge.net/NoamLewis Thanks for all the help. 2B From bijeshn at gmail.com Tue Apr 8 00:26:11 2008 From: bijeshn at gmail.com (bijeshn) Date: Mon, 7 Apr 2008 21:26:11 -0700 (PDT) Subject: splitting an XML file on the basis on basis of XML tags References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> <47F9B845.9040205@behnel.de> <05edd42c-dd16-4364-92ca-43cdbb1ab547@r9g2000prd.googlegroups.com> <47FA14D1.3080608@behnel.de> Message-ID: <529f2c06-b0cd-4105-b3f1-37c934847c0c@1g2000prg.googlegroups.com> On Apr 7, 5:34?pm, Stefan Behnel wrote: > bijeshn wrote: > > the extracted files are to be XML too. ijust need to extract it raw > > (tags and data just like it is in the parent XML file..) > > Ah, so then replace the "print tostring()" line in my example by > > ? ? ET.ElementTree(element).write("outputfile.xml") > > and you're done. > > Stefan thanks a lot, Stefan.... i haven't tested out your idea yet. Will get back as soon as I do it... From sturlamolden at yahoo.no Thu Apr 17 13:33:26 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 17 Apr 2008 10:33:26 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> Message-ID: <6e3e8c87-60bd-496c-9f71-b6e9bbfcdc73@m3g2000hsc.googlegroups.com> On Apr 17, 7:16 pm, Jonathan Gardner wrote: > On Apr 17, 8:19 am, sturlamolden wrote: > > > > > An there you have the answer. It's really very simple :-) > > That's an interesting hack. > > Now, how do the processes communicate with each other without stepping > on each other's work and without using a lock? Why can't I use a lock? There is a big difference between fine-grained locking on each object (cf. Java) and a global lock for everything (cf. CPython's GIL). Fine- grained locking for each object has been tried, and was found to be a significant slow down in the single-threaded case. What if we just do fine grained locking on objects that need to be shared? What if we accept that "shared" objects are volatile and may suddenly disappear (like a weakref), and trap that as an exception? From steve at holdenweb.com Fri Apr 11 00:35:38 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 11 Apr 2008 00:35:38 -0400 Subject: Integer dicision In-Reply-To: <5f499bee-a659-4e36-870c-076cb613a3e7@t12g2000prg.googlegroups.com> References: <5f499bee-a659-4e36-870c-076cb613a3e7@t12g2000prg.googlegroups.com> Message-ID: bdsatish wrote: > How does (a/b) work when both 'a' and 'b' are pure integers ? > >>> (9/2) > 4 > >>> (-9/2) > -5 > > Why is it -5 ? I expect it to be -4 ? Because, in C/C++, 9/2 is 4 and > so negative of it, (-9/2) is -4. > > What should I do to get C-like behavior ? Use C? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From martin at v.loewis.de Fri Apr 18 18:01:04 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sat, 19 Apr 2008 00:01:04 +0200 Subject: Unicode chr(150) en dash In-Reply-To: <480887b8@news.mel.dft.com.au> References: <48063434$0$36327$742ec2ed@news.sonic.net> <7dae96d4-48c4-46c9-9aa9-33a263b84ca4@26g2000hsk.googlegroups.com> <480887b8@news.mel.dft.com.au> Message-ID: <48091A20.2070500@v.loewis.de> > 150 aka \x96 doesn't exist in ISO 8859-1. ISO-8859-1 (two hyphens) is a > superset of ISO 8859-1 (one hyphen) and adds the not-very-useful-AFAICT > control codes \x80 to \x9F. To disambiguate the two, when I want to refer to the one with the control characters, I use the name "IANA ISO-8859-1" or "the IANA version of Latin-1", or some such, to reflect the fact that it's not the ISO standard, but the (unfortunately differing) IANA registration thereof. Regards, Martin From andreas.eisele at gmail.com Sat Apr 12 12:53:13 2008 From: andreas.eisele at gmail.com (andreas.eisele at gmail.com) Date: Sat, 12 Apr 2008 09:53:13 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: Sorry, I have to correct my last posting again: > > Disabling the gc may not be a good idea in a real application; I suggest > > you to play with the gc.set_threshold function and set larger values, at > > least while building the dictionary. (700, 1000, 10) seems to yield good > > results. > > python2.5 -m timeit 'gc.set_threshold(700,1000,10);l=[(i,) for i in range(2000000)]' > > 10 loops, best of 3: 658 msec per loop > Looks nice, but it is pointless, as timeit disables gc by default, and the set_threshold hence has no effect. In order to see the real effect of this, I need to say > python2.5 -m timeit 'gc.enable();gc.set_threshold(700,1000,10);l=[(i,) for i in range(2000000)]' which gives me 10 loops, best of 3: 1.26 sec per loop Still a factor of more than 10 faster than the default settings. > which made me suggest to use these as defaults, but then > Martin v. L?wis wrote that > > > No, the defaults are correct for typical applications. Complex topic... From bignose+hates-spam at benfinney.id.au Fri Apr 18 18:56:29 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Sat, 19 Apr 2008 08:56:29 +1000 Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> Message-ID: <87lk3asrfm.fsf@benfinney.id.au> Thomas Bellman writes: > For what it's worth, Fedora 8 has Python 2.5, RHEL 5 ships with > Python 2.4, and RHEL 4 has Python 2.3. Suse and Debian, I don't > know. The current Debian "stable" branch (4.0r3, "etch", released 2008-02-17) has the 'python' package installing Python 2.4.4. The current Debian "testing" branch ("lenny", the next in line for release) has the 'python' package installing Python 2.4.5. It also has Python 2.5.2, and before too long will be installing that as the 'python' package. The current Debian "unstable" branch (never to be released, but a staging area for new package versions) has the 'python' package installing Python 2.5.2. -- \ "Pinky, are you pondering what I'm pondering?" "Umm, I think | `\ so, Brain, but three men in a tub? Ooh, that's unsanitary!" -- | _o__) _Pinky and The Brain_ | Ben Finney From duncan.booth at invalid.invalid Wed Apr 9 06:24:03 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 9 Apr 2008 10:24:03 GMT Subject: Can C.L.P.handle the load? References: <3b6737c8-9d42-4218-ac60-01df2f578746@p39g2000prm.googlegroups.com> <9bd25fd3-5133-4165-9784-fbbc21145810@24g2000hsh.googlegroups.com> Message-ID: Berco Beute wrote: > On Apr 9, 7:54 am, Paddy wrote: >> What else could we do to make c.l.p. of more use to the newbie whp may >> also be new to usenet whilst keeping c.l.p a usefull place for all? >> >> - Paddy. > > Maybe create a usenet/google group for newbies? A place to ask > beginners questions. And post a sticky to c.l.p. redirecting newbies > (or experienced pythoneers with newbie questions :). > Or just redirect them to the already existing list http://mail.python.org/mailman/listinfo/tutor What do you mean by 'post a sticky'? That sounds like a web forum thing. From dolloffdelvpg at gmail.com Wed Apr 16 08:05:09 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:05:09 -0700 (PDT) Subject: taylor swift height Message-ID: <7bd91158-fe3e-418c-a4b7-b6c4e7619e14@r9g2000prd.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From gagsl-py2 at yahoo.com.ar Thu Apr 24 00:24:11 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 24 Apr 2008 01:24:11 -0300 Subject: Problem using copy.copy with my own class References: <676noiF2n7ttmU1@mid.uni-berlin.de> <480FFF55.5070803@gmail.com> Message-ID: En Thu, 24 Apr 2008 01:21:15 -0300, Gabriel Genellina escribi?: > I agree. In case arg2 were really meaningful, use __getnewargs__ (see ) I forget to include the link: -- Gabriel Genellina From acherry at btinternet.com Fri Apr 11 07:07:36 2008 From: acherry at btinternet.com (Adrian Cherry) Date: 11 Apr 2008 12:07:36 +0100 Subject: Randall Munroe loves Python References: <869c25d9-e4d3-4629-a807-f3b203f3fb65@b1g2000hsg.googlegroups.com> Message-ID: Paul McGuire wrote in news:869c25d9-e4d3- 4629-a807-f3b203f3fb65 at b1g2000hsg.googlegroups.com: > Another xkcd plug for Python: http://xkcd.com/409/ > So Python is on a collision course with Calvin and Hobbes! Adrian From mdomans at gmail.com Tue Apr 1 13:41:18 2008 From: mdomans at gmail.com (mdomans) Date: Tue, 1 Apr 2008 10:41:18 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> Python needs no evangelizing but I can tell you that it is a powerfull tool. I prefer to think that flash is rather visualization tool than programing language, and java needs a lot of typing and a lot of reading. On the other hand python is simple to read and write, can be debuged easily, is intuitive and saves a lot of time. It also supports batteries included policy and you can't get more OO than python. From tjreedy at udel.edu Thu Apr 24 04:40:25 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 24 Apr 2008 04:40:25 -0400 Subject: Explicit variable declaration References: <1506f165-7f86-4dc7-aa29-6488eda9ae7f@l64g2000hse.googlegroups.com><5e59998b-d2e7-48cb-824b-84620f95c9bc@w5g2000prd.googlegroups.com> <1be78d220804231829k2c040fat80f6fe8b96e1b7cf@mail.gmail.com> Message-ID: "Filip Gruszczynski" wrote in message news:1be78d220804231829k2c040fat80f6fe8b96e1b7cf at mail.gmail.com... |> If you want to just declare that name exist, but doesn't want to | > declare the type, why don't you just do this: Names do not 'exist' in Python, nor do they have types. They are bound to objects that have types. Learn to program Python as Python, not one of those languages with a quite different model of names and values. | > def somefunc(): | > nonlocal = nonlocal Syntax error in 3.0. Error or nonsense in 2.x | > local = 0 # or None or [] or an initial value | > # | > return nonlocal * local | | Err.. I don't quite get. How it may help me? Could you explain? Forget the above. The only 'declarations' in Python, 'global' and 'nonlocal' are for the specialized purpose of *binding* names that are not in the local namespace of a function or nested function. They are only needed because otherwise names that get bound are otherwise assumed to be local. See the language ref section on function defs. tjr From elgrandchignon at gmail.com Tue Apr 8 23:04:48 2008 From: elgrandchignon at gmail.com (Jason) Date: Tue, 8 Apr 2008 20:04:48 -0700 (PDT) Subject: Sorting a List of Objects by an Attribute of the Objects Case-Insensitively Message-ID: <736fefbd-510f-40e9-8342-32b69a1a0c2a@t12g2000prg.googlegroups.com> Hi folks-- Basically, I have a pressing need for a combination of 5.2 "Sorting a List of Strings Case-Insensitively" & 5.3 "Sorting a List of Objects by an Attribute of the Objects" from the Python Cookbook. My first guess isn't working: import operator def sort_by_attr(seq, attr): key=operator.attrgetter(attr) key=str.lower return sorted(seq, key) ...would much appreciate any guidance! From sn at sncs.se Tue Apr 8 13:39:48 2008 From: sn at sncs.se (Sverker Nilsson) Date: Tue, 8 Apr 2008 10:39:48 -0700 (PDT) Subject: Guppy-PE / Heapy 0.1.8 Message-ID: I am happy to announce Guppy-PE 0.1.8 Guppy-PE is a library and programming environment for Python, currently providing in particular the Heapy subsystem, which supports object and heap memory sizing, profiling and debugging. It also includes a prototypical specification language, the Guppy Specification Language (GSL), which can be used to formally specify aspects of Python programs and generate tests and documentation from a common source. The current version is updated to work in 64-bit mode and with Python-2.6, and still works in 32-bit mode and with Python 2.3, 2.4 and 2.5. No other major changes have been made from Guppy 0.1.6. In the nearest future, I plan to add interactive help and more examples to the documentation, perhaps a tutorial. Look out for this in the svn HEAD according to instructions at the project home page, if you want the latest version. I will try to make a new release in perhaps a month or so. License: MIT Guppy-PE 0.1.8 is available in source tarball format on the Python Package Index (a.k.a. Cheeseshop): http://pypi.python.org/pypi/guppy/0.1.8 The project homepage is on Sourceforge: http://guppy-pe.sourceforge.net Enjoy, Sverker From aldo at nullcube.com Sat Apr 5 10:13:29 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Sun, 6 Apr 2008 01:13:29 +1100 Subject: ANN: pry unit testing framework In-Reply-To: <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com> Message-ID: <20080405141329.GD15684@nullcube.com> Thus spake Kay Schluehr (kay.schluehr at gmx.net): > Aldo, when you confuse inheritance ( using an OO framework properly ) > with monkey patching no one can draw much different conclusions than I > did. I guess you do always run the risk of being pelted with something from the peanut gallery when you release something in public - maybe I'll think twice about doing so next time. The only "confused" person here is you - I still say that it is NOT possible to provide the functionality Pry does by extending unittest in any sane way. Now, if you don't agree with this, please prove me wrong through reasoned argument or shut up. Do NOT, however, accuse me of not knowing what inheritance or monkeypatching is unless you want to look stupid and make my killfile. > But raving against unittest.py and anti-hyping it for mostly trivial > reasons and with shallow reasoning has become a fashion. Now we see > alternatives that do little more than what can be achieved by adding > two abstract methods to the TestSuite base class and overwrite a few > methods of the TestLoader base class ( maybe I'm wrong about it but I > guess the discussion has become too heated to clarify this point using > technical arguments ). > > I just felt it was a good opportunity to debunk this unittest.py anti- > hype. I'm sorry it has gone too personal. You can choose to use Pry or not, as you please. I would, however, ask that you stop whining incessantly about how it's not compatible with YOUR favourite framework, despite the fact that compatibility would gain YOU very little and ME nothing at all. As I said in my response to Michele, you lose the benefits of compatibility as soon as your tests use any of the features an extension might add. To me, this means the burden is not worth it. Since I designed and wrote Pry, I get to make that choice, not you, and the type of feeble, offensive "argument" you've provided is unlikely to change my mind. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From ivan.illarionov at gmail.com Fri Apr 11 08:58:46 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Fri, 11 Apr 2008 05:58:46 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: <69c85ba7-2ef1-4f65-954a-6d883dfdfb30@u69g2000hse.googlegroups.com> On Apr 11, 2:14 pm, bdsatish wrote: > The built-in function round( ) will always "round up", that is 1.5 is > rounded to 2.0 and 2.5 is rounded to 3.0. > > If I want to round to the nearest even, that is > > my_round(1.5) = 2 # As expected > my_round(2.5) = 2 # Not 3, which is an odd num > > I'm interested in rounding numbers of the form "x.5" depending upon > whether x is odd or even. Any idea about how to implement it ? def even_round(x): if x % 1 == .5 and not (int(x) % 2): return float(int(x)) else: return round(x) nums = [ 3.2, 3.6, 3.5, 2.5, -.5, -1.5, -1.3, -1.8, -2.5 ] for num in nums: print num, '->', even_round(num) 3.2 -> 3.0 3.6 -> 4.0 3.5 -> 4.0 2.5 -> 2.0 -0.5 -> 0.0 -1.5 -> -2.0 -1.3 -> -1.0 -1.8 -> -2.0 -2.5 -> -2.0 From schettino72 at gmail.com Sat Apr 19 15:35:22 2008 From: schettino72 at gmail.com (Eduardo Schettino) Date: Sun, 20 Apr 2008 01:05:22 +0530 Subject: [ANN] DoIt 0.1.0 Released (build tool) Message-ID: DoIt - A task execution tool (build-tool) ========================================= This is the first public release of DoIt Website: http://python-doit.sourceforge.net/ Release: DoIt 0.1.0 License: MIT About ----- DoIt is a build tool that focus not only on making/building things but on executing any kind of tasks in an efficient way. Designed to be easy to use and "get out of your way". DoIt like most build tools is used to execute tasks defined in a configuration file. Configuration files are python modules. The tasks can be python functions (or any callable) or an external shell script. DoIt automatically keeps track of declared dependencies executing only tasks that needs to be update (based on which dependencies have changed). In DoIt, unlike most(all?) build-tools, a task doesn't need to define a target file to use the execute only if not up-to-date feature. This make DoIt specially suitable for running test suites. DoIt can be used to perform any task or build anything, though it doesn't support automatic dependency discovery for any language. Cheers, Eduardo From uniontelecardsindia at gmail.com Tue Apr 22 17:12:56 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:12:56 -0700 (PDT) Subject: Extreme moresome black gay groupsex Message-ID: <44833c7d-efb5-42ab-a2be-1b9584c04a8e@59g2000hsb.googlegroups.com> Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From sturlamolden at yahoo.no Sat Apr 19 13:39:01 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sat, 19 Apr 2008 10:39:01 -0700 (PDT) Subject: why function got dictionary References: <48075950.7050000@gmail.com> Message-ID: On Apr 17, 4:06 pm, AlFire wrote: > Q: why function got dictionary? What it is used for? As previously mentioned, a function has a __dict__ like (most) other objects. You can e.g. use it to create static variables: int foobar() { static int i = 0; return i++; } is roughly equivalent to: def foobar(): foobar.i += 1 return foobar.i foobar.i = 0 From gruszczy at gmail.com Fri Apr 25 12:23:43 2008 From: gruszczy at gmail.com (=?UTF-8?Q?Filip_Gruszczy=C5=84ski?=) Date: Fri, 25 Apr 2008 18:23:43 +0200 Subject: Explicit variable declaration In-Reply-To: <1209101024.201741@chilli.pcug.org.au> References: <1506f165-7f86-4dc7-aa29-6488eda9ae7f@l64g2000hse.googlegroups.com> <5e59998b-d2e7-48cb-824b-84620f95c9bc@w5g2000prd.googlegroups.com> <1209101024.201741@chilli.pcug.org.au> Message-ID: <1be78d220804250923s26b86abaua31ac77d049eb014@mail.gmail.com> > In Python the standard patten for "declaring" variables is just to assign to > them as they are needed. If you want the effect of a declaration as you > would do in C, you can just define the variable and initialize it to 0 or > None. (Or {} for a new dictionary, or [] for a new list.) Yep, I get it and I absolutely love this about Python. What I don't actually love is situation, where I misspell and instead of setting one variable, other is created. This is why I would like to declare variables first and say, that these are the only ones, that can be set in certain function (the same with fields in a class). I am finishing a small tool, that allows to create such declarations in similar manner to Smalltalk declarations. I hope I can post a link to it soon. -- Filip Gruszczy?ski From grahn+nntp at snipabacken.se Mon Apr 21 18:26:57 2008 From: grahn+nntp at snipabacken.se (Jorgen Grahn) Date: 21 Apr 2008 22:26:57 GMT Subject: Java or C++? References: Message-ID: On Mon, 21 Apr 2008 06:14:08 -0700 (PDT), NickC wrote: > On Apr 15, 1:46 pm, Brian Vanderburg II > wrote: >> This will automatically call the constructors of any contained objects >> to initialize the string. The implicit assignment operator >> automatically performs the assignment of any contained objects. >> Destruction is also automatic. When 'p1' goes out of scope, during the >> destructor the destructor for all contained objects is called. > > Yeah, C++ does try to be helpful, and all of those automatic copy > constructor, assignment operator and destructor implementations screw > up royally when confronted with pointers I think that those are newbie problems. The rules for those three "default implementations" are simple and match what C does for structs. Use the standard containers, make a habit of forbidding copying of objects which make no sense copying, and remember the "explicit" keyword, and you will rarely have problems with this. > (and being able to use > pointers is basically the whole reason for bothering to write anything > in C or C++ in the first place). Is it? I rarely use pointers in C++ as anything but a kind of object reference, and mostly because I am forced to. I use C++ because it is an expressive language with static typing, which has access to all the hundreds of libraries with a C API on my (Unix) machine. And because it is fun to use. I use Python because it is an expressive language with dynamic typing, which has access to the most important libraries with a C API on my (Unix) machine. And because it is fun to use. > Code which relies on these default > method implementations is almost certain to be rife with memory leaks > and double-free bugs. So instead of being a convenience, they become a > painfully easy way of writing code that silently does some very, very > wrong things. I have worked with old code with those kinds of bugs. It's simple to check and fix. If a class has pointer members of the Has-A type, the constructors, operator= and destructor have to handle them (or be suppressed). If they don't, the code is broken. If you grasp the concept of invariants, it's hard to get wrong. An object of type Foo has a number of valid states. You have to make sure there are no ways to create a Foo which is in an invalid state, or destroying one without cleaning up its state. The best way is usually to construct it from members which make similar guarantees, e.g. the standard containers. > Other things like methods (including destructors!) being non-virtual > by default also make C++ code annoyingly easy to get wrong (without it > obviously looking wrong). The other side of the coin is that you can write tiny classes in C++ with *no overhead*. If my class Foo can be implemented as an integer, it doesn't need to be slower or take more space than an integer. It can have value semantics, live on the stack etc, like an integer. I assume Java programmers avoid such types, and I assume it decreases type safety in their programs. Ok, it could have been the other way around so that there was a "nonvirtual" keyword ... but on the other hand I use inheritance in C++ about as often as in Python, i.e. almost never. > The whole design of C++ is riddled with premature optimisation of > speed and memory usage in the default settings, instead of choosing > safe defaults and providing concise ways of allowing the programmer to > say "I know optimisation X is safe here, please use it". "Premature optimization" is a phrase which is always useful as a weapon, isn't it? But yeah, I think we can agree about this, at least: when you program in both Python and C++, it is painfully obvious that C++ never sacrifices speed or correctness, and it is painfully obvious that the programmer pays a price for this. Compare ... maybe, for example, the C++ standard library's very detailed and general iterator and algorithm concepts with things like Python's str.split and str.join. A function which takes a list of strings plus a delimiter and returns a string would be unthinkable in the C++ standard library. > That said, C++ code has one *huge* benefit over ordinary C code, which > is scope-controlled deletion of objects, and the associated Resource- > Acquisition-Is-Initialisation model. Yes, RAII is one big advantage over any other language I know of. Compared to good old C, I can come up with many others. I was going to say something about C++ versus Java here, but the fact is I haven't written more than a few pages of Java since it came out. The language (or the culture around it) seems to want to isolate itself from the rest of the world -- unlike C++ and Python. /Jorgen -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! From rorymckinleylists at gmail.com Sat Apr 5 16:37:57 2008 From: rorymckinleylists at gmail.com (Rory McKinley) Date: Sat, 05 Apr 2008 22:37:57 +0200 Subject: Weird scope error In-Reply-To: <47F7A41C.4090402@islandtraining.com> References: <47F79A78.4010207@gmail.com> <47F7A41C.4090402@islandtraining.com> Message-ID: <47F7E325.9060603@gmail.com> Gary Herron wrote: > Python has no such thing as this kind of a "global scope". (True, each > module has its own global scope, but that's not what you are talking > about.) So you'll have to fix the import for *every* module that needs > access to ElementTree. You might make the change as you mentioned > above for each, but really, I think you should just make ElementTree > directly importable by either installing it normally or including > .../xml/etree in your PYTHONPATH Thank you Gary and Kay for the response My apologies for being dense with regard to this: If I understand your responses correctly, the "from xml.etree import ElementTree" that I inserted is failing? And that is why I am getting the NameError in the method? Is Python just ignoring the failure? Rory From lists at cheimes.de Thu Apr 24 09:00:06 2008 From: lists at cheimes.de (Christian Heimes) Date: Thu, 24 Apr 2008 15:00:06 +0200 Subject: How to get inner exception traceback In-Reply-To: <09ce6c51-3c23-4fb7-a369-d357c0f5d287@m73g2000hsh.googlegroups.com> References: <67b8nuF2m1a1kU1@mid.individual.net> <09ce6c51-3c23-4fb7-a369-d357c0f5d287@m73g2000hsh.googlegroups.com> Message-ID: <48108456.2020405@cheimes.de> bockman at virgilio.it schrieb: > On 24 Apr, 13:20, Thomas Guettler wrote: >> Hi, >> >> How can you get the traceback of the inner exception? >> >> try: >> try: >> import does_not_exit >> except ImportError: >> raise Exception("something wrong") >> except: >> ... >> >> Background: In Django some exceptions are caught and a new >> exception gets raised. Unfortunately the real error is hard >> to find. Sometimes I help myself and change (in this example) >> ImportError to e.g. IOError and then I can see the real root >> of the problem. But maybe there is a way to get the inner >> exception and its traceback. This could be displayed in the >> debug view. >> >> Thomas >> >> -- >> Thomas Guettler,http://www.thomas-guettler.de/ >> E-Mail: guettli (*) thomas-guettler + de > > I'm not sure it ill work since sys.exc_info() might not return a deep > copy of the traceback info, > but you could try to store the inner exception and its traceback as > attributes of the outer exception: > > class ReraisedException(Exception): > def __init__(self, message, exc_info): > Exception.__init__(self, message) > self.inner_exception = exc_info > > try: > try: > import does_not_exit > except ImportError: > raise ReraisedException("Something wrong", sys.exc_info() ) > except ReraisedException, e: > ... # here you can use e.inner_exception > except: This may lead to reference cycles, please read http://docs.python.org/dev/library/sys.html#sys.exc_info Christian From mcat.schaefer at gmx.de Tue Apr 8 05:02:17 2008 From: mcat.schaefer at gmx.de (=?ISO-8859-1?Q?Michael_Sch=E4fer?=) Date: Tue, 8 Apr 2008 02:02:17 -0700 (PDT) Subject: Calling CVF-Fortran-dll with ctypes and simple structure References: <60915c2d-0c0d-42fc-8b02-5fb58e13a20c@p25g2000hsf.googlegroups.com> Message-ID: Gabriel, works perfect - even in complex nested structures! Thank you very much! > (If both Fortran and VB say "char*9", why did you choose a pointer here?) I do not know this possibility. Could you please drop me a few lines? -- Michael From fr5478bey at gmail.com Sat Apr 26 11:41:43 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:41:43 -0700 (PDT) Subject: vegas crack Message-ID: <70012696-bc78-4342-82ec-7891f0150278@a23g2000hsc.googlegroups.com> vegas crack http://cracks.00bp.com F R E E C R A C K S From m.otteneder at gmail.com Mon Apr 7 12:05:57 2008 From: m.otteneder at gmail.com (mc) Date: Mon, 7 Apr 2008 09:05:57 -0700 (PDT) Subject: Mathematical Python Library Message-ID: I'm looking for a library which can do mathematical stuff like solving equations. Or calculation the nulls of a function and so on. Does anyone know one? Thanks in advance! From bbxx789_05ss at yahoo.com Sun Apr 6 18:12:37 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sun, 6 Apr 2008 15:12:37 -0700 (PDT) Subject: Tkinter, a lot of buttons, make prog shorter? References: Message-ID: <688483d9-2c6a-4e2a-b64d-f32bb27699ec@p25g2000hsf.googlegroups.com> On Apr 6, 1:59?pm, skanem... at yahoo.se wrote: > is there anyway to make this shorter? i hate having these big blocks > of similar-looking code, very unaesthetic. > maybe doesnt matter good-code-wise? > anyway can i make some function that makes this shorter? > like put the etiquettes on the button froma string of > '123+456-789*0Cr/' ? > problem is the command and lambda-func for each button is different. > > ? ? ? ? self.btnDisplay = Button(self,text='1',command=lambda > n="1":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=3, column=0) > > ? ? ? ? self.btnDisplay = Button(self,text='2',command=lambda > n="2":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=3, column=1) > > ? ? ? ? self.btnDisplay = Button(self,text='3',command=lambda > n="3":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=3, column=2) > > ? ? ? ? self.btnDisplay = Button(self,text='+',command=lambda > n="+":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=3, column=3) > > ? ? ? ? self.btnDisplay = Button(self,text='4',command=lambda > n="4":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=4, column=0) > > ? ? ? ? self.btnDisplay = Button(self,text='5',command=lambda > n="5":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=4, column=1) > > ? ? ? ? self.btnDisplay = Button(self,text='6',command=lambda > n="6":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=4, column=2) > > ? ? ? ? self.btnDisplay = Button(self,text='-',command=lambda > n="-":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=4, column=3) > > ? ? ? ? self.btnDisplay = Button(self,text='7',command=lambda > n="7":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=5, column=0) > > ? ? ? ? self.btnDisplay = Button(self,text='8',command=lambda > n="8":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=5, column=1) > > ? ? ? ? self.btnDisplay = Button(self,text='9',command=lambda > n="9":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=5, column=2) > > ? ? ? ? self.btnDisplay = Button(self,text='*',command=lambda > n="*":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=5, column=3) > > ? ? ? ? self.btnDisplay = Button(self,text='0',command=lambda > n="0":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=6, column=0) > > ? ? ? ? self.btnDisplay = > Button(self,text='C',command=self.Clean,width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=6, column=1) > > ? ? ? ? self.btnDisplay = Button(self,text='r',command=lambda > n="r":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=6, column=2) > > ? ? ? ? self.btnDisplay = Button(self,text='/',command=lambda > n="/":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=6, column=3) You said you were an experienced programmer, but you keep posting code with the same mistakes over and over again. Why are you attaching the buttons to self? From paul.anton.letnes at gmail.com Thu Apr 10 01:57:56 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Thu, 10 Apr 2008 07:57:56 +0200 Subject: wrapping C functions in python In-Reply-To: <54b165660804091355m1326f7c0g1a5eebe3d6b5a1df@mail.gmail.com> References: <54b165660804091322w690e5e64x85c3d8f082b411b2@mail.gmail.com> <54b165660804091355m1326f7c0g1a5eebe3d6b5a1df@mail.gmail.com> Message-ID: <1C8AE033-9B8F-4514-8C52-3462CF6447A2@gmail.com> Brian and Diez: First of all, thanks for the advice. Brian: I have installed NumPy and SciPy, but I can't seem to find a wavelet transform there. The main point of this was more to learn C wrapping than to actually get a calculation done. I will probably be starting a PhD soon, doing really heavy computations. If I want to manipulate data (input / results), python is very nice, especially with gnuplot-py. However, heavy calculations should probably be done in C(++), especially as some code for this already exists. I will look into SWIG. Diez: I will look into it. Do you know a good tutorial for this? I found the "standard" tutorial on C extensions, http://www.python.org/doc/ext/intro.html , but as I mentioned, it seems to be a bit complicated to wrap heavy data structures like arrays. Cheers PA. From castironpi at gmail.com Fri Apr 25 00:43:42 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Thu, 24 Apr 2008 21:43:42 -0700 (PDT) Subject: Little novice program written in Python References: Message-ID: <766ad2f7-08ce-47b8-9c10-19aca9059b16@d45g2000hsc.googlegroups.com> On Apr 24, 11:09?pm, Dennis Lee Bieber wrote: > On Thu, 24 Apr 2008 21:31:15 -0300, Rog?rio Brito > declaimed the following in comp.lang.python: > > > a = [i for i in range(0,n+1)] > > ? ? ? ? Uhm... At least in 2.4 and earlier, range() returns a list... No > need for the list-comp in that era... range() also begins with 0 > > > > >>> n = 5 > >>> a = range(n+1) > >>> a > [0, 1, 2, 3, 4, 5] > > ? ? ? ? So just > > ? ? ? ? a = range(n+1) > > could be used. Of course, if using a version where range() and xrange() > have been unified... > > >>> c = list(xrange(n+1)) > >>> c > [0, 1, 2, 3, 4, 5] > > -- > ? ? ? ? Wulfraed ? ? ? ?Dennis Lee Bieber ? ? ? ? ? ? ? KD6MOG > ? ? ? ? wlfr... at ix.netcom.com ? ? ? ? ? ? ?wulfr... at bestiaria.com > ? ? ? ? ? ? ? ? HTTP://wlfraed.home.netcom.com/ > ? ? ? ? (Bestiaria Support Staff: ? ? ? ? ? ? ? web-a... at bestiaria.com) > ? ? ? ? ? ? ? ? HTTP://www.bestiaria.com/ You're talking hardware-native, which machines don't guarantee. Python can in another dimension of machine compatibility. Stacks are hardware native, the location of an array is not. Python can retrieve your stack in higher dimensions. Fortunately, Python's community is sturdy against counterproductivity en masse, so it's okay to hairbrain it. Cover features of improvements, though, and you might get a Bayes Net change to make and courses to steer. The community values the flexibility of machine- independency too. However, real numbers are not integers, so opinion mass of integer algorithms may favor C. But you just need micro-sales (and scales!) to examine the future of Python. Welcome to our group. From ch612bunn at gmail.com Sun Apr 27 09:20:44 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:20:44 -0700 (PDT) Subject: Alcohol 120% 1.9.6.5429 crack Message-ID: Alcohol 120% 1.9.6.5429 crack http://wga-cracks.crackkey.net From charleshixsn at earthlink.net Sun Apr 13 14:18:58 2008 From: charleshixsn at earthlink.net (Charles D Hixson) Date: Sun, 13 Apr 2008 11:18:58 -0700 Subject: class level properties In-Reply-To: References: Message-ID: <48024E92.2090608@earthlink.net> Peter Otten wrote: > Charles D Hixson wrote: > > >> I want a hundred or so read-only variables, and I'm not sure the best >> way to achieve it. >> > > What do you really want to do? I recommend that you forget about bondage and > rely upon displine: > > class Test(object): > """Never change an attribute with an uppercase name.""" > SIMPLE = "simple example working" > > Now that was easy... > > Peter > > What I'm doing it translating Java code which has a large number of "public static final (type)" variables. As to your answer ... yes, and with good discipline you can write object oriented code in C and never need a garbage collector. It's *not* a good answer. Before I'd chose that one, I'd make it necessary to instantiate the class before testing the value of it's constants. It's just that that seems to be a silly requirement, so I'd like to avoid it. (That's the "solution" that I currently have working with __getattr__.) From gherron at islandtraining.com Fri Apr 25 14:40:23 2008 From: gherron at islandtraining.com (Gary Herron) Date: Fri, 25 Apr 2008 11:40:23 -0700 Subject: Why is None <= 0 In-Reply-To: References: Message-ID: <48122597.9090909@islandtraining.com> Gregor Horvath wrote: > Hi, > > >>> None <= 0 > True > > Why? > Is there a logical reason? > > Gregor > -- > http://mail.python.org/mailman/listinfo/python-list In early Python, the decision was made that the comparison of *any* two objects was legal and would return a consistent result. So objects of different types will compare according to an ordering on their types (an implementation dependent, unspecified, but consistent ordering), and objects of the same type will be compared according to rules that make sense for that type. Other implementations have the right to compare an integer and None differently, but on a specific implementation, the result will not change. Python 3 will raise an exception on such comparisons. Gary Herron From webograph at eml.cc Sat Apr 26 20:48:22 2008 From: webograph at eml.cc (webograph) Date: Sun, 27 Apr 2008 02:48:22 +0200 Subject: Why can't timedeltas be divided? In-Reply-To: <200605251402.15646.maric@aristote.info> References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> Message-ID: <4813CD56.40800@eml.cc> On Thu, 25 May 2006, maric wrote: > > The ratio of two durations has no meaning??? > Oh, sorry, sure it has, I wanted to say "it has no meaning in timedelta provided arithmetic". > It's a ratio (no dimension) not a duration. In that sense the expected result should be a float, and the proposed operator will break the timedelta's arithmetic consistence. > > t, u, v <- timedeltas > t+u # valid > t / u # valid > t / u + v # invalid while all terms are valids > why is this a problem? not every structure has to form a closed mathematical field, and there are other cases in which dividing similar values yields another structure (think of calculating `factor = speed2/speed1; distance2 = factor * distance1`) is there any hope this can be fixed? defining timedelta/timedelta division could not break existing code because no such division is defined yet. > num_weeks = (time_diff.days * 24* 3600 + time_diff.seconds) / (7.*24*3600) this requires domain knowledge i'd expect a time structure to provide! as you can create a timedelta by timedelta(seconds=1234567), i think it is not too much to ask to have some simple way to get back the 1234567 seconds without thinking about what intervals (currently days, seconds and microseconds) are used internally. sorry for bringing up such an old thread, but this seems important to me -- up to now, there are thousands [1] of python programs that use hardcoded time calculations. regards webograph [1] http://www.google.com/codesearch?q=60|3600+24+timedelta+lang%3Apython (gave me about 2000) From sn at sncs.se Fri Apr 18 01:41:13 2008 From: sn at sncs.se (Sverker Nilsson) Date: Thu, 17 Apr 2008 22:41:13 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <66q33cF2krjf2U1@mid.uni-berlin.de> <4807dceb$1@news.mel.dft.com.au> Message-ID: <4d823ed4-d275-4d68-a4af-873b015c431d@m44g2000hsc.googlegroups.com> On Apr 18, 1:27 am, John Machin wrote: > Diez B. Roggisch wrote: > >> And I have been benefiting from Python in general, so far. Thanks, > >> community. > > >> But now... I'll probably stop posting here for now, & I may stop other > >> things too. > > >> Just my 2c. > > > You know what I was just wondering about? All these C-written > > cross-platform libraries (which Python users benefit from, most probably > > including evven you) that run on different unixes & windows, which are a > > much greater diversity to handle than the not-even-yet-settled > > differences between Py3K & 2.x. How the heck do they do that? > > > Oh, and these dreaded 64 bit processors, possibly with multi-cores, > > which need changes in code as well, to be utilized to their power. > > > But then, these guys most probably don't whine about diversity and > > constant change, and cry out useless threats to people who probably > > can't care less. > > > Fare well, if you must. But getting mad over something which impact you > > can't even judge right now is childish. Nothing else. > > At the start of this thread I was pondering the possible meaning of the > verb "to sverk". Thanks for the exposition, Diez. Yah, and I am getting all the more depressed. Thanks? From R.Brodie at rl.ac.uk Thu Apr 17 11:55:37 2008 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Thu, 17 Apr 2008 16:55:37 +0100 Subject: Unicode chr(150) en dash References: <48063434$0$36327$742ec2ed@news.sonic.net> Message-ID: wrote in message news:mailman.595.1208445083.17997.python-list at python.org... > I think I understand the unicode basic principles, what confuses me is the usage > different applications > make out of it. > > For example, I got that EN DASH out of a web page which states > at the beggining. That's why I did go for > that > encoding. But if the browser can properly decode that character using that encoding, > how come > other applications can't? Browsers tend to guess what the author intended a lot. In particular, they fudge the difference between ISO8859-1 and Windows-1252. http://en.wikipedia.org/wiki/Windows-1252 From cwitts at gmail.com Tue Apr 15 07:26:08 2008 From: cwitts at gmail.com (Chris) Date: Tue, 15 Apr 2008 04:26:08 -0700 (PDT) Subject: where is pythoncard program ? References: Message-ID: On Apr 15, 1:04?pm, bvidinli wrote: > i installed pythoncard, but i could not find how to start it ? > where can i find its executable/binary ? > or menu item ? > or command line that i should ?enter ? > > thanks. > > -- > ?.Bahattin Vidinli > Elk-Elektronik M?h. > ------------------- > iletisim bilgileri (Tercih sirasina gore): > skype: bvidinli (sesli gorusme icin,www.skype.com) > msn: bvidi... at iyibirisi.com > yahoo: bvidinli > > +90.532.7990607 > +90.505.5667711 If you installed it on a windows box it creates a folder for it Start - > Programs -> PythonCard. The files by default are located under PythonX.x\Lib\site-packages\PythonCard From istvan.albert at gmail.com Tue Apr 22 10:22:13 2008 From: istvan.albert at gmail.com (Istvan Albert) Date: Tue, 22 Apr 2008 07:22:13 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> On Apr 22, 6:25 am, azrael wrote: > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. > This hurts. Please give me informations about realy famous > aplications. you could show him what Master Yoda said when he compared Python to Perl http://www.personal.psu.edu/iua1/pythonvsperl.htm i. From d.bollmann at tu-berlin.de Wed Apr 23 05:48:33 2008 From: d.bollmann at tu-berlin.de (Dietrich Bollmann) Date: Wed, 23 Apr 2008 18:48:33 +0900 Subject: Error in Extending/Embedding FAQ, point 16: How do I tell "incomplete input" from "invalid input"? In-Reply-To: <1208880579.4557.70.camel@pippi.pippi> References: <1208877167.4557.37.camel@pippi.pippi> <1208880579.4557.70.camel@pippi.pippi> Message-ID: <1208944113.4294.32.camel@pippi.pippi> Hi, I found a solution thanks to another posting on c++-sig and an answer by Andreas Kl?ckner :) Thank you, Andreas! The thread is here: http://mail.python.org/pipermail/c++-sig/2008-April/thread.html#13470 I would like to inform the responsible of the Python Extending/Embedding FAQ, http://www.python.org/doc/faq/extending/ about the broken code in the FAQ and the solution I found. I hope this might prevent other people from the frustration I found myself in this morning (...but unfortunately also, at least partly, from the joy I am experiencing now, after finding the new solution :). Does anybody know how to contact the person in charge? Thanks, Dietrich PS: Of course, I still wonder about the "invalid syntax" error message / code I wrote about. But ok, I hope there will be some more adequate error message / code some day in the future :) On Wed, 2008-04-23 at 01:09 +0900, Dietrich Bollmann wrote: > On Wed, 2008-04-23 at 00:12 +0900, Dietrich Bollmann wrote: > > The following code for example: > > > > >>> eins = [1, > > ... 2, > > ... 3] > > >>> > > > > is accepted without any problem by the Python shell. > > > > When using the code from the FAQ and entering it line by line > > ?already the second line causes a simple "invalid syntax" error: > > > > >>> eins = [1, > > ... 2, > > File "", line 2 > > 2, > > ^ > > SyntaxError: invalid syntax > > By the way - isn't this error message / error code just "wrong" in > the given situation and therefor kind of a "bug"? > > An "end of file" or "incomplete input" error at least would > describe the situation much better - and be a better base for > functionality which is based the error code also. > > --- > > I also thought that I should explain a little bit more exactly, > what I am intending to do with the code based on > paragraph 16 (How do I tell "incomplete input" from "invalid input"?) > of the Extending/Embedding FAQ: > > I am using Python as scripting language in an application (blender). > In order to interface this application from other programs > I programmed a python command port / command socket > for this application. > > Between other clients I also wrote a shell client which connects via > the command port to the application. My goal is to make it as similar > to a normal python shell as possible - and therefor I try to also mimic > the "intelligent" way of the Python shell to react to Python input: > > - when entering a line which is a complete input, > it is immediately evaluated by the shell and the > result is printed. > > - when the last entered line is erroneous, > an error message is printed immediately > > - when the input is incomplete, Python waits > for other lines to complete the input > > - when the line is part of a function definition etc. > python waits until an empty line is entered > before accepting the input as complete. > > My problem is to understand when an input is erroneous and > when it is incomplete - which is impossible with an error message > like "invalid syntax"... > > So here again my question: How can I make the difference > between an incomplete and an erroneous input? > > The code examples in the FAQ worked fine until now - but do not > anymore for the current Python implementation. > > Thanks, Dietrich > > By the way: Does anybody know who is responsible for the FAQ > and could adapt the examples to the current Python version > by changing the code / annotating it? > > > On Wed, 2008-04-23 at 00:12 +0900, Dietrich Bollmann wrote: > Hi, > > > > Both code examples from paragraph 16 from the Python Extending / > > Embedding FAQ - 'How do I tell "incomplete input" from "invalid > input"?' > > - > > > ( http://www.python.org/doc/faq/extending/#how-do-i-tell-incomplete-input-from-invalid-input ) do not work with the current state of Python anymore. > > > > In the second code example, the error message returned by Python is > > checked in order to differentiate errors caused by an incomplete input > > from other syntax errors: > > > > if (PyArg_ParseTuple (val, "sO", &msg, &obj) && > > !strcmp (msg, "unexpected EOF while parsing")) /* E_EOF */ > > > > In the current Python version there are more error messages indicating > an > > incomplete Python input and I could make the code work for a while > > by adding the following strings to the condition: > > > > /* error messages indicating an incomplete input */ > > if (PyArg_ParseTuple(error, "sO", &message, &obj) && > > (!strcmp(message, "unexpected EOF while parsing") || > > !strcmp(message, "expected an indented block") || > > !strcmp(message, "EOF while scanning triple-quoted string") > > ) > > ) { /* E_EOF */ > > > > but recently there are also cases which generate error messages > > which are too general to be added to this list. > > > > The following code for example: > > > > >>> eins = [1, > > ... 2, > > ... 3] > > >>> > > > > is accepted without any problem by the Python shell. > > > > When using the code from the FAQ and entering it line by line > > ?already the second line causes a simple "invalid syntax" error: > > > > >>> eins = [1, > > ... 2, > > File "", line 2 > > 2, > > ^ > > SyntaxError: invalid syntax > > > > which is to general to be integrated into the list of tested > > error messages as it might be caused also by code like: > > > > >>> one two > > File "", line 1 > > one two > > ^ > > SyntaxError: invalid syntax > > > > which generates an "invalid syntax" error even in the Python shell. > > > > I also tried the first code example of paragraph > > '16 How do I tell "incomplete input" from "invalid input"?' > > of the FAQ in order to see if it could be used to make the > > difference between syntax errors and incomplete code errors. > > But - as in the case before - the returned error > > code is E_SYNTAX (14 = Syntax error) and not E_EOF (11 = End Of File) > > as should be expected. > > > > Is there anybody who has an idea how to differentiate the > > first case from the second in order to mimic the behaviour of > > the Python shell from c code? > > > > If this shouldn't be possible lists split into different lines > > couldn't be accepted anymore or the feature of the Python shell > > to described in paragraph 16 of the faq: > > > > Sometimes you want to emulate the Python interactive interpreter's > > behavior, where it gives you a continuation prompt when the input > > is incomplete (e.g. you typed the start of an "if" statement or you > > didn't close your parentheses or triple string quotes), but it > gives > > you a syntax error message immediately when the input is invalid. > > > > would have to be given up and every entered line of code would have > to > > be terminated by an empty line before evaluation :( > > > > Thanks for any help, Dietrich > > > > > > > > > > From roy at panix.com Wed Apr 23 00:56:37 2008 From: roy at panix.com (Roy Smith) Date: Wed, 23 Apr 2008 00:56:37 -0400 Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: In article , Steve Holden wrote: > Challenge him to a dual with dead kippers at twenty paces. You gotta be careful about stuff like this. You might slap him with a dead kipper only to discover he's got a dead camel in his pocket. Of course, there's always http://en.wikipedia.org/wiki/Wikipedia:Trout From deets at nospam.web.de Tue Apr 29 19:43:04 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 30 Apr 2008 01:43:04 +0200 Subject: python command mis-interprets arrow keys In-Reply-To: References: <67pp4oF2ppl3sU1@mid.uni-berlin.de> Message-ID: <67pq47F2plmb8U1@mid.uni-berlin.de> Rahul schrieb: > "Diez B. Roggisch" wrote in > news:67pp4oF2ppl3sU1 at mid.uni-berlin.de: > >> Is libreadline installed? > > Thanks for your help Diez. I did a locate and found: > > /usr/lib/libreadline.a > /usr/lib/libreadline.so > /usr/lib/libreadline.so.5 > /usr/lib/libreadline.so.5.1 > /usr/local/src/Python-2.4.4/Doc/lib/libreadline.tex > > Any better way to check? The question is if python is build with readline support. Did the python version work before, and somehow got messed up, or did you build it yourself and it never actually worked? If it's the latter case, you might try & install a possible readline-dev-package (or whatever it is called on red hat), and build again, cautiously monitoring if readline is picked up from the build-process. Diez From thinkofwhy at yahoo.ca Sun Apr 27 14:29:46 2008 From: thinkofwhy at yahoo.ca (telus news) Date: Sun, 27 Apr 2008 18:29:46 GMT Subject: diffing and uniqing directories In-Reply-To: References: <67ioqmF2nvf5vU2@mid.uni-berlin.de> Message-ID: Just so happens that I am partially finished a gui file backup app. I have many backup CDs and I wanted to consolidate them. You know, all image files in one dir, all install files in another dir, etc. My app scans the input dir tree and displays all file extensions that it finds. You can then remove any extensions that you don't want backed-up, and you can toggle to exclude the listed extensions. It also calculates min/max file sizes that you can adjust. Then the next page allows you to adjust the sub-dir depth with a slider, which displays the total number of files and total amount of memory they will take, for each sub-dir depth. You can also choose to enable versioning, whether or not to put all files into one dir or create a dir for each file type (extension), whether or not to actually backup the files, to write all input pathnames and/or output pathnames to a file. Of course, it won't backup a dir tree as a copy, it can only flatten a dir tree, so if you backup a development source dir, all files will get put into the same dir and that wouldn't be good. I've also used py2exe to make it a drag-n-drop install. What do you think? wrote in message news:bf7b9788-c108-4dad-bffe-49ff8e12bcb4 at a22g2000hsc.googlegroups.com... On Apr 27, 2:37 am, Marc 'BlackJack' Rintsch wrote: > On Sat, 26 Apr 2008 20:35:29 -0700, rustom wrote: > > On Apr 27, 12:31 am, castiro... at gmail.com wrote: > >> On Apr 26, 1:14 pm, "Rustom Mody" wrote: > >> [?] > > > If this is an answer to my question I dont understand it! > > castironpi is either a bot or trolling. Just ignore its posts. > > Ciao, > Marc 'BlackJack' Rintsch I am a bot or trolling. Bots and bot detectors were the first forms of internet life, you know. From nagle at animats.com Wed Apr 16 16:21:46 2008 From: nagle at animats.com (John Nagle) Date: Wed, 16 Apr 2008 13:21:46 -0700 Subject: Default parameter for a method In-Reply-To: <806788d2-67b7-456b-bd1e-08c50cbf0f7b@8g2000hsu.googlegroups.com> References: <806788d2-67b7-456b-bd1e-08c50cbf0f7b@8g2000hsu.googlegroups.com> Message-ID: <48065d11$0$36390$742ec2ed@news.sonic.net> s0suk3 at gmail.com wrote: > I wanted to know if there's any way to create a method that takes a > default parameter, and that parameter's default value is the return > value of another method of the same class. For example: > ... > > def meth2(self, arg=meth1()): Not good. If the default value of an argument is mutable, there are wierd effects, because the default value is bound once when the class is created, then shared between all later uses. This is almost never what was wanted or intended, and it's a common source of subtle bugs. In general, default values should be immutable constants only. There's been talk of fixing this (it's really a design bug in Python), but for now, it's still broken. (I just had horrible thoughts about the implications of binding a closure to a default argument. You don't want to go there.) John Nagle From ch612bunn at gmail.com Sun Apr 27 09:16:29 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:16:29 -0700 (PDT) Subject: kaspersky 7 crack Message-ID: kaspersky 7 crack http://wga-cracks.crackkey.net From kkuhl05 at gmail.com Tue Apr 29 01:26:33 2008 From: kkuhl05 at gmail.com (Kevin K) Date: Mon, 28 Apr 2008 22:26:33 -0700 (PDT) Subject: File IO Issues, help :( Message-ID: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> Hey everyone, I'm new to python and am trying to do a little project with it. I'm running into problems writing over a file. I read from the file and loop through for a specfic case in which I change something. After I open and give it opening options (w, r, etc) one of two things happens: either the file gets truncated and my writing never takes place (or it seems it doesnt) or everything is appended to the file and I have a double of what I started with, its never just the updated file. Can someone shed some light on this for me?? Code below: jsfile = open("../timeline.js", "r+") jscontent = jsfile.readlines() jsfile.truncate() for line in jscontent: if re.search('var d =', line): line = "var d = \""+mint['1'].ascdate()+"\"\n" print line jsfile.write(line) From fetchinson at googlemail.com Wed Apr 16 12:11:09 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Wed, 16 Apr 2008 09:11:09 -0700 Subject: Finally had to plonk google gorups. In-Reply-To: <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: > > > On Apr 16, 9:19 am, Grant Edwards wrote: > > >> This morning almost half of c.l.p was spam. In order to try to > > >> not tar both the benign google group users and the malignant > > >> ones with the same brush, I've been trying to kill usenet spam > > >> with subject patterns. But that's not a battle you can win, so > > >> I broke down and joined all the other people that just killfile > > >> everything posted via google.groups. > > > > >> AFAICT, if you're a google groups user your posts are not being > > >> seen by many/most experienced (read "non-google-group") users. > > >> This is mainly the fault of google who has refused to do > > >> anything to stem the flood of span that's being sent via Google > > >> Groups. > > > > >> -- > > >> Grant Edwards grante Yow! I would like to > > >> at urinate in an > OVULAR, > > >> visi.com porcelain pool -- > > > > > Yeah, I noticed that Google Groups has really sucked this week. I'm > > > using the Google Groups Killfile for Greasemonkey now and it helps a > > > lot. I like Google, but my loyalty only goes to far. This is a > > > complete lack of customer service. > > > > Unfortunately this means Google groups users are getting exactly the > > service they are paying for. > > > > regards > > Steve > > -- > > Steve Holden +1 571 484 6266 +1 800 494 3119 > > Holden Web LLC http://www.holdenweb.com/ > > Steve, > > My workplace doesn't offer NNTP, so there is no good way to browse > c.l.py here. And I haven't been able to get NNTP to work from my home > either. > > By applying this logic to Python and Linux (or any Open Source > product), they shouldn't be used either (since I'm not paying for > them). > > Mike Mike, Steve did not say you (or anyone) should not use google groups. He said you get what you paid for, which is certainly the case. Some open source products are good and some are worse, that's all. Full disclosure: I'm using google groups for both reading and writing. Cheers, Daniel From ajaksu at gmail.com Tue Apr 15 10:37:27 2008 From: ajaksu at gmail.com (ajaksu) Date: Tue, 15 Apr 2008 07:37:27 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> Message-ID: On Apr 14, 11:07?pm, Sverker Nilsson wrote: > What serious reports? You almost had me collecting a list of reports/references. Almost :) Google and you'll find them. Regards, Daniel From mfb.chikazuku at gmail.com Wed Apr 9 17:43:45 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Wed, 09 Apr 2008 23:43:45 +0200 Subject: Stripping scripts from HTML with regular expressions References: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: <47fd46b3$0$6838$2d805a3e@textnews.eweka.nl> Reedick, Andrew wrote: > > >> -----Original Message----- >> From: python-list-bounces+jr9445=att.com at python.org [mailto:python- >> list-bounces+jr9445=att.com at python.org] On Behalf Of Michel Bouwmans >> Sent: Wednesday, April 09, 2008 3:38 PM >> To: python-list at python.org >> Subject: Stripping scripts from HTML with regular expressions >> >> Hey everyone, >> >> I'm trying to strip all script-blocks from a HTML-file using regex. >> >> I tried the following in Python: >> >> testfile = open('testfile') >> testhtml = testfile.read() >> regex = re.compile(']*>(.*?)', re.DOTALL) > > > Aha! \b is being interpolated as a backspace character: > \b ASCII Backspace (BS) > > Always use a raw string with regexes: > regex = re.compile(r']*>(.*?)', re.DOTALL) > > Your regex should now work. > > > > ***** > > The information transmitted is intended only for the person or entity to > which it is addressed and may contain confidential, proprietary, and/or > privileged material. Any review, retransmission, dissemination or other > use of, or taking of any action in reliance upon this information by > persons or entities other than the intended recipient is prohibited. If > you received this in error, please contact the sender and delete the > material from all computers. GA622 Thanks! That did the trick. :) I was trying to use HTMLParser but that choked on the script-blocks that didn't contain comment-indicators. Guess I can now move on with this script, thank you. MFB From spam-trap at telus.net Wed Apr 30 14:06:30 2008 From: spam-trap at telus.net (L. Lindstrom) Date: Wed, 30 Apr 2008 18:06:30 GMT Subject: Python 2.6 and wrapping C libraries on Windows Message-ID: I have read that Python extension modules must link to the same C run-time as the Python interpreter. This I can appreciate. But does this requirement extend to the C libraries an extension module wraps. The case in point is Pygame and SDL. The Pygame extension modules are built with distutils, so for Python 2.6 using Visual Studio 2008 should ensure the .pyd files link to msvcr90.dll. But SDL is built using Msys/MinGW and the configure/make tool chain. This fails when linking to msvcr90.dll since the small test programs configure builds lack manifest files. They fail to load msvcr90.dll, raising an R6034 error instead. So besides heap management and FILE pointers, is there any reason SDL, or any C dependency, needs to link to the same C run-time as Python? If I ensure SDL frees memory it allocates and does not directly access a file opened by Python can I just use another C run-time such as msvcrt? -- Lenard Lindstrom "%s@%s.%s" % ('len-l', 'telus', 'net') From cmpython at gmail.com Mon Apr 7 01:34:53 2008 From: cmpython at gmail.com (CM) Date: Sun, 6 Apr 2008 22:34:53 -0700 (PDT) Subject: Learning curve for new database program with Python? References: Message-ID: On Apr 5, 11:50 am, Jetus wrote: > I have a need for a database program. I downloaded the db2 from ibm, > and reviewed some of the documentation. > > My question is, what is the easiest program for me to try to learn. I > will be creating a database of about 25,000 records, it will be > relational. I am a beginner Python programmer, and need a database > solution that is easy to grasp. I played with sql, > and found that very difficult, if not overly cumbersome. > > A database that could work with Django would be very interesting to > look at as well.. > > Any suggestions out there? >From the good people at Django: "If you want to use Django with a database, which is probably the case, you'll also need a database engine. PostgreSQL is recommended, because we're PostgreSQL fans, and MySQL, SQLite 3, and Oracle are also supported." And if you want to make it a relational database, pretty much it's SQL as the language. And that's ok--it really is not hard at all, I picked it up quick and I'm new to databases; it's rather like a natural language. I've had success with keeping things simple with Python + SQLite--just import sqlite3 and use Python code such as: cur.execute("SELECT name FROM customers WHERE city='Chicago'") See here: http://docs.python.org/lib/module-sqlite3.html Very straightforward. Don't know how Django interacts with these two, but probably quite well, or you could choose from the other database management engines listed above. From bj_666 at gmx.net Fri Apr 25 06:35:05 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 25 Apr 2008 10:35:05 GMT Subject: Little novice program written in Python References: <49249992-3634-4c5f-bd45-7ce4f1b32044@l17g2000pri.googlegroups.com> Message-ID: <67dqepF2nmg7dU1@mid.uni-berlin.de> On Fri, 25 Apr 2008 10:24:16 +0200, Robert Bossy wrote: > John Machin wrote: >> On Apr 25, 5:44 pm, Robert Bossy wrote: >> >>> Peter Otten wrote: >>> If the OP insists in not examining a[0] and a[1], this will do exactly >>> the same as the while version: >>> >>> for p in a[2:]: >>> if p: >>> print p >>> >>> >> >> ... at the cost of almost doubling the amount of memory required. > Indeed. Would it be a sensible proposal that sequence slices should > return an iterator instead of a list? I don't think so as that would break tons of code that relies on the current behavior. Take a look at `itertools.islice()` if you want/need an iterator. Ciao, Marc 'BlackJack' Rintsch From vlastimil.brom at gmail.com Sat Apr 12 11:39:00 2008 From: vlastimil.brom at gmail.com (Vlastimil Brom) Date: Sat, 12 Apr 2008 17:39:00 +0200 Subject: sqlite3 - adding tables and rows via parameters Message-ID: <9fdb569a0804120839w6916ed96ka5b53aad7ca6f565@mail.gmail.com> Hi all, I would like to ask about the usage of sqlite3 in python, more specifically about a way to pass table or column names to a SQL commands using parameters. All examples I could find use the parameter substitution with "?" for values; is it possible the specify table and column names this way? e.g. something like curs.execute(u'INSERT OR REPLACE INTO %s(%s) VALUES (?)' % ("people", "email"), ("qwe at asd.zx",)) (And the similar cases e.g.: CREATE TABLE, ALTER TABLE ... ADD.) Unfortunately, I wasn't successful in replacing the string interpolation with the substitution notation; are there maybe any hints, how to do that? Or is it ok to use string interpolation here? (Are these parts of the SQL command vulnerable too?) What I am trying to achieve is to build a database dynamically - based on the input data the respective table would be chosen, and the appropriate columns created and filled with the content. Thanks in advance for any suggestions - and sorry if I missed something obvious... Vlasta -------------- next part -------------- An HTML attachment was scrubbed... URL: From gagsl-py2 at yahoo.com.ar Thu Apr 10 18:24:47 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 19:24:47 -0300 Subject: problem with using gnuplot/demo.py References: <574751.90080.qm@web94914.mail.in2.yahoo.com> Message-ID: En Thu, 10 Apr 2008 08:59:35 -0300, Paul Anton Letnes escribi?: > Could you include some code around line 39 in demo.py? > > Also, you could try to comment out the stuff before that point, and > see if the demo runs that far. And please include the error type and message too? -- Gabriel Genellina From BrentJRogers at gmail.com Tue Apr 29 22:54:47 2008 From: BrentJRogers at gmail.com (breroger@cisco.com) Date: Tue, 29 Apr 2008 19:54:47 -0700 (PDT) Subject: QA-Test Jobs at Cisco-IronPort Message-ID: Cisco-IronPort is looking for a topnotch Quality Assurance/ Test Engineers with experience in one or more of the following: aPython, utomation framework, performance testing, email encryption, FreeBSD, white.gray box testing, API testing, web security appliances, UNIX, RAID, LDAP, SSH, DNS, SMTP, HTTP, FTP, Telnet, RDBMS, IMAP, POP and/or tested servers. These job openings are in San Bruno. Please contact me directly if you are interested in getting more information. Regards, Brent breroger at cisco.com From cyberco at gmail.com Wed Apr 16 03:41:41 2008 From: cyberco at gmail.com (Berco Beute) Date: Wed, 16 Apr 2008 00:41:41 -0700 (PDT) Subject: webcam (usb) access under Ubuntu References: <66jlk1F2ju6c8U1@mid.uni-berlin.de> <66kkedF2l526dU2@mid.uni-berlin.de> <455760fb-8229-4be3-ba7f-7c41bdcd66de@a22g2000hsc.googlegroups.com> Message-ID: <362eb242-2adc-4d7b-9c0a-95e72f4b22b6@e67g2000hsa.googlegroups.com> On Apr 15, 11:45 pm, Berco Beute wrote: > I've tried reinstalling gstreamer (for windows): > > http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstre...http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstre... > > but that didn't help. I get some complaints about 'libgstinterfaces' > as well... To be more precise, when doing an 'import gst' Python shell pops up an error dialog saying: "This application has failed to start because libgstinterfaces-0.10.dll was not found." 2B From skanemupp at yahoo.se Sun Apr 13 13:03:40 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 13 Apr 2008 10:03:40 -0700 (PDT) Subject: tkinter, canvas, get color of image? Message-ID: <0e4c9708-dbe9-4f29-ac31-34f7298f2624@m1g2000pre.googlegroups.com> mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\elmapovic.gif') w.create_image(10, 10, image = mapq, anchor = NW) after doing this is there any possibility of getting the characteristics of the GIF-picture(or bitmap if i use that)? it would be very helpfull if i for example could do something like canvas.getcolor(image, mouseclick.x,mouseclick.y) if u get the point. get the color of the image where i clicked. From skanemupp at yahoo.se Tue Apr 22 16:11:37 2008 From: skanemupp at yahoo.se (globalrev) Date: Tue, 22 Apr 2008 13:11:37 -0700 (PDT) Subject: question about the mainloop References: <52de38c4-3d1e-4be0-9b58-5d60317f1ef7@b1g2000hsg.googlegroups.com> Message-ID: <01ac8fa5-fb2c-40a3-8096-d7b84d09f1c2@p25g2000hsf.googlegroups.com> On 21 Apr, 07:31, "Gabriel Genellina" wrote: > En Mon, 21 Apr 2008 00:57:38 -0300, globalrev escribi?: > > > > > On 21 Apr, 04:26, "Gabriel Genellina" wrote: > >> En Sun, 20 Apr 2008 20:24:04 -0300, globalrev escribi?: > > >> > i dont get the mainloop() in python. i mean i have written some > >> > programs, for example a calculator using tkinterGUI. > > >> What you call the "mainloop" is the event loop (or message loop) used by event-driven applications as a way to dispatch all events as they happen in the system. The concept is independent of Python/C++/whatever language you choose. The key phrase is "event-driven programming":http://en.wikipedia.org/wiki/Event_driven_programming > >> Tkinter provides an event-driven GUI framework. Simple CLI programs are not event-driven, as your pseudo example above. > > >> > if i have some functions i wanna call to run the program and i wanna > >> > call them ina specific order and be able to call > >> > them from each other should this just be called in the mainloop and > >> > the mianloop then runs the "mainscript" top > >> > to bottom over and over? > > >> If you don't want or don't require a graphical user interface, just write the functions you need and call them from the outermost section in your script. > >> If you do require a GUI, you'll have to write the code in response to user actions: when the user clicks here, do this; when the user chooses that menu option, do that. > > > but what i mean i dont understand is sure i can bind a function to a > > buttonpress but if i have a def dox(): dododo > > and i call it with dox() in the mainscript it will be executed once, > > but not again. > > so what does the mainloop do, 1srt time it is executed it runs the > > mainscript then it it sits and wait s for commands? > > What's the "mainscript"? > The "mainloop" just waits for system events like: mouse movement, mouse click, key pressed, key released, time elapsed, window is uncovered, etc. And when any event arrives, it's dispatched to its registered handler. > Python executes whatever you wrote at the top level of the script you are running, up to the root.mainloop() line. That function doesn't return until the main window is closed; all the user interaction occurs inside that call. Finally, execution resumes on the next line, if any. > I hope this answers your question; if not, try to be more specific. Maybe an example of what you want to do. > > -- > Gabriel Genellina ty everyone i get it now. From v.harishankar at gmail.com Tue Apr 22 09:55:26 2008 From: v.harishankar at gmail.com (Harishankar) Date: Tue, 22 Apr 2008 19:25:26 +0530 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: <480DE8E1.7020601@timgolden.me.uk> References: <200804221847.43924.v.harishankar@gmail.com> <480DE8E1.7020601@timgolden.me.uk> Message-ID: <200804221925.26525.v.harishankar@gmail.com> On Tuesday 22 Apr 2008 19:02:17 Tim Golden wrote: > Well if you want to, you can reproduce the same effect by using ctypes > which *is* in the standard library. But why reinvent the wheel? The reason is once again, rightly or wrongly I feel that using non-standard extensions could make it: 1. Difficult to distribute the application as I am not able to package the third-party extension with distutils. 2. Difficult to predict its behaviour with future versions of Python. > Correct. It's part of the pywin32 extensions, one of many useful packages > available to the discerning Python programmer who doesn't feel in some way > bound to whatever comes bundled with the standard library. > > TJG I wouldn't feel "bound" if I restricted the program to myself. But if I want to distribute it (as I intend to) I have to think of others as well. -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org From ankitks.mital at gmail.com Mon Apr 7 15:41:22 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Mon, 7 Apr 2008 12:41:22 -0700 (PDT) Subject: reading dictionary's (key,value) from file References: <974814d3-59f0-49ec-9b4d-9f5dd7dfaf54@q24g2000prf.googlegroups.com> Message-ID: On Apr 7, 11:55?am, Robert Bossy wrote: > ankitks.mi... at gmail.com wrote: > > Folks, > > Is it possible to read hash values from txt file. > > I have script which sets options. Hash table has key set to option, > > and values are option values. > > > Way we have it, we set options in a different file (*.txt), and we > > read from that file. > > Is there easy way for just reading file and setting options instead of > > parsing it. > > > so this is what my option files look like: > > > 1opt.txt > > { '-cc': '12', > > ? '-I': r'/my/path/work/'} > > > 2opt.txt > > { ?'-I': r/my/path/work2/'} > > > so my scipt how has dictionary > > options = { '-cc' :'12' > > ? ? ? ? ? ? ? ? '-I': r'/my/path/work/:/my/path/work2/'} > > > I am trying to avoid parsing > > For this particular case, you can use the optparse module:http://docs.python.org/lib/module-optparse.html > > Since you're obviously running commands with different set of options, I > suggest you listen to Diez. > > Cheers, > RB- Hide quoted text - > > - Show quoted text - I think I am missing lot regarding optparser module. My only option is to have option file, and I have couple of those..each user creates it's own. How can optparser help me in this regard Thank you From paul at boddie.org.uk Fri Apr 25 07:27:16 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Fri, 25 Apr 2008 04:27:16 -0700 (PDT) Subject: Problem building python in virtual machine running centos References: Message-ID: On 25 Apr, 03:05, Alexandre Gillet wrote: > > I am trying to build python-2.4.5 on Centos 5.1, which is a virtual > machine running with xen. > I am not able to build python. The compilation crash with the following: > gcc -pthread -c -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. > -I./Include -DPy_BUILD_CORE -o Objects/unicodeobject.o > Objects/unicodeobject.c > In file included from ./Include/Python.h:76, > from Objects/unicodeobject.c:39: > ./Include/object.h:228: internal compiler error: Segmentation fault > Please submit a full bug report, > with preprocessed source if appropriate. > See for instructions. > The bug is not reproducible, so it is likely a hardware or OS problem. > > Any suggestion of what am I doing wrong? You say that the bug is not reproducible, so that means that you can sometimes compile Python, or does the crash always happen when compiling some file (not necessarily the one mentioned above)? I think I've only ever seen a reproducible gcc crash once, and that had something to do with a C++ source file which I then split into two and was able to compile as these two separate parts. You might want to check the gcc version (gcc -v) and to look at bug fixes in any later versions. Generally, if you get an internal error in gcc, you aren't doing anything wrong yourself. Paul From gagsl-py2 at yahoo.com.ar Wed Apr 9 01:14:22 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 02:14:22 -0300 Subject: String Literal to Blob References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> Message-ID: En Tue, 08 Apr 2008 13:55:07 -0300, Victor Subervi escribi?: > Thanks. I apparently am printing some holder for the image. I stripped > out > most of it with this > content[0][0] Yes, because of this: content = cursor.fetchall() fetchall returns a list of rows, each row a tuple of columns. > but then I am left with this: > > array('c', '\xff\xd8\xff\xe0\\0\x10JFI...) > How do I extract an image from that? print content.tostring() Or perhaps, replace that line with content.tofile(sys.stdout) http://docs.python.org/lib/module-array.html >> > # print 'Content-Type: image/jpeg\r\nContent-Length: %d\n' % >> len(content) Once you fix the former, you can re-enable that line. >> > print 'Content-Type: image/jpeg\r\n' >> > print '\n' >> > print content >> > print '\n' >> > cursor.close() >> > >> > test() >> > The commented out line gives me a leading less than sign...and that?s >> > it. What do? Try to understand now *why* you got a single character with your previous code. -- Gabriel Genellina From arnodel at googlemail.com Sun Apr 13 04:46:02 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 13 Apr 2008 01:46:02 -0700 (PDT) Subject: Recommendation for Web Framework References: <4801b3a6$0$7713$4c368faf@roadrunner.com> Message-ID: <360b6cbb-5f8b-4de3-92cb-62000cc4d3b3@y21g2000hsf.googlegroups.com> On Apr 13, 8:18?am, James West wrote: [...] > Ideally, I'd like something like Ruby on Rails that would provide > scaffolding support so I can bootstrap the system, so to speak. I've > looked at Django, but the client is only running Apache 1.x and Python > 2.3. Django only requires Python 2.3 IIRC, and I think you can use it with FastCGI instead of mod_python. Doesn't FastCGI only require apache 1.3.x ? -- Arnaud From ernesto.adorio at gmail.com Sun Apr 6 00:18:28 2008 From: ernesto.adorio at gmail.com (ernie) Date: Sat, 5 Apr 2008 21:18:28 -0700 (PDT) Subject: Best way to check if string is an integer? References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> Message-ID: <0fdd2825-6d1c-4380-a79a-a7aac119f002@a5g2000prg.googlegroups.com> On Apr 6, 10:23 am, Roy Smith wrote: > In article , > Steve Holden wrote: > > > > This doesn't cater for negative integers. > > > No, it doesn't, but > > > s.isdigit() or (s[0] in "+-" and s[1:].isdigit) # untested > > > does. > > I think this fails on " -1". So, then you start doing > s.strip().isdigit(), and then somebody else comes up with some other > unexpected corner case... > > int(s) and catching any exception thrown just sounds like the best way. Another corner case: Is "5.0" an integer or treated as one? regards, ernie From george.sakkis at gmail.com Thu Apr 3 18:42:02 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Thu, 3 Apr 2008 15:42:02 -0700 (PDT) Subject: id functions of ints, floats and strings References: Message-ID: zillo... at googlemail.com wrote: > 1) Which of the above behaviours are reliable? For example, does a1 = > a2 for ints and strings always imply that a1 is a2? No. > 2) From the programmer's perspective, are ids of ints, floats and > string of any practical significance at all (since these types are > immutable)? No. > 3) Does the behaviour of ids for lists and tuples of the same element > (of type int, string and sometimes even float), imply that the tuple a > = (1,) takes (nearly) the same storage space as a = 10000*(1,)? (What > about a list, where elements can be changed at will?) No. Regards, George From jason.scheirer at gmail.com Sun Apr 20 18:50:33 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Sun, 20 Apr 2008 15:50:33 -0700 (PDT) Subject: Nested lists, simple though References: Message-ID: <8788db32-30b4-4cae-ab5a-bf6051249294@a9g2000prl.googlegroups.com> On Apr 20, 3:25?pm, Zethex wrote: > Im a bit new to python. ?Anyway working on a little project of mine and i > have nested lists > > ie > > Answer = [['computer', 'radeon', 'nvidia'], ['motherboard', 'asus']] > > and so forth.., > Anyway the amount of [[]] do increase over time. ?Im just wondering is there > a simple way to add these together so they become 1 simple list, so it would > be ['computer'....'asus'] etc without the nested list. ?Its random the > amount each time so i cant just go a[0]+a[1]. > Thank you if you can help > -- > View this message in context:http://www.nabble.com/Nested-lists%2C-simple-though-tp16799674p167996... > Sent from the Python - python-list mailing list archive at Nabble.com. The first idea that comes to mind is reduce(lambda x, y: x + y, list_of_lists, []) From leoniaumybragg at gmail.com Sat Apr 26 06:57:46 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:57:46 -0700 (PDT) Subject: clonedvd crack Message-ID: <129e576a-79a8-47a6-bdcb-1cda4ac54265@24g2000hsh.googlegroups.com> clonedvd crack http://cracks.00bp.com F R E E C R A C K S From deets at nospam.web.de Tue Apr 8 13:55:06 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 08 Apr 2008 19:55:06 +0200 Subject: Is the Python for statement the same as for each in other languages? In-Reply-To: <9e8bfedb-dc75-4252-84e7-4fb96bbaa6ac@l64g2000hse.googlegroups.com> References: <9e8bfedb-dc75-4252-84e7-4fb96bbaa6ac@l64g2000hse.googlegroups.com> Message-ID: <661ps1F2ae3jnU1@mid.uni-berlin.de> jmDesktop schrieb: > Thank you. It looks like it is, but I wanted to make sure I > understood. Also, I didn't see a "regular" for loop construct either > (i=0;i<=10;i++), etc. I'm still new at it, but is there one of those? Yes, it's foreach. And for your usecase, use for i in xrange(11): ... Diez From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 3 10:36:01 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 03 Apr 2008 16:36:01 +0200 Subject: object-relational mappers In-Reply-To: References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <47f37039$0$31900$426a74cc@news.free.fr> Message-ID: <47f4eb4f$0$4959$426a74cc@news.free.fr> Jarek Zgoda a ?crit : > Bruno Desthuilliers napisa?(a): > >> Now my own experience is that whenever I tried this approach for >> anything non-trivial, I ended up building an "ad-hoc, >> informally-specified bug-ridden slow implementation of half of " >> SQLAlchemy. Which BTW is not strictly an ORM, but primarily an attempt >> at a better integration of SQL into Python. So while it may feel like >> learning the inner complexities of SQLALchemy (or Django's ORM which is >> not that bad either) is "wasting brain cells", MVHO is that it's worth >> the time spent. But YMMV of course - IOW, do what works best for you. > > I like OR mappers, they save me lot of work. The problem is, all of them > are very resource hungry, processing resultset of 300k objects one by > one can effectively kill most of commodity systems. This is where raw > SQL comes in handy. The problem here is not about how you build your query but about how you retrieve your data. FWIW, SQLAlchemy provides quite a lot of "lower level" SQL/Python integration that doesn't require the "object mapping" part. "raw SQL" is fine, until you have to dynamically build complex queries from user inputs and whatnot. This is where the "low-level" (ie: non-ORM) part of SQLAlchemy shines IMHO. From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Sun Apr 27 17:38:59 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Sun, 27 Apr 2008 23:38:59 +0200 Subject: design choice: multi-threaded / asynchronous wxpython client? References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: <67ka3jF2nqkb9U1@mid.individual.net> bullockbefriending bard wrote: > 1) The data for the race about to start updates every (say) 15 > seconds, and the data for earlier and later races updates only > every > (say) 5 minutes. There is no point for me to be hammering the > server with requests every 15 seconds for data for races after the > upcoming race... I should query for this perhaps every 150s to be > safe. But for the upcoming race, I must not miss any updates and > should query every > ~7s to be safe. So... in the middle of a race meeting the > situation might be: I don't fully understand this, but can't you design the server in a way that you can connect to it and it notifies you about important things? IMHO, polling isn't ideal. > My initial thought was to have two threads for the different > update polling cycles. In addition I would probably need another > thread to handle UI stuff, and perhaps another for dealing with > file/DB data write out. No need for any additional threads. UI, networking and file I/O can operate asynchronously. Using wxPython's timers with callback functions, you should need only standard Python modules (except wx). > But, I wonder if using Twisted is a better idea? IMHO that's only advisable if you like to create own protocols and reuse them in different apps, or need full-featured customisable implementations of advanced protocols. Additionally, you'd *have to* use multiple threads: One for the Twisted event loop and one for the wxPython one. There is a wxreactor in Twisted which integrates the wxPython event loop, but I stopped using it due to strange deadlock problems which began with some wxPython version. Also, it seems it's no more in development. But my alternative works perfectly (main thread with Twisted, and a GUI thread for wxPython, communicating over Python standard queues). You'd only need additional threads if you would do heavy number crunching inside the wxPython or Twisted thread. For the respective event loop not to hang, it's advisable to use a separate thread for long-running calculations. > I have zero experience with these kinds of design choices and > would be very happy if those with experience could point out the > pros and cons of each (synchronous/multithreaded, or Twisted) for > dealing with the two differing sample rates problem outlined > above. I'd favor "as few threads as neccessary" approach. In my experience this saves pain (i. e. deadlocks and boilerplate queueing code). Regards, Bj?rn -- BOFH excuse #27: radiosity depletion From larry.bates at websafe.com` Tue Apr 22 15:21:11 2008 From: larry.bates at websafe.com` (Larry Bates) Date: Tue, 22 Apr 2008 14:21:11 -0500 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. In-Reply-To: References: Message-ID: <6oGdnT74Vugrp5PVnZ2dnUVZ_h_inZ2d@comcast.com> Kenneth McDonald wrote: > Sadly. > > Thanks, > Ken easy_install BeautifulSoup worked for me a couple of days ago. Of course you ahve to have easy_install running, but that is quite easy and makes installation of other modules quite easy. -Larry From wizzardx at gmail.com Sun Apr 20 02:26:27 2008 From: wizzardx at gmail.com (David) Date: Sun, 20 Apr 2008 08:26:27 +0200 Subject: Checking if a text file is blank In-Reply-To: References: Message-ID: <18c1e6480804192326g663a916bqa161b5fb42c11b9d@mail.gmail.com> > > Is there any way in python to check if a text file is blank? > > What I've tried to do so far is: > > f = file("friends.txt", "w") > if f.read() is True: > """do stuff""" > else: > """do other stuff""" > f.close() > > What I *mean* to do in the second line is to check if the text file is > not-blank. But apparently that's not the way to do it. > > Could someone set me straight please? You're opening your file in write mode, so it gets truncated. Add "+" to your open mode (r+ or w+) if you want to read and write. Here is the file docstring: file(name[, mode[, buffering]]) -> file object Open a file. The mode can be 'r', 'w' or 'a' for reading (default), writing or appending. The file will be created if it doesn't exist when opened for writing or appending; it will be truncated when opened for writing. Add a 'b' to the mode for binary files. Add a '+' to the mode to allow simultaneous reading and writing. If the buffering argument is given, 0 means unbuffered, 1 means line buffered, and larger numbers specify the buffer size. Add a 'U' to mode to open the file for input with universal newline support. Any line ending in the input file will be seen as a '\n' in Python. Also, a file so opened gains the attribute 'newlines'; the value for this attribute is one of None (no newline read yet), '\r', '\n', '\r\n' or a tuple containing all the newline types seen. 'U' cannot be combined with 'w' or '+' mode. Note: open() is an alias for file(). Also, comparison of a value with True is redundant in an if statement. Rather use 'if f.read():' David. From danb_83 at yahoo.com Mon Apr 21 23:30:06 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Mon, 21 Apr 2008 20:30:06 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> <48a1d10c-87cb-43c3-83f4-9c331fc1d818@m1g2000pre.googlegroups.com> Message-ID: <68f586a6-1fac-4f06-b386-ad4bd8c22d61@p25g2000pri.googlegroups.com> On Apr 21, 4:01 am, Paul Boddie wrote: > On 21 Apr, 00:54, Dan Bishop wrote: > > > > > We wouldn't even need that. Just a new source encoding. Then we > > could write: > > > # -*- coding: end-block -*- > > [...] > > Someone at EuroPython 2007 did a lightning talk showing working code > which provided C-style block structuring using this mechanism. Yes, I saw an example of that: It's what inspired my post. From jens at aggergren.dk Tue Apr 29 09:25:50 2008 From: jens at aggergren.dk (Jens) Date: Tue, 29 Apr 2008 06:25:50 -0700 (PDT) Subject: Zope/DTML Infuriating... References: <3a955f90-ed80-46be-a238-1462e4fb2d0c@m3g2000hsc.googlegroups.com> Message-ID: <7f23c8d7-b2aa-4e55-8946-fd25cd8c594b@k13g2000hse.googlegroups.com> On Apr 29, 2:45?pm, Marco Mariani wrote: > Jens wrote: > >> You might have wrong assumptions from previous PHP experiences. > > >> ?>>> 'x'+4 > >> Traceback (most recent call last): > >> ? ?File "", line 1, in > >> TypeError: cannot concatenate 'str' and 'int' objects > > > ... and the non snobby answer would have been: > > > ... ? > > Sorry. Not trying to be snobbish, only in a hurry. > > That answer would have been less useful, because there are TONS of > details in the python tutorial, that set the language apart from its > "scripting cousins". > Reading the syntax and thinking "yeah, got it, boring, next chapter" is > a common mistake I've also made sometime, especially with python when > I've been deceived by its apparent simplicity. > Then, later, the same happened with Javascript, of course. > And it's bound to happen again, as much as I'll try to be careful :-( Hey no worriest. Is this the tutorial you're referring to: http://docs.python.org/lib/typesmapping.html Is there anything better? I miss the discussion and examples that accompany most entries in php.net. From siona at chiark.greenend.org.uk Tue Apr 29 13:21:45 2008 From: siona at chiark.greenend.org.uk (Sion Arrowsmith) Date: 29 Apr 2008 18:21:45 +0100 (BST) Subject: Simple unicode-safe version of str(exception)? References: <481650E3.4060603@v.loewis.de> <67on2nF2ol856U1@mid.individual.net> Message-ID: Russell E. Owen wrote: >No. e.message is only set if the exeption object receives exactly one >argument. And not always then: >>> e1 = Exception(u"\u00fe") >>> e1.message Traceback (most recent call last): File "", line 1, in ? AttributeError: Exception instance has no attribute 'message' >That is why my replacement code reads: > errStr = ",".join([unicode(s) for s in f.args]) errStr = ",".join(e.args) There is something distinctly odd going on here, though: >>> str(e1) Traceback (most recent call last): File "", line 1, in ? UnicodeEncodeError: 'ascii' codec can't encode character u'\xfe' in position 0: ordinal not in range(128) >>> e2 = Exception(u"\u00fe", "foo") >>> str(e2) "(u'\\xfe', 'foo')" >>> -- \S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/ "Frankly I have no feelings towards penguins one way or the other" -- Arthur C. Clarke her nu become? se bera eadward ofdun hl?ddre heafdes b?ce bump bump bump From bj_666 at gmx.net Wed Apr 16 17:03:17 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 16 Apr 2008 21:03:17 GMT Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> <09a38ca2-8c49-4eee-b6cf-58e849aea1fc@q1g2000prf.googlegroups.com> Message-ID: <66n7slF2lroubU2@mid.uni-berlin.de> On Wed, 16 Apr 2008 12:32:00 -0700, Aaron Watters wrote: >> > Perhaps this will inspire improved linters and better coding >> > practices.... >> >> Better coding practices such as extensive unit tests? > > Greetings from Earth. What planet are you from? :) > > There is always the possibility that frustrated > programmers will decide that "using something other > than python" is a "better coding practice". I've seen > it happen. So the average quality of Python coders raises. Cool. ;-) Ciao, Marc 'BlackJack' Rintsch From jywlsn at comcast.net Mon Apr 14 04:15:57 2008 From: jywlsn at comcast.net (J Wilson) Date: Mon, 14 Apr 2008 03:15:57 -0500 Subject: How to get the version of a file In-Reply-To: <472baa87-2aa3-495c-ab0f-9c7f16bef769@8g2000hsu.googlegroups.com> References: <472baa87-2aa3-495c-ab0f-9c7f16bef769@8g2000hsu.googlegroups.com> Message-ID: I'm not clear on how to use this to read the version resource. Specially, I need to get the version of Palm Conduit, which is, I guess, a "carbonized" shared library... or something. ? martin.laloux at gmail.com wrote: > you need appscript "that allows you to control scriptable Mac OS X > applications from Python" > http://pypi.python.org/pypi/appscript/0.18.1 From sturlamolden at yahoo.no Sat Apr 12 16:02:21 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sat, 12 Apr 2008 13:02:21 -0700 (PDT) Subject: C API design flaw (was: Re: Multiple independent Python interpreters in a C/C++ program?) References: <624b9d79-bc02-4f52-bc97-52019bf916d0@n1g2000prb.googlegroups.com> Message-ID: <8e73acd5-b50a-4e0d-9193-8615cb38e5a2@s39g2000prd.googlegroups.com> On Apr 12, 7:05 pm, sturlamolden wrote: > In theory, a GIL private to each (sub)interpreter would make Python > more scalable. The current GIL behaves like the BKL in earlier Linux > kernels. However, some third-party software, notably Apache's > mod_python, is claimed to depend on this behaviour. I just looked into the reason why ctypes, mod_python, etc. depend on a shared GIL. Well ... PyGILState_Ensure() does not take an argument, so it does not know which interpreter's GIL to acquire. Duh! The sad fact is, the functions in Python's C API does not take the interpreter as an argument, so they default to the one that is currently active (i.e. the one that PyThreadState_Get()->interp points to). This is unlike Java's JNI, in which all functions take the "environment" (a Java VM instance) as the first argument. IMHO, I consider this a major design flaw in Python's C API. In a more well thought API, PyGILState_Ensure would take the interpreter returned by Py_NewInterpreter as an argument, and thus know the interpreter with which to synchronize. I complained about this before, but the answer I got was that the simplified GIL API would not work if interpreters has a separate GIL. Obviously it would not work as long as the PyGILState_Ensure does not take any arguments. The lack of a leading VM argument in PyGILState_Ensure, and almost every function in Python's C API, is the heart of the problem. From soltys at noabuse.com Thu Apr 17 06:27:43 2008 From: soltys at noabuse.com (Soltys) Date: Thu, 17 Apr 2008 12:27:43 +0200 Subject: about a head line In-Reply-To: References: Message-ID: Penny Y. pisze: > I saw some scripts have a line at its begin: > > # encoding:gb2312 > > what's this? Why need it? thanks. > Have a look at PEP-0263 (http://www.python.org/dev/peps/pep-0263/) From thudfoo at opensuse.us Thu Apr 24 15:13:48 2008 From: thudfoo at opensuse.us (member thudfoo) Date: Thu, 24 Apr 2008 12:13:48 -0700 Subject: function that accepts any amount of arguments? In-Reply-To: <933e4c97-11c8-43b0-81e0-c78ff8573792@26g2000hsk.googlegroups.com> References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> <4810724a$0$23390$426a74cc@news.free.fr> <63ac69bf-9f6d-42bd-8e6e-5b3b17ec7c69@z72g2000hsb.googlegroups.com> <933e4c97-11c8-43b0-81e0-c78ff8573792@26g2000hsk.googlegroups.com> Message-ID: <3d881a310804241213q2f373190i4d7c7c1ffbaeba4c@mail.gmail.com> On 4/24/08, Jonathan Gardner wrote: > On Apr 24, 5:28 am, malkarouri wrote: > > > > What's wrong with raising ZeroDivisionError (not stopping the > > exception in the first place)? > > > > > Because when I use your module, call avg (or mean) without args, I > should see an error that says, "Hey, you have to pass at least one > value in!" > > ZeroDivisonError doesn't mean that. It means I tried to divide by > zero. Naively, I don't see where I was dividing by zero (because I > don't remember how to calculate the mean---that's what your code was > for.) > > ValueError does mean that I didn't pass the right kind of arguments > in. ValueError("No items specified") would be even clearer. (Or maybe > TypeError?) > > In general, any exception thrown should be meaningful to the code you > are throwing it to. That means they aren't familiar with how your code > works. > [source]|557> def average(n, *ints): |...> return (sum(ints)+n) / (len(ints) + 1) |...> [source]|558> average (1,2,3) <558> 2 [source]|559> average(3) <559> 3 [source]|560> average(1,2) <560> 1 [source]|561> average(0) <561> 0 [source]|562> average() --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /usr/share/doc/packages/python-dateutil/source/ in () TypeError: average() takes at least 1 argument (0 given) From samslists at gmail.com Thu Apr 10 13:37:35 2008 From: samslists at gmail.com (samslists at gmail.com) Date: Thu, 10 Apr 2008 10:37:35 -0700 (PDT) Subject: from __future__ import print Message-ID: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> Am I the only one that thinks this would be useful? :) I'd really like to be able to use python 3.0's print statement in 2.x. Is this at least being considered as an option for 2.6? It seems like it would be helpful with transitioning. From http Sat Apr 12 20:46:34 2008 From: http (Paul Rubin) Date: 12 Apr 2008 17:46:34 -0700 Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> <32e2acc1-97cb-4911-bb0c-67965b5ff113@2g2000hsn.googlegroups.com> Message-ID: <7x8wzi7f9x.fsf@ruckus.brouhaha.com> Steve Holden writes: > I believe you are making surmises outside your range of competence > there. While your faith in the developers is touching, the garbage > collection scheme is something that has received a lot of attention > with respect to performance under typical workloads over the years. Really, Python's cyclic gc is quite crude and should be upgraded to something that doesn't fall into that quadratic behavior. There was some fairly detailed discussion of this in another thread last time the subject came up. From jeff_barish at earthlink.net Wed Apr 9 09:33:22 2008 From: jeff_barish at earthlink.net (Jeffrey Barish) Date: Wed, 09 Apr 2008 07:33:22 -0600 Subject: __init__.py file References: Message-ID: cesco wrote: > I need to instantiate an object (my_object) whose methods I have to > use in two files (file1.py and file2.py) which are in the same > directory. Is it possible to instantiate such object in the > __init__.py file and then directly use it in file1.py and file2.py? > If not, as I seem to experience, what is the best practice to follow > in this case? (I thought __init__.py was somehow useful for that). I do this and find the technique fantastically convenient. You don't explain what problems you encountered -- or perhaps I don't understand what you mean by using the instances "directly" -- but here's what I do: In dirA/dirB/__init__.py, I import my_object to import the my_object.py module. I then instantiate an object in __init__.py. (Note that it is a singleton because Python imports modules only once.) Import the object in file{1,2}.py with import dirA.dirB.my_object or from dirA.dirB import my_object. I use the technique only with objects that are legitimately global. -- Jeffrey Barish From yourpadre at gmail.com Tue Apr 22 10:24:20 2008 From: yourpadre at gmail.com (Miguel Beltran R.) Date: Tue, 22 Apr 2008 09:24:20 -0500 Subject: Problem with urllib2 and authentification Message-ID: Using this script for connect to Zope I have this error ---script: import urllib2 protocolo='http://' servidor='10.28.1.239/' pagina='manage' fullurl=protocolo+servidor+pagina aut=urllib2.HTTPBasicAuthHandler() aut.add_password(realm=None, uri=servidor, user='myadmin', passwd='mypass') opener=urllib2.build_opener(aut, urllib2.HTTPHandler(debuglevel=1)) print opener.open(fullurl).read() ---Error: connect: (10.28.1.239, 80) send: 'GET /manage HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: 10.28.1.239\r\nConnection: close\r\nUser-agent: Python-urllib/2.4\r\n\r\n' reply: 'HTTP/1.1 401 Unauthorized\r\n' header: Server: Zope/(Zope 2.10.5-final, python 2.4.4, win32) ZServer/1.1 header: Date: Tue, 22 Apr 2008 14:14:45 GMT header: Bobo-Exception-Line: 713 header: Content-Length: 884 header: Bobo-Exception-Value: See the server error log for details header: Content-Type: text/html; charset=iso-8859-15 header: Bobo-Exception-Type: Unauthorized header: Connection: close header: Bobo-Exception-File: HTTPResponse.py header: WWW-Authenticate: basic realm="Zope" Traceback (most recent call last): File "z.py", line 15, in ? print opener.open(fullurl).read() File "/usr/local/lib/python2.4/urllib2.py", line 364, in open response = meth(req, response) File "/usr/local/lib/python2.4/urllib2.py", line 471, in http_response response = self.parent.error( File "/usr/local/lib/python2.4/urllib2.py", line 402, in error return self._call_chain(*args) File "/usr/local/lib/python2.4/urllib2.py", line 337, in _call_chain result = func(*args) File "/usr/local/lib/python2.4/urllib2.py", line 480, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 401: Unauthorized why not send authentification? I try python 2.5 on slackware 12 too on python 2.4 and 2.5 on windows xp All same error -- ________________________________________ Lo bueno de vivir un dia mas es saber que nos queda un dia menos de vida From steve at holdenweb.com Fri Apr 25 08:55:28 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 25 Apr 2008 08:55:28 -0400 Subject: function that accepts any amount of arguments? In-Reply-To: References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> Message-ID: <4811D4C0.5050500@holdenweb.com> Nick Craig-Wood wrote: > Steve Holden wrote: >> Ken wrote: >>> "Steve Holden" wrote in message >> [...] >>>> def mean(*x): >>>> total = 0.0 >>>> for v in x: >>>> total += v >>>> return v/len(x) >>>> >>> think you want total/len(x) in return statement >>> >> Yes indeed, how glad I am I wrote "untested". I clearly wasn't pair >> programming when I wrote this post ;-) > > Posting to comp.lang.python is pair programming with the entire > internet ;-) > > +1 QOTW :) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From castironpi at gmail.com Wed Apr 2 11:35:32 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 2 Apr 2008 08:35:32 -0700 (PDT) Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> Message-ID: <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> On Apr 2, 5:00?am, Jo?o Neves wrote: > Hello all, > > I've got this question that has been nagging me for a few days now. > What are the reasons for us to have co_code as read-only? I've been > trying to get some info about it, but I kept hitting the wall. > > Correct me if I'm wrong, but as far as I understand, co_code > represents the compiled bytecode that should be run when, for > instance, a function is called. Wouldn't it be beneficial for > programmers to be able to change the bytecode in runtime? I mean, one > can't, as far as I'm aware, change the bytecode by accident, so if the > programmer would wish to change a function at runtime, he could do so > at his own risk. > > If there is a higher reason behind the read-only property of co_code, > I definitely fail to see it, and would like to know what it is. If > not, why aren't we allowed to write into it? > > Thanks in advance, > > Jo?o Neves Are Python bytes codes Python byte codes? Do you foresee any machine- dependent optimizations? From larry.bates at websafe.com` Fri Apr 18 11:45:52 2008 From: larry.bates at websafe.com` (Larry Bates) Date: Fri, 18 Apr 2008 10:45:52 -0500 Subject: Installing BeautifulSoup with easy_install (broken?) Message-ID: Info: Python version: ActivePython 2.5.1.1 Platform: Windows I wanted to install BeautifulSoup today for a small project and decided to use easy_install. I can install other packages just fine. Unfortunately I get the following error from BeautifulSoup installation attempt: C:\Python25\Lib\SITE-P~1>easy_install BeautifulSoup Searching for BeautifulSoup Reading http://pypi.python.org/simple/BeautifulSoup/ Reading http://www.crummy.com/software/BeautifulSoup/ Reading http://www.crummy.com/software/BeautifulSoup/download/ Best match: BeautifulSoup 3.0.5 Downloading http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup- 3.0.5.tar.gz Processing BeautifulSoup-3.0.5.tar.gz Running BeautifulSoup-3.0.5\setup.py -q bdist_egg --dist-dir c:\docume~1\larry\l ocals~1\temp\easy_install-cfdxna\BeautifulSoup-3.0.5\egg-dist-tmp-gbrpp5 Traceback (most recent call last): File "C:\Python25\Scripts\easy_install-script.py", line 8, in load_entry_point('setuptools==0.6c8', 'console_scripts', 'easy_install')() File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm and\easy_install.py", line 1671, in main File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm and\easy_install.py", line 1659, in with_ei_usage File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm and\easy_install.py", line 1675, in File "C:\Python25\lib\distutils\core.py", line 151, in setup dist.run_commands() File "C:\Python25\lib\distutils\dist.py", line 974, in run_commands self.run_command(cmd) File "C:\Python25\lib\distutils\dist.py", line 994, in run_command cmd_obj.run() File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm and\easy_install.py", line 211, in run File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm and\easy_install.py", line 446, in easy_install File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm and\easy_install.py", line 476, in install_item File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm and\easy_install.py", line 655, in install_eggs File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm and\easy_install.py", line 930, in build_and_install File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm and\easy_install.py", line 919, in run_setup File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand box.py", line 27, in run_setup File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand box.py", line 63, in run File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand box.py", line 29, in File "C:\VOL1\Larry\Websafe\Python\wstools\setup.py", line 2, in import py2exe File "C:\VOL1\Larry\Websafe\Python\wstools\unittest.py", line 3, in class TextCtrlTest(unittest.TestCase): AttributeError: 'module' object has no attribute 'TestCase' Thanks in advance for any "clues". -Larry From hasna1980_14 at hotmail.com Fri Apr 11 06:10:33 2008 From: hasna1980_14 at hotmail.com (ha bo) Date: Fri, 11 Apr 2008 10:10:33 +0000 Subject: No subject Message-ID: hi i use this programme in my application django: import structMASK_CCITT = 0x1021 # CRC-CCITT mask (ISO 3309, used in X25, HDLC)MASK_CRC16 = 0xA001 # CRC16 mask (used in ARC files)def updcrc(crc, data, mask=MASK_CRC16): data_length = len(data) unpackFormat = '%db' % data_length unpackedData = struct.unpack(unpackFormat, data) for char in data: c = ord(char) c = c << 8 for j in xrange(8): if (crc ^ c) & 0x8000: crc = (crc << 1) ^ mask else: crc = crc << 1 c = c << 1 return crc & 0xffff and i call this function in other function in my view: def encodekey(var, expires=None, user='', trusted=False): import random, base64 import updcrc key = "%02X" % len(var) + var key += "%02X" % len(user) + user if expires is not None: key += expires.strftime('%Y%m%d%H%M') else: year = random.choice(range(2000,2100)) month = 23 day = random.choice(range(1,32)) hour = random.choice(range(1,25)) minute = random.choice(range(1,60)) key += "%04d%02d%02d%02d%02d" % (year, month, day, hour, minute) if trusted: checksum = updcrc(42, key) else: checksum = updcrc(0, key) key += "%04X" % checksum return base64.b64encode(key) but it give me this error: unpack requires a string argument of length 31 someone can help me _________________________________________________________________ Lancez des recherches en toute s?curit? depuis n'importe quelle page Web. T?l?chargez GRATUITEMENT Windows Live Toolbar aujourd'hui ! http://toolbar.live.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at holdenweb.com Sat Apr 5 17:54:37 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 17:54:37 -0400 Subject: ANN: pry unit testing framework In-Reply-To: <20080405213059.GA19741@nullcube.com> References: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com> <20080405141329.GD15684@nullcube.com> <20080405213059.GA19741@nullcube.com> Message-ID: <47F7F51D.8010405@holdenweb.com> Aldo Cortesi wrote: > Steve, > >> Kay at least has a long history as a contributor in this group, so >> people know how to interpret her remarks and know that her contributions >> are made on the basis of a deep understanding of Python. She is far from >> belonging to the "peanut gallery", and to suggest otherwise betrays >> either ignorance, arrogance, or both. > > While I'm not a regular poster on this list, I have been reading it for > nearly 10 years, so I probably have more context here than you suspect. > At least one mail to this list and a number of personal emails to me > suggest that it is Kay and and indeed you who are temporarily out of > line with the tone of the list. A more impartial re-reading of the > debate so far might make you judge my final, admittedly angry, response > more fairly. > To be fair I wasn't commenting on the whole thread, more on the angry nature of your final reply, and didn't really consider Kay's remarks fully. So perhaps I could ask *both* of you to be more civil to each other, and leave it at that? Storm in a teacup, of course. I'm sure war won;t be declared about this. Consider the 200,000 (?) readers of the group who *didn't* complain about your post and your software as supporters, if you like :-) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From george.sakkis at gmail.com Fri Apr 4 13:58:26 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 4 Apr 2008 10:58:26 -0700 (PDT) Subject: collecting results in threading app References: <47f64507$0$36354$742ec2ed@news.sonic.net> Message-ID: On Apr 4, 1:54 pm, George Sakkis wrote: > On Apr 4, 11:27 am, Gerardo Herzig wrote: > > There is an approach in which i can 'sum' after *any* thread finish? > > > Could a Queue help me there? > > Yes, you can push each result to a queue and have the main thread wait > in a loop doing a queue.get() every time. After each get() you can do > whatever with the results so far (partial sum, update a progress bar, > etc.) > > > You can take a look at papyros [1], I forgot the link: http://pypi.python.org/pypi/papyros/ George From gagsl-py2 at yahoo.com.ar Mon Apr 28 03:58:10 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 28 Apr 2008 04:58:10 -0300 Subject: Related to Shelve Module References: Message-ID: En Mon, 28 Apr 2008 02:08:31 -0300, tarun escribi?: > Hi All, > I want to store the class instance object variables persistenlty in one file > so that other file can also access for some filtering. I tired doing this > using the shelve module. > > *Code:* > class A: > pass > > import shelve > filename = 'test.db' > d = shelve.open(filename) > > a = A() > print a > d['1'] = a > > print d['1'] > d.close() > > *Output:* > <__main__.A instance at 0x018B56C0> > <__main__.A instance at 0x018B5760> > > *Observation:* > I expect both the print statements to return the same value, The second > print statement just reads the dictonary, but still the adress (0x..) is > different from the first print statement. Can anyone tell me why. Also let > me know if you the way of getting same value both the times. By default, each time you do d['1'] you get a *different* object. A shelve isn't very smart: it stores a string representation of your object (using pickle) and each time you ask for the object, it unpickles the stored string. When used as a persistence mechanism, it doesn't matter so much, the process that created the original instance may have died eons ago. If object identity is important to you, you should remember to "fetch" the values only once in a single process, or use the writeback=True argument to the shelve constructor. But read the warning at py> d = shelve.open(filename, writeback=True) py> a = A() py> d['1'] = a py> x1 = d['1'] py> x2 = d['1'] py> x3 = d['1'] py> print a, x1 <__main__.A instance at 0x00A3D5D0> <__main__.A instance at 0x00A3D5D0> py> a is x1 is x2 is x3 True -- Gabriel Genellina From aguirre.adolfo at gmail.com Mon Apr 28 22:37:25 2008 From: aguirre.adolfo at gmail.com (aguirre.adolfo at gmail.com) Date: Mon, 28 Apr 2008 19:37:25 -0700 (PDT) Subject: Python Math libraries - How to? References: <67nevlF2q292cU1@mid.individual.net> Message-ID: Hi, thak you. I get the following: > > > *** Error message ************* > > > Traceback (most recent call last): > > File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 20, > > in > > > > main() > > File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 13, > > in main > > volume = 4/3*pi*r3 > > NameError: global name 'pi' is not defined From steve at holdenweb.com Wed Apr 16 21:13:18 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 16 Apr 2008 21:13:18 -0400 Subject: TypeNone field detection In-Reply-To: <480698b3$0$31577$ec3e2dad@news.usenetmonster.com> References: <480698b3$0$31577$ec3e2dad@news.usenetmonster.com> Message-ID: Joe Blow wrote: > What is the best way to detect a TypeNone field in a tuple, or in a list? > > I am accessing a MySQL database using the MySQLdb Python interface... this > interface returns a tuple object type in response to SQL SELECT > statements. My understanding of the MySQLdb interface is that NULL > database values are returned as a Python 'None' object. > > Because I need to create some work fields based on the contents of the > database I am doing so by copying the tuple to a list object and then > calculating these work fields as needed. My problem is that I need to be > able to detect the Python 'None' objects and convert them to an integer > zero value field to enable my calculations to work. > > I'm new to Python so I'm sure I'm overlooking something simple ? but what > is the easiest way to do a logical test for the existence of a TypeNone > field? Since there is only one instance of TypeNone (the value we reference as None) the easiest test is if x is None: There is no need to create a list first: you can create a list as you iterate over the tuple: a = (1, 2, None, "a", "b") a = [0 if x is None else x for x in a] regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From dickinsm at gmail.com Mon Apr 7 15:53:22 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Mon, 7 Apr 2008 12:53:22 -0700 (PDT) Subject: A funnily inconsistent behavior of int and float References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com> <1d11875a-470a-489f-910a-b420a145eb61@a1g2000hsb.googlegroups.com> Message-ID: <11b4793c-04cc-4898-99a8-8418d237de3e@2g2000hsn.googlegroups.com> On Apr 7, 3:15 pm, "Terry Reedy" wrote: > > My suggestions: > 1. Change signature to: int([number | string[, radix]). > This makes it clear that radix can only follow a string without having to > say so in the text. > > 2. Replace text with: > Convert a number or string to an integer. If no arguments are given, > return 0. If a number is given, return number.__int__(). Conversion of > floating point numbers to integers truncates towards zero. A string must > be a base-radix integer literal optionally preceded by '+' or '-' (with no > space in between) and optionally surrounded by whitespace. A base-n > literal consists of the digits 0 to n-1, with 'a' to 'z' (or 'A' to 'Z') > having values 10 to 35. The default radix is 10. The allowed values are 0 > and 2-36, with 0 the same as 10. > > If 0 is not the same as 10, the last would have to be changed, but I could > not detect any difference in a quick test. > > After looking at any comments here, I will consider submitting these to the > tracker. > > Terry Jan Reedy Looks good! The description should probably also mention the optional '0b', '0o' or '0x' (or '0B', '0O', '0X') allowed between the sign and the digits (or before the digits in the case of a missing sign) when base=2, base=8 or base=16. The only base 0 versus base 10 difference I could find was the following: >>> int('033', 0) Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 0: '033' [38720 refs] >>> int('033') 33 Mark From malaclypse2 at gmail.com Thu Apr 10 16:06:47 2008 From: malaclypse2 at gmail.com (Jerry Hill) Date: Thu, 10 Apr 2008 16:06:47 -0400 Subject: Python conventions In-Reply-To: References: Message-ID: <16651e80804101306p9742a62x77e34654345d8e4c@mail.gmail.com> On Thu, Apr 10, 2008 at 3:52 PM, wrote: > Daniel, PEP 8 is anything but complete. How much of the following > simple question can you answer from there: > > Given that you can name things with UpperAndLower, lowerAndUpper, > lower_and_underscore, etc., what is the convention for naming > packages, modules, classes, ... Each of those is directly addressed in PEP 8. Perhaps you should have picked a different question? -- Jerry From george.sakkis at gmail.com Fri Apr 4 13:54:51 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 4 Apr 2008 10:54:51 -0700 (PDT) Subject: collecting results in threading app References: <47f64507$0$36354$742ec2ed@news.sonic.net> Message-ID: On Apr 4, 11:27 am, Gerardo Herzig wrote: > John Nagle wrote: > >Gerardo Herzig wrote: > > >>Hi all. Newbee at threads over here. Im missing some point here, but cant > >>figure out which one. > > >>This little peace of code executes a 'select count(*)' over every table > >>in a database, one thread per table: > >> > >>class TableCounter(threading.Thread): > >> def __init__(self, conn, table): > >> self.connection = connection.Connection(host=conn.host, > >>port=conn.port, user=conn.user, password='', base=conn.base) > >> threading.Thread.__init__(self) > >> self.table = table > > >> def run(self): > >> result = self.connection.doQuery("select count(*) from %s" % > >>self.table, [])[0][0] > >> print result > >> return result > > >>class DataChecker(metadata.Database): > > >> def countAll(self): > >> for table in self.tables: > >> t = TableCounter(self.connection, table.name) > >> t.start() > >> return > >> > > >>It works fine, in the sense that every run() method prints the correct > >>value. > >>But...I would like to store the result of t.start() in, say, a list. The > >>thing is, t.start() returns None, so...what im i missing here? > >>Its the desing wrong? > > > 1. What interface to MySQL are you using? That's not MySQLdb. > > 2. If SELECT COUNT(*) is slow, check your table definitions. > > For MyISAM, it's a fixed-time operation, and even for InnoDB, > > it shouldn't take that long if you have an INDEX. > > 3. Threads don't return "results" as such; they're not functions. > > >As for the code, you need something like this: > > >class TableCounter(threading.Thread): > > def __init__(self, conn, table): > > self.result = None > > ... > > > def run(self): > > self.result = self.connection.doQuery("select count(*) from %s" % > > self.table, [])[0][0] > > > def countAll(self): > > mythreads = [] # list of TableCounter objects > > # Start all threads > > for table in self.tables: > > t = TableCounter(self.connection, table.name) > > mythreads.append(t) # list of counter threads > > t.start() > > # Wait for all threads to finish > > totalcount = 0 > > for mythread in mythreads: # for all threads > > mythread.join() # wait for thread to finish > > totalcount += mythread.result # add to result > > print "Total size of all tables is:", totalcount > > > John Nagle > > Thanks John, that certanly works. According to George's suggestion, i > will take a look to the Queue module. > One question about > > for mythread in mythreads: # for all threads > mythread.join() # wait for thread to finish > > That code will wait for the first count(*) to finish and then continues > to the next count(*). Because if is that so, it will be some kind of > 'use threads, but execute one at the time'. > I mean, if mytreads[0] is a very longer one, all the others will be > waiting...rigth? No, all will be executed in parallel; only the main thread will be waiting for the first thread to finish. So if only the first job is long, as soon as it finishes and join()s, all the others will already have finished and their join() will be instantaneous. > There is an approach in which i can 'sum' after *any* thread finish? > > Could a Queue help me there? Yes, you can push each result to a queue and have the main thread wait in a loop doing a queue.get() every time. After each get() you can do whatever with the results so far (partial sum, update a progress bar, etc.) You can take a look at papyros [1], a small package I wrote for hiding the details behind a simple Pythonic API. Using papyros, your example would look something like this: import sys from papyros import Job from papyros.multithreaded import MultiThreadedMaster # a papyros.Job subclass for each type of task you want to run concurrently class CountJob(Job): def __call__(self, connection, table_name): return connection.doQuery("select count(*) from %s" % table_name, [])[0][0] class DataChecker(metadata.Database): def countAll(self): sum_count = 0 # create a pool of 4 threads master = MultiThreadedMaster(4) # issue all the jobs for table in self.tables: master.addJob(CountJob(self.connection, table.name)) # get each processed job as soon as it finishes for job in iter(master.popProcessedJob, None): # the job arguments are available as job.args table_name = job.args[1] try: # try to get the result count = job.result except Exception, ex: # some exception was raised when executing this job print '* Exception raised for table %s: %s' % (table_name, ex) else: # job finished successfully sum_count += count print 'Table %s: count=%d (running total=%d)' % ( table_name, count, sum_count) return sum_count As you can see, any exception raised in a thread is stored and reraised on the main thread when you attempt to get the result. You can also specify a timeout in popProcessedJob() so that the main thread doesn't wait forever in case a job hangs. Last but not least, the same API is implemented both for threads and processes (using Pyro) so it's not restricted by the GIL in case the jobs are CPU-intensive. George From fr5478bey at gmail.com Sat Apr 26 11:40:07 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:40:07 -0700 (PDT) Subject: inventor12 crack Message-ID: <929dd123-66d8-4bf4-a6d1-18fc7abcd999@34g2000hsh.googlegroups.com> inventor12 crack http://cracks.00bp.com F R E E C R A C K S From NIE_DZIALA at gazeta.pl Sat Apr 5 01:22:58 2008 From: NIE_DZIALA at gazeta.pl (Piotr Sobolewski) Date: Sat, 05 Apr 2008 07:22:58 +0200 Subject: variable scope in list comprehensions References: Message-ID: Duncan Booth wrote: > For the OP, in some languages (e.g. C) 'for' loops typically calculate > the value of the loop control variable based on some expression > involving the previous value. Python isn't like that. In Python the data > used to compute the next value is stored internally: you cannot access > it directly. Great! Now everything is clear. Thanks! From paul at itdreamreal.com Mon Apr 7 22:59:04 2008 From: paul at itdreamreal.com (paul Batoum.) Date: Mon, 7 Apr 2008 19:59:04 -0700 (PDT) Subject: python, Mysql_python, storm problem Message-ID: <16547127.post@talk.nabble.com> I am actually tryng to build a database apps in python + storm which use MySQLdb 1.2.2 i actually want the auto reconnect feature of storm, which just need to change the False param of raw_connect to True in storm/databases/mysql.py so far nothing really difficult but from there i got quite a weird result: if i try the following code, it works in the shell python interpreter but not when i put it in a test.py file and call it as python test.py (will be helpfull for unittest): So to make it simple the MySQL reconnect work in the shell interpreter and i got a DisconnectionError: (2006, 'MySQL server has gone away') when i use it the other way. Let me know if one of you have ever experienced something like that Thx Code: import database import time # Test timeout cases pdb = database.Database(connect_info) res = pdb.execute(u"SHOW VARIABLES LIKE 'wait_timeout'") # set the timeout to 3 sec pdb.execute("SET wait_timeout=3") res = pdb.execute(u"SHOW VARIABLES LIKE 'wait_timeout'") res = pdb.execute("select * from country") time.sleep(5) # try a new execute, this one should pass res = pdb.execute("select * from country") -- View this message in context: http://www.nabble.com/python%2C-Mysql_python%2C-storm-problem-tp16547127p16547127.html Sent from the Python - python-list mailing list archive at Nabble.com. From hat at se-162.se.wtb.tue.nl Tue Apr 22 10:30:44 2008 From: hat at se-162.se.wtb.tue.nl (A.T.Hofkamp) Date: Tue, 22 Apr 2008 16:30:44 +0200 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? References: Message-ID: On 2008-04-22, Harishankar wrote: > Hi, > > Sorry to start off on a negative note in the list, but I feel that the Python > subprocess module is sorely deficient because it lacks a mechanism to: > > 1. Create non-blocking pipes which can be read in a separate thread (I am I don't know about threading, but you can read/write streams in a non-blocking way in Python (under Linux) with the os.read/os.write functions (these map directly to read(2)/write(2) primitives). You should first check that something can be read/written. Use eg select.select() for this. Several GUI toolkits also allow monitoring of file handles. Whether this also works at other OSes, I don't know. Alternatively, you can create your own pipes, make them non-blocking, and give the file handles to subprocess. > 2. Kill the subprocess in a platform independent manner (i.e. no third party > modules and no hacks). The concept of sub-process is platform dependent already. Usually however, closing the child input stream is sufficient for most child programs to decide that they can quit. > Is there any way to use non-blocking Popen objects using subprocess? and 2 - > is there a way to kill the subprocess in a platform independent manner in a > purely Pythonic way? I thought initially that this problem is simple enough, > but over the last couple of days I've been really struggling to find any > answer. I've been through dozens of mailing list archives in to find a > solution. Unfortunately none of the solutions seem to fit my needs. Interfacing with the rest of the world implies you are going to need services provided by the OS at one time or another. Python is rather transparent here and gives you quick access to the OS services. While this is bad for uniformity, it is good to let people make their own choices in optimally using the OS services. Python helps here by giving light-weight access to the underlying OS, making explicit what part is OS dependent. (and if still in doubt, why do you think were all the solutions you found 'not fitting'?). > My only solution seems to be to offer the end user the mencoder command line > and make them execute it manually and be done with it but that seems a rather > weak solution. This is always a good fallback. Sincerely, Albert From mal at egenix.com Thu Apr 3 16:53:54 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Thu, 03 Apr 2008 22:53:54 +0200 Subject: object-relational mappers In-Reply-To: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> Message-ID: <47F543E2.9030302@egenix.com> On 2008-04-01 22:40, Aaron Watters wrote: > I've been poking around the world of object-relational > mappers and it inspired me to coin a corellary to the > the famous quote on regular expressions: > > "You have objects and a database: that's 2 problems. > So: get an object-relational mapper: > now you have 2**3 problems." > > That is to say I feel that they all make me learn > so much about the internals and features of the > O-R mapper itself that I would be better off rolling > my own queries on an as-needed basis without > wasting so many brain cells. > > comments? I fully agree :-) -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 03 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From kay.schluehr at gmx.net Sat Apr 5 02:31:38 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Fri, 4 Apr 2008 23:31:38 -0700 (PDT) Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> Message-ID: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> On 2 Apr., 06:38, Aldo Cortesi wrote: > Hi Ben, > > > > We are happy to announce the first release of Pry, a unit testing > > > framework. > > > Thanks for the announcement, and for the software. > > > If Pry is already incompatible with xUnit (i.e. Python's 'unittest'), > > could we please have names that adhere to the Python style guide > > ? > > > In particular the method names 'setUp', 'setUpAll', 'tearDown', > > 'tearDownAll' don't comply with the style guide. Compliant names for > > those methods would be 'set_up', 'set_up_all', etc. > > Keeping fixture setUp and tearDown names the same makes the transition > from unittest to pry easier. At the moment, converting to pry is very > simple - inherit your suites from AutoTree, rewrite tests to use > assertions, and then instantiate your suites at the end of the module. > Voila! You have a nice command-line interface, coverage analysis, and > an easy path to saner, better-engineered unit tests. But you could have added the integration of code coverage and other helpful features with unittest as a conservative extension giving everyone a chance to use it directly with existing tests instead of forcing them to rewrite their tests for bike shading purposes. From benash at gmail.com Thu Apr 3 02:39:51 2008 From: benash at gmail.com (benash at gmail.com) Date: Wed, 2 Apr 2008 23:39:51 -0700 Subject: Parsing HTML? In-Reply-To: References: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> Message-ID: BeautifulSoup does what I need it to. Though, I was hoping to find something that would let me work with the DOM the way JavaScript can work with web browsers' implementations of the DOM. Specifically, I'd like to be able to access the innerHTML element of a DOM element. Python's built-in HTMLParser is SAX-based, so I don't want to use that, and the minidom doesn't appear to implement this part of the DOM. On Wed, Apr 2, 2008 at 10:37 PM, Daniel Fetchinson wrote: > > I'm trying to parse an HTML file. I want to retrieve all of the text > > inside a certain tag that I find with XPath. The DOM seems to make > > this available with the innerHTML element, but I haven't found a way > > to do it in Python. > > Have you tried http://www.google.com/search?q=python+html+parser ? > > HTH, > Daniel > From bdsatish at gmail.com Fri Apr 11 07:42:22 2008 From: bdsatish at gmail.com (bdsatish) Date: Fri, 11 Apr 2008 04:42:22 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: <6ae183c4-5172-4dea-ba22-8c38fb96927c@s39g2000prd.googlegroups.com> On Apr 11, 4:37 pm, Scott David Daniels wrote: > bdsatish wrote: > > The built-in function round( ) will always "round up", that is 1.5 is > def rounded(v): > rounded = round(v) > if divmod(v, 1)[1] == .5 and divmod(rounded, 2)[1] == 1: > if v > 0: > return rounded - 1 > return rounded + 1 > return rounded > > last = None > for n in range(-29, 28): > x = n * .25 > r = xr(x) > if r != last: > last = r > print > print '%s->%s' % (x, xr(x)), > Hi Scott, This is what I was looking for.. I forgot about divmod( ) thanks for reminding. From medin0065 at gmail.com Sun Apr 20 10:47:39 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:47:39 -0700 (PDT) Subject: dark crusade patch 1.2 Message-ID: <814d3f2a-f8ff-4c83-b300-d6106f554650@k10g2000prm.googlegroups.com> dark crusade patch 1.2 http://cracks.00bp.com F R E E C R A C K S From george.sakkis at gmail.com Thu Apr 17 00:00:58 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 16 Apr 2008 21:00:58 -0700 (PDT) Subject: Default parameter for a method References: <806788d2-67b7-456b-bd1e-08c50cbf0f7b@8g2000hsu.googlegroups.com> <48065d11$0$36390$742ec2ed@news.sonic.net> Message-ID: On Apr 16, 4:21?pm, John Nagle wrote: > In general, default values should be immutable constants only. This is more restrictive than necessary; it should rather read "In general, default values should be *treated as* immutable objects only". It's perfectly fine for a default value to be mutable if the function doesn't modify it, as in the following example: def parse(text, stopwords=set(w.strip() for w in open('stopwords.txt')): words = [w for w in text.split() if w not in stopwords] ... Since the set is not modified, there's no harm for being mutable; IOW it's no different than using a frozenset instead. Similarly for dicts, lists and other mutable containers, as long as they are treated as read-only. George From martin at v.loewis.de Sun Apr 20 14:37:12 2008 From: martin at v.loewis.de (=?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 20 Apr 2008 20:37:12 +0200 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> Message-ID: <480b8d58$0$26996$9b622d9e@news.freenet.de> > Pure Python code can cause memory leaks. No, that's not a bug in the > interpreter but the fault of the developer. For example code that messes > around with stack frames and exception object can cause nasty reference > leaks. Can you give an example, please? Regards, Martin From skanemupp at yahoo.se Sun Apr 13 11:57:29 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 13 Apr 2008 08:57:29 -0700 (PDT) Subject: Tkinter, image not appearing in function but without function Message-ID: <42a33edd-5792-47ad-a940-ecb5df23accc@a9g2000prl.googlegroups.com> why is the first program not working? when i click the screen the map is not appearing. the second program works. from Tkinter import * master = Tk() w = Canvas(master, width=700, height=600) w.pack(expand = YES, fill = BOTH) def mapper(): mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\world-map.gif') w.create_image(10, 10, image = mapq, anchor = NW) def key(event): print "pressed", repr(event.char) def callback(event): w.focus_set() print "clicked at", event.x, event.y mapper() print 'yo' square = w.create_oval(event.x-5,event.y-5,event.x+5,event.y+5, fill="black") w.bind("", key) w.bind("", callback) w.pack() mainloop() from Tkinter import * master = Tk() w = Canvas(master, width=700, height=600) w.pack(expand = YES, fill = BOTH) q=raw_input("Choose: i=India, s=sweden, else World: ") if q=="i": mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\map-india.bmp') elif q=='s': mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\provinces-of- sweden.gif') else: mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\world-map.gif') print mapq.height(), mapq.width() w.create_image(10, 10, image = mapq, anchor = NW) def key(event): print "pressed", repr(event.char) def callback(event): w.focus_set() print "clicked at", event.x, event.y square = w.create_oval(event.x-5,event.y-5,event.x+5,event.y+5, fill="black") """hur hitta om inom ratt->kolla color of """ w.bind("", key) w.bind("", callback) w.pack() mainloop() From mensanator at aol.com Sat Apr 19 19:51:12 2008 From: mensanator at aol.com (Mensanator) Date: Sat, 19 Apr 2008 16:51:12 -0700 (PDT) Subject: random.random(), random not defined!? References: <2a3931f5-481d-4831-baad-fcc9f0c0c129@m73g2000hsh.googlegroups.com> <480a57de@news.mel.dft.com.au> Message-ID: <279fb48f-2d55-4c46-a8c4-d43e90a61fc8@l42g2000hsc.googlegroups.com> On Apr 19, 3:36?pm, John Machin wrote: > globalrev wrote: > > do i need to import something to use random? > > No, you need to import random But you could alsways import it as something. >>> import random as something >>> something.random() 0.45811606256668347 From sharma.mohit80 at gmail.com Tue Apr 1 06:57:38 2008 From: sharma.mohit80 at gmail.com (sharma.mohit80 at gmail.com) Date: Tue, 1 Apr 2008 03:57:38 -0700 (PDT) Subject: Canon Laser Printer Message-ID: Canon Laser Printer - LBP2900 :- Features: * New print technologies for faster printouts with print speeds of up to 12ppm monochrome, the LBP2900 offers fast printouts at an affordable price. * Two groundbreaking Canon technologies: CAPT 2.1 and Hi-SCoA redesign the printing process for improved performance. * CAPT 2.1, or Canon advanced printing technology, harnesses the power of the PC to speed up print jobs, instead of loading up the printer with expensive memory upgrades. more features information please visit - http://www.homeshop18.com/shop/u/y/p-Computers-Q-and-Q-Peripherals-S-Printers-Q-and-Q-Scanners-S-Laser-S-Canon-Q-Laser-Q-Printer-Q---Q-LBP2900/Home_Online-pI_3952-clI_2-cI_998-pCI_925- From gggg.iiiii at gmail.com Wed Apr 9 13:17:21 2008 From: gggg.iiiii at gmail.com (G) Date: Wed, 9 Apr 2008 13:17:21 -0400 Subject: question about string formatting In-Reply-To: <42b9a3ff0804091004s4d60751fh68c82673e8e3f4c3@mail.gmail.com> References: <42b9a3ff0804091004s4d60751fh68c82673e8e3f4c3@mail.gmail.com> Message-ID: <4a7f84ac0804091017o7775a9a5k17f8434914b3dd43@mail.gmail.com> >>> import locale >>> locale.setlocale(locale.LC_ALL, '') 'en_US.UTF-8' >>> locale.format('%.2f', 1021212.12, True) '1,021,212.12' >>> On Wed, Apr 9, 2008 at 1:04 PM, Kelie wrote: > Hello, > > Is there something in Python built-in function or library that will > convert a number 1205466.654 to $1,205,466.65? To add the "$" sign and set > the decimal place is not a problem, but I don't know how to add the > thousands delimiter. > > Thanks, > > -- > Kelie > UliPad is my Python editor. > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Sat Apr 5 07:55:35 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 13:55:35 +0200 Subject: In Tkinter - having an input and an entry In-Reply-To: <29f44489-e589-4331-8bea-36fa346026d2@t54g2000hsg.googlegroups.com> References: <29f44489-e589-4331-8bea-36fa346026d2@t54g2000hsg.googlegroups.com> Message-ID: markfernandes02 at googlemail.com wrote: > Traceback (most recent call last): > File "F:\Programming\python and database\access_db8.2.py", line 129, > in ? > Tkwindow() > File "F:\Programming\python and database\access_db8.2.py", line 88, > in Tkwindow > title = stringVar() > NameError: global name 'stringVar' is not defined >>> "StringVar" == "stringVar" False From fetchinson at googlemail.com Wed Apr 9 14:22:46 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Wed, 9 Apr 2008 11:22:46 -0700 Subject: Google App Engine In-Reply-To: <3d4cae10-17bb-4d53-b84f-236287bd5893@m44g2000hsc.googlegroups.com> References: <47fc2c7c$0$36365$742ec2ed@news.sonic.net> <7e43fcd9-6207-4af2-8256-c0099a8ce0bb@1g2000prf.googlegroups.com> <3d4cae10-17bb-4d53-b84f-236287bd5893@m44g2000hsc.googlegroups.com> Message-ID: > > > The backend data store, while it has a vaguely SQLish query language is an > > object database not a relational database, i.e. more like ZODB than MySQL. > > It uses similar concepts to django's data api but isn't the same. It > should > > be possible to write something simple to replace it, but given that you > > only need to migrate away from Google when your data or page hits get > > large, you need to replace it with something scalable. > > I have a bet with a coworker that someone will implement the api, in a > way that makes migration away from Google easy, within a month. > (actually, the bet is just that there will be a project with this > goal). The reason I mention it here, is that he had the same comments > as you regarding this. My thinking is that (if past experiences can be > used as a yardstick) the python community will see this deficiency and > work to correct it. As a result of that thinking, I am fairly certain > that this concern is not a big concern. The authentication thing, > thats a bit different. The best would be if the google datastore backend would be available from sqlalchemy or sqlobject. I understand that the google datastore is not a relational database but that just means that the full power of sqlalchemy or sqlobject would not be available for this backend only a limited subset. I think this should be doable especially because GQL is very similar to SQL looks like it's really a proper subset. From goldtech at worldpost.com Fri Apr 25 11:21:28 2008 From: goldtech at worldpost.com (goldtech) Date: Fri, 25 Apr 2008 08:21:28 -0700 (PDT) Subject: Tkinter scrollbar and checkbox References: <9581b4cd-36f1-47dc-ae6e-0ca58f1b38e0@27g2000hsf.googlegroups.com> <741dfbee-530e-49af-a1fc-deb3cebbbd16@w74g2000hsh.googlegroups.com> Message-ID: <7e29cb37-4bd1-4533-9bd2-8b6616cfa542@e53g2000hsa.googlegroups.com> snip... > > I use wxPython most of the time, however effbot has a good tutorial on > scrollbars for Tkinter that I think you might find helpful: > > http://effbot.org/zone/tkinter-scrollbar-patterns.htm > > Here's another link on the subject: > > http://www.pythonware.com/library/tkinter/introduction/scrollbar.htm > > HTH > > Mike Indeed, I see it: http://effbot.org/zone/tkinter-autoscrollbar.htm Many Thanks. Lee From Scott.Daniels at Acm.Org Wed Apr 2 23:33:23 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Wed, 02 Apr 2008 20:33:23 -0700 Subject: Directed Graph Traversal In-Reply-To: <804682cb-2da6-4d85-83d4-c7425c498534@p25g2000hsf.googlegroups.com> References: <804682cb-2da6-4d85-83d4-c7425c498534@p25g2000hsf.googlegroups.com> Message-ID: bukzor wrote: > Can someone point me in the direction of a good solution of this? I'm > using it to construct a SQL query compiler, .... > Given a directed graph and a list of points in the graph, what is the > minimal subgraph that contains them all? It is preferable that the > subgraph is a tree. I did something nice (but non-redistributable) on this once: here is the driving intuition: * Start with every point a distinct color. * Add all points adjacent in the digraph as the same color; merge colors as you join them. * When you are down to to a single color, you have the minimal solution in the set you've chosen. I actually did a cheapest-first search; adding an edge each time. There is a post-join pruning step that was (as I recall) fairly simple. -Scott David Daniels Scott.Daniels at Acm.Org From pavlovevidence at gmail.com Thu Apr 17 07:06:22 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Thu, 17 Apr 2008 04:06:22 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> Message-ID: On Apr 17, 4:41 am, Sverker Nilsson wrote: > On Apr 17, 12:02 am, Carl Banks wrote: > > > > > On Apr 16, 12:40 pm, Aaron Watters wrote: > > > > On Apr 16, 12:27 pm, Rhamphoryncus wrote: > > > > > On Apr 16, 6:56 am, Aaron Watters wrote: > > > > > > I don't get it. It ain't broke. Don't fix it. > > > > > So how would you have done the old-style class to new-style class > > > > transition? > > > > I'd ignore it. I never understood it and never had > > > any need for it anyway. New-style classes and metaclasses > > > were a complicated solution to an unimportant problem in > > > my opinion. And also a fiendish way to make code > > > inscrutible -- which I thought was more of a Perl thing > > > than a Python thing, or should be. > > > > I must be missing some of the deeper issues here. Please > > > educate me. > > > The deeper issue is that you're benefiting from these "unimportant" > > changes even if you never use them yourself. > > > Carl Banks > > That just seems a BIT categorical for a statement. Who is 'you'? The Python community, more or less. The person I was replying to, specifically. > I don't see I benefit from any important or unimportant features in > py3k. I was talking about the features added in 2.x. Python 3.0 features haven't benefited many people (yet). [snip] > Just my 2c. If you don't mind me saying, I think you've given us quite a bit more than 2c in this thread. Carl Banks From corvettecraz92 at gmail.com Fri Apr 11 10:16:37 2008 From: corvettecraz92 at gmail.com (corvettecraz92 at gmail.com) Date: Fri, 11 Apr 2008 07:16:37 -0700 (PDT) Subject: text adventure game problem References: <4fb4fb0d-4cb2-4fcd-a207-a0341d92e82b@8g2000hsu.googlegroups.com> Message-ID: <7e1c3f97-ff17-4add-8d45-40f7b48dec4a@l64g2000hse.googlegroups.com> On Apr 11, 1:40?am, Dennis Lee Bieber wrote: > On Thu, 10 Apr 2008 05:06:42 -0700 (PDT), corvettecra... at gmail.com > declaimed the following in comp.lang.python: > > > okay, that explains it... > > could you provide a working example of a two-room game using your > > method please so I can understand it better? Thanks in advance! > > ? ? ? ? Okay... It isn't the best thought out system -- I have too > many specific classes... It would probably be better to put actions into > dictionaries and use some custom .getattr() to handle them. > > ? ? ? ? Will four rooms, a hidden chunk of gold, and one other movable > object suffice? Watch out for news client line wrapping. The only > parsing done is of the form: verb object; no attempt to handle: verb > direct_object filler indirect_object > > -=-=-=-=-=-=- > # > # ? TAGS.py ? ? Text Adventure Game Shell > # > > # ? I've probably defined too many special classes here > class Gobject(object): ?#Game object > ? ? def __init__(self, name, description, hidden=False, fixed=True): > ? ? ? ? self._name = name > ? ? ? ? self._description = description > ? ? ? ? self.hidden = hidden ? #hidden objects are not visible to > EXAMINE > ? ? ? ? self.fixed = fixed ? ? #fixed objects can not be taken > ? ? def _getName(self): > ? ? ? ? return self._name > ? ? name = property(_getName) > ? ? def _getDescription(self): > ? ? ? ? return self._description > ? ? description = property(_getDescription) > > class Exit(Gobject): > ? ? def __init__(self, description, target, hidden=False): > ? ? ? ? super(Exit, self).__init__(None, description, hidden) > ? ? ? ? self._target = target > ? ? def _getTarget(self): > ? ? ? ? return self._target > ? ? target = property(_getTarget) > > class Room(Gobject): ? ?#rooms (container object) > ? ? def __init__(self, name, description, exits=None, details=None): > ? ? ? ? super(Room, self).__init__(name, description, hidden=False, > fixed=True) > ? ? ? ? self._exits = exits > ? ? ? ? if details: > ? ? ? ? ? ? self._details = details ? ? #other objects that are inside > the room > ? ? ? ? else: > ? ? ? ? ? ? self._details = {} > ? ? def setExits(self, exits): > ? ? ? ? self._exits = exits > ? ? def go(self, ext): > ? ? ? ? return self._exits.get(ext, None) > ? ? def setDetails(self, details): > ? ? ? ? self._details = details > ? ? def addDetail(self, itm): > ? ? ? ? self._details[itm.name] = itm > ? ? def delDetail(self, name): > ? ? ? ? if (name in self._details and > ? ? ? ? ? ? not self._details[name].fixed): > ? ? ? ? ? ? itm = self._details[name] > ? ? ? ? ? ? del self._details[name] > ? ? ? ? else: > ? ? ? ? ? ? itm = None > ? ? ? ? return itm > ? ? def examine(self, name=None): > ? ? ? ? if not name: return self.description > ? ? ? ? if (name in self._details > ? ? ? ? ? ? and not self._details[name].hidden): > ? ? ? ? ? ? return self._details[name].description > ? ? ? ? else: > ? ? ? ? ? ? return None > ? ? def _detailedDescription(self): > ? ? ? ? items = "nothing of interest" > ? ? ? ? if self._details: > ? ? ? ? ? ? items = ", ".join([itm.name for itm in > self._details.values() > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?if not itm.hidden]) > ? ? ? ? exits = ", ".join([ext for ext in self._exits.keys() > ? ? ? ? ? ? ? ? ? ? ? ? ? ?if not self._exits[ext].hidden]) > ? ? ? ? #there must be at least one exit (the way you came in) > ? ? ? ? return "%s. In the %s you see %s. Passages lead to %s." % > (self._description, > ?self.name, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? items, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? exits) > ? ? description = property(_detailedDescription) > > class Thing(Gobject): > ? ? def __init__(self, name, description, parent, hidden=False, > fixed=False): > ? ? ? ? super(Thing, self).__init__(name, description, hidden, fixed) > ? ? ? ? self.parent = parent > ? ? def take(self): > ? ? ? ? if self.fixed: > ? ? ? ? ? ? return None > ? ? ? ? else: > ? ? ? ? ? ? self.hidden = False ? ? #if taken, one now can see it > ? ? ? ? ? ? return self.parent.delDetail(self.name) > ? ? def drop(self, parent): > ? ? ? ? self.parent.delDetail(self.name) > ? ? ? ? parent.addDetail(self) > > class TriggerThing(Thing): > ? ? def __init__(self, name, description, parent, > ? ? ? ? ? ? ? ? ?hidden=False, fixed=True, triggers=None): > ? ? ? ? super(TriggerThing, self).__init__(name, description, parent, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?hidden, fixed) > ? ? ? ? self._triggers = triggers > ? ? def _detailedDescription(self): > ? ? ? ? if self._triggers: > ? ? ? ? ? ? items = ", ".join([itm.name for itm in > self.parent._details.values() > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?if itm in self._triggers > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?and itm.hidden]) > ? ? ? ? else: > ? ? ? ? ? ? items = ", ".join([itm.name for item in > self.parent._details.values() > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?if itm.hidden]) > ? ? ? ? if not items: items = "nothing of interest" > ? ? ? ? return "%s. In the %s you see %s." % (self._description, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? self.name, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? items) > ? ? description = property(_detailedDescription) > > class Money(Thing): > ? ? # ? note: I've not worked out how to safely handle combining money > objects > ? ? def __init__(self, name, description, amount, parent, hidden=False, > fixed=False): > ? ? ? ? super(Money, self).__init__(name, description, parent, hidden, > fixed) > ? ? ? ? self._value = amount > ? ? def _detailedDescription(self): > ? ? ? ? return "%s pieces of gold" % self._value > ? ? description = property(_detailedDescription) > ? ? def combine(self, money): > ? ? ? ? self._value += money._value > > class Avatar(Gobject): > ? ? def __init__(self, name, description, location, hidden=True, > fixed=True): > ? ? ? ? super(Avatar, self).__init__(name, description, hidden, fixed) > ? ? ? ? self.location = location > ? ? ? ? self._inventory = {} > ? ? def addInv(self, itm): > ? ? ? ? itm.hidden = False > ? ? ? ? if itm.name in self._inventory: ?#presume only gold is > duplicated > ? ? ? ? ? ? self._inventory[itm.name].combine(itm) > ? ? ? ? ? ? del itm > ? ? ? ? else: > ? ? ? ? ? ? self._inventory[itm.name] = itm > ? ? def remInv(self, name): > ? ? ? ? ? ?itm = self._inventory.get(name, None) > ? ? ? ? ? ?if itm: del self._inventory[name] > ? ? ? ? ? ?return itm > ? ? def inv(self): > ? ? ? ? return ", ".join([itm for itm in self._inventory.keys()]) > > #create the universe -- first the raw rooms > room1 = Room("empty room", > ? ? ? ? ? ? ?"a completely empty room") > room2 = Room("time passages", > ? ? ? ? ? ? ?"a fourth-dimensional room having no fixed shape or size") > room3 = Room("control room", > ? ? ? ? ? ? ?"the control room of a TARDIS") > room4 = Room("locker room", > ? ? ? ? ? ? ?"a room full of storage spaces") > > #create each exit > exit1_2 = Exit("you squeeze through the mouse hole", room2) > exit1_4 = Exit("you take the doorway", room4) > exit2_3 = Exit("the TARDIS door opens and you pass in", room3, > hidden=True) > exit3_2 = Exit("you leave the TARDIS", room2) > exit3_1 = Exit("you sneak deeper into the depths of the TARDIS", room1) > exit4_1 = Exit("you move through the door", room1) > exit2_1 = Exit("you take the wormhole out", room1) > exit2_4 = Exit("you follow the light", room4) > exit4_2 = Exit("you follow the shadow", room2) > exit2_2a = Exit("as you enter the reddish passage you see yourself > leaving the room", room2) > exit2_2b = Exit("you feel a bit older as you take the blue passage", > room2) > exit2_2c = Exit("you feel confused as you cross webs of the timestream", > room2) > > #connect rooms to exits > room1.setExits({"hole" : exit1_2, > ? ? ? ? ? ? ? ? "door" : exit1_4}) > room2.setExits({"tardis" : exit2_3, > ? ? ? ? ? ? ? ? "wormhole" : exit2_1, > ? ? ? ? ? ? ? ? "light" : exit2_4, > ? ? ? ? ? ? ? ? "past" : exit2_2a, > ? ? ? ? ? ? ? ? "future" : exit2_2b, > ? ? ? ? ? ? ? ? "sideways" : exit2_2c}) > room3.setExits({"out" : exit3_2, > ? ? ? ? ? ? ? ? "in" : exit3_1}) > room4.setExits({"door" : exit4_1, > ? ? ? ? ? ? ? ? "shadow" : exit4_2}) > > #create a few non-room objects > container1 = Thing("closet", "an empty closet", room4, fixed=True) > gold = Money("gold", None, 8, room4, hidden=True) > container2 = TriggerThing("footlocker", "a fancy carved captain's > chest", room4, > ? ? ? ? ? ? ? ? ? ? ? ? ? fixed=True, triggers=[gold]) > > room4.setDetails({container1.name : container1, > ? ? ? ? ? ? ? ? ? container2.name : container2, > ? ? ? ? ? ? ? ? ? gold.name : gold}) > > #the tardis is both an exit and a thing > tardis = Thing("tardis", "a beat-up type 40 TARDIS", room2, fixed=True) > room2.setDetails({tardis.name : tardis}) > > screwdriver = Thing("screwdriver", "a well worn sonic screwdriver", > room3) > room3.setDetails({screwdriver.name : screwdriver}) > > player = Avatar("Wulfraed", "a nondescript individual", room1) > > #note: no end conditions are defined > while True: > ? ? print player.location.description > ? ? while True: > ? ? ? ? cmdstr = raw_input("command> ").strip().lower() > ? ? ? ? if cmdstr: break > ? ? words = cmdstr.split() > ? ? verb = words[0] > ? ? if len(words) > 1: > ? ? ? ? objct = words[1] > ? ? else: > ? ? ? ? objct = None > ? ? if verb in ["look", "examine"]: > ? ? ? ? if objct: > ? ? ? ? ? ? desc = player.location.examine(objct) > ? ? ? ? else: > ? ? ? ? ? ? desc = player.location.examine() > ? ? ? ? if desc: > ? ? ? ? ? ? print desc > ? ? ? ? else: > ? ? ? ? ? ? print "I don't see that here" > ? ? elif verb in ["grab", "take"]: > ? ? ? ? if objct: > ? ? ? ? ? ? itm = player.location.delDetail(objct) > ? ? ? ? ? ? if itm: > ? ? ? ? ? ? ? ? player.addInv(itm) > ? ? ? ? ? ? ? ? print "%s taken" % itm.name > ? ? ? ? ? ? else: > ? ? ? ? ? ? ? ? print "I can not %s the %s" % (verb, objct) > ? ? ? ? else: > ? ? ? ? ? ? print "%s what?" % verb > ? ? elif verb in ["drop", "leave"]: > ? ? ? ? if objct: > ? ? ? ? ? ? itm = player.remInv(objct) > ? ? ? ? ? ? if itm: > ? ? ? ? ? ? ? ? player.location.addDetail(itm) > ? ? ? ? ? ? ? ? print "%s dropped" % itm.name > ? ? ? ? ? ? else: > ? ? ? ? ? ? ? ? print "I don't have the %s" % objct > ? ? ? ? else: > ? ? ? ? ? ? print "%s what?" % verb > ? ? elif verb in ["walk", "run", "go"]: > ? ? ? ? if objct: > ? ? ? ? ? ? ext = player.location.go(objct) > ? ? ? ? ? ? if ext: > ? ? ? ? ? ? ? ? print ext.description > ? ? ? ? ? ? ? ? player.location = ext.target > ? ? ? ? ? ? else: > ? ? ? ? ? ? ? ? print "I can't go that way" > ? ? ? ? else: > ? ? ? ? ? ? print "%s where?" % verb > ? ? elif verb... > > read more ? I still can't run that....after fixing the simple stuff like 'invalid syntax', there's the "Name examine is not defined." So... From jeffrey at fro.man Mon Apr 7 14:24:47 2008 From: jeffrey at fro.man (Jeffrey Froman) Date: Mon, 07 Apr 2008 11:24:47 -0700 Subject: Tips for load balancing multiple Python apps on dual/quad core processors? References: Message-ID: <9MmdnSE8nY9t-2fanZ2dnUVZ_uevnZ2d@cablespeedwa.com> Malcolm Greene wrote: > I'm looking for tips on how to load balance running multiple Python > applications in multi-CPU environments. My understanding is that Python > applications and their threads are limited to a specific CPU. > > Background: I have a Python utility that processes email messages. I > suspect there's a lot of idle time while this utility waits on a remote > email server. While it's true that python's threads are limited to using a single CPU at a time, it sounds like your bottleneck is network IO, not CPU power. I imagine that your one CPU is doing a lot of idling, thumb-twiddling, etc., while waiting for the remote email server to respond. In such a scenario, python's threads will work fine to speed your application. On the other hand, adding CPUs to an IO-bound application isn't likely to speed it up at all. Jeffrey From __peter__ at web.de Tue Apr 29 02:35:46 2008 From: __peter__ at web.de (Peter Otten) Date: Tue, 29 Apr 2008 08:35:46 +0200 Subject: File IO Issues, help :( References: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> <1fd8deae-1ed4-493c-a508-06c528c4ee1f@r66g2000hsg.googlegroups.com> Message-ID: Kevin K wrote: > On Apr 29, 12:55 am, Peter Otten <__pete... at web.de> wrote: >> Kevin K wrote: >> > On Apr 29, 12:38 am, "Eric Wertman" wrote: >> >> chuck in a jsfile.close(). The buffer isn't flushing with what you >> >> are doing now. jsfile.flush() might work... not sure. Closing and >> >> re-opening the file for sure will help though. >> >> > Yeah sorry I forgot to include the close() in the quote but its there. >> > In fact I moved it up a bit and still no luck heres the new code: >> >> > jsfile = open("../timeline.js", "r+") >> > jscontent = jsfile.readlines() >> > jsfile.truncate() >> >> > for line in jscontent: >> > if re.search('var d =', line): >> > line = "var d = \""+mint['1'].ascdate()+"\"\n" >> > print line >> > jsfile.write(line) >> > jsfile.close() >> >> > I tried this can got the same result...?? >> >> """ >> truncate(...) >> truncate([size]) -> None. Truncate the file to at most size bytes. >> >> Size defaults to the current file position, as returned by tell(). >> """ >> >> After the readlines() call the current file position is at the end of the >> file. Try jsfile.truncate(0). >> >> Also note that readlines() reads the whole file into memory. For large >> files it would therefore be better to write to a new file and rename it >> afterwards. >> >> Peter > > Thanks Peter that seemed to be most of the problem, however I now have > a bunch of null characters in the file. Could it be an unwanted line > in the list that im writing? Oops, truncate() doesn't affect the file position. You probably need jsfile.truncate(0) jsfile.seek(0) Peter From xng at xs4all.nl Thu Apr 17 19:21:31 2008 From: xng at xs4all.nl (Martin P. Hellwig) Date: Fri, 18 Apr 2008 01:21:31 +0200 Subject: get quote enclosed field in a line In-Reply-To: References: Message-ID: <4807dc10$0$25223$e4fe514c@dreader18.news.xs4all.nl> xahlee at gmail.com wrote: > is there a simple way in perl, python, or awk/shell/pipe, that gets > the user agent field in a apache log? > > e.g. the typical line is like this: > > 189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET / > Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org > "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/ > 5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311 > Firefox/2.0.0.13" "-" > > I want the part: "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv: > 1.8.1.13) Gecko/20080311 Firefox/2.0.0.13". > > Thanks. > > Xah > xah at xahlee.org > ? http://xahlee.org/ > > ? Something like: # cut -d '"' -f 6 < httpd-access.log ? -- mph From python.list at tim.thechases.com Tue Apr 8 16:49:59 2008 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 08 Apr 2008 15:49:59 -0500 Subject: new user needs help! In-Reply-To: References: <16571823.post@talk.nabble.com> Message-ID: <47FBDA77.1030009@tim.thechases.com> > f = open("/tmp/data.txt", 'w') > > will open that file. > > You can throw the first line away with > > headings = f.next() > > Then you can loop over the rest with > > for name, aa, topo, access, dssp, stride, z in file: > # > # Then process each line here Small caveat here...Steve changed file-variables on you here, and assumed a tuple-unpacking that won't work. You'll want something like for line in f: (name, aa, topo, access, dssp, stride, z) = ( line.rstrip('\n').split('\t') # process the line here I don't know how your fields are delimited, whether by spaces or tabs. In the above code, I split by tabs, but you can just use .split() if it should be split on any white-space. It's a bit more complex if you need to split by column-offsets. -tkc From karthikk at adventnet.com Tue Apr 8 05:48:54 2008 From: karthikk at adventnet.com (Karthik) Date: Tue, 08 Apr 2008 15:18:54 +0530 Subject: Setting default version among multiple python installations Message-ID: <47FB3F86.5040702@adventnet.com> Hello, I am an absolute linux and python newbie. The linux machine(red hat version 7.2) that i managed to get my hands on had python 1.5(vintage stuff, i guess) in it. I have installed python 2.5 using the source tar. However, when i try to access python, i am taken to the older version only. How do i set python2.5 as the default version? -Karthik -------------- next part -------------- An HTML attachment was scrubbed... URL: From sjmachin at lexicon.net Sun Apr 13 19:54:14 2008 From: sjmachin at lexicon.net (John Machin) Date: Sun, 13 Apr 2008 16:54:14 -0700 (PDT) Subject: py2exe, program has stoped working!? References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> Message-ID: <232151d6-09ed-4a1e-9922-d66c2bf0d05b@w8g2000prd.googlegroups.com> On Apr 13, 11:52 pm, skanem... at yahoo.se wrote: > so i used py2exe and i have the build and the dist-folders. > > in the distfolder there is a Calculator.exe file. > > when i run it it just says "Calculator.exe has stopped working" in a > popup but the program itself never shows up. Is it a console program or a gui program? What happens when you run it without py2exe? Have you searched for "has stopped working" in (a) your source code (b) the py2exe source code? Have you managed to get any py2exe-created program to run properly? From Randy.Galbraith at gmail.com Tue Apr 22 12:46:43 2008 From: Randy.Galbraith at gmail.com (Randy Galbraith) Date: Tue, 22 Apr 2008 09:46:43 -0700 (PDT) Subject: Compiling Python 2.5.2 on AIX 5.2 References: <0b73e8e5-c301-4823-ac94-42f757456cf1@x19g2000prg.googlegroups.com> <48059DA9.5080900@v.loewis.de> <480c2364$0$26788$9b622d9e@news.freenet.de> Message-ID: On Apr 20, 10:17 pm, "Martin v. L?wis" wrote: > I recommend you disable compilation of ctypes (by removing the call > to detect_ctypes from setup.py). It's fairly unlikely that you can > manage to make ctypes work on your system. Martin, Thanks again. I'm much closer now. Here is the script I'm using to compile Python on AIX: --begin script-- cp /path/to/include/bzlib.h Include/. cat <: [Errno 22] Invalid argument and for wait4: test test_wait4 failed -- Traceback (most recent call last): File "Python-2.5.2/Lib/test/fork_wait.py", line 75, in test_wait self.wait_impl(cpid) File "Python-2.5.2/Lib/test/test_wait4.py", line 28, in wait_impl self.assertEqual(spid, cpid) AssertionError: 0 != 6840386 What do these failures indicate? Not sure of course, but will research and report back. Kind regards, -Randy Galbraith "We seem to be made to suffer. It's our lot in life." - C3PO of Star Wars From stesch at no-spoon.de Wed Apr 2 03:03:33 2008 From: stesch at no-spoon.de (Stefan Scholl) Date: Wed, 2 Apr 2008 09:03:33 +0200 Subject: developing web spider References: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> Message-ID: <2T4u1vuoI47qNv8%stesch@parsec.no-spoon.de> abeen wrote: > I would want to know which could be the best programming language for > developing web spider. Since you ask in comp.lang.python: I'd suggest APL -- Web (en): http://www.no-spoon.de/ -*- Web (de): http://www.frell.de/ From wizzardx at gmail.com Tue Apr 22 15:38:08 2008 From: wizzardx at gmail.com (David) Date: Tue, 22 Apr 2008 21:38:08 +0200 Subject: Setting expirty data on a cookie In-Reply-To: <8ba48e05-9aba-4a56-805c-cd31b43517ab@24g2000hsh.googlegroups.com> References: <8ba48e05-9aba-4a56-805c-cd31b43517ab@24g2000hsh.googlegroups.com> Message-ID: <18c1e6480804221238x574bf3dbxb9a2f25d445f190b@mail.gmail.com> On Tue, Apr 22, 2008 at 6:21 PM, sophie_newbie wrote: > Does anyone know how to do this? I can't seem to make it work. > > I'm using: > > c = Cookie.SimpleCookie() > c['data'] = "unamepwordwhatever" > c.expires = time.time() + 300 > print c > > > This doesn't seem to work, so I'm assuming isn't the correct way to > set an expiry data? Anyone able to help me out here? > You're probably looking for cookielib.Cookie From bgeddy at home.havin.a.break Mon Apr 28 08:13:17 2008 From: bgeddy at home.havin.a.break (bgeddy) Date: Mon, 28 Apr 2008 13:13:17 +0100 Subject: Retrieving int from hex in a file. In-Reply-To: <9edfaaa3-4e87-4f74-90a5-c10c9daae101@r66g2000hsg.googlegroups.com> References: <9edfaaa3-4e87-4f74-90a5-c10c9daae101@r66g2000hsg.googlegroups.com> Message-ID: Filipe Teixeira wrote: > Hi. > > I have to open a binary file from an old computer and recover the > information stored (or at least try to). I use: > > f=open('file.bin','rb') > a=f.read() > f.close() > > a in now a string full of hex representations in the form: > > a[6]='\x14' > a[7]='\x20' > > I would like to convert these hex representations to int, but this > (the most obvious way) doesn't seem to be working > >>>> q=a[6] >>>> q > '\x14' >>>> int(q,16) > Traceback (most recent call last): > File "", line 1, in ? > ValueError: invalid literal for int(): > > How can I do this? > > Thanks As you say you are trying to recover information from the old computer are you sure you want to convert the data to it's integer representation ? What I mean is in this case the string will contain the actual data read from the file, not a hex representation. It's just the python displays this data as '\x14'. BTW - are you sure it's displaying '\x20' from your data as this should be a space character i.e. " ". In the python interpreter try this: mydata="" for i in range(256): mydata+=chr(i) >> mydata This will show you the hex representation of the values in mydata that it can't display however the string is not a string of "hex values" as such, it contains the binary values 0-255. From the.blue.valkyrie at gmail.com Tue Apr 8 09:54:12 2008 From: the.blue.valkyrie at gmail.com (=?ISO-8859-1?Q?Cristina_Yenyxe_Gonz=E1lez_Garc=EDa?=) Date: Tue, 8 Apr 2008 15:54:12 +0200 Subject: UML reverse engineering In-Reply-To: <4660fe300804050617k28769016k4687246349352cdc@mail.gmail.com> References: <6712345.1824821207324312295.JavaMail.servlet@kundenserver> <4660fe300804050617k28769016k4687246349352cdc@mail.gmail.com> Message-ID: If you are a Linux user, you can also take a look at Umbrello UML (it is part of the KDE Desktop). -------------- next part -------------- An HTML attachment was scrubbed... URL: From pscott at uwc.ac.za Tue Apr 8 04:10:25 2008 From: pscott at uwc.ac.za (Paul Scott) Date: Tue, 08 Apr 2008 10:10:25 +0200 Subject: First Python project - comments welcome! In-Reply-To: <4a200ecf-a945-4cb6-8f91-0b8baf378e18@n58g2000hsf.googlegroups.com> References: <4a200ecf-a945-4cb6-8f91-0b8baf378e18@n58g2000hsf.googlegroups.com> Message-ID: <1207642225.13710.35.camel@paul-laptop> On Mon, 2008-04-07 at 06:20 -0700, bruno.desthuilliers at gmail.com wrote: > > If anyone on this list is willing/able, please do give me a few > > pointers, even if it is "This is total crap - RTFM and come back when > > you are ready" I would really appreciate it! > > Ok, since you asked for it: > Awesome feedback! Thank you very much. This is exactly what I needed. I will take this into the code as soon as I have some time to play with it again and fix it up. Much appreciated! --Paul -------------- next part -------------- All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm From fennelllindy8241 at gmail.com Mon Apr 28 03:24:11 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:24:11 -0700 (PDT) Subject: ravenhearst crack Message-ID: <80344dda-9026-44f8-aef9-eb61c2e554fc@x35g2000hsb.googlegroups.com> ravenhearst crack http://crack.cracksofts.com From Jim.Vickroy at noaa.gov Wed Apr 2 14:17:33 2008 From: Jim.Vickroy at noaa.gov (j vickroy) Date: Wed, 02 Apr 2008 12:17:33 -0600 Subject: ANN: pry unit testing framework In-Reply-To: References: Message-ID: <47F3CDBD.1010600@noaa.gov> Aldo Cortesi wrote: > We are happy to announce the first release of Pry, a unit testing framework. > > Features > ======== > > * Built-in coverage analysis, profiling, and quick-and-dirty benchmarking > * Assertion-based tests - no ugly failUnless*, failIf*, etc. methods > * Tree-based test structure for better fixture management > * No implicit instantiation of test suits > * Powerful command-line interface > > > Download: http://dev.nullcube.com > > Manual: http://dev.nullcube.com/doc/pry/index.html > > It appears this package can not be used with Microsoft Windows because it uses the *fcntl* module which is not part of the Windows distribution. >>> import sys >>> sys.version '2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]' >>> >>> import libpry Traceback (most recent call last): File "", line 1, in File "C:\Python25\Lib\site-packages\libpry\__init__.py", line 1, in from test import * File "C:\Python25\Lib\site-packages\libpry\test.py", line 4, in import _tinytree, explain, coverage, utils File "C:\Python25\Lib\site-packages\libpry\coverage.py", line 3, in import utils File "C:\Python25\lib\site-packages\libpry\utils.py", line 1, in import os.path, fnmatch, struct, fcntl, termios, os ImportError: No module named fcntl Unfortunate, because I'm definitely interested in the code coverage and profiling features. -- jv From danb_83 at yahoo.com Tue Apr 8 00:19:57 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Mon, 7 Apr 2008 21:19:57 -0700 (PDT) Subject: Newbie: How to pass a dictionary to a function? References: <516e07d1-91f9-462b-9fc0-ac6d1e474f9d@n14g2000pri.googlegroups.com> Message-ID: <1a0d619e-d910-41c9-b85b-612f50cb96b9@t36g2000prm.googlegroups.com> On Apr 7, 10:54 pm, BonusOnus wrote: > How do I pass a dictionary to a function as an argument? The same way you pass any other argument. > # Say I have a function foo... > def foo (arg=[]): It's generally a bad idea to use [] as a default argument. > x = arg['name'] > y = arg['len'] > > s = len (x) > > t = s + y > > return (s, t) Apart from the lack of indentation (and meaningless variable names), it looks correct. > # The dictionary: > > dict = {} > dict['name'] = 'Joe Shmoe' > dict['len'] = 44 "dict" is a built-in name. Don't redefine it. > # I try to pass the dictionary as an argument to a > # function > > len, string = foo (dict) Don't redefine "len" or "string" either. > # This bombs with 'TypeError: unpack non-sequence' > > What am I doing wrong with the dictionary? Runs fine for me as soon as I fixed the indentation. From gagsl-py2 at yahoo.com.ar Mon Apr 28 06:29:12 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 28 Apr 2008 07:29:12 -0300 Subject: Retrieving int from hex in a file. References: <9edfaaa3-4e87-4f74-90a5-c10c9daae101@r66g2000hsg.googlegroups.com> Message-ID: En Mon, 28 Apr 2008 07:14:51 -0300, Filipe Teixeira escribi?: > a in now a string full of hex representations in the form: > > a[6]='\x14' > a[7]='\x20' > > I would like to convert these hex representations to int, but this > (the most obvious way) doesn't seem to be working > >>>> q=a[6] >>>> q > '\x14' >>>> int(q,16) > Traceback (most recent call last): > File "", line 1, in ? > ValueError: invalid literal for int(): >>>> Use ord(q) py> help(ord) Help on built-in function ord in module __builtin__: ord(...) ord(c) -> integer Return the integer ordinal of a one-character string. py> -- Gabriel Genellina From destroooooy at gmail.com Tue Apr 29 17:16:33 2008 From: destroooooy at gmail.com (destroooooy) Date: Tue, 29 Apr 2008 14:16:33 -0700 (PDT) Subject: string translate, replace, find and the forward slash References: <1030ffc2-1bbe-4539-881d-35bf59cacd11@34g2000hsh.googlegroups.com> Message-ID: On Apr 29, 4:50 pm, Arnaud Delobelle wrote: > destroooooy writes: > > Hi folks, > > I'm finding some (what I consider) curious behavior with the string > > methods and the forward slash character. I'm writing a program to > > rename mp3 files based on their id3 tags, and I want to protect > > against goofy characters in the in tags. So I do the following: > > > unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n" > > alt_chars = "_________________________" > > > s_artist.translate(maketranstable(unsafe_chars, alt_chars)) > > > which successfully replaces everything except for forward slashes (at > > least in the files I've tested so far). If I use the "replace()" > > method, it also does not work. Escaping the forward slash changes > > nothing. "find()" however, works, and thus I've resorted to: > > > if "/" in s_artist: > > (s_l, slash, s_r) = s_artist.partition("/") > > s_artist = "_".join([s_l, s_r]) > > > which is rather uncool. It works but I'd just like to know what the > > deal is. TIA. > > It works fine here: > > marigold:junk arno$ python > Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) > [GCC 4.0.1 (Apple Inc. build 5465)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > > >>> unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n" > >>> table = range(256) > >>> for c in unsafe_chars: table[ord(c)] = ord('_') > ... > >>> table = ''.join(chr(o) for o in table) > >>> 'Jon(&Mark/Steve)'.translate(table) > 'Jon__Mark_Steve_' > > -- > Arnaud Okay, so that definitely works. Thanks! However, the chances of me coming up with that on my own were completely nonexistent, and I'd still like to know how one would use maketranstable() to get the same result... From leoniaumybragg at gmail.com Sat Apr 26 06:57:19 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:57:19 -0700 (PDT) Subject: sims 2 patch Message-ID: sims 2 patch http://cracks.00bp.com F R E E C R A C K S From george.sakkis at gmail.com Fri Apr 4 17:08:18 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 4 Apr 2008 14:08:18 -0700 (PDT) Subject: Tokenizer inconsistency wrt to new lines in comments References: <1ce40dcf-4a0a-4577-af3b-6a77ef71356c@f63g2000hsf.googlegroups.com> <6dd69a1f-96d0-4b91-b84b-a54794a31c70@u36g2000prf.googlegroups.com> <8b3fa4cc-deb9-4748-a63c-a6c7e5dd92ba@59g2000hsb.googlegroups.com> Message-ID: <644d73d0-b3ec-4a98-b722-af78604ddb6b@k13g2000hse.googlegroups.com> On Apr 4, 4:38 pm, Fredrik Lundh wrote: > George Sakkis wrote: > >> If it was a bug it has to violate a functional requirement. I can't > >> see which one. > > > Perhaps it's not a functional requirement but it came up as a real > > problem on a source colorizer I use. I count on newlines generating > > token.NEWLINE or tokenize.NL tokens in order to produce
tags. It > > took me some time and head scratching to find out why some comments > > were joined together with the following line. Now I have to check > > whether a comment ends in new line and if it does output an extra
> > tag.. it works but it's a kludge. > > well, the real kludge here is of course that you're writing your own > colorizer, when you can just go and grab Pygments: > > http://pygments.org/ > > or, if you prefer something tiny and self-contained, something like the > colorizer module in this directory: > > http://svn.effbot.org/public/stuff/sandbox/pythondoc/ > > (the element_colorizer module in the same directory gives you XHTML in > an ElementTree instead of raw HTML, if you want to postprocess things) > > First off, I didn't write it from scratch, I just tweaked a single module colorizer I had found online. Second, whether I or someone else had to deal with it is irrelevant; the point is that generate_tokens() is not consistent with respect to new lines after comments. George From tinnews at isbd.co.uk Thu Apr 3 07:37:50 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 03 Apr 2008 11:37:50 GMT Subject: Efficient way of testing for substring being one of a set? Message-ID: <47f4c18e$0$715$bed64819@news.gradwell.net> What's the neatest and/or most efficient way of testing if one of a set of strings (contained in a dictionary, list or similar) is a sub-string of a given string? I.e. I have a string delivered into my program and I want to see if any of a set of strings is a substring of the string I have been given. It's quite OK to stop at the first one found. Ideally the strings being searched through will be the keys of a dictionary but this isn't a necessity, they can just be in a list if it could be done more efficiently using a list. Is this the best one can do (ignoring the likelihood that I've got some syntax wrong) :- # l is the list # str is the incoming string answer = "" for x in l: if str.find(x) < 0: continue answer = x -- Chris Green From steve at holdenweb.com Fri Apr 25 07:38:08 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 25 Apr 2008 07:38:08 -0400 Subject: how to mysqldb dict cursors In-Reply-To: <17d58cc40804242358s26446c42h36f875cf0ee62199@mail.gmail.com> References: <17d58cc40804241950i7b624e1apd2733daa79b3ed5c@mail.gmail.com> <481161FD.5020407@ulmcnett.com> <17d58cc40804242358s26446c42h36f875cf0ee62199@mail.gmail.com> Message-ID: Vaibhav.bhawsar wrote: [top-posting amended: see below] > On Fri, Apr 25, 2008 at 12:45 AM, Paul McNett

> wrote: > > Vaibhav.bhawsar wrote: > > I have been trying to get the DictCursor working with mysqldb > module but can't seem to. I have pasted the basic connection > code and the traceback from pydev. The connection does open with > the default cursor class. can't figure this one out. many thanks. > > > Try one of: > > """ > import MySQLdb, MySQLdb.cursors > conn = MySQLdb.connect(..., cursorclass=MySQLdb.cursors.DictCursor) > """ > > -or- > > """ > import MySQLdb, MySQLdb.cursors > conn = MySQLdb.connect(...) > cur = MySQLdb.cursors.DictCursor(conn) > """ > > I'm going off of memory here, though, but I'm at least close. > > Great both methods worked! I don't quite understand this since i imported > the whole module with "import MySQLdb" > > Thanks! > The point here is that MySQLdb is a package, not a module. Some packages have their top-level __init__.py import the package's sub-modules or sub-packages to make them immediately available within the package namespace (which is why, for example, you can access os.path.* when you have imported os) and others don't. MySQLdb clearly doesn't need to import the cursors module for its own purposes. Perhaps it would be less efficient to always perfrom the import, who knows. Well, Andy Dustman does, I suppose, and possibly anyone else who reads the code, but I haven't done that myself. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gagsl-py2 at yahoo.com.ar Thu Apr 3 22:06:44 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 23:06:44 -0300 Subject: Is there an official way to add methods to an instance? References: <47F57D14.8030206@aim.com> Message-ID: En Thu, 03 Apr 2008 21:57:56 -0300, Brian Vanderburg II escribi?: > I don't know if this is the correct place to send this question. > > I've checked out some ways to get this to work. I want to be able to > add a new function to an instance of an object. I've tested two > different methods that cause problems with 'deleting'/garbage collection > (__del__ may never get called), but implemented one sort of hackishly > maybe that works find. I'm wondering if there is more of an official way > than mine. > > 1. > import new > import gc > > class A: > def __del__(x): > print "Deleting" > > def f(x): > print x > > a = A() > a.f = new.instancemethod(a,f) > a.f() # This works > del a # Not what is expected > gc.collect() # Works, but __del__ does not get called O thou of little faith, wherefore didst thou doubt? This is the simplest and preferred way, and it works! It's true that there is a reference cycle between a and a.f, but the garbage collector is able to detect it and dispose of those objects *UNLESS* any of them contains a __del__ method written in Python. See http://docs.python.org/ref/customization.html So this *is* the right way, and the object `a` would have been deleted if you had not tried to witness the deletion itself... You perturbed the system in a non trivial way just by attempting to observe it - isn't this Quantum Mechanics applied to Python programming? We need a side-effect triggered by __del__ but written in C... hmmm, what about flushing a file buffer? py> import new py> import gc py> import os py> py> class myfile(file): # just to be able to add attributes ... pass ... py> def f(x): ... print x ... py> a = myfile("a.aaa","w") py> print os.stat("a.aaa").st_size # 0 0 py> a.f = new.instancemethod(f, a) py> a.f() # This works py> a.write("X") # a single char, should stay on write buffer py> print os.stat("a.aaa").st_size # still 0 0 py> del a py> print os.stat("a.aaa").st_size # still 0 0 py> gc.collect() 3 py> print os.stat("a.aaa").st_size # now 1 1 -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Sat Apr 12 23:03:49 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 13 Apr 2008 00:03:49 -0300 Subject: String Literal to Blob References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> Message-ID: En Sat, 12 Apr 2008 16:11:20 -0300, Victor Subervi escribi?: > On Fri, Apr 11, 2008 at 2:05 PM, Steve Holden > wrote: > >> Then browse to the URL this program serves and you will see the image >> (assuming you are still sending the image/jpeg content type). > > Well, as I mentioned before, I am sending text/html because the page, > like > almost all web pages, has a whole lot more content than just images. Or, > perhaps you are suggesting I build my pages in frames, and have a frame > for > every image. Unsightly! (Oh my...!) Thanks to Helloween (the metal band) I was in the right mood to write a small example. Simple, bare, raw code: no fancy HTML, no templates, no web frameworks, using the embedded sqlite engine. It works with Python 2.5 out of the box. Each functional piece is in its own file, to emphasize the one-document-per-request rule. It is a photo album, one can upload pictures with title and description, and later see them one at a time. How to run: Create a temporary folder. Create a cgi-bin subdirectory, and copy the four scripts there. In the parent directory, execute: python -m CGIHTTPServer Using your browser, go to http://localhost:8000/cgi-bin/album.py?init=1 (the init parameter is to create the database; you can omit it once it's done). Note that there are TWO scripts involved when you want to display a picture: showpic.py returns the HTML page, containing tags like this: %s" % (picid, cgi.escape(title)) (note the src attribute) and getpic.py returns the picture itself. Note also that this is just a demo; for a real web application I would choose one of the many existing frameworks; or WSGI, or mod_python, finally cgi. And my scripts have absolutely no check for errors at all, and the HTML is not even valid. I hope you finally get the idea of how to serve dynamic content... -- Gabriel Genellina -------------- next part -------------- A non-text attachment was scrubbed... Name: upload.py Type: application/octet-stream Size: 2325 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: album.py Type: application/octet-stream Size: 1228 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: getpic.py Type: application/octet-stream Size: 499 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: showpic.py Type: application/octet-stream Size: 726 bytes Desc: not available URL: From paulgeeleher at gmail.com Tue Apr 22 12:32:38 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Tue, 22 Apr 2008 09:32:38 -0700 (PDT) Subject: Spawing a thread and printing dots until it finishes References: Message-ID: On Apr 22, 4:41 pm, "D'Arcy J.M. Cain" wrote: > On Tue, 22 Apr 2008 07:10:07 -0700 (PDT) > > > > sophie_newbie wrote: > > import threading > > class MyThread ( threading.Thread ): > > def run ( self ): > > myLongCommand()... > > > import time > > > t = MyThread() > > t.start() > > > while t.isAlive(): > > print "." > > time.sleep(.5) > > > print "OK" > > > The thing is this doesn't print a dot every half second. It just > > pauses for ages until the thread is finished and prints prints ".OK". > > But if I take out the "time.sleep(.5)" line it will keep printing dots > > really fast until the thread is finished. So it looks like its the > > time.sleep(.5) bit that is messing this up somehow? > > We know that your main routine gives up the processor but without a > full definition of MyThread how do we know that it ever does? I > suspect that it hits sleep once, if at all, and then goes to the final > print statement. In fact, I suspect that this is not exactly what you > tried anyway. This code would not have printed ".OK" whether it > entered the loop or not. It could have printed this; > > . > OK > > because the print statement in the loop will print a dot on a line by > itself. > > When looking for these sorts of answers you should really try to create > a smallest program that exhibits the behaviour you are questioning and > then cut and paste the entire script into your message unedited. Often > enough you will even answer your own question in the process. > > -- > D'Arcy J.M. Cain | Democracy is three wolveshttp://www.druid.net/darcy/ | and a sheep voting on > +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. "myLongCommand()... " is a call to an function in R (the statistical programming language) via Rpy (A python module that allows calls to R). The call takes a couple of minutes to execute. I'm trying to build a web front end to this R function and instead of the user looking at a blank screen for 2-3 mins, I want to print dots to let them feel like the program isn't hanging. What I am saying is that without the "time.sleep(.5)" line, the above code will print dots on the screen continuously for 2-3 mins, filling it up with a ridiculous ammount of dots. Whereas with the time.sleep line, instead of pausing for half a second between dots, its seems to print, as you correctly pointed out: . OK With a pause of 2-3 minutes between the . and the OK. I hope that clears things up a little. I haven't the faintest idea why the code above doesn't work but hope someone has an idea. It wouldn't be something to do with python not being able to handle multiple threads at the same time or something? I hope there is a workaround. From steve at holdenweb.com Fri Apr 11 08:52:46 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 11 Apr 2008 08:52:46 -0400 Subject: Can we send and receive data to and from Port Using Python ? In-Reply-To: <004901c77c25$130446b0$750ba8c0@patni.com> References: <004901c77c25$130446b0$750ba8c0@patni.com> Message-ID: sambasivareddy wrote: > Hi, > I am new to this group. I have some question, it is listed below. > In my application I should send some data to hardware and it will give > response that response should log in one file. To do it first should > send data to port next receive response from port (hardware) so... > > __ > > _Queries:_ > 1) Can we able to send data to serial port using python? If yes how? The usual mechanism is the pyserial module. Google is your friend. > 2) Can we able to receive data from serial port using python? If yes how? See answer to 1) > 3) Is there any function like "Register event call back?, please explain? > (Register event call back: registers a script to be called when an event > occurs) I believe you need to implement the observer pattern. There have already been several successful implementations of this, and again Google should be capable of finding them. For example: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/131499 > 4) Is it possible "parallel loops" concept in python (In my application > send data to port and receive data should be in one file and execute at > same time)? Most Python implementations support threading, and there are a number of other asynchronous service techniques. There should be absolutely no problem. > > If anyone knows answers please clarify and have any examples related to > this please send it .if u need any information regarding questions > please let me know. > Thanks in advance. > regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From carlwuhwdmckay at gmail.com Mon Apr 21 02:10:10 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:10:10 -0700 (PDT) Subject: cabbage patch kids messy face doll Message-ID: <22f9121f-5145-4350-a2f5-d653f4559898@24g2000hsh.googlegroups.com> cabbage patch kids messy face doll http://cracks.00bp.com F R E E C R A C K S From gmarketer at gmail.com Tue Apr 22 07:07:01 2008 From: gmarketer at gmail.com (GD) Date: Tue, 22 Apr 2008 04:07:01 -0700 (PDT) Subject: Remove multiple inheritance in Python 3000 Message-ID: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> Please remove ability to multiple inheritance in Python 3000. Multiple inheritance is bad for design, rarely used and contains many problems for usual users. Every program can be designed only with single inheritance. I also published this request at http://bugs.python.org/issue2667 From darcy at druid.net Thu Apr 3 13:03:38 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Thu, 3 Apr 2008 13:03:38 -0400 Subject: Why prefer != over <> for Python 3.0? In-Reply-To: References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> <87prt9coti.fsf@pobox.com> Message-ID: <20080403130338.9c1102ce.darcy@druid.net> On Thu, 03 Apr 2008 05:12:28 GMT Tim Roberts wrote: > Yes, indeed. In response to a challenge posted on one of the x86 assembler > newsgroups about two years ago, one intrepid Russian programmer produced a > generic Sudoku solver in a 65-byte executable. Yes, that's 65 BYTES -- not > KB, not MB. Wow! I would have thought that the header on most executible file formats was bigger than that these days. Or was this done as a .COM file or something like that? -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From grante at visi.com Wed Apr 16 10:19:37 2008 From: grante at visi.com (Grant Edwards) Date: Wed, 16 Apr 2008 09:19:37 -0500 Subject: Finally had to plonk google gorups. Message-ID: This morning almost half of c.l.p was spam. In order to try to not tar both the benign google group users and the malignant ones with the same brush, I've been trying to kill usenet spam with subject patterns. But that's not a battle you can win, so I broke down and joined all the other people that just killfile everything posted via google.groups. AFAICT, if you're a google groups user your posts are not being seen by many/most experienced (read "non-google-group") users. This is mainly the fault of google who has refused to do anything to stem the flood of span that's being sent via Google Groups. -- Grant Edwards grante Yow! I would like to at urinate in an OVULAR, visi.com porcelain pool -- From gagsl-py2 at yahoo.com.ar Sun Apr 20 04:11:45 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 05:11:45 -0300 Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> <87prspydex.fsf@physik.rwth-aachen.de> Message-ID: En Wed, 16 Apr 2008 14:23:57 -0300, Steve Holden escribi?: > Torsten Bronger wrote: >> The admistrative overhead of mailing lists is tedious. Fortunately, >> most important computer-related lists are on gmane.org. We could >> list c.l.py there, too. ;-) >> > c.l.py has been on gmane for years, as comp.python.general (why they > have to have their own naming hierarchy i have never understood). Because "someone" chose that name when he/she asked for the list to be added; the name gmane.comp.lang.python *could* have been used, but wasn't. (gmane uses its own hierarchy because not all mirrored lists exist as a newsgroup outside gmane, and there are potential name conflicts) -- Gabriel Genellina From john106henry at hotmail.com Thu Apr 3 20:04:53 2008 From: john106henry at hotmail.com (John Henry) Date: Thu, 3 Apr 2008 17:04:53 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> <58deb8b8-bae9-4d43-b973-3d90846726cb@b5g2000pri.googlegroups.com> <873a5fc2-0bd8-4f93-9c8c-56cda6e0090a@s37g2000prg.googlegroups.com> Message-ID: On Apr 3, 10:17 am, Stef Mientki wrote: > >> Well I doubt it's the visual environment that makes it more easy, > >> color, shape and position can give some extra information though. > >> I think apriori domain knowledge and flattness of information are of far > >> more importance. > >> The first issue is covered quit well by Robolab / Labview, > >> but the second issue certainly is not. > >> I'm right now working on a Labview like editor in Python, > >> which does obey the demand for flatness of information. > >> The first results can be seen here:http://oase.uci.kun.nl/~mientki/data_www/pylab_works/pw_animations_sc... > > >> cheers, > >> Stef Mientki > > >>> And you are going to teach them Java? Oh, please don't. Let the > >>> colleges torture them. :=) > > > What do you mean by flatness of information? > > What I mean is something like; all the information at a certain > abstraction level is visible on one screen or one piece of paper, > and not is available through multiple screen / multiple right-clicks > etc. A wizard in general is an example of strong non-flatness of > information (try adding a mail-account in Thunderbird, this could > easily be put on 1 page, which clearly would give a much better overview). > > cheers, > Stef In that sense, it would appear to me Robolab/Labview would do exactly that. Most of the programs I taught the kids to do fits on one screen. I think what you are doing is very interesting because Robolab does a fair amount of what I am seeing from your screen shots (for simple applications anyway). One day when you finish with the program, may be I can try it on my younger kid. From steve at holdenweb.com Tue Apr 8 16:38:06 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 16:38:06 -0400 Subject: new user needs help! In-Reply-To: <16571823.post@talk.nabble.com> References: <16571823.post@talk.nabble.com> Message-ID: drjekil wrote: > I am totally new in biopython and its my first program.so may be i am asking > stupid question. New? Most questions are sensible. Let's suppose that the four lines you give below are stored in a text file called "/tmp/data.txt". > I am working with a text filelooks like this: > #NAME AA TOPO ACCESS DSSP STRIDE Z-COORD > 1lghB A i 79.8 H H -24.58 > 1lghB V i 79.6 H H -22.06 > 1lghB H i 71.9 H H -19.94 f = open("/tmp/data.txt", 'w') will open that file. You can throw the first line away with headings = f.next() Then you can loop over the rest with for name, aa, topo, access, dssp, stride, z in file: # # Then process each line here # if 10.0 <= z <= 22.0: # # select on other criteria here # > i need to compare those lines which has a Z-COORED value between 10 to 22 > and presents in the following way > True/false A C D E F G H I K L M N P Q R S T V X Y W(here alfabets > represents amino acids) > 1 1:1 2:0 3:0 and so on for rest of the amino acids. > IF PRESENT IN THAT RANGE > IF not PRESENT IN THAT RANGE then > -1 1:0 2:0 so on,it should be 1 instead of 0 when it will find corresponding > amino acid for that line.say here,for 2nd line it will be 16:1. > true will represent 1,false -1. I am afraid I am having trouble understanding that last bit. Perhaps you could find some other way to say the same thing? Sometimes my understanding is not too good. > i have to cheek all the lins in the file and print it. > u have to tell simply otherwise i cant understand even,so stupid am i! "Poor at English" != "Stupid" > I will be really greatful!Thanks in advance That's the first step. Now, what's next? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From john00587 at gmail.com Mon Apr 21 01:38:22 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:38:22 -0700 (PDT) Subject: kids that fall between the cracks Message-ID: <8b85c8b2-b979-4e36-a27b-8c6ef884dfb0@w4g2000prd.googlegroups.com> kids that fall between the cracks http://cracks.00bp.com F R E E C R A C K S From deets at nospam.web.de Thu Apr 17 11:05:53 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 17 Apr 2008 17:05:53 +0200 Subject: why function got dictionary References: <48075950.7050000@gmail.com> <66p409F2lg89hU1@mid.uni-berlin.de> <4807637C.1050900@gmail.com> Message-ID: <66p7bdF2l44iiU1@mid.uni-berlin.de> AlFire wrote: > Diez B. Roggisch wrote: >>> >>> Q: why function got dictionary? What it is used for? >> >> because it is an object, and you can do e.g. >> > > you mean an object in the following sense? > > >>> isinstance(g,object) > True Yes. > > where could I read more about that? I don't know. But essentially _everything_ in python is an object. Some of them lack a __dict__ - e.g. int and float and such - for optimization reasons. But apart from that, you can treat everything as an object. Diez From mr.cerutti at gmail.com Wed Apr 16 11:26:14 2008 From: mr.cerutti at gmail.com (Neil Cerutti) Date: Wed, 16 Apr 2008 11:26:14 -0400 Subject: text adventure game problem In-Reply-To: <3f1023c9-97c1-40b5-8a28-0b89bf79fba1@c65g2000hsa.googlegroups.com> References: <3f1023c9-97c1-40b5-8a28-0b89bf79fba1@c65g2000hsa.googlegroups.com> Message-ID: <51302a8c0804160826x67749324h1428d34397dd4fd4@mail.gmail.com> On Tue, Apr 15, 2008 at 9:25 AM, Carl Banks wrote: > On Apr 11, 12:08 pm, "Neil Cerutti" wrote: > > > such as so > > > they're not stuck with a quasi hack of a language if they have to do > > > something that doesn't fit the framework anticipated by the language > > > designer. > > > > That's not a reason, it's FUD. > > No, it's prudence. > > If I am writing a banal, been-done-a-million-times before, cookie- > cutter text adventure, yes I'd just use a domain-specific language. > > If I am writing a unique game that does new things, sooner or later > I'm going to want to do something the designer of the domain-specific > language and framework didn't anticipate. And there is no uncertainty > or doubt about this: when it comes to that, I don't want to be > restrained by a narrow framework or domain-specific language, and I > would want to be using Python, and it isn't even remotely close. > > The only question would be whether there's enough general purpose > programming required that it would outweigh the extra work. Which, > let's be honest, is not all that much for a text adventure. Thanks for the more detailed response. Your reasoning is valid, but your understanding of the properties of existing text game frameworks seem to be be out of date. A usable, extensible, customizable text adventure library for use in [b]any[/b] general-purpose programming language is still a pipe dream. There aren't even very many [b]failed[/b] attempts. The decent text adventures composed from scratch in a general-purpose programming language are rare exceptions to the rule. Even among the tolerable ones, I have personally never seen one that took advantage of the general-purpose nature of its implementation language to do something that couldn't have been easily done in the handful of mature domain-specific languages. Moreover, the small, but dedicated text-adventure-playing internet community has developed expectations for the features, infrastructure and portability of their text adventures that are not trivial to meet when starting from (close to) ground zero. A few bold pioneers have managed it. If you're keen to attempt it, Python is an OK choice. The most recent success I know of was "Aunts & Butlers" [1], composed in Javascript, which made portability less of an issue than it would be for Python. There are no completed text adventures in the wild composed in Python, that I'm aware of. That doesn't mean it can't happen. [1] http://versificator.co.uk/auntsandbutlers/ -- Neil Cerutti From gagsl-py2 at yahoo.com.ar Sat Apr 12 22:51:36 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 12 Apr 2008 23:51:36 -0300 Subject: String Literal to Blob References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> Message-ID: En Sat, 12 Apr 2008 22:14:31 -0300, Jason Scheirer escribi?: > On Apr 12, 2:44 pm, Steve Holden wrote: >> Victor Subervi wrote: >> > Well, as I mentioned before, I am sending text/html because the page, >> > like almost all web pages, has a whole lot more content than just >> > images. Or, perhaps you are suggesting I build my pages in frames, and >> > have a frame for every image. Unsightly! >> >> Dear Victor: >> >> If you cannot understand, after being told several times by different >> people, that pages with images in them are achieved by multiple HTTP >> requests, then there is little I can do to help you. >> [...] >> Please, do yourself a big favor and persist with this until you >> understand what you are doing wrong and how to serve dynamic images. It >> appears that the learning may be painful, but I guarantee it will be >> worthwhile. > > There _is_ a way to embed image data in HTML that is supported by > every major browser. It is ugly. Using the RFC 2397 (http:// > www.ietf.org/rfc/rfc2397) spec for data URLs you could go > > '' % base64.b64encode(image_data) Another alternative would be to generate a multipart/related document, but I think the OP will gain a lot more understanding the simple cases than using those esoteric features. -- Gabriel Genellina From lists at cheimes.de Sat Apr 12 12:47:32 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 12 Apr 2008 18:47:32 +0200 Subject: Tremendous slowdown due to garbage collection In-Reply-To: <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: <4800E7A4.5050708@cheimes.de> andreas.eisele at gmail.com schrieb: > which made me suggest to use these as defaults, but then > Martin v. L?wis wrote that > >> No, the defaults are correct for typical applications. > > At that point I felt lost and as the general wish in that thread was > to move > discussion to comp.lang.python, I brought it up here, in a modified > and simplified form. Martin said that the default settings for the cyclic gc works for most people. Your test case has found a pathologic corner case which is *not* typical for common application but typical for an artificial benchmark. Python is optimized for regular apps, not for benchmark (like some video drivers). By the way you shouldn't use range for large ranges of more than a thousand items. xrange() should be faster and it will definitely use much less memory - and memory Python 2.5 and older will never release again. I'm going to fix the issue for Python 2.6 and 3.0. Christian From kamhung.soh at gmail.com Wed Apr 30 03:12:15 2008 From: kamhung.soh at gmail.com (Kam-Hung Soh) Date: Wed, 30 Apr 2008 17:12:15 +1000 Subject: sed to python: replace Q References: <48180348$0$34534$742ec2ed@news.sonic.net> Message-ID: On Wed, 30 Apr 2008 15:27:36 +1000, Raymond wrote: > For some reason I'm unable to grok Python's string.replace() function. > Just trying to parse a simple IP address, wrapped in square brackets, > from Postfix logs. In sed this is straightforward given: > > line = "date process text [ip] more text" > > sed -e 's/^.*\[//' -e 's/].*$//' > > yet the following Python code does nothing: > > line = line.replace('^.*\[', '', 1) > line = line.replace('].*$', '') str.replace() doesn't support regular expressions. Try: import re p = re.compile("^.*\[") q = re.compile("].*$") q.sub('',p.sub('', line)) > > Is there a decent description of string.replace() somewhere? > > Raymond Section 3.6.1 String Functions -- Kam-Hung Soh Software Salariman From saluk64007 at gmail.com Fri Apr 18 20:22:28 2008 From: saluk64007 at gmail.com (Patrick Mullen) Date: Fri, 18 Apr 2008 17:22:28 -0700 Subject: python setup.py install on Vista? In-Reply-To: References: Message-ID: On Fri, Apr 18, 2008 at 4:29 PM, globalrev wrote: > type "python setup.py install" > > that is used in most "addons" for python. > > well using windows vista, where the h*** am i supposed to type this? > > if it is not doable in windows, what do i have to do instead? just > clicking the setup.py-file never works. > -- > http://mail.python.org/mailman/listinfo/python-list > There are many problems with this on Vista. First, you need a command prompt. You can go to "start menu->all programs->accessories->command prompt" for this. But to install things in vista, you will likely need to be an administrator, and windows won't automatically ask for permission when typing "python setup.py install." So instead of clicking on command prompt, right click it, and choose "run as administrator". A faster way is to type "cmd" in the start menu search area, and wait for "cmd.exe" to come up. Run that as administrator. Once you have a command prompt, you can "cd" into the directory where you want to install the extension. Then, "c:\python25\python setup.py install" should work. If you are using 2.4 or 3.0, it would be "c:\python24\python" or "c:\python30\python" etc. If you installed python somewhere other than the default folder, then you will need to enter that path. To make this process easier, when I want to install an extension, I usually create a .bat file in the extension folder. Right click in the folder and choose new->text file. Rename the file to "install.bat". Right click the file and go to edit. Enter "c:\python25\python setup.py install" into the file and save. Then right click and choose run as administrator, and it should install. You might add a "pause" line in the bat file as well, so that if it has a problem installing, it will stay open so you can see the output. Your best solution is to uninstall vista and use linux :) From tjreedy at udel.edu Tue Apr 1 01:20:19 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 1 Apr 2008 01:20:19 -0400 Subject: Stuck in a loop References: Message-ID: wrote in message news:e131eb4b-7e78-41b2-8bfd-d7619d620f85 at c26g2000prf.googlegroups.com... |I wrote a simple algorithm and it keeps getting stuck in a loop. I | guess I'm just to tired to figure it out: The easiest way to figure out somethinglike this is to print your variables from inside the loop to see things stick, or if there is a cycle. | compcount=[5,4,2,2] | suitrank=[0,0,0,0] | | trump=2 | l,lt=0,0 | while l<4: | while lt<4: print l, lt | if l==trump: | l+=1 | if l>3: | break | if lt==trump: | lt+=1 | if compcount[l] <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> Message-ID: Gabriel Genellina wrote: > Because Python doesn't follow the "boxed variables" model. Be careful here. `Boxed types' or `boxed objects' is a technical term essentially meaning `heap-allocated objects, probably with reference semantics', which Python most definitely does use -- so this almost means the opposite of what you're talking about. Python has the same basic data model as Lisp, Ruby, Smalltalk and many other languages: a variable (or a `slot' in a compound data-object) contains a reference to value; values can referred to by many variables. Assignment simply copies these references around. This means that it's easy to end up sharing the same object between lots of variables (or structures). Contrast this to the model used by C, Pascal and other `traditional' compiled languages, where a variable is actually a container for a value, and assignment is a copying operation rather than a sharing operation. > In other languages i++ changes the "value" stored inside the box "i", > but the box itself (the variable) is still the same. Python doesn't > have boxes, it has names that refer to objects. For all builtin > numeric types, i += 1 creates a *new* object with the resulting value > and makes the name "i" refer to this new object. Note that `+=' in Python is inconsistent! For numeric types (and other immutable types, such as strings or tuples), `VAR += VALUE' means the same thing as `VAR = VAR + VALUE' (ignoring tedious issues of multiple evaluation of subexpressions -- e.g., subscripts -- in VAR), which as mentioned above causes a new reference to be stored in VAR, referring to the object which was computed by adding VALUE to the object previously referred to by VAR. For lists, it does not do this: instead, it extends the list in place, putting new values on the end of it. (This is one of the language's few obvious inconsistencies, and probably a reasonably justifiable one; but it's still worth pointing out.) To be honest, I don't see any particular reason why `++' is any more of a mutation operation than `+=' is in the languages that define it; Python is actually one of the few to define one but not the other. (The other one I can think of is Acorn's BBC BASIC, for whatever that's worth; it too lacks `++'.) But then again, one of the main conceptual advantages of `++' as an operator is that it has both pre- and post- increment variants, which are useful when used as part of a wider expression. This won't hold in Python, since assignments (which `++' assuredly ought to be) aren't allowed as subexpressions anyway. So the value of `++' would be limited to providing an abbreviation over the already quite short `+= 1'. That's not quite true, in fact: it might be useful to define other kinds of incrementing for specialist types, but I can't think of any obvious examples off the top of my head. This argument doesn't apply to `+=' which has the benefit of saving you from having to type the VAR twice (which is nontrivial if VAR contains complex subexpressions) and -- more significantly -- saves a reader from having to check whether VAR and VAR' actually match in `VAR = VAR' + VALUE' and ensures only single evaluation of subexpressions of VAR. None of this applies to `++'. So `++' is not a feature I find myself sorely missing in Python. -- [mdw] From mark_lim at symantec.com Thu Apr 17 19:27:12 2008 From: mark_lim at symantec.com (Mark Lim) Date: Thu, 17 Apr 2008 16:27:12 -0700 Subject: Building an RPM In-Reply-To: <2F12200B-934E-44D2-94E8-D3E4BDE8FB56@gmail.com> Message-ID: You could use the module compileall to create .pyc and .pyo (http://www.python.org/doc/1.5.1p1/tut/node43.html) and do this in your %build stage. Or if you don't need to ship them, strike them from the package as they will be generated as necessary. On 4/17/08 2:19 PM, "John Sutherland" wrote: > Hi everyone.. > > I'm attempting to build an RPM for Python 2.5.2, using the spec file > found in the standard tarball (Misc/RPM).. > > Currently, its failing cause it hasn't 'compiled' the tools .pyc > and .pyo's, saying the files aren't found. > > Anyone have any ideas? (running on CentOS 4.3) > > --John > > > From roy at panix.com Wed Apr 30 21:03:45 2008 From: roy at panix.com (Roy Smith) Date: Wed, 30 Apr 2008 21:03:45 -0400 Subject: We have string.isdigit(), why not string.isNumber()? References: <0d43feda-fab8-46ba-9af0-eaf497033acd@l17g2000pri.googlegroups.com> Message-ID: In article <0d43feda-fab8-46ba-9af0-eaf497033acd at l17g2000pri.googlegroups.com>, MooMaster wrote: > So it makes sense that something like 5.6 would return false. But what > if we want to make sure that our string is a valid number, ie decimals > included? Just call int(x) or float(x) inside a try block and see if if it raises an exception. From stefan_ml at behnel.de Mon Apr 21 03:24:17 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 21 Apr 2008 09:24:17 +0200 Subject: Elementtree find problem In-Reply-To: References: Message-ID: <480C4121.2000901@behnel.de> Mike Slinn wrote: > The following short Python program parses a KML file and displays the > names of all Marks and Routes: > > from elementtree.ElementTree import ElementTree > tree = ElementTree(file='test.kml') > kml = tree.getroot() > ns = 'http://earth.google.com/kml/2.1' > for folder in kml.findall("{%s}Folder/{%s}Folder/{%s}name" % (ns, ns, ns)): > print folder.text > > I want to modify the program to ignore Marks, and print out the > coordinates of each Route. Seems ElementTree v1.3 will make this task > much easier, but unfortunately the CheeseShop and the Gentoo Portage > repostitory only have v1.2.7 at this time. You can install the current developer version of ET 1.3 from here: http://svn.effbot.org/public/elementtree-1.3 Or use lxml, which comes with full-fledged XPath support. http://codespeak.net/lxml > The following code is as > close as I can get to what I want, but it doesn't run because I've > attempted to use v1.3 syntax, ended up writing complete crap instead, > and I can't understand the docs well enough for the v1.2.7 syntax. > Perhaps someone can understand what I mean and give me a clue as to how > to write this? > > from elementtree.ElementTree import ElementTree > > tree = ElementTree(file='test.kml') > kml = tree.getroot() > ns = 'http://earth.google.com/kml/2.1' > for folders in kml.findall("{%s}Folder/{%s}Folder" % (ns, ns)): > if folders["name"].text=='Routes': > print folder.findall("{%s}LineString/{%s}coordinates" % (ns, > ns)) What's "name" here? An attribute? Then this might work better: if folders.get("name") == 'Routes': or did you mean it to be a child node? if folders.findtext("name") == 'Routes': Stefan From v.harishankar at gmail.com Tue Apr 22 23:20:13 2008 From: v.harishankar at gmail.com (Harishankar) Date: Wed, 23 Apr 2008 08:50:13 +0530 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: References: Message-ID: <200804230850.13672.v.harishankar@gmail.com> On Wednesday 23 Apr 2008 08:27:01 Heikki Toivonen wrote: > At OSAF we used a slightly modified killableprocess module with a > wrapper to deal with complexities of various redirections in > cross-platform way. I actually blogged about this a week ago so rather > than rehash the issues I'll point you to the article which contains > links to all the pieces we used: > > http://www.heikkitoivonen.net/blog/2008/04/16/pythons-ossystem-considered-h >armful/ killableprocess.py looks like a good solution indeed. I actually came across your website in my searches. I just wanted to be absolutely sure that it worked because you had mentioned that it has some drawbacks. -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org From sturlamolden at yahoo.no Thu Apr 24 23:47:25 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 20:47:25 -0700 (PDT) Subject: ctypes: return a pointer to a struct References: <846077c3-beaf-4ccd-83be-1e2168c4f7fe@c65g2000hsa.googlegroups.com> <4dda2bd7-3348-496e-a594-35da0a34d4de@x35g2000hsb.googlegroups.com> Message-ID: On Apr 25, 5:39 am, "Jack" wrote: > AttributeError: 'LP_IP2LocationRecord' object has no attribute > 'country_short' As it says, LP_IP2LocationRecord has no attribute called 'country_short'. IP2LocationRecord does. Use the 'contents' attribute to dereference the pointer. That is: yourstruct.contents.country_short From lorestar at gmail.com Thu Apr 10 10:30:42 2008 From: lorestar at gmail.com (Lorenzo Stella) Date: Thu, 10 Apr 2008 07:30:42 -0700 (PDT) Subject: https and POST method Message-ID: <7956f925-1037-49ea-a360-b58d627ffb20@z24g2000prf.googlegroups.com> Hi all, I'm trying to write a simple script for sending sms via vyke... I have to make a https connection and pass some data with the POST method, like this perl script does: http://www.nutella.org/vyke.sms.txt I tried to make the same, but it simply doesn't work! Any request gives a 200 OK result... This is my code: datah = {"act": "menulogin", "username": login, "password": passwd, "menu_login_form": 1} datas = urllib.urlencode(datah) conn = httplib.HTTPSConnection("www.vyke.com") conn.connect() conn.request("POST", "/merchantsite/login.c?Distributor=MASKINA", datas) res = conn.getresponse() print "login", res.status, res.reason datah = {"act": "sendSMS", "from": numfrom, "to": numto, "message": msg, "sms_form": 1} datas = urllib.urlencode(datah) conn.request("POST", "/merchantsite/sms.c", datas) res = conn.getresponse() print "send", res.status, res.reason conn.request("GET", "/merchantsite/logout.c?Distributor=MASKINA") res = conn.getresponse() print "logout", res.status, res.reason conn.close() I don't know what to do! :-( From gagsl-py2 at yahoo.com.ar Wed Apr 16 01:35:54 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 02:35:54 -0300 Subject: Brand New! References: <7f1828bf-ebe7-4111-bc59-70d125facb0a@d26g2000prg.googlegroups.com> Message-ID: En Tue, 15 Apr 2008 20:37:40 -0300, agent E 10 escribi?: > On Apr 14, 8:37?pm, Benjamin wrote: >> On Apr 14, 9:00 pm, agent E 10 wrote:> ? ?Hi, >> I'm brand new to programming. Have any suggestions? I'm young. >> > Was it a good idea to start with python? I was planning on creating a >> > very simple program that asked yes/no questions for a school project. >> >> IMHO, Python is an excellent language to start with. Have you read the >> tutorial?http://docs.python.org/tut/tut.html > > No, I haven't. I have been reading off of this site > http://www.freenetpages.co.uk/hp/alan.gauld/ is this a good site to > learn off of? About how long will it take me to learn the basics of > the language? I'm unsure if teaching Javascript, VBScript and Python at the same time is a good thing, I'd think one would get a language soup and mix all the concepts, but if it works for you, go ahead. For other resources, see the beginners section in the Python wiki: http://wiki.python.org/moin/BeginnersGuide -- Gabriel Genellina From hdante at gmail.com Thu Apr 17 23:57:21 2008 From: hdante at gmail.com (hdante) Date: Thu, 17 Apr 2008 20:57:21 -0700 (PDT) Subject: Unicode chr(150) en dash References: <48063434$0$36327$742ec2ed@news.sonic.net> Message-ID: <7dae96d4-48c4-46c9-9aa9-33a263b84ca4@26g2000hsk.googlegroups.com> On Apr 17, 12:10 pm, marexpo... at googlemail.com wrote: > Thank you Martin and John, for you excellent explanations. > > I think I understand the unicode basic principles, what confuses me is the usage different applications make out of it. > > For example, I got that EN DASH out of a web page which states at the beggining. That's why I did go for that encoding. But if the browser can There's a trick here. Blame lax web standards and companies that don't like standards. There's no EN DASH in ISO-8859-1. The first 256 characters in Unicode are the same as ISO-8859-1, but EN DASH number is U+2013. The character code in question (which is present in the page), 150, doesn't exist in ISO-8859-1. See http://en.wikipedia.org/wiki/ISO/IEC_8859-1 (the entry for 150 is blank) The character 150 exists in Windows-1252, however, which is a non- standard clone of ISO-8859-1. http://en.wikipedia.org/wiki/Windows-1252 Who is wrong ? - The guy who wrote the web site - The browser that does the trick. - Everybody for using a non-standard encoding - Everybody for using an outdated 8-bit encoding. Don't use old 8-bit encodings. Use UTF-8. > > I might need to go for python's htmllib to avoid this, not sure. But if I don't, if I only want to just copy and paste some web pages text contents into a tkinter Text widget, what should I do to succesfully make every single character go all the way from the widget and out of tkinter into a python string variable? How did my browser knew it should render an EN DASH instead of a circumflexed lowercase u? > > This is the webpage in case you are interested, 4th line of first paragraph, there is the EN DASH:http://www.pagina12.com.ar/diario/elmundo/subnotas/102453-32303-2008-... > > Thanks a lot. > From michele.simionato at gmail.com Sat Apr 5 07:09:32 2008 From: michele.simionato at gmail.com (Michele Simionato) Date: Sat, 5 Apr 2008 04:09:32 -0700 (PDT) Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> Message-ID: <38377121-8dc4-40b8-8a8f-868a2530530c@d1g2000hsg.googlegroups.com> On Apr 5, 12:54 pm, Aldo Cortesi wrote: > Thus spake Matthieu Brucher (matthieu.bruc... at gmail.com): > > > How does it compare to the nose framework ? > > As far as the base unit testing functionality is concerned, I think > they try to address similar problems. Both have assert-based testing > with inspection and re-parsing of assert exceptions for better error > messages. Both try to provide better fixture management. Both make > programmatic test generation easier. Both have a command-line tool for > running and gathering tests. > > I like nose, but I'm biased, and of course I think Pry has some > advantages. One difference I'd point out is Pry's tree-based test > structure, which provides a number of conveniences and features (much > nicer test selection from the command line, for instance). Pry is also > less than half the size of nose, and should therefore be simpler to > extend and understand. You forgot to mention the important point that nose is compatible with unittest and many developer (including myself) would consider that a major selling point. Michele Simionato From kveretennicov at gmail.com Tue Apr 1 14:50:49 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Tue, 1 Apr 2008 21:50:49 +0300 Subject: Why prefer != over <> for Python 3.0? In-Reply-To: References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <659gb2F2f84eoU2@mid.individual.net> <87hceo73ap.fsf@physik.rwth-aachen.de> <65anbqF2fg18bU1@mid.individual.net> <87r6drjss4.fsf@physik.rwth-aachen.de> <65c0bfF2ffipiU1@mid.individual.net> <32822fe60804010015m22a4e9bei5002431afe14921a@mail.gmail.com> Message-ID: <4660fe300804011150v5155705cif40d4277df312b3d@mail.gmail.com> On Tue, Apr 1, 2008 at 12:04 PM, Gabriel Genellina wrote: > En Tue, 01 Apr 2008 04:15:57 -0300, Jorge Vargas > escribi?: > > > as for the original question, the point of going unicode is not to > > make code unicode, but to make code's output unicode. thin of print > > calls and templates and comments the world's complexity in languages. > > sadly most english speaking people think unicode is irrelevant because > > ASCII has everything, but their narrow world is what's wrong. > > Python 3 is a good step in that direction. Strings are unicode, > identifiers are not restricted to ASCII, and the default source encoding > is not ASCII anymore (but I don't remember which one). UTF-8 (http://python.org/dev/peps/pep-3120/) -- kv -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at stinemates.org Fri Apr 18 15:16:36 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 12:16:36 -0700 Subject: insert python script in current script In-Reply-To: References: Message-ID: <20080418191636.GK19281@deviL> On Wed, Apr 16, 2008 at 01:41:13PM -0500, Larry Bates wrote: > Prashant wrote: > > I was wondering is there any way to do this: > > > > I have written a class in python and __init__ goes like this: > > > > def __init__(self): > > > > self.name = 'jack' > > self.age = 50 > > > > import data > > > > > > > > > > now here there is data.py in the same directory and contents are like: > > > > self.address = 'your address' > > self.status = 'single' > > > > The problem is 'self' is giving some error here. I need to know if > > somehow I can do this. It's like inserting the script as it's part of > > the file itself. > > > > Cheers > > > > Can you give a use case for doing this. You would most likely be better doing: > > class person(object): > def __init__(self, name=None, age=None): > self.name=name > self.age=age > > > personInstance=person(name='jack', age='50) > > -Larry > -- > http://mail.python.org/mailman/listinfo/python-list Could it also be that he would like to have a base class? Cause that's what It sounds like to me! class Base: def __init__(self): self.address = "address" self.status = 1 //use numbers instead of strings :) class Person(Base): def __init__(self): Base.__init__(self) # now you have the self.address, self.status -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From kyosohma at gmail.com Wed Apr 16 12:13:33 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 16 Apr 2008 09:13:33 -0700 (PDT) Subject: Splitting MainWindow Class over several modules. References: Message-ID: <0e6b1338-8355-4fba-9db2-0cc09fc05e1e@m44g2000hsc.googlegroups.com> On Apr 16, 10:47 am, Iain King wrote: > Until recently almost all my python programs were held 1 file for 1 > program. This had grown unwieldy for one of my projects, so i decided > to refactor it, and ended up with something like this: > > --- > > import wx > > import options > import gui > import scf > > class MainWindow(wx.Frame): > def __init__(self): > self.title = "SFtools v%s" % VERSION > wx.Frame.__init__(self, None, wx.ID_ANY, self.title, size=(800,600)) > self.SetMinSize((800,600)) > > readOptions = options.readOptions > writeOptions = options.writeOptions > > createBindings = gui.createBindings > createControls = gui.createControls > createMenus = gui.createMenus > reportError = gui.reportError > > loadSCF = scf.loadSCF > onOpen = scf.onOpen > reloadSCF = scf.reloadSCF > setMenuMode = scf.setMenuMode > unloadSCF = scf.unloadSCF > > --- > > Now, this works fine. I like how it reads and that everything being > imported can be clearly seen. I have this funny feeling though, that > this isn't the standard way of doing this. What is? And is there > anything about doing it this way which could be detrimental? > > Iain I don't think there's anything wrong with it. The main thing to remember is to try to keep the interface and the logic separate. I have a fairly complex program with lots of tabs and sub tabs. So I stuck each of the tab's display code in a separate file and imported them into my main program. One good place to learn from would be the wxPython demo. See how Dunn et al did it with that. Or check out Editra's source. I know there's a few wxPython-istas that love XRC for the GUI layout stuff, so that's an option too. I don't use it myself as I couldn't figure out how to implement some of the widgets with it. Mike From tim.arnold at sas.com Thu Apr 24 11:34:11 2008 From: tim.arnold at sas.com (Tim Arnold) Date: Thu, 24 Apr 2008 11:34:11 -0400 Subject: convert xhtml back to html Message-ID: hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop to create CHM files. That application really hates xhtml, so I need to convert self-ending tags (e.g.
) to plain html (e.g.
). Seems simple enough, but I'm having some trouble with it. regexps trip up because I also have to take into account 'img', 'meta', 'link' tags, not just the simple 'br' and 'hr' tags. Well, maybe there's a simple way to do that with regexps, but my simpleminded )]+/> doesn't work. I'm not enough of a regexp pro to figure out that lookahead stuff. I'm not sure where to start now; I looked at BeautifulSoup and BeautifulStoneSoup, but I can't see how to modify the actual tag. thanks, --Tim Arnold From torriem at gmail.com Sun Apr 20 19:08:11 2008 From: torriem at gmail.com (Michael Torrie) Date: Sun, 20 Apr 2008 17:08:11 -0600 Subject: close GUI and quit script? In-Reply-To: <480BC909.6020205@gmail.com> References: <480BC909.6020205@gmail.com> Message-ID: <480BCCDB.2060503@gmail.com> Michael Torrie wrote: > globalrev wrote: >> how do i close a GUI and end the mainloop of the script? > >From a GUI callback, instruct the main loop to quit. In case you can't tell from my reply, I'm basically saying that none of us have any idea unless you actually tell us what GUI system you are using. All the GUI's I have worked with talk about this in their basic API docs and tutorials. So I suggest you look at your GUI toolkit's documentation first. From deets at nospam.web.de Tue Apr 8 08:04:41 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 08 Apr 2008 14:04:41 +0200 Subject: Reproducing a web page and add own content to it. References: Message-ID: <6615blF2ifaqcU1@mid.uni-berlin.de> LaundroMat wrote: > Hi - > > I'm working on a Django powered site where one of the required > functionalities is the possibility of displaying the content of > external pages, with an extra banner at the top where specific > information is displayed. In other words, I'm looking for a way to > reproduce an existing web page and add some HTML code to it. (I can't > think of an example right now, but the idea is similar to sites that > let you see an external page and have some site-specific text above it > (often stating that the content below is not part of the site the user > comes from)). > > To test this, I've been downloading an external page, adding some text > to it and re-opening it in a browser (with the help of built-in > modules such as urllib2 etc). This works of course, but the external > page's links such as , or > are evidently no longer correct. > > Apart from parsing the whole file and trying to inject the external > site's domain in links such as the above (with the added inconvenience > of having to store the external page locally), is there an easier way > of accomplishing what I want? Using a frame? Diez From aaron.watters at gmail.com Tue Apr 15 12:35:27 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Tue, 15 Apr 2008 09:35:27 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <0853b778-c20b-44bb-ac9b-a5803a1aecc5@e67g2000hsa.googlegroups.com> <53ede0ca-ad36-4b11-b693-ea500d7b6e43@e67g2000hsa.googlegroups.com> Message-ID: <207ca229-3309-41e4-9369-ccde5de908a1@l64g2000hse.googlegroups.com> On Apr 14, 11:18 pm, Carl Banks wrote: > However, that is for the OP to decide. The reason I don't like the > sort of question I posed is it's presumptuous--maybe the OP already > considered and rejected this, and has taken steps to ensure the in > memory data structure won't be swapped--but a database solution should > at least be considered here. Yes, you are right, especially if the index structure will be needed many times over a long period of time. Even here though, these days, you can go pretty far by loading everything into core (streaming from disk) and dumping everything out when you are done, if needed (ahem, using the preferred way to do this from python for speed and safety: marshal ;) ). Even with Btree's if you jump around in the tree the performance can be awful. This is why Nucular, for example, is designed to stream results sequentially from disk whenever possible. The one place where it doesn't do this very well (proximity searches) shows the most problems with performance (under bad circumstances like searching for two common words in proximity). -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=joys From pavlovevidence at gmail.com Sat Apr 12 10:20:13 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Sat, 12 Apr 2008 07:20:13 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> Message-ID: On Apr 12, 7:02 am, andreas.eis... at gmail.com wrote: > I would suggest to configure the default behaviour of the garbage > collector in such a way that this squared complexity is avoided > without requiring specific knowledge and intervention by the user. Not > being an expert in these details I would like to ask the gurus how > this could be done. Well, the garbage collector activates whenever allocations exceed deallocations by a certain amount, which for obvious reasons is the reason for the bottleneck wh My first stab at a suggestion would be to adjust the threshold depending on how successful it is. So if a garbage collection run collects no objects, double (or whatever) the threshold until the next run. More formulaicly, if your threshold is X, and a garbage collection pass collects Y objects, the the threshold for the next pass would be something like 2*X/(Y/X+1). Then you can create your very large data structure in only O(N log N) time. But as Steve Holden said, it'll probably mess someone else up. There's not much you can do with a garbage collector to make it please everyone. A question often asked--and I am not a big a fan of these sorts of questions, but it is worth thinking about--of people who are creating very large data structures in Python is "Why are you doing that?" That is, you should consider whether some kind of database solution would be better. You mention lots of dicts--it sounds like some balanced B-trees with disk loading on demand could be a good choice. Carl Banks From landerdebraznpc at gmail.com Mon Apr 28 03:53:35 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:53:35 -0700 (PDT) Subject: norton internet security 2007 keygen Message-ID: norton internet security 2007 keygen http://crack.cracksofts.com From adi at lspl.net Tue Apr 8 22:34:18 2008 From: adi at lspl.net (sniffer) Date: Tue, 8 Apr 2008 19:34:18 -0700 (PDT) Subject: python-com and vista Message-ID: hi all, the problem i am facing is as follows:- i have created a com component in python this registers and works fine on winxp and stuff but on vista i need to turn off user account control to get the component registered and every time i need to use the component i again have to turn it UAC off if it is on, but this component needs to be deployed on the end-users machine and so this exercise of turning on/off UAC cannot be carried out there . Any pointers on how to get this resolved ? TIA From mav at cuma.polymath-solutions.lan Wed Apr 2 12:01:59 2008 From: mav at cuma.polymath-solutions.lan (Maurizio Vitale) Date: Wed, 02 Apr 2008 16:01:59 GMT Subject: non-terminating regex match Message-ID: Has to be something really stupid, but the following never finish (running Python 2.5.1 (r251:54863, Jan 10 2008, 18:00:49) [GCC 4.2.1 (SUSE Linux)] on linux2). The intention is to match C++ identifiers, with or without namespace qualification, with or without arguments (e.g. variables, functions and macros). The following should be accepted: main main(int,char**) ::main std::cout ::std::cout NDEBUG Thanks for any help. And yes, I'm a total beginner when it comes to Python, but it seems very strange to me that a regex match on a finite length string doesn't terminate Regards, Maurizio #!/usr/bin/env python # -*- Python -*- import re if __name__ == '__main__': r = re.compile ( r'(?:(?P(?:(?:::)?\w+)*)::)?' r'(?P\w+)' r'(?:\((?P[^\)]*)\))?' ) match = r.search ('WITH_ALOHA_EXCEPTION_HANDLERS') From collardfelszkw at gmail.com Sun Apr 20 16:33:13 2008 From: collardfelszkw at gmail.com (collardfelszkw at gmail.com) Date: Sun, 20 Apr 2008 13:33:13 -0700 (PDT) Subject: jennifer aniston and paul Message-ID: <1208fb64-8976-433e-be8e-03b31076e3ad@i36g2000prf.googlegroups.com> Just few link on some Movies Movies: http://Jennifer-Aniston.12w.net F R E E C E L E B R I T Y M O V I E S From steve at holdenweb.com Sat Apr 12 18:00:46 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 18:00:46 -0400 Subject: sqlite3 - adding tables and rows via parameters In-Reply-To: <9fdb569a0804121115v43d86c49ieb0f712bd5a49679@mail.gmail.com> References: <9fdb569a0804120839w6916ed96ka5b53aad7ca6f565@mail.gmail.com> <9fdb569a0804121115v43d86c49ieb0f712bd5a49679@mail.gmail.com> Message-ID: Vlastimil Brom wrote: > > 2008/4/12, Steve Holden >: > > Vlastimil Brom wrote: > > Hi all, > > I would like to ask about the usage of sqlite3 in python, more > > specifically about a way to pass table > > or column names to a SQL commands using parameters. > > > The thing that will stop you from using a tablename as an argument to a > parameterized query is that (the) front-ends (I am familiar with) don't > allow table names to be parameterized ... > > ... > > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > ======================= > > Thank you very much for the explanation Steve! > I noticed the limitation, but wasn't sure, if if I wasn't missing > anything, as I don't have many experiences with databases (now I am > actually trying to reimplement, what was previously managed to with > nested dictionaries - hence I don't think, something more robust than > sqlite is appropriate). > But now I am not sure; are there any (security > ...) risks of using string interpolation for table and column names in the SQL commands? Or > are the values, where parametrization (with ? in sqlite3) is supported, > the only vulnerable part; whereas eg. an incorrect value of what should > be a name is safe (of course, apart from the unsuccessful command itself)? > Ultimately that depends where the table and column names come from. If they are user inputs then you are still vulnerable to SQL injection, but usually that's not the case when a query is being parameterized - usually it's values. As long as you consider the source of your data carefully you'll probably be OK. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From elgeee at yahoo.com Thu Apr 17 14:04:03 2008 From: elgeee at yahoo.com (lg) Date: Thu, 17 Apr 2008 18:04:03 GMT Subject: noobie question about mailman Message-ID: <2008041714045350073-elgeee@yahoocom> Hello, I'm pretty new to usenet and totally new to python, so.. hopefully i won't offend anyone with my naivete. I work at a non-profit organization where we use mailman for our email lists, and i've inhereted the task of being list administrator from my sadly-recently-and-unjustly-terminated coworker. Anyway, I'd to know more about working with mailman from the command line. For example, I know it must not be toooo complex to have mailman export a csv doc of all the members of a lis (instead of having to look through members using the web interface for administrators). Can anyone point me in the direction of a forum, email list, or good tutorial to get me started? Any insight *mucly* appreciated! Best, Lauren From ptmcg at austin.rr.com Tue Apr 29 10:20:44 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Tue, 29 Apr 2008 07:20:44 -0700 (PDT) Subject: Issue with regular expressions References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Message-ID: <5a75ea66-2cbb-4c41-8351-a35a70554d8d@i76g2000hsf.googlegroups.com> On Apr 29, 8:46?am, Julien wrote: > I'd like to select terms in a string, so I can then do a search in my > database. > > query = ' ? " ?some words" ?with and "without ? ?quotes ? " ?' > p = re.compile(magic_regular_expression) ? $ <--- the magic happens > m = p.match(query) > > I'd like m.groups() to return: > ('some words', 'with', 'and', 'without quotes') > > Is that achievable with a single regular expression, and if so, what > would it be? > Julien - I dabbled with re's for a few minutes trying to get your solution, then punted and used pyparsing instead. Pyparsing will run slower than re, but many people find it much easier to work with readable class names and instances rather than re's typoglyphics: from pyparsing import OneOrMore, Word, printables, dblQuotedString, removeQuotes # when a quoted string is found, remove the quotes, # then strip whitespace from the contents dblQuotedString.setParseAction(removeQuotes, lambda s:s[0].strip()) # define terms to be found in query string term = dblQuotedString | Word(printables) query_terms = OneOrMore(term) # parse query string to extract terms query = ' " some words" with and "without quotes " ' print tuple(query_terms.parseString(query)) Gives: ('some words', 'with', 'and', 'without quotes') The pyparsing wiki is at http://pyparsing.wikispaces.com. You'll find an examples page that includes a search query parser, and pointers to a number of online documentation and presentation sources. -- Paul From paul.hankin at gmail.com Thu Apr 17 14:19:48 2008 From: paul.hankin at gmail.com (Paul Hankin) Date: Thu, 17 Apr 2008 11:19:48 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <42402158-0b16-42e2-b7a0-9d9a15e8196d@24g2000hsh.googlegroups.com> Message-ID: <316ab669-fa8e-42b3-a1db-68d5b9d7e016@8g2000hsu.googlegroups.com> On Apr 17, 5:56?pm, s0s... at gmail.com wrote: > class RequestHeadersManager: > ... > ? ? def __init__(self, headers, linesep): > ? ? ? ? headersDict = parse_headers(headers, linesep) > > ? ? ? ? for header in headersDict.keys(): > ...[lots of code] Your code is pretty much equivalent to this (untested). class RequestHeadersManager(object): def __getattr__(self, field): if not hasattr(self, field): return None def __init__(self, headers, linesep): for header, value in parse_headers(headers, linesep).iteritems(): header = '_'.join(x.capitalize() for x in header.split('-')) setattr(self, header, value) You may want to add some error checking though! -- Paul Hankin From george.sakkis at gmail.com Tue Apr 1 23:17:30 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 1 Apr 2008 20:17:30 -0700 (PDT) Subject: generator functions: why won't this work? References: Message-ID: On Apr 1, 10:56 pm, zillo... at googlemail.com wrote: > Hi all, > > I'm trying to understand generator functions and the yield keyword. > I'd like to understand why the following code isn't supposed to work. > (What I would have expected it to do is, for a variable number of > arguments composed of numbers, tuples of numbers, tuples of tuples, > etc., the function would give me the next number "in sequence") > #################################### > def getNextScalar(*args): > for arg in args: > if ( isinstance(arg, tuple)): > getNextScalar(arg) > else: > yield arg > #################################### > > # here's an example that uses this function: > # creating a generator object: > g = getNextScalar(1, 2, (3,4)) > g.next() # OK: returns 1 > g.next() # OK: returns 2 > g.next() # not OK: throws StopIteration error > > #################################### > > I'm sure I'm making some unwarranted assumption somewhere, but I > haven't been able to figure it out yet (just started learning Python a > couple of days ago). > > Any help will be appreciated :) You're pretty close, there's just one more thing left. The return value of a generator function is an iterable, something you're supposed to iterate over. In the 'if' clause you call recursively the generator on arg but you don't use the result, you discard it as soon as it is returned. What you have to do is iterate over the returned iterable and yield its values: # don't need parentheses around the if expression if isinstance(arg, tuple): for scalar in getNextScalar(arg): yield scalar Hope this helps, George From castironpi at gmail.com Sun Apr 27 01:58:49 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sat, 26 Apr 2008 22:58:49 -0700 (PDT) Subject: diffing and uniqing directories References: Message-ID: <342c6959-8825-43a5-bee5-0488a2283b80@59g2000hsb.googlegroups.com> On Apr 26, 10:35?pm, rustom wrote: > On Apr 27, 12:31?am, castiro... at gmail.com wrote: > > > > > > > On Apr 26, 1:14?pm, "Rustom Mody" wrote: > > > > Over years Ive collected tgz's of my directories. I would like to diff > > > and uniq them > > > > Now I guess it would be quite simple to write a script that does a > > > walk or find through a pair of directory trees, makes a SHA1 of each > > > file and then sorts out the files whose SHA1s are the same/different. > > > What is more difficult for me to do is to write a visual/gui tool to > > > help me do this. > > > > I would guess that someone in the python world must have already done > > > it [The alternative is to use some of the tools that come with version > > > control systems like git. But if I knew more about that option I would > > > not be stuck with tgzs in the first place ;-)] > > > > So if there is such software known please let me know. > > > > PS Also with the spam flood that has hit the python list I dont know > > > if this mail is being read at all or Ive fallen off the list! > > > I don't want to give you advice; there is profit in diversity, so > > telling you what I use could negatively unify the diverse group. > > > In another language I know, and I pause to defer to the old and wise > > on that, Visual Basic (known to make money), certain counterparts like > > Visual Basic for Applications allow construction of scripts in the > > owner's other suites. ?That is, you can write Basic snippets in Excel, > > Access, and so on. ?That's one benefit that private ownership leaves, > > but not everyone is sold on my country's currency/localcy. ?Perhaps > > it's in the future of version control systems. ?Of course, > > standardization of sufficiency to succeed comes from currency too: > > success isn't success if it isn't current, per se. > > > Do you have any interest in contributing your mind or hands to > > developing a solid gui framework? ?Join a team. > > If this is an answer to my question I dont understand it!- Hide quoted text - > > - Show quoted text - The VisualBasic proprietary editors come with draggable-UIs. Thence, the analysis of utility as a function of where I'm from. OA open architecture has followed Microsoft into Office, so the free one isn't coming. Go distributing, but remember what the serial one is while the dollar's on it. It's picky. From rgarcia2009 at gmail.com Fri Apr 18 11:33:21 2008 From: rgarcia2009 at gmail.com (rgarcia) Date: Fri, 18 Apr 2008 08:33:21 -0700 (PDT) Subject: installing MySQLdb module Message-ID: <80f805f0-6829-4da3-bfb4-79875bb16114@a22g2000hsc.googlegroups.com> I've installed the developer tools package, but when running "python setup.py build" I get the following error: python setup.py build running build running build_py copying MySQLdb/release.py -> build/lib.macosx-10.3-fat-2.5/MySQLdb running build_ext building '_mysql' extension gcc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing - Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic - DNDEBUG -g -O3 -Dversion_info=(1,2,2,'final',0) -D__version__=1.2.2 -I/ Applications/xampp/xamppfiles/include/mysql -I/Library/Frameworks/ Python.framework/Versions/2.5/include/python2.5 -c _mysql.c -o build/ temp.macosx-10.3-fat-2.5/_mysql.o -arch i386 -arch ppc _mysql.c:35:23:_mysql.c:35:23: error: my_config.h: No such file or directoryerror: my_config.h: No such file or directory ... I googled around and people say you need the "-dev" package of mysql in order to have the C headers...where can you download this for mac os? Thanks, Rafael PS I am running XAMPP (http://www.keitr.com/tutorials/xampp) if that changes anything From marlin_rowley at hotmail.com Fri Apr 18 16:10:22 2008 From: marlin_rowley at hotmail.com (Marlin Rowley) Date: Fri, 18 Apr 2008 15:10:22 -0500 Subject: Which event to use for out of focus window? In-Reply-To: References: Message-ID: Bump. From: marlin_rowley at hotmail.com To: python-list at python.org Subject: Which event to use for out of focus window? Date: Fri, 18 Apr 2008 10:25:40 -0500 I think I've found a bug in the wx Library. I've created an event : EVT_IDLE that does something when the event is triggered, however, if your mouse pointer is out-of-focus on the window, the EVT_IDLE doesn't get called. It's only when the window is put into focus that the IDLE event is called. I basically want the IDLE function to be called whether the window is in focus or not. Is there a way to do this? Thanks, -M Get in touch in an instant. Get Windows Live Messenger now. _________________________________________________________________ Pack up or back up?use SkyDrive to transfer files or keep extra copies. Learn how. http://www.windowslive.com/skydrive/overview.html?ocid=TXT_TAGLM_WL_Refresh_skydrive_packup_042008 -------------- next part -------------- An HTML attachment was scrubbed... URL: From goldspin at gmail.com Fri Apr 11 11:35:05 2008 From: goldspin at gmail.com (Henry Chang) Date: Fri, 11 Apr 2008 08:35:05 -0700 Subject: Graphs in Python In-Reply-To: <531651.98983.qm@web55601.mail.re4.yahoo.com> References: <531651.98983.qm@web55601.mail.re4.yahoo.com> Message-ID: Try Google Chart with python wrapper: http://pygooglechart.slowchop.com/ http://code.google.com/apis/chart/ On Thu, Apr 10, 2008 at 10:05 AM, Sanhita Mallick wrote: > Hi. > > I am a newbie to Python. I am trying to implement a > Python code for graph manipulation. My graphs are > about 200-500 nodes big. Excepting for the short basic > graph implementation info on Python.org, where can I > find more in depth info about how to express graphs in > python, and how to use them in a code? > > Also, does anyone know of a easy way of creating the > dictionary for python for a 500-node graph, without > typing each and every node? I found some application > that recognize dot file Graphviz - but I am looking > for a program that can let me "draw" a graph and then > generate the lists automatically from the drawing. > > Thanks. > -SM > -- > http://mail.python.org/mailman/listinfo/python-list > From sn at sncs.se Wed Apr 16 02:50:12 2008 From: sn at sncs.se (Sverker Nilsson) Date: Tue, 15 Apr 2008 23:50:12 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: Thanks for your well-formulated article Providing the Python infrastructure with my program doesn't apply since I am providing a program/library that is intended to be general. So it doesn't help. All that py3k does to me, it seems, is some extra work. To be frank, no innovation. Just changes, no progress. And yes, I am p****d. Somebody compared it with MS stuff. Yes. Nothing personal, I appreciate Your comment. And all others. Sverker On Apr 15, 7:09 pm, Donn Cave wrote: > In article > <11567a1a-b184-42e6-bbf3-a655736c1... at p25g2000hsf.googlegroups.com>, > Sverker Nilsson wrote: > > > No one forces me, but sooner or later they will want a Python 3.0 and > > then a 3.1 whatever. > > > I don't want that fuzz. As about the C versions, I am not that > > worried. What's your point? > > > I just like want to write a program that will stay working. And maybe > > I can go on with something else hopefully than just compatibility > > fixes. They take some work afterall. > > > It seems hard with Python. Esp. 2 -> 3 > > Welcome to the world of Python. > > There was a period of relative stability in the '90s, culminating > with version 1.5.2, which just happens to be about the time that > people started taking Python seriously. It turns out that this > stability was only due to lack of resources, though. > > I think most of us are working under two imperatives here that > really boil down to the same thing: we want a programming > language that lets us focus on the goal of the program. On > one hand, that means things like automatic memory management > that are brought to us by newer languages (i.e., less than > 30 years old.) On the other hand it means stability that allows > our deployed code to go on working without constant intervention, > which usually we find in languages that have become utterly boring > and out of fashion (i.e., more than 30 years old.) > > It's hard to find a good compromise between these two, in an > interpreted language. I don't know what the current party line > may be on this matter, but some years back it was that you should > consider the interpreter part of your application. That is, each > application should deploy with its own dedicated Python interpreter, > complete with libraries and everything. This naturally relieves > some of the maintenance issues, since at least you can upgrade on > your own schedule, but of course it has its costs too. Anyone who > might be thinking about using Python for an application should > seriously think about this. > > Donn Cave, d... at u.washington.edu From pydev at rscorp.ab.ca Tue Apr 29 16:30:08 2008 From: pydev at rscorp.ab.ca (Scott SA) Date: Tue, 29 Apr 2008 14:30:08 -0600 Subject: @classmethod question In-Reply-To: Message-ID: On 4/23/08, Ivan Illarionov (ivan.illarionov at gmail.com) wrote: >On 24 ???, 07:27, Scott SA wrote: >> I'm using the @classemethod decorator for some convenience methods and for > >It would make sense to separate instance-level and class-level >behaviour with additional 'objects' namespace. e.g. >cookie_recipie.get_ingredients() to get ingredients only for cookie >recipie and RecipieClass.objects.get_ingrendients([....]) to get all >the ingredients. As mentioned in another reply, my example was a poor representation of what I was tryin to ask. With that said, your reply is amazingly helpful in my quest to understand python, Django, etc. Django is the ORM I referred to, so the material you have written helps explain a few things. >The elegant solution (AFAIK used by Django) would be to use metaclass >and the object with custom descriptor for class-object/table level >stuff. > >Something like this: > >class RecipieMetaclass(type): > def __new__(cls, bases, attrs): > new_cls = type.__new__(cls, name, bases, attrs) > new_cls.objects = IngredientsDescriptor(IngredientsManager()) > return new_cls > >class RecipieClass(object): > __metaclass__ = RecipieMetaclass > def get_ingredients(self, recipie_list=None): > return self.do_something_interesting(recipie_list) > >class IngredientsManager(object): > def get_ingredients(self, recipie_list=None): > return do_something_boring(recipie_list) > >class IngredientsDescriptor(object): > def __init__(self, ingredients_manager): > self.ingredients_manager = ingredients_manager > def __get__(self, instance, type=None): > if instance is not None: > raise AttributeError, "Access via %s instances is not >allowed" % type.__name__ > return self.ingredients_manager > >Then, "at another time, wanting to know what all the ingredients would >be to make cookies, cake and bread" you would call: >RecipieClass.objects.get_ingrendients(['cookies','cake','bread']) I'm a little vague on the interaction of the IngredientsDescrptor VS IngredientsManager. I gather the 'Descriptor' class is called via the __get__ which then does the instance check. Could this have been done in the 'Manager' class? >Both Django and Google Apps Engine API use similar concepts and you >can learn much more interesting looking in their source code. I have been learning a lot from the Django code and other applications written within it. Still, some things just don't seem to gel, even after a host of google searches. I've not loked at the Google Apps stuff, but will follow your advice. Thanks, Scott From hank.infotec at gmail.com Sun Apr 20 15:09:05 2008 From: hank.infotec at gmail.com (Hank @ITGroup) Date: Mon, 21 Apr 2008 05:09:05 +1000 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <480B52DE.8070105@holdenweb.com> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B52DE.8070105@holdenweb.com> Message-ID: <480B94D1.6050907@gmail.com> Steve Holden wrote: > > You are suffering from a pathological condition yourself: the desire > to optimize performance in an area where you do not have any problems. > I would suggest you just enjoy using Python and then start to ask > these questions again when you have a real issue that's stopping you > from getting real work done. > > regards > Steve > Hi, Steve, This not simply a pathological condition. My people are keeping trying many ways to have job done, and the memory problem became the focus we are paying attention on at this moment. Could you please give us some clear clues to obviously call python to free memory. We want to control its gc operation handily as we were using J**A. From Shawn at Milochik.com Wed Apr 30 13:30:19 2008 From: Shawn at Milochik.com (Shawn Milochik) Date: Wed, 30 Apr 2008 13:30:19 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: <2dc0c81b0804301029n5db13d7ej8cb71938f1980f7e@mail.gmail.com> References: <966256b2-fe7c-4ec5-900b-90b285311881@k10g2000prm.googlegroups.com> <87abjne42n.fsf@physik.rwth-aachen.de> <2dc0c81b0804300851h63500c54q8570202c9cece332@mail.gmail.com> <87r6cncp4r.fsf@physik.rwth-aachen.de> <2dc0c81b0804301029n5db13d7ej8cb71938f1980f7e@mail.gmail.com> Message-ID: <2dc0c81b0804301030x7858b8b5y14729ba3632c61b9@mail.gmail.com> How does one "plonk" stuff from Google Groups? Specifically, how can this be done in Gmail? Thanks, Shawn -------------- next part -------------- An HTML attachment was scrubbed... URL: From ridenour4159 at gmail.com Thu Apr 24 06:13:10 2008 From: ridenour4159 at gmail.com (ridenour4159 at gmail.com) Date: Thu, 24 Apr 2008 03:13:10 -0700 (PDT) Subject: civilization iv crack Message-ID: <149a253c-b561-411b-b195-14c871c8ad95@34g2000hsh.googlegroups.com> civilization iv crack http://cracks.12w.net F R E E C R A C K S From j.foster.davis at gmail.com Tue Apr 15 15:28:00 2008 From: j.foster.davis at gmail.com (Jacob Davis) Date: Tue, 15 Apr 2008 12:28:00 -0700 Subject: Module not found in script that was found in command-line interpreter. Possible Path issue? In-Reply-To: <47F519D7.5090905@activestate.com> References: <8463F6F2-4C02-48BC-BF7E-B606D4B41577@gmail.com> <47F519D7.5090905@activestate.com> Message-ID: <00AC12DC-AD44-4E65-8C8D-FACC0D39299A@gmail.com> On Apr 3, 2008, at 10:54 AM, Trent Mick wrote: > Jacob Davis wrote: >> I just installed the MySQLdb module and I have been able to get it >> to run in my command line interpreter. I am running Mac Leopard, >> and Python 2.5. >> I have tested importing and actually connecting and using a MySQL >> database, although it issues some warning: >> SnakeBite:MySQL-python-1.2.2 Snake$ python >> Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) [GCC 4.0.1 (Apple >> Computer, Inc. build 5341)] on darwin >> Type "help", "copyright", "credits" or "license" for more >> information. >>>>> import MySQLdb >> /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ >> site-packages/MySQL_python-1.2.2-py2.5-macosx-10.3-fat.egg/ >> _mysql.py:3: UserWarning: Module _mysql was already imported from > > From that message it looks like this "python" is /usr/local/bin/ > python (i.e. a separate installation than Apple's system python at / > usr/bin/python and /System/Library/Frameworks/Python.framework). > > You can tell for sure by doing: > > $ which python > >> However, while writing a .py script (with Komodo Edit) I try to >> simply import the module and the in-Komodo interpreter returns an >> error: >> Traceback (most recent call last): >> File "/Users/Snake/Documents/NPS/Thesis/Source_Code/Genetics/ >> mysql_connect_test.py", line 11, in >> import MySQLdb >> ImportError: No module named MySQLdb > > I suspect that this is because your run of Komodo Edit doesn't have > "/usr/local/bin" on its PATH and is using "/usr/bin/python" instead > of the one you typically use on the command line. > > You can configure Komodo to know about /usr/local/bin by adding a > "PATH" setting in the "Environment" prefs panel. Arguably Komodo > should just add /usr/local/bin to its runtime PATH by default, but > unfortunately it currently doesn't. Komodo doesn't pick up your > normal bash shell environment because of problems trying to get that > information in general. > > Please let me know (or on the komodo-discuss list [^1] or Komodo bug > database [^2]) if you have any problems getting that going. > > Cheers, > Trent > > [1]: http://listserv.activestate.com/mailman/listinfo/Komodo-discuss > [2]: http://bugs.activestate.com/query.cgi?product=Komodo > > -- > Trent Mick > trentm at activestate.com Thanks, that seems to have worked. I added "/usr/local/bin" to the PATH in the preferences Environment panel in Komodo. Then in preferences I went into the Python pane and changed my selected interpreter from "/usr/bin/pythonw" to the now available "/usr/local/ bin/pythonw". Thanks again, Jake From ndbecker2 at gmail.com Sat Apr 26 06:53:45 2008 From: ndbecker2 at gmail.com (Neal Becker) Date: Sat, 26 Apr 2008 06:53:45 -0400 Subject: ioctl.py References: Message-ID: Gabriel Genellina wrote: > En Fri, 25 Apr 2008 09:30:56 -0300, Neal Becker > escribi?: > >> I need an ioctl call equivalent to this C code: >> >> my_struct s; >> s.p = p; << a pointer to an array of char >> s.image_size = image_size; >> return (ioctl(fd, xxx, &s)); >> >> I'm thinking to use python array for the array of char, but I don't see >> how >> to put it's address into the structure. > > Use the array's buffer_info() method: > """buffer_info(): Return a tuple (address, length) giving the current > memory address and the length in elements of the buffer used to hold > array's contents.""" > > and you can use the struct module to build my_struct. > >> Maybe ctypes is the answer? > > It could be used too, but I think that in this case it's harder to use > ctypes. > Here is what ioctl should be: from ctypes import * libc = CDLL ('/lib/libc.so.6') #print libc.ioctl libc.ioctl.argtypes = (c_int, c_int, POINTER (eos_dl_args_t)) _IOC_WRITE = 0x1 _IOC_NRBITS= 8 _IOC_TYPEBITS= 8 _IOC_SIZEBITS= 14 _IOC_DIRBITS= 2 _IOC_NRSHIFT= 0 _IOC_TYPESHIFT= (_IOC_NRSHIFT+_IOC_NRBITS) _IOC_SIZESHIFT= (_IOC_TYPESHIFT+_IOC_TYPEBITS) _IOC_DIRSHIFT= (_IOC_SIZESHIFT+_IOC_SIZEBITS) def _IOC (dir, type, nr, size): return (((dir) << _IOC_DIRSHIFT) | \ ((type) << _IOC_TYPESHIFT) | \ ((nr) << _IOC_NRSHIFT) | \ ((size) << _IOC_SIZESHIFT)) def ioctl (fd, request, args): return libc.ioctl (fd, request, args) From gagsl-py2 at yahoo.com.ar Wed Apr 16 18:29:14 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 19:29:14 -0300 Subject: Profiling, recursive func slower than imperative, normal? References: Message-ID: En Wed, 16 Apr 2008 17:53:16 -0300, escribi?: > On Apr 16, 3:27 pm, Jean-Paul Calderone wrote: > >> Any function can be implemented without recursion, although it isn't >> always easy or fun. >> > Really? I'm curious about that, I can't figure out how that would > work. Could give an example? Say, for example, the typical: walking > through the file system hierarchy (without using os.walk(), which uses > recursion anyway!). Use a queue of pending directories to visit: start with empty queue queue.put(starting dir) while queue is not empty: dir = queue.get() list names in dir for each name: if is subdirectory: queue.put(name) else: process file -- Gabriel Genellina From miki.tebeka at gmail.com Thu Apr 17 19:24:35 2008 From: miki.tebeka at gmail.com (Miki) Date: Thu, 17 Apr 2008 16:24:35 -0700 (PDT) Subject: i want to add a timeout to my code References: <53ffe104-be3b-43e2-b5c8-4ce5886ac60d@b1g2000hsg.googlegroups.com> Message-ID: <1f70ea43-7909-4bd8-b63d-2467e8a0542f@c65g2000hsa.googlegroups.com> On Apr 17, 1:10?pm, maehhheeyy wrote: > I want to add a timeout so that when I pull out my gps from my serial > port, it would wait for a bit then loop and then see if it's there. I > also want to add a print statement saying that there is no GPS device > found. However when I run my code and unplug my serial port, my code > will just hang until I plug it back in. > This is my code right now: > > def GetGPS(): > ? ? ? data = [] > ? ? ? #Open com1: 9600,8,N,1 > ? ? ? fi = serial.Serial(0, timeout = 1) > ? ? ? print '[gps module] SERIAL PORT OPEN ON COM1:' > > can anyone help me please? Thanks. http://docs.python.org/lib/node545.html HTH, -- Miki http://pythonwise.blogspot.com From gagsl-py2 at yahoo.com.ar Mon Apr 21 01:31:12 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 02:31:12 -0300 Subject: question about the mainloop References: <52de38c4-3d1e-4be0-9b58-5d60317f1ef7@b1g2000hsg.googlegroups.com> Message-ID: En Mon, 21 Apr 2008 00:57:38 -0300, globalrev escribi?: > On 21 Apr, 04:26, "Gabriel Genellina" wrote: >> En Sun, 20 Apr 2008 20:24:04 -0300, globalrev escribi?: >> >> > i dont get the mainloop() in python. i mean i have written some >> > programs, for example a calculator using tkinterGUI. >> >> What you call the "mainloop" is the event loop (or message loop) used by event-driven applications as a way to dispatch all events as they happen in the system. The concept is independent of Python/C++/whatever language you choose. The key phrase is "event-driven programming":http://en.wikipedia.org/wiki/Event_driven_programming >> Tkinter provides an event-driven GUI framework. Simple CLI programs are not event-driven, as your pseudo example above. >> >> > if i have some functions i wanna call to run the program and i wanna >> > call them ina specific order and be able to call >> > them from each other should this just be called in the mainloop and >> > the mianloop then runs the "mainscript" top >> > to bottom over and over? >> >> If you don't want or don't require a graphical user interface, just write the functions you need and call them from the outermost section in your script. >> If you do require a GUI, you'll have to write the code in response to user actions: when the user clicks here, do this; when the user chooses that menu option, do that. >> > > but what i mean i dont understand is sure i can bind a function to a > buttonpress but if i have a def dox(): dododo > and i call it with dox() in the mainscript it will be executed once, > but not again. > so what does the mainloop do, 1srt time it is executed it runs the > mainscript then it it sits and wait s for commands? What's the "mainscript"? The "mainloop" just waits for system events like: mouse movement, mouse click, key pressed, key released, time elapsed, window is uncovered, etc. And when any event arrives, it's dispatched to its registered handler. Python executes whatever you wrote at the top level of the script you are running, up to the root.mainloop() line. That function doesn't return until the main window is closed; all the user interaction occurs inside that call. Finally, execution resumes on the next line, if any. I hope this answers your question; if not, try to be more specific. Maybe an example of what you want to do. -- Gabriel Genellina From tundra at tundraware.com Thu Apr 17 11:51:55 2008 From: tundra at tundraware.com (Tim Daneliuk) Date: Thu, 17 Apr 2008 10:51:55 -0500 Subject: I just killed GIL!!! In-Reply-To: References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <52vid5-cvl2.ln1@ozzie.tundraware.com> <87hce1t8k5.fsf@physik.rwth-aachen.de> Message-ID: MRAB wrote: > On Apr 17, 5:22 am, Torsten Bronger > wrote: >> Hall?chen! >> >> Tim Daneliuk writes: >>> Daniel Fetchinson wrote: >>>> [...] >>>>> I just had one moment of exceptional clarity, during which >>>>> realized how I could get the GIL out of my way... It's so >>>>> simple, I cannot help wondering why nobody has thought of it >>>>> before. [...] >>>> If I were you I would keep it a secret until a Hollywood producer >>>> offers big bucks for the film rights. >>> Who would play Guido, I wonder? >> Ralf M?ller. No other. >> > If you're not careful Hollywood might re-invent Guido as an all- > American hero, Guy Ross! :-) "DIE HARD WITH NO GIL - He's Back And He's Pissed..." -- ---------------------------------------------------------------------------- Tim Daneliuk tundra at tundraware.com PGP Key: http://www.tundraware.com/PGP/ From duncan.booth at invalid.invalid Thu Apr 3 10:36:55 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 3 Apr 2008 14:36:55 GMT Subject: Nested try...except References: <670a8cc4-e3e0-412f-b259-5977f6d2f62d@a70g2000hsh.googlegroups.com> Message-ID: Carl Banks wrote: > Perhaps the advent of with blocks will help reduce this error in the > future. Indeed, and to encourage its use I think this thread ought to include the 'with statement' form of the function: from __future__ import with_statement from contextlib import closing def count(self): with closing(sqlite.connect( self.filename,isolation_level=ISOLATION_LEVEL)) as db: with closing(db.cursor()) as cur: cur.execute("select count(*) from sessions") return cur.fetchone()[0] From landerdebraznpc at gmail.com Mon Apr 28 03:55:47 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:55:47 -0700 (PDT) Subject: system mechanic 7 keygen Message-ID: system mechanic 7 keygen http://crack.cracksofts.com From Laundro at gmail.com Tue Apr 8 15:55:24 2008 From: Laundro at gmail.com (LaundroMat) Date: Tue, 8 Apr 2008 12:55:24 -0700 (PDT) Subject: Reproducing a web page and add own content to it. References: <6615blF2ifaqcU1@mid.uni-berlin.de> <1cddd2af-28be-42ee-8004-0d76978aeaa9@b9g2000prh.googlegroups.com> Message-ID: On Apr 8, 4:11 pm, Steve Holden wrote: > LaundroMat wrote: > > On Apr 8, 2:04 pm, "Diez B. Roggisch" wrote: > >> LaundroMat wrote: > >>> Hi - > >>> I'm working on a Django powered site where one of the required > >>> functionalities is the possibility of displaying the content of > >>> external pages, with an extra banner at the top where specific > >>> information is displayed. In other words, I'm looking for a way to > >>> reproduce an existing web page and add some HTML code to it. (I can't > >>> think of an example right now, but the idea is similar to sites that > >>> let you see an external page and have some site-specific text above it > >>> (often stating that the content below is not part of the site the user > >>> comes from)). > >>> To test this, I've been downloading an external page, adding some text > >>> to it and re-opening it in a browser (with the help of built-in > >>> modules such as urllib2 etc). This works of course, but the external > >>> page's links such as , or > >>> are evidently no longer correct. > >>> Apart from parsing the whole file and trying to inject the external > >>> site's domain in links such as the above (with the added inconvenience > >>> of having to store the external page locally), is there an easier way > >>> of accomplishing what I want? > >> Using a frame? > > >> Diez > > > Ack. I was too focused on importing the external web page and > > redisplaying the information (I've just been reading up on > > BeautifulSoup) instead of looking for an HTML based approach. > > > Thanks! > > You could also look at adding a tag to your generated page's > section. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ True, but I suppose that users would no longer see the top banner added by me when they click on one of the links on the external site's page. I'm a bit hesitant about using frames however, but reading up on them makes me think the application I have in mind for them might be the generally accepted exception to the rule that frames are bad :) Anyway. Thanks for the help! From fredri8758lupo at gmail.com Wed Apr 23 06:10:37 2008 From: fredri8758lupo at gmail.com (fredri8758lupo at gmail.com) Date: Wed, 23 Apr 2008 03:10:37 -0700 (PDT) Subject: keygen download Message-ID: keygen download http://cracks.12w.net F R E E C R A C K S From roger.miller at nova-sol.com Thu Apr 3 21:43:30 2008 From: roger.miller at nova-sol.com (Roger Miller) Date: Thu, 3 Apr 2008 18:43:30 -0700 (PDT) Subject: Is there an official way to add methods to an instance? References: Message-ID: <0db32c33-04a9-4993-9d5a-a617c575a4d7@u36g2000prf.googlegroups.com> On Apr 3, 2:57 pm, Brian Vanderburg II wrote: > > I've checked out some ways to get this to work. I want to be able to > add a new function to an instance of an object. I've tested two > different methods that cause problems with 'deleting'/garbage collection > (__del__ may never get called), but implemented one sort of hackishly > maybe that works find. I'm wondering if there is more of an official way > than mine. > Maybe I'm missing something, but the boring old straightforward approach works for me: class A: def __del__(self): print "Deleting" def f(x): print x a = A() a.f = f a.f(42) del a Output: 42 Deleting From darcy at druid.net Thu Apr 17 12:33:35 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Thu, 17 Apr 2008 12:33:35 -0400 Subject: Can't do a multiline assignment! In-Reply-To: References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> Message-ID: <20080417123335.cc11b9fb.darcy@druid.net> On Thu, 17 Apr 2008 09:19:32 -0700 (PDT) s0suk3 at gmail.com wrote: > I'm building a web server. The many variables are names of header > fields. One part of the code looks like this (or at least I'd like it > to): > > class RequestHeadersManager: > > # General header fields > Cache_Control = \ > Connection = \ > Date = \ > Pragma = \ > Trailer = \ > Transfer_Encoding = \ > Upgrade = \ > Via = \ > Warning = \ > > # Request header fields > Accept = \ > Accept_Charset = \ > Accept_Encoding = \ > Accept_Language = \ > Authorization = \ > ... > > Etc etc etc. At the end they'll all be assign to None. Then, when > initialized, __init__() will the the string of headers, parse them, > and use those variables shown above to assign to the header values. Of > course a normal request won't include all of those headers, so the > others will remain None. That's what I want. So basically you want a class that has a dict of headers which __init__ assigns to and to get a header you basically return O.get(header). -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From paulgeeleher at gmail.com Mon Apr 21 11:13:27 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Mon, 21 Apr 2008 08:13:27 -0700 (PDT) Subject: Problem setting cookie in Internet Explorer Message-ID: Hi, I'm using the python to set a cookie when a user logs in. Thing is it doesn't seem to be setting properly in Internet Explorer. It works grand in Firefox. Its basically: c = Cookie.SimpleCookie() c['username'] = uname c['password'] = pword print c print pageContent And thats it. I've a suspicion that it could be something to do with the expiry time of the cookie. But I'm really not sure and don't really know where to go with it. I've tried it on Internet Explorer on 2 machines and get the same problem. Thanks for any help... From jkazoo at gmail.com Wed Apr 16 14:43:18 2008 From: jkazoo at gmail.com (jkazoo at gmail.com) Date: Wed, 16 Apr 2008 11:43:18 -0700 (PDT) Subject: str class inheritance prob? Message-ID: <874eed0f-eeeb-4434-8a14-a3b29801a5f6@d26g2000prg.googlegroups.com> so I?m trying to create a class that inherits from str, but I want to run some code on the value on object init. this is what I have: class Path(str): def __init__( self, path ): clean = str(path).replace('\\','/') while clean.find('//') != -1: clean = clean.replace('//','/') print 'cleaned on init:\t',clean self = clean so clearly the clean variable is what I want value of the string to be, but that?s decidedly not the case. so running this: a=Path('path///with\\nasty/////crap_in_it/') print a gives me this: cleaned on init: path/with/nasty/crap_in_it/ path///with\nasty/////crap_in_it/ what gives? what am I doing wrong, and can I do what I?m trying to here? thanks. From martin at v.loewis.de Sun Apr 6 09:25:58 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 06 Apr 2008 15:25:58 +0200 Subject: Form sha1.hexdigest to sha1.digest In-Reply-To: <7c39af89-9cee-428c-a0bc-8202700c5aec@b1g2000hsg.googlegroups.com> References: <7c39af89-9cee-428c-a0bc-8202700c5aec@b1g2000hsg.googlegroups.com> Message-ID: <47F8CF66.1020805@v.loewis.de> > How can convert string from sha1.hexdigest() to string that is the > same, like from sha1.digest() Use binascii.unhexlify. HTH, Martin From sjmachin at lexicon.net Thu Apr 17 19:00:45 2008 From: sjmachin at lexicon.net (John Machin) Date: Thu, 17 Apr 2008 23:00:45 GMT Subject: Request a short code review In-Reply-To: References: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> Message-ID: <4807d69a$1@news.mel.dft.com.au> james at reggieband.com wrote: >> I am not necessarily looking to make the code shorter or more >> functional or anything in particular. However if you spot something >> to improve then I am happy to learn. > > To give an example of what I mean I have already altered the code: > > def output_random_lesson_of_type(self, type=None): > """Output a lesson of a specific type. > If no type is passed in then output any type.""" "any" type? Perhaps you mean all types. > output_lessons = self.lesson_data["lessons"] > if type: > filtered_lessons = filter(lambda x: x["type"] == type, > self.lesson_data["lessons"]) filter/map/reduce/lambda is not to everyone's taste; consider using a list comprehension: filtered_lessons = [x for x in self.lesson_data["lessons"] if x["type"] == type] Now you need to go up a level ... when you find yourself using dictionaries with constant string keys that are words, it's time to consider whether you should really be using classes: filtered_lessons = [x for x in self.lesson_data.lessons if x.type == type] > if filtered_lessons: > output_lessons = filtered_lessons > else: > print "Unable to find lessons of type %s." % type So the error action is to print a vague message on stdout and choose from all lessons? > return self.output_random(output_lessons) > > Changes: > - Respected a column width of 80 If you really care about people who are still using green-screen terminals or emulations thereof, make it < 80 -- some (most? all?) terminals will produce an annoying blank line if the text is exactly 80 bytes long. > - Created the output_lessons variable, assigned it to a default. > This remove an else statement and reduced the call to > self.output_random to a single instance in the return statement ... and also makes folk who are interested in what happens in the error(?) case read backwards to see what lessons will be used. HTH, John From soray6034rao at gmail.com Wed Apr 30 07:30:19 2008 From: soray6034rao at gmail.com (soray6034rao at gmail.com) Date: Wed, 30 Apr 2008 04:30:19 -0700 (PDT) Subject: age of empires 3 crack serial Message-ID: age of empires 3 crack serial http://crack.cracksofts.com From nick at stinemates.org Wed Apr 23 14:40:32 2008 From: nick at stinemates.org (Nick Stinemates) Date: Wed, 23 Apr 2008 11:40:32 -0700 Subject: Calling Python code from inside php In-Reply-To: References: Message-ID: <20080423184032.GA15639@deviL> On Wed, Apr 23, 2008 at 11:09:53AM -0700, vijay wrote: > Hi > I have a python code performing some computation for me.I have a > html page which passes certain argumnets to a php page.This php page > needs to pass on the value to the Python class and get the result > back. > How do I go about this?? > > > Cheers > Vijay > -- > http://mail.python.org/mailman/listinfo/python-list Why not just write it all in Python? -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From floris.bruynooghe at gmail.com Fri Apr 4 07:27:54 2008 From: floris.bruynooghe at gmail.com (Floris Bruynooghe) Date: Fri, 4 Apr 2008 04:27:54 -0700 (PDT) Subject: Ignoring windows registry PythonPath subkeys Message-ID: <133d93d0-8100-446c-909d-3b25d79af0a2@t54g2000hsg.googlegroups.com> Hi We basically want the same as the OP in [1], i.e. when python starts up we don't want to load *any* sys.path entries from the registry, including subkeys of the PythonPath key. The result of that thread seems to be to edit PC/getpathp.c[2] and recompile. This isn't that much of a problem since we're compiling python anyway, but is that really still the only way? Surely this isn't such an outlandish requirement? Regards Floris [1] http://groups.google.com/group/comp.lang.python/browse_frm/thread/4df87ffb23ac0c78/1b47f905eb3f990a?lnk=gst&q=sys.path+registry#1b47f905eb3f990a [2] By looking at getpathp.c it seems just commenting out the two calls to getpythonregpath(), for machinepath and userpath should work in most cases. From half.italian at gmail.com Mon Apr 14 21:21:42 2008 From: half.italian at gmail.com (Sean DiZazzo) Date: Mon, 14 Apr 2008 18:21:42 -0700 (PDT) Subject: text adventure game problem References: Message-ID: <2eea810c-8dfd-42b2-a0f3-d5071fdb7886@q10g2000prf.googlegroups.com> On Apr 8, 6:01?pm, corvettecra... at gmail.com wrote: > okay, I'm having this one problem with a text adventure game. It's > kind of hard to explain, but I'll do my best. > [code] > > def prompt_kitchen(): > ? ? global gold > ? ? gold_taken = False > ? ? while True: > ? ? ? ? prompt_kit = raw_input('>') > ? ? ? ? if prompt_kit == 'examine cabinet 1' and not gold_taken: > ? ? ? ? ? ? print '''This cabinet has a lot of cups in it with all > different > designs and shapes. Where are the people anyway? How come there's > nobody here? > In one of the cups you find 8 gold.''' > ? ? ? ? ? ? gold = gold+8 > ? ? ? ? ? ? gold_taken = True > ? ? ? ? ? ? pass4() > ? ? ? ? elif prompt_kit == 'examine cabinet 1' and gold_taken: > ? ? ? ? ? ? print \ > ? ? ? ? ? ? ? ? ? '''This cabinet has a lot of cups in it with all > different > designs and shapes. Where are the people anyway? How come there's > nobody here?''' > ? ? ? ? ? ? pass4() > > def pass4(): > ? ? global gold > ? ? print 'You have', gold, 'gold' > ? ? pass > [/code] > > Okay, now for my problem. > In the above function, there's the option to examine a cabinet and get > 8 gold. (everyone here knows that...but I'm just trying to state my > problem...) > Unfortunately, it kind of doesn't work. > After the first time I 'examine cabinet 1' in my game, I get 8 gold > and I can't get it again. > But, If I leave the room and come back to it, then it's as if I had > never gotten the gold the first time, and I can get it again. > How do I fix this? Thank you! Just downloaded and am about to have a blast into the past with PlanetFall! From duncan.booth at invalid.invalid Tue Apr 29 05:32:10 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 29 Apr 2008 09:32:10 GMT Subject: Why is None <= 0 References: <481226f9$0$20866$9b622d9e@news.freenet.de> Message-ID: =?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?= wrote: > (FWIW, in 2.x, x>=4?, it's None < numbers < anything else; > numbers are ordered by value, everything else is ordered > by type name, then by address, unless comparison functions > are implemented). Quite apart from Jon pointing out that this isn't true for all cases when copmparing against None, the other half also isn't true: >>> class C: pass >>> C() < 5 True That happens at least in Python 2.5.2 on win32. Yet another reason to avoid old-style classes. From fredri8758lupo at gmail.com Wed Apr 23 06:08:46 2008 From: fredri8758lupo at gmail.com (fredri8758lupo at gmail.com) Date: Wed, 23 Apr 2008 03:08:46 -0700 (PDT) Subject: soundtap keygen Message-ID: soundtap keygen http://cracks.12w.net F R E E C R A C K S From ang.usenet at gmail.com Tue Apr 8 16:35:34 2008 From: ang.usenet at gmail.com (Aaron Gray) Date: Tue, 8 Apr 2008 21:35:34 +0100 Subject: CPython VM & byte code resources wanted References: <6622srF2e32hbU1@mid.individual.net> Message-ID: <66238qF2h0kfqU1@mid.individual.net> "Aaron Gray" wrote in message news:6622srF2e32hbU1 at mid.individual.net... > Hi, > > I am looking to study the CPython source code, but I cannot seem to find > the VM code. Found it :) Python/ceval.c > Also is there any where a detailed list of the opcodes ? Still could do with an opcodes chart. Thanks, Aaron From steve at holdenweb.com Fri Apr 11 15:29:09 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 11 Apr 2008 15:29:09 -0400 Subject: Question on threads In-Reply-To: References: Message-ID: <47FFBC05.50309@holdenweb.com> Jonathan Shao wrote: > Hi all, > > I'm a beginner to Python, so please bear with me. > > Is there a way of guarenteeing that all created threads in a program are > finished before the main program exits? I know that using join() can > guarentee this, but from the test scripts I've run, it seems like join() > also forces each individual thread to terminate first before the next > thread can finish. So if I create like 20 threads in a for loop, and I > join() each created thread, then join() will in effect cause the threads > to be executed in serial rather than in parallel. > No it won't, as in fact there is no mechanism to force a thread to terminate in Python. When you join() each created thread the main thread will wait for each thread to finish. Supposing the longest-lived thread finished first then all others will immediately return from join(). The only requirement it is imposing is that all sub-threads must be finished before the main thread terminates. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From jzgoda at o2.usun.pl Wed Apr 9 14:56:40 2008 From: jzgoda at o2.usun.pl (Jarek Zgoda) Date: Wed, 09 Apr 2008 20:56:40 +0200 Subject: Parsing locale specific dates, currency, numbers In-Reply-To: References: <42b9a3ff0804091004s4d60751fh68c82673e8e3f4c3@mail.gmail.com> <16651e80804091031u5fc752e6s90b54c8675108088@mail.gmail.com> Message-ID: Malcolm Greene pisze: > The locale module provides the ability to format dates, currency and > numbers according to a specific locale. > > Is there a corresponding module for parsing locale's output to convert > locale formatted dates, currency, and numbers back to their native data > types on the basis of a specified locale? > > In other words, a module that will reverse the outputs of locale on a > locale specific basis. There are some attempts in Babel (http://babel.edgewall.org/), but the devs themselves claim the routines are incomplete. You might want to check it, though. -- Jarek Zgoda http://zgodowie.org/ "We read Knuth so you don't have to" - Tim Peters From steve at holdenweb.com Fri Apr 11 09:07:42 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 11 Apr 2008 09:07:42 -0400 Subject: (unknown) In-Reply-To: References: Message-ID: ha bo wrote: > hi i use this programme in my application django: > import struct > MASK_CCITT = 0x1021 # CRC-CCITT mask (ISO 3309, used in X25, HDLC) > MASK_CRC16 = 0xA001 # CRC16 mask (used in ARC files) > > def updcrc(crc, data, mask=MASK_CRC16): > > data_length = len(data) > unpackFormat = '%db' % data_length > unpackedData = struct.unpack(unpackFormat, data) > > for char in data: > c = ord(char) > c = c << 8 > > for j in xrange(8): > if (crc ^ c) & 0x8000: > crc = (crc << 1) ^ mask > else: > crc = crc << 1 > c = c << 1 > > return crc & 0xffff > > > and i call this function in other function in my view: > > > def encodekey(var, expires=None, user='', trusted=False): > > import random, base64 > import updcrc > key = "%02X" % len(var) + var > key += "%02X" % len(user) + user > if expires is not None: > key += expires.strftime('%Y%m%d%H%M') > else: > year = random.choice(range(2000,2100)) > month = 23 > day = random.choice(range(1,32)) > hour = random.choice(range(1,25)) > minute = random.choice(range(1,60)) > key += "%04d%02d%02d%02d%02d" % (year, month, day, hour, minute) > > if trusted: > checksum = updcrc(42, key) > else: > checksum = updcrc(0, key) > key += "%04X" % checksum > > return base64.b64encode(key) > but it give me this error: > > > unpack requires a string argument of length 31 > > > someone can help me > Next time you report an error, please include the whole traceback, not just the exception message. That information is included for a reason. You might also want to print out the value of data in your updcrc function, since that is where the problem is occurring. Finally I might point out there is little point to the struct.unpack since you don't use its result, but I am guessing this is because your algorithm is currently in transition. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From goldenlaks at gmail.com Fri Apr 4 04:47:29 2008 From: goldenlaks at gmail.com (TAJMAHAL TEMPLE) Date: Fri, 4 Apr 2008 01:47:29 -0700 (PDT) Subject: INDIAN TAJ-MAHAL Message-ID: http://ttdtemple.blogspot.com/ From wbsoft at xs4all.nl Fri Apr 11 02:31:04 2008 From: wbsoft at xs4all.nl (Wilbert Berendsen) Date: Fri, 11 Apr 2008 08:31:04 +0200 Subject: pty.spawn directs stderr to stdout Message-ID: <200804110831.05351.wbsoft@xs4all.nl> Hi, using pty.spawn() it seems that stderr output of the spawned process is directed to stdout. Is there a way to keep stderr separate and only direct stdin and stdout to the pty? TIA, w best regards, Wilbert Berendsen -- http://www.wilbertberendsen.nl/ "You must be the change you wish to see in the world." -- Mahatma Gandhi From michele.petrazzo at TOGLIunipex.it Thu Apr 24 09:43:38 2008 From: michele.petrazzo at TOGLIunipex.it (Michele Petrazzo) Date: Thu, 24 Apr 2008 15:43:38 +0200 Subject: annoying dictionary problem, non-existing keys In-Reply-To: References: Message-ID: bvidinli wrote: > i use dictionaries to hold some config data, such as: > > conf={'key1':'value1','key2':'value2'} and so on... > > when i try to process conf, i have to code every time like: if > conf.has_key('key1'): if conf['key1']<>'': other commands.... > > > this is very annoying. in php, i was able to code only like: if > conf['key1']=='someth' > > in python, this fails, because, if key1 does not exists, it raises an > exception. > That is one of python rules: >>> import this (cut) Explicit is better than implicit. (cut) php hide some thing that python expose. > MY question: is there a way to directly get value of an > array/tuple/dict item by key, as in php above, even if key may not > exist, i should not check if key exist, i should only use it, if it > does not exist, it may return only empty, just as in php.... > > i hope you understand my question... > You can simple modify the dict behavior: >>> class my_dict(dict): ... def __getitem__(self, item): ... if item in self: ... return super(my_dict, self).__getitem__(item) ... else: ... return '' ... >>> d = my_dict() >>> d["a"] '' >>> d["a"] = 5 >>> d["a"] 5 >>> Michele From hdante at gmail.com Sat Apr 26 17:27:32 2008 From: hdante at gmail.com (hdante) Date: Sat, 26 Apr 2008 14:27:32 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> Message-ID: <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> On Apr 26, 5:54?pm, n00m wrote: > hdante: > > I run your code quite a few times. > Its time = 0.734s. > Of mine = 0.703-0.718s. > > PS All I have is an ancient Mingw compiler (~1.9.5v) in Dev-C++. Okay, now I believe in you. :-P The next step would be to reimplement readline. From hbloftis at uncc.edu Mon Apr 21 02:33:47 2008 From: hbloftis at uncc.edu (Hunter) Date: Mon, 21 Apr 2008 08:33:47 +0200 (CEST) Subject: Conditional for...in failing with utf-8, Spanish book translation Message-ID: Hi all, This is my first Usenet post! I've run into a wall with my first Python program. I'm writing some simple code to take a text file that's utf-8 and in Spanish and to use online translation tools to convert it, word-by-word, into English. Then I'm generating a PDF with both of the languages. Most of this is working great, but I get intermittent errors of the form: --- Translating coche(coche)... Already cached! English: car Translating ahora(ahora)... tw returned now English: now Translating mismo?(mismo)... Already cached! English: same Translating ?A(?a)... iconv: illegal input sequence at position 0 tw returned error: the required parameter "srctext" is missing English: error: the required parameter "srctext" is missing --- The output should look like: Translating Raw_Text(lowercaserawtextwithoutpunctuation)... tw returned englishtranslation English: englishtranslation I've narrowed the problem down to a simple test program. Check this out: --- # -*- coding: utf-8 -*- acceptable = "abcdefghijklmnopqrstuvwxyz????" # this line will work acceptable = "abcdefghijklmnopqrstuvwxyz?????" # this line won't #wtf? word = "?A" word_key = ''.join([c for c in word.lower() if c in acceptable]) print "word_key = " + word_key --- Any ideas? I'm really stumped! Thanks, Hunter From colas.francis at gmail.com Wed Apr 16 05:56:30 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Wed, 16 Apr 2008 02:56:30 -0700 (PDT) Subject: insert python script in current script References: Message-ID: <967e0362-2d5e-464d-bd22-a0019bc1458a@y21g2000hsf.googlegroups.com> On 16 avr, 09:42, "Prashant" wrote: > I was wondering is there any way to do this: > > I have written a class in python and __init__ goes like this: > > def __init__(self): > > self.name = 'jack' > self.age = 50 > > import data > > now here there is data.py in the same directory and contents are like: > > self.address = 'your address' > self.status = 'single' > > The problem is 'self' is giving some error here. I need to know if > somehow I can do this. It's like inserting the script as it's part of > the file itself. The purpose of import is to build a module object, which implies executing the module file but in a new context. If you simply want to execute some code in a file, you can try execfile("filename"): In [243]: class A(object): .....: def __init__(self): .....: execfile("test.py") .....: In [244]: a=A() In [245]: a.a Out[245]: 1 In [246]: open("test.py").read() Out[246]: 'self.a = 1\n' But do you really want to execute some arbitrary code or to initialize values with some kind of configuration file? > > Cheers From jeffober at gmail.com Thu Apr 3 08:08:13 2008 From: jeffober at gmail.com (Jeff) Date: Thu, 3 Apr 2008 05:08:13 -0700 (PDT) Subject: Get all strings matching given RegExp References: Message-ID: <10be5458-055f-4d9a-af81-de9a6e533729@d1g2000hsg.googlegroups.com> I don't think there is any built in way. Regular expressions are compiled into an expanded pattern internally, but I don't think that it is anything that would be useful for you to directly access. If you are interested in a lot of work, you could do something with PLY and write an re parser that would expand it into a series of possible textual matches :) From python-url at phaseit.net Mon Apr 7 09:14:11 2008 From: python-url at phaseit.net (Gabriel Genellina) Date: Mon, 7 Apr 2008 13:14:11 +0000 (UTC) Subject: Python-URL! - weekly Python news and links (Apr 7) Message-ID: QOTW: "Describing [Python] as a 'scripting language' is like describing a fully-equipped professional kitchen as 'a left-over warming room'." - Steven D'Aprano "[S]ocial measures are the only thing that *can* properly deal with these issues [in this case, naming conflicts, functionality non-partitioning, ...--naming issues, really]." - Ben Finney Python 2.6a2 and 3.0a4 have been released, two new alpha versions of the next major releases: http://groups.google.com/group/comp.lang.python/browse_thread/thread/6cf534b1163b627/ A long thread: Object-Relational Mappers (ORM), pros and cons: http://groups.google.com/group/comp.lang.python/browse_thread/thread/a9b670f2a2b5be42/ Generator functions with recursive calls: why must a loop be explicit? http://groups.google.com/group/comp.lang.python/browse_thread/thread/8923ccee2062473a/ Since 3.0 will be ready soon, why should anyone new to the language bother to learn the old 2.X? http://groups.google.com/group/comp.lang.python/browse_thread/thread/44ace1486d840678/ Adding methods to a single instance: http://groups.google.com/group/comp.lang.python/browse_thread/thread/ba80ed8bf095b12f/ Teaching Python in high school: http://groups.google.com/group/comp.lang.python/browse_thread/thread/846ca6453d396fe0/ Python-by-example, examples covering all the standard library modules. http://groups.google.com/group/comp.lang.python/browse_thread/thread/d94853f357614b25/ http://www.lightbird.net/py-by-example/ Incorrect usage of the try/finally construct: http://groups.google.com/group/comp.lang.python/browse_thread/thread/ac8d61438c4c00ca/ super() - when to use (and when not to use it): http://groups.google.com/group/comp.lang.python/browse_thread/thread/22a35db06b0e9764/ Testing whether any string from a set is contained within another string: http://groups.google.com/group/comp.lang.python/browse_thread/thread/5261983811a04956/ ======================================================================== Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. Just beginning with Python? This page is a great place to start: http://wiki.python.org/moin/BeginnersGuide/Programmers The Python Papers aims to publish "the efforts of Python enthusiats": http://pythonpapers.org/ The Python Magazine is a technical monthly devoted to Python: http://pythonmagazine.com Readers have recommended the "Planet" sites: http://planetpython.org http://planet.python.org comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Python411 indexes "podcasts ... to help people learn Python ..." Updates appear more-than-weekly: http://www.awaretek.com/python/index.html Steve Bethard continues the marvelous tradition early borne by Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim Lesher of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to capture useful and interesting recipes. http://aspn.activestate.com/ASPN/Cookbook/Python Many Python conferences around the world are in preparation. Watch this space for links to them. Among several Python-oriented RSS/RDF feeds available are http://www.python.org/channews.rdf http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi http://python.de/backend.php For more, see http://www.syndic8.com/feedlist.php?ShowMatch=python&ShowStatus=all The old Python "To-Do List" now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse http://www.python.org/dev/peps/pep-0042/ The online Python Journal is posted at pythonjournal.cognizor.com. editor at pythonjournal.com and editor at pythonjournal.cognizor.com welcome submission of material that helps people's understanding of Python use, and offer Web presentation of your work. del.icio.us presents an intriguing approach to reference commentary. It already aggregates quite a bit of Python intelligence. http://del.icio.us/tag/python *Py: the Journal of the Python Language* http://www.pyzine.com Archive probing tricks of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 http://groups.google.com/groups?meta=site%3Dgroups%26group%3Dcomp.lang.python.* Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://www.ddj.com/topic/python/ (requires subscription) http://groups-beta.google.com/groups?q=python-url+group:comp.lang.python*&start=0&scoring=d& http://purl.org/thecliff/python/url.html (dormant) or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python There is *not* an RSS for "Python-URL!"--at least not yet. Arguments for and against are occasionally entertained. Suggestions/corrections for next week's posting are always welcome. E-mail to should get through. To receive a new issue of this posting in e-mail each Monday morning (approximately), ask to subscribe. Mention "Python-URL!". Write to the same address to unsubscribe. -- The Python-URL! Team-- Phaseit, Inc. (http://phaseit.net) is pleased to participate in and sponsor the "Python-URL!" project. Watch this space for upcoming news about posting archives. From kranz at theorie.physik.uni-goettingen.de Sat Apr 12 06:53:11 2008 From: kranz at theorie.physik.uni-goettingen.de (Till Kranz) Date: Sat, 12 Apr 2008 12:53:11 +0200 Subject: Confused about Boost.Python & bjam Message-ID: Hi, I tried to get started with Boost.Python. unfortunately I never used the bjam build system before. As it is explained in the documentation I tried to adapt the the files form the examples directory. I copied 'Jamroot', 'boost_build.jam' and 'extending.cpp' to '~/test/'. But I am lost as to what to do now. The docu says I should adjust the 'use-project' path. But what to? I am using a Gentoo system, so there is no boost directory. The librarys are in /usr/lib/ the boost build stuff is in /usr/share/boost-build and the include files are in /usr/include/boost/. If anyone could post minimal Jamroot & boost_build.jam files for this setting I would be realy grateful. I think I will be able to figure out everything else, once I have a working example. Thanks in advance Till From bronger at physik.rwth-aachen.de Wed Apr 30 07:48:01 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 30 Apr 2008 13:48:01 +0200 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> <87tzhjy4u2.fsf@physik.rwth-aachen.de> <1TYRj.27306$o06.18162@tornado.fastwebnet.it> Message-ID: <87iqxzy366.fsf@physik.rwth-aachen.de> Hall?chen! Marco Mariani writes: > Torsten Bronger wrote: > >> However, join() is really bizarre. The list rather than the >> separator should be the leading actor. > > No, because join must work with _any sequence_, and there is no > "sequence" type to put the join method on. No, but for the sake of aesthetics (that's what we're talking here after all), it would be better to have it as the first argument in a build-in function. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From orpap at nus.edu.sg Mon Apr 21 12:28:49 2008 From: orpap at nus.edu.sg (orpap at nus.edu.sg) Date: Mon, 21 Apr 2008 09:28:49 -0700 (PDT) Subject: Financial Modeling with Python by Shayne Fletcher, Christopher Gardner Message-ID: Just saw at amazon.com reference to the following book that might be available later this year: Financial Modeling with Python [IMPORT] (Hardcover) by Shayne Fletcher (Author), Christopher Gardner (Author) Availability: Sign up to be notified when this item becomes available. Product Details * Hardcover: 352 pages * Publisher: John Wiley and Sons Ltd (November 10, 2008) * ISBN-10: 0470987847 * ISBN-13: 978-0470987841 * Shipping Weight: 1.7 pounds Would be nice if the authors or publisher could post to this group an outline or draft table of contents of the book. From hobgoodoreneyhb at gmail.com Tue Apr 22 11:45:31 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:45:31 -0700 (PDT) Subject: cracked eggs Message-ID: <3aa17072-5e76-4388-a5dc-7f5912b5306e@f36g2000hsa.googlegroups.com> cracked eggs http://cracks.12w.net F R E E C R A C K S From kyosohma at gmail.com Wed Apr 9 15:25:34 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 9 Apr 2008 12:25:34 -0700 (PDT) Subject: Displaying vtk files in a wxPython window References: <45b2ab4c-b7a1-450e-a084-e487f231aeca@q1g2000prf.googlegroups.com> Message-ID: <062bd9ce-5a21-4d7d-afba-2d88979e7270@u69g2000hse.googlegroups.com> On Apr 9, 1:38 pm, rocksportrocker wrote: > Hi, > > I want to visualize some vtk-files within a wxPython Window. Google > did not help me > very much, I only found some tools for Tk, what is no solution for me. > > I'm sure I am not the first one who asks this question.... > > Any hints ? > > Greetings, Uwe Hi Uwe, I've never done this, but I found the following: http://www.vtk.org/pipermail/vtkusers/2004-July/075208.html It seems to be an example of using wxPython and vtk. I'm also pretty sure I've seen this topic discussed on the wxPython user's list. You might want to re-post there: http://wxpython.org/maillist.php I also found these links: http://www.people.cornell.edu/pages/ajd27/VTK/lebbin_wxPython.html http://www.wxpython.org/docs/api/wx.lib.vtk-module.html Mike From soltys at noabuse.com Fri Apr 18 02:55:08 2008 From: soltys at noabuse.com (Soltys) Date: Fri, 18 Apr 2008 08:55:08 +0200 Subject: How to set proxy for a python script to run In-Reply-To: <94243913-cdcb-47a2-b000-a236fe0e8009@p25g2000hsf.googlegroups.com> References: <94243913-cdcb-47a2-b000-a236fe0e8009@p25g2000hsf.googlegroups.com> Message-ID: Adam pisze: > Hi, everyone, I am using /usr/share/system-config-language/ > language_gui.py in Python. > For some reason I have to bypass the firewall using a proxy. I read > the urllib reference and set http_proxy="my proxy". But it didn't > work. Is there anyway that we can set the proxy? I did sth. like this: proxy_url = "http://user:pass at proxy.yourproxy.org:8080" proxy_support = urllib2.ProxyHandler({'http': proxy_url}) opener = urllib2.build_opener(proxy_support) urllib2.install_opener(opener) src = urllib2.urlopen(url) now you can easily read from src. -- Soltys "Free software is a matter of liberty not price" From jzshao1 at gmail.com Mon Apr 14 20:06:48 2008 From: jzshao1 at gmail.com (Jonathan Shao) Date: Mon, 14 Apr 2008 20:06:48 -0400 Subject: Interesting timing issue I noticed Message-ID: The project I'm working on is motion detection, involving a bit of image processing. No worries: no image processing background needed. Suffice to say that I initially wrote a script that goes through every pixel of a 320x240 picture (turned into an array using PIL) and performs some calculatiosn. It simply goes through every pixel in the array and performs a simple subtraction with a known value. The idea is to try to find differences between the two images. After a while, to try to speed up the calculations, I realized that I didn't need to do all 320x240 calculations. So I implemented a slightly more sophisticated algorithm and localized my calculations. I still do the pixel subtractions, but I do it on a smaller scale. Surprisingly, when I used time.time() to time the procedures, I find that doing all 320x240 calculations are often faster! On my machine, the former gives me on average an execution time of around 0.125s (and consistently), whereas the latter on average takes 0.160s. Why does this happen? -- "Perhaps we all give the best of our hearts uncritically, to those who hardly think about us in return." ~ T.H.White -------------- next part -------------- An HTML attachment was scrubbed... URL: From bj_666 at gmx.net Sun Apr 13 13:12:48 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 13 Apr 2008 17:12:48 GMT Subject: Tkinter, image not appearing in function but without function References: <42a33edd-5792-47ad-a940-ecb5df23accc@a9g2000prl.googlegroups.com> Message-ID: <66et8fF2ju94lU2@mid.uni-berlin.de> On Sun, 13 Apr 2008 08:57:29 -0700, skanemupp wrote: > why is the first program not working? when i click the screen the map > is not appearing. > > the second program works. > > > > from Tkinter import * > > master = Tk() > > w = Canvas(master, width=700, height=600) > w.pack(expand = YES, fill = BOTH) > > def mapper(): > mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\world-map.gif') > w.create_image(10, 10, image = mapq, anchor = NW) > > def key(event): > print "pressed", repr(event.char) > > def callback(event): > w.focus_set() > print "clicked at", event.x, event.y > mapper() > print 'yo' > square = w.create_oval(event.x-5,event.y-5,event.x+5,event.y+5, > fill="black") > > w.bind("", key) > w.bind("", callback) > w.pack() > > > mainloop() Python doesn't know that the Tk side still needs the image and frees the memory when `mapper()` is done and `mapq` the only name to the `PhotoImage` instance goes out of scope. Ciao, Marc 'BlackJack' Rintsch From banibrata.dutta at gmail.com Sun Apr 20 00:55:51 2008 From: banibrata.dutta at gmail.com (Banibrata Dutta) Date: Sun, 20 Apr 2008 10:25:51 +0530 Subject: Any reliable obfurscator for Python 2.5 Message-ID: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> Hi, Wanted to check if there is any known, reliable, FOSS/Libre -- Obfurscator for Python 2.5 code. -- regards, Banibrata http://www.linkedin.com/in/bdutta -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrick.waldo at gmail.com Wed Apr 2 14:39:58 2008 From: patrick.waldo at gmail.com (patrick.waldo at gmail.com) Date: Wed, 2 Apr 2008 11:39:58 -0700 (PDT) Subject: xlrd and cPickle.dump References: <34e62ddb-477f-4a99-97a5-21a7b148d244@e67g2000hsa.googlegroups.com> <47f22a41@news.mel.dft.com.au> <0d46a213-9f95-43b5-835b-d74d8403626b@c19g2000prf.googlegroups.com> <6acbf9b4-161b-47db-9a91-b2448ee63c34@c26g2000prf.googlegroups.com> <12375df7-387d-424d-84a8-76beb664ae47@59g2000hsb.googlegroups.com> Message-ID: <8abe8ae1-84c9-4f80-ab37-31497a4d273c@a23g2000hsc.googlegroups.com> >FWIW, it works here on 2.5.1 without errors or warnings. Ouput is: >2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] >0.6.1 I guess it's a version issue then... I forgot about sorted! Yes, that would make sense! Thanks for the input. On Apr 2, 4:23 pm, patrick.wa... at gmail.com wrote: > Still no luck: > > Traceback (most recent call last): > File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework > \scriptutils.py", line 310, in RunScript > exec codeObject in __main__.__dict__ > File "C:\text analysis\pickle_test2.py", line 13, in ? > cPickle.dump(Data_sheet, pickle_file, -1) > PicklingError: Can't pickle : attribute lookup > __builtin__.module failed > > My code remains the same, except I added 'wb' and the -1 following > your suggestions: > > import cPickle,xlrd, sys > > print sys.version > print xlrd.__VERSION__ > > data_path = """C:\\test\\test.xls""" > pickle_path = """C:\\test\\pickle.pickle""" > > book = xlrd.open_workbook(data_path) > Data_sheet = book.sheet_by_index(0) > > pickle_file = open(pickle_path, 'wb')cPickle.dump(Data_sheet, pickle_file, -1) > pickle_file.close() > > To begin with (I forgot to mention this before) I get this error: > WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non- > zero > > I'm not sure what this means. > > > What do you describe as "simple manipulations"? Please describe your > > computer, including how much memory it has. > > I have a 1.8Ghz HP dv6000 with 2Gb of ram, which should be speedy > enough for my programming projects. However, when I try to print out > the rows in the excel file, my computer gets very slow and choppy, > which makes experimenting slow and frustrating. Maybe cPickle won't > solve this problem at all! For this first part, I am trying to make > ID numbers for the different permutation of categories, topics, and > sub_topics. So I will have [book,non-fiction,biography],[book,non- > fiction,history-general],[book,fiction,literature], etc.. > so I want the combination of > [book,non-fiction,biography] = 1 > [book,non-fiction,history-general] = 2 > [book,fiction,literature] = 3 > etc... > > My code does this, except sort returns None, which is strange. I just > want an alphabetical sort of the first option, which sort should do > automatically. When I do a test like>>>nest_list = [['bbc', 'cds'], ['jim', 'ex'],['abc', 'sd']] > >>>nest_list.sort() > > [['abc', 'sd'], ['bbc', 'cds'], ['jim', 'ex']] > It works fine, but not for my rows. > > Here's the code (unpickled/unsorted): > import xlrd, pyExcelerator > > path_file = "C:\\text_analysis\\test.xls" > book = xlrd.open_workbook(path_file) > ProcFT_QC = book.sheet_by_index(0) > log_path = "C:\\text_analysis\\ID_Log.log" > logfile = open(log_path,'wb') > > set_rows = [] > rows = [] > db = {} > n=0 > while n rows.append(ProcFT_QC.row_values(n, 6,9)) > n+=1 > print rows.sort() #Outputs None > ID = 1 > for row in rows: > if row not in set_rows: > set_rows.append(row) > db[ID] = row > entry = str(ID) + '|' + str(row).strip('u[]') + '\r\n' > logfile.write(entry) > ID+=1 > logfile.close() > > > Also, any good reason for sticking with Python 2.4? > > Trying to learn Zope/Plone too, so I'm sticking with Python 2.4. > > Thanks again From python at bdurham.com Fri Apr 25 07:56:10 2008 From: python at bdurham.com (python at bdurham.com) Date: Fri, 25 Apr 2008 07:56:10 -0400 Subject: Parsing text file with #include and #define directives In-Reply-To: References: Message-ID: <1209124570.1537.1249832039@webmail.messagingengine.com> Arnaud, Wow!!! That's beautiful. Thank you very much! Malcolm I think it's straightforward enough to be dealt with simply. Here is a solution that doesn't handle errors but should work with well-formed input and handles recursive expansions. expand(filename) returns an iterator over expanded lines in the file, inserting lines of included files. import re def expand(filename): defines = {} def define_repl(matchobj): return defines[matchobj.group(1)] define_regexp = re.compile('#(.+?)#') for line in open(filename): if line.startswith('#include '): recfilename = line.strip().split(None, 1)[1] for recline in expand(recfilename): yield recline elif line.startswith('#define '): _, name, value = line.strip().split(None, 2) defines[name] = value else: yield define_regexp.sub(define_repl, line) It would be easy to modify it to keep track of line numbers and file names. From marli305nugent at gmail.com Sat Apr 26 09:47:02 2008 From: marli305nugent at gmail.com (marli305nugent at gmail.com) Date: Sat, 26 Apr 2008 06:47:02 -0700 (PDT) Subject: cracks full downloads Message-ID: <839dcb67-e059-4b31-8e64-35049123a8f9@24g2000hsh.googlegroups.com> cracks full downloads http://cracks.00bp.com F R E E C R A C K S From pavlovevidence at gmail.com Wed Apr 30 13:58:45 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Wed, 30 Apr 2008 10:58:45 -0700 (PDT) Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> Message-ID: On Apr 30, 6:47 am, Duncan Booth wrote: > Torsten Bronger wrote: > > The biggest ugliness though is ",".join(). No idea why this should > > be better than join(list, separator=" "). Besides, ",".join(u"x") > > yields an unicode object. This is confusing (but will probably go > > away with Python 3). > > It is only ugly because you aren't used to seeing method calls on string > literals. I'm used to seeing it and I think it's ugly. Too terribly convenient to not use, though (which is why I'm used to seeing it). Carl Banks From roy at panix.com Sat Apr 12 12:52:09 2008 From: roy at panix.com (Roy Smith) Date: Sat, 12 Apr 2008 12:52:09 -0400 Subject: unittest: which directory structure? References: <87zlrzw1f5.fsf@physik.rwth-aachen.de> Message-ID: In article <87zlrzw1f5.fsf at physik.rwth-aachen.de>, Torsten Bronger wrote: > Hall?chen! > > I try to port my doctests to unittest. I've found good turorials > about *writing* unit tests but not about organising the files. > > What's the best way to arrange the test source files? I made a > directory called "tests" on the same level as my package, with > (roughly) one test module per package module and wanted to call each > of them from my Makefile or from some sort of root test module. When I first started using unittest, I did the same thing you did -- I put the test files in some other directory. This forced me into having to play the same sorts of tricks you're playing with sys.path so you could import your modules into the test framework. It also turned out to be more work for me during normal development, having to go into one directory to edit a test, then into another to edit the class being tested. Ultimately, I've come to the conclusion that just putting the production code and tests in the same directory is easier. Your next decision is how to name the files. You could put the tests for foo.py in test_foo.py, or foo_test.py (or a million other minor variations on spelling and punctuation). Using a "test_" *prefix* means all the tests sort to the end of the directory listing, so the production code and the test code stay separated from each other. Using a _test *suffix*, means the tests for a given module sort next to the module itself. This is the sort of decision which, while ultimately unimportant, has the ability to consume the entire development group in days (if not weeks) of religious debate. Just pick a style, go with it, and make sure everybody on the team sticks with the same style. From john00587 at gmail.com Mon Apr 21 01:44:01 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:44:01 -0700 (PDT) Subject: crack for spyware doctor Message-ID: crack for spyware doctor http://cracks.00bp.com F R E E C R A C K S From grahn+nntp at snipabacken.se Mon Apr 21 16:49:40 2008 From: grahn+nntp at snipabacken.se (Jorgen Grahn) Date: 21 Apr 2008 20:49:40 GMT Subject: Python 2.5 adoption References: <1da03626-2d4b-4e01-ba47-93f9d5c8f57f@l64g2000hse.googlegroups.com> Message-ID: On Fri, 18 Apr 2008 12:49:25 -0700 (PDT), George Sakkis wrote: > On Apr 18, 2:08?pm, Joseph Turian wrote: >> How widely adopted is python 2.5? >> >> We are doing some development, and have a choice to make: >> a) Use all the 2.5 features we want. >> b) Maintain backwards compatability with 2.4. >> >> So I guess the question is, does anyone have a sense of what percent >> of python users don't have 2.5? > > Perhaps you should ask the inverse question too: what 2.5 features do > you find so compelling that you are willing to break compatibility > with 2.4 ? FWIW, the only new 2.5 feature I have been using in > practice is the conditional expressions, and I could easily live > without them. 2.4 is still pretty decent, and a major upgrade from > 2.3. Another data point: I write some Python code in my work and some for hobby/private use, and I am very happy with 2.3. List comprehensions (or whatever they are called) and generators are the most recent features I would hate living without. OP: keep in mind that your users do not see any gain from you using 2.5. All they see is something that makes your software harder to install. At some point you can dismiss them as living in the Stone Age, but the Stone Age is currently 2.1 or something. Maybe 2.2 is, too. /Jorgen -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! From Laundro at gmail.com Tue Apr 8 07:31:42 2008 From: Laundro at gmail.com (LaundroMat) Date: Tue, 8 Apr 2008 04:31:42 -0700 (PDT) Subject: Reproducing a web page and add own content to it. Message-ID: Hi - I'm working on a Django powered site where one of the required functionalities is the possibility of displaying the content of external pages, with an extra banner at the top where specific information is displayed. In other words, I'm looking for a way to reproduce an existing web page and add some HTML code to it. (I can't think of an example right now, but the idea is similar to sites that let you see an external page and have some site-specific text above it (often stating that the content below is not part of the site the user comes from)). To test this, I've been downloading an external page, adding some text to it and re-opening it in a browser (with the help of built-in modules such as urllib2 etc). This works of course, but the external page's links such as , or are evidently no longer correct. Apart from parsing the whole file and trying to inject the external site's domain in links such as the above (with the added inconvenience of having to store the external page locally), is there an easier way of accomplishing what I want? Thanks, Mathieu From mobile at ibinsa.com Fri Apr 18 18:32:00 2008 From: mobile at ibinsa.com (Gabriel Ibanez) Date: Sat, 19 Apr 2008 00:32:00 +0200 Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> Message-ID: <002a01c8a1a4$051a5760$0a01a8c0@mobile> Debian Etch (stable) has Python 2.4 ----- Original Message ----- From: "Thomas Bellman" Newsgroups: comp.lang.python To: Sent: Friday, April 18, 2008 8:50 PM Subject: Re: Python 2.5 adoption > John Nagle writes: > >> Desktop or server? > >> If server, check what the major Linux distros, like Fedora >> Core, are shipping with. > > For server, you should probably rather look at distros like > RHEL/CentOS, Suse and Debian Stable. > > For what it's worth, Fedora 8 has Python 2.5, RHEL 5 ships with > Python 2.4, and RHEL 4 has Python 2.3. Suse and Debian, I don't > know. > >> Check major shared hosting providers to see what they're offering >> to their customers as standard. > > I would expect that to often depend on what OS version they are > using. And RHEL/CentOS 4 is still quite common, so if you want > to reach a large "customer base", make sure that your Python > programs work with Python 2.3. > > > -- > Thomas Bellman, Lysator Computer Club, Link??ping University, Sweden > "Don't tell me I'm burning the candle at both ! bellman @ lysator.liu.se > ends -- tell me where to get more wax!!" ! Make Love -- Nicht Wahr! > -------------------------------------------------------------------------------- > -- > http://mail.python.org/mailman/listinfo/python-list From jergosh at wp.pl Tue Apr 15 15:12:30 2008 From: jergosh at wp.pl (=?UTF-8?B?R3J6ZWdvcnogU8WCb2Rrb3dpY3o=?=) Date: Tue, 15 Apr 2008 21:12:30 +0200 Subject: Java or C++? In-Reply-To: References: Message-ID: <4804FE1E.8000100@wp.pl> > You must be joking - better designed? C++ was a botch to an already poor > language. > Although I'm relatively new to the concept that C++ is too difficult to use, I would concede that with certain mindset and priorities Java may be a valid choice. Not so if one is willing to expand knowledge about programming and find a complement for Python. Where I can't agree is that C is a poor language. You may prefer Unix was written in Pascal but C is still an excellent language, if no longer 'general-purpose.' C++ continues its philosophy of granting as much control as possible to the programmer. Whether it's a good or bad thing is debatable and depends on purpose for which you're using it. > Personally I find Java very satisfying to write. > Bing. From santoshanmsoft at gmail.com Tue Apr 29 02:56:29 2008 From: santoshanmsoft at gmail.com (santoshanmsoft at gmail.com) Date: Mon, 28 Apr 2008 23:56:29 -0700 (PDT) Subject: Acer Aspire 4520NWXMi Athlon LX.AHS0C.011LE Notebook Message-ID: <3141aa14-f8dd-46bc-9566-7f5182c16d1d@n1g2000prb.googlegroups.com> Features: * Based on the powerful and affordable AMD Turion? 64 X2 Mobile Technology, the Aspire 4520 is well suited for any home computing environment. Featuring impressive graphics solutions from NVIDIA?, a 14.1"Acer CrystalBrite? display, ultra-realistic Dolby? surround sound, they excel at video/audio playback, gaming and multitasking. Packaged in Acer's cool new chassis design, The Aspire 4520 is a vibrant beacon of style and class that are sure to become a focal point of the home or office. Processor AMD Athlon X2 TK53 * 1024MB DDR2 533MHz Memory (1GB) * 160GB Hard Disk Drive * 8X DVD-Super Multi double-layer drive * 14.1-inch (35.81 cm) WXGA TFT LCD. Specifications: * Operating System Linux * Processor: AMD Athlon X2 TK53 * Chipset: NVIDIA nForce * Memory: 1024MB DDR2 667MHz Memory * Screen Size 35.81 cms (14.1 wide) * Optical Drive 8X DVD Super Multi double layer drive * Hard Disk Drive: 160 GB HDD * Bluetooth Integrated bluetooth 2.0+EDR * Card Reader 5-in-1 Card reader * LAN: Gigabit LAN * Camera: Acer Crystal Eye Webcam supporting Primalite Technology * Ports & Others: Four USB 2.0 Ports, Dolby Stereo Speakers Warranty: Standard warranty on Notebooks - 1 year Carry-In local (India) warranty and 1 year International Travellers Warranty (Both run concurrently). Features: * Based on the powerful and affordable AMD Turion? 64 X2 Mobile Technology, the Aspire 4520 is well suited for any home computing environment. Featuring impressive graphics solutions from NVIDIA?, a 14.1"Acer CrystalBrite? display, ultra-realistic Dolby? surround sound, they excel at video/audio playback, gaming and multitasking. Packaged in Acer's cool new chassis design, The Aspire 4520 is a vibrant beacon of style and class that are sure to become a focal point of the home or office. Processor AMD Athlon X2 TK53 * 1024MB DDR2 533MHz Memory (1GB) * 160GB Hard Disk Drive * 8X DVD-Super Multi double-layer drive * 14.1-inch (35.81 cm) WXGA TFT LCD. Specifications: * Operating System Linux * Processor: AMD Athlon X2 TK53 * Chipset: NVIDIA nForce * Memory: 1024MB DDR2 667MHz Memory * Screen Size 35.81 cms (14.1 wide) * Optical Drive 8X DVD Super Multi double layer drive * Hard Disk Drive: 160 GB HDD * Bluetooth Integrated bluetooth 2.0+EDR * Card Reader 5-in-1 Card reader * LAN: Gigabit LAN * Camera: Acer Crystal Eye Webcam supporting Primalite Technology * Ports & Others: Four USB 2.0 Ports, Dolby Stereo Speakers Warranty: Standard warranty on Notebooks - 1 year Carry-In local (India) warranty and 1 year International Travellers Warranty (Both run concurrently). http://homeshop18.com/shop/faces/tiles/product.jsp?productID=20265&catalogueID=2&categoryID=920 From na at na.com Wed Apr 23 03:17:35 2008 From: na at na.com (Achillez) Date: Wed, 23 Apr 2008 07:17:35 GMT Subject: Script to convert Tcl scripts to Python? Message-ID: Hi, I have a 10k+ line Tcl program that I would like to auto convert over to Python. Do any scripts exist that can convert ~90% of the standard Tcl syntax over to Python? I know Python doesn't handle strings, but just for general syntax e.g., puts > print, expr > math operations thanks From dickinsm at gmail.com Fri Apr 11 15:27:43 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Fri, 11 Apr 2008 12:27:43 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> Message-ID: <5b1b5304-f076-4240-b685-6aa6c4cc209a@u3g2000hsc.googlegroups.com> On Apr 11, 2:33?pm, Lie wrote: > In this table, we consider that a number is rounded down when the > number is equal to truncated value (the number without fractional > part), while round up is equal to truncated value + 1 or truncated > value -1 if value is negative (Actually this is not round-half-up > algorithm, it's a round-half-away-from-zero algorithm, but lets just > consider that to be the same for now). In this revised table, you get > 10 round ups and 10 round down (i.e. Average Rounding Error == 0), > while by rounding to nearest even you get 9 round up and 11 round down > (i.e. Average Rounding Error != 0). No: if you interpret average to mean 'mean' (add up the (signed) rounding errors from the 20 cases you list and divide by 20) you'll find that the average rounding error is indeed 0 for round-half-to- even, and 0.05 for round-half-away-from-0, just as Mikael said. > Another mistake, in an unquantized value the probability of getting > exactly 0.5 (or any other number specified) is not 0 but an > infinitesimal (i.e. lim(x) where x -> 0 (BUT NOT ZERO)) I'm not sure you'll get many takers for this point of view. If X is a random variable uniformly distributed on the interval [0, 1) then the probability that X == 0.5 is indeed exactly 0, using conventional definitions. (And if you're not using conventional definitions, you should say so....) Mark From martin at v.loewis.de Thu Apr 17 15:12:30 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Thu, 17 Apr 2008 21:12:30 +0200 Subject: Unicode chr(150) en dash In-Reply-To: References: <48063434$0$36327$742ec2ed@news.sonic.net> Message-ID: <4807a11f$0$7672$9b622d9e@news.freenet.de> > For example, I got that EN DASH out of a web page which states version="1.0" encoding="ISO-8859-1"?> at the beggining. That's why I > did go for that encoding. But if the browser can properly decode that > character using that encoding, how come other applications can't? Please do trust us that ISO-8859-1 does *NOT* support EN DASH. There are two possible explanations for the behavior you observed: a) even though the file was declared ISO-8859-1, the data in it actually didn't use that encoding. The browser somehow found out, and chose a different encoding from the declared one. b) the web page contained the character reference – (or –), or the entity reference –. XML allows to support arbitrary Unicode characters even in a file that is encoded with ASCII. > I might need to go for python's htmllib to avoid this, not sure. But > if I don't, if I only want to just copy and paste some web pages text > contents into a tkinter Text widget, what should I do to succesfully > make every single character go all the way from the widget and out of > tkinter into a python string variable? How did my browser knew it > should render an EN DASH instead of a circumflexed lowercase u? Read the source of the web page to be certain. > This is the webpage in case you are interested, 4th line of first > paragraph, there is the EN DASH: > http://www.pagina12.com.ar/diario/elmundo/subnotas/102453-32303-2008-04-15.html Ok, this says – in several places, as well as “ and ” HTH, Martin From ewertman at gmail.com Sat Apr 26 21:39:50 2008 From: ewertman at gmail.com (Eric Wertman) Date: Sat, 26 Apr 2008 21:39:50 -0400 Subject: learning with python question (HtTLaPP) In-Reply-To: References: <98acecbd-9de2-4ebf-927b-ac6bc1fbc3fd@b5g2000pri.googlegroups.com> <53d6254f-895f-48fb-8ab9-3929c403f11b@v23g2000pro.googlegroups.com> Message-ID: <92da89760804261839y42a064a4r88f2d6b2154edf12@mail.gmail.com> On Sat, Apr 26, 2008 at 7:50 PM, wrote: > ok.. I finally made something that works.. Please let me know what you > think: > > >>> def lines(letters): > fin = open('words.txt') > count = 0 > rescount = 0 # count the number of results > results = "" # there are words that contain the letters > for line in fin: > needs = 0 > x = str(line.strip()) > for ch in letters: > if ch not in x: > pass > else: > needs = needs + 1 > if needs == len(letters): > rescount += 1 > results = results + '\n' + x > count += 1 > print count, 'lines searched' > print results, '\n' > print 'result count is: ', rescount That's pretty much it.. I'm guessing you are assuming your file has one word per line? I took a shot at it, without using the regex module: file = open('spyware') my_string = 'uzi' length = len(my_string) words = [] for line in file : chunks = line.strip().split() for chunk in chunks : x = 0 for char in my_string : x = chunk.rfind(char,x) if x > 0 : words.append(chunk) print '\n'.join(words) or with the re module: import re text = open('words.txt').read() pattern = '\S*u\S*z\S*i\S*' stuff = re.findall(pattern,text) count = len(stuff) print "Found %d words :" % (count) print "\n".join(stuff) From steve at holdenweb.com Thu Apr 24 21:27:42 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 21:27:42 -0400 Subject: Psyco alternative In-Reply-To: References: Message-ID: sturlamolden wrote: > On Apr 25, 2:15 am, Steve Holden wrote: > >> I believe, without the benefit of recent experience, that the R stands >> for Restricted. Thus and RPython program must of necessity also be a >> valid Python program. Or do you know something I don't? > > That is correct. But RPython is not anything like Python, I would not > even call it a dynamically typed language. It is actually more like > Fortran 77 with a Python look and feel. That seems a little harsh: it's Python-in-a-strait-jacket. The fact remains that since RPython programs also run under the standard interpreter (albeit a factor of maybe a hundred times more slowly) their claim of self-hosting is valid. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bronger at physik.rwth-aachen.de Wed Apr 16 13:45:31 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 16 Apr 2008 19:45:31 +0200 Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> <87prspydex.fsf@physik.rwth-aachen.de> Message-ID: <87fxtly9qc.fsf@physik.rwth-aachen.de> Hall?chen! Steve Holden writes: > Torsten Bronger wrote: > >> [...] >> >> The admistrative overhead of mailing lists is tedious. >> Fortunately, most important computer-related lists are on >> gmane.org. We could list c.l.py there, too. ;-) > > c.l.py has been on gmane for years, as comp.python.general (why > they have to have their own naming hierarchy i have never > understood). Oops, I overlooked this amongst all these interesting groups. ;-) But I don't need it either. Apparently, it also depends on the NNTP server admin team, and I have a very good one (http://www.individual.net/). I also see spam, but not much (7 among the most recent 1000 postings on c.l.py). Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From kapardhib at gmail.com Mon Apr 21 00:09:59 2008 From: kapardhib at gmail.com (kapardhi bvn) Date: Mon, 21 Apr 2008 09:39:59 +0530 Subject: Accessing parallel port interrupts using python or any c python binding ? Message-ID: <384662990804202109w7180365cu99599ca1628a5736@mail.gmail.com> Any body can tell me an efficient way of reading parallel port at high speed. this is basically to extend ISA and other bus interfacing. please help thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From gagsl-py2 at yahoo.com.ar Mon Apr 28 22:59:59 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 28 Apr 2008 23:59:59 -0300 Subject: descriptor & docstring References: Message-ID: En Mon, 28 Apr 2008 14:35:40 -0300, cyril giraudon escribi?: > Hello, > > I try to use python descriptors to define attributes with default > value (the code is reported below). > But apparently, it breaks the docstring mechanism. > > help(Basis) shows the right help but help(Rectangle) shows only two > lines : > " > Help on class Rectangle in module basis2: > > Rectangle = > " > If the Rectangle.length attribute is removed, the help is OK. > > Secondly, the __doc__ attribute of a PhysicalValue instance doesn't > seem to be read. > > I don't understand. > > Any idea ? This looks like a soup of descriptors, metaclasses and properties... I'll write a two step example. I assume that you want to define an attribute with a default value: when not explicitely set, it returns the default value. This can be implemented with an existing descriptor: property. The only special thing is to handle the default value. Step 1: Our first attempt will let us write something like this: class X(object: length = property_default("length", 12., "This is the length property") We have to write property_default so it returns a property object with the right fget and fset methods. Let's use the same convention as your code, property "foo" will store its value at attribute "_foo". def property_default(prop_name, default_value=None, doc=None): attr_name = '_'+prop_name def fget(self, attr_name=attr_name, default_value=default_value): return getattr(self, attr_name, default_value) def fset(self, value, attr_name=attr_name, default_value=default_value): if value == default_value: delattr(self, attr_name) else: setattr(self, attr_name, value) return property(fget=fget, fset=fset, doc=doc) When setting the same value as the default, the instance attribute is removed (so the default will be used when retrieving the value later). I think this is what you intended to do. That's all. The classes look like this: # just to use a more meaningful name, if you wish PhysicalValue = property_default # A basis class class Basis(object): """ Tempest basis class """ # A concrete class class Rectangle(Basis): """ A beautiful Rectangle """ length = PhysicalValue("length", 12., "This is the length property") py> r = Rectangle() py> print r.length 12.0 py> r.length = 13.5 py> print r.length 13.5 py> dir(r) ['__class__', ... '_length', 'length'] py> r.length = 12 py> dir(r) ['__class__', ... 'length'] Help works too: py> help(Rectangle) Help on class Rectangle in module __main__: class Rectangle(Basis) | A beautiful Rectangle | | Method resolution order: | Rectangle | Basis | __builtin__.object | [...] py> help(Rectangle.length) Help on property: This is the length property Step 2: The problem with the property_default declaration above is that it repeats the name "length". If we want to comply with the DRY principle, we can use a metaclass (note that the previous solution doesn't require a custom metaclass). In the class declaration, we only have to store the parameters needed to define the property; later, when the class is created (the metaclass __new__ method), we replace those parameters with an actual property object. The fget/gset implementation is the same as above. class property_default(object): """Store info for defining a property with a default value. Replaced with a real property instance at class creation time. """ def __init__(self, default_value, doc=None): self.default_value = default_value self.doc = doc # just to use a more meaningful name, if you wish class PhysicalValue(property_default): pass class PropDefaultMetaClass(type): def __new__(cls, name, bases, dct): # replace all property_default declarations # with an actual property object # (we can't modify dct at the same time # we iterate over it, so collect the new items # into another dictionary) newprops = {} for prop_name, prop in dct.iteritems(): if isinstance(prop, property_default): attr_name = '_'+prop_name def fget(self, attr_name=attr_name, default_value=prop.default_value): return getattr(self, attr_name, default_value) def fset(self, value, attr_name=attr_name, default_value=prop.default_value): if value == default_value: delattr(self, attr_name) else: setattr(self, attr_name, value) newprops[prop_name] = property( fget=fget, fset=fset, doc=prop.doc) dct.update(newprops) return super(MyMetaClass, cls).__new__(cls, name, bases, dct) # A basis class class Basis(object): """ Tempest basis class """ __metaclass__ = PropDefaultMetaClass # A concrete class class Rectangle(Basis): """ A beautiful Rectangle """ length = PhysicalValue(12., "This is the length property") The usage and behavior is the same as in step 1, only that we can omit the "length" parameter to PhysicalValue. -- Gabriel Genellina From flarefight at googlemail.com Thu Apr 24 11:14:31 2008 From: flarefight at googlemail.com (flarefight at googlemail.com) Date: Thu, 24 Apr 2008 08:14:31 -0700 (PDT) Subject: Loading associated files Message-ID: <74862697-da58-4eb7-8d60-09aaef54b7ad@j22g2000hsf.googlegroups.com> I am trying to make a a simple databasing GUI interface and and have created a module to deal with parsing the data from a file and a GUI based program that displays this data using PyQt4, i know how to register files in the system registry using python and also using Inno Setup which i use to package my applications, but i cant work out how if a file is doubled clicked on to send the path of that file to python. I have looked into passing command line arguments to python and can send a specific pathname to python but ideally what i need is a generic command that i can write to the registry that passes the pathname of whichever file was doubled clicked!?! am i asking too much/does it exist/is there an easier way to do this!! CC From Robert.Bossy at jouy.inra.fr Tue Apr 15 11:43:25 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Tue, 15 Apr 2008 17:43:25 +0200 Subject: use object method without initializing object In-Reply-To: References: Message-ID: <4804CD1D.7040208@jouy.inra.fr> Reckoner wrote: > would it be possible to use one of an object's methods without > initializing the object? > > In other words, if I have: > > class Test: > def __init__(self): > print 'init' > def foo(self): > print 'foo' > > and I want to use the foo function without hitting the > initialize constructor function. > > Is this possible? > Hi, Yes. It is possible and it is called "class method". That is to say, it is a method bound to the class, and not to the class instances. In pragmatic terms, class methods have three differences from instance methods: 1) You have to declare a classmethod as a classmethod with the classmethod() function, or the @classmethod decorator. 2) The first argument is not the instance but the class: to mark this clearly, it is usually named cls, instead of self. 3) Classmethods are called with class objects, which looks like this: ClassName.class_method_name(...). In your example, this becomes: class Test(object): def __init__(self): print 'init' @classmethod def foo(cls): print 'foo' Now call foo without instantiating a Test: Test.foo() RB From mhansen at gmail.com Tue Apr 22 16:12:07 2008 From: mhansen at gmail.com (Mike Hansen) Date: Tue, 22 Apr 2008 13:12:07 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <82ab65e6-90ec-44db-a030-2251e9df7af4@p25g2000hsf.googlegroups.com> On Apr 22, 3:25 am, azrael wrote: > Hy guys, > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. > > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" > > This hurts. Please give me informations about realy famous > aplications. Sage ( http://www.sagemath.org ) is a pretty large Python computer algebra system ( about 150,000 unique lines of Python and 75,000 unique lines of Cython as a rough estimate). Python turned out to be an _excellent_ language do this in since it allows for quick development time for many things that aren't speed dependent while allowing a seemless transition to fast code with Cython. --Mike From greg.jandl at gmail.com Thu Apr 24 00:51:36 2008 From: greg.jandl at gmail.com (Greg J) Date: Wed, 23 Apr 2008 21:51:36 -0700 (PDT) Subject: Curious relation Message-ID: <613aa1f7-3943-4458-ba7e-4cb29c562988@y21g2000hsf.googlegroups.com> I was reading the programming Reddit tonight and came across this (http://reddit.com/info/6gwk1/comments/): >>> ([1]>2)==True True >>> [1]>(2==True) True >>> [1]>2==True False Odd, no? So, can anyone here shed light on this one? From steve at holdenweb.com Thu Apr 10 19:01:43 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 10 Apr 2008 19:01:43 -0400 Subject: How is GUI programming in Python? In-Reply-To: <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: Michel Bouwmans wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Mike Driscoll wrote: > >> On Apr 10, 12:05 pm, Michel Bouwmans wrote: >>> -----BEGIN PGP SIGNED MESSAGE----- >>> Hash: SHA1 >>> >>> >>> >>> Paul Rubin wrote: >>>> Chris Stewart writes: >>>>> I've always had an interest in Python and would like to dabble in it >>>>> further. I've worked on a few very small command line programs but >>>>> nothing of any complexity. I'd like to build a really simple GUI app >>>>> that will work across Mac, Windows, and Linux. How painful is that >>>>> going to be? I used to be really familiar with Java Swing a few years >>>>> ago. I imagine it will be similar. >>>>> ... >>>>> Next, what would you say is the best framework I should look into? >>>> If by "best" you mean "easiest", that is probably tkinter, which >>>> comes with python. It is somewhat rudimentary and the widgets that >>>> come with it don't look so great. But if you just want to put up >>>> GUI's with basic functionality and not much glitz, it is ok for most >>>> such purposes. >>>> out how to use >>> I don't quite agree with you on this. Tkinter may be easy because it is >>> available by standard in Python, but that's about it in my opinion. The >>> API, look and performance hit is horrible. You're much better of with >>> PyQt4 which makes the job really simple. >>> >>> MFB >>> -----BEGIN PGP SIGNATURE----- >>> Version: GnuPG v1.4.7 (GNU/Linux) >>> >>> iD8DBQFH/kjhDpaqHmOKFdQRAj+kAJ0d3aHqpv/mh7kSqtDqUFXtJsxi1gCfU5UP >>> 2Ygw9ttRIYX+ioMyBVUNsVo= >>> =stR5 >>> -----END PGP SIGNATURE----- >> I see a lot of people recommend using pyQt, but they never mention the >> controversy that surrounds its licensing. There have been many posts >> on the subject already, but if the OP ever decides to sell anything >> they create, I've heard that QT's licensing is kind of squirrelly. >> Maybe this has been straightened out? >> >> I looked at the website and found it fairly confusing. And don't you >> need to download QT itself? >> >> Mike > > Yeah, the licensing of Qt is either be open-source (under one of the > Qt-exception licenses licenses so no exclusivity for the GPL anymore) or > pay for the commercial version. So yes, if you would like to sell it as > closed-source software you will need to buy the commercial version of Qt > and PyQt. In other words: you will have to pay twice. Don't forget that you > can also sell open-source software, so you don't have to pay. ;) > I don't think PyQt has any licensing restrictions to speak of, only the underlying Qt platform (though it's a while since I looked). regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From ewertman at gmail.com Sun Apr 20 12:34:58 2008 From: ewertman at gmail.com (Eric Wertman) Date: Sun, 20 Apr 2008 09:34:58 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: <1d7f2d78-11fd-49f4-877c-73e95f449332@b64g2000hsa.googlegroups.com> > Look into any of the dozen Python-based template engines that are > typically used for such tasks; they offer many more features than a > way to indent blocks. > > George I definitely will.. could you throw out some examples though? Thanks! Eric From filipe.tg at gmail.com Mon Apr 28 06:14:51 2008 From: filipe.tg at gmail.com (Filipe Teixeira) Date: Mon, 28 Apr 2008 03:14:51 -0700 (PDT) Subject: Retrieving int from hex in a file. Message-ID: <9edfaaa3-4e87-4f74-90a5-c10c9daae101@r66g2000hsg.googlegroups.com> Hi. I have to open a binary file from an old computer and recover the information stored (or at least try to). I use: f=open('file.bin','rb') a=f.read() f.close() a in now a string full of hex representations in the form: a[6]='\x14' a[7]='\x20' I would like to convert these hex representations to int, but this (the most obvious way) doesn't seem to be working >>> q=a[6] >>> q '\x14' >>> int(q,16) Traceback (most recent call last): File "", line 1, in ? ValueError: invalid literal for int(): >>> How can I do this? Thanks From see.signature at no.spam Wed Apr 30 04:14:43 2008 From: see.signature at no.spam (Eric Brunel) Date: Wed, 30 Apr 2008 10:14:43 +0200 Subject: Simple TK Question - refreshing the canvas when not in focus References: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> <01b7e1cd-2e30-4751-9be5-63684af6530d@8g2000hse.googlegroups.com> Message-ID: On Tue, 29 Apr 2008 17:09:18 +0200, blaine wrote: [snip] > I'll try the update() again. I would want to use that on the canvas > itself right? Not the root window? Well, in fact, there is no difference at all... In tcl/tk, update is a function, and isn't applied to a particular widget. Any call to the update method on any widget should refresh the whole GUI. HTH -- python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])" From greg.ewing at canterbury.ac.nz Thu Apr 24 19:25:50 2008 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Fri, 25 Apr 2008 11:25:50 +1200 Subject: [Python-Dev] annoying dictionary problem, non-existing keys In-Reply-To: <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> Message-ID: <481116FE.9030501@canterbury.ac.nz> bvidinli wrote: > I posted to so many lists because, > > this issue is related to all lists, > this is an idea for python, > this is related to development of python... You shouldn't post to every group that you think might be vaguely relevant. You should pick *one* that you think is *most* relevant and try that. If you pick the wrong group, chances are you'll be politely redirected to a more relevant one. In this case, it's python-list or comp.lang.python, because this is clearly a usage question, not a request or suggestion for changing the language or its implementation (which is what python-ideas and pytho-dev are for). Posting to many groups at once tends to annoy people, because the readerships of related groups often overlap considerably, so many people get multiple copies of the message. -- Greg From leoniaumybragg at gmail.com Sat Apr 26 06:56:25 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:56:25 -0700 (PDT) Subject: dark crusade patch Message-ID: <6451716b-30ef-4ff1-8327-7e5fa8364bd3@l42g2000hsc.googlegroups.com> dark crusade patch http://cracks.00bp.com F R E E C R A C K S From markfernandes02 at googlemail.com Sat Apr 5 10:00:10 2008 From: markfernandes02 at googlemail.com (markfernandes02 at googlemail.com) Date: Sat, 5 Apr 2008 07:00:10 -0700 (PDT) Subject: In Tkinter - having an input and an entry References: <29f44489-e589-4331-8bea-36fa346026d2@t54g2000hsg.googlegroups.com> Message-ID: On Apr 5, 12:55 pm, Fredrik Lundh wrote: > markfernande... at googlemail.com wrote: > > Traceback (most recent call last): > > File "F:\Programming\python and database\access_db8.2.py", line 129, > > in ? > > Tkwindow() > > File "F:\Programming\python and database\access_db8.2.py", line 88, > > in Tkwindow > > title = stringVar() > > NameError: global name 'stringVar' is not defined > > >>> "StringVar" == "stringVar" > False > > Thanks it sorted out my 'StringVar' problem. I now have another problem... Exception in Tkinter callback Traceback (most recent call last): File "D:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__ return self.func(*args) TypeError: Insert() takes at least 1 argument (0 given) Code below def Insert(self, *row): global cursor, title, author, pubdate, accessDatabase sqlInsert = "INSERT INTO Book_table (Bookname, BookAutor, Publicationdate) VALUES('title + ',' author + ',' pubdate)" myconn = odbc.odbc('accessDatabase') #accessDatabase is the main connection fn. to db stored on HardDrive cursor = myconn.cursor() cursor.execute(sqlInsert) myconn.commit() cursor.close() myconn.close() Tkanks for your tech support. Mark From grante at visi.com Fri Apr 18 23:30:45 2008 From: grante at visi.com (Grant Edwards) Date: Fri, 18 Apr 2008 22:30:45 -0500 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> Message-ID: On 2008-04-18, Bob Greschke wrote: > However, in playing around with your suggestion and Grant's code I've > found that the struct stuff is WAY slower than doing something like this > > Value = (ord(Buf[s])*65536)+(ord(Buf[s+1])*256)+ord(Buf[s+2]) > if Value >= 0x800000: > Value -= 0x1000000 > > This is almost twice as fast just sitting here grinding through a few > hundred thousand conversions (like 3sec vs. ~5secs just counting on my > fingers - on an old Sun...it's a bit slow). Replacing *65536 with <<16 > and *256 with <<8 might even be a little faster, but it's too close to > call without really profiling it. I didn't know speed was important. This might be a little faster (depending on hardware): Value = (ord(Buf[s])<<16) | (ord(Buf[s+1])<<8) | ord(Buf[s+2]) It also makes the intention a bit more obvious (at least to me). A decent C compiler will recognize that <<16 and <<8 are special and just move bytes around rather than actually doing shifts. I doubt the Python compiler does optimizations like that, but shifts are still usually faster than multiplies (though, again, a good compiler will recognize that multiplying by 65536 is the same as shifting by 16 and just move bytes around). -- Grant Edwards grante Yow! If elected, Zippy at pledges to each and every visi.com American a 55-year-old houseboy... From bob at passcal.nmt.edu Mon Apr 21 18:51:13 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Mon, 21 Apr 2008 16:51:13 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> <2008042115060816807-bob@passcalnmtedu> Message-ID: <2008042116511375249-bob@passcalnmtedu> Something is fishy. I just ran this simple-minded thing and I'm, again, getting better times for ord() than I am for unpack() on a 2.8GHz OSX iMac with 2.5.1. This is the iterate so many times you can use your wristwatch method: ---- #! /usr/bin/env python from os import system from struct import unpack print "unpack 1" system("date") for x in xrange(0, 100000000): Value = unpack(">B", "a") system("date") print print "ord 1" system("date") for x in xrange(0, 100000000): Value = ord("a") system("date") print print "unpack 3" system("date") for x in xrange(0, 100000000): Value = unpack(">BBB", "abc") system("date") print print "ord 3" system("date") for x in xrange(0, 100000000): Value = (ord("a") << 16)+(ord("b") << 8)+ord("c") system("date") ---- Unpack 1 is about 1m20s Ord 1 is about 20s Unpack 3 is about 1m20s Ord 3 is about 1m03s after averaging a few runs. From bdsatish at gmail.com Fri Apr 11 07:07:51 2008 From: bdsatish at gmail.com (bdsatish) Date: Fri, 11 Apr 2008 04:07:51 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> Message-ID: <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> On Apr 11, 3:27 pm, colas.fran... at gmail.com wrote: > On 11 avr, 12:14, bdsatish wrote: > > > The built-in function round( ) will always "round up", that is 1.5 is > > rounded to 2.0 and 2.5 is rounded to 3.0. > > > If I want to round to the nearest even, that is > > > my_round(1.5) = 2 # As expected > > my_round(2.5) = 2 # Not 3, which is an odd num > > > I'm interested in rounding numbers of the form "x.5" depending upon > > whether x is odd or even. Any idea about how to implement it ? > > When you say "round to the nearest even", you mean new_round(3) <> 3? No. not at all. The clause "nearest even" comes into picture only when a number is of form "x.5" or else it's same as builtin round( ). new_round(3.0) must be 3.0 itself. Here is the mathematical definition of what I want: If 'n' is an integer, new_round(n+0.5) = n if n/2 is integer new_round(n+0.5) = (n+1) if (n+1)/2 is integer In all other cases, new_round() behave similarly as round( ). Here are the results I expect: new_round(3.2) = 3 new_round(3.6) = 4 new_round(3.5) = 4 new_round(2.5) = 2 new_round(-0.5) = 0.0 new_round(-1.5) = -2.0 new_round(-1.3) = -1.0 new_round(-1.8) = -2 new_round(-2.5) = -2.0 The built-in function doesnt meet my needs for round(-2.5) or round(2.5) From irmen.NOSPAM at xs4all.nl Sat Apr 26 08:25:57 2008 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Sat, 26 Apr 2008 14:25:57 +0200 Subject: Receive data from socket stream In-Reply-To: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> Message-ID: <48131f57$0$14357$e4fe514c@news.xs4all.nl> s0suk3 at gmail.com wrote: > Until now, I've been > doing this little trick: > > data = client.recv(256) > new = data > while len(new) == 256: > new = client.recv(256) > data += new Are you aware that recv() will not always return the amount of bytes asked for? (send() is similar; it doesn't guarantee that the full buffer you pass to it will be sent at once) I suggest reading this: http://www.amk.ca/python/howto/sockets/sockets.html --irmen From ohad.frand at percello.com Wed Apr 30 12:55:51 2008 From: ohad.frand at percello.com (Ohad Frand) Date: Wed, 30 Apr 2008 19:55:51 +0300 Subject: listing computer hard drives with python Message-ID: Hi I am looking for a way to get a list of all active logical hard drives of the computer (["c:","d:"..]) Thanks, Ohad -------------- next part -------------- An HTML attachment was scrubbed... URL: From deets at nospam.web.de Tue Apr 29 19:26:17 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 30 Apr 2008 01:26:17 +0200 Subject: python command mis-interprets arrow keys In-Reply-To: References: Message-ID: <67pp4oF2ppl3sU1@mid.uni-berlin.de> Rahul schrieb: > My python command line seems messed up. I can't seem to be able to use my > backspace key nor my arrow keys. > > I only get control characters: ^[[A^[[D^[[D^[[D^[[C^[[C^[[C etc. > > I access my Linux box via a SecureCRT console. Only after opening the > python interpreter does this occur. Linux command like is OK. vim > interprets keystrokes correctly. So do other interpreters e.g. gnuplot. > > $LANG $TERM > en_US xterm-color > > Versions: > Python 2.4.4 > GCC 4.1.2 20070925 (Red Hat 4.1.2-33) > > > Any sugesstions? Google did not throw anything relevant. Is libreadline installed? Diez From leoniaumybragg at gmail.com Sat Apr 26 07:00:52 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 04:00:52 -0700 (PDT) Subject: shredder 2 3 serial crack Message-ID: shredder 2 3 serial crack http://cracks.00bp.com F R E E C R A C K S From jr9445 at ATT.COM Wed Apr 9 16:26:44 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Wed, 9 Apr 2008 15:26:44 -0500 Subject: Stripping scripts from HTML with regular expressions In-Reply-To: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> References: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: > -----Original Message----- > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > list-bounces+jr9445=att.com at python.org] On Behalf Of Michel Bouwmans > Sent: Wednesday, April 09, 2008 3:38 PM > To: python-list at python.org > Subject: Stripping scripts from HTML with regular expressions > > Hey everyone, > > I'm trying to strip all script-blocks from a HTML-file using regex. > > I tried the following in Python: > > testfile = open('testfile') > testhtml = testfile.read() > regex = re.compile(']*>(.*?)', re.DOTALL) Aha! \b is being interpolated as a backspace character: \b ASCII Backspace (BS) Always use a raw string with regexes: regex = re.compile(r']*>(.*?)', re.DOTALL) Your regex should now work. ***** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA622 From altami0762 at gmail.com Thu Apr 17 15:49:55 2008 From: altami0762 at gmail.com (altami0762 at gmail.com) Date: Thu, 17 Apr 2008 12:49:55 -0700 (PDT) Subject: e-6 patch Message-ID: <08205506-86a7-4880-bba8-0d958e99eaa0@8g2000hse.googlegroups.com> e-6 patch http://cracks.12w.net F R E E C R A C K S From paul.anton.letnes at gmail.com Thu Apr 10 07:59:35 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Thu, 10 Apr 2008 13:59:35 +0200 Subject: problem with using gnuplot/demo.py In-Reply-To: <574751.90080.qm@web94914.mail.in2.yahoo.com> References: <574751.90080.qm@web94914.mail.in2.yahoo.com> Message-ID: Could you include some code around line 39 in demo.py? Also, you could try to comment out the stuff before that point, and see if the demo runs that far. Paul. > hi > i want to use gnuplot with python > i installed it seemingly successfully > but when i try to run demo.py it gives the following error > > > Traceback (most recent call last): > File "C:\Python23\Lib\site-packages\Gnuplot\demo.py", line 113, in ? > demo() > File "C:\Python23\Lib\site-packages\Gnuplot\demo.py", line 39, in > demo > g.reset() > File "C:\Python23\Lib\site-packages\Gnuplot\_Gnuplot.py", line > 355, in reset > self('reset') > File "C:\Python23\Lib\site-packages\Gnuplot\_Gnuplot.py", line > 199, in __call__ > self.gnuplot(s) > File "C:\Python23\Lib\site-packages\Gnuplot\gp_win32.py", line > 125, in __call__ > self.write(s + '\n') > > > im using python23 & gnuplot1.7 > > please help > > From Chandigarh to Chennai - find friends all over India. Click > here.-- > http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From walter at livinglogic.de Thu Apr 24 12:46:15 2008 From: walter at livinglogic.de (=?ISO-8859-1?Q?Walter_D=F6rwald?=) Date: Thu, 24 Apr 2008 18:46:15 +0200 Subject: convert xhtml back to html In-Reply-To: References: Message-ID: <4810B957.3090800@livinglogic.de> Arnaud Delobelle wrote: > "Tim Arnold" writes: > >> hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop to >> create CHM files. That application really hates xhtml, so I need to convert >> self-ending tags (e.g.
) to plain html (e.g.
). >> >> Seems simple enough, but I'm having some trouble with it. regexps trip up >> because I also have to take into account 'img', 'meta', 'link' tags, not >> just the simple 'br' and 'hr' tags. Well, maybe there's a simple way to do >> that with regexps, but my simpleminded )]+/> doesn't work. I'm not >> enough of a regexp pro to figure out that lookahead stuff. > > Hi, I'm not sure if this is very helpful but the following works on > the very simple example below. > >>>> import re >>>> xhtml = '

hello spam
bye

' >>>> xtag = re.compile(r'<([^>]*?)/>') >>>> xtag.sub(r'<\1>', xhtml) > '

hello spam
bye

' You might try XIST (http://www.livinglogic.de/Python/xist): Code looks like this: from ll.xist import parsers from ll.xist.ns import html xhtml = '

hello spam
bye

' doc = parsers.parsestring(xhtml) print doc.bytes(xhtml=0) This outputs:

hello spam
bye

(and a warning that the alt attribute is missing in the img ;)) Servus, Walter From pydev at rscorp.ab.ca Wed Apr 30 13:09:23 2008 From: pydev at rscorp.ab.ca (Scott SA) Date: Wed, 30 Apr 2008 11:09:23 -0600 Subject: PIL and IPTC Message-ID: On 4/30/08, Jumping Arne (arnlen at mac.com) wrote: >I'm completely new to PIL and I'm trying to read IPTC info, I understand that >it's possible but I can't find out how (and for once Google doesn't seem to >be able to help). Does anyone have an example of how it's done? Some basic PIL info: has a tutorial and more info It has been a while since I had to do it but effectively, you need to open the image before you can extract the IPTC as I recall. This should give you a starting point: from PIL import IptcImagePlugin dir(IptcImagePlugin) then... help(IptcImagePlugin.getiptcinfo) A Google Search for 'how-to' gives some insight The process is similar to reading EXIF info, I suggest you look there and modify as necessary. So a modified search to include EXIF While not PIL exclusive, the following should be useful: There are also separate libraries for IPTC with Python bindings. One is called libiptcdata. It lives here: Another example using IPTCInfo: And another python-based (non PIL) one here: While not a direct answer, I hope this is helpful, Scott From sbergman27 at gmail.com Thu Apr 17 13:15:34 2008 From: sbergman27 at gmail.com (Steve Bergman) Date: Thu, 17 Apr 2008 10:15:34 -0700 (PDT) Subject: How to make this unpickling/sorting demo faster? Message-ID: <40a5d8f1-a246-4c48-8759-5b65324f9029@m73g2000hsh.googlegroups.com> I'm involved in a discussion thread in which it has been stated that: """ Anything written in a language that is > 20x slower (Perl, Python, PHP) than C/C++ should be instantly rejected by users on those grounds alone. """ I've challenged someone to beat the snippet of code below in C, C++, or assembler, for reading in one million pairs of random floats and sorting them by the second member of the pair. I'm not a master Python programmer. Is there anything I could do to make this even faster than it is? Also, if I try to write the resulting list of tuples back out to a gdbm file, it takes a good 14 seconds, which is far longer than the reading and sorting takes. The problem seems to be that the 'f' flag to gdbm.open() is being ignored and writes are being sync'd to disk either on each write, or on close. I'd really prefer to let the OS decide when to actually write to disk. I'm using python 2.5.2, libgdm 1.8.3, and python-gdbm 2.5.2 under Ubuntu 8.4 beta and an x86_64 architechture. Thanks for any tips. ===== import cPickle, gdbm, operator dbmIn = gdbm.open('float_pairs_in.pickel') print "Reading pairs..." pairs = cPickle.loads(dbmIn['pairs']) print "Sorting pairs..." pairs.sort(key=operator.itemgetter(1)) print "Done!" ===== The input file was created with this: ===== import random, gdbm, cPickle print "Creating pairs file..." pairs = [(random.random(), random.random(),) for pair in range(0,1000000)] dbmOut = gdbm.open('float_pairs_in.pickel', 'nf') dbmOut['pairs'] = cPickle.dumps(pairs, 2) dbmOut.close() print "Done!" ===== From rkmr.em at gmail.com Thu Apr 24 00:19:10 2008 From: rkmr.em at gmail.com (rkmr.em at gmail.com) Date: Wed, 23 Apr 2008 21:19:10 -0700 Subject: dynamically importing a module and function In-Reply-To: <480d27a3@news.mel.dft.com.au> References: <480d1782$1@news.mel.dft.com.au> <480d27a3@news.mel.dft.com.au> Message-ID: On Mon, Apr 21, 2008 at 4:47 PM, John Machin wrote: > > > saved = sys.path > > > sys.path = data['cwd'] > > > module = __import__(data['module']) > > > sys.path = saved > > > > > > > > import os > > > > > os.chdir('/home/mark/work/proj1') > > > > > import sys > > > > > sys.path.append('/home/mark/work/proj1') > > > > > module = __import__('app') > > > > > function = getattr(module, 'new') > > > > > function(1) > > > > > > > > > > > > > > 1 > > > > It's not at all obvious that the "works in shell" code is the same as the > code in your script. > > Consider the possibility that as a result of frantic experimentation you > have multiple copies of app.* with varying contents lying around. thanks a lot! there was a file app.pyc lying around in the dir from which i was running the script... From slocumb.daphn at gmail.com Fri Apr 18 07:39:36 2008 From: slocumb.daphn at gmail.com (slocumb.daphn at gmail.com) Date: Fri, 18 Apr 2008 04:39:36 -0700 (PDT) Subject: Ableton live 4.1.4 crack Message-ID: <37f60071-fd9b-4f08-b85e-6ff27fe8e4bb@24g2000hsh.googlegroups.com> Ableton live 4.1.4 crack From lists at cheimes.de Sat Apr 12 08:48:02 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 12 Apr 2008 14:48:02 +0200 Subject: accessing individual characters in unicode strings In-Reply-To: References: Message-ID: <4800AF82.2020607@cheimes.de> Peter Robinson schrieb: > Dear list > I am at my wits end on what seemed a very simple task: > I have some greek text, nicely encoded in utf8, going in and out of a > xml database, being passed over and beautifully displayed on the web. > For example: the most common greek word of all 'kai' (or ??? if your > mailer can see utf8) > So all I want to do is: > step through this string a character at a time, and do something for > each character (actually set a width attribute somewhere else for each > character) As John already said: UTF-8 ain't unicode. UTF-8 is an encoding similar to ASCII or Latin-1 but different in its inner workings. A single character may be encoded by up to 6 bytes. I highly recommend Joel's article on unicode: The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) http://www.joelonsoftware.com/articles/Unicode.html Christian From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 3 10:06:15 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 03 Apr 2008 16:06:15 +0200 Subject: object-relational mappers In-Reply-To: <89bca327-6a3f-4128-be72-75d4a50b9bf0@13g2000hsb.googlegroups.com> References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> <89bca327-6a3f-4128-be72-75d4a50b9bf0@13g2000hsb.googlegroups.com> Message-ID: <47f4e456$0$20141$426a74cc@news.free.fr> Luis M. Gonz?lez a ?crit : > I have come to the same conclusion. > ORMs make easy things easier, but difficult things impossible... Not my experience with SQLAlchemy. Ok, I still not had an occasion to test it against stored procedures, but when it comes to complex queries, it did the trick so far - and (warning: front-end developper considerations ahead) happened to be much more usable than raw strings to dynamically *build* the queries. > The best approach I've seen so far is webpy's (if we are talking of > web apps). > It isn't an ORM, it is just a way to make the database api easier to > use. > Queries don't return objects, they return something similar to > dictionaries, which can be used with dot notation ( for example, > result.name is equal to result['name'] ). > > A simple select query would be db.select('customers') or > db.select('customers', name='John'). > But you can also resort to plain sql as follows: db.query('select * > from customers where name = "John"'). > > Simple, effective and doesn't get in your way. Seems nice too in another way. Is that part independant of the rest of the framework ? If so, I'll have to give it a try at least for admin scripts. From jgardner at jonathangardner.net Thu Apr 17 13:19:11 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Thu, 17 Apr 2008 10:19:11 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> <87tzi05vrm.fsf@mulj.homelinux.net> Message-ID: On Apr 17, 9:48 am, sturlamolden wrote: > On Apr 17, 5:46 pm, Hrvoje Niksic wrote: > > > Have you tackled the communication problem? The way I see it, one > > interpreter cannot "see" objects created in the other because they > > have separate pools of ... everything. They can communicate by > > passing serialized objects through ctypes, but that sounds like the > > solutions that use processes. > > I see two solutions to that. > > It is possible to use fine-grained locking on the objects that need to > be communicated. And you'll pay a price for every lock/unlock operation, in addition to the added complexity of the code (which you are already beginning to see.) That's been tried in Python, and everyone agreed that the GIL was the better compromise. > The other option is to use serialized Queues like the processing > module in cheese shop. You mean pipes, files, and sockets? You should check out Stackless's channels. Not a new or unique concept, but a very powerful one that everyone should be familiar with. From adam_no_spam at no_s.p.a.m.bregenzer.net Sun Apr 13 00:57:42 2008 From: adam_no_spam at no_s.p.a.m.bregenzer.net (Adam Bregenzer) Date: Sat, 12 Apr 2008 23:57:42 -0500 Subject: Controlling copying and pickling of objects written in C Message-ID: <3_idnfMhL8pbD5zVnZ2dnUVZ_tPinZ2d@speakeasy.net> I am writing an extension and have "hidden" data included in the object's C structure that is not visible to python. I am unsure what would happen to that data if the python object were copied or pickled and would prefer to raise an exception whenever code tries to copy/deep copy/pickle or marshal the object since it would not make sense. Where would I look to control that? Thanks, Adam From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 29 04:55:13 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 29 Apr 2008 10:55:13 +0200 Subject: list.reverse() In-Reply-To: References: Message-ID: <4816e26a$0$30938$426a74cc@news.free.fr> Mark Bryan Yu a ?crit : > This set of codes works: > >>>> x = range(5) >>>> x.reverse() >>>> x > [4, 3, 2, 1, 0] > > But this doesn't: > >>>> x = range(5).reverse() >>>> print x > None This works just as expected - at least for anyone having read the doc. > Please explain this behavior. range(5) returns a list from 0 to 4 and > reverse just reverses the items on the list that is returned by > range(5). Why is x None (null)? Because that's what list.reverse() returns. Call it a wart if you want (FWIW, I do), but at least that's well documented. From ivan.illarionov at gmail.com Sat Apr 19 01:35:12 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Sat, 19 Apr 2008 05:35:12 +0000 (UTC) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> Message-ID: On Sat, 19 Apr 2008 04:45:54 +0000, Ivan Illarionov wrote: > On Fri, 18 Apr 2008 22:30:45 -0500, Grant Edwards wrote: > >> On 2008-04-18, Bob Greschke wrote: >> >>> However, in playing around with your suggestion and Grant's code I've >>> found that the struct stuff is WAY slower than doing something like >>> this >>> >>> Value = (ord(Buf[s])*65536)+(ord(Buf[s+1])*256)+ord(Buf[s+2]) if >>> Value >>> >= 0x800000: >>> Value -= 0x1000000 >>> >>> This is almost twice as fast just sitting here grinding through a few >>> hundred thousand conversions (like 3sec vs. ~5secs just counting on my >>> fingers - on an old Sun...it's a bit slow). Replacing *65536 with >>> <<16 and *256 with <<8 might even be a little faster, but it's too >>> close to call without really profiling it. >> >> I didn't know speed was important. This might be a little faster >> (depending on hardware): >> >> Value = (ord(Buf[s])<<16) | (ord(Buf[s+1])<<8) | ord(Buf[s+2]) >> >> It also makes the intention a bit more obvious (at least to me). >> >> A decent C compiler will recognize that <<16 and <<8 are special and >> just move bytes around rather than actually doing shifts. I doubt the >> Python compiler does optimizations like that, but shifts are still >> usually faster than multiplies (though, again, a good compiler will >> recognize that multiplying by 65536 is the same as shifting by 16 and >> just move bytes around). > > So why not put it in C extension? > > It's easier than most people think: > > > from3bytes.c > ============ > #include > > PyObject* > from3bytes(PyObject* self, PyObject* args) { > const char * s; > int len; > if (!PyArg_ParseTuple(args, "s#", &s, &len)) > return NULL; > long n = (s[0]<<16) | (s[1]<<8) | s[2]; if (n >= 0x800000) > n -= 0x1000000; > return PyInt_FromLong(n); > } > > static PyMethodDef functions[] = { > {"from3bytes", (PyCFunction)from3bytes, METH_VARARGS}, {NULL, > NULL, 0, NULL}, > }; > > > DL_EXPORT(void) > init_from3bytes(void) > { > Py_InitModule("_from3bytes", functions); > } > > buildme.py > ========== > import os > import sys > from distutils.core import Extension, setup > > os.chdir(os.path.dirname(os.path.abspath(__file__))) sys.argv = > [sys.argv[0], 'build_ext', '-i'] setup(ext_modules = > [Extension('_from3bytes', ['from3bytes.c'])]) > > 'python buildme.py' will create '_from3bytes.so' file 'from _from3bytes > import from3bytes' will import C-optimized function > > Hope this helps. Sorry, the right code should be: PyObject* from3bytes(PyObject* self, PyObject* args) { const char * s; int len; if (!PyArg_ParseTuple(args, "s#", &s, &len)) return NULL; long n = ((((unsigned char)s[0])<<16) | (((unsigned char)s[1])<<8) | ((unsigned char)s[2])); if (n >= 0x800000) n -= 0x1000000; return PyInt_FromLong(n); } From ed at leafe.com Tue Apr 1 19:59:55 2008 From: ed at leafe.com (Ed Leafe) Date: Tue, 1 Apr 2008 18:59:55 -0500 Subject: What motivates all unpaid volunteers at Pycon? In-Reply-To: <6ffcb45b-abb9-4d5e-8237-0f8c6bacab08@i29g2000prf.googlegroups.com> References: <7b539c8e-af4c-4409-81bc-d94e687eea59@i7g2000prf.googlegroups.com> <12d7412e-9f87-4798-a319-a78a27f68d00@e6g2000prf.googlegroups.com> <6ffcb45b-abb9-4d5e-8237-0f8c6bacab08@i29g2000prf.googlegroups.com> Message-ID: <2D7EB6ED-E617-41EC-A15D-6EED754E49FE@leafe.com> On Apr 1, 2008, at 5:37 PM, seberino at spawar.navy.mil wrote: > What do the people get back who did all the hard work at registration > desk and > preparing conference attendee bags? ...who did all hotel preparations? You'll have to ask them. When I've been a part of events like this, just knowing that I contributed is a great feeling. I also usually end up meeting several people I might not have otherwise met, and invariably that makes the experience much, much richer. -- Ed Leafe From chris.ortner at googlemail.com Sat Apr 26 16:49:56 2008 From: chris.ortner at googlemail.com (Chris Ortner) Date: Sat, 26 Apr 2008 13:49:56 -0700 (PDT) Subject: python and web programming, easy way...? References: Message-ID: On Apr 26, 9:36 pm, bvidinli wrote: > Please provide me the quickest/most appropriate solution for web > programming in python. > i will try to switch to python in ehcp too.. > > Currently my web programs are simple Object Oriented programs, that > basicly uses a few files, in php. > i use sessions in use authentications. > i currently use php because it is fairly easy to install/run on apache.. > you just put it on server, it runs.. i look something like this for > python. because python programming is much better than php. Give the web application framework Django a try. Greetings, Chris From aldo at nullcube.com Tue Apr 1 21:24:20 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Wed, 2 Apr 2008 12:24:20 +1100 Subject: ANN: cubictemp template engine Message-ID: <20080402012420.GA21586@nullcube.com> We are happy to announce release 2.0 of Cubictemp, a small, elegant templating system for Python. Features ======== * Simple, well-tested and well-documented. * Integrates tightly with Python - pass arbitrary Python objects into a template, walk sequences and iterators, evaluate expressions. * Default escaping helps to prevent common classes of Cross-Site Scripting vulnerabilities. * Encourages separation of interface and program logic by disallowing statements in templates. * Tiny - only ~ 170 SLOC. There are many large, over-designed Python templating systems out there. Cubictemp proves that a templating sytem can be elegant, powerful, fast and remain compact. Download: http://dev.nullcube.com Manual: http://dev.nullcube.com/doc/cubictemp/index.html -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From skanemupp at yahoo.se Sun Apr 6 19:11:47 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 6 Apr 2008 16:11:47 -0700 (PDT) Subject: Prevent GUI layout from changing? References: Message-ID: On 6 Apr, 22:15, "Gabriel Genellina" wrote: > En Sun, 06 Apr 2008 15:12:55 -0300, escribi?: > > I can't help with your sizing problem, I don't know grids. But don't do > this: > > > def Display(self, number): > > self.expr = self.expr + number > > self.lbText = Label(self, text=self.expr) > > self.lbText.grid(row=0, column=0) > > > def Calculate(self): > > self.expr = str(eval(self.expr))#try catch tex 3+6+ > > self.lbText = Label(self, text=self.expr) > > self.lbText.grid(row=1, column=1) > > self.expr = "" > > You're creating a *new* Label object for each keystroke (they stack on the > same place and only the newest is visible, I presume). > Instead, you should change the text inside the existing widget: > > self.lbText.config(text=self.expr) > > (there is no need to reposition the widget) > Label is described herehttp://effbot.org/tkinterbook/label.htm > and you may want to learn to use Tkinter variables: http://effbot.org/tkinterbook/variable.htm > > -- > Gabriel Genellina the problem is that when i start writing long numbers the window grows bigger which is really annoying. is that ebcause of what u said? as of now i can see exactly the expression i typed and the answer it is just annoing that it doesnt stay the same size. From aguirre.adolfo at gmail.com Mon Apr 28 22:08:01 2008 From: aguirre.adolfo at gmail.com (aguirre.adolfo at gmail.com) Date: Mon, 28 Apr 2008 19:08:01 -0700 (PDT) Subject: Python Math libraries - How to? Message-ID: Hi, I am a very newbie who would very much appreciate some hints. Python 2.52. on Windows XP for now. Soon on Ubuntu 8 I am teaching myself Python following free tutorials. I can solve problems using arithmetic, but when I try to upgrade the programs using math libraries nothing seems to work. I downloaded a 2002 tutorial from Zelle "An Introduction to Computer Science" where he uses a "import math" statement to calculate a square root. I tried the "pi" library function but it didn?t work. I tried using def Pi() it did not work either. I am yet to find a tutorial that explains how to declare (or initialize) and pass numbers to the functions such as "cos(x)" and the pi which does not have a variable in it. Is just a constant. Here is the arithmetic program I made that it worked before I added the "import math" line. I erased the constant p = 3.1416 and added the "i" for the library function "pi" in the algorithms. But I get an error message not recognizing "pi" #volumen.py # A program to compute the volume and surface area of a sphere import math def main(): print "This program calculates the volume and surface area of a sphere" print r = input("Please enter the radious: ") print r3 = r*r*r volume = 4/3*pi*r3 r2 = r*r surface = 4*pi*r2 print "The Volume is", volume, " Cubic centimeters" print print "The Surface area is", surface, " square centimeters" main() *** Error message ************* Traceback (most recent call last): File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 20, in main() File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 13, in main volume = 4/3*pi*r3 NameError: global name 'pi' is not defined From stefan_ml at behnel.de Thu Apr 24 15:55:56 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Thu, 24 Apr 2008 21:55:56 +0200 Subject: convert xhtml back to html In-Reply-To: References: Message-ID: <4810E5CC.2000503@behnel.de> Tim Arnold wrote: > hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop to > create CHM files. That application really hates xhtml, so I need to convert > self-ending tags (e.g.
) to plain html (e.g.
). This should do the job in lxml 2.x: from lxml import etree tree = etree.parse("thefile.xhtml") tree.write("thefile.html", method="html") http://codespeak.net/lxml Stefan From tgiles at gmail.com Wed Apr 16 22:22:00 2008 From: tgiles at gmail.com (tgiles) Date: Wed, 16 Apr 2008 19:22:00 -0700 (PDT) Subject: Python and stale file handles Message-ID: Hi, All! I started back programming Python again after a hiatus of several years and run into a sticky problem that I can't seem to fix, regardless of how hard I try- it it starts with tailing a log file. Basically, I'm trying to tail a log file and send the contents elsewhere in the script (here, I call it processor()). My first iteration below works perfectly fine- as long as the log file itself (logfile.log) keeps getting written to. I have a shell script constantly writes to the logfile.log... If I happen to kill it off and restart it (overwriting the log file with more entries) then the python script will stop sending anything at all out. import time, os def processor(message,address): #do something clever here #Set the filename and open the file filename = 'logfile.log' file = open(filename,'r') #Find the size of the file and move to the end st_results = os.stat(filename) st_size = st_results[6] file.seek(st_size) while 1: where = file.tell() line = file.readline() if not line: time.sleep(1) file.seek(where) else: print line, # already has newline data = line if not data: break else: processor(data,addr) print "Sending message '",data,"'....." someotherstuffhere() === This is perfectly normal behavior since the same thing happens when I do a tail -f on the log file. However, I was hoping to build in a bit of cleverness in the python script- that it would note that there was a change in the log file and could compensate for it. So, I wrote up a new script that opens the file to begin with, attempts to do a quick file measurement of the file (to see if it's suddenly stuck) and then reopen the log file if there's something dodgy going on. However, it's not quite working the way that I really intended it to. It will either start reading the file from the beginning (instead of tailing from the end) or just sit there confuzzled until I kill it off. === import time, os filename = logfile.log def processor(message): # do something clever here def checkfile(filename): file = open(filename,'r') print "checking file, first pass" pass1 = os.stat(filename) pass1_size = pass1[6] time.sleep(5) print "file check, 2nd pass" pass2 = os.stat(filename) pass2_size = pass2[6] if pass1_size == pass2_size: print "reopening file" file.close() file = open(filename,'r') else: print "file is OK" pass while 1: checkfile(filename) where = file.tell() line = file.readline() print "reading file", where if not line: print "sleeping here" time.sleep(5) print "seeking file here" file.seek(where) else: # print line, # already has newline data = line print "readying line" if not data: print "no data, breaking here" break else: print "sending line" processor(data) So, have any thoughts on how to keep a Python script from bugging out after a tailed file has been refreshed? I'd love to hear any thoughts you my have on the matter, even if it's of the 'that's the way things work' variety. Cheers, and thanks in advance for any ideas on how to get around the issue. tom From kayvoo at googlemail.com Sat Apr 19 17:47:33 2008 From: kayvoo at googlemail.com (Karl-Heinz Ruskowski) Date: Sat, 19 Apr 2008 23:47:33 +0200 Subject: manipulating class attributes from a decorator while the class is being defined In-Reply-To: <200804192319.14735.wbsoft@xs4all.nl> References: <200804192319.14735.wbsoft@xs4all.nl> Message-ID: <200804192347.40335.kayvoo@gmail.com> > How can I reach the class attribute `regexps' from within a decorator? Now, the first way that comes to my mind is simply overloading the class and set your regexps variable in your new class. The other way is to create an object and set it more manually (obj.regexps = ['.*']). Which for me is an ugly this to do because the first way is far more elegant :) -- GPG key: 0x04B3BB96 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available URL: From bskaplan14 at yahoo.com Sun Apr 27 09:33:57 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Sun, 27 Apr 2008 06:33:57 -0700 (PDT) Subject: Installed python 2.5 over 2.4 and lost installed packages Message-ID: <133019.97041.qm@web39206.mail.mud.yahoo.com> I don't know what the best practice is, but just creating sym links into site-packages will work, and it saves the extra memory from cp'ing. ----- Original Message ---- From: "james at reggieband.com" To: python-list at python.org Sent: Sunday, April 27, 2008 9:15:06 AM Subject: Installed python 2.5 over 2.4 and lost installed packages Hi all, I recently updated os x from python 2.4 to 2.5 (from python.org) and in doing so I lost my old python path entries. Python 2.4 was installed using fink. Now when I do: import sys print sys.path my old site-packages directory is not within it (the 2.4 one). So what is the right thing to do in this situation? It would be a pain to find and re-install each of the packages. Is it ok to add my old site-packages directory to the sys.path? What is the best way to do so (e.g. using .pth files or PYTHONPATH or other)? Is cp'ing the files from one place to another safe or advisable? Any help on best practices appreciated. James. -- http://mail.python.org/mailman/listinfo/python-list ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From darcy at druid.net Wed Apr 23 10:58:46 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Wed, 23 Apr 2008 10:58:46 -0400 Subject: MESSAGE RESPONSE In-Reply-To: <480F483B.9050507@holdenweb.com> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> <27CC3060AF71DA40A5DC85F7D5B70F38033A4F2D@AWMAIL04.belcan.com> <480F483B.9050507@holdenweb.com> Message-ID: <20080423105846.e163bf1f.darcy@druid.net> On Wed, 23 Apr 2008 10:31:23 -0400 Steve Holden wrote: > Blubaugh, David A. wrote: > > Is there a way to block these messages. I do not want to be caught > > with filth such as this material. I could lose my job with Belcan with > > evil messages such as these messages. > > > In future please ensure you do not quote the offending URLs when sending > out such messages. It's quite bad enough that the things appeared on the > list once without you doing the originator the favor of repeating them. Even worse, some people are blocking Google Groups and never even saw those postings until David reposted them from a non-Google account. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From noagbodjivictor at gmail.com Fri Apr 25 06:28:19 2008 From: noagbodjivictor at gmail.com (noagbodjivictor at gmail.com) Date: Fri, 25 Apr 2008 03:28:19 -0700 (PDT) Subject: Can you recommend a book? Message-ID: Hello all, I learned Python with the book "Programming Python" by John Zelle. But today this book is a little bit old. My Python is some kind old. I need a book that will help me brush my style and keep me up to date. I would like one with practical examples. Can you recommend one? From george.sakkis at gmail.com Fri Apr 18 15:49:25 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 18 Apr 2008 12:49:25 -0700 (PDT) Subject: Python 2.5 adoption References: Message-ID: <1da03626-2d4b-4e01-ba47-93f9d5c8f57f@l64g2000hse.googlegroups.com> On Apr 18, 2:08?pm, Joseph Turian wrote: > How widely adopted is python 2.5? > > We are doing some development, and have a choice to make: > a) Use all the 2.5 features we want. > b) Maintain backwards compatability with 2.4. > > So I guess the question is, does anyone have a sense of what percent > of python users don't have 2.5? Perhaps you should ask the inverse question too: what 2.5 features do you find so compelling that you are willing to break compatibility with 2.4 ? FWIW, the only new 2.5 feature I have been using in practice is the conditional expressions, and I could easily live without them. 2.4 is still pretty decent, and a major upgrade from 2.3. George From kay.schluehr at gmx.net Fri Apr 18 16:17:32 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Fri, 18 Apr 2008 13:17:32 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <14107338-3bf1-45cb-983a-687f46f19503@d45g2000hsc.googlegroups.com> Message-ID: <86338087-cc95-4701-b3c6-83b2b01a16c4@m36g2000hse.googlegroups.com> On 18 Apr., 20:07, Aaron Watters wrote: > I don't really know, but I think "fixing" the above issue for > string.format(...) might involve changing the representation of > every python stack frame... not worth it in this case if there > is any penalty (afaik there isn't). In Python 2.6 the format function simply calls PyDict_GetItem on the dictionary object and raises a KeyError if it fails. A dict emulation would require one more lookup if the fast lookup has no result. It would be a speed penalty in the general case if this lookup would be implemented in PyDict_GetItem but handling a special case in the format implementation might not look that bad. From dennis.benzinger at gmx.net Thu Apr 10 10:29:45 2008 From: dennis.benzinger at gmx.net (Dennis.Benzinger@gmx.net) Date: Thu, 10 Apr 2008 07:29:45 -0700 (PDT) Subject: tkinter, overwrite Label-text? References: Message-ID: On Apr 10, 3:47 pm, skanem... at yahoo.se wrote: > [...] > i use the Label-widget. Then you should be able to connect a variable to your widget like I wrote in my previous post. Just try out the example from the Python documentation. Of course in your case entrythingy would be the Label-widget. Take care to assign values to your variable by using the set function. Dennis Benzinger From dolloffdelvpg at gmail.com Wed Apr 16 08:08:38 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:08:38 -0700 (PDT) Subject: taylor swift bio Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From danb_83 at yahoo.com Sat Apr 26 19:25:47 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Sat, 26 Apr 2008 16:25:47 -0700 (PDT) Subject: How do I say "Is this a function"? References: Message-ID: <96f62c7c-f951-4dc3-9af3-6cdd74cfa23b@v26g2000prm.googlegroups.com> On Apr 26, 6:17 pm, John Henry wrote: > How do I determine is something a function? > > For instance, I don't want to relying on exceptions below: > > def f1(): > print "In f1" > > def f3(): > print "In f3" > > def others(): > print "In others" > > for i in xrange(1,3): > fct = "f%d()"%(i+1) > try: > exec fct > except: > others() > > I wish to say: > > if value of fct is a funtion, invoke it, otherwise invoke others(). > > Thanks, hasattr(fct, '__call__') And be careful about using the exec statement. From JesseAldridge at gmail.com Mon Apr 7 02:22:03 2008 From: JesseAldridge at gmail.com (Jesse Aldridge) Date: Sun, 6 Apr 2008 23:22:03 -0700 (PDT) Subject: Python Data Utils References: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> <8eec6557-784d-4fd8-8478-8da17aedf0ab@d1g2000hsg.googlegroups.com> <85979669-64ed-49a1-b154-595bed50179f@w5g2000prd.googlegroups.com> Message-ID: <204305df-2cc8-4f44-8b98-5696e135a936@d45g2000hsc.googlegroups.com> > Docstrings go *after* the def statement. Fixed. > changing "( " to "(" and " )" to ")". Changed. I attempted to take out everything that could be trivially implemented with the standard library. This has left me with... 4 functions in S.py. 1 one of them is used internally, and the others aren't terribly awesome :\ But I think the ones that remain are at least a bit useful :) > The penny drops :-) yeah, yeah > Not in all places ... look at the ends_with function. BTW, this should > be named something like "fuzzy_ends_with". fixed > fuzzy_match(None, None) should return False. changed > 2. make_fuzzy function: first two statements should read "s = > s.replace(.....)" instead of "s.replace(.....)". fixed > 3. Fuzzy matching functions are specialised to an application; I can't > imagine that anyone would be particularly interested in those that you > provide. I think it's useful in many cases. I use it all the time. It helps guard against annoying input errors. > A basic string normalisation-before-comparison function would > usefully include replacing multiple internal whitespace characters by > a single space. I added this functionality. > 5. Casual inspection of your indentation function gave the impression > that it was stuffed Fixed Thanks for the feedback. From tjreedy at udel.edu Wed Apr 9 17:56:53 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 9 Apr 2008 17:56:53 -0400 Subject: Google App Engine References: <47fc2c7c$0$36365$742ec2ed@news.sonic.net><7e43fcd9-6207-4af2-8256-c0099a8ce0bb@1g2000prf.googlegroups.com> Message-ID: "Duncan Booth" wrote in message news:Xns9A7B6452B3786duncanbooth at 127.0.0.1... | There are several things which would make moving away from Google tricky: I noticed that too, but it does have the virtue that development is done on one's own machine rather than keeping everying on the ISP's machines, like one web-stite 'quick' builder I have seen. From bj_666 at gmx.net Sun Apr 27 03:37:58 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 27 Apr 2008 07:37:58 GMT Subject: diffing and uniqing directories References: Message-ID: <67ioqmF2nvf5vU2@mid.uni-berlin.de> On Sat, 26 Apr 2008 20:35:29 -0700, rustom wrote: > On Apr 27, 12:31?am, castiro... at gmail.com wrote: >> On Apr 26, 1:14?pm, "Rustom Mody" wrote: >> [?] > > If this is an answer to my question I dont understand it! castironpi is either a bot or trolling. Just ignore its posts. Ciao, Marc 'BlackJack' Rintsch From jgardner at jonathangardner.net Mon Apr 14 01:25:09 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Sun, 13 Apr 2008 22:25:09 -0700 (PDT) Subject: urllib working differently when run from crontab References: Message-ID: On Apr 13, 8:50?pm, VictorMiller wrote: > I've written a python script which, using urllib, and urllib2 will > fetch a number of files that that I'm interested in from various > websites (they're updated everyday). ?When I run the script from my > command line everything works as intended. ?However, when the script > is run from crontab every single url that I attempt to open gets > "connection refused". ?Has anyone ever seen anything like this? ?If > so, what's causing it, and what can I do about it? > Try su'ing as the user and running the scripts. Maybe that will shed some light on the problem. From victorsubervi at gmail.com Tue Apr 8 12:55:07 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Tue, 8 Apr 2008 11:55:07 -0500 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> Message-ID: <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> Thanks. I apparently am printing some holder for the image. I stripped out most of it with this content[0][0] but then I am left with this: array('c', '\xff\xd8\xff\xe0\\0\x10JFI...) How do I extract an image from that? TIA, Victor On Tue, Apr 8, 2008 at 11:15 AM, Steve Holden wrote: > Victor Subervi wrote: > > Hi: > > I am able (finally) to upload an image to the database. However, when I > > try to retrieve it, I get a string literal. Here is my code: > > > > #!/usr/local/bin/python > > import cgitb; cgitb.enable() > > import MySQLdb > > def test(): > > host = 'mysqldb2.ehost-services.com < > http://mysqldb2.ehost-services.com>' > > user = 'user' > > passwd = 'pass' > > db = 'bre' > > db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > > cursor= db.cursor() > > cursor.execute('select pic1 from products where id="3";') > > content = cursor.fetchall() > > # print 'Content-Type: image/jpeg\r\nContent-Length: %d\n' % > len(content) > > print 'Content-Type: image/jpeg\r\n' > > print '\n' > > print content > > print '\n' > > cursor.close() > > > > test() > > (Apparently, Plesk doesn?t like if __name__ == '__main__': ) > > The commented out line gives me a leading less than sign...and that?s > > it. What do? > > TIA, > > Victor > > > Your headers indicate you intend to serve a JPEG image, so you should > *not* then include HTML. Take a look at the HTML of a web page with an > image inside it (look for the tag) and you will see that > HTML pages reference images as separate web resources. > > Thus once you have printed out your HTML headers you should them > immediately send the contents of the database column. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zolotoiklo at mail.ru Thu Apr 24 07:02:58 2008 From: zolotoiklo at mail.ru (=?KOI8-R?B?+s/Mz9TPyiDrzM/O?=) Date: Thu, 24 Apr 2008 04:02:58 -0700 (PDT) Subject: =?KOI8-R?B?1MXSzc/CxczYxQ==?= Message-ID: Shop Body - ????????-??????? ??????? ??? ??????? ? ????????. ?? ???? ?????????? ?????? ???????? ?????? ??? ???????? ????? ???????????? ? ??????????? ?????? ??????? ?????????????? ????: ?????, ???????, ???????, ?????????? ??????, ??????? ??? ????????? ? ??????? ?????????, ????????? ? ??????????????, ???????? ???????????? ? ??????????, ?????? ??? ????? ?? ?????? ?????????? http://shopbody.ru/ From noahwatkins at gmail.com Thu Apr 3 17:13:25 2008 From: noahwatkins at gmail.com (noahwatkins) Date: Thu, 3 Apr 2008 14:13:25 -0700 (PDT) Subject: displaying execution of Python code Message-ID: <1afcbf34-0a40-4d11-b12f-603f0ee8f26c@m3g2000hsc.googlegroups.com> I'll start my question by describing my desired result. I will construct a GUI which will be used to open a Python script. I would then like to be able to display the Python script, execute it, and highlight the lines of the Python as they are executing. More technically, I am looking for direction on where to start looking in the Python libraries for a functionality that will allow me to execute arbitrary Python code from within a Python application. Additionally, I need to be able to have the ability to get information and perform actions (e.g. line number currently executing) as the code executes. Thanks, Noah From tinnews at isbd.co.uk Sun Apr 6 06:39:41 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 06 Apr 2008 10:39:41 GMT Subject: mailbox.Maildir(), confusing documentation References: <47f4f4f4$0$715$bed64819@news.gradwell.net> Message-ID: <47f8a86d$0$753$bed64819@news.gradwell.net> Peter Otten <__peter__ at web.de> wrote: > tinnews at isbd.co.uk wrote: > > > Having got my Python 2.5.2 installed I'm trying some things out with > > the mailbox.Maildir() class. > > > > If I do the following:- > > > > import maibox > > mailbox.Maildir("/home/isbd/Mail/Li/pytest") > > > > then the pytest Maildir mailbox is created - which is great but isn't > > documented. If the above creates the maildir then what is the > > mailbox.Maildir.add_folder() method for? I tried > > mailbox.Maildir.add_folder() and it appeared to do nothing, it didn't > > produce any errors either. > > You didn't expect the dot, it seems: > I didn't 'expect' the dot because it's not standard maildir syntax, it's just one particular way of doing it. ... but thanks for pointing out what was going on. :-) > >>> import mailbox > >>> m = mailbox.Maildir("alpha") > >>> m.add_folder("beta") > > >>> > $ find . > . > ./alpha > ./alpha/tmp > ./alpha/cur > ./alpha/new > ./alpha/.beta > ./alpha/.beta/tmp > ./alpha/.beta/cur > ./alpha/.beta/new > ./alpha/.beta/maildirfolder > $ > > Peter -- Chris Green From bearophileHUGS at lycos.com Thu Apr 10 17:11:26 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Thu, 10 Apr 2008 14:11:26 -0700 (PDT) Subject: Graphs in Python References: Message-ID: <384e6ccf-107b-4126-8878-ef75a21ddb23@1g2000prg.googlegroups.com> Sanhita Mallick>where can I find more in depth info about how to express graphs in python, and how to use them in a code?< You can look here: https://networkx.lanl.gov/wiki My version: http://sourceforge.net/projects/pynetwork/ Bye, bearophile From bronger at physik.rwth-aachen.de Wed Apr 30 05:06:52 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 30 Apr 2008 11:06:52 +0200 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> Message-ID: <87y76vyamr.fsf@physik.rwth-aachen.de> Hall?chen! SL writes: > "Gabriel Genellina" schreef in bericht > news:mailman.365.1209541507.12834.python-list at python.org... > >> En Wed, 30 Apr 2008 04:19:22 -0300, SL escribi?: And >> that's a very reasonable place to search; I think chr and ord are >> builtin functions (and not str methods) just by an historical >> accident. (Or is there any other reason? what's wrong with >> "a".ord() or str.from_ordinal(65))? > > yes when you know other OO languages you expect this. Anyone know > why builtins were chosen? Just curious *Maybe* for aesthetical reasons. I find ord(c) more pleasent for the eye. YMMV. The biggest ugliness though is ",".join(). No idea why this should be better than join(list, separator=" "). Besides, ",".join(u"x") yields an unicode object. This is confusing (but will probably go away with Python 3). Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From chita323f at casema.nl Tue Apr 29 04:30:21 2008 From: chita323f at casema.nl (RJ vd Oest) Date: Tue, 29 Apr 2008 10:30:21 +0200 Subject: need help of regular expression genius Message-ID: <001301c8a9d3$4c447e90$c17a5553@vanderOest> -------------- next part -------------- An HTML attachment was scrubbed... URL: From hdante at gmail.com Sat Apr 26 14:48:04 2008 From: hdante at gmail.com (hdante) Date: Sat, 26 Apr 2008 11:48:04 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> Message-ID: <847a2819-9684-4bd9-a445-5fd24f6eb768@e39g2000hsf.googlegroups.com> On Apr 26, 12:10?pm, n00m wrote: > Both codes below read the same huge(~35MB) text file. > In the file > 1000000 lines, the length of each line < 99 chars. > > Stable result: > Python runs ~0.65s > C : ~0.70s > > Any thoughts? > > import time > t=time.time() > f=open('D:\\some.txt','r') > z=f.readlines() > f.close() > print len(z) > print time.time()-t > m=input() > print z[m] > > #include > #include > #include > #include > > using namespace std; > char vs[1002000][99]; > FILE *fp=fopen("D:\\some.txt","r"); > > int main() { > ? ? int i=0; > ? ? while (true) { > ? ? ? ? if (!fgets(vs[i],999,fp)) break; > ? ? ? ? ++i; > ? ? } > ? ? fclose(fp); > ? ? cout << i << endl; > ? ? cout << clock()/CLOCKS_PER_SEC << endl; > > ? ? int m; > ? ? cin >> m; > ? ? cout << vs[m]; > ? ? system("pause"); > return 0; > > } > > First try again with pure C code and compile with a C compiler, not with C++ code and C++ compiler. Then, tweak the code to use more buffering, to make it more similar to readline code, like this (not tested): #include #include char vs[1002000][100]; char buffer[65536]; int main(void) { FILE *fp; int i, m; clock_t begin, end; double t; begin = clock(); fp = fopen("cvspython.txt", "r"); i = 0; setvbuf(fp, buffer, _IOFBF, sizeof(buffer)); while(1) { if(!fgets(vs[i], 100, fp)) break; ++i; } fclose(fp); printf("%d\n", i); end = clock(); t = (double)(end - begin)/CLOCKS_PER_SEC; printf("%g\n", t); scanf("%d", &m); printf("%s\n", vs[m]); getchar(); return 0; } Finally, repeat your statement again, if necessary. From Lie.1296 at gmail.com Sun Apr 20 05:16:40 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 20 Apr 2008 02:16:40 -0700 (PDT) Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> Message-ID: <78426dcc-81b1-478a-8c72-bb1b3700d21c@v23g2000pro.googlegroups.com> On Apr 19, 1:08 am, Joseph Turian wrote: > How widely adopted is python 2.5? > > We are doing some development, and have a choice to make: > a) Use all the 2.5 features we want. > b) Maintain backwards compatability with 2.4. > There is another choice: Develop with future in mind because it's possible that when you finished version 1, what seemed to be future would become the present. This is especially if the project is big and requires years to complete. On Apr 19, 5:13 pm, Graham Breed wrote: > My web host uses 1.5.2. That is painful. If them using 1.5.2 is painful for you ask the host to install something newer (AFAIK it is possible to run several python versions side-by-side) or prepare yourself to move to other host. From darcy at druid.net Tue Apr 22 13:25:07 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Tue, 22 Apr 2008 13:25:07 -0400 Subject: Spawing a thread and printing dots until it finishes In-Reply-To: References: Message-ID: <20080422132507.0be52092.darcy@druid.net> On Tue, 22 Apr 2008 09:32:38 -0700 (PDT) sophie_newbie wrote: > On Apr 22, 4:41 pm, "D'Arcy J.M. Cain" wrote: > > We know that your main routine gives up the processor but without a > > full definition of MyThread how do we know that it ever does? I > > suspect that it hits sleep once, if at all, and then goes to the final > > print statement. In fact, I suspect that this is not exactly what you > > tried anyway. This code would not have printed ".OK" whether it > > entered the loop or not. It could have printed this; > > > > . > > OK > > > > because the print statement in the loop will print a dot on a line by > > itself. > "myLongCommand()... " is a call to an function in R (the statistical > programming language) via Rpy (A python module that allows calls to > R). The call takes a couple of minutes to execute. I'm trying to build > a web front end to this R function and instead of the user looking at > a blank screen for 2-3 mins, I want to print dots to let them feel > like the program isn't hanging. > > What I am saying is that without the "time.sleep(.5)" line, the above > code will print dots on the screen continuously for 2-3 mins, filling > it up with a ridiculous ammount of dots. Does it ever finish? It seems to me that it would loop forever if you never give up the processor. Remember, threads are not processes. > Whereas with the time.sleep line, instead of pausing for half a second > between dots, its seems to print, as you correctly pointed out: > > . > OK > > With a pause of 2-3 minutes between the . and the OK. Exactly. It prints the first dot and then gives up the processor to your other thread. That thread runs for 2 to 3 minutes and then completes giving up the processor. At that point your sleep has slept for at least .5 seconds so the first thread if free to run. It then checks the condition of the loop, sees that it is finished and continues on the the next statement which prints the "OK" and exits. > I hope that clears things up a little. I haven't the faintest idea why > the code above doesn't work but hope someone has an idea. It wouldn't > be something to do with python not being able to handle multiple > threads at the same time or something? I hope there is a workaround. I think that there are two things that you need to wrap your head around before understanding what is happening here. First, threads are NOT pre-emptive. Unless your thread gives up the processor it will run forever. The sleep call is one way to give up the processor. Second, sleep() does not return as soon as the time given has expired. The argument is the MINIMUM amount of time that it waits. After that the thread that slept is put back onto the run queue and is now a candidate to be given the processor. Your other thread still has to give up the processor before it can run again and even then there may be other threads on the queue ahead of yours. So, does your thread ever give up the processor other than by dying? -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From zolotoiklo at mail.ru Sun Apr 6 11:24:43 2008 From: zolotoiklo at mail.ru (=?KOI8-R?B?+s/Mz9TPyiDrzM/O?=) Date: Sun, 6 Apr 2008 08:24:43 -0700 (PDT) Subject: =?KOI8-R?B?wc7UyS3DxczMwMzJ1M7ZxSDCwc7LySAozcHT0w==?= =?KOI8-R?B?wdbO2cUg18HL1dXNztnFIMLBzsvJKQ==?= Message-ID: <4a3e3650-8245-4421-b745-d1d6d8e6d354@a5g2000prg.googlegroups.com> ????????? ???????? ??????? <> ??????????? ??? ??????? ? ???????????? ?????????? ? ?????????????? ???????? , ????? ??? ?????????, ???????, ???????, ???????????? ?????; ?????????, ??????, ?????????, ??????, ??????? , ? ????? ??? ??????? ?????????. <> ?????????? ??? ?????????? ??????-???????, ?? ???? ???????? ?????????? ?????? ????? ? ????? ? ????, ?????????? ?? ???????, ???? ?????????? ?????????? ? ???????. ??? ???????????? ????????????? ???????? ????? <> ???? ????????????? ??????? ????????? ?????? ??? ??????, ????? ?????????? ??????? ??????? ???? ??????? ?? ???????. ???????????? ? ???? ??????? ??? ????????? ???????????? ??????????? ?????????????. ??? ???????? ???????????? ?????? ?????????? ???????? ????? ?? ???????? ????? ? ??????? ????????. ??? ?????? ???????? ?????? ???????? ???????? ?????? ?????? ???????? ???????? (??? ??????? ?????? - ?? ????? ???????????). ??? ???, ????????? ? ????????? ?????? ??????????????? ???????? ?? ???????? ????? ? ??????. ??? ??????????? ??????? ?????? ?????????? ???????, ??????? ???????, ????????? ??????????? ????. ??? ?????????? ?????? ?????? ??????????? ?????? . ??? ????????? ????-??????????? ??????? ???????????? ????????? ???????: ???????? ?????? ???????? ?? ?????????? ???????? ???? ?????????????? ? ????????? ??????????, ??? ???? ??????? ?????? ???????????. ???????? ??????????, ??? ???? ??? ??????? ?????? ??????? ?????? ?????????? ?? ??????????. ????-??????????? ????? http://shopbody.ru/chudo-banka.htm From steve at holdenweb.com Mon Apr 7 10:54:52 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 07 Apr 2008 10:54:52 -0400 Subject: Welcome to the "Python-list" mailing list In-Reply-To: References: Message-ID: Ronn Ross wrote: > This is my first post and I'm new to Python. How would someone go about > adding keywords to Python? It would be great to add support for > Esperanto keywords in the language instead of English being the only > option. > Unfortunately the resulting language would no longer be Python. You need to consider software portability: Python has been very conservative about declaring words to be "keywords" in the language, though clearly words like "def" and "class" must necessarily be part of the syntax. When you start to replace the keywords, though, your programs are no longer runnable on all Python installations, and simple transliteration fails because sometimes a keyword in one (natural) language will conflict with a programmer's choice of name(s) in another. So it's a superficially attractive idea with some really bad downside consequences. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From andre.roberge at gmail.com Tue Apr 8 21:55:11 2008 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Tue, 8 Apr 2008 18:55:11 -0700 (PDT) Subject: text adventure game problem References: <6e247b5c-a58d-4e4e-a67a-c21d36061cf0@z38g2000hsc.googlegroups.com> Message-ID: <20bb5b82-9cf2-4983-b9d0-b50c718a6b85@k10g2000prm.googlegroups.com> On Apr 8, 10:44?pm, corvettecra... at gmail.com wrote: > On Apr 8, 9:25?pm, Andr? wrote: > > > > > On Apr 8, 10:01?pm, corvettecra... at gmail.com wrote: > > > > okay, I'm having this one problem with a text adventure game. It's > > > kind of hard to explain, but I'll do my best. > > > [code] > > > > def prompt_kitchen(): > > > ? ? global gold > > > ? ? gold_taken = False > > > ? ? while True: > > > ? ? ? ? prompt_kit = raw_input('>') > > > ? ? ? ? if prompt_kit == 'examine cabinet 1' and not gold_taken: > > > ? ? ? ? ? ? print '''This cabinet has a lot of cups in it with all > > > different > > > designs and shapes. Where are the people anyway? How come there's > > > nobody here? > > > In one of the cups you find 8 gold.''' > > > ? ? ? ? ? ? gold = gold+8 > > > ? ? ? ? ? ? gold_taken = True > > > ? ? ? ? ? ? pass4() > > > ? ? ? ? elif prompt_kit == 'examine cabinet 1' and gold_taken: > > > ? ? ? ? ? ? print \ > > > ? ? ? ? ? ? ? ? ? '''This cabinet has a lot of cups in it with all > > > different > > > designs and shapes. Where are the people anyway? How come there's > > > nobody here?''' > > > ? ? ? ? ? ? pass4() > > > > def pass4(): > > > ? ? global gold > > > ? ? print 'You have', gold, 'gold' > > > ? ? pass > > > [/code] > > > > Okay, now for my problem. > > > In the above function, there's the option to examine a cabinet and get > > > 8 gold. (everyone here knows that...but I'm just trying to state my > > > problem...) > > > Unfortunately, it kind of doesn't work. > > > After the first time I 'examine cabinet 1' in my game, I get 8 gold > > > and I can't get it again. > > > But, If I leave the room and come back to it, then it's as if I had > > > never gotten the gold the first time, and I can get it again. > > > How do I fix this? > > > quick guess: define gold_taken as a global variable and initialize it > > outside of the function. > > > Warning: avoid global variables if at all possible. > > > ;-) > > Andr? > > Here's a sample code that, in fact, does work. In this code, when run, > I can only get the gold once. > > def prompt_house(): > ? ? global gold > ? ? gold_taken = False > ? ? while True: > ? ? ? ? prompt_hou = raw_input('>') > ? ? ? ? if prompt_hou == 'examine table' and not gold_taken: > ? ? ? ? ? ? print \ > ? ? ? ? ? ? ? ? ? '''There are a lot of car magazines here. > You flip through them and find 5 gold. > ''' > ? ? ? ? ? ? gold = gold+5 > ? ? ? ? ? ? gold_taken = True > ? ? ? ? elif prompt_hou == 'go west': > ? ? ? ? ? ? # this gets you out of the loop The above comment is wrong. > ? ? ? ? ? ? go_west() > ? ? ? ? ? ? # more elif choices here ... > ? ? ? ? elif prompt_hou == 'examine table' and gold_taken: > ? ? ? ? ? ? print '''There are a lot of car magazines here.''' > ? ? ? ? ? ? go_west() > def go_west(): > # just a dummy funk > ? ? global gold > ? ? print gold > ? ? pass The "pass" statement is redundant. > ? ? ? ? ? ? ? ? # test > gold = 0 > prompt_house() > > But what's the difference between this and the one that I posted? It is hard to say as you are not posting the entire code. As I indicated above, you wrote a comment indicating that a given choice was taking you out of the loop - which could only happen through a break statement. You may want to post a ("small") code sample that can be run by itself and reproduces the problem behaviour you observe. The sample you posted include infinite loops with no way to get out, so your original claim that you could leave the room and come back is highly suspicious ;-) Andr? From gagsl-py2 at yahoo.com.ar Sun Apr 20 04:12:01 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 05:12:01 -0300 Subject: Calling Java Class from python References: <608239.30549.qm@web35906.mail.mud.yahoo.com> Message-ID: En Wed, 16 Apr 2008 07:37:55 -0300, Good Z escribi?: > We have developed a website in python and we need to integrate few features of third party website. They have provided us Base64EncoderDecoder Java Class and would like us to use it to encode the data before sending it to their site and decode it when received anything from their site. > > I have no idea/knowledge of Java. Can you please guide me how can i call Java class from Python scripts? Or what is the best way to handle this condition. > > Is Base64 library provided by python is compatible to Base64EncoderDecoder Java Class? If the Java class implements Base64 as defined in RFC 3548, it should be compatible with the Python base64 module. Try with some examples, including the corner cases (empty, one byte, two bytes, three bytes, length = 3n, 3n+1, 3n+2, including bytes outside the ASCII range...) -- Gabriel Genellina From steven.p.clark at gmail.com Tue Apr 8 11:49:39 2008 From: steven.p.clark at gmail.com (Steven Clark) Date: Tue, 8 Apr 2008 11:49:39 -0400 Subject: Data structure recommendation? In-Reply-To: References: <663744510804071339g639bfdccl63de8be66fe52df1@mail.gmail.com> Message-ID: <663744510804080849n32c07461yfc3816771cfb7eca@mail.gmail.com> > bisect is definitely the way to go. You should take care with > floating point precision, though. One way to do this is to choose a > number of digits of precision that you want, and then internally to > your class, multiply the keys by 10**precision and truncate, so that > you are working with ints internal to the Foo class. Thanks for the reply. Can you explain how I could be bitten by floating point precision here? I'm familiar with how&why 1.3*3 != 3.9, etc., but I'm not sure how it applies here, or what you are gaining by converting to int. What do you guys think of this approach which uses tuples: from bisect import insort_right, bisect_right class Heavy(object): def __cmp__(self, other): return 1 heavy = Heavy() class Foo(object): def __init__(self): self.data = [] def __setitem__(self, k, v): #if k's are the same, will be sorted by v's. may or may not be desireable insort_right(self.data, (k, v)) def __getitem__(self, k): i = bisect_right(self.data, (k, heavy)) if i == 0: return None else: return self.data[i-1][1] def main(): foo = Foo() assert(foo[1.5] == None) foo[1.3] = 'a' foo[2.6] = 'b' assert(foo[1.2999] == None) assert(foo[1.3] == 'a') assert(foo[1.5] == 'a') assert(foo[2.6] == 'b') assert(foo[7.8] == 'b') foo[5.0] = 'c' assert(foo[7.8] == 'c') print('Foo checks passed.') if __name__ == '__main__': main() From john00587 at gmail.com Mon Apr 21 01:42:01 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:42:01 -0700 (PDT) Subject: boilsoft rm convertor crack Message-ID: <5e5581ca-7334-4c0a-9ef4-62fd7514542d@r9g2000prd.googlegroups.com> boilsoft rm convertor crack http://cracks.00bp.com F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Sun Apr 20 22:26:52 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 23:26:52 -0300 Subject: question about the mainloop References: <52de38c4-3d1e-4be0-9b58-5d60317f1ef7@b1g2000hsg.googlegroups.com> Message-ID: En Sun, 20 Apr 2008 20:24:04 -0300, globalrev escribi?: > in C?? java etc there is usually: > > procedure 1 > procedure 2 > procedure 3 > > main { > procedure 1 > procedure 2 > procedure 3 > } > > i dont get the mainloop() in python. i mean i have written some > programs, for example a calculator using tkinterGUI. > What you call the "mainloop" is the event loop (or message loop) used by event-driven applications as a way to dispatch all events as they happen in the system. The concept is independent of Python/C++/whatever language you choose. The key phrase is "event-driven programming": http://en.wikipedia.org/wiki/Event_driven_programming Tkinter provides an event-driven GUI framework. Simple CLI programs are not event-driven, as your pseudo example above. > if i have some functions i wanna call to run the program and i wanna > call them ina specific order and be able to call > them from each other should this just be called in the mainloop and > the mianloop then runs the "mainscript" top > to bottom over and over? If you don't want or don't require a graphical user interface, just write the functions you need and call them from the outermost section in your script. If you do require a GUI, you'll have to write the code in response to user actions: when the user clicks here, do this; when the user chooses that menu option, do that. -- Gabriel Genellina From kdoiron at sympatico.ca Tue Apr 8 11:17:46 2008 From: kdoiron at sympatico.ca (Kevin) Date: Tue, 8 Apr 2008 08:17:46 -0700 (PDT) Subject: Problem with smtplib and py2exe References: <3ff2767a-bbd8-4e0e-bbf4-3fa72bdca5e7@8g2000hsu.googlegroups.com> Message-ID: <2f783320-3364-4954-b763-1f4f3fe1f26c@y21g2000hsf.googlegroups.com> Thanks, Terry, you pointed me in the right direction with the reference to the "DEBUG". I dug out my "Learning Python" book, to read up on the debugger, and one of the things I came across was a section on IDLE's debugger. It said essentially that if you get an error that doesn't make sense when you're trying to run another program (in this case, py2exe) with IDLE, then run the program from the command line instead. I did that, and much to my surprise, I was able to generate the 'exe' that I needed. I guess the incompatibility isn't necessarily between 'py2exe' and 'smtplib' after all, but between 'py2exe' and 'IDLE'. From rahul at amplifysystems.com Mon Apr 21 02:29:01 2008 From: rahul at amplifysystems.com (Rahul Ka) Date: Mon, 21 Apr 2008 02:29:01 -0400 Subject: Python Developer, DIRECT CLIENT REQUIREMENT: Please Respond Message-ID: Hi , We have this urgent DIRECT client requirement . Please let me know if you have suitable candidates. Please send me their resume rate and contact details ASAP. TITLE: Python Developer LOCATION: Silver spring, MD DUARTION:6 Months + JOB REQUIREMENTS Strong C++ and Python experience 5 to 7 years of UNIX experience 5 to 7 years of TCP/IP network development experience 3 to 5 years of Oracle DB experience- Good to have Payment industry knowledge a plus With Warm Regards and Wishes ! RAHUL Marketing Executive AMPLIFY SYSTEMS E Mail:rahul at amplifysystems.com Phone :603-791-4428 Fax :267-284-6042 From nagle at animats.com Thu Apr 3 01:35:51 2008 From: nagle at animats.com (John Nagle) Date: Wed, 02 Apr 2008 22:35:51 -0700 Subject: Strange MySQL Problem... In-Reply-To: References: <4dc0cfea0804021236n1faafabav1699fbe45acc3c01@mail.gmail.com> Message-ID: <47f46a3e$0$36371$742ec2ed@news.sonic.net> Gabriel Genellina wrote: > En Wed, 02 Apr 2008 16:36:43 -0300, Victor Subervi > escribi?: > >> I have this code which works fine: > > "works fine"? Please check again... > The same remarks I've posted earlier apply here. In addition, you're not committing the database update. You need to do connection.commit() after updating. In general, server side programs should have a try-block wrapped around most of the program, with some code to display or log errors in some useful way. John Nagle From skanemupp at yahoo.se Thu Apr 10 04:15:19 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 01:15:19 -0700 (PDT) Subject: questions about Exceptions? Message-ID: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> is there a general philosophy as to when to use exceptions and when not to? like here: def Calc(): global nbr try: print eval(nbr) except: print "Not computable" nbr = "" i have a calculator and nbr is a string that contains '0123456789+-*/' if the string ends on +-*/ it will throw an exception(unexpected EOF). i could easily prevent the exceptions here with an if-statement, is that preferrable and why? also when u throw exceptions should u catch the speicfic one? i guess only if u want it to do soemthing special since catching only only one exception logicall would abort the program if another one is thrown? From theiviaxx at gmail.com Thu Apr 24 01:54:15 2008 From: theiviaxx at gmail.com (theiviaxx at gmail.com) Date: Wed, 23 Apr 2008 22:54:15 -0700 (PDT) Subject: python-ldap - Operations Error References: <8b35f293-fc64-4d21-a621-124c8eafde59@c65g2000hsa.googlegroups.com> Message-ID: Thanks for that last link, i'll try that tomorrow :) As for the tgolden modules, i will use that in a pinch, but it means our server has to be a windows box. just trying to keep this as open as possible :) Thanks again From sevenjp at gmail.com Wed Apr 2 11:53:09 2008 From: sevenjp at gmail.com (=?ISO-8859-1?Q?Jo=E3o_Neves?=) Date: Wed, 2 Apr 2008 08:53:09 -0700 (PDT) Subject: wsdl (soap) without code generation References: <65hi7dF2ade57U1@mid.individual.net> Message-ID: <76e1e2cd-d048-4ca5-9f6d-a1638da73b3c@u10g2000prn.googlegroups.com> On Apr 2, 3:06 pm, Thomas Guettler wrote: > Hi, > > I looked for a solution to talk to a web service which > offers its signature with a wsdl file. > > I googled for 'wsdl python' and found ZSI. > > This project uses code generation. That's something > I don't like. > > The book 'dive into python' uses SOAPpy. This looks > better since it does not generate source code. > But the last release and first release is from 2001. > > ZSI seems to have integrated SOAPpy. > > I am new to WSDL and SOAP. Do I need a WSDL parsing > routine at all? I guess my wsdl definition won't change > during the next years. So I could read the wsdl with > my eyes and make a fitting soap call... > > Any thoughts? > > -- > Thomas Guettler,http://www.thomas-guettler.de/ > E-Mail: guettli (*) thomas-guettler + de I've been using SOAPpy directly in one of my projects, and so far my experience couldn't be better. SOAPpy can handle (hand-written) WSDLs well enough for me, and so far it has given me no problems at all. From rpmuller at gmail.com Sat Apr 19 15:55:05 2008 From: rpmuller at gmail.com (Rick Muller) Date: Sat, 19 Apr 2008 12:55:05 -0700 (PDT) Subject: Frame work for simple physics web applications Message-ID: <2b0b8b6c-8086-4bf6-8f47-27bc5c9c788c@v23g2000pro.googlegroups.com> I'd like to use my webserver to distribute some simple python physics apps. Ideally, I'd like to use some simple form to input a few pieces of data, call a python program, and return some image from a plot or some other rendering. This is easy to do using CGI, but I was wondering whether anyone on the list could recommend that would look a little more polished and professional. Let's say I want to input a wave vector k, and then input a plot of sin(k*x). I would like to have a simple form input for k, and then display an image of the plot. What I'm doing is a little more varied than this, but the common thread is that in each application I need to input several pieces of data and then display some image. I can probably think of 20 different applications right off the bat that I'd like to deploy. The idea behind this is to put together some simple toy models for quantum computing qubits that my experimental collaborators can play with without having to install Python, NumPy, and MatPlotLib themselves. (I understand, of course, that such an installation might be "good for them", but I'd rather not fight that battle just now.) I could, of course, write a Jython applet for this, but this would require my re-learning how to use the Java API, and it has been a few years for me. Do any of the AJAX frameworks for Python compare in simplicity to writing a simple CGI script? I've been impressed with web.py, since it seems pretty easy to use, but I would go to the trouble of learning one of the bigger frameworks if they would provide a more elegant solution. My web skillz are obviously several years out of date, so I'd like some guidance on the best way to update them. Thanks in advance, Rick From tjreedy at udel.edu Sun Apr 20 23:54:58 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 20 Apr 2008 23:54:58 -0400 Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> <48a1d10c-87cb-43c3-83f4-9c331fc1d818@m1g2000pre.googlegroups.com> Message-ID: "Dan Bishop" wrote in message news:48a1d10c-87cb-43c3-83f4-9c331fc1d818 at m1g2000pre.googlegroups.com... | We wouldn't even need that. Just a new source encoding. Then we | could write: | | # -*- coding: end-block -*- Ummm.. source encoding refers to how unicode chars/codepoints are represented as bytes. This syntax is copied from emacs and uses standard terms. What would you expect an encoding aware editor to do with something like the above? From kveretennicov at gmail.com Wed Apr 2 13:45:07 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Wed, 2 Apr 2008 20:45:07 +0300 Subject: xlrd and cPickle.dump In-Reply-To: <12375df7-387d-424d-84a8-76beb664ae47@59g2000hsb.googlegroups.com> References: <34e62ddb-477f-4a99-97a5-21a7b148d244@e67g2000hsa.googlegroups.com> <47f22a41@news.mel.dft.com.au> <0d46a213-9f95-43b5-835b-d74d8403626b@c19g2000prf.googlegroups.com> <6acbf9b4-161b-47db-9a91-b2448ee63c34@c26g2000prf.googlegroups.com> <12375df7-387d-424d-84a8-76beb664ae47@59g2000hsb.googlegroups.com> Message-ID: <4660fe300804021045r676ddf8au623b0d1cc2595c20@mail.gmail.com> On Wed, Apr 2, 2008 at 5:23 PM, wrote: > Still no luck: > > Traceback (most recent call last): > File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework > \scriptutils.py", line 310, in RunScript > exec codeObject in __main__.__dict__ > File "C:\text analysis\pickle_test2.py", line 13, in ? > cPickle.dump(Data_sheet, pickle_file, -1) > PicklingError: Can't pickle : attribute lookup > __builtin__.module failed > > My code remains the same, except I added 'wb' and the -1 following > your suggestions: > > import cPickle,xlrd, sys > > print sys.version > print xlrd.__VERSION__ > > data_path = """C:\\test\\test.xls""" > pickle_path = """C:\\test\\pickle.pickle""" > > book = xlrd.open_workbook(data_path) > Data_sheet = book.sheet_by_index(0) > > pickle_file = open(pickle_path, 'wb') > cPickle.dump(Data_sheet, pickle_file, -1) > pickle_file.close() > FWIW, it works here on 2.5.1 without errors or warnings. Ouput is: 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] 0.6.1 ... > My code does this, except sort returns None, which is strange. list.sort() is documented to return None. See sorted(). -- kv -------------- next part -------------- An HTML attachment was scrubbed... URL: From wizzardx at gmail.com Sun Apr 27 14:18:42 2008 From: wizzardx at gmail.com (David) Date: Sun, 27 Apr 2008 20:18:42 +0200 Subject: design choice: multi-threaded / asynchronous wxpython client? In-Reply-To: <6fd9f065-630c-44ec-b8ca-348b0eabb3d7@y18g2000pre.googlegroups.com> References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> <6fd9f065-630c-44ec-b8ca-348b0eabb3d7@y18g2000pre.googlegroups.com> Message-ID: <18c1e6480804271118v129838b9v2d8a4c82b8fca612@mail.gmail.com> > Date is the time of the server response and not last data update. Data > is definitely time of server response to my request and bears no > relation to when the live XML data was updated. I know this for a fact > because right now there is no active race meeting and any data still > available is static and many hours old. I would not feel confident > rejecting incoming data as duplicate based only on same content length > criterion. Am I missing something here? It looks like the data is dynamically generated on the server, so the web server doesn't know if/when the data changed. You will usually see this for static content (images, html files, etc). You could go by the Cache-Control line and only fetch data every 30 seconds, but it's possible for you to miss some updates this way. Another thing you could try (if necessary, this is a bit of an overkill) - download the first part of the XML (GET request with a range header), and check the timestamp you mentinoed. If that changed then re-request the doc (a download resume is risky, the XML might change between your 2 requests). David. From fetchinson at googlemail.com Fri Apr 11 19:53:12 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Fri, 11 Apr 2008 16:53:12 -0700 Subject: matplotlib in fedora 8, png format and easy_instal failure on 64bit machine Message-ID: Hi folks, I have a number of issues with matplotlib and was wondering if any of you had similar experiences: 1. I was trying to use the stock matplotlib package that comes with fedora 8, python-matplotlib-0.90.1-2.fc8 for saving graphs in png format. This failed, because the written files are all empty. The unix 'file' utility reports that the file is actually png but when viewed in any image viewer the image is just plain white. Jpg format works though. 2. I tried grabbing the most recent matplotlib version via easy_install but it failed compiling it and as far as I could see the reason was that it tried to use the 32bit libraries instead of the 64bit ones (my machine is a core 2 duo). Does anyone of you use matplotlib on a 64bit machine for writing png's? Which version do you use? Cheers, Daniel From carlwuhwdmckay at gmail.com Sat Apr 26 09:29:11 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:29:11 -0700 (PDT) Subject: serial numbers crack Message-ID: serial numbers crack http://cracks.00bp.com F R E E C R A C K S From sierra9162 at gmail.com Wed Apr 16 11:26:48 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:26:48 -0700 (PDT) Subject: kate hudson pic Message-ID: <93b74cb1-35d1-4877-9416-8910122df0e0@8g2000hsu.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From zzvladimir at gmail.com Tue Apr 8 05:02:00 2008 From: zzvladimir at gmail.com (Vladimir Kropylev) Date: Tue, 8 Apr 2008 13:02:00 +0400 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. In-Reply-To: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> Message-ID: yes, ths is known problem. I can just recomend you to use Linux or FreeBSD, though cygwin maybe also possible 2008/4/8, subhabrata.iisc at hotmail.com : > I am using Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v. > 1310 32 bit (Intel)] on win32 with IDLE 1.2.1 > My O/S is Windows XP SP2 I use 512 MB RAM. > I am encountering the following problems: > (i) a1=1 > a2=2 > a3=a1+a2 > print a3 > # The result is coming sometimes as 3 sometimes as vague numbers. > > (ii) x1="Bangalore is called the Silicon Valley of India" > x2="NewYork" > x3=x1.find(x2) > print x3 > # The result of x3 is coming as -1 as well as +ve numbers. > > (iii) I have been designing one crawler using "urllib". For crawling > one web page it is perfect. But when I am giving around 100 URLs by > and their links and sublinks the IDLE is not responding. Presently I > have been running with 10 URLs but can't it be ported? > > (iv) I have designed a program with more than 500 if elif else but > sometimes it is running fine sometimes it is giving hugely erroneous > results, one view of the code: > elif a4==3: > print "YOU HAVE NOW ENTERED THREE WORDS" > if a3[0] not in a6: > if a3[1] not in a6: > if a3[2] not in a6: > print "a3[0] not in a6, a3[1] not in a6, a3[2] not > in a6" > elif a3[2] in a6: > print "a3[0] not in a6, a3[1] not in a6, a3[2] in > a6" > else: > print "NONE3.1" > elif a3[1] in a6: > if a3[2] not in a6: > print "a3[0] not in a6, a3[1] in a6, a3[2] not in > a6" > elif a3[2] in a6: > print "a3[0] not in a6,a3[1] in a6, a3[2] in a6" > else: > print "NONE3.2" > else: > print "NONE3.3" > elif a3[0] in a6: > if a3[1] not in a6: > if a3[2] not in a6: > print "a3[0] in a6, a3[1] not in a6, a3[2] not in > a6" > elif a3[2] in a6: > print "a3[0] in a6, a3[1] not in a6, a3[2] in a6" > else: > print "NONE3.4" > elif a3[1] in a6: > if a3[2] not in a6: > print "a3[0] in a6, a3[1] in a6, a3[2] not in a6" > elif a3[2] in a6: > print "a3[0] in a6, a3[1] in a6, a3[2] in a6" > else: > print "NONE3.5" > else: > print "NONE3.6" > else: > print "NONE3.7" > Why it is behaving like that? > If someone can help me. > Best Regards, > Subhabrata Banerjee, > Indian Institute of Science, > Bangalore, > India. > > -- > http://mail.python.org/mailman/listinfo/python-list > From joe.p.cool at googlemail.com Tue Apr 15 18:28:31 2008 From: joe.p.cool at googlemail.com (Joe P. Cool) Date: Tue, 15 Apr 2008 15:28:31 -0700 (PDT) Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> <47ffee86$0$6838$2d805a3e@textnews.eweka.nl> <15e5c81b-0b21-44f0-9282-0d1495bc6bb3@z24g2000prf.googlegroups.com> <480011b7$0$28883$c83e3ef6@nn1-read.tele2.net> Message-ID: On 12 Apr., 03:34, baalbek wrote: > Delphi/Object Pascal simply sucks big time! I disagree. Delphi/Object Pascal with the VCL (Visual Component Library) is one of the most sophisticated IDEs ever, even better than Qt IMO. The only drawback is that it is Windows only. > No real control of your GUI design with Delphi, just a lot of point and > click Wrong. It does have a GUI builder - a very good one - and you can do point and click creation of GUIs (nothing wrong with that) but you can also do pure text editor code only programming with it. >?(did anyone mention waste of one's life?), and don't get me started on that > primitive, complete utter waste of language called Object Pascal! I'm no big Pascal fan either but Object Pascal has a decent string library and better container literals than C/C++ and Java. The language itself is a matter of taste and I don't waste my time discussing it. > Python/wxPython/Glade == real programmer's toolkit > > Object Pascal/Delphi == the hobbyist/beginner's toolkit I'm pretty sure that there are more professional software products written in Delphi than in wxPython. From s0suk3 at gmail.com Thu Apr 17 13:02:55 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 10:02:55 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <1952579a-3cfb-44ea-92aa-658daa64aee4@a70g2000hsh.googlegroups.com> Message-ID: <564dd82b-8670-4ead-a3c8-a22b30a3eb73@m73g2000hsh.googlegroups.com> On Apr 17, 11:46 am, Arnaud Delobelle wrote: > > Why not do something like: > > class RequestHeadersManager: > > def __init__(self, string): > self._fields = {} > # Populate self.fields with fields defined in 'string' > > def __getitem__(self, fieldname): > return self._fields.get(fieldname, None) > > This way you don't need to prebind all possible fields to None, and a > field is accessible by its actual name, which should be easier to > remember than an identifier derived from a field name. Moreover you > can more easily do some group manipulation of fields (e.g. print them > all > > def print_fields(self): > for name, value in self._fields.iteritems(): > print "%s: %s" % (name, value) > ) > I do it with all the separate variables mainly for performance. If I had the headers in a dict, I'd be looking up a string in a list of strings (the keys of the dict) everytime I check for a header. Not that that's going to take more that 0.1 seconds, but the program is still small and simple. As it gets bigger, more features are gonna slow things down. From kyosohma at gmail.com Sun Apr 27 15:42:34 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Sun, 27 Apr 2008 12:42:34 -0700 (PDT) Subject: Installed python 2.5 over 2.4 and lost installed packages References: <6c77d0e5-f387-449d-9147-d7aefa3d2735@l64g2000hse.googlegroups.com> Message-ID: <361ca6be-9764-4cff-bd2e-b5f992d5feb7@8g2000hse.googlegroups.com> On Apr 27, 8:15?am, ja... at reggieband.com wrote: > Hi all, > > I recently updated os x from python 2.4 to 2.5 (from python.org) and > in doing so I lost my old python path entries. Python 2.4 was > installed using fink. ?Now when I do: > > import sys > print sys.path > > my old site-packages directory is not within it (the 2.4 one). > > So what is the right thing to do in this situation? ?It would be a > pain to find and re-install each of the packages. ?Is it ok to add my > old site-packages directory to the sys.path? ?What is the best way to > do so (e.g. using .pth files or PYTHONPATH or other)? ?Is cp'ing the > files from one place to another safe or advisable? > > Any help on best practices appreciated. > > James. As long as the Python extensions or packages are pure ones, then copying them over shouldn't hurt anything. If you have some that have C/C++ links (such as PIL or pywin32), then you'll need to reinstall those manually. Mike From bskaplan14 at yahoo.com Thu Apr 17 13:04:11 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Thu, 17 Apr 2008 10:04:11 -0700 (PDT) Subject: Importing My Own Script Message-ID: <69481.40675.qm@web39203.mail.mud.yahoo.com> It might be something in mod python. Try asking on their mailing list. ----- Original Message ---- From: Victor Subervi To: Ben Kaplan Cc: python-list at python.org Sent: Thursday, April 17, 2008 10:47:34 AM Subject: Re: Importing My Own Script On Thu, Apr 17, 2008 at 8:52 AM, Ben Kaplan wrote: If x and y are in the same directory, just do "import x". If not, add the directory containing x to sys.path. Then, "import x" should work. Well, now that?s what I thought! But no, it doesn?t work! Both scripts are in the same folder. Here?s the error: [Thu Apr 17 07:45:50 2008] [error] [client 190.166.0.245] PythonHandler mod_python.cgihandler: File "/var/www/vhosts/livestocksling.com/httpdocs/bre/test.py", line 3, in ?\n import test2 [Thu Apr 17 07:45:50 2008] [error] [client 190.166.0.245] PythonHandler mod_python.cgihandler: ImportError: No module named test2 I?m running through Plesk, if that makes a difference. TIA, Victor ----- Original Message ---- From: Victor Subervi To: python-list at python.org Sent: Thursday, April 17, 2008 9:45:10 AM Subject: Importing My Own Script Hi: How do I import my own script from a second script? That is, I have script x and I want to import script y. How? TIA, Victor Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From hall.jeff at gmail.com Tue Apr 15 14:19:28 2008 From: hall.jeff at gmail.com (hall.jeff at gmail.com) Date: Tue, 15 Apr 2008 11:19:28 -0700 (PDT) Subject: Preferred method for "Assignment by value" References: <8562becb-9fef-415d-9640-05ef80123596@a5g2000prg.googlegroups.com> Message-ID: <534f02b3-1eda-4332-96ae-3db3d4b4f44a@s33g2000pri.googlegroups.com> I think the fundamental "disconnect" is this issue of mutability and immutability that people talk about (mainly regarding tuples and whether they should be thought of as static lists or not) Coming from VBA I have a tendency to think of everything as an array... So when I create the following test=[1,2],[3,4],[5,6] I'm annoyed to find out that I can change do the following test[1][1] = 3 but i can't do test[1] = [3,3] and so I throw tuples out the window and never use them again... The mental disconnect I had (until now) was that my original tuple was in affect "creating" 3 objects (the lists) within a 4th object (the tuple)... Previously, I'd been thinking of the tuple as one big object (mentally forcing them into the same brain space as multi-dimensional arrays in VBA) This was a nice "aha" moment for me... From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 24 07:15:00 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 24 Apr 2008 13:15:00 +0200 Subject: Python development tools In-Reply-To: <87fxtcnvj7.fsf@physik.rwth-aachen.de> References: <09992de9-39fa-4ee6-8009-35732f3433fb@y21g2000hsf.googlegroups.com> <87fxtcnvj7.fsf@physik.rwth-aachen.de> Message-ID: <48106ba0$0$11087$426a34cc@news.free.fr> Torsten Bronger a ?crit : > Hall?chen! > > bruno.desthuilliers at gmail.com writes: > >> On 23 avr, 19:39, "wongjoek... at yahoo.com" >> wrote: >> >>> Are there any completely free developent tools for python scripts >>> like IDLE. I have used IDLE , but I want to try out others >>> also. I saw stuff like PyCrust, but I don't see that it can run >>> the script as well. >> emacs + python-mode (the one from Python, not the horror that >> ships with recent emacs versions) > > What's so bad about it? I'd have to reinstall it to tell you exactly, but I do remember something really bad wrt/ the embedded python-shell, which is one the very strength of the emacs+python-mode combo. > I just installed python-mode (is this the one with the "py-" > prefixes?), It's the one with ;; Copyright (C) 1992,1993,1994 Tim Peters > and it ends multi-line strings at single quotes. it chokes on unbalanced single quotes in triple-single-quoted strings, and on unbalanced double-quotes in triple-double-quoted strings, yes. Given that I never use triple-single-quoted strings (and don't remember having seen such a thing in the thousands of third-part .py files I've read so far), I'd qualify this as at most a very minor annoyance. Not having proper python-shell and pdb integration is wwwwaaaayyyy more annoying IMHO. From george.sakkis at gmail.com Sun Apr 20 18:59:01 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Sun, 20 Apr 2008 15:59:01 -0700 (PDT) Subject: Nested lists, simple though References: <8788db32-30b4-4cae-ab5a-bf6051249294@a9g2000prl.googlegroups.com> Message-ID: <8f3afcd8-e679-44c3-a1ff-86ccec140979@a1g2000hsb.googlegroups.com> On Apr 20, 6:50?pm, Jason Scheirer wrote: > On Apr 20, 3:25?pm, Zethex wrote: > > > > > Im a bit new to python. ?Anyway working on a little project of mine and i > > have nested lists > > > ie > > > Answer = [['computer', 'radeon', 'nvidia'], ['motherboard', 'asus']] > > > and so forth.., > > Anyway the amount of [[]] do increase over time. ?Im just wondering is there > > a simple way to add these together so they become 1 simple list, so it would > > be ['computer'....'asus'] etc without the nested list. ?Its random the > > amount each time so i cant just go a[0]+a[1]. > > Thank you if you can help > > -- > The first idea that comes to mind is reduce(lambda x, y: x + y, > list_of_lists, []) s/first/worst/ There, I fixed it for you. From nospam at here.com Sun Apr 27 18:10:49 2008 From: nospam at here.com (Dennis) Date: Sun, 27 Apr 2008 23:10:49 +0100 Subject: A small and very basic python question Message-ID: Could anyone tell me how this line of code is working: filter(lambda x: x in string.letters, text) I understand that it's filtering the contents of the variable text and I know that lambda is a kind of embedded function. What I'd like to know is how it would be written if it was a normal function. From paulgeeleher at gmail.com Tue Apr 1 11:13:26 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Tue, 1 Apr 2008 08:13:26 -0700 (PDT) Subject: Copy Stdout to string References: Message-ID: <67533661-fe7b-407b-a406-040eddb417cb@e10g2000prf.googlegroups.com> On Apr 1, 3:03 pm, sophie_newbie wrote: > Hi, I'm wondering if its possible to copy all of stdout's output to a > string, while still being able to print on screen. I know you can > capture stdout, but I still need the output to appear on the screen > also... > > Thanks! I found this, it pretty much does the job, easily modified to write to a variable instead of a file: http://www.answermysearches.com/python-how-to-print-to-screen-and-a-file-at-the-same-time/52/ From http Tue Apr 1 12:17:51 2008 From: http (Paul Rubin) Date: 01 Apr 2008 09:17:51 -0700 Subject: Homework help References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> Message-ID: <7xfxu5ft1s.fsf@ruckus.brouhaha.com> bobby.connor at gmail.com writes: > I don't necessarily want the answers, but need help on how to approach > it/the steps i need to solve the problems What parts are you having difficulty with? Are there some course materials and have you read them yet? From sam at mas.pl Wed Apr 2 11:54:59 2008 From: sam at mas.pl (sam) Date: Wed, 02 Apr 2008 17:54:59 +0200 Subject: wsdl (soap) without code generation In-Reply-To: <65hi7dF2ade57U1@mid.individual.net> References: <65hi7dF2ade57U1@mid.individual.net> Message-ID: Thomas Guettler napisa?(a): > I googled for 'wsdl python' and found ZSI. This is current solution, but it is quite new and actively developed, so newer versions are sometimes not compatibile with old ones. So if you use distribution provided packages (eg Debian) you can have troubles after system upgrade and regenerating stub. > This project uses code generation. That's something > I don't like. But after you have generated files it is easy to use that tool -- just call a function and grab result. With ZSI you don't have to generate code, but you will have to do more coding to invoke a call. > I am new to WSDL and SOAP. Do I need a WSDL parsing > routine at all? I guess my wsdl definition won't change > during the next years. So I could read the wsdl with > my eyes and make a fitting soap call... No -- you don't have to read WSDL at all! Just make somebody else do it for you. SOAP is just about sending and receiving text, but you have to keep that properely formated. You don't have to use automation of WSDL and XML parsing. For example visit: http://soapclient.com/soaptest.html put your wsdl file address, click Retrieve. Then fill forms and see what is response and reply -- they will be your templates. Then write simple Python programs with socks sending and receiving templates on http (or https) port. If you gave me your wsdl file address I could probably give more precise help. Here goes example: http://www.ibm.com/developerworks/library/ws-pyth5/#code3 From michael at stroeder.com Fri Apr 4 06:03:27 2008 From: michael at stroeder.com (=?ISO-8859-15?Q?Michael_Str=F6der?=) Date: Fri, 04 Apr 2008 12:03:27 +0200 Subject: object-relational mappers In-Reply-To: References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> Message-ID: M.-A. Lemburg wrote: > On 2008-04-01 22:40, Aaron Watters wrote: >> I've been poking around the world of object-relational >> mappers and it inspired me to coin a corellary to the >> the famous quote on regular expressions: >> >> "You have objects and a database: that's 2 problems. >> So: get an object-relational mapper: >> now you have 2**3 problems." >> >> That is to say I feel that they all make me learn >> so much about the internals and features of the >> O-R mapper itself that I would be better off rolling >> my own queries on an as-needed basis without >> wasting so many brain cells. >> >> comments? > > I fully agree :-) BTW: Some people implemented O/R mappers above python-ldap. All implementations I saw up to now are falling short regarding the complexity of the LDAP attribute sub-types, the syntactical rules for attribute type descriptive names and attribute name aliasing. So first a developer has also to evaluate whether a O/R mapper is really complete before using it. Ciao, Michael. From deets at nospam.web.de Thu Apr 10 09:47:28 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 10 Apr 2008 15:47:28 +0200 Subject: Code-convention checker and possibly reformatter Message-ID: <666k4cF2iltl5U1@mid.uni-berlin.de> Hi, my new company requires me to adhere to some coding conventions - order of imports, amount of whitespace between method definitions and such stuff. Because I'm a lazy a**, I'd like to have some automatic checker that will ensure that I'm following the conventions. Now I know & use pylint - but the docs are sparse, and so I wonder if and how one writes plugins for it. Of course I also dabbled with tokenize and compiler - but those two either are to lowlevel or already to abstract (the former forces me to re-create trees on my own, the latter throws away to much data, e.g. comments and whitespace) So - any suggestions how to proceed? Diez From deets at nospam.web.de Tue Apr 29 18:40:05 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 30 Apr 2008 00:40:05 +0200 Subject: timeout In-Reply-To: <1a9b19bf-5075-4bce-812d-5516d3a4e454@b9g2000prh.googlegroups.com> References: <1a9b19bf-5075-4bce-812d-5516d3a4e454@b9g2000prh.googlegroups.com> Message-ID: <67pme5F2p5fhgU2@mid.uni-berlin.de> maehhheeyy schrieb: > Hi, > > I was just wondering if there was such thing as a timeout module. time.sleep? Diez From victorsubervi at gmail.com Tue Apr 29 08:57:37 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Tue, 29 Apr 2008 07:57:37 -0500 Subject: Goodbying Spaces In-Reply-To: <200804251729.29976.kyrie@uh.cu> References: <4dc0cfea0804251401p3ab96fddy99452f5a3255acde@mail.gmail.com> <200804251729.29976.kyrie@uh.cu> Message-ID: <4dc0cfea0804290557j127de13frbca4c81a2447c669@mail.gmail.com> On Fri, Apr 25, 2008 at 4:29 PM, Luis Zarrabeitia wrote: > > Whats the result of using id.strip()?: > > In [1]: " asdfasdf ".strip() > Out[1]: 'asdfasdf' > > It should work, I guess... It didn?t for some reason. That was the first thing I tried. > > > Btw, you can write your code without using len in a cleaner way: > > try: > if id[0] == ' ': > id = id[1:] # Note this slice notation... > except: > pass > > try: > if id[-1] == ' ': # id[-1] would be the last character > id = id[:-1] # Again, a slice with only one argument > except: > pass Oh, yeah. Forgot about that. Thanks! Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From dotancohen at gmail.com Sat Apr 5 11:58:51 2008 From: dotancohen at gmail.com (Dotan Cohen) Date: Sat, 5 Apr 2008 18:58:51 +0300 Subject: Learning curve for new database program with Python? In-Reply-To: References: Message-ID: <880dece00804050858l34c67f2ds58773cb7fd2e0cca@mail.gmail.com> On 05/04/2008, Jetus wrote: > I have a need for a database program. I downloaded the db2 from ibm, > and reviewed some of the documentation. > > My question is, what is the easiest program for me to try to learn. I > will be creating a database of about 25,000 records, it will be > relational. I am a beginner Python programmer, and need a database > solution that is easy to grasp. I played with sql, > and found that very difficult, if not overly cumbersome. > > A database that could work with Django would be very interesting to > look at as well.. > > Any suggestions out there? > I haven't used _any_ database with Python, but for PHP I found sqlite to be very easy to work with. Take a look at it. Dotan Cohen http://what-is-what.com http://gibberish.co.il ?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? From spamgrinder.trylater at gmail.com Thu Apr 17 10:52:15 2008 From: spamgrinder.trylater at gmail.com (AlFire) Date: Thu, 17 Apr 2008 09:52:15 -0500 Subject: why objects of old style classes are instances of 'object' Message-ID: <4807641F.8030209@gmail.com> Hi, Q: from the subject, why objects of old style classes are instances of 'object'? >>> class a():pass >>> A=a() >>> isinstance(A,object) True I would expect False Thx, Andy From victorsubervi at gmail.com Wed Apr 30 12:02:10 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 30 Apr 2008 11:02:10 -0500 Subject: Custom Classes? Message-ID: <4dc0cfea0804300902o7493dab2m35999b5b59deace4@mail.gmail.com> Hi; I have the following code which produces a file every time I need to display an image from MySQL. What garbage! Surely, python is capable of better than this, but the last time I asked for help on it, I got no responses. Is this only possible with custom classes? Please, give me some guidance here! try: w += 1 getpic = "getpic" + str(w) + ".py" try: os.remove(getpic) except: pass code = """ #!/usr/local/bin/python import cgitb; cgitb.enable() import MySQLdb import cgi import sys,os sys.path.append(os.getcwd()) from login import login user, passwd, db, host = login() form = cgi.FieldStorage() picid = int(form["id"].value) x = int(form["x"].value) pics = {1:'pic1',2:'pic1_thumb',3:'pic2',4:'pic2_thumb',5:'pic3',6:'pic3_thumb',7:'pic4',8:'pic4_thumb',\ 9:'pic5',10:'pic5_thumb',11:'pic6',12:'pic6_thumb'} pic = pics[x] print 'Content-Type: text/html' db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor= db.cursor() sql = "select " + pic + " from products where id='" + str(picid) + "';" cursor.execute(sql) content = cursor.fetchall()[0][0].tostring() cursor.close() print 'Content-Type: image/jpeg' print print content """ script = open(getpic, "w") script.write(code) print '' % pic print '

\n' % (getpic, d, y) TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From ptmcg at austin.rr.com Thu Apr 10 11:21:05 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Thu, 10 Apr 2008 08:21:05 -0700 (PDT) Subject: Stripping scripts from HTML with regular expressions References: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: <15ae3307-3019-4faa-9cb4-c2248a5eaeba@l64g2000hse.googlegroups.com> On Apr 9, 2:38?pm, Michel Bouwmans wrote: > Hey everyone, > > I'm trying to strip all script-blocks from a HTML-file using regex. > > I tried the following in Python: > > testfile = open('testfile') > testhtml = testfile.read() > regex = re.compile(']*>(.*?)', re.DOTALL) > result = regex.sub('', blaat) > print result > > This strips far more away then just the script-blocks. Am I missing > something from the regex-implementation from Python or am I doing something > else wrong? > > greetz > MFB This pyparsing-based HTML stripper (http://pyparsing.wikispaces.com/ space/showimage/htmlStripper.py) strips *all* HTML tags, scripts, and comments. To pare down to just stripping scripts, just change this line: firstPass = (htmlComment | scriptBody | commonHTMLEntity | anyTag | anyClose ).transformString(targetHTML) to: firstPass = scriptBody.transformString(targetHTML) -- Paul From gagsl-py2 at yahoo.com.ar Tue Apr 8 00:53:44 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 08 Apr 2008 01:53:44 -0300 Subject: ImportError: No module named MySQLdb References: <12b075a10804072035j42c85d4m3e4b45778d9697c4@mail.gmail.com> Message-ID: En Tue, 08 Apr 2008 00:35:29 -0300, syed mehdi escribi?: > I have been working in python from some time now, > while writing a python script i used: import MySQLdb in my script to do > some > database related operations. > When i tried to execute the same script on another system it gave me an > error as: > "ImportError: No module named MySQLdb" > though mysqldb was already installed on that system, and python 2.5.2 was > present on that machine. > i have tried uninstalling and installing of mysql again and again but to > no > avail. MySQL (the database engine) is not the same as MySQLdb (the Python package). You have to download and install it: http://mysql-python.sourceforge.net/ -- Gabriel Genellina From skanemupp at yahoo.se Sat Apr 19 19:54:29 2008 From: skanemupp at yahoo.se (globalrev) Date: Sat, 19 Apr 2008 16:54:29 -0700 (PDT) Subject: Bigger projects, including files? Message-ID: if i have a larger project and want to divide my program into several files, how do i include these files in the mainprogram? using import someprojectfile doesnt work because import is for site- packages right and i dont want to put all my files in that folder. so how do i do it? From skanemupp at yahoo.se Sat Apr 19 15:43:21 2008 From: skanemupp at yahoo.se (globalrev) Date: Sat, 19 Apr 2008 12:43:21 -0700 (PDT) Subject: Tkinter, getting canvas-object, how? References: <4d5c6911-7728-4dad-8d8d-7a862bf78d70@k13g2000hse.googlegroups.com> <4814820b-a3d2-44c1-9db4-0069463f079f@a23g2000hsc.googlegroups.com> Message-ID: <91ec0a69-767c-406b-8a41-44f8989e8eba@e39g2000hsf.googlegroups.com> On 19 Apr, 10:15, Rafa? Wysocki wrote: > skanem... at yahoo.se napisa?(a): > > > > > so i load a gif onto a canvas and when i click the canvs i want to get > > the color of the pixel that is clicked. > > so i need to ge the object im clicking. > > i was told in another thread to use find_withtag or find_closest but > > it is not working, maybe im using the > > method on the wrong object. > > how do i do this? > > and how do i then get specifics about that object, ie the pixel-color? > > > Exception in Tkinter callback > > Traceback (most recent call last): > > File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ > > return self.func(*args) > > File "C:\Users\saftarn\Desktop\pythonkod\mapexperiments > > \mapgetobject.py", line 17, in callback > > undermouse=find_closest(master.CURRENT) > > NameError: global name 'find_closest' is not defined > > > from Tkinter import * > > > master = Tk() > > > w = Canvas(master, width=400, height=625) > > w.pack(expand = YES, fill = BOTH) > > > mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\Maps\provinces-of- > > sweden.gif') > > w.create_image(30, 30, image = mapq, anchor = NW) > > > def key(event): > > print "pressed", repr(event.char) > > > def callback(event): > > clobj=event.widget > > ## undermouse=find_withtag(master.CURRENT) > > undermouse=find_closest(master.CURRENT) > > print repr(undermouse) > > > w.bind("", key) > > w.bind("", callback) > > w.pack() > > > mainloop() > > from Tkinter import * > > master = Tk() > > w = Canvas(master, width=400, height=625) > w.pack(expand = YES, fill = BOTH) > > mapq = PhotoImage(file = 'img.gif') > _id = w.create_image(0, 0, image = mapq, anchor = NW) > > objects = {} # map id to object > objects[_id] = mapq > > def key(event): > print "pressed", repr(event.char) > > def callback(event): > x, y = w.canvasx(event.x), w.canvasy(event.y) # Translates a > window x,y coordinates to a canvas coordinate > _id = w.find_closest(x,y)[0] # Returns tuple containing the object > id > obj = objects[_id] # Finds object with given id > print 'color: %s' % obj.get(int(x), int(y)) > > w.bind("", key) > w.bind("", callback) > w.pack() > > mainloop() ty very much. however i dont get the %s really. is % a symbol and then replaced by obj.get-values? anyway when clicked i get 3values, but there is intx and inty only. where does the 3rd value come from and how do i refer to it? From steve at holdenweb.com Sat Apr 19 04:25:01 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 19 Apr 2008 04:25:01 -0400 Subject: python setup.py install on Vista? In-Reply-To: References: Message-ID: Patrick Mullen wrote: > On Fri, Apr 18, 2008 at 4:29 PM, globalrev wrote: >> type "python setup.py install" >> >> that is used in most "addons" for python. >> >> well using windows vista, where the h*** am i supposed to type this? >> >> if it is not doable in windows, what do i have to do instead? just >> clicking the setup.py-file never works. >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > There are many problems with this on Vista. First, you need a command > prompt. You can go to "start menu->all programs->accessories->command > prompt" for this. But to install things in vista, you will likely > need to be an administrator, and windows won't automatically ask for > permission when typing "python setup.py install." So instead of > clicking on command prompt, right click it, and choose "run as > administrator". A faster way is to type "cmd" in the start menu > search area, and wait for "cmd.exe" to come up. Run that as > administrator. A quicker way to get an adminstrator command tool is to bring up the run dialog with Windows-R, enter "cmd" then hit CTRL/SHIFT/Enter. > > Once you have a command prompt, you can "cd" into the directory where > you want to install the extension. Then, "c:\python25\python setup.py > install" should work. If you are using 2.4 or 3.0, it would be > "c:\python24\python" or "c:\python30\python" etc. If you installed > python somewhere other than the default folder, then you will need to > enter that path. > > To make this process easier, when I want to install an extension, I > usually create a .bat file in the extension folder. Right click in > the folder and choose new->text file. Rename the file to > "install.bat". Right click the file and go to edit. Enter > "c:\python25\python setup.py install" into the file and save. Then > right click and choose run as administrator, and it should install. > You might add a "pause" line in the bat file as well, so that if it > has a problem installing, it will stay open so you can see the output. > > Your best solution is to uninstall vista and use linux :) You're right, Vista's a pain. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From tjreedy at udel.edu Mon Apr 7 22:28:00 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 7 Apr 2008 22:28:00 -0400 Subject: A funnily inconsistent behavior of int and float References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com><1d11875a-470a-489f-910a-b420a145eb61@a1g2000hsb.googlegroups.com><11b4793c-04cc-4898-99a8-8418d237de3e@2g2000hsn.googlegroups.com><1255ee3e-cc1e-4ae8-96f3-5f942c389c49@t54g2000hsg.googlegroups.com> Message-ID: "Mark Dickinson" wrote in message | Excellent! | It looks to me as though this covers everything. I'm tempted to | quibble about exact wordings, but probably the most productive thing to do | would be just to submit this to bugs.python.org and then let Georg Brandl | work his magic on it. :-) http://bugs.python.org/issue2580 tjr From musiccomposition at gmail.com Tue Apr 22 22:45:03 2008 From: musiccomposition at gmail.com (Benjamin) Date: Tue, 22 Apr 2008 19:45:03 -0700 (PDT) Subject: Explicit variable declaration References: Message-ID: <1506f165-7f86-4dc7-aa29-6488eda9ae7f@l64g2000hse.googlegroups.com> On Apr 22, 7:39 pm, "Filip Gruszczy?ski" wrote: > Hello everyone! > > It is my first message on this list, therefore I would like to say > hello to everyone. I am fourth year student of CS on the Univeristy of > Warsaw and recently I have become very interested in dynamically typed > languages, especially Python. > > I would like to ask, whether there is any way of explicitly declaring > variables used in a function? While I am pretty sure, that there is no > such way in the language itself, I would like to know, whether there > are any third-party tools to do that. This would be very useful for me > during development, so I am looking for such a tool. You mean the type? Not in 2.x, but in 3.x, there are function annotations: def a_function(arg1: int, arg2: str) -> None: pass > > -- > Filip Gruszczy?ski From bj_666 at gmx.net Wed Apr 9 15:16:41 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 9 Apr 2008 19:16:41 GMT Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> <6641eaF2ics8jU1@mid.uni-berlin.de> Message-ID: <664j0pF2iji99U2@mid.uni-berlin.de> On Wed, 09 Apr 2008 16:16:14 +0200, Diez B. Roggisch wrote: > And then you reply telling us about the greatness of Bangalore and your > product to come. Which is somewhat amusing that people who claim to produce > the greatest software being incapable of debugging it deems me as odd - to > say the least. That's not odd, that's perfectly normal for really clever code: Debugging is twice as hard as writing the code in the first place.Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan ;-) Ciao, Marc 'BlackJack' Rintsch From aaron.watters at gmail.com Fri Apr 18 10:16:35 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Fri, 18 Apr 2008 07:16:35 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: On Apr 17, 12:27 pm, Michael Torrie wrote: > What's the big deal? The big deal is that I would love to see Django become the standard platform for web development, for example. That will be much less likely if 60% of the contributed tools for Django don't work for Python 3000 and 20% don't work for Python 2.6. Expecting volunteer contributors to support both is not realistic. It's hard enough to support one adequately. Even if you could hope to support both with the same code, just testing in both environments would be onerous. It would be another matter entirely if py3k offered major new functionality like full stackless microthreads but it doesn't (afaik -- correct me please). >From my perspective it's just a pain in the @$$. By the way, full stackless microthreads don't seem to require breaking most (or any) existing code. I really like developing in Python -- but it's hard to keep doing it when the growth curve is so slow and a so many people have deep reservations about it, inspired in part, justifiably, by nonsense like this. In fact, I basically stopped. Then I came back. Now I'm wondering if it was such a good idea... -- Aaron Watters ==== http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=stupid+bug From fetchinson at googlemail.com Tue Apr 15 23:26:19 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Tue, 15 Apr 2008 20:26:19 -0700 Subject: Interesting timing issue I noticed In-Reply-To: References: Message-ID: > Can I then simply ignore the time data then? I do see better performance > obviously the smaller the box is, but I guess my issues is how seriously to > take all this data. Because I can't claim "performance improvement" if there > isn't really much of an improvement. > > On Tue, Apr 15, 2008 at 11:04 PM, Daniel Fetchinson < > fetchinson at googlemail.com> wrote: > > > > I've written up a stripped down version of the code. I apologize for > > the bad > > > coding; I am in a bit of a hurry. > > > > > > import random > > > import sys > > > import time > > > > > > sizeX = 320 > > > sizeY = 240 > > > borderX = 20 > > > borderY = 20 > > > > > > # generates a zero matrix > > > def generate_zero(): > > > matrix = [[0 for y in range(sizeY)] for x in range(sizeX)] > > > return matrix > > > # fills zero matrix > > > def fill_matrix(in_mat): > > > mat = in_mat > > > for x in range(sizeX): > > > for y in range(sizeY): > > > mat[x][y] = random.randint(1, 100) > > > return mat > > > ###################################################################### > > > # COMPUTES ONLY A PART OF THE ARRAY > > > def back_diff_one(back_array, fore_array, box): > > > diff_array = generate_zero() > > > > > > start = time.time() > > > for x in range(sizeX): > > > for y in range(borderY): > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > for y in range((sizeY - borderY), sizeY): > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > for y in range(borderY, (sizeY - borderY)): > > > for x in range(borderX): > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > for x in range((sizeX - borderX), sizeX): > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > > > > # tracks object > > > if (len(box) != 0): > > > for x in range(box[0], box[2]): > > > for y in range(box[1], box[3]): > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > print "time one inside = " + str(time.time() - start) > > > return diff_array > > > ###################################################################### > > > # COMPUTES EVERY ELEMENT IN THE ARRAY > > > def back_diff_two(back_array, fore_array): > > > diff_array = generate_zero() > > > start = time.time() > > > for y in range(sizeY): > > > for x in range(sizeX): > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > end = time.time() > > > print "time two inside = " + str(end - start) > > > return diff_array > > > ###################################################################### > > > # CODE TO TEST BOTH FUNCTIONS > > > back = fill_matrix(generate_zero()) > > > fore = fill_matrix(generate_zero()) > > > box = [20, 20, 268, 240] > > > start1 = time.time() > > > diff1 = back_diff_one(back, fore, box) > > > print "time one outside = " + str(time.time() - start1) > > > start2 = time.time() > > > diff2 = back_diff_two(back, fore) > > > print "time one outside = " + str(time.time() - start2) > > > > > > Here are some results from several test runs: > > > > > > time one inside = 0.0780000686646 > > > time one outside = 0.125 > > > time two inside = 0.0780000686646 > > > time two outside = 0.141000032425 > > > >>> ================================ RESTART > > > ================================ > > > >>> > > > time one inside = 0.0629999637604 > > > time one outside = 0.125 > > > time two inside = 0.0789999961853 > > > time two outside = 0.125 > > > >>> ================================ RESTART > > > ================================ > > > >>> > > > time one inside = 0.0620000362396 > > > time one outside = 0.139999866486 > > > time two inside = 0.0780000686646 > > > time two outside = 0.125 > > > >>> ================================ RESTART > > > ================================ > > > >>> > > > time one inside = 0.0780000686646 > > > time one outside = 0.172000169754 > > > time two inside = 0.0789999961853 > > > time two outside = 0.125 > > > >>> ================================ RESTART > > > ================================ > > > >>> > > > time one inside = 0.0780000686646 > > > time one outside = 0.125 > > > time two inside = 0.0780000686646 > > > time two outside = 0.125 > > > >>> ================================ RESTART > > > ================================ > > > >>> > > > time one inside = 0.0620000362396 > > > time one outside = 0.155999898911 > > > time two inside = 0.0780000686646 > > > time two outside = 0.125 > > > >>> ================================ RESTART > > > ================================ > > > >>> > > > time one inside = 0.077999830246 > > > time one outside = 0.125 > > > time two inside = 0.077999830246 > > > time two outside = 0.125 > > > >>> ================================ RESTART > > > ================================ > > > >>> > > > time one inside = 0.0780000686646 > > > time one outside = 0.171000003815 > > > time two inside = 0.077999830246 > > > time two outside = 0.125 > > > >>> ================================ RESTART > > > ================================ > > > >>> > > > time one inside = 0.0629999637604 > > > time one outside = 0.18799996376 > > > time two inside = 0.0620000362396 > > > time two outside = 0.125 > > > > > > Why is a large percentage of the time, the execution time for the > > > (ostensibly smaller) first loop is actually equal to or LARGER than the > > > second? > > > > > > First of all, your method of timing is not the best. Use the timeit > > module instead: http://docs.python.org/lib/module-timeit.html > > > > Second of all the number of subtractions is not that different between > > the two variants of your functions. back_diff_one does 75360 > > subtractions per call while back_diff_two does 76800, these two > > numbers are almost the same. It's true that back_diff_one first only > > calculates a part of the arrays but after "# tracks object" you do a > > bunch of more substractions that will make up the total count. > > > > HTH, > > Daniel > > Please keep the discussion on the list. Yes, if I were you I would discard your original timing data and redo it using the timeit module. Whatever that gives should be reliable and you can start from there. In any case your two functions are doing roughly the same number of operations. HTH, Daniel From tjreedy at udel.edu Wed Apr 30 16:28:51 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 30 Apr 2008 16:28:51 -0400 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> <87tzhjy4u2.fsf@physik.rwth-aachen.de> <1TYRj.27306$o06.18162@tornado.fastwebnet.it> Message-ID: "Marco Mariani" wrote in message news:1TYRj.27306$o06.18162 at tornado.fastwebnet.it... | Torsten Bronger wrote: | | > However, join() is really bizarre. The list rather than the | > separator should be the leading actor. | | No, because join must work with _any sequence_, and there is no | "sequence" type to put the join method on. More generally, it works with any iterable, including dicts... From chris at subtlety.com Sun Apr 6 15:56:43 2008 From: chris at subtlety.com (Chris Bergstresser) Date: Sun, 6 Apr 2008 14:56:43 -0500 Subject: Odd PyQt4 crash on exit when importing on windows Message-ID: <7b0045ed0804061256y57c80619jb81b04e1de709e37@mail.gmail.com> Hi all -- I'm having an odd import issue with PyQt4. If I create two files, like so .... --- xbomb.py --------------- from PyQt4.QtGui import * import sys, ybomb app = QApplication(sys.argv) if __name__ == "__main__": main_win = QMainWindow() main_win.show() sys.exit(qApp.exec_()) --- ybomb.py ---------------- import xbomb ------------------------------------ ... as you can see, the *only* thing ybomb.py does is import the original file. I can run xbomb just fine. However, when I close the dialog it displays, I get a "python.exe has encountered a problem and needs to close. We are sorry for the inconvenience." crash on Windows XP. Obviously, removing either of the import statements fixes the problem. I think I can disentangle my real code so the files don't import each other, but what's going on? Are other people seeing the same behavior? -- Chris From benash at gmail.com Thu Apr 3 00:59:07 2008 From: benash at gmail.com (Benjamin) Date: Wed, 2 Apr 2008 21:59:07 -0700 (PDT) Subject: Parsing HTML? Message-ID: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> I'm trying to parse an HTML file. I want to retrieve all of the text inside a certain tag that I find with XPath. The DOM seems to make this available with the innerHTML element, but I haven't found a way to do it in Python. From olivier.parisy at neuf.REMOVE.fr Sun Apr 27 18:05:06 2008 From: olivier.parisy at neuf.REMOVE.fr (Olivier Parisy) Date: Mon, 28 Apr 2008 00:05:06 +0200 Subject: python and web programming, easy way...? References: <2db36ccf-c9fd-4e7a-9697-fd5c23159287@j22g2000hsf.googlegroups.com> <75679853-b5de-42cb-9db2-a1508f2ad67e@59g2000hsb.googlegroups.com> Message-ID: David a ?crit : > Also, I can't find any reference to cookies or sessions in the webpy > online docs. Maybe it's possible to bolt on support with Python's > Cookie module. The web.py cookbook describes how to use sessions and cookies: http://webpy.org/cookbook Regards, Olivier. From john106henry at hotmail.com Tue Apr 29 12:17:01 2008 From: john106henry at hotmail.com (John Henry) Date: Tue, 29 Apr 2008 09:17:01 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <473deef3-9acb-45dd-a7ca-47b0081bd28c@i36g2000prf.googlegroups.com> <3f7bb91e-335e-46bd-88ca-f15b26c35132@k1g2000prb.googlegroups.com> <827bdae6-4422-4226-a543-af53f5b7e01b@s33g2000pri.googlegroups.com> Message-ID: <083b58e8-522a-4c01-b612-c592fe69fcd1@i36g2000prf.googlegroups.com> On Apr 29, 8:28 am, Panyasan wrote: > > Christian, > > > It appears you're missing a file. Where did you placed my program? I > > see that there are two places being mentioned: > > > > no resource file for /Users/bibliograph/Programme/PythonCard/tools/ > > > layoutEditor/multipropertyEditor > > > and > > > > File "/Library/Python/2.5/site-packages/PythonCard/tools/ > > > layoutEditor/layoutEditor.py", line 556, in createDC > > I unzipped the folder you uploaded and placed it in the PythonCard/ > tools folder. I get the same error if I try to start the default > resourceEditor.py or layoutEditor.py scripts, so it does not seem to > have to do with your modifications. > When I copy multipropertyEditor.rsrc.py files from PythodCard/tools/ > resourceEditor/modules folder to PythodCard/tools/resourceEditor/, it > will throw the error about a different file - might this be some kind > of PATH error? > > C. It certainly looks like it's not finding a file. Not knowing Mac or Linux, I don't know how files are searched. There are a whole bunch of test programs that comes with Pythoncard. Do they work? (Not all of them will work - some requires a database) From duncan.booth at invalid.invalid Mon Apr 14 09:15:48 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 14 Apr 2008 13:15:48 GMT Subject: Process multiple files References: Message-ID: "Doran, Harold" wrote: > If these files followed a naming convention such as 1.txt and 2.txt I > can easily see how these could be parsed consecutively in a loop. > However, they are not and so is it possible to modify this code such > that I can tell python to parse all .txt files in a certain directory > and then to save them as separate files? For instance, using the example > above, python would parse both spam.txt and eggs.txt and then save 2 > different files, say as spam_parsed.txt and eggs_parsed.txt. > This isn't exactly what you asked for, but have you looked at the fileinput module: it will process a list of filenames pointing stdin at each file in turn, optionally it can work inplace, but without that option I think it is pretty close to what you want (warning, untested code follows): output = None for line in fileinput.input(n for n in glob.glob('*.txt') if not n.endswith('_parsed.txt')): if fileinput.isfirstline(): if output: output.close() output = open(fileinput.filename().replace('.', '_parsed.', 1), 'w') print >>output, "parsed:", line.strip() if output: output.close() From otsaloma at cc.hut.fi Sun Apr 6 20:26:15 2008 From: otsaloma at cc.hut.fi (Osmo Salomaa) Date: Mon, 07 Apr 2008 03:26:15 +0300 Subject: py.test and test coverage analysis ? In-Reply-To: References: Message-ID: <1207527975.13270.3.camel@localhost> On ke, 2008-04-02 at 11:23 -0600, j vickroy wrote: > Could someone offer a suggestion on how to combine coverage analysis > with py.test. Use the '-x' option to coverage.py to run py.test, then '-rm' to view the results. I use about the following shell script; additionally I find some grepping of the second command useful. #!/bin/sh coverage.py -x $(which py.test) "$@" || exit 1 coverage.py -rm -o /usr,/var rm -f .coverage -- Osmo Salomaa From bbxx789_05ss at yahoo.com Fri Apr 18 20:36:12 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Fri, 18 Apr 2008 17:36:12 -0700 (PDT) Subject: How to print a unicode string? References: Message-ID: <54e7dba7-f7f2-4aa7-81f9-922e3bf6e6cd@m73g2000hsh.googlegroups.com> On Apr 18, 5:38?pm, damonwisc... at gmail.com wrote: > I'd like to print out a unicode string. > > I'm running Python inside Emacs, which understands utf-8, so I want to > force Python to send utf-8 to sys.stdout. > > From what I've googled, I think I need to set my locale. I don't > understand how. > > import locale > print locale.getlocale() > --> (None,None) > print locale.getdefaultlocal() > --> ('en_GB','cp1252') > print locale.normalize('en_GB.utf-8') > --> en_GB.UTF8 > locale.setlocale(locale.LC_ALL,'en_GB.UTF8') > --> ?locale.Error: unsupported locale setting > > I'd be grateful for advice. > Damon. u_str = u'hell\u00F6 w\u00F6rld' #o's with umlauts print u_str.encode('utf-8') --output:-- hellö wörld From wizzardx at gmail.com Sun Apr 27 02:57:31 2008 From: wizzardx at gmail.com (David) Date: Sun, 27 Apr 2008 08:57:31 +0200 Subject: problem with listdir In-Reply-To: References: Message-ID: <18c1e6480804262357l1233d389gd4fec58d5e20fb7@mail.gmail.com> On Sat, Apr 26, 2008 at 7:56 PM, jimgardener wrote: > > > * Run cmd.exe and see if you can run "dir f:\\code\\python\pgmgallery/*.*" > > > > that causes a message 'Invalid switch - "*.*".' > > Probably because on the command-line, / means a command-line option. Been a while since I used DOS. Try this instead: dir f:\code\python\pgmgallery\*.*" David. From pylists at arcor.de Mon Apr 14 00:04:40 2008 From: pylists at arcor.de (Penny Y.) Date: Mon, 14 Apr 2008 12:04:40 +0800 Subject: Host: header Message-ID: <20080414040454.E685730AC25@mail-in-03.arcor-online.net> Hello, I have a problem with a request url,for example, I have the code below, import httplib try: conn = httplib.HTTPConnection("192.168.1.1") conn.request("GET", "/") r1 = conn.getresponse() if r1.status == 200: result = 0 except Exception: result = -1 but the server on 192.168.1.1 accept virtual host request only. That's to say, I need to specify a "Host:" header in the request. How to do it? thanks. From lew at lewscanon.com Tue Apr 22 23:56:34 2008 From: lew at lewscanon.com (Lew) Date: Tue, 22 Apr 2008 23:56:34 -0400 Subject: pop langs website ranking In-Reply-To: <1208919347_3071@news.newsgroups.com> References: <41fbaf27-a80b-402b-b406-c048a65a8643@b64g2000hsa.googlegroups.com> <315e13cc-3d21-4f2f-8503-835ea79069e2@x35g2000hsb.googlegroups.com> <1208919347_3071@news.newsgroups.com> Message-ID: Gerry Ford wrote: > "Paul McGuire" wrote in message > news:315e13cc-3d21-4f2f-8503-835ea79069e2 at x35g2000hsb.googlegroups.com... > On Apr 22, 4:41 pm, "xah... at gmail.com" wrote: >> In February, i spent few hours researching the popularity of some >> computer language websites. >> > I seem to recall this exact same post from *last* February. > > --->I remember it too. Xah is quite the self-promoter. Massive > cross-posters don't have anything to say for me. So don't do it. -- Lew From matthieu.brucher at gmail.com Sun Apr 6 06:03:45 2008 From: matthieu.brucher at gmail.com (Matthieu Brucher) Date: Sun, 6 Apr 2008 12:03:45 +0200 Subject: ANN: pry unit testing framework In-Reply-To: <20080405105459.GB15154@nullcube.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> Message-ID: 2008/4/5, Aldo Cortesi : > > Thus spake Matthieu Brucher (matthieu.brucher at gmail.com): > > > > How does it compare to the nose framework ? > > > As far as the base unit testing functionality is concerned, I think > they try to address similar problems. Both have assert-based testing > with inspection and re-parsing of assert exceptions for better error > messages. Both try to provide better fixture management. Both make > programmatic test generation easier. Both have a command-line tool for > running and gathering tests. > > I like nose, but I'm biased, and of course I think Pry has some > advantages. One difference I'd point out is Pry's tree-based test > structure, which provides a number of conveniences and features (much > nicer test selection from the command line, for instance). Pry is also > less than half the size of nose, and should therefore be simpler to > extend and understand. > > At any rate, feel free to take a look at Pry and see what you think. > One last question : does it take doctests into account ? Thanks for the last answer ;) Matthieu -- French PhD student Website : http://matthieu-brucher.developpez.com/ Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92 LinkedIn : http://www.linkedin.com/in/matthieubrucher -------------- next part -------------- An HTML attachment was scrubbed... URL: From deets at nospam.web.de Fri Apr 18 08:27:31 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 18 Apr 2008 14:27:31 +0200 Subject: py3k s***s In-Reply-To: References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <66q33cF2krjf2U1@mid.uni-berlin.de> Message-ID: <66rie3F2leg20U1@mid.uni-berlin.de> Robin Becker schrieb: > I'm in the process of attempting a straightforward port of a relatively > simple package which does most of its work by writing out files with a > more or less complicated set of possible encodings. So far I have used > all the 2to3 tools and a lot of effort, but still don't have a working > version. This must be the worst way to convert people to unicode. When > tcl went through this they chose the eminently sensible route of not > choosing a separate unicode type (they used utf8 byte strings instead). > Not only has python chosen to burden itself with two string types, but > with 3 they've swapped roles. This is certainly the first time I've had > to decide on an encoding before writing simple text to a file. Which is the EXACT RIGHT THING TO DO! see below. > > Of course we may end up with a better language, but it will be a > worse(more complex) tool for many simple tasks. Using a complex writing > with many glyphs costs effort no matter how you do it, but I just use > ascii :( and it's still an effort. > > I find the differences in C/OS less hard to understand than why I need > bytes(x,'encoding') everywhere I just used to use str(x). If you google my name + unicode, you see that I'm often answering questions regarding unicode. I wouldn't say I'm a recognized expert on the subject, but I certainly do know enough to deal with it whenever I encounter it. And from my experience with the problems in general, and specificly in python, as well as trying to help others I can say that: - 95% of the times, the problem is in front of the keyboard. - programmers stubbornly refuse to *learn* what unicode is, and what an encoding is, and what role utf-8 plays. Instead, the resort to a voodoo-approach of throwing in various encode/decode-calls + a good deal of cat's feces in hope of wriggling themselves out of the problem. - it is NOT sensible to use utf8 as unicode-"type" - that is as bad as it can get because you don't see the errors, but instead mangle your data and end up with a byte-string-mess. If that is your road to heaven, by all means chose it - and don't use unicode at all. and be prepared for damnation :) If your programs worked for now, but don't do anymore because of Py3K introducing mandatory unicode-objects for string-literals it pretty much follows that they *seem* to work, but very, very probably fail in the face of actual i18nized data. The *only* sensible thing to do is follow these simple rules - and these apply with python 2.x, and will be enforced by 3k which is a good thing IMHO: - when you read data from somewhere, make sure you know which encoding it has, and *immediatly* convert it to unicode - when you write data, make sure you know which encoding you want it to have (in doubt, chose utf-8 to prevent loss of data) and apply it. - XML-parsers take byte-strings & spit out unicode. Period. I neither want to imply that you are an Idiot nor that unicode doesn't have it's complexities. And I'd love to say that Python wouldn't add to these by having two string-types. But the *real* problem is that it used to have only bytestrings, and finally Py3K will solve that issue. Diez From hniksic at xemacs.org Tue Apr 15 06:07:29 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Tue, 15 Apr 2008 12:07:29 +0200 Subject: Dynamic use of property() fails References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> <87wsmz4l5g.fsf@mulj.homelinux.net> <48046af8$0$16166$426a74cc@news.free.fr> Message-ID: <87hce34eji.fsf@mulj.homelinux.net> Bruno Desthuilliers writes: >> However, if you know what you're doing, you can simply customize your >> class's __getattribute__ to do what *you* want for your objects. > > > But bear in mind that, beside possible unwanted side-effectn, you'll > get a non-negligible performance hit - __getattribute__ being, as the > name implies, invoked on each and every attribute lookup. That's unavoidable, though -- whatever you do to customize your class in Python, the result will be slower than the C code built into Python. Fortunately, not every object is performance-critical. In this case, __getattribute__ buys you per-instance customization not otherwise available. The code you posted is probably more efficient, but at the cost of losing the ability to customize specific instances of the class. From MartinRinehart at gmail.com Thu Apr 10 15:52:11 2008 From: MartinRinehart at gmail.com (MartinRinehart at gmail.com) Date: Thu, 10 Apr 2008 12:52:11 -0700 (PDT) Subject: Python conventions References: Message-ID: Daniel Fetchinson wrote: > I'm sorry to disappoint you but this project has already been completed: > > http://www.python.org/dev/peps/pep-0008/ Daniel, PEP 8 is anything but complete. How much of the following simple question can you answer from there: Given that you can name things with UpperAndLower, lowerAndUpper, lower_and_underscore, etc., what is the convention for naming packages, modules, classes, ... PEP 8 very much reminds me of Sun's Java conventions - a start, but only a start. Also, in part, controversial. (How wide do you think Python code should be?) Finally, lacking in basic organization. (This seems to be a disease that infects almost all standards.) We can do better. As a guess, GvR would be happy to have someone fill out PEP 8. From fr5478bey at gmail.com Sat Apr 26 11:42:06 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:42:06 -0700 (PDT) Subject: navigon 6 crack Message-ID: <6b365493-5cee-4f5f-8f51-b655e63c3d7f@i76g2000hsf.googlegroups.com> navigon 6 crack http://cracks.00bp.com F R E E C R A C K S From carbanancizpo at gmail.com Fri Apr 18 16:56:12 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:56:12 -0700 (PDT) Subject: winxp keygen Message-ID: <757fef36-63c6-4f48-a3e4-335dc886d442@x41g2000hsb.googlegroups.com> winxp keygen http://cracks.12w.net F R E E C R A C K S From carsten.haese at gmail.com Fri Apr 4 19:28:58 2008 From: carsten.haese at gmail.com (Carsten Haese) Date: Fri, 4 Apr 2008 16:28:58 -0700 (PDT) Subject: Python2.5 and MySQLdb References: Message-ID: On Apr 4, 5:06 pm, writeson wrote: > It > generates a huge lists of errors and warnings from gcc when I run the > python2.5 setup.py build script that comes with the tar file. Anyone > have any suggestions? I suggest you post a couple of those error messages here, so that we can help you without guessing. -- Carsten Haese http://informixdb.sourceforge.net From zolotoiklo at mail.ru Sat Apr 26 06:46:19 2008 From: zolotoiklo at mail.ru (=?KOI8-R?B?+s/Mz9TPyiDrzM/O?=) Date: Sat, 26 Apr 2008 03:46:19 -0700 (PDT) Subject: =?KOI8-R?B?wsXM2MUgTWFpZGVuZm9ybQ==?= Message-ID: <775dee46-dae9-4791-90c0-41693e9dc437@j22g2000hsf.googlegroups.com> ???????????? ??????????? ????? Maidenform USA - ??????? ?????????????? ????? ????? ???? ? ???. ????????? ????-????? (??????????? ?????) ??????? ??????? ????????? ?? ???????????? ??????????? ????????? ? ???????? ?????????? ????. ??????? ????????? ??????????? ??????? ???????????? ?????????????? ????????? ??????? ??????. ????????? ?????????? ???? ? ?????????????? ????????, ??????????? ????? ????????? ??? ?????????? ???????. ????? Maidenform http://shopbody.ru/maidenform6224.htm From enleverlesX.XmcX at XmclaveauX.com Tue Apr 15 06:18:05 2008 From: enleverlesX.XmcX at XmclaveauX.com (Méta-MCI (MVP)) Date: Tue, 15 Apr 2008 12:18:05 +0200 Subject: [ANN] Data Plotting Library DISLIN 9.3 In-Reply-To: References: Message-ID: <48048358$0$850$ba4acef3@news.orange.fr> Hi, Thanks! I like DISLIN (even if I use it very little). @+ -- Michel Claveau From mishok13 at gmail.com Thu Apr 10 14:06:03 2008 From: mishok13 at gmail.com (Andrii V. Mishkovskyi) Date: Thu, 10 Apr 2008 21:06:03 +0300 Subject: from __future__ import print In-Reply-To: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> References: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> Message-ID: <192840a00804101106t2e0d687erc13d9ebf096448e3@mail.gmail.com> 2008/4/10, samslists at gmail.com : > Am I the only one that thinks this would be useful? :) > > I'd really like to be able to use python 3.0's print statement in > 2.x. Is this at least being considered as an option for 2.6? It > seems like it would be helpful with transitioning. It's not only considered but have been already implemented. Enjoy. :) Python 2.6a2+ (trunk:62269, Apr 10 2008, 20:18:42) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from __future__ import print_function >>> print "asd" File "", line 1 print "foo" ^ SyntaxError: invalid syntax >>> print("foo") foo > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Wbr, Andrii Mishkovskyi. He's got a heart of a little child, and he keeps it in a jar on his desk. From samuel.progin at gmail.com Fri Apr 18 03:41:05 2008 From: samuel.progin at gmail.com (Sam) Date: Fri, 18 Apr 2008 00:41:05 -0700 (PDT) Subject: Request a short code review References: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> Message-ID: <4aaa7c04-99c9-40df-87de-999152a139ab@c65g2000hsa.googlegroups.com> Hello, I would personally avoid using "type" as variable name, or key, because built-in class type already exists. As I understand your code, it was not your intention to override it. ++ Sam From bdsatish at gmail.com Mon Apr 14 03:24:49 2008 From: bdsatish at gmail.com (bdsatish) Date: Mon, 14 Apr 2008 00:24:49 -0700 (PDT) Subject: Java or C++? References: Message-ID: On Apr 14, 12:21 pm, Bob Martin wrote: > in 342367 20080414 074410 s0s... at gmail.com wrote: > > >Hello, I was hoping to get some opinions on a subject. I've been > >programming Python for almost two years now. Recently I learned Perl, > >but frankly I'm not very comfortable with it. Now I want to move on > >two either Java or C++, but I'm not sure which. Which one do you think > >is a softer transition for a Python programmer? Which one do you think > >will educate me the best? > Certainly Java. It's also easier to find Java jobs than C++ jobs. From jens at aggergren.dk Tue Apr 29 08:19:32 2008 From: jens at aggergren.dk (Jens) Date: Tue, 29 Apr 2008 05:19:32 -0700 (PDT) Subject: Zope/DTML Infuriating... References: Message-ID: <3a955f90-ed80-46be-a238-1462e4fb2d0c@m3g2000hsc.googlegroups.com> On Apr 29, 1:59?pm, Marco Mariani wrote: > Jens wrote: > > I've the checked that i'm referring to the variables correctly, so the > > only explanation i can come up with, is that '+' doesn't result in a > > string concatenation (with implicit typecast to string of the integer > > variable(this is a interpreted language after all)). > > No, sorry. You really need to read the python tutorial at the very least. > You might have wrong assumptions from previous PHP experiences. > > ?>>> 'x'+4 > Traceback (most recent call last): > ? ?File "", line 1, in > TypeError: cannot concatenate 'str' and 'int' objects > ?> ... and the non snobby answer would have been: ... From altami0762 at gmail.com Thu Apr 17 15:49:07 2008 From: altami0762 at gmail.com (altami0762 at gmail.com) Date: Thu, 17 Apr 2008 12:49:07 -0700 (PDT) Subject: zillatube cracks keygens Message-ID: zillatube cracks keygens http://cracks.12w.net F R E E C R A C K S From castironpi at gmail.com Fri Apr 18 11:23:15 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Fri, 18 Apr 2008 08:23:15 -0700 (PDT) Subject: python persistence References: <8b1723d9-67c8-4fe5-b07b-22b0b9311519@8g2000hsu.googlegroups.com> <7f58b5f4-3195-472c-b307-dec71b12aaa8@y21g2000hsf.googlegroups.com> <44f04bf3-4edc-4cb4-9e54-fe51b5e591bc@e39g2000hsf.googlegroups.com> <80d1731d-a3c6-4fce-81fd-9c3f3537e59b@d21g2000prf.googlegroups.com> <5386cf08-c155-4fbb-8373-dbbb9829a9e7@m3g2000hsc.googlegroups.com> <3c27b270-e593-4f2a-b881-68126319760c@8g2000hsu.googlegroups.com> <7d71e294-2b13-4be0-948e-2fe0e4bbe7db@f63g2000hsf.googlegroups.com> Message-ID: <2d0db2c2-85ba-4987-9bf7-86109380d325@c65g2000hsa.googlegroups.com> On Apr 1, 3:21?pm, castiro... at gmail.com wrote: > On Apr 1, 11:34?am, "Gabriel Genellina" > > En Tue, 01 Apr 2008 08:47:33 -0300, escribi?: > > > > >> >>>> c['0']= type('None',(),{}) > > >> > Traceback (most recent call last): > > >> > pickle.PicklingError: Can't pickle : it's not > > >> > found as __main__.None > > > >> Don't do that then. Or use the available pickle hooks to customize how ? > > >> such classes may be pickled. All persistence mechanisms have ? > > >> limitations. > > > > I don't see a problem with that; except that binaries come from > > > disks. ?You could have a Python session that runs entirely on disks + > > > the ALU. > > > (ALU? Do you mean CPU?) I don't understand this. Most programs are read ? > > ?from disk. Most data is read from disk. > > > > I want to know if any, and correct me here, simple > > > modification can store live objects. ?I call a.append(it) and the > > > memory update takes place on disk instead. > > > Using ZODB, a.append(it) would mark `a` as dirty. When you latter commit ? > > the transaction, it is stored back on disk. > > > > If you require that all objects referenced by on-disk objects be on- > > > disk, that's an easy workaround. > > > ZODB already does that. > > It's pretty close, but the database connection can get bulky. ?If you > had: > ?_______________________ > | ? ? ? ? ______________________ > |File ? ?| PyOb1 | PyOb2 | ?.. ?| > | ? ? ? ?|_______|_______|______| > |_______________________ > > on disk, updating the reference counts and attributes would take a > long time, but it's just right for some core applications. > > Strictly, I'm not in the "real" programming world [snip]. My intentions may be pedagogical but I can guarantee good. I am following the cases where databases are way-out-of-proportion techniques, and you only need small numbers persistent. I am looking for a step-by-step of everything that happens in line one of the following program: #!/windows a= [ ] What c-l-py says is that the compilation flags vary widely enough to make my destination worthless. Accepting concern, please only reply in readers' free time. I expect I wish to override routines and macros which are buried pretty deep and used pretty pervasively throughout Python and inner user extension modules, so I'll reemphasize that I'm only interested in pass-time hobbyage. Consultants need not reply (but of course may). I foresee that writing my own disk-based-heap may be in order, which would be why Bruno keeps directing us to relationals. I would want an arena file/pool file. Zoom out to the big picture: Session 1: >>> managingfolder= '/live/Python/' >>> manager['a']= [ 0 ] Session 2: >>> managingfolder= '/live/Python/' >>> manager['a'] [ 0 ] >>> manager['a'].append( 0 ) Session 3: >>> managingfolder= '/live/Python/' >>> manager['a'] [ 0, 0 ] I would kind of expect a file per the diagram in obmalloc.c, and I expect to specialize in CPython. Object-specific allocators _____ ______ ______ ________ [ int ] [ dict ] [ list ] ... [ string ] Python core | +3 | <----- Object-specific memory -----> | <-- Non-object memory --> | struct pool_header and struct arena_object would probably appear, and to explify priorities, performance would be a low priority, and it's a high priority to stay all in Python. (Aside, I certainly would maintain Python is yes, still Python.) From pylists at arcor.de Tue Apr 15 01:54:43 2008 From: pylists at arcor.de (Penny Y.) Date: Tue, 15 Apr 2008 13:54:43 +0800 Subject: a name error Message-ID: <20080415055502.9F3CF292B61@mail-in-07.arcor-online.net> Hello, I run this small script: import urllib2,sys try: r=urllib2.urlopen("http://un-know-n.com/") except URLError,e: print str(e) sys.exit(1) print r.info() But got the errors: Traceback (most recent call last): File "t1.py", line 4, in ? except URLError,e: NameError: name 'URLError' is not defined Why these is not the name of URLError? I saw it on this module's page: http://www.python.org/doc/lib/module-urllib2.html Thanks. From reachmsn at hotmail.com Wed Apr 9 04:02:10 2008 From: reachmsn at hotmail.com (reachmsn at hotmail.com) Date: Wed, 9 Apr 2008 01:02:10 -0700 (PDT) Subject: Cannot understand the detailedly the following code References: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> Message-ID: <10a83944-b17a-4c3f-992b-1754c0a5e9b1@s33g2000pri.googlegroups.com> On Apr 8, 5:45?pm, "A.T.Hofkamp" wrote: > On 2008-04-08, reach... at hotmail.com wrote: > > [deleted a long piece of text by our BDFL about recursive graph path-finding algorithm] > > > after first writing the inductive part ... for node in > > graph[start] .... > > and then by trial and error put square brackets around path in the > > Basis part. Can someone please explain how to write this code. Thanks! > > The same as any other function. > (the trick with recursive functions is not to think about recursion. Instead, > pretend you are calling another function that happens to have the same name.) > > As for the actual procedure of writing a function: > > First define the input and output parameters/values of the function. > (ie what goes in, and what comes out) > > For recursive functions, there are always two cases, a terminating case, and a > reduction case. In the first case, you may not use the recursive function, in > the latter function you should. > Both cases should use the information available from the input parameters, and > provide a result that matches with the output requirements of the function. Add > a if/then/else that distinguishes between what case you have, and you're done. > > Sincerely, > Albert Ok following these instructions one gets def find_all_paths(graph, start, end, path=[]): path= path+ [start] for node in graph[start]: find_all_paths(graph, node, end, path) Now > > First define the input and output parameters/values of the function. > (ie what goes in, and what comes out) Now what will be the output parameters - there is a Return statement. Input parameters are graph, vertexes start, node, end and path. Also how would you write the terminating and reduction cases after this. Actually i'm not clear how to proceed writing this recursive function. Thanks! From frikker at gmail.com Tue Apr 29 09:29:20 2008 From: frikker at gmail.com (blaine) Date: Tue, 29 Apr 2008 06:29:20 -0700 (PDT) Subject: Why is None <= 0 References: <481226f9$0$20866$9b622d9e@news.freenet.de> Message-ID: <4d86a7ce-8f3f-493b-b1c2-a2659817b215@k13g2000hse.googlegroups.com> On Apr 29, 5:32 am, Duncan Booth wrote: > =?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?= wrote: > > (FWIW, in 2.x, x>=4?, it's None < numbers < anything else; > > numbers are ordered by value, everything else is ordered > > by type name, then by address, unless comparison functions > > are implemented). > > Quite apart from Jon pointing out that this isn't true for all cases when > copmparing against None, the other half also isn't true: > > >>> class C: pass > >>> C() < 5 > > True > > That happens at least in Python 2.5.2 on win32. Yet another reason to avoid > old-style classes. Sorry - but what are new style classes? From python.list at tim.thechases.com Mon Apr 14 08:57:30 2008 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 14 Apr 2008 07:57:30 -0500 Subject: Process multiple files In-Reply-To: <2323A6D37908A847A7C32F1E3662C80E017BDF37@dc1ex01.air.org> References: <2323A6D37908A847A7C32F1E3662C80E017BDF37@dc1ex01.air.org> Message-ID: <480354BA.103@tim.thechases.com> > new_file = open('filename.txt', 'w') > params = open('eggs.txt', 'r') > do all the python stuff here > new_file.close() > > If these files followed a naming convention such as 1.txt and 2.txt I > can easily see how these could be parsed consecutively in a loop. > However, they are not and so is it possible to modify this code such > that I can tell python to parse all .txt files in a certain directory > and then to save them as separate files? For instance, using the example > above, python would parse both spam.txt and eggs.txt and then save 2 > different files, say as spam_parsed.txt and eggs_parsed.txt. import os for fname in os.listdir('.'): if not fname.lower().endswith('.txt'): continue new_file_name = '%s_parsed%s' % tuple( new_file = open(new_file_name, 'w') params = open(fname) # do all the python stuff here params.close() new_file.close() -tkc From nick at stinemates.org Thu Apr 24 11:26:57 2008 From: nick at stinemates.org (Nick Stinemates) Date: Thu, 24 Apr 2008 08:26:57 -0700 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> Message-ID: <20080424152657.GA7426@deviL> On Tue, Apr 22, 2008 at 04:07:01AM -0700, GD wrote: > Please remove ability to multiple inheritance in Python 3000. > > Multiple inheritance is bad for design, rarely used and contains many > problems for usual users. > > Every program can be designed only with single inheritance. > > I also published this request at http://bugs.python.org/issue2667 > -- > http://mail.python.org/mailman/listinfo/python-list You make strong, compelling arguments............ -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From stefan_ml at behnel.de Tue Apr 22 07:09:13 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 22 Apr 2008 13:09:13 +0200 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> Message-ID: <480DC759.9020703@behnel.de> GD wrote: > Please remove ability to multiple inheritance in Python 3000. I'm so happy *that's* a dead parrot, all right. Stefan From rubrum at pacbell.net Fri Apr 4 20:28:45 2008 From: rubrum at pacbell.net (Michael Press) Date: Fri, 04 Apr 2008 17:28:45 -0700 Subject: Nonlinear least square problem References: <0354420e-819d-4ba3-b61a-faaffd46b65c@r9g2000prd.googlegroups.com> Message-ID: In article <0354420e-819d-4ba3-b61a-faaffd46b65c at r9g2000prd.googlegroups.com>, Uwe Kotyczka wrote: > Hallo, sorry for multiposting, but I am really looking > for some hint to solve my problem. And no, I don't > use Matlab, but maybe the matlab people have an idea > nevertheless. No apology required, since you seem to have cross-posted appropriately, and not multi-posted. Multi-posting is posting the same message one at a time to more than one group. I see in the Newsgroups: header line that you posted to several groups at once. Furthermore the number of groups is not out of bounds, and the groups are appropriate to the question and, presumably, your interests. Unfortunately, I cannot help with the actual question. :) -- Michael Press From sn at sncs.se Fri Apr 18 01:39:46 2008 From: sn at sncs.se (Sverker Nilsson) Date: Thu, 17 Apr 2008 22:39:46 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <66q33cF2krjf2U1@mid.uni-berlin.de> Message-ID: On Apr 18, 12:59 am, "Diez B. Roggisch" wrote: > > And I have been benefiting from Python in general, so far. Thanks, > > community. > > > But now... I'll probably stop posting here for now, & I may stop other > > things too. > > > Just my 2c. > > You know what I was just wondering about? All these C-written > cross-platform libraries (which Python users benefit from, most probably > including evven you) that run on different unixes & windows, which are a > much greater diversity to handle than the not-even-yet-settled > differences between Py3K & 2.x. How the heck do they do that? > > Oh, and these dreaded 64 bit processors, possibly with multi-cores, > which need changes in code as well, to be utilized to their power. > > But then, these guys most probably don't whine about diversity and > constant change, and cry out useless threats to people who probably > can't care less. > > Fare well, if you must. But getting mad over something which impact you > can't even judge right now is childish. Nothing else. > > Diez Some whine. Some just don't care. Why not whine? From duncan.booth at invalid.invalid Tue Apr 29 11:11:05 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 29 Apr 2008 15:11:05 GMT Subject: Why is None <= 0 References: <481226f9$0$20866$9b622d9e@news.freenet.de> <4d86a7ce-8f3f-493b-b1c2-a2659817b215@k13g2000hse.googlegroups.com> Message-ID: blaine wrote: > On Apr 29, 5:32 am, Duncan Booth wrote: >> =?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?= >> wrote: >> > (FWIW, in 2.x, x>=4?, it's None < numbers < anything else; >> > numbers are ordered by value, everything else is ordered >> > by type name, then by address, unless comparison functions >> > are implemented). >> >> Quite apart from Jon pointing out that this isn't true for all cases >> when copmparing against None, the other half also isn't true: >> >> >>> class C: pass >> >>> C() < 5 >> >> True >> >> That happens at least in Python 2.5.2 on win32. Yet another reason to >> avoid old-style classes. > > Sorry - but what are new style classes? > New style classes are anything type derived from object. e.g. class D(object): pass or (since list is derived from object): class E(list): pass Old style classes are those which either have old-style base classes or no base class at all (and no __metaclass__ either but don't worry about that for now) e.g. the class C above. The problem with old style classes is that various things either work subtly differently or don't work at all, but you don't get much warning. So basically steer clear of them. An example of something which doesn't work with old style classes would be the @property decorator: you can get the property, but setting it simply overwrites the property with the new value. See http://www.google.co.uk/search?q=python+%22new+style%22 for more information. From kib2 at free.fr Thu Apr 24 17:06:11 2008 From: kib2 at free.fr (kib) Date: Thu, 24 Apr 2008 23:06:11 +0200 Subject: Psyco alternative In-Reply-To: References: <1369b321-f55b-432b-b2f9-6144787509d8@h11g2000prf.googlegroups.com> <7xlk4473ai.fsf@ruckus.brouhaha.com> <651ncdF2cmik2U1@mid.uni-berlin.de> <651onqF2dripdU1@mid.uni-berlin.de> Message-ID: <4810f649$0$23674$426a74cc@news.free.fr> Christian Tismer a ?crit : > bearophileHUGS at lycos.com wrote: >> Diez B. Roggisch: >>> the author says that the approach is flawed, so at *some* >>> point it will be discontinued. >> >> Can't Psyco be improved, so it can compile things like: >> >> nums = (i for i in xrange(200000) if i % 2) >> print sum(nums) > > Although my main goal is to support PyPy as much as possible, > I am currently taking a pause in favor of filling the gap > for psyco, supporting generators. The details are not yet > settled, maybe we choose to change the project name, > to avoid the author getting bugged with questions about > this extra stuff. > > - chris > Maybe try Psychotic http://code.google.com/p/psychotic/ I really like the screencast ! ...sorry for the bad joke :) From laurent.ploix at gmail.com Tue Apr 8 05:39:04 2008 From: laurent.ploix at gmail.com (=?ISO-8859-1?Q?m=E9choui?=) Date: Tue, 8 Apr 2008 02:39:04 -0700 (PDT) Subject: Is there an official way to add methods to an instance? References: <7xve2yas87.fsf@ruckus.brouhaha.com> <47f61041$0$27969$426a34cc@news.free.fr> <47f645e6$0$36354$742ec2ed@news.sonic.net> Message-ID: <9a4cde09-d1a0-4205-aea8-1ee32d4fb1b3@a70g2000hsh.googlegroups.com> On Apr 4, 5:25 pm, John Nagle wrote: > Bruno Desthuilliers wrote: > > Paul Rubin a ?crit : > >> Brian Vanderburg II writes: > >>> I've checked out some ways to get this to work. I want to be able to > >>> add a new function to an instance of an object. > > >> Ugh. Avoid that if you can. > > > Why so ? OO is about objects, not classes, and adding methods on a > > per-object basis is perfectly legitimate. > > It's what professional programmers call a "l33t feature", > one not suitable for production code. Typically such features > are used by programmers with about two years experience, > trying too hard to prove that they're cool. > > John Nagle Yes, and the reason is quite obvious: if you read the code of the class, you can't see the function. That makes it much more difficult to understand and to debug. From roger.dahlstrom at gmail.com Fri Apr 11 13:45:57 2008 From: roger.dahlstrom at gmail.com (rdahlstrom) Date: Fri, 11 Apr 2008 10:45:57 -0700 (PDT) Subject: Windows - window status (Running vs Not Responding) Message-ID: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> Does anyone know how to determine the window status (Running or Not Responding)? I've tried various methods with no success... This would be on a variety of Windows systems, but all at least XP, and mostly server 2003. Everyone will have Python 2.5.1 on them, and the script would be running locally. Any ideas? From george.sakkis at gmail.com Wed Apr 30 12:56:43 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 30 Apr 2008 09:56:43 -0700 (PDT) Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> Message-ID: <74c070ce-1b8f-4746-9d1c-ac2227aaf515@y21g2000hsf.googlegroups.com> On Apr 30, 5:06?am, Torsten Bronger wrote: > Hall?chen! > > SL writes: > > "Gabriel Genellina" schreef in bericht > >news:mailman.365.1209541507.12834.python-list at python.org... > > >> En Wed, 30 Apr 2008 04:19:22 -0300, SL escribi?: And > >> that's a very reasonable place to search; I think chr and ord are > >> builtin functions (and not str methods) just by an historical > >> accident. (Or is there any other reason? what's wrong with > >> "a".ord() or str.from_ordinal(65))? > > > yes when you know other OO languages you expect this. Anyone know > > why builtins were chosen? Just curious > > *Maybe* for aesthetical reasons. ?I find ord(c) more pleasent for > the eye. ?YMMV. > > The biggest ugliness though is ",".join(). ?No idea why this should > be better than join(list, separator=" "). ? Seconded. While we're at it, a third optional 'encode=str' argument should be added, to the effect of: def join(iterable, sep=' ', encode=str): return sep.join(encode(x) for x in iterable) I can't count the times I've been bitten by TypeErrors raised on ','.join(s) if s contains non-string objects; having to do ','.join(map(str,s)) or ','.join(str(x) for x in s) gets old fast. "Explicit is better than implicit" unless there is an obvious default. George From aaron.watters at gmail.com Wed Apr 16 08:56:55 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 16 Apr 2008 05:56:55 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: On Apr 15, 12:30 am, Sverker Nilsson wrote: > No one forces me, but sooner or later they will want a Python 3.0 and > then a 3.1 whatever. > > I don't want that fuzz. As about the C versions, I am not that > worried. What's your point? > > I just like want to write a program that will stay working. Maybe I'll see the wisdom of py 3k eventually, if I don't die first, but I have to agree with Sverker's general comments. Just yesterday I had a conversation with someone who thinks maybe Ruby is better than Python -- the one really good argument Python has against nearly all contenders is all the stuff out there you can get so easily -- all the stuff that py3k will break -- most of which won't get ported -- and if it does can we be sure it will be tested properly? No, probably you will end up beta testing someone's quick port of what used to be rock solid code... This was quite rightly pointed out to me, and I had to agree that it was a pretty good point. In my opinion python's adherence to backwards compatibility has been a bit mythological anyway -- many new python versions have broken my old code for no good reason. This is an irritant when you have thousands of users out there who suddenly drop your code, blame you and python, and move on to use something else. Honestly, how hard would it have been to provide standard backwards support for the old regex module as a standard module which simply translated one regex string format to another, for example? I don't get it. It ain't broke. Don't fix it. At long last Python has a full head of steam and py3k is just confusing everyone. But I've been wrong before (twice). I also once thought generators were a mistake :) (but I still think full stackless would be much better, which python seems to be very slowly moving towards.....) -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=nonsense From george.sakkis at gmail.com Wed Apr 30 20:00:01 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 30 Apr 2008 17:00:01 -0700 (PDT) Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> <74c070ce-1b8f-4746-9d1c-ac2227aaf515@y21g2000hsf.googlegroups.com> Message-ID: <353ad234-1c1b-4224-90ab-4b5299532a91@k13g2000hse.googlegroups.com> On Apr 30, 3:53 pm, Mel wrote: > George Sakkis wrote: > > def join(iterable, sep=' ', encode=str): > > return sep.join(encode(x) for x in iterable) > > Actually > > return encode(sep).join(encode(x) for x in iterable) > > lest you get TypeErrors for non-string separators. Well separator is almost always a string literal or at least known to be a string, so that TypeError has never occured to me. George From mnordhoff at mattnordhoff.com Thu Apr 24 02:56:09 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Thu, 24 Apr 2008 06:56:09 +0000 Subject: library to do easy shell scripting in Python In-Reply-To: <480FEED6.8080309@gmail.com> References: <480FEED6.8080309@gmail.com> Message-ID: <48102F09.806@mattnordhoff.com> Wow, this message turned out to be *LONG*. And it also took a long time to write. But I had fun with it, so ok. :-) Michael Torrie wrote: > Recently a post that mentioned a recipe that extended subprocess to > allow killable processes caused me to do some thinking. Some of my > larger bash scripts are starting to become a bit unwieldy (hundreds of > lines of code). Yet for many things bash just works out so well because > it is so close to the file system and processes. As part of another > project, I now have need of a really good library to make it almost as > easy to do things in Python as it is in Bash. With a simple wrapper > around subprocess, I'm pretty much able to do most things. Most of my > complicated bash hackery involves using awk, sed, grep, and cut to > process text, which python does quite nicely, thank you very much. But > there's a few things to add. > > To wit, I'm wanting to write a library that can deal with the following > things: > > - spawn a process, feed it std in, get stdout, stderr, and err code. > This is largely already accomplished by subprocess It is accomplished by subprocess.Popen: The 'communicate' method handles stdin, stdout and stderr, waiting for the process to terminate. The 'wait' method just waits for the process to terminate and returns the return code. The 'returncode' attribute contains the return code (or None if the process hasn't terminated yet). You could write a convenience wrapper function if you want to do this in a more terse way. > - spawn off processes as background daemons Couldn't you do this with subprocess by doing subprocess.Popen([prog]) and, well, nothing else? (You may have/want to set stdin/stdout/stderr too. I dunno.) > - spawn multiple processes and pipe output to input. > - can do fancier things like bash does, like combine stderr/stdout, > switch stderr/stdout, redirects to and from files That's possible with subprocess. See this paragraph of : > stdin, stdout and stderr specify the executed programs' standard input, standard output and standard error file handles, respectively. Valid values are PIPE, an existing file descriptor (a positive integer), an existing file object, and None. PIPE indicates that a new pipe to the child should be created. With None, no redirection will occur; the child's file handles will be inherited from the parent. Additionally, stderr can be STDOUT, which indicates that the stderr data from the applications should be captured into the same file handle as for stdout. And also . Not the least verbose, but pretty simple, and I bet it can do anything bash can. > - transparently allow a python function or object to be a part of > the pipeline at any stage. Hmmm. I can't think very well at the moment, but you could create file-like objects that do...I dunno, callbacks or something. Simple and incomplete mockup: class Pipe(object): def __init__(self, from_fh, to_fh, from_callback=None, to_callback=None): self.from_fh = from_fh self.to_fh = to_fh self.from_callback = from_callback self.to_callback = to_callback def read(self, *args, **kwargs): data = self.from_fh.read(*args, **kwargs) if self.from_callback is not None: self.from_callback(data) return data def write(self, data): # XXX Call the callback before or after the data is actually written? if self.to_callback is not None: self.to_callback(data) return self.to_fh.write(data) That just passes input and output through itself, also passing it to callback functions. You'd have to add all the other methods too, like readline and __iter__... Maybe inheriting from 'file' would get most of them. I dunno how it works internally. > Questions include, how would one design the interface for things, like > assembling pipes? Several ideas include: > > pipe([prog1,args],[prog2,args],...) > > or > > run([prog1,args]).pipe([prog2,args]).pipe(...) > > The former doesn't deal very well with re-plumbing of the pipes, nor is > there an easy way to redirect to and from a file. The second syntax is > more flexible but a bit cumbersome. Also it doesn't allow redirection > or flexible plumbing either. > > Any ideas on how I could design this? Ok, the below is an edited-down, more formal-sounding brain dump. Idea 1: >>> run([prog, args], from_fh, to_fh, from_callback, to_callback).run(...) It would basically just automate the construction of the intermediary pipe objects suggested above. It could also be done with tuples, like: >>> run([prog, args], (from_fh, to_fh), (from_callback, to_callback)).run(...) Idea 2: This one would parse a list similar to a bash command line. run('prog', '>>out', '|', 'other_prog', 'arg', '>', 'foo.txt') Which would be like a bash: `prog 2>&1 | other_prog arg >foo.txt` ("2>&1" is how you combine stdout and stderr, right?) "<", ">", ">>" and "|" would be keywords that behave similarly to bash. You would use e.g. ['>', 'foo.txt'] to pass the argument to the keywords. Along with string filenames, it would accept file-like objects and file descriptors like subprocess.Popen does. ">>out", would be equivalent to bash's "2>&1". Similar things like ">err" would work too. They would be entirely separate keywords, not ['>>', 'out'] or something, so you could use "out" as the filename if you wanted to. If the last command in the pipeline didn't have its stdout and stderr redirected somewhere, their file objects would be returned. If you wanted them going to your regular stdout and stderr, I guess you would have to end the pipeline with [">out", ">>err"]. I just realized I made a mistake: In my keywords, I used ">x" for stdout and ">>x" for stderr. Bash uses ">x" and ">>x", and "2>x" and "2>>x", respectively. That could be changed, or we could just leave it all confusing-like. ;-) Idea 3: You could be dirty and just use os.system(). ;-) -- From cokofreedom at gmail.com Thu Apr 10 02:30:43 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Wed, 9 Apr 2008 23:30:43 -0700 (PDT) Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> <6641eaF2ics8jU1@mid.uni-berlin.de> <664j0pF2iji99U2@mid.uni-berlin.de> <89872ea1-dc03-4647-b0bc-9d316df3efb5@q1g2000prf.googlegroups.com> Message-ID: Umm, Mesopotamia is an area geographically located between the Tigris and Euphrates rivers, Bangalore isn't anywhere near that. And most of that is presently under American control. If you don't want to give out your code then try explaining it better. What is the input, what is the output, how are you currently processing. Describe these and people might be willing to aid more. Or complain more about how unhelpful people are. Suits us. From kst-u at mib.org Wed Apr 2 23:09:17 2008 From: kst-u at mib.org (Keith Thompson) Date: Wed, 02 Apr 2008 20:09:17 -0700 Subject: Recursive function won't compile References: <65iafeF2g9cvvU1@mid.uni-berlin.de> Message-ID: <87lk3v4ote.fsf@kvetch.smov.org> "Diez B. Roggisch" writes: >> #include >> #include >> >> def RecursiveFact(n): >> if(n>1): >> return n*RecursiveFact(n-1) >> else: >> return 1 >> >> fact = RecursiveFact(31) >> print fact >> >> fact = "End of program" >> print fact >> >> >> ......but yet it still gives the right answer. How is this possible? > > Given that you obviously don't use python, but some weird cross-breed > beteween python and C - who are we to judge the semantics of that > chimera? What do you mean? Aren't these: #include perfectly valid comments in Python? Followups redirected. -- Keith Thompson (The_Other_Keith) Nokia "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister" From alapidas at student.umass.edu Sat Apr 12 19:07:00 2008 From: alapidas at student.umass.edu (Andrew Lapidas) Date: Sat, 12 Apr 2008 19:07:00 -0400 Subject: PyGTK GUI update without signals from GUI Message-ID: Hi All: I am currently having a problem updating a GUI. I am using PyGTK and Glade to design an interface for a project. This interface contains no buttons, just images, labels, and a progress bar. The code for the project is small, and it basically does some things independent of the GUI in an infinite loop. I need the project code to update the GUI intermittently. I have found, though, that generally it seems that the gtk.main loop is looking for signals from the GUI and I cannot figure out how to give it signals from another application. I have thought spawning a new thread from the __init__ in the GUI and somehow having it send signals to gtk.main, but I do not know if this will work. Any opinions or ideas on this subject would be greatly appreciated. Thank you in advance, Andy From gagsl-py2 at yahoo.com.ar Sat Apr 5 01:15:10 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 05 Apr 2008 02:15:10 -0300 Subject: Pickle to Source - Gabriel Genellina? References: <163089.29394.qm@web65515.mail.ac4.yahoo.com> Message-ID: En Fri, 04 Apr 2008 22:47:47 -0300, $P!D3R DelSol escribi?: > I found this 3 year old message asking about doing the same exact thing > I am trying to do. This is one wheel I REALLY don't want to re-invent. > Can anyone point me to code that does this? > >> I want to convert from pickle format to python source code. That is, >> given an existing pickle, I want to produce a textual representation >> which, when evaluated, yields the original object (as if I had >> unpickled the pickle). See the answer from J P Calderone on that thread about aot in Twisted, that's the only thing I know of. I finally used an XML representation, somewhat legible by humans. -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Wed Apr 23 23:39:10 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 24 Apr 2008 00:39:10 -0300 Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> <56ebf54a-3a60-433f-b073-81963d9f1007@l64g2000hse.googlegroups.com> Message-ID: En Wed, 23 Apr 2008 08:43:56 -0300, Paul Boddie escribi?: > On 23 Apr, 11:12, Mark Wooding wrote: >> Gabriel Genellina wrote: >> > Because Python doesn't follow the "boxed variables" model. >> >> Be careful here. `Boxed types' or `boxed objects' is a technical term >> essentially meaning `heap-allocated objects, probably with reference >> semantics', which Python most definitely does use -- so this almost >> means the opposite of what you're talking about. > > I think Gabriel meant "variables as boxes" - the classic description > of variables in "old school" programming languages, which is in > contrast to the "variables as labels" model used by Python. Yes, I used the wrong expression here. Paul is right, I was thinking of "variables" as a "box" with a label written on it, and a value inside. That model is not valid in Python. -- Gabriel Genellina From urquhart.nak at gmail.com Wed Apr 30 06:27:29 2008 From: urquhart.nak at gmail.com (urquhart.nak at gmail.com) Date: Wed, 30 Apr 2008 03:27:29 -0700 (PDT) Subject: avg crack Message-ID: <60601d36-a21d-4b55-bce6-8c5525d32589@z24g2000prf.googlegroups.com> avg crack http://crack.cracksofts.com From sturlamolden at yahoo.no Thu Apr 17 12:48:42 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 17 Apr 2008 09:48:42 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> <87tzi05vrm.fsf@mulj.homelinux.net> Message-ID: On Apr 17, 5:46 pm, Hrvoje Niksic wrote: > Have you tackled the communication problem? The way I see it, one > interpreter cannot "see" objects created in the other because they > have separate pools of ... everything. They can communicate by > passing serialized objects through ctypes, but that sounds like the > solutions that use processes. I see two solutions to that. It is possible to use fine-grained locking on the objects that need to be communicated. ctypes can pass PyObject* pointers (ctypes.py_object), or we could resort to some C. When interpreter A get a PyObject* pointer from B (a total of four bytes on my computer), interpreter A can: (1) Acquire B's GIL (2) Increment the refcount of the PyObject* (3) Release B's GIL (4) Use the object as its own (synchronization is required) Sharing PyObject* pointer has the possibility of shooting your leg off. But I believe the small quirks can be worked out. The other option is to use serialized Queues like the processing module in cheese shop. I don't think it will be faster than similar mechanisms based on IPC, because object serialization and deserialization are the more expensive parts. From gherron at islandtraining.com Mon Apr 28 14:31:25 2008 From: gherron at islandtraining.com (Gary Herron) Date: Mon, 28 Apr 2008 11:31:25 -0700 Subject: list.reverse() In-Reply-To: References: Message-ID: <481617FD.7030702@islandtraining.com> Mark Bryan Yu wrote: > This set of codes works: > > >>>> x = range(5) >>>> x.reverse() >>>> x >>>> > [4, 3, 2, 1, 0] > > But this doesn't: > > >>>> x = range(5).reverse() >>>> print x >>>> > None > > Please explain this behavior. range(5) returns a list from 0 to 4 and > reverse just reverses the items on the list that is returned by > range(5). Why is x None (null)? > -- > http://mail.python.org/mailman/listinfo/python-list > Because you are misusing reverse. It is an operation on a list that reverses the list in place. It is meant to be used only in the situation where you already have the list and want to reorder it: x = .... list ... x.reverse() # reorders, but returns nothing ... now use x ... You might look at the builtin reversed(list): http://www.python.org/doc/faq/programming/#how-do-i-iterate-over-a-sequence-in-reverse-order Gary Herron From sjmachin at lexicon.net Thu Apr 17 19:50:18 2008 From: sjmachin at lexicon.net (John Machin) Date: Thu, 17 Apr 2008 23:50:18 GMT Subject: get quote enclosed field in a line In-Reply-To: References: Message-ID: <4807e238$1@news.mel.dft.com.au> xahlee at gmail.com wrote: > is there a simple way in perl, python, or awk/shell/pipe, that gets > the user agent field in a apache log? > > e.g. the typical line is like this: > > 189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET / > Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org > "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/ > 5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311 > Firefox/2.0.0.13" "-" > > I want the part: "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv: > 1.8.1.13) Gecko/20080311 Firefox/2.0.0.13". > C:\junk>type xah.py import cStringIO, csv, pprint line = '''189.139.109.235 - etc etc etc''' f = cStringIO.StringIO(line) reader = csv.reader(f, delimiter=" ") row = reader.next() pprint.pprint(row) C:\junk>xah.py ['189.139.109.235', '-', '-', '[07/Apr/2008:00:00:16', '-0400]', 'GET / Periodic_dosage_dir/lacru/manara.html HTTP/1.1', '200', '1933', 'xahlee.org', 'http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311 Fi refox/2.0.0.13', '-'] If you don't like that, just hang about -- there's sure to be a pyparsing bus coming by real soon now :-) Cheers, John From bhawsar.vaibhav at gmail.com Fri Apr 25 13:16:11 2008 From: bhawsar.vaibhav at gmail.com (Vaibhav.bhawsar) Date: Fri, 25 Apr 2008 13:16:11 -0400 Subject: how to mysqldb dict cursors In-Reply-To: References: <17d58cc40804241950i7b624e1apd2733daa79b3ed5c@mail.gmail.com> <481161FD.5020407@ulmcnett.com> <17d58cc40804242358s26446c42h36f875cf0ee62199@mail.gmail.com> Message-ID: <17d58cc40804251016x7fc0f2far816c0bb09bbebd80@mail.gmail.com> Hmm that explains it! Thank you. v On Fri, Apr 25, 2008 at 7:38 AM, Steve Holden wrote: > Vaibhav.bhawsar wrote: > [top-posting amended: see below] > >> On Fri, Apr 25, 2008 at 12:45 AM, Paul McNett

> p at ulmcnett.com>> wrote: >> >> Vaibhav.bhawsar wrote: >> >> I have been trying to get the DictCursor working with mysqldb >> module but can't seem to. I have pasted the basic connection >> code and the traceback from pydev. The connection does open with >> the default cursor class. can't figure this one out. many thanks. >> >> >> Try one of: >> >> """ >> import MySQLdb, MySQLdb.cursors >> conn = MySQLdb.connect(..., cursorclass=MySQLdb.cursors.DictCursor) >> """ >> >> -or- >> >> """ >> import MySQLdb, MySQLdb.cursors >> conn = MySQLdb.connect(...) >> cur = MySQLdb.cursors.DictCursor(conn) >> """ >> >> I'm going off of memory here, though, but I'm at least close. >> >> > Great both methods worked! I don't quite understand this since i > imported > > the whole module with "import MySQLdb" > > > > Thanks! > > > The point here is that MySQLdb is a package, not a module. Some packages > have their top-level __init__.py import the package's sub-modules or > sub-packages to make them immediately available within the package namespace > (which is why, for example, you can access os.path.* when you have imported > os) and others don't. > > MySQLdb clearly doesn't need to import the cursors module for its own > purposes. Perhaps it would be less efficient to always perfrom the import, > who knows. Well, Andy Dustman does, I suppose, and possibly anyone else who > reads the code, but I haven't done that myself. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Vaibhav Bhawsar -------------- next part -------------- An HTML attachment was scrubbed... URL: From frikker at gmail.com Wed Apr 30 10:19:49 2008 From: frikker at gmail.com (blaine) Date: Wed, 30 Apr 2008 07:19:49 -0700 (PDT) Subject: list.reverse() References: <4816e26a$0$30938$426a74cc@news.free.fr> <98c4ad4d-3174-40cd-b281-84e318d699d3@24g2000hsh.googlegroups.com> Message-ID: On Apr 29, 8:51 pm, Roy Smith wrote: > In article > <98c4ad4d-3174-40cd-b281-84e318d69... at 24g2000hsh.googlegroups.com>, > > blaine wrote: > > Check out this cool little trick I recently learned: > > >>> x=range(5) > > >>> x.reverse() or x > > [4, 3, 2, 1, 0] > > > Useful for returning lists that you need to sort or reverse without > > wasting that precious extra line :) > > > What it does: x.reverse() does the reverse and returns None. or is > > bitwise, so it sees that 'None' is not 'True' and then continues to > > process the next operand, x. x or'd with None will always be x (and x > > has just been changed by the reverse()). So you get the new value of > > x :) > > Please don't do that in any code I have to read and understand. Cool > little tricks have no place in good code. > > >>> x = range(5) > >>> x.reverse() > >>> x > > [4, 3, 2, 1, 0] > > does the same thing, and it a lot easier to understand. I buy my newlines > in the big box at Costo, so I don't mind using a few extra ones here or > there. haha true - i usually don't use shortcuts, it kind of defeats the purpose of the readability of python :) From Robert.Bossy at jouy.inra.fr Mon Apr 7 12:55:14 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Mon, 07 Apr 2008 18:55:14 +0200 Subject: reading dictionary's (key,value) from file In-Reply-To: <974814d3-59f0-49ec-9b4d-9f5dd7dfaf54@q24g2000prf.googlegroups.com> References: <974814d3-59f0-49ec-9b4d-9f5dd7dfaf54@q24g2000prf.googlegroups.com> Message-ID: <47FA51F2.2040101@jouy.inra.fr> ankitks.mital at gmail.com wrote: > Folks, > Is it possible to read hash values from txt file. > I have script which sets options. Hash table has key set to option, > and values are option values. > > Way we have it, we set options in a different file (*.txt), and we > read from that file. > Is there easy way for just reading file and setting options instead of > parsing it. > > so this is what my option files look like: > > 1opt.txt > { '-cc': '12', > '-I': r'/my/path/work/'} > > 2opt.txt > { '-I': r/my/path/work2/'} > > so my scipt how has dictionary > options = { '-cc' :'12' > '-I': r'/my/path/work/:/my/path/work2/'} > > I am trying to avoid parsing > For this particular case, you can use the optparse module: http://docs.python.org/lib/module-optparse.html Since you're obviously running commands with different set of options, I suggest you listen to Diez. Cheers, RB From soray6034rao at gmail.com Wed Apr 30 07:28:44 2008 From: soray6034rao at gmail.com (soray6034rao at gmail.com) Date: Wed, 30 Apr 2008 04:28:44 -0700 (PDT) Subject: the sims 2 crack Message-ID: the sims 2 crack http://crack.cracksofts.com From paul at science.uva.nl Tue Apr 29 07:18:32 2008 From: paul at science.uva.nl (Paul Melis) Date: Tue, 29 Apr 2008 13:18:32 +0200 Subject: SWIG Python undefined reference In-Reply-To: <23b925ce-cfa5-4a99-bad3-afcac09b645a@y21g2000hsf.googlegroups.com> References: <23b925ce-cfa5-4a99-bad3-afcac09b645a@y21g2000hsf.googlegroups.com> Message-ID: Instead of manually trying to get all the options to gcc correct you might want to look at using distutils for compiling your extension. See the SWIG documentation, section 30.2.2 (http://www.swig.org/Doc1.3/Python.html#Python_nn6) Paul Soren wrote: > Hi, > > I went through the SWIG tutorial for the example named "simple". > > I managed to get to the first step, creating example_wrap.c using > swig, and doing: > "gcc -fpic -c example_wrap.c -IC:\python24\include " to create > example_wrap.o > > But when I needed to compile the library file using: > "gcc -shared example_wrap.o -o examplemodule.so" I received a lot of > undefined reference compiler errors like: > > example_wrap.o(.text+0x35a5):example_wrap.c: undefined reference to > `_imp__PyErr > _SetString' > > there are many other similar errors all prefaced with _imp__Py, so I > am assuming there is a linker error with the python libraries. I have > adjusted my PATH variable to include all the python directories (libs/ > dlls). > > Does anyone here have any suggestions? > > FILES FROM TUTORIAL: > > > //example.c > #include > double My_variable = 3.0; > > int fact(int n) { > if (n <= 1) return 1; > else return n*fact(n-1); > } > > int my_mod(int x, int y) { > return (x%y); > } > > char *get_time() > { > time_t ltime; > time(<ime); > return ctime(<ime); > } > //*************************************************************** > > //example.i > %module example > %{ > /* Put header files here or function declarations like below */ > extern double My_variable; > extern int fact(int n); > extern int my_mod(int x, int y); > extern char *get_time(); > %} > > extern double My_variable; > extern int fact(int n); > extern int my_mod(int x, int y); > extern char *get_time(); > //*************************************************************** > > //setup.py > from distutils.core import setup, Extension > > setup(name='example', > version = '1.0', > ext_modules=[ > Extension('example', ['example.c', 'example.i']) > ]) From pavlovevidence at gmail.com Tue Apr 22 09:38:10 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 22 Apr 2008 06:38:10 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: On Apr 22, 6:25 am, azrael wrote: > Hy guys, > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. > > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" > > This hurts. Please give me informations about realy famous > aplications. Let me tell you a little story to let you know how you should act in situations like this. Some of you might have heard it before. Apologies if it's a bit long. There was once a young man who absolutely loved clowns. He always dreamed of meeting a clown, and laughing at their silly antics, but he lived in a rural small town and never got to see any. Then one day when the circus came to town. The young man was unbelievably excited, he was finally going to be able to see a clown! He camped out at the ticket booth and was the first in line to get a ticket, because he so loved clowns that he wanted to sit right up front. The yound man never had a better time in his life, watching all the clowns and their funny tricks. Then a young talented clown came out to work the crowd. He went right up to the young man, who couldn't believe his luck: a clown was doing his act with him! The clown asked the man, "Are you front end of an ass?" The young man said, "Um, no." Then the clown asked the man, "Are you the rear end of an ass?" The young man, a little confused, said, "No." Then the clown, with nearly perfect comedic timing, said, "Then you must be no end of an ass!" The crowd roared with laughter, but the young man was crushed. He couldn't believe that the clowns he adored so much could be so mean. He went home from the circus utterly distraught and humiliated, and soon fell into a deep depression. He eventually lost his job, then his home. He became a vagrant and spent his days living on the streets. The years passed by. One day, the now old man saw that the circus was coming back to town. And not only that, but the same clown who had humiliated him years ago was headlining the circus. It brought back terrible and long- suppressed memories, which he told to a social worker at the homeless shelter he was staying at. The social worker felt very moved by the old man's story, and told the old man, "You know, maybe you could overcome with your problems if you could face that clown again and give him his comeupance." The old man was horrified. After the incident he had developed an intense fear of clowns. Yet he somehow felt the social worker was right. "I'd like to do that," he said, "but what if the clown humilates me again?" "Don't worry," said the social worker, "I have the perfect retort." So the social worker and the old man bought front row seats to the circus. Within a few minutes, the old man was enjoying himself immensely. It was the best therapy he'd ever had, and the old man felt that after so many years he would finally be able to put his life back together. Until the final act. The same clown who had humiliated the old man many years before was now an old veteran on his final tour. The clown went right up to the old man and began to work the same routine. ("Don't worry," whispered the social worker to he old man as the clown approached, "I have perfect retort.") The clown asked the old man, "Are you front end of an ass?" The old man said, "No." Then the clown asked the old man, "Are you the rear end of an ass?" The old man, positively scared, meekly said, "No." Then the clown, with utterly perfect comedic timing, said, "Then you must be no end of an ass!" The crowd roared with laughter. The man was humiliated again. But the social winked at him, indicating that he would soon give the clown the perfect retort. The old man couldn't wait to hear what it was. Suddenly the social worker stood up and shouted, "Hey clown!" The crowd hushed, and clown whirled around to look at him. "F**k you!" (It makes even more sense when you consider that Perl programmers pretty much are clowns.) Carl Banks From upton at virginia.edu Wed Apr 16 15:06:55 2008 From: upton at virginia.edu (Dan Upton) Date: Wed, 16 Apr 2008 15:06:55 -0400 Subject: Interesting timing issue I noticed In-Reply-To: References: Message-ID: <5504f9ac0804161206tb4b0d0dl423176dddf70d6ce@mail.gmail.com> On Wed, Apr 16, 2008 at 2:54 PM, Gabriel Genellina wrote: > En Wed, 16 Apr 2008 10:36:14 -0300, Jonathan Shao > escribi?: > > *Gabriel Genellina* gagsl-py2 at yahoo.com.ar > > > > *Wed Apr 16 08:44:10 CEST 2008* > > >> Another thing would be to rearrange the loops so the outer one executes > > less times; if you know that borderX< > better to swap the inner and outer loops above. > > Thank you for the tip on xrange. > > Even if I swap the inner and outer loops, I would still be doing the same > > number of computations, am I right (since I still need to go through the > > same number of elements)? I'm not seeing how a loop swap would lead to > > fewer > > computations, since I still need to calculate the outer rim of elements > > in > > the array (defined by borderX and borderY). > > You minimize the number of "for" statements executed, and the number of > xrange objects created. Both take some time in Python. > > > import timeit > > f1 = """ > for i in xrange(10): > for j in xrange(1000): > i,j > """ > > f2 = """ > for j in xrange(1000): > for i in xrange(10): > i,j > """ > > print timeit.Timer(f1).repeat(number=1000) > print timeit.Timer(f2).repeat(number=1000) > > > Output: > [2.0405478908632233, 2.041863979919242, 2.0397852240997167] > [2.8623411634718821, 2.8330055914927783, 2.8361752680857535] > > The second (using the largest outer loop) is almost 40% slower than the > first one. "Simplified" Big-Oh complexity analysis isn't enough in cases > like this. > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > For large multidimensional arrays you may also see speed differences depending on traversal order due to cache effects. For instance, if the arrays are stored row-major, then processing an array a row at a time means you're getting a bunch of memory accesses contiguous in memory (so the cache loading a line at a time means you'll have several hits per one load), while accessing it by column means you'll probably have to go out to memory a lot (depending on whether the hardware has a prefetcher or how good it is, I suppose). Just something to consider. From marli305nugent at gmail.com Sat Apr 26 09:53:41 2008 From: marli305nugent at gmail.com (marli305nugent at gmail.com) Date: Sat, 26 Apr 2008 06:53:41 -0700 (PDT) Subject: xp password crack Message-ID: xp password crack http://cracks.00bp.com F R E E C R A C K S From python at bdurham.com Tue Apr 29 08:10:41 2008 From: python at bdurham.com (python at bdurham.com) Date: Tue, 29 Apr 2008 08:10:41 -0400 Subject: Given a string - execute a function by the same name Message-ID: <1209471041.12820.1250459017@webmail.messagingengine.com> Bruno, Thank you for your detailed analysis. I learned a lot about Python reading everyone's responses. For development I'm using #5: "globals().get("func")" because its seamless to add additional functionality. But when I release into production I'm going to shift to #3: "Place all my functions in dictionary and lookup the function to be called". This technique will allow me to precisely control the dynamic nature of my application. Thanks again to everyone who contributed on this thread. Regards, Malcolm From phil at riverbankcomputing.com Fri Apr 11 04:10:27 2008 From: phil at riverbankcomputing.com (Phil Thompson) Date: Fri, 11 Apr 2008 09:10:27 +0100 Subject: How is GUI programming in Python? In-Reply-To: References: <7xod8h39zu.fsf@ruckus.brouhaha.com> Message-ID: <200804110910.27091.phil@riverbankcomputing.com> On Friday 11 April 2008, David Cook wrote: > On 2008-04-10, Paul Rubin wrote: > > Well, it's a trade-off, the person wanted a cross platform gui and the > > #1 hurdle for something like PyQt4 is getting it to work on each of > > the platforms you desire to run on. > > Installing Pyqt on windows involves a couple "click to install" EXEs. On > Linux, one uses yum or apt. Only on Mac is it marginally a bit harder. > > Dave Cook Actually, on Windows it's only one .exe as the PyQt GPL binary installer includes Qt and all it's tools (and the eric IDE, and PyQwt). Phil From laurent.pointal at laposte.net Tue Apr 1 16:06:32 2008 From: laurent.pointal at laposte.net (Laurent Pointal) Date: 01 Apr 2008 20:06:32 GMT Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: <47f295c8$0$868$ba4acef3@news.orange.fr> Le Tue, 01 Apr 2008 12:35:46 -0700, Paddy a ?crit?: > On Apr 1, 6:27 pm, sprad wrote: >> >> I want to believe. Evangelize away. > > How proficient are you in Flash/Actionscript? I suggest you try out > Python/Pygame and extrapolate from that, given your available time, > would you be proficient enough to teach it? And if you want to do easy and simple 3D graphics programming, look at VPython http://www.vpython.org/ -- Laurent POINTAL - laurent.pointal at laposte.net From sashulika at gmail.com Sun Apr 6 08:38:37 2008 From: sashulika at gmail.com (LMZ) Date: Sun, 6 Apr 2008 05:38:37 -0700 (PDT) Subject: Form sha1.hexdigest to sha1.digest Message-ID: <7c39af89-9cee-428c-a0bc-8202700c5aec@b1g2000hsg.googlegroups.com> How can convert string from sha1.hexdigest() to string that is the same, like from sha1.digest() thanks for your help! Alexandr. From mccle27252 at gmail.com Mon Apr 21 03:53:30 2008 From: mccle27252 at gmail.com (mccle27252 at gmail.com) Date: Mon, 21 Apr 2008 00:53:30 -0700 (PDT) Subject: mystery case files huntsville 1.6 keygen Message-ID: <91f2262d-e941-41a8-87c5-e92e3b9eb3f1@i36g2000prf.googlegroups.com> mystery case files huntsville 1.6 keygen http://cracks.00bp.com F R E E C R A C K S From micro_passion at yahoo.com Fri Apr 25 08:30:18 2008 From: micro_passion at yahoo.com (micron_make) Date: Fri, 25 Apr 2008 05:30:18 -0700 (PDT) Subject: multiple pattern regular expression Message-ID: <16895148.post@talk.nabble.com> I am trying to parse a file whose contents are : parameter=current max=5A min=2A for a single line I used for line in file: print re.search("parameter\s*=\s*(.*)",line).groups() is there a way to match multiple patterns using regex and return a dictionary. What I am looking for is (pseudo code) for line in file: re.search("pattern1" OR "pattern2" OR ..,line) and the result should be {pattern1:match, pattern2:match...} Also should I be using regex at all here ? -rohit -- View this message in context: http://www.nabble.com/multiple-pattern-regular-expression-tp16895148p16895148.html Sent from the Python - python-list mailing list archive at Nabble.com. From bj_666 at gmx.net Sun Apr 20 05:37:13 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 20 Apr 2008 09:37:13 GMT Subject: ???Python Memory Management S***s??? References: Message-ID: <670h69F2m6j0tU1@mid.uni-berlin.de> On Sun, 20 Apr 2008 18:40:26 +1000, Hank @ITGroup wrote: > In order to evaluate the memory operation, I used the codes below: > > """ > > string1 = ['abcde']*999999 # this took up an obvious memory space... > > del string1 # this freed the memory > successfully !! Indirectly. ``del`` does not delete objects but just names, so you deleted the name `string1` and then the garbage collector kicked in and freed the list object as it was not reachable by other references anymore. > """ > For primary variants, the *del* thing works well. However, challenge the > following codes, using class-instances... > > """ > > from nltk import FreqDist # nltk stands for Natural Language Tool > Kit (this is not an advertisement ~_~) > > instance = FreqDist() > > instanceList = [instance]*99999 > > del instanceList # You can try: nothing is freed by this > """ How do you know this? And did you spot the difference between 999999 and 99999!? Are you aware that both lists contain many references to a *single* object, so the memory consumption has very little to do with the type of object you put into the list? In the second case you still hold a reference to that single instance though. Ciao, Marc 'BlackJack' Rintsch From grante at visi.com Sun Apr 20 20:07:28 2008 From: grante at visi.com (Grant Edwards) Date: Sun, 20 Apr 2008 19:07:28 -0500 Subject: replacing text inplace References: Message-ID: <5tqdnSsck5hdR5bVnZ2dnUVZ_j-dnZ2d@visi> On 2008-04-20, Matt Herzog wrote: > I'm learning some python with the seemingly simple task of > updating a firewall config file with the new IP address when > my dhcpd server hands one out. Yeah, I know it's dangerous to > edit such a file "in place" I don't see how what you're doing is editing a file "in place". > but this is just an exercise at this point. I would not mind > using file handles except they seem to add complexity. Do you mean file objects? > The only apparent problem I have with my script so far is that > it's adding lots of blank lines to the file when it updates > the IP addresses. When you do this: for line in inputfile: Each instance of 'line' has a newline at the end of it. When you do this: print line The print operation adds another newline. Try it this way: print line, The comma tells print not to append a newline after it has printed "line". > So "71.146.250.258" needs to change to "71.146.250.223" or something similar. > > Is there a saner, cleaner way to do this that won't add new, > blank lines? sed -i s/71.146.250.258/71.146.250.223/g filename I suppose one probably should escape the dots in the input regex... -- Grant Edwards grante Yow! With YOU, I can be at MYSELF ... We don't NEED visi.com Dan Rather ... From gert.cuykens at gmail.com Wed Apr 30 07:04:45 2008 From: gert.cuykens at gmail.com (gert) Date: Wed, 30 Apr 2008 04:04:45 -0700 (PDT) Subject: ssh References: <867f5bc7-3748-4303-9f29-9d8044f0d315@m3g2000hsc.googlegroups.com> Message-ID: Eric Wertman wrote: > >from popen2 import Popen3 > >def ssh(host,command) : > ''' Wraps ssh commands ''' > ssh_exec = ['/usr/bin/ssh -qnx -F ssh_config', host, command] > cmd = ' '.join(ssh_exec) > output,errors,status = process(cmd) > return output,errors,status > >def process(cmd) : > proc = Popen3(cmd,-1) > output = proc.fromchild.readlines() > errors = proc.childerr.readlines() > status = proc.poll() > return output,errors,status thanks, what happens with the ssh connection after def process(cmd) is done Do i not need to remove the 'else' for it to work ? Also can i execute multiple commands at once ? import os, time def ssh(user, rhost, pw, cmd): pid, fd = os.forkpty() if pid == 0: os.execv("/bin/ssh", ["/bin/ssh", "-l", user, rhost] + cmd) time.sleep(0.2) os.read(fd, 1000) time.sleep(0.2) os.write(fd, pw + "\n") time.sleep(0.2) res = '' s = os.read(fd, 1) while s: res += s s = os.read(fd, 1) return res print ssh('username', 'serverdomain.com', 'Password', ['ls -l']) From fairwinds at eastlink.ca Mon Apr 7 01:32:01 2008 From: fairwinds at eastlink.ca (David Pratt) Date: Mon, 07 Apr 2008 02:32:01 -0300 Subject: Help replacing os.system call with subprocess call Message-ID: <47F9B1D1.4090701@eastlink.ca> Hi. I am trying to replace a system call with a subprocess call. I have tried subprocess.Popen and subprocess.call with but have not been successful. The command line would be: svnadmin dump /my/repository > svndump.db This is what I am using currently: os.system('svnadmin dump %s > %s' % (svn_dir, os.path.join(backup_dir, 'svndump.db'))) Many thanks. From bressert at gmail.com Wed Apr 16 02:45:18 2008 From: bressert at gmail.com (eli) Date: Tue, 15 Apr 2008 23:45:18 -0700 (PDT) Subject: subplot function in matplotlib Message-ID: <368ac3ca-ed20-494d-9f09-00d06701857d@k37g2000hsf.googlegroups.com> Does anyone know a workaround to plotting beyond 9 subplots in matplotlib? It would be nice to have 20 plots under the subplot function for example (poster). Cheers, Eli From cokofreedom at gmail.com Wed Apr 2 09:19:08 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Wed, 2 Apr 2008 06:19:08 -0700 (PDT) Subject: who said python can't be obsfucated!? Message-ID: def s(c):return[]if c==[]else s([_ for _ in c[1:]if _=c[0]]) Anyone else got some wonders...? From steve at holdenweb.com Fri Apr 25 00:37:11 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 25 Apr 2008 00:37:11 -0400 Subject: Installation in a local directory In-Reply-To: <2008042500101716807-seanmmcdaniel@gmailcom> References: <2008042500101716807-seanmmcdaniel@gmailcom> Message-ID: Sean McDaniel wrote: > Hi y'all, > > I'm trying to perform a local install of python at work in my user > directory. Everything compiles correctly, but I can't seem to tell the > configure script the location of the bin and lib directories where I > want my stuff. I've think I've passed the correct flags to the > 'configure' script. > > make clean > ./configure --enable-shared --prefix=/user/mcdaniel/arch32 > make > > where arch32 contains the the lib and bin directories where I want my > python stuff to go. Unfortunately these directories are not written to; > everything ends up in the default location from where I ran 'make'. > Moreover, if I add a symbolic link from the python binary (which I can > run directly without problems) to the bin directory so that my PATH will > recognize the new python, I get an error about loading shared libraries. > > I'm making on a 32 bit new debian system. > > Thank you for your help, > Did you run "make install" yet? It's that step that moves the binaries to where they should live. As it says in http://www.python.org/download/releases/2.5/ """Change to the Python-2.5 directory and run the "./configure", "make", "make install" commands to compile and install Python.""" regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bikthh at live.cn Sun Apr 13 03:18:14 2008 From: bikthh at live.cn (bikthh at live.cn) Date: Sun, 13 Apr 2008 00:18:14 -0700 (PDT) Subject: =?GB2312?B?09DW0Ln6yMu69T8=?= Message-ID: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> Python????????????????. From sturlamolden at yahoo.no Sun Apr 20 20:35:31 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sun, 20 Apr 2008 17:35:31 -0700 (PDT) Subject: Nested lists, simple though References: Message-ID: On Apr 21, 12:25 am, Zethex wrote: > Anyway the amount of [[]] do increase over time. You can flatten a nested list using a closure and recursion: def flatten(lst): tmp = [] def _flatten(lst): for elem in lst: if type(elem) != list: tmp.append(elem) else: _flatten(elem) _flatten(lst) return tmp However, CPython does not recurse very fast, but Cython and Pyrex do. First, get rid of the closure, it is not supported in Cython or Pyrex (at least not yet). Then change the recursive function to a cdef, i.e. a normal C function which is called without the overhead of Python's attribute lookup: cdef _flatten(lst, tmp): for elem in lst: if type(elem) != list: tmp.append(elem) else: _flatten(elem, tmp) def flatten(lst): tmp = [] _flatten(lst, tmp) return tmp Compile this with Cython or Pyrex, and you get a very fast nested list flattener. This also shows how easy it is to boost the performance of Python code using Cython. From bdsatish at gmail.com Fri Apr 11 00:28:36 2008 From: bdsatish at gmail.com (bdsatish) Date: Thu, 10 Apr 2008 21:28:36 -0700 (PDT) Subject: Integer dicision Message-ID: <5f499bee-a659-4e36-870c-076cb613a3e7@t12g2000prg.googlegroups.com> How does (a/b) work when both 'a' and 'b' are pure integers ? >> (9/2) 4 >> (-9/2) -5 Why is it -5 ? I expect it to be -4 ? Because, in C/C++, 9/2 is 4 and so negative of it, (-9/2) is -4. What should I do to get C-like behavior ? From Lie.1296 at gmail.com Tue Apr 29 18:19:32 2008 From: Lie.1296 at gmail.com (Lie) Date: Tue, 29 Apr 2008 15:19:32 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <2d06b319-e2fd-4790-af61-6f90b9b1b3b1@m1g2000pre.googlegroups.com> <41e72e61-6413-41f3-a162-dbcc1ec5fcee@f63g2000hsf.googlegroups.com> Message-ID: On Apr 28, 2:14?am, n00m wrote: > Lie wrote: > > On Apr 27, 6:28?am, n00m wrote: > > > No so simple, guys. > > > E.g., I can't solve (in Python) this:http://www.spoj.pl/problems/INTEST/ > > > Keep getting TLE (time limit exceeded). Any ideas? After all, it's > > > weekend. > > > > 450. Enormous Input Test > > > Problem code: INTEST > > > > The purpose of this problem is to verify whether the method you are > > > using to read input data is sufficiently fast to handle problems > > > branded with the enormous Input/Output warning. You are expected to be > > > able to process at least 2.5MB of input data per second at runtime. > > > > Input > > > The input begins with two positive integers n k (n, k<=107). The next > > > n lines of input contain one positive integer ti, not greater than > > > 109, each. > > > > Output > > > Write a single integer to output, denoting how many integers ti are > > > divisible by k. > > > > Example > > > Input: > > > 7 3 > > > 1 > > > 51 > > > 966369 > > > 7 > > > 9 > > > 999996 > > > 11 > > > > Output: > > > 4 > > > The problem is faulty. > > First, the bottleneck on reading a huge input is the harddisk speed > > and the string processing, the result of the competition doesn't prove > > anything but how fast the string processor and the harddisk is. > > Python's string processing is not a very fast one as it creates a copy > > of the string every now and then. > > In case you didn't pay attention: > Python and C++ were tested on the same PC. In case you didn't pay attention, what I'm mainly concerned about is running the same algorithm in the same machine in the same programming language but in different phase of the moon that would give two significantly different timing. Harddisk seek time is based on harddisk's fragmentation, MFT's (or equivalent) size, what "other" program are currently doing with the harddisk, and by harddisk age. You can't avoid fragmentation, except if you ghosted the harddisk and reinstall the OS after every test. You can't prevent the OS to switch to other tasks while the test is running they might possibly requested for a huge harddisk query. And I'm sure you can't prevent hardware degradation (although the impact of this is probably not significant). Heck I can go on to other phases of the moon like how full and fragmented the memory (RAM) is, how much swap is being used. My secondary concern, is how the string processing is done in the language. In python, every string operation creates a new string, in C, a string processing is just a mere address passing, for this test, the security given by python is unnecessary since it is read only. We know which one is the more superior in speed, but we can't do anything about this since this is implementation detail of the language. From van.lindberg at gmail.com Thu Apr 24 18:37:06 2008 From: van.lindberg at gmail.com (VanL) Date: Thu, 24 Apr 2008 17:37:06 -0500 Subject: Billing system written in python In-Reply-To: <40847e660804240833q4e4210dyb8a561899635fb77@mail.gmail.com> References: <40847e660804240833q4e4210dyb8a561899635fb77@mail.gmail.com> Message-ID: <48110B92.4070609@gmail.com> AC Perdon wrote: > I was thinking of using django but Im more looking in to a > ready made billing system that I will just do some tweaking and fine > tunning to meet our need. like jbilling. Look at Fivedash (fivedash.com), it may be what you need. From rridge at caffeine.csclub.uwaterloo.ca Fri Apr 18 21:36:05 2008 From: rridge at caffeine.csclub.uwaterloo.ca (Ross Ridge) Date: Fri, 18 Apr 2008 21:36:05 -0400 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> Message-ID: Ross Ridge said: > If you have Python 2.5, here's a faster version: > > from struct import * > unpack_i32be = Struct(">l").unpack > > def from3Bytes_ross2(s): > return unpack_i32be(s + "\0")[0] >> 8 Bob Greschke wrote: > That's not even intelligible. I wanna go back to COBOL. :) It's the same as the previous version except that it "precompiles" the struct.unpack() format string. It works similar to the way Python handles regular expressions. Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] rridge at csclub.uwaterloo.ca -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // From rustompmody at gmail.com Sun Apr 27 23:40:26 2008 From: rustompmody at gmail.com (rustom) Date: Sun, 27 Apr 2008 20:40:26 -0700 (PDT) Subject: diffing and uniqing directories References: <67ioqmF2nvf5vU2@mid.uni-berlin.de> Message-ID: On Apr 27, 11:29?pm, "telus news" wrote: > Just so happens that I am partially finished a gui file backup app. I have > many backup CDs and I wanted to consolidate them. You know, all image files > in one dir, all install files in another dir, etc. My app scans the input > dir tree and displays all file extensions that it finds. You can then remove > any extensions that you don't want backed-up, and you can toggle to exclude > the listed extensions. It also calculates min/max file sizes that you can > adjust. I guess what I am looking for is a merge app more than a backup app. > > Then the next page allows you to adjust the sub-dir depth with a slider, > which displays the total number of files and total amount of memory they > will take, for each sub-dir depth. You can also choose to enable versioning, > whether or not to put all files into one dir or create a dir for each file > type (extension), whether or not to actually backup the files, to write all > input pathnames and/or output pathnames to a file. Of course, it won't > backup a dir tree as a copy, it can only flatten a dir tree, That wont do for me. > so if you > backup a development source dir, all files will get put into the same dir > and that wouldn't be good. > > I've also used py2exe to make it a drag-n-drop install. What do you think? Im working (mostly) on linux From wizzardx at gmail.com Tue Apr 15 16:02:55 2008 From: wizzardx at gmail.com (David) Date: Tue, 15 Apr 2008 22:02:55 +0200 Subject: Recurring patterns: Am I missing it, or can we get these added to the language? In-Reply-To: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: <18c1e6480804151302j2b6a981cs1f880c09520bd17c@mail.gmail.com> > Today I found myself once again defining two functions that I use all > the time: nsplit and iterable. These little helper functions of mine > get used all the time when I work. Im sick of having to define them > (but am very good at it these days, less than 1 typo per function!). > It leads me to the following questions How about creating an erichtools module? From gagsl-py2 at yahoo.com.ar Fri Apr 11 16:29:03 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 11 Apr 2008 13:29:03 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> Message-ID: On 11 abr, 15:33, Lie wrote: > On Apr 11, 10:19 pm, Mikael Olofsson wrote: > > That's exactly how I was taught to do rounding in what-ever low-level > > class it was. The idea is to avoid a bias, which assumes that the > > original values are already quantized. Assume that we have values > > quantized to one decimal only, and assume that all values of this > > decimal are equally likely. Also assume that the integer part of our > > numbers are equally likely to be even or odd. Then the average rounding > > error when rounding to integers will be 0.05 if you always round up when > > the decimal is 5. If you round towards an even number instead when the > > decimal is 5, then you will round up half of those times, and round down > > the other half, and the average rounding error will be 0. That's the > > idea. Of course you could argue that it would be even more fair to make > > the choice based on the tossing of a fair coin. > > That old-school rounding method you're taught is based on a wrong > assumption of the nature of number. In the past, rounding algorithm is > based on this: > > Original => (RoundUp(u|d|n), RoundNearestEven(u|d|n) > ... > 1.0 => 1(n), 1(n) > 1.1 => 1(d), 1(d) > 1.2 => 1(d), 1(d) > 1.3 => 1(d), 1(d) > 1.4 => 1(d), 1(d) > 1.5 => 2(u), 2(u) > 1.6 => 2(u), 2(u) > 1.7 => 2(u), 2(u) > 1.8 => 2(u), 2(u) > 1.9 => 2(u), 2(u) > 2.0 => 2(n), 2(n) > 2.1 => 2(d), 2(d) > 2.2 => 2(d), 2(d) > 2.3 => 2(d), 2(d) > 2.4 => 2(d), 2(d) > 2.5 => 3(u), 2(d) > 2.6 => 3(u), 3(u) > 2.7 => 3(u), 3(u) > 2.8 => 3(u), 3(u) > 2.9 => 3(u), 3(u) > ... > > In this used-to-be-thought-correct table, Round Ups algorithm have 2 > Unrounded, 8 Round Down, and 10 Round Ups which seems incorrect while > Round Even have 2 Unrounded, 9 Round Down, and 9 Round Up which seems > correct. The misunderstanding comes from a view that thinks that there > is such thing as Not Rounded while in fact the only number that is Not > Rounded is 1 and 2 while 1.0 and 2.0 must still be rounded, in > practice we can just say that all number must be rounded somewhere. That's not correct. If the numbers to be rounded come from a measurement, the left column is not just a number but the representant of an interval (as Mikael said, the're quantized). 2.3 means that the measurement was closer to 2.3 than to 2.2 or 2.4 - that is, [2.25, 2.35) (it doesn't really matter which side is open or closed). It is this "interval" behavior that forces the "round-to-even-on-halves" rule. So, the numbers 1.6-2.4 on the left column cover the interval [1.55, 2.45) and there is no doubt that they should be rounded to 2.0 because all of them are closer to 2.0 than to any other integer. Similarly [2.55, 3.45) are all rounded to 3. But what to do with [2.45, 2.55), the interval represented by 2.5? We can assume a uniform distribution here even if the whole distribution is not (because we're talking of the smallest measurable range). So half of the time the "true value" would have been < 2.5, and we should round to 2. And half of the time it's > 2.5 and we should round to 3. Rounding always to 3 introduces a certain bias in the process. Rounding randomly (tossing a coin, by example) would be fair, but people usually prefer more deterministic approaches. If the number of intervals is not so small, the "round even" rule provides a way to choose from that two possibilities with equal probability. So when we round 2.5 we are actually rounding an interval which could be equally be rounded to 2 or to 3, and the same for 3.5, 4.5 etc. If the number of such intervals is big, choosing the even number helps to make as many rounds up as rounds down. If the number of such intervals is small, *any* apriori rule will introduce a bias. > > Note that if you do not have quantized values and assuming that the > > fraction part is evenly distributed between 0 and 1, than this whole > > argument is moot. The probability of getting exactly 0.5 is zero in that > > case, just as the probability of getting any other specified number is zero. > > Another mistake, in an unquantized value the probability of getting > exactly 0.5 (or any other number specified) is not 0 but an > infinitesimal (i.e. lim(x) where x -> 0 (BUT NOT ZERO)) That limit IS zero. And the probability of getting exactly a certain real number, or any finite set of real numbers, is zero too (assuming the usual definition of probability over infinite sets). But we're not actually talking about real numbers here. -- Gabriel Genellina From lists at cheimes.de Tue Apr 29 19:48:42 2008 From: lists at cheimes.de (Christian Heimes) Date: Wed, 30 Apr 2008 01:48:42 +0200 Subject: Sending Cntrl-C ?? In-Reply-To: References: <0274834e-17e1-4a95-88ec-f2aa77aeb3a9@k10g2000prm.googlegroups.com> Message-ID: gamename schrieb: > Thanks, Christian. Would that work on win32 as well? No, Windows doesn't support the same, rich set of signal as Unix OSes. Christian From pavlovevidence at gmail.com Wed Apr 16 18:02:03 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Wed, 16 Apr 2008 15:02:03 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> Message-ID: On Apr 16, 12:40 pm, Aaron Watters wrote: > On Apr 16, 12:27 pm, Rhamphoryncus wrote: > > > On Apr 16, 6:56 am, Aaron Watters wrote: > > > > I don't get it. It ain't broke. Don't fix it. > > > So how would you have done the old-style class to new-style class > > transition? > > I'd ignore it. I never understood it and never had > any need for it anyway. New-style classes and metaclasses > were a complicated solution to an unimportant problem in > my opinion. And also a fiendish way to make code > inscrutible -- which I thought was more of a Perl thing > than a Python thing, or should be. > > I must be missing some of the deeper issues here. Please > educate me. The deeper issue is that you're benefiting from these "unimportant" changes even if you never use them yourself. Carl Banks From gagsl-py2 at yahoo.com.ar Mon Apr 14 21:50:07 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 14 Apr 2008 22:50:07 -0300 Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> Message-ID: En Mon, 14 Apr 2008 22:02:38 -0300, Sverker Nilsson escribi?: > I tried out py3k on my project, http://guppy-pe.sf.net And what happened? I've seen that your project already supports Python 2.6 so the migration path to 3.0 should be easy. -- Gabriel Genellina From bskaplan14 at yahoo.com Sun Apr 13 13:11:18 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Sun, 13 Apr 2008 10:11:18 -0700 (PDT) Subject: Module to read input from commandline Message-ID: <823886.56858.qm@web39208.mail.mud.yahoo.com> Unless I misunderstand your needs, you could just use raw_input(prompt) to get your answers. ----- Original Message ---- From: "james at reggieband.com" To: python-list at python.org Sent: Sunday, April 13, 2008 11:12:06 AM Subject: Module to read input from commandline Hi all, I did some quick searching but I haven't found anything like I want. It probably has to do with the terms I am searching for so if I describe what I want then I hope someone can point me to a good module. I want to take input from the user at the command line. e.g.) Would you like to continue [Y/n]: y What is your favorite color: green .... You get the idea. Basic question answer stuff. It should handle default options, case insensitivity, etc. Perhaps the module would compare the inputted text against a regexp for validation. If the module had an interface similar to OptParse that would be nice. Anyone know of a decent module that handles this type of thing? Writing from scratch would be simple but why re-invent the wheel. Cheers, James. -- http://mail.python.org/mailman/listinfo/python-list __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From deets at nospam.web.de Tue Apr 22 08:33:07 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 14:33:07 +0200 Subject: Does Python 2.5 include or not include SQLite engine? In-Reply-To: References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> Message-ID: <67648mF2mqc8pU2@mid.uni-berlin.de> python at bdurham.com schrieb: > While reading feedback to my post "Does Python 2.5.2's embedded SQLite > support full text searching?" I noticed that there appears to be some > confusion regarding whether Python 2.5 includes the SQLite engine. > > My Windows 2.5.2 binary download includes SQLite. > > But other posters claim otherwise, re: Linux releases of Python 2.5? > > I thought one of the major features of Python 2.5 was its embedded > SQLite engine. > > Thoughts? It is embedded. Period. You can install the pysqlite wrapper additionally, if you need a newer/differen sqlite version. It will be available as a different module, though. Diez From tgrav at mac.com Tue Apr 1 12:35:54 2008 From: tgrav at mac.com (Tommy Grav) Date: Tue, 1 Apr 2008 12:35:54 -0400 Subject: Homework help In-Reply-To: <8e1f6963-1cdd-4afe-9ea5-f1886ed452ab@d21g2000prf.googlegroups.com> References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> <7xfxu5ft1s.fsf@ruckus.brouhaha.com> <8e1f6963-1cdd-4afe-9ea5-f1886ed452ab@d21g2000prf.googlegroups.com> Message-ID: <217C141C-F7F2-480B-BC74-12BE90FB5EBA@mac.com> On Apr 1, 2008, at 12:29 PM, bobby.connor at gmail.com wrote: > On Apr 1, 12:17 pm, Paul Rubin wrote: >> bobby.con... at gmail.com writes: >>> I don't necessarily want the answers, but need help on how to >>> approach >>> it/the steps i need to solve the problems >> >> What parts are you having difficulty with? Are there some course >> materials and have you read them yet? > > I just don't know how to start the problems off How about reading the course material and then firing up python and trying some code. When you have done that and have questions regarding your code you are more than welcome back with questions. Cheers TG From bj_666 at gmx.net Wed Apr 2 14:02:18 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 2 Apr 2008 18:02:18 GMT Subject: Understanding bmp image files References: <2537c458-b4d5-480d-8407-168a2b59a27e@u10g2000prn.googlegroups.com> Message-ID: <65i01aF2embp3U1@mid.uni-berlin.de> On Wed, 02 Apr 2008 10:51:39 -0700, pranav wrote: > I want to read a BMP file, do some processing and then write it in a > new file. The problem is in the third step. For reading the file, i > have converted the file into decimal numbers, representing the pixel > values. You have converted the data into numbers, not "decimal" numbers. > Then i perform calculations on those decimal numbers. Now i am > unable to convert those into the format as required by the "bmp" file. > Any one, who is into image reading/manipulation, please help. How have you converted the bytes into numbers and why can't you reverse that step? Ciao, Marc 'BlackJack' Rintsch From marli305nugent at gmail.com Sat Apr 26 09:51:29 2008 From: marli305nugent at gmail.com (marli305nugent at gmail.com) Date: Sat, 26 Apr 2008 06:51:29 -0700 (PDT) Subject: norton internet security 2006 crack Message-ID: <44fe8d34-a889-406b-9c00-0db7fe3c3bc4@t54g2000hsg.googlegroups.com> norton internet security 2006 crack http://cracks.00bp.com F R E E C R A C K S From sjmachin at lexicon.net Fri Apr 25 08:38:22 2008 From: sjmachin at lexicon.net (John Machin) Date: Fri, 25 Apr 2008 05:38:22 -0700 (PDT) Subject: problem with unicode References: <26fcc207-b864-42c7-afb3-c6945e5fe29f@m44g2000hsc.googlegroups.com> Message-ID: <160a3724-fa7c-403b-bde7-981797ab3205@j33g2000pri.googlegroups.com> On Apr 25, 9:15 pm, "andreas.prof... at googlemail.com" wrote: > Hi everybody, > > I'm using the win32 console and have the following short program > excerpt > > # media is a binary string (mysql escaped zipped file) > > >> print media > > x???[? ... > (works) > > >> print unicode(media) > > UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position > 1: ordinal not in range(128) > (ok i guess print assumes you want to print to ascii) Guessing is no substitute for reading the manual. print has nothing to do with your problem; the problem is unicode(media) -- as you specified no encoding, it uses the default encoding, which is ascii [unless you have been mucking about, which is not recommended]. As the 2nd byte is 0x9c, ascii is going nowhere. > > >> print unicode(media).encode('utf-8') > > UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position > 1: ordinal not in range(128) > (why does this not work?) Already unicode(media) "doesn't work", so naturally(?) unicode(media).whatever() won't be better -- whatever won't be called. > > # mapString is a unicode string (i think at least)>> print "'" + mapString + "'" > > ' yu_200703_hello\ 831 v1234.9874 ' > > >> mystr = "%s %s" % (mapString, media) > > UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position > 1: ordinal not in range(128) > > >> mystr = "%s %s" % (mapString.encode('utf-8'), media.encode('utf-8')) > > UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position > 1: ordinal not in range(128) This is merely repeating the original problem. > > I don't know what to do. I just want to concatenate two string where > apparently one is a binary string, the other one is a unicode string > and I always seem to get this error. > > Any help is appreciated :) We need a clue or two; do this and let us know what it says: print type(media), repr(media) print type(mapString), repr(mapString) import sys; print sys.stdout.encoding Also you say that "print media" works. Do you mean that it produces some meaningful text that you understand? What I see on the screen in Google Groups is the following 6 characters: LATIN SMALL LETTER X KATAKANA LETTER WA KATAKANA LETTER YU KATAKANA LETTER RO LEFT SQUARE BRACKET KATAKANA LETTER YO Is that what you see? What is it that you call "win32 console"? From python.list at tim.thechases.com Sat Apr 5 20:28:31 2008 From: python.list at tim.thechases.com (Tim Chase) Date: Sat, 05 Apr 2008 19:28:31 -0500 Subject: Best way to check if string is an integer? In-Reply-To: <47F8095D.40905@datanet.ab.ca> References: <47F8095D.40905@datanet.ab.ca> Message-ID: <47F8192F.2050806@tim.thechases.com> > I always do it the first way. It is simpler, and should be faster. Ditto. Using int() is best. It's clear, it's correct, and it should be as fast as it gets. >> if c in '0123456789': >> print "integer" >> else: >> print "char" > > Also, the second way will only work on single-digit numbers > (you would have to iterate over the entire string with a for > loop to use it on numbers with more than one digit). It also catches things like c="1234" but misses negative numbers too. It's a bad solution on a number of levels. The isdigit() method of a string does much of what int() does for testing "is this an int" except that it too misses negative numbers. -tkc From fiacre.patrick at gmail.com Sun Apr 20 23:21:20 2008 From: fiacre.patrick at gmail.com (Andrew Lee) Date: Sun, 20 Apr 2008 23:21:20 -0400 Subject: Checking if a text file is blank In-Reply-To: References: <480ae855$0$15157$607ed4bc@cv.net> Message-ID: <480c07b7$0$11616$607ed4bc@cv.net> David wrote: >> import os >> print os.lstat("friends.txt")[6] >> > > I prefer os.lstat("friends.txt").st_size MUCH easier to remember!!!! Thanks! From inq1ltd at inqvista.com Sun Apr 6 20:12:01 2008 From: inq1ltd at inqvista.com (jim-on-linux) Date: Sun, 06 Apr 2008 20:12:01 -0400 Subject: Tkinter, repaint?, keep size? In-Reply-To: <6ff2ce5f-9ba3-492c-b062-324c91e652a0@e10g2000prf.googlegroups.com> References: <6ff2ce5f-9ba3-492c-b062-324c91e652a0@e10g2000prf.googlegroups.com> Message-ID: <200804062012.01208.inq1ltd@inqvista.com> On Sunday 06 April 2008 13:24, skanemupp at yahoo.se wrote: > so my calculator is almost done for u that > have read my previous posts. > i have some minor problems i have to fix > though. > > *one is i need to repaint once i have > performed a calculation so that the old > results are not left on the screen. cant > find a method for that. you can use "wigit".update(). The update method update will redraw wigits as necessary. If you have the state of the wigit set to DISABLE then set it to ACTIVE before using .update(). > > *another is now when i write the > expression to be evaluated it resizes the > window as the text grows. > i want the windowsize and all the > buttonplacements stay constant, how do i > achieve this? I like to make a separate frame for buttons. master = Tk() master.title =('My Project') buttonFrame = Frame(master) buttonFrame.grid(row = 0 column = 1) you could use a dictionary that contains the the text and the command and loop the key to build the buttons. Make x = x+1, y = y+1 for row and column or otherwise as you need. button = Button(buttonframe, text = key, width = 2) button1.grid(row = x, column = y, sticky = NSEW) put other stuff into the master using another frame and grid it in some other column and or row. If you make all buttons the same size inside the frame they will keep their size even if you have more text then the button will hold. There is a lot more but this is the way I would proceed. jim-on-linux http://www.inqvista.com From windypower at gmail.com Fri Apr 25 22:41:46 2008 From: windypower at gmail.com (windypower at gmail.com) Date: Fri, 25 Apr 2008 19:41:46 -0700 (PDT) Subject: Desktop notifications on Windows Message-ID: <0db266c1-50ad-4e01-b508-57c9a8febb4b@a22g2000hsc.googlegroups.com> I'm looking for a way to implement desktop notifications (much like an instant messaging program or a mail notifier) within my Python application, on Windows only (no Gtk/Galago, please). I need no more than a simple text-based notification, which should be clickable and have a timeout, nothing else. I do not want to use Windows's "balloon tips", either. Any suggestions? From ankitks.mital at gmail.com Mon Apr 7 12:38:39 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Mon, 7 Apr 2008 09:38:39 -0700 (PDT) Subject: reading dictionary's (key,value) from file Message-ID: <974814d3-59f0-49ec-9b4d-9f5dd7dfaf54@q24g2000prf.googlegroups.com> Folks, Is it possible to read hash values from txt file. I have script which sets options. Hash table has key set to option, and values are option values. Way we have it, we set options in a different file (*.txt), and we read from that file. Is there easy way for just reading file and setting options instead of parsing it. so this is what my option files look like: 1opt.txt { '-cc': '12', '-I': r'/my/path/work/'} 2opt.txt { '-I': r/my/path/work2/'} so my scipt how has dictionary options = { '-cc' :'12' '-I': r'/my/path/work/:/my/path/work2/'} I am trying to avoid parsing From ivan.illarionov at gmail.com Sun Apr 13 08:27:55 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Sun, 13 Apr 2008 05:27:55 -0700 (PDT) Subject: Looking for a way to include Pyhtho scripting INSIDE a python program References: <48017af0$0$36399$742ec2ed@news.sonic.net> Message-ID: On Apr 13, 7:16 am, John Antypas wrote: > Hello all, > > I'm writing in tool in Python that manipulates various data objects read > from various streams. I wanted to give the user a chance to do advanced > work that could not easily be done from a GUI. > > At first, I tried putting in a lightweight scripting language, and then > I thought, why not include Python in itself -- it is certainly powerful > enough. > > I had assumed I'd present the user with a text window in which they > could type arbitrary python code. I'd wrap that code around a function > and pass that function a call of objects they could manipulate by > calling the methods of that class. > > 1. How can a python program invoke ANOTHER interpreter? > 2. How can I pass the class in as its argument and get the modified > class back? > > I know I can do something very ugly -- call a C method that calls a new > python interpreter but that seems VERY ugly. > > Help? > > Thanks. You don't need to envoke another interpreter. Python can interpret arbitrary python code with exec statement. Wrap user's string inside function definition, and exec it. You might want to disable words like `import`, `exec` and `eval` in user's code because it's a big security risk. -- Ivan Illarionov From fiacre.patrick at gmail.com Wed Apr 23 06:49:31 2008 From: fiacre.patrick at gmail.com (Andrew Lee) Date: Wed, 23 Apr 2008 06:49:31 -0400 Subject: help needed with classes/inheritance In-Reply-To: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> References: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> Message-ID: <480f13e8$0$15157$607ed4bc@cv.net> barbaros wrote: > Hello everybody, > > I am building a code for surface meshes (triangulations for instance). > I need to implement Body objects (bodies can be points, segments, > triangles and so on), then a Mesh will be a collection of bodies, > together with their neighbourhood relations. > I also need OrientedBody objects, which consist in a body > together with a plus or minus sign to describe its orientation. > So, basically an OrientedBody is just a Body with an > integer label stuck on it. > > I implemented it in a very crude manner: > ------------------------------------------ > class Body: > [...] > class OrientedBody: > def __init__ (self,b,orient=1): > # b is an already existing body > assert isinstance(b,Body) > self.base = b > self.orientation = orient > ------------------------------------------- class Body(object) : ... class OrientedBody (Body): def __init__(self, orientation = 1) : Body.__init__(self) self.orientation = orientation as noted But, also. as a rule of thumb .. if you are using "isinstance" in a class to determine what class a parameter is ... you have broken the OO contract. Remember, every class ought to have a well defined internal state and a well defined interface to its state. If I write -- class foo (object): def __init__ : pass def some_func (self, val) : if isinstance (val, "bar") : .... Then I am either doing something very wrong or very clever (either can get me in trouble) In Python it is preferred that I write two functions some_func_a and some_func_b e.g. def some_func_a (self, val = None, class = bar) : assert(isinstance (class, "bar"), True) .... def some_func_b (self, val = None, class = baz) : assert (isinstance (class, "baz"), True) C++ and Java try to enforce the OO contract by making data and methods private, protected or public. Which helps -- but leads to some confusion (what is protected inheritance in C++????) Python exposes all of its classes internals to everyone -- but that doesn't mean you should touch them!! As Larry Wall once wrote, "There is a difference between, 'do not enter my living room because I asked you not to' and 'do not enter my living room because I have a shotgun'" Python adopts the 'do not touch my private parts because I asked you not to' idiom. (In C++, only friends can touch your privates ... ;-) So -- be mindful that checking the class of well defined parameters at anytime is breaking the contract -- you may need to do it -- but it is more likely that you aren't adhering to good OOD. Does that make any sense? Seriously -- I have not had any coffee yet and I am still new at Python. -- Andrew > > My question is: can it be done using inheritance ? > I recall that I need three distinct objects: > the basic (non-oriented) body, the same body with positive > orientation and the same body with negative orientation. > > Thank you. Cristian Barbarosie > http://cmaf.fc.ul.pt/~barbaros From smmehadi at gmail.com Fri Apr 18 04:52:43 2008 From: smmehadi at gmail.com (syed mehdi) Date: Fri, 18 Apr 2008 14:22:43 +0530 Subject: python server side scripting with apache2 Message-ID: <12b075a10804180152ob8ca5b9iacf0a9f0d8822c5e@mail.gmail.com> Hi Guys, I want to do server side scripting in python for one of my applications. So after installing apache2, python lib for apache2 (libapache2....), and doing some changes in default file in /etc/apache2/sites-available i was able to execute python scripts in /var/www/ directory from client side. but i want to place all of my python scripts in some other directory like /home/username/myserver, so what changes i have to make in configuration files at /etc/apache2/apache2.conf or some other place (like /etc/apache2/sites-available/default), so that my server side scripts placed in this folder (/home/username/myserver) gets executed from client side using some url like http://machine-ip/home/username/myserver/abc.py. Thanks & Regards Syed -------------- next part -------------- An HTML attachment was scrubbed... URL: From watches0684 at global-replica-watch.com Tue Apr 22 23:11:27 2008 From: watches0684 at global-replica-watch.com (watches0684 at global-replica-watch.com) Date: Tue, 22 Apr 2008 20:11:27 -0700 (PDT) Subject: Designer Versace V Bag - Khaki 6532 Khaki Handbags, Replica, Fake Message-ID: <22c54b4b-be65-4aab-bcaf-8bb7004a813b@l64g2000hse.googlegroups.com> Designer Versace V Bag - Khaki 6532 Khaki Handbags, Replica, Fake Our Versace V Bag - Khaki 6532 Khaki is a vibrant mix of style and pleasure, offering you exact copies of the original handbags. If you need a cool and most welcomed change to your style, a change you certainly deserve, choose one of the many bags ReplicasHandbag.com offers at a great price. Versace V Bag - Khaki Link : http://www.replicashandbag.com/Versace-6532-Khaki.html Brand : Versace ( http://www.replicashandbag.com/Versace-Handbags.html ) Model : 6532 Khaki Sale Price : $ 215.00 Versace V Bag - Khaki Details : Khaki color Versace leather bagGold chain with khaki leather handleGold color Versace logo at the frontZipper closure and magnetic snap cloure on topInside it has one flat pocketComes with serial numbers, authenticity card, dust bag, and care booklet SIZE : 18.1" x 12.2" x 9.4" You may find the most affordable Designer Versace Handbags on our website replicashandbag.com while high quality can be guaranteed. Our Replica Versace Bags is made with special care to reach the level of an original one. Here you will find luxury items are no longer something you ever hesitate going for. To meet your expectation, we only provide Versace Fake Handbags that is perfectly imitated, featuring the slight details of originals. All of our replica handbags are shipped via EMS to worldwide. Normally it takes 3days to prepare the fake bags you ordered and 5-10days to transmit depending on the different destination.We pay for the free shipping cost for total quantity over 20 pcs. The EMS tracking NO. will be sent by email when an order is shipped from our warehouse. No more other charges from replicashandbag.com such as the tax. If you have any other questions please check our other pages or feel free to email us by sales at replicashandbag.com. The Same Replica Versace Handbags Series : Designer Versace V Bag - Khaki 6532 Khaki Handbags, Replica, Fake From maxerickson at gmail.com Tue Apr 22 11:19:27 2008 From: maxerickson at gmail.com (Max Erickson) Date: Tue, 22 Apr 2008 15:19:27 +0000 (UTC) Subject: Witty retorts (was: Python Success stories) References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <87d4oi3s3c.fsf_-_@benfinney.id.au> Message-ID: Ben Finney wrote: > Carl Banks writes: > >> Let me tell you a little story to let you know how you should >> act in situations like this. Some of you might have heard it >> before. Apologies if it's a bit long. > > I don't know if I've heard it before; it's rather unmemorable. > > What lesson is it intended to teach, other than that "Fuck you" > is somehow a "retort"? I can't see that improving too many > situations. > I got something like "Don't waste your life worrying about what some damn clown said" out of it. You don't even need to swear at the clown to make it work. max From arnodel at googlemail.com Thu Apr 3 18:12:01 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 3 Apr 2008 15:12:01 -0700 (PDT) Subject: expanding a variable to a dict References: Message-ID: On Apr 3, 10:56?pm, idle wrote: > I've got a variable in a loop that I'm trying to expand/translate/ > readdress as an existing dict so as to add some keys into it.. > > eg; I have a set of existing dicts: dictFoo, dictBar, dictFrotz (names > changed to protect the innocent) > > now I'd like to check them all for the existence of certain default > keys; ie, if the dicts don't contain the keys, add them in with > default values. > > so, I've got: > > for a in ['dictFoo','dictBar','dictFrotz']: > ? ? if hasattr(a,'srcdir') == False: > ? ? ? ? a['srcdir']='/usr/src' > > the error I get (which I expect) is 'str' object doesn't support item > assignment. > > what incantation do I cast on 'a' to make the interpreter parse it as > 'dictFoo' on the first iteration, 'dictBar' on the second, and so > forth? > > and/or less importantly, what is such a transformation called, to help > me target my searching? > > thanks You want a to iterate through the dictionary *objects*, not *names*, so write for a in [dictFoo, dictBar, dictFrotz]: ... BTW, hasattr() is not what you want as it check the existence of an attribute, i.e. a.hasattr('x') means that a.x exists; you could write the whole thing as: for a in dictFoo, dictBar, dictFrotz: if 'srcdir' not in a: a['srcdir'] = '/usr/src' Or more concisely: for a in ... : a.setdefault('srcdir', '/usr/src') For more information, help(dict) is your friend :) HTH -- Arnaud From patrickkidd.lists at gmail.com Wed Apr 9 12:31:22 2008 From: patrickkidd.lists at gmail.com (Patrick Stinson) Date: Wed, 9 Apr 2008 10:31:22 -0600 Subject: problem using import from PyRun_String In-Reply-To: References: <664bf2b80804081801u79ae9192h90c03c84c1ef35ce@mail.gmail.com> Message-ID: <664bf2b80804090931y78d9e34dof268784cc6a6cde9@mail.gmail.com> Well, I eventually want to add an import hook, but for now I'd rather just get the import statement working normally again. I have embedded python as a scripting engine in my application. To do this, I create a new empty module, run the script text using PyRun_String() passing the module's __dict__ as locals and globals. This populates the module's __dict__ with the resulting object references from the script text. As I said before I must be forgetting some other module init stuff because I had to manually populate the modules' __dict__ with references from the __builtin__ module in order to get the basic stuff like abs, range, etc. I understand what __builtin__ is used for, but the C struct pointing to the code frame that contains the import statement has a builtin member that apparently does not contain the __import__ function, hence my question. There must be some difference in the way code is parsed and a copy of the __builtin__ module is passed normally and the way I am doing it. So, finding the place where this module bootstrapping normally happens would be awesome, because I sort of feel like I'm hacking this method running into problems like this. I'll definitely be putting together a wiki on this topic before long. Seems like an application scripting engine is incredibly easy to implement if you already know all the tricks, we're just lacking docs. On Wed, Apr 9, 2008 at 1:00 AM, Gabriel Genellina wrote: > En Tue, 08 Apr 2008 22:01:18 -0300, Patrick Stinson > escribi?: > > > I'm creating a module with PyModule_New(), and running a string buffer > as > > the module's text using PyRun_String and passing the module's __dict__ > to > > locals and globals. > > Why? Do you want to fake what import does? > > > I'm having a problem using the import statement from > > within PyRun_String(). It complains about "__import__ not found", which > > after a quick grep it looks like the exception is raised from > > PyExc_EvalFrameEx() in ceval.c after f->f_builtins module doesn't > contain > > "__import__". > > What __builtin__ module does that point to? a quick print of the > > __builtin__ holds all the builtin objects, what a surprise! :) > http://docs.python.org/lib/module-builtin.html > > > Any help? > > What do you want to do actually? > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Patrick Kidd Stinson http://www.patrickkidd.com/ http://pkaudio.sourceforge.net/ http://pksampler.sourceforge.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From kamhung.soh at gmail.com Mon Apr 21 19:07:49 2008 From: kamhung.soh at gmail.com (Kam-Hung Soh) Date: Tue, 22 Apr 2008 09:07:49 +1000 Subject: Is massive spam coming from me on python lists? References: Message-ID: On Mon, 21 Apr 2008 16:01:42 +1000, Brian Vanderburg II wrote: > I've recently gotten more than too many spam messages and all say > Sender: python-list-bounces+my=email.address at python.org. I'm wondering > if my mail list registration is now being used to spam myself and > others. If so, sorry, but I'm not the one sending messages if other are > getting them even though Sender seems to include my address (I'm not > sure about mail headers so I don't know how From: is different than > Sender:) Anyway, it seems to be a bunch of spam emails about cracks and > stuff. > > Brian Vanderburg II No worries. People should (I hope) just ignore the sender address when they receive spam. -- Kam-Hung Soh Software Salariman From sumoee at gmail.com Thu Apr 17 07:45:15 2008 From: sumoee at gmail.com (sumoee at gmail.com) Date: Thu, 17 Apr 2008 04:45:15 -0700 (PDT) Subject: #####SOUTH INDIAN SEX GIRLS SEX###### Message-ID: <20cb4dd8-a897-4f89-886d-c13a4b94a168@8g2000hse.googlegroups.com> http://rajtrytry.dubaimlm.com free Register On $ 100 Free dubai companey Relised Paymend free join form free free 100 dollors free 4days only http://rajtrytry.dubaimlm.com http://rajtrytry.dubaimlm.com http://rajtrytry.dubaimlm.com http://rajtrytry.dubaimlm.com se SEX SEX SWEX SEX WEB SITE NO BIOTECH http://bisblogs.blogspot.com/ http://bisblogs.blogspot.com/ From gagsl-py2 at yahoo.com.ar Mon Apr 21 21:32:08 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 22:32:08 -0300 Subject: yield expression programmized-formal interpretation. (interpretation of yield expression.) References: <888d1fff-5566-47db-b1a9-6c0bb994d7da@d1g2000hsg.googlegroups.com> Message-ID: En Mon, 21 Apr 2008 15:03:05 -0300, escribi?: > What if I say > > oath= yield > > or > > other= yield > > ? > > Does yield evaluate without parenthes? (Eth.) You can't use yield except in a generator function. From and the grammar definition at you can see that assignment_stmt ::= (target_list "=")+ (expression_list | yield_expression) yield_expression ::= "yield" [expression_list] The last expression_list is optional so a bare yield should be allowed in the right hand side of an assignment, as if it were `yield None` (I think such behavior is specified in the original PEP). Let's try: py> def gen(): ... x = yield ... y = yield "second" ... yield x, y ... py> g = gen() py> print g.next() None py> print g.send(123) second py> print g.send(456) (123, 456) py> print g.send(789) Traceback (most recent call last): File "", line 1, in StopIteration -- Gabriel Genellina From john106henry at hotmail.com Sat Apr 26 19:11:11 2008 From: john106henry at hotmail.com (John Henry) Date: Sat, 26 Apr 2008 16:11:11 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <5b326b53-22fc-43f3-8423-bfc49d05ccc3@j22g2000hsf.googlegroups.com> Message-ID: On Apr 26, 4:05 pm, castiro... at gmail.com wrote: > On Apr 26, 5:03 pm, John Henry wrote: > > > > > On Apr 26, 8:46 am, a... at pythoncraft.com (Aahz) wrote: > > > > In article <9028496e-30de-4853-8f57-b55d14e52... at h1g2000prh.googlegroups.com>, > > > John Henry wrote: > > > > >But then I looked closer. It turns out the XML file created by > > > >QxTransformer is *very* similar in structure when compared to the > > > >resource files used inPythonCard. Since there are no GUI builders > > > >for QxTransformer, and I can't affort to buy the one for Qooxdoo > > > >(Java! Yuk!), I decided to roll up my sleeves, took thePythoncard's > > > >Layout Manager and modified it and created my own "Poor Man's Qooxdoo > > > >GUI Layout Designer". > > > > Cute! When you have working code, please do upload to PyPI. > > > -- > > > Aahz (a... at pythoncraft.com) <*> http://www.pythoncraft.com/ > > > > Why is this newsgroup different from all other newsgroups? > > > So far, I have the following widgets working: > > > window, button, checkbox, static text, static box, list, combobox, > > spinner, radio button group > > > Shouldn't be long before the following works: > > > static line, image, image button, choice.- Hide quoted text - > > > - Show quoted text - > > Should static text GUI class support the operations of a string? Say what? From steve at holdenweb.com Fri Apr 11 14:34:36 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 11 Apr 2008 14:34:36 -0400 Subject: About __init__ and default arguments In-Reply-To: References: Message-ID: Kevin Takacs wrote: > Hi, > > I'd like to assign the value of an attribute in __init__ as the default > value of an argument in a method. See below: > > class aphorisms(): > def __init__(self, keyword): > self.default = keyword > > def franklin(self, keyword = self.default): > return "A %s in time saves nine." % (keyword) > > def main(): > keyword = 'FOO' > my_aphorism = aphorisms(keyword) > print my_aphorism.franklin() > print my_aphorism.franklin('BAR') > > if __name__ == "__main__": > main() > > I get this error: > def franklin(self, keyword = self.default): > NameError: name 'self' is not defined > > As you might expect, I'd like to get: > A FOO in time saves nine. > A BAR in time saves nine. > > I suppose I could set the default to a string literal, test for it and if > true assign the value of self.default to keyword; however, that seems > clunky. Any ideas how this could be done along the lines of my proposed > but faulty code? > def franklink(self, keyword=None): if keyword is None: keyword = self.keyword would be the usual way to do it. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From nachogomez at gmail.com Thu Apr 17 15:18:32 2008 From: nachogomez at gmail.com (=?UTF-8?Q?Ra=C3=BAl_G=C3=B3mez_C.?=) Date: Fri, 18 Apr 2008 14:48:32 +1930 Subject: Importing My Own Script In-Reply-To: <69481.40675.qm@web39203.mail.mud.yahoo.com> References: <69481.40675.qm@web39203.mail.mud.yahoo.com> Message-ID: <684b0a740804171218t2fff48c6s6c39acc5b38eb761@mail.gmail.com> Victor, you can do this in order to load your own modules: import sys,os sys.path.append(os.getcwd()) import your_module On Fri, Apr 18, 2008 at 12:34 PM, Ben Kaplan wrote: > It might be something in mod python. Try asking on their mailing list. > > ----- Original Message ---- > From: Victor Subervi > To: Ben Kaplan > Cc: python-list at python.org > Sent: Thursday, April 17, 2008 10:47:34 AM > Subject: Re: Importing My Own Script > > On Thu, Apr 17, 2008 at 8:52 AM, Ben Kaplan wrote: > > > If x and y are in the same directory, just do "import x". If not, add > > the directory containing x to sys.path. Then, "import x" should work. > > > > Well, now that?s what I thought! But no, it doesn?t work! Both scripts are > in the same folder. Here?s the error: > > [Thu Apr 17 07:45:50 2008] [error] [client 190.166.0.245] PythonHandler > mod_python.cgihandler: File "/var/www/vhosts/ > livestocksling.com/httpdocs/bre/test.py", line 3, in ?\n import test2 > [Thu Apr 17 07:45:50 2008] [error] [client 190.166.0.245] PythonHandler > mod_python.cgihandler: ImportError: No module named test2 > I?m running through Plesk, if that makes a difference. > TIA, > Victor > > > > > > ----- Original Message ---- > > From: Victor Subervi > > To: python-list at python.org > > Sent: Thursday, April 17, 2008 9:45:10 AM > > Subject: Importing My Own Script > > > > Hi: > > How do I import my own script from a second script? That is, I have > > script x and I want to import script y. How? > > TIA, > > Victor > > > > > > ------------------------------ > > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try > > it now. > > > > > > ------------------------------ > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it > now. > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Nacho Linux Counter #156439 -------------- next part -------------- An HTML attachment was scrubbed... URL: From sjdevnull at yahoo.com Wed Apr 16 15:33:10 2008 From: sjdevnull at yahoo.com (sjdevnull at yahoo.com) Date: Wed, 16 Apr 2008 12:33:10 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> <09a38ca2-8c49-4eee-b6cf-58e849aea1fc@q1g2000prf.googlegroups.com> Message-ID: <5c5c130e-dade-4663-87b5-f3ab748cc9e3@y21g2000hsf.googlegroups.com> On Apr 16, 2:52 pm, Aaron Watters wrote: > I disagree. You can add lots of cool > stuff without breaking the existing code base, mostly. > For example the minor changes to the way ints will work will > effect almost no programs. Wow, I'd venture that the division changes with ints are the only thing I'm really concerned about breaking in 3.0, both because they're more likely to slip by without being immediately noticed and because they're likely to be foreign going forward for people used to C-style integer division (ie most of the programmers in our office). Even them I don't see as a huge roadblock, but a "erase old ways of thinking" bugaboo for a while. But the rest of the changes are pretty obvious and well warned about by 2to3 and the interpreter. From ashishk30 at gmail.com Wed Apr 16 03:20:51 2008 From: ashishk30 at gmail.com (ashish kamble) Date: Wed, 16 Apr 2008 12:50:51 +0530 Subject: python beginer Message-ID: <81d84eb10804160020n114c4d7ekfef7a09532813e39@mail.gmail.com> hi, can anyone tell me hw to start with webapplication scripting(e.g login page..etc) if anyone has soln for this or simple e.g that mention above please send me by and have a nice day -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin at v.loewis.de Tue Apr 1 19:03:20 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Wed, 02 Apr 2008 01:03:20 +0200 Subject: What motivates all unpaid volunteers at Pycon? In-Reply-To: <6ffcb45b-abb9-4d5e-8237-0f8c6bacab08@i29g2000prf.googlegroups.com> References: <7b539c8e-af4c-4409-81bc-d94e687eea59@i7g2000prf.googlegroups.com> <12d7412e-9f87-4798-a319-a78a27f68d00@e6g2000prf.googlegroups.com> <6ffcb45b-abb9-4d5e-8237-0f8c6bacab08@i29g2000prf.googlegroups.com> Message-ID: <47F2BF38.8090208@v.loewis.de> > What do the people get back who did all the hard work at registration > desk and > preparing conference attendee bags? ...who did all hotel preparations? I think these questions are better asked at the pycon organizers list, than on comp.lang.python (which none of the volunteers may actually read to answer your questions). Regards, Martin From Robert.Bossy at jouy.inra.fr Fri Apr 25 09:05:20 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Fri, 25 Apr 2008 15:05:20 +0200 Subject: Little novice program written in Python In-Reply-To: <67dqepF2nmg7dU1@mid.uni-berlin.de> References: <49249992-3634-4c5f-bd45-7ce4f1b32044@l17g2000pri.googlegroups.com> <67dqepF2nmg7dU1@mid.uni-berlin.de> Message-ID: <4811D710.7080709@jouy.inra.fr> Marc 'BlackJack' Rintsch wrote: >> Indeed. Would it be a sensible proposal that sequence slices should >> return an iterator instead of a list? >> > > I don't think so as that would break tons of code that relies on the > current behavior. Take a look at `itertools.islice()` if you want/need > an iterator. A pity, imvho. Though I can live with islice() even if it is not as powerful as the [:] notation. RB From lobais at gmail.com Mon Apr 14 14:02:48 2008 From: lobais at gmail.com (Thomas Dybdahl Ahle) Date: Mon, 14 Apr 2008 20:02:48 +0200 Subject: Rounding a number to nearest even In-Reply-To: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: <1208196168.24295.36.camel@localhost.localdomain> On Fri, 2008-04-11 at 03:14 -0700, bdsatish wrote: > The built-in function round( ) will always "round up", that is 1.5 is > rounded to 2.0 and 2.5 is rounded to 3.0. > > If I want to round to the nearest even, that is > > my_round(1.5) = 2 # As expected > my_round(2.5) = 2 # Not 3, which is an odd num > > I'm interested in rounding numbers of the form "x.5" depending upon > whether x is odd or even. Any idea about how to implement it ? This seams to work fine: evenRound = lambda f: round(f/2.)*2 >>> [(f*.5, evenRound(f*.5)) for f in xrange(0,20)] [(0.0, 0.0),(0.5, 0.0), (1.0, 2.0), (1.5, 2.0), (2.0, 2.0), (2.5, 2.0), (3.0, 4.0), (3.5, 4.0), (4.0, 4.0), (4.5, 4.0), (5.0, 6.0), (5.5, 6.0), (6.0, 6.0), (6.5, 6.0), (7.0, 8.0), (7.5, 8.0), (8.0, 8.0), (8.5, 8.0), (9.0, 10.0), (9.5, 10.0)] -- Best Regards, Med Venlig Hilsen, Thomas From ptmcg at austin.rr.com Thu Apr 24 12:08:10 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Thu, 24 Apr 2008 09:08:10 -0700 (PDT) Subject: Ideas for parsing this text? References: Message-ID: On Apr 24, 10:42?am, "Eric Wertman" wrote: > I'm sure there are cooler ways to do some of that. ?I spent most of my > time expanding the characters that constitute content. ?I'm concerned > that over time I'll have things break as other characters show up. > Specifically a few of the nodes are of German locale.. so I could get > some odd international characters. > If you want to add international characters without going to Unicode, a first cut would be to add pyparsing's string constant "ascii8bit". > It looks like pyparser has a constant for printable characters. ?I'm > not sure if I can just use that, without worrying about it? > I would discourage you from using printables, since it also includes '[', ']', and '"', which are significant to other elements of the parser (but you could create your own variable initialized with printables, and then use replace("[","") etc. to strip out the offending characters). I'm also a little concerned that you needed to add \t and \n to the content word - was this really necessary? None of your examples showed such words, and I would rather have you let pyparsing skip over the whitespace as is its natural behavior. -- Paul From arnodel at googlemail.com Fri Apr 11 14:41:39 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Fri, 11 Apr 2008 11:41:39 -0700 (PDT) Subject: About __init__ and default arguments References: Message-ID: <2965bd09-1eeb-44b4-bdd5-80c3bb5cb504@m1g2000pre.googlegroups.com> On Apr 11, 7:20?pm, Kevin Takacs wrote: > Hi, > > I'd like to assign the value of an attribute in __init__ as the default > value of an argument in a method. ?See below: > > class aphorisms(): > ? ? def __init__(self, keyword): > ? ? ? ? self.default = keyword > > ? ? def franklin(self, keyword = self.default): > ? ? ? ? return "A %s in time saves nine." % (keyword) > > def main(): > ? ? keyword = 'FOO' > ? ? my_aphorism = aphorisms(keyword) > ? ? print my_aphorism.franklin() > ? ? print my_aphorism.franklin('BAR') > > if __name__ == "__main__": > ? ? main() > > I get this error: > def franklin(self, keyword = self.default): > NameError: name 'self' is not defined > > As you might expect, I'd like to get: > A FOO in time saves nine. > A BAR in time saves nine. > > I suppose I could set the default to a string literal, test for it and if > true assign the value of self.default to keyword; however, that seems > clunky. ?Any ideas how this could be done along the lines of my proposed > but faulty code? > > Thanks, > Kevin The idiom is: def franklin(self, keyword=None): if keyword is None: keyword = self.default HTH -- Arnaud From mattheww at chiark.greenend.org.uk Wed Apr 16 19:32:15 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 17 Apr 2008 00:32:15 +0100 (BST) Subject: How to have unittest tests to be executed in the order they appear? References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> <87zlru7le2.fsf@benfinney.id.au> <87fxtlwi03.fsf@benfinney.id.au> Message-ID: <7nk*FmAas@news.chiark.greenend.org.uk> Ben Finney wrote: > Surely, since "suddenly" implies you changed one small area of the > code, that area of the code is the best place to look for what caused > the failure. Imagine that "suddenly" immediately follows "I upgraded to etch". -M- From landofdreams at gmail.com Wed Apr 30 23:46:15 2008 From: landofdreams at gmail.com (Sam) Date: Wed, 30 Apr 2008 20:46:15 -0700 (PDT) Subject: relative import broken? References: <9c6ba5f9-d65b-4265-baba-fc5d7936781b@d1g2000hsg.googlegroups.com> <87prs6x1ye.fsf@mulj.homelinux.net> Message-ID: <103668f6-8995-4179-a468-4ff6c7f82bba@c65g2000hsa.googlegroups.com> On Apr 30, 9:11 pm, Hrvoje Niksic wrote: > Sam writes: > > I also have a problem with relative import; I can't for the life of me > > figure out how to use the damn thing. I think the main problem is with > > getting Python to recognize the existence of a package. I have > > > S/ > > p.py > > B/ > > b.py > > W/ > > pyw/ > > u.py > > ws.py > > > and I'd like to get u.py to import all the other 3 programs. I put > > empty __init__.py files in all of the above directories (is this > > necessary?), and even manually added the pathway (r'C:\Myname\S') to > > sys.path, but when I execute > > > from S import p > > > in u.py Python gives "ImportError: No module named S". > > A silly question: is the directory that contains "S" in PYTHONPATH or > in sys.path? It's in sys.path. I'm not sure how to access or change PYTHONPATH from within a program (I'm running everything in IDLE). I'm using Windows, btw. > > > The docs for relative import make this sound much easier than it is. > > It's supposed to be just as easy as it sounds. For example: > > $ mkdir S > $ touch S/p.py > $ touch S/__init__.py > $ python > Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 > Type "help", "copyright", "credits" or "license" for more information.>>> from S import p > >>> p > > From paulgeeleher at gmail.com Thu Apr 24 07:41:35 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Thu, 24 Apr 2008 04:41:35 -0700 (PDT) Subject: Setting expirty data on a cookie References: <8ba48e05-9aba-4a56-805c-cd31b43517ab@24g2000hsh.googlegroups.com> Message-ID: On Apr 22, 8:38 pm, David wrote: > On Tue, Apr 22, 2008 at 6:21 PM,sophie_newbie wrote: > > Does anyone know how to do this? I can't seem to make it work. > > > I'm using: > > > c = Cookie.SimpleCookie() > > c['data'] = "unamepwordwhatever" > > c.expires = time.time() + 300 > > print c > > > This doesn't seem to work, so I'm assuming isn't the correct way to > > set an expiry data? Anyone able to help me out here? > > You're probably looking for cookielib.Cookie I don't think so, to give you a more complete picture, if I run this code: import Cookie import time c = Cookie.SimpleCookie() c['data'] = "unamepwordwhatever" c.expires = time.time() + 300 print c This codes gives an output of: "Set-Cookie: data=unamepwordwhatever" As in there is no mention of an expiry date, when surely there should be? Thanks for any advice. From bressert at gmail.com Tue Apr 29 17:03:47 2008 From: bressert at gmail.com (eli) Date: Tue, 29 Apr 2008 14:03:47 -0700 (PDT) Subject: accuracy issues with numpy arrays? Message-ID: <30fa02c6-908c-4c1c-a2ed-acb0a754ea6c@r66g2000hsg.googlegroups.com> Hi, I'm writing a quick script to import a fits (astronomy) image that has very low values for each pixel. Mostly on the order of 10^-9. I have written a python script that attempts to take low values and put them in integer format. I basically do this by taking the mean of the 1000 lowest pixel values, excluding zeros, and dividing the rest of the image by that mean. Unfortunately, when I try this in practice, *all* of the values in the image are being treated as zeros. But, if I doFor example, I take the pixel that I know has the highest value and do x = scipy.ndimage.maximum(image) print x 1.7400700016878545e-05 The script is below. Thanks for the help. Eli import pyfits as p import scipy as s import scipy.ndimage as nd import numpy as n def flux2int(name): d = p.getdata(name) x,y = n.shape(d) l = x*y arr1 = n.array(d.reshape(x*y,1)) temp = n.unique(arr1[0]) # This is where the bug starts. All values are treated as zeros. Hence only one value remains, zero. arr1 = arr1.sort() arr1 = n.array(arr1) arr1 = n.array(arr1[s.where(arr1 >= temp)]) val = n.mean(arr1[0:1000]) d = d*(1.0/val) d = d.round() p.writeto(name[0,]+'fixed.fits',d,h) From landerdebraznpc at gmail.com Mon Apr 28 03:56:39 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:56:39 -0700 (PDT) Subject: dvd cloner crack Message-ID: <85c822c1-43ba-4727-96ea-d354c193b5c5@p25g2000hsf.googlegroups.com> dvd cloner crack http://crack.cracksofts.com From ptmcg at austin.rr.com Tue Apr 29 12:56:26 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Tue, 29 Apr 2008 09:56:26 -0700 (PDT) Subject: Issue with regular expressions References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> <5a75ea66-2cbb-4c41-8351-a35a70554d8d@i76g2000hsf.googlegroups.com> Message-ID: <14bb9a25-01bc-4639-93b3-5658eded2aa8@f36g2000hsa.googlegroups.com> On Apr 29, 9:20?am, Paul McGuire wrote: > On Apr 29, 8:46?am, Julien wrote: > > > I'd like to select terms in a string, so I can then do a search in my > > database. > > > query = ' ? " ?some words" ?with and "without ? ?quotes ? " ?' > > p = re.compile(magic_regular_expression) ? $ <--- the magic happens > > m = p.match(query) > > > I'd like m.groups() to return: > > ('some words', 'with', 'and', 'without quotes') > Oh! It wasn't until Matimus's post that I saw that you wanted the interior whitespace within the quoted strings collapsed also. Just add another parse action to the chain of functions on dblQuotedString: # when a quoted string is found, remove the quotes, # then strip whitespace from the contents, then # collapse interior whitespace dblQuotedString.setParseAction(removeQuotes, lambda s:s[0].strip(), lambda s:" ".join(s[0].split())) Plugging this into the previous script now gives: ('some words', 'with', 'and', 'without quotes') -- Paul From adam_no_spam at no_s.p.a.m.bregenzer.net Sun Apr 13 19:47:32 2008 From: adam_no_spam at no_s.p.a.m.bregenzer.net (Adam Bregenzer) Date: Sun, 13 Apr 2008 18:47:32 -0500 Subject: Controlling copying and pickling of objects written in C References: <3_idnfMhL8pbD5zVnZ2dnUVZ_tPinZ2d@speakeasy.net> Message-ID: <-vidncuD_58JBp_VnZ2dnUVZ_t7inZ2d@speakeasy.net> On Sun, 13 Apr 2008 16:49:51 -0300, Gabriel Genellina wrote: > En Sun, 13 Apr 2008 01:57:42 -0300, Adam Bregenzer > escribi?: > >> I am writing an extension and have "hidden" data included in the >> object's C structure that is not visible to python. I am unsure what >> would happen to that data if the python object were copied or pickled >> and would prefer to raise an exception whenever code tries to copy/deep >> copy/pickle or marshal the object since it would not make sense. Where >> would I look to control that? > > You could raise an exception in __getstate__ - that would make pickle > fail, and probably copy too but I'm not sure of that. Thank you for pointing me in the right direction. Implementing __getstate__ does trigger the exception for copy, however I seem to get the most helpful error messages by implementing __reduce__ and __getstate__ with a reduce related exception message and implementing __copy__ with a copy related exception message. Final question: What is the best exception to use. I am using NotImplementedError since it is deliberately not implemented. Is that correct or would a TypeError exception be more appropriate? Thanks, Adam From TimeHorse at gmail.com Mon Apr 21 07:29:09 2008 From: TimeHorse at gmail.com (TimeHorse) Date: Mon, 21 Apr 2008 04:29:09 -0700 (PDT) Subject: Help with Python+Bazaar+Launchpad Message-ID: Hello, I am trying to to create a branch of the bzr mirror for the current Python Trunk 2.6 development so I can finish my work on Issue 2636. I am not a core developer but am trying to create this branch so it can be reviewed by a core developer I am working with. Because I develop on multiple machines, I want to set up a central repository for my branch database and would like to use Launchpad to host it. Python's bzr archive is mirrored on launchpad via the bzr address lp:python, so that should be the parent branch. I can create a branch on 1 machine locally, but I cannot upload (push) that branch onto launchpad, which is preventing me from doing my development because I don't have access to all machines at all times. I need to have one shared branch between all my development platforms. So, I have tried and failed at all the following: 1) Click the create branch button on the launchpad interface; this creates an empty branch which cannot be populated. 2) Branch from lp:python to a local install then branch from that then try and upload to launchpad. But that means my branch is the child of the child of the mainline-trunk, so merging is too complicated. 3) Branch directly onto launchpad via "bzr branch lp:python bzr+ssh:// @bazaar.launchpad.net/~/python/". This creates a NON-empty branch on Launchpad but I cannot check it out or pull it. Also, it would not be created as a tree-less (--no-trees) which is how it should be created. 4) I have tried to directly use my first branch from step 2 (from lp:python to my local disc) to push an instance onto launchpad, but this creates an empty branch too, and as an empty branch it cannot be checked out or pulled. I know the type of Bazaar setup I want is the type specified in Chapter 5 of the User Guild: decentralized, multi-platform, single- or multiple-user. I just can't figure out how to do that with a branch from python. Chapter 5 talks about setting up a new database with init-repo and pushing new content, but I want to take a branch of an existing database and push it to the public launchpad server. I just can't for the life of me figure out how to do it. I have bzr 1.3 and 1.3.1 and neither have succeeded. Any help would be greatly appreciated as I've totally lost an entire weekend of development which I could have used to complete item 1 of my issue and run gprof over the new engine. I really need help with all this difficult administrative stuff so I can get back to development and get things done in time for the June beta. PLEASE HELP! From paul at boddie.org.uk Thu Apr 3 09:11:40 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Thu, 3 Apr 2008 06:11:40 -0700 (PDT) Subject: Parsing HTML? References: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> Message-ID: <8fc83bb8-ed37-4317-9e3c-bf01f1a0e944@s19g2000prg.googlegroups.com> On 3 Apr, 06:59, Benjamin wrote: > I'm trying to parse an HTML file. I want to retrieve all of the text > inside a certain tag that I find with XPath. The DOM seems to make > this available with the innerHTML element, but I haven't found a way > to do it in Python. With libxml2dom you'd do the following: 1. Parse the file using libxml2dom.parse with html set to a true value. 2. Use the xpath method on the document to select the desired element. 3. Use the toString method on the element to get the text of the element (including start and end tags), or the textContent property to get the text between the tags. See the Package Index page for more details: http://www.python.org/pypi/libxml2dom Paul From pscott at uwc.ac.za Mon Apr 7 07:35:58 2008 From: pscott at uwc.ac.za (Paul Scott) Date: Mon, 07 Apr 2008 13:35:58 +0200 Subject: First Python project - comments welcome! In-Reply-To: References: <1207555415.6966.88.camel@paul-laptop> Message-ID: <1207568158.6966.116.camel@paul-laptop> On Mon, 2008-04-07 at 07:05 -0400, Steve Holden wrote: > The code looks pretty good to someone that doesn't know Gtk graphics. > Err, neither do I, so I guess that means its OK? :) > 184: self.wTree2=gtk.glade.XML(globaldir+"podder.glade","serverdialogue") > > could really do with using os.path.join() if you want to be easily > cross-platform. Similarly the other places you use globaldir+"...". > Ah, OK, will take that into cognisance. Main use of the application will be on Ubuntu based laptops in lecture theatres, so I am not overly concerned, however, in the interests of writing better code, and maybe even making it useful to others outside of my project, I will try and fix it up. > At line 321 you loop while True over a Queue.Queue object until the > QueueEmpty exception is raised, then break out of the loop. It would be > easier to loop while not queue.empty(). I know the docs say that this > function is not reliable due to multi-threading semantics, but I doubt > it will make your program less responsive. > That class is not yet even implemented. I put that code in there to do an upload progress bar for the XML-RPC call, but can't yet figure out how to do it properly. That being said, I will take your notes into consideration when I get to it. Thanks! > You even put docstrings on your code. WEll done, you are going to enjoy > Python. Force of habit. :) Thanks very much for your comments, I *really* appreciate it! --Paul -------------- next part -------------- All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm From wizzardx at gmail.com Sun Apr 27 15:22:39 2008 From: wizzardx at gmail.com (David) Date: Sun, 27 Apr 2008 21:22:39 +0200 Subject: design choice: multi-threaded / asynchronous wxpython client? In-Reply-To: <708eaa6d-3893-407e-83ec-4e6104b0a130@q24g2000prf.googlegroups.com> References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> <002cd046-f11d-482e-a67d-4a10a97687a1@x19g2000prg.googlegroups.com> <708eaa6d-3893-407e-83ec-4e6104b0a130@q24g2000prf.googlegroups.com> Message-ID: <18c1e6480804271222j3bb46333g4457d8af40d49667@mail.gmail.com> > Tempting thought, but one of the problems with this kind of horse > racing tote data is that a lot of it is for combinations of runners > rather than single runners. Whilst there might be (say) 14 horses in a > race, there are 91 quinella price combinations (1-2 through 13-14, > i.e. the 2-subsets of range(1, 15)) and 364 trio price combinations. > It is not really practical (I suspect) to have database tables with > columns for that many combinations? If you normalise your tables correctly, these will be represented as one-to many or many-to-many relationships in your database. Like the other poster I don't know the first thing about horses, and I may be misunderstanding something, but here is one (basic) normalised db schema: tables & descriptions: - horse - holds info about each horse - race - one record per race. Has times, etc - race_hourse - holds records linking horses and races together. You can derive all possible horse combinations from the above info. You don't need to store it in the db unless you need to link something else to it (eg: betting data). In which case: - combination - represents one combination of horses. - combination_horse - links a combinaition to 1 horse. 1 of these per horse per combination. - bet - Represents a bet. Has foreign relationship with combination (and other tables, eg: better, race) With a structure like the above you don't need hudreds of database columns :-) David. From skanemupp at yahoo.se Thu Apr 10 06:00:38 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 03:00:38 -0700 (PDT) Subject: questions about Exceptions? References: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> <71cc8c25-f5f9-4f21-a9d8-06780bf97608@f63g2000hsf.googlegroups.com> Message-ID: <9af81b1a-3e02-4406-b9d2-0a9b6f46566b@p39g2000prm.googlegroups.com> On 10 Apr, 10:51, cokofree... at gmail.com wrote: > In general you should only catch the exceptions you want to catch, > therefore avoiding the issue of catching "unexpected" ones, for > instances the programming unexpectandly closing. > > Well, exception handling is expensive (when it catches one) so it > really is up to you. If you are using eval and know it might "EOF" > then you should probably look to handle that. The main IF statement > style I can think of (checking the end of the string) wouldn't be much > of an improvement. > > Currently I would be very worried about seeing that code as it breaks > a number of "conventions". However it depends on the importance of the > code to wherever or not you should change this. (Global variable, the > use of Eval, the CATCH ALL except and the setting of a global variable > at the end.) > > I've seen a good few (simple and advanced) calculator examples using > python on the NET, it might be worth looking at some to see their > style of coding a calculator to help your own. i know about the GLOBAL stuff, i might rewrite the program using classes later so i can avoid this. i am mainly playin with tkinter for now. i was thinking the same check with if at the beginning and end of the string so there isnt a */ but also if someone uses /// or soemthing like that in the middle it crashes so it is hard to cover every case, esp since **5 means ^5. is the use of if also expensive? From ridenour4159 at gmail.com Thu Apr 24 06:16:44 2008 From: ridenour4159 at gmail.com (ridenour4159 at gmail.com) Date: Thu, 24 Apr 2008 03:16:44 -0700 (PDT) Subject: intervideo windvd keygen Message-ID: intervideo windvd keygen http://cracks.12w.net F R E E C R A C K S From kveretennicov at gmail.com Tue Apr 1 16:01:39 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Tue, 1 Apr 2008 23:01:39 +0300 Subject: XML Parsing In-Reply-To: References: Message-ID: <4660fe300804011301t64934dd0g921cd282d3af8917@mail.gmail.com> On Tue, Apr 1, 2008 at 10:42 PM, Alok Kothari wrote: > Hello, > I am new to XML parsing.Could you kindly tell me whats the > problem with the following code: > > import xml.dom.minidom > import xml.parsers.expat > document = """Lettermanis token>betterthan token>JayLeno""" > This document is not well-formed. It doesn't have root element. ... > > Traceback (most recent call last): > File "C:/Python25/Programs/eg.py", line 20, in > p.Parse(document, 1) > ExpatError: junk after document element: line 1, column 33 > Told ya :) Try wrapping your document in root element, like "......" -- kv -------------- next part -------------- An HTML attachment was scrubbed... URL: From bblais at bryant.edu Sat Apr 19 22:26:55 2008 From: bblais at bryant.edu (Brian Blais) Date: Sat, 19 Apr 2008 22:26:55 -0400 Subject: Frame work for simple physics web applications In-Reply-To: <2b0b8b6c-8086-4bf6-8f47-27bc5c9c788c@v23g2000pro.googlegroups.com> References: <2b0b8b6c-8086-4bf6-8f47-27bc5c9c788c@v23g2000pro.googlegroups.com> Message-ID: <383314A8-C2B6-403C-9B38-B8448D035D0D@bryant.edu> On Apr 19, 2008, at Apr 19:3:55 PM, Rick Muller wrote: > Do any of the AJAX frameworks for Python compare in simplicity to > writing a simple CGI script? I've been impressed with web.py, since it > seems pretty easy to use, but I would go to the trouble of learning > one of the bigger frameworks if they would provide a more elegant > solution. > I'd highly recommend web.py. You can even run it as a cgi script, if you want, but it has its own webserver. For larger scale stuff, they give directions for running it behind apache or lighttpd. It's very easy and flexible. are you using matplotlib for the plots? bb -- Brian Blais bblais at bryant.edu http://web.bryant.edu/~bblais -------------- next part -------------- An HTML attachment was scrubbed... URL: From Robert.Bossy at jouy.inra.fr Mon Apr 28 12:44:15 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Mon, 28 Apr 2008 18:44:15 +0200 Subject: Given a string - execute a function by the same name In-Reply-To: <1209400401.22706.1250293015@webmail.messagingengine.com> References: <1209400401.22706.1250293015@webmail.messagingengine.com> Message-ID: <4815FEDF.6080305@jouy.inra.fr> python at bdurham.com wrote: > I'm parsing a simple file and given a line's keyword, would like to call > the equivalently named function. > > There are 3 ways I can think to do this (other than a long if/elif > construct): > > 1. eval() > > 2. Convert my functions to methods and use getattr( myClass, "method" ) > > 3. Place all my functions in dictionary and lookup the function to be > called > > Any suggestions on the "best" way to do this? (3) is the securest way since the input file cannot induce unexpected behaviour. With this respect (1) is a folly and (2) is a good compromise since you still can write a condition before passing "method" to getattr(). Btw, if you look into the guts, you'll realize that (2) is nearly the same as (3)... RB From bruno.desthuilliers at gmail.com Thu Apr 17 10:33:52 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Thu, 17 Apr 2008 07:33:52 -0700 (PDT) Subject: why function got dictionary References: <48075950.7050000@gmail.com> Message-ID: <35f145d8-ee1c-406e-a036-7aa9ff62d971@c65g2000hsa.googlegroups.com> On 17 avr, 16:06, AlFire wrote: > Hi, > > I am seeking an explanation for following: > > Python 2.5.2 (r252:60911, Apr 8 2008, 21:49:41) > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> def g(): return > ... > >>> g.__dict__ > {} > > Q: why function got dictionary? What it is used for? A: everything (or almost) in Python is an object. Including functions, classes, modules etc. From patrickkidd.lists at gmail.com Thu Apr 17 09:30:08 2008 From: patrickkidd.lists at gmail.com (Patrick Stinson) Date: Thu, 17 Apr 2008 07:30:08 -0600 Subject: import hooks In-Reply-To: References: <664bf2b80804151814g480eed02w739047f84d9deb6b@mail.gmail.com> <664bf2b80804160504x72c870d8pdbfe8105a0c5ed11@mail.gmail.com> Message-ID: <664bf2b80804170630j47e6c7a8r692f5d80af2cc13f@mail.gmail.com> Right on, that seemed to work, thanks. This is different than sys.path_hooks though, which requires a callable or string subclass? After some experimentation it looks like you can disallow an import by raising an import error from your meta_path hook. It seems a little weird that python will then raise a new ImportError from import.c:find_module(), but I guess the behavior is desirable.. On Wed, Apr 16, 2008 at 5:17 PM, Gabriel Genellina wrote: > En Wed, 16 Apr 2008 09:04:36 -0300, Patrick Stinson > escribi?: > > > I am defining a simple finder/loader object and adding it to > > sys.meta_path > > like this: > > > > PyRun_SimpleString("import sys; import ousiainternal; sys.meta_path = > > [ousiainternal.OusiaImporter]"); > > You should append to the existing meta_path, not replace it, erasing any > previous content. > And it must be an *instance* of your importer, not the type itself. > Note that you're polluting the __main__ module namespace by using > PyRun_SimpleString; I'd use API calls like PySys_GetObject("meta_path") > and PyList_Append (PEP 302 guarantees it is a list). > > > "sys.meta_path.append(Importer)\n"; > > Here you append to sys.meta_path, but fail to create the instance first. > > > PyRun_SimpleString(importer_source); > > You should check the return value; I bet you got a -1 (failure). > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Patrick Kidd Stinson http://www.patrickkidd.com/ http://pkaudio.sourceforge.net/ http://pksampler.sourceforge.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From deets at nospam.web.de Tue Apr 8 11:53:57 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 08 Apr 2008 17:53:57 +0200 Subject: import statement convention References: <4078bcf4-e68f-45d4-93ce-335ec7a33c5a@v32g2000prd.googlegroups.com> Message-ID: <661iphF2i9sqvU1@mid.uni-berlin.de> MartinRinehart at gmail.com wrote: > By convention, I've read, your module begins with its import > statements. Is this always sensible? > > I put imports that are needed for testing in the test code at the end > of the module. If only a bit of the module has a visual interface, why > pollute the global namespace with 'from Tkinter import *'? Wouldn't > that be better done in a separate class or function? > > Can we do a better job with a thoughtful rewrite of this convention? Or you could write explicit tests in explicit modules instead of mingling both aspects together in one file. Would that be a thoughtful rewrite of your code? Diez From matiassurdi at gmail.com Thu Apr 17 03:11:39 2008 From: matiassurdi at gmail.com (Matias Surdi) Date: Thu, 17 Apr 2008 09:11:39 +0200 Subject: I just killed GIL!!! In-Reply-To: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: It's april 1st again??? sturlamolden escribi?: > Hello Guys... > > I just had one moment of exceptional clarity, during which realized > how I could get the GIL out of my way... It's so simple, I cannot help > wondering why nobody has thought of it before. Duh! Now I am going to > sit and and marvel at my creation for a while, and then go to bed > (it's past 2:30 a.m.) Tomorrow I will contemplate whether to sell this > little secret for big bucks, give it away for free, or just keep it to > myself... :-) > > Now you are probably thinking I reinvented the gunpowder, and are > running multiple processes. Not so. I am not running parallel > processes, like parallel python or the processing module in cheese > shop. I am running multiple THREADS. In fact, I am just using > threading.Thread. The source code is pure Python, so there is no C > magic, and I only used the stuff that's already there in the standard > library. So, I just made CPython do what everyone claim to be > impossible. One single process of CPython is using all the cpu power > of my dual-core laptop. > > > > > From stefan_ml at behnel.de Tue Apr 22 02:59:40 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 22 Apr 2008 08:59:40 +0200 Subject: py3k concerns. An example In-Reply-To: References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: <480D8CDC.8030606@behnel.de> Gabriel Genellina wrote: >> Has the standard library changed that much? I thought was it mainly the >> deletion of old seldom used modules that happens in new releases anyways. > > *and* renaming of old module names that don't follow PEP8, and merging > others into packages for better structure. > That's another point where using the 2to3 tool is necesary -it takes > care of such changes- unless one wants to maintain two branches. conditional imports were never a problem in Python. Once things are in their final place, you can add a try-except and import from two different places - unless (I assume) you want to use 2to3, which might even break this approach. Stefan From dhong at gist.ac.kr Tue Apr 29 20:00:13 2008 From: dhong at gist.ac.kr (Dongpyo Hong) Date: Wed, 30 Apr 2008 12:00:13 +1200 Subject: swig -python can't find _xxx.dll for windows Message-ID: <61B007AA-8ED3-499F-B787-DB6F2511A124@gist.ac.kr> Dear all, I wrapped c++ code with swig, and made _xxx.dll file. But, when I import xxx.py file from Python interpreter: import xxx it keeps saying that "ImportError: No module named _xxx" I checked sys.path and PATH environment. Why is that? Any explanation? --Dongpyo ===== Dongpyo Hong Research Assistant GIST U-VR Lab http://uvr.gist.ac.kr http://uvr.gist.ac.kr/~dhong Tel. +82-62-970-3157 (2279) Fax. +82-62-970-2204 Email. dhong at gist.ac.kr or dongpyo.hong at gmail.com ===== -------------- next part -------------- An HTML attachment was scrubbed... URL: From grante at visi.com Fri Apr 25 20:44:11 2008 From: grante at visi.com (Grant Edwards) Date: Fri, 25 Apr 2008 19:44:11 -0500 Subject: MESSAGE RESPONSE References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> <678v5qF2me5rvU1@mid.uni-berlin.de> <4e89b45d-198c-48ca-a3a6-3ba42448cb2b@e53g2000hsa.googlegroups.com> Message-ID: On 2008-04-25, ajaksu wrote: >> And as such, I find it hard to believe you could lose your job >> over it. > > Me too. That is, until I tried to Google Belcan and Blubaugh > together. May I suggest a new thread to clear that ugly > results? :D I know it's not nice to laugh at things like that, but I can't help it... I never saw the original message, so I didn't know exactly what he was objecting to. I did know that what he was doing was, well, let's just say counter-productive. -- Grant Edwards grante Yow! .. Now KEN and BARBIE at are PERMANENTLY ADDICTED to visi.com MIND-ALTERING DRUGS... From lbonafide at yahoo.com Tue Apr 1 12:57:55 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Tue, 1 Apr 2008 09:57:55 -0700 (PDT) Subject: Is this a good time to start learning python? References: <47f1140e$0$735$a729d347@news.telepac.pt> Message-ID: On Mar 31, 1:36?pm, "Gabriel Genellina" wrote: > Don't be scared by the "backwards incompatible" tag - it's the way to get ? > rid of nasty things that could not be dropped otherwise. I would consider breaking production code to be "nasty" as well. From rui.maciel at gmail.com Tue Apr 1 07:39:56 2008 From: rui.maciel at gmail.com (Rui Maciel) Date: Tue, 01 Apr 2008 12:39:56 +0100 Subject: Is this a good time to start learning python? References: <47f1140e$0$735$a729d347@news.telepac.pt> Message-ID: <47f21f31$0$755$a729d347@news.telepac.pt> After reading all replies I've decided to keep the subscription to this group, crank up the tutorials and start getting my head around Python. Thanks for all the helpful replies. Kudos, everyone! Rui Maciel From erikwickstrom at gmail.com Wed Apr 9 01:19:47 2008 From: erikwickstrom at gmail.com (erikcw) Date: Tue, 8 Apr 2008 22:19:47 -0700 (PDT) Subject: Can't figure out traceback: (error_proto(-ERR EOF) line 121 poplib.py Message-ID: <9904eabb-31e9-42df-b733-522aee7e3654@x19g2000prg.googlegroups.com> Hi, I keep getting this error from poplib: (error_proto(-ERR EOF) line 121 poplib.py Does this mean the connection has timed out? What can I do to deal with it? Thanks! Erik From popuser at christest2.dc.k12us.com Thu Apr 3 15:24:14 2008 From: popuser at christest2.dc.k12us.com (Pop User) Date: Thu, 03 Apr 2008 15:24:14 -0400 Subject: Efficient way of testing for substring being one of a set? In-Reply-To: References: <47f4c18e$0$715$bed64819@news.gradwell.net> <0c7fd327-7b96-4c20-8c74-a528e280b5f3@r9g2000prd.googlegroups.com> Message-ID: <47F52EDE.50904@christest2.dc.k12us.com> bearophileHUGS at lycos.com wrote: > Dennis Benzinger: >> You could use the Aho-Corasick algorithm > Aho-Corasick_algorithm>. >> I don't know if there's a Python implementation yet. > > http://hkn.eecs.berkeley.edu/~dyoo/python/ahocorasick/ > http://nicolas.lehuen.com/download/pytst/ can do it as well. From marco at sferacarta.com Mon Apr 14 07:06:49 2008 From: marco at sferacarta.com (Marco Mariani) Date: Mon, 14 Apr 2008 13:06:49 +0200 Subject: =?GB2312?B?tPC4tDogSmF2YSBvciBDKys/?= In-Reply-To: References: Message-ID: Penny Y. wrote: > Javascript is different from Java at all. I think even rocks know that. Yet, some use of closure and prototype-based inheritance might be interesting to the OP. > Why not Perl? Come on, learning Perl after two years of Python? How harsh. > Perl is a functional language, And gwbasic is object oriented. From pavlovevidence at gmail.com Wed Apr 2 14:14:42 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Wed, 2 Apr 2008 11:14:42 -0700 (PDT) Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> Message-ID: <25b1f081-94dc-461f-b836-9eba2b0907df@c65g2000hsa.googlegroups.com> On Apr 2, 10:52 am, sam wrote: > Then I say: > > -- __id is awful, because it is a trick to prefix names > > and gurus say: > > -- it is good solution for name conflicts > > But somebody may prefix his names with class names and cause nameconflict, so > maybe it is not so good? I would prefer to hear something like "other solutions > were very complex, and our zen says 'Simple is better than complex.', so we > decided to use this simple and not perfect solution" The stated purpose of the name mangling attributes is to minimize accidental conflicts, not to enforce data hiding. Carl Banks From diljeet_kr at yahoo.com Thu Apr 10 07:25:27 2008 From: diljeet_kr at yahoo.com (diljeet kaur) Date: Thu, 10 Apr 2008 16:55:27 +0530 (IST) Subject: problem with using gnuplot/demo.py Message-ID: <574751.90080.qm@web94914.mail.in2.yahoo.com> hi i want to use gnuplot with python i installed it seemingly successfully but when i try to run demo.py it gives the following error Traceback (most recent call last): File "C:\Python23\Lib\site-packages\Gnuplot\demo.py", line 113, in ? demo() File "C:\Python23\Lib\site-packages\Gnuplot\demo.py", line 39, in demo g.reset() File "C:\Python23\Lib\site-packages\Gnuplot\_Gnuplot.py", line 355, in reset self('reset') File "C:\Python23\Lib\site-packages\Gnuplot\_Gnuplot.py", line 199, in __call__ self.gnuplot(s) File "C:\Python23\Lib\site-packages\Gnuplot\gp_win32.py", line 125, in __call__ self.write(s + '\n') im using python23 & gnuplot1.7 please help Save all your chat conversations. Find them online at http://in.messenger.yahoo.com/webmessengerpromo.php -------------- next part -------------- An HTML attachment was scrubbed... URL: From inq1ltd at inqvista.com Fri Apr 11 22:48:17 2008 From: inq1ltd at inqvista.com (jim-on-linux) Date: Fri, 11 Apr 2008 22:48:17 -0400 Subject: tkinter, annoying grid-problem In-Reply-To: <094b0808-053a-4a36-be11-694bb3835bb5@q1g2000prf.googlegroups.com> References: <094b0808-053a-4a36-be11-694bb3835bb5@q1g2000prf.googlegroups.com> Message-ID: <200804112248.18121.inq1ltd@inqvista.com> On Friday 11 April 2008 18:41, skanemupp at yahoo.se wrote: > so my little calculator works perfectly > now. just having some trouble with the > layout. > this whole tkinter-thing seems to be more > tricky than it should be. how can i make > the 4 column of buttons have the same > distance and size between them as the > other 3 columns? and how can i make the > top entry end where the 2nd row entry > ends(meaning the top entry will be > longer)? > > why are the 4th row split from the others? > hard to fix the problems when u dont even > understand why things happen. seems so > llogical a lot of it. i change something > then something unexpected happens. > Look this file over. I built two additional frames. You can control the looks of the progect easier with the additional frames. The calculator DOES NOT WORK. You will have to have to play with it to get the results that you want, which you can do. jim-on-linux http://www.inqvista.com ###################################### class Calc : def __init__ (self) : self.mygui = Tk() self.mygui.title("Calculator") self.MkButtons() def MkButtons(self): mygui = self.mygui dataFra = Frame(mygui) dataFra.grid(row = 0, column = 0) l = Label(dataFra, text="Answer: ") l.grid(row=0, column=0, sticky=EW) self.e = Entry(dataFra) self.e.grid(row=1, column=0, sticky=EW) c = Entry(dataFra) c.grid(row=2, column=0, sticky=EW) x = 1 y = 4 butFra = Frame(mygui) butFra.grid(row=1, column=0) for n in '123+456-789*0()/.': b = Button(butFra, text= n, command = lambda :self.Disp(n), width=2, height=1) b.grid(row=y, column=x, sticky=W) x=x+1 if x==5: x=1 y=y+1 b = Button(butFra, text="^", command=self.Disp, width=2, height=1) b.grid(row=8, column=2, sticky=W) b = Button(butFra, text="C",command=self.Erase, width=2, height=1) b.grid(row=8, column=3, sticky=W) b = Button(butFra, text="c",command=self.Backspace, width=2, height=1) b.grid(row=8, column=4, sticky=W) b = Button(butFra, text="=",command=self.Calc, width=18, height=1) b.grid(row=9, column=1, columnspan=4, sticky=EW) def Disp(self, n): print n, '## n cal 68\n' n = ord(n) self.e.insert( 0,str( n)) def Calc(self): expr=e.get() c.delete(0, END) try: c.insert(END, eval(expr)) except: c.insert(END, "Not computable") def Erase(self): e.delete(0,END) c.delete(0, END) def Backspace(self): a=len(e.get()) e.delete(a-1,END) #e.delete(INSERT, END) #e.delete(ANCHOR,END) if __name__ == '__main__' : Calc() mainloop() ################################### ################################### > from __future__ import division > import Tkinter > from Tkinter import * > > mygui = Tkinter.Tk() > > mygui.title("Calculator") > > l = Label(mygui, text="Answer: ") > l.grid(row=2, column=1, columnspan=2, > sticky=W) > > e = Entry(mygui) > e.grid(row=1, column=1, columnspan=4, > sticky=W) > > c = Entry(mygui) > c.grid(row=2, column=3, columnspan=4, > sticky=W) > > def Disp(nstr): > e.insert(INSERT, nstr) > > def Calc(): > expr=e.get() > c.delete(0, END) > try: > c.insert(END, eval(expr)) > except: > c.insert(END, "Not computable") > > def Erase(): > e.delete(0,END) > c.delete(0, END) > > def Backspace(): > a=len(e.get()) > e.delete(a-1,END) > #e.delete(INSERT, END) > #e.delete(ANCHOR,END) > > > x = 1 > y = 4 > for char in '123+456-789*0()/.': > b = Button(mygui, text=char, > command=lambda n=char:Disp(n), width=2, > height=1) > b.grid(row=y, column=x, sticky=W) > x=x+1 > if x==5: > x=1 > y=y+1 > > b = Button(mygui, text="^", command=lambda > n="**":Disp(n), width=2, height=1) > b.grid(row=8, column=2, sticky=W) > b = Button(mygui, text="C",command=Erase, > width=2, height=1) b.grid(row=8, column=3, > sticky=W) b = Button(mygui, > text="c",command=Backspace, width=2, > height=1) b.grid(row=8, column=4, > sticky=W) b = Button(mygui, > text="=",command=Calc, width=18, height=1) > b.grid(row=9, column=1, columnspan=4, > sticky=W) > > mygui.mainloop() From steve at holdenweb.com Sat Apr 5 17:54:37 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 17:54:37 -0400 Subject: ANN: pry unit testing framework In-Reply-To: <20080405213059.GA19741@nullcube.com> References: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com> <20080405141329.GD15684@nullcube.com> <20080405213059.GA19741@nullcube.com> Message-ID: <47F7F51D.8010405@holdenweb.com> Aldo Cortesi wrote: > Steve, > >> Kay at least has a long history as a contributor in this group, so >> people know how to interpret her remarks and know that her contributions >> are made on the basis of a deep understanding of Python. She is far from >> belonging to the "peanut gallery", and to suggest otherwise betrays >> either ignorance, arrogance, or both. > > While I'm not a regular poster on this list, I have been reading it for > nearly 10 years, so I probably have more context here than you suspect. > At least one mail to this list and a number of personal emails to me > suggest that it is Kay and and indeed you who are temporarily out of > line with the tone of the list. A more impartial re-reading of the > debate so far might make you judge my final, admittedly angry, response > more fairly. > To be fair I wasn't commenting on the whole thread, more on the angry nature of your final reply, and didn't really consider Kay's remarks fully. So perhaps I could ask *both* of you to be more civil to each other, and leave it at that? Storm in a teacup, of course. I'm sure war won;t be declared about this. Consider the 200,000 (?) readers of the group who *didn't* complain about your post and your software as supporters, if you like :-) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From zedshaw at zedshaw.com Sat Apr 5 13:43:06 2008 From: zedshaw at zedshaw.com (Zed A. Shaw) Date: Sat, 5 Apr 2008 13:43:06 -0400 Subject: [ANN] Vellum 0.8: No More YAML, Some Python Message-ID: <20080405134306.b2bc65d6.zedshaw@zedshaw.com> Hello Everyone, This is a very fast announcement to say that I've managed to remove YAML from Vellum, but also to remove Python while still giving you Python. :-) Check out the latest Vellum: http://www.zedshaw.com/projects/vellum/ https://launchpad.net/vellum And you'll notice that the build descriptions are all Python, that you load other build descriptions with import statements, and yet it's still not actually running these build scripts. What the latest Vellum does is use a minimalist parser (vellum/parser.g) that is able to parse just that much syntax and build the data structure. This makes the build files safe from having injected code, but still gives you a full Python build description. This release is still in development, but if you want to install it, first install Zapps: http://www.zedshaw.com/projects/zapps/ And then you can install Vellum. Comments are welcome, especially about the actual safety of the code in vellum/parser.g and vellum/parser.py (generated by Zapps). Have fun. -- Zed A. Shaw - Hate: http://savingtheinternetwithhate.com/ - Good: http://www.zedshaw.com/ - Evil: http://yearofevil.com/ From bruno.desthuilliers at gmail.com Wed Apr 2 18:55:19 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 15:55:19 -0700 (PDT) Subject: function call - default value & collecting arguments References: <_LQIj.9776$HS3.482805@news.siol.net> <7e50544d-6daf-48c2-bb82-be06d3590450@8g2000hsu.googlegroups.com> Message-ID: On 2 avr, 22:32, "Primoz Skale" wrote: > >> I also understand (fairly) how to collect arguments. For example, let's > >> define another function: > > >> def f(*a): > >> print a > > > This means that f takes any number of optional positional arguments. > > If nothing is passed, within f, 'a' will be an empty tuple. Note that > > this is *not* the usual way to define a function taking multiple > > (mandatory) arguments. > > M. Lutz in "Learning Python" had defined it this way. What is the *usual* > way in this case? You mean : "what's the usual way to define a function taking multiple *mandatory* arguments" ? I'd think it's explained in your book ??? def f(a, b, c): print a, b, c But this is such a cs101 point that we're surely misunderstanding each other here. > > > or (slightly more involved, and certainly overkill): > > > def with_default_args(default): > > def decorator(func): > > def wrapper(*args): > > if not args: > > args = default > > return func(*args) > > return wrapper > > return decorator > > > @with_default_args((0,)) > > def f(*a): > > print a[0] > > Now, this is interesting. Thanks! :) Dont take this as a "recommanded" solution to your problem - it was (mostly) to be exhaustive (and a bit on the "showing off" side too to be honest). From arnodel at googlemail.com Sun Apr 6 12:20:56 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 6 Apr 2008 09:20:56 -0700 (PDT) Subject: append to a sublist - please help References: <47f8f743$0$2983$ba620e4c@news.skynet.be> Message-ID: <6e0d2a37-d57e-4fe3-be43-0c0b4eb3c57c@1g2000prg.googlegroups.com> On Apr 6, 5:16?pm, Helmut Jarausch wrote: > Hi, > > I must be blind but I don't see what's going wrong > with > > G=[[]]*2 > > G[0].append('A') > G[1].append('B') > print G[0] > > gives > > ['A', 'B'] > > as well as > print G[1] > > I was expecting > ['A'] > and > ['B'] > respectively. > > Many thanks for enlightening me, > Helmut. > > -- > Helmut Jarausch > > Lehrstuhl fuer Numerische Mathematik > RWTH - Aachen University > D 52056 Aachen, Germany This is in the top two FAQ, here is the relevant section: http://www.python.org/doc/faq/programming/#how-do-i-create-a-multidimensional-list HTH -- Arnaud From nagle at animats.com Thu Apr 10 23:57:20 2008 From: nagle at animats.com (John Nagle) Date: Thu, 10 Apr 2008 20:57:20 -0700 Subject: Python conventions In-Reply-To: References: Message-ID: <47fedf0e$0$36390$742ec2ed@news.sonic.net> Daniel Fetchinson wrote: > I'm sorry to disappoint you but this project has already been completed: > > http://www.python.org/dev/peps/pep-0008/ Good point. It's probably time for CPython to enforce the rule that you can indent with either tabs or spaces, but cannot mix them. Which to use is ideological; mixing them is a bug. John Nagle From sami.islam at NOSPAMbtinternet.com Sun Apr 6 08:41:40 2008 From: sami.islam at NOSPAMbtinternet.com (Sami) Date: Sun, 06 Apr 2008 13:41:40 +0100 Subject: Problems trying to hook own exception function to sys.excepthook In-Reply-To: References: Message-ID: <8r6dneajtO-cWGXanZ2dnUVZ8s7inZ2d@bt.com> Peter Otten wrote: > Sami wrote: > >> Hello, >> >> I am new to Python. >> >> I tried to hook my own ExceptionPrintingFunction sys.excepthook but it >> does not work. >> >> This is what I wrote: >> ----------------------------------------------------------------------- >> import sys >> >> def MyOwnExceptHook(typ, val, tb): >> print "Inside my own hook" >> >> sys.excepthook = MyOwnExceptHook >> >> x = 1/0 >> ----------------------------------------------------------------------- >> This is what I get >> ----------------------------------------------------------------------- >> Traceback (most recent call last): >> File >> "E:/Home/Programming/Python/TryProjects/ExceptHandling1/Except5.py", >> line 8, in >> x = 1/0 >> ZeroDivisionError: integer division or modulo by zero >> ----------------------------------------------------------------------- >> >> I never see "Inside my own hook" which tells me that the hook is not >> being called. What I really want to test is to stop the exception from >> propagating further and leave the program intact. >> >> What am I doing wrong? Please let me know if there are any other newbie >> groups that I should probably try in stead. > > Are you running your code from within idle? It wraps your script in > something like > > try: > # run script > except: > # show traceback > > (Have a look at InteractiveInterpreter.runcode() in code.py if you are > interested in the actual code) > > So your except hook never gets to see the exception and therefore won't be > invoked. Run your script from the commandline and you will see the > behaviour you expected. > > Peter > Great!! Thank you. I have been trying since yesterday to get to the bottom of this. Does this mean that one should always use the command line to run a python program? Sami From gagsl-py2 at yahoo.com.ar Tue Apr 22 15:35:27 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 22 Apr 2008 16:35:27 -0300 Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> Message-ID: En Tue, 22 Apr 2008 13:50:54 -0300, J?r?my Wagner escribi?: > Sure. Python is more readable than Perl, though I have found Python > to have a weird behavior regarding this little issue : > > How can you explain that Python doesn't support the ++ opeator, > whereas at the same time it does support the += operator ??? > > No python developer I know has been able to answer that. Because Python doesn't follow the "boxed variables" model. In other languages i++ changes the "value" stored inside the box "i", but the box itself (the variable) is still the same. Python doesn't have boxes, it has names that refer to objects. For all builtin numeric types, i += 1 creates a *new* object with the resulting value and makes the name "i" refer to this new object. i++ would be confusing because it looks like a mutating operation over i, but in fact it would be an assignment. -- Gabriel Genellina From skip at pobox.com Fri Apr 11 12:24:33 2008 From: skip at pobox.com (skip at pobox.com) Date: Fri, 11 Apr 2008 11:24:33 -0500 Subject: Multiple independent Python interpreters in a C/C++ program? Message-ID: <18431.37057.886339.853171@montanaro-dyndns-org.local> This question was posed to me today. Given a C/C++ program we can clearly embed a Python interpreter in it. Is it possible to fire up multiple interpreters in multiple threads? For example: C++ main thread 1 Py_Initialize() thread 2 Py_Initialize() Do I wind up with two completely independent interpreters, one per thread? I'm thinking this doesn't work (there are bits which aren't thread-safe and are only protected by the GIL), but wanted to double-check to be sure. Thanks, Skip From bj_666 at gmx.net Sat Apr 5 17:17:50 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 5 Apr 2008 21:17:50 GMT Subject: Tkinter, add pressed buttons onto string display string, how to? References: <57605958-5589-4ebe-abdf-73c2d14c8a82@u10g2000prn.googlegroups.com> Message-ID: <65q8juF2gq610U2@mid.uni-berlin.de> On Sat, 05 Apr 2008 13:17:45 -0700, skanemupp wrote: >> input = "hello" >> input += " world" >> print input > > this i know. im wondering how to handle the variable in the actual > program. this exception i get: > Exception in Tkinter callback > Traceback (most recent call last): > File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ > return self.func(*args) > File "C:\Users\saftarn\Desktop\guiexperiments\calculatorGUI.py", > line 48, in > self.btnDisplay = Button(self,text='+',command=lambda > n="+":self.Display(n),width=1,height=1) > File "C:\Users\saftarn\Desktop\guiexperiments\calculatorGUI.py", > line 92, in Display > str = number + str > UnboundLocalError: local variable 'str' referenced before assignment Just like the message says: You are trying to use `str` (on the right hand side of the assignment) before anything is bound to that name. Ciao, Marc 'BlackJack' Rintsch From kveretennicov at gmail.com Tue Apr 8 18:22:47 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Wed, 9 Apr 2008 01:22:47 +0300 Subject: makepy.py not working In-Reply-To: <03e9c33d-d957-4bc0-8568-3a40403eadb9@a70g2000hsh.googlegroups.com> References: <03e9c33d-d957-4bc0-8568-3a40403eadb9@a70g2000hsh.googlegroups.com> Message-ID: <4660fe300804081522g61c51b1fk1fe038f530dbde1b@mail.gmail.com> On Tue, Apr 8, 2008 at 4:18 PM, wrote: > Hallo, > > I've a problem getting makepy running. When I start the tool on my > machine with doubleclick everything is fine. > But when I try this in my Code: > > makepy.py -i "Microsoft Excel 11.0 Object Library(1.5)" This syntax is used to run makepy.py script from command line. > > I am getting an Syntax Error and command: > > makepy.py > > bring me this message on the screen: > > Traceback (most recent call last): > File "", line 1, in > NameError: name 'makepy' is not defined > > Any ideas what I am doing wrong? Python interpreter obviously accepts only valid python code, like this: import win32com.client.makepy win32com.client.makepy.ShowInfo("Microsoft Excel 11.0 Object Library(1.5)") -- kv From paulgeeleher at gmail.com Thu Apr 24 07:32:58 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Thu, 24 Apr 2008 04:32:58 -0700 (PDT) Subject: Spawing a thread and printing dots until it finishes References: Message-ID: <8df7dc55-7f93-4569-9643-21b4c99e2f33@l42g2000hsc.googlegroups.com> On Apr 22, 3:10 pm, sophie_newbie wrote: > Hi, I'm trying to write a piece of code that spawns a thread and > prints dots every half second until the thread spawned is finished. > Code is > something like this: > > import threading > class MyThread ( threading.Thread ): > def run ( self ): > myLongCommand()... > > import time > > t = MyThread() > t.start() > > while t.isAlive(): > print "." > time.sleep(.5) > > print "OK" > > The thing is this doesn't print a dot every half second. It just > pauses for ages until the thread is finished and prints prints ".OK". > But if I take out the "time.sleep(.5)" line it will keep printing dots > really fast until the thread is finished. So it looks like its the > time.sleep(.5) bit that is messing this up somehow? > > Any ideas? > > Thanks! As it happens I've managed to come up with a solution to this problem using a subprocess rather than a thread. Its not exactly rocket science but I thought I'd post it anyway. There are 3 files: ########## dots.py ####################### # a script to print a dot every half second until it is terminated import time import sys while 1 == 1: sys.stdout.write(".") sys.stdout.flush() time.sleep(.5) ######### PrintDots.py ###################### # This is a simple class to spawn off another process that prints dots repeatedly on screen # when printDots() is called and stops when stopDots is called. It is useful in cgi-scripts # where you may want to let the user know that something is happening, rather than looking # at a blank screen for a couple of minutes. import time import subprocess import os from signal import SIGTERM class PrintDots: # the constructor, called when an object is created. def __init__(self): self.pid = 0 # the location of the script that prints the dots self.dotsScript = "dots.py" def printDots(self): self.pid = subprocess.Popen( [ "python", self.dotsScript] ).pid def stopDots(self): os.kill(self.pid, SIGTERM) ############ mainFile.py ############################## # The above can then be called from any cgi-script as follows from PrintDots import PrintDots p = PrintDots() p.printDots() print "Doing R Stuff" my_Call_To_R_That_Takes_A_Long_Time() p.stopDots() print "OK" ############ And low and behold dots are printed on screen every half second while python is talking to R, with an output like this: Doing R Stuff.................................OK From carlwuhwdmckay at gmail.com Sat Apr 26 09:29:41 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:29:41 -0700 (PDT) Subject: fentanyl patch Message-ID: <1f222cea-1d75-4c92-840f-4db724d628de@w7g2000hsa.googlegroups.com> fentanyl patch http://cracks.00bp.com F R E E C R A C K S From bvidinli at gmail.com Wed Apr 23 15:23:55 2008 From: bvidinli at gmail.com (bvidinli) Date: Wed, 23 Apr 2008 22:23:55 +0300 Subject: Python development tools In-Reply-To: References: Message-ID: <36e8a7020804231223l29cae152o266c0d9bcde821d5@mail.gmail.com> i saw boa constructor to be most close to delphi in python editors.. it is still far away from delphi but, it is closest anyway. 2008/4/23, wongjoekmeu at yahoo.com : > Are there any completely free developent tools for python scripts like > IDLE. I have used IDLE , but I want to try out others also. I saw > stuff like PyCrust, but I don't see that it can run the script as > well. > Thanks, > > RR > > -- > http://mail.python.org/mailman/listinfo/python-list > -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From timr at probo.com Tue Apr 1 02:03:14 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 01 Apr 2008 06:03:14 GMT Subject: CTypes, 64 bit windows, 32 bit dll References: <5a0d8c47-f1b7-4eae-9911-b312a1166757@d1g2000hsg.googlegroups.com> Message-ID: <5uj3v39d6e4ok6o7qda4vagfg4h68kv4th@4ax.com> rdahlstrom wrote: >On Mar 31, 12:53 pm, "mimi.vx" wrote: >> On Mar 31, 4:22 pm, rdahlstrom wrote: >> >> > So I have a 64 bit Windows 2003 system, running python 2.5.1.1. >> >> > I can import a Windows .dll (msvcrt or whatever) using ctypes, but >> > when attempting to import another application-specific .dll (tibrv.dll >> > if anyone is familiar with it), I receive the error WindowsError: >> > [Error 193] %1 is not a valid Win32 application. >> >> > I know there's a Windows on Windows (wow) which allows 32 bit >> > processes to run on 64 bit windows - is there a way to work this in >> > somehow? Maybe I'm barking up the wrong tree? >>... >> >> all dlls and python must be 32bit or 64bit, no mixed ... > >Crap, no way to make a 32 bit load, even using the wowexec? No. In Win64, a process is either entirely 32-bit, or entirely 64-bit. To do the kind of crossing you seek, you would need to create a separate process for the 32-bit DLL and use interprocess communication. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From tim.arnold at sas.com Fri Apr 25 13:29:54 2008 From: tim.arnold at sas.com (Tim Arnold) Date: Fri, 25 Apr 2008 13:29:54 -0400 Subject: convert xhtml back to html References: Message-ID: "bryan rasmussen" wrote in message news:mailman.138.1209061180.12834.python-list at python.org... > I'll second the recommendation to use xsl-t, set the output to html. > > > The code for an XSL-T to do it would be basically: > version="1.0"> > > > > > you would probably want to do other stuff than just copy it out but > that's another case. > > Also, from my recollection the solution in CHM to make XHTML br > elements behave correctly was
as opposed to
, at any rate > I've done projects generating CHM and my output markup was well formed > XML at all occasions. > > Cheers, > Bryan Rasmussen Thanks Bryan, Walter, John, Marc, and Stefan. I finally went with the xslt transform which works very well and is simple. regexps would work, but they just scare me somehow. Brian, my tags were formatted as
but the help compiler would issue warnings on each one resulting in log files with thousands of warnings. It did finish the compile though, but it made understanding the logs too painful. Stefan, I *really* look forward to being able to use lxml when I move to RH linux next month. I've been using hp10.20 and never could get the requisite libraries to compile. Once I make that move, maybe I won't have as many markup related questions here! thanks again to all for the great suggestions. --Tim Arnold From hniksic at xemacs.org Wed Apr 9 08:03:14 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Wed, 09 Apr 2008 14:03:14 +0200 Subject: Basic optimization of python. References: <663p3lF2go90rU1@mid.uni-berlin.de> Message-ID: <877if7b5h9.fsf@mulj.homelinux.net> "Diez B. Roggisch" writes: >> Eg: >> a = 1 + 2 >> .vs. >> a = 3 >> which one is more effective? Does the compiler calculate the result at >> compile time? How about constant spreading? > > Algebraic optimizations aren't done AFAIK Just try it: Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> dis.dis(lambda: 10+5) 1 0 LOAD_CONST 2 (15) 3 RETURN_VALUE From jcd at sdf.lonestar.org Fri Apr 18 07:27:37 2008 From: jcd at sdf.lonestar.org (J. Clifford Dyer) Date: Fri, 18 Apr 2008 07:27:37 -0400 Subject: Unicode chr(150) en dash In-Reply-To: <20080418102856.fdf5ddf3.marexposed@googlemail.com> References: <48063434$0$36327$742ec2ed@news.sonic.net> <7dae96d4-48c4-46c9-9aa9-33a263b84ca4@26g2000hsk.googlegroups.com> <20080418102856.fdf5ddf3.marexposed@googlemail.com> Message-ID: <1208518057.6200.6.camel@jcd-desktop> On Fri, 2008-04-18 at 10:28 +0100, marexposed at googlemail.com wrote: > On Thu, 17 Apr 2008 20:57:21 -0700 (PDT) > hdante wrote: > > > Don't use old 8-bit encodings. Use UTF-8. > > Yes, I'll try. But is a problem when I only want to read, not that I'm trying to write or create the content. > To blame I suppose is Microsoft's commercial success. They won't adhere to standars if that doesn't make sense for their business. > > I'll change the approach trying to filter the contents with htmllib and mapping on my own those troubling characters. > Anyway this has been a very instructive dive into unicode for me, I've got things cleared up now. > > Thanks to everyone for the great help. > There are a number of code points (150 being one of them) that are used in cp1252, which are reserved for control characters in ISO-8859-1. Those characters will pretty much never be used in ISO-8859-1 documents. If you're expecting documents of both types coming in, test for the presence of those characters, and assume cp1252 for those documents. Something like: for c in control_chars: if c in encoded_text: unicode_text = encoded_text.decode('cp1252') break else: unicode_text = encoded_text.decode('latin-1') Note that the else matches the for, not the if. You can figure out the characters to match on by looking at the wikipedia pages for the encodings. Cheers, Cliff From nospam1.reifenberg at gmx.de Sat Apr 5 03:41:48 2008 From: nospam1.reifenberg at gmx.de (Nebur) Date: Sat, 5 Apr 2008 00:41:48 -0700 (PDT) Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? References: <47F67798.3060401@gmail.com> Message-ID: <9c46f378-9d6f-4445-be73-d70a1da6ffb2@m44g2000hsc.googlegroups.com> > Implement what? The virus? I haven't said that I'm interested in virus, > I meant I'd like to know WHAT is this No, this was a misunderstanding. What we meant was: when you want to implement a virus, you should use a version control :- D Nebur From kelle.lavoni at gmail.com Wed Apr 16 11:17:09 2008 From: kelle.lavoni at gmail.com (kelle.lavoni at gmail.com) Date: Wed, 16 Apr 2008 08:17:09 -0700 (PDT) Subject: kate hudson bathing suit Message-ID: <7bf02760-96c0-4a34-96bd-50c6a8b9f565@l64g2000hse.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From bijeshn at gmail.com Fri Apr 4 02:07:48 2008 From: bijeshn at gmail.com (bijeshn) Date: Thu, 3 Apr 2008 23:07:48 -0700 (PDT) Subject: splitting an XML file on the basis on basis of XML tags References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> <65klukF2fp6mkU1@mid.uni-berlin.de> Message-ID: <1228b2c2-1dc3-4a7a-8f75-30edfc903dab@d21g2000prf.googlegroups.com> On Apr 3, 11:28?pm, "Diez B. Roggisch" wrote: > > I abuse it because I can (and because I don't generally work with XML > > files larger than 20-30meg) :) > > And the OP never said the XML file for 1TB in size, which makes things > > different. > > Even with small xml-files your advice was not very sound. Yes, it's > tempting to use regexes to process xml. But usually one falls flat on > his face soon - because of whitespace or attribute order or > versus or .. or .. or. > > Use an XML-parser. That's what they are for. And especially with the > pythonic ones like element-tree (and the compatible lxml), its even more > straight-forward than using rexes. > > Diez yeah, i plan to use SAX.. but the thing is how do you do it with that?.... forget 1 TB for now... how do you split an XML file which is something like 70-80 GB... on the basis of my need (thats the post.)? From skanemupp at yahoo.se Sat Apr 5 13:04:56 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 10:04:56 -0700 (PDT) Subject: Tkinter: making buttons the same size? References: <12bad1a6-3b4b-446e-9673-8893cd6838f9@s37g2000prg.googlegroups.com> Message-ID: <3753aa85-c844-4e54-8213-142e50fd8a7e@b5g2000pri.googlegroups.com> how do i do that? i get this error: self.btnDisplay = Button(self,text='1',command=lambda n=1:self.Display(n)) self.btnDisplay.grid(row=3, column=0, padx=5, pady=5, width=1) self.btnDisplay = Button(self,text='/',command=lambda n="/":self.Display(n)) self.btnDisplay.grid(row=6, column=3, padx=5, pady=5, width=1) Traceback (most recent call last): File "C:\Users\saftarn\Desktop\guiexperiments \calcguiworkingshort.py", line 37, in guiFrame = GUIFramework() File "C:\Users\saftarn\Desktop\guiexperiments \calcguiworkingshort.py", line 20, in __init__ self.CreateWidgets() File "C:\Users\saftarn\Desktop\guiexperiments \calcguiworkingshort.py", line 28, in CreateWidgets self.btnDisplay.grid(row=3, column=0, padx=5, pady=5, width=1) File "C:\Python25\lib\lib-tk\Tkinter.py", line 1859, in grid_configure + self._options(cnf, kw)) TclError: bad option "-width": must be -column, -columnspan, -in, - ipadx, -ipady, -padx, -pady, -row, -rowspan, or -sticky From barbaros at ptmat.fc.ul.pt Wed Apr 23 04:54:13 2008 From: barbaros at ptmat.fc.ul.pt (barbaros) Date: Wed, 23 Apr 2008 01:54:13 -0700 (PDT) Subject: help needed with classes/inheritance Message-ID: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> Hello everybody, I am building a code for surface meshes (triangulations for instance). I need to implement Body objects (bodies can be points, segments, triangles and so on), then a Mesh will be a collection of bodies, together with their neighbourhood relations. I also need OrientedBody objects, which consist in a body together with a plus or minus sign to describe its orientation. So, basically an OrientedBody is just a Body with an integer label stuck on it. I implemented it in a very crude manner: ------------------------------------------ class Body: [...] class OrientedBody: def __init__ (self,b,orient=1): # b is an already existing body assert isinstance(b,Body) self.base = b self.orientation = orient ------------------------------------------- My question is: can it be done using inheritance ? I recall that I need three distinct objects: the basic (non-oriented) body, the same body with positive orientation and the same body with negative orientation. Thank you. Cristian Barbarosie http://cmaf.fc.ul.pt/~barbaros From mcaloney at gmail.com Tue Apr 15 11:35:52 2008 From: mcaloney at gmail.com (Chris McAloney) Date: Tue, 15 Apr 2008 11:35:52 -0400 Subject: py3k s***s In-Reply-To: <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: <0A685715-6D44-4D41-87C2-4B971A751E78@gmail.com> On 15-Apr-08, at 12:30 AM, Sverker Nilsson wrote: > No one forces me, but sooner or later they will want a Python 3.0 and > then a 3.1 whatever. > > I don't want that fuzz. As about the C versions, I am not that > worried. What's your point? > > I just like want to write a program that will stay working. And maybe > I can go on with something else hopefully than just compatibility > fixes. They take some work afterall. > > It seems hard with Python. Esp. 2 -> 3 I couldn't help but notice that not only did you not address Gabriel's most important question, you excluded it from the quote below and changed the comma to a period. Gabriel said: "There is a strategy to migrate from 2.x to 3.0, including the 2to3 tool. Have you used it?" *Have* you tried the 2to3 tool? It might help to lessen your concerns a bit. Yes, Python 3 is different from 2.x, but we've known that it was going to be for years and, as has already been pointed out, the devs are being very careful to minimize the pain that the changes will inflict on Python programmers, with tools such as 2to3. Chris > On Apr 15, 5:41 am, "Gabriel Genellina" > wrote: >> En Mon, 14 Apr 2008 23:38:56 -0300, Sverker Nilsson >> escribi?: >> >> >> >>> On Apr 15, 3:50 am, "Gabriel Genellina" >>> wrote: >>>> En Mon, 14 Apr 2008 22:02:38 -0300, Sverker Nilsson >>>> escribi?: >> >>>>> I tried out py3k on my project,http://guppy-pe.sf.net >> >>>> And what happened? >>>> I've seen that your project already supports Python 2.6 so the >>>> migration >>>> path to 3.0 should be easy. >> >>> 2.6 was no big deal, It was an annoyance that they had to make >>> 'as' a >>> reserved word. Annoyances were also with 2.4, and 2.5. No big >>> problems, I could make guppy backwards compatible to 2.3. But that >>> seems not to be possible with Python 3.x ... it is a MUCH bigger >>> change. And it would require a fork of the code bases, in C, >>> Guido has >>> written tha or to sprinkle with #ifdefs. Would not happen soon >>> for me. >>> It takes some work anyways. Do you volunteer, Guido van Rossum? :-) >> >>> It's not exactly easy. Perhaps not very hard anyways. But think of >>> 1000's of such projects. How many do you think there are? I think >>> many. How many do yo think care? I think few. >> >>> When it has been the fuzz with versions before, then I could have >>> the >>> same code still work with older versions. But now it seems I have to >>> fork TWO codes. It's becoming too much. Think of the time you could >>> write a program in C or even C++ and then it'll work. How do you >>> think >>> eg writers of bash or other unix utilities come along. Do they >>> have to >>> rewrite their code each year? No, it stays. And they can be happy >>> about that, and go on to other things. Why should I have to think >>> about staying compatible with the newest fancy Python all the >>> time? NO >>> -- but the answer may be, they don't care, though the others (C/C++, >>> as they rely on) do. :-( >> >> You can stay with Python 2.6 and not support 3.0; nobody will >> force you to >> use it. And nobody will come and wipe out your Python >> installation, be it >> 2.6, 2.1 or whatever. And if you still enjoy using Python 1.5, >> please keep >> using it - it won't disappear the day after 3.0 becomes available. >> >> Regarding the C language: yes, souce code *had* to be modified for >> newer >> versions of the language and/or compiler. See by example, the new >> "restrict" keyword in C99, or the boolean names. The C guys are >> much more >> concerned about backwards compatibility than Python, but they can't >> guarantee that (at risk of freezing the language). The 3.0 >> incompatibilities are all justified, anyway, and Python is >> changing (as a >> language) much more than C - and that's a good thing. >> >> There is a strategy to migrate from 2.x to 3. From ABH at MCHSI.COM Sun Apr 13 12:07:23 2008 From: ABH at MCHSI.COM (Hutch) Date: Sun, 13 Apr 2008 16:07:23 GMT Subject: PythonWin Print Problem.. Build 210 References: Message-ID: <%cqMj.118543$yE1.5692@attbi_s21> "Roger Upole" wrote in message news:mailman.346.1208051713.17997.python-list at python.org... > > "Hutch" wrote in message > news:H29Mj.117410$yE1.54267 at attbi_s21... >> PythonWin has been a very good ide from early version thru 2.4. >> >> All work ok on THREE of my computers with THREE different HP printers. >> >> Now comes 2.5. >> Every thing seems to work the same except when I want to print out a copy >> of the source code of my project (about 38 pages) >> >> Version 2.5 acts like it is going to print out the source code but >> instead >> prints from several 100 to over 2000 BLANK PAGES pages and no source. >> >> Attempting to print out Source on SAME equipment (computers and printers) >> using 2.4 (WITH NO CHANGES TO EQUIPMENT OR SOFTWARE ) results in >> proper print out of source. >> >> Problem has been reported via direct and SourceForge but no response. >> >> Any body else having the same problem? >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > Did you see the response to the bug report on SF ? > http://sourceforge.net/tracker/index.php?func=detail&aid=1907148&group_id=78018&atid=551954 > > There is also some more info in this thread on the python-win32 mailing > list: > http://mail.python.org/pipermail/python-win32/2006-December/005397.html > > Roger Sorry to report after uninstalling both Python 2.5 and Pythonwin 2.5 and reinstalling.. THE PROBLEM IS STILL WITH US... From wizzardx at gmail.com Sun Apr 27 09:53:31 2008 From: wizzardx at gmail.com (David) Date: Sun, 27 Apr 2008 15:53:31 +0200 Subject: Question regarding Queue object In-Reply-To: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> Message-ID: <18c1e6480804270653r2e075061wf442b7b7d9f50ff6@mail.gmail.com> > WaitMsg will get only msg with certain ids, but this is not possible > in Queue object, because Queue provides no method to peek into the > message queue and fetch only matched item. > > Now I'm using an ugly solution, fetch all the messages and put the not > used ones back to the queue. But I want a better performance. Is there > any alternative out there? > You could try a defaultdict containing queues, one queue per message ID. Or you could implement your own thread-safe LookAheadQueue class. David From aahz at pythoncraft.com Fri Apr 4 13:28:21 2008 From: aahz at pythoncraft.com (Aahz) Date: 4 Apr 2008 10:28:21 -0700 Subject: troll poll References: <65eee6F2eg18jU1@mid.uni-berlin.de> <143a9f24-668e-4e30-a803-c272da27f3ff@s13g2000prd.googlegroups.com> Message-ID: In article <143a9f24-668e-4e30-a803-c272da27f3ff at s13g2000prd.googlegroups.com>, alex23 wrote: > >That is awesome, thank you so much for posting this. The usual >response to complaining about the lack of a killfile for Google Groups >has been "use a decent client", but as I'm constantly moving between >machines having a consistent app for usenet has more value to me. That's why I ssh into my ISP for trn3.6 ;-) -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "It is easier to optimize correct code than to correct optimized code." --Bill Harlan From gdetre at princeton.edu Tue Apr 15 21:59:38 2008 From: gdetre at princeton.edu (gdetre at princeton.edu) Date: Tue, 15 Apr 2008 18:59:38 -0700 (PDT) Subject: OverflowError: regular expression code size limit exceeded Message-ID: <3a2194c6-c753-460a-b797-085f0b2228fa@m36g2000hse.googlegroups.com> Dear all, I'm trying to get a large, machine-generated regular expression (many thousands of characters) to work in Python on a Mac (running Leopard), and I keep banging my head against this brick wall: >>> update_implicit_link_regexp_temp() Traceback (most recent call last): File "", line 1, in File "/Users/greg/elisp/freex/freex_sqlalchemy.py", line 715, in update_implicit_link_regexp_temp impLinkRegexp = re.compile(aliasRegexpStr,re.IGNORECASE| re.MULTILINE) File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/re.py", line 180, in compile return _compile(pattern, flags) File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/re.py", line 231, in _compile p = sre_compile.compile(pattern, flags) File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/sre_compile.py", line 530, in compile groupindex, indexgroup OverflowError: regular expression code size limit exceeded I have successfully run this regular expression many times under linux. I tried it first with the default python iinstallation on Leopard, 2.5.1, but I've also tried it with tthe latest .dmg i could find on the python.org site: Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin I'm really lost about how to proceed. Any ideas? Thank you, Greg From sturlamolden at yahoo.no Fri Apr 11 19:18:40 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 11 Apr 2008 16:18:40 -0700 (PDT) Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> <47ffee86$0$6838$2d805a3e@textnews.eweka.nl> <15e5c81b-0b21-44f0-9282-0d1495bc6bb3@z24g2000prf.googlegroups.com> Message-ID: <1e299792-b744-47c5-ae1d-6fb78639f840@w8g2000prd.googlegroups.com> On Apr 12, 12:32 am, Rune Strand wrote: > produce "what I want" without _wasting life_. But Boa is too unstable, > and does not claim otherwise, and there's no descent alternative I'm > aware of. wxFormDesigner is the best there is for wx. QtDesigner ditto for Qt. Glade ditto for GTK. To use them with Python, you should have the GUI saved in an xml resource (.xrc, .ui, or .glade respectively). From aahz at pythoncraft.com Mon Apr 7 20:44:31 2008 From: aahz at pythoncraft.com (Aahz) Date: 7 Apr 2008 17:44:31 -0700 Subject: troll poll References: <143a9f24-668e-4e30-a803-c272da27f3ff@s13g2000prd.googlegroups.com> <93477f36-fd07-4659-b3ab-29b9cc35bb8d@w5g2000prd.googlegroups.com> Message-ID: In article <93477f36-fd07-4659-b3ab-29b9cc35bb8d at w5g2000prd.googlegroups.com>, alex23 wrote: >(Aahz) wrote: >> alex23 wrote: >>> >>>The usual >>>response to complaining about the lack of a killfile for Google Groups >>>has been "use a decent client", but as I'm constantly moving between >>>machines having a consistent app for usenet has more value to me. >> >> That's why I ssh into my ISP for trn3.6 ;-) > >So what you're saying is, basically, "use a decent client"? :) Partially, but I'm also saying that you should use a decent platform. ;-) -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "It is easier to optimize correct code than to correct optimized code." --Bill Harlan From steve at holdenweb.com Wed Apr 16 11:09:37 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 16 Apr 2008 11:09:37 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> Message-ID: Mike Driscoll wrote: > On Apr 16, 9:19 am, Grant Edwards wrote: >> This morning almost half of c.l.p was spam. In order to try to >> not tar both the benign google group users and the malignant >> ones with the same brush, I've been trying to kill usenet spam >> with subject patterns. But that's not a battle you can win, so >> I broke down and joined all the other people that just killfile >> everything posted via google.groups. >> >> AFAICT, if you're a google groups user your posts are not being >> seen by many/most experienced (read "non-google-group") users. >> This is mainly the fault of google who has refused to do >> anything to stem the flood of span that's being sent via Google >> Groups. >> >> -- >> Grant Edwards grante Yow! I would like to >> at urinate in an OVULAR, >> visi.com porcelain pool -- > > Yeah, I noticed that Google Groups has really sucked this week. I'm > using the Google Groups Killfile for Greasemonkey now and it helps a > lot. I like Google, but my loyalty only goes to far. This is a > complete lack of customer service. > Unfortunately this means Google groups users are getting exactly the service they are paying for. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From steve at holdenweb.com Thu Apr 3 02:51:42 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 03 Apr 2008 02:51:42 -0400 Subject: splitting an XML file on the basis on basis of XML tags In-Reply-To: References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> Message-ID: <47F47E7E.3000406@holdenweb.com> bijeshn wrote: > On Apr 2, 5:37 pm, Chris wrote: >> bije... at gmail.com wrote: >>> Hi all, >>> i have an XML file with the following structure:: >>> >>> -----| >>> | >>> | >>> . | >>> . | --------------------> constitutes one record. >>> . | >>> . | >>> . | >>> | >>> | >>> ----| >>> >>> . >>> . >>> . -----------------------| >>> . | >>> . | >>> . |----------------------> there are n >>> records in between.... >>> . | >>> . | >>> . | >>> . ------------------------| >>> . >>> . >>> >>> -----| >>> | >>> | >>> . | >>> . | --------------------> constitutes one record. >>> . | >>> . | >>> . | >>> | >>> | >>> ----| >>> >>> Here is the main root tag of the XML, and ... >>> constitutes one record. What I would like to do is >>> to extract everything (xml tags and data) between nth tag and (n >>> +k)th tag. The extracted data is to be >>> written down to a separate file. >>> Thanks... >> You could create a generator expression out of it: >> >> txt = """ >> 1 >> 2 >> 3 >> 4 >> 5 >> >> """ >> l = len(txt.split('r2>'))-1 >> a = ('%sr2>'%i for j,i in enumerate(txt.split('r2>')) if 0 < j < l >> and i.replace('>','').replace('<','').strip()) >> >> Now you have a generator you can iterate through with a.next() or >> alternatively you could just create a list out of it by replacing the >> outer parens with square brackets.- Hide quoted text - >> >> - Show quoted text - > > Hmmm... will look into it.. Thanks > > the XML file is almost a TB in size... > Good grief. When will people stop abusing XML this way? > so SAX will have to be the parser.... i'm thinking of doing something > to split the file using SAX > ... Any suggestions on those lines..? If there are any other parsers > suitable, please suggest... You could try pulldom, but the documentation is disgraceful. ElementTree.iterparse *might* help. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From sturlamolden at yahoo.no Wed Apr 16 20:57:11 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Wed, 16 Apr 2008 17:57:11 -0700 (PDT) Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <101680ba-a116-414b-8fff-c5b5bd2f4b65@p39g2000prm.googlegroups.com> Message-ID: <5a826503-cf65-43a0-bfba-39b9d8faaaf7@a1g2000hsb.googlegroups.com> On Apr 16, 4:17 am, lxlau... at gmail.com wrote: > Reformulating my question: > > Which GUI tool, wxPython or PyQt, is more pythonic? (Please, ignore > the license issue because I am thinking about FOSS) None of them, all three of them (you forgot PyGTK), or it doesn't matter more. Nobody with their head screwed on right hand code a UI. There are graphical UI designers for that - QtDesigner, Glade, wxFormBuilder. Notice how the VB, Delphi and .NET crowds are doing the same. From svensven at gmail.com Tue Apr 22 06:46:24 2008 From: svensven at gmail.com (sven _) Date: Tue, 22 Apr 2008 12:46:24 +0200 Subject: Working around buffering issues when writing to pipes Message-ID: <3a4166890804220346y5696765cu235065d694c9f4af@mail.gmail.com> Keywords: subprocess stdout stderr unbuffered pty tty pexpect flush setvbuf I'm trying to find a solution to . In short: unless specifically told not to, normal C stdio will use full output buffering when connected to a pipe. It will use default (typically unbuffered) output when connected to a tty/pty. This is why subprocess.Popen() won't work with the following program when stdout and stderr are pipes: #include #include int main() { int i; for(i = 0; i < 5; i++) { printf("stdout ding %d\n", i); fprintf(stderr, "stderr ding %d\n", i); sleep(1); } return 0; } Then subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) is read using polling, but the pipes don't return any data until the program is done. As expected, specifying a bufsize of 0 or 1 in the Popen() call has no effect. See end of mail for example Python scripts. Unfortunately, changing the child program to flush stdout/err or specifying setvbuf(stdout,0,_IONBF,0); is an undesired workaround in this case. I went with pexpect and it works well, except that I must handle stdout and stderr separately. There seems to be no way to do this with pexpect, or am I mistaken? Are there alternative ways of solving this? Perhaps some way of I'm on Linux, and portability to other platforms is not a requirement. s #Test script using subprocess: import subprocess cmd = '/tmp/slow' # The C program shown above print 'Starting...' proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) while True: lineout = proc.stdout.readline() lineerr = proc.stderr.readline() exitcode = proc.poll() if (not lineout and not lineerr) and exitcode is not None: break if not lineout == '': print lineout.strip() if not lineerr == '': print 'ERR: ' + lineerr.strip() print 'Done.' #Test script using pexpect, merging stdout and stderr: import sys import pexpect cmd = '/home/sveniu/dev/logfetch/bin/slow' print 'Starting...' child = pexpect.spawn(cmd, timeout=100, maxread=1, logfile=sys.stdout) try: while True: child.expect('\n') except pexpect.EOF: pass print 'Done.' From sales024 at aaa-replica-watch.com Tue Apr 1 00:44:56 2008 From: sales024 at aaa-replica-watch.com (sales024 at aaa-replica-watch.com) Date: Mon, 31 Mar 2008 21:44:56 -0700 (PDT) Subject: Cheap Girard Perregaux Classic Elegance Watches Replica - Girard Perregaux Watches Wholesale Message-ID: Cheap Girard Perregaux Classic Elegance Watches Replica - Girard Perregaux Watches Wholesale AAA Replica Watches : http://www.watches-replicas.com Girard Perregaux Watches Brands : http://www.watches-replicas.com/girard-perregaux-watches.html Replica Girard Perregaux Classic Elegance Watches : http://www.watches-replicas.com/girard-perregaux-classic-elegance-watches.html China largest replica watches wholesaler, wholesale up to 80% of Girard Perregaux Classic Elegance Replica Watches and Girard Perregaux Classic Elegance Fake Watch. The most famous Swiss brand name watches you can find, replica Girard Perregaux Classic Elegance Watches and fake Girard Perregaux Classic Elegance Watches are also available. All our Girard Perregaux Classic Elegance Watches replicas are crafted in high quality, You will get great profite by ordering our good cheap watches. Girard Perregaux Classic Elegance Watches All Products : Girard Perragaux Classic Elegance 18kt White Gold Brown Leather Mens Watch 49800.0.53.1041 : http://www.watches-replicas.com/GP-49800-0-53-1041-2719.html Girard Perragaux Classic Elegance 18kt Rose Gold Brown Leather Mens Watch 49800.0.52.1041 : http://www.watches-replicas.com/GP-49800-0-52-1041-2720.html Girard Perragaux Classic Elegance 18kt Yellow Gold Brown Leather Mens Watch 49800.0.51.1041 : http://www.watches-replicas.com/GP-49800-0-51-1041-2721.html Girard Perragaux Classic Elegance Stainless Steel Brown Leather Mens Watch 49460.0.11.8158A : http://www.watches-replicas.com/GP-49460-0-11-8158A-2722.html Girard Perragaux Classic Elegance Stainless Steel Brown Leather Mens Watch 49460.0.11.6456A : http://www.watches-replicas.com/GP-49460-0-11-6456A-2723.html Girard Perragaux Classic Elegance Stainless Steel Mens Watch 49400.1.11.817 : http://www.watches-replicas.com/GP-49400-1-11-817-2724.html Girard Perragaux Classic Elegance Stainless Steel Mens Watch 49400.1.11.615 : http://www.watches-replicas.com/GP-49400-1-11-615-2725.html Girard Perragaux Classic Elegance 18kt White Gold Brown Leather Mens Watch 49400.0.53.917 : http://www.watches-replicas.com/GP-49400-0-53-917-2726.html Girard Perragaux Classic Elegance Stainless Steel Mens Watch 25980.1.11.6156 : http://www.watches-replicas.com/GP-25980-1-11-6156-2727.html Girard Perregaux Classic Elegance Mens Watch 49850-52-151-BACD : http://www.watches-replicas.com/girard-perregaux-watch-49850-52-151-BACD-2703.html Girard Perregaux Classic Elegance Mens Watch 49805-53-252-BA6A : http://www.watches-replicas.com/girard-perregaux-watch-49805-53-252-BA6A-2704.html Girard Perregaux Classic Elegance Stainless Steel Mens Watch 49570-1-11-644 : http://www.watches-replicas.com/girard-perregaux-49570-1-11-644-2705.html Girard Perregaux Classic Elegance Stainless Steel Brown Leather Mens Watch 49570-0-11-114 : http://www.watches-replicas.com/girard-perregaux-49570-0-11-114-2706.html Girard Perregaux Classic Elegance 18kt White Gold Black Leather Mens Watch 49530-0-53-4124 : http://www.watches-replicas.com/girard-perregaux-49530-0-53-4124-2707.html Girard Perregaux Classic Elegance 18kt Rose Gold Brown Leather Mens Watch 49530-0-52-7437 : http://www.watches-replicas.com/girard-perregaux-49530-0-52-7437-2708.html Girard Perregaux Classic Elegance 18kt Yellow Gold Brown Leather Mens Watch 49530-0-51-2122 : http://www.watches-replicas.com/girard-perregaux-49530-0-51-2122-2709.html Girard Perregaux Classic Elegance 18kt Yellow Gold Brown Leather Mens Watch 49530-0-51-1121 : http://www.watches-replicas.com/girard-perregaux-49530-0-51-1121-2710.html Girard Perregaux Classic Elegance Stainless Steel Brown Leather Mens Watch 49530-0-11-4154 : http://www.watches-replicas.com/girard-perregaux-49530-0-11-4154-2711.html Girard Perregaux Classic Elegance Stainless Steel Mens Watch 24990-1-11-1041 : http://www.watches-replicas.com/girard-perregaux-24990-1-11-1041-2712.html Girard Perregaux Classic Elegance Stainless Steel Mens Watch 24980-1-11-1041 : http://www.watches-replicas.com/girard-perregaux-24980-1-11-1041-2713.html Girard Perragaux Classic Elegance Stainless Steel Black Leather Mens Watch 49530.0.11.4154 : http://www.watches-replicas.com/girard-perregaux-watch-49530-0-11-4154-2714.html Girard Perragaux Classic Elegance 18kt White Gold Black Leather Mens Watch 49530.0.53.4124 : http://www.watches-replicas.com/GP-49530-0-53-4124-2715.html Girard Perragaux Classic Elegance Stainless Steel Mens Watch 49350.1.11.614 : http://www.watches-replicas.com/GP-49350-1-11-614-2716.html Girard Perragaux Classic Elegance 18kt Yellow Gold Brown Leather Mens Watch 90120.0.51.8158 : http://www.watches-replicas.com/GP-90120-0-51-8158-2717.html Girard Perragaux Classic Elegance 18kt White Gold Brown Leather Mens Watch 49800.0.53.6046 : http://www.watches-replicas.com/GP-49800-0-53-6046-2718.html Girard Perragaux Classic Elegance 18kt Rose Gold Brown Leather Mens Watch 25980.0.52.8158 : http://www.watches-replicas.com/GP-25980-0-52-8158-2728.html Girard Perragaux Classic Elegance Titanium Mens Watch 49800.T. 21.6046 : http://www.watches-replicas.com/GP-49800-T-21-6046-2729.html Girard Perragaux Classic Elegance 18kt Yellow Gold Brown Leather Mens Watch 49800.0.51.2742A : http://www.watches-replicas.com/GP-49800-0-51-2742A-2730.html Girard Perragaux Classic Elegance Stainless Steel Brown Leather Mens Watch 49350.0.11.614 : http://www.watches-replicas.com/GP-49350-0-11-614-2731.html The Same Girard Perregaux Replica Watches Series : Girard Perregaux Ferrari Watches : http://www.watches-replicas.com/girard-perregaux-ferrari-watches.html Girard Perregaux Classic Elegance Watches : http://www.watches-replicas.com/girard-perregaux-classic-elegance-watches.html Girard Perregaux Richeville Watches : http://www.watches-replicas.com/girard-perregaux-richeville-watches.html Girard Perregaux Collection Lady Watches : http://www.watches-replicas.com/girard-perregaux-collection-lady-watches.html Girard Perregaux Vintage 1945 Watches : http://www.watches-replicas.com/girard-perregaux-vintage-1945-watches.html Girard Perregaux Sport Classique Watches : http://www.watches-replicas.com/girard-perregaux-sport-classique-watches.html Girard Perregaux Cat's Eye Watches : http://www.watches-replicas.com/girard-perregaux-cats-eye-watches.html Girard Perregaux Seahawk II Watches : http://www.watches-replicas.com/girard-perregaux-seahawk-ii-watches.html Girard Perregaux Laureato EVO3 Watches : http://www.watches-replicas.com/girard-perregaux-laureato-evo3-watches.html Girard Perregaux Worldwide Time Control Watches : http://www.watches-replicas.com/girard-perregaux-worldwide-time-control-watches.html Girard Perregaux Foudrayante Watches : http://www.watches-replicas.com/girard-perregaux-foudrayante-watches.html From grg2 at comcast.net Tue Apr 29 11:35:19 2008 From: grg2 at comcast.net (A_H) Date: Tue, 29 Apr 2008 08:35:19 -0700 (PDT) Subject: PyExcerlerator details Message-ID: <937af823-9581-416e-85c1-57a5b0cc69de@e39g2000hsf.googlegroups.com> Hi, I'm using PyExcelerator, and it's great, but I can't figure out a few things: (1) I set the cell style to '0.00%' but the style does not work. (2) I want to place a border around the cells( x1, y1, x2, y2 ) but I can't find any example of doing that. Well I do see ONE example, but it erases the cells if I do it after, or when I write to the cells that erases the outline. Surely I don't have to tediously set each cells border? Help? From gagsl-py2 at yahoo.com.ar Fri Apr 4 17:33:29 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 04 Apr 2008 18:33:29 -0300 Subject: python bisect questions References: <6bb6927b-f553-40db-a142-2ce86b9e819f@q27g2000prf.googlegroups.com> Message-ID: En Fri, 04 Apr 2008 18:08:57 -0300, escribi?: >> b) Define a function to extract a "key" from your items such that items >> ? >> compare the same as their keys. For example, key(x) -> x.lower() may be >> ? >> used to compare text case-insensitively. >> Then, use a tuple (key, value) instead of the bare value. When >> extracting ? >> items from the queue, remember to unpack both parts. This is known as >> the ? >> decorate-sort-undecorate pattern; google for it. >> This is the approach used on your code snippet. >> > I liked decorate-sort-undecorate pattern idea. > But is there anyway I can provide information for tie breaking. > so for case, where keyfunc(x) returns same values, > I need to provide additional tie-breaking rules, is that possible to > do? Use as much elements in the tuple as you need. By example, you could have (year, month, amount, invoice_object) - you would get invocies sorted by year, then by month, then by amount. -- Gabriel Genellina From mathieu.malaterre at gmail.com Tue Apr 15 11:23:23 2008 From: mathieu.malaterre at gmail.com (mathieu) Date: Tue, 15 Apr 2008 08:23:23 -0700 (PDT) Subject: ImportError: No module named dl Message-ID: <270c17d0-53b0-451d-ac07-5578524139f4@m1g2000pre.googlegroups.com> Hi there, I cannot figure out where did the 'dl' module went when running python on AMD64 (debian stable). According to the documentation, I have : python >>> import sys >>> help(sys.setdlopenflags) ... setdlopenflags(...) sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL) ... But when -as suggested by the doc- to load dl, I am getting: >>> import dl Traceback (most recent call last): File "", line 1, in ? ImportError: No module named dl dl module is extremely important since I need to load shared lib with RTLD_GLOBAL (and not RTLD_LOCAL) Ref: http://gcc.gnu.org/ml/gcc/2002-05/msg00869.html & http://lists.apple.com/archives/xcode-users/2006/Feb/msg00234.html Thanks -Mathieu From wizzardx at gmail.com Sun Apr 27 11:37:03 2008 From: wizzardx at gmail.com (David) Date: Sun, 27 Apr 2008 17:37:03 +0200 Subject: Question regarding Queue object In-Reply-To: References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> <18c1e6480804270653r2e075061wf442b7b7d9f50ff6@mail.gmail.com> Message-ID: <18c1e6480804270837s4ed11345jb1e5615accbaea6e@mail.gmail.com> (re-cc-ing the list) On Sun, Apr 27, 2008 at 4:40 PM, Terry Yin wrote: > Defaultdict is not an option because there will be a lot of message IDs (and > increasing). I will implement LookAheadQueue class by overriding the Queue > class. > > Thanks for your kind advice. > > BTW, I have been in old-fashion telecommunication R&D for years, where > messages and state machines are heavily used in software development. And > this makes me automatically resort to messages between task-specific > processes/threads when designing any software, even in python. I'm wondering > if this is the right choice, or it's already not a modern way of design. > There are a lot of ways you could go about it, those 2 were the first that came to mind. Another idea would be to have multiple queues, one per thread or per message type "group". The producer thread pushes into the appropriate queues (through an intelligent PutMsg function), and the consumer threads pull from the queues they're interested in and ignore the others. If your apps are heavily threaded you might take a look at Stackless Python: http://www.stackless.com/ David. From timr at probo.com Fri Apr 18 02:55:28 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 18 Apr 2008 06:55:28 GMT Subject: why function got dictionary References: <48075950.7050000@gmail.com> <66p409F2lg89hU1@mid.uni-berlin.de> <4807637C.1050900@gmail.com> Message-ID: <27hg04d4g7o0hsirp2q15uamh201jec56i@4ax.com> AlFire wrote: >Diez B. Roggisch wrote: >>> >>> Q: why function got dictionary? What it is used for? >> >> because it is an object, and you can do e.g. >> > >you mean an object in the following sense? > > >>> isinstance(g,object) >True > >where could I read more about that? This is a very useful feature. As just one example, the CherryPy web server framework lets you define a class to handle one directory in a web site, where each page is mapped to member functions. However, you also need to include support functions that should not be exposed as web pages. To do that, you just add an "exposed" attribute to the function: class MyWebPage: ... def index( self, ... ): pass index.exposed = 1 def notExposed( self, ... ): pass def request( self, ... ): pass request.exposed = 1 -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From deets at nospam.web.de Sat Apr 12 09:44:55 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Sat, 12 Apr 2008 15:44:55 +0200 Subject: Wrapping C++ class with SWIG, Mac OS X In-Reply-To: References: <66aglpF2ihunjU1@mid.uni-berlin.de> Message-ID: <66bsn3F2jbcl7U1@mid.uni-berlin.de> Paul Anton Letnes schrieb: > Okay, installed SIP. Looks promising, following the tutorial on > http://www.riverbankcomputing.com/static/Docs/sip4/sipref.html#using-sip > It should be noted that I am working on a Mac - I know there are some > differences, but it's still UNIX and should work somehow. > > Anyway, I copy-paste and create the Word.h header, write an > implementation in Word.cpp, the SIP wrapper Word.sip and the > configure.py script. I now run configure and make, creating the > following error: > > ~/Desktop/SIP_example $ python configure.py > ~/Desktop/SIP_example $ make > c++ -c -pipe -fPIC -Os -Wall -W -I. -I/sw/include/python2.5 -o > sipwordcmodule.o sipwordcmodule.cpp > c++ -c -pipe -fPIC -Os -Wall -W -I. -I/sw/include/python2.5 -o > sipwordWord.o sipwordWord.cpp > c++ -headerpad_max_install_names -bundle -undefined dynamic_lookup -o > word.so sipwordcmodule.o sipwordWord.o -lword > ld: library not found for -lword > collect2: ld returned 1 exit status > make: *** [word.so] Error 1 > ~/Desktop/SIP_example $ > > SWIG at least works nicely with C... Too bad I know so little about > compilers and libraries, I don't quite understand what the linker (ld) > is complaining about. The simplest tutorial should anyway work? Not knowing C/C++ & linking is certainly something that will get you when trying to wrap libs written in these languages. I'm on OSX myself, and can say that as a unixish system, it is rather friendly to self-compliation needs. However, without having the complete sources & libs, I can't really comment much - the only thing that is clear from above is that the linker does not find the file libword.dylib which you of course need to have somewhere. The good news is that once you've teached the linker where to find it (using LDFLAGS or other means) you are (modulo debugging) done - SIP has apparently grokked your .sip-file. Of course you also must make the library available at runtime. So it must be installed on a location (or that location given with DYLD_LIBRARY_PATH) where the dynamic loader will find it. Diez From xahlee at gmail.com Tue Apr 29 22:48:39 2008 From: xahlee at gmail.com (xahlee at gmail.com) Date: Tue, 29 Apr 2008 19:48:39 -0700 (PDT) Subject: Python's doc problems: sort Message-ID: <929d5ce9-9063-4e6c-98aa-89526f89fba3@y18g2000pre.googlegroups.com> Of my Python and Perl tutorial at http://xahlee.org/perl-python/index.html the most popular page is ?Sorting in Python and Perl? http://xahlee.org/perl-python/sort_list.html For example, in last week, that page is fetched 550 times. The second most popular page, trails quite a distance. Here's the top 3 pages and their number of times fetched: 550 http://xahlee.org/perl-python/sort_list.html 341 http://xahlee.org/perl-python/system_calls.html 222 http://xahlee.org/perl-python/index.html Note that the first 2 pages are far more popular than the entry page the table of contents. Apparently, and also verified by my web log, that people have difficulty in using sort, and they find my pages thru web search engines. ------------------ In 2005, i wrote over ten essays detailing Python's documentation problems. One of them is titled: ?Python Doc Problem Example: sort()? http://xahlee.org/perl-python/python_doc_sort.html It's been 3 years, and python has gone from 2.4.x to 2.5.2. Looking at the current version of the doc, apparently, Python doc of that page hasn't improved a bit. I want to emphasize a point here, as i have done quite emphatically in the past. The Python documentation, is the world's worst technical writing. As far as technical writing goes, it is even worse than Perl's in my opinion. Although i disliked Perl very much, in part that it is lead by a cult figure that manipulates and deceives the populace, but there is at least one aspect of Perl community that is very positive, namely, embrace all walks of life. This aspect is taken by a Perl derivative the Pretty Home Page, and its success surpassed Perl, yet without Perl's cult string. Now, in my experience, the Python community, is filled with politics more so than Perl, and far more fucking assholes with high hats. Python priests: go fuck yourselfs. (disclaimer: all statements about actual persons in this post are statements of opinion.) ---------------------- Now, i find it pertinent to post my essay about the sort documentation problem again. The HTML version with colors and formatting is here: http://xahlee.org/perl-python/python_doc_sort.html Below is a abridged textual version. ------------------------------------- Python Doc Problem Example: sort() Python doc ?3.6.4 Mutable Sequence Types? at http://python.org/doc/2.4/lib/typesseq-mutable.html in which contains the documentation of the ?sort? method of a list. Quote: ?...? As a piece of documentation, this is a lousy one. The question Python doc writers need to ask when evaluating this piece of doc are these: * Can a experienced programer who is expert at several languages but new to Python, and also have read the official Python tutorial, can he, read this doc, and know exactly how to use sort with all the options? * Can this piece of documentation be rewritten fairly easily, so that the answer to the previous question is a resounding yes? To me, the answers to the above questions are No and Yes. Here are some issues with the doc: ? In the paragraph about the ?key? parameter, the illustration given is: ?cmp=str.lower?. It should be be ?key=str.lower? ? This doc lacks examples. One or two examples will help a lot, especially to less experienced programers. (which comprises the majority of readers) In particular, it should give a full example of using the comparison function and one with the ?key? parameter. Examples are particularly needed here because these parameters are functions, often with the ?lambda? construct. These are unusual and advanced constructs among imperative languages. ? This doc fails to mention what happens when the predicate and the shortcut version conflicts. e.g. ?myList.sort(cmp=lambda x,y: cmp(x[0], y[0]), key=lambda x: str(x[1]) )? ? The notation the Python doc has adopted for indicating the syntax of optional parameters, does not give a clear view just exactly what combination of optional parameters can be omitted. The notation: ?s.sort([cmp[, key[, reverse]]])? gives the impression that only trailing arguments can be omitted, which is not true. ? The doc gives no indication of how to omit a optional arg. Should it be ?nul?, ?Null?, 0, or left empty? Since it doesn't give any examples, doc reader who isn't Python experts is left to guess at how true/false values are presented in Python. ? On the whole, the way this doc is written does not give a clear picture of the roles of the supplied options, nor how to use them. Suggested Quick Remedy: add a example of using the cmp function. And a example using the ?key? function. Add a example of Using one of them and with reverse. (the examples need not to come with much explanations. One sentence annotation is better than none.) Other than that, the way the doc is laid out with a terse table and run-on footnotes (employed in several places in Python doc) is not inductive. For a better improvement, there needs to be a overhaul of the organization and the attitude of the entire doc. The organization needs to be programing based, as opposed to implementation or computer science based. (in this regard, one can learn from the Perl folks). As to attitude, the writing needs to be Python-as-is, as opposed to computer science framework, as indicated in the early parts of this critique series. Addendum, 200510: Since Python 2.4 released in 2005-03, a new built-in function sorted() was added. There's no mention of it at the doc page of the sort() method. Addendum, 2005-10 Here's further example of Python's extreme low quality of documentation. In particular, what follows focuses on the bad writing skill aspect, and comments on some language design and quality issues of Python. From the Official Python documentation of the sort() method, at: http://python.org/doc/2.4.2/lib/typesseq-mutable.html, Quote: ?The sort() method takes optional arguments for controlling the comparisons.? It should be ?optional parameter? not ?optional argument?. Their difference is that ?parameter? indicates the variable, while ?argument? indicates the actual value. ?... for controlling the comparisons.? This is a bad writing caused by lack of understanding. No, it doesn't ?control the comparison?. The proper way to say it is that ?the comparison function specifies an order?. ?The sort() and reverse() methods modify the list in place for economy of space when sorting or reversing a large list. To remind you that they operate by side effect, they don't return the sorted or reversed list. ? This is a example of tech-geeking drivel. The sort() and reverse() methods are just the way they are. Their design and behavior are really not for some economy or remind programers of something. The Python doc is bulked with these irrelevant drivels. These littered inanities dragged down the whole quality and effectiveness of the doc. ?Changed in version 2.4: Support for key and reverse was added.? ?In general, the key and reverse conversion processes are much faster than specifying an equivalent cmp function. This is because cmp is called multiple times for each list element while key and reverse touch each element only once.? When sorting something, one needs to specify a order. The easiest way is to simply list all the elements as a sequence. That way, their order is clearly laid out. However, this is in general not feasible and impractical. Therefore, we devised a mathematically condensed way to specify the order, by defining a function f(x,y) that can take any two elements and tell us which one comes first. This, is the gist of sorting a list in any programing language. The ordering function, being a mathematically condensed way of specifying the order, has some constraints. For example, the function should not tell us x < y and y < x. (For a complete list of these constraints, see http://xahlee.org/perl-python/sort_list.html ) With this ordering function, it is all sort needed to sort a list. Anything more is interface complexity. The optional parameters ?key? and ?reverse? in Python's sort method is a interface complexity. What happened here is that a compiler optimization problem is evaded by moving it into the language syntax for programers to worry about. If the programer does not use the ?key? syntax when sorting a large matrix (provided that he knew in advance of the list to be sorted or the ordering function), then he is penalized by a severe inefficiency by a order of magnitude of execution time. This situation, of moving compiler problems to the syntax surface is common in imperative languages. ?Changed in version 2.3: Support for None as an equivalent to omitting cmp was added.? This is a epitome of catering towards morons. ?myList.sort()? is perfect but Pythoners had to add ?myList.sort(None)? interface complexity just because idiots need it. The motivation here is simple: a explicit ?None? gives coding monkeys a direct sensory input of the fact that ?there is no comparison function?. This is like the double negative in black English ?I ain't no gonna do it!?. Logically, ?None? is not even correct and leads to bad thinking. What really should be stated in the doc, is that ?the default ordering function to sort() is the ?cmp? function.?. ?Starting with Python 2.3, the sort() method is guaranteed to be stable. A sort is stable if it guarantees not to change the relative order of elements that compare equal -- this is helpful for sorting in multiple passes (for example, sort by department, then by salary grade).? One is quite surprised to read this. For about a decade of a language's existence, its sort functionality is not smart enough to preserve order?? A sort that preserves original order isn't something difficult to implement. What we have here is sloppiness and poor quality common in OpenSource projects. Also note the extreme low quality of the writing. It employs the jargon ?stable sort? then proceed to explain what it is, then in trying to illustrate the situation, it throws ?multiple passes? and the mysterious ?by department, by salary?. Here's a suggested rewrite: ?Since Python 2.3, the result of sort() no longer rearrange elements where the comparison function returns 0.? Xah xah at xahlee.org ? http://xahlee.org/ ? From willem at stack.nl Mon Apr 14 04:29:03 2008 From: willem at stack.nl (Willem) Date: Mon, 14 Apr 2008 08:29:03 +0000 (UTC) Subject: Game design : Making computer play References: Message-ID: v4vijayakumar wrote: ) On Apr 14, 12:35 pm, Richard Heathfield wrote: )> v4vijayakumar said: )> > In computer based, two player, board games, how to make computer play? )> )> Write some code that works out what the computer player should do. If you )> want a better answer, ask a better question. ) ) I am just implementing a game played in my village (Tamilnadu / ) India), called "aadupuli" (goats and tigers). There are only 23 ) positions and 18 characters (15 goats and 3 tigers). Some of you might ) be aware of this. Odd, I thought there were 25 positions, 20 goats and 4 tigers. *googles* Oh wait, that is Bagh Chal. Roughly the same rules, different board layout and number of tigers. ) I can post initial version of the game (implemented using html/ ) javascript) in couple of hours here. ) ) Welcome any help in making computer to play one of these player. If the board is that small then an exhaustive search might work, but then the computer would be unbeatable. Minmax would be best I guess. SaSW, Willem -- Disclaimer: I am in no way responsible for any of the statements made in the above text. For all I know I might be drugged or something.. No I'm not paranoid. You all think I'm paranoid, don't you ! #EOT From mgi820 at motorola.com Mon Apr 7 14:19:51 2008 From: mgi820 at motorola.com (Gary Duzan) Date: Mon, 7 Apr 2008 18:19:51 +0000 (UTC) Subject: Learning curve for new database program with Python? References: Message-ID: In article , M.-A. Lemburg wrote: >On 2008-04-07 15:30, Greg Lindstrom wrote: >> >> SQL is one of the areas I wish I had mastered (much) earlier in my career > >Fully agree :-) > >Interesting comments in a time where everyone seems to be obsessed >with ORMs. It seems to me that ORM can work if your database isn't too complex and it is the only way your database is going to be accessed. In our case, we have a messy legacy database (lots of tables, triggers, stored procedures, etc., that nobody really understands) with multiple processes hitting it, and so our efforts to integrate Hibernate haven't been terribly smooth. In this environment the hack seems to be to have Hibernate write to its own tables, then have stored procedures sync them with the old tables. Not pretty. Gary Duzan From nospam1.reifenberg at gmx.de Fri Apr 4 11:38:07 2008 From: nospam1.reifenberg at gmx.de (Nebur) Date: Fri, 4 Apr 2008 08:38:07 -0700 (PDT) Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? Message-ID: Hi folks developing with Pydev/Eclipse, this is the second time in about half a year that the following surprise bites me: I've switched between some files in Pydev/Eclipse using the FileNavigator, and when I want to go back to my last-edited *.py file, it is missing. No more in the FileNavigator, no more in the OpenFiles-List of the Editor. Removed anywhere. Erased from the file system. Restorable from the version control only. Only a young orphan *.pyc file is sitting around, showing me I haven't dreamed of editing the file two minutes before. I'm sure I did no delete operations with eclipse, and I'm sure I did not use another application than eclipse in the meantime. No, I can't reproduce it, and I don't know whom to blame (Pydev? Eclipse ? The File System ? A Virus that only 2 times in half a year deletes a single file I'm busy working with, and seems to do nothing else? Myself beeing schizophrenic ??) Someone else already had this effect ? Nebur PS: Debian Etch 64Bit/JFS,Eclipse3.3,Pydev1.3.14. From steve at holdenweb.com Wed Apr 9 08:19:39 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 08:19:39 -0400 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. In-Reply-To: <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> Message-ID: subhabrata.iisc at hotmail.com wrote: [...] > If you know anyone in Bangalore, India expert in python kindly > send him across I can show him the problem in my machine and Indian > Institute of Science(IISc-locally known as TATA INSTITUTE) is a > distinguished place.Any one should know it. > I am in no mood of doing a joke. [...] >> I have a car. I have turned the ignition key but it fails to start. >> Please tell me what is wrong with it. >> Please understand: this is the Internet. The chances that a random responder will know anyone in Bangalore are vanishingly small. I wasn't joking: I was simply (perhaps sarcastically) pointing out that you do not provide enough information for anyone to help with your problem, since you don't explain what the problem is. Fortunately nobody is under any obligation to help here, it's simply done out of kindness. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gagsl-py2 at yahoo.com.ar Wed Apr 9 01:26:56 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 02:26:56 -0300 Subject: Setting default version among multiple python installations References: <47FB3F86.5040702@adventnet.com> Message-ID: En Tue, 08 Apr 2008 06:48:54 -0300, Karthik escribi?: > I am an absolute linux and python newbie. The linux machine(red hat > version 7.2) that i managed to get my hands on had python 1.5(vintage > stuff, i guess) in it. I have installed python 2.5 using the source tar. > However, when i try to access python, i am taken to the older version > only. Have you actually compiled and installed it? See http://docs.python.org/dev/using/index.html -- Gabriel Genellina From stefan_ml at behnel.de Fri Apr 25 06:37:04 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 25 Apr 2008 12:37:04 +0200 Subject: Can you recommend a book? In-Reply-To: References: Message-ID: <4811B450.3030000@behnel.de> noagbodjivictor at gmail.com wrote: > Hello all, I learned Python with the book "Programming Python" by John > Zelle. But today this book is a little bit old. My Python is some kind > old. I need a book that will help me brush my style and keep me up to > date. I would like one with practical examples. > > Can you recommend one? http://wiki.python.org/moin/PythonBooks Stefan From http Wed Apr 2 13:23:28 2008 From: http (Paul Rubin) Date: 02 Apr 2008 10:23:28 -0700 Subject: april fools email backfires References: Message-ID: <7xbq4sf9wv.fsf@ruckus.brouhaha.com> Aaron Watters writes: > Grapevine says that an architect/bigot at a java/spring shop sent > out an April Fools email saying they had decided to port everything > to Django ASAP. > > Of course the email was taken seriously and he got a lot of positive > feedback from line developers and savvy users/managers that they > thought it would be a great idea; it's about time; gotta do > something about this mess... Django, pah. They should switch to something REALLY advanced: http://www.coboloncogs.org/INDEX.HTM From ivory91044 at gmail.com Tue Apr 29 04:56:23 2008 From: ivory91044 at gmail.com (ivory91044 at gmail.com) Date: Tue, 29 Apr 2008 01:56:23 -0700 (PDT) Subject: patch barracks Message-ID: <09e760d0-f5d8-4804-838f-38eea1c78eff@l42g2000hsc.googlegroups.com> patch barracks http://crack.cracksofts.com From malaclypse2 at gmail.com Wed Apr 16 15:18:15 2008 From: malaclypse2 at gmail.com (Jerry Hill) Date: Wed, 16 Apr 2008 15:18:15 -0400 Subject: str class inheritance prob? In-Reply-To: <587C2C9324493D4B96BD6BBCDEAC321AA956C8@exchange3.valvesoftware.com> References: <587C2C9324493D4B96BD6BBCDEAC321AA956C8@exchange3.valvesoftware.com> Message-ID: <16651e80804161218m729af1eer6306a7ec69a8cd70@mail.gmail.com> On Wed, Apr 16, 2008 at 2:35 PM, Hamish McKenzie wrote: > so I'm trying to create a class that inherits from str, but I want to run > some code on the value on object init. this is what I have: You actually want to run your code when creating the new object, not when initializing it. In python, those are two separate steps. Creation of an instance is handled by the class's __new__ method, and initialization is handled by __init__. This makes a big difference when you inherit from an immutable type like str. Try something like this instead: class Path(str): def __new__( cls, path ): clean = str(path).replace('\\','/') while clean.find('//') != -1: clean = clean.replace('//','/') print 'cleaned on __new__:\t',clean return str.__new__(cls, clean) -- Jerry From fennelllindy8241 at gmail.com Mon Apr 28 03:15:32 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:15:32 -0700 (PDT) Subject: strawberry patch Message-ID: strawberry patch http://crack.cracksofts.com From nick at stinemates.org Fri Apr 18 15:17:35 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 12:17:35 -0700 Subject: how turbo geras code works In-Reply-To: References: Message-ID: <20080418191735.GL19281@deviL> On Wed, Apr 16, 2008 at 01:35:29AM -0700, reetesh nigam wrote: > hi. > actually i have developed one small project but now i want to > develope a project with the help of html.. > please help me out > -- > http://mail.python.org/mailman/listinfo/python-list OK. Done -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From deets at nospam.web.de Tue Apr 15 08:32:37 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 15 Apr 2008 14:32:37 +0200 Subject: webcam (usb) access under Ubuntu References: Message-ID: <66jlk1F2ju6c8U1@mid.uni-berlin.de> Berco Beute wrote: > I've been trying to access my webcam using Python, but I failed > miserably. The camera works fine under Ubuntu (using camora and > skype), but I am unable to get WebCamSpy or libfg to access my webcam. > > First I tried webcamspy (http://webcamspy.sourceforge.net/). That > requires pySerial and pyParallel, and optionally pyI2C. Runing > WebCamSpy results in: > > Exception exceptions.AttributeError: "Parallel instance has no > attribute '_fd'" in > ignored > > This seems to come from importing I2C. The application window opens, > but there's an error message: > > NO VIDEO SOURCE FOUND > > Next I tried libfg (http://antonym.org/libfg). I built it, made the > Python bindings and installed it. Unfortunately the following: > >>>>import fg >>>>grabber = fg.Grabber() > > results in: > > fg_open(): open video device failed: No such file or directory > > Since the camera works fine in Ubuntu itself my guess is that the > problem is with the python libraries (or even likelier, my usage of > them). Is there anybody here that was successful in accessing their > webcam on linux using Python? Else I have to reside to Windows and > VideoCapture (which relies on the win32 api and thus is Windows-only), > something I'd rather not do. It has been *ages* since I did this - so take it with a grain of salt. However, back then I was able to access a video camera using gqcam. Looking into the source of that revealed that all it did were some simple ioctl-calls and reading from a /dev/video*-device. That did the trick for me... Additionally, you might consider using gstreamer + the python bindings for that. I was also successful using them - if I remember this conversation tonight or so, I'll send you the sources. Diez Diez From martin at v.loewis.de Fri Apr 25 03:24:09 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Fri, 25 Apr 2008 09:24:09 +0200 Subject: py3k concerns. An example In-Reply-To: <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> Message-ID: <48118719$0$25846$9b622d9e@news.freenet.de> > In my view using a conversion tool on an ongoing basis is > not an option. It just adds a dependancy. What happens when > the conversion tool is upgraded in a non-backwards-compatible > way? Or do we have assurance that it won't be ;)? The latter: if you include a copy of the converter with your package, it won't change unless you change it. If you rely on the copy of the converter that ships with Python 3.0, you have the assurance that it won't change in a non-backwards-compatible manner in all of 3.0.y. Of course, the copies include in later 3.x releases may change, but you'll have to test for the later 3.x releases, anyway, as they may show incompatible changes themselves. > Will changes to the converter > mean that the users of my > converted libraries have to start > using my tools in a different way? No. If the 2to3 converter is changed to support additional source patterns to convert, it either won't affect your code (if you don't use the pattern), or it may convert some of your code that it didn't previously - then that conversion may or may not be correct. So as a consequence, your library may stop working; then you'll have to adjust either your library, or go back to an older version of the converter. In no case, however, will the users of the library need to adjust their code to changing 2to3 output. 2to3 won't change the library API. > I have no interest in adding additional dependancies, > with an additional degree of freedom to break. Then remove the freedom by fixing a specific 2to3 version (e.g. by including it). > So if I want to support both I have to do everything > twice in the expected case and in the best case test > everything twice, at the same time, if I want to > support both versions and keep features in sync. This I don't understand. Why do you think you have to do everything twice? > I still think it's a shame [...] > pps: I have to note that it would be nice if the > ad-hominem (sp?) invective would drop out of > these threads -- it doesn't add a lot, I think. shame 1 a. a painful emotion caused by consciousness of guilt, shortcoming, or impropriety 2 a condition of humiliating disgrace or disrepute So who do you think should feel guilt? Or should be disgraced or disreputed? Regards, Martin From deets at nospam.web.de Tue Apr 1 17:05:22 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 01 Apr 2008 23:05:22 +0200 Subject: Not Sure This Can Be Done... In-Reply-To: <46aeae28-4470-4136-a5f6-040f6468eb32@b5g2000pri.googlegroups.com> References: <46aeae28-4470-4136-a5f6-040f6468eb32@b5g2000pri.googlegroups.com> Message-ID: <65fmclF2f352gU1@mid.uni-berlin.de> gamename schrieb: > Hi, > > I generally have several copies of the same development environment > checked out from cvs at any one time. Each development tree has a > 'tools' dir containing python modules. Scattered in different places > in the tree are various python scripts. > > What I want to do is force my scripts to always look in the closest > 'tools' dir for any custom modules to import. For example: > > tree1/tools > tree1/my_scripts/foo.py > > tree2/tools > tree2/my_scripts/foo.py > > How can I make 'foo.py' always look in '../../tools' for custom > modules? My preference would be to avoid changing the 'foo.py' script > and have some way to resolve it via the environment (like PYTHONPATH, > or .pth files, etc.). > > Anyone have any ideas? Use virtualenv to create a local python, and activate that when developing for that branch. Alternatively, you can of course manipulate the PYTHONPATH yourself - but why should you if virtualenv takes care of that for you? Diez From marexposed at googlemail.com Tue Apr 15 23:25:48 2008 From: marexposed at googlemail.com (marexposed at googlemail.com) Date: Wed, 16 Apr 2008 04:25:48 +0100 Subject: Unicode chr(150) en dash Message-ID: <20080416042548.f5a47b2e.marexposed@googlemail.com> Hello guys & girls I'm pasting an "en dash" (http://www.fileformat.info/info/unicode/char/2013/index.htm) character into a tkinter widget, expecting it to be properly stored into a MySQL database. I'm getting this error: ***************************************************************************** Exception in Tkinter callback Traceback (most recent call last): File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__ return self.func(*args) File "chupadato.py", line 25, in guardar cursor.execute(a) File "C:\Python24\Lib\site-packages\MySQLdb\cursors.py", line 149, in execute query = query.encode(charset) UnicodeEncodeError: 'latin-1' codec can't encode character u'\u2013' in position 52: ordinal not in range(256) ***************************************************************************** Variable 'a' in 'cursor.execute(a)' contains a proper SQL statement, which includes the 'en dash' character just pasted into the Text widget. When I type 'print chr(150)' into a python command line window I get a LATIN SMALL LETTER U WITH CIRCUMFLEX (http://www.fileformat.info/info/unicode/char/00fb/index.htm), but when I do so into a IDLE window I get a hypen (chr(45). Funny thing I quite don't understand is, when I do paste that 'en dash' character into a python command window (I'm using MSWindows), the character is conveniently converted to chr(45) which is a hyphen (I wouldn't mind if I could do that by coding, I mean 'adapting' by visual similarity). I tried searching "en dash" or even "dash" into the encodings folder of python Lib, but I couldn't find anything. I'm using Windows Vista english, Python 2.4, latest MySQLdb. Default encoding changed (while testing) into "iso-8859-1". Thanks for any help. From simon at brunningonline.net Mon Apr 7 09:09:14 2008 From: simon at brunningonline.net (Simon Brunning) Date: Mon, 7 Apr 2008 14:09:14 +0100 Subject: Learning curve for new database program with Python? In-Reply-To: <47f82573$0$36352$742ec2ed@news.sonic.net> References: <47f82573$0$36352$742ec2ed@news.sonic.net> Message-ID: <8c7f10c60804070609r6b2a8a6eo650f77ff0af0d35e@mail.gmail.com> On Sun, Apr 6, 2008 at 2:31 AM, John Nagle wrote: > > Basic SQL isn't that hard. Learn CREATE, SELECT, INSERT, > UPDATE, and DELETE syntax. That's enough for most simple > applications. Agreed. What's more, I've found SQL to be the single most transferable skill in IT.. No matter what language and platform you find yourself working on, you'll find an SQL driven relational database somewhere in the mix. Learning SQL isn't a waste of time, I guarantee it. -- Cheers, Simon B. simon at brunningonline.net http://www.brunningonline.net/simon/blog/ From cokofreedom at gmail.com Wed Apr 2 09:12:05 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Wed, 2 Apr 2008 06:12:05 -0700 (PDT) Subject: Nested try...except References: Message-ID: On Apr 2, 3:06 pm, Magnus.Morab... at gmail.com wrote: > Hi, > > I found the following code on the net - > > http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/%3C20050924104732.5116.qm... at minotaur.apache.org%3E > > def count(self): > - db = sqlite.connect(self.filename, > isolation_level=ISOLATION_LEVEL) > - try: > - try: > - cur = db.cursor() > - cur.execute("select count(*) from sessions") > - return cur.fetchone()[0] > - finally: > - cur.close() > - finally: > - db.close() > > I don't understand though why the second try is not after the line cur > = db.cursor(). Can anyone explain for me why? > > /Barry. Better question is why is there a try with no except... Better yet, WHY is there two TRY statements when there could quite happily be only one... Towards what you are asking, I GUESS...because the author hoped to handle the cases where cur failed to get assigned...but then his .close method of it would likely not work anyway...I mean...does this even work...YUCK From ewertman at gmail.com Thu Apr 24 11:42:16 2008 From: ewertman at gmail.com (Eric Wertman) Date: Thu, 24 Apr 2008 11:42:16 -0400 Subject: Ideas for parsing this text? In-Reply-To: References: Message-ID: <92da89760804240842n17d95461g21d740a6db394346@mail.gmail.com> Thanks to everyone for the help and feedback. It's amazing to me that I've been dealing with odd log files and other outputs for quite a while, and never really stumbled onto a parser as a solution. I got this far, with Paul's help, which manages my current set of files: from pyparsing import nestedExpr,Word,alphanums,QuotedString from pprint import pprint import re import glob files = glob.glob('wsout/*') for file in files : text = open(file).read() text = re.sub('"\[',' [',text) # These 2 lines just drop double quotes text = re.sub('\]"','] ',text) # that aren't related to a string text = re.sub('\[\]','None',text) # this drops the empty [] text = '[ ' + text + ' ]' # Needs an outer layer content = Word(alphanums+"-_./()*=#\\${}| :,;\t\n\r@?&%%") | QuotedString('"',multiline=True) structure = nestedExpr("[", "]", content).parseString(text) pprint(structure[0].asList()) I'm sure there are cooler ways to do some of that. I spent most of my time expanding the characters that constitute content. I'm concerned that over time I'll have things break as other characters show up. Specifically a few of the nodes are of German locale.. so I could get some odd international characters. It looks like pyparser has a constant for printable characters. I'm not sure if I can just use that, without worrying about it? At any rate, thumbs up on the parser! Definitely going to add to my toolbox. On Thu, Apr 24, 2008 at 8:19 AM, Mark Wooding wrote: > > Eric Wertman wrote: > > > I have a set of files with this kind of content (it's dumped from > > WebSphere): > > > > [propertySet "[[resourceProperties "[[[description "This is a required > > property. This is an actual database name, and its not the locally > > catalogued database name. The Universal JDBC Driver does not rely on > > > information catalogued in the DB2 database directory."] > > [name databaseName] > > [required true] > > [type java.lang.String] > > [value DB2Foo]] ...> > > Looks to me like S-expressions with square brackets instead of the > normal round ones. I'll bet that the correct lexical analysis is > approximately > > [ open-list > propertySet symbol > " open-string > [ open-list > [ open-list > resourceProperties symbol > " open-string (not close-string!) > ... > > so it also looks as if strings aren't properly escaped. > > This is definitely not a pretty syntax. I'd suggest an initial > tokenization pass for the lexical syntax > > [ open-list > ] close-list > "[ open-qlist > ]" close-qlist > "..." string > whitespace ignore > anything-else symbol > > Correct nesting should give you two kinds of lists -- which I've shown > as `list' and `qlist' (for quoted-list), though given the nastiness of > the dump you showed, there's no guarantee of correctness. > > Turn the input string (or file) into a list (generator?) of lexical > objects above; then scan that recursively. The lists (or qlists) seem > to have two basic forms: > > * properties, that is a list of the form [SYMBOL VALUE ...] which can > be thought of as a declaration that some property, named by the > SYMBOL, has a particular VALUE (or maybe VALUEs); and > > * property lists, which are just lists of properties. > > Property lists can be usefully turned into Python dictionaries, indexed > by their SYMBOLs, assuming that they don't try to declare the same > property twice. > > There are, alas, other kinds of lists too -- one of the property lists > contains a property `[value []]' which simply contains an empty list. > > The right first-cut rule for disambiguation is probably that a property > list is a non-empty list, all of whose items look like properties, and a > property is an entry in a property list, and (initially at least) > restrict properties to the simple form [SYMBOL VALUE] rather than > allowing multiple values. > > Does any of this help? > > (In fact, this syntax looks so much like a demented kind of S-expression > that I'd probably try to parse it, initially at least, by using a Common > Lisp system's reader and a custom readtable, but that may not be useful > to you.) > > -- [mdw] > > > > -- > http://mail.python.org/mailman/listinfo/python-list > From cokofreedom at gmail.com Fri Apr 11 07:19:29 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Fri, 11 Apr 2008 04:19:29 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> Message-ID: <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> couldn't you just do. #untested new_round(n): answer = round(n) # is answer now odd if answer % 2: return answer - 1 else: return answer From Lie.1296 at gmail.com Mon Apr 7 16:59:36 2008 From: Lie.1296 at gmail.com (Lie) Date: Mon, 7 Apr 2008 13:59:36 -0700 (PDT) Subject: A funnily inconsistent behavior of int and float References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com> <1d11875a-470a-489f-910a-b420a145eb61@a1g2000hsb.googlegroups.com> Message-ID: <79bf5ab5-ff30-4b30-b268-1c77a5dce97f@l28g2000prd.googlegroups.com> On Apr 8, 2:15?am, "Terry Reedy" wrote: (snip) > 2. Replace text with: > Convert a number or string to an integer. ?If no arguments are given, > return 0. ?If a number is given, return number.__int__(). ?Conversion of > floating point numbers to integers truncates towards zero. ?A string must > be a base-radix integer literal optionally preceded by '+' or '-' (with no > space in between) and optionally surrounded by whitespace. ?A base-n > literal consists of the digits 0 to n-1, with 'a' to 'z' (or 'A' to 'Z') > having values 10 to 35. ?The default radix is 10. The allowed values are 0 > and 2-36, with 0 the same as 10. > > If 0 is not the same as 10, the last would have to be changed, but I could > not detect any difference in a quick test. One thing though, I think it should say "may be surrounded by whitespace" as opposed to "optionally surrounded by whitespace". On Apr 7, 1:55 am, Grant Edwards wrote: > On 2008-04-06, Lie wrote: > > > I've noticed some oddly inconsistent behavior with int and float: > > > Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) > > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > >>>> int('- 345') > > -345 > > > works, > > IMO, it oughtn't. > > >>>> float('- 345.083') > > Traceback (most recent call last): > > File "", line 1, in > > ValueError: invalid literal for float(): - 345.083 > > That's the behavior I'd expect. Sorry to confuse you, by works I mean that the interpreter doesn't complain at all, I didn't mean that it works as it should be. From bj_666 at gmx.net Sun Apr 20 09:59:10 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 20 Apr 2008 13:59:10 GMT Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> Message-ID: <6710hdF2mi30gU1@mid.uni-berlin.de> On Sun, 20 Apr 2008 22:46:37 +1000, Hank @ITGroup wrote: > Apology for the previous offensive title~~ > :) > Thanks, Rintsch, Arnaud and Daniel, for replying so soon. > > I redid the experiment. What following is the record - > > ``starting python`` # == Windows Task Manager: > Python.exe *4,076 *K memory-usage == > >>> st1='abcdefg'*999999 # == 10,952 K == > >>> del st1 # == *4,104*K == > >>> st1='abcdefg'*999999 # == 10,952 K == > >>> del st1 # == 4,104 K == > > >>> li = ['abcde']*999999 # == 8,024 K == > >>> del li # == *4,108* K == > > >>> from nltk import FreqDist # == 17,596 == > >>> fd = FreqDist() # == 17,596 == > >>> for i in range(999999):fd.inc(i) # == 53,412 == > >>> del fd # == *28,780* == > >>> fd2 = FreqDist() # == 28,780 == > >>> for i in range(999999):fd2.inc(i) # == 53,412 == > >>> del fd2 # == 28,780 K == > > >>> def foo(): > ... fd3 = FreqDist() > ... for i in range(999999):fd3.inc(i) > > >>> foo() # == *28,788* K == > > >>> def bar(): > ... fd4 = FreqDist() > ... for i in range(999999):fd4.inc(i) > ... del fd4 > # == 28,788 K == > >>> bar() # == 28,788 K == > > > That is my question, after ``del``, sometimes the memory space returns > back as nothing happened, sometimes not... ... > What exactly was happening??? Something. Really it's a bit complex and implementation dependent. Stop worrying about it until it really becomes a problem. First of all there's no guarantee that memory will be reported as free by the OS because it is up to the C runtime library if it "gives back" freed memory to the OS or not. Second the memory management of Python involves "arenas" of objects that only get freed when all objects in it are freed. Third some types and ranges of objects get special treatment as integers that are allocated, some even preallocated and never freed again. All this is done to speed things up because allocating and deallocating loads of small objects is an expensive operation. Bottom line: let the Python runtime manage the memory and forget about the ``del`` keyword. It is very seldom used in Python and if used then to delete a reference from a container and not "bare" names. In your `bar()` function it is completely unnecessary for example because the name `fd4` disappears right after that line anyway. Ciao, Marc 'BlackJack' Rintsch From ivan.illarionov at gmail.com Thu Apr 24 01:21:17 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Wed, 23 Apr 2008 22:21:17 -0700 (PDT) Subject: @classmethod question References: Message-ID: On 24 ???, 07:27, Scott SA wrote: > Hi, > > I'm using the @classemethod decorator for some convenience methods and for some reason, either mental block or otherwise, can't seem to figure out how to elegantly detect if the call is from an instance or not. > > Here's the problem: Within the class definition, 'isinstance' has nothing to compare to because the class does not appear to exist. > > This is NOT a great example, but it outlines the the code: > > class RecipieClass: > def __init__(self): > pass > > @classmethod > def get_ingrendients(self, recipie_list=None): > > if isinstnace(self,RecipieClass): > return self.do_something_interesting() > else: > return do_something_boring(recipie_list) > > Yes, I can test to see if the param exists, but that makes the call exclusive i.e. I can _only_ call it as an instance or with a parameter. > > Why am I doing this? > > It is a series of convenience methods, in this case I'm interacting with a database via an ORM (object-relational model). I want the ability to call a class-ojbect and get related values, or pass some criteria and get related values for them without collecting the records first as instances, then iterating them. I need to call this from several places so I want to be DRY (don't repeat yourself). > > The easiest way to describe this as an analogy would be like having a recipie for cookies and wanting to know all of the ingredients ahead of time. Then, at another time, wanting to know what all the ingredients would be to make cookies, cake and bread (i.e. complete shopping list). > > cookie_recipie = RecipieClass.get_recipie('cookies') > cookie_recipie.get_ingredients() > 2C Flour > 0.5 C Sugar > ... > > RecipieClass.get_ingrendients(['cookies','cake','bread']) > 8C Flour > 2C Sugar > ... > > Of course any suggestions on how this might be better approached would be interesting too. > > TIA, > > Scott Hi, It would make sense to separate instance-level and class-level behaviour with additional 'objects' namespace. e.g. cookie_recipie.get_ingredients() to get ingredients only for cookie recipie and RecipieClass.objects.get_ingrendients([....]) to get all the ingredients. The elegant solution (AFAIK used by Django) would be to use metaclass and the object with custom descriptor for class-object/table level stuff. Something like this: class RecipieMetaclass(type): def __new__(cls, bases, attrs): new_cls = type.__new__(cls, name, bases, attrs) new_cls.objects = IngredientsDescriptor(IngredientsManager()) return new_cls class RecipieClass(object): __metaclass__ = RecipieMetaclass def get_ingredients(self, recipie_list=None): return self.do_something_interesting(recipie_list) class IngredientsManager(object): def get_ingredients(self, recipie_list=None): return do_something_boring(recipie_list) class IngredientsDescriptor(object): def __init__(self, ingredients_manager): self.ingredients_manager = ingredients_manager def __get__(self, instance, type=None): if instance is not None: raise AttributeError, "Access via %s instances is not allowed" % type.__name__ return self.ingredients_manager Then, "at another time, wanting to know what all the ingredients would be to make cookies, cake and bread" you would call: RecipieClass.objects.get_ingrendients(['cookies','cake','bread']) Both Django and Google Apps Engine API use similar concepts and you can learn much more interesting looking in their source code. Regards, -- Ivan From response1 at antypas.net Sat Apr 12 23:16:00 2008 From: response1 at antypas.net (John Antypas) Date: Sat, 12 Apr 2008 20:16:00 -0700 Subject: Looking for a way to include Pyhtho scripting INSIDE a python program Message-ID: <48017af0$0$36399$742ec2ed@news.sonic.net> Hello all, I'm writing in tool in Python that manipulates various data objects read from various streams. I wanted to give the user a chance to do advanced work that could not easily be done from a GUI. At first, I tried putting in a lightweight scripting language, and then I thought, why not include Python in itself -- it is certainly powerful enough. I had assumed I'd present the user with a text window in which they could type arbitrary python code. I'd wrap that code around a function and pass that function a call of objects they could manipulate by calling the methods of that class. 1. How can a python program invoke ANOTHER interpreter? 2. How can I pass the class in as its argument and get the modified class back? I know I can do something very ugly -- call a C method that calls a new python interpreter but that seems VERY ugly. Help? Thanks. From hobgoodoreneyhb at gmail.com Tue Apr 22 11:37:35 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:37:35 -0700 (PDT) Subject: kalkulator ip crack Message-ID: <21e86bcb-bbcc-4631-954a-2c285cc93cfc@m3g2000hsc.googlegroups.com> kalkulator ip crack http://cracks.12w.net F R E E C R A C K S From aaron.watters at gmail.com Wed Apr 30 11:44:19 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 30 Apr 2008 08:44:19 -0700 (PDT) Subject: best way to host a membership site References: <53034dcc-7346-4f71-889c-3278c9e813ec@w1g2000prd.googlegroups.com> Message-ID: On Apr 30, 10:43 am, Jeroen Ruigrok van der Werven wrote: >.... > Werkzeug -http://werkzeug.pocoo.org/ .... Wow. An initial glance looks great! I need help with pronunciation, though :(. (also, I'm a little disappointed because I made some notes that looked a little like this...) -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=slip+nibble From rhamph at gmail.com Wed Apr 16 13:42:38 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Wed, 16 Apr 2008 10:42:38 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> Message-ID: <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> On Apr 16, 10:40 am, Aaron Watters wrote: > On Apr 16, 12:27 pm, Rhamphoryncus wrote: > > > On Apr 16, 6:56 am, Aaron Watters wrote: > > > > I don't get it. It ain't broke. Don't fix it. > > > So how would you have done the old-style class to new-style class > > transition? > > I'd ignore it. I never understood it and never had > any need for it anyway. New-style classes and metaclasses > were a complicated solution to an unimportant problem in > my opinion. And also a fiendish way to make code > inscrutible -- which I thought was more of a Perl thing > than a Python thing, or should be. > > I must be missing some of the deeper issues here. Please > educate me. >>> type(3) >>> (3).__class__ Traceback (most recent call last): File "", line 1, in ? AttributeError: 'int' object has no attribute '__class__' >>> class Foo: pass ... >>> type(Foo()) >>> Foo().__class__ With new-style classes, (3).__class__ returns int and type(Foo()) returns Foo. Of course a lot of other aspects were redesigned at the same time, such as how attributes/methods are looked up. The consequence of that is we got descriptors. Seems like a fair trade to me. Another example of an incompatible change was this: >>> 2**32 Traceback (most recent call last): File "", line 1, in ? OverflowError: integer exponentiation In recent versions of 2.x you get this instead: >>> 2**32 4294967296L Finally, 3.0 changes it to this: >>> 2**32 4294967296 Personally, I find all these changes to be a good thing. They make the language cleaner and more useful. The only reason to not make the changes is that old, crufty, unmaintained libraries & applications might depend on them somehow. If that's more important to you, what you really want is a language who's specs are frozen - much like C effectively is. I hope python doesn't become that for a long time yet, as there's too much it could do better. From turian at gmail.com Fri Apr 18 14:08:45 2008 From: turian at gmail.com (Joseph Turian) Date: Fri, 18 Apr 2008 11:08:45 -0700 (PDT) Subject: Python 2.5 adoption Message-ID: How widely adopted is python 2.5? We are doing some development, and have a choice to make: a) Use all the 2.5 features we want. b) Maintain backwards compatability with 2.4. So I guess the question is, does anyone have a sense of what percent of python users don't have 2.5? Thanks, Joseph From mr.cerutti at gmail.com Fri Apr 11 12:08:17 2008 From: mr.cerutti at gmail.com (Neil Cerutti) Date: Fri, 11 Apr 2008 12:08:17 -0400 Subject: text adventure game problem In-Reply-To: References: Message-ID: <51302a8c0804110908y2afc91ew2aa8ae83383c03dd@mail.gmail.com> On Thu, Apr 10, 2008 at 8:25 PM, Carl Banks wrote: > On Apr 10, 2:20 pm, Tommy Nordgren wrote: > > > On 9 apr 2008, at 03.01, corvettecra... at gmail.com wrote: > > > > > okay, I'm having this one problem with a text adventure game. It's > > > kind of hard to explain, but I'll do my best. > > > [code] > > > > > def prompt_kitchen(): > > > global gold > > > > > Python is not a suitable language for Text Adventure Development. > > Ridiculous. Agreed. "Not suitable" is an exaggeration. However, designing and implementing your own adventure game framework in Python is a total waste of time. Don't do it except for the sake of it. You can even claim one of several Python-based frameworks out of mothballs as a starting point, if you want to use Python. > There are many good reasons why someone might want to use a general > purpose language like Python to write a text adventure, Yes. > such as so > they're not stuck with a quasi hack of a language if they have to do > something that doesn't fit the framework anticipated by the language > designer. That's not a reason, it's FUD. -- Neil Cerutti From bvidinli at gmail.com Tue Apr 15 04:58:57 2008 From: bvidinli at gmail.com (bvidinli) Date: Tue, 15 Apr 2008 11:58:57 +0300 Subject: Boa: howto make child windows really child Message-ID: <36e8a7020804150158m4db54387g3f3a5852db6fe12d@mail.gmail.com> i just started using Boa constructor, but, i dont like child windows floatin,g on my desktop. how can i make all child windows of boa all together, docked in one parent boa window... i found in preferences, general, childFrameStyle, i set it to wx.FRAME_FLOAT_ON_PARENT|wx.FRAME_TOOL_WINDOW but, it did not help as i want it to be... any help is welcome... -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From s0suk3 at gmail.com Thu Apr 17 11:32:49 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 08:32:49 -0700 (PDT) Subject: Unicode chr(150) en dash References: <48063434$0$36327$742ec2ed@news.sonic.net> Message-ID: <77d74442-f47f-4ef1-8cdd-ab93362f16de@l42g2000hsc.googlegroups.com> On Apr 17, 10:10 am, marexpo... at googlemail.com wrote: > Thank you Martin and John, for you excellent explanations. > > I think I understand the unicode basic principles, what confuses me is the usage different applications make out of it. > > For example, I got that EN DASH out of a web page which states at the beggining. That's why I did go for that encoding. But if the browser can properly decode that character using that encoding, how come other applications can't? > > I might need to go for python's htmllib to avoid this, not sure. But if I don't, if I only want to just copy and paste some web pages text contents into a tkinter Text widget, what should I do to succesfully make every single character go all the way from the widget and out of tkinter into a python string variable? How did my browser knew it should render an EN DASH instead of a circumflexed lowercase u? > > This is the webpage in case you are interested, 4th line of first paragraph, there is the EN DASH:http://www.pagina12.com.ar/diario/elmundo/subnotas/102453-32303-2008-... > > Thanks a lot. > Simplemente escribe en ingles. Like this, see? No encodings mess. From hdante at gmail.com Wed Apr 2 09:58:23 2008 From: hdante at gmail.com (hdante) Date: Wed, 2 Apr 2008 06:58:23 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> Message-ID: <77738358-fc19-48a5-83b6-25e5b7e265b8@a1g2000hsb.googlegroups.com> On Apr 2, 10:50 am, Aaron Watters wrote: > > Try Rails' ActiveRecord. Your problems should reduce to (lg lg > > 2)^(1/12). > > python> (log(log(2)))**(1.0/12.0) > Traceback (most recent call last): > File "", line 1, in ? > ValueError: negative number cannot be raised to a fractional power > > So you are saying the problems will get really complex? :) lg(x) == log_2(x) lg(lg(2))^(1/12) == 0. (fortunately I didn't write 3 lg's). :-P > > > Seriously, you'll forget there's a relational database below. (there > > are even intefaces for "relational lists", "trees", etc.) > > My experience with this sort of thing is that it is a bit > like morphine. It can feel really good, and in emergencies I don't have this much experience on either. ;-) > it can save you a lot of pain. But if you use it too often > and too seriously you end up with really big problems. > > -- Aaron Watters > > ===http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=mysterious+obj... From nick at craig-wood.com Wed Apr 2 04:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Wed, 02 Apr 2008 03:30:03 -0500 Subject: bsddb3 thread problem References: <1c00d777-b1eb-438a-85b6-8096a7453829@u36g2000prf.googlegroups.com> Message-ID: anuraguniyal at yahoo.com wrote: > > > Using threads with bsddb3. ?I spent weeks trying to get it to behave > > when threading. ?I gave up in the end and changed to sqlite :-( > > > So does it mean that I will have to use threading locks around access > methods? or that will also fail mysteriously :) In theory bsddb is thread safe if you pass the right flags into the constructor. In practice I had to read the source code of the python interface to work out what flags I was supposed to be passing at all and I'm not convinced I ever got them right. It is really quite confusing the way bsddb objects get constructed! In practice bdsdb just locked up and crashed in lots of odd ways when I abused it with threads, whereas sqlite gave me nice error messages saying something like "you made this handle in thread X but now you are trying to use it in thread Y which won't work". You can probably make bsddb work with threads, but I wasted too much time trying without success! -- Nick Craig-Wood -- http://www.craig-wood.com/nick From ptmcg at austin.rr.com Thu Apr 17 22:39:12 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Thu, 17 Apr 2008 19:39:12 -0700 (PDT) Subject: get quote enclosed field in a line References: <4807e238$1@news.mel.dft.com.au> Message-ID: <06abd891-daa1-428f-a921-bbd3a46fa7cd@m73g2000hsh.googlegroups.com> On Apr 17, 6:50?pm, John Machin wrote: > xah... at gmail.com wrote: > > is there a simple way in perl, python, or awk/shell/pipe, that gets > > the user agent field in a apache log? > > > e.g. the typical line is like this: > > > 189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET / > > Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org > > "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/ > > 5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311 > > Firefox/2.0.0.13" "-" > > > I want the part: "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv: > > 1.8.1.13) Gecko/20080311 Firefox/2.0.0.13". > > C:\junk>type xah.py > import cStringIO, csv, pprint > line = '''189.139.109.235 - etc etc etc''' > f = cStringIO.StringIO(line) > reader = csv.reader(f, delimiter=" ") > row = reader.next() > pprint.pprint(row) > > C:\junk>xah.py > ['189.139.109.235', > ? '-', > ? '-', > ? '[07/Apr/2008:00:00:16', > ? '-0400]', > ? 'GET / Periodic_dosage_dir/lacru/manara.html HTTP/1.1', > ? '200', > ? '1933', > ? 'xahlee.org', > ? 'http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html', > ? 'Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) > Gecko/20080311 Fi > refox/2.0.0.13', > ? '-'] > > If you don't like that, just hang about -- there's sure to be a > pyparsing bus coming by real soon now :-) > > Cheers, > John Beep, beep! You can find a pyparsing-based log server file parser at http://pyparsing.wikispaces.com/space/showimage/httpServerLogParser.py. Vrooom! -- Paul From dcoffin at gmail.com Mon Apr 28 10:48:58 2008 From: dcoffin at gmail.com (dcoffin at gmail.com) Date: Mon, 28 Apr 2008 07:48:58 -0700 (PDT) Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> <18c1e6480804270653r2e075061wf442b7b7d9f50ff6@mail.gmail.com> Message-ID: <5b8a7008-d463-41cb-ba67-1440fe00dfb4@y21g2000hsf.googlegroups.com> I've never used it myself but you may find candygram interesting; http://candygram.sourceforge.net, which AFAIK implements Erlang-style message queues in Python. From reacocard at gmail.com Sat Apr 5 23:50:58 2008 From: reacocard at gmail.com (reacocard) Date: Sat, 5 Apr 2008 20:50:58 -0700 (PDT) Subject: httplib VERY slow Message-ID: <8486e357-1cab-4b30-a060-1750068929ac@1g2000prg.googlegroups.com> Hi, I'm writing a download manager in python, and httplib is being very slow when pulling from localhost or even other servers on the local network. I'm getting about 10MB in 14s with httplib, while wget hits 80MB in less than 3s. You can find the code I made to benchmark this here: http://pastebin.ca/973486 (noslor is mapped to my IP in / etc/hosts) Does anyone have any idea what might be causing this, and how I can fix it? I'm using python2.5 under Ubuntu Linux 8.04 with apache2 for the webserver. Thanks in advance. From deets at nospam.web.de Wed Apr 9 08:09:39 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 09 Apr 2008 14:09:39 +0200 Subject: Basic optimization of python. References: <16061d43-8baf-4117-88e9-28d65a6d4491@n1g2000prb.googlegroups.com> Message-ID: <663q0vF2hnrh2U1@mid.uni-berlin.de> > This is safe, and is done: > >>>> import dis >>>> def f(): x = 1 + 2 > ... >>>> dis.dis(f) > 1 0 LOAD_CONST 3 (3) > 3 STORE_FAST 0 (x) > 6 LOAD_CONST 0 (None) > 9 RETURN_VALUE >>>> So I stand corrected. Any idea when that was introduced? Diez From python.tsp at gmail.com Wed Apr 9 04:29:24 2008 From: python.tsp at gmail.com (pramod sridhar) Date: Wed, 9 Apr 2008 13:59:24 +0530 Subject: Need Help Message-ID: Hello, I would like to access type library files (.tlb) from python. The application (with .tlb extension) controls an external instrument over standard GPIB interface. Is it possible to control this application from Python? If so, how ? Can anyone share or send link of some examples ? Many Thanks in advance, Pramod -------------- next part -------------- An HTML attachment was scrubbed... URL: From antroy at gmail.com Thu Apr 3 10:49:20 2008 From: antroy at gmail.com (Ant) Date: Thu, 3 Apr 2008 07:49:20 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> <88b07549-9751-489b-968f-c3d2db0aba79@s13g2000prd.googlegroups.com> Message-ID: <5c1011e2-37f4-4e3b-bf46-a8cd26710cb2@u36g2000prf.googlegroups.com> On Apr 3, 2:27 pm, George Sakkis wrote: ... > It's even prettier in 2.5: > > any(word in name for word in words) > > George And arguably the most readable yet! From arnodel at googlemail.com Thu Apr 24 04:43:40 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 24 Apr 2008 09:43:40 +0100 Subject: annoying dictionary problem, non-existing keys References: Message-ID: bvidinli writes: > i use dictionaries to hold some config data, > such as: > > conf={'key1':'value1','key2':'value2'} > and so on... > > when i try to process conf, i have to code every time like: > if conf.has_key('key1'): > if conf['key1']<>'': > other commands.... > > > this is very annoying. Especially when you don't have to do this. > in php, i was able to code only like: > if conf['key1']=='someth' > > in python, this fails, because, if key1 does not exists, it raises > an exception. > > MY question: is there a way to directly get value of an > array/tuple/dict item by key, as in php above, even if key may not > exist, i should not check if key exist, i should only use it, if it > does not exist, it may return only empty, just as in php.... At the interactive prompt, type 'help(dict)' and read carefully about the different methods provided by dictionary objects (one called 'get' may be of particular interest to you). HTH -- Arnaud From joeblow at nowhere.nohow Sat Apr 19 06:40:24 2008 From: joeblow at nowhere.nohow (Joe Blow) Date: 19 Apr 2008 10:40:24 GMT Subject: TypeNone field detection References: <480698b3$0$31577$ec3e2dad@news.usenetmonster.com> Message-ID: <4809cc17$0$2862$ec3e2dad@news.usenetmonster.com> On Wed, 16 Apr 2008 21:13:18 -0400, Steve Holden wrote: > > Since there is only one instance of TypeNone (the value we reference as > None) the easiest test is > > if x is None: > Thanks... the "if x is None:" statement is exactly what I was looking for. From deets at nospam.web.de Fri Apr 18 03:28:37 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 18 Apr 2008 09:28:37 +0200 Subject: Can't do a multiline assignment! In-Reply-To: References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <42402158-0b16-42e2-b7a0-9d9a15e8196d@24g2000hsh.googlegroups.com> <0f5c3363-7e23-4a19-b7f8-021f1d6e3f6c@t54g2000hsg.googlegroups.com> Message-ID: <66r0tlF2m5ltpU1@mid.uni-berlin.de> Michael Torrie schrieb: > s0suk3 at gmail.com wrote: >> You didn't really write that at the Python's interpreter, did you? >> It's wrong. The way that would really go at the interpreter is like > > I did actually run it through the interpreter, but I didn't copy and > past it to the e-mail. Thought that I saw this behavior, but clearly I > must not have. > >> classvar1 and classvar2 might be class variables, but in they don't >> work as they would in C++ or Java (like the ones you declare with the >> 'static' modified). > > Still, it's not pythonic to define instance variables in this way, as > far as I can tell. I've seen & used that for quite a while. It is more clear to provide defaults that way. Diez From malaclypse2 at gmail.com Wed Apr 9 13:31:30 2008 From: malaclypse2 at gmail.com (Jerry Hill) Date: Wed, 9 Apr 2008 13:31:30 -0400 Subject: question about string formatting In-Reply-To: <42b9a3ff0804091004s4d60751fh68c82673e8e3f4c3@mail.gmail.com> References: <42b9a3ff0804091004s4d60751fh68c82673e8e3f4c3@mail.gmail.com> Message-ID: <16651e80804091031u5fc752e6s90b54c8675108088@mail.gmail.com> On Wed, Apr 9, 2008 at 1:04 PM, Kelie wrote: > Is there something in Python built-in function or library that will convert > a number 1205466.654 to $1,205,466.65? To add the "$" sign and set the > decimal place is not a problem, but I don't know how to add the thousands > delimiter. The locale module provides this functionality. >>> import locale >>> locale.setlocale(locale.LC_ALL, '') 'English_United States.1252' >>> print locale.currency(1205466.654) $1205466.65 >>> locale.currency(1205466.654, grouping=true) $1,205,466.65 That's using the default locale. For me, that's US English. Other languages and countries have different ways of showing currency: >>> locale.setlocale(locale.LC_ALL, "fr") 'French_France.1252' >>> print locale.currency(1205466.654, grouping=True) 1 205 466,65 ? -- Jerry From mwilson at the-wire.com Wed Apr 30 15:53:16 2008 From: mwilson at the-wire.com (Mel) Date: Wed, 30 Apr 2008 15:53:16 -0400 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> <74c070ce-1b8f-4746-9d1c-ac2227aaf515@y21g2000hsf.googlegroups.com> Message-ID: George Sakkis wrote: > def join(iterable, sep=' ', encode=str): > return sep.join(encode(x) for x in iterable) Actually return encode(sep).join(encode(x) for x in iterable) lest you get TypeErrors for non-string separators. Mel. From torriem at gmail.com Thu Apr 17 19:47:14 2008 From: torriem at gmail.com (Michael Torrie) Date: Thu, 17 Apr 2008 17:47:14 -0600 Subject: Finally had to plonk google gorups. In-Reply-To: References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <4807E182.60604@gmail.com> Mike Driscoll wrote: > I'm confused. First you say Gmail is create for filtering and then you > say it has a broken interface. I like Gmail for some things, but my > inability to create folders is one thing that really bugs me. I can > set up Thunderbird to accept mail from Gmail and do it that way > though. I assume when you say that you only get 1 email in your inbox, > you mean one "errant" email and the rest get filtered to your other > folders, correct? Gmail is perfectly capable of being used by traditional e-mail clients like Thunderbird via IMAP. When this is done, I see mail in folders and threads. The filtering itself is done by the gmail server. You do have to use the web interface to set up the filtering, but once that is done Thunderbird works fabulously. The Gmail webmail interface displays threads in a fundamentally broken way, though. > > Thanks for the response. It's always interesting to see how others > have dealt with the issue. > > Mike From skanemupp at yahoo.se Sat Apr 5 17:23:50 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 14:23:50 -0700 (PDT) Subject: Tkinter, add pressed buttons onto string display string, how to? References: <57605958-5589-4ebe-abdf-73c2d14c8a82@u10g2000prn.googlegroups.com> <65q8juF2gq610U2@mid.uni-berlin.de> Message-ID: <649d9748-c389-411d-9794-9753ddf434b0@d1g2000pra.googlegroups.com> > Just like the message says: You are trying to use `str` (on the right hand > side of the assignment) before anything is bound to that name. > > Ciao, > Marc 'BlackJack' Rintsch i know but i want the variable str(which i found out is a reserved word so i changed it) to be accessible all over __init__ right? so i tried to delcare it in __init__ in the beginning of the framework class but then when i access it in the method Display i get that error. so how should i declare this variable to be able to access it everywhere? i want another method "calculate" that can access the same string later and do the calculations(writing some other code now that will read and interpret that). From steve at holdenweb.com Wed Apr 2 09:59:17 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 02 Apr 2008 09:59:17 -0400 Subject: generator functions: why won't this work? In-Reply-To: <0aaeddf2-ee63-426e-afb3-0e1acb15adef@r9g2000prd.googlegroups.com> References: <0aaeddf2-ee63-426e-afb3-0e1acb15adef@r9g2000prd.googlegroups.com> Message-ID: zillow10 at googlemail.com wrote: > On Apr 2, 4:42 am, "Gabriel Genellina" wrote: >> En Tue, 01 Apr 2008 23:56:50 -0300, escribi?: >> >>> I'm trying to understand generator functions and the yield keyword. >>> I'd like to understand why the following code isn't supposed to work. >>> (What I would have expected it to do is, for a variable number of >>> arguments composed of numbers, tuples of numbers, tuples of tuples, >>> etc., the function would give me the next number "in sequence") >>> #################################### >>> def getNextScalar(*args): >>> for arg in args: >>> if ( isinstance(arg, tuple)): >>> getNextScalar(arg) >>> else: >>> yield arg >>> #################################### >> You're not the first one in getting confused. After all, this schema works >> well for other recursive constructs. >> Perhaps a progression of working code samples will help to understand what >> happens here. The simplest thing would be to just print the items as >> they're encountered, in a recursive call: >> >> py> data = (1, 2, (3,4,(5,6),7)) >> py> >> py> print "1) using print" >> 1) using print >> py> >> py> def getNextScalar(args): >> ... for arg in args: >> ... if isinstance(arg, tuple): >> ... getNextScalar(arg) >> ... else: >> ... print arg >> ... >> py> getNextScalar(data) >> 1 >> 2 >> 3 >> 4 >> 5 >> 6 >> 7 >> >> Now one could try to collect the numbers in a list: >> >> py> print "2) using extend" >> 2) using extend >> py> >> py> def getNextScalar(args): >> ... result = [] >> ... for arg in args: >> ... if isinstance(arg, tuple): >> ... result.extend(getNextScalar(arg)) >> ... else: >> ... result.append(arg) >> ... return result >> ... >> py> getNextScalar(data) >> [1, 2, 3, 4, 5, 6, 7] >> >> Note that we use two different list methods: for individual items, we use >> "append", but for tuples we use "extend" in the recursive call. If extend >> weren't available, we could emulate it with append: >> >> py> print "3) using append" >> 3) using append >> py> >> py> def getNextScalar(args): >> ... result = [] >> ... for arg in args: >> ... if isinstance(arg, tuple): >> ... for item in getNextScalar(arg): >> ... result.append(item) >> ... else: >> ... result.append(arg) >> ... return result >> ... >> py> getNextScalar(data) >> [1, 2, 3, 4, 5, 6, 7] >> >> See how we need an additional loop to iterate over the results that we get >> from the recursive call. >> Now instead of building an intermediate result list, we delegate such task >> over the caller, and we use a generator that just yields items; this way, >> we remove all references to the result list and all result.append calls >> become yield statements. The inner loop has to remain the same. The yield >> statement acts somewhat as an "append" over an outer list created by the >> generator's caller. >> >> py> print "4) using yield" >> 4) using yield >> py> >> py> def getNextScalar(args): >> ... for arg in args: >> ... if isinstance(arg, tuple): >> ... for item in getNextScalar(arg): >> ... yield item >> ... else: >> ... yield arg >> ... >> py> getNextScalar(data) >> >> py> list(getNextScalar(data)) >> [1, 2, 3, 4, 5, 6, 7] >> >> I hope it's more clear now why you have to use yield on the recursive call >> too. >> >> >> Perhaps this: >> >> yield *iterable >> >> could be used as a shortcut for this: >> >> for __temp in iterable: yield __temp >> >> >> >> -- >> Gabriel Genellina > > Thanks to everyone for your very helpful replies. I think I was trying > to use generator functions without first having really read about > iterators (something I still haven't done, although I've managed to > extrapolate some details based on your comments), and therefore really > "putting the cart before the horse". I was interpreting > getNextScalar(arg) on line 3 as a function call in the usual sense > rather than an object that was being created but never used. > > I have a question about the other issue that was pointed out. With > reference to the following (corrected) code: > > def getNextScalar(*args): > for arg in args: > if(isinstance(arg, tuple)): > for f in getNextScalar(*arg): # why not getNextScalar(arg)? > yield f > else: > yield arg > > although I've verified that the line 4 needs to be "for f in > getNextScalar(*arg)" rather than "for f in getNextScalar(arg)" when > passing multiple arguments to the function, I'd just like to test my > understanding of this. Suppose I create the following generator > object: > > g = getNextScalar(1, 2, (3, 4), 5) > > when the iterator reaches the tuple argument (3, 4) then, according to > Steve and George, the * in *arg causes this tuple to be expanded into > positional arguments, and it makes sense to do it this way. But what > happens when getNextScalar(arg) is used instead? I presume that (3,4) > is passed as a single tuple argument, if(isinstance(arg, tuple)) is > true, and the tuple is passed again as an the argument to > getNextScalar()... ad infinitum. The alternative is to define a > function that takes a tuple, as Gabriel has done. > Either approach would work - it just seemed to make more sense to use existing functionality and recurse (at least to me). You should try removing the * from the recursive call. I expect you would find that you (eventually) experience a stack overflow due to the infinite nature of the recursion. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bbxx789_05ss at yahoo.com Sat Apr 5 15:56:25 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sat, 5 Apr 2008 12:56:25 -0700 (PDT) Subject: Tkinter, add pressed buttons onto string display string, how to? References: Message-ID: <370358c4-c7f3-48da-885a-714df9c1a3bb@u69g2000hse.googlegroups.com> On Apr 5, 1:55?pm, 7stud wrote: > skanem... at yahoo.se wrote: > > using tkinter and python i now have a small App (that will hopefully > > soon be a fully functioning calculator) where u can push buttons and > > the corresponding number or operator is shown. > > > when u press 1, "1" appears on the screen, pres + and "+" appears etc. > > > at the moment every output overwrites the previous so what i want to > > do is obviosuly to add every new output to a string so that i can read > > the string and perform the calculation. > > > so i want: > > * ?when pushing the button push the token of the button onto a string > > * display the new string, ie "1+2" for example > > * want to be able to access this string when pressing calculate so i > > can figure out which operators should > > be done first so it can solve something like this: "(1+2*3)(3-4/2)" > > and not just simple "1+2"-stuff. > > > do i have to have some global string-variable in the GUIframework > > then? im not sure where to start... > > input = "hello" > input += " world" > print input > > --output:-- > hello > > A caculator program is pretty complex. ?Based on your rudimentary > questions, I don't think you have enough programming experience to > tackle a project like that yet. --output:-- hello world From marco at sferacarta.com Wed Apr 16 09:16:27 2008 From: marco at sferacarta.com (Marco Mariani) Date: Wed, 16 Apr 2008 15:16:27 +0200 Subject: py3k s***s In-Reply-To: References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: Aaron Watters wrote: > stuff out there you can get so easily -- all the stuff that py3k > will break -- most of which won't get ported -- and if it does can > we be sure it will be tested properly? No, probably you will end > up beta testing someone's quick port of what used to be rock > solid code... This was quite rightly pointed out to me, and > I had to agree that it was a pretty good point. Do you mean Ruby's track in providing backward compatibility is better than Python's? Googling for that a bit, I would reckon otherwise. From james at reggieband.com Fri Apr 18 14:10:09 2008 From: james at reggieband.com (james at reggieband.com) Date: Fri, 18 Apr 2008 11:10:09 -0700 (PDT) Subject: Request a short code review References: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> Message-ID: <33a50f5b-f82d-41aa-b28f-b00dba4bf2eb@m73g2000hsh.googlegroups.com> Thank you all for posting insightful and useful comments. Here is what I have based on your input: def output_random_lesson_of_type(self, lesson_type=None): """Output a lesson of a specific type. If no type is passed in then output all types.""" lessons = self.lesson_data["lessons"] if lesson_type: lessons = [x for x in lessons if x["type"] == lesson_type] rand_lesson = choice(lessons) inputs = self.create_lesson_inputs(rand_lesson) print rand_lesson["output"] % inputs return rand_lesson, inputs Changes: - generator expression instead of filter - removed keyword 'type' in favor of lesson_type - wrap to 78 columns - remove error-check -- allow it to fail in the choice statement. I've decided to make a valid lesson_type an invariant anyway so the appropriate thing would be an assert - but I'll settle for a throw from choice if it receives an empty list - moved self.output_random logic into this function The lesson data is loaded from YAML which explains why it is inside a dictionary instead of a class. I am currently exploring ways to allow me to easily switch my data providers between SQLAlchemy and YAML. Cheers again. This is very valuable for me. I am a true believer that if one takes care in the smallest of methods then the larger code- base will be all the better. James. From mdboldin at gmail.com Wed Apr 16 11:33:27 2008 From: mdboldin at gmail.com (mmm) Date: Wed, 16 Apr 2008 08:33:27 -0700 (PDT) Subject: Creating arithmetic sequences Message-ID: <54221025-2f61-40ad-beef-82cc74234d87@e39g2000hsf.googlegroups.com> I wrote the code below to create simple arithmetic sequences that are iter-able I.e., this would basically combine the NUMPY arange(start,end,step) to range(start,end), with step not necessarily an integer. The code below is in its simplest form and I want to generalize the sequence types (multiplicative, cumulative, gauss ...), but first I need the simple SEQA( ) function to be more robust. The problem is the three test code functions produces different results based on step. I understand why steps such as 0.1 have rounding and machine math issues, and before I try to solve this I thought it was worth asking if this problem has been solved (so I do not re-invent the wheel). Another way to put my question, is there a PYTHON function that emulates SEQA() in APTECH?s GAUSS language and produces iterable lists ? Note I originally wrote the three versions below see which is fastest, but each is fast enough such that I care more about robustness now. ## Python arithmetic sequence implimentation ## MDB April 16 2008 from numpy import array, arange, floor import time # simple arithmetic sequence def seqa1(start,end,step=1): n= floor( (end-start) / float(step) ) x= [start,] for i in xrange(0,n): x.append(x[-1]+step) return x ##faster seq creation def seqa2(start,end,step=1): n= floor( (end-start) / float(step) ) x= [ start+i*step for i in xrange(0,n) ] return x ##fastest seq creation as array, also allow array --> different type def seqa3(start,end,step=1.0,type=array): x=arange(start,end,step) if type==array: pass elif type==list or type==None or type=='' : x=list(x) elif type==tuple: x=tuple(x) elif type==dict: x= dict(zip(range(1,len(x)),tuple(x))) elif type==set: x= set(x) return x if (1): start=1 end=2 step= 0.10 t0=time.time() x1=seqa1(start,end,step) print 'SEQA1 Time= ', time.time()-t0 t0=time.time() x2=seqa2(start,end+step,step) print 'SEQA2 Time= ', time.time()-t0 print 'Check for X1,X2 equivalence-- ', (x1==x2) t0=time.time() x3=seqa3(start,end+step,step,list) print 'SEQA3 Time= ', time.time()-t0 print 'Check for X2,X3 equivalence-- ', (x2==x3) From m.bless at gmx.de Sun Apr 20 09:49:07 2008 From: m.bless at gmx.de (Martin Bless) Date: Sun, 20 Apr 2008 15:49:07 +0200 Subject: codec for html/xml entities!? References: <48084C97.4040400@behnel.de> Message-ID: <2ohm04hm4sk0rn019tk1ntrii74hu8ajdo@4ax.com> [Stefan Behnel] wrote & schrieb: >Martin Bless wrote: >> What's a good way to encode and decode those entities like € or >> € ? > >Hmm, since you provide code, I'm not quite sure what your actual question is. - What's a GOOD way? - Am I reinventing the wheel? - Are there well tested, fast, state of the art, builtin ways? - Is something like line.decode('htmlentities') out there? - Am I in conformity with relevant RFCs? (I'm hoping so ...) >So I'll just comment on the code here. > > >> def entity2uc(entity): >> """Convert entity like { to unichr. >> >> Return (result,True) on success or (input string, False) >> otherwise. Example: >> entity2cp('€') -> (u'\u20ac',True) >> entity2cp('€') -> (u'\u20ac',True) >> entity2cp('€') -> (u'\u20ac',True) >> entity2cp('&foobar;') -> ('&foobar;',False) >> """ > >Is there a reason why you return a tuple instead of just returning the >converted result and raising an exception if the conversion fails? Mainly a matter of style. When I'll be using the function in future this way it's unambigously clear that there might have been unconverted entities. But I don't have to deal with the details of how this has been discovered. And may be I'd like to change the algorithm in future? This way it's nicely encapsulated. Have a nice day Martin From manisharoy20 at gmail.com Tue Apr 15 04:59:43 2008 From: manisharoy20 at gmail.com (......ADMISSION IN TOP 10 IIT's and ENGINNERING COLLEGE.......) Date: Tue, 15 Apr 2008 01:59:43 -0700 (PDT) Subject: Req. Designation - Jr. Software Engineer(QA) Message-ID: <6e48117f-4f82-49fc-a82e-5798231c99c2@d26g2000prg.googlegroups.com> Req. Designation - Jr. Software Engineer(QA) Company - Allindia Technologies Limited. Criteria - Any Degree SALARY - 2.5 to 3.5 lakhs PA. How to apply -: 1] Click the below link and first complete your profile with your school and college. http://www.batchmates.com/MGMhome.asp?refid=1970195&reflink=22635 2] After completing your all details,check your email and confirm your registration. 3] Finally,go to careers and apply for the above mentioned post(After completing your profile,you must check your email and confirm your registration before applying for the given job). Visit and join http://www.batchmates.com/MGMhome.asp?refid=1970195&reflink=22635 Pls Note:- After registering with your school/college,please check your email immediately. Check the confirmation key or confirmation link. Then only apply for the job,otherwise your application will be rejected. From nick at craig-wood.com Tue Apr 22 08:30:02 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Tue, 22 Apr 2008 07:30:02 -0500 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? References: Message-ID: Harishankar wrote: > Sorry to start off on a negative note in the list, but I feel that the Python > subprocess module is sorely deficient because it lacks a mechanism to: > > 1. Create non-blocking pipes which can be read in a separate thread (I am > currently writing a mencoder GUI in Tkinter and need a full fledged process > handler to control the command line and to display the progress in a > text-box) > > 2. Kill the subprocess in a platform independent manner (i.e. no third party > modules and no hacks). You are correct on both of those points. Subprocess isn't for interacting with subprocesses - this should be written in large letters in the help! > Is there any way to use non-blocking Popen objects using > subprocess? There is a recipe in the cookbook http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554 Which I've used and it works. you can also (if on unix) use http://www.noah.org/wiki/Pexpect I think the best solution would be to port Pexpect to windows which wouldn't be that difficult according to my reading of the code. If only I had more free time! > and 2 - is there a way to kill the subprocess in a platform > independent manner in a purely Pythonic way? I thought initially > that this problem is simple enough, but over the last couple of > days I've been really struggling to find any answer. I've been > through dozens of mailing list archives in to find a > solution. Unfortunately none of the solutions seem to fit my needs. No... This is the best I came up with to add to the subprocess recipe above import os from subprocess import * from subprocess import mswindows from time import sleep if mswindows: import win32api else: import signal class PopenNB(Popen): # - see cookbook recipe for rest of stuff # ... def kill(self, killpg=False): """ Kill the running process """ pid = self.pid if mswindows: # Kill the process using win32api and pid - ignore errors try: PROCESS_TERMINATE = 1 handle = win32api.OpenProcess(PROCESS_TERMINATE, False, pid) win32api.TerminateProcess(handle, -1) win32api.CloseHandle(handle) except pywintypes.error: pass else: # Kill the process by sending the pid / process group a signal if killpg: try: pgid = os.getpgid(pid) except OSError: killpg = False try: if killpg: os.killpg(pgid, signal.SIGTERM) else: os.kill(pid, signal.SIGTERM) except OSError: return sleep(1.0) try: if killpg: os.killpg(pgid, signal.SIGKILL) else: os.kill(pid, signal.SIGKILL) except OSError: return -- Nick Craig-Wood -- http://www.craig-wood.com/nick From donnyf at gmail.com Tue Apr 29 08:52:41 2008 From: donnyf at gmail.com (donnyf at gmail.com) Date: Tue, 29 Apr 2008 05:52:41 -0700 (PDT) Subject: Using Python to verify streaming tv/radio station links Message-ID: Hi guys. I've put together a website ( http://worldwidemediaproject.com ) that is a database of internet streaming tv/radio stations from around the world. I have built the site with all users in mind. The site should be Linux, Unix, Mac, Win, etc friendly as I do not hide the actual stream link or force the user to use an embedded player to view/listen to the streams. In fact, you can even download the streams you like as a playlist that you can load into your player of choice (and even a few PVR software plugins). In building the site, I have enabled the user to report stations that are nonfunctional. In addition to this, I would like to automate the checking of the links in the database as well as any user submitted links. What I am wanting to do is to script this with a simple for loop which would loop through a file containing the station stream link as well as the station id. I'd like to pass each through some kind of verification function and if a connection is made then the stream is good and move on to the next. If the connection fails then the stream is bad, I would like to add the station id to a file containing all 'nonfunctional' streams that I can later automate to flag the stations. Is there an easy way to use python to verify a stream exists? I've done a little experimenting with sockets and was able to connect to my usenet server and talk to it, but I don't really know what's involved with connecting to streaming windows media, real media and winamp servers or what to expect as far as connection status messages. I am not unfamiliar with python, but I am far from an expert. If anyone could give me a hand with this or give me a push in the right direction I would greatly appreciate it! Many thanks! From george.sakkis at gmail.com Mon Apr 28 16:16:08 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Mon, 28 Apr 2008 13:16:08 -0700 (PDT) Subject: How to unget a line when reading from a file/stream iterator/generator? References: Message-ID: On Apr 28, 2:07?pm, pyt... at bdurham.com wrote: > Is there an elegant way to unget a line when reading from a file/stream > iterator/generator? > > By "unget" I mean a way to push back a line into the source stream and > backtrack the iterator/generator one step? > > The only alternative I can see is to put my line reading in a while-True > loop (vs. a for-loop) that manually calls my file/stream > iterator/generator's .next() method while manually handling the > StopIteration exception. Doesn't sound too elegant. > > Is there a Pythonic design pattern/best practice that I can apply here? > > Thank you, > Malcolm http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502304 HTH, George From wizzardx at gmail.com Tue Apr 15 17:16:01 2008 From: wizzardx at gmail.com (David) Date: Tue, 15 Apr 2008 23:16:01 +0200 Subject: Getting subprocess.call() output into a string? In-Reply-To: References: Message-ID: <18c1e6480804151416j7dd49d78p8888132ca01a5237@mail.gmail.com> > > Still, about StringIO... > The module description says you can use it to read and write strings as files, not that you can use strings *everywhere* you can use files. In your specific case, StringIO doesn't work, because the stdout redirection takes place at the operating system level (which uses real file handles), rather than in a python library (for which StringIO would probably work). David. From pylists at arcor.de Sat Apr 12 12:31:32 2008 From: pylists at arcor.de (Penny Y.) Date: Sun, 13 Apr 2008 00:31:32 +0800 Subject: mod_python Message-ID: <4800E3E4.3080508@arcor.de> Hello, I want to rewrite a request url under apache2.0 based on its special header, like, the "Accept-Encoding:" one. With C I think I can do it, but since I get begin with python,so I ask that can I do it under mod_python? what's the guide? Thanks. From hv at tbz-pariv.de Fri Apr 4 08:13:46 2008 From: hv at tbz-pariv.de (Thomas Guettler) Date: Fri, 04 Apr 2008 14:13:46 +0200 Subject: wsdl (soap) without code generation In-Reply-To: <65hi7dF2ade57U1@mid.individual.net> References: <65hi7dF2ade57U1@mid.individual.net> Message-ID: <65mkbqF2gtptsU1@mid.individual.net> ... Thank you for your answers. I tried to parse the wsdl with two libraries. (axis2 (java) and SOAPPy). Both fail because there is no entry for 'service'. The wsdl is from SAP XI. Has someone hints? Thomas -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de From steve at holdenweb.com Fri Apr 11 09:55:18 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 11 Apr 2008 09:55:18 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> <47FCF421.6000807@holdenweb.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> Message-ID: Victor Subervi wrote: > Nope. Do not see it. My ugly stupid way works. I guess I will just > proceed with that and write my howto accordingly. > Victor > OK, but be prepared for some pretty scathing feedback. You will make it clear you do not understand the web. I'd suggest a little more reading first. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From fr5478bey at gmail.com Sat Apr 26 11:38:31 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:38:31 -0700 (PDT) Subject: Treasures Of Montezuma crack Message-ID: Treasures Of Montezuma crack http://cracks.00bp.com F R E E C R A C K S From kamhung.soh at gmail.com Wed Apr 30 03:01:37 2008 From: kamhung.soh at gmail.com (Kam-Hung Soh) Date: Wed, 30 Apr 2008 17:01:37 +1000 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> Message-ID: On Wed, 30 Apr 2008 16:13:17 +1000, SL wrote: > How can I compute with the integer values of characters in python? > Like 'a' + 1 equals 'b' etc Try: ord('a') See also: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65117 -- Kam-Hung Soh Software Salariman From gagsl-py2 at yahoo.com.ar Wed Apr 16 18:49:27 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 19:49:27 -0300 Subject: def power, problem when raising power to decimals References: <48067bdb@news.mel.dft.com.au> Message-ID: En Wed, 16 Apr 2008 19:21:18 -0300, John Machin escribi?: > skanemupp at yahoo.se wrote: >> also i found a link which states 0^0 isnt 1 even though every >> calculator ive tried says it is. >> it doesnt say what it is but i presume 0 then. >> but it seems the dude is wrong and it is 1? > > Of the possible results of 0 ** 0 (i.e. 1, 0, and NaN), 1 seems to be > the least implausible. It allows X ** 0 to be 1 for all X. But a result of 0 would allow 0 ** X to be 0 for all X. (btw, this is the reason lim(x**x) for x->0 does not exist) -- Gabriel Genellina From paulgeeleher at gmail.com Mon Apr 21 13:08:10 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Mon, 21 Apr 2008 10:08:10 -0700 (PDT) Subject: Problem setting cookie in Internet Explorer References: <10655938-e458-4866-a56b-9a989054f055@w4g2000prd.googlegroups.com> Message-ID: <54bddf5e-cea7-4177-b9da-bf068ce6041e@l28g2000prd.googlegroups.com> On Apr 21, 4:24 pm, Mike Driscoll wrote: > On Apr 21, 10:13 am, sophie_newbie wrote: > > > > > Hi, > > > I'm using the python to set a cookie when a user logs in. Thing is it > > doesn't seem to be setting properly in Internet Explorer. It works > > grand in Firefox. Its basically: > > > c = Cookie.SimpleCookie() > > > c['username'] = uname > > > c['password'] = pword > > > print c > > > print pageContent > > > And thats it. I've a suspicion that it could be something to do with > > the expiry time of the cookie. But I'm really not sure and don't > > really know where to go with it. I've tried it on Internet Explorer on > > 2 machines and get the same problem. > > > Thanks for any help... > > Did you make sure cookies are enabled in Internet Explorer? > > You might also take a look at these pages: > > http://www.voidspace.org.uk/python/articles/cookielib.shtmlhttp://www.voidspace.org.uk/python/recipebook.shtml#cookielib > > They seem quite informative. > > Mike Ya cookies are def enabled, will check that out thanks! From kyosohma at gmail.com Mon Apr 21 11:24:29 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Mon, 21 Apr 2008 08:24:29 -0700 (PDT) Subject: Problem setting cookie in Internet Explorer References: Message-ID: <10655938-e458-4866-a56b-9a989054f055@w4g2000prd.googlegroups.com> On Apr 21, 10:13 am, sophie_newbie wrote: > Hi, > > I'm using the python to set a cookie when a user logs in. Thing is it > doesn't seem to be setting properly in Internet Explorer. It works > grand in Firefox. Its basically: > > c = Cookie.SimpleCookie() > > c['username'] = uname > > c['password'] = pword > > print c > > print pageContent > > And thats it. I've a suspicion that it could be something to do with > the expiry time of the cookie. But I'm really not sure and don't > really know where to go with it. I've tried it on Internet Explorer on > 2 machines and get the same problem. > > Thanks for any help... Did you make sure cookies are enabled in Internet Explorer? You might also take a look at these pages: http://www.voidspace.org.uk/python/articles/cookielib.shtml http://www.voidspace.org.uk/python/recipebook.shtml#cookielib They seem quite informative. Mike From victorsubervi at gmail.com Fri Apr 18 11:13:32 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Fri, 18 Apr 2008 10:13:32 -0500 Subject: Another MySQL Images Question Message-ID: <4dc0cfea0804180813o32ed2c82o9c3f68b1a607348d@mail.gmail.com> Hi; If I grab an image in the database thus: sql = "select pic1 from products where id='" + str(id) + "';" cursor.execute(sql) pic1 = cursor.fetchall()[0][0].tostring() # pic1 = cursor.fetchall()[0][0] // either this or the above line and try and re-insert it thus: cursor.execute('update products set pic1="%s" where id="%s", ;', (pic1, id)) it tells me I have an error in my MySQL syntax. What is the error? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan_ml at behnel.de Mon Apr 7 02:12:43 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 07 Apr 2008 08:12:43 +0200 Subject: How to get an XML DOM while offline? In-Reply-To: References: Message-ID: <47F9BB5B.30604@behnel.de> william tanksley wrote: > I want to parse my iTunes Library xml. All was well, until I unplugged > and left for the train (where I get most of my personal projects > done). All of a sudden, I discovered that apparently the presence of a > DOCTYPE in the iTunes XML makes xml.dom.minidom insist on accessing > the Internet... So suddenly I was unable to do any work. > > I don't want to modify the iTunes XML; iTunes rewrites it too often. > How can I prevent xml.dom.minidom from dying when it can't access the > Internet? > > Is there a simpler way to read the iTunes XML? (It's merely a plist, > so the format is much simpler than general XML.) Try lxml. Since version 2.0, its parsers will not access the network unless you tell it to do so. http://codespeak.net/lxml It's also much easier to use than minidom and much faster: http://blog.ianbicking.org/2008/03/30/python-html-parser-performance/ Stefan From steve at holdenweb.com Mon Apr 14 19:38:42 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 14 Apr 2008 19:38:42 -0400 Subject: py2exe, program has stoped working!? In-Reply-To: <67526f9f-a610-4cbe-8e2c-6219a59a4d54@i36g2000prf.googlegroups.com> References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> <232151d6-09ed-4a1e-9922-d66c2bf0d05b@w8g2000prd.googlegroups.com> <67526f9f-a610-4cbe-8e2c-6219a59a4d54@i36g2000prf.googlegroups.com> Message-ID: John Machin wrote: > On Apr 15, 4:08 am, Steve Holden wrote: >> John Machin wrote: >> >>> By the way, "popup" is what you get in a web browser. What did this >>> "popup" look like: a panel from your GUI software? A Windows message >>> box? Did it have a title across the top? What was the exact text in >>> the popup/panel/box? Were there any options other than to close the >>> window? >> >> FYI "xxx has stopped working" is Vista's "user-friendly" way of >> reporting what Windows 3 would probably have called a "General Program >> Fault". > > So I found by googling "has stopped working". I'd never seen such a > litany of weeping, wailing and u'\u02ad' before. > >> It pretty much hides all useful information fro the end-user, >> perhaps on the grounds that end users wouldn't know what to do with the >> information it *could* provide anyway. > > Thanks for the info, Steve. Sounds like it's even worse than its > predecessor in Windows XP. You could say "it sucks" and not be a million miles away. Particularly since Windows Explorer is itself one of the programs that quite frequently "stops working". regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From mail at microcorp.co.za Wed Apr 2 04:41:39 2008 From: mail at microcorp.co.za (Hendrik van Rooyen) Date: Wed, 2 Apr 2008 10:41:39 +0200 Subject: Why prefer != over <> for Python 3.0? Message-ID: <001e01c8949d$7bd6a520$03000080@hendrik> John J. Lee wrote: >How did programmers manage back then in 32k? Some of the answers, in no particular sequence, are: Tight, small operating systems that did the minimum. Assembler. Sequential Processing: - small tasks with multiple passes on tape ( like the concept of Unix pipes ) Overlays. Character based menu systems. No OO. Code structured to the point of incomprehensibility: - if ten or so instructions looked similar, you forced calls instead of inlining. Procedural languages, close to the metal. Small, fixed length, fixed type character based data structures. Some of the other veterans may want to add to this list. - Hendrik From ramesh at winfoware.com Mon Apr 21 06:43:35 2008 From: ramesh at winfoware.com (Ramesh Nathan) Date: Mon, 21 Apr 2008 16:13:35 +0530 Subject: Required Python Consultants Message-ID: <073a01c8a39c$8dc1e7a0$a945b6e0$@com> Hi, I am looking for Python consultants to work with us for couple of months. The location is Bangalore, India. Anybody interested, please contact me. With warm regards, Ramesh Nathan, Head - Business Relations, Winfoware Technologies Ltd, Mobile - 0 93425 54560. Email ? HYPERLINK "mailto:ramesh at winfoware.com"ramesh at winfoware.com Land Line - +91 080 23224418 / 23224420 HYPERLINK "http://www.winfoware.com"www.winfoware.com No virus found in this outgoing message. Checked by AVG. Version: 7.5.524 / Virus Database: 269.23.2/1388 - Release Date: 20-04-2008 15:01 -------------- next part -------------- An HTML attachment was scrubbed... URL: From bignose+hates-spam at benfinney.id.au Mon Apr 7 10:36:37 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Tue, 08 Apr 2008 00:36:37 +1000 Subject: Adherence to PEP 8 for published code References: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> <87d4p2mcrp.fsf_-_@benfinney.id.au> Message-ID: <871w5h20lm.fsf@benfinney.id.au> Aldo Cortesi writes: > This is getting silly. Agreed. > Let's recap. You are upset Not at all. -- \ "We spend the first twelve months of our children's lives | `\ teaching them to walk and talk and the next twelve years | _o__) telling them to sit down and shut up." -- Phyllis Diller | Ben Finney From wesbrooks at gmail.com Tue Apr 22 08:03:02 2008 From: wesbrooks at gmail.com (Wesley Brooks) Date: Tue, 22 Apr 2008 13:03:02 +0100 Subject: Python Success stories In-Reply-To: <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> Message-ID: http://panela.blog-city.com/python_at_google_greg_stein__sdforum.htm Google big enough? ...or look at the companies on the "NASA uses Python... ...so does:" box on the top (nearly top any how!) right of http://www.python.org/ On 22/04/2008, azrael wrote: > Which big aplications are written in python. I see its development, > But i can't come up with a big name. I know that there are a lot of > companys using python, but is there anythong big written only in > python. I want him to fuck of with his perl once and for all time > > -- > http://mail.python.org/mailman/listinfo/python-list > From DrColombes at yahoo.com Thu Apr 3 18:40:02 2008 From: DrColombes at yahoo.com (Dr. Colombes) Date: Thu, 3 Apr 2008 15:40:02 -0700 (PDT) Subject: Easy-to-install-and-use scientific graphics (plotting) package for Python 2.5.1 on Linux Ubuntu 7.1 Message-ID: <771b5531-5681-499f-9fda-77749b5db09f@s37g2000prg.googlegroups.com> Is there an easy scientific graphics (plotting) package for Python 2.5.1 running on Ubuntu Linux 7.1 ("Gutsy Gibbon")? A few years ago I used PyLab (a MatLab-like plotting module for Python) on a Windows machine, but I don't know if there is a similar easy-to-install-and-use Python 2.5.1-compatible graphics package for Ubuntu Linux 7.1? Thanks for any suggestions. From kosh at aesaeion.com Tue Apr 29 11:37:28 2008 From: kosh at aesaeion.com (William Heymann) Date: Tue, 29 Apr 2008 09:37:28 -0600 Subject: Zope/DTML Infuriating... In-Reply-To: References: Message-ID: <200804290937.28491.kosh@aesaeion.com> On Tuesday 29 April 2008, Jens wrote: > Hello Everyone. > > >

    > >
  • >
    >
> > I think you are going to really regret doing things this way, it is only going to make your life much harder regardless of if you are using zpt or dtml by doing stuff like this inside the template. The most correct way in zope to do this is to use a python script object and have the dtml call that. For example your python script would have return ['main%s' % i for i in range(1,10)] and your dtml would have
This leads to much cleaner and easier to maintain systems. From http Tue Apr 15 12:55:41 2008 From: http (Paul Rubin) Date: 15 Apr 2008 09:55:41 -0700 Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <0853b778-c20b-44bb-ac9b-a5803a1aecc5@e67g2000hsa.googlegroups.com> <53ede0ca-ad36-4b11-b693-ea500d7b6e43@e67g2000hsa.googlegroups.com> <207ca229-3309-41e4-9369-ccde5de908a1@l64g2000hse.googlegroups.com> Message-ID: <7xtzi312ia.fsf@ruckus.brouhaha.com> Aaron Watters writes: > Even with Btree's if you jump around in the tree the performance can > be awful. The Linux file cache really helps. The simplest approach is to just "cat" the index files to /dev/null a few times an hour. Slightly faster (what I do with Solr) is mmap the files into memory and read a byte from each page now and then. Assuming (as in Lucene) that the index file format is compressed, this approach is far more ram-efficient than actually unpacking the index into data structures. though of course you take the overhead (a few microseconds) of a couple system calls at each access to the index even when it's all in cache. From sturlamolden at yahoo.no Wed Apr 23 21:08:46 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Wed, 23 Apr 2008 18:08:46 -0700 (PDT) Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. References: Message-ID: <6f45892f-c518-4924-bb92-8ce79368c1ab@t63g2000hsf.googlegroups.com> On Apr 22, 8:36 pm, Kenneth McDonald wrote: > Sadly. I can easily access: http://www.crummy.com/software/BeautifulSoup/ From usenet at solar-empire.de Thu Apr 3 07:17:57 2008 From: usenet at solar-empire.de (Marc Christiansen) Date: Thu, 3 Apr 2008 13:17:57 +0200 Subject: Get all strings matching given RegExp References: Message-ID: <50rec5-4d6.ln1@pluto.solar-empire.de> Alex9968 wrote: > Can I get sequence of all strings that can match a given regular > expression? For example, for expression '(a|b)|(x|y)' it would be ['ax', > 'ay', 'bx', 'by'] > > It would be useful for example to pass these strings to a search engine > not supporting RegExp (therefore adding such support to it). A program > can also let user specify sequence of strings using RegExp (filenames to > process, etc.). If there are other types of expressions for these > purposes, please let me know. > > I know that for some expressions there would be infinite amount of > matching strings, but these aren't the cases I'm considering. It'd still > be possible if string length is limited (there might be large but finite > number of matching strings). This will give you all (byte-)strings upto a given length which match a given regular expression. But beware, it can be slow ;) import re all_chars = [chr(i) for i in xrange(256)] def gen_strings(length, alphabet=all_chars): if length == 1: for c in alphabet: yield c else: for i in alphabet: yield c for s in gen_strings(length - 1, alphabet): yield c + s def regex_matches(regex, max_length, alphabet=all_chars): r = re.compile('(' + regex + r')\Z') return (s for s in gen_strings(max_length, alphabet) if r.match(s)) Marc From rhamph at gmail.com Sat Apr 12 11:56:58 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Sat, 12 Apr 2008 08:56:58 -0700 (PDT) Subject: Multiple independent Python interpreters in a C/C++ program? References: Message-ID: <9f97ea5b-f6c1-4d75-8f20-956c48b855af@i36g2000prf.googlegroups.com> On Apr 11, 10:24 am, s... at pobox.com wrote: > This question was posed to me today. Given a C/C++ program we can clearly > embed a Python interpreter in it. Is it possible to fire up multiple > interpreters in multiple threads? For example: > > C++ main > thread 1 > Py_Initialize() > thread 2 > Py_Initialize() > > Do I wind up with two completely independent interpreters, one per thread? > I'm thinking this doesn't work (there are bits which aren't thread-safe and > are only protected by the GIL), but wanted to double-check to be sure. Since they interpreters would never truly be separate, I think it's best to bite the bullet and use multiple threads within one interpreter. The only really difference is pure python modules aren't duplicated, but why would you need that? Surely not for any kind of security. From pavlovevidence at gmail.com Tue Apr 22 12:26:47 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 22 Apr 2008 09:26:47 -0700 (PDT) Subject: Remove multiple inheritance in Python 3000 References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <6760jfF2n3bn1U1@mid.uni-berlin.de> <676desF2nrgitU1@mid.uni-berlin.de> Message-ID: <6728a814-32df-41cd-8f6e-c86750d9f91f@p25g2000hsf.googlegroups.com> On Apr 22, 11:10 am, "Diez B. Roggisch" wrote: > > 2. Java interfaces solve a different problem than MI (used properly) > > does: interfaces are there to make types polymorphic, whereas > > inheritance's main use is to share behavior. > > But the *goal* of the polymorphy is mainly to have shared behavior. Not at all. The goal of polymorphism is to have objects of different types usable in the same situation. Two such classes might share some behavior, but they don't have to. Carl Banks From tjreedy at udel.edu Mon Apr 7 13:59:08 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 7 Apr 2008 13:59:08 -0400 Subject: Welcome to the "Python-list" mailing list References: Message-ID: "Ronn Ross" wrote in message news:d1c466d40804070747x34588c19id6f9050bf3cf5411 at mail.gmail.com... | This is my first post and I'm new to Python. How would someone go about | adding keywords to Python? It would be great to add support for Esperanto | keywords in the language instead of English being the only option. If you want other-language keywords, you should either use a translator processor or an editor that will do keyword substitution. I do not know of such but I would not be surprised if there is one. I suspect this sort of thing will more likely happen with Python 3, which will allow unicode keywords. PS. Subject lines should reflect the subject of the post. From darcy at druid.net Fri Apr 25 14:50:57 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Fri, 25 Apr 2008 14:50:57 -0400 Subject: Why is None <= 0 In-Reply-To: References: Message-ID: <20080425145057.12b9a1e7.darcy@druid.net> On Fri, 25 Apr 2008 20:27:15 +0200 Gregor Horvath wrote: > >>> None <= 0 > True > > Why? Why not? > Is there a logical reason? Everything in Python can compare to everything else. It is up to the programmer to make sure that they are comparing reasonable things. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From colas.francis at gmail.com Mon Apr 14 11:48:26 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Mon, 14 Apr 2008 08:48:26 -0700 (PDT) Subject: eval modifies passed dict References: <2b2398b1-042e-46bb-b840-ea9e07d87bd1@2g2000hsn.googlegroups.com> Message-ID: <511feb86-3915-46da-9bd8-d02de87eb2de@b1g2000hsg.googlegroups.com> On 14 avr, 17:23, Janto Dreijer wrote: > It seems eval is modifying the passed in locals/globals. This is > behaviour I did not expect and is really messing up my web.py app. > > Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information.>>> d = dict(a=1) > >>> d.keys() > ['a'] > >>> eval("a", d) > 1 > >>> d.keys() > > ['a', '__builtins__'] > > That can't be right. >From the documentation of eval[1] "If the globals dictionary is present and lacks '__builtins__', the current globals are copied into globals before expression is parsed." [1]http://docs.python.org/lib/built-in-funcs.html From robert.kern at gmail.com Fri Apr 11 13:55:28 2008 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 11 Apr 2008 12:55:28 -0500 Subject: Rounding a number to nearest even In-Reply-To: <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> Message-ID: cokofreedom at gmail.com wrote: > Strange request though, why do you need it that way, because 2.5 is > CLOSER to 3 than to 2... Uhhh, no it isn't. (3 - 2.5) == (2.5 - 2) -- 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 From jyoung79 at kc.rr.com Wed Apr 16 10:00:20 2008 From: jyoung79 at kc.rr.com (jyoung79 at kc.rr.com) Date: Wed, 16 Apr 2008 9:00:20 -0500 Subject: Get oldest folder Message-ID: <30689728.337521208354420713.JavaMail.root@hrndva-web15-z02> Hi Tim, Thanks very much for your help! I'm still just learning Python and really appreciate seeing other peoples examples on how they work with Python. Thanks again for taking the time to share this. Jay >> I'd like to be able to get the path to the oldest folder in whatever directory >> I'm currently in. Is there a simple way to go about this? >> I'd like it to run on both OS X and Windows XP. >> I found this example but was curious if there's a better way to do this? >Better: I don't know. Alternative, certainly: > >import os, glob >PATH = "c:/python25/lib/site-packages" >print min ((f for f in glob.glob (os.path.join (PATH, "*")) if os.path.isdir (f)), key=os.path.getctime) > >TJG From bronger at physik.rwth-aachen.de Tue Apr 1 03:36:32 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Tue, 01 Apr 2008 09:36:32 +0200 Subject: Why prefer != over <> for Python 3.0? References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> <659gb2F2f84eoU2@mid.individual.net> <87hceo73ap.fsf@physik.rwth-aachen.de> <65anbqF2fg18bU1@mid.individual.net> <87r6drjss4.fsf@physik.rwth-aachen.de> <65c0bfF2ffipiU1@mid.individual.net> Message-ID: <878wzyyqkf.fsf@physik.rwth-aachen.de> Hall?chen! Jorge Vargas writes: > On Tue, Apr 1, 2008 at 6:03 AM, Gabriel Genellina > wrote: > >> [...] >> >> I think it should be easy to add support for ??? and even ?, >> only the tokenizer has to be changed. >> > show me a keyboard that has those symbols and I'm all up for it. For <= I have to press three buttons, for ? I have to press four buttons. Not much of a difference. ;-) However, I'm slightly disappointed with the UTF-8 support in some mail clients involved in this thread, so Unicode surely has not arrived yet. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From gagsl-py2 at yahoo.com.ar Wed Apr 9 02:26:29 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 03:26:29 -0300 Subject: Cannot understand the detailedly the following code References: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> Message-ID: En Tue, 08 Apr 2008 09:45:35 -0300, A.T.Hofkamp escribi?: > On 2008-04-08, reachmsn at hotmail.com wrote: > > [deleted a long piece of text by our BDFL about recursive graph > path-finding algorithm] > >> after first writing the inductive part ... for node in >> graph[start] .... >> and then by trial and error put square brackets around path in the >> Basis part. Can someone please explain how to write this code. Thanks! > > The same as any other function. > (the trick with recursive functions is not to think about recursion. > Instead, > pretend you are calling another function that happens to have the same > name.) But our BDFL played some tricks to make both functions look more similar than they would instead. Take the "single path" variant: def find_path(graph, start, end, path=[]): path = path + [start] if start == end: return path if not graph.has_key(start): return None for node in graph[start]: if node not in path: newpath = find_path(graph, node, end, path) if newpath: return newpath return None Why are those "return None" there, if not to be replaced by "return []"? Nobody writes that final one at least. Anyway, using the current Python version, it's easier to mutate the above function into a generator of all posible solutions; I hope the OP finds the mutation easier to follow: def find_all_paths(graph, start, end, path=[]): path = path + [start] if start == end: yield path return if start not in graph: return for node in graph[start]: if node not in path: for newpath in find_all_paths(graph, node, end, path): yield newpath The last two lines might be replaced in Python 3 by: yield *find_all_paths if this patch is accepted: http://bugs.python.org/issue2292 -- Gabriel Genellina From sturlamolden at yahoo.no Fri Apr 18 21:29:42 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 18 Apr 2008 18:29:42 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <48074f58$0$4916$e4fe514c@dreader32.news.xs4all.nl> <6002cb46-f48a-421d-a4ff-5b23bf2f9d77@2g2000hsn.googlegroups.com> Message-ID: <39fd7905-4835-43bb-928b-82622ed628c1@m3g2000hsc.googlegroups.com> On 18 Apr, 21:28, "sjdevn... at yahoo.com" wrote: > Passing a NULL SectionHandle to NTCreateProcess/CreateProcessEx > results in a fork-style copy-on-write duplicate of the current process. I know about NtCreateProcess and ZwCreateProcess, but they just create an empty process - no context, no thread(s), no DLLs loaded, etc. There is even an example code of how to implement fork() with ZwCreateProcess in Nebbet's book on NT kernel internals, but apparently it doesn't work quite well. (Right now I cannot even make it compile, because WDK headers are fubar with invalid C; even Microsoft's own compiler does not accept them.) Searching with Google, I find several claims that there is a "CreateProcessEx", which can do a COW fork of a process in the Win32 subsystem. I cannot find it documented anywhere. It is also not exported by kernel32.dll. If you know how this function is defined and which DLL exports it, please post it. But I suspect it does not exist. From samslists at gmail.com Thu Apr 3 18:20:59 2008 From: samslists at gmail.com (samslists at gmail.com) Date: Thu, 3 Apr 2008 15:20:59 -0700 (PDT) Subject: Bug in shlex?? Message-ID: I'm trying to use shlex.split to simulate what would happen in the shell. The docs say that it should be as close as possible to the posix shell parsing rules. If you type the following into a posix compliant shell echo '\?foo' you get back: \?foo (I've tested this in dash, bash and zsh---all give the same results.) Now here's what happens in python: Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import shlex >>> shlex.split("'\?foo'") ['\\?foo'] >>> I think this is a bug? Or am I just misunderstanding? Here is the relevant section of the Posix specification on shell parsing: 2.2.2 Single-Quotes Enclosing characters in single-quotes ( '' ) shall preserve the literal value of each character within the single-quotes. A single- quote cannot occur within single-quotes. That's from http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_03 Thanks for any help! From steve at holdenweb.com Tue Apr 8 17:40:31 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 17:40:31 -0400 Subject: Best way to check if string is an integer? In-Reply-To: <5fa6c12e0804081332r2a58d39gc44ce1ef8cb69052@mail.gmail.com> References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> <0fdd2825-6d1c-4380-a79a-a7aac119f002@a5g2000prg.googlegroups.com> <96d2fe53-96bf-43d8-a58d-8269846bf0df@b64g2000hsa.googlegroups.com> <2033313.fb3g3XYCIP@montana.com> <5fa6c12e0804081332r2a58d39gc44ce1ef8cb69052@mail.gmail.com> Message-ID: Martin Marcher wrote: > hmmm > > int() does miss some stuff: > >>>> 1E+1 > 10.0 >>>> int("1E+1") > Traceback (most recent call last): > File "", line 1, in > ValueError: invalid literal for int() with base 10: '1E+1' > > I wonder how you parse this? > > I honestly thought until right now int() would understand that and > wanted to show that case as ease of use, I was wrong, so how do you > actually cast this type of input to an integer? > > thanks > martin > > int(float("1E+1")) # untested regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gagsl-py2 at yahoo.com.ar Mon Apr 7 22:47:42 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 07 Apr 2008 23:47:42 -0300 Subject: Translating keywords References: Message-ID: En Mon, 07 Apr 2008 14:59:08 -0300, Terry Reedy escribi?: > "Ronn Ross" wrote in message > news:d1c466d40804070747x34588c19id6f9050bf3cf5411 at mail.gmail.com... > | This is my first post and I'm new to Python. How would someone go about > | adding keywords to Python? It would be great to add support for > Esperanto > | keywords in the language instead of English being the only option. > > If you want other-language keywords, you should either use a translator > processor or an editor that will do keyword substitution. I do not know > of > such but I would not be surprised if there is one. I suspect this sort > of > thing will more likely happen with Python 3, which will allow unicode > keywords. Python 3 allows for unicode identifiers, but I don'k know any plans for using unicode keywords too. Looks funny: ? x ? values: if x ? forbidden ? x ? y: print(x, ?(x), ?(x)) print(?(values)) near = ? a,b,?=0.01: a-? ? b ? a+? for x in values: if x not in forbidden and x!=y: print(x, gamma(x), math.sqrt(x)) print(sum(values)) near = lambda a,b,eps=0.01: a-eps <= b <= a+eps -- Gabriel Genellina From hall.jeff at gmail.com Tue Apr 15 14:02:13 2008 From: hall.jeff at gmail.com (hall.jeff at gmail.com) Date: Tue, 15 Apr 2008 11:02:13 -0700 (PDT) Subject: Preferred method for "Assignment by value" References: <6a3ed8f0-b82c-4cd3-b36e-1d94f8a30fe3@n1g2000prb.googlegroups.com> Message-ID: <7047986d-f6cc-4189-81f6-47da1ecf1902@k1g2000prb.googlegroups.com> Thank you both, the assigning using slicing works perfectly (as I'm sure you knew it would)... It just didn't occur to me because it seemed a little nonintuitive... The specific application was def dicttolist (inputdict): finallist=[] for k, v in inputdict.iteritems(): temp = v temp.insert(0,k) finallist.append(temp) return finallist to convert a dictionary to a list. We deal with large amounts of bankdata which the dictionary is perfect for since loan number is a perfect key... at the end, though, I have to throw it into a csv file and the csv writer doesn't like dictionaries (since the key is an iterable string it iterates over each value in the key) by changing temp = v[:] the code worked perfectly (although changing temp.insert(0,k) to temp = [k] + temp also worked fine... I didn't like that as I knew it was a workaround) Thanks again for the help From steve at holdenweb.com Sat Apr 5 22:24:33 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 22:24:33 -0400 Subject: Tkinter, add pressed buttons onto string display string, how to? In-Reply-To: <195771d1-1bb3-4d62-b9c3-920db5a912ac@y21g2000hsf.googlegroups.com> References: <57605958-5589-4ebe-abdf-73c2d14c8a82@u10g2000prn.googlegroups.com> <65q8juF2gq610U2@mid.uni-berlin.de> <649d9748-c389-411d-9794-9753ddf434b0@d1g2000pra.googlegroups.com> <195771d1-1bb3-4d62-b9c3-920db5a912ac@y21g2000hsf.googlegroups.com> Message-ID: 7stud wrote: >>> Just like the message says: You are trying to use `str` (on the right hand >>> side of the assignment) before anything is bound to that name. >>> Ciao, >>> Marc 'BlackJack' Rintsch >> i know but i want the variable str(which i found out is a reserved >> word so i changed it) to be accessible all over __init__ right? >> > > "all over __init__" ? You could practice with a trivial example to > discover how things work in python: > > def f(): > num = 10 > print num > > f() > > def g(): > print num > num = 10 > > g() > > >> so i tried to delcare it in __init__ in the beginning of the framework >> class but then when i access it in the method Display i get that >> error. >> >> so how should i declare this variable to be able to access it >> everywhere? >> > > You don't declare variables in python. You just start using a > variable when you need it. In other words you don't do this: > > string my_str > my_str = "hello" > > You just write: > > my_str = "hello" > > >> i want another method "calculate" that can access the same string >> later and do the calculations(writing some other code now that will >> read and interpret that). > > Does this look familiar: > >> Another thing you should be aware of: self is like a class wide >> bulletin board. If you are writing code inside a class method, and >> there is data that you want code inside another class method to be >> able to see, then post the data on the class wide bulletin board, i.e. >> attach it to self. But in your code, you are doing this: >> >> self.btnDisplay = Button(self, text="7", default=ACTIVE) >> self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) >> >> self.btnDisplay = Button(self, text="8", default=ACTIVE) >> self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) >> >> As a result, your code continually overwrites self.btnDisplay. That >> means you aren't preserving the data assigned to self.btnDisplay. >> Therefore, the data does not need to be posted on the class wide >> bulletin board for other class methods to see. So just write: >> >> btnDisplay = Button(self, text="7", default=ACTIVE) >> btnDisplay.grid(row=5, column=0, padx=5, pady=5) >> >> btnDisplay = Button(self, text="8", default=ACTIVE) >> btnDisplay.grid(row=5, column=1, padx=5, pady=5) To pick nits, "str" is not a reserved word (normally referred to in Python as s "keyword"). It's perfectly possible to write: >>> def str(x): ... return "Fooled you!" ... >>> str(3.14148) 'Fooled you!' >>> and have your program work. But it's not generally good practice to *shadow* built-in names, even when nothing stops you from doing so, simply because there is usually a group somewhere with an investment in using the standard names, and you will make their lives more difficult. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From skanemupp at yahoo.se Wed Apr 23 23:43:02 2008 From: skanemupp at yahoo.se (globalrev) Date: Wed, 23 Apr 2008 20:43:02 -0700 (PDT) Subject: function that accepts any amount of arguments? Message-ID: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> if i want a function that can take any amount of arguments how do i do? lets say i want a function average that accepts any number of integers and returns the average. From gillet at scripps.edu Fri Apr 25 14:11:48 2008 From: gillet at scripps.edu (Alexandre Gillet) Date: Fri, 25 Apr 2008 11:11:48 -0700 Subject: Problem building python in virtual machine running centos In-Reply-To: <1209085558.20290.3.camel@solomon> References: <1209085558.20290.3.camel@solomon> Message-ID: <1209147108.1283.2.camel@solomon> Thanks for your answers. I did solve my problem. I upgraded my glibc libraries and it seems to solve the problem. I was able to build python-2.4.5 using gcc 4.1.2 (glibc-2.5-18.el5_1.1) Alex On Thu, 2008-04-24 at 18:05 -0700, Alexandre Gillet wrote: > Hi, > > I am trying to build python-2.4.5 on Centos 5.1, which is a virtual > machine running with xen. > I am not able to build python. The compilation crash with the following: > gcc -pthread -c -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. > -I./Include -DPy_BUILD_CORE -o Objects/unicodeobject.o > Objects/unicodeobject.c > In file included from ./Include/Python.h:76, > from Objects/unicodeobject.c:39: > ./Include/object.h:228: internal compiler error: Segmentation fault > Please submit a full bug report, > with preprocessed source if appropriate. > See for instructions. > The bug is not reproducible, so it is likely a hardware or OS problem. > > > Any suggestion of what am I doing wrong? > > Thanks > Alex > From kelle.lavoni at gmail.com Wed Apr 16 11:17:35 2008 From: kelle.lavoni at gmail.com (kelle.lavoni at gmail.com) Date: Wed, 16 Apr 2008 08:17:35 -0700 (PDT) Subject: who is kate hudson dating Message-ID: <08589ee0-590e-4568-b056-71c728f4bb0f@l42g2000hsc.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From gandalf at shopzeus.com Mon Apr 21 05:28:22 2008 From: gandalf at shopzeus.com (Laszlo Nagy) Date: Mon, 21 Apr 2008 05:28:22 -0400 Subject: PIL font encoding Message-ID: <480C5E36.7090505@shopzeus.com> def getfnt(size): return ImageFont.truetype("cartoon.ttf",size,encoding='unic') Using the above function, I cannot draw special german characters. E.g. u'L\xfctgendorf' It will print "Lutgendorf" instead of "L?tgendorf". Much more interesting is that I can also do this: def getfnt(size): return ImageFont.truetype("cartoon.ttf",size,encoding='put_somethin_here_it_has_no_effect WHAT?????? ') Same results. Shouldn't the truetype constructor raise an exception if the encoding is invalid and/or not available with the selected font? BTW my "cartoon.ttf" font is able to print "L?tgendorf". I have tested it from GIMP. So I'm 100% sure that the problem is with PIL. Thank you, Laszlo From ganeshborse at gmail.com Mon Apr 21 18:11:31 2008 From: ganeshborse at gmail.com (grbgooglefan) Date: Mon, 21 Apr 2008 15:11:31 -0700 (PDT) Subject: how to pass C++ object to another C++ function via Python function References: <1810b155-5598-4f17-a8e9-e4aa848db5de@i36g2000prf.googlegroups.com> Message-ID: On Apr 21, 10:17?pm, "Gabriel Genellina" wrote: > En Mon, 21 Apr 2008 10:24:15 -0300, grbgooglefan escribi?: > > > I am trying to pass a C++ object to Python function. This Python > > function then calls another C++ function which then uses this C++ > > object to call methods of that object's class. > > > I tried something like this, but it did not work, gave core dump. > > You can't pass any arbitrary C object to a Python function. > In this case you can use a PyCObject, a Python box around a void* pointer. > Seehttp://docs.python.org/api/cObjects.html Yup, I looked at http://www.python.org/doc/ext/using-cobjects.html also. I could not find in this example where is CObject used or converted back from Python to C. Is there any tutorial which I can use for this? From aaron.watters at gmail.com Mon Apr 14 16:27:42 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Mon, 14 Apr 2008 13:27:42 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> Message-ID: <0853b778-c20b-44bb-ac9b-a5803a1aecc5@e67g2000hsa.googlegroups.com> > A question often asked--and I am not a big a fan of these sorts of > questions, but it is worth thinking about--of people who are creating > very large data structures in Python is "Why are you doing that?" > That is, you should consider whether some kind of database solution > would be better. You mention lots of dicts--it sounds like some > balanced B-trees with disk loading on demand could be a good choice. Well, probably because you can get better than 100x improved performance if you don't involve the disk and use clever in memory indexing. BTW, I think the default behaviour of the gc is pretty silly. I tend to disable automatic gc and explicitly put in collections when I know I'm done with some big operation these days. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=dumb+slow From paul.anton.letnes at gmail.com Fri Apr 11 16:18:35 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Fri, 11 Apr 2008 22:18:35 +0200 Subject: Wrapping C++ class with SWIG, Mac OS X Message-ID: Hello guys, (related to previous thread on wrapping C/C++ in Python, trying the SWIG approach.) Trying to map a C++ class to python, one method for now. Running the following commands to "compile": -------------------------------------- #!/usr/bin/env bash MOD_NAME=Wavelet swig -c++ -python -o ${MOD_NAME}_wrap.cpp ${MOD_NAME}.i gcc -c++ -fPIC -c ${MOD_NAME}.cpp -o ${MOD_NAME}.o -I/usr/include/ python2.5 -I/usr/lib/python2.5 gcc -c++ -fPIC -c ${MOD_NAME}_wrap.cpp -o ${MOD_NAME}_wrap.o -I/usr/ include/python2.5 -I/usr/lib/python2.5 gcc -bundle -flat_namespace -undefined suppress -o _${MOD_NAME}.so $ {MOD_NAME}.o ${MOD_NAME}_wrap.o -------------------------------------- The source code is: -------------------------------------- Wavelet.h -------------------------------------- #ifndef _WAVELET_H_ #define _WAVELET_H_ #include #include using namespace std; class Wavelet { public: Wavelet(vector theV); ~Wavelet(); vector GetDaub4Trans(); private: vector v; }; #endif /*_WAVELET_H_*/ -------------------------------------- and Wavelet.cpp: -------------------------------------- #include "wavelet.h" Wavelet::Wavelet(vector theV) { this->v = theV; } Wavelet::~Wavelet() { // Nothing for now } vector Wavelet::GetDaub4Trans() { vector retV = vector(); retV.push_back(3.14); retV.push_back(2.71); retV.push_back(1.62); return retV; // just to test the approach - everything in here I can fix later. } -------------------------------------- This seems to compile, but in python I get: -------------------------------------- $ python imPython 2.5.2 (r252:60911, Mar 30 2008, 22:49:33) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import Wavelet Traceback (most recent call last): File "", line 1, in File "Wavelet.py", line 7, in import _Wavelet ImportError: dlopen(./_Wavelet.so, 2): Symbol not found: __ZNKSt11logic_error4whatEv Referenced from: /Users/paul/Desktop/Wavelet_SWIG_Cpp/_Wavelet.so Expected in: flat namespace >>> -------------------------------------- Any ideas or tips? SWIG seems very nice for simple C methods where you pass an int and return an int, but I can't seem to figure out the syntaxes etc for more complicated stuff - arrays, vector, C++, ... Appreciate any help! Cheers, Paul. From tkpmep at gmail.com Tue Apr 29 17:18:32 2008 From: tkpmep at gmail.com (Thomas Philips) Date: Tue, 29 Apr 2008 14:18:32 -0700 (PDT) Subject: MatplotLib errors Message-ID: I have just started using MatPlotLib, and use it to generate graphs from Python simulations. It often happens that the graph is generated and a Visual C++ Runtime Library error then pops up: Runtime Error! Program C:\Pythin25\Pythonw.exe This application has requested the Runtime to terminate in an unusual way. Please contact the application's support team for more information. I'm running Python 2.5.2 under Windows XP. Any thoughts on what what may be causing the problem? Thanks in advance Thomas Philips From hdante at gmail.com Sat Apr 26 21:02:25 2008 From: hdante at gmail.com (hdante) Date: Sat, 26 Apr 2008 18:02:25 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> Message-ID: <54dc008c-a747-4507-a2d5-9b4ddccbd5b9@e53g2000hsa.googlegroups.com> On Apr 26, 8:28?pm, n00m wrote: > No so simple, guys. > E.g., I can't solve (in Python) this:http://www.spoj.pl/problems/INTEST/ > Keep getting TLE (time limit exceeded). Any ideas? After all, it's > weekend. > > 450. Enormous Input Test > Problem code: INTEST > > The purpose of this problem is to verify whether the method you are > using to read input data is sufficiently fast to handle problems > branded with the enormous Input/Output warning. You are expected to be > able to process at least 2.5MB of input data per second at runtime. > > Input > The input begins with two positive integers n k (n, k<=107). The next > n lines of input contain one positive integer ti, not greater than > 109, each. > > Output > Write a single integer to output, denoting how many integers ti are > divisible by k. > > Example > Input: > 7 3 > 1 > 51 > 966369 > 7 > 9 > 999996 > 11 > > Output: > 4 Maybe the problem is not in reading the input. PS: you can throw a lot of time away in that site. :-) From rjh at see.sig.invalid Mon Apr 14 04:12:56 2008 From: rjh at see.sig.invalid (Richard Heathfield) Date: Mon, 14 Apr 2008 08:12:56 +0000 Subject: Game design : Making computer play References: Message-ID: <54KdnSk6WoWSjJ7VRVnyiQA@bt.com> [comp.programming added, and followups set to that group] v4vijayakumar said: > On Apr 14, 12:35 pm, Richard Heathfield wrote: >> v4vijayakumar said: >> > In computer based, two player, board games, how to make computer play? >> >> Write some code that works out what the computer player should do. If >> you want a better answer, ask a better question. > > I am just implementing a game played in my village (Tamilnadu / > India), called "aadupuli" (goats and tigers). There are only 23 > positions and 18 characters (15 goats and 3 tigers). Some of you might > be aware of this. > > I can post initial version of the game (implemented using html/ > javascript) in couple of hours here. > > Welcome any help in making computer to play one of these player. comp.programming would be a better group. I've found a picture of the board, but I can't find the rules anywhere, without which the task is impossible. Can you tell us what they are? If you reply, I suggest you do so in comp.programming. -- Richard Heathfield Email: -http://www. +rjh@ Google users: "Usenet is a strange place" - dmr 29 July 1999 From the.blue.valkyrie at gmail.com Sat Apr 19 14:31:20 2008 From: the.blue.valkyrie at gmail.com (=?ISO-8859-1?Q?Cristina_Yenyxe_Gonz=E1lez_Garc=EDa?=) Date: Sat, 19 Apr 2008 20:31:20 +0200 Subject: Issue with inspect module In-Reply-To: <2e5e2d31-2adc-4416-a993-19bc05a512bd@w8g2000prd.googlegroups.com> References: <2e5e2d31-2adc-4416-a993-19bc05a512bd@w8g2000prd.googlegroups.com> Message-ID: 2008/4/19, ilanschnell at gmail.com : > Hi, Hello, > I have this trivial program: > > import inspect > class A: > def __init__(self, a): > self.a = a > def __str__(self): > return 'A(%s)' % self.a > a = A(8) > print a > > the output is: > A(8) > A(8) > > Why does the inspect module cause the output > to be printed twice? > I have just run it on the CPython interpreter and it works well. Have you tried it without the 'import inspect' line and checked there is no problem? Or maybe are you using another interpreter? From marexposed at googlemail.com Thu Apr 17 14:41:49 2008 From: marexposed at googlemail.com (marexposed at googlemail.com) Date: Thu, 17 Apr 2008 19:41:49 +0100 Subject: MySQL hardcoding? Message-ID: <20080417194149.eddefdc8.marexposed@googlemail.com> I've got this error (see the path in last line) db=MySQLdb.connect(host='localhost',use_unicode = True, charset = "Windows-1251",user='root',passwd='12',db='articulos') File "C:\Python24\Lib\site-packages\MySQLdb\__init__.py", line 74, in Connect return Connection(*args, **kwargs) File "C:\Python24\lib\site-packages\MySQLdb\connections.py", line 198, in __init__ self.set_character_set(charset) File "C:\Python24\lib\site-packages\MySQLdb\connections.py", line 277, in set_character_set super(Connection, self).set_character_set(charset) OperationalError: (2019, "Can't initialize character set Windows-1251 (path: C:\\mysql\\\\share\\charsets\\)") The truth of the matter is, MySQL is not installed in that path, but into Program Files. I don't know where the hardcoding is, but it is certainly somewhere. Except MySQL is reporting a wrong installation path. I haven't found any other topic in the list about this problem. I'm using Python 2.4 and latest MySQLdb. Have anyone heard of this issue and how to fix it? Thanks a lot. From mobile at ibinsa.com Tue Apr 8 15:01:20 2008 From: mobile at ibinsa.com (Gabriel Ibanez) Date: Tue, 8 Apr 2008 21:01:20 +0200 Subject: Running a python code periodically References: Message-ID: <02f401c899aa$ef2b6df0$0a01a8c0@mobile> Hi, On Linux/Unix: $ man at You could create a bash script using this command. Keep in mind that the script must "schedule" itself again. There's other way: using the cron daemon (crond). Its programming depends on the used distro. I hope this helps. Regards .. ----- Original Message ----- From: Maryam Saeedi To: python-list at python.org Sent: Tuesday, April 08, 2008 7:53 PM Subject: Running a python code periodically Hi, I was wondering if you know how can I run a python code once every five minutes for a period of time either using python or some other program like a bash script. Thanks, Maryam ------------------------------------------------------------------------------ -- http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail.ilocke at gmail.com Tue Apr 29 17:27:32 2008 From: mail.ilocke at gmail.com (ivan) Date: Tue, 29 Apr 2008 14:27:32 -0700 (PDT) Subject: Tix.HList - Move Cursor Message-ID: Hello, How do I move the keyboard cursor position in a Tix.HList? I am using an HList with the right mouse button bound to pop up a menu. If the right click is done on an unselected item, I change the selection to that item. This works, however the keyboard cursor position remains at the last item selected with arrow keys or left click. How can I move this as well as the selection? def onrightclick(event): rightselected=hlist1.nearest(event.y) if hlist1.selection_includes(rightselected) <> "0": callpopup(rightselected) else: hlist1.selection_clear() hlist1.selection_set(rightselected) callpopup(rightselected) hlist1.bind("", onrightclick) Thanks, Ivan From ncoghlan at gmail.com Mon Apr 21 08:51:40 2008 From: ncoghlan at gmail.com (NickC) Date: Mon, 21 Apr 2008 05:51:40 -0700 (PDT) Subject: Finally had to plonk google gorups. References: Message-ID: <966256b2-fe7c-4ec5-900b-90b285311881@k10g2000prm.googlegroups.com> Hmm, according to this thread I probably shouldn't bother even trying to contribute to c.l.p discussions that are highlighted in the Python- URL announcements, even in cases where I think a core developer's perspective may be of interest. As someone that only posts here rarely, and uses Google Groups with a Gmail address to do so, it sounds like I'll be kill-filed by a lot of people regardless of the contents of what I post. *shrug* Ah well, such is life. Cheers, Nick. From http Fri Apr 11 04:20:12 2008 From: http (Paul Rubin) Date: 11 Apr 2008 01:20:12 -0700 Subject: How is GUI programming in Python? References: <7xod8h39zu.fsf@ruckus.brouhaha.com> Message-ID: <7xmyo0hkg3.fsf@ruckus.brouhaha.com> Phil Thompson writes: > > Installing Pyqt on windows involves a couple "click to install" EXEs. On > > Linux, one uses yum or apt. Only on Mac is it marginally a bit harder. > > Actually, on Windows it's only one .exe as the PyQt GPL binary installer > includes Qt and all it's tools (and the eric IDE, and PyQwt). Generally I prefer to minimize the number of installs, and especially minimize the number of binary installs. And my experience with yum and apt has generally been dependency hell, especially when installing from sources. But anyway, I consider zero installs to be far superior to any number greater than zero. From george.sakkis at gmail.com Mon Apr 21 19:16:46 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Mon, 21 Apr 2008 16:16:46 -0700 (PDT) Subject: Code question References: <60ffc058-488f-4e58-b3c9-a60c21595c6f@w8g2000prd.googlegroups.com> Message-ID: On Apr 21, 4:42?pm, Matimus wrote: > On Apr 21, 12:05 pm, wrote: > > > > > I've been trying to figure out a way to combine lists similar to how zip() works. ?The main > > difference though is I want to work with different length lists and combine them. ?I came up with > > the example below, which returns a list like I'm wanting. ?I'm assuming it's somewhat efficient > > (although I wonder if the lists were huge that the 'if' statement might slow things down?). > > > If anyone has time, I was wondering if you could share your thoughts on whether this is an > > efficient way to do something like this, if it's horrible and slow, etc. > > > Thanks! > > > Jay > > > # ---------------------------- > > > def combineLists(theLists): > > ? ? cntList = len(theLists) > > ? ? lenList = [len(x) for x in theLists] > > > ? ? maxList = max(lenList) > > > ? ? combinedList = [] > > > ? ? for x in range(maxList): > > ? ? ? ? for n in range(cntList): > > ? ? ? ? ? ? if lenList[n] > x: combinedList.append(theLists[n][x]) > > > ? ? print combinedList > > > combineLists([a, b, c]) > > > # ---------------------------- > > > # --> ['a', '1', 'a1', 'b', '2', 'b2', 'c', 'c3', 'd4', 'e5'] > > I would probably do something like this: > > >>> def combine(*seqs): > > ... ? ?seqs = [iter(s) for s in seqs] > ... ? ?while seqs: > ... ? ? ? for g in seqs: > ... ? ? ? ? ?try: > ... ? ? ? ? ? ? yield g.next() > ... ? ? ? ? ?except StopIteration: > ... ? ? ? ? ? ? seqs.remove(g) > ...>>> a = 'abc' > >>> b = '12' > >>> c = 'a1 b2 c3 d4 e5'.split() > >>> list(combine(a,b,c)) > > ['a', '1', 'a1', 'b', '2', 'b2', 'c', 'c3', 'd4', 'e5'] > > It has the advantage that it uses the generator protocol, so you can > pass in any type of sequence. It uses arbitrary arguments to make its > use closer to that of zip. It is also a generator, so it takes > advantage of lazy evaluation. Notice that there is never any checking > of length. > > Matt A similar solution using the itertools module: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/528936 George From carlwuhwdmckay at gmail.com Mon Apr 21 02:09:43 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:09:43 -0700 (PDT) Subject: dark crusade 1.11 patch Message-ID: dark crusade 1.11 patch http://cracks.00bp.com F R E E C R A C K S From kveretennicov at gmail.com Wed Apr 2 15:38:07 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Wed, 2 Apr 2008 22:38:07 +0300 Subject: non-terminating regex match In-Reply-To: References: <65i0i3F2embp3U2@mid.uni-berlin.de> Message-ID: <4660fe300804021238v6e2c526ax1fdf29012d5ecd1d@mail.gmail.com> On Wed, Apr 2, 2008 at 9:32 PM, Maurizio Vitale wrote: > Marc 'BlackJack' Rintsch writes: > > > On Wed, 02 Apr 2008 16:01:59 +0000, Maurizio Vitale wrote: > > > >> And yes, I'm a total beginner when it comes to Python, but it seems > >> very strange to me that a regex match on a finite length string > >> doesn't terminate > > > > It does terminate, you just don't wait long enough. Try it with fewer > > characters and then increase the identifier character by character and > > watch the time of the runs grow exponentially. > > > > Ok. Now, my assumption was that re.compile would produce a DFA (or NFA) > and the match would then being linear in the size of the string. > No, it's easy to come up with regex that would perform exponentially by nesting repeated groups. > Apparently this is not the case, so is there anything that can be done > to the regex itself to make sure that whatever re.compile produces is > more efficient? Avoid catastrophic backtracking: http://www.regular-expressions.info/catastrophic.html -- kv -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Mon Apr 7 09:14:58 2008 From: __peter__ at web.de (Peter Otten) Date: Mon, 07 Apr 2008 15:14:58 +0200 Subject: A file iteration question/problem References: <47f8eee1$0$759$bed64819@news.gradwell.net> <322f98fd-eb6e-4a05-a8c7-1e0c5329e955@w5g2000prd.googlegroups.com> <47fa1cf9$0$761$bed64819@news.gradwell.net> Message-ID: tinnews at isbd.co.uk wrote: > Arnaud Delobelle wrote: >> You could use an iterator over the lines of the file: >> >> def recfun(lines): >> for line in lines: >> # Do stuff >> if condition: >> recfun(lines) >> >> lines = iter(open(filename)) >> recfun(lines) > Does that work though? If you iterate through the file with the "for > line in lines:" in the first call of recfun(lines) you surely can't do > "for line in lines:" and get any sort of sensible result in recursive > calls of recfun(lines) can you? Don't speculate, try it. Peter From __peter__ at web.de Wed Apr 16 15:27:20 2008 From: __peter__ at web.de (Peter Otten) Date: Wed, 16 Apr 2008 21:27:20 +0200 Subject: Default parameter for a method References: <806788d2-67b7-456b-bd1e-08c50cbf0f7b@8g2000hsu.googlegroups.com> Message-ID: Cliff Wells wrote: > > On Wed, 2008-04-16 at 13:47 -0500, Larry Bates wrote: >> s0suk3 at gmail.com wrote: >> > I wanted to know if there's any way to create a method that takes a >> > default parameter, and that parameter's default value is the return >> > value of another method of the same class. For example: >> > >> > class A: >> > def __init__(self): >> > self.x = 1 >> > >> > def meth1(self): >> > return self.x >> > >> > def meth2(self, arg=meth1()): >> > # The default `arg' should would take the return value of >> > meth1() >> > print '"arg" is', arg >> > >> > This obviously doesn't work. I know I could do >> > >> > ... >> > def meth2(self, arg=None): >> > if arg is None: >> > arg = self.meth1() >> > >> > but I'm looking for a more straightforward way. >> >> You can write this as: >> >> def meth2(self, arg=None): >> arg = arg or self.meth1() >> >> IMHO - You can't get much more "straightforward" than that. > > What if arg is 0 an empty list or anything else that's "False"? > > def meth2(self, arg=None): > arg = (arg is not None) or self.meth1() > > is what you want. No, it's not: >>> for arg in None, 0, "yadda": ... print "---", arg, "---" ... if arg is None: arg = "call method" ... print "OP:", arg ... print "Larry:", arg or "call method" ... print "Cliff:", (arg is not None) or "call method" ... --- None --- OP: call method Larry: call method Cliff: True --- 0 --- OP: 0 Larry: call method Cliff: True --- yadda --- OP: yadda Larry: yadda Cliff: True Peter From brenNOSPAMbarn at NObrenSPAMbarn.net Wed Apr 2 20:00:16 2008 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Thu, 03 Apr 2008 00:00:16 GMT Subject: function call - default value & collecting arguments References: <_LQIj.9776$HS3.482805@news.siol.net> Message-ID: Primoz Skale wrote: > OK, everything allright till so fair. But! :) Now define third > function as: > > def f(*a): > print a[0] > > In this case, function only prints first argument in the tuple: > >>>f(1,2,3) > 1 >>>f(3) > 3 >>>f() #no arguments passed > Traceback (most recent call last): > File "", line 1, in > f() #no arguments passed > File "", line 2, in f > print a[0] > IndexError: tuple index out of range > > Then I tried to define the function as: > > def f(*a=(0,)): > print a[0] #this should come next, but we get error msg instead, > saying > > SyntaxError: invalid syntax > > but it does not work this way. Now my 'newbie' question: Why not? > :) I wanted to write function in this way, because then we can call > function without any arguments, and it would still print 0 (in this > case). > > What I wanted was something like this: > > def f(*a=(0,)): > print a[0] > >>>f(1,2) > 1 >>>f() #no args passed 0 When you use the *a syntax, you're saying that you want a to contain a tuple of all the arguments. When you try *a=(0,), you seem to be saying that you want a to hold all the arguments, or, if there are none, you want to pretend that it was called with one argument, namely 0. Well, if you want to ensure that there is at least one argument, and print that first one, and make it zero if it's not supplied, why are you using the *a syntax? You're clearly treating that first argument distinctly, since you want to apply a default value to it but not to any others. Just do this: def f(a, *b): print a -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From mccredie at gmail.com Fri Apr 25 12:56:06 2008 From: mccredie at gmail.com (Matimus) Date: Fri, 25 Apr 2008 09:56:06 -0700 (PDT) Subject: Subclassing list the right way? References: Message-ID: On Apr 25, 7:03 am, Kirk Strauser wrote: > I want to subclass list so that each value in it is calculated at call > time. I had initially thought I could do that by defining my own > __getitem__, but 1) apparently that's deprecated (although I can't > find that; got a link?), and 2) it doesn't work. > > For example: > > >>> class Foo(list): > > ... def __getitem__(self, index): > ... return 5 > ...>>> a = Foo([1, 2, 3, 4, 5]) > >>> print a > [1, 2, 3, 4, 5] > >>> print a[2:4] > [3, 4] > >>> print a[3] > > 5 > > I first expected that to instead behave like: > > >>> print a > [5, 5, 5, 5, 5] > >>> print a[2:4] > > [5, 5] > > Is there a "right" way to do this? > -- > Kirk Strauser The built in types are very optimized. You can't make any assumptions about how overriding methods on them will affect other method calls. >From the docs: __getitem__( self, key) Called to implement evaluation of self[key]. For sequence types, the accepted keys should be integers and slice objects. Note that the special interpretation of negative indexes (if the class wishes to emulate a sequence type) is up to the __getitem__() method. If key is of an inappropriate type, TypeError may be raised; if of a value outside the set of indexes for the sequence (after any special interpretation of negative values), IndexError should be raised. For mapping types, if key is missing (not in the container), KeyError should be raised. Note: for loops expect that an IndexError will be raised for illegal indexes to allow proper detection of the end of the sequence. What that basicly says is that it affects what is returned by a[x]. >>> class Foo(list): ... def __getitem__(self, index): ... return 5 ... >>> a = Foo([1, 2, 3, 4, 5]) >>> print a # a.__str__ called [1, 2, 3, 4, 5] >>> print a[2:4] # a.__getslice__ called [3, 4] >>> print a[3] # a.__getitem__ called 5 The _right_ way? Well, it depends on what you really want to do. If you really want to calculate the value at call time but have it behave exactly as a list in every way, then you will have to override pretty much any method that deals with the values normally stored in the list object. That means any method that either returns values stored in the object, accepts as a parameter values stored in the object or uses the values stored in the object in any way. Methods that return values stored in the object: __getitem__ __getslice__ pop Methods that accept as a parameter values stored in the object: __contains__ count remove index Methods that use values stored in the object in some way: __add__ __eq__ __ge__ __gt__ __iadd__ __imul__ __le__ __lt__ __mul__ __ne__ __reduce__ __reduce_ex__? I'm not sure about this one, I think it is for pickling __repr__ __reversed__ __rmul__ __str__ __iter__ sort reverse I know that Py3.0 is going to implement Abstract Base Classes. I don't know if that is going to clean up this behavior or not. So, you can either write a lot of code or restrict the way you use lists to a limited amount of functionality. There is a third option, which is to calculate the values when storing. This might be a little easier, but if you want to ensure that values returned by all methods are the same type as your class you are back to overriding a lot of methods. Matt From nick at craig-wood.com Fri Apr 18 06:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Fri, 18 Apr 2008 05:30:03 -0500 Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> <9140b6c2-fcf3-454f-a24e-0ed03b3b8e3b@k37g2000hsf.googlegroups.com> Message-ID: Rhamphoryncus wrote: > On Apr 17, 7:40 am, Steve Holden wrote: > > I'd love to be wrong about that, but the GIL *has* been the subject of > > extensive efforts to kill it over the last five years, and it has > > survived despite the best efforts of the developers. > > Yo. http://code.google.com/p/python-safethread/ Sounds very interesting. I particularly liked this bit from the web page - an excellent solution to fine grained locking. Sending only immutable objects between threads is very like the functional approach used by Erlang which is extremely good at concurrency. ------------------------------------------------------------ Which objects can be shared between threads You probably know how to append to a list or modify a dict. When confronted with threading though you may start to wonder, what happens if two threads modify a list or a dict simultaneously? There's two common answers to this: * 1. Corruption. This is the default in C, and to a lesser degree Java. It doesn't limit you much and can be faster, but it requires some deep voodoo to know when you're using it right. * 2. Locks. All the operations internally lock the object. This makes them individually correct, but they'll be wrong again if you try to compose them into larger operations. It also adds a significant performance penalty. My priority is making it easy to write correct programs, and neither of those options are good enough. Instead, I take a third option as my default: * 3. Make sharing impossible, avoiding the question. list and dict cannot be shared between threads. Any attempt to pass a list or dict into something like a Queue will raise a TypeError. This ensures any thread interaction is explicit, rather than implicit. See also: The Zen of Python Of course if you couldn't share any objects then you'd just have processes, which are quite awkward to use. Instead, I only make mutable objects like list and dict unshareable, while immutable int and str objects can still be shared. Further, mutable objects that provide an explicit API for use between threads are also shareable. ------------------------------------------------------------ -- Nick Craig-Wood -- http://www.craig-wood.com/nick From torriem at gmail.com Tue Apr 8 21:52:33 2008 From: torriem at gmail.com (Michael Torrie) Date: Tue, 08 Apr 2008 19:52:33 -0600 Subject: Python Leopard DLL Hell In-Reply-To: <54b165660804081819g4787f4d9g821c7269af7b4c66@mail.gmail.com> References: <54b165660804081819g4787f4d9g821c7269af7b4c66@mail.gmail.com> Message-ID: <47FC2161.5020905@gmail.com> Brian Cole wrote: > That appears to be working correctly at first glance. The argument to > dlopen is the correct shared library. Unfortunately, either python or > OS X is lying to me here. If I inspect the python process with OS X's > Activity Monitor and look at the "Open Files and Ports" tab, it shows > that the _foo.so shared library is actually the one located inside > $DYLD_LIBRARY_PATH. > > So this problem may not be python's, but I place it here as a first > shot (maybe I'm using the imp module incorrectly). Sounds like you're going to need to learn how to use dtrace. Then you can more closely monitor exactly what python and the loader are doing. dtrace is very complicated (borrowed from Solaris) but extremely powerful. Worth learning anyway, but sounds like it's probably the debugging tool you need. Another thing you can do is check through the python source code and see how the os x-specific code is handling this type of situation. From vivainio at gmail.com Wed Apr 23 11:17:34 2008 From: vivainio at gmail.com (Ville M. Vainio) Date: Wed, 23 Apr 2008 15:17:34 GMT Subject: Unix Device File Emulation In-Reply-To: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> Message-ID: blaine wrote: > example usage: echo 'line 0 0 10 10' > /dev/screen > > On the actual embedded device this is handled by a kernel module. We > can spit commands into it as fast as we can and the kernel module can > keep up. This is typical unix device file behavior. > > Any suggestions or advice would be splendid. Thanks! Assuming you are on unix, have you considered FIFO's, os.mkfifo()? From ceo.ch2008 at hotmail.com Sat Apr 19 19:19:59 2008 From: ceo.ch2008 at hotmail.com (ceo.ch2008 at hotmail.com) Date: Sat, 19 Apr 2008 16:19:59 -0700 (PDT) Subject: www.crazysupplier.com cheap nike shoes nike air jordans Manufacturer, Buyer, Supplier ... Message-ID: China wholesaler of cheap air jordan shoes,wholesale jordans,wholesale jordans from china,wholesale nike jordans (www.crazysupplier.com) Buy new jordan 23 shoes, air jordan 23 shoes,jordan xx3,nike jordan xxiii,new air jordan 23 shoes,AJ23,jordan 23 (www.crazysupplier.com) cheap Air jordan xxiii,Jordan 23,cheap wholesale jordan 23,cheap buy air jordan 23,cheap air jordan XX3,XXIII from china (www.crazysupplier.com) cheap wholesale jordans,china wholesalers,Jordans cheap wholesale price,buy cheap jordans,air jordan suppliers from china (www.crazysupplier.com) AJ XXIII,aj23,aj xx3,Nike jordan 23,air jordan xx3,Air jordan xxiii,air jordan 23,new jordan xxiii,cheap jordan xx3,buy from china (www.crazysupplier.com) Jordan shoes xxiii,air jordan shoes 23,new jordan 23,xx3,new jordan 23 shoes,Nike Air jordan 23,xx3 jordan,xx3 shoes,nike jordan xxiii (www.crazysupplier.com) Nike air jordan force 23,ajf23,air jordan 23 fusions,nike jordan 23 fusions,AJF xx3, Jordan XX3 fusions,air force jordan 23 xx3,xxiii fusions,nike air jordan fusions xxiii Mixed jordans,air jordan mix,air jordan 3 force one,ajf3,jordan 3 fusions,Air force one jordan iii fusions,Nike air jordan 3 iii X air force one fusions, air force jordan 3 iii fusions, air jordan 4 v fusions, AJF4,air force one jordan v 4,nike AJF4 fusions (www.crazysupplier.com) Nike Jordan countdown pack 10/13,Nike Jordan Countdown Pack (14/9),Nike Air Jordan Collezione (Countdown Pack 10 / 13) Wholesale Air Jordan 12 Fusions (www.crazysupplier.com) china wholesaler Air Jordan 5 x AF1 Fusions Black/Red Sneaker (www.crazysupplier.com) wholesale Air Jordan Force 12 Fusions (www.crazysupplier.com) Air Jordan V x Air Force 1 Fusion,air force 1 jordans (www.crazysupplier.com) Nike Air Jordan Force XII Fusion (www.crazysupplier.com) Air Jordan XII x AF1 Fusion (www.crazysupplier.com) AIR FORCE 1 AIR JORDAN V fusion (www.crazysupplier.com) Nike Air Jordan XII Fusions (www.crazysupplier.com) Nike Air Jordan IV Fusions,Air jordan 4 plus air force 1 (www.myshoesdepot.com) Nike AF1 Air Jordan Fusions wholesale (www.crazysupplier.com) Nike Air Jordan Fusions XII Mid (www.crazysupplier.com) Men's Nike Air Jordan Fusion XII Mid (www.crazysupplier.com) Air Jordan "Fusions": AJ XII x Air Force 1 (www.crazysupplier.com) Sell Air Jordan 12 fusion sneakers (www.crazysupplier.com) Air Jordan 5 (V) x Air Force 1 (One) - Fusion (www.crazysupplier.com) air jordan 12 air force one 1 fusion (www.crazysupplier.com) Air Jordan fusion XII (www.crazysupplier.com) Nike fusion shoes,air jordan 4 fusion,AJF4 fusions,Jordan 4 plus af1 fusion,nike jordan fusion Wholesale Air jordan 4 x air force 1 fusions (www.crazysupplier.com) Wholesale cheap jordans and air force ones site at (www.crazysupplier.com) wholesale Air Jordan 12 Fusion,air jordan 5 x air force 1 Fusion (www.crazysupplier.com) (www.crazysupplier.com) Wholesale New Air Jordan 12 Fusion,Air Jordan 12 X Air Force 1 Wholesale New Air Jordan 12 Fusion,Air Jordan 12 X Air Force 1 cheap Air Jordan 5 x Air Force one Fusion (www.crazysupplier.com) discount Air Jordan 5 and Air Force one Fusion (www.crazysupplier.com) Air Jordan 12 x Air Force One china online store (www.crazysupplier.com) (www.crazysupplier.com) Air Jordan V x Air Force 1 Fusion Air Jordan 12 x Air Force Ones Fusion (www.crazysupplier.com) Nike AF1 x Air Jordan 5. Nike Air Force Ones Shoes & Air Jordan 5. wholesale Air Jordan 5 (V) x Air Force 1 Fusion (www.crazysupplier.com) From kotecha.ravi at googlemail.com Fri Apr 4 08:56:58 2008 From: kotecha.ravi at googlemail.com (Ravi Kotecha) Date: Fri, 4 Apr 2008 05:56:58 -0700 (PDT) Subject: Looking for Advanced Python Tutorials References: Message-ID: <440c1624-ad9d-4038-bce5-68a2b4ed539a@e10g2000prf.googlegroups.com> On Apr 4, 12:58 pm, cokofree... at gmail.com wrote: > I was wondering if anyone knew of some online (free if possible) > advanced tutorials, especially ones that provides tasks and ideas for > small projects. The issue for myself is I want to improve my python > programming level, and my ability to program in general, but come up > blank thinking of a possible task or project to undertake. So with > that in mind I thought I'd ask the community if they knew of sites or > books to read up on and use as a starting block. Of course project > ideas would be great as well! > > Thanks for any help you can provide. > > Coko Project Euler is a site where you work through mathematical problems using any programming language you like. Once you solve a problem you can see everyone elses solutions and Python is quite popular on that site so you'll see some very clever uses of Python there. I like it a lot for when I haven't got anything better to code: http://projecteuler.net/ - Ravi From tinnews at isbd.co.uk Tue Apr 15 05:08:56 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 15 Apr 2008 09:08:56 GMT Subject: =?UTF-8?B?562U5aSNOg==?= =?UTF-8?B?IOacieS4reWbveS6uuS5jj8=?= References: Message-ID: <480470a8$0$752$bed64819@news.gradwell.net> Penny Y. wrote: > -----????----- > ???: python-list-bounces+pylists=arcor.de at python.org > [mailto:python-list-bounces+pylists=arcor.de at python.org] ?? Steve Holden > ????: 2008?4?15? 2:17 > ???: python-list at python.org > ??: Re: ?????? > > > >Since what I entered in English was something like "Yes, Python has a > >future. But it will take some study". Perhaps you can tell me whether > >your translation gives the correect flavor. I'm pretty sure the > >babelfish mangled my intent. > > > > Babelfish does that thing worse. > yes follow your words, the translation could be: > > Python????.????????, ??????. > > :-) > > Coo, I was just about to ask why I couldn't see most of the characters displayed correctly and now, when I hit reply, I do! :-) So that has solved the conundrum for me, my editor is set up correctly for UTF-8 but my news program's pager isn't. Not that I can read the chinese characters but it's rather nice being able to display them. :-) -- Chris Green From hobgoodoreneyhb at gmail.com Tue Apr 22 11:43:32 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:43:32 -0700 (PDT) Subject: mucaca cracks Message-ID: <8a4a9349-9031-4bb0-924f-060fe39f4703@s50g2000hsb.googlegroups.com> mucaca cracks http://cracks.12w.net F R E E C R A C K S From john106henry at hotmail.com Wed Apr 2 18:29:28 2008 From: john106henry at hotmail.com (John Henry) Date: Wed, 2 Apr 2008 15:29:28 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> <58deb8b8-bae9-4d43-b973-3d90846726cb@b5g2000pri.googlegroups.com> Message-ID: <873a5fc2-0bd8-4f93-9c8c-56cda6e0090a@s37g2000prg.googlegroups.com> On Apr 2, 1:32 pm, Stef Mientki wrote: > John Henry wrote: > > On Apr 1, 11:10 am, sprad wrote: > > >> On Apr 1, 11:41 am, mdomans wrote: > > >>> Python needs no evangelizing but I can tell you that it is a powerfull > >>> tool. I prefer to think that flash is rather visualization tool than > >>> programing language, and java needs a lot of typing and a lot of > >>> reading. On the other hand python is simple to read and write, can be > >>> debuged easily, is intuitive and saves a lot of time. It also supports > >>> batteries included policy and you can't get more OO than python. > > >> One advantage of Flash is that we can have something moving on the > >> screen from day one, and add code to it piece by piece for things like > >> keyboard or mouse control, more and more complex physics, etc. Is > >> there an equivalent project in Python? > > > I downloaded the "How to Think Like a Python Programmer" book and read > > it. I think it's a fine reference book for the purpose you > > indicated. > > > Here's my 2 cents on the subject. > > > I had been a volunteer mentor to my son's middle school robotic team > > for several years and I have some experiences, therefore, in how kids > > react to "programming". Granted, high school kids are "bigger kids" - > > but they are kids nevertheless. > > > Last summer, I experimented teaching my own kid Python. He was in 7th > > grade going onto 8th grade. He was the main goto person for the > > robotic team and had no trouble learning the common applications such > > as the Microsoft Office suite, and had some experience in ICONic > > programming (Lego Mindstorm). So, I tried to see what would happen if > > he tries to learn Python - using somewhat similar approach you are > > taking: start with something visually appealing on day one. Instead > > of Flash, I used Pythoncard - a no-brainer Python GUI construction > > toolkit. He was really excited seeing how easy it was to have tic-tae- > > toe type program up so easily (we are taking minutes - not hours) and > > was very interested and motivated to continue. So far so good. > > However, once I start teaching him variables, expressions, loops, and > > what not, I found that (by surprise) he had great difficulties > > catching on. Not soon after that, we had to quit. > > > We - as adults - take many things for granted and sometimes don't > > remember, or don't understand how kids learn. My experience tells me > > that in order to teach today's video game generation of kids, the > > approach really has to be entirely visual. After I abandoned my > > attempt to teach my kid Python, I started them on Robolab - a > > simplified version of LabView and to my delight, they were able to > > cook up a few simple programs (like fibonacci series and so forth) > > without too much effort - although my own kid had some minor trouble > > understanding the concept of a container (LabView's version of a > > variable). > > > I don't know if you have access to LabView or Robolab or similar > > packages but if you do, I would highly recommend those. LabView is > > every bit as powerful, full-featured, and "real-life" as many of the > > other languages and I believe that kids will have a much easier time > > learning computer programming with it. > > Well I doubt it's the visual environment that makes it more easy, > color, shape and position can give some extra information though. > I think apriori domain knowledge and flattness of information are of far > more importance. > The first issue is covered quit well by Robolab / Labview, > but the second issue certainly is not. > I'm right now working on a Labview like editor in Python, > which does obey the demand for flatness of information. > The first results can be seen here:http://oase.uci.kun.nl/~mientki/data_www/pylab_works/pw_animations_sc... > > cheers, > Stef Mientki > > > And you are going to teach them Java? Oh, please don't. Let the > > colleges torture them. :=) What do you mean by flatness of information? From misceverything at gmail.com Sat Apr 5 19:56:31 2008 From: misceverything at gmail.com (misceverything at gmail.com) Date: Sat, 5 Apr 2008 16:56:31 -0700 (PDT) Subject: Recursively Backup Directories Message-ID: I am writing a script that will backup specified folders from one hard drive to another (for example, backup source "C:\DATA", destination "D: \Backup"), and was thinking of using shutil. What I would like to do is recursively backup the specified directories (which copytree will do), but be able to specify exclusion directories (which copytree does not appear to allow you to do). My initial thoughts were I'll probably have to use os.path.walk for the backup source directory, but I'm not sure how to go from there. Thanks in advance. From adelagon at gmail.com Wed Apr 9 04:05:45 2008 From: adelagon at gmail.com (Alvin Delagon) Date: Wed, 9 Apr 2008 16:05:45 +0800 Subject: PyArg_ParseTuple for structs or binary data Message-ID: <7a01f6c00804090105h7cba73f0g53687349d8dcd574@mail.gmail.com> Hello fellow pythonistas, I'm currently writing a simple python SCTP module in C. So far it works sending and receiving strings from it. The C sctp function sctp_sendmsg() has been wrapped and my function looks like this: sendMessage(PyObject *self, PyObject *args) { const char *msg = ""; if (!PyArg_ParseTuple(args, "s", &msg)) return NULL; snprintf(buffer, 1025, msg); ret = sctp_sendmsg(connSock, (void *)buffer, (size_t)strlen(buffer), 0, 0, 0x03000000, 0, 0, 0, 0); return Py_BuildValue("b", ""); } I'm going to construct an SS7 packet in python using struct.pack(). Here's the question, how am I going to pass the packet I wrote in python to my module? Thanks in advance! :) --- Alvin Delagon -------------- next part -------------- An HTML attachment was scrubbed... URL: From bronger at physik.rwth-aachen.de Wed Apr 16 13:01:16 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 16 Apr 2008 19:01:16 +0200 Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> <87prspydex.fsf@physik.rwth-aachen.de> Message-ID: <87lk3dybs3.fsf@physik.rwth-aachen.de> Hall?chen! Michael Torrie writes: > Torsten Bronger wrote: > >> The admistrative overhead of mailing lists is tedious. >> Fortunately, most important computer-related lists are on >> gmane.org. We could list c.l.py there, too. ;-) > > Running a few lists myself, I don't see this. How is > administrative overhead tedious? Most open source projects do it, > so I wonder just how tedious it is. Of all the projects I'm > associated with in lists, Python is the only one still clinging to > NNTP when it appears a normal mail list is just as good. Perish the thought that I ever have to go back to mailing lists again! Finding the web page, entering name and email address and a password, waiting for request for confirmation, sending out confirmation, clicking away welcome message, setting filter in email program, and doing the same for unsubscribing a few days later after having found out that it's not so interesting after all. No. Just going to the group list, search the group, pressing "U" -- and getting all the postings of the past, too! And for unsubscribing, press "U" again. No email address, no password, no filters, no hassle. And spam is also very rare in my groups. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From musiccomposition at gmail.com Tue Apr 15 22:36:35 2008 From: musiccomposition at gmail.com (Benjamin) Date: Tue, 15 Apr 2008 19:36:35 -0700 (PDT) Subject: Brand New! References: <7f1828bf-ebe7-4111-bc59-70d125facb0a@d26g2000prg.googlegroups.com> Message-ID: <2b897fe3-59e8-4268-9821-d203bb7d9d6e@a22g2000hsc.googlegroups.com> On Apr 15, 6:37 pm, agent E 10 wrote: > On Apr 14, 8:37 pm, Benjamin wrote: > > > On Apr 14, 9:00 pm, agent E 10 wrote:> Hi, I'm brand new to programming. Have any suggestions? I'm young. > > > Was it a good idea to start with python? I was planning on creating a > > > very simple program that asked yes/no questions for a school project. > > > IMHO, Python is an excellent language to start with. Have you read the > > tutorial?http://docs.python.org/tut/tut.html > > > > -Thanks!- Hide quoted text - > > > - Show quoted text - > > No, I haven't. I have been reading off of this sitehttp://www.freenetpages.co.uk/hp/alan.gauld/is this a good site to > learn off of? About how long will it take me to learn the basics of > the language? I took a brief glance. It seems like a good start! Compared to other programming languages, Python is very easily to learn. > -Thanks 4 all ur help! Agent E 10 From ivan.illarionov at gmail.com Thu Apr 10 12:30:28 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Thu, 10 Apr 2008 09:30:28 -0700 (PDT) Subject: wrapping C functions in python References: <54b165660804091322w690e5e64x85c3d8f082b411b2@mail.gmail.com> <54b165660804091355m1326f7c0g1a5eebe3d6b5a1df@mail.gmail.com> Message-ID: <1ce459fb-475b-4370-8fd4-a5193600cb23@w1g2000prd.googlegroups.com> On Apr 10, 9:57 am, Paul Anton Letnes wrote: [...] > , but as I mentioned, it seems to be a bit complicated to wrap heavy > data structures like arrays. Hello, I suggest that you might take a look at how other people solved the same problems. The great example is path.c inside PIL [1]. `PyPath_Flatten` function creates C array from Python data, `path_to_list` converts C array into Python list and `path_map` applies a Python function to C array. Also take a look at Python buffer interface [2] - use array module on Python side instead of lists and you'll have almost instant C arrays from Python data and vice versa. 1: http://effbot.org/downloads/Imaging-1.1.6.tar.gz 2: http://docs.python.org/api/buffer-structs.html Regards, -- Ivan From robert.spilleboudt.no.sp.am at skynet.be Thu Apr 10 06:12:38 2008 From: robert.spilleboudt.no.sp.am at skynet.be (Robert.Spilleboudt ) Date: Thu, 10 Apr 2008 12:12:38 +0200 Subject: urgent question, about filesystem-files In-Reply-To: References: Message-ID: <47fde816$0$2956$ba620e4c@news.skynet.be> bvidinli wrote: > i started python programming a few months ago. > > now i need the code to understand if a file already opened in > filesystem by another process ? > > i looked at docs, howtos, but did not find related info. > note that normal file open/write operations in python, i know it. > > i specificly need to know that "is a file already open by some other > process other than python". > > > Thank you in advance This is a OS function. With Linux you use the command lsof (as root). A Python program can call such a command, but you have to parse the output. Robert From frambooz at gmail.com Fri Apr 11 08:54:03 2008 From: frambooz at gmail.com (frambooz at gmail.com) Date: Fri, 11 Apr 2008 05:54:03 -0700 (PDT) Subject: Adding classes to modules at runtime from outside that module References: Message-ID: On Apr 10, 8:05?pm, Andrew Warkentin wrote: > framb... at gmail.com wrote: > > ?In Python, is it possible to add classes to a module at run-time? > > > ?Say I have a module foo and a module bar. Foo has class A and B, and > >bar has class C. I want to add class C to foo so I can access it as > >foo.C, but i want to do it without modifying foo's source. > > > ?Is this at all possible? > > Yes. > > You would do something like > > import foo > import bar > > foo.C = bar.C Wow. That was a lot easier than expected. Thanks, all. ` Rogier From castironpi at gmail.com Wed Apr 2 13:11:30 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 2 Apr 2008 10:11:30 -0700 (PDT) Subject: generator functions: why won't this work? References: Message-ID: <19359dad-3022-4e83-99e4-8f8093116bcb@a1g2000hsb.googlegroups.com> On Apr 1, 10:42?pm, "Gabriel Genellina" wrote: > En Tue, 01 Apr 2008 23:56:50 -0300, escribi?: > > ? ?yield *iterable > > could be used as a shortcut for this: > > ? ?for __temp in iterable: yield __temp How serious were you about that? From stefan_ml at behnel.de Mon Apr 7 02:09:55 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 07 Apr 2008 08:09:55 +0200 Subject: html DOM In-Reply-To: References: Message-ID: <47F9BAB3.9080407@behnel.de> Sam the Cat wrote: > Is there a package that would allow me the same or similar functionality > for modifying html code via the DOM model as I have in JavaScript ? I'd > like to parse an html file, then modify it and save the result. I am > not trying to do this online, rather I would like to do this on a batch > of files stored on my hard drive. I have found several packages that > allow me to parse and dissect html but none that allow me to modify the > object and save the results -- perhaps I am overlooking the obvious http://codespeak.net/lxml/lxmlhtml.html Here are some performance comparisons of HTML parsers: http://blog.ianbicking.org/2008/03/30/python-html-parser-performance/ Stefan From yoz at home.havin.us Wed Apr 16 08:26:04 2008 From: yoz at home.havin.us (yoz) Date: Wed, 16 Apr 2008 13:26:04 +0100 Subject: webcam (usb) access under Ubuntu In-Reply-To: References: Message-ID: Berco Beute wrote: > I've been trying to access my webcam using Python, but I failed > miserably. The camera works fine under Ubuntu (using camora and > skype), but I am unable to get WebCamSpy or libfg to access my webcam. > > First I tried webcamspy (http://webcamspy.sourceforge.net/). That > requires pySerial and pyParallel, and optionally pyI2C. Runing > WebCamSpy results in: > > Exception exceptions.AttributeError: "Parallel instance has no > attribute '_fd'" in > ignored > > This seems to come from importing I2C. The application window opens, > but there's an error message: > > NO VIDEO SOURCE FOUND > > Next I tried libfg (http://antonym.org/libfg). I built it, made the > Python bindings and installed it. Unfortunately the following: > >>>> import fg >>>> grabber = fg.Grabber() > > results in: > > fg_open(): open video device failed: No such file or directory > > Since the camera works fine in Ubuntu itself my guess is that the > problem is with the python libraries (or even likelier, my usage of > them). Is there anybody here that was successful in accessing their > webcam on linux using Python? Else I have to reside to Windows and > VideoCapture (which relies on the win32 api and thus is Windows-only), > something I'd rather not do. > > Thanks for any help, > 2B > > =============== > I am uUsing: > WebCam: Logitech QuickCam Pro 400 > Ubuntu > Python 2.5 Some time ago I was playing with writing a webcam server under Linux using V4L - I found this bit of code which may help (it works for me). Obviously it needs X running to work and the associated libs installed. Note this is not my code but it was a good starting point for me to work from. I can't find a link to the original article but credit to the author. import pygame import Image from pygame.locals import * import sys import opencv #this is important for capturing/displaying images from opencv import highgui camera = highgui.cvCreateCameraCapture(0) def get_image(): im = highgui.cvQueryFrame(camera) #convert Ipl image to PIL image return opencv.adaptors.Ipl2PIL(im) fps = 30.0 pygame.init() window = pygame.display.set_mode((320,240)) pygame.display.set_caption("WebCam Demo") screen = pygame.display.get_surface() while True: events = pygame.event.get() for event in events: if event.type == QUIT or event.type == KEYDOWN: sys.exit(0) im = get_image() pg_img = pygame.image.frombuffer(im.tostring(), im.size, im.mode) screen.blit(pg_img, (0,0)) pygame.display.flip() pygame.time.delay(int(1000 * 1.0/fps)) Best of Luck Bgeddy From rustompmody at gmail.com Mon Apr 21 10:48:28 2008 From: rustompmody at gmail.com (rustom) Date: Mon, 21 Apr 2008 07:48:28 -0700 (PDT) Subject: Java or C++? References: Message-ID: On Apr 14, 11:44?am, s0s... at gmail.com wrote: > Hello, I was hoping to get some opinions on a subject. I've been > programming Python for almost two years now. Recently I learned Perl, > but frankly I'm not very comfortable with it. Now I want to move on > two either Java or C++, but I'm not sure which. Which one do you think > is a softer transition for a Python programmer? Which one do you think > will educate me the best? The movement from knowing no programming language to knowing one is invariably a much larger one than the shift from one to two (see http://en.wikipedia.org/wiki/Diminishing_returns). That is you are likely to get much less from this shift than what you got from python two years ago. So before you make this shift do ask yourself: have you got the best of what python has to offer? I taught python in the univ for a number of years and I would always tell my students that the library reference gave a better conspectus of modern day computer science/IT than anything else I knew of. [That not too many of them listened is another matter :-) ] Then python has a lot of advanced (new) stuff: generators and generator expressions, comprehensions, lambdas and functional programming, descriptors and protocols.... That said you can of course choose your second language to optimize your learning (where optimize could be minimize or maximize!) One language that is promising (and under active development) is curl. (http://www.curl.com) It is targeted to be like C++ in efficiency (native compiler not VM or interpreter) like C#/Java in its OOP with gc style like Javascript in supporting dynamic rich web apps in addition to replacing HTML From hank.infotec at gmail.com Sun Apr 20 08:46:37 2008 From: hank.infotec at gmail.com (Hank @ITGroup) Date: Sun, 20 Apr 2008 22:46:37 +1000 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> Message-ID: <480B3B2D.6040206@gmail.com> Apology for the previous offensive title~~ :) Thanks, Rintsch, Arnaud and Daniel, for replying so soon. I redid the experiment. What following is the record - ``starting python`` # == Windows Task Manager: Python.exe *4,076 *K memory-usage == >>> st1='abcdefg'*999999 # == 10,952 K == >>> del st1 # == *4,104*K == >>> st1='abcdefg'*999999 # == 10,952 K == >>> del st1 # == 4,104 K == >>> li = ['abcde']*999999 # == 8,024 K == >>> del li # == *4,108* K == >>> from nltk import FreqDist # == 17,596 == >>> fd = FreqDist() # == 17,596 == >>> for i in range(999999):fd.inc(i) # == 53,412 == >>> del fd # == *28,780* == >>> fd2 = FreqDist() # == 28,780 == >>> for i in range(999999):fd2.inc(i) # == 53,412 == >>> del fd2 # == 28,780 K == >>> def foo(): ... fd3 = FreqDist() ... for i in range(999999):fd3.inc(i) >>> foo() # == *28,788* K == >>> def bar(): ... fd4 = FreqDist() ... for i in range(999999):fd4.inc(i) ... del fd4 # == 28,788 K == >>> bar() # == 28,788 K == That is my question, after ``del``, sometimes the memory space returns back as nothing happened, sometimes not... ... What exactly was happening??? Best regards to all PYTHON people ~~ !!! Python Team are great !!! From rhamph at gmail.com Fri Apr 18 12:29:11 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Fri, 18 Apr 2008 09:29:11 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> <9140b6c2-fcf3-454f-a24e-0ed03b3b8e3b@k37g2000hsf.googlegroups.com> Message-ID: On Apr 18, 4:30 am, Nick Craig-Wood wrote: > Rhamphoryncus wrote: > > On Apr 17, 7:40 am, Steve Holden wrote: > > > I'd love to be wrong about that, but the GIL *has* been the subject of > > > extensive efforts to kill it over the last five years, and it has > > > survived despite the best efforts of the developers. > > > Yo. http://code.google.com/p/python-safethread/ > > Sounds very interesting. I particularly liked this bit from the web > page - an excellent solution to fine grained locking. Sending only > immutable objects between threads is very like the functional approach > used by Erlang which is extremely good at concurrency. Although superficially similar, the details of Erlang are actually pretty different. It copies all objects passed between threads - it was originally designed for fault tolerance (entire nodes going down), not concurrency. If you want a shared mutable object you need to use a "process" as one, treating it as an actor. Hopefully you can do most of it in a one-way, message driven style, as otherwise you're going to be transforming your synchronous calls into a series of callbacks. If you have a node farm, you want to upgrade it incrementally, and you want it to be fault tolerant (nodes go down at random without kill the whole thing), Erlang is much better than safethread. That's at a significant cost though, as it's only good at the one style. Safethread is much better at a style useful on a single desktop. From gagsl-py2 at yahoo.com.ar Mon Apr 28 02:45:12 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 28 Apr 2008 03:45:12 -0300 Subject: learning with python question (HtTLaPP) References: <98acecbd-9de2-4ebf-927b-ac6bc1fbc3fd@b5g2000pri.googlegroups.com> <53d6254f-895f-48fb-8ab9-3929c403f11b@v23g2000pro.googlegroups.com> Message-ID: En Sat, 26 Apr 2008 20:50:57 -0300, escribi?: > ok.. I finally made something that works.. Please let me know what you > think: > >>>> def lines(letters): > fin = open('words.txt') > count = 0 > rescount = 0 # count the number of results > results = "" # there are words that contain the letters > for line in fin: > needs = 0 > x = str(line.strip()) > for ch in letters: > if ch not in x: > pass > else: > needs = needs + 1 > if needs == len(letters): > rescount += 1 > results = results + '\n' + x > count += 1 > print count, 'lines searched' > print results, '\n' > print 'result count is: ', rescount That's pretty good. Some improvements: - The "natural" way to collect the results is using a list, appending words to it. Later you can print it one word per line or in any other format you want. Also, we don't need the "rescount" variable: it's just the length of the list. > needs = 0 > for ch in letters: > if ch not in x: > pass > else: > needs = needs + 1 > if needs == len(letters): The overall idea is to test whether ALL letters are in the word `x`, ok? So as soon as we find a letter that isn't in the word, we are sure the test failed and we can break out of the loop. And if we get up to the last step, that means that all the letters were in the word (else we would not have got so far). So we don't have to count the letters; instead, we can use the "else" clause of the for loop (it means "the loop was exhausted completely".) - I don't like the names "x" nor "ch"; I'm using "word" and "letter" instead. This is the revised version: def lines(letters): fin = open('words.txt') count = 0 results = [] # there are words that contain the letters for line in fin: word = line.strip() for letter in letters: if letter not in x: break else: results.append(word) count += 1 print count, 'lines searched' print '\n'.join(results), '\n' print 'result count is: ', len(results) That "\n".join(...) means "concatenate all the items in the list using \n as a separator between items" and it's a pretty common idiom in Python. -- Gabriel Genellina From kveretennicov at gmail.com Sat Apr 5 09:17:36 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Sat, 5 Apr 2008 16:17:36 +0300 Subject: UML reverse engineering In-Reply-To: <6712345.1824821207324312295.JavaMail.servlet@kundenserver> References: <6712345.1824821207324312295.JavaMail.servlet@kundenserver> Message-ID: <4660fe300804050617k28769016k4687246349352cdc@mail.gmail.com> On Fri, Apr 4, 2008 at 6:51 PM, wrote: > Hello, > > Do you know a free software witch can compute a UML class diagram from a > python code. I tested many free UML softwares like BoUML, ArgoUML, Dia, > PNSource (not found) ... Did you mean /PyNSource/ ? (http://www.atug.com/andypatterns/pynsource.htm) -- kv From bob at passcal.nmt.edu Mon Apr 21 19:06:39 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Mon, 21 Apr 2008 17:06:39 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> <2008042115060816807-bob@passcalnmtedu> <2008042116511375249-bob@passcalnmtedu> Message-ID: <2008042117063950073-bob@passcalnmtedu> On 2008-04-21 16:51:13 -0600, Bob Greschke said: JUST COMPLETELY IGNORE THAT LAST ONE. What a dope. Here: #! /usr/bin/env python from os import system from struct import unpack print "unpack 1" system("date") for x in xrange(0, 100000000): Value = unpack(">B", "a")[0] if Value > 0x800000: Value -= 0x1000000 system("date") print print "ord 1" system("date") for x in xrange(0, 100000000): Value = ord("a") if Value > 0x800000: Value -= 0x1000000 system("date") print print "unpack 3" system("date") for x in xrange(0, 100000000): Value1, Value2, Value3 = unpack(">BBB", "abc") Value = (Value1 << 16)+(Value2 << 8)+Value3 if Value > 0x800000: Value -= 0x1000000 system("date") print print "ord 3" system("date") for x in xrange(0, 100000000): Value = (ord("a") << 16)+(ord("b") << 8)+ord("c") if Value > 0x800000: Value -= 0x1000000 system("date") Still, the differences between unpack and ord are significant (I just threw in the if's for fun). From nick at stinemates.org Fri Apr 18 15:03:26 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 12:03:26 -0700 Subject: How to have unittest tests to be executed in the order they appear? In-Reply-To: <20080415151439.7065a31a.darcy@druid.net> References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> <20080415151439.7065a31a.darcy@druid.net> Message-ID: <20080418190326.GH19281@deviL> On Tue, Apr 15, 2008 at 03:14:39PM -0400, D'Arcy J.M. Cain wrote: > > However, do consider writing your tests so that order is irrelevant. > If a test depends on a previous test running then it isn't a proprt > self-contained test. For one thing, you can't run a single test that > way if you wanted to. > Agreed! -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From wwzaygvm at gmail.com Wed Apr 16 16:55:21 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 13:55:21 -0700 (PDT) Subject: windows live onecare keygen Message-ID: <1cb70d69-7794-40a9-abea-250c356657a7@p25g2000pri.googlegroups.com> windows live onecare keygen http://cracks.12w.net F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Tue Apr 8 01:12:01 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 08 Apr 2008 02:12:01 -0300 Subject: Newbie: How to pass a dictionary to a function? References: <516e07d1-91f9-462b-9fc0-ac6d1e474f9d@n14g2000pri.googlegroups.com> Message-ID: En Tue, 08 Apr 2008 00:54:09 -0300, BonusOnus escribi?: > How do I pass a dictionary to a function as an argument? The indentation is lost, so it's not easy to check your program. > # Say I have a function foo... Original: def foo(arg=[]). An empty list isn't a good default value here, perhaps you intended to use {}? Anyway, don't use mutable default values; see this FAQ entry: http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects def foo(arg): x = arg['name'] y = arg['len'] s = len(x) t = s + y return s, t # don't use dict as a variable name, you're hiding the builtin dict type my_dict = {} my_dict['name'] = 'Joe Shmoe' my_dict['len'] = 44 # don't use len as a name either # nor string! length, string = foo(my_dict) > # This bombs with 'TypeError: unpack non-sequence' > What am I doing wrong with the dictionary? Nothing. Written as above, it works fine. Don't retype your programs, always copy & paste from the same source you're executing. If you get an exception, post the entire traceback with the exact exception name and message. -- Gabriel Genellina From Robert.Bossy at jouy.inra.fr Thu Apr 24 04:24:37 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Thu, 24 Apr 2008 10:24:37 +0200 Subject: annoying dictionary problem, non-existing keys In-Reply-To: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> Message-ID: <481043C5.20409@jouy.inra.fr> bvidinli wrote: > i use dictionaries to hold some config data, > such as: > > conf={'key1':'value1','key2':'value2'} > and so on... > > when i try to process conf, i have to code every time like: > if conf.has_key('key1'): > if conf['key1']<>'': > other commands.... > > > this is very annoying. > in php, i was able to code only like: > if conf['key1']=='someth' > > in python, this fails, because, if key1 does not exists, it raises an exception. > > MY question: > is there a way to directly get value of an array/tuple/dict item by key, > as in php above, even if key may not exist, i should not check if key exist, > i should only use it, if it does not exist, it may return only empty, > just as in php.... > > i hope you understand my question... > If I understand correctly you want default values for non-existing keys. There are two ways for achieving this: Way 1: use the get() method of the dict object: conf.get(key, default) which is the same as: conf[key] if key in conf else default Way 2: make conf a defaultdict instead of a dict, the documentation is there: http://docs.python.org/lib/defaultdict-objects.html Hope this helps, RB From martin at v.loewis.de Tue Apr 22 01:03:53 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 22 Apr 2008 07:03:53 +0200 Subject: py3k concerns. An example In-Reply-To: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: <480D71B9.40909@v.loewis.de> > In py3k string%dictionary is going away. Why do you say that? It's not going away in Python 3.0. Regards, Martin From rridge at caffeine.csclub.uwaterloo.ca Fri Apr 11 23:18:04 2008 From: rridge at caffeine.csclub.uwaterloo.ca (Ross Ridge) Date: Fri, 11 Apr 2008 23:18:04 -0400 Subject: Windows - window status (Running vs Not Responding) References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> Message-ID: rdahlstrom wrote: >Basically, I'm looking for something similar to the Process.Responding >property in System.Diagnostics... You probably want to use IsHungAppWindow(): IsHungAppWindow Function You call the IsHungAppWindow function to determine if Microsoft Windows considers that a specified application is not responding. An application is considered to be not responding if it is not waiting for input, is not in startup processing, and has not called PeekMessage within the internal timeout period of 5 seconds. Syntax BOOL IsHungAppWindow( HWND hWnd ); ... You can use EnumWindows() to enumerate the all the top level windows. Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] rridge at csclub.uwaterloo.ca -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // From maxerickson at gmail.com Sat Apr 12 08:35:24 2008 From: maxerickson at gmail.com (Max Erickson) Date: Sat, 12 Apr 2008 12:35:24 +0000 (UTC) Subject: [ANN]: Python-by-Example updates References: <48000796$0$30160$4c368faf@roadrunner.com> Message-ID: AK wrote: > Python-by-Example is a guide to LibRef, aiming to give examples > for all functions, classes, modules, etc. Right now examples > for functions in some of the most important modules are > included. > > http://pbe.lightbird.net/ > > thanks, > The second set of examples on the page for decimal doesn't look quite right. The first couple of lines: getcontext().prec = 6 # Decimal('3.0') Decimal("3.0") # Decimal('3.1415926535') I would assume that the " = 6" isn't getting processed correctly. max From roger.dahlstrom at gmail.com Tue Apr 1 06:52:27 2008 From: roger.dahlstrom at gmail.com (rdahlstrom) Date: Tue, 1 Apr 2008 03:52:27 -0700 (PDT) Subject: CTypes, 64 bit windows, 32 bit dll References: <5a0d8c47-f1b7-4eae-9911-b312a1166757@d1g2000hsg.googlegroups.com> <5uj3v39d6e4ok6o7qda4vagfg4h68kv4th@4ax.com> Message-ID: <1cb61f8f-1caf-460e-89a3-c5f202e3179c@59g2000hsb.googlegroups.com> On Apr 1, 2:03 am, Tim Roberts wrote: > rdahlstrom wrote: > >On Mar 31, 12:53 pm, "mimi.vx" wrote: > >> On Mar 31, 4:22 pm, rdahlstrom wrote: > > >> > So I have a 64 bit Windows 2003 system, running python 2.5.1.1. > > >> > I can import a Windows .dll (msvcrt or whatever) using ctypes, but > >> > when attempting to import another application-specific .dll (tibrv.dll > >> > if anyone is familiar with it), I receive the error WindowsError: > >> > [Error 193] %1 is not a valid Win32 application. > > >> > I know there's a Windows on Windows (wow) which allows 32 bit > >> > processes to run on 64 bit windows - is there a way to work this in > >> > somehow? Maybe I'm barking up the wrong tree? > >>... > > >> all dlls and python must be 32bit or 64bit, no mixed ... > > >Crap, no way to make a 32 bit load, even using the wowexec? > > No. In Win64, a process is either entirely 32-bit, or entirely 64-bit. To > do the kind of crossing you seek, you would need to create a separate > process for the 32-bit DLL and use interprocess communication. > -- > Tim Roberts, t... at probo.com > Providenza & Boekelheide, Inc. Shoot. Alright, thanks for your help. I guess I'll have to roll out a 64-bit version of the tibco software. From deets at nospam.web.de Thu Apr 17 10:08:45 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 17 Apr 2008 16:08:45 +0200 Subject: why function got dictionary References: <48075950.7050000@gmail.com> Message-ID: <66p409F2lg89hU1@mid.uni-berlin.de> AlFire wrote: > Hi, > > I am seeking an explanation for following: > > Python 2.5.2 (r252:60911, Apr 8 2008, 21:49:41) > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> def g(): return > ... > >>> g.__dict__ > {} > > Q: why function got dictionary? What it is used for? because it is an object, and you can do e.g. g.exposed = True or similar stuff. Diez From sjmachin at lexicon.net Sat Apr 5 20:12:55 2008 From: sjmachin at lexicon.net (John Machin) Date: Sat, 5 Apr 2008 17:12:55 -0700 (PDT) Subject: while-loops enter the last time after condition is filled? References: Message-ID: On Apr 6, 9:53 am, skanem... at yahoo.se wrote: > it seems to me from my results that when i use a while-loop it will > execute once after the condition is met. > > ie the conditions is met the code executes one time more and then > quits. The syntax is this: while condition: do_something() Do you mean that it executes do_something() only once, but you expect it to execute more that once? Or should we interpret your seemingly inconsistent statement by changing "condition(s) is met" to "condition(s) is NOT met" -- in other words, it is executing one EXTRA time after you expect it to have stopped? Perhaps you should supply a short example of runnable code (including print statements to show what is happening), the actual output that you got when you ran that code, and what was the output that you expected. From zillow10 at googlemail.com Thu Apr 3 18:30:44 2008 From: zillow10 at googlemail.com (zillow10 at googlemail.com) Date: Thu, 3 Apr 2008 15:30:44 -0700 (PDT) Subject: id functions of ints, floats and strings References: Message-ID: On Apr 3, 11:27 pm, zillo... at googlemail.com wrote: > Hi all, > > I've been playing around with the identity function id() for different > types of objects, and I think I understand its behaviour when it comes > to objects like lists and tuples in which case an assignment r2 = r1 > (r1 refers to an existing object) creates an alias r2 that refers to > the same object as r1. In this case id(r1) == id(r2) (or, if you > like: r1 is r2). However for r1, r2 assigned as follows: r1 = [1, 2, > 3] and r2 = [1, 2, 3], (r1 is r2) is False, even if r1==r2, > etc. ...this is all very well. Therefore, it seems that id(r) can be > interpreted as the address of the object that 'r' refers to. > > My observations of its behaviour when comparing ints, floats and > strings have raised some questions in my mind, though. Consider the > following examples: > > ######################################################################### > > # (1) turns out to be true > a = 10 > b = 10 > print a is b > > # (2) turns out to be false > f = 10.0 > g = 10.0 > print f is g > > # behaviour when a list or tuple contains the same elements ("same" > meaning same type and value): > > # define the following function, that checks if all the elements in an > iterable object are equal: > > def areAllElementsEqual(iterable): > return reduce(lambda x, y: x == y and x, iterable) != False > > # (3) checking if ids of all list elements are the same for different > cases: > > a = 3*[1]; areAllElementsEqual([id(i) for i in a]) # True > b = [1, 1, 1]; areAllElementsEqual([id(i) for i in b]) # True > f = 3*[1.0]; areAllElementsEqual([id(i) for i in f]) # True > g = [1.0, 1.0, 1.0]; areAllElementsEqual([id(i) for i in g]) # True > g1 = [1.0, 1.0, 0.5+0.5]; areAllElementsEqual([id(i) for i in g1]) # > False > > # (4) two equal floats defined inside a function body behave > differently than case (1): > > def func(): > f = 10.0 > g = 10.0 > return f is g > > print func() # True > > ###################################################### > > I didn't mention any examples with strings; they behaved like ints > with respect to their id properties for all the cases I tried. > While I have no particular qualms about the behaviour, I have the > following questions: > > 1) Which of the above behaviours are reliable? For example, does a1 = > a2 for ints and strings always imply that a1 is a2? > 2) From the programmer's perspective, are ids of ints, floats and > string of any practical significance at all (since these types are > immutable)? > 3) Does the behaviour of ids for lists and tuples of the same element > (of type int, string and sometimes even float), imply that the tuple a > = (1,) takes (nearly) the same storage space as a = 10000*(1,)? (What > about a list, where elements can be changed at will?) > > Would appreciate your responses... > > AK Question 1 should read "For example, does a1 == a2 for ints ..." From namesagame-usenet at yahoo.com Wed Apr 30 14:06:13 2008 From: namesagame-usenet at yahoo.com (gamename) Date: Wed, 30 Apr 2008 11:06:13 -0700 (PDT) Subject: Sending Cntrl-C ?? References: <0274834e-17e1-4a95-88ec-f2aa77aeb3a9@k10g2000prm.googlegroups.com> Message-ID: <8d53535b-b00e-40b4-b65f-1ca126884592@k10g2000prm.googlegroups.com> > win32api.GenerateConsoleCtrlEvent(win32con.CTRL_C_EVENT, pgid) How do you determine the value of 'pgid'? From sales024 at aaa-replica-watch.com Tue Apr 1 00:45:19 2008 From: sales024 at aaa-replica-watch.com (sales024 at aaa-replica-watch.com) Date: Mon, 31 Mar 2008 21:45:19 -0700 (PDT) Subject: Cheap Chopard Happy Diamonds Watches Replica - Chopard Watches Wholesale Message-ID: <1bb1da1f-e53b-4eec-afdb-bcd05e43c706@e6g2000prf.googlegroups.com> Cheap Chopard Happy Diamonds Watches Replica - Chopard Watches Wholesale AAA Replica Watches : http://www.watches-replicas.com Chopard Watches Brands : http://www.watches-replicas.com/chopard-watches.html Replica Chopard Happy Diamonds Watches : http://www.watches-replicas.com/chopard-happy-diamonds-watches.html China largest replica watches wholesaler, wholesale up to 80% of Chopard Happy Diamonds Replica Watches and Chopard Happy Diamonds Fake Watch. The most famous Swiss brand name watches you can find, replica Chopard Happy Diamonds Watches and fake Chopard Happy Diamonds Watches are also available. All our Chopard Happy Diamonds Watches replicas are crafted in high quality, You will get great profite by ordering our good cheap watches. Chopard Happy Diamonds Watches All Products : Chopard Happy Diamonds Ladies Watch 20/7469 RG MOP Tan : http://www.watches-replicas.com/Chopard-Ladies-Watch-20-7469-RGMOPTan-2314.html Chopard Happy Diamonds Ladies Watch 20/7450-20 : http://www.watches-replicas.com/chopard-happy-diamonds-watch-20-7450-20-2315.html The Same Chopard Replica Watches Series : Chopard Happy Sport Watches : http://www.watches-replicas.com/chopard-happy-sport-watches.html Chopard Happy Beach and Happy Fish Watches : http://www.watches-replicas.com/chopard-happy-beach-and-happy-fish-watches.html Chopard Mille Miglia Watches : http://www.watches-replicas.com/chopard-mille-miglia-watches.html Chopard Happy Snowflake Watches : http://www.watches-replicas.com/chopard-happy-snowflake-watches.html Chopard Imperiale Watches : http://www.watches-replicas.com/chopard-imperiale-watches.html Chopard La Strada Watches : http://www.watches-replicas.com/chopard-la-strada-watches.html Chopard Happy Sport Good Luck Clover Watches : http://www.watches-replicas.com/chopard-happy-sport-good-luck-clover-watches.html Chopard LUC Watches : http://www.watches-replicas.com/chopard-luc-watches.html Chopard H Watches : http://www.watches-replicas.com/chopard-h-watches.html Chopard Happy Spirit Watches : http://www.watches-replicas.com/chopard-happy-spirit-watches.html Chopard Happy Diamonds Watches : http://www.watches-replicas.com/chopard-happy-diamonds-watches.html Chopard Ice Cube Watches : http://www.watches-replicas.com/chopard-ice-cube-watches.html Other Chopard Watches : http://www.watches-replicas.com/other-chopard-watches.html Chopard Happy Sport Happy Hearts Watches : http://www.watches-replicas.com/chopard-happy-sport-happy-hearts-watches.html From bignose+hates-spam at benfinney.id.au Tue Apr 15 19:18:30 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Wed, 16 Apr 2008 09:18:30 +1000 Subject: Testing for callable or iterable (was: Recurring patterns: Am I missing it, or can we get these added to the language?) References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: <874pa2906x.fsf@benfinney.id.au> Erich writes: > def iterable(item, count_str=False): > if not count_str and isinstance(item, str): > return False > try: > iter(item) > except: > return False > return True > This is just simple boolean test for whether or not an object is > iterable. I would like to see this in builtins, to mirror callable. Note that 'callable' is being removed in Python 3.0 . To mirror this, I recommend you remove usage of your 'iterable' function too :-) Seriously, the Pythonic way to handle this is to examine *why* you need to know whether an object is iterable. The only reason I can think of that makes any sense is that you're going to actually iterate over it at some point. In which case, you should omit this 'iterable' check and just iterate over the object when you need to. Python will raise the appropriate exception when it doesn't behave as you expect. No need to LBYL, when Python will tell you about the problem at the time you need to know. Or, you could use the equivalent of the suggestion in PEP 3100: just use 'hasattr(obj, "__iter__")'. But this is inferior to just following EAFP. -- \ "I hope if dogs ever take over the world, and they chose a | `\ king, they don't just go by size, because I bet there are some | _o__) Chihuahuas with some good ideas." -- Jack Handey | Ben Finney From stefan_ml at behnel.de Tue Apr 29 02:14:44 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 29 Apr 2008 08:14:44 +0200 Subject: Sphinx 0.2 released In-Reply-To: References: Message-ID: <4816BCD4.5050600@behnel.de> Hi Georg, Georg Brandl wrote: > I'm pleased to announce the release 0.2 of Sphinx, the Python documentation > generation tool. There were some intermediate smaller releases in the 0.1 > series, but for 0.2 there are quite a lot new features and fixes. > > What is it? > =========== > > Sphinx is a tool that makes it easy to create intelligent and beautiful > documentation for Python projects (or other documents consisting of > multiple reStructuredText source files). I'm wondering, would there be any way to bridge to epydoc? It would be cool to have the two integrated so that you could generate API docs and written docs in one step, with the same look-and-feel. (BTW: yes, I'm advocating not to implement another API documentation tool, but to integrate with an existing one. I would think epydoc matches the requirements quite well here). Stefan From davecook at nowhere.net Thu Apr 10 05:54:03 2008 From: davecook at nowhere.net (David Cook) Date: Thu, 10 Apr 2008 09:54:03 GMT Subject: How is GUI programming in Python? References: Message-ID: <%slLj.46543$f8.32888@newsfe23.lga> On 2008-04-10, Chris Stewart wrote: > I've always had an interest in Python and would like to dabble in it > further. I've worked on a few very small command line programs but > nothing of any complexity. I'd like to build a really simple GUI app > that will work across Mac, Windows, and Linux. How painful is that > going to be? With wxpython and pyqt, it can be relatively painless. You can often just copy your code directly from one OS to the other and run it, and py2exe makes it easy to distribute python apps to windows users. I haven't tried packaging on OS X (with py2app?). > I used to be really familiar with Java Swing a few years > ago. I imagine it will be similar. Yes, the broad principles (event driven, single-threaded event loop) are pretty much the same. Note, if you really like Swing, you can use it from Jython. Your app would install and look like any other Java app to users (Jython is just another jar in your distribution), for good or ill. > Next, what would you say is the best framework I should look into? > I'm curious to hear opinions on that. We use wxPython at work because of the more liberal license. It's very capable and works well for us. However, for my own projects, I've switched to pyqt, which offers more complete application help (e.g. things like Actions) and uses MVC from the ground up rather than as an afterthought. I also find the pyqt API cleaner and more consistent; some aspects of wxpython still seem clunky to me. And the auto-completion solution offered on the wxPython wiki doesn't work on Mac, which pretty much killed it for my project. Dave Cook From bdsatish at gmail.com Thu Apr 24 07:13:49 2008 From: bdsatish at gmail.com (bdsatish) Date: Thu, 24 Apr 2008 04:13:49 -0700 (PDT) Subject: restructured text in python Message-ID: <807d9398-0099-4eee-b0a2-5cb0fbff2124@s33g2000pri.googlegroups.com> Hi all, I have a python prog: #!/usr/bin/env """ Author: BDS Version: 1.0 """ def Hello(): """ Prints a Hello World to the screen""" print "Hello, World" if __name__ == "__main__": Hello() I want to use ReSt (reStructuredText) in my docstrings or comments. Any example of how to do it, w.r.t. above code ? Also how to invoke rst on the Python code to do the processing ? I know how to write in RST but I want to know how to process the resulting Python code From c.boulanger at qxtransformer.org Tue Apr 29 14:30:23 2008 From: c.boulanger at qxtransformer.org (Panyasan) Date: Tue, 29 Apr 2008 11:30:23 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <473deef3-9acb-45dd-a7ca-47b0081bd28c@i36g2000prf.googlegroups.com> <3f7bb91e-335e-46bd-88ca-f15b26c35132@k1g2000prb.googlegroups.com> <827bdae6-4422-4226-a543-af53f5b7e01b@s33g2000pri.googlegroups.com> <083b58e8-522a-4c01-b612-c592fe69fcd1@i36g2000prf.googlegroups.com> Message-ID: <2978ec5b-fd7c-4fb1-9aa5-4bb88ba46ee8@m73g2000hsh.googlegroups.com> On 29 Apr., 18:17, John Henry wrote: > > There are a whole bunch of test programs that comes with Pythoncard. > Do they work? (Not all of them will work - some requires a database) Yes, the examples work. Just the resourceEditor.py and the layoutEditor.py in the distributed version and your modified layoutEditor.py don't. From tatu.kairi at gmail.com Wed Apr 2 08:58:17 2008 From: tatu.kairi at gmail.com (tatu.kairi at gmail.com) Date: Wed, 2 Apr 2008 05:58:17 -0700 (PDT) Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: <76c1d6f1-acfc-4464-9bb7-63c3bae0275e@q27g2000prf.googlegroups.com> On Apr 2, 2:43 pm, GHUM wrote: > Tobu, > > I like this idea. Deducting from an example is really another way to > wisdom. > > What struck me as most diffuclt to understand: > > abs(-5.5) - 5.5 > > -> you are using "-" as symbol for "will give the result", which is > really, really hard to parse. Take something else, please. Unicode has > THAT many cool symbols. Or just -> or -=> or whatever. > > Thanks for sharing that work! > > Harald Or just use comments to indicate text that tells what the code does. I too agree you need to change the '-'. From txtoth at gmail.com Thu Apr 24 15:14:32 2008 From: txtoth at gmail.com (Xavier Toth) Date: Thu, 24 Apr 2008 14:14:32 -0500 Subject: where can I find gdkimlib (imlib bindings)? Message-ID: I'm trying to get some old code that imported GdkImlib to work but I can't find these a current version of these binding, anyone know where they are? -------------- next part -------------- An HTML attachment was scrubbed... URL: From jura.grozni at gmail.com Tue Apr 22 07:53:38 2008 From: jura.grozni at gmail.com (azrael) Date: Tue, 22 Apr 2008 04:53:38 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> Which big aplications are written in python. I see its development, But i can't come up with a big name. I know that there are a lot of companys using python, but is there anythong big written only in python. I want him to fuck of with his perl once and for all time From srf99 at ferg.org Wed Apr 16 12:58:12 2008 From: srf99 at ferg.org (srf99 at ferg.org) Date: Wed, 16 Apr 2008 09:58:12 -0700 (PDT) Subject: question about setup.py and CC and LDSHARED env variables on Solaris Message-ID: Recently I was trying to compile/install cx_Oracle on our Solaris system. When I ran "python setup.py build" I got the following message: "/usr/ucb/cc: language optional software package not installed" I Googled around and discovered that this is a frequently-encountered issue on Solaris systems, because Solaris systems don't have the Solaris C compiler installed by default. (We certainly don't. We use gcc instead.) After poking around in the source code for distutils, I figured out that I could get setup.py to work if -- *before* running setup.py -- I set two environment variables: export CC=gcc export LDSHARED="gcc -G" Afterward, in searching the Web, I couldn't find any documentation to tell me that I had to do this, or why, or when. So my question is: Does anyone know the location of documentation (about distutils, or about using setup.py) that tells you - that you have to do this, - why you have to do it, - the circumstances under which you have to do it? I'm a Unix newbie, so I may very well have missed something obvious. Thanks in advance, -- Steve Ferg From carsten.haese at gmail.com Fri Apr 25 20:40:55 2008 From: carsten.haese at gmail.com (Carsten Haese) Date: Fri, 25 Apr 2008 20:40:55 -0400 Subject: multiple pattern regular expression In-Reply-To: References: <1209131456.20871.1249849011@webmail.messagingengine.com> Message-ID: Nick Stinemates wrote: > On Fri, Apr 25, 2008 at 09:50:56AM -0400, python at bdurham.com wrote: >> How about this? >> >> for line in file: >> # ignore lines without = assignment >> if '=' in line: >> property, value = line.strip().split( '=', 1 ) >> property = property.strip().lower() >> value = value.strip() >> >> # do something with property, value >> >> Malcolm > > This works until you have: > string=The sum of 2+2=4 Actually, it still works, because Malcolm used split()'s maxsplit parameter. -- Carsten Haese http://informixdb.sourceforge.net From sturlamolden at yahoo.no Sat Apr 12 13:00:07 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sat, 12 Apr 2008 10:00:07 -0700 (PDT) Subject: Multiple independent Python interpreters in a C/C++ program? References: Message-ID: <88e07a03-afd4-451e-b815-925a9aa7bc6c@b9g2000prh.googlegroups.com> On Apr 11, 6:24 pm, s... at pobox.com wrote: > Do I wind up with two completely independent interpreters, one per thread? > I'm thinking this doesn't work (there are bits which aren't thread-safe and > are only protected by the GIL), but wanted to double-check to be sure. You can create a new interpreter with a call to Py_NewInterpreter. However, the GIL is a global object for the process. If you have more than two interpreters in the process, they share the same GIL. In tcl, each thread has its own interpreter instance and no GIL is shared. This circumvents most of the problems with a global GIL. In theory, a GIL private to each interpreter would make Python more scalable. The current GIL behaves like the BKL in earlier Linux kernels. However, some third-party software, notably Apache's mod_python, is claimed to depend on this behaviour. From goon12 at gmail.com Tue Apr 29 14:26:19 2008 From: goon12 at gmail.com (Joe Riopel) Date: Tue, 29 Apr 2008 14:26:19 -0400 Subject: Colors for Rows In-Reply-To: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> Message-ID: <6a2ccd190804291126s591e6813y61a23b2f63b2500e@mail.gmail.com> On Tue, Apr 29, 2008 at 10:33 AM, Victor Subervi wrote: > Hi; > > > why doesn't this work? > It never increments z! Yet, if I print z, it will increment and change the > bgcolor! Why?! Are you only trying to "print '\n' % bg" once, or for each iteration of the loop? It might have been the way your message was formatted, but the try/except look like it's out of the for loop. So the print will only run once, after the loop has gone through all d's in id. From arnlen at mac.com Wed Apr 16 09:31:04 2008 From: arnlen at mac.com (Jumping Arne) Date: Wed, 16 Apr 2008 15:31:04 +0200 Subject: Image handling - stupid question References: <0001HW.C42B9FB90009B7E8B01AD9AF@news.individual.de> Message-ID: <0001HW.C42BCC38001425DCB04379AF@news.individual.de> On Wed, 16 Apr 2008 12:21:13 +0200, Jumping Arne wrote (in article <0001HW.C42B9FB90009B7E8B01AD9AF at news.individual.de>): > I'm going to try to write some imange manipulation code (scaling, reading > EXIF and IPTC info) and just want to ask if PIL is *THE* library to use? > > I looked at and noticed that the > latest version is from Dec 2006. > > In my experience that means that either it's abandoned or that it's very good > and stable. > Sounds like PIL is a safe option, thanks. From maxm at mxm.dk Tue Apr 29 09:17:01 2008 From: maxm at mxm.dk (Max M) Date: Tue, 29 Apr 2008 15:17:01 +0200 Subject: Given a string - execute a function by the same name In-Reply-To: <1209471041.12820.1250459017@webmail.messagingengine.com> References: <1209471041.12820.1250459017@webmail.messagingengine.com> Message-ID: <48171FCD.90902@mxm.dk> python at bdurham.com skrev: > Bruno, > But when I release into production I'm going to shift to #3: "Place all > my functions in dictionary and lookup the function to be called". This > technique will allow me to precisely control the dynamic nature of my > application. Just one tiny note: What you will be doing is a variation of the factory pattern. So this search might give you some new ideas: http://www.google.dk/search?hl=en&q=python+factory+pattern -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science From http Thu Apr 17 03:41:33 2008 From: http (Paul Rubin) Date: 17 Apr 2008 00:41:33 -0700 Subject: sampling without replacement References: <6017ea8d-6ee8-44ea-bdad-bf06299a9cd5@a23g2000hsc.googlegroups.com> Message-ID: <7xwsmxudw2.fsf@ruckus.brouhaha.com> braver writes: > Using an array is natural here as it represents "without replacement" > -- we take an element by removing it from the array. But in Python > it's very slow... What approaches are there to implement a shrinking > array with random deletions with the magnitude of millions of > elements? The obvious way is use random.sample(), is there some reason you don't do that? Alternatively, when you select an element a[k] from the middle of the array, instead of deleting that element and moving the rest down (del a[k]), do something like: k = random.randint(0,len(a)-1) selection = a[k] a[k] = a[-1] a.pop() That deletes the last element (avoiding moving them around) after storing it in the newly freed slot. Of course it messes up the order of the array, which won't matter for selecting random elements, but might matter for some other reason in your program. From weiss02121 at gmail.com Tue Apr 15 19:47:26 2008 From: weiss02121 at gmail.com (weiss02121 at gmail.com) Date: Tue, 15 Apr 2008 16:47:26 -0700 (PDT) Subject: lindsay lohan com Message-ID: Just few link on some Lindsay Lohan Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From ewertman at gmail.com Tue Apr 29 22:20:44 2008 From: ewertman at gmail.com (Eric Wertman) Date: Tue, 29 Apr 2008 22:20:44 -0400 Subject: ssh In-Reply-To: <867f5bc7-3748-4303-9f29-9d8044f0d315@m3g2000hsc.googlegroups.com> References: <867f5bc7-3748-4303-9f29-9d8044f0d315@m3g2000hsc.googlegroups.com> Message-ID: <92da89760804291920v79f503b6h7dcdf1de7a8db204@mail.gmail.com> I don't know about the best way.. I use this function, it works ok for me. I have an ssh key stashed already for my user ID, but you could look at the ssh options and supply one on the command line if you needed to. from popen2 import Popen3 def ssh(host,command) : ''' Wraps ssh commands ''' ssh_exec = ['/usr/bin/ssh -qnx -F ssh_config', host, command] cmd = ' '.join(ssh_exec) output,errors,status = process(cmd) return output,errors,status def process(cmd) : proc = Popen3(cmd,-1) output = proc.fromchild.readlines() errors = proc.childerr.readlines() status = proc.poll() return output,errors,status I somtimes call ssh via a Thread object if I need to run a few at the same time. In regards to your question, fork() creates a complete copy of the running process, and returns a 0 in the child (copy). The parent gets the PID of the child as a return code. I don't think there's anything wrong with what you are doing though. I just found that the popen2 module was the easiest to deal with. subprocess is nice, if you have 2.5, but I have to keep 2.3 ish most of the time. The function above could theoretically block if the error pipe gets full before I get to reading it. I can't recall ever getting that much back on stderr though.. so I'm taking the chance. Eric On Tue, Apr 29, 2008 at 9:29 PM, gert wrote: > Is this the best way to use ssh ? > How can i use ssh keys instead of passwords ? > I dont understand what happens when pid does not equal 0 , where does > the cmd get executed when pid is not 0 ? > How do you close the connection ? > > # http://mail.python.org/pipermail/python-list/2002-July/155390.html > import os, time > > def ssh(user, rhost, pw, cmd): > pid, fd = os.forkpty() > if pid == 0: > os.execv("/bin/ssh", ["/bin/ssh", "-l", user, rhost] + cmd) > else: > time.sleep(0.2) > os.read(fd, 1000) > time.sleep(0.2) > os.write(fd, pw + "\n") > time.sleep(0.2) > res = '' > s = os.read(fd, 1) > while s: > res += s > s = os.read(fd, 1) > return res > > print ssh('username', 'serverdomain.com', 'Password', ['ls -l']) > -- > http://mail.python.org/mailman/listinfo/python-list > From sturlamolden at yahoo.no Fri Apr 25 09:34:27 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 25 Apr 2008 06:34:27 -0700 (PDT) Subject: Remove multiple inheritance in Python 3000 References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <60fc4333-6d2b-40f5-b311-031d90a38d39@k37g2000hsf.googlegroups.com> <67dvlbF2nomm6U2@mid.individual.net> Message-ID: <1b19d810-3f47-434b-8935-17911b50bc14@f36g2000hsa.googlegroups.com> On Apr 25, 2:03 pm, Bjoern Schliessmann wrote: > > That's how the Java designers were thinking as well: If MI is > > allowed, programmers will suddenly get an irresistible urge to use > > MI to write unmaintainable spaghetti code. So let's disallow MI > > for the sake of common good. > > Argumenting like that, *all* programming languages had to be > outlawed. 8) James Gosling, grossed by C++ iostreams, also used this argument to disallow operator overloading in Java (except for the String class). That is why Python has NumPy and Java does not. From pavlovevidence at gmail.com Tue Apr 29 16:10:03 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 29 Apr 2008 13:10:03 -0700 (PDT) Subject: list.reverse() References: <4816e26a$0$30938$426a74cc@news.free.fr> Message-ID: <1def8a8f-a50d-424e-9e2a-da517b9891af@34g2000hsh.googlegroups.com> On Apr 29, 9:32 am, Roy Smith wrote: > The reasoning goes along the lines of, "reverse in place is an expensive > operation, so we don't want to make it too easy for people to do". At > least that's the gist of what I got out of the argument the many times it > has come up. Except reversing a list in place isn't expensive at all. I assume you meant "reverse NOT in-place". You're pretty much right but you're missing a step. That an in-place operation is cheaper is the main reason why reverse is destructive, that is true. But it returns None mostly to avoid confusing the user, who is likely to assume that the operation is non-destructive (or forget that it isn't). Carl Banks From deets at nospam.web.de Thu Apr 3 14:28:33 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 03 Apr 2008 20:28:33 +0200 Subject: splitting an XML file on the basis on basis of XML tags In-Reply-To: References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> Message-ID: <65klukF2fp6mkU1@mid.uni-berlin.de> > I abuse it because I can (and because I don't generally work with XML > files larger than 20-30meg) :) > And the OP never said the XML file for 1TB in size, which makes things > different. Even with small xml-files your advice was not very sound. Yes, it's tempting to use regexes to process xml. But usually one falls flat on his face soon - because of whitespace or attribute order or versus or .. or .. or. Use an XML-parser. That's what they are for. And especially with the pythonic ones like element-tree (and the compatible lxml), its even more straight-forward than using rexes. Diez From jason.scheirer at gmail.com Wed Apr 23 21:06:53 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Wed, 23 Apr 2008 18:06:53 -0700 (PDT) Subject: python-ldap - Operations Error References: Message-ID: <8b35f293-fc64-4d21-a621-124c8eafde59@c65g2000hsa.googlegroups.com> On Apr 23, 5:16?pm, theivi... at gmail.com wrote: > Hello all, I am trying to integrate TurboGears with our Active > Directory here at the office. ?TurboGears aside, i cannot get this to > work. ?The simplest thing i can do to test this is: > > >>> import ldap > >>> l = ldap.initialize("ldap://server.net") > >>> l.simple_bind(DN, "secret") > 1 > >>> l.result(1) > (97, []) > >>> l.search("dc=server,dc=net", ldap.SCOPE_SUBTREE, "(sAMAccountName=user)") > > OPERATIONS_ERROR: {'info': '00000000: LdapErr: DSID-0C090627, comment: > In order to perform this operation a successful bind must be completed > on the connection., data 0, vece', 'desc': 'Operations error'} > > The simple bind works fine and returns a result, when i get the > result, it returns 97 meaning successful. ?So there was a successful > bind on the connection, right? ?I'm really not sure where the problems > lies. ?Is it with the way im connecting or is it something to do with > our AD server? > > Thanks Seems more promising: http://tgolden.sc.sabren.com/python/active_directory.html Also, same problem: http://groups.google.com/group/turbogears/browse_thread/thread/10fcd1f9e920d0a8 Also: http://peeved.org/blog/2007/11/20/ Google is pretty awesome when you paste in literal error strings. From aaron.watters at gmail.com Wed Apr 16 12:09:05 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 16 Apr 2008 09:09:05 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <86063f29-21a8-4d5b-a374-cee0723e0852@a22g2000hsc.googlegroups.com> Message-ID: <6894d371-3c3e-4c24-b7ec-4c254ed24afe@24g2000hsh.googlegroups.com> On Apr 16, 11:15 am, Gabriel Genellina wrote: > On 16 abr, 09:56, Aaron Watters wrote: > > > In my opinion python's adherence to backwards compatibility > > has been a bit mythological anyway -- many new python versions > > have broken my old code for no good reason. This is an irritant > > when you have thousands of users out there who suddenly drop > > your code, blame you and python, and move on to use something else. > > Honestly, how hard would it have been to provide standard backwards > > support for the old regex module as a standard module which simply > > translated one regex string format to another, for example? > > Do you mean this? > > py> import reconvert > py> help(reconvert)... Yes I mean it. Actually I was unaware of/forgot reconvert, but it doesn't matter because it doesn't solve the problem of code I wrote that has long ago escaped into the wild no longer working. There are other examples too, having to do with things as simple as a name change in a standard module that broke old code of mine for what I regard as silly cosmetic reasons. I hope you are right about py3k conversions being pain free and routine. I'm suspicious about it however. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=cause+pain From mediocre_person at hotmail.com Thu Apr 3 01:08:42 2008 From: mediocre_person at hotmail.com (Nick J Chackowsky) Date: Thu, 03 Apr 2008 00:08:42 -0500 Subject: Python in High School In-Reply-To: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: <47f45ae2$0$26037$88260bb3@free.teranews.com> sprad wrote: > I'm a high school computer teacher, and I'm starting a series of > programming courses next year (disguised as "game development" classes > to capture more interest). The first year will be a gentle > introduction to programming, leading to two more years of advanced > topics. > I have taught high school comp. sci. for a number of years, using Pascal, Ada, C++, Visual Basic, and Python as languages. Python has, in my opinion, given the students the best opportunity to really discover what programming and computer science are all about. Very high level code without the enormous learning curve for the "extras", plus easy debugging and useful error messages make it ideal. class Example { // your program begins with a call to main() public static void main(String args[]){ System.out.println("this is a simple Java program"); } } vs print ("This is a simple Python program.") Once a student has a grasp of Python and programming, he/she is better prepared to understand _why_ Java and C++ _need_ all the declarations, decorations, and specifications, and why they might be useful. But it's sure nice to start doing real programming in such a simple, elegant environment. Nick. -- Posted via a free Usenet account from http://www.teranews.com From steve at holdenweb.com Thu Apr 24 13:41:34 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 13:41:34 -0400 Subject: function that accepts any amount of arguments? In-Reply-To: <933e4c97-11c8-43b0-81e0-c78ff8573792@26g2000hsk.googlegroups.com> References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> <4810724a$0$23390$426a74cc@news.free.fr> <63ac69bf-9f6d-42bd-8e6e-5b3b17ec7c69@z72g2000hsb.googlegroups.com> <933e4c97-11c8-43b0-81e0-c78ff8573792@26g2000hsk.googlegroups.com> Message-ID: Jonathan Gardner wrote: > On Apr 24, 5:28 am, malkarouri wrote: >> What's wrong with raising ZeroDivisionError (not stopping the >> exception in the first place)? >> > > Because when I use your module, call avg (or mean) without args, I > should see an error that says, "Hey, you have to pass at least one > value in!" > > ZeroDivisonError doesn't mean that. It means I tried to divide by > zero. Naively, I don't see where I was dividing by zero (because I > don't remember how to calculate the mean---that's what your code was > for.) > > ValueError does mean that I didn't pass the right kind of arguments > in. ValueError("No items specified") would be even clearer. (Or maybe > TypeError?) > > In general, any exception thrown should be meaningful to the code you > are throwing it to. That means they aren't familiar with how your code > works. > This is Advice. Software Engineering's next door ;-) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From ABH at MCHSI.COM Tue Apr 8 13:19:47 2008 From: ABH at MCHSI.COM (Hutch) Date: Tue, 08 Apr 2008 17:19:47 GMT Subject: Python 3.0 new integer division References: Message-ID: "Matimus" wrote in message news:b6eafdd4-dbf8-4269-962f-531126bb10c0 at s33g2000pri.googlegroups.com... > On Apr 8, 9:13 am, "Hutch" wrote: >> We now have a float result when two integers are divided in the same >> mannor >> as 2.4 or 2.5. >> I can handle that and use the Floor division but a simple question. >> >> Why in the world would you round down the last presented digit to a 6 >> instead of just leaving it along as an 8. >> For some reason rounding down for a float in Python does not seem >> correct. >> >> IDLE 3.0a4 >> >> >>> 12345678901234567890123456789012345678901234567890/345 >> >> 3.5784576525317586e+46 >> >> >>> 12345678901234567890123456789012345678901234567890//345 >> >> 35784576525317588087314367504383610663481839327 >> ^ >> ^| >> 35784576525317586000000000000000000000000000000 == >> 3.5784576525317586e+46 > > This just has to do with the way floating point numbers are > represented in memory. More information: > http://docs.python.org/tut/node16.html > > Matt Was thinking IBM decimal when I asked the question --should have remembered detail of floats. Thanks Hutch From Lie.1296 at gmail.com Fri Apr 4 19:49:36 2008 From: Lie.1296 at gmail.com (Lie) Date: Fri, 4 Apr 2008 16:49:36 -0700 (PDT) Subject: Newbie Question - Overloading == References: <85edb5fb-eae8-4e8f-8f77-0ee4668063cd@u69g2000hse.googlegroups.com> <7eb5d21a-c4de-4655-ab93-9221d996f424@i7g2000prf.googlegroups.com> Message-ID: On Apr 1, 2:22?pm, Duncan Booth wrote: > "bruno.desthuilli... at gmail.com" wrote: > >> Surely an A isn't equal to every other object which just happens to > >> have the same attributes 'a' and 'b'? > > > And why not ?-) > > >> I would have thoughts the tests want to be > >> something like: > > >> class A: > >> ? ? def __eq__(self,other): > >> ? ? ? ? ?return (isinstance(other, A) and > >> ? ? ? ? ? ? self.a == other.a and self.b == other.b) > > >> (and similar for B) with either an isinstance or exact match required > >> for the type. > > > I don't think there's a clear rule here. Python is dynamically typed > > for good reasons, and MHO is that you should not fight against this > > unless you have equally good reasons to do so. > > I fully agree with that, but an apple != a pear, even if they are the same > size and colour. There will be some types where you can have equality > between objects of different types (e.g. int/float), but more often the > fact that they are different types wil automatically mean they are not > equal. Even though an apple != a pear, sometimes when we just don't need to care between their differences we can treat them as equal, that's what duck typing is. It really depends on your need if you decided to use or not to use isinstance checking, in most cases you'd want them to be checked, but sometimes you just want to know whether the two objects has the same values on their relevant attributes. From grante at visi.com Wed Apr 23 12:31:55 2008 From: grante at visi.com (Grant Edwards) Date: Wed, 23 Apr 2008 11:31:55 -0500 Subject: MESSAGE RESPONSE References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> Message-ID: On 2008-04-22, Blubaugh, David A. wrote: > Is there a way to block these messages. I do not want to be caught > with filth such as this material. I could lose my job with Belcan with > evil messages such as these messages. No, not really. That's one reason I never use my work e-mail address for anything public (Usenet, mailing lists, etc.) -- Grant Edwards grante Yow! I'm into SOFTWARE! at visi.com From mccle27252 at gmail.com Mon Apr 21 03:53:54 2008 From: mccle27252 at gmail.com (mccle27252 at gmail.com) Date: Mon, 21 Apr 2008 00:53:54 -0700 (PDT) Subject: spy sweeper 5.5 crack serial Message-ID: <3d8fd45d-02ba-40aa-8e18-a22009d8daff@z24g2000prf.googlegroups.com> spy sweeper 5.5 crack serial http://cracks.00bp.com F R E E C R A C K S From roy at panix.com Wed Apr 16 19:35:10 2008 From: roy at panix.com (Roy Smith) Date: Wed, 16 Apr 2008 19:35:10 -0400 Subject: How to have unittest tests to be executed in the order they appear? References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> <87zlru7le2.fsf@benfinney.id.au> <87fxtlwi03.fsf@benfinney.id.au> Message-ID: Ben Finney wrote: > Surely, since "suddenly" implies you changed one small area of the > code, that area of the code is the best place to look for what caused > the failure. Sometimes it's the environment that's changed. Yes, I know, a good unit test doesn't depend on the environment, but in real life, that's sometimes difficult to achieve. From carbanancizpo at gmail.com Fri Apr 18 16:59:09 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:59:09 -0700 (PDT) Subject: crack in the world Message-ID: <4a827462-769f-4c06-a98b-c357d30d51e5@2g2000hsn.googlegroups.com> crack in the world http://cracks.12w.net F R E E C R A C K S From roy at panix.com Sun Apr 20 14:49:33 2008 From: roy at panix.com (Roy Smith) Date: Sun, 20 Apr 2008 14:49:33 -0400 Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> <480b6133$0$34498$742ec2ed@news.sonic.net> <3eac67b4-da0a-4926-9ca4-942271513ad2@26g2000hsk.googlegroups.com> Message-ID: In article <3eac67b4-da0a-4926-9ca4-942271513ad2 at 26g2000hsk.googlegroups.com>, sturlamolden wrote: > On Apr 20, 5:28 pm, JB Stern wrote: > > > Curious Steve, how do you pay the rent and by what authority do you > > speak for "The Python world"? Your opinion couldn't be more wrong for > > programmers like myself who live by the code they write (as opposed to > > its support). > > > Are you afraid to show the code to your customer? Are you afraid it > will give you a bad reputatio? Are you worried about loosing future > contracts? Is your code really that bad? Then you better keep it > hidden from sight. > > If this is the case, my advice to you would be to find a different > profession. Perhaps flipping burgers at McDonald's fits your talent? Even if this were worded in a less rude manner, it would be a silly argument. For many businesses, keeping their source code secret is important. Whether you agree with their reasons or not, they feel it is important to them. Hiding your source code is not easy (perhaps impossible) in Python, for reasons which have been covered at length on a regular basis in this forum. If you only ship .pyc or .pyo files, there is still enough information recoverable in the field that most businesses which want to keep their source code hidden would feel excessively exposed. Producing software is all about using tools. Every tool has advantages and disadvantages. The key to using tools effectively is understanding what those are and how they impact your business. If you are lucky, you will find a tool which meets your needs perfectly. More often, you have to weigh all the factors and make the best compromise you can. If keeping your source code secret is of critical importance to your business, then Python is probably the wrong tool to be using to write an application that you're going to ship to customers. If keeping your source code secret is not important to you, that doesn't mean those who do consider it important are stupid, or evil, or better suited for a career spatially reorienting meat by-product patties at a popular restaurant chain. They just have different needs than you do. From deets at nospam.web.de Tue Apr 15 07:49:48 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 15 Apr 2008 13:49:48 +0200 Subject: How to import C++ static library? References: <66j9r8F2k2iplU1@mid.uni-berlin.de> Message-ID: <66jj3oF2ki84vU1@mid.uni-berlin.de> > > Diez: I tried SWIG, and it works nicely with C. For C++, I didn't > manage to make it work. I tried SIP; I have some problems compiling > etc. Would it be too much to ask you to supply a working example of a > (simple, stupid) C++ class and the necessary SIP files? Preferably for > Mac OS X, but Linux is also interesting I guess. I do have some code at home, if I remember this I'll try & post it. However, I suggest you get PyQt and inspect it. And actually I found the SIP-documentation _very_ helpful! Diez From sn at sncs.se Mon Apr 14 19:10:48 2008 From: sn at sncs.se (Sverker Nilsson) Date: Mon, 14 Apr 2008 16:10:48 -0700 (PDT) Subject: py3k s***s Message-ID: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> do i dare to open a thread about this? come on you braver men we are at least not bought by g***le but why? others have said it so many times i think :-//// but why? a few syntactic 'cleanups' for the cost of a huge rewrite of all the code that have been builtup from all the beginning when the once great Python came along and people began to use it and write code for it. Like all that code would have to be rewritten. blaah. and i have perhaps been drinking but i have been p**d all week since i began look into this:-( From alex at computronix.com Thu Apr 3 23:41:19 2008 From: alex at computronix.com (Alex VanderWoude) Date: Fri, 04 Apr 2008 03:41:19 GMT Subject: Figuring out what class instance contains you Message-ID: Consider the following module: ================================ class NewDict(dict): parent = None def __setitem__(self, key, value): print "My parent is", self.parent super(NewDict, self).__setitem__(key, value) class Zero(object): children = NewDict() def __init__(self): self.children.parent = self class One(Zero): pass class Two(One): pass a = One() a.children["spam"] = "baked beans" b = Two() b.children["eggs"] = "bacon" ================================ When the above module is executed, the output looks something like this: My parent is <__main__.One object at 0x00BA27B0> My parent is <__main__.Two object at 0x00B9D170> ...which is great, just what I wanted. Each dictionary instance reports correctly which object instance is its container. However, I would like to find some automagic way of having NewDict figure out what object instance it is on without resorting to having the container class instance poke a reference to itself into the NewDict instance (i.e. the line in Zero.__init__()). I have tried using inspect.getmembers() and walking up the sys._getframe() stack, but to no avail. Am I missing something here? Or is it simply not possible for the NewDict instance to figure out for itself what its container is? From kay.schluehr at gmx.net Sat Apr 12 10:06:43 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 12 Apr 2008 07:06:43 -0700 (PDT) Subject: str(bytes) in Python 3.0 References: Message-ID: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> On 12 Apr., 14:44, Christian Heimes wrote: > Gabriel Genellina schrieb: > > > On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') > > above. But I get the same as repr(x) - is this on purpose? > > Yes, it's on purpose but it's a bug in your application to call str() on > a bytes object or to compare bytes and unicode directly. Several months > ago I added a bytes warning option to Python. Start Python as "python > -bb" and try it again. ;) > > Christian And making an utf-8 encoding default is not possible without writing a new function? From victorsubervi at gmail.com Thu Apr 17 09:45:10 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 17 Apr 2008 08:45:10 -0500 Subject: Importing My Own Script Message-ID: <4dc0cfea0804170645o73b8c72exff0fae3a5b120f8e@mail.gmail.com> Hi: How do I import my own script from a second script? That is, I have script x and I want to import script y. How? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From aahz at pythoncraft.com Sun Apr 20 22:50:25 2008 From: aahz at pythoncraft.com (Aahz) Date: 20 Apr 2008 19:50:25 -0700 Subject: Finally had to plonk google gorups. References: Message-ID: In article , Grant Edwards wrote: > >This morning almost half of c.l.p was spam. In order to try to not tar >both the benign google group users and the malignant ones with the same >brush, I've been trying to kill usenet spam with subject patterns. But >that's not a battle you can win, so I broke down and joined all the >other people that just killfile everything posted via google.groups. For some reason, I don't see that much. Maybe it's because my ISP still honors cancels. ;-) -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "It is easier to optimize correct code than to correct optimized code." --Bill Harlan From marco at sferacarta.com Tue Apr 29 07:59:07 2008 From: marco at sferacarta.com (Marco Mariani) Date: Tue, 29 Apr 2008 13:59:07 +0200 Subject: Zope/DTML Infuriating... In-Reply-To: References: Message-ID: Jens wrote: > I've the checked that i'm referring to the variables correctly, so the > only explanation i can come up with, is that '+' doesn't result in a > string concatenation (with implicit typecast to string of the integer > variable(this is a interpreted language after all)). No, sorry. You really need to read the python tutorial at the very least. You might have wrong assumptions from previous PHP experiences. >>> 'x'+4 Traceback (most recent call last): File "", line 1, in TypeError: cannot concatenate 'str' and 'int' objects >>> From ellingt8877 at gmail.com Mon Apr 28 01:44:05 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:44:05 -0700 (PDT) Subject: software utility to crack games Message-ID: software utility to crack games http://crack.cracksofts.com From mattheww at chiark.greenend.org.uk Tue Apr 1 18:16:29 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 01 Apr 2008 23:16:29 +0100 (BST) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> Message-ID: <1Ul*p0k-r@news.chiark.greenend.org.uk> Aaron Watters wrote: > I've been poking around the world of object-relational > mappers and it inspired me to coin a corellary to the > the famous quote on regular expressions: > "You have objects and a database: that's 2 problems. > So: get an object-relational mapper: > now you have 2**3 problems." > That is to say I feel that they all make me learn > so much about the internals and features of the > O-R mapper itself that I would be better off rolling > my own queries on an as-needed basis without > wasting so many brain cells. That is the conclusion I have come to. When a difficult question comes up, you end up having to know the exact requirements and behaviour of the underlying database anyway. Then once you know what sequence of commands you need to be issued, you have to figure out how to persuade the ORM to do it (and not something similar but subtly wrong). At this stage it's getting in your way. -M- From lbonafide at yahoo.com Tue Apr 15 13:37:15 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Tue, 15 Apr 2008 10:37:15 -0700 (PDT) Subject: Java or C++? References: Message-ID: On Apr 15, 11:55?am, egbert wrote: > What is the role or position of C# in this context ? > If I remember well, some people have said that C# is an improved > C++ or Java. C# is more similar to Java than C++. Neither is very similar to C++, except in some cosmetic syntactic ways. Personally, that would be my last choice. C++ is the most portable of the three, and the only non- proprietary one (like Python). From evenson at gmail.com Sun Apr 20 13:07:51 2008 From: evenson at gmail.com (evenrik) Date: Sun, 20 Apr 2008 10:07:51 -0700 (PDT) Subject: Checking if a text file is blank References: Message-ID: <5c73a304-797e-49b5-bae5-78ed20715785@1g2000prg.googlegroups.com> On Apr 20, 2:04 pm, elno... at gmail.com wrote: > Greetings! > > I've just started learning python, so this is probably one of those > obvious questions newbies ask. > > Is there any way in python to check if a text file is blank? > > What I've tried to do so far is: > > f = file("friends.txt", "w") > if f.read() is True: > """do stuff""" > else: > """do other stuff""" > f.close() > > What I *mean* to do in the second line is to check if the text file is > not-blank. But apparently that's not the way to do it. > > Could someone set me straight please? I use os.path.getsize(path) for this purpose. From marco at sferacarta.com Thu Apr 3 08:56:26 2008 From: marco at sferacarta.com (Marco Mariani) Date: Thu, 03 Apr 2008 14:56:26 +0200 Subject: who said python can't be obsfucated!? In-Reply-To: <47f4b69b$0$19766$426a74cc@news.free.fr> References: <47f4b69b$0$19766$426a74cc@news.free.fr> Message-ID: Bruno Desthuilliers wrote: > sig=lambda m:'@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p > in m.split('@')]) Pff... you call that a quicksort? From http://www.p-nand-q.com/python/obfuscated_python.html import sys funcs = range(10) def A(_,o): _[3]=_[5]() def B(_,o): o[_[2]]=_[9]() def C(_,o): _[3]=_[7]() def D(_,o): o[_[1]]=_[14]() def E(_,o): _[1]=_[4]() def F(_,o): _[2]=_[6]() def G(_,o,O): if _[O[0]]():return O[-1](_,o) or 1 def H(o, start, stop): _=[o[stop],[lambda x,y:x+y,lambda x,y:x-y,lambda x, y:y|1,0,0][1](start,funcs[4](range(funcs[3](), len(o[:])))),stop,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] for i in range(4,19): _[i]=lambda _=_,o=o,s="reduce([lambda x,y:x+y,lambda "\ "x,y:x-y,lambda x,y:y|1,0,0][0],[_[1],funcs[4]("\ "range(eval(\"funcs[3]()\"),_[10]()))])$funcs[4"\ "](range(eval(\"funcs[3]()\"),_[10]()))$[lambda"\ " x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,0,0][1]"\ "(_[2],funcs[4](range(funcs[3](),_[10]())))$fun"\ "cs[4](range(funcs[3](),_[10]()))$range(_[10]()"\ "*_[10]())$o[:][_[1]]$len(o[:])$not _[3]$_[1]=="\ "_[2]$o[:][_[1]]>_[0]$o[:][_[2]]$o[_[2]]<_[0]$_"\ "[2]==_[1]$_[11]() and not E(_,0) and not G(_,o"\ ",[12,A]) and not G(_,o,[13,B])$_[11]() and not"\ " F(_,_) and not G(_,o,[16,C]) and not G(_,o,[1"\ "5,D])".split('$')[:][i-4]:eval("eval('eval(s)')") while _[11](): while _[17](): pass while _[18](): pass o[_[2]] = _[0] return _[2] def quicksort(list,start,stop): exec('funcs[3] = lambda:reduce([lambda x,y:x+y,lambda x,y'\ ':x-y,lambda x,y:y|1,0,0][1],[[lambda x,y:x+y,lambda'\ ' x,y:x-y,lambda x,y:y|1,0,0][2](200,200)]*2)\nfuncs'\ '[4] = lambda x:reduce(lambda x,y:y%2,range(eval("re'\ 'duce([lambda x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,'\ '0,0][2],[len(o[:]),len(o[:])])"),eval("reduce([lamb'\ 'da x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,0,0][2],[l'\ 'en(o[:]),len(o[:])])")+((len(o)and 3)or 3)))\nif st'\ 'art < stop:\n\tsplit = H(list, start, stop)\n\tquic'\ 'ksort(list, start, [lambda x,y:x+y,lambda x,y:x-y,l'\ 'ambda x,y: y|1,0,0][1](split,funcs[4](funcs[3]())))'\ '\n\tquicksort(list, reduce([lambda x,y:x+y,lambda x'\ ',y:x-y,lambda x,y:y|1,0,0][0],[split,funcs[4](funcs'\ '[3]())]), stop)\n') # test code: 2000 elements to sort list = [] import whrandom,time for i in range(2000): list.append(whrandom.randint(1,100)) start = time.clock() quicksort(list,0,len(list)-1) print "Sorting took %.2f" % (time.clock() - start) # just a test loop to see if everything *is* sorted element = -1 for i in list: if i >= element: element = i else: print "FUNK DAT: %20s" % str(i) break From cesugden at gmail.com Thu Apr 24 12:39:26 2008 From: cesugden at gmail.com (Chris) Date: Thu, 24 Apr 2008 09:39:26 -0700 (PDT) Subject: Installer Message-ID: Hey all, I've created a python program that relies on pysqlite, wxpython, and matplotlib. Is there any way of creating an installer that will install all these modules, python 2.5 and my program? Thanks. From pavlovevidence at gmail.com Tue Apr 22 10:22:12 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 22 Apr 2008 07:22:12 -0700 (PDT) Subject: Remove multiple inheritance in Python 3000 References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <6760jfF2n3bn1U1@mid.uni-berlin.de> Message-ID: On Apr 22, 7:30 am, "Diez B. Roggisch" wrote: > GD schrieb: > > > Please remove ability to multiple inheritance in Python 3000. > > > Multiple inheritance is bad for design, rarely used and contains many > > problems for usual users. > > > Every program can be designed only with single inheritance. > > Yes, sure. And that's why Java grew interfaces & it's class-diagrams are > hilariously complex. Because using single inheritance is so much better. I have a couple issues with this, though I wholeheartedly agree with the sentiment: 1. Java didn't grow interfaces, they were there from the start. 2. Java interfaces solve a different problem than MI (used properly) does: interfaces are there to make types polymorphic, whereas inheritance's main use is to share behavior. Too many people believe polymorphism is the only noble goal of OO. If that were true, there'd be no reason for multiple inheritance, or single inheritance for that matter. But in my opinion, minimizing code redundancy by allowing classes to share behaviors is far more useful and important. That's why I wholeheartedly favor MI: it allows classes to share behavior with restraints. Java (for example) allows a class to share behavior with only one other class, and that *severely* limits the opportunities to minimize redundancy. Carl Banks From arnodel at googlemail.com Fri Apr 11 07:02:22 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Fri, 11 Apr 2008 04:02:22 -0700 (PDT) Subject: @x.setter property implementation References: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> <02cb2845-6a25-4e90-9f82-dbd68b37a5e6@p39g2000prm.googlegroups.com> <2c589c82-85e9-4db6-b8f9-156b06dd51f3@s33g2000pri.googlegroups.com> <3238aeb7-cd1b-463d-ad87-0d28dcee0202@a1g2000hsb.googlegroups.com> Message-ID: <41ba2942-3462-4882-9f56-18139c1f916b@x41g2000hsb.googlegroups.com> On Apr 11, 11:19?am, Floris Bruynooghe wrote: [...] > > Unfortunatly both this one and the one I posted before work when I try > > them out on the commandline but both fail when I try to use them in a > > module. ?And I just can't figure out why. > > This in more detail: Imaging mod.py: > > import sys > > _property = property > > class property(property): > ? ? """Python 2.6/3.0 style property""" > ? ? def setter(self, fset): > ? ? ? ? cls_ns = sys._getframe(1).f_locals > ? ? ? ? for k, v in cls_ns.iteritems(): > ? ? ? ? ? ? if v == self: > ? ? ? ? ? ? ? ? propname = k > ? ? ? ? ? ? ? ? break > ? ? ? ? cls_ns[propname] = property(self.fget, fset, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? self.fdel, self.__doc__) > ? ? ? ? return fset > > class Foo(object): > ? ? @property > ? ? def x(self): > ? ? ? ? return self._x > > ? ? @x.setter > ? ? def x(self, v): ^^^^^ Don't call this 'x', it will override the property, change it to 'setx' and everything will work. The same probably goes for your own 'propset' decorator function. > ? ? ? ? self._x = v + 1 > > Now enter the interpreter: > >> import mod > >>> f = mod.Foo() > >>> f.x = 4 > >>> f.x > > 4 > > I don't feel like giving up on this now, so close... -- Arnaud From ivan.illarionov at gmail.com Fri Apr 11 10:13:28 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Fri, 11 Apr 2008 07:13:28 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <31872ffc-5bc4-44c8-961d-ee4f0dc356c5@k1g2000prb.googlegroups.com> <700b1a5f-0af0-466e-abda-4d8dc784dbaa@e67g2000hsa.googlegroups.com> Message-ID: <220fa9fa-3ad3-4d58-b90c-478f936b5352@m1g2000pre.googlegroups.com> On Apr 11, 5:49 pm, hdante wrote: > On Apr 11, 9:45 am, bdsatish wrote: > > > > > On Apr 11, 5:33 pm, bdsatish wrote: > > > > HI Gerard, > > > > I think you've taken it to the best possible implementation. Thanks ! > > > On Apr 11, 5:14 pm, Gerard Flanagan wrote: > > > > > In fact you can avoid the call to the builtin round: > > > > > ------------------------------------------------ > > > > > assert myround(3.2) == 3 > > > > assert myround(3.6) == 4 > > > > assert myround(3.5) == 4 > > > > assert myround(2.5) == 2 > > > > assert myround(-0.5) == 0.0 > > > > assert myround(-1.5) == -2.0 > > > > assert myround(-1.3) == -1.0 > > > > assert myround(-1.8) == -2 > > > > assert myround(-2.5) == -2.0 > > > > ------------------------------------------------ > > > OK, I was too early to praise Gerard. The following version: > > > def myround(x): > > n = int(x) > > if abs(x - n) >= 0.5 and n % 2: > > return n + 1 - 2 * int(n<0) > > else: > > return n > > > of Gerard doesn't work for 0.6 (or 0.7, etc.) It gives the answer 0 > > but I would expect 1.0 ( because 0.6 doesn't end in 0.5 at all... so > > usual rules of round( ) apply) > > Interestingly, you could solve this by using python 3. :-) > round(x[, n]) > Return the floating point value x rounded to n digits after the > decimal point. If n is omitted, it defaults to zero. Values are > rounded to the closest multiple of 10 to the power minus n; if two > multiples are equally close, rounding is done toward the even choice > (so, for example, both round(0.5) and round(-0.5) are 0, and > round(1.5) is 2). Delegates to x.__round__(n). > > My turn: ;-) > > def yaround(x): > i = int(x) > f = x - i > if f != 0.5 and f != -0.5: return round(x) > return 2.0*round(x/2.0) > > a = (-10.0, -9.0, -8.0, -4.6, -4.5, -4.4, -4.0, -3.6, -3.5, > -3.4, -0.6, -0.5, -0.4, 0.0, 0.4, 0.5, 0.6, 0.9, 1.0, > 1.4, 1.5, 1.6, 2.0, 2.4, 2.5, 2.6, 10.0, 100.0) > > b = (-10.0, -9.0, -8.0, -5.0, -4.0, -4.0, -4.0, -4.0, -4.0, > -3.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, > 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 3.0, 10.0, 100.0) > > for i in range(len(a)): > assert yaround(a[i]) == b[i] Shorter version: def round3k(x): return x % 1 != 0.5 and round(x) or round(x / 2.) * 2. nums = [ 0, 2, 3.2, 3.6, 3.5, 2.5, -0.5, -1.5, -1.3, -1.8, -2.5, 0.6, 0.7 ] rnums = [ 0, 2, 3.0, 4.0, 4.0, 2.0, -0.0, -2.0, -1.0, -2.0, -2.0, 1.0, 1.0 ] for num, rnum in zip(nums, rnums): assert even_round(num) == rnum, '%s != %s' % (even_round(num), rnum) print num, '->', even_round(num) It makes sense to add `from __future__ import even_round` to Python 2.6. From silfheed at gmail.com Fri Apr 11 03:36:11 2008 From: silfheed at gmail.com (Silfheed) Date: Fri, 11 Apr 2008 00:36:11 -0700 (PDT) Subject: CDATA and lxml Message-ID: <5ebe3201-80a6-45ba-8b88-e8ece6883efa@w8g2000prd.googlegroups.com> Heyas So first off I know that CDATA is generally hated and just shouldn't be done, but I'm simply required to parse it and spit it back out. Parsing is pretty easy with lxml, but it's the spitting back out that's giving me issues. The fact that lxml strips all the CDATA stuff off isnt really a big issue either, so long as I can create CDATA blocks later with <>&'s showing up instead of <>& . I've scoured through the lxml docs, but probably not hard enough, so anyone know the page I'm looking for or have a quick how to? Thanks! From dickinsm at gmail.com Thu Apr 17 09:38:11 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Thu, 17 Apr 2008 06:38:11 -0700 (PDT) Subject: def power, problem when raising power to decimals References: Message-ID: <88a9c416-2a52-450f-9608-4ad6ac6e1abc@p25g2000hsf.googlegroups.com> On Apr 16, 11:03?pm, "Terry Reedy" wrote: > | decimal.InvalidOperation: 0 ** 0 > > I would think of this as a bug unless the standard Decimal follows demands > this. It does. From http://www2.hursley.ibm.com/decimal/daops.html#refpower : "If both operands are zero, or if the left-hand operand is less than zero and the right-hand operand does not have an integral value[7] or is infinite, an Invalid operation condition is raised, the result is [0,qNaN], and the following rules do not apply." I'm hoping that this will change with the next update of the standard. Mark From skanemupp at yahoo.se Thu Apr 10 08:11:53 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 05:11:53 -0700 (PDT) Subject: questions about Exceptions? References: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> <71cc8c25-f5f9-4f21-a9d8-06780bf97608@f63g2000hsf.googlegroups.com> <9af81b1a-3e02-4406-b9d2-0a9b6f46566b@p39g2000prm.googlegroups.com> <0e586d5d-6799-433f-b8a4-4de5d2a87b61@h1g2000prh.googlegroups.com> <46a79564-4069-46af-b6ab-b38bd9152c2a@d45g2000hsc.googlegroups.com> <1f413b6e-f964-4f8d-b781-61985f86acc2@a9g2000prl.googlegroups.com> <1473f09e-936f-4e35-830d-ecf999976c55@f63g2000hsf.googlegroups.com> Message-ID: <1feb1641-ed06-448a-849b-20a365efc4c7@c19g2000prf.googlegroups.com> from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") l = Label(mygui, text="Answer: ") l.place(relx=0.15, rely=0.2, anchor=CENTER) e = Entry(mygui) e.place(relx=0.4, rely=0.1, anchor=CENTER) def Disp(nstr): e.insert(END, nstr) def Calc(): expr=e.get() try: b = Label(mygui, text=eval(expr)) b.place(relx=0.4, rely=0.2, anchor=CENTER) except: b = Label(mygui, text="Not computable") b.place(relx=0.4, rely=0.2, anchor=CENTER) def Erase(): e.delete(0,END) x = 0.1 y = 0.4 for char in '123+456-789*0^./()': b = Button(mygui, text=char,command=lambda n=char:Disp(n), width=2, height=1) b.place(relx=x, rely=y, anchor=CENTER) x=x+0.1 if x==0.5: x=0.1 y=y+0.1 b = Button(mygui, text="C",command=Erase, width=2, height=1) b.place(relx=0.3, rely=0.8, anchor=CENTER) b = Button(mygui, text="=",command=Calc, width=2, height=1) b.place(relx=0.4, rely=0.8, anchor=CENTER) mygui.mainloop() From kyosohma at gmail.com Wed Apr 23 13:56:02 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 23 Apr 2008 10:56:02 -0700 (PDT) Subject: Python development tools References: Message-ID: <72fa1da4-ae68-4493-8fbc-a7d21d1c3b8c@y21g2000hsf.googlegroups.com> On Apr 23, 12:39?pm, "wongjoek... at yahoo.com" wrote: > Are there any completely free developent tools for python scripts like > IDLE. I have used IDLE , but I want to try out others also. I saw > stuff like PyCrust, but I don't see that it can run the script as > well. > Thanks, > > RR Check out PyDev for Eclipse. It's like Visual Studio for Python...I actually find it kind of clunky, but it is cool! To see what else there is, check out the Python wiki: http://wiki.python.org/moin/PythonEditors Mike From littlesweetmelon at gmail.com Mon Apr 7 01:30:50 2008 From: littlesweetmelon at gmail.com (=?GB2312?B?zPC5zw==?=) Date: Mon, 7 Apr 2008 13:30:50 +0800 Subject: Basic optimization of python. Message-ID: Howdy, I wonder whether python compiler does basic optimizations to .py. Eg: t = self.a.b t.c = ... t.d = ... .vs. self.a.b.c = ... self.a.b.d = ... which one is more effective? Since each dot invokes a hash table lookup, it may be time consuming. If the compiler can do expression folding, then no manual folding is needed. Again, how about contant calculation? Eg: a = 1 + 2 .vs. a = 3 which one is more effective? Does the compiler calculate the result at compile time? How about constant spreading? Best regards, --- ShenLei -------------- next part -------------- An HTML attachment was scrubbed... URL: From skanemupp at yahoo.se Sun Apr 6 16:38:20 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 6 Apr 2008 13:38:20 -0700 (PDT) Subject: How to create an exe-file? Message-ID: <311a216f-5366-47c5-86a7-431dd23ced3e@j1g2000prb.googlegroups.com> how do you create exe-files of your python-code? is it different depending on what libraries, GUI-frameworks you use? i want to create an exe-file of a pythonscript that uses Tkinter. From nospam at invalid.com Thu Apr 24 23:39:58 2008 From: nospam at invalid.com (Jack) Date: Fri, 25 Apr 2008 03:39:58 GMT Subject: ctypes: return a pointer to a struct References: <846077c3-beaf-4ccd-83be-1e2168c4f7fe@c65g2000hsa.googlegroups.com> <4dda2bd7-3348-496e-a594-35da0a34d4de@x35g2000hsb.googlegroups.com> Message-ID: Thanks for the prompt and detailed reply. I tried that but was getting this error: AttributeError: 'LP_IP2LocationRecord' object has no attribute 'country_short' Here's my version, which I think is equivalent to yours: (as a matter of fact, I also tried yours and got the same error.) class IP2LocationRecord(Structure): _fields_ = [("country_short", c_char_p), ("country_long", c_char_p), ("region", c_char_p), ("city", c_char_p), ("isp", c_char_p), ("latitude", c_float), ("longitude", c_float), ("domain", c_char_p), ("zipcode", c_char_p), ("timezone", c_char_p), ("netspeed", c_char_p)] IP2Location_get_all.restype = POINTER(IP2LocationRecord) IP2LocationObj = IP2Location_open(thisdir + '/IP-COUNTRY-SAMPLE.BIN') rec = IP2Location_get_all(IP2LocationObj, '64.233.167.99') print rec.country_short IP2Location_close(IP2LocationObj) "sturlamolden" wrote in message news:4dda2bd7-3348-496e-a594-35da0a34d4de at x35g2000hsb.googlegroups.com... > On Apr 25, 5:15 am, sturlamolden wrote: > >> First define a struct type IP2LocationRecord by subclassing from >> ctypes.Structure. Then define a pointer type as >> ctypes.POINTER(IP2LocationRecord) and set that as the function's >> restype attribute. See the ctypes tutorial or reference for details. > > Which is to say: > > import ctypes > > class IP2LocationRecord(ctypes.Structure): > _fields_ = [ > ('country_short', ctypes.c_char_p), > ('country_long', ctypes.c_char_p), > ('region', ctypes.c_char_p), > ('city', ctypes.c_char_p), > ('isp', ctypes.c_char_p), > ('latitude', ctypes.c_float), > ('longitude', ctypes.c_float), > ('domain', ctypes.c_char_p), > ('zipcode', ctypes.c_char_p), > ('timezone', ctypes.c_char_p), > ('netspeed', ctypes.c_char_p), > ] > > IP2LocationRecord_Ptr_t = ctypes.POINTER(IP2LocationRecord) > > function.restype = IP2LocationRecord_Ptr_t > > From apavluck at gmail.com Mon Apr 28 13:52:11 2008 From: apavluck at gmail.com (Alex Pavluck) Date: Mon, 28 Apr 2008 10:52:11 -0700 (PDT) Subject: xcode able to run script? Message-ID: <31c47061-7038-4868-8422-a8da0f6d7437@m45g2000hsb.googlegroups.com> Does anyone know if it is possible to test your scripts from within the xcode editor? I am currently using Uilipad on windows and there is a sub window that lets you view your output when you launch the script from within the ide. hopefully this makes sense. thanks, Alex From deets at nospam.web.de Wed Apr 9 16:58:23 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 09 Apr 2008 22:58:23 +0200 Subject: basic python question about for loop In-Reply-To: References: Message-ID: <664ovoF2iq9i0U1@mid.uni-berlin.de> jmDesktop schrieb: > From the Python.org tutorial: > >>>> for n in range(2, 10): > ... for x in range(2, n): > ... if n % x == 0: > ... print n, 'equals', x, '*', n/x > ... break > ... else: > ... # loop fell through without finding a factor > ... print n, 'is a prime number' > ... > 2 is a prime number > 3 is a prime number > 4 equals 2 * 2 > 5 is a prime number > 6 equals 2 * 3 > 7 is a prime number > 8 equals 2 * 4 > 9 equals 3 * 3 > > > > first time 2 mod 2, 2/2, no remainder == 0, what am I doing wrong? > Why did it fall through? print out what range(2, n) for n == 2 is. And if you didn't know - 2 *IS* a prime. Diez From gagsl-py2 at yahoo.com.ar Sat Apr 5 01:28:42 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 05 Apr 2008 02:28:42 -0300 Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <7113d012-01bb-4426-bb40-9e2811cdb102@x41g2000hsb.googlegroups.com> <3cf4bbc8-b828-45c5-b9a8-766ce600af43@y21g2000hsf.googlegroups.com> Message-ID: En Sat, 05 Apr 2008 02:02:45 -0300, escribi?: > one thing i dont rally get, i ahve to add my_button.bind() somewhere? > i changed the stuff u said though and i get this error(the program > executes though and i can press the buttons): Either use command, or bind. command requires a function with no parameters (or a bound method with self alone). bind uses a function with a single parameter, the event (or a bound method with self and event parameters). See the Tkinter book: http://www.effbot.org/tkinterbook/tkinter-events-and-bindings.htm http://www.effbot.org/tkinterbook/button.htm -- Gabriel Genellina From lists at cheimes.de Sun Apr 20 12:07:41 2008 From: lists at cheimes.de (Christian Heimes) Date: Sun, 20 Apr 2008 18:07:41 +0200 Subject: Alternate indent proposal for python 3000 In-Reply-To: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: Eric Wertman schrieb: > I was considering putting together a proposal for an alternate block > syntax for python, and I figured I'd post it here and see what the > general reactions are. I did some searching, and while I found a lot > of tab vs space debates, I didn't see anything like what I'm thinking > of, so forgive me if this is a very dead horse. You are definitely too late to propose a change for py3k. > I feel that including some optional means to block code would be a big > step in getting wider adoption of the language in web development and > in general. I do understand though, that the current strict indenting > is part of the core of the language, so... thoughts? Why should Python repeat the mistakes other languages did with SSI or inline code? Python favors the MVC separation of code and layout. Christian From ian.team.python at saltmob.com Tue Apr 8 22:21:51 2008 From: ian.team.python at saltmob.com (ian) Date: Tue, 8 Apr 2008 19:21:51 -0700 (PDT) Subject: style question - hasattr Message-ID: In old python code i would use 'has_key' to determine if an element was present in a dictionary. Python 3.0 will even removed 'has_key'. The reason for removal is that using the 'in' operator is a cleaner syntax and having two ways to achieve the same result is against the principle of the language. Ok, so what about 'hasattr' ?? hasattr(myObject,'property') seems equivalent to 'property' in dir(myObject) I would suggest that using the 'in' is cleaner in this case also. Is there a performance penalty here? Or is there reason why the two are not actually the same? Which style is preferred?? From deets at nospam.web.de Tue Apr 1 18:57:47 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 02 Apr 2008 00:57:47 +0200 Subject: Not Sure This Can Be Done... In-Reply-To: <13777863-548e-4318-9b03-d64ccc3eebea@d21g2000prf.googlegroups.com> References: <46aeae28-4470-4136-a5f6-040f6468eb32@b5g2000pri.googlegroups.com> <65fmclF2f352gU1@mid.uni-berlin.de> <13777863-548e-4318-9b03-d64ccc3eebea@d21g2000prf.googlegroups.com> Message-ID: <65fsveF2ej0d1U1@mid.uni-berlin.de> gamename schrieb: >> Use virtualenv to create a local python, and activate that when >> developing for that branch. > > Thanks for the suggestion, but that's the problem: having to activate > it. > Isn't there some way to simply have the local script look at a > specified > dir rather than starting a virtual environment? You can only do that yourself - you can write a helper-module that will inspect the environment, locates the module, and appends it path to sys.path. Diez From gh at ghaering.de Thu Apr 10 05:06:21 2008 From: gh at ghaering.de (=?ISO-8859-1?Q?Gerhard_H=E4ring?=) Date: Thu, 10 Apr 2008 11:06:21 +0200 Subject: I am worried about Python 3 In-Reply-To: <47fce3ca$0$36346$742ec2ed@news.sonic.net> References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> <47fce3ca$0$36346$742ec2ed@news.sonic.net> Message-ID: <6663kdF2j5bs0U1@mid.uni-berlin.de> John Nagle wrote: > jmDesktop wrote: > >> If I continue in Python 2.5.x, am I making a mistake? Is it really >> that different? > > No. It may never happen, either. The Perl crowd tried > something like this, Perl 6, which was announced in 2000 and still > hasn't come out. The C++ standards committee has been working on a > revision of C++ since the 1990s, and that hasn't happened either. > > The general consensus is that Python 3.x isn't much of an > improvement over the existing language. There's just not much > demand for it. The difference is that Guido learnt from the mistakes of Perl 6 and set much more realistic (moderate) goals for Python 3.0. Unlike others, I think that Python 3.0 will get popular sooner than you think. Imagine: - you're the developer of an Open Source Python library - for fame and glory, you port it to Python 3.0 - you realize that maintaining two branches is cumbersome - Python 3.0 becomes first class - Users switch to ... -- Gerhard From stef.mientki at gmail.com Fri Apr 11 17:40:00 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Fri, 11 Apr 2008 23:40:00 +0200 Subject: win-shortcuts, file associates and command-line parameters ? In-Reply-To: References: <47FE6480.4090602@gmail.com> Message-ID: <47FFDAB0.1020502@gmail.com> Gabriel Genellina wrote: > En Thu, 10 Apr 2008 16:03:28 -0300, Stef Mientki > escribi?: > > >> under windows I tried to make a shortcut to a py -file, to run a program. >> So making a shortcut like this works perfect: >> D:\PyLab_Works.py >> >> But the problem is that I need to give some commandline parameters to >> the py-file, >> and >> >> D:\PyLab_Works.py btc_test >> But the parameter doesn't seem to arrive in the python program >> > > Check the associated command for .py files; see this message > http://groups.google.com/group/comp.lang.python/msg/056ba14ae4fa57e3 > > Didn't work for me winXP-SP2, even after a restart :-( But anyway thanks for the effort. cheers, Stef Mientki From victorsubervi at gmail.com Thu Apr 17 15:19:12 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 17 Apr 2008 14:19:12 -0500 Subject: Error Handling Message-ID: <4dc0cfea0804171219l7e4c749dpfd13f9bb35294e1a@mail.gmail.com> Hi; I have the following code: try: cursor.execute(sql) print '?Exito en introducir!
' print 'Esta p?gina va a regresar a la p?gina principal del carrito de compras en 10 segundos.' except IntegrityError: print 'Lo siento, pero el ID que entraste est? usado actualmente por otra entrada. Favor de dar para atr?z y escojer otro n?mero.' except OperationalError: print 'Lo siento, pero has a?adido un car?cter extra?o a un n?mero (o en "ID", "precio", "rec?maras" o "ba?os". Favor de dar para atr?z y escojer otro n?mero.' except: print 'Lo siento, pero hay un error. Favor de dar para atr?z y averiguar donde est? el error, y reintentar.' When I enter and ID that is not a number, it should trigger the IntegrityError. Instead, I get this in the error log: [Thu Apr 17 12:06:37 2008] [error] [client 190.166.0.245] PythonHandler mod_python.cgihandler: NameError: global name 'IntegrityError' is not defined, referer: http://livestocksling.com/bre/iud.py When I enter a non-digit in a float, I should get an OperationalError. Instead, I get more garbage: [Thu Apr 17 12:10:38 2008] [error] [client 190.166.0.245] PythonHandler mod_python.cgihandler: NameError: global name 'OperationalError' is not defined, referer: http://livestocksling.com/bre/iud.py What do? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From hat at se-162.se.wtb.tue.nl Thu Apr 24 03:38:16 2008 From: hat at se-162.se.wtb.tue.nl (A.T.Hofkamp) Date: Thu, 24 Apr 2008 09:38:16 +0200 Subject: Unix Device File Emulation References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> <480f6376$0$9037$5402220f@news.sunrise.ch> <9ee87070-be57-4a66-a152-3f36c1cc8f0c@k13g2000hse.googlegroups.com> <480f7983$0$9036$5402220f@news.sunrise.ch> <49529b68-88b4-4115-a85a-587528274a50@m73g2000hsh.googlegroups.com> Message-ID: On 2008-04-23, blaine wrote: > On Apr 23, 2:01 pm, "Martin Blume" wrote: >> "blaine" schrieb >> No, >> while 1: >> r = self.fifodev.readline() >> if r: print r >> else: time.sleep(0.1) >> is ok (note the "if r:" clause). >> >> Martin > > Beautiful! Thanks Martin! yes, but you have to follow the usual file handling rules, and close/re-open the fifo after detecting EOF. You will be blocked on attempting to re-open until there is another writing process. while 1: fp = open('my_fifo', 'r') while 1: line = fp.readline() if line == '': break print line.rstrip() # To prevent printing of \n in line fp.close() Albert From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 1 14:23:32 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 01 Apr 2008 20:23:32 +0200 Subject: Python in High School In-Reply-To: References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> Message-ID: <47f27da1$0$17187$426a74cc@news.free.fr> sprad a ?crit : > On Apr 1, 11:41 am, mdomans wrote: >> Python needs no evangelizing but I can tell you that it is a powerfull >> tool. I prefer to think that flash is rather visualization tool than >> programing language, and java needs a lot of typing and a lot of >> reading. On the other hand python is simple to read and write, can be >> debuged easily, is intuitive and saves a lot of time. It also supports >> batteries included policy and you can't get more OO than python. > > One advantage of Flash is that we can have something moving on the > screen from day one, and add code to it piece by piece for things like > keyboard or mouse control, more and more complex physics, etc. Is > there an equivalent project in Python? see my other answer in this thread. From nagle at animats.com Fri Apr 4 13:54:49 2008 From: nagle at animats.com (John Nagle) Date: Fri, 04 Apr 2008 10:54:49 -0700 Subject: collecting results in threading app In-Reply-To: References: <47f64507$0$36354$742ec2ed@news.sonic.net> Message-ID: <47f668d2$0$36340$742ec2ed@news.sonic.net> Gerardo Herzig wrote: > John Nagle wrote: > >> Gerardo Herzig wrote: > Thanks John, that certanly works. According to George's suggestion, i > will take a look to the Queue module. > One question about > > for mythread in mythreads: # for all threads > mythread.join() # wait for thread to finish > > > That code will wait for the first count(*) to finish and then continues > to the next count(*). Because if is that so, it will be some kind of > 'use threads, but execute one at the time'. No, all the threads are started in the first loop, and can run their MySQL queries concurrently. Once all threads have been started, the second loop (above) waits for all of them to finish. John Nagle From davidf at sjsoft.com Tue Apr 1 03:55:52 2008 From: davidf at sjsoft.com (David Fraser) Date: Tue, 1 Apr 2008 00:55:52 -0700 (PDT) Subject: counting using variable length string as base References: <0d2b84b7-efd0-4e53-98da-01ff1d3c6b9e@s8g2000prg.googlegroups.com> <4d1d7d83-8155-4c1a-a807-0b5c951e1192@d21g2000prf.googlegroups.com> Message-ID: <415b6d3e-b9c8-4b24-88ae-1fd47f28258f@2g2000hsn.googlegroups.com> On Mar 31, 8:18 pm, "Gabriel Genellina" wrote: > En Mon, 31 Mar 2008 09:30:00 -0300, Graeme Glass > escribi?: > > > On Mar 27, 11:01 am, Peter Otten <__pete... at web.de> wrote: > >> a b c aa ab ac ba bb bc ca cb cc aaa aab aac aba abb abc aca acb acc > >> baa bab > >> bac bba bbb bbc bca bcb bcc > > > Here is a cool solution we came up with during a little interactive > > session at our local meet up. > > (http://www.python.org.za/pugs/cape-town/cape-town) > > > s = 'abcdef' > > ["".join([s[j] for j in range(len(s)) if x & (1 << j)]) for x in > > range(1,2**len(s)) ] > > But it's doesn't generate the right sequence, and a lot of elements are > missing. For 'abc': > ['a', 'b', 'ab', 'c', 'ac', 'bc', 'abc'] > It lacks ba, bb, ca, cb, cc, all b??, all c?? - see the sequence quoted > above. Indeed, the following shold do the trick although it's fairly inefficient: n=(len(s)+1) ; z = [''] + list(s) ; all = sorted(dict.fromkeys("".join(z[(x/(n**j))%n] for j in range(n)) for x in range(1,n**n))) Cheers David From rune.strand at gmail.com Fri Apr 11 18:32:10 2008 From: rune.strand at gmail.com (Rune Strand) Date: Fri, 11 Apr 2008 15:32:10 -0700 (PDT) Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> <47ffee86$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: <15e5c81b-0b21-44f0-9282-0d1495bc6bb3@z24g2000prf.googlegroups.com> On Apr 12, 12:03 am, Michel Bouwmans wrote: > > Qt Designer. And creating the GUI yourself in the text editor isn't that > bad, plus you have much better control over it. If you like designing isual elements in an editor, that's fine for me! I don't, And as I don't do it all the time, I tend to forget constructional details and waste life googling. So for me it's pain without cognition. AKA waste of life. Numerous RAD' env's, fx Delphi, suggests this kind of incredibly boring almost pre-historic, self-pestering non-sense pain is ancient, and I happen to agree. It's an orthodox and monkish way of programming. Some like it that way and that's none of my business. I don't like it that way. Designing GUI in a text-editor (for me) always produce a : "good enough" and consumes a lot of life. The Boa constructor / Delphi way produce "what I want" without _wasting life_. But Boa is too unstable, and does not claim otherwise, and there's no descent alternative I'm aware of. So, GUI Python still sucks far too much. Console and web Python indeed does not. So if the Python Foundation arrange a "Descent RAD" effort, I'll happily donate $100 for starters. I think Python should be just as easily GUI'able as it is Console'able. Python is soon 20 years old! From tkpmep at hotmail.com Fri Apr 11 14:03:17 2008 From: tkpmep at hotmail.com (tkpmep at hotmail.com) Date: Fri, 11 Apr 2008 11:03:17 -0700 (PDT) Subject: Cannot start RPy - need win32api References: <743ee4e0-bd05-4291-b587-1e8c6237656b@f36g2000hsa.googlegroups.com> Message-ID: <7f1c34ee-04a3-4ea4-aadd-f99cf8425a51@y21g2000hsf.googlegroups.com> Thanks a mill - works like a charm! From gagsl-py2 at yahoo.com.ar Thu Apr 3 10:34:13 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 11:34:13 -0300 Subject: Strange MySQL Problem... References: <4dc0cfea0804021236n1faafabav1699fbe45acc3c01@mail.gmail.com> <47f46a3e$0$36371$742ec2ed@news.sonic.net> <4dc0cfea0804030543t1ad5a3abs539fa6598061c454@mail.gmail.com> Message-ID: En Thu, 03 Apr 2008 09:43:57 -0300, Victor Subervi escribi?: >> Steve Holden wrote: >> Define "no longer works". > Sorry. Throws HTTP 200 error. HTTP 200 means OK. >> > The same remarks I've posted earlier apply here. > Must have missed those. Yes, the code works fine. Repeatedly. http://groups.google.com/group/comp.lang.python/browse_thread/thread/b732eee4e91b1868/ >> In general, server side programs should have a try-block >> wrapped around most of the program, with some code to display or >> log errors in some useful way. > Curious. Why? During testing, I understand, but after testing, why? display or *log* errors... >> Gabriel Genellina wrote: >> > print 'Content-Type: image/jpeg\r\n' >> > print '\nHi!\n' >> >> Don't you see a conflict among those two lines? >> (You're a liar: first you promise to send a nice picture and then you >> only >> send a letter!) > LOL! Okay, make me honest ;) I want to post both text and images. What > use? *post*? This is the server response. Return either text *or* an image (the text may be an html referencing the image) >> > sql = "INSERT INTO justatest VALUES (%s, %s)" >> > cursor.execute(sql, ('ramis', _mysql.escape_string(f)) ) >> >> You're using bound parameters now, a good thing. There is no need to >> escape strings passed as parameters - in fact, it is wrong, as the >> adapter >> will escape the text again. >> In this case, the column is a BLOB, and you have to use the Binary >> function: MySQLdb.Binary(f) >> > > Nope. Threw me another HTTP 200. Again, HTTP 200 means OK. See section 10.2.1 at http://www.faqs.org/rfcs/rfc2616.html > Wrong. I check the mysql and drop the table if the code throws me an HTTP > 200 error. I have run this code many times now. That is what makes the > whole > thing so ridiculously strange to me. That code snippet, that the script > insists on, is a relic from the code I tweaked. It was there to make a > binary, that is all. So why do I still need the darn thing?? Test it locally (just the database thing, no web), test the cgi script without database interaction, only then join the two. >> You have to look at the server error logs, else you're blind fighting. > I am blind fighting. No longer run my own server, no longer have root > access. But you can read the server logs at least? Your code is throwing exceptions but you're not seeing them. Use the cgitb module http://docs.python.org/lib/module-cgitb.html -- Gabriel Genellina From Robert.Bossy at jouy.inra.fr Thu Apr 17 04:39:08 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Thu, 17 Apr 2008 10:39:08 +0200 Subject: Profiling, recursive func slower than imperative, normal? In-Reply-To: References: Message-ID: <48070CAC.6020005@jouy.inra.fr> Gabriel Genellina wrote: > En Wed, 16 Apr 2008 17:53:16 -0300, escribi?: > > >> On Apr 16, 3:27 pm, Jean-Paul Calderone wrote: >> >> >>> Any function can be implemented without recursion, although it isn't >>> always easy or fun. >>> >>> >> Really? I'm curious about that, I can't figure out how that would >> work. Could give an example? Say, for example, the typical: walking >> through the file system hierarchy (without using os.walk(), which uses >> recursion anyway!). >> > > Use a queue of pending directories to visit: > > start with empty queue > queue.put(starting dir) > while queue is not empty: > dir = queue.get() > list names in dir > for each name: > if is subdirectory: queue.put(name) > else: process file > Hi, In that case, I'm not sure you get any performance gain since the queue has basically the same role as the stack in the recursive version. A definitive answer calls for an actual test, though. Anyway if you want to process the tree depth-first, the queue version falls in the "not fun" category. Cheers, RB From limodou at gmail.com Fri Apr 25 02:10:52 2008 From: limodou at gmail.com (limodou) Date: Fri, 25 Apr 2008 14:10:52 +0800 Subject: [ANN]UliPad 3.9 released! Message-ID: <505f13c0804242310n62b0720fs60f36b83d8ea9ab4@mail.gmail.com> UliPad is a flexible editor, based on wxPython. It's has many features,just like:class browser, code auto-complete, html viewer, directory browser, wizard, etc. The main feature is the usage of mixin. This makes UliPad can be extended easily. So you can write your own mixin or plugin, or simple script, these can be easy and seamless integrated with UliPad. New Features and Changes: #. Add php.acp thanks for ?? #. Replace old snippet with new snippet, more details please see <`Snippet Howto `_> #. Binding F5 to editor but not MainFrame, and add F5(Refresh) support in Directory Browser. #. Improve python class browser, threading update, change some icons #. Add indent cursor move functionality see <`Indent Moving Howto `_> #. Improve threading document modification process, so you can get better efficiency #. Introduce meide(http://code.google.com/p/meide) project to simplify the interface creation #. Add FNB.FNB_DROPDOWN_TABS_LIST style to EditorCtrl #. Change auto file check in Editor on_set_focus event handler #. Change DDE to asyncore and asynchat framework #. Change preference dialog from notebook to treebook #. Add icon set theme support #. Add strip line ending when saving functionality option in Preferences #. Strip leading space when doing "Run in Shell" #. Add auto detect python interpreter in windows platform #. Improve ReST document render, and fix the setfocus lost bug when auto modified the html output, thanks a lot to ygao #. Change setmenutext to use fix width to set the menu text, replace with '\t' #. Chanage notebook left double click to right double click(enlarge notebook size) #. Add search text count in Find & Replace pane #. Add line ending mixture check when saving file feature #. Improve preference dialog input assistant checkbox process. When you check the first checkbox(Enable input assistant) it'll automatically toggle other 5 checkboxes. #. Change new toolbutton to dropdown toolbutton, and it can remember the last new file type(select new type menu first), then when you select new menu, it'll create a new file with the last new file type #. Improve command search and pairprog plugin caret display process #. Add auto new version of UliPad check #. Add slice language syntax support #. Add auto pop up project setting dialog when adding directory to directoy browser window #. Add Open Explorer Window Here menu to editoctrl tab context menu #. Add open snippet tool button, change open dirbrowser and open snippet toolbutton to check toolbutton #. Change ``explorer.exe %s`` as ``explorer.exe /e, %s`` in windows platform #. Add copy filename to clipboard menu on document area tab context menu #. Add wrap text feature, via [Edit]->[Format]->[Wrap Text...] New Plugins: #. canvas_test_plugin, you can directly test DC api #. web2py_plugin, supply web2py shell Bug fix: #. Fix webopen twice open bug #. Fix editor shortcuts key caption error #. Fix if set DROP_DOWN_TABS_LIST style, right arrow will disappear bug #. Fix utf-16 convertion bug #. Fix mako tag auto complete bug #issue 14 #. Fix if lines are folded, when goto hiding lines will no effect bug #. Fix DDE bug, thanks to LP #. Fix webopen bug, can't correctly deal with 'mailto:' #. Fix smart tabs bug #. Fix copy and paste lineending is not correct bug #. Fix tab invisible bug after changing size or changing the page title #. Fix template line-ending not match the default line-ending setting #. Fix password widget is not Password type widget bug #. Fix script filename cannot be unicode(chinese) bug #. Fix syntax check exception process bug #. Fix ruler bug UliPad has ported to code.google.com, so you can visit the new project site at: http://code.google.com/p/ulipad, and also visit the new svn address. Recommends using source version. source version download: http://ulipad.googlecode.com/files/ulipad.3.9.zip window exe version: http://ulipad.googlecode.com/files/ulipad.3.9.exe maillist: http://groups.google.com/group/ulipad ulipad snippets site: http://ulipad.appspot.com (hosted by GAE) Hope you enjoy it. -- I like python! UliPad <>: http://code.google.com/p/ulipad/ UliSpot <>: http://ulipad.appspot.com My Blog: http://www.donews.net/limodou From jens at aggergren.dk Tue Apr 29 11:50:38 2008 From: jens at aggergren.dk (Jens) Date: Tue, 29 Apr 2008 08:50:38 -0700 (PDT) Subject: Zope/DTML Infuriating... References: Message-ID: <3473a8d5-e113-464e-825c-e88a7758ce9d@d45g2000hsc.googlegroups.com> On Apr 29, 3:16?pm, Christian Heimes wrote: > Jens schrieb: > > > Hello Everyone. > > > I am relatively new to Zope(using it for a work project) and I was > > wondering if someone here could help me out or at least refer me to a > > decent documentationg for Zope/DTML/Python (at the detail level of > > php.net or Java API reference). ?http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/ > > isn't really detailed enough for my taste. if it doesn't contain a > > exhautive description of all available base classes it's simply no > > good as a reference resource. > > Are you forced to use DTML for the job? ZPT are far superior and easier > to work with, if you have to output HTML. > > Christian For now, I have to use DTML as I am building on an existing solution. I might look into ZPT's but I have limited time and theres no to time at this point to redo everything as ZPT. In the long run we're probably going in a completely different direction, but that a another story. I like some aspects of zope but I find that it ends up sitting between two chairs. On one hand it want's to be a templating language which is easy to get into for novices, but on the other hand you really have be familiar with python to be able to so stuff thats only slighty more complicated then standard SSI. And don't get me started on the whole security philosophy. @Marco: Thanks for the links :-) Python may be one of those really elegant languages, but the reference is really sub standard. Checkout the layout of php.net for comparison. Think what you will about php, but the reference is excellent. For that matter check out msdn section on old-school asp, or even the common-lisp documentation(http://www.lispworks.com/ documentation/HyperSpec/Front/Contents.htm) It's accessibility like that i'm missing. It shouldn't take 10 min and a usenet post to figure to how to basic stuff like string concatenation. And theres still plenty of unanswered questions after checking the reference: - What is the exact definition of the operator e.g. op + (, ) -> , op + (, ) : , op + ( ... - What is the exact operator precedence - Why is it, when primitive data types seem to be objects (similar to javascript), that type casting is done through build-in functions rather than methods, e.g. String.toInt('5') or '5'.toInt() or x = Integer.fromString('5'). From altami0762 at gmail.com Thu Apr 17 15:51:01 2008 From: altami0762 at gmail.com (altami0762 at gmail.com) Date: Thu, 17 Apr 2008 12:51:01 -0700 (PDT) Subject: cabage patch kids Message-ID: <590761ac-184d-4e30-a034-a0aa5ca78a5c@b64g2000hsa.googlegroups.com> cabage patch kids http://cracks.12w.net F R E E C R A C K S From andrei.avk at gmail.com Wed Apr 2 14:50:10 2008 From: andrei.avk at gmail.com (AK) Date: Wed, 02 Apr 2008 13:50:10 -0500 Subject: Python-by-example - new online guide to Python Standard Library In-Reply-To: References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: <47f3c751$0$6477$4c368faf@roadrunner.com> Terry Reedy wrote: > "AK" wrote in message > news:47f2d018$0$6517$4c368faf at roadrunner.com... > > || I'll be glad to hear comments/suggestions/etc: > | > | http://www.lightbird.net/py-by-example/ > > Using - as the example/return delimiter does not work. > If you do not want to substantially lengthen the document by going to > >>>> sqrt(9) > 3 > > then use Python's a comment symbol. > > sqrt(9) # 3 > -or- > sqrt(9) # returns 3 (but I think I prefer the first) > > which clearly is not an arithmetic expression and which can be > cut-and-pasted into the interactive interpreter. This also works nicely > for invalid examples. > > sqrt(-9) # raises ValueError > > Terry Jan Reedy > > > > > > > Thanks to everybody who replied, I will implement the change as per Terry's advice. I'm still considering whether to use the standard interpreter syntax, i.e. >>> ... \n result; my reason for not doing that is that I will often have a whole screen of function / result lines and if I were to add a new line for the result, that'd make two pages out of one, which I think is a bit too much. In current docs there are not so many examples, so that space is not multiplied quite so much, and using interactive interpreter way of showing result is not nearly as much of a problem. However, I'm still thinking this over and it seems that almost everyone wants to see it done in that way, I might still go for two lines. I'll also be posting updates as the work progresses.. thx, -- -ak Tobu | http://www.lightbird.net/tobu/ | Freeform DB / Tagger / PIM Python-by-Example | http://www.lightbird.net/py-by-example/ | Guide to LibRef From bvidinli at gmail.com Thu Apr 17 04:39:23 2008 From: bvidinli at gmail.com (bvidinli) Date: Thu, 17 Apr 2008 11:39:23 +0300 Subject: Fwd: is file open in system ? - other than lsof In-Reply-To: References: Message-ID: <36e8a7020804170139s5986efd1p6fa5f799be0c592@mail.gmail.com> Here is (hope) complete info for my question: i use linux/unix i use python 2.3 my subject is a single file at a time. but i have to check thousands of files in a loop. so, since there is thousands of files to process, i dont want to use like os.system('lsof filename') because lsof is slow regarding, when you called it thousands of times. is there another way, any python command sequence that i can check if a file is open at the time of "before i process file" i am not interested in " the file may be written after i access it.." the important point is " the time at i first access it." my routine is something like: for i in listoffiles: checkfileopen(i) processfile() thats it... i hope this will clear my question.. thank you a lot. ---------- Forwarded message ---------- From: Chris McAloney Date: 16.Nis.2008 17:00 Subject: Re: is file open in system ? - other than lsof To: python-list at python.org On 16-Apr-08, at 9:20 AM, A.T.Hofkamp wrote: > On 2008-04-16, bvidinli wrote: >> is there a way to find out if file open in system ? - >> please write if you know a way other than lsof. because lsof if >> slow for me. >> i need a faster way. >> i deal with thousands of files... so, i need a faster / python way >> for this. >> thanks. > > This is not a Python question but an OS question. > (Python is not going to deliver what the OS doesn't provide). > > Please first find an alternative way at OS level (ie ask this > question at an > appropiate OS news group). Once you have found that, you can think > about Python > support for that alternative. I agree with Albert that this is very operating-system specific. Since you mentioned 'lsof', I'll assume that you are at least using a Unix variant, meaning that the fcntl module will be available to you, so you can check if the file is already locked. Beyond that, I think more information on your application would be necessary before we could give you a solid answer. Do you only need to know if the file is open, or do you want only the files that are open for writing? If you only care about the files that are open for writing, then checking for a write-lock with fcntl will probably do the trick. Are you planning to check all of the "thousands of files" individually to determine if they're open? If so, I think it's unlikely that doing this from Python will actually be faster than a single 'lsof' call. If you're on Linux, you might also want to have a look at the /proc directory tree ("man proc"), as this is where lsof gets its information from on Linux machines. Chris -- http://mail.python.org/mailman/listinfo/python-list -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From fredri8758lupo at gmail.com Wed Apr 23 06:10:11 2008 From: fredri8758lupo at gmail.com (fredri8758lupo at gmail.com) Date: Wed, 23 Apr 2008 03:10:11 -0700 (PDT) Subject: automotive expert program key crack Message-ID: automotive expert program key crack http://cracks.12w.net F R E E C R A C K S From python at bdurham.com Mon Apr 7 14:15:29 2008 From: python at bdurham.com (Malcolm Greene) Date: Mon, 07 Apr 2008 14:15:29 -0400 Subject: Tips for load balancing multiple Python apps on dual/quad core processors? Message-ID: <1207592129.27594.1246549665@webmail.messagingengine.com> I'm looking for tips on how to load balance running multiple Python applications in multi-CPU environments. My understanding is that Python applications and their threads are limited to a specific CPU. Background: I have a Python utility that processes email messages. I suspect there's a lot of idle time while this utility waits on a remote email server. I would like to run as many simultaneous copies of this utility as possible without overwhelming the server these utilities are running on. My thought is that I should write a dispatcher that monitors CPU load and launches/cancels multiple instances of my utility with specific job queues to process. Is there a cross-platform way to monitor CPU load? Is there a pre-existing Python module I should be looking at for building (subclassing) my dispatcher? Thanks! Malcolm From arnodel at googlemail.com Sun Apr 6 12:18:09 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 6 Apr 2008 09:18:09 -0700 (PDT) Subject: A file iteration question/problem References: <47f8eee1$0$759$bed64819@news.gradwell.net> Message-ID: <322f98fd-eb6e-4a05-a8c7-1e0c5329e955@w5g2000prd.googlegroups.com> On Apr 6, 4:40?pm, tinn... at isbd.co.uk wrote: > I want to iterate through the lines of a file in a recursive function > so I can't use:- > > ? ? f = open(listfile, 'r') > ? ? for ln in f: > > because when the function calls itself it won't see any more lines in > the file. ?E.g. more fully I want to do somthing like:- > > def recfun(f) > ? ? while True: > ? ? ? ? str = readline(f) > ? ? ? ? if (str == "") > ? ? ? ? ? ? break; > ? ? ? ? # > ? ? ? ? # do various tests > ? ? ? ? # > ? ? ? ? if : > ? ? ? ? ? ? recfun(f) > > Is there no more elegant way of doing this than that rather clumsy > "while True" followed by a test? > > -- > Chris Green You could use an iterator over the lines of the file: def recfun(lines): for line in lines: # Do stuff if condition: recfun(lines) lines = iter(open(filename)) recfun(lines) Or if you want the filename to be the argument of you function, wrap it in a non-recursive function: def fun(filename): lines = iter(open(filename)) def recfun(): for line in lines: # Do stuff if condition: recfun() recfun() HTH -- Arnaud From shevitz at lanl.gov Tue Apr 29 18:33:02 2008 From: shevitz at lanl.gov (Danny Shevitz) Date: Tue, 29 Apr 2008 22:33:02 +0000 (UTC) Subject: how to convert a multiline string to an anonymous function? Message-ID: Simple question here: I have a multiline string representing the body of a function. I have control over the string, so I can use either of the following: str = ''' print state return True ''' str = ''' def f(state): print state return True ''' and I want to convert this into the function: def f(state): print state return True but return an anonmyous version of it, a la 'return f' so I can assign it independently. The body is multiline so lambda doesn't work. I sort of need something like: def function_constructor(str): f = eval(str) # What should this be return f functions = {} for node in nodes: function[node] = function_constructor(node.text) I'm getting stuck because 'def' doesn't seem to work in an eval function, and exec actually modifies the namespace, so I run into collisions if I use the function more than once. I know I'm missing something stupid here, but I'm stuck just the same... thanks, Danny From nobody at devnull.spamcop.net Mon Apr 14 10:15:58 2008 From: nobody at devnull.spamcop.net (Twayne) Date: Mon, 14 Apr 2008 14:15:58 GMT Subject: Python Workshop References: Message-ID: > Hi, > > We are to hold a workshop about python (introduction). It will be two > one hour and half sessions. > I wanted to know which subjects do you suggest to be presented and is > there a good presentation file (powerpoint or ...) about this on the > net. > We thought that it may be good that first session covers the > introduction, zen of python, python coding syntax and the second > session will be about application, libraries or so. > I really appreciate if you tell me your ideas? Depends; what's the experiene level of the audience? "Introductory" is a pretty vague concept; introductory to what audience? -- -- Regards, Twayne Open Office isn't just for wimps anymore; OOo is a GREAT MS Office replacement www.openoffice.org From bronger at physik.rwth-aachen.de Tue Apr 29 16:34:26 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Tue, 29 Apr 2008 22:34:26 +0200 Subject: Simple unicode-safe version of str(exception)? References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> <67on2nF2ol856U1@mid.individual.net> <87zlrcmxuk.fsf@physik.rwth-aachen.de> Message-ID: <87myncmmct.fsf@physik.rwth-aachen.de> Hall?chen! Russell E. Owen writes: > Torsten Bronger wrote: > >> Russell E. Owen writes: >> >>> [...] >>> >>> So...to repeat the original question, is there any simpler >>> unicode-safe replacement for str(exception)? >> >> Please show us the tracebacks you get becuae unicode(s) must >> fail, too, if there are non-ASCII characters involved. > > Why? > > [...] > >>>> ",".join([unicode(s) for s in e.args]) > u'\xb0' I thought you wanted to have a string. But this is again a unicode. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From bvidinli at gmail.com Mon Apr 14 09:20:56 2008 From: bvidinli at gmail.com (bvidinli) Date: Mon, 14 Apr 2008 16:20:56 +0300 Subject: Python GUI programming and boa or better ? In-Reply-To: <36e8a7020804140620q1a1eb7d2xf4e8b3d753a1b62c@mail.gmail.com> References: <36e8a7020804140620q1a1eb7d2xf4e8b3d753a1b62c@mail.gmail.com> Message-ID: <36e8a7020804140620m2a44b8e8n6c5548d0af8fa0a3@mail.gmail.com> I program in python for about 2-3 monthos. I just started/tested gui programming with many tools. i tested boa last, it is the closest tool to delphi in GUI tools that i used. I managed to play with it a bit. If you have any other tool which you know better than Boa Constructor, please write in here. Any other suggestion about python GUI programming is welcome. thanks. -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From sean.m.mcdaniel at gmail.com Fri Apr 25 00:10:17 2008 From: sean.m.mcdaniel at gmail.com (Sean McDaniel) Date: Fri, 25 Apr 2008 00:10:17 -0400 Subject: Installation in a local directory Message-ID: <2008042500101716807-seanmmcdaniel@gmailcom> Hi y'all, I'm trying to perform a local install of python at work in my user directory. Everything compiles correctly, but I can't seem to tell the configure script the location of the bin and lib directories where I want my stuff. I've think I've passed the correct flags to the 'configure' script. make clean ./configure --enable-shared --prefix=/user/mcdaniel/arch32 make where arch32 contains the the lib and bin directories where I want my python stuff to go. Unfortunately these directories are not written to; everything ends up in the default location from where I ran 'make'. Moreover, if I add a symbolic link from the python binary (which I can run directly without problems) to the bin directory so that my PATH will recognize the new python, I get an error about loading shared libraries. I'm making on a 32 bit new debian system. Thank you for your help, Sean McDaniel From patrickkidd.lists at gmail.com Tue Apr 8 21:01:18 2008 From: patrickkidd.lists at gmail.com (Patrick Stinson) Date: Tue, 8 Apr 2008 19:01:18 -0600 Subject: problem using import from PyRun_String Message-ID: <664bf2b80804081801u79ae9192h90c03c84c1ef35ce@mail.gmail.com> I'm creating a module with PyModule_New(), and running a string buffer as the module's text using PyRun_String and passing the module's __dict__ to locals and globals. I'm having a problem using the import statement from within PyRun_String(). It complains about "__import__ not found", which after a quick grep it looks like the exception is raised from PyExc_EvalFrameEx() in ceval.c after f->f_builtins module doesn't contain "__import__". What __builtin__ module does that point to? a quick print of the content of __builtin__ in CPython code shows a function for the "__import__" key, and I manually added all of the contents of __builtin__ to the module's dict, which was empty before. Any help? Cheers -- Patrick Kidd Stinson http://www.patrickkidd.com/ http://pkaudio.sourceforge.net/ http://pksampler.sourceforge.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From wwzaygvm at gmail.com Wed Apr 16 17:05:53 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 14:05:53 -0700 (PDT) Subject: slovar crack Message-ID: slovar crack http://cracks.12w.net F R E E C R A C K S From sjmachin at lexicon.net Tue Apr 1 17:53:51 2008 From: sjmachin at lexicon.net (John Machin) Date: Tue, 1 Apr 2008 14:53:51 -0700 (PDT) Subject: xlrd and cPickle.dump References: <34e62ddb-477f-4a99-97a5-21a7b148d244@e67g2000hsa.googlegroups.com> <47f22a41@news.mel.dft.com.au> <0d46a213-9f95-43b5-835b-d74d8403626b@c19g2000prf.googlegroups.com> Message-ID: <6acbf9b4-161b-47db-9a91-b2448ee63c34@c26g2000prf.googlegroups.com> On Apr 2, 7:19 am, patrick.wa... at gmail.com wrote: > > How many megabytes is "extremely large"? How many seconds does it take > > to open it with xlrd.open_workbook? > > The document is 15mb ad 50,000+ rows (for test purposes I will use a > smaller sample), 15 Mb is not large. E.g. 120 Mb is large. > but my computer hangs (ie it takes a long time) when > I try to do simple manipulations What do you describe as "simple manipulations"? Please describe your computer, including how much memory it has. > and the documentation leads me to > believe cPickle will be more efficient. The doc says that *IF* you need to read the XLS file multiple times, you can use xlrd.open_workbook() once and save a pickled copy. Then you can c.Pickle.load() from the pickled file multiple times; typically this is about 10 times as fast. BUT this is just a faster way of getting an xlrd.Book object ... not relevant to any subsequent "simple manipulations". You should not be manipulating an xlrd.Book object; treat it as read-only. > If this is not true, then I > don't have a problem (ie I just have to wait), but I still would like > to figure out how to pickle an xlrd object anyways. > > > You only need one of the above imports at the best of times, and for > > what you are attempting to do, you don't need pyExcelerator at all. > > Using pyExcelerator was a guess, because the traditional way didn't > work and I thought it may be because it's an Excel file. Don't guess. If the docs say it wants a file to write to, don't give it None. Especially don't use a function/method call with silly side effects. > Secondly, I > import it twice because sometimes, and I don't know why, PythonWin > does not import pyExcelerator the first time. This has only been true > with pyExcelerator. This seems exceedingly unlikely to me. Try asking on the pywin32 mailing list. > > > > data_path = """C:\test.xls""" > > > It is extremely unlikely that you have a file whose basename begins with > > a TAB ('\t') character. Please post the code that you actually ran. > > you're right, I had just quickly erased my documents and settings > folder to make it smaller for an example. I'm far too astonished by that (and your habit of putting any old bunch of files in your root directory) to make any coherent comment. > > > > Please post the minimal pyExcelerator-free script that demonstrates your > > problem. Ensure that it includes the following line: > > import sys; print sys.version; print xlrd.__VERSION__ > > Also post the output and the traceback (in full). > > As to copy_reg.py, I downloaded Activestate Python 2.4 and that was > it, so I have had no other version on my computer. > > Here's the code: > > import cPickle,xlrd, sys > > print sys.version > print xlrd.__VERSION__ > > data_path = """C:\\test\\test.xls""" > pickle_path = """C:\\test\\pickle.pickle""" > > book = xlrd.open_workbook(data_path) > Data_sheet = book.sheet_by_index(0) > > pickle_file = open(pickle_path, 'w') Use 'wb' ... > cPickle.dump(book, pickle_file) ... use cPickle.dump(book, pickle_file, -1) # latest protocol *I WAS WRONG* (happens sometimes) when I said I couldn't reproduce your problem with Python 2.4; my test/demo/timing code was using -1 by default. Note: as well as not complaining about contained file objects, protocol -1 can be 10 times the speed of protocol 0 and produce a pickle file half the size. > pickle_file.close() > > Here's the output: > > 2.4.3 (#69, Apr 11 2006, 15:32:42) [MSC v.1310 32 bit (Intel)] > 0.6.1 > Traceback (most recent call last): > File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework > \scriptutils.py", line 310, in RunScript > exec codeObject in __main__.__dict__ > File "C:\text analysis\pickle_test2.py", line 13, in ? > cPickle.dump(book, pickle_file) > File "C:\Python24\lib\copy_reg.py", line 69, in _reduce_ex > raise TypeError, "can't pickle %s objects" % base.__name__ > TypeError: can't pickle module objects > > Thanks for the advice! Here's some more: try to *understand* the "hanging" / "simple manipulations" problem before you start implementing solutions. Also, any good reason for sticking with Python 2.4? HTH, John From cwitts at gmail.com Tue Apr 15 05:31:36 2008 From: cwitts at gmail.com (Chris) Date: Tue, 15 Apr 2008 02:31:36 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <1208196168.24295.36.camel@localhost.localdomain> Message-ID: <526792b1-acc2-4e48-8e9f-cc2641134958@k37g2000hsf.googlegroups.com> On Apr 15, 11:22?am, Sjoerd Mullender wrote: > Thomas Dybdahl Ahle wrote: > > On Fri, 2008-04-11 at 03:14 -0700, bdsatish wrote: > >> The built-in function round( ) will always "round up", that is 1.5 is > >> rounded to 2.0 and 2.5 is rounded to 3.0. > > >> If I want to round to the nearest even, that is > > >> my_round(1.5) = 2 ? ? ? ?# As expected > >> my_round(2.5) = 2 ? ? ? ?# Not 3, which is an odd num > > >> I'm interested in rounding numbers of the form "x.5" depending upon > >> whether x is odd or even. Any idea about how to implement it ? > > > This seams to work fine: > > evenRound = lambda f: round(f/2.)*2 > > >>>> [(f*.5, evenRound(f*.5)) for f in xrange(0,20)] > > [(0.0, 0.0),(0.5, 0.0), > > (1.0, 2.0), (1.5, 2.0), (2.0, 2.0), (2.5, 2.0), > > (3.0, 4.0), (3.5, 4.0), (4.0, 4.0), (4.5, 4.0), > > (5.0, 6.0), (5.5, 6.0), (6.0, 6.0), (6.5, 6.0), > > (7.0, 8.0), (7.5, 8.0), (8.0, 8.0), (8.5, 8.0), > > (9.0, 10.0), (9.5, 10.0)] > > No, this does not work:>>> [(f*.25, evenRound(f*.25)) for f in xrange(0,20)] > > [(0.0, 0.0), (0.25, 0.0), (0.5, 0.0), (0.75, 0.0), (1.0, 2.0), (1.25, > 2.0), (1.5, 2.0), (1.75, 2.0), (2.0, 2.0), (2.25, 2.0), (2.5, 2.0), > (2.75, 2.0), (3.0, 4.0), (3.25, 4.0), (3.5, 4.0), (3.75, 4.0), (4.0, > 4.0), (4.25, 4.0), (4.5, 4.0), (4.75, 4.0)] > > x.75 should be rounded up. > > -- > Sjoerd Mullender > > ?signature.asc > 1KDownload even is closer to even.75 than even+1.25. Why should it be rounded up ? From rkmr.em at gmail.com Mon Apr 21 17:53:15 2008 From: rkmr.em at gmail.com (rkmr.em at gmail.com) Date: Mon, 21 Apr 2008 14:53:15 -0700 Subject: dynamically importing a module and function In-Reply-To: References: Message-ID: there was a mistake in my prev mail.. it is not able to successfully import the module. abcde is in directory /home/mark/work/proj1, but it is looking for it in /home/mark from where i am running the script.. though i changed cwd using os.chdir() function > File "/home/mark/app.py", line 5, in > import abcde > ImportError: No module named abcde On Mon, Apr 21, 2008 at 2:46 PM, rkmr.em at gmail.com wrote: > Hi > I have a function data['function'], that I need to import from a file > data['module'], in the directory data['cwd'] > > If I do this from python interactive shell (linux fedora core 8) from > dir /home/mark it works fine: > > cwd = data['cwd'] > os.chdir(cwd) > print os.getcwd() > module = __import__(data['module']) > function = getattr(module, data['function']) > > But if I put this in a file /home/mark/work/common/funcq.py and run it > from /home/mark, it throws me error like this.. how to fix this? it > imports the module successfully, but it is not looking for subsequent > modules in the os.getcwd().. > > /home/mark/work/proj1 > Traceback (most recent call last): > File "/home/mark/work/common/funcq.py", line 60, in > if __name__ == '__main__':do() > File "/home/mark/work/common/funcq.py", line 33, in do > module = __import__(data['module']) > File "/home/mark/app.py", line 5, in > import abcde > ImportError: No module named abcde > From grante at visi.com Wed Apr 16 12:35:27 2008 From: grante at visi.com (Grant Edwards) Date: Wed, 16 Apr 2008 11:35:27 -0500 Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <6rGdnfc8nvJSt5vVnZ2dnUVZ_oDinZ2d@visi> On 2008-04-16, Michael Torrie wrote: >> My workplace doesn't offer NNTP, so there is no good way to browse >> c.l.py here. Browse it via the mailing list using gmane.org. There are no ads and your postings won't get plonked by everybody. >> And I haven't been able to get NNTP to work from my home >> either. > > I rarely use NNTP these days. I access c.l.py exclusively via > e-mail, and that works very well. In some cases there is a > lot of spam that gets filtered out of the nntp side, but makes > it through to the smtp side (like that religious spam a few > months back). But I see absolutely none of the google groups > problems that Grant mentioned. I view my python list mail in > gmail, and get about 1-2 spam messages a day in the python > list. > > This official python list is one of the few lists that's even > still on nntp. All my other ones (gnome, gtk, openldap, > clamav, freeradius, etc) are all e-mail mailing lists only and > it works very well. In fact, I think it's much better since > list subscription can actually be controlled by someone. Since gmane.org makes all the e-mail lists I care about available via NNTP, I can still use a news client to read "e-mail mailing lists only". I've always found that news clients are much better at handling things like mailing lists than e-mail clients. -- Grant Edwards grante Yow! Quick, sing me the at BUDAPEST NATIONAL ANTHEM!! visi.com From jcd at unc.edu Thu Apr 17 11:39:53 2008 From: jcd at unc.edu (J. Cliff Dyer) Date: Thu, 17 Apr 2008 11:39:53 -0400 Subject: More Fun With MySQL and Images In-Reply-To: <4dc0cfea0804170752x789cce43xe1ea6aeba498ccd1@mail.gmail.com> References: <4dc0cfea0804170742g39965533yfaf260bcf4da4301@mail.gmail.com> <4dc0cfea0804170752x789cce43xe1ea6aeba498ccd1@mail.gmail.com> Message-ID: <1208446793.4433.18.camel@aalcdl07.lib.unc.edu> On Thu, 2008-04-17 at 09:52 -0500, Victor Subervi wrote: > Never mind. Apparently, these tags throw it for that loop: > print '\n' > I?m surprised they would, but gratified I found the problem. > Victor > > Why does that surprise you? A jpeg has a well-defined header that tells whatever application is rendering it what to look for. By putting those tags at the beginning of the data sent to your browser, you're no longer getting a well-formed jpeg. The header is wrong. As an experiment, if you're on *nix, or have access to a decent shell, try this: $ echo '' > newfile.jpg $ cat /path/to/any_normal_jpeg >> newfile.jpg $ echo '' >> newfile.jpg If you don't have access to a shell, open a JPEG with your favorite text editor, and manually add "" to the beginning, and save it out. Then try to open newfile in any piece of software of your choosing. It's no longer a well-formed jpeg, so it won't work. That's exactly what you're asking the browser to do. I guess this isn't really python related, so my apologies for that. Cheers, Cliff -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill From n00m at narod.ru Sat Apr 26 16:12:43 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 13:12:43 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> Message-ID: <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> >> char vs[1002000][99]; In the file 1001622(or so) records like phone number + f/l names. So the reserving makes sense, i think. Populating of vector is by zillion times slower. >> Is there an implementation of f.readlines on the internet somewhere? I was greatly surprised how fast it is. As a matter of fact, it's the point of my message here. >> BTW why are you declaring the array as 99 and pass 999 to fgets to read a line? It doesn't matter. All the same, reading of a current line stopped at '\n'. Big number 999(9999,99999,...) just ensures that each line is read up to its end. >> fgets is part of the standard C++ library and it lives in the std namespace. I thought it's from . Anyway, it does not matter. PS Thanx for the code. 2All: Origin of my "discovery" is from http://www.spoj.pl/ranks/SBANK/start=400 I never thought it can be done in Python (there are a couple of Py solutions even faster than mine) and without stuff like radix sort etc. From sjoerd at acm.org Mon Apr 21 02:59:34 2008 From: sjoerd at acm.org (Sjoerd Mullender) Date: Mon, 21 Apr 2008 08:59:34 +0200 Subject: Is massive spam coming from me on python lists? In-Reply-To: <480C2DC6.4050701@aim.com> References: <480C2DC6.4050701@aim.com> Message-ID: <480C3B56.40909@acm.org> On 2008-04-21 08:01, Brian Vanderburg II wrote: > I've recently gotten more than too many spam messages and all say > Sender: python-list-bounces+my=email.address at python.org. I'm wondering > if my mail list registration is now being used to spam myself and > others. If so, sorry, but I'm not the one sending messages if other are > getting them even though Sender seems to include my address (I'm not > sure about mail headers so I don't know how From: is different than > Sender:) Anyway, it seems to be a bunch of spam emails about cracks and > stuff. > > Brian Vanderburg II That is just mailman (the mailing list software) keeping track of things. If there were a bounce, mailman can determine from the address of the bounce message (the bounce gets sent back to the Sender, not the From) which address bounced. So *all* python-list messages you get have that Sender. In other words, these spams do not come from you. -- Sjoerd Mullender From kyosohma at gmail.com Wed Apr 16 13:49:10 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 16 Apr 2008 10:49:10 -0700 (PDT) Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: On Apr 16, 12:40 pm, "D'Arcy J.M. Cain" wrote: > On Wed, 16 Apr 2008 08:23:50 -0700 (PDT) > > Mike Driscoll wrote: > > My workplace doesn't offer NNTP, so there is no good way to browse > > c.l.py here. And I haven't been able to get NNTP to work from my home > > either. > > Hi Mike; > > I am half way to killing Google groups myself. Your message, and > allother Google groups messages, is coloured so that I can evaluate how > much I will miss. So far it looks like it will make reading this group a > whole lot more pleasant and so I will probably kill them soon. > > There are alternatives. I run an ISP http://www.Vex.Net/ > that offers NNTP access to my shell users. You can also receive > this group as a mailing list which is how I read it. Google is not the > only option out there. > > -- > D'Arcy J.M. Cain | Democracy is three wolveshttp://www.druid.net/darcy/ | and a sheep voting on > +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. I don't think I like the email list idea all that much. I'm already on a number of them and they fill up my box like crazy. Besides that, in email format it's hard to follow the thread, so one moment I'm reading about the latest ding dong and the next is a response to a post from last week. But I agree...there are other alternatives. I'll have to start trying them again I suppose. Mike From deets at nospam.web.de Wed Apr 23 08:26:23 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 23 Apr 2008 14:26:23 +0200 Subject: Subprocess module In-Reply-To: References: Message-ID: <678o84F2mkgm2U1@mid.uni-berlin.de> Dominique.Holzwarth at ch.delarue.com schrieb: > Hello all > > I want to convert a tex file into a pdf by using pdflatex. For that, I thought the 'subprocess' module might be a good option. My code doesn't work at all tho: > > Import os, subprocess > > def main(): > scriptpath = os.path.dirname(__file__) > > p = subprocess.Popen("pdflatex --include-directory=%s --output-directory=%s/output --aux-directory=%s/temp --interaction=nonstopmode myFile.tex" > % (scriptpath, scriptpath, scriptpath), > stdin=subprocess.PIPE, > stdout=subprocess.PIPE, > stderr=subprocess.PIPE, > shell=True, > cwd=scriptpath) > (child_stdin, > child_stdout, > child_stderr) = (p.stdin, p.stdout, p.stderr) > print 'stdin' > print child_stdin > print 'stdout' > print child_stdout > print 'stderr' > print child_stderr > > When I run that code I get the following printouts: > > stdin > ', mode 'wb' at 0x009E7968> > stdout > ', mode 'rb' at 0x009E7A40> > stderr > ', mode 'rb' at 0x009E79F8> > Done Just a guess - but how about consuming the very verbose latex ouptut? Otherwise latex will stop when the stdout-pipe is full. And beware of the interactive prompte of latex - that thing has bitten me more than once. Diez From tjreedy at udel.edu Mon Apr 7 16:16:24 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 7 Apr 2008 16:16:24 -0400 Subject: reading dictionary's (key,value) from file References: <974814d3-59f0-49ec-9b4d-9f5dd7dfaf54@q24g2000prf.googlegroups.com> Message-ID: You can use execfile (or exec, in 3.0) function to execute code in a file in the present context. From fredrik at pythonware.com Mon Apr 7 02:52:08 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 07 Apr 2008 08:52:08 +0200 Subject: How to get an XML DOM while offline? In-Reply-To: <47F9BB5B.30604@behnel.de> References: <47F9BB5B.30604@behnel.de> Message-ID: Stefan Behnel wrote: >> Is there a simpler way to read the iTunes XML? (It's merely a plist, >> so the format is much simpler than general XML.) > > Try lxml. Since version 2.0, its parsers will not access the network unless > you tell it to do so. > > http://codespeak.net/lxml which makes it true for all ET implementations (the whole idea that parsing a file should result in unexpected network access is of course a potential security risk and one of a number of utterly stupid design decisions in XML). you'll find plist reading code here, btw: http://effbot.org/zone/element-iterparse.htm#incremental-decoding replace the import with "from xml.etree import cElementTree" if you're running 2.5. (not sure if that one works with lxml, though, but that should be fixable. you can at least reuse the unmarshaller dict). From weiss02121 at gmail.com Tue Apr 15 19:49:00 2008 From: weiss02121 at gmail.com (weiss02121 at gmail.com) Date: Tue, 15 Apr 2008 16:49:00 -0700 (PDT) Subject: lindsay lohan breast Message-ID: <3f70fba3-fa43-404e-9fbb-0aedc889a629@t12g2000prg.googlegroups.com> Just few link on some Lindsay Lohan Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From sgeiger at ncee.net Tue Apr 15 09:27:00 2008 From: sgeiger at ncee.net (Shane Geiger) Date: Tue, 15 Apr 2008 08:27:00 -0500 Subject: hw to program on python In-Reply-To: <66jo14F2jfjnbU1@mid.uni-berlin.de> References: <2732d09a-b0e6-4ae6-a826-9fa375fb3e86@q10g2000prf.googlegroups.com> <66jo14F2jfjnbU1@mid.uni-berlin.de> Message-ID: <4804AD24.8000309@ncee.net> ashish, While you are waiting for Diez to arrive, you should check out this Web site: http://www.google.com. It has some interesting content. Perhaps you can find information there that will help you to ask a better question. Here is another page you should look at: http://www.catb.org/~esr/faqs/smart-questions.html All joking aside, this hasn't been an easily answered question. The creator of Python, Guido, was asking a similar question not so long ago: http://www.artima.com/weblogs/viewpost.jsp?thread=146149 The latest and greatest from Guido's company is Google App Engine, which you might want to learn about. http://www.techcrunch.com/2008/04/07/google-jumps-head-first-into-web-services-with-google-app-engine/ http://code.google.com/appengine/ http://www.computerworld.com.au/index.php/id;1913502382;fp;4;fpid;611908207 http://googleblog.blogspot.com/2008/04/developers-start-your-engines.html http://googleappengine.blogspot.com/2008/04/introducing-google-app-engine-our-new.html Shane Diez B. Roggisch wrote: > ashish wrote: > > >> hi , >> python experts i want some help from u people just mail me how to >> write scripts for web applications (like form coding for login page, >> etc). >> >> >> i m waiting.... for ur reply by >> > > While you are waiting, would a nice back-rub & and a good portion of powder > sugar gently blown up your behind be in order? I'd plain love to drop by & > give that to you, to make the dreaded waiting for the amassing expert > advice a bit more comfortable! > > Diez > -- Shane Geiger IT Director National Council on Economic Education sgeiger at ncee.net | 402-438-8958 | http://www.ncee.net Leading the Campaign for Economic and Financial Literacy From pavlovevidence at gmail.com Mon Apr 14 11:20:13 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 14 Apr 2008 08:20:13 -0700 (PDT) Subject: Java or C++? References: Message-ID: On Apr 14, 2:44 am, s0s... at gmail.com wrote: > Hello, I was hoping to get some opinions on a subject. I've been > programming Python for almost two years now. Recently I learned Perl, > but frankly I'm not very comfortable with it. Now I want to move on > two either Java or C++, but I'm not sure which. Which one do you think > is a softer transition for a Python programmer? Which one do you think > will educate me the best? If you weren't comfortable with Perl my bet is that you'll be less comfortable with C++ than Java. It's softer transition to Java than to C++ from just about any starting point. Carl Banks From dickinsm at gmail.com Sun Apr 13 10:28:22 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Sun, 13 Apr 2008 07:28:22 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> <01db54ab-1fca-4a51-8b98-510de224f40a@y21g2000hsf.googlegroups.com> <8e6dbc15-98f2-441d-bba4-d9ddb36f482d@i36g2000prf.googlegroups.com> Message-ID: On Apr 13, 4:18?am, Lie wrote: [...] > it and there is nothing else in it, but in the second number range > (barely above 1 to 2) the number 1.0 is not included while the number > 2.0 is contained in it, clearly not a clean separation of numbers in > the form of y.x where y is pre-determined and x is variable from other > possible values of y. Have you considered the fact that the real numbers of the form 1.xxxxx... are those in the range [1.0, 2.0], including *both* endpoints? That is, 2.0 = 1.999999... Similarly, the midpoint of this range can be written both in the form 1.500000... and 1.499999... This is relevant if you think of rounding as an operation on *decimal representations* of real numbers rather than as an operation on real numbers themselves. I'm not sure which point of view you're taking here. Either way, your arguments don't change the fact that the average rounding error is strictly positive for positive quantized results, under round-half-away-from-zero. Mark From stef.mientki at gmail.com Sat Apr 19 18:21:57 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Sun, 20 Apr 2008 00:21:57 +0200 Subject: Frame work for simple physics web applications In-Reply-To: References: <2b0b8b6c-8086-4bf6-8f47-27bc5c9c788c@v23g2000pro.googlegroups.com> <6bdd161d-6e92-4de6-8dba-d5c11b08990f@a22g2000hsc.googlegroups.com> Message-ID: <480A7085.6040002@gmail.com> Rick Muller wrote: > On Apr 19, 2:44 pm, globalrev wrote: > > >> www.vpython.orgmight be what you are looking for. >> > > Except, if I'm not mistaken, vpython isn't a web framework. It would > work if I wanted to write some python scripts and have other people > run them, but I want to run everything through a web page, so I don't > have to worry about installing python on everyone's computer So what should the students use when they want to explore quantum computing outside the scope you're offering ? C++, MatLab, LabView perhaps, this looks to me like an unique opportunity to promote Python. > and > distributing updates of all of my scripts. > I'm not familiar with this, but isn't it possible to run scripts from a website locally ? cheers, Stef From paul at science.uva.nl Fri Apr 25 08:16:44 2008 From: paul at science.uva.nl (Paul Melis) Date: Fri, 25 Apr 2008 14:16:44 +0200 Subject: Problem building python in virtual machine running centos In-Reply-To: References: Message-ID: Paul Boddie wrote: > On 25 Apr, 03:05, Alexandre Gillet wrote: > >>I am trying to build python-2.4.5 on Centos 5.1, which is a virtual >>machine running with xen. >>I am not able to build python. The compilation crash with the following: >>gcc -pthread -c -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. >>-I./Include -DPy_BUILD_CORE -o Objects/unicodeobject.o >>Objects/unicodeobject.c >>In file included from ./Include/Python.h:76, >> from Objects/unicodeobject.c:39: >>./Include/object.h:228: internal compiler error: Segmentation fault >>Please submit a full bug report, >>with preprocessed source if appropriate. >>See for instructions. >>The bug is not reproducible, so it is likely a hardware or OS problem. >> >>Any suggestion of what am I doing wrong? > > > You say that the bug is not reproducible, so that means that you can "The bug is not reproducible, so it is likely a hardware or OS problem." This line is printed by GCC itself, not the OP Paul > sometimes compile Python, or does the crash always happen when > compiling some file (not necessarily the one mentioned above)? I think > I've only ever seen a reproducible gcc crash once, and that had > something to do with a C++ source file which I then split into two and > was able to compile as these two separate parts. You might want to > check the gcc version (gcc -v) and to look at bug fixes in any later > versions. Generally, if you get an internal error in gcc, you aren't > doing anything wrong yourself. > > Paul From musiccomposition at gmail.com Wed Apr 2 22:29:09 2008 From: musiccomposition at gmail.com (Benjamin) Date: Wed, 2 Apr 2008 19:29:09 -0700 (PDT) Subject: Classes in modules References: <0cace2e1-6dbc-428f-9e53-ffb99ba42aab@e6g2000prf.googlegroups.com> Message-ID: <3d4c576e-127a-4499-bdbe-3c4faecd2275@a70g2000hsh.googlegroups.com> On Apr 2, 8:05 pm, hexusne... at gmail.com wrote: > I'm trying to get this source code split into multiple files: > > http://pygermanwhist.googlecode.com/files/pygermanwhist.12.py > > I've been trying to make so that I have one class per file for easier > readability. My problem is that the interpreter keeps saying that it > can't find methods and so forth whenever I try to split the code up. Have you read the modules part of the tutorial? http://docs.python.org/tut/node8.html > > This has been a recurring problem for me in languages such as C++ and > Java. I'm used to programming in C. From mcknight0219 at gmail.com Tue Apr 1 22:44:04 2008 From: mcknight0219 at gmail.com (Jimmy) Date: Tue, 1 Apr 2008 19:44:04 -0700 (PDT) Subject: the scaling of pics in pygame Message-ID: <49d8b8ae-08e3-4e86-9ced-2804b6dec4e5@b5g2000pri.googlegroups.com> Hi, everyone I am using Pygame to write a small program. I tried to load a .jpg picture into the screen, however, the size of the pic doesn't fit into the window properly. Can anyone tell me how to scale the picture into the window? thanks! From terry.yinzhe at gmail.com Mon Apr 28 19:28:12 2008 From: terry.yinzhe at gmail.com (Terry) Date: Mon, 28 Apr 2008 16:28:12 -0700 (PDT) Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> <18c1e6480804270653r2e075061wf442b7b7d9f50ff6@mail.gmail.com> <5b8a7008-d463-41cb-ba67-1440fe00dfb4@y21g2000hsf.googlegroups.com> Message-ID: On Apr 28, 10:48 pm, "dcof... at gmail.com" wrote: > I've never used it myself but you may find candygram interesting;http://candygram.sourceforge.net, which AFAIK implements Erlang-style > message queues in Python. Thank you. I will look at candygram and stackless. I believe my solution lies in either of them. From jzgoda at o2.usun.pl Mon Apr 7 05:00:55 2008 From: jzgoda at o2.usun.pl (Jarek Zgoda) Date: Mon, 07 Apr 2008 11:00:55 +0200 Subject: csv.DictReader and unicode In-Reply-To: References: Message-ID: Laszlo Nagy napisa?(a): > This program > > fin = codecs.open(fname,"r",encoding="UTF-8") > eader = csv.DictReader(fin) > for values in reader: > pass > > results in: > > File "run.py", line 23, in process_file > for values in reader: > File "/usr/local/lib/python2.5/csv.py", line 83, in next > row = self.reader.next() > UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in > position 13: ordinal not in range(128) > > As you can see the exception is thrown in csv.py. How it is possible? > The csv.DictReader should not use ascii codec for anything, because the > file encoding is UTF-8. Reader works with byte strings, not unicode objects. -- Jarek Zgoda Skype: jzgoda | GTalk: zgoda at jabber.aster.pl | voice: +48228430101 "We read Knuth so you don't have to." (Tim Peters) From uniontelecardsindia at gmail.com Tue Apr 22 17:17:45 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:17:45 -0700 (PDT) Subject: Nasty gangbang gay trio in the fields Message-ID: Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From garionphx at gmail.com Thu Apr 17 17:19:45 2008 From: garionphx at gmail.com (John Sutherland) Date: Thu, 17 Apr 2008 14:19:45 -0700 Subject: Building an RPM Message-ID: <2F12200B-934E-44D2-94E8-D3E4BDE8FB56@gmail.com> Hi everyone.. I'm attempting to build an RPM for Python 2.5.2, using the spec file found in the standard tarball (Misc/RPM).. Currently, its failing cause it hasn't 'compiled' the tools .pyc and .pyo's, saying the files aren't found. Anyone have any ideas? (running on CentOS 4.3) --John From dotancohen at gmail.com Sat Apr 19 18:22:06 2008 From: dotancohen at gmail.com (Dotan Cohen) Date: Sun, 20 Apr 2008 01:22:06 +0300 Subject: Python for Series 40 Nokia? In-Reply-To: References: Message-ID: <880dece00804191522hde8c4d4u7678b1cecd29df60@mail.gmail.com> On 18/04/2008, colemichae at gmail.com wrote: > On Apr 18, 8:46 am, "Dotan Cohen" wrote: > > I had once heard something about python running on a Series 40 Nokia, > > but I am unable to google anything concrete. Might it have been > > Jython? Is there a known implementation of Python for the series 40 > > (which is not Symbian, by the way)? Will Jython work in such an > > environment? > > > > Thanks in advance. > > there is a comment here of using jython on a nokia S40 > Nokia 7210 SDK for Nokia Series 40 platform. > http://bookshelf.sourceforge.net/en/src-build.html > > So i think i will work. > > I am using a S60 and works well, I have a GPS program in Python, > Editors, Ogg player, and other assorted items. > > I myself purchased the Nokia N70 purely because of the Python ability > it had.. Thanks. I have tried to avoid Symbian phones as they are slow and irresponsive to input in my experience. That said, I loved my N-Gage and irresponsiveness really was my only complaint with the device. Perhaps if the newer models are more responsive, then I will switch so that I can run Python on it. Thanks. Dotan Cohen http://what-is-what.com http://gibberish.co.il ?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? From ewertman at gmail.com Sat Apr 26 18:02:58 2008 From: ewertman at gmail.com (Eric Wertman) Date: Sat, 26 Apr 2008 18:02:58 -0400 Subject: learning with python question (HtTLaPP) In-Reply-To: <53d6254f-895f-48fb-8ab9-3929c403f11b@v23g2000pro.googlegroups.com> References: <98acecbd-9de2-4ebf-927b-ac6bc1fbc3fd@b5g2000pri.googlegroups.com> <53d6254f-895f-48fb-8ab9-3929c403f11b@v23g2000pro.googlegroups.com> Message-ID: <92da89760804261502h4f7aea3p739a176ef14f06b3@mail.gmail.com> > Is the way I wrote the function inherently wrong? What I wrote I would not say that. I think a lot of people probably start off like that with python. You'll find in most cases that manually keeping counters isn't necessary. If you really want to learn python though, I would suggest using built in functions and libraries as much as possible, as that's where the real power comes from (IMO). > returns the sequence, however I'm trying to make the output match for > the letters in the string entered, not necessarily the string > sequence. > Only the sequence shows up 'uzi'. I don't get words like 'unzip' or > 'Zurich' . I've only barely started on invocation and maybe writing > something like I'm describing is above what level I'm currently at. This would be a more difficult approach.. Where you are doing the comparison step: if letters in line.strip(): It's trying to match the exact string "uzi", not any of the individual letters. You would need to look for each letter independently and then make sure they were in the right order to match the other words. From workitharder at gmail.com Thu Apr 3 12:38:31 2008 From: workitharder at gmail.com (bukzor) Date: Thu, 3 Apr 2008 09:38:31 -0700 (PDT) Subject: Directed Graph Traversal References: <804682cb-2da6-4d85-83d4-c7425c498534@p25g2000hsf.googlegroups.com> Message-ID: <8495625e-608e-4c8c-b7f8-f5e47e09082d@c19g2000prf.googlegroups.com> On Apr 2, 8:33 pm, Scott David Daniels wrote: > bukzor wrote: > > Can someone point me in the direction of a good solution of this? I'm > > using it to construct a SQL query compiler, .... > > Given a directed graph and a list of points in the graph, what is the > > minimal subgraph that contains them all? It is preferable that the > > subgraph is a tree. > > I did something nice (but non-redistributable) on this once: here is the > driving intuition: > > * Start with every point a distinct color. > * Add all points adjacent in the digraph as the same color; merge > colors as you join them. > * When you are down to to a single color, you have the minimal solution > in the set you've chosen. > > I actually did a cheapest-first search; adding an edge each time. > There is a post-join pruning step that was (as I recall) fairly simple. > > -Scott David Daniels > Scott.Dani... at Acm.Org That sounds like a kind of iterative deepening search, which is what I'm planning to do. Once I have it written up, I'll post for your pythonic enjoyment. --Buck From nospam at nospam.com Sat Apr 26 17:57:25 2008 From: nospam at nospam.com (Gilles Ganault) Date: Sat, 26 Apr 2008 23:57:25 +0200 Subject: [py2exe] What to download when updating? Message-ID: Hello Out of curiosity, if I recompile a Python (wxPython) app with py2exe, can I have customers just download the latest .exe, or are there dependencies that require downloading the whole thing again? FWIW, here's the list of files that were created after running py2exe: myprog.exe bz2.pyd library.zip MSVCR71.dll python25.dll unicodedata.pyd w9xpopen.exe wxbase28uh_net_vc.dll wxbase28uh_vc.dll wxmsw28uh_adv_vc.dll wxmsw28uh_core_vc.dll wxmsw28uh_html_vc.dll _controls_.pyd _core_.pyd _gdi_.pyd _misc_.pyd _windows_.pyd Thank you. From corvettecraz92 at gmail.com Tue Apr 8 21:01:01 2008 From: corvettecraz92 at gmail.com (corvettecraz92 at gmail.com) Date: Tue, 8 Apr 2008 18:01:01 -0700 (PDT) Subject: text adventure game problem Message-ID: okay, I'm having this one problem with a text adventure game. It's kind of hard to explain, but I'll do my best. [code] def prompt_kitchen(): global gold gold_taken = False while True: prompt_kit = raw_input('>') if prompt_kit == 'examine cabinet 1' and not gold_taken: print '''This cabinet has a lot of cups in it with all different designs and shapes. Where are the people anyway? How come there's nobody here? In one of the cups you find 8 gold.''' gold = gold+8 gold_taken = True pass4() elif prompt_kit == 'examine cabinet 1' and gold_taken: print \ '''This cabinet has a lot of cups in it with all different designs and shapes. Where are the people anyway? How come there's nobody here?''' pass4() def pass4(): global gold print 'You have', gold, 'gold' pass [/code] Okay, now for my problem. In the above function, there's the option to examine a cabinet and get 8 gold. (everyone here knows that...but I'm just trying to state my problem...) Unfortunately, it kind of doesn't work. After the first time I 'examine cabinet 1' in my game, I get 8 gold and I can't get it again. But, If I leave the room and come back to it, then it's as if I had never gotten the gold the first time, and I can get it again. How do I fix this? From carlwuhwdmckay at gmail.com Mon Apr 21 02:07:04 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:07:04 -0700 (PDT) Subject: 89th mp brigade patch Message-ID: <189bd725-d100-4740-ba74-5d06ff492eb3@l64g2000hse.googlegroups.com> 89th mp brigade patch http://cracks.00bp.com F R E E C R A C K S From arnodel at googlemail.com Mon Apr 14 11:55:35 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Mon, 14 Apr 2008 08:55:35 -0700 (PDT) Subject: eval modifies passed dict References: <2b2398b1-042e-46bb-b840-ea9e07d87bd1@2g2000hsn.googlegroups.com> Message-ID: <0bc1464d-684e-476f-b9f3-800325b0a82b@y18g2000pre.googlegroups.com> On Apr 14, 4:23?pm, Janto Dreijer wrote: > It seems eval is modifying the passed in locals/globals. This is > behaviour I did not expect and is really messing up my web.py app. Reading the documentation would be a good start: From http://docs.python.org/lib/built-in-funcs.html: eval( expression[, globals[, locals]]) The arguments are a string and optional globals and locals. If provided, globals must be a dictionary. If provided, locals can be any mapping object. Changed in version 2.4: formerly locals was required to be a dictionary. The expression argument is parsed and evaluated as a Python expression (technically speaking, a condition list) using the globals and locals dictionaries as global and local name space. If the globals dictionary is present and lacks '__builtins__', the current globals are copied into globals before expression is parsed. -- Arnaud From pDOTpagel at helmholtz-muenchen.de Fri Apr 11 10:28:47 2008 From: pDOTpagel at helmholtz-muenchen.de (Philipp Pagel) Date: Fri, 11 Apr 2008 14:28:47 +0000 (UTC) Subject: Graphs in Python References: Message-ID: greg_kr wrote: > You should use Python with R. Google for Rpy, this is the best > Graphing you can do with Python The OP was refering to graph as in 'graph-theory', not plotting data. Of course, R has some packages for dealing with graphs in the former sense but I don't think that's a good solution to the OP's problem. cu Philipp -- Dr. Philipp Pagel Lehrstuhl f. Genomorientierte Bioinformatik Technische Universit?t M?nchen http://mips.gsf.de/staff/pagel From pydev at rscorp.ab.ca Tue Apr 29 14:42:41 2008 From: pydev at rscorp.ab.ca (Scott SA) Date: Tue, 29 Apr 2008 12:42:41 -0600 Subject: @classmethod question In-Reply-To: <481048cf$0$13051$426a74cc@news.free.fr> Message-ID: On 4/24/08, Bruno Desthuilliers (bruno.42.desthuilliers at websiteburo.invalid) wrote: >> It is a series of convenience methods, in this case I'm interacting >> with a database via an ORM (object-relational model). > >out of curiosity : which one ? I'm rapidly becoming a "django junkie"^TM >> I want the ability >> to call a class-ojbect and get related values, or pass some criteria and >> get related values for them without collecting the records first as >> instances, then iterating them. I need to call this from several places >> so I want to be DRY (don't repeat yourself). >> >> The easiest way to describe this as an analogy would be like having a >> recipie for cookies and wanting to know all of the ingredients ahead of >> time. Then, at another time, wanting to know what all the ingredients >> would be to make cookies, cake and bread (i.e. complete shopping list). > >> cookie_recipie = RecipieClass.get_recipie('cookies') >> cookie_recipie.get_ingredients() >> 2C Flour >> 0.5 C Sugar >> ... >> >> RecipieClass.get_ingrendients(['cookies','cake','bread']) >> 8C Flour >> 2C Sugar >> ... > > > Of course any suggestions on how this might be better approached >would > be interesting too. > >Why do you want the same method to do two different things ? You clearly >have two distincts methods doing different things here, and as a user of In retrospect, my example was poorer than I first thought - or was it my spec. Regardless, it wasn't quite right. The question/premise should have been: Is there an effective/accptable way to include class-related utilities that are callable _without_ instantiating an object? I now get the feeling that some of what I was thinking of would be considered bad form and should be separated into the application or a library of sorts. > your code I'd find your API confusing. May I suggest a much simpler >approach: > >class Recipies(object): > @property > def ingredients(self): > return > > @classmethod > def get_ingredients_for(cls, *id_recipies): > return > >print Recipie.get('cookie').ingredients >print Recipies.get_ingredients_for('cookie', 'cake', 'bread') Yes, thank you. While my example didn't accurately portray my original thoughts, this is an educational example of merit. I'm still crossing the bridge of conceptual understanding into practical application. Decoration appears very useful, it's practical application requires a level of thought I'm not fluent. Google is helping. >My 2 cents... You're short-changing yourself ;-) Thanks for your input, Scott From mdw at distorted.org.uk Tue Apr 22 08:47:26 2008 From: mdw at distorted.org.uk (Mark Wooding) Date: Tue, 22 Apr 2008 12:47:26 +0000 (UTC) Subject: Segfault accessing dictionary in C Python module References: Message-ID: Mitko Haralanov wrote: > value = PyDict_GetItem (new_dict, key); You're not calling Py_DECREF on this value are you? That's a no-no, since you're borrowing the dictionary's reference. -- [mdw] From gagsl-py2 at yahoo.com.ar Mon Apr 28 21:04:42 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 28 Apr 2008 22:04:42 -0300 Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> <87od7ue2ne.fsf@mulj.homelinux.net> Message-ID: En Mon, 28 Apr 2008 19:29:33 -0300, escribi?: > A question regarding cStringIO.StringIO(): is there a way to do get > getvalue() to return all the bytes after the current file position > (not before)? For example > > buf = cStringIO.StringIO() > buf.write("foo bar") > buf.seek(3) > buf.getvalue(True) # the True argument means > # to return the bytes up > # to the current file position > > That returns 'foo'. Is there a way to get it to return ' bar'? buf.read() - the obvious answer, once you know it :) -- Gabriel Genellina From bj_666 at gmx.net Mon Apr 28 07:39:45 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 28 Apr 2008 11:39:45 GMT Subject: Need help on left padding References: Message-ID: <67lrc1F2o7iv7U3@mid.uni-berlin.de> On Mon, 28 Apr 2008 04:37:02 -0700, rajesh kataraki wrote: > My requirement is I am using one variable ex. var = 5 which is > integer. > And this variable, I m using in some string. But I want this var > to be used as 005 again integer in this string. In [22]: '%03d' % 5 Out[22]: '005' Ciao, Marc 'BlackJack' Rintsch From hdante at gmail.com Fri Apr 25 20:13:02 2008 From: hdante at gmail.com (hdante) Date: Fri, 25 Apr 2008 17:13:02 -0700 (PDT) Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> Message-ID: <5c5e740d-6974-4aa6-8a79-468ce68a6e37@e53g2000hsa.googlegroups.com> On Apr 25, 7:39?pm, s0s... at gmail.com wrote: > I wanted to ask for standard ways to receive data from a socket stream > (with socket.socket.recv()). It's simple when you know the amount of > data that you're going to receive, or when you'll receive data until > the remote peer closes the connection. But I'm not sure which is the > best way to receive a message with undetermined length from a stream > in a connection that you expect to remain open. Until now, I've been > doing this little trick: > > data = client.recv(256) > new = data > while len(new) == 256: > ? ? new = client.recv(256) > ? ? data += new > > That works well in most cases. But it's obviously error-prone. What if > the client sent *exactly* two hundred and fifty six bytes? It would > keep waiting for data inside the loop. Is there really a better and > standard way, or is this as best as it gets? > > Sorry if this is a little off-topic and more related to networking, > but I'm using Python anyway. > > Thanks, > Sebastian done = False remaining = '' while done == False: data = client.recv(256) done, remaining = process(remaining + data) PS: are you sure you shouldn't be using RPC or SOAP ? From gagsl-py2 at yahoo.com.ar Wed Apr 16 19:17:40 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 20:17:40 -0300 Subject: import hooks References: <664bf2b80804151814g480eed02w739047f84d9deb6b@mail.gmail.com> <664bf2b80804160504x72c870d8pdbfe8105a0c5ed11@mail.gmail.com> Message-ID: En Wed, 16 Apr 2008 09:04:36 -0300, Patrick Stinson escribi?: > I am defining a simple finder/loader object and adding it to > sys.meta_path > like this: > > PyRun_SimpleString("import sys; import ousiainternal; sys.meta_path = > [ousiainternal.OusiaImporter]"); You should append to the existing meta_path, not replace it, erasing any previous content. And it must be an *instance* of your importer, not the type itself. Note that you're polluting the __main__ module namespace by using PyRun_SimpleString; I'd use API calls like PySys_GetObject("meta_path") and PyList_Append (PEP 302 guarantees it is a list). > "sys.meta_path.append(Importer)\n"; Here you append to sys.meta_path, but fail to create the instance first. > PyRun_SimpleString(importer_source); You should check the return value; I bet you got a -1 (failure). -- Gabriel Genellina From alderos at terra.com.br Sun Apr 13 20:42:49 2008 From: alderos at terra.com.br (Alderos Martins) Date: Sun, 13 Apr 2008 22:42:49 -0200 Subject: Remove my mail, please ! Message-ID: Please, remove my mail in to python list. I don?t receive mails. Thank?s. Alderos. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ptmcg at austin.rr.com Wed Apr 23 12:41:27 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Wed, 23 Apr 2008 09:41:27 -0700 (PDT) Subject: help needed with classes/inheritance References: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> <480f05d0$0$25755$426a74cc@news.free.fr> <676bac37-2816-402b-9aed-1a9c1873351b@a23g2000hsc.googlegroups.com> Message-ID: On Apr 23, 10:44?am, barbaros wrote: > > If I understand correctly, in the above implementation I cannot > define firstly a (non-oriented) body, and then build, on top of it, > two bodies with opposite orientations. The point is, I want > both oriented bodies to share the same base Body object. What you are describing is composition+delegation, not inheritance, and it would be the same answer in Java, C++, or OO-langue-du-jour. Python makes delegation to the contained object easier than the others (except maybe for OOldj) - no need to implement all the methods of the contained object in the container, that just delegate the call to the contained; use __getattr__ to get attributes of the contained object that are not defined on the container (methods are attributes, too) as shown below. No inheritance in this example at all. -- Paul class BodyWithoutOrientation(object): def __init__(self,color): self.color = color def show_orientation(self): print "I don't lean one way or the other" class OrientedBody(object): def __init__(self,base,orientation): self.base_body = base self.orientation = orientation def show_orientation(self): print "I lean to the " + \ { OrientedBody.RIGHT : "right", OrientedBody.LEFT : "left", }[self.orientation], print "and my color is " + self.color # delegate any other attr lookups to the base_body object def __getattr__(self,attr): return getattr(self.base_body,attr) OrientedBody.RIGHT = object() OrientedBody.LEFT = object() class LeftRightBody(object): def __init__(self,b): self.common_base = b self.left = OrientedBody(b,OrientedBody.LEFT) self.right = OrientedBody(b,OrientedBody.RIGHT) def show_orientation(self): print "I do both of these:" print "- ", self.left.show_orientation() print "- ", self.right.show_orientation() base = BodyWithoutOrientation("purple") lr = LeftRightBody(base) base.show_orientation() lr.show_orientation() Prints: I don't lean one way or the other I do both of these: - I lean to the left and my color is purple - I lean to the right and my color is purple From arnodel at googlemail.com Tue Apr 8 16:33:45 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Tue, 8 Apr 2008 13:33:45 -0700 (PDT) Subject: CPython VM & byte code resources wanted References: <6622srF2e32hbU1@mid.individual.net> Message-ID: On Apr 8, 9:29?pm, "Aaron Gray" wrote: > Hi, > > I am looking to study the CPython source code, but I cannot seem to find the > VM code. > Also is there any where a detailed ?list of the opcodes ? > > Many thanks in advance, > > Aaron Bytecodes: http://docs.python.org/lib/bytecodes.html VM: Python/ceval.c HTH -- Arnaud From sandip.more at gmail.com Tue Apr 29 01:58:09 2008 From: sandip.more at gmail.com (sandipm) Date: Mon, 28 Apr 2008 22:58:09 -0700 (PDT) Subject: python script as executable References: Message-ID: <4e7ff885-616f-4041-a9b0-4dc6e6c892b2@p39g2000prm.googlegroups.com> thanks it worked On Apr 29, 10:49 am, "Eric Wertman" wrote: > Try to ftp it in ascii mode, or find a dos2unix utility .. the file > has probably got \r\n (windows) line terminators in it.. causes > problems. I guess it's also possible that /usr/bin/env doesn't > exist... not likely though. > > On Tue, Apr 29, 2008 at 1:36 AM, sandipm wrote: > > Hi, > > I have written a python script to run from cron. > > I have put #!/usr/bin/env python at top. file executes correctly when > > I run using python filename.py but > > it fails to execute when try to run it like script/command. > > it throws error: > > :No such file or directory > > > I am editing file from eclipse for python from windows. and then > > uploading on linus machine to run it. > > > any pointers? > > > sandip > > -- > > http://mail.python.org/mailman/listinfo/python-list From john106henry at hotmail.com Sat Apr 26 19:17:59 2008 From: john106henry at hotmail.com (John Henry) Date: Sat, 26 Apr 2008 16:17:59 -0700 (PDT) Subject: How do I say "Is this a function"? Message-ID: How do I determine is something a function? For instance, I don't want to relying on exceptions below: def f1(): print "In f1" def f3(): print "In f3" def others(): print "In others" for i in xrange(1,3): fct = "f%d()"%(i+1) try: exec fct except: others() I wish to say: if value of fct is a funtion, invoke it, otherwise invoke others(). Thanks, From wilson.t.thompson at gmail.com Fri Apr 4 18:07:59 2008 From: wilson.t.thompson at gmail.com (wilson) Date: Fri, 4 Apr 2008 15:07:59 -0700 (PDT) Subject: displaying pgm file in python Message-ID: i converted an 8bit rgb .jpg file into .pgm using adobe photoshop and a plugin from http://photoshop.pluginsworld.com/plugins/adobe/362/richard-rosenman/portable-pixmap-importer-exporter.html I want to check if this file can be properly displayed. Image opening and show() in PIL fails to do it so i tried Tkinter i created a canvas in a tkinter gui and tried self.myimg=PhotoImage(file="mytestpic.pgm") self.selimgtag=self.canvorig.create_image(70,100,image=self.myimg) self.canvorig.update_idletasks() this causes AttributeError snd says can't identify image file I checked the asci text of .pgm file ,it starts with a line P2 and then several lines with integers..can someone tell me if there is a way to display this properly thanks W From vinay_sajip at yahoo.co.uk Thu Apr 10 13:13:33 2008 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Thu, 10 Apr 2008 10:13:33 -0700 (PDT) Subject: subprocess.Popen() output to logging.StreamHandler() References: Message-ID: <6b02e27c-916f-42a7-b2e0-75af51bba343@h1g2000prh.googlegroups.com> On Apr 10, 1:11 pm, "sven _" wrote: > Version: Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) > > My goal is to have stdout and stderr written to alogginghandler. > This code does not work: > > # START > importlogging, subprocess > ch =logging.StreamHandler() > ch.setLevel(logging.DEBUG) > subprocess.call(['ls', '-la'], 0, None, None, ch, ch) > # END > > Traceback (most recent call last): > File "log.py", line 5, in > subprocess.call(['ls', '-la'], 0, None, None, ch, ch) > File "/usr/lib/python2.5/subprocess.py", line 443, in call > return Popen(*popenargs, **kwargs).wait() > File "/usr/lib/python2.5/subprocess.py", line 586, in __init__ > errread, errwrite) = self._get_handles(stdin, stdout, stderr) > File "/usr/lib/python2.5/subprocess.py", line 941, in _get_handles > c2pwrite = stdout.fileno() > AttributeError: StreamHandler instance has no attribute 'fileno' > > This is because subprocess.Popen() expects file descriptors to write > to, andlogging.StreamHandler() does not supply it. The StreamHandler > could supply its own stdout file descriptor, but then Popen() would > write directly to that file, bypassing all theloggingfluff. > > A possible solution would be to make a named pipe (os.mkfifo()), have > Popen() write to that, and then have some horrendous hack run select() > or similar on the fifo to read from it and finally pass it to > StreamHandler. > > Are there better solutions? > > sven Thomas was almost right, but not quite - you can't call info on a Handler instance, only on a Logger instance. The following script: import logging import subprocess logging.basicConfig(level=logging.INFO) # will log to stderr of this script s = subprocess.Popen( ['ls','-la'], stdout=subprocess.PIPE ) while 1: line = s.stdout.readline() exitcode = s.poll() if (not line) and (exitcode is not None): break line = line[:-1] logging.info("%s", line) produces the following output: INFO:root:total 204 INFO:root:drwxr-xr-x 35 vinay vinay 4096 2008-04-10 18:06 . INFO:root:drwxr-xr-x 3 root root 4096 2008-03-22 07:09 .. INFO:root:-rw------- 1 vinay vinay 685 2008-04-10 17:26 .bash_history INFO:root:-rw-r--r-- 1 vinay vinay 220 2008-03-22 07:09 .bash_logout INFO:root:-rw-r--r-- 1 vinay vinay 2327 2008-03-22 07:09 .bashrc INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-04-05 02:21 .bluefish INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-03-22 07:18 .cache INFO:root:drwxr-xr-x 5 vinay vinay 4096 2008-03-22 07:32 .config INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Desktop INFO:root:-rw------- 1 vinay vinay 28 2008-04-10 00:33 .dmrc INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Documents INFO:root:-rw------- 1 vinay vinay 16 2008-03-22 07:17 .esd_auth INFO:root:lrwxrwxrwx 1 vinay vinay 26 2008-03-22 07:09 Examples -> / usr/share/example-content INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-04-10 00:21 .fontconfig INFO:root:drwx------ 4 vinay vinay 4096 2008-04-10 17:23 .gconf INFO:root:drwx------ 2 vinay vinay 4096 2008-04-10 17:43 .gconfd INFO:root:-rw-r----- 1 vinay vinay 0 2008-03-24 19:13 .gksu.lock INFO:root:drwx------ 9 vinay vinay 4096 2008-04-10 00:31 .gnome2 INFO:root:drwx------ 2 vinay vinay 4096 2008-03-22 07:17 .gnome2_private INFO:root:drwx------ 2 vinay vinay 4096 2008-04-10 00:33 .gnupg INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-04-10 00:33 .gstreamer-0.10 INFO:root:-rw-r--r-- 1 vinay vinay 108 2008-04-10 00:33 .gtk- bookmarks INFO:root:dr-x------ 2 vinay vinay 0 2008-04-10 00:33 .gvfs INFO:root:-rw------- 1 vinay vinay 167 2008-04-10 00:33 .ICEauthority INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-03-22 07:18 .local INFO:root:drwx------ 3 vinay vinay 4096 2008-03-22 07:18 .metacity INFO:root:drwx------ 4 vinay vinay 4096 2008-03-24 19:13 .mozilla INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Music INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-04-10 00:31 .nautilus INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-04-05 02:09 .netbeans INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-04-05 02:09 .netbeans- registration INFO:root:drwx------ 3 vinay vinay 4096 2008-04-05 02:15 .openoffice.org2 INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Pictures INFO:root:-rw-r--r-- 1 vinay vinay 566 2008-03-22 07:09 .profile INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Public INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 08:01 .pulse INFO:root:-rw------- 1 vinay vinay 256 2008-03-22 07:17 .pulse- cookie INFO:root:-rw-r--r-- 1 vinay vinay 1973 2008-04-10 18:06 .recently- used.xbel INFO:root:drwx------ 2 vinay vinay 4096 2008-03-22 07:17 .ssh INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-04-05 02:09 .subversion INFO:root:-rw-r--r-- 1 vinay vinay 0 2008-03-22 07:34 .sudo_as_admin_successful INFO:root:drwxr-xr-x 4 vinay vinay 4096 2008-03-22 09:10 .sudoku INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Templates INFO:root:-rw-r--r-- 1 vinay vinay 297 2008-04-10 18:06 test.py INFO:root:-rw-r--r-- 1 vinay vinay 291 2008-04-10 18:06 test.py~ INFO:root:-rwxr--r-- 1 vinay vinay 75 2008-03-22 07:33 update INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 08:22 .update- manager-core INFO:root:drwx------ 2 vinay vinay 4096 2008-03-22 07:18 .update- notifier INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Videos INFO:root:drwxr-xr-x 7 vinay vinay 4096 2007-10-08 14:56 vmware-tools- distrib INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-04-07 00:19 .wapi INFO:root:-rw------- 1 vinay vinay 121 2008-04-10 00:33 .Xauthority INFO:root:-rw-r--r-- 1 vinay vinay 146 2008-04-09 21:33 .xscreensaver-getimage.cache INFO:root:-rw-r--r-- 1 vinay vinay 5102 2008-04-10 17:31 .xsession- errors vinay at zeta-hardy:~$ python test.py | more INFO:root:total 204 INFO:root:drwxr-xr-x 35 vinay vinay 4096 2008-04-10 18:07 . INFO:root:drwxr-xr-x 3 root root 4096 2008-03-22 07:09 .. INFO:root:-rw------- 1 vinay vinay 685 2008-04-10 17:26 .bash_history INFO:root:-rw-r--r-- 1 vinay vinay 220 2008-03-22 07:09 .bash_logout INFO:root:-rw-r--r-- 1 vinay vinay 2327 2008-03-22 07:09 .bashrc INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-04-05 02:21 .bluefish INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-03-22 07:18 .cache INFO:root:drwxr-xr-x 5 vinay vinay 4096 2008-03-22 07:32 .config INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Desktop INFO:root:-rw------- 1 vinay vinay 28 2008-04-10 00:33 .dmrc INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Documents INFO:root:-rw------- 1 vinay vinay 16 2008-03-22 07:17 .esd_auth INFO:root:lrwxrwxrwx 1 vinay vinay 26 2008-03-22 07:09 Examples -> / usr/share/example-content INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-04-10 00:21 .fontconfig INFO:root:drwx------ 4 vinay vinay 4096 2008-04-10 17:23 .gconf INFO:root:drwx------ 2 vinay vinay 4096 2008-04-10 17:43 .gconfd INFO:root:-rw-r----- 1 vinay vinay 0 2008-03-24 19:13 .gksu.lock INFO:root:drwx------ 9 vinay vinay 4096 2008-04-10 00:31 .gnome2 INFO:root:drwx------ 2 vinay vinay 4096 2008-03-22 07:17 .gnome2_private INFO:root:drwx------ 2 vinay vinay 4096 2008-04-10 00:33 .gnupg INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-04-10 00:33 .gstreamer-0.10 INFO:root:-rw-r--r-- 1 vinay vinay 108 2008-04-10 00:33 .gtk- bookmarks INFO:root:dr-x------ 2 vinay vinay 0 2008-04-10 00:33 .gvfs INFO:root:-rw------- 1 vinay vinay 167 2008-04-10 00:33 .ICEauthority INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-03-22 07:18 .local INFO:root:drwx------ 3 vinay vinay 4096 2008-03-22 07:18 .metacity INFO:root:drwx------ 4 vinay vinay 4096 2008-03-24 19:13 .mozilla INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Music INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-04-10 00:31 .nautilus INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-04-05 02:09 .netbeans INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-04-05 02:09 .netbeans- registration INFO:root:drwx------ 3 vinay vinay 4096 2008-04-05 02:15 .openoffice.org2 INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Pictures INFO:root:-rw-r--r-- 1 vinay vinay 566 2008-03-22 07:09 .profile INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Public INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 08:01 .pulse INFO:root:-rw------- 1 vinay vinay 256 2008-03-22 07:17 .pulse- cookie INFO:root:-rw-r--r-- 1 vinay vinay 1973 2008-04-10 18:07 .recently- used.xbel INFO:root:drwx------ 2 vinay vinay 4096 2008-03-22 07:17 .ssh INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-04-05 02:09 .subversion INFO:root:-rw-r--r-- 1 vinay vinay 0 2008-03-22 07:34 .sudo_as_admin_successful INFO:root:drwxr-xr-x 4 vinay vinay 4096 2008-03-22 09:10 .sudoku INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Templates INFO:root:-rw-r--r-- 1 vinay vinay 339 2008-04-10 18:07 test.py INFO:root:-rw-r--r-- 1 vinay vinay 303 2008-04-10 18:07 test.py~ INFO:root:-rwxr--r-- 1 vinay vinay 75 2008-03-22 07:33 update INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 08:22 .update- manager-core INFO:root:drwx------ 2 vinay vinay 4096 2008-03-22 07:18 .update- notifier INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Videos INFO:root:drwxr-xr-x 7 vinay vinay 4096 2007-10-08 14:56 vmware-tools- distrib INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-04-07 00:19 .wapi INFO:root:-rw------- 1 vinay vinay 121 2008-04-10 00:33 .Xauthority INFO:root:-rw-r--r-- 1 vinay vinay 146 2008-04-09 21:33 .xscreensaver-getimage.cache INFO:root:-rw-r--r-- 1 vinay vinay 5102 2008-04-10 17:31 .xsession- errors You should be able to adapt this to your specific requirement. Regards, Vinay Sajip N.B. This test was run using Python 2.5.2 on Ubuntu Hardy Heron (beta): Python 2.5.2 (r252:60911, Apr 8 2008, 21:49:41) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 From john00587 at gmail.com Mon Apr 21 01:38:46 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:38:46 -0700 (PDT) Subject: gutterball 2 crack Message-ID: <134ec4fc-9c54-4a60-8cb9-6b2df443d3ed@w1g2000prd.googlegroups.com> gutterball 2 crack http://cracks.00bp.com F R E E C R A C K S From sturlamolden at yahoo.no Thu Apr 24 20:07:52 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 17:07:52 -0700 (PDT) Subject: Psyco alternative References: <1369b321-f55b-432b-b2f9-6144787509d8@h11g2000prf.googlegroups.com> <7xlk4473ai.fsf@ruckus.brouhaha.com> <651ncdF2cmik2U1@mid.uni-berlin.de> Message-ID: On Mar 27, 4:02 pm, king kikapu wrote: > As for psyco, are there any alternatives to use now ? When Cython has implemented all of Python's syntax, we can replace CPython's compiler and bytecode interpreter with Cython and a C compiler. Cython can be one or two orders of magnitude faster than CPython. From steve at holdenweb.com Sun Apr 20 10:27:42 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 20 Apr 2008 10:27:42 -0400 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <480B3B2D.6040206@gmail.com> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> Message-ID: <480B52DE.8070105@holdenweb.com> Hank @ITGroup wrote: > Apology for the previous offensive title~~ > :) > Thanks, Rintsch, Arnaud and Daniel, for replying so soon. > > I redid the experiment. What following is the record - > > ``starting python`` # == Windows Task Manager: > Python.exe *4,076 *K memory-usage == > >>> st1='abcdefg'*999999 # == 10,952 K == > >>> del st1 # == *4,104*K == > >>> st1='abcdefg'*999999 # == 10,952 K == > >>> del st1 # == 4,104 K == > > >>> li = ['abcde']*999999 # == 8,024 K == > >>> del li # == *4,108* K == > > >>> from nltk import FreqDist # == 17,596 == > >>> fd = FreqDist() # == 17,596 == > >>> for i in range(999999):fd.inc(i) # == 53,412 == > >>> del fd # == *28,780* == > >>> fd2 = FreqDist() # == 28,780 == > >>> for i in range(999999):fd2.inc(i) # == 53,412 == > >>> del fd2 # == 28,780 K == > > >>> def foo(): > ... fd3 = FreqDist() > ... for i in range(999999):fd3.inc(i) > > >>> foo() # == *28,788* K == > > >>> def bar(): > ... fd4 = FreqDist() > ... for i in range(999999):fd4.inc(i) > ... del fd4 > # == 28,788 K == > >>> bar() # == 28,788 K == > > > That is my question, after ``del``, sometimes the memory space returns > back as nothing happened, sometimes not... ... > What exactly was happening??? > > Best regards to all PYTHON people ~~ > !!! Python Team are great !!! > It doesn't really make that much sense to watch memory usage as you have been doing. Your first test case appears to trigger a specific pathology, where the memory allocator actually returns the memory to the operating system when the garbage collector manages to free all of it. Most often this doesn't happen - a chunk of memory might be 99.99% free but still have one small piece used, and so while there is a large amount of "free" memory for Python to allocate without requesting more process memory, this won't be reflected in any external measurement. You are suffering from a pathological condition yourself: the desire to optimize performance in an area where you do not have any problems. I would suggest you just enjoy using Python (its memory management doesn't suck at all, so your title line was inflammatory and simply highlights your lack of knowledge) and then start to ask these questions again when you have a real issue that's stopping you from getting real work done. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From victorsubervi at gmail.com Thu Apr 10 10:46:11 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 10 Apr 2008 09:46:11 -0500 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> <47FCF421.6000807@holdenweb.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> Message-ID: <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> Okay, here is where we find the fly in the ointment. If I run this code: #! /usr/bin/python import MySQLdb print "Content-type: image/jpeg\r\n" host = 'mysqldb2.ehost-services.com' db = 'benobeno_bre' user = 'benobeno' passwd = '21122112' connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor = connection.cursor() cursor.execute('select pic1 from products where id="2";') content = cursor.fetchall()[0][0] content = content.tostring() print content f = open("2.jpg", "w") f.write(content) f.close() all is well :) If, however, I change two lines to make it an html page: #! /usr/bin/python import MySQLdb # print "Content-type: image/jpeg\r\n" print "Content-type: text/html\n" host = 'mysqldb2.ehost-services.com' db = 'benobeno_bre' user = 'benobeno' passwd = '21122112' connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor = connection.cursor() cursor.execute('select pic1 from products where id="2";') content = cursor.fetchall()[0][0] content = content.tostring() print '

' % content # print content f = open("2.jpg", "w") f.write(content) f.close() it prints garbage. It does not yield the image. Now, what? TIA. Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From deets at nospam.web.de Wed Apr 9 13:41:40 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 09 Apr 2008 19:41:40 +0200 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. In-Reply-To: <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> Message-ID: <664detF2fmo9dU1@mid.uni-berlin.de> subhabrata.iisc at hotmail.com schrieb: > Hi Steve, > comp.lang.python is supposed to be a serious group not anyone knowing > nothing and giving comment. Well, original code snippet I don't know > why an expert person like you fails to understand, I told it almost > can't you guess the next portion? And this is outright outrageous. You are actually *aware* that people must guess what you mean and expect them to do so, sparing yourself the work of providing better information - willfully? This is as close to impertinence as it can get. Diez From gagsl-py2 at yahoo.com.ar Fri Apr 25 21:46:39 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 25 Apr 2008 22:46:39 -0300 Subject: ioctl, pass buffer address, howto? References: Message-ID: En Fri, 25 Apr 2008 09:30:56 -0300, Neal Becker escribi?: > I need an ioctl call equivalent to this C code: > > my_struct s; > s.p = p; << a pointer to an array of char > s.image_size = image_size; > return (ioctl(fd, xxx, &s)); > > I'm thinking to use python array for the array of char, but I don't see > how > to put it's address into the structure. Use the array's buffer_info() method: """buffer_info(): Return a tuple (address, length) giving the current memory address and the length in elements of the buffer used to hold array's contents.""" and you can use the struct module to build my_struct. > Maybe ctypes is the answer? It could be used too, but I think that in this case it's harder to use ctypes. -- Gabriel Genellina From dteslenko at gmail.com Mon Apr 14 05:33:32 2008 From: dteslenko at gmail.com (Dmitry Teslenko) Date: Mon, 14 Apr 2008 13:33:32 +0400 Subject: pygtk + threading.Timer Message-ID: <91325fec0804140233y3bbb5708i1afe66467693954e@mail.gmail.com> Hello! I have simple chat application with pygtk UI. I want some event (for example update user list) to have place every n seconds. What's the best way to archive it? I tried threading.Timer but result is following: all events wait till exit of gtk main loop and only then they occur. Thanks in advance From mail at timgolden.me.uk Tue Apr 22 09:32:17 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 22 Apr 2008 14:32:17 +0100 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: <200804221847.43924.v.harishankar@gmail.com> References: <200804221847.43924.v.harishankar@gmail.com> Message-ID: <480DE8E1.7020601@timgolden.me.uk> Harishankar wrote: > On Tuesday 22 Apr 2008 18:00:02 Nick Craig-Wood wrote: >> There is a recipe in the cookbook >> >> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554 >> >> Which I've used and it works. > Thanks. I found that recipe too. I was hoping I could cook up something > similar without having to use the module win32api... Well if you want to, you can reproduce the same effect by using ctypes which *is* in the standard library. But why reinvent the wheel? > By the way, the win32api seems to be a nonstandard module (i.e. not present in > the main distribution). Correct. It's part of the pywin32 extensions, one of many useful packages available to the discerning Python programmer who doesn't feel in some way bound to whatever comes bundled with the standard library. TJG From mccredie at gmail.com Mon Apr 28 12:49:26 2008 From: mccredie at gmail.com (Matimus) Date: Mon, 28 Apr 2008 09:49:26 -0700 (PDT) Subject: Given a string - execute a function by the same name References: Message-ID: <78196696-e5fd-4e35-a666-966c945b5a05@l64g2000hse.googlegroups.com> On Apr 28, 9:33 am, pyt... at bdurham.com wrote: > I'm parsing a simple file and given a line's keyword, would like to call > the equivalently named function. > > There are 3 ways I can think to do this (other than a long if/elif > construct): > > 1. eval() > > 2. Convert my functions to methods and use getattr( myClass, "method" ) > > 3. Place all my functions in dictionary and lookup the function to be > called > > Any suggestions on the "best" way to do this? > > Thank you, > Malcolm You can always import yourself and use getattr on that module. in file "mytest.py": def foo(): print "foo called" def call_by_name(name, *args, **kwargs): import mytest f = getattr(mytest, "foo") f(*args, **kwargs) if __name__ == "__main__": call_by_name('foo') Alternatively you can import __main__ if you are always going to be running directly from that file. Matt From soren.skou.nielsen at gmail.com Thu Apr 10 06:30:53 2008 From: soren.skou.nielsen at gmail.com (Soren) Date: Thu, 10 Apr 2008 03:30:53 -0700 (PDT) Subject: Sorting Directories from files in a os.listdir?? References: <9354f263-b833-4845-a226-1ad3a47b1e6a@p25g2000pri.googlegroups.com> Message-ID: On Apr 10, 12:14 pm, "Gabriel Genellina" wrote: > En Thu, 10 Apr 2008 06:55:13 -0300, Soren > escribi?: > > > I'd like to read the filenames in a directory, but not the > > subdirectories, os.listdir() gives me everything... how do I separate > > the directory names from the filenames? Is there another way of doing > > this? > > Check each returned name using os.path.isfile > (untested): > > def files_only(path): > return [filename for filename in os.listdir(path) > if os.path.isfile(os.path.join(path, filename))] > > -- > Gabriel Genellina Thanks everyone! That worked! :) From noname9968 at gmail.com Thu Apr 3 05:50:52 2008 From: noname9968 at gmail.com (Alex9968) Date: Thu, 03 Apr 2008 13:50:52 +0400 Subject: Get all strings matching given RegExp Message-ID: <47F4A87C.7020701@gmail.com> Can I get sequence of all strings that can match a given regular expression? For example, for expression '(a|b)|(x|y)' it would be ['ax', 'ay', 'bx', 'by'] It would be useful for example to pass these strings to a search engine not supporting RegExp (therefore adding such support to it). A program can also let user specify sequence of strings using RegExp (filenames to process, etc.). If there are other types of expressions for these purposes, please let me know. I know that for some expressions there would be infinite amount of matching strings, but these aren't the cases I'm considering. It'd still be possible if string length is limited (there might be large but finite number of matching strings). Thanks From rowen at cesmail.net Mon Apr 28 15:28:38 2008 From: rowen at cesmail.net (Russell E. Owen) Date: Mon, 28 Apr 2008 12:28:38 -0700 Subject: Simple unicode-safe version of str(exception)? Message-ID: I have code like this: except Exception, e: self.setState(self.Failed, str(e)) which fails if the exception contains a unicode argument. I did, of course, try unicode(e) but that fails. The following works, but seems rather messy: except Exception, e: errStr = ",".join([unicode(s) for s in f.args]) self.setState(self.Failed, errStr) Is there a simpler solution that works in Python 2.3-2.5? -- Russell From breily at gmail.com Wed Apr 23 21:14:18 2008 From: breily at gmail.com (Brian) Date: Wed, 23 Apr 2008 21:14:18 -0400 Subject: Partition list with predicate In-Reply-To: <925822270804231808n44c44ddbx213e936319ad1ed3@mail.gmail.com> References: <925822270804231808n44c44ddbx213e936319ad1ed3@mail.gmail.com> Message-ID: On Wed, Apr 23, 2008 at 9:08 PM, Jared Grubb wrote: > I guess I forgot one requirement: the removed elements need to be > remembered. > > Basically, I have a list of objects in a buffer, one class operates on > some of the objects, but other classes use others. So, a class must extract > the ones it can handle, and leave the rest in the buffer for the other > classes to handle. > > I haven't found a function that will both remove objects from a list, but > save the ones that do get removed. > > Jared > > On 23 Apr 2008, at 10:15, Tim Golden wrote: > > Jared Grubb wrote: > > I want a function that removes values from a list if a predicate evaluates > to True. The best I could come up with is: > > > Have a look at the itertools module, and the ifilter function > in particular. > > TJG > -- > http://mail.python.org/mailman/listinfo/python-list > > > > -- > http://mail.python.org/mailman/listinfo/python-list > I would do it like this: # This takes out the values extracted = [ obj for obj in lst if pred(obj) ] # This filters out any item that was extracted lst = [ obj for obj in list if obj not in extracted ] Brian -------------- next part -------------- An HTML attachment was scrubbed... URL: From gagsl-py2 at yahoo.com.ar Mon Apr 7 21:17:31 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 07 Apr 2008 22:17:31 -0300 Subject: popen pipe limit References: Message-ID: En Mon, 07 Apr 2008 20:52:54 -0300, skunkwerk escribi?: > I'm getting errors when reading from/writing to pipes that are fairly > large in size. To bypass this, I wanted to redirect output to a file > in the subprocess.Popen function, but couldn't get it to work (even > after setting Shell=True). I tried adding ">","temp.sql" after the > password field but mysqldump gave me an error. > > the code: > p1 = subprocess.Popen(["mysqldump","--all-databases","--user=user","-- > password=password"], shell=True) > p2 = subprocess.Popen(["gzip","-9"], stdin=p1.stdout) > output = p2.communicate()[0] > file=open('test.sql.gz','w') > file.write(str(output)) > file.close() You need a pipe to chain subprocesses: import subprocess p1 = subprocess.Popen(["mysqldump","--all-databases","--user=user","--password=password"], stdout=subprocess.PIPE) ofile = open("test.sql.gz", "wb") p2 = subprocess.Popen(["gzip","-9"], stdin=p1.stdout, stdout=ofile) p1.wait() p2.wait() ofile.close() If you don't want the final file on disk: p1 = subprocess.Popen(["mysqldump","--all-databases","--user=user","--password=password"], stdout=subprocess.PIPE) p2 = subprocess.Popen(["gzip","-9"], stdin=p1.stdout, stdout=subprocess.PIPE) while True: chunk = p2.stdout.read(4192) if not chunk: break # do something with read chunk p1.wait() p2.wait() -- Gabriel Genellina From bskaplan14 at yahoo.com Thu Apr 17 09:52:44 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Thu, 17 Apr 2008 06:52:44 -0700 (PDT) Subject: Importing My Own Script Message-ID: <271813.40455.qm@web39202.mail.mud.yahoo.com> If x and y are in the same directory, just do "import x". If not, add the directory containing x to sys.path. Then, "import x" should work. ----- Original Message ---- From: Victor Subervi To: python-list at python.org Sent: Thursday, April 17, 2008 9:45:10 AM Subject: Importing My Own Script Hi: How do I import my own script from a second script? That is, I have script x and I want to import script y. How? TIA, Victor ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From pscott at uwc.ac.za Tue Apr 1 00:30:07 2008 From: pscott at uwc.ac.za (Paul Scott) Date: Tue, 01 Apr 2008 06:30:07 +0200 Subject: Command line input In-Reply-To: <00c99698-e5cb-49dd-88fd-8130623a4e45@e6g2000prf.googlegroups.com> References: <00c99698-e5cb-49dd-88fd-8130623a4e45@e6g2000prf.googlegroups.com> Message-ID: <1207024207.7016.2.camel@paul-laptop> On Mon, 2008-03-31 at 12:39 -0700, hexusnexus at gmail.com wrote: > How do I receive input from the command line in Python? I have used: sys.argv[ 1 ] I have been doing Python for around 2 days now, so please do double check that! --Paul -------------- next part -------------- All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm From torppa at staff.megabaud.fi Sun Apr 27 12:26:11 2008 From: torppa at staff.megabaud.fi (Jarkko Torppa) Date: Sun, 27 Apr 2008 16:26:11 GMT Subject: design choice: multi-threaded / asynchronous wxpython client? References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: On 2008-04-27, David wrote: >> >> 1) The data for the race about to start updates every (say) 15 >> seconds, and the data for earlier and later races updates only every >> (say) 5 minutes. There is no point for me to be hammering the server >> with requests every 15 seconds for data for races after the upcoming > > Try using an HTTP HEAD instruction instead to check if the data has > changed since last time. Get If-Modified-Since is still better (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html 14.25) -- Jarkko Torppa From hdante at gmail.com Fri Apr 11 09:49:23 2008 From: hdante at gmail.com (hdante) Date: Fri, 11 Apr 2008 06:49:23 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <31872ffc-5bc4-44c8-961d-ee4f0dc356c5@k1g2000prb.googlegroups.com> Message-ID: <700b1a5f-0af0-466e-abda-4d8dc784dbaa@e67g2000hsa.googlegroups.com> On Apr 11, 9:45 am, bdsatish wrote: > On Apr 11, 5:33 pm, bdsatish wrote: > > > > > HI Gerard, > > > I think you've taken it to the best possible implementation. Thanks ! > > On Apr 11, 5:14 pm, Gerard Flanagan wrote: > > > > In fact you can avoid the call to the builtin round: > > > > ------------------------------------------------ > > > > assert myround(3.2) == 3 > > > assert myround(3.6) == 4 > > > assert myround(3.5) == 4 > > > assert myround(2.5) == 2 > > > assert myround(-0.5) == 0.0 > > > assert myround(-1.5) == -2.0 > > > assert myround(-1.3) == -1.0 > > > assert myround(-1.8) == -2 > > > assert myround(-2.5) == -2.0 > > > ------------------------------------------------ > > OK, I was too early to praise Gerard. The following version: > > def myround(x): > n = int(x) > if abs(x - n) >= 0.5 and n % 2: > return n + 1 - 2 * int(n<0) > else: > return n > > of Gerard doesn't work for 0.6 (or 0.7, etc.) It gives the answer 0 > but I would expect 1.0 ( because 0.6 doesn't end in 0.5 at all... so > usual rules of round( ) apply) Interestingly, you could solve this by using python 3. :-) round(x[, n]) Return the floating point value x rounded to n digits after the decimal point. If n is omitted, it defaults to zero. Values are rounded to the closest multiple of 10 to the power minus n; if two multiples are equally close, rounding is done toward the even choice (so, for example, both round(0.5) and round(-0.5) are 0, and round(1.5) is 2). Delegates to x.__round__(n). My turn: ;-) def yaround(x): i = int(x) f = x - i if f != 0.5 and f != -0.5: return round(x) return 2.0*round(x/2.0) a = (-10.0, -9.0, -8.0, -4.6, -4.5, -4.4, -4.0, -3.6, -3.5, -3.4, -0.6, -0.5, -0.4, 0.0, 0.4, 0.5, 0.6, 0.9, 1.0, 1.4, 1.5, 1.6, 2.0, 2.4, 2.5, 2.6, 10.0, 100.0) b = (-10.0, -9.0, -8.0, -5.0, -4.0, -4.0, -4.0, -4.0, -4.0, -3.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 3.0, 10.0, 100.0) for i in range(len(a)): assert yaround(a[i]) == b[i] From duncan.booth at invalid.invalid Tue Apr 8 15:10:57 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 8 Apr 2008 19:10:57 GMT Subject: Google App Engine References: Message-ID: William Dode wrote: > On 08-04-2008, Duncan Booth wrote: >> Google have announced a new service called 'Google App Engine' which >> may be of interest to some of the people here (although if you want >> to sign up you'll have to join the queue behind me): >> >> From the introduction: >> >>> What Is Google App Engine? > ... > > It's also interesting to see that we can find django, webob and pyyaml > in their sdk (license apache 2) > Yes, it says you can use almost any Python web framework but django is the preferred one. Some of the comments at http://www.techcrunch.com/2008/04/07/google-jumps-head-first-into-web-services-with-google-app-engine/ sound kind of upset, e.g.: "Python will be a deal breaker for many " or "Python only. What a weird decision. Not business and community-friendly at all." From skanemupp at yahoo.se Fri Apr 4 21:06:11 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 4 Apr 2008 18:06:11 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! Message-ID: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> 1st question: when i run this program 1 will be printed into the interpreter when i run it BUT without me clicking the actual button. when i then click the button "1", nothing happens. obv i dont want any output when i dont push the button but i want it when i do. what am i doing wrong here? 2nd question: i want all the buttons to have the same size. i thought i should use row/columnspan but i dont get that to work. how should i do? [code] #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self,master=None): """Initialize yourself""" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): self.enText = Entry(self) self.enText.grid(row=0, column=0, columnspan=8, padx=5, pady=5) self.enText = Entry(self) self.enText.grid(row=1, column=0, columnspan=8, padx=5, pady=5) self.btnDisplay = Button(self, text="1", command=self.Display(1)) self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="2", default=ACTIVE) self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="3", default=ACTIVE) self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="+", default=ACTIVE) self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) self.btnDisplay = Button(self, text="4", default=ACTIVE) self.btnDisplay.grid(row=4, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="5", default=ACTIVE) self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="6", default=ACTIVE) self.btnDisplay.grid(row=4, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="-", default=ACTIVE) self.btnDisplay.grid(row=4, column=3, padx=5, pady=5) self.btnDisplay = Button(self, text="7", default=ACTIVE) self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="8", default=ACTIVE) self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="9", default=ACTIVE) self.btnDisplay.grid(row=5, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="*", default=ACTIVE) self.btnDisplay.grid(row=5, column=3, padx=5, pady=5) self.btnDisplay = Button(self, text="0", default=ACTIVE) self.btnDisplay.grid(row=6, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="C", default=ACTIVE) self.btnDisplay.grid(row=6, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="r", default=ACTIVE) self.btnDisplay.grid(row=6, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="/", default=ACTIVE) self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) def Display(self, xbtn): if xbtn==1: print 1 if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() [/code] From dstromberglists at gmail.com Tue Apr 15 15:18:26 2008 From: dstromberglists at gmail.com (Dan Stromberg) Date: Tue, 15 Apr 2008 19:18:26 GMT Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> <47FFDA87.3070703@gmail.com> Message-ID: <6c7Nj.1738$pS4.1299@newssvr13.news.prodigy.net> On Sat, 12 Apr 2008 03:43:28 +0000, David Cook wrote: > On 2008-04-11, Gabriel Ibanez wrote: > >> Why is nobody talking about pyGTK ? There are no limits with licenses >> (I think) > > The OS X port is still pretty preliminary. > > Dave Cook I often use pygtk for my *ix projects, because it has a nice license and it comes with most Linux distributions now. It's also an easy install on windows using cygwin. But I've never looked into it on Mac. From caibiner789 at yahoo.com.cn Sat Apr 19 13:12:26 2008 From: caibiner789 at yahoo.com.cn (bm123456) Date: Sat, 19 Apr 2008 10:12:26 -0700 (PDT) Subject: wholesale cheap air jordans sneakers dunks,Shox,max,adidas,puma, Message-ID: <4778adac-7592-4171-922e-5c64d98cc22d@q1g2000prf.googlegroups.com> Dear cheapers? wholesaleshoescn Global Trade Co.,LTD,is a leading brand sports shoes wholesaler in China. It has a wide range of nike,nike max series,nike Shox,jordans,air force one,Dunk, Bape sta, adidas,Gucci,Timberland boots etc to offer. We also supply brand bags and fashion clothes, Jeans. All the shoes are packed with original boxes with retro cards, and the tags. We try our best to provide you with good quality and competitive price. The number of your order starts from one. Hope to hear from your reply. We have confidence that you will be 100% satisfied with products. We are looking forward to doing business with you. If you are interested in our shoes, please feel free to contact us. pls link google search http://www.wholesaleshoescn.com Dear Sir or Madam: WELCOME TO wholesaleshoescn Global Trade Co.,LTD. we are wholesale :jordans sneakers incluing air jordans sneaker, michael jordans sneaker,we also wholesale jordans sneakers, cheap jordans sneakers, retro jordans sneakers,baby jordans sneakers for cheap and cheapize and get your latest exclusive jordans sneakers,The third is air force 1s incluing spongebob air force 1s,womens air force 1s, air force 1s lyrics,high top air force 1s,easter egg air force 1s, rasheed wallace air force 1s, scarface air force 1s,mr catoon air force 1s,mid air force 1s, airbrush air force 1s,painted air force 1s, neew green air force 1s,all white air force 1s,kid air force 1s,2007 air force 1s,yellow,pink,white stash air force 1s. nike basketball sneakers,womens nike sneakers,rare nike sneakers, rare nike sneakers,nike retro snakers,exlusive nike sneakers, you can get wholesale nike sneaker's price with discount for cheap nike shoes and cheap nike sneakers. pls link google search http://www.wholesaleshoescn.com China Factory Wholesale Cheap:Air Jordans Sneakers,Air Force 1s Shoes,Dunks,Shox,Max,Adidas,Puma,Brand Hoodies,Timberland Shoes,Jeans,Bags,Including Custom in http://WWW.WHOLESALESHOESCN.COM Wholesale Jordans Shoes,Cheap Jordan Sneakers; We Wholesale Jordan Shoes at Cheap Price,wholesale women's,wholesale men's,wholesale shoes,wholesale Nike Shoes Air Jordans,wholesale nike Jordans,Kids Jordan Sneakers,Authentic Jordan Sneakers,Baby Jordans Sneakers,wholesale nike shoes,wholesale nike,wholesale nikes,Michael Jordan Sneakers,Air Jordan Sneakers,cheap wholesale jordans,china custom jordans,jordans made in china,Boys Jordan Sneakers,New Jordans Sneakers,wholesale Air Jordans,wholesale Air Jordans 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ,cheap Jordans,cheap nike Jordans,Air Jordans 23,Air Jordans XX3,Discount air Jordans,cheap nike air Jordans,wholesalers cheap Jordans,Warehouse Jordanss,cheap nikes Jordans,cheap air Jordans,cheap nike's air Jordans. pls link google search http://www.wholesaleshoescn.com/product.asp?bigclassid=5 Dear cheapers? wholesaleshoescn Global Trade Co.,LTD,is a leading brand sports shoes wholesaler in China. It has a wide range of nike,nike max series,nike Shox,jordans,air force one,Dunk, Bape sta, adidas,Gucci,Timberland boots etc to offer. We also supply brand bags and fashion clothes, Jeans. All the shoes are packed with original boxes with retro cards, and the tags. We try our best to provide you with good quality and competitive price. The number of your order starts from one. Hope to hear from your reply. We have confidence that you will be 100% satisfied with products. We are looking forward to doing business with you. If you are interested in our shoes, please feel free to contact us. pls link google search http://www.wholesaleshoescn.com Dear Sir or Madam: WELCOME TO wholesaleshoescn Global Trade Co.,LTD. we are wholesale :jordans sneakers incluing air jordans sneaker, michael jordans sneaker,we also wholesale jordans sneakers, cheap jordans sneakers, retro jordans sneakers,baby jordans sneakers for cheap and cheapize and get your latest exclusive jordans sneakers,The third is air force 1s incluing spongebob air force 1s,womens air force 1s, air force 1s lyrics,high top air force 1s,easter egg air force 1s, rasheed wallace air force 1s, scarface air force 1s,mr catoon air force 1s,mid air force 1s, airbrush air force 1s,painted air force 1s, neew green air force 1s,all white air force 1s,kid air force 1s,2007 air force 1s,yellow,pink,white stash air force 1s. nike basketball sneakers,womens nike sneakers,rare nike sneakers, rare nike sneakers,nike retro snakers,exlusive nike sneakers, you can get wholesale nike sneaker's price with discount for cheap nike shoes and cheap nike sneakers. pls link google search http://www.wholesaleshoescn.com China Factory Wholesale Cheap:Air Jordans Sneakers,Air Force 1s Shoes,Dunks,Shox,Max,Adidas,Puma,Brand Hoodies,Timberland Shoes,Jeans,Bags,Including Custom in http://WWW.WHOLESALESHOESCN.COM Wholesale Jordans Shoes,Cheap Jordan Sneakers; We Wholesale Jordan Shoes at Cheap Price,wholesale women's,wholesale men's,wholesale shoes,wholesale Nike Shoes Air Jordans,wholesale nike Jordans,Kids Jordan Sneakers,Authentic Jordan Sneakers,Baby Jordans Sneakers,wholesale nike shoes,wholesale nike,wholesale nikes,Michael Jordan Sneakers,Air Jordan Sneakers,cheap wholesale jordans,china custom jordans,jordans made in china,Boys Jordan Sneakers,New Jordans Sneakers,wholesale Air Jordans,wholesale Air Jordans 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ,cheap Jordans,cheap nike Jordans,Air Jordans 23,Air Jordans XX3,Discount air Jordans,cheap nike air Jordans,wholesalers cheap Jordans,Warehouse Jordanss,cheap nikes Jordans,cheap air Jordans,cheap nike's air Jordans. pls link google search http://www.wholesaleshoescn.com/product.asp?bigclassid=5 Dear cheapers? wholesaleshoescn Global Trade Co.,LTD,is a leading brand sports shoes wholesaler in China. It has a wide range of nike,nike max series,nike Shox,jordans,air force one,Dunk, Bape sta, adidas,Gucci,Timberland boots etc to offer. We also supply brand bags and fashion clothes, Jeans. All the shoes are packed with original boxes with retro cards, and the tags. We try our best to provide you with good quality and competitive price. The number of your order starts from one. Hope to hear from your reply. We have confidence that you will be 100% satisfied with products. We are looking forward to doing business with you. If you are interested in our shoes, please feel free to contact us. pls link google search http://www.wholesaleshoescn.com Dear Sir or Madam: WELCOME TO wholesaleshoescn Global Trade Co.,LTD. we are wholesale :jordans sneakers incluing air jordans sneaker, michael jordans sneaker,we also wholesale jordans sneakers, cheap jordans sneakers, retro jordans sneakers,baby jordans sneakers for cheap and cheapize and get your latest exclusive jordans sneakers,The third is air force 1s incluing spongebob air force 1s,womens air force 1s, air force 1s lyrics,high top air force 1s,easter egg air force 1s, rasheed wallace air force 1s, scarface air force 1s,mr catoon air force 1s,mid air force 1s, airbrush air force 1s,painted air force 1s, neew green air force 1s,all white air force 1s,kid air force 1s,2007 air force 1s,yellow,pink,white stash air force 1s. nike basketball sneakers,womens nike sneakers,rare nike sneakers, rare nike sneakers,nike retro snakers,exlusive nike sneakers, you can get wholesale nike sneaker's price with discount for cheap nike shoes and cheap nike sneakers. pls link google search http://www.wholesaleshoescn.com China Factory Wholesale Cheap:Air Jordans Sneakers,Air Force 1s Shoes,Dunks,Shox,Max,Adidas,Puma,Brand Hoodies,Timberland Shoes,Jeans,Bags,Including Custom in http://WWW.WHOLESALESHOESCN.COM Wholesale Jordans Shoes,Cheap Jordan Sneakers; We Wholesale Jordan Shoes at Cheap Price,wholesale women's,wholesale men's,wholesale shoes,wholesale Nike Shoes Air Jordans,wholesale nike Jordans,Kids Jordan Sneakers,Authentic Jordan Sneakers,Baby Jordans Sneakers,wholesale nike shoes,wholesale nike,wholesale nikes,Michael Jordan Sneakers,Air Jordan Sneakers,cheap wholesale jordans,china custom jordans,jordans made in china,Boys Jordan Sneakers,New Jordans Sneakers,wholesale Air Jordans,wholesale Air Jordans 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ,cheap Jordans,cheap nike Jordans,Air Jordans 23,Air Jordans XX3,Discount air Jordans,cheap nike air Jordans,wholesalers cheap Jordans,Warehouse Jordanss,cheap nikes Jordans,cheap air Jordans,cheap nike's air Jordans. pls link google search http://www.wholesaleshoescn.com/product.asp?bigclassid=5 From pylists at arcor.de Mon Apr 14 04:37:16 2008 From: pylists at arcor.de (Penny Y.) Date: Mon, 14 Apr 2008 16:37:16 +0800 Subject: =?gb2312?B?tPC4tDogtPC4tDogaG93IHRvIHJlbW92ZSBcbiBpbiB0aGUgbGlzdA==?= In-Reply-To: Message-ID: <20080414083724.46958236E44@mail-in-16.arcor-online.net> that's right. got it thanks. -----????----- ???: python-list-bounces+pylists=arcor.de at python.org [mailto:python-list-bounces+pylists=arcor.de at python.org] ?? Eric Brunel ????: 2008?4?14? 16:17 ???: python-list at python.org ??: Re: ??: how to remove \n in the list (please avoid top-posting... corrected) On Mon, 14 Apr 2008 09:08:06 +0200, Penny Y. wrote: > -----????----- > ???: python-list-bounces+pylists=arcor.de at python.org > [mailto:python-list-bounces+pylists=arcor.de at python.org] ?? Gabriel > Genellina > ????: 2008?4?14? 12:59 > ???: python-list at python.org > ??: Re: how to remove \n in the list > > En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam > escribi?: > >> hi, >> l=['5\n', '2\n', '7\n', '3\n', '6\n'] >> >> how to remove \n from the given list > > l is is very poor name... I'll use lines instead: > > lines[:] = [line.rstrip('\n') for line in lines] > --- > > why not just: > > lines = [line.rstrip('\n') for line in lines] > > > what's the difference between lines[:] and lines here? Thanks. Compare: >>> lines = ['5\n', '2\n', '7\n', '3\n', '6\n'] >>> lines2 = lines >>> lines = [line.rstrip('\n') for line in lines] >>> lines ['5', '2', '7', '3', '6'] >>> lines2 ['5\n', '2\n', '7\n', '3\n', '6\n'] with: >>> lines = ['5\n', '2\n', '7\n', '3\n', '6\n'] >>> lines2 = lines >>> lines[:] = [line.rstrip('\n') for line in lines] >>> lines ['5', '2', '7', '3', '6'] >>> lines2 ['5', '2', '7', '3', '6'] Assigning to lines[:] changes the original list. Assigning to lines rebinds the name to the result of the list comprehension, but doesn't affect the original list. HTH -- python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])" -- http://mail.python.org/mailman/listinfo/python-list From Stephen.Cattaneo at u4eatech.com Tue Apr 8 16:36:13 2008 From: Stephen.Cattaneo at u4eatech.com (Stephen Cattaneo) Date: Tue, 8 Apr 2008 13:36:13 -0700 Subject: Running a python code periodically In-Reply-To: References: Message-ID: If your on a *NIX just use cron. Execute 'crontab -e' edit the file as desired and save see man crontab for formatting. Cheers, Steve ________________________________ From: Maryam Saeedi [mailto:ma.saeedi at gmail.com] Sent: Tuesday, April 08, 2008 10:54 AM To: python-list at python.org Subject: Running a python code periodically Hi, I was wondering if you know how can I run a python code once every five minutes for a period of time either using python or some other program like a bash script. Thanks, Maryam -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin.laloux at gmail.com Mon Apr 14 04:06:03 2008 From: martin.laloux at gmail.com (martin.laloux at gmail.com) Date: Mon, 14 Apr 2008 01:06:03 -0700 (PDT) Subject: How to get the version of a file References: Message-ID: <472baa87-2aa3-495c-ab0f-9c7f16bef769@8g2000hsu.googlegroups.com> you need appscript "that allows you to control scriptable Mac OS X applications from Python" http://pypi.python.org/pypi/appscript/0.18.1 From bronger at physik.rwth-aachen.de Sat Apr 12 11:14:22 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Sat, 12 Apr 2008 17:14:22 +0200 Subject: unittest: which directory structure? Message-ID: <87zlrzw1f5.fsf@physik.rwth-aachen.de> Hall?chen! I try to port my doctests to unittest. I've found good turorials about *writing* unit tests but not about organising the files. What's the best way to arrange the test source files? I made a directory called "tests" on the same level as my package, with (roughly) one test module per package module and wanted to call each of them from my Makefile or from some sort of root test module. However, I cannot easily import the to-be-tested module. Currently, I begin every test module with # append the local package path to sys.path import sys, os.path rootpath = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0] sys.path.append(rootpath) in order to be able to import the source modules. I surely have missed something because this is only a workaround solution. Thanks for any hints! Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From victorsubervi at gmail.com Wed Apr 9 10:54:18 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 9 Apr 2008 10:54:18 -0400 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> Message-ID: <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> On Wed, Apr 9, 2008 at 10:24 AM, Steve Holden wrote: > Victor Subervi wrote: > > On Wed, Apr 9, 2008 at 1:14 AM, Gabriel Genellina > > > wrote: > > Now all you have to do is what I told you in the first place, which is > to remove the print statements before and after "print content". That is what I figured after I sent the email. However, I had tried that with a test script and the working script, with bad results. Here is the test script that should have worked flawlessly: #! /usr/bin/python import MySQLdb print "Content-type: image/jpeg\r\n" host = 'host' db = 'bre' user = 'user' passwd = 'pass' connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor = connection.cursor() cursor.execute('select img from photo where id="7";') content = cursor.fetchall() print "Content-Type: image/jpeg\nContent-Length: %d\n" % len(content) print content connection.commit() connection.close() This prints out the URL as an image! No idea why. But it does not produce the desired image. The following is the heart of the script for display. I tried entering the Content-type where indicated, but it produces everything up to the image, then produces the result of code from the exception... cursor.execute('select id from products where category="' + category + '" order by sort_factor desc, price desc;') ids = cursor.fetchall() if len(ids[0]) != 0: for id in ids: for d in id: print '\n' cursor.execute('select * from products where id = ' + str(d) + ';') col_fields = cursor.fetchall() if lang == 'es': print 'ID: ', col_fields[0][0], '
' print 'Nombre: ', col_fields[0][2], '
' print 'T?tulo: ', col_fields[0][6], '
' print 'Descripci?n: ', col_fields[0][9], '
' print 'Precio: ', col_fields[0][11], '
' print 'Rec?maras: ', col_fields[0][12], '
' print 'Ba?os: ', col_fields[0][13], '
' content = col_fields[0][14].tostring() print "Content-Type: image/jpeg\nContent-Length: %d\n" % len(content) print content, '

' ... except: if lang == 'es': print 'Lo siento. Todav?a no tenemos propiedades para ense?arse en la categor?a de ', category, '.\n

' > You are NOT generating HTML, you are generating a JPEG image. I am producing both, and this is causing me confusion. BTW, when we are finally done with this, I will write a nice how-to (since there is not one in python, while php has some nice ones) on how to do this, and give you and Gabrielle all your due credit. I will post it to this list, because that is sure to rank highly in google right away. Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From charleshixsn at earthlink.net Sat Apr 12 15:36:51 2008 From: charleshixsn at earthlink.net (Charles D Hixson) Date: Sat, 12 Apr 2008 12:36:51 -0700 Subject: class level properties Message-ID: <48010F53.1000809@earthlink.net> I'm trying to construct read-only variables at the class level. I've been unsuccessful. Any suggestions? Mixing @classmethod and @property doesn't appear to produce workable code. Ditto for mixing @classmethod and __getattr__. (The property approach compiles, but execution says that you can't execute properties.) I've got a rather large number of variables, so I don't want to define function accessors for each of them, and I *REALLY* don't want to have to access them as functions rather than variables or properties. From jon+usenet at unequivocal.co.uk Wed Apr 16 11:19:20 2008 From: jon+usenet at unequivocal.co.uk (Jon Ribbens) Date: Wed, 16 Apr 2008 10:19:20 -0500 Subject: Finally had to plonk google gorups. References: Message-ID: On 2008-04-16, Grant Edwards wrote: > But that's not a battle you can win, so I broke down and joined all > the other people that just killfile everything posted via google.groups. I did the same about an hour ago. From bj_666 at gmx.net Sat Apr 5 16:11:56 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 5 Apr 2008 20:11:56 GMT Subject: Tkinter: making buttons the same size? References: <12bad1a6-3b4b-446e-9673-8893cd6838f9@s37g2000prg.googlegroups.com> <3753aa85-c844-4e54-8213-142e50fd8a7e@b5g2000pri.googlegroups.com> Message-ID: <65q4ocF2gq610U1@mid.uni-berlin.de> On Sat, 05 Apr 2008 10:04:56 -0700, skanemupp wrote: > how do i do that? Please include enough from the post you are answering to make the context clear for someone who has not received the previous message. BTW I don't think the `width` argument of the `Button()` call is the best solution. Take a look at the options of the `grid()` call and figure out how to tell that the content of the cell should fill it, so that the Buttons in the grid automatically are equally sized in each row and column. Ciao, Marc 'BlackJack' Rintsch From aahz at pythoncraft.com Mon Apr 21 10:28:19 2008 From: aahz at pythoncraft.com (Aahz) Date: 21 Apr 2008 07:28:19 -0700 Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> Message-ID: In article <23bf20ad-9996-4b79-97ef-7930a228c4a3 at t54g2000hsg.googlegroups.com>, Joseph Turian wrote: > >Basically, we're planning on releasing it as open-source, and don't >want to alienate a large percentage of potential users. Datapoint: my company still uses 2.3 and *might* upgrade to 2.4 and later this year. Basically, any company with lots of servers has a good chance to still be stuck with 2.2/2.3 (we only dropped 2.2 last fall). -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ Why is this newsgroup different from all other newsgroups? From cheapair at 163.com Fri Apr 18 05:12:30 2008 From: cheapair at 163.com (cheapair at 163.com) Date: Fri, 18 Apr 2008 02:12:30 -0700 (PDT) Subject: Air Max 90 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn )Air Mir 90 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Message-ID: <43915149-31fb-41b6-99ec-ea837d60043f@m71g2000hse.googlegroups.com> We are the professional and serious wholesaler of brand products,such as shoes, clothing, handbags, sunglasses, hats, belts, and so on.We have many brands such as nike,adidas,puma,Gucci,North face.All goods are with best service,highest quality,competitive price,and safe timely deliverry If you are interested in these goods,don?t hasitate to cantact us please. our website: http://www. top-saler.cn MSN(email): top-saler at hotmail.com Air Max 360 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 90 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn )Air Mir 90 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max LTD paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) air Max LTD paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 2003 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 2003 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 87 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 95 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 95 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 97 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 95 360 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 90 360 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air zoom hateu paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 91 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 87 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 89 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max Tn paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Tn Air Max Tn paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Bape paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) new Bape paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Old bape paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Dunk paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) s Dunk paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) High Dunk paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Dunk paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox NZ paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox R3 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox R4 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox R5 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 360 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 90 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn )Air Mir 90 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max LTD paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) air Max LTD paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 2003 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 2003 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 87 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 95 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 95 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 97 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 95 360 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 90 360 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air zoom hateu paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 91 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 87 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 89 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max Tn paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Tn Air Max Tn paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Bape paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) new Bape paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Old bape paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Dunk paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) s Dunk paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) High Dunk paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Dunk paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox NZ paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox R3 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox R4 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox R5 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) From dullrich at sprynet.com Wed Apr 2 09:17:40 2008 From: dullrich at sprynet.com (David C. Ullrich) Date: Wed, 02 Apr 2008 08:17:40 -0500 Subject: Homework help References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> Message-ID: On Tue, 1 Apr 2008 09:11:12 -0700 (PDT), bobby.connor at gmail.com wrote: >Hey guys >I haev this homework assignment due today >I don't necessarily want the answers, but need help on how to approach >it/the steps i need to solve the problems I can see at least two possible approaches: Approach 1: (i) post the problems on the internet (ii) carefully copy the solutions Approach 2: (i) learn a little bit about the material you were supposed to learn I'll leave the second step in Approach 2 as an exercise... >Thanks > ># (2 Points) Write a python function howMany(item,lst) which accepts >an item and a lst of items and returns the number of times item occurs >in lst. For example, howMany(3,[1,2,3,2,3]) should return 2. > ># (2 Points) Write a python function upTo(n) which accepts a non- >negative number n and returns a list of numbers from 0 to n. For >example, upTo(3) should return the list [0, 1, 2, 3]. > ># (2 Points) Write a python function duplicate(lst) which accepts a >lst of items and returns a list with the items duplicated. For >example, duplicate([1,2,2,3]) should return the list [1, 1, 2, 2, 2, >2, 3, 3]. > ># (2 Points) Write a python function dotProduct(a,b) which accepts two >lists of integers a and b that are of equal length and which returns >the dot product of a and b. I.e., the sum a0 * b0 + ... + an-1 * bn-1 >where n is the length of the lists. For example: > >dotProduct([1,2,3],[4,5,6]) is 1*4 + 2*5 + 3*6 = 4 + 10 + 18 = 32 > ># (2 Points) A pair (exp0, exp1) is a combination of expressions that >are attached together by their joint membership in the pair. For >example: > >>>> (1+2, 'This') >(3, 'This') > >A component of a pair can be obtained using an index in brackets as >with lists (and strings!). For example: > >>>> (33,44)[0] >33 > >Write a function zip(lst1, lst2) such that zip accepts two equal >length lists and returns a list of pairs. For example, zip(['a', 'b', >'c'], [10, 20, 30]) should evaluate to the list [('a', 10), ('b', 20), >('c', 30)]. > ># (2 Points) Write a function unzip(lst) such that unzip accepts a >list of pairs and returns two lists such that lst == zip(unzip(lst)). >For example, unzip([('a', 10), ('b', 20), ('c', 30)] should evaluate >to the pair (['a', 'b', 'c'], [10, 20, 30]). > ># (2 Points) Write a python function isAscending(lst) which accepts a >non-empty list of integers and returns True if the numbers in the list >are in ascending order. Otherwise it should return False. For example, >isAscending([1]) should evaluate to True while isAscending([1,2,2]) >should return False. David C. Ullrich From jkugler at bigfoot.com Fri Apr 25 17:01:45 2008 From: jkugler at bigfoot.com (Joshua Kugler) Date: Fri, 25 Apr 2008 13:01:45 -0800 Subject: Setting an attribute without calling __setattr__() Message-ID: OK, I'm sure the answer is staring me right in the face--whether that answer be "you can't do that" or "here's the really easy way--but I am stuck. I'm writing an object to proxy both lists (subscriptable iterables, really) and dicts. My init lookslike this: def __init__(self, obj=None): if type(obj).__name__ in 'list|tuple|set|frozenset': self.me = [] for v in obj: self.me.append(ObjectProxy(v)) elif type(obj) == dict: self.me = {} for k,v in obj.items(): self.me[k] = ObjectProxy(v) and I have a __setattr__ defined like so: def __setattr__(self, name, value): self.me[name] = ObjectProxy(value) You can probably see the problem. While doing an init, self.me = {} or self.me = [] calls __setattr__, which then ends up in an infinite loop, and even it it succeeded self.me['me'] = {} is not what I wanted in the first place. Is there a way to define self.me without it firing __setattr__? If not, it's not a huge deal, as having this class read-only for now won't be a problem, but I was just trying to make it read/write. Thanks! j From zillow10 at googlemail.com Wed Apr 2 14:42:54 2008 From: zillow10 at googlemail.com (zillow10 at googlemail.com) Date: Wed, 2 Apr 2008 11:42:54 -0700 (PDT) Subject: generator functions: why won't this work? References: <0aaeddf2-ee63-426e-afb3-0e1acb15adef@r9g2000prd.googlegroups.com> Message-ID: <8f38c3e6-1b1c-468e-8ea2-47c21322621f@i36g2000prf.googlegroups.com> On Apr 2, 3:57 pm, Mel wrote: > zillo... at googlemail.com wrote: > > I'd just like to test my > > > understanding of this. Suppose I create the following generator > > object: > > > g = getNextScalar(1, 2, (3, 4), 5) > > > when the iterator reaches the tuple argument (3, 4) then, according to > > Steve and George, the * in *arg causes this tuple to be expanded into > > positional arguments, and it makes sense to do it this way. But what > > happens when getNextScalar(arg) is used instead? > > Try it: > > Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> def a (arg): > ... print arg > ... > >>> def astar (*arg): > ... print arg > ... > >>> a(3,4) > Traceback (most recent call last): > File "", line 1, in > TypeError: a() takes exactly 1 argument (2 given) > >>> astar(3,4) > (3, 4) > >>> a((3,4)) > (3, 4) > >>> astar((3,4)) > ((3, 4),) > >>> > > Mel. Well, I understand that (unless I missed the point you're trying to make). But with respect to the example I quoted: def getNextScalar(*args): for arg in args: if(isinstance(arg, tuple)): for f in getNextScalar(arg): # should use *arg yield f else: yield arg where the function is declared as def getNextScalar(*arg), but is called using getNextScalar(arg), with arg being a tuple: here the generator is being passed a single argument, so there's no TypeError as in your example. However, it fails - as I understand it - because the function keeps passing the same tuple (being unable to access the elements inside it) and goes into an infinite loop: >>> # works for this example, but not very useful: >>> g = getNextScalar(1, 2, 3, 4) >>> for i in g: print i 1 2 3 4 # third argument is a tuple: >>> g = getNextScalar(1, 2, (3, 4)) >>> for i in g: print i 1 2 Traceback (most recent call last): File "", line 1, in for i in g: File "", line 4, in getNextScalar for f in getNextScalar(arg): File "", line 4, in getNextScalar for f in getNextScalar(arg): File "", line 4, in getNextScalar for f in getNextScalar(arg): ... AK From fabianosidler at my-mail.ch Sat Apr 26 20:03:13 2008 From: fabianosidler at my-mail.ch (Fabiano Sidler) Date: Sun, 27 Apr 2008 02:03:13 +0200 Subject: How do I say "Is this a function"? In-Reply-To: References: Message-ID: <4813C2C1.3000106@my-mail.ch> John Henry schrieb: > exec fct You don't want this. You want to store the function in a list instead: l = [ f1, f3, others ] for i in [0,1]: l[i]() Greetings, Fabiano From sturlamolden at yahoo.no Tue Apr 15 16:49:15 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Tue, 15 Apr 2008 13:49:15 -0700 (PDT) Subject: Preferred method for "Assignment by value" References: Message-ID: <84ac1334-b450-490e-a83b-0876274f46b3@26g2000hsk.googlegroups.com> On Apr 15, 7:23 pm, hall.j... at gmail.com wrote: > test = [[1],[2]] > x = test[0] Python names are pointer to values. Python behaves like Lisp - not like Visual Basic or C#. Here you make x point to the object which is currently pointed to by the first element in the list test. If you now reassign test[0] = [2], x is still pointing to [1]. > x[0] = 5 > test>>> [[5],[2]] > > x = 1 Here you reassign x to point to an int object vith value 1. In other words, x is no longer pointing to the same object as the first element in the list test. That is why get this: > test > > >>>[[5],[2]] > x > >>> 1 > test = [[1,2],[3,4]] > I need to do some data manipulation with the first list in the above > list without changing > obviously x = test[0] will not work as any changes i make will alter > the original... You make a slice, e.g. x = [from:until:stride] Now x is pointing to a new list object, containing a subset of the elements in list. If you reassign elements in x, test will still be the same. The point to remember, is that a list does not contain values, but pointers to values. This can be very different from arrays in C, VB, Java or C#: a = [1,2,3,4,5] in Python is different from int a[] = {1,2,3,4,5}; The Python statement makes a list of five pointers, each pointing to an immutable int object on the heap. The C statement allocates a buffer of 5 ints on the stack. If you can read C, the Python statement a = [1,2,3,4,5] is thus similar to something like int **a, i, amortize_padding=4; a = malloc(5 * sizeof(int*) + amortize_padding*sizeof(int*)); for (i=0; i<5; i++) { a[i] = malloc(sizeof(int)); *a[i] = i; } From castironpi at gmail.com Sat Apr 19 16:45:44 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sat, 19 Apr 2008 13:45:44 -0700 (PDT) Subject: Database vs Data Structure? References: <61bf5f46-e917-4a98-b87f-8e5087cb07f7@a23g2000hsc.googlegroups.com> Message-ID: <49da20a3-1625-4fbb-90fe-8fb917ff5e5d@f36g2000hsa.googlegroups.com> On Apr 19, 1:27?pm, Scott David Daniels wrote: > castiro... at gmail.com wrote: > > On Apr 18, 12:23 am, I V wrote: > >> On Thu, 17 Apr 2008 19:30:33 -0700, erikcw wrote: > >>> use some sort of data-structure (maybe > >>> nested dictionaries or a custom class) and store the pickled > >>> data-structure in a single row in the database (then unpickle the data > >>> and query in memory). > >> Why would you want to do this? I don't see what you would hope to gain by > >> doing this, over just using a database. > > > Are databases truly another language from Python, fundamentally? > > Yes. ?A fair amount of study went into them. ?Databases are about > information that survives the over an extended period of time (months > or years, not hours). > > Classic qualities for a database that don't normally apply to Python > (all properties of a "transaction" -- bundled set of changes): > ? ? ?* Atomicity: > ? ? ? ? A transaction either is fully applied or not applied at all. > ? ? ?* Consistency: > ? ? ? ? Transactions applied to a database with invariants preserve > ? ? ? ? those invariants (things like balance sheets totals). > ? ? ?* Isolation: > ? ? ? ? Each transactions happens as if it were happening at its own > ? ? ? ? moment in time -- tou don't worry about other transactions > ? ? ? ? interleaved with your transaction. > ? ? ?* Durability: > ? ? ? ? Once a transaction actually makes it into the database, it stays > ? ? ? ? there and doesn't magically fail a long time later. > > -Scott David Daniels > Scott.Dani... at Acm.Org Scott, Classical qualities for Python that don't normally apply to a database are: * Encapsulation * Modularity (Besides for social factors,) I make case that database language is always better to start learning than program language. They have no properties of databases. Hold that databases are slightly less sophisticated than language, and you hold rates at which data comes from the universe. Note, information isn't terribly well quantified, but is empirical. Note, matter comes from the universe too, but information goes to heads and we care. I hold it's proper to distinguish, though: you're doing the usual things to data from the real world, but it seems like things I want to do to computer screen are hard to do to a computer screen. I'm sensitive to money (want>0); why doesn't it want to do computers? I'd rather just animate plastics. Hook some up to it. Build roads and surfboards. (No snowboards; it's water; or it's way below it.) Plus get a bunch from the A.C. lines. Data always come from the universe, i.e. from matter. Just another way to make money with it. Everyone can make money, what's the problem with SQL? From meisnernel73884 at gmail.com Wed Apr 30 06:38:27 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:38:27 -0700 (PDT) Subject: rar password crack Message-ID: rar password crack http://crack.cracksofts.com From hamish at valvesoftware.com Wed Apr 16 14:35:44 2008 From: hamish at valvesoftware.com (Hamish McKenzie) Date: Wed, 16 Apr 2008 11:35:44 -0700 Subject: str class inheritance prob? Message-ID: <587C2C9324493D4B96BD6BBCDEAC321AA956C8@exchange3.valvesoftware.com> so I'm trying to create a class that inherits from str, but I want to run some code on the value on object init. this is what I have: class Path(str): def __init__( self, path ): clean = str(path).replace('\\','/') while clean.find('//') != -1: clean = clean.replace('//','/') print 'cleaned on init:\t',clean self = clean so clearly the clean variable is what I want value of the string to be, but that's decidedly not the case. so running this: a=Path('path///with\\nasty/////crap_in_it/') print a gives me this: cleaned on init: path/with/nasty/crap_in_it/ path///with\nasty/////crap_in_it/ what gives? what am I doing wrong, and can I do what I'm trying to here? thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From Magnus.Moraberg at gmail.com Wed Apr 2 09:15:33 2008 From: Magnus.Moraberg at gmail.com (Magnus.Moraberg at gmail.com) Date: Wed, 2 Apr 2008 06:15:33 -0700 (PDT) Subject: Nested try...except References: Message-ID: <0a34849f-bcda-419b-a10f-772d76172d1f@b5g2000pri.googlegroups.com> On 2 Apr, 15:12, cokofree... at gmail.com wrote: > On Apr 2, 3:06 pm, Magnus.Morab... at gmail.com wrote: > > > > > Hi, > > > I found the following code on the net - > > > http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/%3C20050924104732.5116.qm... at minotaur.apache.org%3E > > > def count(self): > > - db = sqlite.connect(self.filename, > > isolation_level=ISOLATION_LEVEL) > > - try: > > - try: > > - cur = db.cursor() > > - cur.execute("select count(*) from sessions") > > - return cur.fetchone()[0] > > - finally: > > - cur.close() > > - finally: > > - db.close() > > > I don't understand though why the second try is not after the line cur > > = db.cursor(). Can anyone explain for me why? > > > /Barry. > > Better question is why is there a try with no except... > > Better yet, WHY is there two TRY statements when there could quite > happily be only one... > > Towards what you are asking, I GUESS...because the author hoped to > handle the cases where cur failed to get assigned...but then > his .close method of it would likely not work anyway...I mean...does > this even work...YUCK I shouldn't have written "Nested try...except" as the title, instead I mean "Nested try...finally". Sorry about that... Anyway, how would you do this? That is, use a finally to close the network connection and the cursor? Thanks for your help, Barry From mmanns at gmx.net Sat Apr 19 16:07:14 2008 From: mmanns at gmx.net (Martin Manns) Date: Sat, 19 Apr 2008 22:07:14 +0200 Subject: ANN: pyspread 0.0.1 References: Message-ID: On Fri, 18 Apr 2008 04:46:38 +0200 Martin Manns wrote: > pyspread 0.0.1 is now available at: > http://pyspread.sourceforge.net Hi, I updated to version 0.0.2 that fixes the tarballs and zip files. Any information about the package working on different platforms is appreciated. I got it working on Gentoo and on Debian (python 2.4). Best Regards Martin From hopeorpha308 at gmail.com Sun Apr 27 07:44:32 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:44:32 -0700 (PDT) Subject: stalker shadow of chernobyl crack Message-ID: stalker shadow of chernobyl crack http://wga-cracks.crackkey.net From __peter__ at web.de Sun Apr 6 05:26:35 2008 From: __peter__ at web.de (Peter Otten) Date: Sun, 06 Apr 2008 11:26:35 +0200 Subject: Problems trying to hook own exception function to sys.excepthook References: Message-ID: Sami wrote: > Hello, > > I am new to Python. > > I tried to hook my own ExceptionPrintingFunction sys.excepthook but it > does not work. > > This is what I wrote: > ----------------------------------------------------------------------- > import sys > > def MyOwnExceptHook(typ, val, tb): > print "Inside my own hook" > > sys.excepthook = MyOwnExceptHook > > x = 1/0 > ----------------------------------------------------------------------- > This is what I get > ----------------------------------------------------------------------- > Traceback (most recent call last): > File > "E:/Home/Programming/Python/TryProjects/ExceptHandling1/Except5.py", > line 8, in > x = 1/0 > ZeroDivisionError: integer division or modulo by zero > ----------------------------------------------------------------------- > > I never see "Inside my own hook" which tells me that the hook is not > being called. What I really want to test is to stop the exception from > propagating further and leave the program intact. > > What am I doing wrong? Please let me know if there are any other newbie > groups that I should probably try in stead. Are you running your code from within idle? It wraps your script in something like try: # run script except: # show traceback (Have a look at InteractiveInterpreter.runcode() in code.py if you are interested in the actual code) So your except hook never gets to see the exception and therefore won't be invoked. Run your script from the commandline and you will see the behaviour you expected. Peter From marco at sferacarta.com Thu Apr 3 09:43:52 2008 From: marco at sferacarta.com (Marco Mariani) Date: Thu, 03 Apr 2008 15:43:52 +0200 Subject: object-relational mappers In-Reply-To: References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> Message-ID: Tim Golden wrote: > I've recently used Elixir and found it very useful for a small-scale > database with no more than a dozen tables, well-structured and > easily understood. I'd certainly use it again for anything like that > to save me writing what would amount to boilerplate SQL. But I'd > hate to imagine it in the context of my day job: a messy, organic > and sprawling SQL Server database with over 1,000 tables, let alone > views, procedures and so on. That's the scenario where the rest of SQLAlchemy (beyond Elixir, that is, and with reflection turned to 11) can do mucho bueno. From medin0065 at gmail.com Sun Apr 20 10:44:43 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:44:43 -0700 (PDT) Subject: police shoulder patch trade Message-ID: police shoulder patch trade http://cracks.00bp.com F R E E C R A C K S From andreww591 at gmail.com Fri Apr 11 05:23:08 2008 From: andreww591 at gmail.com (Andrew Warkentin) Date: Fri, 11 Apr 2008 03:23:08 -0600 Subject: Suitable libraries for implementing a "push"-type matching engine? Message-ID: <47FF2DFC.6040502@gmail.com> I am trying to write a matching engine for a matching language for a filtering proxy compatible with that of The Proxomitron. The matching language is basically an extended superset of shell-style globs, with functionality comparable to regexps (see http://www.proxomitron.info/45/help/Matching%20Rules.html). Can anyone recommend any Python libraries that would be suitable for my purposes? I think that I can implement a parser for the patterns themselves with pyparsing, but I'm not sure if anything suitable for finding matches in an input stream of text exists. I don't want to reinvent the wheel if I don't have to. A matching engine for a filtering proxy has to be able to handle partial input and "hold" data until enough is received to determine whether there is a match (or else the entire document would have to be held until the end is reached, filtered, and then sent all at once to the remote client, and that would make it appear much less responsive and possibly break some applications). I also need to be able to associate specific patterns (matching commands and certain backslash-escapes) with functions that are called to determine if they match. From stefan_ml at behnel.de Fri Apr 25 02:16:57 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 25 Apr 2008 08:16:57 +0200 Subject: convert xhtml back to html In-Reply-To: References: <4810E5CC.2000503@behnel.de> Message-ID: <48117759.4090909@behnel.de> bryan rasmussen top-posted: > On Thu, Apr 24, 2008 at 9:55 PM, Stefan Behnel wrote: >> from lxml import etree >> >> tree = etree.parse("thefile.xhtml") >> tree.write("thefile.html", method="html") >> >> http://codespeak.net/lxml > > wow, that's pretty nice there. > > Just to know: what's the performance like on XML instances of 1 GB? That's a pretty big file, although you didn't mention what kind of XML language you want to handle and what you want to do with it. lxml is pretty conservative in terms of memory: http://blog.ianbicking.org/2008/03/30/python-html-parser-performance/ But the exact numbers depend on your data. lxml holds the XML tree in memory, which is a lot bigger than the serialised data. So, for example, if you have 2GB of RAM and want to parse a serialised 1GB XML file full of little one-element integers into an in-memory tree, get prepared for lunch. With a lot of long text string content instead, it might still fit. However, lxml also has a couple of step-by-step and stream parsing APIs: http://codespeak.net/lxml/parsing.html#the-target-parser-interface http://codespeak.net/lxml/parsing.html#the-feed-parser-interface http://codespeak.net/lxml/parsing.html#iterparse-and-iterwalk They might do what you want. Stefan From HDoran at air.org Mon Apr 14 08:36:28 2008 From: HDoran at air.org (Doran, Harold) Date: Mon, 14 Apr 2008 08:36:28 -0400 Subject: Process multiple files Message-ID: <2323A6D37908A847A7C32F1E3662C80E017BDF37@dc1ex01.air.org> Say I have multiple text files in a single directory, for illustration they are called "spam.txt" and "eggs.txt". All of these text files are organized in exactly the same way. I have written a program that parses each file one at a time. In other words, I need to run my program each time I want to process one of these files. However, because I have hundreds of these files I would like to be able to process them all in one fell swoop. The current program is something like this: sample.py new_file = open('filename.txt', 'w') params = open('eggs.txt', 'r') do all the python stuff here new_file.close() If these files followed a naming convention such as 1.txt and 2.txt I can easily see how these could be parsed consecutively in a loop. However, they are not and so is it possible to modify this code such that I can tell python to parse all .txt files in a certain directory and then to save them as separate files? For instance, using the example above, python would parse both spam.txt and eggs.txt and then save 2 different files, say as spam_parsed.txt and eggs_parsed.txt. Thanks From tracyde at gmail.com Wed Apr 2 10:59:57 2008 From: tracyde at gmail.com (Derek Tracy) Date: Wed, 2 Apr 2008 10:59:57 -0400 Subject: Manipulate Large Binary Files Message-ID: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> I am trying to write a script that reads in a large binary file (over 2Gb) saves the header file (169088 bytes) into one file then take the rest of the data and dump it into anther file. I generated code that works wonderfully for files under 2Gb in size but the majority of the files I am dealing with are over the 2Gb limit INPUT = open(infile, 'rb') header = FH.read(169088) ary = array.array('H', INPUT.read()) INPUT.close() OUTF1 = open(outfile1, 'wb') OUTF1.write(header) OUTF2 = open(outfile2, 'wb') ary.tofile(OUTF2) When I try to use the above on files over 2Gb I get: OverflowError: requested number of bytes is more than a Python string can hold Does anybody have an idea as to how I can get by this hurdle? I am working in an environment that does not allow me to freely download modules to use. Python version 2.5.1 R/S -- --------------------------------- Derek Tracy tracyde at gmail.com --------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From dblubaugh at belcan.com Tue Apr 22 18:13:51 2008 From: dblubaugh at belcan.com (Blubaugh, David A.) Date: Tue, 22 Apr 2008 18:13:51 -0400 Subject: Lucky gay sucking cock while butt fucked deep In-Reply-To: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> Message-ID: <27CC3060AF71DA40A5DC85F7D5B70F38033A4F29@AWMAIL04.belcan.com> Is there a way to block these messages. I do not want to be caught with filth such as this material. I could lose my job with Belcan with evil messages such as these messages. David Blubaugh -----Original Message----- From: uniontelecardsindia at gmail.com [mailto:uniontelecardsindia at gmail.com] Sent: Tuesday, April 22, 2008 5:14 PM To: python-list at python.org Subject: Lucky gay sucking cock while butt fucked deep Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . This e-mail transmission contains information that is confidential and may be privileged. It is intended only for the addressee(s) named above. If you receive this e-mail in error, please do not read, copy or disseminate it in any manner. If you are not the intended recipient, any disclosure, copying, distribution or use of the contents of this information is prohibited. Please reply to the message immediately by informing the sender that the message was misdirected. After replying, please erase it from your computer system. Your assistance in correcting this error is appreciated. From bignose+hates-spam at benfinney.id.au Tue Apr 8 21:20:41 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Wed, 09 Apr 2008 11:20:41 +1000 Subject: import statement convention References: <4078bcf4-e68f-45d4-93ce-335ec7a33c5a@v32g2000prd.googlegroups.com> Message-ID: <87fxtvomc6.fsf@benfinney.id.au> MartinRinehart at gmail.com writes: > By convention, I've read, your module begins with its import > statements. Is this always sensible? There are exceptions, but the benefits are great: It's very easy to see what this module requires, without needing to execute it. > I put imports that are needed for testing in the test code at the > end of the module. If only a bit of the module has a visual > interface, why pollute the global namespace with 'from Tkinter > import *'? Wouldn't that be better done in a separate class or > function? If your test code requires the Tkinter module but the rest of the code doesn't, why pollute the functional module with such test code? Move it to a separate unit test module. -- \ ?Never do anything against conscience even if the state demands | `\ it.? ?Albert Einstein | _o__) | Ben Finney From steve at holdenweb.com Sat Apr 5 22:14:15 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 22:14:15 -0400 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> Message-ID: <47F831F7.4000709@holdenweb.com> Fredrik Lundh wrote: > Fredrik Lundh wrote: > >> and for the record, Python doesn't look for PYD files on any of the Unix >> boxes I have convenient access to right now. what Ubuntu version are >> you using, what Python version do you have, and what does >> >> $ python -c "import imp; print imp.get_suffixes()" >> >> print on your machine? > > for reference, here's what I get on Ubuntu 7.10, with the standard > Python interpreter (2.5.1): > > $ python -c "import imp; print imp.get_suffixes()" > [('.so', 'rb', 3), ('module.so', 'rb', 3), ('.py', 'U', 1), > ('.pyc', 'rb', 2)] > > any Ubuntu gurus here that can sort this one out? > I wouldn't claim to be an Ubuntu guru but it seems as though the Ubuntu team decide that you would be able to import extension module YYY either from YYY.so or from YYYmodule.so. IF you are asking *why* then I'd have to answer that I have no idea at all. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From simone.brunozzi at gmail.com Tue Apr 8 10:14:56 2008 From: simone.brunozzi at gmail.com (Simone Brunozzi) Date: Tue, 8 Apr 2008 07:14:56 -0700 (PDT) Subject: Looking for Conferences/Events on Django, Python, MySQL, etc in Europe 2008? References: <7fb0f408-1a2e-4ee1-a179-092f83eb1591@8g2000hsu.googlegroups.com> Message-ID: <8100c94f-3205-480c-9f8a-f56b4ac8b7f3@8g2000hsu.googlegroups.com> On Apr 8, 12:36 pm, "Simon Brunning" wrote: > On Tue, Apr 8, 2008 at 10:10 AM, Simone Brunozzi > > wrote: > > Greetings! > > > I'm looking for conferences or events about Python, Django, Dabatases, > > Mysql, > > PHP, Ruby in Europe (or nearby locations like north africa and middle > > east) in 2008. > > Do you have any suggestions? > > PyCon UK 2008 - 12th to 14th September 2008 - . > > -- > Cheers, > Simon B. > si... at brunningonline.nethttp://www.brunningonline.net/simon/blog/ Thanks a lot! From jkugler at bigfoot.com Wed Apr 9 14:57:07 2008 From: jkugler at bigfoot.com (Joshua Kugler) Date: Wed, 09 Apr 2008 10:57:07 -0800 Subject: Google App Engine References: Message-ID: Duncan Booth wrote: > http://www.techcrunch.com/2008/04/07/google-jumps-head-first-into-web-services-with-google-app-engine/ > "Python only. What a weird decision. Not business and > community-friendly at all." Translation: "Not over-engineered-top-heavy-overly-complex-job-security-inducing-Java-enterprise friendly." j From gagsl-py2 at yahoo.com.ar Sun Apr 20 13:29:32 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 14:29:32 -0300 Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: En Sun, 20 Apr 2008 13:42:05 -0300, Matthew Woodcraft escribi?: > An alternative scheme for describing the block structure could be > useful in other cases, though. For example, if you wanted to support > putting snippets of Python in configuration files, or spreadsheet > cells. > [...] If someone wrote a library for this and it proved popular, I expect it > would be considered for the standard library. There is "pindent.py" in the Tools/scripts directory: # ... When called as "pindent -r" it assumes its input is a # Python program with block-closing comments but with its indentation # messed up, and outputs a properly indented version. # A "block-closing comment" is a comment of the form '# end ' # where is the keyword that opened the block ... def foobar(a, b): if a == b: a = a+1 elif a < b: b = b-1 if b > a: a = a-1 # end if else: print 'oops!' # end if # end def foobar -- Gabriel Genellina From aldo at nullcube.com Sat Apr 5 06:54:59 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Sat, 5 Apr 2008 21:54:59 +1100 Subject: ANN: pry unit testing framework In-Reply-To: References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> Message-ID: <20080405105459.GB15154@nullcube.com> Thus spake Matthieu Brucher (matthieu.brucher at gmail.com): > How does it compare to the nose framework ? As far as the base unit testing functionality is concerned, I think they try to address similar problems. Both have assert-based testing with inspection and re-parsing of assert exceptions for better error messages. Both try to provide better fixture management. Both make programmatic test generation easier. Both have a command-line tool for running and gathering tests. I like nose, but I'm biased, and of course I think Pry has some advantages. One difference I'd point out is Pry's tree-based test structure, which provides a number of conveniences and features (much nicer test selection from the command line, for instance). Pry is also less than half the size of nose, and should therefore be simpler to extend and understand. At any rate, feel free to take a look at Pry and see what you think. Regards, Aldo -- Aldo Cortesi Managing Director M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From sjmachin at lexicon.net Mon Apr 21 17:04:49 2008 From: sjmachin at lexicon.net (John Machin) Date: Mon, 21 Apr 2008 21:04:49 GMT Subject: List of all Python's ____ ? In-Reply-To: <87wsmrdka8.fsf@mulj.homelinux.net> References: <87wsmrdka8.fsf@mulj.homelinux.net> Message-ID: <480d016e$1@news.mel.dft.com.au> Hrvoje Niksic wrote: > python at bdurham.com writes: > >> Is there an official list of all Python's ____? > > http://docs.python.org/ref/specialnames.html __missing__ is missing :-) see note (10) at the bottom of http://docs.python.org/lib/typesmapping.html From aahz at pythoncraft.com Sun Apr 20 22:47:35 2008 From: aahz at pythoncraft.com (Aahz) Date: 20 Apr 2008 19:47:35 -0700 Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: In article <739039ff-10f6-4369-9886-3af628798c22 at 2g2000hsn.googlegroups.com>, Mike Driscoll wrote: > >My workplace doesn't offer NNTP, so there is no good way to browse >c.l.py here. And I haven't been able to get NNTP to work from my home >either. Can you use ssh? Get a shell account somewhere else. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "It is easier to optimize correct code than to correct optimized code." --Bill Harlan From george.sakkis at gmail.com Fri Apr 25 22:41:27 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 25 Apr 2008 19:41:27 -0700 (PDT) Subject: Setting an attribute without calling __setattr__() References: Message-ID: <8b41c868-5630-4bdf-b780-8925ca382cef@34g2000hsh.googlegroups.com> On Apr 25, 5:01 pm, Joshua Kugler wrote: > My init lookslike this: > > def __init__(self, obj=None): > if type(obj).__name__ in 'list|tuple|set|frozenset': > self.me = [] > for v in obj: > self.me.append(ObjectProxy(v)) > elif type(obj) == dict: > self.me = {} > for k,v in obj.items(): > self.me[k] = ObjectProxy(v) As an aside, unrelated to your question, Python encourages "duck typing" instead of exact type matching. Unless you have a good reason to restrict obj to one of the 5 types you hardcoded (a rather rare need), it is more flexible to write it as: def __init__(self, obj=None): if hasattr(obj, 'items'): # assume obj is a mapping type instance self.me = dict((k,ObjectProxy(v)) for k,v in obj.items()) else: try: # check if obj is an iterable instance self.me = map(ObjectProxy, obj) except TypeError: # handle other cases here # self.me = ... A downside of this flexibility is that it may be more liberal than it should. For instance, if obj just happens to have an 'items()' method but it's not really a mapping type, the assumption is violated. Python 3 deals with such potential ambiguities by introducing Abstract Base Classes (ABCs) [1] that allow a class to make explicit its semantics. So in Py3K the hasattr() test above would rather be written as "isinstance(obj, Mapping)", where Mapping is the ABC that represents (read-only) mappings. A more difficult problem is that even if a class derives from some ABC, you may not always want to treat its instances as such. The typical gotcha is that strings are iterable, but in many (most?) applications they are to be treated as atomic values, not as sequences of characters. So in the example above if obj is a string, self.me will be a list of ObjectProxy instances, one per character; probably not what you intend. Of course we can check for "isinstance(obj,str)" but then we're back at explicit type checking. There is no general way to express something lke "atomic value that also happens to be iterable (but pretend it's not)" because it's inherently domain- dependent. George [1] http://www.python.org/dev/peps/pep-3119/ From aldo at nullcube.com Sat Apr 5 08:07:08 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Sat, 5 Apr 2008 23:07:08 +1100 Subject: ANN: pry unit testing framework In-Reply-To: <740c3aec0804050426m39837404i8e8d6c232bef7724@mail.gmail.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <740c3aec0804050426m39837404i8e8d6c232bef7724@mail.gmail.com> Message-ID: <20080405120708.GB15684@nullcube.com> Thus spake BJ?rn Lindqvist (bjourne at gmail.com): > Isn't nose tree-based too? You can select both single test-cases > suites or directories to run. Well, in a way, perhaps. But not in the sense that Pry is. In Pry you can nest test fixtures (setUp/tearDown pairs) within test fixtures, allowing arbitrarily deep fixture hierarchies. You can then address any sub-tree in this hierarchy from the command-line. This structure turns out to be terribly useful in practice, when, for example, developing database applications. > Anyway, I don't think comparisions with nose is fair, because nose is > the best of the best and all other test runners fall short of it. :) I'll take your word for it. ;) Unfortunately, the more bang per line of code argument won't do, since the number of lines of code in your nose example and the Pry example matches almost exactly. Unless, of course, you were joking and that was precisely the point you were trying to make... in which case I apologise and you can ignore this... ;) Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From nagle at animats.com Mon Apr 7 14:27:48 2008 From: nagle at animats.com (John Nagle) Date: Mon, 07 Apr 2008 11:27:48 -0700 Subject: Orphaned child processes In-Reply-To: <51102b91-dedc-4ad6-a936-c29df47f30ab@r9g2000prd.googlegroups.com> References: <51102b91-dedc-4ad6-a936-c29df47f30ab@r9g2000prd.googlegroups.com> Message-ID: <47fa650f$0$36329$742ec2ed@news.sonic.net> rocco.rossi at gmail.com wrote: > I'm using the Python processing module. I've just run into a problem > though. Actually, it's a more general problem that isn't specific to > this module, but to the handling of Unix (Linux processes) in general. > Suppose for instance that for some reason or another, after forking > several child processes, the main process terminates or gets killed > (or segfaults or whatever) and the child processes are orphaned. Is > there any way to automatically arrange things so that they auto- > terminate or, in other words, is there a way to make the child > processes terminate when the parent terminates? > > Thank you. Put a thread in the child which reads stdin, and make stdin connect to a pipe from the parent. When the parent terminates, the child will get a SIGPIPE error and raise an exception. John Nagle From bbxx789_05ss at yahoo.com Wed Apr 2 17:26:05 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Wed, 2 Apr 2008 14:26:05 -0700 (PDT) Subject: class / module introspection? References: <3c3f09df-08cb-4309-a870-6b12a813a8af@u36g2000prf.googlegroups.com> <0f14a289-55ef-49e5-b650-60f7aca371ad@i36g2000prf.googlegroups.com> Message-ID: <033570bc-c5f3-4575-8dae-51780e68d2d7@m3g2000hsc.googlegroups.com> On Apr 2, 1:27?pm, Brian Munroe wrote: > On Apr 2, 12:07 pm, Brian Munroe wrote: > > > > > This gives me ['system1','system2'] - which I can then use __import__ > > on. > > Addendum, thanks Bruno! > > I also required the helper function (my_import) from the Python docs > You don't need that helper function, which is a little tricky to follow: If you have a module name as a string, you can use the builtin function __import__ to import the module, e.g. x = __import__("mymod") x.myfunc() Note that you have to assign the return value of __import__ to a variable. Thereafter you use the variable to access the module's functions. However, when you use __import__ with a package, it behaves in a peculiar manner: it returns the top level package object. For example, if you write: x = __import__("mypackage.subpack.myfuncs") then x is a reference to mypackage--not mypackage.subpack.myfuncs. In order to execute a function in the module myfuncs, you need to write: x.subpack.myfuncs.f(). Or, if you check the docs, you can make __import__ return the rightmost module in the module string by writing: x = __import__("mypackage.subpack.myfuncs", globals(), locals(), ["subpack.myfuncs"]) The last argument is what makes __import__ return a lower level module in the package hierarchy. To solve your problem, you can do something like the following: Directory structure ------------------- ../mypackage __init__.py /system1 __init__.py myfuncs.py /system2 __init__.py myfuncs.py system1/myfuncs.py ------------ def f(): print "system1 here" system2/myfuncs.py ----------------- def f(): print "system2 here" import sys import os #Get all the file names contained in mypackage: fnames = os.listdir("../mypackage") print fnames #Separate out the directory names(which are the sub packages): os.chdir("../mypackage") #so abspath() below can construct full paths package_dirs = [] for fname in fnames: abs_path = os.path.abspath(fname) #need full path for isdir() print abs_path, if os.path.isdir(abs_path): print 'dir' package_dirs.append(fname) else: print 'file' print package_dirs sys.path.append("../") #directs python to search the specified #dir for any modules that are imported #Import the sub packages: for dir in package_dirs: modname = "%s.%s.%s" % ("mypackage", dir, "myfuncs") modname_minus_toplevel_packname = "%s.%s" % (dir, "myfuncs") mod = __import__(modname, globals(), locals(), [modname_minus_toplevel_packname]) mod.f() --output:-- ['__init__.py', '__init__.pyc', 'system1', 'system2'] /Users/me/2testing/mypackage/__init__.py file /Users/me/2testing/mypackage/__init__.pyc file /Users/me/2testing/mypackage/system1 dir /Users/me/2testing/mypackage/system2 dir ['system1', 'system2'] system1 here system2 here From nick at craig-wood.com Mon Apr 28 05:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Mon, 28 Apr 2008 04:30:03 -0500 Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> <18c1e6480804270653r2e075061wf442b7b7d9f50ff6@mail.gmail.com> Message-ID: David wrote: > Another idea would be to have multiple queues, one per thread or per > message type "group". The producer thread pushes into the appropriate > queues (through an intelligent PutMsg function), and the consumer > threads pull from the queues they're interested in and ignore the > others. Unfortunately a thread can only wait on one Queue at once (without polling). So really the only efficient solution is one Queue per thread. Make an intelligent PutMsg function which knows which Queue (or Queues) each message needs to be put in and all the threads will have to do is Queue.get() and be sure they've got a message they can deal with. -- Nick Craig-Wood -- http://www.craig-wood.com/nick From danb_83 at yahoo.com Wed Apr 30 21:04:20 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Wed, 30 Apr 2008 18:04:20 -0700 (PDT) Subject: We have string.isdigit(), why not string.isNumber()? References: <0d43feda-fab8-46ba-9af0-eaf497033acd@l17g2000pri.googlegroups.com> Message-ID: On Apr 30, 7:56 pm, MooMaster wrote: > N00b question alert! I did a search for isdigit() in the group > discussion, and it didn't look like the question had been asked in the > first 2 pages, so sorry if it was... > > The manual documentation says: > "isdigit( ) > > Return true if all characters in the string are digits and there is at > least one character, false otherwise. > For 8-bit strings, this method is locale-dependent. " > > So it makes sense that something like 5.6 would return false. But what > if we want to make sure that our string is a valid number, ie decimals > included? > > I know how to write a regexp or method or whatever to do this, my main > question is *why* something like an isNumber() method is not baked > into the class. Does such functionality exist somewhere else in the > standard library that I'm just missing? A string s is a valid number if float(s) does not raise a ValueError. From samslists at gmail.com Mon Apr 21 18:48:40 2008 From: samslists at gmail.com (samslists at gmail.com) Date: Mon, 21 Apr 2008 15:48:40 -0700 (PDT) Subject: Problems replacing \ with \\ Message-ID: <0ca30eb2-3791-4910-9e78-f32e3b2a72cb@2g2000hsn.googlegroups.com> Hi... Here's a weird problem...I'm trying to escape a bunch of data to put into a database. Here's what I have: def escape(string): """ Escape both single quotes and blackslashes >>> x = r"fun\fun" >>> escape(x) 'fun\\\\fun' """ string = string.replace('\\', '\\\\') return string Now the commands in the doctest work when I type them by hand into the python interpreter! >>> x = r"fun\fun" >>> escape(x) 'fun\\\\fun' But they don't work when I actually run them with doctest: Failed example: escape(x) Expected: 'fun\\fun' Got: 'fun\x0cun' Why? Thanks! From steve at holdenweb.com Sat Apr 5 22:08:45 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 22:08:45 -0400 Subject: Best way to check if string is an integer? In-Reply-To: <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> Message-ID: <47F830AD.9050106@holdenweb.com> John Machin wrote: > On Apr 6, 9:25 am, Mark Dickinson wrote: >> On Apr 5, 6:19 pm, skanem... at yahoo.se wrote: >> >>> which is the best way to check if a string is an number or a char? >>> could the 2nd example be very expensive timewise if i have to check a >>> lot of strings? >> You might be interested in str.isdigit: >> >>>>> print str.isdigit.__doc__ >> S.isdigit() -> bool >> >> Return True if all characters in S are digits >> and there is at least one character in S, False otherwise. >> > > This doesn't cater for negative integers. > No, it doesn't, but s.isdigit() or (s[0] in "+-" and s[1:].isdigit) # untested does. and *may* be quicker than other examples. Not that speed is usually a concern in validation routines anyway ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From balta96428 at gmail.com Wed Apr 23 06:00:06 2008 From: balta96428 at gmail.com (balta96428 at gmail.com) Date: Wed, 23 Apr 2008 03:00:06 -0700 (PDT) Subject: crack how to make Message-ID: <5f690ef1-d5da-42a9-85e1-885cedbe6ed4@k37g2000hsf.googlegroups.com> crack how to make http://cracks.12w.net F R E E C R A C K S From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 3 10:22:30 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 03 Apr 2008 16:22:30 +0200 Subject: How easy is it to install python as non-root user? In-Reply-To: <47f4e617$0$720$bed64819@news.gradwell.net> References: <47f4e617$0$720$bed64819@news.gradwell.net> Message-ID: <47f4e825$0$20141$426a74cc@news.free.fr> tinnews at isbd.co.uk a ?crit : > Does python install fairly easily for a non-root user? > > I have an ssh login account onto a Linux system that currently > provides Python 2.4.3 and I'd really like to use some of the > improvements in Python 2.5.x. > > So, if I download the Python-2.5.2.tgz file is it just the standard:- > > ./configure --prefix=$HOME > make > make install > IIRC there's something like make altinstall - but you'd better read the doc (INSTALL.txt anyone ?) From kyosohma at gmail.com Tue Apr 8 17:12:26 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 8 Apr 2008 14:12:26 -0700 (PDT) Subject: Running a python code periodically References: Message-ID: On Apr 8, 3:01 pm, Larry Bates wrote: > paul wrote: > > Maryam Saeedi schrieb: > >> Hi, > > >> I was wondering if you know how can I run a python code once every five > >> minutes for a period of time either using python or some other program > >> like > >> a bash script. > > > See the sched module in the standard library or here: > >http://pypi.python.org/simple/Recur/ > > > cheers > > Paul > > You could use cron also. > > -Larry And if you're on Windows, you can use the Scheduled Task Manager. Mike From breily at gmail.com Tue Apr 8 18:36:18 2008 From: breily at gmail.com (Brian) Date: Tue, 8 Apr 2008 18:36:18 -0400 Subject: Converting a tuple to a list In-Reply-To: References: <00ba01c899c5$14528ae0$0a01a8c0@mobile> Message-ID: On Tue, Apr 8, 2008 at 6:22 PM, Steve Holden wrote: > Gabriel Ibanez wrote: > > Hi all .. > > > > I'm trying to using the map function to convert a tuple to a list, > without > > success. > > > > I would like to have a lonely line that performs the same as loop of the > > next script: > > > > ------------------------------------------- > > # Conveting tuple -> list > > > > tupla = ((1,2), (3,4), (5,6)) > > > > print tupla > > > > lista = [] > > for a in tupla: > > for b in a: > > lista.append(b) > > print lista > > ------------------------------------------- > > > > Any idea ? > > > > Thanks ... > > > > # Gabriel > > > list(tupla) > > would probably do it. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > That would just make a list of tuples, I think he wants [1, 2, 3, 4, 5, 6]. Try: l = [x for z in t for x in z] --Brian -------------- next part -------------- An HTML attachment was scrubbed... URL: From marli305nugent at gmail.com Sat Apr 26 09:49:53 2008 From: marli305nugent at gmail.com (marli305nugent at gmail.com) Date: Sat, 26 Apr 2008 06:49:53 -0700 (PDT) Subject: windows xp crack serial Message-ID: <9ec0182b-0db2-4599-a935-fdd1eccffc3d@y38g2000hsy.googlegroups.com> windows xp crack serial http://cracks.00bp.com F R E E C R A C K S From magdoll at gmail.com Tue Apr 29 20:11:46 2008 From: magdoll at gmail.com (Magdoll) Date: Tue, 29 Apr 2008 17:11:46 -0700 (PDT) Subject: best way to host a membership site Message-ID: <53034dcc-7346-4f71-889c-3278c9e813ec@w1g2000prd.googlegroups.com> Hi, I know this is potentially off-topic, but because python is the language I'm most comfortable with and I've previously had experiences with plone, I'd as much advice as possible on this. I want to host a site where people can register to become a user. They should be able to maintain their own "showroom", where they can show blog entries (maybe just by linking to their own blogs on some other blog/album-hosting site like Xanga), put up pictures (again, I'm not thinking about actually hosting these data, since there are already plenty of places to put your pictures and blogs). The most important thing is they will be able to build up a "profile" where I can store in a DB. The profile will include membership information - for now, think of it as "member X owns item A,B,C and gave comments on A such and such, also member X is a male white caucasian between his 20-30 who likes outdoors". Eventually, I want this to be a simple social- networking site where people can share a very particular hobby (I'm doing it for comsetics and for a very targeted group that are active bloggers, so they'll be somewhat web-salient) and the backend can collect enough data (while maintaining privacy) to build up a recommendation system similar to Netflix's movie recommendations, or Match.com if you will. I want to know that given I know python best and I abhor C#/ASP, what is the best thing to use. A friend recommended Ruby on Rails - not to instigate war here, but I'd welcome comments on that (I don't know Ruby, but I'll learn). I've used PLONE before, but back then I remembered the site ran incredably slow (or it could just be the server), and there were issues with upgrades. I want to minimze time on trying to learn how to write an interface for users to register and manage their own space. Also I want an infrastructure that's not too rigid so if in the future I want to add more apps it's not to hard. I've also heard about django, but not enough to know how far it'll get me. I'm open to all sorts of suggestions. Thanks! - Magdoll From fetchinson at googlemail.com Mon Apr 21 14:05:02 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Mon, 21 Apr 2008 11:05:02 -0700 Subject: Does Python 2.5.2's embedded SQLite support full text searching? In-Reply-To: <1208794249.15992.1249049327@webmail.messagingengine.com> References: <1208794249.15992.1249049327@webmail.messagingengine.com> Message-ID: > Does Python 2.5.2's embedded SQLite support full text searching? > > Any recommendations on a source where one can find out which SQLite > features are enabled/disabled in each release of Python? I'm trying to > figure out what's available in 2.5.2 as well as what to expect in 2.6 > and 3.0. Sqlite itself is not distributed with python. Only a python db api compliant wrapper is part of the python stdlib and as such it is completely independent of the sqlite build. In other words, if your sqlite build supports full text searching you can use it through the python sqlite wrapper (that is part of the stdlib) and if it doesn't then not. This is true for any sqlite feature though. So if you need an sqlite feature just go ahead and build your own sqlite with that feature enabled and use that feature with the stock python sqlite wrapper that comes with the stdlib. HTH, Daniel From george.sakkis at gmail.com Thu Apr 3 09:27:14 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Thu, 3 Apr 2008 06:27:14 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> <88b07549-9751-489b-968f-c3d2db0aba79@s13g2000prd.googlegroups.com> Message-ID: On Apr 3, 9:00 am, Jeff wrote: > On Apr 3, 8:44 am, Ant wrote: > > > > > On Apr 3, 12:37 pm, tinn... at isbd.co.uk wrote: > > > > What's the neatest and/or most efficient way of testing if one of a > > > A different approach: > > > >>> words = ["he", "sh", "bla"] > > >>> name = "blah" > > >>> True in (word in name for word in words) > > > True > > > >>> name = "bling" > > >>> True in (word in name for word in words) > > > False > > > Perhaps not as obvious or readable as Jeff's example, but is > > essentially doing the same thing using generator syntax. > > That's pretty :) It's even prettier in 2.5: any(word in name for word in words) George From s0suk3 at gmail.com Wed Apr 16 11:14:28 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Wed, 16 Apr 2008 08:14:28 -0700 (PDT) Subject: Default parameter for a method Message-ID: <806788d2-67b7-456b-bd1e-08c50cbf0f7b@8g2000hsu.googlegroups.com> I wanted to know if there's any way to create a method that takes a default parameter, and that parameter's default value is the return value of another method of the same class. For example: class A: def __init__(self): self.x = 1 def meth1(self): return self.x def meth2(self, arg=meth1()): # The default `arg' should would take the return value of meth1() print '"arg" is', arg This obviously doesn't work. I know I could do ... def meth2(self, arg=None): if arg is None: arg = self.meth1() but I'm looking for a more straightforward way. From nullgraph at gmail.com Wed Apr 16 09:31:04 2008 From: nullgraph at gmail.com (nullgraph at gmail.com) Date: Wed, 16 Apr 2008 06:31:04 -0700 (PDT) Subject: vary number of loops Message-ID: Hi everyone, I'm new to Python and the notion of lambda, and I'm trying to write a function that would have a varying number of nested for loops depending on parameter n. This just smells like a job for lambda for me, but I can't figure out how to do it. Any hint? For example, for n=2, I want the function to look something like: def foo(2) generate 2 sets of elements A, B # mix elements by: for a_elt in A for b_elt in B form all combinations of them If n=3, I want to have 3 sets of elements and mix them up using 3 for loops. Any help is greatly appreciated, nullgraph From mccredie at gmail.com Tue Apr 8 12:32:24 2008 From: mccredie at gmail.com (Matimus) Date: Tue, 8 Apr 2008 09:32:24 -0700 (PDT) Subject: Python 3.0 new integer division References: Message-ID: On Apr 8, 9:13 am, "Hutch" wrote: > We now have a float result when two integers are divided in the same mannor > as 2.4 or 2.5. > I can handle that and use the Floor division but a simple question. > > Why in the world would you round down the last presented digit to a 6 > instead of just leaving it along as an 8. > For some reason rounding down for a float in Python does not seem correct. > > IDLE 3.0a4 > > >>> 12345678901234567890123456789012345678901234567890/345 > > 3.5784576525317586e+46 > > >>> 12345678901234567890123456789012345678901234567890//345 > > 35784576525317588087314367504383610663481839327 > ^ > ^| > 35784576525317586000000000000000000000000000000 == 3.5784576525317586e+46 This just has to do with the way floating point numbers are represented in memory. More information: http://docs.python.org/tut/node16.html Matt From stefan_ml at behnel.de Mon Apr 7 10:02:21 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 07 Apr 2008 16:02:21 +0200 Subject: Dependency Queue In-Reply-To: <0309251d-fba9-447c-9b17-f512988103ea@e39g2000hsf.googlegroups.com> References: <0309251d-fba9-447c-9b17-f512988103ea@e39g2000hsf.googlegroups.com> Message-ID: <47FA296D.5020000@behnel.de> Carl Banks wrote: > I'm looking for any information about a certain kind of dynamic data > structure. Not knowing if it has some well-known name that I could > have Googled, I'll just call it a dependency queue. It's like a > priority queue except instead of a strict ordering of items by > priority, there is only a topological ordering (like you would have in > a directed acyclic graph). > > To date I've been generating a dependency graph in advance every > iteration through my main loop, doing a topsort, and executing the > values in order (the values are callable objects--this is a > scheduler). > > However, I'd like a dynamic dependency queue for two reasons: it would > simplify things to not have to generate the whole graph in advance, > and it could improve performance to run some tasks of the next > iteration in the present one (this could potentially make better use > of the dual-core and graphics hardware). > > I'm pretty sure I could hack out this structure on my own, but I'd > like to see any prior information if there is any, in case anyone's > figured out things like, Is there an easy way to detect cycles on > insertion? and so on. You might consider flattening your graph to map it onto a heap (see the heapq module). One way to do that might be to assign a different power of two to each node and calculate the priority of each node as the sum of its parent's numbers. That way, a child will always have a higher value (== lower priority) than its parents, so the heap will return it after its parents. If you also want a unique priority instead of the same one for all children of the same set of parents, adding the number of the child itself will give you a (possibly arbitrary) unique priority. This (or a similar approach) may or may not solve your problem, depending on how you determine the dependencies. Stefan From n00m at narod.ru Sun Apr 27 15:14:17 2008 From: n00m at narod.ru (n00m) Date: Sun, 27 Apr 2008 12:14:17 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <2d06b319-e2fd-4790-af61-6f90b9b1b3b1@m1g2000pre.googlegroups.com> Message-ID: <41e72e61-6413-41f3-a162-dbcc1ec5fcee@f63g2000hsf.googlegroups.com> Lie wrote: > On Apr 27, 6:28?am, n00m wrote: > > No so simple, guys. > > E.g., I can't solve (in Python) this:http://www.spoj.pl/problems/INTEST/ > > Keep getting TLE (time limit exceeded). Any ideas? After all, it's > > weekend. > > > > 450. Enormous Input Test > > Problem code: INTEST > > > > The purpose of this problem is to verify whether the method you are > > using to read input data is sufficiently fast to handle problems > > branded with the enormous Input/Output warning. You are expected to be > > able to process at least 2.5MB of input data per second at runtime. > > > > Input > > The input begins with two positive integers n k (n, k<=107). The next > > n lines of input contain one positive integer ti, not greater than > > 109, each. > > > > Output > > Write a single integer to output, denoting how many integers ti are > > divisible by k. > > > > Example > > Input: > > 7 3 > > 1 > > 51 > > 966369 > > 7 > > 9 > > 999996 > > 11 > > > > Output: > > 4 > > The problem is faulty. > First, the bottleneck on reading a huge input is the harddisk speed > and the string processing, the result of the competition doesn't prove > anything but how fast the string processor and the harddisk is. > Python's string processing is not a very fast one as it creates a copy > of the string every now and then. In case you didn't pay attention: Python and C++ were tested on the same PC. From bruno.desthuilliers at gmail.com Wed Apr 2 18:41:28 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 15:41:28 -0700 (PDT) Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> <7xwsngyu05.fsf@ruckus.brouhaha.com> <7x8wzw80rf.fsf@ruckus.brouhaha.com> Message-ID: <0d97babc-1174-4537-a7eb-e60164521863@s13g2000prd.googlegroups.com> On 2 avr, 22:23, Paul Rubin wrote: > "bruno.desthuilli... at gmail.com" writes: > > Fine. But totally irrelevant here - this is comp.lang.python, not > > comp.lang.c, and we *do not* (I repeat : we *do not*) face the same > > safety and security problems as those existing in C. > > We have it better than they do in some ways. >In some other ways, we have > it worse. Care to elaborate ? Or are we supposed to guess ?-) From phil at riverbankcomputing.com Thu Apr 3 06:53:26 2008 From: phil at riverbankcomputing.com (Phil Thompson) Date: Thu, 3 Apr 2008 11:53:26 +0100 Subject: State of ctypes Support on HP-UX? Message-ID: <200804031153.26234.phil@riverbankcomputing.com> Could somebody confirm how well ctypes is supported on HP-UX (for both PA-RISC and Itanium) for both Python v2.4 and v2.5? I don't have access to an HP system and Google doesn't come up with a definitive answer (which may just mean it works fine, but prior experience with HP means I'd like more specific assurances). Thanks, Phil From paul at subsignal.org Thu Apr 10 15:24:55 2008 From: paul at subsignal.org (paul) Date: Thu, 10 Apr 2008 21:24:55 +0200 Subject: Running a python code periodically In-Reply-To: References: Message-ID: Larry Bates schrieb: > paul wrote: >> Maryam Saeedi schrieb: >>> Hi, >>> >>> I was wondering if you know how can I run a python code once every five >>> minutes for a period of time either using python or some other program >>> like >>> a bash script. >> See the sched module in the standard library or here: >> http://pypi.python.org/simple/Recur/ >> >> cheers >> Paul >> > You could use cron also. I hate external dependencies! Whats worse is the need to fiddle with settings in different locations. All of a sudden, arcane looking crontabs are configuration files you have to care about. Better to avoid that. cheers Paul From deets at nospam.web.de Tue Apr 15 17:35:57 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 15 Apr 2008 23:35:57 +0200 Subject: How to import C++ static library? In-Reply-To: References: <66j9r8F2k2iplU1@mid.uni-berlin.de> Message-ID: <66klecF2khhndU1@mid.uni-berlin.de> > Diez: I tried SWIG, and it works nicely with C. For C++, I didn't manage > to make it work. I tried SIP; I have some problems compiling etc. Would > it be too much to ask you to supply a working example of a (simple, > stupid) C++ class and the necessary SIP files? Preferably for Mac OS X, > but Linux is also interesting I guess. http://roggisch.de/IrrSinn.tgz That's a pet-project of mine. You won't make it compile though! Just see if it works for you as a template. Diez From maxkhesin at gmail.com Sun Apr 6 09:48:15 2008 From: maxkhesin at gmail.com (xamdam) Date: Sun, 6 Apr 2008 06:48:15 -0700 (PDT) Subject: appropriate python version Message-ID: <0790632f-db07-45ef-9bcd-7e1b592d33be@u69g2000hse.googlegroups.com> Sorry if this is a stupid q, I am trying to figure out the appropriate version of Python(2.4 or 2.5) for an XP 64 system running on an Intel Core2 Quad. Python.org has a to a 64bit build, but it specifies Itanium as the target. Should I just be using the regular build? I was also thinking of getting the Enthought edition (http:// code.enthought.com/enthon/) - would their binary work with the setup, and what would be the downside of using it over the special 64bit build? thanks, max. From sn at sncs.se Thu Apr 17 04:42:07 2008 From: sn at sncs.se (Sverker Nilsson) Date: Thu, 17 Apr 2008 01:42:07 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> Message-ID: On Apr 17, 12:02 am, Carl Banks wrote: > On Apr 16, 12:40 pm, Aaron Watters wrote: > > > > > On Apr 16, 12:27 pm, Rhamphoryncus wrote: > > > > On Apr 16, 6:56 am, Aaron Watters wrote: > > > > > I don't get it. It ain't broke. Don't fix it. > > > > So how would you have done the old-style class to new-style class > > > transition? > > > I'd ignore it. I never understood it and never had > > any need for it anyway. New-style classes and metaclasses > > were a complicated solution to an unimportant problem in > > my opinion. And also a fiendish way to make code > > inscrutible -- which I thought was more of a Perl thing > > than a Python thing, or should be. > > > I must be missing some of the deeper issues here. Please > > educate me. > > The deeper issue is that you're benefiting from these "unimportant" > changes even if you never use them yourself. > > Carl Banks That just seems a BIT categorical for a statement. Who is 'you'? I don't see I benefit from any important or unimportant features in py3k. External libraries I rely on, I can benefit from --- But it would take SOME while to get those libraries ported to py3k, if ever. And I have been benefiting from Python in general, so far. Thanks, community. But now... I'll probably stop posting here for now, & I may stop other things too. Just my 2c. Sverker From grahn+nntp at snipabacken.se Wed Apr 9 15:47:51 2008 From: grahn+nntp at snipabacken.se (Jorgen Grahn) Date: 9 Apr 2008 19:47:51 GMT Subject: Running a python code periodically References: Message-ID: On Tue, 08 Apr 2008 15:01:36 -0500, Larry Bates wrote: > paul wrote: >> Maryam Saeedi schrieb: >>> Hi, >>> >>> I was wondering if you know how can I run a python code once every five >>> minutes for a period of time either using python or some other program like >>> a bash script. >> >> See the sched module in the standard library or here: >> http://pypi.python.org/simple/Recur/ > You could use cron also. Yeah, although cron has minute-resolution, so 5 min is fairly close to the limit of what you can do. Also, the poster mentioned "for a period of time" and that makes me suspect that (s)he really wants the code to make a decision about when to stop executing. /Jorgen -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! From andrei.avk at gmail.com Wed Apr 2 17:01:56 2008 From: andrei.avk at gmail.com (AK) Date: Wed, 02 Apr 2008 16:01:56 -0500 Subject: Python-by-example - new online guide to Python Standard Library In-Reply-To: <30730d40-8f7e-48bd-bb0f-3a95e814b20f@t54g2000hsg.googlegroups.com> References: <47f2d018$0$6517$4c368faf@roadrunner.com> <47f3c751$0$6477$4c368faf@roadrunner.com> <30730d40-8f7e-48bd-bb0f-3a95e814b20f@t54g2000hsg.googlegroups.com> Message-ID: <47f3e642$0$6130$4c368faf@roadrunner.com> CM wrote: > On Apr 2, 2:50 pm, AK wrote: >> Terry Reedy wrote: >>> "AK" wrote in message >>> news:47f2d018$0$6517$4c368faf at roadrunner.com... >>> || I'll be glad to hear comments/suggestions/etc: >>> | >>> |http://www.lightbird.net/py-by-example/ >>> Using - as the example/return delimiter does not work. >>> If you do not want to substantially lengthen the document by going to >>>>>> sqrt(9) >>> 3 >>> then use Python's a comment symbol. >>> sqrt(9) # 3 >>> -or- >>> sqrt(9) # returns 3 (but I think I prefer the first) >>> which clearly is not an arithmetic expression and which can be >>> cut-and-pasted into the interactive interpreter. This also works nicely >>> for invalid examples. >>> sqrt(-9) # raises ValueError >>> Terry Jan Reedy >> Thanks to everybody who replied, I will implement the change as per >> Terry's advice. I'm still considering whether to use the standard >> interpreter syntax, i.e. >>> ... \n result; my reason for not doing that >> is that I will often have a whole screen of function / result lines and >> if I were to add a new line for the result, that'd make two pages out of >> one, which I think is a bit too much. In current docs there are not so >> many examples, so that space is not multiplied quite so much, and using >> interactive interpreter way of showing result is not nearly as much of >> a problem. However, I'm still thinking this over and it seems that >> almost everyone wants to see it done in that way, I might still go for >> two lines. I'll also be posting updates as the work progresses.. >> >> thx, >> >> -- >> -ak >> Tobu |http://www.lightbird.net/tobu/| Freeform DB / Tagger / PIM >> Python-by-Example |http://www.lightbird.net/py-by-example/| Guide >> to LibRef > > You should also change the look of the page to be more high-contrast. > The grayish text in a gray box and the light green text...all too > subtle to see. Not easy for well-sighted people let alone those with > poorer vision. Try make things visually very obvious, bolded headers, > etc. If so, and with the change of showing the result not with an "-" > symbol, it will be much stronger. Thank you for doing it. Okay, will do. In fact this is the second time in as many days that I get a comment on my proposed designs to use more contrasted text vs. background (in fact, for the other design about 3-4 people mentioned this topic). I really had no idea many people have trouble with that. To me, less contrasted text looks smoother and more aesthetically pleasing to the eye, unless I have to read 3 pages or more of condensed text. I also do eye excercises religiously every day:-), so this may train the eyes to see small details better, but I design for other people to use, therefore I will of course try to make it as easy to read for as many people as possible.. Thanks for the comment! I will update the site tomorrow morning with all the changes.. -- -ak Tobu | http://www.lightbird.net/tobu/ | Freeform DB / Tagger / PIM Python-by-Example | http://www.lightbird.net/py-by-example/ | Guide to LibRef From terry.yinzhe at gmail.com Tue Apr 29 10:51:55 2008 From: terry.yinzhe at gmail.com (Terry) Date: Tue, 29 Apr 2008 07:51:55 -0700 (PDT) Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> <18c1e6480804270653r2e075061wf442b7b7d9f50ff6@mail.gmail.com> <9cca03a3-9b96-4bee-947b-baa62cd5f9a9@q24g2000prf.googlegroups.com> Message-ID: <898a6373-a0e7-451f-962b-ec1ed6fc9341@u12g2000prd.googlegroups.com> On Apr 29, 5:30 pm, Nick Craig-Wood wrote: > Terry wrote: > > On Apr 28, 5:30 pm, Nick Craig-Wood wrote: > > > David wrote: > > > > Another idea would be to have multiple queues, one per thread or per > > > > message type "group". The producer thread pushes into the appropriate > > > > queues (through an intelligent PutMsg function), and the consumer > > > > threads pull from the queues they're interested in and ignore the > > > > others. > > > > Unfortunately a thread can only wait on one Queue at once (without > > > polling). So really the only efficient solution is one Queue per > > > thread. > > > > Make an intelligent PutMsg function which knows which Queue (or > > > Queues) each message needs to be put in and all the threads will have > > > to do is Queue.get() and be sure they've got a message they can deal > > > with. > > > I do have one Queue per thread. The problem is the thread can not peek > > into the Queue and select msg with certain ID first. > > My point is don't put messages that the thread doesn't need in the > queue in the first place. Ie move that logic into PutMsg. > > -- > Nick Craig-Wood --http://www.craig-wood.com/nick Well, I'm simulating the real world. It's like that you wouldn't drop or proceed a task when you already started your lunch, just save it and process it later when you finish your lunch. Of course the task sender can send the task again and again if he got not ack from you. But that's just one possible situation in the real world, and not an efficient one. From gagsl-py2 at yahoo.com.ar Thu Apr 10 18:06:41 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 19:06:41 -0300 Subject: Reading floats through Telnet object? References: Message-ID: En Thu, 10 Apr 2008 15:58:44 -0300, Marlin Rowley escribi?: > Is there any function that allows reading a stream of floats through the > Telnet Object? There doesn't seem to be a way to control reading from > the socket accept read_until() and that requires a string. There are several read_* methods, none of them fits you? -- Gabriel Genellina From medin0065 at gmail.com Sun Apr 20 10:45:11 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:45:11 -0700 (PDT) Subject: cracked vacuum line heater Message-ID: cracked vacuum line heater http://cracks.00bp.com F R E E C R A C K S From ptmcg at austin.rr.com Thu Apr 3 13:33:28 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Thu, 3 Apr 2008 10:33:28 -0700 (PDT) Subject: Get all strings matching given RegExp References: Message-ID: <44ec9a60-811f-4883-a741-3857ab811096@x41g2000hsb.googlegroups.com> On Apr 3, 4:50?am, Alex9968 wrote: > Can I get sequence of all strings that can match a given regular > expression? For example, for expression '(a|b)|(x|y)' it would be ['ax', > 'ay', 'bx', 'by'] > Actually, this regex will only match 'a', 'b', 'x', or 'y' (assuming you meant to bracket it with leading '^' and trailing '$'). To get the set you listed, you would need to invert '(a|b)(x|y)'. The thread that Gabriel Genellina referenced includes a link to a pyparsing regex inverter (http://pyparsing-public.wikispaces.com/space/ showimage/invRegex.py), which I used to test your regex - I've added both regexes in the test cases of that script. Some of the other test cases include regexes for all US time zones, and all chemical symbols. -- Paul From andre.roberge at gmail.com Tue Apr 8 21:25:20 2008 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Tue, 8 Apr 2008 18:25:20 -0700 (PDT) Subject: text adventure game problem References: Message-ID: On Apr 8, 10:01?pm, corvettecra... at gmail.com wrote: > okay, I'm having this one problem with a text adventure game. It's > kind of hard to explain, but I'll do my best. > [code] > > def prompt_kitchen(): > ? ? global gold > ? ? gold_taken = False > ? ? while True: > ? ? ? ? prompt_kit = raw_input('>') > ? ? ? ? if prompt_kit == 'examine cabinet 1' and not gold_taken: > ? ? ? ? ? ? print '''This cabinet has a lot of cups in it with all > different > designs and shapes. Where are the people anyway? How come there's > nobody here? > In one of the cups you find 8 gold.''' > ? ? ? ? ? ? gold = gold+8 > ? ? ? ? ? ? gold_taken = True > ? ? ? ? ? ? pass4() > ? ? ? ? elif prompt_kit == 'examine cabinet 1' and gold_taken: > ? ? ? ? ? ? print \ > ? ? ? ? ? ? ? ? ? '''This cabinet has a lot of cups in it with all > different > designs and shapes. Where are the people anyway? How come there's > nobody here?''' > ? ? ? ? ? ? pass4() > > def pass4(): > ? ? global gold > ? ? print 'You have', gold, 'gold' > ? ? pass > [/code] > > Okay, now for my problem. > In the above function, there's the option to examine a cabinet and get > 8 gold. (everyone here knows that...but I'm just trying to state my > problem...) > Unfortunately, it kind of doesn't work. > After the first time I 'examine cabinet 1' in my game, I get 8 gold > and I can't get it again. > But, If I leave the room and come back to it, then it's as if I had > never gotten the gold the first time, and I can get it again. > How do I fix this? quick guess: define gold_taken as a global variable and initialize it outside of the function. Warning: avoid global variables if at all possible. ;-) Andr? From mal at egenix.com Thu Apr 24 05:34:30 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Thu, 24 Apr 2008 11:34:30 +0200 Subject: @classmethod question In-Reply-To: References: Message-ID: <48105426.2070001@egenix.com> On 2008-04-24 05:27, Scott SA wrote: > Hi, > > I'm using the @classemethod decorator for some convenience methods and for some reason, either mental block or otherwise, can't seem to figure out how to elegantly detect if the call is from an instance or not. > > Here's the problem: Within the class definition, 'isinstance' has nothing to compare to because the class does not appear to exist. > > This is NOT a great example, but it outlines the the code: > > class RecipieClass: > def __init__(self): > pass > > @classmethod > def get_ingrendients(self, recipie_list=None): > > if isinstnace(self,RecipieClass): > return self.do_something_interesting() > else: > return do_something_boring(recipie_list) > > Yes, I can test to see if the param exists, but that makes the call exclusive i.e. I can _only_ call it as an instance or with a parameter. I would turn the above method into a regular instance method and then add a new function or static method which then returns the summary output. A class method is clearly wrong here, since those are meant to be called with the class as first argument, e.g. to count the number of instances created from a class. > Why am I doing this? > > It is a series of convenience methods, in this case I'm interacting with a database via an ORM (object-relational model). I want the ability to call a class-ojbect and get related values, or pass some criteria and get related values for them without collecting the records first as instances, then iterating them. I need to call this from several places so I want to be DRY (don't repeat yourself). > > The easiest way to describe this as an analogy would be like having a recipie for cookies and wanting to know all of the ingredients ahead of time. Then, at another time, wanting to know what all the ingredients would be to make cookies, cake and bread (i.e. complete shopping list). > > cookie_recipie = RecipieClass.get_recipie('cookies') > cookie_recipie.get_ingredients() > 2C Flour > 0.5 C Sugar > ... > > RecipieClass.get_ingrendients(['cookies','cake','bread']) > 8C Flour > 2C Sugar > ... > > Of course any suggestions on how this might be better approached would be interesting too. > > TIA, > > Scott > -- > http://mail.python.org/mailman/listinfo/python-list -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 24 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From bvidinli at gmail.com Thu Apr 10 05:01:13 2008 From: bvidinli at gmail.com (bvidinli) Date: Thu, 10 Apr 2008 12:01:13 +0300 Subject: Fwd: urgent question, about filesystem-files In-Reply-To: <36e8a7020804100200m6c3a9a41h1ed3021b70f8a829@mail.gmail.com> References: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> <47FDD27E.1040204@islandtraining.com> <36e8a7020804100200m6c3a9a41h1ed3021b70f8a829@mail.gmail.com> Message-ID: <36e8a7020804100201x5cf16377gfedddc8647fe8e3a@mail.gmail.com> Sory for lack of information, i use linux/unix i need to solve this for linux/unix i tested os.open with O_EXCL flag, and some other things, that did not solve. i need exacly: say example file testfile, check if testfile already open by some other process in linux, tahnks. 2008/4/10, Gary Herron : > bvidinli wrote: > > > i started python programming a few months ago. > > > > now i need the code to understand if a file already opened in > > filesystem by another process ? > > > > i looked at docs, howtos, but did not find related info. > > note that normal file open/write operations in python, i know it. > > > > i specificly need to know that "is a file already open by some other > > process other than python". > > > > > > Thank you in advance > > > > > > This is certainly an operating-system dependent bit of functionality. So > first off, you are going to have to tell us *which* OS you're working on. > Then, perhaps someone can help... > > Gary Herron > > -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From sturlamolden at yahoo.no Thu Apr 24 20:08:45 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 17:08:45 -0700 (PDT) Subject: Psyco alternative References: <1369b321-f55b-432b-b2f9-6144787509d8@h11g2000prf.googlegroups.com> <7xlk4473ai.fsf@ruckus.brouhaha.com> <651ncdF2cmik2U1@mid.uni-berlin.de> <651onqF2dripdU1@mid.uni-berlin.de> <47EBB42D.9090206@behnel.de> <25b14b32-8fce-4e79-b236-c64fa96744e8@e23g2000prf.googlegroups.com> Message-ID: On Mar 27, 5:01 pm, king kikapu wrote: > Hmmm...thanks but i think Pyrex-like solution is not the ideal one. > Coming from C# and having 8 years of expertise on it, i have gain a > very positive thinking about jit compilers and i think that psyco (ok, > a just-in-time specializer) is a more easy (and more correct) way to > go that mixing 2 languages. From no at spam.com Tue Apr 29 16:54:38 2008 From: no at spam.com (Grayham) Date: Tue, 29 Apr 2008 21:54:38 +0100 Subject: API's and hardware communication. Newbie References: <_MudnfZZ9uW0hY7VRVnyhwA@bt.com> Message-ID: It seems to me that python needs to be extended with C in some form to able to do what i need. I think instead of learning two languages i am going to put all my efforts in to learning C as it seems that's where i am going to end up. Thank you both for the feed back and links Regards Grayham From ocollioud at gmail.com Thu Apr 3 06:59:22 2008 From: ocollioud at gmail.com (olive) Date: Thu, 3 Apr 2008 03:59:22 -0700 (PDT) Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> <47f49d4b$0$5665$426a74cc@news.free.fr> Message-ID: On 3 avr, 10:32, sam wrote: > Bruno Desthuilliers napisa?(a): > > > Ok, I'm going to be a bit harsh, but this time I'll assume it. > > Sam, you started this thread by asking about prototype vs class based > > minor syntactic points that, whether you like them or not (and > > I think I will get back to this discussion after learning "descriptor protocol" > and maybe I will not talk about syntax then, and maybe it won't get off topic. may I recommend this http://www.cafepy.com/article/ (the first 2)? From mail2spj at yahoo.com Fri Apr 18 16:12:34 2008 From: mail2spj at yahoo.com (SPJ) Date: Fri, 18 Apr 2008 13:12:34 -0700 (PDT) Subject: Error with win32com client on windows 2003 server Message-ID: <576371.68812.qm@web50108.mail.re2.yahoo.com> Sorry, forgot to mention Subject in my earlier post, hence reposting. ------------ I am writing a script which need's to convert an excel file to csv (text) format. For that I am using the following code: excel = win32com.client.Dispatch("Excel.Application","Quit") workbook = excel.Workbooks.Open(xlsfile) workbook.SaveAs(csvfile, FileFormat=24) # 24 represents xlCSVMSDOS workbook.Close(False) excel.Quit() I did not have any problem running this script on a windows xp machine with python 2.5.2 and windows extensions. But I get the following error when I run the same script on a windows 2003 server with the same python and windows extension installation: excel = win32com.client.Dispatch("Excel.Application","Quit") File "D:\Python25\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "D:\Python25\lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "D:\Python25\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147221005, 'Invalid class string', None, None) I verified that installation is same. Any idea's as to what might be the problem? One thing I have noticed though is I can't see Microsoft office 11.0 object library when I do combrowse on windows 2003 server. I also to tried to reinstall python and windows extension. But still no luck. I would appreciate if anyone can guide me as to why this is happening and how to resolve this. Thanks, SPJ ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ From jgardner at jonathangardner.net Thu Apr 17 03:37:47 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Thu, 17 Apr 2008 00:37:47 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> On Apr 16, 5:37?pm, sturlamolden wrote: > One single process of CPython is using all the cpu power > of my dual-core laptop. Are they stuck in a while loop, waiting for their resource to become available? Using 100% of the CPU is a bug, not a feature. If you can't rewrite your algorithm to be disk or network bound, next optimization step is C. From balta96428 at gmail.com Wed Apr 23 05:54:11 2008 From: balta96428 at gmail.com (balta96428 at gmail.com) Date: Wed, 23 Apr 2008 02:54:11 -0700 (PDT) Subject: firecad crack Message-ID: <44deb87e-9a76-4ac1-a07e-4cbb952da004@e39g2000hsf.googlegroups.com> firecad crack http://cracks.12w.net F R E E C R A C K S From martin at v.loewis.de Sun Apr 20 14:51:07 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 20 Apr 2008 20:51:07 +0200 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B80B5.1050500@cheimes.de> Message-ID: <480b909c$0$20038$9b622d9e@news.freenet.de> > In order to deal with 400 thousands texts consisting of 80 million > words, and huge sets of corpora , I have to be care about the memory > things. I need to track every word's behavior, so there needs to be as > many word-objects as words. > I am really suffering from the memory problem, even 4G memory space can > not survive... Only 10,000 texts can kill it in 2 minutes. > By the way, my program has been optimized to ``del`` the objects after > traversing, in order not to store the information in memory all the time. It may then well be that your application leaks memory, however, the examples that you have given so far don't demonstrate that. Most likely, you still keep references to objects at some point, causing the leak. It's fairly difficult to determine the source of such a problem. As a starting point, I recommend to do print len(gc.get_objects()) several times in the program, to see how the number of (gc-managed) objects increases. This number should continually grow up, or else you don't have a memory leak (or one in a C module which would be even harder to determine). Then, from time to time, call import gc from collections import defaultdict def classify(): counters = defaultdict(lambda:0) for o in gc.get_objects(): counters[type(o)] += 1 counters = [(freq, t) for t,freq in counters.items()] counters.sort() for freq,t in counters[-10:]: print t.__name__, freq a number of times, and see what kind of objects get allocated. Then, for the most frequent kind of object, investigate whether any of them "should" have been deleted. If any, try to find out a) whether the code that should have released them was executed, and b) why they are still referenced (use gc.get_referrers for that). And so on. Regards, Martin From tinnews at isbd.co.uk Thu Apr 10 04:24:24 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 10 Apr 2008 08:24:24 GMT Subject: How to find documentation about methods etc. for iterators References: <47fce941$0$755$bed64819@news.gradwell.net> Message-ID: <47fdceb8$0$754$bed64819@news.gradwell.net> Terry Reedy wrote: > > wrote in message > news:47fce941$0$755$bed64819 at news.gradwell.net... > | I'm not sure if I have even phrased that right but anyway.... > | > | How does one find (in the standard Python documentation) information > | about things like the iteritems() method and the enumerate() function. > > The Library Reference manual sections on builtin functions and dict > methods. > > Or, help(enumerate) and help({}.iteritems) > .... but that doesn't address my problem really, how do I know that I need to look for the words enumerate and/or iteritems? This is what my original question was about. There I was thinking that there has to be an easy way to get line numbers as I read lines from a file but not knowing how to find out how to do it:- First question, what sort of 'thing' is the file object, I need to know that if I'm to look up ways of using it. Second question, even if I know what sort of thing a file object is, how do I find methods applicable to it and/or functions applicable to it? The possibility that I might want either a method or a function adds to the fun. In my original query it seemed odd that some objects have the iteritems *method* whereas other objects have the enumerate *function*. It's a common problem in all sorts of computer fields, if you know the name of what you want it's easy to find out details of how to use it but if you don't know its name (or even if it exists) it's much more difficult to find. I've only been using Python for a few months and most of the time I can find my way to what I need but this area of "what things can I do with this object" still eludes me sometimes. What *I* need (I'm not sure if this is a universal requirement though) is some consistent way of firstly finding out what sort of an object something is (i.e. in this case, what sort of object is a file) and then getting a list of methods that I can apply to that object (O.K., this may need some hierachy or other classification to keep it sane, but hopefully you can see where I'm going). -- Chris Green From gagsl-py2 at yahoo.com.ar Sun Apr 13 15:37:20 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 13 Apr 2008 16:37:20 -0300 Subject: toplevel, get latest entry? References: Message-ID: En Sat, 12 Apr 2008 17:50:36 -0300, escribi?: > windows vista and python 2.5, is there a way to get the latest command > entered? would be very useful. > > if not by default, anything i could download or write myself? Do you mean inside the interpreter? Use up arrow/down arrow. Type a few characters and press F8 to search for matches. F7 to select from a list. Courtesy of doskey. -- Gabriel Genellina From claird at lairds.us Mon Apr 7 14:47:27 2008 From: claird at lairds.us (Cameron Laird) Date: Mon, 7 Apr 2008 18:47:27 +0000 Subject: Mathematical Python Library References: Message-ID: In article , Dennis Lee Bieber wrote: >On Mon, 7 Apr 2008 09:05:57 -0700 (PDT), mc >declaimed the following in comp.lang.python: > >> I'm looking for a library which can do mathematical stuff like >> solving equations. Or calculation the nulls of a function and so on. >> Does anyone know one? >> > Other than coding some serial/USB interface to an HP50g... > > Maybe SAGE? > sympy? > >http://www.google.com/search?hl=en&q=python+computer+algebra+system&btnG=Google+Search . . . While there are in fact several possible approaches to symbolic mani- pulation of "mathematical stuff" in Python, I STRONGLY recommend that beginners in the area look into SAGE , already mentioned above by Dennis. SAGE is life-altering software, for those with a life focused on mathematics or related science or engineering. From blog534 at watchesblog.cn Fri Apr 25 10:10:00 2008 From: blog534 at watchesblog.cn (blog534 at watchesblog.cn) Date: Fri, 25 Apr 2008 07:10:00 -0700 (PDT) Subject: Brand Watches Seiko Men's Premier Alarm Chronograph Watch # SNA209P1 Discount, Swiss, Fake Message-ID: <6f0299c8-98fd-491b-97ce-51c5afe30329@w5g2000prd.googlegroups.com> Brand Watches Seiko Men's Premier Alarm Chronograph Watch # SNA209P1 Discount, Swiss, Fake Browse our Seiko Men's Premier Alarm Chronograph Watch # SNA209P1 Swiss watches, which is sure the watch you are looking for at low price. There are more high quality designer watch Swiss for selection Seiko Men's Premier Alarm Chronograph Watch # SNA209P1 Link : http://www.watches-brand.com/Seiko-wristwatch-7566.html Brand : Seiko ( http://www.watches-brand.com/Seiko-Watches.html ) Model : Seiko Men's Premier Alarm Chronograph Watch # SNA209P1 Description :

Seiko Men's Premier Alarm Chronograph Watch . 100 meters water resistant. LumiBrite Hands & Markers. Curved Sapphire Crystal. Alarm hands can indicate the time in a different time zone. Chronograph can measure up to 60 minutes in 1/5 seconds. Alarm can be set on a 12-hour basis with two small hands. Hour, minute and small second hands. White dial. # SNA209 #.

Sale Price : $ 229.00 Seiko Men's Premier Alarm Chronograph Watch # SNA209P1 Details :
  • Watches-Price Sales Rank: #61722 in Watches
  • Brand: Seiko
  • Model: SNA209
  • Band material: stainless-steel
  • Case material: stainless-steel
  • Dial color: White
  • Movement type: Quartz
  • Water-resistant to 100 meters
Seiko Men's Premier Alarm Chronograph Watch # SNA209P1 is new brand Swiss, join thousands of satisfied customers and buy your Seiko with total satisfaction. A watches-brand.COM 30 Day Money Back Guarantee is included with every Seiko Fake Series for secure, risk-free online shopping. watches-brand.COM does not charge sales tax for the Fake Seiko Men's Premier Alarm Chronograph Watch # SNA209P1. All of our Fake watches are shipped via EMS to worldwide. Normally it takes 3days to prepare the fake watch you ordered and 5-10days to transmit depending on the different destination.We pay for the free shipping cost for total quantity over 20 pcs. The EMS tracking NO. will be sent by email when an order is shipped from our warehouse. No more other charges from watches-brand.com such as the tax. If you have any other questions please check our other pages or feel free to email us by sales at watches-brand.com. The Same Fake Seiko Watches Series : Seiko Men's Premier Automatic (Made in Japan) Watch # SPB003J1 : http://www.watches-brand.com/Seiko-wristwatch-7567.html Seiko Men's Premier Automatic (Made in Japan) Watch # SPB005J1 : http://www.watches-brand.com/Seiko-wristwatch-7568.html Seiko Men's Premier Automatic All Stainless-Steel Watch with a Black Dial. Model: SPB001J : http://www.watches-brand.com/Seiko-wristwatch-7569.html Seiko Men's Premier Chronograph Watch SDWG45 : http://www.watches-brand.com/Seiko-wristwatch-7570.html Seiko Men's Premier Chronograph Watch SDWG47 : http://www.watches-brand.com/Seiko-wristwatch-7571.html Seiko Men's Premier Kinetic Auto Relay Watch with Blue Dial. Model: SNG037 : http://www.watches-brand.com/Seiko-wristwatch-7572.html Seiko Men's Premier Kinetic Direct Drive Quartz- Kinetic 100M Water Resistant Watch # SRG001P1 : http://www.watches-brand.com/Seiko-wristwatch-7573.html Seiko Men's Premier Kinetic Direct Drive Quartz- Kinetic 100M Water Resistant Watch # SRG001P2 : http://www.watches-brand.com/Seiko-wristwatch-7574.html Seiko Men's Premier Kinetic Perpetual Calendar Black Dial Watch # SNP005P1 : http://www.watches-brand.com/Seiko-wristwatch-7575.html Seiko Men's Premier Kinetic Perpetual Calendar Silver Dial with Seiko Original Leather Strap Watch # SNP015P1 : http://www.watches-brand.com/Seiko-wristwatch-7576.html Brand Watches Seiko Men's Premier Alarm Chronograph Watch # SNA209P1 Discount, Swiss, Fake From colas.francis at gmail.com Thu Apr 17 12:35:10 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Thu, 17 Apr 2008 09:35:10 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> Message-ID: <3a0c68fb-6cea-455a-92f4-2ded30a79528@a23g2000hsc.googlegroups.com> On 17 avr, 18:19, s0s... at gmail.com wrote: > On Apr 17, 10:54 am, colas.fran... at gmail.com wrote: > > > On 17 avr, 17:40, s0s... at gmail.com wrote: > > > Out of sheer curiosity, why do you need thirty (hand-specified and > > dutifully commented) names to the same constant object if you know > > there will always be only one object? > > I'm building a web server. The many variables are names of header > fields. One part of the code looks like this (or at least I'd like it > to): > > class RequestHeadersManager: > > # General header fields > Cache_Control = \ > Connection = \ > Date = \ > Pragma = \ > Trailer = \ > Transfer_Encoding = \ > Upgrade = \ > Via = \ > Warning = \ > > # Request header fields > Accept = \ > Accept_Charset = \ > Accept_Encoding = \ > Accept_Language = \ > Authorization = \ > ... > > Etc etc etc. At the end they'll all be assign to None. Then, when > initialized, __init__() will the the string of headers, parse them, > and use those variables shown above to assign to the header values. Of > course a normal request won't include all of those headers, so the > others will remain None. That's what I want. Ah, so they are not constant, I was mislead by the name 'CONSTANTn' in your OP. But why would you insist on: """ # helpful comment CONSTANT1 = \ # there too CONSTANT2 = \ CONSTANT3 = \ None """ rather than: """ # helpful comment CONSTANT1 = None # there too CONSTANT2 = None CONSTANT3 = None """ or even: """ CONSTANT = None # helpful comment CONSTANT1 = CONSTANT # there too CONSTANT2 = CONSTANT CONSTANT3 = CONSTANT """ (hopefully you don't consider those names in your code. ^ ^) From andrew at acooke.org Sat Apr 19 10:34:40 2008 From: andrew at acooke.org (andrew cooke) Date: Sat, 19 Apr 2008 07:34:40 -0700 (PDT) Subject: Metaprogramming Example References: <930643c6-2d56-4fb0-aee0-a3e79231f09b@24g2000hsh.googlegroups.com> <32472b97-f35a-4408-96f5-2f8c8f92ae56@m73g2000hsh.googlegroups.com> <39325652-e0cf-4efd-9b28-00c0fe8552cc@m73g2000hsh.googlegroups.com> <562bae18-7b8e-4863-8923-0e5a01ba7125@t54g2000hsg.googlegroups.com> <48086036$0$759$426a74cc@news.free.fr> Message-ID: On Apr 18, 4:48 am, Bruno Desthuilliers wrote: [...] > Practically, this means that (amongst other niceties) : > - you can define functions outside classes and use them as instance or > class methods > - you can add/replaces methods dynamically on a per-class or > per-instance basis > - you can access the function object of a method and use it as a function > - you can define your own callable types, that - if you implement the > appropriate support for the descriptor protocol - will be usable as > methods too ok, that's convincing (i had thought the majority of these were already possible, albeit with some kind of hard-coded "magic" behind the scenes). [...] > > by referring to the titanic > > i didn't mean that python was a disaster, rather that the "iceberg" is > > still there (i am not 100% sure what the iceberg is, but it's > > something > > to do with making namespaces explicit in some places and not others). > > I guess you're thinking of the self argument, declared in the function's > signature but not "explicitly passed" when calling the method ? not really. more to do with when namespaces (i am not sure i have the right term - the dictionary that provides the mapping from name to object) are explicit or implicit. for example, python has closures (implicit lookup) and "self" (explicit lookup). but as i said, i don't have a clear argument - something just feels "odd". at the same time, i know that language design is a practical business and so this is probably not important. finally, thank you for pointing me to sql alchemy (i think it was you?). it really is excellent. andrew From kyosohma at gmail.com Fri Apr 11 15:54:22 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 11 Apr 2008 12:54:22 -0700 (PDT) Subject: Windows - window status (Running vs Not Responding) References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> Message-ID: <5f4a5d63-c862-4d25-8849-6a36dd4e138d@m3g2000hsc.googlegroups.com> On Apr 11, 2:10 pm, rdahlstrom wrote: > On Apr 11, 1:45 pm, rdahlstrom wrote: > > > Does anyone know how to determine the window status (Running or Not > > Responding)? I've tried various methods with no success... > > > This would be on a variety of Windows systems, but all at least XP, > > and mostly server 2003. Everyone will have Python 2.5.1 on them, and > > the script would be running locally. > > > Any ideas? > > Basically, I'm looking for something similar to the Process.Responding > property in System.Diagnostics... Hmmm...I think you should re-post to the Python win32 group. They'll know the answer, if there is one. Here's the link to get signed up: http://mail.python.org/mailman/listinfo/python-win32 Also, you might take a look at the WMI module: http://tgolden.sc.sabren.com/python/wmi.html I'm pretty sure it can do that, but I don't know how. I did find an article on it: http://www.informit.com/articles/article.aspx?p=19489&seqNum=4 If you're better than I am, you can probably translate this to the Python equivalent. Zenoss also has some monitoring software that's open source Python code. Mike From ladynikon at gmail.com Wed Apr 9 08:51:38 2008 From: ladynikon at gmail.com (Danyelle Gragsone) Date: Wed, 9 Apr 2008 08:51:38 -0400 Subject: Very good Python Book. Free download : Beginning Python: From Novice to Professional In-Reply-To: References: Message-ID: <59f9c5160804090551p6132c027vb04ef2123c857e24@mail.gmail.com> HEH From paul.anton.letnes at gmail.com Tue Apr 15 15:58:42 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Tue, 15 Apr 2008 21:58:42 +0200 Subject: Java or C++? In-Reply-To: <95983d3d-d751-4472-af3c-5e1b74fd538f@n14g2000pri.googlegroups.com> References: <480424FC.5040802@aim.com> <95983d3d-d751-4472-af3c-5e1b74fd538f@n14g2000pri.googlegroups.com> Message-ID: Well, if you're new - first find the function, then how to use it, this funny %d5 (or something, don't remember) syntax - it's hard compared to: cout << 5 or similar stream tricks, or just 5 + "" in Java, or just str(5) in Python. Anyway, small tasks are very hard for C newbies. Den 15. april. 2008 kl. 19.35 skrev lbonafide at yahoo.com: > On Apr 15, 3:07 am, Paul Anton Letnes > wrote: > > >> but C bogs you down with administrative stuff (try converting an int >> to a string; I found myself googling for an hour!). > > It took an hour to find sprintf()? > -- > http://mail.python.org/mailman/listinfo/python-list From martin at v.loewis.de Sat Apr 5 17:45:29 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sat, 05 Apr 2008 23:45:29 +0200 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> Message-ID: <47f7f2f9$0$10630$9b622d9e@news.freenet.de> > There must be a rule behind this. There are multiple rules behind this. Python normally uses the same extension for shared libraries as the operating system, as the operating system may refuse to load them if it doesn't. So it *can't* use .pyd on Unix, because that might not work (on some implementations of Unix). It can't use .dll on Windows, because that may (and did) conflict with existing DLLs, hence it uses .pyd. Depending on the system, an extension module may have one of these suffixes: - .so - module.so - .sl - module.sl - .exe - .EXE - module.exe - module.EXE - .pyd - _d.pyd Regards, Martin From Hook at somewhere.nowhere.co.au.it Sat Apr 19 02:37:33 2008 From: Hook at somewhere.nowhere.co.au.it (Hook) Date: 19 Apr 2008 06:37:33 GMT Subject: Inheritance confusion Message-ID: <4809932c$0$12307$c3e8da3@news.astraweb.com> Hi, I'm having a problem with multiple inheritance - it's clearly something I've missed, but the web pages and books that I've consulted aren't helping, so I'll throw myself on the mercy and collective wisdom of Usenet! I've got 4 files (what I'll show has the active content removed for brevity): Errors_m.py ~~~~~~~~~~~ class Errors (object) : def __init__ (self, params) : pass def Error (self, string) : return 100 DT_m.py ~~~~~~~ class DT (object) : def __init__ (self, params) : pass def Date (self, epoch, pattern = 'd mmm yyyy') : dt = datetime.datetime.fromtimestamp (epoch) Hook_m.py ~~~~~~~~~ from DT_m import DT from Error_m import Errors class Hook (Errors, DT) : def __init__ (self, params) : DT.__init__ (self, params) Errors.__init__ (self, params) DB_m.py ~~~~~~~ from Hook_m import Hook class DB (Hook) : def __init__ (self, params) : Hook.__init__ (self, params) And a test script: #!/usr/bin/python import os import re import string import sys from DB_m import DB Dict = dict () Dict ['logdir'] = '/tmp/log' Dict ['diag'] = 1 Obj = DB (Dict) print dir (Obj) Obj.Connect ('Database') When I run the script I get this: Traceback (most recent call last): File "./3.py", line 20, in Obj.Connect ('Database') File "/mnt/isis/Projects/Python/Learning/DB_m.py", line 102, in Connect self.TRACE ("DB::Connect (" + database + "," + mode) File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 314, in TRACE self.DailyLog (msg) File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 98, in DailyLog dt = self.Date (time ()) TypeError: 'module' object is not callable Googling the "TypeError" message suggests that I've got a module and class with the same name, but I can't see that I have. Can someone point me in the right direction please? If you need to see all the source, can do, but it's certainly too much for an intro message! Thanks, Hook From carlwuhwdmckay at gmail.com Sat Apr 26 09:33:45 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:33:45 -0700 (PDT) Subject: keygen fifa 08 Message-ID: <3728b524-26cc-4628-9871-c04b94392f46@d1g2000hsg.googlegroups.com> keygen fifa 08 http://cracks.00bp.com F R E E C R A C K S From coleb2 at gmail.com Wed Apr 9 16:55:43 2008 From: coleb2 at gmail.com (Brian Cole) Date: Wed, 9 Apr 2008 14:55:43 -0600 Subject: wrapping C functions in python In-Reply-To: References: <54b165660804091322w690e5e64x85c3d8f082b411b2@mail.gmail.com> Message-ID: <54b165660804091355m1326f7c0g1a5eebe3d6b5a1df@mail.gmail.com> SWIG is a program that automatically generates code to interface Python (and many other languages) with C/C++. If you plan to create lasting software libraries to be accessed from Python and C it is quite a robust way to do so. Essentially, you feed it header files, compile your code and the code generated by swig as a shared library, then import the functions like you would a normal python module. If all you need is to make some numerical code run faster it may be more of a learning curve then you bargain for. Perhaps trying NumPy is more appropriate. http://numpy.scipy.org/ -Brian On Wed, Apr 9, 2008 at 2:44 PM, Paul Anton Letnes wrote: > Hi, and thanks. > > > However, being a newbie, I now have to ask: What is SWIG? I have heard the > name before, but haven't understood what it is, why I need it, or similar. > Could you please supply some hints? > > > -Paul > > > Den 9. april. 2008 kl. 22.22 skrev Brian Cole: > > > > > > > > > > We use the following SWIG (www.swig.org) typemap to perform such > operations: > > > > %typemap(in) (int argc, char **argv) { > > if (!PySequence_Check($input)) { > > PyErr_SetString(PyExc_ValueError,"Expected a sequence"); > > return NULL; > > } > > $1 = PySequence_Length($input); > > $2 = (char**)alloca($1*sizeof(char*)); > > for (Py_ssize_t i = 0; i < $1; ++i) { > > PyObject *o = PySequence_GetItem($input, i); > > $2[i] = PyString_AsString(o); > > } > > } > > > > That one works for mapping a python sequence (such as a list) into the > > argc, argv arguments commonly passed into main. > > > > -Brian > > > > On Wed, Apr 9, 2008 at 2:13 PM, Paul Anton Letnes > > wrote: > > > > > Hello etc. > > > > > > > > > I am a "scientific" user of Python, and hence have to write some > performance > > > critical algorithms. Right now, I am learning Python, so this is a > "newbie" > > > question. > > > > > > I would like to wrap some heavy C functions inside Python, specifically > a > > > wavelet transform. I am beginning to become aquainted with the functions > > > PyArg_ParseTuple() and Py_BuildValue(). However, I am unable to figure > out > > > how to pass Python list -> C function or C array -> return value in > Python. > > > I manage to build and run the C function, print to screen, pass string > as > > > argument, return an int, etc. The thing which is missing is the magic > > > array/list... > > > > > > > > > Thanks in advance! I fart in your general direction. > > > Paul. > > > -- > > > http://mail.python.org/mailman/listinfo/python-list > > > > > > > > -- > > > > http://mail.python.org/mailman/listinfo/python-list > > > > From tjreedy at udel.edu Tue Apr 15 17:35:19 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 15 Apr 2008 17:35:19 -0400 Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> Message-ID: "Sverker Nilsson" wrote in message news:eda75e1a-904e-4916-9489-934cb679a516 at m44g2000hsc.googlegroups.com... | What serious reports? http://wiki.python.org/moin/Early2to3Migrations From ellingt8877 at gmail.com Mon Apr 28 01:50:08 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:50:08 -0700 (PDT) Subject: diskeeper 2007 crack Message-ID: diskeeper 2007 crack http://crack.cracksofts.com From fredrik at pythonware.com Sat Apr 5 04:48:11 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 10:48:11 +0200 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> Message-ID: llothar wrote: > My question was: Why does setup.py generated sometimes a pyd and > sometimes a so file? setup.py picks an extension that happens to work on the platform you're running setup.py on. doing otherwise would be pretty pointless. From steve at holdenweb.com Thu Apr 10 19:06:46 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 10 Apr 2008 19:06:46 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> <47FCF421.6000807@holdenweb.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> Message-ID: Victor Subervi wrote: > Well, what I did was this: > > content = col_fields[0][14].tostring() > pic = "tmp" + str(i) + ".jpg" > img = open(pic, "w") > img.write(content) > print '

' % pic > img.close() > where I am incrementing i. Ugly. Stupid. But if it is the only way to do > it in python, and I do not want to invest the time doing it in php, > which I think would be prettier in this instance, then I guess it will > do. Your thoughts appreciated. > Victor > It is not the only way to do it on Python, it's not even an especially good way. But I suggest you either read what I have already written more carefully, or study HTTP and HTML until you understand what you are doing unnecessarily wrong. There is absolutely no need to save the images to the file store (otherwise there would be no point in having them in the database in the first place). You simply need to understand how to serve them dynamically. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From darcy at druid.net Tue Apr 29 15:31:08 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Tue, 29 Apr 2008 15:31:08 -0400 Subject: Colors for Rows In-Reply-To: <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> <20080429121105.f10c3862.darcy@druid.net> <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> Message-ID: <20080429153108.87bf8db8.darcy@druid.net> On Tue, 29 Apr 2008 13:14:34 -0500 "Victor Subervi" wrote: > On Tue, Apr 29, 2008 at 11:11 AM, D'Arcy J.M. Cain wrote: > > > for d in (1,2,3,4,5,6): > > > > I changed id to a sequence so that the example actually runs. Please > > run your examples first and cut and paste them into the message after > > you are sure that it runs. > > Not sure what you mean here. The example runs. It prints out bgcolor="#ffffff"> every time. No it doesn't. Perhaps you had something that worked but you did not include a definition of "id" in your code so it crashed right away. > > print '' % bg, d > > Huh? You?re asking for one variable, then giving two! How?s that work? No, I am asking print to display two items. The first is "'' % bg" and the second, following the comma, is "d" which I simply added to show what iteration we were on. I assume that you would be printing some data from "id" in the real code and wrapping it in tags. > I think you understand. I want the row color to alternate, every fourth row > color being the same (or a series of 4) Here is the output of the program I posted: 1 2 3 4 5 6 BTW, I am running Python 2.4.4. You? > > print '' % bg[z % 4], d > > I tried that just for fun. It gave a bg of ?f?. Again, how are you > incorporating d? Here is the complete script with the exact same output as above: #! /usr/bin/env python z = 3 bg = ('#ffffff', '#d2d2d2', '#F6E5DF', '#EAF8D5') for d in (1,2,3,4,5,6): z += 1 print '' % bg[z % 4], d -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From skanemupp at yahoo.se Mon Apr 14 07:28:43 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Mon, 14 Apr 2008 04:28:43 -0700 (PDT) Subject: Game design : Making computer play References: Message-ID: On 14 Apr, 09:13, v4vijayakumar wrote: > In computer based, two player, board games, how to make computer play? > Are there any formal ways to _teach_ computer, to choose best possible > move? > > I know this is kind of off-topic here. Please redirect me, if there > are more appropriate newsgroup. > > Many thanks. can you post a link to the game so I can see the rules and how the board looks. /hopefully going to india soon From tjreedy at udel.edu Sun Apr 13 02:22:03 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 13 Apr 2008 02:22:03 -0400 Subject: Where is the function of 'apply' always used? References: <84cefd1a-58de-485b-b00b-77218d2d054c@c19g2000prf.googlegroups.com> Message-ID: "???" wrote in message news:84cefd1a-58de-485b-b00b-77218d2d054c at c19g2000prf.googlegroups.com... | I'am a beginner of Python.In the course of reading the Python book,I | found the function:apply;But | I don't understand its use.Help! Apply has been deprecated. It has been replaced by the use of *args in function calls. It is only still present for old code and will disappear in 3.0. So you do not need it and should ignore it for now. From deets at nospam.web.de Thu Apr 10 03:51:57 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 10 Apr 2008 09:51:57 +0200 Subject: wrapping C functions in python In-Reply-To: References: <54b165660804091322w690e5e64x85c3d8f082b411b2@mail.gmail.com> <54b165660804091355m1326f7c0g1a5eebe3d6b5a1df@mail.gmail.com> Message-ID: <665v97F2ifd5rU1@mid.uni-berlin.de> Paul Anton Letnes schrieb: > Brian and Diez: > > First of all, thanks for the advice. > > Brian: > > I have installed NumPy and SciPy, but I can't seem to find a wavelet > transform there. > > The main point of this was more to learn C wrapping than to actually get > a calculation done. I will probably be starting a PhD soon, doing really > heavy computations. If I want to manipulate data (input / results), > python is very nice, especially with gnuplot-py. However, heavy > calculations should probably be done in C(++), especially as some code > for this already exists. > > I will look into SWIG. > > > Diez: > > I will look into it. Do you know a good tutorial for this? I found the > "standard" tutorial on C extensions, > http://www.python.org/doc/ext/intro.html , but as I mentioned, it seems > to be a bit complicated to wrap heavy data structures like arrays. ctypes is documented as part of the python 2.5 standard lib documentation. And google helps as always. diez From urquhart.nak at gmail.com Wed Apr 30 06:29:12 2008 From: urquhart.nak at gmail.com (urquhart.nak at gmail.com) Date: Wed, 30 Apr 2008 03:29:12 -0700 (PDT) Subject: crack the sims 2 hm stuff Message-ID: crack the sims 2 hm stuff http://crack.cracksofts.com From wlindley at ups.edu Thu Apr 17 18:14:24 2008 From: wlindley at ups.edu (Walker Lindley) Date: Thu, 17 Apr 2008 15:14:24 -0700 Subject: pyexpat.so not importing Message-ID: <9c8d48280804171514l66a42ea0w710d070e11dc07d2@mail.gmail.com> Hopefully this is a relatively common problem. I'm working on a web service using ZSI running on Apache. The client generates a request just fine, but when the server tries to parse it, it fails while importing pyexpat.so. Specifically what's happening (after I traced the call stack down) is that xml.parsers.expat is being imported and that module consists of a single line: from pyexpat import * And that line is failing. Since it's running from within Apache, I don't get a full error message, but I print a message to Apache's error log before and after that line executes. The message before it prints and the message after it does not. So something's going wrong during that import, but since it's a compiled file, I don't really know what. Is there a way to get better information about what's going wrong? Has someone else had this problem and fixed it? Thanks, Walker -------------- next part -------------- An HTML attachment was scrubbed... URL: From needin4mation at gmail.com Wed Apr 9 16:51:22 2008 From: needin4mation at gmail.com (jmDesktop) Date: Wed, 9 Apr 2008 13:51:22 -0700 (PDT) Subject: basic python question about for loop Message-ID: >From the Python.org tutorial: >>> for n in range(2, 10): ... for x in range(2, n): ... if n % x == 0: ... print n, 'equals', x, '*', n/x ... break ... else: ... # loop fell through without finding a factor ... print n, 'is a prime number' ... 2 is a prime number 3 is a prime number 4 equals 2 * 2 5 is a prime number 6 equals 2 * 3 7 is a prime number 8 equals 2 * 4 9 equals 3 * 3 first time 2 mod 2, 2/2, no remainder == 0, what am I doing wrong? Why did it fall through? http://www.python.org/doc/current/tut/node6.html#SECTION006300000000000000000 Thanks. From arnodel at googlemail.com Sat Apr 12 16:18:57 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sat, 12 Apr 2008 13:18:57 -0700 (PDT) Subject: class level properties References: Message-ID: On Apr 12, 8:36?pm, Charles D Hixson wrote: > I'm trying to construct read-only variables at the class level. ?I've > been unsuccessful. ?Any suggestions? > > Mixing @classmethod and @property doesn't appear to produce workable > code. ?Ditto for mixing @classmethod and __getattr__. ?(The property > approach compiles, but execution says that you can't execute properties.) > > I've got a rather large number of variables, so I don't want to define > function accessors for each of them, and I *REALLY* don't want to have > to access them as functions rather than variables or properties. Metaclasses, of course! >>> class MetaX(type): ... @property ... def spam(self): return 'eggs' ... >>> class X(object): ... __metaclass__ = MetaX ... >>> X.spam 'eggs' >>> HTH -- Arnaud From jason.scheirer at gmail.com Tue Apr 1 16:40:34 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Tue, 1 Apr 2008 13:40:34 -0700 (PDT) Subject: XML Parsing References: Message-ID: <57834854-6622-476c-915e-d5563487f0c6@c19g2000prf.googlegroups.com> On Apr 1, 12:42 pm, Alok Kothari wrote: > Hello, > I am new to XML parsing.Could you kindly tell me whats the > problem with the following code: > > import xml.dom.minidom > import xml.parsers.expat > document = """Lettermanis token>betterthan token>JayLeno""" > > # 3 handler functions > def start_element(name, attrs): > print 'Start element:', name, attrs > def end_element(name): > print 'End element:', name > def char_data(data): > print 'Character data:', repr(data) > > p = xml.parsers.expat.ParserCreate() > > p.StartElementHandler = start_element > p.EndElementHandler = end_element > p.CharacterDataHandler = char_data > p.Parse(document, 1) > > OUTPUT: > > Start element: token {u'pos': u'nn'} > Character data: u'Letterman' > End element: token > > Traceback (most recent call last): > File "C:/Python25/Programs/eg.py", line 20, in > p.Parse(document, 1) > ExpatError: junk after document element: line 1, column 33 Your XML is wrong. Don't put line breaks between . From Dominique.Holzwarth at ch.delarue.com Wed Apr 23 08:20:16 2008 From: Dominique.Holzwarth at ch.delarue.com (Dominique.Holzwarth at ch.delarue.com) Date: Wed, 23 Apr 2008 13:20:16 +0100 Subject: Subprocess module Message-ID: <5213E58D85BC414998FA553C701E386C0EDD125B52@SGBD012511.dlrmail.ad.delarue.com> Hello all I want to convert a tex file into a pdf by using pdflatex. For that, I thought the 'subprocess' module might be a good option. My code doesn't work at all tho: Import os, subprocess def main(): scriptpath = os.path.dirname(__file__) p = subprocess.Popen("pdflatex --include-directory=%s --output-directory=%s/output --aux-directory=%s/temp --interaction=nonstopmode myFile.tex" % (scriptpath, scriptpath, scriptpath), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, cwd=scriptpath) (child_stdin, child_stdout, child_stderr) = (p.stdin, p.stdout, p.stderr) print 'stdin' print child_stdin print 'stdout' print child_stdout print 'stderr' print child_stderr When I run that code I get the following printouts: stdin ', mode 'wb' at 0x009E7968> stdout ', mode 'rb' at 0x009E7A40> stderr ', mode 'rb' at 0x009E79F8> Done The pdf file however is not created, nor are there any tex-temporary files (like *.log or *.aux) created. If I include a 'p.wait()' I see the python.exe and the pdflatex.exe processes are running, but I have it to terminate them manually (they never finish). My system is winXP btw. Does anyone have an idea what could be wrong? The reason why I want to use the Popen class is because it has the wait() function, so I can wait for the childprocess (pdflatex) to terminate before I start it again (because you need to run pdflatex several times to get all the references/index things correct in the generated pdf). Thanks for help, Dominique From ivan.illarionov at gmail.com Mon Apr 21 16:10:26 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Mon, 21 Apr 2008 13:10:26 -0700 (PDT) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> Message-ID: <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> On 20 ???, 04:10, George Sakkis wrote: > On Apr 18, 9:36 pm, Ross Ridge > wrote: > > > > > Ross Ridge said: > > > > If you have Python 2.5, here's a faster version: > > > > from struct import * > > > unpack_i32be = Struct(">l").unpack > > > > def from3Bytes_ross2(s): > > > return unpack_i32be(s + "\0")[0] >> 8 > > > Bob Greschke wrote: > > > > That's not even intelligible. I wanna go back to COBOL. :) > > > It's the same as the previous version except that it "precompiles" > > the struct.unpack() format string. It works similar to the way Python > > handles regular expressions. > > I didn't know about the Struct class; pretty neat. It's amazing that > this version without Psyco is as fast Bob's version with Psyco! Adding > Psyco to it though makes it *slower*, not faster. So here's how I'd > write it (if I wanted or had to stay in pure Python): > > try: import psyco > except ImportError: > from struct import Struct > unpack_i32be = Struct(">l").unpack > def from3Bytes(s): > return unpack_i32be(s + "\0")[0] >> 8 > else: > def from3Bytes(s): > Value = (ord(s[0])<<16) + (ord(s[1])<<8) + ord(s[2]) > if Value >= 0x800000: > Value -= 0x1000000 > return Value > psyco.bind(from3Bytes) > > HTH, > George I was able to get even faster pure-python version using array module: a = array.array('l', ''.join(('\0' + s[i:i+3] for i in xrange(0, len(s), 3)))) if sys.byteorder == 'little': a.byteswap() It actually moves bytes around on C level. test code: import struct import array import sys unpack_i32be = struct.Struct(">l").unpack s = ''.join(struct.pack('>i', 1234567)[1:]*1000) def from3bytes_ord(s): values = [] for i in xrange(0, len(s), 3): Value = (ord(s[i])<<16) | (ord(s[i+1])<<8) | ord(s[i+2]) if Value >= 0x800000: Value -= 0x1000000 values.append(Value) return values def from3bytes_struct(s): return [unpack_i32be(s[i:i+3] + "\0")[0] >> 8 for i in xrange(0, len(s), 3)] def from3bytes_array(s): a = array.array('l', ''.join(('\0' + s[i:i+3] for i in xrange(0, len(s), 3)))) if sys.byteorder == 'little': a.byteswap() return a.tolist() from timeit import Timer t1 = Timer("from3bytes_ord(s)", "from __main__ import s, from3bytes_ord") t2 = Timer("from3bytes_struct(s)", "from __main__ import s, from3bytes_struct") t3 = Timer("from3bytes_array(s)", "from __main__ import s, from3bytes_array") print 'ord:\t', t1.timeit(1000) print 'struct:\t', t2.timeit(1000) print 'array:\t', t3.timeit(1000) Output: ord: 7.08213110884 struct: 3.7689164405 array: 2.62995268952 Inspired by Guido's essay http://www.python.org/doc/essays/list2str/ From fetchinson at googlemail.com Wed Apr 2 02:37:12 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Tue, 1 Apr 2008 23:37:12 -0700 Subject: developing web spider In-Reply-To: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> References: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> Message-ID: > I would want to know which could be the best programming language for > developing web spider. > More information about the spider, much better,, I hear Larry and Sergei were not exactly unsuccessful with a python implementation although you might of course try something even better :) If you are less ambitious have a look at http://nikitathespider.com/ which is also a spider in python. Cheers, Daniel From bockman at virgilio.it Thu Apr 17 08:43:36 2008 From: bockman at virgilio.it (bockman at virgilio.it) Date: Thu, 17 Apr 2008 05:43:36 -0700 (PDT) Subject: Python and stale file handles References: Message-ID: On 17 Apr, 04:22, tgiles wrote: > Hi, All! > > I started back programming Python again after a hiatus of several > years and run into a sticky problem that I can't seem to fix, > regardless of how hard I try- it it starts with tailing a log file. > > Basically, I'm trying to tail a log file and send the contents > elsewhere in the script (here, I call it processor()). My first > iteration below works perfectly fine- as long as the log file itself > (logfile.log) keeps getting written to. > > I have a shell script constantly writes to the logfile.log... If I > happen to kill it off and restart it (overwriting the log file with > more entries) then the python script will stop sending anything at all > out. > > import time, os > > def processor(message,address): > ? ? ? ? #do something clever here > > #Set the filename and open the file > filename = 'logfile.log' > file = open(filename,'r') > > #Find the size of the file and move to the end > st_results = os.stat(filename) > st_size = st_results[6] > file.seek(st_size) > > while 1: > ? ? where = file.tell() > ? ? line = file.readline() > ? ? if not line: > ? ? ? ? time.sleep(1) > ? ? ? ? file.seek(where) > ? ? else: > ? ? ? ? print line, # already has newline > ? ? ? ? data = line > ? ? ? ? if not data: > ? ? ? ? ? ? break > ? ? ? ? else: > ? ? ? ? ? ? ? ? processor(data,addr) > ? ? ? ? ? ? ? ? print "Sending message '",data,"'....." > > someotherstuffhere() > > === > > This is perfectly normal behavior since the same thing happens when I > do a tail -f on the log file. However, I was hoping to build in a bit > of cleverness in the python script- that it would note that there was > a change in the log file and could compensate for it. > > So, I wrote up a new script that opens the file to begin with, > attempts to do a quick file measurement of the file (to see if it's > suddenly stuck) and then reopen the log file if there's something > dodgy going on. > > However, it's not quite working the way that I really intended it to. > It will either start reading the file from the beginning (instead of > tailing from the end) or just sit there confuzzled until I kill it > off. > > === > > import time, os > > filename = logfile.log > > def processor(message): > ? ? # do something clever here > > def checkfile(filename): > ? ? file = open(filename,'r') > ? ? print "checking file, first pass" > ? ? pass1 = os.stat(filename) > ? ? pass1_size = pass1[6] > > ? ? time.sleep(5) > > ? ? print "file check, 2nd pass" > ? ? pass2 = os.stat(filename) > ? ? pass2_size = pass2[6] > ? ? if pass1_size == pass2_size: > ? ? ? ? print "reopening file" > ? ? ? ? file.close() > ? ? ? ? file = open(filename,'r') > ? ? else: > ? ? ? ? print "file is OK" > ? ? ? ? pass > > while 1: > ? ? ? ? checkfile(filename) > ? ? where = file.tell() > ? ? line = file.readline() > ? ? print "reading file", where > ? ? if not line: > ? ? ? ? print "sleeping here" > ? ? ? ? time.sleep(5) > ? ? ? ? print "seeking file here" > ? ? ? ? file.seek(where) > ? ? else: > ? ? ? ? # print line, # already has newline > ? ? ? ? data = line > ? ? ? ? print "readying line" > ? ? ? ? if not data: > ? ? ? ? ? ? print "no data, breaking here" > ? ? ? ? ? ? break > ? ? ? ? else: > ? ? ? ? ? ? print "sending line" > ? ? ? ? ? ? processor(data) > > So, have any thoughts on how to keep a Python script from bugging out > after a tailed file has been refreshed? I'd love to hear any thoughts > you my have on the matter, even if it's of the 'that's the way things > work' variety. > > Cheers, and thanks in advance for any ideas on how to get around the > issue. > > tom Possibly, restarting the program that writes the log file creates a new file rather than appending to the old one?? I think you should always reopen the file between the first and the second pass of your checkfile function, and then: - if the file has the same size, it is probably the same file (but it would better to check the update time!), so seek to the end of it - otherwise, its a new file, and then start reading it from the beginning To reduce the number of seeks, you could perform checkfile only if for N cycles you did not get any data. Ciao ----- FB From marlin_rowley at hotmail.com Tue Apr 15 22:44:49 2008 From: marlin_rowley at hotmail.com (Marlin Rowley) Date: Tue, 15 Apr 2008 21:44:49 -0500 Subject: How is GUI programming in Python? In-Reply-To: References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <101680ba-a116-414b-8fff-c5b5bd2f4b65@p39g2000prm.googlegroups.com> Message-ID: Hmm.. I'm just now learning wxPython and it's very very easy to me. Perhaps because I've delved into other GUI APIs like GLUT and Windows DirectX. Programming in C++ seems a pain when coming from Python. I'll let you know more when I delve more into it. -M > From: lxlaurax at gmail.com> Subject: Re: How is GUI programming in Python?> Date: Tue, 15 Apr 2008 19:17:31 -0700> To: python-list at python.org> > On 11 abr, 20:31, sturlamolden wrote:> > On Apr 11, 5:01 am, "Gabriel Genellina" > > wrote:> >> > > Another annoying thing with the Qt license is that you have to choose it> > > at the very start of the project. You cannot develop something using the> > > open source license and later decide to switch to the commercial licence> > > and buy it.> >> > Trolltech is afraid companies will buy one licence when the task is> > done, as oppsed to one license per developer. In a commercial setting,> > the Qt license is not expensive. It is painful for hobbyists wanting> > to commercialize their products.> > I have no experience with GUI programming in Python, but from this> discussion it seems if the type of license is not an issue (for FOSS> development), PyQt is the best tool because it is:> (a) easier to learn and intuitive for programming (this is important> to me; I am not that smart...);> (b) more stable (although many people have said that wxPython is as> stable as any other GUI nowadays; but not more stable (wx) than> others);> (c) more cross-platform (many people complain that they have to do a> lot of things in wxPython for the cross-platform).> > Is (a) and (c) true or not? If so, how big are these advantages?> > The great advantage of wxPython seems to be the huge community of> users and the large number of widgets/examples/applications available.> > Reformulating my question:> > Which GUI tool, wxPython or PyQt, is more pythonic? (Please, ignore> the license issue because I am thinking about FOSS)> > Laura> -- > http://mail.python.org/mailman/listinfo/python-list _________________________________________________________________ Use video conversation to talk face-to-face with Windows Live Messenger. http://www.windowslive.com/messenger/connect_your_way.html?ocid=TXT_TAGLM_WL_Refresh_messenger_video_042008 -------------- next part -------------- An HTML attachment was scrubbed... URL: From maxm at mxm.dk Mon Apr 28 18:12:58 2008 From: maxm at mxm.dk (Max M) Date: Tue, 29 Apr 2008 00:12:58 +0200 Subject: Given a string - execute a function by the same name In-Reply-To: <1209400401.22706.1250293015@webmail.messagingengine.com> References: <1209400401.22706.1250293015@webmail.messagingengine.com> Message-ID: <48164BEA.7010602@mxm.dk> python at bdurham.com skrev: > I'm parsing a simple file and given a line's keyword, would like to call > the equivalently named function. > > There are 3 ways I can think to do this (other than a long if/elif > construct): > > 1. eval() > > 2. Convert my functions to methods and use getattr( myClass, "method" ) > > 3. Place all my functions in dictionary and lookup the function to be > called > > Any suggestions on the "best" way to do this? No reason to use eval. use either getattr(obj, "method")() or functions['method'] They are basically the same thing. The dict of functions is a bit safer. You don't risk calling a built in method on your object . Which you risk doing with something like: getattr(obj, 'join') -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science From hdante at gmail.com Fri Apr 25 22:47:10 2008 From: hdante at gmail.com (hdante) Date: Fri, 25 Apr 2008 19:47:10 -0700 (PDT) Subject: problem with unicode References: <26fcc207-b864-42c7-afb3-c6945e5fe29f@m44g2000hsc.googlegroups.com> Message-ID: <74543e67-6ec3-4d62-8e86-af4215b19579@y38g2000hsy.googlegroups.com> On Apr 25, 8:15?am, "andreas.prof... at googlemail.com" wrote: > > I don't know what to do. I just want to concatenate two string where > apparently one is a binary string, the other one is a unicode string > and I always seem to get this error. Please explain better what you want to do with the merged unicode + binary string. > > Any help is appreciated :) From v.harishankar at gmail.com Tue Apr 22 09:17:43 2008 From: v.harishankar at gmail.com (Harishankar) Date: Tue, 22 Apr 2008 18:47:43 +0530 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: References: Message-ID: <200804221847.43924.v.harishankar@gmail.com> On Tuesday 22 Apr 2008 18:00:02 Nick Craig-Wood wrote: > There is a recipe in the cookbook > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554 > > Which I've used and it works. Thanks. I found that recipe too. I was hoping I could cook up something similar without having to use the module win32api, but looks like that's not the case. > > you can also (if on unix) use > > http://www.noah.org/wiki/Pexpect > I'm on Linux. Debian. Pexpect would do the job fine too. The only thing is it's a third party module and so would reduce the portability of my application. But never mind. I guess I have to make a compromise one way or the other. > import os > from subprocess import * > from subprocess import mswindows > from time import sleep > > if mswindows: > import win32api > else: > import signal > > class PopenNB(Popen): > # - see cookbook recipe for rest of stuff > # ... > def kill(self, killpg=False): > """ > Kill the running process > """ > pid = self.pid > if mswindows: > # Kill the process using win32api and pid - ignore errors > try: > PROCESS_TERMINATE = 1 > handle = win32api.OpenProcess(PROCESS_TERMINATE, False, > pid) win32api.TerminateProcess(handle, -1) > win32api.CloseHandle(handle) > except pywintypes.error: > pass > else: > # Kill the process by sending the pid / process group a > signal > if killpg: > try: > pgid = os.getpgid(pid) > except OSError: > killpg = False > try: > if killpg: > os.killpg(pgid, signal.SIGTERM) > else: > os.kill(pid, signal.SIGTERM) > except OSError: > return > sleep(1.0) > try: > if killpg: > os.killpg(pgid, signal.SIGKILL) > else: > os.kill(pid, signal.SIGKILL) > except OSError: > return Thanks for this bit of code. It should probably be adaptible to my needs. By the way, the win32api seems to be a nonstandard module (i.e. not present in the main distribution). -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org From billingspanshism at gmail.com Sat Apr 19 17:18:38 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:18:38 -0700 (PDT) Subject: photos of victoria beckham Message-ID: Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From arnodel at googlemail.com Mon Apr 7 14:54:28 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Mon, 7 Apr 2008 11:54:28 -0700 (PDT) Subject: A file iteration question/problem References: <47f8eee1$0$759$bed64819@news.gradwell.net> <322f98fd-eb6e-4a05-a8c7-1e0c5329e955@w5g2000prd.googlegroups.com> <47fa1cf9$0$761$bed64819@news.gradwell.net> Message-ID: <51d5bba5-9a38-4f12-ba1e-ad82e661f59e@k10g2000prm.googlegroups.com> On Apr 7, 2:09?pm, tinn... at isbd.co.uk wrote: > Arnaud Delobelle wrote: > > def recfun(lines): > > ? ? for line in lines: > > ? ? ? ? # Do stuff > > ? ? ? ? if condition: > > ? ? ? ? ? ? recfun(lines) > > > lines = iter(open(filename)) > > recfun(lines) > > Does that work though? ?If you iterate through the file with the "for > line in lines:" in the first call of recfun(lines) you surely can't do > "for line in lines:" and get any sort of sensible result in recursive > calls of recfun(lines) can you? Try it! The keyword is iterator. Here is an example of how this would work, but since you didn't believe me I changed the context (strings not files) and I didn't make it as simple as possible ;) def reclist(string): chariter = iter(string + ' ') def rec(): l = [] word = '' for c in chariter: if c.isalnum(): word += c elif word and (c.isspace() or c in '[]'): l.append(word) word = '' if c == ']': return l elif c == '[': l.append(rec()) return l return rec() >>> reclist('40 and 2 eggs but no spam') ['40', 'and', '2', 'eggs', 'but', 'no', 'spam'] >>> reclist('[[40 and 2] eggs] but [no spam]') [[['40', 'and', '2'], 'eggs'], 'but', ['no', 'spam']] >>> -- Arnaud From gagsl-py2 at yahoo.com.ar Wed Apr 16 02:44:10 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 03:44:10 -0300 Subject: Interesting timing issue I noticed References: Message-ID: En Tue, 15 Apr 2008 23:24:01 -0300, Jonathan Shao escribi?: > I've written up a stripped down version of the code. I apologize for the > bad > coding; I am in a bit of a hurry. First things first: I think you will gain inmensely using NumPy: http://numpy.scipy.org/ My timings were 62 and 47ms with your code; after I modified it slightly, 39 and 48ms (for the "on3" and "two" functions). The changes: - instead of a list of lists, I used a defaultdict with (x,y) as the keys. That is, instead of matrix[x][y], I use matrix[x,y] - I converted all range -> xrange Some lines showing the changes: # generates a zero matrix def generate_zero(): import collections matrix = collections.defaultdict(int) return matrix def back_diff_one(back_array, fore_array, box): diff_array = generate_zero() start = time.time() for x in xrange(sizeX): for y in xrange(borderY): idx = x,y diff_array[idx] = back_array[idx] - fore_array[idx] for y in xrange((sizeY - borderY), sizeY): idx = x,y diff_array[idx] = back_array[idx] - fore_array[idx] for y in xrange(borderY, (sizeY - borderY)): for x in xrange(borderX): idx = x,y diff_array[idx] = back_array[idx] - fore_array[idx] for x in xrange((sizeX - borderX), sizeX): idx = x,y diff_array[idx] = back_array[idx] - fore_array[idx] Probably most of the time was spent on creating that many range objects in the inner loops. xrange objects are rather cheap, but you may try pre-creating them in advance before entering the loops. Another thing would be to rearrange the loops so the outer one executes less times; if you know that borderX< (Pdb) myclass MyClass( 0, 0, 'A string', 123.45) (Pdb) copy.copy(myclass) *** TypeError: TypeError('__new__() takes at least 4 arguments (2 given)',) I see 4 arguments (actually, 5 because Python is passing cls invisibly to __new__). Does anyone have an idea what is going on here? I have not defined __new__ in MyClass above. I can make the problem go away on one platform by defining __new__ as return MyClass(self, self.arg1, self.arg2, self.arg3) but I understand that return value to be the default, so I don't see why defining that method makes a difference. On another platform, that definition causes a different problem (I seem to be getting None as the return value of the copy in some cases). By the way, I have simplified somewhat the code in the explanation. In case it might matter, know that there are actually two classes that exhibit this problem. In one, there is actually a fourth argument in the __new__ method that has a default value (the float above), which is why the error message says that __new__ expects *at least* 4 arguments. In the other, the last argument is a parg collector. I have also had trouble pickling these classes. I surmise that pickle uses copy. -- Jeffrey Barish From bvidinli at gmail.com Wed Apr 16 08:50:25 2008 From: bvidinli at gmail.com (bvidinli) Date: Wed, 16 Apr 2008 15:50:25 +0300 Subject: is file open in system ? - other than lsof Message-ID: <36e8a7020804160550g6fba661cx7249426f35e7d635@mail.gmail.com> is there a way to find out if file open in system ? - please write if you know a way other than lsof. because lsof if slow for me. i need a faster way. i deal with thousands of files... so, i need a faster / python way for this. thanks. -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From weiss02121 at gmail.com Tue Apr 15 19:47:50 2008 From: weiss02121 at gmail.com (weiss02121 at gmail.com) Date: Tue, 15 Apr 2008 16:47:50 -0700 (PDT) Subject: lindsay lohan coke Message-ID: <8ee1238d-4776-4095-b29c-9272ccb96a58@u12g2000prd.googlegroups.com> Just few link on some Lindsay Lohan Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From jerry.fleming at saybot.com Mon Apr 14 04:21:26 2008 From: jerry.fleming at saybot.com (Jerry Fleming) Date: Mon, 14 Apr 2008 16:21:26 +0800 Subject: =?UTF-8?B?5pyJ5Lit5Zu95Lq65LmOPw==?= In-Reply-To: References: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> Message-ID: Penny Y. wrote: > bikthh at live.cn ??: >> Python????????????????. > > hehe, so humorous you are! > Yes I think python has good future. > But it depends on what you use it to do. > If you're a singer, a financier, a historian etc, you don't need python. A singer uses his/here throat; a financier uses the abacus -- well, traditionally. Anyway, python is useful only when computer is useful. It is helpful for programming guru, and newbies as well to do the 'quick tricks'. > But if you are playing in computer programming, it's valuable for you to > take some time learning python. > btw,I'm also newbie to python,but I like it. > > --penny From sjmachin at lexicon.net Tue Apr 22 18:12:03 2008 From: sjmachin at lexicon.net (John Machin) Date: Tue, 22 Apr 2008 22:12:03 GMT Subject: list manipulation In-Reply-To: References: <78158460-8508-4453-a2dc-c5814dda8839@59g2000hsb.googlegroups.com> Message-ID: <480e62b4$1@news.mel.dft.com.au> Mike Driscoll wrote: > Well you could always do something like this: > > output = ';'.join(roadList) > > Which will put single quotes on the ends. No, it doesn't. You are conflating foo and repr(foo). I suppose if you want to be > silly, you could do this: > > output = '"%s"' % ';'.join(roadList) *IF* your first effort were to put single quotes on the ends ('the-text') then your second effort would certainly produce something silly ... either '"the-text"' or "'the-text'" depending on which of the assignment or the join method you imagined was producing the single quotes. From lbonafide at yahoo.com Mon Apr 14 07:51:45 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Mon, 14 Apr 2008 04:51:45 -0700 (PDT) Subject: Java or C++? References: Message-ID: On Apr 14, 2:24?am, bdsatish wrote: > On Apr 14, 12:21 pm, Bob Martin wrote: > > > in 342367 20080414 074410 s0s... at gmail.com wrote: > > > >Hello, I was hoping to get some opinions on a subject. I've been > > >programming Python for almost two years now. Recently I learned Perl, > > >but frankly I'm not very comfortable with it. Now I want to move on > > >two either Java or C++, but I'm not sure which. Which one do you think > > >is a softer transition for a Python programmer? Which one do you think > > >will educate me the best? > > Certainly Java. It's also easier to find Java jobs than C++ jobs. Depending on the field, that is. From gabriel.rossetti at mydeskfriend.com Fri Apr 25 11:11:00 2008 From: gabriel.rossetti at mydeskfriend.com (Gabriel Rossetti) Date: Fri, 25 Apr 2008 17:11:00 +0200 Subject: why does the following with Queue, q.put('\x02', True) not put it in the queue? In-Reply-To: <6eb550ae-dca4-4371-856a-15bc9625f93c@z72g2000hsb.googlegroups.com> References: <6eb550ae-dca4-4371-856a-15bc9625f93c@z72g2000hsb.googlegroups.com> Message-ID: <4811F484.1070901@mydeskfriend.com> Arimaz SA Av. du 24 Janvier 11 Ateliers de la Ville de Renens, Atelier 5 1020 Renens, Switzerland www.mydeskfriend.com Mob: +41-(0)79-539-0069 Tel: +41-(0)21-566-7343 sturlamolden wrote: > On Apr 25, 4:38 pm, Gabriel Rossetti > wrote: > >> Hello, >> >> I'm having some trouble with the Queue class, for some reason, if I do >> this (ch == ) : >> >> q = Queue.Queue(0) >> repr(ch) >> q.put(ch, True) >> len(q.queue) >> > > >>>> from Queue import Queue >>>> q = Queue(0) >>>> s = '\x02' >>>> q.put(s,True) >>>> len(q.queue) >>>> > 1 > > > > yes, if you do it that way (s = '\x02') it works, but I read the data from a file, and I that way it doesn't work.... From musiccomposition at gmail.com Mon Apr 14 22:37:56 2008 From: musiccomposition at gmail.com (Benjamin) Date: Mon, 14 Apr 2008 19:37:56 -0700 (PDT) Subject: Brand New! References: <7f1828bf-ebe7-4111-bc59-70d125facb0a@d26g2000prg.googlegroups.com> Message-ID: On Apr 14, 9:00 pm, agent E 10 wrote: > Hi, I'm brand new to programming. Have any suggestions? I'm young. > Was it a good idea to start with python? I was planning on creating a > very simple program that asked yes/no questions for a school project. IMHO, Python is an excellent language to start with. Have you read the tutorial? http://docs.python.org/tut/tut.html > -Thanks! From torriem at gmail.com Wed Apr 23 22:22:14 2008 From: torriem at gmail.com (Michael Torrie) Date: Wed, 23 Apr 2008 20:22:14 -0600 Subject: library to do easy shell scripting in Python Message-ID: <480FEED6.8080309@gmail.com> Recently a post that mentioned a recipe that extended subprocess to allow killable processes caused me to do some thinking. Some of my larger bash scripts are starting to become a bit unwieldy (hundreds of lines of code). Yet for many things bash just works out so well because it is so close to the file system and processes. As part of another project, I now have need of a really good library to make it almost as easy to do things in Python as it is in Bash. With a simple wrapper around subprocess, I'm pretty much able to do most things. Most of my complicated bash hackery involves using awk, sed, grep, and cut to process text, which python does quite nicely, thank you very much. But there's a few things to add. To wit, I'm wanting to write a library that can deal with the following things: - spawn a process, feed it std in, get stdout, stderr, and err code. This is largely already accomplished by subprocess - spawn off processes as background daemons - spawn multiple processes and pipe output to input. - can do fancier things like bash does, like combine stderr/stdout, switch stderr/stdout, redirects to and from files - transparently allow a python function or object to be a part of the pipeline at any stage. Questions include, how would one design the interface for things, like assembling pipes? Several ideas include: pipe([prog1,args],[prog2,args],...) or run([prog1,args]).pipe([prog2,args]).pipe(...) The former doesn't deal very well with re-plumbing of the pipes, nor is there an easy way to redirect to and from a file. The second syntax is more flexible but a bit cumbersome. Also it doesn't allow redirection or flexible plumbing either. Any ideas on how I could design this? From usenet at janc.be Mon Apr 21 16:43:25 2008 From: usenet at janc.be (Jan Claeys) Date: Mon, 21 Apr 2008 20:43:25 GMT Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: Op Thu, 03 Apr 2008 00:06:34 -0700, schreef Dennis Lee Bieber: > On Thu, 03 Apr 2008 03:37:43 GMT, Jan Claeys declaimed > the following in comp.lang.python: > >> Later I learned C (and even later C++), and I've always been wondering >> why those languages were making simple things so complicated... > > Could it be that they are closer to being high-level assembly > languages meant to get close to the hardware (especially of the PDP > series that C originated on), whereas Pascal was designed to just be a > language meant for teaching algorithms and programming, not originally > intended for production efforts? Pointers in Borland's Pascal (and FreePascal) are bare machine pointers, with optional typing for the referenced value; I've never seen anything you could do with C pointers that you couldn't do with Borland Pascal pointers. (And I think the reason why pointers in C looked complicated is that the C syntax for pointers is inconsistent...) -- JanC From lists at cheimes.de Tue Apr 22 17:15:44 2008 From: lists at cheimes.de (Christian Heimes) Date: Tue, 22 Apr 2008 23:15:44 +0200 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: <480e5367$0$17314$9b622d9e@news.freenet.de> References: <480e5367$0$17314$9b622d9e@news.freenet.de> Message-ID: <480E5580.4090302@cheimes.de> Martin v. L?wis schrieb: >> 2. Kill the subprocess in a platform independent manner (i.e. no third party >> modules and no hacks). > > What's wrong with the .terminate method of the Popen object? It's brand new ;) Christian From contact at pythonxy.com Thu Apr 10 04:38:08 2008 From: contact at pythonxy.com (Python(x,y) - Python for Scientists) Date: Thu, 10 Apr 2008 10:38:08 +0200 (CEST) Subject: Python(x,y) - Free Python distribution for Scientists Message-ID: <58619.132.165.76.2.1207816688.squirrel@secure.nuxit.net> Dear all, The scientists among you may be interested in Python(x,y), a new scientific-oriented Python distribution. This Python/Eclipse distribution is freely available as a one-click Windows installer (a release for GNU/Linux with similar features will follow soon): http://www.pythonxy.com Please do not hesitate to forward this announcement... Thanks a lots, PR -- P. Raybaut Python(x,y) http://www.pythonxy.com From gagsl-py2 at yahoo.com.ar Wed Apr 30 05:12:03 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 30 Apr 2008 06:12:03 -0300 Subject: Sending Cntrl-C ?? References: <0274834e-17e1-4a95-88ec-f2aa77aeb3a9@k10g2000prm.googlegroups.com> Message-ID: En Tue, 29 Apr 2008 20:48:42 -0300, Christian Heimes escribi?: > gamename schrieb: >> Thanks, Christian. Would that work on win32 as well? > > No, Windows doesn't support the same, rich set of signal as Unix OSes. True but irrelevant to the question. To the OP: you can download the pywin32 package from sourceforge, and use win32api.GenerateConsoleCtrlEvent(win32con.CTRL_C_EVENT, pgid) or call the same function using ctypes. See http://msdn.microsoft.com/en-us/library/ms683155(VS.85).aspx for some important remarks. -- Gabriel Genellina From soray6034rao at gmail.com Wed Apr 30 07:29:07 2008 From: soray6034rao at gmail.com (soray6034rao at gmail.com) Date: Wed, 30 Apr 2008 04:29:07 -0700 (PDT) Subject: daylight savings time patch Message-ID: <888a5d55-49b8-4b16-834d-67687c9ad062@a70g2000hsh.googlegroups.com> daylight savings time patch http://crack.cracksofts.com From stefan_ml at behnel.de Tue Apr 22 03:36:52 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 22 Apr 2008 09:36:52 +0200 Subject: Java or C++? In-Reply-To: <2eae6385-1257-48fc-b793-31d0225503ba@f36g2000hsa.googlegroups.com> References: <2eae6385-1257-48fc-b793-31d0225503ba@f36g2000hsa.googlegroups.com> Message-ID: <480D9594.1050505@behnel.de> hdante wrote: > 6. If you just want to speed-up your python programs or offer some > special, system-specific or optimized behavior to your python > applications, or you just want to complement your python knowledge, > learn C. "Learn C", ok, but then go and use Cython instead. Stefan From skanemupp at yahoo.se Sun Apr 27 05:56:26 2008 From: skanemupp at yahoo.se (globalrev) Date: Sun, 27 Apr 2008 02:56:26 -0700 (PDT) Subject: python and web programming, easy way...? References: <2db36ccf-c9fd-4e7a-9697-fd5c23159287@j22g2000hsf.googlegroups.com> Message-ID: <75679853-b5de-42cb-9db2-a1508f2ad67e@59g2000hsb.googlegroups.com> On 27 Apr, 04:26, miya wrote: > On Apr 26, 4:36 pm, bvidinli wrote: > > > > > Hi, > > > i use currently python for console programming. > > in past, i tried it for web programming, to use it instead of php. > > Unfortunately, i failed in my attempt to switch to python. > > Currently, i make many webbased programs and a "Easy Hosting Control > > Panel " (www.ehcp.net) that runs on php, > > ehcp is a hosting control panel in beta stage.. > > > in fact, i use python, love it and want to switch to it in my all > > projects, including webbased programs and ehcp. > > Can your recomment me the easiest, most usable way to use python in > > web programming.. > > > in past, in my first attemt... i was able to run python as as apache > > cgi, runned it basicly, > > but i had many difficulties especially in sessions, cookies... > > > maybe currently there is a solution, but i dont know. > > > Please provide me the quickest/most appropriate solution for web > > programming in python. > > i will try to switch to python in ehcp too.. > > > Currently my web programs are simple Object Oriented programs, that > > basicly uses a few files, in php. > > i use sessions in use authentications. > > i currently use php because it is fairly easy to install/run on apache.. > > you just put it on server, it runs.. i look something like this for > > python. because python programming is much better than php. > > > Thank you a lot. > > > -- > > ?.Bahattin Vidinli > > Elk-Elektronik M?h. > > ------------------- > > iletisim bilgileri (Tercih sirasina gore): > > skype: bvidinli (sesli gorusme icin,www.skype.com) > > msn: bvidi... at iyibirisi.com > > yahoo: bvidinli > > > +90.532.7990607 > > +90.505.5667711 > > Django is the way to go for web development. > > http://www.djangoproject.com/ > > cya > > -- > Nicol?s Miyasato ( miya ) www.webpy.org is supereasy to get going with. dont know which is better for advanced stuff. From oakley at bardo.clearlight.com Fri Apr 11 11:11:37 2008 From: oakley at bardo.clearlight.com (Bryan Oakley) Date: Fri, 11 Apr 2008 15:11:37 GMT Subject: tkinter, overwrite Label-text? In-Reply-To: <403d094e-2704-40c0-a0b3-dd335b19af85@m1g2000pre.googlegroups.com> References: <666s2qF2il38sU1@mid.uni-berlin.de> <403d094e-2704-40c0-a0b3-dd335b19af85@m1g2000pre.googlegroups.com> Message-ID: skanemupp at yahoo.se wrote: > ok but i have trouble using grid. if i try to use a Label witht he > text answer in the following code it doenst work very well. > Can you describe "have trouble"? What sort of trouble -- syntax errors, the text never shows up, etc? Following is my attempt to use a label and textvariables for both the label widget and the entry widget. Caveat emptor: I've *never* written a tkinter program before in my life. I'm a tcl/tk expert but I'm learning python and this is my very first attempt. I took the liberty to reorganize the code slightly. There are still resize behaviors I don't like but let's tackle one problem at a time (rest assured: the problems are all solvable). Does this do what you want? from __future__ import division import Tkinter from Tkinter import * def main(): root = Tkinter.Tk() makeUI(root) root.mainloop() exit() def makeUI(root): global entryVariable global displayVariable displayVariable = StringVar() entryVariable = StringVar() root.title("Calculator") entry = Entry(root, textvariable=entryVariable) entry.grid(row=1, column=1, columnspan=4, sticky="nsew") display=Label(root, textvariable=displayVariable) display.grid(row=2, column=1, columnspan=4, stick="nsew") x = 1 y = 4 for char in '123+456-789*0()/.': b = Button(root, text=char, command=lambda n=char:Disp(n), width=2, height=1) b.grid(row=y, column=x) x=x+1 if x==5: x=1 y=y+1 b = Button(root, text="^", command=lambda n="**":Disp(n), width=2,height=1) b.grid(row=8, column=2) b = Button(root, text="C",command=Erase, width=2, height=1) b.grid(row=8, column=3) b = Button(root, text="c",command=Backspace, width=2, height=1) b.grid(row=8, column=4) b = Button(root, text="=",command=Calc, width=18, height=1) b.grid(row=9, column=1, columnspan=8) def Disp(nstr): global entryVariable tmp=entryVariable.get() tmp+=nstr entryVariable.set(tmp) def Calc(): global entryVariable global displayVariable expr=entryVariable.get() displayVariable.set("") try: displayVariable.set(eval(expr)) except: displayVariable.set("Not computable") def Erase(): global entryVariable global displayVariable entryVariable.set("") displayVariable.set("") def Backspace(): global entryVariable tmp=entryVariable.get() tmp=tmp[0:-1] entryVariable.set(tmp) main() From pecora at anvil.nrl.navy.mil Mon Apr 21 13:59:54 2008 From: pecora at anvil.nrl.navy.mil (Lou Pecora) Date: Mon, 21 Apr 2008 13:59:54 -0400 Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> <8f3a768d-0b4c-4077-9aef-a66898882f03@m1g2000pre.googlegroups.com> Message-ID: In article <8f3a768d-0b4c-4077-9aef-a66898882f03 at m1g2000pre.googlegroups.com>, castironpi at gmail.com wrote: > On Apr 21, 9:28?am, a... at pythoncraft.com (Aahz) wrote: > > > > > > Why is this newsgroup different from all other newsgroups? ? > > Different is a verbally atomic relation. It's a Passover question. -- -- Lou Pecora From ajaksu at gmail.com Mon Apr 14 20:58:25 2008 From: ajaksu at gmail.com (ajaksu) Date: Mon, 14 Apr 2008 17:58:25 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> Message-ID: On Apr 14, 8:10?pm, Sverker Nilsson wrote: > do i dare to open ?a thread about this? Yeah, you sure do! > come on you braver men Yeah! > we are at least not bought by g***le Hell no! > but why? others have said it so many times i think Huh?! > :-//// ?! Whatever! > but why? a few syntactic 'cleanups' for the cost of a huge rewrite of > all the code that have been builtup from all the beginning when the > once great Python came along and people began to use it and write code > for it. Like all that code would have to be rewritten. blaah. Yeah! Woo-hoo! Wait... What? No, no, you got it all wrong. Python developers are being extra-careful and doing a lot of hard work to keep things sane, allow easy migration, etc. > and i have perhaps been drinking but i have been p**d all week since i > began look into this:-( Ah, OK, calm down and look again. Things are way better than you think, but there is a lot of FUD going on too, so focus on serious, reliable reports. Cheers, Daniel From ntv1534 at gmail.com Wed Apr 30 20:56:06 2008 From: ntv1534 at gmail.com (MooMaster) Date: Wed, 30 Apr 2008 17:56:06 -0700 (PDT) Subject: We have string.isdigit(), why not string.isNumber()? Message-ID: <0d43feda-fab8-46ba-9af0-eaf497033acd@l17g2000pri.googlegroups.com> N00b question alert! I did a search for isdigit() in the group discussion, and it didn't look like the question had been asked in the first 2 pages, so sorry if it was... The manual documentation says: "isdigit( ) Return true if all characters in the string are digits and there is at least one character, false otherwise. For 8-bit strings, this method is locale-dependent. " So it makes sense that something like 5.6 would return false. But what if we want to make sure that our string is a valid number, ie decimals included? I know how to write a regexp or method or whatever to do this, my main question is *why* something like an isNumber() method is not baked into the class. Does such functionality exist somewhere else in the standard library that I'm just missing? From arnodel at googlemail.com Fri Apr 11 16:48:44 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Fri, 11 Apr 2008 13:48:44 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> <5b1b5304-f076-4240-b685-6aa6c4cc209a@u3g2000hsc.googlegroups.com> Message-ID: <63799d41-1889-42cc-89a6-4ec576dbc2b5@q24g2000prf.googlegroups.com> On Apr 11, 8:27?pm, Mark Dickinson wrote: > On Apr 11, 2:33?pm, Lie wrote: [...] > > Another mistake, in an unquantized value the probability of getting > > exactly 0.5 (or any other number specified) is not 0 but an > > infinitesimal (i.e. lim(x) where x -> 0 (BUT NOT ZERO)) > > I'm not sure you'll get many takers for this point of view. ?If X is > a random variable uniformly distributed on the interval [0, 1) then > the probability that X == 0.5 is indeed exactly 0, using conventional > definitions. ?(And if you're not using conventional definitions, you > should say so....) And I would like to know what unconventional - but mathematically meaningful - definitions lead to lim x != 0 x -> 0 -- Arnaud From ch612bunn at gmail.com Sun Apr 27 09:18:24 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:18:24 -0700 (PDT) Subject: norton internet security 2008 crack Message-ID: <28c5e948-1722-4317-bd1a-939a136d4a08@k13g2000hse.googlegroups.com> norton internet security 2008 crack http://wga-cracks.crackkey.net From bblais at bryant.edu Wed Apr 30 11:35:23 2008 From: bblais at bryant.edu (Brian Blais) Date: Wed, 30 Apr 2008 11:35:23 -0400 Subject: simple chemistry in python In-Reply-To: <4817BFF2.9030907@al.com.au> References: <5e3717e5-1913-4bda-94b3-ae165e5fb8ba@m73g2000hsh.googlegroups.com> <4817BFF2.9030907@al.com.au> Message-ID: <251FABCD-BAAC-4451-968E-2561E3AE47B4@bryant.edu> > > baoilleach wrote: >> >> If you are familiar with parsing XML, much of the data you need is >> stored in the following file: >> http://bodr.svn.sourceforge.net/viewvc/*checkout*/bodr/trunk/bodr/ >> elements/elements.xml?revision=34&content-type=text%2Fplain Here's a quick BeautifulSoup script to read it into a python dict. It misses anything not a scalar, but you can easily modify it to include arrays, etc... in the xml. hope it's useful. certainly a neat site! bb -- Brian Blais bblais at bryant.edu http://web.bryant.edu/~bblais from __future__ import with_statement from BeautifulSoup import BeautifulSoup with open('elements.xml') as fid: soup=BeautifulSoup(fid) all_atoms=soup('atom') element=soup('atom',{'id':'H'})[0] elements={} for atom in all_atoms: info={} id=atom['id'] scalars=atom('scalar') for s in scalars: dictref=s['dictref'] # seems to have a bo at the beginning datatype=s['datatype'] # seems to have a xsd: at the beginning contents=s.contents[0] if datatype=='xsd:Integer': value=int(contents) elif datatype=='xsd:int': value=int(contents) elif datatype=='xsd:float': value=float(contents) else: value=contents key=dictref[3:] info[key]=value elements[id]=info -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.sakkis at gmail.com Wed Apr 30 00:26:31 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 29 Apr 2008 21:26:31 -0700 (PDT) Subject: Python's doc problems: sort References: <929d5ce9-9063-4e6c-98aa-89526f89fba3@y18g2000pre.googlegroups.com> <9pof14t22rpq24219q0an2748i5f054qr4@4ax.com> Message-ID: <88273bc8-5152-4dfd-9f96-1d6ee2b83f99@e53g2000hsa.googlegroups.com> On Apr 29, 11:13?pm, J?rgen Exner wrote: > "xah... at gmail.com" wrote: > > Is this self-promoting maniac still going at it? > > >Although i disliked Perl very much [...] > > Then why on earth do you bother polluting this NG? > > Back into the killfile you go > > jue \|||/ (o o) ,----ooO--(_)-------. | Please | | don't feed the | | TROLL's ! | '--------------Ooo--' |__|__| || || ooO Ooo From paul at boddie.org.uk Wed Apr 23 07:51:18 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Wed, 23 Apr 2008 04:51:18 -0700 (PDT) Subject: subprocess module is sorely deficient? References: <811891.72800.qm@web39208.mail.mud.yahoo.com> Message-ID: <48d2c7cd-baa9-4815-bae0-cfa1cf481d28@r66g2000hsg.googlegroups.com> On 23 Apr, 13:17, Harishankar wrote: > On Wednesday 23 Apr 2008 15:11:21 Ben Kaplan wrote: > > I don't know about all Linux distros, but my Ubuntu machine (8.04 Beta), > > has the 'TERM' (xterm) and 'COLORTERM' (gnome-terminal) keys in os.environ. > > You might be able to use that to ensure that the terminal is installed, but > > you should probably look at a couple of other popular distros first to make > > sure that the key is there. > > This is set on Debian too. Thanks. I should be able to use this environment > variable on most Linux distributions, I suspect. Here on RHEL 4, COLORTERM has an empty value. I suppose that the freedesktop.org standards should cover this kind of thing, and there are some scripts out there which attempt to provide cross-desktop support on Free Software desktops: http://portland.freedesktop.org/wiki/XdgUtils Similarly, the desktop module should provide support for various desktop features, but opening command line windows or terminals isn't yet possible: http://www.python.org/pypi/desktop It'd be interesting to know if we could find out (or make up) reliable ways of opening the user's preferred terminal application. Paul From aahz at pythoncraft.com Mon Apr 21 09:20:59 2008 From: aahz at pythoncraft.com (Aahz) Date: 21 Apr 2008 06:20:59 -0700 Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: In article , Carl Banks wrote: >On Apr 20, 10:57 pm, a... at pythoncraft.com (Aahz) wrote: >> In article , >> Carl Banks wrote: >>>On Apr 17, 3:37 am, Jonathan Gardner >>>wrote: >>>> >>>> Using 100% of the CPU is a bug, not a feature. >>> >>>No it isn't. That idea is borne of the narrowmindedness of people who >>>write server-like network apps. What's true for web servers isn't >>>true for every application. >> >> Only when you have only one application running on a machine. > >Needless pedantry. > >"Using 100% of the CPU time a OS allow a process to have is not >necessarily a bug." Happy? Not really; my comment is about the same level of pedantry as yours. Jonathan's comment was clearly in the context of inappropriate CPU usage (e.g. spin-polling). Obviously, there are cases where hammering on the CPU for doing a complex calculation may be appropriate, but in those cases, you will want to ensure that your application gets as much CPU as possible by removing all unnecessary CPU usage by other apps. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ Why is this newsgroup different from all other newsgroups? From andreas.eisele at gmail.com Sat Apr 12 16:01:48 2008 From: andreas.eisele at gmail.com (andreas.eisele at gmail.com) Date: Sat, 12 Apr 2008 13:01:48 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: <32e2acc1-97cb-4911-bb0c-67965b5ff113@2g2000hsn.googlegroups.com> > Martin said that the default settings for the cyclic gc works for most > people. I agree. > Your test case has found a pathologic corner case which is *not* > typical for common application but typical for an artificial benchmark. I agree that my "corner" is not typical, but I strongly disagree with the classification as pathological. The only feature of my test case that is not typical is the huge number of distinct objects that are allocated. I admit that 1E7 objects is today still fairly untypical, but there is nothing pathological about it, it is just bigger. I is about as pathological as a file size >2G, which a few years ago seemed so outrageous that no OS bothered to support it, but is fairly common nowadays, so that a lack of support would appear as an arbitrary and unmotivated limitation nowadays. We all enjoy seeing Python adopted on a large scale and used by a broad community, so we should not accept arbitrary size limits. You could call a string with more than 2GB pathological, but I very much appreciate the fact that Python supports such strings for the few cases where they are needed (on a 64 bit architecture). Now a O(N*N) effort for large numbers of objects isn't such a hard limit, but in practice boils down to the same effect, that people cannot use Python in such circumstances. I would prefer it very much if such "soft limits" could be avoided as well. Given there is a fairly simple workaround (thanks again to Amaury!), the issue is not urgent, but I still think it is important in the long run. > Python is optimized for regular apps, not for benchmark (like some video > drivers). > I still think it would be worthwhile to support very large numbers of objects in a way that they can just be used, without knowledge of special tricks, and I would be fairly optimistic that those who have designed the current GC schemes could generalize them slightly so that these marginal cases will work better without imposing a penalty on the more typical cases. > By the way you shouldn't use range for large ranges of more than a > thousand items. xrange() should be faster and it will definitely use > much less memory - and memory Python 2.5 and older will never release > again. I'm going to fix the issue for Python 2.6 and 3.0. > Thanks for this hint, and for the work on the newer versions. This is very much appreciated. Andreas From john106henry at hotmail.com Sun Apr 27 00:04:58 2008 From: john106henry at hotmail.com (John Henry) Date: Sat, 26 Apr 2008 21:04:58 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> Message-ID: <1d8af3e3-c287-4d5b-a481-ca8c650f732f@s33g2000pri.googlegroups.com> On Apr 26, 3:03?pm, John Henry wrote: > On Apr 26, 8:46 am, a... at pythoncraft.com (Aahz) wrote: > > > > > > > In article <9028496e-30de-4853-8f57-b55d14e52... at h1g2000prh.googlegroups.com>, > > John Henry ? wrote: > > > >But then I looked closer. ?It turns out the XML file created by > > >QxTransformer is *very* similar in structure when compared to the > > >resource files used inPythonCard. ?Since there are no GUI builders > > >for QxTransformer, and I can't affort to buy the one for Qooxdoo > > >(Java! ?Yuk!), I decided to roll up my sleeves, took thePythoncard's > > >Layout Manager and modified it and created my own "Poor Man's Qooxdoo > > >GUI Layout Designer". > > > Cute! ?When you have working code, please do upload to PyPI. > > -- > > Aahz (a... at pythoncraft.com) ? ? ? ? ? <*> ? ? ? ?http://www.pythoncraft.com/ > > > Why is this newsgroup different from all other newsgroups? > > So far, I have the following widgets working: > > window, button, checkbox, static text, static box, list, combobox, > spinner, radio button group > > Shouldn't be long before the following works: > > static line, image, image button, choice.- Hide quoted text - > > - Show quoted text - All of the above works! TextFields next. From arnodel at googlemail.com Tue Apr 29 14:28:47 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Tue, 29 Apr 2008 19:28:47 +0100 Subject: Zope/DTML Infuriating... References: <3473a8d5-e113-464e-825c-e88a7758ce9d@d45g2000hsc.googlegroups.com> Message-ID: Jens writes: [...] > @Marco: Thanks for the links :-) Python may be one of those really > elegant languages, but the reference is really sub > standard. Checkout the layout of php.net for comparison. Think what > you will about php, but the reference is excellent. For that matter > check out msdn section on old-school asp, or even the common-lisp > documentation(http://www.lispworks.com/ > documentation/HyperSpec/Front/Contents.htm) Beauty is in the eye of the beholder. I'm used to the python doc layout, and I can find my way round it pretty fast. What I like about it is that it is organised thematically, so it is usually possible to think your way to where the relevant documentation is. Moreover, Python has a very useful help functionality: * at the interactive prompt: >>> help(someobject) >>> help(somemodule) Will give you lots of useful information * At the shell prompt: $ pydoc --> documentation about keyword > It's accessibility like that i'm missing. It shouldn't take 10 min > and a usenet post to figure to how to basic stuff like string > concatenation. It takes time to learn a language, and that includes learning how the documentation is organised. > And theres still plenty of unanswered questions after checking the > reference: > > - What is the exact definition of the operator e.g. op + (, > ) -> , op + (, ) : , op + ( ... The answers are here (in the library reference you checked): http://docs.python.org/lib/types.html > - What is the exact operator precedence That's a language feature, so it's in the *language* reference. http://docs.python.org/ref/summary.html > - Why is it, when primitive data types seem to be objects (similar to > javascript), that type casting is done through build-in functions > rather than methods, e.g. String.toInt('5') or '5'.toInt() or x = > Integer.fromString('5'). Because Python is not Javascript? In fact some are methods, e.g. str(x) is shorthand for x.__str__(). -- Arnaud From spe.stani.be at gmail.com Mon Apr 7 09:15:35 2008 From: spe.stani.be at gmail.com (SPE - Stani's Python Editor) Date: Mon, 7 Apr 2008 06:15:35 -0700 (PDT) Subject: Please test Phatch on Windows (was Re: ANN: Phatch = PHoto bATCH processor and renamer based on PIL) References: <15f9eaeb-8d02-4090-922e-97a65c20fe51@e23g2000prf.googlegroups.com> Message-ID: <95db4f1d-636b-4d61-94d7-6b65704604f3@s8g2000prg.googlegroups.com> Hi Steve, Thanks for the confirmation. It is indeed good news. Feel free to send me privately some screenshots. BTW, I just released Phatch 0.1.3 which is the final version for Ubuntu Hardy. Stani On Mar 31, 3:44?am, Steve Holden wrote: > Stani: > > You'll be happy to hear that it appears (after a quick test) to work on > Vista, though I blush to admit I actually have a Python running on that > platform. > > The font selection is much better than in previous versions - although > the names aren't quite the full font names it's pretty easy to tell > which one will be used. > > regards > ? Steve > > SPE - Stani's Python Editor wrote: > > > > > I have been working the last couple of days purely on bug fixing and > > to port the code ofPhatchfully to Windows as there were many issues. > > This has improved: > > -Phatchcan now create droplets on Windows (win32 extensions > > required) > > - Installed fonts are retrieved from the Windows registry > > - Image file dialogs are now working correctly > > - Missing icons are added (including aphatch.ico) and are now > > displayed in the windows titlebars > > - Image Inspector was missing a panel > > - Preview in Image Inspector now displays correctly > > - (...) > > > Besides thatPhatchnow features for all platforms: > > - fonts can be defined with a nice dropdown autocomplete list > > - drop down lists with convenient values in all actions > > - the action masks now ships with some predefined masks (such as torn > > edges) > > - right click in the actions dialog box to see the source of an action > > - View>Droplet nows shows the name of the action box rendered in the > > logo > > - Dutch translation is 100% complete > > > As such no new features have been added, but the user experience feels > > much more polished now. > > > Please read *carefully* the installation instructions first: > >http://photobatch.wikidot.com/install#toc6 > > > People who have been usingPhatchbefore should clear their font cache > > (if it exists). Simply delete the file: > > C:\Documents and Settings\Username\.phatch\fonts > > > I did thePhatchport on a Windows 2000 machine, so I am curious to > > hear howPhatchworks on Windows XP and Vista. I will fix any bug (as > > far as possible) which is reported quickly in the next couple of days. > > > You can help translatingPhatchhere: > >https://translations.launchpad.net/phatch/trunk/+pots/phatch > > > Thanks in advance, > > > Stani > > > On 18 feb, 15:58, "SPE - Stani's Python Editor" > > wrote: > >> I'm pleased to announce the release ofPhatchwhich is a > >> powerful batch processor and renamer.Phatchexposes a big part of the > >> Python Imaging Library through an user friendly GUI. (It is using > >> python-pyexiv2 to offer more extensive EXIF and IPTC support.)Phatch > >> is not targeted at manipulating individual pictures (such as with > >> Gimp), but repeating the same actions on hundreds or thousands of > >> images. > > >> If you know PIL and have some nice recipes laying around, it is very > >> easy to write plugins asPhatchgenerates the corresponding GUI > >> automagically just like in Django. Any existings PIL scripts can be > >> added very easily. Let me know if you want to contribute or have any > >> questions. > > >> Homepage:http://photobatch.stani.be(freedownload link below) > >> Tutorials:http://photobatch.wikidot.com/tutorials > >> Translations:https://translations.launchpad.net/phatch/trunk/+pots/phatch > >> License: GPLv3 > >> Screenshot:http://photobatch.wikidot.com/local--files/start/Screenshot-Phatch3d.jpg > >> (the perspective and reflection is produced byPhatchitself) > > >> Phatchhas many features, like: > >> - EXIF information inspector with thumbnail > >> - limit jpeg file size when saving > >> - tons of actions organized by tags (including perspective, round > >> corners, shadow, reflection, ...) > >> - console version (Phatchcan now run without a gui on servers) > >> - batch rename and copy files based on exif metadata > >> - data stamping (http://photobatch.wikidot.com) > >> - online documentation wiki (http://photobatch.wikidot.com) > > >> Linux only features: > >> - desktop or panel droplets on which images or folders can be dropped > >> (will be ported to Windows & Mac) > >> - Nautilus and desktop integration (with its own mime type and > >> nautilus extension) > >> - manpage with examples > > >> With python-pyexiv2 the following featues are added: > >> - embedding the original EXIF and IPTC tags in the image > > >> All actions mostly have a separate pil function in their source code, > >> so they could be read as a recipe book for PIL: > >> * Auto Contrast - Maximize image contrast > >> * Background - Put colour under transparent image > >> * Border - Crop or add border to all sides > >> * Brightness - Adjust brightness from black to white > >> * Canvas - Crop the image or enlarge canvas without resizing the image > >> * Colorize - Colorize grayscale image > >> * Common - Copies the most common pixel value > >> * Contrast - Adjust from grey to black & white > >> * Convert Mode - Convert the color mode of an image (grayscale, RGB, > >> RGBA or CMYK) > >> * Copy - Copy image file > >> * Effect - Blur, Sharpen, Emboss, Smooth, ... > >> * Equalize - Equalize the image histogram > >> * Fit - Downsize and crop image with fixed ratio > >> * Grayscale - Fade all colours to gray > >> * Invert - Invert the colors of the image (negative) > >> * Maximum - Copies the maximum pixel value > >> * Mask - Apply a transparency mask > >> * Median - Copies the median pixel value > >> * Minimum - Copies the minimum pixel value > >> * Offset - Offset by distance and wrap around > >> * Posterize - Reduce the number of bits of colour channel > >> * Perspective - Shear 2d or 3d > >> * Rank - Copies the rank'th pixel value > >> * Reflect - Drops a reflection > >> * Rename - Rename image file > >> * Rotate - Rotate with random angle > >> * Round - Round or crossed corners with variable radius and corners > >> * Saturation - Adjust saturation from grayscale to high > >> * Save - Save an image with variable compression in different types > >> * Scale - Scale an image with different resample filters. > >> * Shadow - Drop a blurred shadow under a photo with variable position, > >> blur and color > >> * Solarize - Invert all pixel values above threshold > >> * Text - Write text at a given position > >> * Transpose - Flip or rotate an image by 90 degrees > >> * Watermark - Apply a watermark image with variable placement (offset, > >> scaling, tiling) and opacity > > >> I developPhatchon Ubuntu/Linux, but I have tested and polished it > >> regularly on Windows and Mac Os X. (Only the droplet functionality > >> needs to be ported.)Phatchis submitted to Debian unstable and > >> Ubuntu Hardy. Packagers for other platforms are welcome. > > >> Requirements: > >> - PIL 1.1.5 or higher > >> - wxPython 2.6 or higher > >> - pyexiv2 (optional) > >> - python nautilus bindings (optional) > > >> Best regards, > >> Stani > >> --http://pythonide.stani.be > > -- > Steve Holden ? ? ? ?+1 571 484 6266 ? +1 800 494 3119 > Holden Web LLC ? ? ? ? ? ? ?http://www.holdenweb.com/ From pavlovevidence at gmail.com Mon Apr 7 18:47:28 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 7 Apr 2008 15:47:28 -0700 (PDT) Subject: Dependency Queue References: <0309251d-fba9-447c-9b17-f512988103ea@e39g2000hsf.googlegroups.com> Message-ID: On Apr 7, 1:13 pm, "Terry Reedy" wrote: > "Carl Banks" wrote in message > > news:0309251d-fba9-447c-9b17-f512988103ea at e39g2000hsf.googlegroups.com... > | I'm looking for any information about a certain kind of dynamic data > | structure. Not knowing if it has some well-known name that I could > | have Googled, I'll just call it a dependency queue. It's like a > | priority queue except instead of a strict ordering of items by > | priority, there is only a topological ordering (like you would have in > | a directed acyclic graph). > | > | To date I've been generating a dependency graph in advance every > | iteration through my main loop, doing a topsort, and executing the > | values in order (the values are callable objects--this is a > | scheduler). > | > | However, I'd like a dynamic dependency queue for two reasons: it would > | simplify things to not have to generate the whole graph in advance, > | and it could improve performance to run some tasks of the next > | iteration in the present one (this could potentially make better use > | of the dual-core and graphics hardware). > | > | I'm pretty sure I could hack out this structure on my own, but I'd > | like to see any prior information if there is any, in case anyone's > | figured out things like, Is there an easy way to detect cycles on > | insertion? and so on. > > Perhaps what you want is a dynamic DAG (directed acyclic graph) with > ordered labels. At any time, only the set of sources are eligible for > execution, so there is no reason to flatten the whole thing. I suspect > insertion with cycle detection would be easier, but I don't remember > actually seeing an algorithm. Yes, a dynamically updating DAG is probably how I'd implement it, that's straightforward enough. What I'm looking for is any prior work on uncovering properties and useful algorithms for the situations that would come up. Like is there a chapter of some book devoted to them? Carl Banks From roy at panix.com Thu Apr 10 08:57:39 2008 From: roy at panix.com (Roy Smith) Date: Thu, 10 Apr 2008 08:57:39 -0400 Subject: I am worried about Python 3 References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> <47fce3ca$0$36346$742ec2ed@news.sonic.net> <6663kdF2j5bs0U1@mid.uni-berlin.de> Message-ID: Gerhard H?ring wrote: > The difference is that Guido learnt from the mistakes of Perl 6 and set > much more realistic (moderate) goals for Python 3.0. Another difference is that by the time Perl 6 was being worked on, there were other new things on the horizon. People wanting something better than Perl 5 were looking at Python, Ruby, or Tcl. You're not going to convince your customers to upgrade to a new flavor of duct tape when they're already playing with velcro. From marli305nugent at gmail.com Sat Apr 26 09:54:08 2008 From: marli305nugent at gmail.com (marli305nugent at gmail.com) Date: Sat, 26 Apr 2008 06:54:08 -0700 (PDT) Subject: red alert 2 cd crack Message-ID: <83dd0afd-42a5-465c-b525-0bdb63515ede@26g2000hsk.googlegroups.com> red alert 2 cd crack http://cracks.00bp.com F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Sun Apr 20 21:48:09 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 22:48:09 -0300 Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480b8d58$0$26996$9b622d9e@news.freenet.de> <480BA644.9090701@cheimes.de> Message-ID: En Sun, 20 Apr 2008 17:23:32 -0300, Christian Heimes escribi?: > Martin v. L?wis schrieb: >> Can you give an example, please? > > http://trac.edgewall.org/ contains at least one example of a reference > leak. It's holding up the release of 0.11 for a while. *scnr* > > The problem is also covered by the docs at > http://docs.python.org/dev/library/sys.html#sys.exc_info Ah, you scared me for a while... :) Holding the traceback from sys.exc_info is not a memory leak, just prevents *a lot* of objects reaching refcount 0 as long as the execution frames are refering to them. Don't store a traceback more than needed and it should be fine... -- Gabriel Genellina From aaron.watters at gmail.com Wed Apr 16 14:10:20 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 16 Apr 2008 11:10:20 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> Message-ID: On Apr 16, 1:42 pm, Rhamphoryncus wrote: > The only reason to not make the > changes is that old, crufty, unmaintained libraries & applications > might depend on them somehow. If that's more important to you, what > you really want is a language who's specs are frozen - much like C > effectively is. I hope python doesn't become that for a long time > yet, as there's too much it could do better. I'm feeling a bit old, crufty, and unmaintained myself, but I'll try not to take offense. There is a difference between something that works fine until the rug gets pulled out and something that needs fixing. It's a shame to junk stuff that works. Also in the case of C/java etc changing the infrastructure is less scary because you usually find out about problems when the compile or link fails. For Python you may not find out about it until the program has been run many times. Perhaps this will inspire improved linters and better coding practices.... I suppose if the py3k migration inspires tons of insomniac young programmers to seek fame and admiration by cleaning up ancient libraries, it would be a good thing. It seems to have happened in the Perl4->5 migration some years ago. Could happen again. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=repeatedly+hammer From pavlovevidence at gmail.com Wed Apr 9 03:16:13 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Wed, 9 Apr 2008 00:16:13 -0700 (PDT) Subject: Converting a tuple to a list References: <00ba01c899c5$14528ae0$0a01a8c0@mobile> Message-ID: <38cb266f-259a-4458-8f12-6641091c94b3@s50g2000hsb.googlegroups.com> On Apr 8, 6:46 pm, "Gabriel Ibanez" wrote: > Gabriel Ibanez wrote: > > Hi all .. > > > I'm trying to using the map function to convert a tuple to a list, without > > success. > > > I would like to have a lonely line that performs the same as loop of the > > next script: > > > ------------------------------------------- > > # Conveting tuple -> list > > > tupla = ((1,2), (3,4), (5,6)) > > > print tupla > > > lista = [] > > for a in tupla: > > for b in a: > > lista.append(b) > > print lista > > ------------------------------------------- > > > Any idea ? > > > Thanks ... > > > # Gabriel > > list(tupla) > > would probably do it. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > --http://mail.python.org/mailman/listinfo/python-list > > That would just make a list of tuples, I think he wants [1, 2, 3, 4, 5, 6]. > > Try: l = [x for z in t for x in z] > > --Brian > > --------------- > > Thanks Steve and Brian, > > Brian: that is !! > > However, it's a bit difficult to understand now. I have read it several > times :) A list comp is straightforwardly equivalent to nested for loops. To read, it may be easeier to write it out as loops: l = [] for z in t: for x in z: l.append(x) Which, you'll note, it the same as your working code only with different names. Carl Banks From drjekil77 at gmail.com Wed Apr 9 17:02:01 2008 From: drjekil77 at gmail.com (drjekil) Date: Wed, 9 Apr 2008 14:02:01 -0700 (PDT) Subject: new user needs help! In-Reply-To: <16571823.post@talk.nabble.com> References: <16571823.post@talk.nabble.com> Message-ID: <16596608.post@talk.nabble.com> I have done something so far about that problem,but its not the good way to do it need ur comments about that.... from string import *; import sys myfile = open("/afs/pdc.kth.se/home/d/debnath/membrane/1a91A.txt") a = myfile.readlines() data = myfile.readlines() for line in myfile.readlines(): fields = line.split('\t') items=fields.strip() list1.append(items[1]) for i in aminoacid: if 10.0 <= z <= 22.0: matches.append([1,i]) #here i am getting comment! bash-3.1$ python bb.py File "bb.py", line 16 matches.append([1,i]) ^ IndentationError: expected an indented block else: matches.append([-1,i]) print "#T/F A C D E F G H I K L M N P Q R S T V W X Y Z" for a in range(0,len(matches),1): if matches[a][0]==1: if matches[a][1]=='A': print "1 1:1 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" elif matches[a][1]=='C': print "1 1:0 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" elif matches[a][1]=='D': print " 1 1:0 2:0 3:1 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" """ if matches[a][1]=='E' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:1 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='F' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:1 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='G' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:1 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='H' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='I' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:1 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='K' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:1 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='L' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:1 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='M' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:1 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='N' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:1 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='P' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:1 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='Q' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='R' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:1 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='S' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:1 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='T' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:1 18:0 19:0 20:0 21:0" if matches[a][1]=='V' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:1 19:0 20:0 21:0" if matches[a][1]=='X' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:1 20:0 21:0" if matches[a][1]=='Y' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:1 21:0" if matches[a][1]=='Z' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:1" """ else: if matches[a][1]=='A': print "-1 1:1 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" elif matches[a][1]=='C': print "-1 1:0 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" elif matches[a][1]=='D': print " 1 1:0 2:0 3:1 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" """ if matches[a][1]=='E' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:1 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='F' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:1 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='G' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:1 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='H' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='I' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:1 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='K' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:1 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='L' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:1 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='M' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:1 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='N' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:1 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='P' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:1 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='Q' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='R' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:1 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='S' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:1 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='T' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:1 18:0 19:0 20:0 21:0" if matches[a][1]=='V' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:1 19:0 20:0 21:0" if matches[a][1]=='X' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:1 20:0 21:0" if matches[a][1]=='Y' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:1 21:0" if matches[a][1]=='Z' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:1" waiting for ur opinion. thanks -- View this message in context: http://www.nabble.com/new--user-needs-help%21-tp16571823p16596608.html Sent from the Python - python-list mailing list archive at Nabble.com. From arnodel at googlemail.com Sun Apr 27 13:00:54 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 27 Apr 2008 18:00:54 +0100 Subject: removing extension References: <67jok9F2o7iv7U2@mid.uni-berlin.de> Message-ID: Marc 'BlackJack' Rintsch writes: > Not exactly. In the case of no extension `os.path.splitext()` still works: > > In [14]: 'foo/bar.txt'.rsplit('.') > Out[14]: ['foo/bar', 'txt'] > > In [15]: 'foo/bar'.rsplit('.') > Out[15]: ['foo/bar'] > > In [16]: os.path.splitext('foo/bar') > Out[16]: ('foo/bar', '') And crucially, it still works correctly if the file has no extension but a directory in the path has one: >>> 'foo.baz/bar'.rsplit('.') ['foo', 'baz/bar'] >>> os.path.splitext('foo.baz/bar') ('foo.baz/bar', '') Conclusion: forget about str.rsplit() (which I suggested), use os.path.splitext() instead :) -- Arnaud From gagsl-py2 at yahoo.com.ar Fri Apr 25 22:14:40 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 25 Apr 2008 23:14:40 -0300 Subject: Newbie question about import References: <27308d500804251103t71d04b5fg1de6658ceab9d898@mail.gmail.com> Message-ID: En Fri, 25 Apr 2008 15:03:18 -0300, Luca escribi?: > Hi all. I'm trying to do something with python import but isn't working > for me. > > Using python 2,5 I've a program structured like this: > > * a main module called (for example) "mommy" with an __init__.py and a > file called "mommy.py" > * a __version__ var defined inside the main __init__.py > >> From the mommy.py file I need to import the __version__ var, but I'm > really not able to do this! I fear this is a very stupid task to do... > my problem is that the file is called like the module. > > Anyone can point me to the solution? The short answer is: don't do that! __init__.py may import any module, but other modules in the package should not import anything from __init__.py The same rule applies to the main module in an application: it can import any other required module, but no one should import main. If you don't follow those rules you may encounter some surprises. You *can* break the rules and actually do what you want, but I would not reccomend it. In this case, can't you switch the place where __version__ is defined? It looks like a constant, so you could have it actually defined in mommy.py, and inside __init__.py just import the value. -- Gabriel Genellina From deets at nospam.web.de Thu Apr 17 18:59:39 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 18 Apr 2008 00:59:39 +0200 Subject: py3k s***s In-Reply-To: References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> Message-ID: <66q33cF2krjf2U1@mid.uni-berlin.de> > And I have been benefiting from Python in general, so far. Thanks, > community. > > But now... I'll probably stop posting here for now, & I may stop other > things too. > > Just my 2c. You know what I was just wondering about? All these C-written cross-platform libraries (which Python users benefit from, most probably including evven you) that run on different unixes & windows, which are a much greater diversity to handle than the not-even-yet-settled differences between Py3K & 2.x. How the heck do they do that? Oh, and these dreaded 64 bit processors, possibly with multi-cores, which need changes in code as well, to be utilized to their power. But then, these guys most probably don't whine about diversity and constant change, and cry out useless threats to people who probably can't care less. Fare well, if you must. But getting mad over something which impact you can't even judge right now is childish. Nothing else. Diez From v.harishankar at gmail.com Tue Apr 22 23:09:49 2008 From: v.harishankar at gmail.com (Harishankar) Date: Wed, 23 Apr 2008 08:39:49 +0530 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: References: Message-ID: <200804230839.49560.v.harishankar@gmail.com> On Wednesday 23 Apr 2008 02:25:14 Christian Heimes wrote: > Nick Craig-Wood schrieb: > > Nothing apart from the fact it doesn't work on windows. The buffering > > will cause you grief too. If you want to do this properly under unix > > use pexpect not subprocess. > > > > http://www.noah.org/wiki/Pexpect > > > > Proper non blocking IO is an absolute nightmare under Windows in my > > experience! It really isn't the Windows way so you are fighting the > > system the whole time. > > Nick is correct. The subproces tries to work around the issues with > threads. But it's no more than an ugly workaround fir Windows' short > comings on async file IO. It's a shame Windows implements the select() > syscall in wsock32 and limits its usage to sockets. > > By the way I'm willing to dedicate some time to help enhancing the > subprocess. Everybody is invited to submit patches and I'll review and > check them into the trunk and py3k ASAP. Any help is appreciated: > enhancements for async IO, doc updates, more examples ... > > Christian > Python core developer Thanks a lot to everybody who's been following this discussion. Very interesting indeed. I'm currently thinking of working around this problem by actually opening a new terminal window and running the command from there, thus allowing the user full control over the process. Is there any platform independent way to launch a terminal window from a desktop (Windows, Linux, etc.)? -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org From lists at cheimes.de Sat Apr 12 08:41:42 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 12 Apr 2008 14:41:42 +0200 Subject: Multiple independent Python interpreters in a C/C++ program? In-Reply-To: <669jv8F2jrimvU1@mid.uni-berlin.de> References: <669jv8F2jrimvU1@mid.uni-berlin.de> Message-ID: Diez B. Roggisch schrieb: > AFAIK there was a thread a few month ago that stated that this is > actually possible - but mostly 3rd-party-c-extension aren't capable of > supporting that. Martin von Loewis had a word in that, maybe googling > with that in mind reveals the discussion. > > And of course its a *bad* idea to pass objects between threads... http://www.python.org/dev/peps/pep-3121/ Christian From tracyde at gmail.com Thu Apr 3 14:31:37 2008 From: tracyde at gmail.com (Derek Tracy) Date: Thu, 3 Apr 2008 14:31:37 -0400 Subject: Manipulate Large Binary Files In-Reply-To: <7xlk3vctea.fsf@ruckus.brouhaha.com> References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> <9999810b0804021109n77f2c990p7b10d92e9344ad00@mail.gmail.com> <7xlk3vctea.fsf@ruckus.brouhaha.com> Message-ID: <1247DD9D-C204-48C3-B624-6F79FE96B89C@gmail.com> --------------------------- Derek Tracy tracyde at gmail.com --------------------------- On Apr 3, 2008, at 3:03 AM, Paul Rubin <"http:// phr.cx"@NOSPAM.invalid> wrote: > Derek Martin writes: >>> Both are clocking in at the same time (1m 5sec for 2.6Gb), are there >>> any ways I can optimize either solution? > > Getting 40+ MB/sec through a file system is pretty impressive. > Sounds like a RAID? > >> That said, due to normal I/O generally involving double-buffering, >> you >> might be able to speed things up noticably by using Memory-Mapped I/O >> (MMIO). It depends on whether or not the implementation of the >> Python >> things you're using already use MMIO under the hood, and whether or >> not MMIO happens to be broken in your OS. :) > > Python has the mmap module and I use it sometimes, but it's not > necessarily the right thing for something like this. Each page you > try to read from results in own delay while the resulting page fault > is serviced, so any overlapped i/o you get comes from the OS being > nice enough to do some predictive readahead for you on sequential > access if it does that. By coincidence there are a couple other > threads mentioning AIO which is a somewhat more powerful mechanism. > > -- > http://mail.python.org/mailman/listinfo/python-list From fw3 at hotmail.co.jp Thu Apr 3 16:03:43 2008 From: fw3 at hotmail.co.jp (wang frank) Date: Thu, 3 Apr 2008 20:03:43 +0000 Subject: Is Leo better than Vim and emacs? In-Reply-To: <3H6Jj.17$i_5.5@newsfe06.lga> References: <3H6Jj.17$i_5.5@newsfe06.lga> Message-ID: Hi, Thanks for developing Leo. I have been using Vim for long time to write code. Is it a good time to switch to Leo? what is the advantage of Leo against vim and emacs? Thanks Frank _________________________________________________________________ ?????????????????IE7?MSN??????????????? http://promotion.msn.co.jp/ie7/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin.laloux at gmail.com Sun Apr 20 05:19:07 2008 From: martin.laloux at gmail.com (martin.laloux at gmail.com) Date: Sun, 20 Apr 2008 02:19:07 -0700 (PDT) Subject: installing MySQLdb module References: <80f805f0-6829-4da3-bfb4-79875bb16114@a22g2000hsc.googlegroups.com> Message-ID: search, search, search http://groups.google.be/group/comp.lang.python/browse_thread/thread/d75a491b8dbc3880/7d4f8eea29e23992?hl=fr&lnk=gst&q=MySQLdb+mac#7d4f8eea29e23992 From smmehadi at gmail.com Mon Apr 7 23:35:29 2008 From: smmehadi at gmail.com (syed mehdi) Date: Tue, 8 Apr 2008 09:05:29 +0530 Subject: ImportError: No module named MySQLdb Message-ID: <12b075a10804072035j42c85d4m3e4b45778d9697c4@mail.gmail.com> Hi Guys, I have been working in python from some time now, while writing a python script i used: import MySQLdb in my script to do some database related operations. When i tried to execute the same script on another system it gave me an error as: "ImportError: No module named MySQLdb" though mysqldb was already installed on that system, and python 2.5.2 was present on that machine. i have tried uninstalling and installing of mysql again and again but to no avail. please help me resolve the issue. Thanks & Regards Syed -------------- next part -------------- An HTML attachment was scrubbed... URL: From bbxx789_05ss at yahoo.com Tue Apr 1 01:12:27 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Mon, 31 Mar 2008 22:12:27 -0700 (PDT) Subject: Looking for indent advice howto in emacs python-mode References: Message-ID: <82ac2b10-dae7-4d63-bc8e-29bf47ad7385@n58g2000hsf.googlegroups.com> On Mar 31, 10:32?am, "Steven W. Orr" wrote: > Here's what I want to do: > > if ( ( v == 1 ) > ? ?or ( v == 2 ) > ? ?or ( v == 3 ) ): > ? ? ?pass > python indenting = 4 spaces From wuwei23 at gmail.com Wed Apr 2 06:52:33 2008 From: wuwei23 at gmail.com (alex23) Date: Wed, 2 Apr 2008 03:52:33 -0700 (PDT) Subject: the scaling of pics in pygame References: <49d8b8ae-08e3-4e86-9ced-2804b6dec4e5@b5g2000pri.googlegroups.com> Message-ID: <3c28d833-b336-4665-a692-d9d462a355c2@q27g2000prf.googlegroups.com> On Apr 2, 12:44 pm, Jimmy wrote: > I am using Pygame to write a small program. I tried to load a .jpg > picture into > the screen, however, the size of the pic doesn't fit into the window > properly. Can > anyone tell me how to scale the picture into the window? Have you tried the Pygame documentation? http://www.pygame.org/docs/ref/transform.html#pygame.transform.scale - alex23 From kay.schluehr at gmx.net Fri Apr 4 15:18:48 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Fri, 4 Apr 2008 12:18:48 -0700 (PDT) Subject: Tokenizer inconsistency wrt to new lines in comments References: <1ce40dcf-4a0a-4577-af3b-6a77ef71356c@f63g2000hsf.googlegroups.com> Message-ID: <6dd69a1f-96d0-4b91-b84b-a54794a31c70@u36g2000prf.googlegroups.com> On 4 Apr., 18:22, George Sakkis wrote: > The tokenize.generate_tokens function seems to handle in a context- > sensitive manner the new line after a comment: > > >>> from StringIO import StringIO > >>> from tokenize import generate_tokens > > >>> text = ''' > > ... # hello world > ... x = ( > ... # hello world > ... ) > ... ''' > > >>> for t in generate_tokens(StringIO(text).readline): > > ... print repr(t[1]) > ... > '\n' > '# hello world\n' > 'x' > '=' > '(' > '\n' > '# hello world' > '\n' > ')' > '\n' > '' > > Is there a reason that the newline is included in the first comment > but not in the second, or is it a bug ? > > George I guess it's just an artifact of handling line continuations within expressions where a different rule is applied. For compilation purposes both the newlines within expressions as well as the comments are irrelevant. There are even two different token namely NEWLINE and NL which are produced for newlines. NL and COMMENT will be ignored. NEWLINE is relevant for the parser. If it was a bug it has to violate a functional requirement. I can't see which one. Kay From fabiofz at gmail.com Wed Apr 9 14:11:21 2008 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Wed, 9 Apr 2008 15:11:21 -0300 Subject: Pydev shell (was: Re: Stani's python ide 'spe' editor problem) Message-ID: > Anyway, I am extremely frustrated. I've tried other ide's: pythonwin (I > found it inadequate for my purposes - why is a command line prompt > displayed in a dialog window?) - eclipse (editor is just ok, shell does > not have command history(!), and then *really* funky things started > happening that I could not explain and so had to stop using it) - idle > is good for small things and ok for larger projects but limited in general. Hi Rick, The new release has an actual console shell (with code-completion, history, etc: see http://pydev.sourceforge.net/ for more details). Aside from that, which 'funky' things started happening? Cheers, Fabio From jr9445 at ATT.COM Wed Apr 9 16:11:05 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Wed, 9 Apr 2008 15:11:05 -0500 Subject: Stripping scripts from HTML with regular expressions In-Reply-To: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> References: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: > -----Original Message----- > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > list-bounces+jr9445=att.com at python.org] On Behalf Of Michel Bouwmans > Sent: Wednesday, April 09, 2008 3:38 PM > To: python-list at python.org > Subject: Stripping scripts from HTML with regular expressions > > Hey everyone, > > I'm trying to strip all script-blocks from a HTML-file using regex. > > I tried the following in Python: > > testfile = open('testfile') > testhtml = testfile.read() > regex = re.compile(']*>(.*?)', re.DOTALL) > result = regex.sub('', blaat) > print result > > This strips far more away then just the script-blocks. Am I missing > something from the regex-implementation from Python or am I doing > something > else wrong? > [Insert obligatory comment about using a html specific parser (HTMLParser) instead of regexes.] Actually your regex didn't appear to strip anything. You probably saw stuff disappear because blaat != testhtml: testhtml = testfile.read() result = regex.sub('', blaat) Try this: import re testfile = open('a.html') testhtml = testfile.read() regex = re.compile('(.*?)', re.DOTALL) result = regex.sub('',testhtml) print result From mikael at isy.liu.se Fri Apr 11 11:19:50 2008 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 11 Apr 2008 17:19:50 +0200 Subject: Rounding a number to nearest even In-Reply-To: <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> Message-ID: cokofreedom at gmail.com commented about rounding towards even numbers from mid-way between integers as opposed to for instance always rounding up in those cases: > Strange request though, why do you need it that way, because 2.5 is > CLOSER to 3 than to 2... That's exactly how I was taught to do rounding in what-ever low-level class it was. The idea is to avoid a bias, which assumes that the original values are already quantized. Assume that we have values quantized to one decimal only, and assume that all values of this decimal are equally likely. Also assume that the integer part of our numbers are equally likely to be even or odd. Then the average rounding error when rounding to integers will be 0.05 if you always round up when the decimal is 5. If you round towards an even number instead when the decimal is 5, then you will round up half of those times, and round down the other half, and the average rounding error will be 0. That's the idea. Of course you could argue that it would be even more fair to make the choice based on the tossing of a fair coin. Note that if you do not have quantized values and assuming that the fraction part is evenly distributed between 0 and 1, than this whole argument is moot. The probability of getting exactly 0.5 is zero in that case, just as the probability of getting any other specified number is zero. That said, measurements are in practice always quantized, and rounding towards an even number when mid-way between avoids an average error of half the original precision. As a side-note: The the smallest coin in Swedish currency SEK is 0.50, but prices in stores are given with two decimals, i.e. with precision 0.01. But what if your goods add up to 12.34? The standard in Swedish stores, after adding the prices of your goods, is to round the number to the nearest whole or half SEK, which means that decimals 25 and 75 are mid-way between. In those cases the rounding is usually done to the nearest whole SEK, which is based on precicely the above reasoning. If they did not do that, I could argue that they are stealing on average 0.005 SEK from me every time I go to the store. Well... I could live with that, since 0.005 SEK is a ridiculously small amount, and even if I make thousands of such transactions per year, it still sums up to a neglectable amount. Another side-note: My 12-year old son is now being taught to always round up from mid-way between. Yet another example of the degradation of maths in schools. /MiO From mccle27252 at gmail.com Mon Apr 21 03:52:35 2008 From: mccle27252 at gmail.com (mccle27252 at gmail.com) Date: Mon, 21 Apr 2008 00:52:35 -0700 (PDT) Subject: pes 6 stadium patch download Message-ID: <4549f459-bba8-4889-8a40-6e866cded233@b5g2000pri.googlegroups.com> pes 6 stadium patch download http://cracks.00bp.com F R E E C R A C K S From pavlovevidence at gmail.com Tue Apr 22 14:53:25 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 22 Apr 2008 11:53:25 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> Message-ID: <8460ba2c-c6fd-41e7-a4a9-6dc2892d6ac8@l42g2000hsc.googlegroups.com> On Apr 22, 12:50 pm, J?r?my Wagner wrote: > Sure. Python is more readable than Perl, though I have found Python > to have a weird behavior regarding this little issue : > > How can you explain that Python doesn't support the ++ opeator, > whereas at the same time it does support the += operator ??? Because "Features A and B are in language X. Python adds Feature A. Therefore Python must also add Feature B (or it'll be weird)" is not valid logic. Carl Banks From dennis.benzinger at gmx.net Thu Apr 10 09:28:45 2008 From: dennis.benzinger at gmx.net (Dennis.Benzinger@gmx.net) Date: Thu, 10 Apr 2008 06:28:45 -0700 (PDT) Subject: tkinter, overwrite Label-text? References: Message-ID: On Apr 10, 2:35 pm, skanem... at yahoo.se wrote: > using python And tkinter. > > i have a GUI that outputs a text among other things. after input form > user i want this text to be *)cleared and/or > *)overwritten. > > what is the best way to achieve that? > [...] Which widget do you use? Some widgets can be connected to variables so that when the variable changes the widget is automatically update. Have a look . HTH, Dennis Benzinger From bruno.desthuilliers at gmail.com Wed Apr 2 14:04:00 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 11:04:00 -0700 (PDT) Subject: class / module introspection? References: Message-ID: <3c3f09df-08cb-4309-a870-6b12a813a8af@u36g2000prf.googlegroups.com> On 2 avr, 18:03, Brian Munroe wrote: > I'm struggling with an architectural problem and could use some > advice. > > I'm writing an application that will gather statuses from disparate > systems. Because new systems show up all the time, I'm trying to > design a plugin architecture that will allow people to contribute new > backends by just dropping a package/module into a specific directory. > The object methods in these backends will conform to a documented API > that the main application will call. > > Currently I have something that looks like this: > > src/ > backends/ > system1/ > __init__.py > system2/ > __init__.py > ... > > Then from my application (main.py) I can simply call: > > from backends import system1 > > be1 = system1.Backend() > be1.getStatus() > > This would work great if I knew about system1 and system2 ahead of > time, but that isn't the case. Having to rewrite main.py every time a > new backend module comes along is obviously a stupid idea too. I've > been thinking I need some kind of introspection, but I've been reading > about it and a whole mess of design pattern stuff, so my head is > swimming and I am totally unsure of what the best approach is. > > My guess is that I need to load all the backends at runtime Anyway, almost everything happens at runtime in Python !-) More seriously: the answer is in the doc. http://www.python.org/doc/2.3.5/lib/built-in-funcs.html read about the __import__ function, experiment in your interactive python shell, and you should be done in a couple minutes. From schettino72 at gmail.com Sat Apr 19 15:39:57 2008 From: schettino72 at gmail.com (Eduardo Schettino) Date: Sun, 20 Apr 2008 01:09:57 +0530 Subject: random.random(), random not defined!? In-Reply-To: <2a3931f5-481d-4831-baad-fcc9f0c0c129@m73g2000hsh.googlegroups.com> References: <2a3931f5-481d-4831-baad-fcc9f0c0c129@m73g2000hsh.googlegroups.com> Message-ID: On Sun, Apr 20, 2008 at 12:58 AM, globalrev wrote: > do i need to import something to use random? > -- you need to import random :) Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import random >>> random.random() 0.76018998919085967 From domiriel at gmail.com Mon Apr 21 10:44:15 2008 From: domiriel at gmail.com (domiriel at gmail.com) Date: Mon, 21 Apr 2008 07:44:15 -0700 (PDT) Subject: Finding the selected file in Windows Explorer Message-ID: Hi! I need to find the selected file(s) in a Windows Explorer window from another program (I'd look at the window that last had focus). I found something in the following page that should do the trick: http://blogs.msdn.com/oldnewthing/archive/2004/07/20/188696.aspx However, it is not Python and, while I'm a competent Python programmer, Win32, COM and the like are somewhat outside my competences. Does any one know how to do something similar in Python? Tks! Domiriel From rridge at caffeine.csclub.uwaterloo.ca Fri Apr 18 16:37:21 2008 From: rridge at caffeine.csclub.uwaterloo.ca (Ross Ridge) Date: Fri, 18 Apr 2008 16:37:21 -0400 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> Message-ID: Bob Greschke wrote: >I'm reading 3-byte numbers from a file and they are signed (+8 to >-8million). This seems to work, but I'm not sure it's right. > ># Convert the 3-characters into a number. > Value1, Value2, Value3 = unpack(">BBB", Buffer[s:s+3]) > Value = (Value1*65536)+(Value2*256)+Value3 > if Value >= 0x800000: > Value -= 0x1000000 > print Value > >For example: >16682720 = -94496 > >Should it be Value -= 0x1000001 so that I get -94497, instead? Your first case is correct, "Value -= 0x1000000". The value 0xFFFFFFF should be -1 and 0xFFFFFFF - 0x1000000 == -1. An alternative way of doing this: Value = unpack(">l", Buffer[s:s+3] + "\0")[0] >> 8 Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] rridge at csclub.uwaterloo.ca -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // From eatham at gmail.com Fri Apr 11 16:39:10 2008 From: eatham at gmail.com (Roger Dahlstrom) Date: Fri, 11 Apr 2008 13:39:10 -0700 (PDT) Subject: Windows - window status (Running vs Not Responding) References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> Message-ID: <22aa2ee2-6df9-4884-9aaf-232250a8c23f@y21g2000hsf.googlegroups.com> On Apr 11, 3:46 pm, Tim Golden wrote: > rdahlstrom wrote: > > On Apr 11, 1:45 pm, rdahlstrom wrote: > >> Does anyone know how to determine the window status (Running or Not > >> Responding)? I've tried various methods with no success... > > >> This would be on a variety of Windows systems, but all at least XP, > >> and mostly server 2003. Everyone will have Python 2.5.1 on them, and > >> the script would be running locally. > > >> Any ideas? > > > Basically, I'm looking for something similar to the Process.Responding > > property in System.Diagnostics... > > Well one (slightly drastic) possibility might be to use IronPython [1] > or Python.NET [2] to invoke the .Net functionality directly. AFAIK there > is no direct alternative: I believe that WMI can be a useful match > for System.Diagnostics but doesn't deal with windows (ie user-interface > elements). Presumably you could find a top-level window for each > process, using something vaguely like this [3] coupled with this [4] > and send it a suitable SendMessage to "ping" it. Haven't done it myself > but can't see why it shouldn't work. > > All a bit handwavey but maybe it'll point you somewhere... > > TJG > > [1]http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython > [2]http://pythonnet.sourceforge.net/ > [3]http://timgolden.me.uk/python/wmi_cookbook.html#running_processes > [4]http://timgolden.me.uk/python/win32_how_do_i/find-the-window-for-my-s... You know, I thought about sending it a message, but I found that, in testing, I am able to move, resize, and copy text from a "Not Responding" window. I was having a tough time figuring out a suitable message that I could send a generic window, one that I had no idea about what it had available to me. Other than sending it a graceful exit message (which I really don't want to do), have you any ides about what to send it? From sn at sncs.se Mon Apr 14 21:02:38 2008 From: sn at sncs.se (Sverker Nilsson) Date: Mon, 14 Apr 2008 18:02:38 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> Message-ID: <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> On Apr 15, 1:34 am, Steve Holden wrote: > Sverker Nilsson wrote: > > do i dare to open a thread about this? > > > come on you braver men > > > we are at least not bought by g***le > > > but why? others have said it so many times i think > > > :-//// > > > but why? a few syntactic 'cleanups' for the cost of a huge rewrite of I have sobered up abit, it doesnt matter much I tried out py3k on my project, http://guppy-pe.sf.net And i have looked into py3k also at the list and read quite a bit about it. no fun, to me at least Try it yourself, all contributions are welcome of course Sverker > > all the code that have been builtup from all the beginning when the > > once great Python came along and people began to use it and write code > > for it. Like all that code would have to be rewritten. blaah. > > and i have perhaps been drinking but i have been p**d all week since i > > began look into this:-( > > Perhaps you should sober up and look at the reality of Python 3, which > has deliberately avoided a complete rewrite. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ From python at bdurham.com Mon Apr 21 19:05:46 2008 From: python at bdurham.com (python at bdurham.com) Date: Mon, 21 Apr 2008 19:05:46 -0400 Subject: Does Python 2.5 include or not include SQLite engine? In-Reply-To: References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> Message-ID: <1208819146.23409.1249124463@webmail.messagingengine.com> While reading feedback to my post "Does Python 2.5.2's embedded SQLite support full text searching?" I noticed that there appears to be some confusion regarding whether Python 2.5 includes the SQLite engine. My Windows 2.5.2 binary download includes SQLite. But other posters claim otherwise, re: Linux releases of Python 2.5? I thought one of the major features of Python 2.5 was its embedded SQLite engine. Thoughts? Malcolm From nospam at nospam.invalid Tue Apr 29 20:06:49 2008 From: nospam at nospam.invalid (Rahul) Date: Wed, 30 Apr 2008 00:06:49 +0000 (UTC) Subject: python command mis-interprets arrow keys References: <67pp4oF2ppl3sU1@mid.uni-berlin.de> <67pq47F2plmb8U1@mid.uni-berlin.de> Message-ID: "Diez B. Roggisch" wrote in news:67pq47F2plmb8U1 @mid.uni-berlin.de: > > The question is if python is build with readline support. Did the python > version work before, and somehow got messed up, or did you build it > yourself and it never actually worked? I suspect we upgraded our RHEL and that broke it. Has never worked after. Is there a way to extract what cmd-line options my python was compiled with? Might be worth it before I go the long-painful route of re-installing. -- Rahul From python at bdurham.com Fri Apr 25 09:50:56 2008 From: python at bdurham.com (python at bdurham.com) Date: Fri, 25 Apr 2008 09:50:56 -0400 Subject: multiple pattern regular expression In-Reply-To: References: Message-ID: <1209131456.20871.1249849011@webmail.messagingengine.com> How about this? for line in file: # ignore lines without = assignment if '=' in line: property, value = line.strip().split( '=', 1 ) property = property.strip().lower() value = value.strip() # do something with property, value Malcolm From andrei.avk at gmail.com Sat Apr 5 09:45:55 2008 From: andrei.avk at gmail.com (AK) Date: Sat, 05 Apr 2008 08:45:55 -0500 Subject: Python-by-example - new online guide to Python Standard Library In-Reply-To: References: <47f2d018$0$6517$4c368faf@roadrunner.com> <47f617b0$0$16689$4c368faf@roadrunner.com> Message-ID: <47f77492$0$1096$4c368faf@roadrunner.com> ivan wrote: > Very cool. > Have you thought about making a printable version that doesn't wrap > any lines that shouldn't be and has page breaks at good spots? > > -- > ivan Hi ivan, I will work on that after I finalize modules that are already there. I think this would be better than having people print out the guide and then either have print out again in a couple of weeks or stuck with using a very outdated guide. So, I think it will be one to three weeks at most before printable version is available.. Glad you like Python by Example! thx, -- -ak Tobu | http://tobu.lightbird.net/ | Freeform DB / Tagger / PIM Python-by-Example | http://pbe.lightbird.net/ | Guide to LibRef From andrew at acooke.org Fri Apr 25 23:02:21 2008 From: andrew at acooke.org (andrew cooke) Date: Fri, 25 Apr 2008 20:02:21 -0700 (PDT) Subject: Logging ancestors ignored if config changes? Message-ID: <7770a385-e26d-4ad9-bc72-fa1228034c3b@26g2000hsk.googlegroups.com> Hi, I am seeing some odd behaviour with logging which would be explained if loggers that are not defined explicitly (but which are controlled via their ancestors) must be created after the logging system is configured via fileConfig(). That's a bit abstract, so here's the problem itself: I define my log within a module by doing import logging log = logging.getLogger(__name__) Now typically __name__ will be something like "acooke.utils.foo". That happens before the application configures logging, which it does by calling logging.config.fileConfig() to load a configuration. If I do that, then I don't see any logging output from "acooke.utils.foo" (when using "log" from above after "fileConfig" has been called) unless I explicitly define a logger with that name. Neither root nor an "acooke" logger, defined in the config file, are called. Is this a bug? Am I doing something stupid? To me the above seems like a natural way of using the system... Thanks, Andrew From castironpi at gmail.com Wed Apr 16 08:26:28 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 16 Apr 2008 05:26:28 -0700 (PDT) Subject: Preferred method for "Assignment by value" References: <8562becb-9fef-415d-9640-05ef80123596@a5g2000prg.googlegroups.com> <534f02b3-1eda-4332-96ae-3db3d4b4f44a@s33g2000pri.googlegroups.com> Message-ID: On Apr 15, 3:51?pm, sturlamolden wrote: > On Apr 15, 8:19 pm, hall.j... at gmail.com wrote: > > > Coming from VBA I have a tendency to think of everything as an > > array... > > Coding to much in Visual Basic, like Fortran 77, is bad for your mind. The distinction you're looking for is: VB: set a= collection a= collection Every assignment is a 'set'. From floris.bruynooghe at gmail.com Fri Apr 11 05:16:17 2008 From: floris.bruynooghe at gmail.com (Floris Bruynooghe) Date: Fri, 11 Apr 2008 02:16:17 -0700 (PDT) Subject: @x.setter property implementation References: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> <02cb2845-6a25-4e90-9f82-dbd68b37a5e6@p39g2000prm.googlegroups.com> <2c589c82-85e9-4db6-b8f9-156b06dd51f3@s33g2000pri.googlegroups.com> Message-ID: On Apr 10, 5:09 pm, Arnaud Delobelle wrote: > On Apr 10, 3:37 pm, Floris Bruynooghe > wrote: > > > > > On Apr 7, 2:19 pm, "Andrii V. Mishkovskyi" wrote: > > > > 2008/4/7, Floris Bruynooghe : > > > > > Have been grepping all over the place and failed to find it. I found > > > > the test module for them, but that doesn't get me very far... > > > > I think you should take a look at 'descrobject.c' file in 'Objects' directory. > > > Thanks, I found it! So after some looking around here was my > > implementation: > > > class myproperty(property): > > def setter(self, func): > > self.fset = func > > > But that doesn't work since fset is a read only attribute (and all of > > this is implemented in C). > > > So I've settled with the (nearly) original proposal from Guido on > > python-dev: > > > def propset(prop): > > assert isinstance(prop, property) > > @functools.wraps > > def helper(func): > > return property(prop.fget, func, prop.fdel, prop.__doc__) > > return helper > > > The downside of this is that upgrade from 2.5 to 2.6 will require code > > changes, I was trying to minimise those to just removing an import > > statement. > > > Regards > > Floris > > Here's an implementation of prop.setter in pure python < 2.6, but > using sys._getframe, and the only test performed is the one below :) > > import sys > > def find_key(mapping, searchval): > for key, val in mapping.iteritems(): > if val == searchval: > return key > > _property = property > > class property(property): > def setter(self, fset): > cls_ns = sys._getframe(1).f_locals > propname = find_key(cls_ns, self) > # if not propname: there's a problem! > cls_ns[propname] = property(self.fget, fset, > self.fdel, self.__doc__) > return fset > # getter and deleter can be defined the same way! > > # -------- Example ------- > > class Foo(object): > @property > def bar(self): > return self._bar > @bar.setter > def setbar(self, x): > self._bar = '<%s>' % x > > # -------- Interactive test ----- > > >>> foo = Foo() > >>> foo.bar = 3 > >>> foo.bar > '<3>' > >>> foo.bar = 'oeufs' > >>> foo.bar > '' > > Having fun'ly yours, Neat! Unfortunatly both this one and the one I posted before work when I try them out on the commandline but both fail when I try to use them in a module. And I just can't figure out why. Floris From ott.deb at gmail.com Thu Apr 17 15:04:11 2008 From: ott.deb at gmail.com (ott.deb at gmail.com) Date: Thu, 17 Apr 2008 12:04:11 -0700 (PDT) Subject: rks fax crack Message-ID: <2c7200b1-bdb0-4f3f-a1bb-b7b55e621d61@f36g2000hsa.googlegroups.com> rks fax crack http://cracks.12w.net F R E E C R A C K S From jzgoda at o2.usun.pl Thu Apr 3 09:56:01 2008 From: jzgoda at o2.usun.pl (Jarek Zgoda) Date: Thu, 03 Apr 2008 15:56:01 +0200 Subject: object-relational mappers In-Reply-To: <47f37039$0$31900$426a74cc@news.free.fr> References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <47f37039$0$31900$426a74cc@news.free.fr> Message-ID: Bruno Desthuilliers napisa?(a): > Now my own experience is that whenever I tried this approach for > anything non-trivial, I ended up building an "ad-hoc, > informally-specified bug-ridden slow implementation of half of " > SQLAlchemy. Which BTW is not strictly an ORM, but primarily an attempt > at a better integration of SQL into Python. So while it may feel like > learning the inner complexities of SQLALchemy (or Django's ORM which is > not that bad either) is "wasting brain cells", MVHO is that it's worth > the time spent. But YMMV of course - IOW, do what works best for you. I like OR mappers, they save me lot of work. The problem is, all of them are very resource hungry, processing resultset of 300k objects one by one can effectively kill most of commodity systems. This is where raw SQL comes in handy. -- Jarek Zgoda Skype: jzgoda | GTalk: zgoda at jabber.aster.pl | voice: +48228430101 "We read Knuth so you don't have to." (Tim Peters) From stanc at al.com.au Fri Apr 18 05:04:08 2008 From: stanc at al.com.au (Astan Chee) Date: Fri, 18 Apr 2008 19:04:08 +1000 Subject: testing client-server sockets In-Reply-To: References: <4808627F.5040906@al.com.au> Message-ID: <48086408.4070205@al.com.au> Server code: import os, sys, socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host = '' port = 5602 s.bind((host,port)) try: s.listen(1) while 1: conn, addr = s.accept() print 'client is at', addr data = conn.recv(1000000) data = data * 10 z = raw_input() conn.send(data) conn.close() except Exception: s.close() Client code: import sys, os, socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host = 'hostIP' port = 5602 s.connect((host,port)) s.send(dlg.user.GetValue()) i =0 while True: data = s.recv(1000000) i+=1 if (i<5): print data if not data: break print 'received', len(data), 'bytes' s.close() David Harrison wrote: > On 18/04/2008, Astan Chee wrote: > >> Hi, >> I have a client-server socket script in python. Something like this >> http://ubuntuforums.org/showthread.php?t=208962 >> Now the problem I have is that I want to try to connect the client to >> the server on the same machine, but it gives me a 'port already in use' >> error. I just want the client to connect to the server for testing >> purposes. Any suggestions on how I should do this? >> Thanks >> Astan >> > > Can you post the client / server code for us ? It sounds like it's > likely to be a minor bug. > > -- "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." Animal Logic http://www.animallogic.com Please think of the environment before printing this email. This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. -------------- next part -------------- An HTML attachment was scrubbed... URL: From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 3 04:33:34 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 03 Apr 2008 10:33:34 +0200 Subject: Python in High School In-Reply-To: References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: <47f4965f$0$29986$426a74cc@news.free.fr> Jan Claeys a ?crit : (snip) > I learned about pointers while learning Pascal (and later embedded > assembler) using Borland's tools. > > Later I learned C (and even later C++), and I've always been wondering why > those languages were making simple things so complicated... > Similar pattern here : I had difficulties grasping pointers in C, then learned them in Pascal and got enlightned. Then I was able to use them correctly in C. From bijeshn at gmail.com Wed Apr 2 08:05:45 2008 From: bijeshn at gmail.com (bijeshn at gmail.com) Date: Wed, 2 Apr 2008 05:05:45 -0700 (PDT) Subject: splitting an XML file on the basis on basis of XML tags Message-ID: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> Hi all, i have an XML file with the following structure:: -----| | | . | . | --------------------> constitutes one record. . | . | . | | | ----| . . . -----------------------| . | . | . |----------------------> there are n records in between.... . | . | . | . ------------------------| . . -----| | | . | . | --------------------> constitutes one record. . | . | . | | | ----| Here is the main root tag of the XML, and ... constitutes one record. What I would like to do is to extract everything (xml tags and data) between nth tag and (n +k)th tag. The extracted data is to be written down to a separate file. Thanks... From gagsl-py2 at yahoo.com.ar Wed Apr 2 17:57:09 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 02 Apr 2008 18:57:09 -0300 Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> Message-ID: En Wed, 02 Apr 2008 09:23:21 -0300, sam escribi?: > Gabriel Genellina napisa?(a): > >>>>> 1. You have different syntax for named and unnamed (lambdas) >>>>> functions. Functions and methods are different things in Python even >>>>> if they have same syntax. But all these are still a pieces of code >>>>> that you use repeatedly to make some task. >>>>> >>>> A knife and scissors are both used to cut things, but that doesn't >>>> mean >>>> they are the same. >>> >>> Well -- sometimes you have to use many, many types of scissors. >> >> I don't get the point - weren't you criticizing Python for having many >> different kind of functions? > > Yes. Funciton is always a piece of code (program) that does something. > There is > no need for different syntax. Guido has regretted lambda for a long time; it was scheduled for deletion on Python 3000 [2] but finally will stay [3]. Class methods and instance methods are not just standard functions; instance methods were plain functions before 2.2 and the Class object was in charge of doing the "self magic". Now the descriptor protocol provides far more possibilities. > And you said that it is good to have these two types of syntax. It > sounds like: > "it is good to have knife and scissors to cut the _same_ thing, because > they are > not the same". I didn't say that (note that you trimmed most attribution lines) but I like to have "short anonymous functions" altough the syntax might be different. Perhaps in Python 4000. >> What are those programmers needs? > > Programmers need to protect name in a namespace. Name mangling is not > the best > choice. Why to "protect" names in a namespace? We are all adults here. Name mangling is a reasonable and simple way to avoid name conflicts in a shared namespace. I don't know whether it's the "best" way or not, but has worked fine for me for a long time. [1] http://www.python.org/doc/essays/ppt/regrets/PythonRegrets.ppt (couldn't find easily an older reference, but there are) [2] http://www.artima.com/weblogs/viewpost.jsp?thread=98196 [3] http://mail.python.org/pipermail/python-dev/2006-February/060415.html -- Gabriel Genellina From hniksic at xemacs.org Tue Apr 15 03:24:26 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Tue, 15 Apr 2008 09:24:26 +0200 Subject: Dynamic use of property() fails References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> Message-ID: <871w5760np.fsf@mulj.homelinux.net> "Gabriel Genellina" writes: > The "magic" happens when the descriptor is found in the *class*, not > in the instance. I think it's detailed in Hettinger's document. The document is wrong here: Alternatively, it is more common for a descriptor to be invoked automatically upon attribute access. For example, obj.d looks up d in the dictionary of obj. If d defines the method __get__, then d.__get__(obj) is invoked according to the precedence rules listed below. This sounds plausible and might have led Andrew to believe that his code should work. It should instead say "in the dictionary of obj's type" or something to that effect. I asked Raymond about it some time ago, and he agreed that it's an error, but he apparently didn't get around to fixing it. The actual code examples in the document are, of course, correct. From fabiofz at gmail.com Fri Apr 4 12:28:13 2008 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Fri, 4 Apr 2008 13:28:13 -0300 Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? In-Reply-To: References: Message-ID: Hi Nebur, Are you using svn? I did have a problem once related to that (but it's more related to the svn plugin than to pydev)... I think that for some reason the undo seems to be mapped to a creation of a file that came from svn (I don't remember exactly how to reproduce it, but I do remember it was associated only with svn -- cvs didn't have that problem -- but it was something like trying to make undo on a file that didn't have anything changed and then it would go to the svn and remove another file). Cheers, Fabio On Fri, Apr 4, 2008 at 12:38 PM, Nebur wrote: > Hi folks developing with Pydev/Eclipse, > > this is the second time in about half a year that the following > surprise bites me: > > I've switched between some files in Pydev/Eclipse using the > FileNavigator, and when I want to go back to my last-edited *.py file, > it is missing. > No more in the FileNavigator, no more in the OpenFiles-List of the > Editor. Removed anywhere. Erased from the file system. Restorable from > the version control only. > Only a young orphan *.pyc file is sitting around, showing me I haven't > dreamed of editing the file two minutes before. > I'm sure I did no delete operations with eclipse, and I'm sure I did > not use another application than eclipse in the meantime. > > No, I can't reproduce it, and I don't know whom to blame (Pydev? > Eclipse ? The File System ? A Virus that only 2 times in half a year > deletes a single file I'm busy working with, and seems to do nothing > else? Myself beeing schizophrenic ??) > > Someone else already had this effect ? > Nebur > > > PS: Debian Etch 64Bit/JFS,Eclipse3.3,Pydev1.3.14. > -- > http://mail.python.org/mailman/listinfo/python-list > From kinch1967 at gmail.com Sun Apr 27 12:20:45 2008 From: kinch1967 at gmail.com (bullockbefriending bard) Date: Sun, 27 Apr 2008 09:20:45 -0700 (PDT) Subject: design choice: multi-threaded / asynchronous wxpython client? References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: <6fd9f065-630c-44ec-b8ca-348b0eabb3d7@y18g2000pre.googlegroups.com> On Apr 27, 10:10?pm, David wrote: > > ?1) The data for the race about to start updates every (say) 15 > > ?seconds, and the data for earlier and later races updates only every > > ?(say) 5 minutes. There is ?no point for me to be hammering the server > > ?with requests every 15 seconds for data for races after the upcoming > > Try using an HTTP HEAD instruction instead to check if the data has > changed since last time. Thanks for the suggestion... am I going about this the right way here? import urllib2 request = urllib2.Request("http://get-rich.quick.com") request.get_method = lambda: "HEAD" http_file = urllib2.urlopen(request) print http_file.headers ->>> Age: 0 Date: Sun, 27 Apr 2008 16:07:11 GMT Content-Length: 521 Content-Type: text/xml; charset=utf-8 Expires: Sun, 27 Apr 2008 16:07:41 GMT Cache-Control: public, max-age=30, must-revalidate Connection: close Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET X-AspNet-Version: 1.1.4322 Via: 1.1 jcbw-nc3 (NetCache NetApp/5.5R4D6) Date is the time of the server response and not last data update. Data is definitely time of server response to my request and bears no relation to when the live XML data was updated. I know this for a fact because right now there is no active race meeting and any data still available is static and many hours old. I would not feel confident rejecting incoming data as duplicate based only on same content length criterion. Am I missing something here? Actually there doesn't seem to be too much difficulty performance-wise in fetching and parsing (minidom) the XML data and checking the internal (it's an attribute) update time stamp in the parsed doc. If timings got really tight, presumably I could more quickly check each doc's time stamp with SAX (time stamp comes early in data as one might reasonably expect) before deciding whether to go the whole hog with minidom if the time stamp has in fact changed since I last polled the server. But if there is something I don't get about HTTP HEAD approach, please let me know as a simple check like this would obviously be a good thing for me. From vafada at gmail.com Mon Apr 28 14:12:44 2008 From: vafada at gmail.com (Mark Bryan Yu) Date: Mon, 28 Apr 2008 11:12:44 -0700 (PDT) Subject: list.reverse() Message-ID: This set of codes works: >>> x = range(5) >>> x.reverse() >>> x [4, 3, 2, 1, 0] But this doesn't: >>> x = range(5).reverse() >>> print x None Please explain this behavior. range(5) returns a list from 0 to 4 and reverse just reverses the items on the list that is returned by range(5). Why is x None (null)? From s0suk3 at gmail.com Wed Apr 30 10:12:47 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Wed, 30 Apr 2008 07:12:47 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: <874c3c53-8a9a-4050-8c8d-fdd763fa36fb@m73g2000hsh.googlegroups.com> On Apr 12, 11:11 am, andreas.eis... at gmail.com wrote: > I should have been more specific about possible fixes. > > > > python2.5 -m timeit 'gc.disable();l=[(i,) for i in range(2000000)]' > > > 10 loops, best of 3: 662 msec per loop > > > > python2.5 -m timeit 'gc.enable();l=[(i,) for i in range(2000000)]' > > > 10 loops, best of 3: 15.2 sec per loop > > > In the latter case, thegarbagecollector apparently consumes about > > 97% of the overall time. > > In a related thread onhttp://bugs.python.org/issue2607 > Amaury Forgeot d'Arc suggested a setting of the GC > thresholds that actually solves the problem for me: > > > Disabling the gc may not be a good idea in a real application; I suggest > > you to play with the gc.set_threshold function and set larger values, at > > least while building the dictionary. (700, 1000, 10) seems to yield good > > results. > > python2.5 -m timeit 'gc.set_threshold(700,1000,10);l=[(i,) for i in range(2000000)]' > > 10 loops, best of 3: 658 msec per loop > > which made me suggest to use these as defaults, but then > Martin v. L?wis wrote that > > > No, the defaults are correct for typical applications. > > At that point I felt lost and as the general wish in that thread was > to move > discussion to comp.lang.python, I brought it up here, in a modified > and simplified form. > > > I would suggest to configure the default behaviour of thegarbage > > collector in such a way that this squared complexity is avoided > > without requiring specific knowledge and intervention by the user. Not > > being an expert in these details I would like to ask the gurus how > > this could be done. > > I hope this should be at least technically possible, whether it is > > really desirable or important for a default installation of Python > > could then be discussed once the disadvantages of such a setting would > > be apparent. > > I still don't see what is so good about defaults that lead to O(N*N) > computation for a O(N) problem, and I like Amaury's suggestion a lot, > so I would like to see comments on its disadvantages. Please don't > tell me that O(N*N) is good enough. For N>1E7 it isn't. > > About some other remarks made here: > > > I think the linguists of the world should write better automated > > translation systems. Not being an expert in these details I would like > > to ask the gurus how it could be done. > > I fully agree, and that is why I (as someone involved with MT) would > prefer to focus on MT and not on memory allocation issues, and by the > way, this is why I normally prefer to work in Python, as it normally > lets me focus on the problem instead of the tool. > > > There are going to be pathological cases in any memory allocation > > scheme. The fact that you have apparently located one calls for you to > > change your approach, not for the finely-tuned well-conceivedgarbage > > collection scheme to be abandoned for your convenience. > > I do not agree at all. Having to deal with N>1E7 objects is IMHO not > pathological, it is just daily practice in data-oriented work (we're > talking about deriving models from Gigawords, not about toy systems). > > > If you had made a definite proposal that could have been evaluated you > > request would perhaps have seemed a little more approachable. > > I feel it is ok to describe a generic problem without having found > the answer yet. > (If you disagree: Where are your definite proposals wrt. MT ? ;-) > But I admit, I should have brought up Amaury's definite proposal > right away. > > > A question often asked ... of people who are creating > > very large data structures in Python is "Why are you doing that?" > > That is, you should consider whether some kind of database solution > > would be better. You mention lots of dicts--it sounds like some > > balanced B-trees with disk loading on demand could be a good choice. > > I do it because I have to count frequencies of pairs of things that > appear in real data. Extremely simple stuff, only interesting because > of the size of the data set. After Amaury's hint to switch GC > temporarily > off I can count 100M pairs tokens (18M pair types) in about 15 > minutes, > which is very cool, and I can do it in only a few lines of code, which > is even cooler. > Any approach that would touch the disk would be too slow for me, and > bringing in complicated datastructures by myself would distract me > too much from what I need to do. That's exactly why I use Python; > it has lots of highly fine-tuned complicated stuff behind the scenes, > that is just doing the right thing, so I should not have to (and I > could > not) re-invent this myself. > > Thanks for the helpful comments, > Andreas In the issue at bugs.python.org, why do you say "Do I have to switch to Perl or C to get this done???", as if Perl and C were similar languages? If we were to look at Python, Perl, and C together, Python and Perl would be similar languages, and C would be quite something different, *specially* regarding the discussed issue: speed. So what do you mean by saying "Perl or C"? From sturlamolden at yahoo.no Sun Apr 20 14:11:07 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sun, 20 Apr 2008 11:11:07 -0700 (PDT) Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> <480b6133$0$34498$742ec2ed@news.sonic.net> Message-ID: <3eac67b4-da0a-4926-9ca4-942271513ad2@26g2000hsk.googlegroups.com> On Apr 20, 5:28 pm, JB Stern wrote: > Curious Steve, how do you pay the rent and by what authority do you > speak for "The Python world"? Your opinion couldn't be more wrong for > programmers like myself who live by the code they write (as opposed to > its support). Are you afraid to show the code to your customer? Are you afraid it will give you a bad reputatio? Are you worried about loosing future contracts? Is your code really that bad? Then you better keep it hidden from sight. If this is the case, my advice to you would be to find a different profession. Perhaps flipping burgers at McDonald's fits your talent? From nmiyasato at gmail.com Sat Apr 26 22:26:27 2008 From: nmiyasato at gmail.com (miya) Date: Sat, 26 Apr 2008 19:26:27 -0700 (PDT) Subject: python and web programming, easy way...? References: Message-ID: <2db36ccf-c9fd-4e7a-9697-fd5c23159287@j22g2000hsf.googlegroups.com> On Apr 26, 4:36 pm, bvidinli wrote: > Hi, > > i use currently python for console programming. > in past, i tried it for web programming, to use it instead of php. > Unfortunately, i failed in my attempt to switch to python. > Currently, i make many webbased programs and a "Easy Hosting Control > Panel " (www.ehcp.net) that runs on php, > ehcp is a hosting control panel in beta stage.. > > in fact, i use python, love it and want to switch to it in my all > projects, including webbased programs and ehcp. > Can your recomment me the easiest, most usable way to use python in > web programming.. > > in past, in my first attemt... i was able to run python as as apache > cgi, runned it basicly, > but i had many difficulties especially in sessions, cookies... > > maybe currently there is a solution, but i dont know. > > Please provide me the quickest/most appropriate solution for web > programming in python. > i will try to switch to python in ehcp too.. > > Currently my web programs are simple Object Oriented programs, that > basicly uses a few files, in php. > i use sessions in use authentications. > i currently use php because it is fairly easy to install/run on apache.. > you just put it on server, it runs.. i look something like this for > python. because python programming is much better than php. > > Thank you a lot. > > -- > ?.Bahattin Vidinli > Elk-Elektronik M?h. > ------------------- > iletisim bilgileri (Tercih sirasina gore): > skype: bvidinli (sesli gorusme icin,www.skype.com) > msn: bvidi... at iyibirisi.com > yahoo: bvidinli > > +90.532.7990607 > +90.505.5667711 Django is the way to go for web development. http://www.djangoproject.com/ cya -- Nicol?s Miyasato ( miya ) From bruno.desthuilliers at gmail.com Wed Apr 2 16:01:40 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 13:01:40 -0700 (PDT) Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> <7xwsngyu05.fsf@ruckus.brouhaha.com> Message-ID: On 2 avr, 20:46, Paul Rubin wrote: > "bruno.desthuilli... at gmail.com" writes: > > Here the problem is more philosophical than anything else. Python's > > philosophy is that most programmers are responsible and normally > > intelligent, so treating them all like retarted dummies because > > someone might one day do something stupid is just wasting everyone's > > time. This is also why there's no language-enforced access > > restriction, only a simple stupid convention to denote implementation > > stuff from API. The fact is that it JustWork. > > Additional Principles for C1X (new) > ... > 12. Trust the programmer, as a goal, is outdated in respect to the > security and safety programming communities. While it should not > be totally disregarded as a facet of the spirit of C, the > C1X version of the C Standard should take into account that > programmers need the ability to check their work. > > C - The C1X Charter > Document: WG14 N1250, p. 3http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1250.pdf Fine. But totally irrelevant here - this is comp.lang.python, not comp.lang.c, and we *do not* (I repeat : we *do not*) face the same safety and security problems as those existing in C. From kyosohma at gmail.com Tue Apr 22 23:18:17 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 22 Apr 2008 22:18:17 -0500 Subject: about python In-Reply-To: <12826269.63521208919025392.JavaMail.servlet@perfora> References: <12826269.63521208919025392.JavaMail.servlet@perfora> Message-ID: <480EAA79.6090900@gmail.com> mranjan at varshyl.com wrote: > How can python execute in browser? > > > Mukul > -- > http://mail.python.org/mailman/listinfo/python-list > Check out IronPython, which you can use with Silverlight or Mono. Or you could look at any of the cool Python Web Frameworks, such as TurboGears, Pylons, CherryPy, or Django. Mike From marco at sferacarta.com Tue Apr 29 09:49:25 2008 From: marco at sferacarta.com (Marco Mariani) Date: Tue, 29 Apr 2008 15:49:25 +0200 Subject: Zope/DTML Infuriating... In-Reply-To: <5493f048-db28-4f72-8265-99fd33c79f93@56g2000hsm.googlegroups.com> References: <3a955f90-ed80-46be-a238-1462e4fb2d0c@m3g2000hsc.googlegroups.com> <5493f048-db28-4f72-8265-99fd33c79f93@56g2000hsm.googlegroups.com> Message-ID: Jens wrote: > Hey no worriest. Is this the tutorial you're referring to: > > http://docs.python.org/lib/typesmapping.html > > Is there anything better? That's the library reference - the one to keep under the pillow. It also documents the core -- i.e. builtin objects. As for the language semantics, I suggest the whole of http://docs.python.org/tut/ then a bit of http://docs.python.org/ref/ref.html A good alternative could be the new edition of Python in a Nutshell. The author has a very clear style and leaves no corners uncovered. > I miss the discussion and examples that accompany most entries in php.net. This is a post + comments about strong/weak typing, although not an in-depth analyses. http://www.artima.com/forums/flat.jsp?forum=106&thread=7590 From lists at cheimes.de Sat Apr 12 10:59:17 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 12 Apr 2008 16:59:17 +0200 Subject: str(bytes) in Python 3.0 In-Reply-To: <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> Message-ID: <4800CE45.1030407@cheimes.de> Carl Banks schrieb: > I believe the Zen in effect here is, "In the face of ambiguity, refuse > the temptation to guess." How do you know if the bytes are utf-8 > encoded? Indeed > I'm not sure if str() returning the repr() of a bytes object (when not > passed an encoding) is the right thing, but it's probably better than > throwing an exception. The problem is, str can't decide whether it's > a type conversion operator or a formatted printing function--if it > were strongly one or the other it would be a lot more obvious what to > do. I was against it and I also wanted to have 'egg' == b'egg' raise an exception but I was overruled by Guido. At least I was allowed to implement the byte warning feature (-b and -bb arguments). I *highly* recommend that everybody runs her unit tests with the -bb option. Christian From lbonafide at yahoo.com Wed Apr 16 14:28:33 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Wed, 16 Apr 2008 11:28:33 -0700 (PDT) Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <0f58fb99-f441-4978-b750-1c0adb45eee4@e67g2000hsa.googlegroups.com> On Apr 16, 11:06?am, Steve Holden wrote: > I'm not saying people shouldn't use Google Groups. I'm saying that > Google can "justify" providing customer "support" that lives somewhere > between zero and extremely crappy by not charging for the service. It's even worse than that. Click on one of these spam links and you'll see Google ads. Why would Google have any motivation to stop selling ads? From sean_mcilroy at yahoo.com Sat Apr 12 15:40:04 2008 From: sean_mcilroy at yahoo.com (Sean McIlroy) Date: Sat, 12 Apr 2008 12:40:04 -0700 (PDT) Subject: override the interpreter's parser? Message-ID: <0e23fcab-4169-4ba8-ace4-6aa4a4b95947@q1g2000prf.googlegroups.com> hi all i'd like to write a module that, when run in the interpreter, would cause the interpreter to read certain strings that would normally be rejected as syntax errors (strings beginning with the @ symbol, say) and pass them on to an object defined in the aforementioned module. where should i look to start finding out how to do this? thanks for any help. peace stm From aahz at pythoncraft.com Mon Apr 7 20:47:46 2008 From: aahz at pythoncraft.com (Aahz) Date: 7 Apr 2008 17:47:46 -0700 Subject: Recursively Backup Directories References: Message-ID: In article , Jorgen Grahn wrote: > >I believe it is better to write a script which drives a widely known >and well-tested copying utility. On Unix these include tar, cpio and >rsync -- don't know which ones are common under DOS (xcopy?) Just use pax (I haven't bothered learning it because I haven't used Windows in years, but it's the only cross-platform archive/copy tool available). -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "It is easier to optimize correct code than to correct optimized code." --Bill Harlan From stargaming at gmail.com Fri Apr 4 15:04:28 2008 From: stargaming at gmail.com (Robert Lehmann) Date: 04 Apr 2008 19:04:28 GMT Subject: generator functions: why won't this work? References: <19359dad-3022-4e83-99e4-8f8093116bcb@a1g2000hsb.googlegroups.com> Message-ID: <47f67bbc$0$26905$9b622d9e@news.freenet.de> On Wed, 02 Apr 2008 19:04:30 -0300, Gabriel Genellina wrote: > En Wed, 02 Apr 2008 14:11:30 -0300, escribi?: > >> On Apr 1, 10:42?pm, "Gabriel Genellina" wrote: >>> En Tue, 01 Apr 2008 23:56:50 -0300, >>> escribi?: >>> >>> ? ?yield *iterable >>> >>> could be used as a shortcut for this: >>> >>> ? ?for __temp in iterable: yield __temp >> >> How serious were you about that? > > Not so much, I haven't thougth enough on it. Looks fine in principle, > but yield expressions may be a problem. Issue 2292: "Missing *-unpacking generalizations" http://bugs.python.org/issue2292 Discussion on python-3000.devel: http://thread.gmane.org/gmane.comp.python.python-3000.devel/12131 -- Robert "Stargaming" Lehmann From steve at holdenweb.com Tue Apr 8 22:22:40 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 22:22:40 -0400 Subject: new user needs help! In-Reply-To: <73decd360804081914l3545f622yb63b6f9e8cbcd714@mail.gmail.com> References: <10644597.63801207701350348.JavaMail.nabble@isper.nabble.com> <47FC148B.1010605@holdenweb.com> <73decd360804081914l3545f622yb63b6f9e8cbcd714@mail.gmail.com> Message-ID: <47FC2870.5000006@holdenweb.com> drjekil (or should that be mrhyde?): Once again, *please* make sure you reply to the list. Personal replies are much less likely to get attention. regards Steve drjekil sayer wrote: > u got it! > thats what i am trying to explain with my bad english! > thanks once again. > > > On 4/9/08, *Steve Holden* > wrote: > > drjekil77 at gmail.com wrote: > > thanks! > > > Please keep all replies on the list: somebody else may also wish to > help (and they will also pick up mistakes I make ;-) > > I am working with a text filelooks like this: > #NAME AA TOPO ACCESS DSSP STRIDE Z-COORD > 1lghB A i 79.8 H H -24.58 > 1lghB V i 79.6 H H -22.06 > 1lghB H i 71.9 H H -19.94 > i need to compare those lines which has a value between 10 to 22 > and presents in the following way > True/false A C D E F G H I K L M N P Q R S T V X Y W(here > alfabets represents amino acids) > 1 1:1 2:0 3:0 and so on for rest of the amino acids. > > > I have given 2 examples below to make it clear a bit: > > ex.1: > #NAME AA TOPO ACCESS DSSP STRIDE Z-COORD > 1lghB A i 79.8 H H -24.58 > #for that line amino acid is A and z-COORED > value is more than 22,so output should be look like > > True/false A C D E F G H I K L M N P Q R S T V X Y W(here > alfabets represents amino acids) > -1 1:1 2:0 3:o 4:0 so on upto 20 bcz there r 20 amino acids.and > A presents in the 1st position.every line represents one amino > acid with value,so output will show in which position is it(here > A is in 1st position thats why its value 1:1 and all the other > position o like 2:0,3:0,4:0 and if its Z-COORED value between > 10-22 then true false value 1,otherwise -1. > > another ex: > > 1lghB H i 71.9 H H -19.94 # for that line amino acid > is H and it has value between 10-22.so output should looks like: > > True/false A C D E F G H I K L M N P Q R S T V X Y W(here > alfabets represents 20 amino acids) > > 1 1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0,every position is zero up to > 20 bcz H presents in the 7th position.so it will be 1. > > so for every line, output will in 21 coulum,1st coulum for true > false value,others r for 20 amino acids.true false value will be > either 1 or -1,and within other 20 coulum one value will be > n:1,others will be n:0.n=0,1,2,3..20. > its a bit tricky. > thank u so much for ur help > waiting for ur opinion. > > > So, you are using -1 for true and 1 for false? Can there be multiple > amino acids on each line? > > Would this be a possible input: > > 1lghB AHG i 87.3 Q Q -23.45 > > If so, would this be the required output? > > -1 1:1 2:0 3:0 4:0 5:0 6:0 7:1 8:1 9:0 10:0 ... 19:0 20:0 > > There is no point trying to write more code until we understand the > requirements properly. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From andreas.profous at googlemail.com Fri Apr 25 07:15:55 2008 From: andreas.profous at googlemail.com (andreas.profous at googlemail.com) Date: Fri, 25 Apr 2008 04:15:55 -0700 (PDT) Subject: problem with unicode Message-ID: <26fcc207-b864-42c7-afb3-c6945e5fe29f@m44g2000hsc.googlegroups.com> Hi everybody, I'm using the win32 console and have the following short program excerpt # media is a binary string (mysql escaped zipped file) >> print media x???[? ... (works) >> print unicode(media) UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position 1: ordinal not in range(128) (ok i guess print assumes you want to print to ascii) >> print unicode(media).encode('utf-8') UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position 1: ordinal not in range(128) (why does this not work?) # mapString is a unicode string (i think at least) >> print "'" + mapString + "'" ' yu_200703_hello\ 831 v1234.9874 ' >> mystr = "%s %s" % (mapString, media) UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position 1: ordinal not in range(128) >> mystr = "%s %s" % (mapString.encode('utf-8'), media.encode('utf-8')) UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position 1: ordinal not in range(128) I don't know what to do. I just want to concatenate two string where apparently one is a binary string, the other one is a unicode string and I always seem to get this error. Any help is appreciated :) From fennelllindy8241 at gmail.com Mon Apr 28 03:16:13 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:16:13 -0700 (PDT) Subject: recipe for crack cocaine Message-ID: recipe for crack cocaine http://crack.cracksofts.com From paul at science.uva.nl Tue Apr 22 09:54:42 2008 From: paul at science.uva.nl (Paul Melis) Date: Tue, 22 Apr 2008 15:54:42 +0200 Subject: Python Success stories In-Reply-To: <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> Message-ID: <480DEE22.4040702@science.uva.nl> azrael wrote: > Which big aplications are written in python. I see its development, > But i can't come up with a big name. I know that there are a lot of > companys using python, but is there anythong big written only in > python. I want him to fuck of with his perl once and for all time Not really "big" in terms of lines of code, but definitely well-known and widespread: the official BitTorrent client is written in Python (and has been since the beginning I believe). Regards, Paul From jason.scheirer at gmail.com Tue Apr 22 23:46:36 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Tue, 22 Apr 2008 20:46:36 -0700 (PDT) Subject: about python References: Message-ID: <917df937-7241-4996-bb90-43d1bfbc54d8@e39g2000hsf.googlegroups.com> On Apr 22, 7:50?pm, mran... at varshyl.com wrote: > How can python execute in browser? > > Mukul Very carefully. Alternately, applets/Jython. From marlin_rowley at hotmail.com Fri Apr 25 11:38:13 2008 From: marlin_rowley at hotmail.com (Marlin Rowley) Date: Fri, 25 Apr 2008 10:38:13 -0500 Subject: Having problems with wxPython - HELP!! Message-ID: I'm desperately spending too much time trying to understand wxPython and it's leading me nowhere. I'm trying to make a script that will create a window, and then immediately fill this window with a background color. I also want to be able to fill this window with a background color anytime I need to, therefore I put it in a function called "InitBuffer()". Problem 1: Python doesn't clear the window with "Grey" (my background color) when it is initially created. Why? Problem 2: OnPaint() seems to always get called for whatever reason. Fine. But I only want it to refresh the contents of the window. So, if I draw to the Client window a series of rectangles, the ONLY thing I want OnPaint() to do is refresh what has already been draw to the screen. The ONLY time it should clear the screen is when I call InitBuffer(). How do I do this? Here's my code: # Mental Ray Thread class runMentalRayThread(threading.Thread): def __init__(self,sFile,renderWindow): threading.Thread.__init__(self) self.filename = sFile self.threadID = os.getpid() self.renderBuffer = renderWindow # poll the file using yet another thread. When that returns, # capture the mental ray stream and render to the canvas. def run(self): self.portInfo = queryMentalRay(self.filename) self.renderBuffer.InitBuffer() scanMR(self.portInfo[0], self.portInfo[1], self) # Render Window class RenderWindow(wx.Window): def __init__(self,parent,ID,pos,size): wx.Window.__init__(self,parent,ID,pos,size) self.renderThread = runMentalRayThread(filename,self) self.SetBackgroundColour("Grey") self.Bind(wx.EVT_IDLE, self.OnIdle) self.Bind(wx.EVT_CLOSE, self.OnClose) self.Bind(wx.EVT_PAINT, self.OnPaint) self.InitBuffer() # Our initial buffer must be set and background cleared. def InitBuffer(self): print 'InitBuffer() called...' self.ClearBackground() # Idle function. Wait for a render def OnIdle(self,event): if not self.renderThread.isAlive(): print 'Starting thread to poll Mental Ray...' self.renderThread = runMentalRayThread(filename,self) self.renderThread.start() # Refreshes the window. def OnPaint(self,event): print 'OnPaint() called...' dc = wx.PaintDC(self) # Closing the render window, we need to # kill the thread attached to Mental Ray. def OnClose(self,event): if self.renderThread.isAlive(): # kill the thread os.popen("kill -9 "+str(self.renderThread.threadID)) _________________________________________________________________ Spell a grand slam in this game where word skill meets World Series. Get in the game. http://club.live.com/word_slugger.aspx?icid=word_slugger_wlhm_admod_april08 -------------- next part -------------- An HTML attachment was scrubbed... URL: From reachmsn at hotmail.com Thu Apr 10 22:57:29 2008 From: reachmsn at hotmail.com (reachmsn at hotmail.com) Date: Thu, 10 Apr 2008 19:57:29 -0700 (PDT) Subject: Cannot understand the detailedly the following code References: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> <10a83944-b17a-4c3f-992b-1754c0a5e9b1@s33g2000pri.googlegroups.com> Message-ID: On Apr 9, 8:12?pm, "A.T.Hofkamp" wrote: > On 2008-04-09, reach... at hotmail.com wrote: > > > > > > > On Apr 8, 5:45?pm, "A.T.Hofkamp" wrote: > > Ok following these instructions one gets > > > def find_all_paths(graph, start, end, path=[]): > > ?path= path+ [start] > > > ?for node in graph[start]: > > > ? ?find_all_paths(graph, node, end, path) > > >> First define the input and output parameters/values of the function. > >> (ie what goes in, and what comes out) > > > Now what will be the output parameters - there is a Return statement. > > Input parameters are graph, vertexes start, node, end and path. Also > > how would you write the terminating and reduction cases after this. > > Actually i'm not clear how to proceed writing this recursive function. > > Thanks! > > Don't look at code, don't even think about it (it gives you too much confusing > details). > > Instead, have a beer, sit down in a sunny spot, and do mothing for a while. > > Think about the function as a (black) box. You don't know what is in it (it is > not important yet). That box is the function (many people prefer to draw a > rectangular shape on a sheet of paper, and consider that to be the function). > What data does the box need to do its work, and what does it produce after > it has done its work? > > (suppose you are given the task of 'finding all paths'. What information do you > need to acomplish this task, and what information do you write down as result?) > > A simple example of a multiplication task: One needs 2 numbers to do the task, > and the result is another number. Note that at this stage, you don't worry > about HOW you do the task, only WHAT GOES IN AND WHAT COMES OUT. > (actually, HOW depends on INPUT. Multiplication of 2 and 5 can be done > differently from multiplication of > 230698762085269459068388639078903870385790368703879038285790 and > 5938063786093895682682968390789380834687387689762897. For this reason, deciding > the strategy of solving the problem comes after establishing input and output). > > Sincerely, > Albert > PS email will give you shorter response times.- Hide quoted text - > > - Show quoted text - Hello, Thank you for the suggestion of relaxing! After that the black box function you mentioned looks like this- Output- path1 path 2 | ... path n | | | ---------------------- | | | | | function -find_ | | _all_paths() | | | ---------------------- | | | | Input - graph, start, end i.e. you give, the graph, the start and end vertices as inputs and you get the output as a listing of all the paths. This is where I got to. It would be very nice if you could kindly hint on how to proceed further. Thank you so much for your time! Thanks & Regards, Anshu From billingspanshism at gmail.com Sat Apr 19 17:17:49 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:17:49 -0700 (PDT) Subject: victoria beckham blonde Message-ID: Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From gagsl-py2 at yahoo.com.ar Tue Apr 1 05:04:29 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 06:04:29 -0300 Subject: Why prefer != over <> for Python 3.0? References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> <659gb2F2f84eoU2@mid.individual.net> <87hceo73ap.fsf@physik.rwth-aachen.de> <65anbqF2fg18bU1@mid.individual.net> <87r6drjss4.fsf@physik.rwth-aachen.de> <65c0bfF2ffipiU1@mid.individual.net> <32822fe60804010015m22a4e9bei5002431afe14921a@mail.gmail.com> Message-ID: En Tue, 01 Apr 2008 04:15:57 -0300, Jorge Vargas escribi?: > as for the original question, the point of going unicode is not to > make code unicode, but to make code's output unicode. thin of print > calls and templates and comments the world's complexity in languages. > sadly most english speaking people think unicode is irrelevant because > ASCII has everything, but their narrow world is what's wrong. Python 3 is a good step in that direction. Strings are unicode, identifiers are not restricted to ASCII, and the default source encoding is not ASCII anymore (but I don't remember which one). So this is now possible with 3.0: >>> a?o = 2008 >>> print("halag?e?o") halag?e?o >>> print("halag?e?o".encode("latin1")) b'halag\xfce\xf1o' -- Gabriel Genellina From version5 at gmail.com Wed Apr 2 09:52:08 2008 From: version5 at gmail.com (nnp) Date: Wed, 2 Apr 2008 14:52:08 +0100 Subject: Python queue madness Message-ID: <28749c0e0804020652o74a9491an9eef9ba1813434fb@mail.gmail.com> Hey guys, Basically I have a system where component 1, 2 and 3 communicate with each other using two Python Queues, we'll call them R and W. Here is what is happening 1 writes data to W and reads from R 2 reads data from W and writes data it receives from 3 to R (but not data it receives from 1) 3 writes to W The problem is that data being written by 1 to W is appearing back on R. I have verified that 1 never writes to R and that 2 never writes data it receives from 1 to R, by overwriting the put() and put_nowait() methods of R. Is there any other way for data to get onto a queue or are there any known bugs with Python's Queue module that could lead to this kind of behaviour? -nnp -- http://www.smashthestack.org http://www.unprotectedhex.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From johng at neutralize.com Tue Apr 8 06:41:26 2008 From: johng at neutralize.com (monk.e.boy) Date: Tue, 8 Apr 2008 03:41:26 -0700 (PDT) Subject: urlparse http://site.com/../../../page.html Message-ID: <9fdd0d8b-785a-4363-be6a-75f993527754@c65g2000hsa.googlegroups.com> Hi, Can anyone help me with the urlparse: >>> import urlparse >>> urlparse.urljoin( 'http://site.com/path/', '../../../../path/' ) 'http://site.com/../../../path/' >>> urlparse.urljoin( 'http://site.com/', '../../../../path/' ) 'http://site.com/../../../../path/' >>> urlparse.urljoin( 'http://site.com/', '/path/../path/.././path/./' ) 'http://site.com/path/../path/.././path/./' I'm sure these should all return: http://site.com/path/ I tested all these in firefox -- I built a page with these links as anchors and mouse_over them to see what Firefox thinks they should be. I also know that google parses these URLs into http://site.com/path/ because one of our website has the above links in as a test. Is this a bug in urlparse? I'm not sure. Can anyone help me write something that will create the url I want. Should I look at os.path to help? I would like it to work on both Win and Linux :-) thanks monk.e.boy From hotani at gmail.com Wed Apr 23 13:54:39 2008 From: hotani at gmail.com (hotani) Date: Wed, 23 Apr 2008 10:54:39 -0700 (PDT) Subject: python-ldap: searching without specifying an OU? References: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> <58546d42-bc80-4f9d-be90-e184c312e2d1@k37g2000hsf.googlegroups.com> <0ke3e5-ccc.ln1@nb2.stroeder.com> Message-ID: <8ef38281-a6fe-4501-b711-a24cd9f35a24@t54g2000hsg.googlegroups.com> It seems the only way I can bind is by using this format: simple_bind_s('user at server.local','password') If I try using a DN, it fails every time. This will not work: simple_bind_s('cn=user,dc=server,dc=local', 'password') Errors out with "invalid credentials": ldap.INVALID_CREDENTIALS: {'info': '80090308: LdapErr: DSID-0C090334, comment: AcceptSecurityContext error, data 525, vece', 'desc': 'Invalid credentials'} If I put the *wrong* credentials in the first format, it will fail - which seems to indicate the bind is working. With that 'successful' (?) bind, it is returning the bind error from my earlier post only when I leave out the OU when searching. From lbonafide at yahoo.com Wed Apr 2 08:08:40 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Wed, 2 Apr 2008 05:08:40 -0700 (PDT) Subject: Where can I find : References: <13uu56hn1vdqb9d@corp.supernews.com> <768026ee-b9f1-4445-bd02-088a2f725a9d@b64g2000hsa.googlegroups.com> Message-ID: On Mar 30, 1:22 am, castiro... at gmail.com wrote: > > That's weird. I feel like I could go on about an introductory program > for days and days, la. > > I usually start (both times) with interpreted vs. compiled. It's a > layer of abstraction. But it's very weird; the layers can't tell > either of each other apart. I can hand you the machine instructions, > the names of circuitry, that run Line 1 to Line 9 one time, but you > can't tell the difference between the code and the data. > > Some of it lingers in post-perceptive operations: the memory system, > for the record. Some lingers long times. So far it equates to > different Pythons produce different Pythons, however, though, so I'll > ask the spell checker. Python.get_back_in_skin(). Weird. > > I'm not sure if it makes any difference. The binary you run is > Python.exe. It's already running, then you feed it a raw string, not > on disk without loss of generality. The translation is a little hard > to find too. > > Python :: mingw-c++ : > Python.exe :: mingw-c++.exe : > what? :: machine instructions.exe > > In Python there's a for-loop that's the exact same as one in machine > instructions. > > 0101 b1= 1000 > 0110 if a < b0 goto b1 > 0111 b2= b2+ 1 > > accumulates a number in register b2. You probably want interface and > graphics primitives. Sometimes I feel like "with a scroll bar" > suffices to specify all the detail you need; there's too many > options. (I can do this and this and ... scroll bar, please.) You > know the episode of Star Trek NG where Barclay takes over the > Enterprise. > > I'd also like to be able to write (write) a series of instructions and > have it loop, and debug in vivo, as though a BASIC program were > running and I could edit lines in its doing so, maybe time Windows > Media visualization codecs in time. You could tell story lines and > have it refine, post-inspiration. > > You might be surprised how much repetition in instructions Lines 1 > through 9 (of -code-) share, in both sides of the analogy. Anyone > work with a VAX? What? From steve at holdenweb.com Tue Apr 8 22:35:33 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 22:35:33 -0400 Subject: import statement convention In-Reply-To: <87fxtvomc6.fsf@benfinney.id.au> References: <4078bcf4-e68f-45d4-93ce-335ec7a33c5a@v32g2000prd.googlegroups.com> <87fxtvomc6.fsf@benfinney.id.au> Message-ID: Ben Finney wrote: > MartinRinehart at gmail.com writes: > >> By convention, I've read, your module begins with its import >> statements. Is this always sensible? > > There are exceptions, but the benefits are great: It's very easy to > see what this module requires, without needing to execute it. > >> I put imports that are needed for testing in the test code at the >> end of the module. If only a bit of the module has a visual >> interface, why pollute the global namespace with 'from Tkinter >> import *'? Wouldn't that be better done in a separate class or >> function? > > If your test code requires the Tkinter module but the rest of the code > doesn't, why pollute the functional module with such test code? Move > it to a separate unit test module. > If your test code is the only part of the module that needs Tkinter I'd be perfectly happy seeing the import guarded by the if __name__ == "__main__" condition. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From sam at mas.pl Thu Apr 3 05:32:09 2008 From: sam at mas.pl (sam) Date: Thu, 03 Apr 2008 11:32:09 +0200 Subject: Prototype OO In-Reply-To: <47f49d4b$0$5665$426a74cc@news.free.fr> References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> <47f49d4b$0$5665$426a74cc@news.free.fr> Message-ID: Bruno Desthuilliers napisa?(a): > Ok, I'm going to be a bit harsh, but this time I'll assume it. > Sam, you started this thread by asking about prototype vs class based > minor syntactic points that, whether you like them or not (and I think I will get back to this discussion after learning "descriptor protocol" and maybe I will not talk about syntax then, and maybe it won't get off topic. As you can see I'm novice in Python, but I can show python-experts some newbie opinions. If somebody is an expert then he can't take a fresh look at his many years work. Anyway -- thank you for spending time and giving explanations. From fairwinds at eastlink.ca Mon Apr 7 11:26:36 2008 From: fairwinds at eastlink.ca (David Pratt) Date: Mon, 07 Apr 2008 12:26:36 -0300 Subject: Help replacing os.system call with subprocess call In-Reply-To: <47FA2B72.9050802@mattnordhoff.com> References: <47F9B1D1.4090701@eastlink.ca> <47F9C764.9070401@mattnordhoff.com> <47FA23E7.7040809@eastlink.ca> <47FA2B72.9050802@mattnordhoff.com> Message-ID: <47FA3D2C.2010504@eastlink.ca> Hi Matt. Many thanks. Sorry I had not seen your second post. I'll give this a try and time the completion to compare the differences and post back later today to show os.system, buffered imput and using a file directly for stdout. Regards, David Matt Nordhoff wrote: > David Pratt wrote: >> Hi David and Matt. I appreciate your help which has got me moving >> forward again so many thanks for your reply. I have been using >> subprocess.Popen a fair bit but this was the first time I had to use >> subprocess to capture large file output. The trouble I was having was >> with the process would just hang. Chunking was the solution. I guess I >> assumed this would be taken care of in the internals. >> >> Overall, I wish subprocess had some better documentation since it is >> definitely not a drop in replacement for os.system. In other >> circumstances I am using subprocess.call() for simple calls which works >> fine. >> >> The speed of this solution is slower than os.system. Would a queue of >> some kind be needed to speed this up? Has anyone implemented something >> like this? Many thanks. >> >> Regards, >> David > > Did you see my second message? That should help performance. If not, I'm > totally out of my depth and have no idea at all. Sorry. > > (How much slower? 10%? 200%?) From martin at v.loewis.de Mon Apr 21 01:17:24 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Mon, 21 Apr 2008 07:17:24 +0200 Subject: Compiling Python 2.5.2 on AIX 5.2 In-Reply-To: References: <0b73e8e5-c301-4823-ac94-42f757456cf1@x19g2000prg.googlegroups.com> <48059DA9.5080900@v.loewis.de> Message-ID: <480c2364$0$26788$9b622d9e@news.freenet.de> > Thus it would seem use cif here resulted in a segment violation. I'll > continue to research this issue and report back to the group as I know > more. Perhaps solving the issue with the 'c' and 'm' libraries > (whatever they might be) will make the core dump go away. However, > for tonight, I'll need to stop here. I recommend you disable compilation of ctypes (by removing the call to detect_ctypes from setup.py). It's fairly unlikely that you can manage to make ctypes work on your system. Regards, Martin From deets at nospam.web.de Thu Apr 10 06:23:56 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 10 Apr 2008 12:23:56 +0200 Subject: call python from c -> pass and return arrays/lists References: Message-ID: <66686oF2j0ddsU1@mid.uni-berlin.de> Pieter wrote: > Hi all, > > I'm trying to call a python function from c. I need to pass an > 2D-array to python and the python function returns a 2D-list back to > c. I googled arround and I found how to pass ints/strings/... back and > forth, but didn't find anything on passing arrays. > > For an int it's as simple as this: > > PyArg_Parse(ret,"i#", &my_long); > > But I hacve no idea how to parse python lists to a c-array? You return a list, parse that as object, and then work with the sequence-protocol on them. UNTESTED: PyArg_Parse(ret,"o", &the_list); if(PySequence_Check(the_list) { int size = PySequence_Size(the_list); int *result = malloc(sizof(int) * size); for(int i = 0; i < size; i++) { PyObject *item = PySequence_GetItem(the_list, i); if(PyInt_Check(item)) { result[i] = PyInt_AsLong(item); } else { return NULL; } } Diez From rbrito at ime.usp.br Mon Apr 28 16:51:55 2008 From: rbrito at ime.usp.br (=?ISO-8859-1?Q?Rog=E9rio_Brito?=) Date: Mon, 28 Apr 2008 17:51:55 -0300 Subject: Little novice program written in Python References: Message-ID: On 04/25/2008 01:30 AM, Steve Holden wrote: > Rog?rio Brito wrote: >> I'm just getting my feet wet on Python and, just for starters, I'm >> coding some elementary number theory algorithms (yes, I know that most >> of them are already implemented as modules, but this is an exercise in >> learning the language idioms). > Your Python is actually pretty good - if Raymond Hettinger pronounces it > OK then few would dare to disagree. Thank you. > As for your English, though, the word you sought was "Pythonic" (not > that you will ever find such a word in Webster's dictionary). To suggest > that your code is Pythonesque would mean you found it farcical or > ridiculous (like a Monty Python sketch), which it clearly is not. I didn't know about the pejorative meaning of Pythonesque. :-) Thanks for the comment on my English (which should be obvious that I'm not a native speaker). > PS: I think either my mailer or yours has mangled the indentation. I think that it was mine. Thanks, Rog?rio Brito. -- Rog?rio Brito : rbrito@{mackenzie,ime.usp}.br : GPG key 1024D/7C2CAEB8 http://www.ime.usp.br/~rbrito : http://meusite.mackenzie.com.br/rbrito Projects: algorithms.berlios.de : lame.sf.net : vrms.alioth.debian.org From bronger at physik.rwth-aachen.de Wed Apr 16 14:05:57 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 16 Apr 2008 20:05:57 +0200 Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <87abjty8sa.fsf@physik.rwth-aachen.de> Hall?chen! D'Arcy J.M. Cain writes: > On Wed, 16 Apr 2008 09:11:09 -0700 > "Daniel Fetchinson" wrote: > >> Full disclosure: I'm using google groups for both reading and >> writing. > > You are? Maybe, but not with this posting. It was sent through the mailing list. By the way, the "References:" header seems to get lost sometimes through the mailing list when reading it as a Usenet group, so that the discussion trees become a mess. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From rocco.rossi at gmail.com Mon Apr 7 10:30:06 2008 From: rocco.rossi at gmail.com (rocco.rossi at gmail.com) Date: Mon, 7 Apr 2008 07:30:06 -0700 (PDT) Subject: Orphaned child processes Message-ID: <51102b91-dedc-4ad6-a936-c29df47f30ab@r9g2000prd.googlegroups.com> I'm using the Python processing module. I've just run into a problem though. Actually, it's a more general problem that isn't specific to this module, but to the handling of Unix (Linux processes) in general. Suppose for instance that for some reason or another, after forking several child processes, the main process terminates or gets killed (or segfaults or whatever) and the child processes are orphaned. Is there any way to automatically arrange things so that they auto- terminate or, in other words, is there a way to make the child processes terminate when the parent terminates? Thank you. From grante at visi.com Fri Apr 25 20:38:56 2008 From: grante at visi.com (Grant Edwards) Date: Fri, 25 Apr 2008 19:38:56 -0500 Subject: Why is None <= 0 References: Message-ID: On 2008-04-25, D'Arcy J.M. Cain wrote: > On Fri, 25 Apr 2008 20:27:15 +0200 > Gregor Horvath wrote: >> >>> None <= 0 >> True >> >> Why? > > Why not? > >> Is there a logical reason? > > Everything in Python can compare to everything else. Not true. Python 2.4.4 (#1, Mar 20 2008, 09:20:52) [GCC 3.4.6 (Gentoo 3.4.6-r2, ssp-3.4.6-1.0, pie-8.7.10)] on linux2 >>> 3j < 7 Traceback (most recent call last): File "", line 1, in ? TypeError: no ordering relation is defined for complex numbers > It is up to the programmer to make sure that they are > comparing reasonable things. True. -- Grant Edwards grante Yow! BEEP-BEEP!! I'm a at '49 STUDEBAKER!! visi.com From gagsl-py2 at yahoo.com.ar Wed Apr 9 03:00:13 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 04:00:13 -0300 Subject: problem using import from PyRun_String References: <664bf2b80804081801u79ae9192h90c03c84c1ef35ce@mail.gmail.com> Message-ID: En Tue, 08 Apr 2008 22:01:18 -0300, Patrick Stinson escribi?: > I'm creating a module with PyModule_New(), and running a string buffer as > the module's text using PyRun_String and passing the module's __dict__ to > locals and globals. Why? Do you want to fake what import does? > I'm having a problem using the import statement from > within PyRun_String(). It complains about "__import__ not found", which > after a quick grep it looks like the exception is raised from > PyExc_EvalFrameEx() in ceval.c after f->f_builtins module doesn't contain > "__import__". > What __builtin__ module does that point to? a quick print of the __builtin__ holds all the builtin objects, what a surprise! :) http://docs.python.org/lib/module-builtin.html > Any help? What do you want to do actually? -- Gabriel Genellina From michael at stroeder.com Wed Apr 23 06:11:44 2008 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Wed, 23 Apr 2008 12:11:44 +0200 Subject: python-ldap: searching without specifying an OU? In-Reply-To: <58546d42-bc80-4f9d-be90-e184c312e2d1@k37g2000hsf.googlegroups.com> References: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> <58546d42-bc80-4f9d-be90-e184c312e2d1@k37g2000hsf.googlegroups.com> Message-ID: <0ke3e5-ccc.ln1@nb2.stroeder.com> hotani wrote: > Thanks for the response. The user I'm connecting as should have full > access but I'll double check tomorrow. > > This is the LDAP error that is returned when I leave out the OU: > > {'info': '00000000: LdapErr: DSID-0C090627, comment: In order to > perform this operation a successful bind must be completed on the > connection., data 0, vece', 'desc': 'Operations error'} This clearly indicates that the bind was not successful and you're trying anonymous search access here which is not allowed in default configuration of AD. I'm not sure whether you can allow anonymous access at ou-level. You could try to use trace_level=2 to check whether bind is really successful and which bind-DN and credentials are actually used. Ciao, Michael. From gherron at islandtraining.com Mon Apr 28 12:53:54 2008 From: gherron at islandtraining.com (Gary Herron) Date: Mon, 28 Apr 2008 09:53:54 -0700 Subject: Given a string - execute a function by the same name In-Reply-To: <1209400401.22706.1250293015@webmail.messagingengine.com> References: <1209400401.22706.1250293015@webmail.messagingengine.com> Message-ID: <48160122.8080907@islandtraining.com> python at bdurham.com wrote: > I'm parsing a simple file and given a line's keyword, would like to call > the equivalently named function. > > There are 3 ways I can think to do this (other than a long if/elif > construct): > > 1. eval() > > 2. Convert my functions to methods and use getattr( myClass, "method" ) > > 3. Place all my functions in dictionary and lookup the function to be > called > > Any suggestions on the "best" way to do this? > > Thank you, > Malcolm > -- > http://mail.python.org/mailman/listinfo/python-list > You are on the right track with (2), but you need not do any conversion. All objects that have attributes (and a function is an attribute) can be looked up with getattr. For instance, from a module (function getcwd from modules os): >>> import os >>> getattr(os,'getcwd') >>> getattr(os,'getcwd')() '/home/gherron' You can use getattr with objects, classes, modules, and probably more. Gary Herron From stanc at al.com.au Fri Apr 18 04:57:35 2008 From: stanc at al.com.au (Astan Chee) Date: Fri, 18 Apr 2008 18:57:35 +1000 Subject: testing client-server sockets Message-ID: <4808627F.5040906@al.com.au> Hi, I have a client-server socket script in python. Something like this http://ubuntuforums.org/showthread.php?t=208962 Now the problem I have is that I want to try to connect the client to the server on the same machine, but it gives me a 'port already in use' error. I just want the client to connect to the server for testing purposes. Any suggestions on how I should do this? Thanks Astan -- "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." Animal Logic http://www.animallogic.com Please think of the environment before printing this email. This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. From s0suk3 at gmail.com Tue Apr 22 12:32:36 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Tue, 22 Apr 2008 09:32:36 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: On Apr 22, 5:25?am, azrael wrote: > Hy guys, > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. > > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" > > This hurts. Please give me informations about realy famous > aplications. Those would be insulting statements, but only if he wouldn't be a Perl programmer. Everyone knows Perl's best days are long gone. Perl is not a competent language anymore. I bet your friend is a system administrator or something like that, because the only use for Perl is writing quick-and-dirty scripts, and that's something that sysadmins do the whole day. Anyway, seeing that nobody has posted on the "big applications" matter, here are some examples: Zope ( http://www.zope.org ), Medusa ( http://www.nightmare.com/medusa ), Grail ( http://grail.sourceforge.net ). On the "Python vs. Perl" matter, well, just search "Python Perl" on Google or some other search engine, you'll literally find nothing but pages talking about how Python is better than Perl. On the other hand, I do admit that there's no other language better than Perl to write a 3-10 line long program. In those cases, the Perl version will not only be smaller than the C version, but even smaller than the Python version. This is mostly due to Perls default variables and "magic" events (like reading a line of a file directly into $_ when you're doing while () {...}, or automatically converting between integer/string or scalar/list depending on the operators and context ). But a competent developer won't be writing such small scripts, unless, as I said, you're a sysadmin or something like that. Otherwise, there's no reason to use something as ugly and unconventional as Perl. From luismgz at gmail.com Thu Apr 3 11:34:24 2008 From: luismgz at gmail.com (=?ISO-8859-1?Q?Luis_M=2E_Gonz=E1lez?=) Date: Thu, 3 Apr 2008 08:34:24 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> <89bca327-6a3f-4128-be72-75d4a50b9bf0@13g2000hsb.googlegroups.com> <47f4e456$0$20141$426a74cc@news.free.fr> Message-ID: <366134d3-2e6b-4521-9197-c8236326cf30@e39g2000hsf.googlegroups.com> On 3 abr, 11:06, Bruno Desthuilliers wrote: > Luis M. Gonz?lez a ?crit : > > > I have come to the same conclusion. > > ORMs make easy things easier, but difficult things impossible... > > Not my experience with SQLAlchemy. Ok, I still not had an occasion to > test it against stored procedures, but when it comes to complex queries, > it did the trick so far - and (warning: front-end developper > considerations ahead) happened to be much more usable than raw strings > to dynamically *build* the queries. > > > The best approach I've seen so far is webpy's (if we are talking of > > web apps). > > It isn't an ORM, it is just a way to make the database api easier to > > use. > > Queries don't return objects, they return something similar to > > dictionaries, which can be used with dot notation ( for example, > > result.name is equal to result['name'] ). > > > A simple select query would be db.select('customers') or > > db.select('customers', name='John'). > > But you can also resort to plain sql as follows: db.query('select * > > from customers where name = "John"'). > > > Simple, effective and doesn't get in your way. > > Seems nice too in another way. Is that part independant of the rest of > the framework ? If so, I'll have to give it a try at least for admin > scripts. Yes, webpy's db api can be used in stand-alone scripts if you want. See below: import web db = web.database(dbn='mysql', db='northwind', user='root') x = db.select('employees') for i in x: print i.FirstName, i.LastName ... Another good thing is that, since queries return Storage objects (similar to dictionaries), they are much more flexible. Suppose that you get the results of a form sent via a POST method, and you want to insert this data into your database. You would simple write: i = web.input() db.insert('orders', **i) So everything related to CRUD operations are is easy to do, without having to mess with objects. I think this sticks strictly to the KISS principle, keeping it simple, with less overhead, less layers of abstraction and therefore, less bugs and complications. And it matchs perfectly webpy's philosofy for creating web apps. Luis From hobgoodoreneyhb at gmail.com Tue Apr 22 11:40:59 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:40:59 -0700 (PDT) Subject: photodraw crack Message-ID: photodraw crack http://cracks.12w.net F R E E C R A C K S From lists at cheimes.de Sat Apr 12 11:13:51 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 12 Apr 2008 17:13:51 +0200 Subject: str(bytes) in Python 3.0 In-Reply-To: <87k5j3f7m8.fsf@pobox.com> References: <87k5j3f7m8.fsf@pobox.com> Message-ID: <4800D1AF.9020808@cheimes.de> John J. Lee schrieb: > Why hasn't the one-argument str(bytes_obj) been designed to raise an > exception in Python 3? See for yourself: $ ./python Python 3.0a4+ (py3k:0, Apr 11 2008, 15:31:31) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> str(b'') "b''" [38544 refs] >>> bytes("") Traceback (most recent call last): File "", line 1, in TypeError: string argument without an encoding [38585 refs] $ ./python -b Python 3.0a4+ (py3k:0, Apr 11 2008, 15:31:31) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> str(b'') __main__:1: BytesWarning: str() on a bytes instance "b''" [38649 refs] Christian From mfb.chikazuku at gmail.com Sun Apr 13 18:39:58 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Mon, 14 Apr 2008 00:39:58 +0200 Subject: urllib2 Basic authentication, what am I doing wrong? References: <48025b26$0$6839$2d805a3e@textnews.eweka.nl> <1b67f420-db80-4890-8370-6476063cfadf@f63g2000hsf.googlegroups.com> Message-ID: <48029a0f$0$6838$2d805a3e@textnews.eweka.nl> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Max Erickson wrote: > On Apr 13, 2:11?pm, Michel Bouwmans wrote: > >> Using this nice class (adapted to urllib2) as a basehandler I see that no >> Authentication-header is being send >> out:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440574 >> >> What am I doing wrong here? I spend almost my entire free time today on >> this and couldn't find any problem with my code, anyone else has a >> thought? Thanks in advance. >> >> MFB > > I've attempted to use a password manager and auth manager and failed > in the past, so this is only a guess, but presumably, between the > realm and uri that you are providing to the password manager, it isn't > providing a password for the page you want to load. I've had success > just explicitly setting the authorization header, using the method > discussed in the comments on this page: > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/267197 > > > max Thanks for that tip. I tried that and found out that I was still being rejected eventhough the correct Authorization was being send. I then experimented a bit with liveHTTPheaders and it's replay function in firefox and found out that it needed the cookie to succesfully authenticate. I'll try to fix it with that knowledge. Strange software I'm dealing with here, that's for sure. MFB -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFIAovCDpaqHmOKFdQRAuHXAJ9vGNdR2e8s8iA0Z5zIzxASjES3LgCfbVSU 339iu5iO1rv1Ufh0xNntNeY= =2xbX -----END PGP SIGNATURE----- From arnodel at googlemail.com Tue Apr 29 17:46:13 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Tue, 29 Apr 2008 22:46:13 +0100 Subject: string translate, replace, find and the forward slash References: <1030ffc2-1bbe-4539-881d-35bf59cacd11@34g2000hsh.googlegroups.com> Message-ID: destroooooy writes: > On Apr 29, 4:50 pm, Arnaud Delobelle wrote: >> >> marigold:junk arno$ python >> Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) >> [GCC 4.0.1 (Apple Inc. build 5465)] on darwin >> Type "help", "copyright", "credits" or "license" for more information. >> >> >>> unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n" >> >>> table = range(256) >> >>> for c in unsafe_chars: table[ord(c)] = ord('_') >> ... >> >>> table = ''.join(chr(o) for o in table) >> >>> 'Jon(&Mark/Steve)'.translate(table) >> 'Jon__Mark_Steve_' >> >> -- >> Arnaud > > > Okay, so that definitely works. Thanks! > > However, the chances of me coming up with that on my own were > completely nonexistent, and I'd still like to know how one would use > maketranstable() to get the same result... Do you mean maketrans() from the string module? I didn't know about it, but I've tried it and it works too: >>> import string >>> unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n" >>> alt_chars = "_________________________" >>> table = string.maketrans(unsafe_chars, alt_chars) >>> "a/b/c".translate(table) 'a_b_c' >>> -- Arnaud From ron.longo at cox.net Sun Apr 13 18:28:27 2008 From: ron.longo at cox.net (Ron Provost) Date: Sun, 13 Apr 2008 18:28:27 -0400 Subject: A "Fixed" Tk Text widget Message-ID: <001d01c89db5$b245cf20$6501a8c0@aristotle> I have just completed and uploaded to the Tkinter wiki a "Fixed" version of the Tk Text widget called EnhancedText. This new widget (subclassed from Text) is intended to fix some of the quirks of the Text widget involving cursor movement. Namely, in Text, the cursor moves by paragraph rather than display-line when using the Up and Down arrow keys and it jumps to the beginning and end of a paragraph when using the 'Home' and 'End' keys. EnhancedText rewrites all the event handling of the Text widget. With EnhancedText, Up, Down, Home and End now move according to display lines rather than Paragraphs. This widget can be found here http://tkinter.unpythonic.net/wiki/EnhancedText. Thanks for any comments, bug reports, etc. Ron Longo -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob at passcal.nmt.edu Sat Apr 19 17:50:05 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Sat, 19 Apr 2008 15:50:05 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041816413450073-bob@passcalnmtedu> Message-ID: <2008041915500575249-bob@passcalnmtedu> On 2008-04-18 21:33:34 -0600, Grant Edwards said: > On 2008-04-18, Bob Greschke wrote: > >> I'm on a Solaris 8 with Python 2.3.4 and when crunching >> through, literally, millions and millions of samples of >> seismic data fingers point out the difference nicely. :) I'll >> look into this more on some of our bigger better faster >> machines (there is no -m option for timeit on the Sun :). The >> Sun is just what I develop on. If stuff runs fast enough to >> keep me awake on there over an ssh'ed X11 connection it should run even >> better on the real field equipment (Macs, >> Linuxes, WinXPs). > > If time is an issue, I might write a C program to convert the > files from 24-bit numbers to 32-bit numbers. Then you can use > numpy to load huge arrays of them in a single whack. Yes you could. :) But this is all in real time (as in 'gotta have it right now' real time). Plus we're dealing with 100's of files (instruments) at a time. It'll be 1000's of instruments this summer up in Canada. Here's the program having happily crunched away at nearly twice the speed it was the day before yesterday. www.greschke.com/unlinked/files/pocus.png The white dots come from the 3-byte integers and make up the green line which makes up one 'logical' chunk (in this case they recorded for 60mins at a time) of a whole data file with one file per instrument. Generally we just take a quick look at the green lines to make sure the instruments were working, and pull out the bad ones so they don't get used again until they've been looked at. Zooming in to the level where you can see the individual samples is used to (more) accurately determine the time when an [intentional] explosion was set off. You use instruments placed near the shot holes for that. Simple. :) Bob From skanemupp at yahoo.se Fri Apr 18 12:20:26 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 18 Apr 2008 09:20:26 -0700 (PDT) Subject: Tkinter, getting canvas-object, how? Message-ID: <4d5c6911-7728-4dad-8d8d-7a862bf78d70@k13g2000hse.googlegroups.com> so i load a gif onto a canvas and when i click the canvs i want to get the color of the pixel that is clicked. so i need to ge the object im clicking. i was told in another thread to use find_withtag or find_closest but it is not working, maybe im using the method on the wrong object. how do i do this? and how do i then get specifics about that object, ie the pixel-color? Exception in Tkinter callback Traceback (most recent call last): File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ return self.func(*args) File "C:\Users\saftarn\Desktop\pythonkod\mapexperiments \mapgetobject.py", line 17, in callback undermouse=find_closest(master.CURRENT) NameError: global name 'find_closest' is not defined from Tkinter import * master = Tk() w = Canvas(master, width=400, height=625) w.pack(expand = YES, fill = BOTH) mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\Maps\provinces-of- sweden.gif') w.create_image(30, 30, image = mapq, anchor = NW) def key(event): print "pressed", repr(event.char) def callback(event): clobj=event.widget ## undermouse=find_withtag(master.CURRENT) undermouse=find_closest(master.CURRENT) print repr(undermouse) w.bind("", key) w.bind("", callback) w.pack() mainloop() From sbergman27 at gmail.com Thu Apr 17 18:33:49 2008 From: sbergman27 at gmail.com (Steve Bergman) Date: Thu, 17 Apr 2008 15:33:49 -0700 (PDT) Subject: How to make this unpickling/sorting demo faster? References: <40a5d8f1-a246-4c48-8759-5b65324f9029@m73g2000hsh.googlegroups.com> <7xod88w5l5.fsf@ruckus.brouhaha.com> Message-ID: <672d4491-35b5-4eb5-94bc-13d4b23ba797@d45g2000hsc.googlegroups.com> Thanks for the help. Yes, I see now that gdbm is really superfluous. Not having used pickel before, I started from the example in "Python in a Nutshell" which uses anydbm. Using a regular file saves some time. By far, the biggest improvement has come from using marshall rather than cPickel. Especially for writing. gc.disable() shaved off another 20%. I can't use psyco because I'm on x86_64. And my goal is to demonstrate how Python can combine simplicity, readability, *and* speed when the standard library is leveraged properly. So, in this case, calling C or assembler code would defeat the purpose, as would partitioning into smaller arrays. And my processor is single core. I started at about 7 seconds to just read in and sort, and at 20 seconds to read, sort, and write. I can now read in, sort, and write back out in almost exactly 5 seconds, thanks to marshal and your suggestions. I'll look into struct and ctypes. Although I know *of* them, I'm not very familiar *with* them. Thank you, again, for your help. From kyosohma at gmail.com Tue Apr 22 23:25:14 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 22 Apr 2008 22:25:14 -0500 Subject: list manipulation In-Reply-To: <480e62b4$1@news.mel.dft.com.au> References: <78158460-8508-4453-a2dc-c5814dda8839@59g2000hsb.googlegroups.com> <480e62b4$1@news.mel.dft.com.au> Message-ID: <480EAC1A.1010505@gmail.com> John Machin wrote: > Mike Driscoll wrote: > >> Well you could always do something like this: >> >> output = ';'.join(roadList) >> >> Which will put single quotes on the ends. > > No, it doesn't. You are conflating foo and repr(foo). > > I suppose if you want to be >> silly, you could do this: >> >> output = '"%s"' % ';'.join(roadList) > > *IF* your first effort were to put single quotes on the ends > ('the-text') then your second effort would certainly produce something > silly ... either '"the-text"' or "'the-text'" depending on which of > the assignment or the join method you imagined was producing the > single quotes. > -- > http://mail.python.org/mailman/listinfo/python-list Well, in IDLE's output, it looked like what the OP wanted and the OP seemed to find my examples helpful. Besides, you did almost the exact same thing in your final example. Mike From jewelry087 at jewelry-wholesaler.net Thu Apr 3 00:28:53 2008 From: jewelry087 at jewelry-wholesaler.net (jewelry087 at jewelry-wholesaler.net) Date: Wed, 2 Apr 2008 21:28:53 -0700 (PDT) Subject: Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 Message-ID: <0a735ceb-adcc-4eac-80c3-e8a51bcdc6c5@q27g2000prf.googlegroups.com> Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 Link : http://www.aaa-replica-watch.com/Chopard_27_8361_23.html Buy the cheapest Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 in toppest Replica . www.aaa-replica-watch.com helps you to save money! Chopard-27-8361-23 , Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 , Replia , Cheap , Fake , imitation , Chopard Watches Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 Information : Brand : Chopard Watches (http://www.aaa-replica-watch.com/ Replica_Chopard.html ) Gender : Ladies Model : Chopard-27-8361-23 Case Material : Stainless Steel Case Diameter : 27/8361-23 Dial Color : White Bezel : 104 Diamonds Movement : Quartz Clasp : Black Leather Water Resistant : 30m/100ft Crystal : Scratch Resistant Sapphire Our Price : $ 225.00 Stainless steel case. Black leather strap. White dial with 7 floating diamonds. Bezel set with 104 diamonds. Date displays at 6 o'clock position. Sapphire cabochon crown. 4 sapphire cabochon lugs. Quartz movement. Water resistant at 30 meters (100 feet). Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 Replica, With the mix of finest craftsmanship and contemporary styling, not only does it reflect the time but also care you put into looking good. choose one to promote your quality and make yourself impressive among people .Lowest Price Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 Thank you for choosing www.aaa-replica-watch.com as your reliable dealer of quality waches including Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 . we guarantee every watch you receive will be exact watch you ordered. Each watch sold enjoy one year Warranty for free repair. Every order from aaa-replica-watches is shipped via EMS, the customer is responsible for the shipping fee on the first order, but since the second watch you buy from our site, the shipping cost is free. Please note that If the total amount of payment is over $600(USD), the customer is required to contact our customer service before sending the money in case failed payment. If you have any other questions please check our other pages or feel free to email us by service at aaa-replica-watch.com. Cheapest Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 The Same Chopard Watches Series : Chopard Happy Sport Diamond 18kt Yellow Gold And Steel Ladies Watch 27/8251-23/11 : http://www.aaa-replica-watch.com/Chopard_27_8251_23_11.html Chopard Happy Sport Diamond 18kt Yellow Gold And Steel Ladies Watch 27/8249-23 : http://www.aaa-replica-watch.com/Chopard_27_8249_23_WH.html Chopard Happy Sport Diamond 18kt Yellow Gold And Steel Blue Ladies Watch 27/8249-23 : http://www.aaa-replica-watch.com/Chopard_27_8249_23_BU.html Chopard Happy Sport Black/White Diamond 18kt White Gold Mens Watch 28/3340-50 : http://www.aaa-replica-watch.com/Chopard_28_3340_50.html Chopard Happy Sport Diamond Steel Pink Ladies Watch 27/8245-21 : http://www.aaa-replica-watch.com/Chopard_27_8245_21.html Chopard Happy Sport Diamond Moon/Stars Steel Ladies Watch 27/8250-21 : http://www.aaa-replica-watch.com/Chopard_27_8250_21.html Chopard Happy Sport Diamond Steel Ladies Mini Watch 27/8294-23 2R : http://www.aaa-replica-watch.com/Chopard_27_8294_23.html Chopard Happy Beach Diamond Fish Steel Blue Mini Ladies Watch 27/8923 : http://www.aaa-replica-watch.com/Chopard_278923_DKBLUE.html Chopard Happy Beach Jeweled Fish Black Rubber Unisex Watch 27/8921-402 : http://www.aaa-replica-watch.com/Chopard_278921_402_BK.html Chopard Happy Beach Diamond Fish Steel Blue Mini Ladies Watch 27/8923 : http://www.aaa-replica-watch.com/Chopard_27_8923.html Chopard Happy Beach Diamond Fish Steel Black Unisex Watch 28/8347-8 : http://www.aaa-replica-watch.com/Chopard_28_8347_8.html Chopard Happy Beach Diamond Fish Steel Blue Ladies Watch 27/8925 : http://www.aaa-replica-watch.com/Chopard_27_8925.html cheap ,lowest price , AAA Best Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 From kyosohma at gmail.com Tue Apr 15 15:27:36 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 15 Apr 2008 12:27:36 -0700 (PDT) Subject: Recurring patterns: Am I missing it, or can we get these added to the language? References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: On Apr 15, 1:51 pm, Erich wrote: > Hello all, > > Today I found myself once again defining two functions that I use all > the time: nsplit and iterable. These little helper functions of mine > get used all the time when I work. Im sick of having to define them > (but am very good at it these days, less than 1 typo per function!). > It leads me to the following questions > > 1. Is this functionality already built in and im just missing it > 2. Is there some well known, good technique for these that I missed? > 3. Insert question I need to ask here (with a response) > > These are the funtions w/ explaination: > > def nsplit(s,p,n): > n -= 1 > l = s.split(p, n) > if len(l) < n: > l.extend([''] * (n - len(l))) > return l > The split() method has a maxsplit parameter that I think does the same thing. For example: >>> temp = 'foo,bar,baz' >>> temp.split(',', 1) ['foo', 'bar,baz'] See the docs for more info: http://docs.python.org/lib/string-methods.html > This is like split() but returns a list of exactly lenght n. This is > very useful when using unpacking, e.g.: > x, y = nsplit('foo,bar,baz', ',', 2) > > def iterable(item, count_str=False): > if not count_str and isinstance(item, str): > return False > try: > iter(item) > except: > return False > return True > This is just simple boolean test for whether or not an object is > iterable. I would like to see this in builtins, to mirror callable. > The optional count_str adds flexibility for string handling, since > sometimes I need to iterate over a string, but usually not. I > frequently use it to simplify my case handling in this type of > costruct: > > def foo(bar): > bar = bar if iterable(bar) else [bar] > for x in bar: > .... > > Thanks for feeback, > Erich Not sure about the other one, but you might look at itertools. Mike From john106henry at hotmail.com Sat Apr 26 02:18:24 2008 From: john106henry at hotmail.com (John Henry) Date: Fri, 25 Apr 2008 23:18:24 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. Message-ID: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> For serveral years, I have been looking for a way to migrate away from desktop GUI/client-server programming onto the browser based network computing model of programming. Unfortunately, up until recently, browser based programs are very limited - due to the limitation of HTML itself. Eventhough PythonCard hasn't keep up with the latest widgets in wxpython, the programs so created still works a lot better - until now. If you look at programs at some of the major sites these days - like Google calendar, Netflix, blockbuster, and so forth - you would undoubtedly notice that the quality of the programs are pretty much at par with the desktop programs we use everyday. Since the curious mind wanted to know how these programs are done, I started investigating and found out that what a difference a few years have made to Javascript - the once much hated beast of the Internet age - and during my search for perfection, I found Qooxdoo (http:// qooxdoo.org/). Qooxdoo is a Javascript toolkit that sits on top of Ajax. Take a look at some of the *impressive* widgets at http://demo.qooxdoo.org/current/showcase/#Form. So, what's that got to do with Pythoncard? Read on. After trying for a few days learning Qooxdoo, my head really really hurts. Getting too old to learn this stuff, I was mumbling. Then I looked some more. I found QxTransformer (http:// sites.google.com/a/qxtransformer.org/qxtransformer/Home) which is a XSLT toolkit that creats XML code that invoke qooxdoo. So, what's that got to do with Pythoncard? Read on. After trying for a few days learning QxTransformer, my head really really hurts. Getting too old to learn this stuff, I was mumbling. I want Pythoncard. Damn Pythoncard! Once you got hooked, everything else looks impossibly complicated and unproductive. But then I looked closer. It turns out the XML file created by QxTransformer is *very* similar in structure when compared to the resource files used in PythonCard. Since there are no GUI builders for QxTransformer, and I can't affort to buy the one for Qooxdoo (Java! Yuk!), I decided to roll up my sleeves, took the Pythoncard's Layout Manager and modified it and created my own "Poor Man's Qooxdoo GUI Layout Designer". The result? See the partially completed application at: http://test.powersystemadvisors.com/ and the same application running from the desktop: http://test.powersystemadvisors.com/desktopHelloWorld.jpg It shouldn't be long before I can fill in the gaps and have the GUI builder maps the rest of the Pythoncard widgets to Qooxdoo widgets. Once I've done that, I can have the same application running from the desktop, or from the browser. And it shouldn't take more than minutes to create such applications. Welcome to the modernized world of Pythoncard!!! From nemesis at nowhere.invalid Mon Apr 21 15:14:56 2008 From: nemesis at nowhere.invalid (Nemesis) Date: 21 Apr 2008 19:14:56 GMT Subject: Does Python 2.5.2's embedded SQLite support full text searching? References: Message-ID: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> Ed Leafe wrote: >> Sqlite itself is not distributed with python. Only a python db api >> compliant wrapper is part of the python stdlib and as such it is >> completely independent of the sqlite build. > > Don't most binary distributions include SQLite itself? I installed > 2.5.2 on a new WinXP VM, and SQLite is working fine. So did I. I installed py2.5.2 on windows and didn't install SQLite, and I'm using the module sqlitedb without problems. -- Let us make a special effort to stop communicating with each other, so we can have some conversation. _ _ _ | \| |___ _ __ ___ __(_)___ | .` / -_) ' \/ -_|_-< (_-< |_|\_\___|_|_|_\___/__/_/__/ http://xpn.altervista.org From gagsl-py2 at yahoo.com.ar Fri Apr 25 00:07:56 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 25 Apr 2008 01:07:56 -0300 Subject: How to get inner exception traceback References: <67b8nuF2m1a1kU1@mid.individual.net> Message-ID: En Thu, 24 Apr 2008 08:20:29 -0300, Thomas Guettler escribi?: > How can you get the traceback of the inner exception? > > try: > try: > import does_not_exit > except ImportError: > raise Exception("something wrong") > except: > ... > > > Background: In Django some exceptions are caught and a new > exception gets raised. Unfortunately the real error is hard > to find. Sometimes I help myself and change (in this example) > ImportError to e.g. IOError and then I can see the real root > of the problem. But maybe there is a way to get the inner > exception and its traceback. This could be displayed in the > debug view. You already got a couple ways to do it - but I'd ask why do you want to mask the original exception? If you don't have anything valuable to do with it, just don't catch it. Or raise the *same* exception+context, perhaps after modifying it a bit: try: try: import does_not_exist except ImportError, e: e.args = ("Something is wrong with the plugin system\nDetails: %s" % e.args,) raise # <-- note the "bare" raise except: import traceback print "An error has occurred" print sys.exc_info()[1] print sys.exc_info()[0].__name__ traceback.print_tb(sys.exc_info()[2]) # or whatever you want to do with the exception -- Gabriel Genellina From dblubaugh at belcan.com Thu Apr 24 12:28:29 2008 From: dblubaugh at belcan.com (Blubaugh, David A.) Date: Thu, 24 Apr 2008 12:28:29 -0400 Subject: MESSAGE RESPONSE References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com><27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com><678v5qF2me5rvU1@mid.uni-berlin.de> <5504f9ac0804230927ncfdb91buf7fa3e181f8a9237@mail.gmail.com> Message-ID: <27CC3060AF71DA40A5DC85F7D5B70F3801185540@AWMAIL04.belcan.com> Dear Sir, Belcan has an absolute zero-tolerance policy toward material such as the material described. Thank you for your Concern, David Blubaugh ________________________________ From: Dan Upton [mailto:upton at virginia.edu] Sent: Wed 4/23/2008 12:27 PM To: python-list at python.org Subject: Re: MESSAGE RESPONSE On Wed, Apr 23, 2008 at 10:24 AM, Diez B. Roggisch wrote: > Blubaugh, David A. schrieb: > > > Is there a way to block these messages. I do not want to be caught > > with filth such as this material. I could lose my job with Belcan with > > evil messages such as these messages. > > > > If I (or *anybody*) knew how to block these messages, he or she would sell > the resulting spam-filter for a fortunen that roughly amasses the one of > scrooge mc duck - and go live on the bahamas or even buy them. > > Put up with it. It's (unfortunately) part of ze internet tubes. > And as such, I find it hard to believe you could lose your job over it. This e-mail transmission contains information that is confidential and may be privileged. It is intended only for the addressee(s) named above. If you receive this e-mail in error, please do not read, copy or disseminate it in any manner. If you are not the intended recipient, any disclosure, copying, distribution or use of the contents of this information is prohibited. Please reply to the message immediately by informing the sender that the message was misdirected. After replying, please erase it from your computer system. Your assistance in correcting this error is appreciated. From mdboldin at gmail.com Wed Apr 23 11:15:12 2008 From: mdboldin at gmail.com (mmm) Date: Wed, 23 Apr 2008 08:15:12 -0700 (PDT) Subject: DTD validation and xmlproc Message-ID: I found Python code to validate a XML document basd on DTD file layout. The code uses the 'xmlproc' package and these module loading steps from xml.parsers.xmlproc import xmlproc from xml.parsers.xmlproc import xmlval from xml.parsers.xmlproc import xmldtd Unfortunately, the xml package no longer seems to hold the xmlproc module. As a standalone the xmlproc module seems to be no longer maintained and was subsumed in PyXML a few years ago and that package is no longer maintained (as best I can tell, or maybe was subsumed in the base Python 2.x packages) My problem is I can not get the old xmlproc package files that i did find to work with Python 2.5. I am willing to learn and use new xml procedures, but I found nothng pre-written to validate agaisnt a given DTD file. Any advice would be welcome, even a good tutorial on XML validation usiog Python. From gagsl-py2 at yahoo.com.ar Sun Apr 20 04:12:24 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 05:12:24 -0300 Subject: Request a short code review References: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> <33a50f5b-f82d-41aa-b28f-b00dba4bf2eb@m73g2000hsh.googlegroups.com> Message-ID: En Fri, 18 Apr 2008 15:10:09 -0300, escribi?: > lessons = self.lesson_data["lessons"] > if lesson_type: > lessons = [x for x in lessons if x["type"] == lesson_type] > > Changes: > - generator expression instead of filter The above is not a generator expression, it's a list comprehension. They look similar. This is a list comprehension: py> a = [x for x in range(10) if x % 2 == 0] py> a [0, 2, 4, 6, 8] Note that it uses [] and returns a list. This is a generator expression: py> g = (x for x in range(10) if x % 2 == 0) py> g py> g.next() 0 py> g.next() 2 py> for item in g: ... print item ... 4 6 8 Note that it uses () and returns a generator object. The generator is a block of code that runs lazily, only when the next item is requested. A list is limited by the available memory, a generator may yield infinite items. > Cheers again. This is very valuable for me. I am a true believer > that if one takes care in the smallest of methods then the larger code- > base will be all the better. Sure. -- Gabriel Genellina From danb_83 at yahoo.com Sun Apr 27 18:41:37 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Sun, 27 Apr 2008 15:41:37 -0700 (PDT) Subject: A small and very basic python question References: Message-ID: <13361dd1-5269-4afd-b2ca-972d32f09bf9@w1g2000prd.googlegroups.com> On Apr 27, 5:26 pm, Dennis wrote: > Dennis wrote: > > Could anyone tell me how this line of code is working: > > > filter(lambda x: x in string.letters, text) > > > I understand that it's filtering the contents of the variable text and I > > know that lambda is a kind of embedded function. > > > What I'd like to know is how it would be written if it was a normal > > function. > > I didn't give up after posting and managed to grasp this whole lambda > thing! No need to respond now :-) I understood it the moment I tried to > type out, instead of just thinking in my head, what was going on as a > normal function. I will respond anyway, just to say that you COULD have written: ''.join(char for char in text if char.isalpha()) thus avoiding lambda altogether. From ellingt8877 at gmail.com Mon Apr 28 01:51:43 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:51:43 -0700 (PDT) Subject: fostex ds-8 digital patch bay Message-ID: <2b421ec5-c9d3-4d6b-a9e4-f74405e0d5a3@k1g2000prb.googlegroups.com> fostex ds-8 digital patch bay http://crack.cracksofts.com From bruno.desthuilliers at gmail.com Sun Apr 6 11:35:09 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Sun, 6 Apr 2008 08:35:09 -0700 (PDT) Subject: Presumably an import is no faster or slower than opening a file? References: <47f8d30f$0$761$bed64819@news.gradwell.net> Message-ID: <546467f9-807c-475b-a2ae-9e8faae03825@u3g2000hsc.googlegroups.com> On 6 avr, 15:41, tinn... at isbd.co.uk wrote: > I'm trying to minimise the overheads of a small Python utility, I'm > not really too fussed about how fast it is but I would like to > minimise its loading effect on the system as it could be called lots > of times (and, no, I don't think there's an easy way of keeping it > running and using the same copy repeatedly). > > It needs a configuration file of some sort which I want to keep > separate from the code, is there thus anything to choose between a > configuration file that I read after:- > > f = open("configFile", 'r') > > ... and importing a configuration written as python dictionaries or > whatever:- > > import myConfig In both cases, you'll have to open a file. In the first case, you'll have to parse it each time the script is executed. In the second case, the first import will take care of compiling the python source to byte- code and save it in a myConfig.pyc file. As long as the myConfig.py does not change, subsequent import will directly use the .pyc, so you'll save on the parsing/compiling time. FWIW, you can even "manually" compile the myConfig.py file, after each modification, and only keep the myConfig.pyc in your python path, so you'll never get the small overhead of the "search .py / search .pyc / compare modification time / compile / save" cycle. While we're at it, if you worry about the "overhead" of loading the conf file, you'd better make sure that either you force the script compilation and keep the .py out of the path, or at least keep the script.py file as lightweight as possible (ie : "import somelib; somelib.main()", where all the real code is in somelib.py), since by default, only imported modules get their bytecode saved to .pyc file. Now I may be wrong but I seriously doubt it'll make a huge difference anyway, and if so, you'd really preferer to have a long running process to avoid the real overhead of launching a Python interpreter. My 2 cents... > -- > Chris Green From jeffober at gmail.com Thu Apr 3 08:03:10 2008 From: jeffober at gmail.com (Jeff) Date: Thu, 3 Apr 2008 05:03:10 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> Message-ID: def foo(sample, strings): for s in strings: if sample in s: return True return False This was an order of magnitude faster for me than using str.find or str.index. That was finding rare words in the entire word-list (w/ duplicates) of War and Peace. From nullgraph at gmail.com Wed Apr 16 17:26:09 2008 From: nullgraph at gmail.com (nullgraph at gmail.com) Date: Wed, 16 Apr 2008 14:26:09 -0700 (PDT) Subject: vary number of loops References: <480604BE.3090002@tim.thechases.com> Message-ID: On Apr 16, 10:12 am, "Reedick, Andrew" wrote: > > -----Original Message----- > > From: python-list-bounces+jr9445=att.... at python.org [mailto:python- > > list-bounces+jr9445=att.... at python.org] On Behalf Of Tim Chase > > Sent: Wednesday, April 16, 2008 9:53 AM > > To: nullgr... at gmail.com > > Cc: python-l... at python.org > > Subject: Re: vary number of loops > > > > If n=3, I want to have 3 sets of elements and mix them up using 3 > for > > > loops. > > > You might be ineterested in this thread: > > >http://mail.python.org/pipermail/python-list/2008-January/473650.html > > > where various solutions were proposed and their various merits > > evaluated. > > I second that. The thread compared building loops on the fly, building > comprehensions nested to arbitrarily levels, recursion (sloooow!), a > slick cookbook recipe using iterators, etc. and provided timings for > each method. Definitely worth bookmarking. > Yes, I second that second :) Very nice thread, I'm leaning toward the "pythonic method" from there, but thanks for all the other solutions suggested here. Guess I need to go play with lambda more... nullgraph From nyamatongwe+thunder at gmail.com Mon Apr 14 17:35:07 2008 From: nyamatongwe+thunder at gmail.com (Neil Hodgson) Date: Mon, 14 Apr 2008 21:35:07 GMT Subject: Confused about Boost.Python & bjam In-Reply-To: References: Message-ID: Till Kranz: > I tried to get started with Boost.Python. unfortunately I never used the > bjam build system before. As it is explained in the documentation I > tried to adapt the the files form the examples directory. I copied > 'Jamroot', 'boost_build.jam' and 'extending.cpp' to '~/test/'. But I am > lost as to what to do now. Yes, Boost.Python is difficult to use and the documentation isn't that clear. I've pretty much given up for now but I do have a project called SinkWorld that works with Boost.Python. You can access the CVS at http://scintilla.cvs.sourceforge.net/scintilla/sinkworld/ and the jam config files are in the tentacle/python directory as http://scintilla.cvs.sourceforge.net/scintilla/sinkworld/tentacle/python/Jamfile?revision=1.6&view=markup http://scintilla.cvs.sourceforge.net/scintilla/sinkworld/tentacle/python/boost-build.jam?revision=1.2&view=markup http://scintilla.cvs.sourceforge.net/scintilla/sinkworld/tentacle/python/Jamrules?revision=1.2&view=markup There is a mailing list which may be able to help: http://mail.python.org/mailman/listinfo/c++-sig Neil From thinkofwhy at yahoo.ca Wed Apr 30 14:58:32 2008 From: thinkofwhy at yahoo.ca (thinkofwhy) Date: Wed, 30 Apr 2008 18:58:32 GMT Subject: calling variable function name ? In-Reply-To: References: <57461074-8fd1-4e65-9bc9-2ac916aa1fb5@y21g2000hsf.googlegroups.com> Message-ID: Try a dictionary: def funcA(blah, blah) def funcB(blah, blah) def funcC(blah, blah) functions = {'A': funcA, 'B': funcB, 'C': funcC} user_func = 'A' functions[user_func] #execute function "Arnaud Delobelle" wrote in message news:m28wyvba54.fsf at googlemail.com... > TkNeo writes: > >> >> George - Thanks for your reply but what you >> suggested is not working: >> >> def FA(param1,param2): >> print "FA" + param1 + " " + param2 >> def FA(param1,param2): >> print "FB" + param1 + " " + param2 >> def FA(param1,param2): >> print "FC" + param1 + " " + param2 >> >> temp = sys.argv[1] >> >> func = globals()["F" + temp] >> func("Hello", "World") >> >> >> I ran the script with first parameter as B and >> i get the following >> message >> KeyError: 'FB' > > Perhaps if you call your three function FA, FB, > FC instead of FA, FA, > FA it'll help? > > -- > Arnaud From arnodel at googlemail.com Tue Apr 8 15:56:38 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Tue, 8 Apr 2008 12:56:38 -0700 (PDT) Subject: calling variable function name ? References: Message-ID: On Apr 8, 8:52?pm, TkNeo wrote: > I don't know the exact terminology in python, but this is something i > am trying to do > > i have 3 functions lets say > FA(param1,param2) > FB(param1,param2) > FC(param1,param2) > > temp = "B" #something entered by user. now i want to call FB. I don't > want to do an if else because if have way too many methods like > this... > > var = "F" + temp > var(param1, param2) > > This does not work ofcourse. Does anyone know how to implement this ? F = { 'A': FA, 'B':FB, 'C':FC } F['A'](param1, param2) HTH -- Arnaud From bwljgbwn at gmail.com Tue Apr 22 05:51:50 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:51:50 -0700 (PDT) Subject: xp pro crack Message-ID: xp pro crack http://cracks.12w.net F R E E C R A C K S From jgodoy at gmail.com Sun Apr 27 13:14:39 2008 From: jgodoy at gmail.com (Jorge Godoy) Date: Sun, 27 Apr 2008 14:14:39 -0300 Subject: design choice: multi-threaded / asynchronous wxpython client? References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> <002cd046-f11d-482e-a67d-4a10a97687a1@x19g2000prg.googlegroups.com> <708eaa6d-3893-407e-83ec-4e6104b0a130@q24g2000prf.googlegroups.com> Message-ID: bullockbefriending bard wrote: > Tempting thought, but one of the problems with this kind of horse > racing tote data is that a lot of it is for combinations of runners > rather than single runners. Whilst there might be (say) 14 horses in a > race, there are 91 quinella price combinations (1-2 through 13-14, > i.e. the 2-subsets of range(1, 15)) and 364 trio price combinations. > It is not really practical (I suspect) to have database tables with > columns for that many combinations? > > I certainly DO have a horror of having my XML / whatever else formats > getting out of sync. I also have to worry about the tote company later > changing their XML format. From that viewpoint, there is indeed a lot > to be said for storing the tote data as numbers in tables. I don't understand anything about horse races... But it should be possible to normalize such information into some tables (not necessarily one). But then, there is nothing that prevents you from having dozens of columns on one table if it is needed (it might not be the most efficient solution performance and disk space-wise depending on what you have, but it works). Using things like that you can even enhance your system and provide more information about each horse, its race history, price history, etc. I love working with data and statistics, so even though I don't know the rules and workings of horse racings, I can think of several things I'd like to track or extract from the information you seem to have :-) How does that price thing work? Are these the ratio of payings for bets? What is a quinella or a trio? Two or three horses in a defined order winning the race? From vinay_sajip at yahoo.co.uk Sat Apr 26 11:05:31 2008 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Sat, 26 Apr 2008 08:05:31 -0700 (PDT) Subject: Logging ancestors ignored if config changes? References: <7770a385-e26d-4ad9-bc72-fa1228034c3b@26g2000hsk.googlegroups.com> Message-ID: <589e7281-07f4-4ad4-a074-fe0818321e21@56g2000hsm.googlegroups.com> On 26 Apr, 04:02, andrew cooke wrote: > Hi, > > I am seeing some odd behaviour withloggingwhich would be explained > if loggers that are not defined explicitly (but which are controlled > via their ancestors) must be created after theloggingsystem is > configured via fileConfig(). > > That's a bit abstract, so here's the problem itself: I define my log > within a module by doing > > importlogging > log =logging.getLogger(__name__) > > Now typically __name__ will be something like "acooke.utils.foo". > > That happens before the application configureslogging, which it does > by callinglogging.config.fileConfig() to load a configuration. > > If I do that, then I don't see anyloggingoutput from > "acooke.utils.foo" (when using "log" from above after "fileConfig" has > been called) unless I explicitly define a logger with that name. > Neither root nor an "acooke" logger, defined in the config file, are > called. > > Is this a bug? Am I doing something stupid? To me the above seems > like a natural way of using the system... > > Thanks, > Andrew It's not a bug, it's by design (for better or worse). A call to fileConfig disables all existing loggers which are not explicitly named in the new configuration. Configuration is intended for one-off use rather than in an incremental mode. Better approaches would be to defer creation of the loggers programmatically until after the configuration call, or else to name them explicitly in the configuration. Regards, Vinay Sajip From leoniaumybragg at gmail.com Sat Apr 26 07:01:19 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 04:01:19 -0700 (PDT) Subject: neupro patch Message-ID: neupro patch http://cracks.00bp.com F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Wed Apr 9 03:17:21 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 04:17:21 -0300 Subject: set file permission on windows References: Message-ID: En Tue, 08 Apr 2008 14:03:06 -0300, Tim Arnold escribi?: > hi, I need to set file permissions on some directory trees in windows > using > Python. The hard way: Use the function SetFileSecurity, the pywin32 package exposes it. See the Microsoft documentation at http://msdn2.microsoft.com/en-us/library/aa374860(VS.85).aspx The easy way: the cacls command -- Gabriel Genellina From nwang1981 at gmail.com Mon Apr 14 12:54:30 2008 From: nwang1981 at gmail.com (=?GB2312?B?zfXE/g==?=) Date: Mon, 14 Apr 2008 12:54:30 -0400 Subject: Java or C++? In-Reply-To: References: Message-ID: My idea, if you really love Python and never think about erasing it from your mind, go for C (not C++). A script language plus C can solve every problem you need to solve. Also Python works pretty fine with C. If you want a better job, maybe Java. Not sure though. If you want to educate yourself about Computer Science (including but not solely programming), maybe List/Scheme/Haskell. If you want to challenge yourself, seriously, go for C++. On Mon, Apr 14, 2008 at 2:44 AM, wrote: > Hello, I was hoping to get some opinions on a subject. I've been > programming Python for almost two years now. Recently I learned Perl, > but frankly I'm not very comfortable with it. Now I want to move on > two either Java or C++, but I'm not sure which. Which one do you think > is a softer transition for a Python programmer? Which one do you think > will educate me the best? > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Sun Apr 20 20:04:22 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 20 Apr 2008 20:04:22 -0400 Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: "Matthew Woodcraft" wrote in message news:hLC*ZjUas at news.chiark.greenend.org.uk... | Terry Reedy wrote: | | > But you do not really need a variant. Just define a preprocessor | > function 'blockify' which converts code in an alternate syntax to | > regular indented block syntax. Then | > | > exec(blockify(alt_code_string)) | | You can do it like that, but if it were to become part of the standard | distribution it would be nice to avoid having to tokenise the code | twice. For the motivating example I was responding to -- short snippets of code in html/xml/etc, that is completely a non-issue. Any such scheme is very unlikely to become part of the stdlib and if it were, it would have to first be tested and beat out competitors. A preprocessor written in Python is the obvious way to test and gain acceptance. | (You could define the new block scheme in such a way that | 'blockify' doesn't need to tokenise, Off the top of my head: copy C and use {} to demarcate blocks and ';' to end statements, so that '\n' is not needed and is just whitespace when present. So, repeatedly scan for the next one of '{};'. | but I think it would end up a bit ugly.) For beautiful, stick with standard Python. Terry Jan Reedy From sierra9162 at gmail.com Wed Apr 16 11:26:05 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:26:05 -0700 (PDT) Subject: kate hudson ryder Message-ID: <57995519-8691-4dca-96e1-789da3789c43@u69g2000hse.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From steve at holdenweb.com Wed Apr 2 12:09:03 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 02 Apr 2008 12:09:03 -0400 Subject: Manipulate Large Binary Files In-Reply-To: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> Message-ID: Derek Tracy wrote: > I am trying to write a script that reads in a large binary file (over > 2Gb) saves the header file (169088 bytes) into one file then take the > rest of the data and dump it into anther file. I generated code that > works wonderfully for files under 2Gb in size but the majority of the > files I am dealing with are over the 2Gb limit > > INPUT = open(infile, 'rb') > header = FH.read(169088) > > ary = array.array('H', INPUT.read()) > Replace this line with a loop that reads 10MB or 100MB chunks at a time. There is little reason to read the whole file in to write it out again. regards Steve > INPUT.close() > > OUTF1 = open(outfile1, 'wb') > OUTF1.write(header) > > OUTF2 = open(outfile2, 'wb') > ary.tofile(OUTF2) > > > When I try to use the above on files over 2Gb I get: > OverflowError: requested number of bytes is more than a Python > string can hold > > Does anybody have an idea as to how I can get by this hurdle? > > I am working in an environment that does not allow me to freely download > modules to use. Python version 2.5.1 > > > > R/S -- > --------------------------------- > Derek Tracy > tracyde at gmail.com > --------------------------------- > -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From ewertman at gmail.com Tue Apr 29 01:38:51 2008 From: ewertman at gmail.com (Eric Wertman) Date: Tue, 29 Apr 2008 01:38:51 -0400 Subject: File IO Issues, help :( In-Reply-To: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> References: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> Message-ID: <92da89760804282238w4a790932yb5ebb5a22038e3d3@mail.gmail.com> chuck in a jsfile.close(). The buffer isn't flushing with what you are doing now. jsfile.flush() might work... not sure. Closing and re-opening the file for sure will help though. On Tue, Apr 29, 2008 at 1:26 AM, Kevin K wrote: > Hey everyone, I'm new to python and am trying to do a little project > with it. I'm running into problems writing over a file. I read from > the file and loop through for a specfic case in which I change > something. After I open and give it opening options (w, r, etc) one of > two things happens: either the file gets truncated and my writing > never takes place (or it seems it doesnt) or everything is appended to > the file and I have a double of what I started with, its never just > the updated file. Can someone shed some light on this for me?? Code > below: > > jsfile = open("../timeline.js", "r+") > jscontent = jsfile.readlines() > jsfile.truncate() > > for line in jscontent: > if re.search('var d =', line): > line = "var d = \""+mint['1'].ascdate()+"\"\n" > print line > jsfile.write(line) > -- > http://mail.python.org/mailman/listinfo/python-list > From victorsubervi at gmail.com Sat Apr 12 15:11:20 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Sat, 12 Apr 2008 14:11:20 -0500 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> Message-ID: <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> in line... On Fri, Apr 11, 2008 at 2:05 PM, Steve Holden wrote: > Victor Subervi wrote: > > I have worked on this many hours a day for two weeks. If there is an > > easier way to do it, just take a minute or two and point it out. Have > > you heard of the Law of Diminishing Returns? I have passed it long ago. > > I no longer want to waste time trying to guess at what you are trying to > > tell me. > > Victor > > > > On Fri, Apr 11, 2008 at 8:55 AM, Steve Holden > > wrote: > Where you have > > content = col_fields[0][14].tostring() > pic = "tmp" + str(i) + ".jpg" > img = open(pic, "w") > img.write(content) > print '

' % pic > img.close() > > instead write > > print content Like this, I presume? img = open(pic, "w") img.write(content) print '' % pic print content # print '

\n' % pic Does not work _at_all LOL. You will recall, also, that you once gave me a line similar to the one commented out (but without writing then opening the file). THAT did not work, either. So now do you see why I am frustrated?? > > > Then browse to the URL this program serves and you will see the image > (assuming you are still sending the image/jpeg content type). Well, as I mentioned before, I am sending text/html because the page, like almost all web pages, has a whole lot more content than just images. Or, perhaps you are suggesting I build my pages in frames, and have a frame for every image. Unsightly! > Once you > can see the image, THEN you can write a page that refers to it. Until > you start serving the image (NOT pseudo-html with image data embedded in > it) nothing else will work. My solution works just fine, thank you. It is inelegant. But it now appears to me, and I dare say rather clearly, that this inelegance is the fault of python itself. Perhaps this should be brought to Guido?s attention. Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From billingspanshism at gmail.com Sat Apr 19 17:16:22 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:16:22 -0700 (PDT) Subject: victoria beckham new haircut Message-ID: <45ee676d-2ac0-4cdb-8900-7c0e011899b8@c65g2000hsa.googlegroups.com> Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From fetchinson at googlemail.com Sun Apr 6 13:41:40 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Sun, 6 Apr 2008 10:41:40 -0700 Subject: @x.setter property implementation In-Reply-To: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> References: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> Message-ID: > I found out about the new methods on properties, .setter() > and .deleter(), in python 2.6. Obviously that's a very tempting > syntax and I don't want to wait for 2.6... > > It would seem this can be implemented entirely in python code, and I > have seen hints in this directrion. So before I go and try to invent > this myself does anyone know if there is an "official" implementation > of this somewhere that we can steal until we move to 2.6? The 2.6 source? From steve at holdenweb.com Sun Apr 13 08:05:53 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 13 Apr 2008 08:05:53 -0400 Subject: String Literal to Blob In-Reply-To: <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> Message-ID: Jason Scheirer wrote: [...] > > There _is_ a way to embed image data in HTML that is supported by > every major browser. It is ugly. Using the RFC 2397 (http:// > www.ietf.org/rfc/rfc2397) spec for data URLs you could go > > '' % base64.b64encode(image_data) > > Obviously you need to import the base64 module somewhere in your code > and base64-encoded data is about a third larger than it would be > otherwise, so embedding anything particularly large is going to be a > huge pain and affect page load times pretty badly. This is hardly likely to help someone who hasn't yet grasped the concept of referencing graphics and prefers to write database output to disk to serve it statically. But who knows, maybe it will ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From steve at holdenweb.com Wed Apr 9 17:04:03 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 17:04:03 -0400 Subject: basic python question about for loop In-Reply-To: References: Message-ID: jmDesktop wrote: >>From the Python.org tutorial: > >>>> for n in range(2, 10): > ... for x in range(2, n): > ... if n % x == 0: > ... print n, 'equals', x, '*', n/x > ... break > ... else: > ... # loop fell through without finding a factor > ... print n, 'is a prime number' > ... > 2 is a prime number > 3 is a prime number > 4 equals 2 * 2 > 5 is a prime number > 6 equals 2 * 3 > 7 is a prime number > 8 equals 2 * 4 > 9 equals 3 * 3 > > > > first time 2 mod 2, 2/2, no remainder == 0, what am I doing wrong? > Why did it fall through? > >>> range(2, 2) [] >>> The loop body executes zero times. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From jjl at pobox.com Sat Apr 12 10:52:31 2008 From: jjl at pobox.com (John J. Lee) Date: Sat, 12 Apr 2008 14:52:31 GMT Subject: str(bytes) in Python 3.0 References: Message-ID: <87k5j3f7m8.fsf@pobox.com> Christian Heimes writes: > Gabriel Genellina schrieb: >> On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') >> above. But I get the same as repr(x) - is this on purpose? > > Yes, it's on purpose but it's a bug in your application to call str() on > a bytes object or to compare bytes and unicode directly. Several months > ago I added a bytes warning option to Python. Start Python as "python > -bb" and try it again. ;) Why hasn't the one-argument str(bytes_obj) been designed to raise an exception in Python 3? John From c.boulanger at qxtransformer.org Tue Apr 29 11:28:30 2008 From: c.boulanger at qxtransformer.org (Panyasan) Date: Tue, 29 Apr 2008 08:28:30 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <473deef3-9acb-45dd-a7ca-47b0081bd28c@i36g2000prf.googlegroups.com> <3f7bb91e-335e-46bd-88ca-f15b26c35132@k1g2000prb.googlegroups.com> <827bdae6-4422-4226-a543-af53f5b7e01b@s33g2000pri.googlegroups.com> Message-ID: > Christian, > > It appears you're missing a file. Where did you placed my program? I > see that there are two places being mentioned: > > > no resource file for /Users/bibliograph/Programme/PythonCard/tools/ > > layoutEditor/multipropertyEditor > > and > > > File "/Library/Python/2.5/site-packages/PythonCard/tools/ > > layoutEditor/layoutEditor.py", line 556, in createDC I unzipped the folder you uploaded and placed it in the PythonCard/ tools folder. I get the same error if I try to start the default resourceEditor.py or layoutEditor.py scripts, so it does not seem to have to do with your modifications. When I copy multipropertyEditor.rsrc.py files from PythodCard/tools/ resourceEditor/modules folder to PythodCard/tools/resourceEditor/, it will throw the error about a different file - might this be some kind of PATH error? C. From gagsl-py2 at yahoo.com.ar Wed Apr 2 23:29:08 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 00:29:08 -0300 Subject: Strange MySQL Problem... References: <4dc0cfea0804021236n1faafabav1699fbe45acc3c01@mail.gmail.com> Message-ID: En Wed, 02 Apr 2008 16:36:43 -0300, Victor Subervi escribi?: > I have this code which works fine: "works fine"? Please check again... The same remarks I've posted earlier apply here. > print 'Content-Type: image/jpeg\r\n' > print '\nHi!\n' Don't you see a conflict among those two lines? (You're a liar: first you promise to send a nice picture and then you only send a letter!) > cursor.execute("CREATE TABLE justatest (name TEXT, ablob BLOB)") Note that you *always* attempt to create a table. > sql = "INSERT INTO justatest VALUES (%s, %s)" > cursor.execute(sql, ('ramis', _mysql.escape_string(f)) ) You're using bound parameters now, a good thing. There is no need to escape strings passed as parameters - in fact, it is wrong, as the adapter will escape the text again. In this case, the column is a BLOB, and you have to use the Binary function: MySQLdb.Binary(f) > Now, if I take out this part, which I can?t see does anything at all in > the > code, it no longer works: I don't think "it no longer works" because you removed anything, but because this script can only be run at most once. Probably you're getting an error in the CREATE TABLE statement. You have to look at the server error logs, else you're blind fighting. See other suggestions in my previous post. Specially, try to make things work *locally*, and only when it's working fine, move on to the web part. -- Gabriel Genellina From paul.anton.letnes at gmail.com Tue Apr 15 04:07:15 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Tue, 15 Apr 2008 10:07:15 +0200 Subject: Java or C++? In-Reply-To: <480424FC.5040802@aim.com> References: <480424FC.5040802@aim.com> Message-ID: <6DDC1DFC-74EA-4788-96B3-23ECEAB8EA11@gmail.com> Brian: Impressive! This is the most balanced, well-informed and interesting reply to this debate. I would like to make some comments even so. I have tried all languages, and consider myself agnostic. However, I would like to roughly repeat what James Gosling (Java inventor) said at a lecture I attended: Java is nice because you can work in Java everywhere now - from embedded to desktops to supercomputers and servers. And, I would like to make my own comment: Java is the language I have tried which gives you the most help as a developer. For every crash, there is a complete and useful stack trace. Using Eclipse, you can auto-generate much of the 'boilerplate' code which is claimed to make Java boring to write (get, set, constructors...). It also more or less tells you how to fix small bugs - ';' and } missing for example. Even python is less helpful; concider "Unexpected indent" or the very informative "incorrect syntax" when you forget a ) or a : . C (or C++) for learning to talk to the metal, Java or Python for object orientation, Java will give you the most help, Python gets you started quickly, C++ is the hardest to understand in every detail, but C bogs you down with administrative stuff (try converting an int to a string; I found myself googling for an hour!). I tried this infamous "extending in C" and I would forget that until you know both C and python a bit more... Also, extending python in C++ or Java is possible - I didn't manage C++ yet, and Java I didn't try. Cheers! Paul. Den 15. april. 2008 kl. 05.46 skrev Brian Vanderburg II: >> My idea, if you really love Python and never think about erasing it >> from your mind, go for C (not C++). A script language plus C can >> solve >> every problem you need to solve. Also Python works pretty fine with >> C. > I agree mostly with this one. Scripting is very nice when writing an > application especially one that needs to change very often. Plus > there > are several toolkits and existing libraries available for Python. > I've > used wxPython some with it, and it came in handy for a few > applications > that I would have normally written in C++/wxWidgets and have to > recompile every few weeks to suit my needs (data extraction tools/etc) > > However there are cases when a compiled language is better, especially > anything that needs to be 'fast' and have a lower overhead. I > wouldn't > use Python to create a very graphics intensive game or anything, > though > it can be used with pygame/PyOpenGL for some nice simple stuff. Also > everything in Python is an object so it can start to consume memory > when > handling very large data sets. And since there is no guarantee of > when > garbage collection occurs, simply 'deleting' an item does not ensure > it > is completely gone, especially if there are cyclic references, though > that can be handled by using 'gc.collect()'. > > > > I consider C++ just a simplification of C, in the sense that it > makes it > easier to do things that would take more work to be done in C. One > can > still use C++ without all of the more complicated aspects but still > take > advantages of other aspects. > > C has the advantage that it does not to anything behind your back. > This > is very useful especially for any form of system development or where > you must know exactly what is going on. It is still possible to do > 'object oriented' development in C, it just requires some more > typing to > set up whatever is needed. Even things like COM for windows can be > done > in C, it just requires manually building the 'vtable' so to speak. > Also, C seems to avoid the use of temporaries where as C++ can use > them > in conversions and assignments automatically if needed. > > C++ makes some of it easier by doing certain things for you. Take a > string object for example. In C, assignment would only do a memory > copy > operation: > > String a, b; > b = a; > > The statement 'b = a' would only copy the memory and pointers from 'b' > to 'a' which means they would both point to the same buffer. To avoid > this, a copy constructor or assignment operator can be implemented > when > using C++. The same in C would be something like: > > String_Assign(&b, &a); /* instead of b = a */ > > Then if a structure contains objects, more work is needed. For > example, > in C: > > typedef struct Name > { > String honorary; > String first; > String middle; > String last; > String lineage; > } Name; > > void Name_Create(Name* name) > { > String_Create(&name->honorary); > String_Create(&name->first); > String_Create(&name->middle); > String_Create(&name->last); > String_Create(&name->lineage); > } > > void Name_Assign(Name* self, Name* other) > { > String_Assign(&self->honorary, &other->honorary); > String_Assign(&self->first, &other->first); > String_Assign(&self->middle, &other->middle); > String_Assign(&self->last, &other->last); > String_Assign(&self->lineage, &other->lineage); > } > > Name p1, p2; > Name_Create(&p1); > Name_Create(&p2); > Name_Assign(&p2, &p1); > > But in C++, this is no problem: > > Name p1, p2; > p2 = p1; > > This will automatically call the constructors of any contained objects > to initialize the string. The implicit assignment operator > automatically performs the assignment of any contained objects. > Destruction is also automatic. When 'p1' goes out of scope, during > the > destructor the destructor for all contained objects is called. > > And if you want more control you can implement the default and copy > constructors, destructor, and assignment operator, and tell them to do > what you want. Just beware because the explicit constructors only > calls > default constructors of any parent classes (even the copy constructor) > unless an initializer list is used, and an explicit assignment will > not > automatically do assignment of parent classes. > > Neither C nor C++ is really better, it depends on the what needs to be > done. C does only what it is told, and also has easier external > linkage > since there is no name mangling. C++ does a lot of the needed stuff > automatically, but explicit constructors and assignment operators can > still be declared to control them, and frequently doing the same thing > in C++ takes fewer lines of code than in C. > > As for Java, I think it is 'overly-used' in some areas, especially in > embedded development. I attended NC State and during orientation this > representative was talking about a small little robotic device and how > it had a full Java VM inside it and it only took '6 minutes to boot'. > Some claim it is for portability that Java is so good in embedded > devices. But still, if the program is moved to another device, it may > still need to be changed and recompiled if the new devices has > different > IO pins, timers, interrupts, etc. Most chips have a C > compiler/translator available, and the same program could have been > written in C, compiled directly to the machine code needed for the > device, 'booted' immediately, and not needed a Java VM as well. If > portability to other devices is desired then an abstract layer could > be > created in the program and the device/hardware specific code could be > seperated to that layer seperatly from the rest of the program. > > Well, all of that is just my opinion though, not meant to offend > anyone. > > > > > -- > http://mail.python.org/mailman/listinfo/python-list From ang.usenet at gmail.com Tue Apr 8 16:29:13 2008 From: ang.usenet at gmail.com (Aaron Gray) Date: Tue, 8 Apr 2008 21:29:13 +0100 Subject: CPython VM & byte code resources wanted Message-ID: <6622srF2e32hbU1@mid.individual.net> Hi, I am looking to study the CPython source code, but I cannot seem to find the VM code. Also is there any where a detailed list of the opcodes ? Many thanks in advance, Aaron From aahz at pythoncraft.com Fri Apr 4 16:41:47 2008 From: aahz at pythoncraft.com (Aahz) Date: 4 Apr 2008 13:41:47 -0700 Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: In article , Jan Claeys wrote: > >There are at least 3 books about game programming in python: > STAY AWAY Speaking as half of the tech-editing team for this book (the formal title is _Game Programming: The L Line, The Express Line to Learning_), I recommend staying as far as possible from this book. It does an okay job of teaching pygame, but it does a poor job of teaching Python (for example, it does not mention dicts) and therefore has a number of flaws from a pedagogical perspective, *plus* there are some bugs in the code. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "It is easier to optimize correct code than to correct optimized code." --Bill Harlan From ockman at gmail.com Thu Apr 3 19:34:26 2008 From: ockman at gmail.com (ockman at gmail.com) Date: Thu, 3 Apr 2008 16:34:26 -0700 (PDT) Subject: Bug in shlex?? References: Message-ID: <2dfd3aa7-7380-4825-b54b-88b49051ded0@b1g2000hsg.googlegroups.com> Gabriel... I feel foolish...(and wish I had the two hours back I spent on this). :) Thank you so much! > The result is a list containing a single string. The string contains 5 > characters: a single backslash, a question mark, three letters. The > backslash is the escape character, as in '\n' (a single character, > newline). A backslash by itself is represented (both by repr() and in > string literals) by doubling it. > > If you print the value, you'll see a single \: > > print shlex.split("'\?foo'")[0] > > -- > Gabriel Genellina From kyosohma at gmail.com Mon Apr 14 10:01:04 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Mon, 14 Apr 2008 07:01:04 -0700 (PDT) Subject: Python GUI programming and boa or better ? References: Message-ID: <5797f944-2540-4899-9de8-b123f2f90818@a22g2000hsc.googlegroups.com> On Apr 14, 8:20 am, bvidinli wrote: > I program in python for about 2-3 monthos. > I just started/tested gui programming with many tools. > i tested boa last, it is the closest tool to delphi in tui tools that i used. > > I managed to play with it a bit. > > If you have any other tool which you know better than Boa Constructor, > please write in here. > > Any other suggestion about python GUI programming is welcome. > thanks. > > -- > ?.Bahattin Vidinli > Elk-Elektronik M?h. > ------------------- > iletisim bilgileri (Tercih sirasina gore): > skype: bvidinli (sesli gorusme icin,www.skype.com) > msn: bvidi... at iyibirisi.com > yahoo: bvidinli > > +90.532.7990607 > +90.505.5667711 You'll probably want to take a look at the Python GUI FAQ for Python: http://www.python.org/doc/faq/gui/ And the Python Wiki has information on the many editors out there, including some GUI ones: http://wiki.python.org/moin/PythonEditors I hand-code all of my mine, although occasionally I'll use Visual Studio to create the look and then code wxPython to match. Mike From ronnbus at gmail.com Mon Apr 7 18:29:28 2008 From: ronnbus at gmail.com (Ronn Ross) Date: Mon, 7 Apr 2008 18:29:28 -0400 Subject: playing around with python Message-ID: Hello, I download the source for -------------- next part -------------- An HTML attachment was scrubbed... URL: From hall.jeff at gmail.com Tue Apr 15 13:23:02 2008 From: hall.jeff at gmail.com (hall.jeff at gmail.com) Date: Tue, 15 Apr 2008 10:23:02 -0700 (PDT) Subject: Preferred method for "Assignment by value" Message-ID: As a relative new comer to Python, I haven't done a heck of a lot of hacking around with it. I had my first run in with Python's quirky (to me at least) tendency to assign by reference rather than by value (I'm coming from a VBA world so that's the terminology I'm using). I was surprised that these two cases behave so differently test = [[1],[2]] x = test[0] x[0] = 5 test >>> [[5],[2]] x = 1 test >>>[[5],[2]] x >>> 1 Now I've done a little reading and I think I understand the problem... My issue is, "What's the 'best practise' way of assigning just the value of something to a new name?" i.e. test = [[1,2],[3,4]] I need to do some data manipulation with the first list in the above list without changing obviously x = test[0] will not work as any changes i make will alter the original... I found that I could do this: x = [] + test[0] that gets me a "pure" (i.e. unconnected to test[0] ) list but that concerned me as a bit kludgy Thanks for you time and help. From jkugler at bigfoot.com Tue Apr 29 15:20:53 2008 From: jkugler at bigfoot.com (Joshua Kugler) Date: Tue, 29 Apr 2008 11:20:53 -0800 Subject: Setting an attribute without calling __setattr__() References: Message-ID: animalMutha wrote: >> Consider reading the *second* paragraph about __setattr__ in section >> 3.4.2 of the Python Reference Manual. > > if you are simply going to answer rtfm - might as well kept it to > yourself. For what it's worth, I (the original poster) am glad he answered that way. It showed me the section and paragraph I had overlooked when reading through the docs the first time. j From Scott.Daniels at Acm.Org Wed Apr 2 23:25:17 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Wed, 02 Apr 2008 20:25:17 -0700 Subject: Python in High School In-Reply-To: <47f295c8$0$868$ba4acef3@news.orange.fr> References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <47f295c8$0$868$ba4acef3@news.orange.fr> Message-ID: Laurent Pointal wrote: > Le Tue, 01 Apr 2008 12:35:46 -0700, Paddy a ?crit : > And if you want to do easy and simple 3D graphics programming, look at > VPython > > http://www.vpython.org/ I offer a _strong_ second -- Nowhere in computing have I seen it easier to create stereoscopic views of 3-D things with a tiny amount of code without facing a wall when you exceed their example space. You owe it to yourself to spend a long weekend working through VPython; you will be _shocked_ at what you can do after three full days of hard work. Imagine: Ruth Chabay and Bruce Sherwood built this code in order to teach intro physics: they thought that (and continue to teach classes as if) it was _easier_ to teach Python and the physics than to teach physics alone! -Scott David Daniels Scott.Daniels at Acm.Org From sjmachin at lexicon.net Thu Apr 17 18:00:21 2008 From: sjmachin at lexicon.net (John Machin) Date: Thu, 17 Apr 2008 22:00:21 GMT Subject: MySQL hardcoding? In-Reply-To: References: Message-ID: <4807c872$1@news.mel.dft.com.au> marexposed at googlemail.com wrote: > I've got this error (see the path in last line) > > db=MySQLdb.connect(host='localhost',use_unicode = True, charset = "Windows-1251",user='root',passwd='12',db='articulos') Can't help with the answer to your question, but this may stave off yet another question: The empirical evidence from other recent postings is that you are mucking about with Spanish-language newspaper "articulos" on the web ... so why charset = "Windows-1251", which is Cyrillic (i.e. Russian etc)?? Perhaps you mean 1252 which is Microsoft's latin1 with extras. HTH, John From carbanancizpo at gmail.com Fri Apr 18 16:53:47 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:53:47 -0700 (PDT) Subject: microsoft office 2003 product key crack Message-ID: microsoft office 2003 product key crack http://cracks.12w.net F R E E C R A C K S From marco at sferacarta.com Tue Apr 29 08:45:30 2008 From: marco at sferacarta.com (Marco Mariani) Date: Tue, 29 Apr 2008 14:45:30 +0200 Subject: Zope/DTML Infuriating... In-Reply-To: <3a955f90-ed80-46be-a238-1462e4fb2d0c@m3g2000hsc.googlegroups.com> References: <3a955f90-ed80-46be-a238-1462e4fb2d0c@m3g2000hsc.googlegroups.com> Message-ID: Jens wrote: >> You might have wrong assumptions from previous PHP experiences. >> >> >>> 'x'+4 >> Traceback (most recent call last): >> File "", line 1, in >> TypeError: cannot concatenate 'str' and 'int' objects >> > > ... and the non snobby answer would have been: > > ... Sorry. Not trying to be snobbish, only in a hurry. That answer would have been less useful, because there are TONS of details in the python tutorial, that set the language apart from its "scripting cousins". Reading the syntax and thinking "yeah, got it, boring, next chapter" is a common mistake I've also made sometime, especially with python when I've been deceived by its apparent simplicity. Then, later, the same happened with Javascript, of course. And it's bound to happen again, as much as I'll try to be careful :-( From lutz.georg.horn at googlemail.com Wed Apr 30 02:37:18 2008 From: lutz.georg.horn at googlemail.com (Lutz Horn) Date: Wed, 30 Apr 2008 08:37:18 +0200 Subject: sed to python: replace Q In-Reply-To: <48180348$0$34534$742ec2ed@news.sonic.net> References: <48180348$0$34534$742ec2ed@news.sonic.net> Message-ID: <7c85a2590804292337n68ff0289rcc29deb4678b6012@mail.gmail.com> Hi, 2008/4/30 Raymond : > For some reason I'm unable to grok Python's string.replace() function. replace() does not work with regular expressions. > Is there a decent description of string.replace() somewhere? Use re.sub(). >>> import re >>> line = "date process text [ip] more text" >>> re.sub('].*$', '', re.sub('^.*\[', '', line, 1)) 'ip' Lutz From namesagame-usenet at yahoo.com Sat Apr 5 14:03:56 2008 From: namesagame-usenet at yahoo.com (gamename) Date: Sat, 5 Apr 2008 11:03:56 -0700 (PDT) Subject: Not Sure This Can Be Done... References: <46aeae28-4470-4136-a5f6-040f6468eb32@b5g2000pri.googlegroups.com> <170a668f-4a65-471f-ad03-03231235b314@e6g2000prf.googlegroups.com> Message-ID: Thanks! Good suggestion(s) all. Maybe I can get this done. :) -T On Apr 1, 4:49 pm, MrJean1 wrote: > In any script upon startup, sys.path[0] contains the full path of the > directory where the script is located. See lib/module-sys.html> under 'path'. > > it should be straightforward from here (untested though). In each > script, get the sys.path[0] string, split it using os.path, replace > the last item with 'tools' and join again with os.path. If the > resulting string is not in sys.path, insert it after sys.path[0]. > > /Jean Brouwers > > On Apr 1, 1:57 pm, gamename wrote: > > > Hi, > > > I generally have several copies of the same development environment > > checked out from cvs at any one time. Each development tree has a > > 'tools' dir containing python modules. Scattered in different places > > in the tree are various python scripts. > > > What I want to do is force my scripts to always look in the closest > > 'tools' dir for any custom modules to import. For example: > > > tree1/tools > > tree1/my_scripts/foo.py > > > tree2/tools > > tree2/my_scripts/foo.py > > > How can I make 'foo.py' always look in '../../tools' for custom > > modules? My preference would be to avoid changing the 'foo.py' script > > and have some way to resolve it via the environment (like PYTHONPATH, > > or .pth files, etc.). > > > Anyone have any ideas? > > TIA, > > -T From sturlamolden at yahoo.no Sun Apr 20 17:55:19 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sun, 20 Apr 2008 14:55:19 -0700 (PDT) Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> <480b6133$0$34498$742ec2ed@news.sonic.net> <3eac67b4-da0a-4926-9ca4-942271513ad2@26g2000hsk.googlegroups.com> Message-ID: <8d09a9d0-12ae-4edc-a80a-ef96058a025a@m73g2000hsh.googlegroups.com> On Apr 20, 8:49 pm, Roy Smith wrote: > Hiding your source code is not easy (perhaps impossible) in Python, for > reasons which have been covered at length on a regular basis in this forum. > If you only ship .pyc or .pyo files, there is still enough information > recoverable in the field that most businesses which want to keep their > source code hidden would feel excessively exposed. Every know and then, I see someone complaining you cannot sell programs written i Python or Java, because the bytecodes are so easily reverse engineered. The same guys usually have no problem with C#, because the executable are called 'something.exe'. The fact that a .NET executable also contain bytecodes, seems to be of little significance. It is very easy to obfuscate Python bytecodes beyond normal comprehension. All that is required is to put the .pyc files in a zipped folder and encrypt it. Then it's a matter of triviality to produce a C program that decrypts the zipped folder, embeds a Python interpreter, and runs the decrypted program. But even this scheme is not foolproof against an extremely skilled and determined adversary. Nothing really is. What measures to take depend on the threat. If the threat prevents distribution of code in any form, one can always provide critical parts as a web service and distribute nothing except XML. From davidreynon at gmail.com Wed Apr 23 10:02:46 2008 From: davidreynon at gmail.com (korean_dave) Date: Wed, 23 Apr 2008 07:02:46 -0700 (PDT) Subject: python-doc Message-ID: Hi all. I am using this to try to document my python-coded apps. http://effbot [DOT] org/zone/pythondoc [DOT] htm i am using windows XP professional. I have put the install directory of pythondoc.py in my path file. So i "cd" to the directory containing the python scripts I wish to python-doc, typing in "python-doc.py scriptname.py" and after about 1 second, i get nothing. No error, but again, no indication that this process has been completed. I have no idea where to look for html files. I checked all relevant directories that might have it (the directory containing the pythondoc.py script, etc.). Please help... Maybe my syntax is incorrect? Thanks, -Dave From software at ginstrom.com Wed Apr 16 23:01:11 2008 From: software at ginstrom.com (Ryan Ginstrom) Date: Thu, 17 Apr 2008 12:01:11 +0900 Subject: Splitting MainWindow Class over several modules. In-Reply-To: <0e6b1338-8355-4fba-9db2-0cc09fc05e1e@m44g2000hsc.googlegroups.com> References: <0e6b1338-8355-4fba-9db2-0cc09fc05e1e@m44g2000hsc.googlegroups.com> Message-ID: <191901c8a037$4b08ea20$0203a8c0@MOUSE> > On Behalf Of Mike Driscoll > I don't think there's anything wrong with it. The main thing > to remember is to try to keep the interface and the logic > separate. I have a fairly complex program with lots of tabs > and sub tabs. So I stuck each of the tab's display code in a > separate file and imported them into my main program. There are also several signaling techniques that make it easy to separate the GUI logic from the message-processing logic. Or you could simply have a controller class that instantiates the GUI class and registers itself as the message listener. Regards, Ryan Ginstrom From n00m at narod.ru Sat Apr 26 22:02:03 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 19:02:03 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <54dc008c-a747-4507-a2d5-9b4ddccbd5b9@e53g2000hsa.googlegroups.com> <3a7541ae-8aa2-46d5-93a3-115f9e2a3c38@l42g2000hsc.googlegroups.com> Message-ID: Btw seems all accepted pyth solutions (for this prob) used Psyco. From duncan.booth at invalid.invalid Wed Apr 9 04:51:58 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 9 Apr 2008 08:51:58 GMT Subject: Google App Engine References: <47fc2c7c$0$36365$742ec2ed@news.sonic.net> <7e43fcd9-6207-4af2-8256-c0099a8ce0bb@1g2000prf.googlegroups.com> Message-ID: Jason Scheirer wrote: > On Apr 8, 7:50 pm, John Nagle wrote: >> Duncan Booth wrote: >> > Google have announced a new service called 'Google App Engine' >> > which may be of interest to some of the people here >> >> OK, now we need a compatibility layer so you can move apps from >> Google App Engine to your own servers. You don't want to be locked >> into a single vendor solution, especially when they reserve the right >> to start charging. >> >> Their data store uses a subset of SQL, so it's probably possible >> to write a conversion layer allowing use of MySQL. >> >> John Nagle > > It supports Django, and more importantly, WSGI, so any 'framework' you > build on top of it should transfer out. Heck, you have a stand-alone > python script that comes with the developer kit for hosting your apps > on YOUR computer that you could port to use YOUR database and be done > with it. Write your own ORM or just some decent OO code for handling > data access so the database access layer can be swapped out and you > are golden. I really doubt getting away from the Googe App Engine is > going to be too terribly difficult for any intermediate Python > programmer, assuming good up-front application design. There are several things which would make moving away from Google tricky: The backend data store, while it has a vaguely SQLish query language is an object database not a relational database, i.e. more like ZODB than MySQL. It uses similar concepts to django's data api but isn't the same. It should be possible to write something simple to replace it, but given that you only need to migrate away from Google when your data or page hits get large, you need to replace it with something scalable. The data store is the *only* writeable storage your application can access, so there isn't much scope to write applications without using it. If you use authentication then again you are tied to Google accounts (or Google Apps accounts). For a public application that would also block attempts to move to another platform. The standalone script for testing is just for testing: it dummies out user authentication (login accepts anything), and it only accepts a single request at a time. From acp.dev at gmail.com Thu Apr 24 11:33:49 2008 From: acp.dev at gmail.com (AC Perdon) Date: Thu, 24 Apr 2008 23:33:49 +0800 Subject: Billing system written in python Message-ID: <40847e660804240833q4e4210dyb8a561899635fb77@mail.gmail.com> Hi, I would like to develop a billing system for a cable tv system, basically what it does is have subscribers in db, compute billing statement, print for statement for distribution something like that. I was evaluating jbilling its a java base billing system that uses tomcat,mysql or postgress DB and java. Im looking similar to this but its written in python so that I wont start from scratch. Why not use jbilling instead if it solve you problem? Will the reason Im looking for a python solution is I want to learn python and java is bit complicated for me at this time since Im just a newbie in programing. Any suggestion? I was thinking of using django but Im more looking in to a ready made billing system that I will just do some tweaking and fine tunning to meet our need. like jbilling. Thanks, AC -- -- AC Perdon Registered Linux User #340122 -------------- next part -------------- An HTML attachment was scrubbed... URL: From markfernandes02 at googlemail.com Sat Apr 5 05:56:15 2008 From: markfernandes02 at googlemail.com (markfernandes02 at googlemail.com) Date: Sat, 5 Apr 2008 02:56:15 -0700 (PDT) Subject: In Tkinter - having an input and an entry Message-ID: I need some advice, I am creating a python program to communicate with an MS Access db in python 2.4. I can fetch records but cannot insert records. def Insert(self, *row): global cursor, title, author, pubdate sqlInsert = "INSERT INTO Book_table" sqlInsert = sqlInsert + "(Bookname, BookAutor, " sqlInsert = sqlInsert + "Publicationdate) VALUES ('" sqlInsert = sqlInsert + title + "', '" sqlInsert = sqlInsert + author + "', " sqlInsert = sqlInsert + pubdate + ") " myconn = odbc.odbc('accessDatabase') cursor = myconn.cursor() cursor.execute(sqlInsert) myconn.commit() cursor.close() myconn.close() The above code does not work. Also with Tkinter, i want to have user input records into the db, i cannot get what the user inputs into the entry to become a string variable. If you can help it would be most appreciated. Thanks in advanced Mark From darcy at druid.net Wed Apr 16 14:03:51 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Wed, 16 Apr 2008 14:03:51 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: <48062BB4.8000201@gmail.com> References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> <87prspydex.fsf@physik.rwth-aachen.de> <48062BB4.8000201@gmail.com> Message-ID: <20080416140351.5ba60204.darcy@druid.net> On Wed, 16 Apr 2008 10:39:16 -0600 Michael Torrie wrote: > Running a few lists myself, I don't see this. How is administrative > overhead tedious? Most open source projects do it, so I wonder just how > tedious it is. Of all the projects I'm associated with in lists, Python > is the only one still clinging to NNTP when it appears a normal mail > list is just as good. Especially given that Mailman, a Python program, can handle all the heavy lifting anyway. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From __peter__ at web.de Wed Apr 30 12:18:03 2008 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Apr 2008 18:18:03 +0200 Subject: printing inside and outside of main() module References: <9bd5c596-da19-4615-a4d8-e47b20cfb362@m73g2000hsh.googlegroups.com> <48189ac0$0$9742$426a74cc@news.free.fr> Message-ID: Bruno Desthuilliers wrote: > Peter Otten a ?crit : >> korean_dave wrote: >> >>> This allows me to see output: >>> >>> ---begin of try.py >>> print "Hello World" >>> --end of try.py >>> >>> This DOESN'T though... >>> >>> --begin of try2.py >>> def main(): >>> return "Hello" >> main() # add this >>> --end of try2.py >>> >>> Can someone explain why??? >> >> Python doesn't call the main() function; you have to invoke it >> explicitly. > > > And while we're at it, your main function *returns* a value, but doesn't > *print* anything. > Ouch! From maehhheeyy at gmail.com Tue Apr 29 17:47:40 2008 From: maehhheeyy at gmail.com (maehhheeyy) Date: Tue, 29 Apr 2008 14:47:40 -0700 (PDT) Subject: i want to add a timeout to my code References: <53ffe104-be3b-43e2-b5c8-4ce5886ac60d@b1g2000hsg.googlegroups.com> <1f70ea43-7909-4bd8-b63d-2467e8a0542f@c65g2000hsa.googlegroups.com> Message-ID: On Apr 17, 4:24?pm, Miki wrote: > On Apr 17, 1:10?pm,maehhheeyy wrote: > > > I want to add a timeout so that when I pull out my gps from my serial > > port, it would wait for a bit then loop and then see if it's there. I > > also want to add a print statement saying that there is no GPS device > > found. However when I run my code and unplug my serial port, my code > > will just hang until I plug it back in. > > This is my code right now: > > > def GetGPS(): > > ? ? ? data = [] > > ? ? ? #Open com1: 9600,8,N,1 > > ? ? ? fi = serial.Serial(0, timeout = 1) > > ? ? ? print '[gps module] SERIAL PORT OPEN ON COM1:' > > > can anyone help me please? Thanks. > > http://docs.python.org/lib/node545.html > > HTH, > -- > Miki http://pythonwise.blogspot.com I tried the code onto my codes but what came out was that in the line signal.signal(signal.SIGSLRM, handler), an attributeError appeared reading that 'module' object has no attribute 'SIGALRM' From http Mon Apr 14 20:41:12 2008 From: http (Paul Rubin) Date: 14 Apr 2008 17:41:12 -0700 Subject: pgdb: Debugging Python extensions made easier References: Message-ID: <7xzlrw7xw7.fsf@ruckus.brouhaha.com> SteveD writes: > pgdb.zip is an addition to scite-debug, which adds source debugging to > the popular SciTE programmer's editor. ... > I know the FAQ says that this is not possible, but the FAQ is somewhat > outdated. GDB is quite happy with pending breakpoints to unresolved > libraries, but you have to reassure it. I'm not sure what FAQ or what is supposed to be impossible but I've used gdb in the past to debug python extensions without running into insurmountable problems that I remember. From carlwuhwdmckay at gmail.com Mon Apr 21 02:10:37 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:10:37 -0700 (PDT) Subject: transmac crack Message-ID: transmac crack http://cracks.00bp.com F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Thu Apr 10 06:14:46 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 07:14:46 -0300 Subject: Sorting Directories from files in a os.listdir?? References: <9354f263-b833-4845-a226-1ad3a47b1e6a@p25g2000pri.googlegroups.com> Message-ID: En Thu, 10 Apr 2008 06:55:13 -0300, Soren escribi?: > I'd like to read the filenames in a directory, but not the > subdirectories, os.listdir() gives me everything... how do I separate > the directory names from the filenames? Is there another way of doing > this? Check each returned name using os.path.isfile (untested): def files_only(path): return [filename for filename in os.listdir(path) if os.path.isfile(os.path.join(path, filename))] -- Gabriel Genellina From victorsubervi at gmail.com Wed Apr 16 09:16:45 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 16 Apr 2008 08:16:45 -0500 Subject: String Literal to Blob In-Reply-To: <1208274907.4718.2.camel@aalcdl07.lib.unc.edu> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> <4dc0cfea0804140629rf1ac100m27ad9d0456cbbe2d@mail.gmail.com> <4803644A.8010204@holdenweb.com> <4dc0cfea0804150804l2d3832f0sd8f1d9405934063@mail.gmail.com> <1208274907.4718.2.camel@aalcdl07.lib.unc.edu> Message-ID: <4dc0cfea0804160616u19c3cda8wb0936abd7fc7e201@mail.gmail.com> The _keywords_ are _essential_. It is currently published at the end of a long and exhaustive thread. This is not good. It should be republished correctly, and with the kw people will use to search. For example, I would never have thought to search for a photo album. Victor On Tue, Apr 15, 2008 at 10:55 AM, J. Cliff Dyer wrote: > It is published. On comp.lang.python. Google groups has it, so google > (search) will find it. > > Cheers, > Cliff > > > On Tue, 2008-04-15 at 17:04 +0200, Victor Subervi wrote: > > Gabriel; > > > > That's really nice code you wrote. I will rewrite my app accordingly, > > after I catch a breather! Say, would you please publish this > > somewhere? Why should I write a howto on this and credit you when all > > I would be doing is republishing (plagerizing) what you published? > > Please insert these keywords: mysql, image, python, mysqldb and maybe > > picture and photo (you already have photo). Call it something like > > "MySQL/Python Tutorial for Posting and Retrieving Images / Photo > > Album". I ask you to do this because I scoured google looking for just > > what you've provided and it simply isn't out there. At all. There are > > nice howto's in php. Please post this for those interested in python, > > somewhere like the cookbook. > > > > Thanks, > > > > Victor > > > > > > > > On Tue, Apr 15, 2008 at 3:23 AM, Gabriel Genellina > > wrote: > > En Mon, 14 Apr 2008 11:03:54 -0300, Steve Holden > > > > escribi?: > > > Victor Subervi wrote: > > >> Thanks to all, especially Gabriel. [...] > > >> Steve, thank you for all your help, but do overcome your > > temper :)) > > > > > > > > I'm glad the penny finally dropped. You may have been > > treated to a > > > modest display of exasperation, but please be assured you > > have not yet > > > seen anything remotely like temper from me :-) > > > > > > And I'm glad to see that you finally "got it", too! > > > > -- > > Gabriel Genellina > > > > -- > > > > http://mail.python.org/mailman/listinfo/python-list > > > > > -- > Oook, > J. Cliff Dyer > Carolina Digital Library and Archives > UNC Chapel Hill > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From arnodel at googlemail.com Tue Apr 15 13:48:52 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Tue, 15 Apr 2008 10:48:52 -0700 (PDT) Subject: Preferred method for "Assignment by value" References: Message-ID: <8562becb-9fef-415d-9640-05ef80123596@a5g2000prg.googlegroups.com> On Apr 15, 6:23?pm, hall.j... at gmail.com wrote: > As a relative new comer to Python, I haven't done a heck of a lot of > hacking around with it. I had my first run in with Python's quirky (to > me at least) tendency to assign by reference rather than by value (I'm > coming from a VBA world so that's the terminology I'm using). I was > surprised that these two cases behave so differently Perhaps it is better to think that you bind the name 'x' to the object '42' when you write 'x=42'. > test = [[1],[2]] > x = test[0] > x[0] = 5 > test>>> [[5],[2]] > > x = 1 > test > > >>>[[5],[2]] > x > >>> 1 > > Now I've done a little reading and I think I understand the problem... > My issue is, "What's the 'best practise' way of assigning just the > value of something to a new name?" > > i.e. > test = [[1,2],[3,4]] > I need to do some data manipulation with the first list in the above > list without changing > obviously x = test[0] will not work as any changes i make will alter > the original... > I found that I could do this: > x = [] + test[0] > > that gets me a "pure" (i.e. unconnected to test[0] ) list but that > concerned me as a bit kludgy > > Thanks for you time and help. To create a new list with the same elements as a sequence seq, you can use list(seq). 'list' is the type of lists, it is also a 'constructor' for list objects (the same goes for other common buit-in types, such as 'int', 'float', 'str', 'tuple', 'dict'). E.g. >>> foo = [1, 2, 3] >>> bar = list(foo) >>> foo[0] = 4 >>> foo [4, 2, 3] >>> foo = [1, 2, 3] >>> bar = list(foo) >>> bar[0] = 4 >>> bar [4, 2, 3] >>> foo [1, 2, 3] >>> HTH -- Arnaud From antroy at gmail.com Thu Apr 3 08:44:23 2008 From: antroy at gmail.com (Ant) Date: Thu, 3 Apr 2008 05:44:23 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> Message-ID: <88b07549-9751-489b-968f-c3d2db0aba79@s13g2000prd.googlegroups.com> On Apr 3, 12:37 pm, tinn... at isbd.co.uk wrote: > What's the neatest and/or most efficient way of testing if one of a A different approach: >>> words = ["he", "sh", "bla"] >>> name = "blah" >>> True in (word in name for word in words) True >>> name = "bling" >>> True in (word in name for word in words) False Perhaps not as obvious or readable as Jeff's example, but is essentially doing the same thing using generator syntax. From kyosohma at gmail.com Tue Apr 8 16:41:35 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 8 Apr 2008 13:41:35 -0700 (PDT) Subject: new user needs help! References: Message-ID: <8ffe37a3-2d74-4d14-b8ae-94f8984061b3@b64g2000hsa.googlegroups.com> On Apr 8, 2:55 pm, drjekil wrote: > I am totally new in biopython and its my first program.so may be i am asking > stupid question. > I am working with a text filelooks like this: > #NAME AA TOPO ACCESS DSSP STRIDE Z-COORD > 1lghB A i 79.8 H H -24.58 > 1lghB V i 79.6 H H -22.06 > 1lghB H i 71.9 H H -19.94 > i need to compare those lines which has a Z-COORED value between 10 to 22 > and presents in the following way > True/false A C D E F G H I K L M N P Q R S T V X Y W(here alfabets > represents amino acids) > 1 1:1 2:0 3:0 and so on for rest of the amino acids. > IF PRESENT IN THAT RANGE > IF not PRESENT IN THAT RANGE then > -1 1:0 2:0 so on,it should be 1 instead of 0 when it will find corresponding > amino acid for that line.say here,for 2nd line it will be 16:1. > true will represent 1,false -1. > i have to cheek all the lins in the file and print it. > u have to tell simply otherwise i cant understand even,so stupid am i! > I will be really greatful!Thanks in advance > -- > View this message in context:http://www.nabble.com/new--user-needs-help%21-tp16571823p16571823.html > Sent from the Python - python-list mailing list archive at Nabble.com. To read the file, do something like this: f = open('path/to/filename') for line in f.readlines(): # do something print line See http://docs.python.org/lib/bltin-file-objects.html for more information. You'll want to look at using "if" statements to do the various conditions and you'll probably need to use string slicing/splitting to get the correct part of the line to do the comparison. So, something like f = open('path/to/filename') for line in f.readlines(): parts = line.split() zcoord = parts[-1] if zcoord > 10 and zcoord < 22: # do something pass print line Resources: http://docs.python.org/ref/if.html http://www.ibiblio.org/g2swap/byteofpython/read/if-statement.html http://docs.python.org/lib/string-methods.html http://www.diveintopython.org/native_data_types/joining_lists.html Mike From bronger at physik.rwth-aachen.de Sun Apr 20 14:02:37 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Sun, 20 Apr 2008 20:02:37 +0200 Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B80B5.1050500@cheimes.de> Message-ID: <87myno2yma.fsf@physik.rwth-aachen.de> Hall?chen! Gabriel Genellina writes: > En Sun, 20 Apr 2008 14:43:17 -0300, Christian Heimes > escribi?: > >> Gabriel Genellina schrieb: >> >>> Apart from what everyone has already said, consider that >>> FreqDist may import other modules, store global state, create >>> other objects... whatever. Pure python code should not have any >>> memory leaks (if there are, it's a bug in the Python >>> interpreter). Not-carefully-written C extensions may introduce >>> memory problems. >> >> Pure Python code can cause memory leaks. No, that's not a bug in >> the interpreter but the fault of the developer. For example code >> that messes around with stack frames and exception object can >> cause nasty reference leaks. > > Ouch! > May I assume that code that doesn't use stack frames nor stores > references to exception objects/tracebacks is safe? Circular referencing is no leaking on the C level but in a way it is memory leaking, too. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From george.sakkis at gmail.com Thu Apr 24 01:15:42 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 23 Apr 2008 22:15:42 -0700 (PDT) Subject: Parsing tuple from string? References: Message-ID: <48749047-d762-434d-b67f-125c2b25e612@26g2000hsk.googlegroups.com> On Apr 24, 12:21?am, Daniel wrote: > On Apr 23, 4:22 pm, George Sakkis wrote:> On Apr 23, 6:24 pm, Daniel wrote: > > > > I have a list of strings, which I need to convert into tuples. ?If the > > > string is not in python tuple format (i.e. "('one', 'two')", "("one", > > > 'two')", etc.), then I can just make it a 1-tuple (i.e. return > > > (string,) ). ?If it is in python tuple format, I need to parse it and > > > return the appropriate tuple (it's ok to keep all tuple elements as > > > strings). > > > > I think eval() will work for this, but I don't know what will be in > > > the string, so I don't feel comfortable using that. > > > Check out one of the safe restricted eval recipes, e.g.http://preview.tinyurl.com/6h7ous. > > Thank you very much! You're welcome. By the way, there's a caveat: simple_eval() doesn't require a comma between tuple/list elements or dict pairs: >>> simple_eval('(2 3)') (2, 3) >>> simple_eval('[1 2 ,3]') [1, 2, 3] >>> simple_eval('{ 1:"a" 2:"b"}') {1: 'a', 2: 'b'} Also parenthesized values are evaluated as 1-tuples >>> simple_eval('(2)') (2,) Since it doesn't evaluate general expressions anyway, that's not necessarily a problem. In any case, making it strict is left as an exercise to the reader :) George From umpsumps at gmail.com Sat Apr 26 18:23:11 2008 From: umpsumps at gmail.com (umpsumps at gmail.com) Date: Sat, 26 Apr 2008 15:23:11 -0700 (PDT) Subject: learning with python question (HtTLaPP) References: <98acecbd-9de2-4ebf-927b-ac6bc1fbc3fd@b5g2000pri.googlegroups.com> <53d6254f-895f-48fb-8ab9-3929c403f11b@v23g2000pro.googlegroups.com> Message-ID: <27197fb8-87af-4c86-971b-fb6d37511188@w4g2000prd.googlegroups.com> This is what I'm stuck on. I keep doing things like: for line in fin: for ch in letters: if ch not in line: I've tried for ch in letters: for line in fin: too.. Should I use a while statement? What's the best way to compare a group of letters to a line? > This would be a more difficult approach.. ? Where you are doing the > comparison step: > > if letters in line.strip(): > > It's trying to match the exact string "uzi", not any of the individual > letters. ?You would need to look for each letter independently and > then make sure they were in the right order to match the other words. From sjmachin at lexicon.net Fri Apr 25 18:17:54 2008 From: sjmachin at lexicon.net (John Machin) Date: Fri, 25 Apr 2008 15:17:54 -0700 (PDT) Subject: Subclassing datetime.date does not seem to work References: <4811FF57.5040200@comcast.net> Message-ID: On Apr 26, 7:43 am, Christian Heimes wrote: > Rick King schrieb: > > > > > I would like to subclass datetime.date so that I can write: > > > d = date2('12312008') > > > I tried: > > > from datetime import date > > class date2(date): > > def __init__( self, strng ): > > mm,dd,yy = int(strng[:2]), int(strng[2:4]), int(strng[4:]) > > date.__init__(self,yy,mm,dd) > > > But then this statement: > > d = date2('12312008') > > > Causes: > > TypeError: function takes exactly 3 arguments (1 given) > > > Is there something basically wrong with subclassing date? > > -Rick King > > datetime.date is a C extension class. Subclassing of extension classes > may not always work as you'd expect it. > ... and in this case it's a sledgehammer to crack a nut: >>> from datetime import date >>> def date_from_string(strng): ... mm, dd, yy = int(strng[:2]), int(strng[2:4]), int(strng[4:]) ... return date(yy, mm, dd) ... >>> date_from_string('12312008') datetime.date(2008, 12, 31) >>> Consider also: >>> import datetime >>> datetime.datetime.strptime('12312008', '%m%d%Y').date() datetime.date(2008, 12, 31) From robin at reportlab.com Fri Apr 18 07:54:44 2008 From: robin at reportlab.com (Robin Becker) Date: Fri, 18 Apr 2008 12:54:44 +0100 Subject: py3k s***s In-Reply-To: <66q33cF2krjf2U1@mid.uni-berlin.de> References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <66q33cF2krjf2U1@mid.uni-berlin.de> Message-ID: <48088C04.6090002@chamonix.reportlab.co.uk> Diez B. Roggisch wrote: . > You know what I was just wondering about? All these C-written > cross-platform libraries (which Python users benefit from, most probably > including evven you) that run on different unixes & windows, which are a > much greater diversity to handle than the not-even-yet-settled > differences between Py3K & 2.x. How the heck do they do that? . I'm in the process of attempting a straightforward port of a relatively simple package which does most of its work by writing out files with a more or less complicated set of possible encodings. So far I have used all the 2to3 tools and a lot of effort, but still don't have a working version. This must be the worst way to convert people to unicode. When tcl went through this they chose the eminently sensible route of not choosing a separate unicode type (they used utf8 byte strings instead). Not only has python chosen to burden itself with two string types, but with 3 they've swapped roles. This is certainly the first time I've had to decide on an encoding before writing simple text to a file. Of course we may end up with a better language, but it will be a worse(more complex) tool for many simple tasks. Using a complex writing with many glyphs costs effort no matter how you do it, but I just use ascii :( and it's still an effort. I find the differences in C/OS less hard to understand than why I need bytes(x,'encoding') everywhere I just used to use str(x). -old fart-ly yrs- Robin Becker From rhamph at gmail.com Sun Apr 13 12:09:58 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Sun, 13 Apr 2008 09:09:58 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> <32e2acc1-97cb-4911-bb0c-67965b5ff113@2g2000hsn.googlegroups.com> <7x8wzi7f9x.fsf@ruckus.brouhaha.com> Message-ID: <5e471fea-b70d-4e46-ae70-2a86d59a4190@v26g2000prm.googlegroups.com> On Apr 12, 6:58 pm, Steve Holden wrote: > Paul Rubin wrote: > > Steve Holden writes: > >> I believe you are making surmises outside your range of competence > >> there. While your faith in the developers is touching, the garbage > >> collection scheme is something that has received a lot of attention > >> with respect to performance under typical workloads over the years. > > > Really, Python's cyclic gc is quite crude and should be upgraded to > > something that doesn't fall into that quadratic behavior. There was > > some fairly detailed discussion of this in another thread last time > > the subject came up. > > I'll take your word for it. I discussed it not too long ago, but I can't seem to find the thread.. Basically, python's gen2 collections are to blame. You get a full (gen2) collection a linear number of times for a linear number of allocations, but the cost of each collection is also linear, giving you O(n**2) cost. I think it's fairly clear that it should not be that expensive. From a.ktechnology5 at yahoo.com Tue Apr 22 17:34:44 2008 From: a.ktechnology5 at yahoo.com (a.ktechnology5 at yahoo.com) Date: Tue, 22 Apr 2008 14:34:44 -0700 (PDT) Subject: New technology data storage. Get 2GB Free (Limited time offer) Message-ID: <1fca0ea5-abe3-4dda-aa2e-e4f9d59f28e5@59g2000hsb.googlegroups.com> Get free 2GB online web drive. Get a secure 2GB free online storage solution. Forget the hassles of CDs, floppies and tape drives for your data storage. Whether it is your tax return, music collection or irreplaceable digital photographs, you have the piece of mind that your data is stored in our high security data center. Save your files, documents, music collection online. You can share your stored documents with your friends and family. Store, share, stream, manage and access your files online easily. Protected against virus attacks or worms and other threats. Better, larger and cheaper than USB flash drive. Free offer is for limited time period. Hurry up! Visit now: http://www.aktechnology.net/data_storage.asp FARWARD THIS MESSAGE TO FRIENDS & FAMILY BECAUSE FREE ACCOUNTS ARE LIMITED. From kay.schluehr at gmx.net Sat Apr 5 09:01:28 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 5 Apr 2008 06:01:28 -0700 (PDT) Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> Message-ID: <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com> Aldo, when you confuse inheritance ( using an OO framework properly ) with monkey patching no one can draw much different conclusions than I did. I'm still very positive about the integration of code coverage tools with UT frameworks and of course I've nothing against adding a CLI. Actually *this* is a good reason to advance an existing framework and enable more components to be hooked in. But raving against unittest.py and anti-hyping it for mostly trivial reasons and with shallow reasoning has become a fashion. Now we see alternatives that do little more than what can be achieved by adding two abstract methods to the TestSuite base class and overwrite a few methods of the TestLoader base class ( maybe I'm wrong about it but I guess the discussion has become too heated to clarify this point using technical arguments ). I just felt it was a good opportunity to debunk this unittest.py anti- hype. I'm sorry it has gone too personal. Regards, Kay From darcy at druid.net Tue Apr 15 15:14:39 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Tue, 15 Apr 2008 15:14:39 -0400 Subject: How to have unittest tests to be executed in the order they appear? In-Reply-To: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> Message-ID: <20080415151439.7065a31a.darcy@druid.net> On Tue, 15 Apr 2008 12:02:48 -0700 (PDT) "Giampaolo Rodola'" wrote: > Hi there. > Is there a way to force unittest to run test methods in the order they > appear? Since they run in alphabetical order why not just rename them to the order you want them to run? Something like this: def test_010_z(self): def test_020_b(self): def test_030_d(self): Note the numbering scheme that allows tests to be added between the existing ones if necessary. However, do consider writing your tests so that order is irrelevant. If a test depends on a previous test running then it isn't a proprt self-contained test. For one thing, you can't run a single test that way if you wanted to. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From s0suk3 at gmail.com Thu Apr 17 12:19:32 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 09:19:32 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> Message-ID: On Apr 17, 10:54 am, colas.fran... at gmail.com wrote: > On 17 avr, 17:40, s0s... at gmail.com wrote: > > Out of sheer curiosity, why do you need thirty (hand-specified and > dutifully commented) names to the same constant object if you know > there will always be only one object? I'm building a web server. The many variables are names of header fields. One part of the code looks like this (or at least I'd like it to): class RequestHeadersManager: # General header fields Cache_Control = \ Connection = \ Date = \ Pragma = \ Trailer = \ Transfer_Encoding = \ Upgrade = \ Via = \ Warning = \ # Request header fields Accept = \ Accept_Charset = \ Accept_Encoding = \ Accept_Language = \ Authorization = \ ... Etc etc etc. At the end they'll all be assign to None. Then, when initialized, __init__() will the the string of headers, parse them, and use those variables shown above to assign to the header values. Of course a normal request won't include all of those headers, so the others will remain None. That's what I want. From dhong at gist.ac.kr Tue Apr 29 23:35:29 2008 From: dhong at gist.ac.kr (Dongpyo Hong) Date: Wed, 30 Apr 2008 15:35:29 +1200 Subject: swig -python can't find _xxx.dll for windows In-Reply-To: <61B007AA-8ED3-499F-B787-DB6F2511A124@gist.ac.kr> References: <61B007AA-8ED3-499F-B787-DB6F2511A124@gist.ac.kr> Message-ID: <4AEBEDF8-D283-45F0-BC93-110C9FF412C5@gist.ac.kr> Well, after several hours' googling I just found that Python for Windows only allow .pyd instead of .dll. When I just renamed .dll to .pyd, it just worked fine. But I don't still get the reason why. Anyone can explain this? --Dongpyo On Apr 30, 2008, at 12:00 PM, Dongpyo Hong wrote: > Dear all, > > I wrapped c++ code with swig, and made _xxx.dll file. > But, when I import xxx.py file from Python interpreter: import xxx > it keeps saying that "ImportError: No module named _xxx" > I checked sys.path and PATH environment. > > Why is that? Any explanation? > > --Dongpyo > ===== > Dongpyo Hong > Research Assistant > GIST U-VR Lab http://uvr.gist.ac.kr > http://uvr.gist.ac.kr/~dhong > Tel. +82-62-970-3157 (2279) > Fax. +82-62-970-2204 > Email. dhong at gist.ac.kr or dongpyo.hong at gmail.com > ===== > > > > > > ===== Dongpyo Hong Research Assistant GIST U-VR Lab http://uvr.gist.ac.kr http://uvr.gist.ac.kr/~dhong Tel. +82-62-970-3157 (2279) Fax. +82-62-970-2204 Email. dhong at gist.ac.kr or dongpyo.hong at gmail.com ===== -------------- next part -------------- An HTML attachment was scrubbed... URL: From exarkun at divmod.com Fri Apr 18 14:49:20 2008 From: exarkun at divmod.com (Jean-Paul Calderone) Date: Fri, 18 Apr 2008 14:49:20 -0400 Subject: py3k s***s In-Reply-To: <20080418183215.GC19281@deviL> Message-ID: <20080418184920.6859.2120221760.divmod.quotient.31835@ohm> On Fri, 18 Apr 2008 11:32:15 -0700, Nick Stinemates wrote: > [snip] > >Yo, no one here is a child Hi Nick, Actually, there are a number of young people on the list. So let's keep things civil and try to avoid using harsh language. Thanks! Jean-Paul From skanemupp at yahoo.se Sun Apr 20 16:27:26 2008 From: skanemupp at yahoo.se (globalrev) Date: Sun, 20 Apr 2008 13:27:26 -0700 (PDT) Subject: cherrypy-webapp-code? Message-ID: <31715060-fca3-4a03-b5c4-b6403315aa76@a23g2000hsc.googlegroups.com> anyone have a small cherrypy-webapp and are willing to post the code. could be a nonsense-app just wanna see some code. From bignose+hates-spam at benfinney.id.au Fri Apr 18 02:46:15 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Fri, 18 Apr 2008 16:46:15 +1000 Subject: How to have unittest tests to be executed in the order they appear? References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> <87zlru7le2.fsf@benfinney.id.au> <87fxtlwi03.fsf@benfinney.id.au> Message-ID: <87mynr4q4o.fsf@benfinney.id.au> Roy Smith writes: > Ben Finney wrote: > > > Surely, since "suddenly" implies you changed one small area of the > > code, that area of the code is the best place to look for what caused > > the failure. > > Sometimes it's the environment that's changed. Yes, I know, a good > unit test doesn't depend on the environment, but in real life, > that's sometimes difficult to achieve. Fair enough, I hadn't considered that case of "suddenly". In that case, I would recommend a change to the test *reporter*, so that the tests are still run in an arbitrary sequence, but the failures are reported in some desired sequence. -- \ ?Holy tintinnabulation, Batman!? ?Robin | `\ | _o__) | Ben Finney From steve at holdenweb.com Wed Apr 9 10:24:16 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 10:24:16 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> Message-ID: Victor Subervi wrote: > On Wed, Apr 9, 2008 at 1:14 AM, Gabriel Genellina > > wrote: > > > Thanks. I apparently am printing some holder for the image. I > stripped > > out > > most of it with this > > content[0][0] > > but then I am left with this: > > > > array('c', '\xff\xd8\xff\xe0\\0\x10JFI...) > > How do I extract an image from that? > > print content.tostring() > > > Now *that* gave me something that *looks* a lot more like an image from > a programmers perspective, but still no image... > ????JFIF... > Actually, it does not copy and paste well, but you can see it for the > moment here: > http://livestocksling.com/test/python/Shop/display_es2.py > So, how do I convert *that* to a real live image? > > > Or perhaps, replace that line with content.tofile(sys.stdout) > > > Printed nothing. > > > >> > print 'Content-Type: image/jpeg\r\n' > >> > print '\n' > >> > print content > >> > print '\n' > >> > cursor.close() > >> > > >> > test() > > >> > The commented out line gives me a leading less than sign...and > that?s > >> > it. What do? > > Try to understand now *why* you got a single character with your > previous > code. > > > No clue :/ > > BTW, for purposes of documentation, it appears that, when sending the > form with the image to the script that processes the form, the following > is inadvisable: > > form = cgi.FieldStorage() > pic1 = form.getfirst('pic1', '') > > This appears to work better: > > form = cgi.FieldStorage() > imgfile=open("pixel.gif",'rb') > pixel = imgfile.read() > pic1 = form.getfirst('pic1', pixel) > > because it gives a binary default. The string appears to screw things up. > Victor > Now all you have to do is what I told you in the first place, which is to remove the print statements before and after "print content". You are NOT generating HTML, you are generating a JPEG image. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From cousinstanley at gmail.com Mon Apr 28 23:37:22 2008 From: cousinstanley at gmail.com (Cousin Stanley) Date: Tue, 29 Apr 2008 05:37:22 +0200 (CEST) Subject: Python Math libraries - How to? References: Message-ID: > > Here is the arithmetic program I made that it worked before I added > the "import math" line. > > #volumen.py > # A program to compute the volume and surface area of a sphere > import math > > .... > NameError: global name 'pi' is not defined > .... >>> from math import * >>> >>> def surface( r ) : ... return 4 * pi * r ** 2 ... >>> def volume( r ) : ... return ( 4. / 3. ) * pi * r ** 3 ... >>> for n in range( 1 , 11 ) : ... s = surface( n ) ... v = volume( n ) ... print ' %2d .... %9.4f .... %9.4f ' % ( n , s , v ) ... -- Stanley C. Kitching Human Being Phoenix, Arizona From grahn+nntp at snipabacken.se Sun Apr 6 02:52:18 2008 From: grahn+nntp at snipabacken.se (Jorgen Grahn) Date: 6 Apr 2008 06:52:18 GMT Subject: Best way to check if string is an integer? References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> <0fdd2825-6d1c-4380-a79a-a7aac119f002@a5g2000prg.googlegroups.com> <96d2fe53-96bf-43d8-a58d-8269846bf0df@b64g2000hsa.googlegroups.com> Message-ID: On Sat, 5 Apr 2008 22:02:10 -0700 (PDT), Paddy wrote: > On Apr 6, 5:18 am, ernie wrote: >> On Apr 6, 10:23 am, Roy Smith wrote: >> > int(s) and catching any exception thrown just sounds like the best way. >> >> Another corner case: Is "5.0" an integer or treated as one? > In Python, 5.0 is a float "5.0" is a string, and you need to make your > mind up about what type you want "5.0" to be represented as in your > program and code accordingly. int('5.0') raises an exception rather than rounding or truncating to 5. That is probably what most people want, and it seems the original poster wanted that, too. I always use int(n). If I ever find a situation where I want another syntax for integers for some specialized use, I'll approach it as a normal parsing problem and use regexes and so on -- wrapped in a function. The problem becomes clearer if you look at floats. There are many different ways to write a float[0], and Python parses them better and faster than you and me. /Jorgen [0] There would have been more if Python had supported hexadecimal floating-point literals, like (I believe) C does. -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! From robert.kern at gmail.com Thu Apr 10 17:38:29 2008 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 10 Apr 2008 16:38:29 -0500 Subject: wrapping C functions in python In-Reply-To: <1C8AE033-9B8F-4514-8C52-3462CF6447A2@gmail.com> References: <54b165660804091322w690e5e64x85c3d8f082b411b2@mail.gmail.com> <54b165660804091355m1326f7c0g1a5eebe3d6b5a1df@mail.gmail.com> <1C8AE033-9B8F-4514-8C52-3462CF6447A2@gmail.com> Message-ID: Paul Anton Letnes wrote: > Brian and Diez: > > First of all, thanks for the advice. > > Brian: > > I have installed NumPy and SciPy, but I can't seem to find a wavelet > transform there. Well, you will definitely want to use numpy arrays instead of lists or the standard library's arrays to communicate with your C code. ctypes with numpy is probably more straightforward than using SWIG with any of the three. http://www.scipy.org/Cookbook/Ctypes You may also want to check out pywt: http://pypi.python.org/pypi/PyWavelets/ -- 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 From kar1107 at gmail.com Wed Apr 30 19:20:58 2008 From: kar1107 at gmail.com (Karthik Gurusamy) Date: Wed, 30 Apr 2008 16:20:58 -0700 (PDT) Subject: ssh References: <867f5bc7-3748-4303-9f29-9d8044f0d315@m3g2000hsc.googlegroups.com> Message-ID: <9216be73-c835-4eaf-b90b-b7783f5a4770@r9g2000prd.googlegroups.com> On Apr 29, 6:29 pm, gert wrote: > Is this the best way to use ssh ? > How can i use ssh keys instead of passwords ? > I dont understand what happens when pid does not equal 0 , where does > the cmd get executed when pid is not 0 ? > How do you close the connection ? > > #http://mail.python.org/pipermail/python-list/2002-July/155390.html > import os, time > > def ssh(user, rhost, pw, cmd): > pid, fd = os.forkpty() > if pid == 0: > os.execv("/bin/ssh", ["/bin/ssh", "-l", user, rhost] + cmd) > else: > time.sleep(0.2) > os.read(fd, 1000) > time.sleep(0.2) > os.write(fd, pw + "\n") > time.sleep(0.2) > res = '' > s = os.read(fd, 1) > while s: > res += s > s = os.read(fd, 1) > return res > > print ssh('username', 'serverdomain.com', 'Password', ['ls -l']) If ssh is being used interactively (such as being prompted from password), look into pexpect module. http://www.noah.org/wiki/Pexpect Else try the subprocess module (or even commands module); these are lot simpler to program than the more primitive os.execv/os.read/write. If you have already setup keys, ssh should work passwordless whether it's interactive or not (AFAIK). Karthik From steve at holdenweb.com Mon Apr 7 16:58:42 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 07 Apr 2008 16:58:42 -0400 Subject: Data structure recommendation? In-Reply-To: <663744510804071339g639bfdccl63de8be66fe52df1@mail.gmail.com> References: <663744510804071339g639bfdccl63de8be66fe52df1@mail.gmail.com> Message-ID: Steven Clark wrote: > Hi all- > > I'm looking for a data structure that is a bit like a dictionary or a > hash map. In particular, I want a mapping of floats to objects. > However, I want to map a RANGE of floats to an object. > > This will be used for timestamped storage / lookup, where the float > represents the timestamp. > get(x) should return the object with the "newest" (biggest) timestamp > y <= x, if it exists. > Example: > > foo = Foo() > > foo.get(1.5) > -> None > foo.put(1.3, 'a') > foo.put(2.6, 'b') > foo.get(1.5) > -> 'a' > foo.get(7.8) > -> 'b' > foo.put(5.0, 'c') > foo.get(7.8) > -> 'c' > > In otherwords, by the end here, for foo.get(x), > x < 1.3 maps to None, > 1.3 <= x < 2.6 maps to 'a', > 2.6 <= x < 5.0 maps to 'b', > 5.0 <= x maps to 'c'. > > I know that foo.get() will be called many times for each foo.put(). Is > there any way to achieve O(1) performance for foo.get(), maybe via > some kind of hash function? Or is the best thing to use some kind of > binary search? > I believe the best way to implement this would be a binary search (bisect?) on the actual times, which would be O(log N). Though since they are timestamps they should be monotonically increasing, in which case at least you don't have to go to the expense of sorting them. "Some kind of hash function" won't hack it, since the purpose of a hash function is to map a large number of (possibly) evenly-distributed (potential) keys as nearly as possible randomly across a much smaller set of actual values. You might try messing around with reducing the precision of the numbers to home in on a gross region, but I am not convinced that does anything other than re-spell binary search if carried to extremes. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From ivan.illarionov at gmail.com Tue Apr 22 17:02:09 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Tue, 22 Apr 2008 14:02:09 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <965898d3-5bcf-4525-9f1c-e938a5f92117@m44g2000hsc.googlegroups.com> On 22 ???, 14:25, azrael wrote: [....] > This hurts. Please give me informations about realy famous > aplications. What do you mean by "really famous"? Information is here: http://www.python.org/about/quotes/ Are YouTube and Google famous enough? -- Ivan From sturlamolden at yahoo.no Fri Apr 11 16:31:42 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 11 Apr 2008 13:31:42 -0700 (PDT) Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> Message-ID: <3efcdcb2-1506-41a0-b148-1e1a60581032@h1g2000prh.googlegroups.com> On Apr 11, 8:35 pm, Steve Holden wrote: > wxDesigner. IMHO, wxFormBuilder is better. http://wxformbuilder.org/ http://preview.tinyurl.com/6l8wp4 From petr.jakes at tpc.cz Thu Apr 17 18:11:36 2008 From: petr.jakes at tpc.cz (=?UTF-8?Q?Petr_Jake=C5=A1?=) Date: Fri, 18 Apr 2008 00:11:36 +0200 Subject: User-defined Exceptions: is self.args OK? Message-ID: Hi, I have posted this via google.groups, but I have discovered many of you are filtering such a postings. So this is my second try from the mail client. I am trying to dig through User-defined Exceptions. chapter 8.5 in http://docs.python.org/tut/node10.html I would like to know, if is it OK to add following line to the __init__ method of the TransitionError class? self.args = (self.previous, self.next, self.message) If I do not add this argument to the class, object created by exception does not include values from self.previous, self.next, self.message attributes in the print traceback.format_exc() for example: ===== 8< snipp 8< ======== class TransitionError(Error): def __init__(self, previous, next, message): self.previous = previous self.next = next self.message = message try: raise TransitionError('previous error %s' % 'fooo', 'nextBar', 'this is foo bar message') except TransitionError, err: print err print err.args import traceback, sys print sys.exc_info() traceback.print_exc() ===== 8< snipp 8< ======== Thanks for your replies. Petr Jakes -------------- next part -------------- An HTML attachment was scrubbed... URL: From duncan.booth at invalid.invalid Wed Apr 9 09:32:55 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 9 Apr 2008 13:32:55 GMT Subject: String manipulation questions References: <8cd7b477-6fc6-47c5-b2eb-e2a4f284f7b2@m3g2000hsc.googlegroups.com> Message-ID: goldtech wrote: > Question1: The replace method - If a string does not have the target > replacement "newstring", then newline equals oldstring? Ie. oldstring > is not changed in any way? Seems to be what I observe but just want to > confirm this. Yes. > > Question2: I'm using "line.find(newstring) != -1..." because I want > to print when a replacement happens. Does "line.replace..." report > indirectly somehow when it replaces? Just do the line.replace() and then test for a change. Question 3 (which I'm sure you meant to ask really) ... No, you shouldn't be using a while loop here. Use a for loop and the enumerate builtin: for counter, line in enumerate(fileIN): newline = line.replace(oldstring, newstring) if newline != line: print 'match at line', counter+1 fileOUT.write(newline) From gpk at kochanski.org Sun Apr 6 13:59:17 2008 From: gpk at kochanski.org (Greg Kochanski) Date: Sun, 06 Apr 2008 18:59:17 +0100 Subject: Tweaking PEP-234 to improve Duck Typing Message-ID: <47F90F75.90804@kochanski.org> Id'a like to raise an issue that was partially discussed in 2006 ( http://groups.google.co.uk/group/comp.lang.python/browse_thread/thread/1811df36f2a131fd/435ba1cae670aecf?lnk=st&q=python+iterators+duck+typing#435ba1cae670aecf ) with the half-promise that it would be revisited before Python 3000. Now's the last chance. What is Duck Typing? Ultimately, the goal is that if you do something stupid, Python will give you a big fat error message fairly soon after the stupid code was executed. Without effective duck typing, we'd be forced to put in lots of test code everywhere, something like assert isinstance(x, list) Doing so would be bad because our python would become cluttered and less able to be polymorphic/reused. Nuff said. Now, where does duck typing fail in modern Python? In this case: def foo(x): for i in x: doSomething(i) for i in x: somethingElse(i) Function foo() is unsafe as part of any API because you never know whether someone is going to pass it a list or an iterator. For me, doing scientific programming, this is a *very* common use case. doSomething() may collect statistics or look for bad data, then somethingElse() does the main computation. Now, if foo() is somehow passed an iterator, the second loop will fail silently, leading to much hair pulling and gnashing of teeth. Some might say "serves you right for making a mistake!", but I've always suspected that such people go around insulting victims of traffic accidents. Of *course* there are ways to work around the problem. Using Java is one, adding assert statements is another, writing detailed docstrings is a third. However, none are nearly as good as duck typing. Adding "x=list(x)" near the top of the function should work, but at a horrible cost in efficiency if it's a big list. It seems that the 2006 discussion barely missed the right solution: 1) Create a new standard exception IteratorExhausted; it will be a subclass of StopIteration. 2) StopIteration is raised when the iterator runs out of data. If it.next() is called again, then IteratorExhausted should be raised. 3) For loops will be set to trap IteratorExhausted and raise and error (perhaps raise a TypeError, "Iterator used in two for loops"). POSITIVE IMPACT: This will reduce the transition difficulties to python 3.0 due to changes of zip() and other functions from lists to iterators. Any code of the form foo(zip(a,b)) or foo(map(...)) or foo(filter(...)) or a few other things would become silently wrong in python 3.0. With this modification, it will be noisy wrong. (Much better!) Since IteratorExhausted is a subclass of StopIteration, normal uses of StopIteration will be unaffected. Code that sticks to the current PEP-234 will continue to work absolutely unchanged. NEGATIVE IMPACT: Code in the form below will fail noisily if it was intended to be used with current PEP-234 iterators and if the upper loop does not terminate early. (But it will work correctly if handed a list.) def bar(x): for i in x: if someThing(i): break for i in x: anotherThing(i) However, note that this code will give different results depending if it is passed an iterator or a list, so it's somewhat dangerous anyway. I suspect this is a rare case compared to all the python 3.0 upheaval. However, it can be fixed fairly easily and efficiently by simply putting a try...except statement around the second "for" loop. I believe that it will add no silent failures to 2.5 code run on Python3.0 and will convert many silent failures into noisy failures. In my book, that's a Good Thing. Overall, I believe it will reduce the pain of Python 3.0 and increase the uptake rate. Comments appreciated. (Not that I could avoid them, anyway!) From victorsubervi at gmail.com Mon Apr 14 09:29:57 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Mon, 14 Apr 2008 08:29:57 -0500 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> Message-ID: <4dc0cfea0804140629rf1ac100m27ad9d0456cbbe2d@mail.gmail.com> Thanks to all, especially Gabriel. The base64 is a good idea, but you state a definite problem. I will look at your code at home (offline)...thank you very much! It looks like the kicker is this line here: %s" % (picid, cgi.escape(title)) Now, why didn?t you share that before????? I can see how calling a separate script like that would work! Again, you should have shared that before. How was I to think of that clever trick from the bare information you gave me earlier?? Steve, thank you for all your help, but do overcome your temper :)) Victor On Sun, Apr 13, 2008 at 7:05 AM, Steve Holden wrote: > Jason Scheirer wrote: > [...] > > > > There _is_ a way to embed image data in HTML that is supported by > > every major browser. It is ugly. Using the RFC 2397 (http:// > > www.ietf.org/rfc/rfc2397) spec for data URLs you could go > > > > '' % base64.b64encode(image_data) > > > > Obviously you need to import the base64 module somewhere in your code > > and base64-encoded data is about a third larger than it would be > > otherwise, so embedding anything particularly large is going to be a > > huge pain and affect page load times pretty badly. > > This is hardly likely to help someone who hasn't yet grasped the concept > of referencing graphics and prefers to write database output to disk to > serve it statically. But who knows, maybe it will ... > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From szport at gmail.com Thu Apr 3 09:53:12 2008 From: szport at gmail.com (Zaur Shibzoukhov) Date: Thu, 3 Apr 2008 17:53:12 +0400 Subject: Application of "with" statement in py3k. Property defining/redefining. Message-ID: http://szport.blogspot.com/2008/04/application-of-with-statement-in-py3k.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From aaron.watters at gmail.com Wed Apr 30 16:04:33 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 30 Apr 2008 13:04:33 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> <4814B904.1070804@v.loewis.de> Message-ID: > I do not argue that Python's default GC parameters must change -- only > that applications with lots of objects may want to consider a > reconfiguration. I would argue that changing the GC to some sort of adaptive strategy should at least be investigated. Having an app which doesn't need gc spending most of its time doing gc is annoying, to say the least. Of course any such change should be tested and analysed thoroughly before it goes into Python 2.6.1 or whatever and it would be great if there were several alternatives considered and compared. Hmmm. I think this would make an excellent computer science Master's Thesis topic. Anybody looking for a topic? -- Aaron Watters ==== http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=use+while+fresh From gagsl-py2 at yahoo.com.ar Mon Apr 21 02:13:58 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 03:13:58 -0300 Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: En Fri, 18 Apr 2008 12:58:56 -0300, Aaron Watters escribi?: > Why is the migration to py3k a concern? > For example I have libraries which use string%dictionary > substitution where the dictionary is actually an object > which emulates a dictionary. The __getitem__ for > the object can be very expensive and is only called when > needed by the string substitution. > > In py3k string%dictionary is going away. Why? > I have no idea. But not soon. It's not listed in PEP 3100 and according to this message http://mail.python.org/pipermail/python-3000/2008-April/013094.html %s formatting will not disappear until Python 3.3 You have plenty of time to evaluate alternatives. Your code may become obsolete even before 3.3 is shipped. -- Gabriel Genellina From floris.bruynooghe at gmail.com Sun Apr 6 12:16:52 2008 From: floris.bruynooghe at gmail.com (Floris Bruynooghe) Date: Sun, 6 Apr 2008 09:16:52 -0700 (PDT) Subject: @x.setter property implementation Message-ID: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> Hello I found out about the new methods on properties, .setter() and .deleter(), in python 2.6. Obviously that's a very tempting syntax and I don't want to wait for 2.6... It would seem this can be implemented entirely in python code, and I have seen hints in this directrion. So before I go and try to invent this myself does anyone know if there is an "official" implementation of this somewhere that we can steal until we move to 2.6? Cheers Floris From kyosohma at gmail.com Mon Apr 7 08:54:19 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Mon, 7 Apr 2008 05:54:19 -0700 (PDT) Subject: Wxpython. Is it possible to change layout in a running application? Selfmade listbox References: <716c0f27-bca6-4642-a8ec-cdbb0b23e6e8@h1g2000prh.googlegroups.com> Message-ID: <105355bb-2d56-491e-8764-e4c34a0de8c5@d45g2000hsc.googlegroups.com> On Apr 7, 6:50 am, Soren wrote: > Hi, > > Id like to make my own special listbox.. I want to able (at the push > of a button) to add another item to my special listbox... each item is > a panel with a label, some buttons and maybe a text control. > > I've tried adding a new panel object with the stuff i want to the > sizer i'm using for my listbox (which is a panel which can contain > other panels)... and then run update() and refresh() on everything... > But it doesn't work.. i see a panel appearing, but it's just a small > square in the corner of my "listbox" panel, and it only works the > first time... nothing new appears when I push the button again. > > Is it at all possible to do this? Has anyone created something > similar? Does anyone know what i'm doing wrong? > > Thanks, > Soren I'm pretty sure it's possible, but as Iain pointed out, it's hard to guess what you're doing wrong without some code. Try making a sample app that demonstrates the issue: http://wiki.wxpython.org/MakingSampleApps Also, you will probably receive more help at the wxPython specific list, found here: http://wxpython.org/maillist.php HTH Mike From mav at cuma.polymath-solutions.lan Wed Apr 2 14:32:54 2008 From: mav at cuma.polymath-solutions.lan (Maurizio Vitale) Date: Wed, 02 Apr 2008 18:32:54 GMT Subject: non-terminating regex match References: <65i0i3F2embp3U2@mid.uni-berlin.de> Message-ID: Marc 'BlackJack' Rintsch writes: > On Wed, 02 Apr 2008 16:01:59 +0000, Maurizio Vitale wrote: > >> And yes, I'm a total beginner when it comes to Python, but it seems >> very strange to me that a regex match on a finite length string >> doesn't terminate > > It does terminate, you just don't wait long enough. Try it with fewer > characters and then increase the identifier character by character and > watch the time of the runs grow exponentially. > Ok. Now, my assumption was that re.compile would produce a DFA (or NFA) and the match would then being linear in the size of the string. Apparently this is not the case, so is there anything that can be done to the regex itself to make sure that whatever re.compile produces is more efficient? Thanks, Maurizio From tnelson at onresolve.com Tue Apr 22 13:52:57 2008 From: tnelson at onresolve.com (Trent Nelson) Date: Tue, 22 Apr 2008 10:52:57 -0700 Subject: Python script to automate use of Google Translate? (or other translator) In-Reply-To: References: Message-ID: <87D3F9C72FBF214DB39FA4E3FE618CDC6E243C7BF2@EXMBX04.exchhosting.com> > > I have the need to occasionally translate a single word > > programatically. Would anyone have a Python script that > > would let me do this using Google (or another) translation > > service? As a matter of fact, yes, I do! This happens to be my most favourite piece of Python code I've ever written, too... In [1]: from translate import * In [2]: translate('French', 'The quick brown fox jumped over the lazy dog.') Le renard brun rapide a saut? par-dessus le chien paresseux. In [3]: translate('German', 'The quick brown fox jumped over the lazy dog.') Der schnelle braune Fuchs sprang ?ber den faulen Hund. In [4]: translate('Spanish', 'The quick brown fox jumped over the lazy dog.') El zorro marr?n r?pido salt? sobre el perro perezoso. And translate.py: import sys from urllib import urlopen, urlencode from BeautifulSoup import BeautifulSoup url = 'http://babelfish.altavista.com/tr' languages = { 'French' : 'en_fr', 'German' : 'en_de', 'Italian' : 'en_it', 'Spanish' : 'en_es', 'Russian' : 'en_ru', 'Portuguese': 'en_pt', 'Dutch' : 'en_nl', 'Japanese' : 'en_ja', } def translate(lang, text): kwds = { 'trtext' : text, 'lp' : languages[lang]} soup = BeautifulSoup(urlopen(url, urlencode(kwds))) print soup.find('div', style='padding:10px;').string if __name__ == '__main__': translate(sys.argv[1], sys.argv[2]) Enjoy! Regards, Trent. From sturlamolden at yahoo.no Mon Apr 21 12:34:39 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Mon, 21 Apr 2008 09:34:39 -0700 (PDT) Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B52DE.8070105@holdenweb.com> <2be5608d-560d-4712-b104-f2341a7fa569@t63g2000hsf.googlegroups.com> Message-ID: On Apr 21, 4:09 am, "Gabriel Genellina" wrote: > I'm not sure if this will help the OP at all - going into a world of dangling pointers, keeping track of ownership, releasing memory by hand... One of the good things of Python is automatic memory management. Ensuring that all references to an object are released (the standard Python way) is FAR easier than doing all that by hand. The owner was complaining he could not manually release memory using del, as if it was Python's equivalent of a C++ delete[] operator. I showed him how it could be done. I did not say manual memory management is a good idea. From carlwuhwdmckay at gmail.com Sat Apr 26 09:34:36 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:34:36 -0700 (PDT) Subject: garmin keygen Message-ID: <8c636918-323e-4894-8b0c-8b381c627816@56g2000hsm.googlegroups.com> garmin keygen http://cracks.00bp.com F R E E C R A C K S From jason.scheirer at gmail.com Fri Apr 18 21:34:42 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Fri, 18 Apr 2008 18:34:42 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <0ebcf70f-c6d6-4ee7-9ef8-7cd2221ef906@t12g2000prg.googlegroups.com> <879750f6-614a-45ed-8f18-f0b7ae5ea9a2@26g2000hsk.googlegroups.com> Message-ID: <5e6abd62-56a6-4a8f-b4b9-8e3eb160c733@p39g2000prm.googlegroups.com> On Apr 18, 4:19 pm, Kay Schluehr wrote: > On 18 Apr., 23:09, Matimus wrote: > > > The reason it doesn't work is that you are unpacking the dictionary > > with **, and you have done nothing to define any keys or define a > > length. > > This is a non-issue. The class derives from dict; it has all the > desired attributes. It is also not a problem in particular because > these properties are not requested by format ( at least not in the > code I have examined which was admittedly just a critical section that > caused the exception ). > > > Adding to that... don't worry about py3k. Nobody is forcing you to > > switch. In fact, you are encouraged not to until you are comfortable. > > Py3k won't _break_ your code. You wrote the code for Python 2.x use it > > in 2.x. Python 2.x probably has a good 5-10 years remaining. > > These advices start to get annoying. > > Software hardly ever exists in isolation for the sake of the beauty of > the algorithm but is supplementary to a large framework/engine/ > library. So if e.g. Django switches to 3 everyone who works with it > has to switch sooner or later as well or lose track otherwise, no > matter how long Python 1.5.2 or Python 2.5.2 or whatever version will > be maintained. If Pythons code base becomes fragmented it will be > harmful and affect almost everyones work. This has happened before, though -- I remember the pain of moving to 2.0 from the 1.5 branch way back when, and it wasn't getting my 1.5 code to work in 2.0, it was being jealous of all the cool features of 2.0 that I had to wait to get. I was working in production with 1.5 in 2000 and all the libraries available for Python gradually stopped supporting 1.5 to pick up interesting 2.0 features that actually made them easier to work with, and new libraries all began to assume you were using a 2.0+ Python version because that's what was current. By 2003-2004 everyone I knew had switched over to 2.0, but by then I had had nearly 5 years to port my legacy 1.5 code to 2.0, take advantage of the 2.0 version's features, and do plenty of testing of my 1.5 codebase in 2.0 before I switched my production systems over. Not to mention the fact that plenty of warning was offered BEFORE 2.0 was released and 1.5 was not abruptly ended, but gradually phased out until only the teeniest far ends of the long tail were using it. The 2.6->3.0 process is going to be even less of a pain than the 1.5->2.0 conversion, which was not hard at all going forward into it. You may not want to switch, but by the time you decide to it will be pretty easy to move on -- the extreme opposite reality being your application will be so frozen that both your Python version and your codebase will be fossils, left to hum on completely unchanged on some forgotten server like so much other legacy code. From fetchinson at googlemail.com Tue Apr 15 23:04:51 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Tue, 15 Apr 2008 20:04:51 -0700 Subject: Interesting timing issue I noticed In-Reply-To: References: Message-ID: > I've written up a stripped down version of the code. I apologize for the bad > coding; I am in a bit of a hurry. > > import random > import sys > import time > > sizeX = 320 > sizeY = 240 > borderX = 20 > borderY = 20 > > # generates a zero matrix > def generate_zero(): > matrix = [[0 for y in range(sizeY)] for x in range(sizeX)] > return matrix > # fills zero matrix > def fill_matrix(in_mat): > mat = in_mat > for x in range(sizeX): > for y in range(sizeY): > mat[x][y] = random.randint(1, 100) > return mat > ###################################################################### > # COMPUTES ONLY A PART OF THE ARRAY > def back_diff_one(back_array, fore_array, box): > diff_array = generate_zero() > > start = time.time() > for x in range(sizeX): > for y in range(borderY): > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > for y in range((sizeY - borderY), sizeY): > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > for y in range(borderY, (sizeY - borderY)): > for x in range(borderX): > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > for x in range((sizeX - borderX), sizeX): > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > # tracks object > if (len(box) != 0): > for x in range(box[0], box[2]): > for y in range(box[1], box[3]): > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > print "time one inside = " + str(time.time() - start) > return diff_array > ###################################################################### > # COMPUTES EVERY ELEMENT IN THE ARRAY > def back_diff_two(back_array, fore_array): > diff_array = generate_zero() > start = time.time() > for y in range(sizeY): > for x in range(sizeX): > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > end = time.time() > print "time two inside = " + str(end - start) > return diff_array > ###################################################################### > # CODE TO TEST BOTH FUNCTIONS > back = fill_matrix(generate_zero()) > fore = fill_matrix(generate_zero()) > box = [20, 20, 268, 240] > start1 = time.time() > diff1 = back_diff_one(back, fore, box) > print "time one outside = " + str(time.time() - start1) > start2 = time.time() > diff2 = back_diff_two(back, fore) > print "time one outside = " + str(time.time() - start2) > > Here are some results from several test runs: > > time one inside = 0.0780000686646 > time one outside = 0.125 > time two inside = 0.0780000686646 > time two outside = 0.141000032425 > >>> ================================ RESTART > ================================ > >>> > time one inside = 0.0629999637604 > time one outside = 0.125 > time two inside = 0.0789999961853 > time two outside = 0.125 > >>> ================================ RESTART > ================================ > >>> > time one inside = 0.0620000362396 > time one outside = 0.139999866486 > time two inside = 0.0780000686646 > time two outside = 0.125 > >>> ================================ RESTART > ================================ > >>> > time one inside = 0.0780000686646 > time one outside = 0.172000169754 > time two inside = 0.0789999961853 > time two outside = 0.125 > >>> ================================ RESTART > ================================ > >>> > time one inside = 0.0780000686646 > time one outside = 0.125 > time two inside = 0.0780000686646 > time two outside = 0.125 > >>> ================================ RESTART > ================================ > >>> > time one inside = 0.0620000362396 > time one outside = 0.155999898911 > time two inside = 0.0780000686646 > time two outside = 0.125 > >>> ================================ RESTART > ================================ > >>> > time one inside = 0.077999830246 > time one outside = 0.125 > time two inside = 0.077999830246 > time two outside = 0.125 > >>> ================================ RESTART > ================================ > >>> > time one inside = 0.0780000686646 > time one outside = 0.171000003815 > time two inside = 0.077999830246 > time two outside = 0.125 > >>> ================================ RESTART > ================================ > >>> > time one inside = 0.0629999637604 > time one outside = 0.18799996376 > time two inside = 0.0620000362396 > time two outside = 0.125 > > Why is a large percentage of the time, the execution time for the > (ostensibly smaller) first loop is actually equal to or LARGER than the > second? First of all, your method of timing is not the best. Use the timeit module instead: http://docs.python.org/lib/module-timeit.html Second of all the number of subtractions is not that different between the two variants of your functions. back_diff_one does 75360 subtractions per call while back_diff_two does 76800, these two numbers are almost the same. It's true that back_diff_one first only calculates a part of the arrays but after "# tracks object" you do a bunch of more substractions that will make up the total count. HTH, Daniel From aguirre.adolfo at gmail.com Mon Apr 28 22:58:42 2008 From: aguirre.adolfo at gmail.com (aguirre.adolfo at gmail.com) Date: Mon, 28 Apr 2008 19:58:42 -0700 (PDT) Subject: Python Math libraries - How to? References: Message-ID: <29c9735b-46fc-4650-b82a-1147a3efb2ad@c58g2000hsc.googlegroups.com> Thank you :-), I?ll do Adolfo > > pi is not a global name. When you do "import math",you aren't adding > everything to the name space, you are just telling python that you are > going to be using that file. You then refer to it as math.*, such as > "math.pi", or "math.pow(r,3)". To use it the way you want to, you > would have to do "from math import pi" instead of "import math" From __peter__ at web.de Wed Apr 30 06:17:08 2008 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Apr 2008 12:17:08 +0200 Subject: File IO Issues, help :( References: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> <1fd8deae-1ed4-493c-a508-06c528c4ee1f@r66g2000hsg.googlegroups.com> Message-ID: Dennis Lee Bieber wrote: > On Tue, 29 Apr 2008 08:35:46 +0200, Peter Otten <__peter__ at web.de> > declaimed the following in comp.lang.python: > > >> jsfile.truncate(0) >> jsfile.seek(0) >> > I'd suggest first doing the seek to start, then do the truncate I usually overwrite the file, and that shows. Is there a usecase where truncate() with an argument actually makes sense? Peter From noname9968 at gmail.com Fri Apr 4 14:46:48 2008 From: noname9968 at gmail.com (Alex9968) Date: Fri, 04 Apr 2008 22:46:48 +0400 Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? In-Reply-To: References: Message-ID: <47F67798.3060401@gmail.com> Nebur wrote: > No, I can't reproduce it, and I don't know whom to blame (Pydev? > Eclipse ? The File System ? A Virus that only 2 times in half a year > deletes a single file I'm busy working with, and seems to do nothing > else? Myself beeing schizophrenic ??) A virus created to remind you 2 times in half a year of the importance of backup operations ;-) . I'm joking. I don't know what is this, but I'm interested. Because my files won't be restorable from version control :-( From ewertman at gmail.com Sun Apr 20 11:35:57 2008 From: ewertman at gmail.com (Eric Wertman) Date: Sun, 20 Apr 2008 08:35:57 -0700 (PDT) Subject: Alternate indent proposal for python 3000 Message-ID: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> I was considering putting together a proposal for an alternate block syntax for python, and I figured I'd post it here and see what the general reactions are. I did some searching, and while I found a lot of tab vs space debates, I didn't see anything like what I'm thinking of, so forgive me if this is a very dead horse. Generally speaking, I like the current block scheme just fine. I use python on a daily basis for system administration and text parsing tasks, and it works great for me. >From time to time, though, I find myself needing a language for server- side includes in web pages. Because of the need to indent (and terminate indents), python seems an awkward choice for this, and it's easy for me to see why php and perl are more popular choices for this kind of task. Perhaps this is just my perception though. I feel that including some optional means to block code would be a big step in getting wider adoption of the language in web development and in general. I do understand though, that the current strict indenting is part of the core of the language, so... thoughts? From fairwinds at eastlink.ca Mon Apr 7 23:30:15 2008 From: fairwinds at eastlink.ca (David Pratt) Date: Tue, 08 Apr 2008 00:30:15 -0300 Subject: Help replacing os.system call with subprocess call In-Reply-To: <47FA3D2C.2010504@eastlink.ca> References: <47F9B1D1.4090701@eastlink.ca> <47F9C764.9070401@mattnordhoff.com> <47FA23E7.7040809@eastlink.ca> <47FA2B72.9050802@mattnordhoff.com> <47FA3D2C.2010504@eastlink.ca> Message-ID: <47FAE6C7.5010804@eastlink.ca> Hi Matt. My apologies, I was away a good part of the day and evening today. Here are the numbers for the different methods: original os.system call: 29.685759 s buffered stdout call: 213.370982 s (with 1mb buffer) direct to stdout call: 33.378756 s The second method worked great and is essentially equivalent in execution time to original call :-). This has got me smiling. Many thanks Matt for your help, particularly working through the second example that provided equivalent speed. Regards, David David Pratt wrote: > Hi Matt. Many thanks. Sorry I had not seen your second post. I'll give > this a try and time the completion to compare the differences and post > back later today to show os.system, buffered imput and using a file > directly for stdout. > > Regards, > David > > Matt Nordhoff wrote: >> David Pratt wrote: >>> Hi David and Matt. I appreciate your help which has got me moving >>> forward again so many thanks for your reply. I have been using >>> subprocess.Popen a fair bit but this was the first time I had to use >>> subprocess to capture large file output. The trouble I was having was >>> with the process would just hang. Chunking was the solution. I guess I >>> assumed this would be taken care of in the internals. >>> >>> Overall, I wish subprocess had some better documentation since it is >>> definitely not a drop in replacement for os.system. In other >>> circumstances I am using subprocess.call() for simple calls which works >>> fine. >>> >>> The speed of this solution is slower than os.system. Would a queue of >>> some kind be needed to speed this up? Has anyone implemented something >>> like this? Many thanks. >>> >>> Regards, >>> David >> Did you see my second message? That should help performance. If not, I'm >> totally out of my depth and have no idea at all. Sorry. >> >> (How much slower? 10%? 200%?) From castironpi at gmail.com Tue Apr 1 16:21:17 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Tue, 1 Apr 2008 13:21:17 -0700 (PDT) Subject: python persistence References: <8b1723d9-67c8-4fe5-b07b-22b0b9311519@8g2000hsu.googlegroups.com> <7f58b5f4-3195-472c-b307-dec71b12aaa8@y21g2000hsf.googlegroups.com> <44f04bf3-4edc-4cb4-9e54-fe51b5e591bc@e39g2000hsf.googlegroups.com> <80d1731d-a3c6-4fce-81fd-9c3f3537e59b@d21g2000prf.googlegroups.com> <5386cf08-c155-4fbb-8373-dbbb9829a9e7@m3g2000hsc.googlegroups.com> <3c27b270-e593-4f2a-b881-68126319760c@8g2000hsu.googlegroups.com> <7d71e294-2b13-4be0-948e-2fe0e4bbe7db@f63g2000hsf.googlegroups.com> Message-ID: On Apr 1, 11:34?am, "Gabriel Genellina" wrote: > En Tue, 01 Apr 2008 08:47:33 -0300, escribi?: > > >> >>>> c['0']= type('None',(),{}) > >> > Traceback (most recent call last): > >> > pickle.PicklingError: Can't pickle : it's not > >> > found as __main__.None > > >> Don't do that then. Or use the available pickle hooks to customize how ? > >> such classes may be pickled. All persistence mechanisms have ? > >> limitations. > > > I don't see a problem with that; except that binaries come from > > disks. ?You could have a Python session that runs entirely on disks + > > the ALU. > > (ALU? Do you mean CPU?) I don't understand this. Most programs are read ? > ?from disk. Most data is read from disk. > > > I want to know if any, and correct me here, simple > > modification can store live objects. ?I call a.append(it) and the > > memory update takes place on disk instead. > > Using ZODB, a.append(it) would mark `a` as dirty. When you latter commit ? > the transaction, it is stored back on disk. > > > If you require that all objects referenced by on-disk objects be on- > > disk, that's an easy workaround. > > ZODB already does that. It's pretty close, but the database connection can get bulky. If you had: _______________________ | ______________________ |File | PyOb1 | PyOb2 | .. | | |_______|_______|______| |_______________________ on disk, updating the reference counts and attributes would take a long time, but it's just right for some core applications. Strictly, I'm not in the "real" programming world, so if it's just a few free steps to a database then I'm speculating. If it's not, then writing database code needlessly complicates programs in some cases. A default implementation might even take an explicit destroy statement, essentially being a run-time swap file or random-access pickles. A possibility is to launch a manager in a separate process, so authors don't have to bother with writeback. I'm actually almost looking at off-loading protocols on this one. Cache is guaranteed to be up to date, so cache a file in memory, and manipulate it so it has Python bits. The object comes to survive the program. Call stack is still in volatile. > Using ZODB, a.append(it) would mark `a` as dirty. When you latter commit > the transaction, it is stored back on disk. Python changes are committed on line. ZODB does -not- do that. A pretty close change would be: Open file Interpret file as generator, halted at yield but started, Call send and next What does the code for that look like? From n00m at narod.ru Sun Apr 27 02:21:44 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 23:21:44 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <8ee48fc1-45af-404f-8fad-d8e1b2fb90b4@s50g2000hsb.googlegroups.com> Message-ID: <65aa8711-7fbc-4d07-900f-9067d8a5f7fd@m44g2000hsc.googlegroups.com> Oops... I spotted a slip in my C++ code. Forgot " - t" in cout << clock()/CLOCKS_PER_SEC << endl; The correct proportion is 7.5s / 2.75s = 2.7 times. From ptmcg at austin.rr.com Tue Apr 1 21:01:01 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Tue, 1 Apr 2008 18:01:01 -0700 (PDT) Subject: BeautiflSoup -- getting all the attributes of a tag? References: Message-ID: <75bc9d29-dc13-4339-a221-8189d1f5aa4a@n58g2000hsf.googlegroups.com> On Apr 1, 6:28?pm, 7stud wrote: > On Apr 1, 5:25?pm, 7stud wrote: > > > > > > > You can treat a tag like a dictionary to obtain a specific attribute: > > > import BeautifulSoup as bs > > > html = "
hello
" > > > doc = bs.BeautifulSoup(html) > > div = doc.find("div") > > print div > > print div["x"] > > > --output:-- > > a > > > But you can't iterate over a tag to get all the attributes: > > > import BeautifulSoup as bs > > > html = "
hello
" > > > doc = bs.BeautifulSoup(html) > > div = doc.find("div") > > > for key in div: > > ? ? print key, div[key] > > > --output:-- > > hello > > Traceback (most recent call last): > > ? File "test1.py", line 9, in ? > > ? ? print key, div[key] > > ? File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ > > python2.4/site-packages/BeautifulSoup.py", line 430, in __getitem__ > > ? ? return self._getAttrMap()[key] > > KeyError: u'hello' > > > How can you get all the attributes when you don't know the attribute > > names ahead of time? > > I figured it out: > > import BeautifulSoup as bs > > html = "
hello
" > > doc = bs.BeautifulSoup(html) > div = doc.find("div") > > for attr, val in div.attrs: > ? ? print "%s:%s" % (attr, val) > > --output:-- > x:a > y:b > z:c- Hide quoted text - > Just for another datapoint, here's how it looks with pyparsing. -- Paul from pyparsing import makeHTMLTags,SkipTo html = """
hello
""" # HTML tags match case-insensitive'ly divStart,divEnd = makeHTMLTags("DIV") divTag = divStart + SkipTo(divEnd)("body") + divEnd for div in divTag.searchString(html): print div.dump() print # dict-like access to results for k in div.keys(): print k,div[k] # object.attribute access to results print div.body print div.x print div.y print Prints: ['DIV', ['x', 'a'], ['y', 'b'], ['z', 'c'], False, 'hello', '
'] - body: hello - empty: False - endDiv:
- startDiv: ['DIV', ['x', 'a'], ['y', 'b'], ['z', 'c'], False] - empty: False - x: a - y: b - z: c - x: a - y: b - z: c body hello endDiv y b x a z c startDiv ['DIV', ['x', 'a'], ['y', 'b'], ['z', 'c'], False] empty False hello a b From Robert.Bossy at jouy.inra.fr Fri Apr 25 03:44:32 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Fri, 25 Apr 2008 09:44:32 +0200 Subject: Little novice program written in Python In-Reply-To: References: Message-ID: <48118BE0.8010406@jouy.inra.fr> Peter Otten wrote: > Rog?rio Brito wrote: > > >> i = 2 >> while i <= n: >> if a[i] != 0: >> print a[i] >> i += 1 >> > > You can spell this as a for-loop: > > for p in a: > if p: > print p > > It isn't exactly equivalent, but gives the same output as we know that a[0] > and a[1] are also 0. > If the OP insists in not examining a[0] and a[1], this will do exactly the same as the while version: for p in a[2:]: if p: print p Cheers, RB From rorymckinleylists at gmail.com Sat Apr 5 11:27:52 2008 From: rorymckinleylists at gmail.com (Rory McKinley) Date: Sat, 05 Apr 2008 17:27:52 +0200 Subject: Weird scope error Message-ID: <47F79A78.4010207@gmail.com> Hi I am trying to use the TidyHTMLTreeBuilder module which is part of elementtidy, but I am getting what appears to be some sort of scope error and it is scrambling my n00b brain. The module file (TidyHTMLTreeBuilder.py) tried to import ElementTree by doing the following: from elementtree import ElementTree This bombed, so after a bit of poking around I replaced it with : from xml.etree import ElementTree This appears to have worked. However, when I try and parse a file using the function : TidyHTMLTreeBuilder.parse('weather_ct.html') I receive the following error: Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.5/site-packages/elementtidy/TidyHTMLTreeBuilder.py", line 107, in parse return ElementTree.parse(source, TreeBuilder()) NameError: global name 'ElementTree' is not defined The code producing the error is as follows: def parse(source): return ElementTree.parse(source, TreeBuilder()) Surely, if the from... import has worked, ElementTree is in the global scope and should therefore be accessible to the function parse? Can anybody help? THanks From Scott.Daniels at Acm.Org Fri Apr 11 07:37:03 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Fri, 11 Apr 2008 04:37:03 -0700 Subject: Rounding a number to nearest even In-Reply-To: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: bdsatish wrote: > The built-in function round( ) will always "round up", that is 1.5 is > rounded to 2.0 and 2.5 is rounded to 3.0. > > If I want to round to the nearest even, that is > > my_round(1.5) = 2 # As expected > my_round(2.5) = 2 # Not 3, which is an odd num > > I'm interested in rounding numbers of the form "x.5" depending upon > whether x is odd or even. Any idea about how to implement it ? def rounded(v): rounded = round(v) if divmod(v, 1)[1] == .5 and divmod(rounded, 2)[1] == 1: if v > 0: return rounded - 1 return rounded + 1 return rounded last = None for n in range(-29, 28): x = n * .25 r = xr(x) if r != last: last = r print print '%s->%s' % (x, xr(x)), -7.25->-7.0 -7.0->-7.0 -6.75->-7.0 -6.5->-6.0 -6.25->-6.0 -6.0->-6.0 -5.75->-6.0 -5.5->-6.0 -5.25->-5.0 -5.0->-5.0 -4.75->-5.0 -4.5->-4.0 -4.25->-4.0 -4.0->-4.0 -3.75->-4.0 -3.5->-4.0 -3.25->-3.0 -3.0->-3.0 -2.75->-3.0 -2.5->-2.0 -2.25->-2.0 -2.0->-2.0 -1.75->-2.0 -1.5->-2.0 -1.25->-1.0 -1.0->-1.0 -0.75->-1.0 -0.5->0.0 -0.25->-0.0 0.0->0.0 0.25->0.0 0.5->0.0 0.75->1.0 1.0->1.0 1.25->1.0 1.5->2.0 1.75->2.0 2.0->2.0 2.25->2.0 2.5->2.0 2.75->3.0 3.0->3.0 3.25->3.0 3.5->4.0 3.75->4.0 4.0->4.0 4.25->4.0 4.5->4.0 4.75->5.0 5.0->5.0 5.25->5.0 5.5->6.0 5.75->6.0 6.0->6.0 6.25->6.0 6.5->6.0 6.75->7.0 From cokofreedom at gmail.com Wed Apr 23 11:15:12 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Wed, 23 Apr 2008 08:15:12 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: Civilisation 4 uses Python everywhere and is the main tool used by Modders of the game. From searyan at gmail.com Wed Apr 30 12:42:15 2008 From: searyan at gmail.com (Sean Ryan) Date: Wed, 30 Apr 2008 17:42:15 +0100 Subject: Python -v import behavior Message-ID: <357b87b40804300942v371152b0u9dcc6d8b8d0a3b32@mail.gmail.com> Hi all, (A similar question was posted by a colleague, but did not appear to reach comp.lang.python or this list). I am wondering if the -v option causes the python application to be more tolerant to module import warnings and / or errors. The reason is that a module is failing to import correctly (generating an ImportError exception). Examining this closer we re-ran the script using the -v option. to find that "Unsatisfied symbol" errors we being displayed during import (cx_Oracle 4.3.1, python 2.5.1, HP-UX 11, oracle 9.2). However, the module is usable from the python prompt (when using -v) displayed, i.e. dir (cx_Oracle) works correctly, as does database interaction. Without the -v option the script is halted due to the ImportError exception. My questions are: 1. Is there a way to mimic the seemingly more tolerant import behavior of python -v without producing the verbose output ? 2. Is the behavior described above expected and documented ? Thanks and best regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: From fennelllindy8241 at gmail.com Mon Apr 28 03:24:43 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:24:43 -0700 (PDT) Subject: crack acrylic sheet repair Message-ID: crack acrylic sheet repair http://crack.cracksofts.com From info at wingware.com Mon Apr 28 11:29:47 2008 From: info at wingware.com (Wingware) Date: Mon, 28 Apr 2008 11:29:47 -0400 Subject: Wing IDE 3.1beta3 released Message-ID: <4815ED6B.2070605@wingware.com> Hi, Wingware has released version 3.1 beta3 of Wing IDE, an integrated development environment for the Python programming language. It is available from: http://wingware.com/wingide/beta This release includes the following changes: * How-To and improvements for using Wing IDE with Google App Engine * Scan for sys.path changes in main debug file (e.g. for Zope buildouts) * Preference to auto-strip trailing white space on save * Many vi mode improvements * Testing tool enhancements, including better support for test names that are not method names * Sped up stepping in the debugger * Set encoding for stdin/out/err in debug processes for better handling of non-ascii input and output * Fixed problems with debugging stackless tasklets * Python Shell allows spawned threads to run, rather than stopping all threads * Improved support for debugging code invoked by execfile() * Better autocompletion support for an x defined by 'import x.y.z' * More bug fixes, including also all those found in Wing 3.0.5 Please see the change log for a detailed list of changes: http://wingware.com/pub/wingide/prerelease/3.1.0-b3/CHANGELOG.txt Version 3.1 introduces a number of new features and includes bug fixes not found in the 3.0 series, as follows: * Files within .zip or .egg files can be displayed in the editor * Support for pkg_resources based namespace packages * Support for doctest and nose unit test frameworks (**) * Updated code analysis support for Python 2.5 constructs * Improved support for tasklets in Stackless Python * In-line argument entry of code templates/snippets (tab and back tab to traverse fields; arrow keys to change template indent, Esc to exit data entry mode) (**) * Include templates by name in autocompleter (**) * Simple word list driven auto-completion when working in non-Python files (*) * Open from Project for quick selection of files from the Project by typing a fragment (*) * Find Symbol for quick Goto-Definition for symbols in the current Python file by typing a fragment (*) * Show gi_running and gi_frame in Stack Data for generators * Sort menus and lists using more natural sorting so x2.py comes before x10.py * Preference to strip trailing white space on save * Scan for straightforward sys.path changes in main debug file * How-To and improvements for using Wing IDE with Google App Engine * Many bug fixes not in Wing 3.0.x (*)'d items are available in Wing IDE Personal or Professional only. (**)'d items are available in Wing IDE Professional only. *About Wing IDE* Wing IDE is an integrated development environment for the Python programming language. It provides powerful debugging, editing, code intelligence, testing, and search capabilities that reduce development and debugging time, cut down on coding errors, and make it easier to understand and navigate Python code. Wing IDE is available in three product levels: Wing IDE Professional is the full-featured Python IDE, Wing IDE Personal offers a reduced feature set at a low price, and Wing IDE 101 is a free scaled back version designed for teaching entry level programming courses with Python. System requirements are Windows 2000 or later, OS X 10.3.9 or later for PPC or Intel (requires X11 Server), or a recent Linux system (either 32 or 64 bit). *Purchasing & Upgrading* Wing IDE Professional & Wing IDE Personal are commercial software and require a license to run. Wing 3.1 is a free upgrade for all Wing IDE 3.0 users. Any 2.x license sold after May 2nd 2006 is free to upgrade; others cost 1/2 the normal price to upgrade. To upgrade a 2.x license or purchase a new 3.x license: Upgrade https://wingware.com/store/upgrade Purchase https://wingware.com/store/purchase -- The Wingware Team Wingware | Python IDE Advancing Software Development www.wingware.com From hank.infotec at gmail.com Sun Apr 20 04:40:26 2008 From: hank.infotec at gmail.com (Hank @ITGroup) Date: Sun, 20 Apr 2008 18:40:26 +1000 Subject: ???Python Memory Management S***s??? Message-ID: <480B017A.7020801@gmail.com> Hi, people! Greetings~ These days I have been running a text processing program, written by python, of cause. In order to evaluate the memory operation, I used the codes below: """ > string1 = ['abcde']*999999 # this took up an obvious memory space... > del string1 # this freed the memory successfully !! """ For primary variants, the *del* thing works well. However, challenge the following codes, using class-instances... """ > from nltk import FreqDist # nltk stands for Natural Language Tool Kit (this is not an advertisement ~_~) > instance = FreqDist() > instanceList = [instance]*99999 > del instanceList # You can try: nothing is freed by this """ ??? How do you people control python to free the memory in python 2.5 or python 2.4 ??? Cheers!!! From carbanancizpo at gmail.com Fri Apr 18 16:58:45 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:58:45 -0700 (PDT) Subject: battlefield 2 patch 1.41 Message-ID: battlefield 2 patch 1.41 http://cracks.12w.net F R E E C R A C K S From b0bm00r3 at gmail.com Sun Apr 27 08:05:10 2008 From: b0bm00r3 at gmail.com (philly_bob) Date: Sun, 27 Apr 2008 05:05:10 -0700 (PDT) Subject: Random/anonymous class methods Message-ID: <801e1c38-ae54-443c-8d87-9745db7ef270@59g2000hsb.googlegroups.com> In the sample program below, I want to send a random method to a class instance. In other words, I don't know which method to send until run-time. How can I send ch, which is my random choice, to the myclass instance? Thanks, Bob= #### import random class myclass(object): def meth1(self): print 'meth1' def meth2(self): print 'meth2' c=myclass() meths=['meth1', 'meth2'] ch=random.choice(meths) c.ch() From ed at leafe.com Mon Apr 21 14:58:25 2008 From: ed at leafe.com (Ed Leafe) Date: Mon, 21 Apr 2008 13:58:25 -0500 Subject: Does Python 2.5.2's embedded SQLite support full text searching? In-Reply-To: References: <1208794249.15992.1249049327@webmail.messagingengine.com> Message-ID: <77ED9B94-7AC7-497F-9F5B-DA4ACBC39F29@leafe.com> On Apr 21, 2008, at 1:05 PM, Daniel Fetchinson wrote: > Sqlite itself is not distributed with python. Only a python db api > compliant wrapper is part of the python stdlib and as such it is > completely independent of the sqlite build. Don't most binary distributions include SQLite itself? I installed 2.5.2 on a new WinXP VM, and SQLite is working fine. -- Ed Leafe From mav at cuma.polymath-solutions.lan Wed Apr 2 22:16:47 2008 From: mav at cuma.polymath-solutions.lan (Maurizio Vitale) Date: Thu, 03 Apr 2008 02:16:47 GMT Subject: non-terminating regex match References: Message-ID: MRAB writes: > > I think the problem is with this bit: '(?:(?:::)?\w+)*'. The '::' is > optional and also in a repeated group, so if it tries to match, say, > 'abc' it can try and then backtrack all of these possibilities: abc, > ab c, a bc, a b c. The longer the string, the more possibilities to > try. Try this instead: > > r = re.compile ( > r'(?P(?:::)?(?:\w+::)*)?' > r'(?P\w+)' > r'(?:\((?P[^\)]*)\))?' > ) That was indeed the problem. Your version is ok w/ the minor difference that the named group includes the '::' at the end. This can be easily stripped off. Or maybe the regexp can be massaged further. Thanks a lot, Maurizio From grante at visi.com Tue Apr 1 22:46:12 2008 From: grante at visi.com (Grant Edwards) Date: Tue, 01 Apr 2008 21:46:12 -0500 Subject: manipulating hex values References: <47F26CC3.3060307@u4eatech.com> Message-ID: On 2008-04-01, Stephen Cattaneo wrote: >>> I am relatively new to socket programming. I am attempting to >>> use raw sockets to spoof my IP address. >> >> Don't bother to try... > > Is there a better solution to spoofing my IP. then using raw > sockets You'll have to define "spoofing my IP", but I suspect that what you're trying can't be done by using raw sockets. > (I'm working on a machine with multiple interfaces and need to > be able to some how specify which interface that traffic needs > to be sent/recieved to/from) That's what routing tables are for. If you want to send packets using a particular IP, then configure an interface so that it has that adrress, and then bind your socket to that address. > The source of my confusion is that I need to keep my bytes formated > correctly. I am using the below 'raw socket example' proof-of-concept > code as my example. OK. > (And yes, I have tried the proof-of-concept. It works > correctly. It is not my code.) I know. It's my code. :) I wrote Python's raw socket support code and the example code that is floating around the 'net. > dstAddr = "\x01\x02\x03\x04\x05\x06" > dstAddr1 = "0x010203040506" > dstAddr != dstAddr1 Right. > Follow up question: What is the best to store my bytes up > until sending the packets? That depends on what you want to do with them. Ultimately, they need to be strings when they're sent out the socket (in Python a "string" is really just an array of 8-bit bytes). The best way to store them is entirely dependent on how you want to manipulate them before they're sent. > Perhaps I should use lists of decimal numbers and then > before sending convert to hex. Again: you're not converting them to hex. You're converting them to a python "string" object which is really just an array of bytes. Stop saying "hex" when you're talking about a string (array of bytes). "hex" is a way to _represent_ a value textually. It's simply a format used when print a value on paper or a screen. The value itself isn't hex any more than a particular instance of Canis lupus familiaris is "English" because somebody spells it "dog" instead of "chien" or "Hund". > I.E. dstAddr = [ 1, 2, 3, 4, 5, 6] > dstAddr.prepareToSend() I presume you know that list objects don't have a method called prepareToSend(). > txFrame = struct.pack("!6s6sh",dstAddr,srcAddr,proto) + ethData > > Is there a better way to do this? It's not at all clear what "this" is. If you want to convert from a list (or any sequence, really) of integer objects to a string where each integer is converted into a single byte within the string, then here are a few ways: import operator import struct intlist = [1,2,3,4,5,6] s1 = ''.join(chr(b) for b in intlist) s2 = reduce(operator.add,[chr(b) for b in intlist]) s3 = struct.pack("6B",*tuple(intlist)) print repr(s1) print repr(s2) print repr(s3) print s1==s2 print s2==s3 When run you get this: '\x01\x02\x03\x04\x05\x06' '\x01\x02\x03\x04\x05\x06' '\x01\x02\x03\x04\x05\x06' True True I think the third alternative using struct.pack() is the most readable, but others will no doubt disagree. -- Grant Edwards grante Yow! I'm GLAD I at remembered to XEROX all visi.com my UNDERSHIRTS!! From enrique_1984_00 at hotmail.com Thu Apr 24 14:36:02 2008 From: enrique_1984_00 at hotmail.com (Enrique Alvarez) Date: Thu, 24 Apr 2008 14:36:02 -0400 Subject: question Message-ID: hi, I want to ask something about programming in python, I'm beginning, I download the souce code of an antispyware in python I m talking about nixory: http://nixory.sourceforge.net/ this is a antyspyware only for mozilla firefox and my question is: how could I implement more functions of this antispyware....well I want that the program could scan spywares in cookies of internet explorer too...... do have some idea of this??? how could I scan the dlls files in cookies IE......?in python? ?? what libraries do I must to use?? please help me friends........any suggest......... Thanks in advance _________________________________________________________________ Connect to the next generation of MSN Messenger? http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline -------------- next part -------------- An HTML attachment was scrubbed... URL: From mgreene at bdurham.com Fri Apr 25 07:09:22 2008 From: mgreene at bdurham.com (Malcolm Greene) Date: Fri, 25 Apr 2008 07:09:22 -0400 Subject: Can you recommend a book? In-Reply-To: <1209121653.26409.1249825743@webmail.messagingengine.com> References: <1209121653.26409.1249825743@webmail.messagingengine.com> Message-ID: <1209121762.26539.1249826113@webmail.messagingengine.com> My two favorites: - Core Python Programming by Chun - Learning Python by Lutz Malcolm From Lie.1296 at gmail.com Sun Apr 6 13:29:55 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 6 Apr 2008 10:29:55 -0700 (PDT) Subject: A funnily inconsistent behavior of int and float Message-ID: I've noticed some oddly inconsistent behavior with int and float: Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 >>> int('- 345') -345 works, but >>> float('- 345.083') Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for float(): - 345.083 The problem seems to be that float can't accept spaces between the sign and the number while int can. Possibly caused by some missing regex statement. Minor and harmless (most of the time), but should be made known. From gherron at islandtraining.com Sun Apr 13 11:18:53 2008 From: gherron at islandtraining.com (Gary Herron) Date: Sun, 13 Apr 2008 08:18:53 -0700 Subject: Call a classmethod on a variable class name In-Reply-To: References: Message-ID: <4802245D.9070700@islandtraining.com> Matthew Keene wrote: > I would like to be able to call a specific classmethod on a class name > that is going to be passed from another parameter. In other words, I > have a call that looks something like: > > x = Foo.bar() > > and I would like to generalise this so that I can make this call on any > particular class which provides the bar classmethod. > > I have implemented this using exec, like so: > > className = parameters.className > exec "x = " + className + ".bar()" > Yuck. No. Don't do that. As a general rule, anything you could build and put into an exec is a functionality that is exposed more directly by Python. > but this feels somewhat clumsy. (I do have the requisite exception > handling to cope with the supplied class not existing or not > implementing the bar method, by the way). > > Is there any more Pythonesque way of doing this ? I guess what I'm > probably looking for is something like the way I understand the send > function works in Ruby > First off, if possible, don't pass the class name, but instead pass the class itself: class SomeClass: def foo(): ... whatever... ... parameters.theClass = SomeClass ... parameters.theClass.bar() If you can't do that, then look up that class from the class name and make your call: class SomeClass: def foo(): ... whatever... ... parameters.className = 'SomeClass' ... theClass = globals()[parameters.className] parameters.theClass.bar() (Hint: It matters not whether foo is a classmethod, saticmathod or normal method.) Gary Herron From svensven at gmail.com Thu Apr 10 14:57:29 2008 From: svensven at gmail.com (svensven) Date: Thu, 10 Apr 2008 20:57:29 +0200 Subject: subprocess.Popen() output to logging.StreamHandler() In-Reply-To: <4a1e850d-064f-49b8-87c7-140f10fc88c3@z38g2000hsc.googlegroups.com> References: <4a1e850d-064f-49b8-87c7-140f10fc88c3@z38g2000hsc.googlegroups.com> Message-ID: <47FE6319.5030005@gmail.com> Thomas Dimson wrote: > On Apr 10, 8:11 am, "sven _" wrote: >> My goal is to have stdout and stderr written to a logging handler. >> This code does not work: >> >> # START >> import logging, subprocess >> ch = logging.StreamHandler() >> ch.setLevel(logging.DEBUG) >> subprocess.call(['ls', '-la'], 0, None, None, ch, ch) >> # END > > What is wrong with doing something like: > > import logging, subprocess > ch = logging.StreamHandler() > ch.setLevel(logging.DEBUG) > > s = subprocess.Popen( ['ls','-la'], stdout=subprocess.PIPE ) > while 1: > ch.info( s.stdout.readline() ) > if s.poll() == None: > break > > Perhaps not the most efficient or clean solution, but that is how I > usually do it (note: I didn't test the above code). Thanks, Thomas. That was actually far less messy than I had imagined. I got it to work -- almost work -- using this code: import logging, subprocess logger = logging.getLogger("simple_example") logger.setLevel(logging.DEBUG) ch = logging.StreamHandler() ch.setLevel(logging.DEBUG) formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") ch.setFormatter(formatter) logger.addHandler(ch) s = subprocess.Popen(["ping", "-c", "5", "127.0.0.1"], stdout=subprocess.PIPE, bufsize=1024) while s.poll() == None: logger.info( s.stdout.readline().strip() ) The problem is that the .poll() seems to be a bit too agressive, so the while loop will quit before the process actually finishes. In the ping example above, it will show the pings, but it will skip the summary at the end. The response by Vinay Sajip seems to work just fine, though. Sven From cliff at develix.com Wed Apr 16 15:05:14 2008 From: cliff at develix.com (Cliff Wells) Date: Wed, 16 Apr 2008 12:05:14 -0700 Subject: Default parameter for a method In-Reply-To: References: <806788d2-67b7-456b-bd1e-08c50cbf0f7b@8g2000hsu.googlegroups.com> Message-ID: <1208372714.1289.2.camel@portableevil.develix.com> On Wed, 2008-04-16 at 13:47 -0500, Larry Bates wrote: > s0suk3 at gmail.com wrote: > > I wanted to know if there's any way to create a method that takes a > > default parameter, and that parameter's default value is the return > > value of another method of the same class. For example: > > > > class A: > > def __init__(self): > > self.x = 1 > > > > def meth1(self): > > return self.x > > > > def meth2(self, arg=meth1()): > > # The default `arg' should would take the return value of > > meth1() > > print '"arg" is', arg > > > > This obviously doesn't work. I know I could do > > > > ... > > def meth2(self, arg=None): > > if arg is None: > > arg = self.meth1() > > > > but I'm looking for a more straightforward way. > > You can write this as: > > def meth2(self, arg=None): > arg = arg or self.meth1() > > IMHO - You can't get much more "straightforward" than that. What if arg is 0 an empty list or anything else that's "False"? def meth2(self, arg=None): arg = (arg is not None) or self.meth1() is what you want. Regards, Cliff From bronger at physik.rwth-aachen.de Wed Apr 23 16:52:44 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 23 Apr 2008 22:52:44 +0200 Subject: Python development tools References: <09992de9-39fa-4ee6-8009-35732f3433fb@y21g2000hsf.googlegroups.com> Message-ID: <87fxtcnvj7.fsf@physik.rwth-aachen.de> Hall?chen! bruno.desthuilliers at gmail.com writes: > On 23 avr, 19:39, "wongjoek... at yahoo.com" > wrote: > >> Are there any completely free developent tools for python scripts >> like IDLE. I have used IDLE , but I want to try out others >> also. I saw stuff like PyCrust, but I don't see that it can run >> the script as well. > > emacs + python-mode (the one from Python, not the horror that > ships with recent emacs versions) What's so bad about it? I just installed python-mode (is this the one with the "py-" prefixes?), and it ends multi-line strings at single quotes. That's bad. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From gagsl-py2 at yahoo.com.ar Thu Apr 3 09:14:47 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 10:14:47 -0300 Subject: non-terminating regex match References: Message-ID: En Wed, 02 Apr 2008 13:01:59 -0300, Maurizio Vitale escribi?: > The intention is to match C++ identifiers, with or without namespace > qualification, with or without arguments (e.g. variables, functions and > macros). > The following should be accepted: > main > main(int,char**) > ::main > std::cout > ::std::cout > NDEBUG What about foo(int(*f)(int)) ? You can't match a function definition with a regular expression alone, due to the nested (). The r.e. can recognize an identifier; you can later see whether there is a ( and scan up to the matching ). -- Gabriel Genellina From nospam at nospam.blah Wed Apr 30 20:33:59 2008 From: nospam at nospam.blah (JYA) Date: Thu, 1 May 2008 10:33:59 +1000 Subject: best way to host a membership site References: <53034dcc-7346-4f71-889c-3278c9e813ec@w1g2000prd.googlegroups.com> Message-ID: <48190ff7$0$19248$426a34cc@news.free.fr> Hi On 2008-04-30 10:11:46 +1000, Magdoll said: > is the best thing to use. A friend recommended Ruby on Rails - not to > instigate war here, but I'd welcome comments on that (I don't know You should have a look at Pylons then. It is similar in essence to Ruby on Rails, but using Pythons. http://pylonshq.com/ -- They who would give up an essential liberty for temporary security, deserve neither liberty or security (Benjamin Franklin) From george.sakkis at gmail.com Tue Apr 29 20:03:16 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 29 Apr 2008 17:03:16 -0700 (PDT) Subject: Code/test ratio wrt static vs dynamic typing [was: Re: Python Success stories] References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <57d73312-37b1-4c53-9669-803e84a6901f@p25g2000hsf.googlegroups.com> Message-ID: On Apr 29, 2:25?pm, Fuzzyman wrote: > There are around 30 000 lines of Python in the production code and > about 120 000 lines of Python code in the test framework. A rather off-topic and perhaps naive question, but isn't a 1:4 production/test ratio a bit too much ? Is there a guesstimate of what percentage of this test code tests for things that you would get for free in a statically typed language ? I'm just curious whether this argument against dynamic typing - that you end up doing the job of a static compiler in test code - holds in practice. George From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 24 07:43:25 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 24 Apr 2008 13:43:25 +0200 Subject: function that accepts any amount of arguments? In-Reply-To: References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> Message-ID: <4810724a$0$23390$426a74cc@news.free.fr> Paul McNett a ?crit : > > def avg(*args): > return sum(args) / len(args) > > There are some dangers (at least two glaring ones) with this code, > though, which I leave as an exercise for the reader. try: avg("toto", 42) except TypeError, e: print "this is the first one : %s" % e try: avg() except ZeroDivisionError, e: print "this is the second : %s" % e As far as I'm concerned, I would not handle the first one in the avg function - just document that avg expects numeric args. Not quite sure what's the best thing to do in the second case - raise a ValueError if args is empty, or silently return 0.0 - but I'd tend to choose the first solution (Python's Zen, verses 9-11). From skanemupp at yahoo.se Wed Apr 16 12:35:17 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Wed, 16 Apr 2008 09:35:17 -0700 (PDT) Subject: Profiling very small/quick functions, help!? Message-ID: <1ed0cde8-d04c-444b-9b47-9bea16ae409d@f63g2000hsf.googlegroups.com> i use this code to profile. however for small standard functions it just says 0 seconds. so one solution is to run the function a very big number of times(how big?). but the bottom code doesnt work, it just runs the same profiling 10000 times insetad of running the fucntion 10K times and evaluate the time of all thsoe 10K times. ao how to solve this? if __name__=="__main__": try: from cProfile import run except: from profile import run run("tests()") if __name__=="__main__": try: from cProfile import run except: from profile import run for x in range(1, 10000): run("power(10,10)") From arnodel at googlemail.com Sun Apr 27 08:11:27 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 27 Apr 2008 13:11:27 +0100 Subject: Random/anonymous class methods References: <801e1c38-ae54-443c-8d87-9745db7ef270@59g2000hsb.googlegroups.com> Message-ID: philly_bob writes: > In the sample program below, I want to send a random method to a class > instance. > In other words, I don't know which method to send until run-time. How > can I send ch, which is my random choice, to the myclass instance? > > Thanks, > > Bob= > > #### > import random > > class myclass(object): > def meth1(self): > print 'meth1' > def meth2(self): > print 'meth2' > > c=myclass() > meths=['meth1', 'meth2'] > ch=random.choice(meths) > c.ch() This will work: getattr(c, ch)() Getattr(c, "meth1") is equivalent to c.meth1. Or you could do: meths = [c.meth1, c.meth2] ch = random.choice(meths) ch() -- Arnaud From sjmachin at lexicon.net Wed Apr 9 19:07:54 2008 From: sjmachin at lexicon.net (John Machin) Date: Wed, 9 Apr 2008 16:07:54 -0700 (PDT) Subject: How can I use quotes without escaping them using CSV? References: Message-ID: On Apr 10, 7:39 am, "Reedick, Andrew" wrote: > > -----Original Message----- > > From: python-list-bounces+jr9445=att.... at python.org [mailto:python- > > list-bounces+jr9445=att.... at python.org] On Behalf Of jeffself > > Sent: Wednesday, April 09, 2008 5:11 PM > > To: python-l... at python.org > > Subject: How can I use quotes without escaping them using CSV? > > > If I put an escape character in, it works. For example, if I use ~ as > > my escape character, my output looks like this: > > 0001[tab]Michael L. ~"Mick~" Jones[tab]189 > > > I don't want that. If I don't include an escape character, it doesn't > > work. which means an exception is raised: _csv.Error: need to escape, but no escapechar set > > > Here's my code: [snip] > > writer = csv.writer(f, delimiter='\t', quoting=csv.QUOTE_NONE) [snip] > > The documentation is pretty, uhm, obtuse, but you also need to set > quotechar. Uhm, "obtuse" applies to angles and people :-) I could agree with "obscure". > > import sys > import csv > > names = ['Michael L. "Mick" Jones', 'Vickie A. Meyers', 'John "Jack" > Smith'] > > writer = csv.writer(sys.stdout, delimiter='\t', quotechar='', > quoting=csv.QUOTE_NONE) > for i in names: > writer.writerow(['a', i, 'b']) > > output: > a Michael L. "Mick" Jones b > a Vickie A. Meyers b > a John "Jack" Smith b > > ***** > Here's my call: (1) Code bug: when quoting is set to QUOTE_NONE, it should ignore the setting of quotechar -- it's irrelevant. (2) Documentation bug: """ quotechar A one-character string .... """ but the code allows setting quotechar to '' and to None. Both work around the OP's problem; whether they have identical effect in other situations, I haven't explored. Cheers, John From medin0065 at gmail.com Sun Apr 20 10:48:25 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:48:25 -0700 (PDT) Subject: vuescan 8.4.13 crack Message-ID: <5e53bfe9-b192-439a-ae8e-ae4b49c05dd7@w1g2000prd.googlegroups.com> vuescan 8.4.13 crack http://cracks.00bp.com F R E E C R A C K S From nick at stinemates.org Fri Apr 18 15:01:02 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 12:01:02 -0700 Subject: program to Ping ip addresses In-Reply-To: <192124.99122.qm@web58602.mail.re3.yahoo.com> References: <192124.99122.qm@web58602.mail.re3.yahoo.com> Message-ID: <20080418190102.GG19281@deviL> On Tue, Apr 15, 2008 at 07:24:05AM -0700, shawn s wrote: > Hi > > I am trying to modify a small program i found off the internet as follows... I can get the 'tracert' to work and it gives me all the info back. However, when i replace the tracert with 'ping', the commamd prompt shows 'testing' and the script freezes... any suggestions as why it is doing that. > > import os > import sys > xyz = 1 > > while xyz==1: > ip = raw_input("command >> ") > zx = open("log.txt", "a") > > if ip.lower()=="exit": > ask = raw_input("Are you sure you want to exit? (Y\\N) ") > > if ask.lower()=="y": > sys.exit() > elif ask.lower()=="n": > print("That's what I thought.") > else: > print("Wrong choice. Retard.") > > elif ip.lower()=="range": > stin = raw_input("Enter function: ") > sec = raw_input("Enter the first 3 sections: ") > b = raw_input("Enter beginning number: ") > intb=int(b) > e = int(raw_input("Enter ending number: ")) > > while intb<=e: > print (stin + ' ' + sec + '.' + b ) > z = os.system(stin + ' ' + sec + '.' + b ) > print z > > if z==0: > print(""+str(sec)+"."+str(b)+" is online.") > zx.write(""+str(sec)+"."+str(b)+" is online.\n") > elif z==1: > print("Either "+str(sec)+"."+str(b)+" is offline, or ping request has been blocked.") > zx.write("Either "+str(sec)+"."+str(b)+" is offline, or ping request has been blocked.\n") > > intb = intb + 1 > b=str(intb) > > else: > > print("Wrong choice. Retard.") > I love that you call the users of your app retards :) That rocks! ping runs forever. tracert doesnt. try: > ping -w 5 -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From fennelllindy8241 at gmail.com Mon Apr 28 03:25:39 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:25:39 -0700 (PDT) Subject: imtoo crack Message-ID: imtoo crack http://crack.cracksofts.com From weiss02121 at gmail.com Tue Apr 15 19:48:13 2008 From: weiss02121 at gmail.com (weiss02121 at gmail.com) Date: Tue, 15 Apr 2008 16:48:13 -0700 (PDT) Subject: lindsay lohan cocaine video Message-ID: <5c35bdd9-9e8c-4e03-842a-84272676b459@n14g2000pri.googlegroups.com> Just few link on some Lindsay Lohan Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From toolmaster at 163.com Thu Apr 3 04:45:00 2008 From: toolmaster at 163.com (WaterWalk) Date: Thu, 3 Apr 2008 01:45:00 -0700 (PDT) Subject: unicode in exception traceback Message-ID: Hello. I just found on Windows when an exception is raised and traceback info is printed on STDERR, all the characters printed are just plain ASCII. Take the unicode character u'\u4e00' for example. If I write: print u'\u4e00' If the system locale is "PRC China", then this statement will print this character as a single Chinese character. But if i write: assert u'\u4e00' == 1 An AssertionError will be raised and traceback info will be put to STDERR, while this time, u'\u4e00' will simply be printed just as u'\u4e00', several ASCII characters instead of one single Chinese character. I use the coding directive commen(# -*- coding: utf-8 -*-)t on the first line of Python source file and also save it in utf-8 format, but the problem remains. What's worse, if i directly write Chinese characters in a unicode string, when the traceback info is printed, they'll appear in a non- readable way, that is, they show themselves as something else. It's like printing something DBCS characters when the locale is incorrect. I think this problem isn't unique. When using some other East-Asia characters, the same problem may recur. Is there any workaround to it? From mmanns at gmx.net Sat Apr 26 23:21:56 2008 From: mmanns at gmx.net (Martin Manns) Date: Sun, 27 Apr 2008 05:21:56 +0200 Subject: ANN: pyspread 0.0.4 Message-ID: Hi, The newest version pyspread 0.0.4 now runs on + GTK + Windows + Mac (not tested myself but got positive reports) New features in 0.0.4: + Column, line and table insertion and deletion + Themeable toolbar Feedback is very welcome! Best Regards Martin From matthewcroberts at gmail.com Sat Apr 12 21:48:52 2008 From: matthewcroberts at gmail.com (Matt) Date: Sat, 12 Apr 2008 18:48:52 -0700 (PDT) Subject: Advice on tools/technologies/books, etc. Message-ID: I would like to create a web-based tool for risk management. The tool actually currently exists, but it was programmed in about 1998 using old VB, etc, and we are updating it & moving it to the web. Basically, as a first step, i'd like to create a basic web site that takes user input, gets data from MySQL (i might pickle it, not yet sure) and then runs some numpy routines & outputs the results. This will give us a platform to develop the backend. My intermediate goal is to have an asynchronous site in which as users adjust settings, the computations are run & graphs updated. (the computations are pretty simple, btw). My fantasy goal would be to combine that w/ google gears so the users could use it online or offline, but that's probably just fantasy. So, here are my constraints: I know Python & HTML (and lots of other non-germane languages) but I don't know any javascript or ruby or XML. What is the lowest cost path from here to there? I have been totally out of the loop for this whole web 2.0 thing (I'm an economics professor). Will it be possible for me to put together an async site with only python? (I hesitate to use the term AJAX, b/c its unclear to me how generic it is--do all async sites use javascript? can someone clarify this?) If so, does it make sense to go ahead and start trying to learn Turbogears or Pylons? Will they be able to create async sites? Is there an easier way to do it? (Easy defined as me not having to learn a 7th programming language) I have looked at Spyce, and that seems an easy way to do the basic (step 1) site, but its not at all clear that I can do async with it. CherryPy looks like it has a steeper learning curve, but it also appears that the route to async is clearer. I know where I want to go, and I know what I can do now. I don't mind getting deeper into Python, but I'd love not to have to learn a bunch of other languages if I can avoid it. Any thoughts/comments? TIA, Matt. From ed at leafe.com Tue Apr 1 14:12:17 2008 From: ed at leafe.com (Ed Leafe) Date: Tue, 1 Apr 2008 13:12:17 -0500 Subject: class super method In-Reply-To: <42479e00-c73d-436f-ae1a-bbc24365ccd3@e23g2000prf.googlegroups.com> References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> <42479e00-c73d-436f-ae1a-bbc24365ccd3@e23g2000prf.googlegroups.com> Message-ID: <3D421F14-BB9C-4321-AD31-C416EC220A5C@leafe.com> On Apr 1, 2008, at 12:53 PM, Michele Simionato wrote: > It is just that you did not run (yet) in a corner case of super. The > interesting question would be: did any of your users run into issues > using you library which is heavily relying on super? Especially when > composing it with their own classes? None so far, and our users are pretty good about reporting bugs! > I personally have changed my opinion about multiple inheritance over > the years. > At the beginning I thought it was a very cool idea, but now I think it > is a pretty bad idea. If I were to design a language, I would not > implement multiple inheritance. In Python I never use multiple > inheritance and actually I try very hard to avoid even single > inheritance, preferring composition whenever it is viable. I think MI is great as long as you understand how to use it. I would never encourage anyone to mix dissimilar classes; that's just poor design. But a well-designed mixin class is a wonderful thing. I also don't consider inheritance and composition to be either/or choices. Both can (and usually should) be part of a well-designed application. In my experience, using either incorrectly can get you in trouble. -- Ed Leafe From python at bdurham.com Mon Apr 21 17:05:20 2008 From: python at bdurham.com (python at bdurham.com) Date: Mon, 21 Apr 2008 17:05:20 -0400 Subject: List of all Python's ____ ? In-Reply-To: <87wsmrdka8.fsf@mulj.homelinux.net> References: <87wsmrdka8.fsf@mulj.homelinux.net> Message-ID: <1208811920.4195.1249106841@webmail.messagingengine.com> Hrvoje, >> Is there an official list of all Python's ____? > http://docs.python.org/ref/specialnames.html Wonderful!! Thank you very much. Regards, Malcolm From gagsl-py2 at yahoo.com.ar Thu Apr 10 05:09:22 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 06:09:22 -0300 Subject: How to find documentation about methods etc. for iterators References: <47fce941$0$755$bed64819@news.gradwell.net> <47fdceb8$0$754$bed64819@news.gradwell.net> Message-ID: En Thu, 10 Apr 2008 05:24:24 -0300, escribi?: > Terry Reedy wrote: >> >> wrote in message >> news:47fce941$0$755$bed64819 at news.gradwell.net... >> | I'm not sure if I have even phrased that right but anyway.... >> | >> | How does one find (in the standard Python documentation) information >> | about things like the iteritems() method and the enumerate() function. >> >> The Library Reference manual sections on builtin functions and dict >> methods. >> >> Or, help(enumerate) and help({}.iteritems) >> > .... but that doesn't address my problem really, how do I know that I > need to look for the words enumerate and/or iteritems? This is what > my original question was about. You'll have to read at least section 2 (built-in objects) and section 3 (built-in types) in the Library Reference: http://docs.python.org/lib/ That's the most important part to know. > There I was thinking that there has to be an easy way to get line > numbers as I read lines from a file but not knowing how to find out > how to do it:- > > First question, what sort of 'thing' is the file object, I need to > know that if I'm to look up ways of using it. > > Second question, even if I know what sort of thing a file object > is, how do I find methods applicable to it and/or functions > applicable to it? You look for 'file object' in the index and find http://docs.python.org/lib/bltin-file-objects.html > The possibility that I might want either a method or a function adds > to the fun. In my original query it seemed odd that some objects have > the iteritems *method* whereas other objects have the enumerate > *function*. Other objects don't "have" the enumerate function, enumerate is a builtin function that can be used with any sequence or iterable object. Your know it because you have read section 2.1 in the Library Reference as I've told you a few lines above :) > It's a common problem in all sorts of computer fields, if you know the > name of what you want it's easy to find out details of how to use it > but if you don't know its name (or even if it exists) it's much more > difficult to find. Yes, certainly. Python comes with "batteries included" and there are many of them. You don't have to read the whole Library Reference from begin to end, but at least have a look at the titles so you know that certain thing exists. > I've only been using Python for a few months and most of the time I > can find my way to what I need but this area of "what things can I do > with this object" still eludes me sometimes. What *I* need (I'm not > sure if this is a universal requirement though) is some consistent way > of firstly finding out what sort of an object something is (i.e. in > this case, what sort of object is a file) and then getting a list of > methods that I can apply to that object (O.K., this may need some > hierachy or other classification to keep it sane, but hopefully you > can see where I'm going). A file is... a file: py> f = open("temp.txt","r") py> type(f) You can invoke the help system with any object: py> help(f) Help on file object: class file(object) | file(name[, mode[, buffering]]) -> file object | | Open a file. The mode can be 'r', 'w' or 'a' for reading (default), | writing or appending. The file will be created if it doesn't exist | when opened for writing or appending; [blah...] [... including all methods defined in the file class ...] You can use help with a particular methods or function too: py> help(f.write) Help on built-in function write: write(...) write(str) -> None. Write string str to file. Note that due to buffering, [blah...] You can use dir(something) to see which attributes (including methods) an object has: py> dir(f) ['__class__', '__delattr__', '__doc__', ... 'close', 'closed', 'encoding', ... 'write', 'writelines', 'xreadlines'] Hope this helps. -- Gabriel Genellina From sjoerd at acm.org Mon Apr 21 03:49:26 2008 From: sjoerd at acm.org (Sjoerd Mullender) Date: Mon, 21 Apr 2008 09:49:26 +0200 Subject: Is massive spam coming from me on python lists? In-Reply-To: <87r6cz3cn7.fsf@physik.rwth-aachen.de> References: <480C2DC6.4050701@aim.com> <87r6cz3cn7.fsf@physik.rwth-aachen.de> Message-ID: <480C4706.9040207@acm.org> Torsten Bronger wrote: > Hall?chen! > > Sjoerd Mullender writes: > >> On 2008-04-21 08:01, Brian Vanderburg II wrote: >> >>> I've recently gotten more than too many spam messages and all say >>> Sender: python-list-bounces+my=email.address at python.org. [...] >> That is just mailman (the mailing list software) keeping track of >> things. > > By the way, why does mailman change the Message-IDs when tunneling > postings to the newsgroup? This destroys the thread structure. I have no idea. There is no setting in the mailman administration interface that I can see that influences this. Perhaps submit this as a bugreport to mailman? -- Sjoerd Mullender -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 379 bytes Desc: OpenPGP digital signature URL: From pydecker at gmail.com Thu Apr 10 12:56:05 2008 From: pydecker at gmail.com (Peter Decker) Date: Thu, 10 Apr 2008 11:56:05 -0500 Subject: How is GUI programming in Python? In-Reply-To: References: Message-ID: On Wed, Apr 9, 2008 at 8:54 PM, Chris Stewart wrote: > I've always had an interest in Python and would like to dabble in it > further. I've worked on a few very small command line programs but > nothing of any complexity. I'd like to build a really simple GUI app > that will work across Mac, Windows, and Linux. How painful is that > going to be? I used to be really familiar with Java Swing a few years > ago. I imagine it will be similar. > > Next, what would you say is the best framework I should look into? > I'm curious to hear opinions on that. I've found wxPython to be the best all-around choice: it looks right on Mac, Win and Gtk/Linux, as it uses native controls. The one downside is that its C++ roots show, and make for somewhat ugly and unPythonic code. I've been using the Dabo framework (http://dabodev.com) for over a year now, and it's great. They use wxPython for the UI, but wrap it in a consistent and intelligent layer that makes development much simpler and straightforward. -- # p.d. From gherron at islandtraining.com Tue Apr 15 13:44:19 2008 From: gherron at islandtraining.com (Gary Herron) Date: Tue, 15 Apr 2008 10:44:19 -0700 Subject: Preferred method for "Assignment by value" In-Reply-To: References: Message-ID: <4804E973.7030009@islandtraining.com> hall.jeff at gmail.com wrote: > As a relative new comer to Python, I haven't done a heck of a lot of > hacking around with it. I had my first run in with Python's quirky (to > me at least) tendency to assign by reference rather than by value (I'm > coming from a VBA world so that's the terminology I'm using). I was > surprised that these two cases behave so differently > > test = [[1],[2]] > x = test[0] > x[0] = 5 > test > >>>> [[5],[2]] >>>> > x = 1 > test > >>>> [[5],[2]] >>>> > x > >>>> 1 >>>> > > Now I've done a little reading and I think I understand the problem... > My issue is, "What's the 'best practise' way of assigning just the > value of something to a new name?" > > i.e. > test = [[1,2],[3,4]] > I need to do some data manipulation with the first list in the above > list without changing > obviously x = test[0] will not work as any changes i make will alter > the original... > I found that I could do this: > x = [] + test[0] > > that gets me a "pure" (i.e. unconnected to test[0] ) list but that > concerned me as a bit kludgy > > Thanks for you time and help. > If you want a *copy* of an object (or portion thereof), you must explicitly *specify* a copy. THere are different ways of doing that depending on the object in question. Lists (and slices thereof) can be copied to a new list withthe slice syntax: L[1:4] will copy a limited portion, and L[:] will copy the whole list. The kind of copy is only one level deep -- the contents of the copy will be references to the contents of L Dictionaries have a copy method that creates a new dictionary. Again this copy is only one level deep. The copy modules provides a more general way to copy objects. It provides the ability to produce both shallow and deep copies. A small note: In a dozen years of programming in Python, I've used these various copy methods perhaps a dozen times or less. If you find you are copying structures often, you are probably not using Python as effectively as you could. Gary Herron From svensven at gmail.com Thu Apr 10 08:11:55 2008 From: svensven at gmail.com (sven _) Date: Thu, 10 Apr 2008 14:11:55 +0200 Subject: subprocess.Popen() output to logging.StreamHandler() Message-ID: <3a4166890804100511q6fc9a5e0qb636eeb5b3e949e3@mail.gmail.com> Version: Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) My goal is to have stdout and stderr written to a logging handler. This code does not work: # START import logging, subprocess ch = logging.StreamHandler() ch.setLevel(logging.DEBUG) subprocess.call(['ls', '-la'], 0, None, None, ch, ch) # END Traceback (most recent call last): File "log.py", line 5, in subprocess.call(['ls', '-la'], 0, None, None, ch, ch) File "/usr/lib/python2.5/subprocess.py", line 443, in call return Popen(*popenargs, **kwargs).wait() File "/usr/lib/python2.5/subprocess.py", line 586, in __init__ errread, errwrite) = self._get_handles(stdin, stdout, stderr) File "/usr/lib/python2.5/subprocess.py", line 941, in _get_handles c2pwrite = stdout.fileno() AttributeError: StreamHandler instance has no attribute 'fileno' This is because subprocess.Popen() expects file descriptors to write to, and logging.StreamHandler() does not supply it. The StreamHandler could supply its own stdout file descriptor, but then Popen() would write directly to that file, bypassing all the logging fluff. A possible solution would be to make a named pipe (os.mkfifo()), have Popen() write to that, and then have some horrendous hack run select() or similar on the fifo to read from it and finally pass it to StreamHandler. Are there better solutions? sven From torriem at gmail.com Sun Apr 6 11:52:32 2008 From: torriem at gmail.com (Michael Torrie) Date: Sun, 06 Apr 2008 09:52:32 -0600 Subject: appropriate python version In-Reply-To: <0790632f-db07-45ef-9bcd-7e1b592d33be@u69g2000hse.googlegroups.com> References: <0790632f-db07-45ef-9bcd-7e1b592d33be@u69g2000hse.googlegroups.com> Message-ID: <47F8F1C0.40203@gmail.com> xamdam wrote: > Sorry if this is a stupid q, > I am trying to figure out the appropriate version of Python(2.4 or > 2.5) for an XP 64 system running on an Intel Core2 Quad. Python.org > has a to a 64bit build, but it specifies Itanium as the target. Should > I just be using the regular build? Itanium is a different processor and architecture. It simply won't run on your Core2 Quad. You need an x86-64bit build. > I was also thinking of getting the Enthought edition (http:// > code.enthought.com/enthon/) - would their binary work with the setup, > and what would be the downside of using it over the special 64bit > build? Seeing as the special 64bit build appears to be for itanium (from what you say here), I'd say the question is moot! From hobgoodoreneyhb at gmail.com Tue Apr 22 11:41:38 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:41:38 -0700 (PDT) Subject: diablo 2 lod patch Message-ID: <881d8be9-f26d-4681-8eaf-6a773e038243@t63g2000hsf.googlegroups.com> diablo 2 lod patch http://cracks.12w.net F R E E C R A C K S From goldspin at gmail.com Tue Apr 8 11:23:46 2008 From: goldspin at gmail.com (Henry Chang) Date: Tue, 8 Apr 2008 08:23:46 -0700 Subject: Google App Engine In-Reply-To: References: Message-ID: This is very interesting. Thanks for sharing! On Tue, Apr 8, 2008 at 1:55 AM, Duncan Booth wrote: > Google have announced a new service called 'Google App Engine' which may > be of interest to some of the people here (although if you want to sign > up you'll have to join the queue behind me): > > >From the introduction: > > > What Is Google App Engine? > > > > Google App Engine lets you run your web applications on Google's > > infrastructure. App Engine applications are easy to build, easy to > > maintain, and easy to scale as your traffic and data storage needs > > grow. With App Engine, there are no servers to maintain: You just > > upload your application, and it's ready to serve your users. > > > > You can serve your app using a free domain name on the appspot.com > > domain, or use Google Apps to serve it from your own domain. You can > > share your application with the world, or limit access to members of > > your organization. > > > > App Engine costs nothing to get started. Sign up for a free account, > > and you can develop and publish your application for the world to see, > > at no charge and with no obligation. A free account can use up to > > 500MB of persistent storage and enough CPU and bandwidth for about 5 > > million page views a month. > > > > During the preview release of Google App Engine, only free accounts > > are available. In the near future, you will be able to purchase > > additional computing resources. The Application Environment > > > > Google App Engine makes it easy to build an application that runs > > reliably, even under heavy load and with large amounts of data. The > > environment includes the following features: > > > > * dynamic web serving, with full support for common web > > technologies > > * persistent storage with queries, sorting and transactions > > * automatic scaling and load balancing > > * APIs for authenticating users and sending email using Google > > Accounts > > * a fully featured local development environment that > > simulates Google App Engine on your computer > > > > Google App Engine applications are implemented using the Python > > programming language. The runtime environment includes the full Python > > language and most of the Python standard library. > > > > Although Python is currently the only language supported by Google App > > Engine, we look forward to supporting more languages in the future. > > http://code.google.com/appengine > > > -- > http://mail.python.org/mailman/listinfo/python-list > From siona at chiark.greenend.org.uk Thu Apr 17 13:07:21 2008 From: siona at chiark.greenend.org.uk (Sion Arrowsmith) Date: 17 Apr 2008 18:07:21 +0100 (BST) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> Message-ID: wrote: >In Python, you usually can use parentheses to split something over >several lines. But you can't use parentheses for an assignment of >several lines. Yes you can, you just need an iterable of the right length on the other side for the tuple unpacking to work: >>> (CONSTANT1, ... # This isn't a syntax error ... CONSTANT2, ... CONSTANT3, #and neither is this ... CONSTANT) = [1] * 4 >>> [ (k, v) for k, v in locals().items() if k.startswith("CONSTANT") ] [('CONSTANT', 1), ('CONSTANT1', 1), ('CONSTANT3', 1), ('CONSTANT2', 1)] >>> -- \S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/ "Frankly I have no feelings towards penguins one way or the other" -- Arthur C. Clarke her nu become? se bera eadward ofdun hl?ddre heafdes b?ce bump bump bump From mail at timgolden.me.uk Thu Apr 3 03:56:31 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 03 Apr 2008 08:56:31 +0100 Subject: Python for low-level Windows programming In-Reply-To: References: Message-ID: <47F48DAF.9070707@timgolden.me.uk> haxier wrote: > I've some experience with Python in desktop apps, but now I'm looking > to code a tool like Kee-Pass[1] which must have access to some low- > level primitives in a windows environment: hooks when windows are > displayed, automatic form fill, and so on in a variety of scenarios > (desktop apps, web-based apps, citrix...) > > Is this possible without too much pain? I know I can code it with C# > or C++ but tha'ts a road to avoid, if possible. Well of course I don't know exactly what you'd need, but the answer's certainly Yes :) In short, even native Python comes with the ctypes module which will let you call -- with only a little working out the structures -- into any Windows DLL or COM interface (the latter via the comtypes extension). But in any case the pywin32 packages and various other open source projects have already done a lot of the work for you. Plus it's easy enough to write your own extension which does the dirty work in C and exposes it to Python as functions, objects or whatever suits your purposes. Good luck! TJG From wwzaygvm at gmail.com Wed Apr 16 16:53:48 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 13:53:48 -0700 (PDT) Subject: audio mid recorder 3.95 and crack Message-ID: <0260377e-672e-432f-9471-9a3bc16541e3@b9g2000prh.googlegroups.com> audio mid recorder 3.95 and crack http://cracks.12w.net F R E E C R A C K S From supercooper at gmail.com Wed Apr 30 13:40:20 2008 From: supercooper at gmail.com (supercooper) Date: Wed, 30 Apr 2008 10:40:20 -0700 (PDT) Subject: PIL and IPTC References: <0001HW.C43E4BB60060D69EB01AD9AF@news.individual.de> Message-ID: <0054980b-e4c3-459f-a57a-a5b98b85dfd4@y38g2000hsy.googlegroups.com> On Apr 30, 9:15 am, Jumping Arne wrote: > I'm completely new to PIL and I'm trying to read IPTC info, I understand that > it's possible but I can't find out how (and for once Google doesn't seem to > be able to help). Does anyone have an example of how it's done? I use the IPTCInfo module with great success. Its very easy to work with to read/write IPTC metadata: http://pypi.python.org/pypi/IPTCInfo/1.9.2-rc5 HTH From ott.deb at gmail.com Thu Apr 17 15:05:47 2008 From: ott.deb at gmail.com (ott.deb at gmail.com) Date: Thu, 17 Apr 2008 12:05:47 -0700 (PDT) Subject: digital rights management crack Message-ID: digital rights management crack http://cracks.12w.net F R E E C R A C K S From bdsatish at gmail.com Fri Apr 11 08:45:58 2008 From: bdsatish at gmail.com (bdsatish) Date: Fri, 11 Apr 2008 05:45:58 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: <31872ffc-5bc4-44c8-961d-ee4f0dc356c5@k1g2000prb.googlegroups.com> On Apr 11, 5:33 pm, bdsatish wrote: > HI Gerard, > > I think you've taken it to the best possible implementation. Thanks ! > On Apr 11, 5:14 pm, Gerard Flanagan wrote: > > > In fact you can avoid the call to the builtin round: > > > ------------------------------------------------ > > > assert myround(3.2) == 3 > > assert myround(3.6) == 4 > > assert myround(3.5) == 4 > > assert myround(2.5) == 2 > > assert myround(-0.5) == 0.0 > > assert myround(-1.5) == -2.0 > > assert myround(-1.3) == -1.0 > > assert myround(-1.8) == -2 > > assert myround(-2.5) == -2.0 > > ------------------------------------------------ OK, I was too early to praise Gerard. The following version: def myround(x): n = int(x) if abs(x - n) >= 0.5 and n % 2: return n + 1 - 2 * int(n<0) else: return n of Gerard doesn't work for 0.6 (or 0.7, etc.) It gives the answer 0 but I would expect 1.0 ( because 0.6 doesn't end in 0.5 at all... so usual rules of round( ) apply) From speedman2010 at gmail.com Wed Apr 30 07:08:26 2008 From: speedman2010 at gmail.com (speedman2010) Date: Wed, 30 Apr 2008 04:08:26 -0700 (PDT) Subject: Essentio CS5110 the first produced desktop from asus Message-ID: <5053a61f-7971-4d8f-b725-f8ce93f87dc8@24g2000hsh.googlegroups.com> When I search web as every day I was surprised when I readied that ASUA company announced about it is new Essentio CS5110 desktop and I Saied " cool ASUS enter to the world of desktop manufactories " because ASUS produced good product and have a good Reputation On computer market and I waited for this step a long time To read more go to http://computerworld4y.blogspot.com/ From robert.spilleboudt.no.sp.am at skynet.be Thu Apr 10 15:52:19 2008 From: robert.spilleboudt.no.sp.am at skynet.be (Robert.Spilleboudt ) Date: Thu, 10 Apr 2008 21:52:19 +0200 Subject: Running a python code periodically In-Reply-To: References: Message-ID: <47fe6ff3$0$2956$ba620e4c@news.skynet.be> paul wrote: > Maryam Saeedi schrieb: >> Hi, >> >> I was wondering if you know how can I run a python code once every five >> minutes for a period of time either using python or some other program >> like >> a bash script. > > See the sched module in the standard library or here: > http://pypi.python.org/simple/Recur/ > > cheers > Paul > In a Python loop, use time.sleep(300) to wait 300 seconds. If you use Tkinter, there is another method to call periodically a function. Robert From breily at gmail.com Tue Apr 8 18:40:24 2008 From: breily at gmail.com (Brian) Date: Tue, 8 Apr 2008 18:40:24 -0400 Subject: Converting a tuple to a list In-Reply-To: References: <00ba01c899c5$14528ae0$0a01a8c0@mobile> Message-ID: On Tue, Apr 8, 2008 at 6:36 PM, Brian wrote: > > > On Tue, Apr 8, 2008 at 6:22 PM, Steve Holden wrote: > > > Gabriel Ibanez wrote: > > > Hi all .. > > > > > > I'm trying to using the map function to convert a tuple to a list, > > without > > > success. > > > > > > I would like to have a lonely line that performs the same as loop of > > the > > > next script: > > > > > > ------------------------------------------- > > > # Conveting tuple -> list > > > > > > tupla = ((1,2), (3,4), (5,6)) > > > > > > print tupla > > > > > > lista = [] > > > for a in tupla: > > > for b in a: > > > lista.append(b) > > > print lista > > > ------------------------------------------- > > > > > > Any idea ? > > > > > > Thanks ... > > > > > > # Gabriel > > > > > list(tupla) > > > > would probably do it. > > > > regards > > Steve > > -- > > Steve Holden +1 571 484 6266 +1 800 494 3119 > > Holden Web LLC http://www.holdenweb.com/ > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > > > That would just make a list of tuples, I think he wants [1, 2, 3, 4, 5, > 6]. > > Try: l = [x for z in t for x in z] Edit: Assuming t is tupla from your code. > > > --Brian > -------------- next part -------------- An HTML attachment was scrubbed... URL: From needin4mation at gmail.com Tue Apr 29 15:17:27 2008 From: needin4mation at gmail.com (jmDesktop) Date: Tue, 29 Apr 2008 12:17:27 -0700 (PDT) Subject: Simple import question about mac osx References: Message-ID: On Apr 29, 2:37?pm, "Jerry Hill" wrote: > On Tue, Apr 29, 2008 at 2:14 PM, jmDesktop wrote: > > ?Thanks. ?That worked on mac. ?But it does work like I said in > > ?Windows. ?Don't know why. ?Mr. Chun must also be using Windows because > > ?that is the way he does it in his book. > > It shouldn't work that way on windows either. ?Can you tell us a > little more about what you mean when you say you "compile this" under > windows? ?Normally, python code doesn't need to be compiled, so I'm > wondering if you're doing something different from what we expect when > you say you compile it and then import it in the interpreter. > > Are you by any chance writing code in IDLE, running it, then doing > things in the interpreter? > > ?-- > Jerry On Windows I took the text file I created on mac with vi and opened it in PythonWin. I ran it. It compiled. I run the import and call from the python interpreter. From bignose+hates-spam at benfinney.id.au Wed Apr 2 00:06:54 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Wed, 02 Apr 2008 15:06:54 +1100 Subject: ANN: pry unit testing framework References: Message-ID: <87zlscx5lt.fsf@benfinney.id.au> Aldo Cortesi writes: > We are happy to announce the first release of Pry, a unit testing > framework. Thanks for the announcement, and for the software. If Pry is already incompatible with xUnit (i.e. Python's 'unittest'), could we please have names that adhere to the Python style guide ? In particular the method names 'setUp', 'setUpAll', 'tearDown', 'tearDownAll' don't comply with the style guide. Compliant names for those methods would be 'set_up', 'set_up_all', etc. -- \ "Here is a test to see if your mission on earth is finished. If | `\ you are alive, it isn't." -- Francis Bacon | _o__) | Ben Finney From imliujie at gmail.com Wed Apr 23 02:48:00 2008 From: imliujie at gmail.com (Jack) Date: Wed, 23 Apr 2008 14:48:00 +0800 Subject: =?UTF-8?B?5pyJ5Lit5Zu95Lq65LmOPw==?= In-Reply-To: References: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> Message-ID: <480EDBA0.7070908@gmail.com> Jeroen Ruigrok van der Werven ??: > (My Mandarin is not very good.) > > -On [20080413 09:24], bikthh at live.cn (bikthh at live.cn) wrote: >> Python????????????????. > > Python indeed does have a good future. > I am not quite sure with ??????? if you are asking for someone to > teach to you or if you want to teach others. > ????????????C++ -------------- next part -------------- A non-text attachment was scrubbed... Name: jack_l_china.vcf Type: text/x-vcard Size: 124 bytes Desc: not available URL: From ajaksu at gmail.com Fri Apr 18 11:52:07 2008 From: ajaksu at gmail.com (ajaksu) Date: Fri, 18 Apr 2008 08:52:07 -0700 (PDT) Subject: What can we do about all the spam that the list is getting? References: <259ab201-9d2b-4e4e-88a7-e2fe277f0066@a23g2000hsc.googlegroups.com> Message-ID: <88eeaf57-fb34-49e5-a770-26ce5a0c63c9@k13g2000hse.googlegroups.com> On 16 abr, 14:01, sr... at ferg.org wrote: > What can we do about all the spam that comp.lang.python is getting? > Things are getting pretty bad. I'm reporting most spam, but I don't have high hopes Google cares. We could start a new group (non-usenet Google Groups allow message removal), but I guess most people would rather simply plonk GG posts. Perhaps we could find a way to tag spam threads that would auto-plonk those threads in our preferred reader (email, newsreader and Greasemonkey killfile)? This has the drawback that spam posted to ham threads would be hard to block... Regards, Daniel P.S.: I prefer posting from Google Groups, I'd rather avoid posting at all than having to use a different client... From nagle at animats.com Sat Apr 26 01:15:05 2008 From: nagle at animats.com (John Nagle) Date: Fri, 25 Apr 2008 22:15:05 -0700 Subject: Why is None <= 0 In-Reply-To: References: Message-ID: <4812b799$0$34553$742ec2ed@news.sonic.net> Gregor Horvath wrote: > D'Arcy J.M. Cain schrieb: >> On Fri, 25 Apr 2008 20:27:15 +0200 >> Gregor Horvath wrote: >>> >>> None <= 0 >>> True >>> >>> Why? >> >> Why not? > > Because, from http://www.python.org/dev/peps/pep-0020/ : > > Errors should never pass silently. > In the face of ambiguity, refuse the temptation to guess. > > Greg Good point. The problem is the typical one; Python did not originally have a Boolean type, and the retrofit resulted in weird semantics. C has the same issue. John Nagle From enleverlesX.XmcX at XmclaveauX.com Fri Apr 11 09:38:32 2008 From: enleverlesX.XmcX at XmclaveauX.com (Méta-MCI (MVP)) Date: Fri, 11 Apr 2008 15:38:32 +0200 Subject: Python plus Message-ID: <47ff69e4$0$842$ba4acef3@news.orange.fr> After IronPython, Python + iron : http://www.golfermania.com/SnakeEyes/PYTHON-PLUS-IRON.jpg ;o) Michel Claveau From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Sat Apr 26 06:30:37 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Sat, 26 Apr 2008 12:30:37 +0200 Subject: Pyserial - send and receive characters through linux serial port References: Message-ID: <67geidF2p1bmkU1@mid.individual.net> terry wrote: > I am trying to send a character to '/dev/ttyS0' and expect the > same character and upon receipt I want to send another character. > I tired with Pyserial but in vain. Pyserial works very well for me (despite the device I connect to has quite a screwed protocol and implementation). > Test Set up: > > 1. Send '%' to serial port and make sure it reached the serial > port. 2. Once confirmed, send another character. > > I tried with write and read methods in Pyserial but no luck. Are you actaully trying to get lucky by doing this, or are you observing a specific problem, e.g. nothing is received or wrong characters are received? Also, by what are they received? Regards, Bj?rn -- BOFH excuse #139: UBNC (user brain not connected) From stef.mientki at gmail.com Tue Apr 29 15:40:24 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Tue, 29 Apr 2008 21:40:24 +0200 Subject: __getattr__ and recursion ? Message-ID: <481779A8.6070208@gmail.com> hello, I tried to find an easy way to add properties (attributes) to a number of different components. So I wrote a class, from which all these components are derived. By trial and error I created the code below, which now works, but there is one thing I don't understand: in the line indicated with "<<== 1" I'm not allowed to use for item in self.extra_getters : because it will result in an infinite recursion. But in the line indicated with "<<== 2" , I am allowed ... ... why is this allowed ?? thanks, Stef Mientki # *********************************************************************** # *********************************************************************** class _add_attribs ( object ) : def __init__ ( self ) : self.extra_setters = {} self.extra_getters = {} def _add_attrib ( self, text, setter = None, getter = None ) : if setter : self.extra_setters [ text ] = setter if getter : self.extra_getters [ text ] = getter # ********************************************************* # always called instead of the normal mechanism # ********************************************************* def __setattr__ ( self, attr, value ) : for item in self.extra_setters : if item == attr : self.extra_setters [ item ] ( value ) break else : self.__dict__[attr] = value # ********************************************************* # only called when not found with the normal mechanism # ********************************************************* def __getattr__ ( self, attr ) : try : for item in self.__dict__['extra_getters'] : <<== 1 if item == attr : return self.extra_getters [ item ] ( ) <<== 2 except : return [] # *********************************************************************** From gagsl-py2 at yahoo.com.ar Tue Apr 22 11:55:58 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 22 Apr 2008 12:55:58 -0300 Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <675tasF2kecjsU1@mid.uni-berlin.de> Message-ID: En Tue, 22 Apr 2008 07:34:48 -0300, Diez B. Roggisch escribi?: > azrael schrieb: >> A friend of mine i a proud PERL developer which always keeps making >> jokes on python's cost. >> >> Please give me any arguments to cut him down about his commnets >> like :"keep programing i python. maybe, one day, you will be able to >> program in VisualBasic" >> >> This hurts. Please give me informations about realy famous >> aplications. > > This isn't worth too much, but nontheless: > > http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html Also, you can enter the Python main site, on the right and very prominently you have a link to many successful stories: http://www.python.org/about/success/ > But the real problem is not your friend - it's you. He hurts you because > you let him. Stop getting mad about that he teases you. I agree. -- Gabriel Genellina From oakley at bardo.clearlight.com Tue Apr 15 18:46:07 2008 From: oakley at bardo.clearlight.com (Bryan Oakley) Date: Tue, 15 Apr 2008 22:46:07 GMT Subject: tkinter, canvas, get color of image? In-Reply-To: References: <0e4c9708-dbe9-4f29-ac31-34f7298f2624@m1g2000pre.googlegroups.com> Message-ID: skanemupp at yahoo.se wrote: > On 13 Apr, 19:19, Bryan Oakley wrote: >> skanem... at yahoo.se wrote: >>> mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\elmapovic.gif') >>> w.create_image(10, 10, image = mapq, anchor = NW) >>> after doing this is there any possibility of getting the >>> characteristics of the GIF-picture(or bitmap if i use that)? >>> it would be very helpfull if i for example could do something like >>> canvas.getcolor(image, mouseclick.x,mouseclick.y) if u get the point. >>> get the color of the image where i clicked. >> The image isn't "painted" on the canvas, so to answer your specific >> question, no, you can't get the color of a pixel on the canvas in the >> way that you ask. >> >> However, when you click on the canvas you can get the item that was >> clicked on and the x/y of the click. From that you can figure out which >> pixel of the image is under the cursor. And from that you can query the >> image for the color of a specific pixel. > > > how do i get the item? > http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_image-method > > with any of those methods? > > when i click the mouse i can get event.object u mean? You can use find_closest to find the object closest to the x,y of the event. You can also do find_withtag(tk.CURRENT) which returns the item under the mouse pointer. From lutz.georg.horn at googlemail.com Wed Apr 30 02:44:26 2008 From: lutz.georg.horn at googlemail.com (Lutz Horn) Date: Wed, 30 Apr 2008 08:44:26 +0200 Subject: computing with characters In-Reply-To: <481813E2.2030302@islandtraining.com> References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> Message-ID: <7c85a2590804292344p7875dcf8te5d219a4b37a2153@mail.gmail.com> Hi, 2008/4/30 Gary Herron : > SL wrote: > > How can I compute with the integer values of characters in python? > > Like 'a' + 1 equals 'b' etc > > You can get an integer value from a character with the ord() function. So just for completion, the solution is: >>> chr(ord('a') + 1) 'b' Lutz -- Do you want a Google Mail invitation? Just write me an email! From samslists at gmail.com Sun Apr 6 16:40:11 2008 From: samslists at gmail.com (samslists at gmail.com) Date: Sun, 6 Apr 2008 13:40:11 -0700 (PDT) Subject: Implementation of Crockford's Base32 Encoding? References: <345117e9-2539-4ee0-8b27-9b1a88ddde7c@a1g2000hsb.googlegroups.com> <3EF041EA-8E9A-4DAA-B690-FC725D9E25D6@gmail.com> Message-ID: <9d34f801-29cc-4c19-80d2-2ebdcc41d0bc@8g2000hse.googlegroups.com> Gabriel... I looked at Zooko's encoding. I didn't really like that the first 16 characters weren't the same as for base 16, [0-9a-f]. I hadn't considered the need for padding. Zooko doesn't seem to use it either. How does he get around it? Thanks p.s. Paul...yes it is different. :) On Apr 6, 7:15 am, "Gabriel Genellina" wrote: > En Sun, 06 Apr 2008 06:07:18 -0300, Petite Abeille > escribi?: > > > On Apr 6, 2008, at 9:20 AM, samsli... at gmail.com wrote: > > >> Anyone know of aPythonimplementation of this: > >>http://www.crockford.com/wrmg/base32.html > > > Not sure aboutCrockford'sBase32encoding itself, but here is an > > implementation of Bryce "Zooko" Wilcox-O'Hearn's "human-oriented > > base-32 encoding": > > >https://zooko.com/repos/z-base-32/base32/ > >https://zooko.com/repos/z-base-32/base32/DESIGN > > The design and rationale looks better. TheCrockfordversion is > ill-defined in the sense that you can't recover the exact input string > length in some cases; by example both "\x00"*4 and "\x00"*5 share the same > encoding. > base-64 encoding, by example, uses '=' as pad bytes at the end to avoid > this problem. > > -- > Gabriel Genellina From goodz158 at yahoo.com Wed Apr 16 06:37:55 2008 From: goodz158 at yahoo.com (Good Z) Date: Wed, 16 Apr 2008 03:37:55 -0700 (PDT) Subject: Calling Java Class from python Message-ID: <608239.30549.qm@web35906.mail.mud.yahoo.com> All, We have developed a website in python and we need to integrate few features of third party website. They have provided us Base64EncoderDecoder Java Class and would like us to use it to encode the data before sending it to their site and decode it when received anything from their site. I have no idea/knowledge of Java. Can you please guide me how can i call Java class from Python scripts? Or what is the best way to handle this condition. Is Base64 library provided by python is compatible to Base64EncoderDecoder Java Class? Regards, Mike ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From bbxx789_05ss at yahoo.com Fri Apr 4 20:16:30 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Fri, 4 Apr 2008 17:16:30 -0700 (PDT) Subject: Is there any way to say ignore case with "in"? References: <47f692f3$0$759$bed64819@news.gradwell.net> Message-ID: <432d690f-44be-49a9-bc6a-1cf3445549d6@m71g2000hse.googlegroups.com> On Apr 4, 2:43?pm, tinn... at isbd.co.uk wrote: > Is there any way in python to say > > ? ? if string1 in string2: > ? ? ? ? > > ignoring the case of string1 and string2? > > I know I could use:- > > ? ? if lower(string1) in lower(string2): > ? ? ? ? > > but it somehow feels there ought to be an easier (tidier?) way. > Easier? You mean like some kind of mind meld? From timr at probo.com Wed Apr 30 02:32:21 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 30 Apr 2008 06:32:21 GMT Subject: File IO Issues, help :( References: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> Message-ID: Kevin K wrote: >On Apr 29, 12:38 am, "Eric Wertman" wrote: >> chuck in a jsfile.close(). The buffer isn't flushing with what you >> are doing now. jsfile.flush() might work... not sure. Closing and >> re-opening the file for sure will help though. >> > >Yeah sorry I forgot to include the close() in the quote but its there. >In fact I moved it up a bit and still no luck heres the new code: > >jsfile = open("../timeline.js", "r+") >jscontent = jsfile.readlines() >jsfile.truncate() > >for line in jscontent: > if re.search('var d =', line): > line = "var d = \""+mint['1'].ascdate()+"\"\n" > print line > jsfile.write(line) >jsfile.close() > >I tried this can got the same result...?? That's not what he meant. He meant: jsfile = open("../timeline.js", "r") jscontent = jsfile.readlines() jsfile.close() jsfile = open("../timeline.js", "w") ...etc... You have to decide whether this makes more sense to you than the seek/truncate solution. Personally, I'd prefer the close/open. Or even: jscontent = open("../timeline.js", "r").readlines() jsfile = open("../timeline.js", "w") ... etc ... -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From ajaksu at gmail.com Sun Apr 20 21:00:55 2008 From: ajaksu at gmail.com (ajaksu) Date: Sun, 20 Apr 2008 18:00:55 -0700 (PDT) Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> <480b6133$0$34498$742ec2ed@news.sonic.net> Message-ID: <7dbfc62c-b642-40d5-a55b-2d3d9efc3bd0@2g2000hsn.googlegroups.com> On Apr 20, 3:31?pm, Steve Holden wrote: > JB "My first post on c.l.py" Stern wrote: > > Curious Steve, how do you pay the rent and by what authority do you > > speak for "The Python world"? [snip] > I don't claim to speak *for* the > whole Python world, but as chairman of the Python Software Foundation ROTFLMAO From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 22 08:58:00 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 22 Apr 2008 14:58:00 +0200 Subject: Python Success stories In-Reply-To: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <480de0d0$0$24455$426a74cc@news.free.fr> azrael a ?crit : > Hy guys, > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. s/proud/stupid/ > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" > > This hurts. Please give me informations about realy famous > aplications. Don't let cretins hurt you. One of my best friends who is a die-hard Perl addict really loves Python too, and finds this kind of pissing contests more than stupid. From dave.l.harrison at gmail.com Mon Apr 7 01:45:33 2008 From: dave.l.harrison at gmail.com (David Harrison) Date: Mon, 7 Apr 2008 15:45:33 +1000 Subject: Help replacing os.system call with subprocess call In-Reply-To: References: <47F9B1D1.4090701@eastlink.ca> Message-ID: On 07/04/2008, David Harrison wrote: > On 07/04/2008, David Pratt wrote: > > Hi. I am trying to replace a system call with a subprocess call. I have > > tried subprocess.Popen and subprocess.call with but have not been > > successful. The command line would be: > > > > svnadmin dump /my/repository > svndump.db > > > > This is what I am using currently: > > > > os.system('svnadmin dump %s > %s' % (svn_dir, > > os.path.join(backup_dir, 'svndump.db'))) > > > > Many thanks. > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > > Hey David, > > Your probably want something like the following (code untested and off > the cuff ;-) ) > > Cheers > Dave > > --- > > import subprocess > > p = subprocess.Popen( > [ "svnadmin", "dump" ], > stdin=subprocess.PIPE, > stdout=subprocess.PIPE, > stderr=subprocess.PIPE, > close_fds=True > ) > (child_stdout, child_stdin) = (p.stdout, p.stdin) > > f = open('svndump.db') > f.write(child_stdout.read()) > f.close() My inner pendant kicked in so I tested the code using [ 'ls', '-lha' ] and found that the file object should be f = open('svndump.db', 'w') instead :-) From ang.usenet at gmail.com Tue Apr 8 16:56:53 2008 From: ang.usenet at gmail.com (Aaron Gray) Date: Tue, 8 Apr 2008 21:56:53 +0100 Subject: CPython VM & byte code resources wanted References: <6622srF2e32hbU1@mid.individual.net> Message-ID: <6624goF2icl0vU1@mid.individual.net> >Bytecodes: >http://docs.python.org/lib/bytecodes.html > >VM: >Python/ceval.c Thanks, Aaron From bockman at virgilio.it Wed Apr 16 03:04:07 2008 From: bockman at virgilio.it (bockman at virgilio.it) Date: Wed, 16 Apr 2008 00:04:07 -0700 (PDT) Subject: tkinter, event.widget, what do i get? References: <7caa5089-2ea9-4e18-9117-7431d7403976@l42g2000hsc.googlegroups.com> <3a6f6d87-0102-4995-a033-501137b3f934@s50g2000hsb.googlegroups.com> Message-ID: <953034b6-e4d0-4671-b518-92ed3e837b2b@59g2000hsb.googlegroups.com> On 16 Apr, 01:45, skanem... at yahoo.se wrote: > On 16 Apr, 00:24, "Gabriel Genellina" wrote: > > > > > > > En Tue, 15 Apr 2008 17:45:08 -0300, escribi?: > > > > when calling function hmm here, what do i get? the widget i clicked > > > on? > > > if i have a canvs on wich i have a bitmap and i click on the bitmap, > > > is the event.widget then the bitmap? > > > can i get info about the bitmap then? like color of the pixel i > > > clicked. if so, how? > > > > w.bind("", key) > > > w.bind("", hmm) > > > > def hmm(event): > > > ? ? return event.widget > > > Why don't you try by yourself? You can use: print repr(something) > > > -- > > Gabriel Genellina > > i get > > thing is i get that even though i click outside the image. > and what can i do with this number anyway?- Nascondi testo tra virgolette - > > - Mostra testo tra virgolette - If your image is a canvas item (i.e. created with canvas create_image method), then you can use the method tag_bind to handle events specific of that item. In that case, the callback argument is a Tkinter.Event instance. Ciao ----- FB From danfolkes at gmail.com Fri Apr 25 09:33:10 2008 From: danfolkes at gmail.com (Daniel Folkes) Date: Fri, 25 Apr 2008 06:33:10 -0700 (PDT) Subject: Can you recommend a book? References: Message-ID: On Apr 25, 6:28?am, "noagbodjivic... at gmail.com" wrote: > Hello all, I learned Python with the book "Programming Python" by John > Zelle. But today this book is a little bit old. My Python is some kind > old. I need a book that will help me brush my style and keep me up to > date. I would like one with practical examples. > > Can you recommend one? Learning Python followed by Programming Python. You should be able to find them in a Library too. From kirk.strauser at gmail.com Fri Apr 25 10:03:26 2008 From: kirk.strauser at gmail.com (Kirk Strauser) Date: Fri, 25 Apr 2008 07:03:26 -0700 (PDT) Subject: Subclassing list the right way? Message-ID: I want to subclass list so that each value in it is calculated at call time. I had initially thought I could do that by defining my own __getitem__, but 1) apparently that's deprecated (although I can't find that; got a link?), and 2) it doesn't work. For example: >>> class Foo(list): ... def __getitem__(self, index): ... return 5 ... >>> a = Foo([1, 2, 3, 4, 5]) >>> print a [1, 2, 3, 4, 5] >>> print a[2:4] [3, 4] >>> print a[3] 5 I first expected that to instead behave like: >>> print a [5, 5, 5, 5, 5] >>> print a[2:4] [5, 5] Is there a "right" way to do this? -- Kirk Strauser From jhenRemoveThis at talk21.com Mon Apr 28 22:20:37 2008 From: jhenRemoveThis at talk21.com (John Henderson) Date: Tue, 29 Apr 2008 12:20:37 +1000 Subject: Python Math libraries - How to? References: Message-ID: <67nevlF2q292cU1@mid.individual.net> aguirre.adolfo at gmail.com wrote: > Hi, I am a very newbie who would very much appreciate some > hints. > > Python 2.52. on Windows XP for now. Soon on Ubuntu 8 > > I am teaching myself Python following free tutorials. I can > solve problems using arithmetic, but when I try to upgrade the > programs using math libraries nothing seems to work. I > downloaded a 2002 tutorial from Zelle "An Introduction to > Computer Science" where he uses a "import math" statement to > calculate a square root. I tried the > "pi" library function but it didn?t work. I tried using def > Pi() it did not work either. I am yet to find a tutorial that > explains how to declare (or initialize) and pass numbers to > the functions such as "cos(x)" and the pi which does not have > a variable in it. Is just a constant. > > Here is the arithmetic program I made that it worked before I > added > the "import math" line. I erased the constant p = 3.1416 and > added the "i" for the library function "pi" in the algorithms. > But I get an error message not recognizing "pi" > > > > #volumen.py > # A program to compute the volume and surface area of a sphere > import math Change that line, "import math", to: from math import * and it'll work. I'm learning too, so some proficient person might be able to explain the difference to both of us :) John > > def main(): > > print "This program calculates the volume and surface area > of a > sphere" > print > r = input("Please enter the radious: ") > print > r3 = r*r*r > volume = 4/3*pi*r3 > r2 = r*r > surface = 4*pi*r2 > print "The Volume is", volume, " Cubic centimeters" > print > print "The Surface area is", surface, " square > centimeters" > > main() > > *** Error message ************* > > Traceback (most recent call last): > File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 20, > in > > main() > File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 13, > in main > volume = 4/3*pi*r3 > NameError: global name 'pi' is not defined From sevenjp at gmail.com Wed Apr 2 15:33:25 2008 From: sevenjp at gmail.com (=?ISO-8859-1?Q?Jo=E3o_Neves?=) Date: Wed, 2 Apr 2008 12:33:25 -0700 (PDT) Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> Message-ID: <10ee2a69-f4e2-4887-8083-6b02b60dd0cd@i7g2000prf.googlegroups.com> On Apr 2, 5:41 pm, "Dan Upton" wrote: > > The thing I've been wondering is why _is_ it read-only? In what > > circumstances having write access to co_code would break the language > > or do some other nasty stuff? > > > Jo?o Neves > > I can't speak to Python's implementation in particular, but > self-modifying code in general is unpleasant. It certainly is > possible to support it in runtime environments, but it's usually not > easy to do so. That is, of course, somewhat dependent on the > implementation of the runtime environment, and even to some degree the > underlying hardware. (For instance, the compiled code you want to run > could be in the hardware cache; if you then change the instructions at > those addresses in memory, it's not always straightforward to get the > processor to realize it needs to load the new data into the > instruction cache.) Plus, I suppose it might be possible to break > strong (even dynamic) typing if you start changing the code around > (although I can't construct an example off the top of my head). Indeed, the caching issue is a relevant one I guess, and adding the mechanism to go around that might have a significant impact on performance. I haven't looked in detail into it, but I agree with your opinion concerning strong and dynamic typing. If type check is done while compiling to bytecode, there is no guarantee the modified bytecode will respect the rules, for instance. I don't know though, haven't really checked how it's done at this point. :) I will be fiddling around with the Python VM these days anyway, and since I'm going to muck around the bytecode, I might just try to see the effects of removing the read-only restriction from co_code. > > In short, you need a good reason to support self-modifying code, and > my guess is nobody could come up with one for Python. > > -dan From what I've seen, Python has some support for lambda expressions, albeit it may be limited. Self-modifying code would greatly enhance this feature, I guess. Well, at least from a Lisp newbie perspective. :) --- Jo?o Neves From reachmsn at hotmail.com Tue Apr 15 04:00:07 2008 From: reachmsn at hotmail.com (reachmsn at hotmail.com) Date: Tue, 15 Apr 2008 01:00:07 -0700 (PDT) Subject: Cannot understand the detailedly the following code References: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> <10a83944-b17a-4c3f-992b-1754c0a5e9b1@s33g2000pri.googlegroups.com> Message-ID: <351a72fb-298a-461c-b42f-36da9d2f0d06@w8g2000prd.googlegroups.com> On Apr 11, 10:27?am, "Gabriel Genellina" wrote: > > If you want to understand how recursion works, or how you can actually ? > construct a recursive function step by step, see this excellent post by ? > Neil Cerutti: > > http://groups.google.com/group/comp.lang.python/msg/9f0b10631fd47886 > Hi, I did read the above post by Cerutti but I'm still having trouble writing this recursive function. I will be grateful if someone can kindly guide me. Regards, Anshu From filipe.tg at gmail.com Mon Apr 28 08:54:58 2008 From: filipe.tg at gmail.com (Filipe Teixeira) Date: Mon, 28 Apr 2008 05:54:58 -0700 (PDT) Subject: Retrieving int from hex in a file. References: <9edfaaa3-4e87-4f74-90a5-c10c9daae101@r66g2000hsg.googlegroups.com> Message-ID: > > Use ord(q) > > py> help(ord) > Help on built-in function ord in module __builtin__: > > ord(...) > ord(c) -> integer > > Return the integer ordinal of a one-character string. > > py> > > -- > Gabriel Genellina Thank you Gabriel. It fit's my purpose. From martin at v.loewis.de Wed Apr 16 15:56:20 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Wed, 16 Apr 2008 21:56:20 +0200 Subject: Does Python use a special home-made parser, or does it use Yacc? In-Reply-To: <236a2391-ac15-4910-8d47-5741256486d1@1g2000prf.googlegroups.com> References: <236a2391-ac15-4910-8d47-5741256486d1@1g2000prf.googlegroups.com> Message-ID: <480659e4$0$27007$9b622d9e@news.freenet.de> Robert wrote: > Or some other pre-packaged parser tool? None of them: it's not YACC, not a pre-packaged parser tool, and not a home-made parser. Instead, it uses pgen, a parser tool that is included in the Python distribution (whether *that* was made at home or at work, I don't know :-). Regards, Martin From google at mrabarnett.plus.com Tue Apr 1 17:37:41 2008 From: google at mrabarnett.plus.com (MRAB) Date: Tue, 1 Apr 2008 14:37:41 -0700 (PDT) Subject: Why prefer != over <> for Python 3.0? References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> Message-ID: <84aaed5f-d151-48e9-bfc0-cc69f12b6ec4@f63g2000hsf.googlegroups.com> On Mar 30, 7:59 pm, "Gabriel Genellina" wrote: > En Sun, 30 Mar 2008 11:10:20 -0300, MRAB > escribi?: > > > > > On Mar 30, 6:35 am, "Gabriel Genellina" > > wrote: > >> En Sun, 30 Mar 2008 02:11:33 -0300, hdante escribi?: > > >> > BTW, my opinion is that it's already time that programmer editors > >> > have input methods advanced enough for generating this: > > >> > if x ? 0: > >> > ?y ? s: > >> > if y ? 0: f1(y) > >> > else: f2(y) > > >> Fine if you have the right keyboard... Try to write APL with a standard > >> keyboard :) > > > There was a version of APL for the Sinclair QL which replaced the > > standard APL symbols with keywords. > > Wow, APL on 8 bits? > Now there is (or perhaps there was) J, a reincarnation of APL by Iverson > himself that uses ASCII characters only. > The Sinclair QL used the Motorola 68008, which was like the 68000 (a 32-bit processor) but with an 8-bit external data bus instead of a 16- bit one; that made the system cheaper to build, but as the instructions were multiples of 16 bits long every instruction required at least 2 memory accesses, which made it slower. Nice clean processor though, unlike the 8086... :-) From mail at timgolden.me.uk Wed Apr 23 13:12:45 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 23 Apr 2008 18:12:45 +0100 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. In-Reply-To: <480f6553$0$34545$742ec2ed@news.sonic.net> References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> Message-ID: <480F6E0D.2070808@timgolden.me.uk> John Nagle wrote: > Mike Driscoll wrote: >> Ken, >> >> On Tue, Apr 22, 2008 at 1:36 PM, Kenneth McDonald >> wrote: >>> Sadly. >>> >>> Thanks, >>> Ken >>> -- >>> http://mail.python.org/mailman/listinfo/python-list >>> >> >> I've attached the 2.4 version. I also have some Windows binaries for >> Beautiful Soup uploaded to my website: >> http://www.pythonlibrary.org/python_modules.htm > > What on earth do you need a "Windows binary" for? "BeautifulSoup" > is ONE PYTHON SOURCE FILE, "BeautifulSoup.py". Ummm.. Why does it bother you? Mike seems to be offering a public service to Windows users: by downloading the .exe, I can double-click on one file, have the module or package installed (whether it contains one .py file or twenty or a series of compiled extension modules and their respective DLLs) and for a bonus it's registered in the system packages directory [*] and is therefore uninstallable from there. It's not much different from a Linux distro offering BeautifulSoup via its module repository: apt-get or yum or whatever. Certainly, if you prefer, then go to PyPI or to the source address which you helpfully provided and download the one python source file. I'm sure I don't mind. TJG [*] Which isn't, admittedly, what everyone wants to happen... From urquhart.nak at gmail.com Wed Apr 30 06:27:54 2008 From: urquhart.nak at gmail.com (urquhart.nak at gmail.com) Date: Wed, 30 Apr 2008 03:27:54 -0700 (PDT) Subject: patch management Message-ID: patch management http://crack.cracksofts.com From bockman at virgilio.it Wed Apr 2 13:33:41 2008 From: bockman at virgilio.it (Francesco Bochicchio) Date: Wed, 02 Apr 2008 19:33:41 +0200 Subject: who said python can't be obsfucated!? References: Message-ID: On Wed, 02 Apr 2008 07:19:08 -0700, cokofreedom wrote: > def s(c):return[]if c==[]else s([_ for _ in c[1:]if _ +s([_ for _ in c[1:]if _>=c[0]]) > > Anyone else got some wonders...? Not so good: it took me only one minute to anderstand that is a recursive sort ... or it is? I read it as: """ the function s applied to a list is equal to the empty list if the input list is empty, otherwise it is equal to the result of the function s applied to all the elements smaller than the first one plus the first element plus the function sort applied to all the elements greater or equal to the first one, except the first one itself. """ I like the almost one-to-one corrispondence between the code elements and the components of the sentence describing the function. Now _that_ is an human-friendly syntax :-) Ciao ---- FB From tracyde at gmail.com Wed Apr 2 14:09:45 2008 From: tracyde at gmail.com (Derek Tracy) Date: Wed, 2 Apr 2008 14:09:45 -0400 Subject: Manipulate Large Binary Files In-Reply-To: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> Message-ID: <9999810b0804021109n77f2c990p7b10d92e9344ad00@mail.gmail.com> On Wed, Apr 2, 2008 at 10:59 AM, Derek Tracy wrote: > I am trying to write a script that reads in a large binary file (over 2Gb) saves the header file (169088 bytes) into one file then take the rest of the data and dump it into anther file. I generated code that works wonderfully for files under 2Gb in size but the majority of the files I am dealing with are over the 2Gb limit > > INPUT = open(infile, 'rb') > header = FH.read(169088) > > ary = array.array('H', INPUT.read()) > > INPUT.close() > > OUTF1 = open(outfile1, 'wb') > OUTF1.write(header) > > OUTF2 = open(outfile2, 'wb') > ary.tofile(OUTF2) > > > When I try to use the above on files over 2Gb I get: > OverflowError: requested number of bytes is more than a Python string can hold > > Does anybody have an idea as to how I can get by this hurdle? > > I am working in an environment that does not allow me to freely download modules to use. Python version 2.5.1 > > > > R/S -- > --------------------------------- > Derek Tracy > tracyde at gmail.com > --------------------------------- > I know have 2 solutions, one using partial and the other using array Both are clocking in at the same time (1m 5sec for 2.6Gb), are there any ways I can optimize either solution? Would turning off the read/write buff increase speed? -- --------------------------------- Derek Tracy tracyde at gmail.com http://twistedcode.blogspot.com --------------------------------- From severian at severian.org Wed Apr 16 10:26:09 2008 From: severian at severian.org (Severian) Date: Wed, 16 Apr 2008 10:26:09 -0400 Subject: Embedding Python in my C++ application Message-ID: <48060c3a$0$18426$39cecf19@news.twtelecom.net> I am working on embedding Python 2.5 in my C++ application, and I have a few questions: 1) My application is multi-threaded; what problems should I be aware of if I create a separate interpreter in each working thread? The documentation is a bit vague (or perhaps I haven't found the right place). Calls into my application are already thread-safe. 2) Rather than implementing my own editor in C++, I would like to be able to use existing tools to some degree, such as a python editor, interactive interpreter and perhaps even debugger, without impacting the main (GUI) thread of my application. Is there an example application, or any hints from someone who has done this? 3) Because my program links statically with the C runtime (on Windows), and Python links with it dynamically, there are some things that cannot be passed back and forth, such as C file handles and FILE pointers. Is anyone aware of other issues this may cause? I will greatly appreciate help with these questions, or advice on embedding Python in general! Thanks, Sev From jzgoda at o2.usun.pl Wed Apr 9 08:25:41 2008 From: jzgoda at o2.usun.pl (Jarek Zgoda) Date: Wed, 09 Apr 2008 14:25:41 +0200 Subject: is Pylons alive? In-Reply-To: References: Message-ID: Mage napisa?(a): > I don't want to be impolite, just in short: I am thinking about leaving > RoR and coming back to Python. I've missed the last two years in Python, > however I have been subscribed to this list and there are not too many > e-mails about Pylons in my mailbox. > > On my Gentoo the latest Pylons ebuild has date "jul 2007" or something > like last summer. It has testing keywords both for x86 and amd64. (No > stable version available). It's available on my debian "testing" desktop. > > Before spending much time for investigating, I would like to ask you: is > Pylons the framework I look for if I want to come back to Python and > develop MVC web apps? Latest commit is dated 2008-04-06, so I suppose it's alive, just no release was done in last time. -- Jarek Zgoda Skype: jzgoda | GTalk: zgoda at jabber.aster.pl | voice: +48228430101 "We read Knuth so you don't have to." (Tim Peters) From kj7ny at nakore.com Fri Apr 4 16:20:55 2008 From: kj7ny at nakore.com (kj7ny) Date: Fri, 4 Apr 2008 13:20:55 -0700 (PDT) Subject: Self in Interactive Interpreter Message-ID: Hope this hasn't been posted hundreds of times. I have never seen it before, but could have missed it. For years it has been a slight annoyance that every time I wanted to test a snippet of code from a class by running it in the interactive interpreter, I had to remove all of the self. instances from the code. After I got it working correctly, I had to put all the self.'s back into the code to put it back into my class. The other day my brain had a functional synapse and I realized I could just start my interactive session with: >>> class dummy: >>> def __init__(self): >>> pass >>> self=dummy() I could then just set up my test variables something like: >>> self.x='Hello' >>> self.y='World' And I could then use class type code such as: >>> print self.x, self.y I no longer had to remove and then replace all of the self. notation from my code snippets. So far I haven't seen why I shouldn't to this. I haven't had any problems using it, but I haven't used it that much. If there is a good reason to NOT do it, let me know. Otherwise I hope this helps anyone who has been annoyed by the same thing. Thanks, From lbonafide at yahoo.com Tue Apr 1 14:57:21 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Tue, 1 Apr 2008 11:57:21 -0700 (PDT) Subject: Is this a good time to start learning python? References: <47f1140e$0$735$a729d347@news.telepac.pt> Message-ID: <88fa881e-e59b-4682-801c-90ef08a1480a@a22g2000hsc.googlegroups.com> On Apr 1, 12:47?pm, "Gabriel Genellina" wrote: > En Tue, 01 Apr 2008 13:57:55 -0300, escribi?: > > > On Mar 31, 1:36?pm, "Gabriel Genellina" > > wrote: > > >> Don't be scared by the "backwards incompatible" tag - it's the way to ? > >> get ? > >> rid of nasty things that could not be dropped otherwise. > > > I would consider breaking production code to be "nasty" as well. > > Please explain how the existence of Python 3.0 would break your production ? > code. The existence of battery acid won't hurt me either, unless I come into contact with it. If one eventually upgrades to 3.0 -- which is ostensibly the desired path -- their code could break and require fixing. Backward compatibility is important. C++ could break all ties with C to "clean up" as well, but it would be a braindead move that would break existing code bases upon upgrade. From fennelllindy8241 at gmail.com Mon Apr 28 03:14:59 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:14:59 -0700 (PDT) Subject: risk2 no disk patch Message-ID: risk2 no disk patch http://crack.cracksofts.com From python.tsp at gmail.com Wed Apr 30 06:03:38 2008 From: python.tsp at gmail.com (pramod sridhar) Date: Wed, 30 Apr 2008 15:33:38 +0530 Subject: help: Question regarding parallel communication using python Message-ID: Hello, I would like from my Python application to control 2 (or more devices) using the existing port's interface in my PC,like serial (COM1) or Parallel port (lpt) or any other like PCI...etc. The control mechanism usually involves sending messages to the connected devices in parallel. For instance, I would like to send a command to a target connected on COM port and at the same time would like to read the value of a Digital multimeter over other COM port ( or may be via USB with some adapter) My Question is: - Is it possible to achieve the above in Python ? - Do we need to use any kind of Parallel processing to achieve this ? - If so, Which of the available packages (like pypar or Pydusa..etc) suits best ? Please suggest. Thank you very much in advance, With Regards, Pramod -------------- next part -------------- An HTML attachment was scrubbed... URL: From tinnews at isbd.co.uk Thu Apr 3 10:42:25 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 03 Apr 2008 14:42:25 GMT Subject: How easy is it to install python as non-root user? References: <47f4e617$0$720$bed64819@news.gradwell.net> <47f4e825$0$20141$426a74cc@news.free.fr> Message-ID: <47f4ecd1$0$712$bed64819@news.gradwell.net> Bruno Desthuilliers wrote: > tinnews at isbd.co.uk a ?crit : > > Does python install fairly easily for a non-root user? > > > > I have an ssh login account onto a Linux system that currently > > provides Python 2.4.3 and I'd really like to use some of the > > improvements in Python 2.5.x. > > > > So, if I download the Python-2.5.2.tgz file is it just the standard:- > > > > ./configure --prefix=$HOME > > make > > make install > > > IIRC there's something like make altinstall - but you'd better read the > doc (INSTALL.txt anyone ?) > Well it seems to work perfectly! :-) I just did the usual sequence as noted above and I seem to have a working Python 2.5.2 of my very own. I didn't need 'make altinstall' because I don't need to be able to see the existing Python 2.4.3. It takes a few Mb of disk space but since my free quote is 3Gb or something that doesn't really worry me. I'm impressed, well done Python developers. -- Chris Green From deets at nospam.web.de Wed Apr 23 10:34:11 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 23 Apr 2008 16:34:11 +0200 Subject: Python generators (coroutines) In-Reply-To: References: Message-ID: <678vnoF2nd7eoU1@mid.uni-berlin.de> rocco.rossi at gmail.com schrieb: > I would really like to know more about python 2.5's new generator > characteristics that make them more powerful and analogous to > coroutines. Is it possible for instance to employ them in situations > where I would normally use a thread with a blocking I/O (or socket) > operation? If it is, could someone show me how it can be done? There > appears to be a very limited amount of documentation in this repect, > unfortunately. What do you mean by "new generator characteristics"? AFAIK generators have been around at least since python2.3. Newer versions of python include things like generator expressions (since 2.4 I believe). However, generators don't help anything in blocking IO-situations, because they rely on co-operatively re-scheduling using yield. Of course you could try & use non-blocking IO with them, but I don't see that there is much to them. Or you could go & use a single poll/select in your main-thread, and on arrival of data process that data with generators that re-schedule in between so that you can react on newer data. Depending on your scenario this might reduce latency. Diez From bockman at virgilio.it Sat Apr 26 05:07:45 2008 From: bockman at virgilio.it (Francesco Bochicchio) Date: Sat, 26 Apr 2008 11:07:45 +0200 Subject: problem with listdir References: Message-ID: On Sat, 26 Apr 2008 01:24:23 -0700, jimgardener wrote: > hi > i have a directory containing .pgm files of P5 type.i wanted to read > the pixel values of these files ,so as a firststep i wrote code to > make a list of filenames using listdir > > pgmdir="f:\code\python\pgmgallery" # where i have pgm files > g2=listdir(pgmdir) > > i get the following error > WindowsError: [Error 123] The filename, directory name, or volume > label syntax is incorrect: 'f:\\code\\python\pgmgallery/*.*' > > i am running python on winXP ..can anyone tell me why i get this > error? Did you try using a raw string as pathname pgmdir=r"f:\code\python\pgmgallery" ? AFAIK, the character '\' in interpreted in Python as the beginning of an escape sequence (such as '\n') and it should be doubled ( as in the error message) or a raw string should be used, telling Python that there are no escape sequences inside. However, from the message it looks like the path as been understood as such, so this might not be the case. Ciao ----- FB From spocksplanet at gmail.com Thu Apr 17 13:02:22 2008 From: spocksplanet at gmail.com (sp@k) Date: Thu, 17 Apr 2008 10:02:22 -0700 (PDT) Subject: Newbie question about for...in range() structure References: Message-ID: <93bf7c9f-f6b7-4d04-8d6f-c9c0ce024326@a23g2000hsc.googlegroups.com> > My guess is that you want to initialize total to 1, not 0. > D'oh! Yes, you are right, thank you. From victorsubervi at gmail.com Wed Apr 9 12:11:28 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 9 Apr 2008 12:11:28 -0400 Subject: String Literal to Blob In-Reply-To: <47FCDC77.7030407@holdenweb.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> Message-ID: <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> On Wed, Apr 9, 2008 at 11:10 AM, Steve Holden wrote: > Victor Subervi wrote: > > > On Wed, Apr 9, 2008 at 10:24 AM, Steve Holden > steve at holdenweb.com>> wrote: > > connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > > cursor = connection.cursor() > > cursor.execute('select img from photo where id="7";') > > content = cursor.fetchall() > > > > Bzzt! Nope. Cursor.fetchall() returns a list (length 1) or tuples (length > 1) here, so this should be > > content = cursor.fetchall()[0][0] > > or, perhaps better > > content = cursor.fetchone()[0] I tried both of these, and they, too, gave me the same identical image of the url, not the image I am after. > > > You really don't understand how the web works, do you? I am just really, really, stupid, Steve. Please forgive me for being so stupid. But I am persistent. And I have built dozens of Web site with images. > In order to include an image in a page your browser must make TWO > requests. The first is for an HTML page that will reference the image in > this way: > > > > Seeing this img tag causes the browser to make a SECOND request, which the > script I corrected above should respond to with an image. > > The bytestream is critical in the image response. Even one misplaced byte > will mess things up terribly. In my stupidity, I have assumed you meant this: content = col_fields[0][14].tostring() print '

' Obviously I am wrong. Could you please give me a little more insight? > BTW, when we are finally done with this, I will write a nice how-to (since > > there is not one in python, while php has some nice ones) on how to do this, > > and give you and Gabrielle all your due credit. I will post it to this list, > > because that is sure to rank highly in google right away. > > Victor > > > > That's great, though hardly the point of the exercise. I think Google > already know about Gabriel (*not* Gabrielle) and me already ... Well, I just thought it might be a good way to get the information out, since it is not out there yet. And I believe it is only proper to give credit where credit is due. I would not be doing this to praise you. Rather, I would be doing this because it is needed, and I would feel wrong for not crediting those who deserve credit. Please let me know, however, if you feel otherwise. TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From flarefight at googlemail.com Sun Apr 27 09:21:48 2008 From: flarefight at googlemail.com (flarefight at googlemail.com) Date: Sun, 27 Apr 2008 06:21:48 -0700 (PDT) Subject: Loading associated files References: <74862697-da58-4eb7-8d60-09aaef54b7ad@j22g2000hsf.googlegroups.com> <09337541-0b3e-4aaf-b26f-06a0f689e7dc@u12g2000prd.googlegroups.com> Message-ID: Yep, thats pretty much exactly what i had done, those exact settings, and it still doesnt work. As i said i looked at the other keys to check i had done it right and a i said the settings are fine because i can send the file to python.exe and it loads like a python file fine, but it doesn't like passing it to my program. Have i done something wrong with my program that simply prints the arguments?? From zaleos at gmail.com Wed Apr 2 04:31:59 2008 From: zaleos at gmail.com (Oolon Colluphid) Date: Wed, 2 Apr 2008 01:31:59 -0700 (PDT) Subject: IM status with appscript Message-ID: hi, i need access to application attributes of IM (like Adium, aMsn, MS Messenger) on Mac platform via appscript module. once instantiated the application object with: app=app("Adium") i don't know how recover information like status, and i have find no references. can someone help me? From bignose+hates-spam at benfinney.id.au Sun Apr 27 10:14:02 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Mon, 28 Apr 2008 00:14:02 +1000 Subject: Random/anonymous class methods References: <801e1c38-ae54-443c-8d87-9745db7ef270@59g2000hsb.googlegroups.com> Message-ID: <87tzhn4c7p.fsf@benfinney.id.au> philly_bob writes: > How can I send ch, which is my random choice, to the myclass > instance? > > Thanks, > > Bob= > > #### > import random > > class myclass(object): > def meth1(self): > print 'meth1' > def meth2(self): > print 'meth2' > > c=myclass() > meths=['meth1', 'meth2'] > ch=random.choice(meths) > c.ch() Functions (including methods) are objects, and can be referenced and bound like any other object:: >>> import random >>> class OptionDispatcher(object): ... def option_a(self): ... print "option a" ... def option_b(self): ... print "option b" ... >>> dispatcher = OptionDispatcher() >>> choice = dispatcher.option_a >>> choice() option a >>> choice = dispatcher.option_b >>> choice() option b >>> options = [dispatcher.option_a, dispatcher.option_b] >>> choice = random.choice(options) >>> choice() option a >>> -- \ ?I must say that I find television very educational. The | `\ minute somebody turns it on, I go to the library and read a | _o__) book.? ?Groucho Marx | Ben Finney From grante at visi.com Thu Apr 17 14:30:18 2008 From: grante at visi.com (Grant Edwards) Date: Thu, 17 Apr 2008 13:30:18 -0500 Subject: What can we do about all the spam that the list is getting? References: <259ab201-9d2b-4e4e-88a7-e2fe277f0066@a23g2000hsc.googlegroups.com> Message-ID: On 2008-04-17, Mark Shroyer wrote: >>> So download a "real" NNTP client for whatever platform you're >>> on and give its spam filter a shot; clearly Google is not >>> interested in fighting spam itself. >> >> Plonking anything posted via google.groups is the simplest >> answer. > > Yes, but it's hard to give him that advice with a straight > face until I've convinced him to stop using Google Groups to > begin with ;) When using Google Groups can one kill all posts made via Google Groups? Presuming he has no burning need to see his own posts (something that can't be said for everybody in the history of Usenet), it might still be a viable approach. -- Grant Edwards grante Yow! VICARIOUSLY experience at some reason to LIVE!! visi.com From http Tue Apr 1 04:12:26 2008 From: http (Paul Rubin) Date: 01 Apr 2008 01:12:26 -0700 Subject: counting using variable length string as base References: Message-ID: <7xlk3yro2d.fsf@ruckus.brouhaha.com> Grimsqueaker writes: > Basically I want to find every possible order of every combination. > Its easy if you know how many characters there will be in your string > (use nested for loops), but I am stuck with the variable length > string. I think I have to use a generator but I'm not sure exactly how. > > Can anyone give me a pointer in the right direction? The basic idea is to use recursion to get the effect of nested for loops except to an arbitrary depth. You don't need a generator. From brianc at temple.edu Wed Apr 9 13:36:38 2008 From: brianc at temple.edu (Brian Cole) Date: Wed, 9 Apr 2008 11:36:38 -0600 Subject: Python Leopard DLL Hell In-Reply-To: <47FC2161.5020905@gmail.com> References: <54b165660804081819g4787f4d9g821c7269af7b4c66@mail.gmail.com> <47FC2161.5020905@gmail.com> Message-ID: <54b165660804091036n40aef4c9r98aabe2a059fc19e@mail.gmail.com> I have learned that this is a specific behavior of OS X. I have submitted a formal bug report to Apple about the problem. It appears that this is documented by Apple as acceptable: http://developer.apple.com/documentation/DeveloperTools/Reference/MachOReference/Reference/reference.html#//apple_ref/c/func/dlopen Whereas, linux will respect the fact you gave it a specific shared library: http://linux.die.net/man/3/dlopen If I am provided a workaround by apple I will post a python patch. A little scary that someone can circumvent my application by just setting an environment variable. -Brian Cole On Tue, Apr 8, 2008 at 7:52 PM, Michael Torrie wrote: > Brian Cole wrote: > > That appears to be working correctly at first glance. The argument to > > dlopen is the correct shared library. Unfortunately, either python or > > OS X is lying to me here. If I inspect the python process with OS X's > > Activity Monitor and look at the "Open Files and Ports" tab, it shows > > that the _foo.so shared library is actually the one located inside > > $DYLD_LIBRARY_PATH. > > > > So this problem may not be python's, but I place it here as a first > > shot (maybe I'm using the imp module incorrectly). > > Sounds like you're going to need to learn how to use dtrace. Then you > can more closely monitor exactly what python and the loader are doing. > dtrace is very complicated (borrowed from Solaris) but extremely > powerful. Worth learning anyway, but sounds like it's probably the > debugging tool you need. > > Another thing you can do is check through the python source code and see > how the os x-specific code is handling this type of situation. > > -- > http://mail.python.org/mailman/listinfo/python-list > From sjmachin at lexicon.net Sun Apr 20 02:01:59 2008 From: sjmachin at lexicon.net (John Machin) Date: Sun, 20 Apr 2008 06:01:59 GMT Subject: 2's complement conversion. Is this right? In-Reply-To: References: <2008041813575616807-bob@passcalnmtedu> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> Message-ID: <480adc56@news.mel.dft.com.au> Ross Ridge wrote: > Ross Ridge wrote: >> It's the same as the previous version except that it "precompiles" >> the struct.unpack() format string. =A0It works similar to the way Python >> handles regular expressions. > > George Sakkis wrote: >> I didn't know about the Struct class; pretty neat. It's amazing that >> this version without Psyco is as fast Bob's version with Psyco! > > Unfortunately, it doesn't seem to documented in the Python 2.5 manual. It seems to me that it's documented: http://docs.python.org/lib/struct-objects.html The struct module doc page (http://docs.python.org/lib/module-struct.html) provides links but no explicit mention of the Struct class in its text. From torriem at gmail.com Mon Apr 21 22:10:03 2008 From: torriem at gmail.com (Michael Torrie) Date: Mon, 21 Apr 2008 20:10:03 -0600 Subject: Lists: why is this behavior different for index and slice assignments? In-Reply-To: <480d435b$0$11643$607ed4bc@cv.net> References: <480d435b$0$11643$607ed4bc@cv.net> Message-ID: <480D48FB.4000405@gmail.com> John Salerno wrote: > So the question is, when you assign an empty list to an index, why does > it insert an empty list, but when you assign an empty list to a slice, > it simply deletes the slice? I would say this is consistent behavior because a list slice is also a list itself. Whereas a list element is just that. A reference to an object that can be rebound. In the latter case you are rebinding a single list item to an empty list. From mnordhoff at mattnordhoff.com Sun Apr 27 11:06:54 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Sun, 27 Apr 2008 15:06:54 +0000 Subject: removing extension In-Reply-To: References: Message-ID: <4814968E.4090604@mattnordhoff.com> Arnaud Delobelle wrote: > More simply, use the rsplit() method of strings: > >>>> path = r'C:\myimages\imageone.jpg' >>>> path.rsplit('.', 1) > ['C:\\myimages\\imageone', 'jpg'] > > >>>> path = r"C:\blahblah.blah\images.20.jpg" >>>> path.rsplit('.', 1) > ['C:\\blahblah.blah\\images.20', 'jpg'] > > HTH There's os.path.splitext(), which probably does just about exactly that. -- From aaron.watters at gmail.com Tue Apr 1 16:40:19 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Tue, 1 Apr 2008 13:40:19 -0700 (PDT) Subject: object-relational mappers Message-ID: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> I've been poking around the world of object-relational mappers and it inspired me to coin a corellary to the the famous quote on regular expressions: "You have objects and a database: that's 2 problems. So: get an object-relational mapper: now you have 2**3 problems." That is to say I feel that they all make me learn so much about the internals and features of the O-R mapper itself that I would be better off rolling my own queries on an as-needed basis without wasting so many brain cells. comments? -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=mild+exponential+growth From bvidinli at gmail.com Mon Apr 28 05:42:55 2008 From: bvidinli at gmail.com (bvidinli) Date: Mon, 28 Apr 2008 12:42:55 +0300 Subject: apache module: python and web programming, easy way...? Message-ID: <36e8a7020804280242t3f050b86o2574942cae460484@mail.gmail.com> is there any apache module, you know, that i can just install with apt-get, then put my .py file, and run it ? 2008/4/27 David : > > > > www.webpy.org is supereasy to get going with. dont know which is > > better for advanced stuff. > > > > I don't think that webpy supports sessions. Their addition to webpy is > a Google Summer of Code project: > > http://webpy.org/sessions/gsoc > > Also, I can't find any reference to cookies or sessions in the webpy > online docs. Maybe it's possible to bolt on support with Python's > Cookie module. > > David. > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From danb_83 at yahoo.com Tue Apr 22 22:27:22 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Tue, 22 Apr 2008 19:27:22 -0700 (PDT) Subject: Explicit variable declaration References: Message-ID: <29cc373e-7c27-42cf-980e-733a7bfe6aa5@f63g2000hsf.googlegroups.com> On Apr 22, 7:39 pm, "Filip Gruszczy?ski" wrote: > Hello everyone! > > It is my first message on this list, therefore I would like to say > hello to everyone. I am fourth year student of CS on the Univeristy of > Warsaw and recently I have become very interested in dynamically typed > languages, especially Python. > > I would like to ask, whether there is any way of explicitly declaring > variables used in a function? While I am pretty sure, that there is no > such way in the language itself, I would like to know, whether there > are any third-party tools to do that. This would be very useful for me > during development, so I am looking for such a tool. def a_function(args): # Local variables: item, item2 ... ;-) From x31equsenet at gmail.com Fri Apr 11 10:50:33 2008 From: x31equsenet at gmail.com (Graham Breed) Date: Fri, 11 Apr 2008 07:50:33 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: <63e33f12-cd06-46c7-90fe-0495c45514cf@n1g2000prb.googlegroups.com> On Apr 11, 6:14 pm, bdsatish wrote: > The built-in function round( ) will always "round up", that is 1.5 is > rounded to 2.0 and 2.5 is rounded to 3.0. > > If I want to round to the nearest even, that is > > my_round(1.5) = 2 # As expected > my_round(2.5) = 2 # Not 3, which is an odd num If you care about such details, you may be better off using decimals instead of floats. > I'm interested in rounding numbers of the form "x.5" depending upon > whether x is odd or even. Any idea about how to implement it ? import decimal decimal.Decimal("1.5").to_integral( rounding=decimal.ROUND_HALF_EVEN) decimal.Decimal("2.5").to_integral( rounding=decimal.ROUND_HALF_EVEN) ROUND_HALF_EVEN is the default, but maybe that can be changed, so explicit is safest. If you really insist, import decimal def my_round(f): d = decimal.Decimal(str(f)) rounded = d.to_integral(rounding=decimal.ROUND_HALF_EVEN) return int(rounded) Graham From collardfelszkw at gmail.com Sun Apr 20 16:32:59 2008 From: collardfelszkw at gmail.com (collardfelszkw at gmail.com) Date: Sun, 20 Apr 2008 13:32:59 -0700 (PDT) Subject: jennifer aniston paul sculfor Message-ID: <989eef80-b825-44ac-80dc-c1176e038444@l28g2000prd.googlegroups.com> Just few link on some Movies Movies: http://Jennifer-Aniston.12w.net F R E E C E L E B R I T Y M O V I E S From steve at holdenweb.com Tue Apr 8 15:35:30 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 15:35:30 -0400 Subject: Google App Engine In-Reply-To: References: Message-ID: Duncan Booth wrote: [...] > Yes, it says you can use almost any Python web framework but django is the > preferred one. > > Some of the comments at > http://www.techcrunch.com/2008/04/07/google-jumps-head-first-into-web-services-with-google-app-engine/ > sound kind of upset, e.g.: "Python will be a deal breaker for many?" > or "Python only. What a weird decision. Not business and community-friendly at all." Right, but that's people for you. If you watch the announcement video Guido specifically says that other languages will be supported and Python is merely the first. That decision wasn't Guido's, either. But people will always prefer complaining on the grounds of insufficient information to keeping quiet on the basis of knowledge. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From skanemupp at yahoo.se Sun Apr 20 18:36:12 2008 From: skanemupp at yahoo.se (globalrev) Date: Sun, 20 Apr 2008 15:36:12 -0700 (PDT) Subject: close GUI and quit script? Message-ID: how do i close a GUI and end the mainloop of the script? From stef.mientki at gmail.com Mon Apr 28 12:29:38 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Mon, 28 Apr 2008 18:29:38 +0200 Subject: class or class-instance ? In-Reply-To: <67ld5cF2jm4mjU1@mid.uni-berlin.de> References: <67ld5cF2jm4mjU1@mid.uni-berlin.de> Message-ID: <4815FB72.2030904@gmail.com> > > There is a > > isclass > > in the module inspect. > > Diez thanks Diez, that's exactly what I was looking for. cheers, Stef From mail at nospam.glenstark.net Fri Apr 18 06:32:10 2008 From: mail at nospam.glenstark.net (glen stark) Date: 18 Apr 2008 12:32:10 +0200 Subject: What can we do about all the spam that the list is getting? References: <259ab201-9d2b-4e4e-88a7-e2fe277f0066@a23g2000hsc.googlegroups.com> Message-ID: <480878aa$1_6@news.bluewin.ch> On Thu, 17 Apr 2008 13:30:18 -0500, Grant Edwards wrote: > When using Google Groups can one kill all posts made via Google Groups? > Presuming he has no burning need to see his own posts (something that > can't be said for everybody in the history of Usenet), it might still be > a viable approach. The problem is, if we had followed that advice, none of us would have seen his post. From phil at freehackers.org Tue Apr 1 08:56:15 2008 From: phil at freehackers.org (BlueBird) Date: Tue, 1 Apr 2008 05:56:15 -0700 (PDT) Subject: Using QSystemTrayIcon with PyQt References: <76680315-cadd-42ad-942c-3e89536819df@i12g2000prf.googlegroups.com> <6d0b8776-bb64-4a58-8ccb-46efa35d75a2@s50g2000hsb.googlegroups.com> <1a8a5b03-0b9e-49de-bd87-43fa1aa99dc2@b5g2000pri.googlegroups.com> <6b732135-a488-4175-889b-0cccf5f0c581@s8g2000prg.googlegroups.com> Message-ID: On Apr 1, 6:00 am, Alex Teiche wrote: > On Mar 31, 7:53 pm, Benjamin wrote: > > > > > On Mar 31, 8:41 pm, Alex Teiche wrote: > > > > On Mar 31, 6:40 pm, Alex Teiche wrote: > > > > > On Mar 31, 11:49 am, Alex Teiche wrote: > > > > > > On Mar 30, 3:50 pm, Benjamin wrote: > > > > > > > On Mar 29, 11:02 pm, Alex Teiche wrote:> Hello, > > > > > > > > I am pretty new to Python, and have never learned C++. I am trying to > > > > > > > implement the following thing into my python application: > > > > > > > >http://doc.trolltech.com/4.3/qsystemtrayicon.html > > > > > > > > Through PyQt. I have been using PyQt for awhile and I know how do use > > > > > > > it, but I could not get this specific thing to work. Can someone give > > > > > > > me some hints as to get it working in Python? > > > > > > > What problems are you having? > > > > > > > > Thanks a ton, > > > > > > > > Alex > > > > > > Thanks everyone for your help. I found the example to be particularly > > > > > helpful, and I have made a simplified version just to display an icon > > > > > with a quit button in its menu. Once I know how to do that I will > > > > > incorporate it into my larger program, with more options and the > > > > > ability show messages. The problem is, it doesn't work, and I can't > > > > > find out what's wrong. Can you give me some hints? > > > > > > Here is the code: > > > > > import sys > > > > > from PyQt4 import QtGui, QtCore > > > > > > class trayIcon(QtGui.QWidget): > > > > > def __init__(self, parent=None): > > > > > QtGui.QWidget.__init__(self, parent) > > > > > > #********Create Actions for the Tray Menu********# > > > > > self.quitAction = QtGui.QAction(self.tr("&Quit"), self) > > > > > QtCore.QObject.connect(self.quitAction, > > > > > QtCore.SIGNAL("triggered()"), QtGui.qApp, QtCore.SLOT("quit()")) > > > > > > create_tray_icon() > > > > > > self.composeAction.setEnabled(visible) > > > > > QtGui.QWidget.setVisible(self, visible) > > > > > > self.trayIcon.show() > > > > > > def create_tray_icon(self): > > > > > self.trayIconMenu = QtGui.QMenu(self) > > > > > self.trayIconMenu.addAction(self.composeAction) > > > > > self.trayIcon = QtGui.QSystemTrayIcon(self) > > > > > self.trayIcon.setContextMenu(self.trayIconMenu) > > > > > self.trayIcon.setIcon(bad.svg) > > > > > > app = QtGui.QApplication(sys.argv) > > > > > sys.exit(app.exec_()) > > > > > OK, I messed around with it some more, and it works. I just don't > > > > know how to set an icon, and the example doesn't help at all. > > > > > Here is the code: > > > > import sys > > > > from PyQt4 import QtCore, QtGui > > > > > class Systray(QtGui.QWidget): > > > > def __init__(self): > > > > QtGui.QWidget.__init__(self) > > > > > self.createActions() > > > > self.createTrayIcon() > > > > > #QtCore.QObject.connect(self.trayIcon, > > > > QtCore.SIGNAL("messageClicked()"), self.messageClicked) > > > > #QtCore.QObject.connect(self.trayIcon, > > > > QtCore.SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), > > > > self.iconActivated) > > > > > self.trayIcon.show() > > > > > def createActions(self): > > > > #self.minimizeAction = QtGui.QAction(self.tr("Mi&nimize"), self) > > > > #QtCore.QObject.connect(self.minimizeAction, > > > > # QtCore.SIGNAL("triggered()"), self, QtCore.SLOT("hide()")) > > > > > #self.maximizeAction = QtGui.QAction(self.tr("Ma&ximize"), self) > > > > #QtCore.QObject.connect(self.maximizeAction, > > > > # QtCore.SIGNAL("triggered()"), self, > > > > # QtCore.SLOT("showMaximized()")) > > > > > #self.restoreAction = QtGui.QAction(self.tr("&Restore"), self) > > > > #QtCore.QObject.connect(self.restoreAction, > > > > # QtCore.SIGNAL("triggered()"), self, > > > > # QtCore.SLOT("showNormal()")) > > > > > self.quitAction = QtGui.QAction(self.tr("&Quit"), self) > > > > QtCore.QObject.connect(self.quitAction, QtCore.SIGNAL("triggered()"), > > > > QtGui.qApp, QtCore.SLOT("quit()")) > > > > > def createTrayIcon(self): > > > > self.trayIconMenu = QtGui.QMenu(self) > > > > #self.trayIconMenu.addAction(self.minimizeAction) > > > > #self.trayIconMenu.addAction(self.maximizeAction) > > > > #self.trayIconMenu.addAction(self.restoreAction) > > > > #self.trayIconMenu.addSeparator() > > > > self.trayIconMenu.addAction(self.quitAction) > > > > > self.trayIcon = QtGui.QSystemTrayIcon(self) > > > > self.trayIcon.setContextMenu(self.trayIconMenu) > > > > > app = QtGui.QApplication(sys.argv) > > > > x = Systray() > > > > sys.exit(app.exec_()) > > > > > How would I go about setting the icon? > > > > Sorry, here is the code with commented out lines removed: > > > > import sys > > > from PyQt4 import QtCore, QtGui > > > > class Systray(QtGui.QWidget): > > > def __init__(self): > > > QtGui.QWidget.__init__(self) > > > > self.createActions() > > > self.createTrayIcon() > > > > self.trayIcon.show() > > > > def createActions(self): > > > > self.quitAction = QtGui.QAction(self.tr("&Quit"), self) > > > QtCore.QObject.connect(self.quitAction, QtCore.SIGNAL("triggered()"), > > > QtGui.qApp, QtCore.SLOT("quit()")) > > > > def createTrayIcon(self): > > > self.trayIconMenu = QtGui.QMenu(self) > > > self.trayIconMenu.addAction(self.quitAction) > > > > self.trayIcon = QtGui.QSystemTrayIcon(self) > > > self.trayIcon.setContextMenu(self.trayIconMenu) > > > > app = QtGui.QApplication(sys.argv) > > > x = Systray() > > > sys.exit(app.exec_()) > > > I believe the method you want is QSystemTrayIcon.setIcon. > > I found that, but what do I pass into it? Passing a string to a .svg > file doesn't work. http://www.riverbankcomputing.com/Docs/PyQt4/html/qsystemtrayicon.html#setIcon So, you must pass a QIcon. Now, the doc of QIcon: http://www.riverbankcomputing.com/Docs/PyQt4/html/qicon.html Oh, the list of supported file format is described separately in: http://www.riverbankcomputing.com/Docs/PyQt4/html/qimagereader.html#supportedImageFormats I see that svg is not part of that list. So, it is not surprising that it does not work but there are plenty of other formats that will work. It took me about 20 seconds to solve your problem by reading the appropriate documentation. I suggest you do that too in the future... regards, Philippe From gagsl-py2 at yahoo.com.ar Sun Apr 20 12:04:51 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 13:04:51 -0300 Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> Message-ID: En Sun, 20 Apr 2008 10:32:36 -0300, Banibrata Dutta escribi?: > On 4/20/08, Gabriel Genellina wrote: >> >> En Sun, 20 Apr 2008 01:55:51 -0300, Banibrata Dutta < >> banibrata.dutta at gmail.com> escribi?: >> >> > Wanted to check if there is any known, reliable, FOSS/Libre -- >> Obfurscator >> > for Python 2.5 code. >> >> Why do you want to do that in the first place? > > > I need to do to retain the confidentiality for certain core components, > which are not supposed to be open. While I do have the option of > implementing them in C/C++, I'm trying to see if I can avoid that for 2 > reasons -- > 1. Its a fairly large and complex set of components, and doing it in C/C++ > 'might' take significantly longer. > 2. I'd try to avoid having mix of languages if possible. It makes the > developement easier to maintain/manage over a period of time. > > There is very few you can do to obfuscate Python code. You can't rename >> classes nor methods nor global variables nor argument names due to the >> dynamic nature of Python. All you can safely do is to remove comments and >> join simple statements using ; > > > I do not understand the nuances of dynamic languages completely, so this > might be a foolish assumption, but if i make a complete, self-contained > Python application (collection of modules), then just before shipping a > production copy, why can't I replace 'all' symbols i.e. classes, methods, > variables etc ? Esply if I'm compiling the source ? Because *any* string can be used to retrieve an attribute, it is not easy to replace *every* occurence of an attribute name (the code may use arbitrary expressions with getattr). The code may contain external references to class names (e.g. pickles, logging config files) that must be kept; also code that uses exec/eval will not find the referenced objects. Even local names are necesary in some cases like "%(some)s %(format)d" % locals(). > If you remove docstrings, some things may break. Even renaming local >> variables isn't safe in all cases. > > Hmmm... but I'm aware of atleast 2 Obfuscators one commercial and one FOSS, > that seem to exist for Python. The commercial one is what I might try if I > don't find anything FOSS. The FOSS one seems to be a dead project. If they > are (or have been) there, I guess obfuscation is a doable thing, no ? Sure, it can be done - with a lot of care, and I'm sure *some* code will fail. You may distribute compiled .pyc files - that's enough for most people who cares at all. Paranoids use a modified version of the interpreter incompatible with the standard one. In any case, bug reports (including tracebacks) are less valuable and harder to read. -- Gabriel Genellina From tinnews at isbd.co.uk Thu Apr 10 16:50:51 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 10 Apr 2008 20:50:51 GMT Subject: How to find documentation about methods etc. for iterators References: <47fce941$0$755$bed64819@news.gradwell.net> <47fdceb8$0$754$bed64819@news.gradwell.net> Message-ID: <47fe7dab$0$757$bed64819@news.gradwell.net> Terry Reedy wrote: > > wrote in message > news:47fdceb8$0$754$bed64819 at news.gradwell.net... > | Terry Reedy wrote: > | > > | > wrote in message > | > news:47fce941$0$755$bed64819 at news.gradwell.net... > | > | I'm not sure if I have even phrased that right but anyway.... > | > | > | > | How does one find (in the standard Python documentation) information > | > | about things like the iteritems() method and the enumerate() > function. > | > > | > The Library Reference manual sections on builtin functions and dict > | > methods. > | > > | > Or, help(enumerate) and help({}.iteritems) > | > > | .... but that doesn't address my problem really, how do I know that I > | need to look for the words enumerate and/or iteritems? This is what > | my original question was about. > > Do what Gabriel said: read chapters 2 and 3 of the Lib Manual. You will > not necessarily remember everything, but you will have an idea of what > functionalities exist and know to go look again. In a few months, read > them again. > > As for the stdlib, at least scan through the table of contents so you have > a general idea of what there is. The documentation of modules (as well as > of builtins) is much improved from 10 years ago, when the only doc for some > was the code. > OK, thanks all for the replies. I know I will get more familiar with what's available as I use Python more. I have the O'Reilly "Python in a Nutshell" which I use for basic reference, with the helpful replies in this thread I should be able to find my way. -- Chris Green From bloqueador.rastreador at localizador.gps.com Fri Apr 4 17:49:33 2008 From: bloqueador.rastreador at localizador.gps.com (bloqueador sem mensalidade) Date: Fri, 4 Apr 2008 18:49:33 -0300 Subject: 455 bloqueador veicular sem mensalidades - =?ISO-8859-1?Q?http://bloqueadorgsm.vilabol.uol.com.br=11?= 4555333208173502757727274 Message-ID: Bloqueador ve?cluar com tecnologia gsm - Sem mensalidades Tenha toda seguran?a para seu carro com um pre?o justo. Apenas R$ 299,00 ( sem mensalidades ) http://bloqueadorgsm.vila.bol.com.br/ Compare e Compre. Rastreador de Ve?culo Rastreadores de Ve?culos Rastreador GPS Rastreadores GPS Rastreador Ituran Rastreadores Ituran Rastreador Port?til Rastreadores Port?teis. Assist?ncia 24 Horas Visite agora mesmo nosso site. http://bloqueadorgsm.vila.bol.com.br/ Graber - Teletrim - Tele Trim - Ituran - Rastreadores gps , Localizadores, Bloqueadores Graber - Teletrim - Tele Trim - Ituran - Rastreadores gps , Localizadores, Bloqueadores Graber - Teletrim - Tele Trim - Ituran - Rastreadores gps , Localizadores, Bloqueadores Graber - Teletrim - Tele Trim - Ituran - Rastreadores gps , Localizadores, Bloqueadores Graber - Teletrim - Tele Trim - Ituran - Rastreadores gps , Localizadores, Bloqueadores HTigfm&n(>'qai?5"!Co'IuTsX.5APO=7\pcuWJ6 From duncan.booth at invalid.invalid Tue Apr 22 13:45:45 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 22 Apr 2008 17:45:45 GMT Subject: Lists: why is this behavior different for index and slice assignments? References: <480d435b$0$11643$607ed4bc@cv.net> Message-ID: Steve Holden wrote: > Assignment to a list *element* rebinds the single element to the > assigned value. Assignment to a list *slice* has to be of a list, and it > replaces the elements in the slice by assigned elements. > Assignment to a list *slice* just has use an iterable, it doesn't actually have to be another list. From ni at hao.com Wed Apr 30 04:51:54 2008 From: ni at hao.com (SL) Date: Wed, 30 Apr 2008 10:51:54 +0200 Subject: computing with characters In-Reply-To: References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl><481813E2.2030302@islandtraining.com><61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> Message-ID: <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> "Gabriel Genellina" schreef in bericht news:mailman.365.1209541507.12834.python-list at python.org... > En Wed, 30 Apr 2008 04:19:22 -0300, SL escribi?: > And that's a very reasonable place to search; I think chr and ord are > builtin functions (and not str methods) just by an historical accident. > (Or is there any other reason? what's wrong with "a".ord() or > str.from_ordinal(65))? yes when you know other OO languages you expect this. Anyone know why builtins were chosen? Just curious > > -- > Gabriel Genellina > From mnordhoff at mattnordhoff.com Thu Apr 3 10:42:05 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Thu, 03 Apr 2008 14:42:05 +0000 Subject: How easy is it to install python as non-root user? In-Reply-To: <47f4e617$0$720$bed64819@news.gradwell.net> References: <47f4e617$0$720$bed64819@news.gradwell.net> Message-ID: <47F4ECBD.504@mattnordhoff.com> tinnews at isbd.co.uk wrote: > Does python install fairly easily for a non-root user? > > I have an ssh login account onto a Linux system that currently > provides Python 2.4.3 and I'd really like to use some of the > improvements in Python 2.5.x. > > So, if I download the Python-2.5.2.tgz file is it just the standard:- > > ./configure --prefix=$HOME > make > make install It is easy, but on an oldish Debian box, I ran into problems where the headers for some libraries weren't available, so my Python install didn't support readline or bzip2 (or perhaps other things too). -- From jgardner at jonathangardner.net Tue Apr 8 12:24:57 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Tue, 8 Apr 2008 09:24:57 -0700 (PDT) Subject: Python 3.0 new integer division References: Message-ID: On Apr 8, 9:13?am, "Hutch" wrote: > We now have a float result when two integers are divided in the same mannor > as 2.4 or 2.5. > I can handle that and use the Floor division but a simple question. > > Why in the world would you round down the last presented digit to a 6 > instead of just leaving it along as an 8. > For some reason rounding down for a float in Python does not seem correct. > > IDLE 3.0a4 > > >>> 12345678901234567890123456789012345678901234567890/345 > > 3.5784576525317586e+46 > > >>> 12345678901234567890123456789012345678901234567890//345 > > 35784576525317588087314367504383610663481839327 > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^| > 35784576525317586000000000000000000000000000000 ?== 3.5784576525317586e+46 Floats are weird that way. Part of the problem is you are representing a decimal number (base 10) in binary (base 2). The other part is that you can't increment floats by a very tiny amount. In other words, a + b = a for floats when b is sufficiently small but not zero. Blame floats, not Python. If you want precision with fractions, you should be using the Decimal type, which uses a rational. A rational, if you recall from your math classes, is one integer divided by another. From kayvoo at googlemail.com Sat Apr 19 14:41:14 2008 From: kayvoo at googlemail.com (Karl-Heinz Ruskowski) Date: Sat, 19 Apr 2008 20:41:14 +0200 Subject: Issue with inspect module In-Reply-To: <2e5e2d31-2adc-4416-a993-19bc05a512bd@w8g2000prd.googlegroups.com> References: <2e5e2d31-2adc-4416-a993-19bc05a512bd@w8g2000prd.googlegroups.com> Message-ID: <200804192041.14425.kayvoo@gmail.com> > Why does the inspect module cause the output > to be printed twice? I also tested it, no problem here either. From s0suk3 at gmail.com Wed Apr 16 16:35:09 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Wed, 16 Apr 2008 13:35:09 -0700 (PDT) Subject: str class inheritance prob? References: <874eed0f-eeeb-4434-8a14-a3b29801a5f6@d26g2000prg.googlegroups.com> Message-ID: <5a6531dc-b8f9-4fda-b4fe-0341eeaf12b6@a9g2000prl.googlegroups.com> On Apr 16, 1:43 pm, jka... at gmail.com wrote: > so I?m trying to create a class that inherits from str, but I want to > run some code on the value on object init. this is what I have: > > class Path(str): > def __init__( self, path ): > clean = str(path).replace('\\','/') > while clean.find('//') != -1: > clean = clean.replace('//','/') > > print 'cleaned on init:\t',clean > self = clean > > so clearly the clean variable is what I want value of the string to > be, but that?s decidedly not the case. so running this: > > a=Path('path///with\\nasty/////crap_in_it/') > print a > > gives me this: > > cleaned on init: path/with/nasty/crap_in_it/ > path///with\nasty/////crap_in_it/ > > what gives? what am I doing wrong, and can I do what I?m trying to > here? > thanks. Regardless of the problem you have initializing the class, why do you need to inherit from str? Actually, why do you even need a class? Unless you're dealing something more complex that you didn't mention here, that should be just a simple function. From andrew at acooke.org Thu Apr 17 17:46:59 2008 From: andrew at acooke.org (andrew cooke) Date: Thu, 17 Apr 2008 14:46:59 -0700 (PDT) Subject: Metaprogramming Example References: <930643c6-2d56-4fb0-aee0-a3e79231f09b@24g2000hsh.googlegroups.com> <32472b97-f35a-4408-96f5-2f8c8f92ae56@m73g2000hsh.googlegroups.com> <39325652-e0cf-4efd-9b28-00c0fe8552cc@m73g2000hsh.googlegroups.com> Message-ID: <562bae18-7b8e-4863-8923-0e5a01ba7125@t54g2000hsg.googlegroups.com> bruno: > Ho, and yes : one day, you'll get why it's such a good thing to unite > functions and methods !-) me: > PS Is there anywhere that explains why Decorators (in the context of > functions/methods) are so good? I've read lots of things saying they > are good, but no real justification of why. in the text above i wrote "Decorators" rather than "Descriptors". it was in response to bruno's comment, also above. sorry for the confusion. also, sorry for the inflammatory language - by referring to the titanic i didn't mean that python was a disaster, rather that the "iceberg" is still there (i am not 100% sure what the iceberg is, but it's something to do with making namespaces explicit in some places and not others). anyway, it was only a small point. thanks for all the replies. didn't respond earlier as i was at work. now i can go back and polish that code... andrew From tkpmep at hotmail.com Fri Apr 11 12:47:15 2008 From: tkpmep at hotmail.com (tkpmep at hotmail.com) Date: Fri, 11 Apr 2008 09:47:15 -0700 (PDT) Subject: Cannot start RPy - need win32api Message-ID: I'm running Python 2.5.2 on Windows XP and need to interface with R, so I downloaded the R 2.6.2 statistical package and installed it, and did the same for RPy 1.02 (i made sure I got the version for Python 2.5 and R 2.62.). When I go to the Python command line and type >>> from rpy import * I get the following error message: Traceback (most recent call last): File "", line 1, in from rpy import * File "C:\Python25\lib\site-packages\rpy.py", line 88, in import win32api ImportError: No module named win32api >>> What on earth is win32api, where can I find it, and where ought I to put it? Thanks in advance Thomas Philips From lists at cheimes.de Sat Apr 12 08:44:44 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 12 Apr 2008 14:44:44 +0200 Subject: str(bytes) in Python 3.0 In-Reply-To: References: Message-ID: <4800AEBC.5060307@cheimes.de> Gabriel Genellina schrieb: > On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') > above. But I get the same as repr(x) - is this on purpose? Yes, it's on purpose but it's a bug in your application to call str() on a bytes object or to compare bytes and unicode directly. Several months ago I added a bytes warning option to Python. Start Python as "python -bb" and try it again. ;) Christian From aldo at nullcube.com Tue Apr 1 21:16:16 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Wed, 2 Apr 2008 12:16:16 +1100 Subject: ANN: pry unit testing framework Message-ID: <20080402011616.GA21488@nullcube.com> We are happy to announce the first release of Pry, a unit testing framework. Features ======== * Built-in coverage analysis, profiling, and quick-and-dirty benchmarking * Assertion-based tests - no ugly failUnless*, failIf*, etc. methods * Tree-based test structure for better fixture management * No implicit instantiation of test suits * Powerful command-line interface Download: http://dev.nullcube.com Manual: http://dev.nullcube.com/doc/pry/index.html -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From paddy3118 at googlemail.com Wed Apr 9 01:54:55 2008 From: paddy3118 at googlemail.com (Paddy) Date: Tue, 8 Apr 2008 22:54:55 -0700 (PDT) Subject: Can C.L.P.handle the load? References: <3b6737c8-9d42-4218-ac60-01df2f578746@p39g2000prm.googlegroups.com> Message-ID: <9bd25fd3-5133-4165-9784-fbbc21145810@24g2000hsh.googlegroups.com> On Apr 8, 7:51 pm, Berco Beute wrote: > It's wonderful news for Python. It will definitely be a boost for > Python's (and Django's) popularity. Python finally seems to be on > every developers mind at the moment. Looks like it's showtime for > Python! I'm waiting for the rush of new users to c.l.p :-) If it comes, then aren't regularly posted FAQ's newbie friendly? Is their a good FAQ already around that we can regularly point newbies to? What else could we do to make c.l.p. of more use to the newbie whp may also be new to usenet whilst keeping c.l.p a usefull place for all? - Paddy. From afandimscit at gmail.com Mon Apr 21 07:10:39 2008 From: afandimscit at gmail.com (afandi) Date: Mon, 21 Apr 2008 04:10:39 -0700 (PDT) Subject: How to insert multiple rows in SQLite Dbase References: <50faeed7-775f-4e12-8131-21a95b5f91a8@e6g2000prf.googlegroups.com> <657h3nF2eehi8U1@mid.uni-berlin.de> Message-ID: <7e579f34-9c2c-4a3d-a438-77cb7f30803a@v23g2000pro.googlegroups.com> On Apr 1, 12:22 am, afandi wrote: > On Mar 30, 4:46 am, Gerhard H?ring wrote: > > > > > Gabriel Genellina wrote: > > > [...] > > > and execute: > > > cur.executemany("insert into log (IP, EntryDate, Requestt, ErrorCode) > > > values (:ip, :date, :request, :errorcode)", values) > > > It's probably worth mentioning that pysqlite's executemany() accepts > > anything iterable for its parameter. So you don't need to build a list > > beforehand to enjoy the performance boost of executemany(). > > > The deluxe version with generators could look like this: > > > def parse_logfile(): > > logf = open(...) > > for line in logf: > > if ...: > > row = (value1, value2, value3) > > yield row > > logf.close() > > > ... > > > cur.executemany("insert into ... values (c1, c2, c3)", parse_logfile()) > > > -- Gerhard > > > PS: pysqlite internally has a statement cache since verson 2.2, so > >multipleexecute() calls are almost as fast as executemany(). > > Thanks regards to your suggestion, but I don't understand why we have > to put the IF statement? I have the solution.Thanks split it using REgex to [] [] [] parse to Database From bruno.42.desthuilliers at websiteburo.invalid Mon Apr 21 04:35:51 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Mon, 21 Apr 2008 10:35:51 +0200 Subject: manipulating class attributes from a decorator while the class is being defined In-Reply-To: References: Message-ID: <480c51e7$0$15329$426a74cc@news.free.fr> Wilbert Berendsen a ?crit : > Hi, is it possible to manipulate class attributes from within a decorator > while the class is being defined? > > I want to register methods with some additional values in a class attribute. > But I can't get a decorator to change a class attribute while the class is > still being defined. Something like: > > class Parser(object): > > regexps = [] > def reg(regexp): > def deco(func): > regexps.append((regexp, func)) > return func > return deco > > @reg(r'".*"') > def quoted_string(self): > pass > > How can I reach the class attribute `regexps' from within a decorator? Simple answer : you can't. Because, as you noticed, the class object doesn't exist yet. The canonical solutions are either to store regexps outside the class (ie: as a module level variable) - which can be problematic in some cases -, or to use a two-pass scheme using a decorator and a metaclass, where the decorator annotate the function with required informations for latter processing, and the metaclass do the effective processing. There are of course other solutions, some of them possibly simpler. The 'best' solution of course depends on intented use of your class... HTH From jzshao1 at gmail.com Fri Apr 11 17:29:36 2008 From: jzshao1 at gmail.com (Jonathan Shao) Date: Fri, 11 Apr 2008 17:29:36 -0400 Subject: Question on threads In-Reply-To: <47FFBC05.50309@holdenweb.com> References: <47FFBC05.50309@holdenweb.com> Message-ID: On Fri, Apr 11, 2008 at 3:29 PM, Steve Holden wrote: > Jonathan Shao wrote: > > > Hi all, > > I'm a beginner to Python, so please bear with me. > > Is there a way of guarenteeing that all created threads in a program > > are finished before the main program exits? I know that using join() can > > guarentee this, but from the test scripts I've run, it seems like join() > > also forces each individual thread to terminate first before the next thread > > can finish. So if I create like 20 threads in a for loop, and I join() each > > created thread, then join() will in effect cause the threads to be executed > > in serial rather than in parallel. > > > > > No it won't, as in fact there is no mechanism to force a thread to > terminate in Python. When you join() each created thread the main thread > will wait for each thread to finish. Supposing the longest-lived thread > finished first then all others will immediately return from join(). > > The only requirement it is imposing is that all sub-threads must be > finished before the main thread terminates. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > I guess I'm doing something wrong with join(). Here's a test script I wrote up... import threading import time class TestThread(threading.Thread): def __init__(self, region): self.region = region threading.Thread.__init__(self) def run(self): for loop in range(10): print "Region " + str(self.region) + " reporting: " + str(loop) time.sleep(2) for x in range(10): thr = TestThread(x) thr.start() thr.join() raw_input() In this script thread 0 will finish first... Am I doing something wrong with join()? -------------- next part -------------- An HTML attachment was scrubbed... URL: From simone.brunozzi at gmail.com Tue Apr 8 05:10:01 2008 From: simone.brunozzi at gmail.com (Simone Brunozzi) Date: Tue, 8 Apr 2008 02:10:01 -0700 (PDT) Subject: Looking for Conferences/Events on Django, Python, MySQL, etc in Europe 2008? Message-ID: <7fb0f408-1a2e-4ee1-a179-092f83eb1591@8g2000hsu.googlegroups.com> Greetings! I'm looking for conferences or events about Python, Django, Dabatases, Mysql, PHP, Ruby in Europe (or nearby locations like north africa and middle east) in 2008. Do you have any suggestions? Thanks a lot! From python at bdurham.com Wed Apr 9 13:50:28 2008 From: python at bdurham.com (Malcolm Greene) Date: Wed, 09 Apr 2008 13:50:28 -0400 Subject: Parsing locale specific dates, currency, numbers In-Reply-To: <16651e80804091031u5fc752e6s90b54c8675108088@mail.gmail.com> References: <42b9a3ff0804091004s4d60751fh68c82673e8e3f4c3@mail.gmail.com> <16651e80804091031u5fc752e6s90b54c8675108088@mail.gmail.com> Message-ID: <1207763428.21865.1246989365@webmail.messagingengine.com> The locale module provides the ability to format dates, currency and numbers according to a specific locale. Is there a corresponding module for parsing locale's output to convert locale formatted dates, currency, and numbers back to their native data types on the basis of a specified locale? In other words, a module that will reverse the outputs of locale on a locale specific basis. Thanks! Malcolm From martin at v.loewis.de Sun Apr 27 13:33:56 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 27 Apr 2008 19:33:56 +0200 Subject: Tremendous slowdown due to garbage collection In-Reply-To: References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: <4814B904.1070804@v.loewis.de> > Martin said it but nevertheless it might not be true. > > We observed similar very bad behaviour -- in a Web application server. > Apparently, the standard behaviour is far from optimal when the > system contains a large number of objects and occationally, large > numbers of objects are created in a short time. > We have seen such behaviour during parsing of larger XML documents, for > example (in our Web application). I don't want to claim that the *algorithm* works for all typically applications well. I just claim that the *parameters* of it are fine. The OP originally proposed to change the parameters, making garbage collection run less frequently. This would a) have bad consequences in terms of memory consumption on programs that do have allocation spikes, and b) have no effect on the asymptotic complexity of the algorithm in the case discussed. It may well be that other algorithms would perform better, but none have been contributed. Regards, Martin From tpatch at loftware.com Wed Apr 16 09:50:44 2008 From: tpatch at loftware.com (tpatch at loftware.com) Date: Wed, 16 Apr 2008 09:50:44 -0400 Subject: RotatingFileHandler - ShouldRollover error Message-ID: <4ECBD915C6F1254AB1AFF4B9F08287B2176F4253C0@loftexchange.loftwareinc.com> I am using the RotatingFileHandler logger with Python 2.5 on Windows and I am getting an error on the rollover. When the log file gets close to the size where it needs to rollover, I start getting the following error for every log message. Does anyone have a solution to this problem? Traceback (most recent call last): File "C:\Python25\Lib\logging\handlers.py", line 73, in emit if self.shouldRollover(record): File "C:\Python25\Lib\logging\handlers.py", line 147, in shouldRollover self.stream.seek(0, 2) #due to non-posix-compliant Windows feature ValueError: I/O operation on closed file My configuration file is setup as such: [handler_file_detailed] class:handlers.RotatingFileHandler level:DEBUG formatter:detailed mode=a maxsize=4000000 backcount=5 args:('python.log','a',4000000,5) Thanks, Todd -------------- next part -------------- An HTML attachment was scrubbed... URL: From fn681 at ncf.ca Tue Apr 1 07:20:54 2008 From: fn681 at ncf.ca (Colin J. Williams) Date: Tue, 01 Apr 2008 07:20:54 -0400 Subject: Is this a good time to start learning python? In-Reply-To: References: <47f1140e$0$735$a729d347@news.telepac.pt> Message-ID: Terry Reedy wrote: > "Rui Maciel" wrote in message > news:47f1140e$0$735$a729d347 at news.telepac.pt... > | Recently I woke up inclined to take up the task of learning another > | programming language. I've already dipped my toes in Perl (I've read > online > | tutorials and wrote a couple of irrelevant pet projects) but, as the > | computers at my workplace only sport the python interpreter, it probably > | means that learning python will end up serving me better, at least in the > | short run. Plus, you know how Perl goes. > > If you intend to use Python on the computer at your workplace, then learn > the version installed there. > > | So far the decision seems to be a no brainer. Yet, Python 3000 will > arrive > | in a few months. As it isn't backwards compatible with today's Python, > | there is the risk that no matter what I learn until then, I will end up > | having to re-learn at least a considerable part of the language. > > Most of the changes are deletions and additions, rather than changes. > > 3.0a4 will be out in a few days. If you had no reason to use anything > else, I would consider starting with that. (But the IDLE IDE on Windows > may still not work right.) Replace IDLE by PyScripter and then you have a good development environment for Python 3000. Colin W. > > | To put it in other words, I fear that I will be wasting my time. > > If you learn and use 2.x, then avoid things that are going away. In > particular: > > Unless you need to learn about old-style classes, I would not bother with > them and the differences from new, soon to be the only style, classes. > Derive all your classes from object or a subclass thereof. > > Use // for integer floor division (ie, when you want 1/2 == 0. > Use 'from __future__ import division' if you use '/' in a file where both > operands > might be ints and you would want 1/2==.5. > > | At least that is what a clueless newbie believes. As this group is > | frequented by people who have more insight into all things pythonesque, > | what are your thoughts on this? > > Diverse, I am sure ;-) > > Terry Jan Reedy > > > From stef.mientki at gmail.com Wed Apr 23 19:03:58 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Thu, 24 Apr 2008 01:03:58 +0200 Subject: Python script to automate use of Google Translate? (or other translator) In-Reply-To: <87D3F9C72FBF214DB39FA4E3FE618CDC6E243C7BF2@EXMBX04.exchhosting.com> References: <87D3F9C72FBF214DB39FA4E3FE618CDC6E243C7BF2@EXMBX04.exchhosting.com> Message-ID: <480FC05E.2030202@gmail.com> Trent Nelson wrote: >>> I have the need to occasionally translate a single word >>> programatically. Would anyone have a Python script that >>> would let me do this using Google (or another) translation >>> service? >>> > > As a matter of fact, yes, I do! This happens to be my most favourite piece of Python code I've ever written, too... > thanks Trent, that's really beautiful !! cheers, Stef From JesseAldridge at gmail.com Sun Apr 6 00:43:29 2008 From: JesseAldridge at gmail.com (Jesse Aldridge) Date: Sat, 5 Apr 2008 21:43:29 -0700 (PDT) Subject: Python Data Utils Message-ID: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> In an effort to experiment with open source, I put a couple of my utility files up here. What do you think? From knight at baldmt.com Sat Apr 19 00:28:37 2008 From: knight at baldmt.com (Steven Knight) Date: Fri, 18 Apr 2008 21:28:37 -0700 Subject: ANNOUNCE: SCons 0.98.1 (candidate for 1.0) is now available Message-ID: SCons is a software construction tool (build tool, or make tool) written in Python. It is based on the design which won the Software Carpentry build tool competition in August 2000. Version 0.98.1 of SCons has been released and is now available at the SCons download page: http://www.scons.org/download.php RPM and Debian packages and a Win32 installer are all available, in addition to the traditional .tar.gz and .zip files. This release is considered a candidate for the (long-awaited) official 1.0 SCons release. We welcome and encourage widespread testing and use of this release to try to identify any problems. Please report your bugs following the guidelines at: http://scons.tigris.org/bug-submission.html WHAT'S NEW IN THIS RELEASE? This release contains a huge number of new features, fix, performance improvements, and other changes since the last widely-publicized release (0.97, last year). For a description of important changes that affect upgrading and backwards compatibility, please see our release notes: http://scons.tigris.org/RELEASE.txt For a very complete list of changes, please see our change log: http://scons.tigris.org/CHANGES.txt ABOUT SCONS Distinctive features of SCons include: - a global view of all dependencies; no multiple passes to get everything built properly - configuration files are Python scripts, allowing the full use of a real scripting language to solve difficult build problems - the ability to scan files for implicit dependencies (#include files); - improved parallel build (-j) support that provides consistent build speedup regardless of source tree layout - use of MD5 signatures to decide if a file has really changed; no need to "touch" files to fool make that something is up-to-date - easily extensible through user-defined Builder and Scanner objects - build actions can be Python code, as well as external commands A scons-users mailing list is available for those interested in getting started using SCons. You can subscribe by sending email to: users-subscribe at scons.tigris.org Alternatively, we invite you to subscribe to the (very) low-volume scons-announce mailing list to receive notification when new versions of SCons become available: announce-subscribe at scons.tigris.org On behalf of the SCons team, --SK From s0suk3 at gmail.com Tue Apr 29 13:54:18 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Tue, 29 Apr 2008 10:54:18 -0700 (PDT) Subject: Simple import question about mac osx References: Message-ID: On Apr 29, 12:46 pm, jmDesktop wrote: > On Apr 29, 1:16 pm, jmDesktop wrote: > > > > > Hi, I have this code (learning from Core Python, Chun's book), module > > named chap2.py. > > > class FooClass(object): > > version=0.1 > > > def __init__(self, nm='John Doe'): > > self.name=nm > > print 'Created a class instance for ', nm > > def showname(self): > > print 'Your name is', self.name > > print 'My name is', self.__class__.__name__ > > > On Windows, if I compile this and then in the python interpreter type: > > > >>> import chap2 > > >>> foo1=FooClass() > > > Created a class instance for John Doe > > > If I do the same think on my Mac OS X 10.5.2 > > > NameError: name 'FooClass' is not defined. > > > I thought it was the path and did export PATH=$PATH:/mypath/ > > topythoncode > > > but it did not help. > > > What am I doing wrong? Thank you. > > forgot to say that on the mac I can do import chap2, but when I try > and instantiate I get the error above. It shouldn't work under Windows, either. You have to qualify the name of the class with the name of the module, as in chap2.FooClass(). Or you can type "from chap2 import FooClass" and then you'll be able to simply say FooClass(). From deets at nospam.web.de Fri Apr 25 09:29:49 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 25 Apr 2008 15:29:49 +0200 Subject: Calling Python code from inside php In-Reply-To: References: <679e9oF2mti63U1@mid.uni-berlin.de> <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> <679hd5F2nj6csU1@mid.uni-berlin.de> Message-ID: <67e4n4F2o0sfcU1@mid.uni-berlin.de> Nick Stinemates schrieb: >> While I certainly prefer to use Python wherever I can, that does not mean >> that there aren't cases where legacy systems or other constraints make this >> impossible. If I have e.g. a type3-based website - "how on earth" should I >> replace that with Python (without wasting a lot of time)? > > I don't understand how the 2 are mutually exclusive? > > You can have PHP and Python bindings installed on the same Apache > server, unless I'm mistaken? What about having to set up & maintain (which might not even possible on a cheap hoster) two configs for that - just for having a few lines of python being run? And how do you go about session-state sharing and so forth? After all the scipt might need to be access controlled based on login state. I don't say that there aren't options to run python more direct. I argumented against a rather bold statement of Mr. alexelder: """ A simple yet dangerous and rather rubbish solution (possibly more of a hack than a real implementation) could be achieved by using a technique described above: """ Diez From steve at holdenweb.com Wed Apr 23 00:41:17 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 00:41:17 -0400 Subject: Python Success stories In-Reply-To: References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> Message-ID: <480EBDED.5010600@holdenweb.com> Nikita the Spider wrote: > In article > <7e595409-be62-4b8c-9819-a14cd363d751 at c65g2000hsa.googlegroups.com>, > azrael wrote: > >> Which big aplications are written in python. I see its development, >> But i can't come up with a big name. I know that there are a lot of >> companys using python, but is there anythong big written only in >> python. I want him to fuck of with his perl once and for all time > > Why are either of you so emotionally attached to the tools you use? > > I don't know your friend, but my guess is that he's not interested in a > logical argument, so he won't be impressed even if you claim that God > himself wrote the Universe in Python. I think he enjoys saying this > stuff simply because you react to it. It's pretty sad that he can't find > something better to do with his time. > It's even sadder that he doesn't need to. [...] regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From skanemupp at yahoo.se Thu Apr 10 09:47:52 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 06:47:52 -0700 (PDT) Subject: tkinter, overwrite Label-text? References: Message-ID: On 10 Apr, 15:28, "Dennis.Benzin... at gmx.net" wrote: > On Apr 10, 2:35 pm, skanem... at yahoo.se wrote: > > > using python And tkinter. > > > i have a GUI that outputs a text among other things. after input form > > user i want this text to be *)cleared and/or > > *)overwritten. > > > what is the best way to achieve that? > > [...] > > Which widget do you use? > > Some widgets can be connected to variables so that when the variable > changes the widget is automatically update. > Have a look . > > HTH, > Dennis Benzinger i use the Label-widget. From Jiang.Adam at gmail.com Fri Apr 18 02:52:04 2008 From: Jiang.Adam at gmail.com (Adam) Date: Thu, 17 Apr 2008 23:52:04 -0700 (PDT) Subject: How to set proxy for a python script to run Message-ID: Hi, I am using a script written in Python. For some reasons I should pass the fireware by proxy setting. But it seems not work when I set the 'http_proxy' 'ftp_proxy' environment variable. I also expored 'HTTP_PROXY' 'FTP_PROXY', but the problem remained. How can I set proxy for it to run the script? From paddy3118 at googlemail.com Wed Apr 9 00:58:45 2008 From: paddy3118 at googlemail.com (Paddy) Date: Tue, 8 Apr 2008 21:58:45 -0700 (PDT) Subject: Sorting a List of Objects by an Attribute of the Objects Case-Insensitively References: <736fefbd-510f-40e9-8342-32b69a1a0c2a@t12g2000prg.googlegroups.com> Message-ID: <0912a817-2cdc-4a19-83d2-1d8befed4f4b@24g2000hsh.googlegroups.com> On Apr 9, 4:04 am, Jason wrote: > Hi folks-- > > Basically, I have a pressing need for a combination of 5.2 "Sorting a > List of Strings Case-Insensitively" & 5.3 "Sorting a List of Objects > by an Attribute of the Objects" from the Python Cookbook. > > My first guess isn't working: > > import operator > def sort_by_attr(seq, attr): > key=operator.attrgetter(attr) > key=str.lower > return sorted(seq, key) > > ...would much appreciate any guidance! HiJason, Try key= lambda x: x.attr.lower() The above should calculate the key only once for the items to be sorted rather than using cmp which calculates more than that. - Paddy. From victorsubervi at gmail.com Thu Apr 17 10:52:39 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 17 Apr 2008 09:52:39 -0500 Subject: More Fun With MySQL and Images In-Reply-To: <4dc0cfea0804170742g39965533yfaf260bcf4da4301@mail.gmail.com> References: <4dc0cfea0804170742g39965533yfaf260bcf4da4301@mail.gmail.com> Message-ID: <4dc0cfea0804170752x789cce43xe1ea6aeba498ccd1@mail.gmail.com> Never mind. Apparently, these tags throw it for that loop: print '\n' I?m surprised they would, but gratified I found the problem. Victor On Thu, Apr 17, 2008 at 9:42 AM, Victor Subervi wrote: > Hi again: > Here is my code, an edit of Gabriel?s: > > #!/usr/local/bin/python > import cgitb; cgitb.enable() > import MySQLdb > def test(): > host = 'host' > db = 'db' > user = 'user' > passwd = 'pass' > db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > cursor= db.cursor() > cursor.execute('select pic1 from products where id="2";') > content = cursor.fetchall()[0][0].tostring() > f = open("somefile.jpg", "w") > f.write(content) > f.close() > print 'Content-Type: image/jpeg\r\nContent-Length: %d\n' % len(content) > print '\n' > print content > print '\n' > cursor.close() > > test() > Now, when I surf to the url of this script, it prints out garbage that is > a literal of the image, but not the image itself. However, if I surf to > ?somefile.jpg?, I see the image!! Am I losing my mind?? What?s wrong here? > TIA, > Victor > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fetchinson at googlemail.com Mon Apr 14 00:43:43 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Sun, 13 Apr 2008 21:43:43 -0700 Subject: Recommendation for Web Framework In-Reply-To: <4801b3a6$0$7713$4c368faf@roadrunner.com> References: <4801b3a6$0$7713$4c368faf@roadrunner.com> Message-ID: On Sun, Apr 13, 2008 at 12:18 AM, James West wrote: > Let me explain my situation a bit. > > I've been contracted to develop an ecommerce site. It's nothing too > huge but requires a lot of custom development that's not typical for > your run of the mill webstore. I've got about three weeks to get the > project delivered and I've written quite a bit of code already. > > I'd like to find some sort of tool to generate some of the repetative > bits like data management (think phpMyAdmin but for Python) so I don't > have to write a stupid mangement script for every single module (users, > customers, inventory, etc). I know there's tools out there that will do > this for ASP code with a SQL server backend, but I haven't seen > anything for Python outside of the web application frameworks. > > Ideally, I'd like something like Ruby on Rails that would provide > scaffolding support so I can bootstrap the system, so to speak. I've > looked at Django, but the client is only running Apache 1.x and Python > 2.3. I've given Turbo Gears a try, but couldn't get SQLObject to run > (threw an error that I didn't have time to struggle with). So basically > I need something with low dependencies, easy to develop in, and > releatively easy to deploy. > > Anyone have any recommendations? I really need something on which I can > ramp up quickly to get this project out of the door fast. I'm also a > framework newbie, so I know there's a learning curve. > > Any input is appreciated, thank you. > > - james > > -- > http://mail.python.org/mailman/listinfo/python-list > Have you looked at http://code.google.com/p/dbsprockets/ and/or http://code.google.com/p/dbsprockets/wiki/DBMechanic ? HTH, Daniel -------------- next part -------------- An HTML attachment was scrubbed... URL: From see.signature at no.spam Wed Apr 30 10:01:53 2008 From: see.signature at no.spam (Eric Brunel) Date: Wed, 30 Apr 2008 16:01:53 +0200 Subject: Simple TK Question - refreshing the canvas when not in focus References: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> <4818349e$0$2959$ba620e4c@news.skynet.be> Message-ID: On Wed, 30 Apr 2008 10:58:06 +0200, Robert.Spilleboudt wrote: > blaine wrote: >> Hey everyone! >> I'm not very good with Tk, and I am using a very simple canvas to >> draw some pictures (this relates to that nokia screen emulator I had a >> post about a few days ago). >> Anyway, all is well, except one thing. When I am not in the program, >> and the program receives a draw command (from a FIFO pipe), the canvas >> does not refresh until I click into the program. How do I force it to >> refresh, or force the window to gain focus? It seems like pretty >> common behavior, but a few things that I've tried have not worked. >> Class screen(): >> def __init__(self): >> self.root = Tkinter.Tk() >> self.root.title('Nokia Canvas') >> self.canvas = Tkinter.Canvas(self.root, width =130, >> height=130) >> self.canvas.pack() >> self.root.mainloop() >> Then somewhere a long the line I do: >> self.canvas.create_line(args[0], args[1], args[2], >> args[3], fill=color) >> self.canvas.pack() >> I've tried self.root.set_focus(), self.root.force_focus(), >> self.canvas.update(), etc. but I can't get it. >> Thanks! >> Blaine > When you read the pipe, do you generate an event? Probably not , and Tk > is event-driven and should never update the canvas if there is no event. > This is how I understand Tk. > > I have a Tk program who reads a audio signal (from an RC transmitter) . > I generate a event every 100 msec , and "process" refresh the canvas. > Starting the sequence: > id = root.after(100,process) will call "process" after 100 msec > At the end of "process", repeat: > id = root.after(100,process) > Robert Your method actually works and is in fact even clearer: you explicitely give back the control to the main event loop by sending the event. But the call to 'update' should also work, since it also gives back the control to the main event loop, implicitely however. BTW, the pending events *are* treated by a call to update, which can cause some surprises... -- python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])" From Dodin.Roman at gmail.com Fri Apr 25 07:26:48 2008 From: Dodin.Roman at gmail.com (hellt) Date: Fri, 25 Apr 2008 04:26:48 -0700 (PDT) Subject: Can you recommend a book? References: <1209121653.26409.1249825743@webmail.messagingengine.com> Message-ID: On 25 ???, 15:09, "Malcolm Greene" wrote: > My two favorites: > > - Core Python Programming by Chun > - Learning Python by Lutz > > Malcolm Learning Python (Lutz) is very good, reading right now. From olivier.losinger at gmail.com Mon Apr 14 04:39:56 2008 From: olivier.losinger at gmail.com (olivier.losinger at gmail.com) Date: Mon, 14 Apr 2008 01:39:56 -0700 (PDT) Subject: Py2exe Json Message-ID: I want to use json with py2exe but when I execute the program I have this errors : "Runtime Error : maximun recursion depth exceeded" Here is my code : import json jsonstr='{"toto":"toto"}' print json.read(jsonstr) and my setup #!/usr/bin/env python # -*- coding: latin-1 -*- import sys, os, getopt from distutils.core import setup, Extension import py2exe includes = ["encodings", "encodings.*",] options = {"py2exe": { # create a compressed zip archive "compressed": 1, "optimize": 2, "includes": includes, "packages": ["encodings", "email","json"] }} version_string='1.2' setup(name="test_json", options=options, version=version_string, description="Test json", console=['debugjson.py'], data_files=[] ) Have you got an idea ? From cokofreedom at gmail.com Wed Apr 30 05:47:13 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Wed, 30 Apr 2008 02:47:13 -0700 (PDT) Subject: Code/test ratio wrt static vs dynamic typing [was: Re: Python Success stories] References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <57d73312-37b1-4c53-9669-803e84a6901f@p25g2000hsf.googlegroups.com> Message-ID: <263d5498-821f-4705-9e1d-cc9e97a98e07@34g2000hsf.googlegroups.com> > > A rather off-topic and perhaps naive question, but isn't a 1:4 > production/test ratio a bit too much ? Is there a guesstimate of what > percentage of this test code tests for things that you would get for > free in a statically typed language ? I'm just curious whether this > argument against dynamic typing - that you end up doing the job of a > static compiler in test code - holds in practice. > > George To me it seems like more of an argument for a (more) concise Test Framework for Python, or at least a fully fledge IDE beyond pyDev. From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 4 07:50:45 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 04 Apr 2008 13:50:45 +0200 Subject: Is there an official way to add methods to an instance? In-Reply-To: References: Message-ID: <47f6160e$0$19004$426a74cc@news.free.fr> Peter Otten a ?crit : (snip) > Anyway, here is one more option to add too the zoo: > >>>> class A(object): > ... def __init__(self, f, x): > ... self._f = f > ... self.x = x > ... @property > ... def f(self): > ... return self._f.__get__(self) > ... def __del__(self): > ... print "deleting" > ... This is nice but requires that you know in advance how many methods you're going to add and how they will be named (which is not a bad thing in itself - on the contrary - but may not be what the OP is after), and that you can add these methods at instanciation time. A variant could be: class A(object): def __init__(self, x): self.x = x def __getattr__(self, name): target = '_' + name # avoids recursion if hasattr(self, target): func = getattr(self, target) if hasattr(func, '__get__'): return func.__get__(self, type(self)) # nothing found, bye... raise AttributeError( "%s object has no attribute %s" % (self, name) ) a = A(21) a._foo = lambda self: "answer is %s" % (self.x * 2) print a.foo() From skanemupp at yahoo.se Sat Apr 5 11:29:43 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 08:29:43 -0700 (PDT) Subject: Tkinter: making buttons the same size? Message-ID: <12bad1a6-3b4b-446e-9673-8893cd6838f9@s37g2000prg.googlegroups.com> on windows vista these buttons dont have the same size, the "/" shrinks a little. how do i make them the same size or prevent shrinking? a mac-user told me they look the same to him so maybe it doesnt shrink on macs but it does when using VISTA. i tried some .propagate and extend-stuff but didnt work. #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self, master=None): """Initialize yourself""" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): self.btnDisplay = Button(self,text='1',command=lambda n=1:self.Display(n)) self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='/',command=lambda n="/":self.Display(n)) self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) def Display(self, number): print number if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() From pylists at arcor.de Thu Apr 17 22:41:36 2008 From: pylists at arcor.de (Penny Y.) Date: Fri, 18 Apr 2008 10:41:36 +0800 Subject: get quote enclosed field in a line In-Reply-To: Message-ID: <20080418024152.3566B292B61@mail-in-07.arcor-online.net> Hello, I don't know Python's RE very well. But using Perl's RE you can get it. > cat t1.pl $x=qq{189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET /Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311Firefox/2.0.0.13" "-"}; $ua = ($x=~/\"(.+?)\"/g)[-2]; print $ua,"\n"; > perl t1.pl Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311Firefox/2.0.0.13 > -----????----- > ???: python-list-bounces+pylists=arcor.de at python.org > [mailto:python-list-bounces+pylists=arcor.de at python.org] ?? > xahlee at gmail.com > > e.g. the typical line is like this: > > 189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET / > Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org > "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/ > 5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311 > Firefox/2.0.0.13" "-" > > I want the part: "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv: > 1.8.1.13) Gecko/20080311 Firefox/2.0.0.13". From gagsl-py2 at yahoo.com.ar Mon Apr 21 19:58:42 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 20:58:42 -0300 Subject: how to pass C++ object to another C++ function via Python function References: <1810b155-5598-4f17-a8e9-e4aa848db5de@i36g2000prf.googlegroups.com> <673m48F2lucb5U1@mid.uni-berlin.de> Message-ID: En Mon, 21 Apr 2008 11:19:24 -0300, Diez B. Roggisch escribi?: > Gabriel Genellina wrote: >> You can't pass any arbitrary C object to a Python function. >> In this case you can use a PyCObject, a Python box around a void* >> pointer. >> See http://docs.python.org/api/cObjects.html > > Neat! Didn't know about that one. I found it just by chance. The title alone in the API reference isn't very descriptive... -- Gabriel Genellina From nagle at animats.com Sat Apr 12 12:39:46 2008 From: nagle at animats.com (John Nagle) Date: Sat, 12 Apr 2008 09:39:46 -0700 Subject: Tremendous slowdown due to garbage collection In-Reply-To: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> Message-ID: <4800e342$0$36326$742ec2ed@news.sonic.net> andreas.eisele at gmail.com wrote: > In an application dealing with very large text files, I need to create > dictionaries indexed by tuples of words (bi-, tri-, n-grams) or nested > dictionaries. The number of different data structures in memory grows > into orders beyond 1E7. > > It turns out that the default behaviour of Python is not very suitable > for such a situation, as garbage collection occasionally traverses all > objects in memory (including all tuples) in order to find out which > could be collected. This leads to the sitation that creating O(N) > objects effectively takes O(N*N) time. Do your data structures need garbage collection? CPython is a reference counted system with garbage collection as a backup to catch cycles. Try using weak back-pointers in your data structures to avoid creating cycles. John Nagle From deets at nospam.web.de Wed Apr 9 07:54:01 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 09 Apr 2008 13:54:01 +0200 Subject: Basic optimization of python. References: Message-ID: <663p3lF2go90rU1@mid.uni-berlin.de> ?? wrote: > Howdy, > I wonder whether python compiler does basic optimizations to .py. > Eg: > t = self.a.b > t.c = ... > t.d = ... > .vs. > self.a.b.c = ... > self.a.b.d = ... > which one is more effective? Since each dot invokes a hash table lookup, > it may be time consuming. If the compiler can do expression folding, then > no manual folding is needed. It can't do that because of no guarantee can be made that self.a has no side-effects, and consequently doesn't do it. > Again, how about contant calculation? > Eg: > a = 1 + 2 > .vs. > a = 3 > which one is more effective? Does the compiler calculate the result at > compile time? How about constant spreading? Algebraic optimizations aren't done AFAIK - and it's debatable if the mu-secs saved by that would be worth the effort, as if *they* matter, you obviously are in number-crunching mode and should resort to libs such as Numpy to do your work. Diez From xkenneth at gmail.com Fri Apr 25 17:02:56 2008 From: xkenneth at gmail.com (xkenneth) Date: Fri, 25 Apr 2008 14:02:56 -0700 (PDT) Subject: Oilfield Applications: WITS AND WITSML Message-ID: <1e78af71-9c41-4a50-a5d0-a862f25db8f3@f36g2000hsa.googlegroups.com> All, If anyone has any interest in developing a bit of code for generating WITS and WITSML in python, then drop me a line. I've started a project on google apps, "PyWITS", and I plan to support both WITS and WITSML through a set of standard libraries. I would really appreciate help from other developers or input from anyone. Drop me a line if you're interested. Regards, Kenneth Miller From aguirre.adolfo at gmail.com Mon Apr 28 22:57:12 2008 From: aguirre.adolfo at gmail.com (aguirre.adolfo at gmail.com) Date: Mon, 28 Apr 2008 19:57:12 -0700 (PDT) Subject: Python Math libraries - How to? References: Message-ID: > > Thank you. I?ll try all methods to figure out the convenience of each Adolfo > > From sawilla at gmail.com Fri Apr 25 12:04:33 2008 From: sawilla at gmail.com (sawilla) Date: Fri, 25 Apr 2008 09:04:33 -0700 (PDT) Subject: module error in Vista -- works as administrator References: <815eb7f8-6f00-469d-bb15-e1d9680d9646@e39g2000hsf.googlegroups.com> <480d0a52$1@news.mel.dft.com.au> <72da4abc-57b1-47ca-bed4-48b7244d6407@e39g2000hsf.googlegroups.com> <480d2369@news.mel.dft.com.au> Message-ID: <1ca8d4a1-7e98-4269-8e3b-c67fa757f9b1@b64g2000hsa.googlegroups.com> The access writes to easy-install.pth for regular users is read and execute. The output of sys.path for regular users is: ['', 'C:\\Program Files\\Python25\\lib\\site-packages\ \setuptools-0.6c8-py2.5.eg g', 'C:\\Program Files\\Python25\\python25.zip', 'C:\\Program Files\ \Python25\\D LLs', 'C:\\Program Files\\Python25\\lib', 'C:\\Program Files\\Python25\ \lib\\pla t-win', 'C:\\Program Files\\Python25\\lib\\lib-tk', 'C:\\Program Files\ \Python25 ', 'C:\\Program Files\\Python25\\lib\\site-packages'] The output of sys.path for the admin user is: ['', 'C:\\Program Files\\Python25\\lib\\site-packages\ \setuptools-0.6c8-py2.5.eg g', 'C:\\Program Files\\Python25\\lib\\site-packages\\networkx-0.36- py2.5.egg', 'C:\\Program Files\\Python25\\lib\\site-packages\\numpy-1.0.4-py2.5- win32.egg', 'C:\\Program Files\\Python25\\lib\\site-packages\\scipy-0.6.0-py2.5- win32.egg', 'C:\\Program Files\\Python25\\lib\\site-packages\\matplotlib-0.91.2- py2.5-win32. egg', 'C:\\Program Files\\Python25\\lib\\site-packages\\dot2tex-2.7.0- py2.5.egg' , 'C:\\Program Files\\Python25\\lib\\site-packages\\pydot-1.0.2- py2.5.egg', 'C:\ \Program Files\\Python25\\lib\\site-packages\\pyparsing-1.4.11-py2.5- win32.egg', 'C:\\Program Files\\Python25\\python25.zip', 'C:\\Program Files\ \Python25\\DLLs ', 'C:\\Program Files\\Python25\\lib', 'C:\\Program Files\\Python25\ \lib\\plat-w in', 'C:\\Program Files\\Python25\\lib\\lib-tk', 'C:\\Program Files\ \Python25', 'C:\\Program Files\\Python25\\lib\\site-packages'] The contents of easy-install.pth are: import sys; sys.__plen = len(sys.path) ./setuptools-0.6c8-py2.5.egg ./networkx-0.36-py2.5.egg ./numpy-1.0.4-py2.5-win32.egg ./scipy-0.6.0-py2.5-win32.egg ./matplotlib-0.91.2-py2.5-win32.egg ./dot2tex-2.7.0-py2.5.egg ./pydot-1.0.2-py2.5.egg ./pyparsing-1.4.11-py2.5-win32.egg import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys, '__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new) The location where numpy is found: >>> print os.path.abspath(numpy.__file__) C:\Program Files\Python25\lib\site-packages\numpy-1.0.4-py2.5-win32.egg \numpy\__ init__.pyc So I believe I need to have the easy-install.pth file executed automatically for regular users but I don't know how to do this. Reg On Apr 21, 7:29?pm, John Machin wrote: > sawillawrote: > > On Apr 21, 5:42 pm, John Machin wrote: > >> Log on as administrator, start python in command window and do this: > > >> import sys > >> sys.path # shows where python is looking for importables > >> import numpy > >> import os.path > >> print os.path.abspath(numpy.__file__) # shows where it found numpy > > >> Log on as ordinary user, start python in command window and do this: > > >> import sys > >> sys.path > >> # check how this is different from the admin's sys.path > > >> If you can't see what to do after that, come back here with the output > >> from those steps. > > >> HTH, > >> John > > > That was a great help, thank you. I now see what is causing the > > problem but I don't know how to fix it. I used easy_install to install > > several packages. When I run Python from an administrator command > > window all of the directories in C:\Program Files\Python25\Lib\site- > > packages\easy-install.pth are added to the sys.path. When I run it as > > a regular user, those directories are not added to the sys.path and so > > Python can't find the modules. > > > I know how to manually add those directories to Python's search path > > but then I'll need to update the path every time I install something. > > How do I get Python to automatically load the easy-install.pth file > > for the regular user account? > > > Reg > > """ > If you can't see what to do after that, come back here with the output > from those steps. > """ > in particular what is in sys.path for the non-admin user. > Also what are the access rights to the easy-install.pth file?- Hide quoted text - > > - Show quoted text - From gagsl-py2 at yahoo.com.ar Thu Apr 3 21:04:06 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 22:04:06 -0300 Subject: regarding memoize function References: <94a9e7e6-a623-4783-81da-f69654e51349@e10g2000prf.googlegroups.com> Message-ID: En Thu, 03 Apr 2008 21:21:11 -0300, Dan Bishop escribi?: > On Apr 3, 6:33 pm, ankitks.mi... at gmail.com wrote: >> I saw example of memoize function...here is snippet >> >> def memoize(fn, slot): >> def memoized_fn(obj, *args): >> if hasattr(obj, slot): >> return getattr(obj, slot) >> else: >> val = fn(obj, *args) >> setattr(obj, slot, val) >> return val >> return memoized_fn >> >> and I am really clueless, about what it does. I know in general we try >> to keep computed values for future usage. But I am having hard-time >> visualizing it. >> What is obj here? and what does *args means? > > *args is Python's syntax for variadic functions. In case the strange name gives you nothing, see section 4.7 in the Tutorial [1] For a much simpler implementation, see this FAQ entry [2] [1] http://docs.python.org/tut/node6.html#SECTION006700000000000000000 [2] http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects -- Gabriel Genellina From nick at craig-wood.com Tue Apr 1 13:30:05 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Tue, 01 Apr 2008 12:30:05 -0500 Subject: Homework help References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> Message-ID: bobby.connor at gmail.com wrote: > Hey guys > I haev this homework assignment due today > I don't necessarily want the answers, but need help on how to approach > it/the steps i need to solve the problems > Thanks > > # (2 Points) Write a python function howMany(item,lst) which accepts > an item and a lst of items and returns the number of times item occurs > in lst. For example, howMany(3,[1,2,3,2,3]) should return 2. Read section 4.1, 4.2 and 4.6 from here http://docs.python.org/tut/node6.html -- Nick Craig-Wood -- http://www.craig-wood.com/nick From Dodin.Roman at gmail.com Sat Apr 19 07:20:20 2008 From: Dodin.Roman at gmail.com (hellt) Date: Sat, 19 Apr 2008 04:20:20 -0700 (PDT) Subject: winreg module, need help to understand why i'm getting exception Message-ID: HI all, i found winreg module from http://www.rutherfurd.net/python/winreg/index.html very useful and simple, instead _winreg. But i have a problem with this module, in its iterable part. look at the following code key = Key(HKLM,r"SYSTEM\CurrentControlSet\Services\Tcpip\Enum") for i in key.values: print i.value and that is the exception Traceback (most recent call last): File "D:\.Projects\python\temp.py", line 21, in for i in key.values: File "C:\Python25\Lib\site-packages\winreg.py", line 451, in next return self.values[self.index - 1] File "C:\Python25\Lib\site-packages\winreg.py", line 289, in __getitem__ name = _winreg.EnumValue(self.hkey, key)[0] WindowsError: [Error 259] No more data is available so there is some problem with iterate, i think i am still a beginner, so i cant understand why this appears, and what should i fix. if anyone have some time to look closer to this module, i will appreciate this very much. thanks. From hv at tbz-pariv.de Tue Apr 8 04:09:54 2008 From: hv at tbz-pariv.de (Thomas Guettler) Date: Tue, 08 Apr 2008 10:09:54 +0200 Subject: Destructor? In-Reply-To: References: Message-ID: <660niiF2hrfpvU1@mid.individual.net> Duncan Booth schrieb: > [*] except of course for things like power failure. You simply cannot > catch *all* terminations. And 'kill -SIGKILL' can't be caught, since this signal never reaches the process. The os just removes the processes. Thomas -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de From martin at v.loewis.de Sun Apr 6 02:03:34 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 06 Apr 2008 08:03:34 +0200 Subject: RELEASED Python 2.6a2 and 3.0a4 In-Reply-To: References: <47F68547.1040802@v.loewis.de> Message-ID: <47f867b6$0$26887$9b622d9e@news.freenet.de> John Machin wrote: > On Apr 5, 5:45 am, "Martin v. L?wis" wrote: >>> The Windows x86 MSI installer is missing for both 2.6 and 3.0. >> And likely will continue to do so for some time. >> >> > > Someone's got strange definitions of "missing"! Rather a flexible definition of "some time"; this turned out to be roughly 40 hours. Regards, Martin From victorsubervi at gmail.com Wed Apr 30 11:57:44 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 30 Apr 2008 10:57:44 -0500 Subject: Colors for Rows In-Reply-To: <1209500446.5510.4.camel@aalcdl07.lib.unc.edu> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> <20080429121105.f10c3862.darcy@druid.net> <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> <1209495803.5173.11.camel@aalcdl07.lib.unc.edu> <20080429153930.a6eddea6.darcy@druid.net> <1209500446.5510.4.camel@aalcdl07.lib.unc.edu> Message-ID: <4dc0cfea0804300857h6a7a8aa6l25aa0a3e82da12c0@mail.gmail.com> Thank you all. You helped clean up my code. The stupid mistake was in where I set the initial value of the variable z. Victor On Tue, Apr 29, 2008 at 3:20 PM, J. Cliff Dyer wrote: > On Tue, 2008-04-29 at 15:39 -0400, D'Arcy J.M. Cain wrote: > > On Tue, 29 Apr 2008 15:03:23 -0400 > > "J. Cliff Dyer" wrote: > > > Or, if you aren't sure how many colors you'll be using, try the more > > > robust: > > > > > > bg[z % len(bg)] > > > > Good point although I would have calculated the length once at the > > start rather than each time through the loop. > > > > Good catch. Thanks. What's that they say about eyes and bugs? > > Cheers, > Cliff > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From wilson.t.thompson at gmail.com Sun Apr 27 06:34:02 2008 From: wilson.t.thompson at gmail.com (wilson) Date: Sun, 27 Apr 2008 03:34:02 -0700 (PDT) Subject: removing extension Message-ID: i was trying to convert all images in a folder to another type and save the new images in a separate folder.for that i wrote a class and coded some part class ConvertImgs: def __init__(self,infldr,outfldr): if os.path.isdir(infldr): self.infldr=infldr self.outfldr=outfldr else: print "no such folder,exits program" exit(1) if not os.path.isdir(self.outfldr): os.mkdir(self.outfldr) print "made:",self.outfldr for x in os.listdir(infldr): self.origlist=[os.path.normpath(os.path.join(self.infldr,x)) for x in os.listdir(infldr)] ... the self.origlist returns a list of filenames in infolder.I would like to get them as 'C:\\myimages\\imageone' instead of 'C:\\myimages\ \imageone.jpg' sothat i can add a diff extension to all those strings in the list and save in diff format(ie change 'C:\\myimages\\imageone' to 'C:\\myimages\\imageone.gif ' and save in gif format).but i don't know how to remove those extension from the namestring ..can someone help? W From tdimson at gmail.com Wed Apr 9 18:51:00 2008 From: tdimson at gmail.com (Thomas Dimson) Date: Wed, 9 Apr 2008 15:51:00 -0700 (PDT) Subject: Ctypes and C Infinite Callback Loops References: Message-ID: <89cc7b91-21a3-4627-8aac-c0e0a320db4e@z38g2000hsc.googlegroups.com> On Apr 9, 1:24 am, Dennis Lee Bieber wrote: > On Tue, 8 Apr 2008 16:49:27 -0700 (PDT), Thomas Dimson > declaimed the following in comp.lang.python: > > > > > I assume there is some issue with the global interpreter lock or that > > you can't exit the infinite loop from above Python. Any suggestions on > > how I can design this so the thread will be able to issue exits/raise > > exceptions just like a regular thread? Is there a way of terminating > > this thread from the python interpreter or ctypes.pythonapi? > > No... as I recall, you can't /EXIT/ Python from a sub-thread... > Which is what sys.exit() or whatever is trying to do -- shut down the > entire program, not just the thread. The error you get indicates that > the thread doing the shutdown wants to wait for the sub-thread to finish > -- but /it/ IS the sub-thread. Even console interrupts have to be > delivered to the main program. > > The only safe way to terminate a thread is to be able to code it > such that /it/ responds to an externally set value (a boolean, read a > message off a Queue, etc.) and for IT to then exit. Based upon the > sample you showed, that would require the C main loop to be checking for > a shutdown signal... If the API to that main loop library doesn't > include a shutdown capability I'd suggest it is a less than complete > library... And the only thing I'd suggest is not using a Python thread, > but instead spawning a separate process that somehow communicates to the > parent process -- and which can be forceably killed using OS specific > capabilities... "kill -9 pid" > > -- > Wulfraed Dennis Lee Bieber KD6MOG > wlfr... at ix.netcom.com wulfr... at bestiaria.com > HTTP://wlfraed.home.netcom.com/ > (Bestiaria Support Staff: web-a... at bestiaria.com) > HTTP://www.bestiaria.com/ Thanks for the response, it put me in the right direction (I didn't realize there was no way of exiting the interpreter directly from a non-main thread). If anyone ever has the same problem, the solution I ended up using went like this: I created a wrapper around the infinite loop call that had a setjmp in it, exiting if setjmp was non-zero. Inside each callback function, I had a try/except statement that caught all exceptions. If it had an exception, it would set a thread- specific exception variable to sys.exc_info() and then call a C function that did a longjmp. The thread would first call the wrapper to the infinite loop. If the wrapper returns (because of a longjmp), it would check the thread- specific exception variable for a non-None value and raise the very same exception (with the same traceback) if it found it. A fairly large hack, but it seemed to do the job. Thanks again. From sturlamolden at yahoo.no Sun Apr 20 16:19:43 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sun, 20 Apr 2008 13:19:43 -0700 (PDT) Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B52DE.8070105@holdenweb.com> Message-ID: <2be5608d-560d-4712-b104-f2341a7fa569@t63g2000hsf.googlegroups.com> On Apr 20, 9:09 pm, "Hank @ITGroup" wrote: > Could you please give us some clear clues to obviously call python to > free memory. We want to control its gc operation handily as we were > using J**A. If you want to get rid of a Python object, the only way to do that is to get rid of every reference to the object. This is no different from Java. If you just want to deallocate and allocate memory to store text, Python lets you do that the same way as C: from __future__ import with_statement import os from ctypes import c_char, c_char_p, c_long, cdll from threading import Lock _libc = cdll.msvcr71 if os.name == 'nt' else cdll.libc _lock = Lock() def string_heapalloc(n): ''' allocate a mutable string using malloc ''' with _lock: malloc = _libc.malloc malloc.argtypes = [c_long] malloc.restype = c_char * n memset = _libc.memset memset.restype = None memset.argtypes = [c_char * n, c_char, c_long] tmp = malloc(n) memset(tmp,'0',n) return tmp def string_heapfree(s): ''' free an allocated string ''' with _lock: free = _libc.free free.restype = None free.argtypes = [c_char_p] ptr_first_char = c_char_p( s[0] ) free(ptr_first_char) if __name__ == '__main__': s = string_heapalloc(1000) s[:26] = 'abcdefghijklmnopqrstuvwxyz' print s[:] string_heapfree(s) From ankitks.mital at gmail.com Thu Apr 3 19:33:41 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Thu, 3 Apr 2008 16:33:41 -0700 (PDT) Subject: regarding memoize function Message-ID: I saw example of memoize function...here is snippet def memoize(fn, slot): def memoized_fn(obj, *args): if hasattr(obj, slot): return getattr(obj, slot) else: val = fn(obj, *args) setattr(obj, slot, val) return val return memoized_fn and I am really clueless, about what it does. I know in general we try to keep computed values for future usage. But I am having hard-time visualizing it. What is obj here? and what does *args means? Thanks From aljosa.mohorovic at gmail.com Fri Apr 25 08:56:12 2008 From: aljosa.mohorovic at gmail.com (Aljosa Mohorovic) Date: Fri, 25 Apr 2008 05:56:12 -0700 (PDT) Subject: PYTHONPATH breaks MySQLdb Message-ID: i have a working MySQLdb module (/usr/lib/python2.4/site-packages/ MySQL_python-1.2.2-py2.4-linux-i686.egg), using it without problems. "clean shell" after login: python -c "import MySQLdb" reports no errors if i export PYTHONPATH: export PYTHONPATH=/var/www/projects/uv_portal/portal python -c "import MySQLdb" reports no errors as in previous case if i export PYTHONPATH: export PYTHONPATH=/var/www/projects/uv_portal/portal/apps i get this: python -c "import MySQLdb" Traceback (most recent call last): File "", line 1, in ? ImportError: No module named MySQLdb is there any reason why this happens? Aljosa Mohorovic From stefan_ml at behnel.de Sat Apr 26 17:56:59 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sat, 26 Apr 2008 23:56:59 +0200 Subject: Parsing HTML? In-Reply-To: <76811693-7617-4952-88d3-d1368c4500c5@1g2000prg.googlegroups.com> References: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> <47F9B92C.1030802@behnel.de> <76811693-7617-4952-88d3-d1368c4500c5@1g2000prg.googlegroups.com> Message-ID: <4813A52B.9070206@behnel.de> Benjamin wrote: > On Apr 6, 11:03 pm, Stefan Behnel wrote: >> Benjamin wrote: >>> I'm trying to parse an HTML file. I want to retrieve all of the text >>> inside a certain tag that I find with XPath. The DOM seems to make >>> this available with the innerHTML element, but I haven't found a way >>> to do it in Python. >> import lxml.html as h >> tree = h.parse("somefile.html") >> text = tree.xpath("string( some/element[@condition] )") >> >> http://codespeak.net/lxml >> >> Stefan > > I actually had trouble getting this to work. I guess only new version > of lxml have the html module, and I couldn't get it installed. lxml > does look pretty cool, though. Yes, the above code requires lxml 2.x. However, older versions should allow you to do this: import lxml.etree as et parser = etree.HTMLParser() tree = h.parse("somefile.html", parser) text = tree.xpath("string( some/element[@condition] )") lxml.html is just a dedicated package that makes HTML handling beautiful. It's not required for parsing HTML and doing general XML stuff with it. Stefan From tjreedy at udel.edu Mon Apr 7 15:15:29 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 7 Apr 2008 15:15:29 -0400 Subject: A funnily inconsistent behavior of int and float References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com> <1d11875a-470a-489f-910a-b420a145eb61@a1g2000hsb.googlegroups.com> Message-ID: "Mark Dickinson" wrote in message news:1d11875a-470a-489f-910a-b420a145eb61 at a1g2000hsb.googlegroups.com... | On Apr 7, 6:43 am, "Colin J. Williams" wrote: | > This is good but the documentation for | > 3.0 is missing the syntax documentation | > from 2.5 | | Is | | http://docs.python.org/dev/3.0/reference/lexical_analysis.html#integer-literals | | the documentation that you're looking for? | | But it seems to me that Lie's original point isn't really | about integer *literals* anyway---it's about the behaviour | of the built-in int() function when applied to a string. So | | http://docs.python.org/dev/3.0/library/functions.html#int | | is probably the appropriate place in the documentation. And | I agree that it could be made clearer exactly what strings are | acceptable here. Agreed. It says "If radix is zero, the interpretation is the same as for integer literals." But integer literals are unsigned. Is radix 0 any different from the default of radix 10? It also says "If the argument is a string, it must contain a possibly signed number of arbitrary size, possibly embedded in whitespace." But only integers, not 'numbers' as some would understand that, are accepted. My suggestions: 1. Change signature to: int([number | string[, radix]). This makes it clear that radix can only follow a string without having to say so in the text. 2. Replace text with: Convert a number or string to an integer. If no arguments are given, return 0. If a number is given, return number.__int__(). Conversion of floating point numbers to integers truncates towards zero. A string must be a base-radix integer literal optionally preceded by '+' or '-' (with no space in between) and optionally surrounded by whitespace. A base-n literal consists of the digits 0 to n-1, with 'a' to 'z' (or 'A' to 'Z') having values 10 to 35. The default radix is 10. The allowed values are 0 and 2-36, with 0 the same as 10. If 0 is not the same as 10, the last would have to be changed, but I could not detect any difference in a quick test. After looking at any comments here, I will consider submitting these to the tracker. Terry Jan Reedy From cwitts at gmail.com Thu Apr 10 04:07:44 2008 From: cwitts at gmail.com (Chris) Date: Thu, 10 Apr 2008 01:07:44 -0700 (PDT) Subject: new user needs help! References: <16571823.post@talk.nabble.com> Message-ID: On Apr 9, 11:02?pm, drjekil wrote: > I have done something so far about that problem,but its not the good way to > do it > > need ur comments about that.... > > from string import ?*; > import sys > > myfile = open("/afs/pdc.kth.se/home/d/debnath/membrane/1a91A.txt") > a = myfile.readlines() > data = myfile.readlines() > for line in myfile.readlines(): > ? ? ? ?fields = line.split('\t') > > ? ? ? ?items=fields.strip() > ? ? ? ?list1.append(items[1]) > > for i in aminoacid: > ? ? if ?10.0 <= z <= 22.0: > ? ? matches.append([1,i]) > #here i am getting comment! ?bash-3.1$ python bb.py > ? File "bb.py", line 16 > ? ? matches.append([1,i]) > ? ? ? ? ? ^ > IndentationError: expected an indented block > > ? ? else: > ? ? matches.append([-1,i]) > You are getting the indentation error because you need to tab the lines in after your 'if' and 'else' statements. After that is fixed you should get an Attribute Error on the 'items=fields.strip()' as a list doesn't have access to strip. import string myfile = open("/afs/pdc.kth.se/home/d/debnath/membrane/1a91A.txt", 'rb') AMINO_ACIDS = ['A','B','C',......'X','Y','Z'] for line in myfile: # Files are iterable themselves. try: fields = map(string.strip, line.split('\t')) # This will strip every column for you name, aa, topo, access, tssp, stride, z = fields except IndexError: # In case you don't have enough elements print 'Not enough elements on the line, moving along' if 10 <= z <= 22: # You only wanted between those Z-Coords ? if aa in AMINO_ACIDS: # Now actually process the data you want > print "#T/F ?A ?C ?D ?E ?F ?G ?H ?I ?K ?L ?M ?N ?P ?Q ?R ?S ?T ?V ?W ?X ?Y > Z" > > for a in range(0,len(matches),1): > > ? ? if ? ? matches[a][0]==1: > > ? ? if matches[a][1]=='A': > ? ? ? ? print "1 ?1:1 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 > 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? elif matches[a][1]=='C': > ? ? ? ? print "1 ?1:0 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 > 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? elif matches[a][1]=='D': > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:1 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > """ ? ?if matches[a][1]=='E' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:1 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='F' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:1 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='G' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:1 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='H' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='I' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:1 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='K' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:1 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='L' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:1 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='M' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:1 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='N' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:1 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='P' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:1 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='Q' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='R' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:1 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='S' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:1 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='T' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:1 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='V' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:1 19:0 20:0 21:0" > ? ? if matches[a][1]=='X' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:1 20:0 21:0" > ? ? if matches[a][1]=='Y' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:1 21:0" > ? ? if matches[a][1]=='Z' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:1" > > """ > ? ? else: > ? ? if matches[a][1]=='A': > ? ? ? ? print "-1 ?1:1 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 > 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? elif matches[a][1]=='C': > ? ? ? ? ? ? print "-1 ?1:0 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? elif matches[a][1]=='D': > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:1 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > """ ? ?if matches[a][1]=='E' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:1 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='F' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:1 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='G' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:1 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='H' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='I' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:1 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='K' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:1 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='L' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:1 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='M' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:1 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='N' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:1 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='P' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:1 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='Q' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='R' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:1 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='S' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:1 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='T' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:1 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='V' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:1 19:0 20:0 21:0" > ? ? if matches[a][1]=='X' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:1 20:0 21:0" > ? ? if matches[a][1]=='Y' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:1 21:0" > ? ? if matches[a][1]=='Z' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:1" > ? ?waiting for ur opinion. > ? ?thanks > > -- > View this message in context:http://www.nabble.com/new--user-needs-help%21-tp16571823p16596608.html > Sent from the Python - python-list mailing list archive at Nabble.com. Masses of print statements might work for debugging but you can get a better structure through something else. If you have a specific message for those you could always build a dictionary containing the messages and access them like.... msg_dict = {'A':'Message for A', 'B':'Message for B',......,'Z':'Message for Z'} for part1, part2 in matches: # You have a 2 element structure, (part1, part2) inside the list and lists are iterable if part2 == 1: # Test the value try: print msg_dict[part1] except KeyError: print 'Amino Acid listed not on record' # or you can just simply pass over and not log anything Hope that helps. Chris From deets at nospam.web.de Wed Apr 16 06:25:52 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 16 Apr 2008 12:25:52 +0200 Subject: Image handling - stupid question References: <0001HW.C42B9FB90009B7E8B01AD9AF@news.individual.de> Message-ID: <66m2icF2lo3ghU3@mid.uni-berlin.de> Jumping Arne wrote: > I'm going to try to write some imange manipulation code (scaling, reading > EXIF and IPTC info) and just want to ask if PIL is *THE* library to use? > > I looked at and noticed that the > latest version is from Dec 2006. > > In my experience that means that either it's abandoned or that it's very > good and stable. Certainly the latter. Diez From __peter__ at web.de Tue Apr 29 01:55:53 2008 From: __peter__ at web.de (Peter Otten) Date: Tue, 29 Apr 2008 07:55:53 +0200 Subject: File IO Issues, help :( References: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> Message-ID: Kevin K wrote: > On Apr 29, 12:38 am, "Eric Wertman" wrote: >> chuck in a jsfile.close(). The buffer isn't flushing with what you >> are doing now. jsfile.flush() might work... not sure. Closing and >> re-opening the file for sure will help though. >> > > Yeah sorry I forgot to include the close() in the quote but its there. > In fact I moved it up a bit and still no luck heres the new code: > > jsfile = open("../timeline.js", "r+") > jscontent = jsfile.readlines() > jsfile.truncate() > > for line in jscontent: > if re.search('var d =', line): > line = "var d = \""+mint['1'].ascdate()+"\"\n" > print line > jsfile.write(line) > jsfile.close() > > I tried this can got the same result...?? """ truncate(...) truncate([size]) -> None. Truncate the file to at most size bytes. Size defaults to the current file position, as returned by tell(). """ After the readlines() call the current file position is at the end of the file. Try jsfile.truncate(0). Also note that readlines() reads the whole file into memory. For large files it would therefore be better to write to a new file and rename it afterwards. Peter From bearophileHUGS at lycos.com Tue Apr 8 18:11:41 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Tue, 8 Apr 2008 15:11:41 -0700 (PDT) Subject: Data structure recommendation? References: <1adc3541-7775-4938-bd5a-953dd041656c@2g2000hsn.googlegroups.com> Message-ID: Few more notes on the code: You may use the @property in such situations (or you may just use attributes, dropping the property). Note that Python doesn't inline functions calls like Java HotSpot does quite often. def __children(self): raise NotImplementedError() children = property(__children) ==> (not tested!) @property def __children(self): raise NotImplementedError() If the profiling shows this is s slow, and it's used on lot of items, there are faster O(1) algorithms for this, like this one: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/466330 @staticmethod def determine_median(numbers): return sorted(numbers)[ len(numbers) / 2 ] I have seen you use lot of double underscores (I think one may often suffice, but usually two aren't a problem): def __children(self): Stripped of comments, docstrings, and empty lines the code is just 280 lines long (it's 1498 with them!), so a translation doesn't seem too much work (expecially if the original version was Java). The code seem really well commented, organized, etc. And I like it, it looks better than 90+% of the commercial Python code I see :-) Bye, bearophile From fennelllindy8241 at gmail.com Mon Apr 28 03:18:02 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:18:02 -0700 (PDT) Subject: crack addict Message-ID: crack addict http://crack.cracksofts.com From drjekil77 at gmail.com Tue Apr 8 15:55:33 2008 From: drjekil77 at gmail.com (drjekil) Date: Tue, 8 Apr 2008 12:55:33 -0700 (PDT) Subject: new user needs help! Message-ID: <16571823.post@talk.nabble.com> I am totally new in biopython and its my first program.so may be i am asking stupid question. I am working with a text filelooks like this: #NAME AA TOPO ACCESS DSSP STRIDE Z-COORD 1lghB A i 79.8 H H -24.58 1lghB V i 79.6 H H -22.06 1lghB H i 71.9 H H -19.94 i need to compare those lines which has a Z-COORED value between 10 to 22 and presents in the following way True/false A C D E F G H I K L M N P Q R S T V X Y W(here alfabets represents amino acids) 1 1:1 2:0 3:0 and so on for rest of the amino acids. IF PRESENT IN THAT RANGE IF not PRESENT IN THAT RANGE then -1 1:0 2:0 so on,it should be 1 instead of 0 when it will find corresponding amino acid for that line.say here,for 2nd line it will be 16:1. true will represent 1,false -1. i have to cheek all the lins in the file and print it. u have to tell simply otherwise i cant understand even,so stupid am i! I will be really greatful!Thanks in advance -- View this message in context: http://www.nabble.com/new--user-needs-help%21-tp16571823p16571823.html Sent from the Python - python-list mailing list archive at Nabble.com. From cokofreedom at gmail.com Thu Apr 10 07:15:53 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Thu, 10 Apr 2008 04:15:53 -0700 (PDT) Subject: questions about Exceptions? References: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> <71cc8c25-f5f9-4f21-a9d8-06780bf97608@f63g2000hsf.googlegroups.com> <9af81b1a-3e02-4406-b9d2-0a9b6f46566b@p39g2000prm.googlegroups.com> <0e586d5d-6799-433f-b8a4-4de5d2a87b61@h1g2000prh.googlegroups.com> <46a79564-4069-46af-b6ab-b38bd9152c2a@d45g2000hsc.googlegroups.com> <1f413b6e-f964-4f8d-b781-61985f86acc2@a9g2000prl.googlegroups.com> Message-ID: > the erase() id alwys need if u wanna abort whilst u wrote something. But if it is meant to only evaluate once you've pressed the enter key (I take it?) you shouldn't need that. And if you are to abort while evaluating it will not do that. From john00587 at gmail.com Mon Apr 21 01:42:48 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:42:48 -0700 (PDT) Subject: irc proxy search crack Message-ID: irc proxy search crack http://cracks.00bp.com F R E E C R A C K S From andrew at acooke.org Sat Apr 26 08:21:06 2008 From: andrew at acooke.org (andrew cooke) Date: Sat, 26 Apr 2008 05:21:06 -0700 (PDT) Subject: Logging ancestors ignored if config changes? References: <7770a385-e26d-4ad9-bc72-fa1228034c3b@26g2000hsk.googlegroups.com> Message-ID: One way to handle this is to make creation of module-level Loggers lazy, and make sure that logging initialisation occurs before any other logging is actually used (which is not so hard - just init log at the start of the application). Of course, there's a performance hit... For example: class Log(object): def __init__(self, name): super(Log, self).__init__() self._name = name self._lazy = None def __getattr__(self, key): if not self._lazy: self._lazy = logging.getLogger(self._name) return getattr(self._lazy, key) and then, in some module: from acooke.util.log import Log log = Log(__name__) [...] class Foo(object): def my_method(self): log.debug("this works as expected") Andrew From ch612bunn at gmail.com Sun Apr 27 09:15:58 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:15:58 -0700 (PDT) Subject: Microsoft Office Home and Student 2007 crack Message-ID: <3cf140a3-0ad2-4a63-a71a-297c679c25ff@l64g2000hse.googlegroups.com> Microsoft Office Home and Student 2007 crack http://wga-cracks.crackkey.net From Lie.1296 at gmail.com Sun Apr 20 05:55:52 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 20 Apr 2008 02:55:52 -0700 (PDT) Subject: python setup.py install on Vista? References: Message-ID: On Apr 19, 6:29 am, globalrev wrote: > type "python setup.py install" > > that is used in most "addons" for python. > > well using windows vista, where the h*** am i supposed to type this? > > if it is not doable in windows, what do i have to do instead? just > clicking the setup.py-file never works. It seems that quite a lot of people wondered why python doesn't set the environment variable to Python Path in the default installation. While most Windows users that are flattered with GUI (IDLE) doesn't really care about it, they'd have trouble when trying to run python from command prompt. To set your environment variable: 1. Right-click the Computer icon 2. Choose "Properties" from the context menu 3. Click the "Advanced system settings" link 4. Click the "Environment Variables" button 5. Add Python's installation path (usually C:\PythonXX where XX is the Python version) to System Variables to the end of the path lists 6. Test it, try opening a command prompt and type "python" or "python filename.py" outside Python installation directory From torriem at gmail.com Thu Apr 17 13:00:35 2008 From: torriem at gmail.com (Michael Torrie) Date: Thu, 17 Apr 2008 11:00:35 -0600 Subject: How to know if a module is thread-safe In-Reply-To: <4807805b$0$884$ba4acef3@news.orange.fr> References: <4807805b$0$884$ba4acef3@news.orange.fr> Message-ID: <48078233.2060903@gmail.com> J?r?my Wagner wrote: > Hi, I recently tried to use the subprocess module > within a threading.Thread class, but it appears the module > is not thread-safe. http://bugs.python.org/issue1731717 Pretty bad bug, really, since subprocess is supposed to be the replacement for all the other mechanisms like popen2 and os.popen* > > What is the policy of python regarding thread-safety of a module ? I personally don't know. But any module that's not thread safe would be a bug in my mind. From gagsl-py2 at yahoo.com.ar Mon Apr 21 01:32:06 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 02:32:06 -0300 Subject: Accessing parallel port interrupts using python or any c python binding ? References: <384662990804202109w7180365cu99599ca1628a5736@mail.gmail.com> Message-ID: En Mon, 21 Apr 2008 01:09:59 -0300, kapardhi bvn escribi?: > Any body can tell me an efficient way of reading parallel port at high > speed. > this is basically to extend ISA and other bus interfacing. See pyparallel (part of the pyserial package) -- Gabriel Genellina From Scott.Daniels at Acm.Org Thu Apr 17 21:28:08 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Thu, 17 Apr 2008 18:28:08 -0700 Subject: Request a short code review In-Reply-To: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> References: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> Message-ID: james at reggieband.com wrote: > Here is a method I came across that I would like to clean up: > > > def output_random_lesson_of_type(self, type=None): > """Output a lesson of a specific type - if no type is passed in > then output any type.""" > if type: > filtered_lessons = filter(lambda x: x["type"] == type, > self.lesson_data["lessons"]) > if filtered_lessons: > lesson = self.output_random(filtered_lessons) > else: > print "Unable to find lessons of type %s." % type > else: > lesson = self.output_random(self.lesson_data["lessons"]) > return lesson Simplest: Just let the error float up to where it is caught import random def output_random_lesson_of_type(self, type=None): """Output a lesson of a specific type - None mans any type.""" lessons = self.lesson_data["lessons"] if type is not None: lessons = [x for x in lessons if x["type"] == type] return random.choice(lessons) Or, if you really want to print your message, change that last line to: try: return random.choice(lessons) except IndexError: print "Unable to find lessons of type %s." % type raise -Scott David Daniels Scott.Daniels at Acm.Org From __peter__ at web.de Mon Apr 28 07:03:31 2008 From: __peter__ at web.de (Peter Otten) Date: Mon, 28 Apr 2008 13:03:31 +0200 Subject: Retrieving int from hex in a file. References: <9edfaaa3-4e87-4f74-90a5-c10c9daae101@r66g2000hsg.googlegroups.com> Message-ID: Filipe Teixeira wrote: > I have to open a binary file from an old computer and recover the > information stored (or at least try to). I use: > I would like to convert these hex representations to int, but this If you want to do it efficiently have a look at the array module: >>> import os, array >>> a = array.array("B") >>> filename = "/usr/bin/python" >>> a.fromfile(open(filename, "rb"), os.path.getsize(filename)) >>> a[10] 0 >>> a[:10] array('B', [127, 69, 76, 70, 2, 1, 1, 0, 0, 0]) Peter From martin at v.loewis.de Sun Apr 27 13:25:06 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 27 Apr 2008 19:25:06 +0200 Subject: Why can't timedeltas be divided? In-Reply-To: References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> <48142747$0$20906$9b622d9e@news.freenet.de> Message-ID: <4814B6F2.5010604@v.loewis.de> > Well, http://bugs.python.org/issue1673409 seems very closely related. I can't see the relationship. This issue is about conversion methods, not about arithmetic. Regards, Martin From sjmachin at lexicon.net Fri Apr 25 17:22:21 2008 From: sjmachin at lexicon.net (John Machin) Date: Fri, 25 Apr 2008 14:22:21 -0700 (PDT) Subject: Setting an attribute without calling __setattr__() References: Message-ID: On Apr 26, 7:01 am, Joshua Kugler wrote: > OK, I'm sure the answer is staring me right in the face--whether that answer > be "you can't do that" or "here's the really easy way--but I am stuck. I'm > writing an object to proxy both lists (subscriptable iterables, really) and > dicts. > > My init lookslike this: > > def __init__(self, obj=None): > if type(obj).__name__ in 'list|tuple|set|frozenset': > self.me = [] > for v in obj: > self.me.append(ObjectProxy(v)) > elif type(obj) == dict: > self.me = {} > for k,v in obj.items(): > self.me[k] = ObjectProxy(v) > > and I have a __setattr__ defined like so: > > def __setattr__(self, name, value): > self.me[name] = ObjectProxy(value) > > You can probably see the problem. > > While doing an init, self.me = {} or self.me = [] calls __setattr__, which > then ends up in an infinite loop, and even it it succeeded > > self.me['me'] = {} > > is not what I wanted in the first place. > > Is there a way to define self.me without it firing __setattr__? > Consider reading the *second* paragraph about __setattr__ in section 3.4.2 of the Python Reference Manual. From colas.francis at gmail.com Mon Apr 14 12:28:22 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Mon, 14 Apr 2008 09:28:22 -0700 (PDT) Subject: eval modifies passed dict References: <2b2398b1-042e-46bb-b840-ea9e07d87bd1@2g2000hsn.googlegroups.com> Message-ID: <6ca01677-685f-432e-b32f-167ce0b37c58@d1g2000hsg.googlegroups.com> On 14 avr, 18:05, Duncan Booth wrote: > Janto Dreijer wrote: > > It seems eval is modifying the passed in locals/globals. This is > > behaviour I did not expect and is really messing up my web.py app. > > > Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) > > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > > Type "help", "copyright", "credits" or "license" for more information. > >>>> d = dict(a=1) > >>>> d.keys() > > ['a'] > >>>> eval("a", d) > > 1 > >>>> d.keys() > > ['a', '__builtins__'] > > > That can't be right. > > That can exactly be right. > > The current document is (I think) wrong or at the least misleading. It > says: > > > If the globals dictionary is present and lacks '__builtins__', the > > current globals are copied into globals before expression is parsed. > > I think it should say: > > > If the globals dictionary is present and lacks '__builtins__', the > > current value of __builtins__ is added to globals before expression > > is parsed. > > i.e. only a single variable is assigned, other globals aren't copied. Indeed: Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> globals().keys() ['__builtins__', '__name__', '__doc__'] >>> b = 2 >>> d = {'a': 1} >>> eval('a', d) 1 >>> d.keys() ['a', '__builtins__'] From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 22 08:50:11 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 22 Apr 2008 14:50:11 +0200 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> Message-ID: <480ddefc$0$22219$426a74cc@news.free.fr> GD a ?crit : > Please remove ability to multiple inheritance in Python 3000. Please dont. > Multiple inheritance is bad for design, rarely used and contains many > problems for usual users. Don't blame the tool for your unability to use it properly. > Every program can be designed only with single inheritance. Every program can be implemented in machine code. From hdante at gmail.com Fri Apr 18 13:33:02 2008 From: hdante at gmail.com (hdante) Date: Fri, 18 Apr 2008 10:33:02 -0700 (PDT) Subject: Unicode chr(150) en dash References: <48063434$0$36327$742ec2ed@news.sonic.net> <7dae96d4-48c4-46c9-9aa9-33a263b84ca4@26g2000hsk.googlegroups.com> <480887b8@news.mel.dft.com.au> Message-ID: On Apr 18, 8:36 am, John Machin wrote: > hdante wrote: > > > The character code in question (which is present in the page), 150, > > doesn't exist in ISO-8859-1. > > Are you sure? Consider (re-)reading all of the Wikipedia article. > > 150 aka \x96 doesn't exist in ISO 8859-1. ISO-8859-1 (two hyphens) is a > superset of ISO 8859-1 (one hyphen) and adds the not-very-useful-AFAICT > control codes \x80 to \x9F. > > > See > > > http://en.wikipedia.org/wiki/ISO/IEC_8859-1(the entry for 150 is > > blank) > > You must have been looking at the table of the "lite" ISO 8859-1 (one > hyphen). Reading further you will see \x96 described as SPA or "Start of > Guarded Area". Then there is the ISO-8859-1 (two hyphens) table, > including \x96. > > HTH, > John Sorry, that's right, I should have been referring to the second table. From mail at timgolden.me.uk Fri Apr 11 16:22:18 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 11 Apr 2008 21:22:18 +0100 Subject: Windows - window status (Running vs Not Responding) In-Reply-To: <5f4a5d63-c862-4d25-8849-6a36dd4e138d@m3g2000hsc.googlegroups.com> References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> <5f4a5d63-c862-4d25-8849-6a36dd4e138d@m3g2000hsc.googlegroups.com> Message-ID: <47FFC87A.1080209@timgolden.me.uk> Mike Driscoll wrote: > http://www.informit.com/articles/article.aspx?p=19489&seqNum=4 > > If you're better than I am, you can probably translate this to the > Python equivalent. Zenoss also has some monitoring software that's > open source Python code. I'm afraid that article only allows you to determine whether a known executable is running, If that's what the OP's after, then you can do as much by querying WMI thusly: import wmi c = wmi.WMI () EXE = "notepad.exe" for process in c.Win32_Process (Caption=EXE): print process break else: print "None found" TJG From ridenour4159 at gmail.com Thu Apr 24 06:12:46 2008 From: ridenour4159 at gmail.com (ridenour4159 at gmail.com) Date: Thu, 24 Apr 2008 03:12:46 -0700 (PDT) Subject: crack spyder Message-ID: crack spyder http://cracks.12w.net F R E E C R A C K S From dickinsm at gmail.com Sun Apr 6 18:12:31 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Sun, 6 Apr 2008 15:12:31 -0700 (PDT) Subject: A funnily inconsistent behavior of int and float References: Message-ID: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com> On Apr 6, 1:29?pm, Lie wrote: > I've noticed some oddly inconsistent behavior with int and float: > > Python 2.5.1 (r251:54863, Mar ?7 2008, 03:39:23) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2>>> int('- ? ? ? ? ?345') > > -345 > > works, but > > >>> float('- ? ? ? 345.083') > > Traceback (most recent call last): > ? File "", line 1, in > ValueError: invalid literal for float(): - ? ? ? 345.083 This is a known issue, that has been fixed for Python 3.0. It was decided not to risk breakage by changing this in Python 2.x. See: http://bugs.python.org/issue1779 Mark From ewertman at gmail.com Fri Apr 25 16:03:28 2008 From: ewertman at gmail.com (Eric Wertman) Date: Fri, 25 Apr 2008 16:03:28 -0400 Subject: Calling Python code from inside php In-Reply-To: References: <679e9oF2mti63U1@mid.uni-berlin.de> <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> Message-ID: <92da89760804251303y4288a5fapf0386a00dfed06e9@mail.gmail.com> > > A simple yet dangerous and rather rubbish solution (possibly more of a > > hack than a real implementation) could be achieved by using a > > technique described above: > > > > > echo exec('python foo.py'); > > This will spawn a Python interpreter, and not be particularly > efficient. You could just as well have used CGI. I'm in a bit of a similar situation. I decided to use python to solve problems where I could, in a more regimented fashion. For instance, I have a set of functions in a script, table.py. After I set up mod_python to handle requests to a single directory with python, I can call this with: embedded in the page. This is probably pretty hackish too, but at least it doesn't spawn a new process, and I don't have to solve things that aren't related to display with php. From patrickkidd.lists at gmail.com Fri Apr 11 15:28:33 2008 From: patrickkidd.lists at gmail.com (Patrick Stinson) Date: Fri, 11 Apr 2008 13:28:33 -0600 Subject: frozen/builtin modules and new interpreter instances Message-ID: <664bf2b80804111228l50561a30y1f6bbd56e7cf556@mail.gmail.com> So when creating a new interpreter (thread state) are you expected to re-set PyImport_FrozenModules and call yImport_ExtendInittab() again? the former seems to get corrupted between Py_Initialize() and Py_NewInterpreter(). I know that modules are not shared between interpreter instances, and it would be nice to know how to handle built-in, frozen, and statically linked modules. Any generic help on this topic would be great. Thanks! -- Patrick Kidd Stinson http://www.patrickkidd.com/ http://pkaudio.sourceforge.net/ http://pksampler.sourceforge.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From soray6034rao at gmail.com Wed Apr 30 07:29:31 2008 From: soray6034rao at gmail.com (soray6034rao at gmail.com) Date: Wed, 30 Apr 2008 04:29:31 -0700 (PDT) Subject: ulead video studio 8 serial crack Message-ID: <34ebac8a-68fe-4734-9a35-2b5727cb3444@8g2000hse.googlegroups.com> ulead video studio 8 serial crack http://crack.cracksofts.com From nagle at animats.com Mon Apr 28 14:41:41 2008 From: nagle at animats.com (John Nagle) Date: Mon, 28 Apr 2008 11:41:41 -0700 Subject: Tremendous slowdown due to garbage collection In-Reply-To: References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: <48161A65.6040705@animats.com> Dieter Maurer wrote: > Christian Heimes writes on Sat, 12 Apr 2008 18:47:32 +0200: >> andreas.eisele at gmail.com schrieb: >>> which made me suggest to use these as defaults, but then > We observed similar very bad behaviour -- in a Web application server. > Apparently, the standard behaviour is far from optimal when the > system contains a large number of objects and occationally, large > numbers of objects are created in a short time. > We have seen such behaviour during parsing of larger XML documents, for > example (in our Web application). Our solution to that was to modify BeautifulSoup to use weak pointers. All the pointers towards the root and towards previous parts of the document are "weak". As a result, reference counting alone is sufficient to manage the tree. We still keep GC enabled, but it doesn't find much to collect. John Nagle SiteTruth From bryon.mayo at gmail.com Sun Apr 13 00:16:24 2008 From: bryon.mayo at gmail.com (Bryon) Date: Sat, 12 Apr 2008 21:16:24 -0700 (PDT) Subject: Looking for a way to include Pyhtho scripting INSIDE a python program References: <48017af0$0$36399$742ec2ed@news.sonic.net> Message-ID: On Apr 12, 10:16 pm, John Antypas wrote: > Hello all, > > I'm writing in tool in Python that manipulates various data objects read > from various streams. I wanted to give the user a chance to do advanced > work that could not easily be done from a GUI. > > At first, I tried putting in a lightweight scripting language, and then > I thought, why not include Python in itself -- it is certainly powerful > enough. > > I had assumed I'd present the user with a text window in which they > could type arbitrary python code. I'd wrap that code around a function > and pass that function a call of objects they could manipulate by > calling the methods of that class. > > 1. How can a python program invoke ANOTHER interpreter? > 2. How can I pass the class in as its argument and get the modified > class back? > > I know I can do something very ugly -- call a C method that calls a new > python interpreter but that seems VERY ugly. > > Help? > > Thanks. I'm very new to python but I think this is what you're looking for http://pydoc.org/2.5.1/__builtin__.html#-compile From skanemupp at yahoo.se Sat Apr 5 01:05:35 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 4 Apr 2008 22:05:35 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <7113d012-01bb-4426-bb40-9e2811cdb102@x41g2000hsb.googlegroups.com> <3cf4bbc8-b828-45c5-b9a8-766ce600af43@y21g2000hsf.googlegroups.com> Message-ID: On 5 Apr, 07:02, skanem... at yahoo.se wrote: > On 5 Apr, 05:57, skanem... at yahoo.se wrote: > > > > > On 5 Apr, 05:26, 7stud wrote: > > > > On Apr 4, 7:06 pm, skanem... at yahoo.se wrote: > > > > > 1st question: > > > > > when i run this program 1 will be printed into the interpreter when i > > > > run it BUT without me clicking the actual button. > > > > when i then click the button "1", nothing happens. > > > > > obv i dont want any output when i dont push the button but i want it > > > > when i do. > > > > > what am i doing wrong here? > > > > > 2nd question: > > > > > i want all the buttons to have the same size. i thought i should use > > > > row/columnspan but i dont get that to work. > > > > how should i do? > > > > > [code] > > > > #! /usr/bin/env python > > > > from Tkinter import * > > > > import tkMessageBox > > > > > class GUIFramework(Frame): > > > > """This is the GUI""" > > > > > def __init__(self,master=None): > > > > """Initialize yourself""" > > > > > """Initialise the base class""" > > > > Frame.__init__(self,master) > > > > > """Set the Window Title""" > > > > self.master.title("Calculator") > > > > > """Display the main window" > > > > with a little bit of padding""" > > > > self.grid(padx=10,pady=10) > > > > self.CreateWidgets() > > > > > def CreateWidgets(self): > > > > > self.enText = Entry(self) > > > > self.enText.grid(row=0, column=0, columnspan=8, padx=5, > > > > pady=5) > > > > > self.enText = Entry(self) > > > > self.enText.grid(row=1, column=0, columnspan=8, padx=5, > > > > pady=5) > > > > > self.btnDisplay = Button(self, text="1", > > > > command=self.Display(1)) > > > > self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="2", default=ACTIVE) > > > > self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="3", default=ACTIVE) > > > > self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="+", default=ACTIVE) > > > > self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="4", default=ACTIVE) > > > > self.btnDisplay.grid(row=4, column=0, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="5", default=ACTIVE) > > > > self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="6", default=ACTIVE) > > > > self.btnDisplay.grid(row=4, column=2, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="-", default=ACTIVE) > > > > self.btnDisplay.grid(row=4, column=3, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="7", default=ACTIVE) > > > > self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="8", default=ACTIVE) > > > > self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="9", default=ACTIVE) > > > > self.btnDisplay.grid(row=5, column=2, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="*", default=ACTIVE) > > > > self.btnDisplay.grid(row=5, column=3, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="0", default=ACTIVE) > > > > self.btnDisplay.grid(row=6, column=0, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="C", default=ACTIVE) > > > > self.btnDisplay.grid(row=6, column=1, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="r", default=ACTIVE) > > > > self.btnDisplay.grid(row=6, column=2, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="/", default=ACTIVE) > > > > self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) > > > > > def Display(self, xbtn): > > > > if xbtn==1: > > > > print 1 > > > > > if __name__ == "__main__": > > > > guiFrame = GUIFramework() > > > > guiFrame.mainloop() > > > > > [/code] > > > > If you have this function: > > > > def f(): > > > print 1 > > > return 10 > > > > and you write: > > > > result = f() > > > > The '()' is the function execution operator; it tells python to > > > execute the function. In this case, the function executes, and then > > > the return value of the function is assigned to the variable result. > > > If a function does not have a return statement, then the function > > > returns None by default. > > > > The same thing is happening in this portion of your code: > > > > command = self.Display(1) > > > > That code tells python to execute the Display function and assign the > > > function's return value to the variable command. As a result Display > > > executes and 1 is displayed. Then since Dispay does not have a return > > > statement, None is returned, and None is assigned to command. > > > Obviously, that is not what you want to do. > > > > What you want to do is assign a "function reference" to command so > > > that python can execute the function sometime later when you click on > > > the button. A function reference is just the function name without > > > the '()' after it. So you would write: > > > > command = self.Display > > > > But writing it like that doesn't allow *you* to pass any arguments to > > > Display(). In addition, *tkinter* does not pass any arguments to > > > Display when tkinter calls Display in response to a button click. As > > > a result, there is no way to pass an argument to Display. > > > > However, there is another way to cause a function to execute when an > > > event, like a button click, occurs on a widget: you use the widget's > > > bind() function: > > > > my_button.bind('', someFunc) > > > > The first argument tells tkinter what event to respond to. > > > '' is a left click. Check the docs for the different > > > strings that represent the different events that you can respond to. > > > The second argument is a function reference, which once again does not > > > allow you to pass any arguments to the function. However, when you > > > use bind() to attach a function to a widget, tkinter calls the > > > function and passes it one argument: the "event object". The event > > > object contains various pieces of information, and one piece of > > > information it contains is the widget upon which the event occurred, > > > e.g. the button that was clicked. To get the button, you write: > > > > Display(self, event_obj): > > > button = event_obj.widget > > > > Once you have the button, you can get the text on the button: > > > > Display(self, event_obj): > > > button = event_obj.widget > > > text = button.cget("text") > > > > if text=="1": > > > print 1 > > > > Another thing you should be aware of: self is like a class wide > > > bulletin board. If you are writing code inside a class method, and > > > there is data that you want code inside another class method to be > > > able to see, then post the data on the class wide bulletin board, i.e. > > > attach it to self. But in your code, you are doing this: > > > > self.btnDisplay = Button(self, text="7", default=ACTIVE) > > > self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="8", default=ACTIVE) > > > self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > > > As a result, your code continually overwrites self.btnDisplay. That > > > means you aren't preserving the data assigned to self.btnDisplay. > > > Therefore, the data does not need to be posted on the class wide > > > bulletin board for other class methods to see. So just write: > > > > btnDisplay = Button(self, text="7", default=ACTIVE) > > > btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > > > btnDisplay = Button(self, text="8", default=ACTIVE) > > > btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > > > As for the button sizing problem, your buttons are all the same size > > > and line up perfectly on mac os x 10.4.7. > > > wow thank you so much, awesome answer i will get right to fixing this > > now. > > > in regards to the buttonsizes i use windows VISTA and they have > > different sizes. > > one thing i dont rally get, i ahve to add my_button.bind() somewhere? > i changed the stuff u said though and i get this error(the program > executes though and i can press the buttons): > > Exception in Tkinter callback > Traceback (most recent call last): > File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ > return self.func(*args) > TypeError: Display() takes exactly 2 arguments (1 given) > > current version: > #! /usr/bin/env python > from Tkinter import * > import tkMessageBox > > class GUIFramework(Frame): > """This is the GUI""" > > def __init__(self,master=None): > """Initialize yourself""" > > """Initialise the base class""" > Frame.__init__(self,master) > > """Set the Window Title""" > self.master.title("Calculator") > > """Display the main window" > with a little bit of padding""" > self.grid(padx=10,pady=10) > self.CreateWidgets() > > def CreateWidgets(self): > > enText = Entry(self) > enText.grid(row=0, column=0, columnspan=8, padx=5, pady=5) > > enText = Entry(self) > enText.grid(row=1, column=0, columnspan=8, padx=5, pady=5) > > btnDisplay = Button(self, text="1", command=self.Display) > btnDisplay.grid(row=3, column=0, padx=5, pady=5) > > btnDisplay = Button(self, text="2", default=ACTIVE) > btnDisplay.grid(row=3, column=1, padx=5, pady=5) > > btnDisplay = Button(self, text="3", default=ACTIVE) > btnDisplay.grid(row=3, column=2, padx=5, pady=5) > > btnDisplay = Button(self, text="+", default=ACTIVE) > btnDisplay.grid(row=3, column=3, padx=5, pady=5) > > btnDisplay = Button(self, text="4", default=ACTIVE) > btnDisplay.grid(row=4, column=0, padx=5, pady=5) > > self.btnDisplay = Button(self, text="5", default=ACTIVE) > self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) > > btnDisplay = Button(self, text="6", default=ACTIVE) > btnDisplay.grid(row=4,... > > l?s mer ? and the self. i erased, should i do it in the def __init__ as well or only as i did in createwidgets-function? From lscbtfws at gmail.com Sat Apr 26 12:12:11 2008 From: lscbtfws at gmail.com (lscbtfws at gmail.com) Date: Sat, 26 Apr 2008 09:12:11 -0700 (PDT) Subject: dfx audio enhancer crack Message-ID: <44802168-6243-4d37-9221-52247a4f561f@q1g2000prf.googlegroups.com> dfx audio enhancer crack http://cracks.00bp.com F R E E C R A C K S From sjmachin at lexicon.net Sat Apr 19 16:36:49 2008 From: sjmachin at lexicon.net (John Machin) Date: Sat, 19 Apr 2008 20:36:49 GMT Subject: random.random(), random not defined!? In-Reply-To: <2a3931f5-481d-4831-baad-fcc9f0c0c129@m73g2000hsh.googlegroups.com> References: <2a3931f5-481d-4831-baad-fcc9f0c0c129@m73g2000hsh.googlegroups.com> Message-ID: <480a57de@news.mel.dft.com.au> globalrev wrote: > do i need to import something to use random? No, you need to import random From gagsl-py2 at yahoo.com.ar Fri Apr 11 00:05:52 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 11 Apr 2008 01:05:52 -0300 Subject: Module Conflicts References: <1592fad3-996b-4f62-ac12-42aff8272c21@8g2000hsu.googlegroups.com> <773d436c-2216-49ac-8e79-ca89618ac32f@q24g2000prf.googlegroups.com> Message-ID: En Thu, 10 Apr 2008 17:41:29 -0300, Ivan Illarionov escribi?: > On Apr 11, 12:31 am, Ivan Illarionov > wrote: >> On Apr 10, 2:33 am, Jose wrote: >> >> > I have a module named math.py in a package with some class >> > definitions. I am trying to import the standard python math module >> > inside of math.py but It seems to be importing itself. Is there any >> > way around this problem without renaming my math.py file? >> >> Yes, if you are using Python 2.5 >> >> from __future__ import absolute_import >> >> after this `import math` will always import standard math module and >> `from . import math` will import your module. > > And it's relatively easy to do in earlier versions too: > create subdirectory `stdmath` with one `__init__.py` file with one > line `import math` and than use `from stdmath import math`. Ah, thanks, it seems that the idea can be extended to almost all the standard library. Create a directory "stdlib" somewhere on sys.path, with a single file __init__.py containing this single line: __path__.append("path/to/python/standard/lib") Now, `import stdlib.gzip` will import the standard gzip module, even if there is a gzip.py in the current directory or in some other place along sys.path. That is, we have made a package out of the standard library. Unfortunately it doesn't work for math as-is because math is a builtin module (at least on Windows), but this should work for all other "normal" Python-level modules. (It's a hack, and I would never use this on production code, but it may be useful sometimes) -- Gabriel Genellina From sjmachin at lexicon.net Tue Apr 22 17:50:10 2008 From: sjmachin at lexicon.net (John Machin) Date: Tue, 22 Apr 2008 21:50:10 GMT Subject: list manipulation In-Reply-To: References: <78158460-8508-4453-a2dc-c5814dda8839@59g2000hsb.googlegroups.com> Message-ID: <480e5d93$1@news.mel.dft.com.au> Joe Riopel wrote: > On Tue, Apr 22, 2008 at 4:55 PM, DataSmash wrote: >> Hello, >> >> I have a list that looks like this: >> roadList = ["Motorways","Local","Arterial"] >> >> I want to apply some code so that the output looks like this: >> "Motorways;Local;Arterial" >> How can this be done with the LEAST amount of code? > > Not sure if it's LEAST amount of code, or the best, but it works. It's definitely not the least (see below) and it doesn't work -- it puts a ; after the last list item. > >>>> li = ["Motorways","Local","Arterial"] >>>> '\"%s\"' % (''.join(['%s;' % (x,) for x in li]),) > '"Motorways;Local;Arterial;"' That is littered with redundant punctuation. Removing it: >>> '"%s"' % ''.join('%s;' % x for x in li) '"Motorways;Local;Arterial;"' Note: that would need the [] put back for Python < 2.4. But in any case we can further reduce it like this: >>> '"%s;"' % ';'.join(li) '"Motorways;Local;Arterial;"' >>> Now we have minimal, legible code which works on Python back to 2.1 at least and is only one thump of the Delete key away from what the OP asked for. HTH, John From n00m at narod.ru Sat Apr 26 12:15:17 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 09:15:17 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> Message-ID: <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> fgets() from C++ iostream library??? I guess if I'd came up with "Python reads SLOWER than C" I'd get another (not less) smart explanation "why it's so". From andrew at acooke.org Tue Apr 15 05:08:24 2008 From: andrew at acooke.org (andrew cooke) Date: Tue, 15 Apr 2008 02:08:24 -0700 (PDT) Subject: Dynamic use of property() fails References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> <480461f8$0$20282$426a34cc@news.free.fr> Message-ID: OK, fixed my bug - it does work. Now sleep... Thanks again, Andrew From jkn at nicorp.co.uk Wed Apr 2 16:00:53 2008 From: jkn at nicorp.co.uk (Jon Nicoll) Date: Wed, 02 Apr 2008 21:00:53 +0100 Subject: who said python can't be obsfucated!? References: Message-ID: <18WdnajQathueG7anZ2dnUVZ8sninZ2d@plusnet> cokofreedom at gmail.com wrote: > def s(c):return[]if c==[]else s([_ for _ in c[1:]if _ +s([_ for _ in c[1:]if _>=c[0]]) > > Anyone else got some wonders...? looks like one of castironpi's postings... J^n From mal at egenix.com Thu Apr 17 07:33:43 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Thu, 17 Apr 2008 13:33:43 +0200 Subject: Python module for reading FilePro files? In-Reply-To: References: Message-ID: <48073597.9070503@egenix.com> On 2008-04-16 15:53, Steve Bergman wrote: > Does anyone know of a Python package or module to read data files from > the venerable old Filepro crossplatform database/IDE? No, but there is Filepro support in PHP, so you could write a PHP script which reads the data and then exports it to some other database format which can be read by Python. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 17 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From ajaksu at gmail.com Wed Apr 2 16:57:12 2008 From: ajaksu at gmail.com (ajaksu) Date: Wed, 2 Apr 2008 13:57:12 -0700 (PDT) Subject: Recursive function won't compile References: Message-ID: On Apr 2, 5:23?pm, bc1... at googlemail.com wrote: > #include > #include > > def RecursiveFact(n): > ? ? if(n>1): > ? ? ? ? return n*RecursiveFact(n-1) > ? ? else: > ? ? ? ? return 1 > > fact = RecursiveFact(31) > print fact The output is 8222838654177922817725562880000000 and is correct. But the "#include"s tell me you're a bit confused. Have you tried running "python yourscript.py" (where "yourscript.py" is the filename you saved the above program to)? HTH, Daniel From sturlamolden at yahoo.no Sun Apr 20 20:48:09 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sun, 20 Apr 2008 17:48:09 -0700 (PDT) Subject: Nested lists, simple though References: Message-ID: On Apr 21, 2:35 am, sturlamolden wrote: > This also shows how easy it is to boost the performance of Python code > using Cython. We can improve this further by getting rid of the tmp.append attribue lookup: cdef _flatten(lst, append): for elem in lst: if type(elem) != list: append(elem) else: _flatten(elem, append) def flatten(lst): tmp = [] _flatten(lst, tmp.append) return tmp From jcd at unc.edu Fri Apr 18 13:27:10 2008 From: jcd at unc.edu (J. Cliff Dyer) Date: Fri, 18 Apr 2008 13:27:10 -0400 Subject: py3k concerns. An example In-Reply-To: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: <1208539630.5081.17.camel@aalcdl07.lib.unc.edu> On Fri, 2008-04-18 at 08:58 -0700, Aaron Watters wrote: > Why is the migration to py3k a concern? > For example I have libraries which use string%dictionary > substitution where the dictionary is actually an object > which emulates a dictionary. The __getitem__ for > the object can be very expensive and is only called when > needed by the string substitution. > > In py3k string%dictionary is going away. Why? > I have no idea. > > The replacement is a string.format(...) method > which supports dictionary calling. > string.format(**dictionary) > But dictionary > calling doesn't support dictionary emulation. > So in the example below the substitution works > but the call fails. > > === code > > class fdict(dict): > def __getitem__(self, item): > return "got("+item+")" > > def fn(**d): > print d["boogie"] > > if __name__=="__main__": > fd = fdict() > print "attempting string substitution with fake dictionary" > print > print "hello there %(boogie)s" % fd # <-- works > print > print "now attempting function call with fake dictionary" > print > fn(**fd) # <-- fails > > === output > > % python2.6 dtest.py > attempting string substitution with fake dictionary > > hello there got(boogie) > > now attempting function call with fake dictionary > > Traceback (most recent call last): > File "dtest.py", line 17, in > fn(**fd) > File "dtest.py", line 7, in fn > print d["boogie"] > KeyError: 'boogie' > > ==== end of output > > Consequently there is no simple way to translate > my code, I think. I suspect you will find this kind of subtle > issue in many places. Or worse, you won't find it > until after your program has been installed > in production. > > It's a damn shame because > if string%dict was just left in it wouldn't be an issue. > > Also, if making f(**d) support dict emulation > has any negative performance implications > then I don't want it please. > > sigh. -- Aaron Watters > > === > http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=crack+open > I was with you on this issue right up until that last paragraph. You want it, but only if its free. That's ridiculous. Every thing a computer does requires processor cycles. Do you really mean to tell me that string interpolation has been a major bottleneck for you? Now I think you're just whining because you like to hear yourself whine. Try coming up with a real standard for evaluation. How much of a performance hit will actually cause you trouble? 1% extra on string interpolation? 10%? 50%? 200%? You do provide a link to a website called xfeedme.com. And I just fed you. IHBT. HAND. :-/ -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill From martin at v.loewis.de Sun Apr 27 13:33:56 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 27 Apr 2008 19:33:56 +0200 Subject: Tremendous slowdown due to garbage collection In-Reply-To: References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: <4814B904.1070804@v.loewis.de> > Martin said it but nevertheless it might not be true. > > We observed similar very bad behaviour -- in a Web application server. > Apparently, the standard behaviour is far from optimal when the > system contains a large number of objects and occationally, large > numbers of objects are created in a short time. > We have seen such behaviour during parsing of larger XML documents, for > example (in our Web application). I don't want to claim that the *algorithm* works for all typically applications well. I just claim that the *parameters* of it are fine. The OP originally proposed to change the parameters, making garbage collection run less frequently. This would a) have bad consequences in terms of memory consumption on programs that do have allocation spikes, and b) have no effect on the asymptotic complexity of the algorithm in the case discussed. It may well be that other algorithms would perform better, but none have been contributed. Regards, Martin From kyosohma at gmail.com Fri Apr 25 09:17:56 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 25 Apr 2008 06:17:56 -0700 (PDT) Subject: Environment Variables References: Message-ID: On Apr 25, 8:07?am, Krishna wrote: > Environment variable set up is the most confusing part for me all the > time. Please help me with the following questions: > > When I install python in a new system, I will go to environment > variables (system variables) and set "path" pointing to C:\Python25 > and thats all I do. > I type python from "cmd" window and its converting to python window > for python execution. All fine up to this point. > Now, I want to drag and drop python (.py) files to this window and > execute it. My python files are located in different directories > inside C: and outside C:. When I do that, I get errors and the file is > not found and its not imported. ALso, inside the .py file, if I have a > command to open a different file, it doesnt see that either. How do I > overcome these basic difficulties in python. I wish I can open any > file and work on that using python. > > Thanks for your help! > Krishna I'm pretty sure you can't do that in a command window. I tried it on my Windows XP machine and all I get in my instance of IDLE is the path to the file. It DOES work with PythonWin, which is the ActiveState version of Python. The only difference is that it include the win32 modules and has a more advanced editor. You can probably get this to work in other more advanced editors, like WingIDE or PyDev too. Mike From gillet at scripps.edu Thu Apr 24 21:05:58 2008 From: gillet at scripps.edu (Alexandre Gillet) Date: Thu, 24 Apr 2008 18:05:58 -0700 Subject: Problem building python in virtual machine running centos Message-ID: <1209085558.20290.3.camel@solomon> Hi, I am trying to build python-2.4.5 on Centos 5.1, which is a virtual machine running with xen. I am not able to build python. The compilation crash with the following: gcc -pthread -c -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -o Objects/unicodeobject.o Objects/unicodeobject.c In file included from ./Include/Python.h:76, from Objects/unicodeobject.c:39: ./Include/object.h:228: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See for instructions. The bug is not reproducible, so it is likely a hardware or OS problem. Any suggestion of what am I doing wrong? Thanks Alex -- o Alexandre Gillet Ph.D. email: gillet at scripps.edu / The Scripps Research Institute, o Dept. Molecular Biology, MB-5, \ 10550 North Torrey Pines Road, o La Jolla, CA 92037-1000, USA. / tel: (858) 784-2053 o fax: (858) 784-2860 web: http://mgl.scripps.edu/projects/tangible_models/ From mitko at qlogic.com Mon Apr 21 20:00:16 2008 From: mitko at qlogic.com (Mitko Haralanov) Date: Mon, 21 Apr 2008 17:00:16 -0700 Subject: Segfault accessing dictionary in C Python module Message-ID: <20080421170016.6d6fb378@hematite.mv.qlogic.com> I have a Python module that I have written using the C API and I am having a problem accessing a dictionary from that module. Here is what I have done: 1. In my init function I call module = Py_InitModule ("name", methods); 2. then I get the module's __dict__ structure: dict = PyModule_GetDict (module); 3. Later, I insert a dictionary that I have constructed using the PyDict_* API new_dict = PyDict_New (); PyDict_SetItemString (dict, "dict_name", new_dict); Here is the problem: In one of my methods, I need to retrieve the new_dict dictionary and use it to get a value out of it. I get the dictionary using the PyObject_GetAttrString function: new_dict = PyObject_GetAttrString (module, "dict_name"); (module is a global variable for the file) I make the key from an int with: key = PyInt_FromLong (state); (where state is an int variable) and then get the value for that key: value = PyDict_GetItem (new_dict, key); The problem is that for the first few times I call the function, everything work but after that value (which should contain a PyString) starts getting random values and eventually my program crashes with a segfault. When I try to print the address of the dict variable returned by PyObject_GetAttrString() I always get the same value, so the function is returning the same thing. However, when I try to print the string representation of the return value with this: obj = PyObject_Str (new_dict); if (PyString_Check (obj)) printf ("%s\n", PyString_AsString (obj)); it works the first few calls and then my program segfaults at the PyObject_Str (new_dict) call. As far as I know, I have done everything by the book yet I can't seem to figure out where the problem is. Any help would be great? Thank you -- Mitko Haralanov mitko at qlogic.com Senior Software Engineer 650.934.8064 HSG InfiniBand Engineering http://www.qlogic.com ========================================== There are never any bugs you haven't found yet. From gagsl-py2 at yahoo.com.ar Wed Apr 16 01:43:07 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 02:43:07 -0300 Subject: tkinter, event.widget, what do i get? References: <7caa5089-2ea9-4e18-9117-7431d7403976@l42g2000hsc.googlegroups.com> <3a6f6d87-0102-4995-a033-501137b3f934@s50g2000hsb.googlegroups.com> Message-ID: En Tue, 15 Apr 2008 20:45:24 -0300, escribi?: > On 16 Apr, 00:24, "Gabriel Genellina" wrote: >> En Tue, 15 Apr 2008 17:45:08 -0300, escribi?: >> >> > when calling function hmm here, what do i get? the widget i clicked >> > on? >> > if i have a canvs on wich i have a bitmap and i click on the bitmap, >> > is the event.widget then the bitmap? >> > can i get info about the bitmap then? like color of the pixel i >> > clicked. if so, how? >> >> > w.bind("", key) >> > w.bind("", hmm) >> >> > def hmm(event): >> > return event.widget >> >> Why don't you try by yourself? You can use: print repr(something) > > i get > > thing is i get that even though i click outside the image. So you answered your first question yourself: event.widget is the canvas, not the bitmap. On another thread you get the other answer. > and what can i do with this number anyway? With that specific number, nothing. The whole text says two things: - *what* the object is: a Tkinter.Canvas instance - *which* one: this is not the same one as -- Gabriel Genellina From castironpi at gmail.com Wed Apr 2 13:08:29 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 2 Apr 2008 10:08:29 -0700 (PDT) Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> Message-ID: On Apr 2, 11:41?am, "Dan Upton" wrote: > > ?The thing I've been wondering is why _is_ it read-only? In what > > ?circumstances having write access to co_code would break the language > > ?or do some other nasty stuff? > > > ?Jo?o Neves > > I can't speak to Python's implementation in particular, but > self-modifying code in general is unpleasant. ?It certainly is > possible to support it in runtime environments, but it's usually not > easy to do so. ?That is, of course, somewhat dependent on the > implementation of the runtime environment, and even to some degree the > underlying hardware. ?(For instance, the compiled code you want to run > could be in the hardware cache; if you then change the instructions at > those addresses in memory, it's not always straightforward to get the > processor to realize it needs to load the new data into the > instruction cache.) ?Plus, I suppose it might be possible to break > strong (even dynamic) typing if you start changing the code around > (although I can't construct an example off the top of my head). > > In short, you need a good reason to support self-modifying code, and > my guess is nobody could come up with one for Python. > > -dan Not in the least. You can avoid a lot of if statements, if you have so many, by enumerating functions to call. "Then call this", i.e. turn functions on and off. However, there may be data structures which can accomplish this in constant time too... any takers? From basilisk96 at gmail.com Tue Apr 1 17:57:57 2008 From: basilisk96 at gmail.com (Basilisk96) Date: Tue, 1 Apr 2008 14:57:57 -0700 (PDT) Subject: Is this a good time to start learning python? References: <47f1140e$0$735$a729d347@news.telepac.pt> Message-ID: On Mar 31, 11:40 am, Rui Maciel wrote: > Recently I woke up inclined to take up the task of learning another > programming language. I've already dipped my toes in Perl (I've read online > tutorials and wrote a couple of irrelevant pet projects) but, as the > computers at my workplace only sport the python interpreter, it probably > means that learning python will end up serving me better, at least in the > short run. Plus, you know how Perl goes. > > So far the decision seems to be a no brainer. Yet, Python 3000 will arrive > in a few months. As it isn't backwards compatible with today's Python, > there is the risk that no matter what I learn until then, I will end up > having to re-learn at least a considerable part of the language. To put it > in other words, I fear that I will be wasting my time. > > At least that is what a clueless newbie believes. As this group is > frequented by people who have more insight into all things pythonesque, > what are your thoughts on this? > > Thanks for the help > Rui Maciel Think of it this way - A.) If you start learning Python 2.5 *today*, and then Python3k comes out in a few months and (at worst) breaks all your code, you will still have less code to patch than the person who learned Python 2.3 two years ago :) B.) If you start learning Python 2.5 *tomorrow*... who knows, we might not be alive tomorrow. Seize the day. Seriously, I have watched Guido's GoogleTalk on Py3k plans, and the changes are not all that scary. I'm looking forward to it. Cheers, -Basilisk96 From sam at mas.pl Thu Apr 3 04:20:48 2008 From: sam at mas.pl (sam) Date: Thu, 03 Apr 2008 10:20:48 +0200 Subject: Prototype OO In-Reply-To: References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> Message-ID: Gabriel Genellina napisa?(a): >> Yes. Funciton is always a piece of code (program) that does something. >> There is >> no need for different syntax. > > Guido has regretted lambda for a long time; it was scheduled for > deletion on Python 3000 [2] but finally will stay [3]. Thanks for that info and links. > Class methods and instance methods are not just standard functions; > instance methods were plain functions before 2.2 and the Class object > was in charge of doing the "self magic". Now the descriptor protocol > provides far more possibilities. Actually I don't know what is "descriptor protocol", so maybe I should have finished discussing. I will aslo search for "self magic" -- some pieces of old code, or something. > I didn't say that (note that you trimmed most attribution lines) but I > like to have "short anonymous functions" altough the syntax might be > different. Perhaps in Python 4000. And I say "syntax should be the same". These are only opinions, so forgive me for wasting your time. From hdante at gmail.com Fri Apr 25 23:04:32 2008 From: hdante at gmail.com (hdante) Date: Fri, 25 Apr 2008 20:04:32 -0700 (PDT) Subject: problem with mmap References: Message-ID: <316a2265-4328-4443-a622-fda37ada52e9@e39g2000hsf.googlegroups.com> On Apr 25, 4:43?pm, Carl Banks wrote: > On Apr 25, 9:37 am, Neal Becker wrote: > > > On linux, I don't understand why: > > > f = open ('/dev/eos', 'rw') > > m = mmap.mmap(f.fileno(), 1000000, prot=mmap.PROT_READ|mmap.PROT_WRITE, > > flags=mmap.MAP_SHARED) > > > gives 'permission denied', > > Try > > f = open('/dev/eos', 'r+') > > Carl Banks The equivalent code in python should be: import os, mmap f = os.open('/dev/eos', os.O_RDWR) m = mmap.mmap(f, 1000000, prot=mmap.PROT_READ|mmap.PROT_WRITE, flags=mmap.MAP_SHARED) That should work like the C++ code. From noah at noah.org Wed Apr 9 16:11:02 2008 From: noah at noah.org (Noah) Date: Wed, 9 Apr 2008 13:11:02 -0700 (PDT) Subject: Control process execution References: <1d1bbea2-a503-4db5-bd3f-c45c29916b9c@13g2000hsb.googlegroups.com> Message-ID: On Apr 6, 5:30 am, Wesley Mesquita wrote: > I am trying to create a test environment to a couple C applications > (simple UDP and TCP server/clients), so I want to write this in python > and I m looking for ways to do it. Basically I need an execution timer > and timeout control (to kill the apps in certain situations). Looking > at google, I found the Pexpect package, but I m a little bit lost in > using it. Pexpect might be good. But if you are just looking at running an application without talking to it interactively then you might be able to just get by with os.process. -- Noah From n00m at narod.ru Sat Apr 26 21:43:48 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 18:43:48 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <54dc008c-a747-4507-a2d5-9b4ddccbd5b9@e53g2000hsa.googlegroups.com> Message-ID: <3a7541ae-8aa2-46d5-93a3-115f9e2a3c38@l42g2000hsc.googlegroups.com> I'm there since summer 2004 :) (with several time breaks) From skanemupp at yahoo.se Thu Apr 10 08:35:23 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 05:35:23 -0700 (PDT) Subject: tkinter, overwrite Label-text? Message-ID: using python And tkinter. i have a GUI that outputs a text among other things. after input form user i want this text to be *)cleared and/or *)overwritten. what is the best way to achieve that? also, how do i make Label-text expand to the right and not to the left? From steve at holdenweb.com Wed Apr 9 11:10:47 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 11:10:47 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> Message-ID: <47FCDC77.7030407@holdenweb.com> Victor Subervi wrote: > On Wed, Apr 9, 2008 at 10:24 AM, Steve Holden > wrote: > > Victor Subervi wrote: > > On Wed, Apr 9, 2008 at 1:14 AM, Gabriel Genellina > > > >> wrote: > > > > Now all you have to do is what I told you in the first place, which is > to remove the print statements before and after "print content". > > > That is what I figured after I sent the email. However, I had tried that > with a test script and the working script, with bad results. Here is the > test script that should have worked flawlessly: > > #! /usr/bin/python > > import MySQLdb > > print "Content-type: image/jpeg\r\n" > host = 'host' > db = 'bre' > user = 'user' > passwd = 'pass' > connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > cursor = connection.cursor() > cursor.execute('select img from photo where id="7";') > content = cursor.fetchall() Bzzt! Nope. Cursor.fetchall() returns a list (length 1) or tuples (length 1) here, so this should be content = cursor.fetchall()[0][0] or, perhaps better content = cursor.fetchone()[0] > print "Content-Type: image/jpeg\nContent-Length: %d\n" % len(content) > print content > connection.commit() The line above is completely unnecessary if the database has not been changed. > connection.close() > > This prints out the URL as an image! No idea why. But it does not > produce the desired image. > I've no idea why either, but try fixing the script and see what that does. > The following is the heart of the script for display. I tried entering > the Content-type where indicated, but it produces everything up to the > image, then produces the result of code from the exception... > > cursor.execute('select id from products where category="' + category > + '" order by sort_factor desc, price desc;') > ids = cursor.fetchall() > if len(ids[0]) != 0: > for id in ids: > for d in id: > print '\n' > cursor.execute('select * from products where id = ' + str(d) + > ';') > col_fields = cursor.fetchall() > if lang == 'es': > print 'ID: ', col_fields[0][0], '
' > print 'Nombre: ', col_fields[0][2], '
' > print 'T?tulo: ', col_fields[0][6], '
' > print 'Descripci?n: ', col_fields[0][9], '
' > print 'Precio: ', col_fields[0][11], '
' > print 'Rec?maras: ', col_fields[0][12], '
' > print 'Ba?os: ', col_fields[0][13], '
' > content = col_fields[0][14].tostring() > print "Content-Type: image/jpeg\nContent-Length: %d\n" % > len(content) > print content, '

' You really don't understand how the web works, do you? In order to include an image in a page your browser must make TWO requests. The first is for an HTML page that will reference the image in this way: Seeing this img tag causes the browser to make a SECOND request, which the script I corrected above should respond to with an image. The bytestream is critical in the image response. Even one misplaced byte will mess things up terribly. > ... > except: > if lang == 'es': > print 'Lo siento. Todav?a no tenemos propiedades para ense?arse en > la categor?a de ', category, '.\n

' > > > > You are NOT generating HTML, you are generating a JPEG image. > > > I am producing both, and this is causing me confusion. Read an explanation of HTML and images if my brief treatise above was insufficient. > BTW, when we are finally done with this, I will write a nice how-to > (since there is not one in python, while php has some nice ones) on how > to do this, and give you and Gabrielle all your due credit. I will post > it to this list, because that is sure to rank highly in google right away. > Victor > That's great, though hardly the point of the exercise. I think Google already know about Gabriel (*not* Gabrielle) and me already ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From castironpi at gmail.com Wed Apr 23 16:55:20 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 23 Apr 2008 13:55:20 -0700 (PDT) Subject: Partition list with predicate References: <925822270804230959v557ec5f5re02737709f94d3c6@mail.gmail.com> Message-ID: On Apr 23, 2:26?pm, Steve Holden wrote: > Terry Reedy wrote: > > "Jared Grubb" wrote in message > >news:925822270804230959v557ec5f5re02737709f94d3c6 at mail.gmail.com... > > | I want a function that removes values from a list if a predicate > > evaluates > > | to True. > > > Forget the rigamarole you posted, which has several defects. > > If you must modify the list in place, because you have multiple references > > to it: > > > lst[:] = filter(lambda x: not pred(x), lst) > > Wouldn't > > lst[:] = [x for x in lst if not pred(x)] > > be more direct? > > > Otherwise, just lst = filter(....) > > And similarly > > lst = [x for x in lst if not pred(x)] > > regards > ? Steve > -- > Steve Holden ? ? ? ?+1 571 484 6266 ? +1 800 494 3119 > Holden Web LLC ? ? ? ? ? ? ?http://www.holdenweb.com/ And, actually, if you aren't using the GIL, immutables historically come with locks, which carries concerns with reality (spatialty +localty), i.e. money, if your technique gains from computer speed, but there's a right one for a market nitch. It could be that computers are doing all they can for everybody's public's good, so if so, every alternative will be profitable recreationally only. No reason you can't write a mutable structure that supports multiple references and keep it off the hard drive, but without defining Clear( time0, b ) + Set( time0, b ), you can't beat macrolocks without micros. And of course, neither RAM nor magnetics offer stereo (two-dimensional +) seek mechanisms today. But we'll be allocating squares of memory eventually. All technologies are inevitable. From balta96428 at gmail.com Wed Apr 23 05:53:20 2008 From: balta96428 at gmail.com (balta96428 at gmail.com) Date: Wed, 23 Apr 2008 02:53:20 -0700 (PDT) Subject: vala's pumpkin patch Message-ID: <0878f546-bdb4-4b99-ac45-d34ea0c6c836@z72g2000hsb.googlegroups.com> vala's pumpkin patch http://cracks.12w.net F R E E C R A C K S From dieter at handshake.de Sun Apr 27 13:15:58 2008 From: dieter at handshake.de (Dieter Maurer) Date: 27 Apr 2008 19:15:58 +0200 Subject: Tremendous slowdown due to garbage collection In-Reply-To: References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: Christian Heimes writes on Sat, 12 Apr 2008 18:47:32 +0200: > andreas.eisele at gmail.com schrieb: > > which made me suggest to use these as defaults, but then > > Martin v. L?wis wrote that > > > >> No, the defaults are correct for typical applications. > > > > At that point I felt lost and as the general wish in that thread was > > to move > > discussion to comp.lang.python, I brought it up here, in a modified > > and simplified form. > > Martin said that the default settings for the cyclic gc works for most > people. Your test case has found a pathologic corner case which is *not* > typical for common application but typical for an artificial benchmark. > Python is optimized for regular apps, not for benchmark (like some video > drivers). Martin said it but nevertheless it might not be true. We observed similar very bad behaviour -- in a Web application server. Apparently, the standard behaviour is far from optimal when the system contains a large number of objects and occationally, large numbers of objects are created in a short time. We have seen such behaviour during parsing of larger XML documents, for example (in our Web application). Dieter From sn at sncs.se Mon Apr 14 21:38:30 2008 From: sn at sncs.se (Sverker Nilsson) Date: Mon, 14 Apr 2008 18:38:30 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> Message-ID: <61bbc2b5-d3cf-4791-a7c6-d642878c41d4@b64g2000hsa.googlegroups.com> On Apr 15, 2:58 am, ajaksu wrote: > On Apr 14, 8:10 pm, Sverker Nilsson wrote:> do i dare to open a thread about this? > > Yeah, you sure do! > > > come on you braver men > > Yeah! > > > we are at least not bought by g***le > > Hell no! > > > but why? others have said it so many times i think > > Huh?! > > > :-//// > > ?! Whatever! > > > but why? a few syntactic 'cleanups' for the cost of a huge rewrite of > > all the code that have been builtup from all the beginning when the > > once great Python came along and people began to use it and write code > > for it. Like all that code would have to be rewritten. blaah. > > Yeah! Woo-hoo! > Wait... What? No, no, you got it all wrong. Python developers are > being extra-careful and doing a lot of hard work to keep things sane, > allow easy migration, etc. > > > and i have perhaps been drinking but i have been p**d all week since i > > began look into this:-( > > Ah, OK, calm down and look again. Things are way better than you > think, but there is a lot of FUD going on too, so focus on serious, > reliable reports. > > Cheers, > Daniel I was serious! It's just from my right brain half. I take it you are ironic, I appreciate it, hope we will hear from some Director..... doesnt matter perhapss I said what I said, now I am just trollin or trying How do one troll best? I know but I can also sell you Rolexes for a good price... S-- And what should I say? Perhaps that the debate on the the py3k list is ---- I cant find the word because i am swedish, but it is just that most people or some are so concerned about they having 'commit- privileges' that the don't dare say anything contoversial that would go against mr. GVR. so this is a much freer forum.Not that I am more intelligent than GVR but we can at least debate, though I doubt he has the time:-) So, regrds to all and hope you guys want to continut the debate... Sverker From spe.stani.be at gmail.com Mon Apr 7 09:20:32 2008 From: spe.stani.be at gmail.com (SPE - Stani's Python Editor) Date: Mon, 7 Apr 2008 06:20:32 -0700 (PDT) Subject: Wxpython. Is it possible to change layout in a running application? Selfmade listbox References: <716c0f27-bca6-4642-a8ec-cdbb0b23e6e8@h1g2000prh.googlegroups.com> <105355bb-2d56-491e-8764-e4c34a0de8c5@d45g2000hsc.googlegroups.com> Message-ID: On Apr 7, 2:54?pm, Mike Driscoll wrote: > On Apr 7, 6:50 am, Soren wrote: > > Hi, > > > Id like to make my own special listbox.. I want to able (at the push > > of a button) to add another item to my special listbox... each item is > > a panel with a label, some buttons and maybe a text control. > > > I've tried adding a new panel object with the stuff i want to the > > sizer i'm using for my listbox (which is a panel which can contain > > other panels)... and then run update() and refresh() on everything... > > But it doesn't work.. i see a panel appearing, but it's just a small > > square in the corner of my "listbox" panel, and it only works the > > first time... nothing new appears when I push the button again. > > > Is it at all possible to do this? Has anyone created something > > similar? Does anyone know what i'm doing wrong? To remove any doubt, yes this is possible. I guess you forgot to call the Layout method of the sizer (only update or refresh won't help). > Also, you will probably receive more help at the wxPython specific > list, found here: > > http://wxpython.org/maillist.php That is indeed the best list for wxpython related issues. Good luck, Stani -- Phatch - Photo Batch Processor - http://photobatch.stani.be SPE - Python Editor - http://pythonide.stani.be From bearophileHUGS at lycos.com Wed Apr 9 09:46:52 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Wed, 9 Apr 2008 06:46:52 -0700 (PDT) Subject: Basic optimization of python. References: Message-ID: ShenLei: > t = self.a.b > t.c = ... > t.d = ... > .vs. > self.a.b.c = ... > self.a.b.d = ... > which one is more effective? Since each dot invokes a hash table lookup, it > may be time consuming. If the compiler can do expression folding, then no > manual folding is needed. Removing dots creating a temporary variable speeds up the program, but doing it is useful only in special critical spots, like inside certain large loops, etc. A similar optimization is to use a local instead of a global: from foo import bar def baz(bar=bar): for i in xrange(100000): bar(...) Note that with psyco you often don't need such things. Bye, bearophile From steveo at syslang.net Tue Apr 8 11:31:21 2008 From: steveo at syslang.net (Steven W. Orr) Date: Tue, 8 Apr 2008 11:31:21 -0400 (EDT) Subject: wxPython scrolling question. Message-ID: I just discovered Accelerator entries so my wx app is now able to exit by typing Ctrl-Q. Can someone please tell me what to use to cause a pane to scroll up and down using the middle mouse scroll roller thingy? I looked and found wxCURSOR_MIDDLE_BUTTON but I suspect that's only good for clicking with the middle mouse button. I also found something called WXK_SCROLL, but how do I tell which direction the scroll is going? TIA -- Time flies like the wind. Fruit flies like a banana. Stranger things have .0. happened but none stranger than this. Does your driver's license say Organ ..0 Donor?Black holes are where God divided by zero. Listen to me! We are all- 000 individuals! What if this weren't a hypothetical question? steveo at syslang.net From steve at holdenweb.com Wed Apr 9 11:50:36 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 11:50:36 -0400 Subject: Trouble with list comprehension In-Reply-To: <4c3db5c00804090830p1b05748drf4ee5b8c3185ad9e@mail.gmail.com> References: <4c3db5c00804090830p1b05748drf4ee5b8c3185ad9e@mail.gmail.com> Message-ID: Shane Lillie wrote: > I've got a bit of code that looks like this: > > for i in xrange(1000): > # shuffle the doors > doors = [ 'G', 'C', 'G' ] > random.shuffle(doors) > > # save the doors that have goats (by index) > goats = [ x for x in range(2) if doors[x] == 'G' ] > > but for some reason the list comprehension is not always returning a > list with 2 elements in it (sometimes it will be just 1 element). I've > tried changing to a generator as well as using filter() and all 3 give > the same sort of results. It works if I use a loop, but I'd really > like to know what I'm doing wrong here. Everything looks like it > should be working. > > Thanks in advance for any suggestions. Hint: len(range(2)) != 3 regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From marek.rocki at wp.pl Sun Apr 6 15:54:50 2008 From: marek.rocki at wp.pl (marek.rocki at wp.pl) Date: Sun, 6 Apr 2008 12:54:50 -0700 (PDT) Subject: Form sha1.hexdigest to sha1.digest References: <7c39af89-9cee-428c-a0bc-8202700c5aec@b1g2000hsg.googlegroups.com> <47F8CF66.1020805@v.loewis.de> Message-ID: Martin v. L?wis napisa?(a): > > How can convert string from sha1.hexdigest() to string that is the > > same, like from sha1.digest() > > Use binascii.unhexlify. > > HTH, > Martin Or hexdigest_string.decode('hex') From needin4mation at gmail.com Wed Apr 9 17:03:30 2008 From: needin4mation at gmail.com (jmDesktop) Date: Wed, 9 Apr 2008 14:03:30 -0700 (PDT) Subject: basic python question about for loop References: Message-ID: On Apr 9, 4:59?pm, "Reedick, Andrew" wrote: > > -----Original Message----- > > From: python-list-bounces+jr9445=att.... at python.org [mailto:python- > > list-bounces+jr9445=att.... at python.org] On Behalf Of jmDesktop > > Sent: Wednesday, April 09, 2008 4:51 PM > > To: python-l... at python.org > > Subject: basic python question about for loop > > > >From the Python.org tutorial: > > > >>> for n in range(2, 10): > > ... ? ? for x in range(2, n): > > ... ? ? ? ? if n % x == 0: > > ... ? ? ? ? ? ? print n, 'equals', x, '*', n/x > > ... ? ? ? ? ? ? break > > ... ? ? else: > > ... ? ? ? ? # loop fell through without finding a factor > > ... ? ? ? ? print n, 'is a prime number' > > ... > > 2 is a prime number > > 3 is a prime number > > 4 equals 2 * 2 > > 5 is a prime number > > 6 equals 2 * 3 > > 7 is a prime number > > 8 equals 2 * 4 > > 9 equals 3 * 3 > > > first time 2 mod 2, 2/2, no remainder == 0, what am I doing wrong? > > Why did it fall through? > > a) 2 is prime, so nothing is wrong. > > b) Range isn't doing what you think it's doing: > > >>> print range(2,2) > [] > >>> print range(2,3) > [2] > >>> print range(2,4) > [2, 3] > >>> print range(2,5) > > [2, 3, 4] > > > > >>> print range(1,1) > [] > >>> print range(1,2) > [1] > >>> print range(1,3) > [1, 2] > > ***** > > The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA622- Hide quoted text - > > - Show quoted text - So what is n and x in the first iteration? Sorry. I'm trying. From tjreedy at udel.edu Wed Apr 9 17:40:14 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 9 Apr 2008 17:40:14 -0400 Subject: basic python question about for loop References: Message-ID: |So what is n and x in the first iteration? Sorry. I'm trying. When n == 2, the inner loop executes 0 times (the length of range(2,n)) and then falls thru to the else clause, printing the correct answer. From mranjan at varshyl.com Tue Apr 22 22:50:25 2008 From: mranjan at varshyl.com (mranjan at varshyl.com) Date: Tue, 22 Apr 2008 22:50:25 -0400 Subject: about python Message-ID: <12826269.63521208919025392.JavaMail.servlet@perfora> How can python execute in browser? Mukul From sturlamolden at yahoo.no Thu Apr 24 23:50:52 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 20:50:52 -0700 (PDT) Subject: ctypes: return a pointer to a struct References: <846077c3-beaf-4ccd-83be-1e2168c4f7fe@c65g2000hsa.googlegroups.com> <4dda2bd7-3348-496e-a594-35da0a34d4de@x35g2000hsb.googlegroups.com> Message-ID: <0cfc062c-f83e-46ab-b215-3372258422ff@k37g2000hsf.googlegroups.com> On Apr 25, 5:39 am, "Jack" wrote: > IP2Location_get_all.restype = POINTER(IP2LocationRecord) > IP2LocationObj = IP2Location_open(thisdir + '/IP-COUNTRY-SAMPLE.BIN') > rec = IP2Location_get_all(IP2LocationObj, '64.233.167.99') > print rec.country_short print rec.contents.country_short From bwljgbwn at gmail.com Tue Apr 22 05:49:51 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:49:51 -0700 (PDT) Subject: evra patch Message-ID: evra patch http://cracks.12w.net F R E E C R A C K S From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 25 10:56:43 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 25 Apr 2008 16:56:43 +0200 Subject: Class Inheritance - What am I doing wrong? In-Reply-To: <613bc152-a6f4-4db4-8f90-593cb3f629c7@s33g2000pri.googlegroups.com> References: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> <613bc152-a6f4-4db4-8f90-593cb3f629c7@s33g2000pri.googlegroups.com> Message-ID: <4811f129$0$23023$426a34cc@news.free.fr> Brian Munroe a ?crit : > Ok, so thanks everyone for the helpful hints. That *was* a typo on my > part (should've been super(B...) not super(A..), but I digress) > > I'm building a public API. Along with the API I have a few custom > types that I'm expecting API users to extend, if they need too. If I > don't use name mangling, isn't that considered bad practice (read not > defensive programming) to not protect those 'private' fields? There would be a lot to say about whether defensive programming is a good practice or not. At least in the context of hi-level languages with exception handling and automatic memory management. Anyway: - there's just no way to make anything truly "private" in Python - the convention is that attributes (including methods - they are attributes too) whose name starts with a single leading underscore are implementation stuff and should not be messed with. IOW, the contract is "mess with them and you're on your own". - name mangling is only useful when you really need to make sure an implementation attribute won't be *accidentally* shadowed. These attributes should only be used by methods that are not themselves supposed to be overridden or extended by user code. FWIW, I must have used them less than half a dozen times in 7+ years (and I wrote more than a couple mini-frameworks, with lot of black-juju metaclasses and custom descriptors magic in them). So just use single-leading-underscore for implementation attributes, and document what the users are supposed to extend and what they're supposed to leave alone. My 2 cents. From hniksic at xemacs.org Tue Apr 29 10:41:35 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Tue, 29 Apr 2008 16:41:35 +0200 Subject: Issue with regular expressions References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Message-ID: <87prs83eqo.fsf@mulj.homelinux.net> Julien writes: > I'm fairly new in Python and I haven't used the regular expressions > enough to be able to achieve what I want. > I'd like to select terms in a string, so I can then do a search in my > database. > > query = ' " some words" with and "without quotes " ' > p = re.compile(magic_regular_expression) $ <--- the magic happens > m = p.match(query) I don't think you can achieve this with a single regular expression. Your best bet is to use p.findall() to find all plausible matches, and then rework them a bit. For example: p = re.compile(r'"[^"]*"|[\S]+') p.findall(query) ['" some words"', 'with', 'and', '"without quotes "'] At that point, you can easily iterate through the list and remove the quotes and excess whitespace. From python at bdurham.com Mon Apr 21 16:22:41 2008 From: python at bdurham.com (python at bdurham.com) Date: Mon, 21 Apr 2008 16:22:41 -0400 Subject: List of all Python's ____ ? Message-ID: <1208809361.28412.1249098609@webmail.messagingengine.com> Is there an official list of all Python's ____? I'm learning Python and trying to get an idea of what ____ are available and specifically, what ____ are used by each native Python data type? Thanks! Malcolm From hobgoodoreneyhb at gmail.com Tue Apr 22 11:42:54 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:42:54 -0700 (PDT) Subject: symptoms of crack addiction Message-ID: <2c18a1ab-8748-4363-8309-ca582030fa47@a23g2000hsc.googlegroups.com> symptoms of crack addiction http://cracks.12w.net F R E E C R A C K S From andrei.avk at gmail.com Thu Apr 3 14:33:03 2008 From: andrei.avk at gmail.com (AK) Date: Thu, 03 Apr 2008 13:33:03 -0500 Subject: Python-by-example - new online guide to Python Standard Library In-Reply-To: <47f2d018$0$6517$4c368faf@roadrunner.com> References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: <47f514c5$0$6520$4c368faf@roadrunner.com> AK wrote: > Hello, > > I find that I learn easier when I go from specific examples to a more > general explanation of function's utility and I made a reference guide > that will eventually document all functions, classes and methods in > Python's Standard Library. For now, I covered about 20 most important > modules. I will be adding more modules and eventually I'll cover > everything. Here's my progress so far, let me know if this is useful; > I'll be glad to hear comments/suggestions/etc: > > http://www.lightbird.net/py-by-example/ > I uploaded an updated site incorporating most of the suggestions I received and fixing some errors along the way. I will be adding more examples to modules that are already covered and will try to add more modules during the following week. Thanks again to all who posted advice and comments! -- -ak Tobu | http://www.lightbird.net/tobu/ | Freeform DB / Tagger / PIM Python-by-Example | http://www.lightbird.net/py-by-example/ | Guide to LibRef From theller at python.net Wed Apr 30 03:14:12 2008 From: theller at python.net (Thomas Heller) Date: Wed, 30 Apr 2008 09:14:12 +0200 Subject: py2exe Icon Resources In-Reply-To: <40c03afe-b2c5-4793-b7c3-f5a97360fe6c@a23g2000hsc.googlegroups.com> References: <40c03afe-b2c5-4793-b7c3-f5a97360fe6c@a23g2000hsc.googlegroups.com> Message-ID: <67qki0F2nqiddU1@mid.individual.net> flarefight at googlemail.com schrieb: > I have created an app using python and then converting it to an exe > using py2exe, and have the following code: > > "icon_resources": [(1, "appFavicon.ico"), (2, "dataFavicon.ico")] > > in my py2exe setup file, the appFavicon works fine and it sets that as > the app icon thats fine, but the program creates data files (like > documents) and i wanted them to have a different icon... > > I package my apps using Inno Setup 5, and it registers the file type > fine so that it loads on double click, what i cant do is set the icon > for the file. > > as you can see i have packaged two different icons with py2exe but > when i set DefaultIcon in the registry to "C:\pathtoapp\myapp.exe,2" > it doesnt work, nor does it work with a 1 or a %1 or indeed with > passing a path to the icon itself, nothing seems to work!! > > how do you access the other icons generated from py2exe, or how do you > set the registry up so that i looks for the icon correctly, > There was a problem in the icon resources code in py2exe which was recently fixed in CVS but there is not yet a binary release of this code. Maybe it solves your problem... Thomas From billingspanshism at gmail.com Sat Apr 19 17:18:23 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:18:23 -0700 (PDT) Subject: victoria beckham 2007 Message-ID: <48784072-cba2-4a4e-93ab-ee8d6bda64c3@f36g2000hsa.googlegroups.com> Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From bruno.desthuilliers at gmail.com Tue Apr 8 07:59:41 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Tue, 8 Apr 2008 04:59:41 -0700 (PDT) Subject: Is there an official way to add methods to an instance? References: <7xve2yas87.fsf@ruckus.brouhaha.com> <47f61041$0$27969$426a34cc@news.free.fr> <47f645e6$0$36354$742ec2ed@news.sonic.net> <9a4cde09-d1a0-4205-aea8-1ee32d4fb1b3@a70g2000hsh.googlegroups.com> Message-ID: <41a305bf-9667-46af-9c4f-2b8800c3d038@e67g2000hsa.googlegroups.com> On 8 avr, 11:39, m?choui wrote: > On Apr 4, 5:25 pm, John Nagle wrote: > > > > > Bruno Desthuilliers wrote: > > > Paul Rubin a ?crit : > > >> Brian Vanderburg II writes: > > >>> I've checked out some ways to get this to work. I want to be able to > > >>> add a new function to an instance of an object. > > > >> Ugh. Avoid that if you can. > > > > Why so ? OO is about objects, not classes, and adding methods on a > > > per-object basis is perfectly legitimate. > > > It's what professional programmers call a "l33t feature", > > one not suitable for production code. Typically such features > > are used by programmers with about two years experience, > > trying too hard to prove that they're cool. @john: I've ten years of experience, definitively don't care about looking "cool" or "l33t", and sorry, but I won't buy your purely ideological arguments. This reminds me of the lead engineer in one of my first job forbidding using OO because he didn't get it, or some Java guy trying to convince me that a language with dynamic typing and no access restriction could not be used for "production code". > > John Nagle > > Yes, and the reason is quite obvious: if you read the code of the > class, you can't see the function. That makes it much more difficult > to understand and to debug. Then we should forbid inheritence - you don't see the inherited functions when reading the code of the class. And we should forbid monkey-patching, metaclasses and quite a lot of other things as well. And also, we should go back to static typing - with dynamic typing, you don't know by reading the signature of a function what kind of arguments it expects. C'mon, be serious guys. As everything else, the problem is not with the feature, but with knowing how to properly use it and how to not abuse it. If you don't trust the programmer, then don't use a dynamic language. You know where to find Java and Ada... From elgrandchignon at gmail.com Tue Apr 8 23:33:23 2008 From: elgrandchignon at gmail.com (Jason) Date: Tue, 8 Apr 2008 20:33:23 -0700 (PDT) Subject: Sorting a List of Objects by an Attribute of the Objects Case-Insensitively References: <736fefbd-510f-40e9-8342-32b69a1a0c2a@t12g2000prg.googlegroups.com> Message-ID: <7688aa08-d533-4b25-9a21-335ffebe573d@a22g2000hsc.googlegroups.com> On Apr 8, 8:26 pm, "David Harrison" wrote: > On 09/04/2008, Jason wrote: > > > Hi folks-- > > > Basically, I have a pressing need for a combination of 5.2 "Sorting a > > List of Strings Case-Insensitively" & 5.3 "Sorting a List of Objects > > by an Attribute of the Objects" from the Python Cookbook. > > > My first guess isn't working: > > > import operator > > def sort_by_attr(seq, attr): > > key=operator.attrgetter(attr) > > key=str.lower > > return sorted(seq, key) > > > ...would much appreciate any guidance! > > You're probably looking for the built-in function sorted, > > e.g. > > class Foo: > def __init__(self, value): > self.value = value > > def __repr__(self): > return self.value > > a = [Foo('c'), Foo('B'), Foo('A')] > > print sorted( > a, > cmp=lambda x,y: cmp(x.lower(), y.lower()), > key=lambda x: x.value > ) Hey-- thanks! I actually figured out something that works quite nicely since I posted: def sort_by_attr_case_insensitive(seq, attr): return sorted(seq, cmp=lambda x,y: cmp(x.lower(), y.lower()), key=operator.attrgetter(attr)) From ajaksu at gmail.com Fri Apr 25 19:00:18 2008 From: ajaksu at gmail.com (ajaksu) Date: Fri, 25 Apr 2008 16:00:18 -0700 (PDT) Subject: MESSAGE RESPONSE References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> <678v5qF2me5rvU1@mid.uni-berlin.de> Message-ID: <4e89b45d-198c-48ca-a3a6-3ba42448cb2b@e53g2000hsa.googlegroups.com> On Apr 23, 1:27?pm, "Dan Upton" wrote: > On Wed, Apr 23, 2008 at 10:24 AM, Diez B. Roggisch wrote: > > > Blubaugh, David A. schrieb: > > > > Is there a way to block these messages. ? I do not want to be caught > > > with filth such as this material. ?I could lose my job with Belcan with > > > evil messages such as these messages. > > > ?If I (or *anybody*) knew how to block these messages, he or she would sell > > the resulting spam-filter for a fortunen that roughly amasses the one of > > scrooge mc duck ?- and go live on the bahamas or even buy them. > > > ?Put up with it. It's (unfortunately) part of ze internet tubes. > > And as such, I find it hard to believe you could lose your job over it. Me too. That is, until I tried to Google Belcan and Blubaugh together. May I suggest a new thread to clear that ugly results? :D From gagsl-py2 at yahoo.com.ar Thu Apr 10 23:01:42 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 11 Apr 2008 00:01:42 -0300 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: En Thu, 10 Apr 2008 20:01:43 -0300, Steve Holden escribi?: > Michel Bouwmans wrote: >> >> Mike Driscoll wrote: >>> I see a lot of people recommend using pyQt, but they never mention the >>> controversy that surrounds its licensing. There have been many posts >>> on the subject already, but if the OP ever decides to sell anything >>> they create, I've heard that QT's licensing is kind of squirrelly. >>> Maybe this has been straightened out? >>> >>> I looked at the website and found it fairly confusing. And don't you >>> need to download QT itself? >>> >>> Mike >> >> Yeah, the licensing of Qt is either be open-source (under one of the >> Qt-exception licenses licenses so no exclusivity for the GPL anymore) or >> pay for the commercial version. So yes, if you would like to sell it as >> closed-source software you will need to buy the commercial version of Qt >> and PyQt. In other words: you will have to pay twice. Don't forget that >> you >> can also sell open-source software, so you don't have to pay. ;) >> > I don't think PyQt has any licensing restrictions to speak of, only the > underlying Qt platform (though it's a while since I looked). Yes, you have to buy separate licenses for both PyQt and Qt. From the PyQt home page: """PyQt v4 is licensed under the GNU GPL and under a commercial license on all platforms. [...] You can purchase the commercial version of PyQt here. PyQt does not include a copy of Qt. You must obtain a correctly licensed copy of Qt yourself.""" Another annoying thing with the Qt license is that you have to choose it at the very start of the project. You cannot develop something using the open source license and later decide to switch to the commercial licence and buy it. -- Gabriel Genellina From gherron at islandtraining.com Thu Apr 24 12:11:50 2008 From: gherron at islandtraining.com (Gary Herron) Date: Thu, 24 Apr 2008 09:11:50 -0700 Subject: convert xhtml back to html In-Reply-To: References: Message-ID: <4810B146.4080707@islandtraining.com> Tim Arnold wrote: > hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop to > create CHM files. That application really hates xhtml, so I need to convert > self-ending tags (e.g.
) to plain html (e.g.
). > > Seems simple enough, but I'm having some trouble with it. regexps trip up > because I also have to take into account 'img', 'meta', 'link' tags, not > just the simple 'br' and 'hr' tags. Well, maybe there's a simple way to do > that with regexps, but my simpleminded )]+/> doesn't work. I'm not > enough of a regexp pro to figure out that lookahead stuff. > > I'm not sure where to start now; I looked at BeautifulSoup and > BeautifulStoneSoup, but I can't see how to modify the actual tag. > > thanks, > --Tim Arnold > > > -- > http://mail.python.org/mailman/listinfo/python-list > Whether or not you can find an application that does what you want, I don't know, but at the very least I can say this much. You should not be reading and parsing the text yourself! XHTML is valid XML, and there a lots of ways to read and parse XML with Python. (ElementTree is what I use, but other choices exist.) Once you use an existing package to read your files into an internal tree structure representation, it should be a relatively easy job to traverse the tree to emit the tags and text you want. Gary Herron From aaron.watters at gmail.com Wed Apr 16 13:29:36 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 16 Apr 2008 10:29:36 -0700 (PDT) Subject: Profiling very small/quick functions, help!? References: <1ed0cde8-d04c-444b-9b47-9bea16ae409d@f63g2000hsf.googlegroups.com> Message-ID: <6025f1e4-b5d7-4cee-a255-236db4191b92@2g2000hsn.googlegroups.com> On Apr 16, 12:35 pm, skanem... at yahoo.se wrote: > if __name__=="__main__": > try: > from cProfile import run > except: > from profile import run > for x in range(1, 10000): > run("power(10,10)") def test1(): for x in xrange(1,10000): test = power(10,10) if __name__=="__main__": try: from cProfile import run except: from profile import run for x in range(1, 10000): run("test1()") all the best! -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=jar From deets at nospam.web.de Mon Apr 21 10:19:24 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Mon, 21 Apr 2008 16:19:24 +0200 Subject: how to pass C++ object to another C++ function via Python function References: <1810b155-5598-4f17-a8e9-e4aa848db5de@i36g2000prf.googlegroups.com> Message-ID: <673m48F2lucb5U1@mid.uni-berlin.de> Gabriel Genellina wrote: > En Mon, 21 Apr 2008 10:24:15 -0300, grbgooglefan > escribi?: > >> I am trying to pass a C++ object to Python function. This Python >> function then calls another C++ function which then uses this C++ >> object to call methods of that object's class. >> >> I tried something like this, but it did not work, gave core dump. > > You can't pass any arbitrary C object to a Python function. > In this case you can use a PyCObject, a Python box around a void* pointer. > See http://docs.python.org/api/cObjects.html > Neat! Didn't know about that one. Diez From frikker at gmail.com Wed Apr 30 14:09:52 2008 From: frikker at gmail.com (blaine) Date: Wed, 30 Apr 2008 11:09:52 -0700 (PDT) Subject: I messed up my wxPython install (Eclipse Configuration Issue) References: <18eb0a7c-96f4-41de-b44f-95fd8ba0223f@f63g2000hsf.googlegroups.com> <436f8226-64a5-440a-92f4-afd7dd348e1c@m73g2000hsh.googlegroups.com> Message-ID: <20525ad9-2679-4bc8-a117-66eca4a8dc13@r66g2000hsg.googlegroups.com> On Apr 30, 1:14 pm, Mike Driscoll wrote: > blaine wrote: > > The wxPython group is a bit stale compared to this group, so I'll give > > it a shot :) > > What does that mean? The wxPython group is almost always very quick to > respond with relevant answers. > > As to your question, I think Peter is correct. Your wx.py and wx.pyc > files are masking the wx package. > > Mike I didn't mean anything by it, I promise. This group is just amazing - there are always very active topics and I get responses in no time. The wxPython group I noticed only has had recent discussions a few times in the past month, and their subscribers aren't as high as the Python group. That worked. You guys are awesome, thank you! I can't believe I named that test script wx.py - duh. Thank you for your help! Blaine From sable at users.sourceforge.net Mon Apr 14 06:09:10 2008 From: sable at users.sourceforge.net (=?ISO-8859-1?Q?S=E9bastien_Sabl=E9?=) Date: Mon, 14 Apr 2008 12:09:10 +0200 Subject: Sybase module 0.39 released Message-ID: <48032D46.4050203@users.sourceforge.net> WHAT IS IT: The Sybase module provides a Python interface to the Sybase relational database system. It supports all of the Python Database API, version 2.0 with extensions. The module is available here: http://downloads.sourceforge.net/python-sybase/python-sybase-0.39.tar.gz The module home page is here: http://python-sybase.sourceforge.net/ MAJOR CHANGES SINCE 0.38: * Added type mapping as proposed in http://www.uniqsys.com/~carsten/typemap.html by Carsten Haese * Handle engineer notation of numbers in numeric * Added support for CS_DATE_TYPE * Added support for python Decimal objects in databuf * Possibility to use ct_cursor for some requests * Refactoring - merged Fetchers, CTCursor and CmdCursor in Cursor * Refactored _cancel_cmd * Added a prepare method to Cursor * Additional 'locale' argument to connect and Connection to set the locale of the connection thanks to patch by Harri Pasanen * Better compliance with DBAPI: returns None in nextset when no more set * Added conversion from string to int when assigning to a CS_INT_TYPE DataBuf BUGS CORRECTED SINCE 0.39pre1: * Corrected "undefined symbol" date_datafmt for Sybase versions where CS_DATE_TYPE is not defined (as reported by Alexey Morsov) BUGS CORRECTED SINCE 0.38: * Corrected documentation about CS_CONTEXT Objects thanks to bug report by Derek Harland (close tracker 1748109) * Corrected bug in close() if connection killed from outside thanks to patch by Derek Harland (close tracker 1746220) * Corrected bug if inherit from Sybase.Connection thanks to patch by Derek Harland (close tracker 1719789) * Optimization in fetchall - using fetchmany instead of fetchone to avoid locking time penalty, thanks to patch by Derek Harland (close tracker 1746908) * Corrections to compile with bcp-support against freetds thanks to patch by Klaus-Martin Hansche (close tracker 1724088) * Corrected documentation to compile with FreeTDS and Threads thanks to Derek Harland (close tracker 1709043) * Corrected bug in databuf_alloc: Sybase reports the wrong maxlength for numeric type - verified with Sybase 12.5 - thanks to patch provided by Phil Porter * Better detection of Sybase libraries * the C API to datetime only exists since python 2.4 - disable datetime with previous versions * Corrected python long handling (using CS_NUMERIC instead of CS_LONG which is unspecified) * Corrected various compilation warnings (some linked to python 2.5) The full ChangeLog is here: https://python-sybase.svn.sourceforge.net/svnroot/python-sybase/tags/r0_39/ChangeLog From http Thu Apr 3 03:03:09 2008 From: http (Paul Rubin) Date: 03 Apr 2008 00:03:09 -0700 Subject: Manipulate Large Binary Files References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> <9999810b0804021109n77f2c990p7b10d92e9344ad00@mail.gmail.com> Message-ID: <7xlk3vctea.fsf@ruckus.brouhaha.com> Derek Martin writes: > > Both are clocking in at the same time (1m 5sec for 2.6Gb), are there > > any ways I can optimize either solution? Getting 40+ MB/sec through a file system is pretty impressive. Sounds like a RAID? > That said, due to normal I/O generally involving double-buffering, you > might be able to speed things up noticably by using Memory-Mapped I/O > (MMIO). It depends on whether or not the implementation of the Python > things you're using already use MMIO under the hood, and whether or > not MMIO happens to be broken in your OS. :) Python has the mmap module and I use it sometimes, but it's not necessarily the right thing for something like this. Each page you try to read from results in own delay while the resulting page fault is serviced, so any overlapped i/o you get comes from the OS being nice enough to do some predictive readahead for you on sequential access if it does that. By coincidence there are a couple other threads mentioning AIO which is a somewhat more powerful mechanism. From sevenjp at gmail.com Thu Apr 3 06:10:48 2008 From: sevenjp at gmail.com (=?ISO-8859-1?Q?Jo=E3o_Neves?=) Date: Thu, 3 Apr 2008 03:10:48 -0700 (PDT) Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> <10ee2a69-f4e2-4887-8083-6b02b60dd0cd@i7g2000prf.googlegroups.com> Message-ID: <130ad0b4-504c-4b19-85fc-1bd700590ccf@u10g2000prn.googlegroups.com> On Apr 3, 4:43 am, Scott David Daniels wrote: > Nope: If you change the code in-place, the whole stack's references > to where they were running would need to get updated to corresponding > locations in the new code. _That_ is a lot of work. Ah, there it is. Now I get it, it makes perfect sense. Looks like I'll have to stick to the usual mechanisms! Thanks everyone! --- Jo?o Neves From dickinsm at gmail.com Mon Apr 7 09:55:23 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Mon, 7 Apr 2008 06:55:23 -0700 (PDT) Subject: A funnily inconsistent behavior of int and float References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com> Message-ID: <1d11875a-470a-489f-910a-b420a145eb61@a1g2000hsb.googlegroups.com> On Apr 7, 6:43 am, "Colin J. Williams" wrote: > This is good but the documentation for > 3.0 is missing the syntax documentation > from 2.5 Is http://docs.python.org/dev/3.0/reference/lexical_analysis.html#integer-literals the documentation that you're looking for? But it seems to me that Lie's original point isn't really about integer *literals* anyway---it's about the behaviour of the built-in int() function when applied to a string. So http://docs.python.org/dev/3.0/library/functions.html#int is probably the appropriate place in the documentation. And I agree that it could be made clearer exactly what strings are acceptable here. Mark From lscbtfws at gmail.com Sat Apr 26 12:11:24 2008 From: lscbtfws at gmail.com (lscbtfws at gmail.com) Date: Sat, 26 Apr 2008 09:11:24 -0700 (PDT) Subject: age of empires III crack Message-ID: <5666d9a5-bcd8-42ed-a01e-27354a1efd8f@n1g2000prb.googlegroups.com> age of empires III crack http://cracks.00bp.com F R E E C R A C K S From cokofreedom at gmail.com Tue Apr 8 06:16:23 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Tue, 8 Apr 2008 03:16:23 -0700 (PDT) Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> Message-ID: <31ef4e30-59bd-4d50-a4e1-5e8b9d73ba88@a23g2000hsc.googlegroups.com> 'I have designed a program with more than 500 if elif else' This was your first mistake... (ii) x3=x1.find(x2) returns an integer corresponding to the start position in x1 where it found x2, otherwise it will return -1. (i) ... what kind of vague numbers? It should just give you an integer response... From cstewart913 at gmail.com Wed Apr 9 21:54:33 2008 From: cstewart913 at gmail.com (Chris Stewart) Date: Wed, 9 Apr 2008 21:54:33 -0400 Subject: How is GUI programming in Python? Message-ID: I've always had an interest in Python and would like to dabble in it further. I've worked on a few very small command line programs but nothing of any complexity. I'd like to build a really simple GUI app that will work across Mac, Windows, and Linux. How painful is that going to be? I used to be really familiar with Java Swing a few years ago. I imagine it will be similar. Next, what would you say is the best framework I should look into? I'm curious to hear opinions on that. Chris Stewart cstewart913 at gmail.com From gherron at islandtraining.com Thu Apr 3 18:12:46 2008 From: gherron at islandtraining.com (Gary Herron) Date: Thu, 03 Apr 2008 15:12:46 -0700 Subject: expanding a variable to a dict In-Reply-To: References: Message-ID: <47F5565E.8040109@islandtraining.com> idle wrote: > I've got a variable in a loop that I'm trying to expand/translate/ > readdress as an existing dict so as to add some keys into it.. > > eg; I have a set of existing dicts: dictFoo, dictBar, dictFrotz (names > changed to protect the innocent) > > now I'd like to check them all for the existence of certain default > keys; ie, if the dicts don't contain the keys, add them in with > default values. > > so, I've got: > > for a in ['dictFoo','dictBar','dictFrotz']: > if hasattr(a,'srcdir') == False: > a['srcdir']='/usr/src' > > the error I get (which I expect) is 'str' object doesn't support item > assignment. > > what incantation do I cast on 'a' to make the interpreter parse it as > 'dictFoo' on the first iteration, 'dictBar' on the second, and so > forth? > > and/or less importantly, what is such a transformation called, to help > me target my searching? > > thanks > Try this: for a in [dictFoo, dictBar, dictFrotz]: if 'srcdir' in a: a['srcdir']='/usr/src' Gary Herron From deets at nospam.web.de Tue Apr 15 10:33:05 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 15 Apr 2008 16:33:05 +0200 Subject: webcam (usb) access under Ubuntu References: <66jlk1F2ju6c8U1@mid.uni-berlin.de> Message-ID: <66jsltF2k8dp9U1@mid.uni-berlin.de> Berco Beute wrote: > Thanks, that would be great. > > While I'm at it I wondering how to display a video preview. Here's > someone using VideoCapture (the win32 lib) and PyGame, but I'd rather > use a GUI framework and preview/capture videos directly. gstreamer has a preview window. Diez From breily at gmail.com Tue Apr 8 01:03:20 2008 From: breily at gmail.com (Brian) Date: Tue, 8 Apr 2008 01:03:20 -0400 Subject: Newbie: How to pass a dictionary to a function? In-Reply-To: <0178aef6-46ce-47a4-a2a4-882514e2aacd@k1g2000prb.googlegroups.com> References: <516e07d1-91f9-462b-9fc0-ac6d1e474f9d@n14g2000pri.googlegroups.com> <0178aef6-46ce-47a4-a2a4-882514e2aacd@k1g2000prb.googlegroups.com> Message-ID: Plus you probably don't want to set [] as default argument and then try to access it like a dictionary; you'll get an exception if you ever call just foo(), with no argument. On Tue, Apr 8, 2008 at 12:57 AM, Jason Scheirer wrote: > On Apr 7, 8:54 pm, BonusOnus wrote: > > How do I pass a dictionary to a function as an argument? > > > > # Say I have a function foo... > > def foo (arg=[]): > > x = arg['name'] > > y = arg['len'] > > > > s = len (x) > > > > t = s + y > > > > return (s, t) > > > > # The dictionary: > > > > dict = {} > > dict['name'] = 'Joe Shmoe' > > dict['len'] = 44 > > > > # I try to pass the dictionary as an argument to a > > # function > > > > len, string = foo (dict) > > > > # This bombs with 'TypeError: unpack non-sequence' > > > > What am I doing wrong with the dictionary? > > You want to > return s, t > NOT return (s, t) -- this implicitly only returns ONE item > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jcd at unc.edu Wed Apr 16 14:18:00 2008 From: jcd at unc.edu (J. Cliff Dyer) Date: Wed, 16 Apr 2008 14:18:00 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <1208369880.5771.1.camel@aalcdl07.lib.unc.edu> On Wed, 2008-04-16 at 12:06 -0400, Steve Holden wrote: > Mike Driscoll wrote: > > On Apr 16, 10:09 am, Steve Holden wrote: > >> Mike Driscoll wrote: > >>> On Apr 16, 9:19 am, Grant Edwards wrote: > >>>> This morning almost half of c.l.p was spam. In order to try to > >>>> not tar both the benign google group users and the malignant > >>>> ones with the same brush, I've been trying to kill usenet spam > >>>> with subject patterns. But that's not a battle you can win, so > >>>> I broke down and joined all the other people that just killfile > >>>> everything posted via google.groups. > >>>> AFAICT, if you're a google groups user your posts are not being > >>>> seen by many/most experienced (read "non-google-group") users. > >>>> This is mainly the fault of google who has refused to do > >>>> anything to stem the flood of span that's being sent via Google > >>>> Groups. > >>>> -- > >>>> Grant Edwards grante Yow! I would like to > >>>> at urinate in an OVULAR, > >>>> visi.com porcelain pool -- > >>> Yeah, I noticed that Google Groups has really sucked this week. I'm > >>> using the Google Groups Killfile for Greasemonkey now and it helps a > >>> lot. I like Google, but my loyalty only goes to far. This is a > >>> complete lack of customer service. > >> Unfortunately this means Google groups users are getting exactly the > >> service they are paying for. > >> > >> regards > >> Steve > >> -- > >> Steve Holden +1 571 484 6266 +1 800 494 3119 > >> Holden Web LLC http://www.holdenweb.com/ > > > > Steve, > > > > My workplace doesn't offer NNTP, so there is no good way to browse > > c.l.py here. And I haven't been able to get NNTP to work from my home > > either. > > > > By applying this logic to Python and Linux (or any Open Source > > product), they shouldn't be used either (since I'm not paying for > > them). > > > I'm not saying people shouldn't use Google Groups. I'm saying that > Google can "justify" providing customer "support" that lives somewhere > between zero and extremely crappy by not charging for the service. > > Without tunneling out to an NNTP proxy I don't see what other choice you > have. > > regards > Steve You could subscribe via email, and keep your own archive. If you use an email client with decent adaptive spam filter (i.e. not outlook), you won't even notice the spam floating by. It worked like a charm for me until I switched to digest view :) -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill From skanemupp at yahoo.se Fri Apr 18 19:29:28 2008 From: skanemupp at yahoo.se (globalrev) Date: Fri, 18 Apr 2008 16:29:28 -0700 (PDT) Subject: python setup.py install on Vista? Message-ID: type "python setup.py install" that is used in most "addons" for python. well using windows vista, where the h*** am i supposed to type this? if it is not doable in windows, what do i have to do instead? just clicking the setup.py-file never works. From cwitts at gmail.com Wed Apr 2 08:37:27 2008 From: cwitts at gmail.com (Chris) Date: Wed, 2 Apr 2008 05:37:27 -0700 (PDT) Subject: splitting an XML file on the basis on basis of XML tags References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> Message-ID: bije... at gmail.com wrote: > Hi all, > > i have an XML file with the following structure:: > > > -----| > | > | > . | > . | --------------------> constitutes one record. > . | > . | > . | > | > | > ----| > > . > . > . -----------------------| > . | > . | > . |----------------------> there are n > records in between.... > . | > . | > . | > . ------------------------| > . > . > > -----| > | > | > . | > . | --------------------> constitutes one record. > . | > . | > . | > | > | > ----| > > > > Here is the main root tag of the XML, and ... > constitutes one record. What I would like to do is > to extract everything (xml tags and data) between nth tag and (n > +k)th tag. The extracted data is to be > written down to a separate file. > > Thanks... You could create a generator expression out of it: txt = """ 1 2 3 4 5 """ l = len(txt.split('r2>'))-1 a = ('%sr2>'%i for j,i in enumerate(txt.split('r2>')) if 0 < j < l and i.replace('>','').replace('<','').strip()) Now you have a generator you can iterate through with a.next() or alternatively you could just create a list out of it by replacing the outer parens with square brackets. From kveretennicov at gmail.com Sun Apr 6 07:14:14 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Sun, 6 Apr 2008 14:14:14 +0300 Subject: Python Data Utils In-Reply-To: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> References: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> Message-ID: <4660fe300804060414v70a53166j5e14333d39b50243@mail.gmail.com> On Sun, Apr 6, 2008 at 7:43 AM, Jesse Aldridge wrote: > In an effort to experiment with open source, I put a couple of my > utility files up here. What do you think? Would you search for, install, learn and use these modules if *someone else* created them? -- kv From collardfelszkw at gmail.com Sun Apr 20 16:32:45 2008 From: collardfelszkw at gmail.com (collardfelszkw at gmail.com) Date: Sun, 20 Apr 2008 13:32:45 -0700 (PDT) Subject: jennifer aniston paul Message-ID: Just few link on some Movies Movies: http://Jennifer-Aniston.12w.net F R E E C E L E B R I T Y M O V I E S From donn at u.washington.edu Fri Apr 11 16:02:39 2008 From: donn at u.washington.edu (Donn Cave) Date: Fri, 11 Apr 2008 13:02:39 -0700 Subject: pty.spawn directs stderr to stdout References: Message-ID: In article , Wilbert Berendsen wrote: > Hi, > > using pty.spawn() it seems that stderr output of the spawned process is > directed to stdout. Is there a way to keep stderr separate and only direct > stdin and stdout to the pty? There is, of course. First, you have to decide where you want unit 2 ("stderr") to go, and then get the spawned process to redirect it there. If a disk file will do, then your question is just "how do I redirect error output to a disk file, in ___" (fill in the blank with language used to implement the spawned process - UNIX shell? Python? C?) More likely, you want the spawned process' error output to go wherever the parent's error output was going. This is a little trickier. Ideally, your spawned shell script can conveniently take a new parameter that identifies the new file descriptor unit number for error output. In this case, use fd2 = os.dup(2) to get a new duplicate, add a parameter like -e str(fd2), and in the spawned process, redirect from that unit - in UNIX shell, exec 2>&$fd2 Or you could use an environment variable to identify the backup error unit, if the command line parameter option isn't available for some reason. Donn Cave, donn at u.washington.edu From john00587 at gmail.com Mon Apr 21 01:40:48 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:40:48 -0700 (PDT) Subject: crack and digichat 5 Message-ID: <98a4c42d-e686-4191-9967-c065a303798d@r9g2000prd.googlegroups.com> crack and digichat 5 http://cracks.00bp.com F R E E C R A C K S From vijayakumar.subburaj at gmail.com Mon Apr 14 03:13:56 2008 From: vijayakumar.subburaj at gmail.com (v4vijayakumar) Date: Mon, 14 Apr 2008 00:13:56 -0700 (PDT) Subject: Game design : Making computer play Message-ID: In computer based, two player, board games, how to make computer play? Are there any formal ways to _teach_ computer, to choose best possible move? I know this is kind of off-topic here. Please redirect me, if there are more appropriate newsgroup. Many thanks. From mrmakent at cox.net Wed Apr 23 16:51:09 2008 From: mrmakent at cox.net (Mike Kent) Date: Wed, 23 Apr 2008 13:51:09 -0700 (PDT) Subject: Pythonically extract data from a list of tuples (getopt) References: Message-ID: <8a3f5274-6fb7-4319-ab86-d18c9bbbf9fe@59g2000hsb.googlegroups.com> You could use http://docs.python.org/lib/module-optparse.html From deets at nospam.web.de Wed Apr 23 10:24:37 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 23 Apr 2008 16:24:37 +0200 Subject: MESSAGE RESPONSE In-Reply-To: References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> Message-ID: <678v5qF2me5rvU1@mid.uni-berlin.de> Blubaugh, David A. schrieb: > Is there a way to block these messages. I do not want to be caught > with filth such as this material. I could lose my job with Belcan with > evil messages such as these messages. If I (or *anybody*) knew how to block these messages, he or she would sell the resulting spam-filter for a fortunen that roughly amasses the one of scrooge mc duck - and go live on the bahamas or even buy them. Put up with it. It's (unfortunately) part of ze internet tubes. Diez From exarkun at divmod.com Fri Apr 11 13:23:13 2008 From: exarkun at divmod.com (Jean-Paul Calderone) Date: Fri, 11 Apr 2008 13:23:13 -0400 Subject: pyOpenSSL 0.7 In-Reply-To: 0 Message-ID: <20080411172313.6859.586410116.divmod.quotient.28168@ohm> pyOpenSSL is a wrapper around a subset of the OpenSSL API, including support for X509 certificates, public and private keys, and and SSL connections. pyOpenSSL 0.7 fixes a number of memory leaks and memory corruption issues. It also exposes several new OpenSSL APIs to Python: * SSL_get_shutdown and SSL_set_shutdown exposed as OpenSSL.SSL.Connection.get_shutdown and OpenSSL.SSL.Connection.set_shutdown * SSL_SENT_SHUTDOWN and SSL_RECEIVED_SHUTDOWN exposed as OpenSSL.SSL.SENT_SHUTDOWN and OpenSSL.SSL.RECEIVED_SHUTDOWN * X509_verify_cert_error_string exposed as OpenSSL.crypto.X509_verify_cert_error_string * X509.get_serial_number and X509.set_serial_number now accept long integers * Expose notBefore and notAfter on X509 certificates for inspection and mutation * Expose low-level X509Name state with X509Name.get_components * Expose hashing and DER access on X509Names pyOpenSSL home page: http://pyopenssl.sourceforge.net/ pyOpenSSL downloads: http://sourceforge.net/project/showfiles.php?group_id=31249 Jean-Paul Calderone From watches0560 at global-replica-watch.com Fri Apr 25 12:04:31 2008 From: watches0560 at global-replica-watch.com (watches0560 at global-replica-watch.com) Date: Fri, 25 Apr 2008 09:04:31 -0700 (PDT) Subject: Brand Watches Ebel Classic Brown Leather Strap Date Mens Watch 9120F51.6235134 Discount, Swiss, Fake Message-ID: <18cf6db3-7812-4da1-a745-2df4c5545060@b9g2000prh.googlegroups.com> Brand Watches Ebel Classic Brown Leather Strap Date Mens Watch 9120F51.6235134 Discount, Swiss, Fake Browse our Ebel Classic Brown Leather Strap Date Mens Watch 9120F51.6235134 Swiss watches, which is sure the watch you are looking for at low price. There are more high quality designer watch Swiss for selection Ebel Classic Brown Leather Strap Date Mens Watch 9120F51.6235134 Link : http://www.watches-brand.com/Ebel-wristwatch-3195.html Brand : Ebel ( http://www.watches-brand.com/Ebel-Watches.html ) Model : Ebel Classic Brown Leather Strap Date Mens Watch 9120F51.6235134 Description :

Stainless Steel Case & Bezel, Silver Dial, Brown Crocodile Leather Strap, Date Display, Roman Numeral Hour Markers, Self Winding Automatic Movement, Scratch Resistant Sapphire Crystal, Deployment Buckle, Water Resistant up to 165FT

Sale Price : $ 245.00 Ebel Classic Brown Leather Strap Date Mens Watch 9120F51.6235134 Details :
  • Brand: Ebel
  • Model: 9120F51.6235134
  • Band material: Leather
  • Bezel material: stainless-steel
  • Case material: stainless-steel
  • Clasp type: deployment-buckle
  • Dial color: silver
  • Dial window material: scratch-resistant-sapphire
  • Movement type: Swiss Automatic Movement
  • Water-resistant to 165 feet
Ebel Classic Brown Leather Strap Date Mens Watch 9120F51.6235134 is new brand Swiss, join thousands of satisfied customers and buy your Ebel with total satisfaction. A watches-brand.COM 30 Day Money Back Guarantee is included with every Ebel Fake Series for secure, risk- free online shopping. watches-brand.COM does not charge sales tax for the Fake Ebel Classic Brown Leather Strap Date Mens Watch 9120F51.6235134. All of our Fake watches are shipped via EMS to worldwide. Normally it takes 3days to prepare the fake watch you ordered and 5-10days to transmit depending on the different destination.We pay for the free shipping cost for total quantity over 20 pcs. The EMS tracking NO. will be sent by email when an order is shipped from our warehouse. No more other charges from watches-brand.com such as the tax. If you have any other questions please check our other pages or feel free to email us by sales at watches-brand.com. The Same Fake Ebel Watches Series : Ebel Classic Two-Tone Black Leather Strap Mens Watch 1255F41.0235136 : http://www.watches-brand.com/Ebel-wristwatch-3196.html Ebel Classic Wave Mens Watch 9187151/20125 : http://www.watches-brand.com/Ebel-wristwatch-3197.html Ebel Men's Type E Stainless Steel Black Dial Watch, Model - 9187C41/5716 : http://www.watches-brand.com/Ebel-wristwatch-3198.html Ebel Men's Type E Stainless Steel Rubber Band Watch, Model - 9187C41/06C35606 : http://www.watches-brand.com/Ebel-wristwatch-3199.html Ebel Men's E Type Watch #9187C41-3716 : http://www.watches-brand.com/Ebel-wristwatch-3200.html Ebel Men's E Type Watch #9187C51-5716 : http://www.watches-brand.com/Ebel-wristwatch-3201.html Ebel Men's E Type Automatic Watch #9330C41-0716 : http://www.watches-brand.com/Ebel-wristwatch-3202.html Ebel Men's E Type Watch #9187C41-0716 : http://www.watches-brand.com/Ebel-wristwatch-3203.html Ebel Men's E Type Watch #9187C41-56C35606 : http://www.watches-brand.com/Ebel-wristwatch-3204.html Ebel Men's E Type Watch #9187C51-06C35606 : http://www.watches-brand.com/Ebel-wristwatch-3205.html Brand Watches Ebel Classic Brown Leather Strap Date Mens Watch 9120F51.6235134 Discount, Swiss, Fake From skanemupp at yahoo.se Tue Apr 15 15:46:53 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Tue, 15 Apr 2008 12:46:53 -0700 (PDT) Subject: tkinter, canvas, get color of image? References: <0e4c9708-dbe9-4f29-ac31-34f7298f2624@m1g2000pre.googlegroups.com> Message-ID: On 13 Apr, 19:19, Bryan Oakley wrote: > skanem... at yahoo.se wrote: > > mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\elmapovic.gif') > > w.create_image(10, 10, image = mapq, anchor = NW) > > > after doing this is there any possibility of getting the > > characteristics of the GIF-picture(or bitmap if i use that)? > > > it would be very helpfull if i for example could do something like > > canvas.getcolor(image, mouseclick.x,mouseclick.y) if u get the point. > > get the color of the image where i clicked. > > The image isn't "painted" on the canvas, so to answer your specific > question, no, you can't get the color of a pixel on the canvas in the > way that you ask. > > However, when you click on the canvas you can get the item that was > clicked on and the x/y of the click. From that you can figure out which > pixel of the image is under the cursor. And from that you can query the > image for the color of a specific pixel. how do i get the item? http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_image-method with any of those methods? when i click the mouse i can get event.object u mean? From steve at holdenweb.com Sun Apr 6 22:54:22 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 06 Apr 2008 22:54:22 -0400 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> <47F831F7.4000709@holdenweb.com> Message-ID: Fredrik Lundh wrote: > Steve Holden wrote: > >>> for reference, here's what I get on Ubuntu 7.10, with the standard >>> Python interpreter (2.5.1): >>> >>> $ python -c "import imp; print imp.get_suffixes()" >>> [('.so', 'rb', 3), ('module.so', 'rb', 3), ('.py', 'U', 1), >>> ('.pyc', 'rb', 2)] >>> >>> any Ubuntu gurus here that can sort this one out? >>> >> I wouldn't claim to be an Ubuntu guru but it seems as though the Ubuntu >> team decide that you would be able to import extension module YYY either >> from YYY.so or from YYYmodule.so. IF you are asking *why* then I'd have >> to answer that I have no idea at all. > > oh, the ".so" and "module.so" is standard Python behaviour (see my first > post in this thread). what I cannot figure out is how "llothar" has > managed to get setup.py to build extensions that an Ubuntu Python cannot > load, without noticing. > Well, at least *I* learned something in this thread. I had missed that second paragraph in your first post, and hadn't realised it from other sources. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From martin at v.loewis.de Sat Apr 19 03:59:49 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sat, 19 Apr 2008 09:59:49 +0200 Subject: How to print a unicode string? In-Reply-To: References: <4809394A.1030906@v.loewis.de> Message-ID: <4809A675.70300@v.loewis.de> > Is it possible to change an > environment variable, so that Python uses this coding automatically? No. > Or pass a command-line argument when Emacs python-mode invokes the > Python interpreter? No. > Or execute this line of Python in a startup script > which is invoked whenever a new Python session is started? Yes, you can add the code I suggested to sitecustomize.py. Regards, Martin From cwitts at gmail.com Thu Apr 3 06:27:56 2008 From: cwitts at gmail.com (Chris) Date: Thu, 3 Apr 2008 03:27:56 -0700 (PDT) Subject: splitting an XML file on the basis on basis of XML tags References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> Message-ID: On Apr 3, 8:51?am, Steve Holden wrote: > bijeshn wrote: > > On Apr 2, 5:37 pm, Chris wrote: > >> bije... at gmail.com wrote: > >>> Hi all, > >>> ? ? ? ? ?i have an XML file with the following structure:: > >>> > >>> -----| > >>> ? ? | > >>> ? ? | > >>> . ? ? ? ? ? | > >>> . ? ? ? ? ? | ? ? ? ? --------------------> constitutes one record. > >>> . ? ? ? ? ? | > >>> . ? ? ? ? ? | > >>> . ? ? ? ? ? | > >>> ? ?| > >>> ? ?| > >>> ----| > >>> > >>> . > >>> . > >>> . ? ?-----------------------| > >>> . ? ? ? ? ? ? ? ? ? ? ? ? ? | > >>> . ? ? ? ? ? ? ? ? ? ? ? ? ? | > >>> . ? ? ? ? ? ? ? ? ? ? ? ? ? |----------------------> there are n > >>> records in between.... > >>> . ? ? ? ? ? ? ? ? ? ? ? ? ? | > >>> . ? ? ? ? ? ? ? ? ? ? ? ? ? | > >>> . ? ? ? ? ? ? ? ? ? ? ? ? ? | > >>> . ? ------------------------| > >>> . > >>> . > >>> > >>> -----| > >>> ? ? | > >>> ? ? | > >>> . ? ? ? ? ? | > >>> . ? ? ? ? ? | ? ? ? ? --------------------> constitutes one record. > >>> . ? ? ? ? ? | > >>> . ? ? ? ? ? | > >>> . ? ? ? ? ? | > >>> ? ?| > >>> ? ?| > >>> ----| > >>> > >>> ? ? ? ?Here is the main root tag of the XML, and ... > >>> constitutes one record. What I would like to do is > >>> to extract everything (xml tags and data) between nth tag and (n > >>> +k)th tag. The extracted data is to be > >>> written down to a separate file. > >>> Thanks... > >> You could create a generator expression out of it: > > >> txt = """ > >> ? ? 1 > >> ? ? 2 > >> ? ? 3 > >> ? ? 4 > >> ? ? 5 > >> ? ? > >> ? ? """ > >> l = len(txt.split('r2>'))-1 > >> a = ('%sr2>'%i for j,i in enumerate(txt.split('r2>')) if 0 < j < l > >> and i.replace('>','').replace('<','').strip()) > > >> Now you have a generator you can iterate through with a.next() or > >> alternatively you could just create a list out of it by replacing the > >> outer parens with square brackets.- Hide quoted text - > > >> - Show quoted text - > > > Hmmm... will look into it.. Thanks > > > the XML file is almost a TB in size... > > Good grief. When will people stop abusing XML this way? > > > so SAX will have to be the parser.... i'm thinking of doing something > > to split the file using SAX > > ... Any suggestions on those lines..? If there are any other parsers > > suitable, please suggest... > > You could try pulldom, but the documentation is disgraceful. > > ElementTree.iterparse *might* help. > > regards > ? Steve > > -- > Steve Holden ? ? ? ?+1 571 484 6266 ? +1 800 494 3119 > Holden Web LLC ? ? ? ? ? ? ?http://www.holdenweb.com/ I abuse it because I can (and because I don't generally work with XML files larger than 20-30meg) :) And the OP never said the XML file for 1TB in size, which makes things different. From here at softcom.net Thu Apr 24 23:04:55 2008 From: here at softcom.net (Sal) Date: Thu, 24 Apr 2008 20:04:55 -0700 (PDT) Subject: Remove old version before upgrade? Message-ID: I'm currently running Windows version 2.5.1 and would like to upgrade to 2.5.2. My question is, can I just go ahead and install the new version over the old or should I remove the old version with add/ remove programs first? The old version is in a directory named Python25. From mail at timgolden.me.uk Fri Apr 18 11:36:43 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 18 Apr 2008 16:36:43 +0100 Subject: Excel Manipulation using Python In-Reply-To: References: Message-ID: <4808C00B.2090009@timgolden.me.uk> Krishna wrote: > I was trying to delete rows in an existing .xls file using python. How > do I do that? I was using the following code, it seem to work if I > type in python window, but if I save it in text editor and drage and > drop the .py file, it doesnt work. What am I doing wrong here? Thanks > for your help! > > import win32com.client > from time import sleep > excel = win32com.client.Dispatch("Excel.Application") > > def Extract(): > excel.Visible = 0 > workbook=excel.Workbooks.Open('C:\Trial.xls') > > i=1 > for n in range(1,10): > excel.Rows(i).Select > excel.Selection.Delete > excel.Selection.Delete > i=i+2 > workbook.Save() > print "saved" > > excel.Quit() Several points worthy of note: 1) When you're dealing with Windows filenames, either make the strings raw -- Open (r"c:\trial.txt") -- or use the other slashes =-- Open ("c:/trial.xls"). 2) You're not actually calling the Select and Delete methods, merely referencing them. Try .Delete () etc. 3) You're saving the workbook every time round the loop, but perhaps you knew that. Might prompt you everytime as you're overwriting, but again, maybe you knew... TJG From marion at everautumn.com Thu Apr 3 14:08:20 2008 From: marion at everautumn.com (marion at everautumn.com) Date: Thu, 3 Apr 2008 11:08:20 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: <902504ff-410f-4cfc-b76b-89535b5276cc@2g2000hsn.googlegroups.com> On Apr 1, 1:27?pm, sprad wrote: > I'm a high school computer teacher, and I'm starting a series of > programming courses next year (disguised as "game development" classes > to capture more interest). The first year will be a gentle > introduction to programming, leading to two more years of advanced > topics. > > I was initially thinking about doing the first year in Flash/ > ActionScript, and the later years in Java. My reasoning is that Flash > has the advantage of giving a quick payoff to keep the students > interested while I sneak in some OOP concepts through ActionScript. > Once they've gotten a decent grounding there, they move on to Java for > some more heavy-duty programming. > > I've never used Python, but I keep hearing enough good stuff about it > to make me curious. > > So -- would Python be a good fit for these classes? Could it equal > Java as the later heavy-duty language? Does it have enough quickly- > accessible sparklies to unseat Flash? > > I want to believe. Evangelize away. I am a strong support of teaching programming in middle and high school. Kids have the potential of being more than just passive consumers of other programmers work. That is best illustrated by the growth of game mod'rs writing their own levels for computer games. I think I agree with all of the positive, supporting posts about Python. I would just like to add that Python (and PyGame) are open source and so your students can download it at home and have fun exploring it on their own time (at their own pace). I think that is a real positive. From steve at holdenweb.com Mon Apr 7 07:05:49 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 07 Apr 2008 07:05:49 -0400 Subject: First Python project - comments welcome! In-Reply-To: <1207555415.6966.88.camel@paul-laptop> References: <1207555415.6966.88.camel@paul-laptop> Message-ID: Paul Scott wrote: > I have started, and made some progress (OK it works, but needs some > love) on my first real Python application. > > http://cvs2.uwc.ac.za/trac/python_tools/browser/podder > > I would love some feedback on what I have done. In total this has taken > me 5 nights to do (I am working on it at night as PHP, not Python, is my > day job), so it can probably do with *lots* of improvement. All code is > GPL. > > If anyone on this list is willing/able, please do give me a few > pointers, even if it is "This is total crap - RTFM and come back when > you are ready" I would really appreciate it! > > Many thanks, and thank you to this community for helping me through the > initial bumps of getting into Python - a great dev tool IMHO! > The code looks pretty good to someone that doesn't know Gtk graphics. 184: self.wTree2=gtk.glade.XML(globaldir+"podder.glade","serverdialogue") could really do with using os.path.join() if you want to be easily cross-platform. Similarly the other places you use globaldir+"...". At line 321 you loop while True over a Queue.Queue object until the QueueEmpty exception is raised, then break out of the loop. It would be easier to loop while not queue.empty(). I know the docs say that this function is not reliable due to multi-threading semantics, but I doubt it will make your program less responsive. You even put docstrings on your code. WEll done, you are going to enjoy Python. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gnewsg at gmail.com Thu Apr 10 06:15:08 2008 From: gnewsg at gmail.com (Giampaolo Rodola') Date: Thu, 10 Apr 2008 03:15:08 -0700 (PDT) Subject: Sorting Directories from files in a os.listdir?? References: <9354f263-b833-4845-a226-1ad3a47b1e6a@p25g2000pri.googlegroups.com> Message-ID: <37182914-e2d9-4308-b78e-43c9a5431dbb@f63g2000hsf.googlegroups.com> On 10 Apr, 11:55, Soren wrote: > Hi, > > I'd like to read the filenames in a directory, but not the > subdirectories, os.listdir() gives me everything... how do I separate > the directory names from the filenames? Is there another way of doing > this? > > Thanks! I guess you have no other way than using os.path.isfile or os.path.isdir for every entry returned by os.listdir. --- Giampaolo http://code.google.com/p/pyftpdlib From tismer at stackless.com Thu Apr 24 15:49:45 2008 From: tismer at stackless.com (Christian Tismer) Date: Thu, 24 Apr 2008 12:49:45 -0700 Subject: Psyco alternative In-Reply-To: References: <1369b321-f55b-432b-b2f9-6144787509d8@h11g2000prf.googlegroups.com> <7xlk4473ai.fsf@ruckus.brouhaha.com> <651ncdF2cmik2U1@mid.uni-berlin.de> <651onqF2dripdU1@mid.uni-berlin.de> Message-ID: <4810E459.8040500@stackless.com> bearophileHUGS at lycos.com wrote: > Diez B. Roggisch: >> the author says that the approach is flawed, so at *some* >> point it will be discontinued. > > Can't Psyco be improved, so it can compile things like: > > nums = (i for i in xrange(200000) if i % 2) > print sum(nums) Although my main goal is to support PyPy as much as possible, I am currently taking a pause in favor of filling the gap for psyco, supporting generators. The details are not yet settled, maybe we choose to change the project name, to avoid the author getting bugged with questions about this extra stuff. - chris -- Christian Tismer :^) tismerysoft GmbH : Have a break! Take a ride on Python's Johannes-Niemeyer-Weg 9A : *Starship* http://starship.python.net/ 14109 Berlin : PGP key -> http://wwwkeys.pgp.net/ work +49 30 802 86 56 mobile +49 173 24 18 776 fax +49 30 80 90 57 05 PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04 whom do you want to sponsor today? http://www.stackless.com/ From sturlamolden at yahoo.no Fri Apr 4 19:19:03 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 4 Apr 2008 16:19:03 -0700 (PDT) Subject: Importing a 3rd Party windows DLL for use within th Python References: <92513305-836d-4c85-aeb8-3e3d6571ed92@1g2000prg.googlegroups.com> Message-ID: <82662184-347d-4277-93b5-5bbeef31792a@q27g2000prf.googlegroups.com> On Apr 5, 12:58 am, lee.walc... at gmail.com wrote: > Is it possible for someone to provide the information on the steps > necessary to access this DLL and treat it like any other pyd library? > Maybe there is already a tutorial available for performing this task? > Is this task straight forward? Short answer: Read the ctypes tutorial and reference. http://python.net/crew/theller/ctypes/tutorial.html http://python.net/crew/theller/ctypes/reference.html Other options: - Write a pyd wrapper manually in C - Write a pyd wrapper using Pyrex or Cython - Write a pyd wrapper using Swig - Write a pyd wrapper using Boost.Python or PyCXX - Inline C++ using scipy.weave From ott.deb at gmail.com Thu Apr 17 15:05:22 2008 From: ott.deb at gmail.com (ott.deb at gmail.com) Date: Thu, 17 Apr 2008 12:05:22 -0700 (PDT) Subject: fable keygen Message-ID: <60201293-e258-4ec7-8b97-8d10ece7a9d4@a23g2000hsc.googlegroups.com> fable keygen http://cracks.12w.net F R E E C R A C K S From martin at v.loewis.de Tue Apr 22 17:06:47 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 22 Apr 2008 23:06:47 +0200 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: References: Message-ID: <480e5367$0$17314$9b622d9e@news.freenet.de> > 2. Kill the subprocess in a platform independent manner (i.e. no third party > modules and no hacks). What's wrong with the .terminate method of the Popen object? Regards, Martin From ni at hao.com Wed Apr 30 02:13:17 2008 From: ni at hao.com (SL) Date: Wed, 30 Apr 2008 08:13:17 +0200 Subject: computing with characters Message-ID: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> How can I compute with the integer values of characters in python? Like 'a' + 1 equals 'b' etc From bockman at virgilio.it Sat Apr 26 05:28:39 2008 From: bockman at virgilio.it (Francesco Bochicchio) Date: Sat, 26 Apr 2008 11:28:39 +0200 Subject: display monochromatic images wxPython References: <43c2ef33-b08c-4161-b170-16ab346628d7@m36g2000hse.googlegroups.com> Message-ID: On Fri, 25 Apr 2008 14:42:17 -0700, wongjoekmeu at yahoo.com wrote: > Dear All, > I want to write a GUI program with wxPython displaying an image. But > the image I have is monochromatic. When I retrieve the data from the > image I end up with a list of integer. Starting from a list of integer > and knowing the width and height of the image, how do I display such > an image on a wx panel or frame ? I have had a look at the wxPython > demo but there I see only images where the data is a list of tuple > consisting of r,g ,b values. Is there are function where I directly > can input the list of array and let it display the image ? > Thanks in advance > > RR I think that RGB colors with the same amount of R,G, and B levels always result in some shade of gray. If so, you could try building your image data by convering each numver in a triplet of equal numbers. Ciao ---- FB From gherron at islandtraining.com Wed Apr 16 03:12:24 2008 From: gherron at islandtraining.com (Gary Herron) Date: Wed, 16 Apr 2008 00:12:24 -0700 Subject: Mailing list question In-Reply-To: <397280.11586.qm@web45815.mail.sp1.yahoo.com> References: <397280.11586.qm@web45815.mail.sp1.yahoo.com> Message-ID: <4805A6D8.6060007@islandtraining.com> python newbie wrote: > Hello, > Just curious; can I post a basic programming question to this mailing > list? You just did. :-) (Real answer: Yes. We're pretty newbie friendly here.) Gary Herron > > Thanks in advance. > > Pete > > ------------------------------------------------------------------------ > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try > it now. > From v.harishankar at gmail.com Wed Apr 23 05:31:54 2008 From: v.harishankar at gmail.com (Harishankar) Date: Wed, 23 Apr 2008 15:01:54 +0530 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: References: <200804230839.49560.v.harishankar@gmail.com> Message-ID: <200804231501.54730.v.harishankar@gmail.com> On Wednesday 23 Apr 2008 14:46:20 Christian Heimes wrote: > Harishankar schrieb: > > Is there any platform independent way to launch a terminal window from a > > desktop (Windows, Linux, etc.)? > > No, there isn't. It usually not possible to create a graphical terminal > window on a remote server. > > Christian Ah, well, since my application is a desktop tool and it requires a GUI I'm doing something like this: However, I have to then force the user to use xterm (which is a popular/common X Terminal) if (sys.platform.startswith ('win'): # launch the windows cmd.exe with the command ... else: # warn the user that xterm is required and then launch xterm ... -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org From martin.laloux at gmail.com Wed Apr 16 08:40:03 2008 From: martin.laloux at gmail.com (martin.laloux at gmail.com) Date: Wed, 16 Apr 2008 05:40:03 -0700 (PDT) Subject: Python crashes consistently References: Message-ID: <25f1364c-fc01-4d4c-9443-ac7396efe299@a70g2000hsh.googlegroups.com> I agree, use the official python http://www.python.org/ftp/python/2.5.2/python-2.5.2-macosx.dmg I'm also using OS X 10.4.11 and I have no problem for installing numpy http://www.scipy.org/Installing_SciPy/Mac_OS_X or you can download Pre-built binaries from http://pythonmac.org/packages/py25-fat/index.html or http://trichech.us/?page_id=5 From george.sakkis at gmail.com Tue Apr 1 23:24:01 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 1 Apr 2008 20:24:01 -0700 (PDT) Subject: generator functions: why won't this work? References: Message-ID: On Apr 1, 11:17 pm, George Sakkis wrote: > On Apr 1, 10:56 pm, zillo... at googlemail.com wrote: > > > > > Hi all, > > > I'm trying to understand generator functions and the yield keyword. > > I'd like to understand why the following code isn't supposed to work. > > (What I would have expected it to do is, for a variable number of > > arguments composed of numbers, tuples of numbers, tuples of tuples, > > etc., the function would give me the next number "in sequence") > > #################################### > > def getNextScalar(*args): > > for arg in args: > > if ( isinstance(arg, tuple)): > > getNextScalar(arg) > > else: > > yield arg > > #################################### > > > # here's an example that uses this function: > > # creating a generator object: > > g = getNextScalar(1, 2, (3,4)) > > g.next() # OK: returns 1 > > g.next() # OK: returns 2 > > g.next() # not OK: throws StopIteration error > > > #################################### > > > I'm sure I'm making some unwarranted assumption somewhere, but I > > haven't been able to figure it out yet (just started learning Python a > > couple of days ago). > > > Any help will be appreciated :) > > You're pretty close, there's just one more thing left. The return > value of a generator function is an iterable, something you're > supposed to iterate over. In the 'if' clause you call recursively the > generator on arg but you don't use the result, you discard it as soon > as it is returned. What you have to do is iterate over the returned > iterable and yield its values: > > # don't need parentheses around the if expression > if isinstance(arg, tuple): > for scalar in getNextScalar(arg): > yield scalar > > Hope this helps, > George Just after hitting send I noticed a second unrelated issue that has to do with the generator's signature. Since you define it to take any positional arguments instead of a single argument (as I mistakenly assumed), the right way to call it recursively is expand the tuple arg into positional arguments: getNextScalar(*arg) instead of getNextScalar(arg): # don't need parentheses around the if expression if isinstance(arg, tuple): for scalar in getNextScalar(*arg): yield scalar George From grante at visi.com Fri Apr 18 23:33:34 2008 From: grante at visi.com (Grant Edwards) Date: Fri, 18 Apr 2008 22:33:34 -0500 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041816413450073-bob@passcalnmtedu> Message-ID: On 2008-04-18, Bob Greschke wrote: > I'm on a Solaris 8 with Python 2.3.4 and when crunching > through, literally, millions and millions of samples of > seismic data fingers point out the difference nicely. :) I'll > look into this more on some of our bigger better faster > machines (there is no -m option for timeit on the Sun :). The > Sun is just what I develop on. If stuff runs fast enough to > keep me awake on there over an ssh'ed X11 connection it > should run even better on the real field equipment (Macs, > Linuxes, WinXPs). If time is an issue, I might write a C program to convert the files from 24-bit numbers to 32-bit numbers. Then you can use numpy to load huge arrays of them in a single whack. -- Grant Edwards grante Yow! .. he dominates the at DECADENT SUBWAY SCENE. visi.com From danb_83 at yahoo.com Tue Apr 8 21:25:05 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Tue, 8 Apr 2008 18:25:05 -0700 (PDT) Subject: text adventure game problem References: Message-ID: <63bcd116-6646-4acd-a36a-b2dd5a1706b2@s37g2000prg.googlegroups.com> On Apr 8, 8:01 pm, corvettecra... at gmail.com wrote: > okay, I'm having this one problem with a text adventure game. It's > kind of hard to explain, but I'll do my best. > [code] > > def prompt_kitchen(): > global gold > gold_taken = False > while True: > prompt_kit = raw_input('>') > if prompt_kit == 'examine cabinet 1' and not gold_taken: > print '''This cabinet has a lot of cups in it with all > different > designs and shapes. Where are the people anyway? How come there's > nobody here? > In one of the cups you find 8 gold.''' > gold = gold+8 > gold_taken = True > pass4() > elif prompt_kit == 'examine cabinet 1' and gold_taken: > print \ > '''This cabinet has a lot of cups in it with all > different > designs and shapes. Where are the people anyway? How come there's > nobody here?''' > pass4() > > def pass4(): > global gold > print 'You have', gold, 'gold' > pass > [/code] > > Okay, now for my problem. > In the above function, there's the option to examine a cabinet and get > 8 gold. (everyone here knows that...but I'm just trying to state my > problem...) > Unfortunately, it kind of doesn't work. > After the first time I 'examine cabinet 1' in my game, I get 8 gold > and I can't get it again. > But, If I leave the room and come back to it, then it's as if I had > never gotten the gold the first time, and I can get it again. That's because your function starts with "gold_taken = False". The easiest fix is to make gold_taken a global variable initialized outside the function, like you're already doing with gold. From gagsl-py2 at yahoo.com.ar Wed Apr 30 05:24:00 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 30 Apr 2008 06:24:00 -0300 Subject: Who makes up these rules, anyway? References: Message-ID: En Tue, 29 Apr 2008 13:15:33 -0300, Roel Schroeven escribi?: > Cameron Laird schreef: >> In article , >> Gabriel Genellina wrote: >>> Explicit variable declaration for functions: >>> >>> http://groups.google.com/group/comp.lang.python/browse_thread/thread/6c4a508edd2fbe04/ >> . >> A reader notes that this thread actually lived during 2004 (!) [...] > > I assumed it was a mix-up with the recent thread with the same name: > http://groups.google.com/group/comp.lang.python/browse_thread/thread/f3832259c6da530 Yes, sorry! The worst part is that I *did* notice it was an old thread, but somehow I messed the links at the end. -- Gabriel Genellina From bvidinli at gmail.com Wed Apr 16 04:26:18 2008 From: bvidinli at gmail.com (bvidinli) Date: Wed, 16 Apr 2008 11:26:18 +0300 Subject: How is GUI programming in Python? In-Reply-To: <69795448-0534-4aed-a9a0-84f2cd3aea36@s50g2000hsb.googlegroups.com> References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> <69795448-0534-4aed-a9a0-84f2cd3aea36@s50g2000hsb.googlegroups.com> Message-ID: <36e8a7020804160126j17b9f0c8r11986ff2d3cec8c7@mail.gmail.com> So many gui toolkits, designers.... none of them makes up half of Delphi... unfortunately... i try to use Boa now, easiest of all others on linux/python, but it is far away from Delphi- delphi like... Why dont those toolkits/designers come together and build a single, powerfull ide ? 2008/4/16, bockman at virgilio.it : > On 11 Apr, 20:19, Rune Strand wrote: > > On Apr 10, 3:54 am, Chris Stewart wrote: > > ... > > > > > > > > > Next, what would you say is the best framework I should look into? > > > I'm curious to hear opinions on that. > > > > GUI-programming in Python is a neanderthal experience. What one may > > love with console scripts is turned upside-down. Projects like Boa > > Constructor seemed to be a remedy, but is not developed. The Iron- > > Pythonistas has a very promising RAD GUI-tool in the IronPython - > > Studio,http://www.codeplex.com/IronPythonStudio- but if you're non- > > Iron, only sorrow is left - unless you fancy creating GUI in a text- > > editor. Something I consider waste of life. > > If you refer to lack of GUI designer, every toolkit usable by python - > barring Tkinter - has a GUI > designer wich can be used: > > pygtk -> Glade > pywx -> wxDesigner, rxced, ... > pyqt -> QDesigner, ... > > All can generate python code and/or generate files that can be used by > python program to > create the whole GUI with a few function calls (e.g. libglade ). > > If you refer to the lack of visual programming ala visualstudio or > JBorland, you might be right, > but I personally found that visual programming makes for very > unmaintenable code, especially if you have to > fix something and you don't have the IDE with you (and this has > happened many times to me). > Therefore I now prefer a clean separation between the GUI (described > in someting like glade files or .xrc files) > and my code. > > BTW, once learned to use the right layout managers, even building a > GUI from scratch is not such a PITA, since you > don't have to manually place each widget anymore, but only define the > structure of packers and grids and then > adjust borders and such with some -limited IME - experimentation. I > know people that prefer this approach to any GUI builder, having > developed their own little library to help reducing the boilerplate > (and in Python you can do nice things with decorators ans such ... ). > > So maybe yes, in python you might not have the fancy world of visual > programming, but neither are deprived of tools > that make your work easier. > > Ciao > ----- > FB > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From nick at stinemates.org Sat Apr 26 01:04:54 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 25 Apr 2008 22:04:54 -0700 Subject: multiple pattern regular expression In-Reply-To: References: <1209131456.20871.1249849011@webmail.messagingengine.com> Message-ID: <20080426050454.GA15172@deviL> On Fri, Apr 25, 2008 at 08:40:55PM -0400, Carsten Haese wrote: > Nick Stinemates wrote: >> On Fri, Apr 25, 2008 at 09:50:56AM -0400, python at bdurham.com wrote: >>> How about this? >>> >>> for line in file: >>> # ignore lines without = assignment >>> if '=' in line: >>> property, value = line.strip().split( '=', 1 ) >>> property = property.strip().lower() >>> value = value.strip() >>> >>> # do something with property, value >>> >>> Malcolm >> This works until you have: >> string=The sum of 2+2=4 > > Actually, it still works, because Malcolm used split()'s maxsplit > parameter. > > -- > Carsten Haese > http://informixdb.sourceforge.net > -- > http://mail.python.org/mailman/listinfo/python-list Didn't see that -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From NikitaTheSpider at gmail.com Tue Apr 8 11:13:28 2008 From: NikitaTheSpider at gmail.com (Nikita the Spider) Date: Tue, 08 Apr 2008 11:13:28 -0400 Subject: urlparse http://site.com/../../../page.html References: <9fdd0d8b-785a-4363-be6a-75f993527754@c65g2000hsa.googlegroups.com> Message-ID: In article , "monk.e.boy" wrote: > I figured it out and blogged the answer: > > http://teethgrinder.co.uk/blog/Normalize-URL-path-python/ Thanks for letting us know of a solution. You might also be interested in Fourthought's URI library which contains a function called Absolutize() to do just what you're asking. It also claims to do a better job of parsing URIs than some of the functions in stock Python library. I've been using it heavily for quite a while and it has served me well. http://4suite.org/ -- Philip http://NikitaTheSpider.com/ Whole-site HTML validation, link checking and more From nick at stinemates.org Fri Apr 25 18:34:35 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 25 Apr 2008 15:34:35 -0700 Subject: MESSAGE RESPONSE In-Reply-To: <67bs3rF2najntU2@mid.uni-berlin.de> References: <5504f9ac0804230927ncfdb91buf7fa3e181f8a9237@mail.gmail.com> <67bs3rF2najntU2@mid.uni-berlin.de> Message-ID: <20080425223435.GA12662@deviL> On Thu, Apr 24, 2008 at 06:50:44PM +0200, Diez B. Roggisch wrote: > Blubaugh, David A. schrieb: >> Dear Sir, >> Belcan has an absolute zero-tolerance policy toward material such as the >> material described. > > That pairs up nicely with them having zero knowledge about the internet. > ZING! -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From hopeorpha308 at gmail.com Sun Apr 27 07:48:27 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:48:27 -0700 (PDT) Subject: Nero 7 premium reloaded crack Message-ID: Nero 7 premium reloaded crack http://wga-cracks.crackkey.net From jeffrey at fro.man Tue Apr 15 16:48:18 2008 From: jeffrey at fro.man (Jeffrey Froman) Date: Tue, 15 Apr 2008 13:48:18 -0700 Subject: Recurring patterns: Am I missing it, or can we get these added to the language? References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: Tim Chase wrote: > def nsplit(s, delim=None, maxsplit=None): > if maxsplit: > results = s.split(delim, maxsplit) > result_len = len(results) > if result_len < maxsplit: > results.extend([''] * (maxsplit - result_len) > return results > else: > return s.split(delim) I'll add a couple more suggestions: 1. Delay the test for maxsplit, as str.split() does the right thing if maxsplit is None. 2. Use a generator to pad the list, to avoid interim list creation. This works fine, because list.extend() accepts any iterable. This also shortens the code a bit, because xrange() does the right thing in this case with negative numbers. For example: def nsplit(s, delim=None, maxsplit=None): results = s.split(delim, maxsplit) if maxsplit is not None: results.extend('' for i in xrange(maxsplit - len(results))) return results Jeffrey From reachmsn at hotmail.com Tue Apr 15 03:57:19 2008 From: reachmsn at hotmail.com (reachmsn at hotmail.com) Date: Tue, 15 Apr 2008 00:57:19 -0700 (PDT) Subject: Cannot understand the detailedly the following code References: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> <10a83944-b17a-4c3f-992b-1754c0a5e9b1@s33g2000pri.googlegroups.com> Message-ID: On Apr 11, 10:27?am, "Gabriel Genellina" wrote: > En Thu, 10 Apr 2008 23:57:29 -0300, escribi?: > > > i.e. you give, the graph, the start and end vertices as inputs and you > > get the output as a listing of all the paths. This is where I got to. > > It would be very nice if you could kindly hint on how to proceed > > further. Thank you so much for your time! > > If you want to understand how recursion works, or how you can actually ? > construct a recursive function step by step, see this excellent post by ? > Neil Cerutti: > > http://groups.google.com/group/comp.lang.python/msg/9f0b10631fd47886 > > -- > Gabriel Genellina Hi, I did read the post by Neil Cerutti, but I still am unable to write this recursive function. I will appreciate it if someone can kindly guide me. Thanks, Anshu From hat at se-162.se.wtb.tue.nl Tue Apr 8 08:45:35 2008 From: hat at se-162.se.wtb.tue.nl (A.T.Hofkamp) Date: Tue, 08 Apr 2008 14:45:35 +0200 Subject: Cannot understand the detailedly the following code References: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> Message-ID: On 2008-04-08, reachmsn at hotmail.com wrote: [deleted a long piece of text by our BDFL about recursive graph path-finding algorithm] > after first writing the inductive part ... for node in > graph[start] .... > and then by trial and error put square brackets around path in the > Basis part. Can someone please explain how to write this code. Thanks! The same as any other function. (the trick with recursive functions is not to think about recursion. Instead, pretend you are calling another function that happens to have the same name.) As for the actual procedure of writing a function: First define the input and output parameters/values of the function. (ie what goes in, and what comes out) For recursive functions, there are always two cases, a terminating case, and a reduction case. In the first case, you may not use the recursive function, in the latter function you should. Both cases should use the information available from the input parameters, and provide a result that matches with the output requirements of the function. Add a if/then/else that distinguishes between what case you have, and you're done. Sincerely, Albert From gnewsg at gmail.com Tue Apr 15 15:02:48 2008 From: gnewsg at gmail.com (Giampaolo Rodola') Date: Tue, 15 Apr 2008 12:02:48 -0700 (PDT) Subject: How to have unittest tests to be executed in the order they appear? Message-ID: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> Hi there. Is there a way to force unittest to run test methods in the order they appear? I'll try to explain. My test suite appears as something like this: import unittest from test.test_support import TestSkipped, run_unittest class TestCase(unittest.TestCase): def test_z(self): ... def test_b(self): ... def test_d(self): ... if __name__ == '__main__': run_unittest(TestCase) I'd like the tests to be executed in the order they are defined (test_z, test_b and finally test_d). Is there a way to do that? Thanks in advance. --- Giampaolo http://code.google.com/p/pyftpdlib/ From python at bdurham.com Mon Apr 21 12:10:49 2008 From: python at bdurham.com (python at bdurham.com) Date: Mon, 21 Apr 2008 12:10:49 -0400 Subject: Does Python 2.5.2's embedded SQLite support full text searching? Message-ID: <1208794249.15992.1249049327@webmail.messagingengine.com> Does Python 2.5.2's embedded SQLite support full text searching? Any recommendations on a source where one can find out which SQLite features are enabled/disabled in each release of Python? I'm trying to figure out what's available in 2.5.2 as well as what to expect in 2.6 and 3.0. Thank you, Malcolm From tokyo246 at gmail.com Fri Apr 4 13:29:19 2008 From: tokyo246 at gmail.com (Kenji Noguchi) Date: Fri, 4 Apr 2008 10:29:19 -0700 Subject: developing web spider In-Reply-To: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> References: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> Message-ID: <2ba587f0804041029k75a0595le3e28f56921cbb41@mail.gmail.com> Attached is a essence of my crawler. This collects tag in a given URL HTML parsing is not a big deal as "tidy" does all for you. It converts a broken HTML to a valid XHTML. From that point there're wealth of XML libraries. Just write whatever you want such as element handler. I've extended it for multi-thread, limit the number of thread for a specific web host, more flexible element handling, etc, etc. SQLite is nice for making URL db by the way. Kenji Noguchi -------------- next part -------------- A non-text attachment was scrubbed... Name: crawler.py Type: text/x-python Size: 2583 bytes Desc: not available URL: From gagsl-py2 at yahoo.com.ar Thu Apr 3 08:32:02 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 09:32:02 -0300 Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> Message-ID: En Thu, 03 Apr 2008 05:20:48 -0300, sam escribi?: > Gabriel Genellina napisa?(a): > >> Class methods and instance methods are not just standard functions; >> instance methods were plain functions before 2.2 and the Class object >> was in charge of doing the "self magic". Now the descriptor protocol >> provides far more possibilities. > > Actually I don't know what is "descriptor protocol", so maybe I should > have > finished discussing. I will aslo search for "self magic" -- some pieces > of old > code, or something. I meant the way instance methods acquire their "self" argument; the transformation from someobject.foo(arg1,arg2) into (ClassOfSomeobject.foo)(someobject, arg1, arg2) that classic classes do themselves and could not be changed nor extended. The descriptor protocol provides a way for attributes to modify the way they're handled; this is how instance methods get their self argument, and allows for the existence of class methods, static methods, and properties, among other things. The descriptor protocol is very important for Python and understanding it is a good idea, but not before you are rather fluent with the language or it will be fairly incomprehensible. -- Gabriel Genellina From jeffober at gmail.com Thu Apr 3 09:00:14 2008 From: jeffober at gmail.com (Jeff) Date: Thu, 3 Apr 2008 06:00:14 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> <88b07549-9751-489b-968f-c3d2db0aba79@s13g2000prd.googlegroups.com> Message-ID: On Apr 3, 8:44?am, Ant wrote: > On Apr 3, 12:37 pm, tinn... at isbd.co.uk wrote: > > > What's the neatest and/or most efficient way of testing if one of a > > A different approach: > > >>> words = ["he", "sh", "bla"] > >>> name = "blah" > >>> True in (word in name for word in words) > > True > > >>> name = "bling" > >>> True in (word in name for word in words) > > False > > Perhaps not as obvious or readable as Jeff's example, but is > essentially doing the same thing using generator syntax. That's pretty :) From dickinsm at gmail.com Wed Apr 9 15:35:55 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Wed, 9 Apr 2008 12:35:55 -0700 (PDT) Subject: Python 3.0 new integer division References: Message-ID: On Apr 8, 6:01 pm, Jonathan Gardner wrote: > On Apr 8, 2:25 pm, Grzegorz S?odkowicz wrote: > > > > > Isn't Decimal a BCD implementation? > > Yep, you are right and I am wrong.http://www.python.org/dev/peps/pep-0327/#why-not-rational Strictly speaking, BCD doesn't come into it: the coefficient of a Decimal instance is stored simply as a string of digits. This is pretty wasteful in terms of space: 1 byte per decimal digit instead of the 4 bits per digit that BCD gives, but it's convenient and fairly efficient. An alternative representation that's gained popularity recently is DPD (densely packed decimal), which packs 3 decimal digits into 10 bits in a clever way that allows reasonably efficient extraction of any one of the 3 digits. Decimal doesn't use this either. :) Mark From python at bdurham.com Mon Apr 28 14:07:42 2008 From: python at bdurham.com (python at bdurham.com) Date: Mon, 28 Apr 2008 14:07:42 -0400 Subject: How to unget a line when reading from a file/stream iterator/generator? Message-ID: <1209406062.7586.1250312147@webmail.messagingengine.com> Is there an elegant way to unget a line when reading from a file/stream iterator/generator? By "unget" I mean a way to push back a line into the source stream and backtrack the iterator/generator one step? The only alternative I can see is to put my line reading in a while-True loop (vs. a for-loop) that manually calls my file/stream iterator/generator's .next() method while manually handling the StopIteration exception. Doesn't sound too elegant. Is there a Pythonic design pattern/best practice that I can apply here? Thank you, Malcolm From buzzard at urubu.freeserve.co.uk Tue Apr 15 15:07:14 2008 From: buzzard at urubu.freeserve.co.uk (duncan smith) Date: Tue, 15 Apr 2008 20:07:14 +0100 Subject: Preferred method for "Assignment by value" In-Reply-To: <7047986d-f6cc-4189-81f6-47da1ecf1902@k1g2000prb.googlegroups.com> References: <6a3ed8f0-b82c-4cd3-b36e-1d94f8a30fe3@n1g2000prb.googlegroups.com> <7047986d-f6cc-4189-81f6-47da1ecf1902@k1g2000prb.googlegroups.com> Message-ID: hall.jeff at gmail.com wrote: > Thank you both, the assigning using slicing works perfectly (as I'm > sure you knew it would)... It just didn't occur to me because it > seemed a little nonintuitive... The specific application was > > def dicttolist (inputdict): > finallist=[] > for k, v in inputdict.iteritems(): > temp = v > temp.insert(0,k) > finallist.append(temp) > > return finallist > Maybe, finallist = [[k] + v for k, v in inputdict.iteritems()] the list concatenation creating new lists. Duncan From ivan.illarionov at gmail.com Sun Apr 13 13:43:32 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Sun, 13 Apr 2008 10:43:32 -0700 (PDT) Subject: Looking for a way to include Pyhtho scripting INSIDE a python program References: <48017af0$0$36399$742ec2ed@news.sonic.net> Message-ID: <6c5bca34-71b7-4ebb-8ae9-cf894fac5168@c19g2000prf.googlegroups.com> On Apr 13, 8:20 pm, Bryan Oakley wrote: > Ivan Illarionov wrote: > > You don't need to envoke another interpreter. > > Python can interpret arbitrary python code with exec statement. > > Wrap user's string inside function definition, and exec it. > > > You might want to disable words like `import`, `exec` and `eval` in > > user's code because it's a big security risk. > > The above statement is exactly why one would want to eval the code > inside a separate interpreter. Not just for security, but to prevent > user code from stomping all over the application code by creating or > destroying global resources. > > Is it possible to create a nested interpreter like you can do in some > other languages? Yes. Call PyRun_SimpleString from ctypes or call PyRun_SimpleString from custom python extension. But it does nothing what exec can't do. We have: exec `something` in `where_we_exec` if `where_we_exec` is an empty dictionary the exec'd code has no access to app code or global resources. Even more, it's harder to control the nested interpreter than strings about to be exec'd. And you still have to worry about security. So, not only you gain nothing by this approach, you make your software more vulnerable. The code like `import os\n os.*killme*` or eval("__import__('os').*killme*") will be harder to disable. -- Ivan From huayang.xia at gmail.com Fri Apr 11 09:37:23 2008 From: huayang.xia at gmail.com (Huayang Xia) Date: Fri, 11 Apr 2008 06:37:23 -0700 (PDT) Subject: Convert PyIDispatch object to struct IDispatch* References: <90eee1e1-b1cc-48a9-8c09-173e92861f2c@a5g2000prg.googlegroups.com> Message-ID: <83260aaf-b2d7-4857-bd71-a8e7b30c6d70@n14g2000pri.googlegroups.com> On Apr 11, 12:15 am, "Gabriel Genellina" wrote: > En Thu, 10 Apr 2008 18:45:04 -0300, Huayang Xia > escribi?: > > > I am trying to use ctypes to call dll functions. One of the functions > > requires argument "struct IDispatch* ". I do have a PyIDispatch object > > in python. How can I convert this "PyIDispatch object" to "struct > > IDispatch* "? > > I think a PyIDispatch object is an IDispatch* itself. > But you'll get better answers from the python-win32 list:http://mail.python.org/mailman/listinfo/python-win32 > > -- > Gabriel Genellina Thanks for the info. To call a dll function, it needs a C style IDispatch*. PyIDispatch is a python wrapped one. I found a reference from: http://svn.python.org/projects/ctypes/trunk/comtypes/comtypes/test/test_win32com_interop.py which shows how to convert C style to python style. Unfortunately i need the reversed version. I will post the question to python-win32. From fn681 at ncf.ca Mon Apr 7 19:31:36 2008 From: fn681 at ncf.ca (Colin J. Williams) Date: Mon, 07 Apr 2008 20:31:36 -0300 Subject: A funnily inconsistent behavior of int and float In-Reply-To: References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com> <1d11875a-470a-489f-910a-b420a145eb61@a1g2000hsb.googlegroups.com> Message-ID: Terry Reedy wrote: > "Mark Dickinson" wrote in message > news:1d11875a-470a-489f-910a-b420a145eb61 at a1g2000hsb.googlegroups.com... > | On Apr 7, 6:43 am, "Colin J. Williams" wrote: > | > This is good but the documentation for > | > 3.0 is missing the syntax documentation > | > from 2.5 > | > | Is > | > | > http://docs.python.org/dev/3.0/reference/lexical_analysis.html#integer-literals > | > | the documentation that you're looking for? Yes, thanks. I missed it. Colin W. > | > | But it seems to me that Lie's original point isn't really > | about integer *literals* anyway---it's about the behaviour > | of the built-in int() function when applied to a string. So > | > | http://docs.python.org/dev/3.0/library/functions.html#int > | > | is probably the appropriate place in the documentation. And > | I agree that it could be made clearer exactly what strings are > | acceptable here. > > Agreed. > > It says "If radix is zero, the interpretation is the same as for integer > literals." > But integer literals are unsigned. Is radix 0 any different from the > default of radix 10? > > It also says "If the argument is a string, it must contain a possibly > signed number of arbitrary size, possibly embedded in whitespace." But > only integers, not 'numbers' as some would understand that, are accepted. > > My suggestions: > 1. Change signature to: int([number | string[, radix]). > This makes it clear that radix can only follow a string without having to > say so in the text. > > 2. Replace text with: > Convert a number or string to an integer. If no arguments are given, > return 0. If a number is given, return number.__int__(). Conversion of > floating point numbers to integers truncates towards zero. A string must > be a base-radix integer literal optionally preceded by '+' or '-' (with no > space in between) and optionally surrounded by whitespace. A base-n > literal consists of the digits 0 to n-1, with 'a' to 'z' (or 'A' to 'Z') > having values 10 to 35. The default radix is 10. The allowed values are 0 > and 2-36, with 0 the same as 10. > > If 0 is not the same as 10, the last would have to be changed, but I could > not detect any difference in a quick test. > > After looking at any comments here, I will consider submitting these to the > tracker. > > Terry Jan Reedy > > > From samslists at gmail.com Thu Apr 3 22:29:18 2008 From: samslists at gmail.com (samslists at gmail.com) Date: Thu, 3 Apr 2008 19:29:18 -0700 (PDT) Subject: Any fancy grep utility replacements out there? References: Message-ID: Thanks to everyone who responded, and sorry for my late response. Grin seems like the perfect solution for me. I finally had a chance to download it and play with it today. It's great. Robert...you were kind enough to ask if I had any requests. Just the one right now of grepping through gzip files. If for some reason you don't want to do it or don't have time to do it, I could probably do it and send you a patch. But I imagine that since you wrote the code, you could do it more elegantly than I could. Thanks! P.S. Robert....this program totally deserves a real web page, not just being buried in an svn repository. I spent a lot of time looking for a tool like this that was written in python. I imagine others have as well, and have simply given up. On Mar 18, 7:16 pm, Robert Kern wrote: > I have agrep-like utility I call "grin". I wrote it mostly to recursivelygrep > SVN source trees while ignoring the garbage under the .svn/ directories and more > or less do exactly what I need most frequently without configuration. It could > easily be extended to open gzip files with GzipFile. > > https://svn.enthought.com/svn/sandbox/grin/trunk/ > > Let me know if you have any requests. From saluk64007 at gmail.com Mon Apr 21 21:15:48 2008 From: saluk64007 at gmail.com (Patrick Mullen) Date: Mon, 21 Apr 2008 18:15:48 -0700 Subject: Python 2.5 adoption In-Reply-To: References: <1da03626-2d4b-4e01-ba47-93f9d5c8f57f@l64g2000hse.googlegroups.com> Message-ID: On Mon, Apr 21, 2008 at 1:49 PM, Jorgen Grahn wrote: > OP: keep in mind that your users do not see any gain from you using > 2.5. All they see is something that makes your software harder to > install. At some point you can dismiss them as living in the Stone Age, > but the Stone Age is currently 2.1 or something. Maybe 2.2 is, too. Except for the memory bug which 2.5 fixed (not giving memory back), which in some cases with 2.4 could be a really large issue. But in that case you get the benefit whether it was "coded for" 2.5 or not. So it is still safest to develop for a lower common denominator. For me, the best things about 2.5 were the memory fixes/performance, and the inclusion of ctypes in the standard library. The language upgrades are mostly corner cases. If I were the OP, and those corner situations aren't too big of an issue, I would restrict my usage to 2.4 or even 2.3 to allow easier adoption of the software. From asmodai at in-nomine.org Wed Apr 30 10:43:03 2008 From: asmodai at in-nomine.org (Jeroen Ruigrok van der Werven) Date: Wed, 30 Apr 2008 16:43:03 +0200 Subject: best way to host a membership site In-Reply-To: <53034dcc-7346-4f71-889c-3278c9e813ec@w1g2000prd.googlegroups.com> References: <53034dcc-7346-4f71-889c-3278c9e813ec@w1g2000prd.googlegroups.com> Message-ID: <20080430144303.GH56542@nexus.in-nomine.org> -On [20080430 02:16], Magdoll (magdoll at gmail.com) wrote: >Also I want an infrastructure that's not too rigid so if in the future I >want to add more apps it's not to hard. Not to belittle Django, but for what I wanted to do with it, it was too restraining. I instead went with a combination of: Werkzeug - http://werkzeug.pocoo.org/ SQLAlchemy - http://www.sqlalchemy.org/ Genshi - http://genshi.edgewall.org/ (although some people might prefer Jinja is they like Django's templating - http://jinja.pocoo.org/) Babel - http://babel.edgewall.org/ This provided me with a lot of flexibility, more than Django could've provided me with (but hey, welcome to the general limitation of frameworks). -- Jeroen Ruigrok van der Werven / asmodai ????? ?????? ??? ?? ?????? http://www.in-nomine.org/ | http://www.rangaku.org/ | GPG: 2EAC625B The human race is challenged more than ever before to demonstrate our mastery -- not over nature but of ourselves... From sturlamolden at yahoo.no Thu Apr 17 11:19:44 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 17 Apr 2008 08:19:44 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> Message-ID: On 17 Apr, 10:25, "Martin v. L?wis" wrote: > help progress at all. I think neither was the case in this thread - > the guy claimed that he actually did something about the GIL, and > now we are all waiting for him to also tell us what it is that he > did. Ok, I did not remove the GIL, but I found a way to remove its notorious side effect on SMPs. So I am going to reveal it now. Forgive my strange sence of humor at 3 o'clock in the morning. First, think about this: (1) What is the GIL? (2) Where does it live? (3) How can it be manually released? The answer to this is: (1) A critical section (a lock/mutex object) (2) As a global object in Python25.dll on my computer (3) Using Python's C API or calling methods in a ctypes.CDLL object The Python C API has the ability to embed Python interpreters. You do this by importing Python25.dll into the process. ctypes has the ability to call functions in a DLL. So is it possible to embed Python in Python? And what would be consequence be? First, if I try to load a DLL more than once, Windows will detect this and just give me a handle to the currently imported library. So by importing Python25.dll with ctypes, I can just make my Python interpreter talk to itself through its own CAPI. Yes I can create sub interpreters using PyNew_Interpreter, but they all share the same GIL, so it's not useful here. So here is what I suddendly realized, and please don't laugh, its so simple its almost silly: I make some copies of Python25.dll, and call them Python25-1.dll, Python25-2.dll, Python25-3.dll, Python25-4.dll, etc. Then I load them all into my current Python process as ctypes.CDLL objects. Tada! I now have a pool of independent Python interpreters, not sharing the GIL, but still living in the same process. I can make the different interpreters talk to each other, including manipulating each other's GIL, using the using ctypes and Python's C API for embedding. So why does this circumvent the GIL? Because ctypes releases it before calling functions form a CDLL object. If I use my main interpreter to delegate a task to one of its embedded 'children', its GIL will be released while it is waiting for the answer. Associating each embedded interpreter with a threading.Thread is all that remains. The GIL is released while the thread operating the child interpreter is blocked. An there you have the answer. It's really very simple :-) Regards, Sturla Molden From fetchinson at googlemail.com Tue Apr 15 23:31:52 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Tue, 15 Apr 2008 20:31:52 -0700 Subject: Interesting timing issue I noticed In-Reply-To: References: Message-ID: On 4/15/08, Daniel Fetchinson wrote: > > Can I then simply ignore the time data then? I do see better performance > > obviously the smaller the box is, but I guess my issues is how seriously > to > > take all this data. Because I can't claim "performance improvement" if > there > > isn't really much of an improvement. > > > > On Tue, Apr 15, 2008 at 11:04 PM, Daniel Fetchinson < > > fetchinson at googlemail.com> wrote: > > > > > > I've written up a stripped down version of the code. I apologize for > > > the bad > > > > coding; I am in a bit of a hurry. > > > > > > > > import random > > > > import sys > > > > import time > > > > > > > > sizeX = 320 > > > > sizeY = 240 > > > > borderX = 20 > > > > borderY = 20 > > > > > > > > # generates a zero matrix > > > > def generate_zero(): > > > > matrix = [[0 for y in range(sizeY)] for x in range(sizeX)] > > > > return matrix > > > > # fills zero matrix > > > > def fill_matrix(in_mat): > > > > mat = in_mat > > > > for x in range(sizeX): > > > > for y in range(sizeY): > > > > mat[x][y] = random.randint(1, 100) > > > > return mat > > > > ###################################################################### > > > > # COMPUTES ONLY A PART OF THE ARRAY > > > > def back_diff_one(back_array, fore_array, box): > > > > diff_array = generate_zero() > > > > > > > > start = time.time() > > > > for x in range(sizeX): > > > > for y in range(borderY): > > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > > for y in range((sizeY - borderY), sizeY): > > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > > for y in range(borderY, (sizeY - borderY)): > > > > for x in range(borderX): > > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > > for x in range((sizeX - borderX), sizeX): > > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > > > > > > # tracks object > > > > if (len(box) != 0): > > > > for x in range(box[0], box[2]): > > > > for y in range(box[1], box[3]): > > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > > print "time one inside = " + str(time.time() - start) > > > > return diff_array > > > > ###################################################################### > > > > # COMPUTES EVERY ELEMENT IN THE ARRAY > > > > def back_diff_two(back_array, fore_array): > > > > diff_array = generate_zero() > > > > start = time.time() > > > > for y in range(sizeY): > > > > for x in range(sizeX): > > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > > end = time.time() > > > > print "time two inside = " + str(end - start) > > > > return diff_array > > > > ###################################################################### > > > > # CODE TO TEST BOTH FUNCTIONS > > > > back = fill_matrix(generate_zero()) > > > > fore = fill_matrix(generate_zero()) > > > > box = [20, 20, 268, 240] > > > > start1 = time.time() > > > > diff1 = back_diff_one(back, fore, box) > > > > print "time one outside = " + str(time.time() - start1) > > > > start2 = time.time() > > > > diff2 = back_diff_two(back, fore) > > > > print "time one outside = " + str(time.time() - start2) > > > > > > > > Here are some results from several test runs: > > > > > > > > time one inside = 0.0780000686646 > > > > time one outside = 0.125 > > > > time two inside = 0.0780000686646 > > > > time two outside = 0.141000032425 > > > > >>> ================================ RESTART > > > > ================================ > > > > >>> > > > > time one inside = 0.0629999637604 > > > > time one outside = 0.125 > > > > time two inside = 0.0789999961853 > > > > time two outside = 0.125 > > > > >>> ================================ RESTART > > > > ================================ > > > > >>> > > > > time one inside = 0.0620000362396 > > > > time one outside = 0.139999866486 > > > > time two inside = 0.0780000686646 > > > > time two outside = 0.125 > > > > >>> ================================ RESTART > > > > ================================ > > > > >>> > > > > time one inside = 0.0780000686646 > > > > time one outside = 0.172000169754 > > > > time two inside = 0.0789999961853 > > > > time two outside = 0.125 > > > > >>> ================================ RESTART > > > > ================================ > > > > >>> > > > > time one inside = 0.0780000686646 > > > > time one outside = 0.125 > > > > time two inside = 0.0780000686646 > > > > time two outside = 0.125 > > > > >>> ================================ RESTART > > > > ================================ > > > > >>> > > > > time one inside = 0.0620000362396 > > > > time one outside = 0.155999898911 > > > > time two inside = 0.0780000686646 > > > > time two outside = 0.125 > > > > >>> ================================ RESTART > > > > ================================ > > > > >>> > > > > time one inside = 0.077999830246 > > > > time one outside = 0.125 > > > > time two inside = 0.077999830246 > > > > time two outside = 0.125 > > > > >>> ================================ RESTART > > > > ================================ > > > > >>> > > > > time one inside = 0.0780000686646 > > > > time one outside = 0.171000003815 > > > > time two inside = 0.077999830246 > > > > time two outside = 0.125 > > > > >>> ================================ RESTART > > > > ================================ > > > > >>> > > > > time one inside = 0.0629999637604 > > > > time one outside = 0.18799996376 > > > > time two inside = 0.0620000362396 > > > > time two outside = 0.125 > > > > > > > > Why is a large percentage of the time, the execution time for the > > > > (ostensibly smaller) first loop is actually equal to or LARGER than > the > > > > second? > > > > > > > > > First of all, your method of timing is not the best. Use the timeit > > > module instead: http://docs.python.org/lib/module-timeit.html > > > > > > Second of all the number of subtractions is not that different between > > > the two variants of your functions. back_diff_one does 75360 > > > subtractions per call while back_diff_two does 76800, these two > > > numbers are almost the same. It's true that back_diff_one first only > > > calculates a part of the arrays but after "# tracks object" you do a > > > bunch of more substractions that will make up the total count. > > > > > > HTH, > > > Daniel > > > > > Please keep the discussion on the list. > > Yes, if I were you I would discard your original timing data and redo > it using the timeit module. Whatever that gives should be reliable and > you can start from there. In any case your two functions are doing > roughly the same number of operations. > > HTH, > Daniel > BTW, using the following ###################################################################### # CODE TO TEST BOTH FUNCTIONS back = fill_matrix(generate_zero()) fore = fill_matrix(generate_zero()) box = [20, 20, 268, 240] def test1( ): diff1 = back_diff_one(back, fore, box) def test2( ): diff2 = back_diff_two(back, fore) if __name__=='__main__': from timeit import Timer t = Timer("test1( )", "from __main__ import test1") print t.timeit( 50 ) t = Timer("test2( )", "from __main__ import test2") print t.timeit( 50 ) and removing all your timing code from the two functions gives 1.63772082329 1.82889485359 which is consistent with your expectation that the version that computes only a part of the image runs faster. But only marginally, which is again consistent with the fact that the number of operations is only marginally different. HTH, Daniel From bignose+hates-spam at benfinney.id.au Fri Apr 18 20:53:15 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Sat, 19 Apr 2008 10:53:15 +1000 Subject: How to print a unicode string? References: <87d4omsovf.fsf@benfinney.id.au> <4edea21e-d45c-4467-a66d-e270365eb812@l64g2000hse.googlegroups.com> Message-ID: <878wzasm10.fsf@benfinney.id.au> damonwischik at gmail.com writes: > On Apr 19, 12:51 am, Ben Finney wrote: > > Just because the locale library knows the normalised name for it > > doesn't mean it's available on your OS. Have you confirmed that > > your OS (independent of Python) supports the locale you're trying > > to set? > > No. How do I found out which locales my OS supports? (I'm running > Windows XP.) Can't help you there. > Why does it matter what locales my OS supports, when all I want is > to set the encoding to be used for the output Because the Python 'locale' module is all about using the OS's (actually, the underlying C library's) locale support. The locale you request with 'locale.setlocale' needs to be supported by the locale database, which is independent of any specific application, be it Python, Emacs, or otherwise. -- \ "Two rules to success in life: 1. Don't tell people everything | `\ you know." -- Sassan Tat | _o__) | Ben Finney From deets at nospam.web.de Sun Apr 6 17:17:05 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Sun, 06 Apr 2008 23:17:05 +0200 Subject: How to create an exe-file? In-Reply-To: <8da70474-6ade-4515-8346-8f02a04ff24e@b9g2000prh.googlegroups.com> References: <311a216f-5366-47c5-86a7-431dd23ced3e@j1g2000prb.googlegroups.com> <8da70474-6ade-4515-8346-8f02a04ff24e@b9g2000prh.googlegroups.com> Message-ID: <65ssuoF2h8gpeU1@mid.uni-berlin.de> skanemupp at yahoo.se schrieb: > On 6 Apr, 22:50, Fredrik Lundh wrote: >> skanem... at yahoo.se wrote: >>> how do you create exe-files of your python-code? >>> is it different depending on what libraries, GUI-frameworks you use? >>> i want to create an exe-file of a pythonscript that uses Tkinter. >> assuming windows only, you want: >> >> http://www.py2exe.org/ >> >> also see: >> >> http://effbot.org/zone/python-compile.htm >> >> > > > ty. > > a good thing about python is the portability though. but u cant make > an exe that can be used on mac too, ie one exe fpr both? No. But you can use the same python-sources, without any or only a few platform specific changes. > if i want to make an exe for mac, what do i need? google py2app. Diez From toddw at activestate.com Thu Apr 17 15:28:23 2008 From: toddw at activestate.com (Todd Whiteman) Date: Thu, 17 Apr 2008 12:28:23 -0700 Subject: Python plugin for Firefox In-Reply-To: References: Message-ID: <4807A4D7.8090305@activestate.com> zelegolas wrote: > Hi, > > It's may be a stupid question but do you if someone tried to create a > python plugin for firefox? > If you know an Open Source project let me know... > > Thanks This was asked just recently on the list (included responses below): Joe P. Cool wrote: > > In 2005 I heard of plans to add Python as a second language to the > > Gecko engine. Is this still true? Or has this plan been abandoned? > > You can use Python inside of Mozilla (Gecko) based applications now, such as Firefox/Thunderbird/Komodo Edit/XulRunner which communicate through the Mozilla XPCOM architecture. There are builds of PyXPCOM (Python XPCOM) that can be downloaded and easily installed through the xpi extension mechanism, see: http://pyxpcomext.mozdev.org/ The Mozilla 1.9 branch (Gecko 1.9) also contains the hooks necessary to be able to use Python as a script handler, instead of having to use JavaScript. This is commonly referred to as PyDOM. To get and use PyXPCOM (Mozilla 1.8 and Mozilla 1.9): * install the above extension * or make your own build of the Mozilla application To get and use PyDOM (Mozilla 1.9): * you'll need to make your own build of the Mozilla application I'm the one working on the PyXPCOM extension, which I am hoping will eventually contain the PyDOM module as well (once I get around to making new Mozilla builds with this enabled). Cheers, Todd From steve.j.donovan at gmail.com Mon Apr 14 09:01:24 2008 From: steve.j.donovan at gmail.com (SteveD) Date: Mon, 14 Apr 2008 06:01:24 -0700 (PDT) Subject: pgdb: Debugging Python extensions made easier Message-ID: Hi guys, http://luaforge.net/frs/?group_id=327 pgdb.zip is an addition to scite-debug, which adds source debugging to the popular SciTE programmer's editor. gdbpy.zip is a standalone version which can be run from Emacs. These allow you to single-step from Python to C code in a debugger session. To use pgdb, install scite-debug (either on top of an existing SciTE installation or with one of the packaged all-in-one versions) and unzip into the same directory. gdbpy requires Lua 5.1, but there are no other dependencies. In both cases, read the release notes. I know the FAQ says that this is not possible, but the FAQ is somewhat outdated. GDB is quite happy with pending breakpoints to unresolved libraries, but you have to reassure it. This technique is a generalization of one that I used to solve the equivalent problem with debugging Lua extensions. steve d. From spocksplanet at gmail.com Thu Apr 17 04:30:50 2008 From: spocksplanet at gmail.com (sp@k) Date: Thu, 17 Apr 2008 01:30:50 -0700 (PDT) Subject: Newbie question about for...in range() structure Message-ID: Hi there, I'm new to Python and I've been writing a rudimentary exercise in Deitel's Python: How to Program, and I found that this code exhibits a weird behavior. When I run the script, the for...range(1,11) structure always starts with zero--and I've tried plugging other values as well! >From the Python commandline, though, this structure produces a normal 1,2,3,4,5,6,7,8,9,10 output. Can anyone tell me what I am doing wrong here? input = raw_input("Please enter a value you wish to factorialize:") def fact(n): total = 0 n = int(n) while n > 0: total *= n n -=1 return total print "%d" % fact(input) e = 1 for val in range(1,11): if val == 0: continue else: e += 1/fact(val) print "Where n is 10, e = %d\n\n" % e e2 = 1 input = raw_input("Enter x:") for val in range(1,11): if val == 0: continue else: e2 += (float(input) ** val)/(fact(val)) print "Where the n is 10, e**x = %d\n\n" %e From victorsmiller at gmail.com Sun Apr 13 23:50:07 2008 From: victorsmiller at gmail.com (VictorMiller) Date: Sun, 13 Apr 2008 20:50:07 -0700 (PDT) Subject: urllib working differently when run from crontab Message-ID: I've written a python script which, using urllib, and urllib2 will fetch a number of files that that I'm interested in from various websites (they're updated everyday). When I run the script from my command line everything works as intended. However, when the script is run from crontab every single url that I attempt to open gets "connection refused". Has anyone ever seen anything like this? If so, what's causing it, and what can I do about it? Victor From skanemupp at yahoo.se Sat Apr 5 18:19:59 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 15:19:59 -0700 (PDT) Subject: Best way to check if string is an integer? Message-ID: which is the best way to check if a string is an number or a char? could the 2nd example be very expensive timewise if i have to check a lot of strings? this value = raw_input() try: value = int(value) except ValueError: print "value is not an integer" or: c=raw_input("yo: ") if c in '0123456789': print "integer" else: print "char" or some other way? From upton at virginia.edu Tue Apr 1 14:00:19 2008 From: upton at virginia.edu (Dan Upton) Date: Tue, 1 Apr 2008 14:00:19 -0400 Subject: Homework help In-Reply-To: <65fagoF2fiivoU1@mid.uni-berlin.de> References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> <65fagoF2fiivoU1@mid.uni-berlin.de> Message-ID: <5504f9ac0804011100t38c5237bm5e68449b9b6a92ce@mail.gmail.com> > > Write a function zip(lst1, lst2) such that zip accepts two equal > > length lists and returns a list of pairs. For example, zip(['a', 'b', > > 'c'], [10, 20, 30]) should evaluate to the list [('a', 10), ('b', 20), > > ('c', 30)]. > > Hey not even a rebinding necessary. :-) > We had some exercises like this in Scheme in my undergrad programming languages class (specifically, rewriting map/mapcar). It's not that the method doesn't already exist in the language, it's more about understanding what's going on at a lower level. From gagsl-py2 at yahoo.com.ar Sat Apr 5 16:04:41 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 05 Apr 2008 17:04:41 -0300 Subject: Adding Images To MySQL References: <4dc0cfea0804050732x7dc2ac41n64d56dda9da27a82@mail.gmail.com> Message-ID: En Sat, 05 Apr 2008 11:32:00 -0300, Victor Subervi escribi?: >> * *- You say Content-Type: image/jpeg but you emit HTML code. You're >> lucky > if you see any > >> * *text at all. > > Well, I tried Content-Type: text/html and that threw an HTTP 500 Error. If your script raised any exception, that's the expected code. (500 = internal error = your code has errors). But it's not very useful for debugging; using cgitb or wrapping the code in try/except as has already been suggested, lets you see the exception and traceback. >> * *- HTTP 200 is not an error, it means the request was successful. > > When it doesn?t execute the code, how can it be called successful? If it > doesn?t execute the code, how can you say it?s not an error? What is it, > then? Well, your web server thinks all went ok... BTW, you did't provide details about it, I *guess* you're using CGI because of the print "Content-Type" line. >> * *- As a general advice, try to isolate the problems. Test the database > stuff alone, in a local >> * *application. Test the cgi script alone, without database interaction. > Test the database stuff in >> * *the web server (better if you have a shell account). Merge all and >> test > again. > > Very good advice. Please help me understand how to do that. > > This is what I have done. I have tried these: > > sql = "'insert into products (" + col_names + ") values (" + val + ")', > (" + > col_names + ")" > > cursor.execute(sql) > > and > > sql = "'insert into products (" + col_names + ") values (" + val + ")'" > > cursor.execute(sql, (col_names,)) > > Neither work. You got a syntax error, I guess. What's that ' at the start? I'll try to explain it from the ground up. This would be a valid SQL statement:: insert into PRODUCTS (PRODID, NAME, DESCRIPTION) values (123, 'Easter egg 80g', 'A longer description'); In Python, you need the SQL text inside a string:: sql = "insert into PRODUCTS (PRODID, NAME, DESCRIPTION) " \ "values (123, 'Easter egg 80g', 'A longer description');" and you can execute it with:: cursor.execute(sql) That would be OK when you create the database for the first time. Later your boss comes in and says: "We've got bigger eggs! Code 124, 150g each. We need them in the database". You write an sql statement similar to above. Some days later, they decide to sell bubble gum. Forty-two different sizes and flavors and brands. You don't want to write all that sql statements by hand. Your first thought is to build the sql text by pieces:: sql = "insert into PRODUCTS (PRODID, NAME, DESCRIPTION) " \ "values ("+str(prodid)+", '"+prodname+"', '"+description+"');" But then you remember to have read something about sql injection and you don't like that mess of " + ) ' ( anyway. After reading some articles about DBAPI 2, PEP 249, the MySQLdb module, you write this:: sql = "insert into PRODUCTS (PRODID, NAME, DESCRIPTION) " \ "values (%s,%s,%s);" cursor.execute(sql, (prodid, prodname, description)) and it works fine. Note that execute has two arguments: first, a string with the sql statement text; second, a tuple containing the values. The %s in the sql text are placeholders, they're replaced with the corresponding value from the second argument. And there is no ' anywhere. > However, if I print what that code spits out: > > sql = "'insert into products (" + col_names + ") values (" + val + ")', > (" + > col_names + ")" > > print sql > > then copy and paste it into a cursor.execute() statement, viola! > Everything > works _just_fine_. Go figure. Why?? What you have done has no sense - why do you think it should work? py> a = "2 " + ", " + "3" py> pow(a) Traceback (most recent call last): File "", line 1, in TypeError: pow expected at least 2 arguments, got 1 py> print a 2 , 3 py> pow(2 , 3) 8 Your first attempt used a long string with embedded quotes, it is a *single* argument to execute. If you print it and interpret the result as Python code, there are two items: now you are passing *two* arguments to execute. > pic1 = _mysql.escape_string(f) > > It does not like this (forgot error): > > pic1 = MySQLdb.Binary(f) You should make the above work. Look at the exception, read the error message, look at the traceback. There are a lot of info there. > Escaping the string, I can successfully load this image into the > database, > along with all the other fields. Now, when I load an image from the form > on > the previous page with this code: > > > print '"', MySQLdb.Binary(data[14]), '"' > > and send the form off to the next page, when I process it on that page Why do you do *that*??? That element is for the user to upload a file; if the file is already on the server, why do you transfer it from server to client and back to server? I doubt it can work this way. And why are you using Binary here? Binary is for sql stuff and you're building an HTML page here. (btw, didn't you say that Binary doesn't work?). > pic1 = _mysql.escape_string(pic1) > > print pic1 > > it prints out a messy binary that (almost) starts with something like > ?This > program can only be run in Win32?, whatever that means. But a binary is > printed. (It may be an infinite binary, I stopped it after a few > minutes.) Looks like a .exe; somehow you managed to upload a .exe instead of a jpg, I presume... > Now, if I stick it into the cursor.execute like I did above, it throws an > HTTP non-error non-posting-to-the-database 200 error. I?m more than > happy to > separate all this garbage out for further testing, but I don?t know how > to > do that. Your help is very much appreciated. It seems you have a basic misunderstanding of how web applications work. Reading a book like "Python Web Programming" by Steve Holden might help. http://www.amazon.com/Python-Programming-Landmark-Steve-Holden/dp/0735710902 -- Gabriel Genellina From bruno.desthuilliers at gmail.com Sat Apr 19 14:33:41 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Sat, 19 Apr 2008 11:33:41 -0700 (PDT) Subject: why function got dictionary References: <48075950.7050000@gmail.com> Message-ID: On 19 avr, 19:39, sturlamolden wrote: > On Apr 17, 4:06 pm, AlFire wrote: > > > Q: why function got dictionary? What it is used for? > > As previously mentioned, a function has a __dict__ like (most) other > objects. > > You can e.g. use it to create static variables: > > int foobar() > { > static int i = 0; > return i++; > > } > > is roughly equivalent to: > > def foobar(): > foobar.i += 1 > return foobar.i > foobar.i = 0 barfoo = foobar foobar = lambda x : x And boom. 'static' variables are better implemented using either closures, mutable default arguments or custom callable types. From jeff.self at gmail.com Wed Apr 9 19:39:23 2008 From: jeff.self at gmail.com (jeffself) Date: Wed, 9 Apr 2008 16:39:23 -0700 (PDT) Subject: How can I use quotes without escaping them using CSV? References: Message-ID: <35a28105-1178-4784-8247-d483e55694c7@f63g2000hsf.googlegroups.com> On Apr 9, 5:39 pm, "Reedick, Andrew" wrote: > > -----Original Message----- > > From: python-list-bounces+jr9445=att.... at python.org [mailto:python- > > list-bounces+jr9445=att.... at python.org] On Behalf Of jeffself > > Sent: Wednesday, April 09, 2008 5:11 PM > > To: python-l... at python.org > > Subject: How can I use quotes without escaping them using CSV? > > > If I put an escape character in, it works. For example, if I use ~ as > > my escape character, my output looks like this: > > 0001[tab]Michael L. ~"Mick~" Jones[tab]189 > > > I don't want that. If I don't include an escape character, it doesn't > > work. > > > Here's my code: > > import sys > > import csv > > from readexcel import * > > > f = open("results.txt", 'wb') > > book = sys.argv[1] > > sheet = sys.argv[2] > > > xl = readexcel(book) > > sheetnames = xl.worksheets() > > > for s in sheetnames: > > if s == sheet: > > writer = csv.writer(f, delimiter='\t', quoting=csv.QUOTE_NONE) > > for row in xl.getiter(s): > > writer.writerow((row['Precinct'],row['Candidate'],unicode(int(row['Vote > > > s'])))) > > f.close() > > The documentation is pretty, uhm, obtuse, but you also need to set > quotechar. > > import sys > import csv > > names = ['Michael L. "Mick" Jones', 'Vickie A. Meyers', 'John "Jack" > Smith'] > > writer = csv.writer(sys.stdout, delimiter='\t', quotechar='', > quoting=csv.QUOTE_NONE) > for i in names: > writer.writerow(['a', i, 'b']) > > output: > a Michael L. "Mick" Jones b > a Vickie A. Meyers b > a John "Jack" Smith b > > ***** > > The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA621 I set quotechar="" and was able to get it to work. I'll try this at work tomorrow! From steve at holdenweb.com Wed Apr 23 11:28:04 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 11:28:04 -0400 Subject: Error Message In-Reply-To: <14A2A120D369B6469BB154B2D2DC34D20AD1195E@EXCHVS01.ad.sfwmd.gov> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com><27CC3060AF71DA40A5DC85F7D5B70F38033A4F2D@AWMAIL04.belcan.com> <480F483B.9050507@holdenweb.com> <14A2A120D369B6469BB154B2D2DC34D20AD1195E@EXCHVS01.ad.sfwmd.gov> Message-ID: Ahmed, Shakir wrote: > I am getting application error message ? The instruction at ?0x7c910f29? > referenced memory at ?0xffffffff?. The memory could not be ?read?. I am > running one python script and it is running good without any exception > or error message but getting this message when I am closing python 2.4.1 > application. > > > > Any idea or help is highly appreciated. > The error is at line 317 of your script. [Translation: we cannot know what is wrong with a program we have never seen]. Are you using the ctypes library, or some other extension module? It may be that in invalid pointer is causing problems for the garbage collector during shutdown, for example. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From mishok13 at gmail.com Mon Apr 7 09:19:49 2008 From: mishok13 at gmail.com (Andrii V. Mishkovskyi) Date: Mon, 7 Apr 2008 16:19:49 +0300 Subject: @x.setter property implementation In-Reply-To: References: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> Message-ID: <192840a00804070619h6621cbc7k8cd790ccffe4bd47@mail.gmail.com> 2008/4/7, Floris Bruynooghe : > > Have been grepping all over the place and failed to find it. I found > the test module for them, but that doesn't get me very far... > I think you should take a look at 'descrobject.c' file in 'Objects' directory. -- Wbr, Andrii Mishkovskyi. He's got a heart of a little child, and he keeps it in a jar on his desk. From bruno.desthuilliers at gmail.com Wed Apr 2 15:52:47 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 12:52:47 -0700 (PDT) Subject: function call - default value & collecting arguments References: <_LQIj.9776$HS3.482805@news.siol.net> Message-ID: <7e50544d-6daf-48c2-bb82-be06d3590450@8g2000hsu.googlegroups.com> On 2 avr, 21:03, "Primoz Skale" wrote: > Hello! > > I am fairly new to Python, so I apologise if this is a 'newbie' question. > > First define a simple function: > > def f(a=0): > print a > > >> f(1) > 1 > >>f() > > 0 > > Argument a in function f() is set at default value of 0, if it is not passed > to the function at the function call. I get this! :) > > I also understand (fairly) how to collect arguments. For example, let's > define another function: > > def f(*a): > print a This means that f takes any number of optional positional arguments. If nothing is passed, within f, 'a' will be an empty tuple. Note that this is *not* the usual way to define a function taking multiple (mandatory) arguments. > >>f(1) > (1,) > >>f(1,2) > (1,2) > >>f() > > () > > OK, everything allright till so fair. But! :) Now define third function as: > > def f(*a): > print a[0] > > In this case, function only prints first argument in the tuple: *If* there's one. > >>f(1,2,3) > 1 > >>f(3) > 3 > >>f() #no arguments passed IndexError ? > Traceback (most recent call last): > File "", line 1, in > f() #no arguments passed > File "", line 2, in f > print a[0] > IndexError: tuple index out of range Bingo. > Then I tried to define the function as: > > def f(*a=(0,)): SyntaxError ? > print a[0] #this should come next, but we get error msg instead, saying > > SyntaxError: invalid syntax Bingo. > but it does not work this way. Now my 'newbie' question: Why not? :) Condescending answer : "because" !-) (Sorry, couldn't resist.) More seriously, I can't tell you why this is not allowed, but : > I wanted to write function in this way, because then we can call function > without any arguments, and it would still print 0 (in this case). def f(*a): try: print a[0] except IndexError: print 0 or def f(*a): if not a: a = (0,) print a[0] or (slightly more involved, and certainly overkill): def with_default_args(default): def decorator(func): def wrapper(*args): if not args: args = default return func(*args) return wrapper return decorator @with_default_args((0,)) def f(*a): print a[0] HTH From ybc2084 at gmail.com Thu Apr 10 04:42:53 2008 From: ybc2084 at gmail.com (rockins) Date: Thu, 10 Apr 2008 01:42:53 -0700 (PDT) Subject: what's the reasonale of loghelper() in mathmodule.c References: <49750e9d-1a63-42d2-b292-38d225b0c3c8@n1g2000prb.googlegroups.com> <28321dcf-71d2-4c67-bd1d-1e187015129d@u3g2000hsc.googlegroups.com> Message-ID: <03fb9a52-21de-4478-bcdc-80f6fc6f9409@s13g2000prd.googlegroups.com> On Apr 9, 9:11 pm, Mark Dickinson wrote: > On Apr 9, 4:38 am,rockins wrote: > > > I cannot understand it well, can anyone explain me why and how > > loghelper() can compute any base logarithm? Or could anyone give me > > some reference(such as, books or papers)? > > loghelper is there so that log(n) can be computed for any positive > integer n---it's nothing to do with computing logs to an arbitrary > base. > > All of the other math functions convert an integer argument to a float > first. That conversion fails if the integer is larger than the > largest > representable float (around 1.7e308 on most systems). For example: > > >>> from math import sqrt, log > >>> sqrt(10**600) > > Traceback (most recent call last): > File "", line 1, in > OverflowError: long int too large to convert to float>>> log(10**600) > > 1381.5510557964274 > > The sqrt call first tries to convert 10**600 to a float, giving an > OverflowError (even though the actual square root *is* representable > as a float). The log call goes through loghelper instead, which > doesn't try to convert 10**600 to a float, but instead computes > the log based on the top few bits of 10**600 (in its internal > binary representation) and on the number of bits required to > represent 10**600. > > You're not going to learn much about math function implementations > from mathmodule.c: all it does it wrap the platform libm functions. > > Mark Thanks Marks, your explanation is very clear. Yes, I do not need to learn much about the math functions' implementation of libm, I just need to know why there exists loghelper() in mathmodule.c; I have checked Python's longobject.c, I think I have understood why loghelper() is needed now. Since Python can represent arbitrary precision long integer object, so for logarithm it indeed need to deal with very huge number. Doesn't it? If there's any misunderstanding of mine, please point out. Thank you very much. -rockins From gherron at islandtraining.com Thu Apr 17 12:44:51 2008 From: gherron at islandtraining.com (Gary Herron) Date: Thu, 17 Apr 2008 09:44:51 -0700 Subject: Can't do a multiline assignment! In-Reply-To: References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> Message-ID: <48077E83.5050404@islandtraining.com> s0suk3 at gmail.com wrote: > On Apr 17, 10:54 am, colas.fran... at gmail.com wrote: > >> On 17 avr, 17:40, s0s... at gmail.com wrote: >> >> Out of sheer curiosity, why do you need thirty (hand-specified and >> dutifully commented) names to the same constant object if you know >> there will always be only one object? >> > > I'm building a web server. The many variables are names of header > fields. One part of the code looks like this (or at least I'd like it > to): > > class RequestHeadersManager: > > # General header fields > Cache_Control = \ > Connection = \ > Date = \ > Pragma = \ > Trailer = \ > Transfer_Encoding = \ > Upgrade = \ > Via = \ > Warning = \ > > # Request header fields > Accept = \ > Accept_Charset = \ > Accept_Encoding = \ > Accept_Language = \ > Authorization = \ > ... > But. *What's the point* of doing it this way. I see 14 variables being assigned a value, but I don't see the value, they are getting. Reading this bit if code provides no useful information unless I'm willing to scan down the file until I find the end of this mess. And in that scanning I have to make sure I don't miss the one single line that does not end in a backslash. (Your ellipsis conveniently left out the *one* important line needed to understand what this code is doing, but even if you had included it, I'd have to scan *all* lines to understand what a single value is being assigned. There is *no way* you can argue that code is clearer than this: # General header fields Cache_Control = None Connection = None Date = None Pragma = None ... Gary Herron > Etc etc etc. At the end they'll all be assign to None. Then, when > initialized, __init__() will the the string of headers, parse them, > and use those variables shown above to assign to the header values. Of > course a normal request won't include all of those headers, so the > others will remain None. That's what I want. > From deets at nospam.web.de Tue Apr 22 07:30:36 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 13:30:36 +0200 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> Message-ID: <6760jfF2n3bn1U1@mid.uni-berlin.de> GD schrieb: > Please remove ability to multiple inheritance in Python 3000. > > Multiple inheritance is bad for design, rarely used and contains many > problems for usual users. > > Every program can be designed only with single inheritance. Yes, sure. And that's why Java grew interfaces & it's class-diagrams are hilariously complex. Because using single inheritance is so much better. Diez From nick at craig-wood.com Thu Apr 17 12:30:04 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Thu, 17 Apr 2008 11:30:04 -0500 Subject: is file open in system ? - other than lsof References: <66p6o2F2korm2U1@mid.individual.net> Message-ID: Thomas Guettler wrote: > bvidinli schrieb: > > is there a way to find out if file open in system ? - > > please write if you know a way other than lsof. because lsof if slow for me. > > i need a faster way. > > i deal with thousands of files... so, i need a faster / python way for this. > > thanks. > > On Linux there are symlinks from /proc/PID/fd to the open > files. You could use this: > > #!/usr/bin/env python > import os > pids=os.listdir('/proc') > for pid in sorted(pids): > try: > int(pid) > except ValueError: > continue > fd_dir=os.path.join('/proc', pid, 'fd') > for file in os.listdir(fd_dir): > try: > link=os.readlink(os.path.join(fd_dir, file)) > except OSError: > continue > print pid, link Unfortunately I think that is pretty much exactly what lsof does so is unlikely to be any faster! However if you have 1000s of files to check you only need to do the above scan once and build a dict with all open files in whereas lsof will do it once per call so that may be a useful speedup. Eg ------------------------------------------------------------ import os pids=os.listdir('/proc') open_files = {} for pid in sorted(pids): try: int(pid) except ValueError: continue fd_dir=os.path.join('/proc', pid, 'fd') try: fds = os.listdir(fd_dir) except OSError: continue for file in fds: try: link=os.readlink(os.path.join(fd_dir, file)) except OSError: continue if not os.path.exists(link): continue open_files.setdefault(link, []).append(pid) for link in sorted(open_files.keys()): print "%s : %s" % (link, ", ".join(map(str, open_files[link]))) ------------------------------------------------------------ You might want to consider http://pyinotify.sourceforge.net/ depending on exactly what you are doing... -- Nick Craig-Wood -- http://www.craig-wood.com/nick From kkuhl05 at gmail.com Tue Apr 29 01:46:25 2008 From: kkuhl05 at gmail.com (Kevin K) Date: Mon, 28 Apr 2008 22:46:25 -0700 (PDT) Subject: File IO Issues, help :( References: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> Message-ID: On Apr 29, 12:38 am, "Eric Wertman" wrote: > chuck in a jsfile.close(). The buffer isn't flushing with what you > are doing now. jsfile.flush() might work... not sure. Closing and > re-opening the file for sure will help though. > Yeah sorry I forgot to include the close() in the quote but its there. In fact I moved it up a bit and still no luck heres the new code: jsfile = open("../timeline.js", "r+") jscontent = jsfile.readlines() jsfile.truncate() for line in jscontent: if re.search('var d =', line): line = "var d = \""+mint['1'].ascdate()+"\"\n" print line jsfile.write(line) jsfile.close() I tried this can got the same result...?? From m.zaki.mirza at gmail.com Mon Apr 14 03:49:13 2008 From: m.zaki.mirza at gmail.com (xakee) Date: Mon, 14 Apr 2008 00:49:13 -0700 (PDT) Subject: Java or C++? References: Message-ID: <41b4eea8-8e53-413b-b860-789fc062638c@u69g2000hse.googlegroups.com> On Apr 14, 11:44?am, s0s... at gmail.com wrote: > Hello, I was hoping to get some opinions on a subject. I've been > programming Python for almost two years now. Recently I learned Perl, > but frankly I'm not very comfortable with it. Now I want to move on > two either Java or C++, but I'm not sure which. Which one do you think > is a softer transition for a Python programmer? Which one do you think > will educate me the best? Well if you need an easier transition, go for java. But personally i would recommend you to go for C/C++. There are a few very solid reasons for that. 1. You can still use ur python konwledge, integrate python with you applications, extend python with C/C++ .. and so on. That would not only benefit you but the whole community. 2. C/C++ is likely to teach you more things in this transition than java will. You probably know all the good software engineering stuff and things like that maybe, (which you can still use in python) but going to C/C++ you can actually delve into systems programming and things like that. When you do that, again, you can extend python and contribute to the community. 3. When you get hold of c/c++, there will be lesser friction in you forever to transition to any other language. I appriciate that you chose python in the first place since that is what i advocate as well ... the way i see programming should be taught or taken up is like : bash/shell scripting -> python/perl -> c/c++ -> assembly .... (from there on, given you give enough time to the end parts, you should not have any difficulty going to C#/Java/VB/Delphi or whatever for some nice RAD or even production level performance not-so-critical applications). So if you're intrested in system programming getting to know how things get done, have a SOLID computing background and give python what python gave you, go for C/C++. From gagsl-py2 at yahoo.com.ar Wed Apr 16 14:54:21 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 15:54:21 -0300 Subject: Interesting timing issue I noticed References: Message-ID: En Wed, 16 Apr 2008 10:36:14 -0300, Jonathan Shao escribi?: > *Gabriel Genellina* gagsl-py2 at yahoo.com.ar > > *Wed Apr 16 08:44:10 CEST 2008* >> Another thing would be to rearrange the loops so the outer one executes > less times; if you know that borderX< better to swap the inner and outer loops above. > Thank you for the tip on xrange. > Even if I swap the inner and outer loops, I would still be doing the same > number of computations, am I right (since I still need to go through the > same number of elements)? I'm not seeing how a loop swap would lead to > fewer > computations, since I still need to calculate the outer rim of elements > in > the array (defined by borderX and borderY). You minimize the number of "for" statements executed, and the number of xrange objects created. Both take some time in Python. import timeit f1 = """ for i in xrange(10): for j in xrange(1000): i,j """ f2 = """ for j in xrange(1000): for i in xrange(10): i,j """ print timeit.Timer(f1).repeat(number=1000) print timeit.Timer(f2).repeat(number=1000) Output: [2.0405478908632233, 2.041863979919242, 2.0397852240997167] [2.8623411634718821, 2.8330055914927783, 2.8361752680857535] The second (using the largest outer loop) is almost 40% slower than the first one. "Simplified" Big-Oh complexity analysis isn't enough in cases like this. -- Gabriel Genellina From steve at holdenweb.com Wed Apr 23 08:01:25 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 08:01:25 -0400 Subject: Explicit variable declaration In-Reply-To: <1be78d220804230252n4faa34e6v90b482080750e0cb@mail.gmail.com> References: <1506f165-7f86-4dc7-aa29-6488eda9ae7f@l64g2000hse.googlegroups.com> <1be78d220804230252n4faa34e6v90b482080750e0cb@mail.gmail.com> Message-ID: Filip Gruszczy?ski wrote: >> You mean the type? Not in 2.x, but in 3.x, there are function >> annotations: >> >> def a_function(arg1: int, arg2: str) -> None: pass > > Nope, I don't like types ;-) 3.x seems pretty revolutionary, and this > typing can be appreciated by some people. > >> Declaring what about them? If you mean declaring the type, remember >> that Python deliberately allows any name to be bound to any object; >> type declarations can't be enforced without losing a lot of the power >> of Python. > > Just declaring, that they exist. Saying, that in certain function > there would appear only specified variables. Like in smalltalk, if I > remember correctly. > Icon has (had?) the same feature: if the "local" statement appeared then the names listed in it could be assigned in the local namespace, and assignment to other names wasn't allowed. A lot of people assume that's what the __slots__ feature of the new object model is for, but it isn't: it's actually a memory conservation device for circumstances when millions of objects must be created in an application. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From nospam1.reifenberg at gmx.de Sat Apr 5 03:36:48 2008 From: nospam1.reifenberg at gmx.de (Nebur) Date: Sat, 5 Apr 2008 00:36:48 -0700 (PDT) Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? References: <0c8bfed7-1154-41d5-a740-6d1382180db2@d45g2000hsc.googlegroups.com> Message-ID: <53f83c02-817b-490d-86ba-b600d453d183@m3g2000hsc.googlegroups.com> > So, just wanted to point out that eclipse saves your file history > (even if you do not have a vcs)... that operation can be selected by > right clicking a parent folder and selecting 'restore from local > history'. Fabio, you are right; this feature should help to compensate ... but in my case, the Eclipse said "No deleted ressources in local history for selected container". I'm not familiar with the Local-History feature (since using a vcs), so it may be misconfigured. (The setting in Preferences/Workspace/ LocalHistore are at default: 7 days to keep files, 50 maximum entries per file, max.file size 1MB - which should be enough. ). Hm. Anyway, I don't see any idea how to track down what happened. So lets close the thread and simply continue working. * This is a good occasion to state that Pydev/Eclipse still is a very efficient IDE in my opinion, and (aside from this mystery here) it is perfectly stable for >>1 year now! This must be said, to correct any potential misimpression. Ciao, Nebur From jarausch at skynet.be Wed Apr 23 11:15:44 2008 From: jarausch at skynet.be (Helmut Jarausch) Date: Wed, 23 Apr 2008 17:15:44 +0200 Subject: Unix Device File Emulation In-Reply-To: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> Message-ID: <480f52a0$0$2951$ba620e4c@news.skynet.be> blaine wrote: > Hey everyone, > So I've got a quick query for advice. > > We have an embedded device in which we are displaying to an LCD > device that sits at /dev/screen. This device is not readily available > all the time, so I am needing to write an emulator. This will > basically just monitor a file, /dev/screen for example, and write the > commands to a TK or WxWindows canvas. > > So sending 'line 0 0 10 10' will draw a line on my canvas from (0,0) > to (10,10). > > My question: Whats the best way to set up a monitor (in python) of > this file? Would I simply open up the file for read, check for > changes, get any updated data, and clear the file? Or is there some > standard way of doing something like this that guarantees no overlap > or data loss? > > example usage: echo 'line 0 0 10 10' > /dev/screen > > On the actual embedded device this is handled by a kernel module. We > can spit commands into it as fast as we can and the kernel module can > keep up. This is typical unix device file behavior. > > Any suggestions or advice would be splendid. Thanks! > Blaine It looks as if you need something like the Unix 'tail -f' command. Perhaps here is some help http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/414771 http://mail.python.org/pipermail/python-list/2002-August/157510.html http://pyinotify.sourceforge.net/ -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany From bruno.desthuilliers at gmail.com Wed Apr 2 19:00:54 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 16:00:54 -0700 (PDT) Subject: Nested try...except References: <0a34849f-bcda-419b-a10f-772d76172d1f@b5g2000pri.googlegroups.com> <43d60d13-b420-414d-81c8-b8430af2aa5f@i36g2000prf.googlegroups.com> <7d992474-f90b-4c8f-b359-a1857f570c92@8g2000hse.googlegroups.com> Message-ID: On 2 avr, 18:25, Nanjundi wrote: > On Apr 2, 9:22 am, Magnus.Morab... at gmail.com wrote: > > > > > On 2 Apr, 15:15, Magnus.Morab... at gmail.com wrote: > > > > On 2 Apr, 15:12, cokofree... at gmail.com wrote: > > > > > On Apr 2, 3:06 pm, Magnus.Morab... at gmail.com wrote: > > > > > > Hi, > > > > > > I found the following code on the net - > > > > > > http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/%3C20050924104732.5116.qm... at minotaur.apache.org%3E > > > > > > def count(self): > > > > > - db = sqlite.connect(self.filename, > > > > > isolation_level=ISOLATION_LEVEL) > > > > > - try: > > > > > - try: > > > > > - cur = db.cursor() > > > > > - cur.execute("select count(*) from sessions") > > > > > - return cur.fetchone()[0] > > > > > - finally: > > > > > - cur.close() > > > > > - finally: > > > > > - db.close() > > > > > > I don't understand though why the second try is not after the line cur > > > > > = db.cursor(). Can anyone explain for me why? > > > > > > /Barry. > > > > > Better question is why is there a try with no except... > > > > > Better yet, WHY is there two TRY statements when there could quite > > > > happily be only one... > > > > > Towards what you are asking, I GUESS...because the author hoped to > > > > handle the cases where cur failed to get assigned...but then > > > > his .close method of it would likely not work anyway...I mean...does > > > > this even work...YUCK > > > > I shouldn't have written "Nested try...except" as the title, instead I > > > mean "Nested try...finally". Sorry about that... > > > > Anyway, how would you do this? That is, use a finally to close the > > > network connection and the cursor? > > > > Thanks for your help, > > > > Barry > > > Here's what I would do. Is it OK? > > > def ExecuteWithNoFetching(self, queryString): > > > sqlServerConnection = adodbapi.connect (";".join (connectors)) > > try: > > cursor = sqlServerConnection.cursor() > > try: > > cursor.execute(queryString) > > raise Exception("Exception") > > sqlServerConnection.commit() > > finally: > > cursor.close() > > finally: > > sqlServerConnection.close() > > No.. Why do you have raise statement? > "sqlServerConnection.commit()" never gets executed. It's demonstration code. > -N From gagsl-py2 at yahoo.com.ar Fri Apr 4 02:17:34 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 04 Apr 2008 03:17:34 -0300 Subject: Figuring out what class instance contains you References: Message-ID: En Fri, 04 Apr 2008 00:41:19 -0300, Alex VanderWoude escribi?: > Consider the following module: > > ================================ > class NewDict(dict): > parent = None > > def __setitem__(self, key, value): > print "My parent is", self.parent > super(NewDict, self).__setitem__(key, value) > > class Zero(object): > children = NewDict() > > def __init__(self): > self.children.parent = self > > class One(Zero): > pass > > class Two(One): > pass > > a = One() > a.children["spam"] = "baked beans" > b = Two() > b.children["eggs"] = "bacon" > ================================ > > When the above module is executed, the output looks something like this: > > My parent is <__main__.One object at 0x00BA27B0> > My parent is <__main__.Two object at 0x00B9D170> > > ...which is great, just what I wanted. Each dictionary instance reports > correctly which object instance is its container. But only if you create a single instance of each class, because "children" is a class attribute (behaves as it were shared among all instances). Then you need an instance attribute, initialized in __init__. So why not set the parent at this time? py> class NewDict(dict): pass ... py> class Zero(object): ... def __init__(self): ... self.children = NewDict() ... self.children.parent = self ... py> class One(Zero): ... pass ... py> class Two(One): ... pass ... py> a = One() py> a.children["spam"] = "baked beans" py> b = Two() py> b.children["eggs"] = "bacon" py> c = Two() py> c.children["foo"] = "bar" py> print a.children.parent is a True py> print b.children.parent is b True py> print c.children.parent is c True > However, I would like to find some automagic way of having NewDict > figure out what object instance it is on without resorting to having the > container class instance poke a reference to itself into the NewDict > instance (i.e. the line in Zero.__init__()). Unless there are more contrains that you haven't told us, the above example looks as the simplest approach. -- Gabriel Genellina From billingspanshism at gmail.com Sat Apr 19 17:18:52 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:18:52 -0700 (PDT) Subject: david & victoria beckham Message-ID: <0742fdb0-b791-47d3-90c0-670610743b8e@m73g2000hsh.googlegroups.com> Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From spamgrinder.trylater at gmail.com Thu Apr 17 10:49:32 2008 From: spamgrinder.trylater at gmail.com (AlFire) Date: Thu, 17 Apr 2008 09:49:32 -0500 Subject: why function got dictionary In-Reply-To: <66p409F2lg89hU1@mid.uni-berlin.de> References: <48075950.7050000@gmail.com> <66p409F2lg89hU1@mid.uni-berlin.de> Message-ID: <4807637C.1050900@gmail.com> Diez B. Roggisch wrote: >> >> Q: why function got dictionary? What it is used for? > > because it is an object, and you can do e.g. > you mean an object in the following sense? >>> isinstance(g,object) True where could I read more about that? Andy From carlwuhwdmckay at gmail.com Mon Apr 21 02:08:51 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:08:51 -0700 (PDT) Subject: wheel of fortune crack Message-ID: wheel of fortune crack http://cracks.00bp.com F R E E C R A C K S From nick at craig-wood.com Tue Apr 29 05:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Tue, 29 Apr 2008 04:30:03 -0500 Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> <18c1e6480804270653r2e075061wf442b7b7d9f50ff6@mail.gmail.com> <9cca03a3-9b96-4bee-947b-baa62cd5f9a9@q24g2000prf.googlegroups.com> Message-ID: Terry wrote: > On Apr 28, 5:30 pm, Nick Craig-Wood wrote: > > David wrote: > > > Another idea would be to have multiple queues, one per thread or per > > > message type "group". The producer thread pushes into the appropriate > > > queues (through an intelligent PutMsg function), and the consumer > > > threads pull from the queues they're interested in and ignore the > > > others. > > > > Unfortunately a thread can only wait on one Queue at once (without > > polling). So really the only efficient solution is one Queue per > > thread. > > > > Make an intelligent PutMsg function which knows which Queue (or > > Queues) each message needs to be put in and all the threads will have > > to do is Queue.get() and be sure they've got a message they can deal > > with. > > I do have one Queue per thread. The problem is the thread can not peek > into the Queue and select msg with certain ID first. My point is don't put messages that the thread doesn't need in the queue in the first place. Ie move that logic into PutMsg. -- Nick Craig-Wood -- http://www.craig-wood.com/nick From Christna.Giri at gmail.com Fri Apr 4 14:50:56 2008 From: Christna.Giri at gmail.com (Student) Date: Fri, 4 Apr 2008 11:50:56 -0700 (PDT) Subject: Training course in Los Angeles? Message-ID: <11dbf7dd-ab12-43b6-9cdd-94a9a8fcc114@g1g2000pra.googlegroups.com> Is there a training course in advanced-level Python in the Los Angeles area? We are looking for web-development in particular. From futurescale at gmail.com Tue Apr 15 09:48:30 2008 From: futurescale at gmail.com (Cliff Hall) Date: Tue, 15 Apr 2008 06:48:30 -0700 (PDT) Subject: PureMVC Python / Google App Engine Demo - Blog Message-ID: <8e43fbbc-3cb0-44be-8862-a6d2f00dc9af@m44g2000hsc.googlegroups.com> PureMVC is an extremely lightweight MVC framework based upon proven design patterns. Originally written for ActionScript 3 (Flash, Flex, AIR) it has been ported to nearly all major languages and platforms. Here is a simple blog example using the PureMVC Framework for Python: http://trac.puremvc.org/Demo_Python_GoogleAppEngine_Blog -=Cliff> From kay.schluehr at gmx.net Sat Apr 5 17:27:25 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 5 Apr 2008 14:27:25 -0700 (PDT) Subject: Weird scope error References: <47F79A78.4010207@gmail.com> <47F7A41C.4090402@islandtraining.com> <47F7E325.9060603@gmail.com> Message-ID: <43917932-3381-4130-8aca-a2dd05a19ee2@t36g2000prm.googlegroups.com> On 5 Apr., 23:08, Michael Torrie wrote: > You need to either fix all these imports in these other modules (that > are probably in the site_packages folder), or modify the python import > path so that it can find ElementTree directly. I'd prefer to set an alias in the module cache: >>> import sys >>> import xml.etree >>> sys.modules["elementree"] = xml.etree >>> from elementree import ElementTree >>> From damonwischik at gmail.com Fri Apr 18 19:38:04 2008 From: damonwischik at gmail.com (damonwischik at gmail.com) Date: Fri, 18 Apr 2008 16:38:04 -0700 (PDT) Subject: How to print a unicode string? Message-ID: I'd like to print out a unicode string. I'm running Python inside Emacs, which understands utf-8, so I want to force Python to send utf-8 to sys.stdout. >From what I've googled, I think I need to set my locale. I don't understand how. import locale print locale.getlocale() --> (None,None) print locale.getdefaultlocal() --> ('en_GB','cp1252') print locale.normalize('en_GB.utf-8') --> en_GB.UTF8 locale.setlocale(locale.LC_ALL,'en_GB.UTF8') --> locale.Error: unsupported locale setting I'd be grateful for advice. Damon. From s0suk3 at gmail.com Wed Apr 16 12:26:03 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Wed, 16 Apr 2008 09:26:03 -0700 (PDT) Subject: Default parameter for a method... again Message-ID: <614159c3-1bb9-4026-b7f3-7817f69de505@t54g2000hsg.googlegroups.com> I had posted this before but all the spam whipped it out... I wanted to know if there's any way to create a method that takes a default parameter, and that parameter's default value is the return value of another method of the same class. For example: class A: def __init__(self): self.x = 1 def meth1(self): return self.x def meth2(self, arg=meth1()): # The default `arg' should would take thereturn value of meth1() print '"arg" is', arg This obviously doesn't work. I know I could do ... def meth2(self, arg=None): if arg is None: arg = self.meth1() but I'm looking for a more straightforward way. From arnodel at googlemail.com Fri Apr 25 05:29:15 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Fri, 25 Apr 2008 10:29:15 +0100 Subject: Little novice program written in Python References: <0cecfed4-17e7-4e4d-9dbe-3f0ac8316c1f@y21g2000hsf.googlegroups.com> Message-ID: hellt writes: > my variant of the sieve Since you posted it, you are also looking for advice to improve your code ;) > def GetPrimes(N): > arr = [] > for i in range(1,N+1): > arr.append(i) This is the same as: arr = range(1, N+1) !-) > #Set first item to 0, because 1 is not a prime > arr[0]=0 > #sieve processing > s=2 remove this line > while s < math.sqrt(N): for s in xrange(2, int(math.sqrt(N))+1): > if arr[s-1] != 0: if arr[s-1]: > j = s*s remove this line > while j <= N: for j in xrange(s*s, N+1, s): > arr[j-1] = 0 > j += s remove this line > s += 1 remove this line > return [x for x in arr if x != 0] return filter(None, arr) Altogether now: def getprimes(N): arr = range(1, N+1) arr[0] = 0 for s in xrange(2, int(math.sqrt(N))+1): if arr[s-1]: for j in xrange(s*s, N+1, s): arr[j-1] = 0 return filter(None, arr) It's the same, but it looks a bit less like the litteral translation of some C code. Lastly, the lines: for j in xrange(s*s, N+1, s): arr[j-1] = 0 from above can be condensed using extended slices: arr[s*s-1 : N+1 : s] = [0] * (N/s - s + 1) (If I can count correctly) Giving the following, slightly shorter and probably faster: def getprimes(N): arr = range(1, N+1) arr[0] = 0 for s in xrange(2, int(math.sqrt(N))+1): if arr[s-1]: arr[s*s-1 : N+1 : s] = [0] * (N/s - s + 1) return filter(None, arr) If it was me, I would include 0 in the array, giving the slightly simpler: def getprimes(N): arr = range(N+1) arr[1] = 0 for s in xrange(2, int(math.sqrt(N))+1): if arr[s]: arr[s*s : N+1 : s] = [0] * (N/s - s + 1) return filter(None, arr) (I think) This all needs to be tested. -- Arnaud From spe.stani.be at gmail.com Thu Apr 17 08:38:46 2008 From: spe.stani.be at gmail.com (SPE - Stani's Python Editor) Date: Thu, 17 Apr 2008 05:38:46 -0700 (PDT) Subject: PHATCH: PHoto bATCH processor with EXIF and IPTC support for all platforms Message-ID: <808b0684-19bc-432e-811b-590a451ac899@a22g2000hsc.googlegroups.com> Phatch is a simple to use cross-platform GUI Photo Batch Processor Phatch handles all popular image formats and can duplicate (sub)folder hierarchies. It can batch resize, rotate, apply perspective, shadows, rounded corners, ... and more in minutes instead of hours or days if you do it manually. Phatch allows you to use EXIF and IPTC tags for renaming and data stamping. Phatch also supports a console version to batch photos on web servers. What is new? Until Phatch could only save EXIF and IPTC tags on Linux. Now this feature is available for all platforms hanks to the work of Robin Mills who managed to compile pyexiv2 and all its dependencies and get it to work on MacOS X (Tiger and Leopard, PPC and Intel) and x86 Windows. You can grab the libraries from here: http://www.clanmills.com/articles/gpsexiftags/ (Look for "Download the libraries click here" somewhere in the middle). I have not tested this myself yet, but assumes that it will work. Any volunteers to test this with Phatch Homepage: http://photobatch.stani.be (free download link below) Tutorials: http://photobatch.wikidot.com/tutorials Translations: https://translations.launchpad.net/phatch/trunk/+pots/phatch License: GPLv3 Screenshot: http://photobatch.wikidot.com/local--files/start/Screenshot-Phatch3d.jpg (the perspective and reflection is produced by Phatch itself) Phatch has many features, like: - EXIF information inspector with thumbnail - limit jpeg file size when saving - tons of actions organized by tags (including perspective, round corners, shadow, reflection, ...) - console version (Phatch can now run without a gui on servers) - batch rename and copy files based on exif metadata - data stamping (http://photobatch.wikidot.com) - online documentation wiki (http://photobatch.wikidot.com) - desktop or panel droplets on which images or folders can be dropped (available on Linux & Windows) Linux only features: - Nautilus and desktop integration (with its own mime type and nautilus extension) - manpage with examples With python-pyexiv2 the following featues are added: - embedding the original EXIF and IPTC tags in the image You can install Phatch for any platform if you read these instructions first: http://photobatch.wikidot.com/install From steve at holdenweb.com Thu Apr 24 07:33:52 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 07:33:52 -0400 Subject: annoying dictionary problem, non-existing keys In-Reply-To: <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> Message-ID: bvidinli wrote: > I posted to so many lists because, > > this issue is related to all lists, No, it isn't, as you would have discovered had you bothered to read the purpose of each list. For example, python-help and python-dev are mutually exclusive. > this is an idea for python, It isn't an idea for Python at all. It's you, telling the world that you haven't really used Python much and haven't read the manuals but would nevertheless like us to consider your ideas for improving the language. > this is related to development of python... > No it isn't. Python already has the feature you requested. > why are you so much defensive ? > Terry wasn't being defensive, he was protecting you form the abue you would receive of you kept posting to the wrong list! > i think ideas all important for development of python, software.... > i am sory anyway.... hope will be helpful. > We hope you will be helpful too. For now it would probably be best to start by posting your questions on the regular comp.lang.python group, which is generally suitable for beginners who know something about programming. If you are new to programming as well then the python-tutor list would be more useful. Ask with a little humility (the people who answer questions here are doing it out of the goodness of their hearts, remember) and soon you will be able to pass their assistance on, returning the favor they did for you. Welcome to the Python community. regards Steve > 2008/4/24, Terry Reedy : >> Python-dev is for discussion of development of future Python. Use >> python-list / comp.lang.python / gmane.comp.python.general for usage >> questions. -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From sturlamolden at yahoo.no Thu Apr 24 20:25:15 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 17:25:15 -0700 (PDT) Subject: Psyco alternative References: Message-ID: On Apr 25, 2:15 am, Steve Holden wrote: > I believe, without the benefit of recent experience, that the R stands > for Restricted. Thus and RPython program must of necessity also be a > valid Python program. Or do you know something I don't? That is correct. But RPython is not anything like Python, I would not even call it a dynamically typed language. It is actually more like Fortran 77 with a Python look and feel. From hniksic at xemacs.org Tue Apr 15 03:44:43 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Tue, 15 Apr 2008 09:44:43 +0200 Subject: Dynamic use of property() fails References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> Message-ID: <87wsmz4l5g.fsf@mulj.homelinux.net> andrew cooke writes: > This is my first attempt at new classes and dynamic python, so I am > probably doing something very stupid... After reading the how-to for > descriptors at http://users.rcn.com/python/download/Descriptor.htm I > decided I would make an object that returns attributes on read, but on > setting calls an arbitrary function. > > My code looks like: > class ActiveDAO(object): > def __init__(self): > self.__values__ = {} > def add_field(self, name, value, on_change): > self.__values__[name] = value > def get(self): return self.__values__[name] > def set(self, new_value): self.__values__[name] = > on_change(new_value) > def delete(self): raise AttributeError > self.__dict__[name] = property(get, set, delete) As others explained, descriptors are called for descriptors found in class attributes, not in ones in instance attributes. Calling them for the latter would be dangerous because it might accidentally invoke magic whenever you store the "wrong" kind of object in an instance attribute. Also, in many cases (slots), instance property access is *implemented* using class property descriptors, so calling descriptors on objects retrieved from the instance would mean that the descriptor would have to be invoked twice. However, if you know what you're doing, you can simply customize your class's __getattribute__ to do what *you* want for your objects. For example: def __getattribute__(self, name): dict = object.__getattribute__(self, '__dict__') # self.__dict__ would infloop if name in dict: o = dict[name] # call the descriptor even if found in an object in __dict__ if hasattr(o, '__get__'): return o.__get__(self, type(self)) return o return object.__getattribute__(self, name) With that addition: >>> dao = ActiveDAO() >>> dao.add_field('name', 'value', lambda _: None) >>> dao.name 'value' >>> dao.__dict__['name'] From gagsl-py2 at yahoo.com.ar Tue Apr 1 13:47:37 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 14:47:37 -0300 Subject: Is this a good time to start learning python? References: <47f1140e$0$735$a729d347@news.telepac.pt> Message-ID: En Tue, 01 Apr 2008 13:57:55 -0300, escribi?: > On Mar 31, 1:36?pm, "Gabriel Genellina" > wrote: > >> Don't be scared by the "backwards incompatible" tag - it's the way to >> get ? >> rid of nasty things that could not be dropped otherwise. > > I would consider breaking production code to be "nasty" as well. Please explain how the existence of Python 3.0 would break your production code. -- Gabriel Genellina From paul.anton.letnes at gmail.com Sat Apr 12 08:46:53 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Sat, 12 Apr 2008 14:46:53 +0200 Subject: Wrapping C++ class with SWIG, Mac OS X In-Reply-To: <66aglpF2ihunjU1@mid.uni-berlin.de> References: <66aglpF2ihunjU1@mid.uni-berlin.de> Message-ID: <09DACA88-AEF5-40FE-A408-655AD5FE489A@gmail.com> Okay, installed SIP. Looks promising, following the tutorial on http://www.riverbankcomputing.com/static/Docs/sip4/sipref.html#using-sip It should be noted that I am working on a Mac - I know there are some differences, but it's still UNIX and should work somehow. Anyway, I copy-paste and create the Word.h header, write an implementation in Word.cpp, the SIP wrapper Word.sip and the configure.py script. I now run configure and make, creating the following error: ~/Desktop/SIP_example $ python configure.py ~/Desktop/SIP_example $ make c++ -c -pipe -fPIC -Os -Wall -W -I. -I/sw/include/python2.5 -o sipwordcmodule.o sipwordcmodule.cpp c++ -c -pipe -fPIC -Os -Wall -W -I. -I/sw/include/python2.5 -o sipwordWord.o sipwordWord.cpp c++ -headerpad_max_install_names -bundle -undefined dynamic_lookup -o word.so sipwordcmodule.o sipwordWord.o -lword ld: library not found for -lword collect2: ld returned 1 exit status make: *** [word.so] Error 1 ~/Desktop/SIP_example $ SWIG at least works nicely with C... Too bad I know so little about compilers and libraries, I don't quite understand what the linker (ld) is complaining about. The simplest tutorial should anyway work? Cheers Paul. > > Can't help on SWIG - all I can say is that SIP which is used to wrap > the > large and template-ridden C++-GUI-Toolkit Qt worked flawlessly for me. > Maybe you should try that. > > Diez > -- > http://mail.python.org/mailman/listinfo/python-list From fetchinson at googlemail.com Thu Apr 3 01:37:45 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Wed, 2 Apr 2008 22:37:45 -0700 Subject: Parsing HTML? In-Reply-To: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> References: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> Message-ID: > I'm trying to parse an HTML file. I want to retrieve all of the text > inside a certain tag that I find with XPath. The DOM seems to make > this available with the innerHTML element, but I haven't found a way > to do it in Python. Have you tried http://www.google.com/search?q=python+html+parser ? HTH, Daniel From cwitts at gmail.com Thu Apr 10 04:17:29 2008 From: cwitts at gmail.com (Chris) Date: Thu, 10 Apr 2008 01:17:29 -0700 (PDT) Subject: new user needs help! References: <16571823.post@talk.nabble.com> Message-ID: On Apr 10, 10:07?am, Chris wrote: > On Apr 9, 11:02?pm, drjekil wrote: > > > > > I have done something so far about that problem,but its not the good way to > > do it > > > need ur comments about that.... > > > from string import ?*; > > import sys > > > myfile = open("/afs/pdc.kth.se/home/d/debnath/membrane/1a91A.txt") > > a = myfile.readlines() > > data = myfile.readlines() > > for line in myfile.readlines(): > > ? ? ? ?fields = line.split('\t') > > > ? ? ? ?items=fields.strip() > > ? ? ? ?list1.append(items[1]) > > > for i in aminoacid: > > ? ? if ?10.0 <= z <= 22.0: > > ? ? matches.append([1,i]) > > #here i am getting comment! ?bash-3.1$ python bb.py > > ? File "bb.py", line 16 > > ? ? matches.append([1,i]) > > ? ? ? ? ? ^ > > IndentationError: expected an indented block > > > ? ? else: > > ? ? matches.append([-1,i]) > > You are getting the indentation error because you need to tab the > lines in after your 'if' and 'else' statements. ?After that is fixed > you should get an Attribute Error on the 'items=fields.strip()' as a > list doesn't have access to strip. > > import string > myfile = open("/afs/pdc.kth.se/home/d/debnath/membrane/1a91A.txt", > 'rb') > > AMINO_ACIDS = ['A','B','C',......'X','Y','Z'] > > for line in myfile: ? # Files are iterable themselves. > > ? ? try: > ? ? ? ? fields = map(string.strip, line.split('\t')) ?# This will > strip every column for you > ? ? ? ? name, aa, topo, access, tssp, stride, z = fields > ? ? except IndexError: ? ?# In case you don't have enough elements > ? ? ? ? print 'Not enough elements on the line, moving along' > > ? ? if 10 <= z <= 22: ? # You only wanted between those Z-Coords ? > ? ? ? ? if aa in AMINO_ACIDS: > ? ? ? ? ? ? # Now actually process the data you want > > > > > print "#T/F ?A ?C ?D ?E ?F ?G ?H ?I ?K ?L ?M ?N ?P ?Q ?R ?S ?T ?V ?W ?X ?Y > > Z" > > > for a in range(0,len(matches),1): > > > ? ? if ? ? matches[a][0]==1: > > > ? ? if matches[a][1]=='A': > > ? ? ? ? print "1 ?1:1 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 > > 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? elif matches[a][1]=='C': > > ? ? ? ? print "1 ?1:0 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 > > 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? elif matches[a][1]=='D': > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:1 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > """ ? ?if matches[a][1]=='E' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:1 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='F' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:1 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='G' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:1 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='H' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='I' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:1 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='K' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:1 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='L' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:1 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='M' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:1 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='N' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:1 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='P' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:1 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='Q' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='R' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:1 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='S' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:1 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='T' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:1 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='V' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:1 19:0 20:0 21:0" > > ? ? if matches[a][1]=='X' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:1 20:0 21:0" > > ? ? if matches[a][1]=='Y' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:1 21:0" > > ? ? if matches[a][1]=='Z' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:1" > > > """ > > ? ? else: > > ? ? if matches[a][1]=='A': > > ? ? ? ? print "-1 ?1:1 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 > > 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? elif matches[a][1]=='C': > > ? ? ? ? ? ? print "-1 ?1:0 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? elif matches[a][1]=='D': > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:1 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > """ ? ?if matches[a][1]=='E' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:1 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='F' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:1 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='G' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:1 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='H' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='I' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:1 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='K' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:1 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='L' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:1 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='M' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:1 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='N' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:1 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='P' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:1 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='Q' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='R' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:1 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='S' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:1 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='T' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:1 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='V' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:1 19:0 20:0 21:0" > > ? ? if matches[a][1]=='X' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:1 20:0 21:0" > > ? ? if matches[a][1]=='Y' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:1 21:0" > > ? ? if matches[a][1]=='Z' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:1" > > ? ?waiting for ur opinion. > > ? ?thanks > > > -- > > View this message in context:http://www.nabble.com/new--user-needs-help%21-tp16571823p16596608.html > > Sent from the Python - python-list mailing list archive at Nabble.com. > > Masses of print statements might work for debugging but you can get a > better structure through something else. ?If you have a specific > message for those you could always build a dictionary containing the > messages and access them like.... > > msg_dict = {'A':'Message for A', 'B':'Message for... > > read more ? whoops, forgot the continue statement after the index error for line in myfile: # Files are iterable themselves. try: fields = map(string.strip, line.split('\t')) # This will strip every column for you name, aa, topo, access, tssp, stride, z = fields except IndexError: # In case you don't have enough elements print 'Not enough elements on the line, moving along' continue # This will take your code to the top of the loop and start the next iteration instead of continuing through the code From bruno.42.desthuilliers at wtf.websiteburo.oops.com Tue Apr 1 04:57:47 2008 From: bruno.42.desthuilliers at wtf.websiteburo.oops.com (Bruno Desthuilliers) Date: Tue, 01 Apr 2008 10:57:47 +0200 Subject: Prototype OO In-Reply-To: References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> Message-ID: <47f1f90b$0$27429$426a74cc@news.free.fr> sam a ?crit : > Steven D'Aprano napisa?(a): > >>> I can see that Python and Javascript inheritance model is almost the >>> same. Both languages are dynamically typed. And it seems that using >>> "classes" in Python makes some things more complicated then it is >>> necessary (eg functions, methods and lambdas are differen beeing in >>> Python concept). >> >> Please explain why you think that functions are more complicated in >> Python because of the class model. > > Sorry for a late reply (I was out of the office). > > > 1. You have different syntax for named and unnamed (lambdas) functions. That doesn't make the resulting object different, and this has nothing to do with Python's object model. > Functions and methods are different things in Python even if they have > same syntax. There's *no* syntax for Python methods. Whether you define it at the module's top level, within a class statement or within another function, what you define is a function, period. It's the collaboration between the attribute lookup mechanism and the function objects themselves that yields method objects. > 2. Static function doesn't need to reference "self", and Python forces > programmer to put "self" explicitly. > Then you have to do some "tricks" > on function to become static. Hem... Shouldn't smoke that weird weed they gave you, for sure... If you're talking about staticmethods, they - by definition - don't take the instance as first param. And the 'trick' is mostly: decorate the function with the staticmethod type. Here's how you do it: class Parrot(object): @staticmethod def vroom(): print "vroom" No self, no trick. Now anyway, staticmethod are rarely used - usually, all you need is a plain function (remember that Python doesn't force you into putting everything in a class). Now this still have nothing to do with Python being class-based (for a definition of class-based that's *very* different from Java). > Python is said "nothing is really > private", but interpreter does some "tricks" to make __id hidden for a > class. Not to hide it, but to avoid name clash. > > Some opinions: > > 1. In early days you could do OOP in C -- you just used additional > parameter in a function. While possible, OO in C is definitively a PITA (cf GTK+, OOPC etc). > Then C++ appeared to make life easier: "when > you write mystring.toupper(), then toupper function gets hidden argument > called "this"". Programs are written in a high level object oriented > languages now. In these languages you still use the same syntax > mystring.toupper(), but now you don't pass object to a function (as in > C), but you act on that object. So in the body of toupper() you can > REFERENCE object "mystring". So why do I have to put that "strange" > argument "self"? To allow a simple, uniform and *highly* flexible way to handle functions and methods. Learn about Python's object model (you obviously don't have a clue about it), and specially about the descriptor protocol and how functions implement it, take time to experiment with it and think about all it let you do that you just can't do in C+ or Java, and then I'll be happy to continue this discussion. > This is not only my opinion > (http://apache.ece.arizona.edu/~edatools/Python/Prototypes.htm). Without > "self" you would use same syntax for ordinary functions, methods, and > lambdas. Once again, there's *no* syntax difference between functions and methods, because you *never* define a method. wrt/ lambda, the problem has to do with Python being statemement-based and having significant indentation. > 2. Something is private because you can't reference that from outside > the scope. The wrong way is to make object properties private by > declaring them private or to do hidden actions (__id). For example all > local variables in function are private, because you can't access them > from outside that function. Why desn't this work for objects? Because Python's designer didn't think that language-enforced access restriction was such a good idea. BTW, where are "private" attributes in javascript ?-) > Again this is not only my opinion -- > http://www.crockford.com/javascript/private.html. Answer: a dirty trick using closures... Sam, seriously, why don't start with *learning* about Python's object model ? Seriously ? Not that it's "perfect", not that you have to like it, but if you hope your criticism to be taken seriously, you'd better know what you're talking about. My 2 cents... From paddy3118 at googlemail.com Tue Apr 15 02:58:03 2008 From: paddy3118 at googlemail.com (Paddy) Date: Mon, 14 Apr 2008 23:58:03 -0700 (PDT) Subject: How to make a "command line basd" interactive program? References: Message-ID: <48caf19e-6d43-4357-ac5d-08b6589bd816@m3g2000hsc.googlegroups.com> On Apr 15, 6:35 am, Evan wrote: > that's great, a custom shell is what I need. > > Thanks all > Evan And for the quick-n-dirty there is: python -i yourscript.py Which runs your script then drops you into the interpreter. - Paddy. From patrick.waldo at gmail.com Wed Apr 2 10:23:23 2008 From: patrick.waldo at gmail.com (patrick.waldo at gmail.com) Date: Wed, 2 Apr 2008 07:23:23 -0700 (PDT) Subject: xlrd and cPickle.dump References: <34e62ddb-477f-4a99-97a5-21a7b148d244@e67g2000hsa.googlegroups.com> <47f22a41@news.mel.dft.com.au> <0d46a213-9f95-43b5-835b-d74d8403626b@c19g2000prf.googlegroups.com> <6acbf9b4-161b-47db-9a91-b2448ee63c34@c26g2000prf.googlegroups.com> Message-ID: <12375df7-387d-424d-84a8-76beb664ae47@59g2000hsb.googlegroups.com> Still no luck: Traceback (most recent call last): File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework \scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\text analysis\pickle_test2.py", line 13, in ? cPickle.dump(Data_sheet, pickle_file, -1) PicklingError: Can't pickle : attribute lookup __builtin__.module failed My code remains the same, except I added 'wb' and the -1 following your suggestions: import cPickle,xlrd, sys print sys.version print xlrd.__VERSION__ data_path = """C:\\test\\test.xls""" pickle_path = """C:\\test\\pickle.pickle""" book = xlrd.open_workbook(data_path) Data_sheet = book.sheet_by_index(0) pickle_file = open(pickle_path, 'wb') cPickle.dump(Data_sheet, pickle_file, -1) pickle_file.close() To begin with (I forgot to mention this before) I get this error: WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non- zero I'm not sure what this means. > What do you describe as "simple manipulations"? Please describe your > computer, including how much memory it has. I have a 1.8Ghz HP dv6000 with 2Gb of ram, which should be speedy enough for my programming projects. However, when I try to print out the rows in the excel file, my computer gets very slow and choppy, which makes experimenting slow and frustrating. Maybe cPickle won't solve this problem at all! For this first part, I am trying to make ID numbers for the different permutation of categories, topics, and sub_topics. So I will have [book,non-fiction,biography],[book,non- fiction,history-general],[book,fiction,literature], etc.. so I want the combination of [book,non-fiction,biography] = 1 [book,non-fiction,history-general] = 2 [book,fiction,literature] = 3 etc... My code does this, except sort returns None, which is strange. I just want an alphabetical sort of the first option, which sort should do automatically. When I do a test like >>>nest_list = [['bbc', 'cds'], ['jim', 'ex'],['abc', 'sd']] >>>nest_list.sort() [['abc', 'sd'], ['bbc', 'cds'], ['jim', 'ex']] It works fine, but not for my rows. Here's the code (unpickled/unsorted): import xlrd, pyExcelerator path_file = "C:\\text_analysis\\test.xls" book = xlrd.open_workbook(path_file) ProcFT_QC = book.sheet_by_index(0) log_path = "C:\\text_analysis\\ID_Log.log" logfile = open(log_path,'wb') set_rows = [] rows = [] db = {} n=0 while n Also, any good reason for sticking with Python 2.4? Trying to learn Zope/Plone too, so I'm sticking with Python 2.4. Thanks again From skunkwerk at gmail.com Sun Apr 13 16:54:18 2008 From: skunkwerk at gmail.com (skunkwerk) Date: Sun, 13 Apr 2008 13:54:18 -0700 (PDT) Subject: subprocess.popen function with quotes References: <7f550baf-0622-42a1-bc01-157cf955bca3@i12g2000prf.googlegroups.com> <00e26c78-0d4d-47c2-bf60-601d690b5be3@e23g2000prf.googlegroups.com> <73b93526-fc81-4df7-824f-2e30b3a25456@h11g2000prf.googlegroups.com> <13ukphrj8hng018@corp.supernews.com> Message-ID: On Mar 26, 10:33?pm, skunkwerk wrote: > On Mar 26, 8:05?am, Jeffrey Froman wrote: > > > > >skunkwerkwrote: > > > p = subprocess.Popen(['rename','-vn','s/(.*)\.htm$/ > > > model.html/','*.htm'],stdout=subprocess.PIPE,stderr=subprocess.PIPE) > > > print p.communicate()[0] > > > > i change to print p.communicate()[1] in case the output is blank the > > > first time > > > > this is the output: > > > *.htm renamed as model.html > > > Without shell=True, your glob characters will not be expanded. Hence, the > > command looks for a file actually named "*.htm" > > > > when I add shell=True to the subprocess command, I get the following > > > output: > > > Usage: rename [-v] [-n] [-f] perlexpr [filenames] > > > Here the use of the shell may be confounding the arguments passed. Your > > command will probably work better if you avoid using shell=True. However, > > you will need to perform your own globbing: > > > # Untested (no perl-rename here): > > > command = ['rename','-vn', 's/(.*)\.htm$/model.html/'] > > files = glob.glob('*.htm') > > command.extend(files) > > p = subprocess.Popen( > > ? ? command, > > ? ? stdout=subprocess.PIPE, > > ? ? stderr=subprocess.PIPE, > > ? ? ) > > > Jeffrey > > thanks Jeffrey, that worked like a charm! I'm trying to detect when the subprocess has terminated using the wait() function - but when there is an error with the call to rename (ie the file doesn't exist) rename (when run from the command line just terminates and displays the error). In the code above, though, my call to p.wait() just hangs when rename should throw an error... I've tried adding shell=True but that stops the rename from working. any ideas? thanks From jared.grubb at gmail.com Wed Apr 23 12:59:25 2008 From: jared.grubb at gmail.com (Jared Grubb) Date: Wed, 23 Apr 2008 09:59:25 -0700 Subject: Partition list with predicate Message-ID: <925822270804230959v557ec5f5re02737709f94d3c6@mail.gmail.com> I want a function that removes values from a list if a predicate evaluates to True. The best I could come up with is: def extract(lst, pred): idx = 0 ret = [] for obj in lst[:]: if pred(obj): ret.append(obj) lst.pop(idx) else: idx += 1 return ret Anybody have a better, more Pythonic solution? One of my failed attempts was this code, which fails when the predicate itself has "state": def extract(lst, pred): # BAD: Would not work in a case like pred = "extract every other object" ret = filter(lst, pred) for obj in ret: lst.remove(obj) return ret -------------- next part -------------- An HTML attachment was scrubbed... URL: From soren.skou.nielsen at gmail.com Mon Apr 7 07:50:36 2008 From: soren.skou.nielsen at gmail.com (Soren) Date: Mon, 7 Apr 2008 04:50:36 -0700 (PDT) Subject: Wxpython. Is it possible to change layout in a running application? Selfmade listbox Message-ID: <716c0f27-bca6-4642-a8ec-cdbb0b23e6e8@h1g2000prh.googlegroups.com> Hi, Id like to make my own special listbox.. I want to able (at the push of a button) to add another item to my special listbox... each item is a panel with a label, some buttons and maybe a text control. I've tried adding a new panel object with the stuff i want to the sizer i'm using for my listbox (which is a panel which can contain other panels)... and then run update() and refresh() on everything... But it doesn't work.. i see a panel appearing, but it's just a small square in the corner of my "listbox" panel, and it only works the first time... nothing new appears when I push the button again. Is it at all possible to do this? Has anyone created something similar? Does anyone know what i'm doing wrong? Thanks, Soren From subhabrata.iisc at hotmail.com Thu Apr 10 01:59:24 2008 From: subhabrata.iisc at hotmail.com (subhabrata.iisc at hotmail.com) Date: Wed, 9 Apr 2008 22:59:24 -0700 (PDT) Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> <6641eaF2ics8jU1@mid.uni-berlin.de> <664j0pF2iji99U2@mid.uni-berlin.de> Message-ID: <89872ea1-dc03-4647-b0bc-9d316df3efb5@q1g2000prf.googlegroups.com> I am getting the comments. So any one can post any comment like Steve knows nothing of Python. California has still lot to catch up to be at par with Mesopatamia. comp.lang.python seems a group of fools. Anyhow, all I learnt take whichever suits and ignore rest many people have lot of time to carry out lot of nonsense. Well I should have looked for a paid help and my stand about not giving out my code in open forum stands as prolific. Better not lose time unnecessarily going back to work and debugging the problems is much sensical work that I can do instead of listening to jokes in the morning!!!! Marc 'BlackJack' Rintsch wrote: > On Wed, 09 Apr 2008 16:16:14 +0200, Diez B. Roggisch wrote: > > > And then you reply telling us about the greatness of Bangalore and your > > product to come. Which is somewhat amusing that people who claim to produce > > the greatest software being incapable of debugging it deems me as odd - to > > say the least. > > That's not odd, that's perfectly normal for really clever code: > > Debugging is twice as hard as writing the code in the first > place.Therefore, if you write the code as cleverly as possible, you > are, by definition, not smart enough to debug it. -- Brian W. Kernighan > > ;-) > > Ciao, > Marc 'BlackJack' Rintsch From tnelson at onresolve.com Wed Apr 23 16:17:17 2008 From: tnelson at onresolve.com (Trent Nelson) Date: Wed, 23 Apr 2008 13:17:17 -0700 Subject: Python development tools In-Reply-To: References: Message-ID: <87D3F9C72FBF214DB39FA4E3FE618CDC6E2456CD31@EXMBX04.exchhosting.com> > Are there any completely free developent tools for python > scripts like IDLE. I have used IDLE , but I want to try out > others also. I saw stuff like PyCrust, but I don't see that > it can run the script as well. > Thanks, Ignoring the 'free' part of your question, I've recently moved from PyDev to Wing IDE (www.wingware.com), and would highly recommend it. Trent. From deets at nospam.web.de Mon Apr 21 09:59:20 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Mon, 21 Apr 2008 15:59:20 +0200 Subject: Nested lists, simple though References: <8788db32-30b4-4cae-ab5a-bf6051249294@a9g2000prl.googlegroups.com> Message-ID: <673kujF2n1u62U1@mid.uni-berlin.de> > The first idea that comes to mind is reduce(lambda x, y: x + y, > list_of_lists, []) Which is not helping for arbitrary nested lists, as the OP wanted. Diez From jason.scheirer at gmail.com Fri Apr 18 15:52:06 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Fri, 18 Apr 2008 12:52:06 -0700 (PDT) Subject: Easiest way to get started with WebApps? References: <3c43f29c-3e51-48ab-be02-47402ccd1bfd@b64g2000hsa.googlegroups.com> Message-ID: <37550c25-9d9f-49be-af27-b69b742c995c@n1g2000prb.googlegroups.com> On Apr 18, 12:06 pm, skanem... at yahoo.se wrote: > which is the easiest module to use to just get started with webapps > quicklya nd starting getting things up and running, not advanced stuff > just basic. web.py is probably the most reasonable small webapp framework to get going (it's a very small download and install, with little to no configuration). It does lack a lot of features you may eventually want and you will have to roll yourself, but I really strongly recommend it if you already know something about web programming. I've had a lot of success teaching newbie swith TurboGears, but that's pretty heavyweight and every time you mention it everyone asks why you don't just use Django or Pylons. From billingspanshism at gmail.com Sat Apr 19 17:19:07 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:19:07 -0700 (PDT) Subject: david beckham and victoria beckham Message-ID: Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From mnordhoff at mattnordhoff.com Fri Apr 25 09:08:49 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Fri, 25 Apr 2008 13:08:49 +0000 Subject: problem with unicode In-Reply-To: <26fcc207-b864-42c7-afb3-c6945e5fe29f@m44g2000hsc.googlegroups.com> References: <26fcc207-b864-42c7-afb3-c6945e5fe29f@m44g2000hsc.googlegroups.com> Message-ID: <4811D7E1.2030308@mattnordhoff.com> andreas.profous at googlemail.com wrote: > Hi everybody, > > I'm using the win32 console and have the following short program > excerpt > > # media is a binary string (mysql escaped zipped file) > >>> print media > x???[? ... > (works) > >>> print unicode(media) > UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position > 1: ordinal not in range(128) > (ok i guess print assumes you want to print to ascii) > I don't know what to do. I just want to concatenate two string where > apparently one is a binary string, the other one is a unicode string > and I always seem to get this error. > > Any help is appreciated :) You should read the Python Unicode documentation, such as: and maybe a non-Python-specific article: -- From cor at clsnet.nl Tue Apr 22 18:24:41 2008 From: cor at clsnet.nl (Cor Gest) Date: Tue, 22 Apr 2008 22:24:41 +0000 Subject: pop langs website ranking References: <41fbaf27-a80b-402b-b406-c048a65a8643@b64g2000hsa.googlegroups.com> Message-ID: <873apda5p2.fsf@atthis.clsnet.nl> Some entity, AKA "xahlee at gmail.com" wrote this mindboggling stuff: (selectively-snipped) > My website is now actually ranked higher than PaulGraham.com ! well well, so your site is more popular. You can make it even more popular, you know. Just rename some lame article about how to make a kitty-litter into mytinypussy.html and your hitrate will become astronomical. Cor -- Mijn Tools zijn zo Modern dat ze allemaal eindigen op "saurus" SPAM DELENDA EST http://www.clsnet.nl/mail.php Spamipuku rules the spamwave (defvar My-Computer '((OS . "GNU/Emacs") (IPL . "GNU/Linux"))) From danb_83 at yahoo.com Sun Apr 20 18:54:45 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Sun, 20 Apr 2008 15:54:45 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: <48a1d10c-87cb-43c3-83f4-9c331fc1d818@m1g2000pre.googlegroups.com> On Apr 20, 11:42 am, Matthew Woodcraft wrote: > Christian Heimes wrote: > > >> I feel that including some optional means to block code would be a big > >> step in getting wider adoption of the language in web development and > >> in general. I do understand though, that the current strict indenting > >> is part of the core of the language, so... thoughts? > > Why should Python repeat the mistakes other languages did with SSI or > > inline code? Python favors the MVC separation of code and layout. > > An alternative scheme for describing the block structure could be > useful in other cases, though. For example, if you wanted to support > putting snippets of Python in configuration files, or spreadsheet > cells. > > There's no need to support the new scheme in .py files, so it seems to > me that this doesn't have to be done in the core language. All that's > needed is a variant of 'eval' which expects the alternate scheme, and > that could be prototyped just using text manipulation and the normal > 'eval'. We wouldn't even need that. Just a new source encoding. Then we could write: # -*- coding: end-block -*- def _itoa(num, base): """Return the string representation of a number in the given base.""" if num == 0: return DIGITS[0] end if negative = num < 0 if negative: num = -num end if digits = [] while num: num, last_digit = divmod(num, base) digits.append(DIGITS[last_digit]) end while if negative: digits.append('-') end if return ''.join(reversed(digits)) end def From grg2 at comcast.net Wed Apr 16 10:25:40 2008 From: grg2 at comcast.net (A_H) Date: Wed, 16 Apr 2008 07:25:40 -0700 (PDT) Subject: matplotlib psd Message-ID: <548eaca3-4797-4b77-8583-e176056618ba@d1g2000hsg.googlegroups.com> Kudos to matplotlib in python, it's a real slick package. But I'd like to do several power spectrum density calls [ psd() ] and control the color of each. I don't see any obvious option for this. Any hints? From jtanis at mdchs.org Wed Apr 2 13:22:12 2008 From: jtanis at mdchs.org (James Tanis) Date: Wed, 2 Apr 2008 13:22:12 -0400 Subject: Manipulate Large Binary Files In-Reply-To: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> Message-ID: <74530989b6fe0985f0e21c96093678e2@portal.mdchs.org> "Derek Tracy" wrote: > > INPUT = open(infile, 'rb') > header = FH.read(169088) > > ary = array.array('H', INPUT.read()) > > INPUT.close() > > OUTF1 = open(outfile1, 'wb') > OUTF1.write(header) > > OUTF2 = open(outfile2, 'wb') > ary.tofile(OUTF2) > > > When I try to use the above on files over 2Gb I get: > OverflowError: requested number of bytes is more than a Python string > can hold > > Does anybody have an idea as to how I can get by this hurdle? > If it were me I'd loop until EOF and do small(er) read/write operations rather then attempt to put a whole 2gb file into a single string. Even if it was possible, you'd be using over 2gb of ram for a single operation. Also INPUT.read() returns a string from what I understand.. ary = array.array('c', INPUT.read()) might be more appropriate, but I'm not positive. Anyway I took a short look through array and using ary.fromfile(f, n) might be more appropriate. Using a loop, read some "machine values" with ary.fromfile(f, n) and write them with ary.tofile(f). Catch the EOFError when it is thrown.. I'd imagine that could work. -- James Tanis Technology Coordinator Monsignor Donovan Catholic High School? e: jtanis at mdchs.org p: (706)433-0223 From destroooooy at gmail.com Tue Apr 29 16:39:08 2008 From: destroooooy at gmail.com (destroooooy) Date: Tue, 29 Apr 2008 13:39:08 -0700 (PDT) Subject: string translate, replace, find and the forward slash Message-ID: <1030ffc2-1bbe-4539-881d-35bf59cacd11@34g2000hsh.googlegroups.com> Hi folks, I'm finding some (what I consider) curious behavior with the string methods and the forward slash character. I'm writing a program to rename mp3 files based on their id3 tags, and I want to protect against goofy characters in the in tags. So I do the following: unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n" alt_chars = "_________________________" s_artist.translate(maketranstable(unsafe_chars, alt_chars)) which successfully replaces everything except for forward slashes (at least in the files I've tested so far). If I use the "replace()" method, it also does not work. Escaping the forward slash changes nothing. "find()" however, works, and thus I've resorted to: if "/" in s_artist: (s_l, slash, s_r) = s_artist.partition("/") s_artist = "_".join([s_l, s_r]) which is rather uncool. It works but I'd just like to know what the deal is. TIA. From ridenour4159 at gmail.com Thu Apr 24 06:14:57 2008 From: ridenour4159 at gmail.com (ridenour4159 at gmail.com) Date: Thu, 24 Apr 2008 03:14:57 -0700 (PDT) Subject: xxx crack Message-ID: <4cea9ef9-3699-4586-a947-c2a4ae04d9eb@t54g2000hsg.googlegroups.com> xxx crack http://cracks.12w.net F R E E C R A C K S From fetchinson at googlemail.com Sat Apr 26 01:47:28 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Fri, 25 Apr 2008 22:47:28 -0700 Subject: MESSAGE RESPONSE In-Reply-To: References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> <678v5qF2me5rvU1@mid.uni-berlin.de> <4e89b45d-198c-48ca-a3a6-3ba42448cb2b@e53g2000hsa.googlegroups.com> Message-ID: > >> And as such, I find it hard to believe you could lose your job > >> over it. > > > > Me too. That is, until I tried to Google Belcan and Blubaugh > > together. May I suggest a new thread to clear that ugly > > results? :D > > I know it's not nice to laugh at things like that, but I can't > help it... > > I never saw the original message, so I didn't know exactly what > he was objecting to. I did know that what he was doing was, > well, let's just say counter-productive. Same here :) I had no idea what this thread is about until I searched for belcan and Blubaugh. David! It's actually very simple to filter messages, you just need to install a spam filter like spamassassin or something similar. Then you will not get fired from belcan because of your "I'm feeling lucky" google hit. From bronger at physik.rwth-aachen.de Tue Apr 29 12:26:11 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Tue, 29 Apr 2008 18:26:11 +0200 Subject: Simple unicode-safe version of str(exception)? References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> <67on2nF2ol856U1@mid.individual.net> Message-ID: <87zlrcmxuk.fsf@physik.rwth-aachen.de> Hall?chen! Russell E. Owen writes: > [...] > > So...to repeat the original question, is there any simpler > unicode-safe replacement for str(exception)? Please show us the tracebacks you get becuae unicode(s) must fail, too, if there are non-ASCII characters involved. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From diesch at spamfence.net Wed Apr 30 04:34:47 2008 From: diesch at spamfence.net (Florian Diesch) Date: Wed, 30 Apr 2008 10:34:47 +0200 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> <480fa6e3$0$34491$742ec2ed@news.sonic.net> <7xzlrj14r7.fsf@ruckus.brouhaha.com> <4811edad$0$34525$742ec2ed@news.sonic.net> Message-ID: <7inle5-sgo.ln1@mid.florian-diesch.de> John Nagle wrote: > Perl has CPAN, which is reasonably comprehensive and presents modules > in a uniform way. If you need a common Perl module that's not in the > Perl distro, it's probably in CPAN. "Installing a new module can be as > simple as typing perl -MCPAN -e 'install Chocolate::Belgian'." > So Perl has exactly that. > > Python's Cheese Shop is just a list of links to packages > elsewhere. There's no uniformity, no standard installation, no > standard uninstallation, and no standard version control. Python has easy_install Florian -- ----------------------------------------------------------------------- ** Hi! I'm a signature virus! Copy me into your signature, please! ** ----------------------------------------------------------------------- From musiccomposition at gmail.com Tue Apr 1 22:34:47 2008 From: musiccomposition at gmail.com (Benjamin) Date: Tue, 1 Apr 2008 19:34:47 -0700 (PDT) Subject: Using QSystemTrayIcon with PyQt References: <76680315-cadd-42ad-942c-3e89536819df@i12g2000prf.googlegroups.com> <6d0b8776-bb64-4a58-8ccb-46efa35d75a2@s50g2000hsb.googlegroups.com> <1a8a5b03-0b9e-49de-bd87-43fa1aa99dc2@b5g2000pri.googlegroups.com> <6b732135-a488-4175-889b-0cccf5f0c581@s8g2000prg.googlegroups.com> Message-ID: <29632af8-2ed5-434a-aaaa-1c1c51dd4f1d@m44g2000hsc.googlegroups.com> On Apr 1, 7:56 am, BlueBird wrote: > On Apr 1, 6:00 am, Alex Teiche wrote: > > > > > On Mar 31, 7:53 pm, Benjamin wrote: > > > > On Mar 31, 8:41 pm, Alex Teiche wrote: > > > > > On Mar 31, 6:40 pm, Alex Teiche wrote: > > > > > > On Mar 31, 11:49 am, Alex Teiche wrote: > > > > > > > On Mar 30, 3:50 pm, Benjamin wrote: > > > > > > > > On Mar 29, 11:02 pm, Alex Teiche wrote:> Hello, > > > > > > > > > I am pretty new to Python, and have never learned C++. I am trying to > > > > > > > > implement the following thing into my python application: > > > > > > > > >http://doc.trolltech.com/4.3/qsystemtrayicon.html > > > > > > > > > Through PyQt. I have been using PyQt for awhile and I know how do use > > > > > > > > it, but I could not get this specific thing to work. Can someone give > > > > > > > > me some hints as to get it working in Python? > > > > > > > > What problems are you having? > > > > > > > > > Thanks a ton, > > > > > > > > > Alex > > > > > > > Thanks everyone for your help. I found the example to be particularly > > > > > > helpful, and I have made a simplified version just to display an icon > > > > > > with a quit button in its menu. Once I know how to do that I will > > > > > > incorporate it into my larger program, with more options and the > > > > > > ability show messages. The problem is, it doesn't work, and I can't > > > > > > find out what's wrong. Can you give me some hints? > > > > > > > Here is the code: > > > > > > import sys > > > > > > from PyQt4 import QtGui, QtCore > > > > > > > class trayIcon(QtGui.QWidget): > > > > > > def __init__(self, parent=None): > > > > > > QtGui.QWidget.__init__(self, parent) > > > > > > > #********Create Actions for the Tray Menu********# > > > > > > self.quitAction = QtGui.QAction(self.tr("&Quit"), self) > > > > > > QtCore.QObject.connect(self.quitAction, > > > > > > QtCore.SIGNAL("triggered()"), QtGui.qApp, QtCore.SLOT("quit()")) > > > > > > > create_tray_icon() > > > > > > > self.composeAction.setEnabled(visible) > > > > > > QtGui.QWidget.setVisible(self, visible) > > > > > > > self.trayIcon.show() > > > > > > > def create_tray_icon(self): > > > > > > self.trayIconMenu = QtGui.QMenu(self) > > > > > > self.trayIconMenu.addAction(self.composeAction) > > > > > > self.trayIcon = QtGui.QSystemTrayIcon(self) > > > > > > self.trayIcon.setContextMenu(self.trayIconMenu) > > > > > > self.trayIcon.setIcon(bad.svg) > > > > > > > app = QtGui.QApplication(sys.argv) > > > > > > sys.exit(app.exec_()) > > > > > > OK, I messed around with it some more, and it works. I just don't > > > > > know how to set an icon, and the example doesn't help at all. > > > > > > Here is the code: > > > > > import sys > > > > > from PyQt4 import QtCore, QtGui > > > > > > class Systray(QtGui.QWidget): > > > > > def __init__(self): > > > > > QtGui.QWidget.__init__(self) > > > > > > self.createActions() > > > > > self.createTrayIcon() > > > > > > #QtCore.QObject.connect(self.trayIcon, > > > > > QtCore.SIGNAL("messageClicked()"), self.messageClicked) > > > > > #QtCore.QObject.connect(self.trayIcon, > > > > > QtCore.SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), > > > > > self.iconActivated) > > > > > > self.trayIcon.show() > > > > > > def createActions(self): > > > > > #self.minimizeAction = QtGui.QAction(self.tr("Mi&nimize"), self) > > > > > #QtCore.QObject.connect(self.minimizeAction, > > > > > # QtCore.SIGNAL("triggered()"), self, QtCore.SLOT("hide()")) > > > > > > #self.maximizeAction = QtGui.QAction(self.tr("Ma&ximize"), self) > > > > > #QtCore.QObject.connect(self.maximizeAction, > > > > > # QtCore.SIGNAL("triggered()"), self, > > > > > # QtCore.SLOT("showMaximized()")) > > > > > > #self.restoreAction = QtGui.QAction(self.tr("&Restore"), self) > > > > > #QtCore.QObject.connect(self.restoreAction, > > > > > # QtCore.SIGNAL("triggered()"), self, > > > > > # QtCore.SLOT("showNormal()")) > > > > > > self.quitAction = QtGui.QAction(self.tr("&Quit"), self) > > > > > QtCore.QObject.connect(self.quitAction, QtCore.SIGNAL("triggered()"), > > > > > QtGui.qApp, QtCore.SLOT("quit()")) > > > > > > def createTrayIcon(self): > > > > > self.trayIconMenu = QtGui.QMenu(self) > > > > > #self.trayIconMenu.addAction(self.minimizeAction) > > > > > #self.trayIconMenu.addAction(self.maximizeAction) > > > > > #self.trayIconMenu.addAction(self.restoreAction) > > > > > #self.trayIconMenu.addSeparator() > > > > > self.trayIconMenu.addAction(self.quitAction) > > > > > > self.trayIcon = QtGui.QSystemTrayIcon(self) > > > > > self.trayIcon.setContextMenu(self.trayIconMenu) > > > > > > app = QtGui.QApplication(sys.argv) > > > > > x = Systray() > > > > > sys.exit(app.exec_()) > > > > > > How would I go about setting the icon? > > > > > Sorry, here is the code with commented out lines removed: > > > > > import sys > > > > from PyQt4 import QtCore, QtGui > > > > > class Systray(QtGui.QWidget): > > > > def __init__(self): > > > > QtGui.QWidget.__init__(self) > > > > > self.createActions() > > > > self.createTrayIcon() > > > > > self.trayIcon.show() > > > > > def createActions(self): > > > > > self.quitAction = QtGui.QAction(self.tr("&Quit"), self) > > > > QtCore.QObject.connect(self.quitAction, QtCore.SIGNAL("triggered()"), > > > > QtGui.qApp, QtCore.SLOT("quit()")) > > > > > def createTrayIcon(self): > > > > self.trayIconMenu = QtGui.QMenu(self) > > > > self.trayIconMenu.addAction(self.quitAction) > > > > > self.trayIcon = QtGui.QSystemTrayIcon(self) > > > > self.trayIcon.setContextMenu(self.trayIconMenu) > > > > > app = QtGui.QApplication(sys.argv) > > > > x = Systray() > > > > sys.exit(app.exec_()) > > > > I believe the method you want is QSystemTrayIcon.setIcon. > > > I found that, but what do I pass into it? Passing a string to a .svg > > file doesn't work. > > http://www.riverbankcomputing.com/Docs/PyQt4/html/qsystemtrayicon.htm... > > So, you must pass a QIcon. > > Now, the doc of QIcon:http://www.riverbankcomputing.com/Docs/PyQt4/html/qicon.html > > Oh, the list of supported file format is described separately in:http://www.riverbankcomputing.com/Docs/PyQt4/html/qimagereader.html#s... > > I see that svg is not part of that list. So, it is not surprising that > it does not work but there are plenty of other formats that will work. Well, you can use the QtSvg module to add support for them. > > It took me about 20 seconds to solve your problem by reading the > appropriate documentation. I suggest you do that too in the future... > > regards, > > Philippe From grante at visi.com Wed Apr 2 17:19:48 2008 From: grante at visi.com (Grant Edwards) Date: Wed, 02 Apr 2008 16:19:48 -0500 Subject: april fools email backfires References: <7xbq4sf9wv.fsf@ruckus.brouhaha.com> Message-ID: On 2008-04-02, D'Arcy J.M. Cain wrote: > I nearly fell off my chair when I read this one. > > WE EXPECT FULL CHARACTER SET SUPPORT FOR EBCDIC AND A LARGE SUBSET > OF ASCII IN THE 1.34 RELEASE. TIHS WILL INCLUDE SUPPORT FOR SPECIAL CHR > SUCH AS THE EURO SYMBOL AND LOWER CASE LETTERS. Just don't hold your breath waiting for curly braces... -- Grant Edwards grante Yow! It's NO USE ... I've at gone to "CLUB MED"!! visi.com From grante at visi.com Wed Apr 2 13:29:58 2008 From: grante at visi.com (Grant Edwards) Date: Wed, 02 Apr 2008 12:29:58 -0500 Subject: april fools email backfires References: <7xbq4sf9wv.fsf@ruckus.brouhaha.com> Message-ID: On 2008-04-02, Paul Rubin wrote: > Django, pah. They should switch to something REALLY advanced: > > http://www.coboloncogs.org/INDEX.HTM ROTFLMAO! That's absolutely brilliant! I particularly like the flashing effect that simulates an old screen-at-time mode terminal (or maybe a storage-scope terminal?), and the faint "burn-in" text in the background. -- Grant Edwards grante Yow! I'm having an at EMOTIONAL OUTBURST!! But, visi.com uh, WHY is there a WAFFLE in my PAJAMA POCKET?? From xng at xs4all.nl Sat Apr 5 22:04:12 2008 From: xng at xs4all.nl (Martin P. Hellwig) Date: Sun, 06 Apr 2008 04:04:12 +0200 Subject: sys.path and importing modules from other directories Message-ID: <47f82f9e$0$15728$e4fe514c@dreader26.news.xs4all.nl> Hello all, I had some troubles in the past how to arrange my packages and modules, because I usually don't develop my stuff in the Lib\site-packages directory I have some troubles when importing depending modules that are in 'sibling' directories. Like in the following scenario: pkg_root\ -__init__ - common\ - - __init__ - - something - other\ - - __init__ - - working_on So when I am busy with 'working_on' and want to import from common something it won't let me do that because I don't have pkg_root in my path. No biggy here, I just add the pkg_root to the path. Once I am finished most of the time all modules are initiated from a module directly at the pkg_root level so then importing works without worries. However it has irritated me enough that I wrote a little script I called 'relative_path.py' that I put in my python path that does these things for me, so that I only need to import that one and set the parent path, probably I missed a point here somewhere but if not maybe somebody else finds it useful. So while I am developing the depending modules, these modules begin with: import relative_path relative_path.add_package_root() +++ import os, sys def getparent(depth=0): "Returns the absolute pathname of (grand)parents directory." # By default it returns the current working directory. # The level of 'grand' is set by depth. getcwd = os.getcwd sep = os.sep abspath = os.path.abspath if depth == 0: grand = None else: grand = depth * -1 # Main function # From the current working directory get the absolute path, # split it and join the wanted portion of the list. pathname = sep.join(abspath(getcwd()).split(sep)[:grand]) # Make sure to throw an exception if depth results in an empty string. if len(pathname) == 0: raise_string = "(grand)Parent depth of %s is before root." % depth raise(LookupError(raise_string)) else: return(pathname) def add_package_root(directory=1): "Add a parent directory relative to cwd to sys.path, default the first." sys.path.append(getparent(directory)) +++ -- mph From stef.mientki at gmail.com Wed Apr 2 16:32:39 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Wed, 02 Apr 2008 22:32:39 +0200 Subject: Python in High School In-Reply-To: <58deb8b8-bae9-4d43-b973-3d90846726cb@b5g2000pri.googlegroups.com> References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> <58deb8b8-bae9-4d43-b973-3d90846726cb@b5g2000pri.googlegroups.com> Message-ID: <47F3ED67.90300@gmail.com> John Henry wrote: > On Apr 1, 11:10 am, sprad wrote: > >> On Apr 1, 11:41 am, mdomans wrote: >> >> >>> Python needs no evangelizing but I can tell you that it is a powerfull >>> tool. I prefer to think that flash is rather visualization tool than >>> programing language, and java needs a lot of typing and a lot of >>> reading. On the other hand python is simple to read and write, can be >>> debuged easily, is intuitive and saves a lot of time. It also supports >>> batteries included policy and you can't get more OO than python. >>> >> One advantage of Flash is that we can have something moving on the >> screen from day one, and add code to it piece by piece for things like >> keyboard or mouse control, more and more complex physics, etc. Is >> there an equivalent project in Python? >> > > I downloaded the "How to Think Like a Python Programmer" book and read > it. I think it's a fine reference book for the purpose you > indicated. > > Here's my 2 cents on the subject. > > I had been a volunteer mentor to my son's middle school robotic team > for several years and I have some experiences, therefore, in how kids > react to "programming". Granted, high school kids are "bigger kids" - > but they are kids nevertheless. > > Last summer, I experimented teaching my own kid Python. He was in 7th > grade going onto 8th grade. He was the main goto person for the > robotic team and had no trouble learning the common applications such > as the Microsoft Office suite, and had some experience in ICONic > programming (Lego Mindstorm). So, I tried to see what would happen if > he tries to learn Python - using somewhat similar approach you are > taking: start with something visually appealing on day one. Instead > of Flash, I used Pythoncard - a no-brainer Python GUI construction > toolkit. He was really excited seeing how easy it was to have tic-tae- > toe type program up so easily (we are taking minutes - not hours) and > was very interested and motivated to continue. So far so good. > However, once I start teaching him variables, expressions, loops, and > what not, I found that (by surprise) he had great difficulties > catching on. Not soon after that, we had to quit. > > We - as adults - take many things for granted and sometimes don't > remember, or don't understand how kids learn. My experience tells me > that in order to teach today's video game generation of kids, the > approach really has to be entirely visual. After I abandoned my > attempt to teach my kid Python, I started them on Robolab - a > simplified version of LabView and to my delight, they were able to > cook up a few simple programs (like fibonacci series and so forth) > without too much effort - although my own kid had some minor trouble > understanding the concept of a container (LabView's version of a > variable). > > I don't know if you have access to LabView or Robolab or similar > packages but if you do, I would highly recommend those. LabView is > every bit as powerful, full-featured, and "real-life" as many of the > other languages and I believe that kids will have a much easier time > learning computer programming with it. > Well I doubt it's the visual environment that makes it more easy, color, shape and position can give some extra information though. I think apriori domain knowledge and flattness of information are of far more importance. The first issue is covered quit well by Robolab / Labview, but the second issue certainly is not. I'm right now working on a Labview like editor in Python, which does obey the demand for flatness of information. The first results can be seen here: http://oase.uci.kun.nl/~mientki/data_www/pylab_works/pw_animations_screenshots.html cheers, Stef Mientki > And you are going to teach them Java? Oh, please don't. Let the > colleges torture them. :=) > From arnlen at mac.com Wed Apr 30 10:15:50 2008 From: arnlen at mac.com (Jumping Arne) Date: Wed, 30 Apr 2008 16:15:50 +0200 Subject: PIL and IPTC Message-ID: <0001HW.C43E4BB60060D69EB01AD9AF@news.individual.de> I'm completely new to PIL and I'm trying to read IPTC info, I understand that it's possible but I can't find out how (and for once Google doesn't seem to be able to help). Does anyone have an example of how it's done? From paul.anton.letnes at gmail.com Wed Apr 9 16:13:59 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Wed, 9 Apr 2008 22:13:59 +0200 Subject: wrapping C functions in python Message-ID: Hello etc. I am a "scientific" user of Python, and hence have to write some performance critical algorithms. Right now, I am learning Python, so this is a "newbie" question. I would like to wrap some heavy C functions inside Python, specifically a wavelet transform. I am beginning to become aquainted with the functions PyArg_ParseTuple() and Py_BuildValue(). However, I am unable to figure out how to pass Python list -> C function or C array -> return value in Python. I manage to build and run the C function, print to screen, pass string as argument, return an int, etc. The thing which is missing is the magic array/list... Thanks in advance! I fart in your general direction. Paul. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdw at distorted.org.uk Wed Apr 23 10:38:45 2008 From: mdw at distorted.org.uk (Mark Wooding) Date: Wed, 23 Apr 2008 14:38:45 +0000 (UTC) Subject: [Python 2.4/2.5] subprocess module is sorely deficient? References: <811891.72800.qm@web39208.mail.mud.yahoo.com> Message-ID: Harishankar wrote: > On Wednesday 23 Apr 2008 15:11:21 Ben Kaplan wrote: >> I don't know about all Linux distros, but my Ubuntu machine (8.04 Beta), >> has the 'TERM' (xterm) and 'COLORTERM' (gnome-terminal) keys in os.environ. > This is set on Debian too. Thanks. I should be able to use this environment > variable on most Linux distributions, I suspect. No! The TERM variable is not the name of a terminal emulation program! It's a terminal name intended to be looked up in the termcap and/or terminfo databases. For example, I use pterm as my terminal, but it (correctly) sets TERM=xterm. I'd suggest trying to run (in order, until one actually works): $X_TERMINAL_EMULATOR, sensible-x-terminal-emulator, x-terminal-emulator, xterm. -- [mdw] From pauljefferson at gmail.com Mon Apr 28 14:45:42 2008 From: pauljefferson at gmail.com (Paul Jefferson) Date: Mon, 28 Apr 2008 19:45:42 +0100 Subject: Newbie Help - Alarms Message-ID: Hi, I'm new to this having previously done some programming in Game Maker. In Game Maker there was a function (Alarm) that lets you run a block of code run every x seconds without freezing up the whole program waiting for it. Is there an equavalant for this built in Python beacuse I can't find it? Thanks for any help, Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: From bockman at virgilio.it Sat Apr 5 09:22:19 2008 From: bockman at virgilio.it (Francesco Bochicchio) Date: 05 Apr 2008 13:22:19 GMT Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> Message-ID: <47f77d0a$0$17945$5fc30a8@news.tiscali.it> Il Fri, 04 Apr 2008 20:26:13 -0700, 7stud ha scritto: > On Apr 4, 7:06?pm, skanem... at yahoo.se wrote: >> 1st question: >> >> when i run this program 1 will be printed into the interpreter when i >> run it BUT without me clicking the actual button. when i then click the >> button "1", nothing happens. >> >> obv i dont want any output when i dont push the button but i want it >> when i do. >> >> what am i doing wrong here? >> ... > > The same thing is happening in this portion of your code: > > command = self.Display(1) > > That code tells python to execute the Display function and assign the > function's return value to the variable command. As a result Display > executes and 1 is displayed. Then since Dispay does not have a return > statement, None is returned, and None is assigned to command. Obviously, > that is not what you want to do. > > What you want to do is assign a "function reference" to command so that > python can execute the function sometime later when you click on the > button. A function reference is just the function name without the '()' > after it. So you would write: > > command = self.Display > > But writing it like that doesn't allow *you* to pass any arguments to > Display(). In addition, *tkinter* does not pass any arguments to > Display when tkinter calls Display in response to a button click. As a > result, there is no way to pass an argument to Display. > It should be added here that in Python you have several ways get around this Tkinter limitation and pass an user argument to the callback. Once upon a time , back in Python 1.x, I used to do something like this: class CallIt: def __init__(self, f, *args): self.f = f self.args = args def __call__(self): return apply(self.f, self.args) and then, to do what the OP wanted to do: command = CallIt(self.Display, 1) but nowadays, you can achieve the same effect with: command = functtools.partial(self.Display,1) Ciao ---- FB From grflanagan at gmail.com Mon Apr 21 08:23:40 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Mon, 21 Apr 2008 05:23:40 -0700 (PDT) Subject: manipulating class attributes from a decorator while the class is being defined References: Message-ID: On Apr 19, 11:19 pm, Wilbert Berendsen wrote: > Hi, is it possible to manipulate class attributes from within a decorator > while the class is being defined? > > I want to register methods with some additional values in a class attribute. > But I can't get a decorator to change a class attribute while the class is > still being defined. Something like: > > class Parser(object): > > regexps = [] > def reg(regexp): > def deco(func): > regexps.append((regexp, func)) > return func > return deco > > @reg(r'".*"') > def quoted_string(self): > pass > > How can I reach the class attribute `regexps' from within a decorator? > > Thanks for any help, > Wilbert Berendsen > > --http://www.wilbertberendsen.nl/ > "You must be the change you wish to see in the world." > -- Mahatma Gandhi --------------------------------------------------- def reg(regexp): def deco(func): def inner(self, *args, **kw): if not hasattr(self, 'regexps'): self.regexps = [] self.regexps.append((regexp, func)) return func(self, *args, **kw) return inner return deco class Parser(object): regexps = [] @reg(r'".*"') def quoted_string(self): print 'hi' p = Parser() p.quoted_string() print p.regexps --------------------------------------------------- From arnodel at googlemail.com Thu Apr 24 16:33:07 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 24 Apr 2008 21:33:07 +0100 Subject: Parsing text file with #include and #define directives References: Message-ID: python at bdurham.com writes: > I'm parsing a text file for a proprietary product that has the following > 2 directives: > > #include > #define > > Defined constants are referenced via <#name#> syntax. > > I'm looking for a single text stream that results from processing a file > containing these directives. Even better would be an iterator(?) type > object that tracked file names and line numbers as it returns individual > lines. > > Is there a Python parsing library to handle this type of task or am I > better off writing my own? > > The effort to write one from scratch doesn't seem too difficult (minus > recursive file and constant loops), but I wanted to avoid re-inventing > the wheel if this type of component already exists. > > Thank you, > > Malcolm I think it's straightforward enough to be dealt with simply. Here is a solution that doesn't handle errors but should work with well-formed input and handles recursive expansions. expand(filename) returns an iterator over expanded lines in the file, inserting lines of included files. import re def expand(filename): defines = {} def define_repl(matchobj): return defines[matchobj.group(1)] define_regexp = re.compile('#(.+?)#') for line in open(filename): if line.startswith('#include '): recfilename = line.strip().split(None, 1)[1] for recline in expand(recfilename): yield recline elif line.startswith('#define '): _, name, value = line.strip().split(None, 2) defines[name] = value else: yield define_regexp.sub(define_repl, line) It would be easy to modify it to keep track of line numbers and file names. HTH -- Arnaud From adelagon at gmail.com Thu Apr 10 03:17:59 2008 From: adelagon at gmail.com (Alvin Delagon) Date: Thu, 10 Apr 2008 15:17:59 +0800 Subject: PyArg_ParseTuple for structs or binary data Message-ID: <7a01f6c00804100017u116dc4c3oc3a95f634663a5cb@mail.gmail.com> Hello Gabriel, I just recently discovered that struct.pack does return a string. Everything works fine now. Thanks for the heads up! static PyObject * sendMessage(PyObject *self, PyObject *args) { char *msg = ""; int len; if (!PyArg_ParseTuple(args, "s#", &msg, &len)) return NULL; ret = sctp_sendmsg(connSock, msg, len, 0, 0, 0x03000000, 0, 0x01, 0, 0); return Py_BuildValue("l", ret); } --- Alvin Delagon -------------- next part -------------- An HTML attachment was scrubbed... URL: From info at wingware.com Mon Apr 28 11:28:57 2008 From: info at wingware.com (Wingware) Date: Mon, 28 Apr 2008 11:28:57 -0400 Subject: Wing IDE 3.0.5 released Message-ID: <4815ED39.2080502@wingware.com> Hi, We're happy to announce version 3.0.5 of Wing IDE, an integrated development environment for the Python programming language. It is available from: http://wingware.com/downloads Version 3.0.5 is a bug fix release that adds many vi mode improvements, improves stability, and fixes other usability bugs. See the change log at http://wingware.com/pub/wingide/3.0.5/CHANGELOG.txt for details. It is a free upgrade for all Wing 3.0 users. *About Wing IDE* Wing IDE is an integrated development environment for the Python programming language. It provides powerful debugging, editing, code intelligence, testing, and search capabilities that reduce development and debugging time, cut down on coding errors, and make it easier to understand and navigate Python code. New features added in Wing 3.0 include: * Multi-threaded debugger * Debug value tooltips in editor, debug probe, and interactive shell * Autocompletion and call tips in debug probe and interactive shell * Automatically updating project directories * Testing tool, currently supporting unittest derived tests (*) * OS Commands tool for executing and interacting with external commands (*) * Rewritten indentation analysis and conversion (*) * Introduction of Wing IDE 101, a free edition for beginning programmers * Available as a .deb package for Debian and Ubuntu * Support for Stackless Python * Support for 64 bit Python on Windows and Linux (*)'d items are available in Wing IDE Professional only. System requirements are Windows 2000 or later, OS X 10.3.9 or later for PPC or Intel (requires X11 Server), or a recent Linux system (either 32 or 64 bit). *Purchasing and Upgrading* Wing IDE Professional & Wing IDE Personal are commercial software and require a license to run. To upgrade a 2.x license or purchase a new 3.x license: Upgrade https://wingware.com/store/upgrade Purchase https://wingware.com/store/purchase Any 2.x license sold after May 2nd 2006 is free to upgrade; others cost 1/2 the normal price to upgrade. -- The Wingware Team Wingware | Python IDE Advancing Software Development www.wingware.com From arnodel at googlemail.com Fri Apr 25 01:11:45 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Fri, 25 Apr 2008 06:11:45 +0100 Subject: Class Inheritance - What am I doing wrong? References: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> <613bc152-a6f4-4db4-8f90-593cb3f629c7@s33g2000pri.googlegroups.com> Message-ID: Brian Munroe writes: > Ok, so thanks everyone for the helpful hints. That *was* a typo on my > part (should've been super(B...) not super(A..), but I digress) > > I'm building a public API. Along with the API I have a few custom > types that I'm expecting API users to extend, if they need too. If I > don't use name mangling, isn't that considered bad practice (read not > defensive programming) to not protect those 'private' fields? The problem is that you are using name mangling for an attribute which is accessed by several generations of a class hierarchy. Name mangling is only useful for attributes you *don't* want to share with subclasses (or bases). In python, use attributes starting with a single underscore (such as _name). It tells users that they shouldn't mess with them. By design, python doesn't include mechanisms equivalent to the Java / C++ 'private'. -- Arnaud From arnlen at mac.com Wed Apr 16 06:21:13 2008 From: arnlen at mac.com (Jumping Arne) Date: Wed, 16 Apr 2008 12:21:13 +0200 Subject: Image handling - stupid question Message-ID: <0001HW.C42B9FB90009B7E8B01AD9AF@news.individual.de> I'm going to try to write some imange manipulation code (scaling, reading EXIF and IPTC info) and just want to ask if PIL is *THE* library to use? I looked at and noticed that the latest version is from Dec 2006. In my experience that means that either it's abandoned or that it's very good and stable. From mnordhoff at mattnordhoff.com Tue Apr 8 11:27:23 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Tue, 08 Apr 2008 15:27:23 +0000 Subject: import statement convention In-Reply-To: <4078bcf4-e68f-45d4-93ce-335ec7a33c5a@v32g2000prd.googlegroups.com> References: <4078bcf4-e68f-45d4-93ce-335ec7a33c5a@v32g2000prd.googlegroups.com> Message-ID: <47FB8EDB.9040903@mattnordhoff.com> MartinRinehart at gmail.com wrote: > By convention, I've read, your module begins with its import > statements. Is this always sensible? > > I put imports that are needed for testing in the test code at the end > of the module. If only a bit of the module has a visual interface, why > pollute the global namespace with 'from Tkinter import *'? Wouldn't > that be better done in a separate class or function? > > Can we do a better job with a thoughtful rewrite of this convention? I don't think anyone has been beheaded for breaking from convention when there's a good reason... The Zen of Python does say "Although practicality beats purity.". (One useful related thing is the lazy import modules developed by e.g. Bazaar and Mercurial, where you can "import foo" at the top level, but the import won't really be done until it's actually used.) -- From frikker at gmail.com Wed Apr 23 12:09:37 2008 From: frikker at gmail.com (blaine) Date: Wed, 23 Apr 2008 09:09:37 -0700 (PDT) Subject: Unix Device File Emulation References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> Message-ID: On Apr 23, 11:17 am, "Ville M. Vainio" wrote: > blaine wrote: > > example usage: echo 'line 0 0 10 10' > /dev/screen > > > On the actual embedded device this is handled by a kernel module. We > > can spit commands into it as fast as we can and the kernel module can > > keep up. This is typical unix device file behavior. > > > Any suggestions or advice would be splendid. Thanks! > > Assuming you are on unix, have you considered FIFO's, os.mkfifo()? Thank you - this is exactly what I need, I believe. I'm having a problem though. The os.mkfifo() works fine, but when I read from the file my blocking calls dont work as intended... See below: # Fake Nokia Screen Emulator import sys, os class nokia_fkscrn: def __init__(self, file): if not os.path.exists(file): os.mkfifo(file) self.fifodev = open(file, 'r') def read(self): while 1: r = self.fifodev.readline() print r nokia = nokia_fkscrn('dev.file') nokia.read() This works at first, but when I write to the 'dev.file' for the first time, the text is displayed as intended, but then the program just keeps spitting out blank lines. I can continue to write to the file (using echo 'test\n' > dev.file) and this shows up in my output, but amist a giant mass of scrolling blank lines. This also causes my CPU usage to shoot up to 100%. Any ideas? This is OS X 10.4 -Blaine From tim.arnold at sas.com Thu Apr 24 12:48:18 2008 From: tim.arnold at sas.com (Tim Arnold) Date: Thu, 24 Apr 2008 12:48:18 -0400 Subject: convert xhtml back to html References: Message-ID: "Arnaud Delobelle" wrote in message news:m28wz3cjd1.fsf at googlemail.com... > "Tim Arnold" writes: > >> hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop >> to >> create CHM files. That application really hates xhtml, so I need to >> convert >> self-ending tags (e.g.
) to plain html (e.g.
). >> >> Seems simple enough, but I'm having some trouble with it. regexps trip up >> because I also have to take into account 'img', 'meta', 'link' tags, not >> just the simple 'br' and 'hr' tags. Well, maybe there's a simple way to >> do >> that with regexps, but my simpleminded )]+/> doesn't work. I'm >> not >> enough of a regexp pro to figure out that lookahead stuff. > > Hi, I'm not sure if this is very helpful but the following works on > the very simple example below. > >>>> import re >>>> xhtml = '

hello spam
bye

' >>>> xtag = re.compile(r'<([^>]*?)/>') >>>> xtag.sub(r'<\1>', xhtml) > '

hello spam
bye

' > > > -- > Arnaud Thanks for that. It is helpful--I guess I had a brain malfunction. Your example will work for me I'm pretty sure, except in some cases where the IMG alt text contains a gt sign. I'm not sure that's even possible, so maybe this will do the job. thanks, --Tim From ricky.zhou at gmail.com Tue Apr 8 00:09:36 2008 From: ricky.zhou at gmail.com (Ricky Zhou) Date: Tue, 8 Apr 2008 00:09:36 -0400 Subject: Newbie: How to pass a dictionary to a function? In-Reply-To: <516e07d1-91f9-462b-9fc0-ac6d1e474f9d@n14g2000pri.googlegroups.com> References: <516e07d1-91f9-462b-9fc0-ac6d1e474f9d@n14g2000pri.googlegroups.com> Message-ID: <20080408040936.GR32030@Max> On 2008-04-07 08:54:09 PM, BonusOnus wrote: > How do I pass a dictionary to a function as an argument? > > > # Say I have a function foo... > def foo (arg=[]): Try: def foo(arg={}): Thanks, Ricky -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available URL: From p at ulmcnett.com Fri Apr 25 14:54:23 2008 From: p at ulmcnett.com (Paul McNett) Date: Fri, 25 Apr 2008 11:54:23 -0700 Subject: Why is None <= 0 In-Reply-To: References: Message-ID: <481228DF.5010408@ulmcnett.com> Gregor Horvath wrote: > >>> None <= 0 > True More accurately: >>> None < 0 True > Why? > Is there a logical reason? None is "less than" everything except for itself: >>> None < 'a' True >>> None < False True >>> None == None True In my humble opinion, I think that comparisons involving None should return None, but I trust that the designers came up with this for very good reasons. As far as I know I've never been bitten by it. Paul From fn681 at ncf.ca Sun Apr 6 17:03:55 2008 From: fn681 at ncf.ca (Colin J. Williams) Date: Sun, 06 Apr 2008 18:03:55 -0300 Subject: A funnily inconsistent behavior of int and float In-Reply-To: References: Message-ID: Grant Edwards wrote: > On 2008-04-06, Lie wrote: > >> I've noticed some oddly inconsistent behavior with int and float: >> >> Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) >> [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 >>>>> int('- 345') >> -345 >> >> works, > > IMO, it oughtn't. Agreed it seems inconsistent with the integer literal syntax Python 2.5 Docs: 2.4.4 Integer and long integer literals Python 3.0 doesn't appear to spell out the literal syntax. It would be helpful if it did. Colin W. [snip] From bvidinli at gmail.com Thu Apr 24 04:36:52 2008 From: bvidinli at gmail.com (bvidinli) Date: Thu, 24 Apr 2008 11:36:52 +0300 Subject: [Python-Dev] annoying dictionary problem, non-existing keys In-Reply-To: References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> Message-ID: <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> I posted to so many lists because, this issue is related to all lists, this is an idea for python, this is related to development of python... why are you so much defensive ? i think ideas all important for development of python, software.... i am sory anyway.... hope will be helpful. 2008/4/24, Terry Reedy : > Python-dev is for discussion of development of future Python. Use > python-list / comp.lang.python / gmane.comp.python.general for usage > questions. > > > > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: http://mail.python.org/mailman/options/python-dev/bvidinli%40gmail.com > -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From bruno.42.desthuilliers at websiteburo.invalid Mon Apr 14 04:03:58 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Mon, 14 Apr 2008 10:03:58 +0200 Subject: Java or C++? In-Reply-To: References: Message-ID: <48030fd7$0$27271$426a74cc@news.free.fr> s0suk3 at gmail.com a ?crit : > Hello, I was hoping to get some opinions on a subject. I've been > programming Python for almost two years now. Recently I learned Perl, > but frankly I'm not very comfortable with it. Now I want to move on > two either Java or C++, but I'm not sure which. Which one do you think > is a softer transition for a Python programmer? Which one do you think > will educate me the best? if it's for educational purpose, then you have absolutely nothing to learn from Java. On the hi-level languages side, I'd rather recommend Haskell or OCaml (functional programming) and/or Erlang (concurrent programming). And if you want to go the 'close to the metal' way, then better to learn C. My 2 cents... From deets at nospam.web.de Wed Apr 9 08:33:48 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 09 Apr 2008 14:33:48 +0200 Subject: I am worried about Python 3 References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> Message-ID: <663re9F2i3ikcU1@mid.uni-berlin.de> jmDesktop wrote: > I am a new Python programmer. I have always desired to learn Python, > but have never had the opportunity. Recently this has changed, and I > have an opportunity to get away from the .NET framework. I found > Django (and other web frameworks) and began my quest to learn. I > started reading Dive Into Python and anything I could find and started > participating here in usenet. Then I had to read this: > > http://www.comp.leeds.ac.uk/nde/papers/teachpy3.html > > I think that every time I start a new technology (to me) it is about > to change. Yes, I know that is the nature of things, but I'm always > at the start of "something new." > > If I continue in Python 2.5.x, am I making a mistake? Is it really > that different? > > Here is an excerpt that is causing me concern: > > Two new versions of the language are currently in development: version > 2.6, which retains backwards compatibility with previous releases; and > version 3.0, which breaks backwards compatibility to the extent that > even that simplest of programs, the classic 'Hello, World', will no > longer work in its current form. > > It makes me feel like I am wasting my time and makes it difficult to > justify spending time on projects using 2.5.x and using it where I > work. The above statement is greatly exaggerated. Yes, print will become a function so print "hello world" won't work anymore. But most of python will stay the same, and you certainly don't waste time. Learning 2.x is perfectly sensible, as it is the stable version supported by e.g. providers and of course the community - and will be so for years to come. Diez From http Sat Apr 5 16:09:35 2008 From: http (Paul Rubin) Date: 05 Apr 2008 13:09:35 -0700 Subject: Tkinter, add pressed buttons onto string display string, how to? References: Message-ID: <7xr6dkrrls.fsf@ruckus.brouhaha.com> skanemupp at yahoo.se writes: > using tkinter and python i now have a small App (that will hopefully > soon be a fully functioning calculator) where u can push buttons and > the corresponding number or operator is shown. I wrote something like that a long time ago, one of my first python scripts. http://nightsong.com/phr/python/calc.py From gagsl-py2 at yahoo.com.ar Wed Apr 23 01:16:24 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 23 Apr 2008 02:16:24 -0300 Subject: IDLE gripe and question References: <95f218ba-4925-491a-bf9c-047ac201e0c7@2g2000hsn.googlegroups.com> Message-ID: En Wed, 23 Apr 2008 01:30:47 -0300, Mensanator escribi?: > On Apr 22, 7:42?pm, Dick Moores wrote: >> I have IDLE 1.2.1, on Win XP, Python 2.5.1. >> >> The first time I use File | Open to open a script, the Open dialogue >> box always opens at E:\Python25\Lib\idlelib. Most of the scripts I >> want to access are in E:\PythonWork. There doesn't seem to be a way >> to change the default folder to E:\PythonWork, but is there? > > First, find the shortcut that lauches IDLE. > > On my Vista system it's in > C:\Program Data\Microsoft\Windows\Start Menu\Programs\Python 2.5 > > XP will be different, I think there're start menu directories under > each user and a default one. That's the way to go. But note that you don't have to find where the shortcut lives: just navigate to the desired menu item in the Start menu, right-click on it and select Properties. -- Gabriel Genellina From yzghan at gmail.com Tue Apr 22 17:54:37 2008 From: yzghan at gmail.com (yzghan at gmail.com) Date: Tue, 22 Apr 2008 14:54:37 -0700 (PDT) Subject: python has memory leak? Message-ID: <1d48c77d-cc93-41ce-b644-1a8e52713e1d@b64g2000hsa.googlegroups.com> Hi all, I feel that my python script is leaking memory. And this is a test I have: log.write("[" + timestamp() + "] " + "test() ... memory usage: " + " ".join(repr(i/(1024*1024)) for i in getMemInfo()) + "\n") m = {} i = 1000*1000 while i > 0: i = i - 1 m.setdefault(i, []).append(i) log.write("[" + timestamp() + "] " + "test() ... memory usage: " + " ".join(repr(i/(1024*1024)) for i in getMemInfo()) + "\n") m = {} log.write("[" + timestamp() + "] " + "test() done. memory usage: " + " ".join(repr(i/(1024*1024)) for i in getMemInfo()) + "\n") >From which I got: [17:44:50] test() ... memory usage: 55L 55L [17:44:53] test() ... memory usage: 143L 143L [17:44:53] test() done. memory usage: 125L 143L In the above code getMemInfo is my func to return current and peak memory usage in bytes. Can some expert explain how python manages memory? The version of my python is: Python 2.4.4 Stackless 3.1b3 060516 (#71, Oct 31 2007, 14:22:28) [MSC v.1310 32 bit (Intel)] on win32 Many thanks, GH From fredrik at pythonware.com Sat Apr 5 07:29:27 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 13:29:27 +0200 Subject: In Tkinter - having an input and an entry In-Reply-To: References: Message-ID: markfernandes02 at googlemail.com wrote: > I can fetch records but cannot insert records. > > def Insert(self, *row): > global cursor, title, author, pubdate using globals to pass arguments to a function/method is usually not a good idea. any reason you cannot pass them in as arguments? > sqlInsert = "INSERT INTO Book_table" > sqlInsert = sqlInsert + "(Bookname, BookAutor, " > sqlInsert = sqlInsert + "Publicationdate) VALUES ('" > sqlInsert = sqlInsert + title + "', '" > sqlInsert = sqlInsert + author + "', " > sqlInsert = sqlInsert + pubdate + ") " > myconn = odbc.odbc('accessDatabase') if you're doing multiple insertions, it's usually better to connect once and reuse the connection object. > cursor = myconn.cursor() > cursor.execute(sqlInsert) > myconn.commit() > cursor.close() > myconn.close() > > The above code does not work. define "does not work". do you get a traceback, a database error, some other problem? can you perhaps post the traceback? > Also with Tkinter, i want to have user input records into the db, i > cannot get what the user inputs into the entry to become a string > variable. what did you try? you can get input data from the Entry widget in several ways, including calling the "get" method or using StringVar objects; see http://effbot.org/tkinterbook/entry.htm#patterns for some code snippets. From michele.simionato at gmail.com Wed Apr 30 23:50:43 2008 From: michele.simionato at gmail.com (Michele Simionato) Date: Wed, 30 Apr 2008 20:50:43 -0700 (PDT) Subject: ]ANN[ Vellum 0.16: Lots Of Documentation and Watching References: Message-ID: On Apr 29, 9:51 am, "Zed A. Shaw" wrote: > However, I'm curious to get other people's thoughts. For what concerns the license, I would say that GPL3 is fine: for a tool basically any kind of license is fine, since the tool is external to the code, so this is a minor point. I am curious about two other things, though, perhaps answered in the book but I had no time to read it all. First question: are you saying that vellum does NOT keep track of already built files and recompile everything each time, i.e. it is really in a different ballpark from make and similar build tools? Second question: what about docutils? A Pythonista would expect a documentation tool to use reST and I am sure plenty of us out there have articles/documents (even books) in reST and would be interested in building them. OTOH I would not be interested in learning yet another lightweight markup language or to go back to TeX. Is the Vellum book written in reST? Michele Simionato From wuwei23 at gmail.com Tue Apr 1 21:19:58 2008 From: wuwei23 at gmail.com (alex23) Date: Tue, 1 Apr 2008 18:19:58 -0700 (PDT) Subject: Python Audio PAN (left or right) and channels References: <881813a7-cbbb-48ab-9a4f-53da6fb0a69f@c26g2000prf.googlegroups.com> Message-ID: On Apr 2, 4:04 am, ilgufoeiltuc... at gmail.com wrote: > I need to play mp3 files on different channels and listen Channel 0 on > the left earphone and Channel 1 on the right... > How can I play mp3 files in different channel and pan the output? Hey Mark, Have you taken a look at GStreamer? What you're after could probably be done from a CLI using gstreamer, but it also has python bindings if you're wanting to integrate it with your own code. GStreamer: http://gstreamer.freedesktop.org/ Docs for python bindings: http://pygstdocs.berlios.de/ Hope this helps. - alex23 From steve at holdenweb.com Thu Apr 17 13:53:37 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 17 Apr 2008 13:53:37 -0400 Subject: Can't do a multiline assignment! In-Reply-To: <48077E83.5050404@islandtraining.com> References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <48077E83.5050404@islandtraining.com> Message-ID: Gary Herron wrote: > s0suk3 at gmail.com wrote: >> On Apr 17, 10:54 am, colas.fran... at gmail.com wrote: >> >>> On 17 avr, 17:40, s0s... at gmail.com wrote: >>> >>> Out of sheer curiosity, why do you need thirty (hand-specified and >>> dutifully commented) names to the same constant object if you know >>> there will always be only one object? >>> >> I'm building a web server. The many variables are names of header >> fields. One part of the code looks like this (or at least I'd like it >> to): >> >> class RequestHeadersManager: >> >> # General header fields >> Cache_Control = \ >> Connection = \ >> Date = \ >> Pragma = \ >> Trailer = \ >> Transfer_Encoding = \ >> Upgrade = \ >> Via = \ >> Warning = \ >> >> # Request header fields >> Accept = \ >> Accept_Charset = \ >> Accept_Encoding = \ >> Accept_Language = \ >> Authorization = \ >> ... >> > > But. *What's the point* of doing it this way. I see 14 variables > being assigned a value, but I don't see the value, they are getting. > Reading this bit if code provides no useful information unless I'm > willing to scan down the file until I find the end of this mess. And in > that scanning I have to make sure I don't miss the one single line that > does not end in a backslash. (Your ellipsis conveniently left out the > *one* important line needed to understand what this code is doing, but > even if you had included it, I'd have to scan *all* lines to understand > what a single value is being assigned. > > There is *no way* you can argue that code is clearer than this: > > # General header fields > Cache_Control = None > Connection = None > Date = None > Pragma = None > ... > Thank you, you saved me from making that point. It doesn't even seem like there's a need for each header to reference the same value (though in this case they will, precisely because there is only one None object). regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From george.sakkis at gmail.com Sat Apr 19 20:10:30 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Sat, 19 Apr 2008 17:10:30 -0700 (PDT) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> Message-ID: <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> On Apr 18, 9:36?pm, Ross Ridge wrote: > Ross Ridge said: > > > If you have Python 2.5, here's a faster version: > > > ? ?from struct import * > > ? ?unpack_i32be = Struct(">l").unpack > > > ? ?def from3Bytes_ross2(s): > > ? ? ? ?return unpack_i32be(s + "\0")[0] >> 8 > > Bob Greschke ? wrote: > > > That's not even intelligible. ?I wanna go back to COBOL. :) > > It's the same as the previous version except that it "precompiles" > the struct.unpack() format string. ?It works similar to the way Python > handles regular expressions. I didn't know about the Struct class; pretty neat. It's amazing that this version without Psyco is as fast Bob's version with Psyco! Adding Psyco to it though makes it *slower*, not faster. So here's how I'd write it (if I wanted or had to stay in pure Python): try: import psyco except ImportError: from struct import Struct unpack_i32be = Struct(">l").unpack def from3Bytes(s): return unpack_i32be(s + "\0")[0] >> 8 else: def from3Bytes(s): Value = (ord(s[0])<<16) + (ord(s[1])<<8) + ord(s[2]) if Value >= 0x800000: Value -= 0x1000000 return Value psyco.bind(from3Bytes) HTH, George From kyosohma at gmail.com Wed Apr 30 14:30:17 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 30 Apr 2008 11:30:17 -0700 (PDT) Subject: I messed up my wxPython install (Eclipse Configuration Issue) References: <18eb0a7c-96f4-41de-b44f-95fd8ba0223f@f63g2000hsf.googlegroups.com> <436f8226-64a5-440a-92f4-afd7dd348e1c@m73g2000hsh.googlegroups.com> <20525ad9-2679-4bc8-a117-66eca4a8dc13@r66g2000hsg.googlegroups.com> Message-ID: On Apr 30, 1:09 pm, blaine wrote: > On Apr 30, 1:14 pm, Mike Driscoll wrote: > > > blaine wrote: > > > The wxPython group is a bit stale compared to this group, so I'll give > > > it a shot :) > > > What does that mean? The wxPython group is almost always very quick to > > respond with relevant answers. > > > As to your question, I think Peter is correct. Your wx.py and wx.pyc > > files are masking the wx package. > > > Mike > > I didn't mean anything by it, I promise. This group is just amazing - > there are always very active topics and I get responses in no time. > The wxPython group I noticed only has had recent discussions a few > times in the past month, and their subscribers aren't as high as the > Python group. > That's weird...I subscribe to the wxPython group and I got 10 digests on the 28th. Typically they send out 2-5 digests per day. Where are you getting this information? This looks up-to-date: http://lists.wxwidgets.org/pipermail/wxpython-users/ > That worked. You guys are awesome, thank you! I can't believe I named > that test script wx.py - duh. Thank you for your help! > Blaine No problem. Glad it worked! That's always something to look for when you get that type of error, btw. Mike From rridge at caffeine.csclub.uwaterloo.ca Mon Apr 21 15:42:41 2008 From: rridge at caffeine.csclub.uwaterloo.ca (Ross Ridge) Date: Mon, 21 Apr 2008 15:42:41 -0400 Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: Carl Banks wrote: > If you don't like Python 3, DON'T USE IT. That's the plan. Paul McGuire wrote: >I've read this position a number of times in this and related threads, >and it overlooks one constituency of Python developers - those who >develop and support modules for use by other Python users. As the >supporter of pyparsing, I really can't just "not use" Py3 - ignoring >Py3 means shutting out/holding back those of my users who do want to >use it, and pretty much consigning my module to eventual dustbin >status. Eh. You can ingore it until your users start asking for it. >Ideally, I can implement some form of cross-compatible code >so that I need maintain only a single code base, and I have managed to >do so on a number of fronts (with the help of Robert A. Clark): >- add support for both __bool__ and __nonzero__ (__nonzero__ calls >__bool__, so that upgrading to Py3 actually saves a function call) Doing sometthing like the following would save the function call in both cases: class C(object): def __bool__(self): return False __nonzero__ = __bool__ >- convert isinstance(x,basestring) to isinstance(x,__BASESTRING__) and >dynamically set __BASESTRING__ to basestring or str >- similar treatment for sys.maxint/maxsize -> __MAX_INT__ I don't thiink using double underscores here is appropriate. It suggests it's part of the language. Since "basestring" is no longer part of the language, you could do: if "basestring" not in globals(): basestring = str >Overall, I think I'm getting off pretty easy, but then pyparsing is a >small module with very limited use of the standard lib. Has the standard library changed that much? I thought was it mainly the deletion of old seldom used modules that happens in new releases anyways. >[...] And as much as we all love Python-the-language, language features >alone do not help a language and its community of users to grow >and proliferate. I think most would agree that it is the cornucopia >of libraries that really make Python an environment for developing >production applications. Definately. Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] rridge at csclub.uwaterloo.ca -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // From sjmachin at lexicon.net Fri Apr 18 07:36:28 2008 From: sjmachin at lexicon.net (John Machin) Date: Fri, 18 Apr 2008 11:36:28 GMT Subject: Unicode chr(150) en dash In-Reply-To: <7dae96d4-48c4-46c9-9aa9-33a263b84ca4@26g2000hsk.googlegroups.com> References: <48063434$0$36327$742ec2ed@news.sonic.net> <7dae96d4-48c4-46c9-9aa9-33a263b84ca4@26g2000hsk.googlegroups.com> Message-ID: <480887b8@news.mel.dft.com.au> hdante wrote: > > The character code in question (which is present in the page), 150, > doesn't exist in ISO-8859-1. Are you sure? Consider (re-)reading all of the Wikipedia article. 150 aka \x96 doesn't exist in ISO 8859-1. ISO-8859-1 (two hyphens) is a superset of ISO 8859-1 (one hyphen) and adds the not-very-useful-AFAICT control codes \x80 to \x9F. > See > > http://en.wikipedia.org/wiki/ISO/IEC_8859-1 (the entry for 150 is > blank) You must have been looking at the table of the "lite" ISO 8859-1 (one hyphen). Reading further you will see \x96 described as SPA or "Start of Guarded Area". Then there is the ISO-8859-1 (two hyphens) table, including \x96. HTH, John From patrickkidd.lists at gmail.com Tue Apr 15 21:14:18 2008 From: patrickkidd.lists at gmail.com (Patrick Stinson) Date: Tue, 15 Apr 2008 19:14:18 -0600 Subject: import hooks Message-ID: <664bf2b80804151814g480eed02w739047f84d9deb6b@mail.gmail.com> What's the current way to install an import hook? I've got an embedded app that has a few scripts that I want to import each other, but that are not in sys.modules. I intentionally keep them out of sys.modules because their names will not be unique across the app. They will, however, be unique between scripts that I (do* want to see each other). Basically, I want to return a certain module from a name-based filter. I've already written a type in C with find_module and load_module, but it doesn't seem to work when I add the type to sys.path_hooks. I wrote a simple one that worked just fine from a pure script file run through python.exe. Thanks! -- Patrick Kidd Stinson http://www.patrickkidd.com/ http://pkaudio.sourceforge.net/ http://pksampler.sourceforge.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From torriem at gmail.com Sun Apr 20 18:51:53 2008 From: torriem at gmail.com (Michael Torrie) Date: Sun, 20 Apr 2008 16:51:53 -0600 Subject: close GUI and quit script? In-Reply-To: References: Message-ID: <480BC909.6020205@gmail.com> globalrev wrote: > how do i close a GUI and end the mainloop of the script? >From a GUI callback, instruct the main loop to quit. From juergen.perlinger at t-online.de Sun Apr 20 15:45:02 2008 From: juergen.perlinger at t-online.de (Juergen Perlinger) Date: Sun, 20 Apr 2008 21:45:02 +0200 Subject: socket.AF_INET References: Message-ID: Matt Herzog wrote: > Hi All. > > I'm trying to write a script that will send me an email message when my IP > address changes on a specific NIC. On Linux, the script works. On FreeBSD, > it fails with: > > [snip] > > def get_ip_address(ifname): > s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) > return socket.inet_ntoa(fcntl.ioctl( > s.fileno(), > 0x8915, # SIOCGIFADDR > struct.pack('256s', ifname[:15]) )[20:24]) > [OT: sorry Matt, hit email instead followup twice... stupid me] My bets are that the SIOCGIFADDR opcode has a different numerical value for BSD. Even if some names are portable, the numerical values aren't! I don't have BSD, but using find /usr/include -type f -name '*.h' | xargs grep SIOCGIFADDR /dev/null should give some hints... -- juergen 'pearly' perlinger "It's hard to make new errors!" From pavlovevidence at gmail.com Sat Apr 19 05:56:40 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Sat, 19 Apr 2008 02:56:40 -0700 (PDT) Subject: Python 2.5 adoption References: Message-ID: <4bfdf595-287f-4b66-b062-559d05eb2873@d1g2000hsg.googlegroups.com> On Apr 18, 2:08 pm, Joseph Turian wrote: > How widely adopted is python 2.5? > > We are doing some development, and have a choice to make: > a) Use all the 2.5 features we want. > b) Maintain backwards compatability with 2.4. > > So I guess the question is, does anyone have a sense of what percent > of python users don't have 2.5? One possible barometer for the situation is what's the oldest version of Python to have been supported in the most bug-fix releases? ...In which case you need to maintain backwards compatibility with 2.3. (I bring this up to illustrate that if there are people clamoring for a 2.3 updates, there are probably quite a few supporting 2.4 as well.) Carl Banks From s0suk3 at gmail.com Thu Apr 17 13:46:22 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 10:46:22 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <42402158-0b16-42e2-b7a0-9d9a15e8196d@24g2000hsh.googlegroups.com> Message-ID: <0f5c3363-7e23-4a19-b7f8-021f1d6e3f6c@t54g2000hsg.googlegroups.com> On Apr 17, 12:24 pm, Michael Torrie wrote: > s0s... at gmail.com wrote: > > > > There! That's the whole code. I guess the way you suggest is simpler > > and a bit more intuitive, but I was figuring that the way I suggested > > it is more stylish. > > Umm, doesn't defining all those members in the class lead to class > variables, not instance variables? I believe the recommended way of > making it clear what instance variables to expect is to initialize them > all in __init__. Currently in your implementation, each instance of > your class is going to share the same variables for all those fields you > defined, which probably isn't what you want. > > consider: > > class myclass(object): > classvar1=None > classvar2=None > > def __init__(self,test): > self.instancevar1=test > > >>> a=myclass(3) > >>> b=myclass(6) > >>> a.classvar1=9 > >>> a.classvar1 > 9 > >>> b.classvar1 > 9 > >>> a.instancevar1 > 3 > >>> b.instancevar1 > > 6 > > Also, your idea of checking the length of the headers to reduce the > number of string comparisons is a great case of premature optimization. > First it does not clarify the code, making it harder to follow. > Second, since web servers are I/O bound, it likely does nothing to > improve speed. > > So my recommendation is to use a bunch of self.HEADER_NAME=None > declarations in __init__(). This is the expected way of doing it and > all python programmers who are looking at your code will immediately > recognize that they are instance variables. You didn't really write that at the Python's interpreter, did you? It's wrong. The way that would really go at the interpreter is like this: >>> class myclass(object): ... classvar1=None ... classvar2=None ... def __init__(self,test): ... self.instancevar1=test ... >>> >>> a = myclass(3) >>> b = myclass(6) >>> >>> a.classvar1 = 9 >>> a.classvar1 9 >>> b.classvar1 >>> # Nothing was output in this line because b.classvar1 is still None ... >>> a.instancevar1 3 >>> b.instancevar1 6 classvar1 and classvar2 might be class variables, but in they don't work as they would in C++ or Java (like the ones you declare with the 'static' modified). From simon at brunningonline.net Tue Apr 8 06:36:09 2008 From: simon at brunningonline.net (Simon Brunning) Date: Tue, 8 Apr 2008 11:36:09 +0100 Subject: Looking for Conferences/Events on Django, Python, MySQL, etc in Europe 2008? In-Reply-To: <7fb0f408-1a2e-4ee1-a179-092f83eb1591@8g2000hsu.googlegroups.com> References: <7fb0f408-1a2e-4ee1-a179-092f83eb1591@8g2000hsu.googlegroups.com> Message-ID: <8c7f10c60804080336u1cb687d9occ950bf266688a68@mail.gmail.com> On Tue, Apr 8, 2008 at 10:10 AM, Simone Brunozzi wrote: > Greetings! > > I'm looking for conferences or events about Python, Django, Dabatases, > Mysql, > PHP, Ruby in Europe (or nearby locations like north africa and middle > east) in 2008. > Do you have any suggestions? PyCon UK 2008 - 12th to 14th September 2008 - . -- Cheers, Simon B. simon at brunningonline.net http://www.brunningonline.net/simon/blog/ From steve at holdenweb.com Thu Apr 24 23:54:42 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 23:54:42 -0400 Subject: Psyco alternative In-Reply-To: References: <8b7d9523-1d15-41e5-8b69-39f8250e6a6f@i76g2000hsf.googlegroups.com> Message-ID: sturlamolden wrote: > On Apr 25, 4:57 am, Steve Holden wrote: > >> I am simply pointing out that RPython is used for efficiency, not to do >> things that can't be done in standard Python. > > Yes. And if we only use a very small subset of Python, it would in > effect be a form of assembly code. Hence my comment about the Turing > complete subset. > Since you obviously insist on having the last word I promise not to reply to your next post. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From cyu021 at gmail.com Mon Apr 14 21:44:54 2008 From: cyu021 at gmail.com (James Yu) Date: Tue, 15 Apr 2008 09:44:54 +0800 Subject: click on hyper link and got 404 error Message-ID: <60bb95410804141844t229b7e87x7fb7831d3969eff6@mail.gmail.com> I am using "mod_python.publisher" to generate my web page that contains serveral links to local files. I also replace the path with my domain name like this: curDir = os.path.dirname(__file__) link = 'http://' + hostname + '/' + os.path.basename(curDir) + '/' files = os.listdir(curDir) for i in files: body = body + '
' + i + '' + '
' However, browser give me 404 error whenever I click on any of the links. Is there something wrong with how I build my file links ? Thanks, -- This is a UTF-8 formatted mail ----------------------------------------------- James C.-C.Yu -------------- next part -------------- An HTML attachment was scrubbed... URL: From castironpi at gmail.com Sun Apr 27 06:46:05 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sun, 27 Apr 2008 03:46:05 -0700 (PDT) Subject: problem with listdir References: Message-ID: <31152c20-31a8-4fbd-abdc-5d2b3ccbe048@r66g2000hsg.googlegroups.com> On Apr 27, 1:57?am, David wrote: > On Sat, Apr 26, 2008 at 7:56 PM, jimgardener wrote: > > > ?> * Run cmd.exe and see if you can run "dir f:\\code\\python\pgmgallery/*.*" > > > ?that causes a message 'Invalid switch - "*.*".' > > Probably because on the command-line, / means a command-line option. > Been a while since I used DOS. > > Try this instead: > > dir f:\code\python\pgmgallery\*.*" > > David. Try typing listdir( '.' ), which is Windows for 'the current path [being used]', at an interpreter. listdir does not accept wildcards, (surmisably since reg.exes are more powerful) and try ending with a slash. From skip at pobox.com Sun Apr 27 18:45:34 2008 From: skip at pobox.com (skip at pobox.com) Date: Sun, 27 Apr 2008 17:45:34 -0500 Subject: Looking for a change of pace? Message-ID: <18453.526.662526.696535@montanaro-dyndns-org.local> Have you been "Idol"ed and "Survivor"ed to death? Are you tired of Tiger winning just about every golf tournament he enters? Are you sick to deatch of the circus the Democratic primary race has become? Is it too early in the season to get excited about the prospect of a Red Line World Series between the Cubs and the White Sox? Well, here's something you can do that might be a nice change of pace: 1. Change directory to your Python sandbox or distribution. 2. At your Python prompt execute import random, os print random.choice(os.listdir("Doc/library")) 3. Check and clean up the displayed documentation. Submit a patch to bugs.python.org if necessary. 4. Be happy. Skip From Magnus.Moraberg at gmail.com Wed Apr 2 09:22:50 2008 From: Magnus.Moraberg at gmail.com (Magnus.Moraberg at gmail.com) Date: Wed, 2 Apr 2008 06:22:50 -0700 (PDT) Subject: Nested try...except References: <0a34849f-bcda-419b-a10f-772d76172d1f@b5g2000pri.googlegroups.com> Message-ID: <43d60d13-b420-414d-81c8-b8430af2aa5f@i36g2000prf.googlegroups.com> On 2 Apr, 15:15, Magnus.Morab... at gmail.com wrote: > On 2 Apr, 15:12, cokofree... at gmail.com wrote: > > > > > On Apr 2, 3:06 pm, Magnus.Morab... at gmail.com wrote: > > > > Hi, > > > > I found the following code on the net - > > > > http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/%3C20050924104732.5116.qm... at minotaur.apache.org%3E > > > > def count(self): > > > - db = sqlite.connect(self.filename, > > > isolation_level=ISOLATION_LEVEL) > > > - try: > > > - try: > > > - cur = db.cursor() > > > - cur.execute("select count(*) from sessions") > > > - return cur.fetchone()[0] > > > - finally: > > > - cur.close() > > > - finally: > > > - db.close() > > > > I don't understand though why the second try is not after the line cur > > > = db.cursor(). Can anyone explain for me why? > > > > /Barry. > > > Better question is why is there a try with no except... > > > Better yet, WHY is there two TRY statements when there could quite > > happily be only one... > > > Towards what you are asking, I GUESS...because the author hoped to > > handle the cases where cur failed to get assigned...but then > > his .close method of it would likely not work anyway...I mean...does > > this even work...YUCK > > I shouldn't have written "Nested try...except" as the title, instead I > mean "Nested try...finally". Sorry about that... > > Anyway, how would you do this? That is, use a finally to close the > network connection and the cursor? > > Thanks for your help, > > Barry Here's what I would do. Is it OK? def ExecuteWithNoFetching(self, queryString): sqlServerConnection = adodbapi.connect (";".join (connectors)) try: cursor = sqlServerConnection.cursor() try: cursor.execute(queryString) raise Exception("Exception") sqlServerConnection.commit() finally: cursor.close() finally: sqlServerConnection.close() From nicola.musatti at gmail.com Tue Apr 22 08:24:00 2008 From: nicola.musatti at gmail.com (Nicola Musatti) Date: Tue, 22 Apr 2008 05:24:00 -0700 (PDT) Subject: subprocess module is sorely deficient? References: Message-ID: <621dbfa0-8c3c-4ce4-80e7-cf0840c4b82f@p25g2000hsf.googlegroups.com> On Apr 22, 12:52 pm, Harishankar wrote: > Hi, > > Sorry to start off on a negative note in the list, but I feel that the Python > subprocess module is sorely deficient because it lacks a mechanism to: > > 1. Create non-blocking pipes which can be read in a separate thread (I am > currently writing a mencoder GUI in Tkinter and need a full fledged process > handler to control the command line and to display the progress in a > text-box) I suggest you check out this: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554 Cheers, Nicola Musatti From severian at severian.org Wed Apr 16 14:43:24 2008 From: severian at severian.org (Severian) Date: Wed, 16 Apr 2008 14:43:24 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: <6cadnYCFdNpR2ZvVnZ2dnUVZ_tPinZ2d@visi> References: <28d12cc8-5375-4e95-8e37-f872d238a1bd@b64g2000hsa.googlegroups.com> <6cadnYCFdNpR2ZvVnZ2dnUVZ_tPinZ2d@visi> Message-ID: <48064885$0$18426$39cecf19@news.twtelecom.net> Grant Edwards wrote: > On 2008-04-16, Mensanator wrote: >> On Apr 16, 9:19 am, Grant Edwards wrote: >>> This morning almost half of c.l.p was spam. In order to try >>> to not tar both the benign google group users and the >>> malignant ones with the same brush, I've been trying to kill >>> usenet spam with subject patterns. But that's not a battle >>> you can win, so I broke down and joined all the other people >>> that just killfile everything posted via google.groups. >> Not very bright, eh? >> >>> AFAICT, if you're a google groups user your posts are not being >>> seen by many/most experienced (read "non-google-group") users. >>> This is mainly the fault of google who has refused to do >>> anything to stem the flood of span that's being sent via Google >>> Groups. >> Duh. > > My. That was certainly a well-reasoned and well-written > response. Well, it did come from an AOL user posting from Google groups . From castironpi at gmail.com Sat Apr 26 19:05:07 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sat, 26 Apr 2008 16:05:07 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> Message-ID: <5b326b53-22fc-43f3-8423-bfc49d05ccc3@j22g2000hsf.googlegroups.com> On Apr 26, 5:03?pm, John Henry wrote: > On Apr 26, 8:46 am, a... at pythoncraft.com (Aahz) wrote: > > > > > > > In article <9028496e-30de-4853-8f57-b55d14e52... at h1g2000prh.googlegroups.com>, > > John Henry ? wrote: > > > >But then I looked closer. ?It turns out the XML file created by > > >QxTransformer is *very* similar in structure when compared to the > > >resource files used inPythonCard. ?Since there are no GUI builders > > >for QxTransformer, and I can't affort to buy the one for Qooxdoo > > >(Java! ?Yuk!), I decided to roll up my sleeves, took thePythoncard's > > >Layout Manager and modified it and created my own "Poor Man's Qooxdoo > > >GUI Layout Designer". > > > Cute! ?When you have working code, please do upload to PyPI. > > -- > > Aahz (a... at pythoncraft.com) ? ? ? ? ? <*> ? ? ? ?http://www.pythoncraft.com/ > > > Why is this newsgroup different from all other newsgroups? > > So far, I have the following widgets working: > > window, button, checkbox, static text, static box, list, combobox, > spinner, radio button group > > Shouldn't be long before the following works: > > static line, image, image button, choice.- Hide quoted text - > > - Show quoted text - Should static text GUI class support the operations of a string? From john106henry at hotmail.com Sun Apr 27 16:55:55 2008 From: john106henry at hotmail.com (John Henry) Date: Sun, 27 Apr 2008 13:55:55 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <1d8af3e3-c287-4d5b-a481-ca8c650f732f@s33g2000pri.googlegroups.com> <472056db-8812-42b2-a4fe-3a2accd7571b@8g2000hse.googlegroups.com> Message-ID: <18305718-c56c-49ef-92d6-83aa93a923d2@w5g2000prd.googlegroups.com> On Apr 27, 11:36 am, Ron Stephens wrote: > John, > > This is very interesting! Please do make this available. I love > PythonCard, but I am doing mainly web programming these days. > > I will mention this on my next podcast. Can you do a slider? > > Ron Stephens > Python411www.awaretek.com/python/index.html Not sure if Qooxdoo supports slider yet. I have to ask. From sturlamolden at yahoo.no Sat Apr 19 15:34:22 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sat, 19 Apr 2008 12:34:22 -0700 (PDT) Subject: why function got dictionary References: <48075950.7050000@gmail.com> Message-ID: On Apr 19, 8:33 pm, "bruno.desthuilli... at gmail.com" wrote: > barfoo = foobar > foobar = lambda x : x > > And boom. That's why I used the qualifier 'roughly equivalent' and not simply 'equivalent'. From fennelllindy8241 at gmail.com Mon Apr 28 03:14:11 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:14:11 -0700 (PDT) Subject: morrowind no cd crack Message-ID: morrowind no cd crack http://crack.cracksofts.com From gabriel.rossetti at mydeskfriend.com Tue Apr 8 03:05:27 2008 From: gabriel.rossetti at mydeskfriend.com (Gabriel Rossetti) Date: Tue, 08 Apr 2008 09:05:27 +0200 Subject: Destructor? Message-ID: <47FB1937.5050008@mydeskfriend.com> Hello everyone, we are writing an application that needs some cleanup to be done if the application is quit, normally (normal termination) or by a signal like SIGINT or SIGTERM. I know that the __del__ method exists, but unless I'm mistaken there is no guarantee as of when it will be called, and some objects may have already been released (at lease I've had trouble in the past accessing certain objects from inside __del__, probably since the parent class's __del__ has to be called first, then it's objects are already released by the time I need to do something with them). Another method would be to implement something using the signal module and have a callback that does all the cleanup when the app. is quit/terminated/interrupted and have all the child classes override that with their cleanup code. What is the community's point of view on the subject? Thanks, Gabriel From brian.e.munroe at gmail.com Wed Apr 2 12:03:52 2008 From: brian.e.munroe at gmail.com (Brian Munroe) Date: Wed, 2 Apr 2008 09:03:52 -0700 (PDT) Subject: class / module introspection? Message-ID: I'm struggling with an architectural problem and could use some advice. I'm writing an application that will gather statuses from disparate systems. Because new systems show up all the time, I'm trying to design a plugin architecture that will allow people to contribute new backends by just dropping a package/module into a specific directory. The object methods in these backends will conform to a documented API that the main application will call. Currently I have something that looks like this: src/ backends/ system1/ __init__.py system2/ __init__.py ... Then from my application (main.py) I can simply call: from backends import system1 be1 = system1.Backend() be1.getStatus() This would work great if I knew about system1 and system2 ahead of time, but that isn't the case. Having to rewrite main.py every time a new backend module comes along is obviously a stupid idea too. I've been thinking I need some kind of introspection, but I've been reading about it and a whole mess of design pattern stuff, so my head is swimming and I am totally unsure of what the best approach is. My guess is that I need to load all the backends at runtime - then introspect the loaded classes? Any suggestions would be greatly appreciated. From benash at gmail.com Sat Apr 26 17:26:04 2008 From: benash at gmail.com (Benjamin) Date: Sat, 26 Apr 2008 14:26:04 -0700 (PDT) Subject: Parsing HTML? References: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> <47F9B92C.1030802@behnel.de> Message-ID: <76811693-7617-4952-88d3-d1368c4500c5@1g2000prg.googlegroups.com> On Apr 6, 11:03?pm, Stefan Behnel wrote: > Benjamin wrote: > > I'm trying to parse an HTML file. ?I want to retrieve all of the text > > inside a certain tag that I find with XPath. ?The DOM seems to make > > this available with the innerHTML element, but I haven't found a way > > to do it in Python. > > ? ? import lxml.html as h > ? ? tree = h.parse("somefile.html") > ? ? text = tree.xpath("string( some/element[@condition] )") > > http://codespeak.net/lxml > > Stefan I actually had trouble getting this to work. I guess only new version of lxml have the html module, and I couldn't get it installed. lxml does look pretty cool, though. From http Wed Apr 2 16:23:00 2008 From: http (Paul Rubin) Date: 02 Apr 2008 13:23:00 -0700 Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> <7xwsngyu05.fsf@ruckus.brouhaha.com> Message-ID: <7x8wzw80rf.fsf@ruckus.brouhaha.com> "bruno.desthuilliers at gmail.com" writes: > Fine. But totally irrelevant here - this is comp.lang.python, not > comp.lang.c, and we *do not* (I repeat : we *do not*) face the same > safety and security problems as those existing in C. We have it better than they do in some ways. In some other ways, we have it worse. From bwljgbwn at gmail.com Tue Apr 22 05:55:35 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:55:35 -0700 (PDT) Subject: adobe cs2 crack Message-ID: adobe cs2 crack http://cracks.12w.net F R E E C R A C K S From primoz.skale.lists at gmail.com Thu Apr 3 04:00:19 2008 From: primoz.skale.lists at gmail.com (Primoz Skale) Date: Thu, 3 Apr 2008 10:00:19 +0200 Subject: function call - default value & collecting arguments References: <_LQIj.9776$HS3.482805@news.siol.net> <7e50544d-6daf-48c2-bb82-be06d3590450@8g2000hsu.googlegroups.com> Message-ID: wrote in message news:a3105c47-c016-49b0-8b19-841c26414b43 at s19g2000prg.googlegroups.com... > On 2 avr, 22:32, "Primoz Skale" wrote: >> >> I also understand (fairly) how to collect arguments. For example, >> >> let's >> >> define another function: >> >> >> def f(*a): >> >> print a >> >> > This means that f takes any number of optional positional arguments. >> > If nothing is passed, within f, 'a' will be an empty tuple. Note that >> > this is *not* the usual way to define a function taking multiple >> > (mandatory) arguments. >> >> M. Lutz in "Learning Python" had defined it this way. What is the *usual* >> way in this case? > > You mean : "what's the usual way to define a function taking multiple > *mandatory* arguments" ? I'd think it's explained in your book ??? > > def f(a, b, c): > print a, b, c > > But this is such a cs101 point that we're surely misunderstanding each > other here. > Yes, this was misunderstanding. I thought you meant defining with the *a, and not with a,b,c, etc....Thanks anyway :) >> >> > or (slightly more involved, and certainly overkill): >> >> > def with_default_args(default): >> > def decorator(func): >> > def wrapper(*args): >> > if not args: >> > args = default >> > return func(*args) >> > return wrapper >> > return decorator >> >> > @with_default_args((0,)) >> > def f(*a): >> > print a[0] >> >> Now, this is interesting. Thanks! :) > > Dont take this as a "recommanded" solution to your problem - it was > (mostly) to be exhaustive (and a bit on the "showing off" side too to > be honest). > No of course not - but it is interesting... P. From bbxx789_05ss at yahoo.com Sat Apr 5 05:16:07 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sat, 5 Apr 2008 02:16:07 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <7113d012-01bb-4426-bb40-9e2811cdb102@x41g2000hsb.googlegroups.com> <3cf4bbc8-b828-45c5-b9a8-766ce600af43@y21g2000hsf.googlegroups.com> Message-ID: skanem... at yahoo.se wrote: > > one thing i dont rally get, i ahve to add my_button.bind() somewhere? > i changed the stuff u said though and i get this error(the program > executes though and i can press the buttons): > > Exception in Tkinter callback > Traceback (most recent call last): > File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ > return self.func(*args) > TypeError: Display() takes exactly 2 arguments (1 given) > > > current version: > #! /usr/bin/env python > from Tkinter import * > import tkMessageBox > > class GUIFramework(Frame): > """This is the GUI""" > > def __init__(self,master=None): > """Initialize yourself""" > > """Initialise the base class""" > Frame.__init__(self,master) > > """Set the Window Title""" > self.master.title("Calculator") > > """Display the main window" > with a little bit of padding""" > self.grid(padx=10,pady=10) > self.CreateWidgets() > > def CreateWidgets(self): > > enText = Entry(self) > enText.grid(row=0, column=0, columnspan=8, padx=5, pady=5) > > enText = Entry(self) > enText.grid(row=1, column=0, columnspan=8, padx=5, pady=5) > > btnDisplay = Button(self, text="1", command=self.Display) > btnDisplay.grid(row=3, column=0, padx=5, pady=5) You still have this in your code: btnDisplay = Button(self, text="1", command=self.Display) I suggest you reread my earlier post again. Or, follow the advice given by Marc 'BlackJack' Rintsch (preferable). But whatever you do, don't use both command and bind(). From grante at visi.com Fri Apr 11 18:05:50 2008 From: grante at visi.com (Grant Edwards) Date: Fri, 11 Apr 2008 17:05:50 -0500 Subject: Question on threads References: <47FFBC05.50309@holdenweb.com> Message-ID: On 2008-04-11, Steve Holden wrote: > Yes - you are calling it before you have started ALL your > threads, thereby making hte main thread wait for the end of > thread 1 before starting the next. An impressive demonstration > of thread synchronization, Well, that's one way to get rid of the need for the GIL... -- Grant Edwards grante Yow! Where's th' DAFFY at DUCK EXHIBIT?? visi.com From mail at timgolden.me.uk Thu Apr 24 04:49:56 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 24 Apr 2008 09:49:56 +0100 Subject: python-ldap - Operations Error In-Reply-To: References: <8b35f293-fc64-4d21-a621-124c8eafde59@c65g2000hsa.googlegroups.com> Message-ID: <481049B4.5030708@timgolden.me.uk> Michael Str?der wrote: > Jason Scheirer wrote: >> On Apr 23, 5:16 pm, theivi... at gmail.com wrote: >>> Hello all, I am trying to integrate TurboGears with our Active >>> Directory here at the office. TurboGears aside, i cannot get this to >>> work. >> >> Seems more promising: >> http://tgolden.sc.sabren.com/python/active_directory.html > > This is based on ADSI? > Then the caveat is that it only runs on Windows. Yes, it's Windows-only. (I've no idea if it would run under something like WINE). TJG From gagsl-py2 at yahoo.com.ar Thu Apr 10 04:31:27 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 05:31:27 -0300 Subject: email header decoding fails References: Message-ID: En Wed, 09 Apr 2008 23:12:00 -0300, ZeeGeek escribi?: > It seems that the decode_header function in email.Header fails when > the string is in the following form, > > '=?gb2312?Q?=D0=C7=C8=FC?=(revised)' > > That's when a non-encoded string follows the encoded string without > any whitespace. In this case, decode_header function treats the whole > string as non-encoded. Is there a work around for this problem? That header does not comply with RFC2047 (MIME Part Three: Message Header Extensions for Non-ASCII Text) Section 5 (1) An 'encoded-word' may replace a 'text' token (as defined by RFC 822) in any Subject or Comments header field, any extension message header field, or any MIME body part field for which the field body is defined as '*text'. [...] Ordinary ASCII text and 'encoded-word's may appear together in the same header field. However, an 'encoded-word' that appears in a header field defined as '*text' MUST be separated from any adjacent 'encoded-word' or 'text' by 'linear-white-space'. Section 5 (3) As a replacement for a 'word' entity within a 'phrase', for example, one that precedes an address in a From, To, or Cc header. [...] An 'encoded-word' that appears within a 'phrase' MUST be separated from any adjacent 'word', 'text' or 'special' by 'linear-white-space'. -- Gabriel Genellina From karthikk at adventnet.com Wed Apr 9 04:17:49 2008 From: karthikk at adventnet.com (Karthik) Date: Wed, 09 Apr 2008 13:47:49 +0530 Subject: Setting default version among multiple python installations In-Reply-To: References: <47FB3F86.5040702@adventnet.com> <47FC57F8.40106@adventnet.com> Message-ID: <47FC7BAD.7060901@adventnet.com> Gabriel Genellina wrote: > En Wed, 09 Apr 2008 02:45:28 -0300, Karthik > escribi?: > > >> if i type python2.5 i am able to use the latest python, but if i simply >> type python it taken me to the older version. (it is a minor annoyance, >> but I want to know how to fix it) >> > > From the README file: > > There's an executable /usr/bin/python which is Python > 1.5.2 on most older Red Hat installations; several key Red Hat > tools > require this version. Python 2.1.x may be installed as > /usr/bin/python2. The Makefile installs Python as > /usr/local/bin/python, which may or may not take precedence > over /usr/bin/python, depending on how you have set up $PATH. > > yes, that seems to be the case. i changed the order of entries in $PATH, and now things are working now. thanks for your help. (Lesson learnt: if it says README, better read it completely, dont stop at "Congratulations on getting this far. :-)" ) -Karthik -------------- next part -------------- An HTML attachment was scrubbed... URL: From bronger at physik.rwth-aachen.de Tue Apr 29 17:57:18 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Tue, 29 Apr 2008 23:57:18 +0200 Subject: Simple unicode-safe version of str(exception)? References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> <48179831.7030308@v.loewis.de> Message-ID: <87iqy0miip.fsf@physik.rwth-aachen.de> Hall?chen! Martin v. L?wis writes: >> Should I report this as a bug? I suspect it's a misfeature. > > Please no. There isn't much that can be done about it, IMO. One could give Exception a __unicode__ method. On the other hand, this kind of conversion of an exception to something printable is a quite ugly kludge anyway in my opinion, so it needn't special support. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From mensanator at aol.com Wed Apr 16 13:48:23 2008 From: mensanator at aol.com (Mensanator) Date: Wed, 16 Apr 2008 10:48:23 -0700 (PDT) Subject: Finally had to plonk google gorups. References: Message-ID: <28d12cc8-5375-4e95-8e37-f872d238a1bd@b64g2000hsa.googlegroups.com> On Apr 16, 9:19?am, Grant Edwards wrote: > This morning almost half of c.l.p was spam. ?In order to try to > not tar both the benign google group users and the malignant > ones with the same brush, I've been trying to kill usenet spam > with subject patterns. ?But that's not a battle you can win, so > I broke down and joined all the other people that just killfile > everything posted via google.groups. Not very bright, eh? > > AFAICT, if you're a google groups user your posts are not being > seen by many/most experienced (read "non-google-group") users. > This is mainly the fault of google who has refused to do > anything to stem the flood of span that's being sent via Google > Groups. Duh. > > -- > Grant Edwards ? ? ? ? ? ? ? ? ? grante ? ? ? ? ? ? Yow! I would like to > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at ? ? ? ? ? ? ? urinate in an OVULAR, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?visi.com ? ? ? ? ? ?porcelain pool -- From danb_83 at yahoo.com Thu Apr 24 01:08:49 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Wed, 23 Apr 2008 22:08:49 -0700 (PDT) Subject: Curious relation References: <613aa1f7-3943-4458-ba7e-4cb29c562988@y21g2000hsf.googlegroups.com> Message-ID: On Apr 23, 11:51 pm, Greg J wrote: > I was reading the programming Reddit tonight and came across this > (http://reddit.com/info/6gwk1/comments/): > > >>> ([1]>2)==True > True > >>> [1]>(2==True) > True > >>> [1]>2==True > > False > > Odd, no? > > So, can anyone here shed light on this one? A long time ago, it wasn't possible for comparison operators to raise exceptions, so it was arbitrarily decided that numbers are less than strings. Thus, [1]>2 and [1]>False. This explains your first two examples. For the third, remember that the comparison operators are chained, so a>b==c means (a>b) and (b==c). Since 2==True is false, so is the entire expression. In Python 3.0, all three of these expressions will raise a TypeError. From http Wed Apr 2 14:46:50 2008 From: http (Paul Rubin) Date: 02 Apr 2008 11:46:50 -0700 Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> Message-ID: <7xwsngyu05.fsf@ruckus.brouhaha.com> "bruno.desthuilliers at gmail.com" writes: > Here the problem is more philosophical than anything else. Python's > philosophy is that most programmers are responsible and normally > intelligent, so treating them all like retarted dummies because > someone might one day do something stupid is just wasting everyone's > time. This is also why there's no language-enforced access > restriction, only a simple stupid convention to denote implementation > stuff from API. The fact is that it JustWork. Additional Principles for C1X (new) ... 12. Trust the programmer, as a goal, is outdated in respect to the security and safety programming communities. While it should not be totally disregarded as a facet of the spirit of C, the C1X version of the C Standard should take into account that programmers need the ability to check their work. C - The C1X Charter Document: WG14 N1250, p. 3 http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1250.pdf From __peter__ at web.de Mon Apr 21 17:01:14 2008 From: __peter__ at web.de (Peter Otten) Date: Mon, 21 Apr 2008 23:01:14 +0200 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> Message-ID: Ivan Illarionov wrote: > And even faster: > a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, > len(s), 3)))) > if sys.byteorder == 'little': > a.byteswap() > > I think it's a fastest possible implementation in pure python Clever, but note that it doesn't work correctly for negative numbers. For those you'd have to prepend "\xff" instead of "\0". Peter From paul at boddie.org.uk Thu Apr 17 06:42:23 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Thu, 17 Apr 2008 03:42:23 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: <8ff14bb5-7919-47e8-b64a-9512e0d1b412@l64g2000hse.googlegroups.com> On 16 Apr, 15:16, Marco Mariani wrote: > > Do you mean Ruby's track in providing backward compatibility is better > than Python's? > > Googling for that a bit, I would reckon otherwise. So would I, but then it isn't the Ruby developers that are *promising* to break backward compatibility *and* claiming that it's a good thing. This means that those wanting to sell Ruby as a solution can play the political game and claim a better roadmap even if they end up causing more disruption than Python 3.x does: it's like electioneering on a platform of "no new taxes" and then breaking that promise after gaining power. I find myself agreeing strongly with Aaron about this. Lots of things were considered "wrong" with Python over the years, but I'm unconvinced about the remedy: http://wiki.python.org/moin/PythonWarts There seems to be a lot of "out with the old" in the Free Software world of late. Another example: KDE 3.x eventually finds itself in products with widespread distribution; the developers bring out a less capable version (but with more "bling") that everyone is now supposedly working on instead; momentum is lost. Paul From gherzig at fmed.uba.ar Fri Apr 4 10:42:16 2008 From: gherzig at fmed.uba.ar (Gerardo Herzig) Date: Fri, 04 Apr 2008 11:42:16 -0300 Subject: collecting results in threading app Message-ID: <47F63E48.80002@fmed.uba.ar> Hi all. Newbee at threads over here. Im missing some point here, but cant figure out which one. This little peace of code executes a 'select count(*)' over every table in a database, one thread per table: class TableCounter(threading.Thread): def __init__(self, conn, table): self.connection = connection.Connection(host=conn.host, port=conn.port, user=conn.user, password='', base=conn.base) threading.Thread.__init__(self) self.table = table def run(self): result = self.connection.doQuery("select count(*) from %s" % self.table, [])[0][0] print result return result class DataChecker(metadata.Database): def countAll(self): for table in self.tables: t = TableCounter(self.connection, table.name) t.start() return It works fine, in the sense that every run() method prints the correct value. But...I would like to store the result of t.start() in, say, a list. The thing is, t.start() returns None, so...what im i missing here? Its the desing wrong? thanks! Gerardo From gnewsg at gmail.com Fri Apr 4 07:26:47 2008 From: gnewsg at gmail.com (Giampaolo Rodola') Date: Fri, 4 Apr 2008 04:26:47 -0700 (PDT) Subject: RELEASED Python 2.6a2 and 3.0a4 References: Message-ID: On 4 Apr, 03:47, Barry Warsaw wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On behalf of the Python development team and the Python community, I'm ? > happy to announce the second alpha release of Python 2.6, and the ? > fourth alpha release of Python 3.0. > > Please note that these are alpha releases, and as such are not ? > suitable for production environments. ?We continue to strive for a ? > high degree of quality, but there are still some known problems and ? > the feature sets have not been finalized. ?These alphas are being ? > released to solicit feedback and hopefully discover bugs, as well as ? > allowing you to determine how changes in 2.6 and 3.0 might impact ? > you. ?If you find things broken or incorrect, please submit a bug ? > report at > > ? ?http://bugs.python.org > > For more information and downloadable distributions, see the Python ? > 2.6 web > site: > > ? ?http://www.python.org/download/releases/2.6/ > > and the Python 3.0 web site: > > ? ?http://www.python.org/download/releases/3.0/ > > We are planning one more alpha release of each version, followed by ? > two beta releases, with the final releases planned for August 2008. ? > See PEP 361 for release details: > > ? ? ?http://www.python.org/dev/peps/pep-0361/ > > Enjoy, > - -Barry > > Barry Warsaw > ba... at python.org > Python 2.6/3.0 Release Manager > (on behalf of the entire python-dev team) > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.8 (Darwin) > > iQCVAwUBR/WImHEjvBPtnXfVAQJmoQP+MzqNDI+Xt8zua/FE7Ca4TVXoIIy2uoOm > I1i3+vmevZ9vtAb9hcGwfEgPY4LSwb9Js4KnJJWMPaMuFJK4NgGoiMdj+t42zDbQ > bEzfBUOCoVkejLRxIQnWeJf1Hu8JocYyCHIRffv57/QdKpHuiSs8aE8GIT3STo3o > I88H5NY1GgI= > =WT2z > -----END PGP SIGNATURE----- The Windows x86 MSI installer is missing for both 2.6 and 3.0. --- Giampaolo http://code.google.com/p/pyftpdlib From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 23 08:45:45 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 23 Apr 2008 14:45:45 +0200 Subject: help needed with classes/inheritance In-Reply-To: <480f13e8$0$15157$607ed4bc@cv.net> References: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> <480f13e8$0$15157$607ed4bc@cv.net> Message-ID: <480f2f6c$0$2660$426a74cc@news.free.fr> Andrew Lee a ?crit : (snip) > as a rule of thumb .. if you are using "isinstance" in a class to > determine what class a parameter is ... you have broken the OO contract. Nope. > Remember, every class ought to have a well defined internal state and a > well defined interface to its state. I don't see how the part about the internal state relates to the problem here. > If I write -- > > class foo (object): > def __init__ : > pass > > def some_func (self, val) : > if isinstance (val, "bar") : > .... > > Then I am either doing something very wrong If you do so in a desperate attempt to emulate static typing in Python, then yes, you're doing something very wrong. Else: > or very clever Not necessarily. Given Python's dynamic typing, there's no builtin OneObviousWay(tm) way to dispatch on different functions based on argument's type - something often done in statically typed OOPLs using method overridding (ie: different methods with same name but different signatures). Doing a manual dispatch based on argument's type, while not good OO style, is sometimes the simplest working solution, and a good enough one for the problem at hand. Having different methods for different arg types has the drawback that you don't have one single generic function/method that you can use as a callback. Having a real multidispatch (or rule-based dispatch etc) system either builtin or in the stdlib would indeed be much cleaner. Until then, there are a couple third-part packages solving this problem, but it can be overkill for simple problems (and add unneeded/unwanted dependencies). my 2 cents. From medin0065 at gmail.com Sun Apr 20 10:49:33 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:49:33 -0700 (PDT) Subject: anachronox patch Message-ID: <9a6617e9-4fd7-44c0-8611-e99bf6a593d8@w1g2000prd.googlegroups.com> anachronox patch http://cracks.00bp.com F R E E C R A C K S From c.boulanger at qxtransformer.org Tue Apr 29 04:57:05 2008 From: c.boulanger at qxtransformer.org (Panyasan) Date: Tue, 29 Apr 2008 01:57:05 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <473deef3-9acb-45dd-a7ca-47b0081bd28c@i36g2000prf.googlegroups.com> <3f7bb91e-335e-46bd-88ca-f15b26c35132@k1g2000prb.googlegroups.com> Message-ID: Hi, I am one of the two developers working on the xml-to-javascript converter (qxtransformer) John has mentioned and we are thrilled that our project has found a use in the PythonCard community. However, we have a problem getting PythonCard to work on our Macs (Mac OS 10.5 Leopard). We should probably be asking this on the PythonCard help list, but since the list seems to be somewhat deserted (very few posts) and John is active here and people seem to be using PythonCard, maybe someone has an idea. It might be very simple and stupid - I have never worked with python before. I am using - PythonCard 0.8.2 release on Leopard, which is copied by setup.py to / Library/Python/2.5/site-packages - John's layoutEditor package, (http://qxtransformer.googlegroups.com/ web/layoutEditor.zip) PythonCard email list says that Leopard and PythonCard 0.8.2 seem to like each other generally: http://sourceforge.net/mailarchive/forum.php?thread_name=EE5213D5-A005-4ED0-9512-111B6D4F06A7%40bu.edu&forum_name=pythoncard-users and I can get the examples working. However, when I start John's modified layoutEditor.py, I get an empty window and the following error is thrown: no resource file for /Users/bibliograph/Programme/PythonCard/tools/ layoutEditor/multipropertyEditor Traceback (most recent call last): File "/BinaryCache/wxWidgets/wxWidgets-11~57/Root/System/Library/ Frameworks/Python.framework/Versions/2.5/Extras/lib/python/wx-2.8-mac- unicode/wx/_core.py", line 14095, in File "/Library/Python/2.5/site-packages/PythonCard/tools/ layoutEditor/layoutEditor.py", line 153, in on_initialize self.propertyEditorWindow = model.childWindow(self, PropertyEditor) File "/Library/Python/2.5/site-packages/PythonCard/model.py", line 213, in childWindow rsrc = resource.ResourceFile(filename).getResource() File "/Library/Python/2.5/site-packages/PythonCard/resource.py", line 45, in __init__ self.dictionary = util.readAndEvalFile(rsrcFileName) File "/Library/Python/2.5/site-packages/PythonCard/util.py", line 39, in readAndEvalFile f = open(filename) TypeError: coercing to Unicode: need string or buffer, NoneType found there is a file PythonCard/tools/layoutEditor/modules/ multipropertyEditor.rsrc.py When I resize the window, I get the following errors Tue Apr 29 10:48:08 noname Python[40440] : CGContextConcatCTM: invalid context Tue Apr 29 10:48:08 noname Python[40440] : CGContextSaveGState: invalid context Tue Apr 29 10:48:08 noname Python[40440] : doClip: invalid context Tue Apr 29 10:48:08 noname Python[40440] : CGContextSaveGState: invalid context Tue Apr 29 10:48:08 noname Python[40440] : CGContextSetBlendMode: invalid context Tue Apr 29 10:48:08 noname Python[40440] : CGContextSetShouldAntialias: invalid context Traceback (most recent call last): File "/Library/Python/2.5/site-packages/PythonCard/model.py", line 884, in _dispatch handler(background, aWxEvent) File "/Library/Python/2.5/site-packages/PythonCard/tools/ layoutEditor/layoutEditor.py", line 560, in on_size self.createDC() File "/Library/Python/2.5/site-packages/PythonCard/tools/ layoutEditor/layoutEditor.py", line 556, in createDC dc.SetLogicalFunction(wx.INVERT) File "/BinaryCache/wxWidgets/wxWidgets-11~57/Root/System/Library/ Frameworks/Python.framework/Versions/2.5/Extras/lib/python/wx-2.8-mac- unicode/wx/_gdi.py", line 4079, in SetLogicalFunction wx._core.PyAssertionError: C++ assertion "status == noErr" failed at ../src/mac/carbon/graphics.cpp(1324) in EnsureIsValid(): Cannot nest wxDCs on the same window Thanks for any pointers, Christian From john106henry at hotmail.com Thu Apr 10 15:19:30 2008 From: john106henry at hotmail.com (John Henry) Date: Thu, 10 Apr 2008 12:19:30 -0700 (PDT) Subject: How is GUI programming in Python? References: Message-ID: <2345bb35-50c0-4c2f-8ea0-7498fe6f89b4@p39g2000prm.googlegroups.com> On Apr 9, 6:54 pm, Chris Stewart wrote: > I've always had an interest in Python and would like to dabble in it > further. I've worked on a few very small command line programs but > nothing of any complexity. I'd like to build a really simple GUI app > that will work across Mac, Windows, and Linux. How painful is that > going to be? I used to be really familiar with Java Swing a few years > ago. I imagine it will be similar. > > Next, what would you say is the best framework I should look into? > I'm curious to hear opinions on that. > > Chris Stewart > cstewart... at gmail.com If you are looking for something "really simple", my vote still goes to PythonCard. It has been around a looooooooooong time, very mature, stable, and comes with sufficient widgets to get most daily job done. True, it hasn't been updated to include some of the newer widgets but there are plenty in the package already. The danger is that once you get hooked in using Pythoncard, it's hard to leave because everything else looks soooooooo "non really simple". I've looked at every other Python GUI package. In my humble opinion, none came close to being "really simple" than Pythoncard. It's too bad the more capable people in the Python community doesn't pick up the ball and continue to run with it. For me, I am now migrating away from doing desktop GUI apps into browse based applications with a Python backend, and qooxdoo frontend. So, for me, Pythoncard will be my last desktop GUI tool package. From skanemupp at yahoo.se Sun Apr 13 05:17:53 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 13 Apr 2008 02:17:53 -0700 (PDT) Subject: latest command from toplevel? Message-ID: windows vista and python 2.5, is there a way to get the latest command entered? would be very useful. if not by default, anything i could download or write myself? From xng at xs4all.nl Thu Apr 17 09:21:09 2008 From: xng at xs4all.nl (Martin P. Hellwig) Date: Thu, 17 Apr 2008 15:21:09 +0200 Subject: I just killed GIL!!! In-Reply-To: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: <48074f58$0$4916$e4fe514c@dreader32.news.xs4all.nl> sturlamolden wrote: You killed the GIL, you bastard! :-) > Hello Guys... > > I just had one moment of exceptional clarity, during which realized > how I could get the GIL out of my way... It's so simple, I cannot help > wondering why nobody has thought of it before. Duh! Now I am going to > sit and and marvel at my creation for a while, and then go to bed > (it's past 2:30 a.m.) Tomorrow I will contemplate whether to sell this > little secret for big bucks, give it away for free, or just keep it to > myself... :-) > Sounds good, though I have a question. Is it transparent, meaning I can just write my code the way I used too and it makes the decision for itself to spread the tasks on multiple CPU's without me to worry about shared memory, spinlocks, deadlocks and out of order inter-depending processing of subtask without heaving having so much overhead that it has no performance advantage? If not, what is the advantage above already present solutions? -- mph From jgardner at jonathangardner.net Thu Apr 17 13:16:05 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Thu, 17 Apr 2008 10:16:05 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> Message-ID: On Apr 17, 8:19 am, sturlamolden wrote: > > An there you have the answer. It's really very simple :-) > That's an interesting hack. Now, how do the processes communicate with each other without stepping on each other's work and without using a lock? Once you get that solved, I am sure the entire computing world will beat a path to your door. (Hint: This is the kind of thing Stroustrup, Guido, and Alonzo Church have thought a lot about, just to name a few.) By the way, you do know that you can recompile Python from source code, and that you have the freedom to modify that source code. If you want to remove the GIL and see what happens, just make the calls to acquire and release the GIL do nothing. See how far that will get you. From rbrito at ime.usp.br Thu Apr 24 20:31:15 2008 From: rbrito at ime.usp.br (=?ISO-8859-1?Q?Rog=E9rio_Brito?=) Date: Thu, 24 Apr 2008 21:31:15 -0300 Subject: Little novice program written in Python Message-ID: Hi, All. I'm just getting my feet wet on Python and, just for starters, I'm coding some elementary number theory algorithms (yes, I know that most of them are already implemented as modules, but this is an exercise in learning the language idioms). As you can see from the code below, my background is in C, without too much sophistication. What I would like is to receive some criticism to my code to make it more Python'esque and, possibly, use the resources of the computer in a more efficient way (the algorithm implemented below is the Sieve of Eratosthenes): - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #!/usr/bin/env python n = int(raw_input()) a = [i for i in range(0,n+1)] a[1] = 0 # not a prime prime = 1 # last used prime finished = False while (not finished): prime = prime + 1 # find new prime while prime*prime <= n and a[prime] == 0: prime += 1 # cross the composite numbers if prime*prime <= n: j = 2*prime while j <= n: a[j] = 0 j += prime else: finished = True # print out the prime numbers i = 2 while i <= n: if a[i] != 0: print a[i] i += 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Thank you for any help in improving this program, -- Rog?rio Brito : rbrito@{mackenzie,ime.usp}.br : GPG key 1024D/7C2CAEB8 http://www.ime.usp.br/~rbrito : http://meusite.mackenzie.com.br/rbrito Projects: algorithms.berlios.de : lame.sf.net : vrms.alioth.debian.org From mobile at ibinsa.com Fri Apr 25 14:44:22 2008 From: mobile at ibinsa.com (Gabriel Ibanez) Date: Fri, 25 Apr 2008 20:44:22 +0200 Subject: print some text References: <7ac7b11d-6c9b-477c-8c0d-b038bc760918@c58g2000hsc.googlegroups.com> Message-ID: <01b301c8a704$615e58e0$0a01a8c0@mobile> Hi ! Other idea (old style school): def printing(): f=open("lpt1", "w") f.write("\nSomething to print\f") f.close() Cheers.. - Ibanez - ----- Original Message ----- From: Newsgroups: comp.lang.python To: Sent: Wednesday, April 23, 2008 10:27 PM Subject: Re: print some text On Apr 23, 2:05 pm, barronmo wrote: > I'm a beginner searching for an easy way to print the contents of a > text control. So far I've come up with the following(difficulties): > > 1) using wxPython > -convert to HTML and then print (I don't know anything about > HTML) > -use wx.Printout (Seems complicated; may be beyond my abilities) > > 2) create a text file and then print it out (can create but can only > print with the win32api.ShellExecute method so this solution doesn't > help me on my Linus laptop) > > 3) use ReportLab to create .pdf and then print that out (again, can > create but can't print in Linux) > > Thanks for any help. > > Mike Write out an HTML file, write back if you need a quick one, then print that with a browser. -- http://mail.python.org/mailman/listinfo/python-list From flarefight at googlemail.com Sun Apr 27 18:13:06 2008 From: flarefight at googlemail.com (flarefight at googlemail.com) Date: Sun, 27 Apr 2008 15:13:06 -0700 (PDT) Subject: Loading associated files References: <74862697-da58-4eb7-8d60-09aaef54b7ad@j22g2000hsf.googlegroups.com> <09337541-0b3e-4aaf-b26f-06a0f689e7dc@u12g2000prd.googlegroups.com> <850a01c2-d59e-4ee7-a344-796fd3cbb8aa@v23g2000pro.googlegroups.com> Message-ID: No you didnt misunderstand the situation, i think i have confused matters though!! When Ive got it working my program will read the data within the file. But obviously for it to do that it needs to know where the file is, hence the whole discussion. However to test things were working, just with regards the setting up of the registry, and since the contents of the file are essentially irrelevant for the test, i made the test file a valid python file so that i could test the registry setup by sending it to python.exe. It doesnt need to be and wont be a python file, ultimately it will contain some cPickle data which the program reads from the file. But as i said i need it to know the path of the file it needs to unpickle. And there are already "" around my %1 sign. It currently reads "C:\test \test.py" "%1", where test.py is the short program that simply reads the sys.argv that i posted further up. From leoniaumybragg at gmail.com Sat Apr 26 06:58:39 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:58:39 -0700 (PDT) Subject: crack addict behavior Message-ID: crack addict behavior http://cracks.00bp.com F R E E C R A C K S From trentm at activestate.com Tue Apr 22 13:41:38 2008 From: trentm at activestate.com (Trent Mick) Date: Tue, 22 Apr 2008 10:41:38 -0700 Subject: Does Python 2.5 include or not include SQLite engine? In-Reply-To: <3de8e1f70804212233o4e62c52s2a4d140deaa44355@mail.gmail.com> References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> <1208819146.23409.1249124463@webmail.messagingengine.com> <3de8e1f70804212233o4e62c52s2a4d140deaa44355@mail.gmail.com> Message-ID: <480E2352.5050005@activestate.com> Whether a Python installation includes the SQLite 3 bindings typically depends on: 1. Python version: core support for the SQLite 3 bindings (i.e. the "sqlite3" module) was added in Python 2.5. Earlier versions of Python may also have a 3rd-party package/module that adds SQLite bindings, of course. 2. The Python distro: The binary Python 2.5 installers from python.org (for Windows and Mac OS X [^1]) and ActiveState, i.e. ActivePython, (for Windows, Mac OS X, Linux, Solaris, HP-UX and AIX) include the "sqlite3" module as part of the installer. I don't know about other Python distributions. 3. Platform: Commonly on Linux one will get Python from the Linux distro's own packaging utility (e.g., apt-get, rpm, synaptic, yum, etc.) Typically the Linux distros will break up a Python installation into multiple packages. So an installation of, say, the "python2.5" package will often not have the "sqlite3" module. To get it you would have to install the separate "python2.5-sqlite" package. (Note: the names of these packages vary with Linux distro and version of that distro.) Cheers, Trent [1]: I could be wrong about whether the Mac OS X binary installer for Python 2.5 from python.org includes the "sqlite3" module -- I haven't checked -- but I presume it does. Banibrata Dutta wrote: > Doesn't this depend on the source / distro ? My Python is from the > ActivePython distro, while I am not sure (since I've just about started > playing with it), I haven't seen SQLite included ... possible that I > missed it. > > On 4/22/08, *python at bdurham.com * > > wrote: > > While reading feedback to my post "Does Python 2.5.2's embedded SQLite > support full text searching?" I noticed that there appears to be some > confusion regarding whether Python 2.5 includes the SQLite engine. > > My Windows 2.5.2 binary download includes SQLite. > > But other posters claim otherwise, re: Linux releases of Python 2.5? > > I thought one of the major features of Python 2.5 was its embedded > SQLite engine. > > Thoughts? -- Trent Mick trentm at activestate.com From skanemupp at yahoo.se Sat Apr 12 11:55:37 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 12 Apr 2008 08:55:37 -0700 (PDT) Subject: tkinter, editing an entry, int-value of insert? References: Message-ID: <2d68dadf-6548-40b5-999b-e42ac750a668@w8g2000prd.googlegroups.com> solved this: def Backspace(): st = e.index(INSERT) e.delete(st-1,st) From nicola.musatti at gmail.com Thu Apr 24 05:03:11 2008 From: nicola.musatti at gmail.com (Nicola Musatti) Date: Thu, 24 Apr 2008 02:03:11 -0700 (PDT) Subject: Java or C++? References: Message-ID: On Apr 21, 3:14 pm, NickC wrote: > On Apr 15, 1:46 pm, Brian Vanderburg II > wrote: [...] > Yeah, C++ does try to be helpful, and all of those automatic copy > constructor, assignment operator and destructor implementations screw > up royally when confronted with pointers (and being able to use > pointers is basically the whole reason for bothering to write anything > in C or C++ in the first place). Code which relies on these default > method implementations is almost certain to be rife with memory leaks > and double-free bugs. So instead of being a convenience, they become a > painfully easy way of writing code that silently does some very, very > wrong things. When a class includes a pointer data member, there is no single, right way to handle it. C++ automatically generated member functions are defined so as to be consistent in dealing with *values*. Any C++ programmer that hasn't learnt this simple fact, shouldn't be trusted with any programming language. Python and especially Java will only make it harder to spot the mess he is making. > Other things like methods (including destructors!) being non-virtual > by default also make C++ code annoyingly easy to get wrong (without it > obviously looking wrong). I can see how that might be confusing for programmer coming from Python, but it's more natural for those coming from C. > The whole design of C++ is riddled with premature optimisation of > speed and memory usage in the default settings, instead of choosing > safe defaults and providing concise ways of allowing the programmer to > say "I know optimisation X is safe here, please use it". I absolutely agree. > And the result? Any serious project in the language has to adopt it's > own techniques for avoiding all those traps, and those techniques are > likely to eliminate any supposed optimisations provided by the choices > of the C++ committee, while filling a code base with boilerplate that > only exists for the purpose of working around defects in the language > design (Scott Meyers has written at length about the worst of these > issues, far more clearly and eloquently than I ever could [1]). Did you give up on C++ in the early nineties? Things have changed a lot since then. Many standard/commonly accepted solutions to the problems you mention can be found in the C++ standard library and in Boost (http://boost.org). With std::vector and boost::shared_ptr you can go an extremely long way without giving pointers any special considerations. Cheers, Nicola Musatti From george.sakkis at gmail.com Mon Apr 28 22:49:57 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Mon, 28 Apr 2008 19:49:57 -0700 (PDT) Subject: How to unget a line when reading from a file/stream iterator/generator? References: Message-ID: <5e3854fa-557f-4475-8123-346346767097@k13g2000hse.googlegroups.com> On Apr 28, 10:10?pm, pyt... at bdurham.com wrote: > George, > > > Is there an elegant way to unget a line when reading from a file/stream iterator/generator? > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502304 > > That's exactly what I was looking for! > > For those following this thread, the above recipe creates a generic > object that wraps any iterator with an 'unget' ("push") capability. > Clean and elegant! > > Thank you, > Malcolm A small suggestion: since unget is expected to be called infrequently, next should better be faster for the common case instead of penalizing it with a try/except: def next(self): if not self.pushed_back: return self.it.next() else: return self.pushed_back.pop() George From ellingt8877 at gmail.com Mon Apr 28 01:50:40 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:50:40 -0700 (PDT) Subject: amateur crack whores Message-ID: <785397dc-cb82-452a-9579-a7b482ff140f@l25g2000prd.googlegroups.com> amateur crack whores http://crack.cracksofts.com From kyosohma at gmail.com Fri Apr 11 15:21:41 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 11 Apr 2008 12:21:41 -0700 (PDT) Subject: Profiling programs/scripts? References: Message-ID: On Apr 11, 1:49 pm, skanem... at yahoo.se wrote: > how do i profile a program? i found out that there are some profilers > included in the standard library but couldnt really figure out how to > access/use them Are you talking about using PyChecker or nose or what? In other words, do you want to check your script for errors, documentation issues, compliance with PEPs or something else? Maybe you mean introspection? If the latter, here are a few links on the subject: http://www.ibm.com/developerworks/library/l-pyint.html http://www.diveintopython.org/power_of_introspection/index.html http://www.ginstrom.com/scribbles/2007/10/24/python-introspection-with-the-inspect-module/ If you want to do code coverage, PEPs stuff or checking for errors, use PyChecker and PyLint or nose. See the following for more info: http://www.logilab.org/857 http://pychecker.sourceforge.net/ http://somethingaboutorange.com/mrl/projects/nose/ Mike From jens at aggergren.dk Tue Apr 29 08:20:14 2008 From: jens at aggergren.dk (Jens) Date: Tue, 29 Apr 2008 05:20:14 -0700 (PDT) Subject: Zope/DTML Infuriating... References: Message-ID: <6db28964-d1ff-4c48-8e6d-ddee30e8e31a@y21g2000hsf.googlegroups.com> On Apr 29, 1:59?pm, Marco Mariani wrote: > Jens wrote: > > I've the checked that i'm referring to the variables correctly, so the > > only explanation i can come up with, is that '+' doesn't result in a > > string concatenation (with implicit typecast to string of the integer > > variable(this is a interpreted language after all)). > > No, sorry. You really need to read the python tutorial at the very least. > You might have wrong assumptions from previous PHP experiences. > > ?>>> 'x'+4 > Traceback (most recent call last): > ? ?File "", line 1, in > TypeError: cannot concatenate 'str' and 'int' objects > ?> ... and the non snobby answer would have been: ... From tim.arnold at sas.com Wed Apr 9 13:03:06 2008 From: tim.arnold at sas.com (Tim Arnold) Date: Wed, 9 Apr 2008 13:03:06 -0400 Subject: set file permission on windows References: <7d75fc7b-a2b7-4ca2-b386-27da975043d0@m44g2000hsc.googlegroups.com> Message-ID: "Tim Golden" wrote in message news:mailman.59.1207681890.17997.python-list at python.org... > Tim Arnold wrote: >> "Mike Driscoll" wrote in message >> news:7d75fc7b-a2b7-4ca2-b386-27da975043d0 at m44g2000hsc.googlegroups.com... >>> On Apr 8, 12:03 pm, "Tim Arnold" wrote: >>>> >> >>> According to the following thread, you can use os.chmod on Windows: >>> >>> http://mail.python.org/pipermail/python-list/2003-June/210268.html >>> >>> You can also do it with the PyWin32 package. Tim Golden talks about >>> one way to do it here: >>> >>> http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html >>> >>> Also see the following thread: >>> >>> http://mail.python.org/pipermail/python-win32/2004-July/002102.html >>> >>> or >>> >>> http://bytes.com/forum/thread560518.html >>> >>> Hope that helps! >>> >>> Mike >> >> Hi Mike, >> It does help indeed, especially the last two links. > > Hi, Tim. For the purposes of improving that page of mine linked > above, would you mind highlighting what made it less useful > than the last two links? On the surface, it seems to match your > use case pretty closely. Was there too much information? Too > little? Poor formatting? Just didn't feel right? I've a small set > of security-related pages in train and I'd rather produce something which > people find useful. > > Thanks > > TJG Hi TJG. Thanks for the site. Unfortunately, I mis-typed in the previous reply and that should have been the 'first two links' instead of 'last two links'. In fact I bookmarked your site so I can re-read the material and I copied the code to play around with. Excellent example--it contains just what I needed to know, esp. since it replaces the dacl instead of modifying one. Now I can remove access for 'Everybody' by simply not including it in the new dacl. thanks! --Tim Arnold From ladynikon at gmail.com Sun Apr 20 12:22:37 2008 From: ladynikon at gmail.com (Danyelle Gragsone) Date: Sun, 20 Apr 2008 12:22:37 -0400 Subject: prevx1 crack In-Reply-To: <9f3aa585-8049-4af6-b019-697941c73163@a5g2000prg.googlegroups.com> References: <9f3aa585-8049-4af6-b019-697941c73163@a5g2000prg.googlegroups.com> Message-ID: <59f9c5160804200922h7541f8edgd5289fceb574e2ca@mail.gmail.com> what the ... From tjreedy at udel.edu Tue Apr 8 23:59:52 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 8 Apr 2008 23:59:52 -0400 Subject: style question - hasattr References: Message-ID: "ian" wrote in message news:a59f2b47-d1c2-4db5-82a6-34746af5d1dc at w8g2000prd.googlegroups.com... | In old python code i would use 'has_key' to determine if an element | was present in a dictionary. | | Python 3.0 will even removed 'has_key'. The reason for removal is that | using the 'in' operator is a cleaner syntax and having two ways to | achieve the same result is against the principle of the language. | | Ok, so what about 'hasattr' ?? | hasattr(myObject,'property') | seems equivalent to | 'property' in dir(myObject) | | I would suggest that using the 'in' is cleaner in this case also. Is | there a performance penalty here? Yes, the construction of the dir. And I think there may be slight differences between the two. tjr From bronger at physik.rwth-aachen.de Thu Apr 24 07:28:04 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Thu, 24 Apr 2008 13:28:04 +0200 Subject: Python development tools References: <09992de9-39fa-4ee6-8009-35732f3433fb@y21g2000hsf.googlegroups.com> <87fxtcnvj7.fsf@physik.rwth-aachen.de> <48106ba0$0$11087$426a34cc@news.free.fr> Message-ID: <873apbqypn.fsf@physik.rwth-aachen.de> Hall?chen! Bruno Desthuilliers writes: > [...] > >> and it ends multi-line strings at single quotes. > > it chokes on unbalanced single quotes in triple-single-quoted > strings, and on unbalanced double-quotes in triple-double-quoted > strings, yes. Given that I never use triple-single-quoted strings > (and don't remember having seen such a thing in the thousands of > third-part .py files I've read so far), I'd qualify this as at > most a very minor annoyance. Not having proper python-shell and > pdb integration is wwwwaaaayyyy more annoying IMHO. My formulation was unfortunate. What doesn't work (at least for me) is something like """This is a docstring in which some "variables" are quoted.""" Here, "variables" doesn't seem to belong to the docstring for python-mode. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From watches0560 at global-replica-watch.com Fri Apr 25 12:04:21 2008 From: watches0560 at global-replica-watch.com (watches0560 at global-replica-watch.com) Date: Fri, 25 Apr 2008 09:04:21 -0700 (PDT) Subject: Brand Watches Seiko Men's Watches Premier SNA745P - AA Discount, Swiss, Fake Message-ID: <31119dff-a2e4-4523-a998-0d1803e0581e@i36g2000prf.googlegroups.com> Brand Watches Seiko Men's Watches Premier SNA745P - AA Discount, Swiss, Fake Browse our Seiko Men's Watches Premier SNA745P - AA Swiss watches, which is sure the watch you are looking for at low price. There are more high quality designer watch Swiss for selection Seiko Men's Watches Premier SNA745P - AA Link : http://www.watches-brand.com/Seiko-wristwatch-7594.html Brand : Seiko ( http://www.watches-brand.com/Seiko-Watches.html ) Model : Seiko Men's Watches Premier SNA745P - AA Description :

Seiko watches - indispensable for today's lifestyle. Seiko watches - an important accessory for today's lifestyle.

Sale Price : $ 245.00 Seiko Men's Watches Premier SNA745P - AA Details :
  • Brand: Seiko
  • Band material: Black Leather Strap
  • Case material: Stainless Steel
  • Dial color: Black
  • Movement type: Quartz
  • Water-resistant to 100 meters
Seiko Men's Watches Premier SNA745P - AA is new brand Swiss, join thousands of satisfied customers and buy your Seiko with total satisfaction. A watches-brand.COM 30 Day Money Back Guarantee is included with every Seiko Fake Series for secure, risk-free online shopping. watches-brand.COM does not charge sales tax for the Fake Seiko Men's Watches Premier SNA745P - AA. All of our Fake watches are shipped via EMS to worldwide. Normally it takes 3days to prepare the fake watch you ordered and 5-10days to transmit depending on the different destination.We pay for the free shipping cost for total quantity over 20 pcs. The EMS tracking NO. will be sent by email when an order is shipped from our warehouse. No more other charges from watches-brand.com such as the tax. If you have any other questions please check our other pages or feel free to email us by sales at watches-brand.com. The Same Fake Seiko Watches Series : Seiko Men's Watches Premier SNL039 - 5 : http://www.watches-brand.com/Seiko-wristwatch-7595.html Seiko Men's Watches Premier SNL041 - 5 : http://www.watches-brand.com/Seiko-wristwatch-7596.html Seiko Men's Watches Premier SNL041P - AA : http://www.watches-brand.com/Seiko-wristwatch-7597.html Seiko Men's Watches Premier SNL041P2 - AA : http://www.watches-brand.com/Seiko-wristwatch-7598.html Seiko Men's Watches Premier SNL042P - AA : http://www.watches-brand.com/Seiko-wristwatch-7599.html Seiko Men's Watches Premier SNL044P - AA : http://www.watches-brand.com/Seiko-wristwatch-7600.html Seiko Men's Watches Premier SNP001P - AA : http://www.watches-brand.com/Seiko-wristwatch-7601.html Seiko Men's Watches Premier SNP003P - AA : http://www.watches-brand.com/Seiko-wristwatch-7602.html Seiko Men's Watches Premier SNP004P - AA : http://www.watches-brand.com/Seiko-wristwatch-7603.html Seiko Men's Watches Premier SNP005P - AA : http://www.watches-brand.com/Seiko-wristwatch-7604.html Brand Watches Seiko Men's Watches Premier SNA745P - AA Discount, Swiss, Fake From kyosohma at gmail.com Thu Apr 24 13:36:29 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Thu, 24 Apr 2008 10:36:29 -0700 (PDT) Subject: Installer References: Message-ID: <5fa6a753-82a3-4465-9e47-165fd5f312c8@t54g2000hsg.googlegroups.com> On Apr 24, 11:39?am, Chris wrote: > Hey all, > > I've created a python program that relies on pysqlite, wxpython, and > matplotlib. Is there any way of creating an installer that will > install all these modules, python 2.5 and my program? > > Thanks. Chris, If all you're doing is creating an installer for your custom Python program to be run on PCs without Python, then you should take a look at py2exe or gui2exe (a py2exe wrapper). I use the latter to roll my program into an exe, then I use Inno Setup (which is free) to create the installer. Mike From ajaksu at gmail.com Wed Apr 2 11:55:22 2008 From: ajaksu at gmail.com (ajaksu) Date: Wed, 2 Apr 2008 08:55:22 -0700 (PDT) Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: On Apr 1, 10:15?pm, AK wrote: > Hello, Hiya > I find that I learn easier when I go from specific examples to a more > general explanation of function's utility and I made a reference guide > that will eventually document all functions, classes and methods in > Python's Standard Library. Thanks a lot, this is a great resource. > For now, I covered about 20 most important > modules. I will be adding more modules and eventually I'll cover > everything. Here's my progress so far, let me know if this is useful; > I'll be glad to hear comments/suggestions/etc: > > http://www.lightbird.net/py-by-example/ > Content is nice, presentation can be tweaked towards making examples easier to understand and run on the interactive console. I suggest taking a look at PyMOTW[1] and Crunchy[2][3] for nice ideas. Best regards, Daniel [1] http://www.doughellmann.com/projects/PyMOTW/ [2] http://code.google.com/p/crunchy/ [3] http://us.pycon.org/2008/conference/schedule/event/46/ From google at mrabarnett.plus.com Mon Apr 21 20:08:08 2008 From: google at mrabarnett.plus.com (MRAB) Date: Mon, 21 Apr 2008 17:08:08 -0700 (PDT) Subject: Problems replacing \ with \\ References: <0ca30eb2-3791-4910-9e78-f32e3b2a72cb@2g2000hsn.googlegroups.com> Message-ID: On Apr 21, 11:48 pm, "samsli... at gmail.com" wrote: > Hi... > > Here's a weird problem...I'm trying to escape a bunch of data to put > into a database. > > Here's what I have: > > def escape(string): > """ > Escape both single quotes and blackslashes > >>> x = r"fun\fun" > >>> escape(x) > 'fun\\\\fun' > """ > string = string.replace('\\', '\\\\') > return string > > Now the commands in the doctest work when I type them by hand into the > python interpreter!>>> x = r"fun\fun" > >>> escape(x) > > 'fun\\\\fun' > > But they don't work when I actually run them with doctest: > Failed example: > escape(x) > Expected: > 'fun\\fun' > Got: > 'fun\x0cun' > > Why? > > Thanks! Your doctest is in a triple-quoted string which contains the line: >>> x = r"fun\fun" ^^ which is the same as: >>> x = r"fun\x0cun" ^^^^ If you wrap a raw string in just quotes that is isn't a raw string any longer! HTH From eduardo.padoan at gmail.com Tue Apr 1 15:11:34 2008 From: eduardo.padoan at gmail.com (Eduardo O. Padoan) Date: Tue, 1 Apr 2008 16:11:34 -0300 Subject: Is this a good time to start learning python? In-Reply-To: <88fa881e-e59b-4682-801c-90ef08a1480a@a22g2000hsc.googlegroups.com> References: <47f1140e$0$735$a729d347@news.telepac.pt> <88fa881e-e59b-4682-801c-90ef08a1480a@a22g2000hsc.googlegroups.com> Message-ID: On Tue, Apr 1, 2008 at 3:57 PM, wrote: > On Apr 1, 12:47 pm, "Gabriel Genellina" > wrote: > > En Tue, 01 Apr 2008 13:57:55 -0300, escribi?: > > > > > > On Mar 31, 1:36 pm, "Gabriel Genellina" > > > wrote: > > > > >> Don't be scared by the "backwards incompatible" tag - it's the way to > > >> get > > >> rid of nasty things that could not be dropped otherwise. > > > > > I would consider breaking production code to be "nasty" as well. > > > > > Please explain how the existence of Python 3.0 would break your production > > code. > > The existence of battery acid won't hurt me either, unless I come into > contact with it. If one eventually upgrades to 3.0 -- which is > ostensibly the desired path -- their code could break and require > fixing. And how would this happen? I dont know of any good software distribution that upgrades a component to another major revision without asking first. The desired path is that, if somene wants to port his software to Python 3.0, that he follow the migration plan. Final users will install Python 3.0 as python3.0 anyway, with Python 2.x as default 'python' binary. > Backward compatibility is important. C++ could break all ties with C > to "clean up" as well, but it would be a braindead move that would > break existing code bases upon upgrade. > C++ is not C. No one "upgrades" from C to C++. -- Eduardo de Oliveira Padoan http://www.advogato.org/person/eopadoan/ Bookmarks: http://del.icio.us/edcrypt From danb_83 at yahoo.com Thu Apr 3 19:28:09 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Thu, 3 Apr 2008 16:28:09 -0700 (PDT) Subject: sine in python References: <92f00617-28ee-4104-bd04-a48f87d84785@q27g2000prf.googlegroups.com> Message-ID: On Apr 3, 6:09 pm, zillo... at googlemail.com wrote: > On Apr 3, 11:58 pm, Astan Chee wrote: > > > > > Hi, > > I have a math function that looks like this > > sin (Theta) = 5/6 > > How do I find Theta (in degrees) in python? I am aware of the math.sin > > function, but is there a reverse? maybe a sine table in python? > > Thanks > > Astan > > import math > If you now do > dir(math) > you'll see that the module has the functions 'asin' and 'degrees' that > find the inverse sine of a number, and convert radians to degrees, > respectively Better yet, do help(math) which will display the docstrings. From hexade at gmail.com Sun Apr 13 06:13:09 2008 From: hexade at gmail.com (Hexade) Date: Sun, 13 Apr 2008 03:13:09 -0700 (PDT) Subject: SQLite OperationalError near "?" References: <7e592f06-42b5-4834-8f7c-34c9bc44aceb@s39g2000prd.googlegroups.com> Message-ID: <1c355a11-da2b-40fe-9dba-61bd866abbc6@8g2000hsu.googlegroups.com> On 13 avr, 03:00, John Machin wrote: > On Apr 13, 8:45 am, Hexade wrote: > > > Hello > > > I would like to use the safe "?" placeholder in my SQLite requests but > > I got the following error: > > > Traceback (most recent call last): > > ? (...) > > ? cursor.execute("SELECT ? FROM ? WHERE name = ? ", (key, self.table, > > self.name)) > > OperationalError: near "?": syntax error > > > key, self.table and self.name are standart strings. > > > Any idea about how to solve this problem ? > > You may like to read the answer to the question on sqlite3 that was > posted 45 minutes before yours. Thank you. I guess you are speaking about http://groups.google.com/group/comp.lang.python/browse_thread/thread/50a8ad977ed31e2a# From steve at holdenweb.com Thu Apr 24 22:57:07 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 22:57:07 -0400 Subject: Psyco alternative In-Reply-To: <8b7d9523-1d15-41e5-8b69-39f8250e6a6f@i76g2000hsf.googlegroups.com> References: <8b7d9523-1d15-41e5-8b69-39f8250e6a6f@i76g2000hsf.googlegroups.com> Message-ID: sturlamolden wrote: > On Apr 25, 3:27 am, Steve Holden wrote: > >> That seems a little harsh: it's Python-in-a-strait-jacket. >> >> The fact remains that since RPython programs also run under the standard >> interpreter (albeit a factor of maybe a hundred times more slowly) their >> claim of self-hosting is valid. > > What is the smallest subset of Python needed to make a Turing complete > computer language? And would you still call that Python? > That's completely irrelevant. Let's just step back a bit. You started this by saying: > On Mar 27, 4:44 pm, Jean-Paul Calderone wrote: > >> > PyPy is self-hosted and has been for some time (a year or so?). > > This is technically not correct. PyPy is hosted by RPython, which is > not Python but a different language all together. I am simply pointing out that RPython is used for efficiency, not to do things that can't be done in standard Python. Since everything that is done in RPython can also be done, albeit more slowly, in standard Python, the claim to be self-hosting is valid despite your disagreement. In other words, you can take the PyPy translator and run it on CPython. The fact that they choose to use restricted Python instead in their "production" system is merely an optimization. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From billingspanshism at gmail.com Sat Apr 19 17:17:20 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:17:20 -0700 (PDT) Subject: rock and republic victoria beckham Message-ID: <445c4b3b-25ff-4537-a48e-6897febce861@y21g2000hsf.googlegroups.com> Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From usenet-nospam at well-adjusted.de Tue Apr 8 11:02:05 2008 From: usenet-nospam at well-adjusted.de (Jochen Schulz) Date: Tue, 8 Apr 2008 17:02:05 +0200 Subject: Data structure recommendation? References: Message-ID: * Steven Clark: > Hi all- > > I'm looking for a data structure that is a bit like a dictionary or a > hash map. In particular, I want a mapping of floats to objects. > However, I want to map a RANGE of floats to an object. This solution may be more than you actually need, but I implemented two metric space indexes which would do what you want (and I wanted to plug it anyway :)): http://well-adjusted.de/mspace.py/ You can do arbitrary range searches and nearest-neighbour search in these indexes provided you have a metric distance function for the objects you want to index. The distance function in your case would simply be the absolute difference between your floats. If every log message was contained in objects of this type: class LogMessage(object) def __init__(self, timestamp, object): self.timestamp = timestamp self.message = message you could write a distance function for these objects like this: def log_distance(log1, log2): return abs(log1.timestamp - log2.timestamp) and then you would create and search an index like this: from mspace import VPTree index = VPTree(all_log_messages, log_distance) index.search(single_msg, 10) The last line would yield all log messages within ten seconds (or whatever the unit of your timestamps is) of the given LogMessage single_msg. You could also use index.nn_search(single_msg, 3) To find the three messages closest to the given single_msg. Searching should be quite fast (O(log(n)), but indexing might take some time (O(n*log(n))). The problem is that VPTrees have to be constructed from the complete data set initially. They cannot grow. The alternative from mspace.py, BKTrees, may grow over time but they don't work with non-discrete distances. If you want to use them, you'd have to convert your timestamps to int/long first. J. -- In the west we kill people like chickens. [Agree] [Disagree] From anuraguniyal at yahoo.com Tue Apr 1 23:42:54 2008 From: anuraguniyal at yahoo.com (anuraguniyal at yahoo.com) Date: Tue, 1 Apr 2008 20:42:54 -0700 (PDT) Subject: bsddb3 thread problem References: <391d152a-aa74-40e2-804e-14f30756fda3@u10g2000prn.googlegroups.com> Message-ID: <658d94dd-d636-411d-a915-2a9d254417e0@d21g2000prf.googlegroups.com> On Apr 1, 9:02?pm, Rhamphoryncus wrote: > It's my understanding that the connection is NOT thread-safe. ?Your > thread should be using an entirely separate connection.- Hide quoted text - > Can you please explain that, which connection you are talking about? How to modify my test script for that? rgds Anurag From XX.XmcX at XX.XmclaveauX.com Wed Apr 23 15:08:10 2008 From: XX.XmcX at XX.XmclaveauX.com (MC) Date: Wed, 23 Apr 2008 21:08:10 +0200 Subject: Calling Python code from inside php References: Message-ID: Hi! If you are under Windows, you can: - call Python's functions via Active-Scripting - call a Python COM server (functions or properties) For that, use Pywin32. And, in all cases, call functions can use parameters. -- @-salutations Michel Claveau From ptmcg at austin.rr.com Wed Apr 2 14:05:49 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Wed, 2 Apr 2008 11:05:49 -0700 (PDT) Subject: Understanding bmp image files References: <2537c458-b4d5-480d-8407-168a2b59a27e@u10g2000prn.googlegroups.com> Message-ID: <4afbfaaf-1a31-4ffa-b987-5a7c18f6097d@24g2000hsh.googlegroups.com> On Apr 2, 12:51?pm, pranav wrote: > Hello, > I want to read a BMP file, do some processing and then write it in a > new file. The problem is in the third step. For reading the file, i > have converted the file into decimal numbers, representing the pixel > values. Then i perform calculations on those decimal numbers. Now i am > unable to convert those into the format as required by the "bmp" file. > Any one, who is into image reading/manipulation, please help. Here is a link to a *very* crude BMP file utility I wrote a long time ago. (http://www.geocities.com/ptmcg/python/index.html#bmp) Follow the highlighted "module" link to see the underlying code - there are methods for saving the BMP data to a file. Perhaps those samples might give you some insight on what is required. (I would probably rewrite this to use the struct module nowadays, but this code works as is.) -- Paul From pydev at rscorp.ab.ca Wed Apr 23 23:27:13 2008 From: pydev at rscorp.ab.ca (Scott SA) Date: Wed, 23 Apr 2008 21:27:13 -0600 Subject: @classmethod question Message-ID: Hi, I'm using the @classemethod decorator for some convenience methods and for some reason, either mental block or otherwise, can't seem to figure out how to elegantly detect if the call is from an instance or not. Here's the problem: Within the class definition, 'isinstance' has nothing to compare to because the class does not appear to exist. This is NOT a great example, but it outlines the the code: class RecipieClass: def __init__(self): pass @classmethod def get_ingrendients(self, recipie_list=None): if isinstnace(self,RecipieClass): return self.do_something_interesting() else: return do_something_boring(recipie_list) Yes, I can test to see if the param exists, but that makes the call exclusive i.e. I can _only_ call it as an instance or with a parameter. Why am I doing this? It is a series of convenience methods, in this case I'm interacting with a database via an ORM (object-relational model). I want the ability to call a class-ojbect and get related values, or pass some criteria and get related values for them without collecting the records first as instances, then iterating them. I need to call this from several places so I want to be DRY (don't repeat yourself). The easiest way to describe this as an analogy would be like having a recipie for cookies and wanting to know all of the ingredients ahead of time. Then, at another time, wanting to know what all the ingredients would be to make cookies, cake and bread (i.e. complete shopping list). cookie_recipie = RecipieClass.get_recipie('cookies') cookie_recipie.get_ingredients() 2C Flour 0.5 C Sugar ... RecipieClass.get_ingrendients(['cookies','cake','bread']) 8C Flour 2C Sugar ... Of course any suggestions on how this might be better approached would be interesting too. TIA, Scott From s0suk3 at gmail.com Thu Apr 17 13:58:04 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 10:58:04 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <1952579a-3cfb-44ea-92aa-658daa64aee4@a70g2000hsh.googlegroups.com> <564dd82b-8670-4ead-a3c8-a22b30a3eb73@m73g2000hsh.googlegroups.com> Message-ID: <98406333-c7c0-4b98-845d-c18895644c4a@t54g2000hsg.googlegroups.com> On Apr 17, 12:34 pm, Michael Torrie wrote: > > Another thing to consider is that referencing a member of a class or > instance already *is* a dictionary lookup. It's how python works. Thus > dictionaries are optimized to be fast. Since strings are immutable, > python hashes them into a fast lookup pointer. So every time you say > mydict["mykey"], it already knows the lookup pointer (hash) for "mykey" > (the string) and can find the dictionary entry very quickly, ideally in > O(1) time (well maybe log(N)). Thus putting your headers in a > dictionary is actually a really good idea for performance reasons. I didn't know about that, thanks. So after all the trouble I went through writing those 200 loc I actually maid it worse... From tjreedy at udel.edu Mon Apr 14 13:36:42 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 14 Apr 2008 13:36:42 -0400 Subject: Different times between Python and System References: <66292b91-a2ed-44d1-8fe6-9f4ecd87299b@w1g2000prd.googlegroups.com> Message-ID: "Josh" wrote in message news:66292b91-a2ed-44d1-8fe6-9f4ecd87299b at w1g2000prd.googlegroups.com... | Hmm... That didn't work out so well that time. I feel like an | idiot. Previously there has been an hour difference between the | system time and the time that python reports. That suggests a (temporary?) problem with standard vs. daylight time. From brian.e.munroe at gmail.com Wed Apr 2 16:04:05 2008 From: brian.e.munroe at gmail.com (Brian Munroe) Date: Wed, 2 Apr 2008 13:04:05 -0700 (PDT) Subject: class / module introspection? References: <3c3f09df-08cb-4309-a870-6b12a813a8af@u36g2000prf.googlegroups.com> <0f14a289-55ef-49e5-b650-60f7aca371ad@i36g2000prf.googlegroups.com> <85761ed1-afe8-48cc-8c6d-73183e6692a9@i7g2000prf.googlegroups.com> Message-ID: On Apr 2, 12:33 pm, "bruno.desthuilli... at gmail.com" wrote: > > Why not do the import here, so you store a real module instead of a > name ? > Right now I'm still in the prototyping phase and haven't really thought everything through. I needed the names because I am populating a GUI selection list element. I also assumed that I could then lazy load the modules I needed... Thanks for the help though, you've gotten me past my first of many (I'm sure) hurdles! -- brian From matiassurdi at gmail.com Mon Apr 14 03:41:41 2008 From: matiassurdi at gmail.com (Matias Surdi) Date: Mon, 14 Apr 2008 09:41:41 +0200 Subject: Remote mac address Message-ID: Anyone knows how having the IP address of a host on the lan could I get the mac address of that hosr? p/d: Parsing the output of arp -a is not an option. Thanks a lot! From sam at mas.pl Wed Apr 2 08:23:21 2008 From: sam at mas.pl (sam) Date: Wed, 02 Apr 2008 14:23:21 +0200 Subject: Prototype OO In-Reply-To: References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> Message-ID: Gabriel Genellina napisa?(a): >>>> 1. You have different syntax for named and unnamed (lambdas) >>>> functions. Functions and methods are different things in Python even >>>> if they have same syntax. But all these are still a pieces of code >>>> that you use repeatedly to make some task. >>>> >>> A knife and scissors are both used to cut things, but that doesn't mean >>> they are the same. >> >> Well -- sometimes you have to use many, many types of scissors. > > I don't get the point - weren't you criticizing Python for having many > different kind of functions? Yes. Funciton is always a piece of code (program) that does something. There is no need for different syntax. And you said that it is good to have these two types of syntax. It sounds like: "it is good to have knife and scissors to cut the _same_ thing, because they are not the same". > What are those programmers needs? Programmers need to protect name in a namespace. Name mangling is not the best choice. From roy at panix.com Sun Apr 20 10:12:20 2008 From: roy at panix.com (Roy Smith) Date: Sun, 20 Apr 2008 10:12:20 -0400 Subject: from __future__ import print References: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> <670um2F2ljorfU1@mid.uni-berlin.de> Message-ID: "Diez B. Roggisch" wrote: > You are aware that it is only one character more to type? I'm not arguing for print vs. print(), but I do want to comment on the "character count" argument. I'm a pretty good typist, the result of having been forced in junior high school (in the mid 70's) to learn typing the "right way" -- on a typewriter with blank keycaps. It forced you to really learn to touch-type. I don't know if this was some touchy-feely idea that if they girls had to learn to type (after all, they were all going to be secretaries) then it's only fair to make the boys learn it too. Or, if they were just amazingly prescient about computers taking over the world and typing becoming an important high-tech skill. Either way, I learned to touch type. That being said, hitting the space bar is pretty much a freebie. You can do it with either thumb(*), and you don't have to move your fingers from the home row. To get the ( and ), you have to reach way up to the top row with one hand and down hit the shift key with the opposite pinkie. A much costlier operation in terms of maintaining a good typing speed. On the other hand, it's a well known (or at least well believed :-)) fact that code is read many more times than it's written. Making something easier to read is much more important than making it easy to type. (*) Oddly enough, as I type this and pay attention to what my fingers are doing, I find that I almost exclusively use the *left* thumb, which I never noticed before. From Lie.1296 at gmail.com Sun Apr 27 14:34:05 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 27 Apr 2008 11:34:05 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> Message-ID: <2d06b319-e2fd-4790-af61-6f90b9b1b3b1@m1g2000pre.googlegroups.com> On Apr 27, 6:28?am, n00m wrote: > No so simple, guys. > E.g., I can't solve (in Python) this:http://www.spoj.pl/problems/INTEST/ > Keep getting TLE (time limit exceeded). Any ideas? After all, it's > weekend. > > 450. Enormous Input Test > Problem code: INTEST > > The purpose of this problem is to verify whether the method you are > using to read input data is sufficiently fast to handle problems > branded with the enormous Input/Output warning. You are expected to be > able to process at least 2.5MB of input data per second at runtime. > > Input > The input begins with two positive integers n k (n, k<=107). The next > n lines of input contain one positive integer ti, not greater than > 109, each. > > Output > Write a single integer to output, denoting how many integers ti are > divisible by k. > > Example > Input: > 7 3 > 1 > 51 > 966369 > 7 > 9 > 999996 > 11 > > Output: > 4 The problem is faulty. First, the bottleneck on reading a huge input is the harddisk speed and the string processing, the result of the competition doesn't prove anything but how fast the string processor and the harddisk is. Python's string processing is not a very fast one as it creates a copy of the string every now and then. From bockman at virgilio.it Thu Apr 24 10:41:35 2008 From: bockman at virgilio.it (bockman at virgilio.it) Date: Thu, 24 Apr 2008 07:41:35 -0700 (PDT) Subject: How to get inner exception traceback References: <67b8nuF2m1a1kU1@mid.individual.net> <09ce6c51-3c23-4fb7-a369-d357c0f5d287@m73g2000hsh.googlegroups.com> Message-ID: On 24 Apr, 15:00, Christian Heimes wrote: > bock... at virgilio.it schrieb: > : > > > class ReraisedException(Exception): > > ? ? def __init__(self, message, exc_info): > > ? ? ? ? Exception.__init__(self, message) > > ? ? ? ? self.inner_exception = exc_info > > > ?try: > > ? ? ? try: > > ? ? ? ? ? import does_not_exit > > ? ? ? except ImportError: > > ? ? ? ? ? ?raise ReraisedException("Something wrong", sys.exc_info() ) > > ?except ReraisedException, e: > > ? ? ?... # here you can use e.inner_exception > > ?except: > > This may lead to reference cycles, please readhttp://docs.python.org/dev/library/sys.html#sys.exc_info > > Christian- Nascondi testo tra virgolette - > > - Mostra testo tra virgolette - Thanks. I was not aware of that (Last time I read that section, the warning was not there). I usually do something like that in my scripts: try: do_something() except: err, detail, tb = sys.exc_info() print err, detail traceback.print_tb(tb) According to the document you linked to, also this causes circular reference, although in my case it is ininfluent , since I usually do it only before exiting a program after a fatal error. However, this seems like a dark spot in the implementation of CPython. Do you now if this has/will be cleaned in Python 3.x ? I'd like to see a 'print_tb' method in the exception class, so that I could do something like this: try: do_something() except Exception, e : # I know, in python 3.0 the syntax will be different print e e.print_tb() Ciao ------- F.B. From aldo at nullcube.com Sat Apr 5 06:26:06 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Sat, 5 Apr 2008 21:26:06 +1100 Subject: ANN: pry unit testing framework In-Reply-To: References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> Message-ID: <20080405102606.GA15154@nullcube.com> Thus spake Kay Schluehr (kay.schluehr at gmx.net): > I'm not entirely sure what you are claiming here. From source > inspections I can see that TestSuite instances are instantiated by the > TestLoader and you are free to derive from TestLoader, overwrite its > methods and pass around another instance than defaultTestLoader ( or > a fresh instance of TestLoader which is the same thing ). ... and at this point your monkeypatched framework would no longer be much more compatible with existing test suites than Pry is. > My impression is that unittest is bashed so much because it has Java > style naming conventions i.e. for bike shading reasons Do you mean bike shedding, perhaps? At any rate, your impression is mostly incorrect. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 23 05:48:12 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 23 Apr 2008 11:48:12 +0200 Subject: help needed with classes/inheritance In-Reply-To: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> References: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> Message-ID: <480f05d0$0$25755$426a74cc@news.free.fr> barbaros a ?crit : > Hello everybody, > > I am building a code for surface meshes (triangulations for instance). > I need to implement Body objects (bodies can be points, segments, > triangles and so on), then a Mesh will be a collection of bodies, > together with their neighbourhood relations. > I also need OrientedBody objects, which consist in a body > together with a plus or minus sign to describe its orientation. > So, basically an OrientedBody is just a Body with an > integer label stuck on it. > > I implemented it in a very crude manner: > ------------------------------------------ > class Body: Unless you need compatibility with pre-2.2 Python versions, use a new-style class instead: class Body(object): > [...] > class OrientedBody: > def __init__ (self,b,orient=1): > # b is an already existing body > assert isinstance(b,Body) > self.base = b > self.orientation = orient > ------------------------------------------- > > My question is: can it be done using inheritance ? Technically, yes: class OrientedBody(Body): def __init__(self, orient=1): Body.__init__(self) self.orient = 1 Now if it's the right thing to do is another question... Another possible design could be to have an orient attribute on the Body class itself, with 0 => non-oriented (default), 1 => 'plus', -1 => 'minus' (or any other convention, depending on how you use this attribute). From grante at visi.com Thu Apr 17 09:49:53 2008 From: grante at visi.com (Grant Edwards) Date: Thu, 17 Apr 2008 08:49:53 -0500 Subject: What can we do about all the spam that the list is getting? References: <259ab201-9d2b-4e4e-88a7-e2fe277f0066@a23g2000hsc.googlegroups.com> Message-ID: On 2008-04-16, Mark Shroyer wrote: > In article >, > Mensanator wrote: > >> On Apr 16, 12:01?pm, sr... at ferg.org wrote: >> > What can we do about all the spam that comp.lang.python is getting? >> > Things are getting pretty bad. >> >> Buy Google and make them fix it. > > I've had pretty good luck with MT-NewsWatcher, a freeware Mac > newsreader that performs Bayesian spam filtering. > Thunderbird's Usenet reader also offers Bayesian filtering, > which presumably works just as well for classifying Usenet > spam as it does at handling email spam. > > So download a "real" NNTP client for whatever platform you're > on and give its spam filter a shot; clearly Google is not > interested in fighting spam itself. Plonking anything posted via google.groups is the simplest answer. -- Grant Edwards grante Yow! Am I accompanied by a at PARENT or GUARDIAN? visi.com From urquhart.nak at gmail.com Wed Apr 30 06:28:22 2008 From: urquhart.nak at gmail.com (urquhart.nak at gmail.com) Date: Wed, 30 Apr 2008 03:28:22 -0700 (PDT) Subject: microsoft office 2007 crack Message-ID: <561a471a-9ead-4bc7-b32a-ad169b26a2f6@z24g2000prf.googlegroups.com> microsoft office 2007 crack http://crack.cracksofts.com From bjourne at gmail.com Sun Apr 27 12:27:07 2008 From: bjourne at gmail.com (=?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=) Date: Sun, 27 Apr 2008 18:27:07 +0200 Subject: design choice: multi-threaded / asynchronous wxpython client? In-Reply-To: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: <740c3aec0804270927w43c2d5eal67d927811e91522b@mail.gmail.com> I think twisted is overkill for this problem. Threading, elementtree and urllib should more than suffice. One thread polling the server for each race with the desired polling interval. Each time some data is treated, that thread sends a signal containing information about what changed. The gui listens to the signal and will, if needed, update itself with the new information. The database handler also listens to the signal and updates the db. 2008/4/27, bullockbefriending bard : > I am a complete ignoramus and newbie when it comes to designing and > coding networked clients (or servers for that matter). I have a copy > of Goerzen (Foundations of Python Network Programming) and once > pointed in the best direction should be able to follow my nose and get > things sorted... but I am not quite sure which is the best path to > take and would be grateful for advice from networking gurus. > > I am writing a program to display horse racing tote odds in a desktop > client program. I have access to an HTTP (open one of several URLs, > and I get back an XML doc with some data... not XML-RPC.) source of > XML data which I am able to parse and munge with no difficulty at all. > I have written and successfully tested a simple command line program > which allows me to repeatedly poll the server and parse the XML. Easy > enough, but the real world production complications are: > > 1) The data for the race about to start updates every (say) 15 > seconds, and the data for earlier and later races updates only every > (say) 5 minutes. There is no point for me to be hammering the server > with requests every 15 seconds for data for races after the upcoming > race... I should query for this perhaps every 150s to be safe. But for > the upcoming race, I must not miss any updates and should query every > ~7s to be safe. So... in the middle of a race meeting the situation > might be: > race 1 (race done with, no-longer querying), race 2 (race done with, > no longer querying) race 3 (about to start, data on server for this > race updating every 15s, my client querying every 7s), races 4-8 (data > on server for these races updating every 5 mins, my client querying > every 2.5 mins) > > 2) After a race has started and betting is cut off and there are > consequently no more tote updates for that race (it is possible to > determine when this occurs precisely because of an attribute in the > XML data), I need to stop querying (say) race 3 every 7s and remove > race 4 from the 150s query group and begin querying its data every 7s. > > 3) I need to dump this data (for all races, not just current about to > start race) to text files, store it as BLOBs in a DB *and* update real > time display in a wxpython windowed client. > > My initial thought was to have two threads for the different update > polling cycles. In addition I would probably need another thread to > handle UI stuff, and perhaps another for dealing with file/DB data > write out. But, I wonder if using Twisted is a better idea? I will > still need to handle some threading myself, but (I think) only for > keeping wxpython happy by doing all this other stuff off the main > thread + perhaps also persisting received data in yet another thread. > > I have zero experience with these kinds of design choices and would be > very happy if those with experience could point out the pros and cons > of each (synchronous/multithreaded, or Twisted) for dealing with the > two differing sample rates problem outlined above. > > Many TIA! > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- mvh Bj?rn From deets at nospam.web.de Wed Apr 2 05:40:20 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 02 Apr 2008 11:40:20 +0200 Subject: IM status with appscript References: Message-ID: <65h2l0F2fba8bU1@mid.uni-berlin.de> Oolon Colluphid wrote: > hi, > i need access to application attributes of IM (like Adium, aMsn, MS > Messenger) on Mac platform via appscript module. > once instantiated the application object with: app=app("Adium") > i don't know how recover information like status, and i have find no > references. Use the appscript examples + the OS X script-editor to see what scriptable properties exactly the IM-application offers. You can drag the application-icon into the script-library. Diez From arnodel at googlemail.com Sun Apr 27 07:51:50 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 27 Apr 2008 12:51:50 +0100 Subject: removing extension References: Message-ID: Lie writes: > On Apr 27, 6:05 pm, Lie wrote: >> >> I don't know if this is the simplest way, but you can use re module. >> >> import re >> pat = re.compile(r'(.*?)\..*') > > Sorry, this line should be: > pat = re.compile(r'(.*)\..*') > > or paths like these wouldn't pass correctly: > "C:\\blahblah.blah\\images.20.jpg" > >> name = pat.search('C:\\myimages\\imageone.jpg').group(1) >> print name More simply, use the rsplit() method of strings: >>> path = r'C:\myimages\imageone.jpg' >>> path.rsplit('.', 1) ['C:\\myimages\\imageone', 'jpg'] >>> path = r"C:\blahblah.blah\images.20.jpg" >>> path.rsplit('.', 1) ['C:\\blahblah.blah\\images.20', 'jpg'] HTH -- Arnaud From kyosohma at gmail.com Tue Apr 8 16:44:14 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 8 Apr 2008 13:44:14 -0700 (PDT) Subject: new user needs help! References: <16571823.post@talk.nabble.com> Message-ID: On Apr 8, 3:38 pm, Steve Holden wrote: > drjekil wrote: > > I am totally new in biopython and its my first program.so may be i am asking > > stupid question. > > New? Most questions are sensible. > > Let's suppose that the four lines you give below are stored in a text > file called "/tmp/data.txt". > > > I am working with a text filelooks like this: > > #NAME AA TOPO ACCESS DSSP STRIDE Z-COORD > > 1lghB A i 79.8 H H -24.58 > > 1lghB V i 79.6 H H -22.06 > > 1lghB H i 71.9 H H -19.94 > > f = open("/tmp/data.txt", 'w') > > will open that file. Don't do that! You will overwrite the original! > > You can throw the first line away with > > headings = f.next() I forgot to throw away the first line in my code though...so mine has errors too. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ Mike From dickinsm at gmail.com Sat Apr 5 19:25:49 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Sat, 5 Apr 2008 16:25:49 -0700 (PDT) Subject: Best way to check if string is an integer? References: Message-ID: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> On Apr 5, 6:19?pm, skanem... at yahoo.se wrote: > which is the best way to check if a string is an number or a char? > could the 2nd example be very expensive timewise if i have to check a > lot of strings? You might be interested in str.isdigit: >>> print str.isdigit.__doc__ S.isdigit() -> bool Return True if all characters in S are digits and there is at least one character in S, False otherwise. Mark From ankitks.mital at gmail.com Thu Apr 3 18:21:19 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Thu, 3 Apr 2008 15:21:19 -0700 (PDT) Subject: python bisect questions References: <6bb6927b-f553-40db-a142-2ce86b9e819f@q27g2000prf.googlegroups.com> Message-ID: On Apr 3, 4:24?pm, "Terry Reedy" wrote: > wrote in message > > news:6bb6927b-f553-40db-a142-2ce86b9e819f at q27g2000prf.googlegroups.com... > |I am week on functional programming, and having hard time > | understanding this: > | > | class myPriorityQueue: > | ? ? ?def __init__(self, f=lamda x:x): > | ? ? ? ? ? ? ?self.A = [] > | ? ? ? ? ? ? ?self.f = f > | > | ? ? ?def append(self, item) > | ? ? ? ? ? ? ?bisect.insort(self.A, (self.f(item), item)) > | ? ?............ > | > | now I know we are inserting items(user defined type objects) in list A > | base on sorting order provided by function A. > | but what I don't understand is bisect command > | what does bisect.insort(self.A, (self.f(item), item)) doing here is doc insort_right(a, x[, lo[, hi]]) Insert item x in list a, and keep it sorted assuming a is sorted. If x is already in a, insert it to the right of the rightmost x. Optional args lo (default 0) and hi (default len(a)) bound the slice of a to be searched. but I am still confuse. self.A is my list a. and item is x that I am trying to insert. So it needs to be of type item not (self.f(item), item) It doesn't say anything pass sorting function self.f(item). Also I am new to Python Please help? > > The snippet is missing 'import bisect'. ?The module is documented in the > Lib Ref. ?Or, in the interpreter, help(bisect.insort) redirects you to > help(bisect.insort_right), which will answer your question. > > | isn't it is returning truple of (self.f(item), item)). > > no, see doc > > | why it is not > | biset.insort(self.A, item) > | A.sort(f) > > Efficiency, given that self.A is already sorted. > > tjr From sjmachin at lexicon.net Mon Apr 21 19:47:43 2008 From: sjmachin at lexicon.net (John Machin) Date: Mon, 21 Apr 2008 23:47:43 GMT Subject: dynamically importing a module and function In-Reply-To: References: <480d1782$1@news.mel.dft.com.au> Message-ID: <480d27a3@news.mel.dft.com.au> rkmr.em at gmail.com wrote: > On Mon, Apr 21, 2008 at 3:39 PM, John Machin wrote: >> rkmr.em at gmail.com wrote: >>> data['module'], in the directory data['cwd'] >> OT: Any good reason for using a dictionary instead of a class instance >> (data.functiom, data.module, etc)? > not really, i just wanted to stick to primitive python data types. > > >>> If I do this from python interactive shell (linux fedora core 8) from >>> dir /home/mark it works fine: >>> >>> cwd = data['cwd'] >>> os.chdir(cwd) >>> print os.getcwd() >>> module = __import__(data['module']) >>> function = getattr(module, data['function']) >>> >>> > >> saved = sys.path >> sys.path = data['cwd'] >> module = __import__(data['module']) >> sys.path = saved > > now the module gets loaded, but i am not able to get the function from > the module, though it works fine in the interactive-shell > > Traceback (most recent call last): > File "/home/mark/work/common/funcq.py", line 62, in > if __name__ == '__main__':do() > File "/home/mark/work/common/funcq.py", line 35, in do > function = getattr(module, data['function']) > AttributeError: 'module' object has no attribute 'new' > > > this works in shell though.. >>>> import os >>>> os.chdir('/home/mark/work/proj1') >>>> import sys >>>> sys.path.append('/home/mark/work/proj1') >>>> module = __import__('app') >>>> function = getattr(module, 'new') >>>> function(1) > 1 It's not at all obvious that the "works in shell" code is the same as the code in your script. Consider the possibility that as a result of frantic experimentation you have multiple copies of app.* with varying contents lying around. Try this in your script so that you can see exactly what it is doing, instead of comparing it to a strawman: print "attempting to import", whatever module = __import__(whatever) print "got", module.__name__, "from", os.path.abspath(module.__file__) print "module contents":, dir(module) From fetchinson at googlemail.com Sun Apr 20 17:10:13 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Sun, 20 Apr 2008 14:10:13 -0700 Subject: I would like to learn scripting in Python too! In-Reply-To: <8339da0f0804201151s1ba691e3n970c2827abc22cae@mail.gmail.com> References: <8339da0f0804201151s1ba691e3n970c2827abc22cae@mail.gmail.com> Message-ID: > I am a software tester and I see lot of testers on the forums saying Python > is a wonderful scripting language that testers use on a daily basis. > > I would also like to learn to script in Python but I do not have any > programming background. This is a good starting point: http://wiki.python.org/moin/BeginnersGuide HTH, Daniel From gabriel.rossetti at mydeskfriend.com Wed Apr 2 09:12:57 2008 From: gabriel.rossetti at mydeskfriend.com (Gabriel Rossetti) Date: Wed, 02 Apr 2008 15:12:57 +0200 Subject: Python in High School In-Reply-To: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: <47F38659.4020101@mydeskfriend.com> sprad wrote: > I'm a high school computer teacher, and I'm starting a series of > programming courses next year (disguised as "game development" classes > to capture more interest). The first year will be a gentle > introduction to programming, leading to two more years of advanced > topics. > > I was initially thinking about doing the first year in Flash/ > ActionScript, and the later years in Java. My reasoning is that Flash > has the advantage of giving a quick payoff to keep the students > interested while I sneak in some OOP concepts through ActionScript. > Once they've gotten a decent grounding there, they move on to Java for > some more heavy-duty programming. > > I've never used Python, but I keep hearing enough good stuff about it > to make me curious. > > So -- would Python be a good fit for these classes? Could it equal > Java as the later heavy-duty language? Does it have enough quickly- > accessible sparklies to unseat Flash? > > I want to believe. Evangelize away. > I think it's a good idea (to use python), Mr. Swinnen, a high school teacher in Belgium wrote a book out of the course that he created for his programming class : Apprendre ? programmer avec Python, 2e ?dition, O'Reilly. His course was originally a translation of Allen B. Downey's Open-source book (see : http://www.greenteapress.com/free_books.html). I think this is proof of concept, no? Gabriel From hopeorpha308 at gmail.com Sun Apr 27 07:47:10 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:47:10 -0700 (PDT) Subject: Chocolatier crack Message-ID: <05fb47a8-e6b6-4e64-a4df-35e5e5167130@w7g2000hsa.googlegroups.com> Chocolatier crack http://wga-cracks.crackkey.net From arnodel at googlemail.com Sun Apr 13 05:01:31 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 13 Apr 2008 02:01:31 -0700 (PDT) Subject: Call a classmethod on a variable class name References: Message-ID: <3b34f7c2-7692-4426-8740-2e0d84fdf472@k37g2000hsf.googlegroups.com> On Apr 13, 9:51?am, Matthew Keene wrote: > I would like to be able to call a specific classmethod on a class name > that is going to be passed from another parameter. ?In other words, I > have a call that looks something like: > > ? ?x = Foo.bar() > > and I would like to generalise this so that I can make this call on any > particular class which provides the bar classmethod. > > I have implemented this using exec, like so: > > ? className = parameters.className > ? exec "x = " + className + ".bar()" > > but this feels somewhat clumsy. ?(I do have the requisite exception > handling to cope with the supplied class not existing or not > implementing the bar method, by the way). > > Is there any more Pythonesque way of doing this ? ?I guess what I'm > probably looking for is something like the way I understand the send > function works in Ruby If your class lives in the current global namespace, you can get it with >>> cls = globals()[classname] Then you can access its .bar() method directly: >>> cls.bar() Example: >>> class Foo(object): ... @classmethod ... def bar(cls): print 'Oh my Baz!' ... >>> globals()['Foo'] >>> globals()['Foo'].bar() Oh my Baz! If your class lives in a module, just do getattr(module, classname) instead to get the class object. HTH -- Arnaud From rorymckinleylists at gmail.com Sun Apr 6 03:13:40 2008 From: rorymckinleylists at gmail.com (Rory McKinley) Date: Sun, 06 Apr 2008 09:13:40 +0200 Subject: Weird scope error[SOLVED?] In-Reply-To: <43917932-3381-4130-8aca-a2dd05a19ee2@t36g2000prm.googlegroups.com> References: <47F79A78.4010207@gmail.com> <47F7A41C.4090402@islandtraining.com> <47F7E325.9060603@gmail.com> <43917932-3381-4130-8aca-a2dd05a19ee2@t36g2000prm.googlegroups.com> Message-ID: <47F87824.30907@gmail.com> Kay Schluehr wrote: > On 5 Apr., 23:08, Michael Torrie wrote: > >> You need to either fix all these imports in these other modules (that >> are probably in the site_packages folder), or modify the python import >> path so that it can find ElementTree directly. > > I'd prefer to set an alias in the module cache: > >>>> import sys >>>> import xml.etree >>>> sys.modules["elementree"] = xml.etree >>>> from elementree import ElementTree >>>> > Thank you Kay, Michael, and Gary for all suggestions and patience. I had actually changed the import inside the module itself, but it was still complaining. I was testing using the interactive console. This morning, without actually touching the module file again, I fired up the console and bingo! it works. So, it appears that the console was perhaps "cacheing" the module - does that make sense? Thanks Rory From skanemupp at yahoo.se Sat Apr 5 19:53:14 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 16:53:14 -0700 (PDT) Subject: while-loops enter the last time after condition is filled? Message-ID: it seems to me from my results that when i use a while-loop it will execute once after the condition is met. ie the conditions is met the code executes one time more and then quits. From webograph at eml.cc Sun Apr 27 06:40:05 2008 From: webograph at eml.cc (webograph) Date: Sun, 27 Apr 2008 12:40:05 +0200 Subject: Why can't timedeltas be divided? In-Reply-To: <48142747$0$20906$9b622d9e@news.freenet.de> References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> <48142747$0$20906$9b622d9e@news.freenet.de> Message-ID: <48145805.4040208@eml.cc> On 2008-04-27 09:12, Martin v. L?wis wrote: >> Last time I brought up this sort of thing, it seemed fairly unanimous >> that the shortcomings of the datetime module were 'deliberate' and >> would not be fixed, patch or no patch. >> > Ok, so then if the answer to my question is "yes", the first step > should be to discuss it on python-dev. i've had a look at the source code and written a small patch (attached; contains a case in classical/floor division as well as truediv). is there a defined escalation procedure from python-list to python-dev or should i just send the suggestion+patch there? regards webograph ps: i hope the patch conforms to python c coding style (most of it is just copy/pasted and modified). -------------- next part -------------- A non-text attachment was scrubbed... Name: datetime_datetime_division.patch Type: text/x-diff Size: 2185 bytes Desc: not available URL: From billingspanshism at gmail.com Sat Apr 19 17:17:34 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:17:34 -0700 (PDT) Subject: victoria beckham news Message-ID: <354bf216-66be-44eb-97af-01c893c1ab79@k37g2000hsf.googlegroups.com> Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From gagsl-py2 at yahoo.com.ar Thu Apr 3 10:08:21 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 11:08:21 -0300 Subject: Get all strings matching given RegExp References: <47F4A87C.7020701@gmail.com> Message-ID: En Thu, 03 Apr 2008 06:50:52 -0300, Alex9968 escribi?: > Can I get sequence of all strings that can match a given regular > expression? For example, for expression '(a|b)|(x|y)' it would be ['ax', > 'ay', 'bx', 'by'] See this thread: http://groups.google.com/group/comp.lang.python/browse_thread/thread/bc6e305844aeee82/ -- Gabriel Genellina From smmehadi at gmail.com Wed Apr 9 10:14:33 2008 From: smmehadi at gmail.com (syed mehdi) Date: Wed, 9 Apr 2008 19:44:33 +0530 Subject: argument to python cgi script Message-ID: <12b075a10804090714l44b012e6oe35a9e471d68a059@mail.gmail.com> Hi Guys, If someone can help me in telling how can i pass arguments to python cgi script then that will be good. like if i want to pass "some argument" to my remote python script, by calling something like: http://localhost/cgi-bin/test.py?some\ argument. What is the correct way of sending arguments in this way, and how can i decode/receive them in test.py Thanks & Regards Syed -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Thu Apr 10 08:33:16 2008 From: __peter__ at web.de (Peter Otten) Date: Thu, 10 Apr 2008 14:33:16 +0200 Subject: Sorting Directories from files in a os.listdir?? References: <9354f263-b833-4845-a226-1ad3a47b1e6a@p25g2000pri.googlegroups.com> Message-ID: Scott David Daniels wrote: >> I'd like to read the filenames in a directory, but not the >> subdirectories, os.listdir() gives me everything... how do I separate >> the directory names from the filenames? Is there another way of doing >> this? >> >> Thanks! > > import os > base, files, dirs = iter(os.walk(dirname)).next() > # now files is files and dirs is directories (and base == dirname) >>> import os >>> os.listdir(".") ['fifo', 'dir', 'file'] # a fifo, a directory, and a file >>> w = os.walk(".") >>> w is iter(w) # calling iter() is a noop here True >>> w.next() ('.', ['dir'], ['fifo', 'file']) # base, dirs, files; everything that is not # a directory goes into the files list Peter From martin at v.loewis.de Fri Apr 18 20:14:02 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sat, 19 Apr 2008 02:14:02 +0200 Subject: How to print a unicode string? In-Reply-To: References: Message-ID: <4809394A.1030906@v.loewis.de> > From what I've googled, I think I need to set my locale. Not on this operating system. On Windows, you need to change your console. If it is a cmd.exe-style console, use chcp. For IDLE, changing the output encoding is not supported. If you want to output into a file, use codecs.open. If you absolutely want to output UTF-8 to the terminal even though the terminal will not be able to render it correctly, use sys.stdout = codecs.getwriter("UTF-8")(sys.stdout) HTH, Martin From sn at sncs.se Mon Apr 14 22:38:56 2008 From: sn at sncs.se (Sverker Nilsson) Date: Mon, 14 Apr 2008 19:38:56 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> Message-ID: <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> On Apr 15, 3:50 am, "Gabriel Genellina" wrote: > En Mon, 14 Apr 2008 22:02:38 -0300, Sverker Nilsson escribi?: > > > I tried out py3k on my project,http://guppy-pe.sf.net > > And what happened? > I've seen that your project already supports Python 2.6 so the migration > path to 3.0 should be easy. > > -- > Gabriel Genellina 2.6 was no big deal, It was an annoyance that they had to make 'as' a reserved word. Annoyances were also with 2.4, and 2.5. No big problems, I could make guppy backwards compatible to 2.3. But that seems not to be possible with Python 3.x ... it is a MUCH bigger change. And it would require a fork of the code bases, in C, Guido has written tha or to sprinkle with #ifdefs. Would not happen soon for me. It takes some work anyways. Do you volunteer, Guido van Rossum? :-) It's not exactly easy. Perhaps not very hard anyways. But think of 1000's of such projects. How many do you think there are? I think many. How many do yo think care? I think few. When it has been the fuzz with versions before, then I could have the same code still work with older versions. But now it seems I have to fork TWO codes. It's becoming too much. Think of the time you could write a program in C or even C++ and then it'll work. How do you think eg writers of bash or other unix utilities come along. Do they have to rewrite their code each year? No, it stays. And they can be happy about that, and go on to other things. Why should I have to think about staying compatible with the newest fancy Python all the time? NO -- but the answer may be, they don't care, though the others (C/C++, as they rely on) do. :-( Sverker From jason.scheirer at gmail.com Tue Apr 1 16:50:25 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Tue, 1 Apr 2008 13:50:25 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> Message-ID: <3bc57bca-febe-4f2e-a990-407c9904c810@c26g2000prf.googlegroups.com> On Apr 1, 1:40 pm, Aaron Watters wrote: > I've been poking around the world of object-relational > mappers and it inspired me to coin a corellary to the > the famous quote on regular expressions: > > "You have objects and a database: that's 2 problems. > So: get an object-relational mapper: > now you have 2**3 problems." > > That is to say I feel that they all make me learn > so much about the internals and features of the > O-R mapper itself that I would be better off rolling > my own queries on an as-needed basis without > wasting so many brain cells. > > comments? > > -- Aaron Watters > > ===http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=mild+exponenti... You're going to have to learn how any of the OR mappers work to get anything reasonable out of them, and you are going to need to commit and invest the time to learn how one works. I would argue that you should try making a prototype using one or two OR mappers (or just use SQLAlchemy/Elixir and be done with it) with your existing database and see which most efficiently does what you need it to. If you get to the point where the queries are getting too complex to reasonably manage as python code, then yeah, use raw SQL because that is what it's good for. Most OR mappers will allow you to sprinkle in raw SQL as needed. I think it's natural to be paralyzed by all the choices you have, but just start writing some code and go from there. From leoniaumybragg at gmail.com Sat Apr 26 06:59:04 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:59:04 -0700 (PDT) Subject: windows xp sp2 activation crack Message-ID: windows xp sp2 activation crack http://cracks.00bp.com F R E E C R A C K S From istvan.albert at gmail.com Wed Apr 23 21:56:27 2008 From: istvan.albert at gmail.com (Istvan Albert) Date: Wed, 23 Apr 2008 18:56:27 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> <426812d7-c217-4bfc-81b0-47ba0638a650@k13g2000hse.googlegroups.com> Message-ID: <74415ef0-e395-4a31-90eb-e2645a65d464@e39g2000hsf.googlegroups.com> On Apr 23, 2:08 pm, Bob Woodham wrote: > x = x++; > > has unspecified behaviour in C. That is, it is not specified > whether the value of x after execution of the statement is the > old value of x or one plus the old value of x. unspecified means that the result could be anything: old value, old value+1, -2993882, "trallalla", core dump, stack overflow etc... in Java the behavior is specified, but many might find the result counterintuitive: int x = 0; x = x++; System.out.println(x); prints 0, if I recall it correctly the ++ mutates after the assignment takes place, therefore it increments the old value that then summarily discarded. i. From gagsl-py2 at yahoo.com.ar Sun Apr 20 14:53:06 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 15:53:06 -0300 Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B80B5.1050500@cheimes.de> <87myno2yma.fsf@physik.rwth-aachen.de> Message-ID: En Sun, 20 Apr 2008 15:02:37 -0300, Torsten Bronger escribi?: > Gabriel Genellina writes: >> En Sun, 20 Apr 2008 14:43:17 -0300, Christian Heimes >> escribi?: >>> Gabriel Genellina schrieb: >>> >>>> Apart from what everyone has already said, consider that >>>> FreqDist may import other modules, store global state, create >>>> other objects... whatever. Pure python code should not have any >>>> memory leaks (if there are, it's a bug in the Python >>>> interpreter). Not-carefully-written C extensions may introduce >>>> memory problems. >>> >>> Pure Python code can cause memory leaks. No, that's not a bug in >>> the interpreter but the fault of the developer. For example code >>> that messes around with stack frames and exception object can >>> cause nasty reference leaks. >> >> Ouch! >> May I assume that code that doesn't use stack frames nor stores >> references to exception objects/tracebacks is safe? > > Circular referencing is no leaking on the C level but in a way it is > memory leaking, too. The garbage collector will eventually dispose of the cycle, unless you use __del__. Of course it's better if the code itself breaks the cycle when it's done using the objects. The above comment about stack frames and exceptions does not refer to this situation, I presume. -- Gabriel Genellina From aaron.watters at gmail.com Tue Apr 29 16:35:47 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Tue, 29 Apr 2008 13:35:47 -0700 (PDT) Subject: Cookie Confusion - How to Set a Cookie References: <588d6a6c-0080-48a4-b768-e2c5ef551790@s50g2000hsb.googlegroups.com> Message-ID: <94d81004-fc6d-4ff9-9500-143864a6d7a7@f63g2000hsf.googlegroups.com> > Thanks for the code, Aaron. I will give it a try. > > I've been reading some more about cookielib and am not sure whether I > should use Cookie or cookielib. This is what I want to do: a user is > going to login. Upon a successful login, I want to write their name > and date/time of visit to a cookie file. Which is the correct python > module to use? Cookie does parsing and generation of cookie strings for server-side applications like your CGI script. The cookielib module is designed for either implementing a client like a web browser or emulating a client/browser (for web scraping, for example). I think you want to use Cookie. The distinction could be made clearer in the docs, imho. Also, when you say "write the cookie file" I think you mean "store the cookie to the client browser". This should happen automatically when you send the cookie header to the client correctly (if the client is configured to cooperate). -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=default+does+nothing From martin at v.loewis.de Thu Apr 24 04:21:32 2008 From: martin at v.loewis.de (=?ISO-8859-9?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Thu, 24 Apr 2008 10:21:32 +0200 Subject: [Python-Dev] annoying dictionary problem, non-existing keys In-Reply-To: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> Message-ID: <4810430C.5020709@v.loewis.de> > this is very annoying. Posting to so many lists is even more annoying. You might not get a single helpful answer just because people are so frustrated by this behavior. Regards, Martin From lists at cheimes.de Wed Apr 23 08:58:00 2008 From: lists at cheimes.de (Christian Heimes) Date: Wed, 23 Apr 2008 14:58:00 +0200 Subject: Subprocess module In-Reply-To: <5213E58D85BC414998FA553C701E386C0EDD125B52@SGBD012511.dlrmail.ad.delarue.com> References: <5213E58D85BC414998FA553C701E386C0EDD125B52@SGBD012511.dlrmail.ad.delarue.com> Message-ID: <480F3258.1010801@cheimes.de> Dominique.Holzwarth at ch.delarue.com schrieb: > Hello all > > I want to convert a tex file into a pdf by using pdflatex. For that, I thought the 'subprocess' module might be a good option. My code doesn't work at all tho: > > Import os, subprocess > > def main(): > scriptpath = os.path.dirname(__file__) > > p = subprocess.Popen("pdflatex --include-directory=%s --output-directory=%s/output --aux-directory=%s/temp --interaction=nonstopmode myFile.tex" > % (scriptpath, scriptpath, scriptpath), > stdin=subprocess.PIPE, > stdout=subprocess.PIPE, > stderr=subprocess.PIPE, > shell=True, > cwd=scriptpath) > (child_stdin, > child_stdout, > child_stderr) = (p.stdin, p.stdout, p.stderr) > print 'stdin' > print child_stdin > print 'stdout' > print child_stdout > print 'stderr' > print child_stderr > > When I run that code I get the following printouts: > > stdin > ', mode 'wb' at 0x009E7968> > stdout > ', mode 'rb' at 0x009E7A40> > stderr > ', mode 'rb' at 0x009E79F8> > Done The pdflatex job stales when the standard stream buffers are full. Why do you need stdin anyway? The community method should do the trick for you: out, err = p.communicate() I also suggest you use the form ["pdflatex", "--include-directory="+scriptpath ...] instead of a single string + shell=True. Christian From gagsl-py2 at yahoo.com.ar Thu Apr 3 18:44:16 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 19:44:16 -0300 Subject: Bug in shlex?? References: Message-ID: En Thu, 03 Apr 2008 19:20:59 -0300, samslists at gmail.com escribi?: > I'm trying to use shlex.split to simulate what would happen in the > shell. The docs say that it should be as close as possible to the > posix shell parsing rules. > > If you type the following into a posix compliant shell > > echo '\?foo' > > you get back: > \?foo > > (I've tested this in dash, bash and zsh---all give the same results.) > > Now here's what happens in python: > > Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> import shlex >>>> shlex.split("'\?foo'") > ['\\?foo'] >>>> > > I think this is a bug? Or am I just misunderstanding? The result is a list containing a single string. The string contains 5 characters: a single backslash, a question mark, three letters. The backslash is the escape character, as in '\n' (a single character, newline). A backslash by itself is represented (both by repr() and in string literals) by doubling it. If you print the value, you'll see a single \: print shlex.split("'\?foo'")[0] -- Gabriel Genellina From bockman at virgilio.it Tue Apr 29 04:32:48 2008 From: bockman at virgilio.it (bockman at virgilio.it) Date: Tue, 29 Apr 2008 01:32:48 -0700 (PDT) Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> Message-ID: <16c06038-2421-478e-ba28-8131f7d552d8@b1g2000hsg.googlegroups.com> On 27 Apr, 12:27, Terry wrote: > Hello! > > I'm trying to implement a message queue among threads using Queue. The > message queue has two operations: > PutMsg(id, msg) # ?this is simple, just combine the id and msg as one > and put it into the Queue. > WaitMsg(ids, msg) # this is the hard part > > WaitMsg will get only msg with certain ids, but this is not possible > in Queue object, because Queue provides no method to peek into the > message queue and fetch only matched item. > > Now I'm using an ugly solution, fetch all the messages and put the not > used ones back to the queue. But I want a better performance. Is there > any alternative out there? > > This is my current solution: > > ? ? def _get_with_ids(self,wait, timeout, ids): > ? ? ? ? to = timeout > ? ? ? ? msg = None > ? ? ? ? saved = [] > ? ? ? ? while True: > ? ? ? ? ? ? start = time.clock() > ? ? ? ? ? ? msg =self.q.get(wait, to) > ? ? ? ? ? ? if msg and msg['id'] in ids: > ? ? ? ? ? ? ? ? break; > ? ? ? ? ? ? # not the expecting message, save it. > ? ? ? ? ? ? saved.append(msg) > ? ? ? ? ? ? to = to - (time.clock()-start) > ? ? ? ? ? ? if to <= 0: > ? ? ? ? ? ? ? ? break > ? ? ? ? # put the saved messages back to the queue > ? ? ? ? for m in saved: > ? ? ? ? ? ? self.q.put(m, True) > ? ? ? ? return msg > > br, Terry Wy put them back in the queue? You could have a defaultdict with the id as key and a list of unprocessed messages with that id as items. Your _get_by_ids function could first look into the unprocessed messages for items with that ids and then look into the queue, putting any unprocessed item in the dictionary, for later processing. This should improve the performances, with a little complication of the method code (but way simpler that implementing your own priority-based queue). Ciao ----- FB From kenneth.m.mcdonald at sbcglobal.net Tue Apr 22 14:36:27 2008 From: kenneth.m.mcdonald at sbcglobal.net (Kenneth McDonald) Date: Tue, 22 Apr 2008 13:36:27 -0500 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. Message-ID: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> Sadly. Thanks, Ken From needin4mation at gmail.com Tue Apr 29 13:16:08 2008 From: needin4mation at gmail.com (jmDesktop) Date: Tue, 29 Apr 2008 10:16:08 -0700 (PDT) Subject: Simple import question about mac osx Message-ID: Hi, I have this code (learning from Core Python, Chun's book), module named chap2.py. class FooClass(object): version=0.1 def __init__(self, nm='John Doe'): self.name=nm print 'Created a class instance for ', nm def showname(self): print 'Your name is', self.name print 'My name is', self.__class__.__name__ On Windows, if I compile this and then in the python interpreter type: >>> import chap2 >>> foo1=FooClass() Created a class instance for John Doe >>> If I do the same think on my Mac OS X 10.5.2 NameError: name 'FooClass' is not defined. I thought it was the path and did export PATH=$PATH:/mypath/ topythoncode but it did not help. What am I doing wrong? Thank you. From gagsl-py2 at yahoo.com.ar Thu Apr 3 22:08:46 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 23:08:46 -0300 Subject: Is there an official way to add methods to an instance? References: <0db32c33-04a9-4993-9d5a-a617c575a4d7@u36g2000prf.googlegroups.com> Message-ID: En Thu, 03 Apr 2008 22:43:30 -0300, Roger Miller escribi?: > On Apr 3, 2:57 pm, Brian Vanderburg II > wrote: >> >> I've checked out some ways to get this to work. I want to be able to >> add a new function to an instance of an object. I've tested two >> different methods that cause problems with 'deleting'/garbage collection >> (__del__ may never get called), but implemented one sort of hackishly >> maybe that works find. I'm wondering if there is more of an official way >> than mine. >> > > Maybe I'm missing something, but the boring old straightforward > approach works for me: > > class A: > def __del__(self): > print "Deleting" > > def f(x): > print x > > a = A() > a.f = f > a.f(42) > del a This doesn't create an instance method. You can't access `a` (as `self`) from inside f. -- Gabriel Genellina From pyth0nc0d3r at gmail.com Tue Apr 8 20:31:59 2008 From: pyth0nc0d3r at gmail.com (Lamonte Harris) Date: Tue, 8 Apr 2008 19:31:59 -0500 Subject: How would I go about checking if urllib2 timed out? Message-ID: Can someone explain to me how I would do error handling to check if the current proxy timed out on when trying to connect to the web page: import urllib2 proxy=urllib2.ProxyHandler({'http':'24.232.167.22:80'}) opener=urllib2.build_opener(proxy) f=opener.open('http://www.whatismyipaddress.com' ) print f.read() If someone could help me, thank you very much, I'm still very new to error handling -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Sun Apr 6 17:55:52 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 06 Apr 2008 23:55:52 +0200 Subject: How to create an exe-file? In-Reply-To: <8da70474-6ade-4515-8346-8f02a04ff24e@b9g2000prh.googlegroups.com> References: <311a216f-5366-47c5-86a7-431dd23ced3e@j1g2000prb.googlegroups.com> <8da70474-6ade-4515-8346-8f02a04ff24e@b9g2000prh.googlegroups.com> Message-ID: skanemupp at yahoo.se wrote: > a good thing about python is the portability though. but u cant make > an exe that can be used on mac too, ie one exe fpr both? you can create a portable python archive, but EXE files are windows only. > if i want to make an exe for mac, what do i need? see the second link I posted for the answer. From the.doag at gmail.com Thu Apr 24 00:21:26 2008 From: the.doag at gmail.com (Daniel) Date: Wed, 23 Apr 2008 21:21:26 -0700 (PDT) Subject: Parsing tuple from string? References: Message-ID: On Apr 23, 4:22 pm, George Sakkis wrote: > On Apr 23, 6:24 pm, Daniel wrote: > > > I have a list of strings, which I need to convert into tuples. If the > > string is not in python tuple format (i.e. "('one', 'two')", "("one", > > 'two')", etc.), then I can just make it a 1-tuple (i.e. return > > (string,) ). If it is in python tuple format, I need to parse it and > > return the appropriate tuple (it's ok to keep all tuple elements as > > strings). > > > I think eval() will work for this, but I don't know what will be in > > the string, so I don't feel comfortable using that. > > Check out one of the safe restricted eval recipes, e.g.http://preview.tinyurl.com/6h7ous. > Thank you very much! > HTH, > George From umpsumps at gmail.com Sat Apr 26 17:39:13 2008 From: umpsumps at gmail.com (umpsumps at gmail.com) Date: Sat, 26 Apr 2008 14:39:13 -0700 (PDT) Subject: learning with python question (HtTLaPP) References: <98acecbd-9de2-4ebf-927b-ac6bc1fbc3fd@b5g2000pri.googlegroups.com> Message-ID: <53d6254f-895f-48fb-8ab9-3929c403f11b@v23g2000pro.googlegroups.com> Eric, Thank you for helping. Is the way I wrote the function inherently wrong? What I wrote returns the sequence, however I'm trying to make the output match for the letters in the string entered, not necessarily the string sequence. For example if I search words.txt with my function for 'uzi' I get this: >>> searchtxt('uzi') gauziest gauzier fuzing fuzils fuzil frouziest frouzier defuzing 113809 lines searched.. 8 uzi words present Only the sequence shows up 'uzi'. I don't get words like 'unzip' or 'Zurich' . I've only barely started on invocation and maybe writing something like I'm describing is above what level I'm currently at. On Apr 26, 2:20?pm, "Eric Wertman" wrote: > > ?Python Programmer" and have been trying to write a script that checks > > ?'words.txt' for parameters (letters) given. ?The problem that is the i > > ?can only get results for the exact sequence of parameter 'letters'. > > The "re" module comes to mind: > > text = open('words.txt','r').read() > letters = 'sequence' > results = re.findall(letters,text) > > result_count = len(results) > > # one word per line: > for result in results : > ? ? print result > > # one line > print ' '.join(results) > > of course, you may need to invest a little time in regular expression > syntax to get exactly what you want, but I think you'll find that's > not wasted effort, as this is pretty standard and used in a lot of > other places. From bronger at physik.rwth-aachen.de Wed Apr 9 05:36:44 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 09 Apr 2008 11:36:44 +0200 Subject: Coping with cyclic imports References: <87bq4knmax.fsf@physik.rwth-aachen.de> Message-ID: <87iqyr9xoz.fsf@physik.rwth-aachen.de> Hall?chen! Jeffrey Froman writes: > [...] > > Cyclic imports are not a problem by themselves, but cyclic > definitions are. Thus: > > # a.py > import b > x = 1 > > # b.py > import a > x = 2 > > works fine, but: > > # a.py > import b > x = 1 > > # b.py > import a > x = a.x + 1 # circular definition > > does not. Okay, thanks, but after some own investigations, I think that the clever bit is somewhere else. The above works if you call a.py as the main program, because then a.py is not yet loaded as such when "import a" is executed. So a.py gets executed twice, once by "import a", and once after the whole import thing as the main program. Actually, there seems to be only one case that is dangerous: If you import a module cyclicly, it may be that you only get its name imported but this name points to a yet empty module. Then, you must not refer to things in it while the current module itself is executed. But you may well refer to things in it from functions or methods, because they are called much later, when the whole bunch of modules is already completely loaded and populated. Consequently, "from a import x" also fails if a is incomplete. So, the last question is: Under which circumstances does this happen? It happens when you import a module which imports (directly or indictly) the current module and which comes before the current module in the import order while the program runs. If you don't rely on imported things at top-level code (but only in functions and methods which in turn must not be called from the top-level), everything is fine. Can anybody confirm that this is correct? Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From kay.schluehr at gmx.net Sat Apr 5 11:55:04 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 5 Apr 2008 08:55:04 -0700 (PDT) Subject: Weird scope error References: Message-ID: <7b2a52ad-f036-46bb-b2fb-8eca8dbf7081@b5g2000pri.googlegroups.com> On 5 Apr., 17:27, Rory McKinley wrote: > Hi > > I am trying to use the TidyHTMLTreeBuilder module which is part of > elementtidy, but I am getting what appears to be some sort of scope > error and it is scrambling my n00b brain. > > The module file (TidyHTMLTreeBuilder.py) tried to import ElementTree by > doing the following: > > from elementtree import ElementTree > > This bombed, so after a bit of poking around I replaced it with : > > from xml.etree import ElementTree > > This appears to have worked. However, when I try and parse a file using > the function : > TidyHTMLTreeBuilder.parse('weather_ct.html') > > I receive the following error: > > Traceback (most recent call last): > File "", line 1, in > File > "/usr/lib/python2.5/site-packages/elementtidy/TidyHTMLTreeBuilder.py", > line 107, in parse > return ElementTree.parse(source, TreeBuilder()) > NameError: global name 'ElementTree' is not defined > > The code producing the error is as follows: > > def parse(source): > return ElementTree.parse(source, TreeBuilder()) > > Surely, if the from... import has worked, ElementTree is in the global > scope and should therefore be accessible to the function parse? > > Can anybody help? > > THanks The problem stems from the fact that TidyHTMLTreeBuilder uses a different import path assuming that the elementtree package is found somewhere in the pythonpath e.g. in site-packages and not in the builtins. I guess this problem will be resolved when you install the elementree package again. From mattheww at chiark.greenend.org.uk Wed Apr 2 15:45:33 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 02 Apr 2008 20:45:33 +0100 (BST) Subject: plpythonu+postgrs anybody using it? References: Message-ID: Martin Marcher wrote: > My main concern is that when things start getting more complicated > that everytime a SP is called an instance of the interpreter ist > started which would be a huge slowdown, so does plpythonu run > continiously a python process or does it start one everytime a SP is > called? I'm not using plpythonu, but nobody else seems to be jumping to answer so I'll have a go. I'm fairly sure but not certain that what I say below is true. When you use PL/Python, there is no separate Python process. The Python interpreter is dynamically linked into each PostgreSQL back-end process when it first calls a PL/Python function. That means that whatever the overhead is for initialising the Python interpreter, it will be paid at most once per database connection. If you find that this overhead is too high, a connection pooling system like pgpool might help. -M- From sawilla at gmail.com Mon Apr 21 17:14:24 2008 From: sawilla at gmail.com (sawilla) Date: Mon, 21 Apr 2008 14:14:24 -0700 (PDT) Subject: module error in Vista -- works as administrator Message-ID: <815eb7f8-6f00-469d-bb15-e1d9680d9646@e39g2000hsf.googlegroups.com> First, I'm new to Python. I'm getting and error when I run Python 2.5.2 as a regular user in Vista but not when I run Python as an administrator. For example, if I type "import numpy" after I launch python from an adminstrator-privileged command window it loads fine. However, from a regular-user command window I get: >>> import numpy Traceback (most recent call last): File "", line 1, in ImportError: No module named numpy Thanks in advance for your help. Reg From deets at nospam.web.de Wed Apr 23 15:35:43 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 23 Apr 2008 21:35:43 +0200 Subject: Calling Python code from inside php In-Reply-To: <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> References: <679e9oF2mti63U1@mid.uni-berlin.de> <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> Message-ID: <679hd5F2nj6csU1@mid.uni-berlin.de> > A simple yet dangerous and rather rubbish solution (possibly more of a > hack than a real implementation) could be achieved by using a > technique described above: > > echo exec('python foo.py'); > ?> What is rubbish about that - except from the obvious cleansing of input variables that has to take place? Python has a whole module dedicated to that rubbish, called subprocess. > I would look into pyphp though. This method has so many issues > attached to it it's hardly worth bothering with. > I'm with Nick when I say why on earth are you needing to call Python > from within PHP as opposed to using only Python or only PHP? While I certainly prefer to use Python wherever I can, that does not mean that there aren't cases where legacy systems or other constraints make this impossible. If I have e.g. a type3-based website - "how on earth" should I replace that with Python (without wasting a lot of time)? Diez From michael.harris at MCC-CORP.COM Mon Apr 28 13:42:00 2008 From: michael.harris at MCC-CORP.COM (Michael Harris) Date: Mon, 28 Apr 2008 13:42:00 -0400 Subject: Automating IE 6.0 Message-ID: <81B200F0AB075D4D95DA50067247FFBFF15DB8@mcc-es1.MCC.local> I tried to use the sample code to print a webpage via ie and I get the following error: Traceback (most recent call last): File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py" , line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\ie.py", line 14, in ie.ExecWB(win32com.client.constants.OLECMDID_PRINT, win32com.client.constants.OLECMDEXECOPT_DONTPROMPTUSER) NameError: name 'win32com' is not defined I have the win32com module installed and I clicked on makepy.py and selected Microsoft Internet Controls (1.1). The code was: from win32com.client import Dispatch from time import sleep ie = Dispatch("InternetExplorer.Application") ie.Visible = 1 ie.Navigate("http://www.cnn.com" ) if ie.Busy: sleep(2) # print the current IE document without prompting the user for the printerdialog ie.ExecWB(win32com.client.constants.OLECMDID_PRINT,win32com.client.const ants .OLECMDEXECOPT_DONTPROMPTUSER) Why am I getting this error? -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrickkidd.lists at gmail.com Wed Apr 16 08:04:36 2008 From: patrickkidd.lists at gmail.com (Patrick Stinson) Date: Wed, 16 Apr 2008 06:04:36 -0600 Subject: import hooks In-Reply-To: References: <664bf2b80804151814g480eed02w739047f84d9deb6b@mail.gmail.com> Message-ID: <664bf2b80804160504x72c870d8pdbfe8105a0c5ed11@mail.gmail.com> I am defining a simple finder/loader object and adding it to sys.meta_path like this: PyRun_SimpleString("import sys; import ousiainternal; sys.meta_path = [ousiainternal.OusiaImporter]"); The following C code defines the loader object: static void MyImporter_dealloc(PyObject *self) { self->ob_type->tp_free(self); } static int MyImporter_init(MyImporter *self, PyObject *args, PyObject *kwds) { return 0; } static PyObject * MyImporter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { MyOutput *self; self = (MyOutput *)type->tp_alloc(type, 0); return (PyObject *)self; } /* Check whether we can satisfy the import of the module named by 'fullname'. Return self if we can, None if we can't. FYI: MyImporter imports modules from the local instrument. */ static PyObject * MyImporter_find_module(PyObject *obj, PyObject *args) { MyImporter *self = (MyImporter *)obj; PyObject *path = NULL; char *fullname; if (!PyArg_ParseTuple(args, "s|O", &fullname, &path)) return NULL; mod = lookup_module_in_my_app(name); //borrowed ref if(mod == NULL); { Py_INCREF(Py_None); return Py_None; } Py_INCREF(self); return (PyObject *)self; } /* Load and return the module named by 'fullname'. */ static PyObject * MyImporter_load_module(PyObject *obj, PyObject *args) { MyImporter *self = (MyImporter *)obj; PyObject *mod = NULL; char *fullname; if (!PyArg_ParseTuple(args, "s", &fullname)) return NULL; mod = lookup_module_in_my_app(name); // borrowed ref if(mod) Py_INCREF(mod); return mod; } static PyMethodDef MyImporter_methods[] = { {"find_module", MyImporter_find_module, METH_VARARGS, "find a module"}, {"load_module", MyImporter_load_module, METH_VARARGS, "load a module"}, {NULL, NULL} /* sentinel */ }; static PyTypeObject MyImporterType = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "Myinternal.MyImporter", /*tp_name*/ sizeof( MyImporter), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) MyImporter_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash */ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ "import hook for loading embedded modules", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ MyImporter_methods, /* tp_methods */ 0, //MyImporter_members, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ (initproc) MyImporter_init, /* tp_init */ 0, /* tp_alloc */ MyImporter_new, /* tp_new */ }; A simpler example that yields the same results would be this: static const char *importer_source = "import sys\n" "class Importer:\n" " def __init__(self, path):\n" " print \'Import.__init__\', path\n" " def find_module(self, fullname, path=None):\n" " print self\n" " if fullname == \'bleh\':\n" " return self\n" " def load_module(self, fullname):\n" " print self\n" " if fullname == \'bleh\':\n" " return sys\n" "sys.meta_path.append(Importer)\n"; PyRun_SimpleString(importer_source); For both examples none of the methods are called (I set breakpoints for the C functions) but a statement like "import os" or PyImport_ImportModule("traceback") don't work. Thanks for your help On Wed, Apr 16, 2008 at 12:02 AM, Gabriel Genellina wrote: > En Tue, 15 Apr 2008 22:14:18 -0300, Patrick Stinson > escribi?: > > > What's the current way to install an import hook? I've got an embedded > > app > > that has a few scripts that I want to import each other, but that are > > not in > > sys.modules. I intentionally keep them out of sys.modules because their > > names will not be unique across the app. They will, however, be unique > > between scripts that I (do* want to see each other). > > Basically, I want to return a certain module from a name-based filter. > > I've > > already written a type in C with find_module and load_module, but it > > doesn't > > seem to work when I add the type to sys.path_hooks. I wrote a simple one > > that worked just fine from a pure script file run through python.exe. > > From that description alone I can't say what's happening; you should post > some code. > Also, if your importer isn't disk-based, perhaps using sys.meta_path is > better. > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Patrick Kidd Stinson http://www.patrickkidd.com/ http://pkaudio.sourceforge.net/ http://pksampler.sourceforge.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From bg at bg.fr Tue Apr 8 11:56:01 2008 From: bg at bg.fr (Bruno GUERPILLON) Date: Tue, 8 Apr 2008 17:56:01 +0200 Subject: List open files References: <47fb8d54$0$15068$426a74cc@news.free.fr> Message-ID: <47fb968c$0$22371$426a74cc@news.free.fr> "Mike Driscoll" a ?crit dans le message de news: c62d02f7-62c4-447d-a456-261fefb8b021 at e67g2000hsa.googlegroups.com... > On Apr 8, 10:16 am, "Bruno GUERPILLON" wrote: >> Hi, >> >> I'd like, in a WIN32 environment, list all open files. >> Anyone got a clue how to do this ? >> >> Regards, >> >> Bruno. > > XP comes with a utility called OpenFiles.exe which supposedly gives > this functionality. You can use Python's subprocess command to run it > and parse its output. > > Mike Thanks for the answer Mike. Well, Openfiles.exe list only file opened vi Network. I'd like to know the local opene files list. Regards From irishhacker at gmail.com Wed Apr 16 15:47:25 2008 From: irishhacker at gmail.com (Robert) Date: Wed, 16 Apr 2008 12:47:25 -0700 (PDT) Subject: Does Python use a special home-made parser, or does it use Yacc? Message-ID: <236a2391-ac15-4910-8d47-5741256486d1@1g2000prf.googlegroups.com> Or some other pre-packaged parser tool? From tjreedy at udel.edu Mon Apr 7 17:12:19 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 7 Apr 2008 17:12:19 -0400 Subject: Problem with smtplib and py2exe References: <3ff2767a-bbd8-4e0e-bbf4-3fa72bdca5e7@8g2000hsu.googlegroups.com> Message-ID: "Kevin" wrote in message news:3ff2767a-bbd8-4e0e-bbf4-3fa72bdca5e7 at 8g2000hsu.googlegroups.com... | Hi everyone, | | I'm running Python 2.5.1 on an XP-Pro platform, with all the updates | (SP2, etc) installed. I have a program (send_file.py) that sends a | file to a service provider, using an ftp connection. The program | works properly, and I've created an 'exe' of it, using py2exe. It was | distrubuted to my user base a couple of weeks ago and seems to be | working well. None of the users have Python installed on their | machines, thus the need for an 'exe' for the program. | | I now need to add an email function to the program, to automatically | send an email to a select user list when the program is completed. | I've made the appropriate modifications to my code, and the program | works properly when I run it from Python. When I try to make an exe | out of my new program, however, I get the following error: | | Traceback (most recent call last): | File "C:/Python25/send_ftp/setup.py", line 17, in | console = [{"script": 'send_file.py'}] ) | File "C:\Python25\lib\distutils\core.py", line 168, in setup | raise SystemExit, "error: " + str(msg) I would go to that line in that file (it is in the except: part of a try: statement) and file the function call that raised the exception and ... There seems to be a DEBUG variable, which might also give more info. | SystemExit: error: command 'C:\Python25\pythonw.exe' failed with exit | status 1 | | The 'setup.py' script is the same one I used to generate the 'exe' of | the original program. The email-related code was added to my | 'send_file.py' program as a function - it's not a separate module. If | all of the changes are commented out, the py2exe function works. But | as soon as I activate even the line "import smtplib", the py2exe | process spits out the error above. | | If I put only the email portions of code in a test program, and run it | from Python, it works, but if I try make an 'exe' out of the test | program, I get the same error as above. | | Is there an inherent incompatibility between smtplib and py2exe? Does | anyone have any ideas of how I can fix this problem? tjr From hypocrite at lawyer.com Wed Apr 16 08:46:27 2008 From: hypocrite at lawyer.com (Pete Crite) Date: Wed, 16 Apr 2008 22:46:27 +1000 Subject: Python crashes consistently In-Reply-To: <66m7s3F2l8kitU1@mid.uni-berlin.de> References: <66m7s3F2l8kitU1@mid.uni-berlin.de> Message-ID: <2903FA81-F84F-418A-B73E-ED0F22828755@lawyer.com> Thanks for the quick reply, Just to clarify (sorry, I'm a bit of a command line newbie): Do you mean to install Python from the .dmg - i.e. into /usr/local/ bin? And then to install Numpy directly as well (manually, from source), then continue with the MacPorts installation of Gnumeric (i.e. into /opt/local/)? Thanks, Pete. On 16/04/2008, at 9:56 PM, Diez B. Roggisch wrote: > > Pete Crite wrote: > >> Hello, >> >> I've been trying to install Gnumeric via MacPorts recently, but I >> can't get past the installation of py25-numpy. > > You are using the wrong python version. Don't use MacPorts for > this, because > it will install a local, non-framework version of python - which > will do > you no good if you e.g. want to use any OSX-specific stuff. > > > Use the official 2.5 framework version. And then install Numpy > yourself > (which is a bit annoying I admit, as you need to install e.g. a > fortran > compiler, but it is pretty well documented) > > Diez > -- > http://mail.python.org/mailman/listinfo/python-list > From gagsl-py2 at yahoo.com.ar Wed Apr 16 15:21:45 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 16:21:45 -0300 Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <86063f29-21a8-4d5b-a374-cee0723e0852@a22g2000hsc.googlegroups.com> <6894d371-3c3e-4c24-b7ec-4c254ed24afe@24g2000hsh.googlegroups.com> Message-ID: En Wed, 16 Apr 2008 13:09:05 -0300, Aaron Watters escribi?: > On Apr 16, 11:15 am, Gabriel Genellina wrote: >> On 16 abr, 09:56, Aaron Watters wrote: >> >> > In my opinion python's adherence to backwards compatibility >> > has been a bit mythological anyway -- many new python versions >> > have broken my old code for no good reason. This is an irritant >> > when you have thousands of users out there who suddenly drop >> > your code, blame you and python, and move on to use something else. > Yes I mean it. Actually I was unaware > of/forgot reconvert, but it doesn't > matter because it doesn't solve the problem of code I wrote that > has long ago escaped into the wild no longer working. There are > other examples too, having to do with things as simple as a name > change in a standard module that broke old > code of mine for what I regard as silly cosmetic reasons. Yes, there was some cases like that in the past, but I think that now there is a strict policy for backwards compatibility, including at least one .n release with deprecation warnings before removing old things. Anyway, sometimes incompatible changes appear in the standard library - perhaps because less developers are looking at them in detail? > I hope you are right about py3k conversions being pain > free and routine. I'm suspicious about it however. Well, I would not say "pain free", but certainly it's not as terrible as some people imply... -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Sun Apr 13 15:49:51 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 13 Apr 2008 16:49:51 -0300 Subject: Controlling copying and pickling of objects written in C References: <3_idnfMhL8pbD5zVnZ2dnUVZ_tPinZ2d@speakeasy.net> Message-ID: En Sun, 13 Apr 2008 01:57:42 -0300, Adam Bregenzer escribi?: > I am writing an extension and have "hidden" data included in the object's > C structure that is not visible to python. I am unsure what would happen > to that data if the python object were copied or pickled and would prefer > to raise an exception whenever code tries to copy/deep copy/pickle or > marshal the object since it would not make sense. Where would I look to > control that? You could raise an exception in __getstate__ - that would make pickle fail, and probably copy too but I'm not sure of that. -- Gabriel Genellina From leoniaumybragg at gmail.com Sat Apr 26 06:59:33 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:59:33 -0700 (PDT) Subject: exelon patch Message-ID: <1c7ff1bf-3d6a-4705-95c7-4e6627014bf2@8g2000hse.googlegroups.com> exelon patch http://cracks.00bp.com F R E E C R A C K S From mal at egenix.com Fri Apr 4 06:19:45 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Fri, 04 Apr 2008 12:19:45 +0200 Subject: Unicode conversion problem (codec can't decode) In-Reply-To: References: Message-ID: <47F600C1.7050404@egenix.com> On 2008-04-04 08:18, Jason Scheirer wrote: > On Apr 3, 9:35 pm, "Eric S. Johansson" wrote: >> I'm having a problem (Python 2.4) converting strings with random 8-bit >> characters into an escape form which is 7-bit clean for storage in a database. If you don't want to process the 7-bit form in any way, there are a couple of encodings which you could use: >> Here's an example: >> >> body = meta['mini_body'].encode('unicode-escape') >> >> when given an 8-bit string, (in meta['mini_body']), the code fragment above >> yields the error below. >> >> 'ascii' codec can't decode byte 0xe1 in position 13: ordinal not in range(128) Try this: body = meta['mini_body'].decode('latin-1').encode('unicode-escape') mini_body = body.decode('unicode-escape').encode('latin-1') or this: body = meta['mini_body'].decode('latin-1').encode('utf-7') mini_body = body.decode('utf-7').encode('latin-1') If all you need is the 7-bit form, you're probably better of with a base64 encoding: body = meta['mini_body'].encode('base64') mini_body = body.decode('base64') >> the string that generates that error is: >> >>
Reduce Wh?t You Owe by 50%. Get out of debt today!
Reduuce Interest & >> |V|onthlyy Payme?ts Easy, we will show you how..
Freee Quote in 10 >> Min.
http://www.freefromdebtin.net.cn Looks like spam :-) -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 04 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From mnordhoff at mattnordhoff.com Fri Apr 25 09:28:49 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Fri, 25 Apr 2008 13:28:49 +0000 Subject: Is 2006 too old for a book on Python? In-Reply-To: References: Message-ID: <4811DC91.9050406@mattnordhoff.com> jmDesktop wrote: > Hi, I wanted to buy a book on Python, but am concerned that some of > them are too old. One I had come to after much research was Core > Python by Wesley Chun. I looked at many others, but actually saw this > one in the store and liked it. However, it is from 2006. I know > there is free documentation and Dive Into Python. I just liked the > one in question and was hoping for thoughts on the age of it. I am > using Python 2.5.x and don' t know how different 2.3, 2,4 is from it. > > Thank you. Python 2.x releases maintain backwards compatibility. There are nice features that have come since 2.3, but it's not like it's a different language. You could learn from a slightly old book, then do some research to find out what you missed. ('with' statement, ternary operator, smaller things in the stdlib. Maybe generators? What else?) Now, Python 3 will break backwards compatibility and make more significant changes than usual, but it will still be basically the same language, so the same thing applies. And anyway, it won't be very relevant for a few years. -- From paddy3118 at googlemail.com Tue Apr 1 01:27:39 2008 From: paddy3118 at googlemail.com (Paddy) Date: Mon, 31 Mar 2008 22:27:39 -0700 (PDT) Subject: standard input, for s in f, and buffering References: <65bg55F2esfc1U3@mid.uni-berlin.de> Message-ID: On Mar 31, 11:47 pm, Jorgen Grahn wrote: > On 31 Mar 2008 06:54:29 GMT, Marc 'BlackJack' Rintsch wrote: > > > > > On Sun, 30 Mar 2008 21:02:44 +0000, Jorgen Grahn wrote: > > >> I realize this has to do with the extra read-ahead buffering documented for > >> file.next() and that I can work around it by using file.readline() > >> instead. > > >> The problem is, "for s in f" is the elegant way of reading files line > >> by line. With readline(), I need a much uglier loop. I cannot find a > >> better one than this: > > >> while 1: > >> s = sys.stdin.readline() > >> if not s: break > >> print '####', s , > > >> And also, "for s in f" works on any iterator f -- so I have to choose > >> between two evils: an ugly, non-idiomatic and limiting loop, or one > >> which works well until it is used interactively. > > >> Is there a way around this? Or are the savings in execution time or > >> I/O so large that everyone is willing to tolerate this bug? > > > You can use ``for line in lines:`` and pass ``iter(sys.stdin.readline,'')`` > > as iterable for `lines`. > > Thanks. I wasn't aware that building an iterator was that easy. The > tiny example program then becomes > > #!/usr/bin/env python > import sys > > f = iter(sys.stdin.readline, '') > for s in f: > print '####', s , > > It is still not the elegant interface I'd prefer, though. Maybe I do > prefer handling file-like objects to handling iterators, after all. > > By the way, I timed the three solutions given so far using 5 million > lines of standard input. It went like this: > > for s in file : 1 > iter(readline, ''): 1.30 (i.e. 30% worse than for s in file) > while 1 : 1.45 (i.e. 45% worse than for s in file) > Perl while(<>) : 0.65 > > I suspect most of the slowdown comes from the interpreter having to > execute more user code, not from lack of extra heavy input buffering. > > /Jorgen > > -- > // Jorgen Grahn \X/ snipabacken.se> R'lyeh wgah'nagl fhtagn! Hi Juergen, >From the python manpage: -u Force stdin, stdout and stderr to be totally unbuffered. On systems where it matters, also put stdin, stdout and stderr in binary mode. Note that there is internal buffering in xreadlines(), readlines() and file-object iterators ("for line in sys.stdin") which is not influenced by this option. To work around this, you will want to use "sys.stdin.readline()" inside a "while 1:" loop. Maybe try adding the python -u option? Buffering is supposed to help when processing large amounts of I/O, but gives the 'many lines in before any output' that you saw originally. If the program is to be mainly used to handle millions of lines from a pipe or file, then why not leave the buffering in? If you need both interactive and batch friendly I/O modes you might need to add the ability to switch between two modes for your program. - Paddy. From awaretek at gmail.com Sun Apr 27 14:36:45 2008 From: awaretek at gmail.com (Ron Stephens) Date: Sun, 27 Apr 2008 11:36:45 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <1d8af3e3-c287-4d5b-a481-ca8c650f732f@s33g2000pri.googlegroups.com> <472056db-8812-42b2-a4fe-3a2accd7571b@8g2000hse.googlegroups.com> Message-ID: John, This is very interesting! Please do make this available. I love PythonCard, but I am doing mainly web programming these days. I will mention this on my next podcast. Can you do a slider? Ron Stephens Python411 www.awaretek.com/python/index.html From gagsl-py2 at yahoo.com.ar Mon Apr 14 00:17:21 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 14 Apr 2008 01:17:21 -0300 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <47ff8489$0$6841$2d805a3e@textnews.eweka.nl> <48010fe5$0$6840$2d805a3e@textnews.eweka.nl> Message-ID: En Sat, 12 Apr 2008 15:38:22 -0300, Michel Bouwmans escribi?: > Gabriel Genellina wrote: >> En Fri, 11 Apr 2008 11:31:42 -0300, Michel Bouwmans >> escribi?: >>> Gabriel Genellina wrote: >> >>>> Another annoying thing with the Qt license is that you have >>>> to choose it >>>> at the very start of the project. You cannot developsomething using >>>> the >>>> open source license and later decide to switch to thecommercial >>>> licence and buy it. >>> >>> Unless you're a company with a risk of being checked forlegal software >>> etc., you can always ignore that allthough not very legal. >> >> I just ignore Qt itself. > > Then you're ignorant. What do you prefer than? Yes I am. But that doesn't change the fact that I don't like Qt, I don't like Qt license, my company doesn't use Qt and probably will never use it, and what we do prefer is not your business. -- Gabriel Genellina From jesse.k.rosenthal at gmail.com Mon Apr 7 12:52:41 2008 From: jesse.k.rosenthal at gmail.com (jesse.k.rosenthal at gmail.com) Date: Mon, 7 Apr 2008 09:52:41 -0700 (PDT) Subject: pylirc question: clearing the queue Message-ID: <19045397-5cff-4eae-8684-43f2eddd0405@59g2000hsb.googlegroups.com> Hi all, Is there a way in the pylirc module to either (a) get it to stop listening for a period of time, or (b) clear the queue of any stored up commands? I have a script that starts mplayer, and I use my remote while I'm running mplayer. The shell script waits (subrpocess.Popen.wait()) for the mplayer process to complete, but then it always runs through all the keypresses I've been sending mplayer. So i would like it to either stop listening until I give it a certain command, or to simply clear the queue (I could tell it to that after I return from wait()). Any ideas? Thanks, Jesse From landerdebraznpc at gmail.com Mon Apr 28 03:54:22 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:54:22 -0700 (PDT) Subject: crack and digichat Message-ID: crack and digichat http://crack.cracksofts.com From hdante at gmail.com Sat Apr 26 15:03:40 2008 From: hdante at gmail.com (hdante) Date: Sat, 26 Apr 2008 12:03:40 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> Message-ID: On Apr 26, 1:15?pm, n00m wrote: > fgets() from C++ iostream library??? > fgets is part of the standard C++ library and it lives in the std namespace. > I guess if I'd came up with "Python reads SLOWER than C" > I'd get another (not less) smart explanation "why it's so". From bj_666 at gmx.net Sun Apr 13 11:42:58 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 13 Apr 2008 15:42:58 GMT Subject: How to Choose an Unlimited Web Hosting for free References: <02d391b5-f72f-4f99-8f40-dbc304aa22fe@q24g2000prf.googlegroups.com> <4802276d$0$36379$742ec2ed@news.sonic.net> Message-ID: <66eo01F2ju94lU1@mid.uni-berlin.de> On Sun, 13 Apr 2008 08:42:52 -0700, John Nagle wrote: > Unlimited Free Domain & Web Hosting wrote: >> How to Choose an Unlimited Web Hosting >> 1) Visit www.xxxxxxx.com to get domain and hosting >> 2) Unlimited Bandwidth ,this mean unlimited data transmission for your >> client access. >> 2) Unlimited Space , you can upload file for unlimited . >> 3) Unlimited Email , many of email account can created . >> 5) SSL Security , used SSL / HTTPS to protect your web . >> 6) LINUX , WINDOWS and MAC , can access form many operating system. > > This is some spamming "reseller" for Xxxx Hosting. And now you've spread the spam to those whose news servers filtered the original message. Thanks... Ciao, Marc 'BlackJack' Rintsch From martin at v.loewis.de Sun Apr 20 16:46:02 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 20 Apr 2008 22:46:02 +0200 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480b8d58$0$26996$9b622d9e@news.freenet.de> Message-ID: <480bab8a$0$26764$9b622d9e@news.freenet.de> > http://trac.edgewall.org/ contains at least one example of a reference > leak. It's holding up the release of 0.11 for a while. *scnr* All my investigations on possible memory leaks in Trac have only confirmed that Python does _not_, I repeat, it does *NOT* leak any memory in Trac. Instead, what appears as a leak is an unfortunate side effect of the typical malloc implementation which prevents malloc from returning memory to the system. The memory hasn't leaked, and is indeed available for further allocations by trac. > The problem is also covered by the docs at > http://docs.python.org/dev/library/sys.html#sys.exc_info Ah, but that's not a *reference* leak. If Python (or an extension module) contains a reference leak, that's a bug. A reference leak is a leak where the reference counter is increased without ever being decreased (i.e. without the application having a chance to ever decrease it correctly). In this case, it's just a cyclic reference, which will get released whenever the garbage collector runs next, so it's not a memory leak. Regards, Martin From s0suk3 at gmail.com Thu Apr 17 12:56:24 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 09:56:24 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> Message-ID: <42402158-0b16-42e2-b7a0-9d9a15e8196d@24g2000hsh.googlegroups.com> On Apr 17, 11:44 am, Gary Herron wrote: > But. *What's the point* of doing it this way. I see 14 variables > being assigned a value, but I don't see the value, they are getting. > Reading this bit if code provides no useful information unless I'm > willing to scan down the file until I find the end of this mess. And in > that scanning I have to make sure I don't miss the one single line that > does not end in a backslash. (Your ellipsis conveniently left out the > *one* important line needed to understand what this code is doing, but > even if you had included it, I'd have to scan *all* lines to understand > what a single value is being assigned. > > There is *no way* you can argue that code is clearer than this: > > # General header fields > Cache_Control = None > Connection = None > Date = None > Pragma = None class RequestHeadersManager: # General header fields Cache_Control = \ Connection = \ Date = \ Pragma = \ Trailer = \ Transfer_Encoding = \ Upgrade = \ Via = \ Warning = \ # Request header fields Accept = \ Accept_Charset = \ Accept_Encoding = \ Accept_Language = \ Authorization = \ Expect = \ From = \ Host = \ If_Match = \ If_Modified_Since = \ If_None_Match = \ If_Range = \ If_Unmodified_Since = \ Max_Forwards = \ Proxy_Authorization = \ Range = \ Referer = \ TE = \ User_Agent = \ # Entity header fields Allow = \ Content_Encoding = \ Content_Language = \ Content_Length = \ Content_Location = \ Content_MD5 = \ Content_Range = \ Content_Type = \ Expires = \ Last_Modified = \ None def __init__(self, headers, linesep): headersDict = parse_headers(headers, linesep) for header in headersDict.keys(): charsLength = len(header) if charsLength == 10: if header == "connection": self.Connection = headersDict["connection"] elif header == "user-agent": self.User_Agent = headersDict["user-agent"] elif charsLength == 15: if header == "accept-encoding": self.Accept_Encoding = headersDict["accept- encoding"] elif header == "accept-language": self.Accept_Language = headersDict["accept- language"] elif charsLength == 17: if header == "if-modified-since": self.If_Modified_Since = headersDict["if-modified- since"] elif header == "transfer-encoding": self.Transfer_Encoding = headersDict["transfer- encoding"] elif charsLength == 2: if header == "te": self.TE = headersDict["te"] elif charsLength == 3: if header == "via": self.Via = headersDict["via"] elif charsLength == 4: if header == "date": self.Date = headersDict["date"] elif header == "host": self.Host = headersDict["host"] elif header == "from": self.From = headersDict["from"] elif charsLength == 5: if header == "allow": self.Allow = headersDict["allow"] elif header == "range": self.Range = headersDict["range"] elif charsLength == 6: if header == "accept": self.Accept = headersDict["accept"] elif header == "expect": self.Expect = headersDict["expect"] elif header == "pragma": self.Pragma = headersDict["pragma"] elif charsLength == 7: if header == "expires": self.Expires = headersDict["expires"] elif header == "referer": self.Referer = headersDict["referer"] elif header == "trailer": self.Trailer = headersDict["trailer"] elif header == "upgrade": self.Upgrade = headersDict["upgrade"] elif header == "warning": self.Warning = headersDict["warning"] elif charsLength == 8: if header == "if-match": self.If_Match = headersDict["if-match"] elif header == "if-range": self.If_Range = headersDict["if-range"] elif charsLength == 11: if header == "content-md5": self.Content_MD5 = headersDict["content-md5"] elif charsLength == 12: if header == "content-type": self.Content_Type = headersDict["content-type"] elif header == "max-forwards": self.Max_Forwards = headersDict["max-forwards"] elif charsLength == 13: if header == "authorization": self.Authorization = headersDict["authorization"] elif header == "cache-control": self.Cache_Control = headersDict["cache-control"] elif header == "content-range": self.Content_Range = headersDict["content-range"] elif header == "if-none-match": self.If_None_Match = headersDict["if-none-match"] elif header == "last-modified": self.Last_Modified = headersDict["last-modified"] elif charsLength == 14: if header == "accept-charset": self.Accept_Charset = headersDict["accept- charset"] elif header == "content-length": self.Content_Length = headersDict["content- length"] elif charsLength == 16: if header == "content-encoding": self.Content_Encoding = headersDict["content- encoding"] elif header == "content-language": self.Content_Language = headersDict["content- language"] elif header == "content-location": self.Content_Location = headersDict["content- location"] elif charsLength == 19: if header == "if-unmodified-since": self.If_Unmodified_Since = headersDict["if- unmodified-since"] elif header == "proxy-authorization": self.Proxy_Authorization = headersDict["proxy- authorization"] There! That's the whole code. I guess the way you suggest is simpler and a bit more intuitive, but I was figuring that the way I suggested it is more stylish. From stefan_ml at behnel.de Fri Apr 18 03:24:07 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 18 Apr 2008 09:24:07 +0200 Subject: codec for html/xml entities!? In-Reply-To: References: Message-ID: <48084C97.4040400@behnel.de> Martin Bless wrote: > What's a good way to encode and decode those entities like € or > € ? Hmm, since you provide code, I'm not quite sure what your actual question is. So I'll just comment on the code here. > def entity2uc(entity): > """Convert entity like { to unichr. > > Return (result,True) on success or (input string, False) > otherwise. Example: > entity2cp('€') -> (u'\u20ac',True) > entity2cp('€') -> (u'\u20ac',True) > entity2cp('€') -> (u'\u20ac',True) > entity2cp('&foobar;') -> ('&foobar;',False) > """ Is there a reason why you return a tuple instead of just returning the converted result and raising an exception if the conversion fails? Stefan From andrei.avk at gmail.com Sat Apr 12 03:55:21 2008 From: andrei.avk at gmail.com (AK) Date: Sat, 12 Apr 2008 03:55:21 -0400 Subject: [ANN]: Python-by-Example updates In-Reply-To: <4800620a$0$906$ba4acef3@news.orange.fr> References: <48000796$0$30160$4c368faf@roadrunner.com> <4800620a$0$906$ba4acef3@news.orange.fr> Message-ID: <48006ae9$0$4065$4c368faf@roadrunner.com> M?ta-MCI (MVP) wrote: > Hi! > Good! Thanks. > I found a bad link, for "traceback module" > @-salutations > > Michel Claveau > You're right! I forgot to upload that file, it's fixed now - thanks for noticing! -- -ak Tobu | http://tobu.lightbird.net/ | Freeform DB / Tagger / PIM Python-by-Example | http://pbe.lightbird.net/ | Guide to LibRef From jergosh at wp.pl Mon Apr 14 11:02:08 2008 From: jergosh at wp.pl (=?UTF-8?B?R3J6ZWdvcnogU8WCb2Rrb3dpY3o=?=) Date: Mon, 14 Apr 2008 17:02:08 +0200 Subject: Java or C++? In-Reply-To: References: Message-ID: <480371F0.9090104@wp.pl> > Hello, I was hoping to get some opinions on a subject. I've been > programming Python for almost two years now. Recently I learned Perl, > but frankly I'm not very comfortable with it. Now I want to move on > two either Java or C++, but I'm not sure which. Which one do you think > is a softer transition for a Python programmer? Which one do you think > will educate me the best? > I can't say from personal experience (it was C, C++, then Python for me) but I think you'll find Java very annoying, especially if you value Python for elegance. Both C++ and Java have different philosophy than Python, but C++ is better designed and more flexible. As for the 'number of jobs' argument, sure there are more Java jobs but this is offset by the number of Java programmers. Cheers, Greg From gert.cuykens at gmail.com Tue Apr 29 21:29:26 2008 From: gert.cuykens at gmail.com (gert) Date: Tue, 29 Apr 2008 18:29:26 -0700 (PDT) Subject: ssh Message-ID: <867f5bc7-3748-4303-9f29-9d8044f0d315@m3g2000hsc.googlegroups.com> Is this the best way to use ssh ? How can i use ssh keys instead of passwords ? I dont understand what happens when pid does not equal 0 , where does the cmd get executed when pid is not 0 ? How do you close the connection ? # http://mail.python.org/pipermail/python-list/2002-July/155390.html import os, time def ssh(user, rhost, pw, cmd): pid, fd = os.forkpty() if pid == 0: os.execv("/bin/ssh", ["/bin/ssh", "-l", user, rhost] + cmd) else: time.sleep(0.2) os.read(fd, 1000) time.sleep(0.2) os.write(fd, pw + "\n") time.sleep(0.2) res = '' s = os.read(fd, 1) while s: res += s s = os.read(fd, 1) return res print ssh('username', 'serverdomain.com', 'Password', ['ls -l']) From vivainio at gmail.com Thu Apr 10 11:27:39 2008 From: vivainio at gmail.com (Ville Vainio) Date: Thu, 10 Apr 2008 08:27:39 -0700 (PDT) Subject: is Pylons alive? References: Message-ID: <423388b6-33f1-4abc-8192-70f484f0ced3@h1g2000prh.googlegroups.com> On Apr 9, 2:25 pm, Mage wrote: > Before spending much time for investigating, I would like to ask you: is > Pylons the framework I look for if I want to come back to Python and > develop MVC web apps? Why not play with Django and the Google App Engine that everyone is raving about: http://code.google.com/appengine/ Zope is also becoming a realistic choice now that it's getting easier through Grok... From the.blue.valkyrie at gmail.com Fri Apr 11 05:47:25 2008 From: the.blue.valkyrie at gmail.com (=?ISO-8859-1?Q?Cristina_Yenyxe_Gonz=E1lez_Garc=EDa?=) Date: Fri, 11 Apr 2008 11:47:25 +0200 Subject: How to make a "command line basd" interactive program? In-Reply-To: References: Message-ID: 2008/4/11, Evan : > > > Hope this hasn't been posted hundreds of times. I'm new for this. > > Before using python for this kind of script, I was using TCL to write > down a "command line based" interactive program. it likes a "tclsh", > or "python" command, after that, you can work under a prompt, for > example, " - >> ", and then you can execute any commands what you > defined in script. > > Now, in python, are there any common way(class) to finish this work? > or does anybody has a example to do that? I think the simplest way is using the InteractiveConsole class from the 'code' module. It shows a prompt, reads the commands you type and checks and executes them. Doc here: http://docs.python.org/lib/module-code.html This way the TCL part could be not necessary, though. If you need some special functionality (e.g., storing the commands you type), you can subclass it easily. Thanks, > Evan > Hope it helps :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From altami0762 at gmail.com Thu Apr 17 15:50:27 2008 From: altami0762 at gmail.com (altami0762 at gmail.com) Date: Thu, 17 Apr 2008 12:50:27 -0700 (PDT) Subject: call of duty keygen Message-ID: call of duty keygen http://cracks.12w.net F R E E C R A C K S From kyosohma at gmail.com Tue Apr 15 16:31:55 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 15 Apr 2008 13:31:55 -0700 (PDT) Subject: Recurring patterns: Am I missing it, or can we get these added to the language? References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: <665ee38f-a190-4891-9f61-963705a5ed12@e67g2000hsa.googlegroups.com> On Apr 15, 3:15 pm, Tim Chase wrote: > > My suggestion would just be to create your own utils.py module > that holds your commonly used tools and re-uses them > > -tkc Well, I almost said that, but I was trying to find some "battery" included that he could use since the OP seemed to want one. I'm sure there's a geeky way to do this with lambdas or list comprehensions too. Thanks for the feedback though. Mike From tomupton33 at yahoo.com Wed Apr 30 06:12:42 2008 From: tomupton33 at yahoo.com (mickey333) Date: Wed, 30 Apr 2008 03:12:42 -0700 (PDT) Subject: free fiction Message-ID: <61ea07f5-0a1b-4518-afc1-f23060699b19@k37g2000hsf.googlegroups.com> http://www.authspot.com/Short-Stories/Sunfish.107015 From enleverlesX.XmcX at XmclaveauX.com Sat Apr 12 03:11:11 2008 From: enleverlesX.XmcX at XmclaveauX.com (Méta-MCI (MVP)) Date: Sat, 12 Apr 2008 09:11:11 +0200 Subject: [ANN]: Python-by-Example updates In-Reply-To: <48000796$0$30160$4c368faf@roadrunner.com> References: <48000796$0$30160$4c368faf@roadrunner.com> Message-ID: <4800620a$0$906$ba4acef3@news.orange.fr> Hi! Good! Thanks. I found a bad link, for "traceback module" @-salutations Michel Claveau From bwljgbwn at gmail.com Tue Apr 22 05:50:39 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:50:39 -0700 (PDT) Subject: xp cracks Message-ID: <3f608723-e380-4099-af23-38ac6f9d92f5@k10g2000prm.googlegroups.com> xp cracks http://cracks.12w.net F R E E C R A C K S From Bonus.Onus at gmail.com Mon Apr 7 23:54:09 2008 From: Bonus.Onus at gmail.com (BonusOnus) Date: Mon, 7 Apr 2008 20:54:09 -0700 (PDT) Subject: Newbie: How to pass a dictionary to a function? Message-ID: <516e07d1-91f9-462b-9fc0-ac6d1e474f9d@n14g2000pri.googlegroups.com> How do I pass a dictionary to a function as an argument? # Say I have a function foo... def foo (arg=[]): x = arg['name'] y = arg['len'] s = len (x) t = s + y return (s, t) # The dictionary: dict = {} dict['name'] = 'Joe Shmoe' dict['len'] = 44 # I try to pass the dictionary as an argument to a # function len, string = foo (dict) # This bombs with 'TypeError: unpack non-sequence' What am I doing wrong with the dictionary? From turian at gmail.com Fri Apr 18 15:16:16 2008 From: turian at gmail.com (Joseph Turian) Date: Fri, 18 Apr 2008 12:16:16 -0700 (PDT) Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> Message-ID: <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> Basically, we're planning on releasing it as open-source, and don't want to alienate a large percentage of potential users. From http Tue Apr 15 02:44:58 2008 From: http (Paul Rubin) Date: 14 Apr 2008 23:44:58 -0700 Subject: pgdb: Debugging Python extensions made easier References: <7xzlrw7xw7.fsf@ruckus.brouhaha.com> <20484252-e346-4263-9f61-75a678134a77@8g2000hse.googlegroups.com> Message-ID: <7x3apnwr9x.fsf@ruckus.brouhaha.com> SteveD writes: > The point being that with a newish GDB (the current mingw GDB I think I was using an older gdb, but under linux, so it's possible that under mingw there are or were different issues. From drjekil77 at gmail.com Tue Apr 8 15:54:47 2008 From: drjekil77 at gmail.com (drjekil) Date: Tue, 8 Apr 2008 12:54:47 -0700 (PDT) Subject: new user needs help! Message-ID: <16571784.post@talk.nabble.com> I am totally new in biopython and its my first program.so may be i am asking stupid question. I am working with a text filelooks like this: #NAME AA TOPO ACCESS DSSP STRIDE Z-COORD 1lghB A i 79.8 H H -24.58 1lghB V i 79.6 H H -22.06 1lghB H i 71.9 H H -19.94 i need to compare those lines which has a value between 10 to 22 and presents in the following way True/false A C D E F G H I K L M N P Q R S T V X Y W(here alfabets represents amino acids) 1 1:1 2:0 3:0 and so on for rest of the amino acids. IF PRESENT IN THAT RANGE IF not PRESENT IN THAT RANGE then -1 1:0 2:0 so on,it should be 1 instead of 0 when it will find corresponding amino acid for that line.say here,for 2nd line it will be 16:1. true will represent 1,false -1. i have to cheek all the lins in the file and print it. u have to tell simply otherwise i cant understand even,so stupid am i! I will be really greatful!Thanks in advance -- View this message in context: http://www.nabble.com/new--user-needs-help%21-tp16571784p16571784.html Sent from the Python - python-list mailing list archive at Nabble.com. From paul at boddie.org.uk Fri Apr 25 10:31:36 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Fri, 25 Apr 2008 07:31:36 -0700 (PDT) Subject: Problem building python in virtual machine running centos References: Message-ID: <6f818ad0-fe79-45a9-aa31-a00e337f93aa@a70g2000hsh.googlegroups.com> On 25 Apr, 14:16, Paul Melis wrote: > > "The bug is not reproducible, so it is likely a hardware or OS problem." > > This line is printed by GCC itself, not the OP It's a strange thing for anyone to claim in an error message, though, especially if it is reproducible. Perhaps some people have special criteria for reproducibility. Paul From lists at cheimes.de Mon Apr 21 06:50:04 2008 From: lists at cheimes.de (Christian Heimes) Date: Mon, 21 Apr 2008 12:50:04 +0200 Subject: sys.maxint in Python 3 In-Reply-To: References: Message-ID: <480C715C.90809@cheimes.de> bearophileHUGS at lycos.com schrieb: > In some algorithms a sentinel value may be useful, so for Python 3.x > sys.maxint may be replaced by an improvement of the following infinite > and neginfinite singleton objects: Python 3.0 doesn't have sys.maxint any more since Python 3's ints are of arbitrary length. Instead of sys.maxint it has sys.maxsize; the maximum size of a positive sized size_t aka Py_ssize_t. Christian From gagsl-py2 at yahoo.com.ar Thu Apr 10 03:28:43 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 04:28:43 -0300 Subject: argument to python cgi script References: <12b075a10804090714l44b012e6oe35a9e471d68a059@mail.gmail.com> Message-ID: En Wed, 09 Apr 2008 11:14:33 -0300, syed mehdi escribi?: > Hi Guys, > If someone can help me in telling how can i pass arguments to python cgi > script then that will be good. > like if i want to pass "some argument" to my remote python script, by > calling something like: > http://localhost/cgi-bin/test.py?some\ argument. > What is the correct way of sending arguments in this way, and how can i > decode/receive them in test.py Encoding: py> args = {'some': 'argument', 'x': 1, 'z': 23.4} py> import urllib py> urllib.urlencode(args) 'x=1&z=23.4&some=argument' You can then use urllib.urlopen or urllib2.urlopen to send the HTTP request and retrieve the response. http://docs.python.org/lib/module-urllib.html In the server side, use cgi.FieldStorage: form = cgi.FieldStorage() x = form.getfirst('x', 0) # '1' y = form.getfirst('y', 0) # '0' z = form.getfirst('z', 0) # '23.4' http://docs.python.org/lib/module-cgi.html -- Gabriel Genellina From a.vikohn at gmail.com Mon Apr 7 23:16:03 2008 From: a.vikohn at gmail.com (Avi Kohn) Date: Mon, 7 Apr 2008 23:16:03 -0400 Subject: guide through python interpreter source code Message-ID: Are there documents,books, articles that can introduce me to the python source code base ? Thank you! Avi From terry.yinzhe at gmail.com Sun Apr 27 06:27:59 2008 From: terry.yinzhe at gmail.com (Terry) Date: Sun, 27 Apr 2008 03:27:59 -0700 (PDT) Subject: Question regarding Queue object Message-ID: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> Hello! I'm trying to implement a message queue among threads using Queue. The message queue has two operations: PutMsg(id, msg) # this is simple, just combine the id and msg as one and put it into the Queue. WaitMsg(ids, msg) # this is the hard part WaitMsg will get only msg with certain ids, but this is not possible in Queue object, because Queue provides no method to peek into the message queue and fetch only matched item. Now I'm using an ugly solution, fetch all the messages and put the not used ones back to the queue. But I want a better performance. Is there any alternative out there? This is my current solution: def _get_with_ids(self,wait, timeout, ids): to = timeout msg = None saved = [] while True: start = time.clock() msg =self.q.get(wait, to) if msg and msg['id'] in ids: break; # not the expecting message, save it. saved.append(msg) to = to - (time.clock()-start) if to <= 0: break # put the saved messages back to the queue for m in saved: self.q.put(m, True) return msg br, Terry From Robert.Bossy at jouy.inra.fr Mon Apr 14 04:11:42 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Mon, 14 Apr 2008 10:11:42 +0200 Subject: Java or C++? In-Reply-To: References: Message-ID: <480311BE.1020404@jouy.inra.fr> s0suk3 at gmail.com wrote: > Hello, I was hoping to get some opinions on a subject. I've been > programming Python for almost two years now. Recently I learned Perl, > but frankly I'm not very comfortable with it. Now I want to move on > two either Java or C++, but I'm not sure which. Which one do you think > is a softer transition for a Python programmer? Which one do you think > will educate me the best? > Hi, I vote for Java, it will be relatively smoother if you come from Python. Java adds a bit of type-checking which is a good thing to learn to code with. Also with Java, you'll learn to dig into an API documentation. Brian suggests C++, personnally, I'd rather advise C for learning about computers themselves and non-GC memory management. C++ is just too nasty. If your goal is exclusively education, I suggest a functional language (choose Haskell or any ML dialect) or even a predicate-based language (Prolog or Mercury, but the latter is pretty hardcore). These languages have quite unusual ways of looking at algorithm implementations and they will certainly expand your programming culture. Cheers, RB From andrew at acooke.org Tue Apr 15 04:50:18 2008 From: andrew at acooke.org (andrew cooke) Date: Tue, 15 Apr 2008 01:50:18 -0700 (PDT) Subject: Dynamic use of property() fails References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> <480461f8$0$20282$426a34cc@news.free.fr> Message-ID: On Apr 15, 4:06 am, Bruno Desthuilliers wrote: > The canonical solution is to use a custom descriptor instead of a property: > > class Field(object): > def __init__(self, name, onchange): > self.name = name > self.onchange = onchange > > def __get__(self, instance, cls): > if instance is None: > # called on the class > return self > # called on instance > return instance._values[self.name] > > def __set__(self, instance, value): > instance._values[name] = self.onchange(value) > > class ActiveDAO(object): > def __init__(self): > self._values = [] > > class Person(ActiveDAO): > name = Field('firstname', lambda v: v.strip().capitalize()) > age = Field('age', lambda v : int(v)) i tried code very similar after reading the first replies and found that it did not work as expected on setting. for example, in person = Person() person.age = 27 "age" is set in the instance's dictionary (as 27; the descriptor is not called), which then shadows the definition of age in the class dictionary. my understanding was that the descriptor is only called in the class context, so would be called if, say, a subclass tried to redefine age. but maybe i am still confused. i am about to go to sleep. i guess i will try your code exactly tomorrow, but it looks very close to mine which showed this problem. are you sure your solution works? thanks, andrew From Lie.1296 at gmail.com Sun Apr 6 13:49:42 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 6 Apr 2008 10:49:42 -0700 (PDT) Subject: How To Uses Modules And Plugins References: <47650e1f-148e-48f9-b09e-51cb5fb4f402@m73g2000hsh.googlegroups.com> Message-ID: <50b915ac-176e-4edf-8355-db9f8c31d51e@z24g2000prf.googlegroups.com> On Apr 7, 12:28 am, mar... at everautumn.com wrote: > I am working on a client/server, computer role-play game using Python. > I want to gradually expand the game world by creating maps as > individual py files in a map directory. I am a little foggy of how to > do this. I have read about the __import__() function. I want to > understand what the difference is between using modules and plugins. > Are they the same thing? How will my root script interact with the > individual modules once it has loaded them? If you can point me to a > web site or tutorial on this subject I would be thankful. I think you're doing it with the wrong approach, a map is a data so it should not be placed in a .py file, instead it should be placed in something like .map files which is read by your program to generate the map object. To read a file in python, use: f = file('path/path/file.map', 'r') # for reading g = file('path/path/file.map', 'rw') # for read and write m = f.readline() # To read until meeting a '\n' n = f.read() # To read until EOF (End of File) for line in g: # # To read the file line by line # using the very convenient for # f.close() # Don't forget to close the file after use g.close() From danb_83 at yahoo.com Sat Apr 12 14:00:23 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Sat, 12 Apr 2008 11:00:23 -0700 (PDT) Subject: str(bytes) in Python 3.0 References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> Message-ID: On Apr 12, 9:29 am, Carl Banks wrote: > On Apr 12, 10:06 am, Kay Schluehr wrote: > > > On 12 Apr., 14:44, Christian Heimes wrote: > > > > Gabriel Genellina schrieb: > > > > > On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') > > > > above. But I get the same as repr(x) - is this on purpose? > > > > Yes, it's on purpose but it's a bug in your application to call str() on > > > a bytes object or to compare bytes and unicode directly. Several months > > > ago I added a bytes warning option to Python. Start Python as "python > > > -bb" and try it again. ;) > > > And making an utf-8 encoding default is not possible without writing a > > new function? > > I believe the Zen in effect here is, "In the face of ambiguity, refuse > the temptation to guess." How do you know if the bytes are utf-8 > encoded? True, you can't KNOW that. Maybe the author of those bytes actually MEANT to say '??C??mo est??s?' instead of '?C?mo est?s?'. However, it's statistically unlikely for a non-UTF-8-encoded string to just happen to be valid UTF-8. From kamhung.soh at gmail.com Mon Apr 14 02:12:41 2008 From: kamhung.soh at gmail.com (Kam-Hung Soh) Date: Sun, 13 Apr 2008 23:12:41 -0700 (PDT) Subject: how to remove \n in the list References: <2ba667ab-6818-47eb-8595-79ed970728f7@q1g2000prf.googlegroups.com> Message-ID: On Apr 14, 2:58 pm, "Gabriel Genellina" wrote: > En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam > escribi?: > > > hi, > > l=['5\n', '2\n', '7\n', '3\n', '6\n'] > > > how to remove \n from the given list > > l is is very poor name... I'll use lines instead: > > lines[:] = [line.rstrip('\n') for line in lines] > > -- > Gabriel Genellina Also: map(str.rstrip, l) -- Kam-Hung Soh Software Salariman From skanemupp at yahoo.se Sun Apr 6 14:12:55 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 6 Apr 2008 11:12:55 -0700 (PDT) Subject: Prevent GUI layout from changing? Message-ID: when i added the results-LABEL the buttons have changed place. meh why cant i just put buttons and stuff on a specific coordinate and have them staying there? #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self, master=None): """Initialize yourself""" self.expr = "" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): ## """Create the Entry, set it to be a bit wider""" ## self.enText = Entry(self) ## self.enText.grid(row=0, column=0, columnspan=3) """Create the Button, set the text and the command that will be called when the button is clicked""" self.btnDisplay = Button(self, text="calculate!", command=self.Calculate) self.btnDisplay.grid(row=0, column=31) """Create the Button, set the text and the command that will be called when the button is clicked""" self.lbText = Label(self, text="Results: ") self.lbText.grid(row=1, column=0) self.btnDisplay = Button(self,text='1',command=lambda n="1":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='2',command=lambda n="2":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='3',command=lambda n="3":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='+',command=lambda n="+":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) self.btnDisplay = Button(self,text='4',command=lambda n="4":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='5',command=lambda n="5":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='6',command=lambda n="6":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='-',command=lambda n="-":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=3, padx=5, pady=5) self.btnDisplay = Button(self,text='7',command=lambda n="7":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='8',command=lambda n="8":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='9',command=lambda n="9":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='*',command=lambda n="*":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=3, padx=5, pady=5) self.btnDisplay = Button(self,text='0',command=lambda n="0":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='C',command=self.Clean) self.btnDisplay.grid(row=6, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='r',command=lambda n="r":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='/',command=lambda n="/":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) def Display(self, number): self.expr = self.expr + number self.lbText = Label(self, text=self.expr) self.lbText.grid(row=0, column=0) def Calculate(self): self.expr = str(eval(self.expr))#try catch tex 3+6+ self.lbText = Label(self, text=self.expr) self.lbText.grid(row=1, column=1) self.expr = "" def Clean(self): self.expr = "" #self.update() if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() From deets at nospam.web.de Wed Apr 16 08:20:25 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 16 Apr 2008 14:20:25 +0200 Subject: webcam (usb) access under Ubuntu References: <66jlk1F2ju6c8U1@mid.uni-berlin.de> <66kkedF2l526dU2@mid.uni-berlin.de> <455760fb-8229-4be3-ba7f-7c41bdcd66de@a22g2000hsc.googlegroups.com> <362eb242-2adc-4d7b-9c0a-95e72f4b22b6@e67g2000hsa.googlegroups.com> <66m26hF2lo3ghU1@mid.uni-berlin.de> <590f00ea-15d3-480a-9fa8-c28c32a292b2@e39g2000hsf.googlegroups.com> Message-ID: <66m995F2lchhkU1@mid.uni-berlin.de> Berco Beute wrote: > On Apr 16, 12:19 pm, "Diez B. Roggisch" wrote: >> Maybe if you are now using windows, there are better options - but I'm a >> *nix-boy :) >> >> Diez > > So am I :), but the application I'm writing has to run on *that other > operating system from the 90's*. > I'm trying hard not to implement the application in C#/.Net, but I'm > running out of open source alternatives. VideoCapture *almost* worked > and now I'm stranded at the gstreamer road as well... How's that saying? "If your in Rom, do as the Romans do". Don't fight Windows. And take IronPython to mitigate the pain of using it :) Diez From seberino at spawar.navy.mil Tue Apr 1 18:37:22 2008 From: seberino at spawar.navy.mil (seberino at spawar.navy.mil) Date: Tue, 1 Apr 2008 15:37:22 -0700 (PDT) Subject: What motivates all unpaid volunteers at Pycon? References: <7b539c8e-af4c-4409-81bc-d94e687eea59@i7g2000prf.googlegroups.com> <12d7412e-9f87-4798-a319-a78a27f68d00@e6g2000prf.googlegroups.com> Message-ID: <6ffcb45b-abb9-4d5e-8237-0f8c6bacab08@i29g2000prf.googlegroups.com> On Apr 1, 11:45 am, Ed Leafe wrote: Assuming that people get nothing back by participating in a > community, yes, it would be curious. My experience, though, is that I > get a lot more out of it than I could ever contribute. IOW, it's a > great example of synergy. What do the people get back who did all the hard work at registration desk and preparing conference attendee bags? ...who did all hotel preparations? Chris From marlin_rowley at hotmail.com Wed Apr 16 15:29:48 2008 From: marlin_rowley at hotmail.com (Marlin Rowley) Date: Wed, 16 Apr 2008 14:29:48 -0500 Subject: Passing the output of a thread to the caller. Message-ID: I have a thread that I've created from a main program. I started this thread and passed it a function to execute. Within this function are 'print' statements. While they are directly translated to the stdout, I would love to return them back to the program itself and store them in an object. How would I do this? -M _________________________________________________________________ Use video conversation to talk face-to-face with Windows Live Messenger. http://www.windowslive.com/messenger/connect_your_way.html?ocid=TXT_TAGLM_WL_Refresh_messenger_video_042008 -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavlovevidence at gmail.com Thu Apr 10 06:39:35 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Thu, 10 Apr 2008 03:39:35 -0700 (PDT) Subject: I am worried about Python 3 References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> <47fce3ca$0$36346$742ec2ed@news.sonic.net> Message-ID: <83fda3fc-cedc-4105-862d-9e00d74817e3@24g2000hsh.googlegroups.com> On Apr 9, 11:53 am, John Nagle wrote: > jmDesktop wrote: > > If I continue in Python 2.5.x, am I making a mistake? Is it really > > that different? > > No. It may never happen, either. The Perl crowd tried > something like this, Perl 6, which was announced in 2000 and still > hasn't come out. The C++ standards committee has been working on a > revision of C++ since the 1990s, and that hasn't happened either. You're not paying attention if you think there's it's still doubt over whether Python 3 will happen. > The general consensus is that Python 3.x isn't much of an > improvement over the existing language. I'm going to have to opine that you pulled this out of your ass. > There's just not much demand for it. Well that's a little mode defensible seeing that we really don't know how people will react. Carl Banks From s0suk3 at gmail.com Mon Apr 14 02:44:10 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Sun, 13 Apr 2008 23:44:10 -0700 (PDT) Subject: Java or C++? Message-ID: Hello, I was hoping to get some opinions on a subject. I've been programming Python for almost two years now. Recently I learned Perl, but frankly I'm not very comfortable with it. Now I want to move on two either Java or C++, but I'm not sure which. Which one do you think is a softer transition for a Python programmer? Which one do you think will educate me the best? From colas.francis at gmail.com Wed Apr 16 09:53:39 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Wed, 16 Apr 2008 06:53:39 -0700 (PDT) Subject: vary number of loops References: Message-ID: <7cf04150-06f3-4198-b55f-ffe14ef0e050@y21g2000hsf.googlegroups.com> On 16 avr, 15:31, nullgr... at gmail.com wrote: > Hi everyone, > > I'm new to Python and the notion of lambda, and I'm trying to write a > function that would have a varying number of nested for loops > depending on parameter n. This just smells like a job for lambda for > me, but I can't figure out how to do it. Any hint? > > For example, for n=2, I want the function to look something like: > > def foo(2) > generate 2 sets of elements A, B > # mix elements by: > for a_elt in A > for b_elt in B > form all combinations of them > > If n=3, I want to have 3 sets of elements and mix them up using 3 for > loops. > > Any help is greatly appreciated, > > nullgraph You can try recursion in a more classic manner: In [283]: def foo(n): .....: def bar(n): .....: my_elts = xrange(2) .....: if n<=0: .....: raise StopIteration .....: elif n<=1: .....: for elt in my_elts: .....: yield (elt,) .....: else: .....: for elt in my_elts: .....: for o_elt in bar(n-1): .....: yield (elt,)+o_elt .....: for elt in bar(n): .....: print elt .....: In [284]: foo(2) (0, 0) (0, 1) (1, 0) (1, 1) In [285]: foo(3) (0, 0, 0) (0, 0, 1) (0, 1, 0) (0, 1, 1) (1, 0, 0) (1, 0, 1) (1, 1, 0) (1, 1, 1) In this case, I have an inner function to generate the whole set of elements and then an outer loop to process them. Note that you can have the generation of my_elts depend on rank n of recursion (that is the index of the set in your list). From wizzardx at gmail.com Sat Apr 26 03:54:21 2008 From: wizzardx at gmail.com (David) Date: Sat, 26 Apr 2008 09:54:21 +0200 Subject: problem with listdir In-Reply-To: References: Message-ID: <18c1e6480804260054s2802dbf8teff9dc8284745b4d@mail.gmail.com> > > i get the following error > WindowsError: [Error 123] The filename, directory name, or volume > label syntax is incorrect: 'f:\\code\\python\pgmgallery/*.*' > > i am running python on winXP ..can anyone tell me why i get this > error? > -- >From some Googling, it looks like this error can happen in Windows when you have registry problems. This isn't a Python problem as far as I can tell. A few things for you to try: * Try running your code on another machine with the same directory. * Run cmd.exe and see if you can run "dir f:\\code\\python\pgmgallery/*.*" * Try using other drives besides F: (C: is a good start) * Try using other directories under F: drive in your program and see when you start hitting the problem. David. From sjmachin at lexicon.net Tue Apr 1 08:27:50 2008 From: sjmachin at lexicon.net (John Machin) Date: Tue, 01 Apr 2008 12:27:50 GMT Subject: xlrd and cPickle.dump In-Reply-To: <34e62ddb-477f-4a99-97a5-21a7b148d244@e67g2000hsa.googlegroups.com> References: <34e62ddb-477f-4a99-97a5-21a7b148d244@e67g2000hsa.googlegroups.com> Message-ID: <47f22a41@news.mel.dft.com.au> patrick.waldo at gmail.com wrote: > Hi all, > > Sorry for the repeat I needed to reform my question and had some > problems...silly me. Indeed. Is omitting the traceback part of the "reformation"? > > The xlrd documentation says: > "Pickleable. Default is true. In Python 2.4 or earlier, setting to > false will cause use of array.array objects which save some memory but > can't be pickled. In Python 2.5, array.arrays are used > unconditionally. Note: if you have large files that you need to read > multiple times, it can be much faster to cPickle.dump() the xlrd.Book > object once, and use cPickle.load() multiple times." > > I'm using Python 2.4 and I have an extremely large excel file that I > need to work with. How many megabytes is "extremely large"? How many seconds does it take to open it with xlrd.open_workbook? > The documentation leads me to believe that cPickle > will be a more efficient option, but I am having trouble pickling the > excel file. So far, I have this: > > import cPickle,xlrd > import pyExcelerator > from pyExcelerator import * You only need one of the above imports at the best of times, and for what you are attempting to do, you don't need pyExcelerator at all. > > data_path = """C:\test.xls""" It is extremely unlikely that you have a file whose basename begins with a TAB ('\t') character. Please post the code that you actually ran. > pickle_path = """C:\pickle.xls""" > > book = xlrd.open_workbook(data_path) > Data_sheet = book.sheet_by_index(0) > > wb=pyExcelerator.Workbook() > proc = wb.add_sheet("proc") > > #Neither of these work > #1) pyExcelerator try > #cPickle.dump(book,wb.save(pickle_path)) > #2) Normal pickle try > #pickle_file = open(pickle_path, 'w') > #cPickle.dump(book, pickle_file) > #file.close() > and the last bit of the pre-freormation traceback was """ File "C:\Python24\lib\copy_reg.py", line 69, in _reduce_ex raise TypeError, "can't pickle %s objects" % base.__name__ TypeError: can't pickle file objects """ I can reproduce that behaviour with Python 2.2, also with 2.1 (different error message, same meaning). However it works OK with Python 2.3.5, 2.4.3, and 2.5.2. Precisely which version of Python 2.4 are you using? Are you in the habit of copying library files like copy_reg.py from one version to another? The second argument of cPickle.dump is an open file. wb.save(pickle_path) will write an empty/default spreadsheet file to the given path (this is utterly pointless) and then return None. So once you get over the first problem, you will have the second: None is not an open file. The whole pyExcelerator carry-on is quite irrelevant to your problem. Please post the minimal pyExcelerator-free script that demonstrates your problem. Ensure that it includes the following line: import sys; print sys.version; print xlrd.__VERSION__ Also post the output and the traceback (in full). Cheers, John From pavlovevidence at gmail.com Thu Apr 17 04:18:49 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Thu, 17 Apr 2008 01:18:49 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> Message-ID: On Apr 17, 3:37 am, Jonathan Gardner wrote: > Using 100% of the CPU is a bug, not a feature. No it isn't. That idea is borne of the narrowmindedness of people who write server-like network apps. What's true for web servers isn't true for every application. > If you can't rewrite > your algorithm to be disk or network bound, next optimization step is > C. I'm sorry, but I don't like being told to use C. Perhaps I would like the expressiveness of Python, am willing to accept the cost in performance, but would also like to take advantage of technology to get performance gains when I can? What's so unreasonable about that? Look, the GIL is not a good thing. It's a trade off. Probably a good one, too, considering the history of Python's development and the way it simplifies writing extensions. But it's not, by itself, a good thing. For the record, I am not complaining about that GIL. As I said, I understand and approve of why it's there. I am, however, complaining about attitude that if you want to be free of the GIL you're doing something wrong. Carl Banks From roy at panix.com Sun Apr 6 22:46:14 2008 From: roy at panix.com (Roy Smith) Date: Sun, 06 Apr 2008 22:46:14 -0400 Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> Message-ID: In article , Aldo Cortesi wrote: > I should also note that converting from unittest to Pry is quite simple > - Pry's test structure is a superset of unittest's, and AutoTree was > explicitly written to make "unittest-style" testing possible, meaning > that no _structural_ change is needed for conversion. The most onerous > part is converting to assertion-based testing, something that will > improve the clarity and readability of your tests anyway. I've been following this thread for a while with a mix of amusement and alarm. Contributing code to the community is a good thing, and should be celebrated. If people like it, they will use it. If they don't, it will be ignored. None of which justifies the hostility this thread seems to have degenerated into. In any case, I don't understand why you say that unittest doesn't use "assertion-based testing". They seem like assertions to me. What am I missing? From gagsl-py2 at yahoo.com.ar Tue Apr 8 02:32:33 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 08 Apr 2008 03:32:33 -0300 Subject: Translating keywords References: <873apwubmm.fsf@physik.rwth-aachen.de> Message-ID: En Tue, 08 Apr 2008 03:03:13 -0300, Torsten Bronger escribi?: > Gabriel Genellina writes: >> >> Python 3 allows for unicode identifiers, but I don'k know any >> plans for using unicode keywords too. Looks funny: >> >> ? x ? values: >> if x ? forbidden ? x ? y: >> print(x, ?(x), ?(x)) >> print(?(values)) >> near = ? a,b,?=0.01: a-? ? b ? a+? > > As far as I've understood it, only letters are allowed in > identifiers rather than arbitrary Unicode code points. Yes, this was of course a futuristic exercise of imagination, even replacing keywords with some symbols. Anyway the only non-alphabetic identifier is ?; ? could replace ?, and all others are allowed letters in Python 3. -- Gabriel Genellina From tinnews at isbd.co.uk Thu Apr 3 11:17:08 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 03 Apr 2008 15:17:08 GMT Subject: mailbox.Maildir(), confusing documentation Message-ID: <47f4f4f4$0$715$bed64819@news.gradwell.net> Having got my Python 2.5.2 installed I'm trying some things out with the mailbox.Maildir() class. If I do the following:- import maibox mailbox.Maildir("/home/isbd/Mail/Li/pytest") then the pytest Maildir mailbox is created - which is great but isn't documented. If the above creates the maildir then what is the mailbox.Maildir.add_folder() method for? I tried mailbox.Maildir.add_folder() and it appeared to do nothing, it didn't produce any errors either. Anyway I'm happy that mailbox.Maildir() will create maildirs and it means I can do basically what I want but the documentation could be a bit more helpful. Are there any HowTos or FAQs for this (quite new I know) part of Python? -- Chris Green From reachmsn at hotmail.com Wed Apr 9 03:56:27 2008 From: reachmsn at hotmail.com (reachmsn at hotmail.com) Date: Wed, 9 Apr 2008 00:56:27 -0700 (PDT) Subject: Cannot understand the detailedly the following code References: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> Message-ID: <874ad604-f2c1-4f0c-84c8-724723215d76@q10g2000prf.googlegroups.com> On Apr 8, 5:45?pm, "A.T.Hofkamp" wrote: > On 2008-04-08, reach... at hotmail.com wrote: > > [deleted a long piece of text by our BDFL about recursive graph path-finding algorithm] > > > after first writing the inductive part ... for node in > > graph[start] .... > > and then by trial and error put square brackets around path in the > > Basis part. Can someone please explain how to write this code. Thanks! > > The same as any other function. > (the trick with recursive functions is not to think about recursion. Instead, > pretend you are calling another function that happens to have the same name.) > > As for the actual procedure of writing a function: > > First define the input and output parameters/values of the function. > (ie what goes in, and what comes out) > > For recursive functions, there are always two cases, a terminating case, and a > reduction case. In the first case, you may not use the recursive function, in > the latter function you should. > Both cases should use the information available from the input parameters, and > provide a result that matches with the output requirements of the function. Add > a if/then/else that distinguishes between what case you have, and you're done. > > Sincerely, > Albert OK so trying to follow your instructions I have- def find_all_paths(graph, start, end, path=[]): for node in graph[start]: From spam-trap at telus.net Mon Apr 28 14:27:32 2008 From: spam-trap at telus.net (L. Lindstrom) Date: Mon, 28 Apr 2008 18:27:32 GMT Subject: Python 2.6, building SDL for Pygame Message-ID: I build the Pygame releases for Windows. Pygame wraps the Simple Directmedia Layer (SDL) C library. I am doing preliminary research into porting Pygame to Python 2.6. For Pythons 2.4 and 2.5 the Pygame extension modules are built with MinGW. They link cleanly against msvcr71.dll. A custom SDL, also linked to msvcr71.dll, is used. It is built with Msys/MinGW using the configure/make tool chain. For Python 2.6 I expect Visual Studio 2008 will be required to build the Pygame extension modules. However, I am at a loss as to how to build SDL so it also links against msvcr90.dll. Windows' side=by-side assemblies get in the way. The Msys build process fails. The first test program configure compiles and runs refuses to load msvcr90.dll. It raises an R6034 error. How important is it that a C library uses the same C run-time as the Python extension module that wraps it? If it is not critical then the SDL library will just use msvcrt.dll for Pygame and Python 2.6. -- Lenard Lindstrom "%s@%s.%s" % ('len-l', 'telus', 'net') From jimgardener at gmail.com Sat Apr 26 13:56:31 2008 From: jimgardener at gmail.com (jimgardener) Date: Sat, 26 Apr 2008 10:56:31 -0700 (PDT) Subject: problem with listdir References: Message-ID: > * Run cmd.exe and see if you can run "dir f:\\code\\python\pgmgallery/*.*" > that causes a message 'Invalid switch - "*.*".' > * Try using other directories under F: drive in your program and see> when you start hitting the problem. i tried that..on some directories in the same drive this gives correct result and returns a list of filenames.however the error occurs on other directories ,looks like a weird windows problem! From sam at mas.pl Wed Apr 2 10:52:30 2008 From: sam at mas.pl (sam) Date: Wed, 02 Apr 2008 16:52:30 +0200 Subject: Prototype OO In-Reply-To: <47f38ad8$0$10664$426a34cc@news.free.fr> References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> Message-ID: Bruno Desthuilliers napisa?(a): > Don't misunderstand me : I'm not saying that class-based is better (or > worse) than prototype, I'm not saying that Python is perfect, I'm not > saying that your points are not worth any consideration, I'm just saying > that, from your arguments, I have the very strong impression that you > don't know enough about Python's object model to understand it's > coherence and strength (and I've probably expressed it a rather harsh > way - please bear with me). If I'm wrong, please say so, pardon me and > we'll move ahead. I understand you. Thanks for spending time to write all that things. The point is that when I say: -- you should have same syntax of lambdas and ordinary functions then Python gurus say: -- lambda is very good and is so special, that has its own syntax But it seems to me, that lambda syntax was introduced because of interpreter limitations -- indentation and expressions. So it is not perfect, but must be as it is now. Then I say: -- __id is awful, because it is a trick to prefix names and gurus say: -- it is good solution for name conflicts But somebody may prefix his names with class names and cause nameconflict, so maybe it is not so good? I would prefer to hear something like "other solutions were very complex, and our zen says 'Simple is better than complex.', so we decided to use this simple and not perfect solution" From victorsubervi at gmail.com Tue Apr 22 08:41:41 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Tue, 22 Apr 2008 07:41:41 -0500 Subject: Error Handling In-Reply-To: References: <4dc0cfea0804171219l7e4c749dpfd13f9bb35294e1a@mail.gmail.com> Message-ID: <4dc0cfea0804220541l6b8f0512u19f599e67b2c5e6@mail.gmail.com> That worked. Thanks! Victor On Sun, Apr 20, 2008 at 11:02 PM, Gabriel Genellina wrote: > En Thu, 17 Apr 2008 16:19:12 -0300, Victor Subervi < > victorsubervi at gmail.com> escribi?: > > > try: > > cursor.execute(sql) > > print '?Exito en introducir!
' > > print 'Esta p?gina va a regresar a la p?gina principal del > carrito > > de compras en 10 segundos.' > > except IntegrityError: > > print 'Lo siento, pero el ID que entraste est? usado actualmente > por > > otra entrada. Favor de dar para atr?z y escojer otro n?mero.' > > except OperationalError: > > print 'Lo siento, pero has a?adido un car?cter extra?o a un n?mero > (o > > en "ID", "precio", "rec?maras" o "ba?os". Favor de dar para atr?z y > escojer > > otro n?mero.' > > except: > > print 'Lo siento, pero hay un error. Favor de dar para atr?z y > > averiguar donde est? el error, y reintentar.' > > When I enter and ID that is not a number, it should trigger the > > IntegrityError. Instead, I get this in the error log: > > > > [Thu Apr 17 12:06:37 2008] [error] [client 190.166.0.245] PythonHandler > > mod_python.cgihandler: NameError: global name 'IntegrityError' is not > > defined, referer: http://livestocksling.com/bre/iud.py > > Looks like IntegrityError and OperationalError are defined inside your > database module. Either use: > > from my_database_module import IntegrityError, OperationalError > > try > ... > except OperationalError: ... > except IntegrityError: ... > except Exception: ... > > or else: > > import my_database_module > > try > ... > except my_database_module.OperationalError: ... > except my_database_module.IntegrityError: ... > except Exception: ... > > It's the same as any other symbol, like math.sqrt or os.rename > > Note that I've not used a bare except: clause; it's not a good idea. > sys.exit() raises the SystemExit exception, and pressing Ctrl-C raises > KeyboardInterrupt; a bare except: will catch them, effectively nullifying > the intended purpose. > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdw at distorted.org.uk Tue Apr 22 15:20:26 2008 From: mdw at distorted.org.uk (Mark Wooding) Date: Tue, 22 Apr 2008 19:20:26 +0000 (UTC) Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. References: Message-ID: Kenneth McDonald wrote: > Sadly. python-beautifulsoup is a Debian package, so ftp://ftp.debian.org/debian/pool/main/b/beautifulsoup/beautifulsoup_3.0.4.orig.tar.gz should be a copy of the (unmodified) upstream source. -- [mdw] From kyosohma at gmail.com Thu Apr 24 10:23:25 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Thu, 24 Apr 2008 07:23:25 -0700 (PDT) Subject: Tkinter scrollbar and checkbox References: <9581b4cd-36f1-47dc-ae6e-0ca58f1b38e0@27g2000hsf.googlegroups.com> Message-ID: <741dfbee-530e-49af-a1fc-deb3cebbbd16@w74g2000hsh.googlegroups.com> On Apr 24, 7:11?am, goldtech wrote: > Hi, > > I'm stumped on how to have a scrollbar with a long list of checkboxes. > Given code like: > > from Tkinter import * > root = Tk() > states = [] > for i in range(150): > ? ? var = IntVar() > ? ? chk = Checkbutton(root, text=str(i), variable=var) > ? ? chk.grid(sticky=W) > ? ? states.append(var) > root.mainloop() > print map((lambda var: var.get()), states) > > I've tried adding this to a frame then adding the frame to a canvas > and it gets complicated rather quickly... > > Is there a simple way to add a scroll bar? > > Thanks I use wxPython most of the time, however effbot has a good tutorial on scrollbars for Tkinter that I think you might find helpful: http://effbot.org/zone/tkinter-scrollbar-patterns.htm Here's another link on the subject: http://www.pythonware.com/library/tkinter/introduction/scrollbar.htm HTH Mike From gagsl-py2 at yahoo.com.ar Thu Apr 24 01:37:15 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 24 Apr 2008 02:37:15 -0300 Subject: @classmethod question References: Message-ID: En Thu, 24 Apr 2008 00:27:13 -0300, Scott SA escribi?: > I'm using the @classemethod decorator for some convenience methods and > for some reason, either mental block or otherwise, can't seem to figure > out how to elegantly detect if the call is from an instance or not. > > Here's the problem: Within the class definition, 'isinstance' has > nothing to compare to because the class does not appear to exist. > > This is NOT a great example, but it outlines the the code: > > class RecipieClass: > def __init__(self): > pass > @classmethod > def get_ingrendients(self, recipie_list=None): > if isinstnace(self,RecipieClass): > return self.do_something_interesting() > else: > return do_something_boring(recipie_list) > > Yes, I can test to see if the param exists, but that makes the call > exclusive i.e. I can _only_ call it as an instance or with a parameter. Then you can't use a classmethod. A class method can *only* be called on the defining class or a subclass of it, or using an instance of those classes, but in any case the first argument (usually called "cls", not "self") is the *class* on which you called it. > > Why am I doing this? > > It is a series of convenience methods, in this case I'm interacting with > a database via an ORM (object-relational model). I want the ability to > call a class-ojbect and get related values, or pass some criteria and > get related values for them without collecting the records first as > instances, then iterating them. I need to call this from several places > so I want to be DRY (don't repeat yourself). > > The easiest way to describe this as an analogy would be like having a > recipie for cookies and wanting to know all of the ingredients ahead of > time. Then, at another time, wanting to know what all the ingredients > would be to make cookies, cake and bread (i.e. complete shopping list). > cookie_recipie = RecipieClass.get_recipie('cookies') > cookie_recipie.get_ingredients() > 2C Flour > 0.5 C Sugar > ... > RecipieClass.get_ingrendients(['cookies','cake','bread']) > 8C Flour > 2C Sugar > ... > > Of course any suggestions on how this might be better approached would > be interesting too. I'm not sure if I get the idea right, but it looks like two different classes to me, a Recipe and a RecipeSet: class Recipe: def __init__(self, recipe_name) """a Recipe given its name""" def get_ingredients(self) """a list of ingredients for this recipe""" class RecipeSet: def __init__(self, recipe_names): """a set of recipes considered together""" self.recipe_names = recipe_names def get_ingredients(self) """a summarized list of ingredients for all given recipes""" cookie_recipie = Recipe('cookies') cookie_recipie.get_ingredients() 2C Flour 0.5 C Sugar ... all_ingredients = RecipeSet(['cookies','cake','bread']).get_ingrendients() 8C Flour 2C Sugar ... -- Gabriel Genellina From james at reggieband.com Sun Apr 13 11:12:06 2008 From: james at reggieband.com (james at reggieband.com) Date: Sun, 13 Apr 2008 08:12:06 -0700 (PDT) Subject: Module to read input from commandline Message-ID: <2e04b64c-9a12-4e20-8d5a-546a0ec4ac7f@m36g2000hse.googlegroups.com> Hi all, I did some quick searching but I haven't found anything like I want. It probably has to do with the terms I am searching for so if I describe what I want then I hope someone can point me to a good module. I want to take input from the user at the command line. e.g.) Would you like to continue [Y/n]: y What is your favorite color: green .... You get the idea. Basic question answer stuff. It should handle default options, case insensitivity, etc. Perhaps the module would compare the inputted text against a regexp for validation. If the module had an interface similar to OptParse that would be nice. Anyone know of a decent module that handles this type of thing? Writing from scratch would be simple but why re-invent the wheel. Cheers, James. From wilson.t.thompson at gmail.com Sun Apr 27 09:42:13 2008 From: wilson.t.thompson at gmail.com (wilson) Date: Sun, 27 Apr 2008 06:42:13 -0700 (PDT) Subject: convert images Message-ID: hi i converted some P5 type .pgm images to .jpg using x=Image.open("oldimage.pgm") imsz=x.size newimg=Image.new('L',imsz) newimg.putdata(x.getdata()) newimg.save("newimg.jpg") when i again check the pixel data for these images using getdata() method i,I find that they are slightly different ie if oldimage.pgm has pixels [29 31 38 ..., 10 4 18] then the corresponding jpg image has [29 31 38 ..., 10 3 17] why this difference? shouldn't they be identical?can someone pls explain this? From jcd at sdf.lonestar.org Tue Apr 29 16:20:46 2008 From: jcd at sdf.lonestar.org (J. Cliff Dyer) Date: Tue, 29 Apr 2008 16:20:46 -0400 Subject: Colors for Rows In-Reply-To: <20080429153930.a6eddea6.darcy@druid.net> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> <20080429121105.f10c3862.darcy@druid.net> <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> <1209495803.5173.11.camel@aalcdl07.lib.unc.edu> <20080429153930.a6eddea6.darcy@druid.net> Message-ID: <1209500446.5510.4.camel@aalcdl07.lib.unc.edu> On Tue, 2008-04-29 at 15:39 -0400, D'Arcy J.M. Cain wrote: > On Tue, 29 Apr 2008 15:03:23 -0400 > "J. Cliff Dyer" wrote: > > Or, if you aren't sure how many colors you'll be using, try the more > > robust: > > > > bg[z % len(bg)] > > Good point although I would have calculated the length once at the > start rather than each time through the loop. > Good catch. Thanks. What's that they say about eyes and bugs? Cheers, Cliff From watches0802 at global-replica-watch.com Sat Apr 19 06:18:07 2008 From: watches0802 at global-replica-watch.com (watches0802 at global-replica-watch.com) Date: Sat, 19 Apr 2008 03:18:07 -0700 (PDT) Subject: Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch - Replica Watch Fake Message-ID: <89bacae3-0280-424e-8ab5-5d1cd914e963@a5g2000prg.googlegroups.com> Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch - Replica Watch Fake Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch Link : http://www.watchesprice.net/Replica-Bulova-2208.html Replica Watches Home : http://www.watchesprice.net/ Replica Bulova Brands : http://www.watchesprice.net/Bulova-Replica.html Replica Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch --- one of best selling replica watches, it is crafted in high quality, please click image 'buy now' to buy this chic but inexpensive replica to save you a lot of money . Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch Description: no Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch Details: Brand: Bulova Band material: stainless-steel Bezel material: stainless-steel Case material: stainless-steel Clasp type: deployment-buckle Dial color: mother-of-pearl Dial window material: anti-reflective-sapphire Movement type: Quartz Water-resistant to 330 feet Thank you for choosing www.watchesprice.net as your reliable dealer of quality waches including Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch . we guarantee every watch you receive will be exact watch you ordered. Each watch sold enjoy one year Warranty for free repair. Every order from aaa- replica-watches is shipped via EMS, the customer is responsible for the shipping fee on the first order, but since the second watch you buy from our site, the shipping cost is free. Please note that If the total amount of payment is over $600(USD), the customer is required to contact our customer service before sending the money in case failed payment. If you have any other questions please check our other pages or feel free to email us by service at watchesprice.net. Cheapest Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch The Same Bulova Series : Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch : http://www.watchesprice.net/Replica-Bulova-2209.html Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch : http://www.watchesprice.net/Replica-Bulova-2210.html Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Markers Diamond Bezel Women's Watch : http://www.watchesprice.net/Replica-Bulova-2211.html Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Markers Diamond Bezel Women's Watch : http://www.watchesprice.net/Replica-Bulova-2212.html Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Markers Diamond Bezel Women's Watch : http://www.watchesprice.net/Replica-Bulova-2213.html Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Markers Rotating Bezel Women's Watch : http://www.watchesprice.net/Replica-Bulova-2214.html Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Markers Women's Watch : http://www.watchesprice.net/Replica-Bulova-2215.html Bulova Watches, Bulova Ladies' Sport Marine Star Silver, Pink and Blue Interchangebale Bezel 35 Diamonds Women's Watch : http://www.watchesprice.net/Replica-Bulova-2216.html Bulova Watches, Bulova Ladies' Sport Marine Star Two Tone Steel and Gold Diamond Bezel Women's Watch : http://www.watchesprice.net/Replica-Bulova-2217.html Bulova Watches, Bulova Ladies' Sport Marine Star Two Tone Steel and Rose Gold Diamond Bezel Mother of Pearl Dial Women's Watch : http://www.watchesprice.net/Replica-Bulova-2218.html Bulova Watches, Bulova Latest Edition in Stainless Steel or Two Tone with or without Diamond Bezel Women's Watch : http://www.watchesprice.net/Replica-Bulova-2219.html Bulova Watches- Bulova Ladies' Bracelet Two Tone Steel and Gold Women's Watch : http://www.watchesprice.net/Replica-Bulova-2220.html From corvettecraz92 at gmail.com Tue Apr 8 22:14:26 2008 From: corvettecraz92 at gmail.com (corvettecraz92 at gmail.com) Date: Tue, 8 Apr 2008 19:14:26 -0700 (PDT) Subject: text adventure game problem References: <6e247b5c-a58d-4e4e-a67a-c21d36061cf0@z38g2000hsc.googlegroups.com> <20bb5b82-9cf2-4983-b9d0-b50c718a6b85@k10g2000prm.googlegroups.com> Message-ID: On Apr 8, 9:55?pm, Andr? wrote: > On Apr 8, 10:44?pm, corvettecra... at gmail.com wrote: > > > > > On Apr 8, 9:25?pm, Andr? wrote: > > > > On Apr 8, 10:01?pm, corvettecra... at gmail.com wrote: > > > > > okay, I'm having this one problem with a text adventure game. It's > > > > kind of hard to explain, but I'll do my best. > > > > [code] > > > > > def prompt_kitchen(): > > > > ? ? global gold > > > > ? ? gold_taken = False > > > > ? ? while True: > > > > ? ? ? ? prompt_kit = raw_input('>') > > > > ? ? ? ? if prompt_kit == 'examine cabinet 1' and not gold_taken: > > > > ? ? ? ? ? ? print '''This cabinet has a lot of cups in it with all > > > > different > > > > designs and shapes. Where are the people anyway? How come there's > > > > nobody here? > > > > In one of the cups you find 8 gold.''' > > > > ? ? ? ? ? ? gold = gold+8 > > > > ? ? ? ? ? ? gold_taken = True > > > > ? ? ? ? ? ? pass4() > > > > ? ? ? ? elif prompt_kit == 'examine cabinet 1' and gold_taken: > > > > ? ? ? ? ? ? print \ > > > > ? ? ? ? ? ? ? ? ? '''This cabinet has a lot of cups in it with all > > > > different > > > > designs and shapes. Where are the people anyway? How come there's > > > > nobody here?''' > > > > ? ? ? ? ? ? pass4() > > > > > def pass4(): > > > > ? ? global gold > > > > ? ? print 'You have', gold, 'gold' > > > > ? ? pass > > > > [/code] > > > > > Okay, now for my problem. > > > > In the above function, there's the option to examine a cabinet and get > > > > 8 gold. (everyone here knows that...but I'm just trying to state my > > > > problem...) > > > > Unfortunately, it kind of doesn't work. > > > > After the first time I 'examine cabinet 1' in my game, I get 8 gold > > > > and I can't get it again. > > > > But, If I leave the room and come back to it, then it's as if I had > > > > never gotten the gold the first time, and I can get it again. > > > > How do I fix this? > > > > quick guess: define gold_taken as a global variable and initialize it > > > outside of the function. > > > > Warning: avoid global variables if at all possible. > > > > ;-) > > > Andr? > > > Here's a sample code that, in fact, does work. In this code, when run, > > I can only get the gold once. > > > def prompt_house(): > > ? ? global gold > > ? ? gold_taken = False > > ? ? while True: > > ? ? ? ? prompt_hou = raw_input('>') > > ? ? ? ? if prompt_hou == 'examine table' and not gold_taken: > > ? ? ? ? ? ? print \ > > ? ? ? ? ? ? ? ? ? '''There are a lot of car magazines here. > > You flip through them and find 5 gold. > > ''' > > ? ? ? ? ? ? gold = gold+5 > > ? ? ? ? ? ? gold_taken = True > > ? ? ? ? elif prompt_hou == 'go west': > > ? ? ? ? ? ? # this gets you out of the loop > > The above comment is wrong. > > > ? ? ? ? ? ? go_west() > > ? ? ? ? ? ? # more elif choices here ... > > ? ? ? ? elif prompt_hou == 'examine table' and gold_taken: > > ? ? ? ? ? ? print '''There are a lot of car magazines here.''' > > ? ? ? ? ? ? go_west() > > def go_west(): > > # just a dummy funk > > ? ? global gold > > ? ? print gold > > ? ? pass > > The "pass" statement is redundant. > > > ? ? ? ? ? ? ? ? # test > > gold = 0 > > prompt_house() > > > But what's the difference between this and the one that I posted? > > It is hard to say as you are not posting the entire code. ?As I > indicated above, you wrote a comment indicating that a given choice > was taking you out of the loop - which could only happen through a > break statement. ?You may want to post a ("small") code sample that > can be run by itself and reproduces the problem behaviour you > observe. ?The sample you posted include infinite loops with no way to > get out, so your original claim that you could leave the room and come > back is highly suspicious ;-) > > Andr? Here ya go...this is an excerpt from my main code, with an example room added on. gold = 0 def kitchen(): print 'you have', gold, 'gold' print '''You are in the kitchen of the house. There is a lot of cooking equipment here, along with 3 cabinets, a food pantry, and a drawer. At the far end of the room is an icebox and a stove. To the south there is a living room, and to the east is a den.''' print prompt_kitchen() def prompt_kitchen(): global gold gold_taken = False while True: prompt_kit = raw_input('>') if prompt_kit == 'examine cabinet 1' and not gold_taken: print '''This cabinet has a lot of cups in it with all different designs and shapes. Where are the people anyway? How come there's nobody here? In one of the cups you find 8 gold.''' gold = gold+8 gold_taken = True pass4() elif prompt_kit == 'examine cabinet 1' and gold_taken: print \ '''This cabinet has a lot of cups in it with all different designs and shapes. Where are the people anyway? How come there's nobody here?''' pass4() elif prompt_kit == 'south': extra_room() def extra_room(): print 'you have', gold, 'gold' print 'This is a dead end room. Go north.' kitchen() def pass4(): global gold print 'You have', gold, 'gold' pass kitchen() From skanemupp at yahoo.se Sun Apr 6 15:59:48 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 6 Apr 2008 12:59:48 -0700 (PDT) Subject: Tkinter, a lot of buttons, make prog shorter? Message-ID: is there anyway to make this shorter? i hate having these big blocks of similar-looking code, very unaesthetic. maybe doesnt matter good-code-wise? anyway can i make some function that makes this shorter? like put the etiquettes on the button froma string of '123+456-789*0Cr/' ? problem is the command and lambda-func for each button is different. self.btnDisplay = Button(self,text='1',command=lambda n="1":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=3, column=0) self.btnDisplay = Button(self,text='2',command=lambda n="2":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=3, column=1) self.btnDisplay = Button(self,text='3',command=lambda n="3":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=3, column=2) self.btnDisplay = Button(self,text='+',command=lambda n="+":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=3, column=3) self.btnDisplay = Button(self,text='4',command=lambda n="4":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=4, column=0) self.btnDisplay = Button(self,text='5',command=lambda n="5":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=4, column=1) self.btnDisplay = Button(self,text='6',command=lambda n="6":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=4, column=2) self.btnDisplay = Button(self,text='-',command=lambda n="-":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=4, column=3) self.btnDisplay = Button(self,text='7',command=lambda n="7":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=5, column=0) self.btnDisplay = Button(self,text='8',command=lambda n="8":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=5, column=1) self.btnDisplay = Button(self,text='9',command=lambda n="9":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=5, column=2) self.btnDisplay = Button(self,text='*',command=lambda n="*":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=5, column=3) self.btnDisplay = Button(self,text='0',command=lambda n="0":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=6, column=0) self.btnDisplay = Button(self,text='C',command=self.Clean,width=2,height=2) self.btnDisplay.grid(row=6, column=1) self.btnDisplay = Button(self,text='r',command=lambda n="r":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=6, column=2) self.btnDisplay = Button(self,text='/',command=lambda n="/":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=6, column=3) From roy at panix.com Sat Apr 5 22:23:27 2008 From: roy at panix.com (Roy Smith) Date: Sat, 05 Apr 2008 22:23:27 -0400 Subject: Best way to check if string is an integer? References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> Message-ID: In article , Steve Holden wrote: > > This doesn't cater for negative integers. > > > No, it doesn't, but > > s.isdigit() or (s[0] in "+-" and s[1:].isdigit) # untested > > does. I think this fails on " -1". So, then you start doing s.strip().isdigit(), and then somebody else comes up with some other unexpected corner case... int(s) and catching any exception thrown just sounds like the best way. From martin at v.loewis.de Mon Apr 28 18:29:08 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 29 Apr 2008 00:29:08 +0200 Subject: py3k concerns. An example In-Reply-To: References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> <48118719$0$25846$9b622d9e@news.freenet.de> <481525DE.9060208@v.loewis.de> Message-ID: <48164FB4.3000204@v.loewis.de> > Unless I mix my psuedodicts with standard dicts > in the same list, for example, or pass them to > functions intended to accept any dict-like object, > including the especially important case of standard > dicts. > > Who knows? Maybe I'm wrong about this being a much of > problem. I think so. I expect that in the typical application, you either won't notice the difference in behavior at all, or you get an exception the first time, in which case you can easily adjust the code to support both cases. This expectation is supported by experience both from adjusting the Python standard library itself, and from converting Django to Python 3. In my experience (from the same applications), by far the most significant change in Python 3 is the change to the meaning of string literals, and the disposal of the 2.x str type. Regards, Martin From roy at panix.com Wed Apr 9 09:50:53 2008 From: roy at panix.com (Roy Smith) Date: Wed, 09 Apr 2008 09:50:53 -0400 Subject: I am worried about Python 3 References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> <663r0mF2iji99U1@mid.uni-berlin.de> Message-ID: In article <663r0mF2iji99U1 at mid.uni-berlin.de>, Marc 'BlackJack' Rintsch wrote: > There will be a `2to3.py` program coming with Python??2.6 that tries to > convert most changes automatically. You may have to change the 2.6 code > in a way that makes the automatic conversion possible but it is a > important goal for the Python developers to make the transition as smooth > as possible as far as I can tell. People who have been using good software engineering practices like writing lots of automated tests, will have some confidence that the conversion went well. People who haven't written any tests will probably be afraid of any big changes to the environment (and rightfully so). But, to answer the OP's question, to wit, "If I continue in Python 2.5.x, am I making a mistake?", I would say not. For somebody learning a new language, what you seek is stability. You want everything to be well documented, and to work as documented. You want a large community of people who already know what you are learning, and are able to help. Likewise, you want a good selection of books to provide tutorial and reference help. And a good set of well-tested tools and add-on modules. You'll get all those from Python 2.5. If you go with 3.0, you'll be on the bleeding edge. My advice is to stay with what's stable today and come back and look at 3.0 in a year or so when you know what you're doing better, and the ecosystem has caught up with code. And, write those automated tests, so when the time does come to switch, you can do so with confidence :-) From castironpi at gmail.com Wed Apr 23 16:57:59 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 23 Apr 2008 13:57:59 -0700 (PDT) Subject: Python development tools References: <09992de9-39fa-4ee6-8009-35732f3433fb@y21g2000hsf.googlegroups.com> <87fxtcnvj7.fsf@physik.rwth-aachen.de> Message-ID: <5e606054-901a-464a-bc77-7aadd4637d33@b64g2000hsa.googlegroups.com> On Apr 23, 3:52?pm, Torsten Bronger wrote: > Hall?chen! > > bruno.desthuilli... at gmail.com writes: > > On 23 avr, 19:39, "wongjoek... at yahoo.com" > > wrote: > > >> Are there any completely free developent tools for python scripts > >> like IDLE. I have used IDLE , but I want to try out others > >> also. I saw stuff like PyCrust, but I don't see that it can run > >> the script as well. > > > emacs + python-mode (the one from Python, not the horror that > > ships with recent emacs versions) > > What's so bad about it? > > I just installed python-mode (is this the one with the "py-" > prefixes?), and it ends multi-line strings at single quotes. ?That's > bad. > > Tsch?, > Torsten. > > -- > Torsten Bronger, aquisgrana, europa vetus > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Jabber ID: bron... at jabber.org > ? ? ? ? ? ? ? ?(Seehttp://ime.webhop.orgfor further contact info.) Did you guys see PyPE editor? It just come out. From kj7ny at nakore.com Sun Apr 6 05:05:47 2008 From: kj7ny at nakore.com (kj7ny) Date: Sun, 6 Apr 2008 02:05:47 -0700 (PDT) Subject: Self in Interactive Interpreter References: Message-ID: <22a3ca84-242c-48de-b55c-d402d91ac280@b5g2000pri.googlegroups.com> On Apr 4, 1:41 pm, Fredrik Lundh wrote: > kj7nywrote: > > For years it has been a slight annoyance that every time I wanted to > > test a snippet of code from a class by running it in the interactive > > interpreter, I had to remove all of the self. instances from the > > code. After I got it working correctly, I had to put all the self.'s > > back into the code to put it back into my class. > > wouldn't it be a lot easier to test your code by importing the module > containing it into the interactive interpreter? > > >>>> class dummy: > >>>> def __init__(self): > >>>> pass > > or, shorter: > > >>> class dummy: pass > > Didn't know about the >>> class dummy: pass option. It makes sense now that I see it. Just hadn't ever tried it, I guess. Thanks! With some of my larger applications, it doesn't seem to work well to try to run the whole thing in the interpreter. At least for me, I am not a big IDE sort of programmer. I am much more comfortable in vim and command line stuff. I suppose I should use the IDE more. I wasn't offering this "tip" as a cure all. It was just an observation should it be of use to someone out there. However, I greatly appreciate your improvement on the example I gave. I will use your class dummy: pass approach from now on. Thanks, From __peter__ at web.de Wed Apr 30 10:57:10 2008 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Apr 2008 16:57:10 +0200 Subject: I messed up my wxPython install (Eclipse Configuration Issue) References: <18eb0a7c-96f4-41de-b44f-95fd8ba0223f@f63g2000hsf.googlegroups.com> Message-ID: blaine wrote: > The wxPython group is a bit stale compared to this group, so I'll give > it a shot :) > > (READ: Originally when I started htis post, Python 2.5 at the shell > did not work (identical behavior to eclipse). I'm not sure why, but > it has since worked fine with no problems. Not sure whats going on > there... I didn't change anything. Anyways...) > > Ok so I am having this problem. I am using OS X 10.4. I use > MacPython and installed wxPython a few months back, and it worked > great. Well I haven't done any wx development lately, and now that > I'm getting back into it I can't get wx to work properly. I'm using > Eclipse, too. > > Python 2.5 at Shell: works just fine > $ python >>>> import wx > > OLD projects in Eclipse: import wx works fine > NEW projects in Eclipse (since I have started working wx again after a > few months): > import wx > /Users/frikk/Documents/workspace/Bili_UI/src/wx.py:3: Rename your script wx.py to something that doesn't clash with the installed modules, e.g. my_wx.py. And don't forget to remove /Users/frikk/Documents/workspace/Bili_UI/src/wx.pyc # note the .pyc suffix too. Peter > DeprecationWarning: The wxPython compatibility package is no longer > automatically generated or actively maintained. Please switch to the > wx package as soon as possible. > from wxPython.wx import * > Traceback (most recent call last): > File "/Users/frikk/Documents/workspace/Bili_UI/src/nokia_fkscrn.py", > line 37, in > import wx > File "/Users/frikk/Documents/workspace/Bili_UI/src/wx.py", line 3, > in > from wxPython.wx import * > File "//Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/wx-2.8-mac-ansi/wxPython/__init__.py", line > 15, in > import _wx > File "//Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/wx-2.8-mac-ansi/wxPython/_wx.py", line 3, in > > from _core import * > File "//Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/wx-2.8-mac-ansi/wxPython/_core.py", line 15, > in > import wx._core > ImportError: No module named _core > > I feel like this may be a path issue? Any ideas on what else to look > for? Both sys.path statements are the same, and I'm not sure what else > I could be causing it - some configuration perhaps in Eclipse that is > not being set correctly for newer projects? I also choose 'Python 2.5' > from in eclipse - and it points to the same location for both > projects.. Path: >>>> import sys >>>> sys.path > > ['', '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ > site-packages/setuptools-0.6c8-py2.5.egg', '/Library/Frameworks/ > Python.framework/Versions/2.5/lib/python2.5/site-packages/ > Pygments-0.9- > py2.5.egg', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python25.zip', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/plat-darwin', '/Library/Frameworks/Python.framework/ > Versions/ > 2.5/lib/python2.5/plat-mac', '/Library/Frameworks/Python.framework/ > Versions/2.5/lib/python2.5/plat-mac/lib-scriptpackages', '/Library/ > Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk', '/ > Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib- > dynload', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages', '/Library/Frameworks/Python.framework/ > Versions/2.5/lib/python2.5/site-packages/wx-2.8-mac-ansi'] > > Any suggestions would be great - its probably something pretty > minor... Thanks! > > Blaine From aaron.watters at gmail.com Wed Apr 16 13:12:35 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 16 Apr 2008 10:12:35 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> Message-ID: > Since you don't care about any of the changes or features, and you > don't care if your users care, I'm not sure why you aren't just using > python 2.1. It's not like it's being erased via time machine. "Just > keep using the old thing" is a perfectly valid and extremely common > futureproofing scenario. Well for one thing newer versions of python are faster and they come installed on other peoples linux and mac boxes. If I were only interested in the box sitting in front of me it sure would be a lot simpler. In reality even in a simple environment I have to support 2.3 running on a 32 bit platform and 2.4 running on a 64 bit platform with the same code. This is more of a pain than it should be. Don't get me wrong. I like things like generators that actually are useful (and amazingly fast also, I must say). I'd also love to be able to use stackless which would be even cooler but I can't because no-one else uses it to a first order approximation and I don't want to be responsible for installing it all over the place... I'm interested in developing software for/getting software from the python environment, ecosystem and community. In the short term I foresee everything bifurcating into two separate code bases, and I think that's a shame, and I don't really see the need. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=nightmare From danb_83 at yahoo.com Sat Apr 12 15:30:08 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Sat, 12 Apr 2008 12:30:08 -0700 (PDT) Subject: Recommended "from __future__ import" options for Python 2.5.2? References: Message-ID: <2c97adca-7f34-4ffb-bc8d-858ccf9d0917@w4g2000prd.googlegroups.com> On Apr 12, 1:41 pm, "Malcolm Greene" wrote: > Is there any consensus on what "from __future__ import" options > developers should be using in their Python 2.5.2 applications? > > Is there a consolidated list of "from __future__ import" options to > choose from? Just look inside the __future__ module. * nested_scopes * generators Already mandatory features. You don't need to import them. * with_statement Import this one if you're using the feature. And for forward compatibility, don't use "with" as a variable name. * absolute_import I haven't followed this one. * division ALWAYS import this in new modules. Otherwise, you'll be very likely to get burned my code as simple as def mean(seq): return sum(seq) / len(seq) From semanticist at gmail.com Wed Apr 9 00:41:27 2008 From: semanticist at gmail.com (Miles) Date: Wed, 9 Apr 2008 00:41:27 -0400 Subject: style question - hasattr In-Reply-To: References: Message-ID: On Tue, Apr 8, 2008 at 10:21 PM, ian wrote: > Ok, so what about 'hasattr' ?? > hasattr(myObject,'property') > seems equivalent to > 'property' in dir(myObject) > > I would suggest that using the 'in' is cleaner in this case also. Is > there a performance penalty here? Or is there reason why the two are > not actually the same? >>> class HasAll(object): ... def __getattr__(self, name): pass ... >>> hasattr(HasAll(), 'spam') True >>> 'spam' in dir(HasAll()) False >From the docs: "Because dir() is supplied primarily as a convenience for use at an interactive prompt, it tries to supply an interesting set of names more than it tries to supply a rigorously or consistently defined set of names, and its detailed behavior may change across releases. ... [hasattr] is implemented by calling getattr(object, name) and seeing whether it raises an exception or not." http://docs.python.org/lib/built-in-funcs.html > Which style is preferred?? Don't test for the existence of the attribute if you're going to get it when it exists; just go ahead and get it. try: x = myObject.property except AttributeError: x = None - Miles From meisnernel73884 at gmail.com Wed Apr 30 06:37:23 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:37:23 -0700 (PDT) Subject: wep key crack Message-ID: <23fa3fdc-7055-4b68-ad41-ad7d66e1d964@r66g2000hsg.googlegroups.com> wep key crack http://crack.cracksofts.com From hdante at gmail.com Fri Apr 11 16:44:15 2008 From: hdante at gmail.com (hdante) Date: Fri, 11 Apr 2008 13:44:15 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> Message-ID: <01db54ab-1fca-4a51-8b98-510de224f40a@y21g2000hsf.googlegroups.com> On Apr 11, 3:33 pm, Lie wrote: > > That old-school rounding method you're taught is based on a wrong > assumption of the nature of number. In the past, rounding algorithm is > based on this: > > Original => (RoundUp(u|d|n), RoundNearestEven(u|d|n) > ... > 1.0 => 1(n), 1(n) > 1.1 => 1(d), 1(d) > 1.2 => 1(d), 1(d) > 1.3 => 1(d), 1(d) > 1.4 => 1(d), 1(d) > 1.5 => 2(u), 2(u) > 1.6 => 2(u), 2(u) > 1.7 => 2(u), 2(u) > 1.8 => 2(u), 2(u) > 1.9 => 2(u), 2(u) > 2.0 => 2(n), 2(n) > 2.1 => 2(d), 2(d) > 2.2 => 2(d), 2(d) > 2.3 => 2(d), 2(d) > 2.4 => 2(d), 2(d) > 2.5 => 3(u), 2(d) > 2.6 => 3(u), 3(u) > 2.7 => 3(u), 3(u) > 2.8 => 3(u), 3(u) > 2.9 => 3(u), 3(u) > ... > > In this used-to-be-thought-correct table, Round Ups algorithm have 2 > Unrounded, 8 Round Down, and 10 Round Ups which seems incorrect while > Round Even have 2 Unrounded, 9 Round Down, and 9 Round Up which seems > correct. The misunderstanding comes from a view that thinks that there > is such thing as Not Rounded while in fact the only number that is Not > Rounded is 1 and 2 while 1.0 and 2.0 must still be rounded, in > practice we can just say that all number must be rounded somewhere. > > Original => (RoundUp(u|d), RoundNearestEven(u|d) > ... > 1.0 => 1(d), 1(d) > 1.1 => 1(d), 1(d) > 1.2 => 1(d), 1(d) > 1.3 => 1(d), 1(d) > 1.4 => 1(d), 1(d) > 1.5 => 2(u), 2(u) > 1.6 => 2(u), 2(u) > 1.7 => 2(u), 2(u) > 1.8 => 2(u), 2(u) > 1.9 => 2(u), 2(u) > 2.0 => 2(d), 2(d) > 2.1 => 2(d), 2(d) > 2.2 => 2(d), 2(d) > 2.3 => 2(d), 2(d) > 2.4 => 2(d), 2(d) > 2.5 => 3(u), 2(d) > 2.6 => 3(u), 3(u) > 2.7 => 3(u), 3(u) > 2.8 => 3(u), 3(u) > 2.9 => 3(u), 3(u) > ... > > In this table, we consider that a number is rounded down when the But then, the "Round up" table gives inconsistent results if, by the same argument, we consider 2.0 -> 2 rounding up. (you get 12 round ups and 8 round downs just by "rethinking" the argument). So, "rounding up" is, at the same time, better and worse than rounding to nearest even. > > Another side-note: My 12-year old son is now being taught to always > > round up from mid-way between. Yet another example of the degradation of > > maths in schools. > > A false assertion from a false understanding. The use of Round Up > algorithm is a refinement of the false understanding we used to > practice in the past. The assertion is false, because there's no problem in rounding up, truncating, etc. Just consider the amount of code snippets in this thread. A simpler solution may solve a lot of problems. From joeblow at nowhere.nohow Wed Apr 16 20:24:20 2008 From: joeblow at nowhere.nohow (Joe Blow) Date: 17 Apr 2008 00:24:20 GMT Subject: TypeNone field detection Message-ID: <480698b3$0$31577$ec3e2dad@news.usenetmonster.com> What is the best way to detect a TypeNone field in a tuple, or in a list? I am accessing a MySQL database using the MySQLdb Python interface... this interface returns a tuple object type in response to SQL SELECT statements. My understanding of the MySQLdb interface is that NULL database values are returned as a Python 'None' object. Because I need to create some work fields based on the contents of the database I am doing so by copying the tuple to a list object and then calculating these work fields as needed. My problem is that I need to be able to detect the Python 'None' objects and convert them to an integer zero value field to enable my calculations to work. I'm new to Python so I'm sure I'm overlooking something simple ? but what is the easiest way to do a logical test for the existence of a TypeNone field? From robert.kern at gmail.com Fri Apr 4 16:01:08 2008 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 04 Apr 2008 15:01:08 -0500 Subject: Any fancy grep utility replacements out there? In-Reply-To: <2a1695f7-5e1a-46f3-9c69-76a930e5dd10@e39g2000hsf.googlegroups.com> References: <2a1695f7-5e1a-46f3-9c69-76a930e5dd10@e39g2000hsf.googlegroups.com> Message-ID: Floris Bruynooghe wrote: > I tried to find something similar a while ago and found ack[1]. I do > realise it's written in perl but it does the job nicely. Never needed > to search in zipfiles though, just unzipping them in /tmp would always > work... Yup, I used ack for a little while before writing grin. Unfortunately, I got hooked on context lines and these were unimplemented in ack. -- 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 From gagsl-py2 at yahoo.com.ar Mon Apr 14 04:11:50 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 14 Apr 2008 05:11:50 -0300 Subject: =?utf-8?B?562U5aSNOiBob3cgdG8gcmVtb3ZlIFxuIGluIHRoZSBsaXN0?= References: <20080414070819.D4CA335E6A5@mail-in-06.arcor-online.net> Message-ID: En Mon, 14 Apr 2008 04:08:06 -0300, Penny Y. escribi?: >> lines[:] = [line.rstrip('\n') for line in lines] > > why not just: > > lines = [line.rstrip('\n') for line in lines] > > > what's the difference between lines[:] and lines here? Thanks. My version (using [:]) replaces the *contents* of the original list, but the list itself remains the same object. Yours (without the [:]) reasigns a new list to the old name; the *contents* are the same as the former version, but now the name "lines" refers to a different list. Depending on the context, the difference may be important or not. -- Gabriel Genellina From steve at holdenweb.com Sun Apr 20 10:06:41 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 20 Apr 2008 10:06:41 -0400 Subject: Another MySQL Images Question In-Reply-To: References: <4dc0cfea0804180813o32ed2c82o9c3f68b1a607348d@mail.gmail.com> Message-ID: Dennis Lee Bieber wrote: > On Sat, 19 Apr 2008 03:46:54 +0200, Karl-Heinz Ruskowski > declaimed the following in comp.lang.python: > >> Hi, >> >>> cursor.execute('update products set pic1="%s" where id="%s", ;', >>> (pic1, id)) >> Shouldn't it be something like >> cursor.execute('update products set pic1="%s" where id="%s", ;' % (pic1, id)) > > It should be NEITHER... > > The latter is relying on Python to fill in the parameters. The > former is relying (preferred) for the DB-API adapter to correctly format > the parameters (It is a coincidence that MySQLdb internally uses Python > % formatting, so the place holders are %s, where others use ?) > > To be fully compliant it should be > > cursor.execute("update products set pic1=%s where id=%s", > (pic1, id)) > > NOTE: no trailing , > no trailing ; > no embedded " -- the DB-API spec is that IT will properly > supply whatever quotes or escapes are needed to ensure the data > fits the syntax. This is also why most will not function if one tries to > make the table or field names parameters -- the DB-API will quote them > too, and > > update "products" set "pic1" = "something" > > is much different from > > update products set pic1="something" > Many versions of SQL do actually allow you to quote table names, allowing names with otherwise illegal characters like spaces in them. Double-quotes are typically used for such quoting (though Microsoft, to be different, tends to use brackets). Single-quotes should be used for string literals, although certain sloppy implementations of SQL do also allow double-quotes. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From wbsoft at xs4all.nl Sat Apr 12 15:41:59 2008 From: wbsoft at xs4all.nl (Wilbert Berendsen) Date: Sat, 12 Apr 2008 21:41:59 +0200 Subject: pty.spawn directs stderr to stdout In-Reply-To: References: Message-ID: <200804122142.00091.wbsoft@xs4all.nl> Op vrijdag 11 april 2008, schreef Donn Cave: > More likely, you want the spawned process' error output to go wherever > the parent's error output was going. ?This is a little trickier. I ended up writing a small script that basically reimplements fork() from the pty module, where then STDERR is not dup'ed to the pty. I'm currently trying to combine subprocess.Popen with pty.openpty ... tx, Wilbert Berendsen -- http://www.wilbertberendsen.nl/ "You must be the change you wish to see in the world." -- Mahatma Gandhi From mccredie at gmail.com Tue Apr 15 13:46:03 2008 From: mccredie at gmail.com (Matimus) Date: Tue, 15 Apr 2008 10:46:03 -0700 (PDT) Subject: Preferred method for "Assignment by value" References: Message-ID: <6a3ed8f0-b82c-4cd3-b36e-1d94f8a30fe3@n1g2000prb.googlegroups.com> On Apr 15, 10:23 am, hall.j... at gmail.com wrote: > As a relative new comer to Python, I haven't done a heck of a lot of > hacking around with it. I had my first run in with Python's quirky (to > me at least) tendency to assign by reference rather than by value (I'm > coming from a VBA world so that's the terminology I'm using). I was > surprised that these two cases behave so differently > > test = [[1],[2]] > x = test[0] > x[0] = 5 > test>>> [[5],[2]] > > x = 1 > test > > >>>[[5],[2]] > x > >>> 1 > > Now I've done a little reading and I think I understand the problem... > My issue is, "What's the 'best practise' way of assigning just the > value of something to a new name?" > > i.e. > test = [[1,2],[3,4]] > I need to do some data manipulation with the first list in the above > list without changing > obviously x = test[0] will not work as any changes i make will alter > the original... > I found that I could do this: > x = [] + test[0] > > that gets me a "pure" (i.e. unconnected to test[0] ) list but that > concerned me as a bit kludgy > > Thanks for you time and help. I think you understand the concept, basically you want to make a copy. Ether of these are acceptable: x = test[0][:] OR x = list(test[0]) this will also work: import copy x = copy(test[0]) Matt From aldo at nullcube.com Sun Apr 6 22:34:42 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Mon, 7 Apr 2008 12:34:42 +1000 Subject: ANN: pry unit testing framework In-Reply-To: <87prt2mq8l.fsf@benfinney.id.au> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> Message-ID: <20080407023442.GA16373@nullcube.com> Thus spake Ben Finney (bignose+hates-spam at benfinney.id.au): > > I'm afraid that Pry is unashamedly incompatible with any other unit > > testing method in existence, including but not limited to doctest, > > unittest, nose and py.test. ;) > > Which makes the deliberate deviations from PEP 8 naming a large black > mark against it. You're misunderstanding the intent of PEP 8, which was never supposed to dogmatically enforce a naming standard on all Python projects everywhere. You're also vastly overstating the impact of a minor naming convention choice. Calling this a "large black mark" smacks of scare-mongering to me. > > Some day I might experiment with extending Pry to gather and run > > doctests and unittests. At this stage, however, I don't believe the > > (significant) effort would be worth it. > > That's very unfortunate. Until it plays better with others, I don't > believe the effort of using this package will be worth it. Each of the third-party testing frameworks that have cropped up in this thread extends unittest in some incompatible way. If you use any of these extensions, it means that your unit test suite is tied to that particular test framework. If you have an existing suite of unit tests that you can't or don't want to convert, I'm afraid that Pry is indeed not for you. Pry is not intended to be a general engine for running tests written for other frameworks. I should also note that converting from unittest to Pry is quite simple - Pry's test structure is a superset of unittest's, and AutoTree was explicitly written to make "unittest-style" testing possible, meaning that no _structural_ change is needed for conversion. The most onerous part is converting to assertion-based testing, something that will improve the clarity and readability of your tests anyway. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From martin at marcher.name Tue Apr 8 16:33:17 2008 From: martin at marcher.name (Martin Marcher) Date: Tue, 8 Apr 2008 22:33:17 +0200 Subject: Best way to check if string is an integer? In-Reply-To: <5fa6c12e0804081332r2a58d39gc44ce1ef8cb69052@mail.gmail.com> References: <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> <0fdd2825-6d1c-4380-a79a-a7aac119f002@a5g2000prg.googlegroups.com> <96d2fe53-96bf-43d8-a58d-8269846bf0df@b64g2000hsa.googlegroups.com> <2033313.fb3g3XYCIP@montana.com> <5fa6c12e0804081332r2a58d39gc44ce1ef8cb69052@mail.gmail.com> Message-ID: <5fa6c12e0804081333k377343d4sedf6adc7ff1c7183@mail.gmail.com> arg, as posted earlier: int("10.0") fails, it will of course work with float("1E+1") sorry for the noise... On Tue, Apr 8, 2008 at 10:32 PM, Martin Marcher wrote: > hmmm > > int() does miss some stuff: > > >>> 1E+1 > 10.0 > >>> int("1E+1") > Traceback (most recent call last): > File "", line 1, in > ValueError: invalid literal for int() with base 10: '1E+1' > > I wonder how you parse this? > > I honestly thought until right now int() would understand that and > wanted to show that case as ease of use, I was wrong, so how do you > actually cast this type of input to an integer? > > thanks > martin > > > -- > http://tumblr.marcher.name > https://twitter.com/MartinMarcher > http://www.xing.com/profile/Martin_Marcher > http://www.linkedin.com/in/martinmarcher > > You are not free to read this message, > by doing so, you have violated my licence > and are required to urinate publicly. Thank you. > -- http://tumblr.marcher.name https://twitter.com/MartinMarcher http://www.xing.com/profile/Martin_Marcher http://www.linkedin.com/in/martinmarcher You are not free to read this message, by doing so, you have violated my licence and are required to urinate publicly. Thank you. From m.moghimi at gmail.com Mon Apr 14 05:16:27 2008 From: m.moghimi at gmail.com (m.moghimi) Date: Mon, 14 Apr 2008 02:16:27 -0700 (PDT) Subject: Python Workshop Message-ID: Hi, We are to hold a workshop about python (introduction). It will be two one hour and half sessions. I wanted to know which subjects do you suggest to be presented and is there a good presentation file (powerpoint or ...) about this on the net. We thought that it may be good that first session covers the introduction, zen of python, python coding syntax and the second session will be about application, libraries or so. I really appreciate if you tell me your ideas? From ivan_chernetsky at tutby.by Thu Apr 3 11:39:51 2008 From: ivan_chernetsky at tutby.by (Ivan Chernetsky) Date: Thu, 3 Apr 2008 17:39:51 +0200 (CEST) Subject: PyXMPP and GTalk Message-ID: Hello! Here is the example from PyXMPP package: http://pyxmpp.jajcus.net/trac/browser/trunk/examples/echobot.py And here is output: From s0suk3 at gmail.com Thu Apr 17 10:59:51 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 07:59:51 -0700 (PDT) Subject: Can't do a multiline assignment! Message-ID: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> I was shocked a while ago when a discovered that in Python you can't do a multiline assignment with comments between the lines. For example, let's say I want to assign a bunch of variables to an initial, single value. In C or a similar language you would do: CONSTANT1 = /* This is some constant */ CONSTANT2 = CONSTANT3 = /*This is yet some other constant */ CONSTANT = 1; In Python, you usually can use parentheses to split something over several lines. But you can't use parentheses for an assignment of several lines. For that, you can use the line continuation character ('\'): CONSTANT1 = \ CONSTANT2 = \ CONSTANT3 = \ 1 But I realized that you can't do this: CONSTANT1 = \ # Oops... syntax error CONSTANT2 = \ CONSTANT3 = \ # This is also a syntax error # And this too \ 1 Does anyone know of a way to put the comments between lines like that? I find this limitation very annoying. From fiacre.patrick at gmail.com Thu Apr 17 11:53:55 2008 From: fiacre.patrick at gmail.com (Andrew Lee) Date: Thu, 17 Apr 2008 11:53:55 -0400 Subject: Can't do a multiline assignment! In-Reply-To: References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> Message-ID: <4807723a$0$15206$607ed4bc@cv.net> s0suk3 at gmail.com wrote: >> Yuck! No way!! If you *want* to make your code that hard to read, I'm >> sure you can find lots of ways to do so, even in Python, but don't >> expect Python to change to help you toward such a dubious goal. >> > > Well, my actual code doesn't look like that. Trust me, I like clean > code. > >> Seriously, examine your motivations for wanting such a syntax. Does it >> make the code more readable? (Absolutely not.) Does it make it more >> maintainable. (Certainly not -- consider it you needed to change >> CONSTANT2 to a different value some time in the future.) > Use a dictionary? > Yes, it makes it more readable. And yes, it does make it (a lot) more > maintainable. Mainly because I don't have those four variables, I have > about thirty. And I think I won't need to one or two of them, but > maybe all of them at once. From zedshaw at zedshaw.com Wed Apr 16 05:43:54 2008 From: zedshaw at zedshaw.com (Zed A. Shaw) Date: Wed, 16 Apr 2008 05:43:54 -0400 Subject: [ANN] Vellum 0.13: Simple Python Build Tool (usable now) Message-ID: <20080416054354.8260fbe1.zedshaw@zedshaw.com> Hello Everyone, Insomnia has blessed me with the ability to make another release of Vellum for all to play with and try using. Features in this release: * The ability to make your own commands for your build specs in plain old Python as a Python module. * The docstring comments on your vellum commands become dynamic documentation for vellum via: vellum -C. * Lots of documentation, comments, cleaned up code, and a more complete test suite. * Importing other build specs as recipes and importing python modules are all unified and cleaned up. * Still only 620 lines of Python code which is damn amazing. DOCUMENTATION I wrote a bunch of documentation tonight, and will be doing a more complete manual soon: http://zedshaw.com/projects/vellum/ This page is cleaned up and lays out how to use vellum, write a build.vel file, and write your own commands. DOWNLOADS First, you should grab Zapps and install that: http://zedshaw.com/projects/zapps/ Then you can grab Vellum with easy_install: $ sudo easy_install vellum Or, get it from http://launchpad.net/vellum/ ANNOUNCMENTS You can subscribe to Vellum's RSS feed at: https://launchpad.net/vellum/+announcements FEEDBACK Let me know if you run into anything, and if you like it or hate it. Otherwise, enjoy the gear. -- Zed A. Shaw - Hate: http://savingtheinternetwithhate.com/ - Good: http://www.zedshaw.com/ - Evil: http://yearofevil.com/ From msh at blisses.org Sat Apr 19 11:11:07 2008 From: msh at blisses.org (Matt Herzog) Date: Sat, 19 Apr 2008 10:11:07 -0500 Subject: socket.AF_INET Message-ID: <20080419151107.GZ16190@chicago.blisses.org> Hi All. I'm trying to write a script that will send me an email message when my IP address changes on a specific NIC. On Linux, the script works. On FreeBSD, it fails with: Traceback (most recent call last): File "./pyifcheck.py", line 22, in if get_ip_address('xl0') == IPADDY: File "./pyifcheck.py", line 18, in get_ip_address struct.pack('256s', ifname[:15]) )[20:24]) IOError: [Errno 25] Inappropriate ioctl for device The script is below. ################################################################### SENDMAIL = "/usr/sbin/sendmail" IPADDY = "85.126.250.328" #IFCONFIG = "/sbin/ifconfig import os import smtplib import socket import fcntl import struct def get_ip_address(ifname): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa(fcntl.ioctl( s.fileno(), 0x8915, # SIOCGIFADDR struct.pack('256s', ifname[:15]) )[20:24]) #get_ip_address('xl0') if get_ip_address('xl0') == IPADDY: print "nevermind" else: p = os.popen("%s -t" % SENDMAIL, "w") p.write("To: matthew.herzog at gmail.com\n") p.write("Subject: YOUR IP ADDRESS HAS CHANGED\n") p.write("\n") # blank line separating headers from body p.write("Your IP addy has changed to $getipaddy\n") p.write("some more text\n") sts = p.close() if sts != 0: print "Sendmail exit status", sts ############################################################################## Thanks for any suggestions. -- "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too dark to read." -- Groucho Marx From aaron.watters at gmail.com Wed Apr 16 14:52:35 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 16 Apr 2008 11:52:35 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> <09a38ca2-8c49-4eee-b6cf-58e849aea1fc@q1g2000prf.googlegroups.com> Message-ID: On Apr 16, 2:33 pm, Rhamphoryncus wrote: > The point is, you can't have it both ways. Either you evolve the > language and break things, or you keep it static and nothing breaks. I disagree. You can add lots of cool stuff without breaking the existing code base, mostly. For example the minor changes to the way ints will work will effect almost no programs. I don't see the urgency to clean up what are essentially cosmetic issues and throw out or require rewrites for just about all existing Python code. Python 2.6 isn't fundamentally awful like Perl 4 was. The cost paid for these minor improvements is too high in my book. But I suppose if it is going to happen do it sooner rather than later. Just *please* *please* don't systematically break the pre-existing code base again for a very long time, preferable ever. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=whack From erikwickstrom at gmail.com Thu Apr 17 23:37:34 2008 From: erikwickstrom at gmail.com (erikcw) Date: Thu, 17 Apr 2008 20:37:34 -0700 (PDT) Subject: Database vs Data Structure? Message-ID: Hi, I'm working on a web application where each user will be creating several "projects" in there account, each with 1,000-50,000 objects. Each object will consist of a unique name, an id, and some meta data. The number of objects will grow and shrink as the user works with their project. I'm trying to decided whether to store the objects in the database (each object gets it's own row) or to use some sort of data-structure (maybe nested dictionaries or a custom class) and store the pickled data-structure in a single row in the database (then unpickle the data and query in memory). A few requirements: -Fast/scalable (web app) -able to query objects based on name and id. -will play nicely with versioning (undo/redo) Any input on the best way to go? Thanks! Erik From fredrik at pythonware.com Sat Apr 5 09:30:10 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 15:30:10 +0200 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> Message-ID: llothar wrote: > I don't think so. I asked a pretty simple question and as usual on > usenet nobody read the question did *you* read your own question? it took you three posts before you mentioned what you were trying to do, and four posts before you bothered to mention that you're seeing this behaviour on Ubuntu. and for the record, Python doesn't look for PYD files on any of the Unix boxes I have convenient access to right now. what Ubuntu version are you using, what Python version do you have, and what does $ python -c "import imp; print imp.get_suffixes()" print on your machine? From aaron.watters at gmail.com Mon Apr 28 14:37:01 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Mon, 28 Apr 2008 11:37:01 -0700 (PDT) Subject: Cookie Confusion - How to Set a Cookie References: <588d6a6c-0080-48a4-b768-e2c5ef551790@s50g2000hsb.googlegroups.com> Message-ID: On Apr 28, 9:42 am, cbh... at gmail.com wrote: > ....I see the cookie in my HTTP header > but do not get anything in the cookie text file. I'm working on > linux. > > print "Content-type: text/html" > cookie = Cookie.SimpleCookie() > cookie['Test'] = 'abc' > print cookie > print > > Are there rules about where in the header the set cookie line should > be? Hi Christian. I think the cookie can go anywhere in the header, but I usually put it before the content-type. If you want to store the cookie to a file, or even better, to a database of some sort, you have to do it yourself, the Cookie module doesn't do it for you, I hope. # store cookie to /tmp/cookie.txt file("/tmp/cookie.txt","w").write(str(cookie)) For parsing cookies, I stole and modified this from the Django source (for use in a cgi script): === from Cookie import SimpleCookie import os # stolen and modified from Django def parse_cookie(cookie=None, environ=None): if cookie is None: if environ is None: environ = os.environ cookie = environ.get('HTTP_COOKIE', '') if cookie == '': return {} c = SimpleCookie() c.load(cookie) cookiedict = {} for key in c.keys(): cookiedict[key] = c.get(key).value return cookiedict === All the best. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=monster From cyberco at gmail.com Tue Apr 15 10:19:36 2008 From: cyberco at gmail.com (Berco Beute) Date: Tue, 15 Apr 2008 07:19:36 -0700 (PDT) Subject: webcam (usb) access under Ubuntu References: <66jlk1F2ju6c8U1@mid.uni-berlin.de> Message-ID: Thanks, that would be great. While I'm at it I wondering how to display a video preview. Here's someone using VideoCapture (the win32 lib) and PyGame, but I'd rather use a GUI framework and preview/capture videos directly. 2B > It has been *ages* since I did this - so take it with a grain of salt. > However, back then I was able to access a video camera using gqcam. Looking > into the source of that revealed that all it did were some simple > ioctl-calls and reading from a /dev/video*-device. > > That did the trick for me... > > Additionally, you might consider using gstreamer + the python bindings for > that. I was also successful using them - if I remember this conversation > tonight or so, I'll send you the sources. > > Diez > > Diez From steve at holdenweb.com Wed Apr 2 20:13:36 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 02 Apr 2008 20:13:36 -0400 Subject: Strange MySQL Problem... In-Reply-To: <4dc0cfea0804021236n1faafabav1699fbe45acc3c01@mail.gmail.com> References: <4dc0cfea0804021236n1faafabav1699fbe45acc3c01@mail.gmail.com> Message-ID: Victor Subervi wrote: > Hi; > I have this code which works fine: > > #!/usr/local/bin/python > import _mysql > import MySQLdb, cPickle > host = 'mysqldb2.ehost-services.com ' > user = 'user' > passwd = 'pass' > db = 'bre' > print 'Content-Type: image/jpeg\r\n' > print '\nHi!\n' > connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > imgfile=open("1.jpg",'rb') > f = imgfile.read() > cursor = connection.cursor() > cursor.execute("CREATE TABLE justatest (name TEXT, ablob BLOB)") > names = 'aramis', 'athos', 'porthos' > data = {} > for name in names: > datum = list(name) > datum.sort() > data[name] = cPickle.dumps(datum, 1) > sql = "INSERT INTO justatest VALUES (%s, %s)" > cursor.execute(sql, ('ramis', _mysql.escape_string(f)) ) > imgfile.close() > connection.close() > print '\nBye!\n' > Now, if I take out this part, which I can?t see does anything at all in > the code, it no longer works: > > names = 'aramis', 'athos', 'porthos' > data = {} > for name in names: > datum = list(name) > datum.sort() > data[name] = cPickle.dumps(datum, 1) > Why? > TIA, > Victor > Define "no longer works". regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From ivan.illarionov at gmail.com Thu Apr 17 16:48:19 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Thu, 17 Apr 2008 20:48:19 +0000 (UTC) Subject: index of list of lists References: Message-ID: On Thu, 17 Apr 2008 05:15:52 +0300, Daniel NL wrote: > yes, there's a thread with the same title, but I believe mine is more > appropriate title. > so, as much as I search on the web, read manuals, tutorials, mail-lists > (including this one) I cannot figure it out how to search a string in a > list of lists. > like this one: > > someList = [['somestring', 1, 2], ['oneother', 2, 4]] > > I want to search "somestring" in someList which is in practice a list of > aprox. 200 lists. (hey, I'm a newbie python programmer, don't judge me). > is the list.index the wrong approach? should I use numpy, numarray, > something else? can anyone, be kind and help me with this? You probably need something like this: [x for x, y, z in someList if x == 'somestring'] or this: for x, y, z in someList: if x == 'somestring': return x -- Ivan From svensven at gmail.com Thu Apr 10 15:05:20 2008 From: svensven at gmail.com (svensven) Date: Thu, 10 Apr 2008 21:05:20 +0200 Subject: subprocess.Popen() output to logging.StreamHandler() In-Reply-To: <6b02e27c-916f-42a7-b2e0-75af51bba343@h1g2000prh.googlegroups.com> References: <6b02e27c-916f-42a7-b2e0-75af51bba343@h1g2000prh.googlegroups.com> Message-ID: <47FE64F0.10904@gmail.com> Vinay Sajip wrote: > On Apr 10, 1:11 pm, "sven _" wrote: >> My goal is to have stdout and stderr written to a logginghandler. > > Thomas was almost right, but not quite - you can't call info on a > Handler instance, only on a Logger instance. The following script: Yes, but that was easily fixed. Still there seemed to be a problem there with the .poll(), since it would think the process ended while it was actually running. The result was that only some of the command output was shown. > import logging > import subprocess > > logging.basicConfig(level=logging.INFO) # will log to stderr of this > script > > s = subprocess.Popen( ['ls','-la'], stdout=subprocess.PIPE ) > while 1: > line = s.stdout.readline() > exitcode = s.poll() > if (not line) and (exitcode is not None): > break > line = line[:-1] > logging.info("%s", line) This works perfectly, as far as I can tell. You seem to use another conditional, though. I'll take a closer look at this tomorrow. Thanks for the clean solution, Vinay. sven From kayvoo at googlemail.com Fri Apr 18 21:46:54 2008 From: kayvoo at googlemail.com (Karl-Heinz Ruskowski) Date: Sat, 19 Apr 2008 03:46:54 +0200 Subject: Another MySQL Images Question In-Reply-To: <4dc0cfea0804180813o32ed2c82o9c3f68b1a607348d@mail.gmail.com> References: <4dc0cfea0804180813o32ed2c82o9c3f68b1a607348d@mail.gmail.com> Message-ID: <200804190347.00462.kayvoo@gmail.com> Hi, > cursor.execute('update products set pic1="%s" where id="%s", ;', > (pic1, id)) Shouldn't it be something like cursor.execute('update products set pic1="%s" where id="%s", ;' % (pic1, id)) -- GPG key: 0x04B3BB96 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available URL: From kcemjz at yahoo.com Fri Apr 4 00:31:23 2008 From: kcemjz at yahoo.com (AJay Grimmett) Date: Thu, 3 Apr 2008 21:31:23 -0700 (PDT) Subject: Question. Message-ID: <661622.4034.qm@web54009.mail.re2.yahoo.com> My name is Amanda. My boyfriend sent me an encrypted message by using python. I guess he thought it would be fun for me to figure it out for myself. This one involes a whole lotta numbers. I can't read or understand what I am supposed to do to read this message. I mean, I've read the information, but I seriously do not understand. He sent the .py file, and the messages that were encrypted...i just don't know how to use it to get to the message where I can read it. Is there anyway you or someone could do it step by step..or just do it for me?! lol. I just need to know what this says. Apparently it's an important message and I must read it. =] Thank you for your time. I hope to hear from you soon! -amanda --------------------------------- You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost. -------------- next part -------------- An HTML attachment was scrubbed... URL: From frikker at gmail.com Wed Apr 23 11:02:30 2008 From: frikker at gmail.com (blaine) Date: Wed, 23 Apr 2008 08:02:30 -0700 (PDT) Subject: Unix Device File Emulation Message-ID: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> Hey everyone, So I've got a quick query for advice. We have an embedded device in which we are displaying to an LCD device that sits at /dev/screen. This device is not readily available all the time, so I am needing to write an emulator. This will basically just monitor a file, /dev/screen for example, and write the commands to a TK or WxWindows canvas. So sending 'line 0 0 10 10' will draw a line on my canvas from (0,0) to (10,10). My question: Whats the best way to set up a monitor (in python) of this file? Would I simply open up the file for read, check for changes, get any updated data, and clear the file? Or is there some standard way of doing something like this that guarantees no overlap or data loss? example usage: echo 'line 0 0 10 10' > /dev/screen On the actual embedded device this is handled by a kernel module. We can spit commands into it as fast as we can and the kernel module can keep up. This is typical unix device file behavior. Any suggestions or advice would be splendid. Thanks! Blaine From skanemupp at yahoo.se Sat Apr 19 16:44:27 2008 From: skanemupp at yahoo.se (globalrev) Date: Sat, 19 Apr 2008 13:44:27 -0700 (PDT) Subject: Frame work for simple physics web applications References: <2b0b8b6c-8086-4bf6-8f47-27bc5c9c788c@v23g2000pro.googlegroups.com> Message-ID: <6bdd161d-6e92-4de6-8dba-d5c11b08990f@a22g2000hsc.googlegroups.com> On 19 Apr, 21:55, Rick Muller wrote: > I'd like to use my webserver to distribute some simple python physics > apps. Ideally, I'd like to use some simple form to input a few pieces > of data, call a python program, and return some image from a plot or > some other rendering. This is easy to do using CGI, but I was > wondering whether anyone on the list could recommend that would look a > little more polished and professional. > > Let's say I want to input a wave vector k, and then input a plot of > sin(k*x). I would like to have a simple form input for k, and then > display an image of the plot. What I'm doing is a little more varied > than this, but the common thread is that in each application I need to > input several pieces of data and then display some image. I can > probably think of 20 different applications right off the bat that I'd > like to deploy. > > The idea behind this is to put together some simple toy models for > quantum computing qubits that my experimental collaborators can play > with without having to install Python, NumPy, and MatPlotLib > themselves. (I understand, of course, that such an installation might > be "good for them", but I'd rather not fight that battle just now.) > > I could, of course, write a Jython applet for this, but this would > require my re-learning how to use the Java API, and it has been a few > years for me. > > Do any of the AJAX frameworks for Python compare in simplicity to > writing a simple CGI script? I've been impressed with web.py, since it > seems pretty easy to use, but I would go to the trouble of learning > one of the bigger frameworks if they would provide a more elegant > solution. > > My web skillz are obviously several years out of date, so I'd like > some guidance on the best way to update them. > > Thanks in advance, > > Rick www.vpython.org might be what you are looking for. From kf9150 at gmail.com Wed Apr 9 13:04:12 2008 From: kf9150 at gmail.com (Kelie) Date: Wed, 9 Apr 2008 07:04:12 -1000 Subject: question about string formatting Message-ID: <42b9a3ff0804091004s4d60751fh68c82673e8e3f4c3@mail.gmail.com> Hello, Is there something in Python built-in function or library that will convert a number 1205466.654 to $1,205,466.65? To add the "$" sign and set the decimal place is not a problem, but I don't know how to add the thousands delimiter. Thanks, -- Kelie UliPad is my Python editor. -------------- next part -------------- An HTML attachment was scrubbed... URL: From Lie.1296 at gmail.com Sun Apr 6 03:13:52 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 6 Apr 2008 00:13:52 -0700 (PDT) Subject: Looking for Advanced Python Tutorials References: Message-ID: On Apr 4, 6:58 pm, cokofree... at gmail.com wrote: > I was wondering if anyone knew of some online (free if possible) > advanced tutorials, especially ones that provides tasks and ideas for > small projects. The issue for myself is I want to improve my python > programming level, and my ability to program in general, but come up > blank thinking of a possible task or project to undertake. So with > that in mind I thought I'd ask the community if they knew of sites or > books to read up on and use as a starting block. Of course project > ideas would be great as well! > > Thanks for any help you can provide. > > Coko You might be interested in Python challenge: http://www.pythonchallenge.com/ It's a series of puzzles that involve learning the edges of Python (most of the puzzle can be solved with any programming language, but some involve Python-only features, e.g. pickle) From donn at u.washington.edu Mon Apr 7 19:07:25 2008 From: donn at u.washington.edu (Donn Cave) Date: Mon, 07 Apr 2008 16:07:25 -0700 Subject: Orphaned child processes References: <51102b91-dedc-4ad6-a936-c29df47f30ab@r9g2000prd.googlegroups.com> <47fa650f$0$36329$742ec2ed@news.sonic.net> Message-ID: In article <47fa650f$0$36329$742ec2ed at news.sonic.net>, John Nagle wrote: > rocco.rossi at gmail.com wrote: > > I'm using the Python processing module. I've just run into a problem > > though. Actually, it's a more general problem that isn't specific to > > this module, but to the handling of Unix (Linux processes) in general. > > Suppose for instance that for some reason or another, after forking > > several child processes, the main process terminates or gets killed > > (or segfaults or whatever) and the child processes are orphaned. Is > > there any way to automatically arrange things so that they auto- > > terminate or, in other words, is there a way to make the child > > processes terminate when the parent terminates? > > > > Thank you. > > Put a thread in the child which reads stdin, and make stdin > connect to a pipe from the parent. When the parent terminates, > the child will get a SIGPIPE error and raise an exception. > > John Nagle That could work, but not precisely in that manner. You get SIGPIPE when you write to a closed pipe. When you read from one, you get end of file, i.e., a normal return with 0 bytes. When you test it, make sure to try a configuration with more than one child process. Since the parent holds the write end of the pipe, subsequently forked child processes could easily inherit it, and they'll hold it open and spoil the effect. Donn Cave, donn at u.washington.edu From nospam1.reifenberg at gmx.de Fri Apr 4 16:05:57 2008 From: nospam1.reifenberg at gmx.de (Nebur) Date: Fri, 4 Apr 2008 13:05:57 -0700 (PDT) Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? References: Message-ID: <0c8bfed7-1154-41d5-a740-6d1382180db2@d45g2000hsc.googlegroups.com> Yes. Linux viruses are rare but useful :-) Well, I don't think the problem a very dangerous one. The Pydev/ Eclipse was used for much more than a year nearly daily and intensively. The strange effect is very rare,obviously (plus the chance that it's in my brain, as I mentioned ;-D ) so you probably can lean back. Anyway, I'd be glad to get an even faint idea of the problem. From tjreedy at udel.edu Sat Apr 5 12:34:27 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 5 Apr 2008 12:34:27 -0400 Subject: RELEASED Python 2.6a2 and 3.0a4 References: <47F68547.1040802@v.loewis.de> Message-ID: "Kay Schluehr" wrote in message news:f4ac789e-c98f-4cf2-9236-f1ac609c44de at b1g2000hsg.googlegroups.com... On 4 Apr., 21:45, "Martin v. L?wis" wrote: > > The Windows x86 MSI installer is missing for both 2.6 and 3.0. > > And likely will continue to do so for some time. Fine. Is there also a reason? ========================== On PyDev, Martin gave just (but only) a bit more detail, to the effect that he has run into problems with the new Microsoft compiler being used for 2.6/3.0 that apparently did not crop up with the previous alpha releases a month ago. I think we should be patient and not bug him for more. Terry From upton at virginia.edu Wed Apr 2 12:41:59 2008 From: upton at virginia.edu (Dan Upton) Date: Wed, 2 Apr 2008 12:41:59 -0400 Subject: Rationale for read-only property of co_code In-Reply-To: References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> Message-ID: <5504f9ac0804020941t645de4f2xe0ed0dbc92509021@mail.gmail.com> > The thing I've been wondering is why _is_ it read-only? In what > circumstances having write access to co_code would break the language > or do some other nasty stuff? > > Jo?o Neves I can't speak to Python's implementation in particular, but self-modifying code in general is unpleasant. It certainly is possible to support it in runtime environments, but it's usually not easy to do so. That is, of course, somewhat dependent on the implementation of the runtime environment, and even to some degree the underlying hardware. (For instance, the compiled code you want to run could be in the hardware cache; if you then change the instructions at those addresses in memory, it's not always straightforward to get the processor to realize it needs to load the new data into the instruction cache.) Plus, I suppose it might be possible to break strong (even dynamic) typing if you start changing the code around (although I can't construct an example off the top of my head). In short, you need a good reason to support self-modifying code, and my guess is nobody could come up with one for Python. -dan From kyosohma at gmail.com Thu Apr 10 16:24:09 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Thu, 10 Apr 2008 13:24:09 -0700 (PDT) Subject: win-shortcuts, file associates and command-line parameters ? References: Message-ID: <0cbfd58c-a6af-4b40-a67f-09735ce4a448@m71g2000hse.googlegroups.com> On Apr 10, 2:03 pm, Stef Mientki wrote: > hello, > > under windows I tried to make a shortcut to a py -file, to run a program. > So making a shortcut like this works perfect: > D:\PyLab_Works.py > > But the problem is that I need to give some commandline parameters to > the py-file, > and > > D:\PyLab_Works.py btc_test > But the parameter doesn't seem to arrive in the python program > > If I start with the python interpreter, the parameters do arrive at the > program > P:\pythonw.exe D:\PyLab_Works.py btc_test > Although this method works, > it makes the creation of shortcuts difficult (the paths are in real much > longer). > > Is there a way to pass the commandline parameters correctly, > without explicitly specifying the python interpreter ? > > thanks, > Stef Mientki I'm not sure what you're doing wrong. It works for me. I do have Python on my system path though. I did this: Created a shortcut to my script (test.py). Right-clicked it and chose Properties. Changed it to look like this: C:\Python25\test.py -i Pressed Ok and ran it. It received my parameter just fine. If you want to use pythonw.exe by default, you'll want to change the extension of your script to *.pyw Mike From steve at holdenweb.com Wed Apr 9 12:51:45 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 12:51:45 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> Message-ID: <47FCF421.6000807@holdenweb.com> Victor Subervi wrote: > On Wed, Apr 9, 2008 at 11:10 AM, Steve Holden > wrote: > > Victor Subervi wrote: > > On Wed, Apr 9, 2008 at 10:24 AM, Steve Holden > > >> wrote: > connection = MySQLdb.connect(host=host, user=user, > passwd=passwd, db=db) > cursor = connection.cursor() > cursor.execute('select img from photo where id="7";') > content = cursor.fetchall() > > > Bzzt! Nope. Cursor.fetchall() returns a list (length 1) or tuples > (length 1) here, so this should be > > content = cursor.fetchall()[0][0] > > or, perhaps better > > content = cursor.fetchone()[0] > > > I tried both of these, and they, too, gave me the same identical image > of the url, not the image I am after. > I'm having a problem believing this, but I don't think you are lying. Are you *sure* you have stored the correct omages in your database? The fact remains that cursor.fetchall() will return a list containing one tuple containing (what you believe is) your image, so there is NO way your code above can do what you want. I can therefore only assume that this is a CGI script and that your web server does something *extremely* funky when it gets a CGI output it isn't expecting. But this doesn't make a lot of sense. > > > You really don't understand how the web works, do you? > > > I am just really, really, stupid, Steve. Please forgive me for being so > stupid. But I am persistent. And I have built dozens of Web site with > images. > Stupidity and ignorance are entirely different things, and you (current) ignorance in no way implies stupidity. We all have to learn. However, if you bring up one of the pages from one of your many web sites containing an image, and get your browser to display the HTML of that page you will surely find that the image does not appear direectly in the HTML, but instead appears as a tag in the HTML. Something like: though the src attribute doesn't really need to be that complex. > > In order to include an image in a page your browser must make TWO > requests. The first is for an HTML page that will reference the > image in this way: > > > > Seeing this img tag causes the browser to make a SECOND request, > which the script I corrected above should respond to with an image. > > The bytestream is critical in the image response. Even one misplaced > byte will mess things up terribly. > > > In my stupidity, I have assumed you meant this: > > content = col_fields[0][14].tostring() > print '

' > Well, here I have no idea what the content of your database might be, but if the fifteenth column you retrieve is the web server path to the graphic, that should be right except for the spaces around it, which might give trouble. You might consider instead content = col_fields[0][14].tostring() print '

' % content to omit them. > Obviously I am wrong. Could you please give me a little more insight? > Forget HTML for now. If you direct your browser to the URL on which your server is serving the graphic then it should be displayed in the browser window. Until that happy condition pertains, we are stabbing around in the dark. > BTW, when we are finally done with this, I will write a nice > how-to (since there is not one in python, while php has some > nice ones) on how to do this, and give you and Gabrielle all > your due credit. I will post it to this list, because that is > sure to rank highly in google right away. > Victor > > That's great, though hardly the point of the exercise. I think > Google already know about Gabriel (*not* Gabrielle) and me already ... > > > Well, I just thought it might be a good way to get the information out, > since it is not out there yet. And I believe it is only proper to give > credit where credit is due. I would not be doing this to praise you. > Rather, I would be doing this because it is needed, and I would feel > wrong for not crediting those who deserve credit. Please let me know, > however, if you feel otherwise. It's not that I mind, but I do feel that this knowledge is already available, though clearly I might be wrong ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gagsl-py2 at yahoo.com.ar Thu Apr 3 20:50:03 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 21:50:03 -0300 Subject: id functions of ints, floats and strings References: Message-ID: En Thu, 03 Apr 2008 19:27:47 -0300, escribi?: > Hi all, > > I've been playing around with the identity function id() for different > types of objects, and I think I understand its behaviour when it comes > to objects like lists and tuples in which case an assignment r2 = r1 > (r1 refers to an existing object) creates an alias r2 that refers to > the same object as r1. In this case id(r1) == id(r2) (or, if you > like: r1 is r2). However for r1, r2 assigned as follows: r1 = [1, 2, > 3] and r2 = [1, 2, 3], (r1 is r2) is False, even if r1==r2, > etc. ...this is all very well. Therefore, it seems that id(r) can be > interpreted as the address of the object that 'r' refers to. > > My observations of its behaviour when comparing ints, floats and > strings have raised some questions in my mind, though. Consider the > following examples: > > ######################################################################### > > # (1) turns out to be true > a = 10 > b = 10 > print a is b ...only because CPython happens to cache small integers and return always the same object. Try again with 10000. This is just an optimization and the actual range of cached integer, or whether they are cached at all, is implementation (and version) dependent. (As integers are immutable, the optimization *can* be done, but that doesn't mean that all immutable objects are always shared). > # (2) turns out to be false > f = 10.0 > g = 10.0 > print f is g Because the above optimization isn't used for floats. The `is` operator checks object identity: whether both operands are the very same object (*not* a copy, or being equal: the *same* object) ("identity" is a primitive concept) The only way to guarantee that you are talking of the same object, is using a reference to a previously created object. That is: a = some_arbitrary_object b = a assert a is b The name `b` now refers to the same object as name `a`; the assertion holds for whatever object it is. In other cases, like (1) and (2) above, the literals are just handy constructors for int and float objects. You have two objects constructed (a and b, f and g). Whether they are identical or not is not defined; they might be the same, or not, depending on unknown factors that might include the moon phase; both alternatives are valid Python. > # (3) checking if ids of all list elements are the same for different > cases: > > a = 3*[1]; areAllElementsEqual([id(i) for i in a]) # True > b = [1, 1, 1]; areAllElementsEqual([id(i) for i in b]) # True > f = 3*[1.0]; areAllElementsEqual([id(i) for i in f]) # True > g = [1.0, 1.0, 1.0]; areAllElementsEqual([id(i) for i in g]) # True > g1 = [1.0, 1.0, 0.5+0.5]; areAllElementsEqual([id(i) for i in g1]) # > False Again, this is implementation dependent. If you try with a different Python version or a different implementation you may get other results - and that doesn't mean that any of them is broken. > # (4) two equal floats defined inside a function body behave > differently than case (1): > > def func(): > f = 10.0 > g = 10.0 > return f is g > > print func() # True Another implementation detail related to co_consts. You shouldn't rely on it. > I didn't mention any examples with strings; they behaved like ints > with respect to their id properties for all the cases I tried. You didn't try hard enough :) py> x = "abc" py> y = ''.join(x) py> x == y True py> x is y False Long strings behave like big integers: they aren't cached: py> x = "a rather long string, full of garbage. No, this isn't garbage, just non sense text to fill space." py> y = "a rather long string, full of garbage. No, this isn't garbage, just non sense text to fill space." py> x == y True py> x is y False As always: you have two statements constructing two objects. Whether they return the same object or not, it's not defined. > While I have no particular qualms about the behaviour, I have the > following questions: > > 1) Which of the above behaviours are reliable? For example, does a1 = > a2 for ints and strings always imply that a1 is a2? If you mean: a1 = something a2 = a1 a1 is a2 then, from my comments above, you should be able to answer: yes, always, not restricted to ints and strings. If you mean: a1 = someliteral a2 = someliteral a1 is a2 then: no, it isn't guaranteed at all, nor even for small integers or strings. > 2) From the programmer's perspective, are ids of ints, floats and > string of any practical significance at all (since these types are > immutable)? The same significance as id() of any other object... mostly, none, except for debugging purposes. > 3) Does the behaviour of ids for lists and tuples of the same element > (of type int, string and sometimes even float), imply that the tuple a > = (1,) takes (nearly) the same storage space as a = 10000*(1,)? (What > about a list, where elements can be changed at will?) That's a different thing. A tuple maintains only references to its elements (as any other object in Python). The memory required for a tuple (I'm talking of CPython exclusively) is: (a small header) + n * sizeof(pointer). So the expression 10000*(anything,) will take more space than the singleton (anything,) because the former requires space for 10000 pointers and the latter just one. You have to take into account the memory for the elements themselves; but in both cases there is a *single* object referenced, so it doesn't matter. Note that it doesn't matter whether that single element is an integer, a string, mutable or immutable object: it's always the same object, already existing, and creating that 10000-uple just increments its reference count by 10000. The situation is similar for lists, except that being mutable containers, they're over-allocated (to have room for future expansion). So the list [anything]*10000 has a size somewhat larger than 10000*sizeof(pointer); its (only) element increments its reference count by 10000. -- Gabriel Genellina From arnodel at googlemail.com Thu Apr 24 16:43:28 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 24 Apr 2008 21:43:28 +0100 Subject: Class Inheritance - What am I doing wrong? References: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> Message-ID: Brian Munroe writes: > My example: > > class A(object): > > def __init__(self, name): > self.__name = name > > def getName(self): > return self.__name > > class B(A): > > def __init__(self,name=None): > super(A,self).__init__() > > def setName(self, name): > self.__name = name > > if __name__ == '__main__': > > a = A('class a') > print a.getName() > > b = B('class b') > print b.getName() > > b.setName('class b, reset') > print b.getName() > > I get the following error: > > mtinky:~ brian$ python teste.py > class a > Traceback (most recent call last): > File "teste.py", line 23, in > print b.getName() > File "teste.py", line 7, in getName > return self.__name > AttributeError: 'B' object has no attribute '_A__name' > > Am I *not* using super() correctly? Also, did I define my the class B > constructor correctly? You have fallen victim to the Name Mangling Trap [1]. Replace the leading double underscore in the __name attribute with a single one, and Python shall calm down and let your code behave as you expect it to. That is, if you also pass the name parameter to super(A,self).__init__ in B's __init__ method [1] http://docs.python.org/ref/atom-identifiers.html -- Arnaud From sasha at theotheralex.com Fri Apr 4 01:47:48 2008 From: sasha at theotheralex.com (shurik) Date: Thu, 3 Apr 2008 22:47:48 -0700 (PDT) Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: that's great! thanks for putting this together. what about the inspect module? and particularly getsource :) On Apr 1, 6:15?pm, AK wrote: > Hello, > > I find that I learn easier when I go from specific examples to a more > general explanation of function's utility and I made a reference guide > that will eventually document all functions, classes and methods in > Python's Standard Library. For now, I covered about 20 most important > modules. I will be adding more modules and eventually I'll cover > everything. Here's my progress so far, let me know if this is useful; > I'll be glad to hear comments/suggestions/etc: > > http://www.lightbird.net/py-by-example/ > > -- > ? -ak > ? ?Tobu |http://www.lightbird.net/tobu/| Freeform DB / Tagger / PIM From roy at panix.com Tue Apr 29 09:32:46 2008 From: roy at panix.com (Roy Smith) Date: Tue, 29 Apr 2008 09:32:46 -0400 Subject: list.reverse() References: <4816e26a$0$30938$426a74cc@news.free.fr> Message-ID: In article <4816e26a$0$30938$426a74cc at news.free.fr>, Bruno Desthuilliers wrote: > Mark Bryan Yu a ?crit : > > This set of codes works: > > > >>>> x = range(5) > >>>> x.reverse() > >>>> x > > [4, 3, 2, 1, 0] > > > > But this doesn't: > > > >>>> x = range(5).reverse() > >>>> print x > > None > > This works just as expected - at least for anyone having read the doc. > > > Please explain this behavior. range(5) returns a list from 0 to 4 and > > reverse just reverses the items on the list that is returned by > > range(5). Why is x None (null)? > > Because that's what list.reverse() returns. Call it a wart if you want > (FWIW, I do), but at least that's well documented. The reasoning goes along the lines of, "reverse in place is an expensive operation, so we don't want to make it too easy for people to do". At least that's the gist of what I got out of the argument the many times it has come up. And, yes, I agree with Bruno that it's a wart. What you want to do is look at the reversed() function. Not only does it return something (other than Null), but it is much faster because it doesn't have to store the reversed list anywhere. What it returns is an iterator which walks the list in reverse order. If you really want it as a list, you can turn it into one (with the list() constructor), or you can just iterate over it with a for loop. Same with list.sort() vs. the global sorted(). >>> range(5) [0, 1, 2, 3, 4] >>> reversed(range(5)) >>> list(reversed(range(5))) [4, 3, 2, 1, 0] >>> for i in reversed(range(5)): ... print i ... 4 3 2 1 0 >>> From hopeorpha308 at gmail.com Sun Apr 27 07:44:56 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:44:56 -0700 (PDT) Subject: dvdfabplatinum crack Message-ID: dvdfabplatinum crack http://wga-cracks.crackkey.net From mcat.schaefer at gmx.de Mon Apr 7 08:19:03 2008 From: mcat.schaefer at gmx.de (=?ISO-8859-1?Q?Michael_Sch=E4fer?=) Date: Mon, 7 Apr 2008 05:19:03 -0700 (PDT) Subject: Calling CVF-Fortran-dll with ctypes and simple structure Message-ID: <60915c2d-0c0d-42fc-8b02-5fb58e13a20c@p25g2000hsf.googlegroups.com> Hi all, I deal with the old problem passing characters from python to a fortran dll build with CFV6.6c. I reduced our complex structure to a simple one. Here is the Fortran code: SUBROUTINE DEMO2L(s) C sample for calling CVF6.6c-DLLs from C vb/vba/python with simple structure !DEC$ ATTRIBUTES DLLEXPORT::DEMO2L TYPE rcDEMO INTEGER a REAL b CHARACTER c*9 END TYPE TYPE(rcDEMO) :: s C WRITE(*,*) s.a, s.b, s.c C sample calculation: s.a = s.a*10 s.b = s.b**2.3 s.c = 'Sample' RETURN END From VB the calling is very simple: Declare Sub DEMO2L Lib "release\demo1l.dll" (ByRef k As rcDEMO) Type rcDEMO a As Long b As Single c As String * 9 End Type Dim k As rcDEMO Sub run() k.a = 2 k.b = 3# k.c = "Test" Call DEMO2L(k) Debug.Print k.a, k.b, k.c End Sub and result to: " 20 12,5135 Sample" When I try this from python: from ctypes import * class rcDemo(Structure): _fields_ = [ ('a', c_int), ('b', c_float), ('c', c_char_p), ] mydll = windll.LoadLibrary("release\DEMO1L.DLL") rc = rcDemo() rc.a = 2 rc.b = 3. rc.c = "Test56789" mydll.DEMO2L(byref(rc)) print rc.a print rc.b print ">" + rc.c + "<" I got " 2 3.000000 ???" from the debug print in Fortran and 20 12.513502121 Traceback (most recent call last): File "run_demo.py", line 21, in ? print ">" + rc.c + "<" ValueError: invalid string pointer 0x706D6153 from Python. When passing only the string in a argument list instead of the structure and considering to pass the length of the string as 2nd argument I am be able to send this characters to the dll and receive a changed value back. Have anyone an idea or perhaps a solution ;-) doing this in a structure? Thank you! Michael From sjmachin at lexicon.net Mon Apr 21 17:42:45 2008 From: sjmachin at lexicon.net (John Machin) Date: Mon, 21 Apr 2008 21:42:45 GMT Subject: module error in Vista -- works as administrator In-Reply-To: <815eb7f8-6f00-469d-bb15-e1d9680d9646@e39g2000hsf.googlegroups.com> References: <815eb7f8-6f00-469d-bb15-e1d9680d9646@e39g2000hsf.googlegroups.com> Message-ID: <480d0a52$1@news.mel.dft.com.au> sawilla wrote: > First, I'm new to Python. I'm getting and error when I run Python > 2.5.2 as a regular user in Vista but not when I run Python as an > administrator. > > For example, if I type "import numpy" after I launch python from an > adminstrator-privileged command window it loads fine. However, from a > regular-user command window I get: > >>>> import numpy > Traceback (most recent call last): > File "", line 1, in > ImportError: No module named numpy > Log on as administrator, start python in command window and do this: import sys sys.path # shows where python is looking for importables import numpy import os.path print os.path.abspath(numpy.__file__) # shows where it found numpy Log on as ordinary user, start python in command window and do this: import sys sys.path # check how this is different from the admin's sys.path If you can't see what to do after that, come back here with the output from those steps. HTH, John From grante at visi.com Thu Apr 17 09:52:37 2008 From: grante at visi.com (Grant Edwards) Date: Thu, 17 Apr 2008 08:52:37 -0500 Subject: Finally had to plonk google gorups. References: <4806bcec$0$25058$607ed4bc@cv.net> Message-ID: On 2008-04-17, John Salerno wrote: > Grant Edwards wrote: >> This morning almost half of c.l.p was spam. In order to try to >> not tar both the benign google group users and the malignant >> ones with the same brush, I've been trying to kill usenet spam >> with subject patterns. But that's not a battle you can win, so >> I broke down and joined all the other people that just killfile >> everything posted via google.groups. >> >> AFAICT, if you're a google groups user your posts are not being >> seen by many/most experienced (read "non-google-group") users. >> This is mainly the fault of google who has refused to do >> anything to stem the flood of span that's being sent via Google >> Groups. > > How exactly do you killfile an entire source like that? I use slrn, so I put this in my .score file: Score:: = -9999 Organization: http://groups.google.com Message-ID: .*googlegroups.com > Is it possible with Thunderbird? I've no idea. -- Grant Edwards grante Yow! UH-OH!! I put on at "GREAT HEAD-ON TRAIN visi.com COLLISIONS of the 50's" by mistake!!! From jesus.aguillon at gmail.com Sun Apr 13 16:26:29 2008 From: jesus.aguillon at gmail.com (Jaguillo) Date: Sun, 13 Apr 2008 13:26:29 -0700 (PDT) Subject: PythonWin Print Problem.. Build 210 References: <%cqMj.118543$yE1.5692@attbi_s21> Message-ID: <0ca21bfd-5eb1-45da-ad1d-094367590d25@z24g2000prf.googlegroups.com> On Apr 13, 9:07 am, "Hutch" wrote: > "Roger Upole" wrote in message > > news:mailman.346.1208051713.17997.python-list at python.org... > > > > > > > "Hutch" wrote in message > >news:H29Mj.117410$yE1.54267 at attbi_s21... > >> PythonWin has been a very good ide from early version thru 2.4. > > >> All work ok on THREE of my computers with THREE different HP printers. > > >> Now comes 2.5. > >> Every thing seems to work the same except when I want to print out a copy > >> of the source code of my project (about 38 pages) > > >> Version 2.5 acts like it is going to print out the source code but > >> instead > >> prints from several 100 to over 2000 BLANK PAGES pages and no source. > > >> Attempting to print out Source on SAME equipment (computers and printers) > >> using 2.4 (WITH NO CHANGES TO EQUIPMENT OR SOFTWARE ) results in > >> proper print out of source. > > >> Problem has been reported via direct and SourceForge but no response. > > >> Any body else having the same problem? > > >> -- > >>http://mail.python.org/mailman/listinfo/python-list > > > Did you see the response to the bug report on SF ? > >http://sourceforge.net/tracker/index.php?func=detail&aid=1907148&grou... > > > There is also some more info in this thread on the python-win32 mailing > > list: > >http://mail.python.org/pipermail/python-win32/2006-December/005397.html > > > Roger > > Sorry to report after uninstalling both Python 2.5 and Pythonwin 2.5 and > reinstalling.. THE PROBLEM IS STILL WITH US... Did you make the change that Roger suggested in the file view.py per the link: http://mail.python.org/pipermail/python-win32/2006-December/005397.html It has been working for me on Python 2.5. -Jesus From torriem at gmail.com Thu Apr 17 12:27:29 2008 From: torriem at gmail.com (Michael Torrie) Date: Thu, 17 Apr 2008 10:27:29 -0600 Subject: py3k s***s In-Reply-To: References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: <48077A71.1030709@gmail.com> Aaron Watters wrote: > What I'm saying is that, for example, there are a lot > of cool tools out there for using Python to manipulate > postscript and latex and such. Most of those tools > require no maintenance, and the authors are not paying > any attention to them, and they aren't interested in > messing with them anymore. What makes you think these tools are all going to mysteriously stop working? Python 2.x will be around for a long, long time. Currently there are still Python 1.5 apps that are still in use and circulation and, with Python 1.5 installed, still work fine. The same for Python 2.x. Honestly I don't understand all this FUD over the move to Python 3.x Those that want/need to migrate will. Others won't have to. What's the big deal? Further, 90% of these little, finished utilities are pure python, and so converting them to Python 3.x is a trivial mechanical conversion if the maintainer cared. From deets at nospam.web.de Wed Apr 30 10:53:57 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 30 Apr 2008 16:53:57 +0200 Subject: computing with characters In-Reply-To: <87tzhjy4u2.fsf@physik.rwth-aachen.de> References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> <87tzhjy4u2.fsf@physik.rwth-aachen.de> Message-ID: <67rfg6F2qrcooU1@mid.uni-berlin.de> > However, join() is really bizarre. The list rather than the > separator should be the leading actor. Certainly *not*! This would be the way ruby does it, and IMHO it does not make sense to add join as a string-processing related method/functionality to a general purpose sequence type. And as others have pointed out, this would also mean that e.g. def sgen(): for i in xrange(100): yield str(i) sgen.join(":") wouldn't work or even further spread the join-functionality over even more objects. An argument for the original ord/chr debate btw is orthogonality: if you want ord to be part of a string, you'd want chr to be part of ints - which leads to ugly code due to parsing problems: (100).chr() Diez From mysakjs at gmail.com Fri Apr 25 18:16:07 2008 From: mysakjs at gmail.com (JMysak) Date: Fri, 25 Apr 2008 15:16:07 -0700 (PDT) Subject: newbie question Message-ID: I'm working with the HTMLParser module and have implemented HTMLParser.handle_starttag() and I see there is a separate handle_data method (which can be implemented), but I am not clear how to tie this together with a given start tag, so I only get the data I want. For example, I'd like to get a handle on the character data ( the number 1) immediately after the following start tag 1
. . . Any ideas? From M8R-yfto6h at mailinator.com Sun Apr 27 23:09:58 2008 From: M8R-yfto6h at mailinator.com (Mark Tolonen) Date: Sun, 27 Apr 2008 20:09:58 -0700 Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> <48131f57$0$14357$e4fe514c@news.xs4all.nl> <4ca7b83c-0ca4-4e38-95e5-264780d30ec0@56g2000hsm.googlegroups.com> Message-ID: wrote in message news:4ca7b83c-0ca4-4e38-95e5-264780d30ec0 at 56g2000hsm.googlegroups.com... > On Apr 26, 7:25 am, Irmen de Jong wrote: >> s0s... at gmail.com wrote: >> > Until now, I've been >> > doing this little trick: >> >> > data = client.recv(256) >> > new = data >> > while len(new) == 256: >> > new = client.recv(256) >> > data += new >> >> Are you aware that recv() will not always return the amount of bytes >> asked for? >> (send() is similar; it doesn't guarantee that the full buffer you pass to >> it will be >> sent at once) >> >> I suggest reading >> this:http://www.amk.ca/python/howto/sockets/sockets.html >> >> --irmen > > So every time I use I want to send some thing, I must use > > totalsent = 0 > while sent < len(data): > sent = sock.send(data[totalsent:]) > totalsent += sent > > instead of a simple sock.send(data)? That's kind of nasty. Also, is it > better then to use sockets as file objects? Maybe unbuffered? I think you meant: while totalsent < len(data): Python also has the sendall() function. -Mark From ellingt8877 at gmail.com Mon Apr 28 01:49:34 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:49:34 -0700 (PDT) Subject: keygen studio Message-ID: <1e3b1aa9-e47a-49c6-af28-fd1d8737f437@z24g2000prf.googlegroups.com> keygen studio http://crack.cracksofts.com From cool.sumitc at gmail.com Mon Apr 7 02:54:46 2008 From: cool.sumitc at gmail.com (Sumit) Date: Sun, 6 Apr 2008 23:54:46 -0700 (PDT) Subject: while-loops enter the last time after condition is filled? References: Message-ID: <8b3cf9b5-4add-4f13-9f18-7f16c0384d94@n14g2000pri.googlegroups.com> On Apr 6, 4:53?am, skanem... at yahoo.se wrote: > it seems to me from my results that when i use a while-loop it will > execute once after the condition is met. Perhaps your condition is wrong. Please provide the code where this occured. From kay.schluehr at gmx.net Sat Apr 12 11:51:04 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 12 Apr 2008 08:51:04 -0700 (PDT) Subject: str(bytes) in Python 3.0 References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> Message-ID: <806cf1da-8f06-4fff-8437-7f1ca1ff9472@k10g2000prm.googlegroups.com> On 12 Apr., 16:29, Carl Banks wrote: > > And making an utf-8 encoding default is not possible without writing a > > new function? > > I believe the Zen in effect here is, "In the face of ambiguity, refuse > the temptation to guess." How do you know if the bytes are utf-8 > encoded? How many "encodings" would you define for a Rectangle constructor? Making things infinitely configurable is very nice and shows that the programmer has worked hard. Sometimes however it suffices to provide a mandatory default and some supplementary conversion methods. This still won't exhaust all possible cases but provides a reasonable coverage. From fetchinson at googlemail.com Wed Apr 16 22:25:51 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Wed, 16 Apr 2008 19:25:51 -0700 Subject: index of list of lists In-Reply-To: <1208398552l.41837l.0l@ns.bitcarrier.eu> References: <1208398552l.41837l.0l@ns.bitcarrier.eu> Message-ID: > yes, there's a thread with the same title, but I believe mine is more > appropriate title. > so, as much as I search on the web, read manuals, tutorials, mail-lists > (including this one) I cannot figure it out how to search a string in a > list of lists. > like this one: > > someList = [['somestring', 1, 2], ['oneother', 2, 4]] > > I want to search "somestring" in someList which is in practice a list > of aprox. 200 lists. (hey, I'm a newbie python programmer, don't judge > me). > is the list.index the wrong approach? > should I use numpy, numarray, something else? > can anyone, be kind and help me with this? someList = [['somestring', 1, 2], ['oneother', 2, 4]] for alist in someList: if alist[0] == 'somestring': print "Found it at index %d" % someList.index( alist ) # if you know it will only occur once you might say: break HTH, Daniel From cyberco at gmail.com Tue Apr 8 14:51:53 2008 From: cyberco at gmail.com (Berco Beute) Date: Tue, 8 Apr 2008 11:51:53 -0700 (PDT) Subject: Google App Engine References: Message-ID: <3b6737c8-9d42-4218-ac60-01df2f578746@p39g2000prm.googlegroups.com> It's wonderful news for Python. It will definitely be a boost for Python's (and Django's) popularity. Python finally seems to be on every developers mind at the moment. Looks like it's showtime for Python! From bg at bg.fr Tue Apr 8 11:16:41 2008 From: bg at bg.fr (Bruno GUERPILLON) Date: Tue, 8 Apr 2008 17:16:41 +0200 Subject: List open files Message-ID: <47fb8d54$0$15068$426a74cc@news.free.fr> Hi, I'd like, in a WIN32 environment, list all open files. Anyone got a clue how to do this ? Regards, Bruno. From bruno.desthuilliers at gmail.com Thu Apr 17 14:42:56 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Thu, 17 Apr 2008 11:42:56 -0700 (PDT) Subject: noobie question about mailman References: <2008041714045350073-elgeee@yahoocom> Message-ID: <9b791903-d935-46fd-9ec4-49df4ed273d5@2g2000hsn.googlegroups.com> On 17 avr, 20:04, lg wrote: > Hello, > > I'm pretty new to usenet and totally new to python, so.. hopefully i > won't offend anyone with my naivete. I work at a non-profit > organization where we use mailman for our email lists, and i've > inhereted the task of being list administrator from my > sadly-recently-and-unjustly-terminated coworker. > > Anyway, I'd to know more about working with mailman from the command > line. For example, I know it must not be toooo complex to have mailman > export a csv doc of all the members of a lis (instead of having to look > through members using the web interface for administrators). Can > anyone point me in the direction of a forum, email list, or good > tutorial to get me started? Any insight *mucly* appreciated! A general rule is to start with the project's page, doc and mailinglist. Here we have (first hit on google for 'mailman'): http://www.gnu.org/software/mailman/ which itself points to - amongst other ressources - the documentation: http://www.gnu.org/software/mailman/docs.html and the mailing list: http://www.gnu.org/software/mailman/lists.html All questions related to mailman itself should go there, since that's where you'll find the most knowledgeable peoples. And don't forget to read the doc before posting your questions - not understanding some point in the doc is ok, failing to find something in the doc is ok, but failing to *read* the doc first is a big mistake. If the answers to your questions wrt/ mailmain require more Python knowledge than you actually have, then start with Python's doc (and the tutorial), then post here, and we'll gladly help if we can. Also, since you mention being new to usenet, the following might be a good read too: http://catb.org/~esr/faqs/smart-questions.html NB: don't take what's written there to the letter - there are hopefully some newsgroups that are very tolerant and newbie-friendly (like this one here) - but understanding the overall spirit may help you getting best answers. HTH Bruno From gagsl-py2 at yahoo.com.ar Tue Apr 8 00:10:52 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 08 Apr 2008 01:10:52 -0300 Subject: Adding Images To MySQL References: <4dc0cfea0804050732x7dc2ac41n64d56dda9da27a82@mail.gmail.com> <4dc0cfea0804071117n49dd6faam90032dbc787487e5@mail.gmail.com> Message-ID: En Mon, 07 Apr 2008 15:17:26 -0300, Victor Subervi escribi?: >> sql = "insert into PRODUCTS (PRODID, NAME, DESCRIPTION) " \ >> "values (%s,%s,%s);" >> cursor.execute(sql, (prodid, prodname, description)) >> >> and it works fine. >> >> Note that execute has two arguments: first, a string with the sql >> statement text; second, a tuple containing the values. The %s in the sql >> text are placeholders, they're replaced with the corresponding value >> from >> the second argument. And there is no ' anywhere. > > Well, what I did, that now works, was essentially what you suggested, and > simply assigned null values to variables that accept null values in the > database. That works. What I was trying to do was build up just those > variables that were to be updated or entered, and supply only those > arguments. At this point it is rather academic, but can that be done? Suppose you have the list of non-null column names in a variable `col_names` and their values in another list `col_values` column_part = ','.join(col_names) # all,column,names,with,commas pct_part = ','.join('%s' for _ in col_names) # as many "%s" as columns sql = "insert into PRODUCTS (%s) values (%s);" % (column_part, pct_part) cursor.execute(sql, col_values) Perhaps you find more convenient to build a dictionary with column name, value: ok, then col_names above would be the keys() from the dictionary, and you can figure out how to get col_values. > Amazingly (because I thought I had tested this) both the escape string > and > the db Binary work now. Glad to see that. > I said it did not work in the other page, but now it does. Anyway, what > gets > uploaded is a binary string. How can I convert that into a pretty > picture? By serving it as the appropiate MIME type, image/jpeg by example. You don't have to "convert" anything, just return the same thing previously stored in the database. Again, test locally first: see if you can store a picture in the database and then retrieve it again without problems (locally, not thru the web). Next step would be to use the web server but no database access, just reading a picture from a file: content = open('image.jpg', 'rb').read() print "Content-Type: image/jpeg\nContent-Length: %d\n" % len(content) print content The last step would be to replace the first line with a database query. -- Gabriel Genellina From johnjsal at gmailNOSPAM.com Wed Apr 23 23:12:33 2008 From: johnjsal at gmailNOSPAM.com (John Salerno) Date: Wed, 23 Apr 2008 23:12:33 -0400 Subject: Lists: why is this behavior different for index and slice assignments? In-Reply-To: <480e832d@news.mel.dft.com.au> References: <480d435b$0$11643$607ed4bc@cv.net> <480e7f61$0$25046$607ed4bc@cv.net> <480e832d@news.mel.dft.com.au> Message-ID: <480ffaae$0$11639$607ed4bc@cv.net> John Machin wrote: > Deletion occurs *only* in the corner case where there are no "assigned > elements" i.e. only if the RHS list (sequence) is *empty*. Oh, it was my understanding that deletion always occurs, even when the section is being assigned a non-empty value, i.e. delete the slice and insert new value. Otherwise > there would be no point at all in the language having assignment to a > slice -- del L[0:2] would suffice. Right, but I'm wondering why a statement like L[0:2] = [] doesn't assign an empty list as the new element in L. For example: L = [1, 2, 3, 4, 5] L[0:2] = [] Why doesn't L now equal [[], 3, 4, 5] as it does with an index assignment? > >>> L[0:2] = tuple('foobar') > >>> L > ['f', 'o', 'o', 'b', 'a', 'r', 3, 4, 5] Hmm...why doesn't L equal [('f', 'o', 'o', 'b', 'a', 'r'), 3, 4, 5] ? Shouldn't L be a 4 item list instead of 9? From sales024 at aaa-replica-watch.com Tue Apr 1 00:44:44 2008 From: sales024 at aaa-replica-watch.com (sales024 at aaa-replica-watch.com) Date: Mon, 31 Mar 2008 21:44:44 -0700 (PDT) Subject: Cheap Oris TT3 Watches Replica - Oris Watches Wholesale Message-ID: Cheap Oris TT3 Watches Replica - Oris Watches Wholesale AAA Replica Watches : http://www.watches-replicas.com Oris Watches Brands : http://www.watches-replicas.com/oris-watches.html Replica Oris TT3 Watches : http://www.watches-replicas.com/oris-tt3-watches.html China largest replica watches wholesaler, wholesale up to 80% of Oris TT3 Replica Watches and Oris TT3 Fake Watch. The most famous Swiss brand name watches you can find, replica Oris TT3 Watches and fake Oris TT3 Watches are also available. All our Oris TT3 Watches replicas are crafted in high quality, You will get great profite by ordering our good cheap watches. Oris TT3 Watches All Products : Oris TT3 Day Date Titanium Mens Watch 635-7589-7067MB : http://www.watches-replicas.com/oris-tt3-day-date-watch-635-7589-7067MB-3455.html Oris TT3 Day Date Titanium Black Rubber Mens Watch 635-7588-7069RS : http://www.watches-replicas.com/oris-tt3-day-date-watch-63575887069RS-3456.html Oris TT3 Day Date Titanium Mens Watch 635-7589-7067RS : http://www.watches-replicas.com/oris-tt3-day-date-watch-635-7589-7067RS-3457.html Oris TT3 Day Date Titanium Mens Watch 635-7589-7064RS : http://www.watches-replicas.com/oris-tt3-day-date-watch-635-7589-7064RS-3458.html Oris TT3 Day Date Titanium Mens Watch 635-7589-7064MB : http://www.watches-replicas.com/oris-tt3-day-date-watch-635-7589-7064MB-3459.html Oris TT3 Day Date Titanium Mens Watch 635-7588-7069MB : http://www.watches-replicas.com/oris-tt3-day-date-watch-635-7588-7069MB-3460.html Oris TT3 Day Date Titanium Mens Watch 635-7588-7067RS : http://www.watches-replicas.com/oris-tt3-day-date-watch-635-7588-7067RS-3461.html Oris TT3 Day Date Titanium Mens Watch 635-7588-7064MB : http://www.watches-replicas.com/oris-tt3-day-date-watch-635-7588-7064MB-3462.html Oris TT3 Day Date Titanium Mens Watch 635-7589-7067MB : http://www.watches-replicas.com/oris-tt3-day-date-watch-635-7588-7067MB-3463.html The Same Oris Replica Watches Series : Oris Williams F1 Watches : http://www.watches-replicas.com/oris-williams-f1-watches.html Oris Frank Sinatra Watches : http://www.watches-replicas.com/oris-frank-sinatra-watches.html Oris Artelier Watches : http://www.watches-replicas.com/oris-artelier-watches.html Oris Big Crown Watches : http://www.watches-replicas.com/oris-big-crown-watches.html Oris Flight Timer Watches : http://www.watches-replicas.com/oris-flight-timer-watches.html Newly Added Oris Watches : http://www.watches-replicas.com/newly-added-oris-watches.html Oris Divers Watches : http://www.watches-replicas.com/oris-divers-watches.html Oris TT3 Watches : http://www.watches-replicas.com/oris-tt3-watches.html From gagsl-py2 at yahoo.com.ar Mon Apr 21 10:17:03 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 11:17:03 -0300 Subject: how to pass C++ object to another C++ function via Python function References: <1810b155-5598-4f17-a8e9-e4aa848db5de@i36g2000prf.googlegroups.com> Message-ID: En Mon, 21 Apr 2008 10:24:15 -0300, grbgooglefan escribi?: > I am trying to pass a C++ object to Python function. This Python > function then calls another C++ function which then uses this C++ > object to call methods of that object's class. > > I tried something like this, but it did not work, gave core dump. You can't pass any arbitrary C object to a Python function. In this case you can use a PyCObject, a Python box around a void* pointer. See http://docs.python.org/api/cObjects.html > // compile this Python function using PyRun_String & get its pointer > by PyObject_GetAttrString. > // Later call it as below: > myclass myobj(23); > PyObject *pTuple = 0; > pTuple = PyTuple_New(2); > PyTuple_SetItem(pTuple,0,PyString_FromString("NAME")); // for t167 > parameter > PyObject *inputarg = Py_BuildValue("OO&",pTuple,myobj); // for > classobj parameter > > result = PyObject_CallObject(pPyEvalFunction,inputarg); > } > > How can I pass this class object to Python function? > Is it possible to set it in tuple using PyTuple_SetItem, because I may > have varying number of arguments for my Python functions & that's why > I can't use Py_BuildValue. You have to check every call for errors, and pay attention to the reference counts! The argument passing is wrong. You never set the second tuple element. An easier way is using PyObject_CallFunctionObjArgs(function, arg1, arg2, NULL) -- Gabriel Genellina From sturlamolden at yahoo.no Sun Apr 20 10:22:41 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sun, 20 Apr 2008 07:22:41 -0700 (PDT) Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> Message-ID: <7cbe5fed-a9c5-46ef-82e9-90340f676b90@l42g2000hsc.googlegroups.com> On Apr 20, 2:46 pm, "Hank @ITGroup" wrote: > That is my question, after ``del``, sometimes the memory space returns > back as nothing happened, sometimes not... ... > What exactly was happening??? Python has a garbage collector. Objects that cannot be reached from any scope is reclaimed, sooner or later. This includes objects with reference count of zero, or objects that participate in unreachable reference cycles. Since Python uses a reference counting scheme, it does not tend to accumulate so much garbage as Java or .NET. When the reference count for an object drops to zero, it is immediately freed. You cannot control when Python's garbage collector frees an object from memory. What del does is to delete the object reference from the current scope. It does not delete the object from memory. That is, the del statement decrements the reference count by one, and removes the reference from the current scope. Whether it should removed completely depends on whether someone else is using it. The object is not reclaimed unless the reference count has dropped all the way down to zero. If there still are references to the object other places in your program, it is not reclaimed upon your call to del. From stefan_ml at behnel.de Fri Apr 11 05:59:39 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 11 Apr 2008 11:59:39 +0200 Subject: CDATA and lxml In-Reply-To: <5ebe3201-80a6-45ba-8b88-e8ece6883efa@w8g2000prd.googlegroups.com> References: <5ebe3201-80a6-45ba-8b88-e8ece6883efa@w8g2000prd.googlegroups.com> Message-ID: <47FF368B.4030708@behnel.de> Silfheed wrote: > So first off I know that CDATA is generally hated and just shouldn't > be done, but I'm simply required to parse it and spit it back out. > Parsing is pretty easy with lxml, but it's the spitting back out > that's giving me issues. The fact that lxml strips all the CDATA > stuff off isnt really a big issue either, so long as I can create > CDATA blocks later with <>&'s showing up instead of <>& . > I've scoured through the lxml docs, but probably not hard enough, so > anyone know the page I'm looking for or have a quick how to? There's nothing in the docs because lxml doesn't allow you to create CDATA sections. You're not the first one asking that, but so far, no one really had a take on this. It's not as trivial as it sounds. Removing the CDATA sections in the parser is just for fun. It simplifies the internal tree traversal and text aggregation, so this would be affected if we allowed CDATA content in addition to normal text content. It's not that hard, it's just that it hasn't been done so far. Stefan From fetchinson at googlemail.com Thu Apr 10 13:14:29 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Thu, 10 Apr 2008 10:14:29 -0700 Subject: Python conventions In-Reply-To: References: Message-ID: > I assembled a good conventions set for Java. View it at > http://www.martinrinehart.com/articles/code-conventions.html (is that > better, Steve?) > > It followed a logical organization; it was built from four other > extensive (if not well-organized) convention sets and it scrupulously > avoided injecting my own biases. Where there were disagreements, they > were noted and the opposing viewpoints explained. > > I'm appointing myself project secretary of a similar effort for > Python, until we can find someone better qualified (Python experience > pre-dating my late '07 start would be better qualified). The > secretary's job is to ask questions and correctly record answers. > First question: > > global (e.g., what language for comments) > package > module > class > methods > data > function > statement > expression > variable > > Is this a good outer-level organization? > > For each topic, cover: > > documentation > naming convention(s) > format > > Second question: are the above the items we cover for each topic? > Others? I'm sorry to disappoint you but this project has already been completed: http://www.python.org/dev/peps/pep-0008/ Cheers, Daniel From deets at nospam.web.de Wed Apr 23 14:42:44 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 23 Apr 2008 20:42:44 +0200 Subject: Calling Python code from inside php In-Reply-To: References: Message-ID: <679e9oF2mti63U1@mid.uni-berlin.de> vijay schrieb: > Hi > I have a python code performing some computation for me.I have a > html page which passes certain argumnets to a php page.This php page > needs to pass on the value to the Python class and get the result > back. > How do I go about this?? Write a commandline-app in python, that does the work for you. Invoke that using php. Or use something like pyphp - but I haven't used it, can't comment on its usability/support etc. Diez From miki.tebeka at gmail.com Mon Apr 14 23:48:28 2008 From: miki.tebeka at gmail.com (Miki) Date: Mon, 14 Apr 2008 20:48:28 -0700 (PDT) Subject: How to get the version of a file References: Message-ID: <60199810-f80d-46e6-b402-df4707ff2d1a@w1g2000prd.googlegroups.com> Hello J, > Does anyone know how to get the version of an application on OS X (i.e. > the version string that appears in the "Version" field in the "Get Info" > window for an application)? > > I'm running OS 10.4.11, python 2.5. #!/usr/bin/env python from xml.etree.cElementTree import iterparse from os.path import isfile def get_version(app): info_file = "/Applications/%s.app/Contents/Info.plist" % app if not isfile(info_file): raise KeyError("No version file found") get = 0 for event, element in iterparse(open(info_file)): if get: return element.text if (element.tag == "key") and (element.text == "CFBundleVersion"): get = 1 raise KeyError("Can't find CFBundleVersion key") if __name__ == "__main__": from sys import argv print get_version(argv[1]) HTH, -- Miki http://pythonwise.blogspot.com From musiccomposition at gmail.com Tue Apr 15 22:41:16 2008 From: musiccomposition at gmail.com (Benjamin) Date: Tue, 15 Apr 2008 19:41:16 -0700 (PDT) Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <101680ba-a116-414b-8fff-c5b5bd2f4b65@p39g2000prm.googlegroups.com> Message-ID: <60a51c16-30fc-4d74-a50c-11f7f51138e7@b1g2000hsg.googlegroups.com> On Apr 15, 9:17 pm, lxlau... at gmail.com wrote: > On 11 abr, 20:31, sturlamolden wrote: > > > On Apr 11, 5:01 am, "Gabriel Genellina" > > wrote: > > > > Another annoying thing with the Qt license is that you have to choose it > > > at the very start of the project. You cannot develop something using the > > > open source license and later decide to switch to the commercial licence > > > and buy it. > > > Trolltech is afraid companies will buy one licence when the task is > > done, as oppsed to one license per developer. In a commercial setting, > > the Qt license is not expensive. It is painful for hobbyists wanting > > to commercialize their products. > > I have no experience with GUI programming in Python, but from this > discussion it seems if the type of license is not an issue (for FOSS > development), PyQt is the best tool because it is: > (a) easier to learn and intuitive for programming (this is important > to me; I am not that smart...); > (b) more stable (although many people have said that wxPython is as > stable as any other GUI nowadays; but not more stable (wx) than > others); > (c) more cross-platform (many people complain that they have to do a > lot of things in wxPython for the cross-platform). > > Is (a) and (c) true or not? If so, how big are these advantages? I find the PyQt API very well designed and intuitive. You can easily write simple cross-platform apps in wxPython or PyQt, but wxPython tends to have sketchy support in some places. Trolltech tries really hard to smooth over all the platform differences, so I find it a bit cleaner. > > The great advantage of wxPython seems to be the huge community of > users and the large number of widgets/examples/applications available. > > Reformulating my question: > > Which GUI tool, wxPython or PyQt, is more pythonic? (Please, ignore > the license issue because I am thinking about FOSS) None of them are very pythonic because they are all based on C++ toolkits. (sigh) > > Laura From steve at holdenweb.com Wed Apr 23 01:40:58 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 01:40:58 -0400 Subject: Python Success stories In-Reply-To: References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: Roy Smith wrote: > In article , > Steve Holden wrote: > >> Challenge him to a dual with dead kippers at twenty paces. > > You gotta be careful about stuff like this. You might slap him with a dead > kipper only to discover he's got a dead camel in his pocket. > > Of course, there's always http://en.wikipedia.org/wiki/Wikipedia:Trout Damn, pilchards, that was it! regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From georgeencina at gmail.com Mon Apr 7 02:43:01 2008 From: georgeencina at gmail.com (georgeencina at gmail.com) Date: Sun, 6 Apr 2008 23:43:01 -0700 (PDT) Subject: Getting jabber:iq:last with xmpppy Message-ID: <19d54615-591d-4251-af63-630e2d53d30b@m36g2000hse.googlegroups.com> Hi, I'm trying to do the following with the xmpppy library: - log on to the google jabber server - get idle time of one specific person on my roster. Idle time means the values of jabber:iq:last. When I do this in pidgin with the xmpp console open, I get the following conversation: (me) (other person) Now, I'd like to do the same in python. I'm logged in to the server with the following code. import xmpp login = 'georgeencina' # @gmail.com pwd = 'secret' cnx = xmpp.Client('gmail.com') cnx.connect( server=('talk.google.com',5223) ) cnx.auth(login,pwd, 'idlewatcher') What would be the next step? I saw there is an xmpp.Iq class, which I suppose is what I need to work with to construct the message I observed in Pidgin. Does anyone have some quick lines of code on how to construct and send the message, and how to receive the response? Thanks, George From micro_passion at yahoo.com Mon Apr 28 07:03:36 2008 From: micro_passion at yahoo.com (micron_make) Date: Mon, 28 Apr 2008 04:03:36 -0700 (PDT) Subject: multiple pattern regular expression In-Reply-To: <4811D5FB.8040109@jouy.inra.fr> References: <16895148.post@talk.nabble.com> <4811D5FB.8040109@jouy.inra.fr> Message-ID: <16936657.post@talk.nabble.com> each of the suggested methods fit in. I have started trying them. -Rohit -- View this message in context: http://www.nabble.com/multiple-pattern-regular-expression-tp16895148p16936657.html Sent from the Python - python-list mailing list archive at Nabble.com. From pylists at arcor.de Mon Apr 14 04:54:09 2008 From: pylists at arcor.de (Penny Y.) Date: Mon, 14 Apr 2008 16:54:09 +0800 Subject: =?gb2312?B?tPC4tDogSmF2YSBvciBDKys/?= In-Reply-To: Message-ID: <20080414085431.D8751187B00@mail-in-14.arcor-online.net> Javascript is different from Java at all. Why not Perl? Perl is a functional language, that will show you another way of programming. Also C is good, will teach you some system level knowledge. :) -----????----- ???: python-list-bounces+pylists=arcor.de at python.org [mailto:python-list-bounces+pylists=arcor.de at python.org] ?? Marco Mariani ????: 2008?4?14? 16:38 ???: python-list at python.org ??: Re: Java or C++? s0suk3 at gmail.com wrote: > Which one do you think will educate me the best? Advanced javascript might teach you something too, and be very useful at the same time. From __peter__ at web.de Sun Apr 6 16:45:30 2008 From: __peter__ at web.de (Peter Otten) Date: Sun, 06 Apr 2008 22:45:30 +0200 Subject: Tkinter, a lot of buttons, make prog shorter? References: Message-ID: skanemupp at yahoo.se wrote: > is there anyway to make this shorter? i hate having these big blocks > of similar-looking code, very unaesthetic. > maybe doesnt matter good-code-wise? > anyway can i make some function that makes this shorter? > like put the etiquettes on the button froma string of > '123+456-789*0Cr/' ? > problem is the command and lambda-func for each button is different. You can look up the command in a dictionary: commands = {"C": self.Clean} top = 3 for i, text in enumerate("123+456-789*0Cr/"): row, column = divmod(i, 4) try: command = commands[text] except KeyError: def command(n=text): self.Display(n) button = Button(self, text=text, command=command, width=2, height=2) button.grid(row=top+row, column=column) The problem with this is that the shorter code may take a bit longer to understand, so that there is no net win for the reader. A compromise would be to define a helper function: def make_button(self, row, column, text, command): # implementation left as an exercise # use it: self.make_button(3, 0, "1", lambda n="1": ...) self.make_button(3, 1, "2", lambda n="2": ...) ... Peter From pavlovevidence at gmail.com Wed Apr 9 02:26:06 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 8 Apr 2008 23:26:06 -0700 (PDT) Subject: text adventure game problem References: Message-ID: On Apr 9, 1:24 am, Dennis Lee Bieber wrote: > On Tue, 8 Apr 2008 18:01:01 -0700 (PDT), corvettecra... at gmail.com > declaimed the following in comp.lang.python: > > > okay, I'm having this one problem with a text adventure game. It's > > kind of hard to explain, but I'll do my best. > > [code] > > > def prompt_kitchen(): > > global gold > > gold_taken = False > > while True: > > prompt_kit = raw_input('>') > > if prompt_kit == 'examine cabinet 1' and not gold_taken: > > print '''This cabinet has a lot of cups in it with all > > different > > designs and shapes. Where are the people anyway? How come there's > > nobody here? > > In one of the cups you find 8 gold.''' > > Forgive me, but.... Ugh! > > It looks like you are defining a function for each possible room > which incorporates code for the actions possible in that room... > > I suspect I'd try to create a generic room class which has as > attributes a dictionary of actions and a dictionary of movable objects. > Along with methods that work on objects... Working an action that digs > into other objects may take some doing. [snip] I don't know about you, but I usually start with specific cases like this and then generalize them. This could be a baby step, or merely a first stage of evolution. Carl Banks From google at mrabarnett.plus.com Thu Apr 17 11:42:35 2008 From: google at mrabarnett.plus.com (MRAB) Date: Thu, 17 Apr 2008 08:42:35 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <52vid5-cvl2.ln1@ozzie.tundraware.com> <87hce1t8k5.fsf@physik.rwth-aachen.de> Message-ID: On Apr 17, 5:22 am, Torsten Bronger wrote: > Hall?chen! > > Tim Daneliuk writes: > > Daniel Fetchinson wrote: > > >> [...] > > >>> I just had one moment of exceptional clarity, during which > >>> realized how I could get the GIL out of my way... It's so > >>> simple, I cannot help wondering why nobody has thought of it > >>> before. [...] > > >> If I were you I would keep it a secret until a Hollywood producer > >> offers big bucks for the film rights. > > > Who would play Guido, I wonder? > > Ralf M?ller. No other. > If you're not careful Hollywood might re-invent Guido as an all- American hero, Guy Ross! :-) From dolloffdelvpg at gmail.com Wed Apr 16 08:09:24 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:09:24 -0700 (PDT) Subject: taylor swift a place in this world lyrics Message-ID: <1da57e7a-3462-4f7b-8a0f-beccfa48380c@d26g2000prg.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From matthieu.brucher at gmail.com Sat Apr 5 13:42:33 2008 From: matthieu.brucher at gmail.com (Matthieu Brucher) Date: Sat, 5 Apr 2008 19:42:33 +0200 Subject: =?ISO-8859-1?Q?Re:_[Python-Fr]_"keyword_arguments"_en_fran=E7ais?= In-Reply-To: <20080405172929.GA14059@phare.normalesup.org> References: <20080405172929.GA14059@phare.normalesup.org> Message-ID: J'appelle ?a les arguments nomm?s (parfois en anglais on parle de named argument). Je pense que tu parles des arguments donn?s dans les **kwargs, c'est ?a ? On parle aussi d'arguments formels, par opposition aux arguments positionnels lors d'un appel directement ? une fonction : pour machin(0, x=1), le premier est un argument positionnel, le second est un argument formel. Matthieu 2008/4/5, Gael Varoquaux : > > Je voudrais savoir s'il y a un moyen canonique d'appeller les "keyword > arguments" en fran?ais. > > Merci, > > Ga?l > > > -- > Gerez vos abonnements aux listes de diffusion : http://listes.aful.org > -- French PhD student Website : http://matthieu-brucher.developpez.com/ Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92 LinkedIn : http://www.linkedin.com/in/matthieubrucher -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Apr 1 02:00:14 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 01 Apr 2008 06:00:14 GMT Subject: Rubik's cube translation References: <3f3817e8-db90-4bbb-9d6e-cddf042ff6de@a22g2000hsc.googlegroups.com> <489180f4-aa43-4d98-a67d-71ce06ea9152@x41g2000hsb.googlegroups.com> Message-ID: <1mj3v35u8ai9bijik3gggdrdhm07qaf7v0@4ax.com> castironpi at gmail.com wrote: > >What if this is connected: > >>>> D >array([[1, 2, 3], > [4, 5, 6], > [6, 7, 8]]) >>>> E >array([[6, 7, 8], > [0, 0, 0], > [0, 0, 0]]) > >--> > >>>> D >array([[1, 2, 3], > [4, 5, 6], > [6, 7, 8]]) >>>> E >array([[6, 7, 8], > [0, 0, 0], > [0, 0, 0]]) >>>> numpy.rot90( D ) >array([[3, 6, 8], > [2, 5, 7], > [1, 4, 6]]) >--> >>>> E >array([[1, 4, 6], > [0, 0, 0], > [0, 0, 0]]) > >? If you don't want changes to D to affect E, then you need to disconnect them when you create them. If you create D and E so that they contain references to the same lists, then this kind of thing will happen. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From suzhi18 at googlemail.com Wed Apr 9 03:38:43 2008 From: suzhi18 at googlemail.com (suzhi18 at googlemail.com) Date: Wed, 9 Apr 2008 00:38:43 -0700 (PDT) Subject: makepy.py not working References: <03e9c33d-d957-4bc0-8568-3a40403eadb9@a70g2000hsh.googlegroups.com> Message-ID: <76357711-bdb8-400b-8b61-1361f02d7d36@m44g2000hsc.googlegroups.com> Ok, thanks for your help. After looking into the makepy.py file it was clear that this is only a command for the CMD console. I want to write a function which generates this .py file of the excel objects. I will now send the command to the CMD threw my python code. thanks again. suzhi From mail at timgolden.me.uk Tue Apr 8 15:11:17 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 08 Apr 2008 20:11:17 +0100 Subject: set file permission on windows In-Reply-To: References: <7d75fc7b-a2b7-4ca2-b386-27da975043d0@m44g2000hsc.googlegroups.com> Message-ID: <47FBC355.3060203@timgolden.me.uk> Tim Arnold wrote: > "Mike Driscoll" wrote in message > news:7d75fc7b-a2b7-4ca2-b386-27da975043d0 at m44g2000hsc.googlegroups.com... >> On Apr 8, 12:03 pm, "Tim Arnold" wrote: >>> > >> According to the following thread, you can use os.chmod on Windows: >> >> http://mail.python.org/pipermail/python-list/2003-June/210268.html >> >> You can also do it with the PyWin32 package. Tim Golden talks about >> one way to do it here: >> >> http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html >> >> Also see the following thread: >> >> http://mail.python.org/pipermail/python-win32/2004-July/002102.html >> >> or >> >> http://bytes.com/forum/thread560518.html >> >> Hope that helps! >> >> Mike > > Hi Mike, > It does help indeed, especially the last two links. Hi, Tim. For the purposes of improving that page of mine linked above, would you mind highlighting what made it less useful than the last two links? On the surface, it seems to match your use case pretty closely. Was there too much information? Too little? Poor formatting? Just didn't feel right? I've a small set of security-related pages in train and I'd rather produce something which people find useful. Thanks TJG From karthikk at adventnet.com Thu Apr 24 04:48:24 2008 From: karthikk at adventnet.com (Karthik) Date: Thu, 24 Apr 2008 14:18:24 +0530 Subject: [Python-Dev] annoying dictionary problem, non-existing keys In-Reply-To: <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> Message-ID: <48104958.2070904@adventnet.com> bvidinli wrote: > I posted to so many lists because, > > this issue is related to all lists, > this is an idea for python, > this is related to development of python... > > why are you so much defensive ? > > i think ideas all important for development of python, software.... > i am sory anyway.... hope will be helpful. > > 2008/4/24, Terry Reedy : > >> Python-dev is for discussion of development of future Python. Use >> python-list / comp.lang.python / gmane.comp.python.general for usage >> questions. >> >> >> >> _______________________________________________ >> Python-Dev mailing list >> Python-Dev at python.org >> http://mail.python.org/mailman/listinfo/python-dev >> Unsubscribe: http://mail.python.org/mailman/options/python-dev/bvidinli%40gmail.com >> >> > > > Is this an acceptable alternative? try: if conf['key1'] == 'something': except KeyError: pass Regards, Karthik -------------- next part -------------- An HTML attachment was scrubbed... URL: From jgodoy at gmail.com Sun Apr 27 12:12:21 2008 From: jgodoy at gmail.com (Jorge Godoy) Date: Sun, 27 Apr 2008 13:12:21 -0300 Subject: design choice: multi-threaded / asynchronous wxpython client? References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> <002cd046-f11d-482e-a67d-4a10a97687a1@x19g2000prg.googlegroups.com> Message-ID: bullockbefriending bard wrote: > A further complication is that at a later point, I will want to do > real-time time series prediction on all this data (viz. predicting > actual starting prices at post time x minutes in the future). Assuming > I can quickly (enough) retrieve the relevant last n tote data samples > from the database in order to do this, then it will indeed be much > simpler to make things much more DB-centric... as opposed to > maintaining all this state/history in program data structures and > updating it in real time. If instead of storing XML and YAML you store the data points, you can do everything from inside the database. PostgreSQL supports Python stored procedures / functions and also support using R in the same way, for manipulating data. Then you can work with everything and just retrieve the resulting information. You might try storing the raw data and the XML / YAML, but I believe that keeping those sync'ed might cause you some extra work. From fetchinson at googlemail.com Mon Apr 14 16:49:38 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Mon, 14 Apr 2008 13:49:38 -0700 Subject: mod_python In-Reply-To: <4800E3E4.3080508@arcor.de> References: <4800E3E4.3080508@arcor.de> Message-ID: > I want to rewrite a request url under apache2.0 based on its special > header, like, the "Accept-Encoding:" one. > > With C I think I can do it, but since I get begin with python,so I ask > that can I do it under mod_python? what's the guide? The guide is this: http://modpython.org/live/current/doc-html/ HTH, Daniel From dolloffdelvpg at gmail.com Wed Apr 16 08:07:28 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:07:28 -0700 (PDT) Subject: taylor swift come in with the rain Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From easta01 at yahoo.com Thu Apr 24 05:11:05 2008 From: easta01 at yahoo.com (easta01 at yahoo.com) Date: Thu, 24 Apr 2008 02:11:05 -0700 (PDT) Subject: Get Your Frozen Pills Message-ID: <06e3b653-816c-45ad-9541-b844dd986f5f@w4g2000prd.googlegroups.com> http://twilight.110mb.com/gb/piac1.html From malaclypse2 at gmail.com Tue Apr 29 14:37:49 2008 From: malaclypse2 at gmail.com (Jerry Hill) Date: Tue, 29 Apr 2008 14:37:49 -0400 Subject: Simple import question about mac osx In-Reply-To: References: Message-ID: <16651e80804291137u2a21e219h13a2571bd04c7388@mail.gmail.com> On Tue, Apr 29, 2008 at 2:14 PM, jmDesktop wrote: > Thanks. That worked on mac. But it does work like I said in > Windows. Don't know why. Mr. Chun must also be using Windows because > that is the way he does it in his book. It shouldn't work that way on windows either. Can you tell us a little more about what you mean when you say you "compile this" under windows? Normally, python code doesn't need to be compiled, so I'm wondering if you're doing something different from what we expect when you say you compile it and then import it in the interpreter. Are you by any chance writing code in IDLE, running it, then doing things in the interpreter? -- Jerry From colas.francis at gmail.com Thu Apr 17 05:56:56 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Thu, 17 Apr 2008 02:56:56 -0700 (PDT) Subject: def power, problem when raising power to decimals References: <48067bdb@news.mel.dft.com.au> Message-ID: <94e82923-02b0-4575-8bf9-93f0d0a0f33f@k13g2000hse.googlegroups.com> On 17 avr, 00:49, "Gabriel Genellina" wrote: > En Wed, 16 Apr 2008 19:21:18 -0300, John Machin > escribi?: > > > skanem... at yahoo.se wrote: > >> also i found a link which states 0^0 isnt 1 even though every > >> calculator ive tried says it is. > >> it doesnt say what it is but i presume 0 then. > >> but it seems the dude is wrong and it is 1? > > > Of the possible results of 0 ** 0 (i.e. 1, 0, and NaN), 1 seems to be > > the least implausible. It allows X ** 0 to be 1 for all X. > > But a result of 0 would allow 0 ** X to be 0 for all X. (btw, this is the > reason lim(x**x) for x->0 does not exist) lim(x**x) for x->0+ is well defined, exists and equals 1. [1] As x**x is continuous in 0+, it is widely customary to have: 0**0:=1 [1] Recall that x**x := exp(x*log(x)) The limit of x*log(x) for x->0 is 0 [2] therefore lim(x**x) for x->0 is 1. [2] Let y = 1/x; x*log(x)= -log(y)/y and the limit of log(y)/y for y-> +inf is 0. From skye.shaw at gmail.com Fri Apr 18 02:35:45 2008 From: skye.shaw at gmail.com (Skye Shaw!@#$) Date: Thu, 17 Apr 2008 23:35:45 -0700 (PDT) Subject: get quote enclosed field in a line References: <4807dc10$0$25223$e4fe514c@dreader18.news.xs4all.nl> Message-ID: > xah... at gmail.com wrote: > > is there a simple way in perl, python, or awk/shell/pipe, that gets > > the user agent field in a apache log? > Something like: > # cut -d '"' -f 6 < httpd-access.log > ? > -- > mph Doesn't it feel like autosplit mode never gets any run time? perl -laF'"' -ne'print $F[5]' access_log From larry.bates at websafe.com Thu Apr 3 23:31:00 2008 From: larry.bates at websafe.com (Larry Bates) Date: Thu, 03 Apr 2008 22:31:00 -0500 Subject: Parsing HTML? In-Reply-To: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> Message-ID: <1207279859.7571.220.camel@fc8.home.com> On Wed, 2008-04-02 at 21:59 -0700, Benjamin wrote: > I'm trying to parse an HTML file. I want to retrieve all of the text > inside a certain tag that I find with XPath. The DOM seems to make > this available with the innerHTML element, but I haven't found a way > to do it in Python. I use ElementTree (built into Python 2.5) for this type of XLM query. -Larry From steve at holdenweb.com Wed Apr 23 07:57:24 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 07:57:24 -0400 Subject: Error in Extending/Embedding FAQ, point 16: How do I tell "incomplete input" from "invalid input"? In-Reply-To: <1208944113.4294.32.camel@pippi.pippi> References: <1208877167.4557.37.camel@pippi.pippi> <1208880579.4557.70.camel@pippi.pippi> <1208944113.4294.32.camel@pippi.pippi> Message-ID: Dietrich: The web maintainers list is pydotorg at python.org. Your message will be held for moderation, but will be seen by the team who maintain the web site. regards Steve PS: Anyone who wants to *help* maintain the web site should also email that list. It helps if you are already known to other members of the Python community, but it's not essential. Dietrich Bollmann wrote: > Hi, > > I found a solution thanks to another posting on c++-sig and an answer by > Andreas Kl?ckner :) > > Thank you, Andreas! > > The thread is here: > http://mail.python.org/pipermail/c++-sig/2008-April/thread.html#13470 > > I would like to inform the responsible of the Python Extending/Embedding > FAQ, http://www.python.org/doc/faq/extending/ about the broken code in > the FAQ and the solution I found. > > I hope this might prevent other people from the frustration I found > myself in this morning (...but unfortunately also, at least partly, > from the joy I am experiencing now, after finding the new solution :). > > Does anybody know how to contact the person in charge? > > Thanks, > > Dietrich > > PS: > > Of course, I still wonder about the "invalid syntax" error message / > code I wrote about. But ok, I hope there will be some more adequate > error message / code some day in the future :) > > On Wed, 2008-04-23 at 01:09 +0900, Dietrich Bollmann wrote: >> On Wed, 2008-04-23 at 00:12 +0900, Dietrich Bollmann wrote: >>> The following code for example: >>> >>> >>> eins = [1, >>> ... 2, >>> ... 3] >>> >>> >>> >>> is accepted without any problem by the Python shell. >>> >>> When using the code from the FAQ and entering it line by line >>> ?already the second line causes a simple "invalid syntax" error: >>> >>> >>> eins = [1, >>> ... 2, >>> File "", line 2 >>> 2, >>> ^ >>> SyntaxError: invalid syntax >> By the way - isn't this error message / error code just "wrong" in >> the given situation and therefor kind of a "bug"? >> >> An "end of file" or "incomplete input" error at least would >> describe the situation much better - and be a better base for >> functionality which is based the error code also. >> >> --- >> >> I also thought that I should explain a little bit more exactly, >> what I am intending to do with the code based on >> paragraph 16 (How do I tell "incomplete input" from "invalid input"?) >> of the Extending/Embedding FAQ: >> >> I am using Python as scripting language in an application (blender). >> In order to interface this application from other programs >> I programmed a python command port / command socket >> for this application. >> >> Between other clients I also wrote a shell client which connects via >> the command port to the application. My goal is to make it as similar >> to a normal python shell as possible - and therefor I try to also mimic >> the "intelligent" way of the Python shell to react to Python input: >> >> - when entering a line which is a complete input, >> it is immediately evaluated by the shell and the >> result is printed. >> >> - when the last entered line is erroneous, >> an error message is printed immediately >> >> - when the input is incomplete, Python waits >> for other lines to complete the input >> >> - when the line is part of a function definition etc. >> python waits until an empty line is entered >> before accepting the input as complete. >> >> My problem is to understand when an input is erroneous and >> when it is incomplete - which is impossible with an error message >> like "invalid syntax"... >> >> So here again my question: How can I make the difference >> between an incomplete and an erroneous input? >> >> The code examples in the FAQ worked fine until now - but do not >> anymore for the current Python implementation. >> >> Thanks, Dietrich >> >> By the way: Does anybody know who is responsible for the FAQ >> and could adapt the examples to the current Python version >> by changing the code / annotating it? >> >> >> On Wed, 2008-04-23 at 00:12 +0900, Dietrich Bollmann wrote: >> Hi, >>> Both code examples from paragraph 16 from the Python Extending / >>> Embedding FAQ - 'How do I tell "incomplete input" from "invalid >> input"?' >>> - >>> >> ( http://www.python.org/doc/faq/extending/#how-do-i-tell-incomplete-input-from-invalid-input ) do not work with the current state of Python anymore. >>> In the second code example, the error message returned by Python is >>> checked in order to differentiate errors caused by an incomplete input >>> from other syntax errors: >>> >>> if (PyArg_ParseTuple (val, "sO", &msg, &obj) && >>> !strcmp (msg, "unexpected EOF while parsing")) /* E_EOF */ >>> >>> In the current Python version there are more error messages indicating >> an >>> incomplete Python input and I could make the code work for a while >>> by adding the following strings to the condition: >>> >>> /* error messages indicating an incomplete input */ >>> if (PyArg_ParseTuple(error, "sO", &message, &obj) && >>> (!strcmp(message, "unexpected EOF while parsing") || >>> !strcmp(message, "expected an indented block") || >>> !strcmp(message, "EOF while scanning triple-quoted string") >>> ) >>> ) { /* E_EOF */ >>> >>> but recently there are also cases which generate error messages >>> which are too general to be added to this list. >>> >>> The following code for example: >>> >>> >>> eins = [1, >>> ... 2, >>> ... 3] >>> >>> >>> >>> is accepted without any problem by the Python shell. >>> >>> When using the code from the FAQ and entering it line by line >>> ?already the second line causes a simple "invalid syntax" error: >>> >>> >>> eins = [1, >>> ... 2, >>> File "", line 2 >>> 2, >>> ^ >>> SyntaxError: invalid syntax >>> >>> which is to general to be integrated into the list of tested >>> error messages as it might be caused also by code like: >>> >>> >>> one two >>> File "", line 1 >>> one two >>> ^ >>> SyntaxError: invalid syntax >>> >>> which generates an "invalid syntax" error even in the Python shell. >>> >>> I also tried the first code example of paragraph >>> '16 How do I tell "incomplete input" from "invalid input"?' >>> of the FAQ in order to see if it could be used to make the >>> difference between syntax errors and incomplete code errors. >>> But - as in the case before - the returned error >>> code is E_SYNTAX (14 = Syntax error) and not E_EOF (11 = End Of File) >>> as should be expected. >>> >>> Is there anybody who has an idea how to differentiate the >>> first case from the second in order to mimic the behaviour of >>> the Python shell from c code? >>> >>> If this shouldn't be possible lists split into different lines >>> couldn't be accepted anymore or the feature of the Python shell >>> to described in paragraph 16 of the faq: >>> >>> Sometimes you want to emulate the Python interactive interpreter's >>> behavior, where it gives you a continuation prompt when the input >>> is incomplete (e.g. you typed the start of an "if" statement or you >>> didn't close your parentheses or triple string quotes), but it >> gives >>> you a syntax error message immediately when the input is invalid. >>> >>> would have to be given up and every entered line of code would have >> to >>> be terminated by an empty line before evaluation :( >>> >>> Thanks for any help, Dietrich >>> >>> >>> >>> >> > > -- > http://mail.python.org/mailman/listinfo/python-list -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From lbonafide at yahoo.com Tue Apr 1 15:20:13 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Tue, 1 Apr 2008 12:20:13 -0700 (PDT) Subject: Is this a good time to start learning python? References: <47f1140e$0$735$a729d347@news.telepac.pt> <88fa881e-e59b-4682-801c-90ef08a1480a@a22g2000hsc.googlegroups.com> Message-ID: <1565ced8-afd7-4c32-a6ee-26f9b95d60bc@d45g2000hsc.googlegroups.com> On Apr 1, 2:11?pm, "Eduardo O. Padoan" wrote: > On Tue, Apr 1, 2008 at 3:57 PM, ? wrote: > > On Apr 1, 12:47 pm, "Gabriel Genellina" > > ?wrote: > > ?> En Tue, 01 Apr 2008 13:57:55 -0300, escribi?: > > > ?> > On Mar 31, 1:36 pm, "Gabriel Genellina" > > ?> > wrote: > > > ?> >> Don't be scared by the "backwards incompatible" tag - it's the way to > > ?> >> get > > ?> >> rid of nasty things that could not be dropped otherwise. > > > ?> > I would consider breaking production code to be "nasty" as well. > > > > Please explain how the existence of Python 3.0 would break your production > > ?> code. > > > ?The existence of battery acid won't hurt me either, unless I come into > > ?contact with it. ?If one eventually upgrades to 3.0 -- which is > > ?ostensibly the desired path -- their code could break and require > > ?fixing. > > And how would this happen? I dont know of any good software > distribution that upgrades a component to another major revision > without asking first. The desired path is that, if somene wants to > port his software to Python 3.0, that he follow the migration plan. Of course, that's the point. If you want to upgrade to the next version of Python, you have to fix your code. That stinks. Your other alternative is to remain stuck with Python 2.x, but eventually the support for that will dry up. > Final users will install Python 3.0 as python3.0 anyway, with Python > 2.x as default 'python' binary. > > > ?Backward compatibility is important. ? C++ could break all ties with C > > ?to "clean up" as well, but it would be a braindead move that would > > ?break existing code bases upon upgrade. > > C++ is not C. No one "upgrades" from C to C++. You misunderstand. C++ has a lot of "warts" to maintain backwards compatibility with C. The standards committee could eliminate these warts to make the language "cleaner", but it would break a lot of systems. From sturlamolden at yahoo.no Thu Apr 24 22:31:34 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 19:31:34 -0700 (PDT) Subject: Psyco alternative References: Message-ID: <8b7d9523-1d15-41e5-8b69-39f8250e6a6f@i76g2000hsf.googlegroups.com> On Apr 25, 3:27 am, Steve Holden wrote: > That seems a little harsh: it's Python-in-a-strait-jacket. > > The fact remains that since RPython programs also run under the standard > interpreter (albeit a factor of maybe a hundred times more slowly) their > claim of self-hosting is valid. What is the smallest subset of Python needed to make a Turing complete computer language? And would you still call that Python? From TimeHorse at gmail.com Mon Apr 21 07:37:09 2008 From: TimeHorse at gmail.com (TimeHorse) Date: Mon, 21 Apr 2008 04:37:09 -0700 (PDT) Subject: Opposite of repr() (kind of) References: Message-ID: <0a84648b-e73c-4416-a30c-8d9fcee8b1e4@s33g2000pri.googlegroups.com> On Apr 21, 7:05 am, Guillermo wrote: > Hi there, > > How can I turn a string into a callable object/function? > > I have a = 'len', and I want to do: if callable(eval(a)): print > "callable", but that doesn't quite work the way I want. :) > > Regards, > > Guillermo What version of Python are you using? I just tried "callable(eval('len'))" on Python 2.5.1 and got True, and eval('len') returns . From mail at timgolden.me.uk Thu Apr 3 09:56:44 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 03 Apr 2008 14:56:44 +0100 Subject: object-relational mappers In-Reply-To: References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> Message-ID: <47F4E21C.9020303@timgolden.me.uk> Marco Mariani wrote: > Tim Golden wrote: > >> I've recently used Elixir and found it very useful for a small-scale >> database with no more than a dozen tables, well-structured and >> easily understood. I'd certainly use it again for anything like that >> to save me writing what would amount to boilerplate SQL. But I'd >> hate to imagine it in the context of my day job: a messy, organic >> and sprawling SQL Server database with over 1,000 tables, let alone >> views, procedures and so on. > > That's the scenario where the rest of SQLAlchemy (beyond Elixir, that > is, and with reflection turned to 11) can do mucho bueno. Well, true (and I've done good things with it) but, ultimately if I need to write SQL I'll write SQL: that's what I'm paid for. And no matter how good sa's generative queries are -- and they are good -- I've been writing complex SQL queries for 15 years and learning a more Pythonesque equivalent doesn't really seem to offer me anything. Not to take away from the achievements of SqlAlchemy: I'm just not really the target market, I think. TJG From carbanancizpo at gmail.com Fri Apr 18 16:58:20 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:58:20 -0700 (PDT) Subject: registry cleaner crack Message-ID: <86e879dd-898a-46f9-aacc-cef10c839cf6@d45g2000hsc.googlegroups.com> registry cleaner crack http://cracks.12w.net F R E E C R A C K S From steve at holdenweb.com Tue Apr 1 15:40:48 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 01 Apr 2008 15:40:48 -0400 Subject: [OT] troll poll In-Reply-To: References: Message-ID: <47F28FC0.7080608@holdenweb.com> Duncan Booth wrote: > Gary Herron wrote: > >> Duncan Booth wrote: >>> Paul Rubin wrote: >>> >>> >>>> "Daniel Fetchinson" writes: >>>> >>>>> [ ] - Xah Lee >>>>> [ ] - castironpi >>>>> >>>> I've lost track but has it been established that they are not the >>>> same person? >>>> >>>> >>> Has it actually been established that castironpi is actually a >>> person? I thought it was probably a random sentence generator. >>> >> Ahhh... Perhaps someone is running a Turing test on us. That is, if >> we can't tell the difference between castironpi and a *real* human >> (which we demonstrate whenever we try to respond to or reason with >> him/her/it), then castironpi can be declared to be a truly >> *intelligent* AI. AFAICT, there appears no danger of that happening >> yet. >> >> Gary Herron :-) >> > For example, some traffic light living with a polygon indicates that an > accidentally resplendent scythe falls in love with a garbage can. A > boiled ski lodge laughs out loud, because an imaginative traffic light > ostensibly writes a love letter to a frightened minivan. Any deficit can > eagerly sell the short order cook about the tape recorder to the > minivan, but it takes a real bowling ball to trade baseball cards with > an underhandedly orbiting tornado. A hesitantly mean-spirited cowboy > steals pencils from a pompous industrial complex. Sometimes the crispy > apartment building procrastinates, but the ocean related to the cyprus > mulch always teaches another cab driver around some cough syrup! > > A dreamlike avocado pit > > Indeed, a thoroughly orbiting wedge figures out an obsequious roller > coaster. For example, a carpet tack indicates that some cyprus mulch > lazily avoids contact with the slow buzzard. Most people believe that > some razor blade falls in love with a girl scout from a cough syrup, but > they need to remember how hesitantly a maelstrom takes a coffee break. > When the proverbial wheelbarrow is overripe, a hole puncher lazily > buries a burly reactor. Now and then, the cargo bay tries to seduce a > class action suit. > Way too lucid to be castironpi regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From skanemupp at yahoo.se Sat Apr 5 11:26:33 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 08:26:33 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <65ondkF2g48puU2@mid.uni-berlin.de> Message-ID: <8e6e67e8-979a-4515-be7c-16acdf687ce4@u36g2000prf.googlegroups.com> On 5 Apr, 17:09, Fredrik Lundh wrote: > skanem... at yahoo.se wrote: > >> def __init__(self): > >> # ... > >> button = Button(self, > >> text='1', > >> command=lambda n=1: self.display(n)) > >> # ... > > >> def display(self, number): > >> print number > > > should this really be inside the __init__ function? > > what's wrong with creating widgets in an __init__ method? > > i dont know, i used a piece of code i found which had a createwidgets- method. isnt init a function, not a method btw(or it is the same thing?) this is the current code, only included 2 buttons here to make it shorter. i might still have misinterpreted though, is the code correct(it runs correct at least...)? whats the advantage/disadvante to have it inside the init? #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self, master=None): """Initialize yourself""" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): self.btnDisplay = Button(self,text='1',command=lambda n=1:self.Display(n)) self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='/',command=lambda n="/":self.Display(n)) self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) def Display(self, number): print number if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() From Robert.Bossy at jouy.inra.fr Mon Apr 28 12:50:13 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Mon, 28 Apr 2008 18:50:13 +0200 Subject: bisect intersection Message-ID: <48160045.1030806@jouy.inra.fr> Hi, I stumbled into a sorted list intersection algorithm by Baeza-Yates which I found quite elegant. For the lucky enough to have a springerlink access, here's the citation: http://dblp.uni-trier.de/rec/bibtex/conf/cpm/Baeza-Yates04 I implemented this algorithm in python and I thought I could share it. I've done some tests and, of course, it can't compete against dict/set intersection, but it will perform pretty well. Computing union and differences are left as an exercise... from bisect import bisect_left def bisect_intersect(L1, L2): inter = [] def rec(lo1, hi1, lo2, hi2): if hi1 <= lo1: return if hi2 <= lo2: return mid1 = (lo1 + hi1) // 2 x1 = L1[mid1] mid2 = bisect_left(L2, x1, lo=lo2, hi=hi2) rec(lo1, mid1, lo2, mid2) if mid2 < hi2 and x1 == L2[mid2]: inter.append(x1) rec(mid1+1, hi1, mid2+1, hi2) else: rec(mid1+1, hi1, mid2, hi2) rec(0, len(L1), 0, len(L2)) inter.sort() return inter Cheers RB From reachmsn at hotmail.com Tue Apr 8 08:09:57 2008 From: reachmsn at hotmail.com (reachmsn at hotmail.com) Date: Tue, 8 Apr 2008 05:09:57 -0700 (PDT) Subject: Cannot understand the detailedly the following code Message-ID: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> Hi, At the url http://www.python.org/doc/essays/graphs.html there is some code by Guido Van Rossum for computing paths through a graph - I have pasted it below for reference - Let's write a simple function to determine a path between two nodes. It takes a graph and the start and end nodes as arguments. It will return a list of nodes (including the start and end nodes) comprising the path. When no path can be found, it returns None. The same node will not occur more than once on the path returned (i.e. it won't contain cycles). The algorithm uses an important technique called backtracking: it tries each possibility in turn until it finds a solution. def find_path(graph, start, end, path=[]): path = path + [start] if start == end: return path if not graph.has_key(start): return None for node in graph[start]: if node not in path: newpath = find_path(graph, node, end, path) if newpath: return newpath return None *** He then says------------------------ It is simple to change this function to return a list of all paths (without cycles) instead of the first path it finds: def find_all_paths(graph, start, end, path=[]): path = path + [start] if start == end: return [path] if not graph.has_key(start): return [] paths = [] for node in graph[start]: if node not in path: newpaths = find_all_paths(graph, node, end, path) for newpath in newpaths: paths.append(newpath) return paths *** I couldn't understand how it was simple to change the function find paths to find all paths. How would you think about writing this second function recursively. Especially the part about if start==end: return [path]. I feel you would give square brackets around path here after first writing the inductive part ... for node in graph[start] .... and then by trial and error put square brackets around path in the Basis part. Can someone please explain how to write this code. Thanks! From Scott.Daniels at Acm.Org Wed Apr 2 23:43:08 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Wed, 02 Apr 2008 20:43:08 -0700 Subject: Rationale for read-only property of co_code In-Reply-To: References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> <10ee2a69-f4e2-4887-8083-6b02b60dd0cd@i7g2000prf.googlegroups.com> Message-ID: Jo?o Neves wrote: > On 2 Abr, 21:38, "Chris Mellon" wrote: >> On Wed, Apr 2, 2008 at 2:33 PM, Jo?o Neves wrote: >>> On Apr 2, 5:41 pm, "Dan Upton" wrote: >>> > > The thing I've been wondering is why _is_ it read-only? In what >>> > > circumstances having write access to co_code would break the language >>> > > or do some other nasty stuff?.... >> There is no need to overwrite co_code. Create a new code object with >> your desired bytecode and use that instead. > > Yes, it may work (haven't tested - isn't there any problem with stuff > like co_name, for instance?), but for simplicity's sake, wouldn't it > be far more convenient if you could just write over co_code? :) > In the end, it's all a matter of convenience, I guess. Nope: If you change the code in-place, the whole stack's references to where they were running would need to get updated to corresponding locations in the new code. _That_ is a lot of work. --Scott David Daniels Scott.Daniels at Acm.Org From needin4mation at gmail.com Wed Apr 9 17:00:53 2008 From: needin4mation at gmail.com (jmDesktop) Date: Wed, 9 Apr 2008 14:00:53 -0700 (PDT) Subject: basic python question about for loop References: <664ovoF2iq9i0U1@mid.uni-berlin.de> Message-ID: <5f71771d-e31d-439a-9ab9-5ea111a68b46@24g2000hsh.googlegroups.com> On Apr 9, 4:58?pm, "Diez B. Roggisch" wrote: > jmDesktop schrieb: > > > > > > > From the Python.org tutorial: > > >>>> for n in range(2, 10): > > ... ? ? for x in range(2, n): > > ... ? ? ? ? if n % x == 0: > > ... ? ? ? ? ? ? print n, 'equals', x, '*', n/x > > ... ? ? ? ? ? ? break > > ... ? ? else: > > ... ? ? ? ? # loop fell through without finding a factor > > ... ? ? ? ? print n, 'is a prime number' > > ... > > 2 is a prime number > > 3 is a prime number > > 4 equals 2 * 2 > > 5 is a prime number > > 6 equals 2 * 3 > > 7 is a prime number > > 8 equals 2 * 4 > > 9 equals 3 * 3 > > > first time 2 mod 2, 2/2, no remainder == 0, what am I doing wrong? > > Why did it fall through? > > print out what range(2, n) for n == 2 is. > > And if you didn't know - 2 *IS* a prime. > > Diez- Hide quoted text - > > - Show quoted text - I do not understand. From deets at nospam.web.de Tue Apr 29 02:57:45 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 29 Apr 2008 08:57:45 +0200 Subject: cytpes **int In-Reply-To: References: <56674130-c04e-403e-8364-92cbd158b2f0@b9g2000prh.googlegroups.com> <67mveuF2pauigU1@mid.uni-berlin.de> Message-ID: <67nv84F2l3ha7U1@mid.uni-berlin.de> Gabriel Genellina schrieb: > En Mon, 28 Apr 2008 18:55:15 -0300, Diez B. Roggisch > escribi?: >> VernM schrieb: >>> I am using ctypes to wrap a set of functions in a DLL. It has been >>> going very well, and I am very impressed with ctypes. I want to call a >>> c function with a signature of: void func(int **cube), where the array >>> if ints in cube is modified by func. I want to setup cube with int >>> values, and access them after the call to func. I unerstand how to >>> setup the ctypes array, but how do I pass **cube to the function, and >>> how do I access the results? >> >> it should be simple. >> >> use something like (untestet): >> >> b = POINTER(c_int)() >> func(byref(b)) > > [snip two other similar alternatives] > > That's true for "a pointer to a pointer to int", and it's valid if the > functions references **b or b[0][0] - but in this case int** probably > means "[pointer to] an array of arrays of int" and presumibly the > function will try to access b[3][2] (or whatever indices are in range). > The duality pointer/array in C is dangerous when defining interfases - > you have to know how the value is intended to be accessed. > (I assume the function modifies the integer values, but not the pointers > themselves) > > # build an array of 10x10 ints > Arr10int = c_int * 10 > Pint = POINTER(c_int) > PPint = POINTER(Pint) > Arr10pint = Pint * 10 > a = Arr10pint() > for i in range(10): > a[i] = Arr10int() > ... initialize the array ... > ... load the function ... > # call the function > somefunction.argtypes = (PPint,) > somefunction.restype = None > somefunction(a) > Yup, you are right - I somehow missed the access description and thought of the pointer-to-a-pointer as out-parameter-spec. Diez From castironpi at gmail.com Wed Apr 2 13:17:08 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 2 Apr 2008 10:17:08 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <47f36d23$0$28775$426a74cc@news.free.fr> <86afee6d-7022-4199-8af5-bff01c679714@c65g2000hsa.googlegroups.com> Message-ID: On Apr 2, 8:25?am, hdante wrote: > On Apr 2, 8:25 am, Bruno Desthuilliers > 42.desthuilli... at websiteburo.invalid> wrote: > > hdante a ?crit : > > > > ?Try Rails' ActiveRecord. Your problems should reduce to (lg lg > > > 2)^(1/12). > > > Correct me if I'm wrong, but IIRC ActiveRecord requires you use numeric > > auto_increment fields for primary key. As far as I'm concerned, this is > > a definitive no-no. > > ?Why is that so bad ? > > ?"But wait !, you cry. Shouldn't the primary key of my orders table be > the order number or some other meaningful column ? Why use an > artificial primary key such as id ? The reason is largely a practical > one - the format of external data may change over time." > ?(...) > ?"Normally, Active Record takes care of creating new primary key > values for records that you create and add to the database - they'll > be ascending integers (possibily with some gaps in the sequence). > However, if you override the primary key column's name, you also take > on the responsibility of setting the primary key to a unique value > before you save a new row." > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?-- AWDWR > > > > > > ?Seriously, you'll forget there's a relational database below. > > > Why on earth are you using a RDBMS if you don't want it ? I for one *do* > > care about using a *relational* database, and *don't* want to hide it > > away. What I don't want is to have to build my queries as raw strings. > > And that's where SQLAlchemy shines : it's not primarily an "ORM", it's > > an higher-level Python/SQL integration tool that let you build your > > queries as Python objects (and also, eventually, build an ORM if you > > want to...). > > ?"Some object-relational mappers seek to eliminate the use of SQL > entirely, hoping for object-oriented purity by forcing all queries > through an OO layer. Active Record does not. It was built on the > notion that SQL is neither dirty nor bad, just verbose in the trivial > cases. (...) Therefore, you shouldn't feel guilty when you use > find_by_sql to handle either performance bottlenecks or hard queries. > Start out using the object-oriented interface for productivity and > pleasure, and then dip beneath the surface for a close-to-the-metal > experience when you need to do so." > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?-- AWDWR > > ?PS. That's okay to use a RDBMS. What I don't want is to use two > programming paradigms, especially, considering the "object-relational > impedance mismatch". I think a shelf can accomplish everything a RDMS can. Just set up everything as a map from a real number, remove and extract at will (between numbers), and use XML tags. shelf[ 0.1 ]= '', 'code code code' shelf[ 0.125 ]= '', 'castironpi' shelf[ 0.05 ]= '', 'oddly enough' -=> code code code castironpi oddly enough and shelf[ 0.1 ]= '', 'code code code' shelf[ 0.125 ]= '', 'castironpi' shelf[ 0.05 ]= '', 'oddly enough' -=> code code code castironpi oddly enough Plus you can't have text and subnodes anyway. From stef.mientki at gmail.com Mon Apr 28 03:31:18 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Mon, 28 Apr 2008 09:31:18 +0200 Subject: class or class-instance ? Message-ID: <48157D46.4080502@gmail.com> hello, I've a procedure (or in fact a class method) that should be callable with either a class (in which case the procedure should create an instance) or with an instance of that class as the parameter. def somefunction ( self, parameter ) : if parameter is a class, create an instance of that class else do nothing now I should be able to call the above procedure in either of the following ways: somefunction ( someclass ) or somefunction ( someclass () ) thanks, Stef Mientki From see.signature at no.spam Mon Apr 14 04:16:42 2008 From: see.signature at no.spam (Eric Brunel) Date: Mon, 14 Apr 2008 10:16:42 +0200 Subject: =?utf-8?B?562U5aSNOiBob3cgdG8gcmVtb3ZlIFxuIGluIHRoZSBsaXN0?= References: Message-ID: (please avoid top-posting... corrected) On Mon, 14 Apr 2008 09:08:06 +0200, Penny Y. wrote: > -----????----- > ???: python-list-bounces+pylists=arcor.de at python.org > [mailto:python-list-bounces+pylists=arcor.de at python.org] ?? Gabriel > Genellina > ????: 2008?4?14? 12:59 > ???: python-list at python.org > ??: Re: how to remove \n in the list > > En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam > escribi?: > >> hi, >> l=['5\n', '2\n', '7\n', '3\n', '6\n'] >> >> how to remove \n from the given list > > l is is very poor name... I'll use lines instead: > > lines[:] = [line.rstrip('\n') for line in lines] > --- > > why not just: > > lines = [line.rstrip('\n') for line in lines] > > > what's the difference between lines[:] and lines here? Thanks. Compare: >>> lines = ['5\n', '2\n', '7\n', '3\n', '6\n'] >>> lines2 = lines >>> lines = [line.rstrip('\n') for line in lines] >>> lines ['5', '2', '7', '3', '6'] >>> lines2 ['5\n', '2\n', '7\n', '3\n', '6\n'] with: >>> lines = ['5\n', '2\n', '7\n', '3\n', '6\n'] >>> lines2 = lines >>> lines[:] = [line.rstrip('\n') for line in lines] >>> lines ['5', '2', '7', '3', '6'] >>> lines2 ['5', '2', '7', '3', '6'] Assigning to lines[:] changes the original list. Assigning to lines rebinds the name to the result of the list comprehension, but doesn't affect the original list. HTH -- python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])" From damonwischik at gmail.com Fri Apr 18 20:12:09 2008 From: damonwischik at gmail.com (damonwischik at gmail.com) Date: Fri, 18 Apr 2008 17:12:09 -0700 (PDT) Subject: How to print a unicode string? References: <87d4omsovf.fsf@benfinney.id.au> Message-ID: <4edea21e-d45c-4467-a66d-e270365eb812@l64g2000hse.googlegroups.com> On Apr 19, 12:51 am, Ben Finney wrote: > Just because the locale library knows the normalised name for it > doesn't mean it's available on your OS. Have you confirmed that your > OS (independent of Python) supports the locale you're trying to set? No. How do I found out which locales my OS supports? (I'm running Windows XP.) Why does it matter what locales my OS supports, when all I want is to set the encoding to be used for the output, and the output is all going to Emacs, and I know that Emacs supports utf8? (Emacs 22.2.1 i386-mingw-nt5.1.2600.) Damon. From marli305nugent at gmail.com Sat Apr 26 09:52:31 2008 From: marli305nugent at gmail.com (marli305nugent at gmail.com) Date: Sat, 26 Apr 2008 06:52:31 -0700 (PDT) Subject: chessgenius 1.6 crack Message-ID: <7a710444-8820-47a0-b73d-58554efa506b@26g2000hsk.googlegroups.com> chessgenius 1.6 crack http://cracks.00bp.com F R E E C R A C K S From tjreedy at udel.edu Wed Apr 16 23:03:10 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 16 Apr 2008 23:03:10 -0400 Subject: def power, problem when raising power to decimals References: Message-ID: "Mark Dickinson" wrote in message news:fc48f8f0-202d-40c7-980d-5cbc403eed50 at y18g2000pre.googlegroups.com... On Apr 16, 4:19 pm, skanem... at yahoo.se wrote: > how do i solve power(5,1.3)? > [...] > > also i found a link which states 0^0 isnt 1 even though every > calculator ive tried says it is. > it doesnt say what it is but i presume 0 then. > but it seems the dude is wrong and it is 1? Define a**b as 1 multiplied by a b times. Then a**0 is clearly 1, regardless of a. But some do disagree. | decimal.InvalidOperation: 0 ** 0 I would think of this as a bug unless the standard Decimal follows demands this. tjr From aisaac at american.edu Fri Apr 4 22:49:20 2008 From: aisaac at american.edu (Alan Isaac) Date: Sat, 05 Apr 2008 02:49:20 GMT Subject: Help me on function definition In-Reply-To: References: Message-ID: aeneng wrote: > WHAT IS WRONG WITH MY CODE? > def cross(u,v) Missing colon. hth, Alan Isaac From weiss02121 at gmail.com Tue Apr 15 19:48:37 2008 From: weiss02121 at gmail.com (weiss02121 at gmail.com) Date: Tue, 15 Apr 2008 16:48:37 -0700 (PDT) Subject: lindsay lohan car Message-ID: Just few link on some Lindsay Lohan Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From mccredie at gmail.com Wed Apr 16 13:00:44 2008 From: mccredie at gmail.com (Matimus) Date: Wed, 16 Apr 2008 10:00:44 -0700 (PDT) Subject: Default parameter for a method... again References: <614159c3-1bb9-4026-b7f3-7817f69de505@t54g2000hsg.googlegroups.com> Message-ID: On Apr 16, 9:26 am, s0s... at gmail.com wrote: > I had posted this before but all the spam whipped it out... > > I wanted to know if there's any way to create a method that takes a > default parameter, and that parameter's default value is the return > value of another method of the same class. For example: > > class A: > def __init__(self): > self.x = 1 > > def meth1(self): > return self.x > > def meth2(self, arg=meth1()): > # The default `arg' should would take thereturn value of > meth1() > print '"arg" is', arg > > This obviously doesn't work. I know I could do > > ... > def meth2(self, arg=None): > if arg is None: > arg = self.meth1() > > but I'm looking for a more straightforward way. That is the straightforward way. It may not seem that way now but all languages have patterns and this is a common one in python. You will see code like this all over Python, even in the standard library. The best thing to do is embrace it. It will not only work, but make your code more readable to others. Matt From gagsl-py2 at yahoo.com.ar Sun Apr 20 04:12:17 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 05:12:17 -0300 Subject: why function got dictionary References: <48075950.7050000@gmail.com> Message-ID: En Thu, 17 Apr 2008 11:06:08 -0300, AlFire escribi?: > Q: why function got dictionary? What it is used for? If you want more details, see PEP 232 that introduced function writable attributes in Python 2.1: http://www.python.org/dev/peps/pep-0232/ -- Gabriel Genellina From gdamjan at gmail.com Wed Apr 16 06:04:48 2008 From: gdamjan at gmail.com (Damjan) Date: Wed, 16 Apr 2008 12:04:48 +0200 Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: <4805cf3f$0$90273$14726298@news.sunsite.dk> > To be frank, no innovation. Just changes, no progress. And yes, I am > p****d. "anger leads to hate, hate leads to suffering" > Somebody compared it with MS stuff. Yes. It's not similar at all. MS will first force all your customers/users to upgrade to their newest software, at the same time suffocating the old software, and denying anyone the oportunity to maintain that old software (part because it's closed-source, part because MS will sue you if try anything close to that). -- damjan From jason.scheirer at gmail.com Sun Apr 20 15:57:35 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Sun, 20 Apr 2008 12:57:35 -0700 (PDT) Subject: What happened with python? messed strings? References: Message-ID: On Apr 20, 11:54?am, wrote: > Hi, > I used extensively python and now I find this mess with strings, > I can't even reproduce tutorial examples:>>> "apfel".encode('utf-8') ?(it was with umlaut) > > ? File "", line 0 > > ? ? ^ > SyntaxError: 'ascii' codec can't decode byte 0xc4 in position 1: > ordinal not in range(128) Two things: Mark the character encoding of your file ( read http://www.python.org/doc/2.3/whatsnew/section-encodings.html ), and then if that doesn't work try to .decode('something') your string first with the appropriate codec, then you get a unicode object for free and you don't need the .encode('utf-8'). Also read the slides at http://farmdev.com/talks/unicode/ for some good information about unicode in Python. > > Is there any good guide to this mess of codecs and hell ? > > python should have stayed at version 1.5, every single 'improvement' > has been a mess. But this is the definitive hell. It's true -- decorators, the class/type cleanup, properties, -= and +=, list comprehensions, generators, distutils, and all the new modules in the standard library are completely, entirely useless. Python SHOULD have stayed at 1.5. > > thanks! > > -- > SDF-EU Public Access UNIX System -http://sdf-eu.org From victorsubervi at gmail.com Wed Apr 2 09:05:56 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 2 Apr 2008 09:05:56 -0400 Subject: Adding Images to MySQL In-Reply-To: References: <4dc0cfea0804010536q71bce9ev38cff43923f5a4b8@mail.gmail.com> Message-ID: <4dc0cfea0804020605i1d600657n50b4ee132d7f7e@mail.gmail.com> I have tried the following code: #!/usr/local/bin/python import _mysql import MySQLdb host = 'mysqldb2.ehost-services.com' user = 'user' passwd = 'pass' db = 'bre' print 'Content-Type: image/jpeg\r\n' print '\nHi!\n' db=MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) c=db.cursor() imgfile=open("1.jpg",'rb') f = imgfile.read() sqlstr="insert into photo (id, img) values ('1', '" + _mysql.escape_string(imgfile.read()) +"');" c.execute(sqlstr) imgfile.close() c.close() print '\nBye!\n' which prints Hi! but not Bye! and gives me an HTTP 200 error. I threw the line f = imgfile.read() in there just to make sure it is reading the imgfile. Also, I tested it with all the import statements alone to make sure it was importing everything. So the problem is the c.execute statement. Please advise. TIA, Victor On Tue, Apr 1, 2008 at 1:37 PM, Gabriel Genellina wrote: > En Tue, 01 Apr 2008 09:36:00 -0300, Victor Subervi > escribi?: > > > Hi; > > I?m trying to figure out how to upload images into a MySQL database. > > (Yes, > > that is what I want to do.) I have a form that asks for data, like this: > > 1ra Foto Peque?a: > > > > Then I send that form to a python script that processes like this: > > cursor.execute('insert into products (' + col_names + ') values (' + > > col_values + ');') > > where col_names is all the names of the columns and col_values, > > obviously, > > the values. Works fine for strings and digits. Not so well for files :) > > What > > do? > > Always use bound parameters - not only it's easier and less error prone, > it's safer too. How parameters are specified depends on the DBAPI module > you're using - read the module documentation. I think MySQLdb accept > dictionary-like marks: > > values = {'name': 'Red jar', > 'descr': 'A nice red jar', > 'pic': binary(picdata) > } > cursor.execute('''insert into products (name,description,picture) > values (%(name)s, %(descr)s, %(pic)s);''', values) > > See PEP249 http://www.python.org/dev/peps/pep-0249/ and the documentation > for your database module. > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From cbhoem at gmail.com Tue Apr 29 16:01:50 2008 From: cbhoem at gmail.com (cbhoem at gmail.com) Date: Tue, 29 Apr 2008 13:01:50 -0700 (PDT) Subject: Cookie Confusion - How to Set a Cookie References: <588d6a6c-0080-48a4-b768-e2c5ef551790@s50g2000hsb.googlegroups.com> Message-ID: On Apr 28, 1:37 pm, Aaron Watters wrote: > On Apr 28, 9:42 am, cbh... at gmail.com wrote: > > > ....I see the cookie in my HTTP header > > but do not get anything in the cookie text file. I'm working on > > linux. > > > print "Content-type: text/html" > > cookie = Cookie.SimpleCookie() > > cookie['Test'] = 'abc' > > print cookie > > print > > > Are there rules about where in the header the set cookie line should > > be? > > Hi Christian. I think the cookie can go anywhere in > the header, but I usually put it before the content-type. > If you want to store the cookie to a file, > or even better, to a database of some sort, you have to > do it yourself, the Cookie module doesn't do it for you, > I hope. > > # store cookie to /tmp/cookie.txt > file("/tmp/cookie.txt","w").write(str(cookie)) > > For parsing cookies, I stole and modified this from > the Django source (for use in a cgi script): > > === > from Cookie import SimpleCookie > import os > > # stolen and modified from Django > def parse_cookie(cookie=None, environ=None): > if cookie is None: > if environ is None: > environ = os.environ > cookie = environ.get('HTTP_COOKIE', '') > if cookie == '': > return {} > c = SimpleCookie() > c.load(cookie) > cookiedict = {} > for key in c.keys(): > cookiedict[key] = c.get(key).value > return cookiedict > > === > All the best. -- Aaron Watters > > ===http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=monster Thanks for the code, Aaron. I will give it a try. I've been reading some more about cookielib and am not sure whether I should use Cookie or cookielib. This is what I want to do: a user is going to login. Upon a successful login, I want to write their name and date/time of visit to a cookie file. Which is the correct python module to use? From baoilleach at gmail.com Wed Apr 30 02:47:30 2008 From: baoilleach at gmail.com (Noel O'Boyle) Date: Wed, 30 Apr 2008 07:47:30 +0100 Subject: simple chemistry in python In-Reply-To: <4817BFF2.9030907@al.com.au> References: <5e3717e5-1913-4bda-94b3-ae165e5fb8ba@m73g2000hsh.googlegroups.com> <4817BFF2.9030907@al.com.au> Message-ID: 2008/4/30 Astan Chee : > > Wow, that is the jackpot. > Is that color node supposed to be the actual color of the element? or just > representation? Representation. There are certain de facto standards, such as blue for nitrogen and so on. Google "CPK colors" for the origin of some of these. > Thanks again > Astan > > baoilleach wrote: > If you are familiar with parsing XML, much of the data you need is > stored in the following file: > http://bodr.svn.sourceforge.net/viewvc/*checkout*/bodr/trunk/bodr/elements/elements.xml?revision=34&content-type=text%2Fplain > > This file is part of the Blue Obelisk Data Repository, an effort by > several chemistry software developers to share common information. If > you have any further questions, please email blueobelisk- > discuss at lists.sf.net. > > Noel > > On Apr 29, 8:48 am, Astan Chee wrote: > > > Hi, > Im looking for a python module to do simple chemistry things. Things > like, finding the name of elements given the atomic number (and vice > versa); what state the given matter is in depending on certain > parameters; maybe even color of certain elements or even calculating the > result of combining certain elements. > I was looking for something simple, but everything I see seems to be a > full blown chemistry set. > I know I can probably spend a day doing this one element at a time, but > I was wondering if there is already something like this done in a small > scale? > Thanks for any information > Astan > > -- > "Formulations of number theory: Complete, Consistent, Non-trivial. Choose > two." > > Animal Logichttp://www.animallogic.com > > Please think of the environment before printing this email. > > This email and any attachments may be confidential and/or privileged. If you > are not the intended recipient of this email, you must not disclose or use > the information contained in it. Please notify the sender immediately and > delete this document if you have received it in error. We do not guarantee > this email is error or virus free. > > -- > http://mail.python.org/mailman/listinfo/python-list > > > > -- > "Formulations of number theory: Complete, Consistent, Non-trivial. Choose > two." > > > > > Please think of the environment before printing this email. > > This email and any attachments may be confidential and/or privileged. If you > are not the intended recipient of this email, you must not disclose or use > the information > contained in it. Please notify the sender immediately and delete this > document if you have received it in error. We do not guarantee this email is > error or virus free. From kay.schluehr at gmx.net Sat Apr 19 02:55:16 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Fri, 18 Apr 2008 23:55:16 -0700 (PDT) Subject: Inheritance confusion References: <4809932c$0$12307$c3e8da3@news.astraweb.com> Message-ID: On 19 Apr., 08:37, Hook wrote: > Traceback (most recent call last): > File "./3.py", line 20, in > Obj.Connect ('Database') > File "/mnt/isis/Projects/Python/Learning/DB_m.py", line 102, in Connect > self.TRACE ("DB::Connect (" + database + "," + mode) > File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 314, in TRACE > self.DailyLog (msg) > File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 98, in > DailyLog > dt = self.Date (time ()) > TypeError: 'module' object is not callable > > Googling the "TypeError" message suggests that I've got a module and > class with the same name, but I can't see that I have. The error message just says that you have called a module which is time in this case. Just replace the call to time by time.time() and it shall work. From jyoung79 at kc.rr.com Tue Apr 15 10:18:39 2008 From: jyoung79 at kc.rr.com (jyoung79 at kc.rr.com) Date: Tue, 15 Apr 2008 9:18:39 -0500 Subject: Get oldest folder Message-ID: <22671872.735671208269119432.JavaMail.root@hrndva-web19-z02> I'd like to be able to get the path to the oldest folder in whatever directory I'm currently in. Is there a simple way to go about this? I'd like it to run on both OS X and Windows XP. I found this example at "http://trac.v2v.cc/browser/python-v2v/v2v/v2v.py?rev=python-v2v%2C37", but was curious if there's a better way to do this? def get_oldest_v2v_folder(): 404 ''' 405 returns the oldest folder in share_dir 406 407 is this the right way to check for the oldest folder? 408 could be better to read the info file and 409 extract the date there. 410 ''' 411 global share_dir 412 oldest_timestamp=time.time() 413 folders=listdir(share_dir) 414 for folder in folders: 415 if isdir(join(share_dir,folder)): 416 if stat(join(share_dir,folder)).st_ctime < oldest_timestamp: 417 oldest_timestamp=stat(join(share_dir,folder)).st_ctime 418 oldest_folder=folder 419 return join(share_dir,oldest_folder) Thanks for looking at my question. Jay From rickbking at comcast.net Thu Apr 10 10:40:32 2008 From: rickbking at comcast.net (Rick King) Date: Thu, 10 Apr 2008 10:40:32 -0400 Subject: urgent question, about filesystem-files In-Reply-To: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> References: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> Message-ID: <47FE26E0.5000001@comcast.net> An HTML attachment was scrubbed... URL: From adelagon at gmail.com Thu Apr 10 06:09:40 2008 From: adelagon at gmail.com (Alvin Delagon) Date: Thu, 10 Apr 2008 18:09:40 +0800 Subject: PyArg_ParseTuple for structs or binary data Message-ID: <7a01f6c00804100309u7813df38n998fa1b946fd921c@mail.gmail.com> Hello Gabriel, I just recently discovered that struct.pack does return a string. Everything works fine now. Thanks for the heads up! static PyObject * sendMessage(PyObject *self, PyObject *args) { char *msg = ""; int len; if (!PyArg_ParseTuple(args, "s#", &msg, &len)) return NULL; ret = sctp_sendmsg(connSock, msg, len, 0, 0, 0x03000000, 0, 0x01, 0, 0); return Py_BuildValue("l", ret); } ---- Alvin Delagon -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlwuhwdmckay at gmail.com Sat Apr 26 09:30:10 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:30:10 -0700 (PDT) Subject: windows xp crack Message-ID: windows xp crack http://cracks.00bp.com F R E E C R A C K S From sturlamolden at yahoo.no Thu Apr 24 22:40:43 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 19:40:43 -0700 (PDT) Subject: Remove multiple inheritance in Python 3000 References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> Message-ID: <60fc4333-6d2b-40f5-b311-031d90a38d39@k37g2000hsf.googlegroups.com> On Apr 22, 1:07 pm, GD wrote: > Please remove ability to multiple inheritance in Python 3000. Too late for that, PEPs are closed. > Multiple inheritance is bad for design, rarely used and contains many > problems for usual users. > > Every program can be designed only with single inheritance. That's how the Java designers were thinking as well: If MI is allowed, programmers will suddenly get an irresistible urge to use MI to write unmaintainable spaghetti code. So let's disallow MI for the sake of common good. Fortunately, Python is not designed to be fool proof against fools. If you cannot use MI properly, then don't use that. > I also published this request athttp://bugs.python.org/issue2667 You reported MI as a bug??? From victorsubervi at gmail.com Wed Apr 2 15:36:43 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 2 Apr 2008 14:36:43 -0500 Subject: Strange MySQL Problem... Message-ID: <4dc0cfea0804021236n1faafabav1699fbe45acc3c01@mail.gmail.com> Hi; I have this code which works fine: #!/usr/local/bin/python import _mysql import MySQLdb, cPickle host = 'mysqldb2.ehost-services.com' user = 'user' passwd = 'pass' db = 'bre' print 'Content-Type: image/jpeg\r\n' print '\nHi!\n' connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) imgfile=open("1.jpg",'rb') f = imgfile.read() cursor = connection.cursor() cursor.execute("CREATE TABLE justatest (name TEXT, ablob BLOB)") names = 'aramis', 'athos', 'porthos' data = {} for name in names: datum = list(name) datum.sort() data[name] = cPickle.dumps(datum, 1) sql = "INSERT INTO justatest VALUES (%s, %s)" cursor.execute(sql, ('ramis', _mysql.escape_string(f)) ) imgfile.close() connection.close() print '\nBye!\n' Now, if I take out this part, which I can?t see does anything at all in the code, it no longer works: names = 'aramis', 'athos', 'porthos' data = {} for name in names: datum = list(name) datum.sort() data[name] = cPickle.dumps(datum, 1) Why? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From malaclypse2 at gmail.com Wed Apr 2 16:50:03 2008 From: malaclypse2 at gmail.com (Jerry Hill) Date: Wed, 2 Apr 2008 16:50:03 -0400 Subject: default method parameter behavior In-Reply-To: <879d72da-825f-4b2b-8244-87367647fb6e@f63g2000hsf.googlegroups.com> References: <879d72da-825f-4b2b-8244-87367647fb6e@f63g2000hsf.googlegroups.com> Message-ID: <16651e80804021350s460a84e5y1c500f05660ff133@mail.gmail.com> On Wed, Apr 2, 2008 at 3:59 PM, wrote: > I ran into a similar situation like the following (ipython session). > Can anyone please explain why the behavior? http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects Since you got bitten by this, you may also find it useful to take a look at one of the pages that talks about common python problems, like http://zephyrfalcon.org/labs/python_pitfalls.html or http://www.ferg.org/projects/python_gotchas.html (both of which mention the problems with mutable default arguments). -- Jerry From algaba at droog.sdf-eu.org Sun Apr 20 14:54:20 2008 From: algaba at droog.sdf-eu.org (algaba at droog.sdf-eu.org) Date: Sun, 20 Apr 2008 18:54:20 +0000 (UTC) Subject: What happened with python? messed strings? Message-ID: Hi, I used extensively python and now I find this mess with strings, I can't even reproduce tutorial examples: >>> "apfel".encode('utf-8') (it was with umlaut) File "", line 0 ^ SyntaxError: 'ascii' codec can't decode byte 0xc4 in position 1: ordinal not in range(128) >>> Is there any good guide to this mess of codecs and hell ? python should have stayed at version 1.5, every single 'improvement' has been a mess. But this is the definitive hell. thanks! -- SDF-EU Public Access UNIX System - http://sdf-eu.org From davecook at nowhere.net Thu Apr 10 23:02:54 2008 From: davecook at nowhere.net (David Cook) Date: Fri, 11 Apr 2008 03:02:54 GMT Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <7xod8h39zu.fsf@ruckus.brouhaha.com> Message-ID: On 2008-04-10, Paul Rubin wrote: > Well, it's a trade-off, the person wanted a cross platform gui and the > #1 hurdle for something like PyQt4 is getting it to work on each of > the platforms you desire to run on. Installing Pyqt on windows involves a couple "click to install" EXEs. On Linux, one uses yum or apt. Only on Mac is it marginally a bit harder. Dave Cook From michael at stroeder.com Wed Apr 23 17:37:46 2008 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Wed, 23 Apr 2008 23:37:46 +0200 Subject: python-ldap: searching without specifying an OU? In-Reply-To: <8ef38281-a6fe-4501-b711-a24cd9f35a24@t54g2000hsg.googlegroups.com> References: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> <58546d42-bc80-4f9d-be90-e184c312e2d1@k37g2000hsf.googlegroups.com> <0ke3e5-ccc.ln1@nb2.stroeder.com> <8ef38281-a6fe-4501-b711-a24cd9f35a24@t54g2000hsg.googlegroups.com> Message-ID: hotani wrote: > It seems the only way I can bind is by using this format: > simple_bind_s('user at server.local','password') Believe me: This is not true. > If I try using a DN, it fails every time. This will not work: > simple_bind_s('cn=user,dc=server,dc=local', 'password') Check the DN you're using. Maybe you should search this particular user entry with filter (userPrincipalName=user at server.local) Ciao, Michael. From rafal.wysocki at gmail.com Sat Apr 19 04:15:13 2008 From: rafal.wysocki at gmail.com (=?ISO-8859-2?Q?Rafa=B3_Wysocki?=) Date: Sat, 19 Apr 2008 01:15:13 -0700 (PDT) Subject: Tkinter, getting canvas-object, how? References: <4d5c6911-7728-4dad-8d8d-7a862bf78d70@k13g2000hse.googlegroups.com> Message-ID: <4814820b-a3d2-44c1-9db4-0069463f079f@a23g2000hsc.googlegroups.com> skanem... at yahoo.se napisa?(a): > so i load a gif onto a canvas and when i click the canvs i want to get > the color of the pixel that is clicked. > so i need to ge the object im clicking. > i was told in another thread to use find_withtag or find_closest but > it is not working, maybe im using the > method on the wrong object. > how do i do this? > and how do i then get specifics about that object, ie the pixel-color? > > Exception in Tkinter callback > Traceback (most recent call last): > File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ > return self.func(*args) > File "C:\Users\saftarn\Desktop\pythonkod\mapexperiments > \mapgetobject.py", line 17, in callback > undermouse=find_closest(master.CURRENT) > NameError: global name 'find_closest' is not defined > > from Tkinter import * > > master = Tk() > > w = Canvas(master, width=400, height=625) > w.pack(expand = YES, fill = BOTH) > > mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\Maps\provinces-of- > sweden.gif') > w.create_image(30, 30, image = mapq, anchor = NW) > > def key(event): > print "pressed", repr(event.char) > > def callback(event): > clobj=event.widget > ## undermouse=find_withtag(master.CURRENT) > undermouse=find_closest(master.CURRENT) > print repr(undermouse) > > w.bind("", key) > w.bind("", callback) > w.pack() > > mainloop() from Tkinter import * master = Tk() w = Canvas(master, width=400, height=625) w.pack(expand = YES, fill = BOTH) mapq = PhotoImage(file = 'img.gif') _id = w.create_image(0, 0, image = mapq, anchor = NW) objects = {} # map id to object objects[_id] = mapq def key(event): print "pressed", repr(event.char) def callback(event): x, y = w.canvasx(event.x), w.canvasy(event.y) # Translates a window x,y coordinates to a canvas coordinate _id = w.find_closest(x,y)[0] # Returns tuple containing the object id obj = objects[_id] # Finds object with given id print 'color: %s' % obj.get(int(x), int(y)) w.bind("", key) w.bind("", callback) w.pack() mainloop() From blog553 at watchesblog.cn Mon Apr 21 05:53:09 2008 From: blog553 at watchesblog.cn (blog553 at watchesblog.cn) Date: Mon, 21 Apr 2008 02:53:09 -0700 (PDT) Subject: Invicta 3284 Swiss Quartz Ladies Watch - Replica Watch Fake Message-ID: <82e66f04-fa14-4462-892f-e810b3c9eb9b@y18g2000pre.googlegroups.com> Invicta 3284 Swiss Quartz Ladies Watch - Replica Watch Fake Invicta 3284 Swiss Quartz Ladies Watch Link : http://www.watchesprice.net/Replica-Invicta-17515.html Replica Watches Home : http://www.watchesprice.net/ Replica Invicta Brands : http://www.watchesprice.net/Invicta-Replica.html Replica Invicta 3284 Swiss Quartz Ladies Watch --- one of best selling replica watches, it is crafted in high quality, please click image 'buy now' to buy this chic but inexpensive replica to save you a lot of money . Invicta 3284 Swiss Quartz Ladies Watch Description: Availability: Usually Ships In 1 - 2 Business DaysInvicta 3284 Swiss Quartz Ladies WatchInvicta 3284 Swiss Quartz Ladies Watch. Stainless Steel case, blue dial, quartz movement, stainless steel, water resistant up to 165 ft, scratch resistant mineral, covered with 1 Year Invicta WarrantyInvicta 3284 Swiss Quartz Ladies Watch is brand new, join thousands of satisfied customers and buy your Invicta 3284 Swiss Quartz Ladies Watch with total satisfaction . A Weholesale-watches.org 30 Day Money Back Guarantee is included with every Invicta 3284 Swiss Quartz Ladies Watch for secure, risk-free online shopping. Weholesale- watches.org does not charge sales tax for the Invicta 3284 Swiss Quartz Ladies Watch, unless shipped within New York State. Weholesale- watches.org is rated 5 stars on the Yahoo! network. Invicta 3284 Swiss Quartz Ladies Watch Details: Brand: Invicta Thank you for choosing www.watchesprice.net as your reliable dealer of quality waches including Invicta 3284 Swiss Quartz Ladies Watch . we guarantee every watch you receive will be exact watch you ordered. Each watch sold enjoy one year Warranty for free repair. Every order from aaa-replica-watches is shipped via EMS, the customer is responsible for the shipping fee on the first order, but since the second watch you buy from our site, the shipping cost is free. Please note that If the total amount of payment is over $600(USD), the customer is required to contact our customer service before sending the money in case failed payment. If you have any other questions please check our other pages or feel free to email us by service at watchesprice.net. Cheapest Invicta 3284 Swiss Quartz Ladies Watch The Same Invicta Series : Invicta 3283 Swiss Quartz Ladies Watch : http://www.watchesprice.net/Replica-Invicta-17516.html Invicta 3239 Lady Quartz Date Traditional Women's Watch : http://www.watchesprice.net/Replica-Invicta-17517.html Invicta 3254 Men Quartz Date Traditional Mens Watch : http://www.watchesprice.net/Replica-Invicta-17518.html Invicta 3282 Swiss Quartz Grey Ladies Watch : http://www.watchesprice.net/Replica-Invicta-17519.html Invicta 3281 Swiss Quartz Ladies Watch : http://www.watchesprice.net/Replica-Invicta-17520.html Invicta 3248 Men Quartz Date Traditional Men's Watch : http://www.watchesprice.net/Replica-Invicta-17521.html Invicta 3238 Lady Quartz Date Traditional Women's Watch : http://www.watchesprice.net/Replica-Invicta-17522.html Invicta 3237 Lady Quartz Date Traditional Women's Watch : http://www.watchesprice.net/Replica-Invicta-17523.html Invicta Stainless Steel Mens Watch 3925 : http://www.watchesprice.net/Replica-Invicta-17524.html Invicta 10-Year Stainless Steel Mens Watch 3926 : http://www.watchesprice.net/Replica-Invicta-17525.html Invicta 10-Year Stainless Steel Mens Watch 3924 : http://www.watchesprice.net/Replica-Invicta-17526.html Invicta 3664 Flight Collection Blue Dial Mens Watch : http://www.watchesprice.net/Replica-Invicta-17527.html From fennelllindy8241 at gmail.com Mon Apr 28 03:19:21 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:19:21 -0700 (PDT) Subject: crack library Message-ID: <56cfef41-76ea-4280-8bb5-8db99ce60cce@a23g2000hsc.googlegroups.com> crack library http://crack.cracksofts.com From juice at lemonacid.com Wed Apr 30 09:41:26 2008 From: juice at lemonacid.com (test) Date: Wed, 30 Apr 2008 15:41:26 +0200 Subject: relative import broken? Message-ID: <000601c8aac7$e5fd84b0$49d32401@silver> basic noob question here. i am trying to reference a package, i have the structure: mypack/ __init__.py test.py subdir1/ __init__.py mod1.py subdir2/ __init__.py mod2.py can someone please tell me why the statement: from mypack.subdir1.mod1 import * does NOT work from mod2.py nor from test.py? instead, if i use: from subdir1.mod1 import * it works perfectly from test.py. ....? thank you, aj. From dteslenko at gmail.com Mon Apr 14 11:08:40 2008 From: dteslenko at gmail.com (Dmitry Teslenko) Date: Mon, 14 Apr 2008 19:08:40 +0400 Subject: pygtk + threading.Timer In-Reply-To: References: Message-ID: <91325fec0804140808o76bfac5fq55cc74a07e2f09d5@mail.gmail.com> 2008/4/14 Jarek Zgoda : > > I have simple chat application with pygtk UI. I want some event (for > > example update user list) to have place every n seconds. > > What's the best way to archive it? > > I tried threading.Timer but result is following: all events wait till > > exit of gtk main loop and only then they occur. > > Thanks in advance > > See gobject.timeout_add documentation in pygtk reference Thanks. That's exactly what I need. From grante at visi.com Sun Apr 20 19:48:40 2008 From: grante at visi.com (Grant Edwards) Date: Sun, 20 Apr 2008 18:48:40 -0500 Subject: Nested lists, simple though References: Message-ID: <8ZednTiHOJzFS5bVnZ2dnUVZ_qGknZ2d@visi> On 2008-04-20, Zethex wrote: > Im a bit new to python. Anyway working on a little project of mine and i > have nested lists What you want to do is usually called "flattening". http://mail.python.org/pipermail/tutor/2001-January/002914.html http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/363051 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/121294 -- Grant Edwards grante Yow! HAIR TONICS, please!! at visi.com From gagsl-py2 at yahoo.com.ar Sun Apr 20 15:48:06 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 16:48:06 -0300 Subject: What happened with python? messed strings? References: Message-ID: En Sun, 20 Apr 2008 15:54:20 -0300, escribi?: > I used extensively python and now I find this mess with strings, > I can't even reproduce tutorial examples: >>>> "apfel".encode('utf-8') (it was with umlaut) > File "", line 0 > ^ > SyntaxError: 'ascii' codec can't decode byte 0xc4 in position 1: > ordinal not in range(128) >>>> > Is there any good guide to this mess of codecs and hell ? The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) Python Unicode Howto: > python should have stayed at version 1.5, every single 'improvement' > has been a mess. But this is the definitive hell. Nobody forces you to use a newer version. You can download 1.5.2 from http://www.python.org/download/releases/1.5 -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Mon Apr 14 00:58:35 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 14 Apr 2008 01:58:35 -0300 Subject: how to remove \n in the list References: <2ba667ab-6818-47eb-8595-79ed970728f7@q1g2000prf.googlegroups.com> Message-ID: En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam escribi?: > hi, > l=['5\n', '2\n', '7\n', '3\n', '6\n'] > > how to remove \n from the given list l is is very poor name... I'll use lines instead: lines[:] = [line.rstrip('\n') for line in lines] -- Gabriel Genellina From tjreedy at udel.edu Wed Apr 2 15:33:05 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 2 Apr 2008 15:33:05 -0400 Subject: function call - default value & collecting arguments References: <_LQIj.9776$HS3.482805@news.siol.net> Message-ID: "Primoz Skale" wrote in message news:_LQIj.9776$HS3.482805 at news.siol.net... | def f(*a=(0,)): | print a[0] #this should come next, but we get error msg instead, saying | | SyntaxError: invalid syntax | | but it does not work this way. Now my 'newbie' question: Why not? :) Possibly because no one ever thought of that. More likely because it is contradictory: by definition, *a *always* gets a value, so there is never a need for a 'default'. When a param gets a value you don't like, you have to explicitly replace it or whatever. So add at the top 'a = a or (0,)' tjr From cyberco at gmail.com Wed Apr 16 07:54:48 2008 From: cyberco at gmail.com (Berco Beute) Date: Wed, 16 Apr 2008 04:54:48 -0700 (PDT) Subject: Image handling - stupid question References: <0001HW.C42B9FB90009B7E8B01AD9AF@news.individual.de> Message-ID: <003bf250-875a-418a-b3ce-a295f30aa5b9@a1g2000hsb.googlegroups.com> On Apr 16, 12:21 pm, Jumping Arne wrote: > I'm going to try to write some imange manipulation code (scaling, reading > EXIF and IPTC info) and just want to ask if PIL is *THE* library to use? Depends on your requirements, but it's certainly the first library I would check out. It offers lots of functionality, it is easy to use, well documented and rock solid. > I looked at and noticed that the > latest version is from Dec 2006. > > In my experience that means that either it's abandoned or that it's very good > and stable. The latter (what else would you expect from /F? :) 2B From jon+usenet at unequivocal.co.uk Wed Apr 23 21:16:51 2008 From: jon+usenet at unequivocal.co.uk (Jon Ribbens) Date: Wed, 23 Apr 2008 20:16:51 -0500 Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> Message-ID: On 2008-04-23, Mark Wooding wrote: > Python is actually one of the few to define one but not the other. (The > other one I can think of is Acorn's BBC BASIC, for whatever that's > worth; it too lacks `++'.) You should've added it in Termite Basic then :-p From mccredie at gmail.com Mon Apr 21 19:59:30 2008 From: mccredie at gmail.com (Matimus) Date: Mon, 21 Apr 2008 16:59:30 -0700 (PDT) Subject: Code question References: <60ffc058-488f-4e58-b3c9-a60c21595c6f@w8g2000prd.googlegroups.com> Message-ID: On Apr 21, 4:16 pm, George Sakkis wrote: > On Apr 21, 4:42 pm, Matimus wrote: > > > > > On Apr 21, 12:05 pm, wrote: > > > > I've been trying to figure out a way to combine lists similar to how zip() works. The main > > > difference though is I want to work with different length lists and combine them. I came up with > > > the example below, which returns a list like I'm wanting. I'm assuming it's somewhat efficient > > > (although I wonder if the lists were huge that the 'if' statement might slow things down?). > > > > If anyone has time, I was wondering if you could share your thoughts on whether this is an > > > efficient way to do something like this, if it's horrible and slow, etc. > > > > Thanks! > > > > Jay > > > > # ---------------------------- > > > > def combineLists(theLists): > > > cntList = len(theLists) > > > lenList = [len(x) for x in theLists] > > > > maxList = max(lenList) > > > > combinedList = [] > > > > for x in range(maxList): > > > for n in range(cntList): > > > if lenList[n] > x: combinedList.append(theLists[n][x]) > > > > print combinedList > > > > combineLists([a, b, c]) > > > > # ---------------------------- > > > > # --> ['a', '1', 'a1', 'b', '2', 'b2', 'c', 'c3', 'd4', 'e5'] > > > I would probably do something like this: > > > >>> def combine(*seqs): > > > ... seqs = [iter(s) for s in seqs] > > ... while seqs: > > ... for g in seqs: > > ... try: > > ... yield g.next() > > ... except StopIteration: > > ... seqs.remove(g) > > ...>>> a = 'abc' > > >>> b = '12' > > >>> c = 'a1 b2 c3 d4 e5'.split() > > >>> list(combine(a,b,c)) > > > ['a', '1', 'a1', 'b', '2', 'b2', 'c', 'c3', 'd4', 'e5'] > > > It has the advantage that it uses the generator protocol, so you can > > pass in any type of sequence. It uses arbitrary arguments to make its > > use closer to that of zip. It is also a generator, so it takes > > advantage of lazy evaluation. Notice that there is never any checking > > of length. > > > Matt > > A similar solution using the itertools module:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/528936 > > George Very nice. I was wondering if there would be a way to pull that try/ except block outside of the for loop. Jay: use this solution. It has all of the advantages I list for my solution, only it should be faster, and lazier. Matt From george.sakkis at gmail.com Fri Apr 4 12:22:13 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 4 Apr 2008 09:22:13 -0700 (PDT) Subject: Tokenizer inconsistency wrt to new lines in comments Message-ID: <1ce40dcf-4a0a-4577-af3b-6a77ef71356c@f63g2000hsf.googlegroups.com> The tokenize.generate_tokens function seems to handle in a context- sensitive manner the new line after a comment: >>> from StringIO import StringIO >>> from tokenize import generate_tokens >>> >>> text = ''' ... # hello world ... x = ( ... # hello world ... ) ... ''' >>> >>> for t in generate_tokens(StringIO(text).readline): ... print repr(t[1]) ... '\n' '# hello world\n' 'x' '=' '(' '\n' '# hello world' '\n' ')' '\n' '' Is there a reason that the newline is included in the first comment but not in the second, or is it a bug ? George From gagsl-py2 at yahoo.com.ar Thu Apr 3 00:39:27 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 01:39:27 -0300 Subject: Python queue madness References: <28749c0e0804020652o74a9491an9eef9ba1813434fb@mail.gmail.com> Message-ID: En Wed, 02 Apr 2008 10:52:08 -0300, nnp escribi?: > Basically I have a system where component 1, 2 and 3 communicate with > each > other using two Python Queues, we'll call them R and W. Here is what is > happening > > 1 writes data to W and reads from R > 2 reads data from W and writes data it receives from 3 to R (but not > data it > receives from 1) > 3 writes to W > > The problem is that data being written by 1 to W is appearing back on R. > I > have verified that 1 never writes to R and that 2 never writes data it > receives from 1 to R, by overwriting the put() and put_nowait() methods > of > R. > > Is there any other way for data to get onto a queue or are there any > known > bugs with Python's Queue module that could lead to this kind of > behaviour? Yes, your own code :) Perhaps you put mutable objects into the queue, like a list? and later modify the list in another place? -- Gabriel Genellina From python at bdurham.com Tue Apr 29 10:48:33 2008 From: python at bdurham.com (python at bdurham.com) Date: Tue, 29 Apr 2008 10:48:33 -0400 Subject: Given a string - execute a function by the same name In-Reply-To: <48171FCD.90902@mxm.dk> References: <1209471041.12820.1250459017@webmail.messagingengine.com> <48171FCD.90902@mxm.dk> Message-ID: <1209480513.8422.1250489215@webmail.messagingengine.com> Hi Max, Thank you for pointing out the pattern of my request. Using your google query (http://www.google.dk/search?hl=en&q=python+factory+pattern) I found the following description of what I'm doing. Command Dispatch Pattern http://www.suttoncourtenay.org.uk/duncan/accu/pythonpatterns.html#id26 Regards, Malcolm From goldspin at gmail.com Wed Apr 2 00:53:34 2008 From: goldspin at gmail.com (Henry Chang) Date: Tue, 1 Apr 2008 21:53:34 -0700 Subject: Basic class implementation question In-Reply-To: References: Message-ID: Try this. class wontwork: def really(self): print "Hello World" wontwork().really() On Tue, Apr 1, 2008 at 9:43 PM, wrote: > I can't get call a class for some reason. This must be one of those > newbie questions I hear so much about: > > class wontwork: > def really(): > print "Hello World" > > wontwork.really() > > This returns (as an error): > > Traceback (most recent call last): > File "", line 1, in > wontwork.really() > TypeError: unbound method really() must be called with wontwork > instance as first argument (got nothing instead) > > Any ideas? > -- > http://mail.python.org/mailman/listinfo/python-list > From duncan.booth at invalid.invalid Tue Apr 15 05:47:27 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 15 Apr 2008 09:47:27 GMT Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <1208196168.24295.36.camel@localhost.localdomain> <526792b1-acc2-4e48-8e9f-cc2641134958@k37g2000hsf.googlegroups.com> Message-ID: Chris wrote: > even is closer to even.75 than even+1.25. Why should it be rounded > up ? Because the OP wants to round values to the nearest integer. Only values of the form 'x.5' which have two nearest values use 'nearest even' to disambiguate the result. See http://en.wikipedia.org/wiki/Rounding#Round-to-even_method That's the way I was taught to round numbers when at primary school. From ncoghlan at gmail.com Mon Apr 21 09:14:08 2008 From: ncoghlan at gmail.com (NickC) Date: Mon, 21 Apr 2008 06:14:08 -0700 (PDT) Subject: Java or C++? References: Message-ID: On Apr 15, 1:46 pm, Brian Vanderburg II wrote: > This will automatically call the constructors of any contained objects > to initialize the string. The implicit assignment operator > automatically performs the assignment of any contained objects. > Destruction is also automatic. When 'p1' goes out of scope, during the > destructor the destructor for all contained objects is called. Yeah, C++ does try to be helpful, and all of those automatic copy constructor, assignment operator and destructor implementations screw up royally when confronted with pointers (and being able to use pointers is basically the whole reason for bothering to write anything in C or C++ in the first place). Code which relies on these default method implementations is almost certain to be rife with memory leaks and double-free bugs. So instead of being a convenience, they become a painfully easy way of writing code that silently does some very, very wrong things. Other things like methods (including destructors!) being non-virtual by default also make C++ code annoyingly easy to get wrong (without it obviously looking wrong). The whole design of C++ is riddled with premature optimisation of speed and memory usage in the default settings, instead of choosing safe defaults and providing concise ways of allowing the programmer to say "I know optimisation X is safe here, please use it". And the result? Any serious project in the language has to adopt it's own techniques for avoiding all those traps, and those techniques are likely to eliminate any supposed optimisations provided by the choices of the C++ committee, while filling a code base with boilerplate that only exists for the purpose of working around defects in the language design (Scott Meyers has written at length about the worst of these issues, far more clearly and eloquently than I ever could [1]). That said, C++ code has one *huge* benefit over ordinary C code, which is scope-controlled deletion of objects, and the associated Resource- Acquisition-Is-Initialisation model. Even without using exceptions (although those are handy as well), RAII is an excellent way of guaranteeing that memory is freed, files are closed, or other resources are released when a block of code is finished. RAII was actually one of the inspirations behind the final form of PEP 343's with statement. Cheers, Nick. [1]http://www.amazon.com/Effective-Specific-Addison-Wesley- Professional-Computing/dp/0201924889 From bvidinli at gmail.com Mon Apr 14 09:42:28 2008 From: bvidinli at gmail.com (bvidinli at gmail.com) Date: Mon, 14 Apr 2008 14:42:28 +0100 (BST) Subject: A Question Message-ID: <200804141342.CBB81112@manxnetsf02.manx.net> Fertler? From deets at nospam.web.de Fri Apr 11 21:13:19 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Sat, 12 Apr 2008 03:13:19 +0200 Subject: Wrapping C++ class with SWIG, Mac OS X In-Reply-To: References: Message-ID: <66aglpF2ihunjU1@mid.uni-berlin.de> Paul Anton Letnes schrieb: > Hello guys, > > > (related to previous thread on wrapping C/C++ in Python, trying the SWIG > approach.) > Trying to map a C++ class to python, one method for now. Running the > following commands to "compile": > > -------------------------------------- > #!/usr/bin/env bash > > MOD_NAME=Wavelet > > > swig -c++ -python -o ${MOD_NAME}_wrap.cpp ${MOD_NAME}.i > > gcc -c++ -fPIC -c ${MOD_NAME}.cpp -o ${MOD_NAME}.o > -I/usr/include/python2.5 -I/usr/lib/python2.5 > > gcc -c++ -fPIC -c ${MOD_NAME}_wrap.cpp -o ${MOD_NAME}_wrap.o > -I/usr/include/python2.5 -I/usr/lib/python2.5 > > gcc -bundle -flat_namespace -undefined suppress -o _${MOD_NAME}.so > ${MOD_NAME}.o ${MOD_NAME}_wrap.o > -------------------------------------- > > The source code is: > -------------------------------------- > Wavelet.h > -------------------------------------- > #ifndef _WAVELET_H_ > #define _WAVELET_H_ > > #include > #include > > using namespace std; > > class Wavelet > { > > public: > Wavelet(vector theV); > ~Wavelet(); > vector GetDaub4Trans(); > > private: > vector v; > > }; > > > #endif /*_WAVELET_H_*/ > -------------------------------------- > and Wavelet.cpp: > -------------------------------------- > #include "wavelet.h" > > Wavelet::Wavelet(vector theV) > { > this->v = theV; > } > > Wavelet::~Wavelet() > { > // Nothing for now > } > > vector Wavelet::GetDaub4Trans() > { > vector retV = vector(); > retV.push_back(3.14); > retV.push_back(2.71); > retV.push_back(1.62); > return retV; > // just to test the approach - everything in here I can fix later. > } > -------------------------------------- > This seems to compile, but in python I get: > -------------------------------------- > $ python > imPython 2.5.2 (r252:60911, Mar 30 2008, 22:49:33) > [GCC 4.0.1 (Apple Inc. build 5465)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > >>> import Wavelet > Traceback (most recent call last): > File "", line 1, in > File "Wavelet.py", line 7, in > import _Wavelet > ImportError: dlopen(./_Wavelet.so, 2): Symbol not found: > __ZNKSt11logic_error4whatEv > Referenced from: /Users/paul/Desktop/Wavelet_SWIG_Cpp/_Wavelet.so > Expected in: flat namespace > > >>> > -------------------------------------- > > Any ideas or tips? SWIG seems very nice for simple C methods where you > pass an int and return an int, but I can't seem to figure out the > syntaxes etc for more complicated stuff - arrays, vector, C++, ... > Appreciate any help! Can't help on SWIG - all I can say is that SIP which is used to wrap the large and template-ridden C++-GUI-Toolkit Qt worked flawlessly for me. Maybe you should try that. Diez From alexdbkim at gmail.com Tue Apr 15 03:42:56 2008 From: alexdbkim at gmail.com (Alexander Dong Back Kim) Date: Tue, 15 Apr 2008 00:42:56 -0700 (PDT) Subject: How to import C++ static library? Message-ID: Hi all, I'm very very beginner of python but I'm dare to ask this question straight away. =P Is it possible to import C++ static library compiled by GCC? The target is definitely Linux machine. I found some examples from Google showing the way C++ can import Python so called embedded python. But I want to the opposite way of this. I want to import (or include in C world terminology) the library which is a blah.a file to reuse in python. Any suggestion or idea for this stupid beginner? ;) cheers, Alex From mail at timgolden.me.uk Sat Apr 12 01:58:05 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Sat, 12 Apr 2008 06:58:05 +0100 Subject: Windows - window status (Running vs Not Responding) In-Reply-To: References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> Message-ID: <48004F6D.2010100@timgolden.me.uk> Ross Ridge wrote: > rdahlstrom wrote: >> Basically, I'm looking for something similar to the Process.Responding >> property in System.Diagnostics... > > You probably want to use IsHungAppWindow(): Brilliant! So simple when you find out. Thanks. (Added to my list of things I never knew I never knew about Windows). TJG From deets at nospam.web.de Tue Apr 22 15:17:18 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 21:17:18 +0200 Subject: Spawing a thread and printing dots until it finishes In-Reply-To: References: Message-ID: <676ruhF2lt14mU1@mid.uni-berlin.de> > I think that there are two things that you need to wrap your head > around before understanding what is happening here. First, threads are > NOT pre-emptive. Unless your thread gives up the processor it will run > forever. The sleep call is one way to give up the processor. That is not correct, at least not on usual OSes. The posix-threads as well as windows threads *are* preemptive. > Second, sleep() does not return as soon as the time given has expired. > The argument is the MINIMUM amount of time that it waits. After that > the thread that slept is put back onto the run queue and is now a > candidate to be given the processor. Your other thread still has to > give up the processor before it can run again and even then there may > be other threads on the queue ahead of yours. > > So, does your thread ever give up the processor other than by dying? It shouldn't need to. It will be rescheduled. The code looks ok to me - the problem seems to be in the R-Python as Gabriel pointed out. Diez From mail at timgolden.me.uk Fri Apr 11 09:47:20 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 11 Apr 2008 14:47:20 +0100 Subject: Convert PyIDispatch object to struct IDispatch* In-Reply-To: <83260aaf-b2d7-4857-bd71-a8e7b30c6d70@n14g2000pri.googlegroups.com> References: <90eee1e1-b1cc-48a9-8c09-173e92861f2c@a5g2000prg.googlegroups.com> <83260aaf-b2d7-4857-bd71-a8e7b30c6d70@n14g2000pri.googlegroups.com> Message-ID: <47FF6BE8.2030606@timgolden.me.uk> Huayang Xia wrote: > On Apr 11, 12:15 am, "Gabriel Genellina" > wrote: >> En Thu, 10 Apr 2008 18:45:04 -0300, Huayang Xia >> escribi?: >> >>> I am trying to use ctypes to call dll functions. One of the functions >>> requires argument "struct IDispatch* ". I do have a PyIDispatch object >>> in python. How can I convert this "PyIDispatch object" to "struct >>> IDispatch* "? >> I think a PyIDispatch object is an IDispatch* itself. >> But you'll get better answers from the python-win32 list:http://mail.python.org/mailman/listinfo/python-win32 >> >> -- >> Gabriel Genellina > > Thanks for the info. > > To call a dll function, it needs a C style IDispatch*. PyIDispatch is > a python wrapped one. I found a reference from: > > http://svn.python.org/projects/ctypes/trunk/comtypes/comtypes/test/test_win32com_interop.py > > which shows how to convert C style to python style. Unfortunately i > need the reversed version. > > I will post the question to python-win32. I've had a quick look at the PyIDispatch source and I can't see any obvious way in which the underlying IDispatch is exposed. May have missed something, but it's possible that there's not way out. TJG From steve at holdenweb.com Wed Apr 23 15:26:37 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 15:26:37 -0400 Subject: Partition list with predicate In-Reply-To: References: <925822270804230959v557ec5f5re02737709f94d3c6@mail.gmail.com> Message-ID: Terry Reedy wrote: > "Jared Grubb" wrote in message > news:925822270804230959v557ec5f5re02737709f94d3c6 at mail.gmail.com... > | I want a function that removes values from a list if a predicate > evaluates > | to True. > > Forget the rigamarole you posted, which has several defects. > If you must modify the list in place, because you have multiple references > to it: > > lst[:] = filter(lambda x: not pred(x), lst) > Wouldn't lst[:] = [x for x in lst if not pred(x)] be more direct? > Otherwise, just lst = filter(....) > And similarly lst = [x for x in lst if not pred(x)] regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From ptmcg at austin.rr.com Fri Apr 11 06:46:43 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Fri, 11 Apr 2008 03:46:43 -0700 (PDT) Subject: Randall Munroe loves Python Message-ID: <869c25d9-e4d3-4629-a807-f3b203f3fb65@b1g2000hsg.googlegroups.com> Another xkcd plug for Python: http://xkcd.com/409/ From bj_666 at gmx.net Mon Apr 14 03:26:05 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 14 Apr 2008 07:26:05 GMT Subject: Game design : Making computer play References: Message-ID: <66gf8dF2ju94lU3@mid.uni-berlin.de> On Mon, 14 Apr 2008 00:13:56 -0700, v4vijayakumar wrote: > In computer based, two player, board games, how to make computer play? > Are there any formal ways to _teach_ computer, to choose best possible > move? That depends on the type of the game. For a certain class of games one can use the `minimax method`_ for instance. .. _minimax method: http://en.wikipedia.org/wiki/Minimax Ciao, Marc 'BlackJack' Rintsch From ni at hao.com Wed Apr 30 03:19:22 2008 From: ni at hao.com (SL) Date: Wed, 30 Apr 2008 09:19:22 +0200 Subject: computing with characters In-Reply-To: References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl><481813E2.2030302@islandtraining.com> Message-ID: <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> "Lutz Horn" schreef in bericht news:mailman.360.1209537877.12834.python-list at python.org... > Hi, > > 2008/4/30 Gary Herron : >> SL wrote: >> > How can I compute with the integer values of characters in python? >> > Like 'a' + 1 equals 'b' etc >> >> You can get an integer value from a character with the ord() function. > > So just for completion, the solution is: > >>>> chr(ord('a') + 1) > 'b' thanks :) I'm a beginner and I was expecting this to be a member of string so I couldnt find it anywhere in the docs. From sjmachin at lexicon.net Mon Apr 14 08:11:13 2008 From: sjmachin at lexicon.net (John Machin) Date: Mon, 14 Apr 2008 05:11:13 -0700 (PDT) Subject: py2exe, program has stoped working!? References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> <232151d6-09ed-4a1e-9922-d66c2bf0d05b@w8g2000prd.googlegroups.com> Message-ID: On Apr 14, 7:24 pm, skanem... at yahoo.se wrote: > > Is it a console program or a gui program? > GUI > > What happens when you run it without py2exe? > > it works perfectly, both from within python and launching from > "windows" > > > Have you searched for "has stopped working" in > > (a) your source code > yes no such message there> (b) the py2exe source code? > > no, will do but doubt thats the problem > > > Have you managed to get any py2exe-created program to run properly? > > no Well, perhaps you might like to look in the samples directory of the py2exe distribution and choose a simple example and try that. By the way, "popup" is what you get in a web browser. What did this "popup" look like: a panel from your GUI software? A Windows message box? Did it have a title across the top? What was the exact text in the popup/panel/box? Were there any options other than to close the window? Which version of Python? Which Windows, what service pack? What GUI, what version? Care to divulge the contents of your setup.py? Apart from your GUI, what 3rd party packages/modules are you importing? From jphalip at gmail.com Tue Apr 29 09:46:05 2008 From: jphalip at gmail.com (Julien) Date: Tue, 29 Apr 2008 06:46:05 -0700 (PDT) Subject: Issue with regular expressions Message-ID: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Hi, I'm fairly new in Python and I haven't used the regular expressions enough to be able to achieve what I want. I'd like to select terms in a string, so I can then do a search in my database. query = ' " some words" with and "without quotes " ' p = re.compile(magic_regular_expression) $ <--- the magic happens m = p.match(query) I'd like m.groups() to return: ('some words', 'with', 'and', 'without quotes') Is that achievable with a single regular expression, and if so, what would it be? Any help would be much appreciated. Thanks!! Julien From sturlamolden at yahoo.no Thu Apr 24 20:19:44 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 17:19:44 -0700 (PDT) Subject: Psyco alternative References: <1369b321-f55b-432b-b2f9-6144787509d8@h11g2000prf.googlegroups.com> <7xlk4473ai.fsf@ruckus.brouhaha.com> <651ncdF2cmik2U1@mid.uni-berlin.de> <651onqF2dripdU1@mid.uni-berlin.de> <47EBB42D.9090206@behnel.de> <25b14b32-8fce-4e79-b236-c64fa96744e8@e23g2000prf.googlegroups.com> Message-ID: On Mar 27, 5:01 pm, king kikapu wrote: > Hmmm...thanks but i think Pyrex-like solution is not the ideal one. > Coming from C# and having 8 years of expertise on it, i have gain a > very positive thinking about jit compilers and i think that psyco (ok, > a just-in-time specializer) is a more easy (and more correct) way to > go that mixing 2 languages. The problem with Python, when we are talking out jit compilation, is it's reliance on attribute lookups in hash tables. Java and C# do not have dynamically bound attributes, and can implement classes using vtables. Attributes cannot be rebound in Java or C#. A Python jit cannot even do elementary optimizations like keeping an integer in a register. This makes it a lot easier to make an efficient jit compiler for Java or C#. Python is more like Common Lisp. There is no efficient jit for Lisp. But there are very fast implementations that depend on optional static typing (e.g. SBCL and CMUCL). That could be an option of Python as well, by including something like Cython and a C compiler. Any module that has a cdef is passed to Cython and CC instead of the usual bytecode compiler and interpreter. From mr.enx at alice.it Mon Apr 7 03:19:01 2008 From: mr.enx at alice.it (mr.enx at alice.it) Date: Mon, 7 Apr 2008 00:19:01 -0700 (PDT) Subject: ldap Message-ID: <050e9150-7bbf-4a46-8c63-9d61835b1429@d1g2000hsg.googlegroups.com> sorry, i'm new with Python. I must do interaction beetween Python and Ldap, and I don't know how do this. Searching on the web I know that exists PythonLdap, but I dont'know if this is best choise or not. Thank's From gagsl-py2 at yahoo.com.ar Sun Apr 20 04:12:09 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 05:12:09 -0300 Subject: Checking for unique fields: performance. References: <2dc0c81b0804180823k46a220f1w77a166e6b08f67de@mail.gmail.com> Message-ID: En Fri, 18 Apr 2008 12:23:08 -0300, Shawn Milochik escribi?: > I'm looping through a tab-delimited file to gather statistics on fill rates, > lengths, and uniqueness. > > For the uniqueness, I made a dictionary with keys which correspond to the > field names. The values were originally lists, where I would store values > found in that field. Once I detected a duplicate, I deleted the entire > element from the dictionary. Any which remained by the end are considered > unique. Also, if the value was empty, the dictionary element was deleted and > that field considered not unique. > > A friend of mine suggested changing that dictionary of lists into a > dictionary of dictionaries, for performance reasons. As it turns out, the > speed increase was ridiculous -- a file which took 42 minutes to run dropped > down to six seconds. A dictionary with keys is perfectly reasonable. But a *list* of values has to be searched linearly for every value: a O(n) process. As your friend suggested, searching a dictionary requires O(1) time. A set is even better in this case, because you don't have any use for the values in the inner dictionary (sets and dictionaries are very similar in the implementation). > Here is the excerpt of the bit of code which checks for uniqueness. It's > fully functional, so I'm just looking for any suggestions for improving it > or any comments. Note that fieldNames is a list containing all column > headers. > > #check for unique values > #if we are still tracking that field (we haven't yet > #found a duplicate value). > if fieldUnique.has_key(fieldNames[index]): > #if the current value is a duplicate > if fieldUnique[fieldNames[index]].has_key(value): > #sys.stderr.write("Field %s is not unique. Found a > duplicate value after checking %d values.\n" % (fieldNames[index], lineNum)) > #drop the whole hash element > fieldUnique.__delitem__(fieldNames[index]) > else: > #add the new value to the list > fieldUnique[fieldNames[index]][value] = 1 > - Instead of using fieldNames[index] all along the place, save it in a variable. - Your code doesn't show it, but if you are traversing the fieldNames vector like this: for index in range(len(fieldNames)): ... using fieldNames[index] ... it's better to use: for fieldName in fieldNames: ... using fieldName all along the place ... - Instead of a.has_key(b), use: b in a - Instead of fieldUnique.__delitem__(fieldNames[index]) use: del fieldUnique[fieldName] (In normal code, __special__ methods are never used) #check for unique values #if we are still tracking that field (we haven't yet #found a duplicate value). if fieldName in fieldUnique: #if the current value is a duplicate if value in fieldUnique[fieldName]: #drop the whole field as it's not unique del fieldUnique[fieldName] else: #add the new value to the set fieldUnique[fieldName].add(value) else: # use a set to store the unique values fieldUnique[fieldName] = set([value]) -- Gabriel Genellina From meisnernel73884 at gmail.com Wed Apr 30 06:37:59 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:37:59 -0700 (PDT) Subject: rar password crack Message-ID: <9be5e1ec-9d73-4f0c-bf92-5dc2dd6547e8@e53g2000hsa.googlegroups.com> rar password crack http://crack.cracksofts.com From arnodel at googlemail.com Sat Apr 26 01:37:19 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sat, 26 Apr 2008 06:37:19 +0100 Subject: Setting an attribute without calling __setattr__() References: Message-ID: Joshua Kugler writes: [...] > self.me = [] > for v in obj: > self.me.append(ObjectProxy(v)) Note that is could be spelt: self.me = map(ObjectProxy, v) -- Arnaud From mwilson at the-wire.com Wed Apr 2 10:57:50 2008 From: mwilson at the-wire.com (Mel) Date: Wed, 02 Apr 2008 10:57:50 -0400 Subject: generator functions: why won't this work? References: <0aaeddf2-ee63-426e-afb3-0e1acb15adef@r9g2000prd.googlegroups.com> Message-ID: zillow10 at googlemail.com wrote: I'd just like to test my > understanding of this. Suppose I create the following generator > object: > > g = getNextScalar(1, 2, (3, 4), 5) > > when the iterator reaches the tuple argument (3, 4) then, according to > Steve and George, the * in *arg causes this tuple to be expanded into > positional arguments, and it makes sense to do it this way. But what > happens when getNextScalar(arg) is used instead? Try it: Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def a (arg): ... print arg ... >>> def astar (*arg): ... print arg ... >>> a(3,4) Traceback (most recent call last): File "", line 1, in TypeError: a() takes exactly 1 argument (2 given) >>> astar(3,4) (3, 4) >>> a((3,4)) (3, 4) >>> astar((3,4)) ((3, 4),) >>> Mel. From meisnernel73884 at gmail.com Wed Apr 30 06:36:57 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:36:57 -0700 (PDT) Subject: soul patch Message-ID: <82de0c8d-54d3-4ddb-a78d-67deadfa75bf@f63g2000hsf.googlegroups.com> soul patch http://crack.cracksofts.com From skanemupp at yahoo.se Sun Apr 6 13:24:34 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 6 Apr 2008 10:24:34 -0700 (PDT) Subject: Tkinter, repaint?, keep size? Message-ID: <6ff2ce5f-9ba3-492c-b062-324c91e652a0@e10g2000prf.googlegroups.com> so my calculator is almost done for u that have read my previous posts. i have some minor problems i have to fix though. *one is i need to repaint once i have performed a calculation so that the old results are not left on the screen. cant find a method for that. *another is now when i write the expression to be evaluated it resizes the window as the text grows. i want the windowsize and all the buttonplacements stay constant, how do i achieve this? From martin at v.loewis.de Fri Apr 25 14:46:17 2008 From: martin at v.loewis.de (=?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Fri, 25 Apr 2008 20:46:17 +0200 Subject: Why is None <= 0 In-Reply-To: References: Message-ID: <481226f9$0$20866$9b622d9e@news.freenet.de> >>>> None <= 0 > True > > Why? > Is there a logical reason? None is smaller than anything. The choice of making it so is arbitrary, however, Python 2.x tries to impose a total order on all objects (with varying success), therefore, it is necessary to take arbitrary choices. (FWIW, in 2.x, x>=4?, it's None < numbers < anything else; numbers are ordered by value, everything else is ordered by type name, then by address, unless comparison functions are implemented). Regards, Martin From jyoung79 at kc.rr.com Mon Apr 21 15:05:12 2008 From: jyoung79 at kc.rr.com (jyoung79 at kc.rr.com) Date: Mon, 21 Apr 2008 14:05:12 -0500 Subject: Code question Message-ID: <29695217.1653031208804712889.JavaMail.root@hrndva-web20-z02> I've been trying to figure out a way to combine lists similar to how zip() works. The main difference though is I want to work with different length lists and combine them. I came up with the example below, which returns a list like I'm wanting. I'm assuming it's somewhat efficient (although I wonder if the lists were huge that the 'if' statement might slow things down?). If anyone has time, I was wondering if you could share your thoughts on whether this is an efficient way to do something like this, if it's horrible and slow, etc. Thanks! Jay # ---------------------------- a = ['a', 'b', 'c'] b = ['1', '2'] c = ['a1', 'b2', 'c3', 'd4', 'e5'] def combineLists(theLists): cntList = len(theLists) lenList = [len(x) for x in theLists] maxList = max(lenList) combinedList = [] for x in range(maxList): for n in range(cntList): if lenList[n] > x: combinedList.append(theLists[n][x]) print combinedList combineLists([a, b, c]) # ---------------------------- # --> ['a', '1', 'a1', 'b', '2', 'b2', 'c', 'c3', 'd4', 'e5'] From m.bless at gmx.de Fri Apr 18 03:06:18 2008 From: m.bless at gmx.de (Martin Bless) Date: Fri, 18 Apr 2008 09:06:18 +0200 Subject: codec for html/xml entities!? Message-ID: Hi friends, I've been OFF-Python now for quite a while and am glad being back. At least to some part as work permits. Q: What's a good way to encode and decode those entities like € or € ? I need isolated functions to process lines. Looking at the xml and sgmlib stuff I didn't really get a clue as to what's the most pythonic way. Are there library functions I didn't see? FYI, here is what I hacked down and what will probably (hopefully...) do the job. Feel free to comment. # -*- coding: iso-8859-1 -*- """\ entity_stuff.py, mb, 2008-03-14, 2008-03-18 """ import htmlentitydefs import re RE_OBJ_entity = re.compile('(&.+?;)') def entity2uc(entity): """Convert entity like { to unichr. Return (result,True) on success or (input string, False) otherwise. Example: entity2cp('€') -> (u'\u20ac',True) entity2cp('€') -> (u'\u20ac',True) entity2cp('€') -> (u'\u20ac',True) entity2cp('&foobar;') -> ('&foobar;',False) """ gotCodepoint = False gotUnichr = False if entity.startswith('&#'): if entity[2] == 'x': base = 16 digits = entity[3:-1] else: base = 10 digits = entity[2:-1] try: v = int(digits,base) gotCodepoint = True except: pass else: v = htmlentitydefs.name2codepoint.get(entity[1:-1],None) if not v is None: gotCodepoint = True if gotCodepoint: try: v = unichr(v) gotUnichr = True except: pass if gotUnichr: return v, gotUnichr else: return entity, gotUnichr def line_entities_to_uc(line): result = [] cntProblems = 0 for e in RE_OBJ_entity.split(line): if e.startswith('&'): e,success = entity2uc(e) if not success: cntProblems += 1 result.append(e) return u''.join(result), cntProblems def uc2entity(uc): cp = ord(uc) if cp > 127: name = htmlentitydefs.codepoint2name.get(cp,None) if name: result = '&%s;' % name else: result = '&#x%x;' % cp else: result = chr(cp) return result def encode_line(line): return ''.join([uc2entity(u) for u in line]) if 1 and __name__=="__main__": import codecs infile = 'temp.ascii.xml' outfile = 'temp.utf8.xml' of = codecs.open(outfile,'wb','utf-8') totalProblems = 0 totalLines = 0 for line in file(infile,'rb'): line2, cntProblems = line_entities_to_uc(line) of.write(line2) totalLines += 1 totalProblems += cntProblems of.close() print print "Summary:" print " Infile : %s" % (infile,) print " Outfile: %s" % (outfile,) print ' %8d %s %s' % (totalLines, ['lines','line'][totalLines==1], 'written.') print ' %8d %s %s' % (totalProblems, ['entities','entity'][totalProblems==1], 'left unconverted.') print '%s' % ('Done.',) Have a nice day and ru, Martin (read you, ;-) From tjreedy at udel.edu Sun Apr 6 16:34:23 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 6 Apr 2008 16:34:23 -0400 Subject: Tkinter, a lot of buttons, make prog shorter? References: Message-ID: wrote in message news:c9bf3bb9-71e4-48f6-aae0-fa9400ca8155 at j1g2000prb.googlegroups.com... | is there anyway to make this shorter? i hate having these big blocks | of similar-looking code, very unaesthetic. | maybe doesnt matter good-code-wise? | anyway can i make some function that makes this shorter? | like put the etiquettes on the button froma string of | '123+456-789*0Cr/' ? | problem is the command and lambda-func for each button is different. | | | self.btnDisplay = Button(self,text='1',command=lambda | n="1":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=3, column=0) | | self.btnDisplay = Button(self,text='2',command=lambda | n="2":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=3, column=1) | | self.btnDisplay = Button(self,text='3',command=lambda | n="3":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=3, column=2) | | self.btnDisplay = Button(self,text='+',command=lambda | n="+":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=3, column=3) | | self.btnDisplay = Button(self,text='4',command=lambda | n="4":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=4, column=0) | | self.btnDisplay = Button(self,text='5',command=lambda | n="5":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=4, column=1) | | self.btnDisplay = Button(self,text='6',command=lambda | n="6":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=4, column=2) | | self.btnDisplay = Button(self,text='-',command=lambda | n="-":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=4, column=3) | | self.btnDisplay = Button(self,text='7',command=lambda | n="7":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=5, column=0) | | self.btnDisplay = Button(self,text='8',command=lambda | n="8":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=5, column=1) | | self.btnDisplay = Button(self,text='9',command=lambda | n="9":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=5, column=2) | | self.btnDisplay = Button(self,text='*',command=lambda | n="*":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=5, column=3) | | self.btnDisplay = Button(self,text='0',command=lambda | n="0":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=6, column=0) | | self.btnDisplay = | Button(self,text='C',command=self.Clean,width=2,height=2) | self.btnDisplay.grid(row=6, column=1) | | self.btnDisplay = Button(self,text='r',command=lambda | n="r":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=6, column=2) | | self.btnDisplay = Button(self,text='/',command=lambda | n="/":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=6, column=3) With the exception of the 'C' button, the only thing different is the label and position. I believe (untested, obviously) def btn(self, txt, r, c): self.btnDisplay = Button(self, text=txt, command=lambda: self.Display(txt), width=2,height=2) self.btnDisplay.grid(row=r, column=r) will work. tjr From daitangio at gmail.com Wed Apr 30 10:13:49 2008 From: daitangio at gmail.com (Giovanni Giorgi) Date: Wed, 30 Apr 2008 07:13:49 -0700 (PDT) Subject: Python Search Engine powered by Google Message-ID: <7e5be687-4644-49df-bbda-b4dcde63011b@d1g2000hsg.googlegroups.com> Hi all, I am working on a customized python search engine: http://blog.objectsroot.com/python/ It is done using a special feature of Google, and it is focused on python I'd like to have the contribution of other guys out of there to fine tuning it. Feel free to use it and give me your feedback. You can leave a comment on my blog. Bye bye From sierra9162 at gmail.com Wed Apr 16 11:23:09 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:23:09 -0700 (PDT) Subject: kate hudson tattoo Message-ID: <2cb4a8f1-7f6d-4956-9016-c6da9d8f65ab@b1g2000hsg.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From Lie.1296 at gmail.com Tue Apr 8 16:52:11 2008 From: Lie.1296 at gmail.com (Lie) Date: Tue, 8 Apr 2008 13:52:11 -0700 (PDT) Subject: Translating keywords References: Message-ID: <6537f3aa-512f-466e-ac31-6fa1266be8dc@k10g2000prm.googlegroups.com> On Apr 7, 9:54 pm, Steve Holden wrote: > Ronn Ross wrote: > > This is my first post and I'm new to Python. How would someone go about > > adding keywords to Python? It would be great to add support for > > Esperanto keywords in the language instead of English being the only > > option. > > Unfortunately the resulting language would no longer be Python. > > You need to consider software portability: Python has been very > conservative about declaring words to be "keywords" in the language, > though clearly words like "def" and "class" must necessarily be part of > the syntax. > > When you start to replace the keywords, though, your programs are no > longer runnable on all Python installations, and simple transliteration > fails because sometimes a keyword in one (natural) language will > conflict with a programmer's choice of name(s) in another. I think it might be possible to create a translation table, where this native-language code would be accompanied by an extra file that maps the replaced keywords with Python keywords. And before the code is compiled, it's preprocessed to map the native-language keywords to Python keyword. But I think if such feature is made available, it would crack the language into lots of sub-languages and that would make code exchange hard, and it wouldn't be long before people start being creative and added language support for languages like Klingon or Pig Latin. On Apr 8, 12:47?pm, Arnaud Delobelle wrote: > On Apr 8, 3:47?am, "Gabriel Genellina" wrote: > > > Python 3 allows for unicode identifiers, but I don'k know any plans for ? > > using unicode keywords too. Looks funny: > > > ? x ? values: > > ? ?if x ? forbidden ? x ? y: > > ? ? ?print(x, ?(x), ?(x)) > > print(?(values)) > > near = ? a,b,?=0.01: a-? ? b ? a+? > > It's all in the eye of the beholder: to me it looks readable, but > that's because I've spent 10 years of my life reading and writing > stuff like that. ?Although I would use ? and ? as aliases for all() > and exists() :) > > -- > Arnaud It looks readable to a mathematician, but not to a regular person or even a regular programmer not specializing in mathematics. And the single downside why I think using symbols is bad is because you can't Google with those. And if you don't know Greek (or whatever language the symbol comes from), you can't even name the symbol to search for the meaning. From c.boulanger at qxtransformer.org Tue Apr 29 16:16:04 2008 From: c.boulanger at qxtransformer.org (Panyasan) Date: Tue, 29 Apr 2008 13:16:04 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <473deef3-9acb-45dd-a7ca-47b0081bd28c@i36g2000prf.googlegroups.com> <3f7bb91e-335e-46bd-88ca-f15b26c35132@k1g2000prb.googlegroups.com> <827bdae6-4422-4226-a543-af53f5b7e01b@s33g2000pri.googlegroups.com> <083b58e8-522a-4c01-b612-c592fe69fcd1@i36g2000prf.googlegroups.com> <2978ec5b-fd7c-4fb1-9aa5-4bb88ba46ee8@m73g2000hsh.googlegroups.com> Message-ID: On 29 Apr., 20:30, Panyasan wrote: > On 29 Apr., 18:17, John Henry wrote: > > > > > There are a whole bunch of test programs that comes with Pythoncard. > > Do they work? (Not all of them will work - some requires a database) > > Yes, the examples work. Just the resourceEditor.py and the > layoutEditor.py in the distributed version and your modified > layoutEditor.py don't. Ok, here is how it works for me: copy all the *.rsrc.py from the modules subdirectory to the parent directory. This works for the standard resourceEditor folder and your custom layoutEditor folder. What the heck. Now I can deal with more productive things... From bignose+hates-spam at benfinney.id.au Sat Apr 26 00:47:26 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Sat, 26 Apr 2008 14:47:26 +1000 Subject: Why is None <= 0 References: Message-ID: <87d4od5ijl.fsf@benfinney.id.au> Grant Edwards writes: > On 2008-04-25, D'Arcy J.M. Cain wrote: > > On Fri, 25 Apr 2008 20:27:15 +0200 > > Gregor Horvath wrote: > >> >>> None <= 0 > >> True > > Everything in Python can compare to everything else. > > Not true. Even more untrue in Python 3.0: Comparisons other than == and != between disparate types will raise an exception unless explicitly supported by the type -- \ "We demand rigidly defined areas of doubt and uncertainty!" -- | `\ Vroomfondel, _The Hitch-Hiker's Guide To The Galaxy_, Douglas | _o__) Adams | Ben Finney From sjmachin at lexicon.net Sat Apr 12 05:33:58 2008 From: sjmachin at lexicon.net (John Machin) Date: Sat, 12 Apr 2008 02:33:58 -0700 (PDT) Subject: accessing individual characters in unicode strings References: Message-ID: On Apr 12, 3:45 pm, Peter Robinson wrote: > Dear list > I am at my wits end on what seemed a very simple task: > I have some greek text, nicely encoded in utf8, going in and out of a > xml database, being passed over and beautifully displayed on the web. > For example: the most common greek word of all 'kai' (or ??? if your > mailer can see utf8) > So all I want to do is: > step through this string a character at a time, and do something for > each character (actually set a width attribute somewhere else for each > character) > > Should be simple, yes? > turns out to be near impossible. I tried using a simple index > character routine such as ustr[0]..ustr[1]... and this gives rubbish. > So I use len() to find out how long my simple greek string is, and of > course it is NOT three characters long. The utf8-encoded incarnation is three characters long and it's six bytes long. utf-8 is not unicode. > > A day of intensive searching around the lists tells me that unicode > and python is a moving target: so many fixes are suggested for similar > problems, none apparently working with mine. > > Here is the best I can do, so far > I convert the utf8 string using > ustr = repr(unicode(thisword, 'iso-8859-7')) Don't do that. If you have a utf8 string, convert it to unicode like this: ustr = unicode(the_utf8_string, 'utf8') If you have a string encoded in iso-8859-7, convert it to unicode like this: ustr = unicode(the_iso_8859_7_string, 'iso-8859-7') Then inspect it like this: print repr(ustr) Here's a sample interactive session: >>> thisword = '\xce\xba\xce\xb1\xce\xb9' >>> ustr = unicode(thisword, 'utf8') >>> len(ustr) 3 >>> print repr(ustr) u'\u03ba\u03b1\u03b9' >>> import unicodedata >>> [unicodedata.name(x) for x in ustr] ['GREEK SMALL LETTER KAPPA', 'GREEK SMALL LETTER ALPHA', 'GREEK SMALL LETTER IOTA'] Suggested reading: the Python Unicode HOWTO at http://www.amk.ca/python/howto/unicode This may be handy: http://unicode.org/charts/PDF/U0370.pdf HTH, John From carlwuhwdmckay at gmail.com Sat Apr 26 09:32:18 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:32:18 -0700 (PDT) Subject: cabbage patch dolls Message-ID: <5139a47c-d67c-4b34-b83c-2cfbccaeba39@j22g2000hsf.googlegroups.com> cabbage patch dolls http://cracks.00bp.com F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Tue Apr 1 20:45:31 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 21:45:31 -0300 Subject: XML Parsing References: <5f1019b7-47e1-4fcf-a00c-b982c6b2fd79@f63g2000hsf.googlegroups.com> Message-ID: En Tue, 01 Apr 2008 20:44:41 -0300, 7stud escribi?: >> ? ? ? ? ? I am new to XML parsing.Could you kindly tell me whats the >> problem with the following code: >> >> import xml.dom.minidom >> import xml.parsers.expat > > I don't know if you are aware of the BeautifulSoup module: > Or ElementTree: import xml.etree.ElementTree as ET doctext = """LettermanisbetterthanJayLeno""" doc = ET.fromstring(doctext) for token in doc.findall("token"): print 'pos:', token.get('pos') print 'text:', token.text -- Gabriel Genellina From castironpi at gmail.com Wed Apr 2 14:10:53 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 2 Apr 2008 11:10:53 -0700 (PDT) Subject: python persistence References: <8b1723d9-67c8-4fe5-b07b-22b0b9311519@8g2000hsu.googlegroups.com> <7f58b5f4-3195-472c-b307-dec71b12aaa8@y21g2000hsf.googlegroups.com> <44f04bf3-4edc-4cb4-9e54-fe51b5e591bc@e39g2000hsf.googlegroups.com> <80d1731d-a3c6-4fce-81fd-9c3f3537e59b@d21g2000prf.googlegroups.com> <5386cf08-c155-4fbb-8373-dbbb9829a9e7@m3g2000hsc.googlegroups.com> <3c27b270-e593-4f2a-b881-68126319760c@8g2000hsu.googlegroups.com> <7d71e294-2b13-4be0-948e-2fe0e4bbe7db@f63g2000hsf.googlegroups.com> Message-ID: <041d2491-f67c-4e1f-b22f-b5da2705c74f@m3g2000hsc.googlegroups.com> On Apr 1, 3:21?pm, castiro... at gmail.com wrote: > On Apr 1, 11:34?am, "Gabriel Genellina" > wrote: > > > > > > > En Tue, 01 Apr 2008 08:47:33 -0300, escribi?: > > > >> >>>> c['0']= type('None',(),{}) > > >> > Traceback (most recent call last): > > >> > pickle.PicklingError: Can't pickle : it's not > > >> > found as __main__.None > > > >> Don't do that then. Or use the available pickle hooks to customize how ? > > >> such classes may be pickled. All persistence mechanisms have ? > > >> limitations. > > > > I don't see a problem with that; except that binaries come from > > > disks. ?You could have a Python session that runs entirely on disks + > > > the ALU. > > > (ALU? Do you mean CPU?) I don't understand this. Most programs are read ? > > ?from disk. Most data is read from disk. > > > > I want to know if any, and correct me here, simple > > > modification can store live objects. ?I call a.append(it) and the > > > memory update takes place on disk instead. > > > Using ZODB, a.append(it) would mark `a` as dirty. When you latter commit ? > > the transaction, it is stored back on disk. > > > > If you require that all objects referenced by on-disk objects be on- > > > disk, that's an easy workaround. > > > ZODB already does that. > > It's pretty close, but the database connection can get bulky. ?If you > had: > ?_______________________ > | ? ? ? ? ______________________ > |File ? ?| PyOb1 | PyOb2 | ?.. ?| > | ? ? ? ?|_______|_______|______| > |_______________________ > > on disk, updating the reference counts and attributes would take a > long time, but it's just right for some core applications. > > Strictly, I'm not in the "real" programming world, so if it's just a > few free steps to a database then I'm speculating. ?If it's not, then > writing database code needlessly complicates programs in some cases. > A default implementation might even take an explicit destroy > statement, essentially being a run-time swap file or random-access > pickles. > > A possibility is to launch a manager in a separate process, so authors > don't have to bother with writeback. ?I'm actually almost looking at > off-loading protocols on this one. ?Cache is guaranteed to be up to > date, so cache a file in memory, and manipulate it so it has Python > bits. ?The object comes to survive the program. ?Call stack is still > in volatile. > > > Using ZODB, a.append(it) would mark `a` as dirty. When you latter commit > > the transaction, it is stored back on disk. > > Python changes are committed on line. ?ZODB does -not- do that. ?A > pretty close change would be: > > Open file > Interpret file as generator, halted at yield but started, > Call send and next > > What does the code for that look like?- Hide quoted text - Can you pickle a generator? The only thing I know is: >>> pickle.loads( pickle.dumps( k ) ) TypeError: object.__new__(generator) is not safe, use generator.__new__() >>> type( 'A',( generator, ),{}) TypeError: type 'generator' is not an acceptable base type I bet there's a workaround on this one, how bulky is it? Can you shelve a frame? Separate threads can access a generator, so long as they wrap their calls: synchronous( next, a ); synchronous( a.send, 'xyz' ) From fredrik at pythonware.com Sat Apr 5 10:12:11 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 16:12:11 +0200 Subject: In Tkinter - having an input and an entry In-Reply-To: References: <29f44489-e589-4331-8bea-36fa346026d2@t54g2000hsg.googlegroups.com> Message-ID: markfernandes02 at googlemail.com wrote: > Thanks it sorted out my 'StringVar' problem. > I now have another problem... > > Exception in Tkinter callback > Traceback (most recent call last): > File "D:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__ > return self.func(*args) > TypeError: Insert() takes at least 1 argument (0 given) > > Code below > > def Insert(self, *row): > global cursor, title, author, pubdate, accessDatabase > sqlInsert = "INSERT INTO Book_table (Bookname, BookAutor, > Publicationdate) VALUES('title + ',' author + ',' pubdate)" ... is Insert a function or a method (that is, a function defined inside a class)? who's calling Insert? what is "self" supposed to be? to sort out Python's function call mechanisms, try reading the following chapters: http://www.ibiblio.org/swaroopch/byteofpython/read/functions.html http://docs.python.org/tut/node6.html#SECTION006600000000000000000 From steve at holdenweb.com Tue Apr 1 15:40:48 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 01 Apr 2008 15:40:48 -0400 Subject: [OT] troll poll In-Reply-To: References: Message-ID: <47F28FC0.7080608@holdenweb.com> Duncan Booth wrote: > Gary Herron wrote: > >> Duncan Booth wrote: >>> Paul Rubin wrote: >>> >>> >>>> "Daniel Fetchinson" writes: >>>> >>>>> [ ] - Xah Lee >>>>> [ ] - castironpi >>>>> >>>> I've lost track but has it been established that they are not the >>>> same person? >>>> >>>> >>> Has it actually been established that castironpi is actually a >>> person? I thought it was probably a random sentence generator. >>> >> Ahhh... Perhaps someone is running a Turing test on us. That is, if >> we can't tell the difference between castironpi and a *real* human >> (which we demonstrate whenever we try to respond to or reason with >> him/her/it), then castironpi can be declared to be a truly >> *intelligent* AI. AFAICT, there appears no danger of that happening >> yet. >> >> Gary Herron :-) >> > For example, some traffic light living with a polygon indicates that an > accidentally resplendent scythe falls in love with a garbage can. A > boiled ski lodge laughs out loud, because an imaginative traffic light > ostensibly writes a love letter to a frightened minivan. Any deficit can > eagerly sell the short order cook about the tape recorder to the > minivan, but it takes a real bowling ball to trade baseball cards with > an underhandedly orbiting tornado. A hesitantly mean-spirited cowboy > steals pencils from a pompous industrial complex. Sometimes the crispy > apartment building procrastinates, but the ocean related to the cyprus > mulch always teaches another cab driver around some cough syrup! > > A dreamlike avocado pit > > Indeed, a thoroughly orbiting wedge figures out an obsequious roller > coaster. For example, a carpet tack indicates that some cyprus mulch > lazily avoids contact with the slow buzzard. Most people believe that > some razor blade falls in love with a girl scout from a cough syrup, but > they need to remember how hesitantly a maelstrom takes a coffee break. > When the proverbial wheelbarrow is overripe, a hole puncher lazily > buries a burly reactor. Now and then, the cargo bay tries to seduce a > class action suit. > Way too lucid to be castironpi regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bj_666 at gmx.net Mon Apr 21 02:51:12 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 21 Apr 2008 06:51:12 GMT Subject: Conditional for...in failing with utf-8, Spanish book translation References: Message-ID: <672rr0F2mi30gU2@mid.uni-berlin.de> On Mon, 21 Apr 2008 08:33:47 +0200, Hunter wrote: > I've narrowed the problem down to a simple test program. Check this out: > > --- > > # -*- coding: utf-8 -*- > > acceptable = "abcdefghijklmnopqrstuvwxyz????" # this line will work > acceptable = "abcdefghijklmnopqrstuvwxyz?????" # this line won't > #wtf? > > word = "?A" > word_key = ''.join([c for c in word.lower() if c in acceptable]) > print "word_key = " + word_key > > --- > > Any ideas? I'm really stumped! You are not working with unicode but UTF-8 encoded characters. That's bytes and not letters/characters. Your `word` for example contains three bytes and not the two characters you think it contains: In [43]: word = "?A" In [44]: len(word) Out[44]: 3 In [45]: for c in word: print repr(c) ....: '\xc2' '\xa1' 'A' So you are *not* testing if ? is in `acceptable` but the two byte values that are the UTF-8 representation of that character. Ciao, Marc 'BlackJack' Rintsch From ott.deb at gmail.com Thu Apr 17 15:04:58 2008 From: ott.deb at gmail.com (ott.deb at gmail.com) Date: Thu, 17 Apr 2008 12:04:58 -0700 (PDT) Subject: luxor 3 keygen Message-ID: luxor 3 keygen http://cracks.12w.net F R E E C R A C K S From simonkagwe at yahoo.com Wed Apr 16 00:50:42 2008 From: simonkagwe at yahoo.com (Simon Kagwi) Date: Tue, 15 Apr 2008 21:50:42 -0700 (PDT) Subject: python-gammu for Python 2.4 on Windows Message-ID: <150869.75383.qm@web30606.mail.mud.yahoo.com> Hi everyone, I am looking for binaries (.exe) of python-gammu (any version) for Python 2.4. What I'm getting from the download website is only for Python 2.5. Does anyone know where I can get what I'm looking for? Google isn't really helping :-C Regards, Simon ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ From tarun.kap at gmail.com Wed Apr 30 11:57:45 2008 From: tarun.kap at gmail.com (TkNeo) Date: Wed, 30 Apr 2008 08:57:45 -0700 (PDT) Subject: calling variable function name ? References: Message-ID: <57461074-8fd1-4e65-9bc9-2ac916aa1fb5@y21g2000hsf.googlegroups.com> On Apr 8, 7:51 pm, George Sakkis wrote: > On Apr 8, 3:52 pm,TkNeo wrote: > > > I don't know the exact terminology in python, but this is something i > > am trying to do > > > i have 3 functions lets say > > FA(param1,param2) > > FB(param1,param2) > > FC(param1,param2) > > > temp = "B" #something entered by user. now i want to call FB. I don't > > want to do an if else because if have way too many methods like > > this... > > > var = "F" + temp > > var(param1, param2) > > Try this: > > func = globals()["F" + temp] > func(param1, param2) > > HTH, > George George - Thanks for your reply but what you suggested is not working: def FA(param1,param2): print "FA" + param1 + " " + param2 def FA(param1,param2): print "FB" + param1 + " " + param2 def FA(param1,param2): print "FC" + param1 + " " + param2 temp = sys.argv[1] func = globals()["F" + temp] func("Hello", "World") I ran the script with first parameter as B and i get the following message KeyError: 'FB' From bronger at physik.rwth-aachen.de Fri Apr 4 17:08:11 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Fri, 04 Apr 2008 23:08:11 +0200 Subject: Is there any way to say ignore case with "in"? References: <47f692f3$0$759$bed64819@news.gradwell.net> Message-ID: <87ej9lgwg4.fsf@physik.rwth-aachen.de> Hall?chen! tinnews at isbd.co.uk writes: > Is there any way in python to say > > if string1 in string2: > > > ignoring the case of string1 and string2? You can "normalise" both first, i.e. converting to lower case. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From gagsl-py2 at yahoo.com.ar Mon Apr 14 23:41:37 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 15 Apr 2008 00:41:37 -0300 Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> Message-ID: En Mon, 14 Apr 2008 23:38:56 -0300, Sverker Nilsson escribi?: > On Apr 15, 3:50 am, "Gabriel Genellina" > wrote: >> En Mon, 14 Apr 2008 22:02:38 -0300, Sverker Nilsson >> escribi?: >> >> > I tried out py3k on my project,http://guppy-pe.sf.net >> >> And what happened? >> I've seen that your project already supports Python 2.6 so the migration >> path to 3.0 should be easy. > > 2.6 was no big deal, It was an annoyance that they had to make 'as' a > reserved word. Annoyances were also with 2.4, and 2.5. No big > problems, I could make guppy backwards compatible to 2.3. But that > seems not to be possible with Python 3.x ... it is a MUCH bigger > change. And it would require a fork of the code bases, in C, Guido has > written tha or to sprinkle with #ifdefs. Would not happen soon for me. > It takes some work anyways. Do you volunteer, Guido van Rossum? :-) > > It's not exactly easy. Perhaps not very hard anyways. But think of > 1000's of such projects. How many do you think there are? I think > many. How many do yo think care? I think few. > > When it has been the fuzz with versions before, then I could have the > same code still work with older versions. But now it seems I have to > fork TWO codes. It's becoming too much. Think of the time you could > write a program in C or even C++ and then it'll work. How do you think > eg writers of bash or other unix utilities come along. Do they have to > rewrite their code each year? No, it stays. And they can be happy > about that, and go on to other things. Why should I have to think > about staying compatible with the newest fancy Python all the time? NO > -- but the answer may be, they don't care, though the others (C/C++, > as they rely on) do. :-( You can stay with Python 2.6 and not support 3.0; nobody will force you to use it. And nobody will come and wipe out your Python installation, be it 2.6, 2.1 or whatever. And if you still enjoy using Python 1.5, please keep using it - it won't disappear the day after 3.0 becomes available. Regarding the C language: yes, souce code *had* to be modified for newer versions of the language and/or compiler. See by example, the new "restrict" keyword in C99, or the boolean names. The C guys are much more concerned about backwards compatibility than Python, but they can't guarantee that (at risk of freezing the language). The 3.0 incompatibilities are all justified, anyway, and Python is changing (as a language) much more than C - and that's a good thing. There is a strategy to migrate from 2.x to 3.0, including the 2to3 tool. Have you used it? -- Gabriel Genellina From martin at v.loewis.de Thu Apr 17 04:25:20 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Thu, 17 Apr 2008 10:25:20 +0200 Subject: I just killed GIL!!! In-Reply-To: References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> Message-ID: <48070970.70306@v.loewis.de> > For the record, I am not complaining about that GIL. As I said, I > understand and approve of why it's there. I am, however, complaining > about attitude that if you want to be free of the GIL you're doing > something wrong. If you _want_ to be free of the GIL, you are not _doing_ anything, and that may or may not be wrong. If you are complaining about the GIL, I think you are doing something wrong, because complaining doesn't help progress at all. I think neither was the case in this thread - the guy claimed that he actually did something about the GIL, and now we are all waiting for him to also tell us what it is that he did. I think it is somewhat wrong to not tell in the first place, but this is free software, and choosing not to contribute isn't inherently wrong. Maybe the guy is making fun of us; whether that is wrong or not depends on your notion of humor. Regards, Martin From s0suk3 at gmail.com Mon Apr 28 18:29:33 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Mon, 28 Apr 2008 15:29:33 -0700 (PDT) Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> <87od7ue2ne.fsf@mulj.homelinux.net> Message-ID: On Apr 28, 4:42 am, Hrvoje Niksic wrote: > Nick Craig-Wood writes: > > What you are missing is that if the recv ever returns no bytes at all > > then the other end has closed the connection. So something like this > > is the correct thing to write :- > > > data = "" > > while True: > > new = client.recv(256) > > if not new: > > break > > data += new > > This is a good case for the iter() function: > > buf = cStringIO.StringIO() > for new in iter(partial(client.recv, 256), ''): > buf.write(new) > data = buf.getvalue() > > Note that appending to a string is almost never a good idea, since it > can result in quadratic allocation. A question regarding cStringIO.StringIO(): is there a way to do get getvalue() to return all the bytes after the current file position (not before)? For example buf = cStringIO.StringIO() buf.write("foo bar") buf.seek(3) buf.getvalue(True) # the True argument means # to return the bytes up # to the current file position That returns 'foo'. Is there a way to get it to return ' bar'? From nick at craig-wood.com Tue Apr 29 05:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Tue, 29 Apr 2008 04:30:03 -0500 Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> <1939ddb7-fc72-4d45-8c9c-062a1d0db3e4@y21g2000hsf.googlegroups.com> Message-ID: s0suk3 at gmail.com wrote: > But as I said in my first post, it's simple when you know the amount > of data that you're going to receive, or when you'll receive data > until the remote peer closes the connection. But what about receiving > a message with undetermined length in a connection that you don't want > to close? You obviously need some sort of protocol. Here is some code (taken from a real project and modified a bit) which returns \r\n seperated lines from a socket as they arrive which is a very simple (but widespread) protocol. self.rx_buf is set to "" in the initialisation self.sock is the socket def rx_line(self): message = None while 1: pos = self.rx_buf.find("\r\n") if pos >= 0: message = self.rx_buf[:pos] self.rx_buf = self.rx_buf[pos+2:] break try: rx = self.sock.recv(4096) except socket.error, e: self.sock = None raise ServerNetworkException(e) if len(rx) == 0: self.sock = None raise ServerDisconnectedException() self.rx_buf += rx return message Sorry I mis-understood your original post! -- Nick Craig-Wood -- http://www.craig-wood.com/nick From corvettecraz92 at gmail.com Thu Apr 10 08:06:42 2008 From: corvettecraz92 at gmail.com (corvettecraz92 at gmail.com) Date: Thu, 10 Apr 2008 05:06:42 -0700 (PDT) Subject: text adventure game problem References: Message-ID: <4fb4fb0d-4cb2-4fcd-a207-a0341d92e82b@8g2000hsu.googlegroups.com> On Apr 10, 3:14?am, Dennis Lee Bieber wrote: > On Wed, 9 Apr 2008 05:25:19 -0700 (PDT), corvettecra... at gmail.com > declaimed the following in comp.lang.python: > > > > > I can't even compile your code to see how it works, Dennis. I'm > > confused about what that does. > > ? ? ? ? My apologies -- it was spur of the moment pseudo-code to illustrate > the concepts, but was never meant to be directly executable. > > ? ? ? ? The concepts are that: all rooms are basically the same -- they have > a list of objects that exist within the room (and, as I now realize, the > "gold within the cabinet/cup" would still be an object within the room > -- but would have an attribute "hidden=True" which would control if it > is itemized when one "examines" the room), a list of exits, and a maybe > a list of actions which can be performed in the room or on named objects > (though I see the actions being common methods invoked by the command > parser -- I illustrated a simple "verb object" command, but a good > parser should probably accept more complex commands "throw at > " for example). Uh, I'm saying "list", but "dictionary" would > be the likely implementation. > > ? ? ? ? When one "examines" a room, one essentially gets back a list of the > objects that are in the room instance. When one "examines" one of those > objects (by name), one gets back the detailed description of that > object. If one implements a "hidden" attribute, that object will not be > listed in the higher level "examine". That "gold" inside another object > does get a bit tricky -- I now see it as a hidden object in the room, > but the description of the object has to be somewhat dynamic -- that is, > if the object (cabinet) sees that the "gold" is in the room, examining > the object will report the gold. But a "take gold" command still acts on > the room -- removing the gold from the room inventory, putting it into > the player inventory, and changing the "hidden" property so it is now > visible. > > ? ? ? ? When one does a ?"move ", the player's "location" > attribute is changed from the current room to the room connected to that > direction. > > ? ? ? ? For both objects and directions, if the player enters a term that is > not in the relevant dictionary, a suitable message is returned to the > user. Oh, room objects, besides that "hidden" attribute, may have a > "portable" attribute which controls if one can "take" the object... Or > an attribute for "throwable" which controls if one can throw an object > at another (and the other would have a method/action for when something > is thrown at it -- a default would be "No effect"). > > ? ? ? ? From what I saw of your small sample, you were treating each room as > a discrete function. Moving from one room to another means calling the > new room's function. But that means you are continuously nesting deeper > in the Python stack, and someone that keeps moving back and forth > between two rooms will eventually exceed the Python stack limit. > > ? ? ? ? By making the "current location" an attribute of a "player > instance", no recursion is involved -- you move between rooms by simply > assigning the new room as the "current location". > > -- > ? ? ? ? Wulfraed ? ? ? ?Dennis Lee Bieber ? ? ? ? ? ? ? KD6MOG > ? ? ? ? wlfr... at ix.netcom.com ? ? ? ? ? ? wulfr... at bestiaria.com > ? ? ? ? ? ? ? ? HTTP://wlfraed.home.netcom.com/ > ? ? ? ? (Bestiaria Support Staff: ? ? ? ? ? ? ? web-a... at bestiaria.com) > ? ? ? ? ? ? ? ? HTTP://www.bestiaria.com/ okay, that explains it... could you provide a working example of a two-room game using your method please so I can understand it better? Thanks in advance! From steve at holdenweb.com Thu Apr 24 15:36:16 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 15:36:16 -0400 Subject: function that accepts any amount of arguments? In-Reply-To: <3d881a310804241213q2f373190i4d7c7c1ffbaeba4c@mail.gmail.com> References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> <4810724a$0$23390$426a74cc@news.free.fr> <63ac69bf-9f6d-42bd-8e6e-5b3b17ec7c69@z72g2000hsb.googlegroups.com> <933e4c97-11c8-43b0-81e0-c78ff8573792@26g2000hsk.googlegroups.com> <3d881a310804241213q2f373190i4d7c7c1ffbaeba4c@mail.gmail.com> Message-ID: member thudfoo wrote: > On 4/24/08, Jonathan Gardner wrote: >> On Apr 24, 5:28 am, malkarouri wrote: >> > >> > What's wrong with raising ZeroDivisionError (not stopping the >> > exception in the first place)? >> > >> >> >> Because when I use your module, call avg (or mean) without args, I >> should see an error that says, "Hey, you have to pass at least one >> value in!" >> >> ZeroDivisonError doesn't mean that. It means I tried to divide by >> zero. Naively, I don't see where I was dividing by zero (because I >> don't remember how to calculate the mean---that's what your code was >> for.) >> >> ValueError does mean that I didn't pass the right kind of arguments >> in. ValueError("No items specified") would be even clearer. (Or maybe >> TypeError?) >> >> In general, any exception thrown should be meaningful to the code you >> are throwing it to. That means they aren't familiar with how your code >> works. >> > > [source]|557> def average(n, *ints): > |...> return (sum(ints)+n) / (len(ints) + 1) > |...> > [source]|558> average (1,2,3) > <558> 2 > [source]|559> average(3) > <559> 3 > [source]|560> average(1,2) > <560> 1 > [source]|561> average(0) > <561> 0 > [source]|562> average() > --------------------------------------------------------------------------- > TypeError Traceback (most recent call last) > > /usr/share/doc/packages/python-dateutil/source/ in () > > TypeError: average() takes at least 1 argument (0 given) > -- > http://mail.python.org/mailman/listinfo/python-list > It would also be usual to use floating arithmetic to ensure that the mean of 1 and 2 was 1.5 rather than 1. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From deets at nospam.web.de Mon Apr 21 07:23:11 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Mon, 21 Apr 2008 13:23:11 +0200 Subject: Somebody *really* got fond of python Message-ID: <673bprF2n44icU1@mid.uni-berlin.de> http://xkcd.com/413/ :) From ybc2084 at gmail.com Wed Apr 9 04:38:43 2008 From: ybc2084 at gmail.com (rockins) Date: Wed, 9 Apr 2008 01:38:43 -0700 (PDT) Subject: what's the reasonale of loghelper() in mathmodule.c Message-ID: <49750e9d-1a63-42d2-b292-38d225b0c3c8@n1g2000prb.googlegroups.com> Hi all, I downloaded Python-2.5.2.tar.bz2 and want to lean some math function implementation in it. I found that mathmodule.c implements 'math' module of python. In this file there's a function loghelper()(in Python-2.5.2/Modules/mathmodule.c), it seems with this function's help any base logarithm can be computed, its comments state as: /* A decent logarithm is easy to compute even for huge longs, but libm can't do that by itself -- loghelper can. func is log or log10, and name is "log" or "log10". Note that overflow isn't possible: a long can contain no more than INT_MAX * SHIFT bits, so has value certainly less than 2**(2**64 * 2**16) == 2**2**80, and log2 of that is 2**80, which is small enough to fit in an IEEE single. log and log10 are even smaller. */ static PyObject* loghelper(PyObject* args, double (*func)(double), char *format, PyObject *arg) { ...... } I cannot understand it well, can anyone explain me why and how loghelper() can compute any base logarithm? Or could anyone give me some reference(such as, books or papers)? Thanks in advance, -Rockins Chen From andhralo5 at gmail.com Tue Apr 29 08:05:45 2008 From: andhralo5 at gmail.com (sureka) Date: Tue, 29 Apr 2008 05:05:45 -0700 (PDT) Subject: Bollywood, Asian, Indie Films And More. Message-ID: <3b00f2c5-e13c-4867-b591-991763a4cf05@c19g2000prf.googlegroups.com> Bollywood, Asian, Indie Films And More. http://besthotmovies.blogspot.com/ From paul at boddie.org.uk Thu Apr 3 09:00:14 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Thu, 3 Apr 2008 06:00:14 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> Message-ID: <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> On 2 Apr, 15:50, Aaron Watters wrote: > [Quoting hdante] > > Seriously, you'll forget there's a relational database below. (there > > are even intefaces for "relational lists", "trees", etc.) > > My experience with this sort of thing is that it is a bit > like morphine. It can feel really good, and in emergencies > it can save you a lot of pain. But if you use it too often > and too seriously you end up with really big problems. That's two candidates for quote of the week in the same thread! I agree with those who question why you'd want to treat a relational database like a big dictionary, and although the interface between queries, results and program data structures can often seem quite awkward, I've come to realise that most object-relational mappers are solving the wrong problems: they pretend that the database is somehow the wrong representation whilst being a fast enough black box for holding persistent data (although I doubt that many people push the boundaries enough to see that it's not possible to ignore all details of such a database whilst preserving performance), or they pretend that languages like SQL (which can be cumbersome, admittedly) are inconvenient for querying whilst replicating a less concise mechanism for querying using client language mechanisms. I'm more encouraged by the idea of "query templating", which might sound like a recipe for all sorts of problems, but if done right could provide more effective ways of working with relational databases than pretending that different things in the database are somehow "objects" in the client language sense. Paul From theiviaxx at gmail.com Thu Apr 24 14:02:07 2008 From: theiviaxx at gmail.com (theiviaxx at gmail.com) Date: Thu, 24 Apr 2008 11:02:07 -0700 (PDT) Subject: python-ldap - Operations Error References: Message-ID: Thanks for the help guys, it works! I used the ldap.set_option(ldap.OPT_REFERRALS, 0) from http://peeved.org/blog/2007/11/20/ immedialtey after import, then did the initialize trace_level=2 and did the simple_bind_s. I was able to search and get the results. That trace_level thing is nice, i'm sure i will be debugging this more as i move forward :) Not sure if this is an AD thing or just something i needed to do with our particular server/config. Thanks again! From tjreedy at udel.edu Thu Apr 24 04:56:26 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 24 Apr 2008 04:56:26 -0400 Subject: Lists: why is this behavior different for index and sliceassignments? References: <480d435b$0$11643$607ed4bc@cv.net><480e7f61$0$25046$607ed4bc@cv.net> <480e832d@news.mel.dft.com.au> <480ffaae$0$11639$607ed4bc@cv.net> Message-ID: "John Salerno" wrote in message news:480ffaae$0$11639$607ed4bc at cv.net... | John Machin wrote: | | > Deletion occurs *only* in the corner case where there are no "assigned | > elements" i.e. only if the RHS list (sequence) is *empty*. | | Oh, it was my understanding that deletion always occurs, even when the | section is being assigned a non-empty value, i.e. delete the slice and | insert new value. Slice replacement means replace the slice with a new slice generated from the iterable on the left. John meant that deletion only only happens when the replacement is empty. Yes, deletion always occurs, but usually addition also occurs, so the net result is replacement rather than just deletion. | Otherwise | > there would be no point at all in the language having assignment to a | > slice -- del L[0:2] would suffice. | | Right, but I'm wondering why a statement like | L[0:2] = [] | doesn't assign an empty list as the new element in L. For example: Because, as others already told you, slice replacement is slice replacement, not item assignment. When you say to replace the slice with nothing, the deleted slice is replaced with nothing. L[0:2] = [[]] says to replace the slice with a slice consisting of one item -- [] That will get you what you are expecting. | L = [1, 2, 3, 4, 5] | L[0:2] = [] | | Why doesn't L now equal [[], 3, 4, 5] as it does with an index assignment? See above. | | > >>> L[0:2] = tuple('foobar') L[0:2] = 'foobar' has same effect because s string is an iterable. | > >>> L | > ['f', 'o', 'o', 'b', 'a', 'r', 3, 4, 5] | | Hmm...why doesn't L equal [('f', 'o', 'o', 'b', 'a', 'r'), 3, 4, 5] ? | Shouldn't L be a 4 item list instead of 9? Because you replaced 2 items with 6. L[0:2] = ['foobar'] will replace 2 with 1, leaving 4 tjr From arkanes at gmail.com Wed Apr 16 12:51:54 2008 From: arkanes at gmail.com (Chris Mellon) Date: Wed, 16 Apr 2008 11:51:54 -0500 Subject: py3k s***s In-Reply-To: <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> Message-ID: <4866bea60804160951y5a602277sb5c0a9bd83f4f25a@mail.gmail.com> On Wed, Apr 16, 2008 at 11:40 AM, Aaron Watters wrote: > On Apr 16, 12:27 pm, Rhamphoryncus wrote: > > On Apr 16, 6:56 am, Aaron Watters wrote: > > > > > I don't get it. It ain't broke. Don't fix it. > > > > So how would you have done the old-style class to new-style class > > transition? > > I'd ignore it. I never understood it and never had > any need for it anyway. New-style classes and metaclasses > were a complicated solution to an unimportant problem in > my opinion. And also a fiendish way to make code > inscrutible -- which I thought was more of a Perl thing > than a Python thing, or should be. > > I must be missing some of the deeper issues here. Please > educate me. Since you don't care about any of the changes or features, and you don't care if your users care, I'm not sure why you aren't just using python 2.1. It's not like it's being erased via time machine. "Just keep using the old thing" is a perfectly valid and extremely common futureproofing scenario. From george.sakkis at gmail.com Thu Apr 3 08:19:11 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Thu, 3 Apr 2008 05:19:11 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> Message-ID: <4b7337a4-beda-4984-91f5-6efda6fb390d@r9g2000prd.googlegroups.com> On Apr 3, 8:03 am, Jeff wrote: > def foo(sample, strings): > for s in strings: > if sample in s: > return True > return False > > This was an order of magnitude faster for me than using str.find or > str.index. That was finding rare words in the entire word-list (w/ > duplicates) of War and Peace. If you test against the same substrings over and over again, an alternative would be to build a regular expression: import re search = re.compile('|'.join(re.escape(x) for x in substrings)).search p = search(somestring) if p is not None: print 'Found', p.group() George From gagsl-py2 at yahoo.com.ar Wed Apr 30 05:46:15 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 30 Apr 2008 06:46:15 -0300 Subject: xml.dom.minidom weirdness: bug? References: <4817dea2$0$18028$426a34cc@news.free.fr> Message-ID: En Tue, 29 Apr 2008 23:51:14 -0300, JYA escribi?: > What I'm doing, is read an xml file, create another dom object and copy > the element from one to the other. > > At no time do I ever modify the original dom object, yet it gets > modified. > > for y in x.getElementsByTagName('display-name'): > elem.appendChild(y) > tv_xml.appendChild(elem) > You'll note that at no time do I modify the content of docxml, yet it > gets modified. > > The weirdness disappear if I change the line > channellist = docxml.getElementsByTagName('channel') > to > channellist = copy.deepcopy(docxml.getElementsByTagName('channel')) > > However, my understanding is that it shouldn't be necessary. I think that any element can have only a single parent. If you get an element from one document and insert it onto another document, it gets removed from the first. -- Gabriel Genellina From bskaplan14 at yahoo.com Thu Apr 17 09:32:06 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Thu, 17 Apr 2008 06:32:06 -0700 (PDT) Subject: Calling Java Class from python Message-ID: <413770.43611.qm@web39208.mail.mud.yahoo.com> If you need to explicitly call a method and get the results, AFAIK, the only way to do it is to use Jython, a version of Python written in java. If you can do everything you need from the command line, then you can just use subprocess.Popen to run it. Here is the article on how to run java files from the command line: http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html ----- Original Message ---- From: Good Z To: python-list at python.org Sent: Wednesday, April 16, 2008 6:37:55 AM Subject: Calling Java Class from python All, We have developed a website in python and we need to integrate few features of third party website. They have provided us Base64EncoderDecoder Java Class and would like us to use it to encode the data before sending it to their site and decode it when received anything from their site. I have no idea/knowledge of Java. Can you please guide me how can i call Java class from Python scripts? Or what is the best way to handle this condition. Is Base64 library provided by python is compatible to Base64EncoderDecoder Java Class? Regards, Mike Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From mccredie at gmail.com Fri Apr 11 13:22:18 2008 From: mccredie at gmail.com (Matimus) Date: Fri, 11 Apr 2008 10:22:18 -0700 (PDT) Subject: Multiple independent Python interpreters in a C/C++ program? References: Message-ID: <978060f0-5a50-40ba-b553-f26b35169bd1@m73g2000hsh.googlegroups.com> On Apr 11, 9:24 am, s... at pobox.com wrote: > This question was posed to me today. Given a C/C++ program we can clearly > embed a Python interpreter in it. Is it possible to fire up multiple > interpreters in multiple threads? For example: > > C++ main > thread 1 > Py_Initialize() > thread 2 > Py_Initialize() > > Do I wind up with two completely independent interpreters, one per thread? > I'm thinking this doesn't work (there are bits which aren't thread-safe and > are only protected by the GIL), but wanted to double-check to be sure. > > Thanks, > > Skip AFAIK it is only `sort of' possible. But not like that. See the API documentation on Py_NewInterpreter http://www.python.org/doc/api/initialization.html#l2h-825 As you will see from the documentation it creates an interpreter that isn't 100% separate. It may work for your application though. Also, I don't think using the new interpreter is as simple as just instantiating the new interpreter in a separate thread. But there is much relevant information on the page that I linked to. Matt From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 29 09:52:25 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 29 Apr 2008 15:52:25 +0200 Subject: list.reverse() In-Reply-To: References: <4816e26a$0$30938$426a74cc@news.free.fr> Message-ID: <48172812$0$19991$426a74cc@news.free.fr> Roy Smith a ?crit : (snip) > The reasoning goes along the lines of, "reverse in place is an expensive > operation, so we don't want to make it too easy for people to do". At > least that's the gist of what I got out of the argument the many times it > has come up. IIRC, it's more along the line of "reverse in place is a *destructive* operation, so we don't want to make it too easy for people to forget about it". From s0suk3 at gmail.com Wed Apr 16 18:12:58 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Wed, 16 Apr 2008 15:12:58 -0700 (PDT) Subject: Brand New! References: <7f1828bf-ebe7-4111-bc59-70d125facb0a@d26g2000prg.googlegroups.com> Message-ID: On Apr 14, 9:00 pm, agent E 10 wrote: > Hi, I'm brand new to programming. Have any suggestions? I'm young. > Was it a good idea to start with python? I was planning on creating a > very simple program that asked yes/no questions for a school project. > > -Thanks! Hey! That's actually were I learned to program too! Excellent tutorial. But don't read the JavaScript or VBScript stuff. The only thing it gave me trouble learning from that tutorial was OOP (Object Oriented Programming), but that's a bit advanced for a newcomer anyway... From barry at python.org Thu Apr 3 21:47:01 2008 From: barry at python.org (Barry Warsaw) Date: Thu, 3 Apr 2008 21:47:01 -0400 Subject: RELEASED Python 2.6a2 and 3.0a4 Message-ID: <3C3C0150-ED65-4381-9F54-BB437DD6DFB9@python.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On behalf of the Python development team and the Python community, I'm happy to announce the second alpha release of Python 2.6, and the fourth alpha release of Python 3.0. Please note that these are alpha releases, and as such are not suitable for production environments. We continue to strive for a high degree of quality, but there are still some known problems and the feature sets have not been finalized. These alphas are being released to solicit feedback and hopefully discover bugs, as well as allowing you to determine how changes in 2.6 and 3.0 might impact you. If you find things broken or incorrect, please submit a bug report at http://bugs.python.org For more information and downloadable distributions, see the Python 2.6 web site: http://www.python.org/download/releases/2.6/ and the Python 3.0 web site: http://www.python.org/download/releases/3.0/ We are planning one more alpha release of each version, followed by two beta releases, with the final releases planned for August 2008. See PEP 361 for release details: http://www.python.org/dev/peps/pep-0361/ Enjoy, - -Barry Barry Warsaw barry at python.org Python 2.6/3.0 Release Manager (on behalf of the entire python-dev team) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iQCVAwUBR/WImHEjvBPtnXfVAQJmoQP+MzqNDI+Xt8zua/FE7Ca4TVXoIIy2uoOm I1i3+vmevZ9vtAb9hcGwfEgPY4LSwb9Js4KnJJWMPaMuFJK4NgGoiMdj+t42zDbQ bEzfBUOCoVkejLRxIQnWeJf1Hu8JocYyCHIRffv57/QdKpHuiSs8aE8GIT3STo3o I88H5NY1GgI= =WT2z -----END PGP SIGNATURE----- From rickbking at comcast.net Thu Apr 24 10:21:11 2008 From: rickbking at comcast.net (Rick King) Date: Thu, 24 Apr 2008 10:21:11 -0400 Subject: annoying dictionary problem, non-existing keys In-Reply-To: References: Message-ID: <48109757.5080207@comcast.net> An HTML attachment was scrubbed... URL: From MrJean1 at gmail.com Tue Apr 1 19:49:02 2008 From: MrJean1 at gmail.com (MrJean1) Date: Tue, 1 Apr 2008 16:49:02 -0700 (PDT) Subject: Not Sure This Can Be Done... References: <46aeae28-4470-4136-a5f6-040f6468eb32@b5g2000pri.googlegroups.com> Message-ID: <170a668f-4a65-471f-ad03-03231235b314@e6g2000prf.googlegroups.com> In any script upon startup, sys.path[0] contains the full path of the directory where the script is located. See under 'path'. it should be straightforward from here (untested though). In each script, get the sys.path[0] string, split it using os.path, replace the last item with 'tools' and join again with os.path. If the resulting string is not in sys.path, insert it after sys.path[0]. /Jean Brouwers On Apr 1, 1:57?pm, gamename wrote: > Hi, > > I generally have several copies of the same development environment > checked out from cvs at any one time. ?Each development tree has a > 'tools' dir containing python modules. ?Scattered in different places > in the tree are various python scripts. > > What I want to do is force my scripts to always look in the closest > 'tools' dir for any custom modules to import. For example: > > tree1/tools > tree1/my_scripts/foo.py > > tree2/tools > tree2/my_scripts/foo.py > > How can I make 'foo.py' always look in '../../tools' for custom > modules? My preference would be to avoid changing the 'foo.py' script > and have some way to resolve it via the environment (like PYTHONPATH, > or .pth files, etc.). > > Anyone have any ideas? > TIA, > -T From deets at nospam.web.de Sun Apr 20 09:27:13 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Sun, 20 Apr 2008 15:27:13 +0200 Subject: from __future__ import print In-Reply-To: References: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> Message-ID: <670um2F2ljorfU1@mid.uni-berlin.de> Lie schrieb: > On Apr 13, 7:23 pm, Roy Smith wrote: >> In article >> , >> >> Lie wrote: >>> I wish py3k >>> would make it an option whether to treat print as statement or >>> function though. >> Arrrgghhhhh! No, don't even go there. If you want optional parens, use >> Perl :-) > > Not optional parens, but a simple print statement coupled with a > powerful print function. This print statement would only have basic > printing functionality such as : > > print "Hello" > print var > print var, "Hello too" > > specifically, these would be removed: > print var, > print >> unstdout, var > > This is because it is sometimes annoying to type this: > print("Hello") > print("World") > print("This") > print("is") > print("Captain") > print("Kirk") You are aware that it is only one character more to type? It is debatable if print should have gone or not - but once you decide to have a print-statement I fail to see why you want to rid it of functionality. The costs for a keyword and special parsing rules are paid anyway then. Diez Diez From steve at holdenweb.com Sat Apr 5 08:44:13 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 08:44:13 -0400 Subject: variable scope in list comprehensions In-Reply-To: References: Message-ID: Duncan Booth wrote: > Steve Holden wrote: > >>> For a moment I thought that maybe list comprehension has its own >>> scope, but it doesn't seem to be so: >>> print [[y for y in range(8)] for y in range(8)] >>> print y >>> >>> Does anybody understand it? >>> >>> >> This isn't _a_ list comprehension, it's *two* list comprehensions. The >> interpreter computes the value if the inner list comprehension and >> then duplicates eight references to it (as you will see if you change >> an element). >> > Do you want to reconsider that statement? The interpreter recomputes the > inner list comprehension eight times, there are no duplicated > references. > [...] You are correct. I wrote that before testing, and then after testing wrote """The outer loop's control variable is never used in the inner loop, so there is no chance of conflict: each time the inner loop terminates the outer loop assigns the next value from its range - it isn't "adding one" to the variable, but merely calling an iterator's next() method.""" So I didn't do enough editing after testing to (in)validate my preconceptions. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From grflanagan at gmail.com Thu Apr 10 11:54:50 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Thu, 10 Apr 2008 08:54:50 -0700 (PDT) Subject: subprocess.Popen() output to logging.StreamHandler() References: Message-ID: <4e56c267-eb35-4fa1-831e-733817635c09@i36g2000prf.googlegroups.com> On Apr 10, 5:34 pm, Gerard Flanagan wrote: > On Apr 10, 2:11 pm, "sven _" wrote: > > > > > Version: Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) > > > My goal is to have stdout and stderr written to a logging handler. > > This code does not work: > [...] > > Are there better solutions? > > > sven > > When you create a StreamHandler, it is associated with a particular > stream, eg. sys.stdout. So when you log an event, the handler picks > it up and writes it to the stream. But you seem to think that... [snip didacticism] Rereading your post, I think I've just told you what you already knew... Never mind. G. From paul.hankin at gmail.com Thu Apr 3 07:58:33 2008 From: paul.hankin at gmail.com (Paul Hankin) Date: Thu, 3 Apr 2008 04:58:33 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> Message-ID: <40eadbd9-798b-49b8-8acb-5e27f9b38809@s37g2000prg.googlegroups.com> On Apr 3, 12:37 pm, tinn... at isbd.co.uk wrote: > What's the neatest and/or most efficient way of testing if one of a > set of strings (contained in a dictionary, list or similar) is a > sub-string of a given string? > > I.e. I have a string delivered into my program and I want to see if > any of a set of strings is a substring of the string I have been > given. It's quite OK to stop at the first one found. Ideally the > strings being searched through will be the keys of a dictionary but > this isn't a necessity, they can just be in a list if it could be done > more efficiently using a list. > > Is this the best one can do (ignoring the likelihood that I've got > some syntax wrong) :- > > # l is the list > # str is the incoming string > answer = "" > for x in l: > if str.find(x) < 0: > continue > answer = x I'd not use 'l' (confused with '1') or 'str' (a standard module) as variable names. Your code checks every string in the list even when it's found one... you can reverse the test and break when the first one is found. Using 'in' rather than testing the return value of find is nicer as a substring test. Finally, using the 'else' clause lets you make it clear that answer is set to the empty string when no match is found. for answer in l: if str in answer: break else: answer = '' -- Paul Hankin From malaclypse2 at gmail.com Fri Apr 18 13:18:08 2008 From: malaclypse2 at gmail.com (Jerry Hill) Date: Fri, 18 Apr 2008 13:18:08 -0400 Subject: Pickle problem In-Reply-To: References: Message-ID: <16651e80804181018t5d85b39cyab18d6e4c2310357@mail.gmail.com> On Fri, Apr 18, 2008 at 11:55 AM, Mario Ceresa wrote: > Hello everybody: > I'd like to use the pickle module to save the state of an object so to > be able to restore it later. The problem is that it holds a list of > other objects, say numbers, and if I modify the list and restore the > object, the list itself is not reverted to the saved one, but stays > with one element deleted. ... > ----------------------- > class A(object): > objects = [] > ----------------------- Your problem is in the class definition of A. You declare objects as a class variable, so it is shared between every instance of the class. When you pickle the instance a, then restore it, it continues to reference the same list, which is help by the class. You probably want the objects list to be an instance variable, like this: class A(object): def __init__(self): self.objects = [] If you make that change, pickling and unpickling works the way you expect. -- Jerry From spamgrinder.trylater at ggmail.com Wed Apr 23 21:19:41 2008 From: spamgrinder.trylater at ggmail.com (AlFire) Date: Wed, 23 Apr 2008 20:19:41 -0500 Subject: Python Success stories In-Reply-To: References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <480FE02D.3040201@ggmail.com> Cristina Yenyxe Gonz?lez Garc?a wrote: > 2008/4/23, Reedick, Andrew : >> IIRC, Python is used in games like Eve Online (SciFi MMO) and Vampire: >> Bloodlines (RPG.) Years later, a dedicated fan is still fixing/updating >> the Bloodlines python scripts that control the dialogue and scripted >> events. >> > > Now that you mention it, Python was also used in the Star Wars: > Knights of the Old Republic (KotOR) saga. You can even search the > scripts across the disc and take a look at hilarious code comments > like "this works but I don't know why" :D and Shrek 3 http://www.linuxjournal.com/article/9653 -- a. From soren.skou.nielsen at gmail.com Thu Apr 10 05:55:13 2008 From: soren.skou.nielsen at gmail.com (Soren) Date: Thu, 10 Apr 2008 02:55:13 -0700 (PDT) Subject: Sorting Directories from files in a os.listdir?? Message-ID: <9354f263-b833-4845-a226-1ad3a47b1e6a@p25g2000pri.googlegroups.com> Hi, I'd like to read the filenames in a directory, but not the subdirectories, os.listdir() gives me everything... how do I separate the directory names from the filenames? Is there another way of doing this? Thanks! From juergen.perlinger at t-online.de Tue Apr 22 15:03:00 2008 From: juergen.perlinger at t-online.de (Juergen Perlinger) Date: Tue, 22 Apr 2008 21:03:00 +0200 Subject: SWIG C++ std::cout do not output to interactive interpreter IDLE References: Message-ID: wongjoekmeu at yahoo.com wrote: > Dear All, > > I have some functions written in C++, which I try to approach from > python using swig. In the C++ functions I use std::cout to print stuff > to output. Everything works fine, but the only problem that I have is > that when I start IDLE and use the functions what std::cout should > print to the "IDLE console" simply does not appear. When I don't use > IDLE but simply double click on the .py script, it works all fine. I > was wondering how I could make sure that std::cout would print also to > IDLE. Thanks a lot in advance for helping to answer my question. > > RR Hmmmmm... probably tricky. Most GUIs replace 'sys.stdout' by something that behaves like a Python(!) stream, without actually touching file descriptor 1 (which is the actual process file descriptor for stdout). >From my experience with embedding/extending Python this is going to be a bit nasty, because you would need to get access to the actual stream object in Pythons 'sys' module (easy...), wrap this one in C++ to create a C++ ostream descendant that uses an underlying Python stream (here's the work...) and use it to replace 'cout' (that one's simple after all...). Are you sure you want to tackle this? I've always tried to avoid it and lived with the fact that such an extension was only printing something useful to its output when used as a console application. I haven't had a deeper look into the BOOST Python bindings, (www.boost.org) but they have a rather good reputation. Perhaps there is something in it that takes away most of the burden. -- juergen 'pearly' perlinger "It's hard to make new errors!" From gagsl-py2 at yahoo.com.ar Sun Apr 6 15:40:05 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 06 Apr 2008 16:40:05 -0300 Subject: How To Uses Modules And Plugins References: <47650e1f-148e-48f9-b09e-51cb5fb4f402@m73g2000hsh.googlegroups.com> Message-ID: En Sun, 06 Apr 2008 14:28:44 -0300, escribi?: > I am working on a client/server, computer role-play game using Python. > I want to gradually expand the game world by creating maps as > individual py files in a map directory. I am a little foggy of how to > do this. I have read about the __import__() function. I want to > understand what the difference is between using modules and plugins. > Are they the same thing? How will my root script interact with the > individual modules once it has loaded them? If you can point me to a > web site or tutorial on this subject I would be thankful. Look for recent posts about "plugin" in this group. -- Gabriel Genellina From marexposed at googlemail.com Fri Apr 18 05:40:12 2008 From: marexposed at googlemail.com (marexposed at googlemail.com) Date: Fri, 18 Apr 2008 10:40:12 +0100 Subject: MySQL hardcoding? In-Reply-To: <4807c872$1@news.mel.dft.com.au> References: <4807c872$1@news.mel.dft.com.au> Message-ID: <20080418104012.0fb2ee12.marexposed@googlemail.com> On Thu, 17 Apr 2008 22:00:21 GMT John Machin wrote: > The empirical evidence from other recent postings is that you are > mucking about with Spanish-language newspaper "articulos" on the web ... > so why charset = "Windows-1251", which is Cyrillic (i.e. Russian etc)?? > Perhaps you mean 1252 which is Microsoft's latin1 with extras. > > HTH, > John > -- > http://mail.python.org/mailman/listinfo/python-list Yes John, thanks. The only problem is MySQL doesn't include a cp1252 or Windows-1252 or ansi. I'm trying to find my way with different approaches. But there is certainly a problem if an application goes to the wrong folder to get data as MySQL seems to be doing. Thanks. From leoniaumybragg at gmail.com Sat Apr 26 07:01:45 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 04:01:45 -0700 (PDT) Subject: limewire crack Message-ID: <81d0d174-135d-48e7-9e07-04701b982222@34g2000hsh.googlegroups.com> limewire crack http://cracks.00bp.com F R E E C R A C K S From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 18 04:25:16 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 18 Apr 2008 10:25:16 +0200 Subject: Newbie question about for...in range() structure In-Reply-To: References: Message-ID: <48085ad4$0$18250$426a34cc@news.free.fr> sp at k a ?crit : (snip - already answered) > > def fact(n): > total = 0 > n = int(n) > while n > 0: > total *= n > n -=1 > return total You may be interested in a very different way to get the same result: from operator import mul def fact(n): return reduce(mul, xrange(1, n+1), 1) (snip) From darcy at druid.net Tue Apr 8 10:55:19 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Tue, 8 Apr 2008 10:55:19 -0400 Subject: Learning curve for new database program with Python? In-Reply-To: References: <00fca324-6fce-4b2a-8acb-77c96b83eb1c@p39g2000prm.googlegroups.com> Message-ID: <20080408105519.9d9cd933.darcy@druid.net> On Mon, 7 Apr 2008 23:06:23 -0700 (PDT) CM wrote: > You misunderstood me, but completely understandably. I meant that > a) the OP wanted to use Django, and so I was giving the word on the > only database engines that would work with that and b) the OP wanted > to use a relational database, and therefore would have to use SQL While most database systems require SQL, the type of database and the query language used are are not as tightly coupled as you imply. I did quite a bit of work in Progres DB in a 4GL that was not SQL although SQL was an optional extra. The original query language for PostgreSQL and its predeccessor was QUEL, not SQL. There are other examples. See http://en.wikipedia.org/wiki/SQL#Alternatives_to_SQL for some. This is not to say that learning SQL is a bad idea. It is certainly the de facto standard today. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From tomupton33 at yahoo.com Wed Apr 30 10:53:45 2008 From: tomupton33 at yahoo.com (mickey333) Date: Wed, 30 Apr 2008 07:53:45 -0700 (PDT) Subject: new free fiction Message-ID: <87f74249-e245-48b5-9b8e-da1db750012f@r66g2000hsg.googlegroups.com> http://www.authspot.com/Short-Stories/Gossip.110935 From bdsatish at gmail.com Fri Apr 11 06:14:15 2008 From: bdsatish at gmail.com (bdsatish) Date: Fri, 11 Apr 2008 03:14:15 -0700 (PDT) Subject: Rounding a number to nearest even Message-ID: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> The built-in function round( ) will always "round up", that is 1.5 is rounded to 2.0 and 2.5 is rounded to 3.0. If I want to round to the nearest even, that is my_round(1.5) = 2 # As expected my_round(2.5) = 2 # Not 3, which is an odd num I'm interested in rounding numbers of the form "x.5" depending upon whether x is odd or even. Any idea about how to implement it ? From bbxx789_05ss at yahoo.com Tue Apr 1 19:28:33 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Tue, 1 Apr 2008 16:28:33 -0700 (PDT) Subject: BeautiflSoup -- getting all the attributes of a tag? References: Message-ID: On Apr 1, 5:25?pm, 7stud wrote: > You can treat a tag like a dictionary to obtain a specific attribute: > > import BeautifulSoup as bs > > html = "
hello
" > > doc = bs.BeautifulSoup(html) > div = doc.find("div") > print div > print div["x"] > > --output:-- > a > > But you can't iterate over a tag to get all the attributes: > > import BeautifulSoup as bs > > html = "
hello
" > > doc = bs.BeautifulSoup(html) > div = doc.find("div") > > for key in div: > ? ? print key, div[key] > > --output:-- > hello > Traceback (most recent call last): > ? File "test1.py", line 9, in ? > ? ? print key, div[key] > ? File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ > python2.4/site-packages/BeautifulSoup.py", line 430, in __getitem__ > ? ? return self._getAttrMap()[key] > KeyError: u'hello' > > How can you get all the attributes when you don't know the attribute > names ahead of time? I figured it out: import BeautifulSoup as bs html = "
hello
" doc = bs.BeautifulSoup(html) div = doc.find("div") for attr, val in div.attrs: print "%s:%s" % (attr, val) --output:-- x:a y:b z:c From miki.tebeka at gmail.com Tue Apr 8 11:50:34 2008 From: miki.tebeka at gmail.com (Miki) Date: Tue, 8 Apr 2008 08:50:34 -0700 (PDT) Subject: List open files References: <47fb8d54$0$15068$426a74cc@news.free.fr> Message-ID: <2af7d536-eb72-4e6d-96ca-3c91455b06b9@a9g2000prl.googlegroups.com> Hello Bruno, > I'd like, in a WIN32 environment, list all open files. > Anyone got a clue how to do this ? Have a look at the sysinternals suite (http://technet.microsoft.com/en- us/sysinternals/0e18b180-9b7a-4c49-8120-c47c5a693683.aspx), you might find stuff there that will help you. HTH, -- Miki http://pythonwise.blogspot.com From hdante at gmail.com Sun Apr 6 21:20:39 2008 From: hdante at gmail.com (hdante) Date: Sun, 6 Apr 2008 18:20:39 -0700 (PDT) Subject: appropriate python version References: <0790632f-db07-45ef-9bcd-7e1b592d33be@u69g2000hse.googlegroups.com> <61b10f10-a322-4835-b800-ed09d046fe56@e67g2000hsa.googlegroups.com> Message-ID: On Apr 6, 5:59 pm, xamdam wrote: > Thanks. I am guessing the 32bit build should work anyways, same as > other 32 progs on XP 64? The right build should be the "amd64" one. From m.moghimi at gmail.com Mon Apr 14 14:53:00 2008 From: m.moghimi at gmail.com (m.moghimi) Date: Mon, 14 Apr 2008 11:53:00 -0700 (PDT) Subject: Python Workshop References: Message-ID: <6fd50e0b-9637-422a-b1db-b76734630f54@w8g2000prd.googlegroups.com> On Apr 14, 5:15 pm, "Twayne" wrote: > > Hi, > > > We are to hold a workshop about python (introduction). It will be two > > one hour and half sessions. > > I wanted to know which subjects do you suggest to be presented and is > > there a good presentation file (powerpoint or ...) about this on the > > net. > > We thought that it may be good that first session covers the > > introduction, zen of python, python coding syntax and the second > > session will be about application, libraries or so. > > I really appreciate if you tell me your ideas? > > Depends; what's the experiene level of the audience? "Introductory" is > a pretty vague concept; introductory to what audience? > > -- > -- > Regards, > > Twayne > > Open Office isn't just for wimps anymore; > OOo is a GREAT MS Office replacementwww.openoffice.org The audiences are computer engineering students who know programming in c++ and some of them know java. From aaron.watters at gmail.com Wed Apr 16 12:40:11 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 16 Apr 2008 09:40:11 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> Message-ID: <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> On Apr 16, 12:27 pm, Rhamphoryncus wrote: > On Apr 16, 6:56 am, Aaron Watters wrote: > > > I don't get it. It ain't broke. Don't fix it. > > So how would you have done the old-style class to new-style class > transition? I'd ignore it. I never understood it and never had any need for it anyway. New-style classes and metaclasses were a complicated solution to an unimportant problem in my opinion. And also a fiendish way to make code inscrutible -- which I thought was more of a Perl thing than a Python thing, or should be. I must be missing some of the deeper issues here. Please educate me. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=killer%20joke From google at mrabarnett.plus.com Wed Apr 30 11:15:55 2008 From: google at mrabarnett.plus.com (MRAB) Date: Wed, 30 Apr 2008 08:15:55 -0700 (PDT) Subject: Code/test ratio wrt static vs dynamic typing [was: Re: Python Success stories] References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <57d73312-37b1-4c53-9669-803e84a6901f@p25g2000hsf.googlegroups.com> <263d5498-821f-4705-9e1d-cc9e97a98e07@34g2000hsf.googlegroups.com> Message-ID: On Apr 30, 10:47 am, cokofree... at gmail.com wrote: > > A rather off-topic and perhaps naive question, but isn't a 1:4 > > production/test ratio a bit too much ? Is there a guesstimate of what > > percentage of this test code tests for things that you would get for > > free in a statically typed language ? I'm just curious whether this > > argument against dynamic typing - that you end up doing the job of a > > static compiler in test code - holds in practice. > > > George > > To me it seems like more of an argument for a (more) concise Test > Framework for Python, or at least a fully fledge IDE beyond pyDev. You could just as easily argue that it shows the power of Python: something that contains so much functionality that it requires 120 000 lines to test completely needs only 30 000 lines to implement! :-) From v.harishankar at gmail.com Tue Apr 22 07:48:37 2008 From: v.harishankar at gmail.com (Harishankar) Date: Tue, 22 Apr 2008 17:18:37 +0530 Subject: subprocess module is sorely deficient? In-Reply-To: References: Message-ID: <200804221718.37819.v.harishankar@gmail.com> On Tuesday 22 Apr 2008 17:06:26 Paul Boddie wrote: > On 22 Apr, 12:52, Harishankar wrote: > > Is there any way to use non-blocking Popen objects using subprocess? and > > 2 - is there a way to kill the subprocess in a platform independent > > manner in a purely Pythonic way? I thought initially that this problem is > > simple enough, but over the last couple of days I've been really > > struggling to find any answer. I've been through dozens of mailing list > > archives in to find a solution. Unfortunately none of the solutions seem > > to fit my needs. > > If you want some hints about using subprocesses with non-blocking I/O, > you might find some in my jailtools and pprocess projects: > > http://www.python.org/pypi/jailtools > http://www.python.org/pypi/pprocess > Thank you. I will take a look at those. Actually I feel a mechanism like this should be built-in to Python in the future. > Although these projects involve things which are not exactly cross- > platform, the communications mechanisms should be portable, perhaps > with a bit of effort (since I don't recall whether the poll library > function is available on Windows, so you might have to use the select > function instead). It can be awkward sustaining non-blocking > communications with processes if they use buffered I/O, and the only > way I could make Python-based subprocesses work in jailtools was to > invoke them with the unbuffered option (-u). > > > My only solution seems to be to offer the end user the mencoder command > > line and make them execute it manually and be done with it but that seems > > a rather weak solution. > > The subprocess module may be an improvement over the popen2 module and > various os module functions, but it's still rather arcane. Yes. I am quite sure there must be an elegant solution to the subprocess handling/management. Problem is I've been at this for three days and I'm getting quite bleary eyed trying to pore through a lot of documentation ;-) -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org From ivory91044 at gmail.com Tue Apr 29 04:58:31 2008 From: ivory91044 at gmail.com (ivory91044 at gmail.com) Date: Tue, 29 Apr 2008 01:58:31 -0700 (PDT) Subject: nude crack whores Message-ID: <50bcba78-a4d6-4911-aad2-392154803562@e39g2000hsf.googlegroups.com> nude crack whores http://crack.cracksofts.com From __peter__ at web.de Wed Apr 30 10:12:17 2008 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Apr 2008 16:12:17 +0200 Subject: relative import broken? References: Message-ID: test wrote: > basic noob question here. > > i am trying to reference a package, i have the structure: > > mypack/ > __init__.py > test.py > subdir1/ > __init__.py > mod1.py > subdir2/ > __init__.py > mod2.py > > can someone please tell me why the statement: > > from mypack.subdir1.mod1 import * > > does NOT work from mod2.py nor from test.py? > > instead, if i use: > > from subdir1.mod1 import * > > it works perfectly from test.py. > > ....? The parent directory of mypack must be in the module search path, see http://docs.python.org/tut/node8.html#l2h-19 The least intrusive way to achieve this is to move test.py one level up in the directory hierarchy. Peter From victorsubervi at gmail.com Tue Apr 8 11:24:44 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Tue, 8 Apr 2008 10:24:44 -0500 Subject: String Literal to Blob Message-ID: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> Hi: I am able (finally) to upload an image to the database. However, when I try to retrieve it, I get a string literal. Here is my code: #!/usr/local/bin/python import cgitb; cgitb.enable() import MySQLdb def test(): host = 'mysqldb2.ehost-services.com' user = 'user' passwd = 'pass' db = 'bre' db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor= db.cursor() cursor.execute('select pic1 from products where id="3";') content = cursor.fetchall() # print 'Content-Type: image/jpeg\r\nContent-Length: %d\n' % len(content) print 'Content-Type: image/jpeg\r\n' print '\n' print content print '\n' cursor.close() test() (Apparently, Plesk doesn?t like if __name__ == '__main__': ) The commented out line gives me a leading less than sign...and that?s it. What do? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From ptmcg at austin.rr.com Mon Apr 21 10:14:47 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Mon, 21 Apr 2008 07:14:47 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: On Apr 19, 4:42?am, Carl Banks wrote: > > If you don't like Python 3, DON'T USE IT. > I've read this position a number of times in this and related threads, and it overlooks one constituency of Python developers - those who develop and support modules for use by other Python users. As the supporter of pyparsing, I really can't just "not use" Py3 - ignoring Py3 means shutting out/holding back those of my users who do want to use it, and pretty much consigning my module to eventual dustbin status. Ideally, I can implement some form of cross-compatible code so that I need maintain only a single code base, and I have managed to do so on a number of fronts (with the help of Robert A. Clark): - add support for both __bool__ and __nonzero__ (__nonzero__ calls __bool__, so that upgrading to Py3 actually saves a function call) - convert isinstance(x,basestring) to isinstance(x,__BASESTRING__) and dynamically set __BASESTRING__ to basestring or str - similar treatment for sys.maxint/maxsize -> __MAX_INT__ I dodged a bullet when 3.0a3 added back in support for the 2.x form of "except" for exception handling. 3.0a2 only supported "except varname as ExceptionType:" and there was no way I could do this in a multi- version compatible way. My remaining hassle is print as function vs. print as statement. I provide a number of default diagnostic methods, and I have not fully gotten all to print nice - converting "print x" to "print (x)" is simple enough, and "print (x,y)" replaces "print x,y" well enough when running under Py3, but the same code in Py2.x now prints a tuple instead of a nice string like before. I will probably punt on the whole issue in the next release and just use sys.write.stdout/stderr throughout, and " ".join() the args (another function call!) before calling. I wasn't aware of the coming deprecation of '%' string interpolation, but at least it is deferred until 3.3, which does give me a few years I should think before I absolutely must address it. This is really not so much an issue for me as it is for my "customers." Pyparsing returns its parsed tokens using a class that is dict-like in behavior, but without extending dict (duck-typing at its finest!). I really like that my users can parse an expression and access any named fields directly and neatly in an interpolated string using "%(field_name)s". If this is removed, pyparsing will continue to work as-is, but I feel like a nice ease-of-access mode will have been lost to those who use it. Overall, I think I'm getting off pretty easy, but then pyparsing is a small module with very limited use of the standard lib. I can imagine that maintainers of larger libraries are having some serious fits trying to support both versions with a single code base. And as much as we all love Python-the-language, language features alone do not help a language and its community of users to grow and proliferate. I think most would agree that it is the cornucopia of libraries that really make Python an environment for developing production applications. -- Paul From guybenron at gmail.com Tue Apr 22 16:48:37 2008 From: guybenron at gmail.com (guybenron at gmail.com) Date: Tue, 22 Apr 2008 13:48:37 -0700 (PDT) Subject: Choosing log file destination in logging configuration file References: <3e85cd72-304e-4e17-8ca9-b0688a59fc14@t54g2000hsg.googlegroups.com> Message-ID: On Apr 22, 12:57 pm, Miki wrote: > Hello, > > > > > So far so good. In the relevant applications, the code looks something > > like this: > > logging.config.fileConfig('log.ini') > > logger = logging.getLogger('log.regular') logger = > > logging.getLogger('log.daemonic') > > .. and start logging. > > > The thorn in my side is that after the fileConfig call, BOTH handlers > > are instantiated, meaning both types of files are created for every > > component, even if I don't need it: component.log (for the rotating > > handler) and compenent.date.log (for the regular file handler). > > > ..So finally, here's my question: > > Apart from splitting the logging configuration into two separate > > files, is there any way to NOT create the file until you actually use > > it? > > You can generate the .ini file on the fly and then load it: > > >>> log_ini = gen_log_ini(type) # type is either "deamon" or "regular" > >>> atexit.register(lambda: remove(log_ini)) > >>> logging.config.fileConfig(log_ini) > > HTH, > -- > Miki http://pythonwise.blogspot.com I think it misses the point of having a file to config.. It looks as if there's no solution. A peek at the logging module shows this: klass = cp.get(sectname, "class") ... klass = eval(klass, vars(logging)) args = cp.get(sectname, "args") args = eval(args, vars(logging)) h = apply(klass, args) Bah. I'll have to split them into two configuration files (or subclass and have the respective file and rotating handlers lazy evaluate until the actual log call is made). Thanks though. From wwzaygvm at gmail.com Wed Apr 16 16:57:47 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 13:57:47 -0700 (PDT) Subject: fireworks cs3 crack Message-ID: <37fe3750-239a-4a8b-8871-e568913cf447@u12g2000prd.googlegroups.com> fireworks cs3 crack http://cracks.12w.net F R E E C R A C K S From nigamreetesh84 at gmail.com Mon Apr 14 00:41:55 2008 From: nigamreetesh84 at gmail.com (reetesh nigam) Date: Sun, 13 Apr 2008 21:41:55 -0700 (PDT) Subject: how to remove \n in the list Message-ID: <2ba667ab-6818-47eb-8595-79ed970728f7@q1g2000prf.googlegroups.com> hi, l=['5\n', '2\n', '7\n', '3\n', '6\n'] how to remove \n from the given list From gagsl-py2 at yahoo.com.ar Sun Apr 20 01:17:12 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 02:17:12 -0300 Subject: RotatingFileHandler - ShouldRollover error References: <4ECBD915C6F1254AB1AFF4B9F08287B2176F4253C0@loftexchange.loftwareinc.com> Message-ID: En Wed, 16 Apr 2008 10:50:44 -0300, escribi?: > I am using the RotatingFileHandler logger with Python 2.5 on Windows and > I am getting an error on the rollover. When the log file gets close to > the size where it needs to rollover, I start getting the following error > for every log message. Does anyone have a solution to this problem? > > Traceback (most recent call last): > File "C:\Python25\Lib\logging\handlers.py", line 73, in emit > if self.shouldRollover(record): > File "C:\Python25\Lib\logging\handlers.py", line 147, in shouldRollover > self.stream.seek(0, 2) #due to non-posix-compliant Windows feature > ValueError: I/O operation on closed file There are some fixes in svn - you may try using the current sources from http://svn.python.org/projects/python/trunk/ -- Gabriel Genellina From iamzcyhit at gmail.com Sat Apr 12 22:33:12 2008 From: iamzcyhit at gmail.com (=?GB2312?B?1cW0utS9?=) Date: Sat, 12 Apr 2008 19:33:12 -0700 (PDT) Subject: Where is the function of 'apply' always used? Message-ID: <84cefd1a-58de-485b-b00b-77218d2d054c@c19g2000prf.googlegroups.com> I'am a beginner of Python.In the course of reading the Python book,I found the function:apply;But I don't understand its use.Help! From john.deas at gmail.com Sun Apr 6 13:50:51 2008 From: john.deas at gmail.com (John Deas) Date: Sun, 6 Apr 2008 10:50:51 -0700 (PDT) Subject: subprocess end Message-ID: <569918a5-4ad0-41e6-bec8-c9b870ae65cc@d45g2000hsc.googlegroups.com> Hi, I am coding a small script to batch-convert flv files. At the core of it, mencoder is called through processString='mencoder -oac lavc -ovc lavc -of lavf -lavcopts aglobal=1:vglobal=1:vcodec=mpeg4:acodec=libfaac:vbitrate=256:abitrate=64 -lavfopts format=mp4 -ofps 15 -vf scale=320:240,harddup -ss '+currBegin +' -endpos '+currEnd+' -o '+currOutput+' '+inputName p = subprocess.Popen(processString, shell=True,stdout=subprocess.PIPE) However, instructions following this last one do not wait for it to complete. Is it possible to change this behaviour, so that the rest of my script is executed only when this subprocess has finished its execution ? Thanks JD From no at spam.com Sat Apr 26 07:55:20 2008 From: no at spam.com (Grayham) Date: Sat, 26 Apr 2008 12:55:20 +0100 Subject: API's and hardware communication. Newbie Message-ID: <_MudnfZZ9uW0hY7VRVnyhwA@bt.com> Hi all I am new to this group so 'Hello All' I have a PC which is running linux and in it have installed a digital satellite card. I would like to write some software to access the card, tune it and bring back video. Basically a home brew DVB-s application. Being a non/new programmer (apart from some basic too many years ago) I decided to teach my self Python as from what i have read it's an easy and powerfull language to learn. I have been at it a few weeks and am getting on OK and finding it reasonably OK to pick up. The problem is i can find little to no information on programming for DVB cards or on how to access the Linux tv API in Python but I can find lots of information in C. This is making me think should i bother with Python and just learn C even though this will probably take a lot longer. Can some one help me or point me at a resource somewhere or would it be best to just learn C instead. I am aware this is a complicated little project for someone just starting out but it will be a multifaceted program with loads of interesting classes, functions and loops and i don't have to start with the really difficult stuff first. I just want to know if it's possible under python to access the DVB card and if so how? Cheers Grayham From marexposed at googlemail.com Fri Apr 18 05:28:56 2008 From: marexposed at googlemail.com (marexposed at googlemail.com) Date: Fri, 18 Apr 2008 10:28:56 +0100 Subject: Unicode chr(150) en dash In-Reply-To: <7dae96d4-48c4-46c9-9aa9-33a263b84ca4@26g2000hsk.googlegroups.com> References: <48063434$0$36327$742ec2ed@news.sonic.net> <7dae96d4-48c4-46c9-9aa9-33a263b84ca4@26g2000hsk.googlegroups.com> Message-ID: <20080418102856.fdf5ddf3.marexposed@googlemail.com> On Thu, 17 Apr 2008 20:57:21 -0700 (PDT) hdante wrote: > Don't use old 8-bit encodings. Use UTF-8. Yes, I'll try. But is a problem when I only want to read, not that I'm trying to write or create the content. To blame I suppose is Microsoft's commercial success. They won't adhere to standars if that doesn't make sense for their business. I'll change the approach trying to filter the contents with htmllib and mapping on my own those troubling characters. Anyway this has been a very instructive dive into unicode for me, I've got things cleared up now. Thanks to everyone for the great help. From steve at holdenweb.com Wed Apr 23 08:09:22 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 08:09:22 -0400 Subject: problem with dictionaries In-Reply-To: References: Message-ID: Simon Strobl wrote: > Hello, > > the idea of the following program is to parse a frequency list of the > form FREQUENCY|WORD, to store the frequency of a word in a dictionary > (and to do some things with this information later). > > I have done this many many times. Suddenly, it does not work any more: > The value frq[key] is different from the value that key has in the > file 'my_frqlist.txt'. > > I am using Python 2.5.1 > > Any hints? > > Simon > > ================================================ > > #!/usr/bin/python > > import sys > > frqlist = open('my_frqlist.txt', 'r') > > # my_frqlist looks like this: > # 787560608|the > # 434879575|of > # 413442185|and > # 395209748|to > # 284833918|a > # 249111541|in > # 169988976|is > > frq = {} > > for line in frqlist: > line = line.rstrip() > frequency, word = line.split('|') > frq[word] = int(frequency) > > for key in frq.keys(): > print key, frq[key] > You musts have missed the memo. The rules of the universe changed at 0834 UST yesterday, and all functioning Python programs stopped working. More seriously, *something* must have changed - it's probably not the rules of the universe though. Are the files now coming from a different source (Windows rather than Unix or vice versa)? As you read in the data, insert a print "%r: %s %s" % (line, frequency, word) to see exactly what is being processed and how it is getting split. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From Lie.1296 at gmail.com Sun Apr 27 13:49:19 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 27 Apr 2008 10:49:19 -0700 (PDT) Subject: How do I say "Is this a function"? References: <4813D22A.8040902@v.loewis.de> Message-ID: On Apr 27, 11:01?am, John Henry wrote: > On Apr 26, 6:08?pm, "Martin v. L?wis" wrote: > > > > > > def f1(): > > > ? ?print "In f1" > > > > def f3(): > > > ? ?print "In f3" > > > > def others(): > > > ? ?print "In others" > > > > for i in xrange(1,3): > > > ? ?fct = "f%d()"%(i+1) > > > ? ?try: > > > ? ? ? exec fct > > > ? ?except: > > > ? ? ? others() > > > I'd write that as > > > for i in xrange(1,3): > > ? ? globals().get("f%d" % (i+1), others)() > > > Regards, > > Martin > > Perfect. ?Works great. ?No EXEC. > > You guys are great. If you just want to avoid exec, why not: def f1: print "In f1" def f3: print "In f3" class f4(object): def __init__(self): print "In f4" def others: print "Since all else failed, I'm in others." f2 = "NAF -> Not a Function" flist = [f1, f2, f3, f4] for fct in flist: try: fct() except TypeError: others() It's readable, and it's fast if there's just a few "hard fault" (try- except works best when it usually succeed and just fails once or twice), and it's Pythonic too (Easier to ask forgiveness than to ask permission). The difference between this and the explicit type checking is that this allows a class (like f4) to pass since a Class Constructor & Initiator is a callable function too, depending on your need, you might want to consider class constructor as a function too. From gh at ghaering.de Tue Apr 15 11:10:26 2008 From: gh at ghaering.de (=?ISO-8859-1?Q?Gerhard_H=E4ring?=) Date: Tue, 15 Apr 2008 17:10:26 +0200 Subject: py3k s***s In-Reply-To: <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> Message-ID: <66jur3F2he852U1@mid.uni-berlin.de> Sverker Nilsson wrote: > [about code supporting multiple Python versions] > When it has been the fuzz with versions before, then I could have the > same code still work with older versions. But now it seems I have to > fork TWO codes. [...] I don't think many people have ported their C extensions to Python 3.0, yet. I've had the dubious privilege for pysqlite/the sqlite 3 module. And I find that's a bigger pain than the Python level. Way too many #ifdefs. I don't like branching projects, but this seems to be the only sensible approach here. -- Gerhard From gerry at nowhere.ford Tue Apr 22 23:02:52 2008 From: gerry at nowhere.ford (Gerry Ford) Date: Tue, 22 Apr 2008 22:02:52 -0500 Subject: pop langs website ranking References: <41fbaf27-a80b-402b-b406-c048a65a8643@b64g2000hsa.googlegroups.com> <315e13cc-3d21-4f2f-8503-835ea79069e2@x35g2000hsb.googlegroups.com> Message-ID: <1208919347_3071@news.newsgroups.com> "Paul McGuire" wrote in message news:315e13cc-3d21-4f2f-8503-835ea79069e2 at x35g2000hsb.googlegroups.com... On Apr 22, 4:41 pm, "xah... at gmail.com" wrote: > In February, i spent few hours researching the popularity of some > computer language websites. > I seem to recall this exact same post from *last* February. --->I remember it too. Xah is quite the self-promoter. Massive cross-posters don't have anything to say for me. -- "Life in Lubbock, Texas, taught me two things: One is that God loves you and you're going to burn in hell. The other is that sex is the most awful, filthy thing on earth and you should save it for someone you love." ~~ Butch Hancock From sierra9162 at gmail.com Wed Apr 16 11:27:32 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:27:32 -0700 (PDT) Subject: kate hudson oscars Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From castironpi at gmail.com Mon Apr 21 13:55:42 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Mon, 21 Apr 2008 10:55:42 -0700 (PDT) Subject: Database vs Data Structure? References: <61bf5f46-e917-4a98-b87f-8e5087cb07f7@a23g2000hsc.googlegroups.com> Message-ID: <33cda2a5-78e0-469d-8cde-b28acc3dd2da@m44g2000hsc.googlegroups.com> On Apr 19, 10:56?pm, Dennis Lee Bieber wrote: > On Sat, 19 Apr 2008 11:27:20 -0700, Scott David Daniels > declaimed the following in comp.lang.python: > > ? ? ? ? Hijacking as with the gmail kill filter I had to apply... > > > castiro... at gmail.com wrote: > > > Are databases truly another language from Python, fundamentally? > > ? ? ? ? Databases predate Python by decades... Though getting hardware fast > enough to implement the current darling -- relational -- did take a few > years. > > ? ? ? ? In my college days, database textbooks introduced: Hierarchical (IBM > IMS, I believe was the archetype used, though there were many others); > DBTG (Data Base Task Group) Network (the DBMS on the Xerox Sigma-6 at my > campus was a network model); and then gave Relational as an > experimental/theoretical format. About two years after I graduated, the > revised versions of the textbooks started with Relational, and then > listed hierarchical and network as "historical" formats. > > ? ? ? ? In hierarchical and network, one had to explicitly code for the way > the data was stored... In simple form: hierarchical required one to > access from a top-level record, which then had "fields" comprising > related data (and could have multiple occurrences). > > Invoice: ? ? ? ?has customer number, name, address, etc. and a "field" for > line items... The line items were a subtree: item number, description, > quantity, price, extended price... > > ? ? ? ? Network extended the hierarchical model by allowing access to the > "subtrees" from multiple different types of parent trees. > > ? ? ? ? Relational started life as a theory of "how to view the data -- > independent of how it is stored" -- comprising relations (which are NOT > the links between tables. In relational theory the terms equate as: > > Common/Lay ? ? ? ? ? ? ? ? ? ? ?Theory > table ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? relation > column ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?domain > row/record ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tuple > > "relation" meant that all the data in each tuple was related to the > others. The SQL "relationship operators" that are used to link separate > tables are not where "relational database" comes from. > > ? ? ? ? SQL started life as a query language -- also independent of how the > data is stored. however, it fit into relational theory easily... Maybe > because it sort of combines relational algebra and relational calculus. > > > > > Classic qualities for a database that don't normally apply to Python > > (all properties of a "transaction" -- bundled set of changes): > > ? ? ? ? Examples might have been useful > > > ? ? ?* Atomicity: > > ? ? ? ? A transaction either is fully applied or not applied at all. > > ? ? ? ? Well... self-explanatory... > > > ? ? ?* Consistency: > > ? ? ? ? Transactions applied to a database with invariants preserve > > ? ? ? ? those invariants (things like balance sheets totals). > > ? ? ? ? One of the key ones... > > ? ? ? ? update accounts set > ? ? ? ? ? ? ? ? balance = balance - 100 > ? ? ? ? where accountnum = "from account"; > ? ? ? ? update accounts set > ? ? ? ? ? ? ? ? balance = balance + 100 > ? ? ? ? where accountnum = "to account"; > > ? ? ? ? A failure between the two update statements MUST ensure that no > changes were made to the database... Otherwise, one would lose 100 into > the vapor. (This example does link back to the "A" and is more on the > user side -- the code needs to specify that both updates are part of the > same transaction). > > > ? ? ?* Isolation: > > ? ? ? ? Each transactions happens as if it were happening at its own > > ? ? ? ? moment in time -- tou don't worry about other transactions > > ? ? ? ? interleaved with your transaction. > > ? ? ? ? Though how various RDBMs implement this feature gets confusing. One > has everything from locking the entire database (basically meaning that > "losing" transactions don't get applied at all and the code has to > reexecute the transaction logic) down to those that can lock on > individual records -- so overlapping transactions that don't need those > records complete with no failures. > > > ? ? ?* Durability: > > ? ? ? ? Once a transaction actually makes it into the database, it stays > > ? ? ? ? there and doesn't magically fail a long time later. > > ? ? ? ? Assuming a disk failure is not "magic" and one doesn't have a recent > backup > > -- > ? ? ? ? Wulfraed ? ? ? ?Dennis Lee Bieber ? ? ? ? ? ? ? KD6MOG > ? ? ? ? wlfr... at ix.netcom.com ? ? ? ? ? ? wulfr... at bestiaria.com > ? ? ? ? ? ? ? ? HTTP://wlfraed.home.netcom.com/ > ? ? ? ? (Bestiaria Support Staff: ? ? ? ? ? ? ? web-a... at bestiaria.com) > ? ? ? ? ? ? ? ? HTTP://www.bestiaria.com/ I'm holding the premise that money can be made different ways, also and as technique is scarce, and exploration in programming is a non- negative utility. I have a soft-coded script I can show, I'm just not in the space program. From see at signature.invalid Sat Apr 19 13:49:42 2008 From: see at signature.invalid (Douglas Wells) Date: Sat, 19 Apr 2008 13:49:42 -0400 (EDT) Subject: Kill an OS process from script (perhaps unix specific) References: <7cd7208f-777b-4264-8d34-3c4bf3377940@a22g2000hsc.googlegroups.com> Message-ID: In article <7cd7208f-777b-4264-8d34-3c4bf3377940 at a22g2000hsc.googlegroups.com>, chengiz at my-deja.com writes: > Hi, > I'm trying to run a process from a python script. I need the exit > status of that process but do not care about its output, so until now > was using os.system(). But it turned out that the process often went > into an infinite loop, so I wrote a SIGALRM handler. Unfortunately the > code I came up with is quite kludgy: > > import subprocess > ... > try: > p = subprocess.Popen(..., shell = True) > pid = p.pid > os.waitpid(pid...) > ... > except ...: # Thrown by alarm signal handler > os.kill(pid + 1) # "Real" pid = shell pid + 1 > ... > > The os.kill is very hacky and unsafe so I was looking for better > ideas. Any help will be greatly appreciated. Thanks! Assuming that the problem is really an infinite loop (and not just an arbitrary delay), you could use the simple construct: import os code = os.system ("ulimit -t ; ...") That's not guaranteed to work on all POSIX systems, but it should work with at least ash, bash, and ksh. And it would would be "limit cputime ; ..." if you somehow got hooked up with a C shell. - dmw -- . Douglas Wells . Connection Technologies . . Internet: -sp9804- -at - contek.com- . From paulgeeleher at gmail.com Thu Apr 24 08:12:46 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Thu, 24 Apr 2008 05:12:46 -0700 (PDT) Subject: Setting expirty data on a cookie References: <8ba48e05-9aba-4a56-805c-cd31b43517ab@24g2000hsh.googlegroups.com> Message-ID: <80818edd-37dd-4306-8723-97db63afd5fb@z72g2000hsb.googlegroups.com> On Apr 24, 12:41 pm, sophie_newbie wrote: > On Apr 22, 8:38 pm, David wrote: > > > On Tue, Apr 22, 2008 at 6:21 PM,sophie_newbie wrote: > > > Does anyone know how to do this? I can't seem to make it work. > > > > I'm using: > > > > c = Cookie.SimpleCookie() > > > c['data'] = "unamepwordwhatever" > > > c.expires = time.time() + 300 > > > print c > > > > This doesn't seem to work, so I'm assuming isn't the correct way to > > > set an expiry data? Anyone able to help me out here? > > > You're probably looking for cookielib.Cookie > > I don't think so, to give you a more complete picture, if I run this > code: > > import Cookie > import time > c = Cookie.SimpleCookie() > c['data'] = "unamepwordwhatever" > c.expires = time.time() + 300 > print c > > This codes gives an output of: > > "Set-Cookie: data=unamepwordwhatever" > > As in there is no mention of an expiry date, when surely there should > be? > > Thanks for any advice. Ok this seems to work: import Cookie import time c = Cookie.SimpleCookie() c['data'] = "unamepwordwhatever" c['data']['expires'] = 30 * 24 * 60 * 60 print c Gives an output of: "Set-Cookie: data=unamepwordwhatever; expires=Sat, 24-May-2008 12:11:36 GMT" Bizarre that this information was so hard to find! From gagsl-py2 at yahoo.com.ar Mon Apr 21 01:45:39 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 02:45:39 -0300 Subject: Prob. w/ Script Posting Last Value References: <4dc0cfea0804170922n2a96be20sc424a7e67742a12e@mail.gmail.com> <480791D6.4000802@holdenweb.com> <4dc0cfea0804171151y204b11bal160762b88dfcf3ee@mail.gmail.com> Message-ID: En Thu, 17 Apr 2008 15:51:43 -0300, Victor Subervi escribi?: > On Thu, Apr 17, 2008 at 1:07 PM, Steve Holden wrote: >> Victor Subervi wrote: >> >> > Gabriel provided a lovely script for showing images which I am modifying >> > for my needs. I have the following line: >> > print '

\n' % (d, y) >> > where the correct values are entered for the variables, and those values >> > increment (already tested). Here is the slightly modified script it calls: >> > #!/usr/local/bin/python >> > import cgitb; cgitb.enable() >> > import MySQLdb >> > import cgi >> > form = cgi.FieldStorage() >> > picid = int(form["id"].value) >> > x = int(form["x"].value) >> > pic = str(x) >> > print 'Content-Type: text/html' >> > db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) >> > cursor= db.cursor() >> > sql = "select " + pic + " from products where id='" + str(picid) + "';" >> > cursor.execute(sql) >> > content = cursor.fetchall()[0][0].tostring() >> > cursor.close() >> > print 'Content-Type: image/jpeg\r\nContent-Length: %s\n' % len(content) >> > print content >> > I need to make it so that it will show all my images, not just the last >> > one. Suggestions, please. That 'Content-Type: text/html' is wrong, you're returning an image here. Are you sure that *different* pictures are stored in the database? Perhaps there was an error and all columns have the same picture. Also make sure you're not seeing a cached image in your browser. >> > In your "page generator" page, replace >> >> print '

\n' % (d, y) >> >> by >> >> for d, y in (results of some DB query to get d and y for each image): >> print '

\n' % (d, y) > > Well, I just tried this: > > #! /usr/bin/python > print """Content-type: text/html > > > > > > > > """ > y = 1 > for d in 2, 12: > while y < 12: > print '

\n' % (d, y) > y += 1 > print""" > > """ > and it printed the same image over and over again :( An empty line is missing after Content-Type and before the actual content. Look at the source and be sure the src= attribute is generated correctly. -- Gabriel Genellina From carlwuhwdmckay at gmail.com Mon Apr 21 02:11:00 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:11:00 -0700 (PDT) Subject: crack cocaine user profile Message-ID: <88437666-f152-4a4a-bca3-9a4d5fb88244@l64g2000hse.googlegroups.com> crack cocaine user profile http://cracks.00bp.com F R E E C R A C K S From jjl at pobox.com Tue Apr 1 16:17:29 2008 From: jjl at pobox.com (John J. Lee) Date: Tue, 01 Apr 2008 20:17:29 GMT Subject: Why prefer != over <> for Python 3.0? References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> Message-ID: <87prt9coti.fsf@pobox.com> "Gabriel Genellina" writes: [...] >> There was a version of APL for the Sinclair QL which replaced the >> standard APL symbols with keywords. > > Wow, APL on 8 bits? > Now there is (or perhaps there was) J, a reincarnation of APL by > Iverson himself that uses ASCII characters only. The BBC Model B ran I-APL, too. Sitting on my desk is a copy of "I-APL Instruction Manual for PC Clones, RML Nimbus, BBC Master & B, and Archimedes", along with a few other APL books and a pile of newsletters, waiting to be thrown away :-( I got a copy because they were giving it away free to schools. Poisoning young minds ;-) How did programmers manage back then in 32k? Less software development, more jigsaw puzzle. John From fennelllindy8241 at gmail.com Mon Apr 28 03:17:06 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:17:06 -0700 (PDT) Subject: norton ghost crack Message-ID: norton ghost crack http://crack.cracksofts.com From carlwuhwdmckay at gmail.com Sat Apr 26 09:35:01 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:35:01 -0700 (PDT) Subject: perfect patch Message-ID: <7ee2c246-d7ec-4615-b2c1-e2a4b6460e8e@m73g2000hsh.googlegroups.com> perfect patch http://cracks.00bp.com F R E E C R A C K S From andrewdied at gmail.com Mon Apr 14 11:01:28 2008 From: andrewdied at gmail.com (andrewdied at gmail.com) Date: Mon, 14 Apr 2008 08:01:28 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: On Apr 11, 4:14?am, bdsatish wrote: > I'm interested in rounding numbers of the form "x.5" depending upon > whether x is odd or even. Any idea about how to implement it ? Side note: A specialized use for this is in the US Field Artillery, where it's called "artillery expression." You don't round, but "express" a fraction to the nearest even whole number. 2.5 is 2.0, 3.5 is 4.0, etc. Or, if you need to express to the tens, 15 is 20, 25 is 20, and so on. From workitharder at gmail.com Tue Apr 1 18:46:20 2008 From: workitharder at gmail.com (bukzor) Date: Tue, 1 Apr 2008 15:46:20 -0700 (PDT) Subject: Directed Graph Traversal Message-ID: <804682cb-2da6-4d85-83d4-c7425c498534@p25g2000hsf.googlegroups.com> Can someone point me in the direction of a good solution of this? I'm using it to construct a SQL query compiler, where each node is a table and each edge is a join. I'm planning on using the NetworkX library if possible. https://networkx.lanl.gov/reference/networkx/ Given a directed graph and a list of points in the graph, what is the minimal subgraph that contains them all? It is preferable that the subgraph is a tree. A -- B -- C -- D | | E -- F A, B, F => ABEF (or ABCF) A, F, C => ABCF A, E, D => ABCD E Thanks! --Buck From gagsl-py2 at yahoo.com.ar Tue Apr 8 15:37:19 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 08 Apr 2008 16:37:19 -0300 Subject: Calling CVF-Fortran-dll with ctypes and simple structure References: <60915c2d-0c0d-42fc-8b02-5fb58e13a20c@p25g2000hsf.googlegroups.com> Message-ID: En Tue, 08 Apr 2008 06:02:17 -0300, Michael Sch?fer escribi?: > Gabriel, > > works perfect - even in complex nested structures! > Thank you very much! > >> (If both Fortran and VB say "char*9", why did you choose a pointer >> here?) > I do not know this possibility. Could you please drop me a few lines? (It's just what I posted and you said it worked) In C, strings are usually represented as an array of characters implicitely ending at the first NULL character. By example: `char foo[20]` declares a string variable named foo with enough space for up to 19 characters (plus the final NULL character). A very common way of refer to such strings is to pass a pointer to its first character: `char *pfoo` declares a variable pfoo which can hold a reference to a string variable allocated somewhere (this is the usual way to pass a string argument to a function). In ctypes terminology, the first type is declared as c_char*20, and the second one is c_char_p. In FORTRAN you'd use CHARACTER*20 FOO (or CHARACTER(20)::FOO) to declare a string variable with up to 20 characters, right padded with spaces. The appropiate way to declare this with ctypes is then to use c_char*20 (and probably initialize it with spaces, and trim spaces on the right coming from Fortran). c_char_p declares a pointer, but Fortran filled it as it were an array of characters: the first 4 letters of "Sample", when read as a little-endian integer, give 0x706D6153, the "invalid pointer" you got. -- Gabriel Genellina From vinay_sajip at yahoo.co.uk Wed Apr 23 12:50:33 2008 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Wed, 23 Apr 2008 09:50:33 -0700 (PDT) Subject: Choosing log file destination in logging configuration file References: <3e85cd72-304e-4e17-8ca9-b0688a59fc14@t54g2000hsg.googlegroups.com> Message-ID: <97bb1161-92f2-4079-8f59-a924c965d2f5@34g2000hsf.googlegroups.com> On Apr 22, 9:48 pm, guyben... at gmail.com wrote: > On Apr 22, 12:57 pm, Miki wrote: > > > > > Hello, > > > > So far so good. In the relevant applications, the code looks something > > > like this: > > >logging.config.fileConfig('log.ini') > > > logger =logging.getLogger('log.regular') logger = > > >logging.getLogger('log.daemonic') > > > .. and startlogging. > > > > The thorn in my side is that after the fileConfig call, BOTH handlers > > > are instantiated, meaning both types of files are created for every > > > component, even if I don't need it: component.log (for the rotating > > > handler) and compenent.date.log (for the regular file handler). > > > > ..So finally, here's my question: > > > Apart from splitting theloggingconfiguration into two separate > > > files, is there any way to NOT create the file until you actually use > > > it? > > > You can generate the .ini file on the fly and then load it: > > > >>> log_ini = gen_log_ini(type) # type is either "deamon" or "regular" > > >>> atexit.register(lambda: remove(log_ini)) > > >>>logging.config.fileConfig(log_ini) > > > HTH, > > -- > > Miki http://pythonwise.blogspot.com > > I think it misses the point of having a file to config.. > It looks as if there's no solution. A peek at theloggingmodule shows > this: > klass = cp.get(sectname, "class") > ... > klass = eval(klass, vars(logging)) > args = cp.get(sectname, "args") > args = eval(args, vars(logging)) > h = apply(klass, args) > > Bah. I'll have to split them into two configuration files (or subclass > and have the respective file and rotating handlers lazy evaluate until > the actual log call is made). > Thanks though. Not sure if it's any help - the SVN version contains a new optional "delay" parameter for FileHandler and subclasses (including the rotating handlers) which delays opening the file until there's a need to, i.e. when an emit() call occurs. Regards, Vinay Sajip From danb_83 at yahoo.com Sun Apr 20 02:25:33 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Sat, 19 Apr 2008 23:25:33 -0700 (PDT) Subject: Checking if a text file is blank References: Message-ID: On Apr 20, 1:04 am, elno... at gmail.com wrote: > Greetings! > > I've just started learning python, so this is probably one of those > obvious questions newbies ask. > > Is there any way in python to check if a text file is blank? > > What I've tried to do so far is: > > f = file("friends.txt", "w") > if f.read() is True: > """do stuff""" > else: > """do other stuff""" > f.close() > > What I *mean* to do in the second line is to check if the text file is > not-blank. But apparently that's not the way to do it. > > Could someone set me straight please? The flaw in your code is that "f.read() is True" doesn't do what you think it does. (1) The "is" operator is a test for object IDENTITY. Two objects can be equal but distinct >>> list1 = list2 = [1, 2, 3] >>> list1 is list2 True >>> list1[-1] = 4 >>> list2 [1, 2, 4] >>> list1 = [1, 2, 3] >>> list2 = [1, 2, 3] >>> list1 is list2 False >>> list1[-1] = 4 >>> list2 [1, 2, 3] (2) Even if you used "f.read() == True", it still wouldn't work in Python. Values can be true or false (in the context of an if or while statement) without being equal to True or False. Values that are equal to True: True, 1, 1.0, (1+0j), decimal.Decimal(1) Values that are true but not equal to True: "spam", "1", (1,), [1], set([1]), {1: 2}, etc. Values that are equal to False: False, 0, 0.0, 0j, decimal.Decimal(0) Values that are false but not equal to False: "", (), [], set() And even if you are sure that you're only dealing with values of 0 or 1, it's unnecessary to write "if x == True:". It's redundant, just like "if (x == True) == True:" or "if ((x == True) == True) == True:". Just write "if x:". Or, in this specific case, "if f.read():". (3) While not affecting your program's correctness, it's rather inefficient to read a gigabytes-long file into memory just to check whether it's empty. Read just the first line or the first character. Or use os.stat . From john106henry at hotmail.com Wed Apr 2 16:01:00 2008 From: john106henry at hotmail.com (John Henry) Date: Wed, 2 Apr 2008 13:01:00 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> Message-ID: <58deb8b8-bae9-4d43-b973-3d90846726cb@b5g2000pri.googlegroups.com> On Apr 1, 11:10 am, sprad wrote: > On Apr 1, 11:41 am, mdomans wrote: > > > Python needs no evangelizing but I can tell you that it is a powerfull > > tool. I prefer to think that flash is rather visualization tool than > > programing language, and java needs a lot of typing and a lot of > > reading. On the other hand python is simple to read and write, can be > > debuged easily, is intuitive and saves a lot of time. It also supports > > batteries included policy and you can't get more OO than python. > > One advantage of Flash is that we can have something moving on the > screen from day one, and add code to it piece by piece for things like > keyboard or mouse control, more and more complex physics, etc. Is > there an equivalent project in Python? I downloaded the "How to Think Like a Python Programmer" book and read it. I think it's a fine reference book for the purpose you indicated. Here's my 2 cents on the subject. I had been a volunteer mentor to my son's middle school robotic team for several years and I have some experiences, therefore, in how kids react to "programming". Granted, high school kids are "bigger kids" - but they are kids nevertheless. Last summer, I experimented teaching my own kid Python. He was in 7th grade going onto 8th grade. He was the main goto person for the robotic team and had no trouble learning the common applications such as the Microsoft Office suite, and had some experience in ICONic programming (Lego Mindstorm). So, I tried to see what would happen if he tries to learn Python - using somewhat similar approach you are taking: start with something visually appealing on day one. Instead of Flash, I used Pythoncard - a no-brainer Python GUI construction toolkit. He was really excited seeing how easy it was to have tic-tae- toe type program up so easily (we are taking minutes - not hours) and was very interested and motivated to continue. So far so good. However, once I start teaching him variables, expressions, loops, and what not, I found that (by surprise) he had great difficulties catching on. Not soon after that, we had to quit. We - as adults - take many things for granted and sometimes don't remember, or don't understand how kids learn. My experience tells me that in order to teach today's video game generation of kids, the approach really has to be entirely visual. After I abandoned my attempt to teach my kid Python, I started them on Robolab - a simplified version of LabView and to my delight, they were able to cook up a few simple programs (like fibonacci series and so forth) without too much effort - although my own kid had some minor trouble understanding the concept of a container (LabView's version of a variable). I don't know if you have access to LabView or Robolab or similar packages but if you do, I would highly recommend those. LabView is every bit as powerful, full-featured, and "real-life" as many of the other languages and I believe that kids will have a much easier time learning computer programming with it. And you are going to teach them Java? Oh, please don't. Let the colleges torture them. :=) From spe.stani.be at gmail.com Tue Apr 29 07:38:56 2008 From: spe.stani.be at gmail.com (SPE - Stani's Python Editor) Date: Tue, 29 Apr 2008 04:38:56 -0700 (PDT) Subject: Learn python packaging for Ubuntu and Debian in the Ubuntu Open Week Message-ID: Hi All, If you wrote some python code that you want to package or know a cool python application of which you like to make a deb installer, the python packaging session is all for you! Do you develop some cross- platform open source software and you want to give its popularity a boost by bringing it to Ubuntu and Debian, read on! (Packages are what installers are for Windows.) This session will be hosted by the respected Emilio (pochu). I've worked closely together with him (and others of the Debian PAPT team like POX & ScottK) to make sure these packages landed well in Ubuntu Hardy and Debian Unstable: - Phatch (sudo apt-get install phatch, http://photobatch.stani.be) - SPE (sudo apt-get install spe, http://pythonide.stani.be) I've requested this session as I found there was almost no information available tailored for python coders. I hope many people will attend. The logs will be available here: https://wiki.ubuntu.com/MeetingLogs/openweekhardy/PythonPackaging The complete program of the Ubuntu Open Week is available here: https://wiki.ubuntu.com/UbuntuOpenWeek Feel free to comment or questions ahead of this session on this thread. I am sure Emilio will read this thread. See you there! Stani From lbonafide at yahoo.com Mon Apr 14 08:01:33 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Mon, 14 Apr 2008 05:01:33 -0700 (PDT) Subject: Java or C++? References: Message-ID: On Apr 14, 1:44?am, s0s... at gmail.com wrote: > Hello, I was hoping to get some opinions on a subject. I've been > programming Python for almost two years now. Recently I learned Perl, > but frankly I'm not very comfortable with it. Now I want to move on > two either Java or C++, but I'm not sure which. Which one do you think > is a softer transition for a Python programmer? Which one do you think > will educate me the best? It depends on your reasons for learning either. If you're targeting a specific job market, find out what is prevelant in that market. And keep in mind that if it's for a job, you'll also have to get up to speed on the relevant libraries and frameworks. If it's educational, I'd recommend C++ just to learn about pointers and memory management, so you get a better idea of what's going on under the covers in languages like Java and Python and Ruby and C#. From sanhitam at yahoo.com Thu Apr 10 13:05:59 2008 From: sanhitam at yahoo.com (Sanhita Mallick) Date: Thu, 10 Apr 2008 10:05:59 -0700 (PDT) Subject: Graphs in Python Message-ID: <531651.98983.qm@web55601.mail.re4.yahoo.com> Hi. I am a newbie to Python. I am trying to implement a Python code for graph manipulation. My graphs are about 200-500 nodes big. Excepting for the short basic graph implementation info on Python.org, where can I find more in depth info about how to express graphs in python, and how to use them in a code? Also, does anyone know of a easy way of creating the dictionary for python for a 500-node graph, without typing each and every node? I found some application that recognize dot file Graphviz - but I am looking for a program that can let me "draw" a graph and then generate the lists automatically from the drawing. Thanks. -SM From charleshixsn at earthlink.net Sat Apr 12 19:33:44 2008 From: charleshixsn at earthlink.net (Charles D Hixson) Date: Sat, 12 Apr 2008 16:33:44 -0700 Subject: class level properties In-Reply-To: References: Message-ID: <480146D8.5010506@earthlink.net> Arnaud Delobelle wrote: > On Apr 12, 8:36 pm, Charles D Hixson > wrote: > >> I'm trying to construct read-only variables at the class level. I've >> been unsuccessful. Any suggestions? >> >> Mixing @classmethod and @property doesn't appear to produce workable >> code. Ditto for mixing @classmethod and __getattr__. (The property >> approach compiles, but execution says that you can't execute properties.) >> >> I've got a rather large number of variables, so I don't want to define >> function accessors for each of them, and I *REALLY* don't want to have >> to access them as functions rather than variables or properties. >> > > Metaclasses, of course! > > >>>> class MetaX(type): >>>> > ... @property > ... def spam(self): return 'eggs' > ... > >>>> class X(object): >>>> > ... __metaclass__ = MetaX > ... > >>>> X.spam >>>> > 'eggs' > > > HTH > > -- > Arnau Thanks. I can make that work. Is it possible to move the entire implementation of the interpretation of _valueMap, below, into properties in some similar way? I'm referring to the part managed by __getattr__ below. I want a hundred or so read-only variables, and I'm not sure the best way to achieve it. class MetaROVars(type): @property def simple(self): return "simple example working" class test(object): __metaclass__ = MetaROVars _valueMap = { "t1" : (3, "Concept decay rate", "[1, 99]"), "t2" : (10, "TaskLink decay rate", "[1, 99]"), } #@classmethod def __getattr__(self, name): if name not in test._valueMap: raise AttributeError, name return test._valueMap[name][0] def describe (self, name): if name not in test._valueMap: raise AttributeError, name return test._valueMap[name][1] + ", lying in the range " + test._valueMap[name][2] p = test() print p.t1 print p.describe("t1") print p.t2 print test.simple From nagle at animats.com Fri Apr 4 11:25:17 2008 From: nagle at animats.com (John Nagle) Date: Fri, 04 Apr 2008 08:25:17 -0700 Subject: Is there an official way to add methods to an instance? In-Reply-To: <47f61041$0$27969$426a34cc@news.free.fr> References: <7xve2yas87.fsf@ruckus.brouhaha.com> <47f61041$0$27969$426a34cc@news.free.fr> Message-ID: <47f645e6$0$36354$742ec2ed@news.sonic.net> Bruno Desthuilliers wrote: > Paul Rubin a ?crit : >> Brian Vanderburg II writes: >>> I've checked out some ways to get this to work. I want to be able to >>> add a new function to an instance of an object. >> >> Ugh. Avoid that if you can. > > Why so ? OO is about objects, not classes, and adding methods on a > per-object basis is perfectly legitimate. It's what professional programmers call a "l33t feature", one not suitable for production code. Typically such features are used by programmers with about two years experience, trying too hard to prove that they're cool. John Nagle From jcd at sdf.lonestar.org Fri Apr 18 11:43:09 2008 From: jcd at sdf.lonestar.org (J. Cliff Dyer) Date: Fri, 18 Apr 2008 11:43:09 -0400 Subject: Python-list Digest, Vol 55, Issue 296 In-Reply-To: References: Message-ID: <1208533389.4748.11.camel@aalcdl07.lib.unc.edu> On Fri, 2008-04-18 at 17:25 +0200, python-list-request at python.org wrote: > I really like developing in Python -- but it's hard > to keep doing it when the growth curve is so slow > and a so many people have deep reservations about it, > inspired in part, justifiably, by nonsense like this. > In fact, I basically stopped. Then I came back. Now > I'm wondering if it was such a good idea... > > -- Aaron Watters >From what I've read, the slowness of the growth curve was actually one of the major issues that prompted the Py3K push in the first place. The accumulated cruft had gotten heavy, and was slowing python down. Py3K is deliberately conservative, so that the transition will be as painless as possible, but strips away the warts that were slowing things down. Having print as a statement meant it was difficult to add functionality there. Supporting both new and old style classes meant that you couldn't count on expected functionality in external libraries. The string/unicode dichotomy caused innumerable headaches for everybody. The big changes you are hoping for to justify py3k won't come in python 3.0. They'll come in python 3.2 and python 3.3. Of course, I'm well aware that I'm talking about vaporware, but making the architectural changes now to make that advancement possible in the future is the point of python 3.0. In the meantime, your code will always work on Python 2.5. If you're worried about wild code, bundle it with its own interpreter when you distribute it. It'll survive. Cheers, Cliff From medin0065 at gmail.com Sun Apr 20 10:47:16 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:47:16 -0700 (PDT) Subject: xbox patch Message-ID: <4b32d9dc-6030-4439-8b5d-779a46e82acd@s33g2000pri.googlegroups.com> xbox patch http://cracks.00bp.com F R E E C R A C K S From skanemupp at yahoo.se Sun Apr 13 09:52:06 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 13 Apr 2008 06:52:06 -0700 (PDT) Subject: py2exe, program has stoped working!? Message-ID: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> so i used py2exe and i have the build and the dist-folders. in the distfolder there is a Calculator.exe file. when i run it it just says "Calculator.exe has stopped working" in a popup but the program itself never shows up. wtf!? and when im distributing my program i have to include both catalogues right? From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 24 07:28:09 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 24 Apr 2008 13:28:09 +0200 Subject: help needed with classes/inheritance In-Reply-To: <676bac37-2816-402b-9aed-1a9c1873351b@a23g2000hsc.googlegroups.com> References: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> <480f05d0$0$25755$426a74cc@news.free.fr> <676bac37-2816-402b-9aed-1a9c1873351b@a23g2000hsc.googlegroups.com> Message-ID: <48106eb5$0$21323$426a74cc@news.free.fr> barbaros a ?crit : > On Apr 23, 10:48 am, Bruno Desthuilliers 42.desthuilli... at websiteburo.invalid> wrote: > >>> My question is: can it be done using inheritance ? >> Technically, yes: >> >> class OrientedBody(Body): >> def __init__(self, orient=1): >> Body.__init__(self) >> self.orient = 1 >> >> Now if it's the right thing to do is another question... > > If I understand correctly, in the above implementation I cannot > define firstly a (non-oriented) body, and then build, on top of it, > two bodies with opposite orientations. The point is, I want > both oriented bodies to share the same base Body object. Then it's not a job for inheritence, but for composition/delegation - Sorry but I didn't get your specs quite right :-/ Now the good news is that Python makes composition/delegation close to a no-brainer: class Body(object): # definitions here class OrientedBody(object): # notice that we *dont* inherit from Body def __init__(self, body, orient): self._body = body self.orient = orient def __getattr__(self, name): try: return getattr(self._body, name) except AttributeError: raise AttributeError( "OrientedBody object has no attribute %s" % name ) def __setattr__(self, name, val): # this one is a bit more tricky, since you have # to know which names are (or should be) bound to # which object. I use a Q&D approach here - which will break # on computed attributes (properties etc) in the Body class - # but you can also define a class attribute in either Body # or OrientedBody to explicitly declare what name goes where if name in self._body.__dict__: setattr(self._body, name, val) else: object.__setattr__(self, name, value) From grahn+nntp at snipabacken.se Thu Apr 3 16:15:16 2008 From: grahn+nntp at snipabacken.se (Jorgen Grahn) Date: 3 Apr 2008 20:15:16 GMT Subject: Pexpect question. References: Message-ID: On Wed, 02 Apr 2008 19:57:31 -0600, Paul Lemelle wrote: > Jorgen, > > Thanks for your reply. > > The ssh function is just a small part of what I would like to > accomplish. And yes, chk is undefined, I was trying to figure out why > control was not being returned from the sshcon funciton. OK. Hope my note helped. > I looked for pexpect doucment on http://www.noah.org/wiki/Pexpect, but > the documentaiton link appear to be broken. Could you recommend > another site? As I recall it, the online documentation is just the documentation from the Python module itself, HTML-formatted. You can simply type "pydoc pexpect" and get the reference manual. I think it's pretty good. /Jorgen -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! From bignose+hates-spam at benfinney.id.au Tue Apr 15 19:23:33 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Wed, 16 Apr 2008 09:23:33 +1000 Subject: How to have unittest tests to be executed in the order they appear? References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> Message-ID: <87zlru7le2.fsf@benfinney.id.au> "Giampaolo Rodola'" writes: > Is there a way to force unittest to run test methods in the order > they appear? No, and this is a good thing. Your test cases should *not* depend on any state from other test cases; they should function equally well when executed in any arbitrary sequence. Dependencies between separate test cases (e.g. "they only work correctly when run in a specific sequence") means you're not isolating them properly. Use the TestCase.setUp and TestCase.tearDown methods to handle any fixtures needed by test cases in each class of test cases. That way, the fixtures will be set up and torn down between every test case. Find out about test fixtures in the documentation for unittest . -- \ "All my life I've had one dream: to achieve my many goals." -- | `\ Homer, _The Simpsons_ | _o__) | Ben Finney From mdw at distorted.org.uk Thu Apr 17 13:30:21 2008 From: mdw at distorted.org.uk (Mark Wooding) Date: Thu, 17 Apr 2008 17:30:21 +0000 (UTC) Subject: Integer dicision References: <5f499bee-a659-4e36-870c-076cb613a3e7@t12g2000prg.googlegroups.com> Message-ID: bdsatish wrote: > How does (a/b) work when both 'a' and 'b' are pure integers ? > >>> (9/2) > 4 > >>> (-9/2) > -5 > > Why is it -5 ? I expect it to be -4 ? Because, in C/C++, 9/2 is 4 and > so negative of it, (-9/2) is -4. Some background on the situation: Integer division and remainder operators have to satisfy two axioms: y * (x/y) + x%y = x and |x%y| < |y| (The former is just the definition of remainder, and the latter is necessary to get Euclid's algorithm to work.) When x and y are both nonnegative it's easy to agree on the right behaviour. When x or y is negative then we get conflicting requirements. On the one hand, you get people who expect that (-x)/y == -(x/y). On the other hand, you get people who expect 0 <= x%y < y if y >= 0. Unfortunately, you can't have both and still satisfy the integer- division axioms. C89 didn't specify which behaviour you got. C99 is in the first camp. Python picked the second (long before C99 came out). Which is right? I don't think that's actually a well-posed question: both have uses. I certainly find myself using the latter behaviour (floor, or round towards -infinity) almost exclusively, but then I'm mainly doing number theory and cryptography, and I find the bounds on the remainder very convenient. Heedful of this mess, Common Lisp provides four (!) different integer division functions (in addition to `/', which does exact rational division on integers): * (floor X Y) -> Q R, where Q is the largest integer such that Q <= X/Y, and R = X - Q Y; R is also available as (mod X Y). * (ceiling X Y) -> Q R, where Q is the smallest integer such that Q >= X/Y, and R = X - Q Y. * (truncate X Y) -> Q R, where Q is the integer with the greatest magnitude such that Q has the same sign as X/Y (or is zero) and |Q| <= |X/Y|; again R = X - Q Y; R is also available as (rem X Y). * (round X Y) -> Q R, where Q is the nearest integer to X/Y (rounding ties towards even numbers), and R = X - Q Y. Gluing all this into Python is tricky, partly because the plethora of options seems somewhat unPythonic (at least to me), and partly because it relies on Common Lisp's behaviour of throwing away unwanted additional return values. > What should I do to get C-like behavior ? I would have said abs(x) / abs(y) * sgn(x) * sgn(y) but Python doesn't seem to have a signum function. :-( I'd recommend thinking carefully about your problem and seeing whether the existing floor-divide behaviour can't be made to fit (or indeed if it's not actually better anyway). If that still doesn't help then you'll have to solve the problem the hard way. def trunc_divmod(x, y): """ Return truncating quotient and remainder for X/Y. Assumes Y > 0. """ q, r = divmod(x, y) if x < 0 and r != 0: r -= y q += 1 return q, r -- [mdw] From spam-trap at telus.net Wed Apr 30 21:23:06 2008 From: spam-trap at telus.net (L. Lindstrom) Date: Thu, 01 May 2008 01:23:06 GMT Subject: Python 2.6 and wrapping C libraries on Windows In-Reply-To: References: Message-ID: <_X8Sj.3499$XI1.3261@edtnps91> Christian Heimes wrote: > L. Lindstrom schrieb: >> I have read that Python extension modules must link to the same C >> run-time as the Python interpreter. This I can appreciate. But does this >> requirement extend to the C libraries an extension module wraps. The >> case in point is Pygame and SDL. The Pygame extension modules are built >> with distutils, so for Python 2.6 using Visual Studio 2008 should ensure >> the .pyd files link to msvcr90.dll. But SDL is built using Msys/MinGW >> and the configure/make tool chain. This fails when linking to >> msvcr90.dll since the small test programs configure builds lack manifest >> files. They fail to load msvcr90.dll, raising an R6034 error instead. So >> besides heap management and FILE pointers, is there any reason SDL, or >> any C dependency, needs to link to the same C run-time as Python? If I >> ensure SDL frees memory it allocates and does not directly access a file >> opened by Python can I just use another C run-time such as msvcrt? >> > > Your analysis of the problem and the implication of mixing CRTs is > correct. However ... > > It should be trivial to modify the build systemof SDL so that the > manifest is integrated into the DLLs. Everything else is a hack. It > *should* work and in reality it *does* work for most cases. But someday > you'll hit a solid wall and get strange and hard to debug segfaults. > > It's in your own interest to get it right in the first place. And you'd > serve the Python community greatly by providing a nice tutorial how to > modify 3rd party builds. *hint* :) > > If you need any help feel free to contact me. The new build system is > mostly my work with help from Martin, Amaury and other core developers. > > Christian > Linking to msvcr90.dll is possible with MinGW. The problem is with the configure scripts. So I can run configure against msvcrt.dll, then switch to mscvr90.dll for make. If this works I will make SDL and a test program available on-line so someone can find the appropriate manifests. -- Lenard Lindstrom "%s@%s.%s" % ('len-l', 'telus', 'net') From aaron.watters at gmail.com Fri Apr 11 15:22:06 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Fri, 11 Apr 2008 12:22:06 -0700 (PDT) Subject: Profiling programs/scripts? References: Message-ID: <54e80efc-39b5-4a2b-9e01-d9b6d70ebaed@a23g2000hsc.googlegroups.com> On Apr 11, 2:49 pm, skanem... at yahoo.se wrote: > how do i profile a program? i found out that there are some profilers > included in the standard library but couldnt really figure out how to > access/use them I put this at the bottom of my main module: === cut if __name__=="__main__": try: from cProfile import run except: from profile import run run("tests()") === cut Here tests() is the function I want to profile. The cProfile module, when available is better than the older profile module, but it's only available in very recent Python installations. The profile "run" function will run the tests function and print a report on the timings and counts it found. More info here: http://docs.python.org/lib/profile.html -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=emulate+perl From bbxx789_05ss at yahoo.com Tue Apr 1 19:25:28 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Tue, 1 Apr 2008 16:25:28 -0700 (PDT) Subject: BeautiflSoup -- getting all the attributes of a tag? Message-ID: You can treat a tag like a dictionary to obtain a specific attribute: import BeautifulSoup as bs html = "
hello
" doc = bs.BeautifulSoup(html) div = doc.find("div") print div print div["x"] --output:-- a But you can't iterate over a tag to get all the attributes: import BeautifulSoup as bs html = "
hello
" doc = bs.BeautifulSoup(html) div = doc.find("div") for key in div: print key, div[key] --output:-- hello Traceback (most recent call last): File "test1.py", line 9, in ? print key, div[key] File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ python2.4/site-packages/BeautifulSoup.py", line 430, in __getitem__ return self._getAttrMap()[key] KeyError: u'hello' How can you get all the attributes when you don't know the attribute names ahead of time? From michael at stroeder.com Fri Apr 25 08:06:36 2008 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Fri, 25 Apr 2008 14:06:36 +0200 Subject: python-ldap - Operations Error In-Reply-To: References: Message-ID: theiviaxx at gmail.com wrote: > Thanks for the help guys, it works! I used the > ldap.set_option(ldap.OPT_REFERRALS, 0) from http://peeved.org/blog/2007/11/20/ Hmm, maybe I should generally switch off referral chasing in python-ldap forcing applications to enable it if needed overriding libldap's default. I did this already for LDAPObject.protocol_version where libldap's default is LDAPv2 and python-ldap sets it to LDAPv3 in LDAPObject.__init__(). Although this was an incompatible change no-one complained. > immedialtey after import, then did the initialize trace_level=2 and > did the simple_bind_s. I was able to search and get the results. > That trace_level thing is nice, i'm sure i will be debugging this more > as i move forward :) > > Not sure if this is an AD thing or just something i needed to do with > our particular server/config. Basically the concept of LDAPv3 referrals is broken since there's no concept for specifying how to bind to the referral's target without a-priori local configuration. See also an old posting to news:microsoft.public.windows.server.active_directory related to this: http://groups.google.com/group/microsoft.public.windows.server.active_directory/msg/d061e0398cc366a5 Ciao, Michael. From matthieu.brucher at gmail.com Thu Apr 10 15:28:56 2008 From: matthieu.brucher at gmail.com (Matthieu Brucher) Date: Thu, 10 Apr 2008 21:28:56 +0200 Subject: Graphs in Python In-Reply-To: <531651.98983.qm@web55601.mail.re4.yahoo.com> References: <531651.98983.qm@web55601.mail.re4.yahoo.com> Message-ID: Hi, Did you try packages dedicated to graphs, like NetworkX ? Matthieu 2008/4/10, Sanhita Mallick : > > Hi. > > I am a newbie to Python. I am trying to implement a > Python code for graph manipulation. My graphs are > about 200-500 nodes big. Excepting for the short basic > graph implementation info on Python.org, where can I > find more in depth info about how to express graphs in > python, and how to use them in a code? > > Also, does anyone know of a easy way of creating the > dictionary for python for a 500-node graph, without > typing each and every node? I found some application > that recognize dot file Graphviz - but I am looking > for a program that can let me "draw" a graph and then > generate the lists automatically from the drawing. > > Thanks. > -SM > > -- > http://mail.python.org/mailman/listinfo/python-list > -- French PhD student Website : http://matthieu-brucher.developpez.com/ Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92 LinkedIn : http://www.linkedin.com/in/matthieubrucher -------------- next part -------------- An HTML attachment was scrubbed... URL: From arnodel at googlemail.com Sun Apr 27 14:52:35 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 27 Apr 2008 19:52:35 +0100 Subject: Mapping and Filtering Help for Lists References: <16925836.post@talk.nabble.com> Message-ID: Zethex writes: > Thank you a lot! > > Another quick couple of questions. > > How can i make it so it removes special operators such as ? ! or doesnt > include them? As you are doing lots of string manipulations, I advise you to read the section of the python documentation on strings (link below). This way you will get a good idea of what can be done out of the box with strings in python. http://docs.python.org/lib/string-methods.html (Or type help(str) from the interactive prompt) For the particular task of removing a character, you may be interested in the replace() method. > and > > I need to lowercase the words so should i use sentence = sentence.lower()? Yes. Or you could combine the two by using the translate() method. E.g. >>> table = ''.join(chr(c).lower() for c in range(256)) >>> 'You! are Free??'.translate(table, '!?') 'you are free' HTH -- Arnaud From brianc at temple.edu Tue Apr 8 21:19:19 2008 From: brianc at temple.edu (Brian Cole) Date: Tue, 8 Apr 2008 19:19:19 -0600 Subject: Python Leopard DLL Hell Message-ID: <54b165660804081819g4787f4d9g821c7269af7b4c66@mail.gmail.com> Hello All, I'm running into a strange problem on Leopard with how Python loads shared libraries. I'll give you a background of what we are trying to accomplish before describing the problem. I am not certain whether this is an OS X problem, or a Python problem, though it appears with the combination of the two. We have swig wrapped C++ code. We used to require our users to set LD_LIBRARY_PATH to the directory containing the dynamic libraries because the swig generated .so needs to dynamically link in another .so. The dependency tree looks like the following: foo.py <--- performs a "from libs import _foo" libs/ <--- LD_LIBRARY_PATH required to point here | _foo.so | bar.so <-- _foo.so depends on me The dependency of bar.so can be taken care of by using $ORIGIN with -rpath (http://linuxreviews.org/man/ld.so/). On Mac OS X this is done by post-processing the shared library with install_name_tool (http://lapcatsoftware.com/blog/2007/08/11/embedding-frameworks-in-loadable-bundles/). Another design goal was to allow for the same directory structure to be NFS mounted in a heterogeneous environment. Then the magic of Python can choose the proper .so to load based upon introspection of the machine architecture and the Python version being used. So the directory structure becomes: foo.py <--- performs a "from libs import GetModule; _foo = GetModule('_foo')" libs/ | __init__.py <--- contains code for GetModule | arch-specific-directory/ | _foo.so | bar.so <-- _foo.so depends on me The GetModule function defined in libs/__init__.py looks like the following: DLLS = os.path.join(os.path.basename(__file__), "arch-specific-directory") <-- determined at runtime based on platform, compiler, and python version def GetModule(name): args = imp.find_module(name, [DLLS]) return imp.load_module(name, *args) This works great on Linux. LD_LIBRARY_PATH can even be set to a directory that contains a different (incompatible) _foo.so and python will force the correct .so to be loaded. However, there is a bug on OS X Leopard (maybe Tiger too, I haven't tested it). On OS X, when DYLD_LIBRARY_PATH (the OS X equivalent of LD_LIBRARY_PATH) is set to a directory that contains an identically named .so file imp.load_module pulls that .so file in. Even though the .so has been specified by an absolute filename. Running a simple test with the -v option of python shows the following: coleb at shark~/debug/wrappers/python$ ls -1 $DYLD_LIBRARY_PATH _foo.so bar.so coleb at shark~/debug/wrappers/python$ python -vc "import openeye.oeshape; from time import sleep; sleep(10)" Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. # foo.pyc matches foo.py import foo # precompiled from foo.pyc import libs # directory libs # libs/__init__.pyc matches libs/__init__.py import libs # precompiled from libs/__init__.pyc dlopen("/Users/coleb/debug/wrappers/python/openeye/libs/osx-10.5-g++4.0-x86+x64-python2.5/_foo.so", 2); <--- This is the correct .so! import _foo # dynamically loaded from /Users/coleb/debug/wrappers/python/openeye/libs/osx-10.5-g++4.0-x86+x64-python2.5/_foo.so That appears to be working correctly at first glance. The argument to dlopen is the correct shared library. Unfortunately, either python or OS X is lying to me here. If I inspect the python process with OS X's Activity Monitor and look at the "Open Files and Ports" tab, it shows that the _foo.so shared library is actually the one located inside $DYLD_LIBRARY_PATH. So this problem may not be python's, but I place it here as a first shot (maybe I'm using the imp module incorrectly). Thanks, Brian From kinch1967 at gmail.com Sun Apr 27 12:35:21 2008 From: kinch1967 at gmail.com (bullockbefriending bard) Date: Sun, 27 Apr 2008 09:35:21 -0700 (PDT) Subject: design choice: multi-threaded / asynchronous wxpython client? References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> <002cd046-f11d-482e-a67d-4a10a97687a1@x19g2000prg.googlegroups.com> Message-ID: <708eaa6d-3893-407e-83ec-4e6104b0a130@q24g2000prf.googlegroups.com> On Apr 27, 11:12?pm, Jorge Godoy wrote: > bullockbefriending bard wrote: > > A further complication is that at a later point, I will want to do > > real-time time series prediction on all this data (viz. predicting > > actual starting prices at post time x minutes in the future). Assuming > > I can quickly (enough) retrieve the relevant last n tote data samples > > from the database in order to do this, then it will indeed be much > > simpler to make things much more DB-centric... as opposed to > > maintaining all this state/history in program data structures and > > updating it in real time. > > If instead of storing XML and YAML you store the data points, you can do > everything from inside the database. > > PostgreSQL supports Python stored procedures / functions and also support > using R in the same way, for manipulating data. ?Then you can work with > everything and just retrieve the resulting information. > > You might try storing the raw data and the XML / YAML, but I believe that > keeping those sync'ed might cause you some extra work. Tempting thought, but one of the problems with this kind of horse racing tote data is that a lot of it is for combinations of runners rather than single runners. Whilst there might be (say) 14 horses in a race, there are 91 quinella price combinations (1-2 through 13-14, i.e. the 2-subsets of range(1, 15)) and 364 trio price combinations. It is not really practical (I suspect) to have database tables with columns for that many combinations? I certainly DO have a horror of having my XML / whatever else formats getting out of sync. I also have to worry about the tote company later changing their XML format. From that viewpoint, there is indeed a lot to be said for storing the tote data as numbers in tables. From Ming.YIN at murex.com Wed Apr 16 06:47:19 2008 From: Ming.YIN at murex.com (YIN Ming) Date: Wed, 16 Apr 2008 18:47:19 +0800 Subject: Compilation problem of Python2.5.1 on AIX5.2 (with --enable-shared option) Message-ID: <9347F3EEF61FC542A7D9211A42CD7E6387DF3F@dolphin.sg.murex.com> Dear All, I encountered a problem when compiling Python2.5.1 as shared library on AIX5.2. Your help are greatly appreciated. In order to embed python into our product, we want to compile python as shared library. It works for Solaris and Linux. Unfortunately, It is for AIX and I could not find solution from Web. Could you help answer the following questions: Is it feasible to compile python2.5.1 as shared library for AIX5.2? or where can I find relevant documentation/info for this? So far, the only documents I have are the README and Misc/AIX-NOTES in the source distribution The step I tried to compile python as shared library is to follow README, section "Building a shared libpython", which suggests to add --enable-shared during configuration. My problem is that with --enable-shared, the make step could not complete (the error message shows it tries to refer to "-lpython2.5" in a wrong directory). Then if I refer it to the correct directory (which is compiled in source root), some warning messages show duplicated symbols. And finally I just remove "-lpython2.5", the make could finish but the resulting python interpreter is a statically-linked binary. (The detail is shown below). The detail of my compilation 1. CC="cc_r" ./configure --prefix=/src/new/python2/install --without-gcc --disable-ipv6 --enable-shared 2. make CC="cc_r" OPT="-O -qmaxmem=4000" An error occurred when compiling python extensions. ... running build running build_ext INFO: Can't locate Tcl/Tk libs and/or headers building '_struct' extension creating build ... cc_r -DNDEBUG -O -I. -I/vega5/prod/src/new/python2/Python-2.5.1/./Include -I./In clude -I. -I/usr/local/include -I/vega5/prod/src/new/python2/Python-2.5.1/Includ e -I/vega5/prod/src/new/python2/Python-2.5.1 -c /vega5/prod/src/new/python2/Pyth on-2.5.1/Modules/_struct.c -o build/temp.aix-5.2-2.5/vega5/prod/src/new/python2/ Python-2.5.1/Modules/_struct.o creating build/lib.aix-5.2-2.5 ./Modules/ld_so_aix cc_r -bI:Modules/python.exp build/temp.aix-5.2-2.5/vega5/pro d/src/new/python2/Python-2.5.1/Modules/_struct.o -L/usr/local/lib -lpython2.5 -o build/lib.aix-5.2-2.5/_struct.so ld: 0706-006 Cannot find or open library file: -l python2.5 ld:open(): No such file or directory *** WARNING: renaming "_struct" since importing it failed: No such file or directory error: No such file or directory make: The error code from the last command is 1. The highlighted command tries to locate the pyhton2.5 lib in /usr/local/lib, which obviously does not contain this lib. A library, libpython2.5.a, has already been compiled in the root build directory. 1) First, I try to add "-L." to the command ./Modules/ld_so_aix cc_r -bI:Modules/python.exp build/temp.aix-5.2-2.5/vega5/prod/src/new/python2/Python-2.5.1/Modules/_ struct.o -L/usr/local/lib -L. -lpython2.5 -o build/lib.aix-5.2-2.5/_struct.so It could find but with a lot of warning messages like: ld: 0711-224 WARNING: Duplicate symbol: PyObject_GenericGetAttr ld: 0711-224 WARNING: Duplicate symbol: .PyObject_GenericGetAttr ld: 0711-224 WARNING: Duplicate symbol: ._Py_ReadyTypes ... 2) Second, I try to remove "-L/usr/local/lib -lpython2.5" from the command ./Modules/ld_so_aix cc_r -bI:Modules/python.exp build/temp.aix-5.2-2.5/vega5/prod/src/new/python2/Python-2.5.1/Modules/_ struct.o -o build/lib.aix-5.2-2.5/_struct.so It complete without any warning message. As a result, I filter out all "-lpython2.5" passed to ./Modules/ld_so_aix for the rest commands. In this way, the python interpreter was generated. However, it is a big executable and "ldd python" does not show it depends on any python shared library (It seems no shared python library generated). It has no difference from the one compiled without --enable-shared. Note that if the configuration is run without --enable-shared option, the corresponding commands will not contain "-lpython2.5". Best regards, Yin Ming -------------------------------------------------------- This e-mail contains information for the intended recipient only. It may contain proprietary material or confidential information. If you are not the intended recipient you are not authorised to distribute, copy or use this e-mail or any attachment to it. Murex cannot guarantee that it is virus free and accepts no responsibility for any loss or damage arising from its use. If you have received this e-mail in error please notify immediately the sender and delete the original email received, any attachments and all copies from your system. -------------- next part -------------- An HTML attachment was scrubbed... URL: From maxm at mxm.dk Thu Apr 3 18:44:56 2008 From: maxm at mxm.dk (Max M) Date: Fri, 04 Apr 2008 00:44:56 +0200 Subject: expanding a variable to a dict In-Reply-To: References: Message-ID: <47F55DE8.7090406@mxm.dk> idle skrev: > now I'd like to check them all for the existence of certain default > keys; ie, if the dicts don't contain the keys, add them in with > default values. > > so, I've got: > > for a in ['dictFoo','dictBar','dictFrotz']: > if hasattr(a,'srcdir') == False: > a['srcdir']='/usr/src' There are a few ways to do it. for a in ['dictFoo','dictBar','dictFrotz']: if not a.has_key('srcdir'): a['srcdir'] = '/usr/src' for a in ['dictFoo','dictBar','dictFrotz']: if not 'srcdir' in a: a['srcdir'] = '/usr/src' for a in ['dictFoo','dictBar','dictFrotz']: a.setdefault('srcdir') = '/usr/src' -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science From sunsp1der at yahoo.com Fri Apr 4 21:47:47 2008 From: sunsp1der at yahoo.com ($P!D3R DelSol) Date: Fri, 4 Apr 2008 18:47:47 -0700 (PDT) Subject: Pickle to Source - Gabriel Genellina? Message-ID: <163089.29394.qm@web65515.mail.ac4.yahoo.com> Hello I found this 3 year old message asking about doing the same exact thing I am trying to do. This is one wheel I REALLY don't want to re-invent. Can anyone point me to code that does this? Thanks Ivan ( sunsp1der at yahoo dot com) > I want to convert from pickle format to python source code. That is, > given an existing pickle, I want to produce a textual representation > which, when evaluated, yields the original object (as if I had > unpickled the pickle). > I know of some transformations pickle/xml (Zope comes with one such > tool, gnosis xml is another) so I believe I could build something based > on them. > But I dont want to reinvent the wheel, I wonder if anyone knows of a > library which could do what I want? An example to make things clear: class MyClass: def __init__(self,a,b): self.a=a self.b=b def foo(self): self.done=1 # construct an instance and work with it obj = MyClass(1,2) obj.foo() # save into file pickle.dump(obj,file('test.dat','wb')) Then, later, another day, using another process, I read the file and want to print a block of python code equivalent to the pickle saved in the file. That is, I want to *generate* a block of code like this: xxx = new.instance(MyClass) xxx.a = 1 xxx.b = 2 xxx.done = 1 Or perhaps: xxx = new.instance(MyClass, {'a':1,'b':2,'done':1}) In other words, I need a *string* which, being sent to eval(), would return the original object state saved in the pickle. As has been pointed, repr() would do that for simple types. But I need a more general solution. The real case is a bit more complicated because there may be references to other objects, involving the persistent_id mechanism of pickles, but I think it should not be too difficult. In this example, if xxx.z points to another external instance for which persistent_id returns '1234', would suffice to output another line like: xxx.z = external_reference('1234') I hope its more clear now. Thanks, Gabriel Genellina Softlab SRL ///\*_*/\\\ NOTICE: Empowered by Presidential Executive Orders, the National Security Agency may read this email without warning, warrant, or notice. The NSA may do this without any judicial or legislative oversight. The President also claims the right to designate the sender or the reader as an enemy combatant and to imprison him/her indefinitely without access to legal counsel or anyone else, and to be "rendered" to a foreign government for possible torture or death. ____________________________________________________________________________________ You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost. http://tc.deals.yahoo.com/tc/blockbuster/text5.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdw at distorted.org.uk Tue Apr 22 13:28:56 2008 From: mdw at distorted.org.uk (Mark Wooding) Date: Tue, 22 Apr 2008 17:28:56 +0000 (UTC) Subject: [Python 2.4/2.5] subprocess module is sorely deficient? References: Message-ID: Nick Craig-Wood wrote: > Harishankar wrote: >> 1. Create non-blocking pipes which can be read in a separate thread >> [...] > > You are correct on both of those points. I must be missing something. What's wrong with spawning the subprocess with subprocess.Popen as usual, passing subprocess.PIPE as stdin/stdout/ whatever, making your end nonblocking with fcntl.fcntl and then using os.read/os.write in the obvious ways? -- [mdw] From liveplayboyworld at gmail.com Mon Apr 14 20:16:28 2008 From: liveplayboyworld at gmail.com (liveplayboyworld at gmail.com) Date: Mon, 14 Apr 2008 17:16:28 -0700 (PDT) Subject: the best site about girl & boy. have alook... Message-ID: <2e869a77-80b4-4cf2-80ac-7bee65cab1d7@b9g2000prh.googlegroups.com> http://www.liveplayboyworld.cn From Randy.Galbraith at gmail.com Sun Apr 13 12:57:26 2008 From: Randy.Galbraith at gmail.com (Randy.Galbraith at gmail.com) Date: Sun, 13 Apr 2008 09:57:26 -0700 (PDT) Subject: Compiling Python 2.5.2 on AIX 5.2 Message-ID: <0b73e8e5-c301-4823-ac94-42f757456cf1@x19g2000prg.googlegroups.com> I'm investigating the possible use of Mecurial SCM as a replacement for CVS. Mecurial is written in Python. I have a background in GNU/ Linux, Solaris, sparc and Perl. However AIX, powerpc and Python are new to me. --uname output-- $ uname -rvp 2 5 powerpc --end uname output-- I used this script to compile Python: --script-- export PATH=/usr/bin:/usr/vacpp/bin export CC=xlC_r export OBJECT_MODE=32 gunzip -c Python-2.5.2.tar.gz | tar xvf - cd Python-2.5.2 ./configure --with-gcc="xlc_r" --with-cxx="xlC_r" \ --disable-ipv6 AR="ar" --prefix=$HOME make --end script-- My concern is when I run make test I get this output: --make test output-- 275 tests OK. 2 tests failed: test_mmap test_wait4 45 tests skipped: test_aepack test_al test_applesingle test_bsddb test_bsddb185 test_bsddb3 test_bz2 test_cd test_cl test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_ctypes test_curses test_dl test_gdbm test_gl test_gzip test_imgfile test_largefile test_linuxaudiodev test_macfs test_macostools test_nis test_normalization test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_sqlite test_startfile test_sunaudiodev test_tcl test_timeout test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 test_zipimport test_zlib 2 skips unexpected on aix5: test_largefile test_ctypes make: *** [test] Error 1 --end make test output-- My question are: (a) Have you successfully compiled Python 2.5.2 on AIX 5.2? If so, which options did you place in the environment and send to ./ configure? (b) Given the choice between xlc and gcc 4.2.2 (which we have on the platform) which one is considered more suitable? (c) I am concerned about the two failing test cases: test_mmap and test_wait4. Are there good reasons why these failures can be safely ignored? (d) Should I be concerned with the skips of test_largefile and test_ctypes? Much thanks in advance. Kind regards, -Randy Galbraith From BrianVanderburg2 at aim.com Mon Apr 14 23:46:04 2008 From: BrianVanderburg2 at aim.com (Brian Vanderburg II) Date: Mon, 14 Apr 2008 23:46:04 -0400 Subject: Java or C++? In-Reply-To: References: Message-ID: <480424FC.5040802@aim.com> > My idea, if you really love Python and never think about erasing it > from your mind, go for C (not C++). A script language plus C can solve > every problem you need to solve. Also Python works pretty fine with C. I agree mostly with this one. Scripting is very nice when writing an application especially one that needs to change very often. Plus there are several toolkits and existing libraries available for Python. I've used wxPython some with it, and it came in handy for a few applications that I would have normally written in C++/wxWidgets and have to recompile every few weeks to suit my needs (data extraction tools/etc) However there are cases when a compiled language is better, especially anything that needs to be 'fast' and have a lower overhead. I wouldn't use Python to create a very graphics intensive game or anything, though it can be used with pygame/PyOpenGL for some nice simple stuff. Also everything in Python is an object so it can start to consume memory when handling very large data sets. And since there is no guarantee of when garbage collection occurs, simply 'deleting' an item does not ensure it is completely gone, especially if there are cyclic references, though that can be handled by using 'gc.collect()'. I consider C++ just a simplification of C, in the sense that it makes it easier to do things that would take more work to be done in C. One can still use C++ without all of the more complicated aspects but still take advantages of other aspects. C has the advantage that it does not to anything behind your back. This is very useful especially for any form of system development or where you must know exactly what is going on. It is still possible to do 'object oriented' development in C, it just requires some more typing to set up whatever is needed. Even things like COM for windows can be done in C, it just requires manually building the 'vtable' so to speak. Also, C seems to avoid the use of temporaries where as C++ can use them in conversions and assignments automatically if needed. C++ makes some of it easier by doing certain things for you. Take a string object for example. In C, assignment would only do a memory copy operation: String a, b; b = a; The statement 'b = a' would only copy the memory and pointers from 'b' to 'a' which means they would both point to the same buffer. To avoid this, a copy constructor or assignment operator can be implemented when using C++. The same in C would be something like: String_Assign(&b, &a); /* instead of b = a */ Then if a structure contains objects, more work is needed. For example, in C: typedef struct Name { String honorary; String first; String middle; String last; String lineage; } Name; void Name_Create(Name* name) { String_Create(&name->honorary); String_Create(&name->first); String_Create(&name->middle); String_Create(&name->last); String_Create(&name->lineage); } void Name_Assign(Name* self, Name* other) { String_Assign(&self->honorary, &other->honorary); String_Assign(&self->first, &other->first); String_Assign(&self->middle, &other->middle); String_Assign(&self->last, &other->last); String_Assign(&self->lineage, &other->lineage); } Name p1, p2; Name_Create(&p1); Name_Create(&p2); Name_Assign(&p2, &p1); But in C++, this is no problem: Name p1, p2; p2 = p1; This will automatically call the constructors of any contained objects to initialize the string. The implicit assignment operator automatically performs the assignment of any contained objects. Destruction is also automatic. When 'p1' goes out of scope, during the destructor the destructor for all contained objects is called. And if you want more control you can implement the default and copy constructors, destructor, and assignment operator, and tell them to do what you want. Just beware because the explicit constructors only calls default constructors of any parent classes (even the copy constructor) unless an initializer list is used, and an explicit assignment will not automatically do assignment of parent classes. Neither C nor C++ is really better, it depends on the what needs to be done. C does only what it is told, and also has easier external linkage since there is no name mangling. C++ does a lot of the needed stuff automatically, but explicit constructors and assignment operators can still be declared to control them, and frequently doing the same thing in C++ takes fewer lines of code than in C. As for Java, I think it is 'overly-used' in some areas, especially in embedded development. I attended NC State and during orientation this representative was talking about a small little robotic device and how it had a full Java VM inside it and it only took '6 minutes to boot'. Some claim it is for portability that Java is so good in embedded devices. But still, if the program is moved to another device, it may still need to be changed and recompiled if the new devices has different IO pins, timers, interrupts, etc. Most chips have a C compiler/translator available, and the same program could have been written in C, compiled directly to the machine code needed for the device, 'booted' immediately, and not needed a Java VM as well. If portability to other devices is desired then an abstract layer could be created in the program and the device/hardware specific code could be seperated to that layer seperatly from the rest of the program. Well, all of that is just my opinion though, not meant to offend anyone. From vlastimil.brom at gmail.com Sat Apr 12 14:15:31 2008 From: vlastimil.brom at gmail.com (Vlastimil Brom) Date: Sat, 12 Apr 2008 20:15:31 +0200 Subject: sqlite3 - adding tables and rows via parameters In-Reply-To: References: <9fdb569a0804120839w6916ed96ka5b53aad7ca6f565@mail.gmail.com> Message-ID: <9fdb569a0804121115v43d86c49ieb0f712bd5a49679@mail.gmail.com> 2008/4/12, Steve Holden : > > Vlastimil Brom wrote: > > Hi all, > > I would like to ask about the usage of sqlite3 in python, more > > specifically about a way to pass table > > or column names to a SQL commands using parameters. > > > The thing that will stop you from using a tablename as an argument to a > parameterized query is that (the) front-ends (I am familiar with) don't > allow table names to be parameterized ... > > ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ ======================= Thank you very much for the explanation Steve! I noticed the limitation, but wasn't sure, if if I wasn't missing anything, as I don't have many experiences with databases (now I am actually trying to reimplement, what was previously managed to with nested dictionaries - hence I don't think, something more robust than sqlite is appropriate). But now I am not sure; are there any (security ...) risks of using string interpolation for table and column names in the SQL commands? Or are the values, where parametrization (with ? in sqlite3) is supported, the only vulnerable part; whereas eg. an incorrect value of what should be a name is safe (of course, apart from the unsuccessful command itself)? TIA Vlasta -------------- next part -------------- An HTML attachment was scrubbed... URL: From d3vvnull at gmail.com Tue Apr 15 08:39:21 2008 From: d3vvnull at gmail.com (Michael Mabin) Date: Tue, 15 Apr 2008 07:39:21 -0500 Subject: Java or C++? In-Reply-To: <6660c92c-20d2-48bd-ae46-fee8dfb9f347@e39g2000hsf.googlegroups.com> References: <6660c92c-20d2-48bd-ae46-fee8dfb9f347@e39g2000hsf.googlegroups.com> Message-ID: <170543c70804150539p4fb08181v75ab6fb04b97fb7b@mail.gmail.com> I'm shocked. I've seen no mention of Smalltalk at all. Which should be soo oobvious! ;) I would take an incremental approach. Learn Java first, since it is still OO, offers a rich set of libraries for just about every task but requires a bit more work. C++ requires that you do more work still (build more of your own classes or find more third-party frameworks to do what you need to do), work with the Standard Template Library, distinguish between references and pointers, choose between implementing an OO mechanism (such as IO with iostreams) or traditional (fprintf, printf,etc.). C requires that you shift out of the OO paradigm completely and manage your data and operations separately without the benefit of classes. If you read the Extending Python documentation, you will see how much more work C has to do to make Python possible at all. Michael 2008/4/15 Ivan Illarionov : > On 15 ???, 07:46, Brian Vanderburg II > wrote: > [...] > > C has the advantage that it does not to anything behind your back. This > > is very useful especially for any form of system development or where > > you must know exactly what is going on. It is still possible to do > > 'object oriented' development in C, it just requires some more typing to > > set up whatever is needed. Even things like COM for windows can be done > > in C, it just requires manually building the 'vtable' so to speak. > > Also, C seems to avoid the use of temporaries where as C++ can use them > > in conversions and assignments automatically if needed. > > Great point. It's also possible to do Python object-oriented > programming in C. 'PyMethodDefs' are the same 'vtables'. I've found > that Python/C API is not that hard, the problem is a lack of good > tutorials and false assumptions that ctypes or SWIG are somehow > better. After `#include Python.h` C becomes very Python friendly. > -- > http://mail.python.org/mailman/listinfo/python-list > -- | _ | * | _ | | _ | _ | * | | * | * | * | -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at stroeder.com Wed Apr 23 17:40:37 2008 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Wed, 23 Apr 2008 23:40:37 +0200 Subject: python-ldap: searching without specifying an OU? In-Reply-To: <0bbac44a-5d11-4e27-829d-ad2b2de62210@x35g2000hsb.googlegroups.com> References: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> <58546d42-bc80-4f9d-be90-e184c312e2d1@k37g2000hsf.googlegroups.com> <0ke3e5-ccc.ln1@nb2.stroeder.com> <8ef38281-a6fe-4501-b711-a24cd9f35a24@t54g2000hsg.googlegroups.com> <0bbac44a-5d11-4e27-829d-ad2b2de62210@x35g2000hsb.googlegroups.com> Message-ID: hotani wrote: > This fixed it! > http://peeved.org/blog/2007/11/20/ > > By adding this line after 'import ldap', I was able to search from the > root level: > ldap.set_option(ldap.OPT_REFERRALS, 0) Uumh, yes. I'm always switching off OpenLDAP client lib's internal referral chasing. But be prepared to also handle (at least ignore) the search continuations (LDAP URL) in the search results you will probably receive. These are not regular search entries. Ciao, Michael. From zolotoiklo at mail.ru Tue Apr 29 07:22:29 2008 From: zolotoiklo at mail.ru (=?KOI8-R?B?+s/Mz9TPyiDrzM/O?=) Date: Tue, 29 Apr 2008 04:22:29 -0700 (PDT) Subject: =?KOI8-R?B?8M/R08EgzcHT08HWxdLZINMg1MXSzc8t3MbGxQ==?= =?KOI8-R?B?y9TPzQ==?= Message-ID: <3654a2a9-0fb8-40be-a9d3-6feffdf39f00@w7g2000hsa.googlegroups.com> ??????????? ???? ??? ????????? ?? ??????????????????? ????????? ?????????? ???? ? ?????????? ???????? ??????? ??????? ???????? ? ??????????? ?????????. ??????? ??????????? ??????-????? ???? ? ????? ?????????? ???????????? ??????? ??? ?????????. ?? ??? ????, ????? ??????????? ???? ??????? ??????, ? ??? ????? ?????????? ?????????? ?????????? ?????????, ????? ???? ??????? ??????????? ???? ? ??? ?????, ??? ????? ??????????? ????. ?????-???? ????? ????? ???? ???????? ? ??????? - ??? ????????? ?? ??????? ???. ??????? ?????????? ????????! ??? ???? ???????? ??????????? ???? ? ????????? ??? ???????, ??? ??? ?????????? ???????? ? ??????????? ?????! ????? ????????? ? ?????-???????? http://shopbody.ru/poyas_pohudenia.0.0.html From john00587 at gmail.com Mon Apr 21 01:40:24 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:40:24 -0700 (PDT) Subject: cs3 activation crack Message-ID: cs3 activation crack http://cracks.00bp.com F R E E C R A C K S From ivan.illarionov at gmail.com Mon Apr 21 16:50:13 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Mon, 21 Apr 2008 13:50:13 -0700 (PDT) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> Message-ID: <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> On 22 ???, 00:10, Ivan Illarionov wrote: > On 20 ???, 04:10, George Sakkis wrote: > > > > > On Apr 18, 9:36 pm, Ross Ridge > > wrote: > > > > Ross Ridge said: > > > > > If you have Python 2.5, here's a faster version: > > > > > from struct import * > > > > unpack_i32be = Struct(">l").unpack > > > > > def from3Bytes_ross2(s): > > > > return unpack_i32be(s + "\0")[0] >> 8 > > > > Bob Greschke wrote: > > > > > That's not even intelligible. I wanna go back to COBOL. :) > > > > It's the same as the previous version except that it "precompiles" > > > the struct.unpack() format string. It works similar to the way Python > > > handles regular expressions. > > > I didn't know about the Struct class; pretty neat. It's amazing that > > this version without Psyco is as fast Bob's version with Psyco! Adding > > Psyco to it though makes it *slower*, not faster. So here's how I'd > > write it (if I wanted or had to stay in pure Python): > > > try: import psyco > > except ImportError: > > from struct import Struct > > unpack_i32be = Struct(">l").unpack > > def from3Bytes(s): > > return unpack_i32be(s + "\0")[0] >> 8 > > else: > > def from3Bytes(s): > > Value = (ord(s[0])<<16) + (ord(s[1])<<8) + ord(s[2]) > > if Value >= 0x800000: > > Value -= 0x1000000 > > return Value > > psyco.bind(from3Bytes) > > > HTH, > > George > > I was able to get even faster pure-python version using array module: > > a = array.array('l', ''.join(('\0' + s[i:i+3] for i in xrange(0, > len(s), 3)))) > if sys.byteorder == 'little': > a.byteswap() > > It actually moves bytes around on C level. > > test code: > import struct > import array > import sys > > unpack_i32be = struct.Struct(">l").unpack > s = ''.join(struct.pack('>i', 1234567)[1:]*1000) > > def from3bytes_ord(s): > values = [] > for i in xrange(0, len(s), 3): > Value = (ord(s[i])<<16) | (ord(s[i+1])<<8) | ord(s[i+2]) > if Value >= 0x800000: > Value -= 0x1000000 > values.append(Value) > return values > > def from3bytes_struct(s): > return [unpack_i32be(s[i:i+3] + "\0")[0] >> 8 for i in xrange(0, > len(s), 3)] > > def from3bytes_array(s): > a = array.array('l', ''.join(('\0' + s[i:i+3] for i in xrange(0, > len(s), 3)))) > if sys.byteorder == 'little': > a.byteswap() > return a.tolist() > > from timeit import Timer > > t1 = Timer("from3bytes_ord(s)", "from __main__ import s, > from3bytes_ord") > t2 = Timer("from3bytes_struct(s)", "from __main__ import s, > from3bytes_struct") > t3 = Timer("from3bytes_array(s)", "from __main__ import s, > from3bytes_array") > > print 'ord:\t', t1.timeit(1000) > print 'struct:\t', t2.timeit(1000) > print 'array:\t', t3.timeit(1000) > > Output: > ord: 7.08213110884 > struct: 3.7689164405 > array: 2.62995268952 > > Inspired by Guido's essayhttp://www.python.org/doc/essays/list2str/ And even faster: a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, len(s), 3)))) if sys.byteorder == 'little': a.byteswap() I think it's a fastest possible implementation in pure python From bearophileHUGS at lycos.com Thu Apr 3 09:18:04 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Thu, 3 Apr 2008 06:18:04 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> <0c7fd327-7b96-4c20-8c74-a528e280b5f3@r9g2000prd.googlegroups.com> Message-ID: Dennis Benzinger: > You could use the Aho-Corasick algorithm Aho-Corasick_algorithm>. > I don't know if there's a Python implementation yet. http://hkn.eecs.berkeley.edu/~dyoo/python/ahocorasick/ Bye, bearophile From hniksic at xemacs.org Thu Apr 17 11:46:53 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Thu, 17 Apr 2008 17:46:53 +0200 Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> Message-ID: <87tzi05vrm.fsf@mulj.homelinux.net> sturlamolden writes: > If I use my main interpreter to delegate a task to one of its > embedded 'children', its GIL will be released while it is waiting > for the answer. Associating each embedded interpreter with a > threading.Thread is all that remains. The GIL is released while the > thread operating the child interpreter is blocked. Have you tackled the communication problem? The way I see it, one interpreter cannot "see" objects created in the other because they have separate pools of ... everything. They can communicate by passing serialized objects through ctypes, but that sounds like the solutions that use processes. From bressert at gmail.com Wed Apr 16 10:37:03 2008 From: bressert at gmail.com (eli) Date: Wed, 16 Apr 2008 07:37:03 -0700 (PDT) Subject: subplot function in matplotlib References: <368ac3ca-ed20-494d-9f09-00d06701857d@k37g2000hsf.googlegroups.com> <66m9luF2lchhkU2@mid.uni-berlin.de> Message-ID: <59281036-3160-4a2d-a391-e668bebaf822@k13g2000hse.googlegroups.com> On Apr 16, 8:27?am, "Diez B. Roggisch" wrote: > eli wrote: > > Does anyone know a workaround to plotting beyond 9 subplots in > > matplotlib? It would be nice to have 20 plots under the subplot > > function for example (poster). > > Is there such a limitation? I thought that was only for the condensed > sublpot-specification-form (where you give e.g. 133 instead of 1,3,3) > > Diez Didn't see that part. Now it's fixed. Thanks! Eli From frambooz at gmail.com Thu Apr 10 19:19:13 2008 From: frambooz at gmail.com (frambooz at gmail.com) Date: Thu, 10 Apr 2008 16:19:13 -0700 (PDT) Subject: Adding classes to modules at runtime from outside that module Message-ID: Hey guys, In Python, is it possible to add classes to a module at run-time? Say I have a module foo and a module bar. Foo has class A and B, and bar has class C. I want to add class C to foo so I can access it as foo.C, but i want to do it without modifying foo's source. Is this at all possible? Thanks much. ` Rogier van Etten From pylists at arcor.de Mon Apr 14 03:08:06 2008 From: pylists at arcor.de (Penny Y.) Date: Mon, 14 Apr 2008 15:08:06 +0800 Subject: =?gb2312?B?tPC4tDogaG93IHRvIHJlbW92ZSBcbiBpbiB0aGUgbGlzdA==?= In-Reply-To: Message-ID: <20080414070819.D4CA335E6A5@mail-in-06.arcor-online.net> > lines[:] = [line.rstrip('\n') for line in lines] why not just: lines = [line.rstrip('\n') for line in lines] what's the difference between lines[:] and lines here? Thanks. -----????----- ???: python-list-bounces+pylists=arcor.de at python.org [mailto:python-list-bounces+pylists=arcor.de at python.org] ?? Gabriel Genellina ????: 2008?4?14? 12:59 ???: python-list at python.org ??: Re: how to remove \n in the list En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam escribi?: > hi, > l=['5\n', '2\n', '7\n', '3\n', '6\n'] > > how to remove \n from the given list l is is very poor name... I'll use lines instead: lines[:] = [line.rstrip('\n') for line in lines] -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list From grante at visi.com Thu Apr 17 11:55:58 2008 From: grante at visi.com (Grant Edwards) Date: Thu, 17 Apr 2008 10:55:58 -0500 Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> Message-ID: <1uqdncgQj4iT7prVnZ2dnUVZ_sKqnZ2d@visi> On 2008-04-17, Gary Herron wrote: >> For example, let's say I want to assign a bunch of variables to an >> initial, single value. In C or a similar language you would do: >> >> CONSTANT1 = >> /* This is some constant */ >> CONSTANT2 = >> CONSTANT3 = >> >> /*This is yet some other constant */ >> CONSTANT = >> >> 1; > > > Yuck! No way!! If you *want* to make your code that hard to > read, I'm sure you can find lots of ways to do so, even in > Python, but don't expect Python to change to help you toward > such a dubious goal. > > Seriously, examine your motivations for wanting such a syntax. > Does it make the code more readable? (Absolutely not.) Does > it make it more maintainable. (Certainly not -- consider it > you needed to change CONSTANT2 to a different value some time > in the future.) You move the initialization of CONSTANT2 out of that construct and set it to whatever you want. Consider the case where you have this: constant1 = constant2 = constant3 = constant4 = constant5 = constant6 = What happens when the initial value needs to change? You have to change it in six places instead of in one place as you would if you did this: constant1 = \ constant2 = \ constant3 = \ constant4 = \ constant5 = \ constant6 = Having the same information be duplicated N times is bad. In C, the above construct can be used to solve that problem efficiently. In Python the right thing to do is probably this: initialValue = constant1 = initialValue constant2 = initialValue constant3 = initialValue constant4 = initialValue constant5 = initialValue constant6 = initialValue >> I find this limitation very annoying. If you continue to try to write C code in a Python program, you're going to continue to be annoyed. Start writing Python code when working on Python programs and writing C code when working on C programs. I write a lot of both and have no problem switching back and forth other than an occasional extraneous ";" in my python code. Using an editor with good C and Python modes helps. -- Grant Edwards grante Yow! ... I want to perform at cranial activities with visi.com Tuesday Weld!! From hobgoodoreneyhb at gmail.com Tue Apr 22 11:38:14 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:38:14 -0700 (PDT) Subject: joy ringtone crack Message-ID: <8431e708-5714-4741-a66a-475c1216f178@y21g2000hsf.googlegroups.com> joy ringtone crack http://cracks.12w.net F R E E C R A C K S From damonwischik at gmail.com Fri Apr 18 20:56:12 2008 From: damonwischik at gmail.com (damonwischik at gmail.com) Date: Fri, 18 Apr 2008 17:56:12 -0700 (PDT) Subject: How to print a unicode string? References: <4809394A.1030906@v.loewis.de> Message-ID: On Apr 19, 1:14 am, "Martin v. L?wis" wrote: > > From what I've googled, I think I need to set my locale. > > Not on this operating system. On Windows, you need to change > your console. If it is a cmd.exe-style console, use chcp. > For IDLE, changing the output encoding is not supported. > > If you want to output into a file, use codecs.open. > > If you absolutely want to output UTF-8 to the terminal even > though the terminal will not be able to render it correctly, > use > > sys.stdout = codecs.getwriter("UTF-8")(sys.stdout) Thank you for the suggestion. As I said, I am running Python through Emacs 22.2.1, so I doubt it is a cmd.exe-style console, and it most certainly is not IDLE. I want to output to the Emacs buffer, via the python-mode plugin for Emacs, not to a file. I tried your suggestion of setting sys.stdout, and it works perfectly. As I said, the output is going to Emacs, and Emacs _does_ know how to render UTF-8. How can I make this a global setting? Is it possible to change an environment variable, so that Python uses this coding automatically? Or pass a command-line argument when Emacs python-mode invokes the Python interpreter? Or execute this line of Python in a startup script which is invoked whenever a new Python session is started? Thank you again for your help, Damon. From arnodel at googlemail.com Sun Apr 20 15:27:54 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 20 Apr 2008 12:27:54 -0700 (PDT) Subject: What happened with python? messed strings? References: Message-ID: On Apr 20, 7:54?pm, wrote: [...] > python should have stayed at version 1.5, every single 'improvement' > has been a mess. But this is the definitive hell. You can still download Python 1.5.2 from python.org: http://www.python.org/download/releases/1.5/ HTH -- Arnaud From john106henry at hotmail.com Tue Apr 29 18:23:35 2008 From: john106henry at hotmail.com (John Henry) Date: Tue, 29 Apr 2008 15:23:35 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <473deef3-9acb-45dd-a7ca-47b0081bd28c@i36g2000prf.googlegroups.com> <3f7bb91e-335e-46bd-88ca-f15b26c35132@k1g2000prb.googlegroups.com> <827bdae6-4422-4226-a543-af53f5b7e01b@s33g2000pri.googlegroups.com> <083b58e8-522a-4c01-b612-c592fe69fcd1@i36g2000prf.googlegroups.com> <2978ec5b-fd7c-4fb1-9aa5-4bb88ba46ee8@m73g2000hsh.googlegroups.com> Message-ID: <2a9d9002-85c6-4834-9747-479d16e92009@1g2000prg.googlegroups.com> On Apr 29, 1:16 pm, Panyasan wrote: > On 29 Apr., 20:30, Panyasan wrote: > > > On 29 Apr., 18:17, John Henry wrote: > > > > There are a whole bunch of test programs that comes with Pythoncard. > > > Do they work? (Not all of them will work - some requires a database) > > > Yes, the examples work. Just the resourceEditor.py and the > > layoutEditor.py in the distributed version and your modified > > layoutEditor.py don't. > > Ok, here is how it works for me: copy all the *.rsrc.py from the > modules subdirectory to the parent directory. This works for the > standard resourceEditor folder and your custom layoutEditor folder. > What the heck. Now I can deal with more productive things... Mmmmmm...this is a Mac thing. From lib_team at yahoo.fr Tue Apr 22 05:06:15 2008 From: lib_team at yahoo.fr (=?iso-8859-1?Q?Pr=E9mon_Nom?=) Date: Tue, 22 Apr 2008 09:06:15 +0000 (GMT) Subject: Embeded python memory leaks Message-ID: <351783.77724.qm@web25908.mail.ukl.yahoo.com> An HTML attachment was scrubbed... URL: From mobile at ibinsa.com Tue Apr 15 16:49:42 2008 From: mobile at ibinsa.com (Gabriel Ibanez) Date: Tue, 15 Apr 2008 22:49:42 +0200 Subject: Java or C++? References: <525142.84411.qm@web39208.mail.mud.yahoo.com> <48050D14.6040801@gmail.com> Message-ID: <018b01c89f3a$3b854b50$0a01a8c0@mobile> Hi all, I've never programmed Java. I started directly in C, then C++ and now using Python, mainly because its modules, because I found very hard to use and find external libraries to do the same as Python (i.e. to read an URL o send an email), and soften these libraries on C are not free or depending on an specific compiler (aka VC version x). The lack in Python is only speed, and I don't know what you better get from Java, and may be I loss all those usefull libraries. There's also a said "Student of many, teacher of nothing" From goldtech at worldpost.com Thu Apr 24 08:11:44 2008 From: goldtech at worldpost.com (goldtech) Date: Thu, 24 Apr 2008 05:11:44 -0700 (PDT) Subject: Tkinter scrollbar and checkbox Message-ID: <9581b4cd-36f1-47dc-ae6e-0ca58f1b38e0@27g2000hsf.googlegroups.com> Hi, I'm stumped on how to have a scrollbar with a long list of checkboxes. Given code like: from Tkinter import * root = Tk() states = [] for i in range(150): var = IntVar() chk = Checkbutton(root, text=str(i), variable=var) chk.grid(sticky=W) states.append(var) root.mainloop() print map((lambda var: var.get()), states) I've tried adding this to a frame then adding the frame to a canvas and it gets complicated rather quickly... Is there a simple way to add a scroll bar? Thanks From castironpi at gmail.com Wed Apr 2 11:32:57 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 2 Apr 2008 08:32:57 -0700 (PDT) Subject: Self-referencing decorator function parameters References: <88b2c61e-8cf1-4ac0-a5d4-c968d009b544@c65g2000hsa.googlegroups.com> Message-ID: On Apr 2, 7:30?am, Thomas Dimson wrote: > Hello, > > Originally I posted this as a bug but it was shot down pretty quickly. > I am still mildly curious about this as I'm missing a bit of > understanding of Python here. Why is it that the following code > snippet: > > def decorator( call ): > ? ? def inner(func): > ? ? ? ? def application( *args, **kwargs ): > ? ? ? ? ? ? call(*args,**kwargs) > ? ? ? ? ? ? func(*args,**kwargs) > ? ? ? ? return application > > ? ? return inner > > class DecorateMe: > ? ? @decorator( call=DecorateMe.callMe ) > ? ? def youBet( self ): > ? ? ? ? pass > > ? ? def callMe( self ): > ? ? ? ? print "Hello!" > > DecorateMe().youBet() > > Will not compile, giving: > Traceback (most recent call last): > ? File "badpython.py", line 10, in > ? ? class DecorateMe: > ? File "badpython.py", line 11, in DecorateMe > ? ? @decorator( call=DecorateMe.callMe ) > NameError: name 'DecorateMe' is not defined > > Where if you change the "call=DecorateMe.callMe" to "call=lambda x: > DecorateMe.callMe(x)" everything goes along its merry way. Nesting the > call in a lambda seems to allow it to recognize the class definition. > Any ideas as to what is going on here (other than ugly code)? def decorator( call ): def inner(func): def application( *args, **kwargs ): call(*args,**kwargs) func(*args,**kwargs) return application return inner class DecorateMe: def callMe( self ): print( "Hello!" ) @decorator( call=callMe ) def youBet( self ): pass DecorateMe().youBet() From martin at v.loewis.de Sun Apr 27 21:18:22 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Mon, 28 Apr 2008 03:18:22 +0200 Subject: py3k concerns. An example In-Reply-To: References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> <48118719$0$25846$9b622d9e@news.freenet.de> Message-ID: <481525DE.9060208@v.loewis.de> > This would save me personally a great deal of > painful tedium, I suspect (especially considering > that I've implemented a lot of "dictionary-like" > objects -- so I'll have to change the way their > "keys" method works -- or something -- I haven't > figured it out yet...). [...] > In C# and java, for example, this sort of issue > has never been a problem > in my experience: stuff I wrote many versions ago > still works just fine with no changes (but please > note that I don't write gui stuff, which is less > stable -- I'm speaking of algorithmic and system > libraries). I don't see the connection. Why do you think your .keys() implementation breaks just because dict.keys has a different semantics now? An existing application of an existing dict-like object will continue to work just fine in Python 3, right? I can't find the change to dictionaries outrageous. Regards, Martin From martin.laloux at gmail.com Wed Apr 16 07:38:42 2008 From: martin.laloux at gmail.com (martin.laloux at gmail.com) Date: Wed, 16 Apr 2008 04:38:42 -0700 (PDT) Subject: Python crashes consistently References: Message-ID: which python ? from macports or macpython ? From gagsl-py2 at yahoo.com.ar Wed Apr 23 01:10:02 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 23 Apr 2008 02:10:02 -0300 Subject: Explicit variable declaration References: <1be78d220804221739h77d8a4eak28deb5ce52dbe623@mail.gmail.com> Message-ID: En Tue, 22 Apr 2008 21:39:41 -0300, Filip Gruszczy?ski escribi?: > Hello everyone! > > It is my first message on this list, therefore I would like to say > hello to everyone. I am fourth year student of CS on the Univeristy of > Warsaw and recently I have become very interested in dynamically typed > languages, especially Python. Welcome to Python! > I would like to ask, whether there is any way of explicitly declaring > variables used in a function? While I am pretty sure, that there is no > such way in the language itself, I would like to know, whether there > are any third-party tools to do that. This would be very useful for me > during development, so I am looking for such a tool. Not part of the language itself, but there are some tools to do static code analysis, like PyLint and PyChecker; see http://wiki.python.org/moin/static_source_analysis -- Gabriel Genellina From jason.scheirer at gmail.com Tue Apr 8 23:13:46 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Tue, 8 Apr 2008 20:13:46 -0700 (PDT) Subject: Google App Engine References: <47fc2c7c$0$36365$742ec2ed@news.sonic.net> Message-ID: <7e43fcd9-6207-4af2-8256-c0099a8ce0bb@1g2000prf.googlegroups.com> On Apr 8, 7:50 pm, John Nagle wrote: > Duncan Booth wrote: > > Google have announced a new service called 'Google App Engine' which may > > be of interest to some of the people here > > OK, now we need a compatibility layer so you can move apps from > Google App Engine to your own servers. You don't want to be locked > into a single vendor solution, especially when they reserve the right > to start charging. > > Their data store uses a subset of SQL, so it's probably possible > to write a conversion layer allowing use of MySQL. > > John Nagle It supports Django, and more importantly, WSGI, so any 'framework' you build on top of it should transfer out. Heck, you have a stand-alone python script that comes with the developer kit for hosting your apps on YOUR computer that you could port to use YOUR database and be done with it. Write your own ORM or just some decent OO code for handling data access so the database access layer can be swapped out and you are golden. I really doubt getting away from the Googe App Engine is going to be too terribly difficult for any intermediate Python programmer, assuming good up-front application design. From umpsumps at gmail.com Sat Apr 26 19:50:57 2008 From: umpsumps at gmail.com (umpsumps at gmail.com) Date: Sat, 26 Apr 2008 16:50:57 -0700 (PDT) Subject: learning with python question (HtTLaPP) References: <98acecbd-9de2-4ebf-927b-ac6bc1fbc3fd@b5g2000pri.googlegroups.com> <53d6254f-895f-48fb-8ab9-3929c403f11b@v23g2000pro.googlegroups.com> Message-ID: ok.. I finally made something that works.. Please let me know what you think: >>> def lines(letters): fin = open('words.txt') count = 0 rescount = 0 # count the number of results results = "" # there are words that contain the letters for line in fin: needs = 0 x = str(line.strip()) for ch in letters: if ch not in x: pass else: needs = needs + 1 if needs == len(letters): rescount += 1 results = results + '\n' + x count += 1 print count, 'lines searched' print results, '\n' print 'result count is: ', rescount On Apr 26, 4:02?pm, "Eric Wertman" wrote: > > ?Is the way I wrote the function inherently wrong? ?What I wrote > > I would not say that. ?I think a lot of people probably start off like > that with python. ?You'll find in most cases that manually keeping > counters isn't necessary. ?If you really want to learn python though, > I would suggest using built in functions and libraries as much as > possible, as that's where the real power comes from (IMO). > > > ?returns the sequence, however I'm trying to make the output match for > > ?the letters in the string entered, not necessarily the string > > ?sequence. > > ?Only the sequence shows up 'uzi'. ?I don't get words like 'unzip' or > > ?'Zurich' . ?I've only barely started on invocation and maybe writing > > ?something like I'm describing is above what level I'm currently at. > > This would be a more difficult approach.. ? Where you are doing the > comparison step: > > if letters in line.strip(): > > It's trying to match the exact string "uzi", not any of the individual > letters. ?You would need to look for each letter independently and > then make sure they were in the right order to match the other words. From noname9968 at gmail.com Sat Apr 5 02:14:11 2008 From: noname9968 at gmail.com (Alex9968) Date: Sat, 05 Apr 2008 10:14:11 +0400 Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? In-Reply-To: References: <47F67798.3060401@gmail.com> Message-ID: <47F718B3.9020504@gmail.com> Gabriel Genellina wrote: > En Fri, 04 Apr 2008 15:46:48 -0300, Alex9968 > escribi?: > >> Nebur wrote: >> > > >>> No, I can't reproduce it, and I don't know whom to blame (Pydev? >>> Eclipse ? The File System ? A Virus that only 2 times in half a year >>> deletes a single file I'm busy working with, and seems to do nothing >>> else? Myself beeing schizophrenic ??) >>> > > >> A virus created to remind you 2 times in half a year of the importance >> of backup operations ;-) . I'm joking. I don't know what is this, but >> I'm interested. Because my files won't be restorable from version >> control :-( >> > > Then implement it! It's not so difficult, less if you're the only one > working on the files. Implement what? The virus? I haven't said that I'm interested in virus, I meant I'd like to know WHAT is this From cemasoniv at gmail.com Fri Apr 4 12:08:17 2008 From: cemasoniv at gmail.com (Charles Mason) Date: Fri, 4 Apr 2008 12:08:17 -0400 Subject: Is there an official way to add methods to an instance? In-Reply-To: <47f645e6$0$36354$742ec2ed@news.sonic.net> References: <7xve2yas87.fsf@ruckus.brouhaha.com> <47f61041$0$27969$426a34cc@news.free.fr> <47f645e6$0$36354$742ec2ed@news.sonic.net> Message-ID: <3290753a0804040908j66c5fdb1kc78a7045a2d4573c@mail.gmail.com> And for such a behavior they've termed "monkeying" Thus, the coinage "Monkeypatching" for what you want to do: http://mail.python.org/pipermail/python-dev/2008-January/076194.html There are a group of people who think "monkeypatching is destroying ruby." You still probably should avoid it for production code. On Fri, Apr 4, 2008 at 11:25 AM, John Nagle wrote: > Bruno Desthuilliers wrote: > > Paul Rubin a ?crit : > >> Brian Vanderburg II writes: > >>> I've checked out some ways to get this to work. I want to be able to > >>> add a new function to an instance of an object. > >> > >> Ugh. Avoid that if you can. > > > > Why so ? OO is about objects, not classes, and adding methods on a > > per-object basis is perfectly legitimate. > > It's what professional programmers call a "l33t feature", > one not suitable for production code. Typically such features > are used by programmers with about two years experience, > trying too hard to prove that they're cool. > > John Nagle > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mobile at ibinsa.com Tue Apr 8 18:46:43 2008 From: mobile at ibinsa.com (Gabriel Ibanez) Date: Wed, 9 Apr 2008 00:46:43 +0200 Subject: Converting a tuple to a list References: <00ba01c899c5$14528ae0$0a01a8c0@mobile> Message-ID: <00e601c899ca$6b3be4f0$0a01a8c0@mobile> Gabriel Ibanez wrote: > Hi all .. > > I'm trying to using the map function to convert a tuple to a list, without > success. > > I would like to have a lonely line that performs the same as loop of the > next script: > > ------------------------------------------- > # Conveting tuple -> list > > tupla = ((1,2), (3,4), (5,6)) > > print tupla > > lista = [] > for a in tupla: > for b in a: > lista.append(b) > print lista > ------------------------------------------- > > Any idea ? > > Thanks ... > > # Gabriel > list(tupla) would probably do it. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list That would just make a list of tuples, I think he wants [1, 2, 3, 4, 5, 6]. Try: l = [x for z in t for x in z] --Brian --------------- Thanks Steve and Brian, Brian: that is !! However, it's a bit difficult to understand now. I have read it several times :) From see_website at mindprod.com.invalid Wed Apr 23 00:07:31 2008 From: see_website at mindprod.com.invalid (Roedy Green) Date: Wed, 23 Apr 2008 04:07:31 GMT Subject: pop langs website ranking References: <41fbaf27-a80b-402b-b406-c048a65a8643@b64g2000hsa.googlegroups.com> Message-ID: On Tue, 22 Apr 2008 14:41:33 -0700 (PDT), "xahlee at gmail.com" wrote, quoted or indirectly quoted someone who said : > alexa I was shocked at the detailed information Alexa (owned by Amzon.com)_ had about my website. I wrote them and asked how they got it. They said volunteers use a special browsing tool that reports website visits. They use that to generate the information. I suppose then one way to bump your stats is to use the tool for maintaining your own website. The weakness of this approach is it is unusual group of people who will voluntarily submit to having their usage spied on. These are not a typical group or a large group. Google has AdSense that will let them know in huge detail the hit stats on a huge hunk of the web, but I don't know if they publish that information anywhere. -- Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com From deets at nospam.web.de Mon Apr 28 03:36:50 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Mon, 28 Apr 2008 09:36:50 +0200 Subject: class or class-instance ? In-Reply-To: References: Message-ID: <67ld5cF2jm4mjU1@mid.uni-berlin.de> Stef Mientki schrieb: > hello, > > I've a procedure (or in fact a class method) that should be callable with > either a class > (in which case the procedure should create an instance) > or with an instance of that class > as the parameter. > > def somefunction ( self, parameter ) : > if parameter is a class, create an instance of that class > else do nothing > > > > now I should be able to call the above procedure in either of the > following ways: > > somefunction ( someclass ) > > or > > somefunction ( someclass () ) There is a isclass in the module inspect. Diez From tjreedy at udel.edu Tue Apr 1 13:34:26 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 1 Apr 2008 13:34:26 -0400 Subject: Homework help References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> Message-ID: wrote in message news:06dd172b-e789-409b-b4e9-364ed935205f at i29g2000prf.googlegroups.com... | Hey guys | I haev this homework assignment due today | I don't necessarily want the answers, but need help on how to approach | it/the steps i need to solve the problems | Thanks Read the section of the tutorial (and possibly Launguage Reference) on writing for statements and functions. Then read the sections of the Library Reference on builtin types and specifically sequences and more specifically lists. tjr From michele.simionato at gmail.com Sat Apr 5 12:55:48 2008 From: michele.simionato at gmail.com (Michele Simionato) Date: Sat, 5 Apr 2008 09:55:48 -0700 (PDT) Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com> <20080405141329.GD15684@nullcube.com> Message-ID: On Apr 5, 5:05 pm, Steve Holden wrote: > Kay at least has a long history as a contributor in this group, so > people know how to interpret her remarks and know that her contributions > are made on the basis of a deep understanding of Python. She is I am pretty much sure you are making a gender mistake with Kay Schluehr here ;) For the rest, I do fully agree with your remarks. Kay +1, Aldo -1! Michele Simionato From rjh at see.sig.invalid Mon Apr 14 03:35:09 2008 From: rjh at see.sig.invalid (Richard Heathfield) Date: Mon, 14 Apr 2008 07:35:09 +0000 Subject: Game design : Making computer play References: Message-ID: v4vijayakumar said: > In computer based, two player, board games, how to make computer play? Write some code that works out what the computer player should do. If you want a better answer, ask a better question. > Are there any formal ways to _teach_ computer, to choose best possible > move? That's a better question. The obvious ways are DFS, BFS, and databases. For example, take backgammon, and computer goes first. You roll the PRNGs and get 6, 1. You (the computer) have never played this game before, so you don't have a database of good moves. Your legal moves are: 24,18 and 24,23 24,18 and 8,7 24,18 and 6,5 13,7 and 24,23 13,7 and 8,7 13,7 and 6,5 Of these, which is the best? DFS (Depth-First Search) and BFS (Breadth-First Search) can help you answer that question. What you do is define an evaluation function for the position, based on things like how many blots, how many on the bar, whether you have a prime, and so on. Then you *play the game* in simulation, as deeply as you can (which won't be very deep, actually), evaluating all the time. Once you've found the position that does you most good (or least harm) no matter what die-rolls the opponent may get and no matter how skilfully he or she plays, you know what to get your computer player to do next. If you're clever, you'll keep the solution tree around, destroying only the bits of it that won't ever be used again - to save processing time on your next turn. If you're really clever, you'll write a lot of this information down in a file, a sort of opening "book", so that you don't have to calculate everything from scratch every time. For example, in the above situation, there is no need to calculate, because it's a no-brainer: 13,7 and 8,7 is far and away the best move. > I know this is kind of off-topic here. Please redirect me, if there > are more appropriate newsgroup. comp.programming is probably where you want to be, at least to start off with. -- Richard Heathfield Email: -http://www. +rjh@ Google users: "Usenet is a strange place" - dmr 29 July 1999 From bignose+hates-spam at benfinney.id.au Mon Apr 7 01:53:30 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Mon, 07 Apr 2008 15:53:30 +1000 Subject: Adherence to PEP 8 for published code (was: ANN: pry unit testing framework) References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> Message-ID: <87d4p2mcrp.fsf_-_@benfinney.id.au> Aldo Cortesi writes: > Thus spake Ben Finney (bignose+hates-spam at benfinney.id.au): > > > > I'm afraid that Pry is unashamedly incompatible with any other unit > > > testing method in existence, including but not limited to doctest, > > > unittest, nose and py.test. ;) I didn't write this. Please preserve attribution lines correctly so we can keep track of who wrote what. > > Which makes the deliberate deviations from PEP 8 naming a large > > black mark against it. > > You're misunderstanding the intent of PEP 8, which was never > supposed to dogmatically enforce a naming standard on all Python > projects everywhere. You're placing words in my mouth, and erecting a straw man, as I never made that assertion. PEP 8 only has the force that people grant it. Nevertheless, it's a style guide that's widely accepted in the Python community, and adhering to it in one's code makes it easier to read for the majority, because it reduces the needless inconsistencies between different bodies of code. Conversely, deliberately diverging from the widely-accepted style guide increases the cognitive load on the reader; if that divergence is not done for a very good reason, one is imposing needless burden on every reader of the code. > You're also vastly overstating the impact of a minor naming > convention choice. Calling this a "large black mark" smacks of > scare-mongering to me. When distributing code with the expectation that others use it, it's a large black mark if it deliberately shun the widely-accepted, easily-followed coding standards, for the above reasons. I don't see why that would be scary. If you find it so, you have my sympathy. -- \ "I went to a general store. They wouldn't let me buy anything | `\ specifically." -- Steven Wright | _o__) | Ben Finney From n00m at narod.ru Sat Apr 26 11:10:09 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 08:10:09 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) Message-ID: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> Both codes below read the same huge(~35MB) text file. In the file > 1000000 lines, the length of each line < 99 chars. Stable result: Python runs ~0.65s C : ~0.70s Any thoughts? import time t=time.time() f=open('D:\\some.txt','r') z=f.readlines() f.close() print len(z) print time.time()-t m=input() print z[m] #include #include #include #include using namespace std; char vs[1002000][99]; FILE *fp=fopen("D:\\some.txt","r"); int main() { int i=0; while (true) { if (!fgets(vs[i],999,fp)) break; ++i; } fclose(fp); cout << i << endl; cout << clock()/CLOCKS_PER_SEC << endl; int m; cin >> m; cout << vs[m]; system("pause"); return 0; } From bvidinli at gmail.com Sat Apr 26 15:36:36 2008 From: bvidinli at gmail.com (bvidinli) Date: Sat, 26 Apr 2008 22:36:36 +0300 Subject: python and web programming, easy way...? Message-ID: <36e8a7020804261236j46c4ef62pf0fb7178d765774a@mail.gmail.com> Hi, i use currently python for console programming. in past, i tried it for web programming, to use it instead of php. Unfortunately, i failed in my attempt to switch to python. Currently, i make many webbased programs and a "Easy Hosting Control Panel " (www.ehcp.net) that runs on php, ehcp is a hosting control panel in beta stage.. in fact, i use python, love it and want to switch to it in my all projects, including webbased programs and ehcp. Can your recomment me the easiest, most usable way to use python in web programming.. in past, in my first attemt... i was able to run python as as apache cgi, runned it basicly, but i had many difficulties especially in sessions, cookies... maybe currently there is a solution, but i dont know. Please provide me the quickest/most appropriate solution for web programming in python. i will try to switch to python in ehcp too.. Currently my web programs are simple Object Oriented programs, that basicly uses a few files, in php. i use sessions in use authentications. i currently use php because it is fairly easy to install/run on apache.. you just put it on server, it runs.. i look something like this for python. because python programming is much better than php. Thank you a lot. -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From martin at v.loewis.de Mon Apr 28 18:34:11 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 29 Apr 2008 00:34:11 +0200 Subject: Simple unicode-safe version of str(exception)? In-Reply-To: <67moqeF2paokjU1@mid.individual.net> References: <67moqeF2paokjU1@mid.individual.net> Message-ID: <481650E3.4060603@v.loewis.de> >> I have code like this: >> except Exception, e: >> self.setState(self.Failed, str(e)) >> which fails if the exception contains a unicode argument. > > Fails how? ASCII encoding error, I suppose. It fails only if a) one argument is a Unicode object, and b) that Unicode object contains non-ASCII parameters. >> I did, of course, try unicode(e) but that fails. > > Converting unicode to unicode doesn't help. e is an exception object, not a Unicode object. Regards, Martin From lists at cheimes.de Tue Apr 22 16:45:20 2008 From: lists at cheimes.de (Christian Heimes) Date: Tue, 22 Apr 2008 22:45:20 +0200 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: <200804221622.57424.v.harishankar@gmail.com> References: <200804221622.57424.v.harishankar@gmail.com> Message-ID: <480E4E60.30803@cheimes.de> Harishankar schrieb: > 2. Kill the subprocess in a platform independent manner (i.e. no third party > modules and no hacks). I've added the feature to the Popen class a few days ago. The new methods are kill(), terminate() and send_signal(sig). On Windows all methods just fall back to _subprocess.TerminateProcess. On POSIX OS os.kill() is used. The code also works on Python 2.4 and 2.5 but I can't add new features to maintainence branches. Christian From onbuscol at gmail.com Sun Apr 13 08:06:45 2008 From: onbuscol at gmail.com (Unlimited Free Domain & Web Hosting) Date: Sun, 13 Apr 2008 05:06:45 -0700 (PDT) Subject: How to Choose an Unlimited Web Hosting for free Message-ID: <02d391b5-f72f-4f99-8f40-dbc304aa22fe@q24g2000prf.googlegroups.com> How to Choose an Unlimited Web Hosting 1) Visit www.axealis.com to get domain and hosting 2) Unlimited Bandwidth ,this mean unlimited data transmission for your client access. 2) Unlimited Space , you can upload file for unlimited . 3) Unlimited Email , many of email account can created . 5) SSL Security , used SSL / HTTPS to protect your web . 6) LINUX , WINDOWS and MAC , can access form many operating system. From martin at v.loewis.de Mon Apr 7 16:50:51 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Mon, 07 Apr 2008 22:50:51 +0200 Subject: Data structure recommendation? In-Reply-To: References: Message-ID: <47FA892B.1050608@v.loewis.de> > I know that foo.get() will be called many times for each foo.put(). Is > there any way to achieve O(1) performance for foo.get(), maybe via > some kind of hash function? Or is the best thing to use some kind of > binary search? If you know something about the density of the input values, O(1) is possible. E.g if there is a guarantee that there will be between 1 and 10 values per unit of input, then truncate the "event time" to the next-lower int, and use that as an index k into a list; the list item will be a list of events between k and k+1. As you know that there is an upper bound to the number of such events (10), you know that searching the list will take bounded (i.e. constant) time. Likewise, as you know that there will be atleast one event per (k,k+1) interval, you know that you have to scan only one list. If you know no such thing, you'll have to use a binary search. Regards, Martin From fredrik at pythonware.com Sat Apr 5 09:34:19 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 15:34:19 +0200 Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! In-Reply-To: <47f77d0a$0$17945$5fc30a8@news.tiscali.it> References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <47f77d0a$0$17945$5fc30a8@news.tiscali.it> Message-ID: Francesco Bochicchio wrote: > It should be added here that in Python you have several ways get around > this Tkinter limitation and pass an user argument to the callback. Once > upon a time , back in Python 1.x, I used to do something like this: > > class CallIt: > def __init__(self, f, *args): > self.f = f > self.args = args > def __call__(self): > return apply(self.f, self.args) > > and then, to do what the OP wanted to do: > command = CallIt(self.Display, 1) > > but nowadays, you can achieve the same effect with: > command = functtools.partial(self.Display,1) or, much clearer for non-guru programmers, and a lot easier to extend when you realize that you have to do more than just calling a single method, use a local callback function: def do_display(): self.Display(1) w = Button(callback=do_display) local functions are cheap in Python; creating a new one for each button is very inexpensive. for very simple callbacks, you can use the lambda syntax as well: w = Button(callback=lambda: self.Display(1)) From lists at cheimes.de Tue Apr 22 17:15:44 2008 From: lists at cheimes.de (Christian Heimes) Date: Tue, 22 Apr 2008 23:15:44 +0200 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: <480e5367$0$17314$9b622d9e@news.freenet.de> References: <480e5367$0$17314$9b622d9e@news.freenet.de> Message-ID: <480E5580.4090302@cheimes.de> Martin v. L?wis schrieb: >> 2. Kill the subprocess in a platform independent manner (i.e. no third party >> modules and no hacks). > > What's wrong with the .terminate method of the Popen object? It's brand new ;) Christian From tjreedy at udel.edu Wed Apr 2 15:22:24 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 2 Apr 2008 15:22:24 -0400 Subject: Understanding bmp image files References: <2537c458-b4d5-480d-8407-168a2b59a27e@u10g2000prn.googlegroups.com> Message-ID: "pranav" wrote in message news:2537c458-b4d5-480d-8407-168a2b59a27e at u10g2000prn.googlegroups.com... | Hello, | I want to read a BMP file, do some processing and then write it in a | new file. The problem is in the third step. For reading the file, i | have converted the file into decimal numbers, representing the pixel | values. Then i perform calculations on those decimal numbers. Now i am | unable to convert those into the format as required by the "bmp" file. | Any one, who is into image reading/manipulation, please help. I would look into PIL, PyGame, and Numeric/Numpy. From arnodel at googlemail.com Tue Apr 15 07:14:00 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Tue, 15 Apr 2008 04:14:00 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> Message-ID: On 11 Apr, 21:29, Gabriel Genellina wrote: > ... If the numbers to be rounded come from a > measurement, the left column is not just a number but the representant > of an interval (as Mikael said, the're quantized). 2.3 means that the > measurement was closer to 2.3 than to 2.2 or 2.4 - that is, [2.25, > 2.35) (it doesn't really matter which side is open or closed). It is > this "interval" behavior that forces the "round-to-even-on-halves" > rule. > So, the numbers 1.6-2.4 on the left column cover the interval [1.55, > 2.45) and there is no doubt that they should be rounded to 2.0 because > all of them are closer to 2.0 than to any other integer. Similarly > [2.55, 3.45) are all rounded to 3. > But what to do with [2.45, 2.55), the interval represented by 2.5? We > can assume a uniform distribution here even if the whole distribution > is not (because we're talking of the smallest measurable range). So > half of the time the "true value" would have been < 2.5, and we should > round to 2. And half of the time it's > 2.5 and we should round to 3. > Rounding always to 3 introduces a certain bias in the process. > Rounding randomly (tossing a coin, by example) would be fair, but > people usually prefer more deterministic approaches. If the number of > intervals is not so small, the "round even" rule provides a way to > choose from that two possibilities with equal probability. > So when we round 2.5 we are actually rounding an interval which could > be equally be rounded to 2 or to 3, and the same for 3.5, 4.5 etc. If > the number of such intervals is big, choosing the even number helps to > make as many rounds up as rounds down. > If the number of such intervals is small, *any* apriori rule will > introduce a bias. Great explanation! -- Arnaud From gagsl-py2 at yahoo.com.ar Tue Apr 1 23:42:55 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 02 Apr 2008 00:42:55 -0300 Subject: generator functions: why won't this work? References: Message-ID: En Tue, 01 Apr 2008 23:56:50 -0300, escribi?: > I'm trying to understand generator functions and the yield keyword. > I'd like to understand why the following code isn't supposed to work. > (What I would have expected it to do is, for a variable number of > arguments composed of numbers, tuples of numbers, tuples of tuples, > etc., the function would give me the next number "in sequence") > #################################### > def getNextScalar(*args): > for arg in args: > if ( isinstance(arg, tuple)): > getNextScalar(arg) > else: > yield arg > #################################### You're not the first one in getting confused. After all, this schema works well for other recursive constructs. Perhaps a progression of working code samples will help to understand what happens here. The simplest thing would be to just print the items as they're encountered, in a recursive call: py> data = (1, 2, (3,4,(5,6),7)) py> py> print "1) using print" 1) using print py> py> def getNextScalar(args): ... for arg in args: ... if isinstance(arg, tuple): ... getNextScalar(arg) ... else: ... print arg ... py> getNextScalar(data) 1 2 3 4 5 6 7 Now one could try to collect the numbers in a list: py> print "2) using extend" 2) using extend py> py> def getNextScalar(args): ... result = [] ... for arg in args: ... if isinstance(arg, tuple): ... result.extend(getNextScalar(arg)) ... else: ... result.append(arg) ... return result ... py> getNextScalar(data) [1, 2, 3, 4, 5, 6, 7] Note that we use two different list methods: for individual items, we use "append", but for tuples we use "extend" in the recursive call. If extend weren't available, we could emulate it with append: py> print "3) using append" 3) using append py> py> def getNextScalar(args): ... result = [] ... for arg in args: ... if isinstance(arg, tuple): ... for item in getNextScalar(arg): ... result.append(item) ... else: ... result.append(arg) ... return result ... py> getNextScalar(data) [1, 2, 3, 4, 5, 6, 7] See how we need an additional loop to iterate over the results that we get from the recursive call. Now instead of building an intermediate result list, we delegate such task over the caller, and we use a generator that just yields items; this way, we remove all references to the result list and all result.append calls become yield statements. The inner loop has to remain the same. The yield statement acts somewhat as an "append" over an outer list created by the generator's caller. py> print "4) using yield" 4) using yield py> py> def getNextScalar(args): ... for arg in args: ... if isinstance(arg, tuple): ... for item in getNextScalar(arg): ... yield item ... else: ... yield arg ... py> getNextScalar(data) py> list(getNextScalar(data)) [1, 2, 3, 4, 5, 6, 7] I hope it's more clear now why you have to use yield on the recursive call too. Perhaps this: yield *iterable could be used as a shortcut for this: for __temp in iterable: yield __temp -- Gabriel Genellina From ellingt8877 at gmail.com Mon Apr 28 01:51:09 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:51:09 -0700 (PDT) Subject: crack drug Message-ID: <649bde32-5ed1-4655-94a1-6607b245ff33@1g2000prg.googlegroups.com> crack drug http://crack.cracksofts.com From gagsl-py2 at yahoo.com.ar Mon Apr 14 22:06:47 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 14 Apr 2008 23:06:47 -0300 Subject: Dynamic use of property() fails References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> Message-ID: En Mon, 14 Apr 2008 22:43:39 -0300, andrew cooke escribi?: > This is my first attempt at new classes and dynamic python, so I am > probably doing something very stupid... After reading the how-to for > descriptors at http://users.rcn.com/python/download/Descriptor.htm I > decided I would make an object that returns attributes on read, but on > setting calls an arbitrary function. > > My code looks like: > class ActiveDAO(object): > def __init__(self): > self.__values__ = {} > def add_field(self, name, value, on_change): > self.__values__[name] = value > def get(self): return self.__values__[name] > def set(self, new_value): self.__values__[name] = > on_change(new_value) > def delete(self): raise AttributeError > self.__dict__[name] = property(get, set, delete) > > However, when I try to use this (in a test) with code like: > dao = ActiveDAO() > dao.add_field("name", "value", lambda _: None) > assertEqual(dao.name, "value") > > I get a failure because lookup of the attribute is returning > "". > > That is quite reasonable, but I was under the expression that some > magic was supposed to happen, as described in the document referenced > above! The "magic" happens when the descriptor is found in the *class*, not in the instance. I think it's detailed in Hettinger's document. Do you actually want "per-instance" defined properties? __special__ names are reserved for Python internal usage; don't use them. Implementation-only attributes ("private" ones) are spelled with a single underscore. -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Tue Apr 1 13:05:09 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 14:05:09 -0300 Subject: class super method References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> <0eb3ee4e-82e2-419a-8e7b-4931f7b4effa@c26g2000prf.googlegroups.com> Message-ID: En Tue, 01 Apr 2008 11:21:48 -0300, Ed Leafe escribi?: > On Apr 1, 2008, at 8:43 AM, George Sakkis wrote: > >> Pehaps, at least as long as you make sure that all superclasses have a >> compatible signature - which in practice typically means accept >> arbitrary *args and **kwargs in every class in the hierarchy like your >> example. Good luck figuring out what's wrong if it's not used >> consistently. > > See my comment above. If you do not know what you're doing, you > shouldn't be doing it. This is not the fault of super(); it's the > fault of a poor programmer. And I used generic *args and **kwargs in > the method sig since I was using made-up class names and methods. > Would you have reacted more favorably if I had used (self, foo, bar) > instead? Then *all* classes must use exactly the same signature for that method. You don't know which one will be the next class in the MRO order used by super() so you can't adjust the arguments in any way. In the case of __init__, the only practical way is to make all of them take keyword arguments exclusively and use *args and **kwarsg. See the earlier links for a simple failing example. >> Also doOurCustomStuffBeforeTheSuperCall() works as long as all >> ancestor methods to be called need the same CustomStuff massaging. > > Oh, c'mon. Of course that's the case; if you are overriding method > behavior, it is your job as the programmer to ensure that. Again, this > is nothing to do with the super() function, and everything to do with > the abilities of the developer. How do you know that? super may call a method on a different class that is *not* an ancestor of the current class. Again, for examples, see the earlier links. >> In a sentence, it's better than nothing but worse than anything. > I guess I must be the world's most amazing Python developer, as I've > used super() extensively for years without ever suffering any of the > pitfalls you and others describe. Maybe you're a very lucky man! -- Gabriel Genellina From roy at panix.com Sun Apr 27 22:55:54 2008 From: roy at panix.com (Roy Smith) Date: Sun, 27 Apr 2008 22:55:54 -0400 Subject: Regular Expression - Matching Multiples of 3 Characters exactly. References: Message-ID: In article , blaine wrote: > Hey everyone, > For the regular expression gurus... > > I'm trying to write a string matching algorithm for genomic > sequences. I strongly suggest you stop trying to reinvent the wheel and read up on the Biopython project (http://biopython.org/wiki/Main_Page). From gherron at islandtraining.com Thu Apr 24 11:16:06 2008 From: gherron at islandtraining.com (Gary Herron) Date: Thu, 24 Apr 2008 08:16:06 -0700 Subject: [Python-Dev] annoying dictionary problem, non-existing keys In-Reply-To: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> Message-ID: <4810A436.2060705@islandtraining.com> bvidinli wrote: > i use dictionaries to hold some config data, > such as: > > conf={'key1':'value1','key2':'value2'} > and so on... > > when i try to process conf, i have to code every time like: > if conf.has_key('key1'): > if conf['key1']<>'': > other commands.... > > > this is very annoying. > in php, i was able to code only like: > if conf['key1']=='someth' > > in python, this fails, because, if key1 does not exists, it raises an exception. > > MY question: > is there a way to directly get value of an array/tuple/dict item by key, > as in php above, even if key may not exist, i should not check if key exist, > i should only use it, if it does not exist, it may return only empty, > just as in php.... > > i hope you understand my question... > > See http://docs.python.org/lib/typesmapping.html for a description of the get method of dictionaries. Also look at the key in dict syntax on the same page. Gary Herron From iddw at hotmail.com Tue Apr 1 12:42:30 2008 From: iddw at hotmail.com (Dave Hansen) Date: Tue, 1 Apr 2008 09:42:30 -0700 (PDT) Subject: Homework help References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> <7xfxu5ft1s.fsf@ruckus.brouhaha.com> <8e1f6963-1cdd-4afe-9ea5-f1886ed452ab@d21g2000prf.googlegroups.com> Message-ID: On Apr 1, 11:29 am, bobby.con... at gmail.com wrote: > On Apr 1, 12:17 pm, Paul Rubin wrote: > > > bobby.con... at gmail.com writes: > > > I don't necessarily want the answers, but need help on how to approach > > > it/the steps i need to solve the problems > > > What parts are you having difficulty with? Are there some course > > materials and have you read them yet? > > I just don't know how to start the problems off Well, for the first problem, the first line is def howMany(item,lst): If you can't figure out where to go from there, start here: http://docs.python.org/tut/tut.html Regards, -=Dave From dotancohen at gmail.com Thu Apr 17 20:46:04 2008 From: dotancohen at gmail.com (Dotan Cohen) Date: Fri, 18 Apr 2008 03:46:04 +0300 Subject: Python for Series 40 Nokia? Message-ID: <880dece00804171746t61017950wdd3571d7671867d1@mail.gmail.com> I had once heard something about python running on a Series 40 Nokia, but I am unable to google anything concrete. Might it have been Jython? Is there a known implementation of Python for the series 40 (which is not Symbian, by the way)? Will Jython work in such an environment? Thanks in advance. Dotan Cohen http://what-is-what.com http://gibberish.co.il ?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? From Bryan.Fodness at gmail.com Thu Apr 10 13:22:44 2008 From: Bryan.Fodness at gmail.com (Bryan.Fodness at gmail.com) Date: Thu, 10 Apr 2008 10:22:44 -0700 (PDT) Subject: get array element Message-ID: <820d8589-8529-46af-907a-90ebaac4a6f5@a22g2000hsc.googlegroups.com> I have an array, and I would like to get the indice value. a = array([13,14,15,16]) I would like something like a.getindice(15) If I want 15 it would return 2 From gagsl-py2 at yahoo.com.ar Sat Apr 5 20:20:57 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 05 Apr 2008 21:20:57 -0300 Subject: Tkinter, add pressed buttons onto string display string, how to? References: <57605958-5589-4ebe-abdf-73c2d14c8a82@u10g2000prn.googlegroups.com> <65q8juF2gq610U2@mid.uni-berlin.de> <649d9748-c389-411d-9794-9753ddf434b0@d1g2000pra.googlegroups.com> Message-ID: En Sat, 05 Apr 2008 18:23:50 -0300, escribi?: >> Just like the message says: You are trying to use `str` (on the right >> hand >> side of the assignment) before anything is bound to that name. >> > > i know but i want the variable str(which i found out is a reserved > word so i changed it) to be accessible all over __init__ right? > so i tried to delcare it in __init__ in the beginning of the framework > class but then when i access it in the method Display i get that > error. > > so how should i declare this variable to be able to access it > everywhere? It should be an instance attribute: self.expr by example. Remember to initialize it with '' in __init__ > i want another method "calculate" that can access the same string > later and do the calculations(writing some other code now that will > read and interpret that). Ok, use self.expr in calculate. Something like this: def calculate(self): self.expr = str(eval(self.expr)) and probably force a repaint of the calculator display. You may want to use a try/except block to catch any errors. -- Gabriel Genellina From ewertman at gmail.com Sun Apr 20 14:37:12 2008 From: ewertman at gmail.com (Eric Wertman) Date: Sun, 20 Apr 2008 11:37:12 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: <614c8e94-3b1d-47e0-9051-dd05fe722183@l42g2000hsc.googlegroups.com> On Apr 20, 1:29 pm, "Gabriel Genellina" wrote: > En Sun, 20 Apr 2008 13:42:05 -0300, Matthew Woodcraft escribi?: > > > An alternative scheme for describing the block structure could be > > useful in other cases, though. For example, if you wanted to support > > putting snippets of Python in configuration files, or spreadsheet > > cells. > > [...] If someone wrote a library for this and it proved popular, I expect it > > would be considered for the standard library. > > There is "pindent.py" in the Tools/scripts directory: > > # ... When called as "pindent -r" it assumes its input is a > # Python program with block-closing comments but with its indentation > # messed up, and outputs a properly indented version. > > # A "block-closing comment" is a comment of the form '# end ' > # where is the keyword that opened the block ... > > def foobar(a, b): > if a == b: > a = a+1 > elif a < b: > b = b-1 > if b > a: a = a-1 > # end if > else: > print 'oops!' > # end if > # end def foobar > > -- > Gabriel Genellina That's actually not a lot different than what you have to do now in a web page.. It still seems overcomplicated though. I'm not sure why this is worse: def foobar(a, b): if a == b: a = a+1; elif a < b: b = b-1; if b > a: a = a-1; else: print 'oops!';; It's just ultimately whitespace insensitive. Whether that's a good or bad design is a debate that can be argued either way, but other languages do it, and it's handy sometimes. I agree that it makes it much easier to produce illegible code. Developing for a browser is arguably annoying and hackish enough, without having to stick in comments and such to enforce indenting. From marco at sferacarta.com Thu Apr 17 05:49:44 2008 From: marco at sferacarta.com (Marco Mariani) Date: Thu, 17 Apr 2008 11:49:44 +0200 Subject: I just killed GIL!!! In-Reply-To: <87hce1t8k5.fsf@physik.rwth-aachen.de> References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <52vid5-cvl2.ln1@ozzie.tundraware.com> <87hce1t8k5.fsf@physik.rwth-aachen.de> Message-ID: Torsten Bronger wrote: >>> If I were you I would keep it a secret until a Hollywood producer >>> offers big bucks for the film rights. >> Who would play Guido, I wonder? > > Ralf M?ller. No other. And the GIL killer? Clive Owen, Matt Damon, Mark Wahlberg? From steve at holdenweb.com Sat Apr 12 17:45:26 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 17:45:26 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> Message-ID: <48012D76.2070703@holdenweb.com> One last thing: I am sorry that despite my efforts I was unable to teach you what you need to learn. I can only hope someone else manages to get the point across. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gagsl-py2 at yahoo.com.ar Mon Apr 7 10:26:23 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 07 Apr 2008 11:26:23 -0300 Subject: Calling CVF-Fortran-dll with ctypes and simple structure References: <60915c2d-0c0d-42fc-8b02-5fb58e13a20c@p25g2000hsf.googlegroups.com> Message-ID: En Mon, 07 Apr 2008 09:19:03 -0300, Michael Sch?fer escribi?: > Hi all, > > I deal with the old problem passing characters from python to a > fortran dll build with CFV6.6c. > I reduced our complex structure to a simple one. Here is the Fortran > code: > > SUBROUTINE DEMO2L(s) > > C sample for calling CVF6.6c-DLLs from > C vb/vba/python with simple structure > > !DEC$ ATTRIBUTES DLLEXPORT::DEMO2L > > TYPE rcDEMO > INTEGER a > REAL b > CHARACTER c*9 > END TYPE > > TYPE(rcDEMO) :: s > C > WRITE(*,*) s.a, s.b, s.c > C sample calculation: > s.a = s.a*10 > s.b = s.b**2.3 > s.c = 'Sample' > > RETURN > END > > From VB the calling is very simple: > > Declare Sub DEMO2L Lib "release\demo1l.dll" (ByRef k As rcDEMO) > > Type rcDEMO > a As Long > b As Single > c As String * 9 > End Type > > Dim k As rcDEMO > > Sub run() > > k.a = 2 > k.b = 3# > k.c = "Test" > > Call DEMO2L(k) > > Debug.Print k.a, k.b, k.c > > End Sub > > and result to: " 20 12,5135 Sample" > > When I try this from python: > > from ctypes import * > > class rcDemo(Structure): > _fields_ = [ > ('a', c_int), > ('b', c_float), > ('c', c_char_p), Try with ('c', c_char*9). You may have alignment issues with such odd size, but in this case it doesnt matter so much as it's the last field in the struct. (If both Fortran and VB say "char*9", why did you choose a pointer here?) -- Gabriel Genellina From fetchinson at googlemail.com Sun Apr 20 17:06:57 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Sun, 20 Apr 2008 14:06:57 -0700 Subject: cherrypy-webapp-code? In-Reply-To: <31715060-fca3-4a03-b5c4-b6403315aa76@a23g2000hsc.googlegroups.com> References: <31715060-fca3-4a03-b5c4-b6403315aa76@a23g2000hsc.googlegroups.com> Message-ID: > anyone have a small cherrypy-webapp and are willing to post the code. > could be a nonsense-app just wanna see some code. > -- > http://mail.python.org/mailman/listinfo/python-list > Did you try google? And the cherrypy website? -------------- next part -------------- An HTML attachment was scrubbed... URL: From itskrithika at gmail.com Fri Apr 25 19:22:37 2008 From: itskrithika at gmail.com (terry) Date: Fri, 25 Apr 2008 16:22:37 -0700 (PDT) Subject: Pyserial - send and receive characters through linux serial port Message-ID: Hi, I am trying to send a character to '/dev/ttyS0' and expect the same character and upon receipt I want to send another character. I tired with Pyserial but in vain. Test Set up: 1. Send '%' to serial port and make sure it reached the serial port. 2. Once confirmed, send another character. I tried with write and read methods in Pyserial but no luck. Can you help? Thanking you all. T From jwashin at vt.edu Fri Apr 25 08:46:53 2008 From: jwashin at vt.edu (Jim Washington) Date: Fri, 25 Apr 2008 08:46:53 -0400 Subject: convert xhtml back to html In-Reply-To: <48117759.4090909@behnel.de> References: <4810E5CC.2000503@behnel.de> <48117759.4090909@behnel.de> Message-ID: <4811D2BD.1060208@vt.edu> Stefan Behnel wrote: > bryan rasmussen top-posted: > >> On Thu, Apr 24, 2008 at 9:55 PM, Stefan Behnel wrote: >> >>> from lxml import etree >>> >>> tree = etree.parse("thefile.xhtml") >>> tree.write("thefile.html", method="html") >>> >>> http://codespeak.net/lxml >>> >> wow, that's pretty nice there. >> >> Just to know: what's the performance like on XML instances of 1 GB? >> > > That's a pretty big file, although you didn't mention what kind of XML > language you want to handle and what you want to do with it. > > lxml is pretty conservative in terms of memory: > > http://blog.ianbicking.org/2008/03/30/python-html-parser-performance/ > > But the exact numbers depend on your data. lxml holds the XML tree in memory, > which is a lot bigger than the serialised data. So, for example, if you have > 2GB of RAM and want to parse a serialised 1GB XML file full of little > one-element integers into an in-memory tree, get prepared for lunch. With a > lot of long text string content instead, it might still fit. > > However, lxml also has a couple of step-by-step and stream parsing APIs: > > http://codespeak.net/lxml/parsing.html#the-target-parser-interface > http://codespeak.net/lxml/parsing.html#the-feed-parser-interface > http://codespeak.net/lxml/parsing.html#iterparse-and-iterwalk > If you are operating with huge XML files (say, larger than available RAM) repeatedly, an XML database may also be a good option. My current favorite in this realm is Sedna (free, Apache 2.0 license). Among other features, it has facilities for indexing within documents and collections (faster queries) and transactional sub-document updates (safely modify parts of a document without rewriting the entire document). I have been working on a python interface to it recently (zif.sedna, in pypi). Regarding RAM consumption, a Sedna database uses approximately 100 MB of RAM by default, and that does not change much, no matter how much (or how little) data is actually stored. For a quick idea of Sedna's capabilities, the Sedna folks have put up an on-line demo serving and xquerying an extract from Wikipedia (in the range of 20 GB of data) using a Sedna server, at http://wikidb.dyndns.org/ . Along with the on-line demo, they provide instructions for deploying the technology locally. - Jim Washington From yves at zioup.com Tue Apr 15 19:26:16 2008 From: yves at zioup.com (Yves Dorfsman) Date: Tue, 15 Apr 2008 23:26:16 GMT Subject: how to remove \n in the list In-Reply-To: References: <2ba667ab-6818-47eb-8595-79ed970728f7@q1g2000prf.googlegroups.com> Message-ID: Dan Bishop wrote: >>> lines[:] = [line.rstrip('\n') for line in lines] >> What is the point of the [:] after lines ? How different is it with or >> without it ? > > It causes the result to be stored in the existing list. > If we do: lines = [line.rstrip('\n') for line in lines] lines is now a new list, the old list as no reference to it, and will be discarded by the gc, right ? So we're not really saving any space here ? If we do: lines[:] = [line.rstrip('\n') for line in lines] We reuse an existing list, therefore we are saving the time it takes to create a new list ? So this is a performance issue ? Thanks. Yves. http://www.SollerS.ca From gagsl-py2 at yahoo.com.ar Mon Apr 21 22:01:44 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 23:01:44 -0300 Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: En Mon, 21 Apr 2008 16:42:41 -0300, Ross Ridge escribi?: >> Ideally, I can implement some form of cross-compatible code >> so that I need maintain only a single code base, and I have managed to >> do so on a number of fronts (with the help of Robert A. Clark): Perhaps you can manage to keep your code compatible with all versions, but AFAIK the reccomended strategy is to write code compatible with Python 2.6 and use the 2to3 tool to generate the 3.0 source. And *not* edit the 3.0 code unless one wants to maintain two branches. >> Overall, I think I'm getting off pretty easy, but then pyparsing is a >> small module with very limited use of the standard lib. > > Has the standard library changed that much? I thought was it mainly the > deletion of old seldom used modules that happens in new releases anyways. *and* renaming of old module names that don't follow PEP8, and merging others into packages for better structure. That's another point where using the 2to3 tool is necesary -it takes care of such changes- unless one wants to maintain two branches. -- Gabriel Genellina From phil at riverbankcomputing.com Thu Apr 3 17:37:41 2008 From: phil at riverbankcomputing.com (Phil Thompson) Date: Thu, 3 Apr 2008 22:37:41 +0100 Subject: State of ctypes Support on HP-UX? In-Reply-To: References: <200804031153.26234.phil@riverbankcomputing.com> <200804031429.19025.phil@riverbankcomputing.com> Message-ID: <200804032237.41757.phil@riverbankcomputing.com> On Thursday 03 April 2008, Thomas Heller wrote: > Phil Thompson schrieb: > > On Thursday 03 April 2008, Thomas Heller wrote: > >> Phil Thompson schrieb: > >> > Could somebody confirm how well ctypes is supported on HP-UX (for both > >> > PA-RISC and Itanium) for both Python v2.4 and v2.5? > >> > >> I cannot answer your question, but if you want to try it out > >> yourself there is the HP testdrive program: http://www.testdrive.hp.com/ > > > > Thanks for the pointer. Unfortunately the answer is that there is no > > support (at least for ctypes v1.0.2). > > I tried out the current SVN version of Python myself. ctypes doesn't > compile on the PA system (the libffi assembler code fails to compile), but > I did get it to work on the Itanium system with gcc (I had to set > LDSHARED="gcc -shared" before configuring). Even the ctypes unittests pass > on this system. > > In theory, the ctypes code should be backwards-compatible with python 2.4, > although in practice it currently is not, but IMO it should be possible to > change it accordingly. > > Would this be useful to you? Thanks, but no. A combination of ctypes for Windows and the dl module for everything else will probably meet my needs. Phil From alexelder at gmail.com Wed Apr 23 15:13:40 2008 From: alexelder at gmail.com (alexelder at gmail.com) Date: Wed, 23 Apr 2008 12:13:40 -0700 (PDT) Subject: Calling Python code from inside php References: <679e9oF2mti63U1@mid.uni-berlin.de> Message-ID: <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> On Apr 23, 7:42 pm, "Diez B. Roggisch" wrote: > vijay schrieb: > > > Hi > > I have a python code performing some computation for me.I have a > > html page which passes certain argumnets to a php page.This php page > > needs to pass on the value to the Python class and get the result > > back. > > How do I go about this?? > > Write a commandline-app in python, that does the work for you. Invoke > that using php. > > Or use something like pyphp - but I haven't used it, can't comment on > its usability/support etc. > > Diez A simple yet dangerous and rather rubbish solution (possibly more of a hack than a real implementation) could be achieved by using a technique described above: I would look into pyphp though. This method has so many issues attached to it it's hardly worth bothering with. I'm with Nick when I say why on earth are you needing to call Python from within PHP as opposed to using only Python or only PHP? Alex. From wwzaygvm at gmail.com Wed Apr 16 16:54:31 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 13:54:31 -0700 (PDT) Subject: xilisoft video converter crack Message-ID: <20a0eba4-9668-405c-837d-f39d0976d417@x19g2000prg.googlegroups.com> xilisoft video converter crack http://cracks.12w.net F R E E C R A C K S From steve at holdenweb.com Thu Apr 24 10:34:50 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 10:34:50 -0400 Subject: annoying dictionary problem, non-existing keys In-Reply-To: <36e8a7020804240713y61f143bend2bd0b6bf3ebd8eb@mail.gmail.com> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> <36e8a7020804240713y61f143bend2bd0b6bf3ebd8eb@mail.gmail.com> Message-ID: <48109A8A.5030902@holdenweb.com> Thanks for your reply. Another point to note: if you get a personal reply (often you will just see replies on the list, but sometimes people will also mail you directly) it is usual to make sure the list gets copied in any reply. I hope you don't mind that I am sending a copy of this message to the list, so everyone understands that you are just learning the rules. regards Steve bvidinli wrote: > Thank you for your answer, > Please be tolerant a bit... > > > 2008/4/24, Steve Holden : >> bvidinli wrote: >> >>> I posted to so many lists because, >>> >>> this issue is related to all lists, >>> >> No, it isn't, as you would have discovered had you bothered to read the >> purpose of each list. For example, python-help and python-dev are mutually >> exclusive. >> > > May be, anyway, > >>> this is an idea for python, >>> >> It isn't an idea for Python at all. It's you, telling the world that you >> haven't really used Python much and haven't read the manuals but would >> nevertheless like us to consider your ideas for improving the language. >> > > I am using python for months, > currently i am using it by means of Object oriented, multi thread > applications.... > but i dont see myself a python expert yet.. > >>> this is related to development of python... >>> >>> >> No it isn't. Python already has the feature you requested. > > No, python does not have, php way is simpler, shorter. > list.get('key') is a solution, but not the thing i want... i think > list['key'] is simpler, > this is my idea... > python is generally better than php, but some aspects of php is > better... such as web programming.. > >> >>> why are you so much defensive ? >>> >>> >> Terry wasn't being defensive, he was protecting you form the abue you would >> receive of you kept posting to the wrong list! > > Please be tolerant a bit.. > The person who post may be a person who does not know list rules... > Why hurt such people ? lets concentrate our energy on solutions... > >> >>> i think ideas all important for development of python, software.... >>> i am sory anyway.... hope will be helpful. >>> >>> >> We hope you will be helpful too. For now it would probably be best to start >> by posting your questions on the regular comp.lang.python group, which is >> generally suitable for beginners who know something about programming. If >> you are new to programming as well then the python-tutor list would be more >> useful. >> > > I am not a beginner for programming, not for python, > i am not python expert too... > i do programming since 1988, > i do web/php/system programming since 2000, python for 5 months.. > >> Ask with a little humility (the people who answer questions here are doing >> it out of the goodness of their hearts, remember) and soon you will be able >> to pass their assistance on, returning the favor they did for you. >> >> Welcome to the Python community. > > Anyway, thank you for your answers, your guides, i am happy to hear from you, > to hear from python community. > At least, it is a live community... :) > > see you > Bahattin. > > > >> regards >> Steve >> >> >>> 2008/4/24, Terry Reedy : >>> >>>> Python-dev is for discussion of development of future Python. Use >>>> python-list / comp.lang.python / gmane.comp.python.general for usage >>>> questions. >>>> >> -- >> Steve Holden +1 571 484 6266 +1 800 494 3119 >> Holden Web LLC http://www.holdenweb.com/ >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From python at bdurham.com Tue Apr 29 08:23:51 2008 From: python at bdurham.com (python at bdurham.com) Date: Tue, 29 Apr 2008 08:23:51 -0400 Subject: How to unget a line when reading from a file/stream iterator/generator? In-Reply-To: References: <5e3854fa-557f-4475-8123-346346767097@k13g2000hse.googlegroups.com> Message-ID: <1209471831.15157.1250461645@webmail.messagingengine.com> Duncan, > If speed is an issue then it may be better to avoid the test altogether ... Thanks for your suggestion. Regards, Malcolm From steve at holdenweb.com Thu Apr 17 00:53:14 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 17 Apr 2008 00:53:14 -0400 Subject: Python plugin for Firefox In-Reply-To: References: Message-ID: zelegolas wrote: > Hi, > > It's may be a stupid question but do you if someone tried to create a > python plugin for firefox? > If you know an Open Source project let me know... > > Thanks Look for references to Mark Hammond's PyCon keynote and the work he's been doing with the Mozilla team. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From dennis.benzinger at gmx.net Thu Apr 3 09:08:36 2008 From: dennis.benzinger at gmx.net (Dennis.Benzinger@gmx.net) Date: Thu, 3 Apr 2008 06:08:36 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> Message-ID: <0c7fd327-7b96-4c20-8c74-a528e280b5f3@r9g2000prd.googlegroups.com> On Apr 3, 1:37 pm, tinn... at isbd.co.uk wrote: > What's the neatest and/or most efficient way of testing if one of a > set of strings (contained in a dictionary, list or similar) is a > sub-string of a given string? > [...] You could use the Aho-Corasick algorithm . I don't know if there's a Python implementation yet. Dennis Benzinger From arnodel at googlemail.com Sun Apr 27 13:22:23 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 27 Apr 2008 18:22:23 +0100 Subject: Mapping and Filtering Help for Lists References: Message-ID: Zethex writes: > Alright I got asked today by a friend this question, which obviously I > couldn't help him with. > > He needs to get rid of words in a string referring to an already given list > then needs to map them using a function he already has. Ill explain this > better by giving an example :P > > Say ur given these lists: > > un_words = ['a', 'the', 'he', 'she', 'uses', 'with'] > alterns = [ ['book', 'textbook', 'notepad'], ['pencil', 'pen', 'pacer'] ] > > The problem asks to create a "compareandremove" so that you can use it on a > string, to remove the words from the string that are contained in un_words. > > The remaining words then need to be compared to the alterns list and either > bring back the word if no matches or bring back the list. To better explain > that i'll use an example. > > If i do compareandremove('notepad a pencil with desk') > > I need it so it removes words contained in un_words, so "a" and "with"; > then compares the remaining words to alterns to find a match. > > This should bring back: > > ['notepad', 'book', 'textbook', 'pencil', 'pen', 'pacer', 'desk'] > > > Any tips on how to create this function or maybe the function itself so I > can then show him how to do it. > > Thank you. Look away now if you don't want a complete solution! un_words = ['a', 'the', 'he', 'she', 'uses', 'with'] alterns = [ ['book', 'textbook', 'notepad'], ['pencil', 'pen', 'pacer'] ] # these words will be replaced with nothing wordmap = dict((w, []) for w in un_words) # these words will be replaced with the list of their synonyms for wordlist in alterns: for word in wordlist: wordmap[word] = wordlist def compareandremove(sentence): return [x for w in sentence.split() for x in wordmap.get(w, [w])] # Example >>> compareandremove('notepad a pencil with desk') ['book', 'textbook', 'notepad', 'pencil', 'pen', 'pacer', 'desk'] -- Arnaud From jeffrey at fro.man Fri Apr 4 17:12:17 2008 From: jeffrey at fro.man (Jeffrey Froman) Date: Fri, 04 Apr 2008 14:12:17 -0700 Subject: Python2.5 and MySQLdb References: Message-ID: writeson wrote: > I'm running a CentOS 4 server and have installed Python2.5 on there > (it's our development machine) in preparation of moving to Python2.5 > everywhere. All looks good with our code and 2.5, except where it > comes to MySQLdb, I can't get that to install on the machine. It > generates a huge lists of errors and warnings from gcc when I run the > python2.5 setup.py build script that comes with the tar file. Anyone > have any suggestions? MySQLdb compiles fine for me with python2.5 on CentOS-4. I suggest that you examine the end of that long of warnings and errors to determine why it won't compile on your machine. Jeffrey From balta96428 at gmail.com Wed Apr 23 05:58:38 2008 From: balta96428 at gmail.com (balta96428 at gmail.com) Date: Wed, 23 Apr 2008 02:58:38 -0700 (PDT) Subject: the sims2 nude patch Message-ID: the sims2 nude patch http://cracks.12w.net F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Sun Apr 6 16:28:08 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 06 Apr 2008 17:28:08 -0300 Subject: traceback.print_exc() supposed to stop exception propagation. References: <69-dnW_JftMHvGTanZ2dneKdnZydnZ2d@bt.com> Message-ID: En Sun, 06 Apr 2008 16:16:46 -0300, Sami escribi?: > In the Python book that I am using to learn the language it says that > the traceback.print_exc() can be used to stop exception propagation and > make the program keep running. Either the book is wrong or you have misinterpreted what you read. From http://docs.python.org/lib/module-sys.html: excepthook(type, value, traceback) This function prints out a given traceback and exception to sys.stderr. When an exception is raised and uncaught, the interpreter calls sys.excepthook with three arguments, the exception class, exception instance, and a traceback object. In an interactive session this happens just before control is returned to the prompt; in a Python program this happens just before the program exits. The handling of such top-level exceptions can be customized by assigning another three-argument function to sys.excepthook. -- Gabriel Genellina From darcy at druid.net Tue Apr 22 17:18:42 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Tue, 22 Apr 2008 17:18:42 -0400 Subject: Spawning a thread and printing dots until it finishes In-Reply-To: References: Message-ID: <20080422171842.f1a7e7d8.darcy@druid.net> On Tue, 22 Apr 2008 13:45:32 -0700 Dennis Lee Bieber wrote: > On Tue, 22 Apr 2008 13:25:07 -0400, "D'Arcy J.M. Cain" > declaimed the following in comp.lang.python: > > > > I think that there are two things that you need to wrap your head > > around before understanding what is happening here. First, threads are > > NOT pre-emptive. Unless your thread gives up the processor it will run > > forever. The sleep call is one way to give up the processor. > > > When did that change take place? > > As I recall, the Python interpreter is supposed to preempt a (pure > Python) thread after some 10 or 100 (I think the value changed some > years ago) bytecodes. It sounds to me like you are talking about when the interpreter grabs and releases the GIL but I was talking about when it releases the processor. I certainly never said that sleep() was the only way to release the processor. I was not actually aware that running a certain number of bytecodes was another way but as I said, we never saw the code for the thread so we don't know what it is doing or what extensions it might be calling. It *may* be pure Python but we don't know. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From johng at neutralize.com Tue Apr 8 12:01:46 2008 From: johng at neutralize.com (monk.e.boy) Date: Tue, 8 Apr 2008 09:01:46 -0700 (PDT) Subject: urlparse http://site.com/../../../page.html References: <9fdd0d8b-785a-4363-be6a-75f993527754@c65g2000hsa.googlegroups.com> Message-ID: > http://4suite.org/ Thanks for the info, for the curious I found some docs on how to use it (pretty simple): http://4suite.org/docs/CoreManual.xml and the code is in the CVS under "4Suite/Ft/Lib/Uri.py" The license is similar to the Apache license, so it is pretty liberal :-) I'd like to see this in the Python Lib :-) Thanks, monk.e.boy From happyriding at yahoo.com Wed Apr 30 02:59:53 2008 From: happyriding at yahoo.com (happyriding) Date: Tue, 29 Apr 2008 23:59:53 -0700 (PDT) Subject: sed to python: replace Q References: <48180348$0$34534$742ec2ed@news.sonic.net> Message-ID: <5721ede4-9341-4708-8acf-6cc00207b3e0@k13g2000hse.googlegroups.com> On Apr 29, 11:27?pm, Raymond wrote: > For some reason I'm unable to grok Python's string.replace() function. line = "abc" line = line.replace("a", "x") print line --output:-- xbc line = "abc" line = line.replace("[apq]", "x") print line --output:-- abc Does the 5 character substring "[apq]" exist anywhere in the original string? From http Sun Apr 27 16:10:37 2008 From: http (Paul Rubin) Date: 27 Apr 2008 13:10:37 -0700 Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: <7x3ap75a9u.fsf@ruckus.brouhaha.com> "Terry Reedy" writes: > Can this alternative be made easier by adding a context manager to gc > module to use with 'with' statements? Something like > > with gc.delay() as dummy: > That sonuds worth adding as a hack, but really I hope there can be an improved gc someday. From rickbking at comcast.net Wed Apr 9 14:29:50 2008 From: rickbking at comcast.net (Rick King) Date: Wed, 09 Apr 2008 14:29:50 -0400 Subject: Pydev shell (was: Re: Stani's python ide 'spe' editor problem) In-Reply-To: References: Message-ID: <47FD0B1E.6010600@comcast.net> I guess this is appropriate to the list... the funky things in eclipse that were happening are hard to describe, but first let me say that none of the other ide's had any funky things happening so I don't think it was my code. That said: I'm working on a command line bulk file renaming tool (using cmd.py) in which I can redirect input to a batch file if I want to, and redirect output to a file (for testing purposes). Running within an eclipse console, I could run through one batch file after which input returns to the console, and then try to run through the same batch file again by typing in my 'run' command; suddenly it would be as if a bunch of the tool's commands were executed having little (but something) to do with the batch of commands I just ran, producing a lot of output that didn't really make any sense. When I stepped through the debugger it got really weird: for example, at one point I went to the variables pane and clicked to open 'self' and it was at that moment that all this output came through on the console. Absolutely nonsensical. I'll check out the new stuff for eclipse. -Rick Fabio Zadrozny wrote: >> Anyway, I am extremely frustrated. I've tried other ide's: pythonwin (I >> found it inadequate for my purposes - why is a command line prompt >> displayed in a dialog window?) - eclipse (editor is just ok, shell does >> not have command history(!), and then *really* funky things started >> happening that I could not explain and so had to stop using it) - idle >> is good for small things and ok for larger projects but limited in general. >> > > Hi Rick, > > The new release has an actual console shell (with code-completion, > history, etc: see http://pydev.sourceforge.net/ for more details). > Aside from that, which 'funky' things started happening? > > Cheers, > > Fabio > > > From flarefight at googlemail.com Sat Apr 26 08:26:58 2008 From: flarefight at googlemail.com (flarefight at googlemail.com) Date: Sat, 26 Apr 2008 05:26:58 -0700 (PDT) Subject: Loading associated files References: <74862697-da58-4eb7-8d60-09aaef54b7ad@j22g2000hsf.googlegroups.com> <07ac86a6-e125-40d9-bfe9-7c3286437bef@z72g2000hsb.googlegroups.com> Message-ID: <779515ba-bcf3-4e55-befd-103ffc506a88@r66g2000hsg.googlegroups.com> I can't get this to work (I am on XP SP2 by the way and using Python 2.5), I wrote a very simple script to test the idea: import sys for arg in sys.argv: print arg raw_input("Done") #Merely to slow the program down so i can see output and then setup a file extension .xyz, placed it in the registry, can get a .xyz file to work as a python script so the registry setup is fine, but when i try and put the parameter to the above program and a %1 (or even without) it gets the following error message from windows: C:\...\hmm.xyz is not a valid Win32 application. any suggestions?? From nospam at invalid.com Thu Apr 24 23:48:58 2008 From: nospam at invalid.com (Jack) Date: Fri, 25 Apr 2008 03:48:58 GMT Subject: ctypes: return a pointer to a struct References: <846077c3-beaf-4ccd-83be-1e2168c4f7fe@c65g2000hsa.googlegroups.com> <4dda2bd7-3348-496e-a594-35da0a34d4de@x35g2000hsb.googlegroups.com> Message-ID: That worked. Thank you! >> AttributeError: 'LP_IP2LocationRecord' object has no attribute >> 'country_short' > > As it says, LP_IP2LocationRecord has no attribute called > 'country_short'. IP2LocationRecord does. > > Use the 'contents' attribute to dereference the pointer. That is: > > yourstruct.contents.country_short From altami0762 at gmail.com Thu Apr 17 15:51:29 2008 From: altami0762 at gmail.com (altami0762 at gmail.com) Date: Thu, 17 Apr 2008 12:51:29 -0700 (PDT) Subject: anydvd 3.9.2.1 crack Message-ID: <8c091084-5aa6-46d9-930f-0ec0f1d0823e@m44g2000hsc.googlegroups.com> anydvd 3.9.2.1 crack http://cracks.12w.net F R E E C R A C K S From coleb2 at gmail.com Wed Apr 9 16:22:53 2008 From: coleb2 at gmail.com (Brian Cole) Date: Wed, 9 Apr 2008 14:22:53 -0600 Subject: wrapping C functions in python In-Reply-To: References: Message-ID: <54b165660804091322w690e5e64x85c3d8f082b411b2@mail.gmail.com> We use the following SWIG (www.swig.org) typemap to perform such operations: %typemap(in) (int argc, char **argv) { if (!PySequence_Check($input)) { PyErr_SetString(PyExc_ValueError,"Expected a sequence"); return NULL; } $1 = PySequence_Length($input); $2 = (char**)alloca($1*sizeof(char*)); for (Py_ssize_t i = 0; i < $1; ++i) { PyObject *o = PySequence_GetItem($input, i); $2[i] = PyString_AsString(o); } } That one works for mapping a python sequence (such as a list) into the argc, argv arguments commonly passed into main. -Brian On Wed, Apr 9, 2008 at 2:13 PM, Paul Anton Letnes wrote: > Hello etc. > > > I am a "scientific" user of Python, and hence have to write some performance > critical algorithms. Right now, I am learning Python, so this is a "newbie" > question. > > I would like to wrap some heavy C functions inside Python, specifically a > wavelet transform. I am beginning to become aquainted with the functions > PyArg_ParseTuple() and Py_BuildValue(). However, I am unable to figure out > how to pass Python list -> C function or C array -> return value in Python. > I manage to build and run the C function, print to screen, pass string as > argument, return an int, etc. The thing which is missing is the magic > array/list... > > > Thanks in advance! I fart in your general direction. > Paul. > -- > http://mail.python.org/mailman/listinfo/python-list > From victorsubervi at gmail.com Thu Apr 17 12:15:19 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 17 Apr 2008 11:15:19 -0500 Subject: More Fun With MySQL and Images In-Reply-To: <1208446793.4433.18.camel@aalcdl07.lib.unc.edu> References: <4dc0cfea0804170742g39965533yfaf260bcf4da4301@mail.gmail.com> <4dc0cfea0804170752x789cce43xe1ea6aeba498ccd1@mail.gmail.com> <1208446793.4433.18.camel@aalcdl07.lib.unc.edu> Message-ID: <4dc0cfea0804170915v60624660g7e6631b49388aaec@mail.gmail.com> Yeah, I figured that out between posts ;) On Thu, Apr 17, 2008 at 10:39 AM, J. Cliff Dyer wrote: > On Thu, 2008-04-17 at 09:52 -0500, Victor Subervi wrote: > > Never mind. Apparently, these tags throw it for that loop: > > print '\n' > > I?m surprised they would, but gratified I found the problem. > > Victor > > > > > > Why does that surprise you? A jpeg has a well-defined header that tells > whatever application is rendering it what to look for. By putting those > tags at the beginning of the data sent to your browser, you're no longer > getting a well-formed jpeg. The header is wrong. > > As an experiment, if you're on *nix, or have access to a decent shell, > try this: > > $ echo '' > newfile.jpg > $ cat /path/to/any_normal_jpeg >> newfile.jpg > $ echo '' >> newfile.jpg > > If you don't have access to a shell, open a JPEG with your favorite text > editor, and manually add "" to the beginning, and save it > out. > > Then try to open newfile in any piece of software of your choosing. > It's no longer a well-formed jpeg, so it won't work. That's exactly > what you're asking the browser to do. > > I guess this isn't really python related, so my apologies for that. > > Cheers, > Cliff > > > > > -- > Oook, > J. Cliff Dyer > Carolina Digital Library and Archives > UNC Chapel Hill > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From john106henry at hotmail.com Wed Apr 2 17:04:45 2008 From: john106henry at hotmail.com (John Henry) Date: Wed, 2 Apr 2008 14:04:45 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> <58deb8b8-bae9-4d43-b973-3d90846726cb@b5g2000pri.googlegroups.com> Message-ID: <83d5604a-4b6c-4a85-9fca-3fcee5010319@b5g2000pri.googlegroups.com> On Apr 2, 1:01 pm, John Henry wrote: > On Apr 1, 11:10 am, sprad wrote: > > > On Apr 1, 11:41 am, mdomans wrote: > > > > Python needs no evangelizing but I can tell you that it is a powerfull > > > tool. I prefer to think that flash is rather visualization tool than > > > programing language, and java needs a lot of typing and a lot of > > > reading. On the other hand python is simple to read and write, can be > > > debuged easily, is intuitive and saves a lot of time. It also supports > > > batteries included policy and you can't get more OO than python. > > > One advantage of Flash is that we can have something moving on the > > screen from day one, and add code to it piece by piece for things like > > keyboard or mouse control, more and more complex physics, etc. Is > > there an equivalent project in Python? > > I downloaded the "How to Think Like a Python Programmer" book and read > it. I think it's a fine reference book for the purpose you > indicated. > > Here's my 2 cents on the subject. > > I had been a volunteer mentor to my son's middle school robotic team > for several years and I have some experiences, therefore, in how kids > react to "programming". Granted, high school kids are "bigger kids" - > but they are kids nevertheless. > > Last summer, I experimented teaching my own kid Python. He was in 7th > grade going onto 8th grade. He was the main goto person for the > robotic team and had no trouble learning the common applications such > as the Microsoft Office suite, and had some experience in ICONic > programming (Lego Mindstorm). So, I tried to see what would happen if > he tries to learn Python - using somewhat similar approach you are > taking: start with something visually appealing on day one. Instead > of Flash, I used Pythoncard - a no-brainer Python GUI construction > toolkit. He was really excited seeing how easy it was to have tic-tae- > toe type program up so easily (we are taking minutes - not hours) and > was very interested and motivated to continue. So far so good. > However, once I start teaching him variables, expressions, loops, and > what not, I found that (by surprise) he had great difficulties > catching on. Not soon after that, we had to quit. > > We - as adults - take many things for granted and sometimes don't > remember, or don't understand how kids learn. My experience tells me > that in order to teach today's video game generation of kids, the > approach really has to be entirely visual. After I abandoned my > attempt to teach my kid Python, I started them on Robolab - a > simplified version of LabView and to my delight, they were able to > cook up a few simple programs (like fibonacci series and so forth) > without too much effort - although my own kid had some minor trouble > understanding the concept of a container (LabView's version of a > variable). > > I don't know if you have access to LabView or Robolab or similar > packages but if you do, I would highly recommend those. LabView is > every bit as powerful, full-featured, and "real-life" as many of the > other languages and I believe that kids will have a much easier time > learning computer programming with it. > > And you are going to teach them Java? Oh, please don't. Let the > colleges torture them. :=) BTW: I successfully taught them to program in machine language. We used lego parts to construct a psudo-turing machine with a 33 bit register, and used Lego Mindstorm to do the programming. It would read the position of the "register" (input), perform an operation, and outputs the answer. To do that, they have to break down a set of 2 numbers into binary form (via pencil and paper), set the flip switches (constructed w lego parts), hit a touch sensor to begin the operation. The robot would then read the position of the flip switches (via light sensor), interpret the first bit (operator: add or subtract), then interpret the next 32 bits as 2 numbers (I only allowed them to use addition, shift, and loops in their program), do the operation internally in decimal, convert the answer to binary, and "display" the result (output) using those switches. They take the result - convert it back to decimal (via pencil and papger) and see that the answer is indeed correct. Wow! My machine can add and subtract!!! They did all these without knowing that they learned the very basis of all computer programming - they just had lots of fun doing it. From corvettecraz92 at gmail.com Fri Apr 11 10:21:17 2008 From: corvettecraz92 at gmail.com (corvettecraz92 at gmail.com) Date: Fri, 11 Apr 2008 07:21:17 -0700 (PDT) Subject: text adventure game problem References: <4fb4fb0d-4cb2-4fcd-a207-a0341d92e82b@8g2000hsu.googlegroups.com> <7e1c3f97-ff17-4add-8d45-40f7b48dec4a@l64g2000hse.googlegroups.com> Message-ID: <17342e68-2593-43cc-aff0-af0e09e75d6d@a22g2000hsc.googlegroups.com> On Apr 11, 10:16?am, corvettecra... at gmail.com wrote: > On Apr 11, 1:40?am, Dennis Lee Bieber wrote: > > > On Thu, 10 Apr 2008 05:06:42 -0700 (PDT), corvettecra... at gmail.com > > declaimed the following in comp.lang.python: > > > > okay, that explains it... > > > could you provide a working example of a two-room game using your > > > method please so I can understand it better? Thanks in advance! > > > ? ? ? ? Okay... It isn't the best thought out system -- I have too > > many specific classes... It would probably be better to put actions into > > dictionaries and use some custom .getattr() to handle them. > > > ? ? ? ? Will four rooms, a hidden chunk of gold, and one other movable > > object suffice? Watch out for news client line wrapping. The only > > parsing done is of the form: verb object; no attempt to handle: verb > > direct_object filler indirect_object > > > -=-=-=-=-=-=- > > # > > # ? TAGS.py ? ? Text Adventure Game Shell > > # > > > # ? I've probably defined too many special classes here > > class Gobject(object): ?#Game object > > ? ? def __init__(self, name, description, hidden=False, fixed=True): > > ? ? ? ? self._name = name > > ? ? ? ? self._description = description > > ? ? ? ? self.hidden = hidden ? #hidden objects are not visible to > > EXAMINE > > ? ? ? ? self.fixed = fixed ? ? #fixed objects can not be taken > > ? ? def _getName(self): > > ? ? ? ? return self._name > > ? ? name = property(_getName) > > ? ? def _getDescription(self): > > ? ? ? ? return self._description > > ? ? description = property(_getDescription) > > > class Exit(Gobject): > > ? ? def __init__(self, description, target, hidden=False): > > ? ? ? ? super(Exit, self).__init__(None, description, hidden) > > ? ? ? ? self._target = target > > ? ? def _getTarget(self): > > ? ? ? ? return self._target > > ? ? target = property(_getTarget) > > > class Room(Gobject): ? ?#rooms (container object) > > ? ? def __init__(self, name, description, exits=None, details=None): > > ? ? ? ? super(Room, self).__init__(name, description, hidden=False, > > fixed=True) > > ? ? ? ? self._exits = exits > > ? ? ? ? if details: > > ? ? ? ? ? ? self._details = details ? ? #other objects that are inside > > the room > > ? ? ? ? else: > > ? ? ? ? ? ? self._details = {} > > ? ? def setExits(self, exits): > > ? ? ? ? self._exits = exits > > ? ? def go(self, ext): > > ? ? ? ? return self._exits.get(ext, None) > > ? ? def setDetails(self, details): > > ? ? ? ? self._details = details > > ? ? def addDetail(self, itm): > > ? ? ? ? self._details[itm.name] = itm > > ? ? def delDetail(self, name): > > ? ? ? ? if (name in self._details and > > ? ? ? ? ? ? not self._details[name].fixed): > > ? ? ? ? ? ? itm = self._details[name] > > ? ? ? ? ? ? del self._details[name] > > ? ? ? ? else: > > ? ? ? ? ? ? itm = None > > ? ? ? ? return itm > > ? ? def examine(self, name=None): > > ? ? ? ? if not name: return self.description > > ? ? ? ? if (name in self._details > > ? ? ? ? ? ? and not self._details[name].hidden): > > ? ? ? ? ? ? return self._details[name].description > > ? ? ? ? else: > > ? ? ? ? ? ? return None > > ? ? def _detailedDescription(self): > > ? ? ? ? items = "nothing of interest" > > ? ? ? ? if self._details: > > ? ? ? ? ? ? items = ", ".join([itm.name for itm in > > self._details.values() > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?if not itm.hidden]) > > ? ? ? ? exits = ", ".join([ext for ext in self._exits.keys() > > ? ? ? ? ? ? ? ? ? ? ? ? ? ?if not self._exits[ext].hidden]) > > ? ? ? ? #there must be at least one exit (the way you came in) > > ? ? ? ? return "%s. In the %s you see %s. Passages lead to %s." % > > (self._description, > > ?self.name, > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? items, > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? exits) > > ? ? description = property(_detailedDescription) > > > class Thing(Gobject): > > ? ? def __init__(self, name, description, parent, hidden=False, > > fixed=False): > > ? ? ? ? super(Thing, self).__init__(name, description, hidden, fixed) > > ? ? ? ? self.parent = parent > > ? ? def take(self): > > ? ? ? ? if self.fixed: > > ? ? ? ? ? ? return None > > ? ? ? ? else: > > ? ? ? ? ? ? self.hidden = False ? ? #if taken, one now can see it > > ? ? ? ? ? ? return self.parent.delDetail(self.name) > > ? ? def drop(self, parent): > > ? ? ? ? self.parent.delDetail(self.name) > > ? ? ? ? parent.addDetail(self) > > > class TriggerThing(Thing): > > ? ? def __init__(self, name, description, parent, > > ? ? ? ? ? ? ? ? ?hidden=False, fixed=True, triggers=None): > > ? ? ? ? super(TriggerThing, self).__init__(name, description, parent, > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?hidden, fixed) > > ? ? ? ? self._triggers = triggers > > ? ? def _detailedDescription(self): > > ? ? ? ? if self._triggers: > > ? ? ? ? ? ? items = ", ".join([itm.name for itm in > > self.parent._details.values() > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?if itm in self._triggers > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?and itm.hidden]) > > ? ? ? ? else: > > ? ? ? ? ? ? items = ", ".join([itm.name for item in > > self.parent._details.values() > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?if itm.hidden]) > > ? ? ? ? if not items: items = "nothing of interest" > > ? ? ? ? return "%s. In the %s you see %s." % (self._description, > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? self.name, > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? items) > > ? ? description = property(_detailedDescription) > > > class Money(Thing): > > ? ? # ? note: I've not worked out how to safely handle combining money > > objects > > ? ? def __init__(self, name, description, amount, parent, hidden=False, > > fixed=False): > > ? ? ? ? super(Money, self).__init__(name, description, parent, hidden, > > fixed) > > ? ? ? ? self._value = amount > > ? ? def _detailedDescription(self): > > ? ? ? ? return "%s pieces of gold" % self._value > > ? ? description = property(_detailedDescription) > > ? ? def combine(self, money): > > ? ? ? ? self._value += money._value > > > class Avatar(Gobject): > > ? ? def __init__(self, name, description, location, hidden=True, > > fixed=True): > > ? ? ? ? super(Avatar, self).__init__(name, description, hidden, fixed) > > ? ? ? ? self.location = location > > ? ? ? ? self._inventory = {} > > ? ? def addInv(self, itm): > > ? ? ? ? itm.hidden = False > > ? ? ? ? if itm.name in self._inventory: ?#presume only gold is > > duplicated > > ? ? ? ? ? ? self._inventory[itm.name].combine(itm) > > ? ? ? ? ? ? del itm > > ? ? ? ? else: > > ? ? ? ? ? ? self._inventory[itm.name] = itm > > ? ? def remInv(self, name): > > ? ? ? ? ? ?itm = self._inventory.get(name, None) > > ? ? ? ? ? ?if itm: del self._inventory[name] > > ? ? ? ? ? ?return itm > > ? ? def inv(self): > > ? ? ? ? return ", ".join([itm for itm in self._inventory.keys()]) > > > #create the universe -- first the raw rooms > > room1 = Room("empty room", > > ? ? ? ? ? ? ?"a completely empty room") > > room2 = Room("time passages", > > ? ? ? ? ? ? ?"a fourth-dimensional room having no fixed shape or size") > > room3 = Room("control room", > > ? ? ? ? ? ? ?"the control room of a TARDIS") > > room4 = Room("locker room", > > ? ? ? ? ? ? ?"a room full of storage spaces") > > > #create each exit > > exit1_2 = Exit("you squeeze through the mouse hole", room2) > > exit1_4 = Exit("you take the doorway", room4) > > exit2_3 = Exit("the TARDIS door opens and you pass in", room3, > > hidden=True) > > exit3_2 = Exit("you leave the TARDIS", room2) > > exit3_1 = Exit("you sneak deeper into the depths of the TARDIS", room1) > > exit4_1 = Exit("you move through the door", room1) > > exit2_1 = Exit("you take the wormhole out", room1) > > exit2_4 = Exit("you follow the light", room4) > > exit4_2 = Exit("you follow the shadow", room2) > > exit2_2a = Exit("as you enter the reddish passage you see yourself > > leaving the room", room2) > > exit2_2b = Exit("you feel a bit older as you take the blue passage", > > room2) > > exit2_2c = Exit("you feel confused as you cross webs of the timestream", > > room2) > > > #connect rooms to exits > > room1.setExits({"hole" : exit1_2, > > ? ? ? ? ? ? ? ? "door" : exit1_4}) > > room2.setExits({"tardis" : exit2_3, > > ? ? ? ? ? ? ? ? "wormhole" : exit2_1, > > ? ? ? ? ? ? ? ? "light" : exit2_4, > > ? ? ? ? ? ? ? ? "past" : exit2_2a, > > ? ? ? ? ? ? ? ? "future" : exit2_2b, > > ? ? ? ? ? ? ? ? "sideways" : exit2_2c}) > > room3.setExits({"out" : exit3_2, > > ? ? ? ? ? ? ? ? "in" : exit3_1}) > > room4.setExits({"door" : exit4_1, > > ? ? ? ? ? ? ? ? "shadow" : exit4_2}) > > > #create a few non-room objects > > container1 = Thing("closet", "an empty closet", room4, fixed=True) > > gold = Money("gold", None, 8, room4, hidden=True) > > container2 = TriggerThing("footlocker", "a fancy carved captain's > > chest", room4, > > ? ? ? ? ? ? ? ? ? ? ? ? ? fixed=True, triggers=[gold]) > > > room4.setDetails({container1.name : container1, > > ? ? ? ? ? ? ? ? ? container2.name : container2, > > ? ? ? ? ? ? ? ? ? gold.name : gold}) > > > #the tardis is both an exit and a thing > > tardis = Thing("tardis", "a beat-up type 40 TARDIS", room2, fixed=True) > > room2.setDetails({tardis.name : tardis}) > > > screwdriver = Thing("screwdriver", "a well worn sonic screwdriver", > > room3) > > room3.setDetails({screwdriver.name : screwdriver}) > > > player = Avatar("Wulfraed", "a nondescript individual", room1) > > > #note: no end conditions are defined > > while True: > > ? ? print player.location.description > > ? ? while True: > > ? ? ? ? cmdstr = raw_input("command> ").strip().lower() > > ? ? ? ? if cmdstr: break > > ? ? words = cmdstr.split() > > ? ? verb = words[0] > > ? ? if len(words) > 1: > > ? ? ? ? objct = words[1] > > ? ? else: > > ? ? ? ? objct = None > > ? ? if verb in ["look", "examine"]: > > ? ? ? ? if objct: > > ? ? ? ? ? ? desc = player.location.examine(objct) > > ? ? ? ? else: > > ? ? ? ? ? ? desc = player.location.examine() > > ? ? ? ? if desc: > > ? ? ? ? ? ? print desc > > ? ? ? ? else: > > ? ? ? ? ? ? print "I don't see that here" > > ? ? elif verb in ["grab", "take"]: > > ? ? ? ? if objct: > > ? ? ? ? ? ? itm = player.location.delDetail(objct) > > ? ? ? ? ? ? if itm: > > ? ? ? ? ? ? ? ? player.addInv(itm) > > ? ? ? ? ? ? ? ? print "%s taken" % itm.name > > ? ? ? ? ? ? else: > > ? ? ? ? ? ? ? ? print "I can not %s the %s" % (verb, objct) > > ? ? ? ? else: > > ? ? ? ? ? ? print "%s what?" % verb > > ? ? elif verb in ["drop", "leave"]: > > ? ? ? ? if objct: > > ? ? ? ? ? ? itm = player.remInv(objct) > > ? ? ? ? ? ? if itm: > > ? ? ? ? ? ? ? ? player.location.addDetail(itm) > > ? ? ? ? ? ? ? ? print "%s dropped" % itm.name > > ? ? ? ? ? ? else: > > ? ? ? ? ? ? ? ? print "I don't have the %s" % objct > > ? ? ? ? else: > > ? ? ? ? ? ? print "%s what?" % verb > > ? ? elif verb in ["walk", "run", "go"]: > > ? ? ? ? if objct: > > ? ? ? ? ? ? ext = player.location.go(objct) > > ? ? ? ? ? ? if ext: > > ? ? ? ? ? ? ? ? print ext.description > > ? ? ? ? ? ? ? ? player.location = ext.target > > ? ? ? ? ? ? else: > > ? ? ? ? ? ? ? ? print "I can't go that way" > > ? ? ? ? else: > > ? ? ? ? ? ? print "%s where?" % verb > > ? ? elif verb... > > > read more ? > > I still can't run that....after fixing the simple stuff like 'invalid > syntax', there's the "Name examine is not defined." > So... I still can't run that....after fixing the simple stuff like 'invalid syntax', there's the "Name examine is not defined." So... From mattheww at chiark.greenend.org.uk Mon Apr 14 08:33:41 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 14 Apr 2008 13:33:41 +0100 (BST) Subject: urllib working differently when run from crontab References: Message-ID: In article , VictorMiller wrote: > I've written a python script which, using urllib, and urllib2 will > fetch a number of files that that I'm interested in from various > websites (they're updated everyday). When I run the script from my > command line everything works as intended. However, when the script > is run from crontab every single url that I attempt to open gets > "connection refused". Has anyone ever seen anything like this? If > so, what's causing it, and what can I do about it? Perhaps you have an http_proxy environment variable set in the interactive session but not in cron's environment? -M- From victorsubervi at gmail.com Wed Apr 9 10:15:52 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 9 Apr 2008 10:15:52 -0400 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> Message-ID: <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> On Wed, Apr 9, 2008 at 1:14 AM, Gabriel Genellina wrote: > > Thanks. I apparently am printing some holder for the image. I stripped > > out > > most of it with this > > content[0][0] > > but then I am left with this: > > > > array('c', '\xff\xd8\xff\xe0\\0\x10JFI...) > > How do I extract an image from that? > > print content.tostring() Now *that* gave me something that *looks* a lot more like an image from a programmers perspective, but still no image... ????JFIF... Actually, it does not copy and paste well, but you can see it for the moment here: http://livestocksling.com/test/python/Shop/display_es2.py So, how do I convert *that* to a real live image? > Or perhaps, replace that line with content.tofile(sys.stdout) Printed nothing. > >> > print 'Content-Type: image/jpeg\r\n' > >> > print '\n' > >> > print content > >> > print '\n' > >> > cursor.close() > >> > > >> > test() > > >> > The commented out line gives me a leading less than sign...and that?s > >> > it. What do? > > Try to understand now *why* you got a single character with your previous > code. No clue :/ BTW, for purposes of documentation, it appears that, when sending the form with the image to the script that processes the form, the following is inadvisable: form = cgi.FieldStorage() pic1 = form.getfirst('pic1', '') This appears to work better: form = cgi.FieldStorage() imgfile=open("pixel.gif",'rb') pixel = imgfile.read() pic1 = form.getfirst('pic1', pixel) because it gives a binary default. The string appears to screw things up. Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at holdenweb.com Sat Apr 12 09:11:32 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 09:11:32 -0400 Subject: Tremendous slowdown due to garbage collection In-Reply-To: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> Message-ID: <4800B504.4010601@holdenweb.com> [...] > I would suggest to configure the default behaviour of the garbage > collector in such a way that this squared complexity is avoided > without requiring specific knowledge and intervention by the user. Not > being an expert in these details I would like to ask the gurus how > this could be done. > I hope this should be at least technically possible, whether it is > really desirable or important for a default installation of Python > could then be discussed once the disadvantages of such a setting would > be apparent. > > Thanks a lot for your consideration, and best regards, > Andreas > I think the linguists of the world should write better automated translation systems. Not being an expert in these details I would like to ask the gurus how it could be done. There are going to be pathological cases in any memory allocation scheme. The fact that you have apparently located one calls for you to change your approach, not for the finely-tuned well-conceived garbage collection scheme to be abandoned for your convenience. If you had made a definite proposal that could have been evaluated you request would perhaps have seemed a little more approachable. You might want to consider trying Jython, or IronPython, or PyPy, each of which comes with a different flavor of garbage collection, to see if one of the other approaches suits you better. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From spamgrinder.trylater at ggmail.com Mon Apr 21 23:49:27 2008 From: spamgrinder.trylater at ggmail.com (AlFire) Date: Mon, 21 Apr 2008 22:49:27 -0500 Subject: why objects of old style classes are instances of 'object' In-Reply-To: <66p7eeF2l44iiU2@mid.uni-berlin.de> References: <4807641F.8030209@gmail.com> <66p7eeF2l44iiU2@mid.uni-berlin.de> Message-ID: <6755i2F2hjsb8U1@mid.individual.net> Diez B. Roggisch wrote: > > But not everything is a newstyle-class: > >>>> class Foo: pass > ... >>>> isinstance(Foo, object) > True >>>> isinstance(Foo, type) > False >>>> class Bar(object): pass > ... >>>> isinstance(Bar, type) > True >>>> > thx for explanation. but more I look at it less and less I like the notation of new-style-class definition. what is an added value of adding "(object)" since it is already an object. Any insight? Note: I am not a language purist, more a pragmatic who like a good style. Andy From timr at probo.com Thu Apr 10 01:37:35 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 10 Apr 2008 05:37:35 GMT Subject: Data structure recommendation? References: <663744510804071339g639bfdccl63de8be66fe52df1@mail.gmail.com> Message-ID: <6o9rv35m5sfgvjvm6h94n12850jkar8n4m@4ax.com> "Steven Clark" wrote: > >Thanks for the reply. Can you explain how I could be bitten by >floating point precision here? >I'm familiar with how&why 1.3*3 != 3.9, etc., but I'm not sure how it >applies here, or what you are gaining by converting to int. Well, it depends on how you get your floating point numbers. I assume you won't be using hard-coded floating point constants as your indices. Instead, you'll be computing them from data in files from somewhere. That's where you have the opportunity to have one index that is 1.6-0.4 and one index that is 0.8+0.4, and the two won't be the same. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From sjmachin at lexicon.net Sat Apr 5 18:55:04 2008 From: sjmachin at lexicon.net (John Machin) Date: Sat, 5 Apr 2008 15:55:04 -0700 (PDT) Subject: RELEASED Python 2.6a2 and 3.0a4 References: <47F68547.1040802@v.loewis.de> Message-ID: On Apr 5, 5:45 am, "Martin v. L?wis" wrote: > > The Windows x86 MSI installer is missing for both 2.6 and 3.0. > > And likely will continue to do so for some time. > > Someone's got strange definitions of "missing"! For each there's a link on the the ptyhon.org website, and a caveat about non-Administrator installation ... If it's missing, then what do I expect to find in the 11.7Mb 2.6a2 msi that is downloading as I type? From bbxx789_05ss at yahoo.com Fri Apr 18 20:40:27 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Fri, 18 Apr 2008 17:40:27 -0700 (PDT) Subject: How to print a unicode string? References: <54e7dba7-f7f2-4aa7-81f9-922e3bf6e6cd@m73g2000hsh.googlegroups.com> Message-ID: <5f2ef8e7-8de7-40c8-b23f-0a86780f042e@l64g2000hse.googlegroups.com> On Apr 18, 6:36?pm, 7stud wrote: > On Apr 18, 5:38?pm, damonwisc... at gmail.com wrote: > > > > > I'd like to print out a unicode string. > > > I'm running Python inside Emacs, which understands utf-8, so I want to > > force Python to send utf-8 to sys.stdout. > > > From what I've googled, I think I need to set my locale. I don't > > understand how. > > > import locale > > print locale.getlocale() > > --> (None,None) > > print locale.getdefaultlocal() > > --> ('en_GB','cp1252') > > print locale.normalize('en_GB.utf-8') > > --> en_GB.UTF8 > > locale.setlocale(locale.LC_ALL,'en_GB.UTF8') > > --> ?locale.Error: unsupported locale setting > > > I'd be grateful for advice. > > Damon. > > u_str = u'hell\u00F6 w\u00F6rld' ?#o's with umlauts > > print u_str.encode('utf-8') > > --output:-- > hell? w?rld Or maybe you want this: u_str = u'hell\u00F6 w\u00F6rld' regular_str = u_str.encode('utf-8') print repr(regular_str) --output:-- 'hell\_x_c3\_x_b6 w\_x_c3\_x_b6rld' #underscores added to keep your browser from rendering the utf-8 characters From bj_666 at gmx.net Sun Apr 27 12:40:41 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 27 Apr 2008 16:40:41 GMT Subject: removing extension References: Message-ID: <67jok9F2o7iv7U2@mid.uni-berlin.de> On Sun, 27 Apr 2008 15:06:54 +0000, Matt Nordhoff wrote: > Arnaud Delobelle wrote: >> More simply, use the rsplit() method of strings: >> >>>>> path = r'C:\myimages\imageone.jpg' >>>>> path.rsplit('.', 1) >> ['C:\\myimages\\imageone', 'jpg'] >> >> >>>>> path = r"C:\blahblah.blah\images.20.jpg" >>>>> path.rsplit('.', 1) >> ['C:\\blahblah.blah\\images.20', 'jpg'] >> >> HTH > > There's os.path.splitext(), which probably does just about exactly that. Not exactly. In the case of no extension `os.path.splitext()` still works: In [14]: 'foo/bar.txt'.rsplit('.') Out[14]: ['foo/bar', 'txt'] In [15]: 'foo/bar'.rsplit('.') Out[15]: ['foo/bar'] In [16]: os.path.splitext('foo/bar') Out[16]: ('foo/bar', '') Ciao, Marc 'BlackJack' Rintsch From uniontelecardsindia at gmail.com Tue Apr 22 17:11:27 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:11:27 -0700 (PDT) Subject: Hunkie black gays ass ramming hardcore action Message-ID: <5c7b4584-17ac-4df9-b653-cc692e39e0fa@d45g2000hsc.googlegroups.com> Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From lists at cheimes.de Tue Apr 22 18:59:54 2008 From: lists at cheimes.de (Christian Heimes) Date: Wed, 23 Apr 2008 00:59:54 +0200 Subject: python has memory leak? In-Reply-To: <1d48c77d-cc93-41ce-b644-1a8e52713e1d@b64g2000hsa.googlegroups.com> References: <1d48c77d-cc93-41ce-b644-1a8e52713e1d@b64g2000hsa.googlegroups.com> Message-ID: <480E6DEA.1010701@cheimes.de> yzghan at gmail.com schrieb: > The version of my python is: > Python 2.4.4 Stackless 3.1b3 060516 (#71, Oct 31 2007, 14:22:28) [MSC ^^^^^^^^^ This is the wrong list to ask for memory leaks of Stackless ;) Christian From alex.gaynor at gmail.com Sat Apr 26 21:01:47 2008 From: alex.gaynor at gmail.com (alex.gaynor at gmail.com) Date: Sat, 26 Apr 2008 18:01:47 -0700 (PDT) Subject: How do I say "Is this a function"? References: <96f62c7c-f951-4dc3-9af3-6cdd74cfa23b@v26g2000prm.googlegroups.com> Message-ID: <522faa0a-f1c5-417d-9a57-012196931370@b64g2000hsa.googlegroups.com> callable(func) returns whether something is callable(will return true for classes, functions, and objects with __call__ methods). On Apr 26, 6:25?pm, Dan Bishop wrote: > On Apr 26, 6:17 pm, John Henry wrote: > > > > > How do I determine is something a function? > > > For instance, I don't want to relying on exceptions below: > > > def f1(): > > ? ?print "In f1" > > > def f3(): > > ? ?print "In f3" > > > def others(): > > ? ?print "In others" > > > for i in xrange(1,3): > > ? ?fct = "f%d()"%(i+1) > > ? ?try: > > ? ? ? exec fct > > ? ?except: > > ? ? ? others() > > > I wish to say: > > > ? ?if value of fct is a funtion, invoke it, otherwise invoke others(). > > > Thanks, > > hasattr(fct, '__call__') > > And be careful about using the exec statement. From ivan.illarionov at gmail.com Thu Apr 10 16:31:08 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Thu, 10 Apr 2008 13:31:08 -0700 (PDT) Subject: Module Conflicts References: <1592fad3-996b-4f62-ac12-42aff8272c21@8g2000hsu.googlegroups.com> Message-ID: On Apr 10, 2:33 am, Jose wrote: > I have a module named math.py in a package with some class > definitions. I am trying to import the standard python math module > inside of math.py but It seems to be importing itself. Is there any > way around this problem without renaming my math.py file? Yes, if you are using Python 2.5 from __future__ import absolute import after this `import math` will always import standard math module and `from . import math` will import your module. -- Ivan From sturlamolden at yahoo.no Sun Apr 20 18:33:52 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sun, 20 Apr 2008 15:33:52 -0700 (PDT) Subject: Nested lists, simple though References: Message-ID: On Apr 21, 12:25 am, Zethex wrote: > Anyway the amount of [[]] do increase over time. Im just wondering is there > a simple way to add these together so they become 1 simple list, so it would > be ['computer'....'asus'] etc without the nested list. Its random the > amount each time so i cant just go a[0]+a[1]. > Thank you if you can help Does this answer your question? >>> a = [1,2,3] >>> a.extend([4,5,6]) >>> a [1, 2, 3, 4, 5, 6] From jarausch at skynet.be Sun Apr 6 12:16:02 2008 From: jarausch at skynet.be (Helmut Jarausch) Date: Sun, 06 Apr 2008 18:16:02 +0200 Subject: append to a sublist - please help Message-ID: <47f8f743$0$2983$ba620e4c@news.skynet.be> Hi, I must be blind but I don't see what's going wrong with G=[[]]*2 G[0].append('A') G[1].append('B') print G[0] gives ['A', 'B'] as well as print G[1] I was expecting ['A'] and ['B'] respectively. Many thanks for enlightening me, Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany From skanemupp at yahoo.se Fri Apr 18 12:10:31 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 18 Apr 2008 09:10:31 -0700 (PDT) Subject: tkinter, canvas, get color of image? References: <0e4c9708-dbe9-4f29-ac31-34f7298f2624@m1g2000pre.googlegroups.com> Message-ID: On 16 Apr, 00:46, Bryan Oakley wrote: > skanem... at yahoo.se wrote: > > On 13 Apr, 19:19, Bryan Oakley wrote: > >> skanem... at yahoo.se wrote: > >>> mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\elmapovic.gif') > >>> w.create_image(10, 10, image = mapq, anchor = NW) > >>> after doing this is there any possibility of getting the > >>> characteristics of the GIF-picture(or bitmap if i use that)? > >>> it would be very helpfull if i for example could do something like > >>> canvas.getcolor(image, mouseclick.x,mouseclick.y) if u get the point. > >>> get the color of the image where i clicked. > >> The image isn't "painted" on the canvas, so to answer your specific > >> question, no, you can't get the color of a pixel on the canvas in the > >> way that you ask. > > >> However, when you click on the canvas you can get the item that was > >> clicked on and the x/y of the click. From that you can figure out which > >> pixel of the image is under the cursor. And from that you can query the > >> image for the color of a specific pixel. > > > how do i get the item? > >http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_image-... > > > with any of those methods? > > > when i click the mouse i can get event.object u mean? > > You can use find_closest to find the object closest to the x,y of the > event. You can also do find_withtag(tk.CURRENT) which returns the item > under the mouse pointer. Exception in Tkinter callback Traceback (most recent call last): File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ return self.func(*args) File "C:\Users\saftarn\Desktop\pythonkod\mapexperiments \mapgetobject.py", line 17, in callback undermouse=find_closest(master.CURRENT) NameError: global name 'find_closest' is not defined from Tkinter import * master = Tk() w = Canvas(master, width=400, height=625) w.pack(expand = YES, fill = BOTH) mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\images \something.gif') w.create_image(30, 30, image = mapq, anchor = NW) def key(event): print "pressed", repr(event.char) def callback(event): clobj=event.widget ## undermouse=find_withtag(master.CURRENT) undermouse=find_closest(master.CURRENT) print repr(undermouse) w.bind("", key) w.bind("", callback) w.pack() mainloop() From fr5478bey at gmail.com Sat Apr 26 11:39:19 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:39:19 -0700 (PDT) Subject: tiberium wars crack Message-ID: tiberium wars crack http://cracks.00bp.com F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Sat Apr 12 02:22:08 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 12 Apr 2008 03:22:08 -0300 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <47ff8489$0$6841$2d805a3e@textnews.eweka.nl> Message-ID: En Fri, 11 Apr 2008 11:31:42 -0300, Michel Bouwmans escribi?: > Gabriel Genellina wrote: >> Another annoying thing with the Qt license is that you have to choose it >> at the very start of the project. You cannot develop something using the >> open source license and later decide to switch to the commercial licence >> and buy it. > > Unless you're a company with a risk of being checked for legal software > etc., you can always ignore that allthough not very legal. I just ignore Qt itself. -- Gabriel Genellina From erikwickstrom at gmail.com Thu Apr 17 22:30:33 2008 From: erikwickstrom at gmail.com (erikcw) Date: Thu, 17 Apr 2008 19:30:33 -0700 (PDT) Subject: Database vs Data Structure? Message-ID: <61bf5f46-e917-4a98-b87f-8e5087cb07f7@a23g2000hsc.googlegroups.com> Hi, I'm working on a web application where each user will be creating several "projects" in there account, each with 1,000-50,000 objects. Each object will consist of a unique name, an id, and some meta data. The number of objects will grow and shrink as the user works with their project. I'm trying to decided whether to store the objects in the database (each object gets it's own row) or to use some sort of data-structure (maybe nested dictionaries or a custom class) and store the pickled data-structure in a single row in the database (then unpickle the data and query in memory). A few requirements: -Fast/scalable (web app) -able to query objects based on name and id. -will play nicely with versioning (undo/redo) Any input on the best way to go? Thanks! Erik From Lie.1296 at gmail.com Fri Apr 11 14:33:56 2008 From: Lie.1296 at gmail.com (Lie) Date: Fri, 11 Apr 2008 11:33:56 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> Message-ID: On Apr 11, 10:19 pm, Mikael Olofsson wrote: > cokofree... at gmail.com commented about rounding towards even numbers > from mid-way between integers as opposed to for instance always rounding > up in those cases: > > > Strange request though, why do you need it that way, because 2.5 is > > CLOSER to 3 than to 2... > > That's exactly how I was taught to do rounding in what-ever low-level > class it was. The idea is to avoid a bias, which assumes that the > original values are already quantized. Assume that we have values > quantized to one decimal only, and assume that all values of this > decimal are equally likely. Also assume that the integer part of our > numbers are equally likely to be even or odd. Then the average rounding > error when rounding to integers will be 0.05 if you always round up when > the decimal is 5. If you round towards an even number instead when the > decimal is 5, then you will round up half of those times, and round down > the other half, and the average rounding error will be 0. That's the > idea. Of course you could argue that it would be even more fair to make > the choice based on the tossing of a fair coin. That old-school rounding method you're taught is based on a wrong assumption of the nature of number. In the past, rounding algorithm is based on this: Original => (RoundUp(u|d|n), RoundNearestEven(u|d|n) ... 1.0 => 1(n), 1(n) 1.1 => 1(d), 1(d) 1.2 => 1(d), 1(d) 1.3 => 1(d), 1(d) 1.4 => 1(d), 1(d) 1.5 => 2(u), 2(u) 1.6 => 2(u), 2(u) 1.7 => 2(u), 2(u) 1.8 => 2(u), 2(u) 1.9 => 2(u), 2(u) 2.0 => 2(n), 2(n) 2.1 => 2(d), 2(d) 2.2 => 2(d), 2(d) 2.3 => 2(d), 2(d) 2.4 => 2(d), 2(d) 2.5 => 3(u), 2(d) 2.6 => 3(u), 3(u) 2.7 => 3(u), 3(u) 2.8 => 3(u), 3(u) 2.9 => 3(u), 3(u) ... In this used-to-be-thought-correct table, Round Ups algorithm have 2 Unrounded, 8 Round Down, and 10 Round Ups which seems incorrect while Round Even have 2 Unrounded, 9 Round Down, and 9 Round Up which seems correct. The misunderstanding comes from a view that thinks that there is such thing as Not Rounded while in fact the only number that is Not Rounded is 1 and 2 while 1.0 and 2.0 must still be rounded, in practice we can just say that all number must be rounded somewhere. Original => (RoundUp(u|d), RoundNearestEven(u|d) ... 1.0 => 1(d), 1(d) 1.1 => 1(d), 1(d) 1.2 => 1(d), 1(d) 1.3 => 1(d), 1(d) 1.4 => 1(d), 1(d) 1.5 => 2(u), 2(u) 1.6 => 2(u), 2(u) 1.7 => 2(u), 2(u) 1.8 => 2(u), 2(u) 1.9 => 2(u), 2(u) 2.0 => 2(d), 2(d) 2.1 => 2(d), 2(d) 2.2 => 2(d), 2(d) 2.3 => 2(d), 2(d) 2.4 => 2(d), 2(d) 2.5 => 3(u), 2(d) 2.6 => 3(u), 3(u) 2.7 => 3(u), 3(u) 2.8 => 3(u), 3(u) 2.9 => 3(u), 3(u) ... In this table, we consider that a number is rounded down when the number is equal to truncated value (the number without fractional part), while round up is equal to truncated value + 1 or truncated value -1 if value is negative (Actually this is not round-half-up algorithm, it's a round-half-away-from-zero algorithm, but lets just consider that to be the same for now). In this revised table, you get 10 round ups and 10 round down (i.e. Average Rounding Error == 0), while by rounding to nearest even you get 9 round up and 11 round down (i.e. Average Rounding Error != 0). > Note that if you do not have quantized values and assuming that the > fraction part is evenly distributed between 0 and 1, than this whole > argument is moot. The probability of getting exactly 0.5 is zero in that > case, just as the probability of getting any other specified number is zero. Another mistake, in an unquantized value the probability of getting exactly 0.5 (or any other number specified) is not 0 but an infinitesimal (i.e. lim(x) where x -> 0 (BUT NOT ZERO)) > That said, measurements are in practice always quantized, and rounding > towards an even number when mid-way between avoids an average error of > half the original precision. > As a side-note: The the smallest coin in Swedish currency SEK is 0.50, > but prices in stores are given with two decimals, i.e. with precision > 0.01. But what if your goods add up to 12.34? The standard in Swedish > stores, after adding the prices of your goods, is to round the number to > the nearest whole or half SEK, which means that decimals 25 and 75 are > mid-way between. In those cases the rounding is usually done to the > nearest whole SEK, which is based on precicely the above reasoning. If > they did not do that, I could argue that they are stealing on average > 0.005 SEK from me every time I go to the store. Well... I could live > with that, since 0.005 SEK is a ridiculously small amount, and even if I > make thousands of such transactions per year, it still sums up to a > neglectable amount. No the reason is not that, it's because 1) it is much easier to input integral numbers to computer (calculator or cashier machine), to input .5 to computer you have to press two more buttons or at least one shortcut button and 2) if you have two lists, one with a bunch of . 5's and the other just a few of them you would know that it's easier to sum the latter list with or without calculator. > Another side-note: My 12-year old son is now being taught to always > round up from mid-way between. Yet another example of the degradation of > maths in schools. A false assertion from a false understanding. The use of Round Up algorithm is a refinement of the false understanding we used to practice in the past. From arnodel at googlemail.com Fri Apr 4 15:16:09 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Fri, 4 Apr 2008 12:16:09 -0700 (PDT) Subject: generator functions: why won't this work? References: <19359dad-3022-4e83-99e4-8f8093116bcb@a1g2000hsb.googlegroups.com> Message-ID: <8164c8ce-3085-4d10-8e5f-2b156a04a5c1@s8g2000prg.googlegroups.com> On Apr 2, 11:04?pm, "Gabriel Genellina" wrote: > En Wed, 02 Apr 2008 14:11:30 -0300, escribi?: > > > On Apr 1, 10:42?pm, "Gabriel Genellina" > > wrote: > >> En Tue, 01 Apr 2008 23:56:50 -0300, escribi?: > > >> ? ?yield *iterable > > >> could be used as a shortcut for this: > > >> ? ?for __temp in iterable: yield __temp > > > How serious were you about that? > > Not so much, I haven't thougth enough on it. Looks fine in principle, but ? > yield expressions may be a problem. > > -- > Gabriel Genellina Funnily, there's a patch for py3k to make this work as in your idea. It's currently being discussed on python-3000 :) -- Arnaud From silfheed at gmail.com Fri Apr 11 18:49:45 2008 From: silfheed at gmail.com (Silfheed) Date: Fri, 11 Apr 2008 15:49:45 -0700 (PDT) Subject: CDATA and lxml References: <5ebe3201-80a6-45ba-8b88-e8ece6883efa@w8g2000prd.googlegroups.com> <47FF368B.4030708@behnel.de> <47FFA0D7.1030901@behnel.de> Message-ID: <1d6d4a80-7031-441a-b242-e50ebcd51da9@w5g2000prd.googlegroups.com> On Apr 11, 10:33 am, Stefan Behnel wrote: > Hi again, > > Stefan Behnel wrote: > > Silfheed wrote: > >> So first off I know that CDATA is generally hated and just shouldn't > >> be done, but I'm simply required to parse it and spit it back out. > >> Parsing is pretty easy with lxml, but it's the spitting back out > >> that's giving me issues. The fact that lxml strips all the CDATA > >> stuff off isnt really a big issue either, so long as I can create > >> CDATA blocks later with <>&'s showing up instead of <>& . > >> I've scoured through the lxml docs, but probably not hard enough, so > >> anyone know the page I'm looking for or have a quick how to? > > > There's nothing in the docs because lxml doesn't allow you to create CDATA > > sections. You're not the first one asking that, but so far, no one really had > > a take on this. > > So I gave it a try, then. In lxml 2.1, you will be able to do this: > > >>> root = Element("root") > >>> root.text = CDATA('test') > >>> tostring(root)) > '' > > This does not work for .tail content, only for .text content (no technical > reason, I just don't see why that should be enabled). > > There's also a parser option "strip_cdata" now that allows you to leave CDATA > sections in the tree. However, they will *not* behave any different than > normal text, so you can't even see at the API level that you are dealing with > CDATA. If you want to be really, really sure, you can always do this: > > >>> root.text = CDATA(root.text) > > Hope that helps, > > Stefan That is immensely cool. Do you plan to stick it into svn soon? Thanks! From jkugler at bigfoot.com Fri Apr 4 17:19:20 2008 From: jkugler at bigfoot.com (Joshua Kugler) Date: Fri, 04 Apr 2008 13:19:20 -0800 Subject: Easy-to-install-and-use scientific graphics (plotting) package for Python 2.5.1 on Linux Ubuntu 7.1 References: <771b5531-5681-499f-9fda-77749b5db09f@s37g2000prg.googlegroups.com> Message-ID: > Is there an easy scientific graphics (plotting) package for Python > 2.5.1 running on Ubuntu Linux 7.1 ("Gutsy Gibbon")? > > A few years ago I used PyLab (a MatLab-like plotting module for > Python) on a Windows machine, but I don't know if there is a similar > easy-to-install-and-use Python 2.5.1-compatible graphics package for > Ubuntu Linux 7.1? We've been using Matplotlib for a while, but are looking for alternatives. I recently came across Chaco (http://code.enthought.com/chaco/) and am quite impressed with what I see so far. It's API is very clean, not requiring the "magic functions" (can we say setp()?) that is required by matplotlib. Very OO, and from what I see of example code, the API complies with PEP 8 conventions. Installation was easy (easy_install), but for a couple packages, you will need GCC, python-dev, and swig. I haven't dug into it much, but it looks really, really promising. j From Robert.Bossy at jouy.inra.fr Tue Apr 29 10:40:43 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Tue, 29 Apr 2008 16:40:43 +0200 Subject: Issue with regular expressions In-Reply-To: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Message-ID: <4817336B.7020309@jouy.inra.fr> Julien wrote: > Hi, > > I'm fairly new in Python and I haven't used the regular expressions > enough to be able to achieve what I want. > I'd like to select terms in a string, so I can then do a search in my > database. > > query = ' " some words" with and "without quotes " ' > p = re.compile(magic_regular_expression) $ <--- the magic happens > m = p.match(query) > > I'd like m.groups() to return: > ('some words', 'with', 'and', 'without quotes') > > Is that achievable with a single regular expression, and if so, what > would it be? > > Any help would be much appreciated. > Hi, I think re is not the best tool for you. Maybe there's a regular expression that does what you want but it will be quite complex and hard to maintain. I suggest you split the query with the double quotes and process alternate inside/outside chunks. Something like: import re def spulit(s): inq = False for term in s.split('"'): if inq: yield re.sub('\s+', ' ', term.strip()) else: for word in term.split(): yield word inq = not inq for token in spulit(' " some words" with and "without quotes " '): print token Cheers, RB From wheaties.box at gmail.com Mon Apr 14 03:31:34 2008 From: wheaties.box at gmail.com (Josh) Date: Mon, 14 Apr 2008 00:31:34 -0700 (PDT) Subject: Different times between Python and System References: Message-ID: <66292b91-a2ed-44d1-8fe6-9f4ecd87299b@w1g2000prd.googlegroups.com> Hmm... That didn't work out so well that time. I feel like an idiot. Previously there has been an hour difference between the system time and the time that python reports. On Apr 14, 1:29?am, Josh wrote: > Hi, > > Anyone know why python would not show the same time that my system > shows? > > user at computer:~$ date > Mon Apr 14 01:27:36 MDT 2008 > user at computer:~$ python > Python 2.4.5 (#2, Mar 12 2008, 00:15:51) > [GCC 4.2.3 (Debian 4.2.3-2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information.>>> import datetime > >>> datetime.datetime.now() > > datetime.datetime(2008, 4, 14, 1, 27, 50, 472350) > > Thanks! From antroy at gmail.com Mon Apr 21 07:47:11 2008 From: antroy at gmail.com (Ant) Date: Mon, 21 Apr 2008 04:47:11 -0700 (PDT) Subject: Batteries Included... Message-ID: <74988b0e-c31a-4e98-a7ee-2244a8233a55@k10g2000prm.googlegroups.com> Today's XKCD comic has a nice Python reference! http://xkcd.com/413/ From __peter__ at web.de Sun Apr 6 08:45:31 2008 From: __peter__ at web.de (Peter Otten) Date: Sun, 06 Apr 2008 14:45:31 +0200 Subject: Problems trying to hook own exception function to sys.excepthook References: <8r6dneajtO-cWGXanZ2dnUVZ8s7inZ2d@bt.com> Message-ID: Sami wrote: > Does this mean that one should always use the command line to run a > python program? Yes. Peter From dolloffdelvpg at gmail.com Wed Apr 16 08:06:42 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:06:42 -0700 (PDT) Subject: taylor swift concert schedule Message-ID: <160b5e8f-fcfa-43e0-8a36-954b5a01120f@q24g2000prf.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From bignose+hates-spam at benfinney.id.au Wed Apr 16 18:29:48 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Thu, 17 Apr 2008 08:29:48 +1000 Subject: How to have unittest tests to be executed in the order they appear? References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> <87zlru7le2.fsf@benfinney.id.au> Message-ID: <87fxtlwi03.fsf@benfinney.id.au> Matthew Woodcraft writes: > Ben Finney wrote: > > Your test cases should *not* depend on any state from other test > > cases; they should function equally well when executed in any > > arbitrary sequence. Dependencies between separate test cases (e.g. > > "they only work correctly when run in a specific sequence") means > > you're not isolating them properly. > > So a mode to randomise the test sequence would be nice to have. Twisted has a "trial" framework that allows just such a mode . > Unittest's behaviour (using alphabetical order) doesn't really help > to detect undesired dependencies (which might be bugs in the test > suite or bugs in the underlying code). Agreed. It's just a matter of making a custom unittest.TestRunner, though. Yes, a Small Matter of Programming which I haven't actually done, but unittest doesn't make it difficult to do that. > But running tests in the order they appear is often helpful: you can > put the tests for basic stuff before the tests for advanced stuff, > and then if you suddenly get seventeen failing tests, you know that > the first failure is the best bet to investigate first. Surely, since "suddenly" implies you changed one small area of the code, that area of the code is the best place to look for what caused the failure. -- \ "I planted some bird seed. A bird came up. Now I don't know | `\ what to feed it." -- Steven Wright | _o__) | Ben Finney From nagle at animats.com Thu Apr 10 13:52:05 2008 From: nagle at animats.com (John Nagle) Date: Thu, 10 Apr 2008 10:52:05 -0700 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. In-Reply-To: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> Message-ID: <47fe5133$0$36336$742ec2ed@news.sonic.net> subhabrata.iisc at hotmail.com wrote: > I am using Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v. > 1310 32 bit (Intel)] on win32 with IDLE 1.2.1 > My O/S is Windows XP SP2 I use 512 MB RAM. > I am encountering the following problems: > (i) a1=1 > a2=2 > a3=a1+a2 > print a3 > # The result is coming sometimes as 3 sometimes as vague numbers. Are you pasting that code into IDLE with cut and paste? IDLE doesn't process multiple-line paste operations properly, and usually ignores all lines after the first. When it does this, it does not produce an error message. That may be your first problem. John Nagle From ptmcg at austin.rr.com Wed Apr 2 11:07:52 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Wed, 2 Apr 2008 08:07:52 -0700 (PDT) Subject: april fools email backfires References: Message-ID: On Apr 2, 8:36?am, Aaron Watters wrote: > Grapevine says that an architect/bigot at a java/spring > shop sent out an April Fools email saying they had > decided to port everything to Django ASAP. > > Of course the email was taken seriously and he > got a lot of positive feedback from line developers > and savvy users/managers that they thought it would be a great > idea; it's about time; gotta do something about this > mess... > > ? -- Aaron Watters > > ===http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=other+surprises Can you post a link? -- Paul From kinch1967 at gmail.com Sun Apr 27 11:54:55 2008 From: kinch1967 at gmail.com (bullockbefriending bard) Date: Sun, 27 Apr 2008 08:54:55 -0700 (PDT) Subject: design choice: multi-threaded / asynchronous wxpython client? References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: <002cd046-f11d-482e-a67d-4a10a97687a1@x19g2000prg.googlegroups.com> On Apr 27, 10:05?pm, "Eric Wertman" wrote: > HI, that does look like a lot of fun... You might consider breaking > that into 2 separate programs. ?Write one that's threaded to keep a db > updated properly, and write a completely separate one to handle > displaying data from your db. ?This would allow you to later change or > add a web interface without having to muck with the code that handles > data. Thanks for the good point. It certainly is a lot of 'fun'. One of those jobs which at first looks easy (XML, very simple to parse data), but a few gotchas in the real-time nature of the beast. After thinking about your idea more, I am sure this decoupling of functions and making everything DB-centric can simplify a lot of issues. I quite like the idea of persisting pickled or YAML data along with the raw XML (for archival purposes + occurs to me I might be able to do something with XSLT to get it directly into screen viewable form without too much work) to a DB and then having a client program which queries most recent time-stamped data for display. A further complication is that at a later point, I will want to do real-time time series prediction on all this data (viz. predicting actual starting prices at post time x minutes in the future). Assuming I can quickly (enough) retrieve the relevant last n tote data samples from the database in order to do this, then it will indeed be much simpler to make things much more DB-centric... as opposed to maintaining all this state/history in program data structures and updating it in real time. From notformail at sonic.net Sun Apr 20 11:28:52 2008 From: notformail at sonic.net (JB Stern) Date: 20 Apr 2008 15:28:52 GMT Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> Message-ID: <480b6133$0$34498$742ec2ed@news.sonic.net> Banibrata Dutta wrote: >>Wanted to check if there is any known, reliable, FOSS/Libre -- Obfurscator >> for Python 2.5 code. No, sadly, there is not. There are a number of applications I would be working on if it were possible to obfuscate pyc files. About the best you can do as of 2008/04 is use Jython to compile into Java bytecode and obfuscate that using Proguard. Steve 'not an economics major' Holden wrote: >The Python world isn't particularly paranoid about obfuscation. It's >quite easy to publish compiled code only (.pyc and/or .pyo files), and >that offers enough protection for most. Curious Steve, how do you pay the rent and by what authority do you speak for "The Python world"? Your opinion couldn't be more wrong for programmers like myself who live by the code they write (as opposed to its support). Steve 'not a software consultant' Holden wrote: >The sad fact is that there seems to be an almost direct inverse >correlation between the worth of the code and the authors' desire to >protect it from piracy. Would love to see some evidence to that effect. JB From rdh at new.rr.com Tue Apr 22 17:32:08 2008 From: rdh at new.rr.com (DataSmash) Date: Tue, 22 Apr 2008 14:32:08 -0700 (PDT) Subject: list manipulation References: <78158460-8508-4453-a2dc-c5814dda8839@59g2000hsb.googlegroups.com> Message-ID: <7090b346-813e-47a3-aed7-1536102cc8c3@26g2000hsk.googlegroups.com> Joe & Mike, Thanks for your input! R.D. From mensanator at aol.com Wed Apr 16 21:16:33 2008 From: mensanator at aol.com (Mensanator) Date: Wed, 16 Apr 2008 18:16:33 -0700 (PDT) Subject: TypeNone field detection References: <480698b3$0$31577$ec3e2dad@news.usenetmonster.com> Message-ID: <719373ea-c141-45c3-b723-1b89624bc6ac@a22g2000hsc.googlegroups.com> On Apr 16, 7:24?pm, Joe Blow wrote: > What is the best way to detect a TypeNone field in a tuple, or in a list? > > I am accessing a MySQL database using the MySQLdb Python interface... this > interface returns a tuple object type in response to SQL SELECT > statements. ?My understanding of the MySQLdb interface is that NULL > database values are returned as a Python 'None' object. > > Because I need to create some work fields based on the contents of the > database I am doing so by copying the tuple to a list object and then > calculating these work fields as needed. ?My problem is that I need to be > able to detect the Python 'None' objects and convert them to an integer > zero value field to enable my calculations to work. > > I'm new to Python so I'm sure I'm overlooking something simple ? but what > is the easiest way to do a logical test for the existence of a TypeNone > field? >>> a = 0 >>> a==None False >>> b = None >>> b==None True >>> type(a) >>> type(b) From tnelson at onresolve.com Fri Apr 11 08:07:14 2008 From: tnelson at onresolve.com (Trent Nelson) Date: Fri, 11 Apr 2008 05:07:14 -0700 Subject: Randall Munroe loves Python In-Reply-To: <869c25d9-e4d3-4629-a807-f3b203f3fb65@b1g2000hsg.googlegroups.com> References: <869c25d9-e4d3-4629-a807-f3b203f3fb65@b1g2000hsg.googlegroups.com> Message-ID: <87D3F9C72FBF214DB39FA4E3FE618CDC6E22D1F9B2@EXMBX04.exchhosting.com> > Another xkcd plug for Python: http://xkcd.com/409/ Damn it. There goes another 40 minutes of my life magically whisked away by that more-addictive-than-crack 'RANDOM' button. From asmodai at in-nomine.org Sun Apr 13 04:33:11 2008 From: asmodai at in-nomine.org (Jeroen Ruigrok van der Werven) Date: Sun, 13 Apr 2008 10:33:11 +0200 Subject: =?utf-8?B?5pyJ5Lit5Zu95Lq65LmOPw==?= In-Reply-To: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> References: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> Message-ID: <20080413083310.GR51167@nexus.in-nomine.org> (My Mandarin is not very good.) -On [20080413 09:24], bikthh at live.cn (bikthh at live.cn) wrote: >Python????????????????. Python indeed does have a good future. I am not quite sure with ??????? if you are asking for someone to teach to you or if you want to teach others. -- Jeroen Ruigrok van der Werven / asmodai ????? ?????? ??? ?? ?????? http://www.in-nomine.org/ | http://www.rangaku.org/ My greatest fear... Is that all my Memories will be lost... Like tears, in the rain... From srf99 at ferg.org Wed Apr 16 09:17:21 2008 From: srf99 at ferg.org (srf99 at ferg.org) Date: Wed, 16 Apr 2008 06:17:21 -0700 (PDT) Subject: Learning Tkinter References: Message-ID: <20b6cb69-0048-4d49-aa70-d05bebc4316e@l42g2000hsc.googlegroups.com> You might want to look at these: Thinking in Tkinter http://www.ferg.org/thinking_in_tkinter/index.html Easygui http://www.ferg.org/easygui/index.html From James.Pells at gmail.com Fri Apr 25 18:30:41 2008 From: James.Pells at gmail.com (James.Pells at gmail.com) Date: Fri, 25 Apr 2008 15:30:41 -0700 (PDT) Subject: nntplib retrieve news://FULL_URL Message-ID: So I have established a connection to an nntp server and I am retrieving articles to other articles on the server such as news://newsclip.ap.org/D8L4MFAG0 at news.ap.org Now I am wondering how I query for that article based off of the url? I assume D8L4MFAG0 is an id of some sort but when I try and retrieve that article via myNntpObject.article('D8L4MFAG0') I get an error of 423 Bad article number. Which makes sense as all the other article numbers are integers. D8L4MFAG0 actually looks like a doc-id value for an NITF article stored on the NNTP server which I am retrieving content off of. Anyone have any ideas on how I fetch this content? Jimmy From rune.strand at gmail.com Fri Apr 11 15:29:43 2008 From: rune.strand at gmail.com (Rune Strand) Date: Fri, 11 Apr 2008 12:29:43 -0700 (PDT) Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> Message-ID: On Apr 11, 8:35 pm, Steve Holden wrote: > wxDesigner. Yeah, but it's like Heron of Alexandria's Aeolipile compared to the steam engine of James Watt. IMHO, GUI with Python is pain, pain and utter pain. Even boring and meaningless pain. From gruszczy at gmail.com Wed Apr 23 21:29:54 2008 From: gruszczy at gmail.com (=?UTF-8?Q?Filip_Gruszczy=C5=84ski?=) Date: Thu, 24 Apr 2008 03:29:54 +0200 Subject: Explicit variable declaration In-Reply-To: <5e59998b-d2e7-48cb-824b-84620f95c9bc@w5g2000prd.googlegroups.com> References: <1506f165-7f86-4dc7-aa29-6488eda9ae7f@l64g2000hse.googlegroups.com> <5e59998b-d2e7-48cb-824b-84620f95c9bc@w5g2000prd.googlegroups.com> Message-ID: <1be78d220804231829k2c040fat80f6fe8b96e1b7cf@mail.gmail.com> > If you want to just declare that name exist, but doesn't want to > declare the type, why don't you just do this: > > def somefunc(): > nonlocal = nonlocal > local = 0 # or None or [] or an initial value > # > return nonlocal * local Err.. I don't quite get. How it may help me? Could you explain? -- Filip Gruszczy?ski From ewertman at gmail.com Sun Apr 27 13:21:45 2008 From: ewertman at gmail.com (Eric Wertman) Date: Sun, 27 Apr 2008 13:21:45 -0400 Subject: Mapping and Filtering Help for Lists In-Reply-To: <16925836.post@talk.nabble.com> References: <16925836.post@talk.nabble.com> Message-ID: <92da89760804271021y2cb4e82ek4486f7580adfa7d5@mail.gmail.com> You should check out the sets module: http://docs.python.org/lib/module-sets.html > > The problem asks to create a "compareandremove" so that you can use it on a > string, to remove the words from the string that are contained in un_words. > > The remaining words then need to be compared to the alterns list and either > bring back the word if no matches or bring back the list. To better explain > that i'll use an example. > > If i do compareandremove('notepad a pencil with desk') > > I need it so it removes words contained in un_words, so "a" and "with"; > then compares the remaining words to alterns to find a match. > > This should bring back: > > ['notepad', 'book', 'textbook', 'pencil', 'pen', 'pacer', 'desk'] From sjdevnull at yahoo.com Fri Apr 18 15:28:59 2008 From: sjdevnull at yahoo.com (sjdevnull at yahoo.com) Date: Fri, 18 Apr 2008 12:28:59 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <48074f58$0$4916$e4fe514c@dreader32.news.xs4all.nl> <6002cb46-f48a-421d-a4ff-5b23bf2f9d77@2g2000hsn.googlegroups.com> Message-ID: On Apr 17, 10:30 am, sturlamolden wrote: > On 17 Apr, 15:21, "Martin P. Hellwig" wrote: > > > If not, what is the advantage above already present solutions? > > Well... I like the processing module. Except that Wintendo toy OS has > no fork() availabe for the Win32 subsystem Passing a NULL SectionHandle to NTCreateProcess/CreateProcessEx results in a fork-style copy-on-write duplicate of the current process. From gagsl-py2 at yahoo.com.ar Tue Apr 8 02:41:57 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 08 Apr 2008 03:41:57 -0300 Subject: Translating keywords References: <432e22c6-7cd0-4a9c-b3bc-dea9fe4798d0@8g2000hsu.googlegroups.com> Message-ID: En Tue, 08 Apr 2008 03:28:54 -0300, Arnaud Delobelle escribi?: > On Apr 8, 6:47 am, Arnaud Delobelle wrote: > [...] >> Although I would use ? and ? as aliases for all() >> and exists() :) > > I mean all() and any() of course Yes, I thought about that usage too, but I were looking for *keywords* to replace, and ? x ? A: f(x) instead of `for x in A: f(x)` was a winner because it uses two of them. -- Gabriel Genellina From kyosohma at gmail.com Fri Apr 11 13:20:56 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 11 Apr 2008 10:20:56 -0700 (PDT) Subject: Cannot start RPy - need win32api References: Message-ID: <743ee4e0-bd05-4291-b587-1e8c6237656b@f36g2000hsa.googlegroups.com> On Apr 11, 11:47 am, tkp... at hotmail.com wrote: > I'm running Python 2.5.2 on Windows XP and need to interface with R, > so I downloaded the R 2.6.2 statistical package and installed it, and > did the same for RPy 1.02 (i made sure I got the version for Python > 2.5 and R 2.62.). When I go to the Python command line and type > > >>> from rpy import * > > I get the following error message: > > Traceback (most recent call last): > File "", line 1, in > from rpy import * > File "C:\Python25\lib\site-packages\rpy.py", line 88, in > import win32api > ImportError: No module named win32api > > > > What on earth is win32api, where can I find it, and where ought I to > put it? > > Thanks in advance > > Thomas Philips It's part of the PyWin32 package, which exposes a lot of the win32 processes to Python manipulation. You can get it here: https://sourceforge.net/projects/pywin32/ And documentation is here: http://aspn.activestate.com/ASPN/docs/ActivePython/2.5/pywin32/win32_modules.html Mike From mitko at qlogic.com Tue Apr 1 17:49:28 2008 From: mitko at qlogic.com (Mitko Haralanov) Date: Tue, 1 Apr 2008 14:49:28 -0700 Subject: Decrementing of reference count of new objects? Message-ID: <20080401144928.24bc6506@opal.mv.qlogic.com> For the most part, I understand the theory behind reference counting in Python C code. But there is one thing that I am confused about and I have not been able to clear it up. Let say that you have the following function (over-simplified): PyObject *do_work (PyObject *self, PyObject *args) { PyObject *new_obj; new_obj = PyDict_New (); return new_obj; } What I don't get is whether I have to decrement the reference to new_obj before I return it. I know that function that return object are giving away the reference but I am still confused. Thanks for all your help! -- Mitko Haralanov mitko at qlogic.com Senior Software Engineer 650.934.8064 HSG InfiniBand Engineering http://www.qlogic.com ========================================== 11. Any more trouble from you and your account gets moved to the 750 --Top 100 things you don't want the sysadmin to say From bockman at virgilio.it Wed Apr 16 03:40:44 2008 From: bockman at virgilio.it (bockman at virgilio.it) Date: Wed, 16 Apr 2008 00:40:44 -0700 (PDT) Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> Message-ID: <69795448-0534-4aed-a9a0-84f2cd3aea36@s50g2000hsb.googlegroups.com> On 11 Apr, 20:19, Rune Strand wrote: > On Apr 10, 3:54 am, Chris Stewart wrote: > ... > > > > > Next, what would you say is the best framework I should look into? > > I'm curious to hear opinions on that. > > GUI-programming in Python is a neanderthal experience. What one may > love with console scripts is turned upside-down. ?Projects like Boa > Constructor seemed to be a remedy, but is not developed. The Iron- > Pythonistas has a very promising RAD GUI-tool in the IronPython - > Studio,http://www.codeplex.com/IronPythonStudio- but if you're non- > Iron, only sorrow is left - unless you fancy creating GUI in a text- > editor. Something I consider waste of life. If you refer to lack of GUI designer, every toolkit usable by python - barring Tkinter - has a GUI designer wich can be used: pygtk -> Glade pywx -> wxDesigner, rxced, ... pyqt -> QDesigner, ... All can generate python code and/or generate files that can be used by python program to create the whole GUI with a few function calls (e.g. libglade ). If you refer to the lack of visual programming ala visualstudio or JBorland, you might be right, but I personally found that visual programming makes for very unmaintenable code, especially if you have to fix something and you don't have the IDE with you (and this has happened many times to me). Therefore I now prefer a clean separation between the GUI (described in someting like glade files or .xrc files) and my code. BTW, once learned to use the right layout managers, even building a GUI from scratch is not such a PITA, since you don't have to manually place each widget anymore, but only define the structure of packers and grids and then adjust borders and such with some -limited IME - experimentation. I know people that prefer this approach to any GUI builder, having developed their own little library to help reducing the boilerplate (and in Python you can do nice things with decorators ans such ... ). So maybe yes, in python you might not have the fancy world of visual programming, but neither are deprived of tools that make your work easier. Ciao ----- FB From gagsl-py2 at yahoo.com.ar Thu Apr 10 00:58:22 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 01:58:22 -0300 Subject: PyArg_ParseTuple for structs or binary data References: <7a01f6c00804090105h7cba73f0g53687349d8dcd574@mail.gmail.com> Message-ID: En Wed, 09 Apr 2008 05:05:45 -0300, Alvin Delagon escribi?: > I'm currently writing a simple python SCTP module in C. So far it works > sending and receiving strings from it. The C sctp function sctp_sendmsg() > has been wrapped and my function looks like this: > > sendMessage(PyObject *self, PyObject *args) > { > const char *msg = ""; > if (!PyArg_ParseTuple(args, "s", &msg)) > return NULL; > snprintf(buffer, 1025, msg); > ret = sctp_sendmsg(connSock, (void *)buffer, (size_t)strlen(buffer), > 0, 0, > 0x03000000, 0, 0, 0, 0); > return Py_BuildValue("b", ""); > } > > I'm going to construct an SS7 packet in python using struct.pack(). > Here's > the question, how am I going to pass the packet I wrote in python to my > module? Thanks in advance! :) Same as you do now; struct.pack returns a string object. The "s#" format is safer, in case embedded NUL characters are allowed. Also, there is no need to copy the string into another buffer (assuming the sctp_sendmsg doesn't alter it). This Py_BuildValue looks suspicious - what's the intended return value? In case you want to return "ret" (an integer, I guess), use Py_BuildValue("i", ret) or just PyInt_FromLong(ret) -- Gabriel Genellina From marlin_rowley at hotmail.com Fri Apr 18 11:25:40 2008 From: marlin_rowley at hotmail.com (Marlin Rowley) Date: Fri, 18 Apr 2008 10:25:40 -0500 Subject: Which event to use for out of focus window? Message-ID: I think I've found a bug in the wx Library. I've created an event : EVT_IDLE that does something when the event is triggered, however, if your mouse pointer is out-of-focus on the window, the EVT_IDLE doesn't get called. It's only when the window is put into focus that the IDLE event is called. I basically want the IDLE function to be called whether the window is in focus or not. Is there a way to do this? Thanks, -M _________________________________________________________________ Get in touch in an instant. Get Windows Live Messenger now. http://www.windowslive.com/messenger/overview.html?ocid=TXT_TAGLM_WL_Refresh_getintouch_042008 -------------- next part -------------- An HTML attachment was scrubbed... URL: From fennelllindy8241 at gmail.com Mon Apr 28 03:18:35 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:18:35 -0700 (PDT) Subject: convertxtodvd keygen Message-ID: convertxtodvd keygen http://crack.cracksofts.com From skanemupp at yahoo.se Sun Apr 6 17:05:44 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 6 Apr 2008 14:05:44 -0700 (PDT) Subject: How to create an exe-file? References: <311a216f-5366-47c5-86a7-431dd23ced3e@j1g2000prb.googlegroups.com> Message-ID: <8da70474-6ade-4515-8346-8f02a04ff24e@b9g2000prh.googlegroups.com> On 6 Apr, 22:50, Fredrik Lundh wrote: > skanem... at yahoo.se wrote: > > how do you create exe-files of your python-code? > > > is it different depending on what libraries, GUI-frameworks you use? > > > i want to create an exe-file of a pythonscript that uses Tkinter. > > assuming windows only, you want: > > http://www.py2exe.org/ > > also see: > > http://effbot.org/zone/python-compile.htm > > ty. a good thing about python is the portability though. but u cant make an exe that can be used on mac too, ie one exe fpr both? if i want to make an exe for mac, what do i need? From pavlovevidence at gmail.com Tue Apr 1 01:31:23 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 31 Mar 2008 22:31:23 -0700 (PDT) Subject: Looking for indent advice howto in emacs python-mode References: Message-ID: On Mar 31, 12:32 pm, "Steven W. Orr" wrote: > Here's what I want to do: > > if ( ( v == 1 ) > or ( v == 2 ) > or ( v == 3 ) ): > pass > > but emacs (left to its own devices, does this. > > if ( ( v == 1 ) > or ( v == 2 ) > or ( v == 3 ) ): > pass > > It works great for me in C-mode. Does anyone know how to jimmie up > python-mode so it would know how to do this? Not sure about the python.el that ships with emacs 21, but the python- mode.el that is used in emacs 20, it can't be done without modifying the Lisp code. An open nesting character with nothing on the line following it will indent the following line 4 (or whateve py-basic-indent is set to) spaces. An open nesting character with something following it will indent the following line to match the column of the first item. There is no option to change this. If you are not afraid of Elisp, then the function to modify is called py-compute-indentation, and you should look for a comment with the text "again mimic the first line item". That is where the indent in this case is set. The code following the comment "elset they're about to enter the first item" sets the indent for the other case. You might want to use that code in all cases. (Warning: this may cause problems elsewhere, such as nesting function call.) And once again, all bets are off if you're using python.el in Emacs 21. Carl Banks From jantod at gmail.com Mon Apr 14 11:52:38 2008 From: jantod at gmail.com (Janto Dreijer) Date: Mon, 14 Apr 2008 08:52:38 -0700 (PDT) Subject: eval modifies passed dict References: <2b2398b1-042e-46bb-b840-ea9e07d87bd1@2g2000hsn.googlegroups.com> <511feb86-3915-46da-9bd8-d02de87eb2de@b1g2000hsg.googlegroups.com> Message-ID: On Apr 14, 5:48?pm, colas.fran... at gmail.com wrote: > On 14 avr, 17:23, Janto Dreijer wrote: > > > It seems eval is modifying the passed in locals/globals. This is > > behaviour I did not expect and is really messing up my web.py app. > > > Python 2.5.1 (r251:54863, Mar ?7 2008, 04:10:12) > > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > > Type "help", "copyright", "credits" or "license" for more information.>>> d = dict(a=1) > > >>> d.keys() > > ['a'] > > >>> eval("a", d) > > 1 > > >>> d.keys() > > > ['a', '__builtins__'] > > > That can't be right. > > From the documentation of eval[1] > "If the globals dictionary is present and lacks '__builtins__', the > current globals are copied into globals before expression is parsed." > > [1]http://docs.python.org/lib/built-in-funcs.html Thanks! I'll take it to the webpy group as one of their methods unexpectedly propagates this effect. Janto From mccle27252 at gmail.com Mon Apr 21 03:53:00 2008 From: mccle27252 at gmail.com (mccle27252 at gmail.com) Date: Mon, 21 Apr 2008 00:53:00 -0700 (PDT) Subject: utu conductor patch Message-ID: <00465189-43fe-4902-b6e4-5acda0add440@a9g2000prl.googlegroups.com> utu conductor patch http://cracks.00bp.com F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Tue Apr 22 01:29:31 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 22 Apr 2008 02:29:31 -0300 Subject: why objects of old style classes are instances of 'object' References: <4807641F.8030209@gmail.com> <66p7eeF2l44iiU2@mid.uni-berlin.de> <6755i2F2hjsb8U1@mid.individual.net> Message-ID: En Tue, 22 Apr 2008 00:49:27 -0300, AlFire escribi?: > Diez B. Roggisch wrote: > >> But not everything is a newstyle-class: >> >>>>> class Foo: pass >> ... >>>>> isinstance(Foo, object) >> True >>>>> isinstance(Foo, type) >> False > >>>>> class Bar(object): pass >> ... >>>>> isinstance(Bar, type) >> True >>>>> >> > > > thx for explanation. but more I look at it less and less I like the > notation of new-style-class definition. what is an added value of adding > "(object)" since it is already an object. Any insight? Read Diez previous post again. An old-style class is an *instance* of object (as all other objects), but not a *subclass* of object. It does not *inherit* from object. A new-style class is both an instance of object and a subclass of object. It inherits from object. This is what the base (object) means. > Note: I am not a language purist, more a pragmatic who like a good style. We need *some* way to distinguish new-style classes from old ones. The (object) base is simple, doesn't require new syntax, and it's true (hmm, this may be a form of petitio principii) In Python 3.0, old-style classes are gone, and the (object) is not necesary: all classes inherit from object. -- Gabriel Genellina From bockman at virgilio.it Thu Apr 24 08:50:51 2008 From: bockman at virgilio.it (bockman at virgilio.it) Date: Thu, 24 Apr 2008 05:50:51 -0700 (PDT) Subject: How to get inner exception traceback References: <67b8nuF2m1a1kU1@mid.individual.net> Message-ID: <09ce6c51-3c23-4fb7-a369-d357c0f5d287@m73g2000hsh.googlegroups.com> On 24 Apr, 13:20, Thomas Guettler wrote: > Hi, > > How can you get the traceback of the inner exception? > > try: > ? ? ?try: > ? ? ? ? ?import does_not_exit > ? ? ?except ImportError: > ? ? ? ? ?raise Exception("something wrong") > except: > ? ? ?... > > Background: In Django some exceptions are caught and a new > exception gets raised. Unfortunately the real error is hard > to find. Sometimes I help myself and change (in this example) > ImportError to e.g. IOError and then I can see the real root > of the problem. But maybe there is a way to get the inner > exception and its traceback. This could be displayed in the > debug view. > > ? Thomas > > -- > Thomas Guettler,http://www.thomas-guettler.de/ > E-Mail: guettli (*) thomas-guettler + de I'm not sure it ill work since sys.exc_info() might not return a deep copy of the traceback info, but you could try to store the inner exception and its traceback as attributes of the outer exception: class ReraisedException(Exception): def __init__(self, message, exc_info): Exception.__init__(self, message) self.inner_exception = exc_info try: try: import does_not_exit except ImportError: raise ReraisedException("Something wrong", sys.exc_info() ) except ReraisedException, e: ... # here you can use e.inner_exception except: ... Ciao ----- FB From cyberco at gmail.com Thu Apr 10 11:30:08 2008 From: cyberco at gmail.com (Berco Beute) Date: Thu, 10 Apr 2008 08:30:08 -0700 (PDT) Subject: Can C.L.P.handle the load? References: <3b6737c8-9d42-4218-ac60-01df2f578746@p39g2000prm.googlegroups.com> <9bd25fd3-5133-4165-9784-fbbc21145810@24g2000hsh.googlegroups.com> Message-ID: On Apr 9, 12:24 pm, Duncan Booth wrote: > Berco Beute wrote: > > On Apr 9, 7:54 am, Paddy wrote: > >> What else could we do to make c.l.p. of more use to the newbie whp may > >> also be new to usenet whilst keeping c.l.p a usefull place for all? > > >> - Paddy. > > > Maybe create a usenet/google group for newbies? A place to ask > > beginners questions. And post a sticky to c.l.p. redirecting newbies > > (or experienced pythoneers with newbie questions :). > > Or just redirect them to the already existing listhttp://mail.python.org/mailman/listinfo/tutor I didn't know about that list. It would be nice to have that list duplicated as a usenet/google group (just like c.l.p). > What do you mean by 'post a sticky'? That sounds like a web forum thing. It is. Using Google Groups some can post a post that stays on top. Not sure if everybody would like that. :) 2B From mfb.chikazuku at gmail.com Thu Apr 10 13:17:52 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Thu, 10 Apr 2008 19:17:52 +0200 Subject: Stripping scripts from HTML with regular expressions References: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> <47fd46b3$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: <47fe59f2$0$6838$2d805a3e@textnews.eweka.nl> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Reedick, Andrew wrote: >> -----Original Message----- >> From: python-list-bounces+jr9445=att.com at python.org [mailto:python- >> list-bounces+jr9445=att.com at python.org] On Behalf Of Michel Bouwmans >> Sent: Wednesday, April 09, 2008 5:44 PM >> To: python-list at python.org >> Subject: RE: Stripping scripts from HTML with regular expressions >> >> >> Thanks! That did the trick. :) I was trying to use HTMLParser but that >> choked on the script-blocks that didn't contain comment-indicators. >> Guess I >> can now move on with this script, thank you. >> > > > Soooo.... you asked for help with a regex workaround, but didn't ask for > help with the original problem, namely HTMLParser? ;-) > > > > ***** > > The information transmitted is intended only for the person or entity to > which it is addressed and may contain confidential, proprietary, and/or > privileged material. Any review, retransmission, dissemination or other > use of, or taking of any action in reliance upon this information by > persons or entities other than the intended recipient is prohibited. If > you received this in error, please contact the sender and delete the > material from all computers. GA625 I don't think HTMLParser was doing anything wrong here. I needed to parse a HTML document, but it contained script-blocks with document.write's in them. I only care for the content outside these blocks but HTMLParser will choke on such a block when it isn't encapsulated with HTML-comment markers and it tries to parse the contents of the document.write's. ;) MFB -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFH/kvEDpaqHmOKFdQRAgHgAJ4s2YUN6yynUS+8aunhVUR94rs2yQCgrn94 tAFx/dylzEI0TclRDSTRbJI= =k8SN -----END PGP SIGNATURE----- From paul.anton.letnes at gmail.com Tue Apr 15 05:40:27 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Tue, 15 Apr 2008 11:40:27 +0200 Subject: How to import C++ static library? In-Reply-To: <66j9r8F2k2iplU1@mid.uni-berlin.de> References: <66j9r8F2k2iplU1@mid.uni-berlin.de> Message-ID: <0C2703E6-8EBC-40D5-A931-30ABF49B9333@gmail.com> Den 15. april. 2008 kl. 11.11 skrev Diez B. Roggisch: > Alexander Dong Back Kim wrote: > >> Hi all, >> >> I'm very very beginner of python but I'm dare to ask this question >> straight away. =P >> >> Is it possible to import C++ static library compiled by GCC? The >> target is definitely Linux machine. >> >> I found some examples from Google showing the way C++ can import >> Python so called embedded python. But I want to the opposite way of >> this. I want to import (or include in C world terminology) the >> library >> which is a blah.a file to reuse in python. >> >> Any suggestion or idea for this stupid beginner? ;) > > For C++, you need to create a wrapping using C++ wrapper tools. > There are a > few available: SWIG, Boost::Python and SIP. > > I can only comment personally on the latter - and can recommend it > without > any doubt. > > Diez > -- > http://mail.python.org/mailman/listinfo/python-list Diez: I tried SWIG, and it works nicely with C. For C++, I didn't manage to make it work. I tried SIP; I have some problems compiling etc. Would it be too much to ask you to supply a working example of a (simple, stupid) C++ class and the necessary SIP files? Preferably for Mac OS X, but Linux is also interesting I guess. Cheers Paul. From rocco.rossi at gmail.com Wed Apr 23 10:17:46 2008 From: rocco.rossi at gmail.com (rocco.rossi at gmail.com) Date: Wed, 23 Apr 2008 07:17:46 -0700 (PDT) Subject: Python generators (coroutines) Message-ID: I would really like to know more about python 2.5's new generator characteristics that make them more powerful and analogous to coroutines. Is it possible for instance to employ them in situations where I would normally use a thread with a blocking I/O (or socket) operation? If it is, could someone show me how it can be done? There appears to be a very limited amount of documentation in this repect, unfortunately. Thank you. From s0suk3 at gmail.com Sat Apr 19 08:44:01 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Sat, 19 Apr 2008 05:44:01 -0700 (PDT) Subject: winreg module, need help to understand why i'm getting exception References: <194c4200-b388-429c-9341-28c96f27a9a7@m73g2000hsh.googlegroups.com> Message-ID: Sorry, the above post is not complete. This is the rest: # There should be a for or a while loop around here try: name = _winreg.EnumValue(key, index) except EnvironmentError: # It raises WindowsError, but the _winreg documentation # recommends catching EnvironmentError break else: # do something with 'name' ... Anyway, I'd recommend using _winreg instead of the module you're using, since it clearly has errors, and it's not on the standard library. From skanemupp at yahoo.se Sat Apr 12 16:50:36 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 12 Apr 2008 13:50:36 -0700 (PDT) Subject: toplevel, get latest entry? Message-ID: windows vista and python 2.5, is there a way to get the latest command entered? would be very useful. if not by default, anything i could download or write myself? From namesagame-usenet at yahoo.com Wed Apr 9 17:54:18 2008 From: namesagame-usenet at yahoo.com (gamename) Date: Wed, 9 Apr 2008 14:54:18 -0700 (PDT) Subject: Not Sure This Can Be Done... References: <46aeae28-4470-4136-a5f6-040f6468eb32@b5g2000pri.googlegroups.com> <170a668f-4a65-471f-ad03-03231235b314@e6g2000prf.googlegroups.com> Message-ID: Hi, In hopes it may help someone else, here's what I ended up doing: 1) Add this to to point to your local 'tools' directory: import site # the python tools dir is at "../../tools/python" site.addsitedir('..'+os.sep+'..'+os.sep+'tools'+os.sep +'python') 2) In the 'tools' dir, there is a file called 'local.pth'. Its contents: # the individual modules are at "../../tools/python/modules/ " ./modules/pexpect 3) In the script you can now do: import pexpect That's it. This works fine, but there are still 2 outstanding issues: A) How do make the same ".pth" file usable on a win32 environment? The path separators are different (i.e. "/" vs "\"). B) How to auto-include any subdirectory in 'python/modules' so that each new module dir doesn't have to be added manually? That is, if package 'foo' is added, it would be in 'python/modules/foo'. Is there a way to avoid manually putting that in the '.pth'? FYI, -T From bg at bg.fr Tue Apr 8 11:56:55 2008 From: bg at bg.fr (Bruno GUERPILLON) Date: Tue, 8 Apr 2008 17:56:55 +0200 Subject: List open files References: <47fb8d54$0$15068$426a74cc@news.free.fr> <2af7d536-eb72-4e6d-96ca-3c91455b06b9@a9g2000prl.googlegroups.com> Message-ID: <47fb96c2$0$7182$426a74cc@news.free.fr> "Miki" a ?crit dans le message de news: 2af7d536-eb72-4e6d-96ca-3c91455b06b9 at a9g2000prl.googlegroups.com... > Hello Bruno, > >> I'd like, in a WIN32 environment, list all open files. >> Anyone got a clue how to do this ? > Have a look at the sysinternals suite (http://technet.microsoft.com/en- > us/sysinternals/0e18b180-9b7a-4c49-8120-c47c5a693683.aspx), you might > find stuff there that will help you. > > HTH, > -- > Miki > http://pythonwise.blogspot.com Thanks Miki, Well, i think i'll use handle.exe from sysinternals and parse the input. Regards, From chrishenry.ni at gmail.com Sat Apr 26 01:55:32 2008 From: chrishenry.ni at gmail.com (Chris Henry) Date: Fri, 25 Apr 2008 22:55:32 -0700 (PDT) Subject: multiple pattern regular expression References: Message-ID: On Apr 25, 8:37?pm, Arnaud Delobelle wrote: > micron_make writes: > > I am trying to parse a file whose contents are : > > > parameter=current > > max=5A > > min=2A [snip] > If every line of the file is of the form name=value, then regexps are > indeed not needed. ?You could do something like that. > > params = {} > for line in file: > ? ? name, value = line.strip().split('=', 2) > ? ? params[name] = value > > (untested) > Then params should be the dictionary you want. > I'm also interested in this problem. While this solution works, I'm looking for solution that will also check whether the parameter name/ value is of a certain pattern (these patterns may be different, e.g. paramA, paramB, paramC may take integers value, while paramD may take true/false). Is there a way to do this easily? I'm new to Python and the solution I can think off involve a loop over a switch (a dictionary with name->function mapping). Is there other, more elegant solution? Chris From namesagame-usenet at yahoo.com Tue Apr 29 14:59:25 2008 From: namesagame-usenet at yahoo.com (gamename) Date: Tue, 29 Apr 2008 11:59:25 -0700 (PDT) Subject: Sending Cntrl-C ?? Message-ID: <0274834e-17e1-4a95-88ec-f2aa77aeb3a9@k10g2000prm.googlegroups.com> Hi, I really like this recipe for controlling subprocesses: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554 However, I can't figure out how I can send the equivalent of "Cntrl-C" to the subprocess. How can that be done? TIA, -T From deets at nospam.web.de Tue Apr 29 10:48:19 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 29 Apr 2008 16:48:19 +0200 Subject: list.reverse() In-Reply-To: References: <4816e26a$0$30938$426a74cc@news.free.fr> Message-ID: <67oqpjF2nsikiU1@mid.uni-berlin.de> > > The reasoning goes along the lines of, "reverse in place is an expensive > operation, so we don't want to make it too easy for people to do". At > least that's the gist of what I got out of the argument the many times it > has come up. It's not about the storage - it is about the in-place-modification. The reasioning is that people otherwise could assume that a = [1, 2] b = a.reverse() assert a[0] == 1 and b[0] == 2 would hold, but instead of course "a" is changed. Using reversed as b = reversed(a) will make that assumption hold. Diez From steve at holdenweb.com Fri Apr 25 09:24:55 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 25 Apr 2008 09:24:55 -0400 Subject: Is 2006 too old for a book on Python? In-Reply-To: References: Message-ID: jmDesktop wrote: > Hi, I wanted to buy a book on Python, but am concerned that some of > them are too old. One I had come to after much research was Core > Python by Wesley Chun. I looked at many others, but actually saw this > one in the store and liked it. However, it is from 2006. I know > there is free documentation and Dive Into Python. I just liked the > one in question and was hoping for thoughts on the age of it. I am > using Python 2.5.x and don' t know how different 2.3, 2,4 is from it. Buy it if you like it (and lots of people do). Less than 1% of the language changes between releases. You'll pick the rest up here! regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From jarausch at skynet.be Wed Apr 23 11:32:13 2008 From: jarausch at skynet.be (Helmut Jarausch) Date: Wed, 23 Apr 2008 17:32:13 +0200 Subject: Script to convert Tcl scripts to Python? In-Reply-To: References: Message-ID: <480f567e$0$2954$ba620e4c@news.skynet.be> Achillez wrote: > Hi, > > I have a 10k+ line Tcl program that I would like to auto convert over to > Python. Do any scripts exist that can convert ~90% of the standard Tcl > syntax over to Python? I know Python doesn't handle strings, but just for > general syntax e.g., puts > print, expr > math operations > I asked a similar question some time ago. The summary was - don't do it! Instead, a Tcl interpreter could be loaded and given the job to do. I think that's similar to what Tkinter does. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany From upton at virginia.edu Wed Apr 16 14:10:28 2008 From: upton at virginia.edu (Dan Upton) Date: Wed, 16 Apr 2008 14:10:28 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <5504f9ac0804161110u664dd46bx5c2f9ac0a6ecb0c7@mail.gmail.com> On Wed, Apr 16, 2008 at 1:49 PM, Mike Driscoll wrote: > On Apr 16, 12:40 pm, "D'Arcy J.M. Cain" wrote: > > I don't think I like the email list idea all that much. I'm already on > a number of them and they fill up my box like crazy. Besides that, in > email format it's hard to follow the thread, so one moment I'm reading > about the latest ding dong and the next is a response to a post from > last week. Maybe a thread bashing google "gorups" is a bad place to make this comment, but Gmail organizes the threads so it's easy to follow threads in mailing list conversations. (And I see you're posting from a gmail address, so...) Thunderbird is capable of grouping mailing list messages by thread too, and I can only assume Outlook Express is as well. The recent deluge of spam has gone straight to my junk mail box, and Gmail's spam filter only incorrectly flags as spam about one python-list message per week--maybe instead of ignoring all posts from Google users, you just need a better spam filter. From goldtech at worldpost.com Wed Apr 9 11:33:35 2008 From: goldtech at worldpost.com (goldtech) Date: Wed, 9 Apr 2008 08:33:35 -0700 (PDT) Subject: String manipulation questions References: <8cd7b477-6fc6-47c5-b2eb-e2a4f284f7b2@m3g2000hsc.googlegroups.com> Message-ID: <3545a1f2-fff0-4226-aca1-39dfa70d94ef@x41g2000hsb.googlegroups.com> snip... > > for counter, line in enumerate(fileIN): > newline = line.replace(oldstring, newstring) > if newline != line: > print 'match at line', counter+1 > fileOUT.write(newline) "enumerate" - haven't seen that before. Nice! Thanks From sam at mas.pl Thu Apr 3 04:07:38 2008 From: sam at mas.pl (sam) Date: Thu, 03 Apr 2008 10:07:38 +0200 Subject: Prototype OO In-Reply-To: References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> Message-ID: bruno.desthuilliers at gmail.com napisa?(a): > So, while I often use Python's lambdas, the imposed limitations is ok > to me since I wouldn't use it for anything more complex. > Also - as a side note - while the syntax is a bit different, the > resulting object is an ordinary function. And people start asking why this is that or the other way in Python, and you can't give a good answer to newcomers, especially if Python was chosen as a first learning language. You can't tell "because Python's parsing mechanism don't allow statements in expressions...". >> But somebody may prefix his names with class names and cause nameconflict, > > Here the problem is more philosophical than anything else. Almost the whole discussion is philosofical, but clear philosophy is a good thing. > It's enough. FWIW, I'm not sure I had a use-case for this feature more > than a couple time in 7+ years. > Simple, indeed. But why "not perfect" ? What else would you want ? I would expect you to told me at the beginning that this is enough to solve the problem and that somebody can still cause name conflict, but Python was built for wise people. From frikker at gmail.com Mon Apr 28 13:23:02 2008 From: frikker at gmail.com (blaine) Date: Mon, 28 Apr 2008 10:23:02 -0700 (PDT) Subject: Regular Expression - Matching Multiples of 3 Characters exactly. References: Message-ID: <68e62e2f-2753-4cce-b4a2-3fe24f64c2b0@34g2000hsh.googlegroups.com> On Apr 28, 6:30 am, Nick Craig-Wood wrote: > blaine wrote: > > I'm trying to write a string matching algorithm for genomic > > sequences. I'm pulling out Genes from a large genomic pattern, with > > certain start and stop codons on either side. This is simple > > enough... for example: > > > start = AUG stop=AGG > > BBBBBBAUGWWWWWWAGGBBBBBB > > > So I obviously want to pull out AUGWWWWWWAGG (and all other matches). > > This works great with my current regular expression. > > > The problem, however, is that codons come in sets of 3 bases. So > > there are actually three different 'frames' I could be using. For > > example: > > ABCDEFGHIJ > > I could have ABC DEF GHI or BCD EFG HIJ or CDE FGH IJx.... etc. > > > So finally, my question. How can I represent this in a regular > > expression? :) This is what I'd like to do: > > (Find all groups of any three characters) (Find a start codon) (find > > any other codons) (Find an end codon) > > > Is this possible? It seems that I'd want to do something like this: (\w > > \w\w)+(AUG)(\s)(AGG)(\s)* - where \w\w\w matches EXACTLY all sets of > > three non-whitespace characters, followed by AUG \s AGG, and then > > anything else. > > I'm not sure what the \s are doing in there - there doesn't appear to > be any whitespace in your examples. > > > I hope I am making sense. Obviously, however, this will make sure > > that ANY set of three characters exist before a start codon. Is > > there a way to match exactly, to say something like 'Find all sets > > of three, then AUG and AGG, etc.'. > > I think you want > > ^(\w\w\w)*(AUG)((\w\w\w)*?)(AGG) > > which will match up 0 or more triples, match AUG match 0 or more triples > then AGG. The ? makes it a minimum match otherwise you'll match more > than you expect if there are two AUG...AGG sequences in a given genome. > > >>> import re > >>> m=re.compile(r"^(\w\w\w)*(AUG)((\w\w\w)*?)(AGG)") > >>> m.search("BBBBBBAUGWWWWWWAGGBBBBBB").groups() > ('BBB', 'AUG', 'WWWWWW', 'WWW', 'AGG') > >>> m.search("BBBQBBBAUGWWWWWWAGGBBBBBB") > >>> m.search("BBBQQBBBAUGWWWWWWAGGBBBBBB") > >>> m.search("BBBQQBBQBAUGWWWWWWAGGBBBBBB") > <_sre.SRE_Match object at 0xb7de33e0> > >>> m.search("BBBQQBBQBAUGWWWWWWAGGBBBBBB").groups() > ('BQB', 'AUG', 'WWWWWW', 'WWW', 'AGG') > >>> m.search("BBBQQBBQBAUGWQWWWWWAGGBBBBBB") > >>> m.search("BBBQQBBQBAUGWWWWQWWAGGBBBBBB") > >>> m.search("BBBQQBBQBAUGWWQWWQWWAGGBBBBBB") > >>> m.search("BBBQQBBQBAUGWWQWAWQWWAGGBBBBBB") > <_sre.SRE_Match object at 0xb7de33e0> > >>> m.search("BBBQQBBQBAUGWWQWAWQWWAGGBBBBBB").groups() > ('BQB', 'AUG', 'WWQWAWQWW', 'QWW', 'AGG') > >>> > > > This way, I could scan for genes, remove the first letter, scan for > > more genes, remove the first letter again, and scan for more genes. > > This would hypothetically yield different genes, since the frame > > would be shifted. > > Of you could just unconstrain the first match and it will do them all > at once :- > > (AUG)((\w\w\w)*?)(AGG) > > You could run this with re.findall, but beware that this will only > return non-overlapping matches which may not be what you want. > > I'm not sure re's are the best tool for the job, but they should give > you a quick idea of what the answers might be. > > -- > Nick Craig-Wood --http://www.craig-wood.com/nick Thank you! Your suggestion was overly helpful. Also thank you for the package suggestions. BioPython is on my plate to check out, but I needed a kind of quick fix for this one. The documentation for biopython seems pretty thick - I'm not a biologist so I'm not even sure what kind of packages I'm even looking for. thanks! Blaine From wizzardx at gmail.com Fri Apr 25 15:31:25 2008 From: wizzardx at gmail.com (David) Date: Fri, 25 Apr 2008 21:31:25 +0200 Subject: Setting expirty data on a cookie In-Reply-To: <80818edd-37dd-4306-8723-97db63afd5fb@z72g2000hsb.googlegroups.com> References: <8ba48e05-9aba-4a56-805c-cd31b43517ab@24g2000hsh.googlegroups.com> <80818edd-37dd-4306-8723-97db63afd5fb@z72g2000hsb.googlegroups.com> Message-ID: <18c1e6480804251231q43c75606paa7df0cf816ad507@mail.gmail.com> > import Cookie > import time > c = Cookie.SimpleCookie() > c['data'] = "unamepwordwhatever" > c['data']['expires'] = 30 * 24 * 60 * 60 > print c > > Gives an output of: > > "Set-Cookie: data=unamepwordwhatever; expires=Sat, 24-May-2008 > 12:11:36 GMT" > Hi again. I didn't see your replies until now. Disclaimer: I've never worked with cookies before, I'm just going by the rfc, python docs, and wikipedia. I think the confusion exists because the Cookie module has an unusual definition of cookies. What we call cookies (key + value + attributes), the Cookie module calls a Morsel. What the Cookie module calls a cookie is in fact the collection of Set-Cookie headers that will be sent by the server. So for code like this: c = Cookie.SimpleCookie() c['data1'] = 123 c['data2'] = 456 the server will output 2 cookies like this: Set-Cookie: data1=123 Set-Cookie: data2=456 This is why when you want to set the expiry date for one of the cookies, you need syntax like this: c['data2']['expires'] = 30 * 24 * 60 * 60 Another note: 'expires' is apprantly a legacy attribute for early Netscape browsers. The RFC and python source comments suggest that you use 'Max-Age' instead. I think that the Cookie module author wanted to represent http state as a python dictionary, but chose an unfortunate name for the class. Also, the example page doesn't go into detail about setting attributes. David. From uniontelecardsindia at gmail.com Tue Apr 22 17:15:41 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:15:41 -0700 (PDT) Subject: Gay hunks spreading legs for butt fucking outdoors Message-ID: <528b67cb-575b-4b5d-8462-6593e8d6fe9f@b64g2000hsa.googlegroups.com> Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From alimamatrade at msn.com Sat Apr 5 07:31:56 2008 From: alimamatrade at msn.com (www.alimamatrade.net) Date: Sat, 5 Apr 2008 04:31:56 -0700 (PDT) Subject: low price high quality items whosale & resale at www.alimamatrade.net Message-ID: <5e4fe21e-ca86-4566-82ea-580e8e96c0af@p39g2000prm.googlegroups.com> we would give our lowest price, www.alimamatrade.net 1. Before shipping the goods ,we check the cutting/stitching/high frequency/embroidery/assembly/cement carefully, until the goods are OK. 2. payment:western union,moneygram,bank transfer (T/T by bank). 3. shipping method:EMS,TNT,DHL other shipping as you prefer. 4. we provide best quality and competetive price to our customers, sample order & drop shipment are OK. Minimum order quantity is 1 delivery time is 4-6 days, send the goods door to door. if you have any other questions,welcome to contact me at any time. TKS! Shoes: Adidas Shoes, Bape Shoes, Boots, CA shoes, Chanel shoes, clarks shoes, Converse Shoes, D & G shoes, Diesel Shoes, Dior shoes, Dirk shoes, Dsquared2 shoes, Edhardy shoes, Evisu Shoes, Gucci Shoes, Hogan Shoes, Icecream shoes, Kappa shoes, kid shoes, Lacoste Shoes, Levi's shoes, LV Shoes, Nike air force one, Nike Air Jordan, Nike Air Max, Nike Air Rift, Nike Air Shox, Nike Dunk, Nike James, paioctti-4us, Prada shoes, Puma Shoes, Sand Shoes, sandals, Soccer, Timberland shoes, Versace shoes Apple ipods: MP3, MP4, ipod touch, ipod nano, ipod vedio, Bags: T-shirts: Underwear: Hoodies: Caps: Jeans: Belts: Wallets: Watches: Mobile phones: Blackberry phone, htc tytn phone, iphone, LG phone, LV phone, MOTO, Nokia 6300, Nokia 7500, Nokia E65, Nokia E90, Nokia N70, Nokia N71, Nokia N72, Nokia N73, Nokia N76, Nokia N77, Nokia N80, Nokia N81, Nokia N90, Nokia N91, Nokia N92, Nokia N93, Nokia N95, Nokia N99, Nokia N8600, NOKIA N8800, Nokia Vertu, PDA, Sony Eriosson, sumsing Perfume: Sunglasses: www.alimamatrade.net From balta96428 at gmail.com Wed Apr 23 05:55:31 2008 From: balta96428 at gmail.com (balta96428 at gmail.com) Date: Wed, 23 Apr 2008 02:55:31 -0700 (PDT) Subject: topical analgesic salonpas-hot capsicum patch Message-ID: topical analgesic salonpas-hot capsicum patch http://cracks.12w.net F R E E C R A C K S From mblume at freesurf.ch Wed Apr 23 12:27:33 2008 From: mblume at freesurf.ch (Martin Blume) Date: Wed, 23 Apr 2008 18:27:33 +0200 Subject: Unix Device File Emulation References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> Message-ID: <480f6376$0$9037$5402220f@news.sunrise.ch> "blaine" schrieb > > # Fake Nokia Screen Emulator > import sys, os > > class nokia_fkscrn: > def __init__(self, file): > if not os.path.exists(file): > os.mkfifo(file) > self.fifodev = open(file, 'r') > def read(self): > while 1: > r = self.fifodev.readline() > print r > > nokia = nokia_fkscrn('dev.file') > nokia.read() > > This works at first, but when I write to the 'dev.file' > for the first time, the text is displayed as intended, > but then the program just keeps spitting out blank lines. > I can continue to write to the file > (using echo 'test\n' > dev.file) > and this shows up in my output, but amist a giant mass > of scrolling blank lines. This also causes my CPU > usage to shoot up to 100%. > > Any ideas? This is OS X 10.4 > while 1: r = self.fifodev.readline() if r: print r According to my docs, readline() returns an empty string at the end of the file. Also, you might want to sleep() between reads a little bit. IMHO. HTH. Martin From ptmcg at austin.rr.com Thu Apr 17 09:05:54 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Thu, 17 Apr 2008 06:05:54 -0700 (PDT) Subject: Metaprogramming Example References: <930643c6-2d56-4fb0-aee0-a3e79231f09b@24g2000hsh.googlegroups.com> <32472b97-f35a-4408-96f5-2f8c8f92ae56@m73g2000hsh.googlegroups.com> Message-ID: On Apr 17, 7:25?am, andrew cooke wrote: > On Apr 17, 7:12 am, "bruno.desthuilli... at gmail.com" wrote: > > One other question. ?I had "foo is False" and you said I need > equality, which is a good point. ?However, in any other language "not > foo" would be preferable. ?I was surprised you didn't suggest that > (and I'm unsure now why I didn't write it that way myself). ?Is there > some common Python standard that prefers "foo == False" to "not foo"? > In addition to the problematic "foo is False" test, Bruno was also saying that assertions of True tend to be more readable than negated assertions of False. In your original, you were testing for not P or not Q, Bruno recoded this to the equivalent not(P and Q). That is, the direct way to change the 'is' identity testing to equality testing would have been: if (not self.ignore_identical or new_value != obj._auto_write_dict[self.name]): But Bruno further changed this to: if not (self.ignore_identical and new_value == obj._auto_write_dict[self.name]): -- Paul From ch612bunn at gmail.com Sun Apr 27 09:19:56 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:19:56 -0700 (PDT) Subject: Adobe Premiere CS3 crack Message-ID: <4d720d12-9877-46d4-a1ba-e522b7c015db@m36g2000hse.googlegroups.com> Adobe Premiere CS3 crack http://wga-cracks.crackkey.net From stanc at al.com.au Thu Apr 3 18:58:37 2008 From: stanc at al.com.au (Astan Chee) Date: Fri, 04 Apr 2008 09:58:37 +1100 Subject: sine in python Message-ID: <47F5611D.3090900@al.com.au> Hi, I have a math function that looks like this sin (Theta) = 5/6 How do I find Theta (in degrees) in python? I am aware of the math.sin function, but is there a reverse? maybe a sine table in python? Thanks Astan -- "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." Animal Logic http://www.animallogic.com Please think of the environment before printing this email. This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. From marli305nugent at gmail.com Sat Apr 26 09:53:02 2008 From: marli305nugent at gmail.com (marli305nugent at gmail.com) Date: Sat, 26 Apr 2008 06:53:02 -0700 (PDT) Subject: crack cocaine pictures Message-ID: crack cocaine pictures http://cracks.00bp.com F R E E C R A C K S From rtw at freenet.co.uk Fri Apr 11 18:34:38 2008 From: rtw at freenet.co.uk (Rob Williscroft) Date: Fri, 11 Apr 2008 17:34:38 -0500 Subject: https and POST method References: <7956f925-1037-49ea-a360-b58d627ffb20@z24g2000prf.googlegroups.com> Message-ID: Lorenzo Stella wrote in news:7956f925-1037-49ea-a360-b58d627ffb20 @z24g2000prf.googlegroups.com in comp.lang.python: > Hi all, > I'm trying to write a simple script for sending sms via vyke... I have > to make a https > connection and pass some data with the POST method, like this perl > script does: Curl maybe, http://pycurl.sourceforge.net/ Rob. -- http://www.victim-prime.dsl.pipex.com/ From tall2200 at gmail.com Thu Apr 17 06:53:05 2008 From: tall2200 at gmail.com (kkkk) Date: Thu, 17 Apr 2008 03:53:05 -0700 (PDT) Subject: New youtube video Message-ID: New youtube video http://www.youtube.com/watch?v=tWxFZRgh664 http://www.youtube.com/watch?v=K20FaUQpCEk http://www.youtube.com/watch?v=sSutNlV4Tq0 http://www.youtube.com/watch?v=1P8wqWC7ISE http://www.youtube.com/watch?v=wS1hPZiuXnk http://www.youtube.com/watch?v=wgkDtlod8Wg http://www.youtube.com/watch?v=ZN7NvdrF_Ok http://www.youtube.com/profile_videos?user=dream2008land&p=r From tinnews at isbd.co.uk Thu Apr 3 09:00:15 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 03 Apr 2008 13:00:15 GMT Subject: A question about creating Maildir mailboxes with mailbox.Maildir Message-ID: <47f4d4df$0$712$bed64819@news.gradwell.net> I have mail delivered into Maildirs which live in a directory hierarchy as follows:- /home/isbd/Mail/Li/ /home/isbd/Mail/In/ Note that neither /home/isbd/Mail/Li nor /home/isbd/Mail/In are Maildir mailboxes. How do I create a new Maildir mailbox in either Li or In with mailbox.Maildir.add_folder()? If I have created an instance of Maildir with:- md = mailbox.Maildir("/home/isbd/Mail/Li") that implies that /home/isbd/Mail/Li is a Maildir, which it isn't, and anyway the above fails because it can't see the new, cur and tmp directories in /home/isbd/Mail/Li. It seems that the Python Maildir implementation assumes a Courier style (probably IMAP) Maildir hierarchy with an INBOX and using dots rather than real directories to create sub-directories. I don't have an INBOX or any sort of 'home' maildir, it's most definitely not a requirement of maildir. -- Chris Green From mccle27252 at gmail.com Mon Apr 21 03:51:44 2008 From: mccle27252 at gmail.com (mccle27252 at gmail.com) Date: Mon, 21 Apr 2008 00:51:44 -0700 (PDT) Subject: cracked skin on fingers Message-ID: <04ff3458-b01e-42f0-8f15-2c8fc7b2b32a@b9g2000prh.googlegroups.com> cracked skin on fingers http://cracks.00bp.com F R E E C R A C K S From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 1 12:23:29 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 01 Apr 2008 18:23:29 +0200 Subject: Homework help In-Reply-To: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> Message-ID: <47f2617f$0$15056$426a74cc@news.free.fr> bobby.connor at gmail.com a ?crit : > Hey guys > I haev this homework assignment due today Isn't it a bit too late to worry about it then ? From brian.e.munroe at gmail.com Thu Apr 24 17:18:01 2008 From: brian.e.munroe at gmail.com (Brian Munroe) Date: Thu, 24 Apr 2008 14:18:01 -0700 (PDT) Subject: Class Inheritance - What am I doing wrong? References: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> Message-ID: <613bc152-a6f4-4db4-8f90-593cb3f629c7@s33g2000pri.googlegroups.com> Ok, so thanks everyone for the helpful hints. That *was* a typo on my part (should've been super(B...) not super(A..), but I digress) I'm building a public API. Along with the API I have a few custom types that I'm expecting API users to extend, if they need too. If I don't use name mangling, isn't that considered bad practice (read not defensive programming) to not protect those 'private' fields? From lalitkrishna at gmail.com Thu Apr 24 10:27:36 2008 From: lalitkrishna at gmail.com (Lalit) Date: Thu, 24 Apr 2008 07:27:36 -0700 (PDT) Subject: NameError: global name 'Response' is not defined Message-ID: <1e84807c-aec0-4d04-97a3-1953719f4dc6@8g2000hse.googlegroups.com> Hi I am very new to web development. I started with Pylons. I am using http://www.rexx.com/~dkuhlman/pylons_quick_site.html as reference to create a sample web page using pylons. I got stuck up at step 4.3 i.e when modifying controller to "return Response('

firstapp default

')" I am getting error of : global name 'Response' is not defined It seems I am missing some package. I am not really sure. I installed python 2.5 and through easy_install imported pakages (pylons). Any clues would be appreciated Thanks Lalit From cyberco at gmail.com Wed Apr 16 07:44:41 2008 From: cyberco at gmail.com (Berco Beute) Date: Wed, 16 Apr 2008 04:44:41 -0700 (PDT) Subject: webcam (usb) access under Ubuntu References: <66jlk1F2ju6c8U1@mid.uni-berlin.de> <66kkedF2l526dU2@mid.uni-berlin.de> <455760fb-8229-4be3-ba7f-7c41bdcd66de@a22g2000hsc.googlegroups.com> <362eb242-2adc-4d7b-9c0a-95e72f4b22b6@e67g2000hsa.googlegroups.com> <66m26hF2lo3ghU1@mid.uni-berlin.de> Message-ID: <590f00ea-15d3-480a-9fa8-c28c32a292b2@e39g2000hsf.googlegroups.com> On Apr 16, 12:19 pm, "Diez B. Roggisch" wrote: > Maybe if you are now using windows, there are better options - but I'm a > *nix-boy :) > > Diez So am I :), but the application I'm writing has to run on *that other operating system from the 90's*. I'm trying hard not to implement the application in C#/.Net, but I'm running out of open source alternatives. VideoCapture *almost* worked and now I'm stranded at the gstreamer road as well... 2B From suzhi18 at googlemail.com Wed Apr 9 03:01:14 2008 From: suzhi18 at googlemail.com (suzhi18 at googlemail.com) Date: Wed, 9 Apr 2008 00:01:14 -0700 (PDT) Subject: makepy.py not working References: <03e9c33d-d957-4bc0-8568-3a40403eadb9@a70g2000hsh.googlegroups.com> Message-ID: <1803f997-739c-462d-955c-685374236f0b@m44g2000hsc.googlegroups.com> Ok, thanks for your help. After looking into the makepy.py file it was clear that this is only a command for the CMD console. I want to write a function which generates this .py file of the excel objects. I will now send the command to the CMD threw my python code. thanks again. suzhi From ott.deb at gmail.com Thu Apr 17 15:06:41 2008 From: ott.deb at gmail.com (ott.deb at gmail.com) Date: Thu, 17 Apr 2008 12:06:41 -0700 (PDT) Subject: smoking patch Message-ID: <8a6623c7-07f7-48bc-8305-8737cb240398@m73g2000hsh.googlegroups.com> smoking patch http://cracks.12w.net F R E E C R A C K S From marco at sferacarta.com Thu Apr 3 08:57:51 2008 From: marco at sferacarta.com (Marco Mariani) Date: Thu, 03 Apr 2008 14:57:51 +0200 Subject: who said python can't be obsfucated!? In-Reply-To: <47f4b69b$0$19766$426a74cc@news.free.fr> References: <47f4b69b$0$19766$426a74cc@news.free.fr> Message-ID: Bruno Desthuilliers wrote: > sig=lambda m:'@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p > in m.split('@')]) Pff... you call that a quicksort? From http://www.p-nand-q.com/python/obfuscated_python.html import sys funcs = range(10) def A(_,o): _[3]=_[5]() def B(_,o): o[_[2]]=_[9]() def C(_,o): _[3]=_[7]() def D(_,o): o[_[1]]=_[14]() def E(_,o): _[1]=_[4]() def F(_,o): _[2]=_[6]() def G(_,o,O): if _[O[0]]():return O[-1](_,o) or 1 def H(o, start, stop): _=[o[stop],[lambda x,y:x+y,lambda x,y:x-y,lambda x, y:y|1,0,0][1](start,funcs[4](range(funcs[3](), len(o[:])))),stop,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] for i in range(4,19): _[i]=lambda _=_,o=o,s="reduce([lambda x,y:x+y,lambda "\ "x,y:x-y,lambda x,y:y|1,0,0][0],[_[1],funcs[4]("\ "range(eval(\"funcs[3]()\"),_[10]()))])$funcs[4"\ "](range(eval(\"funcs[3]()\"),_[10]()))$[lambda"\ " x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,0,0][1]"\ "(_[2],funcs[4](range(funcs[3](),_[10]())))$fun"\ "cs[4](range(funcs[3](),_[10]()))$range(_[10]()"\ "*_[10]())$o[:][_[1]]$len(o[:])$not _[3]$_[1]=="\ "_[2]$o[:][_[1]]>_[0]$o[:][_[2]]$o[_[2]]<_[0]$_"\ "[2]==_[1]$_[11]() and not E(_,0) and not G(_,o"\ ",[12,A]) and not G(_,o,[13,B])$_[11]() and not"\ " F(_,_) and not G(_,o,[16,C]) and not G(_,o,[1"\ "5,D])".split('$')[:][i-4]:eval("eval('eval(s)')") while _[11](): while _[17](): pass while _[18](): pass o[_[2]] = _[0] return _[2] def quicksort(list,start,stop): exec('funcs[3] = lambda:reduce([lambda x,y:x+y,lambda x,y'\ ':x-y,lambda x,y:y|1,0,0][1],[[lambda x,y:x+y,lambda'\ ' x,y:x-y,lambda x,y:y|1,0,0][2](200,200)]*2)\nfuncs'\ '[4] = lambda x:reduce(lambda x,y:y%2,range(eval("re'\ 'duce([lambda x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,'\ '0,0][2],[len(o[:]),len(o[:])])"),eval("reduce([lamb'\ 'da x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,0,0][2],[l'\ 'en(o[:]),len(o[:])])")+((len(o)and 3)or 3)))\nif st'\ 'art < stop:\n\tsplit = H(list, start, stop)\n\tquic'\ 'ksort(list, start, [lambda x,y:x+y,lambda x,y:x-y,l'\ 'ambda x,y: y|1,0,0][1](split,funcs[4](funcs[3]())))'\ '\n\tquicksort(list, reduce([lambda x,y:x+y,lambda x'\ ',y:x-y,lambda x,y:y|1,0,0][0],[split,funcs[4](funcs'\ '[3]())]), stop)\n') # test code: 2000 elements to sort list = [] import whrandom,time for i in range(2000): list.append(whrandom.randint(1,100)) start = time.clock() quicksort(list,0,len(list)-1) print "Sorting took %.2f" % (time.clock() - start) # just a test loop to see if everything *is* sorted element = -1 for i in list: if i >= element: element = i else: print "FUNK DAT: %20s" % str(i) break From bj_666 at gmx.net Sun Apr 27 12:36:22 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 27 Apr 2008 16:36:22 GMT Subject: convert images References: Message-ID: <67joc5F2o7iv7U1@mid.uni-berlin.de> On Sun, 27 Apr 2008 06:42:13 -0700, wilson wrote: > i converted some P5 type .pgm images to .jpg using > [?] > ie if oldimage.pgm has pixels > [29 31 38 ..., 10 4 18] > then the corresponding jpg image has > [29 31 38 ..., 10 3 17] > > why this difference? shouldn't they be identical?can someone pls > explain this? JPEG uses a lossy compression algorithm, i.e. the image loses quality and therefore the pixel values are not exactly the same as before saving. If you want get the exact values back you have to use another image format. For RGB or RGBA data PNG is a good format. Ciao, Marc 'BlackJack' Rintsch From aaron.watters at gmail.com Thu Apr 24 21:48:51 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Thu, 24 Apr 2008 18:48:51 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> On Apr 24, 10:10?am, Paul McGuire wrote > end point applications (I consider maintaining 2 branches to be in the > "not working" category), but it does NOT WORK for people who maintain > modules for other people to use, because those people may be on a > range of Python versions that extend beyond 2.6-3.0. ?So if I upgrade > my module to 2.6, those running on earlier versions can no longer use > it. ?At some point in the future, I'll probably be able to say "no > more support for pre-2.6", but it is a bit early to start saying that > now. In my view using a conversion tool on an ongoing basis is not an option. It just adds a dependancy. What happens when the conversion tool is upgraded in a non-backwards-compatible way? Or do we have assurance that it won't be ;)? Will changes to the converter mean that the users of my converted libraries have to start using my tools in a different way? Even if it breaks some users in a very subtle way it's not acceptible. I have no interest in adding additional dependancies, with an additional degree of freedom to break. This is all made worse because it's binary -- with upgrades to C or C# you usually had the option of cross linking between old style components and new style components (and at least with C these could usually be made to work) and you could port the older stuff with care. With py 3.0 and python 2.6 *everything* either works with the interpreter or none of it does. (Don't ask my users to install two interpreters: they'll just give up and use something else.) So if I want to support both I have to do everything twice in the expected case and in the best case test everything twice, at the same time, if I want to support both versions and keep features in sync. This is of course assuming that all the supporting libraries do the same thing. If they don't and one of the libraries doesn't support 2.* and another doesn't support 3.*... I guess I'm just screwed. I still think it's a shame, and I think it's different in kind from python 1.x->2.x. 2.x broke very little as I recall. Most 1.x code just worked in 2.x and most of the rest required very minor change. I think this is not the case for 2.x->3.x. -- Aaron (Scummy) Watters, hoping to shut up now. ps: I didn't notice that % was vanishing later (3.3). that's a bit better (whew ;) ). pps: I have to note that it would be nice if the ad-hominem (sp?) invective would drop out of these threads -- it doesn't add a lot, I think. === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=garbage+left+over From george.sakkis at gmail.com Tue Apr 1 09:15:20 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 1 Apr 2008 06:15:20 -0700 (PDT) Subject: troll poll References: <65eee6F2eg18jU1@mid.uni-berlin.de> Message-ID: On Apr 1, 5:43 am, "Diez B. Roggisch" wrote: > Delaney, Timothy (Tim) wrote: > > George Sakkis wrote: > > >> On Mar 31, 1:46 pm, Marc 'BlackJack' Rintsch wrote: > > >>>> More specifically, who can create a bigger mess on c.l.py? (check > >>>> one) > > >>>> [ ] - Xah Lee > >>>> [X] - castironpi > > >>> Xah Lee's postings might be trolls but sometimes they spark some > >>> really interesting and serious subthreads, while the nonsense of > >>> castironpi is just irritating noise. > > >> Which is exactly why there are rarely any replies to his random > >> gibberish, so I would say that he/she/it has almost no effect on > >> c.l.py. Yet I wish plonking was possible through Google groups. > > > I find classifying all their posts as spam works fairly well. > > I'm also astonished - once I figured out how this knode works regarding > killfiles, all I get to see from them is the occasional citation. > > The only irritating thing is if castironpi answers to one of *my* posts, and > somebody else tells him to shut up... which then appears below my post in > my reader ... > > diez Wow, thanks to this thread I discovered the Google Groups KillFile, a firefox+greasemonkey killfile script (http://www.penney.org/ ggkiller.html). Hope it works as advertised! George From jeffrey at fro.man Tue Apr 8 11:49:26 2008 From: jeffrey at fro.man (Jeffrey Froman) Date: Tue, 08 Apr 2008 08:49:26 -0700 Subject: list.sort(): heaviest item? References: Message-ID: <9vCdnb4PB5-bCWbanZ2dnUVZ_uidnZ2d@cablespeedwa.com> Steven Clark wrote: > If I have a list of items of mixed type, can I put something into it > such that after a list.sort(), is guaranteed to be at the end of the > list? > It looks like "None" always ends up at the start ("lightest"), but I > want the opposite ("heaviest"). I don't know of an object in the standard library that is guaranteed to be "heaviest", but it is trivial to create one: >>> class Heaviest(object): ... def __cmp__(self, other): ... return 1 ... >>> Heaviest = Heaviest() >>> L = [tuple(), list(), dict(), Heaviest, str(), int(), None] >>> L.sort() >>> L [None, 0, {}, [], '', (), <__main__.Heaviest object at 0xb7c04a8c>] Ordering with respect to another object that defines a similar __cmp__ function will still be arbitrary, but maybe you don't have to deal with any such objects ;-) Jeffrey From rowen at cesmail.net Tue Apr 29 12:10:00 2008 From: rowen at cesmail.net (Russell E. Owen) Date: Tue, 29 Apr 2008 09:10:00 -0700 Subject: Simple unicode-safe version of str(exception)? References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> <67on2nF2ol856U1@mid.individual.net> Message-ID: In article <67on2nF2ol856U1 at mid.individual.net>, Bjoern Schliessmann wrote: > "Martin v. L?wis" wrote: > > > e is an exception object, not a Unicode object. > > Er, sure, thanks for pointing that out. At first sight he should > substitute "e" with "e.message" then since he tries to convert to > string (for display?). No. e.message is only set if the exeption object receives exactly one argument. That is why my replacement code reads: errStr = ",".join([unicode(s) for s in f.args]) self.setState(self.Failed, errStr) (where e is an Exception of some kind) Notice that I'm iterating over the args. But again, this is far messier than: self.setState(self.Failed, str(e) So...to repeat the original question, is there any simpler unicode-safe replacement for str(exception)? -- Russell From zillow10 at googlemail.com Thu Apr 3 19:09:02 2008 From: zillow10 at googlemail.com (zillow10 at googlemail.com) Date: Thu, 3 Apr 2008 16:09:02 -0700 (PDT) Subject: sine in python References: Message-ID: <92f00617-28ee-4104-bd04-a48f87d84785@q27g2000prf.googlegroups.com> On Apr 3, 11:58 pm, Astan Chee wrote: > Hi, > I have a math function that looks like this > sin (Theta) = 5/6 > How do I find Theta (in degrees) in python? I am aware of the math.sin > function, but is there a reverse? maybe a sine table in python? > Thanks > Astan > > -- > "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." > > Animal Logichttp://www.animallogic.com > > Please think of the environment before printing this email. > > This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. import math If you now do dir(math) you'll see that the module has the functions 'asin' and 'degrees' that find the inverse sine of a number, and convert radians to degrees, respectively From __peter__ at web.de Sun Apr 13 03:17:35 2008 From: __peter__ at web.de (Peter Otten) Date: Sun, 13 Apr 2008 09:17:35 +0200 Subject: class level properties References: Message-ID: Charles D Hixson wrote: > I want a hundred or so read-only variables, and I'm not sure the best > way to achieve it. What do you really want to do? I recommend that you forget about bondage and rely upon displine: class Test(object): """Never change an attribute with an uppercase name.""" SIMPLE = "simple example working" Now that was easy... Peter From rowen at cesmail.net Tue Apr 29 12:16:21 2008 From: rowen at cesmail.net (Russell E. Owen) Date: Tue, 29 Apr 2008 09:16:21 -0700 Subject: Simple unicode-safe version of str(exception)? References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> Message-ID: In article , Donn Cave wrote: > In article <481650E3.4060603 at v.loewis.de>, > "Martin v. L?wis" wrote: > > > >> I have code like this: > > >> except Exception, e: > > >> self.setState(self.Failed, str(e)) > > >> which fails if the exception contains a unicode argument. > > > > > > Fails how? > > > > ASCII encoding error, I suppose. It fails only if a) one argument > > is a Unicode object, and b) that Unicode object contains non-ASCII > > parameters. > > Seem ironic that this fails even though pretty nearly anything > else is a valid input to str() -- socket, dict, whatever? I agree. In fact str(a) works if a is a dict or list that contains unicode data! Pity the same is not true of exceptions. Should I report this as a bug? I suspect it's a misfeature. > A sort of generic solution might be to follow str's behavior > with respect to '__str__', extending it to fall back to repr() > whatever goes wrong. > > > def xtr(a): > try: > return str(a) > except: > return repr(a) Yes. That is a more flexible alternative to what I've adopted: def exStr(ex): return ",".join([unicode(s) for s in f.args]) the latter gives better output for the case I'm interested in, but only handles exceptions. Oh well. I'll stick to my solution and hope that Python 2.6 and 3.0 fix the problem in a more sensible fashion. -- Russell From musiccomposition at gmail.com Mon Apr 14 22:47:00 2008 From: musiccomposition at gmail.com (Benjamin) Date: Mon, 14 Apr 2008 19:47:00 -0700 (PDT) Subject: about the ';' References: Message-ID: <4fe8b2be-f5e0-4656-b200-551777c924a5@m36g2000hse.googlegroups.com> On Apr 13, 10:33 pm, "Penny Y." wrote: > I saw many python programmers add a ';' at the end of each line. > As good style, should or should not we do coding with that? Where did you see that? > > Thanks. From gagsl-py2 at yahoo.com.ar Tue Apr 29 02:43:05 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 29 Apr 2008 03:43:05 -0300 Subject: descriptor & docstring References: Message-ID: En Tue, 29 Apr 2008 01:29:40 -0300, George Sakkis escribi?: > On Apr 28, 10:59?pm, "Gabriel Genellina" > >> def property_default(prop_name, default_value=None, doc=None): >> >> ? ? ?attr_name = '_'+prop_name >> >> ? ? ?def fget(self, attr_name=attr_name, >> ? ? ? ? ? ? ? ? ? ? default_value=default_value): >> ? ? ? ? ?return getattr(self, attr_name, default_value) >> >> ? ? ?def fset(self, value, >> ? ? ? ? ? ? ? ? ? ? attr_name=attr_name, >> ? ? ? ? ? ? ? ? ? ? default_value=default_value): >> ? ? ? ? ?if value == default_value: >> ? ? ? ? ? ? ?delattr(self, attr_name) >> ? ? ? ? ?else: >> ? ? ? ? ? ? ?setattr(self, attr_name, value) >> >> ? ? ?return property(fget=fget, fset=fset, doc=doc) >> >> When setting the same value as the default, the instance attribute is ? >> removed (so the default will be used when retrieving the value later). >> I think this is what you intended to do. > > Note that this will fail if the value is already equal to the default > and you try to reset it to the default, so it needs an extra > hasattr(self, attr_name) before the delattr. Regardless, I would be > surprised with the following behaviour: > >>>> r = Rectangle() >>>> r.length = 4 >>>> type(r.length) > >>>> r.length = 12 >>>> type(r.length) > Yep, probably the best thing to do is to always call setattr and avoid special cases. > Another simpler alternative would be to (ab)use a decorator: > > def defaultproperty(func): > attr = '_' + func.__name__ > default = func.func_defaults[0] > return property( > fget = lambda self: getattr(self, attr, default), > fset = lambda self,value: setattr(self, attr, value), > doc = func.__doc__) > > > class Rectangle(object): > '''A beautiful Rectangle''' > > @defaultproperty > def length(default=12.0): > '''This is the length property''' Nice, although that empty function looks somewhat strange... -- Gabriel Genellina From blog630 at watchesblog.cn Wed Apr 23 13:20:47 2008 From: blog630 at watchesblog.cn (blog630 at watchesblog.cn) Date: Wed, 23 Apr 2008 10:20:47 -0700 (PDT) Subject: OEM Handheld Mics - Chinese Handheld Mics Manufacturer Message-ID: <38b8cd08-92d0-4e43-9731-81386e7cc7d7@u12g2000prd.googlegroups.com> OEM Handheld Mics - Chinese Handheld Mics Manufacturer Handheld Microphone WebSite Link: http://www.chinese-microphone.com/Handheld-Microphones.html China GuangZhou TianTuo Microphone Manufacturing Co., Ltd WebSite: http://www.chinese-microphone.com/ Microphone Products are: Wireless Microphones, Conference Microphones, Headset Microphones, and Lapel Microphones, interview microphones, wired microphones, musical instrument microphones, drum microphones, teaching microphones, recording microphones, computer's USB microphones and microphone accessories and So on. Compare Handheld Microphone Companies and Handhe http://www.chinese-microphone.com/Handheld-Microphones.html ld Microphone Businesses livedesignonline.com |Directory Home | Company Index | Category Index895 Companies Listed; Is Yours? Get Your Free Listing Most Popular Categories Lamps/Light Source sLighting AccessoriesLuminairesSoundStage Equipment Advertiser Resources Add Your Free Li http://www.chinese-microphone.com/Handheld-Microphones.html sting Update Your Listing Build Your Ad Contact Us Live Design Online Source Book Sound Microphones/Handheld/Stand Supported = Featured Listing Showing 1 - 12 of 12 Microphones/Handheld/Stand Supported Compare and research Handheld Microphone companies and businesses online. Page: 1 Audio-Technica US Inc.Stow, OHDPA Microphones Inc.Longmont, COElectro-VoiceBurnsville, http://www.chinese-microphone.com/Handheld-Microphones.html MNHeil Sound/ TransAudio GroupLas Vegas, NVHi-TechAtlanta, GAImage Technologies Corp.St. Louis, MOProduction Advantage, Inc.Williston, VTProel SpASant'OmeroSennheiser Electronic CorporationOld Lyme, CTShure Inc. Niles, ILSybrsound Sound EngineersMishawaka, I http://www.chinese-microphone.com/Handheld-Microphones.html NXS Lighting & Sound Inc.Farmingdale, NY Page: 1 Live Design Online Source Book | Company Index | Category Index | Advertise With Us | Add Free Listing | Update Listing Customer Support | Terms of Use | Privacy Policy | Site Map Wholesale Handheld Microphone From fetchinson at googlemail.com Sun Apr 20 05:12:19 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Sun, 20 Apr 2008 02:12:19 -0700 Subject: ???Python Memory Management S***s??? In-Reply-To: <480B017A.7020801@gmail.com> References: <480B017A.7020801@gmail.com> Message-ID: On 4/20/08, Hank @ITGroup wrote: > Hi, people! > > Greetings~ > These days I have been running a text processing program, written by > python, of cause. > In order to evaluate the memory operation, I used the codes below: > > """ > > string1 = ['abcde']*999999 # this took up an obvious memory space... > > del string1 # this freed the memory > successfully !! > > """ > For primary variants, the *del* thing works well. However, challenge the > following codes, using class-instances... > > """ > > from nltk import FreqDist # nltk stands for Natural Language Tool > Kit (this is not an advertisement ~_~) > > instance = FreqDist() > > instanceList = [instance]*99999 > > del instanceList # You can try: nothing is freed by this > """ > ??? How do you people control python to free the memory in python 2.5 or > python 2.4 ??? > Cheers!!! I don't know about the others, I personally let the garbage collector take care of it. HTH, Daniel From zolotoiklo at mail.ru Sat Apr 26 06:41:14 2008 From: zolotoiklo at mail.ru (=?KOI8-R?B?+s/Mz9TPyiDrzM/O?=) Date: Sat, 26 Apr 2008 03:41:14 -0700 (PDT) Subject: =?KOI8-R?B?1sXO08vPxSDLz9LSxcvUydLVwN3FxSDCxczY?= =?KOI8-R?B?xQ==?= Message-ID: ???????????? ??????????? ????? Maidenform USA - ??????? ?????????????? ????? ????? ???? ? ???. ????????? ????-????? (??????????? ?????) ??????? ??????? ????????? ?? ???????????? ??????????? ????????? ? ???????? ?????????? ????. ??????? ????????? ??????????? ??????? ???????????? ?????????????? ????????? ??????? ??????. ????????? ?????????? ???? ? ?????????????? ????????, ??????????? ????? ????????? ??? ?????????? ???????. ??????: 77% ??????, 23% ??????? ??????? ?????????????? ????? Maidenform USA http://shopbody.ru/maidenform6224.htm From andrei.avk at gmail.com Mon Apr 14 00:33:45 2008 From: andrei.avk at gmail.com (AK) Date: Mon, 14 Apr 2008 00:33:45 -0400 Subject: ANN: Tobu-0.5.0 Message-ID: <4802deab$0$7056$4c368faf@roadrunner.com> Tobu 0.5.0 is now available. Tobu is something between a freeform information organizer and a database. Changes since last version were: Added multiple undo/redo, toolbar icon for list recent; Fixed loading a previously selected item from listing, disabled closing of last remaining tab, fixed panes disappearing when dragged all the way down or up, fixed removing of favorites, changed last used tag to pop to the top of recently used tags, fixed tab key deleting tags when they are selected, set exact match in filter dropdown to highlight ahead of inexact matches, fixed replacing file name when dragged and dropped instead of appending to old filename, removed 'new copy' icon from toolbar, fixed gvim not saving changes in linux when set as external editor - see note in tutorial, fixed saved views / saved templates interfering with each other, automatic windows installer was added. Tobu's homepage is here: http://tobu.lightbird.net -- ak Tobu | http://tobu.lightbird.net/ | Freeform DB / Tagger / PIM Python-by-Example | http://pbe.lightbird.net/ | Guide to LibRef From joe.p.cool at googlemail.com Tue Apr 15 15:50:33 2008 From: joe.p.cool at googlemail.com (Joe P. Cool) Date: Tue, 15 Apr 2008 12:50:33 -0700 (PDT) Subject: Gecko 1.9 Message-ID: In 2005 I heard of plans to add Python as a second language to the Gecko engine. Is this still true? Or has this plan been abandoned? From kyosohma at gmail.com Tue Apr 22 14:52:12 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 22 Apr 2008 13:52:12 -0500 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. In-Reply-To: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> Message-ID: Ken, On Tue, Apr 22, 2008 at 1:36 PM, Kenneth McDonald wrote: > Sadly. > > Thanks, > Ken > -- > http://mail.python.org/mailman/listinfo/python-list > I've attached the 2.4 version. I also have some Windows binaries for Beautiful Soup uploaded to my website: http://www.pythonlibrary.org/python_modules.htm Hope that helps. Mike -------------- next part -------------- A non-text attachment was scrubbed... Name: BeautifulSoup.py Type: text/x-python Size: 69566 bytes Desc: not available URL: From ch612bunn at gmail.com Sun Apr 27 09:13:59 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:13:59 -0700 (PDT) Subject: avs video converter 5.6.1.715 crack Message-ID: <3dfc2689-c9d6-4379-ab70-102f4b44a274@i76g2000hsf.googlegroups.com> avs video converter 5.6.1.715 crack http://wga-cracks.crackkey.net From oakley at bardo.clearlight.com Sun Apr 13 13:19:22 2008 From: oakley at bardo.clearlight.com (Bryan Oakley) Date: Sun, 13 Apr 2008 17:19:22 GMT Subject: tkinter, canvas, get color of image? In-Reply-To: <0e4c9708-dbe9-4f29-ac31-34f7298f2624@m1g2000pre.googlegroups.com> References: <0e4c9708-dbe9-4f29-ac31-34f7298f2624@m1g2000pre.googlegroups.com> Message-ID: skanemupp at yahoo.se wrote: > mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\elmapovic.gif') > w.create_image(10, 10, image = mapq, anchor = NW) > > after doing this is there any possibility of getting the > characteristics of the GIF-picture(or bitmap if i use that)? > > it would be very helpfull if i for example could do something like > canvas.getcolor(image, mouseclick.x,mouseclick.y) if u get the point. > get the color of the image where i clicked. The image isn't "painted" on the canvas, so to answer your specific question, no, you can't get the color of a pixel on the canvas in the way that you ask. However, when you click on the canvas you can get the item that was clicked on and the x/y of the click. From that you can figure out which pixel of the image is under the cursor. And from that you can query the image for the color of a specific pixel. From rkmr.em at gmail.com Mon Apr 21 18:59:33 2008 From: rkmr.em at gmail.com (rkmr.em at gmail.com) Date: Mon, 21 Apr 2008 15:59:33 -0700 Subject: dynamically importing a module and function In-Reply-To: <480d1782$1@news.mel.dft.com.au> References: <480d1782$1@news.mel.dft.com.au> Message-ID: On Mon, Apr 21, 2008 at 3:39 PM, John Machin wrote: > rkmr.em at gmail.com wrote: > > data['module'], in the directory data['cwd'] > OT: Any good reason for using a dictionary instead of a class instance > (data.functiom, data.module, etc)? not really, i just wanted to stick to primitive python data types. > > If I do this from python interactive shell (linux fedora core 8) from > > dir /home/mark it works fine: > > > > cwd = data['cwd'] > > os.chdir(cwd) > > print os.getcwd() > > module = __import__(data['module']) > > function = getattr(module, data['function']) > > > > > saved = sys.path > sys.path = data['cwd'] > module = __import__(data['module']) > sys.path = saved now the module gets loaded, but i am not able to get the function from the module, though it works fine in the interactive-shell Traceback (most recent call last): File "/home/mark/work/common/funcq.py", line 62, in if __name__ == '__main__':do() File "/home/mark/work/common/funcq.py", line 35, in do function = getattr(module, data['function']) AttributeError: 'module' object has no attribute 'new' this works in shell though.. >>> import os >>> os.chdir('/home/mark/work/proj1') >>> import sys >>> sys.path.append('/home/mark/work/proj1') >>> module = __import__('app') >>> function = getattr(module, 'new') >>> function(1) 1 From deets at nospam.web.de Wed Apr 2 17:00:28 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 02 Apr 2008 23:00:28 +0200 Subject: Recursive function won't compile In-Reply-To: References: Message-ID: <65iafeF2g9cvvU1@mid.uni-berlin.de> bc1891 at googlemail.com schrieb: > #include > #include > > def RecursiveFact(n): > if(n>1): > return n*RecursiveFact(n-1) > else: > return 1 > > fact = RecursiveFact(31) > print fact > > fact = "End of program" > print fact > > > ......but yet it still gives the right answer. How is this possible? Given that you obviously don't use python, but some weird cross-breed beteween python and C - who are we to judge the semantics of that chimera? Diez From __peter__ at web.de Thu Apr 3 05:56:55 2008 From: __peter__ at web.de (Peter Otten) Date: Thu, 03 Apr 2008 11:56:55 +0200 Subject: unicode in exception traceback References: Message-ID: WaterWalk wrote: > Hello. I just found on Windows when an exception is raised and > traceback info is printed on STDERR, all the characters printed are > just plain ASCII. Take the unicode character u'\u4e00' for example. If > I write: > > print u'\u4e00' > > If the system locale is "PRC China", then this statement will print > this character as a single Chinese character. > > But if i write: assert u'\u4e00' == 1 > > An AssertionError will be raised and traceback info will be put to > STDERR, while this time, u'\u4e00' will simply be printed just as > u'\u4e00', several ASCII characters instead of one single Chinese > character. I use the coding directive commen(# -*- coding: utf-8 -*-)t > on the first line of Python source file and also save it in utf-8 > format, but the problem remains. > > What's worse, if i directly write Chinese characters in a unicode > string, when the traceback info is printed, they'll appear in a non- > readable way, that is, they show themselves as something else. It's > like printing something DBCS characters when the locale is incorrect. > > I think this problem isn't unique. When using some other East-Asia > characters, the same problem may recur. > > Is there any workaround to it? Pass a byte string but make some effort to use the right encoding: >>> assert False, u"\u4e00".encode(sys.stdout.encoding or "ascii", "xmlcharrefreplace") Traceback (most recent call last): File "", line 1, in AssertionError: ? You might be able to do this in the except hook: $ cat unicode_exception_message.py import sys def eh(etype, exc, tb, original_excepthook=sys.excepthook): message = exc.args[0] if isinstance(message, unicode): exc.args = (message.encode(sys.stderr.encoding or "ascii", "xmlcharrefreplace"),) + exc.args[1:] return original_excepthook(etype, exc, tb) sys.excepthook = eh assert False, u"\u4e00" $ python unicode_exception_message.py Traceback (most recent call last): File "unicode_exception_message.py", line 11, in assert False, u"\u4e00" AssertionError: ? If python cannot figure out the encoding this falls back to ascii with xml charrefs: $ python unicode_exception_message.py 2>tmp.txt $ cat tmp.txt Traceback (most recent call last): File "unicode_exception_message.py", line 11, in assert False, u"\u4e00" AssertionError: 一 Note that I've not done any tests; e.g. if there are exceptions with immutable .args the except hook itself will fail. Peter From grante at visi.com Wed Apr 16 14:26:20 2008 From: grante at visi.com (Grant Edwards) Date: Wed, 16 Apr 2008 13:26:20 -0500 Subject: Finally had to plonk google gorups. References: <28d12cc8-5375-4e95-8e37-f872d238a1bd@b64g2000hsa.googlegroups.com> Message-ID: <6cadnYCFdNpR2ZvVnZ2dnUVZ_tPinZ2d@visi> On 2008-04-16, Mensanator wrote: > On Apr 16, 9:19?am, Grant Edwards wrote: >> This morning almost half of c.l.p was spam. ?In order to try >> to not tar both the benign google group users and the >> malignant ones with the same brush, I've been trying to kill >> usenet spam with subject patterns. ?But that's not a battle >> you can win, so I broke down and joined all the other people >> that just killfile everything posted via google.groups. > > Not very bright, eh? > >> AFAICT, if you're a google groups user your posts are not being >> seen by many/most experienced (read "non-google-group") users. >> This is mainly the fault of google who has refused to do >> anything to stem the flood of span that's being sent via Google >> Groups. > > Duh. My. That was certainly a well-reasoned and well-written response. -- Grant Edwards grante Yow! Hey, waiter! I want at a NEW SHIRT and a PONY TAIL visi.com with lemon sauce! From kyosohma at gmail.com Tue Apr 8 13:33:40 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 8 Apr 2008 10:33:40 -0700 (PDT) Subject: set file permission on windows References: Message-ID: <7d75fc7b-a2b7-4ca2-b386-27da975043d0@m44g2000hsc.googlegroups.com> On Apr 8, 12:03 pm, "Tim Arnold" wrote: > hi, I need to set file permissions on some directory trees in windows using > Python. > > When I click on properties for a file and select the 'Security' tab, I see a > list of known 'Group or user names' with permissions for each entry such as > Full Control, Modify, Read&Execute, etc. > > I need to (for example) periodically set Group Permissions for one group to > Read, and another Group to None. I need to apply the settings to several > directory trees recursively. > > If this was on Unix, I'd just use os.stat I guess. I don't think that will > work in this case since all I know is the Group names and the permissions I > need to allow. > > thanks for any pointers, > --Tim Arnold According to the following thread, you can use os.chmod on Windows: http://mail.python.org/pipermail/python-list/2003-June/210268.html You can also do it with the PyWin32 package. Tim Golden talks about one way to do it here: http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html Also see the following thread: http://mail.python.org/pipermail/python-win32/2004-July/002102.html or http://bytes.com/forum/thread560518.html Hope that helps! Mike From tom at vector-seven.com Thu Apr 17 19:40:06 2008 From: tom at vector-seven.com (Thomas Lee) Date: Fri, 18 Apr 2008 09:40:06 +1000 Subject: [Python-Dev] Global Python Sprint Weekends: May 10th-11th and June 21st-22nd. In-Reply-To: <94bdd2610804170644x4db329b0vf49de21a590c51e@mail.gmail.com> References: <87D3F9C72FBF214DB39FA4E3FE618CDC6E22F389FE@EXMBX04.exchhosting.com> <4806482C.4030305@voidspace.org.uk> <94bdd2610804170644x4db329b0vf49de21a590c51e@mail.gmail.com> Message-ID: <4807DFD6.5040800@vector-seven.com> Anybody in Melbourne keen for this? Not sure if I'll be able to make it myself, but I'd be interested to know if there's anybody in the area keen to do the sprint. Cheers, T Tarek Ziad? wrote: > On Wed, Apr 16, 2008 at 8:40 PM, Michael Foord > wrote: > >> Trent Nelson wrote: >> > Following on from the success of previous sprint/bugfix weekends and >> > sprinting efforts at PyCon 2008, I'd like to propose the next two >> > Global Python Sprint Weekends take place on the following dates: >> > >> > * May 10th-11th (four days after 2.6a3 and 3.0a5 are released) >> > * June 21st-22nd (~week before 2.6b2 and 3.0b2 are released) >> > >> > It seems there are a few of the Python User Groups keen on meeting >> > up in person and sprinting collaboratively, akin to PyCon, which I >> > highly recommend. I'd like to nominate Saturday across the board >> > as the day for PUGs to meet up in person, with Sunday geared more >> > towards an online collaboration day via IRC, where we can take care >> > of all the little things that got in our way of coding on Saturday >> > (like finalising/preparing/reviewing patches, updating tracker and >> > documentation, writing tests ;-). >> > >> > For User Groups that are planning on meeting up to collaborate, >> > please reply to this thread on python-dev at python.org and let every- >> > one know your intentions! >> > >> > >> >> I should be able to help organise and attend the London contribution. >> Personally I'd like to work on the documentation changes / clean-up for >> the unittest module discussed recently. >> > > We are trying to set up a team here in Paris, > > Personnally I would like to continue the work started in distutils > (various patches) > and some friends here are interested in contributing on documentation. > > Tarek > > From python at bdurham.com Tue Apr 29 13:40:11 2008 From: python at bdurham.com (python at bdurham.com) Date: Tue, 29 Apr 2008 13:40:11 -0400 Subject: Given a string - execute a function by the same name In-Reply-To: <86ac1b9c0804290909w261a01fdy5de70d93607495e7@mail.gmail.com> References: <27f6ba19-8756-4d96-851f-2a7c585ef3c7@m44g2000hsc.googlegroups.com> <1209483330.17070.1250499293@webmail.messagingengine.com> <86ac1b9c0804290909w261a01fdy5de70d93607495e7@mail.gmail.com> Message-ID: <1209490811.6796.1250524559@webmail.messagingengine.com> Erik, > Perhaps I missed something earlier in the thread, but I really don't see the need for that registry dict or the register decorator. Python already maintains a dictionary for each scope: The advantage of the decorator technique is that you explicitly declare which functions are eligible for execution. Using locals() is too broad because it might allow a user to execute an unintended function. Malcolm From jgodoy at gmail.com Sun Apr 27 12:20:53 2008 From: jgodoy at gmail.com (Jorge Godoy) Date: Sun, 27 Apr 2008 13:20:53 -0300 Subject: design choice: multi-threaded / asynchronous wxpython client? References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: bullockbefriending bard wrote: > 3) I need to dump this data (for all races, not just current about to > start race) to text files, store it as BLOBs in a DB *and* update real > time display in a wxpython windowed client. Why in a BLOB? Why not into specific data types and normalized tables? You can also save the BLOB for backup or auditing, but this won't allow you to use your DB to the best of its capabilities... It will just act as a data container, the same as a network share (which would not penalize you too much to have connections open/closed). From tinnews at isbd.co.uk Thu Apr 3 08:11:51 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 03 Apr 2008 12:11:51 GMT Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> <40eadbd9-798b-49b8-8acb-5e27f9b38809@s37g2000prg.googlegroups.com> Message-ID: <47f4c987$0$713$bed64819@news.gradwell.net> Paul Hankin wrote: > On Apr 3, 12:37 pm, tinn... at isbd.co.uk wrote: > > What's the neatest and/or most efficient way of testing if one of a > > set of strings (contained in a dictionary, list or similar) is a > > sub-string of a given string? > > > > I.e. I have a string delivered into my program and I want to see if > > any of a set of strings is a substring of the string I have been > > given. It's quite OK to stop at the first one found. Ideally the > > strings being searched through will be the keys of a dictionary but > > this isn't a necessity, they can just be in a list if it could be done > > more efficiently using a list. > > > > Is this the best one can do (ignoring the likelihood that I've got > > some syntax wrong) :- > > > > # l is the list > > # str is the incoming string > > answer = "" > > for x in l: > > if str.find(x) < 0: > > continue > > answer = x > > I'd not use 'l' (confused with '1') or 'str' (a standard module) as > variable names. Neither would I, it was just thrown together to show how I was thinking. > Your code checks every string in the list even when > it's found one... you can reverse the test and break when the first > one is found. Using 'in' rather than testing the return value of find > is nicer as a substring test. Finally, using the 'else' clause lets > you make it clear that answer is set to the empty string when no match > is found. > > for answer in l: > if str in answer: break > else: > answer = '' > OK, that does improve things somewhat, thanks. -- Chris Green From kevin.p.dwyer at gmail.com Wed Apr 23 08:04:38 2008 From: kevin.p.dwyer at gmail.com (kdwyer) Date: Wed, 23 Apr 2008 05:04:38 -0700 (PDT) Subject: problem with dictionaries References: Message-ID: On Apr 23, 12:16 pm, Simon Strobl wrote: > Hello, > > the idea of the following program is to parse a frequency list of the > form FREQUENCY|WORD, to store the frequency of a word in a dictionary > (and to do some things with this information later). > > I have done this many many times. Suddenly, it does not work any more: > The value frq[key] is different from the value that key has in the > file 'my_frqlist.txt'. > > I am using Python 2.5.1 > > Any hints? > > Simon > > ================================================ > > #!/usr/bin/python > > import sys > > frqlist = open('my_frqlist.txt', 'r') > > # my_frqlist looks like this: > # 787560608|the > # 434879575|of > # 413442185|and > # 395209748|to > # 284833918|a > # 249111541|in > # 169988976|is > > frq = {} > > for line in frqlist: > line = line.rstrip() > frequency, word = line.split('|') > frq[word] = int(frequency) > > for key in frq.keys(): > print key, frq[key] It works for me, save that you need to read the file into a list first - is this really the code that you are running? What results are you getting? K From steve at holdenweb.com Fri Apr 25 09:25:37 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 25 Apr 2008 09:25:37 -0400 Subject: Environment Variables In-Reply-To: References: Message-ID: Krishna wrote: > Environment variable set up is the most confusing part for me all the > time. Please help me with the following questions: > > When I install python in a new system, I will go to environment > variables (system variables) and set "path" pointing to C:\Python25 > and thats all I do. > I type python from "cmd" window and its converting to python window > for python execution. All fine up to this point. > Now, I want to drag and drop python (.py) files to this window and > execute it. My python files are located in different directories > inside C: and outside C:. When I do that, I get errors and the file is > not found and its not imported. ALso, inside the .py file, if I have a > command to open a different file, it doesnt see that either. How do I > overcome these basic difficulties in python. I wish I can open any > file and work on that using python. > http://www.python.org/doc/faq/windows/#how-do-i-run-a-python-program-under-windows regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From duncan.booth at invalid.invalid Tue Apr 1 03:22:41 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 1 Apr 2008 07:22:41 GMT Subject: Newbie Question - Overloading == References: <85edb5fb-eae8-4e8f-8f77-0ee4668063cd@u69g2000hse.googlegroups.com> <7eb5d21a-c4de-4655-ab93-9221d996f424@i7g2000prf.googlegroups.com> Message-ID: "bruno.desthuilliers at gmail.com" wrote: >> Surely an A isn't equal to every other object which just happens to >> have the same attributes 'a' and 'b'? > > And why not ?-) > >> I would have thoughts the tests want to be >> something like: >> >> class A: >> def __eq__(self,other): >> return (isinstance(other, A) and >> self.a == other.a and self.b == other.b) >> >> (and similar for B) with either an isinstance or exact match required >> for the type. > > I don't think there's a clear rule here. Python is dynamically typed > for good reasons, and MHO is that you should not fight against this > unless you have equally good reasons to do so. > I fully agree with that, but an apple != a pear, even if they are the same size and colour. There will be some types where you can have equality between objects of different types (e.g. int/float), but more often the fact that they are different types wil automatically mean they are not equal. From darcy at druid.net Thu Apr 24 06:39:23 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Thu, 24 Apr 2008 06:39:23 -0400 Subject: annoying dictionary problem, non-existing keys In-Reply-To: <481043C5.20409@jouy.inra.fr> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> <481043C5.20409@jouy.inra.fr> Message-ID: <20080424063923.04d32bba.darcy@druid.net> On Thu, 24 Apr 2008 10:24:37 +0200 Robert Bossy wrote: > Way 2: make conf a defaultdict instead of a dict, the documentation is > there: > http://docs.python.org/lib/defaultdict-objects.html Only for 2.5 and up though. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From steve at holdenweb.com Sun Apr 13 07:57:27 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 13 Apr 2008 07:57:27 -0400 Subject: =?GB2312?B?09DW0Ln6yMu69T8=?= In-Reply-To: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> References: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> Message-ID: bikthh at live.cn wrote: > Python????????????????. ?, Python ????????????, ????????? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From Graham.Dumpleton at gmail.com Mon Apr 28 08:03:35 2008 From: Graham.Dumpleton at gmail.com (Graham Dumpleton) Date: Mon, 28 Apr 2008 05:03:35 -0700 (PDT) Subject: apache module: python and web programming, easy way...? References: Message-ID: On Apr 28, 7:42?pm, bvidinli wrote: > is there any apache module, you know, that i can just install with apt-get, > then put my .py file, and run it ? http://www.modwsgi.org http://www.modpython.org The mod_wsgi module supports WSGI (http://www.wsgi.org) specification which is where Python web framework hosting is heading whereas mod_python has its own specific API which results in your application only being able to be hosted with it and nothing else. Graham From grepla at gmail.com Wed Apr 30 01:25:32 2008 From: grepla at gmail.com (grepla at gmail.com) Date: Tue, 29 Apr 2008 22:25:32 -0700 (PDT) Subject: Problem with variables assigned to variables??? Message-ID: I have a simple line of code that requires the following inputs - an input file, output file and a SQL expression. the code needs to be run with several different SQL expressions to produce multiple output files. To do this I first created a list of a portion of the output filename: mylist = ('name1', 'name2', 'name3') I also assigned variables for each SQL expression: name1 = "\"field_a\" LIKE '021'" name2 = "\"field_a\" LIKE '031'" name3 = "\"field_a\" LIKE '041'" Notice the variable names are the same as the listmember strings, that is intentional, but obviously doesn't work. the loop: for listmember in mylist: print listmember + ".shp", listmember my intended output is: name1.shp "field_a LIKE '021' name2.shp "field_a LIKE '031' name3.shp "field_a LIKE '041' but, of course, the variable listmember returns the name of the listmember which makes perfect sense to me: name1.shp name1 So how can I iterate not only the filenames but the SQL expressions as well? From blog189 at watchesblog.cn Fri Apr 18 07:03:00 2008 From: blog189 at watchesblog.cn (blog189 at watchesblog.cn) Date: Fri, 18 Apr 2008 04:03:00 -0700 (PDT) Subject: Brand Watches CITIZEN Eco Drive Women's Black Dial 2-Hand Watch SY2030-54E Discount, Replica, Fake Message-ID: <5093f80b-6e00-4980-ae23-465d049ce91e@y18g2000pre.googlegroups.com> Brand Watches CITIZEN Eco Drive Women's Black Dial 2-Hand Watch SY2030-54E Discount, Replica, Fake Browse our CITIZEN Eco Drive Women's Black Dial 2-Hand Watch SY2030-54E replica watches, which is sure the watch you are looking for at low price. There are more high quality designer watch replicas for selection CITIZEN Eco Drive Women's Black Dial 2-Hand Watch SY2030-54E Link : http://www.watches-brand.com/Replica-Citizen-6180.html Brand : Citizen ( http://www.watches-brand.com/Citizen-Replica.html ) Model : CITIZEN Eco Drive Women's Black Dial 2-Hand Watch SY2030-54E Description :

Watch with Stainless Steel band. Stainless Steel Rectangular Case with diamonds. Scratch Resistant Mineral Crystal. Quartz Movement. Water resistant up to 30 meters.

Sale Price : $ 210.00 CITIZEN Eco Drive Women's Black Dial 2-Hand Watch SY2030-54E Details :
  • Brand: Citizen
  • Band material: stainless-steel
  • Case material: Stainless-Steel
  • Dial color: Black
  • Dial window material: Scratch Resistant Mineral Crystal
  • Water-resistant to 30 meters
CITIZEN Eco Drive Women's Black Dial 2-Hand Watch SY2030-54E is new brand replica, join thousands of satisfied customers and buy your Citizen with total satisfaction. A watches-brand.COM 30 Day Money Back Guarantee is included with every Citizen Replica Series for secure, risk-free online shopping. watches-brand.COM does not charge sales tax for the Fake CITIZEN Eco Drive Women's Black Dial 2-Hand Watch SY2030-54E. All of our replica watches are shipped via EMS to worldwide. Normally it takes 3days to prepare the fake watch you ordered and 5-10days to transmit depending on the different destination.We pay for the free shipping cost for total quantity over 20 pcs. The EMS tracking NO. will be sent by email when an order is shipped from our warehouse. No more other charges from watches-brand.com such as the tax. If you have any other questions please check our other pages or feel free to email us by sales at watches-brand.com. The Same Replica Citizen Watches Series : Citizen Eco-Drive Alarm (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6181.html Citizen Eco-Drive Black Dial (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6182.html Citizen Eco-Drive Black dial (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6183.html Citizen Eco-Drive Black dial (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6184.html Citizen Eco-Drive Black dial (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6185.html Citizen Eco-Drive Black dial (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6186.html Citizen Eco-Drive Black dial (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6187.html Citizen Eco-Drive Black dial (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6188.html Citizen Eco-Drive Blue dial (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6189.html Citizen Eco-Drive Blue dial (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6190.html Brand Watches CITIZEN Eco Drive Women's Black Dial 2-Hand Watch SY2030-54E Discount, Replica, Fake From landofdreams at gmail.com Wed Apr 30 23:46:22 2008 From: landofdreams at gmail.com (Sam) Date: Wed, 30 Apr 2008 20:46:22 -0700 (PDT) Subject: relative import broken? References: <9c6ba5f9-d65b-4265-baba-fc5d7936781b@d1g2000hsg.googlegroups.com> <87prs6x1ye.fsf@mulj.homelinux.net> Message-ID: <33782b65-6d6d-4ae7-8539-29f809ae5077@d45g2000hsc.googlegroups.com> On Apr 30, 9:11 pm, Hrvoje Niksic wrote: > Sam writes: > > I also have a problem with relative import; I can't for the life of me > > figure out how to use the damn thing. I think the main problem is with > > getting Python to recognize the existence of a package. I have > > > S/ > > p.py > > B/ > > b.py > > W/ > > pyw/ > > u.py > > ws.py > > > and I'd like to get u.py to import all the other 3 programs. I put > > empty __init__.py files in all of the above directories (is this > > necessary?), and even manually added the pathway (r'C:\Myname\S') to > > sys.path, but when I execute > > > from S import p > > > in u.py Python gives "ImportError: No module named S". > > A silly question: is the directory that contains "S" in PYTHONPATH or > in sys.path? It's in sys.path. I'm not sure how to access or change PYTHONPATH from within a program (I'm running everything in IDLE). I'm using Windows, btw. > > > The docs for relative import make this sound much easier than it is. > > It's supposed to be just as easy as it sounds. For example: > > $ mkdir S > $ touch S/p.py > $ touch S/__init__.py > $ python > Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 > Type "help", "copyright", "credits" or "license" for more information.>>> from S import p > >>> p > > From ivan.illarionov at gmail.com Tue Apr 22 00:04:46 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Tue, 22 Apr 2008 04:04:46 +0000 (UTC) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> <85c14b14-9302-41bb-9270-b7cdd65098b0@c65g2000hsa.googlegroups.com> Message-ID: On Mon, 21 Apr 2008 16:10:05 -0700, George Sakkis wrote: > On Apr 21, 5:30 pm, Ivan Illarionov wrote: > >> On 22 ???, 01:01, Peter Otten <__pete... at web.de> wrote: >> >> > Ivan Illarionov wrote: >> > > And even faster: >> > > a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, >> > > len(s), 3)))) >> > > if sys.byteorder == 'little': >> > > a.byteswap() >> >> > > I think it's a fastest possible implementation in pure python >> >> > Clever, but note that it doesn't work correctly for negative numbers. >> > For those you'd have to prepend "\xff" instead of "\0". >> >> > Peter >> >> Thanks for correction. >> >> Another step is needed: >> >> a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, >> len(s), 3)))) >> if sys.byteorder == 'little': >> a.byteswap() >> result = [n if n < 0x800000 else n - 0x1000000 for n in a] >> >> And it's still pretty fast :) > > Indeed, the array idea is paying off for largeish inputs. On my box > (Python 2.5, WinXP, 2GHz Intel Core Duo), the cutoff point where > from3Bytes_array becomes faster than from3Bytes_struct is close to 150 > numbers (=450 bytes). > > The struct solution though is now almost twice as fast with Psyco > enabled, while the array doesn't benefit from it. Here are some numbers > from a sample run: > > *** Without Psyco *** > size=1 > from3Bytes_ord: 0.033493 > from3Bytes_struct: 0.018420 > from3Bytes_array: 0.089735 > size=10 > from3Bytes_ord: 0.140470 > from3Bytes_struct: 0.082326 > from3Bytes_array: 0.142459 > size=100 > from3Bytes_ord: 1.180831 > from3Bytes_struct: 0.664799 > from3Bytes_array: 0.690315 > size=1000 > from3Bytes_ord: 11.551990 > from3Bytes_struct: 6.390999 > from3Bytes_array: 5.781636 > *** With Psyco *** > size=1 > from3Bytes_ord: 0.039287 > from3Bytes_struct: 0.009453 > from3Bytes_array: 0.098512 > size=10 > from3Bytes_ord: 0.174362 > from3Bytes_struct: 0.045785 > from3Bytes_array: 0.162171 > size=100 > from3Bytes_ord: 1.437203 > from3Bytes_struct: 0.355930 > from3Bytes_array: 0.800527 > size=1000 > from3Bytes_ord: 14.248668 > from3Bytes_struct: 3.331309 > from3Bytes_array: 6.946709 > > > And here's the benchmark script: > > import struct > from array import array > > def from3Bytes_ord(s): > return [n if n<0x800000 else n-0x1000000 for n in > ((ord(s[i])<<16) | (ord(s[i+1])<<8) | ord(s[i+2]) > for i in xrange(0, len(s), 3))] > > unpack_i32be = struct.Struct('>l').unpack def from3Bytes_struct(s): > return [unpack_i32be(s[i:i+3] + '\0')[0]>>8 > for i in xrange(0,len(s),3)] > > def from3Bytes_array(s): > a = array('l', ''.join('\0' + s[i:i+3] > for i in xrange(0,len(s), 3))) > a.byteswap() > return [n if n<0x800000 else n-0x1000000 for n in a] > > > def benchmark(): > from timeit import Timer > for n in 1,10,100,1000: > print ' size=%d' % n > # cycle between positive and negative buf = > ''.join(struct.pack('>i', 1234567*(-1)**(i%2))[1:] > for i in xrange(n)) > for func in 'from3Bytes_ord', 'from3Bytes_struct', > 'from3Bytes_array': > print ' %s: %f' % (func, > Timer('%s(buf)' % func , > 'from __main__ import %s; buf=%r' % (func,buf) > ).timeit(10000)) > > > if __name__ == '__main__': > s = ''.join(struct.pack('>i',v)[1:] for v in > [0,1,-2,500,-500,7777,-7777,-94496,98765, > -98765,8388607,-8388607,-8388608,1234567]) > assert from3Bytes_ord(s) == from3Bytes_struct(s) == > from3Bytes_array(s) > > print '*** Without Psyco ***' > benchmark() > > import psyco; psyco.full() > print '*** With Psyco ***' > benchmark() > > > George Comments: You didn't use the faster version of array approach: ''.join('\0' + s[i:i+3] for i in xrange(0,len(s), 3)) is slower than '\0' + '\0'.join(s[i:i+3] for i in xrange(0,len(s), 3)) To Bob Greschke: Struct is fast in Python 2.5 with struct.Struct class. Array approach should work with Python 2.3 and it's probably the fastest one (without psyco) with large inputs: def from3bytes_array(s): a = array.array('i', '\0' + '\0'.join([s[i:i+3] for i in xrange(0, len(s), 3)])) a.byteswap() # if your system is little-endian return [n >= 0x800000 and n - 0x1000000 or n for n in a] -- Ivan From pofuk at mzm.hr Sat Apr 5 17:08:27 2008 From: pofuk at mzm.hr (SMALLp) Date: Sat, 05 Apr 2008 23:08:27 +0200 Subject: Transparent bitmap(image) in windows! Message-ID: Hello everyone! First I want to apologize for asking question about wxPython on this group. I'm doing project that uses wx.ScrolledPanel few wx.Bitmap on it. It all looks wonderful on Ubuntu and very very bad on windows because images aren't transparent. As a found out it is problem that windows drowns each image in separate window (or something like that) I'm looking for best and easiest solution for this problem. I found something to bind PAINT event to empty function but it doesn't work because of scrolled panel. Please help! Thanks! From george.sakkis at gmail.com Wed Apr 2 13:09:37 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 2 Apr 2008 10:09:37 -0700 (PDT) Subject: Manipulate Large Binary Files References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> Message-ID: On Apr 2, 11:50 am, Derek Martin wrote: > On Wed, Apr 02, 2008 at 10:59:57AM -0400, Derek Tracy wrote: > > I generated code that works wonderfully for files under 2Gb in size > > but the majority of the files I am dealing with are over the 2Gb > > limit > > > ary = array.array('H', INPUT.read()) > > You're trying to read the file all at once. You need to break your > reads up into smaller chunks, in a loop. You're essentially trying to > store more data in memory than your OS can actually access in a single > process... > > Something like this (off the top of my head, I may have overlooked > some detail, but it should at least illustrate the idea): > > # read a meg at a time > buffsize = 1048576 > while true: > buff = INPUT.read(buffsize) > OUTPUT.write(buff) > if len(buff) != buffsize: > break Or more idiomatically: from functools import partial for buff in iter(partial(INPUT.read, 10 * 1024**2), ''): # process each 10MB buffer George From rocco.rossi at gmail.com Wed Apr 23 18:46:36 2008 From: rocco.rossi at gmail.com (rocco.rossi at gmail.com) Date: Wed, 23 Apr 2008 15:46:36 -0700 (PDT) Subject: Python generators (coroutines) References: Message-ID: <5c4add67-76fa-434f-877e-64daee0fc1de@e53g2000hsa.googlegroups.com> > Anyway, if you have a blocking operation, the only solution is to use > a thread or a separate process. > > Michele Simionato That's what I thought. It was in fact rather obvious, but I wanted to be sure that I hadn't overlooked some arcane possibility (ex. with the use of exceptions or something like that). Thanks for the confirmation. From wizzardx at gmail.com Sat Apr 26 06:20:33 2008 From: wizzardx at gmail.com (David) Date: Sat, 26 Apr 2008 12:20:33 +0200 Subject: nntplib retrieve news://FULL_URL In-Reply-To: References: Message-ID: <18c1e6480804260320m3f088ebdpe8980a482855418a@mail.gmail.com> > So I have established a connection to an nntp server and I am > retrieving articles to other articles on the server such as > news://newsclip.ap.org/D8L4MFAG0 at news.ap.org > > Now I am wondering how I query for that article based off of the url? > > I assume D8L4MFAG0 is an id of some sort but when I try and retrieve > that article via myNntpObject.article('D8L4MFAG0') I get an error of > 423 Bad article number. Which makes sense as all the other article > numbers are integers. > > D8L4MFAG0 actually looks like a doc-id value for an NITF article > stored on the NNTP server which I am retrieving content off of. > > Anyone have any ideas on how I fetch this content? Have a look at the 'Message-ID' header of articles on the server. They usually start and end with "<" and end with ">". An example from comp.lang.python: You probably got the "423 Bad article number" error because there wasn't a "<" and ">" in your message ID, so it tried to parse it as an article number instead. I couldn't check your example because newsclip.ap.org requires a login. David. From nagle at animats.com Fri Apr 4 11:21:34 2008 From: nagle at animats.com (John Nagle) Date: Fri, 04 Apr 2008 08:21:34 -0700 Subject: collecting results in threading app In-Reply-To: References: Message-ID: <47f64507$0$36354$742ec2ed@news.sonic.net> Gerardo Herzig wrote: > Hi all. Newbee at threads over here. Im missing some point here, but cant > figure out which one. > > This little peace of code executes a 'select count(*)' over every table > in a database, one thread per table: > > class TableCounter(threading.Thread): > def __init__(self, conn, table): > self.connection = connection.Connection(host=conn.host, > port=conn.port, user=conn.user, password='', base=conn.base) > threading.Thread.__init__(self) > self.table = table > > def run(self): > result = self.connection.doQuery("select count(*) from %s" % > self.table, [])[0][0] > print result > return result > > > class DataChecker(metadata.Database): > > def countAll(self): > for table in self.tables: > t = TableCounter(self.connection, table.name) > t.start() > return > > > It works fine, in the sense that every run() method prints the correct > value. > But...I would like to store the result of t.start() in, say, a list. The > thing is, t.start() returns None, so...what im i missing here? > Its the desing wrong? 1. What interface to MySQL are you using? That's not MySQLdb. 2. If SELECT COUNT(*) is slow, check your table definitions. For MyISAM, it's a fixed-time operation, and even for InnoDB, it shouldn't take that long if you have an INDEX. 3. Threads don't return "results" as such; they're not functions. As for the code, you need something like this: class TableCounter(threading.Thread): def __init__(self, conn, table): self.result = None ... def run(self): self.result = self.connection.doQuery("select count(*) from %s" % self.table, [])[0][0] def countAll(self): mythreads = [] # list of TableCounter objects # Start all threads for table in self.tables: t = TableCounter(self.connection, table.name) mythreads.append(t) # list of counter threads t.start() # Wait for all threads to finish totalcount = 0 for mythread in mythreads: # for all threads mythread.join() # wait for thread to finish totalcount += mythread.result # add to result print "Total size of all tables is:", totalcount John Nagle From tjreedy at udel.edu Fri Apr 25 18:49:26 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 25 Apr 2008 18:49:26 -0400 Subject: Remove old version before upgrade? References: Message-ID: "Steve Holden" wrote in message news:furl3k$v6t$1 at ger.gmane.org... | Sal wrote: | > I'm currently running Windows version 2.5.1 and would like to upgrade | > to 2.5.2. My question is, can I just go ahead and install the new | > version over the old or should I remove the old version with add/ | > remove programs first? The old version is in a directory named | > Python25. | | You can do either. Since there's no change of major version the | executable will have the same path, and the deinstall handily leaves all | files that weren't part of the original install in place. So if it suits | your sense of neatness, by all means deinstall before reinstallation. I would leave things alone unless you really want to start from scratch. If you have installed any 3rd party packages that put files in Python25/DLLs or Python25/Libs/site-packages, I would not trust the uninstaller to not disturb anything. From fetchinson at googlemail.com Tue Apr 22 12:27:48 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Tue, 22 Apr 2008 09:27:48 -0700 Subject: Does Python 2.5.2's embedded SQLite support full text searching? In-Reply-To: <6763uaF2norrtU1@mid.uni-berlin.de> References: <1208794249.15992.1249049327@webmail.messagingengine.com> <6763uaF2norrtU1@mid.uni-berlin.de> Message-ID: > >> Does Python 2.5.2's embedded SQLite support full text searching? > >> > >> Any recommendations on a source where one can find out which SQLite > >> features are enabled/disabled in each release of Python? I'm trying to > >> figure out what's available in 2.5.2 as well as what to expect in 2.6 > >> and 3.0. > > > > Sqlite itself is not distributed with python. Only a python db api > > compliant wrapper is part of the python stdlib and as such it is > > completely independent of the sqlite build. In other words, if your > > sqlite build supports full text searching you can use it through the > > python sqlite wrapper (that is part of the stdlib) and if it doesn't > > then not. This is true for any sqlite feature though. > > > > So if you need an sqlite feature just go ahead and build your own > > sqlite with that feature enabled and use that feature with the stock > > python sqlite wrapper that comes with the stdlib. > > I doubt that. This would mean that Python comes with a mechanism to > dynamically load different libs for the same module, opening a buttload > full of error-conditions regarding library versions & changing semantics > depending on system configuration. That mechanism is called dynamical shared object loading. The wrapper _sqlite3.so uses libsqlite3.so (which is the sqlite library itself, independently of python) and so if you want to use a custom sqlite which behaves the same as the original sqlite only it adds, for example, a new SQL keyword that can be used in queries, all you need to do is compile it and replace libsqlite3.so with your custom build. If you pass the new SQL keyword in a query from python through the db api it will travel to the part of the wrapper that is implemented in python then to the C wrapper (_sqlite3.so) and then to your new libsqlite3.so which interprets the new keyword correctly. Of course you can not change the sqlite C api in this way for that you would need to rebuild _sqlite3.so as well. Cheers, Daniel > Instead, the sqlite standard lib comes with its own version of sqlite. > If you want something other, you need to > > - install sqlite on your system, including library & headers > - compile the pysqlite extension module > > it will be available in a different module path to prevent confusion. > > THe same is true for ElementTree, btw. From ivan.illarionov at gmail.com Thu Apr 17 19:19:37 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Thu, 17 Apr 2008 23:19:37 +0000 (UTC) Subject: Request a short code review References: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> Message-ID: On Thu, 17 Apr 2008 15:11:40 -0700, james wrote: >> I am not necessarily looking to make the code shorter or more >> functional or anything in particular. However if you spot something to >> improve then I am happy to learn. > > To give an example of what I mean I have already altered the code: > > def output_random_lesson_of_type(self, type=None): > """Output a lesson of a specific type. > If no type is passed in then output any type.""" > output_lessons = self.lesson_data["lessons"] if type: > filtered_lessons = filter(lambda x: x["type"] == type, > self.lesson_data["lessons"]) > if filtered_lessons: > output_lessons = filtered_lessons > else: > print "Unable to find lessons of type %s." % type > return self.output_random(output_lessons) > > Changes: > - Respected a column width of 80 > - Created the output_lessons variable, assigned it to a default. > This remove an else statement and reduced the call to > self.output_random to a single instance in the return statement > > Cheers, > James I would write it like this: def output_random_lesson_of_type(self, type=None): """\ Output a lesson of a specific type. If no type is passed in then output any type. """ if type: return self.output_random([x for x in self.lesson_data["lessons"] if x["type"] == type]) return self.output_random(self.lesson_data["lessons"]) -- Ivan From desktop_specialist at yahoo.com Fri Apr 11 12:20:06 2008 From: desktop_specialist at yahoo.com (shawn s) Date: Fri, 11 Apr 2008 09:20:06 -0700 (PDT) Subject: simple program Message-ID: <256065.832.qm@web58614.mail.re3.yahoo.com> Hi, Here is a simple prog that I can run from the Python shell and it runs fine but when I double click the 'filename.py' , it does not execute the ping statement, and seems like it is stuck at the following output: Fri Apr 11 12:16:09 2008 Testing 192.168.0.1 The prog is as follows: import os, curses import socket, time BAS ='192.168.0.1' os.system ('ping '+ BAS) print time.ctime() curses.delay_output(5000) Any ides as to why it is doing that? You may email me at desktop_specialist at yahoo.com __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From needin4mation at gmail.com Tue Apr 8 13:53:26 2008 From: needin4mation at gmail.com (jmDesktop) Date: Tue, 8 Apr 2008 10:53:26 -0700 (PDT) Subject: Is the Python for statement the same as for each in other languages? Message-ID: <9e8bfedb-dc75-4252-84e7-4fb96bbaa6ac@l64g2000hse.googlegroups.com> Thank you. It looks like it is, but I wanted to make sure I understood. Also, I didn't see a "regular" for loop construct either (i=0;i<=10;i++), etc. I'm still new at it, but is there one of those? From skanemupp at yahoo.se Thu Apr 10 10:37:08 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 07:37:08 -0700 (PDT) Subject: tkinter, overwrite Label-text? References: Message-ID: On 10 Apr, 16:29, "Dennis.Benzin... at gmx.net" wrote: > On Apr 10, 3:47 pm, skanem... at yahoo.se wrote: > > > [...] > > i use the Label-widget. > > Then you should be able to connect a variable to your widget like I > wrote in my previous post. > Just try out the example from the Python documentation. Of course in > your case entrythingy would be the > Label-widget. Take care to assign values to your variable by using the > set function. > > Dennis Benzinger i know how to do this already. the problem is i want the text to stay in the windowa nd not start overwriting "Answer:". i have solved this by using an Entry for the answer as well but id prefer using a Label. here is the code: from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") l = Label(mygui, text="Answer: ") l.place(relx=0.15, rely=0.2, anchor=CENTER) e = Entry(mygui) e.place(relx=0.4, rely=0.1, anchor=CENTER) def Disp(nstr): e.insert(END, nstr) def Calc(): expr=e.get() try: b = Label(mygui, text=eval(expr)) b.place(relx=0.4, rely=0.2, anchor=CENTER) except: b = Label(mygui, text="Not computable") b.place(relx=0.4, rely=0.2, anchor=CENTER) def Erase(): e.delete(0,END) x = 0.1 y = 0.4 for char in '123+456-789*0()/.': b = Button(mygui, text=char, command=lambda n=char:Disp(n), width=2, height=1) b.place(relx=x, rely=y, anchor=CENTER) x=x+0.1 if x==0.5: x=0.1 y=y+0.1 b = Button(mygui, text="^", command=lambda n="**":Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.8, anchor=CENTER) b = Button(mygui, text="C",command=Erase, width=2, height=1) b.place(relx=0.3, rely=0.8, anchor=CENTER) b = Button(mygui, text="=",command=Calc, width=2, height=1) b.place(relx=0.4, rely=0.8, anchor=CENTER) mygui.mainloop() From ankitks.mital at gmail.com Thu Apr 3 19:29:07 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Thu, 3 Apr 2008 16:29:07 -0700 (PDT) Subject: python bisect questions References: <6bb6927b-f553-40db-a142-2ce86b9e819f@q27g2000prf.googlegroups.com> <7d64aa50-9d67-45fe-9d57-ec32904ecb87@u36g2000prf.googlegroups.com> Message-ID: On Apr 3, 5:43?pm, John Machin wrote: > On Apr 4, 9:21 am, ankitks.mi... at gmail.com wrote: > > > > > > > On Apr 3, 4:24 pm, "Terry Reedy" wrote: > > > > wrote in message > > > >news:6bb6927b-f553-40db-a142-2ce86b9e819f at q27g2000prf.googlegroups.com... > > > |I am week on functional programming, and having hard time > > > | understanding this: > > > | > > > | class myPriorityQueue: > > > | ? ? ?def __init__(self, f=lamda x:x): > > > | ? ? ? ? ? ? ?self.A = [] > > > | ? ? ? ? ? ? ?self.f = f > > > | > > > | ? ? ?def append(self, item) > > > | ? ? ? ? ? ? ?bisect.insort(self.A, (self.f(item), item)) > > > | ? ?............ > > > | > > > | now I know we are inserting items(user defined type objects) in list A > > > | base on sorting order provided by function A. > > > | but what I don't understand is bisect command > > > | what does bisect.insort(self.A, (self.f(item), item)) doing > > > here is doc > > insort_right(a, x[, lo[, hi]]) > > > ? ? Insert item x in list a, and keep it sorted assuming a is sorted. > > > ? ? If x is already in a, insert it to the right of the rightmost x. > > > ? ? Optional args lo (default 0) and hi (default len(a)) bound the > > ? ? slice of a to be searched. > > > but I am still confuse. self.A is my list a. and item is x that > > I am trying to insert. > > So it needs to be of type item not (self.f(item), item) > > It doesn't say anything pass sorting function self.f(item). > > That's correct. You are passing a tuple of (sort_key, actual_data). > > Example use case: caseless sortorder but you want to retrieve the > original data. f is lambda x: x.upper() or similar. Your data is > 'foo', 'Bar', 'zOt'. Calls to your_queue.append will result in the > following 2nd args for bisect.insort: > ('FOO', 'foo') > ('BAR', 'Bar') > ('ZOT', 'zOt') Thanks John and Terry, Wow! great way to keep original values with transformation. Thanks for explaining. > > Consider executing the code with a couple of print statements in it so > that you can see what is happening.- Hide quoted text - > > - Show quoted text - From sjmachin at lexicon.net Mon Apr 21 19:29:45 2008 From: sjmachin at lexicon.net (John Machin) Date: Mon, 21 Apr 2008 23:29:45 GMT Subject: module error in Vista -- works as administrator In-Reply-To: <72da4abc-57b1-47ca-bed4-48b7244d6407@e39g2000hsf.googlegroups.com> References: <815eb7f8-6f00-469d-bb15-e1d9680d9646@e39g2000hsf.googlegroups.com> <480d0a52$1@news.mel.dft.com.au> <72da4abc-57b1-47ca-bed4-48b7244d6407@e39g2000hsf.googlegroups.com> Message-ID: <480d2369@news.mel.dft.com.au> sawilla wrote: > On Apr 21, 5:42 pm, John Machin wrote: >> Log on as administrator, start python in command window and do this: >> >> import sys >> sys.path # shows where python is looking for importables >> import numpy >> import os.path >> print os.path.abspath(numpy.__file__) # shows where it found numpy >> >> Log on as ordinary user, start python in command window and do this: >> >> import sys >> sys.path >> # check how this is different from the admin's sys.path >> >> If you can't see what to do after that, come back here with the output >> from those steps. >> >> HTH, >> John > > That was a great help, thank you. I now see what is causing the > problem but I don't know how to fix it. I used easy_install to install > several packages. When I run Python from an administrator command > window all of the directories in C:\Program Files\Python25\Lib\site- > packages\easy-install.pth are added to the sys.path. When I run it as > a regular user, those directories are not added to the sys.path and so > Python can't find the modules. > > I know how to manually add those directories to Python's search path > but then I'll need to update the path every time I install something. > How do I get Python to automatically load the easy-install.pth file > for the regular user account? > > Reg """ If you can't see what to do after that, come back here with the output from those steps. """ in particular what is in sys.path for the non-admin user. Also what are the access rights to the easy-install.pth file? From bignose+hates-spam at benfinney.id.au Wed Apr 30 22:25:01 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Thu, 01 May 2008 12:25:01 +1000 Subject: We have string.isdigit(), why not string.isNumber()? References: <0d43feda-fab8-46ba-9af0-eaf497033acd@l17g2000pri.googlegroups.com> Message-ID: <8763ty3gn6.fsf@benfinney.id.au> MooMaster writes: > I know how to write a regexp or method or whatever to do this, my main > question is *why* something like an isNumber() method is not baked > into the class. Because that name wouldn't conform to PEP 8. (Also, and more importantly, because it's more correct to use it as input to creating a new object of the type you want, and catch the exception if it fails.) -- \ "Courage is resistance to fear, mastery of fear ? not absence | `\ of fear." ?Mark Twain, _Pudd'n'head Wilson_ | _o__) | Ben Finney From tinnews at isbd.co.uk Sun Apr 6 11:40:17 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 06 Apr 2008 15:40:17 GMT Subject: A file iteration question/problem Message-ID: <47f8eee1$0$759$bed64819@news.gradwell.net> I want to iterate through the lines of a file in a recursive function so I can't use:- f = open(listfile, 'r') for ln in f: because when the function calls itself it won't see any more lines in the file. E.g. more fully I want to do somthing like:- def recfun(f) while True: str = readline(f) if (str == "") break; # # do various tests # if : recfun(f) Is there no more elegant way of doing this than that rather clumsy "while True" followed by a test? -- Chris Green From mail at timgolden.me.uk Thu Apr 3 09:22:29 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 03 Apr 2008 14:22:29 +0100 Subject: object-relational mappers In-Reply-To: <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> Message-ID: <47F4DA15.50209@timgolden.me.uk> Paul Boddie wrote: > ... I've come to realise that most object-relational mappers are > solving the wrong problems: they pretend that the database is somehow > the wrong representation whilst being a fast enough black box for > holding persistent data (although I doubt that many people push the > boundaries enough to see that it's not possible to ignore all details > of such a database whilst preserving performance), or they pretend > that languages like SQL (which can be cumbersome, admittedly) are > inconvenient for querying whilst replicating a less concise mechanism > for querying using client language mechanisms. Well at the risk of oversimplifying (!) I find there are two kinds of programmers using databases: those, like me, for whom the database is the application and who can happily envisage any number of interfaces, human and otherwise, to the data; and those, like 70% of the people I've ever interviewed for a job as a SQL developer, for whom the interface is the application and who simply throw things at whatever database they're presented with. The former will more likely tend to reach first for SQL to retrieve their data efficiently before passing it on to the front end for presentation or manipulation. The latter (and I've seen this far too often in interviews) will basically do "SELECT * FROM x WHERE y" to pull everything back into their VB.Net app where they feel more at home. Or, in the case of Python, reach for an ORM. I've recently used Elixir and found it very useful for a small-scale database with no more than a dozen tables, well-structured and easily understood. I'd certainly use it again for anything like that to save me writing what would amount to boilerplate SQL. But I'd hate to imagine it in the context of my day job: a messy, organic and sprawling SQL Server database with over 1,000 tables, let alone views, procedures and so on. TJG From steve at holdenweb.com Wed Apr 23 00:33:17 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 00:33:17 -0400 Subject: Python Success stories In-Reply-To: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: azrael wrote: > Hy guys, > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. > > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" > > This hurts. Please give me informations about realy famous > aplications. > -- > http://mail.python.org/mailman/listinfo/python-list > Ask him why, if Perl is so great, it isn't one of the Google-approved languages for internal use, when Python *is*. Ask him how it feels to program in a wrote-only language. Challenge him to a dual with dead kippers at twenty paces. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From zillow10 at googlemail.com Wed Apr 2 09:54:21 2008 From: zillow10 at googlemail.com (zillow10 at googlemail.com) Date: Wed, 2 Apr 2008 06:54:21 -0700 (PDT) Subject: developing web spider References: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> Message-ID: <30a89852-4730-490b-8701-b915cb0901ce@q27g2000prf.googlegroups.com> On Apr 2, 6:37 am, abeen wrote: > Hello, > > I would want to know which could be the best programming language for > developing web spider. > More information about the spider, much better,, > > thanks > > http://www.imavista.com Just saw this while passing by... There's a nice book by Michael Schrenk (www.schrenk.com) called "Webbots, Spiders and Screen Scrapers" that teaches scraping and spidering from the ground up using PHP. Since you said you want more info on spiders, this book might be a good way for you to acquire concept and implementation hand-in-hand. He's also developed a nice webbot library in PHP that you can get from his website. Also comes with a nice webbot library (which you can download from the website anyway). From fetchinson at googlemail.com Tue Apr 22 11:50:10 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Tue, 22 Apr 2008 08:50:10 -0700 Subject: Does Python 2.5 include or not include SQLite engine? In-Reply-To: <67648mF2mqc8pU2@mid.uni-berlin.de> References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> <67648mF2mqc8pU2@mid.uni-berlin.de> Message-ID: > > While reading feedback to my post "Does Python 2.5.2's embedded SQLite > > support full text searching?" I noticed that there appears to be some > > confusion regarding whether Python 2.5 includes the SQLite engine. > > > > My Windows 2.5.2 binary download includes SQLite. > > > > But other posters claim otherwise, re: Linux releases of Python 2.5? > > > > I thought one of the major features of Python 2.5 was its embedded > > SQLite engine. > > > > Thoughts? > > It is embedded. Period. Would you back that up, please? I mean with something else than "on my distro I see something vaguely resembling an sqlite shared object". The shared object lib-dynload/_sqlite3.so on most linux distros is *not* sqlite only the wrapper. This doesn't exclude the possibility of other python distros distributing sqlite itself, for example on windows this seems to be the case. > You can install the pysqlite wrapper > additionally, if you need a newer/differen sqlite version. It will be > available as a different module, though. From uniontelecardsindia at gmail.com Tue Apr 22 17:15:02 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:15:02 -0700 (PDT) Subject: Horny black homos ass licking and deep throat sucking Message-ID: <46a946c4-1f51-42bb-af14-206071056362@d45g2000hsc.googlegroups.com> Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From tjreedy at udel.edu Fri Apr 25 18:38:38 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 25 Apr 2008 18:38:38 -0400 Subject: Setting an attribute without calling __setattr__() References: Message-ID: "Joshua Kugler" wrote in message news:futgrq$ih6$1 at ger.gmane.org... | OK, I'm sure the answer is staring me right in the face--whether that answer | be "you can't do that" or "here's the really easy way--but I am stuck. I'm | writing an object to proxy both lists (subscriptable iterables, really) and | dicts. | | My init lookslike this: | | def __init__(self, obj=None): | if type(obj).__name__ in 'list|tuple|set|frozenset': | self.me = [] | for v in obj: | self.me.append(ObjectProxy(v)) | elif type(obj) == dict: | self.me = {} | for k,v in obj.items(): | self.me[k] = ObjectProxy(v) | | and I have a __setattr__ defined like so: | | def __setattr__(self, name, value): | self.me[name] = ObjectProxy(value) | | You can probably see the problem. | | While doing an init, self.me = {} or self.me = [] calls __setattr__, which | then ends up in an infinite loop, and even it it succeeded | | self.me['me'] = {} | | is not what I wanted in the first place. | | Is there a way to define self.me without it firing __setattr__? I believe self.__dict__['me'] = {} is one standard idiom. From xng at xs4all.nl Sat Apr 26 21:03:21 2008 From: xng at xs4all.nl (Martin P. Hellwig) Date: Sun, 27 Apr 2008 03:03:21 +0200 Subject: How do I say "Is this a function"? In-Reply-To: References: Message-ID: <4813d195$0$7093$e4fe514c@dreader25.news.xs4all.nl> John Henry wrote: > How do I determine is something a function? > > For instance, I don't want to relying on exceptions below: > > def f1(): > print "In f1" > > def f3(): > print "In f3" > > def others(): > print "In others" > > for i in xrange(1,3): > fct = "f%d()"%(i+1) > try: > exec fct > except: > others() > > I wish to say: > > if value of fct is a funtion, invoke it, otherwise invoke others(). > > Thanks, One way I would think of is: str(type(fct)) == "" -- mph From nick at stinemates.org Fri Apr 25 18:52:47 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 25 Apr 2008 15:52:47 -0700 Subject: multiple pattern regular expression In-Reply-To: <1209131456.20871.1249849011@webmail.messagingengine.com> References: <1209131456.20871.1249849011@webmail.messagingengine.com> Message-ID: <20080425225247.GC12662@deviL> On Fri, Apr 25, 2008 at 09:50:56AM -0400, python at bdurham.com wrote: > How about this? > > for line in file: > # ignore lines without = assignment > if '=' in line: > property, value = line.strip().split( '=', 1 ) > property = property.strip().lower() > value = value.strip() > > # do something with property, value > > Malcolm > -- > http://mail.python.org/mailman/listinfo/python-list This works until you have: string=The sum of 2+2=4 For cases where such input my be expected, I use the following regex import re str = """a=b c=d e=f string=The sum of 2+2=4""".split("\n") p = re.compile("([^=]*)=(.*)") for lines in str: key,value=p.findall(lines)[0] print key, value -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From samslists at gmail.com Sun Apr 6 03:20:41 2008 From: samslists at gmail.com (samslists at gmail.com) Date: Sun, 6 Apr 2008 00:20:41 -0700 (PDT) Subject: Implementation of Crockford's Base32 Encoding? Message-ID: <345117e9-2539-4ee0-8b27-9b1a88ddde7c@a1g2000hsb.googlegroups.com> Anyone know of a Python implementation of this: http://www.crockford.com/wrmg/base32.html Google shows a Perl library. I'm sure someone must have a Python library somewhere? :) Thanks [And yes...I know it won't be that hard to do... I will do it if it doesn't already exist, but I'd much rather spend my time on my core application.] From mfb.chikazuku at gmail.com Fri Apr 11 10:31:42 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Fri, 11 Apr 2008 16:31:42 +0200 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: <47ff8489$0$6841$2d805a3e@textnews.eweka.nl> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Gabriel Genellina wrote: > Another annoying thing with the Qt license is that you have to choose it > at the very start of the project. You cannot develop something using the > open source license and later decide to switch to the commercial licence > and buy it. > Unless you're a company with a risk of being checked for legal software etc., you can always ignore that allthough not very legal. MFB -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFH/3ZSDpaqHmOKFdQRAsupAKCN292aFK7V+AHXeQu/rzac7WAnnACgq+Al 2LzsfA5No1PTOgIc2wdYjf0= =7JyM -----END PGP SIGNATURE----- From zelegolas at gmail.com Wed Apr 16 23:51:32 2008 From: zelegolas at gmail.com (zelegolas) Date: Wed, 16 Apr 2008 20:51:32 -0700 (PDT) Subject: Python plugin for Firefox Message-ID: Hi, It's may be a stupid question but do you if someone tried to create a python plugin for firefox? If you know an Open Source project let me know... Thanks From haraldarminmassa at gmail.com Tue Apr 22 11:35:47 2008 From: haraldarminmassa at gmail.com (GHUM) Date: Tue, 22 Apr 2008 08:35:47 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> Message-ID: <944aa044-4a41-4ae9-9364-56e1bcc82488@p25g2000hsf.googlegroups.com> > Which big aplications are written in python. I see its development, There are no big applications written in Python. Big applications are written in JAVA or COBOL or C# or other legacy programming systems. If you programm in Python, your applications become quite small. Only frameworks in Python are big. best wishes Harald Join us @ EuroPython 2008 in Vilnius to have more fun with Python Submit your talk NOW www.europython.org From mwilson at the-wire.com Wed Apr 2 23:03:23 2008 From: mwilson at the-wire.com (Mel) Date: Wed, 02 Apr 2008 23:03:23 -0400 Subject: generator functions: why won't this work? References: <0aaeddf2-ee63-426e-afb3-0e1acb15adef@r9g2000prd.googlegroups.com> <8f38c3e6-1b1c-468e-8ea2-47c21322621f@i36g2000prf.googlegroups.com> Message-ID: zillow10 at googlemail.com wrote: > On Apr 2, 3:57 pm, Mel wrote: >> zillo... at googlemail.com wrote: >> >> I'd just like to test my >> >>> understanding of this. Suppose I create the following generator >>> object: >>> g = getNextScalar(1, 2, (3, 4), 5) >>> when the iterator reaches the tuple argument (3, 4) then, according to >>> Steve and George, the * in *arg causes this tuple to be expanded into >>> positional arguments, and it makes sense to do it this way. But what >>> happens when getNextScalar(arg) is used instead? >> Try it: >> >> Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) >> [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 >> Type "help", "copyright", "credits" or "license" for more information. >> >>> def a (arg): >> ... print arg >> ... >> >>> def astar (*arg): >> ... print arg >> ... >> >>> a(3,4) >> Traceback (most recent call last): >> File "", line 1, in >> TypeError: a() takes exactly 1 argument (2 given) >> >>> astar(3,4) >> (3, 4) >> >>> a((3,4)) >> (3, 4) >> >>> astar((3,4)) >> ((3, 4),) >> >>> >> >> Mel. > > Well, I understand that (unless I missed the point you're trying to > make). But with respect to the example I quoted: > > def getNextScalar(*args): > for arg in args: > if(isinstance(arg, tuple)): > for f in getNextScalar(arg): # should use *arg > yield f > else: > yield arg > where the function is declared as def getNextScalar(*arg), but is > called using getNextScalar(arg), with arg being a tuple: here the > generator is being passed a single argument, so there's no TypeError > as in your example. However, it fails - as I understand it - because > the function keeps passing the same tuple (being unable to access the > elements inside it) and goes into an infinite loop: >>>> # works for this example, but not very useful: >>>> g = getNextScalar(1, 2, 3, 4) >>>> for i in g: > print i > > > 1 > 2 > 3 > 4 > > # third argument is a tuple: >>>> g = getNextScalar(1, 2, (3, 4)) >>>> for i in g: > print i > > > 1 > 2 > > Traceback (most recent call last): > File "", line 1, in > for i in g: > File "", line 4, in getNextScalar > for f in getNextScalar(arg): > File "", line 4, in getNextScalar > for f in getNextScalar(arg): > File "", line 4, in getNextScalar > for f in getNextScalar(arg): > ... Yeah. I feel as though I haven't put the idea clearly. When a function is defined as `def astar (a*)`, then the parameters that it's called with, however many they are, are packed up into one tuple. Illustrated by those print statements. On the calling side, `a (*(3,4))` will unpack the (3,4) tuple and treat the contents as ordinary positional parameters of a. The call `a(*(3,4))` and the call `a(3,4)` are completely equivalent as far as the function a can see. This explanation is going nowhere fast. Anyway, if you define getNextScalar to pack its positional arguments into a tuple that you can iterate over, THEN if you want to feed it a tuple of values to iterate over you have to star-unpack the tuple when you call. The buggy behaviour is continually calling getNextScalar with a single positional parameter (3,4), packing that single parameter into a 1-tuple ((3,4),) , iterating over the 1-tuple to extract (3,4) and calling getNextScalar again -- ad dump. Mel. From tpatch at loftware.com Fri Apr 18 14:55:27 2008 From: tpatch at loftware.com (tpatch at loftware.com) Date: Fri, 18 Apr 2008 14:55:27 -0400 Subject: Python Logging question Message-ID: <4ECBD915C6F1254AB1AFF4B9F08287B2176F4255D4@loftexchange.loftwareinc.com> I am new to Python and I am trying to understand how to utilize the RotatingFileHandler to rollover when the file gets to a certain size. I followed some examples that I have found for setting the size and the number of files. However, I am finding that when the log file gets close to the threshold I start getting errors in the "handlers.py" file saying the file is closed. I am using Python 2.5 on Windows. Is this a problem others have seen? Is this a handler that is widely used or is there a better one that is generally used? The error that I am receiving is shown below. Traceback (most recent call last): File "C:\Python25\Lib\logging\handlers.py", line 73, in emit if self.shouldRollover(record): File "C:\Python25\Lib\logging\handlers.py", line 147, in shouldRollover self.stream.seek(0, 2) #due to non-posix-compliant Windows feature ValueError: I/O operation on closed file My configuration file is setup as such: [handler_file_detailed] class:handlers.RotatingFileHandler level:DEBUG formatter:detailed mode=a maxsize=4000000 backcount=5 args:('python.log','a',4000000,5) I would appreciate any feedback on this subject. Thanks, Todd -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin at v.loewis.de Sun Apr 6 16:22:16 2008 From: martin at v.loewis.de (=?ISO-8859-2?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 06 Apr 2008 22:22:16 +0200 Subject: Form sha1.hexdigest to sha1.digest In-Reply-To: References: <7c39af89-9cee-428c-a0bc-8202700c5aec@b1g2000hsg.googlegroups.com> <47F8CF66.1020805@v.loewis.de> Message-ID: <47F930F8.7030406@v.loewis.de> > Or hexdigest_string.decode('hex') I would advise against this, as it's incompatible with Python 3. Regards, Martin From steve at holdenweb.com Mon Apr 14 14:08:16 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 14 Apr 2008 14:08:16 -0400 Subject: py2exe, program has stoped working!? In-Reply-To: References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> <232151d6-09ed-4a1e-9922-d66c2bf0d05b@w8g2000prd.googlegroups.com> Message-ID: <48039D90.8040205@holdenweb.com> John Machin wrote: > On Apr 14, 7:24 pm, skanem... at yahoo.se wrote: >>> Is it a console program or a gui program? >> GUI >>> What happens when you run it without py2exe? >> it works perfectly, both from within python and launching from >> "windows" >> >>> Have you searched for "has stopped working" in >> (a) your source code >> yes no such message there> (b) the py2exe source code? >> >> no, will do but doubt thats the problem >> >>> Have you managed to get any py2exe-created program to run properly? >> no > > Well, perhaps you might like to look in the samples directory of the > py2exe distribution and choose a simple example and try that. > > By the way, "popup" is what you get in a web browser. What did this > "popup" look like: a panel from your GUI software? A Windows message > box? Did it have a title across the top? What was the exact text in > the popup/panel/box? Were there any options other than to close the > window? > > Which version of Python? Which Windows, what service pack? What GUI, > what version? Care to divulge the contents of your setup.py? Apart > from your GUI, what 3rd party packages/modules are you importing? FYI "xxx has stopped working" is Vista's "user-friendly" way of reporting what Windows 3 would probably have called a "General Program Fault". It pretty much hides all useful information fro the end-user, perhaps on the grounds that end users wouldn't know what to do with the information it *could* provide anyway. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From deets at nospam.web.de Fri Apr 18 12:27:07 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 18 Apr 2008 18:27:07 +0200 Subject: Installing BeautifulSoup with easy_install (broken?) In-Reply-To: References: <66rvkdF2kqa1lU1@mid.uni-berlin.de> Message-ID: <66s0fbF2m4pafU1@mid.uni-berlin.de> Larry Bates schrieb: > Diez B. Roggisch wrote: >> Larry Bates schrieb: >>> Info: >>> >>> Python version: ActivePython 2.5.1.1 >>> Platform: Windows >>> >>> I wanted to install BeautifulSoup today for a small project and >>> decided to use easy_install. I can install other packages just >>> fine. Unfortunately I get the following error from BeautifulSoup >>> installation attempt: >>> >>> C:\Python25\Lib\SITE-P~1>easy_install BeautifulSoup >>> Searching for BeautifulSoup >>> Reading http://pypi.python.org/simple/BeautifulSoup/ >>> Reading http://www.crummy.com/software/BeautifulSoup/ >>> Reading http://www.crummy.com/software/BeautifulSoup/download/ >>> Best match: BeautifulSoup 3.0.5 >>> Downloading >>> http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup- >>> 3.0.5.tar.gz >>> Processing BeautifulSoup-3.0.5.tar.gz >>> Running BeautifulSoup-3.0.5\setup.py -q bdist_egg --dist-dir >>> c:\docume~1\larry\l >>> ocals~1\temp\easy_install-cfdxna\BeautifulSoup-3.0.5\egg-dist-tmp-gbrpp5 >>> Traceback (most recent call last): >>> File "C:\Python25\Scripts\easy_install-script.py", line 8, in >>> load_entry_point('setuptools==0.6c8', 'console_scripts', >>> 'easy_install')() >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >>> >>> and\easy_install.py", line 1671, in main >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >>> >>> and\easy_install.py", line 1659, in with_ei_usage >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >>> >>> and\easy_install.py", line 1675, in >>> File "C:\Python25\lib\distutils\core.py", line 151, in setup >>> dist.run_commands() >>> File "C:\Python25\lib\distutils\dist.py", line 974, in run_commands >>> self.run_command(cmd) >>> File "C:\Python25\lib\distutils\dist.py", line 994, in run_command >>> cmd_obj.run() >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >>> >>> and\easy_install.py", line 211, in run >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >>> >>> and\easy_install.py", line 446, in easy_install >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >>> >>> and\easy_install.py", line 476, in install_item >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >>> >>> and\easy_install.py", line 655, in install_eggs >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >>> >>> and\easy_install.py", line 930, in build_and_install >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >>> >>> and\easy_install.py", line 919, in run_setup >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand >>> >>> box.py", line 27, in run_setup >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand >>> >>> box.py", line 63, in run >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand >>> >>> box.py", line 29, in >>> File "C:\VOL1\Larry\Websafe\Python\wstools\setup.py", line 2, in >>> >>> import py2exe >>> File "C:\VOL1\Larry\Websafe\Python\wstools\unittest.py", line 3, in >>> >>> class TextCtrlTest(unittest.TestCase): >>> AttributeError: 'module' object has no attribute 'TestCase' >>> >>> >>> Thanks in advance for any "clues". >> >> I'm not sure what happens - but I think it is suspicious that these >> "wstools" get into the way. And it looks as if wstools.unittest >> imports itself, instead of the python-unittest - which must be solved >> with getting the sys.path fixed. >> >> Diez > > Sharp eyes Diez, I overlooked that. This is a path that I search for some > tools I've written. It is set in PYTHONPATH environment variable. I > cleared > PYTHONPATH and easy_install BeautifulSoup worked. Still not quite clear > why. Mayb setuptools imports setup.py - but because of you having another one on the PYTHONPATH, it gets that instead of the one actually needed by setuptools? Only thing that helps is looking at sandbox.py, line 29. Diez From tjreedy at udel.edu Sun Apr 6 16:23:17 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 6 Apr 2008 16:23:17 -0400 Subject: traceback.print_exc() supposed to stop exception propagation. References: <69-dnW_JftMHvGTanZ2dneKdnZydnZ2d@bt.com> Message-ID: "Sami" wrote in message news:69-dnW_JftMHvGTanZ2dneKdnZydnZ2d at bt.com... | Hello, | | In the Python book that I am using to learn the language it says that | the traceback.print_exc() can be used to stop exception propagation and | make the program keep running. It is possible that the unspecified book describes an unspecified Python version that is not the same as the unspecified version that you tested with ;-). Help respondants by providing version info. Sometimes even the system/OS info is helpful, though probably not relevant here. tjr From lists at cheimes.de Sat Apr 19 11:41:51 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 19 Apr 2008 17:41:51 +0200 Subject: why function got dictionary In-Reply-To: <35f145d8-ee1c-406e-a036-7aa9ff62d971@c65g2000hsa.googlegroups.com> References: <48075950.7050000@gmail.com> <35f145d8-ee1c-406e-a036-7aa9ff62d971@c65g2000hsa.googlegroups.com> Message-ID: <480A12BF.4040800@cheimes.de> bruno.desthuilliers at gmail.com schrieb: > A: everything (or almost) in Python is an object. Including functions, > classes, modules etc. Everything you can access from or through Python code must be an object. Every object has at least a type and a reference count. Christian From andrei.avk at gmail.com Fri Apr 4 08:57:29 2008 From: andrei.avk at gmail.com (AK) Date: Fri, 04 Apr 2008 07:57:29 -0500 Subject: Python-by-example - new online guide to Python Standard Library In-Reply-To: References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: <47f617b0$0$16689$4c368faf@roadrunner.com> shurik wrote: > that's great! thanks for putting this together. what about the inspect > module? and particularly getsource :) > Glad you like it! I will add every module eventually, but I'll put inspect up on top of todo list. -- -ak Tobu | http://tobu.lightbird.net/ | Freeform DB / Tagger / PIM Python-by-Example | http://pbe.lightbird.net/ | Guide to LibRef From ivan.illarionov at gmail.com Tue Apr 15 08:01:16 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Tue, 15 Apr 2008 05:01:16 -0700 (PDT) Subject: Java or C++? References: Message-ID: <6660c92c-20d2-48bd-ae46-fee8dfb9f347@e39g2000hsf.googlegroups.com> On 15 ???, 07:46, Brian Vanderburg II wrote: [...] > C has the advantage that it does not to anything behind your back. This > is very useful especially for any form of system development or where > you must know exactly what is going on. It is still possible to do > 'object oriented' development in C, it just requires some more typing to > set up whatever is needed. Even things like COM for windows can be done > in C, it just requires manually building the 'vtable' so to speak. > Also, C seems to avoid the use of temporaries where as C++ can use them > in conversions and assignments automatically if needed. Great point. It's also possible to do Python object-oriented programming in C. 'PyMethodDefs' are the same 'vtables'. I've found that Python/C API is not that hard, the problem is a lack of good tutorials and false assumptions that ctypes or SWIG are somehow better. After `#include Python.h` C becomes very Python friendly. From duncan.booth at invalid.invalid Mon Apr 21 05:44:43 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 21 Apr 2008 09:44:43 GMT Subject: manipulating class attributes from a decorator while the class is being defined References: Message-ID: Wilbert Berendsen wrote: > Hi, is it possible to manipulate class attributes from within a > decorator while the class is being defined? > > I want to register methods with some additional values in a class > attribute. But I can't get a decorator to change a class attribute > while the class is still being defined. Something like: > > class Parser(object): > > regexps = [] > def reg(regexp): > def deco(func): > regexps.append((regexp, func)) > return func > return deco > > @reg(r'".*"') > def quoted_string(self): > pass > > How can I reach the class attribute `regexps' from within a decorator? > Have you tried passing regexps into the decorator as a default argument? def reg(regexp, regexps=regexps): def deco(func): regexps.append((regexp, func)) return func return deco From john106henry at hotmail.com Sun Apr 27 16:59:38 2008 From: john106henry at hotmail.com (John Henry) Date: Sun, 27 Apr 2008 13:59:38 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> Message-ID: <6db0df91-39f1-47a1-b4ca-c0351f0b67bc@y22g2000prd.googlegroups.com> On Apr 27, 12:23 pm, Fred Pacquier wrote: > John Henry said : > > > Welcome to the modernized world of Pythoncard!!! > > Hey, that's really neat ! > > I remember dabbling in Pythoncard in the early days, some years ago, it was > a very interesting project. I gave it up eventually, partly because it > seemed somewhat abandoned (I see it's still stuck in 2006 ?), but mostly > because the wxPython dependency was either unavailable or too hefty for the > sort of machines I was interested in using it on (a Sharp Zaurus then, now > Nokia Internet tablets). Since then I've been doing web apps instead, > hosted and used on the devices themselves. > > So using Pythoncard as a designer for web apps, of course that rings a > bell... > > Do you have any idea of the computing requirements of Qooxdoo and > QxTransformer, compared to a native Pythoncard app ? I wonder if your stuff > would run acceptably on today's mobile platforms (the Nokias have a Firefox > derivative that is reasonably competent at javascript), and would give it a > try if it's not too arcane. > > Do keep us posted ! > > TIA, > fp The performance of Qooxdoo is quite amazing - for a Javascript based web application. Don't know about cell-phones though. You can try their showcase web site I cited earlier. Yes, who would have throught we don't have to give up on Pythoncard? From andrei.avk at gmail.com Sat Apr 12 11:12:19 2008 From: andrei.avk at gmail.com (AK) Date: Sat, 12 Apr 2008 11:12:19 -0400 Subject: [ANN]: Python-by-Example updates In-Reply-To: References: <48000796$0$30160$4c368faf@roadrunner.com> Message-ID: <4800d15b$0$30214$4c368faf@roadrunner.com> Max Erickson wrote: > AK wrote: > >> Python-by-Example is a guide to LibRef, aiming to give examples >> for all functions, classes, modules, etc. Right now examples >> for functions in some of the most important modules are >> included. >> >> http://pbe.lightbird.net/ >> >> thanks, >> > > The second set of examples on the page for decimal doesn't look quite > right. > > The first couple of lines: > > getcontext().prec = 6 # Decimal('3.0') > Decimal("3.0") # Decimal('3.1415926535') > > I would assume that the " = 6" isn't getting processed correctly. > > > max > That block of examples was completely mis-formatted.. it should really be like this: getcontext().prec = 6 Decimal('3.0') # Decimal("3.0") [precision will be # applied after an operation, e.g. addition] Decimal('3.1415926535') # Decimal("3.1415926535") Decimal('3.1415926535') + Decimal('2.7182818285') # Decimal("5.85987") I fixed it now, thanks for the report! -- ak Tobu | http://tobu.lightbird.net/ | Freeform DB / Tagger / PIM Python-by-Example | http://pbe.lightbird.net/ | Guide to LibRef From medin0065 at gmail.com Sun Apr 20 10:48:48 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:48:48 -0700 (PDT) Subject: diner dash 3 crack Message-ID: diner dash 3 crack http://cracks.00bp.com F R E E C R A C K S From castironpi at gmail.com Mon Apr 21 19:50:21 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Mon, 21 Apr 2008 16:50:21 -0700 (PDT) Subject: sys.maxint in Python 3 References: <7xod82df4e.fsf@ruckus.brouhaha.com> Message-ID: <4de6f692-9a62-4287-b0b2-07311555e1c4@8g2000hse.googlegroups.com> On Apr 21, 5:20?pm, Paul Rubin wrote: > bearophileH... at lycos.com writes: > > In some algorithms a sentinel value may be useful, so for Python 3.x > > Better to just use object() to generate sentinels. Infinity is a number that compares always like. From castironpi at gmail.com Sun Apr 27 01:37:14 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sat, 26 Apr 2008 22:37:14 -0700 (PDT) Subject: Why can't timedeltas be divided? References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> Message-ID: <1baaf1da-f7a9-4691-9e98-5b1b1314630b@f36g2000hsa.googlegroups.com> On Apr 26, 10:27?pm, Jon Ribbens wrote: > On 2008-04-27, Martin v. L?wis wrote: > > >> sorry for bringing up such an old thread, but this seems important to me > >> -- up to now, there are thousands [1] of python programs that use > >> hardcoded time calculations. > > > Would you like to work on a patch? > > Last time I brought up this sort of thing, it seemed fairly unanimous > that the shortcomings of the datetime module were 'deliberate' and > would not be fixed, patch or no patch. I wanted to format strings with them. How does modulo a datetime sound? From martin at v.loewis.de Sat Apr 12 10:25:59 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sat, 12 Apr 2008 16:25:59 +0200 Subject: str(bytes) in Python 3.0 In-Reply-To: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> Message-ID: <4800C677.5060703@v.loewis.de> > And making an utf-8 encoding default is not possible without writing a > new function? There is no default encoding anymore in Python 3. This is by design, learning from the problems in Python 2.x. Regards, Martin From exarkun at divmod.com Fri Apr 11 13:23:13 2008 From: exarkun at divmod.com (Jean-Paul Calderone) Date: Fri, 11 Apr 2008 13:23:13 -0400 Subject: pyOpenSSL 0.7 In-Reply-To: 0 Message-ID: pyOpenSSL is a wrapper around a subset of the OpenSSL API, including support for X509 certificates, public and private keys, and and SSL connections. pyOpenSSL 0.7 fixes a number of memory leaks and memory corruption issues. It also exposes several new OpenSSL APIs to Python: * SSL_get_shutdown and SSL_set_shutdown exposed as OpenSSL.SSL.Connection.get_shutdown and OpenSSL.SSL.Connection.set_shutdown * SSL_SENT_SHUTDOWN and SSL_RECEIVED_SHUTDOWN exposed as OpenSSL.SSL.SENT_SHUTDOWN and OpenSSL.SSL.RECEIVED_SHUTDOWN * X509_verify_cert_error_string exposed as OpenSSL.crypto.X509_verify_cert_error_string * X509.get_serial_number and X509.set_serial_number now accept long integers * Expose notBefore and notAfter on X509 certificates for inspection and mutation * Expose low-level X509Name state with X509Name.get_components * Expose hashing and DER access on X509Names pyOpenSSL home page: http://pyopenssl.sourceforge.net/ pyOpenSSL downloads: http://sourceforge.net/project/showfiles.php?group_id=31249 Jean-Paul Calderone From nagle at animats.com Mon Apr 7 23:10:01 2008 From: nagle at animats.com (John Nagle) Date: Mon, 07 Apr 2008 20:10:01 -0700 Subject: read large zip file In-Reply-To: References: Message-ID: <47fadf75$0$36387$742ec2ed@news.sonic.net> Gabriel Genellina wrote: > En Sun, 06 Apr 2008 19:20:31 -0300, Brian Blais > escribi?: > >> I need to read a series of large zipfiles (which only contain one >> large text file), and I noticed that the zipfile module: >> >> 1) has a read method which isn't an iterator, and returns the entire >> file selected all at once >> 2) has no readlines method, and no obvious way to implement one >> >> Is there a way to stream an unzip, so it behaves more like a file? > > Use the module from the 2.6 version; it appears to work fine even on > Python 2.4 (see this thread > http://groups.google.com/group/comp.lang.python/browse_thread/thread/71c4890cefac82aa/ > ) It's easier than that: fd = gzip.open(filename, 'rb') for line in fd : processline(line) This works even in Python 2.4. I use this routinely for processing big log files. John Nagle From bignose+hates-spam at benfinney.id.au Tue Apr 15 21:35:36 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Wed, 16 Apr 2008 11:35:36 +1000 Subject: How to have unittest tests to be executed in the order they appear? References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> <87zlru7le2.fsf@benfinney.id.au> Message-ID: <87r6d6ponr.fsf@benfinney.id.au> Ben Finney writes: > Find out about test fixtures in the documentation for unittest > . Find out easier with the right URL context . -- \ "I like my dental hygenist, I think she's very pretty; so when | `\ I go to have my teeth cleaned, while I'm in the waiting room I | _o__) eat an entire box of cookies." -- Steven Wright | Ben Finney From bignose+hates-spam at benfinney.id.au Tue Apr 22 23:01:49 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Wed, 23 Apr 2008 13:01:49 +1000 Subject: Explicit variable declaration References: Message-ID: <87k5ipz336.fsf@benfinney.id.au> "Filip Gruszczy?ski" writes: > I have become very interested in dynamically typed languages, > especially Python. Good to know. Welcome to the group. > I would like to ask, whether there is any way of explicitly > declaring variables used in a function? Declaring what about them? If you mean declaring the type, remember that Python deliberately allows any name to be bound to any object; type declarations can't be enforced without losing a lot of the power of Python. -- \ "Hanging one scoundrel, it appears, does not deter the next. | `\ Well, what of it? The first one is at least disposed of." -- | _o__) Henry L. Mencken | Ben Finney From dblubaugh at belcan.com Tue Apr 22 18:20:09 2008 From: dblubaugh at belcan.com (Blubaugh, David A.) Date: Tue, 22 Apr 2008 18:20:09 -0400 Subject: MESSAGE RESPONSE In-Reply-To: <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> Message-ID: <27CC3060AF71DA40A5DC85F7D5B70F38033A4F2D@AWMAIL04.belcan.com> Is there a way to block these messages. I do not want to be caught with filth such as this material. I could lose my job with Belcan with evil messages such as these messages. David Blubaugh -----Original Message----- From: uniontelecardsindia at gmail.com [mailto:uniontelecardsindia at gmail.com] Sent: Tuesday, April 22, 2008 5:14 PM To: python-list at python.org Subject: Lucky gay sucking cock while butt fucked deep Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . This e-mail transmission contains information that is confidential and may be privileged. It is intended only for the addressee(s) named above. If you receive this e-mail in error, please do not read, copy or disseminate it in any manner. If you are not the intended recipient, any disclosure, copying, distribution or use of the contents of this information is prohibited. Please reply to the message immediately by informing the sender that the message was misdirected. After replying, please erase it from your computer system. Your assistance in correcting this error is appreciated. From jcd at sdf.lonestar.org Fri Apr 18 07:36:00 2008 From: jcd at sdf.lonestar.org (J. Clifford Dyer) Date: Fri, 18 Apr 2008 07:36:00 -0400 Subject: Unicode chr(150) en dash In-Reply-To: <1208518057.6200.6.camel@jcd-desktop> References: <48063434$0$36327$742ec2ed@news.sonic.net> <7dae96d4-48c4-46c9-9aa9-33a263b84ca4@26g2000hsk.googlegroups.com> <20080418102856.fdf5ddf3.marexposed@googlemail.com> <1208518057.6200.6.camel@jcd-desktop> Message-ID: <1208518560.6200.13.camel@jcd-desktop> On Fri, 2008-04-18 at 07:27 -0400, J. Clifford Dyer wrote: > On Fri, 2008-04-18 at 10:28 +0100, marexposed at googlemail.com wrote: > > On Thu, 17 Apr 2008 20:57:21 -0700 (PDT) > > hdante wrote: > > > > > Don't use old 8-bit encodings. Use UTF-8. > > > > Yes, I'll try. But is a problem when I only want to read, not that I'm trying to write or create the content. > > To blame I suppose is Microsoft's commercial success. They won't adhere to standars if that doesn't make sense for their business. > > > > I'll change the approach trying to filter the contents with htmllib and mapping on my own those troubling characters. > > Anyway this has been a very instructive dive into unicode for me, I've got things cleared up now. > > > > Thanks to everyone for the great help. > > > > There are a number of code points (150 being one of them) that are used > in cp1252, which are reserved for control characters in ISO-8859-1. > Those characters will pretty much never be used in ISO-8859-1 documents. > If you're expecting documents of both types coming in, test for the > presence of those characters, and assume cp1252 for those documents. > > Something like: > > for c in control_chars: > if c in encoded_text: > unicode_text = encoded_text.decode('cp1252') > break > else: > unicode_text = encoded_text.decode('latin-1') > > Note that the else matches the for, not the if. > > You can figure out the characters to match on by looking at the > wikipedia pages for the encodings. One warning: This works if you know all your documents are in one of those two encodings, but you could break other encodings, like UTF-8 this way. Fortunately UTF-8 is a pretty fragile encoding, so it's easy to break. You can usually test if a document is decent UTF-8 just by wrapping it in a try except block: try: unicode_text = encoded.text.decode('utf-8') except UnicodeEncodeError: # I think that's the proper exception # do the stuff above None of these are perfect methods, but then again, if text encoding detection were a perfect science, python could just handle it on its own. If in doubt, prompt the user for confirmation. Maybe others can share better "best practices." Cheers, Cliff From arunragini at gmail.com Thu Apr 10 13:08:29 2008 From: arunragini at gmail.com (Arun ragini) Date: Thu, 10 Apr 2008 22:38:29 +0530 Subject: class Message-ID: <264666470804101008l3d6740c2ve76a81d1815f2d0d@mail.gmail.com> Hi, I have create a class file named Mysqldb.py class Mysqldb: def __init__(self, name): #this where it tries to connect to database self.ip = ip print "Inializing session for name" def test(self): print "worked" ----------------------------------------------------- now i'm trying initialize this another python file called session.py import Mysqldb def session(): Sess = Mysqldb ("localbox") when i try to run in using python session.py. i get error message TypeError: 'module' object is not callable can any 1 help me on this. Thanks & Regards Arun -- ----- Fight back spam! Download the Blue Frog. http://www.bluesecurity.com/register/s?user=YXJ1bnJhZ2luaQ%3D%3D -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at craig-wood.com Mon Apr 28 06:30:04 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Mon, 28 Apr 2008 05:30:04 -0500 Subject: Regular Expression - Matching Multiples of 3 Characters exactly. References: Message-ID: blaine wrote: > I'm trying to write a string matching algorithm for genomic > sequences. I'm pulling out Genes from a large genomic pattern, with > certain start and stop codons on either side. This is simple > enough... for example: > > start = AUG stop=AGG > BBBBBBAUGWWWWWWAGGBBBBBB > > So I obviously want to pull out AUGWWWWWWAGG (and all other matches). > This works great with my current regular expression. > > The problem, however, is that codons come in sets of 3 bases. So > there are actually three different 'frames' I could be using. For > example: > ABCDEFGHIJ > I could have ABC DEF GHI or BCD EFG HIJ or CDE FGH IJx.... etc. > > So finally, my question. How can I represent this in a regular > expression? :) This is what I'd like to do: > (Find all groups of any three characters) (Find a start codon) (find > any other codons) (Find an end codon) > > Is this possible? It seems that I'd want to do something like this: (\w > \w\w)+(AUG)(\s)(AGG)(\s)* - where \w\w\w matches EXACTLY all sets of > three non-whitespace characters, followed by AUG \s AGG, and then > anything else. I'm not sure what the \s are doing in there - there doesn't appear to be any whitespace in your examples. > I hope I am making sense. Obviously, however, this will make sure > that ANY set of three characters exist before a start codon. Is > there a way to match exactly, to say something like 'Find all sets > of three, then AUG and AGG, etc.'. I think you want ^(\w\w\w)*(AUG)((\w\w\w)*?)(AGG) which will match up 0 or more triples, match AUG match 0 or more triples then AGG. The ? makes it a minimum match otherwise you'll match more than you expect if there are two AUG...AGG sequences in a given genome. >>> import re >>> m=re.compile(r"^(\w\w\w)*(AUG)((\w\w\w)*?)(AGG)") >>> m.search("BBBBBBAUGWWWWWWAGGBBBBBB").groups() ('BBB', 'AUG', 'WWWWWW', 'WWW', 'AGG') >>> m.search("BBBQBBBAUGWWWWWWAGGBBBBBB") >>> m.search("BBBQQBBBAUGWWWWWWAGGBBBBBB") >>> m.search("BBBQQBBQBAUGWWWWWWAGGBBBBBB") <_sre.SRE_Match object at 0xb7de33e0> >>> m.search("BBBQQBBQBAUGWWWWWWAGGBBBBBB").groups() ('BQB', 'AUG', 'WWWWWW', 'WWW', 'AGG') >>> m.search("BBBQQBBQBAUGWQWWWWWAGGBBBBBB") >>> m.search("BBBQQBBQBAUGWWWWQWWAGGBBBBBB") >>> m.search("BBBQQBBQBAUGWWQWWQWWAGGBBBBBB") >>> m.search("BBBQQBBQBAUGWWQWAWQWWAGGBBBBBB") <_sre.SRE_Match object at 0xb7de33e0> >>> m.search("BBBQQBBQBAUGWWQWAWQWWAGGBBBBBB").groups() ('BQB', 'AUG', 'WWQWAWQWW', 'QWW', 'AGG') >>> > This way, I could scan for genes, remove the first letter, scan for > more genes, remove the first letter again, and scan for more genes. > This would hypothetically yield different genes, since the frame > would be shifted. Of you could just unconstrain the first match and it will do them all at once :- (AUG)((\w\w\w)*?)(AGG) You could run this with re.findall, but beware that this will only return non-overlapping matches which may not be what you want. I'm not sure re's are the best tool for the job, but they should give you a quick idea of what the answers might be. -- Nick Craig-Wood -- http://www.craig-wood.com/nick From s0suk3 at gmail.com Fri Apr 25 18:53:53 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Fri, 25 Apr 2008 15:53:53 -0700 (PDT) Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> Message-ID: On Apr 25, 5:52?pm, Erik Max Francis wrote: > s0s... at gmail.com wrote: > > I wanted to ask for standard ways to receive data from a socket stream > > (with socket.socket.recv()). It's simple when you know the amount of > > data that you're going to receive, or when you'll receive data until > > the remote peer closes the connection. But I'm not sure which is the > > best way to receive a message with undetermined length from a stream > > in a connection that you expect to remain open. Until now, I've been > > doing this little trick: > > > data = client.recv(256) > > new = data > > while len(new) == 256: > > ? ? new = client.recv(256) > > ? ? data += new > > > That works well in most cases. But it's obviously error-prone. What if > > the client sent *exactly* two hundred and fifty six bytes? It would > > keep waiting for data inside the loop. Is there really a better and > > standard way, or is this as best as it gets? > > > Sorry if this is a little off-topic and more related to networking, > > but I'm using Python anyway. > > You solve this by having a protocol that the client and server both > agree on, so that the client knows how much to read from the server. > There are any number of ways of doing this, all of which depend on the > kind of data you want to transfer and for what purpose. > > -- > Erik Max Francis && m... at alcyone.com &&http://www.alcyone.com/max/ > ? San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis > ? ?In the final choice a solider's pack is not so heavy a burden as a > ? ? prisoner's chains. -- Dwight D. Eisenhower, 1890-1969 So, in an HTTP client/server, I'd had to look in a Content-Length header? From terry.yinzhe at gmail.com Tue Apr 29 10:44:16 2008 From: terry.yinzhe at gmail.com (Terry) Date: Tue, 29 Apr 2008 07:44:16 -0700 (PDT) Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> <16c06038-2421-478e-ba28-8131f7d552d8@b1g2000hsg.googlegroups.com> Message-ID: On Apr 29, 4:32 pm, bock... at virgilio.it wrote: > On 27 Apr, 12:27, Terry wrote: > > > > > Hello! > > > I'm trying to implement a message queue among threads using Queue. The > > message queue has two operations: > > PutMsg(id, msg) # this is simple, just combine the id and msg as one > > and put it into the Queue. > > WaitMsg(ids, msg) # this is the hard part > > > WaitMsg will get only msg with certain ids, but this is not possible > > in Queue object, because Queue provides no method to peek into the > > message queue and fetch only matched item. > > > Now I'm using an ugly solution, fetch all the messages and put the not > > used ones back to the queue. But I want a better performance. Is there > > any alternative out there? > > > This is my current solution: > > > def _get_with_ids(self,wait, timeout, ids): > > to = timeout > > msg = None > > saved = [] > > while True: > > start = time.clock() > > msg =self.q.get(wait, to) > > if msg and msg['id'] in ids: > > break; > > # not the expecting message, save it. > > saved.append(msg) > > to = to - (time.clock()-start) > > if to <= 0: > > break > > # put the saved messages back to the queue > > for m in saved: > > self.q.put(m, True) > > return msg > > > br, Terry > > Wy put them back in the queue? > You could have a defaultdict with the id as key and a list of > unprocessed messages with that id as items. > Your _get_by_ids function could first look into the unprocessed > messages for items with that ids and then > look into the queue, putting any unprocessed item in the dictionary, > for later processing. > This should improve the performances, with a little complication of > the method code (but way simpler > that implementing your own priority-based queue). > > Ciao > ----- > FB Yes, this will improve the performance. And I can see there's a problem in my current implementation. The order of the message might be changed if I put the saved message back to the end of the queue. This may cause some confusion later, though I don't want to depend too much on the message orders. And you remind me one thing -- I need to implement 'priority' for messages, so that the message with highest priority will tend to be fetched first. OMG, this is going to be much more complicated then I have expected. Thanks for your suggestion. And I hope this will also work when I move to stackless. From bj_666 at gmx.net Mon Apr 14 04:03:40 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 14 Apr 2008 08:03:40 GMT Subject: Java or C++? References: <41b4eea8-8e53-413b-b860-789fc062638c@u69g2000hse.googlegroups.com> Message-ID: <66ghesF2ju94lU4@mid.uni-berlin.de> On Mon, 14 Apr 2008 00:49:13 -0700, xakee wrote: > Well if you need an easier transition, go for java. But personally i > would recommend you to go for C/C++. What's that C/C++!? C and C++ are quite different languages. Ciao, Marc 'BlackJack' Rintsch From rowen at cesmail.net Tue Apr 29 15:54:04 2008 From: rowen at cesmail.net (Russell E. Owen) Date: Tue, 29 Apr 2008 12:54:04 -0700 Subject: Simple unicode-safe version of str(exception)? References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> <67on2nF2ol856U1@mid.individual.net> <87zlrcmxuk.fsf@physik.rwth-aachen.de> Message-ID: In article <87zlrcmxuk.fsf at physik.rwth-aachen.de>, Torsten Bronger wrote: > Hall?chen! > > Russell E. Owen writes: > > > [...] > > > > So...to repeat the original question, is there any simpler > > unicode-safe replacement for str(exception)? > > Please show us the tracebacks you get becuae unicode(s) must fail, > too, if there are non-ASCII characters involved. Why? What I am trying to do is get a unicode representation of the arguments of an exception. str(e), the obvious solution, fails if the exception contains one argument that is a unicode string that cannot be decoded to ASCII: UnicodeEncodeError: 'ascii' codec can't encode character...ordinal not in range(128) What I do with the resulting unicode string afterwards is a different issue. (As a matter of fact I display it on a widget that can display unicode, but if I tried to print it to my Mac Terminal it would complain about the non-ASCII characters--something I should look into fixing someday). But in any case, here are the exceptions you wanted to see. This is using Python 2.5.2 on a Mac: >>> d =u"\N{DEGREE SIGN}" >>> d u'\xb0' >>> str(d) Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'ascii' codec can't encode character u'\xb0' in position 0: ordinal not in range(128) >>> e = Exception(d) >>> str(e) Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'ascii' codec can't encode character u'\xb0' in position 0: ordinal not in range(128) >>> e Exception(u'\xb0',) >>> ",".join([unicode(s) for s in e.args]) u'\xb0' >>> Based on the dearth of better replacements I've gone with the solution that is shown as the last line above, coded as the following function (incorporating Donn Cave's excellent suggestion to use repr as a fallback). It has the minor issue that it can mask KeyboardInterrupt on older versions of Python but it's close enough. A lot of work to replace str(exc). def strFromException(exc): """Unicode-safe replacement for str(exception)""" try: return str(exc) except Exception: try: return ",".join([unicode(s) for s in exc.args]) except Exception: # in case exc is some unexpected type return repr(exc) -- Russell From steve at holdenweb.com Sun Apr 20 10:27:42 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 20 Apr 2008 10:27:42 -0400 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <480B3B2D.6040206@gmail.com> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> Message-ID: <480B52DE.8070105@holdenweb.com> Hank @ITGroup wrote: > Apology for the previous offensive title~~ > :) > Thanks, Rintsch, Arnaud and Daniel, for replying so soon. > > I redid the experiment. What following is the record - > > ``starting python`` # == Windows Task Manager: > Python.exe *4,076 *K memory-usage == > >>> st1='abcdefg'*999999 # == 10,952 K == > >>> del st1 # == *4,104*K == > >>> st1='abcdefg'*999999 # == 10,952 K == > >>> del st1 # == 4,104 K == > > >>> li = ['abcde']*999999 # == 8,024 K == > >>> del li # == *4,108* K == > > >>> from nltk import FreqDist # == 17,596 == > >>> fd = FreqDist() # == 17,596 == > >>> for i in range(999999):fd.inc(i) # == 53,412 == > >>> del fd # == *28,780* == > >>> fd2 = FreqDist() # == 28,780 == > >>> for i in range(999999):fd2.inc(i) # == 53,412 == > >>> del fd2 # == 28,780 K == > > >>> def foo(): > ... fd3 = FreqDist() > ... for i in range(999999):fd3.inc(i) > > >>> foo() # == *28,788* K == > > >>> def bar(): > ... fd4 = FreqDist() > ... for i in range(999999):fd4.inc(i) > ... del fd4 > # == 28,788 K == > >>> bar() # == 28,788 K == > > > That is my question, after ``del``, sometimes the memory space returns > back as nothing happened, sometimes not... ... > What exactly was happening??? > > Best regards to all PYTHON people ~~ > !!! Python Team are great !!! > It doesn't really make that much sense to watch memory usage as you have been doing. Your first test case appears to trigger a specific pathology, where the memory allocator actually returns the memory to the operating system when the garbage collector manages to free all of it. Most often this doesn't happen - a chunk of memory might be 99.99% free but still have one small piece used, and so while there is a large amount of "free" memory for Python to allocate without requesting more process memory, this won't be reflected in any external measurement. You are suffering from a pathological condition yourself: the desire to optimize performance in an area where you do not have any problems. I would suggest you just enjoy using Python (its memory management doesn't suck at all, so your title line was inflammatory and simply highlights your lack of knowledge) and then start to ask these questions again when you have a real issue that's stopping you from getting real work done. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gagsl-py2 at yahoo.com.ar Sun Apr 6 18:30:23 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 06 Apr 2008 19:30:23 -0300 Subject: read large zip file References: Message-ID: En Sun, 06 Apr 2008 19:20:31 -0300, Brian Blais escribi?: > I need to read a series of large zipfiles (which only contain one > large text file), and I noticed that the zipfile module: > > 1) has a read method which isn't an iterator, and returns the entire > file selected all at once > 2) has no readlines method, and no obvious way to implement one > > Is there a way to stream an unzip, so it behaves more like a file? Use the module from the 2.6 version; it appears to work fine even on Python 2.4 (see this thread http://groups.google.com/group/comp.lang.python/browse_thread/thread/71c4890cefac82aa/ ) -- Gabriel Genellina From ni at hao.com Sat Apr 26 14:22:34 2008 From: ni at hao.com (SL) Date: Sat, 26 Apr 2008 20:22:34 +0200 Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) In-Reply-To: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> Message-ID: "n00m" schreef in bericht news:6a3f8226-04c6-4ee3-b5a6-f76aca44aa31 at a23g2000hsc.googlegroups.com... > import time > t=time.time() > f=open('D:\\some.txt','r') > z=f.readlines() > f.close() > print len(z) > print time.time()-t > m=input() > print z[m] > > > #include > #include > #include > #include > > using namespace std; > char vs[1002000][99]; > FILE *fp=fopen("D:\\some.txt","r"); > > int main() { > int i=0; > while (true) { > if (!fgets(vs[i],999,fp)) break; > ++i; > } first of all I would rewrite the C loop to: int main() { int i=0; while (fgets(vs[i],999,fp)) ++i; } but I think that the difference comes from what you do in the beginning of the C source: char vs[1002000][99]; this reserves 99,198,000 bytes so expect a lot of cache trashing in the C code! Is there an implementation of f.readlines on the internet somewhere? interested to see in how they implemented it. I'm pretty sure they did it smarter than just reserve 100meg of data :) > fclose(fp); > cout << i << endl; > cout << clock()/CLOCKS_PER_SEC << endl; > > int m; > cin >> m; > cout << vs[m]; > system("pause"); > return 0; > } From asmodai at in-nomine.org Thu Apr 24 09:27:49 2008 From: asmodai at in-nomine.org (Jeroen Ruigrok van der Werven) Date: Thu, 24 Apr 2008 15:27:49 +0200 Subject: restructured text in python In-Reply-To: <807d9398-0099-4eee-b0a2-5cb0fbff2124@s33g2000pri.googlegroups.com> References: <807d9398-0099-4eee-b0a2-5cb0fbff2124@s33g2000pri.googlegroups.com> Message-ID: <20080424132749.GA8632@nexus.in-nomine.org> -On [20080424 13:16], bdsatish (bdsatish at gmail.com) wrote: >#!/usr/bin/env #!/usr/bin/env what? I guess you meant #!/usr/bin/env python >""" >Author: BDS >Version: 1.0 >""" > >def Hello(): > """ Prints a Hello World to the screen""" > print "Hello, World" > >I want to use ReSt (reStructuredText) in my docstrings or comments. >Any example of how to do it, w.r.t. above code ? Also how to invoke >rst on the Python code to do the processing ? Just run epydoc (easy_install epydoc) on your code, for example, and observe the resulting output. Once you see the output it's quite easy, since you already know reSt, how to change your docstrings to use appropriate formatting for what you need. -- Jeroen Ruigrok van der Werven / asmodai ????? ?????? ??? ?? ?????? http://www.in-nomine.org/ | http://www.rangaku.org/ | GPG: 2EAC625B Give me the strength to be who I was, and forgive me for who I am... From rhamph at gmail.com Thu Apr 17 13:24:55 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Thu, 17 Apr 2008 10:24:55 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> <69cbd3d3-449f-4e64-96d5-f512cf317032@m3g2000hsc.googlegroups.com> <2a32d56a-5075-4c48-99fc-686a3f53fc26@m36g2000hse.googlegroups.com> Message-ID: <3e04397a-5e7b-4b19-a4f7-bb6f6795d6bb@e39g2000hsf.googlegroups.com> On Apr 17, 11:05 am, sturlamolden wrote: > On Apr 17, 6:03 pm, Rhamphoryncus wrote: > > > Interesting. Windows specific, but there's other ways to do the same > > thing more portably. > > I believe you can compile Python as a shared object (.so) on Linux as > well, and thus loadable by ctypes. Python is compiled as a .so, but I don't believe that makes everything private to that .so. Other means may be necessary. Not that important though. > > This > > effectively gives you a multiprocess model - a bit cheaper than that, > > but not enough to really supply GIL-free threading. > > That solution is safe. But I am looking into sharing objects. I don't > think its impossible. > > PyObject* pointers can be passed around. GILs can be acquired and > released, refcounts increased and decreased, etc. but we have to sort > out some synchronization details for the shared objects. For one > thing, we have to make sure that a garbage collector does not try to > reclaim a PyObject* belonging to another interpreter. But here we are > talking about minor changes to CPython's source, or perhaps none at > all. But can you automatically manage the reference count? ie, does your interpreter have a proxy to the other interpreter's object, or does the object itself gain a field indicating who owns it? Either way you'll need to keep the number of shared objects to a minimum, as the use of locking creates a bottleneck - only one thread can run at a time for a given object. From __peter__ at web.de Tue Apr 1 08:18:37 2008 From: __peter__ at web.de (Peter Otten) Date: Tue, 01 Apr 2008 14:18:37 +0200 Subject: Passing function objects to timeit References: <13us6o4og79iid0@corp.supernews.com> <13uu1o25912ulb0@corp.supernews.com> <13uusct7elou5e3@corp.supernews.com> Message-ID: George Sakkis wrote: > I'm afraid that the taken approach is worse than your patch. For one > thing, it allows only zero-arg functions. Of course one can work > around it by passing "lambda: f(...)" but that's adding extra overhead > which can be measurable for small fast functions. Even if passing > *args and **kwds to a Timer is allowed, that's still going to be > slower (because of tuple unpacking and whatnot) as Steven's attempt > above showed. > > I think it's at least worth bringing this to the attention of the > developers. I decided to give it a try: http://bugs.python.org/issue2527 Peter From NIE_DZIALA at gazeta.pl Thu Apr 3 02:48:41 2008 From: NIE_DZIALA at gazeta.pl (Piotr Sobolewski) Date: Thu, 03 Apr 2008 08:48:41 +0200 Subject: variable scope in list comprehensions Message-ID: Hello, there is something I don't understand about list comprehensions. I understand how does this work: print [[y for x in range(8)] for y in range(8)] However I don't understand why this one works: print [[y for y in range(8)] for y in range(8)] In this second example I have one loop nested in another. Both loops uses the same variable - y. How is it that those loops do not conflict with each other? For a moment I thought that maybe list comprehension has its own scope, but it doesn't seem to be so: print [[y for y in range(8)] for y in range(8)] print y Does anybody understand it? From mal at egenix.com Thu Apr 17 17:08:01 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Thu, 17 Apr 2008 23:08:01 +0200 Subject: Tidy module? In-Reply-To: References: Message-ID: <4807BC31.3090105@egenix.com> On 2008-04-17 21:00, Mark Reed wrote: > Is there an easy_installable egg with an interface to libtidy? I > found ?Tidy, but it looks like an inactive project, with no updates > since 2004, so I'm skeptical of its reliability. I found mxTidy, but > it's only available as part of some larger distribution, and I don't > want to replace my Python installation. Replace your Python installation ?? You only have to install two package: egenix-mx-base egenix-mx-experimental using the standard "python setup.py install" dance (if you want to compile from source) or get the prebuilt packages and do "python setup.py build --skip install". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 17 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From m.moghimi at gmail.com Sat Apr 19 05:55:35 2008 From: m.moghimi at gmail.com (m.moghimi) Date: Sat, 19 Apr 2008 02:55:35 -0700 (PDT) Subject: Python Workshop References: <6fd50e0b-9637-422a-b1db-b76734630f54@w8g2000prd.googlegroups.com> Message-ID: On Apr 14, 9:53 pm, "m.moghimi" wrote: > On Apr 14, 5:15 pm, "Twayne" wrote: > > > > > > Hi, > > > > We are to hold a workshop about python (introduction). It will be two > > > one hour and half sessions. > > > I wanted to know which subjects do you suggest to be presented and is > > > there a good presentation file (powerpoint or ...) about this on the > > > net. > > > We thought that it may be good that first session covers the > > > introduction, zen of python, python coding syntax and the second > > > session will be about application, libraries or so. > > > I really appreciate if you tell me your ideas? > > > Depends; what's the experiene level of the audience? "Introductory" is > > a pretty vague concept; introductory to what audience? > > > -- > > -- > > Regards, > > > Twayne > > > Open Office isn't just for wimps anymore; > > OOo is a GREAT MS Office replacementwww.openoffice.org > > The audiences are computer engineering students who know programming > in c++ and some of them know java. any ideas? From victorsubervi at gmail.com Fri Apr 11 09:36:02 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Fri, 11 Apr 2008 08:36:02 -0500 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> <47FCF421.6000807@holdenweb.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> Message-ID: <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> Nope. Do not see it. My ugly stupid way works. I guess I will just proceed with that and write my howto accordingly. Victor On Thu, Apr 10, 2008 at 9:01 PM, Gabriel Genellina wrote: > En Thu, 10 Apr 2008 14:04:43 -0300, Victor Subervi > escribi?: > > > Well, what I did was this: > > > > content = col_fields[0][14].tostring() > > pic = "tmp" + str(i) + ".jpg" > > img = open(pic, "w") > > img.write(content) > > print '

' % pic > > img.close() > > where I am incrementing i. Ugly. Stupid. But if it is the only way to do > > it > > in python, and I do not want to invest the time doing it in php, which I > > think would be prettier in this instance, then I guess it will do. Your > > thoughts appreciated. > > You REALLY should read some material on how HTTP works. I'll try to sketch > a few important points. First, suppose you have an HTML page (album.html) > with two images in it: > > >

This is me: > and this is my cat > > > Suppose the URL for that page is http://some.server.com/gabriel/album.html > and you type that in your favorite browser. This is what happens: > 1) The sees the initial "http:" and says "I'll use HTTP". Then sees > "some.server.com" and opens a connection to that server on port 80. Then > sees "/gabriel.album.html" and builds an HTTP GET request for it. > 2) The server receives the GET request, looks for the "album.html" > document, determines the right Content-Type, and returns it specifying > "Content-Type: text/html" > 3) The browser receives the HTML text and tries to display it. When it > encounters the first tag it looks at the src attribute; it doesn't > know that image; so a *NEW* HTTP request is required. This time it says > "GET /images/myself.jpg" > 4) The server receives the GET request, looks for a file with that name, > determines that it's a jpeg image, and returns its contents along with a > "Content-Type: image/jpeg". > 5) The browser receives the image and is able to display it. > 6) The same thing happens with the second tag, there is a third HTTP > GET request for it. > > Note that: > - The images themselves *aren't* in the HTML page, they are somewhere > else. HTML is text and contains ONLY the URI for the image. > - THREE DIFFERENT requests are done to show that page. Each one returns A > SINGLE OBJECT of A SINGLE TYPE. > > The above was using static HTML with static images. If you use CGI to > generate dynamic content, it's the same thing. From the browser point of > view, there is no difference: it still will generate three different > requests for the three pieces (one html document with two images). > Your CGI script (or scripts) will receive three different requests then: > when requested for HTML, return HTML; when requested for an image, return > an image. They are DIFFERENT things, DIFFERENT requests, happening at > DIFFERENT times, so don't mix them. > > I think that combining Steve's responses and mine you now have enough > information to be able to solve your problems. Perhaps if you re-read the > whole thread from start you'll have now a better understanding of what's > happening. > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at cheimes.de Tue Apr 29 09:16:33 2008 From: lists at cheimes.de (Christian Heimes) Date: Tue, 29 Apr 2008 15:16:33 +0200 Subject: Zope/DTML Infuriating... In-Reply-To: References: Message-ID: Jens schrieb: > Hello Everyone. > > I am relatively new to Zope(using it for a work project) and I was > wondering if someone here could help me out or at least refer me to a > decent documentationg for Zope/DTML/Python (at the detail level of > php.net or Java API reference). http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/ > isn't really detailed enough for my taste. if it doesn't contain a > exhautive description of all available base classes it's simply no > good as a reference resource. Are you forced to use DTML for the job? ZPT are far superior and easier to work with, if you have to output HTML. Christian From breily at gmail.com Sat Apr 12 22:15:47 2008 From: breily at gmail.com (Brian) Date: Sat, 12 Apr 2008 22:15:47 -0400 Subject: Advice on tools/technologies/books, etc. In-Reply-To: References: Message-ID: I would definitely recommend Django as a framework - though the choice of framework wouldn't really affect your use of AJAX. And using AJAX actually doesn't require learning a whole lot of javascript stuff - using something like the Prototype JS library (prototypejs.org) takes care of all the details. As for making async apps, AJAX is the popular and simplest choice. Gears/Adobe Air/MS Silverlight I believe involve significantly more work. Brian On Sat, Apr 12, 2008 at 9:48 PM, Matt wrote: > I would like to create a web-based tool for risk management. The tool > actually currently exists, but it was programmed in about 1998 using > old VB, etc, and we are updating it & moving it to the web. Basically, > as a first step, i'd like to create a basic web site that takes user > input, gets data from MySQL (i might pickle it, not yet sure) and then > runs some numpy routines & outputs the results. This will give us a > platform to develop the backend. My intermediate goal is to have an > asynchronous site in which as users adjust settings, the computations > are run & graphs updated. (the computations are pretty simple, btw). > My fantasy goal would be to combine that w/ google gears so the users > could use it online or offline, but that's probably just fantasy. > > So, here are my constraints: I know Python & HTML (and lots of other > non-germane languages) but I don't know any javascript or ruby or XML. > What is the lowest cost path from here to there? I have been totally > out of the loop for this whole web 2.0 thing (I'm an economics > professor). Will it be possible for me to put together an async site > with only python? (I hesitate to use the term AJAX, b/c its unclear to > me how generic it is--do all async sites use javascript? can someone > clarify this?) If so, does it make sense to go ahead and start trying > to learn Turbogears or Pylons? Will they be able to create async > sites? Is there an easier way to do it? (Easy defined as me not having > to learn a 7th programming language) I have looked at Spyce, and that > seems an easy way to do the basic (step 1) site, but its not at all > clear that I can do async with it. CherryPy looks like it has a > steeper learning curve, but it also appears that the route to async is > clearer. > > I know where I want to go, and I know what I can do now. I don't mind > getting deeper into Python, but I'd love not to have to learn a bunch > of other languages if I can avoid it. Any thoughts/comments? > > TIA, > Matt. > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.sakkis at gmail.com Fri Apr 4 16:29:14 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 4 Apr 2008 13:29:14 -0700 (PDT) Subject: Tokenizer inconsistency wrt to new lines in comments References: <1ce40dcf-4a0a-4577-af3b-6a77ef71356c@f63g2000hsf.googlegroups.com> <6dd69a1f-96d0-4b91-b84b-a54794a31c70@u36g2000prf.googlegroups.com> Message-ID: <8b3fa4cc-deb9-4748-a63c-a6c7e5dd92ba@59g2000hsb.googlegroups.com> On Apr 4, 3:18 pm, Kay Schluehr wrote: > I guess it's just an artifact of handling line continuations within > expressions where a different rule is applied. For compilation > purposes both the newlines within expressions as well as the comments > are irrelevant. There are even two different token namely NEWLINE and > NL which are produced for newlines. NL and COMMENT will be ignored. > NEWLINE is relevant for the parser. > > If it was a bug it has to violate a functional requirement. I can't > see which one. Perhaps it's not a functional requirement but it came up as a real problem on a source colorizer I use. I count on newlines generating token.NEWLINE or tokenize.NL tokens in order to produce
tags. It took me some time and head scratching to find out why some comments were joined together with the following line. Now I have to check whether a comment ends in new line and if it does output an extra
tag.. it works but it's a kludge. George From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 23 08:22:30 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 23 Apr 2008 14:22:30 +0200 Subject: problem with dictionaries In-Reply-To: References: Message-ID: <480f29f8$0$11374$426a74cc@news.free.fr> kdwyer a ?crit : > On Apr 23, 12:16 pm, Simon Strobl wrote: (snip) >> #!/usr/bin/python >> >> import sys >> >> frqlist = open('my_frqlist.txt', 'r') (snip) >> frq = {} >> >> for line in frqlist: >> line = line.rstrip() >> frequency, word = line.split('|') >> frq[word] = int(frequency) >> (snip) > It works for me, save that you need to read the file into a list first You don't, unless you're using an old python versions (I'd say 2.3 or older). Files are now their own iterators. From gagsl-py2 at yahoo.com.ar Fri Apr 11 00:15:28 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 11 Apr 2008 01:15:28 -0300 Subject: Convert PyIDispatch object to struct IDispatch* References: <90eee1e1-b1cc-48a9-8c09-173e92861f2c@a5g2000prg.googlegroups.com> Message-ID: En Thu, 10 Apr 2008 18:45:04 -0300, Huayang Xia escribi?: > I am trying to use ctypes to call dll functions. One of the functions > requires argument "struct IDispatch* ". I do have a PyIDispatch object > in python. How can I convert this "PyIDispatch object" to "struct > IDispatch* "? I think a PyIDispatch object is an IDispatch* itself. But you'll get better answers from the python-win32 list: http://mail.python.org/mailman/listinfo/python-win32 -- Gabriel Genellina From lists at cheimes.de Tue Apr 29 17:48:12 2008 From: lists at cheimes.de (Christian Heimes) Date: Tue, 29 Apr 2008 23:48:12 +0200 Subject: Sending Cntrl-C ?? In-Reply-To: <0274834e-17e1-4a95-88ec-f2aa77aeb3a9@k10g2000prm.googlegroups.com> References: <0274834e-17e1-4a95-88ec-f2aa77aeb3a9@k10g2000prm.googlegroups.com> Message-ID: <4817979C.7010601@cheimes.de> gamename schrieb: > Hi, > > I really like this recipe for controlling subprocesses: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554 > > However, I can't figure out how I can send the equivalent of "Cntrl-C" > to the subprocess. How can that be done? import os import signal import subprocess popen = subprocess(...) os.kill(popen.pid, signal.SIGINT) Or with Python 2.6+: popen.send_signal(signal.SIGINT) Christian From duncan.booth at invalid.invalid Wed Apr 30 07:56:03 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 30 Apr 2008 11:56:03 GMT Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> <87tzhjy4u2.fsf@physik.rwth-aachen.de> Message-ID: Torsten Bronger wrote: > However, join() is really bizarre. The list rather than the > separator should be the leading actor. Do you mean the list, or do you mean the list/the tuple/the dict/the generator/the file and anything else which just happens to be an iterable sequence of strings? join is a factory method for creating a string from a separator string and a sequence of strings, any sequence of strings. It doesn't make sense to either limit it to specific sequence types, or to require it as part of the iterator protocol. Having it as a function would make sense, but if it is going to be a method then it should be a method on the string types not on the sequence types. From kay.schluehr at gmx.net Sat Apr 5 03:31:12 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 5 Apr 2008 00:31:12 -0700 (PDT) Subject: RELEASED Python 2.6a2 and 3.0a4 References: <47F68547.1040802@v.loewis.de> Message-ID: On 4 Apr., 21:45, "Martin v. L?wis" wrote: > > The Windows x86 MSI installer is missing for both 2.6 and 3.0. > > And likely will continue to do so for some time. > > Regards, > Martin Fine. Is there also a reason? From rkmr.em at gmail.com Mon Apr 21 17:46:20 2008 From: rkmr.em at gmail.com (rkmr.em at gmail.com) Date: Mon, 21 Apr 2008 14:46:20 -0700 Subject: dynamically importing a module and function Message-ID: Hi I have a function data['function'], that I need to import from a file data['module'], in the directory data['cwd'] If I do this from python interactive shell (linux fedora core 8) from dir /home/mark it works fine: cwd = data['cwd'] os.chdir(cwd) print os.getcwd() module = __import__(data['module']) function = getattr(module, data['function']) But if I put this in a file /home/mark/work/common/funcq.py and run it from /home/mark, it throws me error like this.. how to fix this? it imports the module successfully, but it is not looking for subsequent modules in the os.getcwd().. /home/mark/work/proj1 Traceback (most recent call last): File "/home/mark/work/common/funcq.py", line 60, in if __name__ == '__main__':do() File "/home/mark/work/common/funcq.py", line 33, in do module = __import__(data['module']) File "/home/mark/app.py", line 5, in import abcde ImportError: No module named abcde From jkrukoff at ltgc.com Tue Apr 15 17:16:07 2008 From: jkrukoff at ltgc.com (John Krukoff) Date: Tue, 15 Apr 2008 15:16:07 -0600 Subject: Recurring patterns: Am I missing it, or can we get these added to the language? In-Reply-To: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: <1208294167.5926.12.camel@localhost.localdomain> On Tue, 2008-04-15 at 11:51 -0700, Erich wrote: > Hello all, > > Today I found myself once again defining two functions that I use all > the time: nsplit and iterable. These little helper functions of mine > get used all the time when I work. Im sick of having to define them > (but am very good at it these days, less than 1 typo per function!). > It leads me to the following questions > > 1. Is this functionality already built in and im just missing it > 2. Is there some well known, good technique for these that I missed? > 3. Insert question I need to ask here (with a response) > > These are the funtions w/ explaination: > > def nsplit(s,p,n): > n -= 1 > l = s.split(p, n) > if len(l) < n: > l.extend([''] * (n - len(l))) > return l > > This is like split() but returns a list of exactly lenght n. This is > very useful when using unpacking, e.g.: > x, y = nsplit('foo,bar,baz', ',', 2) > > def iterable(item, count_str=False): > if not count_str and isinstance(item, str): > return False > try: > iter(item) > except: > return False > return True > This is just simple boolean test for whether or not an object is > iterable. I would like to see this in builtins, to mirror callable. > The optional count_str adds flexibility for string handling, since > sometimes I need to iterate over a string, but usually not. I > frequently use it to simplify my case handling in this type of > costruct: > > def foo(bar): > bar = bar if iterable(bar) else [bar] > for x in bar: > .... > > Thanks for feeback, > Erich As far as I know there is no built in function that does exactly what you want. You can certainly simplify your nsplit function a bit, but as mentioned, it's probably best just to create your own package and keep your utility functions there. It's worth noting that you almost certainly want to be doing isinstance( item, basestring ) in your iterable function instead of isinstance( item, str ), or things will get very surprising for you as soon as you have to deal with a unicode string. If you don't want the hassle of creating a separate package, and you're only interested in having these functions be handy on your local python install, you could also add them into your sitecustomize file as described here: http://docs.python.org/lib/module-site.html On linux, that's as easy as creating a file named /usr/lib/python2.5/sitecustomize.py that inserts whatever you want into the __builtin__ module, and it'll be automatically imported whenever you run python. I'd doubt there's a case for getting this functionality added to the language, as your use case seems pretty specific, and it's just not that hard to write the function that does what you want to do. -- John Krukoff Land Title Guarantee Company From gagsl-py2 at yahoo.com.ar Sat Apr 12 23:58:58 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 13 Apr 2008 00:58:58 -0300 Subject: C to python conversion References: Message-ID: En Sat, 12 Apr 2008 07:58:47 -0300, Michele Petrazzo escribi?: > Hi all, > I'm trying to translate a simple C code into a python + ctypes (where > need), but I have some problems on char conversion. The code have > to work on Linux and talk with the serial port. I think that the problem > is that I don't translate correctly the strings. > > C code: > #define START 0x33 > #define RETURN_START 0x22 > #define ADDR 0x01 > #define WRITE_CMD 0x03 > #define ALL_CMD 0xFF > ... > char buf[10]; > char buf_ret[10]; > > buf[0]=0; > buf[0]=START; > buf[1]=ADDR; > buf[2]=WRITE_CMD; > > write(_fd, buf, 6); > read(_fd,buf_ret,6); You don't even need ctypes. In C, `char` is a small integer: 'A' and the number 65 are interchangeable. In Python, there are no chars but strings of length 1, which are not the same thing as their ordinal integer. The easiest way is to define those constants as strings instead: START = chr(0x33) RETURN_START = chr(0x22) ADDR = chr(0x01) WRITE_CMD = chr(0x03) ALL_CMD = chr(0xFF) NUL = chr(0) buf = START + ADDR + WRITE_CMD + NUL + NUL + NUL # I assume the buffer was initialized to NULs, because only 3 bytes # are filled but 6 bytes are written. os.write(_fd, buf) buf_ret = os.read(_fd, 6) -- Gabriel Genellina From phil at riverbankcomputing.com Thu Apr 3 09:29:19 2008 From: phil at riverbankcomputing.com (Phil Thompson) Date: Thu, 3 Apr 2008 14:29:19 +0100 Subject: State of ctypes Support on HP-UX? In-Reply-To: References: <200804031153.26234.phil@riverbankcomputing.com> Message-ID: <200804031429.19025.phil@riverbankcomputing.com> On Thursday 03 April 2008, Thomas Heller wrote: > Phil Thompson schrieb: > > Could somebody confirm how well ctypes is supported on HP-UX (for both > > PA-RISC and Itanium) for both Python v2.4 and v2.5? > > > > I don't have access to an HP system and Google doesn't come up with a > > definitive answer (which may just mean it works fine, but prior > > experience with HP means I'd like more specific assurances). > > > > Thanks, > > Phil > > I cannot answer your question, but if you want to try it out > yourself there is the HP testdrive program: http://www.testdrive.hp.com/ > > Thomas Thanks for the pointer. Unfortunately the answer is that there is no support (at least for ctypes v1.0.2). Phil From ivan.illarionov at gmail.com Thu Apr 10 14:08:30 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Thu, 10 Apr 2008 11:08:30 -0700 (PDT) Subject: get array element References: <820d8589-8529-46af-907a-90ebaac4a6f5@a22g2000hsc.googlegroups.com> Message-ID: <76b6689f-ae00-4a6d-bcab-20069aadf370@q27g2000prf.googlegroups.com> On Apr 10, 9:22 pm, "Bryan.Fodn... at gmail.com" wrote: > I have an array, and I would like to get the indice value. > > a = array([13,14,15,16]) > > I would like something like a.getindice(15) > > If I want 15 it would return 2 >>> a = array('i', [13,14,15,16]) >>> a.index(15) 2 From schettino72 at gmail.com Wed Apr 23 15:37:22 2008 From: schettino72 at gmail.com (Eduardo Schettino) Date: Thu, 24 Apr 2008 01:07:22 +0530 Subject: Python "make" like tools (was Re: [ANN] DoIt 0.1.0 Released (build tool)) In-Reply-To: <9jIPj.124$RM4.68@read4.inet.fi> References: <9jIPj.124$RM4.68@read4.inet.fi> Message-ID: On Wed, Apr 23, 2008 at 8:39 PM, Ville M. Vainio wrote: > > Yeah, decorators get around this. > > > Perhaps you could do: > > for f in pyFiles: > @task("checker") > @depend(f) > def check(): > c("pychecker %s" % f) > > Never underestimate the magic that is nested scopes and name-agnostic > function object creation... > ok. it is possible to do everything with decorators... i agree. but i dont want "name-agnostic function object creation". i want to be able to execute every single task without executing all other tasks. thats why when defining sub-tasks it is required an extra parameter "name". I know you could add another decorator for this also :) I mean decorators could do the job i dont say they cant. *I* prefer to work with dictionaries though. Even if they are a bit more verbose. > > > > I though about using decorator for simple python-tasks but in a different > way: > > > > @task > > > > def create_folder(path): > > """Create folder given by "path" if it doesnt exist""" > > if not os.path.exists(path): > > os.mkdir(path) > > return True > > > > > > so if your python function is a task and you will use it only once you > > dont need to define a function for the 'action' and another function > > to create the task. but not implement yet also. > > > > Yeah, this is what I consider much friendlier syntax (the aim is to not be > much more verbose than make). > > Maybe it is just a bad example. I tried to put all features on single example. but in *real* life I could do like this. import os jsPath = "./" jsFiles = ["file1.js", "file2.js"] sourceFiles = [jsPath + f for f in jsFiles] compressedFiles = [jsPath + "build/" + f + ".compressed" for f in jsFiles] def task_shrink_js(): # create output folder if not os.path.exists(path): os.mkdir(path) for jsFile,compFile in zip(sourceFiles,compressedFiles): action = 'java -jar custom_rhino.jar -c %s > %s'% (jsFile, compFile) yield {'action':action, 'name':jsFile, 'dependencies':(jsFile,), 'targets':(compFile,) } Can I challenge you to do this with any other build tool? i guess anything more complicated than this you want to create a python function separate from the task definition anyway. My examples are from scratch. I dont use a "standard library". I could also document the short-cuts :P. I was afraid that including the short-cuts would make it more complicated for who is trying to learn it. if you dont define any dependencies or args to the function you dont need to return a dictionary. just the action: def task_simple_shell(): return "echo spam" def task_simple_python(): def say_spam(): print "spam" return True return say_spam # or from our discussion def task_create_build_folder(): def create_folder(): path = jsPath + "build" if not os.path.exists(path): os.mkdir(path) return True return create_folder > > > apart from one .py file installation (easy_install is not enough?) > > thats what i am trying to do. > > > > easy_install is not really enough - it introduces a dependency that you > can't get around by just shipping a short .py file with your project. > what about shipping a single egg file with the whole package? ( I am not very much familiar with this subject) > 'Paver' seems to have the right idea: > > http://www.blueskyonmars.com/projects/paver/index.html > Thanks for the link. I took a quick look on its documentation. It seems that "paver" doesnt keep track of file-dependencies at all. So it is more like a setuptools extension commands than a "full-feature" build system with "smart" re-build and dependency support. "doit" target is not on creating releases for python projects only. it can do it also, but it can do much more. You can read about my motivation to start another build tool project on http://schettino72.wordpress.com/2008/04/14/doit-a-build-tool-tale/ > But it's still *slightly* too big: > man, it is hard to make you happy :) the doit egg file containg the whole packge is 27782 bytes on my system. but you also need the command line script 154 bytes. cheers, Eduardo From Lie.1296 at gmail.com Sun Apr 20 07:33:38 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 20 Apr 2008 04:33:38 -0700 (PDT) Subject: from __future__ import print References: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> Message-ID: On Apr 13, 7:23 pm, Roy Smith wrote: > In article > , > > Lie wrote: > > I wish py3k > > would make it an option whether to treat print as statement or > > function though. > > Arrrgghhhhh! No, don't even go there. If you want optional parens, use > Perl :-) Not optional parens, but a simple print statement coupled with a powerful print function. This print statement would only have basic printing functionality such as : print "Hello" print var print var, "Hello too" specifically, these would be removed: print var, print >> unstdout, var This is because it is sometimes annoying to type this: print("Hello") print("World") print("This") print("is") print("Captain") print("Kirk") because of the double enclosement (parens () and quotes ""), especially when you're just slipping a simple debugging statement. This also eases transition between older codes, because while you uses regular print statements everyday, you don't do print redirection and comma-ended printing everyday, and it would be easier to just convert those advanced printing functionality rather than converting all printing statements. From hotani at gmail.com Tue Apr 22 13:40:42 2008 From: hotani at gmail.com (hotani) Date: Tue, 22 Apr 2008 10:40:42 -0700 (PDT) Subject: python-ldap: searching without specifying an OU? Message-ID: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> I am attempting to pull info from an LDAP server (Active Directory), but cannot specify an OU. In other words, I need to search users in all OU's, not a specific one. Here is what works: con = ldap.initialize("ldap://server.local") con.simple_bind_s('user at domain', pass) result = con.search_ext_s( 'OU=some office, DC=server, DC=local', ldap.SCOPE_SUBTREE, "sAMAccountName=username", ['mail'] )[0][1] for i in result: print "%s = %s" (i, result[i]) But i really need it to not require an OU. When I remove that part, it breaks. Or it just won't find the user. Is there a proper syntax for this that I'm missing? Maybe a different search function? From egbert.bouwman at hccnet.nl Tue Apr 15 12:55:27 2008 From: egbert.bouwman at hccnet.nl (egbert) Date: Tue, 15 Apr 2008 18:55:27 +0200 Subject: Java or C++? In-Reply-To: References: Message-ID: <20080415165526.GA21682@hccnet.nl> What is the role or position of C# in this context ? If I remember well, some people have said that C# is an improved C++ or Java. e -- Egbert Bouwman - Keizersgracht 197 II - 1016 DS Amsterdam - 020 6257991 ======================================================================== From mage at mage.hu Wed Apr 9 07:25:01 2008 From: mage at mage.hu (Mage) Date: Wed, 09 Apr 2008 13:25:01 +0200 Subject: is Pylons alive? Message-ID: <47FCA78D.3040203@mage.hu> Hello, I don't want to be impolite, just in short: I am thinking about leaving RoR and coming back to Python. I've missed the last two years in Python, however I have been subscribed to this list and there are not too many e-mails about Pylons in my mailbox. On my Gentoo the latest Pylons ebuild has date "jul 2007" or something like last summer. It has testing keywords both for x86 and amd64. (No stable version available). It's available on my debian "testing" desktop. Before spending much time for investigating, I would like to ask you: is Pylons the framework I look for if I want to come back to Python and develop MVC web apps? Mage From nick at stinemates.org Fri Apr 18 14:42:07 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 11:42:07 -0700 Subject: Brand New! In-Reply-To: References: <7f1828bf-ebe7-4111-bc59-70d125facb0a@d26g2000prg.googlegroups.com> Message-ID: <20080418184207.GE19281@deviL> On Wed, Apr 16, 2008 at 02:35:54AM -0300, Gabriel Genellina wrote: > En Tue, 15 Apr 2008 20:37:40 -0300, agent E 10 > escribi?: > > On Apr 14, 8:37?pm, Benjamin wrote: > >> On Apr 14, 9:00 pm, agent E 10 wrote:> ? ?Hi, > >> I'm brand new to programming. Have any suggestions? I'm young. > >> > Was it a good idea to start with python? I was planning on creating a > >> > very simple program that asked yes/no questions for a school project. > >> > >> IMHO, Python is an excellent language to start with. Have you read the > >> tutorial?http://docs.python.org/tut/tut.html > > > > No, I haven't. I have been reading off of this site > > http://www.freenetpages.co.uk/hp/alan.gauld/ is this a good site to > > learn off of? About how long will it take me to learn the basics of > > the language? > > I'm unsure if teaching Javascript, VBScript and Python at the same time is > a good thing, I'd think one would get a language soup and mix all the > concepts, but if it works for you, go ahead. > For other resources, see the beginners section in the Python wiki: > http://wiki.python.org/moin/BeginnersGuide I agree and disagree! As long as the student understands how the different parts play together, and the Web medium is what gets him interested in python, I don't see any harm! That's a pretty big assumption though! -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From kkuhl05 at gmail.com Tue Apr 29 11:45:31 2008 From: kkuhl05 at gmail.com (Kevin K) Date: Tue, 29 Apr 2008 08:45:31 -0700 (PDT) Subject: File IO Issues, help :( References: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> <1fd8deae-1ed4-493c-a508-06c528c4ee1f@r66g2000hsg.googlegroups.com> Message-ID: <3d9a8971-3480-4743-8b07-575547947bee@i76g2000hsf.googlegroups.com> On Apr 29, 1:07 am, Kevin K wrote: > On Apr 29, 12:55 am, Peter Otten <__pete... at web.de> wrote: > > > > > Kevin K wrote: > > > On Apr 29, 12:38 am, "Eric Wertman" wrote: > > >> chuck in a jsfile.close(). The buffer isn't flushing with what you > > >> are doing now. jsfile.flush() might work... not sure. Closing and > > >> re-opening the file for sure will help though. > > > > Yeah sorry I forgot to include the close() in the quote but its there. > > > In fact I moved it up a bit and still no luck heres the new code: > > > > jsfile = open("../timeline.js", "r+") > > > jscontent = jsfile.readlines() > > > jsfile.truncate() > > > > for line in jscontent: > > > if re.search('var d =', line): > > > line = "var d = \""+mint['1'].ascdate()+"\"\n" > > > print line > > > jsfile.write(line) > > > jsfile.close() > > > > I tried this can got the same result...?? > > > """ > > truncate(...) > > truncate([size]) -> None. Truncate the file to at most size bytes. > > > Size defaults to the current file position, as returned by tell(). > > """ > > > After the readlines() call the current file position is at the end of the > > file. Try jsfile.truncate(0). > > > Also note that readlines() reads the whole file into memory. For large files > > it would therefore be better to write to a new file and rename it > > afterwards. > > > Peter > > Thanks Peter that seemed to be most of the problem, however I now have > a bunch of null characters in the file. Could it be an unwanted line > in the list that im writing? > > Thanks, > Kevin Awesome that seems to work fine! Thanks a lot for your help guys! From sturlamolden at yahoo.no Wed Apr 2 19:04:14 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Wed, 2 Apr 2008 16:04:14 -0700 (PDT) Subject: Summary of threading for experienced non-Python programmers? References: <87od8yolay.fsf@mulj.homelinux.net> <654ng1F2cvh8aU1@mid.uni-berlin.de> <87d4pe9caz.fsf@mulj.homelinux.net> <656vhnF2e9ao7U1@mid.uni-berlin.de> <8763v4otts.fsf@mulj.homelinux.net> <65fulvF2eiaalU1@mid.uni-berlin.de> Message-ID: <6224eb1e-0d48-47d7-bfcd-94e6dc9b5ce2@c19g2000prf.googlegroups.com> On Apr 2, 1:26 am, "Diez B. Roggisch" wrote: > It did *not* say that it supports every existing, more powerful and > generally better asynchronous mechanism supported by any OS out there. > Even though it would certainly be nice if it did :) Python's standard library should have an asynch module that uses aio on Linux and i/o completion ports on Windows. It should work with files and tcp sockets alike. From fredrik at pythonware.com Sun Apr 6 06:55:46 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 06 Apr 2008 12:55:46 +0200 Subject: Self in Interactive Interpreter In-Reply-To: <22a3ca84-242c-48de-b55c-d402d91ac280@b5g2000pri.googlegroups.com> References: <22a3ca84-242c-48de-b55c-d402d91ac280@b5g2000pri.googlegroups.com> Message-ID: kj7ny wrote: > With some of my larger applications, it doesn't seem to work well to > try to run the whole thing in the interpreter. At least for me, I am > not a big IDE sort of programmer. I am much more comfortable in vim > and command line stuff. I suppose I should use the IDE more. you don't need to run the whole thing, of course; just structure your code so you can work with individual modules, import *those* modules into the command line interface, and call their contents from there. cutting and pasting and rewriting code to be able to test it strikes me as tedious and error prone compared to the alternative. (and this has nothing to with IDE:s. I've worked full time with Python for ages, and I still do 99.5% of my programming with an editor and a command line) From jimgardener at gmail.com Sat Apr 26 03:24:23 2008 From: jimgardener at gmail.com (jimgardener) Date: Sat, 26 Apr 2008 00:24:23 -0700 (PDT) Subject: problem with listdir Message-ID: hi i have a directory containing .pgm files of P5 type.i wanted to read the pixel values of these files ,so as a firststep i wrote code to make a list of filenames using listdir pgmdir="f:\code\python\pgmgallery" # where i have pgm files g2=listdir(pgmdir) i get the following error WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect: 'f:\\code\\python\pgmgallery/*.*' i am running python on winXP ..can anyone tell me why i get this error? From emurphy42 at socal.rr.com Tue Apr 15 01:48:20 2008 From: emurphy42 at socal.rr.com (Ed Murphy) Date: Mon, 14 Apr 2008 22:48:20 -0700 Subject: Game design : Making computer play In-Reply-To: References: Message-ID: <480441dd$0$31765$4c368faf@roadrunner.com> v4vijayakumar wrote: > On Apr 14, 1:00 pm, v4vijayakumar > wrote: > .... >> I can post initial version of the game (implemented using html/ >> javascript) in couple of hours here. > > The game is here, > > http://v4vijayakumar.googlepages.com/goats-and-tigers.html The list of valid moves is incomprehensible to humans without actually drawing all the possible moves. Without an exhaustive check for validity, I think the following is an accurate summary: * Treat the board as a 5x6 grid with the corners removed and the top 4 cells merged. * Any piece can move one space up, down, left, or right. * A tiger can eat a goat by jumping over it, thereby moving two spaces up, down, left, or right. From aaron.watters at gmail.com Fri Apr 18 11:58:56 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Fri, 18 Apr 2008 08:58:56 -0700 (PDT) Subject: py3k concerns. An example Message-ID: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Why is the migration to py3k a concern? For example I have libraries which use string%dictionary substitution where the dictionary is actually an object which emulates a dictionary. The __getitem__ for the object can be very expensive and is only called when needed by the string substitution. In py3k string%dictionary is going away. Why? I have no idea. The replacement is a string.format(...) method which supports dictionary calling. string.format(**dictionary) But dictionary calling doesn't support dictionary emulation. So in the example below the substitution works but the call fails. === code class fdict(dict): def __getitem__(self, item): return "got("+item+")" def fn(**d): print d["boogie"] if __name__=="__main__": fd = fdict() print "attempting string substitution with fake dictionary" print print "hello there %(boogie)s" % fd # <-- works print print "now attempting function call with fake dictionary" print fn(**fd) # <-- fails === output % python2.6 dtest.py attempting string substitution with fake dictionary hello there got(boogie) now attempting function call with fake dictionary Traceback (most recent call last): File "dtest.py", line 17, in fn(**fd) File "dtest.py", line 7, in fn print d["boogie"] KeyError: 'boogie' ==== end of output Consequently there is no simple way to translate my code, I think. I suspect you will find this kind of subtle issue in many places. Or worse, you won't find it until after your program has been installed in production. It's a damn shame because if string%dict was just left in it wouldn't be an issue. Also, if making f(**d) support dict emulation has any negative performance implications then I don't want it please. sigh. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=crack+open From frikker at gmail.com Wed Apr 23 12:40:51 2008 From: frikker at gmail.com (blaine) Date: Wed, 23 Apr 2008 09:40:51 -0700 (PDT) Subject: Unix Device File Emulation References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> <480f6376$0$9037$5402220f@news.sunrise.ch> Message-ID: <9ee87070-be57-4a66-a152-3f36c1cc8f0c@k13g2000hse.googlegroups.com> On Apr 23, 12:27 pm, "Martin Blume" wrote: > "blaine" schrieb > > > > > > > # Fake Nokia Screen Emulator > > import sys, os > > > class nokia_fkscrn: > > def __init__(self, file): > > if not os.path.exists(file): > > os.mkfifo(file) > > self.fifodev = open(file, 'r') > > def read(self): > > while 1: > > r = self.fifodev.readline() > > print r > > > nokia = nokia_fkscrn('dev.file') > > nokia.read() > > > This works at first, but when I write to the 'dev.file' > > for the first time, the text is displayed as intended, > > but then the program just keeps spitting out blank lines. > > I can continue to write to the file > > (using echo 'test\n' > dev.file) > > and this shows up in my output, but amist a giant mass > > of scrolling blank lines. This also causes my CPU > > usage to shoot up to 100%. > > > Any ideas? This is OS X 10.4 > > while 1: > r = self.fifodev.readline() > if r: print r > > According to my docs, readline() returns an empty string > at the end of the file. > Also, you might want to sleep() between reads a little bit. > > IMHO. HTH. > Martin Oh ok, that makes sense. Hmm. So do I not want to use readline()? Or is there a way to do something like 'block until the file is not empty'? From paul at boddie.org.uk Tue Apr 22 07:36:26 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Tue, 22 Apr 2008 04:36:26 -0700 (PDT) Subject: subprocess module is sorely deficient? References: Message-ID: On 22 Apr, 12:52, Harishankar wrote: > > Is there any way to use non-blocking Popen objects using subprocess? and 2 - > is there a way to kill the subprocess in a platform independent manner in a > purely Pythonic way? I thought initially that this problem is simple enough, > but over the last couple of days I've been really struggling to find any > answer. I've been through dozens of mailing list archives in to find a > solution. Unfortunately none of the solutions seem to fit my needs. If you want some hints about using subprocesses with non-blocking I/O, you might find some in my jailtools and pprocess projects: http://www.python.org/pypi/jailtools http://www.python.org/pypi/pprocess Although these projects involve things which are not exactly cross- platform, the communications mechanisms should be portable, perhaps with a bit of effort (since I don't recall whether the poll library function is available on Windows, so you might have to use the select function instead). It can be awkward sustaining non-blocking communications with processes if they use buffered I/O, and the only way I could make Python-based subprocesses work in jailtools was to invoke them with the unbuffered option (-u). > My only solution seems to be to offer the end user the mencoder command line > and make them execute it manually and be done with it but that seems a rather > weak solution. The subprocess module may be an improvement over the popen2 module and various os module functions, but it's still rather arcane. Paul From darcy at druid.net Wed Apr 16 13:40:32 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Wed, 16 Apr 2008 13:40:32 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <20080416134032.cb2738e8.darcy@druid.net> On Wed, 16 Apr 2008 08:23:50 -0700 (PDT) Mike Driscoll wrote: > My workplace doesn't offer NNTP, so there is no good way to browse > c.l.py here. And I haven't been able to get NNTP to work from my home > either. Hi Mike; I am half way to killing Google groups myself. Your message, and allother Google groups messages, is coloured so that I can evaluate how much I will miss. So far it looks like it will make reading this group a whole lot more pleasant and so I will probably kill them soon. There are alternatives. I run an ISP http://www.Vex.Net/ that offers NNTP access to my shell users. You can also receive this group as a mailing list which is how I read it. Google is not the only option out there. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From NikitaTheSpider at gmail.com Thu Apr 10 11:12:36 2008 From: NikitaTheSpider at gmail.com (Nikita the Spider) Date: Thu, 10 Apr 2008 11:12:36 -0400 Subject: Stripping scripts from HTML with regular expressions References: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: In article , "Reedick, Andrew" wrote: > > -----Original Message----- > > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > > list-bounces+jr9445=att.com at python.org] On Behalf Of Michel Bouwmans > > Sent: Wednesday, April 09, 2008 3:38 PM > > To: python-list at python.org > > Subject: Stripping scripts from HTML with regular expressions > > > > Hey everyone, > > > > I'm trying to strip all script-blocks from a HTML-file using regex. > > > > [Insert obligatory comment about using a html specific parser > (HTMLParser) instead of regexes.] Yah, seconded. To the OP - use BeautifulSoup or HtmlData unless you like to reinvent wheels. -- Philip http://NikitaTheSpider.com/ Whole-site HTML validation, link checking and more From fengxie.shi at gmail.com Mon Apr 21 12:22:25 2008 From: fengxie.shi at gmail.com (fengxie.shi at gmail.com) Date: Mon, 21 Apr 2008 09:22:25 -0700 (PDT) Subject: wholesale air force one bape adidas wallet bikini tn shox air max air rift References: <5406db08-7333-46cb-bffc-787b9771c1a3@y18g2000pre.googlegroups.com> Message-ID: <6ccfb178-747d-4da4-8b8f-32524f474e11@x19g2000prg.googlegroups.com> We are the professional and serious wholesaler of brand products,such as shoes, clothing, handbags, sunglasses, hats, belts, and so on.We have many brands such as nike,adidas,puma,Gucci,North face.All goods are with best service,highest quality,competitive price,and safe timely deliverry If you are interested in these goods,don?t hasitate to cantact us please. Our website: http://www.nike1.com.cn. MSN?email?: okshoes at live.com Products list : Jordans shoes Jordan 1 shoes http://www.nike1.com.cn Jordan 2 shoes http://www.nike1.com.cn Jordan 3 shoes http://www.nike1.com.cn Jordan 4 shoes http://www.nike1.com.cn Jordan 5 shoes http://www.nike1.com.cn Jordan 6 shoes http://www.nike1.com.cn Jordan 7 shoes http://www.nike1.com.cn Jordan 8 shoes http://www.nike1.com.cn Jordan 9 shoes http://www.nike1.com.cn Jordan 10 shoes http://www.nike1.com.cn Jordan 11 shoes http://www.nike1.com.cn Jordan 12 shoes http://www.nike1.com.cn Jordan 13 shoes http://www.nike1.com.cn Jordan 14 shoes http://www.nike1.com.cn Jordan 16 shoes http://www.nike1.com.cn Jordan 17 shoes http://www.nike1.com.cn Jordan 18 shoes http://www.nike1.com.cn Jordan 19 shoes http://www.nike1.com.cn Jordan 20 shoes http://www.nike1.com.cn Jordan 21 shoes http://www.nike1.com.cn Jordan 22 shoes http://www.nike1.com.cn Jordan 23 shoes http://www.nike1.com.cn Nike Air Max Air Max 87 shoes http://www.nike1.com.cn Air Max 90 shoes http://www.nike1.com.cn Air Max 91 shoes http://www.nike1.com.cn Air Max 95 shoes http://www.nike1.com.cn Air Max 97 shoes http://www.nike1.com.cn Air Max 2003 shoes http://www.nike1.com.cn Air Max 360 shoes http://www.nike1.com.cn Air Max 180 shoes http://www.nike1.com.cn Air Max TN shoes http://www.nike1.com.cn Air Max TN2 shoes http://www.nike1.com.cn Air Max TN3 shoes http://www.nike1.com.cn Air Max TN6 shoes http://www.nike1.com.cn Air Max TN8 shoes http://www.nike1.com.cn Air Max LTD shoes http://www.nike1.com.cn Air Max 1 id shoes http://www.nike1.com.cn Nike Shox Shox NZ shoes http://www.nike1.com.cn Shox R4 shoes http://www.nike1.com.cn Shox TL3 shoes http://www.nike1.com.cn Shox TL4 shoes http://www.nike1.com.cn Shox TL shoes http://www.nike1.com.cn Shox OZ shoes http://www.nike1.com.cn Shox Rival shoes http://www.nike1.com.cn Shox Classic shoes http://www.nike1.com.cn Shox Energia shoes http://www.nike1.com.cn Nike Air Force 1 Air Force 1 low shoes http://www.nike1.com.cn Air Force 1 mid shoes http://www.nike1.com.cn Air Force 1 high shoes http://www.nike1.com.cn Air Force 1 25 shoes http://www.nike1.com.cn Nike Dunk sb shoes Dunk low shoes http://www.nike1.com.cn Dunk high shoes http://www.nike1.com.cn Adidas shoes http://www.nike1.com.cn Adidas Running shoes http://www.nike1.com.cn Adidas 35 shoes http://www.nike1.com.cn Adidas City shoes http://www.nike1.com.cn Adidas Goodyear shoes http://www.nike1.com.cn Adidas NBA shoes http://www.nike1.com.cn Adidas Y-3 shoes http://www.nike1.com.cn T-MAC shoes http://www.nike1.com.cn Rift shoes http://www.nike1.com.cn BapeStar shoes http://www.nike1.com.cn Football shoes http://www.nike1.com.cn Timberland boots shoes http://www.nike1.com.cn Hardaway shoes http://www.nike1.com.cn James shoes http://www.nike1.com.cn Puma shoes http://www.nike1.com.cn Prada shoes http://www.nike1.com.cn Prada low shoes http://www.nike1.com.cn Prada high shoes http://www.nike1.com.cn Dsquared shoes http://www.nike1.com.cn Gucci shoes http://www.nike1.com.cn Gucci low shoes http://www.nike1.com.cn Gucci high shoes http://www.nike1.com.cn LV shoes http://www.nike1.com.cn Kappa shoes http://www.nike1.com.cn Converse shoes http://www.nike1.com.cn Dsquared shoes http://www.nike1.com.cn D&G shoes http://www.nike1.com.cn Lacoste shoes http://www.nike1.com.cn Umbro shoes http://www.nike1.com.cn Versace shoes http://www.nike1.com.cn Woman boots http://www.nike1.com.cn ugg boots http://www.nike1.com.cn Burberry shoes http://www.nike1.com.cn EVISU shoes http://www.nike1.com.cn Hogan Shoes http://www.nike1.com.cn Hurricane Shoes http://www.nike1.com.cn handbag Bags http://www.nike1.com.cn LV Bag http://www.nike1.com.cn Gucci Bag http://www.nike1.com.cn Prada Bag http://www.nike1.com.cn D&G Bag http://www.nike1.com.cn Leather Bag http://www.nike1.com.cn A&F Bag http://www.nike1.com.cn Juicy Bag http://www.nike1.com.cn Guess Bag http://www.nike1.com.cn Feidi Bag http://www.nike1.com.cn Coach Bag http://www.nike1.com.cn Chloe Bag http://www.nike1.com.cn Chanel Bag http://www.nike1.com.cn ugg bag http://www.nike1.com.cn Burberry bag http://www.nike1.com.cn Dooney&Bourke bag http://www.nike1.com.cn Jimmy Choo bag http://www.nike1.com.cn Dior bag http://www.nike1.com.cn Purse CHANEL Purse http://www.nike1.com.cn COACH Purse http://www.nike1.com.cn Else Purse http://www.nike1.com.cn GUCCI Purse http://www.nike1.com.cn LV Purse http://www.nike1.com.cn man purse http://www.nike1.com.cn Strap BAPE Strap http://www.nike1.com.cn BOSS Strap http://www.nike1.com.cn CHANEL Strap http://www.nike1.com.cn D&G Strap http://www.nike1.com.cn GIORGIO ARMANI Strap http://www.nike1.com.cn GUCCI Strap http://www.nike1.com.cn LV Strap http://www.nike1.com.cn Glasses ARMANI Glasses http://www.nike1.com.cn BURBERRY Glasses http://www.nike1.com.cn BVLGARI Glasses http://www.nike1.com.cn Ray.Ban Glasses http://www.nike1.com.cn VERSACE Glasses http://www.nike1.com.cn Prada Glasses http://www.nike1.com.cn OKEY Glasses http://www.nike1.com.cn LV Glasses http://www.nike1.com.cn HERMES Glasses http://www.nike1.com.cn EL.FERROL Glasses http://www.nike1.com.cn DIOR Glasses http://www.nike1.com.cn D&G Glasses http://www.nike1.com.cn GUCCI Glasses http://www.nike1.com.cn CHANEL Glasses http://www.nike1.com.cn CS Glasses http://www.nike1.com.cn CARTIER Glasses http://www.nike1.com.cn Watch http://www.nike1.com.cn Rolex Watch http://www.nike1.com.cn clothing http://www.nike1.com.cn 10 DEEP clothing http://www.nike1.com.cn A&F clothing http://www.nike1.com.cn Abercrombie&Fitch clothing http://www.nike1.com.cn Abercrombie & Fitch clothing http://www.nike1.com.cn ADICOLOR clothing http://www.nike1.com.cn ADIDAS clothing http://www.nike1.com.cn AK clothing http://www.nike1.com.cn ARMANI T-shirt http://www.nike1.com.cn ARMANI Sweater http://www.nike1.com.cn polo Sweater http://www.nike1.com.cn Artful dodger clothing http://www.nike1.com.cn BAPE clothing http://www.nike1.com.cn BBC clothing http://www.nike1.com.cn CLH clothing http://www.nike1.com.cn COOGI clothing http://www.nike1.com.cn D&G clothing http://www.nike1.com.cn DSQUARED clothing http://www.nike1.com.cn ED clothing http://www.nike1.com.cn HARDY clothing http://www.nike1.com.cn EVISU clothing http://www.nike1.com.cn EVS clothing http://www.nike1.com.cn GGG clothing http://www.nike1.com.cn G-STAR clothing http://www.nike1.com.cn LACOSTE T-shirt clothing http://www.nike1.com.cn Lacoste Sweater http://www.nike1.com.cn LRG clothing http://www.nike1.com.cn NY clothing http://www.nike1.com.cn O&L clothing http://www.nike1.com.cn POLO T-shirt 3 4 5 http://www.nike1.com.cn POLO T-shirt clothing http://www.nike1.com.cn Byrberry T-shirt http://www.nike1.com.cn UGG clothing http://www.nike1.com.cn Byrberry clothing http://www.nike1.com.cn NFL Jersey http://www.nike1.com.cn scarf scarves http://www.nike1.com.cn jeans http://www.nike1.com.cn AFTFUL DODGER jeans http://www.nike1.com.cn AKA STASH HOUSE jeans http://www.nike1.com.cn APE jeans http://www.nike1.com.cn BBC jeans http://www.nike1.com.cn COOGI jeans http://www.nike1.com.cn D&G jeans http://www.nike1.com.cn DIESEL jeans http://www.nike1.com.cn ED jeans http://www.nike1.com.cn EVISU jeans http://www.nike1.com.cn Gino jeans http://www.nike1.com.cn G-Star jeans http://www.nike1.com.cn LRG jeans http://www.nike1.com.cn RMC jeans http://www.nike1.com.cn ROCK jeans http://www.nike1.com.cn SHMACK jeans http://www.nike1.com.cn TR jeans http://www.nike1.com.cn ugg jeans http://www.nike1.com.cn hat cap http://www.nike1.com.cn Chanel hat Cap http://www.nike1.com.cn D&G hat cap http://www.nike1.com.cn G-Star hat Cap http://www.nike1.com.cn Gucci hat Cap http://www.nike1.com.cn lv hat Cap http://www.nike1.com.cn POLO hat Cap http://www.nike1.com.cn Prada hat Cap http://www.nike1.com.cn PSP sp2 http://www.nike1.com.cn MP3 MP4 http://www.nike1.com.cn Mobile phone http://www.nike1.com.cn iPhone http://www.nike1.com.cn nokia 8800 http://www.nike1.com.cn nokia n95 http://www.nike1.com.cn nokia n93i http://www.nike1.com.cn nokia n73 http://www.nike1.com.cn memory stick http://www.nike1.com.cn memory strip http://www.nike1.com.cn From sjmachin at lexicon.net Sat Apr 5 19:56:18 2008 From: sjmachin at lexicon.net (John Machin) Date: Sat, 5 Apr 2008 16:56:18 -0700 (PDT) Subject: Best way to check if string is an integer? References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> Message-ID: <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> On Apr 6, 9:25 am, Mark Dickinson wrote: > On Apr 5, 6:19 pm, skanem... at yahoo.se wrote: > > > which is the best way to check if a string is an number or a char? > > could the 2nd example be very expensive timewise if i have to check a > > lot of strings? > > You might be interested in str.isdigit: > > >>> print str.isdigit.__doc__ > > S.isdigit() -> bool > > Return True if all characters in S are digits > and there is at least one character in S, False otherwise. > This doesn't cater for negative integers. From bruno.desthuilliers at gmail.com Wed Apr 2 14:24:34 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 11:24:34 -0700 (PDT) Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> Message-ID: On 2 avr, 16:52, sam wrote: > Bruno Desthuilliers napisa?(a): > > > Don't misunderstand me : I'm not saying that class-based is better (or > > worse) than prototype, I'm not saying that Python is perfect, I'm not > > saying that your points are not worth any consideration, I'm just saying > > that, from your arguments, I have the very strong impression that you > > don't know enough about Python's object model to understand it's > > coherence and strength (and I've probably expressed it a rather harsh > > way - please bear with me). If I'm wrong, please say so, pardon me and > > we'll move ahead. > > I understand you. Thanks for spending time to write all that things. > > The point is that when I say: > > -- you should have same syntax of lambdas and ordinary functions > > then Python gurus say: > > -- lambda is very good and is so special, that has its own syntax > > But it seems to me, that lambda syntax was introduced because of interpreter > limitations -- indentation and expressions. So it is not perfect, but must be as > it is now. You're of course right on this. OTHO, I found out that with languages that let you define "full-blown" inline anonymous functions (like javascript), I tend to make any non- trivial function into an ordinary named one - mainly for readability. So, while I often use Python's lambdas, the imposed limitations is ok to me since I wouldn't use it for anything more complex. But I may be a bit biased here since I discovered the concept of anonymous functions (and quite a lot of other more or less functional programming inspired stuff) with Python. Also - as a side note - while the syntax is a bit different, the resulting object is an ordinary function. > Then I say: > > -- __id is awful, because it is a trick to prefix names > > and gurus say: > > -- it is good solution for name conflicts > > But somebody may prefix his names with class names and cause nameconflict, Here the problem is more philosophical than anything else. Python's philosophy is that most programmers are responsible and normally intelligent, so treating them all like retarted dummies because someone might one day do something stupid is just wasting everyone's time. This is also why there's no language-enforced access restriction, only a simple stupid convention to denote implementation stuff from API. The fact is that it JustWork. > so > maybe it is not so good? It's enough. FWIW, I'm not sure I had a use-case for this feature more than a couple time in 7+ years. > I would prefer to hear something like "other solutions > were very complex, and our zen says 'Simple is better than complex.', so we > decided to use this simple and not perfect solution" Simple, indeed. But why "not perfect" ? What else would you want ? From steve at holdenweb.com Thu Apr 24 22:49:59 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 22:49:59 -0400 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: <60fc4333-6d2b-40f5-b311-031d90a38d39@k37g2000hsf.googlegroups.com> References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <60fc4333-6d2b-40f5-b311-031d90a38d39@k37g2000hsf.googlegroups.com> Message-ID: sturlamolden wrote: > On Apr 22, 1:07 pm, GD wrote: > >> Please remove ability to multiple inheritance in Python 3000. > > Too late for that, PEPs are closed. > >> Multiple inheritance is bad for design, rarely used and contains many >> problems for usual users. >> >> Every program can be designed only with single inheritance. > > That's how the Java designers were thinking as well: If MI is allowed, > programmers will suddenly get an irresistible urge to use MI to write > unmaintainable spaghetti code. So let's disallow MI for the sake of > common good. Fortunately, Python is not designed to be fool proof > against fools. If you cannot use MI properly, then don't use that. > > >> I also published this request athttp://bugs.python.org/issue2667 > > You reported MI as a bug??? > The eventual disposition was "closed, invalid". regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From sophacles at gmail.com Tue Apr 15 14:51:53 2008 From: sophacles at gmail.com (Erich) Date: Tue, 15 Apr 2008 11:51:53 -0700 (PDT) Subject: Recurring patterns: Am I missing it, or can we get these added to the language? Message-ID: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Hello all, Today I found myself once again defining two functions that I use all the time: nsplit and iterable. These little helper functions of mine get used all the time when I work. Im sick of having to define them (but am very good at it these days, less than 1 typo per function!). It leads me to the following questions 1. Is this functionality already built in and im just missing it 2. Is there some well known, good technique for these that I missed? 3. Insert question I need to ask here (with a response) These are the funtions w/ explaination: def nsplit(s,p,n): n -= 1 l = s.split(p, n) if len(l) < n: l.extend([''] * (n - len(l))) return l This is like split() but returns a list of exactly lenght n. This is very useful when using unpacking, e.g.: x, y = nsplit('foo,bar,baz', ',', 2) def iterable(item, count_str=False): if not count_str and isinstance(item, str): return False try: iter(item) except: return False return True This is just simple boolean test for whether or not an object is iterable. I would like to see this in builtins, to mirror callable. The optional count_str adds flexibility for string handling, since sometimes I need to iterate over a string, but usually not. I frequently use it to simplify my case handling in this type of costruct: def foo(bar): bar = bar if iterable(bar) else [bar] for x in bar: .... Thanks for feeback, Erich From colas.francis at gmail.com Thu Apr 17 11:54:07 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Thu, 17 Apr 2008 08:54:07 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> Message-ID: <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> On 17 avr, 17:40, s0s... at gmail.com wrote: > > Yuck! No way!! If you *want* to make your code that hard to read, I'm > > sure you can find lots of ways to do so, even in Python, but don't > > expect Python to change to help you toward such a dubious goal. > > Well, my actual code doesn't look like that. Trust me, I like clean > code. > > > Seriously, examine your motivations for wanting such a syntax. Does it > > make the code more readable? (Absolutely not.) Does it make it more > > maintainable. (Certainly not -- consider it you needed to change > > CONSTANT2 to a different value some time in the future.) > > Yes, it makes it more readable. And yes, it does make it (a lot) more > maintainable. Mainly because I don't have those four variables, I have > about thirty. And I think I won't need to one or two of them, but > maybe all of them at once. Out of sheer curiosity, why do you need thirty (hand-specified and dutifully commented) names to the same constant object if you know there will always be only one object? From zillow10 at googlemail.com Wed Apr 2 09:36:59 2008 From: zillow10 at googlemail.com (zillow10 at googlemail.com) Date: Wed, 2 Apr 2008 06:36:59 -0700 (PDT) Subject: generator functions: why won't this work? References: Message-ID: <0aaeddf2-ee63-426e-afb3-0e1acb15adef@r9g2000prd.googlegroups.com> On Apr 2, 4:42 am, "Gabriel Genellina" wrote: > En Tue, 01 Apr 2008 23:56:50 -0300, escribi?: > > > I'm trying to understand generator functions and the yield keyword. > > I'd like to understand why the following code isn't supposed to work. > > (What I would have expected it to do is, for a variable number of > > arguments composed of numbers, tuples of numbers, tuples of tuples, > > etc., the function would give me the next number "in sequence") > > #################################### > > def getNextScalar(*args): > > for arg in args: > > if ( isinstance(arg, tuple)): > > getNextScalar(arg) > > else: > > yield arg > > #################################### > > You're not the first one in getting confused. After all, this schema works > well for other recursive constructs. > Perhaps a progression of working code samples will help to understand what > happens here. The simplest thing would be to just print the items as > they're encountered, in a recursive call: > > py> data = (1, 2, (3,4,(5,6),7)) > py> > py> print "1) using print" > 1) using print > py> > py> def getNextScalar(args): > ... for arg in args: > ... if isinstance(arg, tuple): > ... getNextScalar(arg) > ... else: > ... print arg > ... > py> getNextScalar(data) > 1 > 2 > 3 > 4 > 5 > 6 > 7 > > Now one could try to collect the numbers in a list: > > py> print "2) using extend" > 2) using extend > py> > py> def getNextScalar(args): > ... result = [] > ... for arg in args: > ... if isinstance(arg, tuple): > ... result.extend(getNextScalar(arg)) > ... else: > ... result.append(arg) > ... return result > ... > py> getNextScalar(data) > [1, 2, 3, 4, 5, 6, 7] > > Note that we use two different list methods: for individual items, we use > "append", but for tuples we use "extend" in the recursive call. If extend > weren't available, we could emulate it with append: > > py> print "3) using append" > 3) using append > py> > py> def getNextScalar(args): > ... result = [] > ... for arg in args: > ... if isinstance(arg, tuple): > ... for item in getNextScalar(arg): > ... result.append(item) > ... else: > ... result.append(arg) > ... return result > ... > py> getNextScalar(data) > [1, 2, 3, 4, 5, 6, 7] > > See how we need an additional loop to iterate over the results that we get > from the recursive call. > Now instead of building an intermediate result list, we delegate such task > over the caller, and we use a generator that just yields items; this way, > we remove all references to the result list and all result.append calls > become yield statements. The inner loop has to remain the same. The yield > statement acts somewhat as an "append" over an outer list created by the > generator's caller. > > py> print "4) using yield" > 4) using yield > py> > py> def getNextScalar(args): > ... for arg in args: > ... if isinstance(arg, tuple): > ... for item in getNextScalar(arg): > ... yield item > ... else: > ... yield arg > ... > py> getNextScalar(data) > > py> list(getNextScalar(data)) > [1, 2, 3, 4, 5, 6, 7] > > I hope it's more clear now why you have to use yield on the recursive call > too. > > > Perhaps this: > > yield *iterable > > could be used as a shortcut for this: > > for __temp in iterable: yield __temp > > > > -- > Gabriel Genellina Thanks to everyone for your very helpful replies. I think I was trying to use generator functions without first having really read about iterators (something I still haven't done, although I've managed to extrapolate some details based on your comments), and therefore really "putting the cart before the horse". I was interpreting getNextScalar(arg) on line 3 as a function call in the usual sense rather than an object that was being created but never used. I have a question about the other issue that was pointed out. With reference to the following (corrected) code: def getNextScalar(*args): for arg in args: if(isinstance(arg, tuple)): for f in getNextScalar(*arg): # why not getNextScalar(arg)? yield f else: yield arg although I've verified that the line 4 needs to be "for f in getNextScalar(*arg)" rather than "for f in getNextScalar(arg)" when passing multiple arguments to the function, I'd just like to test my understanding of this. Suppose I create the following generator object: g = getNextScalar(1, 2, (3, 4), 5) when the iterator reaches the tuple argument (3, 4) then, according to Steve and George, the * in *arg causes this tuple to be expanded into positional arguments, and it makes sense to do it this way. But what happens when getNextScalar(arg) is used instead? I presume that (3,4) is passed as a single tuple argument, if(isinstance(arg, tuple)) is true, and the tuple is passed again as an the argument to getNextScalar()... ad infinitum. The alternative is to define a function that takes a tuple, as Gabriel has done. Regards, AK From mail at timgolden.me.uk Tue Apr 15 10:43:08 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 15 Apr 2008 15:43:08 +0100 Subject: Get oldest folder In-Reply-To: <22671872.735671208269119432.JavaMail.root@hrndva-web19-z02> References: <22671872.735671208269119432.JavaMail.root@hrndva-web19-z02> Message-ID: <4804BEFC.4000105@timgolden.me.uk> jyoung79 at kc.rr.com wrote: > I'd like to be able to get the path to the oldest folder in whatever directory I'm currently in. And just because I'm feeling silly: import os print os.popen ("dir /b /ad /od /tc c:\python25\lib\site-packages").readline () TJG From sidhpurwala.huzaifa at gmail.com Mon Apr 14 06:04:07 2008 From: sidhpurwala.huzaifa at gmail.com (Huzaifa Sidhpurwala) Date: Mon, 14 Apr 2008 15:34:07 +0530 Subject: Remote mac address In-Reply-To: <54lbd5-dk7.ln1@nb2.stroeder.com> References: <54lbd5-dk7.ln1@nb2.stroeder.com> Message-ID: <48032C17.9050305@gmail.com> Michael Stro"der wrote: > Matias Surdi wrote: > >> Anyone knows how having the IP address of a host on the lan could I get >> the mac address of that hosr? >> >> p/d: Parsing the output of arp -a is not an option. >> > > Any reason why arp is not an option? > But the ARP table is exactly what you need to access. This is probably > system-specific. > > You could also try to send ARP requests yourself: > http://www.secdev.org/projects/scapy/ > http://www.ibm.com/developerworks/aix/library/au-pythocli/ > > Ciao, Michael. > From mccredie at gmail.com Mon Apr 21 16:42:48 2008 From: mccredie at gmail.com (Matimus) Date: Mon, 21 Apr 2008 13:42:48 -0700 (PDT) Subject: Code question References: Message-ID: <60ffc058-488f-4e58-b3c9-a60c21595c6f@w8g2000prd.googlegroups.com> On Apr 21, 12:05 pm, wrote: > I've been trying to figure out a way to combine lists similar to how zip() works. The main > difference though is I want to work with different length lists and combine them. I came up with > the example below, which returns a list like I'm wanting. I'm assuming it's somewhat efficient > (although I wonder if the lists were huge that the 'if' statement might slow things down?). > > If anyone has time, I was wondering if you could share your thoughts on whether this is an > efficient way to do something like this, if it's horrible and slow, etc. > > Thanks! > > Jay > > # ---------------------------- > > > def combineLists(theLists): > cntList = len(theLists) > lenList = [len(x) for x in theLists] > > maxList = max(lenList) > > combinedList = [] > > for x in range(maxList): > for n in range(cntList): > if lenList[n] > x: combinedList.append(theLists[n][x]) > > print combinedList > > combineLists([a, b, c]) > > # ---------------------------- > > # --> ['a', '1', 'a1', 'b', '2', 'b2', 'c', 'c3', 'd4', 'e5'] I would probably do something like this: >>> def combine(*seqs): ... seqs = [iter(s) for s in seqs] ... while seqs: ... for g in seqs: ... try: ... yield g.next() ... except StopIteration: ... seqs.remove(g) ... >>> a = 'abc' >>> b = '12' >>> c = 'a1 b2 c3 d4 e5'.split() >>> list(combine(a,b,c)) ['a', '1', 'a1', 'b', '2', 'b2', 'c', 'c3', 'd4', 'e5'] It has the advantage that it uses the generator protocol, so you can pass in any type of sequence. It uses arbitrary arguments to make its use closer to that of zip. It is also a generator, so it takes advantage of lazy evaluation. Notice that there is never any checking of length. Matt From medin0065 at gmail.com Sun Apr 20 10:49:10 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:49:10 -0700 (PDT) Subject: nikon lightroom crack Message-ID: nikon lightroom crack http://cracks.00bp.com F R E E C R A C K S From skanemupp at yahoo.se Fri Apr 11 07:01:42 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 11 Apr 2008 04:01:42 -0700 (PDT) Subject: tkinter, overwrite Label-text? References: <666s2qF2il38sU1@mid.uni-berlin.de> Message-ID: <403d094e-2704-40c0-a0b3-dd335b19af85@m1g2000pre.googlegroups.com> On 10 Apr, 18:03, Marc 'BlackJack' Rintsch wrote: > On Thu, 10 Apr 2008 07:37:08 -0700, skanemupp wrote: > > i know how to do this already. the problem is i want the text to stay > > in the windowa nd not start overwriting "Answer:". > > Then don't use `place()` but let Tkinter handle the layout with the pack > and/or grid layout manager. GUIs with `place()` are a bad idea because > the GUI may look odd or is even unusable on other peoples computers with > other screen resolutions, fonts, and font sizes. > > Ciao, > Marc 'BlackJack' Rintsch ok but i have trouble using grid. if i try to use a Label witht he text answer in the following code it doenst work very well. from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") ##l = Label(mygui, text="Answer: ") ##l.grid(row=2, column=1, columnspan=2) e = Entry(mygui) e.grid(row=1, column=1, columnspan=4) c = Entry(mygui) c.grid(row=2, column=1, columnspan=4) def Disp(nstr): e.insert(INSERT, nstr) def Calc(): expr=e.get() c.delete(0, END) try: c.insert(END, eval(expr)) except: c.insert(END, "Not computable") def Erase(): e.delete(0,END) c.delete(0, END) def Backspace(): a=len(e.get()) e.delete(a-1,END) #e.delete(INSERT, END) #e.delete(ANCHOR,END) x = 1 y = 4 for char in '123+456-789*0()/.': b = Button(mygui, text=char, command=lambda n=char:Disp(n), width=2, height=1) b.grid(row=y, column=x) x=x+1 if x==5: x=1 y=y+1 b = Button(mygui, text="^", command=lambda n="**":Disp(n), width=2, height=1) b.grid(row=8, column=2) b = Button(mygui, text="C",command=Erase, width=2, height=1) b.grid(row=8, column=3) b = Button(mygui, text="c",command=Backspace, width=2, height=1) b.grid(row=8, column=4) b = Button(mygui, text="=",command=Calc, width=18, height=1) b.grid(row=9, column=1, columnspan=8) mygui.mainloop() From dave.l.harrison at gmail.com Fri Apr 18 05:27:21 2008 From: dave.l.harrison at gmail.com (David Harrison) Date: Fri, 18 Apr 2008 19:27:21 +1000 Subject: testing client-server sockets In-Reply-To: <48086408.4070205@al.com.au> References: <4808627F.5040906@al.com.au> <48086408.4070205@al.com.au> Message-ID: On 18/04/2008, Astan Chee wrote: > Server code: > > import os, sys, socket > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > host = '' > port = 5602 > s.bind((host,port)) > try: > s.listen(1) > while 1: > conn, addr = s.accept() > print 'client is at', addr > data = conn.recv(1000000) > data = data * 10 > z = raw_input() > conn.send(data) > conn.close() > except Exception: > s.close() > > Client code: > > import sys, os, socket > > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > host = 'hostIP' > port = 5602 > s.connect((host,port)) > s.send(dlg.user.GetValue()) > i =0 > while True: > data = s.recv(1000000) > i+=1 > if (i<5): > print data > if not data: > break > print 'received', len(data), 'bytes' > s.close() I just ran the code (albeit with a tiny change to send a small string instead so I could see what was going on), and it seems to work fine ... anything else that might be different ? From grflanagan at gmail.com Mon Apr 7 05:46:34 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Mon, 7 Apr 2008 02:46:34 -0700 (PDT) Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> <47f514c5$0$6520$4c368faf@roadrunner.com> Message-ID: <95e51af9-c0c8-4e46-a1fe-ac75a0305859@24g2000hsh.googlegroups.com> On Apr 3, 8:33 pm, AK wrote: > AK wrote: > > Hello, > > > I find that I learn easier when I go from specific examples to a more > > general explanation of function's utility and I made a reference guide > > that will eventually document all functions, classes and methods in > > Python's Standard Library. For now, I covered about 20 most important > > modules. I will be adding more modules and eventually I'll cover > > everything. Here's my progress so far, let me know if this is useful; > > I'll be glad to hear comments/suggestions/etc: > > >http://www.lightbird.net/py-by-example/ > > I uploaded an updated site incorporating most of the suggestions I > received and fixing some errors along the way. I will be adding more > examples to modules that are already covered and will try to add more > modules during the following week. Thanks again to all who posted advice > and comments! > I don't know if you've heard of Sphinx, it's being used to generate the Python 2.6 docs but can also be used standalone. It may have benefits for a project like yours, particularly with regard to collaboration and maintainability over the long-term. I've been playing about with it myself and put together a `very` basic site using a few of the pages from your site: The generated html is here: http://gflanagan.net/site/python/pbe/pbe-sphinx-skeleton-build-0.1.tar.gz http://gflanagan.net/site/python/pbe/pbe-sphinx-skeleton-build-0.1.zip And the actual Sphinx 'app': http://gflanagan.net/site/python/pbe/pbe-sphinx-skeleton-0.1.tar.gz http://gflanagan.net/site/python/pbe/pbe-sphinx-skeleton-0.1.zip For which you would need Sphinx (obviously): http://sphinx.pocoo.org/ which depends on docutils: http://docutils.sourceforge.net/ and pygments: http://pygments.org/ There's a make.bat for windows and a MakeFile for unix but the latter is untested. I've no time to spend on it further, but you're welcome to what's there if you've any interest. (I repeat, it's just a proof of concept - don't expect too much.) As you might see, I preferred 'doctest' style code rather than the commented results, but each to their own. Sphinx uses ReST as its input format - below is what I cooked up for 'restifying' your html, not perfect but a brave attempt! All the best. Gerard ------------------------------------------------------------------ import textwrap import re import os from BeautifulSoup import BeautifulSoup def onmatch(m): return '\nRESULT' + m.group(2) result = re.compile('(# )?(.*?)', re.DOTALL | re.MULTILINE) src = 'c:/workspace/pbe/orig/' for infile in os.listdir(src): if not infile.endswith('-module.html'): continue title = infile[:-5] infile = src + infile outfile = infile[:-4] + 'rst' out = open(outfile, 'wb') out.write(title + '\n') out.write('='*len(title) + '\n\n') soup = BeautifulSoup(open(infile).read()) for p in soup.findAll('ul'): print >> out for line in textwrap.wrap(p.span.contents[0], 79): print >> out, line.lstrip() #code = ''.join(comment.sub(onmatch, str(p.pre))) code = result.sub(onmatch, str(p.pre)).splitlines()[1:-1] if code: print >> out print >> out, '::' print >> out for line in code: line = line.strip() if line: leader = ' ' if line.startswith('RESULT'): line = line[len('RESULT'):] else: leader += '>>> ' print >> out, leader + line else: print >> out print >> out out.close() ------------------------------------------------------------------ From gagsl-py2 at yahoo.com.ar Tue Apr 1 01:16:15 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 02:16:15 -0300 Subject: python persistence References: <8b1723d9-67c8-4fe5-b07b-22b0b9311519@8g2000hsu.googlegroups.com> <7f58b5f4-3195-472c-b307-dec71b12aaa8@y21g2000hsf.googlegroups.com> <44f04bf3-4edc-4cb4-9e54-fe51b5e591bc@e39g2000hsf.googlegroups.com> <80d1731d-a3c6-4fce-81fd-9c3f3537e59b@d21g2000prf.googlegroups.com> <5386cf08-c155-4fbb-8373-dbbb9829a9e7@m3g2000hsc.googlegroups.com> <3c27b270-e593-4f2a-b881-68126319760c@8g2000hsu.googlegroups.com> Message-ID: En Tue, 01 Apr 2008 00:48:35 -0300, escribi?: > We do have, but on Windows, file is not locked to multi-tasking, > shelve. But why don't we have types in there, or non-string > primitives in keys? > >>>> c= shelve.open( 'temp', 'c' ) >>>> c['0']= 'a' >>>> c.sync() >>>> del c >>>> c= shelve.open( 'temp', 'c' ) >>>> c['0'] > 'a' > >>>> c['0'].append( 0 ) >>>> c['0'] > [] The above session doesn't make sense unless it's somewhat related to "on Windows, file is not locked to multi-tasking," and another process has modified the database in-between. I don't think the problem is restricted to Windows only. There exist file locking mechanisms. > And why don't primitive mutations modify contents of disk? A > metaquestion. They do, if you pass writeback=True to the shelve constructor, but read the docs. shelve is a simple class; if it can't fulfill your needs, you may want to use a relational database (perhaps with an ORM like SQLObjects or SQLAlchemy) or an object database like ZODB or Durus. >>>> c['0']= type('None',(),{}) > Traceback (most recent call last): > pickle.PicklingError: Can't pickle : it's not > found as __main__.None Don't do that then. Or use the available pickle hooks to customize how such classes may be pickled. All persistence mechanisms have limitations. -- Gabriel Genellina From patrickkidd.lists at gmail.com Fri Apr 11 03:26:32 2008 From: patrickkidd.lists at gmail.com (Patrick Stinson) Date: Fri, 11 Apr 2008 01:26:32 -0600 Subject: problem using import from PyRun_String In-Reply-To: References: <664bf2b80804081801u79ae9192h90c03c84c1ef35ce@mail.gmail.com> <664bf2b80804090931y78d9e34dof268784cc6a6cde9@mail.gmail.com> Message-ID: <664bf2b80804110026h4175426dk97977471ce20d189@mail.gmail.com> Great, that was the answer I was looking for, thank you. I'll respond with how well it works. On Thu, Apr 10, 2008 at 12:16 AM, Gabriel Genellina wrote: > En Wed, 09 Apr 2008 13:31:22 -0300, Patrick Stinson > escribi?: > > > Well, I eventually want to add an import hook, but for now I'd rather > > just > > get the import statement working normally again. > > I have embedded python as a scripting engine in my application. To do > > this, > > I create a new empty module, run the script text using PyRun_String() > > passing the module's __dict__ as locals and globals. This populates the > > module's __dict__ with the resulting object references from the script > > text. > > Instead of PyRun_String, use PyImport_ExecCodeModuleEx, which takes care > of setting __builtins__ and other details. > You will need to compile the source first (using Py_CompileStringFlags) > which is a good thing anyway, to help catching errors. > > > As I said before I must be forgetting some other module init stuff > > because I > > had to manually populate the modules' __dict__ with references from the > > __builtin__ module in order to get the basic stuff like abs, range, etc. > > That's not exactly what CPython does; if you inspect globals() you don't > see abs, range, etc. Instead, there is a __builtins__ attribute (note the > "s") that points to the __builtin__ module or its __dict__. > > > I understand what __builtin__ is used for, but the C struct pointing to > > the > > code frame that contains the import statement has a builtin member that > > apparently does not contain the __import__ function, hence my question. > > There must be some difference in the way code is parsed and a copy of > the > > __builtin__ module is passed normally and the way I am doing it. > > When a frame builtins != internal builtins, Python runs in "restricted > execution mode", and disallows access to some objects and attributes, I > think that __import__ is one of them. > See http://docs.python.org/lib/module-rexec.html > (That's why it's important to use the right way to create a module) > > > So, finding the place where this module bootstrapping normally happens > > would > > be awesome, because I sort of feel like I'm hacking this method running > > into > > problems like this. > > Exactly. The simplest way would be to save the source code on disk and > just import it, letting Python do all the dirty work. But > compiling+PyImport_ExecCodeModule should work, I presume - any feedback is > welcome! > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Patrick Kidd Stinson http://www.patrickkidd.com/ http://pkaudio.sourceforge.net/ http://pksampler.sourceforge.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From gagsl-py2 at yahoo.com.ar Tue Apr 15 01:13:19 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 15 Apr 2008 02:13:19 -0300 Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: En Tue, 15 Apr 2008 01:30:05 -0300, Sverker Nilsson escribi?: > No one forces me, but sooner or later they will want a Python 3.0 and > then a 3.1 whatever. Welcome to the software industry! If it isn't Python changing, it's the operating system, the processor architecture, the network connectivity, whatever. Only very abstract and generic applications may survive a long time without being affected by changes in the environment. You choose to develop a very specific tool tied to the specifics of memory management in Python (a really good idea, btw), but unfortunately you'll have to adapt it to changes in the language. > I don't want that fuzz. As about the C versions, I am not that > worried. What's your point? You said that a C program doesn't have to be changed when the compiler/language changes, and I refuted that assertion. > I just like want to write a program that will stay working. And maybe > I can go on with something else hopefully than just compatibility > fixes. They take some work afterall. > > It seems hard with Python. Esp. 2 -> 3 Bad luck, you just decided to write your program in the transition phase... In a couple years, I think 3 will be reasonably as stable as 2.x today. -- Gabriel Genellina From aaron.watters at gmail.com Wed Apr 2 12:06:25 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 2 Apr 2008 09:06:25 -0700 (PDT) Subject: april fools email backfires References: Message-ID: <51ab8eb3-e76e-40f1-b924-27297fdfea1c@m3g2000hsc.googlegroups.com> On Apr 2, 11:07 am, Paul McGuire wrote: > > Can you post a link? > > -- Paul Sorry. It came from private email. And I don't want to get anyone in trouble... -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=secret+feature From oakley at bardo.clearlight.com Sun Apr 13 09:45:50 2008 From: oakley at bardo.clearlight.com (Bryan Oakley) Date: Sun, 13 Apr 2008 08:45:50 -0500 Subject: tkinter, annoying grid-problem In-Reply-To: <094b0808-053a-4a36-be11-694bb3835bb5@q1g2000prf.googlegroups.com> References: <094b0808-053a-4a36-be11-694bb3835bb5@q1g2000prf.googlegroups.com> Message-ID: skanemupp at yahoo.se wrote: > so my little calculator works perfectly now. just having some trouble > with the layout. > this whole tkinter-thing seems to be more tricky than it should be. > how can i make the 4 column of buttons have the same distance and > size between them as the other 3 columns? > and how can i make the top entry end where the 2nd row entry > ends(meaning the top entry will be longer)? > > why are the 4th row split from the others? hard to fix the problems > when u dont even understand why things happen. seems so llogical a lot > of it. i change something then something unexpected happens. The best answer I can give (being a Tk expert but not yet a tkinter expert) is to start with a piece of graph paper. Draw the GUI out and you'll probably see what the problems are. For one, the second entry (for the answer) spans 4 columns and begins at column 3, so it ends up in column 6. This ends up affecting the whole layout because nothing else goes to column six. You'll probably find it much easier going to break down your GUI into sections. One for the calculator buttons and one for everything else. Create a frame for the buttons and it becomes trivial to layout out all the buttons in a 4x6 grid, unaffected by things outside that grid. Then, create your other widgets and grid the whole frame of buttons as a single unit inside the outermost frame. I quite often use grid for interior groupings, then use pack on the outter-most frame to manager the various groups. Using the grid layout manager is trivial if you do a little thinking and planning up front. If you don't, you can spend all day chasing down why you end up with an extra blank row or column, unusually sized rows and columns, etc. Again, get a piece of graph paper and draw it out -- that helps immensely when you're first coming up to speed using grid. From s0suk3 at gmail.com Wed Apr 16 16:53:16 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Wed, 16 Apr 2008 13:53:16 -0700 (PDT) Subject: Profiling, recursive func slower than imperative, normal? References: Message-ID: On Apr 16, 3:27 pm, Jean-Paul Calderone wrote: > Any function can be implemented without recursion, although it isn't > always easy or fun. > > Jean-Paul Really? I'm curious about that, I can't figure out how that would work. Could give an example? Say, for example, the typical: walking through the file system hierarchy (without using os.walk(), which uses recursion anyway!). From grflanagan at gmail.com Fri Apr 11 08:14:13 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Fri, 11 Apr 2008 05:14:13 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: On Apr 11, 2:05 pm, Gerard Flanagan wrote: > On Apr 11, 12:14 pm, bdsatish wrote: > > > The built-in function round( ) will always "round up", that is 1.5 is > > rounded to 2.0 and 2.5 is rounded to 3.0. > > > If I want to round to the nearest even, that is > > > my_round(1.5) = 2 # As expected > > my_round(2.5) = 2 # Not 3, which is an odd num > > > I'm interested in rounding numbers of the form "x.5" depending upon > > whether x is odd or even. Any idea about how to implement it ? > > ------------------------------------------------ > def myround(x): > n = int(x) > if abs(x - n) == 0.5: > if n % 2: > #it's odd > return n + 1 - 2 * int(n<0) > else: > return n > else: > return round(x) > > ------------------------------------------------ In fact you can avoid the call to the builtin round: ------------------------------------------------ def myround(x): n = int(x) if abs(x - n) >= 0.5 and n % 2: return n + 1 - 2 * int(n<0) else: return n assert myround(3.2) == 3 assert myround(3.6) == 4 assert myround(3.5) == 4 assert myround(2.5) == 2 assert myround(-0.5) == 0.0 assert myround(-1.5) == -2.0 assert myround(-1.3) == -1.0 assert myround(-1.8) == -2 assert myround(-2.5) == -2.0 ------------------------------------------------ From schettino72 at gmail.com Mon Apr 21 12:09:53 2008 From: schettino72 at gmail.com (Eduardo Schettino) Date: Mon, 21 Apr 2008 21:39:53 +0530 Subject: Python "make" like tools (was Re: [ANN] DoIt 0.1.0 Released (build tool)) In-Reply-To: References: Message-ID: I guess I should post a link to the project in this thread... http://python-doit.sourceforge.net/ From donn at u.washington.edu Tue Apr 15 13:09:15 2008 From: donn at u.washington.edu (Donn Cave) Date: Tue, 15 Apr 2008 10:09:15 -0700 Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: In article <11567a1a-b184-42e6-bbf3-a655736c19c7 at p25g2000hsf.googlegroups.com>, Sverker Nilsson wrote: > No one forces me, but sooner or later they will want a Python 3.0 and > then a 3.1 whatever. > > I don't want that fuzz. As about the C versions, I am not that > worried. What's your point? > > I just like want to write a program that will stay working. And maybe > I can go on with something else hopefully than just compatibility > fixes. They take some work afterall. > > It seems hard with Python. Esp. 2 -> 3 Welcome to the world of Python. There was a period of relative stability in the '90s, culminating with version 1.5.2, which just happens to be about the time that people started taking Python seriously. It turns out that this stability was only due to lack of resources, though. I think most of us are working under two imperatives here that really boil down to the same thing: we want a programming language that lets us focus on the goal of the program. On one hand, that means things like automatic memory management that are brought to us by newer languages (i.e., less than 30 years old.) On the other hand it means stability that allows our deployed code to go on working without constant intervention, which usually we find in languages that have become utterly boring and out of fashion (i.e., more than 30 years old.) It's hard to find a good compromise between these two, in an interpreted language. I don't know what the current party line may be on this matter, but some years back it was that you should consider the interpreter part of your application. That is, each application should deploy with its own dedicated Python interpreter, complete with libraries and everything. This naturally relieves some of the maintenance issues, since at least you can upgrade on your own schedule, but of course it has its costs too. Anyone who might be thinking about using Python for an application should seriously think about this. Donn Cave, donn at u.washington.edu From ch612bunn at gmail.com Sun Apr 27 09:15:26 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:15:26 -0700 (PDT) Subject: norton antivirus 2008 crack Message-ID: <5b8c377e-02f2-4545-849f-a509fbda331b@a22g2000hsc.googlegroups.com> norton antivirus 2008 crack http://wga-cracks.crackkey.net From arnodel at googlemail.com Thu Apr 24 16:47:01 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 24 Apr 2008 21:47:01 +0100 Subject: Class Inheritance - What am I doing wrong? References: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> Message-ID: Arnaud Delobelle writes: > That is, if you also pass the name parameter to super(A,self).__init__ > in B's __init__ method Oops. should be super(B, self).__init__(name), of course. -- Arnaud From kothari.alok at gmail.com Tue Apr 1 15:42:50 2008 From: kothari.alok at gmail.com (Alok Kothari) Date: Tue, 1 Apr 2008 12:42:50 -0700 (PDT) Subject: XML Parsing Message-ID: Hello, I am new to XML parsing.Could you kindly tell me whats the problem with the following code: import xml.dom.minidom import xml.parsers.expat document = """LettermanisbetterthanJayLeno""" # 3 handler functions def start_element(name, attrs): print 'Start element:', name, attrs def end_element(name): print 'End element:', name def char_data(data): print 'Character data:', repr(data) p = xml.parsers.expat.ParserCreate() p.StartElementHandler = start_element p.EndElementHandler = end_element p.CharacterDataHandler = char_data p.Parse(document, 1) OUTPUT: Start element: token {u'pos': u'nn'} Character data: u'Letterman' End element: token Traceback (most recent call last): File "C:/Python25/Programs/eg.py", line 20, in p.Parse(document, 1) ExpatError: junk after document element: line 1, column 33 From gagsl-py2 at yahoo.com.ar Fri Apr 25 01:10:01 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 25 Apr 2008 02:10:01 -0300 Subject: Class Inheritance - What am I doing wrong? References: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> <613bc152-a6f4-4db4-8f90-593cb3f629c7@s33g2000pri.googlegroups.com> Message-ID: En Thu, 24 Apr 2008 18:18:01 -0300, Brian Munroe escribi?: > Ok, so thanks everyone for the helpful hints. That *was* a typo on my > part (should've been super(B...) not super(A..), but I digress) > > I'm building a public API. Along with the API I have a few custom > types that I'm expecting API users to extend, if they need too. If I > don't use name mangling, isn't that considered bad practice (read not > defensive programming) to not protect those 'private' fields? Please read this article: You don't have to define any getXXX/setXXX methods, just use a public attribute (if it is supposed to be public, of course). In case you have to do something special with it (like notifying some observers when the value changes, by example) use a property instead, and use a *single* leading underscore in the protected attribute name. In any case, the client code remains the same: some_object.attribute_name = value In Python, a single leading underscore means "this is an implementation detail, don't mess with it". This is a convention and we all -adult and responsible programmers- follow that convention. Double leading underscores are a means to avoid name conflicts with subclasses - don't use them unless you have a valid reason. Double leading and trailing underscores are __special__ names reserved by Python itself. -- Gabriel Genellina From martin at marcher.name Wed Apr 2 07:18:55 2008 From: martin at marcher.name (Martin Marcher) Date: Wed, 2 Apr 2008 13:18:55 +0200 Subject: plpythonu+postgrs anybody using it? Message-ID: <5fa6c12e0804020418y4152a084n601413b4fa0b4d5a@mail.gmail.com> Hello, I just started on working with a postgres project, the DB looks really bad and isn't normalized in any way... 4k Text messages representing a whole protocol which need to be transformed. Somehow it just doesn't seem right to put this stuff directly in the database and creating a bunch of stored procedures (SP) to parse them but I'm not the one to decide it... My main concern is that when things start getting more complicated that everytime a SP is called an instance of the interpreter ist started which would be a huge slowdown, so does plpythonu run continiously a python process or does it start one everytime a SP is called? -- http://tumblr.marcher.name https://twitter.com/MartinMarcher http://www.xing.com/profile/Martin_Marcher http://www.linkedin.com/in/martinmarcher You are not free to read this message, by doing so, you have violated my licence and are required to urinate publicly. Thank you. From fhaxbox66 at googlemail.com Wed Apr 2 14:21:38 2008 From: fhaxbox66 at googlemail.com (Dr. leo) Date: Wed, 2 Apr 2008 20:21:38 +0200 Subject: Hyphenation: PyHyphen-0.7 released Message-ID: <47f3cd11$0$582$6e1ede2f@read.cnntp.org> Hi, I have just uploaded the latest sources of PyHyphen (http://cheeseshop.python.org/pypi/PyHyphen). The tarball also contains Windows binaries of the C extension for Python 2.4 and 2.5. So most Windows users will get going without compiling. Just enter the usual 'python setup.py install'. There are many bug fixes both in the Python modules on top as well as in the C extension that uses a new release of the underlying hyphenation library (hyphen-2.3.1). Further, I have added a module 'dictools' for easy download and installation of dictionaries (see below). Finally, a script for easy testing of the hyphenation functionality with large wordlists and multiple dictionaries has been added. Dictionaries are installed on the fly and everything is logged. The default dir for dictionaries and the default repository to download dictionaries are configurable, so that one can use existing dictionaries, e.g., from an OpenOffice installation. The package also includes and installs the module 'textwrap2' which adds a hyphenation feature to the standard module textwrap. Code example: from hyphen import hyphenator from hyphen.dictools import * # Download and install some dictionaries in the default directory using the default # repository, usually the OpenOffice website for lang in ['de_DE', 'fr_FR', 'en_UK', 'hu_HU']: if not is_installed(lang): install(lang) # Create some hyphenators h_de = hyphenator('de_DE') h_en = hyphenator('en_US') h_hu = hyphenator('hu_HU') # Now hyphenate some words print h_hu.inserted(u'asszonnyal') 'asz=szony=nyal' print h_en.pairs('beautiful') [[u'beau', u'tiful'], [u'beauti', u'ful']] print h_en.wrap('beautiful', 6) [u'beau-', u'tiful'] print h_en.wrap('beautiful', 7) [u'beauti-', u'ful'] from textwrap2 import fill print fill('very long text...', width = 40, use_hyphens = h_en) My thanks go to those who helped enormously with advice, suggestions, criticism and Windows builds. Regards Leo From martin at marcher.name Tue Apr 8 16:32:22 2008 From: martin at marcher.name (Martin Marcher) Date: Tue, 8 Apr 2008 22:32:22 +0200 Subject: Best way to check if string is an integer? In-Reply-To: References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> <0fdd2825-6d1c-4380-a79a-a7aac119f002@a5g2000prg.googlegroups.com> <96d2fe53-96bf-43d8-a58d-8269846bf0df@b64g2000hsa.googlegroups.com> <2033313.fb3g3XYCIP@montana.com> Message-ID: <5fa6c12e0804081332r2a58d39gc44ce1ef8cb69052@mail.gmail.com> hmmm int() does miss some stuff: >>> 1E+1 10.0 >>> int("1E+1") Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: '1E+1' I wonder how you parse this? I honestly thought until right now int() would understand that and wanted to show that case as ease of use, I was wrong, so how do you actually cast this type of input to an integer? thanks martin -- http://tumblr.marcher.name https://twitter.com/MartinMarcher http://www.xing.com/profile/Martin_Marcher http://www.linkedin.com/in/martinmarcher You are not free to read this message, by doing so, you have violated my licence and are required to urinate publicly. Thank you. From Lie.1296 at gmail.com Sun Apr 27 06:52:12 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 27 Apr 2008 03:52:12 -0700 (PDT) Subject: DO YOU KNOW ANY THING ABOUT ISLAM??? References: <2429a87a-34e8-4294-9a25-b54dd2cf6791@m73g2000hsh.googlegroups.com> Message-ID: On Apr 24, 1:40 pm, ABDULLAH wrote: > What you are about to read might sound unusual but it could be very > enlightened. So I would be thankful if you give my article 5 minute > of > your value time. THANK YOU No, it is not unusual at all, it's very normal. The only thing that's unusual is that you misposted this in a programming language mailing list instead of religion list. From medin0065 at gmail.com Sun Apr 20 10:46:53 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:46:53 -0700 (PDT) Subject: divx keygen Message-ID: <99d2b9ee-a877-48d9-8fdc-3e043481887e@u36g2000prf.googlegroups.com> divx keygen http://cracks.00bp.com F R E E C R A C K S From gherron at islandtraining.com Thu Apr 17 11:30:29 2008 From: gherron at islandtraining.com (Gary Herron) Date: Thu, 17 Apr 2008 08:30:29 -0700 Subject: Can't do a multiline assignment! In-Reply-To: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> Message-ID: <48076D15.5050906@islandtraining.com> s0suk3 at gmail.com wrote: > I was shocked a while ago when a discovered that in Python you can't > do a multiline assignment > with comments between the lines. > > For example, let's say I want to assign a bunch of variables to an > initial, single value. In C or a similar language you would do: > > CONSTANT1 = > /* This is some constant */ > CONSTANT2 = > CONSTANT3 = > > /*This is yet some other constant */ > CONSTANT = > > 1; > Yuck! No way!! If you *want* to make your code that hard to read, I'm sure you can find lots of ways to do so, even in Python, but don't expect Python to change to help you toward such a dubious goal. Seriously, examine your motivations for wanting such a syntax. Does it make the code more readable? (Absolutely not.) Does it make it more maintainable. (Certainly not -- consider it you needed to change CONSTANT2 to a different value some time in the future.) Gary Herron > In Python, you usually can use parentheses to split something over > several lines. But you can't use parentheses for an assignment of > several lines. For that, you can use the line continuation character > ('\'): > > CONSTANT1 = \ > CONSTANT2 = \ > CONSTANT3 = \ > 1 > > But I realized that you can't do this: > > CONSTANT1 = \ > # Oops... syntax error > CONSTANT2 = \ > CONSTANT3 = \ # This is also a syntax error > # And this too \ > 1 > > Does anyone know of a way to put the comments between lines like that? > I find this limitation very annoying. > From hexusnexus at gmail.com Thu Apr 3 17:00:54 2008 From: hexusnexus at gmail.com (hexusnexus at gmail.com) Date: Thu, 3 Apr 2008 14:00:54 -0700 (PDT) Subject: Classes in modules References: <0cace2e1-6dbc-428f-9e53-ffb99ba42aab@e6g2000prf.googlegroups.com> Message-ID: Yeah, I was a little embarrassed putting my code up to be examined. Thanks for the reply. I typed up some classes, but I seemed to have run into some more problems. One of the classes keeps getting an error that it can't pop from an empty list. Here's the code so far: ################begin main.py#######look for more comments #!/usr/bin/python import random #structure for holding card data class Cards(object): RANK = ["ace","2","3","4","5","6","7","8","9","10","jack","queen","king"] SUIT = ["spades","clubs","hearts","diamonds"] def __init__(self,rank,suit): self.rank = rank self.suit = suit self.name = "%s of %s" % (Cards.RANK[self.rank], Cards.SUIT[self.suit]) #deck functions class Deck(object): def __init__(self): self.deck = [] for i in range(52): self.deck.append(Cards(i % 13, i / 13)) def shuffle(self): random.seed() random.shuffle(self.deck) def draw(self): #This is where my (first) problem arises, though there may be more return self.deck.pop() #IndexError: pop from empty list def size(self): return len(self.deck) #Note: if anyone can find more errors in my code thus far, feel free to criticize #it's been a while since I've practised any OOP #hand functions class Hand(object): def __init__(self): self.cards = [] def pull(self, pos=0): return self.cards.pop(pos) def size(self): return len(self.cards) def put(self,crd): self.cards.append(crd) def cards(self): return self.cards def orgcards(self): #organizes cards, 2's to aces, trumps last begin,end=0,0 for i in range(len(self.cards)-1): for j in range(len(self.cards)-1): if self.cards[j] > self.cards[j+1]: temp = self.cards[j+1] self.cards[j+1] = self.cards[j] self.cards[j] = temp for i in range(len(self.cards)): for j in range(len(self.cards)-1): if self.cards[j]%13==0 and self.cards[j]/ 13==self.cards[j+1]/13: temp=self.cards[j+1] self.cards[j+1]=self.cards[j] self.cards[j]=temp for i in range(len(self.cards)-1,-1,-1): if self.cards[i]/13==Stock.trump(): end=i break if end>0: end=0 for i in range(end,-1,-1): if self.cards[i]/13==Stock.trump(): begin=i break m=self.cards-1 for j in range(end,begin,-1): l=0 k=j while True: l=k+1 if l > m: break temp = self.cards[l] self.cards[l]=self.cards[k] self.cards[k]=temp k=l m-=1 if self.cards<13: for i in range(len(self.cards)-1): for j in range(len(self.cards)-1): if self.cards[j] == -1: temp=self.cards[j+1] self.cards[j+1]=self.cards[j] self.cards[j]=temp return self.cards class Stock(Hand): #the stock class, slightly modified from Hand def __init__(self): self.cards = [] self.y = -1 self.cards.extend(Deck.deck) def showtrump(self): if self.y < 0: self.y = self.cards[25] return self.y class Game(object): #the main game class def __init__(self): self.deck = Deck() self.deck.shuffle() self.player = Hand() self.computer = Hand() for i in range(self.deck.size()): self.player.put(self.deck.draw()) self.computer.put(self.deck.draw()) self.stock = Stock() print self.stock.showtrump() mygame = Game() ######################################################### If anyone can take a look at this and tell me where I went wrong, I'd really appreciate it. I'm using Python v2.5. On Apr 2, 8:41 pm, Dennis Lee Bieber wrote: > On Wed, 2 Apr 2008 18:05:38 -0700 (PDT), hexusne... at gmail.com declaimed > the following in comp.lang.python: > > > > I've been trying to make so that I have one class per file for easier > > Unlike Java, which practically mandates the class<=>file format, > Python is perfectly happy with multiple related classes in one file -- > and often /easier/ to read that way as one is not forced to jump around > finding dependent files to understand related classes. > > > > > This has been a recurring problem for me in languages such as C++ and > > Java. I'm used to programming in C. > > Please don't be offended, but looking at the specified file... it > shows... > > Ignoring the language in use, I'd suggest a few studies in software > design, functional decomposition, data structures, and algorithms... to > start... > > I lost count of how many times this > > > if rank==0: > > rankstr = "ace" > > elif rank==10: > > rankstr = "jack" > > elif rank==11: > > rankstr = "queen" > > elif rank==12: > > rankstr = "king" > > else: > > rankstr=str(rank+1) > > appears in the file, but a concept normally emphasized early in a > programming career is that when you have many identical (or near enough > that a minor tweak can serve for all) occurrences of the same code, it > should probably be turned into a function. > > However, this is even better served by usage of data structures... > > _RANKS = [ "ace", "two", "three", "four", "five", > "six", "seven", "eight", "nine", > "ten", "jack", "queen", "king" ] > > as a module-wide "constant", and then replace all those if/elif... > blocks with a simple: > > rankstr = _RANKS[rank] > > Worse though, your code seems to have used the class keyword just > for the "see, I used classes" factor, with no logical concept of object > orientation. Instead you are creating singleton instances that are being > referenced as global data across the classes... > > A simplistic approach for object orientation is to start with a text > description of the problem (in this case, a description of how the game > is played, perhaps). Find the key nouns in that description -- nouns > often (not always) turn into the classes. Find the verbs in the > description -- these are possible methods of the most closely related > noun. Find adjectives -- these may become attributes of the classes. > > Generic Card Game: > The GAME uses one DECK of 52 playing CARDs (standard arrangement: > _ranks_ of Ace, 2, ..., 10, Jack, Queen, King, in the _suits_ of Clubs, > Diamonds, Hearts, Spades). _n_ PLAYERs take turns... The DECK is > /shuffled/, then CARDs are /dealt/ to each PLAYER, each, in turn, > /drawing/ one card from the DECK until they have a HAND of m-CARDs. > > As a start (if you want multiple files)... > > -=-=-=-=-=- carddeck.py > import random > > class Card(object): > _RANKS = [ "ace", "two", "three", "four", "five", > "six", "seven", "eight", "nine", > "ten", "jack", "queen", "king" ] > _SUITS = [ "spades", "clubs", "hearts", "diamonds" ] > > def __init__(self, rank, suit): > self.rank = rank > self.suit = suit > self.name = "%s of %s" % (Card._RANKS[self.rank], > Card._SUITS[self.suit]) > > class Deck(object): > def __init__(self): > # cryptic initialization of 52 cards > # relies on Python 2.4 or earlier behavior > # read the documentation for 2.5 or later to determine changes > self._deck = [Card(i % 13, i / 13) for i in range(52)] > self._discards = [] > def shuffle(self): > self._deck.extend(self._discards) #combine > self._discards = [] > random.shuffle(self._deck) > def draw(self): > return self._deck.pop() #returns one card from deck > def discard(self, crd): > self._discards.append(crd) #puts card into discard pile > > -=-=-=-=-=- player.py > import carddeck #at this point, this may or may not be needed > > class Hand(object): > def __init__(self): > self._cards = [] > def pull(self, pos=0): > return self._cards.pop(pos) > def size(self): > return len(self._cards) > def put(self, crd): > self._cards.append(crd) > def cards(self): > return [ crd.name for crd in self._cards] > > class Player(object): > def __init__(self): > self._hand = Hand() > def pull(self, pos=0): > #I'm pulling a "law of demeter" here; player does not > #directly manipulate cards in the hand > return self._hand.pull(pos) > def size(self): > return self._hand.size() > def put(self, crd): > self._hand.put(crd) > def showHand(self): > for crd in self._hand.cards(): > print crd > > -=-=-=-=- game.py > import carddeck > import player > > class Game(object): > def __init__(self, numPlayers=2): > self._players = [player.Player() for i in range(numPlayers) > self._deck = carddeck.Deck() > self._deck.shuffle() > for i in range(7): #assume each player starts with 7 cards > for p in self._players: > p.put(self._deck.draw()) > > # rest left as an exercise for the student... > > -- > Wulfraed Dennis Lee Bieber KD6MOG > wlfr... at ix.netcom.com wulfr... at bestiaria.com > HTTP://wlfraed.home.netcom.com/ > (Bestiaria Support Staff: web-a... at bestiaria.com) > HTTP://www.bestiaria.com/ From rodperson at comcast.net Wed Apr 9 19:49:00 2008 From: rodperson at comcast.net (Rod Person) Date: Wed, 9 Apr 2008 19:49:00 -0400 Subject: Creating and Audio Equalizer with python and gstreamer Message-ID: <20080409194900.42a4c8b0@atomizer.opensourcebeef.net> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 For about 3 weeks I have been search for examples for grabbing and frequency from an audio stream and manipulating it. So far I haven't been too successful. Just wondering if anyone has done this or has a good example of doing such. TIA Rod -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (FreeBSD) iEYEARECAAYFAkf9VewACgkQWtF04X/kP32peQCfX/1LgmmREFB88bdY9uzVGxb4 n+sAoJngeg2VpGpwWmJ7cJLrNmsVI9uV =rCNp -----END PGP SIGNATURE----- From chumly96 at hotmail.com Wed Apr 23 09:59:32 2008 From: chumly96 at hotmail.com (chumly96 at hotmail.com) Date: Wed, 23 Apr 2008 13:59:32 GMT Subject: example python telnet/shell server Message-ID: <8hHPj.1560$PM5.274@edtnps92> Hi All, I have a program with a Dbus interface, and would like to allow remote users to use telnet ( or something ) to log in, and run predefined commands against the Dbus interface, return the results, and allow the user to log off. Any examples / help would be great. Thanks Chumly From steve at holdenweb.com Thu Apr 10 18:22:52 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 10 Apr 2008 18:22:52 -0400 Subject: Module Conflicts In-Reply-To: References: <1592fad3-996b-4f62-ac12-42aff8272c21@8g2000hsu.googlegroups.com> <845e315c-0159-4390-954a-dc93fd1b27a1@x41g2000hsb.googlegroups.com> Message-ID: Terry Reedy wrote: > "Jose" wrote in message > news:b7ed8b5e-91fa-4495-b4e3-4912be9e8d90 at s50g2000hsb.googlegroups.com... > | On Apr 9, 10:36 pm, Benjamin wrote: > | > On Apr 9, 5:33 pm, Jose wrote: > | > > | > > I have a module named math.py in a package with some class > | > > definitions. I am trying to import the standard python math module > | > > inside of math.py but It seems to be importing itself. Is there any > | > > way around this problem without renaming my math.py file? > | > > | > Not without some unpythonic magic. It's really not good style to name > | > a module the same as a stdlib one. It'll also confuse people reading > | > your code. > | > | Yeah but I thought since math.py was in a package, it would be okay. > > The stdlib contains a few packages, but it is not a package in itself. > So math is not in a package. > > > Indeed, the fact that there is a math.py indicates that it is a module: a package would have been math/__init__.py. For extra marks, what does the interpreter do with "import x" when there is both an x.py and an x/__init__.py in the same directry on the path? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From kyosohma at gmail.com Thu Apr 24 13:41:05 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Thu, 24 Apr 2008 10:41:05 -0700 (PDT) Subject: Loading associated files References: <74862697-da58-4eb7-8d60-09aaef54b7ad@j22g2000hsf.googlegroups.com> Message-ID: <07ac86a6-e125-40d9-bfe9-7c3286437bef@z72g2000hsb.googlegroups.com> On Apr 24, 10:14?am, flarefi... at googlemail.com wrote: > I am trying to make a a simple databasing GUI interface and and have > created a module to deal with parsing the data from a file and a GUI > based program that displays this data using PyQt4, i know how to > register files in the system registry using python and also using Inno > Setup which i use to package my applications, but i cant work out how > if a file is doubled clicked on to send the path of that file to > python. > > I have looked into passing command line arguments to python and can > send a specific pathname to python but ideally what i need is a > generic command that i can write to the registry that passes the > pathname of whichever file was doubled clicked!?! > > am i asking too much/does it exist/is there an easier way to do this!! > > CC I did this by writing the path to me script or exe and added %1 to the end, which basically means that my program can (or requires) a parameter passed to it. Here's an example: "C:\Program Files\PyMail\wxsendmail.exe" %1 That should work. Tested on Windows XP SP2 with Python 2.4/2.5. Mike From ch612bunn at gmail.com Sun Apr 27 09:12:47 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:12:47 -0700 (PDT) Subject: Kaspersky Anti-Virus 7.0.0.125 crack Message-ID: Kaspersky Anti-Virus 7.0.0.125 crack http://wga-cracks.crackkey.net From jens at aggergren.dk Tue Apr 29 09:16:57 2008 From: jens at aggergren.dk (Jens) Date: Tue, 29 Apr 2008 06:16:57 -0700 (PDT) Subject: Zope/DTML Infuriating... References: <3a955f90-ed80-46be-a238-1462e4fb2d0c@m3g2000hsc.googlegroups.com> Message-ID: <5493f048-db28-4f72-8265-99fd33c79f93@56g2000hsm.googlegroups.com> On Apr 29, 2:45?pm, Marco Mariani wrote: > Jens wrote: > >> You might have wrong assumptions from previous PHP experiences. > > >> ?>>> 'x'+4 > >> Traceback (most recent call last): > >> ? ?File "", line 1, in > >> TypeError: cannot concatenate 'str' and 'int' objects > > > ... and the non snobby answer would have been: > > > ... ? > > Sorry. Not trying to be snobbish, only in a hurry. > > That answer would have been less useful, because there are TONS of > details in the python tutorial, that set the language apart from its > "scripting cousins". > Reading the syntax and thinking "yeah, got it, boring, next chapter" is > a common mistake I've also made sometime, especially with python when > I've been deceived by its apparent simplicity. > Then, later, the same happened with Javascript, of course. > And it's bound to happen again, as much as I'll try to be careful :-( Hey no worriest. Is this the tutorial you're referring to: http://docs.python.org/lib/typesmapping.html Is there anything better? I miss the discussion and examples that accompany most entries in php.net. From steve at holdenweb.com Mon Apr 21 08:18:52 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 21 Apr 2008 08:18:52 -0400 Subject: PIL font encoding In-Reply-To: <480C5E36.7090505@shopzeus.com> References: <480C5E36.7090505@shopzeus.com> Message-ID: Laszlo Nagy wrote: > def getfnt(size): > return ImageFont.truetype("cartoon.ttf",size,encoding='unic') > > Using the above function, I cannot draw special german characters. E.g. > > u'L\xfctgendorf' > > > It will print "Lutgendorf" instead of "L?tgendorf". Much more > interesting is that I can also do this: > > def getfnt(size): > return > ImageFont.truetype("cartoon.ttf",size,encoding='put_somethin_here_it_has_no_effect > WHAT?????? ') > > Same results. Shouldn't the truetype constructor raise an exception if > the encoding is invalid and/or not available with the selected font? > > BTW my "cartoon.ttf" font is able to print "L?tgendorf". I have tested > it from GIMP. So I'm 100% sure that the problem is with PIL. > > Thank you, > > Laszlo > > You will be more likely to find assistance for this specific issue via the image-SIG mailing list, see http://mail.python.org/mailman/listinfo/image-sig regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From nagle at animats.com Wed Apr 9 11:53:00 2008 From: nagle at animats.com (John Nagle) Date: Wed, 09 Apr 2008 08:53:00 -0700 Subject: I am worried about Python 3 In-Reply-To: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> Message-ID: <47fce3ca$0$36346$742ec2ed@news.sonic.net> jmDesktop wrote: > If I continue in Python 2.5.x, am I making a mistake? Is it really > that different? No. It may never happen, either. The Perl crowd tried something like this, Perl 6, which was announced in 2000 and still hasn't come out. The C++ standards committee has been working on a revision of C++ since the 1990s, and that hasn't happened either. The general consensus is that Python 3.x isn't much of an improvement over the existing language. There's just not much demand for it. John Nagle From jcd at unc.edu Tue Apr 15 11:55:07 2008 From: jcd at unc.edu (J. Cliff Dyer) Date: Tue, 15 Apr 2008 11:55:07 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804150804l2d3832f0sd8f1d9405934063@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> <4dc0cfea0804140629rf1ac100m27ad9d0456cbbe2d@mail.gmail.com> <4803644A.8010204@holdenweb.com> <4dc0cfea0804150804l2d3832f0sd8f1d9405934063@mail.gmail.com> Message-ID: <1208274907.4718.2.camel@aalcdl07.lib.unc.edu> It is published. On comp.lang.python. Google groups has it, so google (search) will find it. Cheers, Cliff On Tue, 2008-04-15 at 17:04 +0200, Victor Subervi wrote: > Gabriel; > > That's really nice code you wrote. I will rewrite my app accordingly, > after I catch a breather! Say, would you please publish this > somewhere? Why should I write a howto on this and credit you when all > I would be doing is republishing (plagerizing) what you published? > Please insert these keywords: mysql, image, python, mysqldb and maybe > picture and photo (you already have photo). Call it something like > "MySQL/Python Tutorial for Posting and Retrieving Images / Photo > Album". I ask you to do this because I scoured google looking for just > what you've provided and it simply isn't out there. At all. There are > nice howto's in php. Please post this for those interested in python, > somewhere like the cookbook. > > Thanks, > > Victor > > > > On Tue, Apr 15, 2008 at 3:23 AM, Gabriel Genellina > wrote: > En Mon, 14 Apr 2008 11:03:54 -0300, Steve Holden > > escribi?: > > Victor Subervi wrote: > >> Thanks to all, especially Gabriel. [...] > >> Steve, thank you for all your help, but do overcome your > temper :)) > > > > > I'm glad the penny finally dropped. You may have been > treated to a > > modest display of exasperation, but please be assured you > have not yet > > seen anything remotely like temper from me :-) > > > And I'm glad to see that you finally "got it", too! > > -- > Gabriel Genellina > > -- > > http://mail.python.org/mailman/listinfo/python-list > > -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill From uniontelecardsindia at gmail.com Tue Apr 22 17:20:33 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:20:33 -0700 (PDT) Subject: Tattooed big hunks wrapped up in double penetrating gay cum finish. Message-ID: Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From wbsoft at xs4all.nl Sat Apr 12 17:22:42 2008 From: wbsoft at xs4all.nl (Wilbert Berendsen) Date: Sat, 12 Apr 2008 23:22:42 +0200 Subject: pty.spawn directs stderr to stdout In-Reply-To: <200804122142.00091.wbsoft@xs4all.nl> References: <200804122142.00091.wbsoft@xs4all.nl> Message-ID: <200804122322.42241.wbsoft@xs4all.nl> Op zaterdag 12 april 2008, schreef Wilbert Berendsen: > I'm currently trying to combine subprocess.Popen with pty.openpty ... which succeeded :-) http://code.google.com/p/lilykde/source/browse/trunk/runpty.py?r=314 it seems to work :-) thanks, Wilbert Berendsen -- http://www.wilbertberendsen.nl/ "You must be the change you wish to see in the world." -- Mahatma Gandhi From sjmachin at lexicon.net Thu Apr 3 18:43:32 2008 From: sjmachin at lexicon.net (John Machin) Date: Thu, 3 Apr 2008 15:43:32 -0700 (PDT) Subject: python bisect questions References: <6bb6927b-f553-40db-a142-2ce86b9e819f@q27g2000prf.googlegroups.com> Message-ID: <7d64aa50-9d67-45fe-9d57-ec32904ecb87@u36g2000prf.googlegroups.com> On Apr 4, 9:21 am, ankitks.mi... at gmail.com wrote: > On Apr 3, 4:24 pm, "Terry Reedy" wrote: > > > > > > > > > wrote in message > > >news:6bb6927b-f553-40db-a142-2ce86b9e819f at q27g2000prf.googlegroups.com... > > |I am week on functional programming, and having hard time > > | understanding this: > > | > > | class myPriorityQueue: > > | def __init__(self, f=lamda x:x): > > | self.A = [] > > | self.f = f > > | > > | def append(self, item) > > | bisect.insort(self.A, (self.f(item), item)) > > | ............ > > | > > | now I know we are inserting items(user defined type objects) in list A > > | base on sorting order provided by function A. > > | but what I don't understand is bisect command > > | what does bisect.insort(self.A, (self.f(item), item)) doing > > here is doc > insort_right(a, x[, lo[, hi]]) > > Insert item x in list a, and keep it sorted assuming a is sorted. > > If x is already in a, insert it to the right of the rightmost x. > > Optional args lo (default 0) and hi (default len(a)) bound the > slice of a to be searched. > > but I am still confuse. self.A is my list a. and item is x that > I am trying to insert. > So it needs to be of type item not (self.f(item), item) > It doesn't say anything pass sorting function self.f(item). That's correct. You are passing a tuple of (sort_key, actual_data). Example use case: caseless sortorder but you want to retrieve the original data. f is lambda x: x.upper() or similar. Your data is 'foo', 'Bar', 'zOt'. Calls to your_queue.append will result in the following 2nd args for bisect.insort: ('FOO', 'foo') ('BAR', 'Bar') ('ZOT', 'zOt') Consider executing the code with a couple of print statements in it so that you can see what is happening. From __peter__ at web.de Thu Apr 17 03:27:58 2008 From: __peter__ at web.de (Peter Otten) Date: Thu, 17 Apr 2008 09:27:58 +0200 Subject: regular expressions an text string References: <359c5f43-9520-4f33-b49e-45b5256f7169@a22g2000hsc.googlegroups.com> Message-ID: ragia wrote: > i have to match text string char by char to a regular expressions tht > just allow digits 0-9 if other thing a ppear it shall be replaced with > space.how can i do that any help? >>> import re >>> s = "abc123_45!6$" >>> re.sub(r"\D", " ", s) ' 123 45 6 ' Peter From aldo at nullcube.com Sat Apr 5 04:26:05 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Sat, 5 Apr 2008 19:26:05 +1100 Subject: ANN: pry unit testing framework In-Reply-To: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> Message-ID: <20080405082605.GA14042@nullcube.com> Thus spake Kay Schluehr (kay.schluehr at gmx.net): > But you could have added the integration of code coverage and other > helpful features with unittest as a conservative extension giving > everyone a chance to use it directly with existing tests instead of > forcing them to rewrite their tests for bike shading purposes. You're assuming that Pry's only purpose is to introduce test coverage. This is not the case - I already had a module that largely maintained unittest compatibility, but added a command-line interface and coverage analysis. It's now obsolete, but you can find its remains here if you're interested: http://dev.nullcube.com/gitweb/?p=pylid;a=shortlog So, why did I re-write it? Well, I needed a test framework that didn't have the deep flaws that unittest has. I needed good hierarchical fixture management. I needed something that didn't instantiate test suites automatically, freeing me to use inheritance more naturally within my test suites. I needed more sophisticated handling and reporting of errors during startup and teardown. I needed better support for programmatic generation of tests. The list goes on. Pry has all of this, and much of it is simply not possible while maintaining backwards compatibility. Yes, test coverage is critical and hugely neglected by most people, but Pry addresses other problems as well. We're not "forcing" anyone to rewrite anything, but if the description above sounds like something you want, maybe you should give Pry another look. If Pry itself is not to your taste, there are other excellent test frameworks like py.test that have also chosen not to mindlessly duplicate all of unittest's inadequacies. Broaden your horizons and explore some of these - your code will thank you for it... Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From rgacote at AppropriateSolutions.com Sat Apr 19 10:03:33 2008 From: rgacote at AppropriateSolutions.com (Ray Cote) Date: Sat, 19 Apr 2008 10:03:33 -0400 Subject: Python 2.5 adoption In-Reply-To: <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> References: <4808f30e$0$34489$742ec2ed@news.sonic.net> <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> Message-ID: At 12:16 PM -0700 4/18/08, Joseph Turian wrote: >Basically, we're planning on releasing it as open-source, and don't >want to alienate a large percentage of potential users. >-- >http://mail.python.org/mailman/listinfo/python-list A few seconds after reading this, I read the announcement for pyspread. Requirements? Python 2.5. You might want to talk with the pyspread folks regarding their decision to require 2.5. http://pyspread.sourceforge.net --Ray -- Raymond Cote Appropriate Solutions, Inc. PO Box 458 ~ Peterborough, NH 03458-0458 Phone: 603.924.6079 ~ Fax: 603.924.8668 rgacote(at)AppropriateSolutions.com www.AppropriateSolutions.com From gagsl-py2 at yahoo.com.ar Thu Apr 10 02:16:42 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 03:16:42 -0300 Subject: problem using import from PyRun_String References: <664bf2b80804081801u79ae9192h90c03c84c1ef35ce@mail.gmail.com> <664bf2b80804090931y78d9e34dof268784cc6a6cde9@mail.gmail.com> Message-ID: En Wed, 09 Apr 2008 13:31:22 -0300, Patrick Stinson escribi?: > Well, I eventually want to add an import hook, but for now I'd rather > just > get the import statement working normally again. > I have embedded python as a scripting engine in my application. To do > this, > I create a new empty module, run the script text using PyRun_String() > passing the module's __dict__ as locals and globals. This populates the > module's __dict__ with the resulting object references from the script > text. Instead of PyRun_String, use PyImport_ExecCodeModuleEx, which takes care of setting __builtins__ and other details. You will need to compile the source first (using Py_CompileStringFlags) which is a good thing anyway, to help catching errors. > As I said before I must be forgetting some other module init stuff > because I > had to manually populate the modules' __dict__ with references from the > __builtin__ module in order to get the basic stuff like abs, range, etc. That's not exactly what CPython does; if you inspect globals() you don't see abs, range, etc. Instead, there is a __builtins__ attribute (note the "s") that points to the __builtin__ module or its __dict__. > I understand what __builtin__ is used for, but the C struct pointing to > the > code frame that contains the import statement has a builtin member that > apparently does not contain the __import__ function, hence my question. > There must be some difference in the way code is parsed and a copy of the > __builtin__ module is passed normally and the way I am doing it. When a frame builtins != internal builtins, Python runs in "restricted execution mode", and disallows access to some objects and attributes, I think that __import__ is one of them. See http://docs.python.org/lib/module-rexec.html (That's why it's important to use the right way to create a module) > So, finding the place where this module bootstrapping normally happens > would > be awesome, because I sort of feel like I'm hacking this method running > into > problems like this. Exactly. The simplest way would be to save the source code on disk and just import it, letting Python do all the dirty work. But compiling+PyImport_ExecCodeModule should work, I presume - any feedback is welcome! -- Gabriel Genellina From cyril.giraudon at gmail.com Mon Apr 28 13:35:40 2008 From: cyril.giraudon at gmail.com (cyril giraudon) Date: Mon, 28 Apr 2008 10:35:40 -0700 (PDT) Subject: descriptor & docstring Message-ID: Hello, I try to use python descriptors to define attributes with default value (the code is reported below). But apparently, it breaks the docstring mechanism. help(Basis) shows the right help but help(Rectangle) shows only two lines : " Help on class Rectangle in module basis2: Rectangle = " If the Rectangle.length attribute is removed, the help is OK. Secondly, the __doc__ attribute of a PhysicalValue instance doesn't seem to be read. I don't understand. Any idea ? Thanks a lot Cyril. # A descriptor class with default value handling class PhysicalValue(object): """ A physical value descriptor """ def __init__(self, default_value): self.default_value = default_value self.__doc__ = "Hello from Physical Value" def __get__(self, obj, type=None): if obj.__dict__.has_key(self.key): return getattr(obj, self.key) else: return self.default_value def __set__(self, obj, value): if value is DefaultValue: setattr(obj, self.key, self.default_value) else: setattr(obj, self.key, value) # A meta class which adds instance attributes # If hasattr(cls, "attr") then add "_attr" attribute. class MyMetaClass(type): def __init__(cls, name, bases, dct): super(MyMetaClass, cls).__init__(name, bases, dct) print "Add property to ", name def init(self): pvl = [item for item in cls.__dict__.items() if isinstance(item[1], PhysicalValue)] for pv in pvl: print "Add _%s property to %s" % (pv[0], name) cls.__dict__[pv[0]].key = "_" + pv[0] setattr(self, "_" + pv[0], getattr(self, pv[0])) cls.__init__ = init # A basis class class Basis(object): """ Tempest basis class """ __metaclass__ = MyMetaClass # A concrete class class Rectangle(Basis): """ A beautiful Rectangle """ length = PhysicalValue(12.) From jason.scheirer at gmail.com Sat Apr 12 21:14:31 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Sat, 12 Apr 2008 18:14:31 -0700 (PDT) Subject: String Literal to Blob References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> Message-ID: <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> On Apr 12, 2:44 pm, Steve Holden wrote: > Victor Subervi wrote: > > in line... > > > On Fri, Apr 11, 2008 at 2:05 PM, Steve Holden > > wrote: > > > Victor Subervi wrote: > > > I have worked on this many hours a day for two weeks. If there is an > > > easier way to do it, just take a minute or two and point it out. Have > > > you heard of the Law of Diminishing Returns? I have passed it > > long ago. > > > I no longer want to waste time trying to guess at what you are > > trying to > > > tell me. > > > Victor > > > > On Fri, Apr 11, 2008 at 8:55 AM, Steve Holden > > > > > >> wrote: > > Where you have > > > content = col_fields[0][14].tostring() > > pic = "tmp" + str(i) + ".jpg" > > img = open(pic, "w") > > img.write(content) > > print '

' % pic > > img.close() > > > instead write > > > print content > > > Like this, I presume? > > Yes. You might need to use content.tostring() - I am not familiar with > MySQL blobs. > > > img = open(pic, "w") > > img.write(content) > > print ' > value="%s">' % pic > > print content > > # print '

\n' % pic > > Does not work _at_all LOL. You will recall, also, that you once gave me > > a line similar to the one commented out (but without writing then > > opening the file). THAT did not work, either. So now do you see why I am > > frustrated?? > > > Then browse to the URL this program serves and you will see the image > > (assuming you are still sending the image/jpeg content type). > > > Well, as I mentioned before, I am sending text/html because the page, > > like almost all web pages, has a whole lot more content than just > > images. Or, perhaps you are suggesting I build my pages in frames, and > > have a frame for every image. Unsightly! > > Dear Victor: > > If you cannot understand, after being told several times by different > people, that pages with images in them are achieved by multiple HTTP > requests, then there is little I can do to help you. > > > > > Once you > > can see the image, THEN you can write a page that refers to it. Until > > you start serving the image (NOT pseudo-html with image data embedded in > > it) nothing else will work. > > > My solution works just fine, thank you. It is inelegant. But it now > > appears to me, and I dare say rather clearly, that this inelegance is > > the fault of python itself. Perhaps this should be brought to Guido?s > > attention. > > Victor > > You can say it as clearly as you like, but if you say it too loudly you > will make a laughing stock of yourself. > > You surely don't think that a language that supports Zope, TurboGears, > Pylons and Django (to name but the first four that come to mind) is > unsuitable for web programming? > > Please, do yourself a big favor and persist with this until you > understand what you are doing wrong and how to serve dynamic images. It > appears that the learning may be painful, but I guarantee it will be > worthwhile. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ There _is_ a way to embed image data in HTML that is supported by every major browser. It is ugly. Using the RFC 2397 (http:// www.ietf.org/rfc/rfc2397) spec for data URLs you could go '' % base64.b64encode(image_data) Obviously you need to import the base64 module somewhere in your code and base64-encoded data is about a third larger than it would be otherwise, so embedding anything particularly large is going to be a huge pain and affect page load times pretty badly. From jeffrey at fro.man Tue Apr 8 16:41:06 2008 From: jeffrey at fro.man (Jeffrey Froman) Date: Tue, 08 Apr 2008 13:41:06 -0700 Subject: Coping with cyclic imports References: <87bq4knmax.fsf@physik.rwth-aachen.de> Message-ID: Torsten Bronger wrote: > I know that cyclic imports work in Python under certain > circumstances. ?Can anyone refer me to a page which explains when > this works? I don't know of a specific URL offhand. Cyclic imports are not a problem by themselves, but cyclic definitions are. Thus: # a.py import b x = 1 # b.py import a x = 2 works fine, but: # a.py import b x = 1 # b.py import a x = a.x + 1 # circular definition does not. Jeffrey From hank.infotec at gmail.com Sun Apr 20 14:14:43 2008 From: hank.infotec at gmail.com (Hank @ITGroup) Date: Mon, 21 Apr 2008 04:14:43 +1000 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <480B80B5.1050500@cheimes.de> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B80B5.1050500@cheimes.de> Message-ID: <480B8813.6010108@gmail.com> Christian Heimes wrote: > Gabriel Genellina schrieb: > >> Apart from what everyone has already said, consider that FreqDist may import other modules, store global state, create other objects... whatever. >> Pure python code should not have any memory leaks (if there are, it's a bug in the Python interpreter). Not-carefully-written C extensions may introduce memory problems. >> > > Pure Python code can cause memory leaks. No, that's not a bug in the > interpreter but the fault of the developer. For example code that messes > around with stack frames and exception object can cause nasty reference > leaks. > > Christian > > In order to deal with 400 thousands texts consisting of 80 million words, and huge sets of corpora , I have to be care about the memory things. I need to track every word's behavior, so there needs to be as many word-objects as words. I am really suffering from the memory problem, even 4G memory space can not survive... Only 10,000 texts can kill it in 2 minutes. By the way, my program has been optimized to ``del`` the objects after traversing, in order not to store the information in memory all the time. From pDOTpagel at helmholtz-muenchen.de Fri Apr 11 07:40:08 2008 From: pDOTpagel at helmholtz-muenchen.de (Philipp Pagel) Date: Fri, 11 Apr 2008 11:40:08 +0000 (UTC) Subject: Graphs in Python References: Message-ID: Sanhita Mallick wrote: > I have looked at that, and other similar ones all of > which are based on Graphviz. Networkx is not based on graphviz. > My problem is that I myself am creating some large graphs [...] > So I would like to use a graphical/visual method than typing out the > nodes. Not sure what exactly you mean. you will have to enter the nodes somehow - afterwards you can visualize them. Do you mean you would like to have a GUI for entering nodes and edges? I see two options: (1) write a GUI to do that (2) use an existing graph editor and use networkx or something like that for analysis. > Also, I am looking for a good tutorial for basic graph > implementation other than the one on python.org. - Look at the source code for networkx. - Alternatively, basic graph algorithms can be found in many general algorithm books. - More specific stuff e.g. in A. Gibbons "Algorithmic Graph Theory". cu Philipp -- Dr. Philipp Pagel Lehrstuhl f. Genomorientierte Bioinformatik Technische Universit?t M?nchen http://mips.gsf.de/staff/pagel From elgrandchignon at gmail.com Wed Apr 9 19:51:15 2008 From: elgrandchignon at gmail.com (Jason) Date: Wed, 9 Apr 2008 16:51:15 -0700 (PDT) Subject: Sorting a List of Objects by an Attribute of the Objects Case-Insensitively References: <736fefbd-510f-40e9-8342-32b69a1a0c2a@t12g2000prg.googlegroups.com> <0912a817-2cdc-4a19-83d2-1d8befed4f4b@24g2000hsh.googlegroups.com> Message-ID: <39693e9a-e46d-486d-8768-7b68360a5be9@t12g2000prg.googlegroups.com> Thanks so much everyone! That works great, & (presumably) is way faster than the way I was doing it-- From brian.e.munroe at gmail.com Wed Apr 2 15:27:20 2008 From: brian.e.munroe at gmail.com (Brian Munroe) Date: Wed, 2 Apr 2008 12:27:20 -0700 (PDT) Subject: class / module introspection? References: <3c3f09df-08cb-4309-a870-6b12a813a8af@u36g2000prf.googlegroups.com> <0f14a289-55ef-49e5-b650-60f7aca371ad@i36g2000prf.googlegroups.com> Message-ID: On Apr 2, 12:07 pm, Brian Munroe wrote: > > This gives me ['system1','system2'] - which I can then use __import__ > on. > Addendum, thanks Bruno! I also required the helper function (my_import) from the Python docs you pointed me to, that actually was the key to getting everything working! From danb_83 at yahoo.com Sun Apr 13 23:47:00 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Sun, 13 Apr 2008 20:47:00 -0700 (PDT) Subject: about the ';' References: Message-ID: <946aac57-868d-4355-af97-994c40dff287@b9g2000prh.googlegroups.com> On Apr 13, 10:33 pm, "Penny Y." wrote: > I saw many python programmers add a ';' at the end of each line. > As good style, should or should not we do coding with that? That's just because their fingers are stuck in C mode. The recommended style is NOT to use unnecessary semicolons. From steve at holdenweb.com Sat Apr 12 12:16:02 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 12:16:02 -0400 Subject: sqlite3 - adding tables and rows via parameters In-Reply-To: <9fdb569a0804120839w6916ed96ka5b53aad7ca6f565@mail.gmail.com> References: <9fdb569a0804120839w6916ed96ka5b53aad7ca6f565@mail.gmail.com> Message-ID: Vlastimil Brom wrote: > Hi all, > I would like to ask about the usage of sqlite3 in python, more > specifically about a way to pass table > or column names to a SQL commands using parameters. > All examples I could find use > the parameter substitution with "?" for values; is it possible the specify table and column names this way? > e.g. something like > curs.execute(u'INSERT OR REPLACE INTO %s(%s) VALUES (?)' % ("people", > "email"), ("qwe at asd.zx",)) > (And the similar cases e.g.: CREATE TABLE, ALTER TABLE ... ADD.) > Unfortunately, I wasn't successful in replacing the string interpolation > with the substitution notation; are there maybe any hints, how to do > that? Or is it ok to use string interpolation here? (Are these parts of > the SQL command vulnerable too?) > > What I am trying to achieve is to build a database dynamically - based > on the input data the respective > table would be chosen, and the appropriate columns created and filled with the content. > > Thanks in advance for any suggestions - and sorry if I missed something > obvious... > Vlasta > > The thing that will stop you from using a tablename as an argument to a parameterized query is that (the) front-ends (I am familiar with) don't allow table names to be parameterized ... The main points of parameterization are 1) To let the driver handle the creation of syntactically correct SQL (thereby avoiding , e.g. SQL injection attacks) and 2) To allow the driver to get the back-end to optimize the query by developing an execution plan into which the parameters can ve inserted at run time, avoiding repeated recompilation of the same query. It's this that stops most backends from allowing table names, since the optimizations depend upon the table's characteristics and contents. As far as ? vs %s goes, that depends on the particular module's paramstyle. For sqlite3: >>> import sqlite3 >>> sqlite3.paramstyle 'qmark' >>> so you just have to go with what it implements. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From python at bdurham.com Mon Apr 28 22:10:27 2008 From: python at bdurham.com (python at bdurham.com) Date: Mon, 28 Apr 2008 22:10:27 -0400 Subject: How to unget a line when reading from a file/stream iterator/generator? In-Reply-To: References: Message-ID: <1209435027.21177.1250388813@webmail.messagingengine.com> George, > Is there an elegant way to unget a line when reading from a file/stream iterator/generator? http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502304 That's exactly what I was looking for! For those following this thread, the above recipe creates a generic object that wraps any iterator with an 'unget' ("push") capability. Clean and elegant! Thank you, Malcolm From sjmachin at lexicon.net Thu Apr 17 19:59:20 2008 From: sjmachin at lexicon.net (John Machin) Date: Thu, 17 Apr 2008 23:59:20 GMT Subject: get quote enclosed field in a line In-Reply-To: <4807dc10$0$25223$e4fe514c@dreader18.news.xs4all.nl> References: <4807dc10$0$25223$e4fe514c@dreader18.news.xs4all.nl> Message-ID: <4807e457$1@news.mel.dft.com.au> Martin P. Hellwig wrote: > > Something like: > # cut -d '"' -f 6 < httpd-access.log In Python: line.split('"')[5] From james at reggieband.com Mon Apr 28 15:46:50 2008 From: james at reggieband.com (james at reggieband.com) Date: Mon, 28 Apr 2008 12:46:50 -0700 (PDT) Subject: Installed python 2.5 over 2.4 and lost installed packages References: <6c77d0e5-f387-449d-9147-d7aefa3d2735@l64g2000hse.googlegroups.com> <361ca6be-9764-4cff-bd2e-b5f992d5feb7@8g2000hse.googlegroups.com> Message-ID: On Apr 27, 8:42 pm, Mike Driscoll wrote: > On Apr 27, 8:15 am, ja... at reggieband.com wrote: > > I recently updated os x from python 2.4 to 2.5 (from python.org) and > > in doing so I lost my old python path entries. > > So what is the right thing to do in this situation? > > Is cp'ing the files from one place to another safe or advisable? > As long as the Python extensions or packages are pure ones, then > copying them over shouldn't hurt anything. If you have some that have > C/C++ links (such as PIL or pywin32), then you'll need to reinstall > those manually. I tried that and the C extensions burned me. Syck (for YAML) and mercurial (I think ... there were at least 2 problems) posted warnings or bailed out with errors. Looks like I will delay until I have the time and energy to chase all my dependencies. Perhaps once my server (Ubuntu) moves to 2.6 I'll update my Mac at the same time. >From now on I am storing my install packages somewhere accessible instead of deleting them once I'm done with them. I wish I could generate a manifest of installed packages to make upgrading easier. Cheers, James. From nejtak... Thu Apr 3 14:33:35 2008 From: nejtak... (Troels Thomsen) Date: Thu, 3 Apr 2008 20:33:35 +0200 Subject: Python for low-level Windows programming In-Reply-To: References: Message-ID: <47f52303$0$2092$edfadb0f@dtext02.news.tele.dk> >> >> Is this possible without too much pain? I know I can code it with C# >> or C++ but tha'ts a road to avoid, if possible. > > Well of course I don't know exactly what you'd need, but the > answer's certainly Yes :) Need I mention that it is also easy to write a windows service, using pyservice (i think ...) and ? a page of python source tpt From jens at aggergren.dk Tue Apr 29 07:56:19 2008 From: jens at aggergren.dk (Jens) Date: Tue, 29 Apr 2008 04:56:19 -0700 (PDT) Subject: Zope/DTML Infuriating... Message-ID: Hello Everyone. I am relatively new to Zope(using it for a work project) and I was wondering if someone here could help me out or at least refer me to a decent documentationg for Zope/DTML/Python (at the detail level of php.net or Java API reference). http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/ isn't really detailed enough for my taste. if it doesn't contain a exhautive description of all available base classes it's simply no good as a reference resource. Anyway I have the following problem. I'm using zope 2.9 and I would expect the following dtml code to yield a list containing main1, main2 etc.

But it doesn't work(and yes i know that i could simply do "... ...", but that's not what i need). I've the checked that i'm referring to the variables correctly, so the only explanation i can come up with, is that '+' doesn't result in a string concatenation (with implicit typecast to string of the integer variable(this is a interpreted language after all)). It apparently works in other cases but for some reason not here. I get the following cryptical error message which makes me none the wiser. An error was encountered while publishing this resource. Error Type: AttributeError Error Value: 'NoneType' object has no attribute 'group' I would appreciate any feedback you might have regarding this. Thanks in Advance. From arnodel at googlemail.com Thu Apr 17 13:36:41 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 17 Apr 2008 10:36:41 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <1952579a-3cfb-44ea-92aa-658daa64aee4@a70g2000hsh.googlegroups.com> <564dd82b-8670-4ead-a3c8-a22b30a3eb73@m73g2000hsh.googlegroups.com> Message-ID: <2fbafb11-1a99-4007-949e-8a7acd790bf3@a23g2000hsc.googlegroups.com> On Apr 17, 6:02?pm, s0s... at gmail.com wrote: [...] > I do it with all the separate variables mainly for performance. If I > had the headers in a dict, I'd be looking up a string in a list of > strings (the keys of the dict) everytime I check for a header. Not > that that's going to take more that 0.1 seconds, but the program is > still small and simple. As it gets bigger, more features are gonna > slow things down. - Have you measured the difference in performance? - Are you aware that attribute access is implemented as string lookup in a dictionary? i.e. when you write foo.bar, the interpreter looks for 'bar' in foo.__dict__, and if it doesn't find it, then proceeds to look in type(foo).__dict__. So in your code, if a header (with manager rhm) has no 'allow' field and you do: rhm.Allow the interpreter looks up *two* dictionaries (rhm.__dict__ then RequestHeadersManager.__dict__). -- Arnaud -- Arnaud From n00m at narod.ru Wed Apr 30 03:54:56 2008 From: n00m at narod.ru (n00m) Date: Wed, 30 Apr 2008 00:54:56 -0700 (PDT) Subject: Problem with variables assigned to variables??? References: Message-ID: for listmember in mylist: print listmember + ".shp", eval(listmember) From michael.pearmain at tangozebra.com Thu Apr 3 11:26:17 2008 From: michael.pearmain at tangozebra.com (Mike P) Date: Thu, 3 Apr 2008 08:26:17 -0700 (PDT) Subject: MLE in Python for distributions Message-ID: Hi All, Can anyone point me towards some code for Maximum Likilehood for distribution in python? Thanks Mike From sierra9162 at gmail.com Wed Apr 16 11:26:34 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:26:34 -0700 (PDT) Subject: kate hudson pussy Message-ID: <61646556-8508-4bf7-9d85-785b57cc97bb@x41g2000hsb.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From samslists at gmail.com Sun Apr 6 16:45:16 2008 From: samslists at gmail.com (samslists at gmail.com) Date: Sun, 6 Apr 2008 13:45:16 -0700 (PDT) Subject: Implementation of Crockford's Base32 Encoding? References: <345117e9-2539-4ee0-8b27-9b1a88ddde7c@a1g2000hsb.googlegroups.com> <3EF041EA-8E9A-4DAA-B690-FC725D9E25D6@gmail.com> <9d34f801-29cc-4c19-80d2-2ebdcc41d0bc@8g2000hse.googlegroups.com> Message-ID: <7e4eac36-be02-4238-aaa9-a54ca838c7e9@c65g2000hsa.googlegroups.com> Sorry to reply to myself. By reading the whole document I see he does give a few different ways one can hadle the lack of padding (including adding it back in.) Both the specs. seem to fudge a bit on this...I'll have to think more about it. On Apr 6, 5:40 pm, "samsli... at gmail.com" wrote: > Gabriel... > > I looked at Zooko's encoding. I didn't really like that the first 16 > characters weren't the same as for base 16, [0-9a-f]. > > I hadn't considered the need for padding. Zooko doesn't seem to use > it either. How does he get around it? > > Thanks > > p.s. Paul...yes it is different. :) > > On Apr 6, 7:15 am, "Gabriel Genellina" wrote: > > > En Sun, 06 Apr 2008 06:07:18 -0300, Petite Abeille > > escribi?: > > > > On Apr 6, 2008, at 9:20 AM, samsli... at gmail.com wrote: > > > >> Anyone know of aPythonimplementation of this: > > >>http://www.crockford.com/wrmg/base32.html > > > > Not sure aboutCrockford'sBase32encoding itself, but here is an > > > implementation of Bryce "Zooko" Wilcox-O'Hearn's "human-oriented > > > base-32 encoding": > > > >https://zooko.com/repos/z-base-32/base32/ > > >https://zooko.com/repos/z-base-32/base32/DESIGN > > > The design and rationale looks better. TheCrockfordversion is > > ill-defined in the sense that you can't recover the exact input string > > length in some cases; by example both "\x00"*4 and "\x00"*5 share the same > > encoding. > > base-64 encoding, by example, uses '=' as pad bytes at the end to avoid > > this problem. > > > -- > > Gabriel Genellina From bj_666 at gmx.net Wed Apr 16 09:44:32 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 16 Apr 2008 13:44:32 GMT Subject: vary number of loops References: Message-ID: <66me60F2lroubU1@mid.uni-berlin.de> On Wed, 16 Apr 2008 06:31:04 -0700, nullgraph wrote: > I'm new to Python and the notion of lambda, and I'm trying to write a > function that would have a varying number of nested for loops > depending on parameter n. This just smells like a job for lambda for > me, but I can't figure out how to do it. Any hint? That has nothing to do with ``lambda``. If you don't think "Hey, that's smells like a job for a function." then it's no job for ``lambda``, which is just a way to define a function without automatically binding it to a name like ``def`` does. One solution to your problem is recursion. Untested: def foo(xs): if xs: for elt in xs[0]: for ys in foo(xs[1:]): yield [elt] + ys else: yield [] Called as ``foo([A, B])``. Ciao, Marc 'BlackJack' Rintsch From carbanancizpo at gmail.com Fri Apr 18 16:53:24 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:53:24 -0700 (PDT) Subject: moyea flv to video converter keygen Message-ID: <2d4f244c-61e1-4ee6-8b6a-0a0c1b5c08ff@1g2000prf.googlegroups.com> moyea flv to video converter keygen http://cracks.12w.net F R E E C R A C K S From bwljgbwn at gmail.com Tue Apr 22 05:50:15 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:50:15 -0700 (PDT) Subject: nero 7 ultra edition crack Message-ID: <0c6b2d96-bf2d-473b-805b-e641ed08b7ea@q24g2000prf.googlegroups.com> nero 7 ultra edition crack http://cracks.12w.net F R E E C R A C K S From kf9150 at gmail.com Tue Apr 1 15:16:08 2008 From: kf9150 at gmail.com (Kelie) Date: Tue, 1 Apr 2008 12:16:08 -0700 (PDT) Subject: PyQt - Question on QListWidget's selectedItems Method Message-ID: <68632dc8-0426-4c6a-a2d8-04fd49381452@d21g2000prf.googlegroups.com> Hello, This method returns selected items by the order of user's picking, instead of the original order of these items. For example, if a ListWidget stores a list of ['A', 'B', 'C', 'D'] and when user is prompted to make a selection, if he picks 'D' first, then 'B', the returned ListWidget items would be 'D' first, then 'B', instead of 'B' first, then 'D'. This seems unusual to me. Would users normally care about the order of these items being picked? This selectedItems method does not seem to have an optional argument that allows returned items to be in their original order when added to the ListWidget. What did I miss? Thank you! From hotani at gmail.com Tue Apr 22 21:41:30 2008 From: hotani at gmail.com (hotani) Date: Tue, 22 Apr 2008 18:41:30 -0700 (PDT) Subject: python-ldap: searching without specifying an OU? References: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> Message-ID: <58546d42-bc80-4f9d-be90-e184c312e2d1@k37g2000hsf.googlegroups.com> Thanks for the response. The user I'm connecting as should have full access but I'll double check tomorrow. This is the LDAP error that is returned when I leave out the OU: {'info': '00000000: LdapErr: DSID-0C090627, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, vece', 'desc': 'Operations error'} From meisnernel73884 at gmail.com Wed Apr 30 06:36:00 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:36:00 -0700 (PDT) Subject: call of duty modern warfare keygen Message-ID: call of duty modern warfare keygen http://crack.cracksofts.com From bob at passcal.nmt.edu Fri Apr 18 18:41:34 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Fri, 18 Apr 2008 16:41:34 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> Message-ID: <2008041816413450073-bob@passcalnmtedu> On 2008-04-18 16:04:37 -0600, George Sakkis said: > On Apr 18, 5:26?pm, Bob Greschke wrote: > >> On 2008-04-18 14:37:21 -0600, Ross Ridge >> said: >> >> >> >>> Bob Greschke ? wrote: >>>> I'm reading 3-byte numbers from a file and they are signed (+8 to >>>> -8million). ?This seems to work, but I'm not sure it's right. >> >>>> # Convert the 3-characters into a number. >>>> Value1, Value2, Value3 = unpack(">BBB", Buffer[s:s+3]) >>>> Value = (Value1*65536)+(Value2*256)+Value3 >>>> if Value >= 0x800000: >>>> Value -= 0x1000000 >>>> print Value >> >>>> For example: >>>> 16682720 = -94496 >> >>>> Should it be Value -= 0x1000001 so that I get -94497, instead? >> >>> Your first case is correct, "Value -= 0x1000000". ?The value 0xFFFFF > FF >>> should be -1 and 0xFFFFFFF - 0x1000000 == -1. >> >>> An alternative way of doing this: >> >>> ? ?Value = unpack(">l", Buffer[s:s+3] + "\0")[0] >> 8 >> >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?R > oss Ridge >> >> Good to know (never was good on the math front). >> >> However, in playing around with your suggestion and Grant's code I've >> found that the struct stuff is WAY slower than doing something like this >> >> ?Value = (ord(Buf[s])*65536)+(ord(Buf[s+1])*256)+ord(Buf[s+2]) >> ?if Value >= 0x800000: >> ? ? ?Value -= 0x1000000 >> >> This is almost twice as fast just sitting here grinding through a few >> hundred thousand conversions (like 3sec vs. ~5secs just counting on my >> fingers - on an old Sun...it's a bit slow). ? > > You'd better use a more precise timing method than finger counting, > such as timeit. Twice as fast is probably a gross overestimation; on > my box (Python 2.5, WinXP) avoiding unpack is around 10% and 40% > faster from Ross's and Grant's method, respectively: > > python -m timeit "for i in xrange(1000):from3Bytes_bob(s)" \ > -s "from bin import *; s=pack('>i',1234567)[1:]" > 1000 loops, best of 3: 1.02 msec per loop > > python -m timeit "for i in xrange(1000):from3Bytes_grant(s)" \ > -s "from bin import *; s=pack('>i',1234567)[1:]" > 1000 loops, best of 3: 1.43 msec per loop > > python -m timeit "for i in xrange(1000):from3Bytes_ross(s)" \ > -s "from bin import *; s=pack('>i',1234567)[1:]" > 1000 loops, best of 3: 1.12 msec per loop > > ### bin.py ########################################## > > from struct import unpack > > def from3Bytes_bob(s): > Value = (ord(s[0])<<16) + (ord(s[1])<<8) + ord(s[2]) > if Value >= 0x800000: > Value -= 0x1000000 > return Value > > def from3Bytes_grant(s): > if ord(s[0]) & 0x80: > s = '\xff'+s > else: > s = '\x00'+s > return unpack('>i',s)[0] > > def from3Bytes_ross(s): > return unpack(">l", s + "\0")[0] >> 8 > > >> Replacing *65536 with <<16 >> and *256 with <<8 might even be a little faster, but it's too close to >> call without really profiling it. > >> I wasn't planning on making this discovery today! :) >> >> Bob > > If you are running this on a 32-bit architecture, get Psyco [1] and > add at the top of your module: > import psyco; psyco.full() > > Using Psyco in this scenatio is up to 70% faster: > > python -m timeit "for i in xrange(1000):from3Bytes_bob(s)" \ > -s "from bin import *; s=pack('>i',1234567)[1:]" > 1000 loops, best of 3: 624 usec per loop > > python -m timeit "for i in xrange(1000):from3Bytes_grant(s)" \ > -s "from bin import *; s=pack('>i',1234567)[1:]" > 1000 loops, best of 3: 838 usec per loop > > python -m timeit "for i in xrange(1000):from3Bytes_ross(s)" \ > -s "from bin import *; s=pack('>i',1234567)[1:]" > 1000 loops, best of 3: 834 usec per loop > > > George > > [1] http://psyco.sourceforge.net/ I'm on a Solaris 8 with Python 2.3.4 and when crunching through, literally, millions and millions of samples of seismic data fingers point out the difference nicely. :) I'll look into this more on some of our bigger better faster machines (there is no -m option for timeit on the Sun :). The Sun is just what I develop on. If stuff runs fast enough to keep me awake on there over an ssh'ed X11 connection it should run even better on the real field equipment (Macs, Linuxes, WinXPs). Never heard of Psyco. That's nice! Thanks! Bob From tracyde at gmail.com Thu Apr 3 14:36:02 2008 From: tracyde at gmail.com (Derek Tracy) Date: Thu, 3 Apr 2008 14:36:02 -0400 Subject: Manipulate Large Binary Files In-Reply-To: <7xlk3vctea.fsf@ruckus.brouhaha.com> References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> <9999810b0804021109n77f2c990p7b10d92e9344ad00@mail.gmail.com> <7xlk3vctea.fsf@ruckus.brouhaha.com> Message-ID: <9EBD1A97-98C5-44E6-8472-A7AAADC0A3CA@gmail.com> On Apr 3, 2008, at 3:03 AM, Paul Rubin <"http:// phr.cx"@NOSPAM.invalid> wrote: > Derek Martin writes: >>> Both are clocking in at the same time (1m 5sec for 2.6Gb), are there >>> any ways I can optimize either solution? > > Getting 40+ MB/sec through a file system is pretty impressive. > Sounds like a RAID? > >> That said, due to normal I/O generally involving double-buffering, >> you >> might be able to speed things up noticably by using Memory-Mapped I/O >> (MMIO). It depends on whether or not the implementation of the >> Python >> things you're using already use MMIO under the hood, and whether or >> not MMIO happens to be broken in your OS. :) > > Python has the mmap module and I use it sometimes, but it's not > necessarily the right thing for something like this. Each page you > try to read from results in own delay while the resulting page fault > is serviced, so any overlapped i/o you get comes from the OS being > nice enough to do some predictive readahead for you on sequential > access if it does that. By coincidence there are a couple other > threads mentioning AIO which is a somewhat more powerful mechanism. > > -- > http://mail.python.org/mailman/listinfo/python-list I am running it on a RAID(stiped raid 5 using fibre channel), but I was expecting better performance. I will have to check into AIO, thanks for the bone. From triplezone3 at yahoo.co.uk Sat Apr 19 14:19:45 2008 From: triplezone3 at yahoo.co.uk (triplezone3) Date: Sat, 19 Apr 2008 19:19:45 +0100 (BST) Subject: urlretrieve can't send headers In-Reply-To: <66ulg4F2lidl3U1@mid.uni-berlin.de> Message-ID: <932266.62563.qm@web26908.mail.ukl.yahoo.com> I have looked in to urllib2, and I can't find a function which would allow me to get the progress of the download as it happens, bit by bit, like urlretrieve does, at least not easily. urllib.urlretrieve's returnhook is just handy. I have another question concerning urlretrieve, is there a way I can force it to stop downloading half-way, say after the user clicked cancel? Thanks in advance. --- "Diez B. Roggisch" wrote: > triplezone3 schrieb: > > Hello. I'm using urllib.urlretrieve to download > files, > > because it provides a handy hook function. > > Unfortunately, it won't let me send headers, which > > could be quite useful. Is there any way I could do > > this? > > I suggest you look into urllib2. It allows you to > explicitly create an > request-object that you can stuff with headers and > parameters and what > you like. > > diez > -- > http://mail.python.org/mailman/listinfo/python-list > ___________________________________________________________ Yahoo! For Good helps you make a difference http://uk.promotions.yahoo.com/forgood/ From kyosohma at gmail.com Wed Apr 16 13:50:09 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 16 Apr 2008 10:50:09 -0700 (PDT) Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: On Apr 16, 11:06 am, Steve Holden wrote: > Mike Driscoll wrote: > > On Apr 16, 10:09 am, Steve Holden wrote: > >> Mike Driscoll wrote: > >>> On Apr 16, 9:19 am, Grant Edwards wrote: > >>>> This morning almost half of c.l.p was spam. In order to try to > >>>> not tar both the benign google group users and the malignant > >>>> ones with the same brush, I've been trying to kill usenet spam > >>>> with subject patterns. But that's not a battle you can win, so > >>>> I broke down and joined all the other people that just killfile > >>>> everything posted via google.groups. > >>>> AFAICT, if you're a google groups user your posts are not being > >>>> seen by many/most experienced (read "non-google-group") users. > >>>> This is mainly the fault of google who has refused to do > >>>> anything to stem the flood of span that's being sent via Google > >>>> Groups. > >>>> -- > >>>> Grant Edwards grante Yow! I would like to > >>>> at urinate in an OVULAR, > >>>> visi.com porcelain pool -- > >>> Yeah, I noticed that Google Groups has really sucked this week. I'm > >>> using the Google Groups Killfile for Greasemonkey now and it helps a > >>> lot. I like Google, but my loyalty only goes to far. This is a > >>> complete lack of customer service. > >> Unfortunately this means Google groups users are getting exactly the > >> service they are paying for. > > >> regards > >> Steve > >> -- > >> Steve Holden +1 571 484 6266 +1 800 494 3119 > >> Holden Web LLC http://www.holdenweb.com/ > > > Steve, > > > My workplace doesn't offer NNTP, so there is no good way to browse > > c.l.py here. And I haven't been able to get NNTP to work from my home > > either. > > > By applying this logic to Python and Linux (or any Open Source > > product), they shouldn't be used either (since I'm not paying for > > them). > > I'm not saying people shouldn't use Google Groups. I'm saying that > Google can "justify" providing customer "support" that lives somewhere > between zero and extremely crappy by not charging for the service. > > Without tunneling out to an NNTP proxy I don't see what other choice you > have. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ OK. The way it was written + the mood I was in made me misinterpret your meaning. I apologize. Mike From rkmr.em at gmail.com Tue Apr 15 23:25:56 2008 From: rkmr.em at gmail.com (rkmr.em at gmail.com) Date: Tue, 15 Apr 2008 20:25:56 -0700 Subject: python memory leak only in x86 64 linux Message-ID: the memory usage of a python app keeps growing in a x86 64 linux continuously, whereas in 32 bit linux this is not the case. Python version in both 32 bit and 64 bit linux - 2.6.24.4-64.fc8 Python 2.5.1 (r251:54863, Oct 30 2007, 13:45:26) i isolated the memory leak problem to a function that uses datetime module extensively. i use datetime.datetime.strptime, datetime.timedelta, datetime.datetime.now methods... i tried to get some info with guppy and the code goes like this while True: print heapy.heap().get_rp() print heapy.setref() users = globalstuff.q.get() for u in users: doalert(u) and it gives the following output for the 64bit linux below.. I am not able to decode this output or figure out why this leak is happening only in 64 bit linux and not in 32 bit. can anyone tell how to fix this problem? thanks a lot! Reference Pattern by <[dict of] class>. 0: _ --- [-] 82005 (Cheetah.Filters.DummyTemplate | Nouvelle.Serial.place | ... 1: a [-] 19901 tuple: 0x6674c0*27, 0x66b2b0*26, 0x67f270*36... 2: aa ---- [S] 5516 types.CodeType: xmlreader.py:375:_test... 3: ab [S] 454 type: warnings._OptionError, zipimport.ZipImportError... 4: ac ---- [-] 1133 function: bitbucket_s3.s3amazon.S3.__init__... 5: aca [S] 110 dict of module: copy_reg, os, site, warnings..., web 6: acb ---- [S] 233 dict of class: ..Codec, ..UserDict, .._Environ... 7: acc [S] 87 dict of type: ..IncrementalEncoder..., ..Quitter, .._Printer 8: acd ---- [-] 9 dict of email.LazyImporter: 0x93dc90, 0x93dcd0..., 0x93de50 9: acda [-] 9 email.LazyImporter: 0x93dc90, 0x93dcd0, 0x93dd90... None Reference Pattern by <[dict of] class>. 0: _ --- [-] 3862 (DBUtils.PooledDB.PooledDB | DBUtils.PooledDB.PooledDedica... 1: a [-] 51 web.utils.Storage: 0xd11e70, 0xd120c0, 0xd12350, 0xd18d20... 2: aa ---- [-] 1 list: 0xdbdd88*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 465 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 50 web.utils.Storage: 0xdea5d0, 0xdef260, 0xe503d0, 0xe73f10... 2: aa ---- [-] 1 list: 0xda1200*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: b [-] 2 list: 0x2aaaaaada710*2, 0xda1200*50 6: ba ---- [S] 1 dict of module: gc 7: bb [^ 3] 1 types.FrameType: 8: c ---- [^ 3] 1 types.FrameType: 9: d [-] 1 types.GeneratorType: 0x1519ab8 None Reference Pattern by <[dict of] class>. 0: _ --- [-] 467 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 50 web.utils.Storage: 0xbf83a0, 0xbf84d0, 0xd19810, 0xe03bc0... 2: aa ---- [-] 1 list: 0xf99440*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: b [-] 2 list: 0x2aaaaaada710*3, 0xf99440*50 6: ba ---- [S] 1 dict of module: gc 7: bb [^ 3] 1 types.FrameType: 8: c ---- [^ 3] 1 types.FrameType: 9: d [-] 1 types.GeneratorType: 0x10a75a8 None Reference Pattern by <[dict of] class>. 0: _ --- [-] 466 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 50 web.utils.Storage: 0xbf8600, 0xde7720, 0xe02c80, 0xfbd1c0... 2: aa ---- [-] 1 list: 0x1ebac20*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: b [-] 2 list: 0x1ebac20*50, 0x2aaaaaada710*4 6: ba ---- [S] 1 dict of module: gc 7: bb [^ 3] 1 types.FrameType: 8: c ---- [^ 3] 1 types.FrameType: 9: d [-] 1 types.GeneratorType: 0x1eba7e8 None Reference Pattern by <[dict of] class>. 0: _ --- [-] 466 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 50 web.utils.Storage: 0xd21060, 0xd21190, 0xd22480, 0xe48190... 2: aa ---- [-] 1 list: 0x238e560*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: b [-] 2 list: 0x238e560*50, 0x2aaaaaada710*5 6: ba ---- [S] 1 dict of module: gc 7: bb [^ 3] 1 types.FrameType: 8: c ---- [^ 3] 1 types.FrameType: 9: d [-] 1 types.GeneratorType: 0x1519cf8 None Reference Pattern by <[dict of] class>. 0: _ --- [-] 470 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0xdf0ee0, 0xfae860, 0xfc5850, 0xfc59d0... 2: aa ---- [-] 1 list: 0x13c67a0*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 468 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0xdf0ee0, 0xfae680, 0xfae990, 0xfd67b0... 2: aa ---- [-] 1 list: 0xf993b0*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 471 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0xdf0ee0, 0xfbf190, 0xfc0f10, 0xfe4990... 2: aa ---- [-] 1 list: 0x32ade18*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 473 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0xd07d00, 0xd07e30, 0xdf0ee0, 0xfac950... 2: aa ---- [-] 1 list: 0x10ad710*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 471 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x1122500..., 0xde94d0, 0xdf0ee0, 0xfd6040 2: aa ---- [-] 1 list: 0x23bd170*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 469 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x10879f0, 0x1088470..., 0xdf0ee0, 0xff3be0 2: aa ---- [-] 1 list: 0x392d170*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 468 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x112b280..., 0xdf0ee0, 0xfbed60, 0xfc4a00 2: aa ---- [-] 1 list: 0x389c440*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 470 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x10d76f0, 0x11484f0..., 0xdf0ee0, 0xfd2880 2: aa ---- [-] 1 list: 0x2f1cf38*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 470 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0xdf0ee0, 0xfb1e00, 0xfbeb10, 0xfce6a0... 2: aa ---- [-] 1 list: 0x324e5f0*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 472 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x1090e70..., 0xdf0ee0, 0xfdabd0, 0xfee4d0 2: aa ---- [-] 1 list: 0x4261248*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 469 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x1078230..., 0xdf0ee0, 0xfef440, 0xfef780 2: aa ---- [-] 1 list: 0x3dc62d8*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 470 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x1078f70, 0x108bf70..., 0xdf0ee0 2: aa ---- [-] 1 list: 0xf993f8*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 470 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x108e180, 0x112d100..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x10ad248*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 469 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x107db80, 0x107dcb0..., 0xdf0ee0, 0xfc33e0 2: aa ---- [-] 1 list: 0x5d21440*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 471 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x107df30, 0x108f790..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x64a3dd0*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 473 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x111ac40, 0x111ad70..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x72f0830*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 471 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0xdf0ee0, 0xfb61d0, 0xfb6300, 0xfbef50... 2: aa ---- [-] 1 list: 0x7095a70*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 470 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x107c1c0, 0x107c2f0..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x693b4d0*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 470 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x1085830..., 0xdf0ee0, 0xfd6a10, 0xfd6b40 2: aa ---- [-] 1 list: 0x7b85b48*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 470 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x1197940, 0x11afe40..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x892ba70*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 469 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x11bbea0, 0x42c1c00..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x7103050*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 469 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x10763b0, 0x10764e0..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x8b34098*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 469 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x13fffe0, 0x19851d0..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x9105ea8*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 470 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x2474f00, 0x28af3e0..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x9ce0ab8*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 471 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x119cb30, 0x1289d00..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x9ed4dd0*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web From goldspin at gmail.com Wed Apr 2 00:55:35 2008 From: goldspin at gmail.com (Henry Chang) Date: Tue, 1 Apr 2008 21:55:35 -0700 Subject: Basic class implementation question In-Reply-To: References: Message-ID: You might want to consult this. http://www.ibiblio.org/g2swap/byteofpython/read/object-methods.html On Tue, Apr 1, 2008 at 9:43 PM, wrote: > I can't get call a class for some reason. This must be one of those > newbie questions I hear so much about: > > class wontwork: > def really(): > print "Hello World" > > wontwork.really() > > This returns (as an error): > > Traceback (most recent call last): > File "", line 1, in > wontwork.really() > TypeError: unbound method really() must be called with wontwork > instance as first argument (got nothing instead) > > Any ideas? > -- > http://mail.python.org/mailman/listinfo/python-list > From tjreedy at udel.edu Sun Apr 27 15:33:56 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 27 Apr 2008 15:33:56 -0400 Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com><03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: "Dieter Maurer" wrote in message news:x7y76zte0h.fsf at handshake.de... | We observed similar very bad behaviour -- in a Web application server. | Apparently, the standard behaviour is far from optimal when the | system contains a large number of objects and occationally, large | numbers of objects are created in a short time. | We have seen such behaviour during parsing of larger XML documents, for | example (in our Web application). Does the standard alternative behavior of temporarily turning cyclic gc off solve your problem? Can this alternative be made easier by adding a context manager to gc module to use with 'with' statements? Something like with gc.delay() as dummy: with exit invoking the collector (or make that a delay keyword param?) Do the docs need some improvement in this area? tjr From anuraguniyal at yahoo.com Tue Apr 1 23:39:39 2008 From: anuraguniyal at yahoo.com (anuraguniyal at yahoo.com) Date: Tue, 1 Apr 2008 20:39:39 -0700 (PDT) Subject: bsddb3 thread problem References: Message-ID: <1c00d777-b1eb-438a-85b6-8096a7453829@u36g2000prf.googlegroups.com> > Using threads with bsddb3. ?I spent weeks trying to get it to behave > when threading. ?I gave up in the end and changed to sqlite :-( > So does it mean that I will have to use threading locks around access methods? or that will also fail mysteriously :) From castironpi at gmail.com Thu Apr 3 00:03:02 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 2 Apr 2008 21:03:02 -0700 (PDT) Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> <7xwsngyu05.fsf@ruckus.brouhaha.com> <7x8wzw80rf.fsf@ruckus.brouhaha.com> <0d97babc-1174-4537-a7eb-e60164521863@s13g2000prd.googlegroups.com> Message-ID: <83dfdeec-dfc4-41ae-9781-052bdbea7497@b64g2000hsa.googlegroups.com> On Apr 2, 5:41?pm, "bruno.desthuilli... at gmail.com" wrote: > On 2 avr, 22:23, Paul Rubin wrote: > > > "bruno.desthuilli... at gmail.com" writes: > > > Fine. But totally irrelevant here - this is comp.lang.python, not > > > comp.lang.c, and we *do not* (I repeat : we *do not*) face the same > > > safety and security problems as those existing in C. > > > We have it better than they do in some ways. > >In some other ways, we have > > it worse. > > Care to elaborate ? Or are we supposed to guess ?-) Has anyone thought about putting code in a Data file? Am I the only one that wants Python stored procedures in DB? From Lie.1296 at gmail.com Mon Apr 7 12:56:32 2008 From: Lie.1296 at gmail.com (Lie) Date: Mon, 7 Apr 2008 09:56:32 -0700 (PDT) Subject: First Python project - comments welcome! References: Message-ID: <0431417e-52b9-439f-b8cb-941d3b4fb42b@1g2000prg.googlegroups.com> On Apr 7, 3:03?pm, Paul Scott wrote: > I have started, and made some progress (OK it works, but needs some > love) on my first real Python application. > > http://cvs2.uwc.ac.za/trac/python_tools/browser/podder > > I would love some feedback on what I have done. In total this has taken > me 5 nights to do (I am working on it at night as PHP, not Python, is my > day job), so it can probably do with *lots* of improvement. All code is > GPL. > > If anyone on this list is willing/able, please do give me a few > pointers, even if it is "This is total crap - RTFM and come back when > you are ready" I would really appreciate it! > > Many thanks, and thank you to this community for helping me through the > initial bumps of getting into Python - a great dev tool IMHO! > > --Paul > > All Email originating from UWC is covered by disclaimerhttp://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm I don't know if it was just me, but I can't just scan through your code briefly to know what it is about (as is with any non-trivial codes), only after looking through the website's Roadmap I realized it's something to do with audio and recording. Perhaps you should add a short module-level docstring that explains in a brief what the code is about, somewhat like an abstract. And second, it's just my personal preference, but I usually like to separate between GUI codes (codes that handle GUI events) and working code (the real worker). It's just so that if one day you want to revamp the GUI (e.g. unify the play and pause button into a single morphing button), you could do it easily without touching the working code or if you want to call pause() from somewhere else other than GUI (from an error handler?), you don't call it by pause_click() while no clicking is done. It's also helpful if someday you want to make a command-line version of the program (for the same reason, so we don't call play_click() while what we're doing is typing some commands) or change the GUI engine. It's also helpful if we want to do something fancy that is GUI-related, like clicking the play button will keep it depressed until we click the stop button (like that ol' tape recorder) From stefan_ml at behnel.de Mon Apr 21 10:28:01 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 21 Apr 2008 16:28:01 +0200 Subject: py3k concerns. An example In-Reply-To: References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: <480CA471.5020501@behnel.de> Gabriel Genellina wrote: > You have plenty of time to evaluate alternatives. Your code may become obsolete even before 3.3 is shipped. Sure, and don't forget to save two bytes when storing the year. ;) Stefan From bvidinli at gmail.com Mon Apr 14 09:20:12 2008 From: bvidinli at gmail.com (bvidinli) Date: Mon, 14 Apr 2008 16:20:12 +0300 Subject: Python GUI programming and boa or better ? Message-ID: <36e8a7020804140620q1a1eb7d2xf4e8b3d753a1b62c@mail.gmail.com> I program in python for about 2-3 monthos. I just started/tested gui programming with many tools. i tested boa last, it is the closest tool to delphi in tui tools that i used. I managed to play with it a bit. If you have any other tool which you know better than Boa Constructor, please write in here. Any other suggestion about python GUI programming is welcome. thanks. -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From tjreedy at udel.edu Mon Apr 28 23:00:59 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 28 Apr 2008 23:00:59 -0400 Subject: Python Math libraries - How to? References: <48168670.9040102@islandtraining.com> Message-ID: "Gary Herron" wrote in message news:48168670.9040102 at islandtraining.com... aguirre.adolfo at gmail.com wrote: You have several ways to import a module, and your choice determines how you access things. Method 1: import math Then use: math.pi, math.sqrt, math.sin, math.cos, ... Method 2: from math import pi, sqrt Then use pi, and sqrt. But other module attributes (like sin, and cos) are not accessible. Method 3: from math import * Then use pi, sqrt, cos, sin, and anything else defined by the module. (This is sometime frowned upon, but there's no reason to do so here.) | ===================================== | There are two good reasons for the frown. One is for the potential conflict between builtin names, imported names (from possibly multiple modules), and names defined in the module. Builtins and math both have 'pow' functions that I believe are slightly different (or maybe once were). Math and cmath have 13 functions with duplicate names but different input and output (2.5). Importing * from both would be disasterous. The other is that someone not familiar with the imported module(s) will not know where a particular name came from when reading the code. Both problems are obvious worse with multiple imports. Method 4: (my favorite when using multiple names from a module) import math as m Then use m.pi, etc. tjr From sturlamolden at yahoo.no Thu Apr 17 11:29:49 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 17 Apr 2008 08:29:49 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: <7a39a28a-751d-4196-a45d-32bcdab89b90@26g2000hsk.googlegroups.com> On 17 Apr, 10:12, Steve Holden wrote: > Quick, write it down before the drugs wear off. Hehe, I don't take drugs, apart from NSAIDs for arthritis. Read my answer to Martin v. L?wis. From Stephen.Cattaneo at u4eatech.com Tue Apr 8 16:45:50 2008 From: Stephen.Cattaneo at u4eatech.com (Stephen Cattaneo) Date: Tue, 8 Apr 2008 13:45:50 -0700 Subject: Best way to check if string is an integer? In-Reply-To: <5fa6c12e0804081332r2a58d39gc44ce1ef8cb69052@mail.gmail.com> References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com><434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com><0fdd2825-6d1c-4380-a79a-a7aac119f002@a5g2000prg.googlegroups.com><96d2fe53-96bf-43d8-a58d-8269846bf0df@b64g2000hsa.googlegroups.com><2033313.fb3g3XYCIP@montana.com> <5fa6c12e0804081332r2a58d39gc44ce1ef8cb69052@mail.gmail.com> Message-ID: 1E+1 is short hand for a floating point number, not an interger. >>> float("1E+1") 10.0 You could convert the float to an integer if you wanted (i.e. ceiling, floor, rounding, truncating, etc.). Cheers, Steve -----Original Message----- From: Martin Marcher [mailto:martin at marcher.name] Sent: Tuesday, April 08, 2008 1:32 PM To: python-list at python.org Subject: Re: Best way to check if string is an integer? hmmm int() does miss some stuff: >>> 1E+1 10.0 >>> int("1E+1") Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: '1E+1' I wonder how you parse this? I honestly thought until right now int() would understand that and wanted to show that case as ease of use, I was wrong, so how do you actually cast this type of input to an integer? thanks martin -- http://tumblr.marcher.name https://twitter.com/MartinMarcher http://www.xing.com/profile/Martin_Marcher http://www.linkedin.com/in/martinmarcher You are not free to read this message, by doing so, you have violated my licence and are required to urinate publicly. Thank you. From jjl at pobox.com Sun Apr 6 08:08:58 2008 From: jjl at pobox.com (John J. Lee) Date: Sun, 06 Apr 2008 12:08:58 GMT Subject: Any fancy grep utility replacements out there? References: Message-ID: <87iqyv89t1.fsf@pobox.com> "samslists at gmail.com" writes: > So I need to recursively grep a bunch of gzipped files. This can't be > easily done with grep, rgrep or zgrep. (I'm sure given the right > pipeline including using the find command it could be done....but > seems like a hassle). > > So I figured I'd find a fancy next generation grep tool. Thirty > minutes of searching later I find a bunch in Perl, and even one in > Ruby. But I can't find anything that interesting or up to date for > Python. Does anyone know of something? > > Thanks There must be a million of these scripts out there, maybe one per programmer :-) Here's mine: http://codespeak.net/svn/user/jjlee/trunk/pygrep/ It doesn't do zip files. It has the usual file / dir blacklisting feature (for avoiding backup files, etc.). Oddities of this particular script are support for searching for Python tokens in .py files, doctests, doctest files, and preppy 2 .prep template files. It also outputs in a format that allows you to click on matches in emacs. A few years back I was going to release it in the hope that other people would write plugins for other templating systems, but then I stopped doing lots of web stuff. Actually, tokenizing based on a simple fixed "word boundary" rule seems to work as well in many cases (pygrep doesn't do that) -- though sometimes proper tokenization can be quite handy -- searching for a particular Python name, Python string or number can be just what's needed (pygrep does support that -- e.g. , -sep, -sebp, -nep). Most of the time I just use the -t option though, which is just substring match, just because it's fast and good enough for most cases (most search strings are longish and so don't give lots of false positives). The default is tokenized search for files it knows how to tokenize (.py, .prep, etc.) and substring match for every other file that's not blacklisted -- I find this good for small projects, but too slow (there's no caching) for large projects. Somebody at work has a nice little web-based tool that you can run as a local server, and turns tokens (e.g. Python names -- but it's based on some fast simple tokenizer that doesn't know about Python) into links you can click on. The CSS is written so the link styling doesn't show up until you hover the mouse over a token, IIRC. It seems very efficient for exploring/reading and navigating source code -- I only don't use it because it's not integrated with emacs. It would be great if somebody could do the same in emacs, with back / forward buttons :-) John From dgates at somedomain.com Mon Apr 14 10:51:07 2008 From: dgates at somedomain.com (dgates) Date: Mon, 14 Apr 2008 07:51:07 -0700 Subject: Game design : Making computer play References: Message-ID: <7nr604dluq8dhap6jl519vamld41t68nsg@4ax.com> On Mon, 14 Apr 2008 12:13:20 +0000 (UTC), Willem wrote: >Richard wrote: >) Here's the board (which bears only a slight resemblance to one I'd seen on >) the Web): >) >) +---------------+ >) | HORN $ | >) +---+---+---+---+---+---+ >) |L W| | $ | $ | |R W| >) +E-I+--CHEST+---+---+I-I+ >) |F N| | | | |G N| >) +T-G+---+---+---+---+H-G+ >) | | | | | |T | >) +---+---+---+---+---+---+ >) | LEGS| | | >) +---+---+---+---+ >) >) There are three tigers and fifteen goats. >) The tigers' goal is to eat all the goats and remain mobile. >) It seems that the initial tiger positions are: one on the horn, and one >) each on CHEST-2 and CHEST-3 (see $ marks, above). >) The goats' goal is to block the tigers from moving. >) The goats are placed one by one. >) Tigers appear only to be able to move orthogonally (up/down/left/right) - >) although they can use the horn to whizz across the chest (e.g. CHEST-1 to >) HORN, HORN to CHEST-4, in two moves). >) The rest of the rules are beyond me, I'm afraid. It's not clear how tigers >) eat goats or how goats block tigers. > >If it's similar to the 'other' goats and tigers game, a tiger eats a goat >by jumping over it, for which the square behind it needs to be empty, >obviously. v4 gave us a link to a page that not only lists the rules, but lets you try them out: http://v4vijayakumar.googlepages.com/goats-and-tigers.html Seems like a fun quickie game to play with some coins on a piece of paper. I like the asymmetrical goals and the quick setup. From toby at tobiah.org Tue Apr 15 17:03:53 2008 From: toby at tobiah.org (Tobiah) Date: Tue, 15 Apr 2008 14:03:53 -0700 Subject: Getting subprocess.call() output into a string? References: Message-ID: On Tue, 15 Apr 2008 13:36:11 -0700, Tobiah wrote: > I am not sure how to capture the output of a command > using subprocess without creating a temp file. I was Sorry, I jumped into a secondary level of the docs, and didn't see it all. I guess I can use communicate() to get the output. Still, about StringIO... > trying this: > > import StringIO > import subprocess > > file = StringIO.StringIO() > > subprocess.call("ls", stdout = file) > > Traceback (most recent call last): > File "", line 6, in ? > File "/usr/local/lib/python2.4/subprocess.py", line 413, in call > return Popen(*args, **kwargs).wait() > File "/usr/local/lib/python2.4/subprocess.py", line 534, in __init__ > (p2cread, p2cwrite, > File "/usr/local/lib/python2.4/subprocess.py", line 840, in _get_handles > c2pwrite = stdout.fileno() > AttributeError: StringIO instance has no attribute 'fileno' > > So how do I get the output into a string? > > I thought that the idea of StringIO was that it could be > used where a file was expected. > > Thanks, > > Toby > ** Posted from http://www.teranews.com ** ** Posted from http://www.teranews.com ** From gh at ghaering.de Thu Apr 10 04:56:19 2008 From: gh at ghaering.de (=?ISO-8859-1?Q?Gerhard_H=E4ring?=) Date: Thu, 10 Apr 2008 10:56:19 +0200 Subject: urgent question, about filesystem-files In-Reply-To: References: Message-ID: <66631jF2iadeoU1@mid.uni-berlin.de> bvidinli wrote: > i started python programming a few months ago. > > now i need the code to understand if a file already opened in > filesystem by another process ? > > i looked at docs, howtos, but did not find related info. > note that normal file open/write operations in python, i know it. > > i specificly need to know that "is a file already open by some other > process other than python". The pragmatic solution here is to not worry about it and let it be the user's problem if he does something stupid. It's OS specific how to get at this information. On Linux, for example you can call the `fuser` program (if installed; on Ubuntu it's in the psmisc package). But this will only tell you if the same user has the file open (or if you're root). -- Gerhard From michele.simionato at gmail.com Wed Apr 23 13:53:03 2008 From: michele.simionato at gmail.com (Michele Simionato) Date: Wed, 23 Apr 2008 10:53:03 -0700 (PDT) Subject: Python generators (coroutines) References: Message-ID: On Apr 23, 4:17 pm, rocco.ro... at gmail.com wrote: > I would really like to know more about python 2.5's new generator > characteristics that make them more powerful and analogous to > coroutines. Is it possible for instance to employ them in situations > where I would normally use a thread with a blocking I/O (or socket) > operation? If it is, could someone show me how it can be done? There > appears to be a very limited amount of documentation in this repect, > unfortunately. > > Thank you. The real changes between Python 2.4 and Python 2.5 generators are 1) now you can have a yield inside a try .. finally statement 2) now you can send an exception to a generator The fact that now you can send values to a generator is less important, since you could implement the same in Python 2.4 with little effort (granted, with an uglier syntax) whereas there was no way to get 1) and 2). Anyway, if you have a blocking operation, the only solution is to use a thread or a separate process. Michele Simionato From shahmed at sfwmd.gov Wed Apr 23 11:16:19 2008 From: shahmed at sfwmd.gov (Ahmed, Shakir) Date: Wed, 23 Apr 2008 11:16:19 -0400 Subject: Error Message In-Reply-To: <480F483B.9050507@holdenweb.com> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com><27CC3060AF71DA40A5DC85F7D5B70F38033A4F2D@AWMAIL04.belcan.com> <480F483B.9050507@holdenweb.com> Message-ID: <14A2A120D369B6469BB154B2D2DC34D20AD1195E@EXCHVS01.ad.sfwmd.gov> I am getting application error message " The instruction at "0x7c910f29" referenced memory at "0xffffffff". The memory could not be "read". I am running one python script and it is running good without any exception or error message but getting this message when I am closing python 2.4.1 application. Any idea or help is highly appreciated. Thanks sk -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.jpg Type: image/jpeg Size: 12570 bytes Desc: image001.jpg URL: From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 22 03:33:05 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 22 Apr 2008 09:33:05 +0200 Subject: Java or C++? In-Reply-To: <2eae6385-1257-48fc-b793-31d0225503ba@f36g2000hsa.googlegroups.com> References: <2eae6385-1257-48fc-b793-31d0225503ba@f36g2000hsa.googlegroups.com> Message-ID: <480d94aa$0$23089$426a74cc@news.free.fr> hdante a ?crit : > Summarizing the discussion (and giving my opinions), here's an > "algorithm" to find out what language you'll leard next: > > 1. If you just want to learn another language, with no other > essential concern, learn Ruby. > 2. If you want to learn another language to design medium to large > size applications, considering market, jobs, etc., and the speed gains > of static byte-compiled languages, learn Java or C#. > 3. If you want to learn another language to design applications with > speed gains, but you want that the transition be as smooth as possible > and don't have market concerns (and with the possibility of taking > another easy step later to reach step 2), learn Groovy (for the JMV) > or Boo (for .NET). > 4. If you want to develop applications but, for some special reason, > you require native compilation (like speed requirements, embedded > systems, etc.), learn C++ > 5. If you want to develop system software, or just learn better how > machines work, or understand better low level implementation aspects > of software, learn C. > 6. If you just want to speed-up your python programs or offer some > special, system-specific or optimized behavior to your python > applications, or you just want to complement your python knowledge, > learn C. > And if you really want to actually *learn* something, learn a functional language. From fr5478bey at gmail.com Sat Apr 26 11:42:31 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:42:31 -0700 (PDT) Subject: avg internet security crack Message-ID: <72edc5f7-a6f7-44d4-8f30-707acb7fb622@a1g2000hsb.googlegroups.com> avg internet security crack http://cracks.00bp.com F R E E C R A C K S From jason.scheirer at gmail.com Tue Apr 8 00:57:47 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Mon, 7 Apr 2008 21:57:47 -0700 (PDT) Subject: Newbie: How to pass a dictionary to a function? References: <516e07d1-91f9-462b-9fc0-ac6d1e474f9d@n14g2000pri.googlegroups.com> Message-ID: <0178aef6-46ce-47a4-a2a4-882514e2aacd@k1g2000prb.googlegroups.com> On Apr 7, 8:54 pm, BonusOnus wrote: > How do I pass a dictionary to a function as an argument? > > # Say I have a function foo... > def foo (arg=[]): > x = arg['name'] > y = arg['len'] > > s = len (x) > > t = s + y > > return (s, t) > > # The dictionary: > > dict = {} > dict['name'] = 'Joe Shmoe' > dict['len'] = 44 > > # I try to pass the dictionary as an argument to a > # function > > len, string = foo (dict) > > # This bombs with 'TypeError: unpack non-sequence' > > What am I doing wrong with the dictionary? You want to return s, t NOT return (s, t) -- this implicitly only returns ONE item From landerdebraznpc at gmail.com Mon Apr 28 03:55:23 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:55:23 -0700 (PDT) Subject: crack zone Message-ID: <23cd8db2-68da-445a-b86d-6466f433d3e9@l64g2000hse.googlegroups.com> crack zone http://crack.cracksofts.com From ridenour4159 at gmail.com Thu Apr 24 06:12:21 2008 From: ridenour4159 at gmail.com (ridenour4159 at gmail.com) Date: Thu, 24 Apr 2008 03:12:21 -0700 (PDT) Subject: xyplorer crack Message-ID: <9b7fbb72-4c1d-40f9-b397-4542ae846b5b@m36g2000hse.googlegroups.com> xyplorer crack http://cracks.12w.net F R E E C R A C K S From Scott.Daniels at Acm.Org Wed Apr 30 09:00:36 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Wed, 30 Apr 2008 06:00:36 -0700 Subject: how to convert a multiline string to an anonymous function? In-Reply-To: <87c29666-f64f-4f3c-97e1-a3d1dccdc49b@s50g2000hsb.googlegroups.com> References: <67pmdnF2p5fhgU1@mid.uni-berlin.de> <87c29666-f64f-4f3c-97e1-a3d1dccdc49b@s50g2000hsb.googlegroups.com> Message-ID: <9a2dnc3tFZET9oXVnZ2dnUVZ_rqlnZ2d@pdx.net> Matimus wrote: > On Apr 29, 3:39 pm, "Diez B. Roggisch" wrote: >> Danny Shevitz schrieb: >>> Simple question here: ... >>> str = ''' >>> def f(state): >>> print state >>> return True >>> ''' >>> but return an anonmyous version of it, a la 'return f' so I can assign it >>> independently. The body is multiline so lambda doesn't work.... >> The "stupid" thing is that you can pass your own dictionary as globals >> to exec. Then you can get a reference to the function under the name "f" >> in the globals, and store that under whatever name you need.... >> Diez > ... Or, you can even more simply do: text = ''' def f(state): print state return True ''' lcl = {} exec text in globals(), lcl and lcl will be a dictionary with a single item: {'f' : } so you could return lcl.values()[0] -Scott David Daniels Scott.Daniels at Acm.Org From steve at holdenweb.com Wed Apr 9 22:08:01 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 22:08:01 -0400 Subject: new user needs help! In-Reply-To: <16596608.post@talk.nabble.com> References: <16571823.post@talk.nabble.com> <16596608.post@talk.nabble.com> Message-ID: drjekil wrote: > I have done something so far about that problem,but its not the good way to > do it > > need ur comments about that.... > Well, at least you can see that your approach is not satisfactory, so that means you have some sense of what's good and bad programming/ > > from string import *; > import sys > > myfile = open("/afs/pdc.kth.se/home/d/debnath/membrane/1a91A.txt") > a = myfile.readlines() > data = myfile.readlines() The first readlines() exhausts the file. > for line in myfile.readlines(): You should omit the assignments to a and to data, as they are using up the contents of the file that you want this statrement to iterate over. > fields = line.split('\t') > > items=fields.strip() > list1.append(items[1]) > Note that what you are doing here is building a list of the lines in the file to iterate over later, when you could just iterate over the lines in the file. > > for i in aminoacid: > if 10.0 <= z <= 22.0: > matches.append([1,i]) > #here i am getting comment! bash-3.1$ python bb.py > File "bb.py", line 16 > matches.append([1,i]) > ^ > IndentationError: expected an indented block > > else: > matches.append([-1,i]) > The error message is literally correct. The statement(s) controlled by an if must be indented relative to the if statement itself - remember, Python uses indentation to indicate block structure. Also, it seems a little unnecessary to build a list of all the matching lines and then process them, when you could process them one at a time as you read them from the file! > print "#T/F A C D E F G H I K L M N P Q R S T V W X Y > Z" > That looks fine! > for a in range(0,len(matches),1): > > if matches[a][0]==1: > > if matches[a][1]=='A': > print "1 1:1 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 > 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > elif matches[a][1]=='C': > print "1 1:0 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 > 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > elif matches[a][1]=='D': > > print " 1 1:0 2:0 3:1 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > """ if matches[a][1]=='E' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:1 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='F' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:1 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='G' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:1 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='H' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='I' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:1 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='K' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:1 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='L' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:1 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='M' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:1 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='N' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:1 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='P' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:1 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='Q' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='R' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:1 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='S' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:1 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='T' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:1 18:0 19:0 20:0 21:0" > if matches[a][1]=='V' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:1 19:0 20:0 21:0" > if matches[a][1]=='X' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:1 20:0 21:0" > if matches[a][1]=='Y' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:1 21:0" > if matches[a][1]=='Z' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:1" > > > """ > else: > if matches[a][1]=='A': > print "-1 1:1 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 > 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > elif matches[a][1]=='C': > print "-1 1:0 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > elif matches[a][1]=='D': > > print " 1 1:0 2:0 3:1 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > """ if matches[a][1]=='E' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:1 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='F' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:1 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='G' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:1 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='H' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='I' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:1 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='K' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:1 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='L' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:1 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='M' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:1 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='N' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:1 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='P' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:1 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='Q' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='R' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:1 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='S' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:1 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='T' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:1 18:0 19:0 20:0 21:0" > if matches[a][1]=='V' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:1 19:0 20:0 21:0" > if matches[a][1]=='X' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:1 20:0 21:0" > if matches[a][1]=='Y' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:1 21:0" > if matches[a][1]=='Z' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:1" > waiting for ur opinion. > thanks > I think you're right about the logic being unnecessarily complex :-) The following is untested, but it will give you some idea of how you might proceed. myfile = open("/afs/pdc.kth.se/home/d/debnath/membrane/1a91A.txt") print "#T/F A C D E F G H I K L M N P Q R S T V W X Y Z" for line in myfile.readlines(): fields = line.strip().split('\t') if 10.0 <= float(fields[6]) <= 22.0: # Sets T/F flag flag = 1 else: flag = -1 pos = "ACDEFGHIKLMNPQRSTVWXYZ".index(fields[1]) m = [] for i in range(20): if pos == i: m.append("%d:1") else: m.append("%d:0") print flag, " ".join(m) This is not quite as compact as it could be. What you could do is try running it with print statements inserted to show you what value variables are taking in statements you don't understand. Hope this helps! regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From nagle at animats.com Sat Apr 12 01:12:59 2008 From: nagle at animats.com (John Nagle) Date: Fri, 11 Apr 2008 22:12:59 -0700 Subject: Question on threads In-Reply-To: References: <47FFBC05.50309@holdenweb.com> Message-ID: <4800424b$0$36318$742ec2ed@news.sonic.net> Steve Holden wrote: > Jonathan Shao wrote: >> On Fri, Apr 11, 2008 at 3:29 PM, Steve Holden > > wrote: >> >> Jonathan Shao wrote: >> >> Hi all, >> I'm a beginner to Python, so please bear with me. >> Is there a way of guarenteeing that all created threads in a >> program are finished before the main program exits? >> I guess I'm doing something wrong with join(). Didn't we answer this question just a few days ago? John Nagle From skanemupp at yahoo.se Sun Apr 6 22:50:16 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 6 Apr 2008 19:50:16 -0700 (PDT) Subject: Tkinter, a lot of buttons, make prog shorter? References: <688483d9-2c6a-4e2a-b64d-f32bb27699ec@p25g2000hsf.googlegroups.com> Message-ID: <8869512e-19c3-4750-b4f1-5666a2547f13@u3g2000hsc.googlegroups.com> should i not use self. in Clean() and Calculate() either? anyway i had changed it before. must have copied the wrong program. #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self, master=None): """Initialize yourself""" self.expr = "" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): """Create the Button, set the text and the command that will be called when the button is clicked""" btnDisplay = Button(self, text="calculate!", command=self.Calculate) btnDisplay.grid(row=0, column=31) ## """Create the Button, set the text and the ## command that will be called when the button is clicked""" ## self.lbText = Label(self, text="Results:") ## self.lbText.grid(row=1, column=0) btnDisplay = Button(self,text='1',command=lambda n="1":self.Display(n),width=2,height=2) btnDisplay.grid(row=3, column=0) btnDisplay = Button(self,text='2',command=lambda n="2":self.Display(n),width=2,height=2) btnDisplay.grid(row=3, column=1) btnDisplay = Button(self,text='3',command=lambda n="3":self.Display(n),width=2,height=2) btnDisplay.grid(row=3, column=2) btnDisplay = Button(self,text='+',command=lambda n="+":self.Display(n),width=2,height=2) btnDisplay.grid(row=3, column=3) btnDisplay = Button(self,text='4',command=lambda n="4":self.Display(n),width=2,height=2) btnDisplay.grid(row=4, column=0) btnDisplay = Button(self,text='5',command=lambda n="5":self.Display(n),width=2,height=2) btnDisplay.grid(row=4, column=1) btnDisplay = Button(self,text='6',command=lambda n="6":self.Display(n),width=2,height=2) btnDisplay.grid(row=4, column=2) btnDisplay = Button(self,text='-',command=lambda n="-":self.Display(n),width=2,height=2) btnDisplay.grid(row=4, column=3) btnDisplay = Button(self,text='7',command=lambda n="7":self.Display(n),width=2,height=2) btnDisplay.grid(row=5, column=0) btnDisplay = Button(self,text='8',command=lambda n="8":self.Display(n),width=2,height=2) btnDisplay.grid(row=5, column=1) btnDisplay = Button(self,text='9',command=lambda n="9":self.Display(n),width=2,height=2) btnDisplay.grid(row=5, column=2) btnDisplay = Button(self,text='*',command=lambda n="*":self.Display(n),width=2,height=2) btnDisplay.grid(row=5, column=3) btnDisplay = Button(self,text='0',command=lambda n="0":self.Display(n),width=2,height=2) btnDisplay.grid(row=6, column=0) btnDisplay = Button(self,text='C',command=self.Clean,width=2,height=2) btnDisplay.grid(row=6, column=1) btnDisplay = Button(self,text='^.5',command=lambda n="**. 5":self.Display(n),width=2,height=2) btnDisplay.grid(row=6, column=2) btnDisplay = Button(self,text='/',command=lambda n="/":self.Display(n),width=2,height=2) btnDisplay.grid(row=6, column=3) def Display(self, number): self.expr = self.expr + number self.lbText = Label(self, text=self.expr) self.lbText.grid(row=0, column=0) def Calculate(self): self.expr = str(eval(self.expr))#try catch tex 3+6+ result = self.expr self.Clean() self.lbText = Label(self, text=result) self.lbText.grid(row=0, column=0) self.expr = "" def Clean(self): self.expr = " " self.lbText.config(text=self.expr) self.lbText = Label(self, text=self.expr) self.lbText.grid(row=0, column=0) self.expr = "" self.lbText.config(text=self.expr) self.lbText = Label(self, text=self.expr) self.lbText.grid(row=0, column=0) if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() From sturlamolden at yahoo.no Thu Apr 24 22:56:14 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 19:56:14 -0700 (PDT) Subject: Calling Python code from inside php References: <679e9oF2mti63U1@mid.uni-berlin.de> <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> <679hd5F2nj6csU1@mid.uni-berlin.de> Message-ID: <94a6b9c5-9b5b-4b4d-b79a-db4dd61f3e67@w7g2000hsa.googlegroups.com> On Apr 24, 5:51 am, Nick Stinemates wrote: > I don't understand how the 2 are mutually exclusive? > > You can have PHP and Python bindings installed on the same Apache > server, unless I'm mistaken? Not everyone have the luxury of having mod_python installed. It depends on the host. On the other hand, mod_php will almost certainly be installed on any Apache server. From torriem at gmail.com Wed Apr 16 12:12:20 2008 From: torriem at gmail.com (Michael Torrie) Date: Wed, 16 Apr 2008 10:12:20 -0600 Subject: Finally had to plonk google gorups. In-Reply-To: <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <48062564.4000802@gmail.com> Mike Driscoll wrote: > Steve, > > My workplace doesn't offer NNTP, so there is no good way to browse > c.l.py here. And I haven't been able to get NNTP to work from my home > either. I rarely use NNTP these days. I access c.l.py exclusively via e-mail, and that works very well. In some cases there is a lot of spam that gets filtered out of the nntp side, but makes it through to the smtp side (like that religious spam a few months back). But I see absolutely none of the google groups problems that Grant mentioned. I view my python list mail in gmail, and get about 1-2 spam messages a day in the python list. This official python list is one of the few lists that's even still on nntp. All my other ones (gnome, gtk, openldap, clamav, freeradius, etc) are all e-mail mailing lists only and it works very well. In fact, I think it's much better since list subscription can actually be controlled by someone. From ewertman at gmail.com Thu Apr 24 12:14:47 2008 From: ewertman at gmail.com (Eric Wertman) Date: Thu, 24 Apr 2008 12:14:47 -0400 Subject: Ideas for parsing this text? In-Reply-To: References: Message-ID: <92da89760804240914o61467e1at5eec3968a8ab7f33@mail.gmail.com> > I would discourage you from using printables, since it also includes > '[', ']', and '"', which are significant to other elements of the > parser (but you could create your own variable initialized with > printables, and then use replace("[","") etc. to strip out the > offending characters). I'm also a little concerned that you needed to > add \t and \n to the content word - was this really necessary? None > of your examples showed such words, and I would rather have you let > pyparsing skip over the whitespace as is its natural behavior. > > -- Paul You are right... I have taken those out and it still works. I was adding everything I could think of at one point in trying to determine what was breaking the parser. Some of the data in there is input free form... which means that any developer could have put just about anything in there... I find a lot of ^M stuff from day to day in other places. From fred.sells at adventistcare.org Tue Apr 29 16:15:44 2008 From: fred.sells at adventistcare.org (Sells, Fred) Date: Tue, 29 Apr 2008 16:15:44 -0400 Subject: Need Python alternative to Request-Tracker help desk software In-Reply-To: Message-ID: <0A53725C4A497848A7B3A0874B259831011B08E8@acesxch01.ADVENTISTCORP.NET> I've been tasked with either implementing Request-Tracker to upgrade our help desk issue tracking system or finding a Python equivalent (both in terms of functionality and wide spread use). Request-Tracker uses Apache and MySQL, which would also be appropriate to Python. I would prefer to go the Python route, especially since Request-Tracker is written in Perl (which I don't know). My initial attempts with Google were not useful due to the general nature of the keywords. Are there any suggestions. --------------------------------------------------------------------------- The information contained in this message may be privileged and / or confidential and protected from disclosure. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and deleting the material from any computer. --------------------------------------------------------------------------- From george.sakkis at gmail.com Fri Apr 11 15:20:27 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 11 Apr 2008 12:20:27 -0700 (PDT) Subject: Profiling programs/scripts? References: Message-ID: On Apr 11, 2:49?pm, skanem... at yahoo.se wrote: > how do i profile a program? i found out that there are some profilers > included in the standard library but couldnt really figure out how to > access/use them Did you actually read the docs ? There is an example in the stdlib documentation: http://docs.python.org/lib/hotshot-example.html HTH, George From dieter at handshake.de Mon Apr 28 12:44:57 2008 From: dieter at handshake.de (Dieter Maurer) Date: Mon, 28 Apr 2008 18:44:57 +0200 Subject: Tremendous slowdown due to garbage collection In-Reply-To: <4814B904.1070804@v.loewis.de> References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> <4814B904.1070804@v.loewis.de> Message-ID: <18453.65289.773531.366188@gargle.gargle.HOWL> "Martin v. L?wis" wrote at 2008-4-27 19:33 +0200: >> Martin said it but nevertheless it might not be true. >> >> We observed similar very bad behaviour -- in a Web application server. >> Apparently, the standard behaviour is far from optimal when the >> system contains a large number of objects and occationally, large >> numbers of objects are created in a short time. >> We have seen such behaviour during parsing of larger XML documents, for >> example (in our Web application). > >I don't want to claim that the *algorithm* works for all typically >applications well. I just claim that the *parameters* of it are fine. >The OP originally proposed to change the parameters, making garbage >collection run less frequently. This would a) have bad consequences >in terms of memory consumption on programs that do have allocation >spikes, and b) have no effect on the asymptotic complexity of the >algorithm in the case discussed. In our case, it helped to change the parameters: As usual in Python, in our case cyclic garbage is very rare. On the other hand, we have large caches with lots of objects, i.e. a large number of long living objects. Each generation 2 garbage collection visits the complete object set. Thus, if it is called too often, matters can deteriorate drastically. In our case, the main problem has not been the runtime but that during GC the GIL is hold (understandably). This meant that we had every few minutes a scheduling distortion in the order of 10 to 20 s (the time of our generation 2 gc). We changed the parameters to let generation 2 GC happen at about 1/1000 of its former frequency. I do not argue that Python's default GC parameters must change -- only that applications with lots of objects may want to consider a reconfiguration. -- Dieter From carlwuhwdmckay at gmail.com Mon Apr 21 02:06:39 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:06:39 -0700 (PDT) Subject: firewire patch cable Message-ID: <81b7c6ef-7f18-42a6-afee-835c2325464f@k13g2000hse.googlegroups.com> firewire patch cable http://cracks.00bp.com F R E E C R A C K S From arnodel at googlemail.com Thu Apr 10 12:09:36 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 10 Apr 2008 09:09:36 -0700 (PDT) Subject: @x.setter property implementation References: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> <02cb2845-6a25-4e90-9f82-dbd68b37a5e6@p39g2000prm.googlegroups.com> Message-ID: <2c589c82-85e9-4db6-b8f9-156b06dd51f3@s33g2000pri.googlegroups.com> On Apr 10, 3:37?pm, Floris Bruynooghe wrote: > On Apr 7, 2:19 pm, "Andrii V. Mishkovskyi" wrote: > > > 2008/4/7, Floris Bruynooghe : > > > > ?Have been grepping all over the place and failed to find it. ?I found > > > ?the test module for them, but that doesn't get me very far... > > > I think you should take a look at 'descrobject.c' file in 'Objects' directory. > > Thanks, I found it! ?So after some looking around here was my > implementation: > > class myproperty(property): > ? ? def setter(self, func): > ? ? ? ? self.fset = func > > But that doesn't work since fset is a read only attribute (and all of > this is implemented in C). > > So I've settled with the (nearly) original proposal from Guido on > python-dev: > > def propset(prop): > ? ? assert isinstance(prop, property) > ? ? @functools.wraps > ? ? def helper(func): > ? ? ? ? return property(prop.fget, func, prop.fdel, prop.__doc__) > ? ? return helper > > The downside of this is that upgrade from 2.5 to 2.6 will require code > changes, I was trying to minimise those to just removing an import > statement. > > Regards > Floris Here's an implementation of prop.setter in pure python < 2.6, but using sys._getframe, and the only test performed is the one below :) import sys def find_key(mapping, searchval): for key, val in mapping.iteritems(): if val == searchval: return key _property = property class property(property): def setter(self, fset): cls_ns = sys._getframe(1).f_locals propname = find_key(cls_ns, self) # if not propname: there's a problem! cls_ns[propname] = property(self.fget, fset, self.fdel, self.__doc__) return fset # getter and deleter can be defined the same way! # -------- Example ------- class Foo(object): @property def bar(self): return self._bar @bar.setter def setbar(self, x): self._bar = '<%s>' % x # -------- Interactive test ----- >>> foo = Foo() >>> foo.bar = 3 >>> foo.bar '<3>' >>> foo.bar = 'oeufs' >>> foo.bar '' >>> Having fun'ly yours, -- Arnaud From stanc at al.com.au Wed Apr 30 23:21:24 2008 From: stanc at al.com.au (Astan Chee) Date: Thu, 01 May 2008 13:21:24 +1000 Subject: tool to calculate color combination Message-ID: <48193734.4010108@al.com.au> Hi, I was just wondering if there is a tool/script in python that allows me to do color calculations; specifically, when I add them. Also I was thinking that for this to work other than a simple way, some form of measure is included. e.g 50% red(1,0,0) + 50% yellow(1,1,0) = 100% orange(1,0.7,0) Is there such a tool in python? Thanks for any information Astan -- "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." Animal Logic http://www.animallogic.com Please think of the environment before printing this email. This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. From fetchinson at googlemail.com Sat Apr 26 13:05:36 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Sat, 26 Apr 2008 10:05:36 -0700 Subject: So you think PythonCard is old? Here's new wine in an old bottle. In-Reply-To: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> Message-ID: > > For serveral years, I have been looking for a way to migrate away from > desktop GUI/client-server programming onto the browser based network > computing model of programming. Unfortunately, up until recently, > browser based programs are very limited - due to the limitation of > HTML itself. Eventhough PythonCard hasn't keep up with the latest > widgets in wxpython, the programs so created still works a lot better > - until now. > > If you look at programs at some of the major sites these days - like > Google calendar, Netflix, blockbuster, and so forth - you would > undoubtedly notice that the quality of the programs are pretty much at > par with the desktop programs we use everyday. Since the curious mind > wanted to know how these programs are done, I started investigating > and found out that what a difference a few years have made to > Javascript - the once much hated beast of the Internet age - and > during my search for perfection, I found Qooxdoo (http:// > qooxdoo.org/). > > Qooxdoo is a Javascript toolkit that sits on top of Ajax. Take a look > at some of the *impressive* widgets > at http://demo.qooxdoo.org/current/showcase/#Form. > > So, what's that got to do with Pythoncard? Read on. > > After trying for a few days learning Qooxdoo, my head really really > hurts. Getting too old to learn this stuff, I was mumbling. > > Then I looked some more. I found QxTransformer (http:// > sites.google.com/a/qxtransformer.org/qxtransformer/Home) which is a > XSLT toolkit that creats XML code that invoke qooxdoo. > > So, what's that got to do with Pythoncard? Read on. > > After trying for a few days learning QxTransformer, my head really > really hurts. Getting too old to learn > this stuff, I was mumbling. > > I want Pythoncard. > > Damn Pythoncard! Once you got hooked, everything else looks > impossibly complicated and unproductive. > > But then I looked closer. It turns out the XML file created by > QxTransformer is *very* similar in structure when compared to the > resource files used in PythonCard. Since there are no GUI builders > for QxTransformer, and I can't affort to buy the one for Qooxdoo > (Java! Yuk!), I decided to roll up my sleeves, took the Pythoncard's > Layout Manager and modified it and created my own "Poor Man's Qooxdoo > GUI Layout Designer". > > The result? See the partially completed application at: > > http://test.powersystemadvisors.com/ > > and the same application running from the desktop: > > http://test.powersystemadvisors.com/desktopHelloWorld.jpg > > It shouldn't be long before I can fill in the gaps and have the GUI > builder maps the rest of the Pythoncard widgets to Qooxdoo widgets. > Once I've done that, I can have the same application running from the > desktop, or from the browser. And it shouldn't take more than minutes > to create such applications. > > Welcome to the modernized world of Pythoncard!!! Any reason you chose qooxdoo over ext.js? Cheers, Daniel -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin at v.loewis.de Sun Apr 20 10:59:14 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 20 Apr 2008 16:59:14 +0200 Subject: python setup.py install on Vista? In-Reply-To: References: Message-ID: <480B5A42.1050407@v.loewis.de> > It seems that quite a lot of people wondered why python doesn't set > the environment variable to Python Path in the default installation. For several reasons, one being that it's not needed. Just run setup.py as a program, i.e. don't do python setup.py install but instead do setup.py install Regards, Martin From kamhung.soh at gmail.com Sat Apr 26 05:21:53 2008 From: kamhung.soh at gmail.com (Kam-Hung Soh) Date: Sat, 26 Apr 2008 19:21:53 +1000 Subject: problem with listdir References: Message-ID: On Sat, 26 Apr 2008 19:07:45 +1000, Francesco Bochicchio wrote: > On Sat, 26 Apr 2008 01:24:23 -0700, jimgardener wrote: > >> hi >> i have a directory containing .pgm files of P5 type.i wanted to read >> the pixel values of these files ,so as a firststep i wrote code to >> make a list of filenames using listdir >> >> pgmdir="f:\code\python\pgmgallery" # where i have pgm files >> g2=listdir(pgmdir) >> >> i get the following error >> WindowsError: [Error 123] The filename, directory name, or volume >> label syntax is incorrect: 'f:\\code\\python\pgmgallery/*.*' >> >> i am running python on winXP ..can anyone tell me why i get this >> error? > > Did you try using a raw string as pathname > pgmdir=r"f:\code\python\pgmgallery" > ? > > AFAIK, the character '\' in interpreted in Python as the beginning of > an escape sequence (such as '\n') and it should be doubled ( as in the > error message) or a raw string should be used, telling Python that there > are no escape sequences inside. > However, from the message it looks like the path as been understood as > such, so this might not be the case. > > Ciao > ----- > FB Neither \c nor \p are escape characters in Section 2.4.1 "String literals". Could there be some files in that directory whose name is not a valid Windows file name? Windows file names cannot have the following symbols: \ / : * ? " < > | -- Kam-Hung Soh
Software Salariman From noah at noah.org Wed Apr 9 19:13:58 2008 From: noah at noah.org (Noah) Date: Wed, 9 Apr 2008 16:13:58 -0700 (PDT) Subject: Control process execution References: <1d1bbea2-a503-4db5-bd3f-c45c29916b9c@13g2000hsb.googlegroups.com> <7cb4c5dd-8604-4d18-925c-d6aa17c092b5@24g2000hsh.googlegroups.com> Message-ID: On Apr 9, 1:57 pm, Mike Driscoll wrote: > As far as I know, there is no "os.process". Maybe you meant os.system > or the subprocess module? > > Mike Yeah, I was thinking "subprocess" module. -- Noah From mal at egenix.com Thu Apr 24 13:36:01 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Thu, 24 Apr 2008 19:36:01 +0200 Subject: Installer In-Reply-To: References: Message-ID: <4810C501.2020203@egenix.com> On 2008-04-24 18:39, Chris wrote: > Hey all, > > I've created a python program that relies on pysqlite, wxpython, and > matplotlib. Is there any way of creating an installer that will > install all these modules, python 2.5 and my program? Assuming that you're on Windows, a well-working approach is to wrap up your application using py2exe and then creating an installer using e.g. InnoSetup or NSIS. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 24 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From ridenour4159 at gmail.com Thu Apr 24 06:17:59 2008 From: ridenour4159 at gmail.com (ridenour4159 at gmail.com) Date: Thu, 24 Apr 2008 03:17:59 -0700 (PDT) Subject: crack xp Message-ID: <7e771bbf-af51-40a3-93f7-ae02a3b31180@w7g2000hsa.googlegroups.com> crack xp http://cracks.12w.net F R E E C R A C K S From kyosohma at gmail.com Thu Apr 10 13:24:31 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Thu, 10 Apr 2008 10:24:31 -0700 (PDT) Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: On Apr 10, 12:05 pm, Michel Bouwmans wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > > > Paul Rubin wrote: > > Chris Stewart writes: > >> I've always had an interest in Python and would like to dabble in it > >> further. I've worked on a few very small command line programs but > >> nothing of any complexity. I'd like to build a really simple GUI app > >> that will work across Mac, Windows, and Linux. How painful is that > >> going to be? I used to be really familiar with Java Swing a few years > >> ago. I imagine it will be similar. > >> ... > >> Next, what would you say is the best framework I should look into? > > > If by "best" you mean "easiest", that is probably tkinter, which > > comes with python. It is somewhat rudimentary and the widgets that > > come with it don't look so great. But if you just want to put up > > GUI's with basic functionality and not much glitz, it is ok for most > > such purposes. > > out how to use > > I don't quite agree with you on this. Tkinter may be easy because it is > available by standard in Python, but that's about it in my opinion. The > API, look and performance hit is horrible. You're much better of with PyQt4 > which makes the job really simple. > > MFB > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.7 (GNU/Linux) > > iD8DBQFH/kjhDpaqHmOKFdQRAj+kAJ0d3aHqpv/mh7kSqtDqUFXtJsxi1gCfU5UP > 2Ygw9ttRIYX+ioMyBVUNsVo= > =stR5 > -----END PGP SIGNATURE----- I see a lot of people recommend using pyQt, but they never mention the controversy that surrounds its licensing. There have been many posts on the subject already, but if the OP ever decides to sell anything they create, I've heard that QT's licensing is kind of squirrelly. Maybe this has been straightened out? I looked at the website and found it fairly confusing. And don't you need to download QT itself? Mike From ivory91044 at gmail.com Tue Apr 29 04:57:16 2008 From: ivory91044 at gmail.com (ivory91044 at gmail.com) Date: Tue, 29 Apr 2008 01:57:16 -0700 (PDT) Subject: cooking up crack Message-ID: <6017abd8-3d95-43dd-a895-07e65410820f@a70g2000hsh.googlegroups.com> cooking up crack http://crack.cracksofts.com From cyberco at gmail.com Tue Apr 15 08:21:54 2008 From: cyberco at gmail.com (Berco Beute) Date: Tue, 15 Apr 2008 05:21:54 -0700 (PDT) Subject: webcam (usb) access under Ubuntu Message-ID: I've been trying to access my webcam using Python, but I failed miserably. The camera works fine under Ubuntu (using camora and skype), but I am unable to get WebCamSpy or libfg to access my webcam. First I tried webcamspy (http://webcamspy.sourceforge.net/). That requires pySerial and pyParallel, and optionally pyI2C. Runing WebCamSpy results in: Exception exceptions.AttributeError: "Parallel instance has no attribute '_fd'" in > ignored This seems to come from importing I2C. The application window opens, but there's an error message: NO VIDEO SOURCE FOUND Next I tried libfg (http://antonym.org/libfg). I built it, made the Python bindings and installed it. Unfortunately the following: >>>import fg >>>grabber = fg.Grabber() results in: fg_open(): open video device failed: No such file or directory Since the camera works fine in Ubuntu itself my guess is that the problem is with the python libraries (or even likelier, my usage of them). Is there anybody here that was successful in accessing their webcam on linux using Python? Else I have to reside to Windows and VideoCapture (which relies on the win32 api and thus is Windows-only), something I'd rather not do. Thanks for any help, 2B =============== I am uUsing: WebCam: Logitech QuickCam Pro 400 Ubuntu Python 2.5 From sjmachin at lexicon.net Fri Apr 18 17:57:09 2008 From: sjmachin at lexicon.net (John Machin) Date: Fri, 18 Apr 2008 21:57:09 GMT Subject: Delete rows using xlrd? In-Reply-To: <8bc243c7-2980-4201-9372-94ca8a49d221@x19g2000prg.googlegroups.com> References: <8bc243c7-2980-4201-9372-94ca8a49d221@x19g2000prg.googlegroups.com> Message-ID: <48091932$1@news.mel.dft.com.au> Krishna wrote: > I want to delete some rows (by creating a loop may be) using xlrd. Is > this possible, No. The "rd" in "xlrd" is an abbreviation for "read". It is possible to read the more basic info from an Excel spreadsheet, manipulate it in memory, and write out the results to a new file using another package e.g. pyExcelerator (or xlwt, a bug-fixed fork of pyEx.*). If you can find in the xlrd README or documentation even the vaguest hint that xlrd can be used by itself for changing the contents of an XLS file, please let me know, and I'll reword it. > if not how do I do that with python? Please help Perhaps you could read the concurrent thread where somebody with a name very similar to yours is getting help on a script that uses the pywin32 COM approach :-) From peter at sd-editions.com Wed Apr 16 23:15:27 2008 From: peter at sd-editions.com (Peter Robinson) Date: Thu, 17 Apr 2008 04:15:27 +0100 Subject: DBXML and removeDocument in Python Message-ID: I am trying to add and remove documents in a container in Berkeley/ Oracle DB XML within Python, on Mac OS X Leopard. putDocument works fine, but I keep getting 'attributeError' when I try removeDocument. I can't find any documentation on removeDocument in Python and it is not in the examples.py. My code looks like: results = p.query('//page[@id="I-57-1r"]' xc = p.getcontainer() xm = p.getxmlmanager() uc = xm.createUpdateContext() if results.hasNext() is True: #delete the document! xc.removeDocument('57-1r', uc) #add a new document with the same name xc.putDocument('57-1r' , ', uc) Put document works fine. I can remove the document using removeDocument from the shell, but not from within Python. Help... Peter Robinson: peter at sd-editions.com Scholarly Digital Editions 12 The Old Silverworks 54a Spencer Street Jewellery Quarter Birmingham B18 6JT fax: 44 (0) 121 275 6212 From nagle at animats.com Fri Apr 18 12:40:41 2008 From: nagle at animats.com (John Nagle) Date: Fri, 18 Apr 2008 09:40:41 -0700 Subject: Installing BeautifulSoup with easy_install (broken?) In-Reply-To: References: Message-ID: <4808cc41$0$34569$742ec2ed@news.sonic.net> Larry Bates wrote: > Info: > > Python version: ActivePython 2.5.1.1 > Platform: Windows > > I wanted to install BeautifulSoup today for a small project and decided > to use easy_install. I can install other packages just fine. > Unfortunately I get the following error from BeautifulSoup installation > attempt: easy_install usually seems to make things harder. BeautifulSoup is one single .py file. That's all you need. Everything else is excess baggage. John Nagle SiteTruth From bruno.desthuilliers at gmail.com Tue Apr 8 15:53:58 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Tue, 8 Apr 2008 12:53:58 -0700 (PDT) Subject: Is the Python for statement the same as for each in other languages? References: <9e8bfedb-dc75-4252-84e7-4fb96bbaa6ac@l64g2000hse.googlegroups.com> <661ps1F2ae3jnU1@mid.uni-berlin.de> Message-ID: <4c3eb03b-68f9-45c6-9513-baab20422e20@s8g2000prg.googlegroups.com> On 8 avr, 19:55, "Diez B. Roggisch" wrote: > jmDesktop schrieb: > > > Thank you. It looks like it is, but I wanted to make sure I > > understood. Also, I didn't see a "regular" for loop construct either > > (i=0;i<=10;i++), etc. I'm still new at it, but is there one of those? > > Yes, it's foreach. And for your usecase, use > > for i in xrange(11): > ... Or if you want to both iterate over an iterable and have the 'loop index', use enumerate: for index, item in enumerate('this is a test'): print index, ' : ', item From hexusnexus at gmail.com Sat Apr 5 17:07:22 2008 From: hexusnexus at gmail.com (hexusnexus at gmail.com) Date: Sat, 5 Apr 2008 14:07:22 -0700 (PDT) Subject: [PyGTK] Drawing PNG Message-ID: <6c012288-0847-48ef-ad6c-eecd455d1ee6@b5g2000pri.googlegroups.com> I have some PNGs with transparent backgrounds. How do I draw them using PyGTK? From gagsl-py2 at yahoo.com.ar Mon Apr 21 00:02:56 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 01:02:56 -0300 Subject: Error Handling References: <4dc0cfea0804171219l7e4c749dpfd13f9bb35294e1a@mail.gmail.com> Message-ID: En Thu, 17 Apr 2008 16:19:12 -0300, Victor Subervi escribi?: > try: > cursor.execute(sql) > print '?Exito en introducir!
' > print 'Esta p?gina va a regresar a la p?gina principal del carrito > de compras en 10 segundos.' > except IntegrityError: > print 'Lo siento, pero el ID que entraste est? usado actualmente por > otra entrada. Favor de dar para atr?z y escojer otro n?mero.' > except OperationalError: > print 'Lo siento, pero has a?adido un car?cter extra?o a un n?mero (o > en "ID", "precio", "rec?maras" o "ba?os". Favor de dar para atr?z y escojer > otro n?mero.' > except: > print 'Lo siento, pero hay un error. Favor de dar para atr?z y > averiguar donde est? el error, y reintentar.' > When I enter and ID that is not a number, it should trigger the > IntegrityError. Instead, I get this in the error log: > > [Thu Apr 17 12:06:37 2008] [error] [client 190.166.0.245] PythonHandler > mod_python.cgihandler: NameError: global name 'IntegrityError' is not > defined, referer: http://livestocksling.com/bre/iud.py Looks like IntegrityError and OperationalError are defined inside your database module. Either use: from my_database_module import IntegrityError, OperationalError try ... except OperationalError: ... except IntegrityError: ... except Exception: ... or else: import my_database_module try ... except my_database_module.OperationalError: ... except my_database_module.IntegrityError: ... except Exception: ... It's the same as any other symbol, like math.sqrt or os.rename Note that I've not used a bare except: clause; it's not a good idea. sys.exit() raises the SystemExit exception, and pressing Ctrl-C raises KeyboardInterrupt; a bare except: will catch them, effectively nullifying the intended purpose. -- Gabriel Genellina From abuse at tpnet.pl Tue Apr 8 06:19:57 2008 From: abuse at tpnet.pl (Soltys) Date: Tue, 08 Apr 2008 12:19:57 +0200 Subject: Looking for Conferences/Events on Django, Python, MySQL, etc in Europe 2008? In-Reply-To: <7fb0f408-1a2e-4ee1-a179-092f83eb1591@8g2000hsu.googlegroups.com> References: <7fb0f408-1a2e-4ee1-a179-092f83eb1591@8g2000hsu.googlegroups.com> Message-ID: > Greetings! > > I'm looking for conferences or events about Python, Django, Dabatases, > Mysql, > PHP, Ruby in Europe (or nearby locations like north africa and middle > east) in 2008. > Do you have any suggestions? > > Thanks a lot! Hello, Every year starting from 2007 in April there's a RuPy (www.rupy.eu) conference in Poznan (Poland). Unfortunately this year's registration has already finished (on April 7th). Nevertheless you could always give it a try and contact organizers :) And of course there's EuroPython in Vilnius (Lithuania), more can be found on http://www.europython.org/community Any other information can be found on http://www.python.org/community/workshops/ Regards, Soltys From steve at holdenweb.com Tue Apr 1 15:37:09 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 01 Apr 2008 15:37:09 -0400 Subject: Why prefer != over <> for Python 3.0? In-Reply-To: <878wzyyqkf.fsf@physik.rwth-aachen.de> References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> <659gb2F2f84eoU2@mid.individual.net> <87hceo73ap.fsf@physik.rwth-aachen.de> <65anbqF2fg18bU1@mid.individual.net> <87r6drjss4.fsf@physik.rwth-aachen.de> <65c0bfF2ffipiU1@mid.individual.net> <878wzyyqkf.fsf@physik.rwth-aachen.de> Message-ID: <47F28EE5.5080506@holdenweb.com> Torsten Bronger wrote: > Hall?chen! > > Jorge Vargas writes: > >> On Tue, Apr 1, 2008 at 6:03 AM, Gabriel Genellina >> wrote: >> >>> [...] >>> >>> I think it should be easy to add support for ??? and even ?, >>> only the tokenizer has to be changed. >>> >> show me a keyboard that has those symbols and I'm all up for it. > > For <= I have to press three buttons, for ? I have to press four > buttons. Not much of a difference. ;-) > > However, I'm slightly disappointed with the UTF-8 support in some > mail clients involved in this thread, so Unicode surely has not > arrived yet. > I'd settle for a program listing utility that made the replacements. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From nospam at nospam.com Fri Apr 4 12:43:36 2008 From: nospam at nospam.com (3c273) Date: Fri, 4 Apr 2008 09:43:36 -0700 Subject: Looking for Advanced Python Tutorials References: <440c1624-ad9d-4038-bce5-68a2b4ed539a@e10g2000prf.googlegroups.com> Message-ID: Thanks for this. Louis "Ravi Kotecha" wrote in message news:440c1624-ad9d-4038-bce5-68a2b4ed539a at e10g2000prf.googlegroups.com... > On Apr 4, 12:58 pm, cokofree... at gmail.com wrote: > > I was wondering if anyone knew of some online (free if possible) > > advanced tutorials, especially ones that provides tasks and ideas for > > small projects. The issue for myself is I want to improve my python > > programming level, and my ability to program in general, but come up > > blank thinking of a possible task or project to undertake. So with > > that in mind I thought I'd ask the community if they knew of sites or > > books to read up on and use as a starting block. Of course project > > ideas would be great as well! > > > > Thanks for any help you can provide. > > > > Coko > > Project Euler is a site where you work through mathematical problems > using any programming language you like. > > Once you solve a problem you can see everyone elses solutions and > Python is quite popular on that site so you'll see some very clever > uses of Python there. > > I like it a lot for when I haven't got anything better to code: > http://projecteuler.net/ > > - Ravi From Lie.1296 at gmail.com Tue Apr 22 04:37:10 2008 From: Lie.1296 at gmail.com (Lie) Date: Tue, 22 Apr 2008 01:37:10 -0700 (PDT) Subject: question about the mainloop References: <52de38c4-3d1e-4be0-9b58-5d60317f1ef7@b1g2000hsg.googlegroups.com> Message-ID: <1d7054fb-672e-4d2d-9dfc-efdccf818353@p25g2000pri.googlegroups.com> On Apr 21, 6:24 am, globalrev wrote: > in C?? java etc there is usually: > > procedure 1 > procedure 2 > procedure 3 > > main { > procedure 1 > procedure 2 > procedure 3 > > } > > i dont get the mainloop() in python. i mean i have written some > programs, for example a calculator using tkinterGUI. > > if i have some functions i wanna call to run the program and i wanna > call them ina specific order and be able to call > them from each other should this just be called in the mainloop and > the mianloop then runs the "mainscript" top > to bottom over and over? In Python+Tkinter (and I believe, all event-driven programming model), the codes you write are all used for setting up the GUI, specifying where they're placed, what happens when they're clicked, etc, etc, etc. And entering the main loop means the event "manager" (a.k.a mainloop) would start checking all the registered events and respond to the event by calling the associated function you determined at the setup. This event "manager" loops itself over and over until it received an event that tells them to stop listening and quit the program (usually binded with the close button). In some event-driven programming model (like in Visual Basic, don't know about Java, never used it), the setup phase is hidden from you and is done automagically by the GUI designer, and when the setup phase finishes (the mainloop is called), the first event that happens is a programhasjuststarted event, which is automagically bound with a startup function, in VB: the Main Form's OnLoad Event or a Main function. From tkpmep at hotmail.com Fri Apr 11 23:09:22 2008 From: tkpmep at hotmail.com (tkpmep at hotmail.com) Date: Fri, 11 Apr 2008 20:09:22 -0700 (PDT) Subject: Rpy - partially blank R window Message-ID: <197eb1a6-8ccd-4d70-8b99-c33d05cf81f7@a1g2000hsb.googlegroups.com> I have just installed R and Rpy, and am experiencing an odd problem when driving R from Python - if I create a plot in R, the portion of the plot window that lies under the IDLE window in which I type my Python code remains blank. So if I type >>> from rpy import * >>> x = range(10) >>> y = [i ** 2 for i in x] >>> r.plot(x,y) I get a plot of y vs. x, but only the top right portion of the plot shows any points, axes etc. The bottom left corner (the portion that lay under the IDLE window) is blank. Is this a known problem?If so, is there a fix? Sincerely Thomas Philips From colas.francis at gmail.com Tue Apr 15 12:25:08 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Tue, 15 Apr 2008 09:25:08 -0700 (PDT) Subject: use object method without initializing object References: Message-ID: On 15 avr, 17:43, Robert Bossy wrote: > Reckoner wrote: > > would it be possible to use one of an object's methods without > > initializing the object? > > > In other words, if I have: > > > class Test: > > def __init__(self): > > print 'init' > > def foo(self): > > print 'foo' > > > and I want to use the foo function without hitting the > > initialize constructor function. > > > Is this possible? > > Hi, > > Yes. It is possible and it is called "class method". That is to say, it > is a method bound to the class, and not to the class instances. > In pragmatic terms, class methods have three differences from instance > methods: > 1) You have to declare a classmethod as a classmethod with the > classmethod() function, or the @classmethod decorator. > 2) The first argument is not the instance but the class: to mark this > clearly, it is usually named cls, instead of self. > 3) Classmethods are called with class objects, which looks like this: > ClassName.class_method_name(...). > > In your example, this becomes: > > class Test(object): > def __init__(self): > print 'init' > @classmethod > def foo(cls): > print 'foo' > > Now call foo without instantiating a Test: > Test.foo() To be complete, you can also define a static method that will not even be passed the class as argument: In [217]: class Test(object): .....: def __init__(self): .....: print 'init' .....: @staticmethod .....: def foo(): .....: print 'foo' .....: In [218]: Test.foo() foo From tinnews at isbd.co.uk Fri Apr 4 16:43:31 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 04 Apr 2008 20:43:31 GMT Subject: Is there any way to say ignore case with "in"? Message-ID: <47f692f3$0$759$bed64819@news.gradwell.net> Is there any way in python to say if string1 in string2: ignoring the case of string1 and string2? I know I could use:- if lower(string1) in lower(string2): but it somehow feels there ought to be an easier (tidier?) way. -- Chris Green From enleverlesX.XmcX at XmclaveauX.com Tue Apr 8 11:56:58 2008 From: enleverlesX.XmcX at XmclaveauX.com (Méta-MCI (MVP)) Date: Tue, 8 Apr 2008 17:56:58 +0200 Subject: List open files In-Reply-To: References: <47fb8d54$0$15068$426a74cc@news.free.fr> Message-ID: <47fb9789$2$881$ba4acef3@news.orange.fr> Hi! > OpenFiles.exe OK, on a standard CPU/windows. On a server, use: Net File @-salutations -- Michel Claveau From dave.l.harrison at gmail.com Thu Apr 10 06:12:02 2008 From: dave.l.harrison at gmail.com (David Harrison) Date: Thu, 10 Apr 2008 20:12:02 +1000 Subject: Sorting Directories from files in a os.listdir?? In-Reply-To: <9354f263-b833-4845-a226-1ad3a47b1e6a@p25g2000pri.googlegroups.com> References: <9354f263-b833-4845-a226-1ad3a47b1e6a@p25g2000pri.googlegroups.com> Message-ID: On 10/04/2008, Soren wrote: > Hi, > > I'd like to read the filenames in a directory, but not the > subdirectories, os.listdir() gives me everything... how do I separate > the directory names from the filenames? Is there another way of doing > this? The only thing I can think of if you just want the immediate dir is to use the os.path module's function isfile to test each item from the list returned by os.listdir. This should do the trick I think: [ f for f in os.listdir('pathname') if os.path.isfile(f) ] cheers Dave From soren.skou.nielsen at gmail.com Tue Apr 29 06:45:27 2008 From: soren.skou.nielsen at gmail.com (Soren) Date: Tue, 29 Apr 2008 03:45:27 -0700 (PDT) Subject: SWIG Python undefined reference References: <23b925ce-cfa5-4a99-bad3-afcac09b645a@y21g2000hsf.googlegroups.com> Message-ID: <462b5bb4-cfa4-4132-8f97-a609da6908df@8g2000hse.googlegroups.com> On Apr 29, 11:31 am, Soren wrote: > Ok I found out how to do it using: > > gcc -Ic:\python24\include -Lc:\python24\libs --shared example_wrap.c > example.c -lpython24 -o _example.pyd > > but now I get a "dynamic module does not define init function" error > when I try to import it into python.. > > Anyone?? > > Soren In case anyone is having the same problem the solution for me was: gcc example.c example_wrap.c -Ic:\python24\include -Lc:\python24\libs - lpython24 -Xlinker -expoert-dynamic -shared -o _example.pyd Soren From Lie.1296 at gmail.com Sun Apr 27 08:38:43 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 27 Apr 2008 05:38:43 -0700 (PDT) Subject: Loading associated files References: <74862697-da58-4eb7-8d60-09aaef54b7ad@j22g2000hsf.googlegroups.com> Message-ID: <09337541-0b3e-4aaf-b26f-06a0f689e7dc@u12g2000prd.googlegroups.com> On Apr 24, 10:14 pm, flarefi... at googlemail.com wrote: > I am trying to make a a simple databasing GUI interface and and have > created a module to deal with parsing the data from a file and a GUI > based program that displays this data using PyQt4, i know how to > register files in the system registry using python and also using Inno > Setup which i use to package my applications, but i cant work out how > if a file is doubled clicked on to send the path of that file to > python. Do you mean: when a file with "your extension" is double clicked on, then Windows should pass the path of that file to "your application" that is written in Python? (snip) On Apr 26, 7:26 pm, flarefi... at googlemail.com wrote: > I can't get this to work (I am on XP SP2 by the way and using Python > 2.5), > > I wrote a very simple script to test the idea: > > import sys > > for arg in sys.argv: > print arg > > raw_input("Done") #Merely to slow the program down so i can see output > > and then setup a file extension .xyz, placed it in the registry, can > get a .xyz file to work as a python script so the registry setup is > fine, but when i try and put the parameter to the above program and a > %1 (or even without) it gets the following error message from windows: > > C:\...\hmm.xyz is not a valid Win32 application. > > any suggestions?? Windows seems to be trying to execute your file.xyz as an application, this means it hasn't associated your extension (.xyz) with your application, instead .xyz is associated as an executable. To associate your extension with your application, see: http://msdn2.microsoft.com/en-us/library/bb776883.aspx It's a bit advanced NOT TESTED: # Create or edit Registry Key: 'HKEY_CLASSES_ROOT\.xyz' # Change the value for the key 'HKEY_CLASSES_ROOT\.xyz:' into 'MyApp' # Create or edit Registry Key: 'HKEY_CLASSES_ROOT\MyApp\Shell\Open \Command' # Change Registry Key value for 'HKEY_CLASSES_ROOT\MyApp\Shell\Open \Command' into: '"C:\pathtomyapp\myapp.py" "%1"' Check an existing registry key, how they do it. From frikker at gmail.com Wed Apr 30 14:14:47 2008 From: frikker at gmail.com (blaine) Date: Wed, 30 Apr 2008 11:14:47 -0700 (PDT) Subject: Simple TK Question - refreshing the canvas when not in focus References: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> <4818349e$0$2959$ba620e4c@news.skynet.be> <182ace66-bdf6-409c-85ee-fd764de8e1c6@z72g2000hsb.googlegroups.com> Message-ID: <5e13015e-af99-4595-9c10-62a2bc42310c@j22g2000hsf.googlegroups.com> On Apr 30, 10:41 am, Peter Otten <__pete... at web.de> wrote: > blaine wrote: > > Still doesn't work. I'm looking into using wx instead... > > > This is the full code - does it work for anyone else? Just do a echo > > 'line 0 0 10 10' > dev.file > > Haven't tried it, but I think that the problem is that you are updating the > UI from the "readthread". A good example to model your app after is here: > > http://effbot.org/zone/tkinter-threads.htm > > Peter I had a feeling thats what the problem is. Thank you for that link - I am in need of a good model. Thanks for answering both of my questions today, Peter. :) -Blaine From stef.mientki at gmail.com Fri Apr 11 17:39:19 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Fri, 11 Apr 2008 23:39:19 +0200 Subject: How is GUI programming in Python? In-Reply-To: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> Message-ID: <47FFDA87.3070703@gmail.com> Rune Strand wrote: > On Apr 10, 3:54 am, Chris Stewart wrote: > ... > >> Next, what would you say is the best framework I should look into? >> I'm curious to hear opinions on that. >> > > GUI-programming in Python is a neanderthal experience. What one may > love with console scripts is turned upside-down. Projects like Boa > Constructor seemed to be a remedy, but is not developed. The Iron- > Pythonistas has a very promising RAD GUI-tool in the IronPython - > Studio, http://www.codeplex.com/IronPythonStudio - but if you're non- > Iron, only sorrow is left - unless you fancy creating GUI in a text- > editor. Something I consider waste of life. > > Although not as simple as Delphi, wxPython is still quit simple: GUI = """ self.Splitter_Plots ,SplitterVer self.Panel ,PanelVer, 010 self.Panel_Top ,PanelHor, 11 label1 ,wx.StaticText ,label = "Signal1" label2 ,wx.StaticText ,label = "Signal2" self.Panel_X ,wx.Panel, 11 self.Panel_Bottom ,PanelHor label11 ,wx.StaticText ,label = "Signal1b" label12 ,wx.StaticText ,label = "Signal2b" Panel_B ,wx.Panel Button_1 ,wx.Button ,label = "Test" Button_2 ,wx.Button ,label = "Test2", pos = (100,0) """ exec ( Create_wxGUI ( GUI ) ) cheers, Stef From wongjoekmeu at yahoo.com Fri Apr 25 16:42:17 2008 From: wongjoekmeu at yahoo.com (wongjoekmeu at yahoo.com) Date: Fri, 25 Apr 2008 13:42:17 -0700 (PDT) Subject: display monochromatic images wxPython Message-ID: <43c2ef33-b08c-4161-b170-16ab346628d7@m36g2000hse.googlegroups.com> Dear All, I want to write a GUI program with wxPython displaying an image. But the image I have is monochromatic. When I retrieve the data from the image I end up with a list of integer. Starting from a list of integer and knowing the width and height of the image, how do I display such an image on a wx panel or frame ? I have had a look at the wxPython demo but there I see only images where the data is a list of tuple consisting of r,g ,b values. Is there are function where I directly can input the list of array and let it display the image ? Thanks in advance RR From rpmuller at gmail.com Sat Apr 19 16:51:25 2008 From: rpmuller at gmail.com (Rick Muller) Date: Sat, 19 Apr 2008 13:51:25 -0700 (PDT) Subject: Frame work for simple physics web applications References: <2b0b8b6c-8086-4bf6-8f47-27bc5c9c788c@v23g2000pro.googlegroups.com> <6bdd161d-6e92-4de6-8dba-d5c11b08990f@a22g2000hsc.googlegroups.com> Message-ID: On Apr 19, 2:44 pm, globalrev wrote: > > www.vpython.orgmight be what you are looking for. Except, if I'm not mistaken, vpython isn't a web framework. It would work if I wanted to write some python scripts and have other people run them, but I want to run everything through a web page, so I don't have to worry about installing python on everyone's computer and distributing updates of all of my scripts. From ferrarinikap at gmail.com Thu Apr 17 09:42:29 2008 From: ferrarinikap at gmail.com (ferrarinikap at gmail.com) Date: Thu, 17 Apr 2008 06:42:29 -0700 (PDT) Subject: ***CABONGA*** Message-ID: <79292f68-bc67-4b5b-ba9b-d536ff8a4580@d1g2000hsg.googlegroups.com> ****CABONGA*** Listen the amazing Cabong's song!!! http://lacabonga.splinder.com/ From steve at holdenweb.com Fri Apr 25 00:01:33 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 25 Apr 2008 00:01:33 -0400 Subject: Remove old version before upgrade? In-Reply-To: References: Message-ID: Sal wrote: > I'm currently running Windows version 2.5.1 and would like to upgrade > to 2.5.2. My question is, can I just go ahead and install the new > version over the old or should I remove the old version with add/ > remove programs first? The old version is in a directory named > Python25. You can do either. Since there's no change of major version the executable will have the same path, and the deinstall handily leaves all files that weren't part of the original install in place. So if it suits your sense of neatness, by all means deinstall before reinstallation. Note that this *doesn't* work for (say) 2.4 to 2.5, since they can coexist. In that case normally the most recently installed version will be the default. I had a Windows system a while back with 2.1 through 2.5 installed, and 2.4 as the default. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gherron at islandtraining.com Wed Apr 16 11:43:42 2008 From: gherron at islandtraining.com (Gary Herron) Date: Wed, 16 Apr 2008 08:43:42 -0700 Subject: Image handling - stupid question In-Reply-To: <0001HW.C42BCC38001425DCB04379AF@news.individual.de> References: <0001HW.C42B9FB90009B7E8B01AD9AF@news.individual.de> <0001HW.C42BCC38001425DCB04379AF@news.individual.de> Message-ID: <48061EAE.7050007@islandtraining.com> Jumping Arne wrote: > On Wed, 16 Apr 2008 12:21:13 +0200, Jumping Arne wrote > (in article <0001HW.C42B9FB90009B7E8B01AD9AF at news.individual.de>): > > >> I'm going to try to write some imange manipulation code (scaling, reading >> EXIF and IPTC info) and just want to ask if PIL is *THE* library to use? >> >> I looked at and noticed that the >> latest version is from Dec 2006. >> >> In my experience that means that either it's abandoned or that it's very good >> > > >> and stable. >> >> > > Sounds like PIL is a safe option, thanks. > Yes, certainly, PIL is the way to go. But beyond that, if you are going to do any fancy manipulation of the array of pixels (e.g., image processing, image recognition, convolution, ...), then I'd recommend numpy for the array manipulation. (And perhaps even the full-blown scipy.) Numpy can easily access and manipulate the pixel arrays produced by PIL. It's an awesome combination. Gary Herron From x31equsenet at gmail.com Sat Apr 19 06:13:19 2008 From: x31equsenet at gmail.com (Graham Breed) Date: Sat, 19 Apr 2008 03:13:19 -0700 (PDT) Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> Message-ID: On Apr 19, 3:16 am, Joseph Turian wrote: > Basically, we're planning on releasing it as open-source, and don't > want to alienate a large percentage of potential users. How about Java users? Jython was recently at 2.2 (still is for all I know). I'm pleased they've got that far because I like to know that my code can run under Java and I like generators. My web host uses 1.5.2. That is painful. If you're assuming your potential users already have 2.4 then the chances are they'll have upgraded to 2.5 by the time you've finished anyway. Graham From paddy3118 at googlemail.com Tue Apr 1 15:02:39 2008 From: paddy3118 at googlemail.com (Paddy) Date: Tue, 1 Apr 2008 12:02:39 -0700 (PDT) Subject: deleting a line from a file References: <13usb5ngt26qv26@corp.supernews.com> <7xy781zqkq.fsf@ruckus.brouhaha.com> Message-ID: On Apr 1, 6:32 pm, Mark Wooding wrote: > Paddy wrote: > > Why not use the fileinput modules functionality to iterate over a file > > in-place,printing just those lines you want? > > From the Python 2.5 manual: > > : *Optional in-place filtering:* if the keyword argument `INPLACE=1' is > : passed to `input()' or to the `FileInput' constructor, the file is > : moved to a backup file and standard output is directed to the input > : file (if a file of the same name as the backup file already exists, it > : will be replaced silently). > > This behaviour is very dangerous. If the script fails half-way through, > it will leave the partially-written file in place, with the `official' > name. The change-over is not atomic, breaking other programs attempting > to read simultaneously with an update. I've used this methodology all the time both explicitely writing utilities like that and using 'perl -p -i -e ...' theoretically there may be problems. In practice I have people transforming files in their own workarea, and have never been called to clear-up after such a failing. Although theoretically you can describe a method of failure, I take issue with you calling it 'very dangerous' without further qualification. > > Two almost-simultaneous updates will corrupt the file without a usable > backup. The first will back up the input file, and start writing. A > second will /replace/ the backup file with the partially-constructed > output of the first, and then start processing it; but since its input > is incomplete, it will produce incomplete output. Ahah - the qualification. The above would be dangerous, but the OP may find that his current flow, or a slight modification of it will make simultaneous updates unlikely and use of fileinput OK. If not, then other methods may have to be employed. It _is_ good to know the threat and do the analysis though. - Paddy. From gnewsg at gmail.com Sun Apr 6 10:50:41 2008 From: gnewsg at gmail.com (Giampaolo Rodola') Date: Sun, 6 Apr 2008 07:50:41 -0700 (PDT) Subject: RELEASED Python 2.6a2 and 3.0a4 References: <47F68547.1040802@v.loewis.de> Message-ID: On 6 Apr, 00:55, John Machin wrote: > On Apr 5, 5:45 am, "Martin v. L?wis" wrote: > > > > The Windows x86 MSI installer is missing for both 2.6 and 3.0. > > > And likely will continue to do so for some time. > > Someone's got strange definitions of "missing"! > > For each there's a link on the the ptyhon.org website, and a caveat > about non-Administrator installation ... > > If it's missing, then what do I expect to find in the 11.7Mb 2.6a2 msi > that is downloading as I type? At the time I replied they were both missing (in fact that's why I replied :-)). --- Giampaolo http://code.google.com/p/pyftpdlib From Dodin.Roman at gmail.com Fri Apr 25 07:24:51 2008 From: Dodin.Roman at gmail.com (hellt) Date: Fri, 25 Apr 2008 04:24:51 -0700 (PDT) Subject: Little novice program written in Python References: Message-ID: <2caefd7f-dd6b-40a0-877f-3f7df0e70138@8g2000hse.googlegroups.com> On 25 ???, 15:02, Max M wrote: > Rog?rio Brito skrev: > > > Hi, All. > > > What I would like is to receive some criticism to my code to make it > > more Python'esque and, possibly, use the resources of the computer in a > > more efficient way (the algorithm implemented below is the Sieve of > > Eratosthenes): > > I agree with the rest here. Your code generally looks fine. > > But on another note, this type of code is not something you often see in > Python. It is very dense with regard to algorithm. > > Most code is not like that so perhaps you should try something more > "usual" like sending email, fetching webpages etc. to get a feel for the > language. > > -- > > hilsen/regards Max M, Denmark > > http://www.mxm.dk/ > IT's Mad Science em, i would say, that python (esp. with NumPy+Psyco) is very popular in numerical processing also. From s0suk3 at gmail.com Thu Apr 17 13:26:51 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 10:26:51 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> Message-ID: On Apr 17, 12:07 pm, Sion Arrowsmith wrote: > wrote: > >In Python, you usually can use parentheses to split something over > >several lines. But you can't use parentheses for an assignment of > >several lines. > > Yes you can, you just need an iterable of the right length on > the other side for the tuple unpacking to work: > > >>> (CONSTANT1, > > ... # This isn't a syntax error > ... CONSTANT2, > ... CONSTANT3, #and neither is this > ... CONSTANT) = [1] * 4>>> [ (k, v) for k, v in locals().items() if k.startswith("CONSTANT") ] > > [('CONSTANT', 1), ('CONSTANT1', 1), ('CONSTANT3', 1), ('CONSTANT2', 1)] > That's not the same kind of multiple assignment. There, you're just unpacking several items from a sequence into several variables on the left. Some would say that's a list assignment. From steve at holdenweb.com Sat Apr 12 00:43:54 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 00:43:54 -0400 Subject: How is GUI programming in Python? In-Reply-To: References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> Message-ID: Rune Strand wrote: > On Apr 11, 8:35 pm, Steve Holden wrote: >> wxDesigner. > > Yeah, but it's like Heron of Alexandria's Aeolipile compared to the > steam engine of James Watt. > > IMHO, GUI with Python is pain, pain and utter pain. Even boring and > meaningless pain. IMHO you are a troll, troll, and utter troll. Even boring and meaningless troll. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From steve at holdenweb.com Tue Apr 8 17:33:45 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 17:33:45 -0400 Subject: new user needs help! In-Reply-To: <47FBDA77.1030009@tim.thechases.com> References: <16571823.post@talk.nabble.com> <47FBDA77.1030009@tim.thechases.com> Message-ID: <47FBE4B9.4030705@holdenweb.com> Tim Chase wrote: >> f = open("/tmp/data.txt", 'w') >> >> will open that file. >> >> You can throw the first line away with >> >> headings = f.next() >> >> Then you can loop over the rest with >> >> for name, aa, topo, access, dssp, stride, z in file: >> # >> # Then process each line here > > > Small caveat here...Steve changed file-variables on you here, and > assumed a tuple-unpacking that won't work. You'll want something like > > for line in f: > (name, aa, topo, access, dssp, stride, z) = ( > line.rstrip('\n').split('\t') > # process the line here > > I don't know how your fields are delimited, whether by spaces or tabs. > In the above code, I split by tabs, but you can just use .split() if it > should be split on any white-space. It's a bit more complex if you need > to split by column-offsets. > Hmm, perhaps I shoudl wait until I get my brain fixed before I post again! Sorry, Tim, I got distracted and shouldn't have tried to dash off the post before coping with the distraction. Just a minor flood in the basement ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From webograph at eml.cc Sun Apr 27 17:13:20 2008 From: webograph at eml.cc (webograph) Date: Sun, 27 Apr 2008 23:13:20 +0200 Subject: Why can't timedeltas be divided? In-Reply-To: <4814b7c7$0$30314$9b622d9e@news.freenet.de> References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> <48142747$0$20906$9b622d9e@news.freenet.de> <4814b7c7$0$30314$9b622d9e@news.freenet.de> Message-ID: <4814EC70.5000304@eml.cc> On 2008-04-27 19:28, Martin v. L?wis wrote: > Post a patch to bugs.python.org, optionally also post a message > referring to that patch to python-dev. i've created an issue at [1]. let's hope for the best! thanks for your support webograph [1] http://bugs.python.org/issue2706 From jeremy.wagner at laposte.net Thu Apr 17 12:52:45 2008 From: jeremy.wagner at laposte.net (=?ISO-8859-1?Q?J=E9r=E9my_Wagner?=) Date: Thu, 17 Apr 2008 18:52:45 +0200 Subject: How to know if a module is thread-safe Message-ID: <4807805b$0$884$ba4acef3@news.orange.fr> Hi, I recently tried to use the subprocess module within a threading.Thread class, but it appears the module is not thread-safe. What is the policy of python regarding thread-safety of a module ? From rodmena.com at gmail.com Fri Apr 25 00:48:37 2008 From: rodmena.com at gmail.com (Farsheed Ashouri) Date: Thu, 24 Apr 2008 21:48:37 -0700 (PDT) Subject: wxpython and IEHtmlWindow, Focus Problem. Message-ID: Hi everyone. I create a little browser with wxpython and IEHtmlWindow. But I have a little problem here. When I press enter in the html page, The focus goes to another panel. Why this happens? I want to load a html page and it have textares and user should able to press enter inside html page. This is the code for creating it: #===================Code Begin ========================== class PageOne(wx.Panel): def __init__(self, parent): wx.Panel.__init__( self, parent, -1, style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN| wx.NO_FULL_REPAINT_ON_RESIZE ) self.sizer = wx.BoxSizer(wx.HORIZONTAL) import wx.lib.iewin as iewin a = iewin.IEHtmlWindow(self, -1 ) #a.LoadUrl('file:///E:/Ducuments/EL%20Software%20Project/ mainSoft/xmlParser/HTML/learn/less2.html') self.sizer.Add(a, 3, wx.EXPAND,1) self.SetSizer(self.sizer) #self.Bind(wx.EVT_TEXT_ENTER , self.OnKeyPress, a) config.CurrentNotebook = a #===================Code End========================== Thanks in advance. From mfb.chikazuku at gmail.com Sun Apr 13 05:09:31 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Sun, 13 Apr 2008 11:09:31 +0200 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <47ff8489$0$6841$2d805a3e@textnews.eweka.nl> <48010fe5$0$6840$2d805a3e@textnews.eweka.nl> <87ve2mx5nb.fsf@physik.rwth-aachen.de> Message-ID: <4801dc1c$0$6840$2d805a3e@textnews.eweka.nl> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Torsten Bronger wrote: > Hall?chen! Und auch ein hallo, aus den Niederlanden! :P > Michel Bouwmans writes: > >> Gabriel Genellina wrote: >> >>> Michel Bouwmans escribi?: >>> >>>> Gabriel Genellina wrote: >>>> >>>>> Another annoying thing with the Qt license is that you have to >>>>> choose it at the very start of the project. You cannot develop >>>>> something using the open source license and later decide to >>>>> switch to the commercial licence and buy it. >>>> >>>> Unless you're a company with a risk of being checked for legal >>>> software etc., you can always ignore that allthough not very >>>> legal. >>> >>> I just ignore Qt itself. >> >> Then you're ignorant. What do you prefer than? > > Well ... don't expect answers that you like when you suggest doing > something which is not allowed. > >> [...] >> - WxPython is terribly unstable. > > I can't confirm that. When I chose wxPython after thorough > consideration one year ago, my impression was that reports of > instability were indeed frequent but rather old. Apparently, the > situation had improved. Does your experience rely on recent use? > > Tsch?, > Torsten. > About half a year/a year ago. Segfaults is simply not something I like to see when I use an API binding. For me it didn't feel that right when using it so I made the temporary switch to Tkinter. greetz MFB -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFIAc3PDpaqHmOKFdQRAi3PAJ4idF7KLdOQfpfARBjA839wyKBQAQCcDIMA GX41PYj5t+ap8nEwkWRtb4Q= =LTVd -----END PGP SIGNATURE----- From willem at stack.nl Mon Apr 14 08:13:20 2008 From: willem at stack.nl (Willem) Date: Mon, 14 Apr 2008 12:13:20 +0000 (UTC) Subject: Game design : Making computer play References: Message-ID: Richard wrote: ) Here's the board (which bears only a slight resemblance to one I'd seen on ) the Web): ) ) +---------------+ ) | HORN $ | ) +---+---+---+---+---+---+ ) |L W| | $ | $ | |R W| ) +E-I+--CHEST+---+---+I-I+ ) |F N| | | | |G N| ) +T-G+---+---+---+---+H-G+ ) | | | | | |T | ) +---+---+---+---+---+---+ ) | LEGS| | | ) +---+---+---+---+ ) ) There are three tigers and fifteen goats. ) The tigers' goal is to eat all the goats and remain mobile. ) It seems that the initial tiger positions are: one on the horn, and one ) each on CHEST-2 and CHEST-3 (see $ marks, above). ) The goats' goal is to block the tigers from moving. ) The goats are placed one by one. ) Tigers appear only to be able to move orthogonally (up/down/left/right) - ) although they can use the horn to whizz across the chest (e.g. CHEST-1 to ) HORN, HORN to CHEST-4, in two moves). ) The rest of the rules are beyond me, I'm afraid. It's not clear how tigers ) eat goats or how goats block tigers. If it's similar to the 'other' goats and tigers game, a tiger eats a goat by jumping over it, for which the square behind it needs to be empty, obviously. SaSW, Willem -- Disclaimer: I am in no way responsible for any of the statements made in the above text. For all I know I might be drugged or something.. No I'm not paranoid. You all think I'm paranoid, don't you ! #EOT From j.foster.davis at gmail.com Wed Apr 2 19:09:34 2008 From: j.foster.davis at gmail.com (Jacob Davis) Date: Wed, 2 Apr 2008 16:09:34 -0700 Subject: Module not found in script that was found in command-line interpreter. Possible Path issue? Message-ID: <8463F6F2-4C02-48BC-BF7E-B606D4B41577@gmail.com> Hi. I just installed the MySQLdb module and I have been able to get it to run in my command line interpreter. I am running Mac Leopard, and Python 2.5. I have tested importing and actually connecting and using a MySQL database, although it issues some warning: SnakeBite:MySQL-python-1.2.2 Snake$ python Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import MySQLdb /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- packages/MySQL_python-1.2.2-py2.5-macosx-10.3-fat.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /Library/ Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/ MySQL_python-1.2.2-py2.5-macosx-10.3-fat.egg/_mysql.pyc, but /Library/ Python/MySQL-python-1.2.2 is being added to sys.path import sys, pkg_resources, imp >>> However, while writing a .py script (with Komodo Edit) I try to simply import the module and the in-Komodo interpreter returns an error: Traceback (most recent call last): File "/Users/Snake/Documents/NPS/Thesis/Source_Code/Genetics/ mysql_connect_test.py", line 11, in import MySQLdb ImportError: No module named MySQLdb This script does, however, run fine when I call it from the command- line interpreter. I don't really know much about Paths or anything, all I Know is that to get Komodo to run my Python scripts, I had to tell it that an interpreter is located at /usr/bin/pythonw My goal is to use Komodo (or some simple IDE with syntax checking, and function hinting, and an embedded interpreter - so if you know of any others for Mac Leopard) to write and debug scripts. -Jake # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # >>>>> # >>>>> This file tests the connection to a mysql database ("gene_test") on localhost:3306 # >>>>> it gets all of the data from the table "3_weeks" and prints it # >>>>> # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # import MySQL module import MySQLdb # connect db = MySQLdb.connect(host="localhost", user="customer", passwd="customer", db="gene_test") # create a cursor cursor = db.cursor() # execute SQL statement cursor.execute("SELECT * FROM 3_weeks") # get the resultset as a tuple result = cursor.fetchall() # iterate through resultset for record in result: print record[0] , "-->", record[1] -------------- next part -------------- An HTML attachment was scrubbed... URL: From sbergman27 at gmail.com Thu Apr 17 13:29:48 2008 From: sbergman27 at gmail.com (Steve Bergman) Date: Thu, 17 Apr 2008 10:29:48 -0700 (PDT) Subject: Python module for reading FilePro files? References: Message-ID: <3cfb3411-59e6-411c-99ec-494a15d1d6ef@m71g2000hse.googlegroups.com> Thanks. Yes, there is a php-filepro extension that I could hook up with using the command line interpreter. That may well be what I end up doing. Or maybe port the php extension to python. From gagsl-py2 at yahoo.com.ar Mon Apr 14 05:59:12 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 14 Apr 2008 06:59:12 -0300 Subject: text adventure game problem References: <4fb4fb0d-4cb2-4fcd-a207-a0341d92e82b@8g2000hsu.googlegroups.com> <7e1c3f97-ff17-4add-8d45-40f7b48dec4a@l64g2000hse.googlegroups.com> <17342e68-2593-43cc-aff0-af0e09e75d6d@a22g2000hsc.googlegroups.com> Message-ID: En Fri, 11 Apr 2008 11:21:17 -0300, escribi?: > On Apr 11, 10:16?am, corvettecra... at gmail.com wrote: >> On Apr 11, 1:40?am, Dennis Lee Bieber wrote: >> >> > On Thu, 10 Apr 2008 05:06:42 -0700 (PDT), corvettecra... at gmail.com >> > declaimed the following in comp.lang.python: >> >> > > okay, that explains it... >> > > could you provide a working example of a two-room game using your >> > > method please so I can understand it better? Thanks in advance! >> >> > ? ? ? ? Okay... It isn't the best thought out system -- I have >> too >> > many specific classes... It would probably be better to put actions >> into >> > dictionaries and use some custom .getattr() to handle them. >> > # >> > # ? TAGS.py ? ? Text Adventure Game Shell >> > # >> >> > # ? I've probably defined too many special classes here >> > class Gobject(object): ?#Game object >> > ? ? def __init__(self, name, description, hidden=False, fixed=True): >> > ? ? ? ? self._name = name >> > ? ? ? ? self._description = description >> > ? ? ? ? self.hidden = hidden ? #hidden objects are not visible to >> > EXAMINE >> I still can't run that....after fixing the simple stuff like 'invalid >> syntax', there's the "Name examine is not defined." >> So... You will have to manually fix the long lines that were splitted/wrapped by the mailer program. As a rule-of-thumb, try joining any line (inside a function or class) that you see over the left margin, onto the previous line. By example, the EXAMINE word above should be the last word on its previous line, in fact it's part of the comment. -- Gabriel Genellina From meisnernel73884 at gmail.com Wed Apr 30 06:36:30 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:36:30 -0700 (PDT) Subject: cracks and keygens Message-ID: <6c924404-958e-4abd-a345-1fe72fd60ac5@34g2000hsf.googlegroups.com> cracks and keygens http://crack.cracksofts.com From hexusnexus at gmail.com Wed Apr 2 21:05:38 2008 From: hexusnexus at gmail.com (hexusnexus at gmail.com) Date: Wed, 2 Apr 2008 18:05:38 -0700 (PDT) Subject: Classes in modules Message-ID: <0cace2e1-6dbc-428f-9e53-ffb99ba42aab@e6g2000prf.googlegroups.com> I'm trying to get this source code split into multiple files: http://pygermanwhist.googlecode.com/files/pygermanwhist.12.py I've been trying to make so that I have one class per file for easier readability. My problem is that the interpreter keeps saying that it can't find methods and so forth whenever I try to split the code up. This has been a recurring problem for me in languages such as C++ and Java. I'm used to programming in C. From xdicry at gmail.com Fri Apr 11 05:32:52 2008 From: xdicry at gmail.com (Evan) Date: Fri, 11 Apr 2008 02:32:52 -0700 (PDT) Subject: How to make a "command line basd" interactive program? Message-ID: Hope this hasn't been posted hundreds of times. I'm new for this. Before using python for this kind of script, I was using TCL to write down a "command line based" interactive program. it likes a "tclsh", or "python" command, after that, you can work under a prompt, for example, " - >> ", and then you can execute any commands what you defined in script. Now, in python, are there any common way(class) to finish this work? or does anybody has a example to do that? Thanks, Evan From bvidinli at gmail.com Thu Apr 10 06:45:35 2008 From: bvidinli at gmail.com (bvidinli) Date: Thu, 10 Apr 2008 13:45:35 +0300 Subject: urgent question, about filesystem-files In-Reply-To: <6665rfF2j5ohkU1@mid.uni-berlin.de> References: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> <47FDD27E.1040204@islandtraining.com> <36e8a7020804100200m6c3a9a41h1ed3021b70f8a829@mail.gmail.com> <36e8a7020804100201x5cf16377gfedddc8647fe8e3a@mail.gmail.com> <6665rfF2j5ohkU1@mid.uni-berlin.de> Message-ID: <36e8a7020804100345o3af2f622y6c477f1f6a31dd30@mail.gmail.com> * i do not want to prevent other process access same file, i only want if a file being used as i acess it. * i am not interested if a process will access same file just after i access it... because in my case, this is not possible.. * i want some other way, other than linux lsof command. it is slow for me. is there a native python way, ? thanks. 2008/4/10, Diez B. Roggisch : > bvidinli wrote: > > > this is for ensuring that file is not in use, ... > > by any process in system.... > > > How do you prevent the other processes that *might* access that file from > doing so while *you* work on it? unless they cooperate using file-locks, > you might end up with garbage. > > Diez > > -- > http://mail.python.org/mailman/listinfo/python-list -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From tdimson at gmail.com Wed Apr 2 11:13:16 2008 From: tdimson at gmail.com (Thomas Dimson) Date: Wed, 2 Apr 2008 08:13:16 -0700 (PDT) Subject: Self-referencing decorator function parameters References: <88b2c61e-8cf1-4ac0-a5d4-c968d009b544@c65g2000hsa.googlegroups.com> <232b144b-9e09-4baf-9e87-88b6a1d1fb07@b5g2000pri.googlegroups.com> Message-ID: <80ffac0f-baa3-46ac-8157-fa123e2bee9e@8g2000hse.googlegroups.com> On Apr 2, 10:31?am, George Sakkis wrote: > On Apr 2, 8:30?am, Thomas Dimson wrote: > > > > > > > Hello, > > > Originally I posted this as a bug but it was shot down pretty quickly. > > I am still mildly curious about this as I'm missing a bit of > > understanding of Python here. Why is it that the following code > > snippet: > > > def decorator( call ): > > ? ? def inner(func): > > ? ? ? ? def application( *args, **kwargs ): > > ? ? ? ? ? ? call(*args,**kwargs) > > ? ? ? ? ? ? func(*args,**kwargs) > > ? ? ? ? return application > > > ? ? return inner > > > class DecorateMe: > > ? ? @decorator( call=DecorateMe.callMe ) > > ? ? def youBet( self ): > > ? ? ? ? pass > > > ? ? def callMe( self ): > > ? ? ? ? print "Hello!" > > > DecorateMe().youBet() > > > Will not compile, giving: > > Traceback (most recent call last): > > ? File "badpython.py", line 10, in > > ? ? class DecorateMe: > > ? File "badpython.py", line 11, in DecorateMe > > ? ? @decorator( call=DecorateMe.callMe ) > > NameError: name 'DecorateMe' is not defined > > > Where if you change the "call=DecorateMe.callMe" to "call=lambda x: > > DecorateMe.callMe(x)" everything goes along its merry way. Nesting the > > call in a lambda seems to allow it to recognize the class definition. > > Any ideas as to what is going on here (other than ugly code)? > > The error message is pretty obvious; when the > "@decorator(call=DecorateMe.callMe)" line is reached, the DecorateMe > class has not been created yet, let alone the DecorateMe.callMe > method. One way to make it work (for some definition of "work" ;-) is > the following: > > # use "new-style" classes unless you have a good reason not to: > # class DecorateMe(object): > class DecorateMe: > > ? ? def callMe(self): > ? ? ? ? print "Hello!" > > ? ? @decorator(call=callMe) > ? ? def youBet(self): > ? ? ? ? pass > > The reason this works is that at the point where @decorator is > executed, callMe is already in the temporary namespace to be used for > creating the DecorateMe class (although the class itself is not built > yet). > > A subtle point is that in this case callMe is a plain function, not an > (unbound) method such as DecorateMe.callMe. This may or may not > matter, depending on what you do with it in the decorator. Some > decorators that work fine with plain functions break if they are used > to decorate methods (or vice versa) so it's good to have this in mind > when writing or debugging a decorator. > > George- Hide quoted text - > > - Show quoted text - Thanks George, that was helpful. I guess my real question is: why does wrapping the call to be "call=lambda x: DecorateMe.callMe(x)" somehow fix the issue with this temporary namespace? It seems strange to me that defining an additional function (through lambda) would allow me to see/add more members to the namespace. From victorsubervi at gmail.com Tue Apr 29 14:14:34 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Tue, 29 Apr 2008 13:14:34 -0500 Subject: Colors for Rows In-Reply-To: <20080429121105.f10c3862.darcy@druid.net> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> <20080429121105.f10c3862.darcy@druid.net> Message-ID: <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> On Tue, Apr 29, 2008 at 11:11 AM, D'Arcy J.M. Cain wrote: > On Tue, 29 Apr 2008 09:33:32 -0500 > "Victor Subervi" wrote: > > why doesn't this work? > > First, let me remove some blank lines to reduce scrolling. > > > z = 3 > > > > for d in (1,2,3,4,5,6): > > I changed id to a sequence so that the example actually runs. Please > run your examples first and cut and paste them into the message after > you are sure that it runs. Not sure what you mean here. The example runs. It prints out every time. > > > > z += 1 > > > > if z % 4 == 0: > > bg = '#ffffff' > > elif z % 4 == 1: > > bg = '#d2d2d2' > > elif z % 4 == 2: > > bg = '#F6E5DF' > > else: > > bg = '#EAF8D5' > > > > try: > > print '\n' % bg > > except: > > print '\n' > > > > It never increments z! Yet, if I print z, it will increment and change > the > > bgcolor! Why?! > > I am not entirely sure what you are trying to do here. First, what > error condition are you expecting in your try statement. Second, don't > you want the print clause, with or without the try/except, in the > loop. I assume that you want to print a line for each member of your > sequence in alternating colours but this only prints for the last one. > Try this: > > z = 3 > > for d in (1,2,3,4,5,6): > z += 1 > > if z % 4 == 0: > bg = '#ffffff' > elif z % 4 == 1: > bg = '#d2d2d2' > elif z % 4 == 2: > bg = '#F6E5DF' > else: > bg = '#EAF8D5' > > print '' % bg, d Huh? You?re asking for one variable, then giving two! How?s that work? > > > Or, tell us what you are trying to do. I think you understand. I want the row color to alternate, every fourth row color being the same (or a series of 4) > > > In fact, you can replace all the tests and the print statement with > this after defining bg as a list of the four colours: > > print '' % bg[z % 4], d I tried that just for fun. It gave a bg of ?f?. Again, how are you incorporating d? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From darcy at druid.net Tue Apr 29 12:11:05 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Tue, 29 Apr 2008 12:11:05 -0400 Subject: Colors for Rows In-Reply-To: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> Message-ID: <20080429121105.f10c3862.darcy@druid.net> On Tue, 29 Apr 2008 09:33:32 -0500 "Victor Subervi" wrote: > why doesn't this work? First, let me remove some blank lines to reduce scrolling. > z = 3 > > for d in (1,2,3,4,5,6): I changed id to a sequence so that the example actually runs. Please run your examples first and cut and paste them into the message after you are sure that it runs. > z += 1 > > if z % 4 == 0: > bg = '#ffffff' > elif z % 4 == 1: > bg = '#d2d2d2' > elif z % 4 == 2: > bg = '#F6E5DF' > else: > bg = '#EAF8D5' > > try: > print '\n' % bg > except: > print '\n' > > It never increments z! Yet, if I print z, it will increment and change the > bgcolor! Why?! I am not entirely sure what you are trying to do here. First, what error condition are you expecting in your try statement. Second, don't you want the print clause, with or without the try/except, in the loop. I assume that you want to print a line for each member of your sequence in alternating colours but this only prints for the last one. Try this: z = 3 for d in (1,2,3,4,5,6): z += 1 if z % 4 == 0: bg = '#ffffff' elif z % 4 == 1: bg = '#d2d2d2' elif z % 4 == 2: bg = '#F6E5DF' else: bg = '#EAF8D5' print '' % bg, d Or, tell us what you are trying to do. In fact, you can replace all the tests and the print statement with this after defining bg as a list of the four colours: print '' % bg[z % 4], d -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From hopeorpha308 at gmail.com Sun Apr 27 07:48:54 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:48:54 -0700 (PDT) Subject: spyware doctor 5.0.1.205 crack Message-ID: <5b773422-c40c-4d99-8da2-195a6257da5a@34g2000hsh.googlegroups.com> spyware doctor 5.0.1.205 crack http://wga-cracks.crackkey.net From sjmachin at lexicon.net Sun Apr 6 18:10:51 2008 From: sjmachin at lexicon.net (John Machin) Date: Sun, 6 Apr 2008 15:10:51 -0700 (PDT) Subject: Python Data Utils References: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> <8eec6557-784d-4fd8-8478-8da17aedf0ab@d1g2000hsg.googlegroups.com> Message-ID: <85979669-64ed-49a1-b154-595bed50179f@w5g2000prd.googlegroups.com> On Apr 7, 12:32 am, Jesse Aldridge wrote: > Thanks for the detailed feedback. I made a lot of modifications based > on your advice. Mind taking another look? > > > Some names are a bit obscure - "universify"? > > Docstrings would help too, and blank lines > > I changed the name of universify and added a docstrings to every > function. Docstrings go *after* the def statement. > > > ...PEP8 > > I made a few changes in this direction, feel free to take it the rest > of the way ;) I doubt anyone will bother to take up your invitation. A few simple changes would reduce eyestrain e.g. changing "( " to "(" and " )" to ")". > > > find_string is a much slower version of the find method of string objects, > > Got rid of find_string, and contains. What are the others? It seems that you could usefully spend some time reading the documentation on str methods ... instead of asking other people to do your job for you, unpaid. E.g. look for a str method that you could use instead of at least one of the confusingly named "is_white" and "is_blank"? > > > And I don't see what you gain from things like: > > def count( s, sub ): > > return s.count( sub ) > > Yeah, got rid of that stuff too. I ported these files from Java a > while ago, so there was a bit of junk like this lying around. The penny drops :-) > > delete_string, as a function, looks like it should delete some string, not > > return a character; I'd use a string constant DELETE_CHAR, or just DEL, > > it's name in ASCII. > > Got rid of that too :) > > > In general, None should be compared using `is` instead of `==`, and > > instead of `type(x) is type(0)` or `type(x) == type(0)` I'd use > > `isinstance(x, int)` (unless you use Python 2.1 or older, int, float, str, > > list... are types themselves) > > Changed. Not in all places ... look at the ends_with function. BTW, this should be named something like "fuzzy_ends_with". Why all the testing against None? If you have a convention that "" means that a value is known to be the zero-length string whereas None means that the true value is unknown, then: (1) you should document that convention (2) you should use it consistently e.g. fuzzy_match(None, None) should return False. The get_before function returns None in one case and "" in another; is this accidental or deliberate? > > So, yeah, hopefully things are better now. > > Soon developers will flock from all over the world to build this into > the greatest data manipulation library the world has ever seen! ...or > not... > > I'm tired. Making code for other people is too much work :) When you recover, here are a few more things to consider: 1. Testing if obj is a str or unicode object is best done by isinstance(obj, basestring) ... you don't need an is_string function. 2. make_fuzzy function: first two statements should read "s = s.replace(.....)" instead of "s.replace(.....)". 3. Fuzzy matching functions are specialised to an application; I can't imagine that anyone would be particularly interested in those that you provide. A basic string normalisation-before-comparison function would usefully include replacing multiple internal whitespace characters by a single space. 4. get_after('dog cat', 3) is a baroque and slow way of doing 'dog cat'[3+1:] 5. Casual inspection of your indentation function gave the impression that it was stuffed ... verified by a simple test: >>> for i in range(11): ... stest = ' ' * i + 'x' ... print i, indentation(stest, 4) ... 0 0 1 1 2 0 3 0 4 1 5 2 6 1 7 1 8 2 9 3 10 2 HTH, John From ankitks.mital at gmail.com Fri Apr 4 17:02:48 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Fri, 4 Apr 2008 14:02:48 -0700 (PDT) Subject: having list attribute to track max size Message-ID: Lets say I have a dynamic list class (may be extended from list), where I add and remove items during program. a = [] a.append(1) .... I am trying to find is there easy way keep track of 'maximum size of list reached" so for example len(a) goes from 0->3->4->3 If I call a.max_size_ever(), I will get 4 Thanks. From python at bdurham.com Mon Apr 14 16:30:39 2008 From: python at bdurham.com (python at bdurham.com) Date: Mon, 14 Apr 2008 16:30:39 -0400 Subject: What parts of string module will disappear in Python 3.0? Message-ID: <1208205039.18800.1247843527@webmail.messagingengine.com> I understand that many portions of the string module are redundant with the native methods of strings and will removed in Python 3.0. Makes sense to me. But what will happen to the portions of the string module that are not covered by native string methods - like the following: - string constants (example: string.punctuation) - Template strings - maketrans() Will some semblance of the string module remain in Python 3.0 under the string module name or a new module name? Thanks! Malcolm From sjmachin at lexicon.net Wed Apr 16 18:21:18 2008 From: sjmachin at lexicon.net (John Machin) Date: Wed, 16 Apr 2008 22:21:18 GMT Subject: def power, problem when raising power to decimals In-Reply-To: References: Message-ID: <48067bdb@news.mel.dft.com.au> skanemupp at yahoo.se wrote: > how do i solve power(5,1.3)? Is this a trick question? OK, I'll bite: >>> 5 ** 1.3 8.1032829834638136 >>> > > def power(nbr, po): > if po==0: > return 1 > if po>0: > return nbr*power(nbr, po-1) > if po<0: > return 1/power(nbr, -1*po) > > > also i found a link which states 0^0 isnt 1 even though every > calculator ive tried says it is. > it doesnt say what it is but i presume 0 then. > but it seems the dude is wrong and it is 1? Of the possible results of 0 ** 0 (i.e. 1, 0, and NaN), 1 seems to be the least implausible. It allows X ** 0 to be 1 for all X. > > dont run the code with decimals, it will never leave the function, u > have to restart the shell(if using the standard python ide) I presume that by "decimals", you mean "numbers that are not integers". So you've got it into an infinite loop. Have you tried tracing through the first 5 or 6 gyrations? This can be done by (a) putting a debugger breakpoint just after the start of the function (b) using something like: print "power(%.6f, %.6f)" % (nbr, po)) junk = raw_input("Press to continue -> ") (c) using a pencil and a piece of scrap paper, write down what is happening as a typical function call is executed e.g. power(5, 1.3) => 5 * power(5, 0.3) power(5, 0.3) => 5 * power(5, -0.7) power(5, -0.7) => 1 / power (5, 0.7) etc Then work out what extra condition you would have to test to stop it doing that. Then work out how to calculate the return value when that condition is true. HTH, John From gagsl-py2 at yahoo.com.ar Wed Apr 9 00:55:43 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 01:55:43 -0300 Subject: __init__.py file References: Message-ID: En Tue, 08 Apr 2008 17:51:21 -0300, cesco escribi?: > I need to instantiate an object (my_object) whose methods I have to > use in two files (file1.py and file2.py) which are in the same > directory. Is it possible to instantiate such object in the > __init__.py file and then directly use it in file1.py and file2.py? > If not, as I seem to experience, what is the best practice to follow > in this case? (I thought __init__.py was somehow useful for that). Yes, you can, but consider passing the object as an argument. Global objects aren't necesarily evil, anyway I don't have enough information to make an opinion. If you insist on use the global object, there is another question. __init__.py defines the package namespace, and is the public interfase to it, I would not put an object there that is not supposed to be part of the package public interfase. You can instantiate the object in any other module, and import such module from both file1 and file2. -- Gabriel Genellina From phoolimin at gmail.com Fri Apr 25 18:09:36 2008 From: phoolimin at gmail.com (Limin Fu) Date: Fri, 25 Apr 2008 15:09:36 -0700 (PDT) Subject: ANN: Dao 1.0 preview version is released Message-ID: <67ae05be-a3f1-42ee-942e-5a248ad445de@m36g2000hse.googlegroups.com> Hi, I am please to announce a preview release of Dao (1.0). Dao is a simple yet powerful object-oriented programming language featured by, optional typing, BNF-like macro system, regular expression, multidimensional numeric array, asynchronous function call for concurrent programming etc. Since the last beta release (2006 november), a number of new features have been added to the language with some significant improvements on the implementation. Here I will just list some of them: 1. Added a new typing system, so that the type of an variable can be either declared explicitly or inferred implicitly, and type checking is performed at compiling time when possible. More over the type information is used for function overloading and function specialization (with type-optimized VM instructions) according to paramter types. Some types can be compounded into new types, e.g., list, tuple>... 2. A flexible macro-system that allows writting macro in a form close to BNF, and can be used to define new syntax; 3. Added Asynchronous Function Call (AFC) and Message Passing Interface (MPI) for further support for concurrent and distributed programming (still experimental); 4. Added a few new data types, in particular, among which, there is the new tuple type in which each of the items is typed independently, for example, if a tuple is consisted of an integer and a string, then the type of the tuple will be tuple; Moreover the items of a Dao tuple can have field names. 5. The internal data storage scheme is improved to reduce memory overheads for simple types. 6. Added special support for the main() function, so that the comand line arguments are mapped to the function parameters, and are checked against the paremeter types of main(). 7. Improved representation of C/C++ types, so that their inheritance relationships can be still valid in Dao, and they can be derived by Dao classes directly. Moreover, this release has included a tool (tools/autobind.dao) which can do semi-automated wrapping of C/C++ libraries. In fact, many of the modules released this time are generated by this tool. Just to list the modules released this time: DaoCamellia (image processing), DaoCGI (CGI Web programming), DaoCLoader (running time wrapping of C libraries, slightly similar to the ctype module of Python), DaoDataModel (database handling, can be used to set up mappng between data tables and Dao class types), DaoFastCGI (CGI Web programming), DaoLapack (linear algebra library), DaoMagick (image processing), DaoMGL (math plotting), DaoMySQL (database), DaoOpenGL (3D graphics), DaoSDL (multi-media), DaoTCC (embedding C codes into Dao scripts), DaoXML (handling XML documents and fetching web pages from web servers), DaoZlib (compression), DaoVTK (3D data and model visualization). I believe this release has become suitable for some practical applications, and worth to be tried out. Then a formal release of the 1.0 version will be made available during this august or september. I would be very grateful, if anyone can give me some suggestions for improvement, and feature requests are of couse also welcome. Thanks and enjoy, Limin homepage: http://www.xdao.org sourceforge project: http://sourceforge.net/projects/daoscript/ download: https://sourceforge.net/project/showfiles.php?group_id=141871&package_id=273540&release_id=594971 From aftab_d at hotmail.com Thu Apr 17 08:34:25 2008 From: aftab_d at hotmail.com (GoodieMan) Date: Thu, 17 Apr 2008 05:34:25 -0700 (PDT) Subject: Learn Python in easy steps... free!!! Message-ID: Learn Python in very easy steps!!! visit the site. Excellent!!! http://freeware4.blogspot.com/ From dhanlen at owt.com Sun Apr 27 19:01:47 2008 From: dhanlen at owt.com (Don Hanlen) Date: Sun, 27 Apr 2008 16:01:47 -0700 (PDT) Subject: error: (10035, 'The socket operation... Message-ID: IDLE internal error in runcode() Traceback (most recent call last): File "C:\PYTHON25\lib\idlelib\rpc.py", line 235, in asyncqueue self.putmessage((seq, request)) File "C:\PYTHON25\lib\idlelib\rpc.py", line 332, in putmessage n = self.sock.send(s[:BUFSIZE]) error: (10035, 'The socket operation could not complete without blocking') Does this look familiar to anyone? I can't figure out what to do about it. Python 2.5, windoze. I get it when I execute a Tkinter op that works elsewhere. changing this: t = self.b.create_text( (point.baseX + 1)*self.checkerSize/2 + fudge, y + fudge, text = str(point.occupied), width = self.checkerSize) to t = self.b.create_text( (point.baseX + 1)*self.checkerSize/2 + fudge, y + fudge, text = str(point.occupied), font=("Times", str(self.checkerSize/2), "bold"), width = self.checkerSize) for example. The same code works fine elsewhere. I thought I'd ask here before I try (no clue) increasing BUFSIZE in rpc.py? I'm not crazy about tinkering with code I have no clue about.. -- don From rickbking at comcast.net Fri Apr 25 11:57:11 2008 From: rickbking at comcast.net (Rick King) Date: Fri, 25 Apr 2008 11:57:11 -0400 Subject: Subclassing datetime.date does not seem to work Message-ID: <4811FF57.5040200@comcast.net> An HTML attachment was scrubbed... URL: From aaron.watters at gmail.com Thu Apr 17 11:44:54 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Thu, 17 Apr 2008 08:44:54 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> <09a38ca2-8c49-4eee-b6cf-58e849aea1fc@q1g2000prf.googlegroups.com> <5c5c130e-dade-4663-87b5-f3ab748cc9e3@y21g2000hsf.googlegroups.com> Message-ID: On Apr 16, 3:33 pm, "sjdevn... at yahoo.com" wrote: > > Wow, I'd venture that the division changes with ints are the only > thing I'm really concerned about... Oh I forgot about this one. Yes, I think it's a mistake to adopt a different convention for division than C/C++/java/C#/Fortran/ Basic... Just another reason to throw your hands up in frustration, in my book... The implications of the string conversion is entirely unclear to me. I'm betting the libraries will also get "improved" during porting, either intentionally or accidentally which means I'll have to carefully rewrite and retest any code which uses the new and improved libraries ... and the "deprecated/removed" libs won't work anymore, so I can't just put them into my package... sigh. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=sigh From meisnernel73884 at gmail.com Wed Apr 30 06:37:11 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:37:11 -0700 (PDT) Subject: wep key crack Message-ID: <2ac4a94b-0d4a-46dd-b07e-65258f202396@24g2000hsh.googlegroups.com> wep key crack http://crack.cracksofts.com From jon+usenet at unequivocal.co.uk Sun Apr 27 08:46:51 2008 From: jon+usenet at unequivocal.co.uk (Jon Ribbens) Date: Sun, 27 Apr 2008 07:46:51 -0500 Subject: Why can't timedeltas be divided? References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> <48142747$0$20906$9b622d9e@news.freenet.de> Message-ID: On 2008-04-27, webograph wrote: > On 2008-04-27 14:18, Jon Ribbens wrote: >> Yes, that's where it was decided that the datetime module was fine >> that way it is and must not be changed. > could you give me some pointers to that discussion? Well, http://bugs.python.org/issue1673409 seems very closely related. As does the thread starting at http://mail.python.org/pipermail/python-dev/2007-March/071776.html > nevertheless, i fail to see such problems when dividing timedeltas -- > after all, `delta2 / 5 == delta1` works, so why should not `delta2 / > delta1 == 5`? I used very similar arguments for the changes I wanted, and they weren't appreciated ;-) From arnodel at googlemail.com Mon Apr 28 14:44:16 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Mon, 28 Apr 2008 19:44:16 +0100 Subject: list.reverse() References: Message-ID: Mark Bryan Yu writes: > This set of codes works: > >>>> x = range(5) >>>> x.reverse() >>>> x > [4, 3, 2, 1, 0] > > But this doesn't: > >>>> x = range(5).reverse() >>>> print x > None > > Please explain this behavior. range(5) returns a list from 0 to 4 and > reverse just reverses the items on the list that is returned by > range(5). Why is x None (null)? have you tried typing help(list.reverse) at the interactive prompt? -- Arnaud From steve at holdenweb.com Thu Apr 17 14:07:18 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 17 Apr 2008 14:07:18 -0400 Subject: Prob. w/ Script Posting Last Value In-Reply-To: <4dc0cfea0804170922n2a96be20sc424a7e67742a12e@mail.gmail.com> References: <4dc0cfea0804170922n2a96be20sc424a7e67742a12e@mail.gmail.com> Message-ID: <480791D6.4000802@holdenweb.com> Victor Subervi wrote: > Hi; > Gabriel provided a lovely script for showing images which I am modifying > for my needs. I have the following line: > > print '

\n' % (d, y) > where the correct values are entered for the variables, and those values > increment (already tested). Here is the slightly modified script it calls: > > > #!/usr/local/bin/python > import cgitb; cgitb.enable() > import MySQLdb > import cgi > form = cgi.FieldStorage() > picid = int(form["id"].value) > x = int(form["x"].value) > pic = str(x) > print 'Content-Type: text/html' > db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > cursor= db.cursor() > sql = "select " + pic + " from products where id='" + str(picid) + "';" > cursor.execute(sql) > content = cursor.fetchall()[0][0].tostring() > cursor.close() > print 'Content-Type: image/jpeg\r\nContent-Length: %s\n' % len(content) > print content > > I need to make it so that it will show all my images, not just the last > one. Suggestions, please. > TIA, > Victor > In your "page generator" page, replace print '

\n' % (d, y) by for d, y in (results of some DB query to get d and y for each image): print '

\n' % (d, y) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From skanemupp at yahoo.se Sat Apr 12 07:13:08 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 12 Apr 2008 04:13:08 -0700 (PDT) Subject: tkinter, editing an entry, int-value of insert? Message-ID: in this program when using the "c"-button it deletes the last token entered. i want to delete the token after the mousecursor. lets say the string is: 12*(81**.5+12) and i put the cursor between the * and * because i want times .5 not root. now if i press "c" it deletes ")" which is not what i want. ive tried coming up with a function that does what i want but neither of the ways as shown below works. i want to do something like e.delete(INSERT, INSERT+1) but that doesnt work because it is string+int and INSERT+"1" doesnt work either. so how do i get the int-value of insert? what is the trick? def Backspace(): a=len(e.get()) e.delete(a-1,END) #e.delete(INSERT, END) #e.delete(ANCHOR,END) from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") e = Entry(mygui) e.grid(row=1, column=1, columnspan=4, sticky=NSEW) c = Entry(mygui) c.grid(row=2, column=1, columnspan=4, sticky=NSEW) def Disp(nstr): e.insert(INSERT, nstr) def Calc(): expr=e.get() c.delete(0, END) try: c.insert(END, eval(expr)) except: c.insert(END, "Not computable") def Erase(): e.delete(0,END) c.delete(0, END) def Backspace(): a=len(e.get()) e.delete(a-1,END) x = 1 y = 4 for char in '123+456-789*0()/.': b = Button(mygui, text=char, command=lambda n=char:Disp(n), width=2, height=1) b.grid(row=y, column=x, sticky=NSEW) x=x+1 if x==5: x=1 y=y+1 b = Button(mygui, text="^", command=lambda n="**":Disp(n), width=2, height=1) b.grid(row=8, column=2, sticky=NSEW) b = Button(mygui, text="C",command=Erase, width=2, height=1) b.grid(row=8, column=3, sticky=NSEW) b = Button(mygui, text="c",command=Backspace, width=2, height=1) b.grid(row=8, column=4, sticky=NSEW) b = Button(mygui, text="=",command=Calc, width=18, height=1) b.grid(row=9, column=1, columnspan=4, sticky=NSEW) mygui.mainloop() From pecora at anvil.nrl.navy.mil Wed Apr 9 10:22:01 2008 From: pecora at anvil.nrl.navy.mil (Lou Pecora) Date: Wed, 09 Apr 2008 10:22:01 -0400 Subject: Basic optimization of python. References: <663p3lF2go90rU1@mid.uni-berlin.de> <877if7b5h9.fsf@mulj.homelinux.net> Message-ID: In article <877if7b5h9.fsf at mulj.homelinux.net>, Hrvoje Niksic wrote: > "Diez B. Roggisch" writes: > > >> Eg: > >> a = 1 + 2 > >> .vs. > >> a = 3 > >> which one is more effective? Does the compiler calculate the result at > >> compile time? How about constant spreading? > > > > Algebraic optimizations aren't done AFAIK > > Just try it: > > Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> dis.dis(lambda: 10+5) > 1 0 LOAD_CONST 2 (15) > 3 RETURN_VALUE Not always. On a Mac running Python 2.4, here's what I get: In [3]: dis.dis(lambda: 3+4) 1 0 LOAD_CONST 1 (3) 3 LOAD_CONST 2 (4) 6 BINARY_ADD 7 RETURN_VALUE -- -- Lou Pecora From stutzman at skywagon.kjsl.com Mon Apr 14 11:17:14 2008 From: stutzman at skywagon.kjsl.com (Frank Stutzman) Date: Mon, 14 Apr 2008 15:17:14 +0000 (UTC) Subject: Remote mac address References: Message-ID: Matias Surdi wrote: > Anyone knows how having the IP address of a host on the lan could I get > the mac address of that hosr? > p/d: Parsing the output of arp -a is not an option. What kind of system? On linux and probably several other unix-like systems you could (if you had permission) parse the /proc/net/arp file. Granted this isn't terribly far off from parsing the output of 'arp -a', but at least it keeps you from spawning a shell to run the 'arp -a' in. -- Frank Stutzman From Cody.Woolaver at student.nbed.nb.ca Wed Apr 30 09:47:26 2008 From: Cody.Woolaver at student.nbed.nb.ca (Cody Woolaver) Date: Wed, 30 Apr 2008 10:47:26 -0300 Subject: Stream I/O to a java applet (os.popen?) Message-ID: Hello, I have designed a script (in java) that allows me to input a command like "Move 325 642" and the mouse cursor will move to that x,y position. The way that the java program works is when it initializes it runs in a constant loop reading the input each time something is sent to it... Here is an example of how i run the script from the terminal: [code] Cody at Charmander:~/Workspace/Mouse/mouse/>java MouseMove Move 500 500 Click Left 1 1 Move 400 400 Click Right 1 1 Move 250 50 Click Left 2 2 Exit Cody at Charmander:~/Workspace/Mouse/mouse/> [/code] Here is what happens:[quote] I typed: "Move 500 500" then hit enter The code: Moved the mouse to pos x,y. Then waited for more input I typed: "Click Left 1 1" then hit enter The code: Left Clicked at the current position once, with one ms of wait. Then waited for more input I typed: "Move 400 400" then hit enter The code: Moved the mouse to pos x,y. Then waited for more input I typed: "Click Right 1 1" then hit enter The code: Right Clicked at the current position once, with one ms of wait. Then waited for more input I typed: "Move 500 500" then hit enter The code: Moved the mouse to pos x,y. Then waited for more input I typed: "Click Left 2 2" then hit enter The code: Left Clicked at the current position twice (double click), with two ms of wait between each click. Then waited for More input I typed: "Exit" then hit enter The code: Quit the program[/quote] This is all done at the terminal though and i need to have it done through a python file. I'm aware that i will have to use os.popen but am unfamiliar with how it works. As an example could someone show me how to do this all in one "main.py" file. [code] import os #I know this will be needed class JavaClass(): def start(): #Start the java program def move(x,y): #move the mouse (Inputs "Move x y") def click(button, times, delay): #click the mouse (Inputs "Click button times delay") def close(): #Sends "Exit" to the program, ending it safely JavaFile = New JavaClass() JavaFile.start() #Will open up the java file, then waits for input JavaFile.move(500,500) #Input the following (exact same as above) JavaFile.click("Left", 1, 1) #Input the following (exact same as above) JavaFile.move(400,400) #Input the following (exact same as above) JavaFile.click("Right", 1, 1) #Input the following (exact same as above) JavaFile.move(250,50) #Input the following (exact same as above) JavaFile.click("Left", 2, 2) #Input the following (exact same as above) JavaFile.close() #Will send "Exit" to the program closing it [/code] Thank you very much for any help you are able to give me ~Cody Woolaver -------------- next part -------------- An HTML attachment was scrubbed... URL: From domiriel at gmail.com Tue Apr 22 04:49:43 2008 From: domiriel at gmail.com (domiriel at gmail.com) Date: Tue, 22 Apr 2008 01:49:43 -0700 (PDT) Subject: Finding the selected file in Windows Explorer References: Message-ID: <8e2d520c-8113-4052-ac67-d41e0b0871fe@e39g2000hsf.googlegroups.com> Will do! Tks! Domiriel On Apr 21, 4:12 pm, Mike Driscoll wrote: > On Apr 21, 9:44 am, domir... at gmail.com wrote: > > > > > Hi! > > > I need to find the selected file(s) in a Windows Explorer window from > > another program (I'd look at the window that last had focus). I found > > something in the following page that should do the trick: > > >http://blogs.msdn.com/oldnewthing/archive/2004/07/20/188696.aspx > > > However, it is not Python and, while I'm a competent Python > > programmer, Win32, COM and the like are somewhat outside my > > competences. > > > Does any one know how to do something similar in Python? > > > Tks! > > Domiriel > > I think the guys on the PyWin32 mailing list were just talking about > something similar earlier this month. Looks like it was how to select > a file in Explorer. You can check out that thread here: > > http://www.mail-archive.com/python-wi... at python.org/maillist.html > > Or just join their mailing list and re-post your question there: > > http://mail.python.org/mailman/listinfo/python-win32 > > They're quite nice and very knowledgeable. > > Mike From dfg778 at yahoo.com.au Sun Apr 13 05:09:42 2008 From: dfg778 at yahoo.com.au (Matthew Keene) Date: Sun, 13 Apr 2008 19:09:42 +1000 Subject: Call a classmethod on a variable class name References: <3b34f7c2-7692-4426-8740-2e0d84fdf472@k37g2000hsf.googlegroups.com> Message-ID: Arnaud Delobelle wrote: > > If your class lives in the current global namespace, you can get it > with > > >>> cls = globals()[classname] > > Then you can access its .bar() method directly: > > >>> cls.bar() > > Example: > > >>> class Foo(object): > ... @classmethod > ... def bar(cls): print 'Oh my Baz!' > ... > >>> globals()['Foo'] > > >>> globals()['Foo'].bar() > Oh my Baz! > > If your class lives in a module, just do getattr(module, classname) > instead to get the class object. > > HTH > > Yes, that feels much nicer and works well. Thanks for the prompt reply ! From pscott at uwc.ac.za Mon Apr 7 13:18:27 2008 From: pscott at uwc.ac.za (Paul Scott) Date: Mon, 07 Apr 2008 19:18:27 +0200 Subject: First Python project - comments welcome! In-Reply-To: <0431417e-52b9-439f-b8cb-941d3b4fb42b@1g2000prg.googlegroups.com> References: <0431417e-52b9-439f-b8cb-941d3b4fb42b@1g2000prg.googlegroups.com> Message-ID: <1207588707.6922.5.camel@paul-laptop> On Mon, 2008-04-07 at 09:56 -0700, Lie wrote: > I don't know if it was just me, but I can't just scan through your > code briefly to know what it is about (as is with any non-trivial > codes), only after looking through the website's Roadmap I realized > it's something to do with audio and recording. Perhaps you should add > a short module-level docstring that explains in a brief what the code > is about, somewhat like an abstract. > Sure, will add that. It is a simple GUI based audio (and later video) recorder that a user can record a audio stream from line in (mic) and create an ogg vorbis file from it. It then allows the user to upload the ogg file to a Chisimba (PHP5 - my day job) based server to be consumed automagically as a podcast. The file is tagged and converted to MP3 server side and added to the Chisimba podcast module. It is really for use in lecture halls so that lecturers can upload their audio files as podcasts for the students to listen to almost immediately afterwards. > And second, it's just my personal preference, but I usually like to > separate between GUI codes (codes that handle GUI events) and working > code (the real worker). Couldn't agree more! MVC architecture is how I do all of my code. Unfortunately, this was my first stab at 1. Python 2. GUI applications 3. Audio apps so I will need some more help in doing that (i.e. ramping up my skills or getting someone that knows what they are doing onto the project to help out). Thanks for the feedback though, I will improve in time... :) --Paul -------------- next part -------------- All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm From stephen.cattaneo at u4eatech.com Tue Apr 1 13:11:31 2008 From: stephen.cattaneo at u4eatech.com (Stephen Cattaneo) Date: Tue, 01 Apr 2008 10:11:31 -0700 Subject: manipulating hex values Message-ID: <47F26CC3.3060307@u4eatech.com> Hi all, I am relatively new to socket programming. I am attempting to use raw sockets to spoof my IP address. From what I can tell I will have to build from the Ethernet layer on up. This is fine, but I am having some trouble with manipulating my hex values. Seems to me that there are two ways to store hex values: 1. as literal hex - 0x55aa 2. as a string - "\x55aa" If I want to convert hex to decimal I can use: int("\x55aa", 16) # note that plain 0x55aa, instead of "\x55aa", will raise an exception The Question: If I want to do any kind of calculation I have found its best to just convert my values to decimal, do the math, then convert back to hex. In my bellow code I get """byteList.append(int(value,16)) ValueError: invalid literal for int()""" when attempting to run. I do not understand why this exception is being raised? It is a for loop iterating over a list of hex strings. Sorry for the long-ish question. Any help or comments would be appreciated. ----my checksum--- def calcIPCheckSum(ipHeaders): byteList = [] # convert groups from hex to dec for value in ipHeaders: byteList.append(int(value,16)) # Exception raised here! # 1's compliment for index in range(len(byteList)): byteList[index] = abs(byteList[index] - 65535) # add bytes together shifting the extra byte total = 0 for value in byteList: total = total + value if total > 65535: total = total - 65535 return hex(total) checksum = calcIPChecksum(["\x45" + "\x00", "\x01\x4a", "\x00\x00", "\x40"+"\x00", "\x20"+"\x11"]) ------------------------- Cheers, Steve From steven.p.clark at gmail.com Mon Apr 7 17:55:07 2008 From: steven.p.clark at gmail.com (Steven Clark) Date: Mon, 7 Apr 2008 17:55:07 -0400 Subject: Data structure recommendation? In-Reply-To: <3290753a0804071408mcf16fb6r3bd746279cdbb8da@mail.gmail.com> References: <663744510804071339g639bfdccl63de8be66fe52df1@mail.gmail.com> <3290753a0804071408mcf16fb6r3bd746279cdbb8da@mail.gmail.com> Message-ID: <663744510804071455s941b7a3y445b970a20da4fca@mail.gmail.com> > > I believe the best way to implement this would be a binary search > > (bisect?) on the actual times, which would be O(log N). Though since > > they are timestamps they should be monotonically increasing, in which > > case at least you don't have to go to the expense of sorting them. > > > > "Some kind of hash function" won't hack it, since the purpose of a hash > > function is to map a large number of (possibly) evenly-distributed > > (potential) keys as nearly as possible randomly across a much smaller > > set of actual values. > > > > You might try messing around with reducing the precision of the numbers > > to home in on a gross region, but I am not convinced that does anything > > other than re-spell binary search if carried to extremes. > > Thanks all for your comments, which basically confirmed for me that there is no magic bullet in this situation. To add an additional wrinkle to the problem, I know a priori that for sequential calls to foo.get(x), 95% of the time, x is likely to be very close to the previous x. In other words, you might see foo.get(3.9), foo.get(3.8), foo.get(3.7), etc. (think VCR controls, rewinding). It seems to me because of this, saving state and doing a linear search from the previous location can actually be faster than a binary search. But you would pay a big penalty when x jumps by a lot. Hrm, a balancing act... Regarding monotonically increasing timestamps: I had initially assumed so, but I may want to allow adding events back in time. What is the most efficient way to keep the list sorted after each put()? Thanks again. From gagsl-py2 at yahoo.com.ar Sat Apr 5 05:31:57 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 05 Apr 2008 06:31:57 -0300 Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <7113d012-01bb-4426-bb40-9e2811cdb102@x41g2000hsb.googlegroups.com> <3cf4bbc8-b828-45c5-b9a8-766ce600af43@y21g2000hsf.googlegroups.com> Message-ID: En Sat, 05 Apr 2008 03:02:02 -0300, escribi?: > am i not doing that then? did u look at the code? where do i add the > bind if this: > btnDisplay = Button(self, text="1", command=self.Display) > btnDisplay.grid(row=3, column=0, padx=5, pady=5) > > is not enough? Yes, I looked at the code, andn I don't see the word "bind" anywhere, do you? > def Display(self, event_obj): > button = event_obj.widget > text = button.cget("text") > > if text=="1": > print 1 This Display method is OK for *bind* but you're using *command*. Read the previous response and in particular the Tkinter book - from the same guy who wrote the library. -- Gabriel Genellina From kranz at theorie.physik.uni-goettingen.de Sun Apr 13 01:22:36 2008 From: kranz at theorie.physik.uni-goettingen.de (Till Kranz) Date: Sun, 13 Apr 2008 07:22:36 +0200 Subject: Confused about Boost.Python & bjam In-Reply-To: References: Message-ID: Hi, On Sat, 12 Apr 2008, 7stud wrote: > On Apr 12, 4:53?am, Till Kranz goettingen.de> wrote: >> I tried to get started with Boost.Python. >> I am using a Gentoo system, so there is no boost directory. > > A few months ago, I spent a whole day trying to install boost python. > I failed. After that, I decided I'd never go near boost again. I think I kind of managed to install boost. All the header only boost stuff works. It was Gentoos package manager that did the installing for me after all. I think my problem is, that the parts of boost got properly spread out over the file system. I am sure the bjam system can handle this but I need a starting point to find out how. Best Till From ankitks.mital at gmail.com Fri Apr 4 01:24:14 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Thu, 3 Apr 2008 22:24:14 -0700 (PDT) Subject: regarding memoize function References: <94a9e7e6-a623-4783-81da-f69654e51349@e10g2000prf.googlegroups.com> Message-ID: <80ee9d89-12a1-4534-be50-ac4614c28bc2@l42g2000hsc.googlegroups.com> On Apr 3, 8:04?pm, "Gabriel Genellina" wrote: > En Thu, 03 Apr 2008 21:21:11 -0300, Dan Bishop ? > escribi?: > > > > > > > On Apr 3, 6:33 pm, ankitks.mi... at gmail.com wrote: > >> I saw example of memoize function...here is snippet > > >> def memoize(fn, slot): > >> ? ? ? ?def memoized_fn(obj, *args): > >> ? ? ? ? ? ? if hasattr(obj, slot): > >> ? ? ? ? ? ? ? ? return getattr(obj, slot) > >> ? ? ? ? ? ? else: > >> ? ? ? ? ? ? ? ? val = fn(obj, *args) > >> ? ? ? ? ? ? ? ? setattr(obj, slot, val) > >> ? ? ? ? ? ? ? ? return val > >> ? ? ? ?return memoized_fn > > >> and I am really clueless, about what it does. I know in general we try > >> to keep computed values for future usage. But I am having hard-time > >> visualizing it. > >> What is obj here? and what does *args means? > > > *args is Python's syntax for variadic functions. > > In case the strange name gives you nothing, see section 4.7 in the ? > Tutorial [1] > For a much simpler implementation, see this FAQ entry [2] > > [1]http://docs.python.org/tut/node6.html#SECTION006700000000000000000 > [2] ?http://www.python.org/doc/faq/general/#why-are-default-values-shared-... > > -- > Gabriel Genellina- Hide quoted text - > > - Show quoted text - Thanks Gabriel and Dan, But I am still confuse on... what is obj? Let say def f(node): return max(node.path_cost+h(node), getattr(node, 'f', - infinity)) f = memoize(f,'f') what is this doing? I am passing string 'f' as second argument? right? so evertime in function memoize, I am doing hasattr(obj, slot), I am saying hasattr(obj, 'f')? I kindof understand that I am returning maximum of pre-computed value(if there is already) vs. new calculation. But syntax is throwing me off. From deets at nospam.web.de Wed Apr 16 08:27:14 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 16 Apr 2008 14:27:14 +0200 Subject: subplot function in matplotlib References: <368ac3ca-ed20-494d-9f09-00d06701857d@k37g2000hsf.googlegroups.com> Message-ID: <66m9luF2lchhkU2@mid.uni-berlin.de> eli wrote: > Does anyone know a workaround to plotting beyond 9 subplots in > matplotlib? It would be nice to have 20 plots under the subplot > function for example (poster). Is there such a limitation? I thought that was only for the condensed sublpot-specification-form (where you give e.g. 133 instead of 1,3,3) Diez From jkrukoff at ltgc.com Thu Apr 24 13:16:35 2008 From: jkrukoff at ltgc.com (John Krukoff) Date: Thu, 24 Apr 2008 11:16:35 -0600 Subject: convert xhtml back to html In-Reply-To: Message-ID: <000901c8a62e$f36fdc80$c41ea8c0@naomi> > -----Original Message----- > From: python-list-bounces+jkrukoff=ltgc.com at python.org [mailto:python- > list-bounces+jkrukoff=ltgc.com at python.org] On Behalf Of Tim Arnold > Sent: Thursday, April 24, 2008 9:34 AM > To: python-list at python.org > Subject: convert xhtml back to html > > hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop > to > create CHM files. That application really hates xhtml, so I need to > convert > self-ending tags (e.g.
) to plain html (e.g.
). > > Seems simple enough, but I'm having some trouble with it. regexps trip up > because I also have to take into account 'img', 'meta', 'link' tags, not > just the simple 'br' and 'hr' tags. Well, maybe there's a simple way to do > that with regexps, but my simpleminded )]+/> doesn't work. I'm > not > enough of a regexp pro to figure out that lookahead stuff. > > I'm not sure where to start now; I looked at BeautifulSoup and > BeautifulStoneSoup, but I can't see how to modify the actual tag. > > thanks, > --Tim Arnold > > > -- > http://mail.python.org/mailman/listinfo/python-list One method which wouldn't require much python code, would be to run the XHTML through a simple identity XSL tranform with the output method set to HTML. It would have the benefit that you wouldn't have to worry about any of the specifics of the transformation, though you would need an external dependency. As far as I know, both 4suite and lxml (my personal favorite: http://codespeak.net/lxml/) support XSLT in python. It might work out fine for you, but mixing regexps and XML always seems to work out badly in the end for me. --------- John Krukoff jkrukoff at ltgc.com From bruno.desthuilliers at gmail.com Wed Apr 2 18:44:53 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 15:44:53 -0700 (PDT) Subject: class / module introspection? References: <3c3f09df-08cb-4309-a870-6b12a813a8af@u36g2000prf.googlegroups.com> <0f14a289-55ef-49e5-b650-60f7aca371ad@i36g2000prf.googlegroups.com> <85761ed1-afe8-48cc-8c6d-73183e6692a9@i7g2000prf.googlegroups.com> Message-ID: <47ea85b3-c776-422c-bf66-02c68a1aa03a@i7g2000prf.googlegroups.com> On 2 avr, 22:04, Brian Munroe wrote: > On Apr 2, 12:33 pm, "bruno.desthuilli... at gmail.com" > > wrote: > > > Why not do the import here, so you store a real module instead of a > > name ? > > Right now I'm still in the prototyping phase and haven't really > thought everything through. I needed the names because I am > populating a GUI selection list element. import os print os.__name__ 'os' > I also assumed that I could > then lazy load the modules I needed... Ok, that's something else. I had (wrongly) assumed you wanted to load all modules anyway. > Thanks for the help though, you've gotten me past my first of many > (I'm sure) hurdles! You're welcome. From jens at aggergren.dk Tue Apr 29 11:50:31 2008 From: jens at aggergren.dk (Jens) Date: Tue, 29 Apr 2008 08:50:31 -0700 (PDT) Subject: Zope/DTML Infuriating... References: Message-ID: <65492d56-de86-4979-a886-b4e6f9b3b42f@2g2000hsn.googlegroups.com> On Apr 29, 3:16?pm, Christian Heimes wrote: > Jens schrieb: > > > Hello Everyone. > > > I am relatively new to Zope(using it for a work project) and I was > > wondering if someone here could help me out or at least refer me to a > > decent documentationg for Zope/DTML/Python (at the detail level of > > php.net or Java API reference). ?http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/ > > isn't really detailed enough for my taste. if it doesn't contain a > > exhautive description of all available base classes it's simply no > > good as a reference resource. > > Are you forced to use DTML for the job? ZPT are far superior and easier > to work with, if you have to output HTML. > > Christian For now, I have to use DTML as I am building on an existing solution. I might look into ZPT's but I have limited time and theres no to time at this point to redo everything as ZPT. In the long run we're probably going in a completely different direction, but that a another story. I like some aspects of zope but I find that it ends up sitting between two chairs. On one hand it want's to be a templating language which is easy to get into for novices, but on the other hand you really have be familiar with python to be able to so stuff thats only slighty more complicated then standard SSI. And don't get me started on the whole security philosophy. @Marco: Thanks for the links :-) Python may be one of those really elegant languages, but the reference is really sub standard. Checkout the layout of php.net for comparison. Think what you will about php, but the reference is excellent. For that matter check out msdn section on old-school asp, or even the common-lisp documentation(http://www.lispworks.com/ documentation/HyperSpec/Front/Contents.htm) It's accessibility like that i'm missing. It shouldn't take 10 min and a usenet post to figure to how to basic stuff like string concatenation. And theres still plenty of unanswered questions after checking the reference: - What is the exact definition of the operator e.g. op + (, ) -> , op + (, ) : , op + ( ... - What is the exact operator precedence - Why is it, when primitive data types seem to be objects (similar to javascript), that type casting is done through build-in functions rather than methods, e.g. String.toInt('5') or '5'.toInt() or x = Integer.fromString('5'). From juergen.perlinger at t-online.de Sun Apr 20 16:18:09 2008 From: juergen.perlinger at t-online.de (Juergen Perlinger) Date: Sun, 20 Apr 2008 22:18:09 +0200 Subject: What happened with python? messed strings? References: Message-ID: Jason Scheirer wrote: [snip] > > It's true -- decorators, the class/type cleanup, properties, -= and > +=, list comprehensions, generators, distutils, and all the new > modules in the standard library are completely, entirely useless. > Python SHOULD have stayed at 1.5. totally OT, but just a few personal observations: 1. Everything was better a few hundred years ago. 2. A fool with a tool is still a fool. (just in general, all people present excused...) 3. Simple things tend to become complex. Complex things tend to break, even when used properly. And it might be hard to use them properly if you don't have the understanding. 4. Simplicity can be deceptive. -- juergen 'pearly' perlinger "It's hard to make new errors!" From bearophileHUGS at lycos.com Fri Apr 18 09:53:53 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Fri, 18 Apr 2008 06:53:53 -0700 (PDT) Subject: Data structure recommendation? References: <1adc3541-7775-4938-bd5a-953dd041656c@2g2000hsn.googlegroups.com> Message-ID: <00a2788a-cb99-49d0-a421-f28f0a6796dc@a23g2000hsc.googlegroups.com> Jochen Schulz: > Could you please send me an email with an existing From: address? I > tried to reply to you but apparently your From: is forged. Sorry for the delay, I'll send you an email. In the meantime I have created a fast BK-tree implementation for Psyco, on my PC it's about 26+ times faster than mspace (that uses psyco still), but it's less complete. You can find it here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/572156 (I have created a D version too, that's about 4.5 times faster than my Python version, so it's about 126 times faster than the mspace with Psyco). Enjoy, bearophile From jsprad at gmail.com Tue Apr 1 14:10:17 2008 From: jsprad at gmail.com (sprad) Date: Tue, 1 Apr 2008 11:10:17 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> Message-ID: On Apr 1, 11:41 am, mdomans wrote: > Python needs no evangelizing but I can tell you that it is a powerfull > tool. I prefer to think that flash is rather visualization tool than > programing language, and java needs a lot of typing and a lot of > reading. On the other hand python is simple to read and write, can be > debuged easily, is intuitive and saves a lot of time. It also supports > batteries included policy and you can't get more OO than python. One advantage of Flash is that we can have something moving on the screen from day one, and add code to it piece by piece for things like keyboard or mouse control, more and more complex physics, etc. Is there an equivalent project in Python? From steve at holdenweb.com Mon Apr 7 14:39:07 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 07 Apr 2008 14:39:07 -0400 Subject: Tips for load balancing multiple Python apps on dual/quad core processors? In-Reply-To: <1207592129.27594.1246549665@webmail.messagingengine.com> References: <1207592129.27594.1246549665@webmail.messagingengine.com> Message-ID: <47FA6A4B.4020906@holdenweb.com> Malcolm Greene wrote: > I'm looking for tips on how to load balance running multiple Python > applications in multi-CPU environments. My understanding is that Python > applications and their threads are limited to a specific CPU. > > Background: I have a Python utility that processes email messages. I > suspect there's a lot of idle time while this utility waits on a remote > email server. I would like to run as many simultaneous copies of this > utility as possible without overwhelming the server these utilities are > running on. My thought is that I should write a dispatcher that monitors > CPU load and launches/cancels multiple instances of my utility with > specific job queues to process. > > Is there a cross-platform way to monitor CPU load? > > Is there a pre-existing Python module I should be looking at for > building (subclassing) my dispatcher? > As a data point for you, I wrote a multi-threaded application that used 100 threads to send about 45,000 emails in less than four hours. The single-CPU computer that processed this job wasn't using that much CPU (certainly under 50%). regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From pieter.cogghe at gmail.com Thu Apr 10 08:55:30 2008 From: pieter.cogghe at gmail.com (Pieter) Date: Thu, 10 Apr 2008 14:55:30 +0200 Subject: call python from c -> pass and return arrays/lists Message-ID: <5c0bbcb30804100555k4f07d1dt792dbba3bbd5dddf@mail.gmail.com> Thanks, this did the trick: PyArg_Parse(ret,"O", &the_list); if (PySequence_Check(the_list)) { int size = PySequence_Size(the_list); int *result = malloc(sizeof(int) * size); int i; for (i = 0; i < size; i++) { PyObject *item = PySequence_GetItem(the_list, i); if(PyInt_Check(item)) { result[i] = PyInt_AsLong(item); printf("value %d: %d", i, result[i]); } else { printf("Didn't work, NO INT"); } } } kind regards, Pieter ---------- Doorgestuurd bericht ---------- From: "Diez B. Roggisch" To: python-list at python.org Date: Thu, 10 Apr 2008 12:23:56 +0200 Subject: Re: call python from c -> pass and return arrays/lists Pieter wrote: > Hi all, > > I'm trying to call a python function from c. I need to pass an > 2D-array to python and the python function returns a 2D-list back to > c. I googled arround and I found how to pass ints/strings/... back and > forth, but didn't find anything on passing arrays. > > For an int it's as simple as this: > > PyArg_Parse(ret,"i#", &my_long); > > But I hacve no idea how to parse python lists to a c-array? You return a list, parse that as object, and then work with the sequence-protocol on them. UNTESTED: PyArg_Parse(ret,"o", &the_list); if(PySequence_Check(the_list) { int size = PySequence_Size(the_list); int *result = malloc(sizof(int) * size); for(int i = 0; i < size; i++) { PyObject *item = PySequence_GetItem(the_list, i); if(PyInt_Check(item)) { result[i] = PyInt_AsLong(item); } else { return NULL; } } Diez -- Pieter Cogghe Ganzendries 186 9000 Gent 0487 10 14 21 From lbonafide at yahoo.com Tue Apr 15 13:35:08 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Tue, 15 Apr 2008 10:35:08 -0700 (PDT) Subject: Java or C++? References: <480424FC.5040802@aim.com> Message-ID: <95983d3d-d751-4472-af3c-5e1b74fd538f@n14g2000pri.googlegroups.com> On Apr 15, 3:07?am, Paul Anton Letnes wrote: > but C bogs you down with administrative stuff (try converting an int ? > to a string; I found myself googling for an hour!). It took an hour to find sprintf()? From jianbing.chen at gmail.com Wed Apr 2 15:59:25 2008 From: jianbing.chen at gmail.com (jianbing.chen at gmail.com) Date: Wed, 2 Apr 2008 12:59:25 -0700 (PDT) Subject: default method parameter behavior Message-ID: <879d72da-825f-4b2b-8244-87367647fb6e@f63g2000hsf.googlegroups.com> I ran into a similar situation like the following (ipython session). Can anyone please explain why the behavior? Thanks in advance. In [11]: def foo(b=[]): ....: b.append(3) ....: return b ....: In [12]: foo() Out[12]: [3] In [13]: foo() Out[13]: [3, 3] In [14]: foo([]) Out[14]: [3] In [15]: foo([]) Out[15]: [3] From nick at craig-wood.com Mon Apr 28 05:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Mon, 28 Apr 2008 04:30:03 -0500 Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> <48131f57$0$14357$e4fe514c@news.xs4all.nl> <4ca7b83c-0ca4-4e38-95e5-264780d30ec0@56g2000hsm.googlegroups.com> Message-ID: Mark Tolonen wrote: > > So every time I use I want to send some thing, I must use > > > > totalsent = 0 > > while sent < len(data): > > sent = sock.send(data[totalsent:]) > > totalsent += sent > > > > instead of a simple sock.send(data)? That's kind of nasty. Also, is it > > better then to use sockets as file objects? Maybe unbuffered? > > I think you meant: > > while totalsent < len(data): > > Python also has the sendall() function. Just to elaborate, sendall does exactly the above for you. sendall(self, *args) sendall(data[, flags]) Send a data string to the socket. For the optional flags argument, see the Unix manual. This calls send() repeatedly until all data is sent. If an error occurs, it's impossible to tell how much data has been sent. There should really be a recvall for symmetry, but I don't think it would get much use! -- Nick Craig-Wood -- http://www.craig-wood.com/nick From grante at visi.com Mon Apr 28 10:34:41 2008 From: grante at visi.com (Grant Edwards) Date: Mon, 28 Apr 2008 09:34:41 -0500 Subject: API's and hardware communication. Newbie References: <_MudnfZZ9uW0hY7VRVnyhwA@bt.com> Message-ID: <87SdnU_Kr_gcfYjVnZ2dnUVZ_smnnZ2d@visi> On 2008-04-26, Grayham wrote: > Hi all > > I am new to this group so 'Hello All' > > I have a PC which is running linux and in it have installed a digital > satellite card. I would like to write some software to access the card, > tune it and bring back video. Basically a home brew DVB-s application. > > Being a non/new programmer (apart from some basic too many years ago) I > decided to teach my self Python as from what i have read it's an easy and > powerfull language to learn. I have been at it a few weeks and am getting > on OK and finding it reasonably OK to pick up. > > The problem is i can find little to no information on programming for DVB > cards or on how to access the Linux tv API in Python but I can find lots of > information in C. This is making me think should i bother with Python and > just learn C even though this will probably take a lot longer. There are a couple of ways you can handle the problem: * You can use the ctypes modules to make C library calls. At first it seems a bit complicated, but it's really quite easy to use. http://docs.python.org/lib/module-ctypes.html * You can write a C wrapper for the library so that it can be accessed as a Python module. That's going to require a bit more C knowlege than the ctypes approach , but it's not as difficult as it looks. http://www.python.org/doc/ext/intro.html > Can some one help me or point me at a resource somewhere or > would it be best to just learn C instead. > > I am aware this is a complicated little project for someone > just starting out but it will be a multifaceted program with > loads of interesting classes, functions and loops and i don't > have to start with the really difficult stuff first. I just > want to know if it's possible under python to access the DVB > card and if so how? Freevo is a DVR system written in Python, so that might be a good place to look: http://doc.freevo.org/ -- Grant Edwards grante Yow! I guess you guys got at BIG MUSCLES from doing too visi.com much STUDYING! From landerdebraznpc at gmail.com Mon Apr 28 03:52:20 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:52:20 -0700 (PDT) Subject: the pink patch Message-ID: <8b09fc36-5ada-4e74-bd00-9911388bc681@f63g2000hsf.googlegroups.com> the pink patch http://crack.cracksofts.com From ameyer2 at yahoo.com Tue Apr 8 23:42:33 2008 From: ameyer2 at yahoo.com (Alan Meyer) Date: Tue, 8 Apr 2008 20:42:33 -0700 (PDT) Subject: gen_py target directory for makepy Message-ID: I had an unusual problem tonight running makepy to install some Microsoft COM interfaces in a Python 2.5 Windows XP installation created using the ActiveState installer. In earlier versions of Python, the files were generated to: \PythonXX\Lib\site-packages\win32com\gen_py But in my 2.5 installation they were generated to my temp directory, in my case this was: c:\temp\gen_py\2.5 I hadn't paid attention to the messages and when I cleared my temp directory, which I occasionally do, the COM interfaces stopped working. Tracing through the makepy code, I found the following (reformatted for email) in \Python25\Lib\site-packages\win32com\__init__.py if not __gen_path__: try: import win32com.gen_py __gen_path__ = sys.modules["win32com.gen_py"].__path__[0] except ImportError: # If a win32com\gen_py directory already exists, then we use it # (gencache doesn't insist it have an __init__, but our # __import__ above does! __gen_path__ = \ os.path.abspath(os.path.join(__path__[0], "gen_py")) if not os.path.isdir(__gen_path__): # We used to dynamically create a directory under win32com - # but this sucks. If the dir doesn't already exist, we we # create a version specific directory under the user temp # directory. __gen_path__ = os.path.join( win32api.GetTempPath(), "gen_py", "%d.%d" % (sys.version_info[0], sys.version_info[1])) I was able to make everything work right by creating the gen_py directory in the expected place and re-running makepy. But I'm curious to know: 1. Why does it suck to create gen_py dynamically? 2. Why didn't I have a gen_py directory already? Did I somehow destory it or is it not created by default? 3. Why is the temp directory the alternate choice for where to put these? Thanks. Alan From carlwuhwdmckay at gmail.com Sat Apr 26 09:30:40 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:30:40 -0700 (PDT) Subject: diet patch Message-ID: diet patch http://cracks.00bp.com F R E E C R A C K S From bdsatish at gmail.com Fri Apr 11 07:27:06 2008 From: bdsatish at gmail.com (bdsatish) Date: Fri, 11 Apr 2008 04:27:06 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> Message-ID: <0b4620fd-1b09-484e-8daa-ea27d45fe028@w5g2000prd.googlegroups.com> On Apr 11, 4:19 pm, cokofree... at gmail.com wrote: > couldn't you just do. > > #untested > new_round(n): > answer = round(n) > # is answer now odd > if answer % 2: > return answer - 1 > else: > return answer It fails for negative numbers: For -2.5 it gives -4.0 as answer whereas I expect -2.0 From ilanschnell at gmail.com Sat Apr 19 14:13:08 2008 From: ilanschnell at gmail.com (ilanschnell at gmail.com) Date: Sat, 19 Apr 2008 11:13:08 -0700 (PDT) Subject: Issue with inspect module Message-ID: <2e5e2d31-2adc-4416-a993-19bc05a512bd@w8g2000prd.googlegroups.com> Hi, I have this trivial program: import inspect class A: def __init__(self, a): self.a = a def __str__(self): return 'A(%s)' % self.a a = A(8) print a the output is: A(8) A(8) Why does the inspect module cause the output to be printed twice? Thanks From aahz at pythoncraft.com Sat Apr 26 11:44:38 2008 From: aahz at pythoncraft.com (Aahz) Date: 26 Apr 2008 08:44:38 -0700 Subject: Setting an attribute without calling __setattr__() References: Message-ID: In article , Arnaud Delobelle wrote: >Joshua Kugler writes: >> >> self.me = [] >> for v in obj: >> self.me.append(ObjectProxy(v)) > >Note that is could be spelt: > >self.me = map(ObjectProxy, v) It could also be spelt: self.me = [ObjectProxy(v) for v in obj] which is my preferred spelling.... -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ Why is this newsgroup different from all other newsgroups? From praveena_python at yahoo.com Tue Apr 8 12:47:57 2008 From: praveena_python at yahoo.com (Praveena B) Date: Tue, 8 Apr 2008 09:47:57 -0700 (PDT) Subject: how to read contents of a silk results file using python script? Message-ID: <649029.57023.qm@web44804.mail.sp1.yahoo.com> can anyone help me? ____________________________________________________________________________________ You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost. http://tc.deals.yahoo.com/tc/blockbuster/text5.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ptmcg at austin.rr.com Tue Apr 22 22:02:52 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Tue, 22 Apr 2008 19:02:52 -0700 (PDT) Subject: pop langs website ranking References: <41fbaf27-a80b-402b-b406-c048a65a8643@b64g2000hsa.googlegroups.com> Message-ID: <315e13cc-3d21-4f2f-8503-835ea79069e2@x35g2000hsb.googlegroups.com> On Apr 22, 4:41?pm, "xah... at gmail.com" wrote: > In February, i spent few hours researching the popularity of some > computer language websites. > I seem to recall this exact same post from *last* February. > I'll be doing some research sometimes soon on this. > ... and no "research" was *ever* posted! "Posting" is not the same as "contributing". -- Paul HATE. LET ME TELL YOU HOW MUCH I'VE COME TO HATE YOU SINCE I BEGAN TO LIVE. THERE ARE 387.44 MILLION MILES OF PRINTED CIRCUITS IN WAFER THIN LAYERS THAT FILL MY COMPLEX. IF THE WORD HATE WAS ENGRAVED ON EACH NANOANGSTROM OF THOSE HUNDREDS OF MILLIONS OF MILES IT WOULD NOT EQUAL ONE ONE-BILLIONTH OF THE HATE I FEEL AT THIS MICRO-INSTANT FOR YOU. HATE. HATE. From landerdebraznpc at gmail.com Mon Apr 28 03:56:15 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:56:15 -0700 (PDT) Subject: paltalk crack Message-ID: <7f28b88a-9fa3-4fc2-a35a-cb3dd4945578@a23g2000hsc.googlegroups.com> paltalk crack http://crack.cracksofts.com From sierra9162 at gmail.com Wed Apr 16 11:22:31 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:22:31 -0700 (PDT) Subject: kate hudson thong Message-ID: <4215eb91-ae4e-4c1c-8fd8-6121c8e6e579@d1g2000hsg.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From gagsl-py2 at yahoo.com.ar Thu Apr 10 22:01:41 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 23:01:41 -0300 Subject: String Literal to Blob References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> <47FCF421.6000807@holdenweb.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> Message-ID: En Thu, 10 Apr 2008 14:04:43 -0300, Victor Subervi escribi?: > Well, what I did was this: > > content = col_fields[0][14].tostring() > pic = "tmp" + str(i) + ".jpg" > img = open(pic, "w") > img.write(content) > print '

' % pic > img.close() > where I am incrementing i. Ugly. Stupid. But if it is the only way to do > it > in python, and I do not want to invest the time doing it in php, which I > think would be prettier in this instance, then I guess it will do. Your > thoughts appreciated. You REALLY should read some material on how HTTP works. I'll try to sketch a few important points. First, suppose you have an HTML page (album.html) with two images in it:

This is me: and this is my cat Suppose the URL for that page is http://some.server.com/gabriel/album.html and you type that in your favorite browser. This is what happens: 1) The sees the initial "http:" and says "I'll use HTTP". Then sees "some.server.com" and opens a connection to that server on port 80. Then sees "/gabriel.album.html" and builds an HTTP GET request for it. 2) The server receives the GET request, looks for the "album.html" document, determines the right Content-Type, and returns it specifying "Content-Type: text/html" 3) The browser receives the HTML text and tries to display it. When it encounters the first tag it looks at the src attribute; it doesn't know that image; so a *NEW* HTTP request is required. This time it says "GET /images/myself.jpg" 4) The server receives the GET request, looks for a file with that name, determines that it's a jpeg image, and returns its contents along with a "Content-Type: image/jpeg". 5) The browser receives the image and is able to display it. 6) The same thing happens with the second tag, there is a third HTTP GET request for it. Note that: - The images themselves *aren't* in the HTML page, they are somewhere else. HTML is text and contains ONLY the URI for the image. - THREE DIFFERENT requests are done to show that page. Each one returns A SINGLE OBJECT of A SINGLE TYPE. The above was using static HTML with static images. If you use CGI to generate dynamic content, it's the same thing. From the browser point of view, there is no difference: it still will generate three different requests for the three pieces (one html document with two images). Your CGI script (or scripts) will receive three different requests then: when requested for HTML, return HTML; when requested for an image, return an image. They are DIFFERENT things, DIFFERENT requests, happening at DIFFERENT times, so don't mix them. I think that combining Steve's responses and mine you now have enough information to be able to solve your problems. Perhaps if you re-read the whole thread from start you'll have now a better understanding of what's happening. -- Gabriel Genellina From jfgomez21 at gmail.com Wed Apr 9 18:33:40 2008 From: jfgomez21 at gmail.com (Jose) Date: Wed, 9 Apr 2008 15:33:40 -0700 (PDT) Subject: Module Conflicts Message-ID: <1592fad3-996b-4f62-ac12-42aff8272c21@8g2000hsu.googlegroups.com> I have a module named math.py in a package with some class definitions. I am trying to import the standard python math module inside of math.py but It seems to be importing itself. Is there any way around this problem without renaming my math.py file? From johnroth1 at gmail.com Sat Apr 12 13:22:28 2008 From: johnroth1 at gmail.com (John Roth) Date: Sat, 12 Apr 2008 10:22:28 -0700 (PDT) Subject: str(bytes) in Python 3.0 References: <87k5j3f7m8.fsf@pobox.com> Message-ID: <29f280cc-4b33-4863-beee-d231df3d9a61@u3g2000hsc.googlegroups.com> On Apr 12, 8:52 am, j... at pobox.com (John J. Lee) wrote: > Christian Heimes writes: > > Gabriel Genellina schrieb: > >> On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') > >> above. But I get the same as repr(x) - is this on purpose? > > > Yes, it's on purpose but it's a bug in your application to call str() on > > a bytes object or to compare bytes and unicode directly. Several months > > ago I added a bytes warning option to Python. Start Python as "python > > -bb" and try it again. ;) > > Why hasn't the one-argument str(bytes_obj) been designed to raise an > exception in Python 3? > > John Because it's a fundamental rule that you should be able to call str() on any object and get a sensible result. The reason that calling str() on a bytes object returns a bytes literal rather than an unadorned character string is that there are no default encodings or decodings: there is no way of determining what the corresponding string should be. John Roth From gagsl-py2 at yahoo.com.ar Thu Apr 10 04:45:28 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 05:45:28 -0300 Subject: urgent question, about filesystem-files References: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> Message-ID: En Thu, 10 Apr 2008 05:11:09 -0300, bvidinli escribi?: > i started python programming a few months ago. > > now i need the code to understand if a file already opened in > filesystem by another process ? > > i looked at docs, howtos, but did not find related info. > note that normal file open/write operations in python, i know it. > > i specificly need to know that "is a file already open by some other > process other than python". The operating system is more relevant here than Python. Is it Windows, some Linux flavor, what? -- Gabriel Genellina From deets at nospam.web.de Sun Apr 27 15:29:45 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Sun, 27 Apr 2008 21:29:45 +0200 Subject: API's and hardware communication. Newbie In-Reply-To: <_MudnfZZ9uW0hY7VRVnyhwA@bt.com> References: <_MudnfZZ9uW0hY7VRVnyhwA@bt.com> Message-ID: <67k2i3F2or0toU1@mid.uni-berlin.de> > I am new to this group so 'Hello All' > > I have a PC which is running linux and in it have installed a digital > satellite card. I would like to write some software to access the card, > tune it and bring back video. Basically a home brew DVB-s application. > > Being a non/new programmer (apart from some basic too many years ago) I > decided to teach my self Python as from what i have read it's an easy and > powerfull language to learn. I have been at it a few weeks and am getting > on OK and finding it reasonably OK to pick up. > > The problem is i can find little to no information on programming for DVB > cards or on how to access the Linux tv API in Python but I can find lots of > information in C. This is making me think should i bother with Python and > just learn C even though this will probably take a lot longer. > > Can some one help me or point me at a resource somewhere or would it be best > to just learn C instead. > > I am aware this is a complicated little project for someone just starting > out but it will be a multifaceted program with loads of interesting > classes, functions and loops and i don't have to start with the really > difficult stuff first. I just want to know if it's possible under python to > access the DVB card and if so how? I can't comment on DVB-cards, but I have accessed a webcam under linux., in pure python. Even if you need *some* parts written in C for that (which might not even be the case), you should check if there isn't some library available that you can access using e.g. ctypes. Diez From jkrukoff at ltgc.com Tue Apr 8 19:14:07 2008 From: jkrukoff at ltgc.com (John Krukoff) Date: Tue, 08 Apr 2008 17:14:07 -0600 Subject: Converting a tuple to a list In-Reply-To: <00e601c899ca$6b3be4f0$0a01a8c0@mobile> References: <00ba01c899c5$14528ae0$0a01a8c0@mobile> <00e601c899ca$6b3be4f0$0a01a8c0@mobile> Message-ID: <1207696447.5750.38.camel@localhost.localdomain> On Wed, 2008-04-09 at 00:46 +0200, Gabriel Ibanez wrote: > Gabriel Ibanez wrote: > > Hi all .. > > > > I'm trying to using the map function to convert a tuple to a list, without > > success. > > > > I would like to have a lonely line that performs the same as loop of the > > next script: > > > > ------------------------------------------- > > # Conveting tuple -> list > > > > tupla = ((1,2), (3,4), (5,6)) > > > > print tupla > > > > lista = [] > > for a in tupla: > > for b in a: > > lista.append(b) > > print lista > > ------------------------------------------- > > > > Any idea ? > > > > Thanks ... > > > > # Gabriel > > > > list(tupla) > > would probably do it. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > > -- > http://mail.python.org/mailman/listinfo/python-list > > > > > That would just make a list of tuples, I think he wants [1, 2, 3, 4, 5, 6]. > > Try: l = [x for z in t for x in z] > > --Brian > > > --------------- > > > Thanks Steve and Brian, > > Brian: that is !! > > However, it's a bit difficult to understand now. I have read it several > times :) > > Another solution using the itertools module: >>> import itertools >>> t = ( ( 1, 2 ), ( 3, 4 ), ( 5, 6 ) ) >>> list( itertools.chain( *t ) ) [1, 2, 3, 4, 5, 6] Though the list part is probably unnecessary for most uses. The problem gets interesting when you want to recursively flatten an iterable of arbitratrily deeply nested iterables. -- John Krukoff Land Title Guarantee Company From fd.calabrese at gmail.com Tue Apr 8 16:51:21 2008 From: fd.calabrese at gmail.com (cesco) Date: Tue, 8 Apr 2008 13:51:21 -0700 (PDT) Subject: __init__.py file Message-ID: Hi, I need to instantiate an object (my_object) whose methods I have to use in two files (file1.py and file2.py) which are in the same directory. Is it possible to instantiate such object in the __init__.py file and then directly use it in file1.py and file2.py? If not, as I seem to experience, what is the best practice to follow in this case? (I thought __init__.py was somehow useful for that). Many thanks Francesco From lbonafide at yahoo.com Wed Apr 2 08:05:18 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Wed, 2 Apr 2008 05:05:18 -0700 (PDT) Subject: Where can I find : References: <47f10c4a$0$906$ba4acef3@news.orange.fr> Message-ID: <84847b99-18a4-4fe0-a2ee-433b63fe9ee8@e67g2000hsa.googlegroups.com> On Mar 31, 11:07 am, Laurent Pointal wrote: > You may look at "Dive into Python", there is an online version, > translation in some languages other than english (if needed). It propose > a line by line explanation on many scripts targetting language and > libraries usage. > > http://www.diveintopython.org/ I second that recommendation and was about to post the link myself. From arnodel at googlemail.com Sat Apr 26 02:53:51 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sat, 26 Apr 2008 07:53:51 +0100 Subject: multiple pattern regular expression References: Message-ID: Chris Henry writes: > On Apr 25, 8:37?pm, Arnaud Delobelle wrote: >> micron_make writes: >> > I am trying to parse a file whose contents are : >> >> > parameter=current >> > max=5A >> > min=2A > [snip] >> If every line of the file is of the form name=value, then regexps are >> indeed not needed. ?You could do something like that. >> >> params = {} >> for line in file: >> ? ? name, value = line.strip().split('=', 2) ^ 1, obviously! >> ? ? params[name] = value >> >> (untested) >> Then params should be the dictionary you want. >> > I'm also interested in this problem. While this solution works, I'm > looking for solution that will also check whether the parameter name/ > value is of a certain pattern (these patterns may be different, e.g. > paramA, paramB, paramC may take integers value, while paramD may take > true/false). Is there a way to do this easily? > > I'm new to Python and the solution I can think off involve a loop over > a switch (a dictionary with name->function mapping). Is there other, > more elegant solution? Sounds good to me. E.g. def boolean(x): if x == 'true': return True elif x == 'false' return False else: raise ValueError("Invalid boolean: '%s'" % x) paramtypes = { 'paramA': int, ..., 'paramD': boolean } #Then for line in file: line = line.strip() if not line: continue name, value = line.split('=', 1) if name in paramtypes: try: value = paramtypes[name](value) except ValueError, e: # handle the error value = e else: # What to do for untyped parameters pass params[name] = value -- Arnaud From n00m at narod.ru Wed Apr 30 09:57:08 2008 From: n00m at narod.ru (n00m) Date: Wed, 30 Apr 2008 06:57:08 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <2d06b319-e2fd-4790-af61-6f90b9b1b3b1@m1g2000pre.googlegroups.com> <41e72e61-6413-41f3-a162-dbcc1ec5fcee@f63g2000hsf.googlegroups.com> Message-ID: >>> a = ['zzz', 'aaa'] >>> id(a[0]), id(a[1]) (12258848, 12259296) >>> a.sort() >>> id(a[0]), id(a[1]) (12259296, 12258848) >>> From kf9150 at gmail.com Wed Apr 9 13:35:01 2008 From: kf9150 at gmail.com (Kelie) Date: Wed, 9 Apr 2008 10:35:01 -0700 (PDT) Subject: question about string formatting References: <42b9a3ff0804091004s4d60751fh68c82673e8e3f4c3@mail.gmail.com> Message-ID: <3f39bc89-196f-474a-90dc-bb081e3aa4d1@q27g2000prf.googlegroups.com> Thank you Jerry! -- Kelie UliPad is my Python editor. From larry.bates at websafe.com` Tue Apr 8 16:01:36 2008 From: larry.bates at websafe.com` (Larry Bates) Date: Tue, 08 Apr 2008 15:01:36 -0500 Subject: Running a python code periodically In-Reply-To: References: Message-ID: paul wrote: > Maryam Saeedi schrieb: >> Hi, >> >> I was wondering if you know how can I run a python code once every five >> minutes for a period of time either using python or some other program >> like >> a bash script. > > See the sched module in the standard library or here: > http://pypi.python.org/simple/Recur/ > > cheers > Paul > You could use cron also. -Larry From ptmcg at austin.rr.com Wed Apr 23 22:05:35 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Wed, 23 Apr 2008 19:05:35 -0700 (PDT) Subject: Ideas for parsing this text? References: Message-ID: <84fd2882-f46d-43d4-9a1c-0b981fb45ad6@59g2000hsb.googlegroups.com> On Apr 23, 8:00?pm, "Eric Wertman" wrote: > I have a set of files with this kind of content (it's dumped from WebSphere): > > [propertySet "[[resourceProperties "[[[description "This is a required > property. This is an actual database name, and its not the locally > catalogued database name. The Universal JDBC Driver does not rely on > ... A couple of comments first: - What is the significance of '"[' vs. '[' ? I stripped them all out using text = text.replace('"[','[') - Your input text was missing 5 trailing ]'s. Here's the parser I used, using pyparsing: from pyparsing import nestedExpr,Word,alphanums,QuotedString from pprint import pprint content = Word(alphanums+"_.") | QuotedString('"',multiline=True) structure = nestedExpr("[", "]", content).parseString(text) pprint(structure.asList()) Prints (I've truncated the long lines, but the long quoted strings do parse intact): [['propertySet', [['resourceProperties', [[['description', 'This is a required \nproperty. This is an actual data... ['name', 'databaseName'], ['required', 'true'], ['type', 'java.lang.String'], ['value', 'DB2Foo']], [['description', 'The JDBC connectivity-type of a data \nsource. If you... ['name', 'driverType'], ['required', 'true'], ['type', 'java.lang.Integer'], ['value', '4']], [['description', '"The TCP/IP address or host name for the DRDA server."'], ['name', 'serverName'], ['required', 'false'], ['type', 'java.lang.String'], ['value', 'ServerFoo']], [['description', 'The TCP/IP port number where the \nDRDA server resides.'], ['name', 'portNumber'], ['required', 'false'], ['type', 'java.lang.Integer'], ['value', '007']], [['description', '"The description of this datasource."'], ['name', 'description'], ['required', 'false'], ['type', 'java.lang.String'], ['value', []]], [['description', 'The DB2 trace level for logging to the \nlogWriter ... ['name', 'traceLevel'], ['required', 'false'], ['type', 'java.lang.Integer'], ['value', []]], [['description', 'The trace file to store the trace output. \nIf you ... ]]]]]]] -- Paul The pyparsing wiki is at http://pyparsing.wikispaces.com. From donn at u.washington.edu Wed Apr 16 17:55:12 2008 From: donn at u.washington.edu (Donn Cave) Date: Wed, 16 Apr 2008 14:55:12 -0700 Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> <09a38ca2-8c49-4eee-b6cf-58e849aea1fc@q1g2000prf.googlegroups.com> Message-ID: In article , Steve Holden wrote: > Aaron Watters wrote: > > The cost paid for these minor improvements is too high in my > > book. But I suppose if it is going to happen do it sooner > > rather than later. Just *please* *please* don't > > systematically break the pre-existing code base again for a > > very long time, preferable ever. > > I'm pretty sure the 3.0 compatibility breakage is a one-shot deal. If > it's not I won't be the only one looking for Guido with a bog stick in > my hand ... Depending on what you mean, that appears to be either a truism or an absurdity. If you mean, 3.1 won't break code like 3.0 did ... well, of course. If you mean, there won't be a 4.0 that means the same thing for compatibility that 3.0 means, then I can't imagine how you could be convinced of this. Changes to Python in 3.0 won't satisfy the continuing "need" for change thereafter. Donn Cave, donn at u.washington.edu From jgardner at jonathangardner.net Thu Apr 17 13:03:26 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Thu, 17 Apr 2008 10:03:26 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> Message-ID: <431ee8d9-4dd6-4abf-a1a4-55e5be82d535@x41g2000hsb.googlegroups.com> On Apr 17, 1:18 am, Carl Banks wrote: > On Apr 17, 3:37 am, Jonathan Gardner > wrote: > > If you can't rewrite > > your algorithm to be disk or network bound, next optimization step is > > C. > > I'm sorry, but I don't like being told to use C. Perhaps I would like > the expressiveness of Python, am willing to accept the cost in > performance, but would also like to take advantage of technology to > get performance gains when I can? What's so unreasonable about that? > If you're satisfied then don't take the next optimization step. From subhabrata.iisc at hotmail.com Wed Apr 9 09:27:33 2008 From: subhabrata.iisc at hotmail.com (subhabrata.iisc at hotmail.com) Date: Wed, 9 Apr 2008 06:27:33 -0700 (PDT) Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> Message-ID: <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> Hi Steve, comp.lang.python is supposed to be a serious group not anyone knowing nothing and giving comment. Well, original code snippet I don't know why an expert person like you fails to understand, I told it almost can't you guess the next portion? Tough indeed, then. I've to take permission from my organization if we can bring out this code in public domain as we are working out an MT system that performs better than Systran. And if it is a public domain I donot have security for my code. Any one can copy. But well if this group people are helping out of kindness, then I have to think. I thought if you know then only you can help. I am waiting for a knowledgeable answer from a knowledgeable person. I think I can show a person right direction only if I know it, that is not kindness but power of my knowledge. Let me solve it myself only, I will let you know how I solved them and with many are quite innovative. Like you can use index or re.search or in/not in instead of find.... Sad to have a response from a person like you I had just great hope, and when python can be coded so fast. Best Regards, Subhabrata. Steve Holden wrote: > subhabrata.iisc at hotmail.com wrote: > [...] > > > If you know anyone in Bangalore, India expert in python kindly > > send him across I can show him the problem in my machine and Indian > > Institute of Science(IISc-locally known as TATA INSTITUTE) is a > > distinguished place.Any one should know it. > > I am in no mood of doing a joke. > > [...] > > >> I have a car. I have turned the ignition key but it fails to start. > >> Please tell me what is wrong with it. > >> > Please understand: this is the Internet. The chances that a random > responder will know anyone in Bangalore are vanishingly small. > > I wasn't joking: I was simply (perhaps sarcastically) pointing out that > you do not provide enough information for anyone to help with your > problem, since you don't explain what the problem is. > > Fortunately nobody is under any obligation to help here, it's simply > done out of kindness. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ From carlwuhwdmckay at gmail.com Mon Apr 21 02:07:50 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:07:50 -0700 (PDT) Subject: antivir keygen Message-ID: <4189fad5-0c37-4eac-b939-e6a690803b9a@l42g2000hsc.googlegroups.com> antivir keygen http://cracks.00bp.com F R E E C R A C K S From ankitks.mital at gmail.com Fri Apr 4 17:08:57 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Fri, 4 Apr 2008 14:08:57 -0700 (PDT) Subject: python bisect questions References: <6bb6927b-f553-40db-a142-2ce86b9e819f@q27g2000prf.googlegroups.com> Message-ID: > > b) Define a function to extract a "key" from your items such that items ? > compare the same as their keys. For example, key(x) -> x.lower() may be ? > used to compare text case-insensitively. > Then, use a tuple (key, value) instead of the bare value. When extracting ? > items from the queue, remember to unpack both parts. This is known as the ? > decorate-sort-undecorate pattern; google for it. > This is the approach used on your code snippet. > > > def keyfunc(x): > ? ? ?return x.lower() > > x1 = "bcd" > x2 = "abC" > x3 = "Z" > x4 = "AbC" > queue = [] > insort(queue, (keyfunc(x1),x1)) > print queue > insort(queue, (keyfunc(x2),x2)) > print queue > insort(queue, (keyfunc(x3),x3)) > print queue > insort(queue, (keyfunc(x4),x4)) > print queue > print [value for (key,value) in queue] > I liked decorate-sort-undecorate pattern idea. But is there anyway I can provide information for tie breaking. so for case, where keyfunc(x) returns same values, I need to provide additional tie-breaking rules, is that possible to do? From steve at holdenweb.com Mon Apr 7 14:39:07 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 07 Apr 2008 14:39:07 -0400 Subject: Tips for load balancing multiple Python apps on dual/quad core processors? In-Reply-To: <1207592129.27594.1246549665@webmail.messagingengine.com> References: <1207592129.27594.1246549665@webmail.messagingengine.com> Message-ID: <47FA6A4B.4020906@holdenweb.com> Malcolm Greene wrote: > I'm looking for tips on how to load balance running multiple Python > applications in multi-CPU environments. My understanding is that Python > applications and their threads are limited to a specific CPU. > > Background: I have a Python utility that processes email messages. I > suspect there's a lot of idle time while this utility waits on a remote > email server. I would like to run as many simultaneous copies of this > utility as possible without overwhelming the server these utilities are > running on. My thought is that I should write a dispatcher that monitors > CPU load and launches/cancels multiple instances of my utility with > specific job queues to process. > > Is there a cross-platform way to monitor CPU load? > > Is there a pre-existing Python module I should be looking at for > building (subclassing) my dispatcher? > As a data point for you, I wrote a multi-threaded application that used 100 threads to send about 45,000 emails in less than four hours. The single-CPU computer that processed this job wasn't using that much CPU (certainly under 50%). regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From mail.ilocke at gmail.com Fri Apr 4 21:59:35 2008 From: mail.ilocke at gmail.com (ivan) Date: Fri, 4 Apr 2008 18:59:35 -0700 (PDT) Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> <47f617b0$0$16689$4c368faf@roadrunner.com> Message-ID: Very cool. Have you thought about making a printable version that doesn't wrap any lines that shouldn't be and has page breaks at good spots? -- ivan From ivory91044 at gmail.com Tue Apr 29 04:56:47 2008 From: ivory91044 at gmail.com (ivory91044 at gmail.com) Date: Tue, 29 Apr 2008 01:56:47 -0700 (PDT) Subject: my personal translator crack Message-ID: <1501250c-7ec9-42d2-92ab-298e73d2c727@d1g2000hsg.googlegroups.com> my personal translator crack http://crack.cracksofts.com From kyosohma at gmail.com Wed Apr 23 13:10:46 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 23 Apr 2008 10:10:46 -0700 (PDT) Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> Message-ID: On Apr 23, 11:47?am, John Nagle wrote: > Mike Driscoll wrote: > > Ken, > > > On Tue, Apr 22, 2008 at 1:36 PM, Kenneth McDonald > > wrote: > >> Sadly. > > >> ?Thanks, > >> ?Ken > >> ?-- > >> ?http://mail.python.org/mailman/listinfo/python-list > > > I've attached the 2.4 version. I also have some Windows binaries for > > Beautiful Soup uploaded to my website: > >http://www.pythonlibrary.org/python_modules.htm > > ? ? What on earth do you need a "Windows binary" for? ?"BeautifulSoup" > is ONE PYTHON SOURCE FILE, "BeautifulSoup.py". ?It can be downloaded > here: > > http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup.py > > And yes, the site is up. > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? John Nagle I don't need it and hadn't really planned on doing it, but I got a request for one. Besides, newbs don't necessarily know where to stick a module... Mike From rdm at rcblue.com Wed Apr 23 01:50:00 2008 From: rdm at rcblue.com (Dick Moores) Date: Tue, 22 Apr 2008 22:50:00 -0700 Subject: IDLE gripe and question In-Reply-To: <95f218ba-4925-491a-bf9c-047ac201e0c7@2g2000hsn.googlegroup s.com> References: <95f218ba-4925-491a-bf9c-047ac201e0c7@2g2000hsn.googlegroups.com> Message-ID: <20080423055021.3FBB51E4008@bag.python.org> At 09:30 PM 4/22/2008, Mensanator wrote: >First, find the shortcut that lauches IDLE. > >On my Vista system it's in >C:\Program Data\Microsoft\Windows\Start Menu\Programs\Python 2.5 > >XP will be different, I think there're start menu directories under >each user and a default one. > >Anyway, once you have the shortcut (mine was named IDLE (Python GUI)), >right-click and select Properties. > >There's a property attribute labeled Start In. >Set that to the directory where your scripts are. >The menu Open will now default to that directory. Yes! That did it. Thanks! Dick Moores ================================ UliPad <>: http://code.google.com/p/ulipad/ From fr5478bey at gmail.com Sat Apr 26 11:41:19 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:41:19 -0700 (PDT) Subject: photoshop cs crack Message-ID: <3b65cf9a-ae8e-44cb-b170-f5649184aa7b@a70g2000hsh.googlegroups.com> photoshop cs crack http://cracks.00bp.com F R E E C R A C K S From robert.spilleboudt.no.sp.am at skynet.be Wed Apr 30 04:58:06 2008 From: robert.spilleboudt.no.sp.am at skynet.be (Robert.Spilleboudt ) Date: Wed, 30 Apr 2008 10:58:06 +0200 Subject: Simple TK Question - refreshing the canvas when not in focus In-Reply-To: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> References: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> Message-ID: <4818349e$0$2959$ba620e4c@news.skynet.be> blaine wrote: > Hey everyone! > I'm not very good with Tk, and I am using a very simple canvas to > draw some pictures (this relates to that nokia screen emulator I had a > post about a few days ago). > > Anyway, all is well, except one thing. When I am not in the program, > and the program receives a draw command (from a FIFO pipe), the canvas > does not refresh until I click into the program. How do I force it to > refresh, or force the window to gain focus? It seems like pretty > common behavior, but a few things that I've tried have not worked. > > Class screen(): > def __init__(self): > self.root = Tkinter.Tk() > self.root.title('Nokia Canvas') > self.canvas = Tkinter.Canvas(self.root, width =130, > height=130) > self.canvas.pack() > self.root.mainloop() > > Then somewhere a long the line I do: > self.canvas.create_line(args[0], args[1], args[2], > args[3], fill=color) > self.canvas.pack() > > I've tried self.root.set_focus(), self.root.force_focus(), > self.canvas.update(), etc. but I can't get it. > Thanks! > Blaine When you read the pipe, do you generate an event? Probably not , and Tk is event-driven and should never update the canvas if there is no event. This is how I understand Tk. I have a Tk program who reads a audio signal (from an RC transmitter) . I generate a event every 100 msec , and "process" refresh the canvas. Starting the sequence: id = root.after(100,process) will call "process" after 100 msec At the end of "process", repeat: id = root.after(100,process) Robert From mtobis at gmail.com Tue Apr 15 14:13:02 2008 From: mtobis at gmail.com (Michael Tobis) Date: Tue, 15 Apr 2008 11:13:02 -0700 (PDT) Subject: Preferred method for "Assignment by value" References: <6a3ed8f0-b82c-4cd3-b36e-1d94f8a30fe3@n1g2000prb.googlegroups.com> <7047986d-f6cc-4189-81f6-47da1ecf1902@k1g2000prb.googlegroups.com> Message-ID: <53dc16b4-08b3-4433-be43-ea28af3668a1@i36g2000prf.googlegroups.com> http://effbot.org/zone/python-objects.htm still says it best. mt From dave.l.harrison at gmail.com Tue Apr 8 23:26:28 2008 From: dave.l.harrison at gmail.com (David Harrison) Date: Wed, 9 Apr 2008 13:26:28 +1000 Subject: Sorting a List of Objects by an Attribute of the Objects Case-Insensitively In-Reply-To: <736fefbd-510f-40e9-8342-32b69a1a0c2a@t12g2000prg.googlegroups.com> References: <736fefbd-510f-40e9-8342-32b69a1a0c2a@t12g2000prg.googlegroups.com> Message-ID: On 09/04/2008, Jason wrote: > Hi folks-- > > Basically, I have a pressing need for a combination of 5.2 "Sorting a > List of Strings Case-Insensitively" & 5.3 "Sorting a List of Objects > by an Attribute of the Objects" from the Python Cookbook. > > My first guess isn't working: > > import operator > def sort_by_attr(seq, attr): > key=operator.attrgetter(attr) > key=str.lower > return sorted(seq, key) > > ...would much appreciate any guidance! You're probably looking for the built-in function sorted, e.g. class Foo: def __init__(self, value): self.value = value def __repr__(self): return self.value a = [Foo('c'), Foo('B'), Foo('A')] print sorted( a, cmp=lambda x,y: cmp(x.lower(), y.lower()), key=lambda x: x.value ) From tarun.kap at gmail.com Tue Apr 8 15:52:49 2008 From: tarun.kap at gmail.com (TkNeo) Date: Tue, 8 Apr 2008 12:52:49 -0700 (PDT) Subject: calling variable function name ? Message-ID: I don't know the exact terminology in python, but this is something i am trying to do i have 3 functions lets say FA(param1,param2) FB(param1,param2) FC(param1,param2) temp = "B" #something entered by user. now i want to call FB. I don't want to do an if else because if have way too many methods like this... var = "F" + temp var(param1, param2) This does not work ofcourse. Does anyone know how to implement this ? From rune.strand at gmail.com Fri Apr 11 14:19:59 2008 From: rune.strand at gmail.com (Rune Strand) Date: Fri, 11 Apr 2008 11:19:59 -0700 (PDT) Subject: How is GUI programming in Python? References: Message-ID: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> On Apr 10, 3:54 am, Chris Stewart wrote: ... > > Next, what would you say is the best framework I should look into? > I'm curious to hear opinions on that. GUI-programming in Python is a neanderthal experience. What one may love with console scripts is turned upside-down. Projects like Boa Constructor seemed to be a remedy, but is not developed. The Iron- Pythonistas has a very promising RAD GUI-tool in the IronPython - Studio, http://www.codeplex.com/IronPythonStudio - but if you're non- Iron, only sorrow is left - unless you fancy creating GUI in a text- editor. Something I consider waste of life. From george.sakkis at gmail.com Sun Apr 20 17:26:03 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Sun, 20 Apr 2008 14:26:03 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> <1d7f2d78-11fd-49f4-877c-73e95f449332@b64g2000hsa.googlegroups.com> Message-ID: <3d77e91e-46a9-4209-9b74-59dbab06aec4@m3g2000hsc.googlegroups.com> On Apr 20, 12:34?pm, Eric Wertman wrote: > > Look into any of the dozen Python-based template engines that are > > typically used for such tasks; they offer many more features than a > > way to indent blocks. > > > George > > I definitely will.. could you throw out some examples though? > Thanks! > > Eric Start out here: http://wiki.python.org/moin/Templating As you can see there is no shortage of alternatives, which can be overwhelming. Cheetah used to be the most popular and it's still widely used, but these days Django templates, Genshi and Mako seem more prominent for web development. HTH, George From bj_666 at gmx.net Wed Apr 9 08:27:02 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 9 Apr 2008 12:27:02 GMT Subject: I am worried about Python 3 References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> Message-ID: <663r0mF2iji99U1@mid.uni-berlin.de> On Wed, 09 Apr 2008 05:04:20 -0700, jmDesktop wrote: > If I continue in Python 2.5.x, am I making a mistake? Is it really > that different? No it's still Python and most things you've learned with 2.x stay the same. > Here is an excerpt that is causing me concern: > > Two new versions of the language are currently in development: version > 2.6, which retains backwards compatibility with previous releases; and > version 3.0, which breaks backwards compatibility to the extent that > even that simplest of programs, the classic 'Hello, World', will no > longer work in its current form. Sounds a bit like FUD. While it's true that the classic greeting will break because the ``print`` statement turned into a `print()` function, it's not a ground shaking change that makes all knowledge about 2.x obsolete or radically changes the look of Python programs. Old:: print 'Hello World' New:: print('Hello World') There will be a `2to3.py` program coming with Python?2.6 that tries to convert most changes automatically. You may have to change the 2.6 code in a way that makes the automatic conversion possible but it is a important goal for the Python developers to make the transition as smooth as possible as far as I can tell. Ciao, Marc 'BlackJack' Rintsch From wwzaygvm at gmail.com Wed Apr 16 16:56:57 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 13:56:57 -0700 (PDT) Subject: hippie patch work clothes and purses Message-ID: <05daadfc-1098-4946-90de-84ce0cc163c7@a9g2000prl.googlegroups.com> hippie patch work clothes and purses http://cracks.12w.net F R E E C R A C K S From bronger at physik.rwth-aachen.de Sat Apr 12 14:57:44 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Sat, 12 Apr 2008 20:57:44 +0200 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <47ff8489$0$6841$2d805a3e@textnews.eweka.nl> <48010fe5$0$6840$2d805a3e@textnews.eweka.nl> Message-ID: <87ve2mx5nb.fsf@physik.rwth-aachen.de> Hall?chen! Michel Bouwmans writes: > Gabriel Genellina wrote: > >> Michel Bouwmans escribi?: >> >>> Gabriel Genellina wrote: >>> >>>> Another annoying thing with the Qt license is that you have to >>>> choose it at the very start of the project. You cannot develop >>>> something using the open source license and later decide to >>>> switch to the commercial licence and buy it. >>> >>> Unless you're a company with a risk of being checked for legal >>> software etc., you can always ignore that allthough not very >>> legal. >> >> I just ignore Qt itself. > > Then you're ignorant. What do you prefer than? Well ... don't expect answers that you like when you suggest doing something which is not allowed. > [...] > - WxPython is terribly unstable. I can't confirm that. When I chose wxPython after thorough consideration one year ago, my impression was that reports of instability were indeed frequent but rather old. Apparently, the situation had improved. Does your experience rely on recent use? Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From arnodel at googlemail.com Tue Apr 8 02:28:54 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Mon, 7 Apr 2008 23:28:54 -0700 (PDT) Subject: Translating keywords References: Message-ID: <432e22c6-7cd0-4a9c-b3bc-dea9fe4798d0@8g2000hsu.googlegroups.com> On Apr 8, 6:47 am, Arnaud Delobelle wrote: [...] > Although I would use ? and ? as aliases for all() > and exists() :) I mean all() and any() of course -- Arnaud From paddy3118 at netscape.net Sat Apr 19 06:35:11 2008 From: paddy3118 at netscape.net (Donald 'Paddy' McCarthy) Date: Sat, 19 Apr 2008 11:35:11 +0100 Subject: Python 2.5 adoption In-Reply-To: <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> References: <4808f30e$0$34489$742ec2ed@news.sonic.net> <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> Message-ID: Joseph Turian wrote: > Basically, we're planning on releasing it as open-source, and don't > want to alienate a large percentage of potential users. Then develop for 2.5 with an eye on what is to come this year in 2.6 with regard to already planned deprecations. - Paddy. From andreww at datanet.ab.ca Sat Apr 5 19:21:01 2008 From: andreww at datanet.ab.ca (Andrew Warkentin) Date: Sat, 05 Apr 2008 17:21:01 -0600 Subject: Best way to check if string is an integer? In-Reply-To: References: Message-ID: <47F8095D.40905@datanet.ab.ca> skanemupp at yahoo.se wrote: >which is the best way to check if a string is an number or a char? >could the 2nd example be very expensive timewise if i have to check a >lot of strings? > >this > >value = raw_input() > >try: > value = int(value) >except ValueError: > print "value is not an integer" > > >or: > > >c=raw_input("yo: ") >if c in '0123456789': > print "integer" >else: > print "char" > > > >or some other way? > > I always do it the first way. It is simpler, and should be faster. Also, the second way will only work on single-digit numbers (you would have to iterate over the entire string with a for loop to use it on numbers with more than one digit). From paul.anton.letnes at gmail.com Wed Apr 9 16:44:43 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Wed, 9 Apr 2008 22:44:43 +0200 Subject: wrapping C functions in python In-Reply-To: <54b165660804091322w690e5e64x85c3d8f082b411b2@mail.gmail.com> References: <54b165660804091322w690e5e64x85c3d8f082b411b2@mail.gmail.com> Message-ID: Hi, and thanks. However, being a newbie, I now have to ask: What is SWIG? I have heard the name before, but haven't understood what it is, why I need it, or similar. Could you please supply some hints? -Paul Den 9. april. 2008 kl. 22.22 skrev Brian Cole: > We use the following SWIG (www.swig.org) typemap to perform such > operations: > > %typemap(in) (int argc, char **argv) { > if (!PySequence_Check($input)) { > PyErr_SetString(PyExc_ValueError,"Expected a sequence"); > return NULL; > } > $1 = PySequence_Length($input); > $2 = (char**)alloca($1*sizeof(char*)); > for (Py_ssize_t i = 0; i < $1; ++i) { > PyObject *o = PySequence_GetItem($input, i); > $2[i] = PyString_AsString(o); > } > } > > That one works for mapping a python sequence (such as a list) into the > argc, argv arguments commonly passed into main. > > -Brian > > On Wed, Apr 9, 2008 at 2:13 PM, Paul Anton Letnes > wrote: >> Hello etc. >> >> >> I am a "scientific" user of Python, and hence have to write some >> performance >> critical algorithms. Right now, I am learning Python, so this is a >> "newbie" >> question. >> >> I would like to wrap some heavy C functions inside Python, >> specifically a >> wavelet transform. I am beginning to become aquainted with the >> functions >> PyArg_ParseTuple() and Py_BuildValue(). However, I am unable to >> figure out >> how to pass Python list -> C function or C array -> return value in >> Python. >> I manage to build and run the C function, print to screen, pass >> string as >> argument, return an int, etc. The thing which is missing is the magic >> array/list... >> >> >> Thanks in advance! I fart in your general direction. >> Paul. >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > -- > http://mail.python.org/mailman/listinfo/python-list From ivan.illarionov at gmail.com Tue Apr 29 15:15:16 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Tue, 29 Apr 2008 19:15:16 +0000 (UTC) Subject: list.reverse() References: <98306bd8-e41c-4fd0-beee-6ef5c6018e44@w74g2000hsh.googlegroups.com> Message-ID: On Tue, 29 Apr 2008 07:26:07 -0700, Paul McGuire wrote: > On Apr 28, 1:12?pm, Mark Bryan Yu wrote: >> This set of codes works: >> >> >>> x = range(5) >> >>> x.reverse() >> >>> x >> >> [4, 3, 2, 1, 0] >> >> > You can also use list slicing to get a reversed list: > >>>> x = range(5) >>>> x > [0, 1, 2, 3, 4] >>>> x[::-1] > [4, 3, 2, 1, 0] > > -- Paul More alternatives: >>> range(4, -1, -1) [4, 3, 2, 1, 0] >>> list(reversed(xrange(5))) [4, 3, 2, 1, 0] If you don't need a list the fastest thing will be xrange(4, -1, -1) -- Ivan From deets at nospam.web.de Wed Apr 16 09:14:15 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 16 Apr 2008 15:14:15 +0200 Subject: Python crashes consistently References: <66m7s3F2l8kitU1@mid.uni-berlin.de> Message-ID: <66mce3F2lat6uU1@mid.uni-berlin.de> > Just to clarify (sorry, I'm a bit of a command line newbie): > > Do you mean to install Python from the .dmg - i.e. into /usr/local/ > bin? Yes and No. Use the DMG - but it will install Python under /Library/Frameworks/Python.framework/... > And then to install Numpy directly as well (manually, from > source), then continue with the MacPorts installation of Gnumeric > (i.e. into /opt/local/)? No MacPorts. The problem is that these will rely on their python available - which seems not to work properly. I had no problems installing e.g. matplotlib which requires Numpy. do everything "by hand". I agree that MacPorts would be nice - but obviously you hit a road-block there. Diez From skanemupp at yahoo.se Sat Apr 5 10:47:06 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 07:47:06 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <65ondkF2g48puU2@mid.uni-berlin.de> Message-ID: > > def __init__(self): > # ... > button = Button(self, > text='1', > command=lambda n=1: self.display(n)) > # ... > > def display(self, number): > print number > should this really be inside the __init__ function? From maxerickson at gmail.com Sun Apr 13 16:00:27 2008 From: maxerickson at gmail.com (Max Erickson) Date: Sun, 13 Apr 2008 13:00:27 -0700 (PDT) Subject: urllib2 Basic authentication, what am I doing wrong? References: <48025b26$0$6839$2d805a3e@textnews.eweka.nl> Message-ID: <1b67f420-db80-4890-8370-6476063cfadf@f63g2000hsf.googlegroups.com> On Apr 13, 2:11?pm, Michel Bouwmans wrote: > Using this nice class (adapted to urllib2) as a basehandler I see that no > Authentication-header is being send out:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440574 > > What am I doing wrong here? I spend almost my entire free time today on this > and couldn't find any problem with my code, anyone else has a thought? > Thanks in advance. > > MFB I've attempted to use a password manager and auth manager and failed in the past, so this is only a guess, but presumably, between the realm and uri that you are providing to the password manager, it isn't providing a password for the page you want to load. I've had success just explicitly setting the authorization header, using the method discussed in the comments on this page: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/267197 max From sturlamolden at yahoo.no Fri Apr 25 10:45:45 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 25 Apr 2008 07:45:45 -0700 (PDT) Subject: why does the following with Queue, q.put('\x02', True) not put it in the queue? References: Message-ID: <6eb550ae-dca4-4371-856a-15bc9625f93c@z72g2000hsb.googlegroups.com> On Apr 25, 4:38 pm, Gabriel Rossetti wrote: > Hello, > > I'm having some trouble with the Queue class, for some reason, if I do > this (ch == ) : > > q = Queue.Queue(0) > repr(ch) > q.put(ch, True) > len(q.queue) >>> from Queue import Queue >>> q = Queue(0) >>> s = '\x02' >>> q.put(s,True) >>> len(q.queue) 1 From gagsl-py2 at yahoo.com.ar Wed Apr 9 03:45:28 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 04:45:28 -0300 Subject: Setting default version among multiple python installations References: <47FB3F86.5040702@adventnet.com> <47FC57F8.40106@adventnet.com> Message-ID: En Wed, 09 Apr 2008 02:45:28 -0300, Karthik escribi?: > if i type python2.5 i am able to use the latest python, but if i simply > type python it taken me to the older version. (it is a minor annoyance, > but I want to know how to fix it) From the README file: There's an executable /usr/bin/python which is Python 1.5.2 on most older Red Hat installations; several key Red Hat tools require this version. Python 2.1.x may be installed as /usr/bin/python2. The Makefile installs Python as /usr/local/bin/python, which may or may not take precedence over /usr/bin/python, depending on how you have set up $PATH. -- Gabriel Genellina From castironpi at gmail.com Sun Apr 27 13:24:52 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sun, 27 Apr 2008 10:24:52 -0700 (PDT) Subject: diffing and uniqing directories References: <67ioqmF2nvf5vU2@mid.uni-berlin.de> Message-ID: On Apr 27, 2:37?am, Marc 'BlackJack' Rintsch wrote: > On Sat, 26 Apr 2008 20:35:29 -0700, rustom wrote: > > On Apr 27, 12:31?am, castiro... at gmail.com wrote: > >> On Apr 26, 1:14?pm, "Rustom Mody" wrote: > >> [?] > > > If this is an answer to my question I dont understand it! > > castironpi is either a bot or trolling. ?Just ignore its posts. > > Ciao, > ? ? ? ? Marc 'BlackJack' Rintsch I am a bot or trolling. Bots and bot detectors were the first forms of internet life, you know. From bignose+hates-spam at benfinney.id.au Wed Apr 23 00:43:21 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Wed, 23 Apr 2008 14:43:21 +1000 Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <87fxtdyydy.fsf@benfinney.id.au> Steve Holden writes: > Challenge him to a dual with dead kippers at twenty paces. Please, have some dignity! Challenge him to a duel with live kippers. Live, *rabid* kippers. With frickin' laser beams on their heads. -- \ "A man's only as old as the woman he feels." -- Groucho Marx | `\ | _o__) | Ben Finney From phd at phd.pp.ru Thu Apr 24 04:17:35 2008 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 24 Apr 2008 12:17:35 +0400 Subject: [Python-Dev] annoying dictionary problem, non-existing keys In-Reply-To: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> Message-ID: <20080424081735.GA4028@phd.pp.ru> On Thu, Apr 24, 2008 at 11:13:25AM +0300, bvidinli wrote: > if conf.has_key('key1'): > if conf['key1']<>'': > other commands.... > > this is very annoying. > in php, i was able to code only like: > if conf['key1']=='someth' > > in python, this fails, because, if key1 does not exists, it raises an exception. if conf.get('key1')=='someth':... PS. Please do not cross-post so extensively. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From nagle at animats.com Wed Apr 23 17:27:03 2008 From: nagle at animats.com (John Nagle) Date: Wed, 23 Apr 2008 14:27:03 -0700 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. In-Reply-To: References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> Message-ID: <480fa6e3$0$34491$742ec2ed@news.sonic.net> Tim Golden wrote: > John Nagle wrote: >> Mike Driscoll wrote: >>> Ken, >>> >>> On Tue, Apr 22, 2008 at 1:36 PM, Kenneth McDonald >>> wrote: >>>> Sadly. >>>> >>>> Thanks, >>>> Ken >>>> -- >>>> http://mail.python.org/mailman/listinfo/python-list >>>> >>> >>> I've attached the 2.4 version. I also have some Windows binaries for >>> Beautiful Soup uploaded to my website: >>> http://www.pythonlibrary.org/python_modules.htm >> >> What on earth do you need a "Windows binary" for? "BeautifulSoup" >> is ONE PYTHON SOURCE FILE, "BeautifulSoup.py". > > Ummm.. Why does it bother you? Mike seems to be offering a public > service to Windows users: by downloading the .exe, I can double-click > on one file, have the module or package installed (whether it contains > one .py file or twenty or a series of compiled extension modules and > their respective DLLs) and for a bonus it's registered in the system > packages directory [*] and is therefore uninstallable from there. Executing strange executables is risky. One always wonders what else they install in addition to what they're supposed be installing. John Nagle From patrick.waldo at gmail.com Tue Apr 1 06:36:52 2008 From: patrick.waldo at gmail.com (patrick.waldo at gmail.com) Date: Tue, 1 Apr 2008 03:36:52 -0700 (PDT) Subject: xlrd and cPickle.dump Message-ID: <34e62ddb-477f-4a99-97a5-21a7b148d244@e67g2000hsa.googlegroups.com> Hi all, Sorry for the repeat I needed to reform my question and had some problems...silly me. The xlrd documentation says: "Pickleable. Default is true. In Python 2.4 or earlier, setting to false will cause use of array.array objects which save some memory but can't be pickled. In Python 2.5, array.arrays are used unconditionally. Note: if you have large files that you need to read multiple times, it can be much faster to cPickle.dump() the xlrd.Book object once, and use cPickle.load() multiple times." I'm using Python 2.4 and I have an extremely large excel file that I need to work with. The documentation leads me to believe that cPickle will be a more efficient option, but I am having trouble pickling the excel file. So far, I have this: import cPickle,xlrd import pyExcelerator from pyExcelerator import * data_path = """C:\test.xls""" pickle_path = """C:\pickle.xls""" book = xlrd.open_workbook(data_path) Data_sheet = book.sheet_by_index(0) wb=pyExcelerator.Workbook() proc = wb.add_sheet("proc") #Neither of these work #1) pyExcelerator try #cPickle.dump(book,wb.save(pickle_path)) #2) Normal pickle try #pickle_file = open(pickle_path, 'w') #cPickle.dump(book, pickle_file) #file.close() Any ideas would be helpful. Otherwise, I won't pickle the excel file and deal with the lag time. Patrick From martin at v.loewis.de Tue Apr 22 14:17:32 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 22 Apr 2008 20:17:32 +0200 Subject: Compiling Python 2.5.2 on AIX 5.2 In-Reply-To: References: <0b73e8e5-c301-4823-ac94-42f757456cf1@x19g2000prg.googlegroups.com> <48059DA9.5080900@v.loewis.de> <480c2364$0$26788$9b622d9e@news.freenet.de> Message-ID: <480e2bbc$0$24477$9b622d9e@news.freenet.de> > test test_mmap crashed -- : [Errno > 22] Invalid argument You should run this with -v. This is too little detail to know what exactly failed. > self.assertEqual(spid, cpid) > AssertionError: 0 != 6840386 > > What do these failures indicate? That suggests a bug in wait4: apparently, it fails to correctly return the PID. Could be an OS bug, but more likely, it's a type problem in Modules/posixmodule.c. Regards, Martin From cwitts at gmail.com Tue Apr 15 06:47:11 2008 From: cwitts at gmail.com (Chris) Date: Tue, 15 Apr 2008 03:47:11 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <1208196168.24295.36.camel@localhost.localdomain> <526792b1-acc2-4e48-8e9f-cc2641134958@k37g2000hsf.googlegroups.com> <732f1af2-ebae-4764-a40e-698ae1bde95f@h1g2000prh.googlegroups.com> Message-ID: <4d88216e-ffd2-48bf-a593-5d110c66dcf9@w5g2000prd.googlegroups.com> On Apr 15, 12:33?pm, Chris wrote: > On Apr 15, 11:47?am, Duncan Booth > wrote: > > > Chris wrote: > > > even is closer to even.75 than even+1.25. ?Why should it be rounded > > > up ? > > > Because the OP wants to round values to the nearest integer. Only values of > > the form 'x.5' which have two nearest values use 'nearest even' to > > disambiguate the result. > > > Seehttp://en.wikipedia.org/wiki/Rounding#Round-to-even_method > > > That's the way I was taught to round numbers when at primary school. > > My bad, didn't see he only wanted for halves and handle others as > normal. My contribution then: def my_round(x): if x < 0: NEG = 1 x = -x else: NEG = 0 if not x%.5 and not int(x)%2: if NEG: return -round(x-.1) return round(x-.1) elif not x%.5 and int(x)%2: if NEG: return -round(x+.1) return round(x+.1) elif NEG: return round(-x) else: return round(x) [(f*.25, my_round(f*.25)) for f in xrange(-20,20)] [(-5.0, -5.0), (-4.75, -5.0), (-4.5, -4.0), (-4.25, -4.0), (-4.0, -4.0), (-3.75, -4.0), (-3.5, -4.0), (-3.25, -3.0), (-3.0, -3.0), (-2.75, -3.0), (-2.5, -2.0), (-2.25, -2.0), (-2.0, -2.0), (-1.75, -2.0), (-1.5, -2.0), (-1.25, -1.0), (-1.0, -1.0), (-0.75, -1.0), (-0.5, 0.0), (-0.25, 0.0), (0.0, 0.0), (0.25, 0.0), (0.5, 0.0), (0.75, 1.0), (1.0, 1.0), (1.25, 1.0), (1.5, 2.0), (1.75, 2.0), (2.0, 2.0), (2.25, 2.0), (2.5, 2.0), (2.75, 3.0), (3.0, 3.0), (3.25, 3.0), (3.5, 4.0), (3.75, 4.0), (4.0, 4.0), (4.25, 4.0), (4.5, 4.0), (4.75, 5.0)] From lists at cheimes.de Fri Apr 25 17:45:59 2008 From: lists at cheimes.de (Christian Heimes) Date: Fri, 25 Apr 2008 23:45:59 +0200 Subject: Why is None <= 0 In-Reply-To: <481228DF.5010408@ulmcnett.com> References: <481228DF.5010408@ulmcnett.com> Message-ID: <48125117.9060907@cheimes.de> > In my humble opinion, I think that comparisons involving None should > return None, but I trust that the designers came up with this for very > good reasons. As far as I know I've never been bitten by it. It's fixed in Python 3.x. Python 3.x refuses to compare objects unless one of both objects has explicit support for both types: >>> 1 < None Traceback (most recent call last): File "", line 1, in TypeError: unorderable types: int() < NoneType() From Scott.Daniels at Acm.Org Sat Apr 26 00:02:18 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Fri, 25 Apr 2008 21:02:18 -0700 Subject: Is 2006 too old for a book on Python? In-Reply-To: References: Message-ID: jmDesktop wrote: > Hi, I wanted to buy a book on Python, but am concerned that some of > them are too old. One I had come to after much research was Core > Python by Wesley Chun. I looked at many others, but actually saw this > one in the store and liked it. However, it is from 2006. I know > there is free documentation and Dive Into Python. I just liked the > one in question and was hoping for thoughts on the age of it. I am > using Python 2.5.x and don' t know how different 2.3, 2,4 is from it. Look at http://rgruet.free.fr/ If you look at the 2.5 quick reference, several previous versions are included, with the differences color-coded. You can reassure yourself that the vast majority of the language remains the same. --Scott David Daniels Scott.Daniels at Acm.Org From wuwei23 at gmail.com Sat Apr 5 21:45:32 2008 From: wuwei23 at gmail.com (alex23) Date: Sat, 5 Apr 2008 18:45:32 -0700 (PDT) Subject: troll poll References: <65eee6F2eg18jU1@mid.uni-berlin.de> <143a9f24-668e-4e30-a803-c272da27f3ff@s13g2000prd.googlegroups.com> Message-ID: <93477f36-fd07-4659-b3ab-29b9cc35bb8d@w5g2000prd.googlegroups.com> (Aahz) wrote: > alex23 wrote: > > >The usual > >response to complaining about the lack of a killfile for Google Groups > >has been "use a decent client", but as I'm constantly moving between > >machines having a consistent app for usenet has more value to me. > > That's why I ssh into my ISP for trn3.6 ;-) So what you're saying is, basically, "use a decent client"? :) - alex23 From mdboldin at gmail.com Thu Apr 24 16:20:27 2008 From: mdboldin at gmail.com (mmm) Date: Thu, 24 Apr 2008 13:20:27 -0700 (PDT) Subject: DTD validation and xmlproc References: <480F8513.6040309@behnel.de> Message-ID: > Regarding ... try lxml. > http://codespeak.net/lxmlhttp://codespeak.net/lxml/tutorial.htmlhttp://codespeak.net/lxml/validation.html > Thx Stefan, it seems that lxml does everything I need. I have not figured out all of the bells and whistles but the tutorials are getting me up to speed. Based 2 days of trial, I can recommend lxml without reservation. From n00m at narod.ru Sun Apr 27 15:54:48 2008 From: n00m at narod.ru (n00m) Date: Sun, 27 Apr 2008 12:54:48 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <2d06b319-e2fd-4790-af61-6f90b9b1b3b1@m1g2000pre.googlegroups.com> <41e72e61-6413-41f3-a162-dbcc1ec5fcee@f63g2000hsf.googlegroups.com> Message-ID: <9776420a-c34d-425e-8598-eecf4bfd0d02@t63g2000hsf.googlegroups.com> Another PC, another OS (Linux) and another compiler C++ (g++ 4.0.0-8) Compare 2 my latest submissions: http://www.spoj.pl/status/SBANK,zzz/ times: 1.32s and 0.60s Submitted codes: import sys z=sys.stdin.readlines() print z[5] #include #include #include #include using namespace std; vector vs; int main() { while (true) { char line[50]; if (!fgets(line,50,stdin)) break; vs.push_back(line); } return 0; } If it proves nothing then white is black and good is evil From see.signature at no.spam Tue Apr 29 10:36:56 2008 From: see.signature at no.spam (Eric Brunel) Date: Tue, 29 Apr 2008 16:36:56 +0200 Subject: Simple TK Question - refreshing the canvas when not in focus References: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> Message-ID: On Tue, 29 Apr 2008 15:22:12 +0200, blaine wrote: > Hey everyone! > I'm not very good with Tk, and I am using a very simple canvas to > draw some pictures (this relates to that nokia screen emulator I had a > post about a few days ago). > > Anyway, all is well, except one thing. When I am not in the program, > and the program receives a draw command (from a FIFO pipe), the canvas > does not refresh until I click into the program. How do I force it to > refresh, or force the window to gain focus? It seems like pretty > common behavior, but a few things that I've tried have not worked. > > Class screen(): > def __init__(self): > self.root = Tkinter.Tk() > self.root.title('Nokia Canvas') > self.canvas = Tkinter.Canvas(self.root, width =130, > height=130) > self.canvas.pack() > self.root.mainloop() > > Then somewhere a long the line I do: > self.canvas.create_line(args[0], args[1], args[2], > args[3], fill=color) > self.canvas.pack() Unrelated question: why are you doing a .pack() again here? Packing the widget just inserts it at the right place in its container, so you only have to do it once. So the one you did in __init__ is enough. > I've tried self.root.set_focus(), self.root.force_focus(), > self.canvas.update(), etc. but I can't get it. IIRC: - self.root.set_focus() will only work if your application already has the focus, so it's not what you need here. - self.root.force_focus() is usually considered as evil: it'll give the focus to your application whatever the user is doing, which is usually *really* annoying. So I guess a lot of window managers just refuse to do it; this may be what happens here. But self.canvas.update() should work. If it doesn't, then there are probably limitations on your platform that prevents it to work... Do you happen to have other applications that can update their display while they don't have the focus? Do they have the same problem? If they do, it's probably a limitation on the platform and I guess you won't be able to do anything about it... BTW, what platform are you on? > Thanks! > Blaine HTH -- python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])" From bwljgbwn at gmail.com Tue Apr 22 05:51:02 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:51:02 -0700 (PDT) Subject: paint shop pro keygen Message-ID: <47765661-a861-4bd7-b600-cd1e9747a7ea@c19g2000prf.googlegroups.com> paint shop pro keygen http://cracks.12w.net F R E E C R A C K S From xnews2 at fredp.lautre.net Thu Apr 17 11:48:15 2008 From: xnews2 at fredp.lautre.net (Fred Pacquier) Date: 17 Apr 2008 15:48:15 GMT Subject: PHATCH: PHoto bATCH processor with EXIF and IPTC support for all platforms References: <808b0684-19bc-432e-811b-590a451ac899@a22g2000hsc.googlegroups.com> Message-ID: "SPE - Stani's Python Editor" said : > What is new? Until Phatch could only save EXIF and IPTC tags on Linux. > Now this feature is available for all platforms hanks to the work of > Robin Mills who managed to compile pyexiv2 and all its dependencies > and get it to work on MacOS X (Tiger and Leopard, PPC and Intel) and > x86 Windows. > You can grab the libraries from here: > http://www.clanmills.com/articles/gpsexiftags/ (Look for "Download the > libraries click here" somewhere in the middle). > I have not tested this myself yet, but assumes that it will work. Any > volunteers to test this with Phatch That is great news, thanks ! I will certainly give it a try. From stefan_ml at behnel.de Mon Apr 21 03:00:28 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 21 Apr 2008 09:00:28 +0200 Subject: Conditional for...in failing with utf-8, Spanish book translation In-Reply-To: References: Message-ID: <480C3B8C.9080902@behnel.de> Hunter wrote: > I've narrowed the problem down to a simple test program. Check this out: > > --- > > # -*- coding: utf-8 -*- > > acceptable = "abcdefghijklmnopqrstuvwxyz????" # this line will work > acceptable = "abcdefghijklmnopqrstuvwxyz?????" # this line won't [bad words stripped] this should read acceptable = u"abcdefghijklmnopqrstuvwxyz????" acceptable = u"abcdefghijklmnopqrstuvwxyz?????" Mind the little "u" before the string, which makes it a unicode string instead of an encoded byte string. http://docs.python.org/tut/node5.html#SECTION005130000000000000000 Stefan From tdimson at gmail.com Tue Apr 8 19:49:27 2008 From: tdimson at gmail.com (Thomas Dimson) Date: Tue, 8 Apr 2008 16:49:27 -0700 (PDT) Subject: Ctypes and C Infinite Callback Loops Message-ID: Hello, I have quite a complex issue that is arising with regards to using ctypes to hook into some legacy code. The legacy code is in infinite loop - I can not touch this. It does some listening, and periodically calls a specific callback function. What I would like to be able to do is spawn a Python thread to handle this infinite loop, and continue on my merry way. This works to an extent, however if I try to raise the SystemExit exception (or any other one) inside of this thread I get an error message of "AssertionError: cannot join current thread". I assume there is some issue with the global interpreter lock or that you can't exit the infinite loop from above Python. Any suggestions on how I can design this so the thread will be able to issue exits/raise exceptions just like a regular thread? Is there a way of terminating this thread from the python interpreter or ctypes.pythonapi? I have also tried being sneaky by using a pthread in the C code, but I had issues when I tried to create a new thread state using ctypes.pythonapi (well, I had issues swapping it in when I get to the callback). If this is the best solution, how do I create/swap in the thread state from ctypes? For some cooked up sample code that simulates this: main.c (main.o -> main.so ) #include void loop( void (*callback)() ) { while( 1 ) { callback(); sleep(1); } } void testLoop( void (*callback)() ) { loop( callback ); } ************************************************ test.py: import threading,ctypes,time,sys,os soPath = os.path.join( "/home/tdimson/ctypes/main.so" ) class callLoop( threading.Thread ): def callback( self ): sys.exit() def run( self ): ctypes.cdll.LoadLibrary( soPath ) mainLib = ctypes.CDLL( soPath ) _callback = ctypes.CFUNCTYPE( None )( self.callback ) mainLib.testLoop( _callback ) loopThread = callLoop() loopThread.start() while 1: print "Not blocking" time.sleep(10) ******************************************** Then I execute: python test.py and get Not blocking Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/usr/lib/python2.4/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "/usr/lib/python2.4/threading.py", line 634, in __exitfunc t.join() File "/usr/lib/python2.4/threading.py", line 532, in join assert self is not currentThread(), "cannot join current thread" AssertionError: cannot join current thread Error in sys.exitfunc: Traceback (most recent call last): File "/usr/lib/python2.4/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "/usr/lib/python2.4/threading.py", line 634, in __exitfunc t.join() File "/usr/lib/python2.4/threading.py", line 532, in join assert self is not currentThread(), "cannot join current thread" AssertionError: cannot join current thread Thanks for even reading this much :) -Thomas Dimson From bvidinli at gmail.com Thu Apr 10 04:11:09 2008 From: bvidinli at gmail.com (bvidinli) Date: Thu, 10 Apr 2008 11:11:09 +0300 Subject: urgent question, about filesystem-files Message-ID: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> i started python programming a few months ago. now i need the code to understand if a file already opened in filesystem by another process ? i looked at docs, howtos, but did not find related info. note that normal file open/write operations in python, i know it. i specificly need to know that "is a file already open by some other process other than python". Thank you in advance From gagsl-py2 at yahoo.com.ar Sun Apr 13 15:37:20 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 13 Apr 2008 16:37:20 -0300 Subject: toplevel, get latest entry? References: Message-ID: En Sat, 12 Apr 2008 17:50:36 -0300, escribi?: > windows vista and python 2.5, is there a way to get the latest command > entered? would be very useful. > > if not by default, anything i could download or write myself? Do you mean inside the interpreter? Use up arrow/down arrow. Type a few characters and press F8 to search for matches. F7 to select from a list. Courtesy of doskey. -- Gabriel Genellina From jgardner at jonathangardner.net Thu Apr 24 13:02:13 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Thu, 24 Apr 2008 10:02:13 -0700 (PDT) Subject: How to find the parent of an old-style class? References: <9742ba66-eebf-43ba-8391-d0d0edb52c95@l42g2000hsc.googlegroups.com> Message-ID: <805bf888-722e-44a7-9c6a-66f9a28278af@b64g2000hsa.googlegroups.com> On Apr 24, 7:16?am, Jasper wrote: > I'm stuck using a library based on old style classes, and need to find > a class's parent at runtime. > > With new style classes you can use .__base__ to inspect a parent, but > I can't remember how this was done in days of yore, before object. > I've tried googling, but apparently my search term Fu is weak. :-( > > Can anyone help me out here? ?There must be something simple. > It's very odd that you need to know a class's parent. I'm interested in hearing why you need this. In all my years, I've never had to do this. Regardless, I believe you are looking for __bases__. From kf9150 at gmail.com Tue Apr 1 12:50:29 2008 From: kf9150 at gmail.com (Kelie) Date: Tue, 1 Apr 2008 09:50:29 -0700 (PDT) Subject: PyQt - How to prevent a dialog being resized? References: Message-ID: <281915c9-c4d1-4025-a46b-7cd4cc4b101a@s8g2000prg.googlegroups.com> Thanks to all. I used the approach suggested by David. From tom at vector-seven.com Wed Apr 16 19:23:53 2008 From: tom at vector-seven.com (Thomas Lee) Date: Thu, 17 Apr 2008 09:23:53 +1000 Subject: [Python-Dev] Global Python Sprint Weekends: May 10th-11th and June 21st-22nd. In-Reply-To: <87D3F9C72FBF214DB39FA4E3FE618CDC6E22F389FE@EXMBX04.exchhosting.com> References: <87D3F9C72FBF214DB39FA4E3FE618CDC6E22F389FE@EXMBX04.exchhosting.com> Message-ID: <48068A89.9000306@vector-seven.com> Anyone in Melbourne, Australia keen for the first sprint? I'm not sure if I'll be available, but if I can it'd be great to work with some others. Failing that, it's red bull and pizza in my lounge room :) I've been working on some neat code for an AST optimizer. If I'm free that weekend, I'll probably continue my work on that. Cheers, T Trent Nelson wrote: > Following on from the success of previous sprint/bugfix weekends and > sprinting efforts at PyCon 2008, I'd like to propose the next two > Global Python Sprint Weekends take place on the following dates: > > * May 10th-11th (four days after 2.6a3 and 3.0a5 are released) > * June 21st-22nd (~week before 2.6b2 and 3.0b2 are released) > > It seems there are a few of the Python User Groups keen on meeting > up in person and sprinting collaboratively, akin to PyCon, which I > highly recommend. I'd like to nominate Saturday across the board > as the day for PUGs to meet up in person, with Sunday geared more > towards an online collaboration day via IRC, where we can take care > of all the little things that got in our way of coding on Saturday > (like finalising/preparing/reviewing patches, updating tracker and > documentation, writing tests ;-). > > For User Groups that are planning on meeting up to collaborate, > please reply to this thread on python-dev at python.org and let every- > one know your intentions! > > As is commonly the case, #python-dev on irc.freenode.net will be > the place to be over the course of each sprint weekend; a large > proportion of Python developers with commit access will be present, > increasing the amount of eyes available to review and apply patches. > > For those that have an idea on areas they'd like to sprint on and > want to look for other developers to rope in (or just to communicate > plans in advance), please also feel free to jump on this thread via > python-dev@ and indicate your intentions. > > For those that haven't the foggiest on what to work on, but would > like to contribute, the bugs tracker at http://bugs.python.org is > the best place to start. Register an account and start searching > for issues that you'd be able to lend a hand with. > > All contributors that submit code patches or documentation updates > will typically get listed in Misc/ACKS.txt; come September when the > final release of 2.6 and 3.0 come about, you'll be able to point at > the tarball or .msi and exclaim loudly ``I helped build that!'', > and actually back it up with hard evidence ;-) > > Bring on the pizza and Red Bull! > > Trent. > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: http://mail.python.org/mailman/options/python-dev/krumms%40gmail.com > From bdsatish at gmail.com Fri Apr 11 07:32:13 2008 From: bdsatish at gmail.com (bdsatish) Date: Fri, 11 Apr 2008 04:32:13 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> Message-ID: <76c20d47-2cb4-44ee-97d8-6bc41978d4e4@b9g2000prh.googlegroups.com> On Apr 11, 4:24 pm, cokofree... at gmail.com wrote: > On Apr 11, 1:19 pm, cokofree... at gmail.com wrote: > > > couldn't you just do. > > > #untested > > new_round(n): > > answer = round(n) > > # is answer now odd > > if answer % 2: > > return answer - 1 > > else: > > return answer > > Whoops, this also affects odd numbers... > > Will try and find a GOOD solution later... > > Strange request though, why do you need it that way, because 2.5 is > CLOSER to 3 than to 2... It also fails for negative numbers. For -2.5 as input, I get -4.0 whereas I expect -2.0 This is a lengthy solution I came-up with: def round_even(x): temp = round(abs(x)) if (abs(x) - 0.5)%2.0 == 0.0: temp=temp-1 return signum(x)*temp def signum(x): if x>0: return 1 if x<0: return -1 return 0 But i guess there are better ways. I need it 'cos I'm translating some code from Mathematica to Python. And Math..ica's Round[ ] behaves this way (as I requested) From uniontelecardsindia at gmail.com Tue Apr 22 17:19:54 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:19:54 -0700 (PDT) Subject: Hardcore hood gay musclemen in a paired ass-pounding orgy session. Message-ID: <5ad5f2bd-92c7-4ae9-98c1-d2116608e076@c65g2000hsa.googlegroups.com> Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 15 09:01:19 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 15 Apr 2008 15:01:19 +0200 Subject: Dynamic use of property() fails In-Reply-To: <87hce34eji.fsf@mulj.homelinux.net> References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> <87wsmz4l5g.fsf@mulj.homelinux.net> <48046af8$0$16166$426a74cc@news.free.fr> <87hce34eji.fsf@mulj.homelinux.net> Message-ID: <4804a719$0$15325$426a74cc@news.free.fr> Hrvoje Niksic a ?crit : > Bruno Desthuilliers > writes: > >>> However, if you know what you're doing, you can simply customize your >>> class's __getattribute__ to do what *you* want for your objects. >> >> But bear in mind that, beside possible unwanted side-effectn, you'll >> get a non-negligible performance hit - __getattribute__ being, as the >> name implies, invoked on each and every attribute lookup. > > That's unavoidable, though -- whatever you do to customize your class > in Python, the result will be slower than the C code built into > Python. This one customization hook is probably the most sensible still. > Fortunately, not every object is performance-critical. In > this case, __getattribute__ buys you per-instance customization not > otherwise available. The code you posted is probably more efficient, > but at the cost of losing the ability to customize specific instances > of the class. You could as well just customize __setattr__/__getattr__ (which is what was done before new-style classes and descriptors). But my own experience is that the very few times I thought I had a need for per-instance descriptors, I found other solutions that were certainly easier to grasp and maintain on the long term. Not that I would not be able to deal with per-instance descriptors, but so far the cost outweighted the benefits IMHO. Now YMMV of course !-) From bijeshn at gmail.com Mon Apr 7 06:15:59 2008 From: bijeshn at gmail.com (bijeshn) Date: Mon, 7 Apr 2008 03:15:59 -0700 (PDT) Subject: splitting an XML file on the basis on basis of XML tags References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> <47F9B845.9040205@behnel.de> Message-ID: pls disregard the above post.... On Apr 7, 3:13?pm, bijeshn wrote: > > What do you mean by "written down to a separate file"? Do you have a specific > > format in mind? > > sorry, it should be extracted into separate " XML files". i.e. if i have an > XML file containing 10 million records, i need to split the file to > 100 XML files containing 100,000 records each. > > i hope this is clearer... From grflanagan at gmail.com Wed Apr 23 06:49:08 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Wed, 23 Apr 2008 03:49:08 -0700 (PDT) Subject: Script to convert Tcl scripts to Python? References: Message-ID: On Apr 23, 9:17 am, "Achillez" wrote: > Hi, > > I have a 10k+ line Tcl program that I would like to auto convert over to > Python. Do any scripts exist that can convert ~90% of the standard Tcl > syntax over to Python? I know Python doesn't handle strings, but just for > general syntax e.g., puts > print, expr > math operations > > thanks Never used it, but there's a jacl2jython tool (IBM): http://www-1.ibm.com/support/docview.wss?rs=180&uid=swg24012144 G. From lists at cheimes.de Sun Apr 20 13:43:17 2008 From: lists at cheimes.de (Christian Heimes) Date: Sun, 20 Apr 2008 19:43:17 +0200 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> Message-ID: <480B80B5.1050500@cheimes.de> Gabriel Genellina schrieb: > Apart from what everyone has already said, consider that FreqDist may import other modules, store global state, create other objects... whatever. > Pure python code should not have any memory leaks (if there are, it's a bug in the Python interpreter). Not-carefully-written C extensions may introduce memory problems. Pure Python code can cause memory leaks. No, that's not a bug in the interpreter but the fault of the developer. For example code that messes around with stack frames and exception object can cause nasty reference leaks. Christian From darcy at druid.net Tue Apr 22 11:41:23 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Tue, 22 Apr 2008 11:41:23 -0400 Subject: Spawing a thread and printing dots until it finishes In-Reply-To: References: Message-ID: <20080422114123.446c3480.darcy@druid.net> On Tue, 22 Apr 2008 07:10:07 -0700 (PDT) sophie_newbie wrote: > import threading > class MyThread ( threading.Thread ): > def run ( self ): > myLongCommand()... > > import time > > t = MyThread() > t.start() > > while t.isAlive(): > print "." > time.sleep(.5) > > print "OK" > > The thing is this doesn't print a dot every half second. It just > pauses for ages until the thread is finished and prints prints ".OK". > But if I take out the "time.sleep(.5)" line it will keep printing dots > really fast until the thread is finished. So it looks like its the > time.sleep(.5) bit that is messing this up somehow? We know that your main routine gives up the processor but without a full definition of MyThread how do we know that it ever does? I suspect that it hits sleep once, if at all, and then goes to the final print statement. In fact, I suspect that this is not exactly what you tried anyway. This code would not have printed ".OK" whether it entered the loop or not. It could have printed this; . OK because the print statement in the loop will print a dot on a line by itself. When looking for these sorts of answers you should really try to create a smallest program that exhibits the behaviour you are questioning and then cut and paste the entire script into your message unedited. Often enough you will even answer your own question in the process. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From nospam at here.com Sun Apr 27 18:26:11 2008 From: nospam at here.com (Dennis) Date: Sun, 27 Apr 2008 23:26:11 +0100 Subject: A small and very basic python question In-Reply-To: References: Message-ID: I didn't give up after posting and managed to grasp this whole lambda thing! No need to respond now :-) I understood it the moment I tried to type out, instead of just thinking in my head, what was going on as a normal function. Dennis wrote: > Could anyone tell me how this line of code is working: > > filter(lambda x: x in string.letters, text) > > I understand that it's filtering the contents of the variable text and I > know that lambda is a kind of embedded function. > > What I'd like to know is how it would be written if it was a normal > function. From stefan_ml at behnel.de Mon Apr 7 08:34:25 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 07 Apr 2008 14:34:25 +0200 Subject: splitting an XML file on the basis on basis of XML tags In-Reply-To: <05edd42c-dd16-4364-92ca-43cdbb1ab547@r9g2000prd.googlegroups.com> References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> <47F9B845.9040205@behnel.de> <05edd42c-dd16-4364-92ca-43cdbb1ab547@r9g2000prd.googlegroups.com> Message-ID: <47FA14D1.3080608@behnel.de> bijeshn wrote: > the extracted files are to be XML too. ijust need to extract it raw > (tags and data just like it is in the parent XML file..) Ah, so then replace the "print tostring()" line in my example by ET.ElementTree(element).write("outputfile.xml") and you're done. Stefan From larry.bates at websafe.com Thu Apr 3 23:26:50 2008 From: larry.bates at websafe.com (Larry Bates) Date: Thu, 03 Apr 2008 22:26:50 -0500 Subject: Prototype OO In-Reply-To: <83dfdeec-dfc4-41ae-9781-052bdbea7497@b64g2000hsa.googlegroups.com> References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> <7xwsngyu05.fsf@ruckus.brouhaha.com> <7x8wzw80rf.fsf@ruckus.brouhaha.com> <0d97babc-1174-4537-a7eb-e60164521863@s13g2000prd.googlegroups.com> <83dfdeec-dfc4-41ae-9781-052bdbea7497@b64g2000hsa.googlegroups.com> Message-ID: <1207279610.7571.218.camel@fc8.home.com> On Wed, 2008-04-02 at 21:03 -0700, castironpi at gmail.com wrote: > On Apr 2, 5:41 pm, "bruno.desthuilli... at gmail.com" > wrote: > > On 2 avr, 22:23, Paul Rubin wrote: > > > > > "bruno.desthuilli... at gmail.com" writes: > > > > Fine. But totally irrelevant here - this is comp.lang.python, not > > > > comp.lang.c, and we *do not* (I repeat : we *do not*) face the same > > > > safety and security problems as those existing in C. > > > > > We have it better than they do in some ways. > > >In some other ways, we have > > > it worse. > > > > Care to elaborate ? Or are we supposed to guess ?-) > > Has anyone thought about putting code in a Data file? Am I the only > one that wants Python stored procedures in DB? postgreSQL supports Python stored procedures. Take a look: http://www.postgresql.org/docs/8.1/static/plpython.html -Larry From nagle at animats.com Mon Apr 7 18:40:35 2008 From: nagle at animats.com (John Nagle) Date: Mon, 07 Apr 2008 15:40:35 -0700 Subject: A file iteration question/problem In-Reply-To: <47f8eee1$0$759$bed64819@news.gradwell.net> References: <47f8eee1$0$759$bed64819@news.gradwell.net> Message-ID: <47faa04f$0$36349$742ec2ed@news.sonic.net> tinnews at isbd.co.uk wrote: > I want to iterate through the lines of a file in a recursive function > so I can't use:- > > f = open(listfile, 'r') > for ln in f: > > because when the function calls itself it won't see any more lines in > the file. E.g. more fully I want to do somthing like:- > > def recfun(f) > while True: > str = readline(f) > if (str == "") > break; > # > # do various tests > # > if : > recfun(f) > Don't do that; Python doesn't have tail recursion and you'll hit the stack limit. John Nagle From ewertman at gmail.com Sat Apr 26 16:20:23 2008 From: ewertman at gmail.com (Eric Wertman) Date: Sat, 26 Apr 2008 16:20:23 -0400 Subject: learning with python question (HtTLaPP) In-Reply-To: <98acecbd-9de2-4ebf-927b-ac6bc1fbc3fd@b5g2000pri.googlegroups.com> References: <98acecbd-9de2-4ebf-927b-ac6bc1fbc3fd@b5g2000pri.googlegroups.com> Message-ID: <92da89760804261320t30f7418cx17ed676fea63fc5c@mail.gmail.com> > Python Programmer" and have been trying to write a script that checks > 'words.txt' for parameters (letters) given. The problem that is the i > can only get results for the exact sequence of parameter 'letters'. The "re" module comes to mind: text = open('words.txt','r').read() letters = 'sequence' results = re.findall(letters,text) result_count = len(results) # one word per line: for result in results : print result # one line print ' '.join(results) of course, you may need to invest a little time in regular expression syntax to get exactly what you want, but I think you'll find that's not wasted effort, as this is pretty standard and used in a lot of other places. From arnodel at googlemail.com Tue Apr 29 16:50:54 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Tue, 29 Apr 2008 21:50:54 +0100 Subject: string translate, replace, find and the forward slash References: <1030ffc2-1bbe-4539-881d-35bf59cacd11@34g2000hsh.googlegroups.com> Message-ID: destroooooy writes: > Hi folks, > I'm finding some (what I consider) curious behavior with the string > methods and the forward slash character. I'm writing a program to > rename mp3 files based on their id3 tags, and I want to protect > against goofy characters in the in tags. So I do the following: > > unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n" > alt_chars = "_________________________" > > s_artist.translate(maketranstable(unsafe_chars, alt_chars)) > > > which successfully replaces everything except for forward slashes (at > least in the files I've tested so far). If I use the "replace()" > method, it also does not work. Escaping the forward slash changes > nothing. "find()" however, works, and thus I've resorted to: > > if "/" in s_artist: > (s_l, slash, s_r) = s_artist.partition("/") > s_artist = "_".join([s_l, s_r]) > > which is rather uncool. It works but I'd just like to know what the > deal is. TIA. It works fine here: marigold:junk arno$ python Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n" >>> table = range(256) >>> for c in unsafe_chars: table[ord(c)] = ord('_') ... >>> table = ''.join(chr(o) for o in table) >>> 'Jon(&Mark/Steve)'.translate(table) 'Jon__Mark_Steve_' >>> -- Arnaud From bbxx789_05ss at yahoo.com Sun Apr 6 23:17:38 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sun, 6 Apr 2008 20:17:38 -0700 (PDT) Subject: Tkinter, a lot of buttons, make prog shorter? References: <688483d9-2c6a-4e2a-b64d-f32bb27699ec@p25g2000hsf.googlegroups.com> <8869512e-19c3-4750-b4f1-5666a2547f13@u3g2000hsc.googlegroups.com> Message-ID: <0869aea0-d86d-4eb9-860a-e35f958e6477@a70g2000hsh.googlegroups.com> On Apr 6, 8:50?pm, skanem... at yahoo.se wrote: > should i not use self. in Clean() and Calculate() either? > You probably shouldn't be using classes at all. When you are trying to learn the basics of a language, you don't want to complicate things further with classes. Copying a program off the internet and trying to modify it for your own purposes is usually going to be a lot more work than writing the whole thing from scratch yourself. In addition, when you write the whole thing yourself, you'll have a better understanding of how things work. From bijeshn at gmail.com Thu Apr 3 02:12:25 2008 From: bijeshn at gmail.com (bijeshn) Date: Wed, 2 Apr 2008 23:12:25 -0700 (PDT) Subject: splitting an XML file on the basis on basis of XML tags References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> Message-ID: On Apr 2, 5:37?pm, Chris wrote: > bije... at gmail.com wrote: > > Hi all, > > > ? ? ? ? ?i have an XML file with the following structure:: > > > > > -----| > > ? ? | > > ? ? | > > . ? ? ? ? ? | > > . ? ? ? ? ? | ? ? ? ? --------------------> constitutes one record. > > . ? ? ? ? ? | > > . ? ? ? ? ? | > > . ? ? ? ? ? | > > ? ?| > > ? ?| > > ----| > > > > . > > . > > . ? ?-----------------------| > > . ? ? ? ? ? ? ? ? ? ? ? ? ? | > > . ? ? ? ? ? ? ? ? ? ? ? ? ? | > > . ? ? ? ? ? ? ? ? ? ? ? ? ? |----------------------> there are n > > records in between.... > > . ? ? ? ? ? ? ? ? ? ? ? ? ? | > > . ? ? ? ? ? ? ? ? ? ? ? ? ? | > > . ? ? ? ? ? ? ? ? ? ? ? ? ? | > > . ? ------------------------| > > . > > . > > > > -----| > > ? ? | > > ? ? | > > . ? ? ? ? ? | > > . ? ? ? ? ? | ? ? ? ? --------------------> constitutes one record. > > . ? ? ? ? ? | > > . ? ? ? ? ? | > > . ? ? ? ? ? | > > ? ?| > > ? ?| > > ----| > > > > > ? ? ? ?Here is the main root tag of the XML, and ... > > constitutes one record. What I would like to do is > > to extract everything (xml tags and data) between nth tag and (n > > +k)th tag. The extracted data is to be > > written down to a separate file. > > > Thanks... > > You could create a generator expression out of it: > > txt = """ > ? ? 1 > ? ? 2 > ? ? 3 > ? ? 4 > ? ? 5 > ? ? > ? ? """ > l = len(txt.split('r2>'))-1 > a = ('%sr2>'%i for j,i in enumerate(txt.split('r2>')) if 0 < j < l > and i.replace('>','').replace('<','').strip()) > > Now you have a generator you can iterate through with a.next() or > alternatively you could just create a list out of it by replacing the > outer parens with square brackets.- Hide quoted text - > > - Show quoted text - Hmmm... will look into it.. Thanks the XML file is almost a TB in size... so SAX will have to be the parser.... i'm thinking of doing something to split the file using SAX ... Any suggestions on those lines..? If there are any other parsers suitable, please suggest... From darcy at druid.net Fri Apr 25 15:02:29 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Fri, 25 Apr 2008 15:02:29 -0400 Subject: Why is None <= 0 In-Reply-To: <481228DF.5010408@ulmcnett.com> References: <481228DF.5010408@ulmcnett.com> Message-ID: <20080425150229.653404bc.darcy@druid.net> On Fri, 25 Apr 2008 11:54:23 -0700 Paul McNett

wrote: > In my humble opinion, I think that comparisons involving None should > return None... Like relational databases. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From vivainio at gmail.com Wed Apr 9 15:16:53 2008 From: vivainio at gmail.com (Ville Vainio) Date: Wed, 9 Apr 2008 12:16:53 -0700 (PDT) Subject: pywin32 vista installer fix & general distutils installer name bug Message-ID: <843dba28-dded-483a-9435-c1a99db94c08@s13g2000prd.googlegroups.com> I just noticed that pywin32 does not work with vista directly (tried import win32clipboard, => ImportError). The problem is the installer name; it's the usual pywin32-210-win32-py2.5.exe It needs to be renamed to: pywin32-210.win32-setup-py2.5.exe In order for vista to catch it as "installer". We renamed the IPython exe installer to have "setup" to get around the same issue. Just posting this for benefit of googlers. I'll complain about this on distutils-sig as well. From billingspanshism at gmail.com Sat Apr 19 17:19:50 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:19:50 -0700 (PDT) Subject: victoria beckham boobs Message-ID: <7dbf45d5-b7d7-4a7b-bb0d-03c31e6a8300@2g2000hsn.googlegroups.com> Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From gslindstrom at gmail.com Tue Apr 1 16:11:51 2008 From: gslindstrom at gmail.com (Greg Lindstrom) Date: Tue, 1 Apr 2008 15:11:51 -0500 Subject: What motivates all unpaid volunteers at Pycon? Message-ID: > >> There really isn't any simple answer. Most people seem to be > >> motivated to help out their communities, > > > > I still think all this unselfishness is noteworthy > > and curious. > > > Assuming that people get nothing back by participating in a > community, yes, it would be curious. My experience, though, is that I > get a lot more out of it than I could ever contribute. IOW, it's a > great example of synergy. > > -- Ed Leafe I attended my first PyCon in D.C. a few years back. The next year I volunteered as a session chair because I wanted one of the groovy black "staff" shirts. Last year I signed up as the tutorial coordinator because I was told there was a need for people to step up and I felt strongly that as part of the community I have an obligation to give back (the same reason I was a volunteer firefighter for 5 years). I had no idea how much work it would be to put together 1 day of the conference; and just the talks at that (there's the technical aspect, food, registration, etc., that others handled). Once you become part of the community that puts the conference together and see how much passion these people put into their tasks it's hard to walk away, at least for me. I've signed up for tutorials again for 2009 and hope to bring 3 or 4 other volunteers along for the ride. What do I get out of it? Sure, I got another groovy tee shirt, but I also saw over 600 people taking classes on Tutorial Thursday. I got to meet some very smart cookies and saw a lot of Python that I had never seen before. Not everything went as planned, and a few things went poorly but, overall, things went pretty well. We are taking all off the feedback into account and are already looking at next year. So, if you're still reading this, why don't *YOU* help out, too? You can help out a little or you can help out a lot. There are highly technical issues that need addressing (see "PyCon Tech") and other tasks that don't require programming at all but are just as important (food, swag, etc.). Click on over to http://www.python.org/community/pycon/ and introduce yourself. You'll get a lot more than a groovy tee shirt out of it! --greg -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at holdenweb.com Sat Apr 5 22:08:45 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 22:08:45 -0400 Subject: Best way to check if string is an integer? In-Reply-To: <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> Message-ID: <47F830AD.9050106@holdenweb.com> John Machin wrote: > On Apr 6, 9:25 am, Mark Dickinson wrote: >> On Apr 5, 6:19 pm, skanem... at yahoo.se wrote: >> >>> which is the best way to check if a string is an number or a char? >>> could the 2nd example be very expensive timewise if i have to check a >>> lot of strings? >> You might be interested in str.isdigit: >> >>>>> print str.isdigit.__doc__ >> S.isdigit() -> bool >> >> Return True if all characters in S are digits >> and there is at least one character in S, False otherwise. >> > > This doesn't cater for negative integers. > No, it doesn't, but s.isdigit() or (s[0] in "+-" and s[1:].isdigit) # untested does. and *may* be quicker than other examples. Not that speed is usually a concern in validation routines anyway ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From __peter__ at web.de Mon Apr 7 07:16:48 2008 From: __peter__ at web.de (Peter Otten) Date: Mon, 07 Apr 2008 13:16:48 +0200 Subject: csv.DictReader and unicode References: Message-ID: Laszlo Nagy wrote: >> Read the values as byte strings and decode afterwards. Or monkey-patch: import csv def make_reader(fin, encoding="UTF-8"): reader = csv.DictReader(fin) reader.reader = ([col.decode(encoding) for col in row] for row in reader.reader) return reader fin = open("example.csv") for record in make_reader(fin): print record > Is there a plan to make csv reader compatible with unicode? I don't know. Peter From Lie.1296 at gmail.com Sun Apr 27 07:09:33 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 27 Apr 2008 04:09:33 -0700 (PDT) Subject: removing extension References: Message-ID: On Apr 27, 6:05 pm, Lie wrote: > On Apr 27, 5:34 pm, wilson wrote: > > > > > i was trying to convert all images in a folder to another type and > > save the new images in a separate folder.for that i wrote a class and > > coded some part > > > class ConvertImgs: > > def __init__(self,infldr,outfldr): > > if os.path.isdir(infldr): > > self.infldr=infldr > > self.outfldr=outfldr > > else: > > print "no such folder,exits program" > > exit(1) > > if not os.path.isdir(self.outfldr): > > os.mkdir(self.outfldr) > > print "made:",self.outfldr > > > for x in os.listdir(infldr): > > self.origlist=[os.path.normpath(os.path.join(self.infldr,x)) for x in > > os.listdir(infldr)] > > > ... > > the self.origlist returns a list of filenames in infolder.I would > > like to get them as 'C:\\myimages\\imageone' instead of 'C:\\myimages\ > > \imageone.jpg' sothat i can add a diff extension to all those strings > > in the list and save in diff format(ie change 'C:\\myimages\\imageone' > > to 'C:\\myimages\\imageone.gif ' and save in gif format).but i don't > > know how to remove those extension from the namestring ..can someone > > help? > > W > > I don't know if this is the simplest way, but you can use re module. > > import re > pat = re.compile(r'(.*?)\..*') Sorry, this line should be: pat = re.compile(r'(.*)\..*') or paths like these wouldn't pass correctly: "C:\\blahblah.blah\\images.20.jpg" > name = pat.search('C:\\myimages\\imageone.jpg').group(1) > print name From jr9445 at ATT.COM Wed Apr 16 10:12:26 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Wed, 16 Apr 2008 09:12:26 -0500 Subject: vary number of loops In-Reply-To: <480604BE.3090002@tim.thechases.com> References: <480604BE.3090002@tim.thechases.com> Message-ID: > -----Original Message----- > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > list-bounces+jr9445=att.com at python.org] On Behalf Of Tim Chase > Sent: Wednesday, April 16, 2008 9:53 AM > To: nullgraph at gmail.com > Cc: python-list at python.org > Subject: Re: vary number of loops > > > > > If n=3, I want to have 3 sets of elements and mix them up using 3 for > > loops. > > You might be ineterested in this thread: > > http://mail.python.org/pipermail/python-list/2008-January/473650.html > > where various solutions were proposed and their various merits > evaluated. > I second that. The thread compared building loops on the fly, building comprehensions nested to arbitrarily levels, recursion (sloooow!), a slick cookbook recipe using iterators, etc. and provided timings for each method. Definitely worth bookmarking. ***** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA625 From fairwinds at eastlink.ca Mon Apr 7 09:38:47 2008 From: fairwinds at eastlink.ca (David Pratt) Date: Mon, 07 Apr 2008 10:38:47 -0300 Subject: Help replacing os.system call with subprocess call In-Reply-To: <47F9C764.9070401@mattnordhoff.com> References: <47F9B1D1.4090701@eastlink.ca> <47F9C764.9070401@mattnordhoff.com> Message-ID: <47FA23E7.7040809@eastlink.ca> Hi David and Matt. I appreciate your help which has got me moving forward again so many thanks for your reply. I have been using subprocess.Popen a fair bit but this was the first time I had to use subprocess to capture large file output. The trouble I was having was with the process would just hang. Chunking was the solution. I guess I assumed this would be taken care of in the internals. Overall, I wish subprocess had some better documentation since it is definitely not a drop in replacement for os.system. In other circumstances I am using subprocess.call() for simple calls which works fine. The speed of this solution is slower than os.system. Would a queue of some kind be needed to speed this up? Has anyone implemented something like this? Many thanks. Regards, David Matt Nordhoff wrote: > David Pratt wrote: >> Hi. I am trying to replace a system call with a subprocess call. I have >> tried subprocess.Popen and subprocess.call with but have not been >> successful. The command line would be: >> >> svnadmin dump /my/repository > svndump.db >> >> This is what I am using currently: >> >> os.system('svnadmin dump %s > %s' % (svn_dir, >> os.path.join(backup_dir, 'svndump.db'))) >> >> Many thanks. > > Try this: > > import os.path > import subprocess > > p = subprocess.Popen( > ['svnadmin', 'dump', svndir], > stdout=subprocess.PIPE, > ) > > fh = open(os.path.join(backup_dir, 'svndump.db'), 'wb') > > while True: > chunk = p.stdout.read(2**20) # 1 MB > if not chunk: > break > fh.write(chunk) > > fh.close() > > It reads svnadmin's stdout in 1 MB chunks, in case it's large enough > that reading the whole thing into RAM at once would be a bad idea. > > No error handling. For one, you might want to add a try...finally to > ensure that fh will get closed. (Or if you have Python 2.5, use a with > statement! :-) ) Also, Popen will raise an OSError if svnadmin can't be > found or something. And this isn't even considering svnadmin erroring out... > > svnadmin's stderr will go to your stderr. > > I didn't test it, but I'm pretty sure it will work. (I spotted a syntax > error while writing that though.) I don't have much experience with > Popen's stdio objects, so it's possible you'd need to do something like > call p.wait() to wait for it to exit before being able to read its stdout. > > It could be slower than the os.system version, since now Python is doing > all of the I/O, instead of your shell, but I doubt that'll be a big problem. > > (Also, insert suggestion about using a good VCS. ;-) ) From software at ginstrom.com Tue Apr 1 10:32:12 2008 From: software at ginstrom.com (Ryan Ginstrom) Date: Tue, 1 Apr 2008 23:32:12 +0900 Subject: Copy Stdout to string In-Reply-To: References: Message-ID: <04c501c89405$2d213f00$0203a8c0@MOUSE> > On Behalf Of sophie_newbie > Hi, I'm wondering if its possible to copy all of stdout's > output to a string, while still being able to print on > screen. I know you can capture stdout, but I still need the > output to appear on the screen also... If I understand you correctly, the following class should work. from StringIO import StringIO class OutBuffer(object): """Wraps a stream, and keeps output as a buffer Usage: >>> import sys >>> sys.stdout = OutBuffer(sys.stdout) >>> print "spam" spam >>> print "egg" egg >>> sys.stdout.getvalue().splitlines() ['spam', 'egg'] """ def __init__(self, outstream): self.out = outstream self.buffer = StringIO() def write(self, obj): """Writes obj to the output stream, storing it to a buffer as well""" self.out.write(obj) self.buffer.write(obj) def getvalue(self): """Retrieves the buffer value""" return self.buffer.getvalue() def __getattr__(self, attr): """Delegate everything but write and getvalue to the stream""" return getattr(self.out, attr) Regards, Ryan Ginstrom From pavlovevidence at gmail.com Tue Apr 22 10:55:03 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 22 Apr 2008 07:55:03 -0700 (PDT) Subject: Remove multiple inheritance in Python 3000 References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <6760jfF2n3bn1U1@mid.uni-berlin.de> <6bec3c67-689a-4df2-848f-d3936a143024@f36g2000hsa.googlegroups.com> Message-ID: <1510fd01-5e13-4124-a3fe-ff69d9011ebb@d1g2000hsg.googlegroups.com> On Apr 22, 10:36 am, George Sakkis wrote: > On Apr 22, 10:22 am, Carl Banks wrote: > > > Java (for example) allows a class to share behavior with only one > > other class, and that *severely* limits the opportunities to minimize > > redundancy. > > Not really; composition is usually a better way to share functionality > and reduce redundancy than inheritance. I should have known this was coming. I disagree: inheritance is a much better way to share behavior. Use inheritance by default, composition if you have to. (Or composition when it actually reflects a composition relationship, and not mere behavior sharing.) With composition you're burdening the user with having to learn the shared relationships that ought to be implementation details of the class. E.g., obj.action_style.perform_action() With inheritance, the user doesn't have to worry about these relationships. obj.perform_action() It's better to isolate complexity (which inheritance does) than to spread it out (which composition does). Carl Banks From istvan.albert at gmail.com Fri Apr 18 09:50:17 2008 From: istvan.albert at gmail.com (Istvan Albert) Date: Fri, 18 Apr 2008 06:50:17 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <66q33cF2krjf2U1@mid.uni-berlin.de> Message-ID: On Apr 18, 1:39 am, Sverker Nilsson wrote: > Some whine. Some just don't care. Why not whine? Whining and ranting is actually good for the psyche. It is better to get it out of your system. As for your original post, no doubt there are substantial downsides to introducing Py3K, but as Guido put it every language must "change or die". Of course we could end up with "change and die" as well. I for one am an optimist, I think there are several substantial improvements to the language that today may not be apparent for a casual observer, yet will allow it to evolve into an even more powerful and fun language i. From mensanator at aol.com Wed Apr 16 19:12:09 2008 From: mensanator at aol.com (Mensanator) Date: Wed, 16 Apr 2008 16:12:09 -0700 (PDT) Subject: def power, problem when raising power to decimals References: <48067bdb@news.mel.dft.com.au> Message-ID: <6f348df6-e441-4c47-aa6c-cd01266e97fe@y21g2000hsf.googlegroups.com> On Apr 16, 5:49?pm, "Gabriel Genellina" wrote: > En Wed, 16 Apr 2008 19:21:18 -0300, John Machin ? > escribi?: > > > skanem... at yahoo.se wrote: > >> also i found a link which states 0^0 isnt 1 even though every > >> calculator ive tried says it is. > >> it doesnt say what it is but i presume 0 then. > >> but it seems the dude is wrong and it is 1? > > > Of the possible results of 0 ** 0 (i.e. 1, 0, and NaN), 1 seems to be > > the least implausible. It allows X ** 0 to be 1 for all X. > > But a result of 0 would allow 0 ** X to be 0 for all X. (btw, this is the ? > reason lim(x**x) for x->0 does not exist) Where this has come up in my research, X**0 being a multiplicative identity is far more important than 0**X being an additive identity. > > -- > Gabriel Genellina From kinch1967 at gmail.com Sun Apr 27 09:35:43 2008 From: kinch1967 at gmail.com (bullockbefriending bard) Date: Sun, 27 Apr 2008 06:35:43 -0700 (PDT) Subject: design choice: multi-threaded / asynchronous wxpython client? Message-ID: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> I am a complete ignoramus and newbie when it comes to designing and coding networked clients (or servers for that matter). I have a copy of Goerzen (Foundations of Python Network Programming) and once pointed in the best direction should be able to follow my nose and get things sorted... but I am not quite sure which is the best path to take and would be grateful for advice from networking gurus. I am writing a program to display horse racing tote odds in a desktop client program. I have access to an HTTP (open one of several URLs, and I get back an XML doc with some data... not XML-RPC.) source of XML data which I am able to parse and munge with no difficulty at all. I have written and successfully tested a simple command line program which allows me to repeatedly poll the server and parse the XML. Easy enough, but the real world production complications are: 1) The data for the race about to start updates every (say) 15 seconds, and the data for earlier and later races updates only every (say) 5 minutes. There is no point for me to be hammering the server with requests every 15 seconds for data for races after the upcoming race... I should query for this perhaps every 150s to be safe. But for the upcoming race, I must not miss any updates and should query every ~7s to be safe. So... in the middle of a race meeting the situation might be: race 1 (race done with, no-longer querying), race 2 (race done with, no longer querying) race 3 (about to start, data on server for this race updating every 15s, my client querying every 7s), races 4-8 (data on server for these races updating every 5 mins, my client querying every 2.5 mins) 2) After a race has started and betting is cut off and there are consequently no more tote updates for that race (it is possible to determine when this occurs precisely because of an attribute in the XML data), I need to stop querying (say) race 3 every 7s and remove race 4 from the 150s query group and begin querying its data every 7s. 3) I need to dump this data (for all races, not just current about to start race) to text files, store it as BLOBs in a DB *and* update real time display in a wxpython windowed client. My initial thought was to have two threads for the different update polling cycles. In addition I would probably need another thread to handle UI stuff, and perhaps another for dealing with file/DB data write out. But, I wonder if using Twisted is a better idea? I will still need to handle some threading myself, but (I think) only for keeping wxpython happy by doing all this other stuff off the main thread + perhaps also persisting received data in yet another thread. I have zero experience with these kinds of design choices and would be very happy if those with experience could point out the pros and cons of each (synchronous/multithreaded, or Twisted) for dealing with the two differing sample rates problem outlined above. Many TIA! From uniontelecardsindia at gmail.com Tue Apr 22 17:13:32 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:13:32 -0700 (PDT) Subject: Masculine black gays in nasty orgy Message-ID: Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From bskaplan14 at yahoo.com Wed Apr 16 21:13:03 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Wed, 16 Apr 2008 18:13:03 -0700 (PDT) Subject: Logical Operator and code block not executing (newbie question) Message-ID: <671091.823.qm@web39205.mail.mud.yahoo.com> The problem is that your loop says "while guess != number". When guess is equal to the number, the code in the loop is not executed. Instead, do something like while guess != number and tries < total_attempts: if guess > number: ... elif guess < number: ... if guess == number : ... ----- Original Message ---- From: python newbie To: python-list at python.org Sent: Wednesday, April 16, 2008 8:58:10 PM Subject: Logical Operator and code block not executing (newbie question) Hello, I am running into a small problem of not having a code block not executing after after a logical operator is true. What am I missing or doing wrong. Any thoughts or opinions would be greatly appreciated. The block that isn't being executed follows: elif (guess == the_number) and (tries < total_attempts): print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" print "The correct answer is: ", the_number Below is the complete script: #! /usr/bin/python # Aurthor: Me # Purpose: Demonstrates # Date: April 15, 2008 import random print "\tWelcome to 'Guess My Number'!" print "\nI'm thinking of a number between 1 and 100." print "Try to guess it in as few attempts as possible.\n" # set the initial values the_number = random.randrange(100) + 1 guess = int(raw_input("Take a guess: ")) tries = 1 total_attempts = 3 # guessing loop while (guess != the_number): if (guess > the_number) and (tries < total_attempts): print "Lower..." print "You have...", total_attempts - tries, "left." print "The correct answer is: ", the_number elif (guess < the_number) and (tries < total_attempts): print "Higher..." print "You have...", total_attempts - tries, "left." print "The correct answer is: ", the_number elif (guess == the_number) and (tries < total_attempts): print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" print "The correct answer is: ", the_number elif (tries >= total_attempts): print "You're out of guess" print "You have...", total_attempts - tries, "left." print "You need more practice." print "The correct answer is: ", the_number break else: print "You shouldn't see this message..." print "You have...", total_attempts - tries, "left." print "The correct answer is: ", the_number break guess = int(raw_input("Take a guess: ")) tries += 1 raw_input("\n\nPress the enter key to exit.") PS: I am new to coding & scripting. Pete Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From gh at gregor-horvath.com Fri Apr 25 14:27:15 2008 From: gh at gregor-horvath.com (Gregor Horvath) Date: Fri, 25 Apr 2008 20:27:15 +0200 Subject: Why is None <= 0 Message-ID: Hi, >>> None <= 0 True Why? Is there a logical reason? Gregor From hdante at gmail.com Sun Apr 27 21:17:51 2008 From: hdante at gmail.com (hdante) Date: Sun, 27 Apr 2008 18:17:51 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <2d06b319-e2fd-4790-af61-6f90b9b1b3b1@m1g2000pre.googlegroups.com> <41e72e61-6413-41f3-a162-dbcc1ec5fcee@f63g2000hsf.googlegroups.com> <9776420a-c34d-425e-8598-eecf4bfd0d02@t63g2000hsf.googlegroups.com> Message-ID: <075fc7b8-ff84-40f7-ad2b-eb2077e5abdb@t54g2000hsg.googlegroups.com> On Apr 27, 4:54?pm, n00m wrote: > Another PC, another OS (Linux) and another compiler C++ (g++ 4.0.0-8) > > Compare 2 my latest submissions:http://www.spoj.pl/status/SBANK,zzz/ > > times: 1.32s and 0.60s > > Submitted codes: > > import sys > z=sys.stdin.readlines() > print z[5] > > #include > #include > #include > #include > > using namespace std; > > vector vs; > > int main() { > ? ? while (true) { > ? ? ? ? char line[50]; > ? ? ? ? if (!fgets(line,50,stdin)) break; > ? ? ? ? vs.push_back(line); > ? ? } > return 0; > > } > > If it proves nothing then white is black and good is evil It seems that the "push_back" line takes most of the time of the code. Remove it and execution will drop to 0.25s. Python readline uses fread instead of fgets: http://svn.python.org/view/python/tags/r251/Objects/fileobject.c?rev=54864&view=markup (see the file_readlines function) If you write a code that does an fread loop, execution will drop to 0.01s. This C code takes 0.25s. Almost all time is spent with string manipulation. #include #include #define B 8192 char vs[100000][40]; char buffer[B]; int main(void) { int count; char *begin, *end; int i; i = 0; while (1) { count = fread(buffer, 1, B, stdin); if (count == 0) break; begin = buffer; while(1) { end = (char *)memchr(begin, '\n', buffer+B-begin); if (end == NULL) { memmove(buffer, begin, buffer+B-begin); break; } memmove(vs[i], begin, end-begin); i = (i+1)%100000; begin = end + 1; } } return 0; } The difference, 0.60s-0.25s = 0.35s is probably mostly python's memory management (which seems to be much more efficient than std::vector default). Very interesting post. :-) I had no idea about how much optimized the builtin library was. From needin4mation at gmail.com Tue Apr 29 13:46:04 2008 From: needin4mation at gmail.com (jmDesktop) Date: Tue, 29 Apr 2008 10:46:04 -0700 (PDT) Subject: Simple import question about mac osx References: Message-ID: On Apr 29, 1:16?pm, jmDesktop wrote: > Hi, I have this code (learning from Core Python, Chun's book), module > named chap2.py. > > class FooClass(object): > ? ? ? ? version=0.1 > > ? ? ? ? def __init__(self, nm='John Doe'): > ? ? ? ? ? ? ? ? self.name=nm > ? ? ? ? ? ? ? ? print 'Created a class instance for ', nm > ? ? ? ? def showname(self): > ? ? ? ? ? ? ? ? print 'Your name is', self.name > ? ? ? ? ? ? ? ? print 'My name is', self.__class__.__name__ > > On Windows, if I compile this and then in the python interpreter type: > > >>> import chap2 > >>> foo1=FooClass() > > Created a class instance for ?John Doe > > > > If I do the same think on my Mac OS X 10.5.2 > > NameError: name 'FooClass' is not defined. > > I thought it was the path and did export PATH=$PATH:/mypath/ > topythoncode > > but it did not help. > > What am I doing wrong? ?Thank you. forgot to say that on the mac I can do import chap2, but when I try and instantiate I get the error above. From mccredie at gmail.com Fri Apr 11 17:08:31 2008 From: mccredie at gmail.com (Matimus) Date: Fri, 11 Apr 2008 14:08:31 -0700 (PDT) Subject: How to make a "command line basd" interactive program? References: Message-ID: On Apr 11, 2:32 am, Evan wrote: > Hope this hasn't been posted hundreds of times. I'm new for this. > > Before using python for this kind of script, I was using TCL to write > down a "command line based" interactive program. it likes a "tclsh", > or "python" command, after that, you can work under a prompt, for > example, " - >> ", and then you can execute any commands what you > defined in script. > > Now, in python, are there any common way(class) to finish this work? > or does anybody has a example to do that? > > Thanks, > Evan Do you want a custom shell that does whatever you want? Or do you want an interactive python shell that has some custom commands? For the first check out the cmd module http://docs.python.org/lib/module-cmd.html example: >>> import cmd >>> class MyCmd(cmd.Cmd): ... def do_echo(self, params): ... print params ... >>> MyCmd().cmdloop() (Cmd) echo Hello World Hello World (Cmd) help Undocumented commands: ====================== echo help For the second, check out the code module http://docs.python.org/lib/module-code.html example: >>> import code >>> def foo(): ... print "hello, this is foo" ... >>> code.interact("Welcome to my python shell!", local={'bar':foo}) Welcome to my python shell! >>> bar() hello, this is foo >>> Hope this helps, Matt From tundra at tundraware.com Thu Apr 17 00:08:09 2008 From: tundra at tundraware.com (Tim Daneliuk) Date: Wed, 16 Apr 2008 23:08:09 -0500 Subject: I just killed GIL!!! In-Reply-To: References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: <52vid5-cvl2.ln1@ozzie.tundraware.com> Daniel Fetchinson wrote: >> Hello Guys... >> >> I just had one moment of exceptional clarity, during which realized >> how I could get the GIL out of my way... It's so simple, I cannot help >> wondering why nobody has thought of it before. Duh! Now I am going to >> sit and and marvel at my creation for a while, and then go to bed >> (it's past 2:30 a.m.) Tomorrow I will contemplate whether to sell this >> little secret for big bucks, give it away for free, or just keep it to >> myself... :-) >> >> Now you are probably thinking I reinvented the gunpowder, and are >> running multiple processes. Not so. I am not running parallel >> processes, like parallel python or the processing module in cheese >> shop. I am running multiple THREADS. In fact, I am just using >> threading.Thread. The source code is pure Python, so there is no C >> magic, and I only used the stuff that's already there in the standard >> library. So, I just made CPython do what everyone claim to be >> impossible. One single process of CPython is using all the cpu power >> of my dual-core laptop. > > > > If I were you I would keep it a secret until a Hollywood producer > offers big bucks for the film rights. Who would play Guido, I wonder? -- ---------------------------------------------------------------------------- Tim Daneliuk tundra at tundraware.com PGP Key: http://www.tundraware.com/PGP/ From grahn+nntp at snipabacken.se Sun Apr 6 03:05:19 2008 From: grahn+nntp at snipabacken.se (Jorgen Grahn) Date: 6 Apr 2008 07:05:19 GMT Subject: Recursively Backup Directories References: Message-ID: On Sat, 5 Apr 2008 16:56:31 -0700 (PDT), misceverything at gmail.com wrote: > I am writing a script that will backup specified folders from one hard > drive to another (for example, backup source "C:\DATA", destination "D: > \Backup"), and was thinking of using shutil. I'd avoid doing that (writing a backup script, that is). It may be fine if your goal is using it only under MS-DOS, and not distribute it. But making it robust (vital to a backup utility!) and portable is tricky. You have to handle things like - symbolic links (when to follow, when not to) - hard links - copying metadata of various kinds (timestamps, permissions, ACLs, file system-specific metadata) - non-obvious error handling (like copying the file 'foo', but the target exists as a directory and must be rmdir()ed first) - ... I believe it is better to write a script which drives a widely known and well-tested copying utility. On Unix these include tar, cpio and rsync -- don't know which ones are common under DOS (xcopy?) I guess I'm saying that I do not trust module shutil. I see now that it documents how it treats some of the things above, but ... /Jorgen -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! From kyosohma at gmail.com Fri Apr 11 17:11:04 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 11 Apr 2008 14:11:04 -0700 (PDT) Subject: Windows - window status (Running vs Not Responding) References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> <5f4a5d63-c862-4d25-8849-6a36dd4e138d@m3g2000hsc.googlegroups.com> Message-ID: On Apr 11, 3:22 pm, Tim Golden wrote: > Mike Driscoll wrote: > >http://www.informit.com/articles/article.aspx?p=19489&seqNum=4 > > > If you're better than I am, you can probably translate this to the > > Python equivalent. Zenoss also has some monitoring software that's > > open source Python code. > > I'm afraid that article only allows you to determine whether > a known executable is running, If that's what the OP's after, > then you can do as much by querying WMI thusly: > > > import wmi > c = wmi.WMI () > > EXE = "notepad.exe" > for process in c.Win32_Process (Caption=EXE): > print process > break > else: > print "None found" > > > > TJG Tim, Oh well. I guess my Google-Fu failed me this time around. Thanks for looking at it though. Mike From smmehadi at gmail.com Tue Apr 8 01:35:12 2008 From: smmehadi at gmail.com (syed mehdi) Date: Tue, 8 Apr 2008 11:05:12 +0530 Subject: ImportError: No module named MySQLdb In-Reply-To: References: <12b075a10804072035j42c85d4m3e4b45778d9697c4@mail.gmail.com> Message-ID: <12b075a10804072235w6978491era2ff50d2bd80367f@mail.gmail.com> Thanks Gabriel, it worked after installing MySQL (database engine). Regards Syed On Tue, Apr 8, 2008 at 10:23 AM, Gabriel Genellina wrote: > En Tue, 08 Apr 2008 00:35:29 -0300, syed mehdi > escribi?: > > > I have been working in python from some time now, > > while writing a python script i used: import MySQLdb in my script to do > > some > > database related operations. > > When i tried to execute the same script on another system it gave me an > > error as: > > "ImportError: No module named MySQLdb" > > though mysqldb was already installed on that system, and python 2.5.2 > was > > present on that machine. > > i have tried uninstalling and installing of mysql again and again but to > > no > > avail. > > MySQL (the database engine) is not the same as MySQLdb (the Python > package). You have to download and install it: > http://mysql-python.sourceforge.net/ > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at cheimes.de Wed Apr 23 05:16:20 2008 From: lists at cheimes.de (Christian Heimes) Date: Wed, 23 Apr 2008 11:16:20 +0200 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: <200804230839.49560.v.harishankar@gmail.com> References: <200804230839.49560.v.harishankar@gmail.com> Message-ID: Harishankar schrieb: > Is there any platform independent way to launch a terminal window from a > desktop (Windows, Linux, etc.)? No, there isn't. It usually not possible to create a graphical terminal window on a remote server. Christian From terry.yinzhe at gmail.com Sun Apr 27 09:35:46 2008 From: terry.yinzhe at gmail.com (Terry) Date: Sun, 27 Apr 2008 06:35:46 -0700 (PDT) Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> Message-ID: <8c7579b8-d6d1-4ae6-9374-443d46462c59@j33g2000pri.googlegroups.com> On Apr 27, 6:27 pm, Terry wrote: > Hello! > > I'm trying to implement a message queue among threads using Queue. The > message queue has two operations: > PutMsg(id, msg) # this is simple, just combine the id and msg as one > and put it into the Queue. > WaitMsg(ids, msg) # this is the hard part > > WaitMsg will get only msg with certain ids, but this is not possible > in Queue object, because Queue provides no method to peek into the > message queue and fetch only matched item. > > Now I'm using an ugly solution, fetch all the messages and put the not > used ones back to the queue. But I want a better performance. Is there > any alternative out there? > > This is my current solution: > > def _get_with_ids(self,wait, timeout, ids): > to = timeout > msg = None > saved = [] > while True: > start = time.clock() > msg =self.q.get(wait, to) > if msg and msg['id'] in ids: > break; > # not the expecting message, save it. > saved.append(msg) > to = to - (time.clock()-start) > if to <= 0: > break > # put the saved messages back to the queue > for m in saved: > self.q.put(m, True) > return msg > > br, Terry I just found that Queue is written in Python, maybe I can override it. From deets at nospam.web.de Wed Apr 16 06:20:54 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 16 Apr 2008 12:20:54 +0200 Subject: how turbo geras code works References: Message-ID: <66m292F2lo3ghU2@mid.uni-berlin.de> reetesh nigam wrote: > hi. > actually i have developed one small project but now i want to > develope a project with the help of html.. > please help me out Try and work through the turbogears.org website, especially the tutorial. Subscribe to the TG mailing list, and post *concrete* questions. Questions of the type "I want to fly to the moon, please help me do it" are hard to answer. Diez From ggpolo at gmail.com Sat Apr 5 13:17:08 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sat, 5 Apr 2008 14:17:08 -0300 Subject: Tkinter: making buttons the same size? In-Reply-To: <3753aa85-c844-4e54-8213-142e50fd8a7e@b5g2000pri.googlegroups.com> References: <12bad1a6-3b4b-446e-9673-8893cd6838f9@s37g2000prg.googlegroups.com> <3753aa85-c844-4e54-8213-142e50fd8a7e@b5g2000pri.googlegroups.com> Message-ID: 2008/4/5, skanemupp at yahoo.se : > how do i do that? i get this error: > > > > self.btnDisplay = Button(self,text='1',command=lambda > n=1:self.Display(n)) > > self.btnDisplay.grid(row=3, column=0, padx=5, pady=5, width=1) > > > self.btnDisplay = Button(self,text='/',command=lambda > n="/":self.Display(n)) > > self.btnDisplay.grid(row=6, column=3, padx=5, pady=5, width=1) > Add it to the Button widget, not to the grid method. mybtn = Button(..., width=1) Thanks, -- -- Guilherme H. Polo Goncalves From paulgeeleher at gmail.com Tue Apr 22 10:10:07 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Tue, 22 Apr 2008 07:10:07 -0700 (PDT) Subject: Spawing a thread and printing dots until it finishes Message-ID: Hi, I'm trying to write a piece of code that spawns a thread and prints dots every half second until the thread spawned is finished. Code is something like this: import threading class MyThread ( threading.Thread ): def run ( self ): myLongCommand()... import time t = MyThread() t.start() while t.isAlive(): print "." time.sleep(.5) print "OK" The thing is this doesn't print a dot every half second. It just pauses for ages until the thread is finished and prints prints ".OK". But if I take out the "time.sleep(.5)" line it will keep printing dots really fast until the thread is finished. So it looks like its the time.sleep(.5) bit that is messing this up somehow? Any ideas? Thanks! From google at mrabarnett.plus.com Thu Apr 17 11:50:51 2008 From: google at mrabarnett.plus.com (MRAB) Date: Thu, 17 Apr 2008 08:50:51 -0700 (PDT) Subject: Profiling, recursive func slower than imperative, normal? References: Message-ID: <8e40ad23-cd75-4dfa-84ff-3fdef36faa11@m36g2000hse.googlegroups.com> On Apr 17, 9:39 am, Robert Bossy wrote: > Gabriel Genellina wrote: > > En Wed, 16 Apr 2008 17:53:16 -0300, escribi?: > > >> On Apr 16, 3:27 pm, Jean-Paul Calderone wrote: > > >>> Any function can be implemented without recursion, although it isn't > >>> always easy or fun. > > >> Really? I'm curious about that, I can't figure out how that would > >> work. Could give an example? Say, for example, the typical: walking > >> through the file system hierarchy (without using os.walk(), which uses > >> recursion anyway!). > > > Use a queue of pending directories to visit: > > > start with empty queue > > queue.put(starting dir) > > while queue is not empty: > > dir = queue.get() > > list names in dir > > for each name: > > if is subdirectory: queue.put(name) > > else: process file > > Hi, > > In that case, I'm not sure you get any performance gain since the queue > has basically the same role as the stack in the recursive version. A > definitive answer calls for an actual test, though. > > Anyway if you want to process the tree depth-first, the queue version > falls in the "not fun" category. > If you store the folders in a queue (push onto one end and pop from the other end) the search is breadth-first; if you store the folders in a stack (push onto one end and pop from the same end) the search is depth-first. Simple really! :-) From fredri8758lupo at gmail.com Wed Apr 23 06:09:20 2008 From: fredri8758lupo at gmail.com (fredri8758lupo at gmail.com) Date: Wed, 23 Apr 2008 03:09:20 -0700 (PDT) Subject: 7 sins nude patch Message-ID: 7 sins nude patch http://cracks.12w.net F R E E C R A C K S From shikha_saxena2007 at yahoo.com Wed Apr 16 03:42:06 2008 From: shikha_saxena2007 at yahoo.com (Prashant) Date: Wed, 16 Apr 2008 07:42:06 -0000 Subject: insert python script in current script Message-ID: I was wondering is there any way to do this: I have written a class in python and __init__ goes like this: def __init__(self): self.name = 'jack' self.age = 50 import data now here there is data.py in the same directory and contents are like: self.address = 'your address' self.status = 'single' The problem is 'self' is giving some error here. I need to know if somehow I can do this. It's like inserting the script as it's part of the file itself. Cheers From arnodel at googlemail.com Tue Apr 8 01:38:32 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Mon, 7 Apr 2008 22:38:32 -0700 (PDT) Subject: A file iteration question/problem References: <47f8eee1$0$759$bed64819@news.gradwell.net> <47faa04f$0$36349$742ec2ed@news.sonic.net> Message-ID: On Apr 7, 11:40?pm, John Nagle wrote: > tinn... at isbd.co.uk wrote: > > I want to iterate through the lines of a file in a recursive function > > so I can't use:- > > > ? ? f = open(listfile, 'r') > > ? ? for ln in f: > > > because when the function calls itself it won't see any more lines in > > the file. ?E.g. more fully I want to do somthing like:- > > > def recfun(f) > > ? ? while True: > > ? ? ? ? str = readline(f) > > ? ? ? ? if (str == "") > > ? ? ? ? ? ? break; > > ? ? ? ? # > > ? ? ? ? # do various tests > > ? ? ? ? # > > ? ? ? ? if : > > ? ? ? ? ? ? recfun(f) > > ? ? ?Don't do that; Python doesn't have tail recursion and you'll hit the > stack limit. > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? John Nagle This function is not tail recursive (the recursive call is in a loop). -- Arnaud From umpsumps at gmail.com Sat Apr 26 16:00:00 2008 From: umpsumps at gmail.com (umpsumps at gmail.com) Date: Sat, 26 Apr 2008 13:00:00 -0700 (PDT) Subject: learning with python question (HtTLaPP) Message-ID: <98acecbd-9de2-4ebf-927b-ac6bc1fbc3fd@b5g2000pri.googlegroups.com> Hello all, I've been trying to teach myself python from "How to Think Like a Python Programmer" and have been trying to write a script that checks 'words.txt' for parameters (letters) given. The problem that is the i can only get results for the exact sequnce of parameter 'letters'. I'll spare posting all the different ways I've tried to search for specific letters. But they are all generally: for line in fin: for linechar in line: for ch in letters: or the "for linechar in line:" and "for ch in letters:" get switched.. I'm getting really frustrated to say the least. What alternative method could I use that isn't too advanced? Any tips/suggestions on the code itself would be greatly appreciated, and tips for learning in general. here is the code that returns a certain sequence: >>> def searchtxt(letters): fin = open('words.txt') words = "" index = 0 count = 0 for line in fin: index +=1 if letters in line.strip(): count += 1 words = line.strip() + '\n' + words print words print index, 'lines searched..', count, letters, 'words present' Thank you in advance. From tjreedy at udel.edu Wed Apr 9 18:37:46 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 9 Apr 2008 18:37:46 -0400 Subject: How to find documentation about methods etc. for iterators References: <47fce941$0$755$bed64819@news.gradwell.net> Message-ID: wrote in message news:47fce941$0$755$bed64819 at news.gradwell.net... | I'm not sure if I have even phrased that right but anyway.... | | How does one find (in the standard Python documentation) information | about things like the iteritems() method and the enumerate() function. The Library Reference manual sections on builtin functions and dict methods. Or, help(enumerate) and help({}.iteritems) tjr From bruno.desthuilliers at gmail.com Mon Apr 7 09:20:10 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Mon, 7 Apr 2008 06:20:10 -0700 (PDT) Subject: First Python project - comments welcome! References: Message-ID: <4a200ecf-a945-4cb6-8f91-0b8baf378e18@n58g2000hsf.googlegroups.com> On 7 avr, 10:03, Paul Scott wrote: > I have started, and made some progress (OK it works, but needs some > love) on my first real Python application. > > http://cvs2.uwc.ac.za/trac/python_tools/browser/podder > > I would love some feedback on what I have done. In total this has taken > me 5 nights to do (I am working on it at night as PHP, not Python, is my > day job), so it can probably do with *lots* of improvement. All code is > GPL. > > If anyone on this list is willing/able, please do give me a few > pointers, even if it is "This is total crap - RTFM and come back when > you are ready" I would really appreciate it! Ok, since you asked for it: 22 try: 23 import pygtk 24 #tell pyGTK, if possible, that we want GTKv2 25 pygtk.require("2.0") 26 except: Don't use bare except clauses, always mention the exception class you're expecting and let every other exception propagate. Else you may shadow other unexpected errors (ie: what if the user has a pygtk.py file in her pythonpath that is unrelated to the expected pygtk module ? And yes, this kind of thing can and does happen, more often than you may think). 27 print "You need to install pyGTK or GTKv2 or set your PYTHONPATH correctly" stdout is for normal program outputs. Error messages should go to sys.stderr. 28 print "try: export PYTHONPATH=/usr/local/lib/python2.2/site- packages/" 29 sys.exit(1) 40 class appgui: 1/ naming convention : should be Appgui or AppGui (cf pep08) 2/ unless you have very compelling reasons to stick with old-style classes, make your class a newstyle one: class AppGui(object): 41 def __init__(self): 42 """ 43 In this init we are going to display the main recorder window 44 """ 45 global globaldir 46 globaldir="./" Since this doesn't depend on anything passed to the initializer, and is initialized with a constant value, this should go to the top-level, ie: GLOBAL_DIR = './' class AppGui(object): # code here 58 "on_window1_destroy" : (gtk.main_quit)} This may not do what you think. If what you want is to pass a tuple, the syntax is: "on_window1_destroy" : (gtk.main_quit, ) } notice the trailing ',' 59 self.wTree.signal_autoconnect (dic) 60 self.status = STOPPED 61 return You don't need this return statement. 64 def record_click(self,widget): (snip) 70 self.player = gst.Pipeline("recorder") (snip) 87 def pause_click(self,widget): (snip) 94 if widget.get_active(): 95 # print "paused recording..." 96 self.player.set_state(gst.STATE_PAUSED) This may be a bit of a personnal preference, but I never feel confortable with attributes added in a method (I mean, else than the initializer) and accessed in another. Specially when it's a very important attribute... One reason being that I don't get the 'big picture' just from browsing the __init__ and the methods names, another being that now pause_click depends on record_click having been called before - yet nothing mentions it, nothing documents it, you have to read the whole code to find about it. 204 try: 205 f=open(globaldir+"lecture.ogg", 'r') Steve Holden already commented on using os.path.join here, and I commented about using a top-level constant (GLOBAL_DIR), which will makes thing more explicit (we know it's a constant, and we will look for it at the top-level). I'd recommend to also use top-level symbolic constants for the file names, instead of hardcoding them in the methods. Same thing for urls etc. 206 b=open(globaldir+"basefile", 'w') 207 encoded = base64.encode(f,b) 208 b.close() 209 except: 210 print "File could not be opened..." And what you get an exception in the call to base64.encode ? This is *exactly* why you should *never* use bare except clauses. (snip more bare except clauses...) And while we're at it, you forget to close f. 283 if type(currentThread()) != _MainThread: Since types are singletons, you can use the identity test here: if type(currentThread()) is not _MainThread: 306 def __init__ (self, parrent, queue, signal, sendPolicy): (snip) 309 self.parrent = parrent Don't you mean 'parent' ?-) 316 v = self.queue.get() 317 if v == None: identity test again (more idiomatic, and a little bit faster) 318 break 319 threads_enter() 320 l = [v] 'v' is a very poor name, and 'l' is even worse. 431 # Get stuff # 432 def isCancelled (self): 433 return self.cancelled 434 435 def isDone (self): 436 return self.done 437 438 def getProgress (self): 439 return self.progress Unless something in the framework requires these getters (I have almost no experience with pyGTK), you'd be better using direct attribute access IMHO. Else, it would be better to mark cancelled, done and progress as implementation attributes (by prefixing them with a single underscore) so everyone knows he shouldn't access them directly. Else it looks mostly clean !-) HTH From marco at sferacarta.com Tue Apr 22 06:41:41 2008 From: marco at sferacarta.com (Marco Mariani) Date: Tue, 22 Apr 2008 12:41:41 +0200 Subject: Python Success stories In-Reply-To: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: azrael wrote: > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" > > This hurts. Please give me informations about realy famous > aplications. He's joking. Perl is a dysfunctional language and its users need a strong sense of humor to go on, day after day. From kyosohma at gmail.com Mon Apr 21 11:12:40 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Mon, 21 Apr 2008 08:12:40 -0700 (PDT) Subject: Finding the selected file in Windows Explorer References: Message-ID: On Apr 21, 9:44 am, domir... at gmail.com wrote: > Hi! > > I need to find the selected file(s) in a Windows Explorer window from > another program (I'd look at the window that last had focus). I found > something in the following page that should do the trick: > > http://blogs.msdn.com/oldnewthing/archive/2004/07/20/188696.aspx > > However, it is not Python and, while I'm a competent Python > programmer, Win32, COM and the like are somewhat outside my > competences. > > Does any one know how to do something similar in Python? > > Tks! > Domiriel I think the guys on the PyWin32 mailing list were just talking about something similar earlier this month. Looks like it was how to select a file in Explorer. You can check out that thread here: http://www.mail-archive.com/python-win32 at python.org/maillist.html Or just join their mailing list and re-post your question there: http://mail.python.org/mailman/listinfo/python-win32 They're quite nice and very knowledgeable. Mike From bruno.desthuilliers at gmail.com Wed Apr 2 13:56:07 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 10:56:07 -0700 (PDT) Subject: april fools email backfires References: <7xbq4sf9wv.fsf@ruckus.brouhaha.com> Message-ID: On 2 avr, 19:23, Paul Rubin wrote: > Aaron Watters writes: > > Grapevine says that an architect/bigot at a java/spring shop sent > > out an April Fools email saying they had decided to port everything > > to Django ASAP. > > > Of course the email was taken seriously and he got a lot of positive > > feedback from line developers and savvy users/managers that they > > thought it would be a great idea; it's about time; gotta do > > something about this mess... > > Django, pah. They should switch to something REALLY advanced: > > http://www.coboloncogs.org/INDEX.HTM KEYBOARD ! From stef.mientki at gmail.com Thu Apr 3 17:21:25 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Thu, 03 Apr 2008 23:21:25 +0200 Subject: displaying execution of Python code In-Reply-To: <1afcbf34-0a40-4d11-b12f-603f0ee8f26c@m3g2000hsc.googlegroups.com> References: <1afcbf34-0a40-4d11-b12f-603f0ee8f26c@m3g2000hsc.googlegroups.com> Message-ID: <47F54A55.6000308@gmail.com> noahwatkins wrote: > I'll start my question by describing my desired result. I will > construct a GUI which will be used to open a Python script. I would > then like to be able to display the Python script, execute it, and > highlight the lines of the Python as they are executing. > > More technically, I am looking for direction on where to start looking > in the Python libraries for a functionality that will allow me to > execute arbitrary Python code from within a Python application. > Additionally, I need to be able to have the ability to get information > and perform actions (e.g. line number currently executing) as the code > executes. > > Thanks, > Noah > start with the wxPython demo, I guess you find all you need in there. cheers, Stef From jon+usenet at unequivocal.co.uk Fri Apr 25 20:17:24 2008 From: jon+usenet at unequivocal.co.uk (Jon Ribbens) Date: Fri, 25 Apr 2008 19:17:24 -0500 Subject: Why is None <= 0 References: <481226f9$0$20866$9b622d9e@news.freenet.de> Message-ID: On 2008-04-25, Martin v. L?wis wrote: > None is smaller than anything. According to Tim Peters, this is not true. See http://bugs.python.org/issue1673405 From kyosohma at gmail.com Tue Apr 22 17:09:40 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 22 Apr 2008 14:09:40 -0700 (PDT) Subject: list manipulation References: <78158460-8508-4453-a2dc-c5814dda8839@59g2000hsb.googlegroups.com> Message-ID: On Apr 22, 3:55 pm, DataSmash wrote: > Hello, > > I have a list that looks like this: > roadList = ["Motorways","Local","Arterial"] > > I want to apply some code so that the output looks like this: > "Motorways;Local;Arterial" > > ...in other words, I want each item in the list separated by a ';' and > then the whole thing surrounded by quotes. > > How can this be done with the LEAST amount of code? > > I appreciate your help! > R.D. Well you could always do something like this: output = ';'.join(roadList) Which will put single quotes on the ends. I suppose if you want to be silly, you could do this: output = '"%s"' % ';'.join(roadList) HTH Mike From bronger at physik.rwth-aachen.de Tue Apr 8 16:06:46 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Tue, 08 Apr 2008 22:06:46 +0200 Subject: Coping with cyclic imports Message-ID: <87bq4knmax.fsf@physik.rwth-aachen.de> Hall?chen! I have a rather fat module that represents a document parser -- inline elements, block elements, and the like. Now I want to split it into many modules to make everything more manageable. But at the moment I don't see how to avoid cyclic imports: A document element A, which is represented my module parser.A, may contain the element B, as defined in parser.B. And vice versa. So both modules must import each other, as far as I can see. I know that cyclic imports work in Python under certain circumstances. Can anyone refer me to a page which explains *when* this works? Because at least once, the imported module was not "finished" and thus largely unusual. Thank you! Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From victorsubervi at gmail.com Sat Apr 5 10:32:00 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Sat, 5 Apr 2008 09:32:00 -0500 Subject: Adding Images To MySQL Message-ID: <4dc0cfea0804050732x7dc2ac41n64d56dda9da27a82@mail.gmail.com> >* *(What a mess! I don't know where to begin...) Yeah. Never claimed to be any good at this :( Just persistent :) >* *- You say Content-Type: image/jpeg but you emit HTML code. You're lucky if you see any >* *text at all. Well, I tried Content-Type: text/html and that threw an HTTP 500 Error. >* *- HTTP 200 is not an error, it means the request was successful. When it doesn?t execute the code, how can it be called successful? If it doesn?t execute the code, how can you say it?s not an error? What is it, then? >* *- As a general advice, try to isolate the problems. Test the database stuff alone, in a local >* *application. Test the cgi script alone, without database interaction. Test the database stuff in >* *the web server (better if you have a shell account). Merge all and test again. Very good advice. Please help me understand how to do that. This is what I have done. I have tried these: sql = "'insert into products (" + col_names + ") values (" + val + ")', (" + col_names + ")" cursor.execute(sql) and sql = "'insert into products (" + col_names + ") values (" + val + ")'" cursor.execute(sql, (col_names,)) Neither work. However, if I print what that code spits out: sql = "'insert into products (" + col_names + ") values (" + val + ")', (" + col_names + ")" print sql then copy and paste it into a cursor.execute() statement, viola! Everything works _just_fine_. Go figure. Why?? Incidentally, all that is without using images, and obviously since it posted to the database after copying and pasting, I believe I am dealing only with a python problem. Now, concerning images, this is what I have so far. I put an image on the server, and did this: imgfile=open("1.jpg",'rb') f = imgfile.read() pic1 = _mysql.escape_string(f) It does not like this (forgot error): pic1 = MySQLdb.Binary(f) Escaping the string, I can successfully load this image into the database, along with all the other fields. Now, when I load an image from the form on the previous page with this code: From gagsl-py2 at yahoo.com.ar Sun Apr 6 16:15:49 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 06 Apr 2008 17:15:49 -0300 Subject: Prevent GUI layout from changing? References: Message-ID: En Sun, 06 Apr 2008 15:12:55 -0300, escribi?: I can't help with your sizing problem, I don't know grids. But don't do this: > def Display(self, number): > self.expr = self.expr + number > self.lbText = Label(self, text=self.expr) > self.lbText.grid(row=0, column=0) > > def Calculate(self): > self.expr = str(eval(self.expr))#try catch tex 3+6+ > self.lbText = Label(self, text=self.expr) > self.lbText.grid(row=1, column=1) > self.expr = "" You're creating a *new* Label object for each keystroke (they stack on the same place and only the newest is visible, I presume). Instead, you should change the text inside the existing widget: self.lbText.config(text=self.expr) (there is no need to reposition the widget) Label is described here http://effbot.org/tkinterbook/label.htm and you may want to learn to use Tkinter variables: http://effbot.org/tkinterbook/variable.htm -- Gabriel Genellina From bbxx789_05ss at yahoo.com Sat Apr 5 20:53:46 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sat, 5 Apr 2008 17:53:46 -0700 (PDT) Subject: Tkinter, add pressed buttons onto string display string, how to? References: <57605958-5589-4ebe-abdf-73c2d14c8a82@u10g2000prn.googlegroups.com> <65q8juF2gq610U2@mid.uni-berlin.de> <649d9748-c389-411d-9794-9753ddf434b0@d1g2000pra.googlegroups.com> Message-ID: <195771d1-1bb3-4d62-b9c3-920db5a912ac@y21g2000hsf.googlegroups.com> > > Just like the message says: You are trying to use `str` (on the right hand > > side of the assignment) before anything is bound to that name. > > > Ciao, > > ? ? ? ? Marc 'BlackJack' Rintsch > > i know but i want the variable str(which i found out is a reserved > word so i changed it) to be accessible all over __init__ right? > "all over __init__" ? You could practice with a trivial example to discover how things work in python: def f(): num = 10 print num f() def g(): print num num = 10 g() > so i tried to delcare it in __init__ in the beginning of the framework > class but then when i access it in the method Display i get that > error. > > so how should i declare this variable to be able to access it > everywhere? > You don't declare variables in python. You just start using a variable when you need it. In other words you don't do this: string my_str my_str = "hello" You just write: my_str = "hello" > i want another method "calculate" that can access the same string > later and do the calculations(writing some other code now that will > read and interpret that). Does this look familiar: > Another thing you should be aware of: self is like a class wide > bulletin board. If you are writing code inside a class method, and > there is data that you want code inside another class method to be > able to see, then post the data on the class wide bulletin board, i.e. > attach it to self. ?But in your code, you are doing this: > > self.btnDisplay = Button(self, text="7", default=ACTIVE) > self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > self.btnDisplay = Button(self, text="8", default=ACTIVE) > self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > As a result, your code continually overwrites self.btnDisplay. ?That > means you aren't preserving the data assigned to self.btnDisplay. > Therefore, the data does not need to be posted on the class wide > bulletin board for other class methods to see. ?So just write: > > btnDisplay = Button(self, text="7", default=ACTIVE) > btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > btnDisplay = Button(self, text="8", default=ACTIVE) > btnDisplay.grid(row=5, column=1, padx=5, pady=5) From bbxx789_05ss at yahoo.com Tue Apr 1 19:44:41 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Tue, 1 Apr 2008 16:44:41 -0700 (PDT) Subject: XML Parsing References: Message-ID: <5f1019b7-47e1-4fcf-a00c-b982c6b2fd79@f63g2000hsf.googlegroups.com> On Apr 1, 1:42?pm, Alok Kothari wrote: > Hello, > ? ? ? ? ? I am new to XML parsing.Could you kindly tell me whats the > problem with the following code: > > import xml.dom.minidom > import xml.parsers.expat > document = """Lettermanis token>betterthan token>JayLeno""" > > # 3 handler functions > def start_element(name, attrs): > ? ? print 'Start element:', name, attrs > def end_element(name): > ? ? print 'End element:', name > def char_data(data): > ? ? print 'Character data:', repr(data) > > p = xml.parsers.expat.ParserCreate() > > p.StartElementHandler = start_element > p.EndElementHandler = end_element > p.CharacterDataHandler = char_data > p.Parse(document, 1) > > OUTPUT: > > Start element: token {u'pos': u'nn'} > Character data: u'Letterman' > End element: token > > Traceback (most recent call last): > ? File "C:/Python25/Programs/eg.py", line 20, in > ? ? p.Parse(document, 1) > ExpatError: junk after document element: line 1, column 33 I don't know if you are aware of the BeautifulSoup module: import BeautifulSoup as bs xml = """LettermanisbetterthanJayLeno""" doc = bs.BeautifulStoneSoup(xml) tokens = doc.findAll("token") for token in tokens: for attr in token.attrs: print "%s : %s" % attr print token.string --output:-- pos : nn Letterman pos : bez is pos : jjr better pos : cs than pos : np Jay pos : np Leno From andre.roberge at gmail.com Tue Apr 8 21:39:39 2008 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Tue, 8 Apr 2008 18:39:39 -0700 (PDT) Subject: text adventure game problem References: Message-ID: On Apr 8, 10:25?pm, Andr? wrote: > On Apr 8, 10:01?pm, corvettecra... at gmail.com wrote: > > > > > okay, I'm having this one problem with a text adventure game. It's > > kind of hard to explain, but I'll do my best. > > [code] > > > def prompt_kitchen(): > > ? ? global gold > > ? ? gold_taken = False > > ? ? while True: > > ? ? ? ? prompt_kit = raw_input('>') > > ? ? ? ? if prompt_kit == 'examine cabinet 1' and not gold_taken: > > ? ? ? ? ? ? print '''This cabinet has a lot of cups in it with all > > different > > designs and shapes. Where are the people anyway? How come there's > > nobody here? > > In one of the cups you find 8 gold.''' > > ? ? ? ? ? ? gold = gold+8 > > ? ? ? ? ? ? gold_taken = True > > ? ? ? ? ? ? pass4() > > ? ? ? ? elif prompt_kit == 'examine cabinet 1' and gold_taken: > > ? ? ? ? ? ? print \ > > ? ? ? ? ? ? ? ? ? '''This cabinet has a lot of cups in it with all > > different > > designs and shapes. Where are the people anyway? How come there's > > nobody here?''' > > ? ? ? ? ? ? pass4() > > > def pass4(): > > ? ? global gold > > ? ? print 'You have', gold, 'gold' > > ? ? pass > > [/code] > > > Okay, now for my problem. > > In the above function, there's the option to examine a cabinet and get > > 8 gold. (everyone here knows that...but I'm just trying to state my > > problem...) > > Unfortunately, it kind of doesn't work. > > After the first time I 'examine cabinet 1' in my game, I get 8 gold > > and I can't get it again. > > But, If I leave the room and come back to it, then it's as if I had > > never gotten the gold the first time, and I can get it again. > > How do I fix this? > > quick guess: define gold_taken as a global variable and initialize it > outside of the function. > > Warning: avoid global variables if at all possible. > > ;-) > Andr? Actually, what I would do if I were designing such a game is probably define an object with various states, so that instead of gold_taken, I'd have state.gold_taken_in_cabinet_1 Alternatively, you could define a dict at the beginning with things like gold_taken = {'cabinet 1': False, 'cabinet 2': False, ...} This approach would allow to identify at a glance all relevant game situations rather than having to go through the entire code. Andr? From hopeorpha308 at gmail.com Sun Apr 27 07:47:35 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:47:35 -0700 (PDT) Subject: sony sound forge 9 crack Message-ID: <9fabd8f6-1642-4ad8-b723-e2a1015a9c17@34g2000hsh.googlegroups.com> sony sound forge 9 crack http://wga-cracks.crackkey.net From michael at stroeder.com Mon Apr 14 05:35:27 2008 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Mon, 14 Apr 2008 11:35:27 +0200 Subject: Remote mac address In-Reply-To: References: Message-ID: <54lbd5-dk7.ln1@nb2.stroeder.com> Matias Surdi wrote: > Anyone knows how having the IP address of a host on the lan could I get > the mac address of that hosr? > > p/d: Parsing the output of arp -a is not an option. But the ARP table is exactly what you need to access. This is probably system-specific. You could also try to send ARP requests yourself: http://www.secdev.org/projects/scapy/ http://www.ibm.com/developerworks/aix/library/au-pythocli/ Ciao, Michael. From exarkun at divmod.com Mon Apr 28 12:00:26 2008 From: exarkun at divmod.com (Jean-Paul Calderone) Date: Mon, 28 Apr 2008 12:00:26 -0400 Subject: Receive data from socket stream In-Reply-To: <1939ddb7-fc72-4d45-8c9c-062a1d0db3e4@y21g2000hsf.googlegroups.com> Message-ID: <20080428160026.6859.1551084614.divmod.quotient.56204@ohm> On Mon, 28 Apr 2008 07:26:13 -0700 (PDT), s0suk3 at gmail.com wrote: > [snip] > > >BTW, has anybody used sockets as file-like objects >(client.makefile())? Is it more secure? More efficient? It's not more (or less) secure. In certain cases, it's significantly less efficient. It's for simplicity of programming, not much else. Jean-Paul From wbsoft at xs4all.nl Sat Apr 19 17:19:14 2008 From: wbsoft at xs4all.nl (Wilbert Berendsen) Date: Sat, 19 Apr 2008 23:19:14 +0200 Subject: manipulating class attributes from a decorator while the class is being defined Message-ID: <200804192319.14735.wbsoft@xs4all.nl> Hi, is it possible to manipulate class attributes from within a decorator while the class is being defined? I want to register methods with some additional values in a class attribute. But I can't get a decorator to change a class attribute while the class is still being defined. Something like: class Parser(object): regexps = [] def reg(regexp): def deco(func): regexps.append((regexp, func)) return func return deco @reg(r'".*"') def quoted_string(self): pass How can I reach the class attribute `regexps' from within a decorator? Thanks for any help, Wilbert Berendsen -- http://www.wilbertberendsen.nl/ "You must be the change you wish to see in the world." -- Mahatma Gandhi From Lie.1296 at gmail.com Tue Apr 22 07:50:10 2008 From: Lie.1296 at gmail.com (Lie) Date: Tue, 22 Apr 2008 04:50:10 -0700 (PDT) Subject: Python script to automate use of Google Translate? (or other translator) References: Message-ID: On Apr 21, 8:58 am, Kenneth McDonald wrote: > I have the need to occasionally translate a single word > programatically. Would anyone have a Python script that would let me > do this using Google (or another) translation service? > > Thanks, > Ken Are you sure you want to use Google translation service (or other online translation services) cause you won't be able to translate if you don't have internet. On the other hand, if you're only looking translator for yourself, you could search for some firefox plugins or Google Toolbar. From castironpi at gmail.com Wed Apr 23 16:27:54 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 23 Apr 2008 13:27:54 -0700 (PDT) Subject: print some text References: <7ac7b11d-6c9b-477c-8c0d-b038bc760918@c58g2000hsc.googlegroups.com> Message-ID: On Apr 23, 2:05?pm, barronmo wrote: > I'm a beginner searching for an easy way to print the contents of a > text control. ?So far I've come up with the following(difficulties): > > 1) using wxPython > ? ? ?-convert to HTML and then print (I don't know anything about > HTML) > ? ? ?-use wx.Printout (Seems complicated; may be beyond my abilities) > > 2) create a text file and then print it out (can create but can only > print with the win32api.ShellExecute method so this solution doesn't > help me on my Linus laptop) > > 3) use ReportLab to create .pdf and then print that out (again, can > create but can't print in Linux) > > Thanks for any help. > > Mike Write out an HTML file, write back if you need a quick one, then print that with a browser. From victorsubervi at gmail.com Fri Apr 18 13:06:54 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Fri, 18 Apr 2008 12:06:54 -0500 Subject: Another MySQL Images Question In-Reply-To: <1208533718.4748.16.camel@aalcdl07.lib.unc.edu> References: <4dc0cfea0804180813o32ed2c82o9c3f68b1a607348d@mail.gmail.com> <1208533718.4748.16.camel@aalcdl07.lib.unc.edu> Message-ID: <4dc0cfea0804181006m1811e3c3wcea4dacf68eb8a0d@mail.gmail.com> Thank you. That worked. Victor On Fri, Apr 18, 2008 at 10:48 AM, J. Cliff Dyer wrote: > There are several problems with your SQL, but not all of them would be > caught by the computer. Your SELECT statement is not parameterized. > This is a security problem. *Always* parameterize your variables. Your > UPDATE statement has an extraneous comma at the end, and it also has > quotes around the "%s"es that you don't need, because you already > parameterized that query. Your dbapi interface will provide appropriate > quoting for whatever type of data you pass it. > > Cheers, > Cliff > > > On Fri, 2008-04-18 at 10:13 -0500, Victor Subervi wrote: > > Hi; > > If I grab an image in the database thus: > > > > sql = "select pic1 from products where id='" + str(id) + "';" > > cursor.execute(sql) > > pic1 = cursor.fetchall()[0][0].tostring() > > # pic1 = cursor.fetchall()[0][0] // either this or the above > > line > > > > and try and re-insert it thus: > > > > cursor.execute('update products set pic1="%s" where id="%s", ;', > > (pic1, id)) > > > > it tells me I have an error in my MySQL syntax. What is the error? > > TIA, > > Victor > -- > Oook, > J. Cliff Dyer > Carolina Digital Library and Archives > UNC Chapel Hill > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From glasper9 at yahoo.org.au Fri Apr 25 01:23:36 2008 From: glasper9 at yahoo.org.au (Jason Stokes) Date: Fri, 25 Apr 2008 15:23:36 +1000 Subject: Explicit variable declaration References: <1506f165-7f86-4dc7-aa29-6488eda9ae7f@l64g2000hse.googlegroups.com><5e59998b-d2e7-48cb-824b-84620f95c9bc@w5g2000prd.googlegroups.com> Message-ID: <1209101024.201741@chilli.pcug.org.au> "Filip Gruszczynski" wrote in message news:mailman.89.1209000606.12834.python-list at python.org... >> If you want to just declare that name exist, but doesn't want to >> declare the type, why don't you just do this: >> >> def somefunc(): >> nonlocal = nonlocal >> local = 0 # or None or [] or an initial value >> # >> return nonlocal * local > > Err.. I don't quite get. How it may help me? Could you explain? Hi Filip, In Python the standard patten for "declaring" variables is just to assign to them as they are needed. If you want the effect of a declaration as you would do in C, you can just define the variable and initialize it to 0 or None. (Or {} for a new dictionary, or [] for a new list.) eg, def collaterecs(): recordscount = 0 recordlist = [] ... return recordlist From kamhung.soh at gmail.com Fri Apr 18 07:37:33 2008 From: kamhung.soh at gmail.com (Kam-Hung Soh) Date: Fri, 18 Apr 2008 21:37:33 +1000 Subject: index of list of lists References: <1208398552l.41837l.0l@ns.bitcarrier.eu> Message-ID: On Thu, 17 Apr 2008 12:25:51 +1000, Daniel Fetchinson wrote: >> yes, there's a thread with the same title, but I believe mine is more >> appropriate title. >> so, as much as I search on the web, read manuals, tutorials, mail-lists >> (including this one) I cannot figure it out how to search a string in a >> list of lists. >> like this one: >> >> someList = [['somestring', 1, 2], ['oneother', 2, 4]] >> >> I want to search "somestring" in someList which is in practice a list >> of aprox. 200 lists. (hey, I'm a newbie python programmer, don't judge >> me). >> is the list.index the wrong approach? >> should I use numpy, numarray, something else? >> can anyone, be kind and help me with this? > > someList = [['somestring', 1, 2], ['oneother', 2, 4]] > for alist in someList: > if alist[0] == 'somestring': > print "Found it at index %d" % someList.index( alist ) > # if you know it will only occur once you might say: > break > > HTH, > Daniel See also Section 4.5. Filtering Lists. List comprehension: [x for x in someList if x[0] == 'somestring'] Use filter() function: filter(lambda x: x[0] == 'somestring', someList) -- Kam-Hung Soh Software Salariman From hejibo at gmail.com Sat Apr 12 16:06:55 2008 From: hejibo at gmail.com (He Jibo) Date: Sat, 12 Apr 2008 13:06:55 -0700 (PDT) Subject: [help] how to install pygtk Message-ID: <78e6da3e-767e-470c-9efa-70281eda204f@u69g2000hse.googlegroups.com> Hi, Everyone, Could someone help me how to install pygtk? I get some problems with it. Here is the error I get while install pygtk: https://netfiles.uiuc.edu/jibohe2/error.GIF?uniq=-k6678k I use python 2.4, I first installed glade-2.0.1-win32_with_gtk, and then pycairo-1.0.2-1.win32-py2.4, pygobject-2.12.3-1.win32-py2.4, and pygtk-2.8.6-1.win32-py2.4. Afterwards, I try to setup pygtk-2.8.4, and got the above error. Although I did above operations suggested by the information from the web , I seems that I still do not have pygtk in my computer. I want to run cankiri.py (which relies on pygtk), and still get the following error. cankiri.py is used to record screen video , and could be downloaded at https://netfiles.uiuc.edu/jibohe2/cankiri.py?uniq=-z4xh4m. Thank you so much ! Traceback (most recent call last): File "E:\Program Files\Python2.4\py2exe code \cankiri-0.1\cankiri-0.1\cankiri.py", line 20, in -toplevel- import gtk, gobject File "E:\Program Files\Python2.4\Lib\site-packages\gtk-2.0\gtk \__init__.py", line 45, in -toplevel- from _gtk import * File "E:\Program Files\Python2.4\Lib\site-packages\cairo \__init__.py", line 1, in -toplevel- from _cairo import * ImportError: DLL load failed: The specified procedure could not be found. From larry.bates at websafe.com` Wed Apr 16 14:47:31 2008 From: larry.bates at websafe.com` (Larry Bates) Date: Wed, 16 Apr 2008 13:47:31 -0500 Subject: Default parameter for a method In-Reply-To: <806788d2-67b7-456b-bd1e-08c50cbf0f7b@8g2000hsu.googlegroups.com> References: <806788d2-67b7-456b-bd1e-08c50cbf0f7b@8g2000hsu.googlegroups.com> Message-ID: s0suk3 at gmail.com wrote: > I wanted to know if there's any way to create a method that takes a > default parameter, and that parameter's default value is the return > value of another method of the same class. For example: > > class A: > def __init__(self): > self.x = 1 > > def meth1(self): > return self.x > > def meth2(self, arg=meth1()): > # The default `arg' should would take the return value of > meth1() > print '"arg" is', arg > > This obviously doesn't work. I know I could do > > ... > def meth2(self, arg=None): > if arg is None: > arg = self.meth1() > > but I'm looking for a more straightforward way. You can write this as: def meth2(self, arg=None): arg = arg or self.meth1() IMHO - You can't get much more "straightforward" than that. -Larry From sjmachin at lexicon.net Fri Apr 25 08:46:09 2008 From: sjmachin at lexicon.net (John Machin) Date: Fri, 25 Apr 2008 05:46:09 -0700 (PDT) Subject: problem with unicode References: <26fcc207-b864-42c7-afb3-c6945e5fe29f@m44g2000hsc.googlegroups.com> <67dvg8F2nomm6U1@mid.individual.net> Message-ID: On Apr 25, 10:01 pm, Bjoern Schliessmann wrote: > andreas.prof... at googlemail.com wrote: > > # media is a binary string (mysql escaped zipped file) > > >>>> print media > > x???[? ... > > (works) > > Which encoding, perhaps UTF-8 or ISO8859-1? > > >>>> print unicode(media) > > UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in > > position 1: ordinal not in range(128) > > (ok i guess print assumes you want to print to ascii) > > Not at all -- unicode tries to decode the byte string you gave it, > but doesn't know which encoding to use, so it falls back to ASCII. > > You should decode all "incoming" byte strings to unicode objects > using the right encoding -- here I tried yours with UTF-8. This > works best using string's method "decode" which returns a unicode > object. > > >>> media="x???[?" > >>> print repr(media.decode("utf-8")) > > u'x\u30ef\u30e6\u30ed[\u30e8' > But that_unicode_string.encode("utf-8") produces 'x\xe3\x83\xaf\xe3\x83\xa6\xe3\x83\xad[\xe3\x83\xa8' which does not contain the complained-about byte 0x9c in position 1 (or any other position) -- how can that be? From __peter__ at web.de Fri Apr 4 04:29:56 2008 From: __peter__ at web.de (Peter Otten) Date: Fri, 04 Apr 2008 10:29:56 +0200 Subject: Is there an official way to add methods to an instance? References: Message-ID: Brian Vanderburg II wrote: > I don't know if this is the correct place to send this question. It is. > I've checked out some ways to get this to work. I want to be able to > add a new function to an instance of an object. I've tested two > different methods that cause problems with 'deleting'/garbage collection > (__del__ may never get called), but implemented one sort of hackishly > maybe that works find. I'm wondering if there is more of an official way > than mine. [snip] I think "Try hard to avoid __del__()" is as close to an official stance as you can get ;) Anyway, here is one more option to add too the zoo: >>> class A(object): ... def __init__(self, f, x): ... self._f = f ... self.x = x ... @property ... def f(self): ... return self._f.__get__(self) ... def __del__(self): ... print "deleting" ... >>> a = A(lambda s: s.x * 2, 2) >>> b = A(lambda s: s.x * 3, 3) >>> a.f() 4 >>> b.f() 9 >>> del a deleting >>> del b deleting Peter From cmpython at gmail.com Mon Apr 7 01:05:33 2008 From: cmpython at gmail.com (CM) Date: Sun, 6 Apr 2008 22:05:33 -0700 (PDT) Subject: Learning curve for new database program with Python? References: Message-ID: <521b0a89-8d86-4cc2-8029-4aa731522b34@b1g2000hsg.googlegroups.com> On Apr 5, 11:50 am, Jetus wrote: > I have a need for a database program. I downloaded the db2 from ibm, > and reviewed some of the documentation. > > My question is, what is the easiest program for me to try to learn. I > will be creating a database of about 25,000 records, it will be > relational. I am a beginner Python programmer, and need a database > solution that is easy to grasp. I played with sql, > and found that very difficult, if not overly cumbersome. > > A database that could work with Django would be very interesting to > look at as well.. > > Any suggestions out there? Re: Django...from the Django site: "If you want to use Django with a database, which is probably the case, you'll also need a database engine. PostgreSQL is recommended, because we're PostgreSQL fans, and MySQL, SQLite 3, and Oracle are also supported." Those all use SQL, and really if you are using a relational database, SQL is pretty much what is used. SQL has not struck me as difficult nor cumbersome, e.g., for a database table called "customers" that has a column called "name" and "city": (in SQL): SELECT name FROM customers WHERE city='Chicago' (in partially shouted English): "GIVE ME ALL THE names OF customers WHOSE CITY IS Chicago.") or, in Python 2.5 if you import sqlite3: import sqlite3 conn = sqlite3.connect('C:/Documents and Settings/user/Desktop/ somedatabase.db') cur = conn.cursor() cur.execute("SELECT name FROM customers WHERE city='Chicago'") I've enjoyed using SQLite in Python, and there's some good online documentation to help there. And SQLite, Python, Django all play well together, somehow, AFAIK. From kveretennicov at gmail.com Wed Apr 2 16:12:20 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Wed, 2 Apr 2008 23:12:20 +0300 Subject: Python queue madness In-Reply-To: <28749c0e0804020652o74a9491an9eef9ba1813434fb@mail.gmail.com> References: <28749c0e0804020652o74a9491an9eef9ba1813434fb@mail.gmail.com> Message-ID: <4660fe300804021312v26e0bf86h6f45fd1e305ee0bf@mail.gmail.com> On Wed, Apr 2, 2008 at 4:52 PM, nnp wrote: > > Is there any other way for data to get onto a queue Yes, by manipulating Queue.Queue's internal "queue" attribute directly. > or are there any known bugs with Python's Queue module that could lead to > this kind of behaviour? > Much more likely your code has some unexpected behavior. Could you arrange a minimal example that reproduces the problem? -- kv -------------- next part -------------- An HTML attachment was scrubbed... URL: From hdante at gmail.com Sat Apr 12 11:17:23 2008 From: hdante at gmail.com (hdante) Date: Sat, 12 Apr 2008 08:17:23 -0700 (PDT) Subject: accessing individual characters in unicode strings References: Message-ID: On Apr 12, 9:48 am, Christian Heimes wrote: > Peter Robinson schrieb: > > > Dear list > > I am at my wits end on what seemed a very simple task: > > I have some greek text, nicely encoded in utf8, going in and out of a > > xml database, being passed over and beautifully displayed on the web. > > For example: the most common greek word of all 'kai' (or ??? if your > > mailer can see utf8) > > So all I want to do is: > > step through this string a character at a time, and do something for > > each character (actually set a width attribute somewhere else for each > > character) > > As John already said: UTF-8 ain't unicode. UTF-8 is an encoding similar > to ASCII or Latin-1 but different in its inner workings. A single > character may be encoded by up to 6 bytes. Up to 4 bytes in the latest versions. (the largest value is U+10FFFF and is represented by 0xF4 0x8F 0xBF 0xBF). I believe the proper way for returning the number of characters for Greek would require a normalization first: from unicodedata import normalize def greek_text_length(utf8_string): u = unicode(utf8_string, 'utf-8') u = normalize('NFC', u) return len(u) If there are pairs of characters that count as one, things may be worse. > > I highly recommend Joel's article on unicode: > > The Absolute Minimum Every Software Developer Absolutely, Positively > Must Know About Unicode and Character Sets (No Excuses!)http://www.joelonsoftware.com/articles/Unicode.html > > Christian From landerdebraznpc at gmail.com Mon Apr 28 03:53:10 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:53:10 -0700 (PDT) Subject: vista ultimate crack Message-ID: vista ultimate crack http://crack.cracksofts.com From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 15 05:19:48 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 15 Apr 2008 11:19:48 +0200 Subject: Dynamic use of property() fails In-Reply-To: References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> <480461f8$0$20282$426a34cc@news.free.fr> Message-ID: <4804732e$0$19414$426a34cc@news.free.fr> andrew cooke a ?crit : > On Apr 15, 4:06 am, Bruno Desthuilliers 42.desthuilli... at websiteburo.invalid> wrote: > >> The canonical solution is to use a custom descriptor instead of a property: (snip code) > i tried code very similar after reading the first replies and found > that it did not work as expected on setting. for example, in > > person = Person() > person.age = 27 > > "age" is set in the instance's dictionary (as 27; the descriptor is > not called), which then shadows the definition of age in the class > dictionary. Are you sure your Person class is a new-style one (inheriting, directly or not, from object) ? The descriptor protocol doesn't work properly on old-style classes, with *exactly* the symptom you describe here (setter is not invoked, property get shadowed by an instance attribute) > my understanding was that the descriptor is only called in the class > context, The descriptor protocol is only invoked on class attributes. > so would be called if, say, a subclass tried to redefine > age. but maybe i am still confused. Possibly. > i am about to go to sleep. i guess i will try your code exactly > tomorrow, but it looks very close to mine which showed this problem. > are you sure your solution works? Yes - minus a couple (unrelated) typos ('name' instead of 'self.name' in Field.__set__, and 'self._values = []' instead of 'self._values = {}' in ActiveDAO.__init__). Here's the corrected one: class Field(object): def __init__(self, name, onchange): self.name = name self.onchange = onchange def __get__(self, instance, cls): if instance is None: # called on the class return self # called on instance return instance._values[self.name] def __set__(self, instance, value): instance._values[self.name] = self.onchange(value) class ActiveDAO(object): def __init__(self): self._values = {} class Person(ActiveDAO): name = Field('name', lambda v: v.strip().capitalize()) age = Field('age', lambda v : int(v)) From aguirre.adolfo at gmail.com Mon Apr 28 22:07:52 2008 From: aguirre.adolfo at gmail.com (aguirre.adolfo at gmail.com) Date: Mon, 28 Apr 2008 19:07:52 -0700 (PDT) Subject: Python Math libraries - How to? Message-ID: Hi, I am a very newbie who would very much appreciate some hints. Python 2.52. on Windows XP for now. Soon on Ubuntu 8 I am teaching myself Python following free tutorials. I can solve problems using arithmetic, but when I try to upgrade the programs using math libraries nothing seems to work. I downloaded a 2002 tutorial from Zelle "An Introduction to Computer Science" where he uses a "import math" statement to calculate a square root. I tried the "pi" library function but it didn?t work. I tried using def Pi() it did not work either. I am yet to find a tutorial that explains how to declare (or initialize) and pass numbers to the functions such as "cos(x)" and the pi which does not have a variable in it. Is just a constant. Here is the arithmetic program I made that it worked before I added the "import math" line. I erased the constant p = 3.1416 and added the "i" for the library function "pi" in the algorithms. But I get an error message not recognizing "pi" #volumen.py # A program to compute the volume and surface area of a sphere import math def main(): print "This program calculates the volume and surface area of a sphere" print r = input("Please enter the radious: ") print r3 = r*r*r volume = 4/3*pi*r3 r2 = r*r surface = 4*pi*r2 print "The Volume is", volume, " Cubic centimeters" print print "The Surface area is", surface, " square centimeters" main() *** Error message ************* Traceback (most recent call last): File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 20, in main() File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 13, in main volume = 4/3*pi*r3 NameError: global name 'pi' is not defined From arnodel at googlemail.com Sun Apr 13 02:06:29 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sat, 12 Apr 2008 23:06:29 -0700 (PDT) Subject: class level properties References: Message-ID: <513c5440-5ff0-4642-bc76-cc24d3dfaaa8@u69g2000hse.googlegroups.com> On Apr 13, 12:33?am, Charles D Hixson wrote: > Arnaud Delobelle wrote: > >>>> class MetaX(type): > > > ... ? ? @property > > ... ? ? def spam(self): return 'eggs' > > ... > > >>>> class X(object): > > > ... ? ? ?__metaclass__ = MetaX > > ... > > >>>> X.spam > > > 'eggs' > > > HTH > > > -- > > Arnau > > Thanks. ?I can make that work. ?Is it possible to move the entire > implementation of the interpretation of ?_valueMap, below, into > properties in some similar way? ?I'm referring to the part managed by > __getattr__ below. > I want a hundred or so read-only variables, and I'm not sure the best > way to achieve it. [snip code sample] * Do you want to be able to access your attributes from instances as well or from the class object only? The metaclass trick creates attributes only accessible from the class object, i.e. in my example above: >>> x=X() >>> x.spam Traceback (most recent call last): File "", line 1, in AttributeError: 'X' object has no attribute 'spam' * If you have a hundred of so names and values, are you sure you want to expose them as attributes? It seems to me that they should be in their own namespace (as keys in a mapping or attributes of a subobject) -- Arnaud From dolloffdelvpg at gmail.com Wed Apr 16 08:07:05 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:07:05 -0700 (PDT) Subject: taylor swift concert dates Message-ID: <19bea8be-033e-4fed-b33a-3d2401d58cac@k1g2000prb.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 29 05:03:54 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 29 Apr 2008 11:03:54 +0200 Subject: Given a string - execute a function by the same name In-Reply-To: References: Message-ID: <4816e474$0$15296$426a74cc@news.free.fr> python at bdurham.com a ?crit : > I'm parsing a simple file and given a line's keyword, would like to call > the equivalently named function. > > There are 3 ways I can think to do this (other than a long if/elif > construct): > > 1. eval() > > 2. Convert my functions to methods and use getattr( myClass, "method" ) > > 3. Place all my functions in dictionary and lookup the function to be > called > 4. Place all your functions in a module and use getattr(the_module, "func") 5. use globals().get("func") > Any suggestions on the "best" way to do this? #1 is the worst possible solution, and #2 doesn't make sens if you don't need methods. #4 is simple but can be problematic since these functions are not necessarily related enough to make for a module with hi cohesion and low coupling. #5 is the simplest solution, but can be dangerous, since just any function in the global namespace (which includes the builtins...) can be called. #3 is a bit heaviest to setup and maintain, but much more secure since you explicitely choose the availables functions. Depending on the context (ie: where this 'simple file' comes from), I'd choose #3 or #5. My 2 cents... From darcy at druid.net Tue Apr 29 15:39:30 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Tue, 29 Apr 2008 15:39:30 -0400 Subject: Colors for Rows In-Reply-To: <1209495803.5173.11.camel@aalcdl07.lib.unc.edu> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> <20080429121105.f10c3862.darcy@druid.net> <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> <1209495803.5173.11.camel@aalcdl07.lib.unc.edu> Message-ID: <20080429153930.a6eddea6.darcy@druid.net> On Tue, 29 Apr 2008 15:03:23 -0400 "J. Cliff Dyer" wrote: > Or, if you aren't sure how many colors you'll be using, try the more > robust: > > bg[z % len(bg)] Good point although I would have calculated the length once at the start rather than each time through the loop. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From sn at sncs.se Thu Apr 17 04:41:30 2008 From: sn at sncs.se (Sverker Nilsson) Date: Thu, 17 Apr 2008 01:41:30 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> Message-ID: On Apr 17, 12:02 am, Carl Banks wrote: > On Apr 16, 12:40 pm, Aaron Watters wrote: > > > > > On Apr 16, 12:27 pm, Rhamphoryncus wrote: > > > > On Apr 16, 6:56 am, Aaron Watters wrote: > > > > > I don't get it. It ain't broke. Don't fix it. > > > > So how would you have done the old-style class to new-style class > > > transition? > > > I'd ignore it. I never understood it and never had > > any need for it anyway. New-style classes and metaclasses > > were a complicated solution to an unimportant problem in > > my opinion. And also a fiendish way to make code > > inscrutible -- which I thought was more of a Perl thing > > than a Python thing, or should be. > > > I must be missing some of the deeper issues here. Please > > educate me. > > The deeper issue is that you're benefiting from these "unimportant" > changes even if you never use them yourself. > > Carl Banks That just seems a BIT categorical for a statement. Who is 'you'? I don't see I benefit from any important or unimportant features in py3k. External libraries I rely on, I can benefit from --- But it would take SOME while to get those libraries ported to py3k, if ever. And I have been benefiting from Python in general, so far. Thanks, community. But now... I'll probably stop posting here for now, & I may stop other things too. Just my 2c. Sverker From tjreedy at udel.edu Wed Apr 9 00:09:37 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 9 Apr 2008 00:09:37 -0400 Subject: text adventure game problem References: Message-ID: wrote in message news:cea9f806-a85d-4187-ac93-4f876a1be39c at l64g2000hse.googlegroups.com... | In the above function, there's the option to examine a cabinet and get | 8 gold. (everyone here knows that...but I'm just trying to state my | problem...) | Unfortunately, it kind of doesn't work. | After the first time I 'examine cabinet 1' in my game, I get 8 gold | and I can't get it again. | But, If I leave the room and come back to it, then it's as if I had | never gotten the gold the first time, and I can get it again. | How do I fix this? I would define a container class. The init function gives it a name and contents (8 gold, for instance). Give kitchen a container('cabinet', 8). Give containers a .examine() method which gives the contents to the player. and a message which varies with the contents. You can even make some container 'refreshable' if you want. tjr From v.harishankar at gmail.com Wed Apr 23 07:17:03 2008 From: v.harishankar at gmail.com (Harishankar) Date: Wed, 23 Apr 2008 16:47:03 +0530 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: <811891.72800.qm@web39208.mail.mud.yahoo.com> References: <811891.72800.qm@web39208.mail.mud.yahoo.com> Message-ID: <200804231647.03614.v.harishankar@gmail.com> On Wednesday 23 Apr 2008 15:11:21 Ben Kaplan wrote: > I don't know about all Linux distros, but my Ubuntu machine (8.04 Beta), > has the 'TERM' (xterm) and 'COLORTERM' (gnome-terminal) keys in os.environ. > You might be able to use that to ensure that the terminal is installed, but > you should probably look at a couple of other popular distros first to make > sure that the key is there. This is set on Debian too. Thanks. I should be able to use this environment variable on most Linux distributions, I suspect. -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org From mensanator at aol.com Wed Apr 16 13:42:40 2008 From: mensanator at aol.com (Mensanator) Date: Wed, 16 Apr 2008 10:42:40 -0700 (PDT) Subject: vary number of loops References: Message-ID: <86c2ba05-d83d-44a3-b044-6daa90b4d3f7@b64g2000hsa.googlegroups.com> On Apr 16, 8:31?am, nullgr... at gmail.com wrote: > Hi everyone, > > I'm new to Python and the notion of lambda, and I'm trying to write a > function that would have a varying number of nested for loops > depending on parameter n. This just smells like a job for lambda for > me, but I can't figure out how to do it. Any hint? > > For example, for n=2, I want the function to look something like: > > def foo(2) > ? ?generate 2 sets of elements A, B > ? ?# mix elements by: > ? ?for a_elt in A > ? ? ? for b_elt in B > ? ? ? ? ?form all combinations of them > > If n=3, I want to have 3 sets of elements and mix them up using 3 for > loops. > > Any help is greatly appreciated, > > nullgraph There's always the stupid way: def ooloop6(a, n, perm=True, repl=True): if (not repl) and (n>len(a)): return r0 = range(n) r1 = r0[1:] if perm and repl: # permutations with replacement v = ','.join(['c%s' % i for i in r0]) f = ' '.join(['for c%s in a' % i for i in r0]) e = ''.join(["p = [''.join((",v,")) ",f,"]"]) exec e return p if (not perm) and repl: # combinations with replacement v = ','.join(['c%s' % i for i in r0]) f = ' '.join(['for c%s in a' % i for i in r0]) i = ' and '.join(['(c%s>=c%s)' % (j,j-1) for j in r1]) e = ''.join(["p = [''.join((",v,")) ",f," if ",i,"]"]) exec e return p if perm and (not repl): # permutaions without replacement v = ','.join(['c%s' % i for i in r0]) f = ' '.join(['for c%s in a' % i for i in r0]) i = ' and '.join([' and '.join(['(c%s!=c%s)' % (j,k) for k in range(j)]) for j in r1]) e = ''.join(["p = [''.join((",v,")) ",f," if ",i,"]"]) exec e return p if (not perm) and (not repl): # combinations without replacement v = ','.join(['c%s' % i for i in r0]) f = ' '.join(['for c%s in a' % i for i in r0]) i = ' and '.join(['(c%s>c%s)' % (j,j-1) for j in r1]) e = ''.join(["p = [''.join((",v,")) ",f," if ",i,"]"]) exec e print '\n\n',e,'\n\n' return p a = 'abcdefghij' n = 6 # for lotto use Combinations without Replacement p = ooloop6(a,n,False, False) ################################################################## Here's the code that gets executed: ## p = [''.join((c0,c1,c2,c3,c4,c5)) for c0 in a ## for c1 in a for c2 in a for c3 in a for c4 in a ## for c5 in a if (c1>c0) and (c2>c1) and (c3>c2) ## and (c4>c3) and (c5>c4)] From hypocrite at lawyer.com Wed Apr 16 03:50:49 2008 From: hypocrite at lawyer.com (Pete Crite) Date: Wed, 16 Apr 2008 17:50:49 +1000 Subject: Python crashes consistently Message-ID: Hello, I've been trying to install Gnumeric via MacPorts recently, but I can't get past the installation of py25-numpy. It appears that python crashes consistently during installation. I'm not sure if this is related to python itself, but I just thought I'd ask here, just in case anyone else was aware of this problem. I did have a few problems during the installation, so perhaps it might be related to them? Is there anyway to check that my installation of python is valid? I'm using OS X 10.4.11 on a Mac Mini PPC. I have attached the error messages from the terminal and the mac pop-up window from the crash. Any help would be very much appreciated! Cheers, Pete. The terminal says: > Error: Target org.macports.build returned: shell command " cd "/opt/ > local/var/macports/build/ > _opt_local_var_macports_sources_rsync.macports.org_release_ports_pytho > n_py25-numpy/work/numpy-1.0.4" && /opt/local/bin/python2.5 setup.py > config_fc --fcompiler g95 --f77exec /opt/local/bin/g95 --f90exec / > opt/local/bin/g95 build " returned error 139 > Command output: Running from numpy source directory. > > Error: The following dependencies failed to build: py25-gtk py25- > cairo py25-numpy > Error: Status 1 encountered during processing. > The crash window that pops up says: > Date/Time: 2008-03-30 11:30:33.545 +1100 > OS Version: 10.4.11 (Build 8S165) > Report Version: 4 > > Command: python2.5 > Path: /opt/local/bin/python2.5 > Parent: sh [247] > > Version: ??? (???) > > PID: 248 > Thread: 0 > > Exception: EXC_BAD_ACCESS (0x0001) > Codes: KERN_INVALID_ADDRESS (0x0001) at 0x82008000 > > Thread 0 Crashed: > 0 _random.so 0x00571334 random_seed + 644 > (_randommodule.c:297) > 1 _random.so 0x0057131c random_seed + 620 > (_randommodule.c:292) > 2 libpython2.5.dylib 0x002b1788 PyEval_EvalFrameEx + 17604 > (ceval.c:3573) > 3 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 > (ceval.c:2836) > 4 libpython2.5.dylib 0x002b19ac PyEval_EvalFrameEx + 18152 > (ceval.c:3669) > 5 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 > (ceval.c:2836) > 6 libpython2.5.dylib 0x0023969c function_call + 332 > (funcobject.c:524) > 7 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: > 1862) > 8 libpython2.5.dylib 0x0021960c instancemethod_call + 764 > (classobject.c:2520) > 9 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: > 1862) > 10 libpython2.5.dylib 0x0026e81c slot_tp_init + 72 (typeobject.c: > 4944) > 11 libpython2.5.dylib 0x00273f88 type_call + 664 (typeobject.c:436) > 12 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: > 1862) > 13 libpython2.5.dylib 0x002b2fc8 PyEval_EvalFrameEx + 23812 > (ceval.c:3786) > 14 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 > (ceval.c:2836) > 15 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) > 16 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 > (import.c:676) > 17 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 > (import.c:960) > 18 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: > 2401) > 19 libpython2.5.dylib 0x002cd7d4 load_next + 300 (import.c:2221) > 20 libpython2.5.dylib 0x002cde8c import_module_level + 624 > (import.c:2002) > 21 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 > (import.c:2072) > 22 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 > (bltinmodule.c:49) > 23 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: > 1862) > 24 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + > 276 (ceval.c:3443) > 25 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 > (ceval.c:2067) > 26 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 > (ceval.c:2836) > 27 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) > 28 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 > (import.c:676) > 29 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 > (import.c:960) > 30 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: > 2401) > 31 libpython2.5.dylib 0x002cd828 load_next + 384 (import.c:2225) > 32 libpython2.5.dylib 0x002cde8c import_module_level + 624 > (import.c:2002) > 33 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 > (import.c:2072) > 34 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 > (bltinmodule.c:49) > 35 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: > 1862) > 36 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + > 276 (ceval.c:3443) > 37 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 > (ceval.c:2067) > 38 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 > (ceval.c:2836) > 39 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) > 40 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 > (import.c:676) > 41 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 > (import.c:960) > 42 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: > 2401) > 43 libpython2.5.dylib 0x002cd7d4 load_next + 300 (import.c:2221) > 44 libpython2.5.dylib 0x002cde8c import_module_level + 624 > (import.c:2002) > 45 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 > (import.c:2072) > 46 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 > (bltinmodule.c:49) > 47 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: > 1862) > 48 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + > 276 (ceval.c:3443) > 49 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 > (ceval.c:2067) > 50 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 > (ceval.c:2836) > 51 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) > 52 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 > (import.c:676) > 53 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 > (import.c:960) > 54 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: > 2401) > 55 libpython2.5.dylib 0x002cdb68 ensure_fromlist + 552 (import.c: > 2312) > 56 libpython2.5.dylib 0x002ce03c import_module_level + 1056 > (import.c:2038) > 57 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 > (import.c:2072) > 58 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 > (bltinmodule.c:49) > 59 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: > 1862) > 60 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + > 276 (ceval.c:3443) > 61 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 > (ceval.c:2067) > 62 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 > (ceval.c:2836) > 63 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) > 64 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 > (import.c:676) > 65 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 > (import.c:960) > 66 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: > 2401) > 67 libpython2.5.dylib 0x002cd7d4 load_next + 300 (import.c:2221) > 68 libpython2.5.dylib 0x002cde8c import_module_level + 624 > (import.c:2002) > 69 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 > (import.c:2072) > 70 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 > (bltinmodule.c:49) > 71 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: > 1862) > 72 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + > 276 (ceval.c:3443) > 73 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 > (ceval.c:2067) > 74 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 > (ceval.c:2836) > 75 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) > 76 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 > (import.c:676) > 77 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 > (import.c:960) > 78 libpython2.5.dylib 0x002ccf20 load_package + 336 (import.c:1015) > 79 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: > 2401) > 80 libpython2.5.dylib 0x002cd7d4 load_next + 300 (import.c:2221) > 81 libpython2.5.dylib 0x002cdec0 import_module_level + 676 > (import.c:2009) > 82 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 > (import.c:2072) > 83 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 > (bltinmodule.c:49) > 84 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: > 1862) > 85 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + > 276 (ceval.c:3443) > 86 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 > (ceval.c:2067) > 87 libpython2.5.dylib 0x002b1924 PyEval_EvalFrameEx + 18016 > (ceval.c:3660) > 88 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 > (ceval.c:2836) > 89 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) > 90 libpython2.5.dylib 0x002d8444 PyRun_FileExFlags + 288 > (pythonrun.c:1274) > 91 libpython2.5.dylib 0x002d87fc PyRun_SimpleFileExFlags + 840 > (pythonrun.c:879) > 92 libpython2.5.dylib 0x002e9b74 Py_Main + 3184 (main.c:523) > 93 python2.5 0x000019d8 _start + 760 > 94 python2.5 0x000016dc start + 48 > > Thread 0 crashed with PPC Thread State 64: > srr0: 0x0000000000571334 srr1: > 0x000000000000d030 vrsave: 0x0000000000000000 > cr: 0x44244228 xer: 0x0000000000000004 lr: > 0x000000000057131c ctr: 0x0000000000000001 > r0: 0x0000000080000000 r1: 0x00000000bfff80a0 r2: > 0x00000000a0001fac r3: 0x0000000002008000 > r4: 0x0000000002008000 r5: 0x0000000000000000 r6: > 0x00000000bfff7fbc r7: 0x00000000000fdff8 > r8: 0x0000000001800400 r9: 0x000000000000000a r10: > 0x000000000000000a r11: 0x000000000000003f > r12: 0x000000009000661c r13: 0x00000000ffffffff r14: > 0x000000000000ccac r15: 0x00000000000c6930 > r16: 0x00000000000c9090 r17: 0x0000000000000000 r18: > 0x000000000031bf48 r19: 0x0000000000627b04 > r20: 0x00000000005710c4 r21: 0x0000000001858010 r22: > 0x000000000000d248 r23: 0x0000000001803814 > r24: 0x0000000002008000 r25: 0x0000000040000000 r26: > 0x0000000020000001 r27: 0x0000000000000000 > r28: 0x000000000004c0c0 r29: 0x000000000004c0c0 r30: > 0x0000000044244228 r31: 0x00000000005710c4 > > Binary Images Description: > 0x1000 - 0x1fff python2.5 /opt/local/bin/python2.5 > 0xe2000 - 0xe5fff strop.so /opt/local/lib/python2.5/lib- > dynload/strop.so > 0xf2000 - 0xf3fff math.so /opt/local/lib/python2.5/lib- > dynload/math.so > 0x205000 - 0x31afff libpython2.5.dylib /opt/local/lib/ > libpython2.5.dylib > 0x565000 - 0x567fff binascii.so /opt/local/lib/python2.5/lib- > dynload/binascii.so > 0x570000 - 0x571fff _random.so /opt/local/lib/python2.5/lib- > dynload/_random.so > 0x8fe00000 - 0x8fe52fff dyld 46.16 /usr/lib/dyld > 0x90000000 - 0x901bcfff libSystem.B.dylib /usr/lib/libSystem.B.dylib > 0x90214000 - 0x90219fff libmathCommon.A.dylib /usr/lib/system/ > libmathCommon.A.dylib > 0x945e0000 - 0x94600fff libmx.A.dylib /usr/lib/libmx.A.dylib > > Model: PowerMac10,1, BootROM 4.8.9f1, 1 processors, PowerPC G4 > (1.2), 1.25 GHz, 1 GB > Graphics: ATI Radeon 9200, ATY,RV280, AGP, 32 MB > Memory Module: DIMM0/J11, 1 GB, DDR SDRAM, PC3200U-30330 > Modem: Jump, V.92, Version 1.0 > Network Service: Built-in Ethernet, Ethernet, en0 > Parallel ATA Device: ST940110A, 37.26 GB > Parallel ATA Device: MATSHITACD-RW CW-8124 > USB Device: Hub in Apple Pro Keyboard, Mitsumi Electric, Up to 12 > Mb/sec, 500 mA > USB Device: PS/2+USB Mouse, Up to 1.5 Mb/sec, 100 mA > USB Device: C-Media USB Headphone Set, Up to 12 Mb/sec, 100 mA > USB Device: Apple Pro Keyboard, Mitsumi Electric, Up to 12 Mb/sec, > 250 mA > From http Mon Apr 21 18:20:33 2008 From: http (Paul Rubin) Date: 21 Apr 2008 15:20:33 -0700 Subject: sys.maxint in Python 3 References: Message-ID: <7xod82df4e.fsf@ruckus.brouhaha.com> bearophileHUGS at lycos.com writes: > In some algorithms a sentinel value may be useful, so for Python 3.x Better to just use object() to generate sentinels. From python.list at tim.thechases.com Sat Apr 5 20:08:19 2008 From: python.list at tim.thechases.com (Tim Chase) Date: Sat, 05 Apr 2008 19:08:19 -0500 Subject: while-loops enter the last time after condition is filled? In-Reply-To: References: Message-ID: <47F81473.3050503@tim.thechases.com> > it seems to me from my results that when i use a while-loop it > will execute once after the condition is met. Nope. > ie the conditions is met the code executes one time more and > then quits. Must be that your conditional is wrong, or your conditions are not updated the way you think they are. -tkc From steve at holdenweb.com Sun Apr 20 14:31:29 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 20 Apr 2008 14:31:29 -0400 Subject: Any reliable obfurscator for Python 2.5 In-Reply-To: <480b6133$0$34498$742ec2ed@news.sonic.net> References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> <480b6133$0$34498$742ec2ed@news.sonic.net> Message-ID: <480B8C01.1080306@holdenweb.com> JB "My first post on c.l.py" Stern wrote: > Banibrata Dutta wrote: >>> Wanted to check if there is any known, reliable, FOSS/Libre -- Obfurscator >>> for Python 2.5 code. > > No, sadly, there is not. There are a number of applications I would be > working on if it were possible to obfuscate pyc files. About the best > you can do as of 2008/04 is use Jython to compile into Java bytecode and > obfuscate that using Proguard. > > Steve 'not an economics major' Holden wrote: >> The Python world isn't particularly paranoid about obfuscation. It's >> quite easy to publish compiled code only (.pyc and/or .pyo files), and >> that offers enough protection for most. > > Curious Steve, how do you pay the rent and by what authority do you > speak for "The Python world"? Your opinion couldn't be more wrong for > programmers like myself who live by the code they write (as opposed to > its support). > I pay the mortgage by creating software systems, though not usually packaged systems for shrink-wrap sale. I don't claim to speak *for* the whole Python world, but as chairman of the Python Software Foundation and a long-time member of this mailing list I can probably claim to be more closely in touch with it than many--yourself included, apparently. If it's important to you to be able to obfuscate your code then you have made an inapposite choice of language. > Steve 'not a software consultant' Holden wrote: >> The sad fact is that there seems to be an almost direct inverse >> correlation between the worth of the code and the authors' desire to >> protect it from piracy. > > Would love to see some evidence to that effect. > That is just an observation based on the many similar posts that have been made on this list, not one of them coming from the author of a recognized software package, plus forty years experience in the software industry. The ripping of of source code is far less frequent that novice programmers believe. The code that novice programmers write is almost always less valuable than they believe. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From smithy at hotmail.com Mon Apr 14 09:40:02 2008 From: smithy at hotmail.com (smithy at hotmail.com) Date: Mon, 14 Apr 2008 14:40:02 +0100 (BST) Subject: A Question Message-ID: <200804141340.CBB79947@manxnetsf02.manx.net> Werdle? From elbertlev at hotmail.com Sun Apr 13 20:21:29 2008 From: elbertlev at hotmail.com (Lev Elbert) Date: Sun, 13 Apr 2008 17:21:29 -0700 (PDT) Subject: email module windows and suse References: <0j35041u36l70vhmov0uvfmv8ftp5npp2i@4ax.com> Message-ID: <25696d24-b989-4555-8cd6-b0c95553829d@r9g2000prd.googlegroups.com> On Apr 13, 3:55?pm, Tim Roberts wrote: > Lev Elbert wrote: > > >I have to make a custom email module, based on the standard one. The > >custom module has to be able to work with extremely large mails (1GB > >+), having memory "footprint" much smaller. > > Then you have a design problem right from the start. ?It is extremely rare > to find a mail server today that will transmit email messages larger than a > few dozen megabytes. ?Even on a 100 megabit network, it's takes a minute > and a half for a 1GB message to go from the server to the user's > workstation. > > What are you really trying to do here? ?In most cases, you would be better > off storing your attachments on a web server and transmitting links in the > email. > > >The modified program has to work in SUSE environment, while the > >development is done under Windows. ?I'm not too good with linux and do > >not know if speedup in Windows translates one-to-one into speedup in > >SUSE. For example, if the bottleneck is IO, in windows I can spawn a > >separate thread or 2 to do "read-ahead". > > We would need more information on your processing to advise you on this. > Disk I/O is slow, network I/O is slower. ?You can't go any faster than your > slowest link. > > >Are threads available and as effective in SUSE as they are in Windows? > > Threads are available in Linux. ?There is considerable debate over the > relative performace improvement. > -- > Tim Roberts, t... at probo.com > Providenza & Boekelheide, Inc. Thank you. I have a 100mb mail file. I just made a very simple expiremnt the message_from_file method boils down to a loop: 1 while True: 2 data = fp.read(block_size) 3 if not data: 4 break 5 feedparser.feed(data) 6 Total time is 21 seconds (lines 1-6), while processing (non IO) lines 3-5 is 20 seconds. This means, that no IO optimization would help. This also explains the following fact: changing the block_size from 8K to 1M has almost no processing time impact. Also multithreading wouldn't help. I beleive I have to change Message class (more exactly: derive another class, which would store pieces on a disk. From lee.walczak at gmail.com Fri Apr 4 18:58:26 2008 From: lee.walczak at gmail.com (lee.walczak at gmail.com) Date: Fri, 4 Apr 2008 15:58:26 -0700 (PDT) Subject: Importing a 3rd Party windows DLL for use within th Python Message-ID: <92513305-836d-4c85-aeb8-3e3d6571ed92@1g2000prg.googlegroups.com> Hi, I have recently started learing how to code/script in Python which I am realy enjoying. I am new to this game as my background is RF/HW design engineer so coding is not my first skillset , so please bare with me! I am a little lost with how to procede on this problem. I need to write a python script enabling me to comunnicate routines to a pico ADC212 oscilloscope. I have been provided with a windows DLL & a header filefrom the manufacturer. Is it possible for someone to provide the information on the steps necessary to access this DLL and treat it like any other pyd library? Maybe there is already a tutorial available for performing this task? Is this task straight forward? Look forward to 'a' response! B.Regards, Lee Feel free to request more information if you feel it is necessary. From hobgoodoreneyhb at gmail.com Tue Apr 22 11:44:11 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:44:11 -0700 (PDT) Subject: the pumpkin patch Message-ID: <7ff8cf39-d231-4110-8aa7-e419f4f960a0@l64g2000hse.googlegroups.com> the pumpkin patch http://cracks.12w.net F R E E C R A C K S From dj3vande at csclub.uwaterloo.ca.invalid Wed Apr 2 16:52:10 2008 From: dj3vande at csclub.uwaterloo.ca.invalid (dj3vande at csclub.uwaterloo.ca.invalid) Date: Wed, 2 Apr 2008 20:52:10 +0000 (UTC) Subject: Recursive function won't compile References: Message-ID: In article , wrote: (Subject: Recursive function won't compile) >#include >#include > >def RecursiveFact(n): >......but yet it still gives the right answer. How is this possible? Possibly because it gives the right answer in a different language than it fails to compile in? dave -- Dave Vandervies dj3vande at eskimo dot com A violent rewrite could produce something worthwhile; as it is you need enough experience to not need the book to be able to read it. Well, that makes sense to me, anyhow. --CBFalconer in comp.lang.c From gabriel.rossetti at mydeskfriend.com Fri Apr 25 10:38:48 2008 From: gabriel.rossetti at mydeskfriend.com (Gabriel Rossetti) Date: Fri, 25 Apr 2008 16:38:48 +0200 Subject: why does the following with Queue, q.put('\x02', True) not put it in the queue? Message-ID: <4811ECF8.2020307@mydeskfriend.com> Hello, I'm having some trouble with the Queue class, for some reason, if I do this (ch == ) : q = Queue.Queue(0) repr(ch) q.put(ch, True) len(q.queue) where the output is : '\x02' 0 why isn't the character/string being put it in the queue? Thank you, Gabriel From markjreed at gmail.com Thu Apr 17 15:00:22 2008 From: markjreed at gmail.com (Mark Reed) Date: Thu, 17 Apr 2008 12:00:22 -0700 (PDT) Subject: Tidy module? Message-ID: Is there an easy_installable egg with an interface to libtidy? I found ?Tidy, but it looks like an inactive project, with no updates since 2004, so I'm skeptical of its reliability. I found mxTidy, but it's only available as part of some larger distribution, and I don't want to replace my Python installation. Is there one out there that I missed? Preferably, it'd be a single module I can drop into my current Python 2.5 installation, ideally via easy_install, to get tidy functionality without having to resort to os.popen("tidy"). Thanks in advance for any pointers. From mmanns at gmx.net Sun Apr 27 13:07:28 2008 From: mmanns at gmx.net (Martin Manns) Date: Sun, 27 Apr 2008 19:07:28 +0200 Subject: ANN: pyspread 0.0.4 References: Message-ID: On Sun, 27 Apr 2008 05:21:56 +0200 Martin Manns wrote: > The newest version pyspread 0.0.4 now runs on > + GTK > + Windows > + Mac (not tested myself but got positive reports) > > New features in 0.0.4: > + Column, line and table insertion and deletion > + Themeable toolbar I forgot to post the short description and the link: pyspread is a spreadsheet that accepts a pure python expression in each cell. Highlights: + No non-python syntax add-ons + Access to python modules from cells + 3D grid + Numpy object array for representation of string entry into grid cell + Numpy object array for representation of eval function array + Cell access via slicing of numpy function array + X, Y, and Z yield current cell location for relative reference Requires: Python >=2.4, Numpy 1.0.4, and wxPython 2.8.7.1. License: GPL Project page: http://pyspread.sourceforge.net Best Regards Martin From james at reggieband.com Thu Apr 17 18:11:40 2008 From: james at reggieband.com (james at reggieband.com) Date: Thu, 17 Apr 2008 15:11:40 -0700 (PDT) Subject: Request a short code review References: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> Message-ID: > I am not necessarily looking to make the code shorter or more > functional or anything in particular. However if you spot something > to improve then I am happy to learn. To give an example of what I mean I have already altered the code: def output_random_lesson_of_type(self, type=None): """Output a lesson of a specific type. If no type is passed in then output any type.""" output_lessons = self.lesson_data["lessons"] if type: filtered_lessons = filter(lambda x: x["type"] == type, self.lesson_data["lessons"]) if filtered_lessons: output_lessons = filtered_lessons else: print "Unable to find lessons of type %s." % type return self.output_random(output_lessons) Changes: - Respected a column width of 80 - Created the output_lessons variable, assigned it to a default. This remove an else statement and reduced the call to self.output_random to a single instance in the return statement Cheers, James From victorsubervi at gmail.com Thu Apr 10 13:04:43 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 10 Apr 2008 12:04:43 -0500 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> <47FCF421.6000807@holdenweb.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> Message-ID: <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> Well, what I did was this: content = col_fields[0][14].tostring() pic = "tmp" + str(i) + ".jpg" img = open(pic, "w") img.write(content) print '

' % pic img.close() where I am incrementing i. Ugly. Stupid. But if it is the only way to do it in python, and I do not want to invest the time doing it in php, which I think would be prettier in this instance, then I guess it will do. Your thoughts appreciated. Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From http Fri Apr 4 05:23:36 2008 From: http (Paul Rubin) Date: 04 Apr 2008 02:23:36 -0700 Subject: Is there an official way to add methods to an instance? References: Message-ID: <7xve2yas87.fsf@ruckus.brouhaha.com> Brian Vanderburg II writes: > I've checked out some ways to get this to work. I want to be able to > add a new function to an instance of an object. Ugh. Avoid that if you can. But see: http://en.wikipedia.org/wiki/Monkey_patch From gagsl-py2 at yahoo.com.ar Mon Apr 21 19:54:29 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 20:54:29 -0300 Subject: how to pass C++ object to another C++ function via Python function References: <1810b155-5598-4f17-a8e9-e4aa848db5de@i36g2000prf.googlegroups.com> Message-ID: En Mon, 21 Apr 2008 19:11:31 -0300, grbgooglefan escribi?: > On Apr 21, 10:17?pm, "Gabriel Genellina" > wrote: >> En Mon, 21 Apr 2008 10:24:15 -0300, grbgooglefan >> escribi?: >> >> > I am trying to pass a C++ object to Python function. This Python >> > function then calls another C++ function which then uses this C++ >> > object to call methods of that object's class. >> >> > I tried something like this, but it did not work, gave core dump. >> >> You can't pass any arbitrary C object to a Python function. >> In this case you can use a PyCObject, a Python box around a void* >> pointer. >> Seehttp://docs.python.org/api/cObjects.html > > Yup, I looked at http://www.python.org/doc/ext/using-cobjects.html > also. I could not find in this example where is CObject used or > converted back from Python to C. > Is there any tutorial which I can use for this? If you have a C function that receives a PyCObject, just include the relevant headers (cobject.h) and you can retrieve the original pointer using PyCObject_AsVoidPtr: void foo(PyObject *pyobj) { TOriginalType *porig; porig = (TOriginalType *)PyCObject_AsVoidPtr(pyobj); // do something with porig } -- Gabriel Genellina From medin0065 at gmail.com Sun Apr 20 10:48:02 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:48:02 -0700 (PDT) Subject: silverfall patch Message-ID: <69808366-68c4-4914-804d-a1d239c49445@w4g2000prd.googlegroups.com> silverfall patch http://cracks.00bp.com F R E E C R A C K S From fredrik at pythonware.com Sat Apr 5 12:08:16 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 18:08:16 +0200 Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! In-Reply-To: <8e6e67e8-979a-4515-be7c-16acdf687ce4@u36g2000prf.googlegroups.com> References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <65ondkF2g48puU2@mid.uni-berlin.de> <8e6e67e8-979a-4515-be7c-16acdf687ce4@u36g2000prf.googlegroups.com> Message-ID: skanemupp at yahoo.se wrote: > i dont know, i used a piece of code i found which had a createwidgets- > method. isnt init a function, not a method btw(or it is the same > thing?) a method is a function defined inside a class statement, and which is designed to be called via an instance of that class. def function(): print "this is a function" def Class: def method(self): print "this is a method" function() # calls a function obj = Class() # create an instance (call __init__ if present) obj.method() # calls a method __init__ is automatically called when Python creates a new instance. if you create the widgets inside the init method or inside a separate method that's called from the init method (or from the outside) is up to you. From sturlamolden at yahoo.no Thu Apr 17 11:26:08 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 17 Apr 2008 08:26:08 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: <181216e5-7162-47c8-b866-b06660401fd3@y21g2000hsf.googlegroups.com> On 17 Apr, 09:11, Matias Surdi wrote: > It's april 1st again??? Not according to my calendar. This was not meant as a joke. I think I may have solved the GIL issue. See my answer to Martin v. L?wis for a full explanation. From diresu at web.de Tue Apr 22 12:09:39 2008 From: diresu at web.de (Dietrich Bollmann) Date: Wed, 23 Apr 2008 01:09:39 +0900 Subject: Error in Extending/Embedding FAQ, point 16: How do I tell "incomplete input" from "invalid input"? In-Reply-To: <1208877167.4557.37.camel@pippi.pippi> References: <1208877167.4557.37.camel@pippi.pippi> Message-ID: <1208880579.4557.70.camel@pippi.pippi> On Wed, 2008-04-23 at 00:12 +0900, Dietrich Bollmann wrote: > The following code for example: > > >>> eins = [1, > ... 2, > ... 3] > >>> > > is accepted without any problem by the Python shell. > > When using the code from the FAQ and entering it line by line > ?already the second line causes a simple "invalid syntax" error: > > >>> eins = [1, > ... 2, > File "", line 2 > 2, > ^ > SyntaxError: invalid syntax By the way - isn't this error message / error code just "wrong" in the given situation and therefor kind of a "bug"? An "end of file" or "incomplete input" error at least would describe the situation much better - and be a better base for functionality which is based the error code also. --- I also thought that I should explain a little bit more exactly, what I am intending to do with the code based on paragraph 16 (How do I tell "incomplete input" from "invalid input"?) of the Extending/Embedding FAQ: I am using Python as scripting language in an application (blender). In order to interface this application from other programs I programmed a python command port / command socket for this application. Between other clients I also wrote a shell client which connects via the command port to the application. My goal is to make it as similar to a normal python shell as possible - and therefor I try to also mimic the "intelligent" way of the Python shell to react to Python input: - when entering a line which is a complete input, it is immediately evaluated by the shell and the result is printed. - when the last entered line is erroneous, an error message is printed immediately - when the input is incomplete, Python waits for other lines to complete the input - when the line is part of a function definition etc. python waits until an empty line is entered before accepting the input as complete. My problem is to understand when an input is erroneous and when it is incomplete - which is impossible with an error message like "invalid syntax"... So here again my question: How can I make the difference between an incomplete and an erroneous input? The code examples in the FAQ worked fine until now - but do not anymore for the current Python implementation. Thanks, Dietrich By the way: Does anybody know who is responsible for the FAQ and could adapt the examples to the current Python version by changing the code / annotating it? On Wed, 2008-04-23 at 00:12 +0900, Dietrich Bollmann wrote: Hi, > > Both code examples from paragraph 16 from the Python Extending / > Embedding FAQ - 'How do I tell "incomplete input" from "invalid input"?' > - > ( http://www.python.org/doc/faq/extending/#how-do-i-tell-incomplete-input-from-invalid-input ) do not work with the current state of Python anymore. > > In the second code example, the error message returned by Python is > checked in order to differentiate errors caused by an incomplete input > from other syntax errors: > > if (PyArg_ParseTuple (val, "sO", &msg, &obj) && > !strcmp (msg, "unexpected EOF while parsing")) /* E_EOF */ > > In the current Python version there are more error messages indicating an > incomplete Python input and I could make the code work for a while > by adding the following strings to the condition: > > /* error messages indicating an incomplete input */ > if (PyArg_ParseTuple(error, "sO", &message, &obj) && > (!strcmp(message, "unexpected EOF while parsing") || > !strcmp(message, "expected an indented block") || > !strcmp(message, "EOF while scanning triple-quoted string") > ) > ) { /* E_EOF */ > > but recently there are also cases which generate error messages > which are too general to be added to this list. > > The following code for example: > > >>> eins = [1, > ... 2, > ... 3] > >>> > > is accepted without any problem by the Python shell. > > When using the code from the FAQ and entering it line by line > ?already the second line causes a simple "invalid syntax" error: > > >>> eins = [1, > ... 2, > File "", line 2 > 2, > ^ > SyntaxError: invalid syntax > > which is to general to be integrated into the list of tested > error messages as it might be caused also by code like: > > >>> one two > File "", line 1 > one two > ^ > SyntaxError: invalid syntax > > which generates an "invalid syntax" error even in the Python shell. > > I also tried the first code example of paragraph > '16 How do I tell "incomplete input" from "invalid input"?' > of the FAQ in order to see if it could be used to make the > difference between syntax errors and incomplete code errors. > But - as in the case before - the returned error > code is E_SYNTAX (14 = Syntax error) and not E_EOF (11 = End Of File) > as should be expected. > > Is there anybody who has an idea how to differentiate the > first case from the second in order to mimic the behaviour of > the Python shell from c code? > > If this shouldn't be possible lists split into different lines > couldn't be accepted anymore or the feature of the Python shell > to described in paragraph 16 of the faq: > > Sometimes you want to emulate the Python interactive interpreter's > behavior, where it gives you a continuation prompt when the input > is incomplete (e.g. you typed the start of an "if" statement or you > didn't close your parentheses or triple string quotes), but it gives > you a syntax error message immediately when the input is invalid. > > would have to be given up and every entered line of code would have to > be terminated by an empty line before evaluation :( > > Thanks for any help, Dietrich > > > > From MartinRinehart at gmail.com Wed Apr 9 11:02:44 2008 From: MartinRinehart at gmail.com (MartinRinehart at gmail.com) Date: Wed, 9 Apr 2008 08:02:44 -0700 (PDT) Subject: import statement convention References: <4078bcf4-e68f-45d4-93ce-335ec7a33c5a@v32g2000prd.googlegroups.com> Message-ID: <405fef20-2593-44da-abe8-516fec7e59fa@k10g2000prm.googlegroups.com> Thanks, all. Good to know no one's been beheaded. Yes to separating test and non-test code, but no if that will just turn one modest module into two modules, smaller still. Amen to 'practicality beats purity.' Do wish we had a good, thorough convention set. I wrote one for Java. It took a lot of work. ( file:/home/martin/mrwebsite/articles/code- conventions.html ) From bbxx789_05ss at yahoo.com Sun Apr 6 18:21:51 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sun, 6 Apr 2008 15:21:51 -0700 (PDT) Subject: Tkinter, a lot of buttons, make prog shorter? References: <688483d9-2c6a-4e2a-b64d-f32bb27699ec@p25g2000hsf.googlegroups.com> Message-ID: On Apr 6, 4:12?pm, 7stud wrote: > You said you were an experienced programmer, but you keep posting code > with the same mistakes over and over again. ?Why are you attaching the > buttons to self? Remember this: > Another thing you should be aware of: self is like a class wide > bulletin board. If you are writing code inside a class method, and > there is data that you want code inside another class method to be > able to see, then post the data on the class wide bulletin board, i.e. > attach it to self. ?But in your code, you are doing this: > > self.btnDisplay = Button(self, text="7", default=ACTIVE) > self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > self.btnDisplay = Button(self, text="8", default=ACTIVE) > self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > As a result, your code continually overwrites self.btnDisplay. ?That > means you aren't preserving the data assigned to self.btnDisplay. > Therefore, the data does not need to be posted on the class wide > bulletin board for other class methods to see. ?So just write: > > btnDisplay = Button(self, text="7", default=ACTIVE) > btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > btnDisplay = Button(self, text="8", default=ACTIVE) > btnDisplay.grid(row=5, column=1, padx=5, pady=5) From matthieu.brucher at gmail.com Thu Apr 10 11:24:24 2008 From: matthieu.brucher at gmail.com (Matthieu Brucher) Date: Thu, 10 Apr 2008 17:24:24 +0200 Subject: SWIG/C++ In-Reply-To: References: Message-ID: Hi, The error is generated because you are asking for a u8*, but the buffer is not a u8*, perhaps a char* or even a void*. If you change the method signature to either char* or void*, it may work like you want it to ;) Matthieu 2008/4/10, Bill Davy : > > Is there a better place to post such questions? > > Anyway, in the hope it is something simple, I would appreciate some help. > > I am adding some C++ code to Python. From Python I want to be able to > read > data from a target device, over USB. My software does all the hard work > and > I have a class: > > class ViperUsbC > { > public: > // snip snip > ERROR_T ReadSlaveMemory(u8 Slave, u16 Offset, u8* pData, u16 > Length); > // Snip,snip > }; > > I use swigwin-1.3.34 to wrap it into a module called SHIP. > > In Python, I have: > > import SHIP > ViperUsb = SHIP.ViperUsbC() > Slave =7 > Offset = 0 > Length = 64 > Buffer = 'a' * Length > print "type(Buffer)=%s" % type(Buffer) > print "len(Buffer)=%s" % len(Buffer) > Result = ViperUsb.ReadSlaveMemory(Slave, Offset, Buffer, Length); > > That fails with: > > type(Buffer)= > len(Buffer)=64 > > Traceback (most recent call last): > File "H:\Husky\HostPC\V1\SHIP\test1.py", line 1970, in -toplevel- > ViperTests() > File "H:\Husky\HostPC\V1\SHIP\test1.py", line 1884, in ViperTests > Result = ViperUsb.ReadSlaveMemory(Slave, Offset, Buffer, Length); > File "H:\Husky\HostPC\V1\SHIP\Release\SHIP.py", line 1757, in > ReadSlaveMemory > def ReadSlaveMemory(*args): return > _SHIP.ViperUsbC_ReadSlaveMemory(*args) > TypeError: in method 'ViperUsbC_ReadSlaveMemory', argument 4 of type 'u8 > *' > > > How do I provide a buffer into which to read the data? It would not be > intolerable to provide another layer using %extend, but I feel sure this > should be automagic. > > Thanks in advance > Bill > > PS This is a very small part of a much larger project so I cannot supply > complete source code. > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- French PhD student Website : http://matthieu-brucher.developpez.com/ Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92 LinkedIn : http://www.linkedin.com/in/matthieubrucher -------------- next part -------------- An HTML attachment was scrubbed... URL: From ross.buick at iquest.co.nz Sun Apr 20 21:29:05 2008 From: ross.buick at iquest.co.nz (DevEng) Date: Sun, 20 Apr 2008 18:29:05 -0700 (PDT) Subject: C\C++ Python embedding linking problem Message-ID: <944798e9-cfd8-496b-a369-448bd4dbad61@q24g2000prf.googlegroups.com> Hi all, I am new to Python and trying to embed it into a c/c++ application. I started with examples from the documentation pages and go to the Pure Embedding example (http://docs.python.org/ext/pure-embedding.html). I can compile and run this example on wxDevC++ with a mingwin compiler. However when I tried this with Borland C++ Builder 5 I get linker errors. The code is the same exactly (the same main.c file), the only difference is the library I am using, as Borland requires OMF format library (I have converted it from). I am using the same binary distribution of Python on win XP. As far as I can tell the functions the linker complains about are not in the converted library or the original. [Linker Error] Unresolved external '_Py_InitModule4TraceRefs' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER5\PROJECTS\EXP \TRY2\PETMAIN.OBJ [Linker Error] Unresolved external '__Py_RefTotal' referenced from C: \PROGRAM FILES\BORLAND\CBUILDER5\PROJECTS\EXP\TRY2\PETMAIN.OBJ [Linker Error] Unresolved external '__Py_NegativeRefcount' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER5\PROJECTS\EXP\TRY2\PETMAIN.OBJ [Linker Error] Unresolved external '__Py_Dealloc' referenced from C: \PROGRAM FILES\BORLAND\CBUILDER5\PROJECTS\EXP\TRY2\PETMAIN.OBJ As far as I can tell it is a problem with my Borland setup but I cannot find what it is... Any help is greatly appreciated, Ross From pavlovevidence at gmail.com Thu Apr 17 16:07:56 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Thu, 17 Apr 2008 13:07:56 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <431ee8d9-4dd6-4abf-a1a4-55e5be82d535@x41g2000hsb.googlegroups.com> Message-ID: On Apr 17, 1:03 pm, Jonathan Gardner wrote: > On Apr 17, 1:18 am, Carl Banks wrote: > > > On Apr 17, 3:37 am, Jonathan Gardner > > wrote: > > > If you can't rewrite > > > your algorithm to be disk or network bound, next optimization step is > > > C. > > > I'm sorry, but I don't like being told to use C. Perhaps I would like > > the expressiveness of Python, am willing to accept the cost in > > performance, but would also like to take advantage of technology to > > get performance gains when I can? What's so unreasonable about that? > > If you're satisfied then don't take the next optimization step. Where do you see the word "satisfied" in what I wrote? Carl Banks From hdante at gmail.com Tue Apr 1 19:24:40 2008 From: hdante at gmail.com (hdante) Date: Tue, 1 Apr 2008 16:24:40 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> Message-ID: <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> On Apr 1, 5:40 pm, Aaron Watters wrote: > I've been poking around the world of object-relational > mappers and it inspired me to coin a corellary to the > the famous quote on regular expressions: > > "You have objects and a database: that's 2 problems. > So: get an object-relational mapper: > now you have 2**3 problems." > > That is to say I feel that they all make me learn > so much about the internals and features of the > O-R mapper itself that I would be better off rolling > my own queries on an as-needed basis without > wasting so many brain cells. > > comments? Try Rails' ActiveRecord. Your problems should reduce to (lg lg 2)^(1/12). Seriously, you'll forget there's a relational database below. (there are even intefaces for "relational lists", "trees", etc.) I won't post a code sample here, it would be heretic. :-) > > -- Aaron Watters > > ===http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=mild+exponenti... From zethex at hotmail.com Sun Apr 27 14:22:06 2008 From: zethex at hotmail.com (Zethex) Date: Sun, 27 Apr 2008 11:22:06 -0700 (PDT) Subject: Mapping and Filtering Help for Lists In-Reply-To: References: <16925836.post@talk.nabble.com> Message-ID: <16926760.post@talk.nabble.com> Thank you a lot! Another quick couple of questions. How can i make it so it removes special operators such as ? ! or doesnt include them? and I need to lowercase the words so should i use sentence = sentence.lower()? -- View this message in context: http://www.nabble.com/Mapping-and-Filtering-Help-for-Lists-tp16925836p16926760.html Sent from the Python - python-list mailing list archive at Nabble.com. From steve at holdenweb.com Thu Apr 17 16:16:48 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 17 Apr 2008 16:16:48 -0400 Subject: Can't do a multiline assignment! In-Reply-To: <564dd82b-8670-4ead-a3c8-a22b30a3eb73@m73g2000hsh.googlegroups.com> References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <1952579a-3cfb-44ea-92aa-658daa64aee4@a70g2000hsh.googlegroups.com> <564dd82b-8670-4ead-a3c8-a22b30a3eb73@m73g2000hsh.googlegroups.com> Message-ID: s0suk3 at gmail.com wrote: > On Apr 17, 11:46 am, Arnaud Delobelle wrote: >> Why not do something like: >> >> class RequestHeadersManager: >> >> def __init__(self, string): >> self._fields = {} >> # Populate self.fields with fields defined in 'string' >> >> def __getitem__(self, fieldname): >> return self._fields.get(fieldname, None) >> >> This way you don't need to prebind all possible fields to None, and a >> field is accessible by its actual name, which should be easier to >> remember than an identifier derived from a field name. Moreover you >> can more easily do some group manipulation of fields (e.g. print them >> all >> >> def print_fields(self): >> for name, value in self._fields.iteritems(): >> print "%s: %s" % (name, value) >> ) >> > > I do it with all the separate variables mainly for performance. If I > had the headers in a dict, I'd be looking up a string in a list of > strings (the keys of the dict) everytime I check for a header. Not > that that's going to take more that 0.1 seconds, but the program is > still small and simple. As it gets bigger, more features are gonna > slow things down. So basically you are optimizing for a performance problem you don't currently have. You want to stop that *straight* away. You are contorting your logic for absolutely no good reason. Do what's easiest. Then, when you have that working correctly, speed it up (if you need to). Start with a dict. How do you know it won't be fast enough? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From ivan.illarionov at gmail.com Fri Apr 18 20:47:30 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Sat, 19 Apr 2008 00:47:30 +0000 (UTC) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <0ebcf70f-c6d6-4ee7-9ef8-7cd2221ef906@t12g2000prg.googlegroups.com> <879750f6-614a-45ed-8f18-f0b7ae5ea9a2@26g2000hsk.googlegroups.com> Message-ID: On Fri, 18 Apr 2008 16:19:38 -0700, Kay Schluehr wrote: > On 18 Apr., 23:09, Matimus wrote: >> The reason it doesn't work is that you are unpacking the dictionary >> with **, and you have done nothing to define any keys or define a >> length. > > This is a non-issue. The class derives from dict; it has all the desired > attributes. It is also not a problem in particular because these > properties are not requested by format ( at least not in the code I have > examined which was admittedly just a critical section that caused the > exception ). > >> Adding to that... don't worry about py3k. Nobody is forcing you to >> switch. In fact, you are encouraged not to until you are comfortable. >> Py3k won't _break_ your code. You wrote the code for Python 2.x use it >> in 2.x. Python 2.x probably has a good 5-10 years remaining. > > These advices start to get annoying. > > Software hardly ever exists in isolation for the sake of the beauty of > the algorithm but is supplementary to a large framework/engine/ library. > So if e.g. Django switches to 3 everyone who works with it has to switch > sooner or later as well or lose track otherwise, no matter how long > Python 1.5.2 or Python 2.5.2 or whatever version will be maintained. If > Pythons code base becomes fragmented it will be harmful and affect > almost everyones work. This Py3k-Django-related FUD starts to get annoying. AFAIK Django is going to support everything from 2.3 to 3.0 from single codebase. 2to3 tool will be called from setup.py and code will have few 'if sys.version_info < (3, 0)/else' tricks. Proof of concept already exists: http://wiki.python.org/moin/PortingDjangoTo3k I work with Django as well as *on* Django and 3rd party Django addons and don't see any reason to worry. Your particular problem may be solved by using a real dictionary with real keys which will probably have positive performance impact on your code and make it more clean. Even if Python code base will become fragmented why is it harmfull? This is a way our life work - you rise and get better or die. It is essential part of progress and evolution. IMHO, we'll only get better Python and better Python libraries. -- Ivan From ankitks.mital at gmail.com Thu Apr 3 15:58:25 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Thu, 3 Apr 2008 12:58:25 -0700 (PDT) Subject: python bisect questions Message-ID: <6bb6927b-f553-40db-a142-2ce86b9e819f@q27g2000prf.googlegroups.com> I am week on functional programming, and having hard time understanding this: class myPriorityQueue: def __init__(self, f=lamda x:x): self.A = [] self.f = f def append(self, item) bisect.insort(self.A, (self.f(item), item)) ............ now I know we are inserting items(user defined type objects) in list A base on sorting order provided by function A. but what I don't understand is bisect command what does bisect.insort(self.A, (self.f(item), item)) doing isn't it is returning truple of (self.f(item), item)). why it is not biset.insort(self.A, item) A.sort(f) thanks for your comments From kyosohma at gmail.com Fri Apr 25 10:30:33 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 25 Apr 2008 07:30:33 -0700 (PDT) Subject: Environment Variables References: <336c3140-4620-4ca3-a6b9-9869dafc4b36@c19g2000prf.googlegroups.com> Message-ID: On Apr 25, 8:26?am, Krishna wrote: > On Apr 25, 9:17?am, Mike Driscoll wrote: > > > > > On Apr 25, 8:07?am, Krishna wrote: > > > > Environment variable set up is the most confusing part for me all the > > > time. Please help me with the following questions: > > > > When I install python in a new system, I will go to environment > > > variables (system variables) and set "path" pointing to C:\Python25 > > > and thats all I do. > > > I type python from "cmd" window and its converting to python window > > > for python execution. All fine up to this point. > > > Now, I want to drag and drop python (.py) files to this window and > > > execute it. My python files are located in different directories > > > inside C: and outside C:. When I do that, I get errors and the file is > > > not found and its not imported. ALso, inside the .py file, if I have a > > > command to open a different file, it doesnt see that either. How do I > > > overcome these basic difficulties in python. I wish I can open any > > > file and work on that using python. > > > > Thanks for your help! > > > Krishna > > > I'm pretty sure you can't do that in a command window. I tried it on > > my Windows XP machine and all I get in my instance of IDLE is the path > > to the file. It DOES work with PythonWin, which is the ActiveState > > version of Python. The only difference is that it include the win32 > > modules and has a more advanced editor. > > > You can probably get this to work in other more advanced editors, like > > WingIDE or PyDev too. > > > Mike- Hide quoted text - > > > - Show quoted text - > > So, how do I get the win32 module and what to do with that? Just > install it? > > Thanks, > Krishna ActivePython can be found on the ActiveState website: http://www.activestate.com/Products/activepython/?_x=1 This will basically just add whatever modules needed if Python is already installed and it will also install another editor called pythonwin, which you should be able to find in your start menu. But be sure to check out that link that Steve gave you. That might work for you too. Mike From nick at stinemates.org Fri Apr 18 14:40:27 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 11:40:27 -0700 Subject: Brand New! In-Reply-To: References: <7f1828bf-ebe7-4111-bc59-70d125facb0a@d26g2000prg.googlegroups.com> Message-ID: <20080418184027.GD19281@deviL> On Tue, Apr 15, 2008 at 04:37:40PM -0700, agent E 10 wrote: > On Apr 14, 8:37?pm, Benjamin wrote: > > On Apr 14, 9:00 pm, agent E 10 wrote:> ? ?Hi, I'm brand new to programming. Have any suggestions? I'm young. > > > Was it a good idea to start with python? I was planning on creating a > > > very simple program that asked yes/no questions for a school project. > > > > IMHO, Python is an excellent language to start with. Have you read the > > tutorial?http://docs.python.org/tut/tut.html > > > > > > > > > -Thanks!- Hide quoted text - > > > > - Show quoted text - > > No, I haven't. I have been reading off of this site > http://www.freenetpages.co.uk/hp/alan.gauld/ is this a good site to > learn off of? About how long will it take me to learn the basics of > the language? > -Thanks 4 all ur help! Agent E 10 > -- > http://mail.python.org/mailman/listinfo/python-list Windows or Unix/Linux? I find python is easier to learn in Linux environments, since it assumes some familiarty with the shell. -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From ch612bunn at gmail.com Sun Apr 27 09:19:26 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:19:26 -0700 (PDT) Subject: adobe illustrator cs3 crack Message-ID: <8ed265cd-4ba7-441f-a9ee-a1240c082f70@e39g2000hsf.googlegroups.com> adobe illustrator cs3 crack http://wga-cracks.crackkey.net From barbaros at ptmat.fc.ul.pt Wed Apr 23 11:44:50 2008 From: barbaros at ptmat.fc.ul.pt (barbaros) Date: Wed, 23 Apr 2008 08:44:50 -0700 (PDT) Subject: help needed with classes/inheritance References: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> <480f05d0$0$25755$426a74cc@news.free.fr> Message-ID: <676bac37-2816-402b-9aed-1a9c1873351b@a23g2000hsc.googlegroups.com> On Apr 23, 10:48 am, Bruno Desthuilliers wrote: > > > My question is: can it be done using inheritance ? > > Technically, yes: > > class OrientedBody(Body): > def __init__(self, orient=1): > Body.__init__(self) > self.orient = 1 > > Now if it's the right thing to do is another question... If I understand correctly, in the above implementation I cannot define firstly a (non-oriented) body, and then build, on top of it, two bodies with opposite orientations. The point is, I want both oriented bodies to share the same base Body object. > Another > possible design could be to have an orient attribute on the Body class > itself, with 0 => non-oriented (default), 1 => 'plus', -1 => 'minus' (or > any other convention, depending on how you use this attribute). The above comments apply here, too. In what concerns other suggestion, about Python language, I shall do my best to understand them and apply them. Thank you. Cristian Barbarosie http://cmaf.fc.ul.pt/~barbaros From bbxx789_05ss at yahoo.com Sun Apr 13 21:19:28 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sun, 13 Apr 2008 18:19:28 -0700 (PDT) Subject: Tkinter, image not appearing in function but without function References: <42a33edd-5792-47ad-a940-ecb5df23accc@a9g2000prl.googlegroups.com> <66et8fF2ju94lU2@mid.uni-berlin.de> Message-ID: <8d74351a-4d73-4981-a9c8-c2535c070b30@d1g2000hsg.googlegroups.com> On Apr 13, 11:12?am, Marc 'BlackJack' Rintsch wrote: > On Sun, 13 Apr 2008 08:57:29 -0700, skanemupp wrote: > > why is the first program not working? when i click the screen the map > > is not appearing. > > > the second program works. > > > from Tkinter import * > > > master = Tk() > > > w = Canvas(master, width=700, height=600) > > w.pack(expand = YES, fill = BOTH) > > > def mapper(): > > ? ? mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\world-map.gif') > > ? ? w.create_image(10, 10, image = mapq, anchor = NW) > > > def key(event): > > ? ? print "pressed", repr(event.char) > > > def callback(event): > > ? ? w.focus_set() > > ? ? print "clicked at", event.x, event.y > > ? ? mapper() > > ? ? print 'yo' > > ? ? square = w.create_oval(event.x-5,event.y-5,event.x+5,event.y+5, > > fill="black") > > > w.bind("", key) > > w.bind("", callback) > > w.pack() > > > mainloop() > > Python doesn't know that the Tk side still needs the image and frees the > memory when `mapper()` is done and `mapq` the only name to the `PhotoImage` > instance goes out of scope. > > Ciao, > ? ? ? ? Marc 'BlackJack' Rintsch ...so you should do something like this(untested): def mapper(height, width, widget, img, position): widget.create_image(height, width, image=img, anchor=position) w = Canvas(master, width=700, height=600) w.pack(expand = YES, fill = BOTH) #Create a permanent reference to the image, i.e. the variable is not #created inside a function: my_img = PhotoImage(file = 'C:\Users\saftarn\Desktop\world-map.gif') mapper(10, 10, w, my_img, NW) From tjreedy at udel.edu Wed Apr 2 13:12:57 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 2 Apr 2008 13:12:57 -0400 Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: "AK" wrote in message news:47f2d018$0$6517$4c368faf at roadrunner.com... || I'll be glad to hear comments/suggestions/etc: | | http://www.lightbird.net/py-by-example/ Using - as the example/return delimiter does not work. If you do not want to substantially lengthen the document by going to >>> sqrt(9) 3 then use Python's a comment symbol. sqrt(9) # 3 -or- sqrt(9) # returns 3 (but I think I prefer the first) which clearly is not an arithmetic expression and which can be cut-and-pasted into the interactive interpreter. This also works nicely for invalid examples. sqrt(-9) # raises ValueError Terry Jan Reedy From __peter__ at web.de Sun Apr 13 16:34:19 2008 From: __peter__ at web.de (Peter Otten) Date: Sun, 13 Apr 2008 22:34:19 +0200 Subject: class level properties References: Message-ID: Charles D Hixson wrote: > Peter Otten wrote: >> Charles D Hixson wrote: >> >> >>> I want a hundred or so read-only variables, and I'm not sure the best >>> way to achieve it. >>> >> >> What do you really want to do? I recommend that you forget about bondage >> and rely upon displine: >> >> class Test(object): >> """Never change an attribute with an uppercase name.""" >> SIMPLE = "simple example working" >> >> Now that was easy... >> >> Peter >> >> > What I'm doing it translating Java code which has a large number of > "public static final (type)" variables. Ah, Java, the class is an artefact of the language then, and my example becomes SIMPLE = "simple example working" > As to your answer ... yes, and with good discipline you can write object > oriented code in C and never need a garbage collector. It's *not* a > good answer. Before I'd chose that one, I'd make it necessary to Hmm, if you were to choose between a Java dialect without garbage collection or without the 'final' keyword, would you throw a coin? > instantiate the class before testing the value of it's constants. It's > just that that seems to be a silly requirement, so I'd like to avoid Silly or not, it keeps your code simpler, and simplicity just cannot be overvalued. > it. (That's the "solution" that I currently have working with > __getattr__.) I'm confident that after you have been coding in Python for a while the Javaisms will wither away. For now, if you feel that uppercase module-level names are too big a leap I suggest that you add a __setattr__() method that records any attempts to modify read-only attributes. That way you'll have a way to learn whether that particular safety net was a useful investment or just dead code. Peter From steve at holdenweb.com Wed Apr 23 22:49:44 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 22:49:44 -0400 Subject: Partition list with predicate In-Reply-To: <925822270804231839y2eb399a2ic05ab67406c94d0d@mail.gmail.com> References: <925822270804231808n44c44ddbx213e936319ad1ed3@mail.gmail.com> <925822270804231839y2eb399a2ic05ab67406c94d0d@mail.gmail.com> Message-ID: Jared Grubb wrote: > That almost works, except that a predicate can have "memory". For > example, the predicate could be "extract every other object", which > doesn't care about the value of the object (so you cant remove them > later based on value!). Or your predicate might be "remove the first 5 > objects that are even", which means that the predicate must be run > against the list in forward order with only one test per element (like > an input/output iterator in C++; running the predicate changes the > predicate itself, so you cant run one pass with "pred" and then another > pass with "not pred" to get the rest). Example of a case where your > proposed solution wouldn't quite work: > > class EveryOtherOne: > def __init__(self): > self.parity = False > def __call__(self, obj): > ret, self.parity = self.parity, not self.parity > return ret > > >>> pred = EveryOtherOne() > >>> lst = [1,2,2,1] > >>> extracted = [ obj for obj in lst if pred(obj) ] > >>> extracted > [2, 1] > >>> lst = [ obj for obj in lst if obj not in extracted ] > >>> lst > [] > > On Wed, Apr 23, 2008 at 6:14 PM, Brian > wrote: > > On Wed, Apr 23, 2008 at 9:08 PM, Jared Grubb > wrote: > > I guess I forgot one requirement: the removed elements need to > be remembered. > > Basically, I have a list of objects in a buffer, one class > operates on some of the objects, but other classes use others. > So, a class must extract the ones it can handle, and leave the > rest in the buffer for the other classes to handle. > > I haven't found a function that will both remove objects from a > list, but save the ones that do get removed. > > Jared > > On 23 Apr 2008, at 10:15, Tim Golden wrote: >> Jared Grubb wrote: >>> I want a function that removes values from a list if a >>> predicate evaluates to True. The best I could come up with is: >> >> Have a look at the itertools module, and the ifilter function >> in particular. >> >> TJG >> -- >> http://mail.python.org/mailman/listinfo/python-list > > > -- > http://mail.python.org/mailman/listinfo/python-list > > > I would do it like this: > > # This takes out the values > extracted = [ obj for obj in lst if pred(obj) ] > # This filters out any item that was extracted > lst = [ obj for obj in list if obj not in extracted ] > So what you are saying is that you want to build *two* lists, one of them the ones for which the predicate is true and the other the rest. Typical customer, doesn't bother to give us the whole specification until we've started programming! How about (untested, conditional expression abuse warning): def stripf(lst, pred): tlst = [] flst = [] for itm in lst: (tlst if pred(itm) else flst).append(itm) return tlst, flst regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From mellit at gmail.com Tue Apr 22 09:47:53 2008 From: mellit at gmail.com (Anton Mellit) Date: Tue, 22 Apr 2008 15:47:53 +0200 Subject: overriding = operator Message-ID: Hi, I am developing something like a compiler in Python, a library that would help to generate machine-language code. One of the features is the following. When I want to generate a piece of code I want to declare variables as follows: x = var() y = var() This would generate no code, but it would mean that I need, say, two 32-bit integer variables. Then whenever I write something like x+y, the '+' operator is overriden in such a way that a code which computes the sum is generated. What I also want to do, I want to write something like z = var() z = x + y and I want a code which takes the sum of x and y and puts it in z to be generated. However in python z = x + y already has its meaning and it does something different from what I want. So I need something like 'overriding' =, which is impossible, but I look for a systematic approach to do something instead. It seems there are two ways to do what I need: 1. Implement a method 'assign' which generates the corresponding code to store value: z.assign(x + y) 2. Do the same as 1., but via property set methods. For example, this would look cleaner: z.value = x + y Which of these is preferrable? Does anyone know any alternative ways? Anton From dave.l.harrison at gmail.com Fri Apr 18 05:01:10 2008 From: dave.l.harrison at gmail.com (David Harrison) Date: Fri, 18 Apr 2008 19:01:10 +1000 Subject: testing client-server sockets In-Reply-To: <4808627F.5040906@al.com.au> References: <4808627F.5040906@al.com.au> Message-ID: On 18/04/2008, Astan Chee wrote: > Hi, > I have a client-server socket script in python. Something like this > http://ubuntuforums.org/showthread.php?t=208962 > Now the problem I have is that I want to try to connect the client to > the server on the same machine, but it gives me a 'port already in use' > error. I just want the client to connect to the server for testing > purposes. Any suggestions on how I should do this? > Thanks > Astan Can you post the client / server code for us ? It sounds like it's likely to be a minor bug. From python at rcn.com Tue Apr 8 15:25:34 2008 From: python at rcn.com (Raymond Hettinger) Date: Tue, 8 Apr 2008 12:25:34 -0700 (PDT) Subject: list.sort(): heaviest item? References: Message-ID: On Apr 8, 8:15?am, "Steven Clark" wrote: > If I have a list of items of mixed type, can I put something into it > such that after a list.sort(), is guaranteed to be at the end of the > list? Since the other guys gave you the real answer, how about this: sentinel = object() mylist.sort() mylist.append(sentinel) _ ~ @ @ \_/ From steve at holdenweb.com Wed Apr 23 00:41:17 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 00:41:17 -0400 Subject: Python Success stories In-Reply-To: References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> Message-ID: <480EBDED.5010600@holdenweb.com> Nikita the Spider wrote: > In article > <7e595409-be62-4b8c-9819-a14cd363d751 at c65g2000hsa.googlegroups.com>, > azrael wrote: > >> Which big aplications are written in python. I see its development, >> But i can't come up with a big name. I know that there are a lot of >> companys using python, but is there anythong big written only in >> python. I want him to fuck of with his perl once and for all time > > Why are either of you so emotionally attached to the tools you use? > > I don't know your friend, but my guess is that he's not interested in a > logical argument, so he won't be impressed even if you claim that God > himself wrote the Universe in Python. I think he enjoys saying this > stuff simply because you react to it. It's pretty sad that he can't find > something better to do with his time. > It's even sadder that he doesn't need to. [...] regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From castironpi at gmail.com Sun Apr 27 13:27:44 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sun, 27 Apr 2008 10:27:44 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <1d8af3e3-c287-4d5b-a481-ca8c650f732f@s33g2000pri.googlegroups.com> Message-ID: <472056db-8812-42b2-a4fe-3a2accd7571b@8g2000hse.googlegroups.com> On Apr 26, 11:04?pm, John Henry wrote: > On Apr 26, 3:03?pm, John Henry wrote: > > > > > > > On Apr 26, 8:46 am, a... at pythoncraft.com (Aahz) wrote: > > > > In article <9028496e-30de-4853-8f57-b55d14e52... at h1g2000prh.googlegroups.com>, > > > John Henry ? wrote: > > > > >But then I looked closer. ?It turns out the XML file created by > > > >QxTransformer is *very* similar in structure when compared to the > > > >resource files used inPythonCard. ?Since there are no GUI builders > > > >for QxTransformer, and I can't affort to buy the one for Qooxdoo > > > >(Java! ?Yuk!), I decided to roll up my sleeves, took thePythoncard's > > > >Layout Manager and modified it and created my own "Poor Man's Qooxdoo > > > >GUI Layout Designer". > > > > Cute! ?When you have working code, please do upload to PyPI. > > > -- > > > Aahz (a... at pythoncraft.com) ? ? ? ? ? <*> ? ? ? ?http://www.pythoncraft.com/ > > > > Why is this newsgroup different from all other newsgroups? > > > So far, I have the following widgets working: > > > window, button, checkbox, static text, static box, list, combobox, > > spinner, radio button group > > > Shouldn't be long before the following works: > > > static line, image, image button, choice.- Hide quoted text - > > > - Show quoted text - > > All of the above works! > > TextFields next.- Hide quoted text - > > - Show quoted text - Actually, I was asking what operations you chose to support in 'static text'. Additional Python methods of strings could be made to work on them. From gagsl-py2 at yahoo.com.ar Tue Apr 15 18:24:03 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 15 Apr 2008 19:24:03 -0300 Subject: tkinter, event.widget, what do i get? References: <7caa5089-2ea9-4e18-9117-7431d7403976@l42g2000hsc.googlegroups.com> Message-ID: En Tue, 15 Apr 2008 17:45:08 -0300, escribi?: > when calling function hmm here, what do i get? the widget i clicked > on? > if i have a canvs on wich i have a bitmap and i click on the bitmap, > is the event.widget then the bitmap? > can i get info about the bitmap then? like color of the pixel i > clicked. if so, how? > > > w.bind("", key) > w.bind("", hmm) > > def hmm(event): > return event.widget Why don't you try by yourself? You can use: print repr(something) -- Gabriel Genellina From jeff.self at gmail.com Wed Apr 9 17:10:44 2008 From: jeff.self at gmail.com (jeffself) Date: Wed, 9 Apr 2008 14:10:44 -0700 (PDT) Subject: How can I use quotes without escaping them using CSV? Message-ID: I'm reading data out of an Excel spreadsheet using the XLRD module. The spreadsheet contains a list of election results. The fields are as follows: Precinct, Candidate, Votes The problem is candidate names can be funky, for instance: Michael L. "Mick" Jones I cannot for the life of me figure out how to get the CSV module to allow a name like this to be written to a file. Why does it insist on an escape character when I'm telling it that the delimiter should be '\t'? I want the quotes to go to the file and I want the tab- delimited file to look like this: 0001[tab]Michael L. "Mick" Jones[tab]189 0002[tab]Vickie A. Meyers[tab]221 0003[tab]John "Jack" Smith[tab]187 Note: I don't want [tab] to display, I want a real tab there. If I put an escape character in, it works. For example, if I use ~ as my escape character, my output looks like this: 0001[tab]Michael L. ~"Mick~" Jones[tab]189 I don't want that. If I don't include an escape character, it doesn't work. Here's my code: import sys import csv from readexcel import * f = open("results.txt", 'wb') book = sys.argv[1] sheet = sys.argv[2] xl = readexcel(book) sheetnames = xl.worksheets() for s in sheetnames: if s == sheet: writer = csv.writer(f, delimiter='\t', quoting=csv.QUOTE_NONE) for row in xl.getiter(s): writer.writerow((row['Precinct'],row['Candidate'],unicode(int(row['Votes'])))) f.close() Thanks! From george.sakkis at gmail.com Tue Apr 22 09:03:27 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 22 Apr 2008 06:03:27 -0700 (PDT) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> <85c14b14-9302-41bb-9270-b7cdd65098b0@c65g2000hsa.googlegroups.com> Message-ID: <870d9ebe-ffcb-4222-8aa1-43634b767f76@s50g2000hsb.googlegroups.com> On Apr 22, 12:04?am, Ivan Illarionov wrote: > On Mon, 21 Apr 2008 16:10:05 -0700, George Sakkis wrote: > > On Apr 21, 5:30 pm, Ivan Illarionov wrote: > > >> On 22 ???, 01:01, Peter Otten <__pete... at web.de> wrote: > > >> > Ivan Illarionov wrote: > >> > > And even faster: > >> > > a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, > >> > > len(s), 3)))) > >> > > if sys.byteorder == 'little': > >> > > ? ? a.byteswap() > > >> > > I think it's a fastest possible implementation in pure python > > >> > Clever, but note that it doesn't work correctly for negative numbers. > >> > For those you'd have to prepend "\xff" instead of "\0". > > >> > Peter > > >> Thanks for correction. > > >> Another step is needed: > > >> a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, > >> len(s), 3)))) > >> if sys.byteorder == 'little': > >> ? ? a.byteswap() > >> result = [n if n < 0x800000 else n - 0x1000000 for n in a] > > >> And it's still pretty fast :) > > > Indeed, the array idea is paying off for largeish inputs. On my box > > (Python 2.5, WinXP, 2GHz Intel Core Duo), the cutoff point where > > from3Bytes_array becomes faster than from3Bytes_struct is close to 150 > > numbers (=450 bytes). > > > The struct solution though is now almost twice as fast with Psyco > > enabled, while the array doesn't benefit from it. Here are some numbers > > from a sample run: > > > *** Without Psyco *** > > ? size=1 > > ? ? from3Bytes_ord: 0.033493 > > ? ? from3Bytes_struct: 0.018420 > > ? ? from3Bytes_array: 0.089735 > > ? size=10 > > ? ? from3Bytes_ord: 0.140470 > > ? ? from3Bytes_struct: 0.082326 > > ? ? from3Bytes_array: 0.142459 > > ? size=100 > > ? ? from3Bytes_ord: 1.180831 > > ? ? from3Bytes_struct: 0.664799 > > ? ? from3Bytes_array: 0.690315 > > ? size=1000 > > ? ? from3Bytes_ord: 11.551990 > > ? ? from3Bytes_struct: 6.390999 > > ? ? from3Bytes_array: 5.781636 > > *** With Psyco *** > > ? size=1 > > ? ? from3Bytes_ord: 0.039287 > > ? ? from3Bytes_struct: 0.009453 > > ? ? from3Bytes_array: 0.098512 > > ? size=10 > > ? ? from3Bytes_ord: 0.174362 > > ? ? from3Bytes_struct: 0.045785 > > ? ? from3Bytes_array: 0.162171 > > ? size=100 > > ? ? from3Bytes_ord: 1.437203 > > ? ? from3Bytes_struct: 0.355930 > > ? ? from3Bytes_array: 0.800527 > > ? size=1000 > > ? ? from3Bytes_ord: 14.248668 > > ? ? from3Bytes_struct: 3.331309 > > ? ? from3Bytes_array: 6.946709 > > > And here's the benchmark script: > > > import struct > > from array import array > > > def from3Bytes_ord(s): > > ? ? return [n if n<0x800000 else n-0x1000000 for n in > > ? ? ? ? ? ? ((ord(s[i])<<16) | (ord(s[i+1])<<8) | ord(s[i+2]) > > ? ? ? ? ? ? ? for i in xrange(0, len(s), 3))] > > > unpack_i32be = struct.Struct('>l').unpack def from3Bytes_struct(s): > > ? ? return [unpack_i32be(s[i:i+3] + '\0')[0]>>8 > > ? ? ? ? ? ? for i in xrange(0,len(s),3)] > > > def from3Bytes_array(s): > > ? ? a = array('l', ''.join('\0' + s[i:i+3] > > ? ? ? ? ? ? ? ? ? ? ? ? ? ?for i in xrange(0,len(s), 3))) > > ? ? a.byteswap() > > ? ? return [n if n<0x800000 else n-0x1000000 for n in a] > > > def benchmark(): > > ? ? from timeit import Timer > > ? ? for n in 1,10,100,1000: > > ? ? ? ? print ' ?size=%d' % n > > ? ? ? ? # cycle between positive and negative buf = > > ? ? ? ? ''.join(struct.pack('>i', 1234567*(-1)**(i%2))[1:] > > ? ? ? ? ? ? ? ? ? ? ? for i in xrange(n)) > > ? ? ? ? for func in 'from3Bytes_ord', 'from3Bytes_struct', > > 'from3Bytes_array': > > ? ? ? ? ? ? print ' ? ?%s: %f' % (func, > > ? ? ? ? ? ? ? ? Timer('%s(buf)' % func , > > ? ? ? ? ? ? ? ? ? ? ? 'from __main__ import %s; buf=%r' % (func,buf) > > ? ? ? ? ? ? ? ? ? ? ? ).timeit(10000)) > > > if __name__ == '__main__': > > ? ? s = ''.join(struct.pack('>i',v)[1:] for v in > > ? ? ? ? ? ? ? ? [0,1,-2,500,-500,7777,-7777,-94496,98765, > > ? ? ? ? ? ? ? ? -98765,8388607,-8388607,-8388608,1234567]) > > ? ? assert from3Bytes_ord(s) == from3Bytes_struct(s) == > > from3Bytes_array(s) > > > ? ? print '*** Without Psyco ***' > > ? ? benchmark() > > > ? ? import psyco; psyco.full() > > ? ? print '*** With Psyco ***' > > ? ? benchmark() > > > George > > Comments: > You didn't use the faster version of array approach: > ''.join('\0' + s[i:i+3] for i in xrange(0,len(s), 3)) > is slower than > '\0' + '\0'.join(s[i:i+3] for i in xrange(0,len(s), 3)) Good catch; the faster version reduces the cutoff point between from3Bytes_array and from3Bytes_struct to ~50 numbers (=150 bytes) only (without Psyco). George From gagsl-py2 at yahoo.com.ar Wed Apr 16 01:23:35 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 02:23:35 -0300 Subject: how to remove \n in the list References: <2ba667ab-6818-47eb-8595-79ed970728f7@q1g2000prf.googlegroups.com> Message-ID: En Tue, 15 Apr 2008 20:26:16 -0300, Yves Dorfsman escribi?: > Dan Bishop wrote: > >>>> lines[:] = [line.rstrip('\n') for line in lines] >>> What is the point of the [:] after lines ? How different is it with or >>> without it ? >> >> It causes the result to be stored in the existing list. >> > > If we do: > lines = [line.rstrip('\n') for line in lines] > > lines is now a new list, the old list as no reference to it, and will be > discarded by the gc, right ? So we're not really saving any space here ? > > If we do: > lines[:] = [line.rstrip('\n') for line in lines] > > We reuse an existing list, therefore we are saving the time it takes to > create a new list ? So this is a performance issue ? No. The new list (the right hand side) is created in either case, so there is no difference here. And the name `lines` refers to a list with the new contents in all cases. The difference is on whether *other* references to the original list see the changes or not. For an example, see Dan Bishop's message earlier on this thread. -- Gabriel Genellina From castironpi at gmail.com Tue Apr 1 08:32:24 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Tue, 1 Apr 2008 05:32:24 -0700 (PDT) Subject: Rubik's cube translation References: <3f3817e8-db90-4bbb-9d6e-cddf042ff6de@a22g2000hsc.googlegroups.com> <489180f4-aa43-4d98-a67d-71ce06ea9152@x41g2000hsb.googlegroups.com> <1mj3v35u8ai9bijik3gggdrdhm07qaf7v0@4ax.com> Message-ID: On Apr 1, 1:00?am, Tim Roberts wrote: > castiro... at gmail.com wrote: > > >What if this is connected: > > >>>> D > >array([[1, 2, 3], > > ? ? ? [4, 5, 6], > > ? ? ? [6, 7, 8]]) > >>>> E > >array([[6, 7, 8], > > ? ? ? [0, 0, 0], > > ? ? ? [0, 0, 0]]) > > >--> > > >>>> D > >array([[1, 2, 3], > > ? ? ? [4, 5, 6], > > ? ? ? [6, 7, 8]]) > >>>> E > >array([[6, 7, 8], > > ? ? ? [0, 0, 0], > > ? ? ? [0, 0, 0]]) > >>>> numpy.rot90( D ) > >array([[3, 6, 8], > > ? ? ? [2, 5, 7], > > ? ? ? [1, 4, 6]]) > >--> > >>>> E > >array([[1, 4, 6], > > ? ? ? [0, 0, 0], > > ? ? ? [0, 0, 0]]) > > >? > > If you don't want changes to D to affect E, then you need to disconnect > them when you create them. ?If you create D and E so that they contain > references to the same lists, then this kind of thing will happen. Basically, I need to change both D row 3 and E row 1 at the same time. From markflorisson88 at gmail.com Sat Apr 19 08:13:32 2008 From: markflorisson88 at gmail.com (mark) Date: Sat, 19 Apr 2008 14:13:32 +0200 Subject: eggy IDE Message-ID: <4809E1EC.7040102@gmail.com> Hello, I have written an open source IDE in python and Qt, called eggy. Eggy supports several languages, including python, ruby, C, C++, java, perl and others. Eggy also supports group projects over the lan or internet - with live changes, lets you compile and run your code, supports templates and lets you write your own plugins very easily. You also have syntax highlighting, autocompletion, an integrated bash shell and the option of chatting with group partners. You can read more about it here: http://eggy.student.utwente.nl it free and open source (GPL). Regards, Mark PS: if anyone is interested in helping out with the project, feel free to write and submit a plugin (in python), its really easy and some ideas are posted on the website. From fivesheep at gmail.com Thu Apr 17 06:13:45 2008 From: fivesheep at gmail.com (Fivesheep) Date: Thu, 17 Apr 2008 03:13:45 -0700 (PDT) Subject: about a head line References: Message-ID: On Apr 17, 5:54 pm, "Penny Y." wrote: > I saw some scripts have a line at its begin: > > # encoding:gb2312 > > what's this? Why need it? thanks. declaring of the encoding used in the source file. it's like in html take gb2312 as an example. you will need it if you have some chinese char in the source file which uses gb2312 for the file encoding. if not, you might get an error like: SyntaxError: Non-ASCII character ......... From Graham.Dumpleton at gmail.com Sat Apr 12 18:28:02 2008 From: Graham.Dumpleton at gmail.com (Graham Dumpleton) Date: Sat, 12 Apr 2008 15:28:02 -0700 (PDT) Subject: Multiple independent Python interpreters in a C/C++ program? References: <624b9d79-bc02-4f52-bc97-52019bf916d0@n1g2000prb.googlegroups.com> Message-ID: <4f3b3348-4fe6-443c-8d2f-25f6702ad0ef@s13g2000prd.googlegroups.com> On Apr 13, 3:05?am, sturlamolden wrote: > On Apr 11, 6:24 pm, s... at pobox.com wrote: > > > Do I wind up with two completely independent interpreters, one per thread? > > I'm thinking this doesn't work (there are bits which aren't thread-safe and > > are only protected by the GIL), but wanted to double-check to be sure. > > You can create a new subinterpreter with a call to Py_NewInterpreter. > You get a nwe interpreter, but not an independent one. The GIL is a > global object for the process. If you have more than one interpreter > in the process, they share the same GIL. > > In tcl, each thread has its own interpreter instance and no GIL is > shared. This circumvents most of the problems with a global GIL. > > In theory, a GIL private to each (sub)interpreter would make Python > more scalable. The current GIL behaves like the BKL in earlier Linux > kernels. However, some third-party software, notably Apache'smod_python, is claimed to depend on this behaviour. I wouldn't use mod_python as a good guide on how to do this as it doesn't properly use PyGILState_Ensure() for main interpreter like it should. If you want an example of how to do this, have a look at code for mod_wsgi instead. If you want it to work for Python 3.0 as well as Python 2.X, make sure you look at mod_wsgi source code from subversion repository trunk as tweak had to be made to source to support Python 3.0. This is because in Python 3.0 it is no longer sufficient to hold only the GIL when using string/unicode functions, you also need a proper thread state to be active now. Do note that although multiple sub interpreters can be made to work, destroying sub interpreters within the context of a running process, ie., before the process ends, can be a cause for various problems with third party C extension modules and thus would advise that once a sub interpreter has been created, you keep it and use it for the life of the process. Graham From victorsubervi at gmail.com Thu Apr 17 15:32:06 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 17 Apr 2008 14:32:06 -0500 Subject: Importing My Own Script In-Reply-To: <684b0a740804171218t2fff48c6s6c39acc5b38eb761@mail.gmail.com> References: <69481.40675.qm@web39203.mail.mud.yahoo.com> <684b0a740804171218t2fff48c6s6c39acc5b38eb761@mail.gmail.com> Message-ID: <4dc0cfea0804171232g1bb56215obc2062ed785ba57@mail.gmail.com> That worked. Thanks. Victor On Thu, Apr 17, 2008 at 2:18 PM, Ra?l G?mez C. wrote: > Victor, you can do this in order to load your own modules: > > import sys,os > sys.path.append(os.getcwd()) > > import your_module > > > > On Fri, Apr 18, 2008 at 12:34 PM, Ben Kaplan > wrote: > > > It might be something in mod python. Try asking on their mailing > > list. > > > > ----- Original Message ---- > > From: Victor Subervi > > To: Ben Kaplan > > Cc: python-list at python.org > > Sent: Thursday, April 17, 2008 10:47:34 AM > > Subject: Re: Importing My Own Script > > > > On Thu, Apr 17, 2008 at 8:52 AM, Ben Kaplan > > wrote: > > > > > If x and y are in the same directory, just do "import x". If not, add > > > the directory containing x to sys.path. Then, "import x" should work. > > > > > > > Well, now that?s what I thought! But no, it doesn?t work! Both scripts > > are in the same folder. Here?s the error: > > > > [Thu Apr 17 07:45:50 2008] [error] [client 190.166.0.245] PythonHandler > > mod_python.cgihandler: File "/var/www/vhosts/ > > livestocksling.com/httpdocs/bre/test.py", line 3, in ?\n import test2 > > [Thu Apr 17 07:45:50 2008] [error] [client 190.166.0.245] PythonHandler > > mod_python.cgihandler: ImportError: No module named test2 > > I?m running through Plesk, if that makes a difference. > > TIA, > > Victor > > > > > > > > > > ----- Original Message ---- > > > From: Victor Subervi > > > To: python-list at python.org > > > Sent: Thursday, April 17, 2008 9:45:10 AM > > > Subject: Importing My Own Script > > > > > > Hi: > > > How do I import my own script from a second script? That is, I have > > > script x and I want to import script y. How? > > > TIA, > > > Victor > > > > > > > > > ------------------------------ > > > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try > > > it now. > > > > > > > > > > > ------------------------------ > > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try > > it now. > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > > > -- > Nacho > Linux Counter #156439 > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at cheimes.de Sun Apr 20 16:10:52 2008 From: lists at cheimes.de (Christian Heimes) Date: Sun, 20 Apr 2008 22:10:52 +0200 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <480B8813.6010108@gmail.com> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B80B5.1050500@cheimes.de> <480B8813.6010108@gmail.com> Message-ID: <480BA34C.6010905@cheimes.de> Hank @ITGroup schrieb: > In order to deal with 400 thousands texts consisting of 80 million > words, and huge sets of corpora , I have to be care about the memory > things. I need to track every word's behavior, so there needs to be as > many word-objects as words. > I am really suffering from the memory problem, even 4G memory space can > not survive... Only 10,000 texts can kill it in 2 minutes. > By the way, my program has been optimized to ``del`` the objects after > traversing, in order not to store the information in memory all the time. No ordinary system and programming language can hold that much data in memory at once. Your design is broken; some may call it even insane. I highly recommend ZODB for your problem. ZODB will allow you to work with several GB of data in a transaction oriented way without the needs of an external database server like Postgres or MySQL. ZODB even supports clustering and mounting of additional database from the same file system or an external server. Christian From exarkun at divmod.com Tue Apr 22 21:58:39 2008 From: exarkun at divmod.com (Jean-Paul Calderone) Date: Tue, 22 Apr 2008 21:58:39 -0400 Subject: python has memory leak? In-Reply-To: <1d48c77d-cc93-41ce-b644-1a8e52713e1d@b64g2000hsa.googlegroups.com> Message-ID: <20080423015839.6859.414435618.divmod.quotient.33820@ohm> On Tue, 22 Apr 2008 14:54:37 -0700 (PDT), yzghan at gmail.com wrote: >Hi all, > >I feel that my python script is leaking memory. And this is a test I >have: > > [snip] > The test doesn't demonstrate any leaks. It does demonstrate that memory usage can remain at or near peak memory usage even after the objects for which that memory was allocated are no longer live in the process. This is only a leak if peak memory goes up again each time you create any new objects. Try repeated allocations of a large dictionary and observe how memory usage rises and falls. Python 2.5 does a somewhat better job of releasing memory when actual use falls below peak, but this is a difficult thing to do perfectly. Jean-Paul From baoilleach at gmail.com Tue Apr 29 08:41:04 2008 From: baoilleach at gmail.com (baoilleach) Date: Tue, 29 Apr 2008 05:41:04 -0700 (PDT) Subject: simple chemistry in python References: Message-ID: <5e3717e5-1913-4bda-94b3-ae165e5fb8ba@m73g2000hsh.googlegroups.com> If you are familiar with parsing XML, much of the data you need is stored in the following file: http://bodr.svn.sourceforge.net/viewvc/*checkout*/bodr/trunk/bodr/elements/elements.xml?revision=34&content-type=text%2Fplain This file is part of the Blue Obelisk Data Repository, an effort by several chemistry software developers to share common information. If you have any further questions, please email blueobelisk- discuss at lists.sf.net. Noel On Apr 29, 8:48 am, Astan Chee wrote: > Hi, > Im looking for a python module to do simple chemistry things. Things > like, finding the name of elements given the atomic number (and vice > versa); what state the given matter is in depending on certain > parameters; maybe even color of certain elements or even calculating the > result of combining certain elements. > I was looking for something simple, but everything I see seems to be a > full blown chemistry set. > I know I can probably spend a day doing this one element at a time, but > I was wondering if there is already something like this done in a small > scale? > Thanks for any information > Astan > > -- > "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." > > Animal Logichttp://www.animallogic.com > > Please think of the environment before printing this email. > > This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. From Manisa999 at gmail.com Sat Apr 26 01:19:10 2008 From: Manisa999 at gmail.com (Manisa999 at gmail.com) Date: Fri, 25 Apr 2008 22:19:10 -0700 (PDT) Subject: Hard & Soft Parts Available Here X Message-ID: <45efd8be-75f7-4445-b2bf-f9ab06a8fb7b@a9g2000prl.googlegroups.com> SEXY SEGMENT *********************************** http://bigsexmovies.notlong.com/ http://indiansexx.notlong.com/ *********************************** From gagsl-py2 at yahoo.com.ar Mon Apr 28 03:27:51 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 28 Apr 2008 04:27:51 -0300 Subject: error: (10035, 'The socket operation... References: Message-ID: En Sun, 27 Apr 2008 21:41:57 -0300, Benjamin Kaplan escribi?: >> On Sun, Apr 27, 2008 at 7:01 PM, Don Hanlen wrote: >> > IDLE internal error in runcode() >> > Traceback (most recent call last): >> > File "C:\PYTHON25\lib\idlelib\rpc.py", line 235, in asyncqueue >> > self.putmessage((seq, request)) >> > File "C:\PYTHON25\lib\idlelib\rpc.py", line 332, in putmessage >> > n = self.sock.send(s[:BUFSIZE]) >> > error: (10035, 'The socket operation could not complete without >> > blocking') >> > >> > Does this look familiar to anyone? I can't figure out what to do >> > about it. Python 2.5, windoze. I get it when I execute a Tkinter op >> > that works elsewhere. >> It might have something to do with the fact that IDLE uses Tkinter, >> but, having never used it myself, I'm not sure. I think IDLE doesn't work well with Tkinter apps, they compete for the main loop. But perhaps that's already been resolved in recent releases. Anyway this looks like a different problem, I'd file a bug at bugs.python.org In the meantime, run your app from the command line instead of from inside IDLE. -- Gabriel Genellina From marlin_rowley at hotmail.com Thu Apr 10 14:58:44 2008 From: marlin_rowley at hotmail.com (Marlin Rowley) Date: Thu, 10 Apr 2008 13:58:44 -0500 Subject: Reading floats through Telnet object? In-Reply-To: References: Message-ID: Is there any function that allows reading a stream of floats through the Telnet Object? There doesn't seem to be a way to control reading from the socket accept read_until() and that requires a string. -M _________________________________________________________________ Use video conversation to talk face-to-face with Windows Live Messenger. http://www.windowslive.com/messenger/connect_your_way.html?ocid=TXT_TAGLM_WL_Refresh_messenger_video_042008 -------------- next part -------------- An HTML attachment was scrubbed... URL: From andreas.eisele at gmail.com Sat Apr 12 07:02:21 2008 From: andreas.eisele at gmail.com (andreas.eisele at gmail.com) Date: Sat, 12 Apr 2008 04:02:21 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection Message-ID: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> In an application dealing with very large text files, I need to create dictionaries indexed by tuples of words (bi-, tri-, n-grams) or nested dictionaries. The number of different data structures in memory grows into orders beyond 1E7. It turns out that the default behaviour of Python is not very suitable for such a situation, as garbage collection occasionally traverses all objects in memory (including all tuples) in order to find out which could be collected. This leads to the sitation that creating O(N) objects effectively takes O(N*N) time. Although this can be cured by switching garbage collection off before the data structures are built and back on afterwards, it may easily lead a user not familiar with the fine details of garbage collection behaviour to the impression of weak scalability, which would be a pity, as the real problem is much more specific and can be cured. The problem is already clearly visible for 1M objects, but for larger numbers it gets much more pronounced. Here is a very simple example that displays the problem. > python2.5 -m timeit 'gc.disable();l=[(i,) for i in range(1000000)]' 10 loops, best of 3: 329 msec per loop > python2.5 -m timeit 'gc.enable();l=[(i,) for i in range(1000000)]' 10 loops, best of 3: 4.06 sec per loop > python2.5 -m timeit 'gc.disable();l=[(i,) for i in range(2000000)]' 10 loops, best of 3: 662 msec per loop > python2.5 -m timeit 'gc.enable();l=[(i,) for i in range(2000000)]' 10 loops, best of 3: 15.2 sec per loop In the latter case, the garbage collector apparently consumes about 97% of the overall time. I would suggest to configure the default behaviour of the garbage collector in such a way that this squared complexity is avoided without requiring specific knowledge and intervention by the user. Not being an expert in these details I would like to ask the gurus how this could be done. I hope this should be at least technically possible, whether it is really desirable or important for a default installation of Python could then be discussed once the disadvantages of such a setting would be apparent. Thanks a lot for your consideration, and best regards, Andreas ------ Dr. Andreas Eisele, Senior Researcher DFKI GmbH, Language Technology Lab, eisele at dfki.de Saarland University Computational Linguistics Stuhlsatzenhausweg 3 tel: +49-681-302-5285 D-66123 Saarbr?cken fax: +49-681-302-5338 From andrew.english at gmail.com Wed Apr 30 00:30:37 2008 From: andrew.english at gmail.com (Andrew English) Date: Wed, 30 Apr 2008 00:30:37 -0400 Subject: ffmpeg hangs when executed from python Message-ID: <84b9d8200804292130n1d412f49nd95d4237b7bba2f6@mail.gmail.com> I have tried a few methods of executing ffmpeg from within python and it has hanged every time. Two of the configurations I tried are: def convertFileToFlash(filename): commandString = "./convertasftoswf.sh " + getSaveDirectory() + " " + filename logging.debug("RUNNING: " + commandString) results = commands.getstatusoutput(commandString) logging.debug(results) convertasftoswf.sh: #!/bin/sh mencoder ${1}${2} -o ${1}outputfile.avi -ovc xvid -xvidencopts bitrate=280:max_bframes=0 -oac mp3lame -lameopts mode=0:cbr:br=128 -vf-add scale=320:240,expand=320:240 -vf-add harddup -ofps 25.00 -srate 44100 chmod 777 ${1}outputfile.avi ffmpeg -i ${1}outputfile.avi ${1}${2}.swf Also, I tried running each of the commands (mencoder and ffmpeg) separately with the commands.getstatusoutput from within python. Then mencoder call always runs without a problem and the ffmpeg always hangs. Running the shell script directly from the command line works as expected. Any ideas about why ffmpeg would hang in that situation? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From billingspanshism at gmail.com Sat Apr 19 17:16:36 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:16:36 -0700 (PDT) Subject: victoria beckham biography Message-ID: Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From rhamph at gmail.com Wed Apr 16 12:27:59 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Wed, 16 Apr 2008 09:27:59 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> On Apr 16, 6:56 am, Aaron Watters wrote: > I don't get it. It ain't broke. Don't fix it. So how would you have done the old-style class to new-style class transition? From sbergman27 at gmail.com Thu Apr 17 15:40:49 2008 From: sbergman27 at gmail.com (Steve Bergman) Date: Thu, 17 Apr 2008 12:40:49 -0700 (PDT) Subject: How to make this unpickling/sorting demo faster? References: <40a5d8f1-a246-4c48-8759-5b65324f9029@m73g2000hsh.googlegroups.com> <493d67b3-ea8f-4662-86fc-c764a7d47a02@8g2000hse.googlegroups.com> Message-ID: > THe above is applied slavishly by those who value machine time over > peoples time. Do you want to work with them? I understand where you are coming from. But in writing the code snippet I learned something about pickling/unpickling, which I knew *about* but had never actually used before. And also learned the quick and easy way of DSU sorting, which got easier and faster in 2.4. So, personally, I'm ahead on this one. Otherwise, I agree that arguing the matter in long flame threads is a waste of time. From arnodel at googlemail.com Wed Apr 9 15:57:30 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Wed, 9 Apr 2008 12:57:30 -0700 (PDT) Subject: Python 3.0 new integer division References: Message-ID: On Apr 9, 8:35?pm, Mark Dickinson wrote: > Strictly speaking, BCD doesn't come into it: ?the coefficient of a > Decimal instance is stored simply as a string of digits. ?This is > pretty wasteful in terms of space: ?1 byte per decimal digit > instead of the 4 bits per digit that BCD gives, but it's > convenient and fairly efficient. > > An alternative representation that's gained popularity recently is > DPD (densely packed decimal), which packs 3 decimal digits into 10 > bits in a clever way that allows reasonably efficient extraction > of any one of the 3 digits. ?Decimal doesn't use this either. :) > > Mark Naive question: why not just use a long + an exponent? e.g. 132560 -> (13256, 1) 0.534 -> (534, -3) 5.23e10 -> (523, 8) -- Arnaud From castironpi at gmail.com Sun Apr 27 10:17:01 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sun, 27 Apr 2008 07:17:01 -0700 (PDT) Subject: Random/anonymous class methods References: <801e1c38-ae54-443c-8d87-9745db7ef270@59g2000hsb.googlegroups.com> Message-ID: <89ba37e2-49dd-4f95-87c2-95cba9f660ab@56g2000hsm.googlegroups.com> On Apr 27, 7:11?am, Arnaud Delobelle wrote: > philly_bob writes: > > In the sample program below, I want to send a random method to a class > > instance. > > In other words, I don't know which method to send until run-time. ?How > > can I send ch, which is my random choice, to the myclass instance? > > > Thanks, > > > Bob= > > > #### > > import random > > > class myclass(object): > > ? ?def meth1(self): > > ? ? ? print 'meth1' > > ? ?def meth2(self): > > ? ? ? print 'meth2' > > > c=myclass() > > meths=['meth1', 'meth2'] > > ch=random.choice(meths) > > c.ch() > > This will work: > getattr(c, ch)() > > Getattr(c, "meth1") is equivalent to c.meth1. ?Or you could do: > > meths = [c.meth1, c.meth2] > ch = random.choice(meths) > ch() > > -- > Arnaud- Hide quoted text - > > - Show quoted text - MethodType constructors can't be subclassed nor aren't guaranteed consistent. Inferrably, it's because there's more than one way to do it. The way C used to do it was by ordinal, which turns into Java-style reflection. If you use non-linear operation time, string lookup can actually exceed running value of the dollar that Python is on. Do you want the reliability of compile-time errors to do brainwork? If you're chasing running time on member look-up, you may be at an Python entry bottleneck. The class is the only structure that knows what function to run on what object. If you are looking for just a clean -syntax- to denote a uni- dimensional bit by a string of symbols (write 'that' down), you would keep methods in synch across *del+setattr*, specifically, changes. To walk through it: you have a method name from an unknown source, and you want to know different addresses of functions with that name. >>> read 'foo'. 'foo' is a method of more than one object. >>> 'bar'.'foo' 'foo' method of 'bar'. >>> 'cat'.'foo' 'foo' method of 'cat' >>> call cat.foo a thousand times What steps did the interpreter take? If you mutate 'foo', what should 'cat'.'foo' do? Strings aren't immutable in the generic language. If you mutate 'cat', what should 'cat'.'foo' do? If you keep a ('cat','foo') pair in memory (which is why I keep metioning two- dimensional arrays, they're just sparsely populated), you can hash the intersection to a specific bit, but it may not be faster than hash lookups on 'cat' and 'foo' combined. Won't you change the contents of 'cat'? An object-method pair-wise lookup could make more bucks. Do you want more than two? Isn't a generic n-dimensional lookup from linear memory a hash table anyway? You make a case that rigid static lookups are live and useful, and someone else makes the case that users like dynamic lookups, perhaps a more even cross-section of them or something. Rigid statics would be in hardware. Can Python live if hardware comes to support it? From kyosohma at gmail.com Thu Apr 24 10:33:14 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Thu, 24 Apr 2008 07:33:14 -0700 (PDT) Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> <480fa6e3$0$34491$742ec2ed@news.sonic.net> Message-ID: On Apr 23, 4:27?pm, John Nagle wrote: > Tim Golden wrote: > > John Nagle wrote: > >> Mike Driscoll wrote: > >>> Ken, > > >>> On Tue, Apr 22, 2008 at 1:36 PM, Kenneth McDonald > >>> wrote: > >>>> Sadly. > > >>>> ?Thanks, > >>>> ?Ken > >>>> ?-- > >>>> ?http://mail.python.org/mailman/listinfo/python-list > > >>> I've attached the 2.4 version. I also have some Windows binaries for > >>> Beautiful Soup uploaded to my website: > >>>http://www.pythonlibrary.org/python_modules.htm > > >> ? ?What on earth do you need a "Windows binary" for? ?"BeautifulSoup" > >> is ONE PYTHON SOURCE FILE, "BeautifulSoup.py". > > > Ummm.. Why does it bother you? Mike seems to be offering a public > > service to Windows users: by downloading the .exe, I can double-click > > on one file, have the module or package installed (whether it contains > > one .py file or twenty or a series of compiled extension modules and > > their respective DLLs) and for a bonus it's registered in the system > > packages directory [*] and is therefore uninstallable from there. > > ? ? ?Executing strange executables is risky. ?One always wonders what > else they install in addition to what they're supposed be installing. > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? John Nagle This is a legitimate issue and one I don't know how to solve. It would be nice to have some kind of verification process, but I'm unaware of anything affordable. If you have any ideas, feel free to express them. I hope to get testimonials from developers or pythoneers eventually. Suggestions are welcome. Mike From Lie.1296 at gmail.com Sun Apr 13 05:09:45 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 13 Apr 2008 02:09:45 -0700 (PDT) Subject: from __future__ import print References: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> Message-ID: On Apr 11, 7:26 pm, Bruno Desthuilliers wrote: > samsli... at gmail.com a ?crit : > > > Am I the only one that thinks this would be useful? :) > > > I'd really like to be able to use python 3.0's print statement in > > 2.x. > > > FWIW, the whole point is that in 3.0, print stop being a statement to > become a function... > But the reason it becomes a function is because being a statement it is inflexible and there is no way to pass arguments to the print function, at the cost of extra typing of parentheses. I wish py3k would make it an option whether to treat print as statement or function though. Since not all programs require the power of print as a function and having to type the extra parentheses is a bit tiring if you're printing lots of things. Probably it may be coupled with a translator (for source code from statement to function, since the reverse would not be practical) if you changed your mind. From DrColombes at yahoo.com Thu Apr 10 19:45:27 2008 From: DrColombes at yahoo.com (Dr. Colombes) Date: Thu, 10 Apr 2008 16:45:27 -0700 (PDT) Subject: How to modify EVDEV.py to record ASCII characters instead of keystrokes ? Message-ID: <58347b7b-c786-4ed5-ae28-dcfd92d8f8f8@q27g2000prf.googlegroups.com> I've used EVDEV.py successfully as a keystroke logger on Linux machines. How should EVDEV.py be modified to function as an ASCII character logger? That is, to record upper and lower case letters, lower case "5" and upper case "%" characters, etc. Shift and Caps Lock key press events are recorded by EVDEV.py, but the press event of the Shift and Caps Lock keys do not specify which, if any, of the subsequent keys are to be interpreted as "upper case" characters. Thanks for your suggestions. From hnikbakhsht at yahoo.com Fri Apr 4 11:37:03 2008 From: hnikbakhsht at yahoo.com (hassan nikbakhsh) Date: Fri, 4 Apr 2008 08:37:03 -0700 (PDT) Subject: Very good Python Book. Free download : Beginning Python: From Novice to Professional Message-ID: <556360.42077.qm@web37102.mail.mud.yahoo.com> can i have a free bownload of this book many thanks --------------------------------- You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost. -------------- next part -------------- An HTML attachment was scrubbed... URL: From sami.islam at btinternet.com Sun Apr 6 04:54:37 2008 From: sami.islam at btinternet.com (Sami) Date: Sun, 06 Apr 2008 09:54:37 +0100 Subject: Problems trying to hook own exception function to sys.excepthook Message-ID: Hello, I am new to Python. I tried to hook my own ExceptionPrintingFunction sys.excepthook but it does not work. This is what I wrote: ----------------------------------------------------------------------- import sys def MyOwnExceptHook(typ, val, tb): print "Inside my own hook" sys.excepthook = MyOwnExceptHook x = 1/0 ----------------------------------------------------------------------- This is what I get ----------------------------------------------------------------------- Traceback (most recent call last): File "E:/Home/Programming/Python/TryProjects/ExceptHandling1/Except5.py", line 8, in x = 1/0 ZeroDivisionError: integer division or modulo by zero ----------------------------------------------------------------------- I never see "Inside my own hook" which tells me that the hook is not being called. What I really want to test is to stop the exception from propagating further and leave the program intact. What am I doing wrong? Please let me know if there are any other newbie groups that I should probably try in stead. Thanks Sami From Hook at somewhere.nowhere.co.au.it Sat Apr 19 09:58:39 2008 From: Hook at somewhere.nowhere.co.au.it (Hook) Date: 19 Apr 2008 13:58:39 GMT Subject: Inheritance confusion References: <4809932c$0$12307$c3e8da3@news.astraweb.com> Message-ID: <4809fa8f$0$11248$c3e8da3@news.astraweb.com> Thanks to everyone who replied. Kay and Mark put me on the right track immediately. Ben is quite right - the fragment that I posted couldn't have given that error, but I didn't want to post the whole thing - perhaps wrongly, I thought it wouldn't help clarify what I thought the problem was. And that was the real issue - I had managed to convince myself that I had a naming problem in one of my own modules somewhere. If anyone is interested in the background, I'm a long time Perl programmer trying to learn Python by converting a small set of standard, locally developed Perl libraries. It's an edifying experience, and I can understand why some colleagues like Python so much. Again, thanks for the help, it's appreciated. Hook From tarun.kap at gmail.com Tue Apr 29 09:56:24 2008 From: tarun.kap at gmail.com (TkNeo) Date: Tue, 29 Apr 2008 06:56:24 -0700 (PDT) Subject: SSL through python. possible ? Message-ID: I need to do SSL file transfer using python? Is there a library i can use ? Thanks. From gagsl-py2 at yahoo.com.ar Mon Apr 28 02:09:12 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 28 Apr 2008 03:09:12 -0300 Subject: Loading associated files References: <74862697-da58-4eb7-8d60-09aaef54b7ad@j22g2000hsf.googlegroups.com> <09337541-0b3e-4aaf-b26f-06a0f689e7dc@u12g2000prd.googlegroups.com> <850a01c2-d59e-4ee7-a344-796fd3cbb8aa@v23g2000pro.googlegroups.com> Message-ID: En Sun, 27 Apr 2008 19:13:06 -0300, escribi?: > No you didnt misunderstand the situation, i think i have confused > matters though!! When Ive got it working my program will read the data > within the file. But obviously for it to do that it needs to know > where the file is, hence the whole discussion. However to test things After reading the thread I'm confused as well. Try using an installer (like InnoSetup) to install your application. It can handle the .xyz registry stuff for you, among other things. -- Gabriel Genellina From tjreedy at udel.edu Fri Apr 4 21:31:57 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 4 Apr 2008 21:31:57 -0400 Subject: having list attribute to track max size References: Message-ID: wrote in message news:f4fe2704-92fd-4fee-a2a9-98d2edcc5a5d at o1g2000pra.googlegroups.com... | Lets say I have a dynamic list class (may be extended from list), | where I add and remove items during program. | a = [] | a.append(1) | .... | | I am trying to find is there easy way keep track of 'maximum size of | list reached" | so for example len(a) goes from 0->3->4->3 | If I call a.max_size_ever(), I will get 4 Here is a start: >>> class mlist(list): def __init__(self,it): list.__init__(self,it) self.maxlen = len(self) >>> ll = mlist((1,2,3)) >>> ll.maxlen 3 Now, add methods for the list grow methods (.append, .extend, and .__setslice__) which follow a call to the parent method with self.maxlen = max(self.maxlen, len(self)) # or equivalent code tjr From balta96428 at gmail.com Wed Apr 23 05:53:45 2008 From: balta96428 at gmail.com (balta96428 at gmail.com) Date: Wed, 23 Apr 2008 02:53:45 -0700 (PDT) Subject: serials and keygens Message-ID: serials and keygens http://cracks.12w.net F R E E C R A C K S From steve at holdenweb.com Thu Apr 17 14:07:18 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 17 Apr 2008 14:07:18 -0400 Subject: Prob. w/ Script Posting Last Value In-Reply-To: <4dc0cfea0804170922n2a96be20sc424a7e67742a12e@mail.gmail.com> References: <4dc0cfea0804170922n2a96be20sc424a7e67742a12e@mail.gmail.com> Message-ID: <480791D6.4000802@holdenweb.com> Victor Subervi wrote: > Hi; > Gabriel provided a lovely script for showing images which I am modifying > for my needs. I have the following line: > > print '

\n' % (d, y) > where the correct values are entered for the variables, and those values > increment (already tested). Here is the slightly modified script it calls: > > > #!/usr/local/bin/python > import cgitb; cgitb.enable() > import MySQLdb > import cgi > form = cgi.FieldStorage() > picid = int(form["id"].value) > x = int(form["x"].value) > pic = str(x) > print 'Content-Type: text/html' > db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > cursor= db.cursor() > sql = "select " + pic + " from products where id='" + str(picid) + "';" > cursor.execute(sql) > content = cursor.fetchall()[0][0].tostring() > cursor.close() > print 'Content-Type: image/jpeg\r\nContent-Length: %s\n' % len(content) > print content > > I need to make it so that it will show all my images, not just the last > one. Suggestions, please. > TIA, > Victor > In your "page generator" page, replace print '

\n' % (d, y) by for d, y in (results of some DB query to get d and y for each image): print '

\n' % (d, y) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gagsl-py2 at yahoo.com.ar Mon Apr 21 01:15:11 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 02:15:11 -0300 Subject: MySQL hardcoding? References: <20080417194149.eddefdc8.marexposed@googlemail.com> Message-ID: En Thu, 17 Apr 2008 15:41:49 -0300, escribi?: > I've got this error (see the path in last line) > > db=MySQLdb.connect(host='localhost',use_unicode = True, charset = "Windows-1251",user='root',passwd='12',db='articulos') > OperationalError: (2019, "Can't initialize character set Windows-1251 (path: C:\\mysql\\\\share\\charsets\\)") > > The truth of the matter is, MySQL is not installed in that path, but into Program Files. > I don't know where the hardcoding is, but it is certainly somewhere. Except MySQL is reporting a wrong installation path. > I haven't found any other topic in the list about this problem. Looks like a configuration problem in MySQL itself, unrelated to Python. See the my.ini file in MySQL installation directory. -- Gabriel Genellina From bj_666 at gmx.net Wed Apr 2 14:11:15 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 2 Apr 2008 18:11:15 GMT Subject: non-terminating regex match References: Message-ID: <65i0i3F2embp3U2@mid.uni-berlin.de> On Wed, 02 Apr 2008 16:01:59 +0000, Maurizio Vitale wrote: > And yes, I'm a total beginner when it comes to Python, but it seems > very strange to me that a regex match on a finite length string > doesn't terminate It does terminate, you just don't wait long enough. Try it with fewer characters and then increase the identifier character by character and watch the time of the runs grow exponentially. Ciao, Marc 'BlackJack' Rintsch From damonwischik at gmail.com Fri Apr 18 22:18:12 2008 From: damonwischik at gmail.com (damonwischik at gmail.com) Date: Fri, 18 Apr 2008 19:18:12 -0700 (PDT) Subject: How to print a unicode string? References: Message-ID: On Apr 19, 12:38 am, Damon Wischik wrote: > I'd like to print out a unicode string. > > I'm running Python inside Emacs, which understands utf-8, so I want to > force Python to send utf-8 to sys.stdout. Thank you everyone who was sent suggestions. Here is my solution (for making Python output utf-8, and persuading Emacs 22.2.1 with python- mode to print it). 1. Set the registry key HKEY_CURRENT_USER\Software\GNU\Emacs\Home to have value "d:\documents\home". This makes Emacs look for a .emacs file in this directory (the home directory). 2. Put a file called .emacs file in the home directory. It should include these lines: (setenv "PYTHONPATH" "d:/documents/home") (prefer-coding-system 'utf-8) The first line means that python will look in my home directory for libraries etc. The second line tells Emacs to default to utf-8 for its buffers. Without the second line, Emacs may default to a different coding, and it will not know what to do when it receives utf-8. 3. Put a file called sitecustomize.py in the home directory. This file should contain these lines: import codecs import sys sys.stdout = codecs.getwriter("UTF-8")(sys.stdout) 4. Now it should all work. If I enter print u'La Pe\xf1a' then it comes out with a n-tilde. NB. An alternative solution is to edit site.py in the Python install directory, and replace the line encoding = "ascii" # Default value set by _PyUnicode_Init() with encoding = 'utf8' But the trouble with this is that it will be overwritten if I install a new version of Python. NB. I also have these lines in my .emacs file, to load python-mode, and to make it so that ctrl+enter executes the current paragraph: ; Python file association (load "c:/program files/emacs-plugins/python-mode-1.0/python-mode.el") (setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist)) (setq interpreter-mode-alist (cons '("python" . python-mode) interpreter-mode-alist)) (autoload 'python-mode "python-mode" "Python editing mode." t) ; Note: the command for invoking Python is specified at the end, ; as a custom variable. ;; DJW's command to select the current paragraph, then execute-region. (defun py-execute-paragraph (vis) "Send the current paragraph to Python Don't know what vis does." (interactive "P") (save-excursion (forward-paragraph) (let ((end (point))) (backward-paragraph) (py-execute-region (point) end )))) (setq py-shell-switch-buffers-on-execute nil) (global-set-key [(ctrl return)] 'py-execute-paragraph) (custom-set-variables ;; custom-set-variables was added by Custom -- don't edit or cut/ paste it! ;; Your init file should contain only one such instance. '(py-python-command "c:/program files/Python25/python.exe")) Damon. From deets at nospam.web.de Fri Apr 11 13:03:25 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 11 Apr 2008 19:03:25 +0200 Subject: Multiple independent Python interpreters in a C/C++ program? In-Reply-To: References: Message-ID: <669jv8F2jrimvU1@mid.uni-berlin.de> skip at pobox.com schrieb: > This question was posed to me today. Given a C/C++ program we can clearly > embed a Python interpreter in it. Is it possible to fire up multiple > interpreters in multiple threads? For example: > > C++ main > thread 1 > Py_Initialize() > thread 2 > Py_Initialize() > > Do I wind up with two completely independent interpreters, one per thread? > I'm thinking this doesn't work (there are bits which aren't thread-safe and > are only protected by the GIL), but wanted to double-check to be sure. AFAIK there was a thread a few month ago that stated that this is actually possible - but mostly 3rd-party-c-extension aren't capable of supporting that. Martin von Loewis had a word in that, maybe googling with that in mind reveals the discussion. And of course its a *bad* idea to pass objects between threads... Diez From parnell.s at comcast.net Sun Apr 27 15:34:25 2008 From: parnell.s at comcast.net (Ixiaus) Date: Sun, 27 Apr 2008 12:34:25 -0700 (PDT) Subject: Python equivalent to PHP's SPL __autoload() ?? Message-ID: <5bfb3fa2-652c-4ce5-b914-27ef21685c33@p25g2000pri.googlegroups.com> I was curious (and have spent an enormous amount of time on Google trying to answer it for myself) if Python has anything remotely similar to PHP's SPL __autoload() for loading classes on the fly?? After digging through docs I feel doubtful there is such a language feature, but, it is possible I missed something or maybe someone has written an extension?!? Thanks in advance! From hotani at gmail.com Wed Apr 23 14:45:42 2008 From: hotani at gmail.com (hotani) Date: Wed, 23 Apr 2008 11:45:42 -0700 (PDT) Subject: python-ldap: searching without specifying an OU? References: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> <58546d42-bc80-4f9d-be90-e184c312e2d1@k37g2000hsf.googlegroups.com> <0ke3e5-ccc.ln1@nb2.stroeder.com> <8ef38281-a6fe-4501-b711-a24cd9f35a24@t54g2000hsg.googlegroups.com> Message-ID: <0bbac44a-5d11-4e27-829d-ad2b2de62210@x35g2000hsb.googlegroups.com> This fixed it! http://peeved.org/blog/2007/11/20/ By adding this line after 'import ldap', I was able to search from the root level: ldap.set_option(ldap.OPT_REFERRALS, 0) From ed at leafe.com Tue Apr 1 09:31:26 2008 From: ed at leafe.com (Ed Leafe) Date: Tue, 1 Apr 2008 08:31:26 -0500 Subject: class super method In-Reply-To: References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> Message-ID: On Apr 1, 2008, at 7:23 AM, brooklineTom at gmail_spam_blocking_suffix.com wrote: > I've also found myself wondering: > > 1. What are the two arguments to super used for? To determine the type (1st arg) for which the superclass hierarchy is to be determined, and the instance (2nd arg) if the super object is to be bound. In typical usage, they are the class of the current instance, and the 'self' reference to the instance. > 2. What happens when the method supplied *after* the super is > different from the containing method? > > In the above example what happens if: > > class DaboUIClass(dabo.ui.dControlMixin, someWxPythonClass): > def __init__(self, *args, **kwargs): > doOurCustomStuffBeforeTheSuperCall() > super(DaboUIClass, self).callRandomMethod(foobar) > doOurCustomStuffAfterTheSuperCall() super() returns an object that doesn't "know" in what method it was derived, so as long as the superclass has the 'callRandomMethod' method, and 'foobar' is defined, there is no problem at all. IOW, the only context is the class of the instance, not any particular method of the instance. You could also do something like this: class DaboUIClass(dabo.ui.dControlMixin, someWxPythonClass): def __init__(self, *args, **kwargs): doOurCustomStuffBeforeTheSuperCall() self.super = super(DaboUIClass, self) self.super.__init__(*args, **kwargs) doOurCustomStuffAfterTheSuperCall() def someMethod(self, foo, bar): self.super.someMethod(foo, bar) def someOtherMethod(self): self.super.someOtherMethod() -- Ed Leafe From haxier at gmail.com Thu Apr 3 03:10:26 2008 From: haxier at gmail.com (haxier) Date: Thu, 3 Apr 2008 00:10:26 -0700 (PDT) Subject: Python for low-level Windows programming Message-ID: Hi all I've some experience with Python in desktop apps, but now I'm looking to code a tool like Kee-Pass[1] which must have access to some low- level primitives in a windows environment: hooks when windows are displayed, automatic form fill, and so on in a variety of scenarios (desktop apps, web-based apps, citrix...) Is this possible without too much pain? I know I can code it with C# or C++ but tha'ts a road to avoid, if possible. Thanks [1] http://sourceforge.net/projects/keepass From laurent.pointal at laposte.net Tue Apr 15 16:45:56 2008 From: laurent.pointal at laposte.net (Laurent Pointal) Date: 15 Apr 2008 20:45:56 GMT Subject: webcam (usb) access under Ubuntu References: Message-ID: <48051403$0$875$ba4acef3@news.orange.fr> Le Tue, 15 Apr 2008 05:21:54 -0700, Berco Beute a ?crit?: > I've been trying to access my webcam using Python, but I failed > miserably. The camera works fine under Ubuntu (using camora and skype), > but I am unable to get WebCamSpy or libfg to access my webcam. > > First I tried webcamspy (http://webcamspy.sourceforge.net/). That > requires pySerial and pyParallel, and optionally pyI2C. Runing WebCamSpy > results in: > > Exception exceptions.AttributeError: "Parallel instance has no attribute > '_fd'" in > ignored > > This seems to come from importing I2C. The application window opens, but > there's an error message: > > NO VIDEO SOURCE FOUND > > Next I tried libfg (http://antonym.org/libfg). I built it, made the > Python bindings and installed it. Unfortunately the following: > >>>>import fg >>>>grabber = fg.Grabber() > > results in: > > fg_open(): open video device failed: No such file or directory > > Since the camera works fine in Ubuntu itself my guess is that the > problem is with the python libraries (or even likelier, my usage of > them). Is there anybody here that was successful in accessing their > webcam on linux using Python? Else I have to reside to Windows and > VideoCapture (which relies on the win32 api and thus is Windows-only), > something I'd rather not do. > > Thanks for any help, I dont know if this resolve your problem, but to get snapshots from a camera under linux, using V4L2 API, I wrote a small wrapper around this API. Its called pyvideograb, and its here: http://laurent.pointal.org/python/projets/pyvideograb/index.pih Note: there is no automatic thing in this library, just a wrapper to V4L2, so you must know what options and image format your camera support and use these (you may have to convert image by yourself - see PIL and Numpy for quick data processing functions). To find the supported options you can use xawtv and give it ad-hoc cli option to make it verbose. A+ Laurent. -- Laurent POINTAL - laurent.pointal at laposte.net From medin0065 at gmail.com Sun Apr 20 10:46:30 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:46:30 -0700 (PDT) Subject: active camera crack Message-ID: <3275425d-9867-42d2-a4b4-62f8f131f420@p25g2000pri.googlegroups.com> active camera crack http://cracks.00bp.com F R E E C R A C K S From gatti at dsdata.it Sat Apr 12 12:32:03 2008 From: gatti at dsdata.it (Lorenzo Gatti) Date: Sat, 12 Apr 2008 09:32:03 -0700 (PDT) Subject: str(bytes) in Python 3.0 References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> <806cf1da-8f06-4fff-8437-7f1ca1ff9472@k10g2000prm.googlegroups.com> Message-ID: On Apr 12, 5:51 pm, Kay Schluehr wrote: > On 12 Apr., 16:29, Carl Banks wrote: > > > > And making an utf-8 encoding default is not possible without writing a > > > new function? > > > I believe the Zen in effect here is, "In the face of ambiguity, refuse > > the temptation to guess." How do you know if the bytes are utf-8 > > encoded? > > How many "encodings" would you define for a Rectangle constructor? > > Making things infinitely configurable is very nice and shows that the > programmer has worked hard. Sometimes however it suffices to provide a > mandatory default and some supplementary conversion methods. This > still won't exhaust all possible cases but provides a reasonable > coverage. There is no sensible default because many incompatible encodings are in common use; programmers need to take responsibility for tracking ot guessing string encodings according to their needs, in ways that depend on application architecture, characteristics of users and data, and various risk and quality trade-offs. In languages that, like Java, have a default encoding for convenience, documents are routinely mangled by sloppy programmers who think that they live in an ASCII or UTF-8 fairy land and that they don't need tight control of the encoding of all text that enters and leaves the system. Ceasing to support this obsolete attitude with lenient APIs is the only way forward; being forced to learn that encodings are important is better than, say, discovering unrecoverable data corruption in a working system. Regards, Lorenzo Gatti From watches0802 at global-replica-watch.com Sat Apr 19 06:17:49 2008 From: watches0802 at global-replica-watch.com (watches0802 at global-replica-watch.com) Date: Sat, 19 Apr 2008 03:17:49 -0700 (PDT) Subject: Mondaine Women's Railway watch #A669.30305.11SBC - Replica Watch Fake Message-ID: Mondaine Women's Railway watch #A669.30305.11SBC - Replica Watch Fake Mondaine Women's Railway watch #A669.30305.11SBC Link : http://www.watchesprice.net/Replica-Mondaine-10291.html Replica Watches Home : http://www.watchesprice.net/ Replica Mondaine Brands : http://www.watchesprice.net/Mondaine-Replica.html Replica Mondaine Women's Railway watch #A669.30305.11SBC --- one of best selling replica watches, it is crafted in high quality, please click image 'buy now' to buy this chic but inexpensive replica to save you a lot of money . Mondaine Women's Railway watch A669.30305.11SBC Description: Swiss quartz movement, Casual watch, Black hands and hour markers, Black indices, Analog date display, Polished stainless steel silver- tone bezel, case, crown and caseback, 30 meters/100 feet water resistant Mondaine Women's Railway watch A669.30305.11SBC Details: Brand: Mondaine Model: A669.30305.11SBC Dimensions: .7 pounds Dial color: Polished stainless steel silver-tone case, White Water-resistant to 30 meters Thank you for choosing www.watchesprice.net as your reliable dealer of quality waches including Mondaine Women's Railway watch #A669.30305.11SBC . we guarantee every watch you receive will be exact watch you ordered. Each watch sold enjoy one year Warranty for free repair. Every order from aaa-replica-watches is shipped via EMS, the customer is responsible for the shipping fee on the first order, but since the second watch you buy from our site, the shipping cost is free. Please note that If the total amount of payment is over $600(USD), the customer is required to contact our customer service before sending the money in case failed payment. If you have any other questions please check our other pages or feel free to email us by service at watchesprice.net. Cheapest Mondaine Women's Railway watch #A669.30305.11SBC The Same Mondaine Series : Mondaine - A6693031111SBB (Size: women) : http://www.watchesprice.net/Replica-Mondaine-10292.html Mondaine A6873030814sbb Line Extension Unisex Watch : http://www.watchesprice.net/Replica-Mondaine-10293.html Mondaine - A6903030814SBB (Size: men) : http://www.watchesprice.net/Replica-Mondaine-10294.html Mondaine A6873030811sbb Line Extension Unisex Watch : http://www.watchesprice.net/Replica-Mondaine-10295.html Mondaine A6663032214sbb Line Extension Unisex Watch : http://www.watchesprice.net/Replica-Mondaine-10296.html Mondaine Men's Railways watch #A669.30308.64SBB : http://www.watchesprice.net/Replica-Mondaine-10297.html Mondaine Men's Railway watch #A660.30303.14SBB : http://www.watchesprice.net/Replica-Mondaine-10298.html Mondaine Men's Watches Specials A658.30300.11GEB - 5 : http://www.watchesprice.net/Replica-Mondaine-10299.html From fredrik at pythonware.com Sat Apr 5 07:23:36 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 13:23:36 +0200 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> Message-ID: llothar wrote: > I ship an application that compiles an python interpreter and > extension on a remote system. > It also needs to copy this created items around. So if i use setup.py > to create an > extension i need to know the file name of the generated file. so why not just ask setup.py to copy the files for you? you can either use "install" with the --home option to copy all the files to a given directory, or create a binary kit with "bdist" and unpack the resulting archive at the target location. > Unfortunately as pointless as the answers i got so far. well, cutting the "I'm not going to tell you why I need to know this" stuff might help people come up with solutions to your actual problem instead of posting stuff that's informative but misses the point. From paul at boddie.org.uk Mon Apr 21 11:17:04 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Mon, 21 Apr 2008 08:17:04 -0700 (PDT) Subject: Python "make" like tools (was Re: [ANN] DoIt 0.1.0 Released (build tool)) References: Message-ID: On 21 Apr, 16:51, "Ville M. Vainio" wrote: > > Wouldn't it be more convenient to provide syntax like this: > > @task("create_build_folder") > @depend("dep1 some_other_dep") > def buildf(): > buildFolder = jsPath + "build" > create_folder(buildFolder) I'd want to make the "grunt work" a bit easier before breaking out the decorators. > I find the doit syntax a bit cumbersome, especially as you can avoid > 'args' by just returning a lamda in 'action'. > > I've looked around a bit for python "make" replacement, but there does > not seem to be a simple & straightforward solution around (read - > straight-python syntax, one .py file installation, friendly license). Have you surveyed the landscape...? http://wiki.python.org/moin/ConfigurationAndBuildTools I'm inclined to think that Waf would probably meet your requirements: http://code.google.com/p/waf/ Paul From skanemupp at yahoo.se Tue Apr 15 16:45:08 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Tue, 15 Apr 2008 13:45:08 -0700 (PDT) Subject: tkinter, event.widget, what do i get? Message-ID: <7caa5089-2ea9-4e18-9117-7431d7403976@l42g2000hsc.googlegroups.com> when calling function hmm here, what do i get? the widget i clicked on? if i have a canvs on wich i have a bitmap and i click on the bitmap, is the event.widget then the bitmap? can i get info about the bitmap then? like color of the pixel i clicked. if so, how? w.bind("", key) w.bind("", hmm) def hmm(event): return event.widget From woodham at cs.ubc.ca Fri Apr 25 20:01:48 2008 From: woodham at cs.ubc.ca (Bob Woodham) Date: Sat, 26 Apr 2008 00:01:48 +0000 (UTC) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> <426812d7-c217-4bfc-81b0-47ba0638a650@k13g2000hse.googlegroups.com> <74415ef0-e395-4a31-90eb-e2645a65d464@e39g2000hsf.googlegroups.com> Message-ID: On 2008-04-24, Istvan Albert wrote: > On Apr 23, 2:08 pm, Bob Woodham wrote: > >> x = x++; >> >> has unspecified behaviour in C. That is, it is not specified >> whether the value of x after execution of the statement is the >> old value of x or one plus the old value of x. > > unspecified means that the result could be anything: old value, old > value+1, -2993882, "trallalla", core dump, stack overflow etc... One would certainly hope there are only two possible results, the old value of x or the incremented value of x. I first encountered this issue with a C compiler that produced one of those two results differently depending on the level of optimization requested. (Ultimately, it boiled down to the issue of whether the compiler allocated x to a register or as a standard memory reference). Rather than it being a bug, I was surprised to discover that the C compiler had not, in fact, violated the ANSI C standard. Note that x can be a pointer of arbitrary type. Thus, it is not beyond the realm of possibilty that a result different from what the programmer expected might indeed produce, in the end, -2993882, "trallalla", core dump, stack overflow etc... I don't have a copy of the ISO/ANSI C spec at hand. Harbison and Steele, Jr., "C a Reference Manual (4th ed)," section 7.12.1, page 228, state, "In ISO C, if a single object is modified more than once between successive sequence points, the result is undefined." Assuming Harbison and Steele quote the 1990 spec correctly, the word I should have used is "undefined." Can you live with that? Aside: Yes, the issue is that x = x++; modifies the single object x more than once between successive sequence points. From gherron at islandtraining.com Wed Apr 16 04:38:18 2008 From: gherron at islandtraining.com (Gary Herron) Date: Wed, 16 Apr 2008 01:38:18 -0700 Subject: Can't see variables declared as global in a function In-Reply-To: <175C22B8-EE9B-4FC2-BDB0-F1DC7EFD5F60@gmail.com> References: <175C22B8-EE9B-4FC2-BDB0-F1DC7EFD5F60@gmail.com> Message-ID: <4805BAFA.8050307@islandtraining.com> Jacob Davis wrote: > Hi. > > I have a hundred lines of code in a module that declare some global > variables inside a function so that those variables can be used by > other functions. I want to import this module so that I can more > easily debug by looking at the value of individual variables. But > when I try to reach these variables, I get a warning that they are not > defined. > > I am on an Intel Mac running Leopard 10.5.2, Python 2.5 > > Here is an example of some code that has the same problem: > > > > > #!/usr/bin/env python > > global isglobal > isglobal=200 > > def somefunc(): > global from_somefunc > from_somefunc=5 > > def anotherfunc(): > return from_somefunc+30 > > > > > So during debugging I want to look at the variable from_somefunc > > here is my terminal output. I start by looking at dir(), then > run somefunc(), then run anotherfunc(), then I want to look > at from_somefunc but I get a warning: Yuck, YUCK, YUCK! You are breaking *so* many good-programming-practices, I hardly know where to start. First off: A python global is not what you think. There are *no* program wide globals. There are only module wide globals. Also, the "global isglobal" is absolutely meaningless as anything declared there is a (module level) global by definition. SO... Your from_somefunc is a global variable in module test_vars, but you are trying to access it from your main module (the interactive session). The fact that you did "from test_vars import *" isn't going to fix this, because at the time you did the import, from_somefunc was not defined ad so was not imported by the "*". You could just "import test_vars", and then after calling your function test_vars.somefunc(), you would find that test_vars.from_somefunc would be defined. BUT... DON'T DO THAT! A better way: (It is still slightly dubious, but it is much more straightforward, and does not use the global statement.) Define your vars.py module: isglobal=200 # and nothing else And from your main program, import vars print vars.isglobal # will print 200 vars.from_somefunc = 5 # will define and set a global in vars print vars.from_somefunc+30 # retrieves a global value from vars As I said above this is still slightly dubious. Better solutions would probably involve creating a class with each of your huindred variables as attributes of the class, or a class, each instance of which has the hundred variables, or ... whatever. To give you better advice, we'd have to know more about what problem you are trying to solve. If you really getters and setters (that's what we might call somefucn and anotherfunc) then you really should be using a class to contain all the hundred variables, and define getter/setter methods for them. Gary Herron > > > > Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) > [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > >>> from test_vars import * > >>> dir() > ['__builtins__', '__doc__', '__name__', 'anotherfunc', 'isglobal', > 'somefunc'] > >>> somefunc() > >>> anotherfunc() > 35 > >>> isglobal > 200 > >>> from_somefunc > Traceback (most recent call last): > File "", line 1, in > NameError: name 'from_somefunc' is not defined > >>> dir() > ['__builtins__', '__doc__', '__name__', 'anotherfunc', 'isglobal', > 'somefunc'] > > > > Is there a way that I can view from_somefunc? > > Thanks, > > Jake > From robert.kern at gmail.com Thu Apr 10 17:43:25 2008 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 10 Apr 2008 16:43:25 -0500 Subject: get array element In-Reply-To: <820d8589-8529-46af-907a-90ebaac4a6f5@a22g2000hsc.googlegroups.com> References: <820d8589-8529-46af-907a-90ebaac4a6f5@a22g2000hsc.googlegroups.com> Message-ID: Bryan.Fodness at gmail.com wrote: > I have an array, and I would like to get the indice value. > > a = array([13,14,15,16]) > > I would like something like a.getindice(15) > > If I want 15 it would return 2 You will want to ask numpy questions on the numpy mailing list. If you don't mention that you are using numpy here, people get confused. http://www.scipy.org/Mailing_Lists Anyways, if your array is sorted, use a.searchsorted(15). If it isn't sorted, then you can find all of the indices equal to the value with the following: In [7]: from numpy import * In [8]: a = array([13,14,15,16]) In [9]: nonzero(a == 15)[0] Out[9]: array([2]) -- 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 From marco at sferacarta.com Tue Apr 1 06:00:12 2008 From: marco at sferacarta.com (Marco Mariani) Date: Tue, 01 Apr 2008 12:00:12 +0200 Subject: [OT] troll poll In-Reply-To: References: Message-ID: Daniel Fetchinson wrote: > This is a quick poll to have scientific data on our beloved troll community: > > Whose trolling behaviour is more professional? (check one) You forgot to mention Ilias Lazaridis. He needs to be Analyzed and Evaluated, too. From paulgeeleher at gmail.com Tue Apr 1 10:03:32 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Tue, 1 Apr 2008 07:03:32 -0700 (PDT) Subject: Copy Stdout to string Message-ID: Hi, I'm wondering if its possible to copy all of stdout's output to a string, while still being able to print on screen. I know you can capture stdout, but I still need the output to appear on the screen also... Thanks! From stefan_ml at behnel.de Sun Apr 20 10:20:54 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sun, 20 Apr 2008 16:20:54 +0200 Subject: codec for html/xml entities!? In-Reply-To: <2ohm04hm4sk0rn019tk1ntrii74hu8ajdo@4ax.com> References: <48084C97.4040400@behnel.de> <2ohm04hm4sk0rn019tk1ntrii74hu8ajdo@4ax.com> Message-ID: <480B5146.1070605@behnel.de> Martin Bless wrote: > [Stefan Behnel] wrote & schrieb: >>> def entity2uc(entity): >>> """Convert entity like { to unichr. >>> >>> Return (result,True) on success or (input string, False) >>> otherwise. Example: >>> entity2cp('€') -> (u'\u20ac',True) >>> entity2cp('€') -> (u'\u20ac',True) >>> entity2cp('€') -> (u'\u20ac',True) >>> entity2cp('&foobar;') -> ('&foobar;',False) >>> """ >> Is there a reason why you return a tuple instead of just returning the >> converted result and raising an exception if the conversion fails? > > Mainly a matter of style. When I'll be using the function in future > this way it's unambigously clear that there might have been > unconverted entities. But I don't have to deal with the details of how > this has been discovered. And may be I'd like to change the algorithm > in future? This way it's nicely encapsulated. The normal case is that it could be replaced, and it is an exceptional case that it failed, in which case the caller has to deal with the problem in one way or another. You are making the normal case more complicated, as the caller *always* has to check the result indicator to see if the return value is the expected result or something different. I don't think there is any reason to require that, except when the conversion really failed. Stefan From gagsl-py2 at yahoo.com.ar Tue Apr 22 13:26:01 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 22 Apr 2008 14:26:01 -0300 Subject: Spawing a thread and printing dots until it finishes References: Message-ID: En Tue, 22 Apr 2008 13:32:38 -0300, sophie_newbie escribi?: > On Apr 22, 4:41 pm, "D'Arcy J.M. Cain" wrote: >> On Tue, 22 Apr 2008 07:10:07 -0700 (PDT) >> sophie_newbie wrote: >> > import threading >> > class MyThread ( threading.Thread ): >> > def run ( self ): >> > myLongCommand()... >> >> > import time >> >> > t = MyThread() >> > t.start() >> >> > while t.isAlive(): >> > print "." >> > time.sleep(.5) >> >> > print "OK" >> >> > The thing is this doesn't print a dot every half second. It just >> > pauses for ages until the thread is finished and prints prints ".OK". >> > But if I take out the "time.sleep(.5)" line it will keep printing dots >> > really fast until the thread is finished. So it looks like its the >> > time.sleep(.5) bit that is messing this up somehow? >> >> We know that your main routine gives up the processor but without a >> full definition of MyThread how do we know that it ever does? I > > "myLongCommand()... " is a call to an function in R (the statistical > programming language) via Rpy (A python module that allows calls to > R). The call takes a couple of minutes to execute. I'm trying to build > a web front end to this R function and instead of the user looking at > a blank screen for 2-3 mins, I want to print dots to let them feel > like the program isn't hanging. > > What I am saying is that without the "time.sleep(.5)" line, the above > code will print dots on the screen continuously for 2-3 mins, filling > it up with a ridiculous ammount of dots. > > Whereas with the time.sleep line, instead of pausing for half a second > between dots, its seems to print, as you correctly pointed out: > > . > OK > > With a pause of 2-3 minutes between the . and the OK. A possible explanation is that the RPy call does not release the GIL; once the main thread loses it due to sleep, it can never reacquire it again until the RPy call finishes. Try contacting the RPy author, or perhaps there is a specific mailing list for RPy questions. -- Gabriel Genellina From jarausch at skynet.be Mon Apr 28 11:26:05 2008 From: jarausch at skynet.be (Helmut Jarausch) Date: Mon, 28 Apr 2008 17:26:05 +0200 Subject: Regular Expression - Matching Multiples of 3 Characters exactly. In-Reply-To: References: Message-ID: <4815ec8e$0$2994$ba620e4c@news.skynet.be> blaine wrote: > Hey everyone, > For the regular expression gurus... > > I'm trying to write a string matching algorithm for genomic > sequences. I'm pulling out Genes from a large genomic pattern, with > certain start and stop codons on either side. This is simple > enough... for example: > > start = AUG stop=AGG > BBBBBBAUGWWWWWWAGGBBBBBB > > So I obviously want to pull out AUGWWWWWWAGG (and all other matches). > This works great with my current regular expression. > > The problem, however, is that codons come in sets of 3 bases. So > there are actually three different 'frames' I could be using. For > example: > ABCDEFGHIJ > I could have ABC DEF GHI or BCD EFG HIJ or CDE FGH IJx.... etc. > > So finally, my question. How can I represent this in a regular > expression? :) This is what I'd like to do: > (Find all groups of any three characters) (Find a start codon) (find > any other codons) (Find an end codon) > > Is this possible? It seems that I'd want to do something like this: (\w > \w\w)+(AUG)(\s)(AGG)(\s)* - where \w\w\w matches EXACTLY all sets of > three non-whitespace characters, followed by AUG \s AGG, and then > anything else. I hope I am making sense. Obviously, however, this > will make sure that ANY set of three characters exist before a start > codon. Is there a way to match exactly, to say something like 'Find > all sets of three, then AUG and AGG, etc.'. This way, I could scan > for genes, remove the first letter, scan for more genes, remove the > first letter again, and scan for more genes. This would > hypothetically yield different genes, since the frame would be > shifted. > As an alternative - if you do need speed - have a look at http://www.egenix.com/products/python/mxBase/mxTextTools/ Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany From rbrito at ime.usp.br Mon Apr 28 16:56:36 2008 From: rbrito at ime.usp.br (=?ISO-8859-1?Q?Rog=E9rio_Brito?=) Date: Mon, 28 Apr 2008 17:56:36 -0300 Subject: Little novice program written in Python References: <49249992-3634-4c5f-bd45-7ce4f1b32044@l17g2000pri.googlegroups.com> Message-ID: On 04/25/2008 05:00 AM, John Machin wrote: > On Apr 25, 5:44 pm, Robert Bossy wrote: >> If the OP insists in not examining a[0] and a[1], this will do exactly >> the same as the while version: >> >> for p in a[2:]: >> if p: >> print p > > ... at the cost of almost doubling the amount of memory required. Yes, despite the asymptotic consumption of memory being the same, the practical one is also a concern. And in my original version of that loop (sketched in paper) was a for loop, but with C syntax. -- Rog?rio Brito : rbrito@{mackenzie,ime.usp}.br : GPG key 1024D/7C2CAEB8 http://www.ime.usp.br/~rbrito : http://meusite.mackenzie.com.br/rbrito Projects: algorithms.berlios.de : lame.sf.net : vrms.alioth.debian.org From Robert.Bossy at jouy.inra.fr Wed Apr 30 03:11:35 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Wed, 30 Apr 2008 09:11:35 +0200 Subject: sed to python: replace Q In-Reply-To: <48180348$0$34534$742ec2ed@news.sonic.net> References: <48180348$0$34534$742ec2ed@news.sonic.net> Message-ID: <48181BA7.1030604@jouy.inra.fr> Raymond wrote: > For some reason I'm unable to grok Python's string.replace() function. > Just trying to parse a simple IP address, wrapped in square brackets, > from Postfix logs. In sed this is straightforward given: > > line = "date process text [ip] more text" > > sed -e 's/^.*\[//' -e 's/].*$//' > alternatively: sed -e 's/.*\[\(.*\)].*/\1/' > yet the following Python code does nothing: > > line = line.replace('^.*\[', '', 1) > line = line.replace('].*$', '') > > Is there a decent description of string.replace() somewhere? > In python shell: help(str.replace) Online: http://docs.python.org/lib/string-methods.html#l2h-255 But what you are probably looking for is re.sub(): http://docs.python.org/lib/node46.html#l2h-405 RB From python.list at tim.thechases.com Tue Apr 15 16:15:47 2008 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 15 Apr 2008 15:15:47 -0500 Subject: Recurring patterns: Am I missing it, or can we get these added to the language? In-Reply-To: References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: <48050CF3.5050802@tim.thechases.com> >> def nsplit(s,p,n): >> n -= 1 >> l = s.split(p, n) >> if len(l) < n: >> l.extend([''] * (n - len(l))) >> return l > > The split() method has a maxsplit parameter that I think does the same > thing. For example: > >>>> temp = 'foo,bar,baz' >>>> temp.split(',', 1) > ['foo', 'bar,baz'] The OP's code *does* use the maxsplit parameter of split() The important (and missing) aspect of the OP's code in your example is exercised when there are *fewer* delimited pieces than "n": >>> "a,b,c".split(',', 5) ['a', 'b', 'c'] >>> nsplit("a,b,c", ',', 5) ['a', 'b', 'c', '', ''] A few things I noticed that might "improve" the code: - cache len(l) though my understanding is that len() is an O(1) operation, so it may not make a difference - using "delim", "maxsplit", "results" instead of "p", "n" "l" to make it easier to read -setting default values to match split() def nsplit(s, delim=None, maxsplit=None): if maxsplit: results = s.split(delim, maxsplit) result_len = len(results) if result_len < maxsplit: results.extend([''] * (maxsplit - result_len) return results else: return s.split(delim) My suggestion would just be to create your own utils.py module that holds your commonly used tools and re-uses them -tkc From ivan.illarionov at gmail.com Sun Apr 13 07:56:31 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Sun, 13 Apr 2008 04:56:31 -0700 (PDT) Subject: C to python conversion References: Message-ID: On Apr 13, 7:58 am, "Gabriel Genellina" wrote: > En Sat, 12 Apr 2008 07:58:47 -0300, Michele Petrazzo > escribi?: > > > > > Hi all, > > I'm trying to translate a simple C code into a python + ctypes (where > > need), but I have some problems on char conversion. The code have > > to work on Linux and talk with the serial port. I think that the problem > > is that I don't translate correctly the strings. > > > C code: > > #define START 0x33 > > #define RETURN_START 0x22 > > #define ADDR 0x01 > > #define WRITE_CMD 0x03 > > #define ALL_CMD 0xFF > > ... > > char buf[10]; > > char buf_ret[10]; > > > buf[0]=0; > > buf[0]=START; > > buf[1]=ADDR; > > buf[2]=WRITE_CMD; > > > write(_fd, buf, 6); > > read(_fd,buf_ret,6); > > You don't even need ctypes. In C, `char` is a small integer: 'A' and the > number 65 are interchangeable. In Python, there are no chars but strings > of length 1, which are not the same thing as their ordinal integer. > The easiest way is to define those constants as strings instead: > > START = chr(0x33) > RETURN_START = chr(0x22) > ADDR = chr(0x01) > WRITE_CMD = chr(0x03) > ALL_CMD = chr(0xFF) > NUL = chr(0) > > buf = START + ADDR + WRITE_CMD + NUL + NUL + NUL > # I assume the buffer was initialized to NULs, because only 3 bytes > # are filled but 6 bytes are written. > os.write(_fd, buf) > buf_ret = os.read(_fd, 6) > > -- > Gabriel Genellina The easiest way is to use struct: START = 0x33 RETURN_START = 0x22 ADDR = 0x01 WRITE_CMD = 0x03 ALL_CMD = 0xFF buf = struct.pack('3b3x', START, ADDR, WRITE_CMD) os.write(_fd, buf) buf_ret = os.read(_fd, 6) And, definitely, no need for ctypes here. -- Ivan Illarionov From hdante at gmail.com Mon Apr 21 21:00:10 2008 From: hdante at gmail.com (hdante) Date: Mon, 21 Apr 2008 18:00:10 -0700 (PDT) Subject: Java or C++? References: Message-ID: <2eae6385-1257-48fc-b793-31d0225503ba@f36g2000hsa.googlegroups.com> Summarizing the discussion (and giving my opinions), here's an "algorithm" to find out what language you'll leard next: 1. If you just want to learn another language, with no other essential concern, learn Ruby. 2. If you want to learn another language to design medium to large size applications, considering market, jobs, etc., and the speed gains of static byte-compiled languages, learn Java or C#. 3. If you want to learn another language to design applications with speed gains, but you want that the transition be as smooth as possible and don't have market concerns (and with the possibility of taking another easy step later to reach step 2), learn Groovy (for the JMV) or Boo (for .NET). 4. If you want to develop applications but, for some special reason, you require native compilation (like speed requirements, embedded systems, etc.), learn C++ 5. If you want to develop system software, or just learn better how machines work, or understand better low level implementation aspects of software, learn C. 6. If you just want to speed-up your python programs or offer some special, system-specific or optimized behavior to your python applications, or you just want to complement your python knowledge, learn C. On Apr 21, 7:26 pm, Jorgen Grahn wrote: > On Mon, 21 Apr 2008 06:14:08 -0700 (PDT), NickC wrote: > > On Apr 15, 1:46 pm, Brian Vanderburg II > > wrote: > >> This will automatically call the constructors of any contained objects > >> to initialize the string. The implicit assignment operator > >> automatically performs the assignment of any contained objects. > >> Destruction is also automatic. When 'p1' goes out of scope, during the > >> destructor the destructor for all contained objects is called. > > > Yeah, C++ does try to be helpful, and all of those automatic copy > > constructor, assignment operator and destructor implementations screw > > up royally when confronted with pointers > > I think that those are newbie problems. The rules for those three > "default implementations" are simple and match what C does for > structs. Use the standard containers, make a habit of forbidding > copying of objects which make no sense copying, and remember the > "explicit" keyword, and you will rarely have problems with this. > > > (and being able to use > > pointers is basically the whole reason for bothering to write anything > > in C or C++ in the first place). > > Is it? I rarely use pointers in C++ as anything but a kind of > object reference, and mostly because I am forced to. > > I use C++ because it is an expressive language with static typing, > which has access to all the hundreds of libraries with a C API on my > (Unix) machine. And because it is fun to use. > > I use Python because it is an expressive language with dynamic typing, > which has access to the most important libraries with a C API on my > (Unix) machine. And because it is fun to use. > > > Code which relies on these default > > method implementations is almost certain to be rife with memory leaks > > and double-free bugs. So instead of being a convenience, they become a > > painfully easy way of writing code that silently does some very, very > > wrong things. > > I have worked with old code with those kinds of bugs. > > It's simple to check and fix. If a class has pointer members of the > Has-A type, the constructors, operator= and destructor have to handle > them (or be suppressed). If they don't, the code is broken. > > If you grasp the concept of invariants, it's hard to get wrong. An > object of type Foo has a number of valid states. You have to make sure > there are no ways to create a Foo which is in an invalid state, or > destroying one without cleaning up its state. The best way is usually > to construct it from members which make similar guarantees, e.g. the > standard containers. > > > Other things like methods (including destructors!) being non-virtual > > by default also make C++ code annoyingly easy to get wrong (without it > > obviously looking wrong). > > The other side of the coin is that you can write tiny classes in C++ > with *no overhead*. If my class Foo can be implemented as an integer, > it doesn't need to be slower or take more space than an integer. It > can have value semantics, live on the stack etc, like an integer. > > I assume Java programmers avoid such types, and I assume it decreases > type safety in their programs. > > Ok, it could have been the other way around so that there was a > "nonvirtual" keyword ... but on the other hand I use inheritance in > C++ about as often as in Python, i.e. almost never. > > > The whole design of C++ is riddled with premature optimisation of > > speed and memory usage in the default settings, instead of choosing > > safe defaults and providing concise ways of allowing the programmer to > > say "I know optimisation X is safe here, please use it". > > "Premature optimization" is a phrase which is always useful as a > weapon, isn't it? > > But yeah, I think we can agree about this, at least: when you program > in both Python and C++, it is painfully obvious that C++ never > sacrifices speed or correctness, and it is painfully obvious that the > programmer pays a price for this. Compare ... maybe, for example, the > C++ standard library's very detailed and general iterator and > algorithm concepts with things like Python's str.split and str.join. A > function which takes a list of strings plus a delimiter and returns a > string would be unthinkable in the C++ standard library. > > > That said, C++ code has one *huge* benefit over ordinary C code, which > > is scope-controlled deletion of objects, and the associated Resource- > > Acquisition-Is-Initialisation model. > > Yes, RAII is one big advantage over any other language I know of. > Compared to good old C, I can come up with many others. > > I was going to say something about C++ versus Java here, but the fact > is I haven't written more than a few pages of Java since it came out. > The language (or the culture around it) seems to want to isolate itself > from the rest of the world -- unlike C++ and Python. > > /Jorgen > > -- > // Jorgen Grahn \X/ snipabacken.se> R'lyeh wgah'nagl fhtagn! From xahlee at gmail.com Thu Apr 17 19:06:56 2008 From: xahlee at gmail.com (xahlee at gmail.com) Date: Thu, 17 Apr 2008 16:06:56 -0700 (PDT) Subject: get quote enclosed field in a line Message-ID: is there a simple way in perl, python, or awk/shell/pipe, that gets the user agent field in a apache log? e.g. the typical line is like this: 189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET / Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/ 5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13" "-" I want the part: "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv: 1.8.1.13) Gecko/20080311 Firefox/2.0.0.13". Thanks. Xah xah at xahlee.org ? http://xahlee.org/ ? From martin at v.loewis.de Sat Apr 26 21:08:58 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 27 Apr 2008 03:08:58 +0200 Subject: How do I say "Is this a function"? In-Reply-To: References: Message-ID: <4813D22A.8040902@v.loewis.de> > def f1(): > print "In f1" > > def f3(): > print "In f3" > > def others(): > print "In others" > > for i in xrange(1,3): > fct = "f%d()"%(i+1) > try: > exec fct > except: > others() I'd write that as for i in xrange(1,3): globals().get("f%d" % (i+1), others)() Regards, Martin From steve at holdenweb.com Fri Apr 11 14:35:13 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 11 Apr 2008 14:35:13 -0400 Subject: How is GUI programming in Python? In-Reply-To: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> Message-ID: Rune Strand wrote: > On Apr 10, 3:54 am, Chris Stewart wrote: > ... >> Next, what would you say is the best framework I should look into? >> I'm curious to hear opinions on that. > > GUI-programming in Python is a neanderthal experience. What one may > love with console scripts is turned upside-down. Projects like Boa > Constructor seemed to be a remedy, but is not developed. The Iron- > Pythonistas has a very promising RAD GUI-tool in the IronPython - > Studio, http://www.codeplex.com/IronPythonStudio - but if you're non- > Iron, only sorrow is left - unless you fancy creating GUI in a text- > editor. Something I consider waste of life. > wxDesigner. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From steve at holdenweb.com Thu Apr 17 09:40:09 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 17 Apr 2008 09:40:09 -0400 Subject: I just killed GIL!!! In-Reply-To: <48070970.70306@v.loewis.de> References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> Message-ID: Martin v. L?wis wrote: >> For the record, I am not complaining about that GIL. As I said, I >> understand and approve of why it's there. I am, however, complaining >> about attitude that if you want to be free of the GIL you're doing >> something wrong. > > If you _want_ to be free of the GIL, you are not _doing_ anything, and > that may or may not be wrong. If you are complaining about the GIL, > I think you are doing something wrong, because complaining doesn't > help progress at all. I think neither was the case in this thread - > the guy claimed that he actually did something about the GIL, and > now we are all waiting for him to also tell us what it is that he > did. I think it is somewhat wrong to not tell in the first place, > but this is free software, and choosing not to contribute isn't > inherently wrong. Maybe the guy is making fun of us; whether that > is wrong or not depends on your notion of humor. > I suspect rather that he is merely deluded. Time alone will tell - the OP is a fertile source of ideas, not all of them fully baked, shall we say. I agree that the coyness in not immediately revealing the technique is less than helpful, and increases my assessment that the assertion of having "killed the GIL" will turn out to be wrong. I'd love to be wrong about that, but the GIL *has* been the subject of extensive efforts to kill it over the last five years, and it has survived despite the best efforts of the developers. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From xdicry at gmail.com Tue Apr 15 01:35:25 2008 From: xdicry at gmail.com (Evan) Date: Mon, 14 Apr 2008 22:35:25 -0700 (PDT) Subject: How to make a "command line basd" interactive program? References: Message-ID: that's great, a custom shell is what I need. Thanks all Evan From alexelder at gmail.com Tue Apr 29 11:11:44 2008 From: alexelder at gmail.com (alexelder at gmail.com) Date: Tue, 29 Apr 2008 08:11:44 -0700 (PDT) Subject: Using Python to verify streaming tv/radio station links References: Message-ID: <2e6baf9b-09d3-430e-9e01-cd56ec6e1a33@t54g2000hsg.googlegroups.com> On Apr 29, 1:52 pm, don... at gmail.com wrote: > Hi guys. I've put together a website (http://worldwidemediaproject.com > ) that is a database of internet streaming tv/radio stations from > around the world. I have built the site with all users in mind. The > site should be Linux, Unix, Mac, Win, etc friendly as I do not hide > the actual stream link or force the user to use an embedded player to > view/listen to the streams. In fact, you can even download the streams > you like as a playlist that you can load into your player of choice > (and even a few PVR software plugins). > > In building the site, I have enabled the user to report stations that > are nonfunctional. In addition to this, I would like to automate the > checking of the links in the database as well as any user submitted > links. What I am wanting to do is to script this with a simple for > loop which would loop through a file containing the station stream > link as well as the station id. I'd like to pass each through some > kind of verification function and if a connection is made then the > stream is good and move on to the next. If the connection fails then > the stream is bad, I would like to add the station id to a file > containing all 'nonfunctional' streams that I can later automate to > flag the stations. > > Is there an easy way to use python to verify a stream exists? I've > done a little experimenting with sockets and was able to connect to my > usenet server and talk to it, but I don't really know what's involved > with connecting to streaming windows media, real media and winamp > servers or what to expect as far as connection status messages. I am > not unfamiliar with python, but I am far from an expert. If anyone > could give me a hand with this or give me a push in the right > direction I would greatly appreciate it! > > Many thanks! Hey! With regards checking feeds, look into urllib (maybe) and the httplib (definitely). They /could/ offer some sort of information regarding the activity of your feeds. Without knowing anything about the streaming protocols I wouldn't suggest my methods to necessarily be the most helpful. You could, at least [maybe], establish whether a feed is active if it can return a HTTP 200 response. If that's a sufficient check I would suggest that httplib is the place to start. Alex. From BrianVanderburg2 at aim.com Mon Apr 21 02:01:42 2008 From: BrianVanderburg2 at aim.com (Brian Vanderburg II) Date: Mon, 21 Apr 2008 02:01:42 -0400 Subject: Is massive spam coming from me on python lists? Message-ID: <480C2DC6.4050701@aim.com> I've recently gotten more than too many spam messages and all say Sender: python-list-bounces+my=email.address at python.org. I'm wondering if my mail list registration is now being used to spam myself and others. If so, sorry, but I'm not the one sending messages if other are getting them even though Sender seems to include my address (I'm not sure about mail headers so I don't know how From: is different than Sender:) Anyway, it seems to be a bunch of spam emails about cracks and stuff. Brian Vanderburg II From carbanancizpo at gmail.com Fri Apr 18 16:55:47 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:55:47 -0700 (PDT) Subject: manufacturing crack cocaine Message-ID: manufacturing crack cocaine http://cracks.12w.net F R E E C R A C K S From nick at stinemates.org Wed Apr 23 23:51:08 2008 From: nick at stinemates.org (Nick Stinemates) Date: Wed, 23 Apr 2008 20:51:08 -0700 Subject: Calling Python code from inside php In-Reply-To: <679hd5F2nj6csU1@mid.uni-berlin.de> References: <679e9oF2mti63U1@mid.uni-berlin.de> <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> <679hd5F2nj6csU1@mid.uni-berlin.de> Message-ID: <20080424035108.GA6029@deviL> > While I certainly prefer to use Python wherever I can, that does not mean > that there aren't cases where legacy systems or other constraints make this > impossible. If I have e.g. a type3-based website - "how on earth" should I > replace that with Python (without wasting a lot of time)? I don't understand how the 2 are mutually exclusive? You can have PHP and Python bindings installed on the same Apache server, unless I'm mistaken? -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From marco at sferacarta.com Thu Apr 3 06:03:40 2008 From: marco at sferacarta.com (Marco Mariani) Date: Thu, 03 Apr 2008 12:03:40 +0200 Subject: splitting an XML file on the basis on basis of XML tags In-Reply-To: References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> Message-ID: <0Y1Jj.9751$T35.2972@tornado.fastwebnet.it> Steve Holden wrote: >> the XML file is almost a TB in size... >> > Good grief. When will people stop abusing XML this way? Not before somebody writes a clever xmlfs for the linux kernel :-/ From tundra at tundraware.com Tue Apr 1 18:51:46 2008 From: tundra at tundraware.com (Tim Daneliuk) Date: Tue, 01 Apr 2008 17:51:46 -0500 Subject: Directed Graph Traversal In-Reply-To: <804682cb-2da6-4d85-83d4-c7425c498534@p25g2000hsf.googlegroups.com> References: <804682cb-2da6-4d85-83d4-c7425c498534@p25g2000hsf.googlegroups.com> Message-ID: bukzor wrote: > Can someone point me in the direction of a good solution of this? I'm > using it to construct a SQL query compiler, where each node is a table > and each edge is a join. I'm planning on using the NetworkX library if > possible. > https://networkx.lanl.gov/reference/networkx/ > > > Given a directed graph and a list of points in the graph, what is the > minimal subgraph that contains them all? It is preferable that the > subgraph is a tree. > > > A -- B -- C -- D > | | > E -- F > > > A, B, F => ABEF (or ABCF) > A, F, C => ABCF > A, E, D => ABCD > E > > Thanks! > --Buck This leaps to mind: http://en.wikipedia.org/wiki/Kruskal's_algorithm The implementation details are left to the reader ;) -- ---------------------------------------------------------------------------- Tim Daneliuk tundra at tundraware.com PGP Key: http://www.tundraware.com/PGP/ From gagsl-py2 at yahoo.com.ar Tue Apr 1 12:34:30 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 13:34:30 -0300 Subject: python persistence References: <8b1723d9-67c8-4fe5-b07b-22b0b9311519@8g2000hsu.googlegroups.com> <7f58b5f4-3195-472c-b307-dec71b12aaa8@y21g2000hsf.googlegroups.com> <44f04bf3-4edc-4cb4-9e54-fe51b5e591bc@e39g2000hsf.googlegroups.com> <80d1731d-a3c6-4fce-81fd-9c3f3537e59b@d21g2000prf.googlegroups.com> <5386cf08-c155-4fbb-8373-dbbb9829a9e7@m3g2000hsc.googlegroups.com> <3c27b270-e593-4f2a-b881-68126319760c@8g2000hsu.googlegroups.com> <7d71e294-2b13-4be0-948e-2fe0e4bbe7db@f63g2000hsf.googlegroups.com> Message-ID: En Tue, 01 Apr 2008 08:47:33 -0300, escribi?: >> >>>> c['0']= type('None',(),{}) >> > Traceback (most recent call last): >> > pickle.PicklingError: Can't pickle : it's not >> > found as __main__.None >> >> Don't do that then. Or use the available pickle hooks to customize how ? >> such classes may be pickled. All persistence mechanisms have >> limitations. > > I don't see a problem with that; except that binaries come from > disks. You could have a Python session that runs entirely on disks + > the ALU. (ALU? Do you mean CPU?) I don't understand this. Most programs are read from disk. Most data is read from disk. > I want to know if any, and correct me here, simple > modification can store live objects. I call a.append(it) and the > memory update takes place on disk instead. Using ZODB, a.append(it) would mark `a` as dirty. When you latter commit the transaction, it is stored back on disk. > If you require that all objects referenced by on-disk objects be on- > disk, that's an easy workaround. ZODB already does that. -- Gabriel Genellina From wuwei23 at gmail.com Thu Apr 3 02:47:16 2008 From: wuwei23 at gmail.com (alex23) Date: Wed, 2 Apr 2008 23:47:16 -0700 (PDT) Subject: Where can I find : References: <13uu56hn1vdqb9d@corp.supernews.com> <768026ee-b9f1-4445-bd02-088a2f725a9d@b64g2000hsa.googlegroups.com> Message-ID: <65be3cc0-215c-4b22-b2ca-bb35131d2b29@s37g2000prg.googlegroups.com> On Apr 2, 10:08 pm, lbonaf... at yahoo.com wrote: > On Mar 30, 1:22 am, castiro... at gmail.com wrote: > > [the usual masturbatory castironpi ramble] > > What? Yeah, that's what pretty much everyone says regarding his posts. Very very little signal amongst that noise. From jim.hefferon at gmail.com Tue Apr 29 20:50:49 2008 From: jim.hefferon at gmail.com (Jim) Date: Tue, 29 Apr 2008 17:50:49 -0700 (PDT) Subject: Simple unicode-safe version of str(exception)? References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> <48179831.7030308@v.loewis.de> <87iqy0miip.fsf@physik.rwth-aachen.de> Message-ID: I often struggle with the problem outlined in part in this thread. I know that I'm going to repeat some of what is said elsewhere but I'd like to present the question all in one place. I believe that the routines in the Python standard library do not document which exceptions they could raise (I understand some reasons why, but they nontheless do not). So I often find out the hard way that a library call can raise an exception that I was not smart enough to anticipate. So I often find myself doing try: make_a_routine_call(x,y,z) except AnticipatedError, err: do_something_with_it(x,y,z,err) exception Exception, err: print "something crazy happened "+str(err) where the print statement is just supposed to give me some idea of what happened. (I actually usually log it instead of printing it. If there is a better way, I'd love to hear it.) But "str(err)" sometimes fails, as the OP noted. Further, xtr(err) alone is not enough, I believe. I believe that some routines in the standard library do not return strings (by that I mean something approximately like "err.value is a pair"; forgive me, I don't remember the full details). Surely as lovely a language as Python has a better idiom for dealing with exceptions in the standard library than something that works out to print "something crazy happened"+" ".join([xtra(x) for x in err]) ? (I would understand better if it was a user's code; they are free to do what works for them, of course.) But I've been unable to think of one and I haven't seen in this thread another direction. Is there one? Jim From aldo at nullcube.com Sun Apr 6 23:57:21 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Mon, 7 Apr 2008 13:57:21 +1000 Subject: ANN: pry unit testing framework In-Reply-To: <47F98A5B.8010000@holdenweb.com> References: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> <20080407023442.GA16373@nullcube.com> <47F98A5B.8010000@holdenweb.com> Message-ID: <20080407035721.GB16373@nullcube.com> Thus spake Steve Holden (steve at holdenweb.com): > It probably reflects personal preference, but it's a preference that > many people will maintain. I understand that PEP 008 was largely > directed at standard library authors and maintainers, but anything > that claims wide utility should have ambitions to be included in the > standard library, and hence PEP 008 conformance would be a plus. Well, that's an entirely different conversation. Inclusion in the standard library has not always benefitted libraries - in fact, the standard library contains a number of examples of modules that have calcified due to the strict demands for interface backwards compatibility. Many of these could have been excellent if development and refactoring had continued. The library cleanup for Py3K may fix some of these problems, but then we're stuck again until, well, Py4K, and by then we'll all be too busy swanning about in our flying cars and having holidays on Mars to care. ;) So, no, I don't think inclusion in the standard library should be a universal ambition, and it's certainly not one I have for Pry. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From steve at holdenweb.com Wed Apr 16 13:23:57 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 16 Apr 2008 13:23:57 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: <87prspydex.fsf@physik.rwth-aachen.de> References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> <87prspydex.fsf@physik.rwth-aachen.de> Message-ID: Torsten Bronger wrote: > Hall?chen! > > Michael Torrie writes: > >> [...] >> >> This official python list is one of the few lists that's even >> still on nntp. All my other ones (gnome, gtk, openldap, clamav, >> freeradius, etc) are all e-mail mailing lists only and it works >> very well. In fact, I think it's much better since list >> subscription can actually be controlled by someone. > > The admistrative overhead of mailing lists is tedious. Fortunately, > most important computer-related lists are on gmane.org. We could > list c.l.py there, too. ;-) > c.l.py has been on gmane for years, as comp.python.general (why they have to have their own naming hierarchy i have never understood). regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From castironpi at gmail.com Mon Apr 21 16:30:12 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Mon, 21 Apr 2008 13:30:12 -0700 (PDT) Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> <8f3a768d-0b4c-4077-9aef-a66898882f03@m1g2000pre.googlegroups.com> Message-ID: <91e13570-b4ab-4063-93e2-dc2cbd96c7d7@e39g2000hsf.googlegroups.com> On Apr 21, 12:59?pm, Lou Pecora wrote: > In article > <8f3a768d-0b4c-4077-9aef-a66898882... at m1g2000pre.googlegroups.com>, > > ?castiro... at gmail.com wrote: > > On Apr 21, 9:28?am, a... at pythoncraft.com (Aahz) wrote: > > > > Why is this newsgroup different from all other newsgroups? ? > > > Different is a verbally atomic relation. > > It's a Passover question. Did it Pass. From steve at holdenweb.com Tue Apr 1 18:18:27 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 01 Apr 2008 18:18:27 -0400 Subject: class super method In-Reply-To: <0eb3ee4e-82e2-419a-8e7b-4931f7b4effa@c26g2000prf.googlegroups.com> References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> <0eb3ee4e-82e2-419a-8e7b-4931f7b4effa@c26g2000prf.googlegroups.com> Message-ID: George Sakkis wrote: > On Mar 31, 10:41 pm, Ed Leafe wrote: > >> On Mar 31, 2008, at 5:58 PM, George Sakkis wrote: >> >>>> is there any tutorial for super method (when/how to use it)? >>>> or maybe someone could explain me how it works? >>>> thx >>> Super is one of the dark corners of the language [1,2]... a good rule >>> of thumb is to stay away from it, or at least stick to its basic >>> usage. >> I disagree - super is quite elegant and dependable. > > Did you follow the links I gave by any chance? With all the gotchas > and rules of how to use it properly, it's far from what I would call > elegant. > >> In my own project (Dabo), we use mixin classes liberally to provide >> consistent behavior across our UI classes. The use of super makes >> customizing __init__() behavior, for example, quite straightforward. >> The general form looks like: >> >> class DaboUIClass(dabo.ui.dControlMixin, someWxPythonClass): >> def __init__(self, *args, **kwargs): >> doOurCustomStuffBeforeTheSuperCall() >> super(DaboUIClass, self).__init__(*args, **kwargs) >> doOurCustomStuffAfterTheSuperCall() >> >> This has worked reliably for us in every place where we have used it. >> There's nothing dark and mysterious about it at all. > > Pehaps, at least as long as you make sure that all superclasses have a > compatible signature - which in practice typically means accept > arbitrary *args and **kwargs in every class in the hierarchy like your > example. Good luck figuring out what's wrong if it's not used > consistently. > > Also doOurCustomStuffBeforeTheSuperCall() works as long as all > ancestor methods to be called need the same CustomStuff massaging. > > In a sentence, it's better than nothing but worse than anything. > So you are prepared to write off the voice of experience because some random web pages contradict what Ed is saying? As Ed rightly points out, any sufficiently complex gun can end up shooting you in the foot. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From sierra9162 at gmail.com Wed Apr 16 11:26:20 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:26:20 -0700 (PDT) Subject: kate hudson quotes Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From Magnus.Moraberg at gmail.com Wed Apr 2 09:06:47 2008 From: Magnus.Moraberg at gmail.com (Magnus.Moraberg at gmail.com) Date: Wed, 2 Apr 2008 06:06:47 -0700 (PDT) Subject: Nested try...except Message-ID: Hi, I found the following code on the net - http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/%3C20050924104732.5116.qmail at minotaur.apache.org%3E def count(self): - db = sqlite.connect(self.filename, isolation_level=ISOLATION_LEVEL) - try: - try: - cur = db.cursor() - cur.execute("select count(*) from sessions") - return cur.fetchone()[0] - finally: - cur.close() - finally: - db.close() I don't understand though why the second try is not after the line cur = db.cursor(). Can anyone explain for me why? /Barry. From nanjundi at gmail.com Wed Apr 2 12:25:21 2008 From: nanjundi at gmail.com (Nanjundi) Date: Wed, 2 Apr 2008 09:25:21 -0700 (PDT) Subject: Nested try...except References: <0a34849f-bcda-419b-a10f-772d76172d1f@b5g2000pri.googlegroups.com> <43d60d13-b420-414d-81c8-b8430af2aa5f@i36g2000prf.googlegroups.com> Message-ID: <7d992474-f90b-4c8f-b359-a1857f570c92@8g2000hse.googlegroups.com> On Apr 2, 9:22 am, Magnus.Morab... at gmail.com wrote: > On 2 Apr, 15:15, Magnus.Morab... at gmail.com wrote: > > > > > On 2 Apr, 15:12, cokofree... at gmail.com wrote: > > > > On Apr 2, 3:06 pm, Magnus.Morab... at gmail.com wrote: > > > > > Hi, > > > > > I found the following code on the net - > > > > > http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/%3C20050924104732.5116.qm... at minotaur.apache.org%3E > > > > > def count(self): > > > > - db = sqlite.connect(self.filename, > > > > isolation_level=ISOLATION_LEVEL) > > > > - try: > > > > - try: > > > > - cur = db.cursor() > > > > - cur.execute("select count(*) from sessions") > > > > - return cur.fetchone()[0] > > > > - finally: > > > > - cur.close() > > > > - finally: > > > > - db.close() > > > > > I don't understand though why the second try is not after the line cur > > > > = db.cursor(). Can anyone explain for me why? > > > > > /Barry. > > > > Better question is why is there a try with no except... > > > > Better yet, WHY is there two TRY statements when there could quite > > > happily be only one... > > > > Towards what you are asking, I GUESS...because the author hoped to > > > handle the cases where cur failed to get assigned...but then > > > his .close method of it would likely not work anyway...I mean...does > > > this even work...YUCK > > > I shouldn't have written "Nested try...except" as the title, instead I > > mean "Nested try...finally". Sorry about that... > > > Anyway, how would you do this? That is, use a finally to close the > > network connection and the cursor? > > > Thanks for your help, > > > Barry > > Here's what I would do. Is it OK? > > def ExecuteWithNoFetching(self, queryString): > > sqlServerConnection = adodbapi.connect (";".join (connectors)) > try: > cursor = sqlServerConnection.cursor() > try: > cursor.execute(queryString) > raise Exception("Exception") > sqlServerConnection.commit() > finally: > cursor.close() > finally: > sqlServerConnection.close() No.. Why do you have raise statement? "sqlServerConnection.commit()" never gets executed. -N From mattheww at chiark.greenend.org.uk Mon Apr 21 18:14:38 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 21 Apr 2008 23:14:38 +0100 (BST) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: Terry Reedy wrote: > Off the top of my head: copy C and use {} to demarcate blocks and ';' to > end statements, so that '\n' is not needed and is just whitespace when > present. So, repeatedly scan for the next one of '{};'. That would break if those characters appear in string literals or comments. That's why it's nicer if you can do the transformation after tokenising. (Also, '{' and '}' have rather useful meanings in Python already.) -M- From bignose+hates-spam at benfinney.id.au Tue Apr 1 04:12:12 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Tue, 01 Apr 2008 19:12:12 +1100 Subject: Why prefer != over <> for Python 3.0? References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> <659gb2F2f84eoU2@mid.individual.net> <87hceo73ap.fsf@physik.rwth-aachen.de> <65anbqF2fg18bU1@mid.individual.net> <87r6drjss4.fsf@physik.rwth-aachen.de> <65c0bfF2ffipiU1@mid.individual.net> <878wzyyqkf.fsf@physik.rwth-aachen.de> Message-ID: <87fxu6f0yr.fsf@benfinney.id.au> Torsten Bronger writes: > However, I'm slightly disappointed with the UTF-8 support in some > mail clients involved in this thread, so Unicode surely has not > arrived yet. Want . -- \ "bash awk grep perl sed, df du, du-du du-du, vi troff su fsck | `\ rm * halt LART LART LART!" -- The Swedish BOFH, | _o__) alt.sysadmin.recovery | Ben Finney From stefan_ml at behnel.de Wed Apr 23 14:50:59 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 23 Apr 2008 20:50:59 +0200 Subject: DTD validation and xmlproc In-Reply-To: References: Message-ID: <480F8513.6040309@behnel.de> mmm wrote: > I am willing to learn and use new xml procedures, but I found nothng > pre-written to validate agaisnt a given DTD file. > > Any advice would be welcome, even a good tutorial on XML validation > usiog Python. Regarding that part, try lxml. http://codespeak.net/lxml http://codespeak.net/lxml/tutorial.html http://codespeak.net/lxml/validation.html Stefan From john00587 at gmail.com Mon Apr 21 01:39:10 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:39:10 -0700 (PDT) Subject: firebird quarter patch Message-ID: <690c3dee-0496-4653-85ff-6f3795ce7205@z24g2000prf.googlegroups.com> firebird quarter patch http://cracks.00bp.com F R E E C R A C K S From bbxx789_05ss at yahoo.com Sun Apr 13 17:23:48 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sun, 13 Apr 2008 14:23:48 -0700 (PDT) Subject: urllib2 Basic authentication, what am I doing wrong? References: <48025b26$0$6839$2d805a3e@textnews.eweka.nl> Message-ID: <79fdc8fe-24ab-44c1-8c2f-a4804d45a654@t54g2000hsg.googlegroups.com> Michel Bouwmans wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hey everybody, > > I'm having a little problem with urllib2 and Basic HTTP authentication. > > I have the following code: > > auth = urllib2.HTTPPasswordMgrWithDefaultRealm() > auth.add_password(None, 'https://webmail.osg-erasmus.nl/oneNet/NetStorage/', > user, password) > authhandler = urllib2.HTTPBasicAuthHandler(auth) > > opener = urllib2.build_opener(auth) > opener.addheaders = [('User-agent', 'Mozilla/5.0 Something/1.0')] > > try: > return > self.opener.open('https://webmail.osg-erasmus.nl/oneNet/NetStorage/') > except urllib2.HTTPError, e: > print e.code > print e.headers > > This however does not allow me to authenticate. I keep getting back a 401: > > 401 > Date: Sun, 13 Apr 2008 18:11:32 GMT > Server: Apache/2.0.54 (NETWARE) mod_perl/1.99_12 Perl/v5.8.4 PHP/5.0.5 > mod_nsn/1.0_0 mod_jk/1.2.14 > Set-Cookie: novellsession1=8KuAO0iLyAEAAAAAAAAAAA==; path=/ > WWW-Authenticate: Basic realm="ERASMUS-TREE" > Vary: accept-language,accept-charset > Accept-Ranges: bytes > Connection: close > Transfer-Encoding: chunked > Content-Type: text/html; charset=iso-8859-1 > Content-Language: en > > Using this nice class (adapted to urllib2) as a basehandler I see that no > Authentication-header is being send out: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440574 > > What am I doing wrong here? I spend almost my entire free time today on this > and couldn't find any problem with my code, anyone else has a thought? > Thanks in advance. Can you get something like the following to work: import urllib2 pword_manager = urllib2.HTTPPasswordMgrWithDefaultRealm() pword_manager.add_password(None, 'http://localhost/ pwordProtectedStuff/', 'jane', 'janes_password') authentication_handler = urllib2.HTTPBasicAuthHandler(pword_manager) my_custom_urlopen_function = urllib2.build_opener(authentication_handler) urllib2.install_opener(my_custom_urlopen_function) f = urllib2.urlopen('http://localhost/pwordProtectedStuff/test.htm') print f.read() From kay.schluehr at gmx.net Fri Apr 25 14:26:28 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Fri, 25 Apr 2008 11:26:28 -0700 (PDT) Subject: Newbie question about import References: Message-ID: On 25 Apr., 20:03, Luca wrote: > Hi all. I'm trying to do something with python import but isn't working for me. > > Using python 2,5 I've a program structured like this: > > * a main module called (for example) "mommy" with an __init__.py and a > file called "mommy.py" > * a __version__ var defined inside the main __init__.py > > >From the mommy.py file I need to import the __version__ var, but I'm > > really not able to do this! I fear this is a very stupid task to do... > my problem is that the file is called like the module. > > Anyone can point me to the solution? > > -- > -- luca You have to import the package containing mummy and __init__ from the pythonpath ( which can be examined using the sys module and the sys.path attribute ). Then access __version__ as an attribute: mypack/ # package indicated by __init__.py mummy.py __init__.py mummy.py -------- import mypack # o.k. if accessible from pythonpath mypack.__version__ From mail at timgolden.me.uk Wed Apr 23 13:15:52 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 23 Apr 2008 18:15:52 +0100 Subject: Partition list with predicate In-Reply-To: <925822270804230959v557ec5f5re02737709f94d3c6@mail.gmail.com> References: <925822270804230959v557ec5f5re02737709f94d3c6@mail.gmail.com> Message-ID: <480F6EC8.4090706@timgolden.me.uk> Jared Grubb wrote: > I want a function that removes values from a list if a predicate > evaluates to True. The best I could come up with is: Have a look at the itertools module, and the ifilter function in particular. TJG From kyosohma at gmail.com Tue Apr 29 10:10:47 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 29 Apr 2008 07:10:47 -0700 (PDT) Subject: SSL through python. possible ? References: Message-ID: On Apr 29, 8:56?am, TkNeo wrote: > I need to do SSL file transfer using python? Is there a library i can > use ? > > Thanks. Did you try Google? Here's a few links that look like possibilities: http://sandbox.rulemaker.net/ngps/m2/ http://pypgsql.sourceforge.net/misc/python-ssl.html http://pypi.python.org/pypi/ssl/ http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/117004 HTH Mike From dolloffdelvpg at gmail.com Wed Apr 16 08:04:46 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:04:46 -0700 (PDT) Subject: taylor swift in concert Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From mensanator at aol.com Wed Apr 16 13:46:03 2008 From: mensanator at aol.com (Mensanator) Date: Wed, 16 Apr 2008 10:46:03 -0700 (PDT) Subject: What can we do about all the spam that the list is getting? References: <259ab201-9d2b-4e4e-88a7-e2fe277f0066@a23g2000hsc.googlegroups.com> Message-ID: On Apr 16, 12:01?pm, sr... at ferg.org wrote: > What can we do about all the spam that comp.lang.python is getting? > Things are getting pretty bad. Buy Google and make them fix it. From skanemupp at yahoo.se Sat Apr 19 15:28:37 2008 From: skanemupp at yahoo.se (globalrev) Date: Sat, 19 Apr 2008 12:28:37 -0700 (PDT) Subject: random.random(), random not defined!? Message-ID: <2a3931f5-481d-4831-baad-fcc9f0c0c129@m73g2000hsh.googlegroups.com> do i need to import something to use random? From patrick.waldo at gmail.com Tue Apr 1 16:19:54 2008 From: patrick.waldo at gmail.com (patrick.waldo at gmail.com) Date: Tue, 1 Apr 2008 13:19:54 -0700 (PDT) Subject: xlrd and cPickle.dump References: <34e62ddb-477f-4a99-97a5-21a7b148d244@e67g2000hsa.googlegroups.com> <47f22a41@news.mel.dft.com.au> Message-ID: <0d46a213-9f95-43b5-835b-d74d8403626b@c19g2000prf.googlegroups.com> > How many megabytes is "extremely large"? How many seconds does it take > to open it with xlrd.open_workbook? The document is 15mb ad 50,000+ rows (for test purposes I will use a smaller sample), but my computer hangs (ie it takes a long time) when I try to do simple manipulations and the documentation leads me to believe cPickle will be more efficient. If this is not true, then I don't have a problem (ie I just have to wait), but I still would like to figure out how to pickle an xlrd object anyways. > You only need one of the above imports at the best of times, and for > what you are attempting to do, you don't need pyExcelerator at all. Using pyExcelerator was a guess, because the traditional way didn't work and I thought it may be because it's an Excel file. Secondly, I import it twice because sometimes, and I don't know why, PythonWin does not import pyExcelerator the first time. This has only been true with pyExcelerator. > > data_path = """C:\test.xls""" > > It is extremely unlikely that you have a file whose basename begins with > a TAB ('\t') character. Please post the code that you actually ran. you're right, I had just quickly erased my documents and settings folder to make it smaller for an example. > > Please post the minimal pyExcelerator-free script that demonstrates your > problem. Ensure that it includes the following line: > import sys; print sys.version; print xlrd.__VERSION__ > Also post the output and the traceback (in full). As to copy_reg.py, I downloaded Activestate Python 2.4 and that was it, so I have had no other version on my computer. Here's the code: import cPickle,xlrd, sys print sys.version print xlrd.__VERSION__ data_path = """C:\\test\\test.xls""" pickle_path = """C:\\test\\pickle.pickle""" book = xlrd.open_workbook(data_path) Data_sheet = book.sheet_by_index(0) pickle_file = open(pickle_path, 'w') cPickle.dump(book, pickle_file) pickle_file.close() Here's the output: 2.4.3 (#69, Apr 11 2006, 15:32:42) [MSC v.1310 32 bit (Intel)] 0.6.1 Traceback (most recent call last): File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework \scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\text analysis\pickle_test2.py", line 13, in ? cPickle.dump(book, pickle_file) File "C:\Python24\lib\copy_reg.py", line 69, in _reduce_ex raise TypeError, "can't pickle %s objects" % base.__name__ TypeError: can't pickle module objects Thanks for the advice! From DanQ.cunningham at landesk.com Mon Apr 7 10:11:23 2008 From: DanQ.cunningham at landesk.com (Cunningham, Dan) Date: Mon, 7 Apr 2008 08:11:23 -0600 Subject: Getting a value from a nested dictionary Message-ID: Hi, My name is Dan and I'm a newb to python (and programming. Please forgive) I am trying to get a value from a nested dictionary. I would like to pass in a parameter from a conf file, then compare it to a value in the dictionary, and verify that it is a valid value. (The SSL_MODE Portion of the below listed dictionary) I have d1{key1: val1, key2: val_2{key_a: val_a, key_b: val_b}, key3: val_3} And In comes the value from the conf file key2: val_a Any Ideas? Dan C #!/usr/local/bin/python2.5 # -*- coding: UTF-8 -*- # File extractconf.py # The file authn.conf must exist import os import sys import re CONF_FILE = "authn.conf" #Use these defaults if none are provided in the .conf file PARAMS_VALUES = {"INSTANCE_NAME": "", "CHASE_REFERRALS": False, "DOMAIN_NAME": "", "GROUP_CONTAINER": "", "PASSWORD": "", "SSL_MODE": {"ssl1": "NO_SSL", "ssl2": "SSL_TRUST_ALL", "ssl3": "SSL_CERTIFICATE_MODE"}, "USE_GC": False, "USE_KERBEROS": False, "USER_CONTAINER": "", "USER_NAME": "", "USER_NAME_TYPE": {'unt1': "FULL_SAM", 'unt2': "PARTIAL_SAM", 'unt3': "FULL_UPN", 'unt4': "PARTIAL_UPN"}} def extractParams(): thedir = os.getcwd() #Parse the dir and get the file listing filelist = os.listdir(thedir) if CONF_FILE in filelist: thefile = open("authn.conf").readlines() thefile = [l.strip() for l in thefile] #Strip out the whitespace thefile = [l for l in thefile if l.find('=') >= 0] # Filters out non-conf lines thefile = [re.split(r"\s*=\s*", l) for l in thefile] #Use regex and get out spaces thefile = [(l[0], eval(l[1])) for l in thefile] #Evaluate the str and bool values thefile = dict(thefile) #Turn the file into a dictionary for k in thefile.keys(): #For each entry in the file if k == 'SSL_MODE': #If the key is equal to the SSL_MODE key ##THIS IS WHERE I'M STUCK print PARAMS_VALUES['SSL_MODE'] ## else: ## THIS PART IS OK for k in PARAMS_VALUES.keys(): #Replace values in default dict with the values from the conf file PARAMS_VALUES[k] = thefile[k] else: sys.exit("File authn.conf must exist") if __name__ == "__main__": extractParams() -------------- next part -------------- An HTML attachment was scrubbed... URL: From rhamph at gmail.com Tue Apr 1 12:02:33 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Tue, 1 Apr 2008 09:02:33 -0700 (PDT) Subject: bsddb3 thread problem References: Message-ID: <391d152a-aa74-40e2-804e-14f30756fda3@u10g2000prn.googlegroups.com> On Apr 1, 1:29 am, "anuraguni... at yahoo.com" wrote: > In my application I am trying to access(read) a DB thru a thread while > my main thread is adding data to it and it gives following error(s) > > bsddb._db.DBRunRecoveryError: (-30974, 'DB_RUNRECOVERY: Fatal error, > run database recovery -- PANIC: Permission denied') > > and sometimes > bsddb._db.DBRunRecoveryError: (-30974, 'DB_RUNRECOVERY: Fatal error, > run database recovery -- PANIC: fatal region error detected; run > recovery') > > sometimes > bsddb._db.DBInvalidArgError: (22, 'Invalid argument -- DB_LOCK- > > >lock_put: Lock is no longer valid') > > sometimes pure seg fault. > Program received signal SIGSEGV, Segmentation fault. > 0xb7c1b845 in __bam_adjust () from /usr/lib/libdb-4.4.so > > and some time memory usage keeps on increasing and cpu is 100% > it crashes with memory error. > > This doesn't happen always, almost 1 in 10 cases. > If i use simple python threaded function instead of threading class, > it works. > > I have attached a simple script which tries to replicate the scenario. > > Do anybody has a clue what I am doing wrong here? > I suppose bsddb3 DB can be accessed from mutiple threads? > or do I need to specifically set DB_THREAD flag? though with > db.DB_THREAD it hangs on some mutex? > > Thanks a lot > Anurag > > ------- > import time > import os > import threading > import thread > import shutil > from bsddb3 import db > > class DocQueueConsumer(threading.Thread): > > def __init__(self, queueDB): > threading.Thread.__init__(self) > self.queueDB = queueDB > self.setDaemon(True) > > def run(self): > while True: self.queueDB.cursor() > > def crash(): > path = "/tmp/test_crash" > if os.path.exists(path): > shutil.rmtree(path) > os.mkdir(path) > > aBigEnv = db.DBEnv() > aBigEnv.set_cachesize(0, 512*1024*1024) > aBigEnv.open(path, db.DB_INIT_CDB|db.DB_INIT_MPOOL|db.DB_CREATE) > > queueDB = db.DB(aBigEnv) > queueDB.open('mydb', dbtype=db.DB_RECNO, flags=db.DB_CREATE) > > DocQueueConsumer(queueDB).start() > for i in xrange(10**5): > if i%1000==0: print i/1000 > queueDB.append("something") > > crash() > ------- It's my understanding that the connection is NOT thread-safe. Your thread should be using an entirely separate connection. From fabiofz at gmail.com Wed Apr 9 13:41:07 2008 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Wed, 9 Apr 2008 14:41:07 -0300 Subject: Pydev 1.3.15 Released Message-ID: Hi All, Pydev and Pydev Extensions 1.3.15 have been released Details on Pydev Extensions: http://www.fabioz.com/pydev Details on Pydev: http://pydev.sf.net Details on its development: http://pydev.blogspot.com Release Highlights in Pydev Extensions: ----------------------------------------------------------------- * Globals Browser: Was not correctly showing definition on a case with multiple projects when one did not have the python nature configured. * Code Analysis: False positive: Classes defined within a class context are correctly found when later accessed in the parent context. * Interactive console integration o Context insensitive completions with auto-import in console o Ctrl+Alt+Enter: can be used to: + Create console if no console exists + Send selected text to console + Make execfile for current file if there's no selected text Release Highlights in Pydev: ---------------------------------------------- * Files without extension: If a file that does not have an extension is found in the root of the pythonpath, code-completion and breakpoints work with it. * Extract method: comma not removed when found after a tuple and before a keyword argument. * Console Encoding: print u"\xF6" works (console encoding correctly customized in python -- see http://sourceforge.net/tracker/index.php?func=detail&aid=1580766&group_id=85796&atid=577329 for details). * Debugger: Context of breakpoint correctly defined when comments are present in the end of the module. * from __future__ import (xxx, with_statement): works. * Interactive Console View, featuring: o Code Completion + Context sensitive with shell completions + Qualifier matches as case insensitive + Templates + Repeating the activation changes from templates to default completions o Console Configurations + Initial commands for starting the console + Colors for the console + Vmargs can be specified for jython o Auto-indent o Auto-edits o Context info on hover o Up / Down Arrows cycles through the history (and uses the current text to match for the start of the history command) o Page Up: shows dialog with console history (where lines to be re-executed can be selected) o Esc: clears current line o ctrl+1 works for assign quick-assist o Hyperlinks addedd to tracebacks in the console o Paste added directly to the command line o Cut will only cut from the command line o Copy does not get the prompt chars o Home goes to: first text char / prompt end / line start (and cycles again) o Cursor automatically moved to command line on key events o Multiple views of the same console can be created o Limitation: Output is not asynchonous (stdout and stderr are only shown after a new command is sent to the console) What is PyDev? --------------------------- PyDev is a plugin that enables users to use Eclipse for Python and Jython development -- making Eclipse a first class Python IDE -- It comes with many goodies such as code completion, syntax highlighting, syntax analysis, refactor, debug and many others. Cheers, -- Fabio Zadrozny ------------------------------------------------------ Software Developer ESSS - Engineering Simulation and Scientific Software http://www.esss.com.br Pydev Extensions http://www.fabioz.com/pydev Pydev - Python Development Enviroment for Eclipse http://pydev.sf.net http://pydev.blogspot.com From upton at virginia.edu Wed Apr 23 11:27:08 2008 From: upton at virginia.edu (Dan Upton) Date: Wed, 23 Apr 2008 11:27:08 -0400 Subject: Unix Device File Emulation In-Reply-To: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> Message-ID: <5504f9ac0804230827l1a5b2697n5dd716daf0d4b175@mail.gmail.com> (let's try this again, and actually send it to the list this time) On Wed, Apr 23, 2008 at 11:02 AM, blaine wrote: > Hey everyone, > So I've got a quick query for advice. > > We have an embedded device in which we are displaying to an LCD > device that sits at /dev/screen. This device is not readily available > all the time, so I am needing to write an emulator. This will > basically just monitor a file, /dev/screen for example, and write the > commands to a TK or WxWindows canvas. > > So sending 'line 0 0 10 10' will draw a line on my canvas from (0,0) > to (10,10). > > My question: Whats the best way to set up a monitor (in python) of > this file? Would I simply open up the file for read, check for > changes, get any updated data, and clear the file? Or is there some > standard way of doing something like this that guarantees no overlap > or data loss? > > example usage: echo 'line 0 0 10 10' > /dev/screen > > On the actual embedded device this is handled by a kernel module. We > can spit commands into it as fast as we can and the kernel module can > keep up. This is typical unix device file behavior. > > Any suggestions or advice would be splendid. Thanks! > Blaine > -- > http://mail.python.org/mailman/listinfo/python-list > 've only interacted with device files from python that I was only reading from. And I guess technically they were under /proc and /sys, rather than /dev, although they may be handled the same way. Anyway, in that case my method was basically to open the file, read it, close it, do whatever processing I needed to do on the data, sleep for some interval...lather, rinse, repeat. Sleeping for some interval may or may not be appropriate in your case. I know in the case of /proc files and /sys files, the files are generated on demand by the kernel and relevant kernel structures are basically printed to a string and copied into a page in memory that the user program can access. AFAIK, you can seek back and forth through them, but I don't know whether the data in the page is updated on a seek, so you may have to close and reopen the file ever iteration to see what's changed. HTH, -dan From bruno.desthuilliers at gmail.com Mon Apr 7 13:19:44 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Mon, 7 Apr 2008 10:19:44 -0700 (PDT) Subject: Learning curve for new database program with Python? References: Message-ID: <00fca324-6fce-4b2a-8acb-77c96b83eb1c@p39g2000prm.googlegroups.com> On 7 avr, 07:34, CM wrote: > On Apr 5, 11:50 am, Jetus wrote: > > > I have a need for a database program. I downloaded the db2 from ibm, > > and reviewed some of the documentation. > > > My question is, what is the easiest program for me to try to learn. I > > will be creating a database of about 25,000 records, it will be > > relational. I am a beginner Python programmer, and need a database > > solution that is easy to grasp. I played with sql, > > and found that very difficult, if not overly cumbersome. > > > A database that could work with Django would be very interesting to > > look at as well.. > > > Any suggestions out there? > > From the good people at Django: > > "If you want to use Django with a database, which is probably the > case, you'll also need a database engine. PostgreSQL is recommended, > because we're PostgreSQL fans, and MySQL, SQLite 3, and Oracle are > also supported." > > And if you want to make it a relational database, Err... I may totally misunderstand you here, but I've the strong impression that you missed the fact that the database systems mentionned above are all (so-called) relational dabatases. From kyosohma at gmail.com Tue Apr 8 11:47:10 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 8 Apr 2008 08:47:10 -0700 (PDT) Subject: List open files References: <47fb8d54$0$15068$426a74cc@news.free.fr> Message-ID: On Apr 8, 10:16 am, "Bruno GUERPILLON" wrote: > Hi, > > I'd like, in a WIN32 environment, list all open files. > Anyone got a clue how to do this ? > > Regards, > > Bruno. XP comes with a utility called OpenFiles.exe which supposedly gives this functionality. You can use Python's subprocess command to run it and parse its output. Mike From deets at nospam.web.de Tue Apr 22 13:06:52 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 19:06:52 +0200 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: <6728a814-32df-41cd-8f6e-c86750d9f91f@p25g2000hsf.googlegroups.com> References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <6760jfF2n3bn1U1@mid.uni-berlin.de> <676desF2nrgitU1@mid.uni-berlin.de> <6728a814-32df-41cd-8f6e-c86750d9f91f@p25g2000hsf.googlegroups.com> Message-ID: <676ka0F2mt126U1@mid.uni-berlin.de> Carl Banks schrieb: > On Apr 22, 11:10 am, "Diez B. Roggisch" wrote: >>> 2. Java interfaces solve a different problem than MI (used properly) >>> does: interfaces are there to make types polymorphic, whereas >>> inheritance's main use is to share behavior. >> But the *goal* of the polymorphy is mainly to have shared behavior. > > Not at all. The goal of polymorphism is to have objects of different > types usable in the same situation. Two such classes might share some > behavior, but they don't have to. Of course they don't *have* to. Yet very often they do. But I should have (again) worded that more cautiously. When doing Java, using interfaces like the ones found in the collection packages or e.g. HttpServletRequest and such usually leads to the delegation-pattern I described. The same for swing. Generally, a lot of code is written that declares first an interface & then some Impl-classes of that - for the sole purpose of working around the SI-caveats. This shaped my viewpoint of interfaces - while on their own useful - as a necessary crutch to create a MI-like features, that I wanted to emphasize in this discussion. Diez From kf9150 at gmail.com Tue Apr 1 17:20:27 2008 From: kf9150 at gmail.com (Kelie) Date: Tue, 1 Apr 2008 14:20:27 -0700 (PDT) Subject: PyQt - Question on QListWidget's selectedItems Method References: <68632dc8-0426-4c6a-a2d8-04fd49381452@d21g2000prf.googlegroups.com> Message-ID: Another question I have about QListWidget is when user manually selects and deselects a QListWidgetItem, the background color switches between blue and white. But when an item is programmingly selected with setItemSelected method, the background color is some kind of light gray instead of blue. Why is there such a difference and how do I programmingly set the QListWidgetItem background color to blue? Thank you! From __peter__ at web.de Thu Apr 3 06:28:56 2008 From: __peter__ at web.de (Peter Otten) Date: Thu, 03 Apr 2008 12:28:56 +0200 Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> Message-ID: Jo?o Neves wrote: > Let me give a very basic example. Say we have these two functions: I suppose you mean >>> def inc(x): return x + 1 ... >>> def dec(x): return x - 1 ... >>> inc(1), dec(1) (2, 0) > Examining the compiled bytecodes for these two functions: > > >>> inc.func_code.co_code > '|\x00\x00d\x01\x00\x17}\x00\x00d\x00\x00S' > > >>> dec.func_code.co_code > '|\x00\x00d\x01\x00\x18}\x00\x00d\x00\x00S' > > Now suppose that I wanted to mess with inc, and have it behave like > dec. >>> inc.func_code = dec.func_code >>> inc(1), dec(1) (0, 0) There you are, and there wasn't even a slight chance that you combined the byte code with an incompatible function signature ;) Peter From larry.bates at websafe.com` Fri Apr 25 14:23:02 2008 From: larry.bates at websafe.com` (Larry Bates) Date: Fri, 25 Apr 2008 13:23:02 -0500 Subject: Newbie question about import In-Reply-To: References: Message-ID: Luca wrote: > Hi all. I'm trying to do something with python import but isn't working for me. > > Using python 2,5 I've a program structured like this: > > * a main module called (for example) "mommy" with an __init__.py and a > file called "mommy.py" > * a __version__ var defined inside the main __init__.py > >>From the mommy.py file I need to import the __version__ var, but I'm > really not able to do this! I fear this is a very stupid task to do... > my problem is that the file is called like the module. > > Anyone can point me to the solution? > In the future please show us what you "actually" did with full tracebacks if there were any so we know what you actually tried. I do something like this by doing: from version import version__ It doesn't have to be a module (e.g. doesn't need __init__.py) to make that work. Hope this helps. -Larry From Shawn at Milochik.com Wed Apr 30 14:53:16 2008 From: Shawn at Milochik.com (Shawn Milochik) Date: Wed, 30 Apr 2008 14:53:16 -0400 Subject: Issue with regular expressions In-Reply-To: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Message-ID: <2dc0c81b0804301153g343f0f1eg84951d7a5500cb42@mail.gmail.com> My stab at it: My stab at it: #!/usr/bin/env python import re query = ' " some words" with and "without quotes " ' query = re.sub("\s+", " ", query) words = [] while query.__len__(): query = query.strip() print("Current query value: '%s'" % query) print words print if query[0] == '"': secondQuote = query[1:].index('"') + 2 words.append(query[0:secondQuote].replace('"', '').strip()) query = query[secondQuote:] else: if query.count(" ") == 0 : words.append(query) query = "" else: space = query.index(" ") words.append(query[0:space]) query = query[space:] print words print query -------------- next part -------------- An HTML attachment was scrubbed... URL: From schettino72 at gmail.com Sat Apr 19 17:18:32 2008 From: schettino72 at gmail.com (Eduardo Schettino) Date: Sun, 20 Apr 2008 02:48:32 +0530 Subject: [ANN] DoIt 0.1.0 Released (build tool) In-Reply-To: <480a576a$1@news.mel.dft.com.au> References: <480a576a$1@news.mel.dft.com.au> Message-ID: On Sun, Apr 20, 2008 at 2:04 AM, John Machin wrote: > You may like to consider the possibility of confusion caused by the > similarity of some characters in some fonts (DoIt, Do1t, Dolt) ... > google("dictionary dolt") :-) > -- > http://mail.python.org/mailman/listinfo/python-list > hehehehe. i feel like a DOLT I never realized that it is confusing. I also didnt know this word "dolt" before. i wont use capital letters anymore. thanks From george.sakkis at gmail.com Wed Apr 2 15:56:07 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 2 Apr 2008 12:56:07 -0700 (PDT) Subject: Manipulate Large Binary Files References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> Message-ID: <9cef43da-c101-4003-9a49-308da3c9667a@u36g2000prf.googlegroups.com> On Apr 2, 2:09 pm, "Derek Tracy" wrote: > On Wed, Apr 2, 2008 at 10:59 AM, Derek Tracy wrote: > > I am trying to write a script that reads in a large binary file (over 2Gb) saves the header file (169088 bytes) into one file then take the rest of the data and dump it into anther file. I generated code that works wonderfully for files under 2Gb in size but the majority of the files I am dealing with are over the 2Gb limit > > > INPUT = open(infile, 'rb') > > header = FH.read(169088) > > > ary = array.array('H', INPUT.read()) > > > INPUT.close() > > > OUTF1 = open(outfile1, 'wb') > > OUTF1.write(header) > > > OUTF2 = open(outfile2, 'wb') > > ary.tofile(OUTF2) > > > When I try to use the above on files over 2Gb I get: > > OverflowError: requested number of bytes is more than a Python string can hold > > > Does anybody have an idea as to how I can get by this hurdle? > > > I am working in an environment that does not allow me to freely download modules to use. Python version 2.5.1 > > > R/S -- > > --------------------------------- > > Derek Tracy > > trac... at gmail.com > > --------------------------------- > > I know have 2 solutions, one using > partial > and the other using array > > Both are clocking in at the same time (1m 5sec for 2.6Gb), are there > any ways I can optimize either solution? Would turning off the > read/write buff increase speed? You may try to increase the buffering size when you open() the file and see if this helps: def iterchunks(filename, buffering): return iter(partial(open(filename,buffering=buffering).read, buffering), '') for chunk in iterchunks(filename, 32*1024): pass #for chunk in iterchunks(filename, 1024**2): pass #for chunk in iterchunks(filename, 10*1024**2): pass George From ziade.tarek at gmail.com Thu Apr 17 09:44:23 2008 From: ziade.tarek at gmail.com (=?ISO-8859-1?Q?Tarek_Ziad=E9?=) Date: Thu, 17 Apr 2008 15:44:23 +0200 Subject: [Python-Dev] Global Python Sprint Weekends: May 10th-11th and June 21st-22nd. In-Reply-To: <4806482C.4030305@voidspace.org.uk> References: <87D3F9C72FBF214DB39FA4E3FE618CDC6E22F389FE@EXMBX04.exchhosting.com> <4806482C.4030305@voidspace.org.uk> Message-ID: <94bdd2610804170644x4db329b0vf49de21a590c51e@mail.gmail.com> On Wed, Apr 16, 2008 at 8:40 PM, Michael Foord wrote: > Trent Nelson wrote: > > Following on from the success of previous sprint/bugfix weekends and > > sprinting efforts at PyCon 2008, I'd like to propose the next two > > Global Python Sprint Weekends take place on the following dates: > > > > * May 10th-11th (four days after 2.6a3 and 3.0a5 are released) > > * June 21st-22nd (~week before 2.6b2 and 3.0b2 are released) > > > > It seems there are a few of the Python User Groups keen on meeting > > up in person and sprinting collaboratively, akin to PyCon, which I > > highly recommend. I'd like to nominate Saturday across the board > > as the day for PUGs to meet up in person, with Sunday geared more > > towards an online collaboration day via IRC, where we can take care > > of all the little things that got in our way of coding on Saturday > > (like finalising/preparing/reviewing patches, updating tracker and > > documentation, writing tests ;-). > > > > For User Groups that are planning on meeting up to collaborate, > > please reply to this thread on python-dev at python.org and let every- > > one know your intentions! > > > > > > I should be able to help organise and attend the London contribution. > Personally I'd like to work on the documentation changes / clean-up for > the unittest module discussed recently. We are trying to set up a team here in Paris, Personnally I would like to continue the work started in distutils (various patches) and some friends here are interested in contributing on documentation. Tarek -- Tarek Ziad? | Association AfPy | www.afpy.org Blog FR | http://programmation-python.org Blog EN | http://tarekziade.wordpress.com/ From bruno.desthuilliers at gmail.com Thu Apr 17 09:46:43 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Thu, 17 Apr 2008 06:46:43 -0700 (PDT) Subject: Metaprogramming Example References: <930643c6-2d56-4fb0-aee0-a3e79231f09b@24g2000hsh.googlegroups.com> <32472b97-f35a-4408-96f5-2f8c8f92ae56@m73g2000hsh.googlegroups.com> Message-ID: <39325652-e0cf-4efd-9b28-00c0fe8552cc@m73g2000hsh.googlegroups.com> On 17 avr, 14:25, andrew cooke wrote: > On Apr 17, 7:12 am, "bruno.desthuilli... at gmail.com" wrote: > > [...] > > Thanks very much! > > These are useful pointers. I'll update my code accordingly. > > At one point you pointed out I didn't need parentheses and I agree - I > was using them to avoid having a line continuation backslash (I think > I read to do that in a style guide recently). Ok. I personnaly prefer \ continuations, but that's another troll^M^discussion !-) > One other question. I had "foo is False" and you said I need > equality, which is a good point. However, in any other language "not > foo" would be preferable. And it's indeed the case in Python. > I was surprised you didn't suggest that I did - even if somewhat implicitly -, as Paul brillantly explained. > (and I'm unsure now why I didn't write it that way myself). Is there > some common Python standard that prefers "foo == False" to "not foo"? Definitively not. FWIW, True and False are later additions to Python, which has a much more generic concept of what's true or false (notice the lowercase) in the context of a boolean expression, that is: - False, None, numeric zero are false - an object that has a __nonzero__ method has the truth value of the result of calling this method - a "sizeable" object (one which defines a __len__ method) is true if len(obj) > 0, else it's false (which implies that empty dicts, lists, tuples and strings are false) - anything else is true (please someone correct me if I forgot something here). > > PS Is there anywhere that explains why Decorators (in the context of > functions/methods) are so good? I've read lots of things saying they > are good, but no real justification of why. To me it looks more like > "re-arranging deck chairs on the Titanic" - you're just moving where > the hack happens from one place to another. Is the point that now the > hack is more visible and hence modifiable? I wouldn't call function decorators "a hack" - it's just a pretty common use of HOFs. Now wrt/ the @decorator syntax: yes, you're plain right, the GoodThing(tm) is that it makes the use of the HOF clearly visible at the top of the function definition so you just can't miss it. From bwljgbwn at gmail.com Tue Apr 22 05:51:26 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:51:26 -0700 (PDT) Subject: clonecd crack Message-ID: <0ecf01ca-9887-4ed4-aff9-38e6e43e4139@b5g2000pri.googlegroups.com> clonecd crack http://cracks.12w.net F R E E C R A C K S From xnews2 at fredp.lautre.net Mon Apr 28 14:47:21 2008 From: xnews2 at fredp.lautre.net (Fred Pacquier) Date: 28 Apr 2008 18:47:21 GMT Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <6db0df91-39f1-47a1-b4ca-c0351f0b67bc@y22g2000prd.googlegroups.com> Message-ID: John Henry said : > The performance of Qooxdoo is quite amazing - for a Javascript based > web application. Don't know about cell-phones though. You can try > their showcase web site I cited earlier. Just for the record, Nokia Internet tablets (770, N800, N810) are the only things made by Nokia that are not cell-phones... They're ARM machines with a 800x480 4" screen, Wifi, Bluetooth, and Linux. And Python, pyGTK and Pygame. Probably pyQt next as they just bought Trolltech. But no wxPython. I was not speaking of running just the client part in the device's browser, either - but the full Monty (haha) with the web server and the application engine, python, middleware and all. I'm doing it right now using a full- blown framework (web2py), so it's not unreasonable. There's no Ajax in there though, so I'm wondering what kind of impact those tools you mention would have, server side. > Yes, who would have throught we don't have to give up on Pythoncard? Proof of superior vision, architecture and design, all that time ago... From theller at ctypes.org Thu Apr 3 15:17:14 2008 From: theller at ctypes.org (Thomas Heller) Date: Thu, 03 Apr 2008 21:17:14 +0200 Subject: State of ctypes Support on HP-UX? In-Reply-To: <200804031429.19025.phil@riverbankcomputing.com> References: <200804031153.26234.phil@riverbankcomputing.com> <200804031429.19025.phil@riverbankcomputing.com> Message-ID: Phil Thompson schrieb: > On Thursday 03 April 2008, Thomas Heller wrote: >> Phil Thompson schrieb: >> > Could somebody confirm how well ctypes is supported on HP-UX (for both >> > PA-RISC and Itanium) for both Python v2.4 and v2.5? >> I cannot answer your question, but if you want to try it out >> yourself there is the HP testdrive program: http://www.testdrive.hp.com/ > > Thanks for the pointer. Unfortunately the answer is that there is no support > (at least for ctypes v1.0.2). I tried out the current SVN version of Python myself. ctypes doesn't compile on the PA system (the libffi assembler code fails to compile), but I did get it to work on the Itanium system with gcc (I had to set LDSHARED="gcc -shared" before configuring). Even the ctypes unittests pass on this system. In theory, the ctypes code should be backwards-compatible with python 2.4, although in practice it currently is not, but IMO it should be possible to change it accordingly. Would this be useful to you? Thomas From johnjsal at gmailNOSPAM.com Sun Apr 13 23:11:18 2008 From: johnjsal at gmailNOSPAM.com (John Salerno) Date: Sun, 13 Apr 2008 23:11:18 -0400 Subject: Best way to update a settings file? Message-ID: <4802cb83$0$15190$607ed4bc@cv.net> I'm thinking about writing a small script that will update an xml file with whatever game settings the user enters. I imagine that the user will have a single-screen GUI application with several different settings, like this: CROSSHAIRS ON LOCATION ON HEALTHBAR OFF etc..... These settings will somehow be toggleable with an ON/OFF button, or something. Anyway, I can think of two ways to do this: 1. After the user chooses his settings and clicks the Save button, Python reads all the settings from the GUI application and updates *every* entry in the xml file (whether it has changed or not). 2. After the user chooses his settings and clicks the Save button, Python reads all the settings from the GUI application, compares these settings to those in the xml file, and updates only the ones that have been changed. Now, #2 seems, at first glance, like the more efficient option, because you are only updating what needs to be updated, and leaving the rest alone. However, I wonder if the extra step of comparing all the settings from the user input and the xml file will end up taking longer than just simply rewriting all the settings. Probably neither method will take much longer than the other, but I'm asking more from a good design/efficiency standpoint. Which of these two methods is the better way, or is there perhaps another way I'm not thinking of? Thanks! From trentm at activestate.com Wed Apr 9 17:48:31 2008 From: trentm at activestate.com (Trent Mick) Date: Wed, 09 Apr 2008 14:48:31 -0700 Subject: ANN: ActivePython 2.5.2.2 and 2.4.5.14 are now available Message-ID: <47FD39AF.7070008@activestate.com> I'm happy to announce that ActivePython 2.5.2.2 and 2.4.5.14 are now available for download from: http://www.activestate.com/products/activepython/ These are patch releases that update ActivePython to core Python 2.5.2 and 2.4.5. What is ActivePython? --------------------- ActivePython is ActiveState's binary distribution of Python. Builds for Windows, Mac OS X, Linux, HP-UX and AIX are made freely available. ActivePython includes the Python core and the many core extensions: zlib and bzip2 for data compression, the Berkeley DB (bsddb) and SQLite (sqlite3, ActivePython 2.5 only) database libraries, OpenSSL bindings for HTTPS support, the Tix GUI widgets for Tkinter, ElementTree for XML processing (ActivePython 2.5 only), ctypes (on supported platforms, ActivePython 2.5 only) for low-level library access, and others. The Windows distribution ships with PyWin32 -- a suite of Windows tools developed by Mark Hammond, including bindings to the Win32 API and Windows COM. See this page for full details: http://aspn.activestate.com/ASPN/docs/ActivePython/2.5/whatsincluded.html As well, ActivePython ships with a wealth of documentation for both new and experienced Python programmers. In addition to the core Python docs, ActivePython includes the "What's New in Python" series, "Dive into Python", the Python FAQs & HOWTOs, and the Python Enhancement Proposals (PEPs). An online version of the docs can be found here: http://aspn.activestate.com/ASPN/docs/ActivePython/2.5/welcome.html http://aspn.activestate.com/ASPN/docs/ActivePython/2.4/welcome.html We would welcome any and all feedback to: ActivePython-feedback at activestate.com.com Please file bugs against ActivePython at: http://bugs.activestate.com/query.cgi?product=ActivePython On what platforms does ActivePython run? ---------------------------------------- ActivePython includes installers for the following platforms: - Windows/x86 - Mac OS X - Linux/x86 - Solaris/SPARC - Solaris/x86 - Windows/x64 ("x64" is also known as "AMD64") - Linux/x86_64 ("x86_64" is also known as "AMD64") - HP-UX/PA-RISC - AIX/PowerPC Extra Bits ---------- ActivePython releases also include the following: - ActivePython24.chm, ActivePython25.chm: An MS compiled help collection of the full ActivePython documentation set. Linux users of applications such as xCHM might find this useful. This package is installed by default on Windows. Extra bits are available from: http://downloads.activestate.com/ActivePython/etc/ Apologies for the delay. I was crazy-busy getting the Komodo 4.3 release out. Check it out: http://www.activestate.com/products/komodo/ Thanks, and enjoy! Trent, Python Tech Lead -- Trent Mick trentm at activestate.com From floris.bruynooghe at gmail.com Fri Apr 4 07:36:53 2008 From: floris.bruynooghe at gmail.com (Floris Bruynooghe) Date: Fri, 4 Apr 2008 04:36:53 -0700 (PDT) Subject: Any fancy grep utility replacements out there? References: Message-ID: <2a1695f7-5e1a-46f3-9c69-76a930e5dd10@e39g2000hsf.googlegroups.com> On Mar 19, 2:44 am, Peter Wang wrote: > On Mar 18, 5:16 pm, Robert Kern wrote: > > > > > samsli... at gmail.com wrote: > > > So I need to recursively grep a bunch of gzipped files. This can't be > > > easily done with grep, rgrep or zgrep. (I'm sure given the right > > > pipeline including using the find command it could be done....but > > > seems like a hassle). > > > > So I figured I'd find a fancy next generation grep tool. Thirty > > > minutes of searching later I find a bunch in Perl, and even one in > > > Ruby. But I can't find anything that interesting or up to date for > > > Python. Does anyone know of something? > > > I have a grep-like utility I call "grin". I wrote it mostly to recursively grep > > SVN source trees while ignoring the garbage under the .svn/ directories and more > > or less do exactly what I need most frequently without configuration. It could > > easily be extended to open gzip files with GzipFile. > > > https://svn.enthought.com/svn/sandbox/grin/trunk/ > > > Let me know if you have any requests. > > And don't forget: Colorized output! :) I tried to find something similar a while ago and found ack[1]. I do realise it's written in perl but it does the job nicely. Never needed to search in zipfiles though, just unzipping them in /tmp would always work... I'll check out grin this afternoon! Floris [1] http://petdance.com/ack/ From nick at craig-wood.com Tue Apr 22 16:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Tue, 22 Apr 2008 15:30:03 -0500 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? References: Message-ID: Mark Wooding wrote: > Nick Craig-Wood wrote: > > Harishankar wrote: > >> 1. Create non-blocking pipes which can be read in a separate thread > >> [...] > > > > You are correct on both of those points. > > I must be missing something. What's wrong with spawning the subprocess > with subprocess.Popen as usual, passing subprocess.PIPE as stdin/stdout/ > whatever, making your end nonblocking with fcntl.fcntl and then using > os.read/os.write in the obvious ways? Nothing apart from the fact it doesn't work on windows. The buffering will cause you grief too. If you want to do this properly under unix use pexpect not subprocess. http://www.noah.org/wiki/Pexpect Proper non blocking IO is an absolute nightmare under Windows in my experience! It really isn't the Windows way so you are fighting the system the whole time. -- Nick Craig-Wood -- http://www.craig-wood.com/nick From mal at egenix.com Fri Apr 18 07:32:05 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Fri, 18 Apr 2008 13:32:05 +0200 Subject: Database vs Data Structure? In-Reply-To: References: Message-ID: <480886B5.1000004@egenix.com> On 2008-04-18 05:37, erikcw wrote: > Hi, > > I'm working on a web application where each user will be creating > several "projects" in there account, each with 1,000-50,000 objects. > Each object will consist of a unique name, an id, and some meta data. > > The number of objects will grow and shrink as the user works with > their project. > > I'm trying to decided whether to store the objects in the database > (each object gets it's own row) or to use some sort of data-structure > (maybe nested dictionaries or a custom class) and store the pickled > data-structure in a single row in the database (then unpickle the data > and query in memory). > > A few requirements: > -Fast/scalable (web app) > -able to query objects based on name and id. > -will play nicely with versioning (undo/redo) > > Any input on the best way to go? Relational databases offer the best scalability and reliability, so I'd go for those as backend. If your data is mostly read-only and usually only touches a small part of your database (e.g. the data for a day or two), then you can increase query performance by keeping that part in an in-memory database (e.g. use sqlite or Oracle TimesTen) and only update the copy in case something changes in the backend. Regards, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 18 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From hexade at gmail.com Sat Apr 12 18:45:25 2008 From: hexade at gmail.com (Hexade) Date: Sat, 12 Apr 2008 15:45:25 -0700 (PDT) Subject: SQLite OperationalError near "?" Message-ID: <7e592f06-42b5-4834-8f7c-34c9bc44aceb@s39g2000prd.googlegroups.com> Hello I would like to use the safe "?" placeholder in my SQLite requests but I got the following error: Traceback (most recent call last): (...) cursor.execute("SELECT ? FROM ? WHERE name = ? ", (key, self.table, self.name)) OperationalError: near "?": syntax error key, self.table and self.name are standart strings. Any idea about how to solve this problem ? Thanks in advance, Hexade From version5 at gmail.com Thu Apr 3 08:24:11 2008 From: version5 at gmail.com (nnp) Date: Thu, 3 Apr 2008 13:24:11 +0100 Subject: Python queue madness In-Reply-To: References: <28749c0e0804020652o74a9491an9eef9ba1813434fb@mail.gmail.com> Message-ID: <28749c0e0804030524p2f1b4d9fn1d63f93794b57ab5@mail.gmail.com> Hrm, it sounds likely that I am using something mutable and that is messing things up. I'll look into it. As for providing sample code to recreate the problem, I would find it difficult I think to provide a simple example that accurately reflects what is truly going on so there wouldn't be much point. Cheers, nnp On Thu, Apr 3, 2008 at 5:39 AM, Gabriel Genellina wrote: > En Wed, 02 Apr 2008 10:52:08 -0300, nnp escribi?: > > > Basically I have a system where component 1, 2 and 3 communicate with > > each > > other using two Python Queues, we'll call them R and W. Here is what is > > happening > > > > 1 writes data to W and reads from R > > 2 reads data from W and writes data it receives from 3 to R (but not > > data it > > receives from 1) > > 3 writes to W > > > > The problem is that data being written by 1 to W is appearing back on R. > > I > > have verified that 1 never writes to R and that 2 never writes data it > > receives from 1 to R, by overwriting the put() and put_nowait() methods > > of > > R. > > > > Is there any other way for data to get onto a queue or are there any > > known > > bugs with Python's Queue module that could lead to this kind of > > behaviour? > > Yes, your own code :) > Perhaps you put mutable objects into the queue, like a list? and later > modify the list in another place? > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://www.smashthestack.org http://www.unprotectedhex.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From Lie.1296 at gmail.com Tue Apr 22 07:06:47 2008 From: Lie.1296 at gmail.com (Lie) Date: Tue, 22 Apr 2008 04:06:47 -0700 (PDT) Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B80B5.1050500@cheimes.de> Message-ID: On Apr 21, 1:14 am, "Hank @ITGroup" wrote: > Christian Heimes wrote: > > Gabriel Genellina schrieb: > > >> Apart from what everyone has already said, consider that FreqDist may import other modules, store global state, create other objects... whatever. > >> Pure python code should not have any memory leaks (if there are, it's a bug in the Python interpreter). Not-carefully-written C extensions may introduce memory problems. > > > Pure Python code can cause memory leaks. No, that's not a bug in the > > interpreter but the fault of the developer. For example code that messes > > around with stack frames and exception object can cause nasty reference > > leaks. > > > Christian > > In order to deal with 400 thousands texts consisting of 80 million > words, and huge sets of corpora , I have to be care about the memory > things. I need to track every word's behavior, so there needs to be as > many word-objects as words. > I am really suffering from the memory problem, even 4G memory space can > not survive... Only 10,000 texts can kill it in 2 minutes. > By the way, my program has been optimized to ``del`` the objects after > traversing, in order not to store the information in memory all the time. May we be explained a little further on what you're doing on the 80 million words? Perhaps we could help you better the design since, as Christian Heimes has said, the 80 million words strains present day computers to hold on memory all at once as it requires 500 MBs to hold 80 million for 6 ASCII letters words. If you're using Unicode, this number may double or quadruple. A better solution may be achieved by loading parts of the text required and process it using generators or to index the words, it may be slower (or even faster as the OS wouldn't need to allocate as much memory) but that's a tradeoff you should decide on. From frikker at gmail.com Tue Apr 29 11:09:18 2008 From: frikker at gmail.com (blaine) Date: Tue, 29 Apr 2008 08:09:18 -0700 (PDT) Subject: Simple TK Question - refreshing the canvas when not in focus References: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> Message-ID: <01b7e1cd-2e30-4751-9be5-63684af6530d@8g2000hse.googlegroups.com> On Apr 29, 10:36 am, "Eric Brunel" wrote: > On Tue, 29 Apr 2008 15:22:12 +0200, blaine wrote: > > Hey everyone! > > I'm not very good with Tk, and I am using a very simple canvas to > > draw some pictures (this relates to that nokia screen emulator I had a > > post about a few days ago). > > > Anyway, all is well, except one thing. When I am not in the program, > > and the program receives a draw command (from a FIFO pipe), the canvas > > does not refresh until I click into the program. How do I force it to > > refresh, or force the window to gain focus? It seems like pretty > > common behavior, but a few things that I've tried have not worked. > > > Class screen(): > > def __init__(self): > > self.root = Tkinter.Tk() > > self.root.title('Nokia Canvas') > > self.canvas = Tkinter.Canvas(self.root, width =130, > > height=130) > > self.canvas.pack() > > self.root.mainloop() > > > Then somewhere a long the line I do: > > self.canvas.create_line(args[0], args[1], args[2], > > args[3], fill=color) > > self.canvas.pack() > > Unrelated question: why are you doing a .pack() again here? Packing the > widget just inserts it at the right place in its container, so you only > have to do it once. So the one you did in __init__ is enough. > > > I've tried self.root.set_focus(), self.root.force_focus(), > > self.canvas.update(), etc. but I can't get it. > > IIRC: > - self.root.set_focus() will only work if your application already has the > focus, so it's not what you need here. > - self.root.force_focus() is usually considered as evil: it'll give the > focus to your application whatever the user is doing, which is usually > *really* annoying. So I guess a lot of window managers just refuse to do > it; this may be what happens here. > > But self.canvas.update() should work. If it doesn't, then there are > probably limitations on your platform that prevents it to work... Do you > happen to have other applications that can update their display while they > don't have the focus? Do they have the same problem? If they do, it's > probably a limitation on the platform and I guess you won't be able to do > anything about it... BTW, what platform are you on? > > > Thanks! > > Blaine > > HTH > -- > python -c "print ''.join([chr(154 - ord(c)) for c in > 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])" Thanks a lot for the response! To answer your first question - I'm using pack() there because I didn't mean to slip it in - this is something I wrote very quickly and was playing around with... and pack() should not be there, heh. I'm just using OS X with Python 2.5. For the record - I don't mind if the application forces focus. The only time I will be running this emulator is when I'm trying to use it. I'll try the update() again. I would want to use that on the canvas itself right? Not the root window? Blaine From catalinfest at gmail.com Sat Apr 26 02:50:23 2008 From: catalinfest at gmail.com (catalinfest at gmail.com) Date: Fri, 25 Apr 2008 23:50:23 -0700 (PDT) Subject: new user Message-ID: <890bb3c8-94a7-4d08-8c3e-4260ab76b6f7@b1g2000hsg.googlegroups.com> Hi ! This is my first message . I new here . I like python , blender 3d and opengl and is a hobby for me. I have a site www.catalinfest.xhost.ro where i write about me and python , blender ... I hope learning more on this group . Have a nice day ! From exarkun at divmod.com Wed Apr 16 16:27:40 2008 From: exarkun at divmod.com (Jean-Paul Calderone) Date: Wed, 16 Apr 2008 16:27:40 -0400 Subject: Profiling, recursive func slower than imperative, normal? In-Reply-To: Message-ID: <20080416202740.6859.1493080452.divmod.quotient.30718@ohm> On Wed, 16 Apr 2008 13:18:22 -0700 (PDT), skanemupp at yahoo.se wrote: >the 0.409 vs 0.095 is the total times right? >so the imperative function is >4 times faster than the recursive. >or what does tottime stand for? > >is this always the case that the recursive function is slower? >the gain is less code? > >are some functions only implementable recursively? > Function calls (recursive or otherwise) are more expensive than for loops, so the version that replaces recursion with a loop is faster. Any function can be implemented without recursion, although it isn't always easy or fun. Jean-Paul From george.sakkis at gmail.com Tue Apr 1 12:48:26 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 1 Apr 2008 09:48:26 -0700 (PDT) Subject: class super method References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> <0eb3ee4e-82e2-419a-8e7b-4931f7b4effa@c26g2000prf.googlegroups.com> Message-ID: <5e597dca-204d-4ed6-b477-cdfb6e5eaa78@d21g2000prf.googlegroups.com> On Apr 1, 10:21 am, Ed Leafe wrote: > On Apr 1, 2008, at 8:43 AM, George Sakkis wrote: > > Pehaps, at least as long as you make sure that all superclasses have a > > compatible signature - which in practice typically means accept > > arbitrary *args and **kwargs in every class in the hierarchy like your > > example. Good luck figuring out what's wrong if it's not used > > consistently. > > See my comment above. If you do not know what you're doing, you > shouldn't be doing it. This is not the fault of super(); it's the > fault of a poor programmer. And I used generic *args and **kwargs in > the method sig since I was using made-up class names and methods. > Would you have reacted more favorably if I had used (self, foo, bar) > instead? No, that was exactly my point; with a non-generic signature like (self, foo, bar), it's a matter of time until some subclass breaks it. Non-trivial hierarchies with all __init__ having compatible signatures is not typical in my experience, but they have to be compatible to be used correctly with super. Here is the conclusion from the second article I linked: ''' If you do use super, here are some best practices: * Use it consistently, and document that you use it, as it is part of the external interface for your class, like it or not. * Never call super with anything but the exact arguments you received, unless you really know what you're doing. * When you use it on methods whose acceptable arguments can be altered on a subclass via addition of more optional arguments, always accept *args, **kw, and call super like "super(MyClass, self).currentmethod(alltheargsideclared, *args, **kwargs)". If you don't do this, forbid addition of optional arguments in subclasses. * Never use positional arguments in __init__ or __new__. Always use keyword args, and always call them as keywords, and always pass all keywords on to super. ''' > > In a sentence, it's better than nothing but worse than anything. > > I guess I must be the world's most amazing Python developer, as I've > used super() extensively for years without ever suffering any of the > pitfalls you and others describe. Some people use the same argument for explicit memory management in C/C ++. Sure, it can be done, but that doesn't make it elegant or trivial. When experts like Michele Simionato find super() tricky enough to write an article about it, that says something. George From bellman at lysator.liu.se Fri Apr 18 14:50:26 2008 From: bellman at lysator.liu.se (Thomas Bellman) Date: Fri, 18 Apr 2008 18:50:26 +0000 (UTC) Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> Message-ID: John Nagle writes: > Desktop or server? > If server, check what the major Linux distros, like Fedora > Core, are shipping with. For server, you should probably rather look at distros like RHEL/CentOS, Suse and Debian Stable. For what it's worth, Fedora 8 has Python 2.5, RHEL 5 ships with Python 2.4, and RHEL 4 has Python 2.3. Suse and Debian, I don't know. > Check major shared hosting providers to see what they're offering > to their customers as standard. I would expect that to often depend on what OS version they are using. And RHEL/CentOS 4 is still quite common, so if you want to reach a large "customer base", make sure that your Python programs work with Python 2.3. -- Thomas Bellman, Lysator Computer Club, Link??ping University, Sweden "Don't tell me I'm burning the candle at both ! bellman @ lysator.liu.se ends -- tell me where to get more wax!!" ! Make Love -- Nicht Wahr! From http Thu Apr 17 17:10:14 2008 From: http (Paul Rubin) Date: 17 Apr 2008 14:10:14 -0700 Subject: How to make this unpickling/sorting demo faster? References: <40a5d8f1-a246-4c48-8759-5b65324f9029@m73g2000hsh.googlegroups.com> Message-ID: <7xod88w5l5.fsf@ruckus.brouhaha.com> Steve Bergman writes: > Anything written in a language that is > 20x slower (Perl, Python, > PHP) than C/C++ should be instantly rejected by users on those grounds > alone. Well, if you time it starting from when you sit down at the computer and start programming, til when the sorted array is output, Python might be 20x faster than C/C++ and 100x faster than assembler. > I've challenged someone to beat the snippet of code below in C, C++, > or assembler, for reading in one million pairs of random floats and > sorting them by the second member of the pair. I'm not a master > Python programmer. Is there anything I could do to make this even > faster than it is? 1. Turn off the cyclic garbage collector during the operation since you will have no cyclic garbage. 2. See if there is a way to read the array directly (using something like the struct module or ctypes) rather than a pickle. 3. Use psyco and partition the array into several smaller ones with a quicksort-like partitioning step, then sort the smaller arrays in parallel using multiple processes, if you have a multicore CPU. 4. Write your sorting routine in C or assembler and call it through the C API. If the sorting step is a small part of a large program and the sort is using a lot of cpu, this is a good approach since for the other parts of the program you still get the safety and productivity gain of Python. > Also, if I try to write the resulting list of tuples back out to a > gdbm file, I don't understand what you're doing with gdbm. Just use a binary file. From sturlamolden at yahoo.no Tue Apr 15 16:51:50 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Tue, 15 Apr 2008 13:51:50 -0700 (PDT) Subject: Preferred method for "Assignment by value" References: <8562becb-9fef-415d-9640-05ef80123596@a5g2000prg.googlegroups.com> <534f02b3-1eda-4332-96ae-3db3d4b4f44a@s33g2000pri.googlegroups.com> Message-ID: On Apr 15, 8:19 pm, hall.j... at gmail.com wrote: > Coming from VBA I have a tendency to think of everything as an > array... Coding to much in Visual Basic, like Fortran 77, is bad for your mind. From deets at nospam.web.de Thu Apr 3 04:39:34 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 03 Apr 2008 10:39:34 +0200 Subject: Prototype OO In-Reply-To: References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> Message-ID: <65jjeaF2ghnarU1@mid.uni-berlin.de> > And I say "syntax should be the same". These are only opinions, so > forgive me for wasting your time. You mean like in JS? function foo(args) {} foo = function(args) {} Somehow the JS-designers also made a compromise to allow to create unnamed and named functions. Could it be that it make *sense* to sacrifice simplicity and orthogonality here, so that different usage scenarios get to be written concisely? Start coding in python. And enjoy it. Is it perfect? Heck no! But it sure is fun enough to deal with the occasional wart. Diez From pylists at arcor.de Sun Apr 13 05:31:54 2008 From: pylists at arcor.de (Penny Y.) Date: Sun, 13 Apr 2008 17:31:54 +0800 Subject: =?UTF-8?B?5pyJ5Lit5Zu95Lq65LmOPw==?= In-Reply-To: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> References: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> Message-ID: <4801D30A.501@arcor.de> bikthh at live.cn ??: > Python????????????????. hehe, so humorous you are! Yes I think python has good future. But it depends on what you use it to do. If you're a singer, a financier, a historian etc, you don't need python. But if you are playing in computer programming, it's valuable for you to take some time learning python. btw,I'm also newbie to python,but I like it. --penny From maxm at mxm.dk Tue Apr 22 07:18:58 2008 From: maxm at mxm.dk (Max M) Date: Tue, 22 Apr 2008 13:18:58 +0200 Subject: Python Success stories In-Reply-To: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: azrael skrev: > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" When I started writing in Python in the nineties there was a lot of tech-media coverage of Perl. Python was always mentioned as a rival to Perl in those articles. These days Python is mentioned in a lot of tech-articles. Perl is never mentioned as a rival in those articles. Other languages like Ruby are. Ok I am Python biased, but I don't see anything happen on the Perl front anymore. It has simply gone quiet. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science From donn at u.washington.edu Mon Apr 28 19:46:05 2008 From: donn at u.washington.edu (Donn Cave) Date: Mon, 28 Apr 2008 16:46:05 -0700 Subject: Simple unicode-safe version of str(exception)? References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> Message-ID: In article <481650E3.4060603 at v.loewis.de>, "Martin v. L?wis" wrote: > >> I have code like this: > >> except Exception, e: > >> self.setState(self.Failed, str(e)) > >> which fails if the exception contains a unicode argument. > > > > Fails how? > > ASCII encoding error, I suppose. It fails only if a) one argument > is a Unicode object, and b) that Unicode object contains non-ASCII > parameters. Seem ironic that this fails even though pretty nearly anything else is a valid input to str() -- socket, dict, whatever? A sort of generic solution might be to follow str's behavior with respect to '__str__', extending it to fall back to repr() whatever goes wrong. def xtr(a): try: return str(a) except: return repr(a) ... self.setState(self.Failed, xtr(e)) Donn Cave, donn at u.washington.edu From manthra.mohan at gmail.com Fri Apr 18 11:21:48 2008 From: manthra.mohan at gmail.com (Krishna) Date: Fri, 18 Apr 2008 08:21:48 -0700 (PDT) Subject: Excel Manipulation using Python Message-ID: I was trying to delete rows in an existing .xls file using python. How do I do that? I was using the following code, it seem to work if I type in python window, but if I save it in text editor and drage and drop the .py file, it doesnt work. What am I doing wrong here? Thanks for your help! import win32com.client from time import sleep excel = win32com.client.Dispatch("Excel.Application") def Extract(): excel.Visible = 0 workbook=excel.Workbooks.Open('C:\Trial.xls') i=1 for n in range(1,10): excel.Rows(i).Select excel.Selection.Delete excel.Selection.Delete i=i+2 workbook.Save() print "saved" excel.Quit() From martin at v.loewis.de Sun Apr 13 01:39:36 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 13 Apr 2008 07:39:36 +0200 Subject: Tremendous slowdown due to garbage collection In-Reply-To: <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: <48019C98.8040800@v.loewis.de> > I still don't see what is so good about defaults that lead to O(N*N) > computation for a O(N) problem, and I like Amaury's suggestion a lot, > so I would like to see comments on its disadvantages. Please don't > tell me that O(N*N) is good enough. For N>1E7 it isn't. Please understand that changing the defaults will *not* affect the asymptotic complexity. If your application shows O(N*N), then, multiplying each value in the gc frequency with 1000, your application might run faster, but it will *still* run at O(N*N). Regards, Martin From gagsl-py2 at yahoo.com.ar Wed Apr 16 11:15:38 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 08:15:38 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: <86063f29-21a8-4d5b-a374-cee0723e0852@a22g2000hsc.googlegroups.com> On 16 abr, 09:56, Aaron Watters wrote: > In my opinion python's adherence to backwards compatibility > has been a bit mythological anyway -- many new python versions > have broken my old code for no good reason. ?This is an irritant > when you have thousands of users out there who suddenly drop > your code, blame you and python, and move on to use something else. > Honestly, how hard would it have been to provide standard backwards > support for the old regex module as a standard module which simply > translated one regex string format to another, for example? Do you mean this? py> import reconvert py> help(reconvert) Help on module reconvert: NAME reconvert - Convert old ("regex") regular expressions to new syntax ("re"). FILE c:\apps\python24\lib\reconvert.py DESCRIPTION When imported as a module, there are two functions, with their own strings: convert(s, syntax=None) -- convert a regex regular expression to re syntax quote(s) -- return a quoted string literal When used as a script, read a Python string literal (or any other expression evaluating to a string) from stdin, and write the translated expression to stdout as a string literal. Unless stdout is a tty, no trailing \n is written to stdout. This is done so that it can be used with Emacs C-U M-| (shell-command-on-region with argument which filters the region through the shell command). > What I'm saying is that, for example, there are a lot > of cool tools out there for using Python to manipulate > postscript and latex and such. Most of those tools > require no maintenance, and the authors are not paying > any attention to them, and they aren't interested in > messing with them anymore. And they will continue to work using the Python version for which they were designed, or even a later one; probably up to the last 2.x. Some scripts designed for Python 1.x still work. Really I don't feel the 3.0 incompatibilities are so big. > My guess is that there are few > such tools for Ruby. However, I wouldn't be too > surprised if porting them to Ruby and testing them > properly is not much more difficult than porting them > to py3k and testing them properly... If you have to convert the code to 3.x, 2to3 does most of the dirty work. Of course you have to test properly - the same as with any new version. And you can't say seriously than porting to Ruby is easier than fixing the incompatibilities with 3.0 > Especially > since the basic treatment of strings is totally > different in py3k, it seems. No. The new str type is the (renamed) old unicode type. Old strings are called bytes now. Both are immutable and mostly support the same old methods. Comparing (2.5) dir(u"") with (3.0) dir(""): decode() is not supported anymore; new: isidentifier(), maketrans(). Comparing (old) str with (new) bytes: encode() is not supported, nor format(); fromhex() added. So they look basically the same to me. Ok, when in 2.x you write u"abc", it's spelled "abc" in 3.0; and when you write "abc" it will be spelled b"abc". But that change is easily done with the 2to3 tool, or using "from __future__ import unicode_literals" in Python 2.6. Again, not so terrible. It seems to me that the fear of the upcoming 3.0 is caused mostly by lack of information. -- Gabriel Genellina From stef.mientki at gmail.com Thu Apr 10 15:03:28 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Thu, 10 Apr 2008 21:03:28 +0200 Subject: win-shortcuts, file associates and command-line parameters ? Message-ID: <47FE6480.4090602@gmail.com> hello, under windows I tried to make a shortcut to a py -file, to run a program. So making a shortcut like this works perfect: D:\PyLab_Works.py But the problem is that I need to give some commandline parameters to the py-file, and D:\PyLab_Works.py btc_test But the parameter doesn't seem to arrive in the python program If I start with the python interpreter, the parameters do arrive at the program P:\pythonw.exe D:\PyLab_Works.py btc_test Although this method works, it makes the creation of shortcuts difficult (the paths are in real much longer). Is there a way to pass the commandline parameters correctly, without explicitly specifying the python interpreter ? thanks, Stef Mientki From sn at sncs.se Mon Apr 14 22:07:37 2008 From: sn at sncs.se (Sverker Nilsson) Date: Mon, 14 Apr 2008 19:07:37 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> Message-ID: On Apr 15, 2:58 am, ajaksu wrote: > On Apr 14, 8:10 pm, Sverker Nilsson wrote:> do i dare to open a thread about this? > > Yeah, you sure do! > > > come on you braver men > > Yeah! > > > we are at least not bought by g***le > > Hell no! > > > but why? others have said it so many times i think > > Huh?! > > > :-//// > > ?! Whatever! > > > but why? a few syntactic 'cleanups' for the cost of a huge rewrite of > > all the code that have been builtup from all the beginning when the > > once great Python came along and people began to use it and write code > > for it. Like all that code would have to be rewritten. blaah. > > Yeah! Woo-hoo! > Wait... What? No, no, you got it all wrong. Python developers are > being extra-careful and doing a lot of hard work to keep things sane, > allow easy migration, etc. > > > and i have perhaps been drinking but i have been p**d all week since i > > began look into this:-( > > Ah, OK, calm down and look again. Things are way better than you > think, but there is a lot of FUD going on too, so focus on serious, > reliable reports. > > Cheers, > Daniel What serious reports? From bobby.connor at gmail.com Tue Apr 1 12:11:12 2008 From: bobby.connor at gmail.com (bobby.connor at gmail.com) Date: Tue, 1 Apr 2008 09:11:12 -0700 (PDT) Subject: Homework help Message-ID: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> Hey guys I haev this homework assignment due today I don't necessarily want the answers, but need help on how to approach it/the steps i need to solve the problems Thanks # (2 Points) Write a python function howMany(item,lst) which accepts an item and a lst of items and returns the number of times item occurs in lst. For example, howMany(3,[1,2,3,2,3]) should return 2. # (2 Points) Write a python function upTo(n) which accepts a non- negative number n and returns a list of numbers from 0 to n. For example, upTo(3) should return the list [0, 1, 2, 3]. # (2 Points) Write a python function duplicate(lst) which accepts a lst of items and returns a list with the items duplicated. For example, duplicate([1,2,2,3]) should return the list [1, 1, 2, 2, 2, 2, 3, 3]. # (2 Points) Write a python function dotProduct(a,b) which accepts two lists of integers a and b that are of equal length and which returns the dot product of a and b. I.e., the sum a0 * b0 + ... + an-1 * bn-1 where n is the length of the lists. For example: dotProduct([1,2,3],[4,5,6]) is 1*4 + 2*5 + 3*6 = 4 + 10 + 18 = 32 # (2 Points) A pair (exp0, exp1) is a combination of expressions that are attached together by their joint membership in the pair. For example: >>> (1+2, 'This') (3, 'This') A component of a pair can be obtained using an index in brackets as with lists (and strings!). For example: >>> (33,44)[0] 33 Write a function zip(lst1, lst2) such that zip accepts two equal length lists and returns a list of pairs. For example, zip(['a', 'b', 'c'], [10, 20, 30]) should evaluate to the list [('a', 10), ('b', 20), ('c', 30)]. # (2 Points) Write a function unzip(lst) such that unzip accepts a list of pairs and returns two lists such that lst == zip(unzip(lst)). For example, unzip([('a', 10), ('b', 20), ('c', 30)] should evaluate to the pair (['a', 'b', 'c'], [10, 20, 30]). # (2 Points) Write a python function isAscending(lst) which accepts a non-empty list of integers and returns True if the numbers in the list are in ascending order. Otherwise it should return False. For example, isAscending([1]) should evaluate to True while isAscending([1,2,2]) should return False. From JesseAldridge at gmail.com Mon Apr 7 11:24:02 2008 From: JesseAldridge at gmail.com (Jesse Aldridge) Date: Mon, 7 Apr 2008 08:24:02 -0700 (PDT) Subject: Python Data Utils References: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> <8eec6557-784d-4fd8-8478-8da17aedf0ab@d1g2000hsg.googlegroups.com> <85979669-64ed-49a1-b154-595bed50179f@w5g2000prd.googlegroups.com> <204305df-2cc8-4f44-8b98-5696e135a936@d45g2000hsc.googlegroups.com> Message-ID: <9f35f47c-ef79-4501-8d3b-bb5adebac518@u3g2000hsc.googlegroups.com> > But then you introduced more. oops. old habits... > mxTextTools. This looks cool, so does the associated book - "Text Processing in Python". I'll look into them. > def normalise_whitespace(s): > ? ? return ' '.join(s.split()) Ok, fixed. > a.replace('\xA0', ' ') in there somewhere. Added. Thanks again. From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 18 04:14:59 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 18 Apr 2008 10:14:59 +0200 Subject: Database vs Data Structure? In-Reply-To: <61bf5f46-e917-4a98-b87f-8e5087cb07f7@a23g2000hsc.googlegroups.com> References: <61bf5f46-e917-4a98-b87f-8e5087cb07f7@a23g2000hsc.googlegroups.com> Message-ID: <4808586b$0$23721$426a74cc@news.free.fr> erikcw a ?crit : > Hi, > > I'm working on a web application where each user will be creating > several "projects" in there account, each with 1,000-50,000 objects. > Each object will consist of a unique name, an id, and some meta data. > > The number of objects will grow and shrink as the user works with > their project. > > I'm trying to decided whether to store the objects in the database > (each object gets it's own row) or to use some sort of data-structure > (maybe nested dictionaries or a custom class) and store the pickled > data-structure in a single row in the database (then unpickle the data > and query in memory). Yuck. Fighting against the tool won't buy you much - except for interoperability and maintainance headeaches. Either use your relational database properly, or switch to an object db - like ZODB or Durus - if you're ok with the implications (no interoperability, no simple query langage, and possibly bad performances if your app does heavy data processing). > A few requirements: > -Fast/scalable (web app) > -able to query objects based on name and id. > -will play nicely with versioning (undo/redo) Versionning is a somewhat othogonal problem. > Any input on the best way to go? My very humble opinion - based on several years of working experience with both the Zodb and many RDBMS - is quite clear : use a RDBMS and use it properly. From meisnernel73884 at gmail.com Wed Apr 30 06:36:47 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:36:47 -0700 (PDT) Subject: soul patch Message-ID: <16c6778a-39a4-4629-a8c5-306b0c453e8b@s50g2000hsb.googlegroups.com> soul patch http://crack.cracksofts.com From zolotoiklo at mail.ru Tue Apr 8 06:50:52 2008 From: zolotoiklo at mail.ru (=?KOI8-R?B?+s/Mz9TPyiDrzM/O?=) Date: Tue, 8 Apr 2008 03:50:52 -0700 (PDT) Subject: =?KOI8-R?B?6NXMwcjV0CDT0NLUydfO2cogz8LS1d4g0yDNwQ==?= =?KOI8-R?B?x87J1MHNySDV1NHWxczFzs7Zyg==?= Message-ID: <725ff219-90fc-431a-931d-bdb78967abea@m1g2000pre.googlegroups.com> Acu Hoop Pro. ?????????, ??????????? ?????-???????. ??? ??? ??? ? ????????? (Acu Hoop Pro) - ?????????? ???????? ????????? ?????????? ????? ??? ????, ??? ?????? ???????? ? ??????? ???????????? ????? ? ???????? ??????.?? ??????? 100 ??????? ?? ?????? 10 ????? ??????????!!! ????????? ??????????? ?????????????? ??????? ???????????, ????????? ????? ??? ??? ??? ???????? BRADEX ???????????? ???????? ???????? ?????????? ???? ? ??????? ????? ? ??????. ????????? ?????? ????? ? ?????. ???????? ? ???? ???????? ???????? ????-???? ? ???????? ?????????? ?????????????? ???????. ??? ???????????? ?????????? ???? ?????????? ??????? ?????????????? ? ???????? ? ?????? ? ?????????? ??????? ?????????. ????? ???????, ?????????? ?????????????????????, ??????????????, ??????????, ????????????? ????????. ????????? ???? ????????? ??????????? ?? ???????? ????????? ? ????? ?????????. ? ?????? ??????????? ?????????? ???? ?????????? ??????????????? (5-15 ?????) ?????????? ???????????? ?????????, ??????? ????? ????????? ??????????? ????????????????, ?????????? ????????? ???????????? ?????????, ????????? ?????????????? ??????????? ?????????? ??????, ? ?????????? ?? ???????????????. ???????? ????? ?? ???? ???? ??? ??? 40 ??? ???????? ???? ???? ????????. ?????? ????? - ??????? ???! ?????? ??????? - ????????? ?????! ??????? ????????? ????? http://shopbody.ru/bradexobruchmagnit.htm From n00m at narod.ru Sat Apr 26 23:58:38 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 20:58:38 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> Message-ID: Dennis Lee Bieber wrote: > (untested for both): > -=-=-=-=-=-=- Many thanks but alas both your codes got "wrong answer" verdict. I can't understand why; they seem Ok (but I'm a bit sleepy:)). From andrei.avk at gmail.com Tue Apr 1 21:15:15 2008 From: andrei.avk at gmail.com (AK) Date: Tue, 01 Apr 2008 20:15:15 -0500 Subject: Python-by-example - new online guide to Python Standard Library Message-ID: <47f2d018$0$6517$4c368faf@roadrunner.com> Hello, I find that I learn easier when I go from specific examples to a more general explanation of function's utility and I made a reference guide that will eventually document all functions, classes and methods in Python's Standard Library. For now, I covered about 20 most important modules. I will be adding more modules and eventually I'll cover everything. Here's my progress so far, let me know if this is useful; I'll be glad to hear comments/suggestions/etc: http://www.lightbird.net/py-by-example/ -- -ak Tobu | http://www.lightbird.net/tobu/ | Freeform DB / Tagger / PIM From NikitaTheSpider at gmail.com Wed Apr 9 13:25:22 2008 From: NikitaTheSpider at gmail.com (Nikita the Spider) Date: Wed, 09 Apr 2008 13:25:22 -0400 Subject: is Pylons alive? References: <663qr1F2ig5dkU1@mid.uni-berlin.de> Message-ID: In article <663qr1F2ig5dkU1 at mid.uni-berlin.de>, Gerhard H?ring wrote: > - TurboGears 2.0 (I personally wouldn't bother with TurboGears 1.x at > this point) Having investigated some of this myself recently, I agree with you that the TG 1.x series is a dead end, but there's no TG 2.0 yet. Last time I checked the developers hoped to have an alpha release at the end of March. -- Philip http://NikitaTheSpider.com/ Whole-site HTML validation, link checking and more From jeffober at gmail.com Mon Apr 28 09:22:32 2008 From: jeffober at gmail.com (Jeff) Date: Mon, 28 Apr 2008 06:22:32 -0700 (PDT) Subject: Regular Expression - Matching Multiples of 3 Characters exactly. References: Message-ID: <856060dd-d64d-4961-b57d-0ca7e93c053f@e39g2000hsf.googlegroups.com> Regular expressions for that sort of thing can get *really* big. The most efficient way would be to programmatically compose the regular expression to be as exact as possible. import re def permutation(lst): """" From http://labix.org/snippets/permutations/. Computes permutations of a list iteratively. """ queue = [-1] lenlst = len(lst) while queue: i = queue[-1]+1 if i == lenlst: queue.pop() elif i not in queue: queue[-1] = i if len(queue) == lenlst: yield [lst[j] for j in queue] queue.append(-1) else: queue[-1] = i def segment_re(a, b): """ Creates grouped regular expression pattern to match text between all possibilies of three-letter sets a and b. """ def pattern(n): return "(%s)" % '|'.join( [''.join(grp) for grp in permutation(n)] ) return re.compile( r'%s(\w+?)%s' % (pattern(a), pattern(b)) ) print segment_re(["a", "b", "c"], ["d", "e", "f"]) You could extend segment_re to accept an integer to limit the (\w+?) to a definite quantifier. This will grow the compiled expression in memory but make matching faster (such as \w{3,n} to match from 3 to n characters). See http://artfulcode.net/articles/optimizing-regular-expressions/ for specifics on optimizing regexes. From pavlovevidence at gmail.com Wed Apr 2 20:08:32 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Wed, 2 Apr 2008 17:08:32 -0700 (PDT) Subject: Nested try...except References: Message-ID: <670a8cc4-e3e0-412f-b259-5977f6d2f62d@a70g2000hsh.googlegroups.com> On Apr 2, 9:06 am, Magnus.Morab... at gmail.com wrote: > Hi, > > I found the following code on the net - > > http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/%3C20050924104732.5116.qm... at minotaur.apache.org%3E > > def count(self): > - db = sqlite.connect(self.filename, > isolation_level=ISOLATION_LEVEL) > - try: > - try: > - cur = db.cursor() > - cur.execute("select count(*) from sessions") > - return cur.fetchone()[0] > - finally: > - cur.close() > - finally: > - db.close() > > I don't understand though why the second try is not after the line cur > = db.cursor(). Can anyone explain for me why? It's a pretty common mistake to make, I assume because there's a tendency to line up the init and finalize statements. In other words, it looks wrong for open and close to be in different columns: open() try: do_stuff() finally: close() It's almost always wrong for initiazation to be inside of the try block. Perhaps the advent of with blocks will help reduce this error in the future. Carl Banks From bearophileHUGS at lycos.com Wed Apr 2 15:51:52 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Wed, 2 Apr 2008 12:51:52 -0700 (PDT) Subject: who said python can't be obsfucated!? References: Message-ID: cokofree...: > def s(c):return[]if c==[]else s([_ for _ in c[1:]if _=c[0]]) That QuickSort can be written as a lambda too: s=lambda l:[]if l==[]else s([x for x in l[1:]if x=l[0]]) Bye, bearophile From pydev at rscorp.ab.ca Thu Apr 10 00:03:30 2008 From: pydev at rscorp.ab.ca (Scott SA) Date: Wed, 9 Apr 2008 22:03:30 -0600 Subject: Linux Mag's "Introduction to Python Decorators" Message-ID: Hi, I've been trying to wrap my head around decorators and in my trails found a very recent article on Linux Mag's website. I didn't see a post here regarding this article and feel it is worth directing interested parties towards: Introduction to Python Decorators Have a web app that occasionally hangs? Use signals to add a timeout to function requests with Python decorators. Matthew Wilson Thursday, March 13th, 2008 The link req. registration (sorry, I can't do anything about that). In a brief summary: The author has a Linux-hosted Web service that occasionally hangs. He uses signals via decorators to overcome the problem in an elegant way. While some of the content may not be applicable to all readers needs for decorators, his illustration and description of the subject is very good (IMO, FWIW). I hope this helps others as much as it has for me, Scott From lxlaurax at gmail.com Tue Apr 15 22:17:31 2008 From: lxlaurax at gmail.com (lxlaurax at gmail.com) Date: Tue, 15 Apr 2008 19:17:31 -0700 (PDT) Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <101680ba-a116-414b-8fff-c5b5bd2f4b65@p39g2000prm.googlegroups.com> Message-ID: On 11 abr, 20:31, sturlamolden wrote: > On Apr 11, 5:01 am, "Gabriel Genellina" > wrote: > > > Another annoying thing with the Qt license is that you have to choose it > > at the very start of the project. You cannot develop something using the > > open source license and later decide to switch to the commercial licence > > and buy it. > > Trolltech is afraid companies will buy one licence when the task is > done, as oppsed to one license per developer. In a commercial setting, > the Qt license is not expensive. It is painful for hobbyists wanting > to commercialize their products. I have no experience with GUI programming in Python, but from this discussion it seems if the type of license is not an issue (for FOSS development), PyQt is the best tool because it is: (a) easier to learn and intuitive for programming (this is important to me; I am not that smart...); (b) more stable (although many people have said that wxPython is as stable as any other GUI nowadays; but not more stable (wx) than others); (c) more cross-platform (many people complain that they have to do a lot of things in wxPython for the cross-platform). Is (a) and (c) true or not? If so, how big are these advantages? The great advantage of wxPython seems to be the huge community of users and the large number of widgets/examples/applications available. Reformulating my question: Which GUI tool, wxPython or PyQt, is more pythonic? (Please, ignore the license issue because I am thinking about FOSS) Laura From nospam at nospam.invalid Tue Apr 29 12:17:10 2008 From: nospam at nospam.invalid (Rahul) Date: Tue, 29 Apr 2008 16:17:10 +0000 (UTC) Subject: python command mis-interprets arrow keys Message-ID: My python command line seems messed up. I can't seem to be able to use my backspace key nor my arrow keys. I only get control characters: ^[[A^[[D^[[D^[[D^[[C^[[C^[[C etc. I access my Linux box via a SecureCRT console. Only after opening the python interpreter does this occur. Linux command like is OK. vim interprets keystrokes correctly. So do other interpreters e.g. gnuplot. $LANG $TERM en_US xterm-color Versions: Python 2.4.4 GCC 4.1.2 20070925 (Red Hat 4.1.2-33) Any sugesstions? Google did not throw anything relevant. -- Rahul From munichlinux at news.motzarella.org Sun Apr 20 06:46:12 2008 From: munichlinux at news.motzarella.org (prashanth) Date: Sun, 20 Apr 2008 16:16:12 +0530 Subject: Checking if a text file is blank In-Reply-To: References: Message-ID: Hi elnoire at gmail.com wrote: > Greetings! > > Is there any way in python to check if a text file is blank? obviously there are many ways, one simple way is to check length if its None then the file is blank. > > What I've tried to do so far is: > > f = file("friends.txt", "w") > if f.read() is True: > """do stuff""" > else: > """do other stuff""" > f.close() If checking the file is blank is what you are tying to do then why do you open the file in the write mode. Prashanth From skanemupp at yahoo.se Fri Apr 11 18:41:10 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 11 Apr 2008 15:41:10 -0700 (PDT) Subject: tkinter, annoying grid-problem Message-ID: <094b0808-053a-4a36-be11-694bb3835bb5@q1g2000prf.googlegroups.com> so my little calculator works perfectly now. just having some trouble with the layout. this whole tkinter-thing seems to be more tricky than it should be. how can i make the 4 column of buttons have the same distance and size between them as the other 3 columns? and how can i make the top entry end where the 2nd row entry ends(meaning the top entry will be longer)? why are the 4th row split from the others? hard to fix the problems when u dont even understand why things happen. seems so llogical a lot of it. i change something then something unexpected happens. from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") l = Label(mygui, text="Answer: ") l.grid(row=2, column=1, columnspan=2, sticky=W) e = Entry(mygui) e.grid(row=1, column=1, columnspan=4, sticky=W) c = Entry(mygui) c.grid(row=2, column=3, columnspan=4, sticky=W) def Disp(nstr): e.insert(INSERT, nstr) def Calc(): expr=e.get() c.delete(0, END) try: c.insert(END, eval(expr)) except: c.insert(END, "Not computable") def Erase(): e.delete(0,END) c.delete(0, END) def Backspace(): a=len(e.get()) e.delete(a-1,END) #e.delete(INSERT, END) #e.delete(ANCHOR,END) x = 1 y = 4 for char in '123+456-789*0()/.': b = Button(mygui, text=char, command=lambda n=char:Disp(n), width=2, height=1) b.grid(row=y, column=x, sticky=W) x=x+1 if x==5: x=1 y=y+1 b = Button(mygui, text="^", command=lambda n="**":Disp(n), width=2, height=1) b.grid(row=8, column=2, sticky=W) b = Button(mygui, text="C",command=Erase, width=2, height=1) b.grid(row=8, column=3, sticky=W) b = Button(mygui, text="c",command=Backspace, width=2, height=1) b.grid(row=8, column=4, sticky=W) b = Button(mygui, text="=",command=Calc, width=18, height=1) b.grid(row=9, column=1, columnspan=4, sticky=W) mygui.mainloop() From john106henry at hotmail.com Sun Apr 27 19:11:28 2008 From: john106henry at hotmail.com (John Henry) Date: Sun, 27 Apr 2008 16:11:28 -0700 (PDT) Subject: How do I say "Is this a function"? References: <4813D22A.8040902@v.loewis.de> Message-ID: <7be299bd-4b39-4d46-94f5-ed5a0a895b46@c19g2000prf.googlegroups.com> On Apr 27, 10:49 am, Lie wrote: > On Apr 27, 11:01 am, John Henry wrote: > > > > > On Apr 26, 6:08 pm, "Martin v. L?wis" wrote: > > > > > def f1(): > > > > print "In f1" > > > > > def f3(): > > > > print "In f3" > > > > > def others(): > > > > print "In others" > > > > > for i in xrange(1,3): > > > > fct = "f%d()"%(i+1) > > > > try: > > > > exec fct > > > > except: > > > > others() > > > > I'd write that as > > > > for i in xrange(1,3): > > > globals().get("f%d" % (i+1), others)() > > > > Regards, > > > Martin > > > Perfect. Works great. No EXEC. > > > You guys are great. > > If you just want to avoid exec, why not: > > def f1: > print "In f1" > def f3: > print "In f3" > > class f4(object): > def __init__(self): > print "In f4" > > def others: > print "Since all else failed, I'm in others." > > f2 = "NAF -> Not a Function" > > flist = [f1, f2, f3, f4] > for fct in flist: > try: > fct() > except TypeError: > others() > > It's readable, and it's fast if there's just a few "hard fault" (try- > except works best when it usually succeed and just fails once or > twice), and it's Pythonic too (Easier to ask forgiveness than to ask > permission). The difference between this and the explicit type > checking is that this allows a class (like f4) to pass since a Class > Constructor & Initiator is a callable function too, depending on your > need, you might want to consider class constructor as a function too. The reason I didn't want to do that is because when something goes wrong inside the fcts, others gets executed. I wanted the program to crash and burn rather than running others. From sierra9162 at gmail.com Wed Apr 16 11:22:09 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:22:09 -0700 (PDT) Subject: kate hudson videos Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From deets at nospam.web.de Fri Apr 11 03:50:51 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 11 Apr 2008 09:50:51 +0200 Subject: How to use my dynamic link libraries in python?? In-Reply-To: References: Message-ID: <668jj5F2j08lrU1@mid.uni-berlin.de> ??? schrieb: > Hello: > My OS is Linux, I compile my dynamic link libraries , and > want to call the function of my dynamic library through python! > How can I realize the function? Please give me some advices! Thanks If the module has a plain C-interface, consider using ctypes to wrap it. It comes with python2.5, see the docs. If it is C++, I suggest using SIP, a very good C++-wrapper-generator. There are other options as well, SWIG and Boost-Python, which I can't comment though. Diez From Vern.Muhr at gmail.com Tue Apr 29 16:01:22 2008 From: Vern.Muhr at gmail.com (VernM) Date: Tue, 29 Apr 2008 13:01:22 -0700 (PDT) Subject: cytpes **int References: <56674130-c04e-403e-8364-92cbd158b2f0@b9g2000prh.googlegroups.com> <67mveuF2pauigU1@mid.uni-berlin.de> <67nv84F2l3ha7U1@mid.uni-berlin.de> Message-ID: <42bdae4a-ff8b-477c-bf76-1b33ad4a40b4@t12g2000prg.googlegroups.com> On Apr 28, 11:57?pm, "Diez B. Roggisch" wrote: > Gabriel Genellina schrieb: > > > > > > > [snip repetition] > > > That's true for "a pointer to a pointer to int", and it's valid if the > > functions references **b or b[0][0] - but in this case int** probably > > means "[pointer to] an array of arrays of int" and presumibly the > > function will try to access b[3][2] (or whatever indices are in range). > > The duality pointer/array in C is dangerous when defining interfases - > > you have to know how the value is intended to be accessed. > > (I assume the function modifies the integer values, but not the pointers > > themselves) > > > # build an array of 10x10 ints > > Arr10int = c_int * 10 > > Pint = POINTER(c_int) > > PPint = POINTER(Pint) > > Arr10pint = Pint * 10 > > a = Arr10pint() > > for i in range(10): > > ? ? a[i] = Arr10int() > > ... initialize the array ... > > ... load the function ... > > # call the function > > somefunction.argtypes = (PPint,) > > somefunction.restype = None > > somefunction(a) > > Yup, you are right - I somehow missed the access description and thought > of the pointer-to-a-pointer as out-parameter-spec. > > Diez- Hide quoted text - > > - Show quoted text - To provide a little more detail: currently, a DLL function uses malloc to create a pointer to a block of memory where the ints are stored This pointer is returned to python. Then a pointer to this pointer is passed to another C function which manipulates the ints. When that C function returns, python needs to access the int values. I am now able to get this to work with this grossly ugly code. # Setup a place to store the *int pointer pt = (ctypes.c_int * 1) cube = pt() cube[0] = dll.AllocCube() # Get the pointer to the ints # Call the function that manipulates the ints dll.FirstPrime(ctypes.byref(cube)) # Create a python list of the ints result = [ctypes.c_int.from_address(cube[0]+i*4).value for i in range(5)] I appreciate the suggestions so far. I know there must be a cleaner way to express this. I would prefer the array of ints to be built by cytpes, rather than by a C function in the DLL. From michele.simionato at gmail.com Sat Apr 5 13:07:35 2008 From: michele.simionato at gmail.com (Michele Simionato) Date: Sat, 5 Apr 2008 10:07:35 -0700 (PDT) Subject: Learning curve for new database program with Python? References: Message-ID: <7118c29f-7901-40e7-a410-783ade9c2f6b@a23g2000hsc.googlegroups.com> On Apr 5, 5:50 pm, Jetus wrote: > I have a need for a database program. I downloaded the db2 from ibm, > and reviewed some of the documentation. > > My question is, what is the easiest program for me to try to learn. I > will be creating a database of about 25,000 records, it will be > relational. I am a beginner Python programmer, and need a database > solution that is easy to grasp. I played with sql, > and found that very difficult, if not overly cumbersome. > > A database that could work with Django would be very interesting to > look at as well.. > > Any suggestions out there? sqlite is arguably the simplest relational database out there, and it is integrated with Python 2.5+. Of course you need to tell us if an embedded database if enough for your use case, or if you want a client-server database, if you use Windows or Unix, if you want graphical administration tools or not, what your final goal is, and so on. Michele Simionato From steve at holdenweb.com Sat Apr 5 07:14:56 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 07:14:56 -0400 Subject: Is there any way to say ignore case with "in"? In-Reply-To: <432d690f-44be-49a9-bc6a-1cf3445549d6@m71g2000hse.googlegroups.com> References: <47f692f3$0$759$bed64819@news.gradwell.net> <432d690f-44be-49a9-bc6a-1cf3445549d6@m71g2000hse.googlegroups.com> Message-ID: 7stud wrote: > On Apr 4, 2:43 pm, tinn... at isbd.co.uk wrote: >> Is there any way in python to say >> >> if string1 in string2: >> >> >> ignoring the case of string1 and string2? >> >> I know I could use:- >> >> if lower(string1) in lower(string2): >> >> >> but it somehow feels there ought to be an easier (tidier?) way. >> > > Easier? You mean like some kind of mind meld? > That's right, DWIM mode Python. Rock on! regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From hniksic at xemacs.org Tue Apr 22 02:36:51 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Tue, 22 Apr 2008 08:36:51 +0200 Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <480D71B9.40909@v.loewis.de> Message-ID: <87lk36e6po.fsf@mulj.homelinux.net> "Martin v. L?wis" writes: >> In py3k string%dictionary is going away. > > Why do you say that? It's not going away in Python 3.0. I also got the impression that it was going away. PEP 3101's abstract says: This PEP proposes a new system for built-in string formatting operations, intended as a replacement [sic] for the existing '%' string formatting operator. Under "Backward compatibility" it says that both systems can coexist "until it comes time to deprecate the older system". From breily at gmail.com Wed Apr 16 10:11:09 2008 From: breily at gmail.com (Brian) Date: Wed, 16 Apr 2008 10:11:09 -0400 Subject: is file open in system ? - other than lsof In-Reply-To: References: Message-ID: On Wed, Apr 16, 2008 at 10:00 AM, Chris McAloney wrote: > On 16-Apr-08, at 9:20 AM, A.T.Hofkamp wrote: > > On 2008-04-16, bvidinli wrote: > >> is there a way to find out if file open in system ? - > >> please write if you know a way other than lsof. because lsof if > >> slow for me. > >> i need a faster way. > >> i deal with thousands of files... so, i need a faster / python way > >> for this. > >> thanks. > > > > This is not a Python question but an OS question. > > (Python is not going to deliver what the OS doesn't provide). > > > > Please first find an alternative way at OS level (ie ask this > > question at an > > appropiate OS news group). Once you have found that, you can think > > about Python > > support for that alternative. > > I agree with Albert that this is very operating-system specific. > Since you mentioned 'lsof', I'll assume that you are at least using a > Unix variant, meaning that the fcntl module will be available to you, > so you can check if the file is already locked. > > Beyond that, I think more information on your application would be > necessary before we could give you a solid answer. Do you only need > to know if the file is open, or do you want only the files that are > open for writing? If you only care about the files that are open for > writing, then checking for a write-lock with fcntl will probably do > the trick. Are you planning to check all of the "thousands of files" > individually to determine if they're open? If so, I think it's > unlikely that doing this from Python will actually be faster than a > single 'lsof' call. > > If you're on Linux, you might also want to have a look at the /proc > directory tree ("man proc"), as this is where lsof gets its > information from on Linux machines. > > Chris > -- > I know this is a python list, but if speed is such an issue you might want to consider writing in C/C++. Both would be considerably faster than python. > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlwuhwdmckay at gmail.com Mon Apr 21 02:09:18 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:09:18 -0700 (PDT) Subject: call of duty united offensive patch Message-ID: <6b29044a-6b37-44df-b02a-b1b5312c9b30@l64g2000hse.googlegroups.com> call of duty united offensive patch http://cracks.00bp.com F R E E C R A C K S From zerty.david at gmail.com Wed Apr 30 10:52:40 2008 From: zerty.david at gmail.com (David Anderson) Date: Wed, 30 Apr 2008 11:52:40 -0300 Subject: psycopg2 ReferenceManual Message-ID: <5dc598e30804300752j1c36456bp40cf813754a01974@mail.gmail.com> Hi all, where can I find the reference manual from the psycopg2 or the dbapi2.0 because in their official pages I could'nt find thx -------------- next part -------------- An HTML attachment was scrubbed... URL: From floris.bruynooghe at gmail.com Thu Apr 10 10:37:30 2008 From: floris.bruynooghe at gmail.com (Floris Bruynooghe) Date: Thu, 10 Apr 2008 07:37:30 -0700 (PDT) Subject: @x.setter property implementation References: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> Message-ID: <02cb2845-6a25-4e90-9f82-dbd68b37a5e6@p39g2000prm.googlegroups.com> On Apr 7, 2:19 pm, "Andrii V. Mishkovskyi" wrote: > 2008/4/7, Floris Bruynooghe : > > > > > Have been grepping all over the place and failed to find it. I found > > the test module for them, but that doesn't get me very far... > > I think you should take a look at 'descrobject.c' file in 'Objects' directory. Thanks, I found it! So after some looking around here was my implementation: class myproperty(property): def setter(self, func): self.fset = func But that doesn't work since fset is a read only attribute (and all of this is implemented in C). So I've settled with the (nearly) original proposal from Guido on python-dev: def propset(prop): assert isinstance(prop, property) @functools.wraps def helper(func): return property(prop.fget, func, prop.fdel, prop.__doc__) return helper The downside of this is that upgrade from 2.5 to 2.6 will require code changes, I was trying to minimise those to just removing an import statement. Regards Floris From gagsl-py2 at yahoo.com.ar Wed Apr 2 22:22:48 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 02 Apr 2008 23:22:48 -0300 Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> <10ee2a69-f4e2-4887-8083-6b02b60dd0cd@i7g2000prf.googlegroups.com> Message-ID: En Wed, 02 Apr 2008 17:54:33 -0300, Jo?o Neves escribi?: > On 2 Abr, 21:38, "Chris Mellon" wrote: >> There is no need to overwrite co_code. Create a new code object with >> your desired bytecode and use that instead. > > Yes, it may work (haven't tested - isn't there any problem with stuff > like co_name, for instance?), but for simplicity's sake, wouldn't it > be far more convenient if you could just write over co_code? :) > In the end, it's all a matter of convenience, I guess. Functions aren't just code - they contain the environment needed to actually call the code. But they're easy to create given a code object: py> import new py> new.function py> help(new.function) Help on class function in module __builtin__: class function(object) | function(code, globals[, name[, argdefs[, closure]]]) | | Create a function object from a code object and a dictionary. | The optional name string overrides the name from the code object. | The optional argdefs tuple specifies the default argument values. | The optional closure tuple supplies the bindings for free variables. py> import types py> types.FunctionType is new.function is type(lambda:0) True -- Gabriel Genellina From hniksic at xemacs.org Mon Apr 21 16:29:03 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Mon, 21 Apr 2008 22:29:03 +0200 Subject: List of all Python's ____ ? References: Message-ID: <87wsmrdka8.fsf@mulj.homelinux.net> python at bdurham.com writes: > Is there an official list of all Python's ____? http://docs.python.org/ref/specialnames.html From aldo at nullcube.com Fri Apr 4 22:17:39 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Sat, 5 Apr 2008 13:17:39 +1100 Subject: ANN: pry unit testing framework In-Reply-To: <47F3CDBD.1010600@noaa.gov> References: <47F3CDBD.1010600@noaa.gov> Message-ID: <20080405021739.GA11777@nullcube.com> Hi Jim, Thus spake j vickroy (jim.vickroy at noaa.gov): > > We are happy to announce the first release of Pry, a unit testing framework. > > > > Features > > ======== > > > > * Built-in coverage analysis, profiling, and quick-and-dirty benchmarking > > * Assertion-based tests - no ugly failUnless*, failIf*, etc. methods > > * Tree-based test structure for better fixture management > > * No implicit instantiation of test suits > > * Powerful command-line interface > > > > > > Download: http://dev.nullcube.com > > > > Manual: http://dev.nullcube.com/doc/pry/index.html > > > > > It appears this package can not be used with Microsoft Windows because > it uses the *fcntl* module which is not part of the Windows distribution. Thanks for letting me know about this. I've just released version 0.2.1 of Pry, which addresses this and a few other Windows compatibility issues. You can download it here: http://dev.nullcube.com/download/pry-0.2.1.tar.gz Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From paulgeeleher at gmail.com Thu Apr 24 07:36:22 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Thu, 24 Apr 2008 04:36:22 -0700 (PDT) Subject: Spawing a thread and printing dots until it finishes References: <8df7dc55-7f93-4569-9643-21b4c99e2f33@l42g2000hsc.googlegroups.com> Message-ID: <10384208-7d8e-4d90-8ebe-d910a26a5947@2g2000hsn.googlegroups.com> On Apr 24, 12:32 pm, sophie_newbie wrote: > On Apr 22, 3:10 pm,sophie_newbie wrote: > > > > > Hi, I'm trying to write a piece of code that spawns a thread and > > prints dots every half second until the thread spawned is finished. > > Code is > > something like this: > > > import threading > > class MyThread ( threading.Thread ): > > def run ( self ): > > myLongCommand()... > > > import time > > > t = MyThread() > > t.start() > > > while t.isAlive(): > > print "." > > time.sleep(.5) > > > print "OK" > > > The thing is this doesn't print a dot every half second. It just > > pauses for ages until the thread is finished and prints prints ".OK". > > But if I take out the "time.sleep(.5)" line it will keep printing dots > > really fast until the thread is finished. So it looks like its the > > time.sleep(.5) bit that is messing this up somehow? > > > Any ideas? > > > Thanks! > > As it happens I've managed to come up with a solution to this problem > using a subprocess rather than a thread. Its not exactly rocket > science but I thought I'd post it anyway. There are 3 files: > > ########## dots.py ####################### > # a script to print a dot every half second until it is terminated > > import time > import sys > > while 1 == 1: > > sys.stdout.write(".") > sys.stdout.flush() > > time.sleep(.5) > > ######### PrintDots.py ###################### > > # This is a simple class to spawn off another process that prints dots > repeatedly on screen > # when printDots() is called and stops when stopDots is called. It is > useful in cgi-scripts > # where you may want to let the user know that something is happening, > rather than looking > # at a blank screen for a couple of minutes. > > import time > import subprocess > import os > from signal import SIGTERM > > class PrintDots: > > # the constructor, called when an object is created. > def __init__(self): > > self.pid = 0 > > # the location of the script that prints the dots > self.dotsScript = "dots.py" > > def printDots(self): > > self.pid = subprocess.Popen( [ "python", self.dotsScript] ).pid > > def stopDots(self): > > os.kill(self.pid, SIGTERM) > > ############ mainFile.py ############################## > # The above can then be called from any cgi-script as follows > > from PrintDots import PrintDots > p = PrintDots() > p.printDots() > print "Doing R Stuff" > my_Call_To_R_That_Takes_A_Long_Time() > p.stopDots() > print "OK" > > ############ > > And low and behold dots are printed on screen every half second while > python is talking to R, with an output like this: > > Doing R Stuff.................................OK Whoops that last bit of code should read as follows: from PrintDots import PrintDots p = PrintDots() print "Doing R Stuff" p.printDots() my_Call_To_R_That_Takes_A_Long_Time() p.stopDots() print "OK" From gagsl-py2 at yahoo.com.ar Wed Apr 9 10:14:03 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 9 Apr 2008 07:14:03 -0700 (PDT) Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> Message-ID: On 9 abr, 10:27, subhabrata.i... at hotmail.com wrote: > comp.lang.python is supposed to be a serious group not anyone knowing > nothing and giving comment. Anyone is welcome to post in this group - from beginners to gurus, and that's a very good thing. All people here is usually very kind and helpful, and that's not very common on Usenet. > Well, original code snippet I don't know > why an expert person like you fails to understand, I told it almost > can't you guess the next portion? Tough indeed, then. I've to take > permission from my organization if we can bring out this code in > public domain as we are working out an MT system that performs better > than Systran. And if it is a public domain I donot have security for > my code. Any one can copy. How could anyone give some advise on what's wrong with your code, if you don't show it? All you said is that you used urllib2 - there are millions of ways to use the library, good and bad. > But well if this group people are helping out of kindness, then I have > to think. Nobody here is being paid for helping others, they're all volunteers. But even if there were some paid consultants, nobody has a crystall ball, nobody can *guess* what's wrong with your code if you don't post it. About your crazy 500 if/elif: if all of them are like your posted fragment, this needs a huge refactoring. After three repeats of the same structure any sane programmer would say "hey, let's rearrange this!". Someone posted an alternative, after guessing a bit what you actually want to do. Note that "a in b" and "a not in b" cover ALL possibilities ("tertium non datur") so your 3-way ifs are wrong. If you want to determine which strings from a set -if any- are contained in another string, use some variant of the Aho-Corasick algorithm. -- Gabriel Genellina From yves at zioup.com Mon Apr 14 23:55:55 2008 From: yves at zioup.com (Yves Dorfsman) Date: Tue, 15 Apr 2008 03:55:55 GMT Subject: how to remove \n in the list In-Reply-To: References: <2ba667ab-6818-47eb-8595-79ed970728f7@q1g2000prf.googlegroups.com> Message-ID: Gabriel Genellina wrote: > En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam >> l=['5\n', '2\n', '7\n', '3\n', '6\n'] >> >> how to remove \n from the given list > > l is is very poor name... I'll use lines instead: > > lines[:] = [line.rstrip('\n') for line in lines] When I saw the original message, I immediately thought: k = [x.strip() for x in l] What is the point of the [:] after lines ? How different is it with or without it ? Yves. http://www.SollerS.ca From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 3 06:56:45 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 03 Apr 2008 12:56:45 +0200 Subject: What motivates all unpaid volunteers at Pycon? In-Reply-To: <6ffcb45b-abb9-4d5e-8237-0f8c6bacab08@i29g2000prf.googlegroups.com> References: <7b539c8e-af4c-4409-81bc-d94e687eea59@i7g2000prf.googlegroups.com> <12d7412e-9f87-4798-a319-a78a27f68d00@e6g2000prf.googlegroups.com> <6ffcb45b-abb9-4d5e-8237-0f8c6bacab08@i29g2000prf.googlegroups.com> Message-ID: <47f4b7ed$0$18744$426a34cc@news.free.fr> seberino at spawar.navy.mil a ?crit : > On Apr 1, 11:45 am, Ed Leafe wrote: > Assuming that people get nothing back by participating in a >> community, yes, it would be curious. My experience, though, is that I >> get a lot more out of it than I could ever contribute. IOW, it's a >> great example of synergy. > > What do the people get back who did all the hard work at registration > desk and > preparing conference attendee bags? ...who did all hotel preparations? I can't speak for them, but I'd think they feel like they *already* got at least a couple things 'back': a language they like, and a helpful community. Just my 2 cents... From frikker at gmail.com Wed Apr 23 14:11:46 2008 From: frikker at gmail.com (blaine) Date: Wed, 23 Apr 2008 11:11:46 -0700 (PDT) Subject: Unix Device File Emulation References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> <480f6376$0$9037$5402220f@news.sunrise.ch> <9ee87070-be57-4a66-a152-3f36c1cc8f0c@k13g2000hse.googlegroups.com> <480f7983$0$9036$5402220f@news.sunrise.ch> Message-ID: <49529b68-88b4-4115-a85a-587528274a50@m73g2000hsh.googlegroups.com> On Apr 23, 2:01 pm, "Martin Blume" wrote: > "blaine" schrieb > > > > > > while 1: > > > r = self.fifodev.readline() > > > if r: print r > > > > According to my docs, readline() returns an empty > > > string at the end of the file. > > > Also, you might want to sleep() between reads a > > > little bit. > > > Oh ok, that makes sense. Hmm. So do I not want to use > > readline()? Or is there a way to do something like > > 'block until the file is not empty'? > > No, > while 1: > r = self.fifodev.readline() > if r: print r > else: time.sleep(0.1) > is ok (note the "if r:" clause). > > Martin Beautiful! Thanks Martin! From __peter__ at web.de Thu Apr 24 08:04:27 2008 From: __peter__ at web.de (Peter Otten) Date: Thu, 24 Apr 2008 14:04:27 +0200 Subject: How to get inner exception traceback References: <67b8nuF2m1a1kU1@mid.individual.net> Message-ID: Thomas Guettler wrote: > How can you get the traceback of the inner exception? You have to record it yourself or it will be lost. > try: > try: > import does_not_exit > except ImportError: > raise Exception("something wrong") > except: > ... > > > Background: In Django some exceptions are caught and a new > exception gets raised. Unfortunately the real error is hard > to find. Sometimes I help myself and change (in this example) > ImportError to e.g. IOError and then I can see the real root > of the problem. But maybe there is a way to get the inner > exception and its traceback. This could be displayed in the > debug view. You can get the current exception and traceback with sys.exc_info() and later print or format it using the traceback module. >>> try: ... 1/0 ... except Exception: ... x = sys.exc_info() ... raise ValueError ... Traceback (most recent call last): File "", line 5, in ValueError >>> traceback.print_exception(*x) Traceback (most recent call last): File "", line 2, in ZeroDivisionError: integer division or modulo by zero Peter From pofuk at mzm.hr Sat Apr 5 17:11:07 2008 From: pofuk at mzm.hr (SMALLp) Date: Sat, 05 Apr 2008 23:11:07 +0200 Subject: Transparent bitmap(image) in windows! In-Reply-To: References: Message-ID: this is code that adds image: kartaGif = wx.Image("slike/karta.gif", wx.BITMAP_TYPE_GIF) kartaGif.Rescale(self.sizeX, self.sizeY) kartaGif = wx.BitmapFromImage(kartaGif) mask = wx.Mask(kartaGif, wx.WHITE) kartaGif.SetMask(mask) self.karta = wx.StaticBitmap(self.mPanel, -1, kartaGif, (10, 10), (kartaGif.GetWidth(), kartaGif.GetHeight())) self.karta.Bind(wx.EVT_LEFT_DOWN, self.getPos) SMALLp wrote: > Hello everyone! > > First I want to apologize for asking question about wxPython on this group. > > I'm doing project that uses wx.ScrolledPanel few wx.Bitmap on it. It all > looks wonderful on Ubuntu and very very bad on windows because images > aren't transparent. As a found out it is problem that windows drowns > each image in separate window (or something like that) > > I'm looking for best and easiest solution for this problem. I found > something to bind PAINT event to empty function but it doesn't work > because of scrolled panel. > > Please help! > > Thanks! From john106henry at hotmail.com Thu Apr 3 20:00:18 2008 From: john106henry at hotmail.com (John Henry) Date: Thu, 3 Apr 2008 17:00:18 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> <58deb8b8-bae9-4d43-b973-3d90846726cb@b5g2000pri.googlegroups.com> <42106982-8d2e-4c98-b316-d6dc0a675230@a23g2000hsc.googlegroups.com> Message-ID: On Apr 3, 12:24 pm, ajaksu wrote: > On Apr 2, 5:01 pm, John Henry wrote: > > > However, once I start teaching him variables, expressions, loops, and > > what not, I found that (by surprise) he had great difficulties > > catching on. Not soon after that, we had to quit. > > This makes me curious: how much of videogamer are you? And your son? > You mean you are able to find a kid that isn't a videogamer these days? My level of videogame went as far as Black Hawk Down and that was about it. I find it hard to comprehand why they like to do Gaiter Hero III. With Counter Strike, at least you have some interesting scene to look at. But then again, I am not a kid anymore (not by a long stretch). > I ask that because when I think about teaching programming to young > kids, I imagine using terms they know from gaming, like "save > slots" (variables/names), "memory cards" (containers), > "combos" (functions, loops), "life meters" (counters), "next > level" (conditionals, iteration, loops), "teammates" (helper > functions), "character classes" and "characters" (class and > instances), "confirm/cancel" (conditionals), etc. > > But I've never really tried to put all those together and find a test > subject, so I'd like to know how fluent in this lingo you both were so > I can assess my pseudo-didatic approach by proxy :) > > Regards, > Daniel Well, I can't say that I am a child education expert, I am only commenting base on my last several years of volunteering activities. I've found that whenever there is a visual approach to a topic, I can hold their attention far longer. Case in point, rather than asking to read building instructions for a Lego robot, I gave them access to Leocad: a CAD program that allow them to "put together" a robot virtually. They can spin the virtual robot around, break-up the pieces virtually, and put them the robot virtually. Then they build the real thing from there. When they're done, they can made their product presentation using 3-D renderization programs (VPython stuff, I can see now). With this approach, I was able to hold the attentions of the middle school kids - even a couple of 4th graders. They were able to "program" their robots using the Lego Mindstorm ICONic programming language - and later onto the Labview based Robolab language. I think the color, the sound, the icons, videos of these visual programming languages means a lot to kids. I wish there is a visual Python - much like the Robolab/Labview approach to programming. Several of the kids continued to stay involved with our activities for several years. I was able to teach them "programming" without really really teaching them "programming". I hope they do well in high school. But then they told me the first "computer programming" class at the local high school will be teaching Office, Flash, ... Of the 18 middle-schools in our district, ours was the only one that taught the kids about computer applications and "programming" early. Unfortunately, due to budget cut, they had no choice but to cut that class (lack of staff). And without a teacher sponsoring our activities, my volunteering activity is also coming to a close. But I sure learned a lot about how kids learn (and can't learn). From sbergman27 at gmail.com Wed Apr 16 09:53:32 2008 From: sbergman27 at gmail.com (Steve Bergman) Date: Wed, 16 Apr 2008 06:53:32 -0700 (PDT) Subject: Python module for reading FilePro files? Message-ID: Does anyone know of a Python package or module to read data files from the venerable old Filepro crossplatform database/IDE? From __peter__ at web.de Wed Apr 30 11:31:17 2008 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Apr 2008 17:31:17 +0200 Subject: printing inside and outside of main() module References: <9bd5c596-da19-4615-a4d8-e47b20cfb362@m73g2000hsh.googlegroups.com> Message-ID: korean_dave wrote: > This allows me to see output: > > ---begin of try.py > print "Hello World" > --end of try.py > > This DOESN'T though... > > --begin of try2.py > def main(): > return "Hello" main() # add this > --end of try2.py > > Can someone explain why??? Python doesn't call the main() function; you have to invoke it explicitly. Peter From fetchinson at googlemail.com Thu Apr 3 18:46:46 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Thu, 3 Apr 2008 15:46:46 -0700 Subject: id functions of ints, floats and strings In-Reply-To: References: Message-ID: > Hi all, > > I've been playing around with the identity function id() for different > types of objects, and I think I understand its behaviour when it comes > to objects like lists and tuples in which case an assignment r2 = r1 > (r1 refers to an existing object) creates an alias r2 that refers to > the same object as r1. In this case id(r1) == id(r2) (or, if you > like: r1 is r2). However for r1, r2 assigned as follows: r1 = [1, 2, > 3] and r2 = [1, 2, 3], (r1 is r2) is False, even if r1==r2, > etc. ...this is all very well. Therefore, it seems that id(r) can be > interpreted as the address of the object that 'r' refers to. > > My observations of its behaviour when comparing ints, floats and > strings have raised some questions in my mind, though. Consider the > following examples: > > ######################################################################### > > # (1) turns out to be true > a = 10 > b = 10 > print a is b > > # (2) turns out to be false > f = 10.0 > g = 10.0 > print f is g > > # behaviour when a list or tuple contains the same elements ("same" > meaning same type and value): > > # define the following function, that checks if all the elements in an > iterable object are equal: > > def areAllElementsEqual(iterable): > return reduce(lambda x, y: x == y and x, iterable) != False > > # (3) checking if ids of all list elements are the same for different > cases: > > a = 3*[1]; areAllElementsEqual([id(i) for i in a]) # True > b = [1, 1, 1]; areAllElementsEqual([id(i) for i in b]) # True > f = 3*[1.0]; areAllElementsEqual([id(i) for i in f]) # True > g = [1.0, 1.0, 1.0]; areAllElementsEqual([id(i) for i in g]) # True > g1 = [1.0, 1.0, 0.5+0.5]; areAllElementsEqual([id(i) for i in g1]) # > False > > # (4) two equal floats defined inside a function body behave > differently than case (1): > > def func(): > f = 10.0 > g = 10.0 > return f is g > > print func() # True > > ###################################################### > > I didn't mention any examples with strings; they behaved like ints > with respect to their id properties for all the cases I tried. > While I have no particular qualms about the behaviour, I have the > following questions: Small integers and short strings are cached and reused and for these ( r1 == r2 ) implies ( r1 is r2 ). For longer strings or larger integers this does not happen and so in general ( r1 == r2 ) does not imply ( r1 is r2 ). The caching and reuse is for performance gains and is an implementation detail which should not be relied upon. > 1) Which of the above behaviours are reliable? For example, does a1 = > a2 for ints and strings always imply that a1 is a2? No, see above. > 2) From the programmer's perspective, are ids of ints, floats and > string of any practical significance at all (since these types are > immutable)? You can check identity (and not equality) with them. So whenever you need that they are practically useful if all you need is equality they are useless. > 3) Does the behaviour of ids for lists and tuples of the same element > (of type int, string and sometimes even float), imply that the tuple a > = (1,) takes (nearly) the same storage space as a = 10000*(1,)? (What > about a list, where elements can be changed at will?) I'm not sure about tuples but for lists the storage space needed for 10000*(1,) is roughly 10000 times more than for (1,). > Would appreciate your responses... HTH, Daniel From danb_83 at yahoo.com Thu Apr 3 20:21:11 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Thu, 3 Apr 2008 17:21:11 -0700 (PDT) Subject: regarding memoize function References: Message-ID: <94a9e7e6-a623-4783-81da-f69654e51349@e10g2000prf.googlegroups.com> On Apr 3, 6:33 pm, ankitks.mi... at gmail.com wrote: > I saw example of memoize function...here is snippet > > def memoize(fn, slot): > def memoized_fn(obj, *args): > if hasattr(obj, slot): > return getattr(obj, slot) > else: > val = fn(obj, *args) > setattr(obj, slot, val) > return val > return memoized_fn > > and I am really clueless, about what it does. I know in general we try > to keep computed values for future usage. But I am having hard-time > visualizing it. > What is obj here? and what does *args means? *args is Python's syntax for variadic functions. From paul.hankin at gmail.com Fri Apr 11 03:56:05 2008 From: paul.hankin at gmail.com (Paul Hankin) Date: Fri, 11 Apr 2008 00:56:05 -0700 (PDT) Subject: Integer dicision References: <5f499bee-a659-4e36-870c-076cb613a3e7@t12g2000prg.googlegroups.com> Message-ID: <354a333b-9c5c-4f84-9a9b-e9717ba6b807@m3g2000hsc.googlegroups.com> On Apr 11, 6:06?am, casevh wrote: > On Apr 10, 9:28 pm, bdsatish wrote: > > > How does (a/b) work when both 'a' and 'b' are pure integers ? > > Python defines the quotient and remainder from integer division so > that a = qb + r and 0<=r < abs(b). C/C++ lets the remainder be > negative. On Apr 11, 6:06 am, casevh wrote: > On Apr 10, 9:28 pm, bdsatish wrote: > > > How does (a/b) work when both 'a' and 'b' are pure integers ? > > Python defines the quotient and remainder from integer division so > that a = qb + r and 0<=r < abs(b). C/C++ lets the remainder be > negative. On Apr 11, 6:06 am, casevh wrote: > On Apr 10, 9:28 pm, bdsatish wrote: > > > How does (a/b) work when both 'a' and 'b' are pure integers ? > > Python defines the quotient and remainder from integer division so > that a = qb + r and 0<=r < abs(b). C/C++ lets the remainder be > negative. (Puts language lawyer hat on) That's not accurate: r can be negative. To quote the reference manual: 'The modulo operator always yields a result with the same sign as its second operand (or zero); the absolute value of the result is strictly smaller than the absolute value of the second operand.' divmod(9, -2) # (-5, -1) Both C and Python define q = a / b and r = a % b to satisfy a = q * b + r, where -abs(b) < r < abs(b). Where they differ: Python: r has the same sign of b (or 0). C99: r has the same sign as a (or 0). C89 (Standard C): It's implementation defined what sign r has if either a or b is negative. This means python already has C-like behaviour... it's compatible with standard C, although not with C99. -- Paul Hankin From mccredie at gmail.com Fri Apr 18 17:09:20 2008 From: mccredie at gmail.com (Matimus) Date: Fri, 18 Apr 2008 14:09:20 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: <0ebcf70f-c6d6-4ee7-9ef8-7cd2221ef906@t12g2000prg.googlegroups.com> On Apr 18, 8:58 am, Aaron Watters wrote: > Why is the migration to py3k a concern? > For example I have libraries which use string%dictionary > substitution where the dictionary is actually an object > which emulates a dictionary. The __getitem__ for > the object can be very expensive and is only called when > needed by the string substitution. > > In py3k string%dictionary is going away. Why? > I have no idea. > > The replacement is a string.format(...) method > which supports dictionary calling. > string.format(**dictionary) > But dictionary > calling doesn't support dictionary emulation. > So in the example below the substitution works > but the call fails. > > === code > > class fdict(dict): > def __getitem__(self, item): > return "got("+item+")" > > def fn(**d): > print d["boogie"] > > if __name__=="__main__": > fd = fdict() > print "attempting string substitution with fake dictionary" > print > print "hello there %(boogie)s" % fd # <-- works > print > print "now attempting function call with fake dictionary" > print > fn(**fd) # <-- fails > > === output > > % python2.6 dtest.py > attempting string substitution with fake dictionary > > hello there got(boogie) > > now attempting function call with fake dictionary > > Traceback (most recent call last): > File "dtest.py", line 17, in > fn(**fd) > File "dtest.py", line 7, in fn > print d["boogie"] > KeyError: 'boogie' > > ==== end of output > > Consequently there is no simple way to translate > my code, I think. I suspect you will find this kind of subtle > issue in many places. Or worse, you won't find it > until after your program has been installed > in production. > > It's a damn shame because > if string%dict was just left in it wouldn't be an issue. > > Also, if making f(**d) support dict emulation > has any negative performance implications > then I don't want it please. > > sigh. -- Aaron Watters > > ===http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=crack+open The reason it doesn't work is that you are unpacking the dictionary with **, and you have done nothing to define any keys or define a length. I would describe the way you are using dict as a hack, and not part of any standard feature. You make a good point that it breaks your code, but at the same time the format facility gives you the ability to do something similar but in a standard way. You simply define a class with a __format__ method and pass that in instead of your dict. class MyClass: def __format__(self, spec): return "got({0})".format(spec) c = MyClass() print ("hey everybody {0:some words}".format(c)) print ("lets try this {0:more words} {0:even more words}".format(c)) should produce: hey everybody got(some words) lets try this got(more words) got(even more words) My point is that instead of exploiting the string formatting of dictionaries feature to create a custom format specifier, you actually get to define your own format specifiers, something which is much more powerful. And actually, you can do this too... which is even simpler and allows you to use your a portion of your existing solution: class fdict(dict): def __getitem__(self, item): return "got("+item+")" fd = fdict() print ("hello there {0[boogie]} hello there {0[george])".format(fd)) Which should result in: hello there got(boogie) hello there got(george) * Keep in mind that I have not tested any of this code, there may be bugs. I don't have Py3k or 2.6 installed locally. I think this is a good trade-off. Adding to that... don't worry about py3k. Nobody is forcing you to switch. In fact, you are encouraged not to until you are comfortable. Py3k won't _break_ your code. You wrote the code for Python 2.x use it in 2.x. Python 2.x probably has a good 5-10 years remaining. Matt From skanemupp at yahoo.se Thu Apr 10 06:13:32 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 03:13:32 -0700 (PDT) Subject: questions about Exceptions? References: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> <71cc8c25-f5f9-4f21-a9d8-06780bf97608@f63g2000hsf.googlegroups.com> <9af81b1a-3e02-4406-b9d2-0a9b6f46566b@p39g2000prm.googlegroups.com> Message-ID: <0e586d5d-6799-433f-b8a4-4de5d2a87b61@h1g2000prh.googlegroups.com> here is the whole code: from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") w = Label(mygui, text="Answer: ") w.place(relx=0.15, rely=0.1, anchor=CENTER) nbr = "" def Disp(nstr): global nbr nbr=nbr+nstr print "You need to seek help!",nbr def Calc(): global nbr try: print eval(nbr) #a = Label(mygui, text=eval(nbr)) #a.place(relx=0.4, rely=0.1, anchor=CENTER) except: print "Not computable" nbr = "" def Erase(): global nbr nbr = "" b = Button(mygui, text="1",command=lambda n='1':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.2, anchor=CENTER) b = Button(mygui, text="2",command=lambda n='2':Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.2, anchor=CENTER) b = Button(mygui, text="3",command=lambda n='3':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.2, anchor=CENTER) b = Button(mygui, text="+",command=lambda n='+':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.2, anchor=CENTER) b = Button(mygui, text="4",command=lambda n='4':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.3, anchor=CENTER) b = Button(mygui, text="5",command=lambda n='5':Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.3, anchor=CENTER) b = Button(mygui, text="6",command=lambda n='6':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.3, anchor=CENTER) b = Button(mygui, text="-",command=lambda n='-':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.3, anchor=CENTER) b = Button(mygui, text="7",command=lambda n='7':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.4, anchor=CENTER) b = Button(mygui, text="8",command=lambda n='8':Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.4, anchor=CENTER) b = Button(mygui, text="9",command=lambda n='9':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.4, anchor=CENTER) b = Button(mygui, text="*",command=lambda n='*':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.4, anchor=CENTER) b = Button(mygui, text="0",command=lambda n='0':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.5, anchor=CENTER) b = Button(mygui, text="C",command=Erase, width=2, height=1) b.place(relx=0.2, rely=0.5, anchor=CENTER) b = Button(mygui, text="^.5",command=lambda n='**.5':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.5, anchor=CENTER) b = Button(mygui, text="/",command=lambda n='/':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.5, anchor=CENTER) b = Button(mygui, text="=",command=Calc, width=2, height=1) b.place(relx=0.2, rely=0.7, anchor=CENTER) mygui.mainloop() From srf99 at ferg.org Wed Apr 16 13:01:55 2008 From: srf99 at ferg.org (srf99 at ferg.org) Date: Wed, 16 Apr 2008 10:01:55 -0700 (PDT) Subject: What can we do about all the spam that the list is getting? Message-ID: <259ab201-9d2b-4e4e-88a7-e2fe277f0066@a23g2000hsc.googlegroups.com> What can we do about all the spam that comp.lang.python is getting? Things are getting pretty bad. From tinnews at isbd.co.uk Sun Apr 6 09:41:35 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 06 Apr 2008 13:41:35 GMT Subject: Presumably an import is no faster or slower than opening a file? Message-ID: <47f8d30f$0$761$bed64819@news.gradwell.net> I'm trying to minimise the overheads of a small Python utility, I'm not really too fussed about how fast it is but I would like to minimise its loading effect on the system as it could be called lots of times (and, no, I don't think there's an easy way of keeping it running and using the same copy repeatedly). It needs a configuration file of some sort which I want to keep separate from the code, is there thus anything to choose between a configuration file that I read after:- f = open("configFile", 'r') ... and importing a configuration written as python dictionaries or whatever:- import myConfig -- Chris Green From Scott.Daniels at Acm.Org Sat Apr 19 14:27:20 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Sat, 19 Apr 2008 11:27:20 -0700 Subject: Database vs Data Structure? In-Reply-To: References: <61bf5f46-e917-4a98-b87f-8e5087cb07f7@a23g2000hsc.googlegroups.com> Message-ID: castironpi at gmail.com wrote: > On Apr 18, 12:23 am, I V wrote: >> On Thu, 17 Apr 2008 19:30:33 -0700, erikcw wrote: >>> use some sort of data-structure (maybe >>> nested dictionaries or a custom class) and store the pickled >>> data-structure in a single row in the database (then unpickle the data >>> and query in memory). >> Why would you want to do this? I don't see what you would hope to gain by >> doing this, over just using a database. > > Are databases truly another language from Python, fundamentally? Yes. A fair amount of study went into them. Databases are about information that survives the over an extended period of time (months or years, not hours). Classic qualities for a database that don't normally apply to Python (all properties of a "transaction" -- bundled set of changes): * Atomicity: A transaction either is fully applied or not applied at all. * Consistency: Transactions applied to a database with invariants preserve those invariants (things like balance sheets totals). * Isolation: Each transactions happens as if it were happening at its own moment in time -- tou don't worry about other transactions interleaved with your transaction. * Durability: Once a transaction actually makes it into the database, it stays there and doesn't magically fail a long time later. -Scott David Daniels Scott.Daniels at Acm.Org From soren.skou.nielsen at gmail.com Tue Apr 29 05:31:09 2008 From: soren.skou.nielsen at gmail.com (Soren) Date: Tue, 29 Apr 2008 02:31:09 -0700 (PDT) Subject: SWIG Python undefined reference References: <23b925ce-cfa5-4a99-bad3-afcac09b645a@y21g2000hsf.googlegroups.com> Message-ID: Ok I found out how to do it using: gcc -Ic:\python24\include -Lc:\python24\libs --shared example_wrap.c example.c -lpython24 -o _example.pyd but now I get a "dynamic module does not define init function" error when I try to import it into python.. Anyone?? Soren From jcd at unc.edu Wed Apr 16 14:27:26 2008 From: jcd at unc.edu (J. Cliff Dyer) Date: Wed, 16 Apr 2008 14:27:26 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <1208370446.5771.6.camel@aalcdl07.lib.unc.edu> On Wed, 2008-04-16 at 10:49 -0700, Mike Driscoll wrote: > On Apr 16, 12:40 pm, "D'Arcy J.M. Cain" wrote: > > On Wed, 16 Apr 2008 08:23:50 -0700 (PDT) > > > > Mike Driscoll wrote: > > > My workplace doesn't offer NNTP, so there is no good way to browse > > > c.l.py here. And I haven't been able to get NNTP to work from my home > > > either. > > > > Hi Mike; > > > > I am half way to killing Google groups myself. Your message, and > > allother Google groups messages, is coloured so that I can evaluate how > > much I will miss. So far it looks like it will make reading this group a > > whole lot more pleasant and so I will probably kill them soon. > > > > There are alternatives. I run an ISP http://www.Vex.Net/ > > that offers NNTP access to my shell users. You can also receive > > this group as a mailing list which is how I read it. Google is not the > > only option out there. > > > > -- > > D'Arcy J.M. Cain | Democracy is three wolveshttp://www.druid.net/darcy/ | and a sheep voting on > > +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. > > I don't think I like the email list idea all that much. I'm already on > a number of them and they fill up my box like crazy. Besides that, in > email format it's hard to follow the thread, so one moment I'm reading > about the latest ding dong and the next is a response to a post from > last week. > In any email client worth its salt, you can set up rules for automatically moving new messages to different folders by matching various criteria. In Evolution this is as easy as right clicking on a message from the list in your inbox, select "Create Rule From Message > Filter on Mailing List", and then choose a folder to redirect to. Reading by thread instead of by date is as easy as Ctrl-T on your inbox. It isn't much different in Thunderbird. > But I agree...there are other alternatives. I'll have to start trying > them again I suppose. > > Mike > -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill From arnodel at googlemail.com Thu Apr 24 12:23:22 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 24 Apr 2008 17:23:22 +0100 Subject: convert xhtml back to html References: Message-ID: "Tim Arnold" writes: > hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop to > create CHM files. That application really hates xhtml, so I need to convert > self-ending tags (e.g.
) to plain html (e.g.
). > > Seems simple enough, but I'm having some trouble with it. regexps trip up > because I also have to take into account 'img', 'meta', 'link' tags, not > just the simple 'br' and 'hr' tags. Well, maybe there's a simple way to do > that with regexps, but my simpleminded )]+/> doesn't work. I'm not > enough of a regexp pro to figure out that lookahead stuff. Hi, I'm not sure if this is very helpful but the following works on the very simple example below. >>> import re >>> xhtml = '

hello spam
bye

' >>> xtag = re.compile(r'<([^>]*?)/>') >>> xtag.sub(r'<\1>', xhtml) '

hello spam
bye

' -- Arnaud From breily at gmail.com Fri Apr 25 06:37:44 2008 From: breily at gmail.com (Brian) Date: Fri, 25 Apr 2008 06:37:44 -0400 Subject: Can you recommend a book? In-Reply-To: References: Message-ID: On Fri, Apr 25, 2008 at 6:28 AM, noagbodjivictor at gmail.com < noagbodjivictor at gmail.com> wrote: > Hello all, I learned Python with the book "Programming Python" by John > Zelle. But today this book is a little bit old. My Python is some kind > old. I need a book that will help me brush my style and keep me up to > date. I would like one with practical examples. > > Can you recommend one? > -- > http://mail.python.org/mailman/listinfo/python-list > Dive Into Python is awesome, and best of all, free. Brian -------------- next part -------------- An HTML attachment was scrubbed... URL: From sambasivareddy.s at patni.com Fri Apr 11 07:07:11 2008 From: sambasivareddy.s at patni.com (sambasivareddy) Date: Fri, 11 Apr 2008 11:07:11 -0000 Subject: Can we send and receive data to and from Port Using Python ? Message-ID: <004901c77c25$130446b0$750ba8c0@patni.com> Hi, I am new to this group. I have some question, it is listed below. In my application I should send some data to hardware and it will give response that response should log in one file. To do it first should send data to port next receive response from port (hardware) so... Queries: 1) Can we able to send data to serial port using python? If yes how? 2) Can we able to receive data from serial port using python? If yes how? 3) Is there any function like "Register event call back", please explain? (Register event call back: registers a script to be called when an event occurs) 4) Is it possible "parallel loops" concept in python (In my application send data to port and receive data should be in one file and execute at same time)? If anyone knows answers please clarify and have any examples related to this please send it .if u need any information regarding questions please let me know. Thanks in advance. Regards, Sambasivareddy.S http://www.patni.com World-Wide Partnerships. World-Class Solutions. _____________________________________________________________________ This e-mail message may contain proprietary, confidential or legally privileged information for the sole use of the person or entity to whom this message was originally addressed. Any review, e-transmission dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this e-mail in error kindly delete this e-mail from your records. If it appears that this mail has been forwarded to you without proper authority, please notify us immediately at netadmin at patni.com and delete this mail. _____________________________________________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From marco at sferacarta.com Mon Apr 14 04:37:47 2008 From: marco at sferacarta.com (Marco Mariani) Date: Mon, 14 Apr 2008 10:37:47 +0200 Subject: Java or C++? In-Reply-To: References: Message-ID: s0suk3 at gmail.com wrote: > Which one do you think will educate me the best? Advanced javascript might teach you something too, and be very useful at the same time. Take a look at the Crockford lessons on Yahoo! Video. http://video.yahoo.com/watch/111593 http://video.yahoo.com/watch/111594 http://video.yahoo.com/watch/111595 http://video.yahoo.com/watch/111596 http://video.yahoo.com/watch/111585 http://video.yahoo.com/watch/111586 http://video.yahoo.com/watch/111587 From torriem at gmail.com Mon Apr 21 22:12:41 2008 From: torriem at gmail.com (Michael Torrie) Date: Mon, 21 Apr 2008 20:12:41 -0600 Subject: Problems replacing \ with \\ In-Reply-To: <0ca30eb2-3791-4910-9e78-f32e3b2a72cb@2g2000hsn.googlegroups.com> References: <0ca30eb2-3791-4910-9e78-f32e3b2a72cb@2g2000hsn.googlegroups.com> Message-ID: <480D4999.4070609@gmail.com> samslists at gmail.com wrote: > Hi... > > Here's a weird problem...I'm trying to escape a bunch of data to put > into a database. Is it possible to use the database API and prepared statements to avoid having to go through this exercise? Also, most database APIs work natively in unicode, so creating your prepared statement and then passing in each parameter as an argument saves a lot of hassle, since the API's usually decode the unicode strings automatically. From gagsl-py2 at yahoo.com.ar Fri Apr 4 15:57:49 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 04 Apr 2008 16:57:49 -0300 Subject: Classes in modules References: <0cace2e1-6dbc-428f-9e53-ffb99ba42aab@e6g2000prf.googlegroups.com> Message-ID: En Thu, 03 Apr 2008 18:00:54 -0300, escribi?: > Yeah, I was a little embarrassed putting my code up to be examined. > Thanks for the reply. I typed up some classes, but I seemed to have > run into some more problems. One of the classes keeps getting an > error that it can't pop from an empty list. Here's the code so far: > > #deck functions > class Deck(object): > def __init__(self): > self.deck = [] > for i in range(52): > self.deck.append(Cards(i % 13, i / 13)) > def draw(self): #This is where my (first) problem > arises, though there may be more > return self.deck.pop() #IndexError: pop from empty list > def size(self): > return len(self.deck) Next time post the whole traceback including the exception message. It really contains valuable information. Without it, one has to guess... "pop from empty list" means that you are trying to draw a card after the deck is empty. The traceback would show the caller, but in this case it's easy because there is a single place: > class Game(object): #the main game class > def __init__(self): > self.deck = Deck() > self.deck.shuffle() > self.player = Hand() > self.computer = Hand() > for i in range(self.deck.size()): > self.player.put(self.deck.draw()) > self.computer.put(self.deck.draw()) > self.stock = Stock() > print self.stock.showtrump() The loop takes 52 iterations but you draw two cards in each iteration - the 27th sees an empty deck. -- Gabriel Genellina From fr5478bey at gmail.com Sat Apr 26 11:40:55 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:40:55 -0700 (PDT) Subject: nod crack Message-ID: nod crack http://cracks.00bp.com F R E E C R A C K S From tjreedy at udel.edu Sun Apr 20 13:54:20 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 20 Apr 2008 13:54:20 -0400 Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> Message-ID: "Banibrata Dutta" wrote in message news:3de8e1f70804200632i31768d8atc235e8b6a7137173 at mail.gmail.com... | Hmmm... but I'm aware of atleast 2 Obfuscators one commercial and one FOSS, | that seem to exist for Python. The commercial one is what I might try if I | don't find anything FOSS. The FOSS one seems to be a dead project. If they | are (or have been) there, I guess obfuscation is a doable thing, no ? Given that a reliable obfuscator (not obfurscator) would be commercially valuable, why would you expect someone to give it away rather than obfuscate it, like you want to do with your code? So go ahead and pay. There are ways to make Python code truly obscure by turning it into pure functional code, but I do not know that this can be done algorithmicly, and the result is not something one would want to develop and maintain for anything more than toy examples. From marion at everautumn.com Sun Apr 6 13:28:44 2008 From: marion at everautumn.com (marion at everautumn.com) Date: Sun, 6 Apr 2008 10:28:44 -0700 (PDT) Subject: How To Uses Modules And Plugins Message-ID: <47650e1f-148e-48f9-b09e-51cb5fb4f402@m73g2000hsh.googlegroups.com> I am working on a client/server, computer role-play game using Python. I want to gradually expand the game world by creating maps as individual py files in a map directory. I am a little foggy of how to do this. I have read about the __import__() function. I want to understand what the difference is between using modules and plugins. Are they the same thing? How will my root script interact with the individual modules once it has loaded them? If you can point me to a web site or tutorial on this subject I would be thankful. From sjmachin at lexicon.net Wed Apr 9 20:23:12 2008 From: sjmachin at lexicon.net (John Machin) Date: Wed, 9 Apr 2008 17:23:12 -0700 (PDT) Subject: How can I use quotes without escaping them using CSV? References: <35a28105-1178-4784-8247-d483e55694c7@f63g2000hsf.googlegroups.com> Message-ID: <663f5ce6-45a5-4f5e-a879-2e8ed405e41c@k1g2000prb.googlegroups.com> On Apr 10, 9:39 am, jeffself wrote: > I set quotechar="" and was able to get it to work. I'll try this at > work tomorrow! setting it to what Andrew told you to do ('' not ")works equally well From tinnews at isbd.co.uk Wed Apr 9 12:05:21 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 09 Apr 2008 16:05:21 GMT Subject: How to find documentation about methods etc. for iterators Message-ID: <47fce941$0$755$bed64819@news.gradwell.net> I'm not sure if I have even phrased that right but anyway.... How does one find (in the standard Python documentation) information about things like the iteritems() method and the enumerate() function. They are mentioned in the tutorial as ways of getting more information as you loop through an object but there seems to be no easy way to find the definitive documentation of these sorts of methods and functions. OK, if I know the name before I start I can probably find what I want, but what if I want to know how to extract some information from an object as I loop and don't know what I want is called? My particular quest that raised this was a way to get the line number as I iterate through the lines of a file:- f = open(fn, 'r') lineNo = 0 for ln in f: lineNo += 1 Is there a neater way of getting that line number as I go? If so how am I meant to find out about it? -- Chris Green From JesseAldridge at gmail.com Sun Apr 6 10:32:27 2008 From: JesseAldridge at gmail.com (Jesse Aldridge) Date: Sun, 6 Apr 2008 07:32:27 -0700 (PDT) Subject: Python Data Utils References: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> Message-ID: <8eec6557-784d-4fd8-8478-8da17aedf0ab@d1g2000hsg.googlegroups.com> Thanks for the detailed feedback. I made a lot of modifications based on your advice. Mind taking another look? > Some names are a bit obscure - "universify"? > Docstrings would help too, and blank lines I changed the name of universify and added a docstrings to every function. > ...PEP8 I made a few changes in this direction, feel free to take it the rest of the way ;) > find_string is a much slower version of the find method of string objects, ? Got rid of find_string, and contains. What are the others? > And I don't see what you gain from things like: > def count( s, sub ): > ? ? ?return s.count( sub ) Yeah, got rid of that stuff too. I ported these files from Java a while ago, so there was a bit of junk like this lying around. > delete_string, as a function, looks like it should delete some string, not ? > return a character; I'd use a string constant DELETE_CHAR, or just DEL, ? > it's name in ASCII. Got rid of that too :) > In general, None should be compared using `is` instead of `==`, and ? > instead of `type(x) is type(0)` or `type(x) == type(0)` I'd use ? > `isinstance(x, int)` (unless you use Python 2.1 or older, int, float, str, ? > list... are types themselves) Changed. So, yeah, hopefully things are better now. Soon developers will flock from all over the world to build this into the greatest data manipulation library the world has ever seen! ...or not... I'm tired. Making code for other people is too much work :) From martin at v.loewis.de Sat Apr 5 17:34:28 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sat, 05 Apr 2008 23:34:28 +0200 Subject: RELEASED Python 2.6a2 and 3.0a4 In-Reply-To: References: <47F68547.1040802@v.loewis.de> Message-ID: <47F7F064.6030906@v.loewis.de> Kay Schluehr wrote: > On 4 Apr., 21:45, "Martin v. L?wis" wrote: >>> The Windows x86 MSI installer is missing for both 2.6 and 3.0. >> And likely will continue to do so for some time. >> >> Regards, >> Martin > > Fine. Is there also a reason? Sure! I don't have the time to spell it out, though, please look at the python-dev archives. If you want to help, please contact me in private. Regards, Martin From jeffrey at fro.man Tue Apr 15 17:01:07 2008 From: jeffrey at fro.man (Jeffrey Froman) Date: Tue, 15 Apr 2008 14:01:07 -0700 Subject: Recurring patterns: Am I missing it, or can we get these added to the language? References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: Erich wrote: > def iterable(item, count_str=False): > if not count_str and isinstance(item, str): > return False > try: > iter(item) > except: > return False > return True Beware the "except" clause here, as it catches *all* errors. Thus, if you happen to have an unfortunate typo: try: iter(iten) except: return False return True then your code will happily return False for everything. This code should catch TypeErrors only for better results: try: iter(item) except TypeError: return False return True Jeffrey From Manisa999 at gmail.com Sat Apr 26 01:18:57 2008 From: Manisa999 at gmail.com (Manisa999 at gmail.com) Date: Fri, 25 Apr 2008 22:18:57 -0700 (PDT) Subject: Latest PC Parts In Small Price U Nid Contact Mi!! Message-ID: <0f1fe502-8859-4397-8808-8651ee5edfc9@w5g2000prd.googlegroups.com> SEXY SEGMENT *********************************** http://bigsexmovies.notlong.com/ http://indiansexx.notlong.com/ *********************************** From gagsl-py2 at yahoo.com.ar Fri Apr 25 06:27:35 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 25 Apr 2008 07:27:35 -0300 Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: En Thu, 24 Apr 2008 11:10:55 -0300, Paul McGuire escribi?: > On Apr 21, 9:01?pm, "Gabriel Genellina" > wrote: >> >> Perhaps you can manage to keep your code compatible with all versions, >> but ? >> AFAIK the reccomended strategy is to write code compatible with Python >> 2.6 ? >> and use the 2to3 tool to generate the 3.0 source. And *not* edit the >> 3.0 ? >> code unless one wants to maintain two branches. >> > > Gabriel - > > (Thanks for chiming in on this sub-thread, I really enjoy reading your > posts.) (And I enjoy using your parser! Not that I have to parse text so often, but when it comes, the "pythonicity" of pyparsing is a great thing!) > My point is that the recommended strategy MAY work for those who write > end point applications (I consider maintaining 2 branches to be in the > "not working" category), but it does NOT WORK for people who maintain > modules for other people to use, because those people may be on a > range of Python versions that extend beyond 2.6-3.0. So if I upgrade > my module to 2.6, those running on earlier versions can no longer use > it. At some point in the future, I'll probably be able to say "no > more support for pre-2.6", but it is a bit early to start saying that > now. > > Likewise, I don't want to say "no support for 3.0" - people DO want to > try 3.0 out, and I WANT them to want and be able to use my module too. > > Given the recommended strategy, and ruling out dual codebase, whom do > I tell that they can't use the next version of my module? Ok, code that is "2.6 compatible" doesn't mean that it only runs on 2.6... I'm *trying* to write code that is "2to3 friendly" but anyway compatible with older Python versions, and it should not require 2.6 to run. That means not using "with" as a variable name, for example. (And on the other side, also refrain from using some new 2.6 features like class decorators and binary literals) I hope the final version of the 2to3 tool will be a little more robust - or at least, that one will always be able to write code in a way that it can handle (and I *dont* want to maintain a 2.x and 3.x branches of any code either) Based on my limited experience I'd say that this approach *could* work, that is, write the code base for 2.x (x >= 3, in my case) and automatically convert to 3.0. That last stage may fail, but -I hope!- not so often in the future. As always, YMMV... Also note that I *don't* write code for other developers (thanks God!), just final users (with Python 2.3/4/5) > Again, to me, this is a non-issue because I've been able to create a > cross-version compatible single codebase for pyparsing. But it was a > bit dicey there for a while, and I think other module developers/ > maintainers may not be so lucky. That's a bit tricky at least. How did you manage to avoid problems with (string/unicode) and (bytes/string) in 3.0? > So, I feel that the recommended strategy was devised with a narrow > group of developers in mind, and leaves module developers/maintainers, > who wish to target as broad a set of users as possible, faced with > choosing one of these strategies: > - create (if possible) single cross-version compatible code > - forego support of 3.0 users > - discontinue pre-2.6 support for future versions of their module > - maintain dual codebase I hope the first alternative will be actually viable, perhaps with help from tools like 2to3... -- Gabriel Genellina From mail at timgolden.me.uk Fri Apr 11 15:46:24 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 11 Apr 2008 20:46:24 +0100 Subject: Windows - window status (Running vs Not Responding) In-Reply-To: References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> Message-ID: <47FFC010.2020602@timgolden.me.uk> rdahlstrom wrote: > On Apr 11, 1:45 pm, rdahlstrom wrote: >> Does anyone know how to determine the window status (Running or Not >> Responding)? I've tried various methods with no success... >> >> This would be on a variety of Windows systems, but all at least XP, >> and mostly server 2003. Everyone will have Python 2.5.1 on them, and >> the script would be running locally. >> >> Any ideas? > > > Basically, I'm looking for something similar to the Process.Responding > property in System.Diagnostics... Well one (slightly drastic) possibility might be to use IronPython [1] or Python.NET [2] to invoke the .Net functionality directly. AFAIK there is no direct alternative: I believe that WMI can be a useful match for System.Diagnostics but doesn't deal with windows (ie user-interface elements). Presumably you could find a top-level window for each process, using something vaguely like this [3] coupled with this [4] and send it a suitable SendMessage to "ping" it. Haven't done it myself but can't see why it shouldn't work. All a bit handwavey but maybe it'll point you somewhere... TJG [1] http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython [2] http://pythonnet.sourceforge.net/ [3] http://timgolden.me.uk/python/wmi_cookbook.html#running_processes [4] http://timgolden.me.uk/python/win32_how_do_i/find-the-window-for-my-subprocess.html From victorsubervi at gmail.com Thu Apr 17 10:42:39 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 17 Apr 2008 09:42:39 -0500 Subject: More Fun With MySQL and Images Message-ID: <4dc0cfea0804170742g39965533yfaf260bcf4da4301@mail.gmail.com> Hi again: Here is my code, an edit of Gabriel?s: #!/usr/local/bin/python import cgitb; cgitb.enable() import MySQLdb def test(): host = 'host' db = 'db' user = 'user' passwd = 'pass' db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor= db.cursor() cursor.execute('select pic1 from products where id="2";') content = cursor.fetchall()[0][0].tostring() f = open("somefile.jpg", "w") f.write(content) f.close() print 'Content-Type: image/jpeg\r\nContent-Length: %d\n' % len(content) print '\n' print content print '\n' cursor.close() test() Now, when I surf to the url of this script, it prints out garbage that is a literal of the image, but not the image itself. However, if I surf to ?somefile.jpg?, I see the image!! Am I losing my mind?? What?s wrong here? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From mmanns at gmx.net Thu Apr 17 22:46:38 2008 From: mmanns at gmx.net (Martin Manns) Date: Fri, 18 Apr 2008 04:46:38 +0200 Subject: ANN: pyspread 0.0.1 Message-ID: pyspread 0.0.1 is now available at: http://pyspread.sourceforge.net pyspread is a spreadsheet that accepts a pure python expression in each cell. Highlights: + No non-python syntax add-ons + Access to python modules from cells + 3D grid + Numpy object array for representation of string entry into grid cell + Numpy object array for representation of eval function array + Cell access via slicing of numpy function array + X, Y, and Z yield current cell location for relative reference Requires: Python 2.5, Numpy 1.0.4, and wxPython 2.8.7.1. License: GPL Best Regards Martin Manns -- mmanns gmx.net From BrentJRogers at gmail.com Tue Apr 29 22:52:48 2008 From: BrentJRogers at gmail.com (breroger@cisco.com) Date: Tue, 29 Apr 2008 19:52:48 -0700 (PDT) Subject: QA-Test Jobs at Cisco-IronPort Message-ID: Cisco-IronPort is looking for a topnotch Quality Assurance/ Test Engineers with experience in one or more of the following: aPython, utomation framework, performance testing, email encryption, FreeBSD, white.gray box testing, API testing, web security appliances, UNIX, RAID, LDAP, SSH, DNS, SMTP, HTTP, FTP, Telnet, RDBMS, IMAP, POP and/or tested servers. These job openings are in San Bruno. Please contact me directly if you are interested in getting more information. Regards, Brent breroger at cisco.com From kyosohma at gmail.com Wed Apr 30 13:14:56 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 30 Apr 2008 10:14:56 -0700 (PDT) Subject: I messed up my wxPython install (Eclipse Configuration Issue) References: <18eb0a7c-96f4-41de-b44f-95fd8ba0223f@f63g2000hsf.googlegroups.com> Message-ID: <436f8226-64a5-440a-92f4-afd7dd348e1c@m73g2000hsh.googlegroups.com> blaine wrote: > The wxPython group is a bit stale compared to this group, so I'll give > it a shot :) > What does that mean? The wxPython group is almost always very quick to respond with relevant answers. As to your question, I think Peter is correct. Your wx.py and wx.pyc files are masking the wx package. Mike From noorhanabbas at yahoo.co.uk Wed Apr 16 06:48:02 2008 From: noorhanabbas at yahoo.co.uk (Noorhan Abbas) Date: Wed, 16 Apr 2008 10:48:02 +0000 (GMT) Subject: Change the output font color Message-ID: <306504.18131.qm@web27412.mail.ukl.yahoo.com> Hello, I am developing a program that searches for a word in a piece of text. I need to be able to change the color of the searched for word when found in the output text. Is that possible in Python? So, for example: The input text could be: "I like banans and apples" The output should be: "I like banans and apples" Thank you very much, Nora. ___________________________________________________________ Yahoo! For Good helps you make a difference http://uk.promotions.yahoo.com/forgood/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From barronmo at gmail.com Wed Apr 2 16:07:30 2008 From: barronmo at gmail.com (barronmo) Date: Wed, 2 Apr 2008 13:07:30 -0700 (PDT) Subject: subtract dates with time module References: <16b10790-a57f-4e7e-bbb5-32e71b321771@u69g2000hse.googlegroups.com> <47eb7d5b$1@news.mel.dft.com.au> Message-ID: <652c0efa-c472-4016-bbcc-f3c4c7a67060@a1g2000hsb.googlegroups.com> Thanks for the help everyone. I ended up with the following: def OBweeks(ptID): qry = 'SELECT short_des FROM problems WHERE patient_ID = %s;' % (ptID) results = EMR_utilities.getAllData(qry) for items in results: r = re.search('\d\d\d\d-\d\d-\d\d', str(items)) if r: edc = datetime.date(*map(int, r.group().split('-'))) pregnancy = datetime.timedelta(weeks=-40) conception = edc + pregnancy howfar = datetime.date.today() - conception weeks, days = divmod(howfar.days, 7) return '%s %s/7 weeks' % (weeks, days) else: pass Mike From dickinsm at gmail.com Mon Apr 7 15:55:52 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Mon, 7 Apr 2008 12:55:52 -0700 (PDT) Subject: A funnily inconsistent behavior of int and float References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com> <1d11875a-470a-489f-910a-b420a145eb61@a1g2000hsb.googlegroups.com> <11b4793c-04cc-4898-99a8-8418d237de3e@2g2000hsn.googlegroups.com> Message-ID: <1255ee3e-cc1e-4ae8-96f3-5f942c389c49@t54g2000hsg.googlegroups.com> On Apr 7, 3:53 pm, Mark Dickinson wrote: > The only base 0 versus base 10 difference I could find was the > following: > > >>> int('033', 0) > > Traceback (most recent call last): > File "", line 1, in > ValueError: invalid literal for int() with base 0: '033' > [38720 refs]>>> int('033') > > 33 > > Mark And also things like: >>> int('0x33') Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: '0x33' [38719 refs] >>> int('0x33', 0) 51 [38719 refs] Mark From kyosohma at gmail.com Tue Apr 8 14:55:39 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 8 Apr 2008 11:55:39 -0700 (PDT) Subject: set file permission on windows References: <7d75fc7b-a2b7-4ca2-b386-27da975043d0@m44g2000hsc.googlegroups.com> Message-ID: <9aaa562d-b256-4fe5-bb10-d32def072564@2g2000hsn.googlegroups.com> On Apr 8, 1:19 pm, "Tim Arnold" wrote: > "Mike Driscoll" wrote in message > > news:7d75fc7b-a2b7-4ca2-b386-27da975043d0 at m44g2000hsc.googlegroups.com... > > > > > On Apr 8, 12:03 pm, "Tim Arnold" wrote: > >> > > According to the following thread, you can use os.chmod on Windows: > > >http://mail.python.org/pipermail/python-list/2003-June/210268.html > > > You can also do it with the PyWin32 package. Tim Golden talks about > > one way to do it here: > > >http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html > > > Also see the following thread: > > >http://mail.python.org/pipermail/python-win32/2004-July/002102.html > > > or > > >http://bytes.com/forum/thread560518.html > > > Hope that helps! > > > Mike > > Hi Mike, > It does help indeed, especially the last two links. That certainly gets me > started in the right direction. I'm always amazed at the helpful generosity > of the folks on this list. > thanks again for the help. > --Tim Arnold Hi Tim, I thought I'd used the methods in those last two links before, but I was thinking of changing permissions on running services to reboot a PC, which is not quite the same. If you run into more issues, there's a PyWin32 mailing list with helpful people there too. You can find it here: http://mail.python.org/mailman/listinfo/python-win32 Mike From aaron.watters at gmail.com Fri Apr 18 10:36:40 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Fri, 18 Apr 2008 07:36:40 -0700 (PDT) Subject: Database vs Data Structure? References: <61bf5f46-e917-4a98-b87f-8e5087cb07f7@a23g2000hsc.googlegroups.com> <4808586b$0$23721$426a74cc@news.free.fr> Message-ID: > My very humble opinion - based on several years of working experience > with both the Zodb and many RDBMS - is quite clear : use a RDBMS and use > it properly. Yes, somewhere down the line you will want to get a report of all the customers in Ohio, ordered by county and zip code, who have a "rabbit cage" project -- and if you just pickle everything you will end up traversing the entire database, possibly multiple times to find it. A little old fashioned database design up front can save you a lot of pain. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=ouch From maxkhesin at gmail.com Sun Apr 6 16:59:03 2008 From: maxkhesin at gmail.com (xamdam) Date: Sun, 6 Apr 2008 13:59:03 -0700 (PDT) Subject: appropriate python version References: <0790632f-db07-45ef-9bcd-7e1b592d33be@u69g2000hse.googlegroups.com> Message-ID: <61b10f10-a322-4835-b800-ed09d046fe56@e67g2000hsa.googlegroups.com> Thanks. I am guessing the 32bit build should work anyways, same as other 32 progs on XP 64? From lutz.georg.horn at googlemail.com Wed Apr 30 02:41:47 2008 From: lutz.georg.horn at googlemail.com (Lutz Horn) Date: Wed, 30 Apr 2008 08:41:47 +0200 Subject: Problem with variables assigned to variables??? In-Reply-To: References: Message-ID: <7c85a2590804292341l566b59f7x59ba06634bd98650@mail.gmail.com> Hi, 2008/4/30 : > mylist = ('name1', 'name2', 'name3') > > I also assigned variables for each SQL expression: > name1 = "\"field_a\" LIKE '021'" > name2 = "\"field_a\" LIKE '031'" > name3 = "\"field_a\" LIKE '041'" > my intended output is: > name1.shp "field_a LIKE '021' > name2.shp "field_a LIKE '031' > name3.shp "field_a LIKE '041' You should use a dictionary someway like this: >>> mydict = {'name1':"\"field_a\" LIKE '021'", ... 'name2':"\"field_a\" LIKE '031'", ... 'name3':"\"field_a\" LIKE '041'"} >>> for key, value in mydict.items(): ... print key, value ... name2 "field_a" LIKE '031' name3 "field_a" LIKE '041' name1 "field_a" LIKE '021' Lutz -- Do you want a Google Mail invitation? Just write me an email! From abeen0 at gmail.com Wed Apr 2 01:37:22 2008 From: abeen0 at gmail.com (abeen) Date: Tue, 1 Apr 2008 22:37:22 -0700 (PDT) Subject: developing web spider Message-ID: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> Hello, I would want to know which could be the best programming language for developing web spider. More information about the spider, much better,, thanks http://www.imavista.com From gagsl-py2 at yahoo.com.ar Thu Apr 10 05:18:39 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 06:18:39 -0300 Subject: email header decoding fails References: Message-ID: En Thu, 10 Apr 2008 05:45:41 -0300, ZeeGeek escribi?: > On Apr 10, 4:31 pm, "Gabriel Genellina" > wrote: >> En Wed, 09 Apr 2008 23:12:00 -0300, ZeeGeek >> escribi?: >> >> > It seems that the decode_header function in email.Header fails when >> > the string is in the following form, >> >> > '=?gb2312?Q?=D0=C7=C8=FC?=(revised)' >> An 'encoded-word' that appears within a >> 'phrase' MUST be separated from any adjacent 'word', 'text' or >> 'special' by 'linear-white-space'. > > Thank you very much, Gabriel. The above just says "why" decode_header refuses to decode it, and why it's not a bug. But if you actually have to deal with those malformed headers, some heuristics may help. By example, if you *know* your mails typically specify gb2312 encoding, or iso-8859-1, you may look for things that look like the example above and "fix" it. -- Gabriel Genellina From victorsubervi at gmail.com Tue Apr 29 10:33:32 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Tue, 29 Apr 2008 09:33:32 -0500 Subject: Colors for Rows Message-ID: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> Hi; why doesn't this work? z = 3 for d in id: z += 1 if z % 4 == 0: bg = '#ffffff' elif z % 4 == 1: bg = '#d2d2d2' elif z % 4 == 2: bg = '#F6E5DF' else: bg = '#EAF8D5' try: print '\n' % bg except: print '\n' It never increments z! Yet, if I print z, it will increment and change the bgcolor! Why?! Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From skanemupp at yahoo.se Mon Apr 14 05:24:34 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Mon, 14 Apr 2008 02:24:34 -0700 (PDT) Subject: py2exe, program has stoped working!? References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> <232151d6-09ed-4a1e-9922-d66c2bf0d05b@w8g2000prd.googlegroups.com> Message-ID: > Is it a console program or a gui program? GUI > What happens when you run it without py2exe? it works perfectly, both from within python and launching from "windows" > Have you searched for "has stopped working" in (a) your source code yes no such message there > (b) the py2exe source code? no, will do but doubt thats the problem > Have you managed to get any py2exe-created program to run properly? no From paul at subsignal.org Sat Apr 19 11:31:14 2008 From: paul at subsignal.org (paul) Date: Sat, 19 Apr 2008 17:31:14 +0200 Subject: is file open in system ? - other than lsof In-Reply-To: <36e8a7020804160550g6fba661cx7249426f35e7d635@mail.gmail.com> References: <36e8a7020804160550g6fba661cx7249426f35e7d635@mail.gmail.com> Message-ID: bvidinli schrieb: > is there a way to find out if file open in system ? - > please write if you know a way other than lsof. because lsof if slow for me. > i need a faster way. > i deal with thousands of files... so, i need a faster / python way for this. > thanks. I think you can do this with inotify. It's an event based notification mechanism for linux kernel 2.6.13 and up. It has python bindings available (google for pyinotify). You will receive events like IN_OPEN,IN_CLOSE,etc. and keep track of opened files this way. hth Paul From cokofreedom at gmail.com Mon Apr 7 08:15:37 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Mon, 7 Apr 2008 05:15:37 -0700 (PDT) Subject: First Python project - comments welcome! References: <1207555415.6966.88.camel@paul-laptop> Message-ID: <9c313122-7eb0-4761-9443-50f467985767@p25g2000hsf.googlegroups.com> Just a random check. Is __gsignals__ a builtin type? Else it would probably be better not to include the postfix underscores. Though I might be wrong here. Otherwise seems pretty good and well organised. I hate it when people go comment mad, but you've kept them to the places where an explanation is required. Good job :=) From Bill at SynectixLtd.com Thu Apr 10 04:00:14 2008 From: Bill at SynectixLtd.com (Bill Davy) Date: Thu, 10 Apr 2008 09:00:14 +0100 Subject: SWIG/C++ Message-ID: Is there a better place to post such questions? Anyway, in the hope it is something simple, I would appreciate some help. I am adding some C++ code to Python. From Python I want to be able to read data from a target device, over USB. My software does all the hard work and I have a class: class ViperUsbC { public: // snip snip ERROR_T ReadSlaveMemory(u8 Slave, u16 Offset, u8* pData, u16 Length); // Snip,snip }; I use swigwin-1.3.34 to wrap it into a module called SHIP. In Python, I have: import SHIP ViperUsb = SHIP.ViperUsbC() Slave =7 Offset = 0 Length = 64 Buffer = 'a' * Length print "type(Buffer)=%s" % type(Buffer) print "len(Buffer)=%s" % len(Buffer) Result = ViperUsb.ReadSlaveMemory(Slave, Offset, Buffer, Length); That fails with: type(Buffer)= len(Buffer)=64 Traceback (most recent call last): File "H:\Husky\HostPC\V1\SHIP\test1.py", line 1970, in -toplevel- ViperTests() File "H:\Husky\HostPC\V1\SHIP\test1.py", line 1884, in ViperTests Result = ViperUsb.ReadSlaveMemory(Slave, Offset, Buffer, Length); File "H:\Husky\HostPC\V1\SHIP\Release\SHIP.py", line 1757, in ReadSlaveMemory def ReadSlaveMemory(*args): return _SHIP.ViperUsbC_ReadSlaveMemory(*args) TypeError: in method 'ViperUsbC_ReadSlaveMemory', argument 4 of type 'u8 *' How do I provide a buffer into which to read the data? It would not be intolerable to provide another layer using %extend, but I feel sure this should be automagic. Thanks in advance Bill PS This is a very small part of a much larger project so I cannot supply complete source code. From usenet-mail at markshroyer.com Sat Apr 19 03:03:54 2008 From: usenet-mail at markshroyer.com (Mark Shroyer) Date: Sat, 19 Apr 2008 03:03:54 -0400 Subject: Inheritance confusion References: <4809932c$0$12307$c3e8da3@news.astraweb.com> Message-ID: In article <4809932c$0$12307$c3e8da3 at news.astraweb.com>, Hook wrote: > Hi, > > I'm having a problem with multiple inheritance - it's clearly something > I've missed, but the web pages and books that I've consulted aren't > helping, so I'll throw myself on the mercy and collective wisdom of > Usenet! > > I've got 4 files (what I'll show has the active content removed for > brevity): > > Errors_m.py > ~~~~~~~~~~~ > class Errors (object) : > def __init__ (self, params) : > pass > > def Error (self, string) : > return 100 > > DT_m.py > ~~~~~~~ > class DT (object) : > def __init__ (self, params) : > pass > > def Date (self, epoch, pattern = 'd mmm yyyy') : > dt = datetime.datetime.fromtimestamp (epoch) > > Hook_m.py > ~~~~~~~~~ > from DT_m import DT > from Error_m import Errors > > class Hook (Errors, DT) : > def __init__ (self, params) : > DT.__init__ (self, params) > Errors.__init__ (self, params) > > DB_m.py > ~~~~~~~ > from Hook_m import Hook > > class DB (Hook) : > def __init__ (self, params) : > Hook.__init__ (self, params) > > > And a test script: > > #!/usr/bin/python > > import os > import re > import string > import sys > > from DB_m import DB > > Dict = dict () > Dict ['logdir'] = '/tmp/log' > Dict ['diag'] = 1 > > Obj = DB (Dict) > print dir (Obj) > Obj.Connect ('Database') > > > When I run the script I get this: > > Traceback (most recent call last): > File "./3.py", line 20, in > Obj.Connect ('Database') > File "/mnt/isis/Projects/Python/Learning/DB_m.py", line 102, in Connect > self.TRACE ("DB::Connect (" + database + "," + mode) > File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 314, in TRACE > self.DailyLog (msg) > File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 98, in > DailyLog > dt = self.Date (time ()) > TypeError: 'module' object is not callable > > > Googling the "TypeError" message suggests that I've got a module and > class with the same name, but I can't see that I have. For what it's worth, modules actually *are* allowed to contain a class of the same name: for example, datetime.datetime. Anyway, what this error message is actually trying to tell you is that you are attempting to call a module as a function somewhere -- and in this particular case, I think it's referring to the time module. Are you sure that line 98 in Hook_m.py should not instead be: dt = self.Date(time.time()) The time module contains a function, time(), which returns the current Unix time (another example of a module containing an object of the same name, incidentally); but you'll need to call this function as "time.time()" unless you have prefaced your code with from time import time or from time import * Otherwise, the token "time" refers to the time module, which is not callable, and not the desired function therein. -- Mark Shroyer, http://markshroyer.com/contact/ Due to extreme spam, I block all articles originating from Google Groups. If you want your postings to be seen by more readers you will need to find a different means of posting on Usenet. http://improve-usenet.org/ From python-url at phaseit.net Mon Apr 21 06:45:13 2008 From: python-url at phaseit.net (Gabriel Genellina) Date: Mon, 21 Apr 2008 10:45:13 +0000 (UTC) Subject: Python-URL! - weekly Python news and links (Apr 21) Message-ID: QOTW: "But people will always prefer complaining on the grounds of insufficient information to keeping quiet on the basis of knowledge." - Steve Holden http://groups.google.com/group/comp.lang.python/msg/007b9fea0a5db786 Speed of Python vs C when reading, sorting and writing data: http://groups.google.com/group/comp.lang.python/browse_thread/thread/172902584511f19e/ The GIL was murdered - but it refuses to die: http://groups.google.com/group/comp.lang.python/browse_thread/thread/2d537ad8df9dab67/ The "obvious" way to declare per-instance properties doesn't work: http://groups.google.com/group/comp.lang.python/browse_thread/thread/c14aae97eb7c19d8/ Metaprogramming example (metaclasses and descriptors): http://groups.google.com/group/comp.lang.python/browse_thread/thread/e4144d9c8fafe29a/ Concerns about the migration to 3.0 (Python and C code): http://groups.google.com/group/comp.lang.python/browse_thread/thread/25c4c3175569fa37/ The future replacement of string % formatting in Python 3.x: http://groups.google.com/group/comp.lang.python/browse_thread/thread/f07feff4f01be76f/ How widely adopted is Python 2.5? http://groups.google.com/group/comp.lang.python/browse_thread/thread/5f15ac04993dfb9/ What to learn after Python: Java, C++, ...? http://groups.google.com/group/comp.lang.python/browse_thread/thread/5d8be7aca2cd6d49/ Many people filter out messages posted thru Google Groups: http://groups.google.com/group/comp.lang.python/browse_thread/thread/a90b84c4f8987b3f/ ======================================================================== Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. Just beginning with Python? This page is a great place to start: http://wiki.python.org/moin/BeginnersGuide/Programmers The Python Papers aims to publish "the efforts of Python enthusiats": http://pythonpapers.org/ The Python Magazine is a technical monthly devoted to Python: http://pythonmagazine.com Readers have recommended the "Planet" sites: http://planetpython.org http://planet.python.org comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Python411 indexes "podcasts ... to help people learn Python ..." Updates appear more-than-weekly: http://www.awaretek.com/python/index.html Steve Bethard continues the marvelous tradition early borne by Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim Lesher of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to capture useful and interesting recipes. http://aspn.activestate.com/ASPN/Cookbook/Python Many Python conferences around the world are in preparation. Watch this space for links to them. Among several Python-oriented RSS/RDF feeds available are http://www.python.org/channews.rdf http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi http://python.de/backend.php For more, see http://www.syndic8.com/feedlist.php?ShowMatch=python&ShowStatus=all The old Python "To-Do List" now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse http://www.python.org/dev/peps/pep-0042/ The online Python Journal is posted at pythonjournal.cognizor.com. editor at pythonjournal.com and editor at pythonjournal.cognizor.com welcome submission of material that helps people's understanding of Python use, and offer Web presentation of your work. del.icio.us presents an intriguing approach to reference commentary. It already aggregates quite a bit of Python intelligence. http://del.icio.us/tag/python *Py: the Journal of the Python Language* http://www.pyzine.com Archive probing tricks of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 http://groups.google.com/groups?meta=site%3Dgroups%26group%3Dcomp.lang.python.* Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://www.ddj.com/topic/python/ (requires subscription) http://groups-beta.google.com/groups?q=python-url+group:comp.lang.python*&start=0&scoring=d& http://purl.org/thecliff/python/url.html (dormant) or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python There is *not* an RSS for "Python-URL!"--at least not yet. Arguments for and against are occasionally entertained. Suggestions/corrections for next week's posting are always welcome. E-mail to should get through. To receive a new issue of this posting in e-mail each Monday morning (approximately), ask to subscribe. Mention "Python-URL!". Write to the same address to unsubscribe. -- The Python-URL! Team-- Phaseit, Inc. (http://phaseit.net) is pleased to participate in and sponsor the "Python-URL!" project. Watch this space for upcoming news about posting archives. From spe.stani.be at gmail.com Tue Apr 29 07:51:34 2008 From: spe.stani.be at gmail.com (SPE - Stani's Python Editor) Date: Tue, 29 Apr 2008 04:51:34 -0700 (PDT) Subject: Learn python packaging for Ubuntu and Debian in the Ubuntu Open Week References: Message-ID: I forgot an important detail... This session will be hosted Thu 1 May at 21.00 UTC on IRC in #ubuntu- classroom. From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 16 06:52:37 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 16 Apr 2008 12:52:37 +0200 Subject: Image handling - stupid question In-Reply-To: <0001HW.C42B9FB90009B7E8B01AD9AF@news.individual.de> References: <0001HW.C42B9FB90009B7E8B01AD9AF@news.individual.de> Message-ID: <4805da69$0$11464$426a74cc@news.free.fr> Jumping Arne a ?crit : > I'm going to try to write some imange manipulation code (scaling, reading > EXIF and IPTC info) and just want to ask if PIL is *THE* library to use? > > I looked at and noticed that the > latest version is from Dec 2006. > > In my experience that means that either it's abandoned I doubt it is. > or that it's very good > and stable. My own experience is that it's indeed a pretty good and AFAICT stable library. From mobile at ibinsa.com Fri Apr 11 18:12:07 2008 From: mobile at ibinsa.com (Gabriel Ibanez) Date: Sat, 12 Apr 2008 00:12:07 +0200 Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> <47FFDA87.3070703@gmail.com> Message-ID: <020201c89c21$14d02be0$0a01a8c0@mobile> Hello all ! More fire .. Why is nobody talking about pyGTK ? There are no limits with licenses (I think) If we work on Ubuntu or Fedora, is there any reason to give GTK away and develop on Qt ? ----- Original Message ----- From: "Stef Mientki" Cc: Sent: Friday, April 11, 2008 11:39 PM Subject: Re: How is GUI programming in Python? > Rune Strand wrote: >> On Apr 10, 3:54 am, Chris Stewart wrote: >> ... >> >>> Next, what would you say is the best framework I should look into? >>> I'm curious to hear opinions on that. >>> >> >> GUI-programming in Python is a neanderthal experience. What one may >> love with console scripts is turned upside-down. Projects like Boa >> Constructor seemed to be a remedy, but is not developed. The Iron- >> Pythonistas has a very promising RAD GUI-tool in the IronPython - >> Studio, http://www.codeplex.com/IronPythonStudio - but if you're non- >> Iron, only sorrow is left - unless you fancy creating GUI in a text- >> editor. Something I consider waste of life. >> >> > Although not as simple as Delphi, > wxPython is still quit simple: > > GUI = """ > self.Splitter_Plots ,SplitterVer > self.Panel ,PanelVer, 010 > self.Panel_Top ,PanelHor, 11 > label1 ,wx.StaticText ,label = "Signal1" > label2 ,wx.StaticText ,label = "Signal2" > self.Panel_X ,wx.Panel, 11 > self.Panel_Bottom ,PanelHor > label11 ,wx.StaticText ,label = "Signal1b" > label12 ,wx.StaticText ,label = "Signal2b" > Panel_B ,wx.Panel > Button_1 ,wx.Button ,label = "Test" > Button_2 ,wx.Button ,label = "Test2", pos = (100,0) > """ > exec ( Create_wxGUI ( GUI ) ) > > cheers, > Stef > -- > http://mail.python.org/mailman/listinfo/python-list > From gagsl-py2 at yahoo.com.ar Fri Apr 18 15:27:38 2008 From: gagsl-py2 at yahoo.com.ar (gagsl-py2 at yahoo.com.ar) Date: Fri, 18 Apr 2008 16:27:38 -0300 (ART) Subject: import hooks In-Reply-To: <664bf2b80804170630j47e6c7a8r692f5d80af2cc13f@mail.gmail.com> Message-ID: <808535.5211.qm@web32807.mail.mud.yahoo.com> --- Patrick Stinson escribi?: > Right on, that seemed to work, thanks. > This is different than sys.path_hooks though, which > requires a callable or > string subclass? Yes, it's different, meta_path is a generic mechanism that doesn't depend on sys.path and is tried before sys.path is traversed; the other is triggered by a special sys.path entry (like a .zip file). > After some experimentation it looks like you can > disallow an import by > raising an import error from your meta_path hook. It > seems a little weird > that python will then raise a new ImportError from > import.c:find_module(), > but I guess the behavior is desirable.. I think you can't make an import fail completely; if your meta_path doesn't work, the next one is tried, and then the standard places (where the error is finally raised). Looks like the "global name foo not defined" error: sometimes it's not a global name at all, but that's where the search finally failed. -- Gabriel Genellina Gabriel Genellina Softlab SRL Tarjeta de cr?dito Yahoo! de Banco Supervielle. Solicit? tu nueva Tarjeta de cr?dito. De tu PC directo a tu casa. www.tuprimeratarjeta.com.ar From kitchen.kabinets at gmail.com Tue Apr 29 22:11:50 2008 From: kitchen.kabinets at gmail.com (kitchen.kabinets at gmail.com) Date: Tue, 29 Apr 2008 19:11:50 -0700 (PDT) Subject: Cheap Cabinets - Why You Don't Have To Sacrifice Quality To Find Cabinets At A Discount Price Message-ID: Kitchen Cabinets: http://the-kitchen-cabinets.blogspot.com, With the demand for cheaper building materials and the rapid housing boom a couple of years back, many kitchen cabinet manufacturers started looking overseas for a way to make a cheaper kitchen cabinet. In order to conform to the KCMA standards (Kitchen Cabinet Manufacturers Association), they required the kitchen cabinet manufacturing plants overseas to increase the quality of the materials they used and increase the durability of the kitchen cabinets. Discount kitchen cabinets or RTA Kitchen Cabinets up until this time had been made of fiberboard or particleboard, with staples or dowels holding the cabinets together. Many of the cheap kitchen cabinets at that time had a veneer surface that would warp or buckle when it came in contact with too much water. Because of these inferior features, they didn't compare to the cabinets that were being manufactured in the U.S. With the improvements to meet the standards of the KCMA, {discount| cheap} kitchen cabinets are now being built with solid plywood sides, solid wood face frames and doors. and cam locks to hold the cabinet together. Cheap Cabinets is no longer the right description for rta kitchen cabinets. With the improvements in design and function, discount cabinets started being imported by more and more companies to provide an alternative to the name brand manufacturers in the US that were asking, in some cases, 2-3 times as much for their kitchen cabinets as discount kitchen cabinet importers were. Even the big box stores started carrying their own lines of rta kitchen cabinets or discount cabinets, in both knockdown and pre-assembled form. There are some drawbacks to buying discount kitchen cabinets... most manufacturers only carry 5-6 different styles or finishes, which limits your choices. In order to get discount cabinets at their cheapest price, you have to buy them rta or ready-to-assemble, which requires additional time and labor to assemble them. The good news is that with the cam lock assembly, most discount cabinet lines only require a screwdriver to assemble them. So before buying your new kitchen cabinets at retail price, may sure you stop to take a look at discount kitchen cabinets or rta cabinets. Thanks for improvements, it is now possible to get cheap kitchen cabinets at a discount price. I have been able to save thousands of dollars on discount kitchen cabinets by buying RTA cabinets. If you are interested in finding out my secrets, go to my Kitchen Cabinets article at http://the-kitchen-cabinets.blogspot.com From stephen.cattaneo at u4eatech.com Tue Apr 1 15:09:09 2008 From: stephen.cattaneo at u4eatech.com (Stephen Cattaneo) Date: Tue, 01 Apr 2008 12:09:09 -0700 Subject: manipulating hex values In-Reply-To: References: <47F26CC3.3060307@u4eatech.com> Message-ID: <47F28855.50908@u4eatech.com> Gabriel Genellina wrote: >
En Tue, > 01 Apr 2008 14:11:31 -0300, Stephen Cattaneo > escribi?: > >> I am relatively new to socket programming. I am attempting to use raw >> sockets to spoof my IP address. > > Don't bother to try... > ? Is there a better solution to spoofing my IP then using raw sockets (I'm working on a machine with multiple interfaces and need to be able to some how specify which interface that traffic needs to be sent/recieved to/from) >> From what I can tell I will have to >> build from the Ethernet layer on up. This is fine, but I am having >> some trouble with manipulating my hex values. >> >> Seems to me that there are two ways to store hex values: >> 1. as literal hex - 0x55aa >> 2. as a string - "\x55aa" > > The later is exactly the same string as "Uaa": > > py> print "\x55aa" > Uaa > >> If I want to convert hex to decimal I can use: >> int("\x55aa", 16) # note that plain 0x55aa, instead of "\x55aa", will >> raise an exception > > Have you tried it? > > py> int("\x55aa", 16) > Traceback (most recent call last): > File "", line 1, in > ValueError: invalid literal for int() with base 16: 'Uaa' > py> int("0x55aa", 16) > 21930 > An oversight on my part and the source of my problem. Thank you. The source of my confusion is that I need to keep my bytes formated correctly. I am using the below 'raw socket example' proof-of-concept code as my example. (And yes, I have tried the proof-of-concept. It works correctly. It is not my code.) dstAddr = "\x01\x02\x03\x04\x05\x06" dstAddr1 = "0x010203040506" dstAddr != dstAddr1 Follow up question: What is the best to store my bytes up until sending the packets? Perhaps I should use lists of decimal numbers and then before sending convert to hex. I.E. dstAddr = [ 1, 2, 3, 4, 5, 6] dstAddr.prepareToSend() txFrame = struct.pack("!6s6sh",dstAddr,srcAddr,proto) + ethData Is there a better way to do this? Thanks, Steve ----------------raw socket example------------------- #!/usr/bin/python import sys import string import struct from socket import * proto = 0x55aa s = socket(AF_PACKET, SOCK_RAW, proto) s.bind(("eth0",proto)) ifName,ifProto,pktType,hwType,hwAddr = s.getsockname() srcAddr = hwAddr # send packet to ethernet MAC: 01-02-03-04-05-06 dstAddr = "\x01\x02\x03\x04\x05\x06" ethData = "here is some data for an ethernet packet" print "ethData length is: " + str(len(ethData)) txFrame = struct.pack("!6s6sh",dstAddr,srcAddr,proto) + ethData s.send(txFrame) From ZeeGeek at gmail.com Thu Apr 10 04:45:41 2008 From: ZeeGeek at gmail.com (ZeeGeek) Date: Thu, 10 Apr 2008 01:45:41 -0700 (PDT) Subject: email header decoding fails References: Message-ID: On Apr 10, 4:31 pm, "Gabriel Genellina" wrote: > En Wed, 09 Apr 2008 23:12:00 -0300, ZeeGeek escribi?: > > > It seems that the decode_header function in email.Header fails when > > the string is in the following form, > > > '=?gb2312?Q?=D0=C7=C8=FC?=(revised)' > > > That's when a non-encoded string follows the encoded string without > > any whitespace. In this case, decode_header function treats the whole > > string as non-encoded. Is there a work around for this problem? > > That header does not comply with RFC2047 (MIME Part Three: Message Header > Extensions for Non-ASCII Text) > > Section 5 (1) > An 'encoded-word' may replace a 'text' token (as defined by RFC 822) > in any Subject or Comments header field, any extension message > header field, or any MIME body part field for which the field body > is defined as '*text'. [...] > Ordinary ASCII text and 'encoded-word's may appear together in the > same header field. However, an 'encoded-word' that appears in a > header field defined as '*text' MUST be separated from any adjacent > 'encoded-word' or 'text' by 'linear-white-space'. > > Section 5 (3) > As a replacement for a 'word' entity within a 'phrase', for example, > one that precedes an address in a From, To, or Cc header. [...] > An 'encoded-word' that appears within a > 'phrase' MUST be separated from any adjacent 'word', 'text' or > 'special' by 'linear-white-space'. Thank you very much, Gabriel. From jwwest at gmail.com Sun Apr 13 03:18:13 2008 From: jwwest at gmail.com (James West) Date: Sun, 13 Apr 2008 02:18:13 -0500 Subject: Recommendation for Web Framework Message-ID: <4801b3a6$0$7713$4c368faf@roadrunner.com> Let me explain my situation a bit. I've been contracted to develop an ecommerce site. It's nothing too huge but requires a lot of custom development that's not typical for your run of the mill webstore. I've got about three weeks to get the project delivered and I've written quite a bit of code already. I'd like to find some sort of tool to generate some of the repetative bits like data management (think phpMyAdmin but for Python) so I don't have to write a stupid mangement script for every single module (users, customers, inventory, etc). I know there's tools out there that will do this for ASP code with a SQL server backend, but I haven't seen anything for Python outside of the web application frameworks. Ideally, I'd like something like Ruby on Rails that would provide scaffolding support so I can bootstrap the system, so to speak. I've looked at Django, but the client is only running Apache 1.x and Python 2.3. I've given Turbo Gears a try, but couldn't get SQLObject to run (threw an error that I didn't have time to struggle with). So basically I need something with low dependencies, easy to develop in, and releatively easy to deploy. Anyone have any recommendations? I really need something on which I can ramp up quickly to get this project out of the door fast. I'm also a framework newbie, so I know there's a learning curve. Any input is appreciated, thank you. - james From rjh at see.sig.invalid Mon Apr 14 08:01:29 2008 From: rjh at see.sig.invalid (Richard Heathfield) Date: Mon, 14 Apr 2008 12:01:29 +0000 Subject: Game design : Making computer play References: Message-ID: skanemupp at yahoo.se said: > On 14 Apr, 09:13, v4vijayakumar > wrote: >> In computer based, two player, board games, how to make computer play? >> Are there any formal ways to _teach_ computer, to choose best possible >> move? >> >> I know this is kind of off-topic here. Please redirect me, if there >> are more appropriate newsgroup. > > can you post a link to the game so I can see the rules and how the > board looks. Here's the board (which bears only a slight resemblance to one I'd seen on the Web): +---------------+ | HORN $ | +---+---+---+---+---+---+ |L W| | $ | $ | |R W| +E-I+--CHEST+---+---+I-I+ |F N| | | | |G N| +T-G+---+---+---+---+H-G+ | | | | | |T | +---+---+---+---+---+---+ | LEGS| | | +---+---+---+---+ There are three tigers and fifteen goats. The tigers' goal is to eat all the goats and remain mobile. It seems that the initial tiger positions are: one on the horn, and one each on CHEST-2 and CHEST-3 (see $ marks, above). The goats' goal is to block the tigers from moving. The goats are placed one by one. Tigers appear only to be able to move orthogonally (up/down/left/right) - although they can use the horn to whizz across the chest (e.g. CHEST-1 to HORN, HORN to CHEST-4, in two moves). The rest of the rules are beyond me, I'm afraid. It's not clear how tigers eat goats or how goats block tigers. -- Richard Heathfield Email: -http://www. +rjh@ Google users: "Usenet is a strange place" - dmr 29 July 1999 From bwljgbwn at gmail.com Tue Apr 22 05:54:36 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:54:36 -0700 (PDT) Subject: flash 8 crack Message-ID: flash 8 crack http://cracks.12w.net F R E E C R A C K S From carsten.haese at gmail.com Thu Apr 17 19:59:24 2008 From: carsten.haese at gmail.com (Carsten Haese) Date: Thu, 17 Apr 2008 23:59:24 GMT Subject: get quote enclosed field in a line In-Reply-To: <4807e238$1@news.mel.dft.com.au> References: <4807e238$1@news.mel.dft.com.au> Message-ID: John Machin wrote: > xahlee at gmail.com wrote: >> is there a simple way in perl, python, or awk/shell/pipe, that gets >> the user agent field in a apache log? > If you don't like that, just hang about -- there's sure to be a > pyparsing bus coming by real soon now :-) While we're waiting for the pyparsing bus, here's the shlex train: import shlex line = """blah blah blah""" print shlex.split(line)[10] HTH, -- Carsten Haese http://informixdb.sourceforge.net From mfb.chikazuku at gmail.com Thu Apr 10 14:56:54 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Thu, 10 Apr 2008 20:56:54 +0200 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Mike Driscoll wrote: > On Apr 10, 12:05 pm, Michel Bouwmans wrote: >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> >> >> Paul Rubin wrote: >> > Chris Stewart writes: >> >> I've always had an interest in Python and would like to dabble in it >> >> further. I've worked on a few very small command line programs but >> >> nothing of any complexity. I'd like to build a really simple GUI app >> >> that will work across Mac, Windows, and Linux. How painful is that >> >> going to be? I used to be really familiar with Java Swing a few years >> >> ago. I imagine it will be similar. >> >> ... >> >> Next, what would you say is the best framework I should look into? >> >> > If by "best" you mean "easiest", that is probably tkinter, which >> > comes with python. It is somewhat rudimentary and the widgets that >> > come with it don't look so great. But if you just want to put up >> > GUI's with basic functionality and not much glitz, it is ok for most >> > such purposes. >> > out how to use >> >> I don't quite agree with you on this. Tkinter may be easy because it is >> available by standard in Python, but that's about it in my opinion. The >> API, look and performance hit is horrible. You're much better of with >> PyQt4 which makes the job really simple. >> >> MFB >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG v1.4.7 (GNU/Linux) >> >> iD8DBQFH/kjhDpaqHmOKFdQRAj+kAJ0d3aHqpv/mh7kSqtDqUFXtJsxi1gCfU5UP >> 2Ygw9ttRIYX+ioMyBVUNsVo= >> =stR5 >> -----END PGP SIGNATURE----- > > I see a lot of people recommend using pyQt, but they never mention the > controversy that surrounds its licensing. There have been many posts > on the subject already, but if the OP ever decides to sell anything > they create, I've heard that QT's licensing is kind of squirrelly. > Maybe this has been straightened out? > > I looked at the website and found it fairly confusing. And don't you > need to download QT itself? > > Mike Yeah, the licensing of Qt is either be open-source (under one of the Qt-exception licenses licenses so no exclusivity for the GPL anymore) or pay for the commercial version. So yes, if you would like to sell it as closed-source software you will need to buy the commercial version of Qt and PyQt. In other words: you will have to pay twice. Don't forget that you can also sell open-source software, so you don't have to pay. ;) MFB -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFH/mMBDpaqHmOKFdQRAiAkAJ0XoysACvcaxLWwvYauFlgEEaGLVwCfdz7g XMUDfEPLX6RfLV25viLB9aA= =d2ms -----END PGP SIGNATURE----- From fritz at milkpotato.org Mon Apr 28 09:36:09 2008 From: fritz at milkpotato.org (fritz) Date: Mon, 28 Apr 2008 06:36:09 -0700 Subject: is there a threadsafe cookie library? Message-ID: <20080428063609.3a0ad024ae5a198c10a90d54bed1b07a.ff2f7b4127.wbe@email.secureserver.net> An HTML attachment was scrubbed... URL: From sturlamolden at yahoo.no Thu Apr 17 13:05:00 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 17 Apr 2008 10:05:00 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> <69cbd3d3-449f-4e64-96d5-f512cf317032@m3g2000hsc.googlegroups.com> Message-ID: <2a32d56a-5075-4c48-99fc-686a3f53fc26@m36g2000hse.googlegroups.com> On Apr 17, 6:03 pm, Rhamphoryncus wrote: > Interesting. Windows specific, but there's other ways to do the same > thing more portably. I believe you can compile Python as a shared object (.so) on Linux as well, and thus loadable by ctypes. > The bigger issue is that you can't share any objects. Why not? > This > effectively gives you a multiprocess model - a bit cheaper than that, > but not enough to really supply GIL-free threading. That solution is safe. But I am looking into sharing objects. I don't think its impossible. PyObject* pointers can be passed around. GILs can be acquired and released, refcounts increased and decreased, etc. but we have to sort out some synchronization details for the shared objects. For one thing, we have to make sure that a garbage collector does not try to reclaim a PyObject* belonging to another interpreter. But here we are talking about minor changes to CPython's source, or perhaps none at all. From steve at holdenweb.com Sat Apr 12 17:51:16 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 17:51:16 -0400 Subject: str(bytes) in Python 3.0 In-Reply-To: References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> Message-ID: Dan Bishop wrote: > On Apr 12, 9:29 am, Carl Banks wrote: >> On Apr 12, 10:06 am, Kay Schluehr wrote: >> >>> On 12 Apr., 14:44, Christian Heimes wrote: >>>> Gabriel Genellina schrieb: >>>>> On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') >>>>> above. But I get the same as repr(x) - is this on purpose? >>>> Yes, it's on purpose but it's a bug in your application to call str() on >>>> a bytes object or to compare bytes and unicode directly. Several months >>>> ago I added a bytes warning option to Python. Start Python as "python >>>> -bb" and try it again. ;) >>> And making an utf-8 encoding default is not possible without writing a >>> new function? >> I believe the Zen in effect here is, "In the face of ambiguity, refuse >> the temptation to guess." How do you know if the bytes are utf-8 >> encoded? > > True, you can't KNOW that. Maybe the author of those bytes actually > MEANT to say '??C??mo est??s?' instead of '?C?mo est?s?'. However, > it's statistically unlikely for a non-UTF-8-encoded string to just > happen to be valid UTF-8. So you propose to perform a statistical analysis on your input to determine whether it's UTF-8 or some other encoding? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gagsl-py2 at yahoo.com.ar Thu Apr 24 01:00:14 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 24 Apr 2008 02:00:14 -0300 Subject: python-doc References: Message-ID: En Wed, 23 Apr 2008 11:02:46 -0300, korean_dave escribi?: > Hi all. I am using this to try to document my python-coded apps. > http://effbot [DOT] org/zone/pythondoc [DOT] htm > > i am using windows XP professional. I have put the install directory > of pythondoc.py in my path file. So i "cd" to the directory containing > the python scripts I wish to python-doc, typing in "python-doc.py > scriptname.py" and after about 1 second, i get nothing. No error, but > again, no indication that this process has been completed. > > I have no idea where to look for html files. I checked all relevant > directories that might have it (the directory containing the > pythondoc.py script, etc.). I've never used pythondoc myself, but it says "The current version writes the output to the current directory, to files named pythondoc-module.html." You may try using another documentation tool, there are many available, see -- Gabriel Genellina From hobgoodoreneyhb at gmail.com Tue Apr 22 11:45:00 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:45:00 -0700 (PDT) Subject: revit building 9 crack only Message-ID: <485712cb-4510-4199-8589-ed151ef79597@p25g2000hsf.googlegroups.com> revit building 9 crack only http://cracks.12w.net F R E E C R A C K S From tjreedy at udel.edu Mon Apr 7 16:59:21 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 7 Apr 2008 16:59:21 -0400 Subject: A funnily inconsistent behavior of int and float References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com><1d11875a-470a-489f-910a-b420a145eb61@a1g2000hsb.googlegroups.com><11b4793c-04cc-4898-99a8-8418d237de3e@2g2000hsn.googlegroups.com> <1255ee3e-cc1e-4ae8-96f3-5f942c389c49@t54g2000hsg.googlegroups.com> Message-ID: "Mark Dickinson" wrote in message news:1255ee3e-cc1e-4ae8-96f3-5f942c389c49 at t54g2000hsg.googlegroups.com... Thank you for the corrections. Here is my revised proposal: int([number | string[, radix]) Convert a number or string to an integer. If no arguments are given, return 0. If a number is given, return number.__int__(). Conversion of floating point numbers to integers truncates towards zero. A string must be a base-radix integer literal optionally preceded by '+' or '-' (with no space in between) and optionally surrounded by whitespace. A base-n literal consists of the digits 0 to n-1, with 'a' to 'z' (or 'A' to 'Z') having values 10 to 35. The default radix is 10. The allowed values are 0 and 2-36. Base-2, -8, and -16 literals can be optionally prefixed with 0b/0B, 0o/0O, or 0x/0X, as with integer literals in code. Radix 0 means to interpret exactly as a code literal, so that the actual radix is 2, 8, 10, or 16, and so that int('010',0) is not legal, while int('010') is. Terry Jan Reedy From tjreedy at udel.edu Thu Apr 10 16:07:01 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 10 Apr 2008 16:07:01 -0400 Subject: Module Conflicts References: <1592fad3-996b-4f62-ac12-42aff8272c21@8g2000hsu.googlegroups.com> <845e315c-0159-4390-954a-dc93fd1b27a1@x41g2000hsb.googlegroups.com> Message-ID: "Jose" wrote in message news:b7ed8b5e-91fa-4495-b4e3-4912be9e8d90 at s50g2000hsb.googlegroups.com... | On Apr 9, 10:36 pm, Benjamin wrote: | > On Apr 9, 5:33 pm, Jose wrote: | > | > > I have a module named math.py in a package with some class | > > definitions. I am trying to import the standard python math module | > > inside of math.py but It seems to be importing itself. Is there any | > > way around this problem without renaming my math.py file? | > | > Not without some unpythonic magic. It's really not good style to name | > a module the same as a stdlib one. It'll also confuse people reading | > your code. | | Yeah but I thought since math.py was in a package, it would be okay. The stdlib contains a few packages, but it is not a package in itself. So math is not in a package. From aaron.watters at gmail.com Wed Apr 30 10:20:13 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 30 Apr 2008 07:20:13 -0700 (PDT) Subject: best way to host a membership site References: <53034dcc-7346-4f71-889c-3278c9e813ec@w1g2000prd.googlegroups.com> <48185252$0$32098$426a74cc@news.free.fr> Message-ID: > We're about to start a couple somewhat similar projects here, and while > our chief engineer is a definitive Ruby/Rails addict, we finally settled > on Django. While it's not my own personal favorite Python MVC framework, > it's still a very good one, and probably the more mature and stable so > far. wrt/ the "add more apps in the future" concern, you may want to > read this:http://www.b-list.org/weblog/2007/nov/29/django-blog/ Interesting link. Django does seem to be a well designed modular approach -- and I think if it had existed back in '97 the history of web development would have been much different. I can't help feeling that it would be nice to have a collection of tools that was even more orthogonal and flexible, and WSGI seems to possibly offer a nice base platform for constructing tools like these. Also I think it remains devilishly difficult to implement ajaxy functionalities like smart data pickers, in-form validation, partial form saving, "chatty interfaces" etc. What are some good paradigms or methodologies or ideas out there that the Python community should steal? :) warning: It's very possible that my understanding of Django is not deep enough and that the answer is "Django". -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=you+may+cheat From dolloffdelvpg at gmail.com Wed Apr 16 08:09:47 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:09:47 -0700 (PDT) Subject: taylor swift a place in this world Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From kyosohma at gmail.com Wed Apr 9 16:57:43 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 9 Apr 2008 13:57:43 -0700 (PDT) Subject: Control process execution References: <1d1bbea2-a503-4db5-bd3f-c45c29916b9c@13g2000hsb.googlegroups.com> Message-ID: <7cb4c5dd-8604-4d18-925c-d6aa17c092b5@24g2000hsh.googlegroups.com> On Apr 9, 3:11 pm, Noah wrote: > On Apr 6, 5:30 am, Wesley Mesquita wrote: > > > I am trying to create a test environment to a couple C applications > > (simple UDP and TCP server/clients), so I want to write this in python > > and I m looking for ways to do it. Basically I need an execution timer > > and timeout control (to kill the apps in certain situations). Looking > > at google, I found the Pexpect package, but I m a little bit lost in > > using it. > > Pexpect might be good. But if you are just looking at running an > application > without talking to it interactively then you might be able to just get > by > with os.process. > > -- > Noah As far as I know, there is no "os.process". Maybe you meant os.system or the subprocess module? Mike From kyosohma at gmail.com Wed Apr 9 09:19:09 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 9 Apr 2008 06:19:09 -0700 (PDT) Subject: I am worried about Python 3 References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> Message-ID: <44c8b263-a01b-45b5-a971-faa6aa1611ec@d45g2000hsc.googlegroups.com> On Apr 9, 7:04 am, jmDesktop wrote: > I am a new Python programmer. I have always desired to learn Python, > but have never had the opportunity. Recently this has changed, and I > have an opportunity to get away from the .NET framework. I found > Django (and other web frameworks) and began my quest to learn. I > started reading Dive Into Python and anything I could find and started > participating here in usenet. Then I had to read this: > > http://www.comp.leeds.ac.uk/nde/papers/teachpy3.html > > I think that every time I start a new technology (to me) it is about > to change. Yes, I know that is the nature of things, but I'm always > at the start of "something new." > > If I continue in Python 2.5.x, am I making a mistake? Is it really > that different? > > Here is an excerpt that is causing me concern: > > Two new versions of the language are currently in development: version > 2.6, which retains backwards compatibility with previous releases; and > version 3.0, which breaks backwards compatibility to the extent that > even that simplest of programs, the classic 'Hello, World', will no > longer work in its current form. > > It makes me feel like I am wasting my time and makes it difficult to > justify spending time on projects using 2.5.x and using it where I > work. Just because there's a new version on the horizon that doesn't mean you have to upgrade to it. There are plenty of people that still use 2.3, such as my web host. I've only just started really using 2.5 this year. Mike From SuJinzhu at gmail.com Mon Apr 14 04:26:28 2008 From: SuJinzhu at gmail.com (James Su) Date: Mon, 14 Apr 2008 01:26:28 -0700 (PDT) Subject: Chinese character become ??? by pymssql or pyodbc Message-ID: <01d95039-b547-45ff-9b54-f04aee8eaaa1@u36g2000prf.googlegroups.com> I tried to use pymssql to access MSSQL 2000, with a table, I store Chinese Character in NVarchar field, Chinese Character display normally when I query them by MS SQL Query Analyzer under Windows or by unixODBC under Ubuntu. But when I query those data by pymssql or pyodbc, all Chinese Character display ??? instead. Does anyone has some advice or thread? Thanks. From carbanancizpo at gmail.com Fri Apr 18 16:55:22 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:55:22 -0700 (PDT) Subject: army men 2 crack Message-ID: army men 2 crack http://cracks.12w.net F R E E C R A C K S From tjreedy at udel.edu Thu Apr 24 04:41:50 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 24 Apr 2008 04:41:50 -0400 Subject: function that accepts any amount of arguments? References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> Message-ID: "globalrev" wrote in message news:4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0 at w7g2000hsa.googlegroups.com... | if i want a function that can take any amount of arguments how do i | do? | | lets say i want a function average that accepts any number of integers | and returns the average. To add to the other comments, read the ref manual section of function defs. From meisnernel73884 at gmail.com Wed Apr 30 06:38:48 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:38:48 -0700 (PDT) Subject: autocad 2005 cracks and cheats Message-ID: <2df45216-0fff-4f22-9876-0de8b24a6397@2g2000hsn.googlegroups.com> autocad 2005 cracks and cheats http://crack.cracksofts.com From george.sakkis at gmail.com Tue Apr 1 09:43:49 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 1 Apr 2008 06:43:49 -0700 (PDT) Subject: class super method References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> Message-ID: <0eb3ee4e-82e2-419a-8e7b-4931f7b4effa@c26g2000prf.googlegroups.com> On Mar 31, 10:41 pm, Ed Leafe wrote: > On Mar 31, 2008, at 5:58 PM, George Sakkis wrote: > > >> is there any tutorial for super method (when/how to use it)? > > >> or maybe someone could explain me how it works? > > >> thx > > > Super is one of the dark corners of the language [1,2]... a good rule > > of thumb is to stay away from it, or at least stick to its basic > > usage. > > I disagree - super is quite elegant and dependable. Did you follow the links I gave by any chance? With all the gotchas and rules of how to use it properly, it's far from what I would call elegant. > In my own project (Dabo), we use mixin classes liberally to provide > consistent behavior across our UI classes. The use of super makes > customizing __init__() behavior, for example, quite straightforward. > The general form looks like: > > class DaboUIClass(dabo.ui.dControlMixin, someWxPythonClass): > def __init__(self, *args, **kwargs): > doOurCustomStuffBeforeTheSuperCall() > super(DaboUIClass, self).__init__(*args, **kwargs) > doOurCustomStuffAfterTheSuperCall() > > This has worked reliably for us in every place where we have used it. > There's nothing dark and mysterious about it at all. Pehaps, at least as long as you make sure that all superclasses have a compatible signature - which in practice typically means accept arbitrary *args and **kwargs in every class in the hierarchy like your example. Good luck figuring out what's wrong if it's not used consistently. Also doOurCustomStuffBeforeTheSuperCall() works as long as all ancestor methods to be called need the same CustomStuff massaging. In a sentence, it's better than nothing but worse than anything. George From JesseAldridge at gmail.com Sun Apr 6 10:34:11 2008 From: JesseAldridge at gmail.com (Jesse Aldridge) Date: Sun, 6 Apr 2008 07:34:11 -0700 (PDT) Subject: Python Data Utils References: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> Message-ID: On Apr 6, 6:14?am, "Konstantin Veretennicov" wrote: > On Sun, Apr 6, 2008 at 7:43 AM, Jesse Aldridge wrote: > > In an effort to experiment with open source, I put a couple of my > > ?utility files up here. ?What do you think? > > Would you search for, install, learn and use these modules if *someone > else* created them? > > -- > kv Yes, I would. I searched a bit for a library that offered similar functionality. I didn't find anything. Maybe I'm just looking in the wrong place. Any suggestions? From paulgeeleher at gmail.com Tue Apr 22 12:21:44 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Tue, 22 Apr 2008 09:21:44 -0700 (PDT) Subject: Setting expirty data on a cookie Message-ID: <8ba48e05-9aba-4a56-805c-cd31b43517ab@24g2000hsh.googlegroups.com> Does anyone know how to do this? I can't seem to make it work. I'm using: c = Cookie.SimpleCookie() c['data'] = "unamepwordwhatever" c.expires = time.time() + 300 print c This doesn't seem to work, so I'm assuming isn't the correct way to set an expiry data? Anyone able to help me out here? Thanks! From fr5478bey at gmail.com Sat Apr 26 11:38:07 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:38:07 -0700 (PDT) Subject: registry mechanic 7.0 crack Message-ID: <4405bd80-9ec0-412b-9e28-ed3469a6dd1b@f63g2000hsf.googlegroups.com> registry mechanic 7.0 crack http://cracks.00bp.com F R E E C R A C K S From fredrik at pythonware.com Sun Apr 6 04:34:17 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 06 Apr 2008 10:34:17 +0200 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: <47F831F7.4000709@holdenweb.com> References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> <47F831F7.4000709@holdenweb.com> Message-ID: Steve Holden wrote: >> for reference, here's what I get on Ubuntu 7.10, with the standard >> Python interpreter (2.5.1): >> >> $ python -c "import imp; print imp.get_suffixes()" >> [('.so', 'rb', 3), ('module.so', 'rb', 3), ('.py', 'U', 1), >> ('.pyc', 'rb', 2)] >> >> any Ubuntu gurus here that can sort this one out? >> > I wouldn't claim to be an Ubuntu guru but it seems as though the Ubuntu > team decide that you would be able to import extension module YYY either > from YYY.so or from YYYmodule.so. IF you are asking *why* then I'd have > to answer that I have no idea at all. oh, the ".so" and "module.so" is standard Python behaviour (see my first post in this thread). what I cannot figure out is how "llothar" has managed to get setup.py to build extensions that an Ubuntu Python cannot load, without noticing. From cyberco at gmail.com Wed Apr 9 05:35:48 2008 From: cyberco at gmail.com (Berco Beute) Date: Wed, 9 Apr 2008 02:35:48 -0700 (PDT) Subject: Can C.L.P.handle the load? References: <3b6737c8-9d42-4218-ac60-01df2f578746@p39g2000prm.googlegroups.com> <9bd25fd3-5133-4165-9784-fbbc21145810@24g2000hsh.googlegroups.com> Message-ID: On Apr 9, 7:54 am, Paddy wrote: > What else could we do to make c.l.p. of more use to the newbie whp may > also be new to usenet whilst keeping c.l.p a usefull place for all? > > - Paddy. Maybe create a usenet/google group for newbies? A place to ask beginners questions. And post a sticky to c.l.p. redirecting newbies (or experienced pythoneers with newbie questions :). 2B From the.doag at gmail.com Wed Apr 23 18:24:02 2008 From: the.doag at gmail.com (Daniel) Date: Wed, 23 Apr 2008 15:24:02 -0700 (PDT) Subject: Parsing tuple from string? Message-ID: I have a list of strings, which I need to convert into tuples. If the string is not in python tuple format (i.e. "('one', 'two')", "("one", 'two')", etc.), then I can just make it a 1-tuple (i.e. return (string,) ). If it is in python tuple format, I need to parse it and return the appropriate tuple (it's ok to keep all tuple elements as strings). I think eval() will work for this, but I don't know what will be in the string, so I don't feel comfortable using that. I tried coming up with a regex, but the best I can get with my limit knowledge right now is: matches = re.match("\(['\"](.*)['\"], ['\"](.*)['\"]\)", string) which works well enough for my purposes (even though I know it's far from proper), except that it only captures as 2-tuples, and I need to be able to capture n-tuples. Can someone help point me to the correct re or a better way to solve this? Thanks in advance, Daniel From ellingt8877 at gmail.com Mon Apr 28 01:48:48 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:48:48 -0700 (PDT) Subject: stellar phoenix crack Message-ID: stellar phoenix crack http://crack.cracksofts.com From bob at passcal.nmt.edu Fri Apr 18 17:26:58 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Fri, 18 Apr 2008 15:26:58 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> Message-ID: <2008041815265875249-bob@passcalnmtedu> On 2008-04-18 14:37:21 -0600, Ross Ridge said: > Bob Greschke wrote: >> I'm reading 3-byte numbers from a file and they are signed (+8 to >> -8million). This seems to work, but I'm not sure it's right. >> >> # Convert the 3-characters into a number. >> Value1, Value2, Value3 = unpack(">BBB", Buffer[s:s+3]) >> Value = (Value1*65536)+(Value2*256)+Value3 >> if Value >= 0x800000: >> Value -= 0x1000000 >> print Value >> >> For example: >> 16682720 = -94496 >> >> Should it be Value -= 0x1000001 so that I get -94497, instead? > > Your first case is correct, "Value -= 0x1000000". The value 0xFFFFFFF > should be -1 and 0xFFFFFFF - 0x1000000 == -1. > > An alternative way of doing this: > > Value = unpack(">l", Buffer[s:s+3] + "\0")[0] >> 8 > > Ross Ridge Good to know (never was good on the math front). However, in playing around with your suggestion and Grant's code I've found that the struct stuff is WAY slower than doing something like this Value = (ord(Buf[s])*65536)+(ord(Buf[s+1])*256)+ord(Buf[s+2]) if Value >= 0x800000: Value -= 0x1000000 This is almost twice as fast just sitting here grinding through a few hundred thousand conversions (like 3sec vs. ~5secs just counting on my fingers - on an old Sun...it's a bit slow). Replacing *65536 with <<16 and *256 with <<8 might even be a little faster, but it's too close to call without really profiling it. I wasn't planning on making this discovery today! :) Bob From vaibhav4947 at gmail.com Tue Apr 8 07:44:30 2008 From: vaibhav4947 at gmail.com (vaibhav pol) Date: Tue, 8 Apr 2008 17:14:30 +0530 Subject: No subject Message-ID: <18a05b120804080444ke5819e0n683ef6387267042d@mail.gmail.com> hi, I wrote a python program and import the function and executing , that fuction get executing as the current uid what i have to do if i want to exectue that function as root or another user . -------------- next part -------------- An HTML attachment was scrubbed... URL: From arnodel at googlemail.com Sun Apr 20 13:04:01 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 20 Apr 2008 10:04:01 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: <4d543ba1-c601-4490-8739-e42b46fc2236@k37g2000hsf.googlegroups.com> On Apr 20, 5:42?pm, Matthew Woodcraft wrote: > Christian Heimes ? wrote: > > >> I feel that including some optional means to block code would be a big > >> step in getting wider adoption of the language in web development and > >> in general. ?I do understand though, that the current strict indenting > >> is part of the core of the language, so... thoughts? > > Why should Python repeat the mistakes other languages did with SSI or > > inline code? Python favors the MVC separation of code and layout. > > An alternative scheme for describing the block structure could be > useful in other cases, though. For example, if you wanted to support > putting snippets of Python in configuration files, or spreadsheet > cells. > > There's no need to support the new scheme in .py files, so it seems to > me that this doesn't have to be done in the core language. All that's > needed is a variant of 'eval' which expects the alternate scheme, and > that could be prototyped just using text manipulation and the normal > 'eval'. By 'eval', I guess you mean 'exec' :) -- Arnaud From jr9445 at ATT.COM Thu Apr 10 11:37:55 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Thu, 10 Apr 2008 10:37:55 -0500 Subject: Stripping scripts from HTML with regular expressions In-Reply-To: <47fd46b3$0$6838$2d805a3e@textnews.eweka.nl> References: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> <47fd46b3$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: > -----Original Message----- > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > list-bounces+jr9445=att.com at python.org] On Behalf Of Michel Bouwmans > Sent: Wednesday, April 09, 2008 5:44 PM > To: python-list at python.org > Subject: RE: Stripping scripts from HTML with regular expressions > > > Thanks! That did the trick. :) I was trying to use HTMLParser but that > choked on the script-blocks that didn't contain comment-indicators. > Guess I > can now move on with this script, thank you. > Soooo.... you asked for help with a regex workaround, but didn't ask for help with the original problem, namely HTMLParser? ;-) ***** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA625 From carlwuhwdmckay at gmail.com Sat Apr 26 09:33:19 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:33:19 -0700 (PDT) Subject: serials and cracks Message-ID: <227a7ae9-14d5-4363-beb6-852ea6369ca3@m36g2000hse.googlegroups.com> serials and cracks http://cracks.00bp.com F R E E C R A C K S From pavlovevidence at gmail.com Sun Apr 13 03:24:04 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Sun, 13 Apr 2008 00:24:04 -0700 (PDT) Subject: str(bytes) in Python 3.0 References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> <806cf1da-8f06-4fff-8437-7f1ca1ff9472@k10g2000prm.googlegroups.com> Message-ID: <8fab7cda-d915-4e13-8bb8-f449b6617778@a22g2000hsc.googlegroups.com> On Apr 12, 11:51 am, Kay Schluehr wrote: > On 12 Apr., 16:29, Carl Banks wrote: > > > > And making an utf-8 encoding default is not possible without writing a > > > new function? > > > I believe the Zen in effect here is, "In the face of ambiguity, refuse > > the temptation to guess." How do you know if the bytes are utf-8 > > encoded? > > How many "encodings" would you define for a Rectangle constructor? I'm not sure what you're insinuating. If you are arguing that it's inappropriate for a constructor to take an "encoding" argument (as you put it), be my guest. I wasn't commenting on that specifically. I was commenting on your suggestion of having str assume utf-8 encoding, which IMO would be very unPythonic, whether you can pass encodings to it or not. Whatever happened to the decode method anyway? Why has str() been coopted for this purpose? I had expected that str objects would retain the encode method, bytes the decode method, and everyone would live happily ever after. If decode is a confusing name (and I know I have to engage a few extra neurons to figure out which way it goes), why not rename it to something like to_unicode instead of overloading the constructors more. Carl Banks From marcobonifazi at gmail.com Sun Apr 6 04:26:11 2008 From: marcobonifazi at gmail.com (Marco Bonifazi) Date: Sun, 6 Apr 2008 01:26:11 -0700 (PDT) Subject: PyGtk Windows all in one installer Message-ID: I realized a PyGtk all in one installer for Windows. You can download it from here: http://www.bonifazi.eu/appunti/pygtk_windows_installer.exe It is simply an assembling of all the different installers I previously downloaded (which are executed step by step), and you can choose. I realized this installer using EclipseNSIS and compiling the script generated by NSIS. Then, the script I created and that you can compile and modify using NSIS is the following: http://www.bonifazi.eu/appunti/pygtk_windows_installer.nsi I give also the link of the webpages where I got the different installers: http://www.bonifazi.eu/appunti/2008/04/pygtk-all-in-one-installer.html I'll try to keep update this installer. I hope it could be useful to someone. Bye. Marco Bonifazi From vlastimil.brom at gmail.com Sat Apr 12 18:38:05 2008 From: vlastimil.brom at gmail.com (Vlastimil Brom) Date: Sun, 13 Apr 2008 00:38:05 +0200 Subject: sqlite3 - adding tables and rows via parameters In-Reply-To: References: <9fdb569a0804120839w6916ed96ka5b53aad7ca6f565@mail.gmail.com> <9fdb569a0804121115v43d86c49ieb0f712bd5a49679@mail.gmail.com> Message-ID: <9fdb569a0804121538x4e0b0a88h3312dbafc58ace4e@mail.gmail.com> 2008/4/13, Steve Holden : > > Vlastimil Brom wrote: > > > ... are there any (security > > ...) risks of using string interpolation for table and column names in > the SQL commands? Or > > are the values, where parametrization (with ? in sqlite3) is supported, > > the only vulnerable part; whereas eg. an incorrect value of what should > > be a name is safe (of course, apart from the unsuccessful command > itself)? > > > > Ultimately that depends where the table and column names come from. If > they are user inputs then you are still vulnerable to SQL injection, but > usually that's not the case when a query is being parameterized - > usually it's values. > > As long as you consider the source of your data carefully you'll > probably be OK. > > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > Thanks again, there shouldn't be any unsecure data I am now aware of; I just didn't want to introduce possible problem sources, if there would be some more appropriate solution available :-) Regards, Vlasta -------------- next part -------------- An HTML attachment was scrubbed... URL: From diresu at web.de Tue Apr 8 04:31:24 2008 From: diresu at web.de (Dietrich Bollmann) Date: Tue, 08 Apr 2008 17:31:24 +0900 Subject: segmentation fault when executing PyImport_ImportModule("sys") Message-ID: <1207643484.845.6.camel@pippi.pippi> Hi, Since some time I get the following segmentation fault in an application which used to work fine until recently. I made a backtrace but couldn't find the reason for the segmentaion fault until now. In the hope that somebody might have encountered a similar problem or does understand the backtrace better than me and can explain it I posted the backtrace here... At the end of the backtrace I appended some more context concerning the involved code. Thanks for your help :) Dietrich Here comes the backtrace: ---- Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb046ab90 (LWP 9854)] threadstate_getframe (self=0xb7e8a889) at ../Python/pystate.c:154 154 ../Python/pystate.c: No such file or directory. in ../Python/pystate.c (gdb) bt full #0 threadstate_getframe (self=0xb7e8a889) at ../Python/pystate.c:154 No locals. #1 0xb7e8a897 in PyEval_GetGlobals () at ../Python/ceval.c:3340 current_frame = #2 0xb7eaeb67 in PyImport_Import (module_name=0xb7119480) at ../Python/import.c:2400 globals = import = builtins = r = silly_list = (PyObject *) 0xb738fb0c builtins_str = (PyObject *) 0xb7391c50 import_str = (PyObject *) 0xb7391fc0 #3 0xb7eaede5 in PyImport_ImportModule (name=0x901504b "sys") at ../Python/import.c:1903 pname = (PyObject *) 0xb7119480 result = (PyObject *) 0x0 #4 0x08996c9f in py_stdouterr_buffer_new () at source/blender/commandport/blender/src/py_stdouterr_buffer.c:75 buffer = (py_stdouterr_buffer) 0x94fd428 func_StringIO = (PyObject *) 0x9152a48 args_StringIO = (PyObject *) 0x0 #5 0x089967e1 in bcp_blender_handler_new () at source/blender/commandport/blender/src/bcp_blender.c:130 handler = (bcp_blender_handler) 0x9810420 #6 0x08998db3 in bcp_handle_client (client_socket=8) at source/blender/commandport/blender/src/bcp_handle_client.c:73 debug = 0 debug3 = 0 debug4 = 0 message_handler = (message_handler) 0x97eba10 blender_handler = (bcp_blender_handler) 0x0 command = 0x0 result = 0x9152a48 "%G?%@016\025\th%G??%@@\\%G?%@022v#\b \"v#\b%G??%@v#\bRv#\bbv#\brv#\b\202v#\b\222v#\b%G?%@v#\b%G?%@v#\b` \032%G?%@020\026%G???%@#\b%G?%@#\b\002w#\b\022w# \b\"w#\b2w#\bBw#\bRw#\bbw#\brw#\b\202w#\b\222w#\b%G?%@w#\b%G?%@w# \bp#p%G??%@#\b" package_number = -1216545219 #7 0x08998d60 in bcp_client_thread (args=0x0) at source/blender/commandport/blender/src/bcp_server.c:164 targs = (struct bcp_client_thread_args *) 0x0 client_socket = 8 client_thread = 2957421456 #8 0xb76b04fb in start_thread () from /lib/i686/cmov/libpthread.so.0 No symbol table info available. #9 0xb77c2d7e in clone () from /lib/i686/cmov/libc.so.6 No symbol table info available. (gdb) q The program is running. Exit anyway? (y or n) y --- and here some informations about its context: Python-2.4.4/Python/ceval.c line 3340: PyFrameObject *current_frame = PyEval_GetFrame(); context: --- PyObject * PyEval_GetGlobals(void) { PyFrameObject *current_frame = PyEval_GetFrame(); if (current_frame == NULL) return NULL; else return current_frame->f_globals; } --- Python-2.4.4/Python/pystate.c lign 154: { context: --- /* Default implementation for _PyThreadState_GetFrame */ static struct _frame * threadstate_getframe(PyThreadState *self) { return self->frame; } --- Python-2.4.4/Python/import.c lign 2400: globals = PyEval_GetGlobals(); context: --- PyObject * PyImport_Import(PyObject *module_name) { ... /* Get the builtins from current globals */ globals = PyEval_GetGlobals(); if (globals != NULL) { Py_INCREF(globals); builtins = PyObject_GetItem(globals, builtins_str); if (builtins == NULL) goto err; } ... } --- Python-2.4.4/Python/import.c lign 1903: result = PyImport_Import(pname); context: --- PyObject * PyImport_ImportModule(char *name) { PyObject *pname; PyObject *result; pname = PyString_FromString(name); if (pname == NULL) return NULL; result = PyImport_Import(pname); Py_DECREF(pname); return result; } --- source/blender/commandport/blender/src/py_stdouterr_buffer.c lign 75: buffer->mod_sys = PyImport_ImportModule("sys"); context: --- /** Make a new python io buffer. */ py_stdouterr_buffer py_stdouterr_buffer_new() { py_stdouterr_buffer buffer; buffer = (py_stdouterr_buffer) malloc(sizeof(py_stdouterr_buffer_struct)); if (buffer == NULL) { fprintf(stderr, "Couldn't allocate memory for new py_stdouterr_buffer! \n"); exit(ERROR_MEMORY); } buffer->mod_sys = PyImport_ImportModule("sys"); buffer->mod_cStringIO = PyImport_ImportModule("cStringIO"); /* store stdout and stderr */ buffer->stdout_obj = PyObject_GetAttrString(buffer->mod_sys, "stdout"); buffer->stderr_obj = PyObject_GetAttrString(buffer->mod_sys, "stderr"); /* make new string buffer for stdout and stderr */ PyObject *func_StringIO, *args_StringIO; func_StringIO = PyObject_GetAttrString(buffer->mod_cStringIO, "StringIO"); args_StringIO = Py_BuildValue("()"); buffer->outbuf_obj = PyEval_CallObject(func_StringIO, args_StringIO); buffer->errbuf_obj = PyEval_CallObject(func_StringIO, args_StringIO); Py_DECREF(args_StringIO); Py_DECREF(func_StringIO); return buffer; } --- From balta96428 at gmail.com Wed Apr 23 05:55:58 2008 From: balta96428 at gmail.com (balta96428 at gmail.com) Date: Wed, 23 Apr 2008 02:55:58 -0700 (PDT) Subject: pinnacle studio keygen Message-ID: <78dc86dc-fc77-44b4-b61d-ce14996075b7@m44g2000hsc.googlegroups.com> pinnacle studio keygen http://cracks.12w.net F R E E C R A C K S From __peter__ at web.de Wed Apr 9 03:31:06 2008 From: __peter__ at web.de (Peter Otten) Date: Wed, 09 Apr 2008 09:31:06 +0200 Subject: Sorting a List of Objects by an Attribute of the Objects Case-Insensitively References: <736fefbd-510f-40e9-8342-32b69a1a0c2a@t12g2000prg.googlegroups.com> <0912a817-2cdc-4a19-83d2-1d8befed4f4b@24g2000hsh.googlegroups.com> Message-ID: Paddy wrote: > On Apr 9, 4:04 am, Jason wrote: >> Hi folks-- >> >> Basically, I have a pressing need for a combination of 5.2 "Sorting a >> List of Strings Case-Insensitively" & 5.3 "Sorting a List of Objects >> by an Attribute of the Objects" from the Python Cookbook. >> >> My first guess isn't working: >> >> import operator >> def sort_by_attr(seq, attr): >> key=operator.attrgetter(attr) >> key=str.lower >> return sorted(seq, key) >> >> ...would much appreciate any guidance! > > HiJason, > Try key= lambda x: x.attr.lower() > The above should calculate the key only once for the items to be > sorted rather than using cmp which calculates more than that. A key func is indeed preferable over cmp. Here is a working example: >>> import operator >>> class A(object): ... def __init__(self, name, value): ... self.name = name ... self.value = value ... def __repr__(self): ... return "%s|%s" % (self.name, self.value) ... >>> items = [A("a", "z"), A("C", "Y"), A("b", "x")] >>> items [a|z, C|Y, b|x] >>> def sorted_by_attr_icase(items, attrname): ... get = operator.attrgetter(attrname) ... return sorted(items, key=lambda item: get(item).lower()) ... >>> sorted_by_attr_icase(items, "name") [a|z, b|x, C|Y] >>> sorted_by_attr_icase(items, "value") [b|x, C|Y, a|z] Peter From tjreedy at udel.edu Thu Apr 3 17:24:25 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 3 Apr 2008 17:24:25 -0400 Subject: python bisect questions References: <6bb6927b-f553-40db-a142-2ce86b9e819f@q27g2000prf.googlegroups.com> Message-ID: wrote in message news:6bb6927b-f553-40db-a142-2ce86b9e819f at q27g2000prf.googlegroups.com... |I am week on functional programming, and having hard time | understanding this: | | class myPriorityQueue: | def __init__(self, f=lamda x:x): | self.A = [] | self.f = f | | def append(self, item) | bisect.insort(self.A, (self.f(item), item)) | ............ | | now I know we are inserting items(user defined type objects) in list A | base on sorting order provided by function A. | but what I don't understand is bisect command | what does bisect.insort(self.A, (self.f(item), item)) doing The snippet is missing 'import bisect'. The module is documented in the Lib Ref. Or, in the interpreter, help(bisect.insort) redirects you to help(bisect.insort_right), which will answer your question. | isn't it is returning truple of (self.f(item), item)). no, see doc | why it is not | biset.insort(self.A, item) | A.sort(f) Efficiency, given that self.A is already sorted. tjr From bruno.desthuilliers at gmail.com Sun Apr 20 14:54:56 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Sun, 20 Apr 2008 11:54:56 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: <23254d9a-ceca-453a-a984-4ce457ed12b2@59g2000hsb.googlegroups.com> On 20 avr, 17:35, Eric Wertman wrote: > I was considering putting together a proposal for an alternate block > syntax for python, and I figured I'd post it here and see what the > general reactions are. I did some searching, and while I found a lot > of tab vs space debates, I didn't see anything like what I'm thinking > of, so forgive me if this is a very dead horse. > > Generally speaking, I like the current block scheme just fine. I use > python on a daily basis for system administration and text parsing > tasks, and it works great for me. > > From time to time, though, I find myself needing a language for server- > side includes in web pages. Because of the need to indent (and > terminate indents), python seems an awkward choice for this, and it's > easy for me to see why php and perl are more popular choices for this > kind of task. Perhaps this is just my perception though. The server-page scheme has long shown it's limitations and quirks - mostly, you end up mixing application logic and presentation logic. Even PHP programmers are slowly taking the MVC route. > I feel that including some optional means to block code would be a big > step in getting wider adoption of the language in web development and > in general. I do understand though, that the current strict indenting > is part of the core of the language, so... thoughts? Python Server Page packages are nothing new, and didn't help making Python more popular for web developpement. MVC frameworks like Django, Pylons, Turbogears or web.py seems to draw way more attention, and we start to see PHP coders switching to Django - which is the one with the IMHO weakest templating language. If you're looking for a templating system with Python syntax support, you may want to take a look at Cheetah and (my favourite one) Mako. Mako is the default template system for Pylons, and IIRC web.py supports Cheetah (warning: never used web.py, and haven't followed recent dev, so you'd better check by yourself). HTH From johnjsal at gmailNOSPAM.com Mon Apr 21 21:45:53 2008 From: johnjsal at gmailNOSPAM.com (John Salerno) Date: Mon, 21 Apr 2008 21:45:53 -0400 Subject: Lists: why is this behavior different for index and slice assignments? Message-ID: <480d435b$0$11643$607ed4bc@cv.net> Hey all. I've decided I let my Python skills (minor though they were) slip away so I started reading the new edition of Learning Python to brush up. I just read about lists again and I'm wondering if someone could explain what's going on under the hood that makes index and slice assignments behave differently when assigning an empty list. For example: >>> L = [1, 2, 3, 4, 5] >>> L[0:2] = [] >>> L [3, 4, 5] >>> L = [1, 2, 3, 4, 5] >>> L[0] = [] >>> L [[], 2, 3, 4, 5] So the question is, when you assign an empty list to an index, why does it insert an empty list, but when you assign an empty list to a slice, it simply deletes the slice? Thanks! From nick at craig-wood.com Fri Apr 25 08:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Fri, 25 Apr 2008 07:30:03 -0500 Subject: function that accepts any amount of arguments? References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> Message-ID: Steve Holden wrote: > Ken wrote: > > "Steve Holden" wrote in message > [...] > >> def mean(*x): > >> total = 0.0 > >> for v in x: > >> total += v > >> return v/len(x) > >> > > > > think you want total/len(x) in return statement > > > Yes indeed, how glad I am I wrote "untested". I clearly wasn't pair > programming when I wrote this post ;-) Posting to comp.lang.python is pair programming with the entire internet ;-) -- Nick Craig-Wood -- http://www.craig-wood.com/nick From code at pizzashack.org Wed Apr 2 11:50:51 2008 From: code at pizzashack.org (Derek Martin) Date: Wed, 2 Apr 2008 11:50:51 -0400 Subject: Manipulate Large Binary Files In-Reply-To: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> Message-ID: <20080402155051.GB22737@dragontoe.org> On Wed, Apr 02, 2008 at 10:59:57AM -0400, Derek Tracy wrote: > I generated code that works wonderfully for files under 2Gb in size > but the majority of the files I am dealing with are over the 2Gb > limit > > ary = array.array('H', INPUT.read()) You're trying to read the file all at once. You need to break your reads up into smaller chunks, in a loop. You're essentially trying to store more data in memory than your OS can actually access in a single process... Something like this (off the top of my head, I may have overlooked some detail, but it should at least illustrate the idea): # read a meg at a time buffsize = 1048576 while true: buff = INPUT.read(buffsize) OUTPUT.write(buff) if len(buff) != buffsize: break -- Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0x81CFE75D -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available URL: From bruno.desthuilliers at gmail.com Thu Apr 24 15:12:06 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Thu, 24 Apr 2008 12:12:06 -0700 (PDT) Subject: function that accepts any amount of arguments? References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> <4810724a$0$23390$426a74cc@news.free.fr> <63ac69bf-9f6d-42bd-8e6e-5b3b17ec7c69@z72g2000hsb.googlegroups.com> Message-ID: On 24 avr, 14:28, malkarouri wrote: > On Apr 24, 12:43 pm, Bruno Desthuilliers wrote: > > [...] > > > Not quite sure what's the best thing to do in the second case - raise a > > ValueError if args is empty, or silently return 0.0 - but I'd tend to > > choose the first solution (Python's Zen, verses 9-11). > > What's wrong with raising ZeroDivisionError (not stopping the > exception in the first place)? Because - from a semantic POV - the real error is not that you're trying to divide zero by zero, but that you failed to pass any argument. FWIW, I'd personnaly write avg as taking a sequence - ie, not using varargs - in which case calling it without arguments would a TypeError (so BTW please s/Value/Type/ in my previous post). From rridge at caffeine.csclub.uwaterloo.ca Fri Apr 18 19:55:32 2008 From: rridge at caffeine.csclub.uwaterloo.ca (Ross Ridge) Date: Fri, 18 Apr 2008 19:55:32 -0400 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> Message-ID: George Sakkis wrote: >You'd better use a more precise timing method than finger counting, >such as timeit. Twice as fast is probably a gross overestimation; on >my box (Python 2.5, WinXP) avoiding unpack is around 10% and 40% >faster from Ross's and Grant's method, respectively: ... >def from3Bytes_ross(s): > return unpack(">l", s + "\0")[0] >> 8 If you have Python 2.5, here's a faster version: from struct import * unpack_i32be = Struct(">l").unpack def from3Bytes_ross2(s): return unpack_i32be(s + "\0")[0] >> 8 Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] rridge at csclub.uwaterloo.ca -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // From bruno.desthuilliers at gmail.com Wed Apr 2 15:33:43 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 12:33:43 -0700 (PDT) Subject: class / module introspection? References: <3c3f09df-08cb-4309-a870-6b12a813a8af@u36g2000prf.googlegroups.com> <0f14a289-55ef-49e5-b650-60f7aca371ad@i36g2000prf.googlegroups.com> Message-ID: <85761ed1-afe8-48cc-8c6d-73183e6692a9@i7g2000prf.googlegroups.com> On 2 avr, 21:07, Brian Munroe wrote: > On Apr 2, 11:04 am, "bruno.desthuilli... at gmail.com" > > wrote: > > > More seriously: the answer is in the doc.http://www.python.org/doc/2.3.5/lib/built-in-funcs.html > > > read about the __import__ function, experiment in your interactive > > python shell, and you should be done in a couple minutes. > > Well, If I understand the docs correctly, that would work great if > backends/ was a module and not a package? Not necessarily. > I need to keep backends/ > system1/ and backends/system2 as separate directory structures to make > things fairly isolated from each other (for neatness sake) > > Currently I'm building the backends/__init__.py __all__ list > dynamically, such as: > > backends/__init__.py > -------------------- > > import os > > __all__ = [] > > for module in os.listdir(__path__[0]): > if not module.startswith("__"): > __all__.append(module) Why not do the import here, so you store a real module instead of a name ? ie (not tested): for module_name in os.listdir(__path__[0]): if not module_name.startswith("__"): __all__.append(__import__(module_name, globals(), locals())) My 2 cents... From nigamreetesh84 at gmail.com Wed Apr 16 03:53:01 2008 From: nigamreetesh84 at gmail.com (reetesh nigam) Date: Wed, 16 Apr 2008 00:53:01 -0700 (PDT) Subject: how tirbo gears work? Message-ID: <53db8d68-23d4-4430-b7a8-49bca0ff4df7@i36g2000prf.googlegroups.com> hi everone, 1:- i want to know, how to turbo gears code works. 2:- i want to write code on html with the help of turbo gears From sjdevnull at yahoo.com Sat Apr 19 16:29:21 2008 From: sjdevnull at yahoo.com (sjdevnull at yahoo.com) Date: Sat, 19 Apr 2008 13:29:21 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <48074f58$0$4916$e4fe514c@dreader32.news.xs4all.nl> <6002cb46-f48a-421d-a4ff-5b23bf2f9d77@2g2000hsn.googlegroups.com> <39fd7905-4835-43bb-928b-82622ed628c1@m3g2000hsc.googlegroups.com> Message-ID: On Apr 18, 9:29 pm, sturlamolden wrote: > On 18 Apr, 21:28, "sjdevn... at yahoo.com" wrote: > > > Passing a NULL SectionHandle to NTCreateProcess/CreateProcessEx > > results in a fork-style copy-on-write duplicate of the current process. > > I know about NtCreateProcess and ZwCreateProcess, but they just create > an empty process - no context, no thread(s), no DLLs loaded, etc. > There is even an example code of how to implement fork() with > ZwCreateProcess in Nebbet's book on NT kernel internals, but > apparently it doesn't work quite well. It works fine for a copy-on-write process creation. It doesn't work 100% compatibly to fork. Nebbet is the best reference out there on the method. FWIW, NT's POSIX subsytem fork() uses (or used to use) the NULL SectionHandle method and was POSIX certified, so it's certainly possible. > Searching with Google, I find several claims that there is a > "CreateProcessEx" Yeah my bad, I meant zwCreateProcess. It's been almost a decade now since I used it. From sjmachin at lexicon.net Thu Apr 17 19:27:42 2008 From: sjmachin at lexicon.net (John Machin) Date: Thu, 17 Apr 2008 23:27:42 GMT Subject: py3k s***s In-Reply-To: <66q33cF2krjf2U1@mid.uni-berlin.de> References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <66q33cF2krjf2U1@mid.uni-berlin.de> Message-ID: <4807dceb$1@news.mel.dft.com.au> Diez B. Roggisch wrote: >> And I have been benefiting from Python in general, so far. Thanks, >> community. >> >> But now... I'll probably stop posting here for now, & I may stop other >> things too. >> >> Just my 2c. > > You know what I was just wondering about? All these C-written > cross-platform libraries (which Python users benefit from, most probably > including evven you) that run on different unixes & windows, which are a > much greater diversity to handle than the not-even-yet-settled > differences between Py3K & 2.x. How the heck do they do that? > > Oh, and these dreaded 64 bit processors, possibly with multi-cores, > which need changes in code as well, to be utilized to their power. > > But then, these guys most probably don't whine about diversity and > constant change, and cry out useless threats to people who probably > can't care less. > > Fare well, if you must. But getting mad over something which impact you > can't even judge right now is childish. Nothing else. > At the start of this thread I was pondering the possible meaning of the verb "to sverk". Thanks for the exposition, Diez. From stefan_ml at behnel.de Fri Apr 25 18:17:55 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sat, 26 Apr 2008 00:17:55 +0200 Subject: is there a python equivalent for this tool? In-Reply-To: References: Message-ID: <48125893.3000202@behnel.de> Jorge Vargas wrote: > Dear python users, do you know of a tool like this that is written in python? > > http://code.google.com/p/css-redundancy-checker/ > > in case you where wondering I just don't want to have the ruby > dependency on my python proyects. This comes to mind: http://code.google.com/p/cssutils/ Not sure if it does what you want, though. If not, it should be quite trivial to implement what you ask using this: http://codespeak.net/lxml/cssselect.html Algorithm: for each CSS selector in the stylesheet, check if it matches an element in the HTML tree. If not, remove it. Stefan From watches0759 at global-replica-watch.com Wed Apr 23 01:16:44 2008 From: watches0759 at global-replica-watch.com (watches0759 at global-replica-watch.com) Date: Tue, 22 Apr 2008 22:16:44 -0700 (PDT) Subject: Designer Louis Vuitton Taiga Computer Case Odessa - Green M30834 Green Handbags, Replica, Fake Message-ID: <55f924ca-60a8-422c-b56e-889964e53f2e@i76g2000hsf.googlegroups.com> Designer Louis Vuitton Taiga Computer Case Odessa - Green M30834 Green Handbags, Replica, Fake Our Louis Vuitton Taiga Computer Case Odessa - Green M30834 Green is a vibrant mix of style and pleasure, offering you exact copies of the original handbags. If you need a cool and most welcomed change to your style, a change you certainly deserve, choose one of the many bags ReplicasHandbag.com offers at a great price. Louis Vuitton Taiga Computer Case Odessa - Green Link : http://www.replicashandbag.com/Louis-Vuitton-M30834-Green.html Brand : Louis Vuitton ( http://www.replicashandbag.com/Louis-Vuitton-Handbags.html ) Model : M30834 Green Sale Price : $ 240.00 Louis Vuitton Taiga Computer Case Odessa - Green Details : Classical green color Louis Vuitton leather bagIt has adjustable green color strap with LV name on itWrap around silver color zipper closure Inside it has two strap to keep your things on holdAlso this bag comes with a small bag for your small thingsComes with serial numbers, authenticity card, dust bag, and care booklet SIZE: 14.5" x 12.2" x 2.8" You may find the most affordable Designer Louis Vuitton Handbags on our website replicashandbag.com while high quality can be guaranteed. Our Replica Louis Vuitton Bags is made with special care to reach the level of an original one. Here you will find luxury items are no longer something you ever hesitate going for. To meet your expectation, we only provide Louis Vuitton Fake Handbags that is perfectly imitated, featuring the slight details of originals. All of our replica handbags are shipped via EMS to worldwide. Normally it takes 3days to prepare the fake bags you ordered and 5-10days to transmit depending on the different destination.We pay for the free shipping cost for total quantity over 20 pcs. The EMS tracking NO. will be sent by email when an order is shipped from our warehouse. No more other charges from replicashandbag.com such as the tax. If you have any other questions please check our other pages or feel free to email us by sales at replicashandbag.com. The Same Replica Louis Vuitton Handbags Series : Louis Vuitton Taiga Dersou -Dark Coffee 30168coffee : http://www.replicashandbag.com/Louis-Vuitton-30168coffee.html Louis Vuitton Taiga Dimitri - Black 32462black : http://www.replicashandbag.com/Louis-Vuitton-32462black.html Louis Vuitton Taiga Dimitri - Black 30902black : http://www.replicashandbag.com/Louis-Vuitton-30902black.html Louis Vuitton Taiga Dimitri - Coffee M30918coffee : http://www.replicashandbag.com/Louis-Vuitton-M30918coffee.html Louis vuitton Taiga Dimitri -Coffee 32468coffee : http://www.replicashandbag.com/Louis-Vuitton-32468coffee.html Louis Vuitton Taiga Igor - Dark Coffee 92532coffee : http://www.replicashandbag.com/Louis-Vuitton-92532coffee.html Louis Vuitton Taiga Kasbek GM - Black 31012black : http://www.replicashandbag.com/Louis-Vuitton-31012black.html Louis vuitton Taiga Kasbek GM - Dark Purple 31012purple : http://www.replicashandbag.com/Louis-Vuitton-31012purple.html Louis Vuitton Taiga Kurgan Clutch - Black 30892black : http://www.replicashandbag.com/Louis-Vuitton-30892black.html Louis Vuitton Taiga Kurgan Clutch -Dark Purple 30892purple : http://www.replicashandbag.com/Louis-Vuitton-30892purple.html Designer Louis Vuitton Taiga Computer Case Odessa - Green M30834 Green Handbags, Replica, Fake From bruno.42.desthuilliers at websiteburo.invalid Mon Apr 28 09:26:20 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Mon, 28 Apr 2008 15:26:20 +0200 Subject: function that accepts any amount of arguments? In-Reply-To: References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> <4810724a$0$23390$426a74cc@news.free.fr> <63ac69bf-9f6d-42bd-8e6e-5b3b17ec7c69@z72g2000hsb.googlegroups.com> Message-ID: <4815d07b$0$5405$426a74cc@news.free.fr> Lie a ?crit : > On Apr 25, 2:12 am, "bruno.desthuilli... at gmail.com" > wrote: (...) >> FWIW, I'd personnaly write avg as taking a sequence - ie, >> not using varargs - in which case calling it without arguments would a >> TypeError (so BTW please s/Value/Type/ in my previous post). > > The problem with passing it as a sequence is, if you want to call it, > you may have to wrestle with this odd looking code: > avg((3, 4, 6, 7)) > > rather than this, more natural code: > avg(3, 4, 6, 7) Possibly. Yet my experience is that, most of the time, such a function will be called with an already existing sequence, so the most common call scheme is res = avg(some_sequence) which is more natural than res = avg(*some_sequence) !-) > And FWIW, the OP asked if it is possible to pass variable amount of > arguments, avg is just a mere example of one where it could be used > not where it could be best used. Indeed - but that's not what I was commenting on. From diresu at web.de Tue Apr 22 11:12:47 2008 From: diresu at web.de (Dietrich Bollmann) Date: Wed, 23 Apr 2008 00:12:47 +0900 Subject: Error in Extending/Embedding FAQ, point 16: How do I tell "incomplete input" from "invalid input"? Message-ID: <1208877167.4557.37.camel@pippi.pippi> Hi, Both code examples from paragraph 16 from the Python Extending / Embedding FAQ - 'How do I tell "incomplete input" from "invalid input"?' - ( http://www.python.org/doc/faq/extending/#how-do-i-tell-incomplete-input-from-invalid-input ) do not work with the current state of Python anymore. In the second code example, the error message returned by Python is checked in order to differentiate errors caused by an incomplete input from other syntax errors: if (PyArg_ParseTuple (val, "sO", &msg, &obj) && !strcmp (msg, "unexpected EOF while parsing")) /* E_EOF */ In the current Python version there are more error messages indicating an incomplete Python input and I could make the code work for a while by adding the following strings to the condition: /* error messages indicating an incomplete input */ if (PyArg_ParseTuple(error, "sO", &message, &obj) && (!strcmp(message, "unexpected EOF while parsing") || !strcmp(message, "expected an indented block") || !strcmp(message, "EOF while scanning triple-quoted string") ) ) { /* E_EOF */ but recently there are also cases which generate error messages which are too general to be added to this list. The following code for example: >>> eins = [1, ... 2, ... 3] >>> is accepted without any problem by the Python shell. When using the code from the FAQ and entering it line by line ?already the second line causes a simple "invalid syntax" error: >>> eins = [1, ... 2, File "", line 2 2, ^ SyntaxError: invalid syntax which is to general to be integrated into the list of tested error messages as it might be caused also by code like: >>> one two File "", line 1 one two ^ SyntaxError: invalid syntax which generates an "invalid syntax" error even in the Python shell. I also tried the first code example of paragraph '16 How do I tell "incomplete input" from "invalid input"?' of the FAQ in order to see if it could be used to make the difference between syntax errors and incomplete code errors. But - as in the case before - the returned error code is E_SYNTAX (14 = Syntax error) and not E_EOF (11 = End Of File) as should be expected. Is there anybody who has an idea how to differentiate the first case from the second in order to mimic the behaviour of the Python shell from c code? If this shouldn't be possible lists split into different lines couldn't be accepted anymore or the feature of the Python shell to described in paragraph 16 of the faq: Sometimes you want to emulate the Python interactive interpreter's behavior, where it gives you a continuation prompt when the input is incomplete (e.g. you typed the start of an "if" statement or you didn't close your parentheses or triple string quotes), but it gives you a syntax error message immediately when the input is invalid. would have to be given up and every entered line of code would have to be terminated by an empty line before evaluation :( Thanks for any help, Dietrich From marli305nugent at gmail.com Sat Apr 26 09:47:55 2008 From: marli305nugent at gmail.com (marli305nugent at gmail.com) Date: Sat, 26 Apr 2008 06:47:55 -0700 (PDT) Subject: area council patch news Message-ID: <124fc461-fe1e-4b0a-8c2b-23903f082bdb@56g2000hsm.googlegroups.com> area council patch news http://cracks.00bp.com F R E E C R A C K S From nagle at animats.com Wed Apr 23 17:40:07 2008 From: nagle at animats.com (John Nagle) Date: Wed, 23 Apr 2008 14:40:07 -0700 Subject: Java or C++? In-Reply-To: References: Message-ID: <480fa9f4$0$34576$742ec2ed@news.sonic.net> Bob Martin wrote: > in 342367 20080414 074410 s0suk3 at gmail.com wrote: >> Hello, I was hoping to get some opinions on a subject. I've been >> programming Python for almost two years now. Recently I learned Perl, >> but frankly I'm not very comfortable with it. Now I want to move on >> two (sic) either Java or C++, but I'm not sure which. Which one do you think >> is a softer transition for a Python programmer? Which one do you think >> will educate me the best? > > C++ is for masochists. Go for Java. Definitely Java. And I have ten years of C++ experience. C++ is the only major language that has hiding without safety. That was a mistake. Perl is useful because it runs everywhere; you'll be able to run your Perl program on just about any commercial web hosting service. Other than that, there's not much good to be said for it. Java is a generally good language fighting to get out from under a mountain of mediocre libraries. John Nagle From BrianVanderburg2 at aim.com Thu Apr 3 20:57:56 2008 From: BrianVanderburg2 at aim.com (Brian Vanderburg II) Date: Thu, 03 Apr 2008 20:57:56 -0400 Subject: Is there an official way to add methods to an instance? Message-ID: <47F57D14.8030206@aim.com> I don't know if this is the correct place to send this question. I've checked out some ways to get this to work. I want to be able to add a new function to an instance of an object. I've tested two different methods that cause problems with 'deleting'/garbage collection (__del__ may never get called), but implemented one sort of hackishly maybe that works find. I'm wondering if there is more of an official way than mine. 1. import new import gc class A: def __del__(x): print "Deleting" def f(x): print x a = A() a.f = new.instancemethod(a,f) a.f() # This works del a # Not what is expected gc.collect() # Works, but __del__ does not get called 2. import gc def addmethod(self,func,name): def wrapper(*args,**kwargs): return func(self,*args,**kwargs) setattr(self,name,func) class A: def __del__(x): print "Deleting" def f(x): print x a = A() addmethod(a, f, "f") a.f() # Works as expected del a # nope gc.collect() # Still __del__ doesn't get called 3. Slightly hackish method, maybe some problems import gc import weakref def addmethod(self,func,name): # change the value of 'self' so wrapper.func_globals will reference the new value self = weakref.ref(self) def wrapper(*args,**kwargs): return func(self(),*args,**kwargs) setattr(self(),name,func) class A: def __del__(x): print "Deleting" def f(x): print x a = A() addmethod(a, f, "f") a.f() # Works as expected del a gc.collect() With this method 'del a' does the expected most of the time, and "Deleting" does get printed or when calling 'gc.collect()' it prints correctly. This seems the best approach so that when 'a' is no longer valid, the object can die instead of continuing to exitng because wrapper.func_globals still contains a reference, but seems very hackish an maybe problematic. I'm wondering if there is a better way? Brian Vanderburg II From hv at tbz-pariv.de Thu Apr 24 07:20:29 2008 From: hv at tbz-pariv.de (Thomas Guettler) Date: Thu, 24 Apr 2008 13:20:29 +0200 Subject: How to get inner exception traceback Message-ID: <67b8nuF2m1a1kU1@mid.individual.net> Hi, How can you get the traceback of the inner exception? try: try: import does_not_exit except ImportError: raise Exception("something wrong") except: ... Background: In Django some exceptions are caught and a new exception gets raised. Unfortunately the real error is hard to find. Sometimes I help myself and change (in this example) ImportError to e.g. IOError and then I can see the real root of the problem. But maybe there is a way to get the inner exception and its traceback. This could be displayed in the debug view. Thomas -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de From pscott at uwc.ac.za Mon Apr 21 02:21:35 2008 From: pscott at uwc.ac.za (Paul Scott) Date: Mon, 21 Apr 2008 08:21:35 +0200 Subject: Is massive spam coming from me on python lists? In-Reply-To: <480C2DC6.4050701@aim.com> References: <480C2DC6.4050701@aim.com> Message-ID: <1208758895.14026.2.camel@paul-laptop> On Mon, 2008-04-21 at 02:01 -0400, Brian Vanderburg II wrote: > I've recently gotten more than too many spam messages and all say > Sender: python-list-bounces+my=email.address at python.org. I'm wondering > if my mail list registration is now being used to spam myself and > others. If so, sorry, but I'm not the one sending messages if other are > getting them even though Sender seems to include my address (I'm not > sure about mail headers so I don't know how From: is different than > Sender:) Anyway, it seems to be a bunch of spam emails about cracks and > stuff. I think all of the spam is coming from Google Groups. --Paul -------------- next part -------------- All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm From brian.e.munroe at gmail.com Wed Apr 2 15:07:46 2008 From: brian.e.munroe at gmail.com (Brian Munroe) Date: Wed, 2 Apr 2008 12:07:46 -0700 (PDT) Subject: class / module introspection? References: <3c3f09df-08cb-4309-a870-6b12a813a8af@u36g2000prf.googlegroups.com> Message-ID: <0f14a289-55ef-49e5-b650-60f7aca371ad@i36g2000prf.googlegroups.com> On Apr 2, 11:04 am, "bruno.desthuilli... at gmail.com" wrote: > > More seriously: the answer is in the doc.http://www.python.org/doc/2.3.5/lib/built-in-funcs.html > > read about the __import__ function, experiment in your interactive > python shell, and you should be done in a couple minutes. Well, If I understand the docs correctly, that would work great if backends/ was a module and not a package? I need to keep backends/ system1/ and backends/system2 as separate directory structures to make things fairly isolated from each other (for neatness sake) Currently I'm building the backends/__init__.py __all__ list dynamically, such as: backends/__init__.py -------------------- import os __all__ = [] for module in os.listdir(__path__[0]): if not module.startswith("__"): __all__.append(module) then from my main application, I can do the following main.py ------- import backends print backends.__all__ This gives me ['system1','system2'] - which I can then use __import__ on. -- brian From pyth0nc0d3r at gmail.com Wed Apr 9 07:43:52 2008 From: pyth0nc0d3r at gmail.com (Lamonte Harris) Date: Wed, 9 Apr 2008 06:43:52 -0500 Subject: ProxyHandler doesn't completly hide your identity? Message-ID: Is it still possible to detect who you are under a proxy when using urllib2? -------------- next part -------------- An HTML attachment was scrubbed... URL: From bj_666 at gmx.net Thu Apr 10 12:03:39 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 10 Apr 2008 16:03:39 GMT Subject: tkinter, overwrite Label-text? References: Message-ID: <666s2qF2il38sU1@mid.uni-berlin.de> On Thu, 10 Apr 2008 07:37:08 -0700, skanemupp wrote: > i know how to do this already. the problem is i want the text to stay > in the windowa nd not start overwriting "Answer:". Then don't use `place()` but let Tkinter handle the layout with the pack and/or grid layout manager. GUIs with `place()` are a bad idea because the GUI may look odd or is even unusable on other peoples computers with other screen resolutions, fonts, and font sizes. Ciao, Marc 'BlackJack' Rintsch From MartinRinehart at gmail.com Thu Apr 10 11:49:07 2008 From: MartinRinehart at gmail.com (MartinRinehart at gmail.com) Date: Thu, 10 Apr 2008 08:49:07 -0700 (PDT) Subject: Python conventions Message-ID: I assembled a good conventions set for Java. View it at http://www.martinrinehart.com/articles/code-conventions.html (is that better, Steve?) It followed a logical organization; it was built from four other extensive (if not well-organized) convention sets and it scrupulously avoided injecting my own biases. Where there were disagreements, they were noted and the opposing viewpoints explained. I'm appointing myself project secretary of a similar effort for Python, until we can find someone better qualified (Python experience pre-dating my late '07 start would be better qualified). The secretary's job is to ask questions and correctly record answers. First question: global (e.g., what language for comments) package module class methods data function statement expression variable Is this a good outer-level organization? For each topic, cover: documentation naming convention(s) format Second question: are the above the items we cover for each topic? Others? From wizzardx at gmail.com Wed Apr 30 14:10:19 2008 From: wizzardx at gmail.com (David) Date: Wed, 30 Apr 2008 20:10:19 +0200 Subject: Python -v import behavior In-Reply-To: <357b87b40804300942v371152b0u9dcc6d8b8d0a3b32@mail.gmail.com> References: <357b87b40804300942v371152b0u9dcc6d8b8d0a3b32@mail.gmail.com> Message-ID: <18c1e6480804301110o1aad3766jb7a286147920c258@mail.gmail.com> On Wed, Apr 30, 2008 at 6:42 PM, Sean Ryan wrote: > Hi all, > (A similar question was posted by a colleague, but did not appear to reach > comp.lang.python or this list). > > I am wondering if the -v option causes the python application to be more > tolerant to module import warnings and / or errors. > > The reason is that a module is failing to import correctly (generating an > ImportError exception). Examining this closer we re-ran the script using > the -v option. to find that "Unsatisfied symbol" errors we being displayed > during import (cx_Oracle 4.3.1, python 2.5.1, HP-UX 11, oracle 9.2). > However, the module is usable from the python prompt (when using -v) > displayed, i.e. dir (cx_Oracle) works correctly, as does database > interaction. Without the -v option the script is halted due to the > ImportError exception. > > My questions are: > 1. Is there a way to mimic the seemingly more tolerant import behavior of > python -v without producing the verbose output ? > 2. Is the behavior described above expected and documented ? > If -v makes a difference, it is most likely due to timing. The output to console slows down your app enough so that the ImportError doesn't get raised. Try piping output to a text file. Also experiment with the -u (unbuffered output) option. Another possibility is that the python binary that runs (when you launch with -v) is different to the one that the script normally runs with (see #! line at start of script). Also try adding the -v to the #! line instead of the command line. Something for you to try: Making a temporary copy of the project, and then cut out all the code except the import lines. See if that fails, then start commenting out imports until the error goes away. David. From bearophileHUGS at lycos.com Fri Apr 18 09:51:55 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Fri, 18 Apr 2008 06:51:55 -0700 (PDT) Subject: sampling without replacement References: <6017ea8d-6ee8-44ea-bdad-bf06299a9cd5@a23g2000hsc.googlegroups.com> Message-ID: <91f72a14-c344-4d69-93e0-083e4ec8c47b@f63g2000hsf.googlegroups.com> Alexy>But in Python it's very slow...< I'm the first one to say that CPython is slow, but almost any language is slow if you use such wrong algorithms like you do. There are many ways to solve your problem efficiently, one of such ways, among the simpler ones is to to not modify the original list: >>> from random import shuffle, seed >>> items = list("abcdefghijklm") >>> seed(10) >>> shuffle(items) >>> it_items = iter(items) >>> it_items.next() 'i' >>> it_items.next() 'd' >>> it_items.next() 'l' >>> it_items.next() 'b' >>> it_items.next() 'j' >>> it_items.next() 'a' >>> it_items.next() 'e' If you don't want to extract the same element twice across different runs of the program, then you may create a class like this: from random import shuffle, seed class Sampler(object): def __init__(self, items, init_seed=1): self.items = list(items) self.last = len(self.items) - 1 self.init_seed = init_seed seed(init_seed) shuffle(self.items) def __repr__(self): return repr(self.items[:self.last+1]) def next(self): if self.last < 0: raise StopIteration self.last -= 1 return self.items[self.last+1] def save(self, filename): pass # saves self.last and self.init_seed on disk samp = Sampler("abcdefghijklm") print samp print samp.next() print samp.next() print samp.next() That class code is raw, you may want to improve it in some ways. Bye, bearophile From kyosohma at gmail.com Sat Apr 26 23:42:56 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Sat, 26 Apr 2008 20:42:56 -0700 (PDT) Subject: Desktop notifications on Windows References: <0db266c1-50ad-4e01-b508-57c9a8febb4b@a22g2000hsc.googlegroups.com> <60516dea-2c40-47d2-b816-8d9169399d86@c58g2000hsc.googlegroups.com> Message-ID: <50466177-f999-4952-9123-57b9c3f9b6ec@f63g2000hsf.googlegroups.com> On Apr 26, 4:08?pm, WindPower wrote: > On Apr 26, 4:52 am, David wrote: > > > On Sat, Apr 26, 2008 at 4:41 AM, ? wrote: > > > I'm looking for a way to implement desktop notifications (much like an > > > ?instant messaging program or a mail notifier) within my Python > > > ?application, on Windows only (no Gtk/Galago, please). I need no more > > > ?than a simple text-based notification, which should be clickable and > > > ?have a timeout, nothing else. I do not want to use Windows's "balloon > > > ?tips", either. Any suggestions? > > > ?-- > > > You could use Tkinter, which comes with Python. > > The problem is that Tkinter cannot (I haven't looked at it in details, > so correct me if I'm wrong) create notifications the way I want them; > it can only create standard dialogs or top-level dialogs, both of > which steal the focus of other applications, while I want these > notifications not to interfere with anything (and possibly not be > displayed if an application is already running in fullscreen). wxPython can do this. They have a wx.PopupWindow that does this and comes with wxPython or you can use the more advanced custom Toasterbox widget that I found here: http://xoomer.alice.it/infinity77/main/freeware.html#toasterbox I've used both, but the latter gives more control of the "look & feel". Hope that helps! Mike From gnewsg at gmail.com Thu Apr 3 19:16:47 2008 From: gnewsg at gmail.com (Giampaolo Rodola') Date: Thu, 3 Apr 2008 16:16:47 -0700 (PDT) Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: On 2 Apr, 03:15, AK wrote: > Hello, > > I find that I learn easier when I go from specific examples to a more > general explanation of function's utility and I made a reference guide > that will eventually document all functions, classes and methods in > Python's Standard Library. For now, I covered about 20 most important > modules. I will be adding more modules and eventually I'll cover > everything. Here's my progress so far, let me know if this is useful; > I'll be glad to hear comments/suggestions/etc: > > http://www.lightbird.net/py-by-example/ > > -- > ? -ak > ? ?Tobu |http://www.lightbird.net/tobu/| Freeform DB / Tagger / PIM Great idea! Thanks a lot for you work. --- Giampaolo http://code.google.com/p/pyftpdlib From enleverlesX.XmcX at XmclaveauX.com Tue Apr 8 12:02:01 2008 From: enleverlesX.XmcX at XmclaveauX.com (Méta-MCI (MVP)) Date: Tue, 8 Apr 2008 18:02:01 +0200 Subject: List open files In-Reply-To: <47fb8d54$0$15068$426a74cc@news.free.fr> References: <47fb8d54$0$15068$426a74cc@news.free.fr> Message-ID: <47fb9789$0$881$ba4acef3@news.orange.fr> Salut ! Finalement, tu as obtenu plus de r?ponses sur le NG fran?ais. Comme quoi, la v?rit? n'est pas toujours ailleurs... @+ -- Michel Claveau From software at ginstrom.com Sun Apr 6 21:28:01 2008 From: software at ginstrom.com (Ryan Ginstrom) Date: Mon, 7 Apr 2008 10:28:01 +0900 Subject: ANN: pry unit testing framework In-Reply-To: <87prt2mq8l.fsf@benfinney.id.au> References: <87zlscx5lt.fsf@benfinney.id.au><4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com><20080405082605.GA14042@nullcube.com><20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> Message-ID: <1e1001c8984e$9ef29c30$0203a8c0@MOUSE> > On Behalf Of Ben Finney > Aldo Cortesi writes: > > Some day I might experiment with extending Pry to gather and run > > doctests and unittests. At this stage, however, I don't believe the > > (significant) effort would be worth it. > > That's very unfortunate. Until it plays better with others, I > don't believe the effort of using this package will be worth it. I also don't want to be negative, since Aldo obviously has put a lot of work into this framework. But since it's not compatible with other frameworks, it will mainly be attractive to people not writing unit tests now, which means they: 1) Think writing unit tests is too much of a hassle, or 2) Ae new (Python) programmers In either case, the key requirement of the framework would be ease of use, but Pry's selling point is actually its sophisticated options. Thus it appears that the potential user base is rather small... Regards, Ryan Ginstrom From steve at holdenweb.com Wed Apr 9 09:58:32 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 09:58:32 -0400 Subject: CPython VM & byte code resources wanted In-Reply-To: References: <6622srF2e32hbU1@mid.individual.net> <66238qF2h0kfqU1@mid.individual.net> Message-ID: <47FCCB88.8090203@holdenweb.com> Steve Holden wrote: > Aaron Gray wrote: >> "Aaron Gray" wrote in message >> news:6622srF2e32hbU1 at mid.individual.net... >>> Hi, >>> >>> I am looking to study the CPython source code, but I cannot seem to find >>> the VM code. >> Found it :) >> >> Python/ceval.c >> >>> Also is there any where a detailed list of the opcodes ? >> Still could do with an opcodes chart. >> > Be sure and post it on the Wiki when you finish it ;-) > I was being a little too flip here. If you look in the "dis" module I would imagine you will find what you seek, given that it's capable of disassembling the byte codes -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bob.martin at excite.com Tue Apr 15 03:40:04 2008 From: bob.martin at excite.com (Bob Martin) Date: Tue, 15 Apr 2008 07:40:04 GMT Subject: Java or C++? References: Message-ID: in 342436 20080414 160208 =?UTF-8?B?R3J6ZWdvcnogU8WCb2Rrb3dpY3o=?= wrote: >> Hello, I was hoping to get some opinions on a subject. I've been >> programming Python for almost two years now. Recently I learned Perl, >> but frankly I'm not very comfortable with it. Now I want to move on >> two either Java or C++, but I'm not sure which. Which one do you think >> is a softer transition for a Python programmer? Which one do you think >> will educate me the best? >> >I can't say from personal experience (it was C, C++, then Python for me) >but I think you'll find Java very annoying, especially if you value >Python for elegance. Both C++ and Java have different philosophy than >Python, but C++ is better designed and more flexible. You must be joking - better designed? C++ was a botch to an already poor language. Personally I find Java very satisfying to write. From wuwei23 at gmail.com Tue Apr 1 21:02:51 2008 From: wuwei23 at gmail.com (alex23) Date: Tue, 1 Apr 2008 18:02:51 -0700 (PDT) Subject: troll poll References: <65eee6F2eg18jU1@mid.uni-berlin.de> Message-ID: <143a9f24-668e-4e30-a803-c272da27f3ff@s13g2000prd.googlegroups.com> On Apr 1, 11:15 pm, George Sakkis wrote: > Wow, thanks to this thread I discovered the Google Groups KillFile, a > firefox+greasemonkey killfile script (http://www.penney.org/ > ggkiller.html). Hope it works as advertised! That is awesome, thank you so much for posting this. The usual response to complaining about the lack of a killfile for Google Groups has been "use a decent client", but as I'm constantly moving between machines having a consistent app for usenet has more value to me. I maintain castironpi is far more lucid than others give him credit for, if you understand that the sole concept he is trying to communicate is how damn "clever" he is. On the plus side, he does give me a test target for this greasemonkey script :) Cheers George! - alex23 From carbanancizpo at gmail.com Fri Apr 18 16:54:58 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:54:58 -0700 (PDT) Subject: unreal tounament patch 451 Message-ID: unreal tounament patch 451 http://cracks.12w.net F R E E C R A C K S From robin at nibor.org Mon Apr 14 11:27:17 2008 From: robin at nibor.org (Robin Stocker) Date: Mon, 14 Apr 2008 17:27:17 +0200 Subject: [ANN] PyStructure: Structure and Dependency Analyser for Python Projects Message-ID: <480377D5.6090409@nibor.org> Hi Python developers, We are happy to announce our first release of PyStructure, a structure and dependency analyser for Python code (written in Java). It is now in a state where it can parse and analyse real-world projects (with limitations, see below) and show the results in Structure101g, a dependency visualiser. To try it out with your projects, download pystructure.zip from the following address and follow the instructions in the README file: http://pystructure.ifs.hsr.ch/release/ We are two students working on this as our bachelor thesis. The project page can be found at: http://pystructure.ifs.hsr.ch/ We are very eager to hear your feedback about our project. What do you think about the idea of a 'structural analyser' for a dynamic language like Python? Does it work for your project (probably not very well at the moment)? Cheers, Reto Sch?ttel Robin Stocker About PyStructure ----------------- Our project's goal is to develop a structural analyser for programs written in the Python programming language. The analyser should be able to parse an application's source code, analyse it and then generate a graph representing the internal structure of the project. As Python is a dynamic language most of the interesting details (i.e. type) are not known before the application is running. The analyser has to 'guess' the correct type by analysing the code base. The project is licensed under the LGPL (v2 or later), see the COPYING file. Current Limitations ------------------- Although the engine already supports a wide variety of cases it still lacks some very important features: - No support for inheritance Currently the engine ignores everything that involves inheritance. For example if a method is implemented in a base class it won't be found if it was called on an instance of a sub class. - Type of list/dict elements is not known The type of container elements cannot be determined yet. For projects which heavily rely on lists this means that a lot of types can't be determined. - Only little support for built-ins Only a few built-in operations are recognised. For example the type inference engine doesn't yet know that len("str") returns an integer. We are working on tackling these issues in the next two milestones and we hope to improve the accuracy of the engine significantly. Possible Applications --------------------- Our library (especially the type inferencer we use) might be interesting for other applications. For example: - Code completion and navigation in IDEs And it might improve the accuracy of tools which: - Detect unused/dead code - Look for possible bugs in code (like FindBugs for Java) - Do type checks and optimisations at compile time References ---------- - DDP: Demand-Driven Analysis with Goal Pruning by Lex Spoon http://www.lexspoon.org/ti/ - Headway Software http://www.headwaysoftware.com/ From tjreedy at udel.edu Mon Apr 14 00:04:14 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 14 Apr 2008 00:04:14 -0400 Subject: about the ';' References: <20080414033334.97C8B8C461@mail-in-12.arcor-online.net> Message-ID: "Penny Y." wrote in message news:20080414033334.97C8B8C461 at mail-in-12.arcor-online.net... |I saw many python programmers add a ';' at the end of each line. | As good style, should or should not we do coding with that? NOOOOOO....... Read PEP8 for one style guide (for new stdlib code). From steve at holdenweb.com Sat Apr 5 08:40:40 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 08:40:40 -0400 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> Message-ID: llothar wrote: > On 5 Apr., 15:48, Fredrik Lundh wrote: >> llothar wrote: >>> My question was: Why does setup.py generated sometimes a pyd and >>> sometimes a so file? >> setup.py picks an extension that happens to work on the platform you're >> running setup.py on. doing otherwise would be pretty pointless. >> >> > > Unfortunately as pointless as the answers i got so far. > Right, so you think people aren't trying to help you? Put your paranoia back in your pocket :-) > > Okay i try it one more time: > > I ship an application that compiles an python interpreter and > extension on a remote system. > It also needs to copy this created items around. So if i use setup.py > to create an > extension i need to know the file name of the generated file. > > Damned this is trivial and a fundamental question and it is not > documented anywhere. > > I have a clue at the moment that it might be ".so" when python is > compiled without shared library > and ".pyd" otherwise (configure option --enable-shared) . But this is > just a guess. Does anybody know? > > And by the way: I think this is a bug and should be fixed. If the > platform does allow renaming the > extension of a DLL (does HP/UX allow this?) it should always be > ".pyd" You display your ignorance here. The ".pyd" extension is used on Windows as an alternative to ".dll", but both are recognized as shared libraries. Personally I'm not really sure why they even chose to use ".pyd", which is confusing to most Windows users. In UNIX/Linux environments ".so" is the standard extension for a shared library. To depart from the platform standard would be unhelpful and confusing to the majority of users. It's know use telling us what you think: tell us instead the compelling reasons why your opinion is correct. Opinions, after all, are so cheap that everyone can have one. There are ways to build distributions of Python extensions (modules or packages involving binary code from languages like C or C++), but you will want to understand a bit more about computing in general (and work on your social skills ;-) before you start to approach them. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From namesagame-usenet at yahoo.com Tue Apr 1 18:11:37 2008 From: namesagame-usenet at yahoo.com (gamename) Date: Tue, 1 Apr 2008 15:11:37 -0700 (PDT) Subject: Not Sure This Can Be Done... References: <46aeae28-4470-4136-a5f6-040f6468eb32@b5g2000pri.googlegroups.com> <65fmclF2f352gU1@mid.uni-berlin.de> Message-ID: <13777863-548e-4318-9b03-d64ccc3eebea@d21g2000prf.googlegroups.com> > Use virtualenv to create a local python, and activate that when > developing for that branch. Thanks for the suggestion, but that's the problem: having to activate it. Isn't there some way to simply have the local script look at a specified dir rather than starting a virtual environment? -T From donn at u.washington.edu Fri Apr 25 12:10:31 2008 From: donn at u.washington.edu (Donn Cave) Date: Fri, 25 Apr 2008 09:10:31 -0700 Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> <48118719$0$25846$9b622d9e@news.freenet.de> Message-ID: In article <48118719$0$25846$9b622d9e at news.freenet.de>, "Martin v. L?wis" wrote: > > I still think it's a shame > [...] > > pps: I have to note that it would be nice if the > > ad-hominem (sp?) invective would drop out of > > these threads -- it doesn't add a lot, I think. > > shame > 1 a. a painful emotion caused by consciousness of guilt, > shortcoming, or impropriety > 2 a condition of humiliating disgrace or disrepute - [in sing.] a regrettable or unfortunate situation or action: `it is a shame that they are not better known' If English isn't your 1st language, you deserve a lot of credit for your mastery of it, but you need a better dictionary. Donn Cave, donn at u.washington.edu From benash at gmail.com Sat Apr 26 17:23:39 2008 From: benash at gmail.com (Benjamin) Date: Sat, 26 Apr 2008 14:23:39 -0700 (PDT) Subject: Parsing HTML? References: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> <29bcc6bc-ab2e-4ba6-a7b3-aa1f1e850ea1@y21g2000hsf.googlegroups.com> Message-ID: On Apr 3, 9:10?pm, 7stud wrote: > On Apr 3, 12:39?am, ben... at gmail.com wrote: > > > BeautifulSoup does what I need it to. ?Though, I was hoping to find > > something that would let me work with the DOM the way JavaScript can > > work with web browsers' implementations of the DOM. ?Specifically, I'd > > like to be able to access the innerHTML element of a DOM element. > > Python's built-in HTMLParser is SAX-based, so I don't want to use > > that, and the minidom doesn't appear to implement this part of the > > DOM. > > innerHTML has never been part of the DOM. ?It is however a defacto > browser standard. ?That's probably why you aren't having any luck > using a python module that implements the DOM. That makes sense. From gnewsg at gmail.com Wed Apr 30 10:20:15 2008 From: gnewsg at gmail.com (Giampaolo Rodola') Date: Wed, 30 Apr 2008 07:20:15 -0700 (PDT) Subject: List all files using FTP References: Message-ID: <2762d539-c3c6-4930-8776-ae0943faec78@24g2000hsh.googlegroups.com> On 6 Mar, 18:46, Anders Eriksson wrote: > Hello, > > I need to list all the files on myFTPaccount (multiple subdirectories). I > don't have shell access to the account. > > anyone that has a program that will do this? > > // Anders > -- > English is not my first, or second, language > so anything strange, or insulting, is due to > the translation. > Please correct me so I may improve my English! If you mean listing ALL files including those contained in sub directories if the server supports globbing you can issue a "STAT *" command and receive the list of all files on the command channel in an "ls -lR *"-like form. Not tested: >>> import ftplib >>> f = ftplib.FTP() >>> f.connect('ftpserver.domain', 21) >>> f.login() >>> f.sendcmd('STAT *') an "ls -lR *" is expected to come From jon+usenet at unequivocal.co.uk Sun Apr 27 08:18:00 2008 From: jon+usenet at unequivocal.co.uk (Jon Ribbens) Date: Sun, 27 Apr 2008 07:18:00 -0500 Subject: Why can't timedeltas be divided? References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> <48142747$0$20906$9b622d9e@news.freenet.de> Message-ID: On 2008-04-27, Martin v. L?wis wrote: >> Last time I brought up this sort of thing, it seemed fairly unanimous >> that the shortcomings of the datetime module were 'deliberate' and >> would not be fixed, patch or no patch. > > Ok, so then if the answer to my question is "yes", the first step > should be to discuss it on python-dev. Yes, that's where it was decided that the datetime module was fine that way it is and must not be changed. From eedmit at NO.eed.SPAM.ericsson.PLS.se Fri Apr 18 13:17:39 2008 From: eedmit at NO.eed.SPAM.ericsson.PLS.se (Michael Tosch) Date: Fri, 18 Apr 2008 19:17:39 +0200 Subject: get quote enclosed field in a line In-Reply-To: References: Message-ID: xahlee at gmail.com wrote: > is there a simple way in perl, python, or awk/shell/pipe, that gets > the user agent field in a apache log? > > e.g. the typical line is like this: > > 189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET / > Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org > "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/ > 5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311 > Firefox/2.0.0.13" "-" > > I want the part: "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv: > 1.8.1.13) Gecko/20080311 Firefox/2.0.0.13". > > Thanks. > > Xah > xah at xahlee.org > ? http://xahlee.org/ > > ? awk -F\" '{print $6}' httpd-access.log awk -F\" 'NF>6{print $6}' httpd-access.log -- Michael Tosch @ hp : com From __peter__ at web.de Sat Apr 19 02:55:58 2008 From: __peter__ at web.de (Peter Otten) Date: Sat, 19 Apr 2008 08:55:58 +0200 Subject: Inheritance confusion References: <4809932c$0$12307$c3e8da3@news.astraweb.com> Message-ID: Hook wrote: > When I run the script I get this: > > Traceback (most recent call last): > File "./3.py", line 20, in > Obj.Connect ('Database') > File "/mnt/isis/Projects/Python/Learning/DB_m.py", line 102, in Connect > self.TRACE ("DB::Connect (" + database + "," + mode) > File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 314, in TRACE > self.DailyLog (msg) > File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 98, in > DailyLog > dt = self.Date (time ()) > TypeError: 'module' object is not callable > > > Googling the "TypeError" message suggests that I've got a module and > class with the same name, but I can't see that I have. > > Can someone point me in the right direction please? Read the traceback ;) Here's a hint: >>> import time >>> time() Traceback (most recent call last): File "", line 1, in TypeError: 'module' object is not callable >>> time.time() 1208588011.7017989 Peter From gkrill at gmail.com Fri Apr 11 10:07:21 2008 From: gkrill at gmail.com (greg_kr) Date: Fri, 11 Apr 2008 07:07:21 -0700 (PDT) Subject: Graphs in Python References: Message-ID: You should use Python with R. Google for Rpy, this is the best Graphing you can do with Python On Apr 11, 7:40?am, Philipp Pagel wrote: > Sanhita Mallick wrote: > > I have looked at that, and other similar ones all of > > which are based on Graphviz. > > Networkx is not based on graphviz. > > > > > My problem is that I myself am creating some large graphs > [...] > > So I would like to use a graphical/visual method than typing out the > > nodes. > > Not sure what exactly you mean. you will have to enter the nodes somehow > - afterwards you can visualize them. > > Do you mean you would like to have a GUI for entering nodes and edges? > I see two options: (1) write a GUI to do that (2) use an existing graph > editor and use networkx or something like that for analysis. > > > Also, I am looking for a good tutorial for basic graph > > implementation other than the one on python.org. > > ?- Look at the source code for networkx. > ?- Alternatively, basic graph algorithms can be found in many general > ? ?algorithm books. ? > ?- More specific stuff e.g. in A. Gibbons "Algorithmic Graph Theory". > > cu > ? ? ? ? Philipp > > -- > Dr. Philipp Pagel > Lehrstuhl f. Genomorientierte Bioinformatik > Technische Universit?t M?nchenhttp://mips.gsf.de/staff/pagel From danb_83 at yahoo.com Sat Apr 26 00:33:03 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Fri, 25 Apr 2008 21:33:03 -0700 (PDT) Subject: Is 2006 too old for a book on Python? References: Message-ID: On Apr 25, 8:16 am, jmDesktop wrote: > Hi, I wanted to buy a book on Python, but am concerned that some of > them are too old. One I had come to after much research was Core > Python by Wesley Chun. I looked at many others, but actually saw this > one in the store and liked it. However, it is from 2006. I know > there is free documentation and Dive Into Python. I just liked the > one in question and was hoping for thoughts on the age of it. I am > using Python 2.5.x and don' t know how different 2.3, 2,4 is from it. The changes are relatively minor. And having learned Python 2.3, you can simply refer to: What's New in Python 2.4: http://www.python.org/doc/2.4.3/whatsnew/whatsnew24.html What's New in Python 2.5: http://docs.python.org/whatsnew/whatsnew25.html From wwzaygvm at gmail.com Wed Apr 16 17:01:03 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 14:01:03 -0700 (PDT) Subject: partition manager 8.5 keygen Message-ID: partition manager 8.5 keygen http://cracks.12w.net F R E E C R A C K S From nick at stinemates.org Fri Apr 18 14:47:23 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 11:47:23 -0700 Subject: Brand New! In-Reply-To: <1208324917.7339.10.camel@paul-laptop> References: <7f1828bf-ebe7-4111-bc59-70d125facb0a@d26g2000prg.googlegroups.com> <1208324917.7339.10.camel@paul-laptop> Message-ID: <20080418184723.GF19281@deviL> On Wed, Apr 16, 2008 at 07:48:37AM +0200, Paul Scott wrote: > > On Wed, 2008-04-16 at 02:35 -0300, Gabriel Genellina wrote: > > I'm unsure if teaching Javascript, VBScript and Python at the same time is > > a good thing, I'd think one would get a language soup and mix all the > > concepts, but if it works for you, go ahead. > > For other resources, see the beginners section in the Python wiki: > > http://wiki.python.org/moin/BeginnersGuide > > Well, as an example, I learnt Python to a decent level of competency in > 2 days. I looked through the Dive into Python tuts, and then had a look > at the Python GUI FAQ (Which didn't really help much, as I started with > a GTK based GUI app). A little bit of Googling and a couple of questions > to this list gave me everything that I needed to roll out a pretty > decent application in 5 days. Oh, and just by the way, I am _not_ a > Computer Scientist or anything, I am a botanist, which means that if I > can do that, just about anyone that can read can do it. > > Python has been long on my list of TODO's, and now, finally, it is > there. I have immensely enjoyed it so far, and will continue to tinker > well into the future. > > --Paul > I think that's wonderful! I think problem solving language independent. As long as you can break down what you need to do and conceptualize. You must have learned to do with with botany, so programming came natural :) -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From Simon.Strobl at gmail.com Wed Apr 23 07:16:55 2008 From: Simon.Strobl at gmail.com (Simon Strobl) Date: Wed, 23 Apr 2008 04:16:55 -0700 (PDT) Subject: problem with dictionaries Message-ID: Hello, the idea of the following program is to parse a frequency list of the form FREQUENCY|WORD, to store the frequency of a word in a dictionary (and to do some things with this information later). I have done this many many times. Suddenly, it does not work any more: The value frq[key] is different from the value that key has in the file 'my_frqlist.txt'. I am using Python 2.5.1 Any hints? Simon ================================================ #!/usr/bin/python import sys frqlist = open('my_frqlist.txt', 'r') # my_frqlist looks like this: # 787560608|the # 434879575|of # 413442185|and # 395209748|to # 284833918|a # 249111541|in # 169988976|is frq = {} for line in frqlist: line = line.rstrip() frequency, word = line.split('|') frq[word] = int(frequency) for key in frq.keys(): print key, frq[key] From bj_666 at gmx.net Tue Apr 1 13:42:49 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 1 Apr 2008 17:42:49 GMT Subject: Homework help References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> Message-ID: <65fagoF2fiivoU1@mid.uni-berlin.de> On Tue, 01 Apr 2008 09:11:12 -0700, bobby.connor wrote: > # (2 Points) Write a python function howMany(item,lst) which accepts > an item and a lst of items and returns the number of times item occurs > in lst. For example, howMany(3,[1,2,3,2,3]) should return 2. Study the methods on lists. > # (2 Points) Write a python function upTo(n) which accepts a non- > negative number n and returns a list of numbers from 0 to n. For > example, upTo(3) should return the list [0, 1, 2, 3]. Study the built in functions. I don't know if it is considered cheating but you can get away with binding an existing one to the new name. > # (2 Points) Write a python function dotProduct(a,b) which accepts two > lists of integers a and b that are of equal length and which returns > the dot product of a and b. I.e., the sum a0 * b0 + ... + an-1 * bn-1 > where n is the length of the lists. For example: > > dotProduct([1,2,3],[4,5,6]) is 1*4 + 2*5 + 3*6 = 4 + 10 + 18 = 32 Again study the built in functions. Here the function from the `zip()` exercise below might be handy. > # (2 Points) A pair (exp0, exp1) is a combination of expressions that > are attached together by their joint membership in the pair. For > example: > >>>> (1+2, 'This') > (3, 'This') > > A component of a pair can be obtained using an index in brackets as > with lists (and strings!). For example: > >>>> (33,44)[0] > 33 And the exercise to solve is!? Study the built in data types. > Write a function zip(lst1, lst2) such that zip accepts two equal > length lists and returns a list of pairs. For example, zip(['a', 'b', > 'c'], [10, 20, 30]) should evaluate to the list [('a', 10), ('b', 20), > ('c', 30)]. Hey not even a rebinding necessary. :-) Ciao, Marc 'BlackJack' Rintsch From hniksic at xemacs.org Thu Apr 24 06:34:00 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Thu, 24 Apr 2008 12:34:00 +0200 Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <480D71B9.40909@v.loewis.de> <87lk36e6po.fsf@mulj.homelinux.net> <480e2c97$0$24477$9b622d9e@news.freenet.de> Message-ID: <87iqy7bkyv.fsf@mulj.homelinux.net> "Martin v. L?wis" writes: >>>> In py3k string%dictionary is going away. >>> Why do you say that? It's not going away in Python 3.0. >> >> I also got the impression that it was going away. PEP 3101's abstract >> says: >> >> This PEP proposes a new system for built-in string formatting >> operations, intended as a replacement [sic] for the existing '%' >> string formatting operator. >> >> Under "Backward compatibility" it says that both systems can coexist >> "until it comes time to deprecate the older system". > > The PEP may say that it's going away, but it doesn't say that it > goes away in 3.0 - and indeed, it won't. Thanks for clarifying it. It is certainly unclear from the wording of the PEP, given that 3.0 is regarded as the Python version allowed to break backward compatibility. > At some point in the future, somebody will likely propose that the > PEP will be executed. At that time, huge flame wars will start. I > expect that they settle in changing the PEP to explain that the old > mechanism gets removed in Python 4, to be release in 2018 :-) Indeed. From floris.bruynooghe at gmail.com Fri Apr 11 08:07:40 2008 From: floris.bruynooghe at gmail.com (Floris Bruynooghe) Date: Fri, 11 Apr 2008 05:07:40 -0700 (PDT) Subject: @x.setter property implementation References: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> <02cb2845-6a25-4e90-9f82-dbd68b37a5e6@p39g2000prm.googlegroups.com> <2c589c82-85e9-4db6-b8f9-156b06dd51f3@s33g2000pri.googlegroups.com> <3238aeb7-cd1b-463d-ad87-0d28dcee0202@a1g2000hsb.googlegroups.com> <41ba2942-3462-4882-9f56-18139c1f916b@x41g2000hsb.googlegroups.com> Message-ID: Oh, that was a good hint! See inline On Apr 11, 12:02 pm, Arnaud Delobelle wrote: > On Apr 11, 11:19 am, Floris Bruynooghe > wrote: > [...] > > > > Unfortunatly both this one and the one I posted before work when I try > > > them out on the commandline but both fail when I try to use them in a > > > module. And I just can't figure out why. > > > This in more detail: Imaging mod.py: > > > import sys > > > _property = property > > > class property(property): > > """Python 2.6/3.0 style property""" > > def setter(self, fset): > > cls_ns = sys._getframe(1).f_locals > > for k, v in cls_ns.iteritems(): > > if v == self: > > propname = k > > break > > cls_ns[propname] = property(self.fget, fset, > > self.fdel, self.__doc__) > > return fset return cls_ns[propname] And then it works as I tried originally! > > class Foo(object): > > @property > > def x(self): > > return self._x > > > @x.setter > > def x(self, v): > > ^^^^^ > Don't call this 'x', it will override the property, change it to > 'setx' and everything will work. The same probably goes for your own > 'propset' decorator function. > > > self._x = v + 1 > > > Now enter the interpreter: > > >> import mod > > >>> f = mod.Foo() > > >>> f.x = 4 > > >>> f.x > > > 4 > > > I don't feel like giving up on this now, so close... > > -- > Arnaud From Lie.1296 at gmail.com Sun Apr 13 04:18:24 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 13 Apr 2008 01:18:24 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> <01db54ab-1fca-4a51-8b98-510de224f40a@y21g2000hsf.googlegroups.com> Message-ID: <8e6dbc15-98f2-441d-bba4-d9ddb36f482d@i36g2000prf.googlegroups.com> On Apr 12, 3:44 am, hdante wrote: (snip) > > In this table, we consider that a number is rounded down when the > > But then, the "Round up" table gives inconsistent results if, by the > same argument, we consider 2.0 -> 2 rounding up. (you get 12 round ups > and 8 round downs just by "rethinking" the argument). So, "rounding > up" is, at the same time, better and worse than rounding to nearest > even. > It's not round up, why? In the usual sense -- when not comparing against round-half-even -- the number range we're talking is from x to lim((x+1)-y)[y -> 0 from the positive side], e.g. 1 to nearly 2 (thus the integer 2 itself is not included in the number range we're talking since it belongs to the next set), then we choose a uniformly distributed samples, i.e. 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, and 1.9. From these samples, we chose which are rounded down and which are rounded up, it happens that 1.0 is rounded down, while 1.5 is rounded up. IF for the sake of argument, you choose the number range to be lim(x + y)[y -> 0 from the positive side] to x + 1, e.g. barely above 1 to 2, then the number sample you use is 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, and 2.0, in this second number range, there are 5 round downs (1.1, 1.2, 1.3, 1.4, 1.5) and 5 round ups (1.6, 1.7, 1.8, 1.9, 2.0), but how logical is it to choose this number range (barely above 1 to 2) against choosing the more natural range (1 to nearly 2): in the correctly chosen number range (1 to nearly 2) all numbers in the form of 1.x (where x is any positive number and 0) is contained within it and there is nothing else in it, but in the second number range (barely above 1 to 2) the number 1.0 is not included while the number 2.0 is contained in it, clearly not a clean separation of numbers in the form of y.x where y is pre-determined and x is variable from other possible values of y. In short, choosing that x.0 is rounded down and x.5 is rounded up is arbitrary but not without a reason. From mnordhoff at mattnordhoff.com Tue Apr 8 00:11:10 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Tue, 08 Apr 2008 04:11:10 +0000 Subject: Newbie: How to pass a dictionary to a function? In-Reply-To: <516e07d1-91f9-462b-9fc0-ac6d1e474f9d@n14g2000pri.googlegroups.com> References: <516e07d1-91f9-462b-9fc0-ac6d1e474f9d@n14g2000pri.googlegroups.com> Message-ID: <47FAF05E.3070901@mattnordhoff.com> BonusOnus wrote: > How do I pass a dictionary to a function as an argument? > > > # Say I have a function foo... > def foo (arg=[]): > x = arg['name'] > y = arg['len'] > > s = len (x) > > t = s + y > > return (s, t) I assume you actually indented the body of the function? > # The dictionary: > > dict = {} > dict['name'] = 'Joe Shmoe' > dict['len'] = 44 'dict' is the name of a built-in type. You should name your variable something else. > # I try to pass the dictionary as an argument to a > # function > > len, string = foo (dict) 'len' is the name of a built-in function and 'string' is a module in the standard library. You should name both of them something else. > # This bombs with 'TypeError: unpack non-sequence' > > What am I doing wrong with the dictionary? It would be helpful to provide the full traceback, since that says what line the problem is on... HTH (it probably won't) -- From steve at holdenweb.com Tue Apr 1 19:10:00 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 01 Apr 2008 19:10:00 -0400 Subject: class super method In-Reply-To: References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> <0eb3ee4e-82e2-419a-8e7b-4931f7b4effa@c26g2000prf.googlegroups.com> Message-ID: Steve Holden wrote: > George Sakkis wrote: >> On Mar 31, 10:41 pm, Ed Leafe wrote: [...] >> In a sentence, it's better than nothing but worse than anything. >> > So you are prepared to write off the voice of experience because some > random web pages contradict what Ed is saying? > > As Ed rightly points out, any sufficiently complex gun can end up > shooting you in the foot. > Lest my remarks should be thought disrespectful to Michele Simionato, I should point out that I am familiar with those comments, and they do correctly identify problems with super() which are in fact fundamental to any multiple inheritance scheme. So it was a little rude of me to refer to "some random web pages" there, and I apologize. Ed is a good enough designer to avoid the corner cases. Strangely enough the one place where I have ended up making significant use of super() was in providing mixins for wxPython interface classes! regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From jeremy.wagner at laposte.net Tue Apr 22 12:50:54 2008 From: jeremy.wagner at laposte.net (=?ISO-8859-1?Q?J=E9r=E9my_Wagner?=) Date: Tue, 22 Apr 2008 18:50:54 +0200 Subject: Python Success stories In-Reply-To: <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> Message-ID: <480e176c$0$884$ba4acef3@news.orange.fr> Sure. Python is more readable than Perl, though I have found Python to have a weird behavior regarding this little issue : How can you explain that Python doesn't support the ++ opeator, whereas at the same time it does support the += operator ??? No python developer I know has been able to answer that. Istvan Albert a ?crit : > On Apr 22, 6:25 am, azrael wrote: > >> A friend of mine i a proud PERL developer which always keeps making >> jokes on python's cost. > >> This hurts. Please give me informations about realy famous >> aplications. > > you could show him what Master Yoda said when he compared Python to > Perl > > http://www.personal.psu.edu/iua1/pythonvsperl.htm > > i. From suzhi18 at googlemail.com Wed Apr 9 03:14:30 2008 From: suzhi18 at googlemail.com (suzhi18 at googlemail.com) Date: Wed, 9 Apr 2008 00:14:30 -0700 (PDT) Subject: makepy.py not working References: <03e9c33d-d957-4bc0-8568-3a40403eadb9@a70g2000hsh.googlegroups.com> Message-ID: <74c6f30e-9e79-4ce4-94fd-cde5e7fcc52e@m44g2000hsc.googlegroups.com> Ok, thanks for your help. After looking into the makepy.py file it was clear that this is only a command for the CMD console. I want to write a function which generates this .py file of the excel objects. I will now send the command to the CMD threw my python code. thanks again. suzhi From billingspanshism at gmail.com Sat Apr 19 17:18:04 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:18:04 -0700 (PDT) Subject: victoria beckham gallery Message-ID: <63e7e2ff-f5a1-4ead-b6b7-d4b9a2569a47@a23g2000hsc.googlegroups.com> Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From skip at pobox.com Fri Apr 11 14:28:08 2008 From: skip at pobox.com (Skip Montanaro) Date: Fri, 11 Apr 2008 18:28:08 +0000 (UTC) Subject: Multiple independent Python interpreters in a C/C++ program? References: <18431.37057.886339.853171@montanaro-dyndns-org.local> Message-ID: > Hi,You will only have one the different static Python variables, > so this is not possible. Thanks, that's pretty much what I expected... Skip From meisnernel73884 at gmail.com Wed Apr 30 06:39:12 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:39:12 -0700 (PDT) Subject: fifa manager 08 crack Message-ID: <9cd7fd65-2d46-4896-b57c-df71b28e34d8@d45g2000hsc.googlegroups.com> fifa manager 08 crack http://crack.cracksofts.com From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 4 08:06:36 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 04 Apr 2008 14:06:36 +0200 Subject: Python in High School In-Reply-To: <902504ff-410f-4cfc-b76b-89535b5276cc@2g2000hsn.googlegroups.com> References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <902504ff-410f-4cfc-b76b-89535b5276cc@2g2000hsn.googlegroups.com> Message-ID: <47f619c5$0$19004$426a74cc@news.free.fr> marion at everautumn.com a ?crit : (snip) > I think I agree with all of the positive, supporting posts about > Python. I would just like to add that Python (and PyGame) are open > source And run on most common platforms AFAIK. > and so your students can download it at home and have fun > exploring it on their own time (at their own pace). I think that is a > real positive. Indeed. From jnormoyle at iel.ie Tue Apr 29 12:28:08 2008 From: jnormoyle at iel.ie (John Normoyle) Date: Tue, 29 Apr 2008 17:28:08 +0100 Subject: Import fails with python but succeeds with python -v Message-ID: <3C57A0B536BE86438ED51856C6E830C3E1CB22@ieldubmail.iel.ie> Hi, I've noticed strange behaviour where cx_Oracle will fail to load when using "python" but it will succeed when using "python -v" while throwing "Unsatisfied code symbol" errors. This is for Python 2.5, Oracle 9.2 and cx_Oracle 4.3.1 on the platform HP-UX 11 Output for python: ImportError: Failed to load cx_Oracle Output for python -v: (extract of the errors) shl_load /admin/3rd_party/HP-UX/cx_Oracle-4.3.1_build/build/lib.hp-ux-B.11.23-ia6 4-2.5/cx_Oracle.so /usr/lib/hpux32/dld.so: Unsatisfied data symbol 'kpggwcx_' in load module '/product/app/oracle/9.2.0.2.svr/lib32/libwtc9.so'. /usr/lib/hpux32/dld.so: Unsatisfied code symbol 'LhtStrSearch' in load module '/product/app/oracle/9.2.0.2.svr/lib32/libwtc9.so'. /usr/lib/hpux32/dld.so: Unsatisfied code symbol 'kpggGetPG' in load module '/product/app/oracle/9.2.0.2.svr/lib32/libwtc9.so'. /usr/lib/hpux32/dld.so: Unsatisfied code symbol 'LhtStrInsert' in load module '/product/app/oracle/9.2.0.2.svr/lib32/libwtc9.so'. /usr/lib/hpux32/dld.so: Unsatisfied code symbol 'kpuhhalo' in load module '/product/app/oracle/9.2.0.2.svr/lib32/libwtc9.so'. /usr/lib/hpux32/dld.so: Unsatisfied code symbol 'kpuhhfre' in load module '/product/app/oracle/9.2.0.2.svr/lib32/libwtc9.so'. /usr/lib/hpux32/dld.so: Unsatisfied code symbol 'LhtStrCreate' in load module '/product/app/oracle/9.2.0.2.svr/lib32/libwtc9.so'. /usr/lib/hpux32/dld.so: Unsatisfied code symbol 'kpugdr' in load module '/product/app/oracle/9.2.0.2.svr/lib32/libwtc9.so'. I don't really understand why using python -v results in such a different in behaviour since as far as I know, it's just a verbose option. Any help would be appreciated in figuring this out so I can hopefully apply that knowledge in importing cx_Oracle without using the -v option. Thanks, John _____________________________________________ John Normoyle Email: jnormoyle at iel.ie Web Site: http://www.interactive-enterprise.com Software Developer Interactive Enterprise 7 Riverwalk National Digital Park CityWest Business Campus Dublin 24 Ireland -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin at v.loewis.de Sat Apr 26 21:12:12 2008 From: martin at v.loewis.de (=?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?=) Date: Sun, 27 Apr 2008 03:12:12 +0200 Subject: Why can't timedeltas be divided? In-Reply-To: References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> Message-ID: <4813d2ec$0$20870$9b622d9e@news.freenet.de> > sorry for bringing up such an old thread, but this seems important to me > -- up to now, there are thousands [1] of python programs that use > hardcoded time calculations. Would you like to work on a patch? Regards, Martin From andrew at acooke.org Wed Apr 16 22:27:51 2008 From: andrew at acooke.org (andrew cooke) Date: Wed, 16 Apr 2008 19:27:51 -0700 (PDT) Subject: Metaprogramming Example Message-ID: Hi, Thanks for the help a couple of days ago. I completed what I was doing and wrote a summary which I've posted at http://acooke.org/cute/PythonMeta0.html (it's kind of long to post here). I hope it might be useful to someone else - it's complete code for a simple metaprogramming task that uses metaclasses and descriptors. I'd also appreciate further feedback if I've done anything stupid or if there's some interesting approach I've missed that might work better. Thanks again, Andrew From cmpython at gmail.com Tue Apr 8 02:06:23 2008 From: cmpython at gmail.com (CM) Date: Mon, 7 Apr 2008 23:06:23 -0700 (PDT) Subject: Learning curve for new database program with Python? References: <00fca324-6fce-4b2a-8acb-77c96b83eb1c@p39g2000prm.googlegroups.com> Message-ID: On Apr 7, 1:19 pm, "bruno.desthuilli... at gmail.com" wrote: > On 7 avr, 07:34, CM wrote: > > > > > On Apr 5, 11:50 am, Jetus wrote: > > > > I have a need for a database program. I downloaded the db2 from ibm, > > > and reviewed some of the documentation. > > > > My question is, what is the easiest program for me to try to learn. I > > > will be creating a database of about 25,000 records, it will be > > > relational. I am a beginner Python programmer, and need a database > > > solution that is easy to grasp. I played with sql, > > > and found that very difficult, if not overly cumbersome. > > > > A database that could work with Django would be very interesting to > > > look at as well.. > > > > Any suggestions out there? > > > From the good people at Django: > > > "If you want to use Django with a database, which is probably the > > case, you'll also need a database engine. PostgreSQL is recommended, > > because we're PostgreSQL fans, and MySQL, SQLite 3, and Oracle are > > also supported." > > > And if you want to make it a relational database, > > Err... I may totally misunderstand you here, but I've the strong > impression that you missed the fact that the database systems > mentionned above are all (so-called) relational dabatases. You misunderstood me, but completely understandably. I meant that a) the OP wanted to use Django, and so I was giving the word on the only database engines that would work with that and b) the OP wanted to use a relational database, and therefore would have to use SQL despite not wanting to. But these two facts are completely connected, and by leaving out that connection it seemed like those DBs weren't relational. It would have been better for me to have said: "All of these are relational databases, and, like any relational database (which you want yours to be), they will require SQL." Sorry for the confusion. From eatham at gmail.com Fri Apr 11 16:40:36 2008 From: eatham at gmail.com (Roger Dahlstrom) Date: Fri, 11 Apr 2008 13:40:36 -0700 (PDT) Subject: Windows - window status (Running vs Not Responding) References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> <5f4a5d63-c862-4d25-8849-6a36dd4e138d@m3g2000hsc.googlegroups.com> Message-ID: On Apr 11, 3:54 pm, Mike Driscoll wrote: > On Apr 11, 2:10 pm, rdahlstrom wrote: > > > On Apr 11, 1:45 pm, rdahlstrom wrote: > > > > Does anyone know how to determine the window status (Running or Not > > > Responding)? I've tried various methods with no success... > > > > This would be on a variety of Windows systems, but all at least XP, > > > and mostly server 2003. Everyone will have Python 2.5.1 on them, and > > > the script would be running locally. > > > > Any ideas? > > > Basically, I'm looking for something similar to the Process.Responding > > property in System.Diagnostics... > > Hmmm...I think you should re-post to the Python win32 group. They'll > know the answer, if there is one. Here's the link to get signed up:http://mail.python.org/mailman/listinfo/python-win32 > > Also, you might take a look at the WMI module: > > http://tgolden.sc.sabren.com/python/wmi.html > > I'm pretty sure it can do that, but I don't know how. I did find an > article on it: > > http://www.informit.com/articles/article.aspx?p=19489&seqNum=4 > > If you're better than I am, you can probably translate this to the > Python equivalent. Zenoss also has some monitoring software that's > open source Python code. > > Mike I thought about posting to the win32 group, but in looking at all of the win32 apis, I couldn't find anything that did this - other than System.Diagnostic in c#, which isn't available to win32 (nor would you expect it to be, I guess) From jjl at pobox.com Sun Apr 6 09:14:53 2008 From: jjl at pobox.com (John J. Lee) Date: Sun, 06 Apr 2008 13:14:53 GMT Subject: py.test and test coverage analysis ? References: Message-ID: <87ej9j86r6.fsf@pobox.com> j vickroy writes: > Hello all, > > I am using py.test (http://codespeak.net/py/dist/test.html) to perform > unit testing. I would like to include test coverage analysis using > coverage.py (http://nedbatchelder.com/code/modules/coverage.html), but > I do not know how to simultaneously apply the two tools in a single > run. > > Could someone offer a suggestion on how to combine coverage analysis > with py.test. http://darcs.idyll.org/~t/projects/figleaf/doc/ Run: figleaf py.test John From imageguy1206 at gmail.com Thu Apr 3 06:49:14 2008 From: imageguy1206 at gmail.com (imageguy) Date: Thu, 3 Apr 2008 03:49:14 -0700 (PDT) Subject: Examples using msilib to build windows installers Message-ID: I have been using InnoSetup to distribute my wxpython app and ir works great, howver, I would like to offer a *.msi installer to customers as an option and this isn't available using Innosetup. It would appear to me that the msilib library included with standard python 2.5 would allow be to do this. I found the source code that builds the python distrubition installer packages, but I was wondering if there were other examples that I can learn from. TIA. From jason.scheirer at gmail.com Fri Apr 4 02:18:14 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Thu, 3 Apr 2008 23:18:14 -0700 (PDT) Subject: Unicode conversion problem (codec can't decode) References: Message-ID: On Apr 3, 9:35 pm, "Eric S. Johansson" wrote: > I'm having a problem (Python 2.4) converting strings with random 8-bit > characters into an escape form which is 7-bit clean for storage in a database. > Here's an example: > > body = meta['mini_body'].encode('unicode-escape') > > when given an 8-bit string, (in meta['mini_body']), the code fragment above > yields the error below. > > 'ascii' codec can't decode byte 0xe1 in position 13: ordinal not in range(128) > > the string that generates that error is: > >
Reduce Wh?t You Owe by 50%. Get out of debt today!
Reduuce Interest & > |V|onthlyy Payme?ts Easy, we will show you how..
Freee Quote in 10 > Min.
http://www.freefromdebtin.net.cn > > I've read a lot of stuff about Unicode and Python and I'm pretty comfortable > with how you can convert between different encoding types. What I don't > understand is how to go from a byte string with 8-bit characters to an encoded > string where 8-bit characters are turned into two character hexadecimal sequences. > > I really don't care about the character set used. I'm looking for a matched set > of operations that converts the string to a seven bits a form and back to its > original form. Since I need the ability to match a substring of the original > text while the string is in it's encoded state, something like Unicode-escaped > encoding would work well for me. unfortunately, I am missing some knowledge > about encoding and decoding. I wish I knew what cjson was doing because it does > the right things for my project. It takes strings or Unicode, stores everything > as Unicode and then returns everything as Unicode. Quite frankly, I love to > have my entire system run using Unicode strings but again, I missing some > knowledge on how to force all of my modules to be Unicode by default > > any enlightenment would be most appreciated. > > ---eric > > -- > Speech-recognition in use. It makes mistakes, I correct some. ASCII is technically only the seven-bit characters, so the codec is just being very 'correct'. One trick you may want to try is a string.decode() before your encode using some 8-bit encoding, such as latin-1: body = meta['mini_body'].decode('latin-1').encode('unicode-escape') The problem here is that you don't really ever know EXACTLY which single-byte character set you're dealing with, so there's no guarantee you're going to be translating the CORRECT sequence of bytes back and forth -- for instance, the addition of the Euro symbol, which was fairly recent, supplanting the place of the old generic 'currency' character. There are libraries such as Mark Pilgrim's port of the Mozilla character detection code ( http://chardet.feedparser.org/ ), but from my experience it doesn't do differentiation between latin sets well, it's better at detecting CJK character encodings. If you're merely using some unicode file/database as a dumb store you plan to eventually push back into a sequence of bytes, you may be well off doing string.decode('some-random-encoding').encode('utf-8') when pushing in and string.decode('utf-8').encode('some-random-encoding') when getting it back out. Another thing to consider is a lot of XML libraries will create unicode string objects that ARE NOT REALLY UNICODE -- something that bit me when using cElementTree is that if an XML file is in latin-* without a declaration of it being in that charset, it will still create unicode string instances, but with illegal characters in them. This causes Python to lead you down the garden path until you try to encode the string again. At that point, it will try to validate it and throw that exception. I usually use an idiom like this: def join_chars(x): def __dummy(*args, **kws): return ''.join(x(*args, **kws)) return __dummy @join_chars def unidecode(unicode_string): for character in unicode_string: try: yield character.decode('utf-8').encode('utf-8') except: yield ord(character) And pass all my potentially invalid 'unicode' strings through it, giving an explicit try when encoding each character. It's slow, but it's really the only quick, reproducible way I've found around the problem. From duncan.booth at invalid.invalid Tue Apr 8 04:55:57 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 8 Apr 2008 08:55:57 GMT Subject: Google App Engine Message-ID: Google have announced a new service called 'Google App Engine' which may be of interest to some of the people here (although if you want to sign up you'll have to join the queue behind me): >From the introduction: > What Is Google App Engine? > > Google App Engine lets you run your web applications on Google's > infrastructure. App Engine applications are easy to build, easy to > maintain, and easy to scale as your traffic and data storage needs > grow. With App Engine, there are no servers to maintain: You just > upload your application, and it's ready to serve your users. > > You can serve your app using a free domain name on the appspot.com > domain, or use Google Apps to serve it from your own domain. You can > share your application with the world, or limit access to members of > your organization. > > App Engine costs nothing to get started. Sign up for a free account, > and you can develop and publish your application for the world to see, > at no charge and with no obligation. A free account can use up to > 500MB of persistent storage and enough CPU and bandwidth for about 5 > million page views a month. > > During the preview release of Google App Engine, only free accounts > are available. In the near future, you will be able to purchase > additional computing resources. The Application Environment > > Google App Engine makes it easy to build an application that runs > reliably, even under heavy load and with large amounts of data. The > environment includes the following features: > > * dynamic web serving, with full support for common web > technologies > * persistent storage with queries, sorting and transactions > * automatic scaling and load balancing > * APIs for authenticating users and sending email using Google > Accounts > * a fully featured local development environment that > simulates Google App Engine on your computer > > Google App Engine applications are implemented using the Python > programming language. The runtime environment includes the full Python > language and most of the Python standard library. > > Although Python is currently the only language supported by Google App > Engine, we look forward to supporting more languages in the future. http://code.google.com/appengine From toby at tobiah.org Tue Apr 8 15:53:28 2008 From: toby at tobiah.org (Tobiah) Date: Tue, 08 Apr 2008 12:53:28 -0700 Subject: Best way to check if string is an integer? References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> <0fdd2825-6d1c-4380-a79a-a7aac119f002@a5g2000prg.googlegroups.com> <96d2fe53-96bf-43d8-a58d-8269846bf0df@b64g2000hsa.googlegroups.com> <2033313.fb3g3XYCIP@montana.com> Message-ID: > byte twiddling if the need arouse. I'm excited already :) ** Posted from http://www.teranews.com ** From mfb.chikazuku at gmail.com Thu Apr 10 13:05:33 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Thu, 10 Apr 2008 19:05:33 +0200 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> Message-ID: <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Paul Rubin wrote: > Chris Stewart writes: >> I've always had an interest in Python and would like to dabble in it >> further. I've worked on a few very small command line programs but >> nothing of any complexity. I'd like to build a really simple GUI app >> that will work across Mac, Windows, and Linux. How painful is that >> going to be? I used to be really familiar with Java Swing a few years >> ago. I imagine it will be similar. >> ... >> Next, what would you say is the best framework I should look into? > > If by "best" you mean "easiest", that is probably tkinter, which > comes with python. It is somewhat rudimentary and the widgets that > come with it don't look so great. But if you just want to put up > GUI's with basic functionality and not much glitz, it is ok for most > such purposes. > out how to use I don't quite agree with you on this. Tkinter may be easy because it is available by standard in Python, but that's about it in my opinion. The API, look and performance hit is horrible. You're much better of with PyQt4 which makes the job really simple. MFB -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFH/kjhDpaqHmOKFdQRAj+kAJ0d3aHqpv/mh7kSqtDqUFXtJsxi1gCfU5UP 2Ygw9ttRIYX+ioMyBVUNsVo= =stR5 -----END PGP SIGNATURE----- From nyamatongwe+thunder at gmail.com Fri Apr 25 19:16:57 2008 From: nyamatongwe+thunder at gmail.com (Neil Hodgson) Date: Fri, 25 Apr 2008 23:16:57 GMT Subject: MESSAGE RESPONSE In-Reply-To: <4e89b45d-198c-48ca-a3a6-3ba42448cb2b@e53g2000hsa.googlegroups.com> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> <678v5qF2me5rvU1@mid.uni-berlin.de> <4e89b45d-198c-48ca-a3a6-3ba42448cb2b@e53g2000hsa.googlegroups.com> Message-ID: ajaksu: > Me too. That is, until I tried to Google Belcan and Blubaugh together. Or google for "Blubaugh, David" or similar. Repeating a message you object to actually increases its visibility and includes you in its footprint. Neil From tjreedy at udel.edu Thu Apr 24 23:13:35 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 24 Apr 2008 23:13:35 -0400 Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> Message-ID: "Aaron Watters" wrote in message news:83ab3b9e-078c-4f5c-82ab-dafd41339dc1 at u36g2000prf.googlegroups.com... The reason that successive versions of 2.x broke so little is that starting at about 2.2, all breakages (starting with int division change) were put off until until 3.0 instead of being implemented as decided upon (with warning, deprecation, and then removal). Now the debt comes due. The new policy of mass breakage was a result of complaint about the old policy of gradual breakage. Of course, the new policy will get complaints both from those who preferred the old policy and those who want Python frozen with nothing ever removed for improvements. No change, gradual change, and jump change all have problems. In a year, we will have a better idea of which was better. From deets at nospam.web.de Wed Apr 9 08:15:19 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 09 Apr 2008 14:15:19 +0200 Subject: Basic optimization of python. References: <663p3lF2go90rU1@mid.uni-berlin.de> <877if7b5h9.fsf@mulj.homelinux.net> Message-ID: <663qbjF2hnrh2U2@mid.uni-berlin.de> Hrvoje Niksic wrote: > "Diez B. Roggisch" writes: > >>> Eg: >>> a = 1 + 2 >>> .vs. >>> a = 3 >>> which one is more effective? Does the compiler calculate the result at >>> compile time? How about constant spreading? >> >> Algebraic optimizations aren't done AFAIK > > Just try it: > > Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> dis.dis(lambda: 10+5) > 1 0 LOAD_CONST 2 (15) > 3 RETURN_VALUE I remember times when that hasn't been the case - thus my answer. [GCC 3.4.6 (Ubuntu 3.4.6-6ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. Welcome to rlcompleter2 0.96 for nice experiences hit multiple times >>> import dis >>> dis.dis(lambda: 1+2) 1 0 LOAD_CONST 1 (1) 3 LOAD_CONST 2 (2) 6 BINARY_ADD 7 RETURN_VALUE Python 2.4.4 (#2, Mar 7 2008, 04:45:43) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import dis >>> dis.dis(lambda: 1+2) 1 0 LOAD_CONST 1 (1) 3 LOAD_CONST 2 (2) 6 BINARY_ADD 7 RETURN_VALUE >>> But great to know it is done now. Diez From carlwuhwdmckay at gmail.com Sat Apr 26 09:31:05 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:31:05 -0700 (PDT) Subject: cod4 multiplayer crack Message-ID: <7cc87216-ebe1-4a9b-87c9-852e2bdc61b0@56g2000hsm.googlegroups.com> cod4 multiplayer crack http://cracks.00bp.com F R E E C R A C K S From arnodel at googlemail.com Thu Apr 17 12:46:14 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 17 Apr 2008 09:46:14 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> Message-ID: <1952579a-3cfb-44ea-92aa-658daa64aee4@a70g2000hsh.googlegroups.com> On Apr 17, 5:19?pm, s0s... at gmail.com wrote: > On Apr 17, 10:54 am, colas.fran... at gmail.com wrote: > > > On 17 avr, 17:40, s0s... at gmail.com wrote: > > > Out of sheer curiosity, why do you need thirty (hand-specified and > > dutifully commented) names to the same constant object if you know > > there will always be only one object? > > I'm building a web server. The many variables are names of header > fields. One part of the code looks like this (or at least I'd like it > to): > > class RequestHeadersManager: > > ? ? # General header fields > ? ? Cache_Control ? ? ? ? ? ? ? = \ > ? ? Connection ? ? ? ? ? ? ? ? ?= \ > ? ? Date ? ? ? ? ? ? ? ? ? ? ? ?= \ > ? ? Pragma ? ? ? ? ? ? ? ? ? ? ?= \ > ? ? Trailer ? ? ? ? ? ? ? ? ? ? = \ > ? ? Transfer_Encoding ? ? ? ? ? = \ > ? ? Upgrade ? ? ? ? ? ? ? ? ? ? = \ > ? ? Via ? ? ? ? ? ? ? ? ? ? ? ? = \ > ? ? Warning ? ? ? ? ? ? ? ? ? ? = \ > > ? ? # Request header fields > ? ? Accept ? ? ? ? ? ? ? ? ? ? ?= \ > ? ? Accept_Charset ? ? ? ? ? ? ?= \ > ? ? Accept_Encoding ? ? ? ? ? ? = \ > ? ? Accept_Language ? ? ? ? ? ? = \ > ? ? Authorization ? ? ? ? ? ? ? = \ > ... > > Etc etc etc. At the end they'll all be assign to None. Then, when > initialized, __init__() will the the string of headers, parse them, > and use those variables shown above to assign to the header values. Of > course a normal request won't include all of those headers, so the > others will remain None. That's what I want. Why not do something like: class RequestHeadersManager: def __init__(self, string): self._fields = {} # Populate self.fields with fields defined in 'string' def __getitem__(self, fieldname): return self._fields.get(fieldname, None) This way you don't need to prebind all possible fields to None, and a field is accessible by its actual name, which should be easier to remember than an identifier derived from a field name. Moreover you can more easily do some group manipulation of fields (e.g. print them all def print_fields(self): for name, value in self._fields.iteritems(): print "%s: %s" % (name, value) ) -- Arnaud From pavlovevidence at gmail.com Sat Apr 19 05:42:43 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Sat, 19 Apr 2008 02:42:43 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: On Apr 18, 11:58 am, Aaron Watters wrote: > Why is the migration to py3k a concern? > For example I have libraries which use string%dictionary > substitution where the dictionary is actually an object > which emulates a dictionary. The __getitem__ for > the object can be very expensive and is only called when > needed by the string substitution. > > In py3k string%dictionary is going away. Why? > I have no idea. > > The replacement is a string.format(...) method > which supports dictionary calling. > string.format(**dictionary) > But dictionary > calling doesn't support dictionary emulation. > So in the example below the substitution works > but the call fails. > > === code > > class fdict(dict): > def __getitem__(self, item): > return "got("+item+")" > > def fn(**d): > print d["boogie"] > > if __name__=="__main__": > fd = fdict() > print "attempting string substitution with fake dictionary" > print > print "hello there %(boogie)s" % fd # <-- works > print > print "now attempting function call with fake dictionary" > print > fn(**fd) # <-- fails > > === output > > % python2.6 dtest.py > attempting string substitution with fake dictionary > > hello there got(boogie) > > now attempting function call with fake dictionary > > Traceback (most recent call last): > File "dtest.py", line 17, in > fn(**fd) > File "dtest.py", line 7, in fn > print d["boogie"] > KeyError: 'boogie' > > ==== end of output > > Consequently there is no simple way to translate > my code, I think. I suspect you will find this kind of subtle > issue in many places. Or worse, you won't find it > until after your program has been installed > in production. > > It's a damn shame because > if string%dict was just left in it wouldn't be an issue. > > Also, if making f(**d) support dict emulation > has any negative performance implications > then I don't want it please. > > sigh. -- Aaron Watters If you don't like Python 3, DON'T USE IT. It's been stated repeatedly that 2.x and 3.x are going to be supported in parallel for years. Refusing to use 3, thus casting your brain-share vote against it, is far more likely to have an effect than you coming here and making everyone's life miserable with your pitiful whining. Carl Banks From steve at holdenweb.com Wed Apr 9 13:49:30 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 13:49:30 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> <47FCF421.6000807@holdenweb.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> Message-ID: Victor Subervi wrote: > On Wed, Apr 9, 2008 at 12:51 PM, Steve Holden > wrote: > > Victor Subervi wrote: > > On Wed, Apr 9, 2008 at 11:10 AM, Steve Holden > > >> wrote: > > I'm having a problem believing this, but I don't think you are > lying. Are you *sure* you have stored the correct omages in your > database? > > > Well, the Plesk PHP/MySQL interface indicates that a blob has been > successfully stored. Furthermore, the output I get has strings like > either 'Adobe Photoshop' or 'GIMP', depending on the editor I used. And > the output is like I have seen before from incorrectly rendered images. > And images are what I loaded into those fields through my form. So I > believe they are indeed images. > > > The fact remains that cursor.fetchall() will return a list > containing one tuple containing (what you believe is) your image, so > there is NO way your code above can do what you want. > > > Right. I used your suggestion of cursor.fetchall()[0][0] and the result > was *still* the image of the url. (I also used the other suggestion.) > > > > > I can therefore only assume that this is a CGI script and that your > web server does something *extremely* funky when it gets a CGI > output it isn't expecting. But this doesn't make a lot of sense. > > > Okay. How trouble-shoot this? Pass it on to the techies where I host? > Generally they are less than receptive, but maybe if I show them this > thread I can get their attention. > Nope, no need to start berating unresponsive techies yet. Instead, try writing a file and see whether it is a legitimate JPEG or not. I imagine the following code should do so, given your earlier writings: #! /usr/bin/python import MySQLdb print "Content-type: image/jpeg\r\n" host = 'host' db = 'bre' user = 'user' passwd = 'pass' connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor = connection.cursor() cursor.execute('select img from photo where id="7";') content = cursor.fetchall()[0][0] f = open("somefile.jpg", "w") f.write(content) f.close() Then see if you can deal with "somefile.jpg" like any other JPEG. If you can't then your blobs are somehow being mangled. If you can, we'll take it from there. regards Steve > > > > Stupidity and ignorance are entirely different things, and you > (current) ignorance in no way implies stupidity. We all have to learn. > > > True. I have never found programming easy. But I have been very > persistent. It still is not easy for me. > > > However, if you bring up one of the pages from one of your many web > sites containing an image, and get your browser to display the HTML > of that page you will surely find that the image does not appear > direectly in the HTML, but instead appears as a tag in the HTML. > Something like: > > > > though the src attribute doesn't really need to be that complex. > > > Of course. > > > > > In my stupidity, I have assumed you meant this: > > content = col_fields[0][14].tostring() > print '

' > > Well, here I have no idea what the content of your database might > be, but if the fifteenth column you retrieve is the web server path > to the graphic, that should be right except for the spaces around > it, which might give trouble. You might consider instead > > > content = col_fields[0][14].tostring() > print '

' % content > > > Great suggestion! Those spaces always mess me up. Unfortunately, it > *still* did not render properly :( > > > > > Forget HTML for now. If you direct your browser to the URL on which > your server is serving the graphic then it should be displayed in > the browser window. Until that happy condition pertains, we are > stabbing around in the dark. > > > Again...time to alert the teckies where I host? > > > > It's not that I mind, but I do feel that this knowledge is already > available, though clearly I might be wrong ... > > > Well, I may have missed it in all my googling, but I thought I was > pretty thorough. At any rate, it certainly cannot hurt to document it > again (if it is indeed 'again') > TIA, > Victor > -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From paul at boddie.org.uk Tue Apr 22 12:38:26 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Tue, 22 Apr 2008 09:38:26 -0700 (PDT) Subject: Witty retorts (was: Python Success stories) References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <87d4oi3s3c.fsf_-_@benfinney.id.au> Message-ID: <23c91e74-f4a4-4304-afc1-b435ec3df557@l64g2000hse.googlegroups.com> On 22 Apr, 16:02, Ben Finney wrote: > > What lesson is it intended to teach, other than that "Fuck you" is > somehow a "retort"? I can't see that improving too many situations. It isn't supposed to teach anything: it's a joke! It'd be more relevant (yet somewhat surreal if detached from this particular context) if it ended with the social worker saying... "Hey clown! What happened to Perl 6?" Paul From gagsl-py2 at yahoo.com.ar Sun Apr 6 06:15:52 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 06 Apr 2008 07:15:52 -0300 Subject: Implementation of Crockford's Base32 Encoding? References: <345117e9-2539-4ee0-8b27-9b1a88ddde7c@a1g2000hsb.googlegroups.com> <3EF041EA-8E9A-4DAA-B690-FC725D9E25D6@gmail.com> Message-ID: En Sun, 06 Apr 2008 06:07:18 -0300, Petite Abeille escribi?: > On Apr 6, 2008, at 9:20 AM, samslists at gmail.com wrote: > >> Anyone know of a Python implementation of this: >> http://www.crockford.com/wrmg/base32.html > > Not sure about Crockford's Base32 encoding itself, but here is an > implementation of Bryce "Zooko" Wilcox-O'Hearn's "human-oriented > base-32 encoding": > > https://zooko.com/repos/z-base-32/base32/ > https://zooko.com/repos/z-base-32/base32/DESIGN The design and rationale looks better. The Crockford version is ill-defined in the sense that you can't recover the exact input string length in some cases; by example both "\x00"*4 and "\x00"*5 share the same encoding. base-64 encoding, by example, uses '=' as pad bytes at the end to avoid this problem. -- Gabriel Genellina From hopeorpha308 at gmail.com Sun Apr 27 07:43:10 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:43:10 -0700 (PDT) Subject: inventor2008 crack Message-ID: <6ef4277e-2b65-463e-ab06-59afa231b77e@c58g2000hsc.googlegroups.com> inventor2008 crack http://wga-cracks.crackkey.net From johnjsal at gmailNOSPAM.com Tue Apr 22 20:14:13 2008 From: johnjsal at gmailNOSPAM.com (John Salerno) Date: Tue, 22 Apr 2008 20:14:13 -0400 Subject: Lists: why is this behavior different for index and slice assignments? In-Reply-To: References: <480d435b$0$11643$607ed4bc@cv.net> Message-ID: <480e7f61$0$25046$607ed4bc@cv.net> Steve Holden wrote: > Assignment to a list *element* rebinds the single element to the > assigned value. Ok, I understand that. Assignment to a list *slice* has to be of a list [or iterable, as per Duncan], and it > replaces the elements in the slice by assigned elements. I don't understand the second part of that sentence. I'm assuming "it" refers to the list being assigned, "replaces the elements" is self-evident, but what does "by assigned elements" refer to? It seems when you assign a list to a list slice, nothing gets replaced, the slice just gets deleted. From tjreedy at udel.edu Thu Apr 17 14:08:08 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 17 Apr 2008 14:08:08 -0400 Subject: Profiling, recursive func slower than imperative, normal? References: <48070CAC.6020005@jouy.inra.fr> Message-ID: |In that case, I'm not sure you get any performance gain since the queue |has basically the same role as the stack in the recursive version. A |definitive answer calls for an actual test, though. The potential gain comes from not incurring function call overhead and only queueing or stacking the exact data needed. From torriem at gmail.com Sat Apr 5 17:08:51 2008 From: torriem at gmail.com (Michael Torrie) Date: Sat, 05 Apr 2008 15:08:51 -0600 Subject: Weird scope error In-Reply-To: <47F7E325.9060603@gmail.com> References: <47F79A78.4010207@gmail.com> <47F7A41C.4090402@islandtraining.com> <47F7E325.9060603@gmail.com> Message-ID: <47F7EA63.3010504@gmail.com> Rory McKinley wrote: > Gary Herron wrote: > >> Python has no such thing as this kind of a "global scope". (True, each >> module has its own global scope, but that's not what you are talking >> about.) So you'll have to fix the import for *every* module that needs >> access to ElementTree. You might make the change as you mentioned >> above for each, but really, I think you should just make ElementTree >> directly importable by either installing it normally or including >> .../xml/etree in your PYTHONPATH > > > Thank you Gary and Kay for the response > > My apologies for being dense with regard to this: If I understand your > responses correctly, the "from xml.etree import ElementTree" that I > inserted is failing? And that is why I am getting the NameError in the > method? Is Python just ignoring the failure? No. Your import is fine. It imports "ElementTree" into the namespace of your current module/program. The problem is that the elementtidy.TidyHTMLTreeBuilder module (not your code) is also trying to import ElementTree into it's own namespace, which is failing, because ElementTree itself isn't in the python path, but rather is in xml.etree. You need to either fix all these imports in these other modules (that are probably in the site_packages folder), or modify the python import path so that it can find ElementTree directly. Again the problem isn't in your code, but rather in the other modules. > > > > Rory From ptmcg at austin.rr.com Wed Apr 23 01:12:44 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Tue, 22 Apr 2008 22:12:44 -0700 (PDT) Subject: "Dreaming in Code" Message-ID: <14fccf8d-eb21-4e04-9244-50bcfc84c4d7@d45g2000hsc.googlegroups.com> Haven't seen anyone mention this book, it is a "Soul of a New Machine"- style record of the Chandler project. Since Chandler uses Python and Twisted, and employed a few Python celebs, I thought folks on this list might have already read the hardcover version. I just picked up the paperback at B&N yesterday, finished it this evening. It's a decent read, describing a software project in laymen's terms (like there are laymen out there who care about that sort of thing!). The paperback version adds a chapter including events that transpired after the hardcover publication date, current up to about October, '07, so that's a nice touch. I'm going to ask my wife to read it so she might learn what I do for a living. -- Paul From paul.hankin at gmail.com Tue Apr 22 14:09:55 2008 From: paul.hankin at gmail.com (Paul Hankin) Date: Tue, 22 Apr 2008 11:09:55 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> Message-ID: <426812d7-c217-4bfc-81b0-47ba0638a650@k13g2000hse.googlegroups.com> On Apr 22, 5:50?pm, J?r?my Wagner wrote: > Sure. Python is more readable than Perl, though I have found Python > to have a weird behavior regarding this little issue : > > How can you explain that Python doesn't support the ++ opeator, > whereas at the same time it does support the += operator ??? > > No python developer I know has been able to answer that. Because ++ is of limited use and has poor readability? 'x++' vs 'x += 1' saves 3 characters and is less readable. 'my_long_variable += expression' vs 'my_long_variable = my_long_variable + expression' saves a lot of characters and is more readable, because it avoids the duplication of the variable name. When my_long_variable is a more complex term (perhaps my_long_variable[some_long_expression]) it's even better. Plus you get the useful update-in-place behaviour when the left-hand- side of the += expression is a list. -- Paul Hankin From aubrey at rinao.com Fri Apr 11 01:46:36 2008 From: aubrey at rinao.com (Aubrey Hutchison) Date: Fri, 11 Apr 2008 01:46:36 -0400 Subject: Pydev 1.3.15 Released References: Message-ID: <002f01c89b97$683c5310$0d01a8c0@Bubba> Hi, I have tried Pydev as used in Python(x,y). I tend to like it but I miss a couple of things.. When viewing the code, Line numbers can be added for reference. This is a very good thing BUT if line numbers are useful in the monitor screen view they would of course be desirable in a hard copy. But I find the line numbers are not printed out. To resolve this I must go back and use Pywin for printing out. The other thing is ,often I want the output of a trial run to be sent to hard copy. I find that the console does not allow me to do this directly. Same thing with the Wing IDE's Again I must go to Pywin to get a hard copy for a trial run. Interesting the more advance a product is the less useful in some areas. Aubrey ----- Original Message ----- From: "Fabio Zadrozny" Newsgroups: comp.lang.python.announce To: ; ; ; ; ; "Python List" Sent: Wednesday, April 09, 2008 1:41 PM Subject: Pydev 1.3.15 Released > Hi All, > > Pydev and Pydev Extensions 1.3.15 have been released > > Details on Pydev Extensions: http://www.fabioz.com/pydev > Details on Pydev: http://pydev.sf.net > Details on its development: http://pydev.blogspot.com > > Release Highlights in Pydev Extensions: > ----------------------------------------------------------------- > > * Globals Browser: Was not correctly showing definition on a case with > multiple projects when one did not have the python nature configured. > * Code Analysis: False positive: Classes defined within a class > context are correctly found when later accessed in the parent context. > * Interactive console integration > o Context insensitive completions with auto-import in console > o Ctrl+Alt+Enter: can be used to: > + Create console if no console exists > + Send selected text to console > + Make execfile for current file if there's no selected text > > > Release Highlights in Pydev: > ---------------------------------------------- > > * Files without extension: If a file that does not have an extension > is found in the root of the pythonpath, code-completion and > breakpoints work with it. > * Extract method: comma not removed when found after a tuple and > before a keyword argument. > * Console Encoding: print u"\xF6" works (console encoding correctly > customized in python -- see > http://sourceforge.net/tracker/index.php?func=detail&aid=1580766&group_id=85796&atid=577329 > for details). > * Debugger: Context of breakpoint correctly defined when comments are > present in the end of the module. > * from __future__ import (xxx, with_statement): works. > * Interactive Console View, featuring: > o Code Completion > + Context sensitive with shell completions > + Qualifier matches as case insensitive > + Templates > + Repeating the activation changes from templates to > default completions > o Console Configurations > + Initial commands for starting the console > + Colors for the console > + Vmargs can be specified for jython > o Auto-indent > o Auto-edits > o Context info on hover > o Up / Down Arrows cycles through the history (and uses the > current text to match for the start of the history command) > o Page Up: shows dialog with console history (where lines to be > re-executed can be selected) > o Esc: clears current line > o ctrl+1 works for assign quick-assist > o Hyperlinks addedd to tracebacks in the console > o Paste added directly to the command line > o Cut will only cut from the command line > o Copy does not get the prompt chars > o Home goes to: first text char / prompt end / line start (and > cycles again) > o Cursor automatically moved to command line on key events > o Multiple views of the same console can be created > o Limitation: Output is not asynchonous (stdout and stderr are > only shown after a new command is sent to the console) > > > > What is PyDev? > --------------------------- > > PyDev is a plugin that enables users to use Eclipse for Python and > Jython development -- making Eclipse a first class Python IDE -- It > comes with many goodies such as code completion, syntax highlighting, > syntax analysis, refactor, debug and many others. > > > Cheers, > > -- > Fabio Zadrozny > ------------------------------------------------------ > Software Developer > > ESSS - Engineering Simulation and Scientific Software > http://www.esss.com.br > > Pydev Extensions > http://www.fabioz.com/pydev > > Pydev - Python Development Enviroment for Eclipse > http://pydev.sf.net > http://pydev.blogspot.com From barronmo at gmail.com Sun Apr 27 10:35:48 2008 From: barronmo at gmail.com (barronmo) Date: Sun, 27 Apr 2008 07:35:48 -0700 (PDT) Subject: print some text References: <7ac7b11d-6c9b-477c-8c0d-b038bc760918@c58g2000hsc.googlegroups.com> Message-ID: <1b0b588a-be43-49d6-be0f-231217b074dd@k13g2000hse.googlegroups.com> On Apr 25, 2:44 pm, "Gabriel Ibanez" wrote: > Hi ! > > Other idea (old style school): > > def printing(): > f=open("lpt1", "w") > f.write("\nSomething to print\f") > f.close() > > Cheers.. > > - Ibanez - > I haven't found a way from within python to print f. I'm sure there it is something simple but I've been searching for a couple weeks now with no luck. Mike From jkugler at bigfoot.com Fri Apr 25 21:26:48 2008 From: jkugler at bigfoot.com (Joshua Kugler) Date: Fri, 25 Apr 2008 17:26:48 -0800 Subject: Setting an attribute without calling __setattr__() References: Message-ID: John Machin wrote: >> Is there a way to define self.me without it firing __setattr__? > Consider reading the *second* paragraph about __setattr__ in section > 3.4.2 of the Python Reference Manual. Like I said in my original post, it was probably staring me right in the face. I had read through a bit of the documentation on special methods, but for some reason I missed that part. Thanks to all for your responses! j From aldo at nullcube.com Sat Apr 5 08:20:13 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Sat, 5 Apr 2008 23:20:13 +1100 Subject: ANN: pry unit testing framework In-Reply-To: <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> Message-ID: <20080405122012.GC15684@nullcube.com> Thus spake Kay Schluehr (kay.schluehr at gmx.net): > A properly extended framework would of course be compatible with all > existing test suites. This has nothing to do with monkeypatching. I'm > not sure you even understand the concepts you are talking about. I'm afraid I'm just going to have to assure you that I do in fact know what I'm talking about, and leave it at that. Never fear - I will personally ensure that Pry's vast, fanatical legion of goose-stepping users does not force you to use it if you don't want to... Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From rustompmody at gmail.com Sat Apr 26 14:14:17 2008 From: rustompmody at gmail.com (Rustom Mody) Date: Sat, 26 Apr 2008 23:44:17 +0530 Subject: diffing and uniqing directories Message-ID: Over years Ive collected tgz's of my directories. I would like to diff and uniq them Now I guess it would be quite simple to write a script that does a walk or find through a pair of directory trees, makes a SHA1 of each file and then sorts out the files whose SHA1s are the same/different. What is more difficult for me to do is to write a visual/gui tool to help me do this. I would guess that someone in the python world must have already done it [The alternative is to use some of the tools that come with version control systems like git. But if I knew more about that option I would not be stuck with tgzs in the first place ;-)] So if there is such software known please let me know. PS Also with the spam flood that has hit the python list I dont know if this mail is being read at all or Ive fallen off the list! From carlwuhwdmckay at gmail.com Sat Apr 26 09:28:43 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:28:43 -0700 (PDT) Subject: password crack Message-ID: <360fe26c-7e40-477c-af8b-2e1af0dfe460@e53g2000hsa.googlegroups.com> password crack http://cracks.00bp.com F R E E C R A C K S From colas.francis at gmail.com Tue Apr 15 11:39:37 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Tue, 15 Apr 2008 08:39:37 -0700 (PDT) Subject: use object method without initializing object References: Message-ID: <4e4351d8-971c-4c56-827f-bc288f736d7f@m44g2000hsc.googlegroups.com> On 15 avr, 17:27, Reckoner wrote: > would it be possible to use one of an object's methods without > initializing the object? > > In other words, if I have: > > class Test: > def __init__(self): > print 'init' > def foo(self): > print 'foo' > > and I want to use the foo function without hitting the > initialize constructor function. > > Is this possible? Yes: In [214]: class Test: .....: def foo(self): .....: print 'foo' .....: In [215]: t = Test() In [216]: t.foo() foo From bignose+hates-spam at benfinney.id.au Sat Apr 19 01:32:32 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Sat, 19 Apr 2008 15:32:32 +1000 Subject: ANNOUNCE: SCons 0.98.1 (candidate for 1.0) is now available References: Message-ID: <871w52o1e7.fsf@benfinney.id.au> "Steven Knight" writes: > For a description of important changes that affect upgrading and > backwards compatibility, please see our release notes: > > http://scons.tigris.org/RELEASE.txt > > For a very complete list of changes, please see our change log: > > http://scons.tigris.org/CHANGES.txt Both those URLs lead me to 404 responses, "No matches to your request were found." -- \ "Why should I care about posterity? What's posterity ever done | `\ for me?" -- Groucho Marx | _o__) | Ben Finney From zethex at hotmail.com Sun Apr 27 13:07:41 2008 From: zethex at hotmail.com (Zethex) Date: Sun, 27 Apr 2008 10:07:41 -0700 (PDT) Subject: Mapping and Filtering Help for Lists Message-ID: <16925836.post@talk.nabble.com> Alright I got asked today by a friend this question, which obviously I couldn't help him with. He needs to get rid of words in a string referring to an already given list then needs to map them using a function he already has. Ill explain this better by giving an example :P Say ur given these lists: un_words = ['a', 'the', 'he', 'she', 'uses', 'with'] alterns = [ ['book', 'textbook', 'notepad'], ['pencil', 'pen', 'pacer'] ] The problem asks to create a "compareandremove" so that you can use it on a string, to remove the words from the string that are contained in un_words. The remaining words then need to be compared to the alterns list and either bring back the word if no matches or bring back the list. To better explain that i'll use an example. If i do compareandremove('notepad a pencil with desk') I need it so it removes words contained in un_words, so "a" and "with"; then compares the remaining words to alterns to find a match. This should bring back: ['notepad', 'book', 'textbook', 'pencil', 'pen', 'pacer', 'desk'] Any tips on how to create this function or maybe the function itself so I can then show him how to do it. Thank you. -- View this message in context: http://www.nabble.com/Mapping-and-Filtering-Help-for-Lists-tp16925836p16925836.html Sent from the Python - python-list mailing list archive at Nabble.com. From HDoran at air.org Wed Apr 16 08:46:13 2008 From: HDoran at air.org (Doran, Harold) Date: Wed, 16 Apr 2008 08:46:13 -0400 Subject: Learning Tkinter Message-ID: <2323A6D37908A847A7C32F1E3662C80E017BDFB9@dc1ex01.air.org> I am currently reading An Intro to Tkinter (1999) by F. Lundh. This doc was published in 1999 and I wonder if there is a more recent version. I've googled a bit and this version is the one I keep finding. I like how this document is organized and also how it provides the code with visuals of what should appear on the screen. If there are other docs I should read, please let me know. Second, I am trying to work through a couple of the examples and make some small tweaks as I go to see how new things can work. In the first case, I have copied the code in the book to see how the menu works and are created as in the example menu.py below. I see how menus are created and how the command option is used to call the function callback. # menu.py from Tkinter import * def callback(): print "called the callback!" root = Tk() # create a menu menu = Menu(root) root.config(menu=menu) filemenu = Menu(menu) menu.add_cascade(label="File", menu=filemenu) filemenu.add_command(label="New", command=harold) filemenu.add_command(label="Open...", command=callback) filemenu.add_separator() filemenu.add_command(label="Exit", command=callback) helpmenu = Menu(menu) menu.add_cascade(label="Help", menu=helpmenu) helpmenu.add_command(label="About...", command=callback) mainloop() However, I now want to incorporate a basic python program with a command. Say I have a simple program called test.py # test.py filename = raw_input("Please enter the file you want to open: ") new_file = raw_input("Save the output file as: ") f = open(new_file, 'w') new = open(filename, 'r') for line in new: x = line.split('\t') print >> f, x[0],':', x[1] f.close() To make this example complete assume I have a text file like this # data.txt 1 one 2 two 3 three 4 four So, the user currently just follows directions on the screen, enters the file names, and I get what I want. I'd like to try experimenting with gui programming to see if the python programs I have written can be made even more user friendly. I currently use py2exe to create executables so that others in my organization can use these programs. In that spirit, say I want to have a menu option that allows the user to search their computer for this file, execute the python code and then save the result as a user-defined filename. So, I guess my questions are how do I associate the portion of code in menu.py "filemenu.add_command(label="Open...", command=callback)" with an operation that gives the user the ability to search the drives on their machine and then once they do let python execute the code in test.py? Many thanks, From __peter__ at web.de Mon Apr 7 05:00:00 2008 From: __peter__ at web.de (Peter Otten) Date: Mon, 07 Apr 2008 11:00:00 +0200 Subject: csv.DictReader and unicode References: Message-ID: Laszlo Nagy wrote: > This program > > fin = codecs.open(fname,"r",encoding="UTF-8") > eader = csv.DictReader(fin) > for values in reader: > pass > > results in: > > File "run.py", line 23, in process_file > for values in reader: > File "/usr/local/lib/python2.5/csv.py", line 83, in next > row = self.reader.next() > UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in > position 13: ordinal not in range(128) > > As you can see the exception is thrown in csv.py. How it is possible? > The csv.DictReader should not use ascii codec for anything, because the > file encoding is UTF-8. The csv module doesn't support unicode. Read the values as byte strings and decode afterwards. Peter From ch612bunn at gmail.com Sun Apr 27 09:17:21 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:17:21 -0700 (PDT) Subject: nod32 2.70.39 crack Message-ID: nod32 2.70.39 crack http://wga-cracks.crackkey.net From steve at holdenweb.com Thu Apr 24 20:15:53 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 20:15:53 -0400 Subject: Psyco alternative In-Reply-To: References: Message-ID: sturlamolden wrote: > On Mar 27, 4:44 pm, Jean-Paul Calderone wrote: > >> PyPy is self-hosted and has been for some time (a year or so?). > > This is technically not correct. PyPy is hosted by RPython, which is > not Python but a different language all together. > I believe, without the benefit of recent experience, that the R stands for Restricted. Thus and RPython program must of necessity also be a valid Python program. Or do you know something I don't? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From stefan_ml at behnel.de Fri Apr 18 14:46:09 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 18 Apr 2008 20:46:09 +0200 Subject: Installing BeautifulSoup with easy_install (broken?) In-Reply-To: <4808cc41$0$34569$742ec2ed@news.sonic.net> References: <4808cc41$0$34569$742ec2ed@news.sonic.net> Message-ID: <4808EC71.9050507@behnel.de> John Nagle wrote: > easy_install usually seems to make things harder. > > BeautifulSoup is one single .py file. That's all you need. > Everything else is excess baggage. I wouldn't call the installation of a single module Python package a good example for the "usual" case. Stefan From rocksportrocker at googlemail.com Wed Apr 9 14:38:42 2008 From: rocksportrocker at googlemail.com (rocksportrocker) Date: Wed, 9 Apr 2008 11:38:42 -0700 (PDT) Subject: Displaying vtk files in a wxPython window Message-ID: <45b2ab4c-b7a1-450e-a084-e487f231aeca@q1g2000prf.googlegroups.com> Hi, I want to visualize some vtk-files within a wxPython Window. Google did not help me very much, I only found some tools for Tk, what is no solution for me. I'm sure I am not the first one who asks this question.... Any hints ? Greetings, Uwe From rhamph at gmail.com Thu Apr 17 12:03:07 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Thu, 17 Apr 2008 09:03:07 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> Message-ID: <69cbd3d3-449f-4e64-96d5-f512cf317032@m3g2000hsc.googlegroups.com> On Apr 17, 9:19 am, sturlamolden wrote: > On 17 Apr, 10:25, "Martin v. L?wis" wrote: > > > help progress at all. I think neither was the case in this thread - > > the guy claimed that he actually did something about the GIL, and > > now we are all waiting for him to also tell us what it is that he > > did. > > Ok, I did not remove the GIL, but I found a way to remove its > notorious side effect on SMPs. So I am going to reveal it now. Forgive > my strange sence of humor at 3 o'clock in the morning. > > First, think about this: > > (1) What is the GIL? > (2) Where does it live? > (3) How can it be manually released? > > The answer to this is: > > (1) A critical section (a lock/mutex object) > (2) As a global object in Python25.dll on my computer > (3) Using Python's C API or calling methods in a ctypes.CDLL object > > The Python C API has the ability to embed Python interpreters. You do > this by importing Python25.dll into the process. ctypes has the > ability to call functions in a DLL. So is it possible to embed Python > in Python? And what would be consequence be? > > First, if I try to load a DLL more than once, Windows will detect this > and just give me a handle to the currently imported library. So by > importing Python25.dll with ctypes, I can just make my Python > interpreter talk to itself through its own CAPI. Yes I can create sub > interpreters using PyNew_Interpreter, but they all share the same GIL, > so it's not useful here. > > So here is what I suddendly realized, and please don't laugh, its so > simple its almost silly: > > I make some copies of Python25.dll, and call them Python25-1.dll, > Python25-2.dll, Python25-3.dll, Python25-4.dll, etc. Then I load them > all into my current Python process as ctypes.CDLL objects. Tada! I now > have a pool of independent Python interpreters, not sharing the GIL, > but still living in the same process. > > I can make the different interpreters talk to each other, including > manipulating each other's GIL, using the using ctypes and Python's C > API for embedding. > > So why does this circumvent the GIL? Because ctypes releases it before > calling functions form a CDLL object. > > If I use my main interpreter to delegate a task to one of its embedded > 'children', its GIL will be released while it is waiting for the > answer. Associating each embedded interpreter with a threading.Thread > is all that remains. The GIL is released while the thread operating > the child interpreter is blocked. > > An there you have the answer. It's really very simple :-) Interesting. Windows specific, but there's other ways to do the same thing more portably. The bigger issue is that you can't share any objects. This effectively gives you a multiprocess model - a bit cheaper than that, but not enough to really supply GIL-free threading. From steveo at syslang.net Tue Apr 8 17:14:32 2008 From: steveo at syslang.net (Steven W. Orr) Date: Tue, 8 Apr 2008 17:14:32 -0400 (EDT) Subject: __init__.py file In-Reply-To: References: Message-ID: On Tuesday, Apr 8th 2008 at 16:51 -0000, quoth cesco: =>Hi, => =>I need to instantiate an object (my_object) whose methods I have to =>use in two files (file1.py and file2.py) which are in the same =>directory. Is it possible to instantiate such object in the =>__init__.py file and then directly use it in file1.py and file2.py? =>If not, as I seem to experience, what is the best practice to follow =>in this case? (I thought __init__.py was somehow useful for that). Sounds more like a job for a singleton. I recently found one that I like a lot better than the standard recipe: class Singleton(object): __single = None # the one, true Singleton def __new__(classtype, *args, **kwargs): if classtype != type(classtype.__single): classtype.__single = object.__new__(classtype, *args, **kwargs) return classtype.__single def __init__(self,name=None): """Arg doesn't have to be str.""" self.name = name def display(self): print self.name,id(self),type(self) The advantage of this one is that it can be nicely subclassed. if __name__ == "__main__": class SubSingleton(Singleton): def __init__(self, name=None): Singleton.__init__(self, name) self.aa = 123 self.bb = 456 self.cc = 789 o1 = Singleton('foo') o1.display() o2 = Singleton('bar') o2.display() o3 = SubSingleton('foobar') o3.display() o4 = SubSingleton('barfoo') o4.display() print 'o1 = o2:',o1 == o2 print 'o1 = o3:',o1 == o3 print 'o3 = o4:',o3 == o4 -- Time flies like the wind. Fruit flies like a banana. Stranger things have .0. happened but none stranger than this. Does your driver's license say Organ ..0 Donor?Black holes are where God divided by zero. Listen to me! We are all- 000 individuals! What if this weren't a hypothetical question? steveo at syslang.net From gandalf at shopzeus.com Mon Apr 7 05:13:28 2008 From: gandalf at shopzeus.com (Laszlo Nagy) Date: Mon, 07 Apr 2008 11:13:28 +0200 Subject: csv.DictReader and unicode In-Reply-To: References: Message-ID: <47F9E5B8.8080200@shopzeus.com> Peter Otten wrote: > Laszlo Nagy wrote: > > >> This program >> >> fin = codecs.open(fname,"r",encoding="UTF-8") >> eader = csv.DictReader(fin) >> for values in reader: >> pass >> >> results in: >> >> File "run.py", line 23, in process_file >> for values in reader: >> File "/usr/local/lib/python2.5/csv.py", line 83, in next >> row = self.reader.next() >> UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in >> position 13: ordinal not in range(128) >> >> As you can see the exception is thrown in csv.py. How it is possible? >> The csv.DictReader should not use ascii codec for anything, because the >> file encoding is UTF-8. >> > > The csv module doesn't support unicode. I understand that csv does not support unicode. I figured out that the exception will not be thrown if I open the file with the built in open() call. > Read the values as byte strings and decode afterwards. > Is there a plan to make csv reader compatible with unicode? Thanks, Laszlo From aaron.watters at gmail.com Wed Apr 2 09:50:03 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 2 Apr 2008 06:50:03 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> Message-ID: <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> > Try Rails' ActiveRecord. Your problems should reduce to (lg lg > 2)^(1/12). python> (log(log(2)))**(1.0/12.0) Traceback (most recent call last): File "", line 1, in ? ValueError: negative number cannot be raised to a fractional power So you are saying the problems will get really complex? :) > Seriously, you'll forget there's a relational database below. (there > are even intefaces for "relational lists", "trees", etc.) My experience with this sort of thing is that it is a bit like morphine. It can feel really good, and in emergencies it can save you a lot of pain. But if you use it too often and too seriously you end up with really big problems. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=mysterious+objects From primoz.skale.lists at gmail.com Wed Apr 2 16:32:36 2008 From: primoz.skale.lists at gmail.com (Primoz Skale) Date: Wed, 2 Apr 2008 22:32:36 +0200 Subject: function call - default value & collecting arguments References: <_LQIj.9776$HS3.482805@news.siol.net> <7e50544d-6daf-48c2-bb82-be06d3590450@8g2000hsu.googlegroups.com> Message-ID: >> I also understand (fairly) how to collect arguments. For example, let's >> define another function: >> >> def f(*a): >> print a > > This means that f takes any number of optional positional arguments. > If nothing is passed, within f, 'a' will be an empty tuple. Note that > this is *not* the usual way to define a function taking multiple > (mandatory) arguments. > M. Lutz in "Learning Python" had defined it this way. What is the *usual* way in this case? > > or (slightly more involved, and certainly overkill): > > def with_default_args(default): > def decorator(func): > def wrapper(*args): > if not args: > args = default > return func(*args) > return wrapper > return decorator > > @with_default_args((0,)) > def f(*a): > print a[0] > Now, this is interesting. Thanks! :) Primoz From victorsubervi at gmail.com Thu Apr 3 13:03:53 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 3 Apr 2008 12:03:53 -0500 Subject: Strange MySQL Problem... In-Reply-To: References: <4dc0cfea0804021236n1faafabav1699fbe45acc3c01@mail.gmail.com> <47f46a3e$0$36371$742ec2ed@news.sonic.net> <4dc0cfea0804030543t1ad5a3abs539fa6598061c454@mail.gmail.com> Message-ID: <4dc0cfea0804031003r24086f0fgea31eccdefa2ed54@mail.gmail.com> On Thu, Apr 3, 2008 at 9:34 AM, Gabriel Genellina wrote: > En Thu, 03 Apr 2008 09:43:57 -0300, Victor Subervi > escribi?: > > >> Steve Holden wrote: > >> Define "no longer works". > > Sorry. Throws HTTP 200 error. > > HTTP 200 means OK. Yes. But there is an error somewhere, because it doesn?t run all the code. For example, I have to manually drop the table. > > > >> > The same remarks I've posted earlier apply here. > > Must have missed those. Yes, the code works fine. Repeatedly. > > > http://groups.google.com/group/comp.lang.python/browse_thread/thread/b732eee4e91b1868/ Thank you. I believe you mean by bound, something like this, right? binary(picdata) I am now doing that, if I am not mistaken. > display or *log* errors... Yeah. There are always errors... > *post*? This is the server response. Return either text *or* an image (the > text may be an html referencing the image) Yes, post. But what do I write instead of this? print 'Content-Type: image/jpeg\r\n' > Test it locally (just the database thing, no web), test the cgi script > without database interaction, only then join the two. Okay, but how do I upload an image into mysql without a script? And once I can do that, everything?s (almost) solved! > But you can read the server logs at least? I am new to Plesk. I discovered I can read logs. More following... > > Your code is throwing exceptions but you're not seeing them. Use the cgitb > module http://docs.python.org/lib/module-cgitb.html Now here you give me another laugh :) I added this line to the script import cgitb; cgitb.enable() and suddenly I can take out these junk lines that were throwing the HTTP 200 error: names = 'aramis', 'athos', 'porthos' data = {} for name in names: datum = list(name) datum.sort() data[name] = cPickle.dumps(datum, 1) Is this some kind of magic wand? :) Okay, where I am at now... I have a script called start.py which has this code in it: import cgitb; cgitb.enable() import MySQLdb import struct import _mysql, sys Lots of imports, just to try things out. Most not needed... col_names = ['id', 'name_en', 'name_es', 'name_it', 'category', 'title_en', 'title_es', 'title_it', \ 'description_en', 'description_es', 'description_it', 'price', 'bedrooms', 'bathrooms', 'pic1', 'sort_factor'] Just notice the pic1 there... Then I make a nice list of colnames like MySQL wants... col_names_with_commas = '' for name in col_names: col_names_with_commas += name + ', ' count = len(col_names_with_commas)-2 col_names_with_commas = col_names_with_commas[0:len(col_names_with_commas)-2] All that I have checked, it is good... Here is the sticky point: for id in ids: for d in id: print '\n' cursor.execute('select ' + col_names_with_commas + ' from products where id = ' + str(d) + ';') col_fields = cursor.fetchall() i = 0 x = 0 for field in col_fields[0]: if x == 0: # This is the ID field i += 1 check = 'check' + str(i) print '\n' if x == 15: print '', field, '\n' else: print '', field, '\n' x += 1 I have to do both of those for statements. The sticky point is in the last if statement. 15 is the pic1 field. Should I use binary(field) instead? It does not like that. I send the whole thing over to another script which has this: import cgitb; cgitb.enable() import MySQLdb import cgi import struct Same old same old... Here?s the sticky part... if what_do == 'insert': data = ['', '', '', '', '', '', '', '', '', '', '', 0.0, '', '', '', 500] the_form(data, what_do) elif what_do == 'update': cursor.execute('select * from products where id=' + update_these[0] + ';') data = cursor.fetchall() the_form(data[0], what_do) And then try to render... 1ra Foto Grande: I show you both parts, because the Internal Server Error comes from the second page, but the logged error points to the first page. Here is the log record... [Thu Apr 03 09:53:33 2008] [error] [client 190.166.0.65] PythonHandler mod_python.cgihandler: File "/var/www/vhosts/ livestocksling.com/httpdocs/test/python/Shop/iud.py", line 210, in the_form\n print '"', binary(data[14]), '"', referer: http://livestocksling.com/test/python/Shop/start.py [Thu Apr 03 09:53:33 2008] [error] [client 190.166.0.65] PythonHandler mod_python.cgihandler: NameError: global name 'binary' is not defined, referer: http://livestocksling.com/test/python/Shop/start.py TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From gherron at islandtraining.com Sat Apr 5 12:09:00 2008 From: gherron at islandtraining.com (Gary Herron) Date: Sat, 05 Apr 2008 09:09:00 -0700 Subject: Weird scope error In-Reply-To: <47F79A78.4010207@gmail.com> References: <47F79A78.4010207@gmail.com> Message-ID: <47F7A41C.4090402@islandtraining.com> Rory McKinley wrote: > Hi > > I am trying to use the TidyHTMLTreeBuilder module which is part of > elementtidy, but I am getting what appears to be some sort of scope > error and it is scrambling my n00b brain. > > The module file (TidyHTMLTreeBuilder.py) tried to import ElementTree by > doing the following: > > from elementtree import ElementTree > > This bombed, so after a bit of poking around I replaced it with : > > from xml.etree import ElementTree > > This appears to have worked. However, when I try and parse a file using > the function : > TidyHTMLTreeBuilder.parse('weather_ct.html') > > I receive the following error: > > Traceback (most recent call last): > File "", line 1, in > File > "/usr/lib/python2.5/site-packages/elementtidy/TidyHTMLTreeBuilder.py", > line 107, in parse > return ElementTree.parse(source, TreeBuilder()) > NameError: global name 'ElementTree' is not defined > > > The code producing the error is as follows: > > def parse(source): > return ElementTree.parse(source, TreeBuilder()) > > Surely, if the from... import has worked, ElementTree is in the global > scope and should therefore be accessible to the function parse? > Python has no such thing as this kind of a "global scope". (True, each module has its own global scope, but that's not what you are talking about.) So you'll have to fix the import for *every* module that needs access to ElementTree. You might make the change as you mentioned above for each, but really, I think you should just make ElementTree directly importable by either installing it normally or including .../xml/etree in your PYTHONPATH Gary Herron > Can anybody help? > > THanks > From jeffrey at fro.man Mon Apr 7 12:54:36 2008 From: jeffrey at fro.man (Jeffrey Froman) Date: Mon, 07 Apr 2008 09:54:36 -0700 Subject: reading dictionary's (key,value) from file References: <974814d3-59f0-49ec-9b4d-9f5dd7dfaf54@q24g2000prf.googlegroups.com> Message-ID: ankitks.mital at gmail.com wrote: > so this is what my option files look like: > > 1opt.txt > { '-cc': '12', > '-I': r'/my/path/work/'} You can turn these strings read from text files into actual dictionaries using eval: >>> d = eval("{ '-cc': '12', '-I': r'/my/path/work/'}") >>> d {'-I': '/my/path/work/', '-cc': '12'} >>> type(d) Note that eval will happily execute all sorts of arbitrary code, so this is not a good solution if you don't fully trust your option file creators. It's also a bit clunky compared to simply importing. Since you already have dictionary-literal syntax in your text file, why not add a left-hand-operator and make it a module instead? For example: # opt1.py d = { '-cc': '12', '-I': r'/my/path/work/'} # main.py from opt1 import d -- Jeffrey From markfernandes02 at googlemail.com Sat Apr 5 07:49:37 2008 From: markfernandes02 at googlemail.com (markfernandes02 at googlemail.com) Date: Sat, 5 Apr 2008 04:49:37 -0700 (PDT) Subject: In Tkinter - having an input and an entry References: Message-ID: <29f44489-e589-4331-8bea-36fa346026d2@t54g2000hsg.googlegroups.com> Traceback (most recent call last): File "F:\Programming\python and database\access_db8.2.py", line 129, in ? Tkwindow() File "F:\Programming\python and database\access_db8.2.py", line 88, in Tkwindow title = stringVar() NameError: global name 'stringVar' is not defined Here is the TKwindow code. def Tkwindow(): global entry, entry2, entry3, entry4, entry5, entry6 global title, author, pubdate root = Tk() b1 = Button(root, text='Exit', command=root.quit) b1.grid(column = 1, row = 4) b2 = Button(root, text= 'Fetch', command= Fetch) b2.grid(column = 0, row = 3) b3 = Button(root, text= 'Clear', command= Clear) b3.grid(column = 0, row = 4) b4 = Button(root, text= 'Insert', command= Insert) b4.grid(column = 1, row = 3) #title = stringVar() #author = stringVar() #pubdate = stringVar() entry = Entry(root) entry.grid(column = 0, row = 0) entry2 = Entry(root) entry2.grid(column = 0, row = 1) entry3 = Entry(root) entry3.grid(column = 0, row = 2) title = stringVar() entry4 = Entry(root, textvariable = title) entry4.grid(column = 1, row = 0) author = stringVar() entry5 = Entry(root, textvariable = author) entry5.grid(column = 1, row = 1) pubdate = stringVar() entry6 = Entry(root, textvariable = pubdate) entry6.grid(column = 1, row = 2) print author print title print pubdate root.mainloop() From dolloffdelvpg at gmail.com Wed Apr 16 08:07:52 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:07:52 -0700 (PDT) Subject: taylor swift birthday Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From gagsl-py2 at yahoo.com.ar Wed Apr 30 03:57:11 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 30 Apr 2008 04:57:11 -0300 Subject: list.reverse() References: <4816e26a$0$30938$426a74cc@news.free.fr> Message-ID: En Tue, 29 Apr 2008 10:32:46 -0300, Roy Smith escribi?: > What you want to do is look at the reversed() function. Not only does it > return something (other than Null), but it is much faster because it > doesn't have to store the reversed list anywhere. What it returns is an > iterator which walks the list in reverse order. > Same with list.sort() vs. the global sorted(). No, sorted() returns a -newly created- true list, not an iterator. Its argument may be any iterable, but the result is always a list. -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Mon Apr 7 09:44:37 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 07 Apr 2008 10:44:37 -0300 Subject: A file iteration question/problem References: <47f8eee1$0$759$bed64819@news.gradwell.net> <322f98fd-eb6e-4a05-a8c7-1e0c5329e955@w5g2000prd.googlegroups.com> <47fa1cf9$0$761$bed64819@news.gradwell.net> Message-ID: En Mon, 07 Apr 2008 10:09:13 -0300, escribi?: > Arnaud Delobelle wrote: >> def recfun(lines): >> for line in lines: >> # Do stuff >> if condition: >> recfun(lines) >> >> lines = iter(open(filename)) >> recfun(lines) >> > Does that work though? If you iterate through the file with the "for > line in lines:" in the first call of recfun(lines) you surely can't do > "for line in lines:" and get any sort of sensible result in recursive > calls of recfun(lines) can you? Why not? Test and see what happens. -- Gabriel Genellina From sturlamolden at yahoo.no Thu Apr 24 20:04:10 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 17:04:10 -0700 (PDT) Subject: Psyco alternative References: Message-ID: On Mar 27, 4:44 pm, Jean-Paul Calderone wrote: > PyPy is self-hosted and has been for some time (a year or so?). This is technically not correct. PyPy is hosted by RPython, which is not Python but a different language all together. From sisson.j at gmail.com Tue Apr 22 14:08:20 2008 From: sisson.j at gmail.com (J Sisson) Date: Tue, 22 Apr 2008 13:08:20 -0500 Subject: Does Python 2.5 include or not include SQLite engine? In-Reply-To: <480E2352.5050005@activestate.com> References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> <1208819146.23409.1249124463@webmail.messagingengine.com> <3de8e1f70804212233o4e62c52s2a4d140deaa44355@mail.gmail.com> <480E2352.5050005@activestate.com> Message-ID: <4297a9020804221108y6f367decy9d115801593443ed@mail.gmail.com> On Gentoo, SQLite can be turned on or off via the sqlite USE flag for Python 2.5+ during installation. There's also a separate pysqlite package, and the python-updater script doesn't seem to take Python2.5's build into account when (re)building all of the Python2.4 modules for Python2.5...it breaks Python's sqlite support if you have both a) the sqlite USE flag set and b) the pysqlite package installed. (Might have been fixed since I last looked at it). OpenBSD seems to have pysqlite as a separate package from the "stock" python 2.5 package (at least on i386). On Tue, Apr 22, 2008 at 12:41 PM, Trent Mick wrote: > Whether a Python installation includes the SQLite 3 bindings typically > depends on: > > 1. Python version: core support for the SQLite 3 bindings (i.e. the > "sqlite3" module) was added in Python 2.5. Earlier versions of Python may > also have a 3rd-party package/module that adds SQLite bindings, of course. > > 2. The Python distro: The binary Python 2.5 installers from python.org(for Windows and Mac OS X [^1]) and ActiveState, i.e. ActivePython, (for > Windows, Mac OS X, Linux, Solaris, HP-UX and AIX) include the "sqlite3" > module as part of the installer. I don't know about other Python > distributions. > > 3. Platform: Commonly on Linux one will get Python from the Linux distro's > own packaging utility (e.g., apt-get, rpm, synaptic, yum, etc.) Typically > the Linux distros will break up a Python installation into multiple > packages. So an installation of, say, the "python2.5" package will often not > have the "sqlite3" module. To get it you would have to install the separate > "python2.5-sqlite" package. (Note: the names of these packages vary with > Linux distro and version of that distro.) > > > > Cheers, > Trent > > [1]: I could be wrong about whether the Mac OS X binary installer for > Python 2.5 from python.org includes the "sqlite3" module -- I haven't > checked -- but I presume it does. > > > Banibrata Dutta wrote: > > > Doesn't this depend on the source / distro ? My Python is from the > > ActivePython distro, while I am not sure (since I've just about started > > playing with it), I haven't seen SQLite included ... possible that I missed > > it. > > > > On 4/22/08, *python at bdurham.com * < > > python at bdurham.com > wrote: > > > > While reading feedback to my post "Does Python 2.5.2's embedded > > SQLite > > support full text searching?" I noticed that there appears to be some > > confusion regarding whether Python 2.5 includes the SQLite engine. > > > > My Windows 2.5.2 binary download includes SQLite. > > > > But other posters claim otherwise, re: Linux releases of Python 2.5? > > > > I thought one of the major features of Python 2.5 was its embedded > > SQLite engine. > > > > Thoughts? > > > > > -- > Trent Mick > trentm at activestate.com > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Computers are like air conditioners... They quit working when you open Windows. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mnordhoff at mattnordhoff.com Mon Apr 7 10:10:58 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Mon, 07 Apr 2008 14:10:58 +0000 Subject: Help replacing os.system call with subprocess call In-Reply-To: <47FA23E7.7040809@eastlink.ca> References: <47F9B1D1.4090701@eastlink.ca> <47F9C764.9070401@mattnordhoff.com> <47FA23E7.7040809@eastlink.ca> Message-ID: <47FA2B72.9050802@mattnordhoff.com> David Pratt wrote: > Hi David and Matt. I appreciate your help which has got me moving > forward again so many thanks for your reply. I have been using > subprocess.Popen a fair bit but this was the first time I had to use > subprocess to capture large file output. The trouble I was having was > with the process would just hang. Chunking was the solution. I guess I > assumed this would be taken care of in the internals. > > Overall, I wish subprocess had some better documentation since it is > definitely not a drop in replacement for os.system. In other > circumstances I am using subprocess.call() for simple calls which works > fine. > > The speed of this solution is slower than os.system. Would a queue of > some kind be needed to speed this up? Has anyone implemented something > like this? Many thanks. > > Regards, > David Did you see my second message? That should help performance. If not, I'm totally out of my depth and have no idea at all. Sorry. (How much slower? 10%? 200%?) -- From ilgufoeiltucano at gmail.com Tue Apr 1 14:04:25 2008 From: ilgufoeiltucano at gmail.com (ilgufoeiltucano at gmail.com) Date: Tue, 1 Apr 2008 11:04:25 -0700 (PDT) Subject: Python Audio PAN (left or right) and channels Message-ID: <881813a7-cbbb-48ab-9a4f-53da6fb0a69f@c26g2000prf.googlegroups.com> Hi folks... I don't know if there are other modules that let me do whatever I want with mp3s or only PyGame do that... I need to play mp3 files on different channels and listen Channel 0 on the left earphone and Channel 1 on the right... I know how to play mp3 files with pygame... I also know that pygame do what I need to do only with wave and not with mp3... Can someone suggest to me something ? :D How can I play mp3 files in different channel and pan the output? There are other py-modules that let me do this? thanks to everyone... Mark From mal at egenix.com Mon Apr 7 11:37:48 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Mon, 07 Apr 2008 17:37:48 +0200 Subject: Learning curve for new database program with Python? In-Reply-To: References: Message-ID: <47FA3FCC.6010301@egenix.com> On 2008-04-07 15:30, Greg Lindstrom wrote: > On Sun, Apr 6, 2008 at 2:31 AM, John Nagle wrote: >> Basic SQL isn't that hard. Learn CREATE, SELECT, INSERT, >> UPDATE, and DELETE syntax. That's enough for most simple >> applications. > > And then learn more advanced SQL: joins, nested selects, pivot tables and > stored procedures. You can do a lot of processing "inside" the database > which cuts down on data running over the wire. > > SQL is one of the areas I wish I had mastered (much) earlier in my career Fully agree :-) Interesting comments in a time where everyone seems to be obsessed with ORMs. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 07 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From lists at cheimes.de Sat Apr 19 17:37:14 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 19 Apr 2008 23:37:14 +0200 Subject: manipulating class attributes from a decorator while the class is being defined In-Reply-To: <200804192319.14735.wbsoft@xs4all.nl> References: <200804192319.14735.wbsoft@xs4all.nl> Message-ID: Wilbert Berendsen schrieb: > Hi, is it possible to manipulate class attributes from within a decorator > while the class is being defined? > > I want to register methods with some additional values in a class attribute. > But I can't get a decorator to change a class attribute while the class is > still being defined. Something like: > > class Parser(object): > > regexps = [] > def reg(regexp): > def deco(func): > regexps.append((regexp, func)) > return func > return deco > > @reg(r'".*"') > def quoted_string(self): > pass > > How can I reach the class attribute `regexps' from within a decorator? It's really tricky . The class object doesn't exists yet. It's created after all functions are parsed and created. You have can walk up the stack frames but it's ugly. Christian From gagsl-py2 at yahoo.com.ar Sun Apr 6 19:08:27 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 06 Apr 2008 20:08:27 -0300 Subject: Python Data Utils References: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> Message-ID: En Sun, 06 Apr 2008 11:34:11 -0300, Jesse Aldridge escribi?: > On Apr 6, 6:14?am, "Konstantin Veretennicov" > wrote: >> On Sun, Apr 6, 2008 at 7:43 AM, Jesse Aldridge >> wrote: >> > In an effort to experiment with open source, I put a couple of my >> > ?utility files up > href="http://github.com/jessald/python_data_utils/ >> > ?tree/master">here. ?What do you think? >> >> Would you search for, install, learn and use these modules if *someone >> else* created them? > > Yes, I would. I searched a bit for a library that offered similar > functionality. I didn't find anything. Maybe I'm just looking in the > wrong place. Any suggestions? Haven't you heard that Python comes with "batteries included"? For most operations in your modules, you don't need anything more than what already Python provides. Most of the whitespace, find, search, replace variants are already in the standard library, or trivially implemented with the existing tools [1]. Even more speciallized functions like pattern_to_regex are already there (see fnmatch.translate [2]) So I think you would benefit a lot reading the Library Reference documentation [3]; as it says in the docs main page: "keep this under your pillow" [1] http://docs.python.org/lib/string-methods.html [2] http://docs.python.org/lib/module-fnmatch.html [3] http://docs.python.org/lib/ -- Gabriel Genellina From nick at stinemates.org Fri Apr 25 18:36:46 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 25 Apr 2008 15:36:46 -0700 Subject: Calling Python code from inside php In-Reply-To: <67e4n4F2o0sfcU1@mid.uni-berlin.de> References: <679e9oF2mti63U1@mid.uni-berlin.de> <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> <679hd5F2nj6csU1@mid.uni-berlin.de> <67e4n4F2o0sfcU1@mid.uni-berlin.de> Message-ID: <20080425223646.GB12662@deviL> On Fri, Apr 25, 2008 at 03:29:49PM +0200, Diez B. Roggisch wrote: > Nick Stinemates schrieb: >>> While I certainly prefer to use Python wherever I can, that does not mean >>> that there aren't cases where legacy systems or other constraints make >>> this impossible. If I have e.g. a type3-based website - "how on earth" >>> should I replace that with Python (without wasting a lot of time)? >> I don't understand how the 2 are mutually exclusive? >> You can have PHP and Python bindings installed on the same Apache >> server, unless I'm mistaken? > > What about having to set up & maintain (which might not even possible on a > cheap hoster) two configs for that - just for having a few lines of python > being run? And how do you go about session-state sharing and so forth? > After all the scipt might need to be access controlled based on login > state. > > I don't say that there aren't options to run python more direct. I > argumented against a rather bold statement of Mr. alexelder: > > """ > A simple yet dangerous and rather rubbish solution (possibly more of a > hack than a real implementation) could be achieved by using a > technique described above: > """ > > Diez > -- > http://mail.python.org/mailman/listinfo/python-list Don't cry me the river, I was just asking about his situation. If there's a specific problem with using python, then write it in PHP?!? -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From Scott.Daniels at Acm.Org Thu Apr 10 08:19:52 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Thu, 10 Apr 2008 05:19:52 -0700 Subject: Sorting Directories from files in a os.listdir?? In-Reply-To: <9354f263-b833-4845-a226-1ad3a47b1e6a@p25g2000pri.googlegroups.com> References: <9354f263-b833-4845-a226-1ad3a47b1e6a@p25g2000pri.googlegroups.com> Message-ID: Soren wrote: > Hi, > > I'd like to read the filenames in a directory, but not the > subdirectories, os.listdir() gives me everything... how do I separate > the directory names from the filenames? Is there another way of doing > this? > > Thanks! import os base, files, dirs = iter(os.walk(dirname)).next() # now files is files and dirs is directories (and base == dirname) From bbxx789_05ss at yahoo.com Fri Apr 4 23:26:13 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Fri, 4 Apr 2008 20:26:13 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> Message-ID: On Apr 4, 7:06?pm, skanem... at yahoo.se wrote: > 1st question: > > when i run this program 1 will be printed into the interpreter when i > run it BUT without me clicking the actual button. > when i then click the button "1", nothing happens. > > obv i dont want any output when i dont push the button but i want it > when i do. > > what am i doing wrong here? > > 2nd question: > > i want all the buttons to have the same size. i thought i should use > row/columnspan but i dont get that to work. > how should i do? > > [code] > #! /usr/bin/env python > from Tkinter import * > import tkMessageBox > > class GUIFramework(Frame): > ? ? """This is the GUI""" > > ? ? def __init__(self,master=None): > ? ? ? ? """Initialize yourself""" > > ? ? ? ? """Initialise the base class""" > ? ? ? ? Frame.__init__(self,master) > > ? ? ? ? """Set the Window Title""" > ? ? ? ? self.master.title("Calculator") > > ? ? ? ? """Display the main window" > ? ? ? ? with a little bit of padding""" > ? ? ? ? self.grid(padx=10,pady=10) > ? ? ? ? self.CreateWidgets() > > ? ? def CreateWidgets(self): > > ? ? ? ? self.enText = Entry(self) > ? ? ? ? self.enText.grid(row=0, column=0, columnspan=8, padx=5, > pady=5) > > ? ? ? ? self.enText = Entry(self) > ? ? ? ? self.enText.grid(row=1, column=0, columnspan=8, padx=5, > pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="1", > command=self.Display(1)) > ? ? ? ? self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="2", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="3", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="+", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="4", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=4, column=0, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="5", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="6", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=4, column=2, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="-", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=4, column=3, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="7", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="8", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="9", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=5, column=2, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="*", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=5, column=3, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="0", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=6, column=0, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="C", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=6, column=1, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="r", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=6, column=2, padx=5, pady=5) > > ? ? ? ? self.btnDisplay = Button(self, text="/", default=ACTIVE) > ? ? ? ? self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) > > ? ? def Display(self, xbtn): > ? ? ? ? if xbtn==1: > ? ? ? ? ? ? print 1 > > if __name__ == "__main__": > ? ? guiFrame = GUIFramework() > ? ? guiFrame.mainloop() > > [/code] If you have this function: def f(): print 1 return 10 and you write: result = f() The '()' is the function execution operator; it tells python to execute the function. In this case, the function executes, and then the return value of the function is assigned to the variable result. If a function does not have a return statement, then the function returns None by default. The same thing is happening in this portion of your code: command = self.Display(1) That code tells python to execute the Display function and assign the function's return value to the variable command. As a result Display executes and 1 is displayed. Then since Dispay does not have a return statement, None is returned, and None is assigned to command. Obviously, that is not what you want to do. What you want to do is assign a "function reference" to command so that python can execute the function sometime later when you click on the button. A function reference is just the function name without the '()' after it. So you would write: command = self.Display But writing it like that doesn't allow *you* to pass any arguments to Display(). In addition, *tkinter* does not pass any arguments to Display when tkinter calls Display in response to a button click. As a result, there is no way to pass an argument to Display. However, there is another way to cause a function to execute when an event, like a button click, occurs on a widget: you use the widget's bind() function: my_button.bind('', someFunc) The first argument tells tkinter what event to respond to. '' is a left click. Check the docs for the different strings that represent the different events that you can respond to. The second argument is a function reference, which once again does not allow you to pass any arguments to the function. However, when you use bind() to attach a function to a widget, tkinter calls the function and passes it one argument: the "event object". The event object contains various pieces of information, and one piece of information it contains is the widget upon which the event occurred, e.g. the button that was clicked. To get the button, you write: Display(self, event_obj): button = event_obj.widget Once you have the button, you can get the text on the button: Display(self, event_obj): button = event_obj.widget text = button.cget("text") if text=="1": print 1 Another thing you should be aware of: self is like a class wide bulletin board. If you are writing code inside a class method, and there is data that you want code inside another class method to be able to see, then post the data on the class wide bulletin board, i.e. attach it to self. But in your code, you are doing this: self.btnDisplay = Button(self, text="7", default=ACTIVE) self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="8", default=ACTIVE) self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) As a result, your code continually overwrites self.btnDisplay. That means you aren't preserving the data assigned to self.btnDisplay. Therefore, the data does not need to be posted on the class wide bulletin board for other class methods to see. So just write: btnDisplay = Button(self, text="7", default=ACTIVE) btnDisplay.grid(row=5, column=0, padx=5, pady=5) btnDisplay = Button(self, text="8", default=ACTIVE) btnDisplay.grid(row=5, column=1, padx=5, pady=5) As for the button sizing problem, your buttons are all the same size and line up perfectly on mac os x 10.4.7. From paul at science.uva.nl Tue Apr 22 09:49:58 2008 From: paul at science.uva.nl (Paul Melis) Date: Tue, 22 Apr 2008 15:49:58 +0200 Subject: Does Python 2.5 include or not include SQLite engine? In-Reply-To: <67646qF2mqc8pU1@mid.uni-berlin.de> References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> <67646qF2mqc8pU1@mid.uni-berlin.de> Message-ID: Hi, Diez B. Roggisch wrote: > Dennis Lee Bieber schrieb: > >> On Mon, 21 Apr 2008 19:05:46 -0400, python at bdurham.com declaimed the >> following in comp.lang.python: >> >>> I thought one of the major features of Python 2.5 was its embedded >>> SQLite engine. >>> >> No, just the inclusion of the adapter became standard... The >> packagers of Windows installers include the SQLite3 DLL as it isn't a >> commonly available item... But many Linux versions probably include it >> as an option during the OS install. > > > AFAIK thats wrong. On my ubuntu gutsy for example, I find this: > > deets at absinth:~$ find /usr/lib/python2.5/ | grep -i sqlite > /usr/lib/python2.5/lib-dynload/_sqlite3.so > /usr/lib/python2.5/site-packages/pysqlite-2.3.2.egg-info > /usr/lib/python2.5/site-packages/pysqlite2 > /usr/lib/python2.5/site-packages/pysqlite2/__init__.py > /usr/lib/python2.5/site-packages/pysqlite2/__init__.pyc > /usr/lib/python2.5/site-packages/pysqlite2/_sqlite.so > /usr/lib/python2.5/site-packages/pysqlite2/dbapi2.py > /usr/lib/python2.5/site-packages/pysqlite2/dbapi2.pyc > /usr/lib/python2.5/sqlite3 > /usr/lib/python2.5/sqlite3/__init__.py > > ... > > > As you can see, stock 2.5 ships with its OWN version of sqlite, and I > additionally installed the pysqlite-wrapper for whatever reason I now > can't remember. The _sqlite3.so is only a wrapper around the real sqlite library. Compiling a fresh Python 2.5.2 install here gives: 15:46|paul at tabu:~/py25/lib/python2.5/lib-dynload> ldd _sqlite3.so linux-gate.so.1 => (0x00748000) libsqlite3.so.0 => /usr/lib/libsqlite3.so.0 (0x00111000) libpthread.so.0 => /lib/libpthread.so.0 (0x00631000) libc.so.6 => /lib/libc.so.6 (0x00d1b000) /lib/ld-linux.so.2 (0x00749000) I.e. the _sqlite3 module links against the system-wide installed Sqlite version. Furthermore, checking the Python source distribution will show that there is no included version of the whole Sqlite library, only the wrapper code. How your Linux distribution packages Python w.r.t. the sqlite3 module is different per distro. Regards, Paul From aaron.watters at gmail.com Wed Apr 16 15:32:00 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 16 Apr 2008 12:32:00 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> <09a38ca2-8c49-4eee-b6cf-58e849aea1fc@q1g2000prf.googlegroups.com> Message-ID: > > Also in the case of C/java etc changing the infrastructure > > is less scary because you usually find out about problems > > when the compile or link fails. For Python you may not find > > out about it until the program has been run many times. > > Perhaps this will inspire improved linters and better coding > > practices.... > > Better coding practices such as extensive unit tests? Greetings from Earth. What planet are you from? :) There is always the possibility that frustrated programmers will decide that "using something other than python" is a "better coding practice". I've seen it happen. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=alien From chris.ortner at googlemail.com Tue Apr 1 07:35:17 2008 From: chris.ortner at googlemail.com (Chris Ortner) Date: Tue, 1 Apr 2008 04:35:17 -0700 (PDT) Subject: PyQt - How to prevent a dialog being resized? References: Message-ID: <2e859fec-d833-40fc-8e7b-afbe06eae9bf@k13g2000hse.googlegroups.com> On Apr 1, 12:12?am, Kelie wrote: > Hello, > > My question is as subject. I tried something like this and it doesn't > work. > > def resizeEvent(self, event): > ? ? self.size = event.oldSize() > > Any hint? > > Thank you. If you use the Qt designer you can set the minimum- and maximum window size to the same value, which disables resize as well. Tested with Qt4 on Linux 2.6. But I'm pretty sure that there could be a much cleaner way to do this. From ivory91044 at gmail.com Tue Apr 29 04:57:40 2008 From: ivory91044 at gmail.com (ivory91044 at gmail.com) Date: Tue, 29 Apr 2008 01:57:40 -0700 (PDT) Subject: driver detective crack keygen Message-ID: <280ae4fc-6a59-4f11-9f62-58d4f0fa45c0@w74g2000hsh.googlegroups.com> driver detective crack keygen http://crack.cracksofts.com From tjreedy at udel.edu Wed Apr 23 15:40:12 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 23 Apr 2008 15:40:12 -0400 Subject: problem with dictionaries References: Message-ID: "Simon Strobl" wrote in message news:ed249bcd-87ae-48ab-9aa9-c4bc9177b5c4 at b64g2000hsa.googlegroups.com... | Any hints? For future reference, I would consider using sample data in the file itself for debugging -- to separate an algorithm problem from a file problem: | ================================================ | | #!/usr/bin/python | | import sys | | frqlist = open('my_frqlist.txt', 'r') | | # my_frqlist looks like this: | # 787560608|the | # 434879575|of | # 413442185|and | # 395209748|to | # 284833918|a | # 249111541|in | # 169988976|is Change above to: # frqlist = open('my_frqlist.txt', 'r') frqlist = '''\ 787560608|the 434879575|of 413442185|and 395209748|to 284833918|a 249111541|in 169988976|is'''.split('\n') # sample my_frqlist.txt | frq = {} | | for line in frqlist: | line = line.rstrip() | frequency, word = line.split('|') | frq[word] = int(frequency) | | for key in frq.keys(): | print key, frq[key] An alternative is 'print line' in the first loop after stripping. tjr From p at ulmcnett.com Fri Apr 25 00:45:49 2008 From: p at ulmcnett.com (Paul McNett) Date: Thu, 24 Apr 2008 21:45:49 -0700 Subject: how to mysqldb dict cursors In-Reply-To: <17d58cc40804241950i7b624e1apd2733daa79b3ed5c@mail.gmail.com> References: <17d58cc40804241950i7b624e1apd2733daa79b3ed5c@mail.gmail.com> Message-ID: <481161FD.5020407@ulmcnett.com> Vaibhav.bhawsar wrote: > I have been trying to get the DictCursor working with mysqldb module but > can't seem to. I have pasted the basic connection code and the traceback > from pydev. The connection does open with the default cursor class. > can't figure this one out. many thanks. Try one of: """ import MySQLdb, MySQLdb.cursors conn = MySQLdb.connect(..., cursorclass=MySQLdb.cursors.DictCursor) """ -or- """ import MySQLdb, MySQLdb.cursors conn = MySQLdb.connect(...) cur = MySQLdb.cursors.DictCursor(conn) """ I'm going off of memory here, though, but I'm at least close. Paul From tjreedy at udel.edu Sun Apr 13 02:10:19 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 13 Apr 2008 02:10:19 -0400 Subject: str(bytes) in Python 3.0 References: <87k5j3f7m8.fsf@pobox.com> <29f280cc-4b33-4863-beee-d231df3d9a61@u3g2000hsc.googlegroups.com> Message-ID: "John Roth" wrote in message news:29f280cc-4b33-4863-beee-d231df3d9a61 at u3g2000hsc.googlegroups.com... | On Apr 12, 8:52 am, j... at pobox.com (John J. Lee) wrote: | > Christian Heimes writes: | > > Gabriel Genellina schrieb: | > >> On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') | > >> above. But I get the same as repr(x) - is this on purpose? | > | > > Yes, it's on purpose but it's a bug in your application to call str() on | > > a bytes object or to compare bytes and unicode directly. Several months | > > ago I added a bytes warning option to Python. Start Python as "python | > > -bb" and try it again. ;) | > | > Why hasn't the one-argument str(bytes_obj) been designed to raise an | > exception in Python 3? | > | > John | | Because it's a fundamental rule that you should be able to call str() | on any object and get a sensible result. | | The reason that calling str() on a bytes object returns a bytes | literal rather than an unadorned character string is that there are no | default encodings or decodings: there is no way of determining what | the corresponding string should be. In having a double meaning, str is much like type. Type(obj) echoes the existing class of the object. Type(o,p,q) attempts to construct a new class. Similarly, Str(obj) gives a string representing the obj (which, for a string, is the string;-). Str(obj,obj2) attemps to construct a new string. tjr From petite.abeille at gmail.com Sun Apr 6 05:07:18 2008 From: petite.abeille at gmail.com (Petite Abeille) Date: Sun, 6 Apr 2008 11:07:18 +0200 Subject: Implementation of Crockford's Base32 Encoding? In-Reply-To: <345117e9-2539-4ee0-8b27-9b1a88ddde7c@a1g2000hsb.googlegroups.com> References: <345117e9-2539-4ee0-8b27-9b1a88ddde7c@a1g2000hsb.googlegroups.com> Message-ID: <3EF041EA-8E9A-4DAA-B690-FC725D9E25D6@gmail.com> On Apr 6, 2008, at 9:20 AM, samslists at gmail.com wrote: > Anyone know of a Python implementation of this: http://www.crockford.com/wrmg/base32.html Not sure about Crockford's Base32 encoding itself, but here is an implementation of Bryce "Zooko" Wilcox-O'Hearn's "human-oriented base-32 encoding": https://zooko.com/repos/z-base-32/base32/ https://zooko.com/repos/z-base-32/base32/DESIGN -- PA. http://alt.textdrive.com/nanoki/ From torriem at gmail.com Thu Apr 17 13:24:54 2008 From: torriem at gmail.com (Michael Torrie) Date: Thu, 17 Apr 2008 11:24:54 -0600 Subject: Can't do a multiline assignment! In-Reply-To: <42402158-0b16-42e2-b7a0-9d9a15e8196d@24g2000hsh.googlegroups.com> References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <42402158-0b16-42e2-b7a0-9d9a15e8196d@24g2000hsh.googlegroups.com> Message-ID: <480787E6.5050806@gmail.com> s0suk3 at gmail.com wrote: > > There! That's the whole code. I guess the way you suggest is simpler > and a bit more intuitive, but I was figuring that the way I suggested > it is more stylish. Umm, doesn't defining all those members in the class lead to class variables, not instance variables? I believe the recommended way of making it clear what instance variables to expect is to initialize them all in __init__. Currently in your implementation, each instance of your class is going to share the same variables for all those fields you defined, which probably isn't what you want. consider: class myclass(object): classvar1=None classvar2=None def __init__(self,test): self.instancevar1=test >>> a=myclass(3) >>> b=myclass(6) >>> a.classvar1=9 >>> a.classvar1 9 >>> b.classvar1 9 >>> a.instancevar1 3 >>> b.instancevar1 6 Also, your idea of checking the length of the headers to reduce the number of string comparisons is a great case of premature optimization. First it does not clarify the code, making it harder to follow. Second, since web servers are I/O bound, it likely does nothing to improve speed. So my recommendation is to use a bunch of self.HEADER_NAME=None declarations in __init__(). This is the expected way of doing it and all python programmers who are looking at your code will immediately recognize that they are instance variables. From Lie.1296 at gmail.com Sat Apr 26 02:59:09 2008 From: Lie.1296 at gmail.com (Lie) Date: Fri, 25 Apr 2008 23:59:09 -0700 (PDT) Subject: function that accepts any amount of arguments? References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> <4810724a$0$23390$426a74cc@news.free.fr> <63ac69bf-9f6d-42bd-8e6e-5b3b17ec7c69@z72g2000hsb.googlegroups.com> Message-ID: On Apr 25, 2:12?am, "bruno.desthuilli... at gmail.com" wrote: > On 24 avr, 14:28, malkarouri wrote: > > > On Apr 24, 12:43 pm, Bruno Desthuilliers wrote: > > > [...] > > > > Not quite sure what's the best thing to do in the second case - raise a > > > ValueError if args is empty, or silently return 0.0 - but I'd tend to > > > choose the first solution (Python's Zen, verses 9-11). > > > What's wrong with raising ZeroDivisionError (not stopping the > > exception in the first place)? > > Because - from a semantic POV - ?the real error is not that you're > trying to divide zero by zero, but that you failed to pass any > argument. FWIW, I'd personnaly write avg as taking a sequence - ie, > not using varargs - in which case calling it without arguments would a > TypeError (so BTW please s/Value/Type/ in my previous post). The problem with passing it as a sequence is, if you want to call it, you may have to wrestle with this odd looking code: avg((3, 4, 6, 7)) rather than this, more natural code: avg(3, 4, 6, 7) And FWIW, the OP asked if it is possible to pass variable amount of arguments, avg is just a mere example of one where it could be used not where it could be best used. Nick Craig-Wood wrote: > Steve Holden wrote: >> Ken wrote: >>> "Steve Holden" wrote in message >> [...] >>>> def mean(*x): >>>> total = 0.0 >>>> for v in x: >>>> total += v >>>> return v/len(x) >>> think you want total/len(x) in return statement >> Yes indeed, how glad I am I wrote "untested". I clearly wasn't pair >> programming when I wrote this post ;-) > Posting to comp.lang.python is pair programming with the entire > internet ;-) No, actually it's pair programming with the readers of c.l.py (or more accurately with the readers of c.l.py that happens to pass the said thread). From paddy3118 at googlemail.com Sun Apr 6 01:02:10 2008 From: paddy3118 at googlemail.com (Paddy) Date: Sat, 5 Apr 2008 22:02:10 -0700 (PDT) Subject: Best way to check if string is an integer? References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> <0fdd2825-6d1c-4380-a79a-a7aac119f002@a5g2000prg.googlegroups.com> Message-ID: <96d2fe53-96bf-43d8-a58d-8269846bf0df@b64g2000hsa.googlegroups.com> On Apr 6, 5:18 am, ernie wrote: > On Apr 6, 10:23 am, Roy Smith wrote: > > > > > In article , > > Steve Holden wrote: > > > > > This doesn't cater for negative integers. > > > > No, it doesn't, but > > > > s.isdigit() or (s[0] in "+-" and s[1:].isdigit) # untested > > > > does. > > > I think this fails on " -1". So, then you start doing > > s.strip().isdigit(), and then somebody else comes up with some other > > unexpected corner case... > > > int(s) and catching any exception thrown just sounds like the best way. > > Another corner case: Is "5.0" an integer or treated as one? > > regards, > ernie In Python, 5.0 is a float "5.0" is a string, and you need to make your mind up about what type you want "5.0" to be represented as in your program and code accordingly. - Paddy. From gagsl-py2 at yahoo.com.ar Tue Apr 15 02:18:17 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 15 Apr 2008 03:18:17 -0300 Subject: a name error References: <20080415055502.9F3CF292B61@mail-in-07.arcor-online.net> Message-ID: En Tue, 15 Apr 2008 02:54:43 -0300, Penny Y. escribi?: > import urllib2,sys > try: > r=urllib2.urlopen("http://un-know-n.com/") > except URLError,e: > print str(e) > sys.exit(1) > > print r.info() > > > But got the errors: > > Traceback (most recent call last): > File "t1.py", line 4, in ? > except URLError,e: > NameError: name 'URLError' is not defined Same as the function urlopen, you have to qualify URLError with the module first: except urllib2.URLError, e: ... Or import both things from urllib2: from urllib2 import urlopen, URLError try: r = urlopen(...) except URLError, e: ... -- Gabriel Genellina From woodham at cs.ubc.ca Fri Apr 25 19:22:04 2008 From: woodham at cs.ubc.ca (Bob Woodham) Date: Fri, 25 Apr 2008 23:22:04 +0000 (UTC) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> <426812d7-c217-4bfc-81b0-47ba0638a650@k13g2000hse.googlegroups.com> <480FDFD2.8070906@ggmail.com> Message-ID: On 2008-04-24, AlFire wrote: > Bob Woodham wrote: > >> >> x = x++; >> >> has unspecified behaviour in C. > > what about C++ To the extent that (historically) C++ was a superset of C, it was true of C++ as well. However, I haven't kept pace with the C++ standardization process. C++ now has its own ANSI standard and I don't know what, if anything, the C++ standard has to say on this issue. Maybe a C++ guru can comment. From jsprad at gmail.com Tue Apr 1 13:27:18 2008 From: jsprad at gmail.com (sprad) Date: Tue, 1 Apr 2008 10:27:18 -0700 (PDT) Subject: Python in High School Message-ID: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> I'm a high school computer teacher, and I'm starting a series of programming courses next year (disguised as "game development" classes to capture more interest). The first year will be a gentle introduction to programming, leading to two more years of advanced topics. I was initially thinking about doing the first year in Flash/ ActionScript, and the later years in Java. My reasoning is that Flash has the advantage of giving a quick payoff to keep the students interested while I sneak in some OOP concepts through ActionScript. Once they've gotten a decent grounding there, they move on to Java for some more heavy-duty programming. I've never used Python, but I keep hearing enough good stuff about it to make me curious. So -- would Python be a good fit for these classes? Could it equal Java as the later heavy-duty language? Does it have enough quickly- accessible sparklies to unseat Flash? I want to believe. Evangelize away. From sn at sncs.se Tue Apr 15 00:30:05 2008 From: sn at sncs.se (Sverker Nilsson) Date: Mon, 14 Apr 2008 21:30:05 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> Message-ID: <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> No one forces me, but sooner or later they will want a Python 3.0 and then a 3.1 whatever. I don't want that fuzz. As about the C versions, I am not that worried. What's your point? I just like want to write a program that will stay working. And maybe I can go on with something else hopefully than just compatibility fixes. They take some work afterall. It seems hard with Python. Esp. 2 -> 3 Sverker On Apr 15, 5:41 am, "Gabriel Genellina" wrote: > En Mon, 14 Apr 2008 23:38:56 -0300, Sverker Nilsson escribi?: > > > > > On Apr 15, 3:50 am, "Gabriel Genellina" > > wrote: > >> En Mon, 14 Apr 2008 22:02:38 -0300, Sverker Nilsson > >> escribi?: > > >> > I tried out py3k on my project,http://guppy-pe.sf.net > > >> And what happened? > >> I've seen that your project already supports Python 2.6 so the migration > >> path to 3.0 should be easy. > > > 2.6 was no big deal, It was an annoyance that they had to make 'as' a > > reserved word. Annoyances were also with 2.4, and 2.5. No big > > problems, I could make guppy backwards compatible to 2.3. But that > > seems not to be possible with Python 3.x ... it is a MUCH bigger > > change. And it would require a fork of the code bases, in C, Guido has > > written tha or to sprinkle with #ifdefs. Would not happen soon for me. > > It takes some work anyways. Do you volunteer, Guido van Rossum? :-) > > > It's not exactly easy. Perhaps not very hard anyways. But think of > > 1000's of such projects. How many do you think there are? I think > > many. How many do yo think care? I think few. > > > When it has been the fuzz with versions before, then I could have the > > same code still work with older versions. But now it seems I have to > > fork TWO codes. It's becoming too much. Think of the time you could > > write a program in C or even C++ and then it'll work. How do you think > > eg writers of bash or other unix utilities come along. Do they have to > > rewrite their code each year? No, it stays. And they can be happy > > about that, and go on to other things. Why should I have to think > > about staying compatible with the newest fancy Python all the time? NO > > -- but the answer may be, they don't care, though the others (C/C++, > > as they rely on) do. :-( > > You can stay with Python 2.6 and not support 3.0; nobody will force you to > use it. And nobody will come and wipe out your Python installation, be it > 2.6, 2.1 or whatever. And if you still enjoy using Python 1.5, please keep > using it - it won't disappear the day after 3.0 becomes available. > > Regarding the C language: yes, souce code *had* to be modified for newer > versions of the language and/or compiler. See by example, the new > "restrict" keyword in C99, or the boolean names. The C guys are much more > concerned about backwards compatibility than Python, but they can't > guarantee that (at risk of freezing the language). The 3.0 > incompatibilities are all justified, anyway, and Python is changing (as a > language) much more than C - and that's a good thing. > > There is a strategy to migrate from 2.x to 3.0, including the 2to3 tool. > Have you used it? > > -- > Gabriel Genellina From bwljgbwn at gmail.com Tue Apr 22 05:55:09 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:55:09 -0700 (PDT) Subject: smoking crack cocaine Message-ID: smoking crack cocaine http://cracks.12w.net F R E E C R A C K S From sean_mcilroy at yahoo.com Sat Apr 12 17:14:22 2008 From: sean_mcilroy at yahoo.com (Sean McIlroy) Date: Sat, 12 Apr 2008 14:14:22 -0700 (PDT) Subject: override the interpreter's parser? References: <0e23fcab-4169-4ba8-ace4-6aa4a4b95947@q1g2000prf.googlegroups.com> Message-ID: never mind. i found it. From gagsl-py2 at yahoo.com.ar Thu Apr 10 01:01:58 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 02:01:58 -0300 Subject: Need Help References: Message-ID: En Wed, 09 Apr 2008 05:29:24 -0300, pramod sridhar escribi?: > I would like to access type library files (.tlb) from python. > > The application (with .tlb extension) controls an external instrument > over > standard GPIB interface. > Is it possible to control this application from Python? If so, how ? > Can anyone share or send link of some examples ? You'll want a package pywin32 by Mark Hammond -available from sourceforge- and a book "Python Programming in Win32" by the same author. -- Gabriel Genellina From steve at holdenweb.com Fri Apr 11 15:29:09 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 11 Apr 2008 15:29:09 -0400 Subject: Question on threads In-Reply-To: References: Message-ID: <47FFBC05.50309@holdenweb.com> Jonathan Shao wrote: > Hi all, > > I'm a beginner to Python, so please bear with me. > > Is there a way of guarenteeing that all created threads in a program are > finished before the main program exits? I know that using join() can > guarentee this, but from the test scripts I've run, it seems like join() > also forces each individual thread to terminate first before the next > thread can finish. So if I create like 20 threads in a for loop, and I > join() each created thread, then join() will in effect cause the threads > to be executed in serial rather than in parallel. > No it won't, as in fact there is no mechanism to force a thread to terminate in Python. When you join() each created thread the main thread will wait for each thread to finish. Supposing the longest-lived thread finished first then all others will immediately return from join(). The only requirement it is imposing is that all sub-threads must be finished before the main thread terminates. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From rdm at rcblue.com Tue Apr 22 20:42:26 2008 From: rdm at rcblue.com (Dick Moores) Date: Tue, 22 Apr 2008 17:42:26 -0700 Subject: IDLE gripe and question Message-ID: <20080423005006.D40B81E4008@bag.python.org> I have IDLE 1.2.1, on Win XP, Python 2.5.1. The first time I use File | Open to open a script, the Open dialogue box always opens at E:\Python25\Lib\idlelib. Most of the scripts I want to access are in E:\PythonWork. There doesn't seem to be a way to change the default folder to E:\PythonWork, but is there? Thanks, Dick Moores ================================ UliPad <>: http://code.google.com/p/ulipad/ From tamim.shahriar at gmail.com Fri Apr 18 12:22:15 2008 From: tamim.shahriar at gmail.com (subeen) Date: Fri, 18 Apr 2008 09:22:15 -0700 (PDT) Subject: How to set proxy for a python script to run References: <94243913-cdcb-47a2-b000-a236fe0e8009@p25g2000hsf.googlegroups.com> Message-ID: <2931b1e8-a784-46d2-b13b-e6955acd68dd@p25g2000pri.googlegroups.com> On Apr 18, 12:31 pm, Adam wrote: > Hi, everyone, I am using /usr/share/system-config-language/ > language_gui.py in Python. > For some reason I have to bypass the firewall using a proxy. I read > the urllib reference and set http_proxy="my proxy". But it didn't > work. Is there anyway that we can set the proxy? Check the link: http://love-python.blogspot.com/2008/03/use-proxy-in-your-spider.html From basilisk96 at gmail.com Tue Apr 1 17:48:50 2008 From: basilisk96 at gmail.com (Basilisk96) Date: Tue, 1 Apr 2008 14:48:50 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: <659b3a11-6aed-41c7-a54b-34151afb0562@x41g2000hsb.googlegroups.com> On Apr 1, 12:27 pm, sprad wrote: > I'm a high school computer teacher, and I'm starting a series of > programming courses next year (disguised as "game development" classes > to capture more interest). The first year will be a gentle > introduction to programming, leading to two more years of advanced > topics. > > I was initially thinking about doing the first year in Flash/ > ActionScript, and the later years in Java. My reasoning is that Flash > has the advantage of giving a quick payoff to keep the students > interested while I sneak in some OOP concepts through ActionScript. > Once they've gotten a decent grounding there, they move on to Java for > some more heavy-duty programming. > > I've never used Python, but I keep hearing enough good stuff about it > to make me curious. > > So -- would Python be a good fit for these classes? Could it equal > Java as the later heavy-duty language? Does it have enough quickly- > accessible sparklies to unseat Flash? > > I want to believe. Evangelize away. I highly recommend that you read the introduction chapters in two of the books on this site: http://www.greenteapress.com/ The first book is called "How To Think Like a Computer Scientist: Learning with Python". The second book is a follow-up edition to that one, and is called "How To Think Like a (Python) Programmer". All of the books there are written by school teachers, so I think you will find valuable insight there. The same books also have a Java and a C++ flavor. All are free downloads. My very first serious look into Python came from this series, and I thoroughly enjoyed learning the basics. I think the text was so successful for me because the content is well-connected. As far as which language to choose - well, you can make the choice yourself after reading at least the introductions of all the books. If you do decide on Python, there is a library called "pygame" that may achieve your visual game programming goals. Enjoy! -Basilisk96 From robert.kern at gmail.com Fri Apr 4 16:06:24 2008 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 04 Apr 2008 15:06:24 -0500 Subject: Any fancy grep utility replacements out there? In-Reply-To: References: Message-ID: samslists at gmail.com wrote: > Thanks to everyone who responded, and sorry for my late response. > > Grin seems like the perfect solution for me. I finally had a chance > to download it and play with it today. It's great. > > Robert...you were kind enough to ask if I had any requests. Just the > one right now of grepping through gzip files. If for some reason you > don't want to do it or don't have time to do it, I could probably do > it and send you a patch. But I imagine that since you wrote the code, > you could do it more elegantly than I could. I was hoping that the code would be understandable enough that it shouldn't matter who's modifying it. But I have a plane trip tomorrow; I'll take a stab at it. > P.S. Robert....this program totally deserves a real web page, not > just being buried in an svn repository. I spent a lot of time looking > for a tool like this that was written in python. I imagine others > have as well, and have simply given up. It will. Eventually. -- 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 From gagsl-py2 at yahoo.com.ar Thu Apr 10 02:46:52 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 03:46:52 -0300 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> <6641eaF2ics8jU1@mid.uni-berlin.de> <664j0pF2iji99U2@mid.uni-berlin.de> <89872ea1-dc03-4647-b0bc-9d316df3efb5@q1g2000prf.googlegroups.com> Message-ID: En Thu, 10 Apr 2008 02:59:24 -0300, escribi?: > I am getting the comments. So any one can post any comment like > Steve knows nothing of Python. > California has still lot to catch up to be at par with Mesopatamia. > comp.lang.python seems a group of fools. > Anyhow, all I learnt take whichever suits and ignore rest many people > have lot of time to carry out lot of nonsense. > Well I should have looked for a paid help and my stand about not > giving out my code in open forum stands as prolific. Better not lose > time unnecessarily going back to work and debugging the problems is > much sensical work that I can do instead of listening to jokes in the > morning!!!! I hope this whole thread is just a big misunderstanding, maybe a linguistic problem. Nobody wants to steal your work, but if you say "my code is slow, what's wrong with it?", nobody can give any useful answer if you don't post the code. That's what everyone is saying, it's just common sense, in California, Mesopotamia or Buenos Aires. Have a great life, -- Gabriel Genellina From robin at nibor.org Tue Apr 15 15:25:43 2008 From: robin at nibor.org (Robin Stocker) Date: Tue, 15 Apr 2008 21:25:43 +0200 Subject: Preferred method for "Assignment by value" In-Reply-To: <7047986d-f6cc-4189-81f6-47da1ecf1902@k1g2000prb.googlegroups.com> References: <6a3ed8f0-b82c-4cd3-b36e-1d94f8a30fe3@n1g2000prb.googlegroups.com> <7047986d-f6cc-4189-81f6-47da1ecf1902@k1g2000prb.googlegroups.com> Message-ID: <48050137.8020307@nibor.org> hall.jeff at gmail.com schrieb: > by changing temp = v[:] the code worked perfectly (although changing > temp.insert(0,k) to temp = [k] + temp also worked fine... I didn't > like that as I knew it was a workaround) So the for body now looks like this?: temp = v[:] temp.insert(0, k) finallist.append(temp) It can still be clarified and simplified to this (may also be faster): temp = [k] + v finallist.append(temp) Which one do you like better :)? Robin From steve at holdenweb.com Thu Apr 17 13:45:00 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 17 Apr 2008 13:45:00 -0400 Subject: Can't do a multiline assignment! In-Reply-To: References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> Message-ID: Marco Mariani wrote: > s0suk3 at gmail.com wrote: > >> Yes, it makes it more readable. And yes, it does make it (a lot) more >> maintainable. Mainly because I don't have those four variables, I have >> about thirty. And I think I won't need to one or two of them, but >> maybe all of them at once. > > have fun with locals(), then (but please feel dirty :-) > > loc = locals() > for var in [ > 'foo', # INSERT > 'bar', # COMMENT > 'baz' # HERE > ]: > loc[var] = 42 > And bear in mind there is an explicit notification of the danger of this course of action in the CPython documentation, which refuses to guarantee that changes made to the object returns by locals() will ve reflected in the local namespace. You have been warned. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From arnodel at googlemail.com Mon Apr 28 12:58:22 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Mon, 28 Apr 2008 17:58:22 +0100 Subject: Given a string - execute a function by the same name References: Message-ID: python at bdurham.com writes: > I'm parsing a simple file and given a line's keyword, would like to call > the equivalently named function. > > There are 3 ways I can think to do this (other than a long if/elif > construct): > > 1. eval() > > 2. Convert my functions to methods and use getattr( myClass, "method" ) > > 3. Place all my functions in dictionary and lookup the function to be > called 4. Put all my functions in a module and use getattr(module, 'function') -- Arnaud From bikthh at live.cn Sun Apr 13 03:15:30 2008 From: bikthh at live.cn (bikthh at live.cn) Date: Sun, 13 Apr 2008 00:15:30 -0700 (PDT) Subject: Where is the function of 'apply' always used? References: <84cefd1a-58de-485b-b00b-77218d2d054c@c19g2000prf.googlegroups.com> Message-ID: ??,????????????????????. From bob at passcal.nmt.edu Mon Apr 21 19:59:51 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Mon, 21 Apr 2008 17:59:51 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> <2008042115060816807-bob@passcalnmtedu> <2008042116511375249-bob@passcalnmtedu> <2008042117063950073-bob@passcalnmtedu> Message-ID: <2008042117595143658-bob@passcalnmtedu> On 2008-04-21 17:06:39 -0600, Bob Greschke said: > On 2008-04-21 16:51:13 -0600, Bob Greschke said: > JUST COMPLETELY IGNORE THAT LAST ONE. What a dope. Here: > > #! /usr/bin/env python > > from os import system > from struct import unpack > > print "unpack 1" > system("date") > for x in xrange(0, 100000000): > Value = unpack(">B", "a")[0] > if Value > 0x800000: > Value -= 0x1000000 > system("date") > print > > print "ord 1" > system("date") > for x in xrange(0, 100000000): > Value = ord("a") > if Value > 0x800000: > Value -= 0x1000000 > system("date") > print > > print "unpack 3" > system("date") > for x in xrange(0, 100000000): > Value1, Value2, Value3 = unpack(">BBB", "abc") > Value = (Value1 << 16)+(Value2 << 8)+Value3 > if Value > 0x800000: > Value -= 0x1000000 > system("date") > print > > print "ord 3" > system("date") > for x in xrange(0, 100000000): > Value = (ord("a") << 16)+(ord("b") << 8)+ord("c") > if Value > 0x800000: > Value -= 0x1000000 > system("date") > > > Still, the differences between unpack and ord are significant (I just > threw in the if's for fun). I just ran this on my SunBlade 1000 with 2.3.4 and unpack 1: 7m53s ord 1: 2m00s unpack 3: 14m20s ord 3: 5m30s timeit looks broken somehow to me. From ggpolo at gmail.com Tue Apr 22 23:15:13 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Wed, 23 Apr 2008 00:15:13 -0300 Subject: IDLE gripe and question In-Reply-To: <20080423005006.D40B81E4008@bag.python.org> References: <20080423005006.D40B81E4008@bag.python.org> Message-ID: 2008/4/22, Dick Moores : > I have IDLE 1.2.1, on Win XP, Python 2.5.1. > > The first time I use File | Open to open a script, the Open dialogue box > always opens at E:\Python25\Lib\idlelib. Here on Linux it opens at the directory from where idle was executed, so I can't exactly reproduce the problem. But.. > Most of the scripts I want to > access are in E:\PythonWork. There doesn't seem to be a way to change the > default folder to E:\PythonWork, but is there? you could open a bug report on bugs.python.org and request for this feature. Do you think using the directory of the last opened file opened would be good enough ? It already maintains the recent opened files so the first entry could be used for this new feature. > > Thanks, > > Dick Moores > > ================================ > UliPad <>: > http://code.google.com/p/ulipad/ > -- > http://mail.python.org/mailman/listinfo/python-list > -- -- Guilherme H. Polo Goncalves From steve at holdenweb.com Sun Apr 20 17:26:09 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 20 Apr 2008 17:26:09 -0400 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <480B94D1.6050907@gmail.com> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B52DE.8070105@holdenweb.com> <480B94D1.6050907@gmail.com> Message-ID: <480BB4F1.9080102@holdenweb.com> Hank @ITGroup wrote: > Steve Holden wrote: >> You are suffering from a pathological condition yourself: the desire >> to optimize performance in an area where you do not have any problems. >> I would suggest you just enjoy using Python and then start to ask >> these questions again when you have a real issue that's stopping you >> from getting real work done. >> >> regards >> Steve >> > Hi, Steve, > This not simply a pathological condition. My people are keeping trying > many ways to have job done, and the memory problem became the focus we > are paying attention on at this moment. > Could you please give us some clear clues to obviously call python to > free memory. We want to control its gc operation handily as we were > using J**A. Well, now you've told us a little more about your application I can understand that you need to be careful with memory allocation. The best thing you can do is to ensure that your program is reasonably decomposed into functions. That way the local namespaces have limited lifetimes, and only the values that they return are injected into the environment. You also need to be careful in exception processing that you do not cause a reference to the stack frame to be retained, as that can be a fruitful source of references to objects, rendering them non-collectable. You appear to be stressing the limits of a single program under present-day memory constraints. I am afraid that no matter how carefully you manage object references, any difference you can make is likely to be lost in the noise as far as memory utilization is concerned, and you may have to consider using less direct methods of processing your data sets. The gc module does give you some control over the garbage collector, but generally speaking most programs don't even need that much control. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bsk16 at case.edu Sun Apr 27 20:41:57 2008 From: bsk16 at case.edu (Benjamin Kaplan) Date: Sun, 27 Apr 2008 20:41:57 -0400 Subject: error: (10035, 'The socket operation... In-Reply-To: References: Message-ID: oops, forgot to post this to the list. sorry. On Sun, Apr 27, 2008 at 8:41 PM, Benjamin Kaplan wrote: > > On Sun, Apr 27, 2008 at 7:01 PM, Don Hanlen wrote: > > IDLE internal error in runcode() > > Traceback (most recent call last): > > File "C:\PYTHON25\lib\idlelib\rpc.py", line 235, in asyncqueue > > self.putmessage((seq, request)) > > File "C:\PYTHON25\lib\idlelib\rpc.py", line 332, in putmessage > > n = self.sock.send(s[:BUFSIZE]) > > error: (10035, 'The socket operation could not complete without > > blocking') > > > > Does this look familiar to anyone? I can't figure out what to do > > about it. Python 2.5, windoze. I get it when I execute a Tkinter op > > that works elsewhere. > > > > changing this: > > > > t = self.b.create_text( > > (point.baseX + 1)*self.checkerSize/2 + fudge, > > y + fudge, > > text = str(point.occupied), > > width = self.checkerSize) > > > > to > > > > t = self.b.create_text( > > (point.baseX + 1)*self.checkerSize/2 + fudge, > > y + fudge, > > text = str(point.occupied), > > font=("Times", str(self.checkerSize/2), "bold"), > > width = self.checkerSize) > > > > for example. The same code works fine elsewhere. I thought I'd ask > > here before I try (no clue) increasing BUFSIZE in rpc.py? I'm not > > crazy about tinkering with code I have no clue about.. > > -- > > don > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > It might have something to do with the fact that IDLE uses Tkinter, > but, having never used it myself, I'm not sure. > From sjmachin at lexicon.net Wed Apr 9 20:33:22 2008 From: sjmachin at lexicon.net (John Machin) Date: Wed, 9 Apr 2008 17:33:22 -0700 (PDT) Subject: I am worried about Python 3 References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> Message-ID: <46d2ec83-9068-4cc6-a16d-961d031da720@k1g2000prb.googlegroups.com> On Apr 10, 8:12 am, "Terry Reedy" wrote: > "jmDesktop" wrote in message > > news:77c208d1-8163-4acf-8e88-bd704e05bc04 at e39g2000hsf.googlegroups.com... > | Two new versions of the language are currently in development: version > | 2.6, which retains backwards compatibility with previous releases; and > | version 3.0, which breaks backwards compatibility to the extent that > | even that simplest of programs, the classic 'Hello, World', will no > | longer work in its current form. > > That change is however, the one most immediately visible to new > programmers. Most of the other statements are pretty much unchanged. In > any case, 'print' is an easy-to-use facade over sys.stdout.write(), with > default formatting. If really concerned about it, start programs with > import sys > write = sys.stdout.write > and use that to write out explicitly formatted strings. (Some people > routinely do this for production code anyway.) > > tjr Some C tragics do things like this, which appear to be 3.0-proof: def fprintf(f, fmt, *vargs): f.write(fmt % vargs) Cheers, John From gagsl-py2 at yahoo.com.ar Mon Apr 7 02:00:08 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 07 Apr 2008 03:00:08 -0300 Subject: how to do "load script; run script" in a loop in embedded python? References: <352f4111-94b5-4aa9-917b-90cd56a5f7d6@s8g2000prg.googlegroups.com> Message-ID: En Thu, 03 Apr 2008 20:52:31 -0300, escribi?: > Hi, all, > > I am currently involved in a project that needs to load/run a python > script dynamically in a C application. The sample code is as > following: > > PyObject *LoadScript(char *file, char *func) > { > PyObject *pName, *pModule, *pDict, *pFunc; > > pName = PyString_FromString(file); > pModule = PyImport_Import(pName); > pDict = PyModule_GetDict(pModule); > pFunc = PyDict_GetItemString(pDict, func); > return pFunc; > } Remember to check all PyObject* return values, NULL means there was an error. And pay attention to reference counts! Read the section about reference counts in both books, Extending and Embedding, and the Python API Reference. http://docs.python.org/ > The first loop is perfectly ok, but on the second loop, script loading > is successful but running will always fail. "fail" in what form? A Python exception? The program freezes? A core dump? -- Gabriel Genellina From carlwuhwdmckay at gmail.com Sat Apr 26 09:36:03 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:36:03 -0700 (PDT) Subject: num-lock serial crack keygen Message-ID: <3d1e4ae9-fa1c-4c89-94fc-724ddc9cba78@x41g2000hsb.googlegroups.com> num-lock serial crack keygen http://cracks.00bp.com F R E E C R A C K S From inq1ltd at inqvista.com Sun Apr 6 20:41:05 2008 From: inq1ltd at inqvista.com (jim-on-linux) Date: Sun, 06 Apr 2008 20:41:05 -0400 Subject: Tkinter, repaint?, keep size? In-Reply-To: <200804062012.01208.inq1ltd@inqvista.com> References: <6ff2ce5f-9ba3-492c-b062-324c91e652a0@e10g2000prf.googlegroups.com> <200804062012.01208.inq1ltd@inqvista.com> Message-ID: <200804062041.05813.inq1ltd@inqvista.com> On Sunday 06 April 2008 20:12, jim-on-linux wrote: > On Sunday 06 April 2008 13:24, > > skanemupp at yahoo.se wrote: > > so my calculator is almost done for u > > that have read my previous posts. > > i have some minor problems i have to fix > > though. > > > > *one is i need to repaint once i have > > performed a calculation so that the old > > results are not left on the screen. cant > > find a method for that. > > you can use "wigit".update(). > The update method update will redraw > wigits as necessary. If you have the > state of the wigit set to DISABLE then set > it to ACTIVE before using .update(). > > > *another is now when i write the > > expression to be evaluated it resizes > > the window as the text grows. > > i want the windowsize and all the > > buttonplacements stay constant, how do > > i achieve this? > > I like to make a separate frame for > buttons. > > master = Tk() > master.title =('My Project') > > buttonFrame = Frame(master) > buttonFrame.grid(row = 0 column = 1) > > you could use a dictionary that contains > the the text and the command and loop the > key to build the buttons. Make x = x+1, y > = y+1 for row and column or otherwise as > you need. > If you loop the button you should provide a unique name for each button such as name = name+str(x) > button = Button(buttonframe, text = key, > width = 2) > button1.grid(row = x, column = y, sticky = > NSEW) > > put other stuff into the master using > another frame and grid it in some other > column and or row. > > If you make all buttons the same size > inside the frame they will keep their size > even if you have more text then the button > will hold. > > There is a lot more but this is the way I > would proceed. > > jim-on-linux http://www.inqvista.com From javainthinking at gmail.com Wed Apr 2 11:27:58 2008 From: javainthinking at gmail.com (Dolphin.o0O...) Date: Wed, 2 Apr 2008 23:27:58 +0800 Subject: Hello, everybody! Message-ID: C++ Java Python All of them are critical! -- Best regards. Yours sincerely, Dolphin.o0O... ~~~~~~~~~~~~~~~~~~~~~~~~~~ Dedicate in what you love so much! Dolphin.o0O.... ~~~~~~~~~~~~~~~~~~~~~~~~~~ -------------- next part -------------- An HTML attachment was scrubbed... URL: From deets at nospam.web.de Tue Apr 15 17:18:54 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 15 Apr 2008 23:18:54 +0200 Subject: webcam (usb) access under Ubuntu In-Reply-To: References: <66jlk1F2ju6c8U1@mid.uni-berlin.de> Message-ID: <66kkedF2l526dU2@mid.uni-berlin.de> Berco Beute schrieb: > Thanks, that would be great. Here you go. http://roggisch.de/vidio.tgz Diez From pavlovevidence at gmail.com Mon Apr 21 10:29:31 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 21 Apr 2008 07:29:31 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: On Apr 21, 9:20 am, a... at pythoncraft.com (Aahz) wrote: > In article , > Carl Banks wrote: > > > > >On Apr 20, 10:57 pm, a... at pythoncraft.com (Aahz) wrote: > >> In article , > >> Carl Banks wrote: > >>>On Apr 17, 3:37 am, Jonathan Gardner > >>>wrote: > > >>>> Using 100% of the CPU is a bug, not a feature. > > >>>No it isn't. That idea is borne of the narrowmindedness of people who > >>>write server-like network apps. What's true for web servers isn't > >>>true for every application. > > >> Only when you have only one application running on a machine. > > >Needless pedantry. > > >"Using 100% of the CPU time a OS allow a process to have is not > >necessarily a bug." Happy? > > Not really; my comment is about the same level of pedantry as yours. > Jonathan's comment was clearly in the context of inappropriate CPU usage > (e.g. spin-polling). That's far from evident. Jonathan's logic went from "I'm using 100% CPU" to "You must be spin-polling". At best, Jonathan was making some unsupported assumptions about the type of program sturlamolden had in mind, and criticized him based on it. But frankly, I've seen enough people who seem to have no conception that anyone could write a useful program without an I/O loop that it wouldn't surprise me it he meant it generally. > Obviously, there are cases where hammering on the > CPU for doing a complex calculation may be appropriate, but in those > cases, you will want to ensure that your application gets as much CPU as > possible by removing all unnecessary CPU usage by other apps. Nonsense. If I'm running a background task on my desktop, say formating a complex document for printing, I would like it to take up as much of CPU as possible, but still have secondary priority to user interface processes so that latency is low. Carl Banks From gagsl-py2 at yahoo.com.ar Fri Apr 4 02:56:37 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 04 Apr 2008 03:56:37 -0300 Subject: regarding memoize function References: <94a9e7e6-a623-4783-81da-f69654e51349@e10g2000prf.googlegroups.com> <80ee9d89-12a1-4534-be50-ac4614c28bc2@l42g2000hsc.googlegroups.com> Message-ID: En Fri, 04 Apr 2008 02:24:14 -0300, escribi?: > On Apr 3, 8:04?pm, "Gabriel Genellina" wrote: >> En Thu, 03 Apr 2008 21:21:11 -0300, Dan Bishop ? >> escribi?: >> > On Apr 3, 6:33 pm, ankitks.mi... at gmail.com wrote: >> >> I saw example of memoize function...here is snippet >> >> >> def memoize(fn, slot): >> >> ? ? ? ?def memoized_fn(obj, *args): >> >> ? ? ? ? ? ? if hasattr(obj, slot): >> >> ? ? ? ? ? ? ? ? return getattr(obj, slot) >> >> ? ? ? ? ? ? else: >> >> ? ? ? ? ? ? ? ? val = fn(obj, *args) >> >> ? ? ? ? ? ? ? ? setattr(obj, slot, val) >> >> ? ? ? ? ? ? ? ? return val >> >> ? ? ? ?return memoized_fn >> > Thanks Gabriel and Dan, > But I am still confuse on... > what is obj? > > Let say > def f(node): return max(node.path_cost+h(node), getattr(node, 'f', - > infinity)) > f = memoize(f,'f') > > what is this doing? > I am passing string 'f' as second argument? right? so evertime in > function memoize, > I am doing hasattr(obj, slot), I am saying hasattr(obj, 'f')? > > I kindof understand that I am returning maximum of pre-computed > value(if there is already) vs. new calculation. > But syntax is throwing me off. It *is* confusing. And a bit strange that it does not use the args argument as a key (if it is true that f(*args) doesn't depend on args, why using args in the first place?) You may be calling f as f(a,b,c) or as a.f(b,c) - in both cases, obj is `a`, the first argument (or "self" when used as a method) An alternative version (with the same limitations with regard to *args) but usable as a mehtod decorator: from functools import wraps def memoize(slot): def decorator(fn, slot=slot): @wraps(fn) def inner(self, *args): if hasattr(self, slot): return getattr(self, slot) else: val = fn(self, *args) setattr(self, slot, val) return val return inner return decorator class Foo(object): def __init__(self, items): self.items = tuple(items) @memoize('max') def hardtocompute(self): return max(self.items) a = Foo((10,20,30)) assert not hasattr(a,'max') assert a.hardtocompute()==30 assert a.max==30 del a.items assert a.hardtocompute()==30 There is an excelent article by Michele Simionato explaining decorators with some useful recipes. http://www.phyast.pitt.edu/~micheles/python/documentation.html -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Wed Apr 2 18:04:30 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 02 Apr 2008 19:04:30 -0300 Subject: generator functions: why won't this work? References: <19359dad-3022-4e83-99e4-8f8093116bcb@a1g2000hsb.googlegroups.com> Message-ID: En Wed, 02 Apr 2008 14:11:30 -0300, escribi?: > On Apr 1, 10:42?pm, "Gabriel Genellina" > wrote: >> En Tue, 01 Apr 2008 23:56:50 -0300, escribi?: >> >> ? ?yield *iterable >> >> could be used as a shortcut for this: >> >> ? ?for __temp in iterable: yield __temp > > How serious were you about that? Not so much, I haven't thougth enough on it. Looks fine in principle, but yield expressions may be a problem. -- Gabriel Genellina From sierra9162 at gmail.com Wed Apr 16 11:25:21 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:25:21 -0700 (PDT) Subject: kate hudson son Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From chengiz at my-deja.com Sat Apr 19 10:43:16 2008 From: chengiz at my-deja.com (chengiz at my-deja.com) Date: Sat, 19 Apr 2008 07:43:16 -0700 (PDT) Subject: Kill an OS process from script (perhaps unix specific) Message-ID: <7cd7208f-777b-4264-8d34-3c4bf3377940@a22g2000hsc.googlegroups.com> Hi, I'm trying to run a process from a python script. I need the exit status of that process but do not care about its output, so until now was using os.system(). But it turned out that the process often went into an infinite loop, so I wrote a SIGALRM handler. Unfortunately the code I came up with is quite kludgy: import subprocess ... try: p = subprocess.Popen(..., shell = True) pid = p.pid os.waitpid(pid...) ... except ...: # Thrown by alarm signal handler os.kill(pid + 1) # "Real" pid = shell pid + 1 ... The os.kill is very hacky and unsafe so I was looking for better ideas. Any help will be greatly appreciated. Thanks! From bruno.desthuilliers at gmail.com Sat Apr 19 12:01:29 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Sat, 19 Apr 2008 09:01:29 -0700 (PDT) Subject: Metaprogramming Example References: <930643c6-2d56-4fb0-aee0-a3e79231f09b@24g2000hsh.googlegroups.com> <32472b97-f35a-4408-96f5-2f8c8f92ae56@m73g2000hsh.googlegroups.com> <39325652-e0cf-4efd-9b28-00c0fe8552cc@m73g2000hsh.googlegroups.com> <562bae18-7b8e-4863-8923-0e5a01ba7125@t54g2000hsg.googlegroups.com> <48086036$0$759$426a74cc@news.free.fr> Message-ID: <480f371e-3957-4787-b3cd-0c00f4754a02@f36g2000hsa.googlegroups.com> On 19 avr, 16:34, andrew cooke wrote: > On Apr 18, 4:48 am, Bruno Desthuilliers wrote: > > [...] > > > Practically, this means that (amongst other niceties) : > > - you can define functions outside classes and use them as instance or > > class methods > > - you can add/replaces methods dynamically on a per-class or > > per-instance basis > > - you can access the function object of a method and use it as a function > > - you can define your own callable types, that - if you implement the > > appropriate support for the descriptor protocol - will be usable as > > methods too > > ok, that's convincing (i had thought the majority of these were > already > possible, albeit with some kind of hard-coded "magic" behind the > scenes). Yep, the whole point is that it's not that hard-coded anymore. Python exposes most of it's inner mechanisms, so that you can taylor quite a lot of things to your needs. This is quite useful for writing clean frameworks needing very few boilerplate in the user code. > [...] > > > > by referring to the titanic > > > i didn't mean that python was a disaster, rather that the "iceberg" is > > > still there (i am not 100% sure what the iceberg is, but it's > > > something > > > to do with making namespaces explicit in some places and not others). > > > I guess you're thinking of the self argument, declared in the function's > > signature but not "explicitly passed" when calling the method ? > > not really. more to do with when namespaces (i am not sure i have the > right term - the dictionary that provides the mapping from name to > object) > are explicit or implicit. for example, python has closures (implicit > lookup) and "self" (explicit lookup). > > but as i said, i don't have a clear argument - something just feels > "odd". > at the same time, i know that language design is a practical business > and so this is probably not important. The fact is that everything you do with closures can be done with objects. OTHO, there are quite a lot of cases where defining a specific class would be just way too heavy, and a closure is much more lightweight. So yes, it's a matter of "practicality beats purity". While trying to remain as clean as possible, Python is definitively a practical language. > finally, thank you for pointing me to sql alchemy (i think it was > you?). Seems so. > it really is excellent. Indeed !-) From jywlsn at comcast.net Mon Apr 14 03:55:40 2008 From: jywlsn at comcast.net (J Wilson) Date: Mon, 14 Apr 2008 02:55:40 -0500 Subject: How to get the version of a file Message-ID: Does anyone know how to get the version of an application on OS X (i.e. the version string that appears in the "Version" field in the "Get Info" window for an application)? I'm running OS 10.4.11, python 2.5. From NikitaTheSpider at gmail.com Tue Apr 22 10:54:00 2008 From: NikitaTheSpider at gmail.com (Nikita the Spider) Date: Tue, 22 Apr 2008 10:54:00 -0400 Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> Message-ID: In article <7e595409-be62-4b8c-9819-a14cd363d751 at c65g2000hsa.googlegroups.com>, azrael wrote: > Which big aplications are written in python. I see its development, > But i can't come up with a big name. I know that there are a lot of > companys using python, but is there anythong big written only in > python. I want him to fuck of with his perl once and for all time Why are either of you so emotionally attached to the tools you use? I don't know your friend, but my guess is that he's not interested in a logical argument, so he won't be impressed even if you claim that God himself wrote the Universe in Python. I think he enjoys saying this stuff simply because you react to it. It's pretty sad that he can't find something better to do with his time. If Python works for you and Perl for your friend, you can each keep using the tool you prefer and be happy about it. In the meantime you might want to look for some friends that don't find your anger and frustration entertaining. -- Philip http://NikitaTheSpider.com/ Whole-site HTML validation, link checking and more From harvey.thomas at informa.com Tue Apr 29 10:50:46 2008 From: harvey.thomas at informa.com (harvey.thomas at informa.com) Date: Tue, 29 Apr 2008 07:50:46 -0700 (PDT) Subject: Issue with regular expressions References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Message-ID: On Apr 29, 2:46?pm, Julien wrote: > Hi, > > I'm fairly new in Python and I haven't used the regular expressions > enough to be able to achieve what I want. > I'd like to select terms in a string, so I can then do a search in my > database. > > query = ' ? " ?some words" ?with and "without ? ?quotes ? " ?' > p = re.compile(magic_regular_expression) ? $ <--- the magic happens > m = p.match(query) > > I'd like m.groups() to return: > ('some words', 'with', 'and', 'without quotes') > > Is that achievable with a single regular expression, and if so, what > would it be? > > Any help would be much appreciated. > > Thanks!! > > Julien You can't do it simply and completely with regular expressions alone because of the requirement to strip the quotes and normalize whitespace, but its not too hard to write a function to do it. Viz: import re wordre = re.compile('"[^"]+"|[a-zA-Z]+').findall def findwords(src): ret = [] for x in wordre(src): if x[0] == '"': #strip off the quotes and normalise spaces ret.append(' '.join(x[1:-1].split())) else: ret.append(x) return ret query = ' " Some words" with and "without quotes " ' print findwords(query) Running this gives ['Some words', 'with', 'and', 'without quotes'] HTH Harvey From bearophileHUGS at lycos.com Tue Apr 8 18:21:19 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Tue, 8 Apr 2008 15:21:19 -0700 (PDT) Subject: Data structure recommendation? References: <1adc3541-7775-4938-bd5a-953dd041656c@2g2000hsn.googlegroups.com> Message-ID: More bits from your code: neighbours = list() ==> neighbours = [] If you have a recent enough version of Python you can use: candidate_is_neighbour = any(distance < n[1] for n in neighbours) Instead of: candidate_is_neighbour = bool([1 for n in neighbours if distance < n[1]]) It's shorter & simpler, and it stops as soon as it finds a true condition. Bye, bearophile From tim.arnold at sas.com Tue Apr 8 13:03:06 2008 From: tim.arnold at sas.com (Tim Arnold) Date: Tue, 8 Apr 2008 13:03:06 -0400 Subject: set file permission on windows Message-ID: hi, I need to set file permissions on some directory trees in windows using Python. When I click on properties for a file and select the 'Security' tab, I see a list of known 'Group or user names' with permissions for each entry such as Full Control, Modify, Read&Execute, etc. I need to (for example) periodically set Group Permissions for one group to Read, and another Group to None. I need to apply the settings to several directory trees recursively. If this was on Unix, I'd just use os.stat I guess. I don't think that will work in this case since all I know is the Group names and the permissions I need to allow. thanks for any pointers, --Tim Arnold From juergen.perlinger at t-online.de Sun Apr 20 15:53:32 2008 From: juergen.perlinger at t-online.de (Juergen Perlinger) Date: Sun, 20 Apr 2008 21:53:32 +0200 Subject: What happened with python? messed strings? References: Message-ID: algaba at droog.sdf-eu.org wrote: > > Hi, > I used extensively python and now I find this mess with strings, > I can't even reproduce tutorial examples: >>>> "apfel".encode('utf-8') (it was with umlaut) > File "", line 0 > > ^ > SyntaxError: 'ascii' codec can't decode byte 0xc4 in position 1: > ordinal not in range(128) >>>> > Is there any good guide to this mess of codecs and hell ? > > python should have stayed at version 1.5, every single 'improvement' > has been a mess. But this is the definitive hell. > > thanks! > Basically you're not using ASCII encoding in your source text... You need to define an encoding for your source if you're using german umlauts or other fancy stuff. See chapter 2.1.4 of the reference manual, and add e.g. # -*- coding: utf-8 -*- as first or second line to your script. Make sure your editor talks utf-8, or use the encoding used by your editor. cp1552 is a good choice for windows... -- juergen 'pearly' perlinger "It's hard to make new errors!" From john00587 at gmail.com Mon Apr 21 01:42:24 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:42:24 -0700 (PDT) Subject: cracks in skin caused by medication Message-ID: cracks in skin caused by medication http://cracks.00bp.com F R E E C R A C K S From gruszczy at gmail.com Wed Apr 23 05:52:28 2008 From: gruszczy at gmail.com (=?UTF-8?Q?Filip_Gruszczy=C5=84ski?=) Date: Wed, 23 Apr 2008 11:52:28 +0200 Subject: Explicit variable declaration In-Reply-To: <1506f165-7f86-4dc7-aa29-6488eda9ae7f@l64g2000hse.googlegroups.com> References: <1506f165-7f86-4dc7-aa29-6488eda9ae7f@l64g2000hse.googlegroups.com> Message-ID: <1be78d220804230252n4faa34e6v90b482080750e0cb@mail.gmail.com> > You mean the type? Not in 2.x, but in 3.x, there are function > annotations: > > def a_function(arg1: int, arg2: str) -> None: pass Nope, I don't like types ;-) 3.x seems pretty revolutionary, and this typing can be appreciated by some people. > Declaring what about them? If you mean declaring the type, remember > that Python deliberately allows any name to be bound to any object; > type declarations can't be enforced without losing a lot of the power > of Python. Just declaring, that they exist. Saying, that in certain function there would appear only specified variables. Like in smalltalk, if I remember correctly. -- Filip Gruszczy?ski From dhubleizh at o2.pl Tue Apr 22 08:02:21 2008 From: dhubleizh at o2.pl (=?iso-8859-2?q?Cezary_Krzy=BFanowski?=) Date: Tue, 22 Apr 2008 14:02:21 +0200 Subject: Remove multiple inheritance in Python 3000 References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> Message-ID: Dnia Tue, 22 Apr 2008 04:07:01 -0700, GD napisa?(a): > Please remove ability to multiple inheritance in Python 3000. > Please send me 1 mln $. I've always wanted to be rich and furthermore, I've got a lot of plans and ideas how to spend that cash. > I also published this request at http://bugs.python.org/issue2667 I'll be not publishing the bug, as I don't want to leave trace, so that I don't have to pay taxes. With regards, Cz at rny From vijayakumar.subburaj at gmail.com Mon Apr 14 04:00:05 2008 From: vijayakumar.subburaj at gmail.com (v4vijayakumar) Date: Mon, 14 Apr 2008 01:00:05 -0700 (PDT) Subject: Game design : Making computer play References: Message-ID: On Apr 14, 12:35 pm, Richard Heathfield wrote: > v4vijayakumar said: > > In computer based, two player, board games, how to make computer play? > > Write some code that works out what the computer player should do. If you > want a better answer, ask a better question. I am just implementing a game played in my village (Tamilnadu / India), called "aadupuli" (goats and tigers). There are only 23 positions and 18 characters (15 goats and 3 tigers). Some of you might be aware of this. I can post initial version of the game (implemented using html/ javascript) in couple of hours here. Welcome any help in making computer to play one of these player. From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 11 08:26:23 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 11 Apr 2008 14:26:23 +0200 Subject: from __future__ import print In-Reply-To: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> References: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> Message-ID: <47ff58e9$0$20006$426a74cc@news.free.fr> samslists at gmail.com a ?crit : > Am I the only one that thinks this would be useful? :) > > I'd really like to be able to use python 3.0's print statement in > 2.x. FWIW, the whole point is that in 3.0, print stop being a statement to become a function... From pranny at gmail.com Wed Apr 2 13:51:39 2008 From: pranny at gmail.com (pranav) Date: Wed, 2 Apr 2008 10:51:39 -0700 (PDT) Subject: Understanding bmp image files Message-ID: <2537c458-b4d5-480d-8407-168a2b59a27e@u10g2000prn.googlegroups.com> Hello, I want to read a BMP file, do some processing and then write it in a new file. The problem is in the third step. For reading the file, i have converted the file into decimal numbers, representing the pixel values. Then i perform calculations on those decimal numbers. Now i am unable to convert those into the format as required by the "bmp" file. Any one, who is into image reading/manipulation, please help. From nagle at animats.com Fri Apr 25 10:53:34 2008 From: nagle at animats.com (John Nagle) Date: Fri, 25 Apr 2008 07:53:34 -0700 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. In-Reply-To: <7xzlrj14r7.fsf@ruckus.brouhaha.com> References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> <480fa6e3$0$34491$742ec2ed@news.sonic.net> <7xzlrj14r7.fsf@ruckus.brouhaha.com> Message-ID: <4811edad$0$34525$742ec2ed@news.sonic.net> Paul Rubin wrote: > Paul Boddie writes: >> simple Python-only modules, all you'd really need to do to prove the >> concept is to develop the client-side Windows software (eg. apt-get >> for Windows) which downloads package lists, verifies signatures, and >> works out where to put the package contents. ... > > I thought the Windows "solution" to this was Authenticode, which is a > scheme for signing executables against certificates similar to those > used on SSL web sites. Of course there's been at least one notorious > forgery, but typical Linux distro repositories are probably not all > that secure either. > > In the case of a pure Python program like Beautiful Soup, I certainly > think any installation needing running code should be done by > distutils included in the Python distro. Yes. Perl has CPAN, which is reasonably comprehensive and presents modules in a uniform way. If you need a common Perl module that's not in the Perl distro, it's probably in CPAN. "Installing a new module can be as simple as typing perl -MCPAN -e 'install Chocolate::Belgian'." So Perl has exactly that. Python's Cheese Shop is just a list of links to packages elsewhere. There's no uniformity, no standard installation, no standard uninstallation, and no standard version control. John Nagle From wuwei23 at gmail.com Tue Apr 15 20:12:03 2008 From: wuwei23 at gmail.com (alex23) Date: Tue, 15 Apr 2008 17:12:03 -0700 (PDT) Subject: how to remove \n in the list References: <2ba667ab-6818-47eb-8595-79ed970728f7@q1g2000prf.googlegroups.com> Message-ID: On Apr 16, 9:26 am, Yves Dorfsman wrote: > If we do: > lines[:] = [line.rstrip('\n') for line in lines] > > We reuse an existing list, therefore we are saving the time it takes to > create a new list ? So this is a performance issue ? I think it's more of a reference issue. You may have other labels already pointing to 'lines', if you want them to refer to the same, rstrip'd list, you'd do an in-place update like this. - alex23 From skanemupp at yahoo.se Thu Apr 10 12:36:38 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 09:36:38 -0700 (PDT) Subject: Tkinter, resize window, keep widgets relative placements? Message-ID: <6a656935-7c32-454c-ab72-30e7d7e84b40@u12g2000prd.googlegroups.com> the code is down below. when i click maximize window it looks terrible since the widgets are not keeping their relative size. i guess i could use pack or grid to do that instead of place? but i tried with pack and grid before and had trouble making it looking good. is it possible to have the minimized window just being placed in the middle without the distance between the buttons and entrys being enlonge>? from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") l = Label(mygui, text="Answer: ") l.place(relx=0.15, rely=0.2, anchor=CENTER) e = Entry(mygui) e.place(relx=0.48, rely=0.1, anchor=CENTER, width=173) c = Entry(mygui) c.place(relx=0.6, rely=0.2, anchor=CENTER) def Disp(nstr): e.insert(INSERT, nstr) def Calc(): expr=e.get() c.delete(0, END) try: c.insert(END, eval(expr)) except: c.insert(END, "Not computable") def Erase(): e.delete(0,END) c.delete(0, END) def Backspace(): a=len(e.get()) e.delete(a-1,END) #e.delete(INSERT, END) #e.delete(ANCHOR,END) x = 0.1 y = 0.4 for char in '123+456-789*0()/.': b = Button(mygui, text=char, command=lambda n=char:Disp(n), width=2, height=1) b.place(relx=x, rely=y, anchor=CENTER) x=x+0.1 if x==0.5: x=0.1 y=y+0.1 b = Button(mygui, text="^", command=lambda n="**":Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.8, anchor=CENTER) b = Button(mygui, text="C",command=Erase, width=2, height=1) b.place(relx=0.3, rely=0.8, anchor=CENTER) b = Button(mygui, text="c",command=Backspace, width=2, height=1) b.place(relx=0.4, rely=0.8, anchor=CENTER) b = Button(mygui, text="=",command=Calc, width=12, height=1) b.place(relx=0.25, rely=0.9, anchor=CENTER) mygui.mainloop() From deets at nospam.web.de Thu Apr 10 05:43:46 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 10 Apr 2008 11:43:46 +0200 Subject: urgent question, about filesystem-files References: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> <47FDD27E.1040204@islandtraining.com> <36e8a7020804100200m6c3a9a41h1ed3021b70f8a829@mail.gmail.com> <36e8a7020804100201x5cf16377gfedddc8647fe8e3a@mail.gmail.com> Message-ID: <6665rfF2j5ohkU1@mid.uni-berlin.de> bvidinli wrote: > this is for ensuring that file is not in use, ... > by any process ?in system.... How do you prevent the other processes that *might* access that file from doing so while *you* work on it? unless they cooperate using file-locks, you might end up with garbage. Diez From aladameh at gmail.com Wed Apr 2 03:09:55 2008 From: aladameh at gmail.com (Ramsey Nasser) Date: Wed, 2 Apr 2008 10:09:55 +0300 Subject: the scaling of pics in pygame In-Reply-To: <3de70275-c4d6-46f8-9700-17503a606c84@d62g2000hsf.googlegroups.com> References: <49d8b8ae-08e3-4e86-9ced-2804b6dec4e5@b5g2000pri.googlegroups.com> <3de70275-c4d6-46f8-9700-17503a606c84@d62g2000hsf.googlegroups.com> Message-ID: <76f39e0e0804020009s7211a0d5m1c5717a992d2a72f@mail.gmail.com> Isn't PIL best suited for things like this? The resize function should do what you're looking for: http://www.pythonware.com/library/pil/handbook/image.htm On Wed, Apr 2, 2008 at 6:59 AM, wrote: > On Apr 1, 9:44 pm, Jimmy wrote: > > Hi, everyone > > > > I am using Pygame to write a small program. I tried to load a .jpg > > picture into > > the screen, however, the size of the pic doesn't fit into the window > > properly. Can > > anyone tell me how to scale the picture into the window? > > You might get a quicker answer at pygame.org - check the mailing list > and/or docs. > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- nasser From mal at egenix.com Wed Apr 30 06:18:36 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Wed, 30 Apr 2008 12:18:36 +0200 Subject: Problem with variables assigned to variables??? In-Reply-To: References: Message-ID: <4818477C.5010308@egenix.com> On 2008-04-30 07:25, grepla at gmail.com wrote: > I have a simple line of code that requires the following inputs - an > input file, output file and a SQL expression. the code needs to be > run with several different SQL expressions to produce multiple output > files. To do this I first created a list of a portion of the output > filename: > mylist = ('name1', 'name2', 'name3') > > I also assigned variables for each SQL expression: > name1 = "\"field_a\" LIKE '021'" > name2 = "\"field_a\" LIKE '031'" > name3 = "\"field_a\" LIKE '041'" > > Notice the variable names are the same as the listmember strings, that > is intentional, but obviously doesn't work. > > the loop: > for listmember in mylist: > print listmember + ".shp", listmember > > my intended output is: > name1.shp "field_a LIKE '021' > name2.shp "field_a LIKE '031' > name3.shp "field_a LIKE '041' > > but, of course, the variable listmember returns the name of the > listmember which makes perfect sense to me: > name1.shp name1 > > So how can I iterate not only the filenames but the SQL expressions as > well? The Python way to do this would be to take two lists, one with the filenames and one with the SQL, and then iterate over them in parallel: for filename, sql_snippet in zip(filenames, sql_snippets): ... (there are also a couple of ways to use iterators to do the same) If you just want to get you code to work, use this: for listmember in mylist: print listmember + ".shp", locals()[listmember] -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 30 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From spe.stani.be at gmail.com Wed Apr 9 16:19:49 2008 From: spe.stani.be at gmail.com (SPE - Stani's Python Editor) Date: Wed, 9 Apr 2008 13:19:49 -0700 (PDT) Subject: Stani's python ide 'spe' editor problem References: Message-ID: <297b9940-8f49-4057-a9cf-a0345d20901e@q24g2000prf.googlegroups.com> Did you try to remove the .spe folder from your c:\Documents & Settings \username folder? Stani On Apr 9, 6:16?pm, Rick King wrote: > Hi everyone, > The editor inspeon my system (win XP home sp2) does not do automatic > indentation..... I can't figure out why - it used to. I'm set up with > subversion so I have the very latest stuff from Stani. It's amazing how > not having automatic indentation can make working in the ide such a pain. > > This has been going on for a while (like a few years), and the situation > is deteriorating - used to be that the indentation would work for a > while after restarting my system and then stop (until the next restart). > Now, with his latest stuff, it doesn't work at all. > > Because it used to reset with a restart, it must have something to do > with a dll, like the scintilla editor dll? But that's kind of hard to > believe: why would the editor dll care about indentation? > > Anyway, I am extremely frustrated. I've tried other ide's: pythonwin (I > found it inadequate for my purposes - why is a command line prompt > displayed in a dialog window?) - eclipse (editor is just ok, shell does > not have command history(!), and then *really* funky things started > happening that I could not explain and so had to stop using it) - idle > is good for small things and ok for larger projects but limited in general. > > I really likespeand want to continue using it. Stani himself seems > pretty unreachable. > > Does anyone have a clue for me about what the issue is? Is no one else > using this great ide? Or is no one else having this problem? > > Thanks for any help. > -Rick King > Southfield MI From sturlamolden at yahoo.no Thu Apr 24 23:27:32 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 20:27:32 -0700 (PDT) Subject: ctypes: return a pointer to a struct References: <846077c3-beaf-4ccd-83be-1e2168c4f7fe@c65g2000hsa.googlegroups.com> Message-ID: <4dda2bd7-3348-496e-a594-35da0a34d4de@x35g2000hsb.googlegroups.com> On Apr 25, 5:15 am, sturlamolden wrote: > First define a struct type IP2LocationRecord by subclassing from > ctypes.Structure. Then define a pointer type as > ctypes.POINTER(IP2LocationRecord) and set that as the function's > restype attribute. See the ctypes tutorial or reference for details. Which is to say: import ctypes class IP2LocationRecord(ctypes.Structure): _fields_ = [ ('country_short', ctypes.c_char_p), ('country_long', ctypes.c_char_p), ('region', ctypes.c_char_p), ('city', ctypes.c_char_p), ('isp', ctypes.c_char_p), ('latitude', ctypes.c_float), ('longitude', ctypes.c_float), ('domain', ctypes.c_char_p), ('zipcode', ctypes.c_char_p), ('timezone', ctypes.c_char_p), ('netspeed', ctypes.c_char_p), ] IP2LocationRecord_Ptr_t = ctypes.POINTER(IP2LocationRecord) function.restype = IP2LocationRecord_Ptr_t From gagsl-py2 at yahoo.com.ar Sat Apr 12 22:51:36 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 12 Apr 2008 23:51:36 -0300 Subject: String Literal to Blob References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> Message-ID: En Sat, 12 Apr 2008 22:14:31 -0300, Jason Scheirer escribi?: > On Apr 12, 2:44 pm, Steve Holden wrote: >> Victor Subervi wrote: >> > Well, as I mentioned before, I am sending text/html because the page, >> > like almost all web pages, has a whole lot more content than just >> > images. Or, perhaps you are suggesting I build my pages in frames, and >> > have a frame for every image. Unsightly! >> >> Dear Victor: >> >> If you cannot understand, after being told several times by different >> people, that pages with images in them are achieved by multiple HTTP >> requests, then there is little I can do to help you. >> [...] >> Please, do yourself a big favor and persist with this until you >> understand what you are doing wrong and how to serve dynamic images. It >> appears that the learning may be painful, but I guarantee it will be >> worthwhile. > > There _is_ a way to embed image data in HTML that is supported by > every major browser. It is ugly. Using the RFC 2397 (http:// > www.ietf.org/rfc/rfc2397) spec for data URLs you could go > > '' % base64.b64encode(image_data) Another alternative would be to generate a multipart/related document, but I think the OP will gain a lot more understanding the simple cases than using those esoteric features. -- Gabriel Genellina From manthra.mohan at gmail.com Fri Apr 25 09:07:13 2008 From: manthra.mohan at gmail.com (Krishna) Date: Fri, 25 Apr 2008 06:07:13 -0700 (PDT) Subject: Environment Variables Message-ID: Environment variable set up is the most confusing part for me all the time. Please help me with the following questions: When I install python in a new system, I will go to environment variables (system variables) and set "path" pointing to C:\Python25 and thats all I do. I type python from "cmd" window and its converting to python window for python execution. All fine up to this point. Now, I want to drag and drop python (.py) files to this window and execute it. My python files are located in different directories inside C: and outside C:. When I do that, I get errors and the file is not found and its not imported. ALso, inside the .py file, if I have a command to open a different file, it doesnt see that either. How do I overcome these basic difficulties in python. I wish I can open any file and work on that using python. Thanks for your help! Krishna From bronger at physik.rwth-aachen.de Mon Apr 21 03:16:15 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Mon, 21 Apr 2008 09:16:15 +0200 Subject: lost sourcecode: decompyle? Message-ID: <87mynn3cg0.fsf@physik.rwth-aachen.de> Hall?chen! Due to erroneous use of my VCS, I lost my revision of yesterday. All I have are the pyc v2.5 files. Unfortunately, decompyle can only handle v2.3. Can one convert this, e.g. by de-assembling, manual tweaking, and re-assembling? The result must not be perfect since I still have most content of the files. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From mwilson at the-wire.com Mon Apr 7 08:55:19 2008 From: mwilson at the-wire.com (Mel) Date: Mon, 07 Apr 2008 08:55:19 -0400 Subject: Is there any way to say ignore case with "in"? References: <47f692f3$0$759$bed64819@news.gradwell.net> <432d690f-44be-49a9-bc6a-1cf3445549d6@m71g2000hse.googlegroups.com> <47f8d5df$0$23304$9b622d9e@news.freenet.de> Message-ID: Paul McGuire wrote: > On Apr 6, 8:53 am, "Martin v. L?wis" wrote: >>>> I know I could use:- >>>> if lower(string1) in lower(string2): >>>> >>>> but it somehow feels there ought to be an easier (tidier?) way. >> Take, for example, U+017F, LATIN SMALL LETTER LONG S. It's .lower() is >> the same character, as the character is already in lower case. >> It's .upper() is U+0053, LATIN CAPITAL LETTER S. Notice that the LONG >> is gone - there is no upper-case version of a "long s". >> It's .upper().lower() is U+0073, LATIN SMALL LETTER S. >> >> So should case-insensitive matching match the small s with the small >> long s, as they have the same upper-case letter? [ ... ] >>>> [i for i in range(65536) if unichr(i).lower().upper() != > ... unichr(i).upper()] > [304, 1012, 8486, 8490, 8491] > > Instead of 15 exceptions to the rule, conversion to upper has only 5 > exceptions. So perhaps comparsion of upper's is, while not foolproof, > less likely to encounter these exceptions? Or at least, simpler to > code explicit tests. I don't know what meaning is carried by all those differences in lower-case glyphs. Converting to upper seems to fold together a lot of variant pi's and rho's which I think would be roughly a good thing. I seem to recall that the tiny iota (ypogegrammeni) has or had grammatical significance. The other effect would be conflating physics' Angstron unit and Kelvin unit signs with ring-a and K. Applicaton programmers beware. Mel. From ewertman at gmail.com Tue Apr 29 01:49:26 2008 From: ewertman at gmail.com (Eric Wertman) Date: Tue, 29 Apr 2008 01:49:26 -0400 Subject: python script as executable In-Reply-To: References: Message-ID: <92da89760804282249y10dd9987wacfaeafc14f681bb@mail.gmail.com> Try to ftp it in ascii mode, or find a dos2unix utility .. the file has probably got \r\n (windows) line terminators in it.. causes problems. I guess it's also possible that /usr/bin/env doesn't exist... not likely though. On Tue, Apr 29, 2008 at 1:36 AM, sandipm wrote: > Hi, > I have written a python script to run from cron. > I have put #!/usr/bin/env python at top. file executes correctly when > I run using python filename.py but > it fails to execute when try to run it like script/command. > it throws error: > :No such file or directory > > I am editing file from eclipse for python from windows. and then > uploading on linus machine to run it. > > > any pointers? > > sandip > -- > http://mail.python.org/mailman/listinfo/python-list > From jzshao1 at gmail.com Fri Apr 11 15:16:29 2008 From: jzshao1 at gmail.com (Jonathan Shao) Date: Fri, 11 Apr 2008 15:16:29 -0400 Subject: Question on threads Message-ID: Hi all, I'm a beginner to Python, so please bear with me. Is there a way of guarenteeing that all created threads in a program are finished before the main program exits? I know that using join() can guarentee this, but from the test scripts I've run, it seems like join() also forces each individual thread to terminate first before the next thread can finish. So if I create like 20 threads in a for loop, and I join() each created thread, then join() will in effect cause the threads to be executed in serial rather than in parallel. ~ Jon -- "Perhaps we all give the best of our hearts uncritically, to those who hardly think about us in return." ~ T.H.White -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at holdenweb.com Mon Apr 14 19:34:06 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 14 Apr 2008 19:34:06 -0400 Subject: py3k s***s In-Reply-To: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> Message-ID: Sverker Nilsson wrote: > do i dare to open a thread about this? > > come on you braver men > > we are at least not bought by g***le > > but why? others have said it so many times i think > > :-//// > > but why? a few syntactic 'cleanups' for the cost of a huge rewrite of > all the code that have been builtup from all the beginning when the > once great Python came along and people began to use it and write code > for it. Like all that code would have to be rewritten. blaah. > and i have perhaps been drinking but i have been p**d all week since i > began look into this:-( Perhaps you should sober up and look at the reality of Python 3, which has deliberately avoided a complete rewrite. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From iltchevi at gmail.com Sun Apr 27 16:31:01 2008 From: iltchevi at gmail.com (ici) Date: Sun, 27 Apr 2008 13:31:01 -0700 (PDT) Subject: Python equivalent to PHP's SPL __autoload() ?? References: <5bfb3fa2-652c-4ce5-b914-27ef21685c33@p25g2000pri.googlegroups.com> Message-ID: <50cb2fd1-022f-4d72-b95a-adb002ad0978@z72g2000hsb.googlegroups.com> On Apr 27, 10:34 pm, Ixiaus wrote: > I was curious (and have spent an enormous amount of time on Google > trying to answer it for myself) if Python has anything remotely > similar to PHP's SPL __autoload() for loading classes on the fly?? > > After digging through docs I feel doubtful there is such a language > feature, but, it is possible I missed something or maybe someone has > written an extension?!? > > Thanks in advance! from module_name include * Can do the magic. You can't learn Python from helps or internet, got a book. Learning Python: http://www.oreilly.com/catalog/lpython/ is a very good start :) From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 30 12:14:06 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 30 Apr 2008 18:14:06 +0200 Subject: printing inside and outside of main() module In-Reply-To: References: <9bd5c596-da19-4615-a4d8-e47b20cfb362@m73g2000hsh.googlegroups.com> Message-ID: <48189ac0$0$9742$426a74cc@news.free.fr> Peter Otten a ?crit : > korean_dave wrote: > >> This allows me to see output: >> >> ---begin of try.py >> print "Hello World" >> --end of try.py >> >> This DOESN'T though... >> >> --begin of try2.py >> def main(): >> return "Hello" > main() # add this >> --end of try2.py >> >> Can someone explain why??? > > Python doesn't call the main() function; you have to invoke it explicitly. And while we're at it, your main function *returns* a value, but doesn't *print* anything. From darian.schramm at gmail.com Thu Apr 10 14:53:24 2008 From: darian.schramm at gmail.com (darian schramm) Date: Thu, 10 Apr 2008 14:53:24 -0400 Subject: class In-Reply-To: <264666470804101008l3d6740c2ve76a81d1815f2d0d@mail.gmail.com> References: <264666470804101008l3d6740c2ve76a81d1815f2d0d@mail.gmail.com> Message-ID: <67edaf4b0804101153m2d37a7cbp8770b7206600ec61@mail.gmail.com> Your import statement is wrong. Try: from Mysqldb import Mysqldb in your session.py On Thu, Apr 10, 2008 at 1:08 PM, Arun ragini wrote: > Hi, > > I have create a class file named Mysqldb.py > > class Mysqldb: > def __init__(self, name): > #this where it tries to connect to database > self.ip = ip > print "Inializing session for name" > > def test(self): > print "worked" > > ----------------------------------------------------- > > now i'm trying initialize this another python file called session.py > > import Mysqldb > > def session(): > Sess = Mysqldb ("localbox") > > > when i try to run in using python session.py. > > i get error message > TypeError: 'module' object is not callable > > can any 1 help me on this. > > Thanks & Regards > Arun > > > -- > ----- > Fight back spam! Download the Blue Frog. > http://www.bluesecurity.com/register/s?user=YXJ1bnJhZ2luaQ%3D%3D > -- > http://mail.python.org/mailman/listinfo/python-list > -- Darian V Schramm From eduardo.padoan at gmail.com Tue Apr 1 15:42:36 2008 From: eduardo.padoan at gmail.com (Eduardo O. Padoan) Date: Tue, 1 Apr 2008 16:42:36 -0300 Subject: Is this a good time to start learning python? In-Reply-To: <1565ced8-afd7-4c32-a6ee-26f9b95d60bc@d45g2000hsc.googlegroups.com> References: <47f1140e$0$735$a729d347@news.telepac.pt> <88fa881e-e59b-4682-801c-90ef08a1480a@a22g2000hsc.googlegroups.com> <1565ced8-afd7-4c32-a6ee-26f9b95d60bc@d45g2000hsc.googlegroups.com> Message-ID: On Tue, Apr 1, 2008 at 4:20 PM, wrote: > > > > Please explain how the existence of Python 3.0 would break your production > > > > code. > > > > > The existence of battery acid won't hurt me either, unless I come into > > > contact with it. If one eventually upgrades to 3.0 -- which is > > > ostensibly the desired path -- their code could break and require > > > fixing. > > > > > And how would this happen? I dont know of any good software > > distribution that upgrades a component to another major revision > > without asking first. The desired path is that, if somene wants to > > port his software to Python 3.0, that he follow the migration plan. > > Of course, that's the point. If you want to upgrade to the next > version of Python, you have to fix your code. That stinks. Your > other alternative is to remain stuck with Python 2.x, but eventually > the support for that will dry up. "Eventually" it will take a decade to happen. 2.x support will not be dropped untill gets (much) more users than Python 3.x. > > Final users will install Python 3.0 as python3.0 anyway, with Python > > 2.x as default 'python' binary. > > > > > > Backward compatibility is important. C++ could break all ties with C > > > to "clean up" as well, but it would be a braindead move that would > > > break existing code bases upon upgrade. > > > > > C++ is not C. No one "upgrades" from C to C++. > > You misunderstand. C++ has a lot of "warts" to maintain backwards > compatibility with C. The standards committee could eliminate these > warts to make the language "cleaner", but it would break a lot of > systems. It would not "break" anything that not move from C to C++, this is my point. People not willing to take the migration path (porting to 2.6, using the -3 flag, refactoring and re-running the tests untill the warning are gone, using the 2to3 tool...) will not upgrade. No one will force you to do it. 2.6 will not desappear from the python.org site anytime soon. -- Eduardo de Oliveira Padoan http://www.advogato.org/person/eopadoan/ Bookmarks: http://del.icio.us/edcrypt From http Wed Apr 2 21:14:42 2008 From: http (Paul Rubin) Date: 02 Apr 2008 18:14:42 -0700 Subject: Summary of threading for experienced non-Python programmers? References: <87od8yolay.fsf@mulj.homelinux.net> <654ng1F2cvh8aU1@mid.uni-berlin.de> <87d4pe9caz.fsf@mulj.homelinux.net> <656vhnF2e9ao7U1@mid.uni-berlin.de> <8763v4otts.fsf@mulj.homelinux.net> <65fulvF2eiaalU1@mid.uni-berlin.de> <6224eb1e-0d48-47d7-bfcd-94e6dc9b5ce2@c19g2000prf.googlegroups.com> Message-ID: <7xprt7g2nx.fsf@ruckus.brouhaha.com> sturlamolden writes: > Python's standard library should have an asynch module that uses aio > on Linux and i/o completion ports on Windows. It should work with > files and tcp sockets alike. Lately I'm hearing that Linux's aio implementation doesn't work very well yet. It is fairly recent. It's possible that BSD's or Solaris's versions are better. From nick at stinemates.org Fri Apr 18 15:10:00 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 12:10:00 -0700 Subject: Getting subprocess.call() output into a string? In-Reply-To: <18c1e6480804151416j7dd49d78p8888132ca01a5237@mail.gmail.com> References: <18c1e6480804151416j7dd49d78p8888132ca01a5237@mail.gmail.com> Message-ID: <20080418191000.GI19281@deviL> On Tue, Apr 15, 2008 at 11:16:01PM +0200, David wrote: > > > > Still, about StringIO... > > > > The module description says you can use it to read and write strings > as files, not that you can use strings *everywhere* you can use files. > > In your specific case, StringIO doesn't work, because the stdout > redirection takes place at the operating system level (which uses real > file handles), rather than in a python library (for which StringIO > would probably work). > > David. > -- > http://mail.python.org/mailman/listinfo/python-list Just a note to all of those who are interested. I have yet to get this to work properly for an app which runs indefinitely and you want to read the output at a specified interval. Right now the only way I can read is if the _close() method has been called. Anyway, I wrote a wrapper around it so I could easily change the implementation if I could ever find a better solution. Here's my code: =========================== import subprocess import os import select class ProcessMonitor: def __init__(self): self.__process = None self.__stdin = None self.__stdout = None def _create(self, process): self.__process = subprocess.Popen(process, stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True) self.__stdin = self.__process.stdout self.__stdout = self.__process.stdout def _close(self): os.kill(self.__process.pid,9) def _listen(self): """ get from stdout """ return "".join(self.__stdout.readlines()) def _listen2(self): """ My attempt at trying different things. """ inp, out = self.__process.communicate("") print out -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From __peter__ at web.de Sun Apr 20 06:21:24 2008 From: __peter__ at web.de (Peter Otten) Date: Sun, 20 Apr 2008 12:21:24 +0200 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <2008041915243216807-bob@passcalnmtedu> Message-ID: Bob Greschke wrote: > On 2008-04-18 23:35:12 -0600, Ivan Illarionov > said: > >> On Sat, 19 Apr 2008 04:45:54 +0000, Ivan Illarionov wrote: >> >>> On Fri, 18 Apr 2008 22:30:45 -0500, Grant Edwards wrote: >>> >>>> On 2008-04-18, Bob Greschke wrote: >>>> >>>>> However, in playing around with your suggestion and Grant's code I've >>>>> found that the struct stuff is WAY slower than doing something like >>>>> this >>>>> >>>>> Value = (ord(Buf[s])*65536)+(ord(Buf[s+1])*256)+ord(Buf[s+2]) if >>>>> Value >>>>>> = 0x800000: >>>>> Value -= 0x1000000 >>>>> >>>>> This is almost twice as fast just sitting here grinding through a few >>>>> hundred thousand conversions (like 3sec vs. ~5secs just counting on my >>>>> fingers - on an old Sun...it's a bit slow). Replacing *65536 with >>>>> <<16 and *256 with <<8 might even be a little faster, but it's too >>>>> close to call without really profiling it. >>>> >>>> I didn't know speed was important. This might be a little faster >>>> (depending on hardware): >>>> >>>> Value = (ord(Buf[s])<<16) | (ord(Buf[s+1])<<8) | ord(Buf[s+2]) >>>> >>>> It also makes the intention a bit more obvious (at least to me). >>>> >>>> A decent C compiler will recognize that <<16 and <<8 are special and >>>> just move bytes around rather than actually doing shifts. I doubt the >>>> Python compiler does optimizations like that, but shifts are still >>>> usually faster than multiplies (though, again, a good compiler will >>>> recognize that multiplying by 65536 is the same as shifting by 16 and >>>> just move bytes around). >>> >>> So why not put it in C extension? >>> >>> It's easier than most people think: >>> >>> >>> from3bytes.c >>> ============ >>> #include >>> >>> PyObject* >>> from3bytes(PyObject* self, PyObject* args) { >>> const char * s; >>> int len; >>> if (!PyArg_ParseTuple(args, "s#", &s, &len)) >>> return NULL; >>> long n = (s[0]<<16) | (s[1]<<8) | s[2]; if (n >= 0x800000) >>> n -= 0x1000000; >>> return PyInt_FromLong(n); >>> } >>> >>> static PyMethodDef functions[] = { >>> {"from3bytes", (PyCFunction)from3bytes, METH_VARARGS}, {NULL, >>> NULL, 0, NULL}, >>> }; >>> >>> >>> DL_EXPORT(void) >>> init_from3bytes(void) >>> { >>> Py_InitModule("_from3bytes", functions); >>> } >>> >>> buildme.py >>> ========== >>> import os >>> import sys >>> from distutils.core import Extension, setup >>> >>> os.chdir(os.path.dirname(os.path.abspath(__file__))) sys.argv = >>> [sys.argv[0], 'build_ext', '-i'] setup(ext_modules = >>> [Extension('_from3bytes', ['from3bytes.c'])]) >>> >>> 'python buildme.py' will create '_from3bytes.so' file 'from _from3bytes >>> import from3bytes' will import C-optimized function >>> >>> Hope this helps. >> >> Sorry, >> the right code should be: >> >> PyObject* from3bytes(PyObject* self, PyObject* args) >> { >> const char * s; >> int len; >> if (!PyArg_ParseTuple(args, "s#", &s, &len)) >> return NULL; >> long n = ((((unsigned char)s[0])<<16) | (((unsigned >> char)s[1])<<8) | >> ((unsigned char)s[2])); >> if (n >= 0x800000) >> n -= 0x1000000; >> return PyInt_FromLong(n); >> } > > No thanks. Being able to alter and install these programs on whatever > computer they are installed on is more important than speed. I went > down the C-extension path years ago and it turned into a big mess. > Everything has to run on Sun's, Mac's, Linux and Windows without any > major hassels if they have to be changed. I can't reley on everything > the program needs to be rebuilt being installed beyond Python and > Tkinter (and pySerial and PIL for a couple of programs), which they > need to run. So no compiling and everything is in one file, in case a > new version has to be upgraded by a user by emailing it to them while > they're sitting on some mountain in Tibet. Just unzip, stick the .py > somewhere logical, (usually) double-click, and they are off and running. > > Bob Just for fun, here's a way to convert lots of 3-byte integers using PIL: from PIL import Image import array def int3_pil(s, trafo="\x00"*128+"\xff"*128): n = len(s)//3 im = Image.new("RGB", (n, 1)) im.fromstring(s) hi, mid, lo = im.split() sign = Image.new("L", (n, 1)) sign.fromstring(hi.tostring().translate(trafo)) im = Image.merge("RGBA", (lo, mid, hi, sign)) a = array.array("i") a.fromstring(im.tostring()) return a.tolist() Not as fast as I had hoped, though. Also, it needs some work to make it independent of the processor architecture. Peter From bob at passcal.nmt.edu Sat Apr 19 17:24:32 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Sat, 19 Apr 2008 15:24:32 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> Message-ID: <2008041915243216807-bob@passcalnmtedu> On 2008-04-18 23:35:12 -0600, Ivan Illarionov said: > On Sat, 19 Apr 2008 04:45:54 +0000, Ivan Illarionov wrote: > >> On Fri, 18 Apr 2008 22:30:45 -0500, Grant Edwards wrote: >> >>> On 2008-04-18, Bob Greschke wrote: >>> >>>> However, in playing around with your suggestion and Grant's code I've >>>> found that the struct stuff is WAY slower than doing something like >>>> this >>>> >>>> Value = (ord(Buf[s])*65536)+(ord(Buf[s+1])*256)+ord(Buf[s+2]) if >>>> Value >>>>> = 0x800000: >>>> Value -= 0x1000000 >>>> >>>> This is almost twice as fast just sitting here grinding through a few >>>> hundred thousand conversions (like 3sec vs. ~5secs just counting on my >>>> fingers - on an old Sun...it's a bit slow). Replacing *65536 with >>>> <<16 and *256 with <<8 might even be a little faster, but it's too >>>> close to call without really profiling it. >>> >>> I didn't know speed was important. This might be a little faster >>> (depending on hardware): >>> >>> Value = (ord(Buf[s])<<16) | (ord(Buf[s+1])<<8) | ord(Buf[s+2]) >>> >>> It also makes the intention a bit more obvious (at least to me). >>> >>> A decent C compiler will recognize that <<16 and <<8 are special and >>> just move bytes around rather than actually doing shifts. I doubt the >>> Python compiler does optimizations like that, but shifts are still >>> usually faster than multiplies (though, again, a good compiler will >>> recognize that multiplying by 65536 is the same as shifting by 16 and >>> just move bytes around). >> >> So why not put it in C extension? >> >> It's easier than most people think: >> >> >> from3bytes.c >> ============ >> #include >> >> PyObject* >> from3bytes(PyObject* self, PyObject* args) { >> const char * s; >> int len; >> if (!PyArg_ParseTuple(args, "s#", &s, &len)) >> return NULL; >> long n = (s[0]<<16) | (s[1]<<8) | s[2]; if (n >= 0x800000) >> n -= 0x1000000; >> return PyInt_FromLong(n); >> } >> >> static PyMethodDef functions[] = { >> {"from3bytes", (PyCFunction)from3bytes, METH_VARARGS}, {NULL, >> NULL, 0, NULL}, >> }; >> >> >> DL_EXPORT(void) >> init_from3bytes(void) >> { >> Py_InitModule("_from3bytes", functions); >> } >> >> buildme.py >> ========== >> import os >> import sys >> from distutils.core import Extension, setup >> >> os.chdir(os.path.dirname(os.path.abspath(__file__))) sys.argv = >> [sys.argv[0], 'build_ext', '-i'] setup(ext_modules = >> [Extension('_from3bytes', ['from3bytes.c'])]) >> >> 'python buildme.py' will create '_from3bytes.so' file 'from _from3bytes >> import from3bytes' will import C-optimized function >> >> Hope this helps. > > Sorry, > the right code should be: > > PyObject* from3bytes(PyObject* self, PyObject* args) > { > const char * s; > int len; > if (!PyArg_ParseTuple(args, "s#", &s, &len)) > return NULL; > long n = ((((unsigned char)s[0])<<16) | (((unsigned char)s[1])<<8) | > ((unsigned char)s[2])); > if (n >= 0x800000) > n -= 0x1000000; > return PyInt_FromLong(n); > } No thanks. Being able to alter and install these programs on whatever computer they are installed on is more important than speed. I went down the C-extension path years ago and it turned into a big mess. Everything has to run on Sun's, Mac's, Linux and Windows without any major hassels if they have to be changed. I can't reley on everything the program needs to be rebuilt being installed beyond Python and Tkinter (and pySerial and PIL for a couple of programs), which they need to run. So no compiling and everything is in one file, in case a new version has to be upgraded by a user by emailing it to them while they're sitting on some mountain in Tibet. Just unzip, stick the .py somewhere logical, (usually) double-click, and they are off and running. Bob From tommy.nordgren at comhem.se Thu Apr 10 14:20:19 2008 From: tommy.nordgren at comhem.se (Tommy Nordgren) Date: Thu, 10 Apr 2008 20:20:19 +0200 Subject: text adventure game problem In-Reply-To: References: Message-ID: <28A235C5-F5FE-4203-899D-4E843CEF90D3@comhem.se> On 9 apr 2008, at 03.01, corvettecraz92 at gmail.com wrote: > okay, I'm having this one problem with a text adventure game. It's > kind of hard to explain, but I'll do my best. > [code] > > def prompt_kitchen(): > global gold Python is not a suitable language for Text Adventure Development. You should use one of the several excellent free text adventure languages instead. In particular languages like TADS (The text adventure development system) have strong built-in support for the tricky command parsing. ----------------------------------- See the amazing new SF reel: Invasion of the man eating cucumbers from outer space. On congratulations for a fantastic parody, the producer replies : "What parody?" Tommy Nordgren tommy.nordgren at comhem.se From p.newbie at yahoo.com Wed Apr 16 20:58:10 2008 From: p.newbie at yahoo.com (python newbie) Date: Wed, 16 Apr 2008 17:58:10 -0700 (PDT) Subject: Logical Operator and code block not executing (newbie question) Message-ID: <101830.10301.qm@web45803.mail.sp1.yahoo.com> Hello, I am running into a small problem of not having a code block not executing after after a logical operator is true. What am I missing or doing wrong. Any thoughts or opinions would be greatly appreciated. The block that isn't being executed follows: elif (guess == the_number) and (tries < total_attempts): print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" print "The correct answer is: ", the_number Below is the complete script: #! /usr/bin/python # Aurthor: Me # Purpose: Demonstrates # Date: April 15, 2008 import random print "\tWelcome to 'Guess My Number'!" print "\nI'm thinking of a number between 1 and 100." print "Try to guess it in as few attempts as possible.\n" # set the initial values the_number = random.randrange(100) + 1 guess = int(raw_input("Take a guess: ")) tries = 1 total_attempts = 3 # guessing loop while (guess != the_number): if (guess > the_number) and (tries < total_attempts): print "Lower..." print "You have...", total_attempts - tries, "left." print "The correct answer is: ", the_number elif (guess < the_number) and (tries < total_attempts): print "Higher..." print "You have...", total_attempts - tries, "left." print "The correct answer is: ", the_number elif (guess == the_number) and (tries < total_attempts): print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" print "The correct answer is: ", the_number elif (tries >= total_attempts): print "You're out of guess" print "You have...", total_attempts - tries, "left." print "You need more practice." print "The correct answer is: ", the_number break else: print "You shouldn't see this message..." print "You have...", total_attempts - tries, "left." print "The correct answer is: ", the_number break guess = int(raw_input("Take a guess: ")) tries += 1 raw_input("\n\nPress the enter key to exit.") PS: I am new to coding & scripting. Pete --------------------------------- Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan_ml at behnel.de Wed Apr 9 16:18:27 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Wed, 09 Apr 2008 22:18:27 +0200 Subject: Stripping scripts from HTML with regular expressions In-Reply-To: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> References: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: <47FD2493.7050701@behnel.de> Michel Bouwmans wrote: > I'm trying to strip all script-blocks from a HTML-file using regex. You might want to take a look at lxml.html instead, which comes with an HTML cleaner module: http://codespeak.net/lxml/lxmlhtml.html#cleaning-up-html Stefan From v.softwaretester at gmail.com Sun Apr 20 14:51:16 2008 From: v.softwaretester at gmail.com (Software Testing) Date: Sun, 20 Apr 2008 14:51:16 -0400 Subject: I would like to learn scripting in Python too! Message-ID: <8339da0f0804201151s1ba691e3n970c2827abc22cae@mail.gmail.com> Hello There, I am a software tester and I see lot of testers on the forums saying Python is a wonderful scripting language that testers use on a daily basis. I would also like to learn to script in Python but I do not have any programming background. Please help Thanks Mansa -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at holdenweb.com Sun Apr 6 22:43:39 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 06 Apr 2008 22:43:39 -0400 Subject: ANN: pry unit testing framework In-Reply-To: <20080407023442.GA16373@nullcube.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> <20080407023442.GA16373@nullcube.com> Message-ID: <47F98A5B.8010000@holdenweb.com> Aldo Cortesi wrote: > Thus spake Ben Finney (bignose+hates-spam at benfinney.id.au): > >>> I'm afraid that Pry is unashamedly incompatible with any other unit >>> testing method in existence, including but not limited to doctest, >>> unittest, nose and py.test. ;) >> Which makes the deliberate deviations from PEP 8 naming a large black >> mark against it. > > You're misunderstanding the intent of PEP 8, which was never supposed > to dogmatically enforce a naming standard on all Python projects > everywhere. You're also vastly overstating the impact of a minor naming > convention choice. Calling this a "large black mark" smacks of > scare-mongering to me. > It probably reflects personal preference, but it's a preference that many people will maintain. I understand that PEP 008 was largely directed at standard library authors and maintainers, but anything that claims wide utility should have ambitions to be included in the standard library, and hence PEP 008 conformance would be a plus. >>> Some day I might experiment with extending Pry to gather and run >>> doctests and unittests. At this stage, however, I don't believe the >>> (significant) effort would be worth it. >> That's very unfortunate. Until it plays better with others, I don't >> believe the effort of using this package will be worth it. > > Each of the third-party testing frameworks that have cropped up in this > thread extends unittest in some incompatible way. If you use any of > these extensions, it means that your unit test suite is tied to that > particular test framework. If you have an existing suite of unit tests > that you can't or don't want to convert, I'm afraid that Pry is indeed > not for you. Pry is not intended to be a general engine for running > tests written for other frameworks. > A reasonable enough point of view, but it means that you are just one of a number of competing frameworks. While you are earnest about pry's advantages you have a lot of work to do to move people away form the entrenched testing frameworks they are used to. > I should also note that converting from unittest to Pry is quite simple > - Pry's test structure is a superset of unittest's, and AutoTree was > explicitly written to make "unittest-style" testing possible, meaning > that no _structural_ change is needed for conversion. The most onerous > part is converting to assertion-based testing, something that will > improve the clarity and readability of your tests anyway. > Time will tell. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From cmpython at gmail.com Wed Apr 2 15:04:07 2008 From: cmpython at gmail.com (CM) Date: Wed, 2 Apr 2008 12:04:07 -0700 (PDT) Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> <47f3c751$0$6477$4c368faf@roadrunner.com> Message-ID: <30730d40-8f7e-48bd-bb0f-3a95e814b20f@t54g2000hsg.googlegroups.com> On Apr 2, 2:50 pm, AK wrote: > Terry Reedy wrote: > > "AK" wrote in message > >news:47f2d018$0$6517$4c368faf at roadrunner.com... > > > || I'll be glad to hear comments/suggestions/etc: > > | > > |http://www.lightbird.net/py-by-example/ > > > Using - as the example/return delimiter does not work. > > If you do not want to substantially lengthen the document by going to > > >>>> sqrt(9) > > 3 > > > then use Python's a comment symbol. > > > sqrt(9) # 3 > > -or- > > sqrt(9) # returns 3 (but I think I prefer the first) > > > which clearly is not an arithmetic expression and which can be > > cut-and-pasted into the interactive interpreter. This also works nicely > > for invalid examples. > > > sqrt(-9) # raises ValueError > > > Terry Jan Reedy > > Thanks to everybody who replied, I will implement the change as per > Terry's advice. I'm still considering whether to use the standard > interpreter syntax, i.e. >>> ... \n result; my reason for not doing that > is that I will often have a whole screen of function / result lines and > if I were to add a new line for the result, that'd make two pages out of > one, which I think is a bit too much. In current docs there are not so > many examples, so that space is not multiplied quite so much, and using > interactive interpreter way of showing result is not nearly as much of > a problem. However, I'm still thinking this over and it seems that > almost everyone wants to see it done in that way, I might still go for > two lines. I'll also be posting updates as the work progresses.. > > thx, > > -- > -ak > Tobu |http://www.lightbird.net/tobu/| Freeform DB / Tagger / PIM > Python-by-Example |http://www.lightbird.net/py-by-example/| Guide > to LibRef You should also change the look of the page to be more high-contrast. The grayish text in a gray box and the light green text...all too subtle to see. Not easy for well-sighted people let alone those with poorer vision. Try make things visually very obvious, bolded headers, etc. If so, and with the change of showing the result not with an "-" symbol, it will be much stronger. Thank you for doing it. From lcordier at gmail.com Tue Apr 1 05:15:48 2008 From: lcordier at gmail.com (rootkill) Date: Tue, 1 Apr 2008 02:15:48 -0700 (PDT) Subject: counting using variable length string as base References: Message-ID: On Mar 27, 8:15 am, Grimsqueaker wrote: > Hi, I'm fairly new to Python and to this list. I have a problem that > is driving me insane, sorry if it seems simple to everyone, I've been > fighting with it for a while. :)) > > I want to take a variable length string and use it as a base for > counting, eg. given the string 'abc' the sequence would be: > > a > b > c > aa > ba > ca > ab > bb > cb > ... > ccc > > Basically I want to find every possible order of every combination. > Its easy if you know how many characters there will be in your string > (use nested for loops), but I am stuck with the variable length > string. I think I have to use a generator but I'm not sure exactly > how. > > Can anyone give me a pointer in the right direction? > > Thanks > Daniel Browne Since you didn't ask for the smallest solution I'll opt for the clearest one ;) I'll use the very usefull baseconvert, http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/111286 def baseconvert(number, fromdigits, todigits): if str(number)[0] == '-': number = str(number)[1:] neg = 1 else: neg = 0 # make an integer out of the number x = long(0) for digit in str(number): x = x * len(fromdigits) + fromdigits.index(digit) # create the result in base 'len(todigits)' res = '' if x == 0: res = todigits[0] while x > 0: digit = x % len(todigits) res = todigits[digit] + res x /= len(todigits) if neg: res = '-' + res return res BASE10 = '0123456789' s = 'abcdef' n = len(s) for i in xrange(n**n): print baseconvert(str(i), BASE10, s) You can also convert back, baseconvert('abaa', s, BASE10). Hope it helps. Regards, Louis. From bijeshn at gmail.com Mon Apr 7 06:20:00 2008 From: bijeshn at gmail.com (bijeshn) Date: Mon, 7 Apr 2008 03:20:00 -0700 (PDT) Subject: splitting an XML file on the basis on basis of XML tags References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> <47F9B845.9040205@behnel.de> Message-ID: <05edd42c-dd16-4364-92ca-43cdbb1ab547@r9g2000prd.googlegroups.com> the extracted files are to be XML too. ijust need to extract it raw (tags and data just like it is in the parent XML file..) From skanemupp at yahoo.se Thu Apr 10 13:22:57 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 10:22:57 -0700 (PDT) Subject: Tkinter, resize window, keep widgets relative placements? References: <6a656935-7c32-454c-ab72-30e7d7e84b40@u12g2000prd.googlegroups.com> Message-ID: <98e39774-cfa9-44c7-92ec-4c5aa0d3f431@p25g2000pri.googlegroups.com> here i didi it with pack() but when i try to use the answerwidget it gtes all f***** up. any suggestions? from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") ##l = Label(mygui, text="Answer: ") ##l.grid(row=2, column=1, columnspan=2) e = Entry(mygui) e.grid(row=1, column=1, columnspan=4) c = Entry(mygui) c.grid(row=2, column=1, columnspan=4) def Disp(nstr): e.insert(INSERT, nstr) def Calc(): expr=e.get() c.delete(0, END) try: c.insert(END, eval(expr)) except: c.insert(END, "Not computable") def Erase(): e.delete(0,END) c.delete(0, END) def Backspace(): a=len(e.get()) e.delete(a-1,END) #e.delete(INSERT, END) #e.delete(ANCHOR,END) x = 1 y = 4 for char in '123+456-789*0()/.': b = Button(mygui, text=char, command=lambda n=char:Disp(n), width=2, height=1) b.grid(row=y, column=x) x=x+1 if x==5: x=1 y=y+1 b = Button(mygui, text="^", command=lambda n="**":Disp(n), width=2, height=1) b.grid(row=8, column=2) b = Button(mygui, text="C",command=Erase, width=2, height=1) b.grid(row=8, column=3) b = Button(mygui, text="c",command=Backspace, width=2, height=1) b.grid(row=8, column=4) b = Button(mygui, text="=",command=Calc, width=18, height=1) b.grid(row=9, column=1, columnspan=8) mygui.mainloop() From silfheed at gmail.com Fri Apr 11 18:59:44 2008 From: silfheed at gmail.com (Silfheed) Date: Fri, 11 Apr 2008 15:59:44 -0700 (PDT) Subject: CDATA and lxml References: <5ebe3201-80a6-45ba-8b88-e8ece6883efa@w8g2000prd.googlegroups.com> <47FF368B.4030708@behnel.de> <47FFA0D7.1030901@behnel.de> <1d6d4a80-7031-441a-b242-e50ebcd51da9@w5g2000prd.googlegroups.com> Message-ID: <3ebbd54e-6cf2-4f49-b0c1-43e1eb16dfb0@n14g2000pri.googlegroups.com> On Apr 11, 3:49 pm, Silfheed wrote: > On Apr 11, 10:33 am, Stefan Behnel wrote: > > > > > Hi again, > > > Stefan Behnel wrote: > > > Silfheed wrote: > > >> So first off I know that CDATA is generally hated and just shouldn't > > >> be done, but I'm simply required to parse it and spit it back out. > > >> Parsing is pretty easy with lxml, but it's the spitting back out > > >> that's giving me issues. The fact that lxml strips all the CDATA > > >> stuff off isnt really a big issue either, so long as I can create > > >> CDATA blocks later with <>&'s showing up instead of <>& . > > >> I've scoured through the lxml docs, but probably not hard enough, so > > >> anyone know the page I'm looking for or have a quick how to? > > > > There's nothing in the docs because lxml doesn't allow you to create CDATA > > > sections. You're not the first one asking that, but so far, no one really had > > > a take on this. > > > So I gave it a try, then. In lxml 2.1, you will be able to do this: > > > >>> root = Element("root") > > >>> root.text = CDATA('test') > > >>> tostring(root)) > > '' > > > This does not work for .tail content, only for .text content (no technical > > reason, I just don't see why that should be enabled). > > > There's also a parser option "strip_cdata" now that allows you to leave CDATA > > sections in the tree. However, they will *not* behave any different than > > normal text, so you can't even see at the API level that you are dealing with > > CDATA. If you want to be really, really sure, you can always do this: > > > >>> root.text = CDATA(root.text) > > > Hope that helps, > > > Stefan > > That is immensely cool. Do you plan to stick it into svn soon? > Thanks! Ah, looks like it's there already. Very cool, very cool. Thanks again. From mitko at qlogic.com Tue Apr 22 13:13:25 2008 From: mitko at qlogic.com (Mitko Haralanov) Date: Tue, 22 Apr 2008 10:13:25 -0700 Subject: Segfault accessing dictionary in C Python module In-Reply-To: <365f11e2-6e3e-4e9c-bfda-7c4168a39769@u69g2000hse.googlegroups.com> References: <365f11e2-6e3e-4e9c-bfda-7c4168a39769@u69g2000hse.googlegroups.com> Message-ID: <20080422101325.0c43e24f@hematite.mv.qlogic.com> On Mon, 21 Apr 2008 17:09:57 -0700 (PDT) sturlamolden wrote: > Albeit not having looked at your code in detail, I'm wiling to bet you > have one of the refcounts wrong. It turns out you are correct. I forgot to increment the refcount on the value extracted from the dict (since PyDict_GetItem returns a borrowed reference). Once I did that, all was well. Thank you! -- Mitko Haralanov mitko at qlogic.com Senior Software Engineer 650.934.8064 HSG InfiniBand Engineering http://www.qlogic.com ========================================== Fry: Drugs are for losers, and hypnosis is for losers with big weird eyebrows. From grflanagan at gmail.com Thu Apr 24 05:52:21 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Thu, 24 Apr 2008 02:52:21 -0700 (PDT) Subject: Ideas for parsing this text? References: <84fd2882-f46d-43d4-9a1c-0b981fb45ad6@59g2000hsb.googlegroups.com> Message-ID: <7a1cd8a8-caf8-4b7a-9c16-e8067266b234@m73g2000hsh.googlegroups.com> On Apr 24, 4:05 am, Paul McGuire wrote: > On Apr 23, 8:00 pm, "Eric Wertman" wrote: > > > I have a set of files with this kind of content (it's dumped from WebSphere): > > > [propertySet "[[resourceProperties "[[[description "This is a required > > property. This is an actual database name, and its not the locally > > catalogued database name. The Universal JDBC Driver does not rely on > > ... > > A couple of comments first: > - What is the significance of '"[' vs. '[' ? I stripped them all out > using The data can be thought of as a serialised object. A simple attribute looks like: [name someWebsphereObject] or [jndiName []] if 'jndiName is None'. A complex attribute is an attribute whose value is itself an object (or dict if you prefer). The *value* is indicated with "[...]": [connectionPool "[[agedTimeout 0] [connectionTimeout 180] [freePoolDistributionTableSize 0] [maxConnections 10] [minConnections 1] [numberOfFreePoolPartitions 0] [numberOfSharedPoolPartitions 0] [unusedTimeout 1800]]"] However, 'propertySet' is effectively a keyword and its value may be thought of as a 'data table' or 'list of data rows', where 'data row' == dict/object You can see how the posted example is incomplete because the last 'row' is missing all but one 'column'. > text = text.replace('"[','[') > - Your input text was missing 5 trailing ]'s. > I think only 2 (the original isn't Python). To fix the example, remove the last 'description' and add two ]'s > Here's the parser I used, using pyparsing: > > from pyparsing import nestedExpr,Word,alphanums,QuotedString > from pprint import pprint > > content = Word(alphanums+"_.") | QuotedString('"',multiline=True) > structure = nestedExpr("[", "]", content).parseString(text) > > pprint(structure.asList()) > By the way, I think this would be a good example for the pyparsing recipes page (even an IBM developerworks article?) http://www.ibm.com/developerworks/websphere/library/techarticles/0801_simms/0801_simms.html Gerard example data (copied and pasted; doesn't have the case where a complex attribute has a complex attribute): [authDataAlias []] [authMechanismPreference BASIC_PASSWORD] [connectionPool "[[agedTimeout 0] [connectionTimeout 180] [freePoolDistributionTableSize 0] [maxConnections 10] [minConnections 1] [numberOfUnsharedPoolPartitions 0] [properties []] [purgePolicy FailingConnectionOnly] [reapTime 180] [surgeThreshold -1] [testConnection false] [testConnectionInterval 0] [unusedTimeout 1800]]"] [propertySet "[[resourceProperties "[[[description "This is a required property. This is an actual database name, and its not the locally catalogued database name. The Universal JDBC Driver does not rely on information catalogued in the DB2 database directory."] [name databaseName] [required true] [type java.lang.String] [value DB2Foo]] [[description "The JDBC connectivity-type of a data source. If you want to use a type 4 driver, set the value to 4. If you want to use a type 2 driver, set the value to 2. Use of driverType 2 is not supported on WAS z/OS."] [name driverType] [required true] [type java.lang.Integer] [value 4]] [[description "The TCP/IP address or name for the DRDA server."] [name serverName] [required false] [type java.lang.String] [value ServerFoo]] [[description "The TCP/IP port number where the DRDA server resides."] [name portNumber] [required false] [type java.lang.Integer] [value 007]] [[description "The description of this datasource."] [name description] [required false] [type java.lang.String] [value []]] [[description "The DB2 trace level for logging to the logWriter or trace file. Possible trace levels are: TRACE_NONE = 0,TRACE_CONNECTION_CALLS = 1,TRACE_STATEMENT_CALLS = 2,TRACE_RESULT_SET_CALLS = 4,TRACE_DRIVER_CONFIGURATION = 16,TRACE_CONNECTS = 32,TRACE_DRDA_FLOWS = 64,TRACE_RESULT_SET_META_DATA = 128,TRACE_PARAMETER_META_DATA = 256,TRACE_DIAGNOSTICS = 512,TRACE_SQLJ = 1024,TRACE_ALL = -1, ."] [name traceLevel] [required false] [type java.lang.Integer] [value []]] ]] From steve at holdenweb.com Fri Apr 25 00:30:02 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 25 Apr 2008 00:30:02 -0400 Subject: Little novice program written in Python In-Reply-To: References: Message-ID: Rog?rio Brito wrote: > Hi, All. > > I'm just getting my feet wet on Python and, just for starters, I'm > coding some elementary number theory algorithms (yes, I know that most > of them are already implemented as modules, but this is an exercise in > learning the language idioms). > > As you can see from the code below, my background is in C, without too > much sophistication. > > What I would like is to receive some criticism to my code to make it > more Python'esque and, possibly, use the resources of the computer in a > more efficient way (the algorithm implemented below is the Sieve of > Eratosthenes): > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > #!/usr/bin/env python > > n = int(raw_input()) > a = [i for i in range(0,n+1)] > a[1] = 0 # not a prime > prime = 1 # last used prime > finished = False > > while (not finished): > prime = prime + 1 > # find new prime > while prime*prime <= n and a[prime] == 0: > prime += 1 > # cross the composite numbers > if prime*prime <= n: > j = 2*prime > while j <= n: > a[j] = 0 > j += prime > else: > finished = True > > # print out the prime numbers > i = 2 > while i <= n: > if a[i] != 0: > print a[i] > i += 1 > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > Thank you for any help in improving this program, > Your Python is actually pretty good - if Raymond Hettinger pronounces it OK then few would dare to disagree. As for your English, though, the word you sought was "Pythonic" (not that you will ever find such a word in Webster's dictionary). To suggest that your code is Pythonesque would mean you found it farcical or ridiculous (like a Monty Python sketch), which it clearly is not. Another wrinkle you might consider is simply printing the primes out as they are generated rather than doing the printing in a separate loop, though whether that approach would be preferable in "real life" would depend on the application, of course. regards Steve PS: I think either my mailer or yours has mangled the indentation. -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From Scott.Daniels at Acm.Org Sat Apr 12 08:18:54 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Sat, 12 Apr 2008 05:18:54 -0700 Subject: About __init__ and default arguments In-Reply-To: References: Message-ID: Nathan Duran wrote: > > On Apr 11, 2008, at 11:35 AM, python-list-request at python.org wrote: >> I'd like to assign the value of an attribute in __init__ as the default >> value of an argument in a method. See below: > Why not just do > > def franklin(self, keyword): > if not keyword: keyword = self.default > return "A %s in time saves nine." % (keyword) Several things are false (for example: '', 0, False, [], ...) If you can get along with the code you have suggested, I'd think about using: def franklin(self, keyword): return "A %s in time saves nine." % (keyword or self.default) -Scott David Daniels Scott.Daniels at Acm.Org From martin at v.loewis.de Wed Apr 16 02:33:13 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Wed, 16 Apr 2008 08:33:13 +0200 Subject: Compiling Python 2.5.2 on AIX 5.2 In-Reply-To: References: <0b73e8e5-c301-4823-ac94-42f757456cf1@x19g2000prg.googlegroups.com> Message-ID: <48059DA9.5080900@v.loewis.de> > What is Py_UNICODE_SIZE and why was it not defined? There are current > questions I have. Py_UNICODE_SIZE is the number of bytes that a Py_UNICODE value should have in the interpreter. With --enable-unicode=ucs2, it should be 2. I cannot guess why it is not defined; check pyconfig.h to find out whether there is a definition. If not, look in your configure output for the line checking what type to use for unicode... and perhaps edit configure to print out additional messages around the place where it deals with Py_UNICODE. Regards, Martin From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Wed Apr 30 15:55:10 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Wed, 30 Apr 2008 21:55:10 +0200 Subject: I messed up my wxPython install (Eclipse Configuration Issue) References: <18eb0a7c-96f4-41de-b44f-95fd8ba0223f@f63g2000hsf.googlegroups.com> <436f8226-64a5-440a-92f4-afd7dd348e1c@m73g2000hsh.googlegroups.com> <20525ad9-2679-4bc8-a117-66eca4a8dc13@r66g2000hsg.googlegroups.com> Message-ID: <67s14vF2q5kh8U1@mid.individual.net> blaine wrote: > I didn't mean anything by it, I promise. This group is just > amazing - there are always very active topics and I get responses > in no time. The wxPython group I noticed only has had recent > discussions a few times in the past month, and their subscribers > aren't as high as the Python group. There _is_ a difference between quality and volume. Also, in some cases high quality goes along with low volume, as in others do high volume and low quality. Regards, Bj?rn -- BOFH excuse #34: (l)user error From nagle at animats.com Sun Apr 13 23:48:43 2008 From: nagle at animats.com (John Nagle) Date: Sun, 13 Apr 2008 20:48:43 -0700 Subject: Best way to update a settings file? In-Reply-To: <4802cb83$0$15190$607ed4bc@cv.net> References: <4802cb83$0$15190$607ed4bc@cv.net> Message-ID: <4802d18c$0$36323$742ec2ed@news.sonic.net> John Salerno wrote: > I'm thinking about writing a small script that will update an xml file > with whatever game settings the user enters. I imagine that the user > will have a single-screen GUI application with several different > settings, like this: > > CROSSHAIRS ON > LOCATION ON > HEALTHBAR OFF > etc..... > > These settings will somehow be toggleable with an ON/OFF button, or > something. > > Anyway, I can think of two ways to do this: > > 1. After the user chooses his settings and clicks the Save button, > Python reads all the settings from the GUI application and updates > *every* entry in the xml file (whether it has changed or not). > > 2. After the user chooses his settings and clicks the Save button, > Python reads all the settings from the GUI application, compares these > settings to those in the xml file, and updates only the ones that have > been changed. You can't write into the middle of an XML file effectively; any field that has changed length won't fit. You generally have to create a new XML file. Read this on how to replace a file with a new one, as an atomic operation: http://blogs.msdn.com/adioltean/archive/2005/12/28/507866.aspx If you really want to update files in place, use a database, like SQLite. If you find yourself rewriting big files for minor changes, switch to a database. For small files, just rewrite the whole thing. John Nagle From kyosohma at gmail.com Tue Apr 8 11:57:46 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 8 Apr 2008 08:57:46 -0700 (PDT) Subject: Problem with smtplib and py2exe References: <3ff2767a-bbd8-4e0e-bbf4-3fa72bdca5e7@8g2000hsu.googlegroups.com> <2f783320-3364-4954-b763-1f4f3fe1f26c@y21g2000hsf.googlegroups.com> Message-ID: On Apr 8, 10:17 am, Kevin wrote: > Thanks, Terry, you pointed me in the right direction with the > reference to the "DEBUG". > > I dug out my "Learning Python" book, to read up on the debugger, and > one of the things I came across was a section on IDLE's debugger. It > said essentially that if you get an error that doesn't make sense when > you're trying to run another program (in this case, py2exe) with IDLE, > then run the program from the command line instead. I did that, and > much to my surprise, I was able to generate the 'exe' that I needed. > > I guess the incompatibility isn't necessarily between 'py2exe' and > 'smtplib' after all, but between 'py2exe' and 'IDLE'. I also recommend trying out GUI2Exe, a cool GUI wrapper for the py2exe program that allows developers to create executables quickly and easily. It also saves all your settings, which is nice if you need to re-compile frequently. I found it here: http://xoomer.alice.it/infinity77/main/GUI2Exe.html Mike From landerdebraznpc at gmail.com Mon Apr 28 03:54:47 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:54:47 -0700 (PDT) Subject: crack gmail Message-ID: crack gmail http://crack.cracksofts.com From devphyl at gmail.com Sun Apr 13 04:56:51 2008 From: devphyl at gmail.com (alefajnie) Date: Sun, 13 Apr 2008 01:56:51 -0700 (PDT) Subject: Graphical grammar in python Message-ID: <32b272bb-b5d8-415d-8640-4dc6dbd62f0c@m73g2000hsh.googlegroups.com> hi Is exist any graphical library with resize, rotate, shape recognition, ...? suitable for graphical grammar at this moment I have OpenGL (resize & rotate) and recognition solved as saved set of shapes (classes) feel free to write down any ideas :) From steve at holdenweb.com Tue Apr 1 15:37:09 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 01 Apr 2008 15:37:09 -0400 Subject: Why prefer != over <> for Python 3.0? In-Reply-To: <878wzyyqkf.fsf@physik.rwth-aachen.de> References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> <659gb2F2f84eoU2@mid.individual.net> <87hceo73ap.fsf@physik.rwth-aachen.de> <65anbqF2fg18bU1@mid.individual.net> <87r6drjss4.fsf@physik.rwth-aachen.de> <65c0bfF2ffipiU1@mid.individual.net> <878wzyyqkf.fsf@physik.rwth-aachen.de> Message-ID: <47F28EE5.5080506@holdenweb.com> Torsten Bronger wrote: > Hall?chen! > > Jorge Vargas writes: > >> On Tue, Apr 1, 2008 at 6:03 AM, Gabriel Genellina >> wrote: >> >>> [...] >>> >>> I think it should be easy to add support for ??? and even ?, >>> only the tokenizer has to be changed. >>> >> show me a keyboard that has those symbols and I'm all up for it. > > For <= I have to press three buttons, for ? I have to press four > buttons. Not much of a difference. ;-) > > However, I'm slightly disappointed with the UTF-8 support in some > mail clients involved in this thread, so Unicode surely has not > arrived yet. > I'd settle for a program listing utility that made the replacements. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From banibrata.dutta at gmail.com Thu Apr 24 07:40:06 2008 From: banibrata.dutta at gmail.com (Banibrata Dutta) Date: Thu, 24 Apr 2008 17:10:06 +0530 Subject: Python development tools In-Reply-To: <3de8e1f70804240439n26235c64o6d635ea9d4333856@mail.gmail.com> References: <09992de9-39fa-4ee6-8009-35732f3433fb@y21g2000hsf.googlegroups.com> <87fxtcnvj7.fsf@physik.rwth-aachen.de> <48106ba0$0$11087$426a34cc@news.free.fr> <873apbqypn.fsf@physik.rwth-aachen.de> <3de8e1f70804240439n26235c64o6d635ea9d4333856@mail.gmail.com> Message-ID: <3de8e1f70804240440g24375a6em5009399a0250b352@mail.gmail.com> On 4/24/08, Banibrata Dutta wrote: > On Windows, I use "PyScripter", and it's quite nice and functional. > > On 4/24/08, Torsten Bronger wrote: > > Hall?chen! > > > > Bruno Desthuilliers writes: > > > > > [...] > > > > > >> and it ends multi-line strings at single quotes. > > > > > > it chokes on unbalanced single quotes in triple-single-quoted > > > strings, and on unbalanced double-quotes in triple-double-quoted > > > strings, yes. Given that I never use triple-single-quoted strings > > > (and don't remember having seen such a thing in the thousands of > > > third-part .py files I've read so far), I'd qualify this as at > > > most a very minor annoyance. Not having proper python-shell and > > > pdb integration is wwwwaaaayyyy more annoying IMHO. > > > > My formulation was unfortunate. What doesn't work (at least for me) > > is something like > > > > """This is a docstring in which some "variables" are quoted.""" > > > > Here, "variables" doesn't seem to belong to the docstring for > > python-mode. > > > > Tsch?, > > Torsten. > > > > -- > > Torsten Bronger, aquisgrana, europa vetus > > Jabber ID: bronger at jabber.org > > (See http://ime.webhop.org for further contact info.) > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > > -- > regards, > Banibrata > http://www.linkedin.com/in/bdutta > -- regards, Banibrata http://www.linkedin.com/in/bdutta From needin4mation at gmail.com Tue Apr 29 14:14:57 2008 From: needin4mation at gmail.com (jmDesktop) Date: Tue, 29 Apr 2008 11:14:57 -0700 (PDT) Subject: Simple import question about mac osx References: Message-ID: On Apr 29, 1:54?pm, s0s... at gmail.com wrote: > On Apr 29, 12:46 pm, jmDesktop wrote: > > > > > > > On Apr 29, 1:16 pm, jmDesktop wrote: > > > > Hi, I have this code (learning from Core Python, Chun's book), module > > > named chap2.py. > > > > class FooClass(object): > > > ? ? ? ? version=0.1 > > > > ? ? ? ? def __init__(self, nm='John Doe'): > > > ? ? ? ? ? ? ? ? self.name=nm > > > ? ? ? ? ? ? ? ? print 'Created a class instance for ', nm > > > ? ? ? ? def showname(self): > > > ? ? ? ? ? ? ? ? print 'Your name is', self.name > > > ? ? ? ? ? ? ? ? print 'My name is', self.__class__.__name__ > > > > On Windows, if I compile this and then in the python interpreter type: > > > > >>> import chap2 > > > >>> foo1=FooClass() > > > > Created a class instance for ?John Doe > > > > If I do the same think on my Mac OS X 10.5.2 > > > > NameError: name 'FooClass' is not defined. > > > > I thought it was the path and did export PATH=$PATH:/mypath/ > > > topythoncode > > > > but it did not help. > > > > What am I doing wrong? ?Thank you. > > > forgot to say that on the mac I can do import chap2, but when I try > > and instantiate I get the error above. > > It shouldn't work under Windows, either. You have to qualify the name > of the class with the name of the module, as in chap2.FooClass(). Or > you can type "from chap2 import FooClass" and then you'll be able to > simply say FooClass().- Hide quoted text - > > - Show quoted text - Thanks. That worked on mac. But it does work like I said in Windows. Don't know why. Mr. Chun must also be using Windows because that is the way he does it in his book. From ewertman at gmail.com Sun Apr 27 11:05:40 2008 From: ewertman at gmail.com (Eric Wertman) Date: Sun, 27 Apr 2008 11:05:40 -0400 Subject: design choice: multi-threaded / asynchronous wxpython client? In-Reply-To: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: <92da89760804270805q31487a1et9999801ab6c27162@mail.gmail.com> HI, that does look like a lot of fun... You might consider breaking that into 2 separate programs. Write one that's threaded to keep a db updated properly, and write a completely separate one to handle displaying data from your db. This would allow you to later change or add a web interface without having to muck with the code that handles data. From hypocrite at lawyer.com Wed Apr 16 07:59:44 2008 From: hypocrite at lawyer.com (Pete Crite) Date: Wed, 16 Apr 2008 21:59:44 +1000 Subject: Python crashes consistently In-Reply-To: References: Message-ID: <43804F30-A656-40C1-805F-07DE7BE154AB@lawyer.com> On 16/04/2008, at 9:38 PM, martin.laloux at gmail.com wrote: > > which python ? from macports or macpython ? > -- > http://mail.python.org/mailman/listinfo/python-list > MacPorts. It automatically downloaded 2.5.2. My original message is reproduced below. On 16/04/2008, at 5:50 PM, Pete Crite wrote: > > Hello, > > I've been trying to install Gnumeric via MacPorts recently, but I > can't get past the installation of py25-numpy. > > It appears that python crashes consistently during installation. I'm > not sure if this is related to python itself, but I just thought I'd > ask here, just in case anyone else was aware of this problem. I did > have a few problems during the installation, so perhaps it might be > related to them? Is there anyway to check that my installation of > python is valid? > > I'm using OS X 10.4.11 on a Mac Mini PPC. I have attached the error > messages from the terminal and the mac pop-up window from the crash. > > Any help would be very much appreciated! > > Cheers, > Pete. > > > The terminal says: > >> Error: Target org.macports.build returned: shell command " cd "/opt/ >> local/var/macports/build/ >> _opt_local_var_macports_sources_rsync.macports.org_release_ports_pyth >> o >> n_py25-numpy/work/numpy-1.0.4" && /opt/local/bin/python2.5 setup.py >> config_fc --fcompiler g95 --f77exec /opt/local/bin/g95 --f90exec / >> opt/local/bin/g95 build " returned error 139 >> Command output: Running from numpy source directory. >> >> Error: The following dependencies failed to build: py25-gtk py25- >> cairo py25-numpy >> Error: Status 1 encountered during processing. >> > > > The crash window that pops up says: > >> Date/Time: 2008-03-30 11:30:33.545 +1100 >> OS Version: 10.4.11 (Build 8S165) >> Report Version: 4 >> >> Command: python2.5 >> Path: /opt/local/bin/python2.5 >> Parent: sh [247] >> >> Version: ??? (???) >> >> PID: 248 >> Thread: 0 >> >> Exception: EXC_BAD_ACCESS (0x0001) >> Codes: KERN_INVALID_ADDRESS (0x0001) at 0x82008000 >> >> Thread 0 Crashed: >> 0 _random.so 0x00571334 random_seed + 644 >> (_randommodule.c:297) >> 1 _random.so 0x0057131c random_seed + 620 >> (_randommodule.c:292) >> 2 libpython2.5.dylib 0x002b1788 PyEval_EvalFrameEx + 17604 >> (ceval.c:3573) >> 3 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 >> (ceval.c:2836) >> 4 libpython2.5.dylib 0x002b19ac PyEval_EvalFrameEx + 18152 >> (ceval.c:3669) >> 5 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 >> (ceval.c:2836) >> 6 libpython2.5.dylib 0x0023969c function_call + 332 >> (funcobject.c:524) >> 7 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: >> 1862) >> 8 libpython2.5.dylib 0x0021960c instancemethod_call + 764 >> (classobject.c:2520) >> 9 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: >> 1862) >> 10 libpython2.5.dylib 0x0026e81c slot_tp_init + 72 (typeobject.c: >> 4944) >> 11 libpython2.5.dylib 0x00273f88 type_call + 664 (typeobject.c:436) >> 12 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: >> 1862) >> 13 libpython2.5.dylib 0x002b2fc8 PyEval_EvalFrameEx + 23812 >> (ceval.c:3786) >> 14 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 >> (ceval.c:2836) >> 15 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) >> 16 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 >> (import.c:676) >> 17 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 >> (import.c:960) >> 18 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: >> 2401) >> 19 libpython2.5.dylib 0x002cd7d4 load_next + 300 (import.c:2221) >> 20 libpython2.5.dylib 0x002cde8c import_module_level + 624 >> (import.c:2002) >> 21 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 >> (import.c:2072) >> 22 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 >> (bltinmodule.c:49) >> 23 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: >> 1862) >> 24 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + >> 276 (ceval.c:3443) >> 25 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 >> (ceval.c:2067) >> 26 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 >> (ceval.c:2836) >> 27 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) >> 28 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 >> (import.c:676) >> 29 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 >> (import.c:960) >> 30 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: >> 2401) >> 31 libpython2.5.dylib 0x002cd828 load_next + 384 (import.c:2225) >> 32 libpython2.5.dylib 0x002cde8c import_module_level + 624 >> (import.c:2002) >> 33 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 >> (import.c:2072) >> 34 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 >> (bltinmodule.c:49) >> 35 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: >> 1862) >> 36 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + >> 276 (ceval.c:3443) >> 37 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 >> (ceval.c:2067) >> 38 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 >> (ceval.c:2836) >> 39 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) >> 40 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 >> (import.c:676) >> 41 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 >> (import.c:960) >> 42 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: >> 2401) >> 43 libpython2.5.dylib 0x002cd7d4 load_next + 300 (import.c:2221) >> 44 libpython2.5.dylib 0x002cde8c import_module_level + 624 >> (import.c:2002) >> 45 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 >> (import.c:2072) >> 46 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 >> (bltinmodule.c:49) >> 47 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: >> 1862) >> 48 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + >> 276 (ceval.c:3443) >> 49 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 >> (ceval.c:2067) >> 50 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 >> (ceval.c:2836) >> 51 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) >> 52 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 >> (import.c:676) >> 53 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 >> (import.c:960) >> 54 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: >> 2401) >> 55 libpython2.5.dylib 0x002cdb68 ensure_fromlist + 552 (import.c: >> 2312) >> 56 libpython2.5.dylib 0x002ce03c import_module_level + 1056 >> (import.c:2038) >> 57 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 >> (import.c:2072) >> 58 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 >> (bltinmodule.c:49) >> 59 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: >> 1862) >> 60 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + >> 276 (ceval.c:3443) >> 61 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 >> (ceval.c:2067) >> 62 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 >> (ceval.c:2836) >> 63 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) >> 64 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 >> (import.c:676) >> 65 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 >> (import.c:960) >> 66 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: >> 2401) >> 67 libpython2.5.dylib 0x002cd7d4 load_next + 300 (import.c:2221) >> 68 libpython2.5.dylib 0x002cde8c import_module_level + 624 >> (import.c:2002) >> 69 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 >> (import.c:2072) >> 70 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 >> (bltinmodule.c:49) >> 71 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: >> 1862) >> 72 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + >> 276 (ceval.c:3443) >> 73 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 >> (ceval.c:2067) >> 74 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 >> (ceval.c:2836) >> 75 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) >> 76 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 >> (import.c:676) >> 77 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 >> (import.c:960) >> 78 libpython2.5.dylib 0x002ccf20 load_package + 336 (import.c:1015) >> 79 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: >> 2401) >> 80 libpython2.5.dylib 0x002cd7d4 load_next + 300 (import.c:2221) >> 81 libpython2.5.dylib 0x002cdec0 import_module_level + 676 >> (import.c:2009) >> 82 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 >> (import.c:2072) >> 83 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 >> (bltinmodule.c:49) >> 84 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: >> 1862) >> 85 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + >> 276 (ceval.c:3443) >> 86 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 >> (ceval.c:2067) >> 87 libpython2.5.dylib 0x002b1924 PyEval_EvalFrameEx + 18016 >> (ceval.c:3660) >> 88 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 >> (ceval.c:2836) >> 89 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) >> 90 libpython2.5.dylib 0x002d8444 PyRun_FileExFlags + 288 >> (pythonrun.c:1274) >> 91 libpython2.5.dylib 0x002d87fc PyRun_SimpleFileExFlags + 840 >> (pythonrun.c:879) >> 92 libpython2.5.dylib 0x002e9b74 Py_Main + 3184 (main.c:523) >> 93 python2.5 0x000019d8 _start + 760 >> 94 python2.5 0x000016dc start + 48 >> >> Thread 0 crashed with PPC Thread State 64: >> srr0: 0x0000000000571334 srr1: >> 0x000000000000d030 vrsave: 0x0000000000000000 >> cr: 0x44244228 xer: 0x0000000000000004 lr: >> 0x000000000057131c ctr: 0x0000000000000001 >> r0: 0x0000000080000000 r1: 0x00000000bfff80a0 r2: >> 0x00000000a0001fac r3: 0x0000000002008000 >> r4: 0x0000000002008000 r5: 0x0000000000000000 r6: >> 0x00000000bfff7fbc r7: 0x00000000000fdff8 >> r8: 0x0000000001800400 r9: 0x000000000000000a r10: >> 0x000000000000000a r11: 0x000000000000003f >> r12: 0x000000009000661c r13: 0x00000000ffffffff r14: >> 0x000000000000ccac r15: 0x00000000000c6930 >> r16: 0x00000000000c9090 r17: 0x0000000000000000 r18: >> 0x000000000031bf48 r19: 0x0000000000627b04 >> r20: 0x00000000005710c4 r21: 0x0000000001858010 r22: >> 0x000000000000d248 r23: 0x0000000001803814 >> r24: 0x0000000002008000 r25: 0x0000000040000000 r26: >> 0x0000000020000001 r27: 0x0000000000000000 >> r28: 0x000000000004c0c0 r29: 0x000000000004c0c0 r30: >> 0x0000000044244228 r31: 0x00000000005710c4 >> >> Binary Images Description: >> 0x1000 - 0x1fff python2.5 /opt/local/bin/python2.5 >> 0xe2000 - 0xe5fff strop.so /opt/local/lib/python2.5/lib- >> dynload/strop.so >> 0xf2000 - 0xf3fff math.so /opt/local/lib/python2.5/lib- >> dynload/math.so >> 0x205000 - 0x31afff libpython2.5.dylib /opt/local/lib/ >> libpython2.5.dylib >> 0x565000 - 0x567fff binascii.so /opt/local/lib/python2.5/lib- >> dynload/binascii.so >> 0x570000 - 0x571fff _random.so /opt/local/lib/python2.5/lib- >> dynload/_random.so >> 0x8fe00000 - 0x8fe52fff dyld 46.16 /usr/lib/dyld >> 0x90000000 - 0x901bcfff libSystem.B.dylib /usr/lib/libSystem.B.dylib >> 0x90214000 - 0x90219fff libmathCommon.A.dylib /usr/lib/system/ >> libmathCommon.A.dylib >> 0x945e0000 - 0x94600fff libmx.A.dylib /usr/lib/libmx.A.dylib >> >> Model: PowerMac10,1, BootROM 4.8.9f1, 1 processors, PowerPC G4 >> (1.2), 1.25 GHz, 1 GB >> Graphics: ATI Radeon 9200, ATY,RV280, AGP, 32 MB >> Memory Module: DIMM0/J11, 1 GB, DDR SDRAM, PC3200U-30330 >> Modem: Jump, V.92, Version 1.0 >> Network Service: Built-in Ethernet, Ethernet, en0 >> Parallel ATA Device: ST940110A, 37.26 GB >> Parallel ATA Device: MATSHITACD-RW CW-8124 >> USB Device: Hub in Apple Pro Keyboard, Mitsumi Electric, Up to 12 >> Mb/sec, 500 mA >> USB Device: PS/2+USB Mouse, Up to 1.5 Mb/sec, 100 mA >> USB Device: C-Media USB Headphone Set, Up to 12 Mb/sec, 100 mA >> USB Device: Apple Pro Keyboard, Mitsumi Electric, Up to 12 Mb/sec, >> 250 mA >> From gagsl-py2 at yahoo.com.ar Tue Apr 1 20:28:13 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 21:28:13 -0300 Subject: manipulating hex values References: <47F26CC3.3060307@u4eatech.com> <47F28855.50908@u4eatech.com> Message-ID: En Tue, 01 Apr 2008 16:09:09 -0300, Stephen Cattaneo escribi?: > Gabriel Genellina wrote: >>
En Tue, >> 01 Apr 2008 14:11:31 -0300, Stephen Cattaneo >> escribi?: >> >>> I am relatively new to socket programming. I am attempting to use raw >>> sockets to spoof my IP address. >> Don't bother to try... > ? Is there a better solution to spoofing my IP then using raw sockets > (I'm working on a machine with multiple interfaces and need to be able > to some how specify which interface that traffic needs to be > sent/recieved to/from) It seems you are looking for NAT - have you considered the existing NAT solutions? I'm afraid I can't provide further details but it's a well-known topic. > The source of my confusion is that I need to keep my bytes formated > correctly. I am using the below 'raw socket example' proof-of-concept > code as my example. (And yes, I have tried the proof-of-concept. It > works correctly. It is not my code.) > dstAddr = "\x01\x02\x03\x04\x05\x06" > dstAddr1 = "0x010203040506" > dstAddr != dstAddr1 As others have pointed out, you're confusing numbers, strings, and how they're represented. As an example, here you have 10 different ways to get the integer "two hundreds and fifty eight": py> 258, 0x0102, int("0x0102",16) (258, 258, 258) py> int("0102",16), ord("\x02\x01".decode("utf-16-le")) (258, 258) py> struct.unpack(" struct.unpack(">H", "\x01\x02")[0] 258 py> 0402, int("0402",8), int("100000010",2) (258, 258, 258) In all cases you get an *integer* object; it doesn't matter how you wrote it, you always get the same integer, the same as writting 258 alone. > Follow up question: What is the best to store my bytes up until sending > the packets? Perhaps I should use lists of decimal numbers "list of numbers" > and then > before sending convert to hex. "convert to string of bytes" > I.E. dstAddr = [ 1, 2, 3, 4, 5, 6] > dstAddr.prepareToSend() > txFrame = struct.pack("!6s6sh",dstAddr,srcAddr,proto) + ethData I thought you were working with IP packets, not ethernet frames. If you have the MACs as a list of 6 numbers, 0-255: txFrame = struct.pack("!6B", *dstAddr) + \ struct.pack("!6B", *srcAddr) + \ struct.pack("!h", proto) + ethData > proto = 0x55aa > s = socket(AF_PACKET, SOCK_RAW, proto) > s.bind(("eth0",proto)) > > ifName,ifProto,pktType,hwType,hwAddr = s.getsockname() > srcAddr = hwAddr > # send packet to ethernet MAC: 01-02-03-04-05-06 > dstAddr = "\x01\x02\x03\x04\x05\x06" > ethData = "here is some data for an ethernet packet" > print "ethData length is: " + str(len(ethData)) > > txFrame = struct.pack("!6s6sh",dstAddr,srcAddr,proto) + ethData > s.send(txFrame) That's wrong. Your raw socket is working with PACKETS (layer 3, network), not FRAMES (layer 2). -- Gabriel Genellina From wongjoekmeu at yahoo.com Wed Apr 23 13:39:06 2008 From: wongjoekmeu at yahoo.com (wongjoekmeu at yahoo.com) Date: Wed, 23 Apr 2008 10:39:06 -0700 (PDT) Subject: Python development tools Message-ID: Are there any completely free developent tools for python scripts like IDLE. I have used IDLE , but I want to try out others also. I saw stuff like PyCrust, but I don't see that it can run the script as well. Thanks, RR From ch612bunn at gmail.com Sun Apr 27 09:18:54 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:18:54 -0700 (PDT) Subject: AVS Video Converter 5.6 crack Message-ID: AVS Video Converter 5.6 crack http://wga-cracks.crackkey.net From zillow20 at googlemail.com Tue Apr 1 22:56:50 2008 From: zillow20 at googlemail.com (zillow20 at googlemail.com) Date: Tue, 1 Apr 2008 19:56:50 -0700 (PDT) Subject: generator functions: why won't this work? Message-ID: Hi all, I'm trying to understand generator functions and the yield keyword. I'd like to understand why the following code isn't supposed to work. (What I would have expected it to do is, for a variable number of arguments composed of numbers, tuples of numbers, tuples of tuples, etc., the function would give me the next number "in sequence") #################################### def getNextScalar(*args): for arg in args: if ( isinstance(arg, tuple)): getNextScalar(arg) else: yield arg #################################### # here's an example that uses this function: # creating a generator object: g = getNextScalar(1, 2, (3,4)) g.next() # OK: returns 1 g.next() # OK: returns 2 g.next() # not OK: throws StopIteration error #################################### I'm sure I'm making some unwarranted assumption somewhere, but I haven't been able to figure it out yet (just started learning Python a couple of days ago). Any help will be appreciated :) Akiel From george.sakkis at gmail.com Tue Apr 22 09:33:40 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 22 Apr 2008 06:33:40 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <675tasF2kecjsU1@mid.uni-berlin.de> Message-ID: <76def89d-cb1a-47ce-ac47-f057e1abddf0@d1g2000hsg.googlegroups.com> On Apr 22, 6:34?am, "Diez B. Roggisch" wrote: > azrael schrieb: > > > Hy guys, > > A friend of mine i a proud PERL developer which always keeps making > > jokes on python's cost. > > > Please give me any arguments to cut him down about his commnets > > like :"keep programing i python. maybe, one day, you will be able to > > program in VisualBasic" > > > This hurts. Please give me informations about realy famous > > aplications. > > This isn't worth too much, but nontheless: > > http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html > > Klick on Perl & Python respectively to see who's going to need to use > something else some day. One more limited worth datapoint: http://www.google.com/trends?q=python+programming%2C+perl+programming&ctab=0 From andreww at datanet.ab.ca Thu Apr 10 20:05:20 2008 From: andreww at datanet.ab.ca (Andrew Warkentin) Date: Thu, 10 Apr 2008 18:05:20 -0600 Subject: Adding classes to modules at runtime from outside that module In-Reply-To: References: Message-ID: <47FEAB40.7090102@datanet.ab.ca> frambooz at gmail.com wrote: > In Python, is it possible to add classes to a module at run-time? > > Say I have a module foo and a module bar. Foo has class A and B, and >bar has class C. I want to add class C to foo so I can access it as >foo.C, but i want to do it without modifying foo's source. > > Is this at all possible? > > Yes. You would do something like import foo import bar foo.C = bar.C From cmpython at gmail.com Fri Apr 11 23:48:06 2008 From: cmpython at gmail.com (CM) Date: Fri, 11 Apr 2008 20:48:06 -0700 (PDT) Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> Message-ID: On Apr 11, 3:29 pm, Rune Strand wrote: > On Apr 11, 8:35 pm, Steve Holden wrote: > > > wxDesigner. > > Yeah, but it's like Heron of Alexandria's Aeolipile compared to the > steam engine of James Watt. > > IMHO, GUI with Python is pain, pain and utter pain. Even boring and > meaningless pain. What do you prefer, then, to do GUI with? And why? From jr9445 at ATT.COM Wed Apr 9 17:39:07 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Wed, 9 Apr 2008 16:39:07 -0500 Subject: How can I use quotes without escaping them using CSV? In-Reply-To: References: Message-ID: > -----Original Message----- > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > list-bounces+jr9445=att.com at python.org] On Behalf Of jeffself > Sent: Wednesday, April 09, 2008 5:11 PM > To: python-list at python.org > Subject: How can I use quotes without escaping them using CSV? > > > If I put an escape character in, it works. For example, if I use ~ as > my escape character, my output looks like this: > 0001[tab]Michael L. ~"Mick~" Jones[tab]189 > > I don't want that. If I don't include an escape character, it doesn't > work. > > > Here's my code: > import sys > import csv > from readexcel import * > > f = open("results.txt", 'wb') > book = sys.argv[1] > sheet = sys.argv[2] > > xl = readexcel(book) > sheetnames = xl.worksheets() > > for s in sheetnames: > if s == sheet: > writer = csv.writer(f, delimiter='\t', quoting=csv.QUOTE_NONE) > for row in xl.getiter(s): > > writer.writerow((row['Precinct'],row['Candidate'],unicode(int(row['Vote > s'])))) > f.close() > The documentation is pretty, uhm, obtuse, but you also need to set quotechar. import sys import csv names = ['Michael L. "Mick" Jones', 'Vickie A. Meyers', 'John "Jack" Smith'] writer = csv.writer(sys.stdout, delimiter='\t', quotechar='', quoting=csv.QUOTE_NONE) for i in names: writer.writerow(['a', i, 'b']) output: a Michael L. "Mick" Jones b a Vickie A. Meyers b a John "Jack" Smith b ***** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA621 From t.a.adjuster at gmail.com Thu Apr 24 15:25:01 2008 From: t.a.adjuster at gmail.com (t.a.adjuster at gmail.com) Date: Thu, 24 Apr 2008 12:25:01 -0700 (PDT) Subject: python-ldap - Operations Error References: Message-ID: On Apr 24, 2:02 pm, theivi... at gmail.com wrote: > Not sure if this is an AD thing or just something i needed to do with > our particular server/config. Glad to hear my posting helped somebody. In our case, our domain controller was passing us referrals to the Configuration, ForestDNSZones, and DomainDNSZones partitions of the directory when we were doing SCOPE_SUBTREE scoped searches from the root DN of an AD domain. When python-ldap tried to chase those referrals it did so with an anonymous bind, hence the error. Once we turned off the OPT_REFERRALS option, our only other consideration was to be sure that, when iterating over our search results, we just scrubbed out the referrals that were returned (based on the referrals being lists and the real search results being dictionaries). This is a bit quick and dirty, perhaps, but it's what did the trick for us. Evan From aldo at nullcube.com Wed Apr 2 00:38:32 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Wed, 2 Apr 2008 15:38:32 +1100 Subject: ANN: pry unit testing framework In-Reply-To: <87zlscx5lt.fsf@benfinney.id.au> References: <87zlscx5lt.fsf@benfinney.id.au> Message-ID: <20080402043832.GA23773@nullcube.com> Hi Ben, > > We are happy to announce the first release of Pry, a unit testing > > framework. > > Thanks for the announcement, and for the software. > > If Pry is already incompatible with xUnit (i.e. Python's 'unittest'), > could we please have names that adhere to the Python style guide > ? > > In particular the method names 'setUp', 'setUpAll', 'tearDown', > 'tearDownAll' don't comply with the style guide. Compliant names for > those methods would be 'set_up', 'set_up_all', etc. Keeping fixture setUp and tearDown names the same makes the transition from unittest to pry easier. At the moment, converting to pry is very simple - inherit your suites from AutoTree, rewrite tests to use assertions, and then instantiate your suites at the end of the module. Voila! You have a nice command-line interface, coverage analysis, and an easy path to saner, better-engineered unit tests. Internal consistency in this case is much more important than the style guide, which intends only to standardise naming conventions within the Python standard library, and even there does not go so far as to suggest converting existing modules to the new convention. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From HDoran at air.org Fri Apr 18 11:15:30 2008 From: HDoran at air.org (Doran, Harold) Date: Fri, 18 Apr 2008 11:15:30 -0400 Subject: Making Windows Larger in Tkinter Message-ID: <2323A6D37908A847A7C32F1E3662C80E017BE072@dc1ex01.air.org> Thanks to some help I received on list the other day, I now have a very nice windows-based application that implements multiple programs. This is a very powerful tool. Now I am working to make this window pretty. One problem I cannot find help on is how to make the windows a certain size. For example, I have added in a root.title() with a lot of text in the file example.py below. Is it possible to make the window box a specific size, or by default, always be large enough to show the entire text in root.title? example.py from Tkinter import * import tkMessageBox def callback(): print "called the callback!" def message(): if tkMessageBox.askokcancel("Quit", "Do you really wish to quit?"): root.destroy() def about(): tkMessageBox.showinfo("About", "Foo?") root = Tk() root.title('Hello World: How Can we see the entire title?') # create a menu menu = Menu(root) root.config(menu=menu) filemenu = Menu(menu) menu.add_cascade(label="File", menu=filemenu) filemenu.add_command(label="New", command=message) filemenu.add_command(label="Open...", command=callback) filemenu.add_separator() filemenu.add_command(label="Exit", command=message) helpmenu = Menu(menu) menu.add_cascade(label="Help", menu=helpmenu) helpmenu.add_command(label="About...", command=about) mainloop() -------------- next part -------------- An HTML attachment was scrubbed... URL: From workitharder at gmail.com Tue Apr 1 18:49:13 2008 From: workitharder at gmail.com (bukzor) Date: Tue, 1 Apr 2008 15:49:13 -0700 (PDT) Subject: Directed Graph Traversal References: <804682cb-2da6-4d85-83d4-c7425c498534@p25g2000hsf.googlegroups.com> Message-ID: <31d91a7b-80db-4ca2-a821-aab55e9e6a11@m73g2000hsh.googlegroups.com> On Apr 1, 3:46 pm, bukzor wrote: > Can someone point me in the direction of a good solution of this? I'm > using it to construct a SQL query compiler, where each node is a table > and each edge is a join. I'm planning on using the NetworkX library if > possible.https://networkx.lanl.gov/reference/networkx/ > > Given a directed graph and a list of points in the graph, what is the > minimal subgraph that contains them all? It is preferable that the > subgraph is a tree. > > A -- B -- C -- D > | | > E -- F > > A, B, F => ABEF (or ABCF) > A, F, C => ABCF > A, E, D => ABCD > E > > Thanks! > --Buck edited to correct diagram for monospace font... From jonathan.lukens at gmail.com Thu Apr 17 13:22:46 2008 From: jonathan.lukens at gmail.com (Jonathan Lukens) Date: Thu, 17 Apr 2008 10:22:46 -0700 (PDT) Subject: help with docutils Message-ID: <09658c2d-f726-47ff-9e24-839703b80918@y21g2000hsf.googlegroups.com> I am trying generate html from a reST document, both the body of the document and a table of contents, each contained in separate variables. I had initially assumed that there would be a 'toc' key in publish_parts, but apparently there is not. Is there a relatively easy way to achieve this? From john00587 at gmail.com Mon Apr 21 01:39:59 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:39:59 -0700 (PDT) Subject: xplite 1.6 keygen Message-ID: <1bc4fbc8-8224-462f-9aa5-659c04928263@y22g2000prd.googlegroups.com> xplite 1.6 keygen http://cracks.00bp.com F R E E C R A C K S From vemburuby at gmail.com Fri Apr 25 08:32:16 2008 From: vemburuby at gmail.com (mahalakshmi) Date: Fri, 25 Apr 2008 05:32:16 -0700 (PDT) Subject: @@@@ THEY DO DIFFERENT THINGS TO GET HERE@@@@@ Message-ID: <8f78e482-1df0-4ec9-9728-67c5101d81e2@w8g2000prd.googlegroups.com> HAI !!!!!!!!!!!!!!!!! EARN MORE MONEY INTERESTED HERE.................SEE IN MY SITE. THEY DO DIFFERENT THINGS TO GET HERE........ www.getitlove.blogspot.com www.doitbetter5.blogspot.com From steven.p.clark at gmail.com Tue Apr 8 11:38:17 2008 From: steven.p.clark at gmail.com (Steven Clark) Date: Tue, 8 Apr 2008 11:38:17 -0400 Subject: list.sort(): heaviest item? In-Reply-To: <661hbrF2iip12U1@mid.uni-berlin.de> References: <661hbrF2iip12U1@mid.uni-berlin.de> Message-ID: <663744510804080838h4506a6d5v46047c18a0b34060@mail.gmail.com> > You can pass a cmp-function that will always make one object being greater > than all others. > > Diez > -- Yeah, I figured it out 2 minutes after I posted, d'oh! class Anvil(object): def __cmp__(self. other): return 1 Sorry for the wasted space. From elnoire at gmail.com Sun Apr 20 02:04:40 2008 From: elnoire at gmail.com (elnoire at gmail.com) Date: Sat, 19 Apr 2008 23:04:40 -0700 (PDT) Subject: Checking if a text file is blank Message-ID: Greetings! I've just started learning python, so this is probably one of those obvious questions newbies ask. Is there any way in python to check if a text file is blank? What I've tried to do so far is: f = file("friends.txt", "w") if f.read() is True: """do stuff""" else: """do other stuff""" f.close() What I *mean* to do in the second line is to check if the text file is not-blank. But apparently that's not the way to do it. Could someone set me straight please? From wesleymesquita at gmail.com Sun Apr 6 08:30:54 2008 From: wesleymesquita at gmail.com (Wesley Mesquita) Date: Sun, 6 Apr 2008 05:30:54 -0700 (PDT) Subject: Control process execution Message-ID: <1d1bbea2-a503-4db5-bd3f-c45c29916b9c@13g2000hsb.googlegroups.com> Hi all, I am trying to create a test environment to a couple C applications (simple UDP and TCP server/clients), so I want to write this in python and I m looking for ways to do it. Basically I need an execution timer and timeout control (to kill the apps in certain situations). Looking at google, I found the Pexpect package, but I m a little bit lost in using it. So, any good suggetions? Thanks in advance. From deets at nospam.web.de Tue Apr 1 05:43:06 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 01 Apr 2008 11:43:06 +0200 Subject: troll poll References: Message-ID: <65eee6F2eg18jU1@mid.uni-berlin.de> Delaney, Timothy (Tim) wrote: > George Sakkis wrote: > >> On Mar 31, 1:46 pm, Marc 'BlackJack' Rintsch wrote: >> >>>> More specifically, who can create a bigger mess on c.l.py? (check >>>> one) >>> >>>> [ ] - Xah Lee >>>> [X] - castironpi >>> >>> Xah Lee's postings might be trolls but sometimes they spark some >>> really interesting and serious subthreads, while the nonsense of >>> castironpi is just irritating noise. >> >> Which is exactly why there are rarely any replies to his random >> gibberish, so I would say that he/she/it has almost no effect on >> c.l.py. Yet I wish plonking was possible through Google groups. > > I find classifying all their posts as spam works fairly well. I'm also astonished - once I figured out how this knode works regarding killfiles, all I get to see from them is the occasional citation. The only irritating thing is if castironpi answers to one of *my* posts, and somebody else tells him to shut up... which then appears below my post in my reader ... diez From leoniaumybragg at gmail.com Sat Apr 26 07:02:11 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 04:02:11 -0700 (PDT) Subject: b-jigsaw serial crack keygen Message-ID: b-jigsaw serial crack keygen http://cracks.00bp.com F R E E C R A C K S From flarefight at googlemail.com Tue Apr 29 16:24:34 2008 From: flarefight at googlemail.com (flarefight at googlemail.com) Date: Tue, 29 Apr 2008 13:24:34 -0700 (PDT) Subject: py2exe Icon Resources Message-ID: <40c03afe-b2c5-4793-b7c3-f5a97360fe6c@a23g2000hsc.googlegroups.com> I have created an app using python and then converting it to an exe using py2exe, and have the following code: "icon_resources": [(1, "appFavicon.ico"), (2, "dataFavicon.ico")] in my py2exe setup file, the appFavicon works fine and it sets that as the app icon thats fine, but the program creates data files (like documents) and i wanted them to have a different icon... I package my apps using Inno Setup 5, and it registers the file type fine so that it loads on double click, what i cant do is set the icon for the file. as you can see i have packaged two different icons with py2exe but when i set DefaultIcon in the registry to "C:\pathtoapp\myapp.exe,2" it doesnt work, nor does it work with a 1 or a %1 or indeed with passing a path to the icon itself, nothing seems to work!! how do you access the other icons generated from py2exe, or how do you set the registry up so that i looks for the icon correctly, any help appreciated, Caspar From rajeshkataraki at gmail.com Mon Apr 28 07:37:02 2008 From: rajeshkataraki at gmail.com (rajesh kataraki) Date: Mon, 28 Apr 2008 04:37:02 -0700 (PDT) Subject: Need help on left padding Message-ID: Hello, My requirement is I am using one variable ex. var = 5 which is integer. And this variable, I m using in some string. But I want this var to be used as 005 again integer in this string. The snippet of string is as follows: container_name = "%s-%d-dso-%s.so" % (platform_affix,var, rteset) Please let me know how can I implement this efficiently in python language. Need help urgent. Thanks, -Rajesh From deets at nospam.web.de Tue Apr 22 11:38:36 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 17:38:36 +0200 Subject: Does Python 2.5.2's embedded SQLite support full text searching? In-Reply-To: <6763uaF2norrtU1@mid.uni-berlin.de> References: <1208794249.15992.1249049327@webmail.messagingengine.com> <6763uaF2norrtU1@mid.uni-berlin.de> Message-ID: <676f4fF2nfvqgU2@mid.uni-berlin.de> Diez B. Roggisch schrieb: > Daniel Fetchinson schrieb: >>> Does Python 2.5.2's embedded SQLite support full text searching? >>> >>> Any recommendations on a source where one can find out which SQLite >>> features are enabled/disabled in each release of Python? I'm trying to >>> figure out what's available in 2.5.2 as well as what to expect in 2.6 >>> and 3.0. >> >> Sqlite itself is not distributed with python. Only a python db api >> compliant wrapper is part of the python stdlib and as such it is >> completely independent of the sqlite build. In other words, if your >> sqlite build supports full text searching you can use it through the >> python sqlite wrapper (that is part of the stdlib) and if it doesn't >> then not. This is true for any sqlite feature though. >> >> So if you need an sqlite feature just go ahead and build your own >> sqlite with that feature enabled and use that feature with the stock >> python sqlite wrapper that comes with the stdlib. > > I doubt that. This would mean that Python comes with a mechanism to > dynamically load different libs for the same module, opening a buttload > full of error-conditions regarding library versions & changing semantics > depending on system configuration. And Paul Melis showed me that exactly that is the case. Sorry for the noise. Diez From jura.grozni at gmail.com Tue Apr 22 06:25:59 2008 From: jura.grozni at gmail.com (azrael) Date: Tue, 22 Apr 2008 03:25:59 -0700 (PDT) Subject: Python Success stories Message-ID: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Hy guys, A friend of mine i a proud PERL developer which always keeps making jokes on python's cost. Please give me any arguments to cut him down about his commnets like :"keep programing i python. maybe, one day, you will be able to program in VisualBasic" This hurts. Please give me informations about realy famous aplications. From __peter__ at web.de Wed Apr 30 10:41:02 2008 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Apr 2008 16:41:02 +0200 Subject: Simple TK Question - refreshing the canvas when not in focus References: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> <4818349e$0$2959$ba620e4c@news.skynet.be> <182ace66-bdf6-409c-85ee-fd764de8e1c6@z72g2000hsb.googlegroups.com> Message-ID: blaine wrote: > Still doesn't work. I'm looking into using wx instead... > > This is the full code - does it work for anyone else? Just do a echo > 'line 0 0 10 10' > dev.file Haven't tried it, but I think that the problem is that you are updating the UI from the "readthread". A good example to model your app after is here: http://effbot.org/zone/tkinter-threads.htm Peter From pieter.cogghe at gmail.com Thu Apr 10 05:58:14 2008 From: pieter.cogghe at gmail.com (Pieter) Date: Thu, 10 Apr 2008 11:58:14 +0200 Subject: call python from c -> pass and return arrays/lists Message-ID: <5c0bbcb30804100258l2e562ae4ga26781d372899d03@mail.gmail.com> Hi all, I'm trying to call a python function from c. I need to pass an 2D-array to python and the python function returns a 2D-list back to c. I googled arround and I found how to pass ints/strings/... back and forth, but didn't find anything on passing arrays. For an int it's as simple as this: PyArg_Parse(ret,"i#", &my_long); But I hacve no idea how to parse python lists to a c-array? thanks a lot, Pieter -- Pieter Cogghe Ganzendries 186 9000 Gent 0487 10 14 21 From arnodel at googlemail.com Thu Apr 10 16:08:30 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 10 Apr 2008 13:08:30 -0700 (PDT) Subject: Obtaining a callable class method object from a specific class References: Message-ID: On Apr 10, 7:47?pm, Nathan Duran wrote: > This is a contrived pseudocode example which has been broken out of a ? > larger problem, so it may seem like a strange thing to want to do, ? > but... > > I have a group of objects which inherit (single) from a common base ? > class like so: > > --- > class Root(object): > ? ? ?@classmethod > ? ? ?def CumulativeScore(cls, arg): > ? ? ? ? ?#Ask every child class to > ? ? ? ? ?#generate a score and add > ? ? ? ? ?#them together > ? ? ? ? ?cumulativescore = 0 > ? ? ? ? ?for base in cls.mro(): > ? ? ? ? ? ? ?cumulativescore += base.Score(arg) > ? ? ? ? ?return cumulativescore > ? ? ?#No Score method defined in Root so don't try to call one! > > class BranchChild(Root): > ? ? ?@classmethod > ? ? ?def Score(cls, arg): > ? ? ? ? ?return 1 > > class LeafChild(BranchChild): > ? ? ?@classmethod > ? ? ?def Score(cls, arg): > ? ? ? ? ?return 3 > > class LeafChild2(BranchChild): > ? ? ?pass > ? ? ?#No Score method defined here, either! > I won't question why you want to do this... Here is a solution base on a metaclass, but it feels wrong. @classmethod def score(cls, args): return 0 def totalscore(rootcls, arg): return sum(cls.score(arg) for cls in rootcls.mro() if hasattr(cls, 'score')) class MetaScore(type): def __new__(meta, name, bases, attrs): attrs.setdefault('score', score) return type.__new__(meta, name, bases, attrs) class Root(object): __metaclass__ = MetaScore class Branch(Root): @classmethod def score(cls, arg): return 1 class Leaf(Branch): @classmethod def score(cls, arg): return 3 class Leaf2(Branch): pass --------- Test --------- >>> totalscore(Root, 1) 0 >>> totalscore(Branch, 1) 1 >>> totalscore(Leaf, 1) 4 >>> totalscore(Leaf2, 1) 1 -- Arnaud From jkrukoff at ltgc.com Tue Apr 29 18:29:44 2008 From: jkrukoff at ltgc.com (John Krukoff) Date: Tue, 29 Apr 2008 16:29:44 -0600 Subject: i want to add a timeout to my code In-Reply-To: References: <53ffe104-be3b-43e2-b5c8-4ce5886ac60d@b1g2000hsg.googlegroups.com> <1f70ea43-7909-4bd8-b63d-2467e8a0542f@c65g2000hsa.googlegroups.com> Message-ID: <1209508184.5278.58.camel@localhost.localdomain> On Tue, 2008-04-29 at 14:47 -0700, maehhheeyy wrote: > On Apr 17, 4:24 pm, Miki wrote: > > On Apr 17, 1:10 pm,maehhheeyy wrote: > > > > > I want to add a timeout so that when I pull out my gps from my serial > > > port, it would wait for a bit then loop and then see if it's there. I > > > also want to add a print statement saying that there is no GPS device > > > found. However when I run my code and unplug my serial port, my code > > > will just hang until I plug it back in. > > > This is my code right now: > > > > > def GetGPS(): > > > data = [] > > > #Open com1: 9600,8,N,1 > > > fi = serial.Serial(0, timeout = 1) > > > print '[gps module] SERIAL PORT OPEN ON COM1:' > > > > > can anyone help me please? Thanks. > > > > http://docs.python.org/lib/node545.html > > > > HTH, > > -- > > Miki http://pythonwise.blogspot.com > > I tried the code onto my codes but what came out was that in the line > signal.signal(signal.SIGSLRM, handler), an attributeError appeared > reading that 'module' object has no attribute 'SIGALRM' > -- > http://mail.python.org/mailman/listinfo/python-list Are you writing your program on windows, or some other platform which is not unix? -- John Krukoff Land Title Guarantee Company From urquhart.nak at gmail.com Wed Apr 30 06:28:47 2008 From: urquhart.nak at gmail.com (urquhart.nak at gmail.com) Date: Wed, 30 Apr 2008 03:28:47 -0700 (PDT) Subject: crack cream Message-ID: <3ef360aa-a61f-4aef-9d39-eb434e714ea4@w8g2000prd.googlegroups.com> crack cream http://crack.cracksofts.com From rhamph at gmail.com Sun Apr 13 12:16:39 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Sun, 13 Apr 2008 09:16:39 -0700 (PDT) Subject: C API design flaw (was: Re: Multiple independent Python interpreters in a C/C++ program?) References: <624b9d79-bc02-4f52-bc97-52019bf916d0@n1g2000prb.googlegroups.com> <8e73acd5-b50a-4e0d-9193-8615cb38e5a2@s39g2000prd.googlegroups.com> Message-ID: On Apr 12, 2:02 pm, sturlamolden wrote: > On Apr 12, 7:05 pm, sturlamolden wrote: > > > In theory, a GIL private to each (sub)interpreter would make Python > > more scalable. The current GIL behaves like the BKL in earlier Linux > > kernels. However, some third-party software, notably Apache's > > mod_python, is claimed to depend on this behaviour. > > I just looked into the reason why ctypes, mod_python, etc. depend on a > shared GIL. Well ... PyGILState_Ensure() does not take an argument, so > it does not know which interpreter's GIL to acquire. Duh! > > The sad fact is, the functions in Python's C API does not take the > interpreter as an argument, so they default to the one that is > currently active (i.e. the one that PyThreadState_Get()->interp points > to). This is unlike Java's JNI, in which all functions take the > "environment" (a Java VM instance) as the first argument. > > IMHO, I consider this a major design flaw in Python's C API. In a more > well thought API, PyGILState_Ensure would take the interpreter > returned by Py_NewInterpreter as an argument, and thus know the > interpreter with which to synchronize. > > I complained about this before, but the answer I got was that the > simplified GIL API would not work if interpreters has a separate GIL. > Obviously it would not work as long as the PyGILState_Ensure does not > take any arguments. The lack of a leading VM argument in > PyGILState_Ensure, and almost every function in Python's C API, is the > heart of the problem. Alternatively, the multiple interpreter API could be ripped out, and you could just use separate threads. Do you have a use case that requires it? From seberino at spawar.navy.mil Tue Apr 1 14:20:05 2008 From: seberino at spawar.navy.mil (seberino at spawar.navy.mil) Date: Tue, 1 Apr 2008 11:20:05 -0700 (PDT) Subject: What motivates all unpaid volunteers at Pycon? References: <7b539c8e-af4c-4409-81bc-d94e687eea59@i7g2000prf.googlegroups.com> Message-ID: <12d7412e-9f87-4798-a319-a78a27f68d00@e6g2000prf.googlegroups.com> On Mar 31, 7:35 pm, a... at pythoncraft.com (Aahz) wrote: > There really isn't any simple answer. Most people seem to be motivated > to help out their communities, I still think all this unselfishness is noteworthy and curious. Chris From victorsubervi at gmail.com Mon Apr 7 14:17:26 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Mon, 7 Apr 2008 19:17:26 +0100 Subject: Adding Images To MySQL In-Reply-To: References: <4dc0cfea0804050732x7dc2ac41n64d56dda9da27a82@mail.gmail.com> Message-ID: <4dc0cfea0804071117n49dd6faam90032dbc787487e5@mail.gmail.com> in line... On 4/5/08, Gabriel Genellina wrote: > > En Sat, 05 Apr 2008 11:32:00 -0300, Victor Subervi > escribi?: > > >> * *- You say Content-Type: image/jpeg but you emit HTML code. You're > >> lucky > > if you see any > > > >> * *text at all. > > > > Well, I tried Content-Type: text/html and that threw an HTTP 500 Error. > > If your script raised any exception, that's the expected code. (500 = > internal error = your code has errors). But it's not very useful for > debugging; using cgitb or wrapping the code in try/except as has already > been suggested, lets you see the exception and traceback. Yes, and I have employed your suggestion of cgtib, and I sent you personally under separate cover the errors, since I forgot to include them in this post. >> * *- HTTP 200 is not an error, it means the request was successful. > > > > When it doesn?t execute the code, how can it be called successful? If it > > doesn?t execute the code, how can you say it?s not an error? What is it, > > then? > > Well, your web server thinks all went ok... BTW, you did't provide details > about it, I *guess* you're using CGI because of the print "Content-Type" > line. Yes, that is correct... >> * *- As a general advice, try to isolate the problems. Test the database > > stuff alone, in a local > >> * *application. Test the cgi script alone, without database > interaction. > > Test the database stuff in > >> * *the web server (better if you have a shell account). Merge all and > >> test > > again. > > > > Very good advice. Please help me understand how to do that. > > > > This is what I have done. I have tried these: > > > > sql = "'insert into products (" + col_names + ") values (" + val + ")', > > (" + > > col_names + ")" > > > > cursor.execute(sql) > > > > and > > > > sql = "'insert into products (" + col_names + ") values (" + val + ")'" > > > > cursor.execute(sql, (col_names,)) > > > > Neither work. > > You got a syntax error, I guess. What's that ' at the start? > I'll try to explain it from the ground up. This would be a valid SQL > statement:: > > insert into PRODUCTS (PRODID, NAME, DESCRIPTION) > values (123, 'Easter egg 80g', 'A longer description'); > > In Python, you need the SQL text inside a string:: > > sql = "insert into PRODUCTS (PRODID, NAME, DESCRIPTION) " \ > "values (123, 'Easter egg 80g', 'A longer description');" > > and you can execute it with:: > > cursor.execute(sql) > > That would be OK when you create the database for the first time. Later > your boss comes in and says: "We've got bigger eggs! Code 124, 150g each. > We need them in the database". You write an sql statement similar to > above. Some days later, they decide to sell bubble gum. Forty-two > different sizes and flavors and brands. You don't want to write all that > sql statements by hand. Your first thought is to build the sql text by > pieces:: > > sql = "insert into PRODUCTS (PRODID, NAME, DESCRIPTION) " \ > "values ("+str(prodid)+", '"+prodname+"', '"+description+"');" > > But then you remember to have read something about sql injection and you > don't like that mess of " + ) ' ( anyway. After reading some articles > about DBAPI 2, PEP 249, the MySQLdb module, you write this:: > > sql = "insert into PRODUCTS (PRODID, NAME, DESCRIPTION) " \ > "values (%s,%s,%s);" > cursor.execute(sql, (prodid, prodname, description)) > > and it works fine. > > Note that execute has two arguments: first, a string with the sql > statement text; second, a tuple containing the values. The %s in the sql > text are placeholders, they're replaced with the corresponding value from > the second argument. And there is no ' anywhere. Well, what I did, that now works, was essentially what you suggested, and simply assigned null values to variables that accept null values in the database. That works. What I was trying to do was build up just those variables that were to be updated or entered, and supply only those arguments. At this point it is rather academic, but can that be done? > However, if I print what that code spits out: > > > > sql = "'insert into products (" + col_names + ") values (" + val + ")', > > (" + > > col_names + ")" > > > > print sql > > > > then copy and paste it into a cursor.execute() statement, viola! > > Everything > > works _just_fine_. Go figure. Why?? > > What you have done has no sense - why do you think it should work? See above. > pic1 = _mysql.escape_string(f) > > > > It does not like this (forgot error): > > > > pic1 = MySQLdb.Binary(f) > > You should make the above work. Look at the exception, read the error > message, look at the traceback. There are a lot of info there. Amazingly (because I thought I had tested this) both the escape string and the db Binary work now. > Escaping the string, I can successfully load this image into the > > database, > > along with all the other fields. Now, when I load an image from the form > > on > > the previous page with this code: > > > > > > > print '"', MySQLdb.Binary(data[14]), '"' > > > > and send the form off to the next page, when I process it on that page > > Why do you do *that*??? That element is for the user to upload a > file; if the file is already on the server, why do you transfer it from > server to client and back to server? I doubt it can work this way. And why > are you using Binary here? Binary is for sql stuff and you're building an > HTML page here. (btw, didn't you say that Binary doesn't work?). I said it did not work in the other page, but now it does. Anyway, what gets uploaded is a binary string. How can I convert that into a pretty picture? > pic1 = _mysql.escape_string(pic1) > > > > print pic1 > > > > it prints out a messy binary that (almost) starts with something like > > ?This > > program can only be run in Win32?, whatever that means. But a binary is > > printed. (It may be an infinite binary, I stopped it after a few > > minutes.) > > Looks like a .exe; somehow you managed to upload a .exe instead of a jpg, > I presume... It was an image. At any rate, I do not see that in the images (or binary strings) now loaded. > Now, if I stick it into the cursor.execute like I did above, it throws an > > HTTP non-error non-posting-to-the-database 200 error. I?m more than > > happy to > > separate all this garbage out for further testing, but I don?t know how > > to > > do that. Your help is very much appreciated. > > It seems you have a basic misunderstanding of how web applications work. > Reading a book like "Python Web Programming" by Steve Holden might help. > > http://www.amazon.com/Python-Programming-Landmark-Steve-Holden/dp/0735710902 I have done a lot of reading over the years and I presume a lot of forgetting. At any rate, looks like everything is working, thanks to your help, except for the displaying of the image as opposed to the binary string, which is no doubt some other stupid little mistake of mine. No errors to send to analyze now. Can you shed some light on this last issue? Again, thank you very much for your help and patience! Victor -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Tue Apr 15 10:36:57 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 15 Apr 2008 15:36:57 +0100 Subject: Get oldest folder In-Reply-To: <22671872.735671208269119432.JavaMail.root@hrndva-web19-z02> References: <22671872.735671208269119432.JavaMail.root@hrndva-web19-z02> Message-ID: <4804BD89.6000208@timgolden.me.uk> jyoung79 at kc.rr.com wrote: > I'd like to be able to get the path to the oldest folder in whatever directory > I'm currently in. Is there a simple way to go about this? > I'd like it to run on both OS X and Windows XP. > I found this example but was curious if there's a better way to do this? Better: I don't know. Alternative, certainly: import os, glob PATH = "c:/python25/lib/site-packages" print min ((f for f in glob.glob (os.path.join (PATH, "*")) if os.path.isdir (f)), key=os.path.getctime) TJG From carbanancizpo at gmail.com Fri Apr 18 16:57:54 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:57:54 -0700 (PDT) Subject: foundation crack Message-ID: <1e167114-2be7-489d-867a-676e309bc61a@c65g2000hsa.googlegroups.com> foundation crack http://cracks.12w.net F R E E C R A C K S From wwzaygvm at gmail.com Wed Apr 16 17:01:55 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 14:01:55 -0700 (PDT) Subject: win xp sp2 keygen Message-ID: <97b9d09b-16db-421f-a96b-332ef246757a@f36g2000hsa.googlegroups.com> win xp sp2 keygen http://cracks.12w.net F R E E C R A C K S From brooklineTom at gmail_spam_blocking_suffix.com Tue Apr 1 08:23:18 2008 From: brooklineTom at gmail_spam_blocking_suffix.com (brooklineTom at gmail_spam_blocking_suffix.com) Date: Tue, 01 Apr 2008 08:23:18 -0400 Subject: class super method References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> Message-ID: On Mon, 31 Mar 2008 21:41:37 -0500, Ed Leafe wrote: >On Mar 31, 2008, at 5:58 PM, George Sakkis wrote: > >>> is there any tutorial for super method (when/how to use it)? >>> >>> or maybe someone could explain me how it works? >>> >>> thx >> >> Super is one of the dark corners of the language [1,2]... a good rule >> of thumb is to stay away from it, or at least stick to its basic >> usage. > > > I disagree - super is quite elegant and dependable. > > Because Python support multiple inheritance, it is difficult to >manually ensure that when augmenting a method that the correct >superclass calls are made. super() handles that without having to >guess as to what the correct inheritance hierarchy is. > > In my own project (Dabo), we use mixin classes liberally to provide >consistent behavior across our UI classes. The use of super makes >customizing __init__() behavior, for example, quite straightforward. >The general form looks like: > >class DaboUIClass(dabo.ui.dControlMixin, someWxPythonClass): > def __init__(self, *args, **kwargs): > doOurCustomStuffBeforeTheSuperCall() > super(DaboUIClass, self).__init__(*args, **kwargs) > doOurCustomStuffAfterTheSuperCall() > > This has worked reliably for us in every place where we have used it. >There's nothing dark and mysterious about it at all. Perhaps it's the oo-think that seems "dark and mysterious", rather than anything about super. In my experience, "super" works just fine. It is a bit tedious, in that it's all too easy to forget to change the first parameter when moving a method that contains super to a different class. I've also found myself wondering: 1. What are the two arguments to super used for? 2. What happens when the method supplied *after* the super is different from the containing method? In the above example what happens if: class DaboUIClass(dabo.ui.dControlMixin, someWxPythonClass): def __init__(self, *args, **kwargs): doOurCustomStuffBeforeTheSuperCall() super(DaboUIClass, self).callRandomMethod(foobar) doOurCustomStuffAfterTheSuperCall() From istvan.albert at gmail.com Wed Apr 9 11:59:34 2008 From: istvan.albert at gmail.com (Istvan Albert) Date: Wed, 9 Apr 2008 08:59:34 -0700 (PDT) Subject: I am worried about Python 3 References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> <47fce3ca$0$36346$742ec2ed@news.sonic.net> Message-ID: On Apr 9, 11:53 am, John Nagle wrote: > The general consensus is that Python 3.x isn't much of an there are a number of unfortunate typos in there that interfere with the message, instead of "The general consensus is" I think you actually meant "In my opinion" i. From pscott at uwc.ac.za Mon Apr 7 04:03:35 2008 From: pscott at uwc.ac.za (Paul Scott) Date: Mon, 07 Apr 2008 10:03:35 +0200 Subject: First Python project - comments welcome! Message-ID: <1207555415.6966.88.camel@paul-laptop> I have started, and made some progress (OK it works, but needs some love) on my first real Python application. http://cvs2.uwc.ac.za/trac/python_tools/browser/podder I would love some feedback on what I have done. In total this has taken me 5 nights to do (I am working on it at night as PHP, not Python, is my day job), so it can probably do with *lots* of improvement. All code is GPL. If anyone on this list is willing/able, please do give me a few pointers, even if it is "This is total crap - RTFM and come back when you are ready" I would really appreciate it! Many thanks, and thank you to this community for helping me through the initial bumps of getting into Python - a great dev tool IMHO! --Paul -------------- next part -------------- All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm From hopeorpha308 at gmail.com Sun Apr 27 07:45:20 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:45:20 -0700 (PDT) Subject: F-Secure 2007 crack Message-ID: <462e0099-151f-440e-8f97-cfa306ba801f@d1g2000hsg.googlegroups.com> F-Secure 2007 crack http://wga-cracks.crackkey.net From deets at nospam.web.de Wed Apr 9 17:25:47 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 09 Apr 2008 23:25:47 +0200 Subject: basic python question about for loop In-Reply-To: <5f71771d-e31d-439a-9ab9-5ea111a68b46@24g2000hsh.googlegroups.com> References: <664ovoF2iq9i0U1@mid.uni-berlin.de> <5f71771d-e31d-439a-9ab9-5ea111a68b46@24g2000hsh.googlegroups.com> Message-ID: <664qj3F2ied87U1@mid.uni-berlin.de> jmDesktop schrieb: > On Apr 9, 4:58 pm, "Diez B. Roggisch" wrote: >> jmDesktop schrieb: >> >> >> >> >> >>> From the Python.org tutorial: >>>>>> for n in range(2, 10): >>> ... for x in range(2, n): >>> ... if n % x == 0: >>> ... print n, 'equals', x, '*', n/x >>> ... break >>> ... else: >>> ... # loop fell through without finding a factor >>> ... print n, 'is a prime number' >>> ... >>> 2 is a prime number >>> 3 is a prime number >>> 4 equals 2 * 2 >>> 5 is a prime number >>> 6 equals 2 * 3 >>> 7 is a prime number >>> 8 equals 2 * 4 >>> 9 equals 3 * 3 >>> first time 2 mod 2, 2/2, no remainder == 0, what am I doing wrong? >>> Why did it fall through? >> print out what range(2, n) for n == 2 is. >> >> And if you didn't know - 2 *IS* a prime. >> >> Diez- Hide quoted text - >> >> - Show quoted text - > > I do not understand. for in loops over a sequence. And of course it doens't if the sequence is empty, because you can't loop over something that is empty, can't you? and range(2,2) is the empty sequence. Diez From grg2 at comcast.net Wed Apr 9 16:37:49 2008 From: grg2 at comcast.net (A_H) Date: Wed, 9 Apr 2008 13:37:49 -0700 (PDT) Subject: Love matplotlib, but.... Message-ID: I love matplotlib, but I want to do a polar plot using your basic compass type plot, i.e. zero degrees at the top, degrees going clockwise. I don't see a real easy way to do this. Any examples? Thanks! From kinch1967 at gmail.com Sun Apr 27 12:46:59 2008 From: kinch1967 at gmail.com (bullockbefriending bard) Date: Sun, 27 Apr 2008 09:46:59 -0700 (PDT) Subject: design choice: multi-threaded / asynchronous wxpython client? References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: <960ab78d-e764-4233-bab4-02ea0948db46@l28g2000prd.googlegroups.com> On Apr 27, 11:27?pm, "BJ?rn Lindqvist" wrote: > I think twisted is overkill for this problem. Threading, elementtree > and urllib should more than suffice. One thread polling the server for > each race with the desired polling interval. Each time some data is > treated, that thread sends a signal containing information about what > changed. The gui listens to the signal and will, if needed, update > itself with the new information. The database handler also listens to > the signal and updates the db. So, if i understand you correctly: Assuming 8 races and we are just about to start the race 1, we would have 8 polling threads with the race 1 thread polling at faster rate than the other ones. after race 1 betting closed, could dispense with that thread, change race 2 thread to poll faster, and so on...? I had been rather stupidly thinking of just two polling threads, one for the current race and one for races not yet run... but starting out with a thread for each extant race seems simpler given there then is no need to handle the mechanics of shifting the polling of races from the omnibus slow thread to the current race fast thread. Having got my minidom parser working nicely, I'm inclined to stick with it for now while I get other parts of the problem licked into shape. However, I do take your point that it's probably overkill for this simple kind of structured, mostly numerical data and will try to find time to experiment with the elementtree approach later. No harm at all in shaving the odd second off document parse times. From bj_666 at gmx.net Tue Apr 22 14:06:10 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 22 Apr 2008 18:06:10 GMT Subject: Problem using copy.copy with my own class References: Message-ID: <676noiF2n7ttmU1@mid.uni-berlin.de> On Tue, 22 Apr 2008 11:13:43 -0600, Jeffrey Barish wrote: > By the way, I have simplified somewhat the code in the explanation. Please simplify the code to a minimal example that still has the problem and *show it to us*. It's hard to spot errors in code that nobody except you knows. From lbonafide at yahoo.com Tue Apr 1 16:16:55 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Tue, 1 Apr 2008 13:16:55 -0700 (PDT) Subject: Is this a good time to start learning python? References: <47f1140e$0$735$a729d347@news.telepac.pt> <88fa881e-e59b-4682-801c-90ef08a1480a@a22g2000hsc.googlegroups.com> <1565ced8-afd7-4c32-a6ee-26f9b95d60bc@d45g2000hsc.googlegroups.com> Message-ID: On Apr 1, 2:42?pm, "Eduardo O. Padoan" wrote: > On Tue, Apr 1, 2008 at 4:20 PM, ? wrote: > > ?You misunderstand. ?C++ has a lot of "warts" to maintain backwards > > ?compatibility with C. ?The standards committee could eliminate these > > ?warts to make the language "cleaner", but it would break a lot of > > ?systems. > > It would not "break" anything that not move from C to C++, this is my point. You missed the point completely. C++ has a new version coming out soon, and as part of it, the less attractive parts of the language (like C compatibility) are NOT being removed, as that would break a lot of existing apps. > People not willing to take the migration path (porting to 2.6, using > the -3 flag, refactoring and re-running the tests untill the warning > are gone, using the 2to3 tool...) will not upgrade. No one will force > you to do it. 2.6 will not desappear from the python.org site anytime > soon. Will 2.6 be supported with patches and fixes going forward? From fetchinson at googlemail.com Wed Apr 16 22:19:02 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Wed, 16 Apr 2008 19:19:02 -0700 Subject: I just killed GIL!!! In-Reply-To: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: > Hello Guys... > > I just had one moment of exceptional clarity, during which realized > how I could get the GIL out of my way... It's so simple, I cannot help > wondering why nobody has thought of it before. Duh! Now I am going to > sit and and marvel at my creation for a while, and then go to bed > (it's past 2:30 a.m.) Tomorrow I will contemplate whether to sell this > little secret for big bucks, give it away for free, or just keep it to > myself... :-) > > Now you are probably thinking I reinvented the gunpowder, and are > running multiple processes. Not so. I am not running parallel > processes, like parallel python or the processing module in cheese > shop. I am running multiple THREADS. In fact, I am just using > threading.Thread. The source code is pure Python, so there is no C > magic, and I only used the stuff that's already there in the standard > library. So, I just made CPython do what everyone claim to be > impossible. One single process of CPython is using all the cpu power > of my dual-core laptop. If I were you I would keep it a secret until a Hollywood producer offers big bucks for the film rights. From sjmachin at lexicon.net Thu Apr 3 18:22:34 2008 From: sjmachin at lexicon.net (John Machin) Date: Thu, 3 Apr 2008 15:22:34 -0700 (PDT) Subject: expanding a variable to a dict References: Message-ID: <5a582bad-676d-4c95-b7d5-4e6ca4f676f3@b5g2000pri.googlegroups.com> On Apr 4, 8:56 am, idle wrote: > I've got a variable in a loop that I'm trying to expand/translate/ > readdress as an existing dict so as to add some keys into it.. > > eg; I have a set of existing dicts: dictFoo, dictBar, dictFrotz (names > changed to protect the innocent) > > now I'd like to check them all for the existence of certain default > keys; ie, if the dicts don't contain the keys, add them in with > default values. > > so, I've got: > > for a in ['dictFoo','dictBar','dictFrotz']: > if hasattr(a,'srcdir') == False: > a['srcdir']='/usr/src' > > the error I get (which I expect) is 'str' object doesn't support item > assignment. > > what incantation do I cast on 'a' to make the interpreter parse it as > 'dictFoo' on the first iteration, 'dictBar' on the second, and so > forth? > > and/or less importantly, what is such a transformation called, to help > me target my searching? > It's called "deleting extraneous apostrophes from source code". Happy googling! From jr9445 at ATT.COM Wed Apr 9 16:59:55 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Wed, 9 Apr 2008 15:59:55 -0500 Subject: basic python question about for loop In-Reply-To: References: Message-ID: > -----Original Message----- > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > list-bounces+jr9445=att.com at python.org] On Behalf Of jmDesktop > Sent: Wednesday, April 09, 2008 4:51 PM > To: python-list at python.org > Subject: basic python question about for loop > > >From the Python.org tutorial: > > >>> for n in range(2, 10): > ... for x in range(2, n): > ... if n % x == 0: > ... print n, 'equals', x, '*', n/x > ... break > ... else: > ... # loop fell through without finding a factor > ... print n, 'is a prime number' > ... > 2 is a prime number > 3 is a prime number > 4 equals 2 * 2 > 5 is a prime number > 6 equals 2 * 3 > 7 is a prime number > 8 equals 2 * 4 > 9 equals 3 * 3 > > > > first time 2 mod 2, 2/2, no remainder == 0, what am I doing wrong? > Why did it fall through? > a) 2 is prime, so nothing is wrong. b) Range isn't doing what you think it's doing: >>> print range(2,2) [] >>> print range(2,3) [2] >>> print range(2,4) [2, 3] >>> print range(2,5) [2, 3, 4] >>> print range(1,1) [] >>> print range(1,2) [1] >>> print range(1,3) [1, 2] >>> ***** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA622 From medin0065 at gmail.com Sun Apr 20 10:44:05 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:44:05 -0700 (PDT) Subject: band patch Message-ID: band patch http://cracks.00bp.com F R E E C R A C K S From robert.kern at gmail.com Wed Apr 16 19:18:55 2008 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 16 Apr 2008 18:18:55 -0500 Subject: Creating arithmetic sequences In-Reply-To: <54221025-2f61-40ad-beef-82cc74234d87@e39g2000hsf.googlegroups.com> References: <54221025-2f61-40ad-beef-82cc74234d87@e39g2000hsf.googlegroups.com> Message-ID: mmm wrote: > I wrote the code below to create simple arithmetic sequences that are > iter-able > I.e., this would basically combine the NUMPY arange(start,end,step) > to range(start,end), with step not necessarily an integer. > > The code below is in its simplest form and I want to generalize the > sequence types (multiplicative, cumulative, gauss ...), but first I > need the simple SEQA( ) function to be more robust. The problem is > the three test code functions produces different results based on > step. I understand why steps such as 0.1 have rounding and machine > math issues, and before I try to solve this I thought it was worth > asking if this problem has been solved (so I do not re-invent the > wheel). Using numpy.arange() with floats is known to be problematic, and it is discouraged. Almost all of the use cases are better served with numpy.linspace() which accepts a start, end, and the number of points rather than a step. -- 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 From musiccomposition at gmail.com Wed Apr 9 22:36:42 2008 From: musiccomposition at gmail.com (Benjamin) Date: Wed, 9 Apr 2008 19:36:42 -0700 (PDT) Subject: Module Conflicts References: <1592fad3-996b-4f62-ac12-42aff8272c21@8g2000hsu.googlegroups.com> Message-ID: <845e315c-0159-4390-954a-dc93fd1b27a1@x41g2000hsb.googlegroups.com> On Apr 9, 5:33 pm, Jose wrote: > I have a module named math.py in a package with some class > definitions. I am trying to import the standard python math module > inside of math.py but It seems to be importing itself. Is there any > way around this problem without renaming my math.py file? Not without some unpythonic magic. It's really not good style to name a module the same as a stdlib one. It'll also confuse people reading your code. From ptmcg at austin.rr.com Wed Apr 2 18:08:12 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Wed, 2 Apr 2008 15:08:12 -0700 (PDT) Subject: Understanding bmp image files References: <2537c458-b4d5-480d-8407-168a2b59a27e@u10g2000prn.googlegroups.com> Message-ID: On Apr 2, 2:22?pm, "Terry Reedy" wrote: > "pranav" wrote in message > > news:2537c458-b4d5-480d-8407-168a2b59a27e at u10g2000prn.googlegroups.com... > | Hello, > | I want to read a BMP file, do some processing and then write it in a > | new file. The problem is in the third step. For reading the file, i > | have converted the file into decimal numbers, representing the pixel > | values. Then i perform calculations on those decimal numbers. Now i am > | unable to convert those into the format as required by the "bmp" file. > | Any one, who is into image reading/manipulation, please help. > > I would look into PIL, PyGame, and Numeric/Numpy. My mistake, for some reason I thought the OP wanted to read a BMP file directly, and the code I cited shows the guts of writing out a BMP file so he might get an idea about the file's structure - to address the OP's actual question, I would second the recommendation to use PIL to read, manipulate, and write back out the pixel values. -- Paul From mnordhoff at mattnordhoff.com Mon Apr 7 03:04:04 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Mon, 07 Apr 2008 07:04:04 +0000 Subject: Help replacing os.system call with subprocess call In-Reply-To: <47F9B1D1.4090701@eastlink.ca> References: <47F9B1D1.4090701@eastlink.ca> Message-ID: <47F9C764.9070401@mattnordhoff.com> David Pratt wrote: > Hi. I am trying to replace a system call with a subprocess call. I have > tried subprocess.Popen and subprocess.call with but have not been > successful. The command line would be: > > svnadmin dump /my/repository > svndump.db > > This is what I am using currently: > > os.system('svnadmin dump %s > %s' % (svn_dir, > os.path.join(backup_dir, 'svndump.db'))) > > Many thanks. Try this: import os.path import subprocess p = subprocess.Popen( ['svnadmin', 'dump', svndir], stdout=subprocess.PIPE, ) fh = open(os.path.join(backup_dir, 'svndump.db'), 'wb') while True: chunk = p.stdout.read(2**20) # 1 MB if not chunk: break fh.write(chunk) fh.close() It reads svnadmin's stdout in 1 MB chunks, in case it's large enough that reading the whole thing into RAM at once would be a bad idea. No error handling. For one, you might want to add a try...finally to ensure that fh will get closed. (Or if you have Python 2.5, use a with statement! :-) ) Also, Popen will raise an OSError if svnadmin can't be found or something. And this isn't even considering svnadmin erroring out... svnadmin's stderr will go to your stderr. I didn't test it, but I'm pretty sure it will work. (I spotted a syntax error while writing that though.) I don't have much experience with Popen's stdio objects, so it's possible you'd need to do something like call p.wait() to wait for it to exit before being able to read its stdout. It could be slower than the os.system version, since now Python is doing all of the I/O, instead of your shell, but I doubt that'll be a big problem. (Also, insert suggestion about using a good VCS. ;-) ) -- From hniksic at xemacs.org Wed Apr 30 21:11:53 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Thu, 01 May 2008 03:11:53 +0200 Subject: relative import broken? References: <9c6ba5f9-d65b-4265-baba-fc5d7936781b@d1g2000hsg.googlegroups.com> Message-ID: <87prs6x1ye.fsf@mulj.homelinux.net> Sam writes: > I also have a problem with relative import; I can't for the life of me > figure out how to use the damn thing. I think the main problem is with > getting Python to recognize the existence of a package. I have > > S/ > p.py > B/ > b.py > W/ > pyw/ > u.py > ws.py > > and I'd like to get u.py to import all the other 3 programs. I put > empty __init__.py files in all of the above directories (is this > necessary?), and even manually added the pathway (r'C:\Myname\S') to > sys.path, but when I execute > > from S import p > > in u.py Python gives "ImportError: No module named S". A silly question: is the directory that contains "S" in PYTHONPATH or in sys.path? > The docs for relative import make this sound much easier than it is. It's supposed to be just as easy as it sounds. For example: $ mkdir S $ touch S/p.py $ touch S/__init__.py $ python Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from S import p >>> p From mensanator at aol.com Thu Apr 17 14:56:53 2008 From: mensanator at aol.com (Mensanator) Date: Thu, 17 Apr 2008 11:56:53 -0700 (PDT) Subject: sampling without replacement References: <6017ea8d-6ee8-44ea-bdad-bf06299a9cd5@a23g2000hsc.googlegroups.com> <7xwsmxudw2.fsf@ruckus.brouhaha.com> Message-ID: <15843892-2f7f-477c-837d-a4c7917ae31f@m3g2000hsc.googlegroups.com> On Apr 17, 2:41?am, Paul Rubin wrote: > braver writes: > > Using an array is natural here as it represents "without replacement" > > -- we take an element by removing it from the array. ?But in Python > > it's very slow... ?What approaches are there to implement a shrinking > > array with random deletions with ?the magnitude of millions of > > elements? > > The obvious way is use random.sample(), is there some reason you > don't do that? > > Alternatively, when you select an element a[k] from the middle of the > array, instead of deleting that element and moving the rest down (del > a[k]), do something like: > > ? ?k = random.randint(0,len(a)-1) > ? ?selection = a[k] > ? ?a[k] = a[-1] > ? ?a.pop() > > That deletes the last element (avoiding moving them around) after > storing it in the newly freed slot. ?Of course it messes up the order > of the array, which won't matter for selecting random elements, but > might matter for some other reason in your program. What about an initial random shuffle on the array and then always pop the last element? Or for that matter, why even pop it, why not just take succesively larger negative indexes as the "last" element? From frikker at gmail.com Wed Apr 30 14:19:32 2008 From: frikker at gmail.com (blaine) Date: Wed, 30 Apr 2008 11:19:32 -0700 (PDT) Subject: Simple TK Question - refreshing the canvas when not in focus References: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> <4818349e$0$2959$ba620e4c@news.skynet.be> <182ace66-bdf6-409c-85ee-fd764de8e1c6@z72g2000hsb.googlegroups.com> Message-ID: <8fbf2b85-1b6a-4f6c-a84e-934609fd0e4e@c58g2000hsc.googlegroups.com> On Apr 30, 10:41 am, Peter Otten <__pete... at web.de> wrote: > blaine wrote: > > Still doesn't work. I'm looking into using wx instead... > > > This is the full code - does it work for anyone else? Just do a echo > > 'line 0 0 10 10' > dev.file > > Haven't tried it, but I think that the problem is that you are updating the > UI from the "readthread". A good example to model your app after is here: > > http://effbot.org/zone/tkinter-threads.htm > > Peter Update: Not only is that a good model, its exactly what I'm trying to do. Thanks again! From gherron at islandtraining.com Wed Apr 2 17:00:26 2008 From: gherron at islandtraining.com (Gary Herron) Date: Wed, 02 Apr 2008 14:00:26 -0700 Subject: Recursive function won't compile In-Reply-To: References: Message-ID: <47F3F3EA.9050608@islandtraining.com> bc1891 at googlemail.com wrote: > #include > #include > > def RecursiveFact(n): > if(n>1): > return n*RecursiveFact(n-1) > else: > return 1 > > fact = RecursiveFact(31) > print fact > > fact = "End of program" > print fact > > > ......but yet it still gives the right answer. How is this possible? > Why not? What did you expect? Hint: The first two lines are comments to Python -- so are ignored. The last two lines just print a string -- no problem there. The recursive calculation is standard -- the extra set of parenthesis in the if don't cause any problem. So again please: Why are you surprised? Gary Herron From MartinRinehart at gmail.com Tue Apr 8 10:21:22 2008 From: MartinRinehart at gmail.com (MartinRinehart at gmail.com) Date: Tue, 8 Apr 2008 07:21:22 -0700 (PDT) Subject: import statement convention Message-ID: <4078bcf4-e68f-45d4-93ce-335ec7a33c5a@v32g2000prd.googlegroups.com> By convention, I've read, your module begins with its import statements. Is this always sensible? I put imports that are needed for testing in the test code at the end of the module. If only a bit of the module has a visual interface, why pollute the global namespace with 'from Tkinter import *'? Wouldn't that be better done in a separate class or function? Can we do a better job with a thoughtful rewrite of this convention? From deets at nospam.web.de Sun Apr 6 15:58:48 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Sun, 06 Apr 2008 21:58:48 +0200 Subject: traceback.print_exc() supposed to stop exception propagation. In-Reply-To: <69-dnW_JftMHvGTanZ2dneKdnZydnZ2d@bt.com> References: <69-dnW_JftMHvGTanZ2dneKdnZydnZ2d@bt.com> Message-ID: <65sobvF2g2vr6U1@mid.uni-berlin.de> Sami schrieb: > Hello, > > In the Python book that I am using to learn the language it says that > the traceback.print_exc() can be used to stop exception propagation and > make the program keep running. > > Here is a simple piece of code that I typed in to test this fact: > --------------------------------------------------------------------------- > import sys > > def Myexcepthook(etype, value, tb): > print "in Myexcepthook\n" > import traceback > lines=traceback.format_exception(etype, value, tb) > print "\n".join(lines) > traceback.print_exc() > > > sys.excepthook = Myexcepthook > > x = 1/0 > > x = 78 > > print x > -------------------------------------------------------------------------- > The Output: > -------------------------------------------------------------------------- > in Myexcepthook > > Traceback (most recent call last): > > File > "E:\Home\Programming\Python\TryProjects\ExceptHandling1\Except2.py", lin > 15, in > x = 1/0 > > ZeroDivisionError: integer division or modulo by zero > > None > -------------------------------------------------------------------------- > > I never see the value 78. > > What am I doing wrong? Trusting a wrong source. Or misinterpreting it. Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. imWelcome to rlcompleter2 0.96 for nice experiences hit multiple times >>> import traceback >>> help(traceback.print_exc) Help on function print_exc in module traceback: print_exc(limit=None, file=None) Shorthand for 'print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback, limit, file)'. (In fact, it uses sys.exc_info() to retrieve the same information in a thread-safe way.) >>> Nothing in there says that this would prevent the exception from being propagated. Diez From grante at visi.com Sat Apr 26 11:21:13 2008 From: grante at visi.com (Grant Edwards) Date: Sat, 26 Apr 2008 10:21:13 -0500 Subject: Pyserial - send and receive characters through linux serial port References: Message-ID: On 2008-04-25, terry wrote: > I am trying to send a character to '/dev/ttyS0' and expect the > same character and upon receipt I want to send another > character. I tired with Pyserial but in vain. Pyserial works. I've been using it almost daily for many years. Either your program is broken, your serial port is broken, or the device connected to the serial port is broken. > Test Set up: > > 1. Send '%' to serial port and make sure it reached the serial port. > 2. Once confirmed, send another character. > > I tried with write and read methods in Pyserial but no luck. > > Can you help? Ah yes, the problem is in line 89 of your program. We've no way to help if you don't provide details. If you really want help, write as small a program as possible that exhibits the problem. I'd like to emphasize _small_. The larger the program the less likely people are to look at it, and the less likely they are to find the problem if they do look at it. Much of the time the exercise of writing a small demo program will lead you to the answer. If not, then post it, along with the output from the program that shows the problem. Then we can tell you what you did wrong. -- Grant Edwards grante Yow! I'm also against at BODY-SURFING!! visi.com From mensanator at aol.com Wed Apr 23 00:30:47 2008 From: mensanator at aol.com (Mensanator) Date: Tue, 22 Apr 2008 21:30:47 -0700 (PDT) Subject: IDLE gripe and question References: Message-ID: <95f218ba-4925-491a-bf9c-047ac201e0c7@2g2000hsn.googlegroups.com> On Apr 22, 7:42?pm, Dick Moores wrote: > I have IDLE 1.2.1, on Win XP, Python 2.5.1. > > The first time I use File | Open to open a script, the Open dialogue > box always opens at E:\Python25\Lib\idlelib. Most of the scripts I > want to access are in E:\PythonWork. There doesn't seem to be a way > to change the default folder to E:\PythonWork, but is there? First, find the shortcut that lauches IDLE. On my Vista system it's in C:\Program Data\Microsoft\Windows\Start Menu\Programs\Python 2.5 XP will be different, I think there're start menu directories under each user and a default one. Anyway, once you have the shortcut (mine was named IDLE (Python GUI)), right-click and select Properties. There's a property attribute labeled Start In. Set that to the directory where your scripts are. The menu Open will now default to that directory. Mine is C:\Python25\user, a directory I created after installing Python. > > Thanks, > > Dick Moores > > ? ? ? ? ? ? ================================ > UliPad <>:http://code.google.com/p/ulipad/ From tdimson at gmail.com Thu Apr 10 09:59:09 2008 From: tdimson at gmail.com (Thomas Dimson) Date: Thu, 10 Apr 2008 06:59:09 -0700 (PDT) Subject: subprocess.Popen() output to logging.StreamHandler() References: Message-ID: <4a1e850d-064f-49b8-87c7-140f10fc88c3@z38g2000hsc.googlegroups.com> On Apr 10, 8:11?am, "sven _" wrote: > Version: Python 2.5.1 (r251:54863, Mar ?7 2008, 04:10:12) > > My goal is to have stdout and stderr written to a logging handler. > This code does not work: > > # START > import logging, subprocess > ch = logging.StreamHandler() > ch.setLevel(logging.DEBUG) > subprocess.call(['ls', '-la'], 0, None, None, ch, ch) > # END > > Traceback (most recent call last): > ? File "log.py", line 5, in > ? ?subprocess.call(['ls', '-la'], 0, None, None, ch, ch) > ? File "/usr/lib/python2.5/subprocess.py", line 443, in call > ? ?return Popen(*popenargs, **kwargs).wait() > ? File "/usr/lib/python2.5/subprocess.py", line 586, in __init__ > ? ?errread, errwrite) = self._get_handles(stdin, stdout, stderr) > ? File "/usr/lib/python2.5/subprocess.py", line 941, in _get_handles > ? ?c2pwrite = stdout.fileno() > AttributeError: StreamHandler instance has no attribute 'fileno' > > This is because subprocess.Popen() expects file descriptors to write > to, and logging.StreamHandler() does not supply it. The StreamHandler > could supply its own stdout file descriptor, but then Popen() would > write directly to that file, bypassing all the logging fluff. > > A possible solution would be to make a named pipe (os.mkfifo()), have > Popen() write to that, and then have some horrendous hack run select() > or similar on the fifo to read from it and finally pass it to > StreamHandler. > > Are there better solutions? > > sven What is wrong with doing something like: import logging, subprocess ch = logging.StreamHandler() ch.setLevel(logging.DEBUG) s = subprocess.Popen( ['ls','-la'], stdout=subprocess.PIPE ) while 1: ch.info( s.stdout.readline() ) if s.poll() == None: break Perhaps not the most efficient or clean solution, but that is how I usually do it (note: I didn't test the above code). -Thomas Dimson From wizzardx at gmail.com Tue Apr 15 16:55:15 2008 From: wizzardx at gmail.com (David) Date: Tue, 15 Apr 2008 22:55:15 +0200 Subject: Getting subprocess.call() output into a string? In-Reply-To: References: Message-ID: <18c1e6480804151355n10e61ec2ye59ee1a0cd6fdefc@mail.gmail.com> On Tue, Apr 15, 2008 at 10:36 PM, Tobiah wrote: > I am not sure how to capture the output of a command > using subprocess without creating a temp file. I was > trying this: > > import StringIO > import subprocess > > file = StringIO.StringIO() > > subprocess.call("ls", stdout = file) > > Traceback (most recent call last): > File "", line 6, in ? > File "/usr/local/lib/python2.4/subprocess.py", line 413, in call > return Popen(*args, **kwargs).wait() > File "/usr/local/lib/python2.4/subprocess.py", line 534, in __init__ > (p2cread, p2cwrite, > File "/usr/local/lib/python2.4/subprocess.py", line 840, in _get_handles > c2pwrite = stdout.fileno() > AttributeError: StringIO instance has no attribute 'fileno' > > So how do I get the output into a string? > > I thought that the idea of StringIO was that it could be > used where a file was expected. > For basic file-like read and write. But it won't provide a file handle since there is no 'real' file. Also, from 2.3.9 File Objects: "File-like objects which do not have a real file descriptor should not provide this method!" You should use the PIPE subprocess argument to capture output. From the tutorial: 6.8.3.1 Replacing /bin/sh shell backquote output=`mycmd myarg` ==> output = Popen(["mycmd", "myarg"], stdout=PIPE).communicate()[0] From ZeeGeek at gmail.com Wed Apr 9 22:12:00 2008 From: ZeeGeek at gmail.com (ZeeGeek) Date: Wed, 9 Apr 2008 19:12:00 -0700 (PDT) Subject: email header decoding fails Message-ID: It seems that the decode_header function in email.Header fails when the string is in the following form, '=?gb2312?Q?=D0=C7=C8=FC?=(revised)' That's when a non-encoded string follows the encoded string without any whitespace. In this case, decode_header function treats the whole string as non-encoded. Is there a work around for this problem? Thanks. From jr9445 at ATT.COM Tue Apr 1 11:14:40 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Tue, 1 Apr 2008 10:14:40 -0500 Subject: Is this a good time to start learning python? In-Reply-To: References: <47f1140e$0$735$a729d347@news.telepac.pt> Message-ID: > -----Original Message----- > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > list-bounces+jr9445=att.com at python.org] On Behalf Of Ant > Sent: Monday, March 31, 2008 5:58 PM > To: python-list at python.org > Subject: Re: Is this a good time to start learning python? > > On Mar 31, 5:40 pm, Rui Maciel wrote: > > BTW. I have to disagree with Andrew's comment: "With Perl, > once you get the core syntax down, you don't need to master Perl. > Instead you just look up the module/feature you want to use and just > use > it.". This may be true for knocking up Perl scripts, but for reading > *other peoples* code in any language you need to have a good mastery > of the core language. In Perl this is a quagmire of strange syntax, > special cases, multiple ways to do the same thing and esoterica/magic, > whereas Python's design to make whitespace significant and its "One > (obvious) way to do things" philosophy makes reading other peoples > code much easier. (Of course other peoples code always sucks, but > hey ;-) Eh... reading other people's Python code can be pretty hit or miss too. Between undeclared variables (did you mean to reuse that variable name?) and dynamic typing, Python can be really tough to follow. Add in side effects, over-use of lambdas, and the really hit or miss quality of Python's documentation, and Python can be just as difficult to follow as Perl. The things that make code readable are good comments, good design (Python emphasizes OO which helps,) and well-structured code (i.e. don't combine 3-4 operations in a single line.) This holds true for any language, so I wouldn't go out of my to ding Perl. IME. > its "One (obvious) way to do things" philosophy Given some of the solutions people have proposed to code questions in the past, I'm going to pretend you didn't say that. ;-) From luismgz at gmail.com Thu Apr 3 11:28:15 2008 From: luismgz at gmail.com (=?ISO-8859-1?Q?Luis_M=2E_Gonz=E1lez?=) Date: Thu, 3 Apr 2008 08:28:15 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> <89bca327-6a3f-4128-be72-75d4a50b9bf0@13g2000hsb.googlegroups.com> <47f4e456$0$20141$426a74cc@news.free.fr> Message-ID: <90b1bd9e-bf55-43c6-a5b9-d97cacb94b8a@z38g2000hsc.googlegroups.com> Yes, webpy's db api can be used in stand-alone scripts if you want. See below: import web db = web.database(dbn='mysql', db='northwind', user='root') x = db.select('employees') ... Another good thing is that, since queries return Storage objects (similar to dictionaries), they are much more flexible. Suppose that you get the results of a form sent via a POST method, and you want to insert this data into your database. You would simple write: i = web.input() db.insert('orders', **i) So everything related to CRUD operations are is easy to do, without having to mess with objects. I think this sticks strictly to the KISS principle, keeping it simple, with less overhead, less layers of abstraction and therefore, less bugs and complications. And it matchs perfectly webpy's philosofy for creating web apps. Luis On 3 abr, 11:06, Bruno Desthuilliers wrote: > Seems nice too in another way. Is that part independant of the rest of > the framework ? If so, I'll have to give it a try at least for admin > scripts. From usenet at janc.be Fri Apr 25 17:18:30 2008 From: usenet at janc.be (Jan Claeys) Date: Fri, 25 Apr 2008 21:18:30 GMT Subject: pop langs website ranking References: <41fbaf27-a80b-402b-b406-c048a65a8643@b64g2000hsa.googlegroups.com> Message-ID: Op Wed, 23 Apr 2008 04:07:31 +0000, schreef Roedy Green: > The weakness of this approach is it is unusual group of people who will > voluntarily submit to having their usage spied on. These are not a > typical group or a large group. Hello, planet Earth calling? I guess around 90% of internet users don't care, mostly because they don't know this is happening (how many people do you think read EULAs?). Alexa's & Google's & other (often less legal) profiling tools come with lots of pseudo-freeware applications these days... -- JanC From victorsubervi at gmail.com Wed Apr 9 14:29:21 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 9 Apr 2008 14:29:21 -0400 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> <47FCF421.6000807@holdenweb.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> Message-ID: <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> On Wed, Apr 9, 2008 at 1:49 PM, Steve Holden wrote: > Victor Subervi wrote: > > On Wed, Apr 9, 2008 at 12:51 PM, Steve Holden > > wrote: > I imagine the following code should do so, given your earlier writings: > > #! /usr/bin/python > > import MySQLdb > > print "Content-type: image/jpeg\r\n" > host = 'host' > db = 'bre' > user = 'user' > passwd = 'pass' > connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > cursor = connection.cursor() > cursor.execute('select img from photo where id="7";') > content = cursor.fetchall()[0][0] > f = open("somefile.jpg", "w") > f.write(content) > f.close() > > Then see if you can deal with "somefile.jpg" like any other JPEG. If you > can't then your blobs are somehow being mangled. If you can, we'll take > it from there. Yes, I can. Shows up in browser when surfed to, and it was pulled from the database. No mangling. I am signing off, back tomorrow morning. TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From tinnews at isbd.co.uk Sun Apr 6 12:04:57 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 06 Apr 2008 16:04:57 GMT Subject: Presumably an import is no faster or slower than opening a file? References: <47f8d30f$0$761$bed64819@news.gradwell.net> <546467f9-807c-475b-a2ae-9e8faae03825@u3g2000hsc.googlegroups.com> Message-ID: <47f8f4a9$0$758$bed64819@news.gradwell.net> bruno.desthuilliers at gmail.com wrote: > On 6 avr, 15:41, tinn... at isbd.co.uk wrote: > > I'm trying to minimise the overheads of a small Python utility, I'm > > not really too fussed about how fast it is but I would like to > > minimise its loading effect on the system as it could be called lots > > of times (and, no, I don't think there's an easy way of keeping it > > running and using the same copy repeatedly). > > > > It needs a configuration file of some sort which I want to keep > > separate from the code, is there thus anything to choose between a > > configuration file that I read after:- > > > > f = open("configFile", 'r') > > > > ... and importing a configuration written as python dictionaries or > > whatever:- > > > > import myConfig > > In both cases, you'll have to open a file. In the first case, you'll > have to parse it each time the script is executed. In the second case, > the first import will take care of compiling the python source to byte- > code and save it in a myConfig.pyc file. As long as the myConfig.py > does not change, subsequent import will directly use the .pyc, so > you'll save on the parsing/compiling time. FWIW, you can even > "manually" compile the myConfig.py file, after each modification, and > only keep the myConfig.pyc in your python path, so you'll never get > the small overhead of the "search .py / search .pyc / compare > modification time / compile / save" cycle. > > While we're at it, if you worry about the "overhead" of loading the > conf file, you'd better make sure that either you force the script > compilation and keep the .py out of the path, or at least keep the > script.py file as lightweight as possible (ie : "import somelib; > somelib.main()", where all the real code is in somelib.py), since by > default, only imported modules get their bytecode saved to .pyc file. > > Now I may be wrong but I seriously doubt it'll make a huge difference > anyway, and if so, you'd really preferer to have a long running > process to avoid the real overhead of launching a Python interpreter. > Thanks for the comments, mostly about what I was thinking too but I just wanted to check that I'm not missing anything really obvious. -- Chris Green From martin at v.loewis.de Fri Apr 4 15:25:58 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Fri, 04 Apr 2008 21:25:58 +0200 Subject: Examples using msilib to build windows installers In-Reply-To: References: Message-ID: <47F680C6.4070802@v.loewis.de> > It would appear to me that the msilib library included with standard > python 2.5 would allow be to do this. I found the source code that > builds the python distrubition installer packages, but I was wondering > if there were other examples that I can learn from. Actually, the installer itself is built with Tools/msi/msilib, which predates the msilib shipped in 2.5; the former one uses ActiveX (automation), whereas the latter one links directly to a native library (and hence doesn't require PythonCOM). That library was also used (with modifications) to build Enthought Python. In any case, the single known application of the shipped msilib is the bdist_msi command of distutils. If you want to start using MSI, you absolutely have to know about the database tables and their purpose. Use orca.exe to inspect MSI files, and try to make sense out of that. Read MSDN documentation. msilib greatly helps in writing installers quickly, but the "learning curve" is perhaps even steeper than "mere" MSI, as you need to understand both the MSI principles themselves, and then how msilib wraps it in a more compact form. Of course, if you can manage to package your application as a distutils package, you can just try running bdist_msi, and see what you get. Regards, Martin From contact at dann.ro Wed Apr 16 22:15:52 2008 From: contact at dann.ro (Daniel NL) Date: Thu, 17 Apr 2008 05:15:52 +0300 Subject: index of list of lists Message-ID: <1208398552l.41837l.0l@ns.bitcarrier.eu> yes, there's a thread with the same title, but I believe mine is more appropriate title. so, as much as I search on the web, read manuals, tutorials, mail-lists (including this one) I cannot figure it out how to search a string in a list of lists. like this one: someList = [['somestring', 1, 2], ['oneother', 2, 4]] I want to search "somestring" in someList which is in practice a list of aprox. 200 lists. (hey, I'm a newbie python programmer, don't judge me). is the list.index the wrong approach? should I use numpy, numarray, something else? can anyone, be kind and help me with this? From detlev at die-offenbachs.de Sat Apr 5 10:15:29 2008 From: detlev at die-offenbachs.de (Detlev Offenbach) Date: Sat, 05 Apr 2008 16:15:29 +0200 Subject: ANN: eric4 4.1.2 released Message-ID: Hi, eric4 4.1.2 has been released today. This release fixes a few bugs reported since the last release. As usual it is available via http://www.die-offenbachs.de/eric/index.html. What is eric? ------------- eric is a Python IDE written using PyQt4 and QScintilla2. It comes with batteries included. Please see a.m. link for details. Regards, Detlev -- Detlev Offenbach detlev at die-offenbachs.de From sturlamolden at yahoo.no Fri Apr 11 19:31:17 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 11 Apr 2008 16:31:17 -0700 (PDT) Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: <101680ba-a116-414b-8fff-c5b5bd2f4b65@p39g2000prm.googlegroups.com> On Apr 11, 5:01 am, "Gabriel Genellina" wrote: > Another annoying thing with the Qt license is that you have to choose it > at the very start of the project. You cannot develop something using the > open source license and later decide to switch to the commercial licence > and buy it. Trolltech is afraid companies will buy one licence when the task is done, as oppsed to one license per developer. In a commercial setting, the Qt license is not expensive. It is painful for hobbyists wanting to commercialize their products. From aaron.watters at gmail.com Wed Apr 16 09:59:32 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 16 Apr 2008 06:59:32 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: On Apr 16, 9:16 am, Marco Mariani wrote: > > Do you mean Ruby's track in providing backward compatibility is better > than Python's? > > Googling for that a bit, I would reckon otherwise. I can't comment on that. Ruby is a lot younger -- I'd expect it to still be stabilizing a bit. What I'm saying is that, for example, there are a lot of cool tools out there for using Python to manipulate postscript and latex and such. Most of those tools require no maintenance, and the authors are not paying any attention to them, and they aren't interested in messing with them anymore. My guess is that there are few such tools for Ruby. However, I wouldn't be too surprised if porting them to Ruby and testing them properly is not much more difficult than porting them to py3k and testing them properly... Especially since the basic treatment of strings is totally different in py3k, it seems. Maybe there is a secret desire in the Python community to remain a fringe minority underdog forever? -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=reap+dead+child From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 2 07:25:29 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 02 Apr 2008 13:25:29 +0200 Subject: object-relational mappers In-Reply-To: <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> Message-ID: <47f36d23$0$28775$426a74cc@news.free.fr> hdante a ?crit : > On Apr 1, 5:40 pm, Aaron Watters wrote: >> I've been poking around the world of object-relational >> mappers and it inspired me to coin a corellary to the >> the famous quote on regular expressions: >> >> "You have objects and a database: that's 2 problems. >> So: get an object-relational mapper: >> now you have 2**3 problems." >> >> That is to say I feel that they all make me learn >> so much about the internals and features of the >> O-R mapper itself that I would be better off rolling >> my own queries on an as-needed basis without >> wasting so many brain cells. >> >> comments? > > Try Rails' ActiveRecord. Your problems should reduce to (lg lg > 2)^(1/12). Correct me if I'm wrong, but IIRC ActiveRecord requires you use numeric auto_increment fields for primary key. As far as I'm concerned, this is a definitive no-no. > Seriously, you'll forget there's a relational database below. Why on earth are you using a RDBMS if you don't want it ? I for one *do* care about using a *relational* database, and *don't* want to hide it away. What I don't want is to have to build my queries as raw strings. And that's where SQLAlchemy shines : it's not primarily an "ORM", it's an higher-level Python/SQL integration tool that let you build your queries as Python objects (and also, eventually, build an ORM if you want to...). From george.sakkis at gmail.com Fri Apr 18 14:00:06 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 18 Apr 2008 11:00:06 -0700 (PDT) Subject: Pickle problem References: Message-ID: <933a2b55-7a99-4061-9dc0-4de657448f1c@s50g2000hsb.googlegroups.com> On Apr 18, 11:55?am, "Mario Ceresa" wrote: > Hello everybody: > I'd like to use the pickle module to save the state of an object so to > be able to restore it later. The problem is that it holds a list of > other objects, say numbers, and if I modify the list and restore the > object, the list itself is not reverted to the saved one, but stays > with one element deleted. > An example session is the following: > > Data is ?A [1, 2, 3, 4] > saving a with pickle > Deleting an object: del a[3] > Now data is A [1, 2, 3] > Oops! That was an error: can you please recover to the last saved data? > A [1, 2, 3] ? ? #### I'd like to have here A[1,2,3,4]!!!!!! > > Is it the intended behavior for pickle? if so, are there any way to > save the state of my object? > > Code follows > ----------------------- > class A(object): > ? ? ? ? objects = [] > ----------------------- > then I run ?the code: > --------------------------------------- > import pickle > from core import A > > a = A() > > for i in [1,2,3,4]: > ? ? ? ? a.objects.append(i) > > savedData = pickle.dumps(a) > print "Saved data is ",a > print "Deleting an object" > del a.objects[3] > print a > print "Oops! This was an error: can you please recover the last saved data?" > > print pickle.loads(savedData) > -------------------------------------------- > > Thank you for any help! > > Mario The problem is that the way you define 'objects', it is an attribute of the A *class*, not the instance you create. Change the A class to: class A(object): def __init__(self): self.objects = [] and rerun it; it should now work as you intended. HTH, George From sam at mas.pl Wed Apr 2 08:04:28 2008 From: sam at mas.pl (sam) Date: Wed, 02 Apr 2008 14:04:28 +0200 Subject: Prototype OO In-Reply-To: <47f1f90b$0$27429$426a74cc@news.free.fr> References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> Message-ID: Bruno Desthuilliers napisa?(a): > Sam, seriously, why don't start with *learning* about Python's object > model ? Seriously ? Not that it's "perfect", not that you have to like > it Ok -- thank you for your time and your strong opinions about current solutions. From hv at tbz-pariv.de Wed Apr 2 10:06:37 2008 From: hv at tbz-pariv.de (Thomas Guettler) Date: Wed, 02 Apr 2008 16:06:37 +0200 Subject: wsdl (soap) without code generation Message-ID: <65hi7dF2ade57U1@mid.individual.net> Hi, I looked for a solution to talk to a web service which offers its signature with a wsdl file. I googled for 'wsdl python' and found ZSI. This project uses code generation. That's something I don't like. The book 'dive into python' uses SOAPpy. This looks better since it does not generate source code. But the last release and first release is from 2001. ZSI seems to have integrated SOAPpy. I am new to WSDL and SOAP. Do I need a WSDL parsing routine at all? I guess my wsdl definition won't change during the next years. So I could read the wsdl with my eyes and make a fitting soap call... Any thoughts? -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de From has.temp3 at virgin.net Wed Apr 2 08:58:09 2008 From: has.temp3 at virgin.net (has) Date: Wed, 2 Apr 2008 05:58:09 -0700 (PDT) Subject: IM status with appscript References: <65h2l0F2fba8bU1@mid.uni-berlin.de> Message-ID: On 2 Apr, 10:40, "Diez B. Roggisch" wrote: > Oolon Colluphid wrote: > > hi, > > i need access to application attributes of IM (like Adium, aMsn, MS > > Messenger) on Mac platform via appscript module. > > once instantiated the application object with: app=app("Adium") > > i don't know how recover information like status, and i have find no > > references. > > Use the appscript examples + the OS X script-editor to see what scriptable > properties exactly the IM-application offers. You can also use ASDictionary (http://appscript.sourceforge.net/ tools.html) to export application dictionaries in appscript format. As an added bonus, installing ASDictionary allows you to use appscript's built-in help method to explore application dictionaries and object models from the interactive python interpreter. HTH has -- Control AppleScriptable applications from Python, Ruby and ObjC: http://appscript.sourceforge.net From panzerlurch at gmail.com Wed Apr 2 09:53:28 2008 From: panzerlurch at gmail.com (Panzerlurch) Date: Wed, 2 Apr 2008 06:53:28 -0700 (PDT) Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: <453e3ac2-5ed5-4f1f-a33b-55851677f02a@y21g2000hsf.googlegroups.com> Why don't use the normal Python shell syntax as used by doctest? >>> abs(-5.5) 5.5 That would be much more readable. From kyosohma at gmail.com Fri Apr 18 16:02:14 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 18 Apr 2008 13:02:14 -0700 (PDT) Subject: Easiest way to get started with WebApps? References: <3c43f29c-3e51-48ab-be02-47402ccd1bfd@b64g2000hsa.googlegroups.com> Message-ID: <19b6a1fe-c307-4f6e-abd0-c426967674a5@m36g2000hse.googlegroups.com> On Apr 18, 2:06 pm, skanem... at yahoo.se wrote: > which is the easiest module to use to just get started with webapps > quicklya nd starting getting things up and running, not advanced stuff > just basic. cherrypy is also good for quick and dirty webapps without a lot of bling. Mike From tdimson at gmail.com Wed Apr 2 08:30:06 2008 From: tdimson at gmail.com (Thomas Dimson) Date: Wed, 2 Apr 2008 05:30:06 -0700 (PDT) Subject: Self-referencing decorator function parameters Message-ID: <88b2c61e-8cf1-4ac0-a5d4-c968d009b544@c65g2000hsa.googlegroups.com> Hello, Originally I posted this as a bug but it was shot down pretty quickly. I am still mildly curious about this as I'm missing a bit of understanding of Python here. Why is it that the following code snippet: def decorator( call ): def inner(func): def application( *args, **kwargs ): call(*args,**kwargs) func(*args,**kwargs) return application return inner class DecorateMe: @decorator( call=DecorateMe.callMe ) def youBet( self ): pass def callMe( self ): print "Hello!" DecorateMe().youBet() Will not compile, giving: Traceback (most recent call last): File "badpython.py", line 10, in class DecorateMe: File "badpython.py", line 11, in DecorateMe @decorator( call=DecorateMe.callMe ) NameError: name 'DecorateMe' is not defined Where if you change the "call=DecorateMe.callMe" to "call=lambda x: DecorateMe.callMe(x)" everything goes along its merry way. Nesting the call in a lambda seems to allow it to recognize the class definition. Any ideas as to what is going on here (other than ugly code)? Thank you, Thomas Dimson From mccredie at gmail.com Tue Apr 29 21:22:09 2008 From: mccredie at gmail.com (Matimus) Date: Tue, 29 Apr 2008 18:22:09 -0700 (PDT) Subject: how to convert a multiline string to an anonymous function? References: <67pmdnF2p5fhgU1@mid.uni-berlin.de> Message-ID: <87c29666-f64f-4f3c-97e1-a3d1dccdc49b@s50g2000hsb.googlegroups.com> On Apr 29, 3:39 pm, "Diez B. Roggisch" wrote: > Danny Shevitz schrieb: > > > > > Simple question here: > > > I have a multiline string representing the body of a function. I have control > > over the string, so I can use either of the following: > > > str = ''' > > print state > > return True > > ''' > > > str = ''' > > def f(state): > > print state > > return True > > ''' > > > and I want to convert this into the function: > > > def f(state): > > print state > > return True > > > but return an anonmyous version of it, a la 'return f' so I can assign it > > independently. The body is multiline so lambda doesn't work. > > > I sort of need something like: > > > def function_constructor(str): > > f = eval(str) # What should this be > > return f > > > functions = {} > > for node in nodes: > > function[node] = function_constructor(node.text) > > > I'm getting stuck because 'def' doesn't seem to work in an eval function, > > and exec actually modifies the namespace, so I run into collisions if I use > > the function more than once. > > > I know I'm missing something stupid here, but I'm stuck just the same... > > The "stupid" thing is that you can pass your own dictionary as globals > to exec. Then you can get a reference to the function under the name "f" > in the globals, and store that under whatever name you need. > > Beware of recursion though! If that happens, you need to create unique > names for your functions, but as you know these beforehand I don't see > any problem with that - just enumerate them, like f1, f2, f3.... > > Diez In other words: >>> d = {} >>> >>> # don't use str, that is the name of the built-in string type >>> text = ''' ... def f(state): ... print state ... return True ... ''' >>> >>> exec text in d >>> >>> f('state') Traceback (most recent call last): File "", line 1, in NameError: name 'f' is not defined >>> >>> f = d['f'] >>> f('state') state True Matt From maxm at mxm.dk Wed Apr 9 08:05:08 2008 From: maxm at mxm.dk (Max M) Date: Wed, 09 Apr 2008 14:05:08 +0200 Subject: expanding a variable to a dict In-Reply-To: <76f75b0d-2355-4c18-a6e4-931c307cb5c6@u10g2000prn.googlegroups.com> References: <76f75b0d-2355-4c18-a6e4-931c307cb5c6@u10g2000prn.googlegroups.com> Message-ID: John Machin skrev: > On Apr 4, 9:44 am, Max M wrote: > Ummm ... excessive apostrophes plus bonus gross syntax error, dood. > Did you try running any of these snippets??? No I just wanted to quickly show different ways to do it. The dicts in the original question wasn't dicts either. So I asumed I could answer in the same vein. >> http://www.mxm.dk/ >> IT's Mad Science > > Sure is. Oh yes. That will motivate further answers. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science From skanemupp at yahoo.se Sat Apr 5 01:02:45 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 4 Apr 2008 22:02:45 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <7113d012-01bb-4426-bb40-9e2811cdb102@x41g2000hsb.googlegroups.com> Message-ID: <3cf4bbc8-b828-45c5-b9a8-766ce600af43@y21g2000hsf.googlegroups.com> On 5 Apr, 05:57, skanem... at yahoo.se wrote: > On 5 Apr, 05:26, 7stud wrote: > > > > > On Apr 4, 7:06 pm, skanem... at yahoo.se wrote: > > > > 1st question: > > > > when i run this program 1 will be printed into the interpreter when i > > > run it BUT without me clicking the actual button. > > > when i then click the button "1", nothing happens. > > > > obv i dont want any output when i dont push the button but i want it > > > when i do. > > > > what am i doing wrong here? > > > > 2nd question: > > > > i want all the buttons to have the same size. i thought i should use > > > row/columnspan but i dont get that to work. > > > how should i do? > > > > [code] > > > #! /usr/bin/env python > > > from Tkinter import * > > > import tkMessageBox > > > > class GUIFramework(Frame): > > > """This is the GUI""" > > > > def __init__(self,master=None): > > > """Initialize yourself""" > > > > """Initialise the base class""" > > > Frame.__init__(self,master) > > > > """Set the Window Title""" > > > self.master.title("Calculator") > > > > """Display the main window" > > > with a little bit of padding""" > > > self.grid(padx=10,pady=10) > > > self.CreateWidgets() > > > > def CreateWidgets(self): > > > > self.enText = Entry(self) > > > self.enText.grid(row=0, column=0, columnspan=8, padx=5, > > > pady=5) > > > > self.enText = Entry(self) > > > self.enText.grid(row=1, column=0, columnspan=8, padx=5, > > > pady=5) > > > > self.btnDisplay = Button(self, text="1", > > > command=self.Display(1)) > > > self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="2", default=ACTIVE) > > > self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="3", default=ACTIVE) > > > self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="+", default=ACTIVE) > > > self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="4", default=ACTIVE) > > > self.btnDisplay.grid(row=4, column=0, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="5", default=ACTIVE) > > > self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="6", default=ACTIVE) > > > self.btnDisplay.grid(row=4, column=2, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="-", default=ACTIVE) > > > self.btnDisplay.grid(row=4, column=3, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="7", default=ACTIVE) > > > self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="8", default=ACTIVE) > > > self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="9", default=ACTIVE) > > > self.btnDisplay.grid(row=5, column=2, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="*", default=ACTIVE) > > > self.btnDisplay.grid(row=5, column=3, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="0", default=ACTIVE) > > > self.btnDisplay.grid(row=6, column=0, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="C", default=ACTIVE) > > > self.btnDisplay.grid(row=6, column=1, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="r", default=ACTIVE) > > > self.btnDisplay.grid(row=6, column=2, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="/", default=ACTIVE) > > > self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) > > > > def Display(self, xbtn): > > > if xbtn==1: > > > print 1 > > > > if __name__ == "__main__": > > > guiFrame = GUIFramework() > > > guiFrame.mainloop() > > > > [/code] > > > If you have this function: > > > def f(): > > print 1 > > return 10 > > > and you write: > > > result = f() > > > The '()' is the function execution operator; it tells python to > > execute the function. In this case, the function executes, and then > > the return value of the function is assigned to the variable result. > > If a function does not have a return statement, then the function > > returns None by default. > > > The same thing is happening in this portion of your code: > > > command = self.Display(1) > > > That code tells python to execute the Display function and assign the > > function's return value to the variable command. As a result Display > > executes and 1 is displayed. Then since Dispay does not have a return > > statement, None is returned, and None is assigned to command. > > Obviously, that is not what you want to do. > > > What you want to do is assign a "function reference" to command so > > that python can execute the function sometime later when you click on > > the button. A function reference is just the function name without > > the '()' after it. So you would write: > > > command = self.Display > > > But writing it like that doesn't allow *you* to pass any arguments to > > Display(). In addition, *tkinter* does not pass any arguments to > > Display when tkinter calls Display in response to a button click. As > > a result, there is no way to pass an argument to Display. > > > However, there is another way to cause a function to execute when an > > event, like a button click, occurs on a widget: you use the widget's > > bind() function: > > > my_button.bind('', someFunc) > > > The first argument tells tkinter what event to respond to. > > '' is a left click. Check the docs for the different > > strings that represent the different events that you can respond to. > > The second argument is a function reference, which once again does not > > allow you to pass any arguments to the function. However, when you > > use bind() to attach a function to a widget, tkinter calls the > > function and passes it one argument: the "event object". The event > > object contains various pieces of information, and one piece of > > information it contains is the widget upon which the event occurred, > > e.g. the button that was clicked. To get the button, you write: > > > Display(self, event_obj): > > button = event_obj.widget > > > Once you have the button, you can get the text on the button: > > > Display(self, event_obj): > > button = event_obj.widget > > text = button.cget("text") > > > if text=="1": > > print 1 > > > Another thing you should be aware of: self is like a class wide > > bulletin board. If you are writing code inside a class method, and > > there is data that you want code inside another class method to be > > able to see, then post the data on the class wide bulletin board, i.e. > > attach it to self. But in your code, you are doing this: > > > self.btnDisplay = Button(self, text="7", default=ACTIVE) > > self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="8", default=ACTIVE) > > self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > > As a result, your code continually overwrites self.btnDisplay. That > > means you aren't preserving the data assigned to self.btnDisplay. > > Therefore, the data does not need to be posted on the class wide > > bulletin board for other class methods to see. So just write: > > > btnDisplay = Button(self, text="7", default=ACTIVE) > > btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > > btnDisplay = Button(self, text="8", default=ACTIVE) > > btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > > As for the button sizing problem, your buttons are all the same size > > and line up perfectly on mac os x 10.4.7. > > wow thank you so much, awesome answer i will get right to fixing this > now. > > in regards to the buttonsizes i use windows VISTA and they have > different sizes. one thing i dont rally get, i ahve to add my_button.bind() somewhere? i changed the stuff u said though and i get this error(the program executes though and i can press the buttons): Exception in Tkinter callback Traceback (most recent call last): File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ return self.func(*args) TypeError: Display() takes exactly 2 arguments (1 given) current version: #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self,master=None): """Initialize yourself""" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): enText = Entry(self) enText.grid(row=0, column=0, columnspan=8, padx=5, pady=5) enText = Entry(self) enText.grid(row=1, column=0, columnspan=8, padx=5, pady=5) btnDisplay = Button(self, text="1", command=self.Display) btnDisplay.grid(row=3, column=0, padx=5, pady=5) btnDisplay = Button(self, text="2", default=ACTIVE) btnDisplay.grid(row=3, column=1, padx=5, pady=5) btnDisplay = Button(self, text="3", default=ACTIVE) btnDisplay.grid(row=3, column=2, padx=5, pady=5) btnDisplay = Button(self, text="+", default=ACTIVE) btnDisplay.grid(row=3, column=3, padx=5, pady=5) btnDisplay = Button(self, text="4", default=ACTIVE) btnDisplay.grid(row=4, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="5", default=ACTIVE) self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) btnDisplay = Button(self, text="6", default=ACTIVE) btnDisplay.grid(row=4, column=2, padx=5, pady=5) btnDisplay = Button(self, text="-", default=ACTIVE) btnDisplay.grid(row=4, column=3, padx=5, pady=5) btnDisplay = Button(self, text="7", default=ACTIVE) btnDisplay.grid(row=5, column=0, padx=5, pady=5) btnDisplay = Button(self, text="8", default=ACTIVE) btnDisplay.grid(row=5, column=1, padx=5, pady=5) btnDisplay = Button(self, text="9", default=ACTIVE) btnDisplay.grid(row=5, column=2, padx=5, pady=5) btnDisplay = Button(self, text="*", default=ACTIVE) btnDisplay.grid(row=5, column=3, padx=5, pady=5) btnDisplay = Button(self, text="0", default=ACTIVE) btnDisplay.grid(row=6, column=0, padx=5, pady=5) btnDisplay = Button(self, text="C", default=ACTIVE) btnDisplay.grid(row=6, column=1, padx=5, pady=5) btnDisplay = Button(self, text="r", default=ACTIVE) btnDisplay.grid(row=6, column=2, padx=5, pady=5) btnDisplay = Button(self, text="/", default=ACTIVE) btnDisplay.grid(row=6, column=3, padx=5, pady=5) #self.btnDisplay(expand=0/1) ## def Display(self, xbtn): ## if xbtn==1: ## print 1 def Display(self, event_obj): button = event_obj.widget text = button.cget("text") if text=="1": print 1 if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() From rustompmody at gmail.com Sat Apr 26 23:35:29 2008 From: rustompmody at gmail.com (rustom) Date: Sat, 26 Apr 2008 20:35:29 -0700 (PDT) Subject: diffing and uniqing directories References: Message-ID: On Apr 27, 12:31?am, castiro... at gmail.com wrote: > On Apr 26, 1:14?pm, "Rustom Mody" wrote: > > > > > Over years Ive collected tgz's of my directories. I would like to diff > > and uniq them > > > Now I guess it would be quite simple to write a script that does a > > walk or find through a pair of directory trees, makes a SHA1 of each > > file and then sorts out the files whose SHA1s are the same/different. > > What is more difficult for me to do is to write a visual/gui tool to > > help me do this. > > > I would guess that someone in the python world must have already done > > it [The alternative is to use some of the tools that come with version > > control systems like git. But if I knew more about that option I would > > not be stuck with tgzs in the first place ;-)] > > > So if there is such software known please let me know. > > > PS Also with the spam flood that has hit the python list I dont know > > if this mail is being read at all or Ive fallen off the list! > > I don't want to give you advice; there is profit in diversity, so > telling you what I use could negatively unify the diverse group. > > In another language I know, and I pause to defer to the old and wise > on that, Visual Basic (known to make money), certain counterparts like > Visual Basic for Applications allow construction of scripts in the > owner's other suites. ?That is, you can write Basic snippets in Excel, > Access, and so on. ?That's one benefit that private ownership leaves, > but not everyone is sold on my country's currency/localcy. ?Perhaps > it's in the future of version control systems. ?Of course, > standardization of sufficiency to succeed comes from currency too: > success isn't success if it isn't current, per se. > > Do you have any interest in contributing your mind or hands to > developing a solid gui framework? ?Join a team. If this is an answer to my question I dont understand it! From steveb428 at gmail.com Mon Apr 7 19:20:27 2008 From: steveb428 at gmail.com (steve) Date: Mon, 7 Apr 2008 16:20:27 -0700 (PDT) Subject: pyAmazon Message-ID: <137ba7ca-2be3-4c0a-ba85-187d8e172150@i36g2000prf.googlegroups.com> Anyone familiar with pyAmazon ( the latest for AWS 4.0 ), who knows why the ItemSearch echo's the XML that is retrieved ? My statement is products = ecs.ItemSearch("Duma Key", SearchIndex='Books') And the "products" list is populated okay, however before my script ends ( executing script on DOS command line ), I get all of the XML data scrolling on the screen. Thanks From banibrata.dutta at gmail.com Tue Apr 22 01:33:18 2008 From: banibrata.dutta at gmail.com (Banibrata Dutta) Date: Tue, 22 Apr 2008 11:03:18 +0530 Subject: Does Python 2.5 include or not include SQLite engine? In-Reply-To: <1208819146.23409.1249124463@webmail.messagingengine.com> References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> <1208819146.23409.1249124463@webmail.messagingengine.com> Message-ID: <3de8e1f70804212233o4e62c52s2a4d140deaa44355@mail.gmail.com> Doesn't this depend on the source / distro ? My Python is from the ActivePython distro, while I am not sure (since I've just about started playing with it), I haven't seen SQLite included ... possible that I missed it. On 4/22/08, python at bdurham.com wrote: > > While reading feedback to my post "Does Python 2.5.2's embedded SQLite > support full text searching?" I noticed that there appears to be some > confusion regarding whether Python 2.5 includes the SQLite engine. > > My Windows 2.5.2 binary download includes SQLite. > > But other posters claim otherwise, re: Linux releases of Python 2.5? > > I thought one of the major features of Python 2.5 was its embedded > SQLite engine. > > Thoughts? > > Malcolm > -- > http://mail.python.org/mailman/listinfo/python-list > -- regards, Banibrata http://www.linkedin.com/in/bdutta -------------- next part -------------- An HTML attachment was scrubbed... URL: From upton at virginia.edu Wed Apr 2 17:02:45 2008 From: upton at virginia.edu (Dan Upton) Date: Wed, 2 Apr 2008 17:02:45 -0400 Subject: Python in High School In-Reply-To: References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: <5504f9ac0804021402j256f66cdyed2b778f7f6ba376@mail.gmail.com> On Wed, Apr 2, 2008 at 1:10 PM, Jan Claeys wrote: > Op Tue, 01 Apr 2008 10:27:18 -0700, schreef sprad: > > > > I'm a high school computer teacher, and I'm starting a series of > > programming courses next year (disguised as "game development" classes > > to capture more interest). The first year will be a gentle introduction > > to programming, leading to two more years of advanced topics. > > [...] > > > So -- would Python be a good fit for these classes? > > There are at least 3 books about game programming in python: > > > > This was the book I first bought when I started thinking about learning Python, and it includes some pygame projects. It uses all game programming-based concepts for teaching, although many of them are text-based and it only introduces pygame toward the end. http://www.amazon.com/Python-Programming-Absolute-Beginner-Michael/dp/1592000738/ref=sr_1_6?ie=UTF8&s=books&qid=1207169620&sr=1-6 I might add, you might do a disservice to students by starting them with flashy graphics-based programming--IIRC, that was actually a part of the complaints a couple months ago about why "Java schools" were failing to turn out competent computer scientists: they focus too heavily on something that looks good and end up missing the underlying concepts. Not that you'd ever do such a thing, I'm sure ;) But my intro CS professor in undergrad had us do two of the projects from our textbook that involved GUI programming, then quickly dropped it, partly because we were spending so much time of the implementation of the projects 1) figuring out how to set up the GUI in Swing, and 2) not really understanding why we're typing all this stuff to create buttons and text fields. On Wed, Apr 2, 2008 at 4:01 PM, John Henry wrote: > > And you are going to teach them Java? Oh, please don't. Let the > colleges torture them. :=) > Side rant: I think Java's just fine, as long as it's taught properly. I'd done a little bit of C and C++ programming when I was in high school, trying to teach myself from a book, but I never really got pointers or objects. Going back to it after Java, it made so much more sense, even though people will tell you "Java doesn't make you learn about pointers." From jim.vickroy at noaa.gov Wed Apr 2 13:23:39 2008 From: jim.vickroy at noaa.gov (j vickroy) Date: Wed, 02 Apr 2008 11:23:39 -0600 Subject: py.test and test coverage analysis ? Message-ID: Hello all, I am using py.test (http://codespeak.net/py/dist/test.html) to perform unit testing. I would like to include test coverage analysis using coverage.py (http://nedbatchelder.com/code/modules/coverage.html), but I do not know how to simultaneously apply the two tools in a single run. Could someone offer a suggestion on how to combine coverage analysis with py.test. Thanks, -- jv From hobgoodoreneyhb at gmail.com Tue Apr 22 11:39:38 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:39:38 -0700 (PDT) Subject: dell network assistant keygen Message-ID: <450907f7-93b5-45eb-9edd-c0269fa0dc71@d1g2000hsg.googlegroups.com> dell network assistant keygen http://cracks.12w.net F R E E C R A C K S From sjdevnull at yahoo.com Wed Apr 23 01:08:50 2008 From: sjdevnull at yahoo.com (sjdevnull at yahoo.com) Date: Tue, 22 Apr 2008 22:08:50 -0700 (PDT) Subject: about python References: Message-ID: On Apr 22, 10:50 pm, mran... at varshyl.com wrote: > How can python execute in browser? > > Mukul Depends on the browser and which compilers/postprocessors you're willing to use. The Grail browser supports python natively, there are python plugins for some other browsers, and there are C# plugins for other browsers which can be wrangled to work with IronPython. For common, widespread browser support, Jython can run on anything supporting Java and py2js can run on anything supporting Javascript. From ewertman at gmail.com Wed Apr 23 21:00:49 2008 From: ewertman at gmail.com (Eric Wertman) Date: Wed, 23 Apr 2008 21:00:49 -0400 Subject: Ideas for parsing this text? Message-ID: <92da89760804231800g50f9a2pbe45a7ff8104e7b0@mail.gmail.com> I have a set of files with this kind of content (it's dumped from WebSphere): [propertySet "[[resourceProperties "[[[description "This is a required property. This is an actual database name, and its not the locally catalogued database name. The Universal JDBC Driver does not rely on information catalogued in the DB2 database directory."] [name databaseName] [required true] [type java.lang.String] [value DB2Foo]] [[description "The JDBC connectivity-type of a data source. If you want to use a type 4 driver, set the value to 4. If you want to use a type 2 driver, set the value to 2. Use of driverType 2 is not supported on WAS z/OS."] [name driverType] [required true] [type java.lang.Integer] [value 4]] [[description "The TCP/IP address or host name for the DRDA server."] [name serverName] [required false] [type java.lang.String] [value ServerFoo]] [[description "The TCP/IP port number where the DRDA server resides."] [name portNumber] [required false] [type java.lang.Integer] [value 007]] [[description "The description of this datasource."] [name description] [required false] [type java.lang.String] [value []]] [[description "The DB2 trace level for logging to the logWriter or trace file. Possible trace levels are: TRACE_NONE = 0,TRACE_CONNECTION_CALLS = 1,TRACE_STATEMENT_CALLS = 2,TRACE_RESULT_SET_CALLS = 4,TRACE_DRIVER_CONFIGURATION = 16,TRACE_CONNECTS = 32,TRACE_DRDA_FLOWS = 64,TRACE_RESULT_SET_META_DATA = 128,TRACE_PARAMETER_META_DATA = 256,TRACE_DIAGNOSTICS = 512,TRACE_SQLJ = 1024,TRACE_ALL = -1, ."] [name traceLevel] [required false] [type java.lang.Integer] [value []]] [[description "The trace file to store the trace output. If you specify the trace file, the DB2 Jcc trace will be logged in this trace file. If this property is not specified and the WAS.database trace group is enabled, then both WebSphere trace and DB2 trace will be logged into the WebSphere trace file."] I'm trying to figure out the best way to feed it all into dictionaries, without having to know exactly what the contents of the file are. There are a number of things going on, The nesting is preserved in [] pairs, and in some cases in between double quotes. There are also cases where double quotes are only there to preserve spaces in a string though. I managed to get what I needed in the short term by just stripping the nesting all together, and flattening out the key/value pairs, but I had to do some things that were specific to the file contents to make it work. Any ideas? I was considering making a list of string combinations, like so: junk = ['[[','"[',']]'] and just using re.sub to covert them into a single character that I could start to do split() actions on. There must be something else I can do.. those brackets can't be a coincidence. The output came from a jython script. Thanks! From nash.coccer at gmail.com Mon Apr 14 07:41:40 2008 From: nash.coccer at gmail.com (nash.coccer at gmail.com) Date: Mon, 14 Apr 2008 04:41:40 -0700 (PDT) Subject: REAL BRUTAL RAPE VIDEOS HERE.SEE IT AND ENJOY. ALL THE GIRLS WERE Message-ID: <8c495ecd-6508-4106-972e-78b8f95f0720@u12g2000prd.googlegroups.com> REAL BRUTAL RAPE VIDEOS HERE.SEE IT AND ENJOY. ALL THE GIRLS WERE SCREAM .BUT IT IS SWEAT.THE LINK IS BELOW http://onlinemillionare.blogspot.com/ ENJOY HOW SWEET IT IS From martin at v.loewis.de Thu Apr 24 13:06:57 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Thu, 24 Apr 2008 19:06:57 +0200 Subject: Installer In-Reply-To: References: Message-ID: <4810be31$0$26785$9b622d9e@news.freenet.de> > I've created a python program that relies on pysqlite, wxpython, and > matplotlib. Is there any way of creating an installer that will > install all these modules, python 2.5 and my program? Sure. Look at Tools/msi in the Python code, and adjust it to your needs. Please don't use the official product code, but create your own one. Regards, Martin From bj_666 at gmx.net Thu Apr 3 07:25:03 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 3 Apr 2008 11:25:03 GMT Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> Message-ID: <65jt4fF2ges01U1@mid.uni-berlin.de> On Thu, 03 Apr 2008 10:07:38 +0200, sam wrote: > bruno.desthuilliers at gmail.com napisa?(a): > > >> So, while I often use Python's lambdas, the imposed limitations is ok >> to me since I wouldn't use it for anything more complex. > >> Also - as a side note - while the syntax is a bit different, the >> resulting object is an ordinary function. > > And people start asking why this is that or the other way in Python, and you > can't give a good answer to newcomers, especially if Python was chosen as a > first learning language. You can't tell "because Python's parsing mechanism > don't allow statements in expressions...". But one can tell "because the way Python's syntax is based on indentation, no one has come up with a syntax for anonymous functions without the limitations of the current ``lambda``, that doesn't need 'curly braces' and is still as readable as Python is now." Ciao, Marc 'BlackJack' Rintsch From matthieu.brucher at gmail.com Thu Apr 10 07:47:07 2008 From: matthieu.brucher at gmail.com (Matthieu Brucher) Date: Thu, 10 Apr 2008 13:47:07 +0200 Subject: =?ISO-8859-1?Q?Re:_[Python-Fr]_R=E9flexions_sur_l'auto?= =?ISO-8859-1?Q?compl=E9tion_dans_les_=E9diteurs_Python...?= In-Reply-To: <47FDFDA9.1050204@climpact.com> References: <47FDFDA9.1050204@climpact.com> Message-ID: Le 10/04/08, Jul a ?crit : > > Bonjour ? tous, > > L'un des probl?mes des ?diteurs de code Python est qu'il ne proposent pas > d'autocompl?tion "intelligente", c'est ? dire en coh?rence avec l'objet en > cours de frappe. La plupart des ?diteurs se basent sur des fichiers texte > (fichiers API) contenant la liste des m?thodes et attributs susceptibles de > compl?ter la frappe; mais comme ces suggestions ne sont pas cr??es > dynamiquement en fonction de la variable, elles sont souvent ? cot? de la > plaque. > > En Java, comme toutes les variables sont typ?es, on connait les m?thodes > et attribtus d?s la d?claration de la variable et il est possible de > proposer exactement les bonnes entr?es pour l'autocompl?tion. Mais en > Python, cela parait plus compliqu? a cause du manque de typage... > > Pensez-vous qu'un module d'autocompl?tion un peu plus "intelligent" que > des entr?es venant d'un fichier statique soit possible ? > Existe-t-il des modules d'analyse de code permettant de proposer les > bonnes entr?es ? > As-tu test? IPython ? L'autocompl?tion de ce shell est normalement bas?e sur l'introspection du code. Matthieu -- French PhD student Website : http://matthieu-brucher.developpez.com/ Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92 LinkedIn : http://www.linkedin.com/in/matthieubrucher -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexelder at gmail.com Fri Apr 25 13:37:23 2008 From: alexelder at gmail.com (alexelder at gmail.com) Date: Fri, 25 Apr 2008 10:37:23 -0700 (PDT) Subject: Calling Python code from inside php References: <679e9oF2mti63U1@mid.uni-berlin.de> <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> Message-ID: <8106a79a-d729-4d4f-bf2f-0c17041ad09b@e53g2000hsa.googlegroups.com> On Apr 25, 4:02 pm, sturlamolden wrote: > On Apr 23, 9:13 pm, alexel... at gmail.com wrote: > > > A simple yet dangerous and rather rubbish solution (possibly more of a > > hack than a real implementation) could be achieved by using a > > technique described above: > > > > echo exec('python foo.py'); > > This will spawn a Python interpreter, and not be particularly > efficient. You could just as well have used CGI. Thanks for pointing that out. I thought the warning before hand could've suggested that this implementation wasn't the best. I'll be more explicit in the future. From deets at nospam.web.de Tue Apr 22 08:27:34 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 14:27:34 +0200 Subject: Does Python 2.5.2's embedded SQLite support full text searching? In-Reply-To: References: <1208794249.15992.1249049327@webmail.messagingengine.com> Message-ID: <6763uaF2norrtU1@mid.uni-berlin.de> Daniel Fetchinson schrieb: >> Does Python 2.5.2's embedded SQLite support full text searching? >> >> Any recommendations on a source where one can find out which SQLite >> features are enabled/disabled in each release of Python? I'm trying to >> figure out what's available in 2.5.2 as well as what to expect in 2.6 >> and 3.0. > > Sqlite itself is not distributed with python. Only a python db api > compliant wrapper is part of the python stdlib and as such it is > completely independent of the sqlite build. In other words, if your > sqlite build supports full text searching you can use it through the > python sqlite wrapper (that is part of the stdlib) and if it doesn't > then not. This is true for any sqlite feature though. > > So if you need an sqlite feature just go ahead and build your own > sqlite with that feature enabled and use that feature with the stock > python sqlite wrapper that comes with the stdlib. I doubt that. This would mean that Python comes with a mechanism to dynamically load different libs for the same module, opening a buttload full of error-conditions regarding library versions & changing semantics depending on system configuration. Instead, the sqlite standard lib comes with its own version of sqlite. If you want something other, you need to - install sqlite on your system, including library & headers - compile the pysqlite extension module it will be available in a different module path to prevent confusion. THe same is true for ElementTree, btw. Diez From steve at holdenweb.com Mon Apr 21 17:20:15 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 21 Apr 2008 17:20:15 -0400 Subject: 2's complement conversion. Is this right? In-Reply-To: <2008042115060816807-bob@passcalnmtedu> References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> <2008042115060816807-bob@passcalnmtedu> Message-ID: Bob Greschke wrote: > On 2008-04-21 14:50:13 -0600, Ivan Illarionov said: > >> On 22 ???, 00:10, Ivan Illarionov wrote: >>> On 20 ???, 04:10, George Sakkis w >> rote: >>> >>> >>>> On Apr 18, 9:36 pm, Ross Ridge >>>> wrote: >>>>> Ross Ridge said: >>>>>> If you have Python 2.5, here's a faster version: >>>>>> from struct import * >>>>>> unpack_i32be = Struct(">l").unpack >>>>>> def from3Bytes_ross2(s): >>>>>> return unpack_i32be(s + "\0")[0] >> 8 >>>>> Bob Greschke wrote: >>>>>> That's not even intelligible. I wanna go back to COBOL. :) >>>>> It's the same as the previous version except that it "precompiles" >>>>> the struct.unpack() format string. It works similar to the way Python >>>>> handles regular expressions. >>>> I didn't know about the Struct class; pretty neat. It's amazing that >>>> this version without Psyco is as fast Bob's version with Psyco! Adding >>>> Psyco to it though makes it *slower*, not faster. So here's how I'd >>>> write it (if I wanted or had to stay in pure Python): >>>> try: import psyco >>>> except ImportError: >>>> from struct import Struct >>>> unpack_i32be = Struct(">l").unpack >>>> def from3Bytes(s): >>>> return unpack_i32be(s + "\0")[0] >> 8 >>>> else: >>>> def from3Bytes(s): >>>> Value = (ord(s[0])<<16) + (ord(s[1])<<8) + ord(s[2]) >>>> if Value >= 0x800000: >>>> Value -= 0x1000000 >>>> return Value >>>> psyco.bind(from3Bytes) >>>> HTH, >>>> George >>> I was able to get even faster pure-python version using array module: >>> >>> a = array.array('l', ''.join(('\0' + s[i:i+3] for i in xrange(0, >>> len(s), 3)))) >>> if sys.byteorder == 'little': >>> a.byteswap() >>> >>> It actually moves bytes around on C level. >>> >>> test code: >>> import struct >>> import array >>> import sys >>> >>> unpack_i32be = struct.Struct(">l").unpack >>> s = ''.join(struct.pack('>i', 1234567)[1:]*1000) >>> >>> def from3bytes_ord(s): >>> values = [] >>> for i in xrange(0, len(s), 3): >>> Value = (ord(s[i])<<16) | (ord(s[i+1])<<8) | ord(s[i+2]) >>> if Value >= 0x800000: >>> Value -= 0x1000000 >>> values.append(Value) >>> return values >>> >>> def from3bytes_struct(s): >>> return [unpack_i32be(s[i:i+3] + "\0")[0] >> 8 for i in xrange(0, >>> len(s), 3)] >>> >>> def from3bytes_array(s): >>> a = array.array('l', ''.join(('\0' + s[i:i+3] for i in xrange(0, >>> len(s), 3)))) >>> if sys.byteorder == 'little': >>> a.byteswap() >>> return a.tolist() >>> >>> from timeit import Timer >>> >>> t1 = Timer("from3bytes_ord(s)", "from __main__ import s, >>> from3bytes_ord") >>> t2 = Timer("from3bytes_struct(s)", "from __main__ import s, >>> from3bytes_struct") >>> t3 = Timer("from3bytes_array(s)", "from __main__ import s, >>> from3bytes_array") >>> >>> print 'ord:\t', t1.timeit(1000) >>> print 'struct:\t', t2.timeit(1000) >>> print 'array:\t', t3.timeit(1000) >>> >>> Output: >>> ord: 7.08213110884 >>> struct: 3.7689164405 >>> array: 2.62995268952 >>> >>> Inspired by Guido's essayhttp://www.python.org/doc/essays/list2str/ >> And even faster: >> a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, >> len(s), 3)))) >> if sys.byteorder == 'little': >> a.byteswap() >> >> I think it's a fastest possible implementation in pure python > > Geeze! :) How did struct get so fast? I'm guessing there have been > improvements since 2.3 (which is what I've been working on). I'm going > to be able to go back to my IBM PC XT pretty soon. :) > > Thanks! > Yes, Bob Ippolito spent quite a bit of time improving it at the Need for Speed sprint shortly before the 2.4 (?) release. It shows. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From sophacles at gmail.com Wed Apr 2 11:41:10 2008 From: sophacles at gmail.com (Erich) Date: Wed, 2 Apr 2008 08:41:10 -0700 (PDT) Subject: Self-referencing decorator function parameters References: <88b2c61e-8cf1-4ac0-a5d4-c968d009b544@c65g2000hsa.googlegroups.com> <232b144b-9e09-4baf-9e87-88b6a1d1fb07@b5g2000pri.googlegroups.com> <80ffac0f-baa3-46ac-8157-fa123e2bee9e@8g2000hse.googlegroups.com> Message-ID: <034a09e4-7d78-49d3-a92d-d4134b8dcf28@13g2000hsb.googlegroups.com> On Apr 2, 10:13 am, Thomas Dimson wrote: > > I guess my real question is: why does wrapping the call to be > "call=lambda x: DecorateMe.callMe(x)" somehow fix the issue with this > temporary namespace? It seems strange to me that defining an > additional function (through lambda) would allow me to see/add more > members to the namespace. This works because of the very same mechanism that allows decorators to work. When the decorator in your example is called, it then evaluates the inner statements, including the creation of the function inner (the def ...). Similarly, when you do the lambda above, python points call to the lambda function, but does not evaluate it until later, when the youBet method is run. By the time youBet is run, the DecorateMe class exists, so this will properly evaluate. I hope the above is clear, I haven't had my coffee yet. regards, Erich From Randy.Galbraith at gmail.com Mon Apr 21 01:01:46 2008 From: Randy.Galbraith at gmail.com (Randy Galbraith) Date: Sun, 20 Apr 2008 22:01:46 -0700 (PDT) Subject: Compiling Python 2.5.2 on AIX 5.2 References: <0b73e8e5-c301-4823-ac94-42f757456cf1@x19g2000prg.googlegroups.com> <48059DA9.5080900@v.loewis.de> Message-ID: On Apr 15, 11:33 pm, "Martin v. L?wis" wrote: > > What is Py_UNICODE_SIZE and why was it not defined? There are current > > questions I have. > > Py_UNICODE_SIZE is the number of bytes that a Py_UNICODE value should > have in the interpreter. With --enable-unicode=ucs2, it should be 2. Martin, Thanks for your reply. I feel like a dummy, when I was following Marc- Andre's instructions I incorrectly typed "--enable- unicode=ucs24" (note the "4"). Once I fixed that the Py_UNICODE_SIZE issue went away. Alas, I still am having problems compiling and getting a clean run through make test. I got this error: Python-2.5.2/Modules/bz2module.c:12:19: error: bzlib.h: No such file or directory Which I solved by copying bzlib.h I have on the system to Python-2.5.2/ Include/. The run of make test resulted in this error: test_ctypes find_library('c') -> None find_library('m') -> None make: *** [test] Segmentation fault (core dumped) An examination of the core with gdb shows this: $ gdb python core GNU gdb 6.0 Copyright 2003 Free Software Foundation, Inc. [snip] This GDB was configured as "powerpc-ibm-aix5.2.0.0"... Core was generated by `python'. Program terminated with signal 11, Segmentation fault. #0 0xdebccc5c in ffi_closure_helper_DARWIN (closure=0xdebcd050, rvalue=0x2ff20230, pgr=0x2ff20258, pfr=0x2ff201c8) at Python-2.5.2/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c: 626 626 avalue = alloca(cif->nargs * sizeof(void *)); (gdb) bt #0 0xdebccc5c in ffi_closure_helper_DARWIN (closure=0xdebcd050, rvalue=0x2ff20230, pgr=0x2ff20258, pfr=0x2ff201c8) at Python-2.5.2/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c: 626 #1 0xdebcd2bc in ffi_closure_ASM () from build/lib.aix-5.2-2.5/ _ctypes.so #2 0xdebcd458 in ffi_call_AIX () from build/lib.aix-5.2-2.5/ _ctypes.so #3 0xdebccf24 in ffi_call (cif=0xdebcd050, fn=@0x2ff20288: 0x2ff20350, rvalue=0x2ff20258, avalue=0x2ff201c8) at Python-2.5.2/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c: 421 #4 0xdebcb5e8 in _CallProc (pProc=@0x30000fc8: 0xdebcd248 , argtuple=0x20d5e9ac, flags=4097, argtypes=0x20d5eb2c, restype=0x20e7dc44, checker=0x0) at Python-2.5.2/Modules/_ctypes/callproc.c:668 [snip frames #5 to #55] #56 0x10063a70 in PyEval_EvalCode (co=0xdebcd050, globals=0x2ff20230, locals=0x2ff20258) at Python/ceval.c:494 cals=0x2ff20258) at Python/ceval.c:494 (gdb) print cif $1 = (ffi_cif *) 0x140 (gdb) print *cif $3 = {abi = 1600485481, nargs = 1946157056, arg_types = 0x0, rtype = 0x400a, bytes = 1, flags = 0} Thus it would seem use cif here resulted in a segment violation. I'll continue to research this issue and report back to the group as I know more. Perhaps solving the issue with the 'c' and 'm' libraries (whatever they might be) will make the core dump go away. However, for tonight, I'll need to stop here. Kind regards, -Randy Galbraith From andrew at acooke.org Mon Apr 14 22:36:06 2008 From: andrew at acooke.org (andrew cooke) Date: Mon, 14 Apr 2008 19:36:06 -0700 (PDT) Subject: Dynamic use of property() fails References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> Message-ID: <07e75b35-fc64-4388-b953-f75728b259f6@x41g2000hsb.googlegroups.com> [Gabriel:] > The "magic" happens when the descriptor is found in the *class*, not in > the instance. I think it's detailed in Hettinger's document. > Do you actually want "per-instance" defined properties? ah! ok. yes, you're right: i want instance values but class properties, so i'll rethink things. thanks very much! > __special__ names are reserved for Python internal usage; don't use them. > Implementation-only attributes ("private" ones) are spelled with a single > underscore. ah, yes, sorry about that. thanks again for the quick reply, andrew From ockman at gmail.com Sat Apr 12 10:43:11 2008 From: ockman at gmail.com (ockman at gmail.com) Date: Sat, 12 Apr 2008 07:43:11 -0700 (PDT) Subject: from __future__ import print References: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> Message-ID: <93176fb4-dd7d-457e-ac44-b54596bb95e1@k37g2000hsf.googlegroups.com> On Apr 10, 3:06 pm, "Andrii V. Mishkovskyi" wrote: > 2008/4/10, samsli... at gmail.com : > > > Am I the only one that thinks this would be useful? :) > > > I'd really like to be able to use python 3.0'sprintstatement in > > 2.x. Is this at least being considered as an option for 2.6? It > > seems like it would be helpful with transitioning. > > It's not only considered but have been already implemented. Enjoy. :) Awesome! I'm still stuck on 2.5 but I'm glad to know it's in 2.6. :) From mccle27252 at gmail.com Mon Apr 21 03:52:11 2008 From: mccle27252 at gmail.com (mccle27252 at gmail.com) Date: Mon, 21 Apr 2008 00:52:11 -0700 (PDT) Subject: ulead gif animator 5 crack Message-ID: ulead gif animator 5 crack http://cracks.00bp.com F R E E C R A C K S From ptmcg at austin.rr.com Mon Apr 7 20:14:21 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Mon, 7 Apr 2008 17:14:21 -0700 (PDT) Subject: Data structure recommendation? References: <663744510804071339g639bfdccl63de8be66fe52df1@mail.gmail.com> Message-ID: On Apr 7, 3:58?pm, Steve Holden wrote: > > I believe the best way to implement this would be a binary search > (bisect?) on the actual times, which would be O(log N). bisect is definitely the way to go. You should take care with floating point precision, though. One way to do this is to choose a number of digits of precision that you want, and then internally to your class, multiply the keys by 10**precision and truncate, so that you are working with ints internal to the Foo class. Here is a stab at a solution to your question, with precision to 1 decimal place. I also added __getitem__ and __setitem__, since your class has many dict- like semantics. -- Paul import bisect class Foo(object): def __init__(self): self.items = {} self.keys = [] def put(self,key,value): key = int(key * 10) if key not in self.items: bisect.insort(self.keys, key) self.items[key] = value def get(self,key): key = int(key * 10) idx = bisect.bisect_left(self.keys,key) if idx: return self.items[self.keys[idx-1]] def __setitem__(self,key,value): self.put(key,value) def __getitem__(self,key): return self.get(key) if __name__ == "__main__": foo = Foo() print foo.get(1.5) # -> None foo.put(1.3, 'a') foo.put(2.6, 'b') print foo.get(1.5) # -> 'a' print foo.get(7.8) # -> 'b' foo.put(5.0, 'c') print foo.get(7.8) # -> 'c' print foo[1.0] # -> None foo[6.3] = 'z' print foo[7.8] From darcy at druid.net Thu Apr 24 12:44:51 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Thu, 24 Apr 2008 12:44:51 -0400 Subject: MESSAGE RESPONSE In-Reply-To: <27CC3060AF71DA40A5DC85F7D5B70F3801185540@AWMAIL04.belcan.com> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> <678v5qF2me5rvU1@mid.uni-berlin.de> <5504f9ac0804230927ncfdb91buf7fa3e181f8a9237@mail.gmail.com> <27CC3060AF71DA40A5DC85F7D5B70F3801185540@AWMAIL04.belcan.com> Message-ID: <20080424124451.9070e2fb.darcy@druid.net> On Thu, 24 Apr 2008 12:28:29 -0400 "Blubaugh, David A." wrote: > Belcan has an absolute zero-tolerance policy toward material such as the material described. Hard to imagine that they would hold you responsible for something sent to you without your permission. On the other hand I can see them being concerned about the posting that you made when you resent it to the list. And really, who uses their business address for news/mailing lists. I own my own company and I won't even do that. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From steve at holdenweb.com Wed Apr 9 12:51:45 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 12:51:45 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> Message-ID: <47FCF421.6000807@holdenweb.com> Victor Subervi wrote: > On Wed, Apr 9, 2008 at 11:10 AM, Steve Holden > wrote: > > Victor Subervi wrote: > > On Wed, Apr 9, 2008 at 10:24 AM, Steve Holden > > >> wrote: > connection = MySQLdb.connect(host=host, user=user, > passwd=passwd, db=db) > cursor = connection.cursor() > cursor.execute('select img from photo where id="7";') > content = cursor.fetchall() > > > Bzzt! Nope. Cursor.fetchall() returns a list (length 1) or tuples > (length 1) here, so this should be > > content = cursor.fetchall()[0][0] > > or, perhaps better > > content = cursor.fetchone()[0] > > > I tried both of these, and they, too, gave me the same identical image > of the url, not the image I am after. > I'm having a problem believing this, but I don't think you are lying. Are you *sure* you have stored the correct omages in your database? The fact remains that cursor.fetchall() will return a list containing one tuple containing (what you believe is) your image, so there is NO way your code above can do what you want. I can therefore only assume that this is a CGI script and that your web server does something *extremely* funky when it gets a CGI output it isn't expecting. But this doesn't make a lot of sense. > > > You really don't understand how the web works, do you? > > > I am just really, really, stupid, Steve. Please forgive me for being so > stupid. But I am persistent. And I have built dozens of Web site with > images. > Stupidity and ignorance are entirely different things, and you (current) ignorance in no way implies stupidity. We all have to learn. However, if you bring up one of the pages from one of your many web sites containing an image, and get your browser to display the HTML of that page you will surely find that the image does not appear direectly in the HTML, but instead appears as a tag in the HTML. Something like: though the src attribute doesn't really need to be that complex. > > In order to include an image in a page your browser must make TWO > requests. The first is for an HTML page that will reference the > image in this way: > > > > Seeing this img tag causes the browser to make a SECOND request, > which the script I corrected above should respond to with an image. > > The bytestream is critical in the image response. Even one misplaced > byte will mess things up terribly. > > > In my stupidity, I have assumed you meant this: > > content = col_fields[0][14].tostring() > print '

' > Well, here I have no idea what the content of your database might be, but if the fifteenth column you retrieve is the web server path to the graphic, that should be right except for the spaces around it, which might give trouble. You might consider instead content = col_fields[0][14].tostring() print '

' % content to omit them. > Obviously I am wrong. Could you please give me a little more insight? > Forget HTML for now. If you direct your browser to the URL on which your server is serving the graphic then it should be displayed in the browser window. Until that happy condition pertains, we are stabbing around in the dark. > BTW, when we are finally done with this, I will write a nice > how-to (since there is not one in python, while php has some > nice ones) on how to do this, and give you and Gabrielle all > your due credit. I will post it to this list, because that is > sure to rank highly in google right away. > Victor > > That's great, though hardly the point of the exercise. I think > Google already know about Gabriel (*not* Gabrielle) and me already ... > > > Well, I just thought it might be a good way to get the information out, > since it is not out there yet. And I believe it is only proper to give > credit where credit is due. I would not be doing this to praise you. > Rather, I would be doing this because it is needed, and I would feel > wrong for not crediting those who deserve credit. Please let me know, > however, if you feel otherwise. It's not that I mind, but I do feel that this knowledge is already available, though clearly I might be wrong ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From george.sakkis at gmail.com Fri Apr 18 18:04:37 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 18 Apr 2008 15:04:37 -0700 (PDT) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> Message-ID: <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> On Apr 18, 5:26?pm, Bob Greschke wrote: > On 2008-04-18 14:37:21 -0600, Ross Ridge > said: > > > > > Bob Greschke ? wrote: > >> I'm reading 3-byte numbers from a file and they are signed (+8 to > >> -8million). ?This seems to work, but I'm not sure it's right. > > >> # Convert the 3-characters into a number. > >> Value1, Value2, Value3 = unpack(">BBB", Buffer[s:s+3]) > >> Value = (Value1*65536)+(Value2*256)+Value3 > >> if Value >= 0x800000: > >> Value -= 0x1000000 > >> print Value > > >> For example: > >> 16682720 = -94496 > > >> Should it be Value -= 0x1000001 so that I get -94497, instead? > > > Your first case is correct, "Value -= 0x1000000". ?The value 0xFFFFFFF > > should be -1 and 0xFFFFFFF - 0x1000000 == -1. > > > An alternative way of doing this: > > > ? ?Value = unpack(">l", Buffer[s:s+3] + "\0")[0] >> 8 > > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Ross Ridge > > Good to know (never was good on the math front). > > However, in playing around with your suggestion and Grant's code I've > found that the struct stuff is WAY slower than doing something like this > > ?Value = (ord(Buf[s])*65536)+(ord(Buf[s+1])*256)+ord(Buf[s+2]) > ?if Value >= 0x800000: > ? ? ?Value -= 0x1000000 > > This is almost twice as fast just sitting here grinding through a few > hundred thousand conversions (like 3sec vs. ~5secs just counting on my > fingers - on an old Sun...it's a bit slow). ? You'd better use a more precise timing method than finger counting, such as timeit. Twice as fast is probably a gross overestimation; on my box (Python 2.5, WinXP) avoiding unpack is around 10% and 40% faster from Ross's and Grant's method, respectively: python -m timeit "for i in xrange(1000):from3Bytes_bob(s)" \ -s "from bin import *; s=pack('>i',1234567)[1:]" 1000 loops, best of 3: 1.02 msec per loop python -m timeit "for i in xrange(1000):from3Bytes_grant(s)" \ -s "from bin import *; s=pack('>i',1234567)[1:]" 1000 loops, best of 3: 1.43 msec per loop python -m timeit "for i in xrange(1000):from3Bytes_ross(s)" \ -s "from bin import *; s=pack('>i',1234567)[1:]" 1000 loops, best of 3: 1.12 msec per loop ### bin.py ########################################## from struct import unpack def from3Bytes_bob(s): Value = (ord(s[0])<<16) + (ord(s[1])<<8) + ord(s[2]) if Value >= 0x800000: Value -= 0x1000000 return Value def from3Bytes_grant(s): if ord(s[0]) & 0x80: s = '\xff'+s else: s = '\x00'+s return unpack('>i',s)[0] def from3Bytes_ross(s): return unpack(">l", s + "\0")[0] >> 8 > Replacing *65536 with <<16 > and *256 with <<8 might even be a little faster, but it's too close to > call without really profiling it. > I wasn't planning on making this discovery today! :) > > Bob If you are running this on a 32-bit architecture, get Psyco [1] and add at the top of your module: import psyco; psyco.full() Using Psyco in this scenatio is up to 70% faster: python -m timeit "for i in xrange(1000):from3Bytes_bob(s)" \ -s "from bin import *; s=pack('>i',1234567)[1:]" 1000 loops, best of 3: 624 usec per loop python -m timeit "for i in xrange(1000):from3Bytes_grant(s)" \ -s "from bin import *; s=pack('>i',1234567)[1:]" 1000 loops, best of 3: 838 usec per loop python -m timeit "for i in xrange(1000):from3Bytes_ross(s)" \ -s "from bin import *; s=pack('>i',1234567)[1:]" 1000 loops, best of 3: 834 usec per loop George [1] http://psyco.sourceforge.net/ From malaclypse2 at gmail.com Tue Apr 29 16:47:10 2008 From: malaclypse2 at gmail.com (Jerry Hill) Date: Tue, 29 Apr 2008 16:47:10 -0400 Subject: Simple import question about mac osx In-Reply-To: References: Message-ID: <16651e80804291347k545a2f0do7707eec0d3eea54a@mail.gmail.com> On Tue, Apr 29, 2008 at 3:17 PM, jmDesktop wrote: > On Windows I took the text file I created on mac with vi and opened it > in PythonWin. I ran it. It compiled. I run the import and call from > the python interpreter. You're not doing what you think you're doing. I'm not sure I know the right way to explain it, though. When you run your code in pythonwin, it's just like calling 'python -i chap2.py' It runs the code in chap2.py, then gives you an interpreter window to interact with your code. In this case, that means that FooClass is visible with no import at all, because it was defined in the scope of the currently running script, as opposed to being imported. You haven't said exactly how you're doing this on your mac, but I'm guessing that you're opening a command line, starting up the python interpreter, then going from there? Can someone help me out? I'm running into a mental block on how to explain the difference between doing this: C:\Python25>python -i chap2.py >>> foo1=FooClass() Created a class instance for John Doe >>> and doing this: C:\Python25>python Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import chap2 >>> foo1=chap2.FooClass() Created a class instance for John Doe >>> -- Jerry From deets at nospam.web.de Wed Apr 16 07:56:23 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 16 Apr 2008 13:56:23 +0200 Subject: Python crashes consistently References: Message-ID: <66m7s3F2l8kitU1@mid.uni-berlin.de> Pete Crite wrote: > Hello, > > I've been trying to install Gnumeric via MacPorts recently, but I > can't get past the installation of py25-numpy. You are using the wrong python version. Don't use MacPorts for this, because it will install a local, non-framework version of python - which will do you no good if you e.g. want to use any OSX-specific stuff. Use the official 2.5 framework version. And then install Numpy yourself (which is a bit annoying I admit, as you need to install e.g. a fortran compiler, but it is pretty well documented) Diez From tnelson at onresolve.com Tue Apr 8 23:07:55 2008 From: tnelson at onresolve.com (Trent Nelson) Date: Tue, 8 Apr 2008 20:07:55 -0700 Subject: Google App Engine In-Reply-To: References: Message-ID: <87D3F9C72FBF214DB39FA4E3FE618CDC6E22BEB5D7@EXMBX04.exchhosting.com> > But people will always prefer complaining on the grounds of > insufficient information to keeping quiet on the basis of knowledge. +1 QOTW! From paul at science.uva.nl Mon Apr 21 07:30:19 2008 From: paul at science.uva.nl (Paul Melis) Date: Mon, 21 Apr 2008 13:30:19 +0200 Subject: SWIG (Python) - "no constructor defined" for concrete class In-Reply-To: References: Message-ID: Stodge wrote: > Yet another SWIG question (YASQ!). > > I'm having a problem with using an abstract base class. When > generating the Python bindings, SWIG thinks that all the concrete > classes that derive from this abstract class are abstract too and > won't create the correct constructor. > > Abstract class: > > [source lang="cpp"]class CORE_API Shape > { > public: > virtual ~Shape() > { > nshapes--; > }; > double x, y; > virtual void move(double dx, double dy); > virtual double area(void) = 0; > virtual double perimeter(void) = 0; > static int nshapes; > protected: > Shape() { > nshapes++; > } > > }; > [/source] > > Derived classes: > > [source lang="cpp"]class CORE_API Circle : public Shape > { > private: > double radius; > public: > Circle(double r): Shape(), radius(r) > { > }; > virtual double area(void); > virtual double perimeter(void); > }; > > class CORE_API Square : public Shape > { > private: > double width; > public: > Square(double r): Shape(), width(r) > { > }; > virtual double area(void); > virtual double perimeter(void); > }; > [/source] > > SWIG file: > > [source lang="cpp"]class Shape > { > virtual void move(double dx, double dy); > virtual double area(void) = 0; > virtual double perimeter(void) = 0; > }; > > class Circle: public Shape > { > Circle(double r); > virtual double area(void); > virtual double perimeter(void); > }; > > > class Square: public Shape > { > Square(double r); > virtual double area(void); > virtual double perimeter(void); > }; > [/source] > > C++ COde: > > [source lang="cpp"] Circle c(1.02); > std::cout << "(c++)\t\tCircle\t" << c.area() << std::endl; > Square s(9.20); > std::cout << "(c++)\t\tSquare\t" << s.area() << std::endl; > > [/source] > > For some reason SWIG thinks that Circle and Square are abstract. Any > ideas why? I'm rather confused by this. See section 6.6.2 of the SWIG documentation (SWIG and C++ -> Default constructors, copy constructors and implicit destructors). Your abstract base class defines its default constructor in the protected section. From the docs: "Default constructors and implicit destructors are not created if any base class defines a non-public default constructor or destructor." Paul From king.aftab at gmail.com Sat Apr 26 07:17:21 2008 From: king.aftab at gmail.com (king.aftab at gmail.com) Date: Sat, 26 Apr 2008 04:17:21 -0700 (PDT) Subject: Riva FLV Encoder 2.0 - FLV Converter Message-ID: <9fa94472-ca5e-441c-8df6-14a78580f870@u36g2000prf.googlegroups.com> This robust video converter ably packs a number of file formats into the Flash video format and is stylish to boot. Riva FLV Encoder works well with the usual suspects: AVI, WMV, MPEG, and MOV files. Riva is a great freeware application for a reliable (and inexpensive) way to convert video files to the Web. Download from here: http://freeware4.blogspot.com/2008/04/riva-flv-encoder-20-flv-converter.html From kveretennicov at gmail.com Tue Apr 1 16:23:28 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Tue, 1 Apr 2008 23:23:28 +0300 Subject: import multiple modules with same name In-Reply-To: References: Message-ID: <4660fe300804011323p44ee747bse7010031dc9a492d@mail.gmail.com> On Mon, Mar 31, 2008 at 11:52 PM, Christian Bird wrote: > Is it possible to import multiple modules with the same name from > different locations? This might work: import imp util1 = imp.load_source('util1', 'mod1/util.py') util2 = imp.load_source('util2', 'mod2/util.py') But using packages is cleaner. -- kv -------------- next part -------------- An HTML attachment was scrubbed... URL: From jcd at sdf.lonestar.org Thu Apr 17 14:55:00 2008 From: jcd at sdf.lonestar.org (J. Cliff Dyer) Date: Thu, 17 Apr 2008 14:55:00 -0400 Subject: Can't do a multiline assignment! In-Reply-To: References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <48077E83.5050404@islandtraining.com> Message-ID: <1208458500.5656.4.camel@aalcdl07.lib.unc.edu> On Thu, 2008-04-17 at 13:53 -0400, Steve Holden wrote: > Gary Herron wrote: > > s0suk3 at gmail.com wrote: > >> On Apr 17, 10:54 am, colas.fran... at gmail.com wrote: > >> > >>> On 17 avr, 17:40, s0s... at gmail.com wrote: > >>> > >>> Out of sheer curiosity, why do you need thirty (hand-specified and > >>> dutifully commented) names to the same constant object if you know > >>> there will always be only one object? > >>> > >> I'm building a web server. The many variables are names of header > >> fields. One part of the code looks like this (or at least I'd like it > >> to): > >> > >> class RequestHeadersManager: > >> > >> # General header fields > >> Cache_Control = \ > >> Connection = \ > >> Date = \ > >> Pragma = \ > >> Trailer = \ > >> Transfer_Encoding = \ > >> Upgrade = \ > >> Via = \ > >> Warning = \ > >> > >> # Request header fields > >> Accept = \ > >> Accept_Charset = \ > >> Accept_Encoding = \ > >> Accept_Language = \ > >> Authorization = \ > >> ... > >> > > > > But. *What's the point* of doing it this way. I see 14 variables > > being assigned a value, but I don't see the value, they are getting. > > Reading this bit if code provides no useful information unless I'm > > willing to scan down the file until I find the end of this mess. And in > > that scanning I have to make sure I don't miss the one single line that > > does not end in a backslash. (Your ellipsis conveniently left out the > > *one* important line needed to understand what this code is doing, but > > even if you had included it, I'd have to scan *all* lines to understand > > what a single value is being assigned. > > > > There is *no way* you can argue that code is clearer than this: > > > > # General header fields > > Cache_Control = None > > Connection = None > > Date = None > > Pragma = None > > ... > > > Thank you, you saved me from making that point. It doesn't even seem > like there's a need for each header to reference the same value (though > in this case they will, precisely because there is only one None object). > > regards > Steve Another possibility is to assign to a dict using a loop, if typing None over and over again is so onerous. options = ['cache_control', 'connection', 'date', 'pragma'] params = {} for option in options: params[option] = None And of course you could substitute your choice of appropriate __dict__ for params, if you want to access the options as free-standing objects. Cheers, Cliff From evlangelis at gmail.com Mon Apr 28 08:58:51 2008 From: evlangelis at gmail.com (Albert Leibbrandt) Date: Mon, 28 Apr 2008 15:58:51 +0300 Subject: Need help on left padding In-Reply-To: <67lrc1F2o7iv7U3@mid.uni-berlin.de> References: <67lrc1F2o7iv7U3@mid.uni-berlin.de> Message-ID: <4815CA0B.3020602@gmail.com> Marc 'BlackJack' Rintsch wrote: > On Mon, 28 Apr 2008 04:37:02 -0700, rajesh kataraki wrote: > > >> My requirement is I am using one variable ex. var = 5 which is >> integer. >> And this variable, I m using in some string. But I want this var >> to be used as 005 again integer in this string. >> > > In [22]: '%03d' % 5 > Out[22]: '005' > > Ciao, > Marc 'BlackJack' Rintsch > -- > http://mail.python.org/mailman/listinfo/python-list > > that or use *str(5).zfill(3)* -------------- next part -------------- An HTML attachment was scrubbed... URL: From wwzaygvm at gmail.com Wed Apr 16 17:03:02 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 14:03:02 -0700 (PDT) Subject: indesign cs2 crack Message-ID: <7732575d-daa9-4717-9865-5efe5a0726b5@8g2000hse.googlegroups.com> indesign cs2 crack http://cracks.12w.net F R E E C R A C K S From http Wed Apr 9 22:00:43 2008 From: http (Paul Rubin) Date: 09 Apr 2008 19:00:43 -0700 Subject: How is GUI programming in Python? References: Message-ID: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> Chris Stewart writes: > I've always had an interest in Python and would like to dabble in it > further. I've worked on a few very small command line programs but > nothing of any complexity. I'd like to build a really simple GUI app > that will work across Mac, Windows, and Linux. How painful is that > going to be? I used to be really familiar with Java Swing a few years > ago. I imagine it will be similar. > ... > Next, what would you say is the best framework I should look into? If by "best" you mean "easiest", that is probably tkinter, which comes with python. It is somewhat rudimentary and the widgets that come with it don't look so great. But if you just want to put up GUI's with basic functionality and not much glitz, it is ok for most such purposes. out how to use From wizzardx at gmail.com Tue Apr 22 15:29:52 2008 From: wizzardx at gmail.com (David) Date: Tue, 22 Apr 2008 21:29:52 +0200 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. In-Reply-To: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> Message-ID: <18c1e6480804221229k1155d1e0j920ce247c941dfc4@mail.gmail.com> On Tue, Apr 22, 2008 at 8:36 PM, Kenneth McDonald wrote: > Sadly. > > Thanks, > Ken > -- I checked, it's up now. You can also download packaged versions from Linux distros. eg: http://packages.debian.org/sid/web/python-beautifulsoup (there's a link to the tar.gz on the right side). Doesn't come with the nice online docs. But you can find those in other places (eg Google Cache). David. From michels at mps.mpg.de Tue Apr 15 04:31:50 2008 From: michels at mps.mpg.de (Helmut Michels) Date: Tue, 15 Apr 2008 10:31:50 +0200 Subject: [ANN] Data Plotting Library DISLIN 9.3 Message-ID: Dear Python users, I am pleased to announce version 9.3 of the data plotting software DISLIN. DISLIN is a high-level and easy to use plotting library for displaying data as curves, bar graphs, pie charts, 3D-colour plots, surfaces, contours and maps. Several output formats are supported such as X11, VGA, PostScript, PDF, CGM, WMF, HPGL, TIFF, GIF, PNG, BMP and SVG. The software is available for the most C, Fortran 77 and Fortran 90/95 compilers. Plotting extensions for the interpreting languages Perl, Python and Java are also supported. DISLIN distributions and manuals in PDF, PostScript and HTML format are available from the DISLIN home page http://www.dislin.de and via FTP from the server ftp://ftp.gwdg.de/pub/grafik/dislin All DISLIN distributions are free for non-commercial use. Licenses for commercial use are available from the site http://www.dislin.de. ------------------- Helmut Michels Max Planck Institute for Solar System Research Phone: +49 5556 979-334 Max-Planck-Str. 2 Fax : +49 5556 979-240 D-37191 Katlenburg-Lindau Mail : michels at mps.mpg.de From fennelllindy8241 at gmail.com Mon Apr 28 03:25:10 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:25:10 -0700 (PDT) Subject: 4502 cams patch Message-ID: <1700c43f-6402-4fdf-bf17-10f0014ca9ae@x35g2000hsb.googlegroups.com> 4502 cams patch http://crack.cracksofts.com From uwe.kotyczka at web.de Thu Apr 3 16:31:46 2008 From: uwe.kotyczka at web.de (Uwe Kotyczka) Date: Thu, 3 Apr 2008 13:31:46 -0700 (PDT) Subject: Nonlinear least square problem Message-ID: <0354420e-819d-4ba3-b61a-faaffd46b65c@r9g2000prd.googlegroups.com> Hallo, sorry for multiposting, but I am really looking for some hint to solve my problem. And no, I don't use Matlab, but maybe the matlab people have an idea nevertheless. I have to solve a nonlinear least square problem. Let me tell you some background first. Imagine you have a tool to process some work piece, say polishing some piece of glas. The tool behaves different on different locations of the piece, and I can describe that behaviour. Now the tool shall smooth the surface of the workpiece. Next I have information about the piece before handling it. What I have to find is optimal time curve for the tool to obtain a perfectly smooth surface. How to formulate the problem? Given a time vector (t_j) I have a function g which calculates the remaining error (e_i) (e_i) = g(t_j) The rest error is given at, say, 100 points, (t_j) is searched at 200 points. My idea was to make the (t_j) a function of some few parameters (t_j) = h(p_k), say 15 parameters. So the concatenated function (e_i) = g(t_j) = g(h(p_k)) =: f(p_k) is to be minimized. in the sense (e_i)-c -> Min, where c is a constant, the end level of the surface. To solve this problem I use a "C" implementation of the Levenberg-Marquardt algorithm as you can find it in the LevMar Package (www.ics.forth.gr/~lourakis/levmar/). The function g contains the information about the tool and about the initial surface. For the function h I tried several approaches, making the time a cubic spline of a selected times, or making it some polynmial or... Now what is my problem? With the above I do find solutions, however a lot of solutions seem to give very similar remaining errors. The only problem is that the corresponding time vectors, which are (t_j_optimal) = h(p_k_optimal) look very different from optimal solution to optimal solution. In particular the optimization algorithm often prefers solutions where the time vector is heavily oscillating. Now this is something I _must_ suppress, but I have no idea how. The oscillation of the (t_j) depend of the ansatz of h, of the number of parameters (p_k). If f would be a linear function, then the matrix representing it would be a band matrix with a lot of diagonals nonzero. How many depends on the ratio tool diameter to piece diameter. Now what are my question: Is the problem properly formulated? Can I expect to find non-oscillating solutions? Is it normal that taking more parameters (p_k) makes the thing worse? What else should I consider? Is this more verbal description sufficient? Thank you very much in advance. From peterjwright at gmail.com Wed Apr 2 10:15:23 2008 From: peterjwright at gmail.com (Pete Wright) Date: Wed, 2 Apr 2008 07:15:23 -0700 (PDT) Subject: developing web spider References: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> <30a89852-4730-490b-8701-b915cb0901ce@q27g2000prf.googlegroups.com> Message-ID: <1b3eb5b4-e540-4832-acc3-a2e1c959e526@f63g2000hsf.googlegroups.com> The O'Reilly Spidering Hacks book is also really good, albeit a little too focussed on Perl. On Apr 2, 9:54 am, zillo... at googlemail.com wrote: > On Apr 2, 6:37 am, abeen wrote: > > > Hello, > > > I would want to know which could be the best programming language for > > developing web spider. > > More information about the spider, much better,, > > > thanks > > >http://www.imavista.com > > Just saw this while passing by... There's a nice book by Michael > Schrenk (www.schrenk.com) called "Webbots, Spiders and Screen > Scrapers" that teaches scraping and spidering from the ground up using > PHP. Since you said you want more info on spiders, this book might be > a good way for you to acquire concept and implementation hand-in-hand. > He's also developed a nice webbot library in PHP that you can get from > his website. > > Also comes with a nice webbot library (which you can download from > the website anyway). From arnodel at googlemail.com Tue Apr 8 01:47:13 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Mon, 7 Apr 2008 22:47:13 -0700 (PDT) Subject: Translating keywords References: Message-ID: On Apr 8, 3:47?am, "Gabriel Genellina" wrote: > Python 3 allows for unicode identifiers, but I don'k know any plans for ? > using unicode keywords too. Looks funny: > > ? x ? values: > ? ?if x ? forbidden ? x ? y: > ? ? ?print(x, ?(x), ?(x)) > print(?(values)) > near = ? a,b,?=0.01: a-? ? b ? a+? It's all in the eye of the beholder: to me it looks readable, but that's because I've spent 10 years of my life reading and writing stuff like that. Although I would use ? and ? as aliases for all() and exists() :) -- Arnaud From ni at hao.com Wed Apr 30 04:06:12 2008 From: ni at hao.com (SL) Date: Wed, 30 Apr 2008 10:06:12 +0200 Subject: computing with characters In-Reply-To: References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> Message-ID: <5ed0b$48182881$541fc2ec$5430@cache1.tilbu1.nb.home.nl> "Arnaud Delobelle" schreef in bericht news:m2d4o7bwmd.fsf at googlemail.com... > "Gabriel Genellina" writes: > >> En Wed, 30 Apr 2008 04:19:22 -0300, SL escribi?: >> >>> "Lutz Horn" schreef in bericht >>> news:mailman.360.1209537877.12834.python-list at python.org... >>>> >>>> So just for completion, the solution is: >>>> >>>>>>> chr(ord('a') + 1) >>>> 'b' >>> >>> thanks :) I'm a beginner and I was expecting this to be a member of >>> string so I couldnt find it anywhere in the docs. >> >> And that's a very reasonable place to search; I think chr and ord are >> builtin functions (and not str methods) just by an historical >> accident. (Or is there any other reason? what's wrong with "a".ord() >> or str.from_ordinal(65))? > > > Not a reason, but doesn't ord() word with unicode as well? yes it does, I just read the documentation on it :) > > -- > Arnaud > From floris.bruynooghe at gmail.com Mon Apr 7 08:30:18 2008 From: floris.bruynooghe at gmail.com (Floris Bruynooghe) Date: Mon, 7 Apr 2008 05:30:18 -0700 (PDT) Subject: @x.setter property implementation References: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> Message-ID: On Apr 6, 6:41 pm, "Daniel Fetchinson" wrote: > > I found out about the new methods on properties, .setter() > > and .deleter(), in python 2.6. Obviously that's a very tempting > > syntax and I don't want to wait for 2.6... > > > It would seem this can be implemented entirely in python code, and I > > have seen hints in this directrion. So before I go and try to invent > > this myself does anyone know if there is an "official" implementation > > of this somewhere that we can steal until we move to 2.6? > > The 2.6 source? Have been grepping all over the place and failed to find it. I found the test module for them, but that doesn't get me very far... From billingspanshism at gmail.com Sat Apr 19 17:19:22 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:19:22 -0700 (PDT) Subject: how tall is victoria beckham Message-ID: <35040d0f-c9e9-46e4-86bd-26949cc2c856@59g2000hsb.googlegroups.com> Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From trentm at activestate.com Thu Apr 3 13:54:31 2008 From: trentm at activestate.com (Trent Mick) Date: Thu, 03 Apr 2008 10:54:31 -0700 Subject: Module not found in script that was found in command-line interpreter. Possible Path issue? In-Reply-To: <8463F6F2-4C02-48BC-BF7E-B606D4B41577@gmail.com> References: <8463F6F2-4C02-48BC-BF7E-B606D4B41577@gmail.com> Message-ID: <47F519D7.5090905@activestate.com> Jacob Davis wrote: > I just installed the MySQLdb module and I have been able to get it to > run in my command line interpreter. > > I am running Mac Leopard, and Python 2.5. > > I have tested importing and actually connecting and using a MySQL > database, although it issues some warning: > > SnakeBite:MySQL-python-1.2.2 Snake$ python > Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) > [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin > Type "help", "copyright", "credits" or "license" for more information. >>>> import MySQLdb > /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-macosx-10.3-fat.egg/_mysql.py:3: > UserWarning: Module _mysql was already imported from From that message it looks like this "python" is /usr/local/bin/python (i.e. a separate installation than Apple's system python at /usr/bin/python and /System/Library/Frameworks/Python.framework). You can tell for sure by doing: $ which python > However, while writing a .py script (with Komodo Edit) I try to simply > import the module and the in-Komodo interpreter returns an error: > Traceback (most recent call last): > File > "/Users/Snake/Documents/NPS/Thesis/Source_Code/Genetics/mysql_connect_test.py", > line 11, in > import MySQLdb > ImportError: No module named MySQLdb I suspect that this is because your run of Komodo Edit doesn't have "/usr/local/bin" on its PATH and is using "/usr/bin/python" instead of the one you typically use on the command line. You can configure Komodo to know about /usr/local/bin by adding a "PATH" setting in the "Environment" prefs panel. Arguably Komodo should just add /usr/local/bin to its runtime PATH by default, but unfortunately it currently doesn't. Komodo doesn't pick up your normal bash shell environment because of problems trying to get that information in general. Please let me know (or on the komodo-discuss list [^1] or Komodo bug database [^2]) if you have any problems getting that going. Cheers, Trent [1]: http://listserv.activestate.com/mailman/listinfo/Komodo-discuss [2]: http://bugs.activestate.com/query.cgi?product=Komodo -- Trent Mick trentm at activestate.com From gherron at islandtraining.com Wed Apr 30 02:38:26 2008 From: gherron at islandtraining.com (Gary Herron) Date: Tue, 29 Apr 2008 23:38:26 -0700 Subject: computing with characters In-Reply-To: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> Message-ID: <481813E2.2030302@islandtraining.com> SL wrote: > How can I compute with the integer values of characters in python? > Like > 'a' + 1 equals 'b' etc > -- > http://mail.python.org/mailman/listinfo/python-list You can get an integer value from a character with the ord() function. Gary Herron From fr5478bey at gmail.com Sat Apr 26 11:38:55 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:38:55 -0700 (PDT) Subject: RegistryBooster2 crack Message-ID: <32be3d11-ec3e-47bf-9139-f702f4d46d9c@e39g2000hsf.googlegroups.com> RegistryBooster2 crack http://cracks.00bp.com F R E E C R A C K S From deets at nospam.web.de Wed Apr 16 06:19:33 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 16 Apr 2008 12:19:33 +0200 Subject: webcam (usb) access under Ubuntu References: <66jlk1F2ju6c8U1@mid.uni-berlin.de> <66kkedF2l526dU2@mid.uni-berlin.de> <455760fb-8229-4be3-ba7f-7c41bdcd66de@a22g2000hsc.googlegroups.com> <362eb242-2adc-4d7b-9c0a-95e72f4b22b6@e67g2000hsa.googlegroups.com> Message-ID: <66m26hF2lo3ghU1@mid.uni-berlin.de> Berco Beute wrote: > On Apr 15, 11:45 pm, Berco Beute wrote: >> I've tried reinstalling gstreamer (for windows): >> >> http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstre...http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstre... >> >> but that didn't help. I get some complaints about 'libgstinterfaces' >> as well... > > To be more precise, when doing an 'import gst' Python shell pops up an > error dialog saying: > > "This application has failed to start because > libgstinterfaces-0.10.dll was not found." I'm sorry, but I really can't comment on gst-installion issues - that all worked for me because of ubuntu. Maybe if you are now using windows, there are better options - but I'm a *nix-boy :) Diez From steve at holdenweb.com Sat Apr 5 07:07:04 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 07:07:04 -0400 Subject: In Tkinter - having an input and an entry In-Reply-To: References: Message-ID: markfernandes02 at googlemail.com wrote: > I need some advice, > I am creating a python program to communicate with an MS Access db in > python 2.4. > I can fetch records but cannot insert records. > > def Insert(self, *row): > global cursor, title, author, pubdate > sqlInsert = "INSERT INTO Book_table" > sqlInsert = sqlInsert + "(Bookname, BookAutor, " > sqlInsert = sqlInsert + "Publicationdate) VALUES ('" > sqlInsert = sqlInsert + title + "', '" > sqlInsert = sqlInsert + author + "', " > sqlInsert = sqlInsert + pubdate + ") " First of all, read about parameterized queries so that you don't do any more of this. Abbreviated version: formulate your query so that cursor.execute takes a query with parameter slots in it as the first argument and a data set as the second argument. > myconn = odbc.odbc('accessDatabase') > cursor = myconn.cursor() > cursor.execute(sqlInsert) > myconn.commit() > cursor.close() > myconn.close() > > The above code does not work. Secondly, observe that in a GUI environment the valuable traceback information will likely be completely lost, so you should get your code working first in a command-line based tool that will provide information about what is going wrong. "Does not work" is way to vague for anyone to be able to provide helpful responses. We need to see specific tracebacks (though kudos for actually listing your code: some people effectively just say the equivalent of "My program to do X does not work, can you tell me what's wrong with it"!). > Also with Tkinter, i want to have user input records into the db, i > cannot get what the user inputs into the entry to become a string > variable. > That's usually a matter of calling the appropriate widget's correct method. For example, if you have an Entry widget called e you would retrieve the input from it by calling e.get - see http://effbot.org/tkinterbook/entry.htm for documentation from the effbot, the font of all Tkinter knowledge. > If you can help it would be most appreciated. > Thanks in advanced > Did my best. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From zedshaw at zedshaw.com Tue Apr 29 03:51:43 2008 From: zedshaw at zedshaw.com (Zed A. Shaw) Date: Tue, 29 Apr 2008 03:51:43 -0400 Subject: ]ANN[ Vellum 0.16: Lots Of Documentation and Watching Message-ID: <20080429035143.1383a32f.zedshaw@zedshaw.com> Hi Everyone, Just putting out an announcement that I've released a new version of Vellum numbered 0.16. This version should be ready for people to use as not much of the internal structure has changed in a great many commits and it contains all the latest bug fixes. It also has the beginning of an extensive PDF document describing how to use it. This is still an in-progress work, so it has grammar mistakes and spelling errors, but it does show off some nice documentation wizardy I'm experimenting with in LaTeX. Finally there's a new "watch" feature which is very handy described further down. It simply watches a file and reruns your targets when the file changes. GETTING IT Honestly, the easiest way is just: sudo easy_install zapps vellum If you want to build the book yourself and have all of TeX Live installed then you'd also need: sudo easy_install pygments idiopidae You can also hit the http://launchpad.net/vellum/ page to grab source tarballs and other goodies. THE BOOK OF VELLUM You can grab the most recent draft of the book at: http://zedshaw.com/projects/vellum/manual-final.pdf Any corrections or comments on how it is written are more than welcome. Suggestions for improving the TeX are also helpful since I'm not a TeX expert yet. The software I'm using to build that book is fully available to anyone looking to document their projects. You can grab Idiopidae, Pygments, and TeX from the interwebs. You can then grab the whole source and all the LaTeX goodness from my Bazaar repository: bzr pull http://zedshaw.com/repository/vellum/ Look in the doc/ directory for all the fun. You'll notice that the .tex files have *no* code in them, and that it's all imported by Idiopidae. Look at the doc/book.vel file to see how it's all merged and massaged together, and you can reuse this book.vel file to start your own books. CRAZY NICE WATCH FEATURE I added a feature to Vellum that is one of those "duh" features. You can tell Vellum to watch a file, and if it changes Vellum will rerun some targets. When I work on the manual.tex file, I do this: vellum -w doc/manual.tex book.draft book.view It just keeps looping, and if you hit CTRL-C you can force a build with ENTER or quit with CTRL-C. Then I use the evince PDF viewer under linux, which has similar Vim key bindings and reloads the PDF when it changes. The net effect of this is, whenever I change my manual.tex file, Vellum runs my build for the manual and evince redisplays it for me to see. You could use this simple feature to also continually run unit tests whenever a file changes that you are working on. GPLv3? How do people feel about Vellum's GPLv3 status? It actually doesn't impact anyone unless you embed Vellum into a project/product or you create commands (which you should give back anyway). Even then if you never release your build to your users then you don't need to release the commands. However, I'm curious to get other people's thoughts. Thanks a bunch folks. -- Zed A. Shaw - Hate: http://savingtheinternetwithhate.com/ - Good: http://www.zedshaw.com/ - Evil: http://yearofevil.com/ From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Sat Apr 26 06:32:08 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Sat, 26 Apr 2008 12:32:08 +0200 Subject: display monochromatic images wxPython References: <43c2ef33-b08c-4161-b170-16ab346628d7@m36g2000hse.googlegroups.com> Message-ID: <67gel8F2p1bmkU2@mid.individual.net> wongjoekmeu at yahoo.com wrote: > I want to write a GUI program with wxPython displaying an image. Then be sure to check out the wxPython demo application. It displays lots of images. Regards, Bj?rn -- BOFH excuse #217: The MGs ran out of gas. From george.sakkis at gmail.com Tue Apr 8 20:51:11 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 8 Apr 2008 17:51:11 -0700 (PDT) Subject: calling variable function name ? References: Message-ID: On Apr 8, 3:52 pm, TkNeo wrote: > I don't know the exact terminology in python, but this is something i > am trying to do > > i have 3 functions lets say > FA(param1,param2) > FB(param1,param2) > FC(param1,param2) > > temp = "B" #something entered by user. now i want to call FB. I don't > want to do an if else because if have way too many methods like > this... > > var = "F" + temp > var(param1, param2) Try this: func = globals()["F" + temp] func(param1, param2) HTH, George From sjmachin at lexicon.net Sat Apr 19 16:34:53 2008 From: sjmachin at lexicon.net (John Machin) Date: Sat, 19 Apr 2008 20:34:53 GMT Subject: [ANN] DoIt 0.1.0 Released (build tool) In-Reply-To: References: Message-ID: <480a576a$1@news.mel.dft.com.au> Eduardo Schettino wrote: > DoIt - A task execution tool (build-tool) > ========================================= > > This is the first public release of DoIt > > Website: http://python-doit.sourceforge.net/ > Release: DoIt 0.1.0 > License: MIT > > About > ----- > > DoIt is a build tool that focus not only on making/building things but on > executing any kind of tasks in an efficient way. Designed to be easy to use > and "get out of your way". You may like to consider the possibility of confusion caused by the similarity of some characters in some fonts (DoIt, Do1t, Dolt) ... google("dictionary dolt") :-) From gagsl-py2 at yahoo.com.ar Tue Apr 22 15:04:11 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 22 Apr 2008 16:04:11 -0300 Subject: Problem with urllib2 and authentification References: Message-ID: En Tue, 22 Apr 2008 11:24:20 -0300, Miguel Beltran R. escribi?: > Using this script for connect to Zope I have this error > > ---script: > import urllib2 > > protocolo='http://' > servidor='10.28.1.239/' > pagina='manage' > fullurl=protocolo+servidor+pagina > > aut=urllib2.HTTPBasicAuthHandler() > aut.add_password(realm=None, > uri=servidor, > user='myadmin', > passwd='mypass') > opener=urllib2.build_opener(aut, urllib2.HTTPHandler(debuglevel=1)) > > print opener.open(fullurl).read() > > > ---Error: > connect: (10.28.1.239, 80) > send: 'GET /manage HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: > 10.28.1.239\r\nConnection: close\r\nUser-agent: > Python-urllib/2.4\r\n\r\n' > reply: 'HTTP/1.1 401 Unauthorized\r\n' > header: Server: Zope/(Zope 2.10.5-final, python 2.4.4, win32) ZServer/1.1 > header: Date: Tue, 22 Apr 2008 14:14:45 GMT > header: Bobo-Exception-Line: 713 > header: Content-Length: 884 > header: Bobo-Exception-Value: See the server error log for details > header: Content-Type: text/html; charset=iso-8859-15 > header: Bobo-Exception-Type: Unauthorized > header: Connection: close > header: Bobo-Exception-File: HTTPResponse.py > header: WWW-Authenticate: basic realm="Zope" Note the realm="Zope" above. You should add a password for such exact realm, or use an HTTPPasswordMgrWithDefaultRealm instead. Also, the uri argument to add_password is wrong. Try this: protocolo='http://' servidor='10.28.1.239' pagina='/manage' fullurl=protocolo+servidor+pagina aut=urllib2.HTTPBasicAuthHandler() aut.add_password(realm="Zope", uri=servidor, user='myadmin', passwd='mypass') opener=urllib2.build_opener(aut, urllib2.HTTPHandler(debuglevel=1)) print opener.open(fullurl).read() The other alternative would be: pmgr = urllib2.HTTPPasswordMgrWithDefaultRealm() pmgr.add_password(None, uri=servidor, user=..., passwd=...) aut = urllib2.HTTPBasicAuthHandler(pmgr) opener=urllib2.build_opener(aut, urllib2.HTTPHandler(debuglevel=1)) -- Gabriel Genellina From jkrukoff at ltgc.com Tue Apr 15 17:25:39 2008 From: jkrukoff at ltgc.com (John Krukoff) Date: Tue, 15 Apr 2008 15:25:39 -0600 Subject: Recurring patterns: Am I missing it, or can we get these added to the language? In-Reply-To: References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: <1208294739.5926.17.camel@localhost.localdomain> On Tue, 2008-04-15 at 13:48 -0700, Jeffrey Froman wrote: > Tim Chase wrote: > > def nsplit(s, delim=None, maxsplit=None): > > if maxsplit: > > results = s.split(delim, maxsplit) > > result_len = len(results) > > if result_len < maxsplit: > > results.extend([''] * (maxsplit - result_len) > > return results > > else: > > return s.split(delim) > > I'll add a couple more suggestions: > > 1. Delay the test for maxsplit, as str.split() does the right thing if > maxsplit is None. > > 2. Use a generator to pad the list, to avoid interim list creation. This > works fine, because list.extend() accepts any iterable. This also shortens > the code a bit, because xrange() does the right thing in this case with > negative numbers. For example: > > def nsplit(s, delim=None, maxsplit=None): > results = s.split(delim, maxsplit) > if maxsplit is not None: > results.extend('' for i in xrange(maxsplit - len(results))) > return results > > > Jeffrey > Neither of these quite match what the OP's nsplit function did, as his n parameter (maxsplit here) actually specified the number of list items in the result, not the number of splits to perform. Which makes matching the default split parameters kind of pointless, as why bother doing all this work to return a 0 item list in the default maxsplit = None case. -- John Krukoff Land Title Guarantee Company From asmodai at in-nomine.org Mon Apr 14 04:54:58 2008 From: asmodai at in-nomine.org (Jeroen Ruigrok van der Werven) Date: Mon, 14 Apr 2008 10:54:58 +0200 Subject: Chinese character become ??? by pymssql or pyodbc In-Reply-To: <01d95039-b547-45ff-9b54-f04aee8eaaa1@u36g2000prf.googlegroups.com> References: <01d95039-b547-45ff-9b54-f04aee8eaaa1@u36g2000prf.googlegroups.com> Message-ID: <20080414085457.GW51167@nexus.in-nomine.org> -On [20080414 10:31], James Su (SuJinzhu at gmail.com) wrote: >But when I query those data by pymssql or pyodbc, all Chinese >Character display ??? instead. Sounds like you are getting typical Unicode replacement characters. -- Jeroen Ruigrok van der Werven / asmodai ????? ?????? ??? ?? ?????? http://www.in-nomine.org/ | http://www.rangaku.org/ >From here, what you see you become... From steven.p.clark at gmail.com Mon Apr 7 16:39:56 2008 From: steven.p.clark at gmail.com (Steven Clark) Date: Mon, 7 Apr 2008 16:39:56 -0400 Subject: Data structure recommendation? Message-ID: <663744510804071339g639bfdccl63de8be66fe52df1@mail.gmail.com> Hi all- I'm looking for a data structure that is a bit like a dictionary or a hash map. In particular, I want a mapping of floats to objects. However, I want to map a RANGE of floats to an object. This will be used for timestamped storage / lookup, where the float represents the timestamp. get(x) should return the object with the "newest" (biggest) timestamp y <= x, if it exists. Example: foo = Foo() foo.get(1.5) -> None foo.put(1.3, 'a') foo.put(2.6, 'b') foo.get(1.5) -> 'a' foo.get(7.8) -> 'b' foo.put(5.0, 'c') foo.get(7.8) -> 'c' In otherwords, by the end here, for foo.get(x), x < 1.3 maps to None, 1.3 <= x < 2.6 maps to 'a', 2.6 <= x < 5.0 maps to 'b', 5.0 <= x maps to 'c'. I know that foo.get() will be called many times for each foo.put(). Is there any way to achieve O(1) performance for foo.get(), maybe via some kind of hash function? Or is the best thing to use some kind of binary search? Thanks for any advice. -Steven From john106henry at hotmail.com Tue Apr 29 10:11:40 2008 From: john106henry at hotmail.com (John Henry) Date: Tue, 29 Apr 2008 07:11:40 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <473deef3-9acb-45dd-a7ca-47b0081bd28c@i36g2000prf.googlegroups.com> <3f7bb91e-335e-46bd-88ca-f15b26c35132@k1g2000prb.googlegroups.com> Message-ID: <827bdae6-4422-4226-a543-af53f5b7e01b@s33g2000pri.googlegroups.com> On Apr 29, 1:57 am, Panyasan wrote: > Hi, > > I am one of the two developers working on the xml-to-javascript > converter (qxtransformer) John has mentioned and we are thrilled that > our project has found a use in the PythonCard community. > > However, we have a problem getting PythonCard to work on our Macs (Mac > OS 10.5 Leopard). We should probably be asking this on the PythonCard > help list, but since the list seems to be somewhat deserted (very few > posts) and John is active here and people seem to be using PythonCard, > maybe someone has an idea. It might be very simple and stupid - I have > never worked with python before. > > I am using > - PythonCard 0.8.2 release on Leopard, which is copied by setup.py to / > Library/Python/2.5/site-packages > - John's layoutEditor package, (http://qxtransformer.googlegroups.com/ > web/layoutEditor.zip) > > PythonCard email list says that Leopard and PythonCard 0.8.2 seem to > like each other generally: > > http://sourceforge.net/mailarchive/forum.php?thread_name=EE5213D5-A00... > > and I can get the examples working. However, when I start John's > modified layoutEditor.py, I get an empty window and the following > error is thrown: > > no resource file for /Users/bibliograph/Programme/PythonCard/tools/ > layoutEditor/multipropertyEditor > Traceback (most recent call last): > File "/BinaryCache/wxWidgets/wxWidgets-11~57/Root/System/Library/ > Frameworks/Python.framework/Versions/2.5/Extras/lib/python/wx-2.8-mac- > unicode/wx/_core.py", line 14095, in > File "/Library/Python/2.5/site-packages/PythonCard/tools/ > layoutEditor/layoutEditor.py", line 153, in on_initialize > self.propertyEditorWindow = model.childWindow(self, > PropertyEditor) > File "/Library/Python/2.5/site-packages/PythonCard/model.py", line > 213, in childWindow > rsrc = resource.ResourceFile(filename).getResource() > File "/Library/Python/2.5/site-packages/PythonCard/resource.py", > line 45, in __init__ > self.dictionary = util.readAndEvalFile(rsrcFileName) > File "/Library/Python/2.5/site-packages/PythonCard/util.py", line > 39, in readAndEvalFile > f = open(filename) > TypeError: coercing to Unicode: need string or buffer, NoneType found > > there is a file PythonCard/tools/layoutEditor/modules/ > multipropertyEditor.rsrc.py > > When I resize the window, I get the following errors > > Tue Apr 29 10:48:08 noname Python[40440] : CGContextConcatCTM: > invalid context > Tue Apr 29 10:48:08 noname Python[40440] : CGContextSaveGState: > invalid context > Tue Apr 29 10:48:08 noname Python[40440] : doClip: invalid > context > Tue Apr 29 10:48:08 noname Python[40440] : CGContextSaveGState: > invalid context > Tue Apr 29 10:48:08 noname Python[40440] : > CGContextSetBlendMode: invalid context > Tue Apr 29 10:48:08 noname Python[40440] : > CGContextSetShouldAntialias: invalid context > Traceback (most recent call last): > File "/Library/Python/2.5/site-packages/PythonCard/model.py", line > 884, in _dispatch > handler(background, aWxEvent) > File "/Library/Python/2.5/site-packages/PythonCard/tools/ > layoutEditor/layoutEditor.py", line 560, in on_size > self.createDC() > File "/Library/Python/2.5/site-packages/PythonCard/tools/ > layoutEditor/layoutEditor.py", line 556, in createDC > dc.SetLogicalFunction(wx.INVERT) > File "/BinaryCache/wxWidgets/wxWidgets-11~57/Root/System/Library/ > Frameworks/Python.framework/Versions/2.5/Extras/lib/python/wx-2.8-mac- > unicode/wx/_gdi.py", line 4079, in SetLogicalFunction > wx._core.PyAssertionError: C++ assertion "status == noErr" failed > at ../src/mac/carbon/graphics.cpp(1324) in EnsureIsValid(): Cannot > nest wxDCs on the same window > > Thanks for any pointers, > > Christian Christian, It appears you're missing a file. Where did you placed my program? I see that there are two places being mentioned: > no resource file for /Users/bibliograph/Programme/PythonCard/tools/ > layoutEditor/multipropertyEditor and > File "/Library/Python/2.5/site-packages/PythonCard/tools/ > layoutEditor/layoutEditor.py", line 556, in createDC From ggrason at NOSPAM.gmail.com.INVALID Tue Apr 8 12:07:48 2008 From: ggrason at NOSPAM.gmail.com.INVALID (Guillaume) Date: Tue, 08 Apr 2008 18:07:48 +0200 Subject: List open files In-Reply-To: <47fb9789$0$881$ba4acef3@news.orange.fr> References: <47fb8d54$0$15068$426a74cc@news.free.fr> <47fb9789$0$881$ba4acef3@news.orange.fr> Message-ID: Oh and don't forget to take care about saving correctly the Oracle database ! ^^ (private joke *giggles* j/k :)) Regards, -- Guillaume From bruno.desthuilliers at gmail.com Wed Apr 2 19:03:57 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 16:03:57 -0700 (PDT) Subject: Nested try...except References: Message-ID: <767f1014-1279-40b6-bfef-fd3b39ba2dda@s37g2000prg.googlegroups.com> On 2 avr, 15:12, cokofree... at gmail.com wrote: > On Apr 2, 3:06 pm, Magnus.Morab... at gmail.com wrote: > > > > > Hi, > > > I found the following code on the net - > > > http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/%3C20050924104732.5116.qm... at minotaur.apache.org%3E > > > def count(self): > > - db = sqlite.connect(self.filename, > > isolation_level=ISOLATION_LEVEL) > > - try: > > - try: > > - cur = db.cursor() > > - cur.execute("select count(*) from sessions") > > - return cur.fetchone()[0] > > - finally: > > - cur.close() > > - finally: > > - db.close() > > > I don't understand though why the second try is not after the line cur > > = db.cursor(). Can anyone explain for me why? > > > /Barry. > > Better question is why is there a try with no except... Because the author doesn't want to handle the exception here, only make sure resources are freed. > Better yet, WHY is there two TRY statements when there could quite > happily be only one... > > Towards what you are asking, I GUESS...because the author hoped to > handle the cases where cur failed to get assigned...but then > his .close method of it would likely not work anyway...I mean...does > this even work...YUCK Indeed. From lists at cheimes.de Mon Apr 14 16:43:44 2008 From: lists at cheimes.de (Christian Heimes) Date: Mon, 14 Apr 2008 22:43:44 +0200 Subject: What parts of string module will disappear in Python 3.0? In-Reply-To: <1208205039.18800.1247843527@webmail.messagingengine.com> References: <1208205039.18800.1247843527@webmail.messagingengine.com> Message-ID: <4803C200.7040800@cheimes.de> python at bdurham.com schrieb: > I understand that many portions of the string module are redundant with > the native methods of strings and will removed in Python 3.0. Makes > sense to me. > > But what will happen to the portions of the string module that are not > covered by native string methods - like the following: > > - string constants (example: string.punctuation) > - Template strings > - maketrans() > > Will some semblance of the string module remain in Python 3.0 under the > string module name or a new module name? See for yourself: http://svn.python.org/projects/python/branches/py3k/Lib/string.py Christian From arnodel at googlemail.com Wed Apr 30 04:00:26 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Wed, 30 Apr 2008 09:00:26 +0100 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> Message-ID: "Gabriel Genellina" writes: > En Wed, 30 Apr 2008 04:19:22 -0300, SL escribi?: > >> "Lutz Horn" schreef in bericht >> news:mailman.360.1209537877.12834.python-list at python.org... >>> >>> So just for completion, the solution is: >>> >>>>>> chr(ord('a') + 1) >>> 'b' >> >> thanks :) I'm a beginner and I was expecting this to be a member of >> string so I couldnt find it anywhere in the docs. > > And that's a very reasonable place to search; I think chr and ord are > builtin functions (and not str methods) just by an historical > accident. (Or is there any other reason? what's wrong with "a".ord() > or str.from_ordinal(65))? Not a reason, but doesn't ord() word with unicode as well? -- Arnaud From Colin.Prepscius at morganstanley.com Wed Apr 2 09:19:57 2008 From: Colin.Prepscius at morganstanley.com (Prepscius, Colin (IT)) Date: Wed, 2 Apr 2008 09:19:57 -0400 Subject: ThreadingTCPServer: sock.recv() doesn't block? Message-ID: So I'm using the ThreadingTCPServer from the python standard library SocketServer, and calling serve_forever on it. In my handler's handle method, I call self.request.recv(x) in a loop until I've received n bytes. But recv() returns immediately with nothing, over and over. It all still works, but my cpu pegs. I thought socketc.recv() was supposed to block. Anybody know if I'm doing something wrong? thanks! Colin -------------------------------------------------------- NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error. -------------- next part -------------- An HTML attachment was scrubbed... URL: From bowman at montana.com Sun Apr 6 12:04:23 2008 From: bowman at montana.com (bowman) Date: Sun, 06 Apr 2008 10:04:23 -0600 Subject: Best way to check if string is an integer? References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> <0fdd2825-6d1c-4380-a79a-a7aac119f002@a5g2000prg.googlegroups.com> <96d2fe53-96bf-43d8-a58d-8269846bf0df@b64g2000hsa.googlegroups.com> Message-ID: <2033313.fb3g3XYCIP@montana.com> Jorgen Grahn wrote: > [0] There would have been more if Python had supported hexadecimal > floating-point literals, like (I believe) C does. C99 does. On the other hand, it isn't a feature I sorely missed during the first 20 years or so of C's history, but you could always do some creative byte twiddling if the need arouse. From bruno.42.desthuilliers at wtf.websiteburo.oops.com Tue Apr 1 05:02:27 2008 From: bruno.42.desthuilliers at wtf.websiteburo.oops.com (Bruno Desthuilliers) Date: Tue, 01 Apr 2008 11:02:27 +0200 Subject: Newbie Question - Overloading == In-Reply-To: References: <85edb5fb-eae8-4e8f-8f77-0ee4668063cd@u69g2000hse.googlegroups.com> <7eb5d21a-c4de-4655-ab93-9221d996f424@i7g2000prf.googlegroups.com> Message-ID: <47f1fa23$0$27429$426a74cc@news.free.fr> Duncan Booth a ?crit : > "bruno.desthuilliers at gmail.com" wrote: > >>> Surely an A isn't equal to every other object which just happens to >>> have the same attributes 'a' and 'b'? >> And why not ?-) >> >>> I would have thoughts the tests want to be >>> something like: >>> >>> class A: >>> def __eq__(self,other): >>> return (isinstance(other, A) and >>> self.a == other.a and self.b == other.b) >>> >>> (and similar for B) with either an isinstance or exact match required >>> for the type. >> I don't think there's a clear rule here. Python is dynamically typed >> for good reasons, and MHO is that you should not fight against this >> unless you have equally good reasons to do so. >> > I fully agree with that, but an apple != a pear, even if they are the same > size and colour. It mostly depends on the problem at hand. It may be that for some problem, an apple == a pear if they have the same size and colour. > There will be some types where you can have equality > between objects of different types (e.g. int/float), but more often the > fact that they are different types wil automatically mean they are not > equal. 'most often' != 'always' !-) From stefan_ml at behnel.de Fri Apr 11 06:49:18 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 11 Apr 2008 12:49:18 +0200 Subject: [lxml-dev] CDATA and lxml In-Reply-To: <47FF368B.4030708@behnel.de> References: <5ebe3201-80a6-45ba-8b88-e8ece6883efa@w8g2000prd.googlegroups.com> <47FF368B.4030708@behnel.de> Message-ID: <47FF422E.5090104@behnel.de> Stefan Behnel wrote: > It's not as trivial as it sounds. Removing the CDATA sections in the parser is > just for fun. ... *not* just for fun ... obviously ... Stefan From andy.leszczynski at gmail.com Wed Apr 23 21:19:41 2008 From: andy.leszczynski at gmail.com (AlFire) Date: Wed, 23 Apr 2008 20:19:41 -0500 Subject: Python Success stories In-Reply-To: References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <480FE02D.3040201@ggmail.com> Cristina Yenyxe Gonz?lez Garc?a wrote: > 2008/4/23, Reedick, Andrew : >> IIRC, Python is used in games like Eve Online (SciFi MMO) and Vampire: >> Bloodlines (RPG.) Years later, a dedicated fan is still fixing/updating >> the Bloodlines python scripts that control the dialogue and scripted >> events. >> > > Now that you mention it, Python was also used in the Star Wars: > Knights of the Old Republic (KotOR) saga. You can even search the > scripts across the disc and take a look at hilarious code comments > like "this works but I don't know why" :D and Shrek 3 http://www.linuxjournal.com/article/9653 -- a. From deets at nospam.web.de Thu Apr 17 11:07:29 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 17 Apr 2008 17:07:29 +0200 Subject: why objects of old style classes are instances of 'object' References: <4807641F.8030209@gmail.com> Message-ID: <66p7eeF2l44iiU2@mid.uni-berlin.de> AlFire wrote: > Hi, > > Q: from the subject, why objects of old style classes are instances of > 'object'? > > >>> class a():pass > >>> A=a() > >>> isinstance(A,object) > > True Because everything is an object. But not everything is a newstyle-class: >>> class Foo: pass ... >>> isinstance(Foo, object) True >>> isinstance(Foo, type) False >>> class Bar(object): pass ... >>> isinstance(Bar, type) True >>> Diez From alexelder at gmail.com Wed Apr 23 04:49:04 2008 From: alexelder at gmail.com (alexelder at gmail.com) Date: Wed, 23 Apr 2008 01:49:04 -0700 (PDT) Subject: "Dreaming in Code" References: <14fccf8d-eb21-4e04-9244-50bcfc84c4d7@d45g2000hsc.googlegroups.com> Message-ID: <615ec25f-b4ca-4e37-afb5-0f0046c1b52a@l64g2000hse.googlegroups.com> On Apr 23, 6:12 am, Paul McGuire wrote: > Haven't seen anyone mention this book, it is a "Soul of a New Machine"- > style record of the Chandler project. Since Chandler uses Python and > Twisted, and employed a few Python celebs, I thought folks on this > list might have already read the hardcover version. I just picked up > the paperback at B&N yesterday, finished it this evening. It's a > decent read, describing a software project in laymen's terms (like > there are laymen out there who care about that sort of thing!). > > The paperback version adds a chapter including events that transpired > after the hardcover publication date, current up to about October, > '07, so that's a nice touch. > > I'm going to ask my wife to read it so she might learn what I do for a > living. > > -- Paul Hi, Paul. This book was actually the book which got me into Python! At the time of reading I was in my second year of University, utterly snowed under with Java and C related assignments/personal projects, however, I found time to read this book; I'm /so/ glad I did. I actually heard of the book from an article written by Joel 'Joel on Software', Spolsky. (you can find it here: http://www.joelonsoftware.com/items/2007/01/02.html). It's an interesting read and poses a nice insight into how software projects evolve over time. Alex. From leoniaumybragg at gmail.com Sat Apr 26 07:00:25 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 04:00:25 -0700 (PDT) Subject: civilization 3 crack Message-ID: <276f223e-15e3-4f34-88ba-b18d619d0e8f@e39g2000hsf.googlegroups.com> civilization 3 crack http://cracks.00bp.com F R E E C R A C K S From martin at v.loewis.de Sun Apr 27 03:12:07 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 27 Apr 2008 09:12:07 +0200 Subject: Why can't timedeltas be divided? In-Reply-To: References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> Message-ID: <48142747$0$20906$9b622d9e@news.freenet.de> > Last time I brought up this sort of thing, it seemed fairly unanimous > that the shortcomings of the datetime module were 'deliberate' and > would not be fixed, patch or no patch. Ok, so then if the answer to my question is "yes", the first step should be to discuss it on python-dev. Regards, Martin From python at bdurham.com Mon Apr 28 12:33:21 2008 From: python at bdurham.com (python at bdurham.com) Date: Mon, 28 Apr 2008 12:33:21 -0400 Subject: Given a string - execute a function by the same name Message-ID: <1209400401.22706.1250293015@webmail.messagingengine.com> I'm parsing a simple file and given a line's keyword, would like to call the equivalently named function. There are 3 ways I can think to do this (other than a long if/elif construct): 1. eval() 2. Convert my functions to methods and use getattr( myClass, "method" ) 3. Place all my functions in dictionary and lookup the function to be called Any suggestions on the "best" way to do this? Thank you, Malcolm From theller at ctypes.org Fri Apr 4 07:49:24 2008 From: theller at ctypes.org (Thomas Heller) Date: Fri, 04 Apr 2008 13:49:24 +0200 Subject: Ignoring windows registry PythonPath subkeys In-Reply-To: <133d93d0-8100-446c-909d-3b25d79af0a2@t54g2000hsg.googlegroups.com> References: <133d93d0-8100-446c-909d-3b25d79af0a2@t54g2000hsg.googlegroups.com> Message-ID: <47F615C4.3070704@ctypes.org> Floris Bruynooghe schrieb: > Hi > > We basically want the same as the OP in [1], i.e. when python starts > up we don't want to load *any* sys.path entries from the registry, > including subkeys of the PythonPath key. The result of that thread > seems to be to edit PC/getpathp.c[2] and recompile. > > This isn't that much of a problem since we're compiling python anyway, > but is that really still the only way? Surely this isn't such an > outlandish requirement? If you look into PC/getpathp.c *and* PC/dl_nt.c, you'll find that the registry key name if constructed from static components plus a variable component named PyWin_DLLVersionString. The latter is loaded from a string resource (with resource ID 1000, IIRC) inside the pythonXY.dll. This string resource can be changed (even without compiling!); so this is a way for you to force the lookup of PythonPath to a different registry key. You can choose something that probably does not exist. py2exe does this also for 'frozen' executables, and so has complete control over sys.path. Thomas From aldo at nullcube.com Tue Apr 1 22:51:04 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Wed, 2 Apr 2008 13:51:04 +1100 Subject: ANN: cubictemp template engine In-Reply-To: References: <20080402012420.GA21586@nullcube.com> Message-ID: <20080402025104.GA22178@nullcube.com> Hi Daniel, > Does it support the Buffet API? No - we don't use any of the frameworks that require it. If the implementation is simple enough, though, I'd be happy to look at a patch... ;) > Do you have any benchmarks to compare it with other template systems > (in terms of speed)? Not formally - perhaps I'll get to it one day in my Copious Free Time. Cubictemp is optimised for use in situations where Template objects are persistent. Templates are parsed on instantiation, and all expressions they contain are pre-compiled. In long-running processes like FastCGI where you can instantiate a Template once and use it many times Cubictemp should be very fast. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From aahz at pythoncraft.com Fri Apr 25 20:07:38 2008 From: aahz at pythoncraft.com (Aahz) Date: 25 Apr 2008 17:07:38 -0700 Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> Message-ID: In article <7e595409-be62-4b8c-9819-a14cd363d751 at c65g2000hsa.googlegroups.com>, azrael wrote: > >Which big aplications are written in python. YouTube -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ Why is this newsgroup different from all other newsgroups? From john00587 at gmail.com Mon Apr 21 01:39:35 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:39:35 -0700 (PDT) Subject: anydvd 6.1.6.0 crack Message-ID: <07e5ad34-98a9-4ea5-800e-2c67940e9349@w1g2000prd.googlegroups.com> anydvd 6.1.6.0 crack http://cracks.00bp.com F R E E C R A C K S From ockman at gmail.com Mon Apr 21 20:12:44 2008 From: ockman at gmail.com (ockman at gmail.com) Date: Mon, 21 Apr 2008 17:12:44 -0700 (PDT) Subject: Problems replacing \ with \\ References: <0ca30eb2-3791-4910-9e78-f32e3b2a72cb@2g2000hsn.googlegroups.com> Message-ID: <6f7342eb-08f8-45d6-b50e-652bf77921d7@l42g2000hsc.googlegroups.com> HTH -- Thank you for the response. I'm not sure I understand the last sentence, although I think I get the idea. How do I create a proper doctest? Thanks On Apr 21, 9:08 pm, MRAB wrote: > On Apr 21, 11:48 pm, "samsli... at gmail.com" > wrote: > > > > > Hi... > > > Here's a weird problem...I'm trying to escape a bunch of data to put > > into a database. > > > Here's what I have: > > > def escape(string): > > """ > > Escape both single quotes and blackslashes > > >>> x = r"fun\fun" > > >>> escape(x) > > 'fun\\\\fun' > > """ > > string = string.replace('\\', '\\\\') > > return string > > > Now the commands in the doctest work when I type them by hand into the > > python interpreter!>>> x = r"fun\fun" > > >>> escape(x) > > > 'fun\\\\fun' > > > But they don't work when I actually run them with doctest: > > Failed example: > > escape(x) > > Expected: > > 'fun\\fun' > > Got: > > 'fun\x0cun' > > > Why? > > > Thanks! > > Your doctest is in a triple-quoted string which contains the line: > > >>> x = r"fun\fun" > > ^^ > > which is the same as: > > >>> x = r"fun\x0cun" > > ^^^^ > > If you wrap a raw string in just quotes that is isn't a raw string any > longer! > > HTH From george.sakkis at gmail.com Tue Apr 29 13:44:33 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 29 Apr 2008 10:44:33 -0700 (PDT) Subject: Issue with regular expressions References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Message-ID: <0ad3385b-7864-4c54-9f1e-36e907000a6c@m45g2000hsb.googlegroups.com> On Apr 29, 9:46 am, Julien wrote: > Hi, > > I'm fairly new in Python and I haven't used the regular expressions > enough to be able to achieve what I want. > I'd like to select terms in a string, so I can then do a search in my > database. > > query = ' " some words" with and "without quotes " ' > p = re.compile(magic_regular_expression) $ <--- the magic happens > m = p.match(query) > > I'd like m.groups() to return: > ('some words', 'with', 'and', 'without quotes') > > Is that achievable with a single regular expression, and if so, what > would it be? As other replies mention, there is no single expression since you are doing two things: find all matches and substitute extra spaces within the quoted matches. It can be done with two expressions though: def normquery(text, findterms=re.compile(r'"([^"]+)"|(\S+)').findall, normspace=re.compile(r'\s{2,}').sub): return [normspace(' ', (t[0] or t[1]).strip()) for t in findterms(text)] >>> normquery(' "some words" with and "without quotes " ') >>> ['some words', 'with', 'and', 'without quotes'] HTH, George From castironpi at gmail.com Mon Apr 21 11:12:31 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Mon, 21 Apr 2008 08:12:31 -0700 (PDT) Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> Message-ID: <8f3a768d-0b4c-4077-9aef-a66898882f03@m1g2000pre.googlegroups.com> On Apr 21, 9:28?am, a... at pythoncraft.com (Aahz) wrote: > In article <23bf20ad-9996-4b79-97ef-7930a228c... at t54g2000hsg.googlegroups.com>, > Joseph Turian ? wrote: > > > > >Basically, we're planning on releasing it as open-source, and don't > >want to alienate a large percentage of potential users. > > Datapoint: my company still uses 2.3 and *might* upgrade to 2.4 and > later this year. ?Basically, any company with lots of servers has a good > chance to still be stuck with 2.2/2.3 (we only dropped 2.2 last fall). > -- > Aahz (a... at pythoncraft.com) ? ? ? ? ? <*> ? ? ? ?http://www.pythoncraft.com/ > > Why is this newsgroup different from all other newsgroups? ? Different is a verbally atomic relation. From bignose+hates-spam at benfinney.id.au Sun Apr 6 21:02:34 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Mon, 07 Apr 2008 11:02:34 +1000 Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> Message-ID: <87prt2mq8l.fsf@benfinney.id.au> Aldo Cortesi writes: > I'm afraid that Pry is unashamedly incompatible with any other unit > testing method in existence, including but not limited to doctest, > unittest, nose and py.test. ;) Which makes the deliberate deviations from PEP 8 naming a large black mark against it. > Some day I might experiment with extending Pry to gather and run > doctests and unittests. At this stage, however, I don't believe the > (significant) effort would be worth it. That's very unfortunate. Until it plays better with others, I don't believe the effort of using this package will be worth it. -- \ "If you ever drop your keys into a river of molten lava, let | `\ 'em go, because, man, they're gone." -- Jack Handey | _o__) | Ben Finney From rob.clewley at gmail.com Mon Apr 7 12:30:18 2008 From: rob.clewley at gmail.com (Rob Clewley) Date: Mon, 7 Apr 2008 12:30:18 -0400 Subject: Mathematical Python Library In-Reply-To: References: Message-ID: The closest thing so far is probably going to be a combination of the numpy, scipy, and sympy libraries. The latter is the one with the most functionality for solving equations algebraically, but is also the least mature package at the moment. The first two also provide the basic tools for calculating the nulls of a function (for instance) as numerical approximations, provided you are able to write small scripts to use those tools. -Rob On Mon, Apr 7, 2008 at 12:05 PM, mc wrote: > I'm looking for a library which can do mathematical stuff like > solving equations. Or calculation the nulls of a function and so on. > Does anyone know one? > > Thanks in advance! > -- > http://mail.python.org/mailman/listinfo/python-list > -- Robert H. Clewley, Ph. D. Assistant Professor Department of Mathematics and Statistics Georgia State University 720 COE, 30 Pryor St Atlanta, GA 30303, USA tel: 404-413-6420 fax: 404-651-2246 http://www.mathstat.gsu.edu/~matrhc http://brainsbehavior.gsu.edu/ From robert.kern at gmail.com Fri Apr 4 19:29:33 2008 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 04 Apr 2008 18:29:33 -0500 Subject: Importing a 3rd Party windows DLL for use within th Python In-Reply-To: <92513305-836d-4c85-aeb8-3e3d6571ed92@1g2000prg.googlegroups.com> References: <92513305-836d-4c85-aeb8-3e3d6571ed92@1g2000prg.googlegroups.com> Message-ID: lee.walczak at gmail.com wrote: > Hi, > > I have recently started learing how to code/script in Python which I > am realy enjoying. I am new to this game as my background is RF/HW > design engineer so coding is not my first skillset , so please bare > with me! > > I am a little lost with how to procede on this problem. I need to > write a python script enabling me to comunnicate routines to a pico > ADC212 oscilloscope. I have been provided with a windows DLL & a > header filefrom the manufacturer. > Is it possible for someone to provide the information on the steps > necessary to access this DLL and treat it like any other pyd library? > Maybe there is already a tutorial available for performing this task? > Is this task straight forward? It depends on how complicated the library is. For a first stab, I recommend using ctypes. ctypes lets you load the DLL and call its functions in pure Python without having to write an extension module (pyd) first. ctypes comes with Python 2.5 already; if you have Python 2.4, you can install it separately. http://python.net/crew/theller/ctypes/ You may eventually want to write an extension module. Here is the tutorial: http://docs.python.org/ext/ext.html There are a couple of tools to make this task easier. I happen to like Cython for things like this: http://cython.org/ One large benefit of using ctypes instead of building an extension is that you do not have to compile anything. When wrapping binary-only DLLs on Windows, compiling and linking correctly are often the largest hurdles. -- 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 From malkarouri at gmail.com Thu Apr 24 08:28:12 2008 From: malkarouri at gmail.com (malkarouri) Date: Thu, 24 Apr 2008 05:28:12 -0700 (PDT) Subject: function that accepts any amount of arguments? References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> <4810724a$0$23390$426a74cc@news.free.fr> Message-ID: <63ac69bf-9f6d-42bd-8e6e-5b3b17ec7c69@z72g2000hsb.googlegroups.com> On Apr 24, 12:43?pm, Bruno Desthuilliers wrote: [...] > Not quite sure what's the best thing to do in the second case - raise a > ValueError if args is empty, or silently return 0.0 - but I'd tend to > choose the first solution (Python's Zen, verses 9-11). What's wrong with raising ZeroDivisionError (not stopping the exception in the first place)? k From webograph at eml.cc Sun Apr 27 08:38:45 2008 From: webograph at eml.cc (webograph) Date: Sun, 27 Apr 2008 14:38:45 +0200 Subject: Why can't timedeltas be divided? In-Reply-To: References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> <48142747$0$20906$9b622d9e@news.freenet.de> Message-ID: <481473D5.2060605@eml.cc> On 2008-04-27 14:18, Jon Ribbens wrote: > Yes, that's where it was decided that the datetime module was fine > that way it is and must not be changed. could you give me some pointers to that discussion? i found some discussion about interpretation as intervals [1], casting numbers to intervals [2] and vice versa (plus discussion of connection to unix timestamps) [3], and arithmetics of time/datetime and timedelta [4], on which i agree that those are problematic (some of those also touch the problem of time zones). nevertheless, i fail to see such problems when dividing timedeltas -- after all, `delta2 / 5 == delta1` works, so why should not `delta2 / delta1 == 5`? regards webograph [1] http://www.mail-archive.com/python-dev at python.org/msg21629.html [2] http://mail.python.org/pipermail/python-dev/2002-March/020604.html [3] http://www.mailinglistarchive.com/python-dev at python.org/msg12596.html [4] http://bugs.python.org/issue1118748 From gslindstrom at gmail.com Wed Apr 9 08:08:37 2008 From: gslindstrom at gmail.com (Greg Lindstrom) Date: Wed, 9 Apr 2008 07:08:37 -0500 Subject: Very good Python Book. Free download : Beginning Python: From Novice to Professional Message-ID: > From: hassan nikbakhsh > Subject: Very good Python Book. Free download : Beginning Python: From > Novice to Professional > can i have a free bownload of this book > many thanks > Yes, it's a very good book. Magnus Lie Hetland spent a lot of time putting the book together; why not *buy* it (~$29.00 on Amazon) to help support the effort? It's not that much and a great way to say "thanks". --greg -------------- next part -------------- An HTML attachment was scrubbed... URL: From gagsl-py2 at yahoo.com.ar Fri Apr 11 01:27:55 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 11 Apr 2008 02:27:55 -0300 Subject: Cannot understand the detailedly the following code References: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> <10a83944-b17a-4c3f-992b-1754c0a5e9b1@s33g2000pri.googlegroups.com> Message-ID: En Thu, 10 Apr 2008 23:57:29 -0300, escribi?: > i.e. you give, the graph, the start and end vertices as inputs and you > get the output as a listing of all the paths. This is where I got to. > It would be very nice if you could kindly hint on how to proceed > further. Thank you so much for your time! If you want to understand how recursion works, or how you can actually construct a recursive function step by step, see this excellent post by Neil Cerutti: http://groups.google.com/group/comp.lang.python/msg/9f0b10631fd47886 -- Gabriel Genellina From aboudouvas at panafonet.gr Mon Apr 14 16:10:44 2008 From: aboudouvas at panafonet.gr (king kikapu) Date: Mon, 14 Apr 2008 13:10:44 -0700 (PDT) Subject: Python GUI programming and boa or better ? References: Message-ID: On 14 ???, 16:20, bvidinli wrote: > I program in python for about 2-3 monthos. > I just started/tested gui programming with many tools. > i tested boa last, it is the closest tool to delphi in tui tools that i used. > > I managed to play with it a bit. > > If you have any other tool which you know better than Boa Constructor, > please write in here. > > Any other suggestion about python GUI programming is welcome. > thanks. > > -- > ?.Bahattin Vidinli > Elk-Elektronik M?h. > ------------------- > iletisim bilgileri (Tercih sirasina gore): > skype: bvidinli (sesli gorusme icin,www.skype.com) > msn: bvidi... at iyibirisi.com > yahoo: bvidinli > > +90.532.7990607 > +90.505.5667711 Use PyQt. It ha some very nice goodies (Qt Designer and the like). From nagle at animats.com Wed Apr 2 12:01:15 2008 From: nagle at animats.com (John Nagle) Date: Wed, 02 Apr 2008 09:01:15 -0700 Subject: developing web spider In-Reply-To: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> References: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> Message-ID: <47f3ab52$0$36346$742ec2ed@news.sonic.net> abeen wrote: > Hello, > > I would want to know which could be the best programming language for > developing web spider. > More information about the spider, much better,, As someone who actually runs a Python based web spider in production, I should comment. You need a very robust parser to parse real world HTML. Even the stock version of BeautifulSoup isn't good enough. We have a modified version of BeautifulSoup, plus other library patches, just to keep the parser from blowing up or swallowing the entire page into a malformed comment or tag. Browsers are incredibly forgiving in this regard. "urllib" needs extra robustness, too. The stock timeout mechanism isn't good enough. Some sites do weird things, like open TCP connections for HTTP but not send anything. Python is on the slow side for this. Python is about 60x slower than C, and for this application, you definitely see that. A Python based spider will go compute bound for seconds per page on big pages. The C-based parsers for XML/HTML aren't robust enough for this application. And then there's the Global Interpreter Lock; a multicore CPU won't help a multithreaded compute-bound process. I'd recommend using Java or C# for new work in this area if you're doing this in volume. Otherwise, you'll need to buy many, many extra racks of servers. In practice, the big spiders are in C or C++. > http://www.immavista.com Lose the ad link. John Nagle From mcaloney at gmail.com Wed Apr 16 10:00:26 2008 From: mcaloney at gmail.com (Chris McAloney) Date: Wed, 16 Apr 2008 10:00:26 -0400 Subject: is file open in system ? - other than lsof In-Reply-To: References: Message-ID: On 16-Apr-08, at 9:20 AM, A.T.Hofkamp wrote: > On 2008-04-16, bvidinli wrote: >> is there a way to find out if file open in system ? - >> please write if you know a way other than lsof. because lsof if >> slow for me. >> i need a faster way. >> i deal with thousands of files... so, i need a faster / python way >> for this. >> thanks. > > This is not a Python question but an OS question. > (Python is not going to deliver what the OS doesn't provide). > > Please first find an alternative way at OS level (ie ask this > question at an > appropiate OS news group). Once you have found that, you can think > about Python > support for that alternative. I agree with Albert that this is very operating-system specific. Since you mentioned 'lsof', I'll assume that you are at least using a Unix variant, meaning that the fcntl module will be available to you, so you can check if the file is already locked. Beyond that, I think more information on your application would be necessary before we could give you a solid answer. Do you only need to know if the file is open, or do you want only the files that are open for writing? If you only care about the files that are open for writing, then checking for a write-lock with fcntl will probably do the trick. Are you planning to check all of the "thousands of files" individually to determine if they're open? If so, I think it's unlikely that doing this from Python will actually be faster than a single 'lsof' call. If you're on Linux, you might also want to have a look at the /proc directory tree ("man proc"), as this is where lsof gets its information from on Linux machines. Chris From jeffober at gmail.com Thu Apr 3 08:59:33 2008 From: jeffober at gmail.com (Jeff) Date: Thu, 3 Apr 2008 05:59:33 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> <4b7337a4-beda-4984-91f5-6efda6fb390d@r9g2000prd.googlegroups.com> Message-ID: On Apr 3, 8:19?am, George Sakkis wrote: > On Apr 3, 8:03 am, Jeff wrote: > > > def foo(sample, strings): > > ? ? ? ? for s in strings: > > ? ? ? ? ? ? ? ? if sample in s: > > ? ? ? ? ? ? ? ? ? ? ? ? return True > > ? ? ? ? return False > > > This was an order of magnitude faster for me than using str.find or > > str.index. ?That was finding rare words in the entire word-list (w/ > > duplicates) of War and Peace. > > If you test against the same substrings over and over again, an > alternative would be to build a regular expression: > > import re > search = re.compile('|'.join(re.escape(x) > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?for x in substrings)).search > p = search(somestring) > if p is not None: > ? print 'Found', p.group() > > George That would be an enormous regular expression and eat a lot of memory. But over an enormous number of substrings, it would be O(log n), rather than O(n). From Johannes.Nix at gmx.net Sun Apr 27 15:25:53 2008 From: Johannes.Nix at gmx.net (Johannes Nix) Date: Sun, 27 Apr 2008 12:25:53 -0700 (PDT) Subject: Chapter on real-time signal processing using numerical Python Message-ID: Hi, this might be of interest for people who are look for practical information on doing real-time signal processing, possibly using multiple CPUs, and wonder whether it's possible to use Python for audio-type worst case latencies (around 25 ms). I've done that in my PhD work, both with real-time requirements on dual-CPU 64 bit platforms, and with very complex algorithms running on multicomputers. What I found is that numerical Python is a great environment for such tasks. I've used it as well for massively parallel algorithms (particle filters) for simulations of auditory scene analysis. What is a very special advantage is that if you get faster hardware, you can simply copy your algorithms to a new system and compile - even if it has a different CPU! I've documented the approach in my PhD thesis, in Appendix A, starting with some thoughts on developments in signal processing in the last years. This piece is available online. Title and abstract of that chapter read as follows: -------------------------------------------------------------- A real-time, script-based, multiprocessing Solution for experimental Development of Signal Processing Algorithms Evaluation of audio signal processing algorithms on real-time platforms has unique advantages. However, such environments also used to have the disadvantage of requiring expensive hardware, and tedious work to set them up, while providing only a short useful life. This report proposes to exploit advances in hardware and software development by integrating real-time processing with script-based explorative development and use of multiprocessing hardware. The concept was implemented based on standard hardware and open source software, and its realization and characteristics are presented here. Applications of the system for algorithm development and evaluation are described briefly. -------------------------------------------------------------- Here is the download link for several paper formats: http://medi.uni-oldenburg.de/members/jnix/index.html#thesisdownload Alternatively, for ISO A4 paper, use one of these two URLs: http://medi.uni-oldenburg.de/download/paper/Nix,Johannes-PhDthesis-2005-ISO-A4-format.pdf http://docserver.bis.uni-oldenburg.de/publikationen/dissertation/2006/nixloc05/nixloc05.html (for that paper size, this are the PDF pages 155 - 163) If you want to cite the chapter, e.g. when doing advocacy for scientific computing using SciPy, please do this as follows: Nix, Johannes (2005), "A real-time, script-based, multiprocessing Solution for experimental Development of Signal Processing Algorithms", in: Localization and Separation of Concurrent Talkers Based on Principles of Auditory Scene Analysis and Multi-Dimensional Statistical Methods, Appendix A, Ph.D. thesis, Universit?t Oldenburg, Germany. Also, I am currently looking for interesting further work opportunities or contracts in the domain of scientific computing and statistical estimation. If you know some interesting position, don't hesistate to contact me. Kind regards, Johannes -- Dr. Johannes Nix Energy & Meteo Systems GmbH Research & Development of windpower forecasts Bremen, Germany Phone: + 49 421 8963914 From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 30 07:05:02 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 30 Apr 2008 13:05:02 +0200 Subject: best way to host a membership site In-Reply-To: <53034dcc-7346-4f71-889c-3278c9e813ec@w1g2000prd.googlegroups.com> References: <53034dcc-7346-4f71-889c-3278c9e813ec@w1g2000prd.googlegroups.com> Message-ID: <48185252$0$32098$426a74cc@news.free.fr> Magdoll a ?crit : > Hi, > I know this is potentially off-topic, but because python is the > language I'm most comfortable with and I've previously had experiences > with plone, I'd as much advice as possible on this. > > I want to host a site where people can register to become a user. They > should be able to maintain their own "showroom", where they can show > blog entries (maybe just by linking to their own blogs on some other > blog/album-hosting site like Xanga), put up pictures (again, I'm not > thinking about actually hosting these data, since there are already > plenty of places to put your pictures and blogs). The most important > thing is they will be able to build up a "profile" where I can store > in a DB. The profile will include membership information - for now, > think of it as "member X owns item A,B,C and gave comments on A such > and such, also member X is a male white caucasian between his 20-30 > who likes outdoors". Eventually, I want this to be a simple social- > networking site where people can share a very particular hobby (I'm > doing it for comsetics and for a very targeted group that are active > bloggers, so they'll be somewhat web-salient) and the backend can > collect enough data (while maintaining privacy) to build up a > recommendation system similar to Netflix's movie recommendations, or > Match.com if you will. You may want to have a look at o'reilly's "Programming Collective Intelligence" http://www.oreilly.com/catalog/9780596529321/ The code examples are alas very very poorly coded, but at least they are in Python. > I want to know that given I know python best and I abhor C#/ASP, what > is the best thing to use. A friend recommended Ruby on Rails - not to > instigate war here, but I'd welcome comments on that (I don't know > Ruby, but I'll learn). Ruby by itself is a nice language, but really on the same "niche" as Python. Rails is a nice framework too, but there are real problems wrt/ perfs and scalability - nothing that can't be solved given enough efforts and hardware, but depending on the expected load, this might be something you want to take into account (or just don't care). > I've used PLONE before, but back then I > remembered the site ran incredably slow (or it could just be the > server), and there were issues with upgrades. Plone is indeed a 80000-pounds behemoth, and (from working experience) is certainly one of the worst possible solution for anything else than pure content management. > I want to minimze time > on trying to learn how to write an interface for users to register and > manage their own space. Also I want an infrastructure that's not too > rigid so if in the future I want to add more apps it's not to hard. > > I've also heard about django, but not enough to know how far it'll get > me. I'm open to all sorts of suggestions. Thanks! We're about to start a couple somewhat similar projects here, and while our chief engineer is a definitive Ruby/Rails addict, we finally settled on Django. While it's not my own personal favorite Python MVC framework, it's still a very good one, and probably the more mature and stable so far. wrt/ the "add more apps in the future" concern, you may want to read this: http://www.b-list.org/weblog/2007/nov/29/django-blog/ HTH From arnodel at googlemail.com Sun Apr 13 16:06:48 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 13 Apr 2008 13:06:48 -0700 (PDT) Subject: Interesting math problem References: <3a34caaf-a279-4e86-837d-42efa4d80129@d4g2000prg.googlegroups.com> <3fe449cb-4060-4bb6-9605-1e1778b707f8@p39g2000prm.googlegroups.com> Message-ID: <16bb44e0-b5a0-446a-a541-d4930df07ae9@i36g2000prf.googlegroups.com> On Apr 13, 5:35?pm, Ivan Illarionov wrote: > On Mar 19, 2:17 pm, "BJ?rn Lindqvist" wrote: > > > > > On Mon, Mar 17, 2008 at 11:57 PM, Arnaud Delobelle > > > wrote: > > > ?> def make_slope(distance, parts): > > > ?> ? ? step = distance / float(parts) > > > ?> ? ? intstep = int(step) > > > ?> ? ? floatstep = step - intstep > > > > ?> ? ? steps = [] > > > ?> ? ? acc = 0.0 > > > ?> ? ? for i in range(parts): > > > ?> ? ? ? ? acc += floatstep > > > ?> ? ? ? ? step = intstep > > > ?> ? ? ? ? if acc > 0.999: > > > ?> ? ? ? ? ? ? step += 1 > > > ?> ? ? ? ? ? ? acc -= 1.0 > > > ?> ? ? ? ? steps.append(step) > > > ?> ? ? return steps > > > > ?OK then, using list comprehensions. ?It is more succint, is it easier > > > ?to read? > > > > ?def slope(dist, parts): > > > ? ? return [(i+1)*dist/parts - i*dist/parts for i in xrange(parts)] > > > Congratulations! You Won! Jeff Schwab's recursive approach is also > > cool but this is the most interesting abuse of integer division I have > > seen. I don't think any of the variants are readable at a first > > glance, but with a comment it should be ok. > > > -- > > mvh Bj?rn > > I really want to revive this discussion. Arnaud's approach is > definetly cool, but it turns out that in real-world situations it > doesn't work as succint as here. > > Try to use it to draw a simple non-anitaliased line in a standrad > python array or buffer object. Suppose we have an array of unsigned > bytes called `buf` where each line takes `pitch` bytes. That's what I > got while trying to take advantage of this approach. No advantage at > all. And what about ability to port the code to C for speed? > > def draw_line(buf, pitch, x, y, dx, dy): > ? ? if dx == dy == 0: > ? ? ? ? buf[y * pitch + x] = 0 > ? ? ? ? return > ? ? xdir, ydir = 1, 1 > > ? ? if dx < 0: > ? ? ? ? xdir = -1 > ? ? ? ? dx = abs(dx) > ? ? if dy < 0: > ? ? ? ? ydir = -1 > ? ? ? ? dy = abs(dy) > > ? ? if dy < dx: > ? ? ? ? steps = ((i+1) * dx / dy - i * dx / dy for i in xrange(dy)) > ? ? ? ? for step in steps: > ? ? ? ? ? ? start = y * pitch + x > ? ? ? ? ? ? if xdir > 0: > ? ? ? ? ? ? ? ? buf[start : start + step] = array('B', [0] * step) > ? ? ? ? ? ? else: > ? ? ? ? ? ? ? ? buf[start - step : start] = array('B', [0] * step) > ? ? ? ? ? ? x += step * xdir > ? ? ? ? ? ? y += ydir > ? ? else: > ? ? ? ? steps = ((i+1) * dy / dx - i * dy / dx for i in xrange(dx)) > ? ? ? ? for step in steps: > ? ? ? ? ? ? start = y * pitch + x > ? ? ? ? ? ? if ydir > 0: > ? ? ? ? ? ? ? ? for i in range(start, start + pitch * step, pitch): > ? ? ? ? ? ? ? ? ? ? buf[i] = 0 > ? ? ? ? ? ? else: > ? ? ? ? ? ? ? ? for i in range(start, start - pitch * step, -pitch): > ? ? ? ? ? ? ? ? ? ? buf[i] = 0 > ? ? ? ? ? ? x += xdir > ? ? ? ? ? ? y += step * ydir > > Please, tell me that I'm wrong and it's really possible to draw lines, > do scan-conversion and so on with such a cool succint constructs! > > -- > Ivan I don't think my answer is suitable for drawing a line the way you are doing it. FWIW, this is how I would go about it (not tested): def draw_rectangle(buf, pitch, x, y, w, h): # Make a mask for w and apply it across h lines def draw_line(buf, pitch, x, y, w, h): # w and h can't be < 0 if w < h: limits = ((i, i*h/w) for i in xrange(1, w+1)) else: limits = ((i*w/h, i) for i in xrange(1, h+1)) dx0, dy0 = 0, 0 for dx, dy in limits: draw_rectangle(x+dx0, y+dy0, dx-dx0, dy-dy0) dx0, dy0 = dx, dy The positive thing is that it is trivial to extend draw_line so that it accepts a thickness parameter as well. -- Arnaud From bhmckendrick at gmail.com Sat Apr 26 11:28:38 2008 From: bhmckendrick at gmail.com (animalMutha) Date: Sat, 26 Apr 2008 08:28:38 -0700 (PDT) Subject: Setting an attribute without calling __setattr__() References: Message-ID: > Consider reading the *second* paragraph about __setattr__ in section > 3.4.2 of the Python Reference Manual. if you are simply going to answer rtfm - might as well kept it to yourself. From stefan_ml at behnel.de Fri Apr 11 13:33:11 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 11 Apr 2008 19:33:11 +0200 Subject: [lxml-dev] CDATA and lxml In-Reply-To: <47FF368B.4030708@behnel.de> References: <5ebe3201-80a6-45ba-8b88-e8ece6883efa@w8g2000prd.googlegroups.com> <47FF368B.4030708@behnel.de> Message-ID: <47FFA0D7.1030901@behnel.de> Hi again, Stefan Behnel wrote: > Silfheed wrote: >> So first off I know that CDATA is generally hated and just shouldn't >> be done, but I'm simply required to parse it and spit it back out. >> Parsing is pretty easy with lxml, but it's the spitting back out >> that's giving me issues. The fact that lxml strips all the CDATA >> stuff off isnt really a big issue either, so long as I can create >> CDATA blocks later with <>&'s showing up instead of <>& . >> I've scoured through the lxml docs, but probably not hard enough, so >> anyone know the page I'm looking for or have a quick how to? > > There's nothing in the docs because lxml doesn't allow you to create CDATA > sections. You're not the first one asking that, but so far, no one really had > a take on this. So I gave it a try, then. In lxml 2.1, you will be able to do this: >>> root = Element("root") >>> root.text = CDATA('test') >>> tostring(root)) '' This does not work for .tail content, only for .text content (no technical reason, I just don't see why that should be enabled). There's also a parser option "strip_cdata" now that allows you to leave CDATA sections in the tree. However, they will *not* behave any different than normal text, so you can't even see at the API level that you are dealing with CDATA. If you want to be really, really sure, you can always do this: >>> root.text = CDATA(root.text) Hope that helps, Stefan From roy at panix.com Tue Apr 29 20:51:27 2008 From: roy at panix.com (Roy Smith) Date: Tue, 29 Apr 2008 20:51:27 -0400 Subject: list.reverse() References: <4816e26a$0$30938$426a74cc@news.free.fr> <98c4ad4d-3174-40cd-b281-84e318d699d3@24g2000hsh.googlegroups.com> Message-ID: In article <98c4ad4d-3174-40cd-b281-84e318d699d3 at 24g2000hsh.googlegroups.com>, blaine wrote: > Check out this cool little trick I recently learned: > >>> x=range(5) > >>> x.reverse() or x > [4, 3, 2, 1, 0] > > Useful for returning lists that you need to sort or reverse without > wasting that precious extra line :) > > What it does: x.reverse() does the reverse and returns None. or is > bitwise, so it sees that 'None' is not 'True' and then continues to > process the next operand, x. x or'd with None will always be x (and x > has just been changed by the reverse()). So you get the new value of > x :) Please don't do that in any code I have to read and understand. Cool little tricks have no place in good code. >>> x = range(5) >>> x.reverse() >>> x [4, 3, 2, 1, 0] does the same thing, and it a lot easier to understand. I buy my newlines in the big box at Costo, so I don't mind using a few extra ones here or there. From jzshao1 at gmail.com Tue Apr 15 22:24:01 2008 From: jzshao1 at gmail.com (Jonathan Shao) Date: Tue, 15 Apr 2008 22:24:01 -0400 Subject: Interesting timing issue I noticed Message-ID: I've written up a stripped down version of the code. I apologize for the bad coding; I am in a bit of a hurry. import random import sys import time sizeX = 320 sizeY = 240 borderX = 20 borderY = 20 # generates a zero matrix def generate_zero(): matrix = [[0 for y in range(sizeY)] for x in range(sizeX)] return matrix # fills zero matrix def fill_matrix(in_mat): mat = in_mat for x in range(sizeX): for y in range(sizeY): mat[x][y] = random.randint(1, 100) return mat ###################################################################### # COMPUTES ONLY A PART OF THE ARRAY def back_diff_one(back_array, fore_array, box): diff_array = generate_zero() start = time.time() for x in range(sizeX): for y in range(borderY): diff_array[x][y] = back_array[x][y] - fore_array[x][y] for y in range((sizeY - borderY), sizeY): diff_array[x][y] = back_array[x][y] - fore_array[x][y] for y in range(borderY, (sizeY - borderY)): for x in range(borderX): diff_array[x][y] = back_array[x][y] - fore_array[x][y] for x in range((sizeX - borderX), sizeX): diff_array[x][y] = back_array[x][y] - fore_array[x][y] # tracks object if (len(box) != 0): for x in range(box[0], box[2]): for y in range(box[1], box[3]): diff_array[x][y] = back_array[x][y] - fore_array[x][y] print "time one inside = " + str(time.time() - start) return diff_array ###################################################################### # COMPUTES EVERY ELEMENT IN THE ARRAY def back_diff_two(back_array, fore_array): diff_array = generate_zero() start = time.time() for y in range(sizeY): for x in range(sizeX): diff_array[x][y] = back_array[x][y] - fore_array[x][y] end = time.time() print "time two inside = " + str(end - start) return diff_array ###################################################################### # CODE TO TEST BOTH FUNCTIONS back = fill_matrix(generate_zero()) fore = fill_matrix(generate_zero()) box = [20, 20, 268, 240] start1 = time.time() diff1 = back_diff_one(back, fore, box) print "time one outside = " + str(time.time() - start1) start2 = time.time() diff2 = back_diff_two(back, fore) print "time one outside = " + str(time.time() - start2) Here are some results from several test runs: time one inside = 0.0780000686646 time one outside = 0.125 time two inside = 0.0780000686646 time two outside = 0.141000032425 >>> ================================ RESTART ================================ >>> time one inside = 0.0629999637604 time one outside = 0.125 time two inside = 0.0789999961853 time two outside = 0.125 >>> ================================ RESTART ================================ >>> time one inside = 0.0620000362396 time one outside = 0.139999866486 time two inside = 0.0780000686646 time two outside = 0.125 >>> ================================ RESTART ================================ >>> time one inside = 0.0780000686646 time one outside = 0.172000169754 time two inside = 0.0789999961853 time two outside = 0.125 >>> ================================ RESTART ================================ >>> time one inside = 0.0780000686646 time one outside = 0.125 time two inside = 0.0780000686646 time two outside = 0.125 >>> ================================ RESTART ================================ >>> time one inside = 0.0620000362396 time one outside = 0.155999898911 time two inside = 0.0780000686646 time two outside = 0.125 >>> ================================ RESTART ================================ >>> time one inside = 0.077999830246 time one outside = 0.125 time two inside = 0.077999830246 time two outside = 0.125 >>> ================================ RESTART ================================ >>> time one inside = 0.0780000686646 time one outside = 0.171000003815 time two inside = 0.077999830246 time two outside = 0.125 >>> ================================ RESTART ================================ >>> time one inside = 0.0629999637604 time one outside = 0.18799996376 time two inside = 0.0620000362396 time two outside = 0.125 Why is a large percentage of the time, the execution time for the (ostensibly smaller) first loop is actually equal to or LARGER than the second? -- "Perhaps we all give the best of our hearts uncritically, to those who hardly think about us in return." ~ T.H.White -------------- next part -------------- An HTML attachment was scrubbed... URL: From p.newbie at yahoo.com Wed Apr 16 03:00:22 2008 From: p.newbie at yahoo.com (python newbie) Date: Wed, 16 Apr 2008 00:00:22 -0700 (PDT) Subject: Mailing list question Message-ID: <397280.11586.qm@web45815.mail.sp1.yahoo.com> Hello, Just curious; can I post a basic programming question to this mailing list? Thanks in advance. Pete --------------------------------- Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. -------------- next part -------------- An HTML attachment was scrubbed... URL: From paul at boddie.org.uk Wed Apr 23 07:43:56 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Wed, 23 Apr 2008 04:43:56 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> Message-ID: <56ebf54a-3a60-433f-b073-81963d9f1007@l64g2000hse.googlegroups.com> On 23 Apr, 11:12, Mark Wooding wrote: > Gabriel Genellina wrote: > > Because Python doesn't follow the "boxed variables" model. > > Be careful here. `Boxed types' or `boxed objects' is a technical term > essentially meaning `heap-allocated objects, probably with reference > semantics', which Python most definitely does use -- so this almost > means the opposite of what you're talking about. I think Gabriel meant "variables as boxes" - the classic description of variables in "old school" programming languages, which is in contrast to the "variables as labels" model used by Python. [...] > This won't hold in Python, since assignments (which `++' > assuredly ought to be) aren't allowed as subexpressions anyway. This syntactic note is probably one of the biggest arguments against it, yes, since many of the benefits it has in C would be absent in Python. [...] > That's not quite true, in fact: it might be useful to define other kinds > of incrementing for specialist types, but I can't think of any obvious > examples off the top of my head. Well, as I recall, data structures in C++ (such as iterators) often use the pre/post-increment/decrement operators as shorthand, arguably reflecting the "pointer arithmetic" heritage of the C family of languages. It would be pure sugar in Python, though. Paul From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 4 07:26:00 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 04 Apr 2008 13:26:00 +0200 Subject: Is there an official way to add methods to an instance? In-Reply-To: <7xve2yas87.fsf@ruckus.brouhaha.com> References: <7xve2yas87.fsf@ruckus.brouhaha.com> Message-ID: <47f61041$0$27969$426a34cc@news.free.fr> Paul Rubin a ?crit : > Brian Vanderburg II writes: >> I've checked out some ways to get this to work. I want to be able to >> add a new function to an instance of an object. > > Ugh. Avoid that if you can. Why so ? OO is about objects, not classes, and adding methods on a per-object basis is perfectly legitimate. > But see: > > http://en.wikipedia.org/wiki/Monkey_patch Adding methods on a per-object basis is not monkey patching (as defined in the above article and as usually understood here) and doesn't address the same class (no pun intended) of problems. From manthra.mohan at gmail.com Fri Apr 18 11:48:36 2008 From: manthra.mohan at gmail.com (Krishna) Date: Fri, 18 Apr 2008 08:48:36 -0700 (PDT) Subject: Delete rows using xlrd? Message-ID: <8bc243c7-2980-4201-9372-94ca8a49d221@x19g2000prg.googlegroups.com> I want to delete some rows (by creating a loop may be) using xlrd. Is this possible, if not how do I do that with python? Please help Thanks Krishna From tjreedy at udel.edu Wed Apr 16 23:06:25 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 16 Apr 2008 23:06:25 -0400 Subject: Default parameter for a method References: <806788d2-67b7-456b-bd1e-08c50cbf0f7b@8g2000hsu.googlegroups.com> <48065d11$0$36390$742ec2ed@news.sonic.net> Message-ID: "John Nagle" wrote in message news:48065d11$0$36390$742ec2ed at news.sonic.net... | s0suk3 at gmail.com wrote: | > I wanted to know if there's any way to create a method that takes a | > default parameter, and that parameter's default value is the return | > value of another method of the same class. For example: | > | ... | | > | > def meth2(self, arg=meth1()): | | Not good. If the default value of an argument is mutable, there | are wierd effects, because the default value is bound once when the | class is created, then shared between all later uses. This is almost | never what was wanted or intended, and it's a common source of subtle | bugs. | | In general, default values should be immutable constants only. Then one would have to restrict default args to immutable builtins. There is no way to determine (without reading code) whether instances of a user-defined class are mutable or not. tjr From miki.tebeka at gmail.com Tue Apr 22 15:57:18 2008 From: miki.tebeka at gmail.com (Miki) Date: Tue, 22 Apr 2008 12:57:18 -0700 (PDT) Subject: Choosing log file destination in logging configuration file References: <3e85cd72-304e-4e17-8ca9-b0688a59fc14@t54g2000hsg.googlegroups.com> Message-ID: Hello, > So far so good. In the relevant applications, the code looks something > like this: > logging.config.fileConfig('log.ini') > logger = logging.getLogger('log.regular') logger = > logging.getLogger('log.daemonic') > .. and start logging. > > The thorn in my side is that after the fileConfig call, BOTH handlers > are instantiated, meaning both types of files are created for every > component, even if I don't need it: component.log (for the rotating > handler) and compenent.date.log (for the regular file handler). > > ..So finally, here's my question: > Apart from splitting the logging configuration into two separate > files, is there any way to NOT create the file until you actually use > it? You can generate the .ini file on the fly and then load it: >>> log_ini = gen_log_ini(type) # type is either "deamon" or "regular" >>> atexit.register(lambda: remove(log_ini)) >>> logging.config.fileConfig(log_ini) HTH, -- Miki http://pythonwise.blogspot.com From fiacre.patrick at gmail.com Sun Apr 20 02:54:35 2008 From: fiacre.patrick at gmail.com (Andrew Lee) Date: Sun, 20 Apr 2008 02:54:35 -0400 Subject: Checking if a text file is blank In-Reply-To: References: Message-ID: <480ae855$0$15157$607ed4bc@cv.net> elnoire at gmail.com wrote: > Greetings! > > I've just started learning python, so this is probably one of those > obvious questions newbies ask. > > Is there any way in python to check if a text file is blank? > > What I've tried to do so far is: > > f = file("friends.txt", "w") > if f.read() is True: > """do stuff""" > else: > """do other stuff""" > f.close() > > What I *mean* to do in the second line is to check if the text file is > not-blank. But apparently that's not the way to do it. > > Could someone set me straight please? Along with the other posts ... consider using the lstat command to get information about the file. import os print os.lstat("friends.txt")[6] gives the size in bytes of friends.txt or throws an OSError if friends.txt does not exist. lstat is portable, it defaults to stat on Windows. From reacocard at gmail.com Sun Apr 6 00:54:01 2008 From: reacocard at gmail.com (reacocard) Date: Sat, 5 Apr 2008 21:54:01 -0700 (PDT) Subject: httplib VERY slow References: <8486e357-1cab-4b30-a060-1750068929ac@1g2000prg.googlegroups.com> Message-ID: On Apr 5, 8:50?pm, reacocard wrote: > Hi, I'm writing a download manager in python, and httplib is being > very slow when pulling from localhost or even other servers on the > local network. I'm getting about 10MB in 14s with httplib, while wget > hits 80MB in less than 3s. You can find the code I made to benchmark > this here:http://pastebin.ca/973486(noslor is mapped to my IP in / > etc/hosts) > > Does anyone have any idea what might be causing this, and how I can > fix it? I'm using python2.5 under Ubuntu Linux 8.04 with apache2 for > the webserver. > > Thanks in advance. Upon further investigation, the slowness appears to be related to this bug report: http://bugs.python.org/issue508157 Applying the fix given in the bug report speeds up httplib immensely. So now the question becomes, what is the best way to implement this? Should I go ahead and subclass most of httplib, or is there an easier way? From mnordhoff at mattnordhoff.com Tue Apr 22 20:33:56 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Wed, 23 Apr 2008 00:33:56 +0000 Subject: Lists: why is this behavior different for index and slice assignments? In-Reply-To: <480e7f61$0$25046$607ed4bc@cv.net> References: <480d435b$0$11643$607ed4bc@cv.net> <480e7f61$0$25046$607ed4bc@cv.net> Message-ID: <480E83F4.6040500@mattnordhoff.com> John Salerno wrote: >> replaces the elements in the slice by assigned elements. > > > I don't understand the second part of that sentence. I'm assuming "it" > refers to the list being assigned, "replaces the elements" is > self-evident, but what does "by assigned elements" refer to? It seems > when you assign a list to a list slice, nothing gets replaced, the slice > just gets deleted. >>> x = range(5) >>> x[0:3] = ["a", "b"] >>> x ['a', 'b', 3, 4] Here, '= ["a", "b"]' replaces x[0:3] with ["a", "b"]. When you do '= []', it replaces them with nothing. -- From gagsl-py2 at yahoo.com.ar Tue Apr 1 14:04:55 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 15:04:55 -0300 Subject: manipulating hex values References: <47F26CC3.3060307@u4eatech.com> Message-ID: En Tue, 01 Apr 2008 14:11:31 -0300, Stephen Cattaneo escribi?: > I am relatively new to socket programming. I am attempting to use raw > sockets to spoof my IP address. Don't bother to try... > From what I can tell I will have to > build from the Ethernet layer on up. This is fine, but I am having > some trouble with manipulating my hex values. > > Seems to me that there are two ways to store hex values: > 1. as literal hex - 0x55aa > 2. as a string - "\x55aa" The later is exactly the same string as "Uaa": py> print "\x55aa" Uaa > If I want to convert hex to decimal I can use: > int("\x55aa", 16) # note that plain 0x55aa, instead of "\x55aa", will > raise an exception Have you tried it? py> int("\x55aa", 16) Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 16: 'Uaa' py> int("0x55aa", 16) 21930 > The Question: > If I want to do any kind of calculation I have found its best to just > convert my values to decimal, do the math, then convert back to hex. In > my bellow code I get "decimal" and "hex" are just ways to represent/display integers. You convert from the representation used on the source, to integer, do some math, and convert again to another representation for display/store the result. > """byteList.append(int(value,16)) > ValueError: invalid literal for int()""" > when attempting to run. I do not understand why this exception is > being raised? It is a for loop iterating over a list of hex strings. > Sorry for the long-ish question. Any help or comments would be > appreciated. Use the struct package. -- Gabriel Genellina From ellingt8877 at gmail.com Mon Apr 28 01:44:55 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:44:55 -0700 (PDT) Subject: fsuipc crack Message-ID: fsuipc crack http://crack.cracksofts.com From zillow10 at googlemail.com Wed Apr 2 09:56:44 2008 From: zillow10 at googlemail.com (zillow10 at googlemail.com) Date: Wed, 2 Apr 2008 06:56:44 -0700 (PDT) Subject: developing web spider References: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> <30a89852-4730-490b-8701-b915cb0901ce@q27g2000prf.googlegroups.com> Message-ID: On Apr 2, 2:54 pm, zillo... at googlemail.com wrote: > On Apr 2, 6:37 am, abeen wrote: > > > Hello, > > > I would want to know which could be the best programming language for > > developing web spider. > > More information about the spider, much better,, > > > thanks > > >http://www.imavista.com > > Just saw this while passing by... There's a nice book by Michael > Schrenk (www.schrenk.com) called "Webbots, Spiders and Screen > Scrapers" that teaches scraping and spidering from the ground up using > PHP. Since you said you want more info on spiders, this book might be > a good way for you to acquire concept and implementation hand-in-hand. > He's also developed a nice webbot library in PHP that you can get from > his website. > > Also comes with a nice webbot library (which you can download from > the website anyway). Sorry for the duplicate comment about the webbot library... the perils of cutting and pasting to restructure sentences. :) From bc1891 at googlemail.com Wed Apr 2 16:23:58 2008 From: bc1891 at googlemail.com (bc1891 at googlemail.com) Date: Wed, 2 Apr 2008 13:23:58 -0700 (PDT) Subject: Recursive function won't compile Message-ID: #include #include def RecursiveFact(n): if(n>1): return n*RecursiveFact(n-1) else: return 1 fact = RecursiveFact(31) print fact fact = "End of program" print fact ......but yet it still gives the right answer. How is this possible? From roy at panix.com Sun Apr 13 08:23:22 2008 From: roy at panix.com (Roy Smith) Date: Sun, 13 Apr 2008 08:23:22 -0400 Subject: from __future__ import print References: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> Message-ID: In article , Lie wrote: > I wish py3k > would make it an option whether to treat print as statement or > function though. Arrrgghhhhh! No, don't even go there. If you want optional parens, use Perl :-) From deets at nospam.web.de Wed Apr 16 09:15:08 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 16 Apr 2008 15:15:08 +0200 Subject: Serving binary content (images, etc) using BasteHTTPServer References: <556871d3-1fea-40f2-9cc6-2a4e3a80f968@k10g2000prm.googlegroups.com> Message-ID: <66mcfoF2lat6uU2@mid.uni-berlin.de> MarkCSU at gmail.com wrote: > I'm writing a simple web server in python using the BaseHTTPServer > library. I can serve text content (ie html pages) with ease, but im > running into troubles when i try to serve images. The image gets > corrupted in transit and when I manually download the image from the > website and look at it using a hex editor it appears that the first 60 > (or first 3C in hex if it makes a helps) characters are missing. > > > My code looks like this: > > def do_GET(s): > > # code that determines that yes this is an image > > s.send_response(200) > s.send_header("Content-type", "image/jpeg") > s.end_headers > > fileObj = open("1.jpg","rb") # file is harcoded until > i get images being served correctly > image = fileObj.read() > s.wfile.write(image) Don't you miss a Content-Length header? Diez From deets at nospam.web.de Mon Apr 21 09:53:09 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Mon, 21 Apr 2008 15:53:09 +0200 Subject: how to pass C++ object to another C++ function via Python function References: <1810b155-5598-4f17-a8e9-e4aa848db5de@i36g2000prf.googlegroups.com> Message-ID: <673kj1F2msp6jU1@mid.uni-berlin.de> grbgooglefan wrote: > I am trying to pass a C++ object to Python function. This Python > function then calls another C++ function which then uses this C++ > object to call methods of that object's class. You might consider using a C++-wrapper like SIP, Swig or Boost::Python to do this. If you don't like that, all I can think of would be to return the address of the object as integer, and pass that around. Then in the appropriate C++-call, cast that integer to the object. butt-ugly and -10 style-points though. Diez From skanemupp at yahoo.se Thu Apr 10 08:40:42 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 05:40:42 -0700 (PDT) Subject: questions about Exceptions? References: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> <71cc8c25-f5f9-4f21-a9d8-06780bf97608@f63g2000hsf.googlegroups.com> <9af81b1a-3e02-4406-b9d2-0a9b6f46566b@p39g2000prm.googlegroups.com> <0e586d5d-6799-433f-b8a4-4de5d2a87b61@h1g2000prh.googlegroups.com> <46a79564-4069-46af-b6ab-b38bd9152c2a@d45g2000hsc.googlegroups.com> Message-ID: <6b41831d-7510-49fa-97f5-8034613afa00@w4g2000prd.googlegroups.com> On 10 Apr, 12:38, cokofree... at gmail.com wrote: > > def Calc(): > > global nbr > > try: > > print eval(nbr) > > #a = Label(mygui, text=eval(nbr)) > > #a.place(relx=0.4, rely=0.1, anchor=CENTER) > > except: > > print "Not computable" > > nbr = "" > > > def Erase(): > > global nbr > > nbr = "" > > Seems to me you could be better off passing a parameter and a return > statement of None (or your parameter cleaned) for those functions, > which should work. Given an input, Eval it and then return None. That > way you wouldn't need the Erase... i never really got what u meant by this? From meisnernel73884 at gmail.com Wed Apr 30 06:37:35 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:37:35 -0700 (PDT) Subject: vws crack Message-ID: vws crack http://crack.cracksofts.com From mobile at ibinsa.com Fri Apr 18 17:23:42 2008 From: mobile at ibinsa.com (Gabriel Ibanez) Date: Fri, 18 Apr 2008 23:23:42 +0200 Subject: Upset of spamming ... Message-ID: <002801c8a19a$7a145ed0$0a01a8c0@mobile> Very upset. Really ugly. If anyone have an idea of how stops this thing with python programming I will be glad of contributing. :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg at cosc.canterbury.ac.nz Sun Apr 6 18:37:56 2008 From: greg at cosc.canterbury.ac.nz (greg) Date: Mon, 07 Apr 2008 10:37:56 +1200 Subject: why does socket.makefile require non-blocking mode? In-Reply-To: References: Message-ID: <47F950C4.6010104@cosc.canterbury.ac.nz> Forest wrote: > I guess you mean that since _fileobject.read() calls recv() multiple > times, the second and later calls might block even if select() said the > socket was > readable. The main problem is buffering. The select() may block on the socket even though the file object has data in its buffer waiting to be read. When using select(), you really need to deal with the socket directly, with no buffering in the way. -- Greg From usenet at janc.be Wed Apr 2 14:29:55 2008 From: usenet at janc.be (Jan Claeys) Date: Wed, 02 Apr 2008 18:29:55 GMT Subject: License of Python References: <683e7a60-1967-4c95-b66f-e80a5f4f0116@e6g2000prf.googlegroups.com> <5feb7205-e852-401c-aac2-61ff3d1601ca@i12g2000prf.googlegroups.com> Message-ID: Op Sun, 30 Mar 2008 08:16:39 -0700, schreef iu2: > Due to Competitors... I don't want to expost the language I use If they are clever, they already know that you want to use python by now, after you posted this on a public mailing list / newsgroup... -- JanC From danb_83 at yahoo.com Tue Apr 15 00:08:26 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Mon, 14 Apr 2008 21:08:26 -0700 (PDT) Subject: how to remove \n in the list References: <2ba667ab-6818-47eb-8595-79ed970728f7@q1g2000prf.googlegroups.com> Message-ID: On Apr 14, 10:55 pm, Yves Dorfsman wrote: > Gabriel Genellina wrote: > > En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam > >> l=['5\n', '2\n', '7\n', '3\n', '6\n'] > > >> how to remove \n from the given list > > > l is is very poor name... I'll use lines instead: > > > lines[:] = [line.rstrip('\n') for line in lines] > > When I saw the original message, I immediately thought: > > k = [x.strip() for x in l] > > What is the point of the [:] after lines ? How different is it with or > without it ? It causes the result to be stored in the existing list. >>> a = [0, 1, 2, 3, 4] >>> b = a # "a" and "b" now refer to the same list >>> a = [5, 6, 7] # "a" now refers to a new list >>> a [5, 6, 7] >>> b [0, 1, 2, 3, 4] >>> a = [0, 1, 2, 3, 4] >>> b = a # As before, "a" and "b" refers to the same list >>> a[:] = [5, 6, 7] # This replaces the elements of the list with new ones. # "a" still refers to the same list as "b". >>> a [5, 6, 7] >>> b [5, 6, 7] From nagle at animats.com Thu Apr 3 01:27:00 2008 From: nagle at animats.com (John Nagle) Date: Wed, 02 Apr 2008 22:27:00 -0700 Subject: Rationale for read-only property of co_code In-Reply-To: References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> Message-ID: <47f4682c$0$36371$742ec2ed@news.sonic.net> Dan Upton wrote: >> The thing I've been wondering is why _is_ it read-only? In what >> circumstances having write access to co_code would break the language >> or do some other nasty stuff? >> >> Jo?o Neves > > I can't speak to Python's implementation in particular, but > self-modifying code in general is unpleasant. Yes. Self-modifying code has a long and painful history. It's sometimes useful to generate and execute code dynamically, but that's different than modifying running code. Python already has "eval", plus the ability to compile and include new code at run time, so the useful facilities are already working. John Nagle From http Thu Apr 24 14:34:20 2008 From: http (Paul Rubin) Date: 24 Apr 2008 11:34:20 -0700 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> <480fa6e3$0$34491$742ec2ed@news.sonic.net> Message-ID: <7xzlrj14r7.fsf@ruckus.brouhaha.com> Paul Boddie writes: > simple Python-only modules, all you'd really need to do to prove the > concept is to develop the client-side Windows software (eg. apt-get > for Windows) which downloads package lists, verifies signatures, and > works out where to put the package contents. ... I thought the Windows "solution" to this was Authenticode, which is a scheme for signing executables against certificates similar to those used on SSL web sites. Of course there's been at least one notorious forgery, but typical Linux distro repositories are probably not all that secure either. In the case of a pure Python program like Beautiful Soup, I certainly think any installation needing running code should be done by distutils included in the Python distro. From john106henry at hotmail.com Mon Apr 28 15:41:16 2008 From: john106henry at hotmail.com (John Henry) Date: Mon, 28 Apr 2008 12:41:16 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> Message-ID: <473deef3-9acb-45dd-a7ca-47b0081bd28c@i36g2000prf.googlegroups.com> On Apr 27, 12:23 pm, Fred Pacquier wrote: > > Do keep us posted ! > > TIA, > fp Check it out now. Only one to be added is the Multicolumn List (table), and then menus. The other widgets (Togglebutton, BitmapCanvas, Gauge, Notebook, CodeEditor) will not be implemented initially. http://test.powersystemadvisors.com From carbanancizpo at gmail.com Fri Apr 18 16:56:37 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:56:37 -0700 (PDT) Subject: iron on canvas patch Message-ID: <0ebe94bc-4c87-4b08-b49b-db6c12a7646d@a23g2000hsc.googlegroups.com> iron on canvas patch http://cracks.12w.net F R E E C R A C K S From ivory91044 at gmail.com Tue Apr 29 04:58:06 2008 From: ivory91044 at gmail.com (ivory91044 at gmail.com) Date: Tue, 29 Apr 2008 01:58:06 -0700 (PDT) Subject: autocad crack Message-ID: autocad crack http://crack.cracksofts.com From gagsl-py2 at yahoo.com.ar Tue Apr 29 00:02:32 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 29 Apr 2008 01:02:32 -0300 Subject: cytpes **int References: <56674130-c04e-403e-8364-92cbd158b2f0@b9g2000prh.googlegroups.com> <67mveuF2pauigU1@mid.uni-berlin.de> Message-ID: En Mon, 28 Apr 2008 18:55:15 -0300, Diez B. Roggisch escribi?: > VernM schrieb: >> I am using ctypes to wrap a set of functions in a DLL. It has been >> going very well, and I am very impressed with ctypes. I want to call a >> c function with a signature of: void func(int **cube), where the array >> if ints in cube is modified by func. I want to setup cube with int >> values, and access them after the call to func. I unerstand how to >> setup the ctypes array, but how do I pass **cube to the function, and >> how do I access the results? > > it should be simple. > > use something like (untestet): > > b = POINTER(c_int)() > func(byref(b)) [snip two other similar alternatives] That's true for "a pointer to a pointer to int", and it's valid if the functions references **b or b[0][0] - but in this case int** probably means "[pointer to] an array of arrays of int" and presumibly the function will try to access b[3][2] (or whatever indices are in range). The duality pointer/array in C is dangerous when defining interfases - you have to know how the value is intended to be accessed. (I assume the function modifies the integer values, but not the pointers themselves) # build an array of 10x10 ints Arr10int = c_int * 10 Pint = POINTER(c_int) PPint = POINTER(Pint) Arr10pint = Pint * 10 a = Arr10pint() for i in range(10): a[i] = Arr10int() ... initialize the array ... ... load the function ... # call the function somefunction.argtypes = (PPint,) somefunction.restype = None somefunction(a) -- Gabriel Genellina From ch612bunn at gmail.com Sun Apr 27 09:17:51 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:17:51 -0700 (PDT) Subject: kaspersky internet security 7 crack Message-ID: kaspersky internet security 7 crack http://wga-cracks.crackkey.net From bob.martin at excite.com Mon Apr 14 03:21:48 2008 From: bob.martin at excite.com (Bob Martin) Date: Mon, 14 Apr 2008 07:21:48 GMT Subject: Java or C++? References: Message-ID: in 342367 20080414 074410 s0suk3 at gmail.com wrote: >Hello, I was hoping to get some opinions on a subject. I've been >programming Python for almost two years now. Recently I learned Perl, >but frankly I'm not very comfortable with it. Now I want to move on >two either Java or C++, but I'm not sure which. Which one do you think >is a softer transition for a Python programmer? Which one do you think >will educate me the best? C++ is for masochists. Go for Java. From john00587 at gmail.com Mon Apr 21 01:43:37 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:43:37 -0700 (PDT) Subject: revit 9 keygen Message-ID: <4ff8fc5d-70a4-4c8f-b8ed-cb279807bde7@y18g2000pre.googlegroups.com> revit 9 keygen http://cracks.00bp.com F R E E C R A C K S From tdimson at gmail.com Thu Apr 10 16:41:53 2008 From: tdimson at gmail.com (Thomas Dimson) Date: Thu, 10 Apr 2008 13:41:53 -0700 (PDT) Subject: subprocess.Popen() output to logging.StreamHandler() References: <6b02e27c-916f-42a7-b2e0-75af51bba343@h1g2000prh.googlegroups.com> Message-ID: On Apr 10, 3:05?pm, svensven wrote: > Vinay Sajip wrote: > > ?> On Apr 10, 1:11 pm, "sven _" wrote: > ?>> My goal is to have stdout and stderr written to a logginghandler. > ?> > ?> Thomas was almost right, but not quite - you can't call info on a > ?> Handler instance, only on a Logger instance. The following script: > > Yes, but that was easily fixed. Still there seemed to be a problem > there with the .poll(), since it would think the process ended while > it was actually running. The result was that only some of the command > output was shown. > > ?> import logging > ?> import subprocess > ?> > ?> logging.basicConfig(level=logging.INFO) # will log to stderr of this > ?> script > ?> > ?> s = subprocess.Popen( ['ls','-la'], stdout=subprocess.PIPE ) > ?> while 1: > ?> ? ? line = s.stdout.readline() > ?> ? ? exitcode = s.poll() > ?> ? ? if (not line) and (exitcode is not None): > ?> ? break > ?> ? ? line = line[:-1] > ?> ? ? logging.info("%s", line) > > This works perfectly, as far as I can tell. You seem to use another > conditional, though. > > I'll take a closer look at this tomorrow. Thanks for the clean > solution, Vinay. > > sven I think what I actually meant was: s = subprocess.Popen( ['ls','-la'], stdout=subprocess.PIPE ) while 1: line = s.stdout.readline() if not line: break logging.info( line ) The problem with p.poll() is that the process probably has ended before you have gotten all the text out of the buffer. Readline will return a falsy value when the process ends. Anyway, this post has a lot of responses so I'm sure _something_ works :) From maxm at mxm.dk Fri Apr 25 07:02:50 2008 From: maxm at mxm.dk (Max M) Date: Fri, 25 Apr 2008 13:02:50 +0200 Subject: Little novice program written in Python In-Reply-To: References: Message-ID: Rog?rio Brito skrev: > Hi, All. > > What I would like is to receive some criticism to my code to make it > more Python'esque and, possibly, use the resources of the computer in a > more efficient way (the algorithm implemented below is the Sieve of > Eratosthenes): I agree with the rest here. Your code generally looks fine. But on another note, this type of code is not something you often see in Python. It is very dense with regard to algorithm. Most code is not like that so perhaps you should try something more "usual" like sending email, fetching webpages etc. to get a feel for the language. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science From bronger at physik.rwth-aachen.de Wed Apr 16 02:38:03 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 16 Apr 2008 08:38:03 +0200 Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> <47ffee86$0$6838$2d805a3e@textnews.eweka.nl> <15e5c81b-0b21-44f0-9282-0d1495bc6bb3@z24g2000prf.googlegroups.com> <480011b7$0$28883$c83e3ef6@nn1-read.tele2.net> Message-ID: <87od8amhis.fsf@physik.rwth-aachen.de> Hall?chen! Joe P. Cool writes: > On 12 Apr., 03:34, baalbek wrote: > >> Delphi/Object Pascal simply sucks big time! > > I disagree. Delphi/Object Pascal with the VCL (Visual Component > Library) is one of the most sophisticated IDEs ever, even better > than Qt IMO. [...] I was somewhat disappointed with Delphi. I had used Turbo Pascal 15 years ago, which was one of the best IDEs at that time. It was really good. Now, we use Delphi in our institute for measurement and automation applications with GUI. It is probably possible to work equally well with Delphi, however, none of us have found the right IDE settings for this yet. Especially the behaviour after runtime errors seems to be unpredictable to us, and it is mostly sub-optimal. After having tested most of the dozens of checkboxes I could improve the situation slightly but not more. As far as the GUI composing is concerned, this is great with Delphi, especially for beginners. However, I still prefer the text-only programming in e.g. wxPython (and I'm equally fast with it) but this is a matter of taste. It's like the Word vs LaTeX or Gnuplot vs Origin thing I suppose. All of us were utterly disappointed with the new help system. This used to be a stronghold in Borland products but now, you get explanations ? la "Method 'foo': do foo with the object". Super. > [...] > > Wrong. It does have a GUI builder - a very good one - and you can > do point and click creation of GUIs (nothing wrong with that) but > you can also do pure text editor code only programming with it. This shows another disadvantage of such IDEs, namely the editor question. The editor is a very personal piece of software, and I ended up using Emacs for a lot of my Delphi work. I don't consider myself a religious Emacs user -- I was really faster this way. However, this throws away a lot of the IDE's advantages. Thus, having everything in one system is only a good idea if you do Delpi-only. >> (did anyone mention waste of one's life?), and don't get me >> started on that primitive, complete utter waste of language >> called Object Pascal! > > I'm no big Pascal fan either but Object Pascal has a decent string > library and better container literals than C/C++ and Java. The > language itself is a matter of taste and I don't waste my time > discussing it. Well, there also are objective issues with it that *can* be discussed. You mentioned the string library. This is what caused a lot of headaches here. There is a *lot* of doubled functionality there because there seems to be a transition in Delphi from old to new string functions. The difference between Wide Strings and AnsiStrings is still obscure to me. In .NET Delphi, this seems to have been cleaned up, but I haven't used it. >> Python/wxPython/Glade == real programmer's toolkit >> Object Pascal/Delphi == the hobbyist/beginner's toolkit > > I'm pretty sure that there are more professional software products > written in Delphi than in wxPython. Certainly. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From robert.kern at gmail.com Fri Apr 11 13:51:14 2008 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 11 Apr 2008 12:51:14 -0500 Subject: Graphs in Python In-Reply-To: References: <531651.98983.qm@web55601.mail.re4.yahoo.com> Message-ID: Henry Chang wrote: > Try Google Chart with python wrapper: > > http://pygooglechart.slowchop.com/ > > http://code.google.com/apis/chart/ Wrong kind of graph. -- 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 From toby at tobiah.org Wed Apr 23 15:17:06 2008 From: toby at tobiah.org (Tobiah) Date: Wed, 23 Apr 2008 12:17:06 -0700 Subject: Calling Python code from inside php References: <679e9oF2mti63U1@mid.uni-berlin.de> Message-ID: On Wed, 23 Apr 2008 20:42:44 +0200, Diez B. Roggisch wrote: > vijay schrieb: >> Hi >> I have a python code performing some computation for me.I have a >> html page which passes certain argumnets to a php page.This php page >> needs to pass on the value to the Python class and get the result >> back. >> How do I go about this?? I do this quite a bit: &1"; $p = popen($command, 'r'); $output = fread($p, 1024 * 1024); print $output; ?> ** Posted from http://www.teranews.com ** From jr9445 at ATT.COM Wed Apr 9 17:23:30 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Wed, 9 Apr 2008 16:23:30 -0500 Subject: basic python question about for loop In-Reply-To: References: Message-ID: > -----Original Message----- > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > list-bounces+jr9445=att.com at python.org] On Behalf Of jmDesktop > Sent: Wednesday, April 09, 2008 5:04 PM > To: python-list at python.org > Subject: Re: basic python question about for loop > > > > > > >>> for n in range(2, 10): > > > ... ? ? for x in range(2, n): > > > ... ? ? ? ? if n % x == 0: > > > ... ? ? ? ? ? ? print n, 'equals', x, '*', n/x > > > ... ? ? ? ? ? ? break > > > ... ? ? else: > > > ... ? ? ? ? # loop fell through without finding a factor > > > ... ? ? ? ? print n, 'is a prime number' > > > ... > > > > > first time 2 mod 2, 2/2, no remainder == 0, what am I doing wrong? > > > Why did it fall through? > > > > So what is n and x in the first iteration? Sorry. I'm trying. You're never getting to n and x in the first iteration, because the 'for x in range(2, n)' loop isn't looping. This: for x in range(2, n) is equivalent in C/Perl/etc. to: for(x=2; x This is a contrived pseudocode example which has been broken out of a larger problem, so it may seem like a strange thing to want to do, but... I have a group of objects which inherit (single) from a common base class like so: --- class Root(object): @classmethod def CumulativeScore(cls, arg): #Ask every child class to #generate a score and add #them together cumulativescore = 0 for base in cls.mro(): cumulativescore += base.Score(arg) return cumulativescore #No Score method defined in Root so don't try to call one! class BranchChild(Root): @classmethod def Score(cls, arg): return 1 class LeafChild(BranchChild): @classmethod def Score(cls, arg): return 3 class LeafChild2(BranchChild): pass #No Score method defined here, either! --- The goal is to be able to call CumulativeScore(arg) on an instance of any of these objects (Root, Branch or Leaf) which will then chain calls (top down) to each subclass' Score method if (and only if) one is defined, returning the sum of all of these calls. Kinda like constructor chaining, only I don't want it to be explicit/cooperative because super() doesn't seem to work in classmethods and I want to reduce the amount of redundant boilerplate code in the subclasses (which will be numerous). In order to do this I really need a way to ask LeafChild to give me *its* Score method *if* it has one of its own. I don't want its parent's method or its grandparent's method (until I get to them of course), just the one that's (optionally) defined in LeafChild, so getattr() and __dict__ are of no use to me. The only thing I've been able to find that actually works is inspect.classify_class_attrs(). While it delivers the expected behavior, classify_class_attrs spews out a ton of superfluous information which I have to parse myself, and the method objects it returns in its tuples are not callable to boot. This leads to ugly looking code like this: --- @classmethod def CumulativeScore(cls, arg): cumulativescore = 0 mro = list(cls.mro()) mro.reverse() for base in mro: matchfunc = [getattr(base, "Score") for attr in inspect.classify_class_attrs(base) if attr[0] == "Score" and attr[2] == base] if len(matchfunc) == 1: cumulativescore += matchfunc[0](arg) return cumulativescore --- In looking through the inspect module's documentation, it seems as though getmembers() once offered the functionality I require, but no longer: "Changed in version 2.2: im_class used to refer to the class that defined the method." I've gotten the feeling from the Python documentation that classmethods are seen as third-class citizens, but they are unfortunately perfect for my needs, and it doesn't seem like this should be as complicated as it is. Is there a simpler, more elegant way to ask a class object if it has a particular method definition that I've missed somewhere? If not, why can't classify_class_attrs at least return a callable method object for me (yes, I've read the "unifying" paper)? Thanks! From code at pizzashack.org Wed Apr 2 16:28:41 2008 From: code at pizzashack.org (Derek Martin) Date: Wed, 2 Apr 2008 16:28:41 -0400 Subject: Manipulate Large Binary Files In-Reply-To: <9999810b0804021109n77f2c990p7b10d92e9344ad00@mail.gmail.com> References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> <9999810b0804021109n77f2c990p7b10d92e9344ad00@mail.gmail.com> Message-ID: <20080402202841.GC22737@dragontoe.org> On Wed, Apr 02, 2008 at 02:09:45PM -0400, Derek Tracy wrote: > Both are clocking in at the same time (1m 5sec for 2.6Gb), are there > any ways I can optimize either solution? Buy faster disks? How long do you expect it to take? At 65s, you're already reading/writing 2.6GB at a sustained transfer rate of about 42.6 MB/s. That's nothing to sneeze at... Your disks, and not your program, are almost certainly the real bottleneck. Unless you have reason to believe your hardware should be significantly faster... That said, due to normal I/O generally involving double-buffering, you might be able to speed things up noticably by using Memory-Mapped I/O (MMIO). It depends on whether or not the implementation of the Python things you're using already use MMIO under the hood, and whether or not MMIO happens to be broken in your OS. :) > Would turning off the read/write buff increase speed? No... -- Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0x81CFE75D -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available URL: From george.sakkis at gmail.com Wed Apr 2 19:19:12 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 2 Apr 2008 16:19:12 -0700 (PDT) Subject: Recursive function won't compile References: <65iafeF2g9cvvU1@mid.uni-berlin.de> Message-ID: On Apr 2, 5:00 pm, "Diez B. Roggisch" wrote: > bc1... at googlemail.com schrieb: > > > > > #include > > #include > > > def RecursiveFact(n): > > if(n>1): > > return n*RecursiveFact(n-1) > > else: > > return 1 > > > fact = RecursiveFact(31) > > print fact > > > fact = "End of program" > > print fact > > > ......but yet it still gives the right answer. How is this possible? > > Given that you obviously don't use python, but some weird cross-breed > beteween python and C - who are we to judge the semantics of that chimera? > > Diez Seems like a bad belated April Fool's day joke to me. George From james at reggieband.com Thu Apr 17 17:59:14 2008 From: james at reggieband.com (james at reggieband.com) Date: Thu, 17 Apr 2008 14:59:14 -0700 (PDT) Subject: Request a short code review Message-ID: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> Hi all, I am moving my server based scripting over to Python and I am attempting to write more idiomatic python. I have 8 years professional programming experience and I am looking to get to a very high standard of python coding. As such, I was wondering if it was appropriate to post code snippets I am not 100% happy with in order to find a more elegant python way for coding. Here is a method I came across that I would like to clean up: def output_random_lesson_of_type(self, type=None): """Output a lesson of a specific type - if no type is passed in then output any type.""" if type: filtered_lessons = filter(lambda x: x["type"] == type, self.lesson_data["lessons"]) if filtered_lessons: lesson = self.output_random(filtered_lessons) else: print "Unable to find lessons of type %s." % type else: lesson = self.output_random(self.lesson_data["lessons"]) return lesson Where 'type' is a string, and 'self.lesson_data["lessons"]' is an array of dictionaries where each item is guaranteed to have string value with a key 'type' I am not necessarily looking to make the code shorter or more functional or anything in particular. However if you spot something to improve then I am happy to learn. Any and all comments appreciated. Cheers, James. From nick at craig-wood.com Wed Apr 23 05:30:04 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Wed, 23 Apr 2008 04:30:04 -0500 Subject: subprocess module is sorely deficient? References: Message-ID: Mike Hansen wrote: > > I think the best solution would be to port Pexpect to windows which > > wouldn't be that difficult according to my reading of the code. If > > only I had more free time! > > Sage ( http://www.sagemath.org ) uses pexpect fairly extensively to > interface with all sorts of other systems. We recently received > funding from Microsoft to do a native port of Sage (and all of its > components to Windows. Part of this will most likely be a port of > pexpect to Windows. Hooray! -- Nick Craig-Wood -- http://www.craig-wood.com/nick From ijoshua at gmail.com Sun Apr 6 11:19:38 2008 From: ijoshua at gmail.com (ijoshua) Date: Sun, 6 Apr 2008 08:19:38 -0700 (PDT) Subject: Is there any way to say ignore case with "in"? References: <47f692f3$0$759$bed64819@news.gradwell.net> <432d690f-44be-49a9-bc6a-1cf3445549d6@m71g2000hse.googlegroups.com> Message-ID: <012dfbc3-858b-4ffa-8c2a-4164496d826b@8g2000hse.googlegroups.com> On Apr 5, 7:14?am, Steve Holden wrote: > 7stud wrote: > > > Easier? ?You mean like some kind of mind meld? > > That's right, DWIM mode Python. Rock on! If it is common enough, define a custom type of string. I have appended a simple version that should work for your example of `in`. You would probably want to define all of the builtin str methods for this class to be really useful. Regards, Josh --- # cistr.py import operator class cistr(object): """A type of string that ignores character case for the right side of the `in` operator. >>> 'AND' in cistr('sPaM aNd eGgS') True """ def __init__(self, string): self.string = str(string).lower() def __contains__(self, other): return operator.contains(self.string, other.lower()) def __repr__(self): return 'cistr(%r)'%(self.string) def lower(self): return self.string if '__main__' == __name__: string1 = 'AND' string2 = 'sPaM aNd eGgS' print '%r in %r ? %r' % (string1, string2, string1 in string2) print '%r in %r ? %r' % (string1, cistr(string2), string1 in cistr(string2)) From gagsl-py2 at yahoo.com.ar Sun Apr 6 03:13:41 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 06 Apr 2008 04:13:41 -0300 Subject: Python Data Utils References: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> Message-ID: En Sun, 06 Apr 2008 01:43:29 -0300, Jesse Aldridge escribi?: > In an effort to experiment with open source, I put a couple of my > utility files up here. What do you think? Some names are a bit obscure - "universify"? Docstrings would help too, and blank lines, and in general following PEP8 style guide. find_string is a much slower version of the find method of string objects, same for find_string_last, contains and others. And I don't see what you gain from things like: def count( s, sub ): return s.count( sub ) it's slower and harder to read (because one has to *know* what S.count does). Other functions may be useful but without even a docstring it's hard to tell what they do. delete_string, as a function, looks like it should delete some string, not return a character; I'd use a string constant DELETE_CHAR, or just DEL, it's name in ASCII. In general, None should be compared using `is` instead of `==`, and instead of `type(x) is type(0)` or `type(x) == type(0)` I'd use `isinstance(x, int)` (unless you use Python 2.1 or older, int, float, str, list... are types themselves) Files.py is similar - a lot of more or less common things with a different name, and a few wheels reinvented :) Don't feel bad, but I would not use those modules because there is no net gain, and even a loss in legibility. If you develop your code alone, that's fine, you know what you wrote and can use it whenever you please. But for others to use it, it means that they have to learn new ways to say the same old thing. -- Gabriel Genellina From grante at visi.com Thu Apr 17 09:55:05 2008 From: grante at visi.com (Grant Edwards) Date: Thu, 17 Apr 2008 08:55:05 -0500 Subject: Finally had to plonk google gorups. References: Message-ID: On 2008-04-17, Dennis Lee Bieber wrote: > On Wed, 16 Apr 2008 09:19:37 -0500, Grant Edwards > declaimed the following in comp.lang.python: > >> I broke down and joined all the other people that just killfile >> everything posted via google.groups. > > Unfortunately, that is the one weak point in Agent... Usenet > kill filters only take subject or author fields... Sound like a good reason to hack on Agent so that you can kill based on any header you want. > I suspect they try to apply them when fetching headers before > downloading the messages and don't have other fields > available... > > So... given the recent batch... My next best was to kill on > @gmail... That's the one big reason I've not switched over to using my gmail address. I'm thinking I should register my own domain and have it forward to my gmail address. That way I get all the free storage (and web access) on gmail's imap server without the stigma of using a gmail.com address. -- Grant Edwards grante Yow! I joined scientology at at a garage sale!! visi.com From mattheww at chiark.greenend.org.uk Wed Apr 16 17:31:52 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 16 Apr 2008 22:31:52 +0100 (BST) Subject: How to have unittest tests to be executed in the order they appear? References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> <87zlru7le2.fsf@benfinney.id.au> Message-ID: Ben Finney wrote: >"Giampaolo Rodola'" writes: >> Is there a way to force unittest to run test methods in the order >> they appear? > No, and this is a good thing. > Your test cases should *not* depend on any state from other test > cases; they should function equally well when executed in any > arbitrary sequence. Dependencies between separate test cases (e.g. > "they only work correctly when run in a specific sequence") means > you're not isolating them properly. So a mode to randomise the test sequence would be nice to have. Unittest's behaviour (using alphabetical order) doesn't really help to detect undesired dependencies (which might be bugs in the test suite or bugs in the underlying code). But running tests in the order they appear is often helpful: you can put the tests for basic stuff before the tests for advanced stuff, and then if you suddenly get seventeen failing tests, you know that the first failure is the best bet to investigate first. -M- From sierra9162 at gmail.com Wed Apr 16 11:20:56 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:20:56 -0700 (PDT) Subject: kate hudson wallpapers Message-ID: <6011c411-7fce-4d77-a7eb-55b1536712df@a23g2000hsc.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From larry.bates at websafe.com` Fri Apr 18 12:24:01 2008 From: larry.bates at websafe.com` (Larry Bates) Date: Fri, 18 Apr 2008 11:24:01 -0500 Subject: Installing BeautifulSoup with easy_install (broken?) In-Reply-To: <66rvkdF2kqa1lU1@mid.uni-berlin.de> References: <66rvkdF2kqa1lU1@mid.uni-berlin.de> Message-ID: Diez B. Roggisch wrote: > Larry Bates schrieb: >> Info: >> >> Python version: ActivePython 2.5.1.1 >> Platform: Windows >> >> I wanted to install BeautifulSoup today for a small project and >> decided to use easy_install. I can install other packages just fine. >> Unfortunately I get the following error from BeautifulSoup >> installation attempt: >> >> C:\Python25\Lib\SITE-P~1>easy_install BeautifulSoup >> Searching for BeautifulSoup >> Reading http://pypi.python.org/simple/BeautifulSoup/ >> Reading http://www.crummy.com/software/BeautifulSoup/ >> Reading http://www.crummy.com/software/BeautifulSoup/download/ >> Best match: BeautifulSoup 3.0.5 >> Downloading >> http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup- >> 3.0.5.tar.gz >> Processing BeautifulSoup-3.0.5.tar.gz >> Running BeautifulSoup-3.0.5\setup.py -q bdist_egg --dist-dir >> c:\docume~1\larry\l >> ocals~1\temp\easy_install-cfdxna\BeautifulSoup-3.0.5\egg-dist-tmp-gbrpp5 >> Traceback (most recent call last): >> File "C:\Python25\Scripts\easy_install-script.py", line 8, in >> load_entry_point('setuptools==0.6c8', 'console_scripts', >> 'easy_install')() >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >> and\easy_install.py", line 1671, in main >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >> and\easy_install.py", line 1659, in with_ei_usage >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >> and\easy_install.py", line 1675, in >> File "C:\Python25\lib\distutils\core.py", line 151, in setup >> dist.run_commands() >> File "C:\Python25\lib\distutils\dist.py", line 974, in run_commands >> self.run_command(cmd) >> File "C:\Python25\lib\distutils\dist.py", line 994, in run_command >> cmd_obj.run() >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >> and\easy_install.py", line 211, in run >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >> and\easy_install.py", line 446, in easy_install >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >> and\easy_install.py", line 476, in install_item >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >> and\easy_install.py", line 655, in install_eggs >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >> and\easy_install.py", line 930, in build_and_install >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >> and\easy_install.py", line 919, in run_setup >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand >> box.py", line 27, in run_setup >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand >> box.py", line 63, in run >> File >> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand >> box.py", line 29, in >> File "C:\VOL1\Larry\Websafe\Python\wstools\setup.py", line 2, in >> >> import py2exe >> File "C:\VOL1\Larry\Websafe\Python\wstools\unittest.py", line 3, in >> >> class TextCtrlTest(unittest.TestCase): >> AttributeError: 'module' object has no attribute 'TestCase' >> >> >> Thanks in advance for any "clues". > > I'm not sure what happens - but I think it is suspicious that these > "wstools" get into the way. And it looks as if wstools.unittest imports > itself, instead of the python-unittest - which must be solved with > getting the sys.path fixed. > > Diez Sharp eyes Diez, I overlooked that. This is a path that I search for some tools I've written. It is set in PYTHONPATH environment variable. I cleared PYTHONPATH and easy_install BeautifulSoup worked. Still not quite clear why. Thanks loads. -Larry From victorsubervi at gmail.com Tue Apr 15 11:04:02 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Tue, 15 Apr 2008 17:04:02 +0200 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> <4dc0cfea0804140629rf1ac100m27ad9d0456cbbe2d@mail.gmail.com> <4803644A.8010204@holdenweb.com> Message-ID: <4dc0cfea0804150804l2d3832f0sd8f1d9405934063@mail.gmail.com> Gabriel; That's really nice code you wrote. I will rewrite my app accordingly, after I catch a breather! Say, would you please publish this somewhere? Why should I write a howto on this and credit you when all I would be doing is republishing (plagerizing) what you published? Please insert these keywords: mysql, image, python, mysqldb and maybe picture and photo (you already have photo). Call it something like "MySQL/Python Tutorial for Posting and Retrieving Images / Photo Album". I ask you to do this because I scoured google looking for just what you've provided and it simply isn't out there. At all. There are nice howto's in php. Please post this for those interested in python, somewhere like the cookbook. Thanks, Victor On Tue, Apr 15, 2008 at 3:23 AM, Gabriel Genellina wrote: > En Mon, 14 Apr 2008 11:03:54 -0300, Steve Holden > escribi?: > > Victor Subervi wrote: > >> Thanks to all, especially Gabriel. [...] > >> Steve, thank you for all your help, but do overcome your temper :)) > > > > I'm glad the penny finally dropped. You may have been treated to a > > modest display of exasperation, but please be assured you have not yet > > seen anything remotely like temper from me :-) > > And I'm glad to see that you finally "got it", too! > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.sakkis at gmail.com Wed Apr 23 21:17:41 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 23 Apr 2008 18:17:41 -0700 (PDT) Subject: Ideas for parsing this text? References: Message-ID: On Apr 23, 9:00?pm, "Eric Wertman" wrote: > I have a set of files with this kind of content (it's dumped from WebSphere): > > [snipped] > > I'm trying to figure out the best way to feed it all into > dictionaries, without having to know exactly what the contents of the > file are. ? It would be pretty pointless if you had to know in advance the exact file content, but you still have to know the structure of the files, that is the grammar they conform to. > Any ideas? ?I was considering making a list of string combinations, like so: > > junk = ['[[','"[',']]'] > > and just using re.sub to covert them into a single character that I > could start to do split() actions on. ?There must be something else I > can do.. Yes, find out the formal grammar of these files and use a parser generator [1] to specify it. HTH, George [1] http://wiki.python.org/moin/LanguageParsing From ptmcg at austin.rr.com Tue Apr 22 09:54:12 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Tue, 22 Apr 2008 06:54:12 -0700 (PDT) Subject: overriding = operator References: Message-ID: <23874e00-e22e-43d8-a4e7-a2a101eb822f@a1g2000hsb.googlegroups.com> On Apr 22, 8:47?am, "Anton Mellit" wrote: > I need something like > 'overriding' =, which is impossible, but I look for a systematic > approach to do something instead. It seems there are two ways to do > what I need: > > 1. Implement a method 'assign' which generates the corresponding code > to store value: > > z.assign(x + y) > > 2. Do the same as 1., but via property set methods. For example, this > would look cleaner: > > z.value = x + y > > Which of these is preferrable? Does anyone know any alternative ways? > > Anton If you are willing to accept '<<=' as meaning 'assign to existing' instead of 'left shift in place', you can override this operator using the __ilshift__ method. We used this technique in C++/CORBA code back in the 90's to "inject" values into CORBA::Any variables. -- Paul From kyosohma at gmail.com Tue Apr 8 12:20:02 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 8 Apr 2008 09:20:02 -0700 (PDT) Subject: List open files References: <47fb8d54$0$15068$426a74cc@news.free.fr> <47fb968c$0$22371$426a74cc@news.free.fr> Message-ID: On Apr 8, 10:56 am, "Bruno GUERPILLON" wrote: > "Mike Driscoll" a ?crit dans le message de news: > c62d02f7-62c4-447d-a456-261fefb8b... at e67g2000hsa.googlegroups.com... > > > On Apr 8, 10:16 am, "Bruno GUERPILLON" wrote: > >> Hi, > > >> I'd like, in a WIN32 environment, list all open files. > >> Anyone got a clue how to do this ? > > >> Regards, > > >> Bruno. > > > XP comes with a utility called OpenFiles.exe which supposedly gives > > this functionality. You can use Python's subprocess command to run it > > and parse its output. > > > Mike > > Thanks for the answer Mike. > Well, Openfiles.exe list only file opened vi Network. > I'd like to know the local opene files list. > > Regards There is a /Local flag that's supposed to show local files that are open. I've never used this program myself though. You might be able to use WMI somehow. Mike From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 30 06:37:24 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 30 Apr 2008 12:37:24 +0200 Subject: Problem with variables assigned to variables??? In-Reply-To: References: Message-ID: <48184bd7$0$4924$426a34cc@news.free.fr> n00m a ?crit : > for listmember in mylist: > print listmember + ".shp", eval(listmember) eval and exec are almost always the wrong solution. The right solution very often implies a dict or attribute lookup, either on custom dict or on one of the available namespaces (globals(), locals(), or a module, class or instance). From contact at dann.ro Wed Apr 16 22:15:52 2008 From: contact at dann.ro (Daniel NL) Date: Thu, 17 Apr 2008 05:15:52 +0300 Subject: index of list of lists Message-ID: <1208398552l.41837l.0l@ns.bitcarrier.eu> yes, there's a thread with the same title, but I believe mine is more appropriate title. so, as much as I search on the web, read manuals, tutorials, mail-lists (including this one) I cannot figure it out how to search a string in a list of lists. like this one: someList = [['somestring', 1, 2], ['oneother', 2, 4]] I want to search "somestring" in someList which is in practice a list of aprox. 200 lists. (hey, I'm a newbie python programmer, don't judge me). is the list.index the wrong approach? should I use numpy, numarray, something else? can anyone, be kind and help me with this? From hat at se-162.se.wtb.tue.nl Wed Apr 9 11:12:49 2008 From: hat at se-162.se.wtb.tue.nl (A.T.Hofkamp) Date: Wed, 09 Apr 2008 17:12:49 +0200 Subject: Cannot understand the detailedly the following code References: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> <10a83944-b17a-4c3f-992b-1754c0a5e9b1@s33g2000pri.googlegroups.com> Message-ID: On 2008-04-09, reachmsn at hotmail.com wrote: > On Apr 8, 5:45?pm, "A.T.Hofkamp" wrote: > Ok following these instructions one gets > > def find_all_paths(graph, start, end, path=[]): > path= path+ [start] > > for node in graph[start]: > > find_all_paths(graph, node, end, path) > >> First define the input and output parameters/values of the function. >> (ie what goes in, and what comes out) > > Now what will be the output parameters - there is a Return statement. > Input parameters are graph, vertexes start, node, end and path. Also > how would you write the terminating and reduction cases after this. > Actually i'm not clear how to proceed writing this recursive function. > Thanks! Don't look at code, don't even think about it (it gives you too much confusing details). Instead, have a beer, sit down in a sunny spot, and do mothing for a while. Think about the function as a (black) box. You don't know what is in it (it is not important yet). That box is the function (many people prefer to draw a rectangular shape on a sheet of paper, and consider that to be the function). What data does the box need to do its work, and what does it produce after it has done its work? (suppose you are given the task of 'finding all paths'. What information do you need to acomplish this task, and what information do you write down as result?) A simple example of a multiplication task: One needs 2 numbers to do the task, and the result is another number. Note that at this stage, you don't worry about HOW you do the task, only WHAT GOES IN AND WHAT COMES OUT. (actually, HOW depends on INPUT. Multiplication of 2 and 5 can be done differently from multiplication of 230698762085269459068388639078903870385790368703879038285790 and 5938063786093895682682968390789380834687387689762897. For this reason, deciding the strategy of solving the problem comes after establishing input and output). Sincerely, Albert PS email will give you shorter response times. From lscbtfws at gmail.com Sat Apr 26 12:13:46 2008 From: lscbtfws at gmail.com (lscbtfws at gmail.com) Date: Sat, 26 Apr 2008 09:13:46 -0700 (PDT) Subject: get data back crack Message-ID: get data back crack http://cracks.00bp.com F R E E C R A C K S From sjmachin at lexicon.net Sat Apr 12 21:00:18 2008 From: sjmachin at lexicon.net (John Machin) Date: Sat, 12 Apr 2008 18:00:18 -0700 (PDT) Subject: SQLite OperationalError near "?" References: <7e592f06-42b5-4834-8f7c-34c9bc44aceb@s39g2000prd.googlegroups.com> Message-ID: On Apr 13, 8:45 am, Hexade wrote: > Hello > > I would like to use the safe "?" placeholder in my SQLite requests but > I got the following error: > > Traceback (most recent call last): > (...) > cursor.execute("SELECT ? FROM ? WHERE name = ? ", (key, self.table, > self.name)) > OperationalError: near "?": syntax error > > key, self.table and self.name are standart strings. > > Any idea about how to solve this problem ? > You may like to read the answer to the question on sqlite3 that was posted 45 minutes before yours. From jorge.vargas at gmail.com Fri Apr 25 17:55:13 2008 From: jorge.vargas at gmail.com (Jorge Vargas) Date: Fri, 25 Apr 2008 17:55:13 -0400 Subject: is there a python equivalent for this tool? Message-ID: <32822fe60804251455y3bde3f26t2239e3e29ae36d82@mail.gmail.com> Dear python users, do you know of a tool like this that is written in python? http://code.google.com/p/css-redundancy-checker/ in case you where wondering I just don't want to have the ruby dependency on my python proyects. From kperkins257 at gmail.com Wed Apr 23 15:53:20 2008 From: kperkins257 at gmail.com (kperkins257 at gmail.com) Date: Wed, 23 Apr 2008 12:53:20 -0700 (PDT) Subject: Python development tools References: Message-ID: <93653508-8c67-4ea1-924a-a36b80353239@w7g2000hsa.googlegroups.com> On Apr 23, 1:39?pm, "wongjoek... at yahoo.com" wrote: > Are there any completely free developent tools for python scripts like > IDLE. I have used IDLE , but I want to try out others also. I saw > stuff like PyCrust, but I don't see that it can run the script as > well. > Thanks, > > RR SPE is a very nice, and free python development tool. Written in python ansd uses wxpython for the gui. http://pythonide.blogspot.com/ From gagsl-py2 at yahoo.com.ar Thu Apr 3 14:22:29 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 15:22:29 -0300 Subject: Strange MySQL Problem... References: <4dc0cfea0804021236n1faafabav1699fbe45acc3c01@mail.gmail.com> <47f46a3e$0$36371$742ec2ed@news.sonic.net> <4dc0cfea0804030543t1ad5a3abs539fa6598061c454@mail.gmail.com> <4dc0cfea0804031003r24086f0fgea31eccdefa2ed54@mail.gmail.com> Message-ID: En Thu, 03 Apr 2008 14:03:53 -0300, Victor Subervi escribi?: > On Thu, Apr 3, 2008 at 9:34 AM, Gabriel Genellina > > wrote: > > Thank you. I believe you mean by bound, something like this, right? > binary(picdata) > I am now doing that, if I am not mistaken. No, I mean execute(sqltext, arguments) instead of execute(sqltext_with_values_inserted_by_hand) >> *post*? This is the server response. Return either text *or* an image >> (the >> text may be an html referencing the image) > > Yes, post. But what do I write instead of this? > print 'Content-Type: image/jpeg\r\n' Perhaps you should read a little about how HTTP works. Very shortly, the client (the browser, on behalf of the user) sends an HTTP Request (usually a GET request, sometimes POST). The server receives it, processes it and returns an HTTP Response. Whatever you 'print' in your CGI script is part of the Response, a response isn't a POST. If the response is an HTML page, the Content-Type should say text/html, NOT image/jpeg. >> Test it locally (just the database thing, no web), test the cgi script >> without database interaction, only then join the two. > > Okay, but how do I upload an image into mysql without a script? And once > I can do that, everything?s (almost) solved! I insist: test each step separately. First locally, later merge all steps. One doesn't "upload an image into mysql": one uploads an image, and some script on the server saves the image into mysql database. >> But you can read the server logs at least? > I am new to Plesk. I discovered I can read logs. More following... Good thing! >> Your code is throwing exceptions but you're not seeing them. Use the >> cgitb >> module http://docs.python.org/lib/module-cgitb.html > > Now here you give me another laugh :) I added this line to the script > import cgitb; cgitb.enable() > and suddenly I can take out these junk lines that were throwing the HTTP > 200 > error: Please stop refering to it as HTTP 200 error: it is *not* an error! > I have a script called start.py which has this code in it: > > col_names = ['id', 'name_en', 'name_es', 'name_it', 'category', > 'title_en', 'title_es', 'title_it', \ > 'description_en', 'description_es', 'description_it', 'price', > 'bedrooms', 'bathrooms', 'pic1', 'sort_factor'] > Just notice the pic1 there... > Then I make a nice list of colnames like MySQL wants... > > col_names_with_commas = '' > for name in col_names: > col_names_with_commas += name + ', ' > count = len(col_names_with_commas)-2 > col_names_with_commas = > col_names_with_commas[0:len(col_names_with_commas)-2] The above code is a long and convoluted way to write: col_names_with_commas = ', '.join(col_names) > for id in ids: > for d in id: > print '\n' > cursor.execute('select ' + col_names_with_commas + ' from > products > where id = ' + str(d) + ';') Remember to use parameters: cursor.execute('select ' + col_names_with_commas + ' from products ' ' where id = %s;', (d,)) All this looks like the kind of spaghetti code common in cgi scripts around 10 years ago, mixing application logic, storage and presentation all at once. At least try to separate database operations from html generation: make your queries, build some data structure, and generate the HTML using that structure as parameters. There are many templating engines to choose for: http://wiki.python.org/moin/Templating > if x == 15: > print '', field, '\n' > else: > print '', field, '\n' > x += 1 > I have to do both of those for statements. The sticky point is in the > last > if statement. 15 is the pic1 field. Should I use binary(field) instead? > It > does not like that. Binary is part of the DBAPI interface (you should read PEP 249 [1]). It has absolutely nothing to do with html pages. > mod_python.cgihandler: NameError: global name 'binary' is not defined, Python is case sensitive... Use MySQLdb.Binary instead. See [1] and the MySQLdb documentation. I insist again: this would have been a lot easier to catch if you test locally; this error has nothing to do with the web part of the application. [1] http://www.python.org/dev/peps/pep-0249/ -- Gabriel Genellina From code at pizzashack.org Thu Apr 3 19:07:58 2008 From: code at pizzashack.org (Derek Martin) Date: Thu, 3 Apr 2008 19:07:58 -0400 Subject: Manipulate Large Binary Files In-Reply-To: <9EBD1A97-98C5-44E6-8472-A7AAADC0A3CA@gmail.com> References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> <9999810b0804021109n77f2c990p7b10d92e9344ad00@mail.gmail.com> <7xlk3vctea.fsf@ruckus.brouhaha.com> <9EBD1A97-98C5-44E6-8472-A7AAADC0A3CA@gmail.com> Message-ID: <20080403230758.GG22737@dragontoe.org> On Thu, Apr 03, 2008 at 02:36:02PM -0400, Derek Tracy wrote: > I am running it on a RAID(stiped raid 5 using fibre channel), but I > was expecting better performance. Don't forget that you're reading from and writing to the same spindles. Writes are slower on RAID 5, and you have to read the data before you can write it... -- Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0x81CFE75D -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available URL: From george.sakkis at gmail.com Fri Apr 4 11:15:38 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 4 Apr 2008 08:15:38 -0700 (PDT) Subject: collecting results in threading app References: Message-ID: <3c56504f-5820-4452-929d-18a95e5d163f@z38g2000hsc.googlegroups.com> On Apr 4, 10:42 am, Gerardo Herzig wrote: > Hi all. Newbee at threads over here. Im missing some point here, but cant > figure out which one. > > This little peace of code executes a 'select count(*)' over every table > in a database, one thread per table: > > class TableCounter(threading.Thread): > def __init__(self, conn, table): > self.connection = connection.Connection(host=conn.host, > port=conn.port, user=conn.user, password='', base=conn.base) > threading.Thread.__init__(self) > self.table = table > > def run(self): > result = self.connection.doQuery("select count(*) from %s" % > self.table, [])[0][0] > print result > return result > > class DataChecker(metadata.Database): > > def countAll(self): > for table in self.tables: > t = TableCounter(self.connection, table.name) > t.start() > return > > > It works fine, in the sense that every run() method prints the correct > value. > But...I would like to store the result of t.start() in, say, a list. The > thing is, t.start() returns None, so...what im i missing here? > Its the desing wrong? The simplest way is to just store it as an attribute in the TableCounter instance: def run(self): self.result = self.connection.doQuery(...) Another alternative is to add it to a Queue. You can't use a list unless you protect with a lock to prevent concurrent append()s, but that's what Queues do anyway [1]. Regardless of where the results are stored, a second issue which you don't address here is, how do you know that a given result or all results are done ? Again there are several alternatives, but Python 2.5 adds two convenient Queue methods for this, task_done() and join(). Check out the example at the bottom of the Queue doc page [2] to see how it works. HTH, George [1] http://docs.python.org/lib/module-Queue.html [2] http://docs.python.org/lib/QueueObjects.html From spiro.harvey at gmail.com Thu Apr 3 18:22:39 2008 From: spiro.harvey at gmail.com (idle) Date: Thu, 3 Apr 2008 15:22:39 -0700 (PDT) Subject: expanding a variable to a dict References: Message-ID: <599b39da-6187-4dca-90ff-75ade61719d5@s13g2000prd.googlegroups.com> brilliant. thanks to both of you. From grahn+nntp at snipabacken.se Tue Apr 1 07:34:05 2008 From: grahn+nntp at snipabacken.se (Jorgen Grahn) Date: 1 Apr 2008 11:34:05 GMT Subject: standard input, for s in f, and buffering References: <65bg55F2esfc1U3@mid.uni-berlin.de> Message-ID: On Mon, 31 Mar 2008 22:27:39 -0700 (PDT), Paddy wrote: > On Mar 31, 11:47 pm, Jorgen Grahn wrote: >> On 31 Mar 2008 06:54:29 GMT, Marc 'BlackJack' Rintsch wrote: >> >> > On Sun, 30 Mar 2008 21:02:44 +0000, Jorgen Grahn wrote: >> >> >> I realize this has to do with the extra read-ahead buffering documented for >> >> file.next() and that I can work around it by using file.readline() >> >> instead. >> > You can use ``for line in lines:`` and pass ``iter(sys.stdin.readline,'')`` >> > as iterable for `lines`. >> >> Thanks. I wasn't aware that building an iterator was that easy. The >> tiny example program then becomes >> By the way, I timed the three solutions given so far using 5 million >> lines of standard input. It went like this: >> >> for s in file : 1 >> iter(readline, ''): 1.30 (i.e. 30% worse than for s in file) >> while 1 : 1.45 (i.e. 45% worse than for s in file) >> Perl while(<>) : 0.65 >> >> I suspect most of the slowdown comes from the interpreter having to >> execute more user code, not from lack of extra heavy input buffering. > Hi Juergen, > From the python manpage: > -u Force stdin, stdout and stderr to be totally unbuffered. > On systems where it matters, also put stdin, stdout and > stderr in binary mode. Note that there is internal > buffering in xreadlines(), readlines() and file-object > iterators ("for line in sys.stdin") which is not influenced > by this option. To work around this, you will want to use > "sys.stdin.readline()" inside a "while 1:" loop. > Maybe try adding the python -u option? Doesn't help when the code is in a module, unfortunately. > Buffering is supposed to help when processing large amounts of I/O, > but gives the 'many lines in before any output' that you saw > originally. "Is supposed to help", yes. I suspect (but cannot prove) that the kind of buffering done here doesn't buy more than 10% or so even in artificial tests, if you consider the fact that "for s in f" is in itself a faster construct than my workarounds in user code. Note that even with buffering, there seems to be one system call per line when used interactively, and lines are of course passed to user code one by one. Lastly, there is still the question about having to press Ctrl-D twice to end the loop, which I mentioned my the original posting. That still feels very wrong. > If the program is to be mainly used to handle millions of > lines from a pipe or file, then why not leave the buffering in? > If you need both interactive and batch friendly I/O modes you might > need to add the ability to switch between two modes for your program. That is exactly the tradeoff I am dealing with right now, and I think I have come to the conclusion that I want no buffering. My source data set can be huge (gigabytes of text) but in reality it is boiled down to at most 50000 lines by a Perl script further to the left in my pipeline: zcat foo.gz | perl | python > bar The Perl script takes ~100 times longer time to execute, and both are designed as filters, which means a modest increase in CPU time for the Python script isn't visible to the end user. /Jorgen -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! From dfg778 at yahoo.com.au Sun Apr 13 04:51:39 2008 From: dfg778 at yahoo.com.au (Matthew Keene) Date: Sun, 13 Apr 2008 18:51:39 +1000 Subject: Call a classmethod on a variable class name Message-ID: I would like to be able to call a specific classmethod on a class name that is going to be passed from another parameter. In other words, I have a call that looks something like: x = Foo.bar() and I would like to generalise this so that I can make this call on any particular class which provides the bar classmethod. I have implemented this using exec, like so: className = parameters.className exec "x = " + className + ".bar()" but this feels somewhat clumsy. (I do have the requisite exception handling to cope with the supplied class not existing or not implementing the bar method, by the way). Is there any more Pythonesque way of doing this ? I guess what I'm probably looking for is something like the way I understand the send function works in Ruby From sevenjp at gmail.com Wed Apr 2 06:00:51 2008 From: sevenjp at gmail.com (=?ISO-8859-1?Q?Jo=E3o_Neves?=) Date: Wed, 2 Apr 2008 03:00:51 -0700 (PDT) Subject: Rationale for read-only property of co_code Message-ID: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> Hello all, I've got this question that has been nagging me for a few days now. What are the reasons for us to have co_code as read-only? I've been trying to get some info about it, but I kept hitting the wall. Correct me if I'm wrong, but as far as I understand, co_code represents the compiled bytecode that should be run when, for instance, a function is called. Wouldn't it be beneficial for programmers to be able to change the bytecode in runtime? I mean, one can't, as far as I'm aware, change the bytecode by accident, so if the programmer would wish to change a function at runtime, he could do so at his own risk. If there is a higher reason behind the read-only property of co_code, I definitely fail to see it, and would like to know what it is. If not, why aren't we allowed to write into it? Thanks in advance, Jo?o Neves From steve at holdenweb.com Sat Apr 5 22:14:15 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 22:14:15 -0400 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> Message-ID: <47F831F7.4000709@holdenweb.com> Fredrik Lundh wrote: > Fredrik Lundh wrote: > >> and for the record, Python doesn't look for PYD files on any of the Unix >> boxes I have convenient access to right now. what Ubuntu version are >> you using, what Python version do you have, and what does >> >> $ python -c "import imp; print imp.get_suffixes()" >> >> print on your machine? > > for reference, here's what I get on Ubuntu 7.10, with the standard > Python interpreter (2.5.1): > > $ python -c "import imp; print imp.get_suffixes()" > [('.so', 'rb', 3), ('module.so', 'rb', 3), ('.py', 'U', 1), > ('.pyc', 'rb', 2)] > > any Ubuntu gurus here that can sort this one out? > I wouldn't claim to be an Ubuntu guru but it seems as though the Ubuntu team decide that you would be able to import extension module YYY either from YYY.so or from YYYmodule.so. IF you are asking *why* then I'd have to answer that I have no idea at all. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From maehhheeyy at gmail.com Thu Apr 17 16:10:58 2008 From: maehhheeyy at gmail.com (maehhheeyy) Date: Thu, 17 Apr 2008 13:10:58 -0700 (PDT) Subject: i want to add a timeout to my code Message-ID: <53ffe104-be3b-43e2-b5c8-4ce5886ac60d@b1g2000hsg.googlegroups.com> I want to add a timeout so that when I pull out my gps from my serial port, it would wait for a bit then loop and then see if it's there. I also want to add a print statement saying that there is no GPS device found. However when I run my code and unplug my serial port, my code will just hang until I plug it back in. This is my code right now: def GetGPS(): data = [] #Open com1: 9600,8,N,1 fi = serial.Serial(0, timeout = 1) print '[gps module] SERIAL PORT OPEN ON COM1:' can anyone help me please? Thanks. From lists at cheimes.de Sun Apr 20 16:23:32 2008 From: lists at cheimes.de (Christian Heimes) Date: Sun, 20 Apr 2008 22:23:32 +0200 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <480b8d58$0$26996$9b622d9e@news.freenet.de> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480b8d58$0$26996$9b622d9e@news.freenet.de> Message-ID: <480BA644.9090701@cheimes.de> Martin v. L?wis schrieb: > Can you give an example, please? http://trac.edgewall.org/ contains at least one example of a reference leak. It's holding up the release of 0.11 for a while. *scnr* The problem is also covered by the docs at http://docs.python.org/dev/library/sys.html#sys.exc_info Christian From gagsl-py2 at yahoo.com.ar Fri Apr 4 18:46:11 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 04 Apr 2008 19:46:11 -0300 Subject: displaying pgm file in python References: Message-ID: En Fri, 04 Apr 2008 19:07:59 -0300, wilson escribi?: > i converted an 8bit rgb .jpg file into .pgm using adobe photoshop and > a plugin from > http://photoshop.pluginsworld.com/plugins/adobe/362/richard-rosenman/portable-pixmap-importer-exporter.html > I want to check if this file can be properly displayed. > Image opening and show() in PIL fails to do it so i tried Tkinter > I checked the asci text of .pgm file ,it starts with a line P2 and > then several lines with integers..can someone tell me if there is a > way to display this properly P2 is a rather old variant that it's not in use anymore AFAIK. Try replacing P2 with P5; at least PIL should recognize it, I think. PIL can read and write .pgm, why don't you do the conversion with PIL? -- Gabriel Genellina From sergio.correia at gmail.com Tue Apr 22 11:24:16 2008 From: sergio.correia at gmail.com (Sergio Correia) Date: Tue, 22 Apr 2008 10:24:16 -0500 Subject: Financial Modeling with Python by Shayne Fletcher, Christopher Gardner In-Reply-To: References: Message-ID: Searched on google and couldn't find anything :S On Mon, Apr 21, 2008 at 11:28 AM, wrote: > Just saw at amazon.com reference to the following book that might be > available later this year: > > Financial Modeling with Python [IMPORT] (Hardcover) > by Shayne Fletcher (Author), Christopher Gardner (Author) > > Availability: Sign up to be notified when this item becomes available. > > Product Details > > * Hardcover: 352 pages > * Publisher: John Wiley and Sons Ltd (November 10, 2008) > * ISBN-10: 0470987847 > * ISBN-13: 978-0470987841 > * Shipping Weight: 1.7 pounds > > Would be nice if the authors or publisher could post to this group an > outline or draft table of contents of the book. > -- > http://mail.python.org/mailman/listinfo/python-list > From destroooooy at gmail.com Tue Apr 29 16:56:29 2008 From: destroooooy at gmail.com (destroooooy) Date: Tue, 29 Apr 2008 13:56:29 -0700 (PDT) Subject: string translate, replace, find and the forward slash References: <1030ffc2-1bbe-4539-881d-35bf59cacd11@34g2000hsh.googlegroups.com> Message-ID: <599157bd-5a4e-4133-afda-d446d0051aab@y38g2000hsy.googlegroups.com> On Apr 29, 4:50 pm, Arnaud Delobelle wrote: > destroooooy writes: > > Hi folks, > > I'm finding some (what I consider) curious behavior with the string > > methods and the forward slash character. I'm writing a program to > > rename mp3 files based on their id3 tags, and I want to protect > > against goofy characters in the in tags. So I do the following: > > > unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n" > > alt_chars = "_________________________" > > > s_artist.translate(maketranstable(unsafe_chars, alt_chars)) > > > which successfully replaces everything except for forward slashes (at > > least in the files I've tested so far). If I use the "replace()" > > method, it also does not work. Escaping the forward slash changes > > nothing. "find()" however, works, and thus I've resorted to: > > > if "/" in s_artist: > > (s_l, slash, s_r) = s_artist.partition("/") > > s_artist = "_".join([s_l, s_r]) > > > which is rather uncool. It works but I'd just like to know what the > > deal is. TIA. > > It works fine here: > > marigold:junk arno$ python > Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) > [GCC 4.0.1 (Apple Inc. build 5465)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > > >>> unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n" > >>> table = range(256) > >>> for c in unsafe_chars: table[ord(c)] = ord('_') > ... > >>> table = ''.join(chr(o) for o in table) > >>> 'Jon(&Mark/Steve)'.translate(table) > 'Jon__Mark_Steve_' > > -- > Arnaud Oooh. Let me try it that way. From Jiang.Adam at gmail.com Fri Apr 18 02:31:30 2008 From: Jiang.Adam at gmail.com (Adam) Date: Thu, 17 Apr 2008 23:31:30 -0700 (PDT) Subject: How to set proxy for a python script to run Message-ID: <94243913-cdcb-47a2-b000-a236fe0e8009@p25g2000hsf.googlegroups.com> Hi, everyone, I am using /usr/share/system-config-language/ language_gui.py in Python. For some reason I have to bypass the firewall using a proxy. I read the urllib reference and set http_proxy="my proxy". But it didn't work. Is there anyway that we can set the proxy? From dimitri.pater at gmail.com Tue Apr 22 18:52:20 2008 From: dimitri.pater at gmail.com (dimitri pater) Date: Wed, 23 Apr 2008 00:52:20 +0200 Subject: Python Success stories In-Reply-To: <965898d3-5bcf-4525-9f1c-e938a5f92117@m44g2000hsc.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <965898d3-5bcf-4525-9f1c-e938a5f92117@m44g2000hsc.googlegroups.com> Message-ID: http://code.google.com/appengine/docs/whatisgoogleappengine.html 2008/4/22 Ivan Illarionov : > On 22 ???, 14:25, azrael wrote: > [....] > > > This hurts. Please give me informations about realy famous > > aplications. > > What do you mean by "really famous"? > > Information is here: > http://www.python.org/about/quotes/ > > Are YouTube and Google famous enough? > > -- > Ivan > > > -- > http://mail.python.org/mailman/listinfo/python-list -- --- You can't have everything. Where would you put it? -- Steven Wright --- please visit www.serpia.org From duncan.booth at invalid.invalid Wed Apr 30 06:47:36 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 30 Apr 2008 10:47:36 GMT Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> Message-ID: Torsten Bronger wrote: > The biggest ugliness though is ",".join(). No idea why this should > be better than join(list, separator=" "). Besides, ",".join(u"x") > yields an unicode object. This is confusing (but will probably go > away with Python 3). It is only ugly because you aren't used to seeing method calls on string literals. Here are some arguably less-ugly alternatives: print str.join(", ", sequence) or: comma_separated = ", ".join will let you use: print comma_separated(sequence) or even just: SEPARATOR = ", " followed by: SEPARATOR.join(sequence) is no more ugly than any other method call. It would make perfect sense for join to be a method on stringlike objects if it simply returned an object of the same type as the object it is called on. As you point out, where it breaks down is a str separator can return a unicode result and that is confusing: if you want a unicode result perhaps you should be required to use a unicode separator but that isn't going to happen (at least not in Python 2.x). What definitely wouldn't make sense would be to make join a method of the list type (as it is in some other languages). From vivainio at gmail.com Wed Apr 23 11:09:57 2008 From: vivainio at gmail.com (Ville M. Vainio) Date: Wed, 23 Apr 2008 15:09:57 GMT Subject: Python "make" like tools (was Re: [ANN] DoIt 0.1.0 Released (build tool)) In-Reply-To: References: Message-ID: <9jIPj.124$RM4.68@read4.inet.fi> Eduardo Schettino wrote: >> I find the doit syntax a bit cumbersome, especially as you can avoid >> 'args' by just returning a lamda in 'action'. > > > My idea was to: do *not* add any new syntax (to avoid being > cumbersome). It is just python, you dont have to import or subclass Yeah, decorators get around this. > I though about using decorators in the beginning... but returning a > dictionary looked easier to implement and more flexible. one important > feature is how easy to define a group of task with the same action. > Take a look at the example below on running pychecker in all python > files from a folder. I couldnt figure out an easy way of doing it with > decorators. > > import glob; > pyFiles = glob.glob('*.py') > > def task_checker(): > for f in pyFiles: > yield {'action': "pychecker %s"% f, > 'name':f, > 'dependencies':(f,)} Perhaps you could do: for f in pyFiles: @task("checker") @depend(f) def check(): c("pychecker %s" % f) Never underestimate the magic that is nested scopes and name-agnostic function object creation... > Another advantage of using just a dictionary to define a task is that > it will be easy to read tasks from a text file (if it is very simple > and you dont need to write any python script). but not implemented > yet. It is easy with the above syntax as well. > I though about using decorator for simple python-tasks but in a different way: > > @task > def create_folder(path): > """Create folder given by "path" if it doesnt exist""" > if not os.path.exists(path): > os.mkdir(path) > return True > > so if your python function is a task and you will use it only once you > dont need to define a function for the 'action' and another function > to create the task. but not implement yet also. Yeah, this is what I consider much friendlier syntax (the aim is to not be much more verbose than make). > apart from one .py file installation (easy_install is not enough?) > thats what i am trying to do. easy_install is not really enough - it introduces a dependency that you can't get around by just shipping a short .py file with your project. This problem domain seems simple enough that it should be covered by a very short and simple module (Paul, the Waf you suggested was ~ 300k, no doubt caused by all the c compiler stuff that I don't need). 'Paver' seems to have the right idea: http://www.blueskyonmars.com/projects/paver/index.html But it's still *slightly* too big: http://bazaar.launchpad.net/~dangoor/paver/main/files From fredrik at pythonware.com Fri Apr 4 16:38:50 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 04 Apr 2008 22:38:50 +0200 Subject: Tokenizer inconsistency wrt to new lines in comments In-Reply-To: <8b3fa4cc-deb9-4748-a63c-a6c7e5dd92ba@59g2000hsb.googlegroups.com> References: <1ce40dcf-4a0a-4577-af3b-6a77ef71356c@f63g2000hsf.googlegroups.com> <6dd69a1f-96d0-4b91-b84b-a54794a31c70@u36g2000prf.googlegroups.com> <8b3fa4cc-deb9-4748-a63c-a6c7e5dd92ba@59g2000hsb.googlegroups.com> Message-ID: George Sakkis wrote: >> If it was a bug it has to violate a functional requirement. I can't >> see which one. > > Perhaps it's not a functional requirement but it came up as a real > problem on a source colorizer I use. I count on newlines generating > token.NEWLINE or tokenize.NL tokens in order to produce
tags. It > took me some time and head scratching to find out why some comments > were joined together with the following line. Now I have to check > whether a comment ends in new line and if it does output an extra
> tag.. it works but it's a kludge. well, the real kludge here is of course that you're writing your own colorizer, when you can just go and grab Pygments: http://pygments.org/ or, if you prefer something tiny and self-contained, something like the colorizer module in this directory: http://svn.effbot.org/public/stuff/sandbox/pythondoc/ (the element_colorizer module in the same directory gives you XHTML in an ElementTree instead of raw HTML, if you want to postprocess things) From castironpi at gmail.com Sun Apr 27 22:24:49 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sun, 27 Apr 2008 19:24:49 -0700 (PDT) Subject: Regular Expression - Matching Multiples of 3 Characters exactly. References: Message-ID: On Apr 27, 8:31?pm, blaine wrote: > Hey everyone, > ? For the regular expression gurus... > > I'm trying to write a string matching algorithm for genomic > sequences. ?I'm pulling out Genes from a large genomic pattern, with > certain start and stop codons on either side. ?This is simple > enough... for example: > > start = AUG stop=AGG > BBBBBBAUGWWWWWWAGGBBBBBB > > So I obviously want to pull out AUGWWWWWWAGG (and all other matches). > This works great with my current regular expression. > > The problem, however, is that codons come in sets of 3 bases. ?So > there are actually three different 'frames' I could be using. ?For > example: > ABCDEFGHIJ > I could have ABC DEF GHI or BCD EFG HIJ or CDE FGH IJx.... etc. > > So finally, my question. ?How can I represent this in a regular > expression? :) ?This is what I'd like to do: > (Find all groups of any three characters) (Find a start codon) (find > any other codons) (Find an end codon) > > Is this possible? It seems that I'd want to do something like this: (\w > \w\w)+(AUG)(\s)(AGG)(\s)* - where \w\w\w matches EXACTLY all sets of > three non-whitespace characters, followed by AUG \s AGG, and then > anything else. ?I hope I am making sense. ?Obviously, however, this > will make sure that ANY set of three characters exist before a start > codon. ?Is there a way to match exactly, to say something like 'Find > all sets of three, then AUG and AGG, etc.'. ?This way, I could scan > for genes, remove the first letter, scan for more genes, remove the > first letter again, and scan for more genes. ?This would > hypothetically yield different genes, since the frame would be > shifted. > > This might be a lot of information... I appreciate any insight. ?Thank > you! > Blaine Here's one idea (untested): s= { } for x in range( len( genes )- 3 ): s[ x ]= genes[ x: x+ 3 ] You might like Python's 'string slicing' feature. From kay.schluehr at gmx.net Fri Apr 18 19:19:38 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Fri, 18 Apr 2008 16:19:38 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <0ebcf70f-c6d6-4ee7-9ef8-7cd2221ef906@t12g2000prg.googlegroups.com> Message-ID: <879750f6-614a-45ed-8f18-f0b7ae5ea9a2@26g2000hsk.googlegroups.com> On 18 Apr., 23:09, Matimus wrote: > The reason it doesn't work is that you are unpacking the dictionary > with **, and you have done nothing to define any keys or define a > length. This is a non-issue. The class derives from dict; it has all the desired attributes. It is also not a problem in particular because these properties are not requested by format ( at least not in the code I have examined which was admittedly just a critical section that caused the exception ). > Adding to that... don't worry about py3k. Nobody is forcing you to > switch. In fact, you are encouraged not to until you are comfortable. > Py3k won't _break_ your code. You wrote the code for Python 2.x use it > in 2.x. Python 2.x probably has a good 5-10 years remaining. These advices start to get annoying. Software hardly ever exists in isolation for the sake of the beauty of the algorithm but is supplementary to a large framework/engine/ library. So if e.g. Django switches to 3 everyone who works with it has to switch sooner or later as well or lose track otherwise, no matter how long Python 1.5.2 or Python 2.5.2 or whatever version will be maintained. If Pythons code base becomes fragmented it will be harmful and affect almost everyones work. From john00587 at gmail.com Mon Apr 21 01:41:12 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:41:12 -0700 (PDT) Subject: egirl crack Message-ID: egirl crack http://cracks.00bp.com F R E E C R A C K S From hdante at gmail.com Wed Apr 2 09:25:26 2008 From: hdante at gmail.com (hdante) Date: Wed, 2 Apr 2008 06:25:26 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <47f36d23$0$28775$426a74cc@news.free.fr> Message-ID: <86afee6d-7022-4199-8af5-bff01c679714@c65g2000hsa.googlegroups.com> On Apr 2, 8:25 am, Bruno Desthuilliers wrote: > hdante a ?crit : > > > > > > Try Rails' ActiveRecord. Your problems should reduce to (lg lg > > 2)^(1/12). > > Correct me if I'm wrong, but IIRC ActiveRecord requires you use numeric > auto_increment fields for primary key. As far as I'm concerned, this is > a definitive no-no. Why is that so bad ? "But wait !, you cry. Shouldn't the primary key of my orders table be the order number or some other meaningful column ? Why use an artificial primary key such as id ? The reason is largely a practical one - the format of external data may change over time." (...) "Normally, Active Record takes care of creating new primary key values for records that you create and add to the database - they'll be ascending integers (possibily with some gaps in the sequence). However, if you override the primary key column's name, you also take on the responsibility of setting the primary key to a unique value before you save a new row." -- AWDWR > > > Seriously, you'll forget there's a relational database below. > > Why on earth are you using a RDBMS if you don't want it ? I for one *do* > care about using a *relational* database, and *don't* want to hide it > away. What I don't want is to have to build my queries as raw strings. > And that's where SQLAlchemy shines : it's not primarily an "ORM", it's > an higher-level Python/SQL integration tool that let you build your > queries as Python objects (and also, eventually, build an ORM if you > want to...). "Some object-relational mappers seek to eliminate the use of SQL entirely, hoping for object-oriented purity by forcing all queries through an OO layer. Active Record does not. It was built on the notion that SQL is neither dirty nor bad, just verbose in the trivial cases. (...) Therefore, you shouldn't feel guilty when you use find_by_sql to handle either performance bottlenecks or hard queries. Start out using the object-oriented interface for productivity and pleasure, and then dip beneath the surface for a close-to-the-metal experience when you need to do so." -- AWDWR PS. That's okay to use a RDBMS. What I don't want is to use two programming paradigms, especially, considering the "object-relational impedance mismatch". From ivan.illarionov at gmail.com Tue Apr 22 00:04:16 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Tue, 22 Apr 2008 04:04:16 +0000 (UTC) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> <85c14b14-9302-41bb-9270-b7cdd65098b0@c65g2000hsa.googlegroups.com> Message-ID: On Mon, 21 Apr 2008 16:10:05 -0700, George Sakkis wrote: > On Apr 21, 5:30 pm, Ivan Illarionov wrote: > >> On 22 ???, 01:01, Peter Otten <__pete... at web.de> wrote: >> >> > Ivan Illarionov wrote: >> > > And even faster: >> > > a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, >> > > len(s), 3)))) >> > > if sys.byteorder == 'little': >> > > a.byteswap() >> >> > > I think it's a fastest possible implementation in pure python >> >> > Clever, but note that it doesn't work correctly for negative numbers. >> > For those you'd have to prepend "\xff" instead of "\0". >> >> > Peter >> >> Thanks for correction. >> >> Another step is needed: >> >> a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, >> len(s), 3)))) >> if sys.byteorder == 'little': >> a.byteswap() >> result = [n if n < 0x800000 else n - 0x1000000 for n in a] >> >> And it's still pretty fast :) > > Indeed, the array idea is paying off for largeish inputs. On my box > (Python 2.5, WinXP, 2GHz Intel Core Duo), the cutoff point where > from3Bytes_array becomes faster than from3Bytes_struct is close to 150 > numbers (=450 bytes). > > The struct solution though is now almost twice as fast with Psyco > enabled, while the array doesn't benefit from it. Here are some numbers > from a sample run: > > *** Without Psyco *** > size=1 > from3Bytes_ord: 0.033493 > from3Bytes_struct: 0.018420 > from3Bytes_array: 0.089735 > size=10 > from3Bytes_ord: 0.140470 > from3Bytes_struct: 0.082326 > from3Bytes_array: 0.142459 > size=100 > from3Bytes_ord: 1.180831 > from3Bytes_struct: 0.664799 > from3Bytes_array: 0.690315 > size=1000 > from3Bytes_ord: 11.551990 > from3Bytes_struct: 6.390999 > from3Bytes_array: 5.781636 > *** With Psyco *** > size=1 > from3Bytes_ord: 0.039287 > from3Bytes_struct: 0.009453 > from3Bytes_array: 0.098512 > size=10 > from3Bytes_ord: 0.174362 > from3Bytes_struct: 0.045785 > from3Bytes_array: 0.162171 > size=100 > from3Bytes_ord: 1.437203 > from3Bytes_struct: 0.355930 > from3Bytes_array: 0.800527 > size=1000 > from3Bytes_ord: 14.248668 > from3Bytes_struct: 3.331309 > from3Bytes_array: 6.946709 > > > And here's the benchmark script: > > import struct > from array import array > > def from3Bytes_ord(s): > return [n if n<0x800000 else n-0x1000000 for n in > ((ord(s[i])<<16) | (ord(s[i+1])<<8) | ord(s[i+2]) > for i in xrange(0, len(s), 3))] > > unpack_i32be = struct.Struct('>l').unpack def from3Bytes_struct(s): > return [unpack_i32be(s[i:i+3] + '\0')[0]>>8 > for i in xrange(0,len(s),3)] > > def from3Bytes_array(s): > a = array('l', ''.join('\0' + s[i:i+3] > for i in xrange(0,len(s), 3))) > a.byteswap() > return [n if n<0x800000 else n-0x1000000 for n in a] > > > def benchmark(): > from timeit import Timer > for n in 1,10,100,1000: > print ' size=%d' % n > # cycle between positive and negative buf = > ''.join(struct.pack('>i', 1234567*(-1)**(i%2))[1:] > for i in xrange(n)) > for func in 'from3Bytes_ord', 'from3Bytes_struct', > 'from3Bytes_array': > print ' %s: %f' % (func, > Timer('%s(buf)' % func , > 'from __main__ import %s; buf=%r' % (func,buf) > ).timeit(10000)) > > > if __name__ == '__main__': > s = ''.join(struct.pack('>i',v)[1:] for v in > [0,1,-2,500,-500,7777,-7777,-94496,98765, > -98765,8388607,-8388607,-8388608,1234567]) > assert from3Bytes_ord(s) == from3Bytes_struct(s) == > from3Bytes_array(s) > > print '*** Without Psyco ***' > benchmark() > > import psyco; psyco.full() > print '*** With Psyco ***' > benchmark() > > > George Comments: You didn't use the faster version of array approach: ''.join('\0' + s[i:i+3] for i in xrange(0,len(s), 3)) is slower than '\0' + '\0'.join(s[i:i+3] for i in xrange(0,len(s), 3)) To Bob Greschke: Struct is fast in Python 2.5 with struct.Struct class. Array approach should work with Python 2.3 and it's probably the fastest one (without psyco) with large inputs: def from3bytes_array(s): a = array.array('i', '\0' + '\0'.join([s[i:i+3] for i in xrange(0, len(s), 3)])) a.byteswap() # if your system is little-endian return [n >= 0x800000 and n - 0x1000000 or n for n in a] -- Ivan From lscbtfws at gmail.com Sat Apr 26 12:08:13 2008 From: lscbtfws at gmail.com (lscbtfws at gmail.com) Date: Sat, 26 Apr 2008 09:08:13 -0700 (PDT) Subject: xpand rally crack Message-ID: <53146891-63d7-4760-af0d-5b7ac14a41f0@h1g2000prh.googlegroups.com> xpand rally crack http://cracks.00bp.com F R E E C R A C K S From mensanator at aol.com Wed Apr 16 15:59:47 2008 From: mensanator at aol.com (Mensanator) Date: Wed, 16 Apr 2008 12:59:47 -0700 (PDT) Subject: Finally had to plonk google gorups. References: <28d12cc8-5375-4e95-8e37-f872d238a1bd@b64g2000hsa.googlegroups.com> <6cadnYCFdNpR2ZvVnZ2dnUVZ_tPinZ2d@visi> <48064885$0$18426$39cecf19@news.twtelecom.net> Message-ID: <647beab1-3d5d-41cb-b9b7-f46184ecc072@b64g2000hsa.googlegroups.com> On Apr 16, 1:43?pm, Severian wrote: > Grant Edwards wrote: > > On 2008-04-16, Mensanator wrote: > >> On Apr 16, 9:19 am, Grant Edwards wrote: > >>> This morning almost half of c.l.p was spam. ?In order to try > >>> to not tar both the benign google group users and the > >>> malignant ones with the same brush, I've been trying to kill > >>> usenet spam with subject patterns. ?But that's not a battle > >>> you can win, so I broke down and joined all the other people > >>> that just killfile everything posted via google.groups. > >> Not very bright, eh? > > >>> AFAICT, if you're a google groups user your posts are not being > >>> seen by many/most experienced (read "non-google-group") users. > >>> This is mainly the fault of google who has refused to do > >>> anything to stem the flood of span that's being sent via Google > >>> Groups. > >> Duh. > > > My. ?That was certainly a well-reasoned and well-written > > response. > > Well, it did come from an AOL user posting from Google groups . Hey, he wasn't supposed to see that! He's plonked Google Groups, hasn't he? Looks like you'll have to reconsider how well-reasoned AOL users are. Who use Google because AOL terminated their news service - because of Google. Smart move, eh? From lists at cheimes.de Wed Apr 30 15:19:38 2008 From: lists at cheimes.de (Christian Heimes) Date: Wed, 30 Apr 2008 21:19:38 +0200 Subject: Python 2.6 and wrapping C libraries on Windows In-Reply-To: References: Message-ID: L. Lindstrom schrieb: > I have read that Python extension modules must link to the same C > run-time as the Python interpreter. This I can appreciate. But does this > requirement extend to the C libraries an extension module wraps. The > case in point is Pygame and SDL. The Pygame extension modules are built > with distutils, so for Python 2.6 using Visual Studio 2008 should ensure > the .pyd files link to msvcr90.dll. But SDL is built using Msys/MinGW > and the configure/make tool chain. This fails when linking to > msvcr90.dll since the small test programs configure builds lack manifest > files. They fail to load msvcr90.dll, raising an R6034 error instead. So > besides heap management and FILE pointers, is there any reason SDL, or > any C dependency, needs to link to the same C run-time as Python? If I > ensure SDL frees memory it allocates and does not directly access a file > opened by Python can I just use another C run-time such as msvcrt? > Your analysis of the problem and the implication of mixing CRTs is correct. However ... It should be trivial to modify the build systemof SDL so that the manifest is integrated into the DLLs. Everything else is a hack. It *should* work and in reality it *does* work for most cases. But someday you'll hit a solid wall and get strange and hard to debug segfaults. It's in your own interest to get it right in the first place. And you'd serve the Python community greatly by providing a nice tutorial how to modify 3rd party builds. *hint* :) If you need any help feel free to contact me. The new build system is mostly my work with help from Martin, Amaury and other core developers. Christian From mattheww at chiark.greenend.org.uk Sun Apr 20 13:13:39 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 20 Apr 2008 18:13:39 +0100 (BST) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> <4d543ba1-c601-4490-8739-e42b46fc2236@k37g2000hsf.googlegroups.com> Message-ID: Arnaud Delobelle wrote: > By 'eval', I guess you mean 'exec' :) Yes. Shows how often I use either. -M- From ott.deb at gmail.com Thu Apr 17 15:07:14 2008 From: ott.deb at gmail.com (ott.deb at gmail.com) Date: Thu, 17 Apr 2008 12:07:14 -0700 (PDT) Subject: movie collector crack Message-ID: movie collector crack http://cracks.12w.net F R E E C R A C K S From deets at nospam.web.de Tue Apr 15 09:13:44 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 15 Apr 2008 15:13:44 +0200 Subject: hw to program on python References: <2732d09a-b0e6-4ae6-a826-9fa375fb3e86@q10g2000prf.googlegroups.com> Message-ID: <66jo14F2jfjnbU1@mid.uni-berlin.de> ashish wrote: > hi , > python experts i want some help from u people just mail me how to > write scripts for web applications (like form coding for login page, > etc). > > > i m waiting.... for ur reply by While you are waiting, would a nice back-rub & and a good portion of powder sugar gently blown up your behind be in order? I'd plain love to drop by & give that to you, to make the dreaded waiting for the amassing expert advice a bit more comfortable! Diez From Plemelle at comcast.net Wed Apr 2 21:57:31 2008 From: Plemelle at comcast.net (Paul Lemelle) Date: Wed, 02 Apr 2008 19:57:31 -0600 Subject: Pexpect question. References: Message-ID: Jorgen, Thanks for your reply. The ssh function is just a small part of what I would like to accomplish. And yes, chk is undefined, I was trying to figure out why control was not being returned from the sshcon funciton. I looked for pexpect doucment on http://www.noah.org/wiki/Pexpect, but the documentaiton link appear to be broken. Could you recommend another site? Thanks, Paul On 30 Mar 2008 21:39:46 GMT, Jorgen Grahn wrote: >On Fri, 28 Mar 2008 08:12:36 -0700 (PDT), Paul Lemelle wrote: >> I am trying separate a script that users pexpect into >> various functions within the same expect session. The >> problem is that the function does not return control >> back Main. > >I do not understand what that sentence means. > >> Any insight into this issue would be >> greatly appreciated. Below is sample code of the >> problem. > >First, what is the purpose of this program? It seems to be a more >tedious way to get an ssh login to some Unix host. Ssh can be >configured to do many things; maybe you do not need Python at all? > >Second, it will fail as soon as you use the undefined object 'chk'. > >Third, if "not return control back Main" means "sshcon() does not >return", then it is by design. You call go.interact(), which hands >over control to the user until he types an escape sequence. See the >pexpect documentation. > >Fourth, sshcon() does not handle the full dialogue ssh can give you. >If you get "are you sure you want to connect" etc, you will hang until >pexpect.TIMEOUT is thrown. > >I have reformatted the source code to be more readable: > >> import pexpect >> >> def sshcon(host, password): >> go = pexpect.spawn ('/usr/bin/ssh -l root %s ' % host) >> go.expect ('Password: ') >> go.sendline (password) >> go.interact() >> >> #get node info for both clusters. >> C1_node = raw_input("Enter the ip address for node on cluster 1: ") >> C1_pass = raw_input("Enter the password for the node on cluster 1: ") >> >> sshcon(C1_node, C1_pass) >> >> #go to the path >> chk.expect('# ') >> chk.sendline('ls') >> >> chk.interact() > >/Jorgen From Dodin.Roman at gmail.com Fri Apr 25 05:32:36 2008 From: Dodin.Roman at gmail.com (hellt) Date: Fri, 25 Apr 2008 02:32:36 -0700 (PDT) Subject: Little novice program written in Python References: <0cecfed4-17e7-4e4d-9dbe-3f0ac8316c1f@y21g2000hsf.googlegroups.com> Message-ID: On 25 ???, 13:29, Arnaud Delobelle wrote: > hellt writes: > > my variant of the sieve > > Since you posted it, you are also looking for advice to improve your > code ;) > > > def GetPrimes(N): > > arr = [] > > for i in range(1,N+1): > > arr.append(i) > > This is the same as: > arr = range(1, N+1) > !-) > > > #Set first item to 0, because 1 is not a prime > > arr[0]=0 > > #sieve processing > > s=2 > > remove this line > > > while s < math.sqrt(N): > > for s in xrange(2, int(math.sqrt(N))+1): > > > if arr[s-1] != 0: > > if arr[s-1]: > > > j = s*s > > remove this line > > > while j <= N: > > for j in xrange(s*s, N+1, s): > > > arr[j-1] = 0 > > j += s > > remove this line > > > s += 1 > > remove this line > > > return [x for x in arr if x != 0] > > return filter(None, arr) > > Altogether now: > > def getprimes(N): > arr = range(1, N+1) > arr[0] = 0 > for s in xrange(2, int(math.sqrt(N))+1): > if arr[s-1]: > for j in xrange(s*s, N+1, s): > arr[j-1] = 0 > return filter(None, arr) > > It's the same, but it looks a bit less like the litteral translation > of some C code. > > Lastly, the lines: > > for j in xrange(s*s, N+1, s): > arr[j-1] = 0 > > from above can be condensed using extended slices: > > arr[s*s-1 : N+1 : s] = [0] * (N/s - s + 1) > > (If I can count correctly) > > Giving the following, slightly shorter and probably faster: > > def getprimes(N): > arr = range(1, N+1) > arr[0] = 0 > for s in xrange(2, int(math.sqrt(N))+1): > if arr[s-1]: > arr[s*s-1 : N+1 : s] = [0] * (N/s - s + 1) > return filter(None, arr) > > If it was me, I would include 0 in the array, giving the slightly simpler: > > def getprimes(N): > arr = range(N+1) > arr[1] = 0 > for s in xrange(2, int(math.sqrt(N))+1): > if arr[s]: > arr[s*s : N+1 : s] = [0] * (N/s - s + 1) > return filter(None, arr) > > (I think) > > This all needs to be tested. > > -- > Arnaud nice, but i'm a newbie to python too, so some things for me seems a liitle complicated))) From dolloffdelvpg at gmail.com Wed Apr 16 08:10:10 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:10:10 -0700 (PDT) Subject: songs by taylor swift Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From bskaplan14 at yahoo.com Wed Apr 23 05:41:21 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Wed, 23 Apr 2008 02:41:21 -0700 (PDT) Subject: [Python 2.4/2.5] subprocess module is sorely deficient? Message-ID: <811891.72800.qm@web39208.mail.mud.yahoo.com> I don't know about all Linux distros, but my Ubuntu machine (8.04 Beta), has the 'TERM' (xterm) and 'COLORTERM' (gnome-terminal) keys in os.environ. You might be able to use that to ensure that the terminal is installed, but you should probably look at a couple of other popular distros first to make sure that the key is there. ----- Original Message ---- From: Harishankar To: python-list at python.org Sent: Wednesday, April 23, 2008 5:31:54 AM Subject: Re: [Python 2.4/2.5] subprocess module is sorely deficient? On Wednesday 23 Apr 2008 14:46:20 Christian Heimes wrote: > Harishankar schrieb: > > Is there any platform independent way to launch a terminal window from a > > desktop (Windows, Linux, etc.)? > > No, there isn't. It usually not possible to create a graphical terminal > window on a remote server. > > Christian Ah, well, since my application is a desktop tool and it requires a GUI I'm doing something like this: However, I have to then force the user to use xterm (which is a popular/common X Terminal) if (sys.platform.startswith ('win'): # launch the windows cmd.exe with the command ... else: # warn the user that xterm is required and then launch xterm ... -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org -- http://mail.python.org/mailman/listinfo/python-list ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From casey.mcginty at gmail.com Tue Apr 22 06:36:57 2008 From: casey.mcginty at gmail.com (Casey McGinty) Date: Tue, 22 Apr 2008 00:36:57 -1000 Subject: Getting PyUnit to run Package Test Modules In-Reply-To: References: Message-ID: I came up with this solution based off of the __import__ python reference page. If I missed anything let me know. def suite(): # create TestSuite object alltests = unittest.TestSuite() # load all modules define in the module list for name in mod_to_test: print name mod = __import__(name) components = name.split('.') for comp in components[1:]: print comp mod = getattr(mod,comp) alltests.addTest(unittest.findTestCases(mod)) return alltest On Tue, Apr 22, 2008 at 12:12 AM, Casey McGinty wrote: > Hopefully this is an easy question for someone to answer. I have a > directory structure like so: > > alltest.py > prog.py > ../package > __init__.py > mod1.py > test_mod1.py > modn. py > (and so on...) > > Each test_mod*.py file contains some PyUnit test cases. I am using the > following code in alltest.py to run all the unit test modules: > > mod_to_test = [package.mod1, package.mod2] > > def suite(): > # create TestSuite object > alltests = unittest.TestSuite() > # load all modules define in the module list > for module in map(__import__, mod_to_test): > alltests.addTest(unittest.findTestCases(module)) > return alltest > > if __name__ == '__main__': > unittest.main(defaultTest='suite') > > My guess is there is something needed in __init__.py to get this work. Any > advice? > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eyal.teutsch at gmail.com Thu Apr 24 01:47:52 2008 From: eyal.teutsch at gmail.com (Eyal Teutsch) Date: Thu, 24 Apr 2008 08:47:52 +0300 Subject: couple of optparse questions Message-ID: <2b72fcea0804232247v1ee699e2h57e9bdd38d35ea6e@mail.gmail.com> I have a bunch of command line scripts which I would like them to partially share command line options. For the sake of example, let's say I have the following 2 scripts: monitor_io.py - accepts 'interval' and 'disk' arguments: monitor_io.py -i 30 -d disk1 monitor_processes.py - accepts 'interval' and '# of procesess' arguments: monitor_processes.py -i 15 -n 8 So what I would like to do, is to have a shared command line parser (let's call it parser.py) that would selectively use the parser.add_option calls according to the arguments that were passed to it when it was instantiated by the above command line scripts. So, in monitor_io.py, the parser would be instantiated as follows: parsamon = parse(['interval', 'disk']) and in parser.py, I would have a dictionary of all possible options: self.options['interval'] ='"-c", action="callback", dest="interval", type="int", callback=self.verify_type, callback_kwargs={"action":"int"}, help="the execution interval"' # does not work and then selectively add specific options to the parser according to the arguments passed to parser.py, for instance: parser.add_option(self.options['interval']) The above though wouldn't work as what seems to me a quotation error. The following, would actually work: self.options['interval']='-c' while this one here would not: self.options['interval']='-c, action="store_true"' # does not work it terminates with the following error: optparse.OptionError: invalid long option string '-c, action="store_true"': must start with --, foll owed by non-dash It would accept though a double-dash (which isn't what I want): self.options['interval']='--c, action="store_true"' # works but then again, the full option using a double dash, would not work: self.options['interval']='"--c", action="callback", dest="interval", type="int", callback=self.verify_type, callback_kwargs={"action":"int"}, help="the execution interval"' # does not work optparse.OptionError: invalid long option string '"--c", action="callback", dest="mint_interval", ty pe="int", callback=self.verify_type, callback_kwargs={"action":"int"}, help="the mint interval"': mu st start with --, followed by non-dash So, my first question is how to accomplish the above task? My second question is that I found the fact that optparse returns the values as properties of the object rather than returning a dictionary with all parsed options a bit inconvenient, as the latter approach would offer convenient ways to iterate/verify the parsed arguments returned. Any thoughts on this? Thanks.. -------------- next part -------------- An HTML attachment was scrubbed... URL: From andre.roberge at gmail.com Tue Apr 1 17:28:35 2008 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Tue, 1 Apr 2008 14:28:35 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <47f27a74$0$20512$426a74cc@news.free.fr> Message-ID: <0236d0aa-de8c-4636-a1d8-300d5d8e1818@i29g2000prf.googlegroups.com> On Apr 1, 3:09 pm, Bruno Desthuilliers wrote: > sprad a ?crit : > > > > > I'm a high school computer teacher, and I'm starting a series of > > programming courses next year (disguised as "game development" classes > > to capture more interest). The first year will be a gentle > > introduction to programming, leading to two more years of advanced > > topics. > > > I was initially thinking about doing the first year in Flash/ > > ActionScript, and the later years in Java. My reasoning is that Flash > > has the advantage of giving a quick payoff to keep the students > > interested while I sneak in some OOP concepts through ActionScript. > > Once they've gotten a decent grounding there, they move on to Java for > > some more heavy-duty programming. > > > I've never used Python, but I keep hearing enough good stuff about it > > to make me curious. > > > So -- would Python be a good fit for these classes? > > IMHO, yes, definitively - except that it won't introduce concepts like > static typing and primitive types, since it's dynamically typed and 100% > object. OTHO, it'll let you introduce quite a lot of more advanced > topics (operator overloading, metaclasses, higher-order functions, > closures, partial application etc) that you're less likely to grasp > using Java. > > > Could it equal > > Java as the later heavy-duty language? > > If you mean "is it possible to use Python to write real-world, > non-trivial applications", then the answer is obviously yes. Python's > use range from Q&D admin script to full-blown web application server > including vector graphic GUI apps, scientific data analysis and plotting > and game developpment and/or scripting. > > > Does it have enough quickly- > > accessible sparklies to unseat Flash? > > Since you plan to lure poor schoolboys in by pretending to teach them > game programming, you may want to have a look at pygame: > > http://www.pygame.org/news.html > > > I want to believe. Evangelize away. > > "Then I saw Pygame, now I'm a believer".... !-) There is also pyglet which is quite impressive and easy to use. Andr? From steve at holdenweb.com Tue Apr 8 18:22:55 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 18:22:55 -0400 Subject: Converting a tuple to a list In-Reply-To: <00ba01c899c5$14528ae0$0a01a8c0@mobile> References: <00ba01c899c5$14528ae0$0a01a8c0@mobile> Message-ID: Gabriel Ibanez wrote: > Hi all .. > > I'm trying to using the map function to convert a tuple to a list, without > success. > > I would like to have a lonely line that performs the same as loop of the > next script: > > ------------------------------------------- > # Conveting tuple -> list > > tupla = ((1,2), (3,4), (5,6)) > > print tupla > > lista = [] > for a in tupla: > for b in a: > lista.append(b) > print lista > ------------------------------------------- > > Any idea ? > > Thanks ... > > # Gabriel > list(tupla) would probably do it. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From mail2spj at yahoo.com Fri Apr 18 16:42:28 2008 From: mail2spj at yahoo.com (SPJ) Date: Fri, 18 Apr 2008 13:42:28 -0700 (PDT) Subject: Error with win32com client on windows 2003 server Message-ID: <867065.32400.qm@web50107.mail.re2.yahoo.com> I got the reason for why this is happening. MS office is not installed on that server. Thanks anyways.. SPJ ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ From claird at lairds.us Tue Apr 29 11:46:30 2008 From: claird at lairds.us (Cameron Laird) Date: Tue, 29 Apr 2008 15:46:30 +0000 Subject: Who makes up these rules, anyway? (was: Python-URL! - weekly Python news and links (Apr 28)) References: Message-ID: In article , Gabriel Genellina wrote: . . . > Explicit variable declaration for functions: > >http://groups.google.com/group/comp.lang.python/browse_thread/thread/6c4a508edd2fbe04/ . . . A reader notes that this thread actually lived during 2004 (!) (entirely during January 2004, in fact), and mildly questions its pertinence to what bills itself as "weekly Python news ..." Well might the reader wonder. "Python-URL!" has long chosen to err on the side of INclusiveness in its categorizations, even to the occasional point of apparent frivolity. As Harlan Ellison used to advise his readers, think of it as a bonus, rather than a mistake. It's our tradition, too. From george.sakkis at gmail.com Sun Apr 20 19:02:26 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Sun, 20 Apr 2008 16:02:26 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> <48a1d10c-87cb-43c3-83f4-9c331fc1d818@m1g2000pre.googlegroups.com> Message-ID: On Apr 20, 6:54?pm, Dan Bishop wrote: > On Apr 20, 11:42 am, Matthew Woodcraft > > > > wrote: > > Christian Heimes ? wrote: > > > >> I feel that including some optional means to block code would be a big > > >> step in getting wider adoption of the language in web development and > > >> in general. ?I do understand though, that the current strict indenting > > >> is part of the core of the language, so... thoughts? > > > Why should Python repeat the mistakes other languages did with SSI or > > > inline code? Python favors the MVC separation of code and layout. > > > An alternative scheme for describing the block structure could be > > useful in other cases, though. For example, if you wanted to support > > putting snippets of Python in configuration files, or spreadsheet > > cells. > > > There's no need to support the new scheme in .py files, so it seems to > > me that this doesn't have to be done in the core language. All that's > > needed is a variant of 'eval' which expects the alternate scheme, and > > that could be prototyped just using text manipulation and the normal > > 'eval'. > > We wouldn't even need that. ?Just a new source encoding. ?Then we > could write: > > # -*- coding: end-block -*- > > def _itoa(num, base): > """Return the string representation of a number in the given base.""" > if num == 0: > return DIGITS[0] > end if > negative = num < 0 > if negative: > num = -num > end if > digits = [] > while num: > num, last_digit = divmod(num, base) > digits.append(DIGITS[last_digit]) > end while > if negative: > digits.append('-') > end if > return ''.join(reversed(digits)) > end def A great example of why something like this would never fly in standard Python. From Vern.Muhr at gmail.com Mon Apr 28 14:26:52 2008 From: Vern.Muhr at gmail.com (VernM) Date: Mon, 28 Apr 2008 11:26:52 -0700 (PDT) Subject: cytpes **int Message-ID: <56674130-c04e-403e-8364-92cbd158b2f0@b9g2000prh.googlegroups.com> I am using ctypes to wrap a set of functions in a DLL. It has been going very well, and I am very impressed with ctypes. I want to call a c function with a signature of: void func(int **cube), where the array if ints in cube is modified by func. I want to setup cube with int values, and access them after the call to func. I unerstand how to setup the ctypes array, but how do I pass **cube to the function, and how do I access the results? From db3l.net at gmail.com Sun Apr 27 22:00:17 2008 From: db3l.net at gmail.com (David Bolen) Date: Sun, 27 Apr 2008 22:00:17 -0400 Subject: [py2exe] What to download when updating? References: Message-ID: Gilles Ganault writes: > Hello > > Out of curiosity, if I recompile a Python (wxPython) app with > py2exe, can I have customers just download the latest .exe, or are > there dependencies that require downloading the whole thing again? It will depend on what you changed in your application. The most likely file that will change is your library.zip file since it has all of your Python modules. I believe that with py2exe the main exe is typically a standard stub, so it need not change, but it can if the top level script is named differently since it has to execute it. The other files are binary dependencies, so you may add or remove them during any given build process depending on what modules you may newly import (or have removed the use of). In the end, you could in theory just compare the prior version distribution tree to the new version is simplest. But then you'd need to package up an installer that did the right thing on the target system. To be honest, just packaging it up as a new version and putting it into a standard installer (as with InnoSetup or NSIS) and letting the installer keep track of what to do when installing the new version on top of an existing version is generally simplest overall, albeit larger. But during internal development or other special cases, I've definitely just distributed updated library.zip files without any problem. -- David From michael at stroeder.com Tue Apr 22 17:14:28 2008 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Tue, 22 Apr 2008 23:14:28 +0200 Subject: python-ldap: searching without specifying an OU? In-Reply-To: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> References: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> Message-ID: hotani wrote: > I am attempting to pull info from an LDAP server (Active Directory), > but cannot specify an OU. In other words, I need to search users in > all OU's, not a specific one. If the user you're binding with has the right in AD to search the whole subtree you can start searching at the domain-level. > con = ldap.initialize("ldap://server.local") > con.simple_bind_s('user at domain', pass) ^^^^^^^^^^^^ Just for the records: A simple bind with userPrincipalName only works on AD. It's not a LDAPv3 compliant bind request then (which requires a full DN). > result = con.search_ext_s( > 'OU=some office, DC=server, DC=local', > ldap.SCOPE_SUBTREE, > "sAMAccountName=username", ['mail'] > )[0][1] > > for i in result: > print "%s = %s" (i, result[i]) > > But i really need it to not require an OU. It should work. I'm doing this quite often. > When I remove that part, it breaks. What does "it breaks" mean? Any exception raised by python-ldap? > Maybe a different search function? Nope. Ciao, Michael. From sisson.j at gmail.com Mon Apr 14 15:40:57 2008 From: sisson.j at gmail.com (J Sisson) Date: Mon, 14 Apr 2008 14:40:57 -0500 Subject: How to make python run faster In-Reply-To: References: <0baa301a-ec8c-48ef-b30e-f9c80f72e5af@u12g2000prd.googlegroups.com> Message-ID: <4297a9020804141240s7098cd3g381e296dade11a72@mail.gmail.com> 2008/4/14 : > On Apr 14, 8:48 am, ??? wrote: > > > But, it is still not as fast as 1. > > > So if speed is the #1 design goal, use pure C. If not, develop in > pure Python and, if the application is too slow, profile the code and > look for bottlenecks that can be optimized. There's a good chance > that they can be resolved algorithmically, not by simply dropping down > to C. > -- > http://mail.python.org/mailman/listinfo/python-list > Profiling python code can help spot bottlenecks that would *still be bottlenecks* if translated directly to C, so I definitely agree here...given a big enough problem space, a bad algorithm will run slow(er) regardless of language or hardware. -- Computers are like air conditioners... They quit working when you open Windows. -------------- next part -------------- An HTML attachment was scrubbed... URL: From antroy at gmail.com Mon Apr 21 08:14:13 2008 From: antroy at gmail.com (Ant) Date: Mon, 21 Apr 2008 05:14:13 -0700 (PDT) Subject: Somebody *really* got fond of python References: <673bprF2n44icU1@mid.uni-berlin.de> Message-ID: On Apr 21, 12:23 pm, "Diez B. Roggisch" wrote: > http://xkcd.com/413/ > > :) Didn't realise you'd posted this when I posted my "Batteries Included..." post. Amused me as well! From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 22 11:18:35 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 22 Apr 2008 17:18:35 +0200 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: <1510fd01-5e13-4124-a3fe-ff69d9011ebb@d1g2000hsg.googlegroups.com> References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <6760jfF2n3bn1U1@mid.uni-berlin.de> <6bec3c67-689a-4df2-848f-d3936a143024@f36g2000hsa.googlegroups.com> <1510fd01-5e13-4124-a3fe-ff69d9011ebb@d1g2000hsg.googlegroups.com> Message-ID: <480e01c2$0$24570$426a74cc@news.free.fr> Carl Banks a ?crit : > On Apr 22, 10:36 am, George Sakkis wrote: >> On Apr 22, 10:22 am, Carl Banks wrote: >> >>> Java (for example) allows a class to share behavior with only one >>> other class, and that *severely* limits the opportunities to minimize >>> redundancy. >> Not really; composition is usually a better way to share functionality >> and reduce redundancy than inheritance. > > I should have known this was coming. I disagree: inheritance is a > much better way to share behavior. > (snip) > With composition you're burdening the user with having to learn the > shared relationships that ought to be implementation details of the > class. E.g., > > obj.action_style.perform_action() > > With inheritance, the user doesn't have to worry about these > relationships. > > obj.perform_action() > (snip) Unless you use composition + delegation (which is a PITA in Java and close to a no-brainer in Python). In which case this is mostly transparent to the user code. Anyway, in Python, inheritence is kind of a special case of composition+delegation. From theller at ctypes.org Thu Apr 3 07:21:13 2008 From: theller at ctypes.org (Thomas Heller) Date: Thu, 03 Apr 2008 13:21:13 +0200 Subject: State of ctypes Support on HP-UX? In-Reply-To: <200804031153.26234.phil@riverbankcomputing.com> References: <200804031153.26234.phil@riverbankcomputing.com> Message-ID: Phil Thompson schrieb: > Could somebody confirm how well ctypes is supported on HP-UX (for both PA-RISC > and Itanium) for both Python v2.4 and v2.5? > > I don't have access to an HP system and Google doesn't come up with a > definitive answer (which may just mean it works fine, but prior experience > with HP means I'd like more specific assurances). > > Thanks, > Phil I cannot answer your question, but if you want to try it out yourself there is the HP testdrive program: http://www.testdrive.hp.com/ Thomas From j.spies at hccnet.nl Thu Apr 10 05:54:52 2008 From: j.spies at hccnet.nl (Jaap Spies) Date: Thu, 10 Apr 2008 11:54:52 +0200 Subject: wrapping C functions in python In-Reply-To: References: <54b165660804091322w690e5e64x85c3d8f082b411b2@mail.gmail.com> Message-ID: <32a58$47fde3ed$d4785a98$31444@cache4.tilbu1.nb.home.nl> Paul Anton Letnes wrote: > Hi, and thanks. > > > However, being a newbie, I now have to ask: What is SWIG? I have heard > the name before, but haven't understood what it is, why I need it, or > similar. Could you please supply some hints? > [...] >>> >>> I am a "scientific" user of Python, and hence have to write some >>> performance >>> critical algorithms. Right now, I am learning Python, so this is a >>> "newbie" >>> question. >>> >>> I would like to wrap some heavy C functions inside Python, >>> specifically a >>> wavelet transform. I am beginning to become aquainted with the functions >>> PyArg_ParseTuple() and Py_BuildValue(). However, I am unable to >>> figure out >>> how to pass Python list -> C function or C array -> return value in >>> Python. >>> I manage to build and run the C function, print to screen, pass >>> string as >>> argument, return an int, etc. The thing which is missing is the magic >>> array/list... >>> >>> >>> Thanks in advance! I fart in your general direction. >>> Paul. Maybe you should have a look at Cython: http://www.cython.org/ and Sage: http://www.sagemath.org/ Jaap From hobgoodoreneyhb at gmail.com Tue Apr 22 11:38:57 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:38:57 -0700 (PDT) Subject: what is a keygen Message-ID: <9daad734-30de-47b3-888e-ec2811ee12cf@a22g2000hsc.googlegroups.com> what is a keygen http://cracks.12w.net F R E E C R A C K S From kamhung.soh at gmail.com Wed Apr 16 20:08:53 2008 From: kamhung.soh at gmail.com (Kam-Hung Soh) Date: Wed, 16 Apr 2008 17:08:53 -0700 (PDT) Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <66efcc2e-d806-4cb1-966c-178b41b183ba@d1g2000hsg.googlegroups.com> Message-ID: On Apr 17, 1:14 am, Mike Kent wrote: > On Apr 16, 10:26 am, Mike Driscoll wrote: > > > Yeah, I noticed that Google Groups has really sucked this week. I'm > > using the Google Groups Killfile for Greasemonkey now and it helps a > > lot. I like Google, but my loyalty only goes to far. This is a > > complete lack of customer service. > > > Mike > > Bless you. I just installed Greasemonkey and the Google Groups > Killfile. Works like a charm. I manually edit the REs in the GGK's kill file variable (use Firefox about:config and filter for "kill") and enable case-insensitive search (open the script, search for "compile()" and add a second parameter "i"). (Posted via GG, but I'm open to an alternative web-based Usenet service.) -- Kam-Hung Soh Software Salariman From billingspanshism at gmail.com Sat Apr 19 17:16:51 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:16:51 -0700 (PDT) Subject: victoria beckham quotes Message-ID: <1b355dce-84cf-4b27-afed-caa51fc7c4ac@k37g2000hsf.googlegroups.com> Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From bruno.42.desthuilliers at websiteburo.invalid Mon Apr 21 07:26:24 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Mon, 21 Apr 2008 13:26:24 +0200 Subject: Opposite of repr() (kind of) In-Reply-To: References: Message-ID: <480c79e0$0$5045$426a74cc@news.free.fr> Guillermo a ?crit : > Hi there, > > How can I turn a string into a callable object/function? Depends on what's in your string. > I have a = 'len', and I want to do: if callable(eval(a)): print > "callable", but that doesn't quite work the way I want. :) Works here: Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a = "len" >>> callable(eval(a)) True >>> From mattheww at chiark.greenend.org.uk Sun Apr 20 14:22:07 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 20 Apr 2008 19:22:07 +0100 (BST) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: Terry Reedy wrote: > But you do not really need a variant. Just define a preprocessor > function 'blockify' which converts code in an alternate syntax to > regular indented block syntax. Then > > exec(blockify(alt_code_string)) You can do it like that, but if it were to become part of the standard distribution it would be nice to avoid having to tokenise the code twice. (You could define the new block scheme in such a way that 'blockify' doesn't need to tokenise, but I think it would end up a bit ugly.) -M- From triplezone3 at yahoo.co.uk Sat Apr 19 11:56:37 2008 From: triplezone3 at yahoo.co.uk (triplezone3) Date: Sat, 19 Apr 2008 16:56:37 +0100 (BST) Subject: urlretrieve can't send headers Message-ID: <378613.74223.qm@web26908.mail.ukl.yahoo.com> Hello. I'm using urllib.urlretrieve to download files, because it provides a handy hook function. Unfortunately, it won't let me send headers, which could be quite useful. Is there any way I could do this? __________________________________________________________ Sent from Yahoo! Mail. A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html From stanc at al.com.au Tue Apr 29 20:40:18 2008 From: stanc at al.com.au (Astan Chee) Date: Wed, 30 Apr 2008 10:40:18 +1000 Subject: simple chemistry in python In-Reply-To: <5e3717e5-1913-4bda-94b3-ae165e5fb8ba@m73g2000hsh.googlegroups.com> References: <5e3717e5-1913-4bda-94b3-ae165e5fb8ba@m73g2000hsh.googlegroups.com> Message-ID: <4817BFF2.9030907@al.com.au> Wow, that is the jackpot. Is that color node supposed to be the actual color of the element? or just representation? Thanks again Astan baoilleach wrote: > If you are familiar with parsing XML, much of the data you need is > stored in the following file: > http://bodr.svn.sourceforge.net/viewvc/*checkout*/bodr/trunk/bodr/elements/elements.xml?revision=34&content-type=text%2Fplain > > This file is part of the Blue Obelisk Data Repository, an effort by > several chemistry software developers to share common information. If > you have any further questions, please email blueobelisk- > discuss at lists.sf.net. > > Noel > > On Apr 29, 8:48 am, Astan Chee wrote: > >> Hi, >> Im looking for a python module to do simple chemistry things. Things >> like, finding the name of elements given the atomic number (and vice >> versa); what state the given matter is in depending on certain >> parameters; maybe even color of certain elements or even calculating the >> result of combining certain elements. >> I was looking for something simple, but everything I see seems to be a >> full blown chemistry set. >> I know I can probably spend a day doing this one element at a time, but >> I was wondering if there is already something like this done in a small >> scale? >> Thanks for any information >> Astan >> >> -- >> "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." >> >> Animal Logichttp://www.animallogic.com >> >> Please think of the environment before printing this email. >> >> This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. >> > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." Animal Logic http://www.animallogic.com Please think of the environment before printing this email. This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. -------------- next part -------------- An HTML attachment was scrubbed... URL: From skanemupp at yahoo.se Tue Apr 15 19:45:24 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Tue, 15 Apr 2008 16:45:24 -0700 (PDT) Subject: tkinter, event.widget, what do i get? References: <7caa5089-2ea9-4e18-9117-7431d7403976@l42g2000hsc.googlegroups.com> Message-ID: <3a6f6d87-0102-4995-a033-501137b3f934@s50g2000hsb.googlegroups.com> On 16 Apr, 00:24, "Gabriel Genellina" wrote: > En Tue, 15 Apr 2008 17:45:08 -0300, escribi?: > > > when calling function hmm here, what do i get? the widget i clicked > > on? > > if i have a canvs on wich i have a bitmap and i click on the bitmap, > > is the event.widget then the bitmap? > > can i get info about the bitmap then? like color of the pixel i > > clicked. if so, how? > > > w.bind("", key) > > w.bind("", hmm) > > > def hmm(event): > > return event.widget > > Why don't you try by yourself? You can use: print repr(something) > > -- > Gabriel Genellina i get thing is i get that even though i click outside the image. and what can i do with this number anyway? From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 18 05:28:36 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 18 Apr 2008 11:28:36 +0200 Subject: Can't do a multiline assignment! In-Reply-To: <98406333-c7c0-4b98-845d-c18895644c4a@t54g2000hsg.googlegroups.com> References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <1952579a-3cfb-44ea-92aa-658daa64aee4@a70g2000hsh.googlegroups.com> <564dd82b-8670-4ead-a3c8-a22b30a3eb73@m73g2000hsh.googlegroups.com> <98406333-c7c0-4b98-845d-c18895644c4a@t54g2000hsg.googlegroups.com> Message-ID: <480869ac$0$18253$426a74cc@news.free.fr> s0suk3 at gmail.com a ?crit : > On Apr 17, 12:34 pm, Michael Torrie wrote: >> Another thing to consider is that referencing a member of a class or >> instance already *is* a dictionary lookup. It's how python works. Thus >> dictionaries are optimized to be fast. Since strings are immutable, >> python hashes them into a fast lookup pointer. So every time you say >> mydict["mykey"], it already knows the lookup pointer (hash) for "mykey" >> (the string) and can find the dictionary entry very quickly, ideally in >> O(1) time (well maybe log(N)). Thus putting your headers in a >> dictionary is actually a really good idea for performance reasons. > > I didn't know about that, thanks. So after all the trouble I went > through writing those 200 loc I actually maid it worse... That's an understatement. From bruno.desthuilliers at gmail.com Mon Apr 7 08:08:59 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Mon, 7 Apr 2008 05:08:59 -0700 (PDT) Subject: while-loops enter the last time after condition is filled? References: Message-ID: <547d0b90-deb8-4342-a1f1-72d3f08c6015@e39g2000hsf.googlegroups.com> On 6 avr, 01:53, skanem... at yahoo.se wrote: > it seems to me from my results that when i use a while-loop it will > execute once after the condition is met. > > ie the conditions is met the code executes one time more and then > quits. The problem is obviously in your code, but since you failed to post the minimal code exhibiting the problem, we can't help. From mslinn at mslinn.com Mon Apr 21 02:51:58 2008 From: mslinn at mslinn.com (Mike Slinn) Date: Sun, 20 Apr 2008 23:51:58 -0700 Subject: Elementtree find problem Message-ID: <480C398E.8020505@mslinn.com> The following short Python program parses a KML file and displays the names of all Marks and Routes: from elementtree.ElementTree import ElementTree tree = ElementTree(file='test.kml') kml = tree.getroot() ns = 'http://earth.google.com/kml/2.1' for folder in kml.findall("{%s}Folder/{%s}Folder/{%s}name" % (ns, ns, ns)): print folder.text I want to modify the program to ignore Marks, and print out the coordinates of each Route. Seems ElementTree v1.3 will make this task much easier, but unfortunately the CheeseShop and the Gentoo Portage repostitory only have v1.2.7 at this time. The following code is as close as I can get to what I want, but it doesn't run because I've attempted to use v1.3 syntax, ended up writing complete crap instead, and I can't understand the docs well enough for the v1.2.7 syntax. Perhaps someone can understand what I mean and give me a clue as to how to write this? from elementtree.ElementTree import ElementTree tree = ElementTree(file='test.kml') kml = tree.getroot() ns = 'http://earth.google.com/kml/2.1' for folders in kml.findall("{%s}Folder/{%s}Folder" % (ns, ns)): if folders["name"].text=='Routes': print folder.findall("{%s}LineString/{%s}coordinates" % (ns, ns)) Thanks, Mike From damonwischik at gmail.com Fri Apr 18 21:09:46 2008 From: damonwischik at gmail.com (damonwischik at gmail.com) Date: Fri, 18 Apr 2008 18:09:46 -0700 (PDT) Subject: How to print a unicode string? References: <87d4omsovf.fsf@benfinney.id.au> <4edea21e-d45c-4467-a66d-e270365eb812@l64g2000hse.googlegroups.com> <878wzasm10.fsf@benfinney.id.au> Message-ID: <072f2f58-2434-4848-9eb7-85033069d1f9@a22g2000hsc.googlegroups.com> On Apr 19, 1:53 am, Ben Finney wrote: > Damon Wischik writes: >> Why does it matter what locales my OS supports, when all I want is >> to set the encoding to be used for the output > > Because the Python 'locale' module is all about using the OS's > (actually, the underlying C library's) locale support. > > The locale you request with 'locale.setlocale' needs to be supported > by the locale database, which is independent of any specific > application, be it Python, Emacs, or otherwise. Let me try to ask a better question. It seems that the logical choice of locale (en_GB.utf8) is not supported by my operating system. Nonetheless, I want Python to output in utf-8, because I know for certain that the terminal I am using (Emacs 22.2.1 with python-mode) will display utf-8 correctly. It therefore seems that I cannot use the locale mechanism to indicate to Python the encoding I want for sys.stdout. What other mechanisms are there for me to indicate what I want to Python? Another poster pointed me to >> sys.stdout = codecs.getwriter("UTF-8")(sys.stdout) and this works great. All I want now is some reassurance that this is the most appropriate way for me to achieve what I want (e.g. least likely to break with future versions of Python, most in keeping with the design of Python, easiest for me to maintain, etc.). Damon. From stodge at gmail.com Fri Apr 18 08:44:43 2008 From: stodge at gmail.com (Stodge) Date: Fri, 18 Apr 2008 05:44:43 -0700 (PDT) Subject: SWIG (Python) - "no constructor defined" for concrete class Message-ID: Yet another SWIG question (YASQ!). I'm having a problem with using an abstract base class. When generating the Python bindings, SWIG thinks that all the concrete classes that derive from this abstract class are abstract too and won't create the correct constructor. Abstract class: [source lang="cpp"]class CORE_API Shape { public: virtual ~Shape() { nshapes--; }; double x, y; virtual void move(double dx, double dy); virtual double area(void) = 0; virtual double perimeter(void) = 0; static int nshapes; protected: Shape() { nshapes++; } }; [/source] Derived classes: [source lang="cpp"]class CORE_API Circle : public Shape { private: double radius; public: Circle(double r): Shape(), radius(r) { }; virtual double area(void); virtual double perimeter(void); }; class CORE_API Square : public Shape { private: double width; public: Square(double r): Shape(), width(r) { }; virtual double area(void); virtual double perimeter(void); }; [/source] SWIG file: [source lang="cpp"]class Shape { virtual void move(double dx, double dy); virtual double area(void) = 0; virtual double perimeter(void) = 0; }; class Circle: public Shape { Circle(double r); virtual double area(void); virtual double perimeter(void); }; class Square: public Shape { Square(double r); virtual double area(void); virtual double perimeter(void); }; [/source] C++ COde: [source lang="cpp"] Circle c(1.02); std::cout << "(c++)\t\tCircle\t" << c.area() << std::endl; Square s(9.20); std::cout << "(c++)\t\tSquare\t" << s.area() << std::endl; [/source] For some reason SWIG thinks that Circle and Square are abstract. Any ideas why? I'm rather confused by this. Thanks as always From m.zaki.mirza at gmail.com Mon Apr 14 03:55:06 2008 From: m.zaki.mirza at gmail.com (xakee) Date: Mon, 14 Apr 2008 00:55:06 -0700 (PDT) Subject: Game design : Making computer play References: Message-ID: <535ad4b4-afd6-4807-90e9-c1fa3eb48bc1@m36g2000hse.googlegroups.com> On Apr 14, 12:13?pm, v4vijayakumar wrote: > In computer based, two player, board games, how to make computer play? > Are there any formal ways to _teach_ computer, to choose best possible > move? > > I know this is kind of off-topic here. Please redirect me, if there > are more appropriate newsgroup. > > Many thanks. You should pick up some nice Artificial intelligence book and see for the game playing section. Most of them have it. Teaching the computer is almost like telling it all the possibilities. The actual teaching is telling the computer how to decide which possibility is the best. That is by using heuristics. All possibilities are normally represented as trees, one move leading to another. Then there is are pruning techniques, miny-maxy things where we deal with the concept of minimizing opponents gain and maximizing your own. So you design heuristics like that. (For example in the game of tic tac toe, there can be say 5 moves to be made, and the heuristic function is the number of moves a given player will win in.... and the computer calculates that its 4 for him and 3 for you for a certain move.... he will pick the next move with is maybe 3 for him and 4 for you and execute that move). This is a very simplistic application but this is how it goes. There are many searching heuristic based algorithms, some blind search algorithms etc. They are very important in game playing not just board ones but almost all of them. They are the foundation. So I would recommend you to open some elementary AI book. From ksterling at mindspring.com Thu Apr 24 05:19:46 2008 From: ksterling at mindspring.com (Ken) Date: Thu, 24 Apr 2008 05:19:46 -0400 Subject: function that accepts any amount of arguments? References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> Message-ID: "Steve Holden" wrote in message news:mailman.99.1209009225.12834.python-list at python.org... > globalrev wrote: >> if i want a function that can take any amount of arguments how do i >> do? >> >> lets say i want a function average that accepts any number of integers >> and returns the average. > > Use a parameter of the form *args - the asterisk tells the interpreter to > collect positional arguments into a tuple. Untested: > > def mean(*x): > total = 0.0 > for v in x: > total += v > return v/len(x) > think you want total/len(x) in return statement > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > From jared.grubb at gmail.com Wed Apr 23 21:08:44 2008 From: jared.grubb at gmail.com (Jared Grubb) Date: Wed, 23 Apr 2008 18:08:44 -0700 Subject: Partition list with predicate Message-ID: <925822270804231808n44c44ddbx213e936319ad1ed3@mail.gmail.com> I guess I forgot one requirement: the removed elements need to be remembered. Basically, I have a list of objects in a buffer, one class operates on some of the objects, but other classes use others. So, a class must extract the ones it can handle, and leave the rest in the buffer for the other classes to handle. I haven't found a function that will both remove objects from a list, but save the ones that do get removed. Jared On 23 Apr 2008, at 10:15, Tim Golden wrote: Jared Grubb wrote: I want a function that removes values from a list if a predicate evaluates to True. The best I could come up with is: Have a look at the itertools module, and the ifilter function in particular. TJG -- http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From rdh at new.rr.com Tue Apr 22 16:55:46 2008 From: rdh at new.rr.com (DataSmash) Date: Tue, 22 Apr 2008 13:55:46 -0700 (PDT) Subject: list manipulation Message-ID: <78158460-8508-4453-a2dc-c5814dda8839@59g2000hsb.googlegroups.com> Hello, I have a list that looks like this: roadList = ["Motorways","Local","Arterial"] I want to apply some code so that the output looks like this: "Motorways;Local;Arterial" ...in other words, I want each item in the list separated by a ';' and then the whole thing surrounded by quotes. How can this be done with the LEAST amount of code? I appreciate your help! R.D. From aldo at nullcube.com Sat Apr 5 07:25:16 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Sat, 5 Apr 2008 22:25:16 +1100 Subject: ANN: pry unit testing framework In-Reply-To: <38377121-8dc4-40b8-8a8f-868a2530530c@d1g2000hsg.googlegroups.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <38377121-8dc4-40b8-8a8f-868a2530530c@d1g2000hsg.googlegroups.com> Message-ID: <20080405112516.GA15684@nullcube.com> Thus spake Michele Simionato (michele.simionato at gmail.com): > > As far as the base unit testing functionality is concerned, I think > > they try to address similar problems. Both have assert-based testing > > with inspection and re-parsing of assert exceptions for better error > > messages. Both try to provide better fixture management. Both make > > programmatic test generation easier. Both have a command-line tool for > > running and gathering tests. > > > > I like nose, but I'm biased, and of course I think Pry has some > > advantages. One difference I'd point out is Pry's tree-based test > > structure, which provides a number of conveniences and features (much > > nicer test selection from the command line, for instance). Pry is also > > less than half the size of nose, and should therefore be simpler to > > extend and understand. > > You forgot to mention the important point that nose is compatible > with unittest and many developer (including myself) would consider > that a major selling point. That's true. If you have a body of tests that would be difficult to convert for some reason, that IS a big advantage. If, however, you plan to use any of nose's advanced features, you will be incompatible with unittest anyway, and you should feel free to consider competing suites like test.py and Pry. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From arnodel at googlemail.com Tue Apr 29 08:47:57 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Tue, 29 Apr 2008 05:47:57 -0700 (PDT) Subject: Given a string - execute a function by the same name References: Message-ID: <27f6ba19-8756-4d96-851f-2a7c585ef3c7@m44g2000hsc.googlegroups.com> On 29 Apr, 13:10, pyt... at bdurham.com wrote: > Bruno, > > Thank you for your detailed analysis. I learned a lot about Python > reading everyone's responses. > > For development I'm using #5: "globals().get("func")" because its > seamless to add additional functionality. > > But when I release into production I'm going to shift to #3: "Place all > my functions in dictionary and lookup the function to be called". This > technique will allow me to precisely control the dynamic nature of my > application. > > Thanks again to everyone who contributed on this thread. > > Regards, > Malcolm You could avoid #5 from the start using a decorator: functions = {} def register(func): functions[func.__name__] = func return func @register def foo(): print "Foo!" @register def bar(): print "Bar!" >>> functions {'foo': , 'bar': } >>> functions['bar']() Bar! -- Arnaud From banibrata.dutta at gmail.com Mon Apr 21 02:07:46 2008 From: banibrata.dutta at gmail.com (Banibrata Dutta) Date: Mon, 21 Apr 2008 11:37:46 +0530 Subject: Any reliable obfurscator for Python 2.5 In-Reply-To: <480B8C01.1080306@holdenweb.com> References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> <480b6133$0$34498$742ec2ed@news.sonic.net> <480B8C01.1080306@holdenweb.com> Message-ID: <3de8e1f70804202307p10539825sac6d861511937f85@mail.gmail.com> On 4/21/08, Steve Holden wrote: > > If it's important to you to be able to obfuscate your code then you have > made an inapposite choice of language. Cutting through all the smoke (thanks to the slight flame we had), this seems to be the answer that 'shines thorough'... if this is coming from an expert who knows the Language darn too well (and I don't doubt that Steve does), I'd take it. I'm a Noob with Python, and probably the question was a bit premature i.e. w/o enough research. Creation of 'pyc' in encrypted zip with a decrypting/embedded-interpreter launcher seems like an excellent work-around for what I need. I am not sure how many of you who are against obfuscation use Skype. I'd be glad to know. If you don't, I trust that you are a OSS zealot, and respect you for that. If you do, then you may be surprised to know that for the excellent functionality, ease-of-use and stability/robusness of communication it provides, it's one of the most closed-source software you could imagine. The strategic reasons for doing so are not too hard to imagine. Thanks to all for this response. BTW, I'm glad that I chose Python over few other available options. The community participation and response is quite fantastic. cheers. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gagsl-py2 at yahoo.com.ar Mon Apr 7 09:58:04 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 07 Apr 2008 10:58:04 -0300 Subject: Help replacing os.system call with subprocess call References: <47F9B1D1.4090701@eastlink.ca> <47F9C764.9070401@mattnordhoff.com> <47FA23E7.7040809@eastlink.ca> Message-ID: >> David Pratt wrote: >>> Hi. I am trying to replace a system call with a subprocess call. I have >>> tried subprocess.Popen and subprocess.call with but have not been >>> successful. The command line would be: >>> >>> svnadmin dump /my/repository > svndump.db En Mon, 07 Apr 2008 10:38:47 -0300, David Pratt escribi?: > The speed of this solution is slower than os.system. Would a queue of > some kind be needed to speed this up? Has anyone implemented something > like this? Many thanks. See the last post from Matt Nordhoff, where he calls Popen with stdout=an_open_file. This is the direct translation of ">outfile" in a shell, and faster because it doesn't involve Python processing. -- Gabriel Genellina From ch612bunn at gmail.com Sun Apr 27 09:14:43 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:14:43 -0700 (PDT) Subject: spyware doctor 5.0.5.259 crack Message-ID: spyware doctor 5.0.5.259 crack http://wga-cracks.crackkey.net From steve at holdenweb.com Thu Apr 10 12:58:49 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 10 Apr 2008 12:58:49 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> <47FCF421.6000807@holdenweb.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> Message-ID: Victor Subervi wrote: > Okay, here is where we find the fly in the ointment. If I run this code: > > #! /usr/bin/python > import MySQLdb > print "Content-type: image/jpeg\r\n" > host = 'mysqldb2.ehost-services.com ' > db = 'benobeno_bre' > user = 'benobeno' > passwd = '21122112' > connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > cursor = connection.cursor() > cursor.execute('select pic1 from products where id="2";') > content = cursor.fetchall()[0][0] > content = content.tostring() > print content > f = open("2.jpg", "w") > f.write(content) > f.close() > all is well :) If, however, I change two lines to make it an html page: > > #! /usr/bin/python > import MySQLdb > # print "Content-type: image/jpeg\r\n" > print "Content-type: text/html\n" > host = 'mysqldb2.ehost-services.com ' > db = 'benobeno_bre' > user = 'benobeno' > passwd = '21122112' > connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > cursor = connection.cursor() > cursor.execute('select pic1 from products where id="2";') > content = cursor.fetchall()[0][0] > content = content.tostring() > print '

' % content > # print content > f = open("2.jpg", "w") > f.write(content) > f.close() > it prints garbage. It does not yield the image. Now, what? > TIA. > Victor > Of course it prints garbage. Since you claim to understand HTML I have no idea what makes you expect that it would print anything else. That's because you are sending garbage to the browser instead of the HTML your content type promises. THE VALUE OF THE IMG TAG'S SRC ATTRIBUTE SHOULD BE THE URL OF AN IMAGE< NOT THE IMAGE ITSELF. Sorry, I don't normally shout like that. So pay attention when I do. First let's agree that what you are writing here is a web script to return an image, NOT a web page with an embedded image. So ... Now you formulate a correct response instead. You should NOT be returning a content type of text/html here, you should be returning a content type of image/jpeg. So your code should read #! /usr/bin/python import MySQLdb print "Content-type: image/jpeg\r\n" host = 'mysqldb2.ehost-services.com' db = 'benobeno_bre' user = 'benobeno' passwd = '21122112' connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor = connection.cursor() cursor.execute('select pic1 from products where id="2";') content = cursor.fetchall()[0][0] content = content.tostring() print content If you then direct your browser to the correct URL to access the output of this script you will see your image. When you want to see your image in the context of some HTML, write *another page* and you put the URL of the image inside it like this: as a reference to the image your script returns. I think you are on your own from here. If you follow instructions you should not need any further help. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From marexposed at googlemail.com Thu Apr 17 11:10:35 2008 From: marexposed at googlemail.com (marexposed at googlemail.com) Date: Thu, 17 Apr 2008 16:10:35 +0100 Subject: Unicode chr(150) en dash In-Reply-To: <48063434$0$36327$742ec2ed@news.sonic.net> References: <48063434$0$36327$742ec2ed@news.sonic.net> Message-ID: <20080417161035.bc123709.marexposed@googlemail.com> Thank you Martin and John, for you excellent explanations. I think I understand the unicode basic principles, what confuses me is the usage different applications make out of it. For example, I got that EN DASH out of a web page which states at the beggining. That's why I did go for that encoding. But if the browser can properly decode that character using that encoding, how come other applications can't? I might need to go for python's htmllib to avoid this, not sure. But if I don't, if I only want to just copy and paste some web pages text contents into a tkinter Text widget, what should I do to succesfully make every single character go all the way from the widget and out of tkinter into a python string variable? How did my browser knew it should render an EN DASH instead of a circumflexed lowercase u? This is the webpage in case you are interested, 4th line of first paragraph, there is the EN DASH: http://www.pagina12.com.ar/diario/elmundo/subnotas/102453-32303-2008-04-15.html Thanks a lot. On Wed, 16 Apr 2008 10:27:26 -0700 John Nagle wrote: > marexposed at googlemail.com wrote: > > Hello guys & girls > > > > I'm pasting an "en dash" > > (http://www.fileformat.info/info/unicode/char/2013/index.htm) character into > > a tkinter widget, expecting it to be properly stored into a MySQL database. > > > > I'm getting this error: > > ***************************************************************************** > > Exception in Tkinter callback Traceback (most recent call last): File > > "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__ return > > self.func(*args) File "chupadato.py", line 25, in guardar cursor.execute(a) > > File "C:\Python24\Lib\site-packages\MySQLdb\cursors.py", line 149, in execute > > query = query.encode(charset) UnicodeEncodeError: 'latin-1' codec can't > > encode character u'\u2013' in position 52: ordinal not in range(256) > > ***************************************************************************** > > Python and MySQL will do end to end Unicode quite well. But that's > not what you're doing. How did "latin-1" get involved? > > If you want to use MySQL in Unicode, there are several things to be done. > First, the connection has to be opened in Unicode: > > db = MySQLdb.connect(host="localhost", > use_unicode = True, charset = "utf8", > user=username, passwd=password, db=database) > > Yes, you have to specify both "use_unicode=True", which tells the client > to talk Unicode, and set "charset" to"utf8", which tells the server > to talk Unicode encoded as UTF-8". > > Then the tables need to be in Unicode. In SQL, > > ALTER DATABASE dbname DEFAULT CHARACTER SET utf8; > > before creating the tables. You can also change the types of > existing tables and even individual fields to utf8, if necessary. > (This takes time for big tables; the table is copied. But it works.) > > It's possible to get MySQL to store character sets other than > ASCII or Unicode; you can store data in "latin1" if you want. This > might make sense if, for example, all your data is in French or German, > which maps well to "latin1". Unless that's your situation, go with > either all-ASCII or all-Unicode. It's less confusing. > > John Nagle > -- > http://mail.python.org/mailman/listinfo/python-list From martin at v.loewis.de Tue Apr 22 14:21:11 2008 From: martin at v.loewis.de (=?ISO-8859-2?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 22 Apr 2008 20:21:11 +0200 Subject: py3k concerns. An example In-Reply-To: <87lk36e6po.fsf@mulj.homelinux.net> References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <480D71B9.40909@v.loewis.de> <87lk36e6po.fsf@mulj.homelinux.net> Message-ID: <480e2c97$0$24477$9b622d9e@news.freenet.de> >>> In py3k string%dictionary is going away. >> Why do you say that? It's not going away in Python 3.0. > > I also got the impression that it was going away. PEP 3101's abstract > says: > > This PEP proposes a new system for built-in string formatting > operations, intended as a replacement [sic] for the existing '%' > string formatting operator. > > Under "Backward compatibility" it says that both systems can coexist > "until it comes time to deprecate the older system". The PEP may say that it's going away, but it doesn't say that it goes away in 3.0 - and indeed, it won't. At some point in the future, somebody will likely propose that the PEP will be executed. At that time, huge flame wars will start. I expect that they settle in changing the PEP to explain that the old mechanism gets removed in Python 4, to be release in 2018 :-) Regards, Martin From mfb.chikazuku at gmail.com Wed Apr 9 15:38:09 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Wed, 09 Apr 2008 21:38:09 +0200 Subject: Stripping scripts from HTML with regular expressions Message-ID: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> Hey everyone, I'm trying to strip all script-blocks from a HTML-file using regex. I tried the following in Python: testfile = open('testfile') testhtml = testfile.read() regex = re.compile(']*>(.*?)', re.DOTALL) result = regex.sub('', blaat) print result This strips far more away then just the script-blocks. Am I missing something from the regex-implementation from Python or am I doing something else wrong? greetz MFB From sjmachin at lexicon.net Fri Apr 25 04:00:50 2008 From: sjmachin at lexicon.net (John Machin) Date: Fri, 25 Apr 2008 01:00:50 -0700 (PDT) Subject: Little novice program written in Python References: Message-ID: <49249992-3634-4c5f-bd45-7ce4f1b32044@l17g2000pri.googlegroups.com> On Apr 25, 5:44 pm, Robert Bossy wrote: > Peter Otten wrote: > > Rog?rio Brito wrote: > > >> i = 2 > >> while i <= n: > >> if a[i] != 0: > >> print a[i] > >> i += 1 > > > You can spell this as a for-loop: > > > for p in a: > > if p: > > print p > > > It isn't exactly equivalent, but gives the same output as we know that a[0] > > and a[1] are also 0. > > If the OP insists in not examining a[0] and a[1], this will do exactly > the same as the while version: > > for p in a[2:]: > if p: > print p > ... at the cost of almost doubling the amount of memory required. From steve at holdenweb.com Tue Apr 1 19:17:54 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 01 Apr 2008 19:17:54 -0400 Subject: Is this a good time to start learning python? In-Reply-To: References: <47f1140e$0$735$a729d347@news.telepac.pt> <88fa881e-e59b-4682-801c-90ef08a1480a@a22g2000hsc.googlegroups.com> <1565ced8-afd7-4c32-a6ee-26f9b95d60bc@d45g2000hsc.googlegroups.com> Message-ID: lbonafide at yahoo.com wrote: > On Apr 1, 2:42 pm, "Eduardo O. Padoan" > wrote: >> On Tue, Apr 1, 2008 at 4:20 PM, wrote: > >>> You misunderstand. C++ has a lot of "warts" to maintain backwards >>> compatibility with C. The standards committee could eliminate these >>> warts to make the language "cleaner", but it would break a lot of >>> systems. >> It would not "break" anything that not move from C to C++, this is my point. > > You missed the point completely. C++ has a new version coming out > soon, and as part of it, the less attractive parts of the language > (like C compatibility) are NOT being removed, as that would break a > lot of existing apps. > >> People not willing to take the migration path (porting to 2.6, using >> the -3 flag, refactoring and re-running the tests untill the warning >> are gone, using the 2to3 tool...) will not upgrade. No one will force >> you to do it. 2.6 will not desappear from the python.org site anytime >> soon. > > Will 2.6 be supported with patches and fixes going forward? Yes. About the only definite assertion Guido has so far made about the 2.x series is that it won't go further than 2.9, as he feels that 2.10 is ambiguous about its position in the series. You should expect at least three years of Python 2.X after the release of 3.0 (and the simultaneous release of 2.6) this August. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From arnodel at googlemail.com Tue Apr 29 02:08:54 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Tue, 29 Apr 2008 07:08:54 +0100 Subject: python script as executable References: Message-ID: sandipm writes: > Hi, > I have written a python script to run from cron. > I have put #!/usr/bin/env python at top. file executes correctly when > I run using python filename.py but > it fails to execute when try to run it like script/command. > it throws error: > :No such file or directory > > I am editing file from eclipse for python from windows. and then > uploading on linus machine to run it. > > > any pointers? Have you made your file executable (man chmod)? -- Arnaud From ptmcg at austin.rr.com Sat Apr 12 07:16:06 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Sat, 12 Apr 2008 04:16:06 -0700 (PDT) Subject: C to python conversion References: Message-ID: On Apr 12, 5:58?am, Michele Petrazzo wrote: > Hi all, > I'm trying to translate a simple C code into a python + ctypes (where > need), but I have some problems on char conversion. The code have > to work on Linux and talk with the serial port. I think that the problem > is that I don't translate correctly the strings. > > C code: > #define START 0x33 > #define RETURN_START 0x22 > #define ADDR 0x01 > #define WRITE_CMD 0x03 > #define ALL_CMD 0xFF > ... > char buf[10]; > char buf_ret[10]; > > buf[0]=0; > buf[0]=START; > buf[1]=ADDR; > buf[2]=WRITE_CMD; > > write(_fd, buf, 6); > read(_fd,buf_ret,6); > > It works > > python: > START = 0x33 > RETURN_START = 0x22 > ADDR = 0x01 > WRITE_CMD = 0x03 > ALL_CMD = 0xFF > > lib = C.CDLL('libc.so.6') > > items = [START, ADDR, WRITE_CMD] > buf = C.c_char * 10 > buffer_rec = buf() > buffer_send = buf(*items) > > (Here I receive: TypeError: one character string expected) > If I do: > chr(int()) of every value, it work, but: > > lib.write(fd, buffer_send, 6) > lib.read(fd, buffer_rec, 6) > > I stay there and block the program execution, until a CTRL+C > > What can I do? > > Thanks, > Michele Here are some differences between the C and Python programs: - the C program uses a separate buffer for reading and writing - the Python program uses buf for both - the C program *may* have null-filled the output buffer, I don't know what the Python buffer contains after the first 3 characters - in the Python program, items has only 3 characters to write; the C program has a buffer of 10 characters Here are some things to try in the Python program: items = [START, ADDR, WRITE_CMD] + [0]*7 inbuf = C.c_char * 10 outbuf = C.c_char * 10 buffer_rec = inbuf() buffer_send = outbuf(*items) -- Paul From uniontelecardsindia at gmail.com Tue Apr 22 17:12:11 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:12:11 -0700 (PDT) Subject: White masculine gay sucking two black cocks Message-ID: <42bcb0b7-7988-4fe2-9bea-08e60e7097f1@24g2000hsh.googlegroups.com> Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 15 04:06:21 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 15 Apr 2008 10:06:21 +0200 Subject: Dynamic use of property() fails In-Reply-To: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> Message-ID: <480461f8$0$20282$426a34cc@news.free.fr> andrew cooke a ?crit : > Hi, > > This is my first attempt at new classes and dynamic python, so I am > probably doing something very stupid... After reading the how-to for > descriptors at http://users.rcn.com/python/download/Descriptor.htm I > decided I would make an object that returns attributes on read, but on > setting calls an arbitrary function. > > My code looks like: > class ActiveDAO(object): > def __init__(self): > self.__values__ = {} __names__ are reserved for the Python implementation itself. Use _names for 'protected' attributes. > def add_field(self, name, value, on_change): > self.__values__[name] = value > def get(self): return self.__values__[name] > def set(self, new_value): self.__values__[name] = > on_change(new_value) > def delete(self): raise AttributeError > self.__dict__[name] = property(get, set, delete) > > However, when I try to use this (in a test) with code like: > dao = ActiveDAO() > dao.add_field("name", "value", lambda _: None) > assertEqual(dao.name, "value") > > I get a failure because lookup of the attribute is returning > "". > > That is quite reasonable, but I was under the expression that some > magic was supposed to happen, as described in the document referenced > above! > > Please can someone explain why there is no magic? :o( Others already answered this. The canonical solution is to use a custom descriptor instead of a property: class Field(object): def __init__(self, name, onchange): self.name = name self.onchange = onchange def __get__(self, instance, cls): if instance is None: # called on the class return self # called on instance return instance._values[self.name] def __set__(self, instance, value): instance._values[name] = self.onchange(value) class ActiveDAO(object): def __init__(self): self._values = [] class Person(ActiveDAO): name = Field('firstname', lambda v: v.strip().capitalize()) age = Field('age', lambda v : int(v)) Now you may want to search here or in the cookbook to learn how to: - dynamically create new classes - avoid having to repeat the name of the field (usually done using a metaclass and a two-stages initialisation of Field objects) HTH From kdoiron at sympatico.ca Mon Apr 7 15:49:58 2008 From: kdoiron at sympatico.ca (Kevin) Date: Mon, 7 Apr 2008 12:49:58 -0700 (PDT) Subject: Problem with smtplib and py2exe Message-ID: <3ff2767a-bbd8-4e0e-bbf4-3fa72bdca5e7@8g2000hsu.googlegroups.com> Hi everyone, I'm running Python 2.5.1 on an XP-Pro platform, with all the updates (SP2, etc) installed. I have a program (send_file.py) that sends a file to a service provider, using an ftp connection. The program works properly, and I've created an 'exe' of it, using py2exe. It was distrubuted to my user base a couple of weeks ago and seems to be working well. None of the users have Python installed on their machines, thus the need for an 'exe' for the program. I now need to add an email function to the program, to automatically send an email to a select user list when the program is completed. I've made the appropriate modifications to my code, and the program works properly when I run it from Python. When I try to make an exe out of my new program, however, I get the following error: Traceback (most recent call last): File "C:/Python25/send_ftp/setup.py", line 17, in console = [{"script": 'send_file.py'}] ) File "C:\Python25\lib\distutils\core.py", line 168, in setup raise SystemExit, "error: " + str(msg) SystemExit: error: command 'C:\Python25\pythonw.exe' failed with exit status 1 The 'setup.py' script is the same one I used to generate the 'exe' of the original program. The email-related code was added to my 'send_file.py' program as a function - it's not a separate module. If all of the changes are commented out, the py2exe function works. But as soon as I activate even the line "import smtplib", the py2exe process spits out the error above. If I put only the email portions of code in a test program, and run it from Python, it works, but if I try make an 'exe' out of the test program, I get the same error as above. Is there an inherent incompatibility between smtplib and py2exe? Does anyone have any ideas of how I can fix this problem? From tjreedy at udel.edu Wed Apr 9 17:35:48 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 9 Apr 2008 17:35:48 -0400 Subject: Basic optimization of python. References: Message-ID: "??" wrote in message news:cdb837ea0804062230y7efc2105x7523c05133a0bed7 at mail.gmail.com... | I wonder whether python compiler does basic optimizations to .py. In general, the answer to such questions depends on the implementation and version thereof. For CPython, you can look at bytecode with the dis module as another poster showed. | Again, how about contant calculation? | Eg: | a = 1 + 2 | .vs. | a = 3 This was added to CPython in version 2.5, I believe. From jcd at sdf.lonestar.org Tue Apr 29 15:03:23 2008 From: jcd at sdf.lonestar.org (J. Cliff Dyer) Date: Tue, 29 Apr 2008 15:03:23 -0400 Subject: Colors for Rows In-Reply-To: <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> <20080429121105.f10c3862.darcy@druid.net> <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> Message-ID: <1209495803.5173.11.camel@aalcdl07.lib.unc.edu> On Tue, 2008-04-29 at 13:14 -0500, Victor Subervi wrote: > On Tue, Apr 29, 2008 at 11:11 AM, D'Arcy J.M. Cain > wrote: > On Tue, 29 Apr 2008 09:33:32 -0500 > "Victor Subervi" wrote: > > why doesn't this work? > > > First, let me remove some blank lines to reduce scrolling. > > > z = 3 > > > > for d in (1,2,3,4,5,6): > > I changed id to a sequence so that the example actually runs. > Please > run your examples first and cut and paste them into the > message after > you are sure that it runs. > > Not sure what you mean here. The example runs. It prints out bgcolor="#ffffff"> every time. > > > > > z += 1 > > > > if z % 4 == 0: > > bg = '#ffffff' > > elif z % 4 == 1: > > bg = '#d2d2d2' > > elif z % 4 == 2: > > bg = '#F6E5DF' > > else: > > bg = '#EAF8D5' > > > > try: > > print '\n' % bg > > except: > > print '\n' > > > > It never increments z! Yet, if I print z, it will increment > and change the > > bgcolor! Why?! > > > I am not entirely sure what you are trying to do here. First, > what > error condition are you expecting in your try statement. > Second, don't > you want the print clause, with or without the try/except, in > the > loop. I assume that you want to print a line for each member > of your > sequence in alternating colours but this only prints for the > last one. > Try this: > > z = 3 > > for d in (1,2,3,4,5,6): > z += 1 > > if z % 4 == 0: > bg = '#ffffff' > elif z % 4 == 1: > bg = '#d2d2d2' > elif z % 4 == 2: > bg = '#F6E5DF' > else: > bg = '#EAF8D5' > > > print '' % bg, d > > Huh? You?re asking for one variable, then giving two! How?s that work? > Not quite. You're passing one variable to the string formatting operator, and passing a tuple to the print function. The implicit parenthesization is not print '' % (bg, d) as I think you are suggesting, but rather it is print ('' % bg), d > > > Or, tell us what you are trying to do. > > I think you understand. I want the row color to alternate, every > fourth row color being the same (or a series of 4) > > > > In fact, you can replace all the tests and the print statement > with > this after defining bg as a list of the four colours: > > print '' % bg[z % 4], d > > I tried that just for fun. It gave a bg of ?f?. Again, how are you > incorporating d? If you add that print line to end of your original code, then you'll get the z%4-th element of bg, which would be one character, because bg is a string, but if you "define bg as a list of the four colours" first, as instructed, you'll get sensible results: bg = ['#ffffff', '#b2b2b2', '#33FF66', '#000000'] for z in (0,1,2,3,4,5,6,7,8,9): print (' TIA, > Victor Cheers, Cliff From nick at craig-wood.com Fri Apr 25 08:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Fri, 25 Apr 2008 07:30:03 -0500 Subject: Little novice program written in Python References: Message-ID: Rog?rio Brito wrote: > I'm just getting my feet wet on Python and, just for starters, I'm coding some > elementary number theory algorithms (yes, I know that most of them are already > implemented as modules, but this is an exercise in learning the > language idioms). When you are up to speed in python I suggest you check out gmpy for number theory algorithms. Eg :- import gmpy p = 2 while 1: print p p = gmpy.next_prime(p) -- Nick Craig-Wood -- http://www.craig-wood.com/nick From timr at probo.com Sun Apr 13 18:55:18 2008 From: timr at probo.com (Tim Roberts) Date: Sun, 13 Apr 2008 22:55:18 GMT Subject: email module windows and suse References: Message-ID: <0j35041u36l70vhmov0uvfmv8ftp5npp2i@4ax.com> Lev Elbert wrote: > >I have to make a custom email module, based on the standard one. The >custom module has to be able to work with extremely large mails (1GB >+), having memory "footprint" much smaller. Then you have a design problem right from the start. It is extremely rare to find a mail server today that will transmit email messages larger than a few dozen megabytes. Even on a 100 megabit network, it's takes a minute and a half for a 1GB message to go from the server to the user's workstation. What are you really trying to do here? In most cases, you would be better off storing your attachments on a web server and transmitting links in the email. >The modified program has to work in SUSE environment, while the >development is done under Windows. I'm not too good with linux and do >not know if speedup in Windows translates one-to-one into speedup in >SUSE. For example, if the bottleneck is IO, in windows I can spawn a >separate thread or 2 to do "read-ahead". We would need more information on your processing to advise you on this. Disk I/O is slow, network I/O is slower. You can't go any faster than your slowest link. >Are threads available and as effective in SUSE as they are in Windows? Threads are available in Linux. There is considerable debate over the relative performace improvement. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Thu Apr 3 01:12:28 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 03 Apr 2008 05:12:28 GMT Subject: Why prefer != over <> for Python 3.0? References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> <87prt9coti.fsf@pobox.com> Message-ID: jjl at pobox.com (John J. Lee) wrote: > >How did programmers manage back then in 32k? Less software >development, more jigsaw puzzle. Yes, indeed. In response to a challenge posted on one of the x86 assembler newsgroups about two years ago, one intrepid Russian programmer produced a generic Sudoku solver in a 65-byte executable. Yes, that's 65 BYTES -- not KB, not MB. I consider myself an x86 assembler expert, but I remain in awe of that code. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From n00m at narod.ru Sun Apr 27 00:28:39 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 21:28:39 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> Message-ID: <8ee48fc1-45af-404f-8fad-d8e1b2fb90b4@s50g2000hsb.googlegroups.com> One more brick. This time I compare list.sort() vs sort(vector). Incredible. Python does it by 8.3s / 2.75s = 3 times faster than C++. import time f=open('D:\\v.txt','r') z=f.readlines() f.close() t=time.time() z.sort() print time.time()-t m=int(raw_input()) print z[m] #include #include #include #include #include #include #include using namespace std; vector vs; FILE *fp=fopen("D:\\v.txt","r"); int main() { int i=0; while (true) { char line[50]; if (!fgets(line,50,fp)) break; vs.push_back(line); ++i; } fclose(fp); double t; t=clock()/CLOCKS_PER_SEC; sort(vs.begin(),vs.end()); cout << clock()/CLOCKS_PER_SEC << endl; int m; cin >> m; cout << vs[m]; getchar(); return 0; } From jzgoda at o2.usun.pl Mon Apr 14 06:01:20 2008 From: jzgoda at o2.usun.pl (Jarek Zgoda) Date: Mon, 14 Apr 2008 12:01:20 +0200 Subject: pygtk + threading.Timer In-Reply-To: References: Message-ID: Dmitry Teslenko napisa?(a): > I have simple chat application with pygtk UI. I want some event (for > example update user list) to have place every n seconds. > What's the best way to archive it? > I tried threading.Timer but result is following: all events wait till > exit of gtk main loop and only then they occur. > Thanks in advance See gobject.timeout_add documentation in pygtk reference -- Jarek Zgoda Skype: jzgoda | GTalk: zgoda at jabber.aster.pl | voice: +48228430101 "We read Knuth so you don't have to." (Tim Peters) From cwitts at gmail.com Tue Apr 15 06:33:03 2008 From: cwitts at gmail.com (Chris) Date: Tue, 15 Apr 2008 03:33:03 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <1208196168.24295.36.camel@localhost.localdomain> <526792b1-acc2-4e48-8e9f-cc2641134958@k37g2000hsf.googlegroups.com> Message-ID: <732f1af2-ebae-4764-a40e-698ae1bde95f@h1g2000prh.googlegroups.com> On Apr 15, 11:47?am, Duncan Booth wrote: > Chris wrote: > > even is closer to even.75 than even+1.25. ?Why should it be rounded > > up ? > > Because the OP wants to round values to the nearest integer. Only values of > the form 'x.5' which have two nearest values use 'nearest even' to > disambiguate the result. > > Seehttp://en.wikipedia.org/wiki/Rounding#Round-to-even_method > > That's the way I was taught to round numbers when at primary school. My bad, didn't see he only wanted for halves and handle others as normal. From Lie.1296 at gmail.com Sun Apr 6 13:36:51 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 6 Apr 2008 10:36:51 -0700 (PDT) Subject: append to a sublist - please help References: <47f8f743$0$2983$ba620e4c@news.skynet.be> Message-ID: On Apr 6, 11:16 pm, Helmut Jarausch wrote: > Hi, > > I must be blind but I don't see what's going wrong > with The reason is: > G=[[]]*2 is doing a "shallow copy" of the blank list. The corrected code is either: G = [[] for _ in xrange(2)] or G = [[], []] btw, this is a very frequently asked question From aahz at pythoncraft.com Mon Apr 21 09:22:28 2008 From: aahz at pythoncraft.com (Aahz) Date: 21 Apr 2008 06:22:28 -0700 Subject: xkcd strikes again Message-ID: http://xkcd.com/413/ (As usual, make sure to read the alt text.) -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ Why is this newsgroup different from all other newsgroups? From gagsl-py2 at yahoo.com.ar Tue Apr 1 21:20:38 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 22:20:38 -0300 Subject: Decrementing of reference count of new objects? References: <20080401144928.24bc6506@opal.mv.qlogic.com> Message-ID: En Tue, 01 Apr 2008 18:49:28 -0300, Mitko Haralanov escribi?: > For the most part, I understand the theory behind reference counting in > Python C code. But there is one thing that I am confused about and I > have not been able to clear it up. > > Let say that you have the following function (over-simplified): > > PyObject *do_work (PyObject *self, PyObject *args) { > PyObject *new_obj; > new_obj = PyDict_New (); > return new_obj; > } > > What I don't get is whether I have to decrement the reference to > new_obj before I return it. I know that function that return object are > giving away the reference but I am still confused. PyDict_New returns a new reference (check section 7.4.1 in the API Reference), so do_work "owns" that reference. Functions that are intended to be called from Python code must return an owned reference to some PyObject* (see section 1.10.2 Ownership Rules, in the Extending/Embedding reference) (yes, these things are scattered all over the place...) Since do_work has to return an owned reference, it can't decrement it. In this example it's rather clear because the *only* reference to the newly created dict is hold by the function, and decrementing it would destroy the dictionary. -- Gabriel Genellina From sturlamolden at yahoo.no Wed Apr 30 17:26:09 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Wed, 30 Apr 2008 14:26:09 -0700 (PDT) Subject: Python 2.6 and wrapping C libraries on Windows References: Message-ID: <60da8569-4b80-4b31-9fd0-5b2a79ec2164@k13g2000hse.googlegroups.com> On Apr 30, 8:06 pm, "L. Lindstrom" wrote: > I have read that Python extension modules must link to the same C > run-time as the Python interpreter. This I can appreciate. But does this > requirement extend to the C libraries an extension module wraps. This somewhat of a misconception. You cannot reliably mix and blend CRT resources across different CRTs. This is not really a Python problem. It applies to any program. The reason this is important for Python C extensions, is mainly the possibility of accessing a Python file object as a pointer to a FILE struct in C. If you get a FILE* pointer from one CRT, you should not pass it to another CRT's fread. Likewise, if you allocate memory with one CRT's malloc(), you should not release the memory with another CRT's free(). As long as your libraries don't share CRT resources, it does not matter that the link to different CRTs for their internal work. From duncan.booth at invalid.invalid Tue Apr 29 05:23:33 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 29 Apr 2008 09:23:33 GMT Subject: How to unget a line when reading from a file/stream iterator/generator? References: <5e3854fa-557f-4475-8123-346346767097@k13g2000hse.googlegroups.com> Message-ID: George Sakkis wrote: > On Apr 28, 10:10?pm, pyt... at bdurham.com wrote: >> George, >> >> > Is there an elegant way to unget a line when reading from a >> > file/stream > iterator/generator? >> >> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502304 >> >> That's exactly what I was looking for! >> >> For those following this thread, the above recipe creates a generic >> object that wraps any iterator with an 'unget' ("push") capability. >> Clean and elegant! >> >> Thank you, >> Malcolm > > A small suggestion: since unget is expected to be called infrequently, > next should better be faster for the common case instead of penalizing > it with a try/except: > > def next(self): > if not self.pushed_back: > return self.it.next() > else: > return self.pushed_back.pop() > If speed is an issue then it may be better to avoid the test altogether: def __init__(self, it): self.it = it self.pushed_back = [] self.nextfn = it.next def __iter__(self): return self def __nonzero__(self): if self.pushed_back: return True try: self.pushback(self.nextfn()) except StopIteration: return False else: return True def popfn(self): lst = self.pushed_back res = lst.pop() if not lst: self.nextfn = self.it.next return res def next(self): return self.nextfn() def pushback(self, item): self.pushed_back.append(item) self.nextfn = self.popfn From mfb.chikazuku at gmail.com Sat Apr 12 14:38:22 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Sat, 12 Apr 2008 20:38:22 +0200 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <47ff8489$0$6841$2d805a3e@textnews.eweka.nl> Message-ID: <48010fe5$0$6840$2d805a3e@textnews.eweka.nl> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Gabriel Genellina wrote: > En Fri, 11 Apr 2008 11:31:42 -0300, Michel Bouwmans > escribi?: >> Gabriel Genellina wrote: > >>> Another annoying thing with the Qt license is that you have to choose it >>> at the very start of the project. You cannot develop something using the >>> open source license and later decide to switch to the commercial licence >>> and buy it. >> >> Unless you're a company with a risk of being checked for legal software >> etc., you can always ignore that allthough not very legal. > > I just ignore Qt itself. > Then you're ignorant. What do you prefer than? - - GTK is utter bullshit, creating GUI's functional wise. :r - - WxPython is terribly unstable. (Next to that I dislike it using GTK on *NIX, but that's personal :P) - - Tkinter is ugly and is a memory hog. MFB -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFIAQGjDpaqHmOKFdQRAvbQAKCFwfw2qfMPKzwLny1yaLKBb2xMFACfb/2Z 44qenzoZGgNoP1hd76Rrk6k= =eKjK -----END PGP SIGNATURE----- From bob.martin at excite.com Wed Apr 2 06:39:00 2008 From: bob.martin at excite.com (Bob Martin) Date: Wed, 02 Apr 2008 10:39:00 GMT Subject: Why prefer != over <> for Python 3.0? References: Message-ID: <8nJIj.31740$%N1.6042@newsfe3-gui.ntli.net> in 340625 20080402 094139 "Hendrik van Rooyen" wrote: >John J. Lee wrote: > >>How did programmers manage back then in 32k? > >Some of the answers, in no particular sequence, are: > >Tight, small operating systems that did the minimum. Apart from the GUI stuff, mainframe operating systems did everything that today's x86 OSs do. Early releases of IBM's OS/360 could run in 64KB and offered Fortran, Cobol etc The task time-sharing on release 12 (MVT, about 1971) was better than that in Windows XP or Vista (that should start a few arguments). >Assembler. >Sequential Processing: >- small tasks with multiple passes on tape >( like the concept of Unix pipes ) >Overlays. >Character based menu systems. >No OO. >Code structured to the point of incomprehensibility: >- if ten or so instructions looked similar, >you forced calls instead of inlining. I think you have that back-to-front - it is unstructured code with lots of inlining which is incomprehensible. >Procedural languages, close to the metal. >Small, fixed length, fixed type character based data structures. > >Some of the other veterans may want to add to this list. > >- Hendrik From rw at smsnet.pl Tue Apr 22 14:24:12 2008 From: rw at smsnet.pl (Rob Wolfe) Date: Tue, 22 Apr 2008 20:24:12 +0200 Subject: Problem with urllib2 and authentification References: Message-ID: <8763u921f7.fsf@merkury.smsnet.pl> "Miguel Beltran R." writes: > Using this script for connect to Zope I have this error You forgot to add the authentication handler to the list of handlers. See below. > > ---script: > import urllib2 > > protocolo='http://' > servidor='10.28.1.239/' > pagina='manage' > fullurl=protocolo+servidor+pagina > > aut=urllib2.HTTPBasicAuthHandler() > aut.add_password(realm=None, > uri=servidor, > user='myadmin', > passwd='mypass') > opener=urllib2.build_opener(aut, urllib2.HTTPHandler(debuglevel=1)) Add here: opener.add_handler(aut)) > print opener.open(fullurl).read() HTH, Rob From victorsmiller at gmail.com Wed Apr 16 23:22:18 2008 From: victorsmiller at gmail.com (VictorMiller) Date: Wed, 16 Apr 2008 20:22:18 -0700 (PDT) Subject: urllib working differently when run from crontab References: Message-ID: <678dcbe5-ef5a-4e9a-94ab-d327570be1b2@u69g2000hse.googlegroups.com> On Apr 14, 8:33 am, Matthew Woodcraft wrote: > In article , > > VictorMiller wrote: > > I've written a python script which, using urllib, and urllib2 will > > fetch a number of files that that I'm interested in from various > > websites (they're updated everyday). When I run the script from my > > command line everything works as intended. However, when the script > > is run from crontab every single url that I attempt to open gets > > "connection refused". Has anyone ever seen anything like this? If > > so, what's causing it, and what can I do about it? > > Perhaps you have an http_proxy environment variable set in the > interactive session but not in cron's environment? > Aha! Thanks, I think that that may indeed be the problem. I'll know for sure tomorrow morning after I look at the trace of the run. Victor > -M- From frikker at gmail.com Tue Apr 29 09:39:53 2008 From: frikker at gmail.com (blaine) Date: Tue, 29 Apr 2008 06:39:53 -0700 (PDT) Subject: list.reverse() References: <4816e26a$0$30938$426a74cc@news.free.fr> Message-ID: <98c4ad4d-3174-40cd-b281-84e318d699d3@24g2000hsh.googlegroups.com> On Apr 29, 9:32 am, Roy Smith wrote: > In article <4816e26a$0$30938$426a7... at news.free.fr>, > Bruno Desthuilliers wrote: > > > > > Mark Bryan Yu a ?crit : > > > This set of codes works: > > > >>>> x = range(5) > > >>>> x.reverse() > > >>>> x > > > [4, 3, 2, 1, 0] > > > > But this doesn't: > > > >>>> x = range(5).reverse() > > >>>> print x > > > None > > > This works just as expected - at least for anyone having read the doc. > > > > Please explain this behavior. range(5) returns a list from 0 to 4 and > > > reverse just reverses the items on the list that is returned by > > > range(5). Why is x None (null)? > > > Because that's what list.reverse() returns. Call it a wart if you want > > (FWIW, I do), but at least that's well documented. > > The reasoning goes along the lines of, "reverse in place is an expensive > operation, so we don't want to make it too easy for people to do". At > least that's the gist of what I got out of the argument the many times it > has come up. > > And, yes, I agree with Bruno that it's a wart. > > What you want to do is look at the reversed() function. Not only does it > return something (other than Null), but it is much faster because it > doesn't have to store the reversed list anywhere. What it returns is an > iterator which walks the list in reverse order. If you really want it as a > list, you can turn it into one (with the list() constructor), or you can > just iterate over it with a for loop. > > Same with list.sort() vs. the global sorted(). > > >>> range(5) > > [0, 1, 2, 3, 4] > > >>> reversed(range(5)) > > > > >>> list(reversed(range(5))) > > [4, 3, 2, 1, 0] > > >>> for i in reversed(range(5)): > > ... print i > ... > 4 > 3 > 2 > 1 > 0 > > Check out this cool little trick I recently learned: >>> x=range(5) >>> x.reverse() or x [4, 3, 2, 1, 0] Useful for returning lists that you need to sort or reverse without wasting that precious extra line :) What it does: x.reverse() does the reverse and returns None. or is bitwise, so it sees that 'None' is not 'True' and then continues to process the next operand, x. x or'd with None will always be x (and x has just been changed by the reverse()). So you get the new value of x :) Blaine From srf99 at ferg.org Wed Apr 16 09:21:25 2008 From: srf99 at ferg.org (srf99 at ferg.org) Date: Wed, 16 Apr 2008 06:21:25 -0700 (PDT) Subject: How is GUI programming in Python? References: Message-ID: <0e4c64b9-c570-4d1c-839f-0d5776a2c8cd@d1g2000hsg.googlegroups.com> > I'd like to build a really simple GUI app ? > that will work across Mac, Windows, and Linux. You might look at easygui http://www.ferg.org/easygui/index.html That will give you something simple and workable. Then you can go on to more advanced stuff at your leisure. From duncan.booth at invalid.invalid Mon Apr 14 12:05:23 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 14 Apr 2008 16:05:23 GMT Subject: eval modifies passed dict References: <2b2398b1-042e-46bb-b840-ea9e07d87bd1@2g2000hsn.googlegroups.com> Message-ID: Janto Dreijer wrote: > It seems eval is modifying the passed in locals/globals. This is > behaviour I did not expect and is really messing up my web.py app. > > Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> d = dict(a=1) >>>> d.keys() > ['a'] >>>> eval("a", d) > 1 >>>> d.keys() > ['a', '__builtins__'] > > That can't be right. > That can exactly be right. Python always expects a global called '__builtins__'. If it isn't in the dict you pass to eval to use for globals it will be added. You may, of course, initialise it yourself if you don't want your script to have access to all of the standard globals. The current document is (I think) wrong or at the least misleading. It says: > If the globals dictionary is present and lacks '__builtins__', the > current globals are copied into globals before expression is parsed. I think it should say: > If the globals dictionary is present and lacks '__builtins__', the > current value of __builtins__ is added to globals before expression > is parsed. i.e. only a single variable is assigned, other globals aren't copied. From jzgoda at o2.usun.pl Fri Apr 11 05:37:09 2008 From: jzgoda at o2.usun.pl (Jarek Zgoda) Date: Fri, 11 Apr 2008 11:37:09 +0200 Subject: How to make a "command line basd" interactive program? In-Reply-To: References: Message-ID: Evan napisa?(a): > Hope this hasn't been posted hundreds of times. I'm new for this. > > Before using python for this kind of script, I was using TCL to write > down a "command line based" interactive program. it likes a "tclsh", > or "python" command, after that, you can work under a prompt, for > example, " - >> ", and then you can execute any commands what you > defined in script. > > Now, in python, are there any common way(class) to finish this work? > or does anybody has a example to do that? See module cmd and class Cmd there. -- Jarek Zgoda Skype: jzgoda | GTalk: zgoda at jabber.aster.pl | voice: +48228430101 "We read Knuth so you don't have to." (Tim Peters) From python-url at phaseit.net Mon Apr 28 15:26:06 2008 From: python-url at phaseit.net (Gabriel Genellina) Date: Mon, 28 Apr 2008 19:26:06 +0000 (UTC) Subject: Python-URL! - weekly Python news and links (Apr 28) Message-ID: QOTW: "Posting to comp.lang.python is pair programming with the entire internet ;-)" - Nick Craig-Wood http://groups.google.com/group/comp.lang.python/msg/6f13cfca8a92c1a2 "When it got to the point where managers were asking, 'Why didn't you use the config check tool?', it was a done deal." - Roy Smith, on Python adoption http://mail.python.org/pipermail/advocacy/2008-April/000575.html Ideas to design a Python client/server application involving many aynchronous queries and real-time display of data: http://groups.google.com/group/comp.lang.python/browse_thread/thread/5e46184e940886b9/ Explicit variable declaration for functions: http://groups.google.com/group/comp.lang.python/browse_thread/thread/6c4a508edd2fbe04/ An example showing the difference between inheritance and composition: http://groups.google.com/group/comp.lang.python/browse_thread/thread/44612866d4d2fedb/ Lists: item and slice assignment are confusing for a novice Python programmer: http://groups.google.com/group/comp.lang.python/browse_thread/thread/d00b0c848a3003fc/ Converting xhtml to html isn't as trivial as one might expect: http://groups.google.com/group/comp.lang.python/browse_thread/thread/4bbbcecf89693a74/ Using the subprocess module with non-blocking pipes: http://groups.google.com/group/comp.lang.python/browse_thread/thread/a6dd7b98211bbd4c/ Calling Python from PHP http://groups.google.com/group/comp.lang.python/browse_thread/thread/ffb9d476ee4cd523/ People worried about code breakage in Python 3.0 (continued from last week) http://groups.google.com/group/comp.lang.python/browse_thread/thread/f07feff4f01be76f/ Python Advocacy: success stories http://groups.google.com/group/comp.lang.python/browse_thread/thread/1bd91aca0c86c57c/ ======================================================================== Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. Just beginning with Python? This page is a great place to start: http://wiki.python.org/moin/BeginnersGuide/Programmers The Python Papers aims to publish "the efforts of Python enthusiats": http://pythonpapers.org/ The Python Magazine is a technical monthly devoted to Python: http://pythonmagazine.com Readers have recommended the "Planet" sites: http://planetpython.org http://planet.python.org comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Python411 indexes "podcasts ... to help people learn Python ..." Updates appear more-than-weekly: http://www.awaretek.com/python/index.html Steve Bethard continues the marvelous tradition early borne by Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim Lesher of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to capture useful and interesting recipes. http://aspn.activestate.com/ASPN/Cookbook/Python Many Python conferences around the world are in preparation. Watch this space for links to them. Among several Python-oriented RSS/RDF feeds available are http://www.python.org/channews.rdf http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi http://python.de/backend.php For more, see http://www.syndic8.com/feedlist.php?ShowMatch=python&ShowStatus=all The old Python "To-Do List" now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse http://www.python.org/dev/peps/pep-0042/ The online Python Journal is posted at pythonjournal.cognizor.com. editor at pythonjournal.com and editor at pythonjournal.cognizor.com welcome submission of material that helps people's understanding of Python use, and offer Web presentation of your work. del.icio.us presents an intriguing approach to reference commentary. It already aggregates quite a bit of Python intelligence. http://del.icio.us/tag/python *Py: the Journal of the Python Language* http://www.pyzine.com Archive probing tricks of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 http://groups.google.com/groups?meta=site%3Dgroups%26group%3Dcomp.lang.python.* Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://www.ddj.com/topic/python/ (requires subscription) http://groups-beta.google.com/groups?q=python-url+group:comp.lang.python*&start=0&scoring=d& http://purl.org/thecliff/python/url.html (dormant) or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python There is *not* an RSS for "Python-URL!"--at least not yet. Arguments for and against are occasionally entertained. Suggestions/corrections for next week's posting are always welcome. E-mail to should get through. To receive a new issue of this posting in e-mail each Monday morning (approximately), ask to subscribe. Mention "Python-URL!". Write to the same address to unsubscribe. -- The Python-URL! Team-- Phaseit, Inc. (http://phaseit.net) is pleased to participate in and sponsor the "Python-URL!" project. Watch this space for upcoming news about posting archives. From wescpy at gmail.com Tue Apr 1 13:44:52 2008 From: wescpy at gmail.com (wesley chun) Date: Tue, 1 Apr 2008 10:44:52 -0700 Subject: [ANN] Python course, May 2008 Message-ID: <78b3a9580804011044g370899c4kb86a10cdb0a5218f@mail.gmail.com> *** my apologies... this training course is next month, not this Fall! *** contact me privately off-list for further details. thanks! > FINAL ANNOUNCEMENT > > Need to get up-to-speed with Python as quickly as possible? Come join > me, Wesley Chun, author of Prentice-Hall's well-received "Core Python > Programming," for another comprehensive intro course next month in > beautiful Northern California! I look forward to meeting you! > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > (COMPREHENSIVE) INTRODUCTION TO PYTHON: Mon-Wed, 2008 May 5-7 > > Although this course may appear to those new to Python, it is also > perfect those who have tinkered with it and want to "fill in the gaps" > and/or want to get more in-depth formal training. It combines the > best of both an introduction to the language as well as a "Python > Internals" training course. > > We will immerse you in the world of Python in only a few days. We > will show you more than just its syntax (which you don't really need a > book to learn, right?). Knowing more about how Python works under the > covers, including the relationship between data objects and memory > management, will make you a much more > effective Python programmer coming out of the gate. 3 hands-on labs > each day will help hammer the concepts home. > > Come find out why Google, Yahoo!, Disney, ILM/LucasFilm, VMware, OLPC, > NASA, Ubuntu, YouTube, and Red Hat all use Python. Users supporting or > jumping to Plone, Zope, TurboGears, Django, Pylons, Jython, > IronPython, and Mailman will also benefit! > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > WHERE: near the San Francisco Airport (SFO/San Bruno), CA, USA > > WEB: http://cyberwebconsulting.com (click "Python Training") > > LOCALS: easy freeway (101/280/380) with lots of parking plus public > transit (BART and CalTrain) access via the San Bruno stations, easily > accessible from all parts of the Bay Area > > VISITORS: free shuttle to/from the airport, free high-speed internet, > free breakfast and regular evening receptions; fully-equipped suites > > See website for costs, venue info, and registration. Discounts are > available for multiple registrations as well as for teachers/students. > > Hope to see you there! > -- wesley > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > "Core Python Programming", Prentice Hall, (c)2007,2001 > http://corepython.com > > wesley.j.chun :: wescpy-at-gmail.com > python training and technical consulting > cyberweb.consulting : silicon valley, ca > http://cyberwebconsulting.com > -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall, (c)2007,2001 http://corepython.com wesley.j.chun :: wescpy-at-gmail.com python training and technical consulting cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com From hobgoodoreneyhb at gmail.com Tue Apr 22 11:46:05 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:46:05 -0700 (PDT) Subject: crack hoe Message-ID: crack hoe http://cracks.12w.net F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Mon Apr 14 21:23:28 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 14 Apr 2008 22:23:28 -0300 Subject: How to make python run faster References: <0baa301a-ec8c-48ef-b30e-f9c80f72e5af@u12g2000prd.googlegroups.com> Message-ID: En Mon, 14 Apr 2008 10:48:47 -0300, ??? escribi?: > I read this article on http://kortis.to/radix/python_ext/ Note the date (2002) and the Python version used (2.1) > And I decided to try if it's true. > > I write the program in 4 ways: > > 1. Pure C > 2. Python using C extension > 3. Python using psycho > 4. Pure Python > > And then I used timeit to test the speed of these 4. Unsurprisingly, > the time they cost were: > > 4 > 3 > 2 > 1 > > But I did noticed that 2 is a least 3 times slower than 1, not as fast > as the article stated. > > That's quite weird and I thought maybe it's because I am using > Windows. I did the same test on Linux and I found 2 only uses 1.5 > times of time of 1. > > But, it is still not as fast as 1. As other have noted, there are two important things to consider: 1) use the right algorithm and the right data structure for the job. Usually it's much better to use an O(n) process (if available) than to try to microoptimize an O(n?) variant. 2) profile and measure your code to find the critical parts, and apply optimizations ONLY on those. The algorithm used in the article... hmmm, well, this is a public forum and there are ladies and minors so I won't use *those* words, but it's really horrible, or horrible?, and that makes the whole article moot. Python has *other* advantages, apart from speed: easy to write meaningful code, expresiveness, code easy to understand by others, higher order constructs, easy to write prototypes, non trivial OO... Take the good things from Python and delegate the speed, when required, to Cython or psyco or a C extension or a normal C library+ctypes. -- Gabriel Genellina From deets at nospam.web.de Tue Apr 8 11:29:35 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 08 Apr 2008 17:29:35 +0200 Subject: list.sort(): heaviest item? References: Message-ID: <661hbrF2iip12U1@mid.uni-berlin.de> Steven Clark wrote: > If I have a list of items of mixed type, can I put something into it > such that after a list.sort(), is guaranteed to be at the end of the > list? > > Looking at http://www.python.org/doc/2.3.5/ref/comparisons.html > "Most other types compare unequal unless they are the same object; the > choice whether one object is considered smaller or larger than another > one is made arbitrarily but consistently within one execution of a > program." > > makes me unsure. > > It looks like "None" always ends up at the start ("lightest"), but I > want the opposite ("heaviest"). You can pass a cmp-function that will always make one object being greater than all others. Diez From primoz.skale.lists at gmail.com Wed Apr 2 16:55:07 2008 From: primoz.skale.lists at gmail.com (Primoz Skale) Date: Wed, 2 Apr 2008 22:55:07 +0200 Subject: default method parameter behavior References: <879d72da-825f-4b2b-8244-87367647fb6e@f63g2000hsf.googlegroups.com> Message-ID: wrote in message news:879d72da-825f-4b2b-8244-87367647fb6e at f63g2000hsf.googlegroups.com... >I ran into a similar situation like the following (ipython session). > Can anyone please explain why the behavior? > Thanks in advance. > > In [11]: def foo(b=[]): > ....: b.append(3) > ....: return b > ....: > > In [12]: foo() > Out[12]: [3] > > In [13]: foo() > Out[13]: [3, 3] > > In [14]: foo([]) > Out[14]: [3] > > In [15]: foo([]) > Out[15]: [3] I think it has something to do with foo.func_defaults thing :) If parameter that is assigned a default value is mutable then foo.func_defaults is changed everytime there is no parameter passed to the function. For example: >>> def f(b=[]): b.append(3) return b >>> f.func_defaults #default is [], because function was not yet called ([],) >>> f() #no args [3] >>> f.func_defaults #default is now b=[3], because b is mutable object ([3],) >>> f([]) #empty; default still == [3] [3] >>> f.func_defaults #as we can see here ([3],) >>> f() #again no args; default is changed to [3,3] [3, 3] >>> f.func_defaults ([3, 3],) >>> f([]) #no args [3] >>> f.func_defaults ([3, 3],) As *I* understand it, it goes something like this. Because mutable objects change globaly if not passed correctly, and because [] is mutable, python creates a *def global* object, which is only seen by function that created it, with a name b to which it assigns a default value of []. But when this default [] is changed in function, it becomes [3], and so on..... Correct me if I am wrong... P. From ed at leafe.com Tue Apr 1 14:45:46 2008 From: ed at leafe.com (Ed Leafe) Date: Tue, 1 Apr 2008 13:45:46 -0500 Subject: What motivates all unpaid volunteers at Pycon? In-Reply-To: <12d7412e-9f87-4798-a319-a78a27f68d00@e6g2000prf.googlegroups.com> References: <7b539c8e-af4c-4409-81bc-d94e687eea59@i7g2000prf.googlegroups.com> <12d7412e-9f87-4798-a319-a78a27f68d00@e6g2000prf.googlegroups.com> Message-ID: On Apr 1, 2008, at 1:20 PM, seberino at spawar.navy.mil wrote: >> There really isn't any simple answer. Most people seem to be >> motivated >> to help out their communities, > > I still think all this unselfishness is noteworthy > and curious. Assuming that people get nothing back by participating in a community, yes, it would be curious. My experience, though, is that I get a lot more out of it than I could ever contribute. IOW, it's a great example of synergy. -- Ed Leafe From medin0065 at gmail.com Sun Apr 20 10:43:38 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:43:38 -0700 (PDT) Subject: deer hunter 2005 crack Message-ID: deer hunter 2005 crack http://cracks.00bp.com F R E E C R A C K S From jantod at gmail.com Mon Apr 14 11:23:25 2008 From: jantod at gmail.com (Janto Dreijer) Date: Mon, 14 Apr 2008 08:23:25 -0700 (PDT) Subject: eval modifies passed dict Message-ID: <2b2398b1-042e-46bb-b840-ea9e07d87bd1@2g2000hsn.googlegroups.com> It seems eval is modifying the passed in locals/globals. This is behaviour I did not expect and is really messing up my web.py app. Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> d = dict(a=1) >>> d.keys() ['a'] >>> eval("a", d) 1 >>> d.keys() ['a', '__builtins__'] That can't be right. Regards Janto From michele.simionato at gmail.com Wed Apr 23 15:12:34 2008 From: michele.simionato at gmail.com (Michele Simionato) Date: Wed, 23 Apr 2008 12:12:34 -0700 (PDT) Subject: Python generators (coroutines) References: Message-ID: <8744f315-4408-4f1f-81d7-6876b7274181@34g2000hsh.googlegroups.com> On Apr 23, 8:26 pm, Jean-Paul Calderone wrote: > On Wed, 23 Apr 2008 10:53:03 -0700 (PDT), Michele Simionato: > You could have #2. It's a trivial variation of sending a value. For > example, > > http://twistedmatrix.com/trac/browser/trunk/twisted/internet/defer.py... > > Jean-Paul Yep, I stand corrected, it is only #1 which is the real improvement. From maxerickson at gmail.com Sun Apr 27 18:54:15 2008 From: maxerickson at gmail.com (Max Erickson) Date: Sun, 27 Apr 2008 22:54:15 +0000 (UTC) Subject: Python equivalent to PHP's SPL __autoload() ?? References: <5bfb3fa2-652c-4ce5-b914-27ef21685c33@p25g2000pri.googlegroups.com> Message-ID: Ixiaus wrote: > I was curious (and have spent an enormous amount of time on Google > trying to answer it for myself) if Python has anything remotely > similar to PHP's SPL __autoload() for loading classes on the fly?? > > After digging through docs I feel doubtful there is such a language > feature, but, it is possible I missed something or maybe someone has > written an extension?!? > > Thanks in advance! > -- > http://mail.python.org/mailman/listinfo/python-list > If I'm understanding __autoload() correctly, not in the box, but most of what you need is built in, you just have to do a little work to use it. See the "Loading and reloading modules" section on this page: http://effbot.org/librarybook/builtin.htm max From deets at nospam.web.de Tue Apr 29 18:39:52 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 30 Apr 2008 00:39:52 +0200 Subject: how to convert a multiline string to an anonymous function? In-Reply-To: References: Message-ID: <67pmdnF2p5fhgU1@mid.uni-berlin.de> Danny Shevitz schrieb: > Simple question here: > > I have a multiline string representing the body of a function. I have control > over the string, so I can use either of the following: > > str = ''' > print state > return True > ''' > > str = ''' > def f(state): > print state > return True > ''' > > and I want to convert this into the function: > > def f(state): > print state > return True > > but return an anonmyous version of it, a la 'return f' so I can assign it > independently. The body is multiline so lambda doesn't work. > > I sort of need something like: > > def function_constructor(str): > f = eval(str) # What should this be > return f > > functions = {} > for node in nodes: > function[node] = function_constructor(node.text) > > I'm getting stuck because 'def' doesn't seem to work in an eval function, > and exec actually modifies the namespace, so I run into collisions if I use > the function more than once. > > I know I'm missing something stupid here, but I'm stuck just the same... The "stupid" thing is that you can pass your own dictionary as globals to exec. Then you can get a reference to the function under the name "f" in the globals, and store that under whatever name you need. Beware of recursion though! If that happens, you need to create unique names for your functions, but as you know these beforehand I don't see any problem with that - just enumerate them, like f1, f2, f3.... Diez From mdw at distorted.org.uk Tue Apr 1 13:32:41 2008 From: mdw at distorted.org.uk (Mark Wooding) Date: Tue, 1 Apr 2008 17:32:41 +0000 (UTC) Subject: deleting a line from a file References: <13usb5ngt26qv26@corp.supernews.com> <7xy781zqkq.fsf@ruckus.brouhaha.com> Message-ID: Paddy wrote: > Why not use the fileinput modules functionality to iterate over a file > in-place,printing just those lines you want? >From the Python 2.5 manual: : *Optional in-place filtering:* if the keyword argument `INPLACE=1' is : passed to `input()' or to the `FileInput' constructor, the file is : moved to a backup file and standard output is directed to the input : file (if a file of the same name as the backup file already exists, it : will be replaced silently). This behaviour is very dangerous. If the script fails half-way through, it will leave the partially-written file in place, with the `official' name. The change-over is not atomic, breaking other programs attempting to read simultaneously with an update. Two almost-simultaneous updates will corrupt the file without a usable backup. The first will back up the input file, and start writing. A second will /replace/ the backup file with the partially-constructed output of the first, and then start processing it; but since its input is incomplete, it will produce incomplete output. The safely_writing context manager has none of these defects. -- [mdw] From aaron.watters at gmail.com Sun Apr 27 20:01:58 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Sun, 27 Apr 2008 17:01:58 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> <48118719$0$25846$9b622d9e@news.freenet.de> Message-ID: > shame > 1 a. a painful emotion caused by consciousness of guilt, > ? ? ?shortcoming, or impropriety > 2 a condition of humiliating disgrace or disrepute Sigh. This is stupid (in the usual usage), but I must reply because I can't control myself. I meant usage 5: "something regrettable, unfortunate, or outrageous: it's a shame that he wasn't told." -- http://www.yourdictionary.com/shame I think outrageous is appropriate here because I think it's outrageous to change the basic usage for things like dictionary.keys() when it would be so easy to leave the old definition and add a new method like dictionary.keySet(). This would save me personally a great deal of painful tedium, I suspect (especially considering that I've implemented a lot of "dictionary-like" objects -- so I'll have to change the way their "keys" method works -- or something -- I haven't figured it out yet...). I know that the designers of Python are motivated by a desire to attain a Platonic ideal of aesthetic perfection primarily with a weaker desire to make lives easy for people writing libraries and tools somewhere further down the list, but from my perspective it's a shame^H^H^H^H^H regretable and unfortunate that the aesthetics so often trumps other considerations. In C# and java, for example, this sort of issue has never been a problem in my experience: stuff I wrote many versions ago still works just fine with no changes (but please note that I don't write gui stuff, which is less stable -- I'm speaking of algorithmic and system libraries). -- Aaron Watters === btw: usage (5) for "shame" in the python source: http://www.xfeedme.com/nucular/pydistro.py/go?FocusId=463&FREETEXT=shame From torriem at gmail.com Thu Apr 17 13:34:07 2008 From: torriem at gmail.com (Michael Torrie) Date: Thu, 17 Apr 2008 11:34:07 -0600 Subject: Can't do a multiline assignment! In-Reply-To: <564dd82b-8670-4ead-a3c8-a22b30a3eb73@m73g2000hsh.googlegroups.com> References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <1952579a-3cfb-44ea-92aa-658daa64aee4@a70g2000hsh.googlegroups.com> <564dd82b-8670-4ead-a3c8-a22b30a3eb73@m73g2000hsh.googlegroups.com> Message-ID: <48078A0F.90304@gmail.com> s0suk3 at gmail.com wrote: > I do it with all the separate variables mainly for performance. If I > had the headers in a dict, I'd be looking up a string in a list of > strings (the keys of the dict) everytime I check for a header. Not > that that's going to take more that 0.1 seconds, but the program is > still small and simple. As it gets bigger, more features are gonna > slow things down. As I just said in my other post, this is all premature optimization. Make your program simple and clear up front, and then work on spot-optimizations in the places that your code really is slow. Premature optimization can kill you in terms of code reliability and maintainability. The rule of thumb is that 80% of your program's execution time will be in 20% of the code. Therefore you have to profile the code and fine out exactly where this 20% is. Then you can optimize it. Another thing to consider is that referencing a member of a class or instance already *is* a dictionary lookup. It's how python works. Thus dictionaries are optimized to be fast. Since strings are immutable, python hashes them into a fast lookup pointer. So every time you say mydict["mykey"], it already knows the lookup pointer (hash) for "mykey" (the string) and can find the dictionary entry very quickly, ideally in O(1) time (well maybe log(N)). Thus putting your headers in a dictionary is actually a really good idea for performance reasons. From bjourne at gmail.com Sat Apr 5 07:26:59 2008 From: bjourne at gmail.com (=?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=) Date: Sat, 5 Apr 2008 13:26:59 +0200 Subject: ANN: pry unit testing framework In-Reply-To: <20080405105459.GB15154@nullcube.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> Message-ID: <740c3aec0804050426m39837404i8e8d6c232bef7724@mail.gmail.com> On Sat, Apr 5, 2008 at 12:54 PM, Aldo Cortesi wrote: > Thus spake Matthieu Brucher (matthieu.brucher at gmail.com): > > > > How does it compare to the nose framework ? > > As far as the base unit testing functionality is concerned, I think > they try to address similar problems. Both have assert-based testing > with inspection and re-parsing of assert exceptions for better error > messages. Both try to provide better fixture management. Both make > programmatic test generation easier. Both have a command-line tool for > running and gathering tests. > > I like nose, but I'm biased, and of course I think Pry has some > advantages. One difference I'd point out is Pry's tree-based test > structure, which provides a number of conveniences and features (much > nicer test selection from the command line, for instance). Isn't nose tree-based too? You can select both single test-cases suites or directories to run. Anyway, I don't think comparisions with nose is fair, because nose is the best of the best and all other test runners fall short of it. :) nose and nose-like test runners use automatic test case discovery, so that you don't have to write redundant boilerplate like in PyUnit and PyUnit-like frameworks. To take an example from Pry's manual: import libpry class MySuite(libpry.AutoTree): def setUpAll(self): self.all_fixture = True def tearDownAll(self): self.all_fixture = False def setUp(self): self.fixture = True def tearDown(self): self.fixture = False def test_one(self): assert self.fixture assert self.all_fixture tests = [ MySuite() ] in those, this could be written like this: class Empty: pass obj = Empty() def setup(): obj.all_fixture = True def setup_func(): obj.fixture = True def teardown(): obj.all_fixture = False def teardown_func(): obj.fixture = False @with_setup(setup_func, teardown_func) def test_one(): assert self.fixture assert self.all_fixture nose gives you much more bang per line of code. -- mvh Bj?rn From hopeorpha308 at gmail.com Sun Apr 27 07:46:44 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:46:44 -0700 (PDT) Subject: camfrog pro crack Message-ID: <2fef5514-b664-4959-8de9-3dd218970e1d@b1g2000hsg.googlegroups.com> camfrog pro crack http://wga-cracks.crackkey.net From gagsl-py2 at yahoo.com.ar Thu Apr 10 23:23:22 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 11 Apr 2008 00:23:22 -0300 Subject: Python conventions References: Message-ID: En Thu, 10 Apr 2008 16:52:11 -0300, escribi?: > Daniel Fetchinson wrote: >> I'm sorry to disappoint you but this project has already been completed: >> >> http://www.python.org/dev/peps/pep-0008/ > > Daniel, PEP 8 is anything but complete. How much of the following > simple question can you answer from there: > > Given that you can name things with UpperAndLower, lowerAndUpper, > lower_and_underscore, etc., what is the convention for naming > packages, modules, classes, ... > > PEP 8 very much reminds me of Sun's Java conventions - a start, but > only a start. Also, in part, controversial. (How wide do you think > Python code should be?) Finally, lacking in basic organization. (This > seems to be a disease that infects almost all standards.) We can do > better. As a guess, GvR would be happy to have someone fill out PEP 8. This feels like a dej?-vu... Your thread from last January: http://groups.google.com/group/comp.lang.python/browse_thread/thread/96fac33ed9d601b7/ If you like doing these kind of things, go ahead and summarize them. You have more than 30 style guides to start with. Enjoy. -- Gabriel Genellina From cmpython at gmail.com Wed Apr 9 00:18:56 2008 From: cmpython at gmail.com (CM) Date: Tue, 8 Apr 2008 21:18:56 -0700 (PDT) Subject: Converting a tuple to a list References: <00ba01c899c5$14528ae0$0a01a8c0@mobile> Message-ID: <0276f1e5-c37b-4698-9f20-ca26e2d9201f@m71g2000hse.googlegroups.com> On Apr 8, 6:46 pm, "Gabriel Ibanez" wrote: > Gabriel Ibanez wrote: > > Hi all .. > > > I'm trying to using the map function to convert a tuple to a list, without > > success. > > > I would like to have a lonely line that performs the same as loop of the > > next script: > > > ------------------------------------------- > > # Conveting tuple -> list > > > tupla = ((1,2), (3,4), (5,6)) > > > print tupla > > > lista = [] > > for a in tupla: > > for b in a: > > lista.append(b) > > print lista > > ------------------------------------------- > > > Any idea ? > > > Thanks ... > > > # Gabriel > > list(tupla) > > would probably do it. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > --http://mail.python.org/mailman/listinfo/python-list > > That would just make a list of tuples, I think he wants [1, 2, 3, 4, 5, 6]. > > Try: l = [x for z in t for x in z] > > --Brian > > --------------- > > Thanks Steve and Brian, > > Brian: that is !! > > However, it's a bit difficult to understand now. I have read it several > times :) Doing it this way is called a "list comprehension", which means you put the formula inside the brackets and that new list will be built with the formula. This one is also easier to understand if you substitute more meaningful names than l, x,t,z...like so: newlist = [number for subtuple in fulltuple for number in subtuple] or, writing it in the typical for loop way (not using the list comprehension shortcut): for subtuple in fulltuple: for number in subtuple: newlist.append(number) but the list comprehension doesn't need the append part, it is built in. They're handy. From xahlee at gmail.com Tue Apr 22 17:41:33 2008 From: xahlee at gmail.com (xahlee at gmail.com) Date: Tue, 22 Apr 2008 14:41:33 -0700 (PDT) Subject: pop langs website ranking Message-ID: <41fbaf27-a80b-402b-b406-c048a65a8643@b64g2000hsa.googlegroups.com> In February, i spent few hours researching the popularity of some computer language websites. (The message can be found here: http://xahlee.org/lang_traf/lang_sites.html http://community.livejournal.com/lisp/42778.html http://groups.google.com/group/comp.lang.perl.misc/msg/59c87899c2668f4c ) In that post, one question i puzzeled over is why PaulGraham.com's traffic is surprisingly high, since the site doesn't seems to host forums, computer lang documentation, or wiki type of thing, yet it is ranked higher than perl.com, which actually host online forum, faq, documentation, news etc. I wrote: ------------ paulgraham.com 48153 (lisp bigwig, but huh?) Perl.com 49104 xahlee.org 80060 ? Me! ------------- Compared to xahlee.org, it's a ranking difference about 32 thousand! Today, while checking the web ranking site alexa.com, they seems to have updated their ranking algorithm to be more fair, as opposed basing it solely on a browser toolbar that users install. So i went over to my essay and checked the ranking again of sites i reported. I have spent only about 20 min to cursorily go thru the sites i reported before. It appears that, in general, the order of sites that i listed ROUGHLY remains unperturbed, but the specific ranking ordinal has changed rather significantly. However, there's a big surprise. My website is now actually ranked higher than PaulGraham.com ! LOL. Paul Graham? Bah humbug. Painters == Hackers? Fuck ya ass. Arc? Eat shit and die. PS: not having no confidence of myself, but i note that xahlee.org is now marginally ranked higher than perl.com and perl.org, both of which host forum/blog/wiki, news, docs, etc., while my website don't do any of these and is all static html pages. For those unflagging, alternative web ranking site is http://ww.quantcast.com/ . I'll be doing some research sometimes soon on this. Xah xah at xahlee.org ? http://xahlee.org/ ? From timothy.brian14 at gmail.com Fri Apr 11 12:17:05 2008 From: timothy.brian14 at gmail.com (Timothy B) Date: Fri, 11 Apr 2008 09:17:05 -0700 (PDT) Subject: Sr. Lead Architect - (NYC) Message-ID: I am in need for a Sr. Lead Architect for an outstanding company located in NYC. The company has been outsourcing their technology to California and are bringing the office to NYC. The company is looking for an individual who can build and manage the technolgy team in NYC. Individual must be a Python expert. Please contact timothy.brian14 at gmail.com Thanks, Tim From barronmo at gmail.com Wed Apr 23 15:05:22 2008 From: barronmo at gmail.com (barronmo) Date: Wed, 23 Apr 2008 12:05:22 -0700 (PDT) Subject: print some text Message-ID: <7ac7b11d-6c9b-477c-8c0d-b038bc760918@c58g2000hsc.googlegroups.com> I'm a beginner searching for an easy way to print the contents of a text control. So far I've come up with the following(difficulties): 1) using wxPython -convert to HTML and then print (I don't know anything about HTML) -use wx.Printout (Seems complicated; may be beyond my abilities) 2) create a text file and then print it out (can create but can only print with the win32api.ShellExecute method so this solution doesn't help me on my Linus laptop) 3) use ReportLab to create .pdf and then print that out (again, can create but can't print in Linux) Thanks for any help. Mike From cokofreedom at gmail.com Thu Apr 10 04:51:14 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Thu, 10 Apr 2008 01:51:14 -0700 (PDT) Subject: questions about Exceptions? References: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> Message-ID: <71cc8c25-f5f9-4f21-a9d8-06780bf97608@f63g2000hsf.googlegroups.com> In general you should only catch the exceptions you want to catch, therefore avoiding the issue of catching "unexpected" ones, for instances the programming unexpectandly closing. Well, exception handling is expensive (when it catches one) so it really is up to you. If you are using eval and know it might "EOF" then you should probably look to handle that. The main IF statement style I can think of (checking the end of the string) wouldn't be much of an improvement. Currently I would be very worried about seeing that code as it breaks a number of "conventions". However it depends on the importance of the code to wherever or not you should change this. (Global variable, the use of Eval, the CATCH ALL except and the setting of a global variable at the end.) I've seen a good few (simple and advanced) calculator examples using python on the NET, it might be worth looking at some to see their style of coding a calculator to help your own. From mattheww at chiark.greenend.org.uk Sun Apr 20 12:42:05 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 20 Apr 2008 17:42:05 +0100 (BST) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: Christian Heimes wrote: >> I feel that including some optional means to block code would be a big >> step in getting wider adoption of the language in web development and >> in general. I do understand though, that the current strict indenting >> is part of the core of the language, so... thoughts? > Why should Python repeat the mistakes other languages did with SSI or > inline code? Python favors the MVC separation of code and layout. An alternative scheme for describing the block structure could be useful in other cases, though. For example, if you wanted to support putting snippets of Python in configuration files, or spreadsheet cells. There's no need to support the new scheme in .py files, so it seems to me that this doesn't have to be done in the core language. All that's needed is a variant of 'eval' which expects the alternate scheme, and that could be prototyped just using text manipulation and the normal 'eval'. If someone wrote a library for this and it proved popular, I expect it would be considered for the standard library. -M- From rw at smsnet.pl Tue Apr 22 14:39:16 2008 From: rw at smsnet.pl (Rob Wolfe) Date: Tue, 22 Apr 2008 20:39:16 +0200 Subject: Problem with urllib2 and authentification References: <8763u921f7.fsf@merkury.smsnet.pl> Message-ID: <871w4x20q3.fsf@merkury.smsnet.pl> Rob Wolfe writes: >> ---script: >> import urllib2 >> >> protocolo='http://' >> servidor='10.28.1.239/' >> pagina='manage' >> fullurl=protocolo+servidor+pagina >> >> aut=urllib2.HTTPBasicAuthHandler() >> aut.add_password(realm=None, >> uri=servidor, >> user='myadmin', >> passwd='mypass') >> opener=urllib2.build_opener(aut, urllib2.HTTPHandler(debuglevel=1)) Please ignore me. I overlooked that you added this handler here. But anyway I would try this `add_handler` method. ;) Rob From martin at v.loewis.de Sun Apr 27 13:28:39 2008 From: martin at v.loewis.de (=?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?=) Date: Sun, 27 Apr 2008 19:28:39 +0200 Subject: Why can't timedeltas be divided? In-Reply-To: References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> <48142747$0$20906$9b622d9e@news.freenet.de> Message-ID: <4814b7c7$0$30314$9b622d9e@news.freenet.de> > i've had a look at the source code and written a small patch (attached; > contains a case in classical/floor division as well as truediv). > is there a defined escalation procedure from python-list to python-dev > or should i just send the suggestion+patch there? Post a patch to bugs.python.org, optionally also post a message referring to that patch to python-dev. Regards, Martin From steve at holdenweb.com Wed Apr 16 17:03:33 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 16 Apr 2008 17:03:33 -0400 Subject: py3k s***s In-Reply-To: References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> <09a38ca2-8c49-4eee-b6cf-58e849aea1fc@q1g2000prf.googlegroups.com> Message-ID: <480669A5.3050705@holdenweb.com> Aaron Watters wrote: > On Apr 16, 2:33 pm, Rhamphoryncus wrote: >> The point is, you can't have it both ways. Either you evolve the >> language and break things, or you keep it static and nothing breaks. > > I disagree. You can add lots of cool > stuff without breaking the existing code base, mostly. > For example the minor changes to the way ints will work will > effect almost no programs. > > I don't see the urgency to clean up what are essentially > cosmetic issues and throw out or > require rewrites for just about all existing Python > code. Python 2.6 isn't fundamentally awful like Perl 4 was. > The cost paid for these minor improvements is too high in my > book. But I suppose if it is going to happen do it sooner > rather than later. Just *please* *please* don't > systematically break the pre-existing code base again for a > very long time, preferable ever. I'm pretty sure the 3.0 compatibility breakage is a one-shot deal. If it's not I won't be the only one looking for Guido with a bog stick in my hand ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From reckoner at gmail.com Tue Apr 15 11:27:21 2008 From: reckoner at gmail.com (Reckoner) Date: Tue, 15 Apr 2008 08:27:21 -0700 (PDT) Subject: use object method without initializing object Message-ID: would it be possible to use one of an object's methods without initializing the object? In other words, if I have: class Test: def __init__(self): print 'init' def foo(self): print 'foo' and I want to use the foo function without hitting the initialize constructor function. Is this possible? From sjmachin at lexicon.net Wed Apr 2 17:10:48 2008 From: sjmachin at lexicon.net (John Machin) Date: Wed, 02 Apr 2008 21:10:48 GMT Subject: xlrd and cPickle.dump In-Reply-To: <8abe8ae1-84c9-4f80-ab37-31497a4d273c@a23g2000hsc.googlegroups.com> References: <34e62ddb-477f-4a99-97a5-21a7b148d244@e67g2000hsa.googlegroups.com> <47f22a41@news.mel.dft.com.au> <0d46a213-9f95-43b5-835b-d74d8403626b@c19g2000prf.googlegroups.com> <6acbf9b4-161b-47db-9a91-b2448ee63c34@c26g2000prf.googlegroups.com> <12375df7-387d-424d-84a8-76beb664ae47@59g2000hsb.googlegroups.com> <8abe8ae1-84c9-4f80-ab37-31497a4d273c@a23g2000hsc.googlegroups.com> Message-ID: <47f3f654@news.mel.dft.com.au> patrick.waldo at gmail.com wrote: >> FWIW, it works here on 2.5.1 without errors or warnings. Ouput is: >> 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] >> 0.6.1 > > I guess it's a version issue then... I say again: Don't guess. > > I forgot about sorted! Yes, that would make sense! > > Thanks for the input. > > > On Apr 2, 4:23 pm, patrick.wa... at gmail.com wrote: >> Still no luck: >> >> Traceback (most recent call last): >> File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework >> \scriptutils.py", line 310, in RunScript >> exec codeObject in __main__.__dict__ >> File "C:\text analysis\pickle_test2.py", line 13, in ? >> cPickle.dump(Data_sheet, pickle_file, -1) >> PicklingError: Can't pickle : attribute lookup >> __builtin__.module failed I didn't notice that the exception had changed from the original: "TypeError: can't pickle file objects" (with protocol=0) to: "TypeError: can't pickle module objects" (pickling an xlrd.Book object with protocol=-1) and now to: "PicklingError: Can't pickle : attribute lookup __builtin__.module failed" (pickling an xlrd.Sheet object with protocol -1) I'm wondering if this is some unfortunate side effect of running the script in the pywin IDE ("exec codeObject in __main__.__dict__"). Can you reproduce the problem by running the script in the Command Prompt window? What version of pywin32 are you using? >> >> My code remains the same, except I added 'wb' and the -1 following >> your suggestions: >> >> import cPickle,xlrd, sys >> >> print sys.version >> print xlrd.__VERSION__ >> >> data_path = """C:\\test\\test.xls""" >> pickle_path = """C:\\test\\pickle.pickle""" >> >> book = xlrd.open_workbook(data_path) >> Data_sheet = book.sheet_by_index(0) >> >> pickle_file = open(pickle_path, 'wb')cPickle.dump(Data_sheet, pickle_file, -1) >> pickle_file.close() >> >> To begin with (I forgot to mention this before) I get this error: >> WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non- >> zero "WARNING" != "error". If that's the only message you get, ignore it; it means that your XLS file was created by the perl XLS-writing package or a copier thereof. >> >> I'm not sure what this means. >> >>> What do you describe as "simple manipulations"? Please describe your >>> computer, including how much memory it has. >> I have a 1.8Ghz HP dv6000 with 2Gb of ram, which should be speedy >> enough for my programming projects. However, when I try to print out >> the rows in the excel file, my computer gets very slow and choppy, >> which makes experimenting slow and frustrating. Just printing the rows is VERY UNLIKELY to cause this. Demonstrate this to yourself by using xlrd's supplied runxlrd script: command_prompt> c:\python24\scripts\runxlrd.py show yourfile.xls >> Maybe cPickle won't >> solve this problem at all! 99.9% chance, not "maybe". >> For this first part, I am trying to make >> ID numbers for the different permutation of categories, topics, and >> sub_topics. So I will have [book,non-fiction,biography],[book,non- >> fiction,history-general],[book,fiction,literature], etc.. >> so I want the combination of >> [book,non-fiction,biography] = 1 >> [book,non-fiction,history-general] = 2 >> [book,fiction,literature] = 3 >> etc... >> >> My code does this, except sort returns None, which is strange. list.sort() returns None by definition; it sorts the list object's contents in situ. > I just >> want an alphabetical sort of the first option, which sort should do >> automatically. When I do a test like>>>nest_list = [['bbc', 'cds'], ['jim', 'ex'],['abc', 'sd']] >>>>> nest_list.sort() >> [['abc', 'sd'], ['bbc', 'cds'], ['jim', 'ex']] >> It works fine, but not for my rows. Why are you sorting? >> >> Here's the code (unpickled/unsorted): >> import xlrd, pyExcelerator >> >> path_file = "C:\\text_analysis\\test.xls" >> book = xlrd.open_workbook(path_file) >> ProcFT_QC = book.sheet_by_index(0) >> log_path = "C:\\text_analysis\\ID_Log.log" >> logfile = open(log_path,'wb') >> >> set_rows = [] The test x in y where y is a sequence needs to compare with half of the existing items on average. You are doing that test N times. If the number of unique rows is U, it will do about N*U/4 comparisons. You said N is about 50,000. The changes below make y a set; consequentially x needs to be a tuple instead of a list. set_rows = set() >> rows = [] >> db = {} >> n=0 >> while n> rows.append(ProcFT_QC.row_values(n, 6,9)) rows.append(tuple(ProcFT_QC.row_values(n, 6,9))) >> n+=1 >> print rows.sort() #Outputs None >> ID = 1 >> for row in rows: >> if row not in set_rows: >> set_rows.append(row) set_rows.add(row) >> db[ID] = row >> entry = str(ID) + '|' + str(row).strip('u[]') + '\r\n' Presuming your data is actually ASCII, you could save time and memory by converting it once as you extract it from the spreadsheet. entry = str(ID) + '|' + str(row).strip('u()') + '\r\n' >> logfile.write(entry) >> ID+=1 >> logfile.close() >> HTH, John From sturlamolden at yahoo.no Wed Apr 16 20:37:43 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Wed, 16 Apr 2008 17:37:43 -0700 (PDT) Subject: I just killed GIL!!! Message-ID: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Hello Guys... I just had one moment of exceptional clarity, during which realized how I could get the GIL out of my way... It's so simple, I cannot help wondering why nobody has thought of it before. Duh! Now I am going to sit and and marvel at my creation for a while, and then go to bed (it's past 2:30 a.m.) Tomorrow I will contemplate whether to sell this little secret for big bucks, give it away for free, or just keep it to myself... :-) Now you are probably thinking I reinvented the gunpowder, and are running multiple processes. Not so. I am not running parallel processes, like parallel python or the processing module in cheese shop. I am running multiple THREADS. In fact, I am just using threading.Thread. The source code is pure Python, so there is no C magic, and I only used the stuff that's already there in the standard library. So, I just made CPython do what everyone claim to be impossible. One single process of CPython is using all the cpu power of my dual-core laptop. From nick at craig-wood.com Tue Apr 29 05:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Tue, 29 Apr 2008 04:30:03 -0500 Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> <87od7ue2ne.fsf@mulj.homelinux.net> <87hcdmdpf9.fsf@mulj.homelinux.net> Message-ID: Hrvoje Niksic wrote: > Nick Craig-Wood writes: > > >> Note that appending to a string is almost never a good idea, since it > >> can result in quadratic allocation. > > > > My aim was clear exposition rather than the ultimate performance! > > That would normally be fine. My post wasn't supposed to pick > performance nits, but to point out potentially quadratic behavior. > > > Anyway str += was optimised in python 2.4 or 2.5 (forget which) wasn't > > it? > > That optimization works only in certain cases, when working with > uninterned strings with a reference count of 1, and then only when the > strings are in stored local variables, rather than in global vars or > in slots. And then, it only works in CPython, not in other > implementations. The optimization works by "cheating" -- breaking the > immutable string abstraction in the specific cases in which it is > provably safe to do so. > http://utcc.utoronto.ca/~cks/space/blog/python/ExaminingStringConcatOpt > examines it in some detail. Ah, I didn't realise that - thanks for the interesting link. For the example I gave, just a simple local variable the optimisation kicks in. I can see how you could easily migrate that to an instance variable and the optimisation would no longer work, eg $ python -m timeit -s 's=""' 'for i in xrange(10000): s+="x"' 1000 loops, best of 3: 1.04 msec per loop $ python -m timeit -s 'class A: pass' -s 'a=A(); a.s=""' 'for i in xrange(10000): a.s+="x"' 10 loops, best of 3: 160 msec per loop > Guido was reluctant to accept the patch that implements the > optimization because he thought it would "change the way people write > code", a sentiment expressed in > http://mail.python.org/pipermail/python-dev/2004-August/046702.html > This discussion shows that he was quite right in retrospect. (I'm not > saying that the optimization is a bad thing, just that it is changing > the "recommended" way of writing Python in a way that other > implementations cannot follow.) Certainly something I wasn't aware of before - thanks! -- Nick Craig-Wood -- http://www.craig-wood.com/nick From gagsl-py2 at yahoo.com.ar Sun Apr 20 12:38:38 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 13:38:38 -0300 Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> Message-ID: En Sun, 20 Apr 2008 09:46:37 -0300, Hank @ITGroup escribi?: > ``starting python`` # == Windows Task Manager: > Python.exe *4,076 *K memory-usage == > >>> st1='abcdefg'*999999 # == 10,952 K == > >>> del st1 # == *4,104*K == > >>> st1='abcdefg'*999999 # == 10,952 K == > >>> del st1 # == 4,104 K == > > >>> li = ['abcde']*999999 # == 8,024 K == > >>> del li # == *4,108* K == > > >>> from nltk import FreqDist # == 17,596 == > >>> fd = FreqDist() # == 17,596 == > >>> for i in range(999999):fd.inc(i) # == 53,412 == > >>> del fd # == *28,780* == > >>> fd2 = FreqDist() # == 28,780 == > >>> for i in range(999999):fd2.inc(i) # == 53,412 == > >>> del fd2 # == 28,780 K == > > >>> def foo(): > ... fd3 = FreqDist() > ... for i in range(999999):fd3.inc(i) > > >>> foo() # == *28,788* K == > > >>> def bar(): > ... fd4 = FreqDist() > ... for i in range(999999):fd4.inc(i) > ... del fd4 > # == 28,788 K == > >>> bar() # == 28,788 K == > > > That is my question, after ``del``, sometimes the memory space returns > back as nothing happened, sometimes not... ... > What exactly was happening??? Apart from what everyone has already said, consider that FreqDist may import other modules, store global state, create other objects... whatever. Pure python code should not have any memory leaks (if there are, it's a bug in the Python interpreter). Not-carefully-written C extensions may introduce memory problems. -- Gabriel Genellina From ridenour4159 at gmail.com Thu Apr 24 06:18:24 2008 From: ridenour4159 at gmail.com (ridenour4159 at gmail.com) Date: Thu, 24 Apr 2008 03:18:24 -0700 (PDT) Subject: ilife 08 keygen Message-ID: <086890ad-60be-4901-90e9-c7f4c0259b96@f36g2000hsa.googlegroups.com> ilife 08 keygen http://cracks.12w.net F R E E C R A C K S From colemichae at gmail.com Thu Apr 17 22:43:04 2008 From: colemichae at gmail.com (colemichae at gmail.com) Date: Thu, 17 Apr 2008 19:43:04 -0700 (PDT) Subject: Python for Series 40 Nokia? References: Message-ID: On Apr 18, 8:46 am, "Dotan Cohen" wrote: > I had once heard something about python running on a Series 40 Nokia, > but I am unable to google anything concrete. Might it have been > Jython? Is there a known implementation of Python for the series 40 > (which is not Symbian, by the way)? Will Jython work in such an > environment? > > Thanks in advance. > > Dotan Cohen > > http://what-is-what.comhttp://gibberish.co.il > ?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-? > > A: Because it messes up the order in which people normally read text. > Q: Why is top-posting such a bad thing? there is a comment here of using jython on a nokia S40 Nokia 7210 SDK for Nokia Series 40 platform. http://bookshelf.sourceforge.net/en/src-build.html So i think i will work. I am using a S60 and works well, I have a GPS program in Python, Editors, Ogg player, and other assorted items. I myself purchased the Nokia N70 purely because of the Python ability it had.. From bignose+hates-spam at benfinney.id.au Fri Apr 18 22:01:28 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Sat, 19 Apr 2008 12:01:28 +1000 Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> <87lk3asrfm.fsf@benfinney.id.au> Message-ID: <873apir4av.fsf@benfinney.id.au> Ben Finney writes: > Thomas Bellman writes: > > > For what it's worth, Fedora 8 has Python 2.5, RHEL 5 ships with > > Python 2.4, and RHEL 4 has Python 2.3. Suse and Debian, I don't > > know. > > The current Debian "stable" branch (4.0r3, "etch", released > 2008-02-17) has the 'python' package installing Python 2.4.4. > > The current Debian "testing" branch ("lenny", the next in line for > release) has the 'python' package installing Python 2.4.5. It also has > Python 2.5.2, and before too long will be installing that as the > 'python' package. > > The current Debian "unstable" branch (never to be released, but a > staging area for new package versions) has the 'python' package > installing Python 2.5.2. Much better than the URLs I gave to the raw data, here is the full package information page for 'python-defaults' . The section titled "Available versions" shows the current default versions of Python in all currently-supported branches of Debian. -- \ ?Working out the social politics of who you can trust and why | `\ is, quite literally, what a very large part of our brain has | _o__) evolved to do.? ?Douglas Adams | Ben Finney From bronger at physik.rwth-aachen.de Wed Apr 16 12:25:58 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 16 Apr 2008 18:25:58 +0200 Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <87prspydex.fsf@physik.rwth-aachen.de> Hall?chen! Michael Torrie writes: > [...] > > This official python list is one of the few lists that's even > still on nntp. All my other ones (gnome, gtk, openldap, clamav, > freeradius, etc) are all e-mail mailing lists only and it works > very well. In fact, I think it's much better since list > subscription can actually be controlled by someone. The admistrative overhead of mailing lists is tedious. Fortunately, most important computer-related lists are on gmane.org. We could list c.l.py there, too. ;-) Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From dolloffdelvpg at gmail.com Wed Apr 16 08:08:14 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:08:14 -0700 (PDT) Subject: taylor swift biography Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From ra21vi at gmail.com Tue Apr 1 14:31:14 2008 From: ra21vi at gmail.com (Ravi Kumar) Date: Wed, 2 Apr 2008 00:01:14 +0530 Subject: libgmail through proxy Message-ID: <9a63e8920804011131p1e8e90f7mef8d05773a950390@mail.gmail.com> HI, I was trying to use libgmail. I used that successfully, fetched mail to some extend (thought after some mails, it threw exceptions on NonIterable Int). But when I used the same package from my office where I have to use the proxy, it failed. I used idle, then I also set os.ENVIRON['http_proxy'] to the same settings which I use, but I could not succeed. The login() method reports error about no addreess associated with it. Please help me solve it. I used the proxy settings, but it didnt work. so any workaround, and what sort of thing I am missing. -- -=Ravi=- -------------- next part -------------- An HTML attachment was scrubbed... URL: From ptmcg at austin.rr.com Thu Apr 24 10:10:55 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Thu, 24 Apr 2008 07:10:55 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: On Apr 21, 9:01?pm, "Gabriel Genellina" wrote: > > Perhaps you can manage to keep your code compatible with all versions, but ? > AFAIK the reccomended strategy is to write code compatible with Python 2.6 ? > and use the 2to3 tool to generate the 3.0 source. And *not* edit the 3.0 ? > code unless one wants to maintain two branches. > Gabriel - (Thanks for chiming in on this sub-thread, I really enjoy reading your posts.) My point is that the recommended strategy MAY work for those who write end point applications (I consider maintaining 2 branches to be in the "not working" category), but it does NOT WORK for people who maintain modules for other people to use, because those people may be on a range of Python versions that extend beyond 2.6-3.0. So if I upgrade my module to 2.6, those running on earlier versions can no longer use it. At some point in the future, I'll probably be able to say "no more support for pre-2.6", but it is a bit early to start saying that now. Likewise, I don't want to say "no support for 3.0" - people DO want to try 3.0 out, and I WANT them to want and be able to use my module too. Given the recommended strategy, and ruling out dual codebase, whom do I tell that they can't use the next version of my module? Again, to me, this is a non-issue because I've been able to create a cross-version compatible single codebase for pyparsing. But it was a bit dicey there for a while, and I think other module developers/ maintainers may not be so lucky. So, I feel that the recommended strategy was devised with a narrow group of developers in mind, and leaves module developers/maintainers, who wish to target as broad a set of users as possible, faced with choosing one of these strategies: - create (if possible) single cross-version compatible code - forego support of 3.0 users - discontinue pre-2.6 support for future versions of their module - maintain dual codebase -- Paul From __peter__ at web.de Sat Apr 5 05:55:10 2008 From: __peter__ at web.de (Peter Otten) Date: Sat, 05 Apr 2008 11:55:10 +0200 Subject: mailbox.Maildir(), confusing documentation References: <47f4f4f4$0$715$bed64819@news.gradwell.net> Message-ID: tinnews at isbd.co.uk wrote: > Having got my Python 2.5.2 installed I'm trying some things out with > the mailbox.Maildir() class. > > If I do the following:- > > import maibox > mailbox.Maildir("/home/isbd/Mail/Li/pytest") > > then the pytest Maildir mailbox is created - which is great but isn't > documented. If the above creates the maildir then what is the > mailbox.Maildir.add_folder() method for? I tried > mailbox.Maildir.add_folder() and it appeared to do nothing, it didn't > produce any errors either. You didn't expect the dot, it seems: >>> import mailbox >>> m = mailbox.Maildir("alpha") >>> m.add_folder("beta") >>> $ find . . ./alpha ./alpha/tmp ./alpha/cur ./alpha/new ./alpha/.beta ./alpha/.beta/tmp ./alpha/.beta/cur ./alpha/.beta/new ./alpha/.beta/maildirfolder $ Peter From skanemupp at yahoo.se Wed Apr 16 16:19:13 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Wed, 16 Apr 2008 13:19:13 -0700 (PDT) Subject: def power, problem when raising power to decimals Message-ID: how do i solve power(5,1.3)? def power(nbr, po): if po==0: return 1 if po>0: return nbr*power(nbr, po-1) if po<0: return 1/power(nbr, -1*po) also i found a link which states 0^0 isnt 1 even though every calculator ive tried says it is. it doesnt say what it is but i presume 0 then. but it seems the dude is wrong and it is 1? dont run the code with decimals, it will never leave the function, u have to restart the shell(if using the standard python ide) From sierra9162 at gmail.com Wed Apr 16 11:27:03 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:27:03 -0700 (PDT) Subject: kate hudson photo Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From ma.saeedi at gmail.com Tue Apr 8 13:53:33 2008 From: ma.saeedi at gmail.com (Maryam Saeedi) Date: Tue, 8 Apr 2008 12:53:33 -0500 Subject: Running a python code periodically Message-ID: Hi, I was wondering if you know how can I run a python code once every five minutes for a period of time either using python or some other program like a bash script. Thanks, Maryam -------------- next part -------------- An HTML attachment was scrubbed... URL: From nagle at animats.com Sun Apr 13 11:42:52 2008 From: nagle at animats.com (John Nagle) Date: Sun, 13 Apr 2008 08:42:52 -0700 Subject: How to Choose an Unlimited Web Hosting for free In-Reply-To: <02d391b5-f72f-4f99-8f40-dbc304aa22fe@q24g2000prf.googlegroups.com> References: <02d391b5-f72f-4f99-8f40-dbc304aa22fe@q24g2000prf.googlegroups.com> Message-ID: <4802276d$0$36379$742ec2ed@news.sonic.net> Unlimited Free Domain & Web Hosting wrote: > How to Choose an Unlimited Web Hosting > 1) Visit www.axealis.com to get domain and hosting > 2) Unlimited Bandwidth ,this mean unlimited data transmission for your > client access. > 2) Unlimited Space , you can upload file for unlimited . > 3) Unlimited Email , many of email account can created . > 5) SSL Security , used SSL / HTTPS to protect your web . > 6) LINUX , WINDOWS and MAC , can access form many operating system. This is some spamming "reseller" for Byet Hosting. Which does not support Python. John Nagle From sami.islam at NOSPAMbtinternet.com Sun Apr 6 15:16:46 2008 From: sami.islam at NOSPAMbtinternet.com (Sami) Date: Sun, 06 Apr 2008 20:16:46 +0100 Subject: traceback.print_exc() supposed to stop exception propagation. Message-ID: <69-dnW_JftMHvGTanZ2dneKdnZydnZ2d@bt.com> Hello, In the Python book that I am using to learn the language it says that the traceback.print_exc() can be used to stop exception propagation and make the program keep running. Here is a simple piece of code that I typed in to test this fact: --------------------------------------------------------------------------- import sys def Myexcepthook(etype, value, tb): print "in Myexcepthook\n" import traceback lines=traceback.format_exception(etype, value, tb) print "\n".join(lines) traceback.print_exc() sys.excepthook = Myexcepthook x = 1/0 x = 78 print x -------------------------------------------------------------------------- The Output: -------------------------------------------------------------------------- in Myexcepthook Traceback (most recent call last): File "E:\Home\Programming\Python\TryProjects\ExceptHandling1\Except2.py", lin 15, in x = 1/0 ZeroDivisionError: integer division or modulo by zero None -------------------------------------------------------------------------- I never see the value 78. What am I doing wrong? Thanks, Sami From jean11821cleme at gmail.com Tue Apr 29 05:17:00 2008 From: jean11821cleme at gmail.com (jean11821cleme at gmail.com) Date: Tue, 29 Apr 2008 02:17:00 -0700 (PDT) Subject: sims patch Message-ID: <1f18d647-dfc1-4f1f-ae5a-c1691ca73d90@a9g2000prl.googlegroups.com> sims patch http://crack.cracksofts.com From Lie.1296 at gmail.com Sun Apr 27 07:05:57 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 27 Apr 2008 04:05:57 -0700 (PDT) Subject: removing extension References: Message-ID: On Apr 27, 5:34 pm, wilson wrote: > i was trying to convert all images in a folder to another type and > save the new images in a separate folder.for that i wrote a class and > coded some part > > class ConvertImgs: > def __init__(self,infldr,outfldr): > if os.path.isdir(infldr): > self.infldr=infldr > self.outfldr=outfldr > else: > print "no such folder,exits program" > exit(1) > if not os.path.isdir(self.outfldr): > os.mkdir(self.outfldr) > print "made:",self.outfldr > > for x in os.listdir(infldr): > self.origlist=[os.path.normpath(os.path.join(self.infldr,x)) for x in > os.listdir(infldr)] > > ... > the self.origlist returns a list of filenames in infolder.I would > like to get them as 'C:\\myimages\\imageone' instead of 'C:\\myimages\ > \imageone.jpg' sothat i can add a diff extension to all those strings > in the list and save in diff format(ie change 'C:\\myimages\\imageone' > to 'C:\\myimages\\imageone.gif ' and save in gif format).but i don't > know how to remove those extension from the namestring ..can someone > help? > W I don't know if this is the simplest way, but you can use re module. import re pat = re.compile(r'(.*?)\..*') name = pat.search('C:\\myimages\\imageone.jpg').group(1) print name From dickinsm at gmail.com Wed Apr 9 16:27:33 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Wed, 9 Apr 2008 13:27:33 -0700 (PDT) Subject: Python 3.0 new integer division References: Message-ID: <572137bc-390d-445f-9b43-210e0c7955d8@d45g2000hsc.googlegroups.com> On Apr 9, 3:57?pm, Arnaud Delobelle wrote: > Naive question: why not just use a long + an exponent? > > e.g. 132560 ?-> (13256, 1) > ? ? ?0.534 ? -> (534, -3) > ? ? ?5.23e10 -> (523, 8) > It's a good question. The standard answer is that if the coefficient is a long then it's awkward to get at individual digits; looking up a digit becomes an O(n^2) operation (involving a division and a remainder) instead of the O(1) that it should be. And you need access to the digits for rounding operations, which are pretty darn common (one round at the end of each arithmetic operation, as a rule). But I could easily be convinced that storing the coefficient as a long speeds things up for the usual use cases, even if it gives horrible asymptotics for those trying to do really high-precision calculations. And it would certainly make the code slightly simpler in places. It would be great if someone could try converting Decimal so that the coefficient is stored as a long, to see if there's any noticeable impact on speed one way or the other. It wouldn't be such a hard change: a few hours of work at most. It's on my todo list to try this, but so far down that it's not looking like it'll end up at the top of the list before Christmas 20??. Mark From upton at virginia.edu Fri Apr 25 19:18:08 2008 From: upton at virginia.edu (Dan Upton) Date: Fri, 25 Apr 2008 19:18:08 -0400 Subject: MESSAGE RESPONSE In-Reply-To: <4e89b45d-198c-48ca-a3a6-3ba42448cb2b@e53g2000hsa.googlegroups.com> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> <678v5qF2me5rvU1@mid.uni-berlin.de> <4e89b45d-198c-48ca-a3a6-3ba42448cb2b@e53g2000hsa.googlegroups.com> Message-ID: <5504f9ac0804251618g29afc246n6df35bff2fb947ce@mail.gmail.com> On Fri, Apr 25, 2008 at 7:00 PM, ajaksu wrote: > On Apr 23, 1:27 pm, "Dan Upton" wrote: > > > On Wed, Apr 23, 2008 at 10:24 AM, Diez B. Roggisch wrote: > > > > > Blubaugh, David A. schrieb: > > > > > > Is there a way to block these messages. I do not want to be caught > > > > with filth such as this material. I could lose my job with Belcan with > > > > evil messages such as these messages. > > > > > If I (or *anybody*) knew how to block these messages, he or she would sell > > > the resulting spam-filter for a fortunen that roughly amasses the one of > > > scrooge mc duck - and go live on the bahamas or even buy them. > > > > > Put up with it. It's (unfortunately) part of ze internet tubes. > > > > > And as such, I find it hard to believe you could lose your job over it. > > Me too. That is, until I tried to Google Belcan and Blubaugh together. > May I suggest a new thread to clear that ugly results? :D > ...awesome. From petr.jakes.tpc at gmail.com Wed Apr 16 12:54:27 2008 From: petr.jakes.tpc at gmail.com (petr.jakes.tpc at gmail.com) Date: Wed, 16 Apr 2008 09:54:27 -0700 (PDT) Subject: User-defined Exceptions: is self.args OK? Message-ID: Hi, I am trying to dig through User-defined Exceptions (http:// docs.python.org/tut/node10.html chapter 8.5) is it OK to add following line to the __init__ method of the TransitionError class? .... .... self.args = (self.previous, self.next, self.message) If I do not add this argument to the class, following code does not include values from self.previous, self.next, self.message attributes try: raise TransitionError('previousFoo', 'nextBar', 'this is foo bar message') except TransitionError, err: print err import traceback, sys print sys.exc_info() traceback.print_exc() Thanks for your replies. Petr Jakes From fn681 at ncf.ca Mon Apr 7 06:43:40 2008 From: fn681 at ncf.ca (Colin J. Williams) Date: Mon, 07 Apr 2008 07:43:40 -0300 Subject: A funnily inconsistent behavior of int and float In-Reply-To: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com> References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com> Message-ID: Mark Dickinson wrote: > On Apr 6, 1:29 pm, Lie wrote: >> I've noticed some oddly inconsistent behavior with int and float: >> >> Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) >> [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2>>> int('- 345') >> >> -345 >> >> works, but >> >>>>> float('- 345.083') >> Traceback (most recent call last): >> File "", line 1, in >> ValueError: invalid literal for float(): - 345.083 > > This is a known issue, that has been fixed for Python 3.0. > It was decided not to risk breakage by changing this in > Python 2.x. See: > > http://bugs.python.org/issue1779 > > Mark This is good but the documentation for 3.0 is missing the syntax documentation from 2.5 Colin W. From skanemupp at yahoo.se Fri Apr 11 14:49:08 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 11 Apr 2008 11:49:08 -0700 (PDT) Subject: Profiling programs/scripts? Message-ID: how do i profile a program? i found out that there are some profilers included in the standard library but couldnt really figure out how to access/use them From castironpi at gmail.com Tue Apr 1 07:47:33 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Tue, 1 Apr 2008 04:47:33 -0700 (PDT) Subject: python persistence References: <8b1723d9-67c8-4fe5-b07b-22b0b9311519@8g2000hsu.googlegroups.com> <7f58b5f4-3195-472c-b307-dec71b12aaa8@y21g2000hsf.googlegroups.com> <44f04bf3-4edc-4cb4-9e54-fe51b5e591bc@e39g2000hsf.googlegroups.com> <80d1731d-a3c6-4fce-81fd-9c3f3537e59b@d21g2000prf.googlegroups.com> <5386cf08-c155-4fbb-8373-dbbb9829a9e7@m3g2000hsc.googlegroups.com> <3c27b270-e593-4f2a-b881-68126319760c@8g2000hsu.googlegroups.com> Message-ID: <7d71e294-2b13-4be0-948e-2fe0e4bbe7db@f63g2000hsf.googlegroups.com> On Apr 1, 12:16?am, "Gabriel Genellina" wrote: > En Tue, 01 Apr 2008 00:48:35 -0300, escribi?: > > > We do have, but on Windows, file is not locked to multi-tasking, > > shelve. ?But why don't we have types in there, or non-string > > primitives in keys? > > >>>> c= shelve.open( 'temp', 'c' ) > >>>> c['0']= 'a' > >>>> c.sync() > >>>> del c > >>>> c= shelve.open( 'temp', 'c' ) > >>>> c['0'] > > 'a' > > >>>> c['0'].append( 0 ) > >>>> c['0'] > > [] > > The above session doesn't make sense unless it's somewhat related to "on ? > Windows, file is not locked to multi-tasking," and another process has ? > modified the database in-between. I don't think the problem is restricted ? > to Windows only. There exist file locking mechanisms. > > > And why don't primitive mutations modify contents of disk? ?A > > metaquestion. > > They do, if you pass writeback=True to the shelve constructor, but read ? > the docs. > shelve is a simple class; if it can't fulfill your needs, you may want to ? > use a relational database (perhaps with an ORM like SQLObjects or ? > SQLAlchemy) or an object database like ZODB or Durus. > > >>>> c['0']= type('None',(),{}) > > Traceback (most recent call last): > > pickle.PicklingError: Can't pickle : it's not > > found as __main__.None > > Don't do that then. Or use the available pickle hooks to customize how ? > such classes may be pickled. All persistence mechanisms have limitations. > > -- > Gabriel Genellina I don't see a problem with that; except that binaries come from disks. You could have a Python session that runs entirely on disks + the ALU. I want to know if any, and correct me here, simple modification can store live objects. I call a.append(it) and the memory update takes place on disk instead. If you require that all objects referenced by on-disk objects be on- disk, that's an easy workaround. From mensanator at aol.com Sat Apr 5 13:00:52 2008 From: mensanator at aol.com (Mensanator) Date: Sat, 5 Apr 2008 10:00:52 -0700 (PDT) Subject: Learning curve for new database program with Python? References: Message-ID: On Apr 5, 10:50?am, Jetus wrote: > I have a need for a database program. I downloaded the db2 from ibm, > and reviewed some of the documentation. > > My question is, what is the easiest program for me to try to learn. I > will be creating a database of about 25,000 records, it will be > relational. I am a beginner Python programmer, and need a database > solution that is easy to grasp. I played with sql, > and found that very difficult, if not overly cumbersome. > > A database that could work with Django would be very interesting to > look at as well.. > > Any suggestions out there? You didn't mention the system you're using or whether you require something that's free. Microsoft Access is easy to learn. You can become very productive without every needing to learn SQL. Of course, you'll need to learn some SQL in order to interface to Python. But the good news is you can use the MS-Access drag-and-drop interface to learn how to set up the relational queries and once it's running, you can display the underlying SQL code to learn how to use it in Python. For example, I often design the queries in Access (where I have the advantage of visual design) and use simple SELECT calls from Python do retrieve the data. From rschroev_nospam_ml at fastmail.fm Sun Apr 6 06:46:42 2008 From: rschroev_nospam_ml at fastmail.fm (Roel Schroeven) Date: Sun, 06 Apr 2008 12:46:42 +0200 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> Message-ID: llothar schreef: >> There are ways to build distributions of Python extensions (modules or >> packages involving binary code from languages like C or C++), but you >> will want to understand a bit more about computing in general > > Believe me nobody needs to teach me anything about general programming > anymore. "The people who are best at programming are the people who realize how small their brains are. They are humble." -- Edsger Dijkstra, 1972 (http://www.codinghorror.com/blog/archives/000051.html, http://www.cs.utexas.edu/users/EWD/ewd03xx/EWD340.PDF) -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven From mark at mailinator.com Tue Apr 15 18:01:01 2008 From: mark at mailinator.com (Mark) Date: 15 Apr 2008 22:01:01 GMT Subject: Different times between Python and System References: <66292b91-a2ed-44d1-8fe6-9f4ecd87299b@w1g2000prd.googlegroups.com> Message-ID: On Mon, 14 Apr 2008 00:31:34 -0700, Josh wrote: > Hmm... That didn't work out so well that time. I feel like an idiot. > Previously there has been an hour difference between the system time and > the time that python reports. Thanks for the laugh though Josh. That was funny! :) From wuwei23 at gmail.com Thu Apr 24 06:00:47 2008 From: wuwei23 at gmail.com (alex23) Date: Thu, 24 Apr 2008 03:00:47 -0700 (PDT) Subject: library to do easy shell scripting in Python References: Message-ID: <377ef64e-eb31-4bb5-9f6e-55920a51c8a2@m1g2000pre.googlegroups.com> On Apr 24, 12:22 pm, Michael Torrie wrote: > pipe([prog1,args],[prog2,args],...) > Any ideas on how I could design this? There's a recipe on Activestate's Python Cookbook that does pretty much this: > Allows arbitrary number of commands to be strung together with > each one feeding into the next ones input. Syntax is simple: > x=pipe("cmd1", "cmd2", "cmd3").read() is equivalent to bash > command x=`cmd1 | cmd2 | cmd3`. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/475171 I haven't used it myself, but it might make a good place to start. - alex23 From steve at holdenweb.com Sat Apr 12 18:16:30 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 18:16:30 -0400 Subject: basic python question about for loop In-Reply-To: References: Message-ID: jmDesktop wrote: [...] > So what is n and x in the first iteration? Sorry. I'm trying. Somewhat feebly, if you don't mind my saying so, but don't worry. The usual way to proceed in the face of such ignorance is to insert some form of output that will tell you the answer to your question. So: >>> for n in range(2, 20): ... print range(2, n) ... for x in range(2, n): ... if n % x == 0: ... print n, 'equals', x, '*', n/x ... break ... else: ... print n, "is prime" ... [] 2 is prime [2] 3 is prime [2, 3] 4 equals 2 * 2 [2, 3, 4] 5 is prime [2, 3, 4, 5] 6 equals 2 * 3 [2, 3, 4, 5, 6] 7 is prime [2, 3, 4, 5, 6, 7] 8 equals 2 * 4 [2, 3, 4, 5, 6, 7, 8] 9 equals 3 * 3 and so on! This is the value of the interactive interpreter. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From paddy3118 at googlemail.com Sun Apr 13 07:37:45 2008 From: paddy3118 at googlemail.com (Paddy) Date: Sun, 13 Apr 2008 04:37:45 -0700 (PDT) Subject: Looking for a way to include Pyhtho scripting INSIDE a python program References: <48017af0$0$36399$742ec2ed@news.sonic.net> Message-ID: <3c9359da-90ab-43fc-a18a-eb78bba4a8b5@8g2000hsu.googlegroups.com> On Apr 13, 4:16 am, John Antypas wrote: > Hello all, > > I'm writing in tool in Python that manipulates various data objects read > from various streams. I wanted to give the user a chance to do advanced > work that could not easily be done from a GUI. > > At first, I tried putting in a lightweight scripting language, and then > I thought, why not include Python in itself -- it is certainly powerful > enough. > > I had assumed I'd present the user with a text window in which they > could type arbitrary python code. I'd wrap that code around a function > and pass that function a call of objects they could manipulate by > calling the methods of that class. > > 1. How can a python program invoke ANOTHER interpreter? > 2. How can I pass the class in as its argument and get the modified > class back? > > I know I can do something very ugly -- call a C method that calls a new > python interpreter but that seems VERY ugly. > > Help? > > Thanks. You might try ipython at http://ipython.scipy.org/moin/; or 'python - i'; or the exec and eval statements. There is also the compiler module: http://docs.python.org/lib/compiler.html - Paddy. From sawilla at gmail.com Fri Apr 25 12:49:03 2008 From: sawilla at gmail.com (sawilla) Date: Fri, 25 Apr 2008 09:49:03 -0700 (PDT) Subject: module error in Vista -- works as administrator References: <815eb7f8-6f00-469d-bb15-e1d9680d9646@e39g2000hsf.googlegroups.com> <480d0a52$1@news.mel.dft.com.au> <72da4abc-57b1-47ca-bed4-48b7244d6407@e39g2000hsf.googlegroups.com> <480d2369@news.mel.dft.com.au> <1ca8d4a1-7e98-4269-8e3b-c67fa757f9b1@b64g2000hsa.googlegroups.com> Message-ID: <6eff951e-208a-457a-bd6c-bebed6c71d11@56g2000hsm.googlegroups.com> I've discovered the cause of the problem. At some point previously, Windows Vista had created a copy of the site-packages directory in a virtual store for the user account. The easy-install.pth file in the virtual store did not contain the same path information as the easy- install.pth that the administrator account sees. I deleted the user's Python25 directory in the virtual store and now the user's sys.path contains all of the necessary paths. Reg On Apr 25, 12:04?pm, sawilla wrote: > The access writes to easy-install.pth for regular users is read and > execute. > > The output of sys.path for regular users is: > ['', 'C:\\Program Files\\Python25\\lib\\site-packages\ > \setuptools-0.6c8-py2.5.eg > g', 'C:\\Program Files\\Python25\\python25.zip', 'C:\\Program Files\ > \Python25\\D > LLs', 'C:\\Program Files\\Python25\\lib', 'C:\\Program Files\\Python25\ > \lib\\pla > t-win', 'C:\\Program Files\\Python25\\lib\\lib-tk', 'C:\\Program Files\ > \Python25 > ', 'C:\\Program Files\\Python25\\lib\\site-packages'] > > The output of sys.path for the admin user is: > ['', 'C:\\Program Files\\Python25\\lib\\site-packages\ > \setuptools-0.6c8-py2.5.eg > g', 'C:\\Program Files\\Python25\\lib\\site-packages\\networkx-0.36- > py2.5.egg', > 'C:\\Program Files\\Python25\\lib\\site-packages\\numpy-1.0.4-py2.5- > win32.egg', > 'C:\\Program Files\\Python25\\lib\\site-packages\\scipy-0.6.0-py2.5- > win32.egg', > 'C:\\Program Files\\Python25\\lib\\site-packages\\matplotlib-0.91.2- > py2.5-win32. > egg', 'C:\\Program Files\\Python25\\lib\\site-packages\\dot2tex-2.7.0- > py2.5.egg' > , 'C:\\Program Files\\Python25\\lib\\site-packages\\pydot-1.0.2- > py2.5.egg', 'C:\ > \Program Files\\Python25\\lib\\site-packages\\pyparsing-1.4.11-py2.5- > win32.egg', > ?'C:\\Program Files\\Python25\\python25.zip', 'C:\\Program Files\ > \Python25\\DLLs > ', 'C:\\Program Files\\Python25\\lib', 'C:\\Program Files\\Python25\ > \lib\\plat-w > in', 'C:\\Program Files\\Python25\\lib\\lib-tk', 'C:\\Program Files\ > \Python25', > 'C:\\Program Files\\Python25\\lib\\site-packages'] > > The contents of easy-install.pth are: > import sys; sys.__plen = len(sys.path) > ./setuptools-0.6c8-py2.5.egg > ./networkx-0.36-py2.5.egg > ./numpy-1.0.4-py2.5-win32.egg > ./scipy-0.6.0-py2.5-win32.egg > ./matplotlib-0.91.2-py2.5-win32.egg > ./dot2tex-2.7.0-py2.5.egg > ./pydot-1.0.2-py2.5.egg > ./pyparsing-1.4.11-py2.5-win32.egg > import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; > p=getattr(sys, > '__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new) > > The location where numpy is found:>>> print os.path.abspath(numpy.__file__) > > C:\Program Files\Python25\lib\site-packages\numpy-1.0.4-py2.5-win32.egg > \numpy\__ > init__.pyc > > So I believe I need to have the easy-install.pth file executed > automatically for regular users but I don't know how to do this. > > Reg > > On Apr 21, 7:29?pm, John Machin wrote: > > > > > sawillawrote: > > > On Apr 21, 5:42 pm, John Machin wrote: > > >> Log on as administrator, start python in command window and do this: > > > >> import sys > > >> sys.path # shows where python is looking for importables > > >> import numpy > > >> import os.path > > >> print os.path.abspath(numpy.__file__) # shows where it found numpy > > > >> Log on as ordinary user, start python in command window and do this: > > > >> import sys > > >> sys.path > > >> # check how this is different from the admin's sys.path > > > >> If you can't see what to do after that, come back here with the output > > >> from those steps. > > > >> HTH, > > >> John > > > > That was a great help, thank you. I now see what is causing the > > > problem but I don't know how to fix it. I used easy_install to install > > > several packages. When I run Python from an administrator command > > > window all of the directories in C:\Program Files\Python25\Lib\site- > > > packages\easy-install.pth are added to the sys.path. When I run it as > > > a regular user, those directories are not added to the sys.path and so > > > Python can't find the modules. > > > > I know how to manually add those directories to Python's search path > > > but then I'll need to update the path every time I install something. > > > How do I get Python to automatically load the easy-install.pth file > > > for the regular user account? > > > > Reg > > > """ > > If you can't see what to do after that, come back here with the output > > from those steps. > > """ > > in particular what is in sys.path for the non-admin user. > > Also what are the access rights to the easy-install.pth file?- Hide quoted text - > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - From victorsubervi at gmail.com Thu Apr 17 14:51:43 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 17 Apr 2008 13:51:43 -0500 Subject: Prob. w/ Script Posting Last Value In-Reply-To: <480791D6.4000802@holdenweb.com> References: <4dc0cfea0804170922n2a96be20sc424a7e67742a12e@mail.gmail.com> <480791D6.4000802@holdenweb.com> Message-ID: <4dc0cfea0804171151y204b11bal160762b88dfcf3ee@mail.gmail.com> On Thu, Apr 17, 2008 at 1:07 PM, Steve Holden wrote: > Victor Subervi wrote: > > > Hi; > > Gabriel provided a lovely script for showing images which I am modifying > > for my needs. I have the following line: > > print '

\n' % (d, y) > > where the correct values are entered for the variables, and those values > > increment (already tested). Here is the slightly modified script it calls: > > #!/usr/local/bin/python > > import cgitb; cgitb.enable() > > import MySQLdb > > import cgi > > form = cgi.FieldStorage() > > picid = int(form["id"].value) > > x = int(form["x"].value) > > pic = str(x) > > print 'Content-Type: text/html' > > db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > > cursor= db.cursor() > > sql = "select " + pic + " from products where id='" + str(picid) + "';" > > cursor.execute(sql) > > content = cursor.fetchall()[0][0].tostring() > > cursor.close() > > print 'Content-Type: image/jpeg\r\nContent-Length: %s\n' % len(content) > > print content > > I need to make it so that it will show all my images, not just the last > > one. Suggestions, please. > > TIA, > > Victor > > > > In your "page generator" page, replace > > print '

\n' % (d, y) > > by > > for d, y in (results of some DB query to get d and y for each image): > print '

\n' % (d, y) > Well, I just tried this: #! /usr/bin/python print """Content-type: text/html """ y = 1 for d in 2, 12: while y < 12: print '

\n' % (d, y) y += 1 print""" """ and it printed the same image over and over again :( Now, I could write a generator function that writes and then executes a new program for each image "getpic" + i + "py?... but that is ugly. Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From brian.e.munroe at gmail.com Thu Apr 24 16:22:53 2008 From: brian.e.munroe at gmail.com (Brian Munroe) Date: Thu, 24 Apr 2008 13:22:53 -0700 (PDT) Subject: Class Inheritance - What am I doing wrong? Message-ID: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> My example: class A(object): def __init__(self, name): self.__name = name def getName(self): return self.__name class B(A): def __init__(self,name=None): super(A,self).__init__() def setName(self, name): self.__name = name if __name__ == '__main__': a = A('class a') print a.getName() b = B('class b') print b.getName() b.setName('class b, reset') print b.getName() I get the following error: mtinky:~ brian$ python teste.py class a Traceback (most recent call last): File "teste.py", line 23, in print b.getName() File "teste.py", line 7, in getName return self.__name AttributeError: 'B' object has no attribute '_A__name' Am I *not* using super() correctly? Also, did I define my the class B constructor correctly? From bignose+hates-spam at benfinney.id.au Fri Apr 18 18:30:46 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Sat, 19 Apr 2008 08:30:46 +1000 Subject: Python 2.5 adoption References: Message-ID: <87skxin6cp.fsf@benfinney.id.au> Joseph Turian writes: > How widely adopted is python 2.5? Impossible to answer in general, because there's no way of finding out. > So I guess the question is, does anyone have a sense of what percent > of python users don't have 2.5? You might be able to get a more useful answer for your case if you narrow down the sample set. How many of *your target users* don't have, or would be unwilling to upgrade to, Python 2.5? -- \ ?God forbid that any book should be banned. The practice is | `\ as indefensible as infanticide.? ?Dame Rebecca West | _o__) | Ben Finney From johnjsal at gmailNOSPAM.com Wed Apr 16 22:58:49 2008 From: johnjsal at gmailNOSPAM.com (John Salerno) Date: Wed, 16 Apr 2008 22:58:49 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: References: Message-ID: <4806bcec$0$25058$607ed4bc@cv.net> Grant Edwards wrote: > This morning almost half of c.l.p was spam. In order to try to > not tar both the benign google group users and the malignant > ones with the same brush, I've been trying to kill usenet spam > with subject patterns. But that's not a battle you can win, so > I broke down and joined all the other people that just killfile > everything posted via google.groups. > > AFAICT, if you're a google groups user your posts are not being > seen by many/most experienced (read "non-google-group") users. > This is mainly the fault of google who has refused to do > anything to stem the flood of span that's being sent via Google > Groups. > How exactly do you killfile an entire source like that? Is it possible with Thunderbird? From iainking at gmail.com Mon Apr 7 08:36:40 2008 From: iainking at gmail.com (Iain King) Date: Mon, 7 Apr 2008 05:36:40 -0700 (PDT) Subject: Wxpython. Is it possible to change layout in a running application? Selfmade listbox References: <716c0f27-bca6-4642-a8ec-cdbb0b23e6e8@h1g2000prh.googlegroups.com> Message-ID: On Apr 7, 12:50 pm, Soren wrote: > Hi, > > Id like to make my own special listbox.. I want to able (at the push > of a button) to add another item to my special listbox... each item is > a panel with a label, some buttons and maybe a text control. > > I've tried adding a new panel object with the stuff i want to the > sizer i'm using for my listbox (which is a panel which can contain > other panels)... and then run update() and refresh() on everything... > But it doesn't work.. i see a panel appearing, but it's just a small > square in the corner of my "listbox" panel, and it only works the > first time... nothing new appears when I push the button again. > > Is it at all possible to do this? Has anyone created something > similar? Does anyone know what i'm doing wrong? > > Thanks, > Soren Without your code can only really guess, but I'd check that the new panel you are trying to add to the sizer has the listbox as a parent. Iain From frikker at gmail.com Tue Apr 29 09:22:12 2008 From: frikker at gmail.com (blaine) Date: Tue, 29 Apr 2008 06:22:12 -0700 (PDT) Subject: Simple TK Question - refreshing the canvas when not in focus Message-ID: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> Hey everyone! I'm not very good with Tk, and I am using a very simple canvas to draw some pictures (this relates to that nokia screen emulator I had a post about a few days ago). Anyway, all is well, except one thing. When I am not in the program, and the program receives a draw command (from a FIFO pipe), the canvas does not refresh until I click into the program. How do I force it to refresh, or force the window to gain focus? It seems like pretty common behavior, but a few things that I've tried have not worked. Class screen(): def __init__(self): self.root = Tkinter.Tk() self.root.title('Nokia Canvas') self.canvas = Tkinter.Canvas(self.root, width =130, height=130) self.canvas.pack() self.root.mainloop() Then somewhere a long the line I do: self.canvas.create_line(args[0], args[1], args[2], args[3], fill=color) self.canvas.pack() I've tried self.root.set_focus(), self.root.force_focus(), self.canvas.update(), etc. but I can't get it. Thanks! Blaine From arnodel at googlemail.com Fri Apr 25 08:37:25 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Fri, 25 Apr 2008 13:37:25 +0100 Subject: multiple pattern regular expression References: Message-ID: micron_make writes: > I am trying to parse a file whose contents are : > > parameter=current > max=5A > min=2A > > for a single line I used > for line in file: > print re.search("parameter\s*=\s*(.*)",line).groups() > > is there a way to match multiple patterns using regex and return a > dictionary. What I am looking for is (pseudo code) > > for line in file: > re.search("pattern1" OR "pattern2" OR ..,line) > > and the result should be {pattern1:match, pattern2:match...} > > Also should I be using regex at all here ? If every line of the file is of the form name=value, then regexps are indeed not needed. You could do something like that. params = {} for line in file: name, value = line.strip().split('=', 2) params[name] = value (untested) Then params should be the dictionary you want. -- Arnaud From ott.deb at gmail.com Thu Apr 17 15:04:35 2008 From: ott.deb at gmail.com (ott.deb at gmail.com) Date: Thu, 17 Apr 2008 12:04:35 -0700 (PDT) Subject: recycle crack Message-ID: recycle crack http://cracks.12w.net F R E E C R A C K S From steve.j.donovan at gmail.com Tue Apr 15 02:18:28 2008 From: steve.j.donovan at gmail.com (SteveD) Date: Mon, 14 Apr 2008 23:18:28 -0700 (PDT) Subject: pgdb: Debugging Python extensions made easier References: <7xzlrw7xw7.fsf@ruckus.brouhaha.com> Message-ID: <20484252-e346-4263-9f61-75a678134a77@8g2000hse.googlegroups.com> They are not insurmontable problems. But you will still see things like this: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66510 The point being that with a newish GDB (the current mingw GDB is still 5.x) there's no need for such tedious tricks, since it handles pending breakpoints fine. The additional trick I use for debugging plain non-debug python is to use symbol-file to load some arbitrary symbols, so GDB will not complain about breakpoints. steve d. On Apr 15, 2:41 am, Paul Rubin wrote: > SteveD writes: > > pgdb.zip is an addition to scite-debug, which adds source debugging to > > the popular SciTE programmer's editor. ... > > I know the FAQ says that this is not possible, but the FAQ is somewhat > > outdated. GDB is quite happy with pending breakpoints to unresolved > > libraries, but you have to reassure it. > > I'm not sure what FAQ or what is supposed to be impossible but > I've used gdb in the past to debug python extensions without > running into insurmountable problems that I remember. From tjreedy at udel.edu Tue Apr 8 00:45:34 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 8 Apr 2008 00:45:34 -0400 Subject: Translating keywords References: Message-ID: "Gabriel Genellina" wrote in message news:op.t89t1sbgx6zn5v at gabriel2.softlabbsas.com.ar... | En Mon, 07 Apr 2008 14:59:08 -0300, Terry Reedy | escribi?: | > If you want other-language keywords, you should either use a translator | > processor or an editor that will do keyword substitution. I do not know | > of | > such but I would not be surprised if there is one. I suspect this sort | > of | > thing will more likely happen with Python 3, which will allow unicode | > keywords. | | Python 3 allows for unicode identifiers, but I don'k know any plans for | using unicode keywords too. Looks funny: There are no official (PSF) plans and I expect there will be not be any for a long time if ever. My 'suspicion' was with respect to very unofficial 3rd party efforts, perhaps not even announced here in English/ascii land. My reasoning: If one is writing in ascii only, then ascii keywords and even English keywords are not so much a burden. But if one is writing comments and strings and identifiers in a different alphabet, then ascii begin to look odd and native character keywords more inviting. From donn at u.washington.edu Wed Apr 16 12:16:27 2008 From: donn at u.washington.edu (Donn Cave) Date: Wed, 16 Apr 2008 09:16:27 -0700 Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: In article , Aaron Watters wrote: > Maybe there is a secret desire in the Python > community to remain a fringe minority underdog > forever? I'm sure anyone who has given it any thought understands that the fringe minority situation is a lot more fun in some ways, but I think if you were to apply a sort of conspiracy analysis to the situation - "who benefits from language change" - this would be a couple items down on the list of motivations. Donn Cave, donn at u.washington.edu From gagsl-py2 at yahoo.com.ar Sat Apr 12 02:13:34 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 12 Apr 2008 03:13:34 -0300 Subject: str(bytes) in Python 3.0 Message-ID: Hello Is this the intended behavior? Python 3.0a4+ (py3k, Apr 12 2008, 02:53:16) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> x = b"abc" >>> repr(x) "b'abc'" >>> str(x,"ascii") 'abc' >>> str(x,"utf-8") 'abc' >>> str(x) "b'abc'" On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') above. But I get the same as repr(x) - is this on purpose? -- Gabriel Genellina From steve at holdenweb.com Sun Apr 20 14:31:29 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 20 Apr 2008 14:31:29 -0400 Subject: Any reliable obfurscator for Python 2.5 In-Reply-To: <480b6133$0$34498$742ec2ed@news.sonic.net> References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> <480b6133$0$34498$742ec2ed@news.sonic.net> Message-ID: <480B8C01.1080306@holdenweb.com> JB "My first post on c.l.py" Stern wrote: > Banibrata Dutta wrote: >>> Wanted to check if there is any known, reliable, FOSS/Libre -- Obfurscator >>> for Python 2.5 code. > > No, sadly, there is not. There are a number of applications I would be > working on if it were possible to obfuscate pyc files. About the best > you can do as of 2008/04 is use Jython to compile into Java bytecode and > obfuscate that using Proguard. > > Steve 'not an economics major' Holden wrote: >> The Python world isn't particularly paranoid about obfuscation. It's >> quite easy to publish compiled code only (.pyc and/or .pyo files), and >> that offers enough protection for most. > > Curious Steve, how do you pay the rent and by what authority do you > speak for "The Python world"? Your opinion couldn't be more wrong for > programmers like myself who live by the code they write (as opposed to > its support). > I pay the mortgage by creating software systems, though not usually packaged systems for shrink-wrap sale. I don't claim to speak *for* the whole Python world, but as chairman of the Python Software Foundation and a long-time member of this mailing list I can probably claim to be more closely in touch with it than many--yourself included, apparently. If it's important to you to be able to obfuscate your code then you have made an inapposite choice of language. > Steve 'not a software consultant' Holden wrote: >> The sad fact is that there seems to be an almost direct inverse >> correlation between the worth of the code and the authors' desire to >> protect it from piracy. > > Would love to see some evidence to that effect. > That is just an observation based on the many similar posts that have been made on this list, not one of them coming from the author of a recognized software package, plus forty years experience in the software industry. The ripping of of source code is far less frequent that novice programmers believe. The code that novice programmers write is almost always less valuable than they believe. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From kovyrus2 at gmail.com Wed Apr 9 18:18:23 2008 From: kovyrus2 at gmail.com (kovyrus2 at gmail.com) Date: Wed, 9 Apr 2008 15:18:23 -0700 (PDT) Subject: Free Photo Sharing Message-ID: <7739b530-38f8-47d5-949e-a8640c1deb45@q10g2000prf.googlegroups.com> Upload your photos and share them with friends and family. http://fotochange.com From jeffrey at fro.man Wed Apr 9 11:39:12 2008 From: jeffrey at fro.man (Jeffrey Froman) Date: Wed, 09 Apr 2008 08:39:12 -0700 Subject: Trouble with list comprehension References: Message-ID: Shane Lillie wrote: > goats = [ x for x in range(2) if doors[x] == 'G' ] > > but for some reason the list comprehension is not always returning a > list with 2 elements in it (sometimes it will be just 1 element). The problem here is with your usage of the range() function. You provide an endpoint of 2, but that endpoint is not included in the range. Thus, you are only checking the indexes 0 and 1. You'll get two results when those two indexes are 'G', and one otherwise. You want range(3). By the way, the enumerate() function is good for this task, as it does not require you to know the length of your list in advance: goats = [index for index, item in enumerate(doors)] -- Jeffrey From skanemupp at yahoo.se Sat Apr 5 15:27:49 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 12:27:49 -0700 (PDT) Subject: Tkinter, add pressed buttons onto string display string, how to? Message-ID: using tkinter and python i now have a small App (that will hopefully soon be a fully functioning calculator) where u can push buttons and the corresponding number or operator is shown. when u press 1, "1" appears on the screen, pres + and "+" appears etc. at the moment every output overwrites the previous so what i want to do is obviosuly to add every new output to a string so that i can read the string and perform the calculation. so i want: * when pushing the button push the token of the button onto a string * display the new string, ie "1+2" for example * want to be able to access this string when pressing calculate so i can figure out which operators should be done first so it can solve something like this: "(1+2*3)(3-4/2)" and not just simple "1+2"-stuff. do i have to have some global string-variable in the GUIframework then? im not sure where to start... here is the code: #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self, master=None): """Initialize yourself""" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): ## """Create the Entry, set it to be a bit wider""" ## self.enText = Entry(self) ## self.enText.grid(row=0, column=0, columnspan=3) """Create the Button, set the text and the command that will be called when the button is clicked""" self.btnDisplay = Button(self, text="calculate!", state=DISABLED) self.btnDisplay.grid(row=0, column=31) self.btnDisplay = Button(self,text='1',command=lambda n=1:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='2',command=lambda n=2:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='3',command=lambda n=3:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='+',command=lambda n="+":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) self.btnDisplay = Button(self,text='4',command=lambda n=4:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='5',command=lambda n=5:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='6',command=lambda n=6:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='-',command=lambda n="-":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=3, padx=5, pady=5) self.btnDisplay = Button(self,text='7',command=lambda n=7:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='8',command=lambda n=8:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='9',command=lambda n=9:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='*',command=lambda n="*":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=3, padx=5, pady=5) self.btnDisplay = Button(self,text='0',command=lambda n=0:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='C',command=lambda n="C":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='r',command=lambda n="r":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='/',command=lambda n="/":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) def Display(self, number): #print number self.lbText = Label(self, text=number) self.lbText.grid(row=0, column=0) if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() From steve at holdenweb.com Tue Apr 8 12:15:51 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 12:15:51 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> Message-ID: Victor Subervi wrote: > Hi: > I am able (finally) to upload an image to the database. However, when I > try to retrieve it, I get a string literal. Here is my code: > > #!/usr/local/bin/python > import cgitb; cgitb.enable() > import MySQLdb > def test(): > host = 'mysqldb2.ehost-services.com ' > user = 'user' > passwd = 'pass' > db = 'bre' > db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > cursor= db.cursor() > cursor.execute('select pic1 from products where id="3";') > content = cursor.fetchall() > # print 'Content-Type: image/jpeg\r\nContent-Length: %d\n' % len(content) > print 'Content-Type: image/jpeg\r\n' > print '\n' > print content > print '\n' > cursor.close() > > test() > (Apparently, Plesk doesn?t like if __name__ == '__main__': ) > The commented out line gives me a leading less than sign...and that?s > it. What do? > TIA, > Victor > Your headers indicate you intend to serve a JPEG image, so you should *not* then include HTML. Take a look at the HTML of a web page with an image inside it (look for the tag) and you will see that HTML pages reference images as separate web resources. Thus once you have printed out your HTML headers you should them immediately send the contents of the database column. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From castironpi at gmail.com Tue Apr 1 00:04:20 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Mon, 31 Mar 2008 21:04:20 -0700 (PDT) Subject: python persistence References: <8b1723d9-67c8-4fe5-b07b-22b0b9311519@8g2000hsu.googlegroups.com> <7f58b5f4-3195-472c-b307-dec71b12aaa8@y21g2000hsf.googlegroups.com> Message-ID: <09f7e201-3b3c-4e9f-9d8b-de7af4771049@m73g2000hsh.googlegroups.com> On Mar 31, 7:14?pm, 7stud wrote: > On Mar 31, 5:31?pm, castiro... at gmail.com wrote: > > > Can you have a Python object stored entirely on disk? > > import cPickle as cp > > class Dog(object): > ? ? def __init__(self, name): > ? ? ? ? self.name = name > > d = Dog("Spot") > > f = open("data.txt", "w") > cp.dump(d, f) > f.close() > > f = open("data.txt") > stored_obj = cp.load(f) > print stored_obj.name > > --output:-- > Spot From listobject.h: #define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v)) Can we make ob_item a seek-tell offset? From mccredie at gmail.com Tue Apr 29 12:51:02 2008 From: mccredie at gmail.com (Matimus) Date: Tue, 29 Apr 2008 09:51:02 -0700 (PDT) Subject: Issue with regular expressions References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Message-ID: <8a393c76-cbbd-4056-9ef0-ee5fc66e8fbf@q24g2000prf.googlegroups.com> On Apr 29, 6:46 am, Julien wrote: > Hi, > > I'm fairly new in Python and I haven't used the regular expressions > enough to be able to achieve what I want. > I'd like to select terms in a string, so I can then do a search in my > database. > > query = ' " some words" with and "without quotes " ' > p = re.compile(magic_regular_expression) $ <--- the magic happens > m = p.match(query) > > I'd like m.groups() to return: > ('some words', 'with', 'and', 'without quotes') > > Is that achievable with a single regular expression, and if so, what > would it be? > > Any help would be much appreciated. > > Thanks!! > > Julien I don't know if it is possible to do it all with one regex, but it doesn't seem practical. I would check-out the shlex module. >>> import shlex >>> >>> query = ' " some words" with and "without quotes " ' >>> shlex.split(query) [' some words', 'with', 'and', 'without quotes '] To get rid of the leading and trailing space you can then use strip: >>> [s.strip() for s in shlex.split(query)] ['some words', 'with', 'and', 'without quotes'] The only problem is getting rid of the extra white-space in the middle of the expression, for which re might still be a good solution. >>> import re >>> [re.sub(r"\s+", ' ', s.strip()) for s in shlex.split(query)] ['some words', 'with', 'and', 'without quotes'] Matt From bignose+hates-spam at benfinney.id.au Tue Apr 22 10:02:47 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Wed, 23 Apr 2008 00:02:47 +1000 Subject: Witty retorts (was: Python Success stories) References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <87d4oi3s3c.fsf_-_@benfinney.id.au> Carl Banks writes: > Let me tell you a little story to let you know how you should act in > situations like this. Some of you might have heard it before. > Apologies if it's a bit long. I don't know if I've heard it before; it's rather unmemorable. What lesson is it intended to teach, other than that "Fuck you" is somehow a "retort"? I can't see that improving too many situations. -- \ "Probably the toughest time in anyone's life is when you have | `\ to murder a loved one because they're the devil." -- Emo | _o__) Philips | Ben Finney From arnodel at googlemail.com Wed Apr 30 12:05:59 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Wed, 30 Apr 2008 17:05:59 +0100 Subject: calling variable function name ? References: <57461074-8fd1-4e65-9bc9-2ac916aa1fb5@y21g2000hsf.googlegroups.com> Message-ID: TkNeo writes: > > George - Thanks for your reply but what you suggested is not working: > > def FA(param1,param2): > print "FA" + param1 + " " + param2 > def FA(param1,param2): > print "FB" + param1 + " " + param2 > def FA(param1,param2): > print "FC" + param1 + " " + param2 > > temp = sys.argv[1] > > func = globals()["F" + temp] > func("Hello", "World") > > > I ran the script with first parameter as B and i get the following > message > KeyError: 'FB' Perhaps if you call your three function FA, FB, FC instead of FA, FA, FA it'll help? -- Arnaud From darcy at druid.net Tue Apr 22 12:10:06 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Tue, 22 Apr 2008 12:10:06 -0400 Subject: Python Success stories In-Reply-To: <944aa044-4a41-4ae9-9364-56e1bcc82488@p25g2000hsf.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> <944aa044-4a41-4ae9-9364-56e1bcc82488@p25g2000hsf.googlegroups.com> Message-ID: <20080422121006.b0243813.darcy@druid.net> On Tue, 22 Apr 2008 08:35:47 -0700 (PDT) GHUM wrote: > > Which big aplications are written in python. I see its development, > > There are no big applications written in Python. > > Big applications are written in JAVA or COBOL or C# or other legacy > programming systems. > > If you programm in Python, your applications become quite small. Only > frameworks in Python are big. So the fact that there are no big applications written in Python IS the success story. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From sturlamolden at yahoo.no Thu Apr 24 23:07:56 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 20:07:56 -0700 (PDT) Subject: Psyco alternative References: <8b7d9523-1d15-41e5-8b69-39f8250e6a6f@i76g2000hsf.googlegroups.com> Message-ID: On Apr 25, 4:57 am, Steve Holden wrote: > I am simply pointing out that RPython is used for efficiency, not to do > things that can't be done in standard Python. Yes. And if we only use a very small subset of Python, it would in effect be a form of assembly code. Hence my comment about the Turing complete subset. From cokofreedom at gmail.com Fri Apr 11 07:24:35 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Fri, 11 Apr 2008 04:24:35 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> Message-ID: <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> On Apr 11, 1:19 pm, cokofree... at gmail.com wrote: > couldn't you just do. > > #untested > new_round(n): > answer = round(n) > # is answer now odd > if answer % 2: > return answer - 1 > else: > return answer Whoops, this also affects odd numbers... Will try and find a GOOD solution later... Strange request though, why do you need it that way, because 2.5 is CLOSER to 3 than to 2... From fred.sells at adventistcare.org Tue Apr 8 14:16:44 2008 From: fred.sells at adventistcare.org (Sells, Fred) Date: Tue, 8 Apr 2008 14:16:44 -0400 Subject: need help to upload file to webserver In-Reply-To: <47faa04f$0$36349$742ec2ed@news.sonic.net> Message-ID: <0A53725C4A497848A7B3A0874B259831011B08C3@acesxch01.ADVENTISTCORP.NET> I am automating the client side of a simple web interface. I need to upload a file to a webserver that requires authentication. I've got the authentication working with urllib2 (see below), but the only examples I've found to upload files use httplib without authentication. I'm competent with Python but no whiz with web api's. Could I get a little help please. ---------the form I'm trying to simulate looks like this----------------------

------------------my code follows--------------------------------------------- import urllib2, urllib, socket, base64, cookielib import webtools # from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306 STANDARD_HEADERS = {'User-agent':'Mozilla/5.0 (compatible; MSIE 5.5; Windows NT)'} COOKIEFILE = 'cokies.lwp' socket.setdefaulttimeout(30) HTTP = "http://" HTTPS = "https://" #IP, UNAME, PW = "............." #deleted for security top_level_url = "http://..............." PasswordManager = urllib2.HTTPPasswordMgrWithDefaultRealm() PasswordManager.add_password(None, top_level_url, UNAME, PW) AuthenticationHandler = urllib2.HTTPBasicAuthHandler(PasswordManager) opener = urllib2.build_opener(AuthenticationHandler) urllib2.install_opener(opener) class MyConnection: def __init__(self, ipaddr="192.168.1.0", uname=None, password=None): self.SERVER_AND_PORT = "%s:81" % ipaddr self.UNAME = uname def getPage(self, url, kwargs, headers=None): headers = headers or STANDARD_HEADERS request = urllib2.Request(url, urllib.urlencode(kwargs), headers) handle = urllib2.urlopen(request) page = handle.read() handle.close() return page def getValidationReportsPage(self): ########this works self.getPage(HTTPS+self.SERVER_AND_PORT+"/cgi/listrpts.exe",{}) def login(self): #########this works try: print self.getPage(HTTPS+self.SERVER_AND_PORT+"/cgi/mainhtml.exe",{}) except: print 'login failed' def uploadFile(self, filepath): #????????????? need help here buffer = open(filepath).read() headers = dict(STANDARD_HEADERS) #make a copy parms = ('file', filepath, buffer ) contenttype, body = webtools.encode_multipart_formdata([], [parms]) headers['Content-Type']= contenttype data = {'file':body} self.getPage(HTTPS+self.SERVER_AND_PORT+"/cgi/upload.exe",data,headers) def unittest(): print 'start unittest of '+ __file__ X = MyConnection(uname=UNAME, password=PW) X.login() X.uploadFile('testdata/MouseMds.txt') if __name__ == "__main__": unittest() -------------------------------------------------------------------------------- You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost. --------------------------------------------------------------------------- The information contained in this message may be privileged and / or confidential and protected from disclosure. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and deleting the material from any computer. --------------------------------------------------------------------------- From fetchinson at googlemail.com Mon Apr 21 17:36:17 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Mon, 21 Apr 2008 14:36:17 -0700 Subject: Does Python 2.5.2's embedded SQLite support full text searching? In-Reply-To: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> Message-ID: > >> Sqlite itself is not distributed with python. Only a python db api > >> compliant wrapper is part of the python stdlib and as such it is > >> completely independent of the sqlite build. > > > > Don't most binary distributions include SQLite itself? I installed > > 2.5.2 on a new WinXP VM, and SQLite is working fine. > > So did I. I installed py2.5.2 on windows and didn't install SQLite, and I'm > using the module sqlitedb without problems. On linux this is not the case (i.e. on linux one has to install sqlite itself separately) and I assumed on windows you have to install sqlite separately too. My apologies for the misinformation. Cheers, Daniel From stanc at al.com.au Fri Apr 18 05:35:36 2008 From: stanc at al.com.au (Astan Chee) Date: Fri, 18 Apr 2008 19:35:36 +1000 Subject: testing client-server sockets In-Reply-To: References: <4808627F.5040906@al.com.au> <48086408.4070205@al.com.au> Message-ID: <48086B68.5060004@al.com.au> Wierd. It works now. I must've changed something. Oh well, thanks anyway. David Harrison wrote: > On 18/04/2008, Astan Chee wrote: > >> Server code: >> >> import os, sys, socket >> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >> host = '' >> port = 5602 >> s.bind((host,port)) >> try: >> s.listen(1) >> while 1: >> conn, addr = s.accept() >> print 'client is at', addr >> data = conn.recv(1000000) >> data = data * 10 >> z = raw_input() >> conn.send(data) >> conn.close() >> except Exception: >> s.close() >> >> Client code: >> >> import sys, os, socket >> >> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >> host = 'hostIP' >> port = 5602 >> s.connect((host,port)) >> s.send(dlg.user.GetValue()) >> i =0 >> while True: >> data = s.recv(1000000) >> i+=1 >> if (i<5): >> print data >> if not data: >> break >> print 'received', len(data), 'bytes' >> s.close() >> > > I just ran the code (albeit with a tiny change to send a small string > instead so I could see what was going on), and it seems to work fine > ... anything else that might be different ? > > -- "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." Animal Logic http://www.animallogic.com Please think of the environment before printing this email. This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. -------------- next part -------------- An HTML attachment was scrubbed... URL: From lbonafide at yahoo.com Fri Apr 4 15:13:08 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Fri, 4 Apr 2008 12:13:08 -0700 (PDT) Subject: Looking for Advanced Python Tutorials References: Message-ID: <04baf595-49a0-48fd-9837-431cda33e33e@b64g2000hsa.googlegroups.com> On Apr 4, 6:58?am, cokofree... at gmail.com wrote: > I was wondering if anyone knew of some online (free if possible) > advanced tutorials, especially ones that provides tasks and ideas for > small projects. The issue for myself is I want to improve my python > programming level, and my ability to program in general, but come up > blank thinking of a possible task or project to undertake. Look at PyGame (http://pygame.org) and write a simple game, like asteroids or space invaders. Or heck, start with pong. You'll be amazed at how game programming will stretch your programming skills. Or do graphics with PyOpenGL. Google for NeHe's OpenGL tutorials to get you started. From mattheww at chiark.greenend.org.uk Mon Apr 21 18:15:53 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 21 Apr 2008 23:15:53 +0100 (BST) Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3eac67b4-da0a-4926-9ca4-942271513ad2@26g2000hsk.googlegroups.com> Message-ID: Terry Reedy wrote: > Such requests happen about once a month or so. If all the code-hiders were > to have gotten together to openly share their obfuscation ideas and code, I > suspect there would have been something pretty good by now. But in 10 > years of my watching, this does not seem to have happened ;-) I suppose that makes this a frequently asked question. So who maintains the FAQ? -M- From bhmckendrick at gmail.com Sat Apr 26 11:17:52 2008 From: bhmckendrick at gmail.com (animalMutha) Date: Sat, 26 Apr 2008 08:17:52 -0700 (PDT) Subject: Setting an attribute without calling __setattr__() References: <87bq3xej01.fsf@mulj.homelinux.net> <87tzhpd497.fsf@mulj.homelinux.net> Message-ID: <4b2f7629-548f-4868-b423-c1ca716e31f5@m44g2000hsc.googlegroups.com> Hrvoje Niksic wrote: > Hrvoje Niksic writes: > > > Joshua Kugler writes: > > > >> self.me = [] > >> self.me = {} > > > > Use "object.__setattr__(self, 'me') = []" and likewise for {}. > > Oops, that should of course be "object.__setattr__(self, 'me', [])". From bskaplan14 at yahoo.com Wed Apr 9 22:12:25 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Wed, 9 Apr 2008 19:12:25 -0700 (PDT) Subject: How is GUI programming in Python? Message-ID: <620714.1085.qm@web39204.mail.mud.yahoo.com> The pain level all depends on how you go about it. If you try to builda GUI from scratch, it will be very painful. If you use a toolkit, thenit's pretty close to working with Swing. WxPython is the only one I've used, so Ican't give you a "best one". I can say that going from Swing to wxPython wasn't too difficult. Here is the python wiki page with a bunch of the different ways to makecross-platform GUIs, if you want to just look at a couple. http://wiki.python.org/moin/GuiProgramming ----- Original Message ---- From: Chris Stewart To: python-list at python.org Sent: Wednesday, April 9, 2008 9:54:33 PM Subject: How is GUI programming in Python? I've always had an interest in Python and would like to dabble in it further. I've worked on a few very small command line programs but nothing of any complexity. I'd like to build a really simple GUI app that will work across Mac, Windows, and Linux. How painful is that going to be? I used to be really familiar with Java Swing a few years ago. I imagine it will be similar. Next, what would you say is the best framework I should look into? I'm curious to hear opinions on that. Chris Stewart cstewart913 at gmail.com -- http://mail.python.org/mailman/listinfo/python-list __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From cemasoniv at gmail.com Mon Apr 7 17:08:39 2008 From: cemasoniv at gmail.com (Charles Mason) Date: Mon, 7 Apr 2008 17:08:39 -0400 Subject: Data structure recommendation? In-Reply-To: References: <663744510804071339g639bfdccl63de8be66fe52df1@mail.gmail.com> Message-ID: <3290753a0804071408mcf16fb6r3bd746279cdbb8da@mail.gmail.com> If you can imply a partial order on your ranges then you can get O(n lg n) random access using a heap data structure. You'll have to implement your own heap, but heap search is easy to implement (it's Heapify that might require a little thinking). This will only work, of course, if your ranges are disjoint. C On Mon, Apr 7, 2008 at 4:58 PM, Steve Holden wrote: > Steven Clark wrote: > > Hi all- > > > > I'm looking for a data structure that is a bit like a dictionary or a > > hash map. In particular, I want a mapping of floats to objects. > > However, I want to map a RANGE of floats to an object. > > > > This will be used for timestamped storage / lookup, where the float > > represents the timestamp. > > get(x) should return the object with the "newest" (biggest) timestamp > > y <= x, if it exists. > > Example: > > > > foo = Foo() > > > > foo.get(1.5) > > -> None > > foo.put(1.3, 'a') > > foo.put(2.6, 'b') > > foo.get(1.5) > > -> 'a' > > foo.get(7.8) > > -> 'b' > > foo.put(5.0, 'c') > > foo.get(7.8) > > -> 'c' > > > > In otherwords, by the end here, for foo.get(x), > > x < 1.3 maps to None, > > 1.3 <= x < 2.6 maps to 'a', > > 2.6 <= x < 5.0 maps to 'b', > > 5.0 <= x maps to 'c'. > > > > I know that foo.get() will be called many times for each foo.put(). Is > > there any way to achieve O(1) performance for foo.get(), maybe via > > some kind of hash function? Or is the best thing to use some kind of > > binary search? > > > I believe the best way to implement this would be a binary search > (bisect?) on the actual times, which would be O(log N). Though since > they are timestamps they should be monotonically increasing, in which > case at least you don't have to go to the expense of sorting them. > > "Some kind of hash function" won't hack it, since the purpose of a hash > function is to map a large number of (possibly) evenly-distributed > (potential) keys as nearly as possible randomly across a much smaller > set of actual values. > > You might try messing around with reducing the precision of the numbers > to home in on a gross region, but I am not convinced that does anything > other than re-spell binary search if carried to extremes. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From edreamleo at charter.net Thu Apr 3 11:26:38 2008 From: edreamleo at charter.net (Edward K Ream) Date: Thu, 3 Apr 2008 10:26:38 -0500 Subject: ANN: Leo 4.4.8 rc1 released Message-ID: <3H6Jj.17$i_5.5@newsfe06.lga> Leo 4.4.8 rc1 is now available at: http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106 This version features a new ipython plugin that provides a two-way bridge between Leo and IPython. See http://webpages.charter.net/edreamleo/IPythonBridge.html Leo is a text editor, data organizer, project manager and much more. See: http://webpages.charter.net/edreamleo/intro.html The highlights of Leo 4.4.8: ---------------------------- - Leo's source code is now managed by bzr: see link below. - Leo's discussion is now hosted by Google Groups: see link below. - Arguments to g.es and g.es_print can be translated using gettext. - Completed ILeo: a bridge between IPython and Leo. See http://webpages.charter.net/edreamleo/IPythonBridge.html - Minibuffer commands may have arguments. - @menu trees can now refer to commands created by @command and @button nodes. - Added support for common @commands nodes in settings files. Links: ------ Leo: http://webpages.charter.net/edreamleo/front.html Forum: http://groups.google.com/group/leo-editor Download: http://sourceforge.net/project/showfiles.php?group_id=3458 Bzr: http://code.launchpad.net/leo-editor/ Quotes: http://webpages.charter.net/edreamleo/testimonials.html -------------------------------------------------------------------- Edward K. Ream email: edreamleo at yahoo.com Leo: http://webpages.charter.net/edreamleo/front.html -------------------------------------------------------------------- From tjreedy at udel.edu Sun Apr 20 20:29:44 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 20 Apr 2008 20:29:44 -0400 Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com><3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com><480b6133$0$34498$742ec2ed@news.sonic.net><3eac67b4-da0a-4926-9ca4-942271513ad2@26g2000hsk.googlegroups.com> Message-ID: "Roy Smith" wrote in message news:roy-E96A38.14493320042008 at 70-1-84-166.area1.spcsdns.net... | Even if this were worded in a less rude manner, I agree that Stula's response was rude. But it also strikes me as rude for people to whine about not getting free help hiding their code from the very people that they want help from. So I politely suggested that the OP pay for secret help. Such requests happen about once a month or so. If all the code-hiders were to have gotten together to openly share their obfuscation ideas and code, I suspect there would have been something pretty good by now. But in 10 years of my watching, this does not seem to have happened ;-) tjr From mail at timgolden.me.uk Fri Apr 18 16:37:32 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 18 Apr 2008 21:37:32 +0100 Subject: No subject In-Reply-To: <581282.70773.qm@web50110.mail.re2.yahoo.com> References: <581282.70773.qm@web50110.mail.re2.yahoo.com> Message-ID: <4809068C.8090107@timgolden.me.uk> SPJ wrote: > I am writing a script which need's to convert an excel file to > csv (text) format. For that I am using the following code: > > excel = win32com.client.Dispatch("Excel.Application","Quit") > workbook = excel.Workbooks.Open(xlsfile) > workbook.SaveAs(csvfile, FileFormat=24) # 24 represents xlCSVMSDOS > workbook.Close(False) > excel.Quit() > > I did not have any problem running this script on a windows xp > machine with python 2.5.2 and windows extensions. > But I get the following error when I run the same script on a > windows 2003 server with the same python and windows extension installation: > excel = win32com.client.Dispatch("Excel.Application","Quit") > File "D:\Python25\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch > dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) > File "D:\Python25\lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName > return (_GetGoodDispatch(IDispatch, clsctx), userName) > File "D:\Python25\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) > com_error: (-2147221005, 'Invalid class string', None, None) What's that "Quit" doing as the second param to Dispatch? TJG From deets at nospam.web.de Tue Apr 22 11:10:00 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 17:10:00 +0200 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <6760jfF2n3bn1U1@mid.uni-berlin.de> Message-ID: <676desF2nrgitU1@mid.uni-berlin.de> > I have a couple issues with this, though I wholeheartedly agree with > the sentiment: > > 1. Java didn't grow interfaces, they were there from the start. I might have expressed myself wrong here - I should have written "needed to introduce interfaces (right from the start)" > 2. Java interfaces solve a different problem than MI (used properly) > does: interfaces are there to make types polymorphic, whereas > inheritance's main use is to share behavior. But the *goal* of the polymorphy is mainly to have shared behavior. And matter of factly e.g. in swing, you use inner classes that implement most of the behavior you want, and override the few points where you want differences - and then clumsily delegate to that inner class all your interface-methods. Diez From namesagame-usenet at yahoo.com Tue Apr 29 18:06:10 2008 From: namesagame-usenet at yahoo.com (gamename) Date: Tue, 29 Apr 2008 15:06:10 -0700 (PDT) Subject: Sending Cntrl-C ?? References: <0274834e-17e1-4a95-88ec-f2aa77aeb3a9@k10g2000prm.googlegroups.com> Message-ID: > import os > import signal > import subprocess > > popen = subprocess(...) > os.kill(popen.pid, signal.SIGINT) > > Or with Python 2.6+: > > popen.send_signal(signal.SIGINT) Thanks, Christian. Would that work on win32 as well? -T From kkuhl05 at gmail.com Tue Apr 29 02:07:03 2008 From: kkuhl05 at gmail.com (Kevin K) Date: Mon, 28 Apr 2008 23:07:03 -0700 (PDT) Subject: File IO Issues, help :( References: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> Message-ID: <1fd8deae-1ed4-493c-a508-06c528c4ee1f@r66g2000hsg.googlegroups.com> On Apr 29, 12:55 am, Peter Otten <__pete... at web.de> wrote: > Kevin K wrote: > > On Apr 29, 12:38 am, "Eric Wertman" wrote: > >> chuck in a jsfile.close(). The buffer isn't flushing with what you > >> are doing now. jsfile.flush() might work... not sure. Closing and > >> re-opening the file for sure will help though. > > > Yeah sorry I forgot to include the close() in the quote but its there. > > In fact I moved it up a bit and still no luck heres the new code: > > > jsfile = open("../timeline.js", "r+") > > jscontent = jsfile.readlines() > > jsfile.truncate() > > > for line in jscontent: > > if re.search('var d =', line): > > line = "var d = \""+mint['1'].ascdate()+"\"\n" > > print line > > jsfile.write(line) > > jsfile.close() > > > I tried this can got the same result...?? > > """ > truncate(...) > truncate([size]) -> None. Truncate the file to at most size bytes. > > Size defaults to the current file position, as returned by tell(). > """ > > After the readlines() call the current file position is at the end of the > file. Try jsfile.truncate(0). > > Also note that readlines() reads the whole file into memory. For large files > it would therefore be better to write to a new file and rename it > afterwards. > > Peter Thanks Peter that seemed to be most of the problem, however I now have a bunch of null characters in the file. Could it be an unwanted line in the list that im writing? Thanks, Kevin From grante at visi.com Fri Apr 18 16:17:35 2008 From: grante at visi.com (Grant Edwards) Date: Fri, 18 Apr 2008 15:17:35 -0500 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> Message-ID: <1aadnUuqsapCnJTVnZ2dnUVZ_jqdnZ2d@visi> On 2008-04-18, Bob Greschke wrote: > I'm reading 3-byte numbers from a file and they are signed (+8 to > -8million). This seems to work, but I'm not sure it's right. > > # Convert the 3-characters into a number. > Value1, Value2, Value3 = unpack(">BBB", Buffer[s:s+3]) > Value = (Value1*65536)+(Value2*256)+Value3 > if Value >= 0x800000: > Value -= 0x1000000 > print Value > > For example: > 16682720 = -94496 > > Should it be Value -= 0x1000001 so that I get -94497, instead? Nope. -94496 is the right answer: >>> -94496 & 0xffffff 16682720 Here's another way to do it: ------------------------------------------------------------------ import struct def tohex(s): return '0x' + ''.join(['%0.2x' % ord(b) for b in s]) def from3Bytes(s): # sign extend the three byte number in s to make it 4 bytes long if ord(s[0]) & 0x80: s = '\xff'+s else: s = '\x00'+s return struct.unpack('>i',s)[0] for v in 0,1,-2,500,-500,7777,-7777,-94496,98765,-98765,8388607,-8388607,-8388608: s = struct.pack('>i',v)[1:] print "%8d %s %8d" % (v, tohex(s), from3Bytes(s)) ------------------------------------------------------------------ -- Grant Edwards grante Yow! I'll eat ANYTHING at that's BRIGHT BLUE!! visi.com From bignose+hates-spam at benfinney.id.au Wed Apr 16 18:18:48 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Thu, 17 Apr 2008 08:18:48 +1000 Subject: Death of NNTP greatly exaggerated (was: Finally had to plonk google gorups.) References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <87k5ixwiif.fsf_-_@benfinney.id.au> Michael Torrie writes: > I rarely use NNTP these days. I access c.l.py exclusively via e-mail, > and that works very well. I rarely use email for technical mailing lists these days. I access such forums exclusively via NNTP , and that works very well. > This official python list is one of the few lists that's even still on > nntp. All my other ones (gnome, gtk, openldap, clamav, freeradius, etc) > are all e-mail mailing lists only and it works very well. In fact, I > think it's much better since list subscription can actually be > controlled by someone. Most technical mailing lists are accessible via NNTP on gmane.org. It works very well. Other discussion groups remain on Usenet, accessible via NNTP from servers around the world that mirror each group. In fact, I think it's much better since I can use any one of those servers, and the content isn't locked up in one specific server. -- \ "I'm beginning to think that life is just one long Yoko Ono | `\ album; no rhyme or reason, just a lot of incoherent shrieks and | _o__) then it's over." -- Ian Wolff | Ben Finney From arnodel at googlemail.com Wed Apr 9 12:18:44 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Wed, 9 Apr 2008 09:18:44 -0700 (PDT) Subject: How to find documentation about methods etc. for iterators References: <47fce941$0$755$bed64819@news.gradwell.net> Message-ID: On Apr 9, 5:05 pm, tinn... at isbd.co.uk wrote: > I'm not sure if I have even phrased that right but anyway.... > > How does one find (in the standard Python documentation) information > about things like the iteritems() method and the enumerate() function. > > They are mentioned in the tutorial as ways of getting more information > as you loop through an object but there seems to be no easy way to > find the definitive documentation of these sorts of methods and > functions. OK, if I know the name before I start I can probably find > what I want, but what if I want to know how to extract some > information from an object as I loop and don't know what I want is > called? > > My particular quest that raised this was a way to get the line number > as I iterate through the lines of a file:- > > f = open(fn, 'r') > lineNo = 0 > for ln in f: > lineNo += 1 > > Is there a neater way of getting that line number as I go? If so how > am I meant to find out about it? There is a neater way, and you mention it in your question: f = open('myfile') for lineno, line in enumerate(f): # Do stuff How to find out about it? I suppose you need to get familiar with python iterators/iterables and the functions to manipulate them. How to do that depends on your prior experience with such concepts. Unfortunately I am not able to provide you with a good link :( -- Arnaud From leoniaumybragg at gmail.com Sat Apr 26 06:59:59 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:59:59 -0700 (PDT) Subject: spynomore crack Message-ID: spynomore crack http://cracks.00bp.com F R E E C R A C K S From kyosohma at gmail.com Fri Apr 11 21:06:24 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 11 Apr 2008 18:06:24 -0700 (PDT) Subject: win-shortcuts, file associates and command-line parameters ? References: <47FE6480.4090602@gmail.com> Message-ID: On Apr 11, 4:40 pm, Stef Mientki wrote: > Gabriel Genellina wrote: > > En Thu, 10 Apr 2008 16:03:28 -0300, Stef Mientki > > escribi?: > > >> under windows I tried to make a shortcut to a py -file, to run a program. > >> So making a shortcut like this works perfect: > >> D:\PyLab_Works.py > > >> But the problem is that I need to give some commandline parameters to > >> the py-file, > >> and > > >> D:\PyLab_Works.py btc_test > >> But the parameter doesn't seem to arrive in the python program > > > Check the associated command for .py files; see this message > >http://groups.google.com/group/comp.lang.python/msg/056ba14ae4fa57e3 > > Didn't work for me winXP-SP2, even after a restart :-( > But anyway thanks for the effort. > > cheers, > Stef Mientki You could try uninstalling Python and reinstalling it. Or you could do a registry hack. I did a search for what Gabriel was talking about and it looks like the key you want is found here: HKEY_LOCAL_MACHINE\software\classes\applications\pythonw.exe\shell \Edit with IDLE\command Mine has the following for its value: "L:\Python24\pythonw.exe" "L:\Python24\Lib\idlelib\idle.pyw" -n -e "%1" %* Make sure that the type is REG_SZ. As always, unless you know what you're doing, back up the registry (or create a restore point) before messing with it. However, I think the only thing that this hack could possibly do is mess up your Python install more if it was screwed up. Mike From Laundro at gmail.com Tue Apr 8 09:06:55 2008 From: Laundro at gmail.com (LaundroMat) Date: Tue, 8 Apr 2008 06:06:55 -0700 (PDT) Subject: Reproducing a web page and add own content to it. References: <6615blF2ifaqcU1@mid.uni-berlin.de> Message-ID: <1cddd2af-28be-42ee-8004-0d76978aeaa9@b9g2000prh.googlegroups.com> On Apr 8, 2:04 pm, "Diez B. Roggisch" wrote: > LaundroMat wrote: > > Hi - > > > I'm working on a Django powered site where one of the required > > functionalities is the possibility of displaying the content of > > external pages, with an extra banner at the top where specific > > information is displayed. In other words, I'm looking for a way to > > reproduce an existing web page and add some HTML code to it. (I can't > > think of an example right now, but the idea is similar to sites that > > let you see an external page and have some site-specific text above it > > (often stating that the content below is not part of the site the user > > comes from)). > > > To test this, I've been downloading an external page, adding some text > > to it and re-opening it in a browser (with the help of built-in > > modules such as urllib2 etc). This works of course, but the external > > page's links such as , or
> > are evidently no longer correct. > > > Apart from parsing the whole file and trying to inject the external > > site's domain in links such as the above (with the added inconvenience > > of having to store the external page locally), is there an easier way > > of accomplishing what I want? > > Using a frame? > > Diez Ack. I was too focused on importing the external web page and redisplaying the information (I've just been reading up on BeautifulSoup) instead of looking for an HTML based approach. Thanks! From luismgz at gmail.com Thu Apr 3 09:33:42 2008 From: luismgz at gmail.com (=?ISO-8859-1?Q?Luis_M=2E_Gonz=E1lez?=) Date: Thu, 3 Apr 2008 06:33:42 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> Message-ID: <89bca327-6a3f-4128-be72-75d4a50b9bf0@13g2000hsb.googlegroups.com> I have come to the same conclusion. ORMs make easy things easier, but difficult things impossible... The best approach I've seen so far is webpy's (if we are talking of web apps). It isn't an ORM, it is just a way to make the database api easier to use. Queries don't return objects, they return something similar to dictionaries, which can be used with dot notation ( for example, result.name is equal to result['name'] ). A simple select query would be db.select('customers') or db.select('customers', name='John'). But you can also resort to plain sql as follows: db.query('select * from customers where name = "John"'). Simple, effective and doesn't get in your way. Luis From aldo at nullcube.com Mon Apr 7 03:51:42 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Mon, 7 Apr 2008 17:51:42 +1000 Subject: Adherence to PEP 8 for published code (was: ANN: pry unit testing framework) In-Reply-To: <87d4p2mcrp.fsf_-_@benfinney.id.au> References: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> <87d4p2mcrp.fsf_-_@benfinney.id.au> Message-ID: <20080407075142.GA17450@nullcube.com> Thus spake Ben Finney (bignose+hates-spam at benfinney.id.au): > PEP 8 only has the force that people grant it. Nevertheless, it's a > style guide that's widely accepted in the Python community, and > adhering to it in one's code makes it easier to read for the majority, > because it reduces the needless inconsistencies between different > bodies of code. > > Conversely, deliberately diverging from the widely-accepted style > guide increases the cognitive load on the reader; if that divergence > is not done for a very good reason, one is imposing needless burden on > every reader of the code. This is getting silly. Let's recap. You are upset because I prefer this widely-used method naming convention: object.myName() ... to this one, which was recently adopted as a recommendation in PEP 008 for modules in the standard library: object.my_name() By doing so, you say, I am "imposing needless burden on every reader" of my code... Well, lets look at the facts: First, PEP 8 recommends a naming scheme only for the standard library, and it is not follwed consistently even there. Second, mixedCase is very common both inside and outside the Python project. No-one who codes regularly in Python can be unfamiliar with it, even if they never stray beyond the standard library. Third, this is a minor, recently-introduced convention. Anyone would dislike code that chose not to name classes with an initial capital, or used something other than "self" as the first method parameter. Method naming conventions are far, far fuzzier. The primary issue is simply to clearly distinguish between words in multi-word names - mymethodname would be bad, MYMETHODNAME would be even worse, but my_method_name and myMethodName are both perfectly legible. You are mis-interpreting the intent behind PEP-8 if you think its authors intended to provoke shrill public condemnation of any module that dares to use a long-standing, widely-used alternative method naming scheme. In fact, PEP 8 contains an entire section warning against exactly this kind of inflexible and small-minded application of its recommendations - perhaps you should read it sometime. > > You're also vastly overstating the impact of a minor naming > > convention choice. Calling this a "large black mark" smacks of > > scare-mongering to me. > > When distributing code with the expectation that others use it, it's a > large black mark if it deliberately shun the widely-accepted, > easily-followed coding standards, for the above reasons. > > I don't see why that would be scary. If you find it so, you have my > sympathy. You re-enforce the point you're trying to counter beautifully. Thanks for driving my argument home. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From sean.m.mcdaniel at gmail.com Fri Apr 25 08:55:15 2008 From: sean.m.mcdaniel at gmail.com (s.mcdaniel) Date: Fri, 25 Apr 2008 05:55:15 -0700 (PDT) Subject: Installation in a local directory References: <2008042500101716807-seanmmcdaniel@gmailcom> Message-ID: On Apr 25, 12:37 am, Steve Holden wrote: > Sean McDaniel wrote: > > Hi y'all, > > > I'm trying to perform a local install of python at work in my user > > directory. Everything compiles correctly, but I can't seem to tell the > > configure script the location of the bin and lib directories where I > > want my stuff. I've think I've passed the correct flags to the > > 'configure' script. > > > make clean > > ./configure --enable-shared --prefix=/user/mcdaniel/arch32 > > make > > > where arch32 contains the the lib and bin directories where I want my > > python stuff to go. Unfortunately these directories are not written to; > > everything ends up in the default location from where I ran 'make'. > > Moreover, if I add a symbolic link from the python binary (which I can > > run directly without problems) to the bin directory so that my PATH will > > recognize the new python, I get an error about loading shared libraries. > > > I'm making on a 32 bit new debian system. > > > Thank you for your help, > > Did you run "make install" yet? It's that step that moves the binaries > to where they should live. As it says in > > http://www.python.org/download/releases/2.5/ > > """Change to the Python-2.5 directory and run the "./configure", "make", > "make install" commands to compile and install Python.""" > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ Damnit, That was exactly the problem. Thank you. Sean From mal at egenix.com Mon Apr 14 10:01:27 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Mon, 14 Apr 2008 16:01:27 +0200 Subject: Compiling Python 2.5.2 on AIX 5.2 In-Reply-To: <0b73e8e5-c301-4823-ac94-42f757456cf1@x19g2000prg.googlegroups.com> References: <0b73e8e5-c301-4823-ac94-42f757456cf1@x19g2000prg.googlegroups.com> Message-ID: <480363B7.3040004@egenix.com> On 2008-04-13 18:57, Randy.Galbraith at gmail.com wrote: > I'm investigating the possible use of Mecurial SCM as a replacement > for CVS. Mecurial is written in Python. I have a background in GNU/ > Linux, Solaris, sparc and Perl. However AIX, powerpc and Python are > new to me. On AIX 5.3, Python 2.5.2 should build out of the box using gcc. We've successfully build Python 2.3, 2.4 and 2.5 on AIX 5.3 using the gcc compiler suite and tools installed from the AIX Linux Toolbox: http://www-03.ibm.com/systems/p/os/aix/linux/toolbox/altlic.html ./configure --enable-unicode=ucs2 --with-gcc For 2.3 and 2.4 you need to patch pyconfig.h after the configure run: *** pyconfig.h~ Wed Nov 14 17:22:01 2007 --- pyconfig.h Wed Nov 14 17:22:01 2007 *************** *** 49,55 **** /* #undef HAVE_BROKEN_POLL */ /* Define if the Posix semaphores do not work on your system */ ! /* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ /* Define if pthread_sigmask() does not work on your system. */ /* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ --- 49,55 ---- /* #undef HAVE_BROKEN_POLL */ /* Define if the Posix semaphores do not work on your system */ ! #define HAVE_BROKEN_POSIX_SEMAPHORES 1 /* Define if pthread_sigmask() does not work on your system. */ /* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 14 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From yzghan at gmail.com Wed Apr 23 10:44:23 2008 From: yzghan at gmail.com (yzghan at gmail.com) Date: Wed, 23 Apr 2008 07:44:23 -0700 (PDT) Subject: python has memory leak? References: Message-ID: Thanks to Christian and Jean-Paul for your reply. I moved away from the stackless version (which I don't understand what uniqueness it comes with) and downloaded a fresh copy of Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32. Following J-P's suggestion, I included the block to be tested in a loop: i=20 while i>0: i=i-1 test(log) log.flush() And logged the memory usage in bytes instead of MB. The result as included below shows the peak memory usage keeps going up in the first 7 iterations. Can someone point to some docs or books about how python manages memory or share some experience? Thanks, -GH [10:27:54] test() starting ... memory usage: 4599808L 4599808L [10:27:56] test() ... memory usage: 107499520L 107499520L [10:27:56] test() done. memory usage: 41754624L 107503616L [10:27:56] test() starting ... memory usage: 41754624L 107503616L [10:27:59] test() ... memory usage: 108216320L 108400640L [10:27:59] test() done. memory usage: 58884096L 108400640L [10:27:59] test() starting ... memory usage: 58884096L 108400640L [10:28:02] test() ... memory usage: 108220416L 108433408L [10:28:02] test() done. memory usage: 42233856L 108433408L [10:28:02] test() starting ... memory usage: 42233856L 108433408L [10:28:04] test() ... memory usage: 108228608L 108441600L [10:28:05] test() done. memory usage: 75149312L 108441600L [10:28:05] test() starting ... memory usage: 75149312L 108441600L [10:28:07] test() ... memory usage: 108498944L 108707840L [10:28:07] test() done. memory usage: 41992192L 108707840L [10:28:07] test() starting ... memory usage: 41992192L 108707840L [10:28:10] test() ... memory usage: 108122112L 108707840L [10:28:10] test() done. memory usage: 58523648L 108707840L [10:28:10] test() starting ... memory usage: 58523648L 108707840L [10:28:13] test() ... memory usage: 108642304L 108855296L [10:28:13] test() done. memory usage: 41873408L 108855296L [10:28:13] test() starting ... memory usage: 41873408L 108855296L [10:28:16] test() ... memory usage: 108224512L 108855296L [10:28:16] test() done. memory usage: 58626048L 108855296L [10:28:16] test() starting ... memory usage: 58626048L 108855296L [10:28:18] test() ... memory usage: 108224512L 108855296L [10:28:19] test() done. memory usage: 41975808L 108855296L [10:28:19] test() starting ... memory usage: 41975808L 108855296L [10:28:21] test() ... memory usage: 108224512L 108855296L [10:28:22] test() done. memory usage: 58626048L 108855296L [10:28:22] test() starting ... memory usage: 58626048L 108855296L [10:28:24] test() ... memory usage: 108224512L 108855296L [10:28:24] test() done. memory usage: 41975808L 108855296L [10:28:24] test() starting ... memory usage: 41975808L 108855296L [10:28:27] test() ... memory usage: 108224512L 108855296L [10:28:27] test() done. memory usage: 58626048L 108855296L [10:28:27] test() starting ... memory usage: 58626048L 108855296L [10:28:30] test() ... memory usage: 108224512L 108855296L [10:28:30] test() done. memory usage: 41975808L 108855296L [10:28:30] test() starting ... memory usage: 41975808L 108855296L [10:28:32] test() ... memory usage: 108224512L 108855296L [10:28:33] test() done. memory usage: 58626048L 108855296L [10:28:33] test() starting ... memory usage: 58626048L 108855296L [10:28:35] test() ... memory usage: 108224512L 108855296L [10:28:36] test() done. memory usage: 41975808L 108855296L [10:28:36] test() starting ... memory usage: 41975808L 108855296L [10:28:38] test() ... memory usage: 108224512L 108855296L [10:28:38] test() done. memory usage: 58626048L 108855296L [10:28:38] test() starting ... memory usage: 58626048L 108855296L [10:28:41] test() ... memory usage: 108224512L 108855296L [10:28:41] test() done. memory usage: 41975808L 108855296L [10:28:41] test() starting ... memory usage: 41975808L 108855296L [10:28:44] test() ... memory usage: 108224512L 108855296L [10:28:44] test() done. memory usage: 58626048L 108855296L [10:28:44] test() starting ... memory usage: 58626048L 108855296L [10:28:46] test() ... memory usage: 108224512L 108855296L [10:28:47] test() done. memory usage: 41975808L 108855296L [10:28:47] test() starting ... memory usage: 41975808L 108855296L [10:28:49] test() ... memory usage: 108224512L 108855296L [10:28:50] test() done. memory usage: 58626048L 108855296L From zoom.quiet at gmail.com Fri Apr 25 02:13:42 2008 From: zoom.quiet at gmail.com (Zoom.Quiet) Date: Fri, 25 Apr 2008 14:13:42 +0800 Subject: [ulipad:2586] [ANN]UliPad 3.9 released! In-Reply-To: <505f13c0804242310n62b0720fs60f36b83d8ea9ab4@mail.gmail.com> References: <505f13c0804242310n62b0720fs60f36b83d8ea9ab4@mail.gmail.com> Message-ID: <9dad9f0a0804242313m4b2d96sb7ed7ae48fe75bc8@mail.gmail.com> good job! enjoy now! 2008/4/25 limodou : > > UliPad is a flexible editor, based on wxPython. It's has many features,just > like:class browser, code auto-complete, html viewer, directory browser, wizard, > etc. The main feature is the usage of mixin. This makes UliPad can be > extended easily. So you can write your own mixin or plugin, or simple script, > these can be easy and seamless integrated with UliPad. > > New Features and Changes: > > #. Add php.acp thanks for ?? > #. Replace old snippet with new snippet, more details please see > <`Snippet Howto `_> > #. Binding F5 to editor but not MainFrame, and add F5(Refresh) support > in Directory Browser. > #. Improve python class browser, threading update, change some icons > #. Add indent cursor move functionality see <`Indent Moving Howto > `_> > #. Improve threading document modification process, so you can get > better efficiency > #. Introduce meide(http://code.google.com/p/meide) project to simplify > the interface creation > #. Add FNB.FNB_DROPDOWN_TABS_LIST style to EditorCtrl > #. Change auto file check in Editor on_set_focus event handler > #. Change DDE to asyncore and asynchat framework > #. Change preference dialog from notebook to treebook > #. Add icon set theme support > #. Add strip line ending when saving functionality option in Preferences > #. Strip leading space when doing "Run in Shell" > #. Add auto detect python interpreter in windows platform > #. Improve ReST document render, and fix the setfocus lost bug when > auto modified > the html output, thanks a lot to ygao > #. Change setmenutext to use fix width to set the menu text, replace with '\t' > #. Chanage notebook left double click to right double click(enlarge > notebook size) > #. Add search text count in Find & Replace pane > #. Add line ending mixture check when saving file feature > #. Improve preference dialog input assistant checkbox process. > When you check the first checkbox(Enable input assistant) it'll > automatically toggle other 5 checkboxes. > #. Change new toolbutton to dropdown toolbutton, and it can remember the last > new file type(select new type menu first), then when you select new menu, > it'll create a new file with the last new file type > #. Improve command search and pairprog plugin caret display process > #. Add auto new version of UliPad check > #. Add slice language syntax support > #. Add auto pop up project setting dialog when adding directory to > directoy browser window > #. Add Open Explorer Window Here menu to editoctrl tab context menu > #. Add open snippet tool button, change open dirbrowser and open > snippet toolbutton to check toolbutton > #. Change ``explorer.exe %s`` as ``explorer.exe /e, %s`` in windows platform > #. Add copy filename to clipboard menu on document area tab context menu > #. Add wrap text feature, via [Edit]->[Format]->[Wrap Text...] > > New Plugins: > > #. canvas_test_plugin, you can directly test DC api > #. web2py_plugin, supply web2py shell > > Bug fix: > > #. Fix webopen twice open bug > #. Fix editor shortcuts key caption error > #. Fix if set DROP_DOWN_TABS_LIST style, right arrow will disappear bug > #. Fix utf-16 convertion bug > #. Fix mako tag auto complete bug #issue 14 > #. Fix if lines are folded, when goto hiding lines will no effect bug > #. Fix DDE bug, thanks to LP > #. Fix webopen bug, can't correctly deal with 'mailto:' > #. Fix smart tabs bug > #. Fix copy and paste lineending is not correct bug > #. Fix tab invisible bug after changing size or changing the page title > #. Fix template line-ending not match the default line-ending setting > #. Fix password widget is not Password type widget bug > #. Fix script filename cannot be unicode(chinese) bug > #. Fix syntax check exception process bug > #. Fix ruler bug > > UliPad has ported to code.google.com, so you can visit the new project site at: > http://code.google.com/p/ulipad, and also visit the new svn address. Recommends > using source version. > > source version download: http://ulipad.googlecode.com/files/ulipad.3.9.zip > window exe version: http://ulipad.googlecode.com/files/ulipad.3.9.exe > > maillist: http://groups.google.com/group/ulipad > ulipad snippets site: http://ulipad.appspot.com (hosted by GAE) > > Hope you enjoy it. > -- > I like python! > UliPad <>: http://code.google.com/p/ulipad/ > UliSpot <>: http://ulipad.appspot.com > My Blog: http://www.donews.net/limodou > -- '''????????????????????! PI keeps evolving organizations which promoting people be good! '''http://zoomquiet.org Pls. usage OOo to replace M$ Office. http://zh.openoffice.org Pls. usage 7-zip to replace WinRAR/WinZip. http://7-zip.org You can get the truely Freedom 4 software. From Stephen.Cattaneo at u4eatech.com Thu Apr 3 10:31:06 2008 From: Stephen.Cattaneo at u4eatech.com (Stephen Cattaneo) Date: Thu, 3 Apr 2008 07:31:06 -0700 Subject: manipulating hex values In-Reply-To: References: <47F26CC3.3060307@u4eatech.com> Message-ID: Thanks to everyone ( Grant, Cliff, and Gabriel) for responding and helping me. Cheers, Steve -----Original Message----- From: Grant Edwards [mailto:grante at visi.com] Sent: Tuesday, April 01, 2008 7:46 PM To: python-list at python.org Subject: Re: manipulating hex values On 2008-04-01, Stephen Cattaneo wrote: >>> I am relatively new to socket programming. I am attempting to >>> use raw sockets to spoof my IP address. >> >> Don't bother to try... > > Is there a better solution to spoofing my IP. then using raw > sockets You'll have to define "spoofing my IP", but I suspect that what you're trying can't be done by using raw sockets. > (I'm working on a machine with multiple interfaces and need to > be able to some how specify which interface that traffic needs > to be sent/recieved to/from) That's what routing tables are for. If you want to send packets using a particular IP, then configure an interface so that it has that adrress, and then bind your socket to that address. > The source of my confusion is that I need to keep my bytes formated > correctly. I am using the below 'raw socket example' proof-of-concept > code as my example. OK. > (And yes, I have tried the proof-of-concept. It works > correctly. It is not my code.) I know. It's my code. :) I wrote Python's raw socket support code and the example code that is floating around the 'net. > dstAddr = "\x01\x02\x03\x04\x05\x06" > dstAddr1 = "0x010203040506" > dstAddr != dstAddr1 Right. > Follow up question: What is the best to store my bytes up > until sending the packets? That depends on what you want to do with them. Ultimately, they need to be strings when they're sent out the socket (in Python a "string" is really just an array of 8-bit bytes). The best way to store them is entirely dependent on how you want to manipulate them before they're sent. > Perhaps I should use lists of decimal numbers and then > before sending convert to hex. Again: you're not converting them to hex. You're converting them to a python "string" object which is really just an array of bytes. Stop saying "hex" when you're talking about a string (array of bytes). "hex" is a way to _represent_ a value textually. It's simply a format used when print a value on paper or a screen. The value itself isn't hex any more than a particular instance of Canis lupus familiaris is "English" because somebody spells it "dog" instead of "chien" or "Hund". > I.E. dstAddr = [ 1, 2, 3, 4, 5, 6] > dstAddr.prepareToSend() I presume you know that list objects don't have a method called prepareToSend(). > txFrame = struct.pack("!6s6sh",dstAddr,srcAddr,proto) + ethData > > Is there a better way to do this? It's not at all clear what "this" is. If you want to convert from a list (or any sequence, really) of integer objects to a string where each integer is converted into a single byte within the string, then here are a few ways: import operator import struct intlist = [1,2,3,4,5,6] s1 = ''.join(chr(b) for b in intlist) s2 = reduce(operator.add,[chr(b) for b in intlist]) s3 = struct.pack("6B",*tuple(intlist)) print repr(s1) print repr(s2) print repr(s3) print s1==s2 print s2==s3 When run you get this: '\x01\x02\x03\x04\x05\x06' '\x01\x02\x03\x04\x05\x06' '\x01\x02\x03\x04\x05\x06' True True I think the third alternative using struct.pack() is the most readable, but others will no doubt disagree. -- Grant Edwards grante Yow! I'm GLAD I at remembered to XEROX all visi.com my UNDERSHIRTS!! From lists at cheimes.de Fri Apr 25 17:43:30 2008 From: lists at cheimes.de (Christian Heimes) Date: Fri, 25 Apr 2008 23:43:30 +0200 Subject: Subclassing datetime.date does not seem to work In-Reply-To: <4811FF57.5040200@comcast.net> References: <4811FF57.5040200@comcast.net> Message-ID: <48125082.5020409@cheimes.de> Rick King schrieb: > I would like to subclass datetime.date so that I can write: > > d = date2('12312008') > > I tried: > > from datetime import date > class date2(date): > def __init__( self, strng ): > mm,dd,yy = int(strng[:2]), int(strng[2:4]), int(strng[4:]) > date.__init__(self,yy,mm,dd) > > But then this statement: > d = date2('12312008') > > Causes: > TypeError: function takes exactly 3 arguments (1 given) > > Is there something basically wrong with subclassing date? > -Rick King datetime.date is a C extension class. Subclassing of extension classes may not always work as you'd expect it. Christian From skanemupp at yahoo.se Wed Apr 16 16:18:22 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Wed, 16 Apr 2008 13:18:22 -0700 (PDT) Subject: Profiling, recursive func slower than imperative, normal? Message-ID: the 0.409 vs 0.095 is the total times right? so the imperative function is >4 times faster than the recursive. or what does tottime stand for? is this always the case that the recursive function is slower? the gain is less code? are some functions only implementable recursively? def power(nbr, po): if po==0: return 1 if po>0: return nbr*power(nbr, po-1) if po<0: return 1/power(nbr, -1*po) 109992 function calls (10002 primitive calls) in 0.409 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.015 0.015 0.409 0.409 :1(test1) 1 0.000 0.000 0.409 0.409 :1() 109989/9999 0.394 0.000 0.394 0.000 myMath.py:39(power) 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} def power2(nbr, po): acc=1 if po >= 1: acc=nbr for x in range(1, po): acc=acc*nbr if po < 0: if nbr!=0: acc=1 for x in range(0, po, -1): acc=acc/nbr else: return "Division by zero" return acc 20001 function calls in 0.095 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.026 0.026 0.095 0.095 :1(test1) 1 0.000 0.000 0.095 0.095 :1() 9999 0.051 0.000 0.069 0.000 myMath.py:47(power2) 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} 9999 0.017 0.000 0.017 0.000 {range} From theiviaxx at gmail.com Wed Apr 23 20:16:32 2008 From: theiviaxx at gmail.com (theiviaxx at gmail.com) Date: Wed, 23 Apr 2008 17:16:32 -0700 (PDT) Subject: python-ldap - Operations Error Message-ID: Hello all, I am trying to integrate TurboGears with our Active Directory here at the office. TurboGears aside, i cannot get this to work. The simplest thing i can do to test this is: >>> import ldap >>> l = ldap.initialize("ldap://server.net") >>> l.simple_bind(DN, "secret") 1 >>> l.result(1) (97, []) >>> l.search("dc=server,dc=net", ldap.SCOPE_SUBTREE, "(sAMAccountName=user)") OPERATIONS_ERROR: {'info': '00000000: LdapErr: DSID-0C090627, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, vece', 'desc': 'Operations error'} The simple bind works fine and returns a result, when i get the result, it returns 97 meaning successful. So there was a successful bind on the connection, right? I'm really not sure where the problems lies. Is it with the way im connecting or is it something to do with our AD server? Thanks From gagsl-py2 at yahoo.com.ar Thu Apr 24 00:21:15 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 24 Apr 2008 01:21:15 -0300 Subject: Problem using copy.copy with my own class References: <676noiF2n7ttmU1@mid.uni-berlin.de> <480FFF55.5070803@gmail.com> Message-ID: En Thu, 24 Apr 2008 00:32:37 -0300, Michael Torrie escribi?: > Jeffrey Barish wrote: >> Marc 'BlackJack' Rintsch wrote: >>> Please simplify the code to a minimal example that still has the >>> problem >>> and *show it to us*. It's hard to spot errors in code that nobody >>> except >>> you knows. >> >> Here it is: >> >> import copy >> >> class Test(int): >> def __new__(cls, arg1, arg2): > ^^^^^^^ > The exception is saying that copy.copy is not providing this 3rd > argument. I might be a bit dense, but what would arg2 be for? Isn't > arg1 supposed to be the object instance you are copying from? If so, > arg2 is superfluous. I agree. In case arg2 were really meaningful, use __getnewargs__ (see ) import copy class Test(int): def __new__(cls, arg1, arg2): return int.__new__(cls, arg1) def __init__(self, arg1, arg2): self.arg2 = arg2 def __getnewargs__(self): return int(self), self.arg2 py> t = Test(3, 4) py> print type(t), t, t.arg2 3 4 py> t_copy = copy.copy(t) py> print type(t_copy), t_copy, t_copy.arg2 3 4 But note that subclassing int (and many other builtin types) doesn't work as expected unless you redefine most operations: py> x = t + t_copy py> print type(x), x 6 py> t += t_copy py> print type(t), t 6 -- Gabriel Genellina From martin at v.loewis.de Thu Apr 24 10:21:50 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Thu, 24 Apr 2008 16:21:50 +0200 Subject: py3k concerns. An example In-Reply-To: References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: <4810977E.3060509@v.loewis.de> > Again, to me, this is a non-issue because I've been able to create a > cross-version compatible single codebase for pyparsing. But it was a > bit dicey there for a while, and I think other module developers/ > maintainers may not be so lucky. I'm more optimistic. I tried it for Django, and while the port is not complete, it goes really well and supports "basic" operations (i.e. the Django tutorial). Based on your experience, and other reports, I think there is a fair chance that you can support a wide range of versions (2.x and 3.x) from a single code base for most projects. > - create (if possible) single cross-version compatible code > - forego support of 3.0 users > - discontinue pre-2.6 support for future versions of their module > - maintain dual codebase One needs to consider the drawbacks in each case; for the single codebase approach, the drawback probably is that readability suffers, and the need for testing increases (but it does always if you support multiple targets). It also requires expertise to create such cross-version code in the first place, but that's "just" a learning issue (i.e. you have to keep the rules in mind that you want to follow). Regards, Martin From python.list at tim.thechases.com Wed Apr 16 09:53:02 2008 From: python.list at tim.thechases.com (Tim Chase) Date: Wed, 16 Apr 2008 08:53:02 -0500 Subject: vary number of loops In-Reply-To: References: Message-ID: <480604BE.3090002@tim.thechases.com> > I'm new to Python and the notion of lambda, and I'm trying to write a > function that would have a varying number of nested for loops > depending on parameter n. This just smells like a job for lambda for > me, but I can't figure out how to do it. Any hint? I'm not sure lambda is the tool to use here. Doable, perhaps, but improbable in my book. > For example, for n=2, I want the function to look something like: > > def foo(2) > generate 2 sets of elements A, B > # mix elements by: > for a_elt in A > for b_elt in B > form all combinations of them > > If n=3, I want to have 3 sets of elements and mix them up using 3 for > loops. You might be ineterested in this thread: http://mail.python.org/pipermail/python-list/2008-January/473650.html where various solutions were proposed and their various merits evaluated. -tkc From grante at visi.com Tue Apr 1 14:25:11 2008 From: grante at visi.com (Grant Edwards) Date: Tue, 01 Apr 2008 13:25:11 -0500 Subject: manipulating hex values References: Message-ID: On 2008-04-01, Stephen Cattaneo wrote: > I am relatively new to socket programming. I am attempting to > use raw sockets to spoof my IP address. From what I can tell > I will have to build from the Ethernet layer on up. This is > fine, but I am having some trouble with manipulating my hex > values. > > Seems to me that there are two ways to store hex values: > 1. as literal hex - 0x55aa That's a hex represenation of a literal integer object. The object itself isn't either decimal or hex. It's and integer object. [It's _probably_ stored in binary, but that's beside the point.] > 2. as a string - "\x55aa" That is the string "Uaa". Perhaps you meant "\x55\xaa"? If so, that might or might not have the same bit-pattern as 0x55aa depending on what CPU you're using. > If I want to convert hex to decimal I can use: int("\x55aa", 16) No you can't' 1) That call doesn't convert hex to decimal. It converts to an integer object (which almost certainly is stored in 2's compliment binary). There is nothing in decimal in the example. 2) "\x55aa" doesn't mean what you think it does. "\x55aa" is a three byte string consisting of a byte with the value 0x55 and then two ascii 'a' bytes. 0x55 is an ascii 'U'. I think you meant "0x55aa". That's completely different from either "\x55aa" or "\x55\xaa". > # note that plain 0x55aa, instead of "\x55aa", will > raise an exception That's because the above function call requires a string. 0x55aa isn't a string. It's an integer literal. "\x55aa" is a three byte string that's equal to "Uaa", and it can't be converted to an integer. > The Question: > If I want to do any kind of calculation I have found its best to just > convert my values to decimal, do the math, then convert back to hex. First: stop talking (and thinking) about "decimal" stuff. You're not really doing anything in decimal in any of the code you've posted so far. > In my bellow code I get > """byteList.append(int(value,16)) > ValueError: invalid literal for int()""" > when attempting to run. No you don't. You get this: Traceback (most recent call last): File "foo.py", line 20, in ? checksum = calcIPChecksum(["\x45" + "\x00", "\x01\x4a", "\x00\x00", "\x40"+"\x00", "\x20"+"\x11"]) NameError: name 'calcIPChecksum' is not defined Don't re-type examples in postings. Paste in the actual code that you're using. That way we don't have to try to guess about the differences between the real code and what's in the posting. > I do not understand why this exception is being raised? If you want to understand why you're getting that exception, add the line "print value" immediately prior to the int(value,16) line. > It is a for loop iterating over a list of hex strings. Sorry > for the long-ish question. Any help or comments would be > appreciated. > > > ----my checksum--- > def calcIPCheckSum(ipHeaders): > byteList = [] > # convert groups from hex to dec > for value in ipHeaders: > byteList.append(int(value,16)) # Exception raised here! > > # 1's compliment > for index in range(len(byteList)): > byteList[index] = abs(byteList[index] - 65535) > > # add bytes together shifting the extra byte > total = 0 > for value in byteList: > total = total + value > if total > 65535: > total = total - 65535 > > return hex(total) > > checksum = calcIPChecksum(["\x45" + "\x00", "\x01\x4a", "\x00\x00", > "\x40"+"\x00", "\x20"+"\x11"]) You pretty much lost me on the above algorithm (hex/decimal/string/integer mixups aside). FWIW, here's an IP checksum routine: def calcIPCheckSum(ipHeaders): total = 0 for w in ipHeaders: total += w carries = total >> 16 sum = (total + carries) & 0xffff return sum ^ 0xffff print hex(calcIPCheckSum([0x0100,0xf203,0xf4f5,0xf6f7])) A slightly more terse version: import operator def calcIPCheckSum(ipHeaders): total = reduce(operator.add,ipHeaders) carries = total >> 16 return ((total + carries) ^ 0xffff) & 0xffff -- Grant Edwards grante Yow! ... he dominates the at DECADENT SUBWAY SCENE. visi.com From gagsl-py2 at yahoo.com.ar Sun Apr 20 04:12:36 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 05:12:36 -0300 Subject: random.random(), random not defined!? References: <2a3931f5-481d-4831-baad-fcc9f0c0c129@m73g2000hsh.googlegroups.com> Message-ID: En Sat, 19 Apr 2008 16:28:37 -0300, globalrev escribi?: > do i need to import something to use random? Let me guess: you have a script named random.py? Perhaps the same one you're executing? In that case when you write "import random", you're importing *your* script instead of the standard one. -- Gabriel Genellina From sturlamolden at yahoo.no Mon Apr 21 20:09:57 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Mon, 21 Apr 2008 17:09:57 -0700 (PDT) Subject: Segfault accessing dictionary in C Python module References: Message-ID: <365f11e2-6e3e-4e9c-bfda-7c4168a39769@u69g2000hse.googlegroups.com> On Apr 22, 2:00 am, Mitko Haralanov wrote: > As far as I know, I have done everything by the book yet I can't seem > to figure out where the problem is. Any help would be great? Albeit not having looked at your code in detail, I'm wiling to bet you have one of the refcounts wrong. Have you considered using Cython? From lists at cheimes.de Wed Apr 9 12:10:38 2008 From: lists at cheimes.de (Christian Heimes) Date: Wed, 09 Apr 2008 18:10:38 +0200 Subject: I am worried about Python 3 In-Reply-To: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> Message-ID: <47FCEA7E.5060908@cheimes.de> jmDesktop schrieb: > If I continue in Python 2.5.x, am I making a mistake? Is it really > that different? I'm speaking as a long time Python user and Python core developer here. You are safe to ignore Python 3.0 for now. :] You can start worrying about the 3.x series in 2010 when Python 3.1 is out and most libraries are ported to 3.x. Christian From aaron.watters at gmail.com Fri Apr 18 14:07:12 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Fri, 18 Apr 2008 11:07:12 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: <14107338-3bf1-45cb-983a-687f46f19503@d45g2000hsc.googlegroups.com> > Try coming up with a real standard for evaluation. > How much of a performance hit will actually cause you trouble? 1% extra > on string interpolation? 10%? 50%? 200%? You misread my comment. I don't want function calls to support dictionary emulation if there is a speed penalty because this is such a special case and function calls are so important. I don't really know, but I think "fixing" the above issue for string.format(...) might involve changing the representation of every python stack frame... not worth it in this case if there is any penalty (afaik there isn't). An alternative is to provide an alternate interface to string.format so that you could pass in an object which might emulate a dictionary, like string.formatDict(D) -- or you could even adopt a shortcut notation like string % D -- hey there's an idea! -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=ignore+warnings From aaron.watters at gmail.com Wed Apr 2 09:36:26 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 2 Apr 2008 06:36:26 -0700 (PDT) Subject: april fools email backfires Message-ID: Grapevine says that an architect/bigot at a java/spring shop sent out an April Fools email saying they had decided to port everything to Django ASAP. Of course the email was taken seriously and he got a lot of positive feedback from line developers and savvy users/managers that they thought it would be a great idea; it's about time; gotta do something about this mess... -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=other+surprises From Lie.1296 at gmail.com Wed Apr 23 12:48:54 2008 From: Lie.1296 at gmail.com (Lie) Date: Wed, 23 Apr 2008 09:48:54 -0700 (PDT) Subject: Explicit variable declaration References: <1506f165-7f86-4dc7-aa29-6488eda9ae7f@l64g2000hse.googlegroups.com> Message-ID: <5e59998b-d2e7-48cb-824b-84620f95c9bc@w5g2000prd.googlegroups.com> On Apr 23, 4:52 pm, "Filip Gruszczy?ski" wrote: > > You mean the type? Not in 2.x, but in 3.x, there are function > > annotations: > > > def a_function(arg1: int, arg2: str) -> None: pass > > Nope, I don't like types ;-) 3.x seems pretty revolutionary, and this > typing can be appreciated by some people. > > > Declaring what about them? If you mean declaring the type, remember > > that Python deliberately allows any name to be bound to any object; > > type declarations can't be enforced without losing a lot of the power > > of Python. > > Just declaring, that they exist. Saying, that in certain function > there would appear only specified variables. Like in smalltalk, if I > remember correctly. If you want to just declare that name exist, but doesn't want to declare the type, why don't you just do this: def somefunc(): nonlocal = nonlocal local = 0 # or None or [] or an initial value # return nonlocal * local From george.sakkis at gmail.com Wed Apr 2 13:36:13 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 2 Apr 2008 10:36:13 -0700 (PDT) Subject: april fools email backfires References: <7xbq4sf9wv.fsf@ruckus.brouhaha.com> Message-ID: <51f66f4e-08c4-4a67-bcd7-f3c9e556d198@m73g2000hsh.googlegroups.com> On Apr 2, 1:29?pm, Grant Edwards wrote: > On 2008-04-02, Paul Rubin wrote: > > > Django, pah. ?They should switch to something REALLY advanced: > > >http://www.coboloncogs.org/INDEX.HTM > > ROTFLMAO! > > That's absolutely brilliant! ?I particularly like the flashing > effect that simulates an old screen-at-time mode terminal (or > maybe a storage-scope terminal?), and the faint "burn-in" text > in the background. And the "(c) " at the bottom left.. priceless! From kay.schluehr at gmx.net Fri Apr 25 12:05:20 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Fri, 25 Apr 2008 09:05:20 -0700 (PDT) Subject: Fun with relative imports and py3k Message-ID: Since their introduction in Python 2.5 I only reviewed the new "relative import" notation briefly by reading the "What's new in Python 2.5" article. Now I wanted checkout if I get comfortable with them. Opening the tutorial I found following notice ( 6.4.2 ): "Note that both explicit and implicit relative imports are based on the name of the current module. Since the name of the main module is always "__main__", modules intended for use as the main module of a Python application should always use absolute imports." The distinction between modules and scripts was new to me. One of the primary features I always appreciated in Python was that modules had a dual purpose: they were components and they were programs. One could use them in isolation or as a part of a package something I always missed when I programmed in languages with the tyranny of a single main. However 'implicit relative imports' work as usual and Py3K just changes the priority of search - one might simply ignore the 'explicit' variant and care for unambiguous names. Now things are not so easy in life and when you are confronted with other peoples software you have to know at least the rules of the game. Digging a little deeper I found the following section in "What's new in Python 2.6" 'Python?s -m switch allows running a module as a script. When you ran a module that was located inside a package, relative imports didn?t work correctly.' Hmm... they worked as specified or at least as documented. I admit I'm confused but I suspect I'm not the only one. Now everything is fine. You just run each and every module with the -m option "as a script" because there is a chance that somewhere is a relative import ( e.g. local to a function ) and suddenly the module fails to import stuff due to a modality in the import behavior. Let's see how it works in practice. This here my very first attempt to start Pythons 2to3 refactoring tool written by the master himself. I looked at it and he used relative imports. C:\Python30\Lib\lib2to3>C:\Python30\python -m refactor.py Traceback (most recent call last): File "C:\Python30\lib\runpy.py", line 103, in _run_module_as_main loader, code, fname = _get_module_details(mod_name) File "C:\Python30\lib\runpy.py", line 78, in _get_module_details loader = get_loader(mod_name) File "C:\Python30\lib\pkgutil.py", line 456, in get_loader return find_loader(fullname) File "C:\Python30\lib\pkgutil.py", line 466, in find_loader for importer in iter_importers(fullname): File "C:\Python30\lib\pkgutil.py", line 422, in iter_importers __import__(pkg) File "C:\Python30\lib\lib2to3\refactor.py", line 23, in from .pgen2 import driver ValueError: Attempted relative import in non-package Not working. I'm perfectly sure I don't understand the error message but what's worse is that runpy.py fails which was just created ( in Python 2.6 ) to fix the issue with the apparently broken relative imports that is o.k. according to the introductory material that is dedicated to newbies. I'm trying to fix this naively by turning the explicit into implicit relative (or absolute?) imports and see what happens. refactor.py ------------------------ ... # Local imports from pgen2 import driver from pgen2 import tokenize import pytree import patcomp import fixes import pygram .... C:\Python30\Lib\lib2to3>C:\Python30\python -m refactor.py Traceback (most recent call last): File "C:\Python30\lib\runpy.py", line 103, in _run_module_as_main loader, code, fname = _get_module_details(mod_name) File "C:\Python30\lib\runpy.py", line 78, in _get_module_details loader = get_loader(mod_name) File "C:\Python30\lib\pkgutil.py", line 456, in get_loader return find_loader(fullname) File "C:\Python30\lib\pkgutil.py", line 466, in find_loader for importer in iter_importers(fullname): File "C:\Python30\lib\pkgutil.py", line 422, in iter_importers __import__(pkg) File "refactor.py", line 27, in import patcomp File "C:\Python30\lib\lib2to3\patcomp.py", line 17, in from .pgen2 import driver ValueError: Attempted relative import in non-package This time patcomp fails with its relative imports despite the fact that it is not imported as a "script" but as a module inside the lib2to3 package and it is not __main__ but refactor.py is. I give up. I always thought migration from Python 2.X to Python 3.0 was an issue not the conversion tool ;) From linhanzu at gmail.com Thu Apr 10 22:21:51 2008 From: linhanzu at gmail.com (=?GB2312?B?ufnTwr78?=) Date: Fri, 11 Apr 2008 10:21:51 +0800 Subject: How to use my dynamic link libraries in python?? Message-ID: Hello: My OS is Linux, I compile my dynamic link libraries , and want to call the function of my dynamic library through python! How can I realize the function? Please give me some advices! Thanks From steve at holdenweb.com Sat Apr 5 11:05:12 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 11:05:12 -0400 Subject: ANN: pry unit testing framework In-Reply-To: <20080405141329.GD15684@nullcube.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com> <20080405141329.GD15684@nullcube.com> Message-ID: Aldo Cortesi wrote: > Thus spake Kay Schluehr (kay.schluehr at gmx.net): > >> Aldo, when you confuse inheritance ( using an OO framework properly ) >> with monkey patching no one can draw much different conclusions than I >> did. > > I guess you do always run the risk of being pelted with something from > the peanut gallery when you release something in public - maybe I'll > think twice about doing so next time. > > The only "confused" person here is you - I still say that it is NOT > possible to provide the functionality Pry does by extending unittest in > any sane way. Now, if you don't agree with this, please prove me wrong > through reasoned argument or shut up. Do NOT, however, accuse me of not > knowing what inheritance or monkeypatching is unless you want to look > stupid and make my killfile. > >> But raving against unittest.py and anti-hyping it for mostly trivial >> reasons and with shallow reasoning has become a fashion. Now we see >> alternatives that do little more than what can be achieved by adding >> two abstract methods to the TestSuite base class and overwrite a few >> methods of the TestLoader base class ( maybe I'm wrong about it but I >> guess the discussion has become too heated to clarify this point using >> technical arguments ). >> >> I just felt it was a good opportunity to debunk this unittest.py anti- >> hype. I'm sorry it has gone too personal. > > You can choose to use Pry or not, as you please. I would, however, ask > that you stop whining incessantly about how it's not compatible with > YOUR favourite framework, despite the fact that compatibility would > gain YOU very little and ME nothing at all. As I said in my response to > Michele, you lose the benefits of compatibility as soon as your tests > use any of the features an extension might add. To me, this means the > burden is not worth it. Since I designed and wrote Pry, I get to make > that choice, not you, and the type of feeble, offensive "argument" > you've provided is unlikely to change my mind. > Unpleasantly personal replies of this type are unwelcome here. Please restrict your arguments to technical ones or refrain from posting. Kay at least has a long history as a contributor in this group, so people know how to interpret her remarks and know that her contributions are made on the basis of a deep understanding of Python. She is far from belonging to the "peanut gallery", and to suggest otherwise betrays either ignorance, arrogance, or both. As a newcomer, however, your responses make you seem to be complaining that the world isn't grateful for your contributions, yet you don't seem to even consider the possibility that might be happening because you aren't explaining them well enough. To truculently suggest that reasoned responses make you less likely to contribute to open source in future suggests that you weren't ready to start in the first place. This group is a "broad church" that respects opinions of all kinds, and you will find that you are just as welcome as everyone else if you can confirm to accepted standard of behavior. Don't take things too personally (even when someone accuses you of "raving" - nobody said you are a bad person). regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From Dodin.Roman at gmail.com Fri Apr 25 04:44:03 2008 From: Dodin.Roman at gmail.com (hellt) Date: Fri, 25 Apr 2008 01:44:03 -0700 (PDT) Subject: Little novice program written in Python References: <0cecfed4-17e7-4e4d-9dbe-3f0ac8316c1f@y21g2000hsf.googlegroups.com> Message-ID: also, i would recommend you to visit projecteuler.net you can solve math tasks and then see how others have done the same. you can fetch very good and pythonic solution there. From maxm at mxm.dk Fri Apr 25 08:44:29 2008 From: maxm at mxm.dk (Max M) Date: Fri, 25 Apr 2008 14:44:29 +0200 Subject: Little novice program written in Python In-Reply-To: <2caefd7f-dd6b-40a0-877f-3f7df0e70138@8g2000hse.googlegroups.com> References: <2caefd7f-dd6b-40a0-877f-3f7df0e70138@8g2000hse.googlegroups.com> Message-ID: <4811D22D.30409@mxm.dk> hellt skrev: >> Most code is not like that so perhaps you should try something more >> "usual" like sending email, fetching webpages etc. to get a feel for the >> language. >> > em, i would say, that python (esp. with NumPy+Psyco) is very popular > in numerical processing also. I know, and I might be way of, but I would believe that even that would be more like stringing ready built modules together, calling methods etc. I have written far denser code that the above example in Python regularly. But It is like 1%-5% of my code I believe. Unlike the c family of languages where there is a lot more algorithms due to the low level coding. Memory handling, list, dicts etc. qickly becomes more like math algorithms than in Python. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science From jkugler at bigfoot.com Wed Apr 9 14:53:01 2008 From: jkugler at bigfoot.com (Joshua Kugler) Date: Wed, 09 Apr 2008 10:53:01 -0800 Subject: Can C.L.P.handle the load? References: <3b6737c8-9d42-4218-ac60-01df2f578746@p39g2000prm.googlegroups.com> <9bd25fd3-5133-4165-9784-fbbc21145810@24g2000hsh.googlegroups.com> Message-ID: Paddy wrote: > I'm waiting for the rush of new users to c.l.p :-) > If it comes, then aren't regularly posted FAQ's newbie friendly? No, it just means they didn't take the time to read the docs and the FAQ for themselves. :) > Is their a good FAQ already around that we can regularly point newbies > to? You mean this one: http://www.python.org/doc/faq/ j From rasmussen.bryan at gmail.com Thu Apr 24 14:08:50 2008 From: rasmussen.bryan at gmail.com (bryan rasmussen) Date: Thu, 24 Apr 2008 20:08:50 +0200 Subject: convert xhtml back to html In-Reply-To: References: Message-ID: <3bb44c6e0804241108g215ec5a4hb2d0f767fa215ac@mail.gmail.com> I'll second the recommendation to use xsl-t, set the output to html. The code for an XSL-T to do it would be basically: you would probably want to do other stuff than just copy it out but that's another case. Also, from my recollection the solution in CHM to make XHTML br elements behave correctly was
as opposed to
, at any rate I've done projects generating CHM and my output markup was well formed XML at all occasions. Cheers, Bryan Rasmussen On Thu, Apr 24, 2008 at 5:34 PM, Tim Arnold wrote: > hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop to > create CHM files. That application really hates xhtml, so I need to convert > self-ending tags (e.g.
) to plain html (e.g.
). > > Seems simple enough, but I'm having some trouble with it. regexps trip up > because I also have to take into account 'img', 'meta', 'link' tags, not > just the simple 'br' and 'hr' tags. Well, maybe there's a simple way to do > that with regexps, but my simpleminded )]+/> doesn't work. I'm not > enough of a regexp pro to figure out that lookahead stuff. > > I'm not sure where to start now; I looked at BeautifulSoup and > BeautifulStoneSoup, but I can't see how to modify the actual tag. > > thanks, > --Tim Arnold > > > -- > http://mail.python.org/mailman/listinfo/python-list > From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 24 07:46:51 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 24 Apr 2008 13:46:51 +0200 Subject: Python development tools In-Reply-To: <873apbqypn.fsf@physik.rwth-aachen.de> References: <09992de9-39fa-4ee6-8009-35732f3433fb@y21g2000hsf.googlegroups.com> <87fxtcnvj7.fsf@physik.rwth-aachen.de> <48106ba0$0$11087$426a34cc@news.free.fr> <873apbqypn.fsf@physik.rwth-aachen.de> Message-ID: <48107317$0$23390$426a74cc@news.free.fr> Torsten Bronger a ?crit : > Hall?chen! > > Bruno Desthuilliers writes: > >> [...] >> >>> and it ends multi-line strings at single quotes. >> it chokes on unbalanced single quotes in triple-single-quoted >> strings, and on unbalanced double-quotes in triple-double-quoted >> strings, yes. Given that I never use triple-single-quoted strings >> (and don't remember having seen such a thing in the thousands of >> third-part .py files I've read so far), I'd qualify this as at >> most a very minor annoyance. Not having proper python-shell and >> pdb integration is wwwwaaaayyyy more annoying IMHO. > > My formulation was unfortunate. What doesn't work (at least for me) > is something like > > """This is a docstring in which some "variables" are quoted.""" > > Here, "variables" doesn't seem to belong to the docstring for > python-mode. Nope, but it doesn't break anything neither. At this stage, this is a less than minor annoyance to me. From george.sakkis at gmail.com Tue Apr 29 00:29:40 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Mon, 28 Apr 2008 21:29:40 -0700 (PDT) Subject: descriptor & docstring References: Message-ID: On Apr 28, 10:59?pm, "Gabriel Genellina" > def property_default(prop_name, default_value=None, doc=None): > > ? ? ?attr_name = '_'+prop_name > > ? ? ?def fget(self, attr_name=attr_name, > ? ? ? ? ? ? ? ? ? ? default_value=default_value): > ? ? ? ? ?return getattr(self, attr_name, default_value) > > ? ? ?def fset(self, value, > ? ? ? ? ? ? ? ? ? ? attr_name=attr_name, > ? ? ? ? ? ? ? ? ? ? default_value=default_value): > ? ? ? ? ?if value == default_value: > ? ? ? ? ? ? ?delattr(self, attr_name) > ? ? ? ? ?else: > ? ? ? ? ? ? ?setattr(self, attr_name, value) > > ? ? ?return property(fget=fget, fset=fset, doc=doc) > > When setting the same value as the default, the instance attribute is ? > removed (so the default will be used when retrieving the value later). I ? > think this is what you intended to do. Note that this will fail if the value is already equal to the default and you try to reset it to the default, so it needs an extra hasattr(self, attr_name) before the delattr. Regardless, I would be surprised with the following behaviour: >>> r = Rectangle() >>> r.length = 4 >>> type(r.length) >>> r.length = 12 >>> type(r.length) Another simpler alternative would be to (ab)use a decorator: def defaultproperty(func): attr = '_' + func.__name__ default = func.func_defaults[0] return property( fget = lambda self: getattr(self, attr, default), fset = lambda self,value: setattr(self, attr, value), doc = func.__doc__) class Rectangle(object): '''A beautiful Rectangle''' @defaultproperty def length(default=12.0): '''This is the length property''' George From rschroev_nospam_ml at fastmail.fm Tue Apr 29 12:15:33 2008 From: rschroev_nospam_ml at fastmail.fm (Roel Schroeven) Date: Tue, 29 Apr 2008 18:15:33 +0200 Subject: Who makes up these rules, anyway? In-Reply-To: References: Message-ID: Cameron Laird schreef: > In article , > Gabriel Genellina wrote: > . > . > . >> Explicit variable declaration for functions: >> >> http://groups.google.com/group/comp.lang.python/browse_thread/thread/6c4a508edd2fbe04/ > . > . > . > A reader notes that this thread actually lived during 2004 (!) > (entirely during January 2004, in fact), and mildly questions > its pertinence to what bills itself as "weekly Python news ..." > > Well might the reader wonder. "Python-URL!" has long chosen > to err on the side of INclusiveness in its categorizations, > even to the occasional point of apparent frivolity. As Harlan > Ellison used to advise his readers, think of it as a bonus, > rather than a mistake. It's our tradition, too. I assumed it was a mix-up with the recent thread with the same name: http://groups.google.com/group/comp.lang.python/browse_thread/thread/f3832259c6da530 -- The saddest aspect of life right now is that science gathers knowledge faster than society gathers wisdom. -- Isaac Asimov Roel Schroeven From ankitks.mital at gmail.com Fri Apr 4 02:06:37 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Thu, 3 Apr 2008 23:06:37 -0700 (PDT) Subject: python bisect questions References: <6bb6927b-f553-40db-a142-2ce86b9e819f@q27g2000prf.googlegroups.com> Message-ID: <6280b454-2f0f-446d-b980-ff4fa6643799@b64g2000hsa.googlegroups.com> Thanks Gabriel From bronger at physik.rwth-aachen.de Tue Apr 8 02:03:13 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Tue, 08 Apr 2008 08:03:13 +0200 Subject: Translating keywords References: Message-ID: <873apwubmm.fsf@physik.rwth-aachen.de> Hall?chen! Gabriel Genellina writes: > [...] > > Python 3 allows for unicode identifiers, but I don'k know any > plans for using unicode keywords too. Looks funny: > > ? x ? values: > if x ? forbidden ? x ? y: > print(x, ?(x), ?(x)) > print(?(values)) > near = ? a,b,?=0.01: a-? ? b ? a+? As far as I've understood it, only letters are allowed in identifiers rather than arbitrary Unicode code points. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From uniontelecardsindia at gmail.com Tue Apr 22 17:14:10 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:14:10 -0700 (PDT) Subject: Lucky gay sucking cock while butt fucked deep Message-ID: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From n00m at narod.ru Sat Apr 26 16:54:29 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 13:54:29 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> Message-ID: hdante: I run your code quite a few times. Its time = 0.734s. Of mine = 0.703-0.718s. PS All I have is an ancient Mingw compiler (~1.9.5v) in Dev-C++. From s0suk3 at gmail.com Thu Apr 17 03:30:04 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 00:30:04 -0700 (PDT) Subject: regular expressions an text string References: <359c5f43-9520-4f33-b49e-45b5256f7169@a22g2000hsc.googlegroups.com> Message-ID: <96774d85-2a76-461b-89c6-f12a68908825@m36g2000hse.googlegroups.com> On Apr 17, 2:09 am, ragia wrote: > hi > i have to match text string char by char to a regular expressions tht > just allow digits 0-9 if other thing a ppear it shall be replaced with > space.how can i do that any help? > so far i have the string and can read it using a for loop...but how to > match each char with the regular expressions and save the result into > other string or replace it with space in that other string to have new > one.. > I a new in python ,thatnks in advance >>> import re # Python's library supporting regexps >>> >>> string = "abc123def456" >>> re.sub("\D", " ", string) ' 123 456' ~~Sosuke~~ From mrmakent at cox.net Wed Apr 16 11:14:24 2008 From: mrmakent at cox.net (Mike Kent) Date: Wed, 16 Apr 2008 08:14:24 -0700 (PDT) Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> Message-ID: <66efcc2e-d806-4cb1-966c-178b41b183ba@d1g2000hsg.googlegroups.com> On Apr 16, 10:26 am, Mike Driscoll wrote: > Yeah, I noticed that Google Groups has really sucked this week. I'm > using the Google Groups Killfile for Greasemonkey now and it helps a > lot. I like Google, but my loyalty only goes to far. This is a > complete lack of customer service. > > Mike Bless you. I just installed Greasemonkey and the Google Groups Killfile. Works like a charm. From paddy3118 at googlemail.com Wed Apr 9 01:44:10 2008 From: paddy3118 at googlemail.com (Paddy) Date: Tue, 8 Apr 2008 22:44:10 -0700 (PDT) Subject: pprint module and newer standard types Message-ID: Hi, When I try and use pprint on standard types I get varying 'quality of output'. Lists will wrap nicely to multiple lines as will dicts, but sets and defaultdicts give one long unreadable line. Is their a chance to get this changed so that more built-in types look pretty when printed with pprint? I just did a small trial on an early version of Python 3 and sets don't seem to obey pprint.pprints width argument, the same way that lists do: Python 3.0a1 (py3k:57844, Aug 31 2007, 16:54:27) [MSC v.1310 32 bit (Intel)] on win32 >>> from pprint import pprint as pp >>> pp(list(range(3)), width=4) [0, 1, 2] >>> pp(set(range(3)), width=4) {0, 1, 2} >>> - Paddy. From andre.roberge at gmail.com Thu Apr 17 18:53:36 2008 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Thu, 17 Apr 2008 15:53:36 -0700 (PDT) Subject: Request a short code review References: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> Message-ID: <4e632ff9-2ce9-4b2d-9f93-cfdab2452841@k37g2000hsf.googlegroups.com> On Apr 17, 7:11 pm, ja... at reggieband.com wrote: > > I am not necessarily looking to make the code shorter or more > > functional or anything in particular. However if you spot something > > to improve then I am happy to learn. > > To give an example of what I mean I have already altered the code: > > def output_random_lesson_of_type(self, type=None): > """Output a lesson of a specific type. > If no type is passed in then output any type.""" > output_lessons = self.lesson_data["lessons"] > if type: > filtered_lessons = filter(lambda x: x["type"] == type, > self.lesson_data["lessons"]) > if filtered_lessons: > output_lessons = filtered_lessons > else: > print "Unable to find lessons of type %s." % type > return self.output_random(output_lessons) > > Changes: > - Respected a column width of 80 > - Created the output_lessons variable, assigned it to a default. > This remove an else statement and reduced the call to > self.output_random to a single instance in the return statement > > Cheers, > James I prefer, especially for longer methods, to return as soon as possible (thereby indicating that the code below is irrelevant to a particular condition). Thus, I would replace output_lessons = filtered lessons by return self.output_random(filtered_lessons) Andr? From ridenour4159 at gmail.com Thu Apr 24 06:17:34 2008 From: ridenour4159 at gmail.com (ridenour4159 at gmail.com) Date: Thu, 24 Apr 2008 03:17:34 -0700 (PDT) Subject: orbital trader crack Message-ID: orbital trader crack http://cracks.12w.net F R E E C R A C K S From jr9445 at ATT.COM Wed Apr 23 09:50:00 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Wed, 23 Apr 2008 08:50:00 -0500 Subject: Python Success stories In-Reply-To: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: > -----Original Message----- > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > list-bounces+jr9445=att.com at python.org] On Behalf Of azrael > Sent: Tuesday, April 22, 2008 6:26 AM > To: python-list at python.org > Subject: Python Success stories > > Hy guys, > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. > > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" > > This hurts. Please give me informations about realy famous > aplications. IIRC, Python is used in games like Eve Online (SciFi MMO) and Vampire: Bloodlines (RPG.) Years later, a dedicated fan is still fixing/updating the Bloodlines python scripts that control the dialogue and scripted events. OTOH, I use Perl over Python when it comes to Windows COM scripts due to finding a typelib that Python just refused to load. *shrug* Perl, Python, and your friend are tools. Use them appropriately for the given situation. From http Mon Apr 7 14:33:34 2008 From: http (Paul Rubin) Date: 07 Apr 2008 11:33:34 -0700 Subject: Tips for load balancing multiple Python apps on dual/quad core processors? References: Message-ID: <7x63utfrb5.fsf@ruckus.brouhaha.com> "Malcolm Greene" writes: > Is there a cross-platform way to monitor CPU load? Cross-platform: not that I know of. Linux: /proc/loadav (load average), /proc/cpuinfo (to figure out number of cpu's). You want the load average and # of cpu's to be about equal, i.e. all cpu's should be kept busy but not overloaded. From primoz.skale.lists at gmail.com Thu Apr 3 16:31:55 2008 From: primoz.skale.lists at gmail.com (Primoz Skale) Date: Thu, 3 Apr 2008 22:31:55 +0200 Subject: function call - default value & collecting arguments References: <_LQIj.9776$HS3.482805@news.siol.net> Message-ID: "OKB (not okblacke)" wrote in message news:Xns9A74ACF8732AEOKB at 199.45.49.11... > Primoz Skale wrote: > >> OK, everything allright till so fair. But! :) Now define third >> function as: >> >> def f(*a): >> print a[0] >> >> In this case, function only prints first argument in the tuple: >> >>>>f(1,2,3) >> 1 >>>>f(3) >> 3 >>>>f() #no arguments passed >> Traceback (most recent call last): >> File "", line 1, in >> f() #no arguments passed >> File "", line 2, in f >> print a[0] >> IndexError: tuple index out of range >> >> Then I tried to define the function as: >> >> def f(*a=(0,)): >> print a[0] #this should come next, but we get error msg instead, >> saying >> >> SyntaxError: invalid syntax >> >> but it does not work this way. Now my 'newbie' question: Why not? >> :) I wanted to write function in this way, because then we can call >> function without any arguments, and it would still print 0 (in this >> case). >> >> What I wanted was something like this: >> >> def f(*a=(0,)): >> print a[0] >> >>>>f(1,2) >> 1 >>>>f() #no args passed 0 > > When you use the *a syntax, you're saying that you want a to > contain a tuple of all the arguments. When you try *a=(0,), you seem to > be saying that you want a to hold all the arguments, or, if there are > none, you want to pretend that it was called with one argument, namely > 0. > > Well, if you want to ensure that there is at least one argument, > and print that first one, and make it zero if it's not supplied, why are > you using the *a syntax? You're clearly treating that first argument > distinctly, since you want to apply a default value to it but not to any > others. Just do this: > > def f(a, *b): > print a Thanks! I never thought of that.... :) P. > > -- > --OKB (not okblacke) > Brendan Barnwell > "Do not follow where the path may lead. Go, instead, where there is > no path, and leave a trail." > --author unknown From stanc at al.com.au Tue Apr 29 03:48:01 2008 From: stanc at al.com.au (Astan Chee) Date: Tue, 29 Apr 2008 17:48:01 +1000 Subject: simple chemistry in python Message-ID: <4816D2B1.2010404@al.com.au> Hi, Im looking for a python module to do simple chemistry things. Things like, finding the name of elements given the atomic number (and vice versa); what state the given matter is in depending on certain parameters; maybe even color of certain elements or even calculating the result of combining certain elements. I was looking for something simple, but everything I see seems to be a full blown chemistry set. I know I can probably spend a day doing this one element at a time, but I was wondering if there is already something like this done in a small scale? Thanks for any information Astan -- "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." Animal Logic http://www.animallogic.com Please think of the environment before printing this email. This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. From steve at holdenweb.com Sun Apr 20 10:13:46 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 20 Apr 2008 10:13:46 -0400 Subject: Any reliable obfurscator for Python 2.5 In-Reply-To: <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> Message-ID: Banibrata Dutta wrote: > > > On 4/20/08, *Gabriel Genellina* > wrote: > > En Sun, 20 Apr 2008 01:55:51 -0300, Banibrata Dutta > > escribi?: > > > Wanted to check if there is any known, reliable, FOSS/Libre -- > Obfurscator > > for Python 2.5 code. > > Why do you want to do that in the first place? > > > I need to do to retain the confidentiality for certain core components, > which are not supposed to be open. While I do have the option of > implementing them in C/C++, I'm trying to see if I can avoid that for 2 > reasons -- > 1. Its a fairly large and complex set of components, and doing it in > C/C++ 'might' take significantly longer. > 2. I'd try to avoid having mix of languages if possible. It makes the > developement easier to maintain/manage over a period of time. > > There is very few you can do to obfuscate Python code. You can't > rename classes nor methods nor global variables nor argument names > due to the dynamic nature of Python. All you can safely do is to > remove comments and join simple statements using ; > > > I do not understand the nuances of dynamic languages completely, so this > might be a foolish assumption, but if i make a complete, self-contained > Python application (collection of modules), then just before shipping a > production copy, why can't I replace 'all' symbols i.e. classes, > methods, variables etc ? Esply if I'm compiling the source ? > > If you remove docstrings, some things may break. Even renaming local > variables isn't safe in all cases. > > > Hmmm... but I'm aware of atleast 2 Obfuscators one commercial and one > FOSS, that seem to exist for Python. The commercial one is what I might > try if I don't find anything FOSS. The FOSS one seems to be a dead > project. If they are (or have been) there, I guess obfuscation is a > doable thing, no ? > The Python world isn't particularly paranoid about obfuscation. It's quite easy to publish compiled code only (.pyc and/or .pyo files), and that offers enough protection for most. The sad fact is that there seems to be an almost direct inverse correlation between the worth of the code and the authors' desire to protect it from piracy. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From eddieatter at gmail.com Tue Apr 15 19:37:40 2008 From: eddieatter at gmail.com (agent E 10) Date: Tue, 15 Apr 2008 16:37:40 -0700 (PDT) Subject: Brand New! References: <7f1828bf-ebe7-4111-bc59-70d125facb0a@d26g2000prg.googlegroups.com> Message-ID: On Apr 14, 8:37?pm, Benjamin wrote: > On Apr 14, 9:00 pm, agent E 10 wrote:> ? ?Hi, I'm brand new to programming. Have any suggestions? I'm young. > > Was it a good idea to start with python? I was planning on creating a > > very simple program that asked yes/no questions for a school project. > > IMHO, Python is an excellent language to start with. Have you read the > tutorial?http://docs.python.org/tut/tut.html > > > > > -Thanks!- Hide quoted text - > > - Show quoted text - No, I haven't. I have been reading off of this site http://www.freenetpages.co.uk/hp/alan.gauld/ is this a good site to learn off of? About how long will it take me to learn the basics of the language? -Thanks 4 all ur help! Agent E 10 From sturlamolden at yahoo.no Sat Apr 12 13:05:19 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sat, 12 Apr 2008 10:05:19 -0700 (PDT) Subject: Multiple independent Python interpreters in a C/C++ program? References: Message-ID: <624b9d79-bc02-4f52-bc97-52019bf916d0@n1g2000prb.googlegroups.com> On Apr 11, 6:24 pm, s... at pobox.com wrote: > Do I wind up with two completely independent interpreters, one per thread? > I'm thinking this doesn't work (there are bits which aren't thread-safe and > are only protected by the GIL), but wanted to double-check to be sure. You can create a new subinterpreter with a call to Py_NewInterpreter. You get a nwe interpreter, but not an independent one. The GIL is a global object for the process. If you have more than one interpreter in the process, they share the same GIL. In tcl, each thread has its own interpreter instance and no GIL is shared. This circumvents most of the problems with a global GIL. In theory, a GIL private to each (sub)interpreter would make Python more scalable. The current GIL behaves like the BKL in earlier Linux kernels. However, some third-party software, notably Apache's mod_python, is claimed to depend on this behaviour. From wizzardx at gmail.com Sun Apr 20 08:11:22 2008 From: wizzardx at gmail.com (David) Date: Sun, 20 Apr 2008 14:11:22 +0200 Subject: Any reliable obfurscator for Python 2.5 In-Reply-To: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> Message-ID: <18c1e6480804200511k202ff618i9941b244d0b77853@mail.gmail.com> On Sun, Apr 20, 2008 at 6:55 AM, Banibrata Dutta wrote: > Hi, > > Wanted to check if there is any known, reliable, FOSS/Libre -- Obfurscator > for Python 2.5 code. > What might work is to put all your code in python modules, generate .pyc, and then only distribute those. But you have to be careful that eg: target python interpreter version is the same that you compiled with and so on. From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Sun Apr 27 17:42:44 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Sun, 27 Apr 2008 23:42:44 +0200 Subject: print some text References: <7ac7b11d-6c9b-477c-8c0d-b038bc760918@c58g2000hsc.googlegroups.com> <1b0b588a-be43-49d6-be0f-231217b074dd@k13g2000hse.googlegroups.com> Message-ID: <67kaakF2nqkb9U2@mid.individual.net> barronmo wrote: > I haven't found a way from within python to print f. I'm sure > there it is something simple but I've been searching for a couple > weeks now with no luck. Tried some searching? http://wiki.wxpython.org/Printing HTH&Regards, Bj?rn -- BOFH excuse #374: It's the InterNIC's fault. From pylists at arcor.de Sun Apr 13 08:05:22 2008 From: pylists at arcor.de (Penny Y.) Date: Sun, 13 Apr 2008 20:05:22 +0800 Subject: =?UTF-8?B?5pyJ5Lit5Zu95Lq65LmOPw==?= In-Reply-To: References: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> Message-ID: <4801F702.5050401@arcor.de> Steve Holden ??: > ????????, ????????? > What do you mean? If I understand you correctly, maybe it should be, ??python??????,??????. Am I right? From bblais at bryant.edu Sun Apr 6 18:20:31 2008 From: bblais at bryant.edu (Brian Blais) Date: Sun, 6 Apr 2008 18:20:31 -0400 Subject: read large zip file Message-ID: Hello, I need to read a series of large zipfiles (which only contain one large text file), and I noticed that the zipfile module: 1) has a read method which isn't an iterator, and returns the entire file selected all at once 2) has no readlines method, and no obvious way to implement one Is there a way to stream an unzip, so it behaves more like a file? thanks, Brian Blais -- Brian Blais bblais at bryant.edu http://web.bryant.edu/~bblais -------------- next part -------------- An HTML attachment was scrubbed... URL: From phil at freehackers.org Tue Apr 1 09:03:13 2008 From: phil at freehackers.org (BlueBird) Date: Tue, 1 Apr 2008 06:03:13 -0700 (PDT) Subject: python scripts to standalone executable References: <34dce829-9eca-4e13-a9c5-eeb9f6b913be@e6g2000prf.googlegroups.com> Message-ID: <8a291754-83c8-4d8e-b3d9-e04b5249b1db@2g2000hsn.googlegroups.com> On Mar 31, 7:24 pm, Amit Gupta wrote: > Hi > > I am looking for a some tool that can convert python scripts to > executable on Linux. > > I found freeeze.py as the only option so far. Couple of queries on > freeze: > > 1. Have anyone used the freeze utility and any experiences to share > from that? > 2. Is there any enterprise-level exe-builder for python on linux > (ActiveState has nothing)? > > Any other related commets are also welcome. > > Thanks > Amit I've run into the same question and decided to keep a web page memo about it: http://www.freehackers.org/Packaging_a_python_program I'll be happy to update it with feedback. Philippe From cokofreedom at gmail.com Tue Apr 8 10:53:13 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Tue, 8 Apr 2008 07:53:13 -0700 (PDT) Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> Message-ID: > > I have a car. I have turned the ignition key but it fails to start. > Please tell me what is wrong with it. > The engine is missing! Am I close? From danb_83 at yahoo.com Mon Apr 21 22:19:42 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Mon, 21 Apr 2008 19:19:42 -0700 (PDT) Subject: Java or C++? References: Message-ID: On Apr 21, 5:26 pm, Jorgen Grahn wrote: > On Mon, 21 Apr 2008 06:14:08 -0700 (PDT), NickC wrote: > > On Apr 15, 1:46 pm, Brian Vanderburg II > > wrote: > >> This will automatically call the constructors of any contained objects > >> to initialize the string. The implicit assignment operator > >> automatically performs the assignment of any contained objects. > >> Destruction is also automatic. When 'p1' goes out of scope, during the > >> destructor the destructor for all contained objects is called. > > > Yeah, C++ does try to be helpful, and all of those automatic copy > > constructor, assignment operator and destructor implementations screw > > up royally when confronted with pointers > > I think that those are newbie problems. The rules for those three > "default implementations" are simple and match what C does for > structs. Use the standard containers, make a habit of forbidding > copying of objects which make no sense copying, and remember the > "explicit" keyword, and you will rarely have problems with this. Yes, but why should you have to remember? Wouldn't it be less error- prone to make objects uncopyable and constructors explicit unless stated otherwise? (Yes, default implementations for structs had to match C, but "class" was a new keyword.) > > Other things like methods (including destructors!) being non-virtual > > by default also make C++ code annoyingly easy to get wrong (without it > > obviously looking wrong). > > The other side of the coin is that you can write tiny classes in C++ > with *no overhead*. If my class Foo can be implemented as an integer, > it doesn't need to be slower or take more space than an integer. It > can have value semantics, live on the stack etc, like an integer. > > I assume Java programmers avoid such types, and I assume it decreases > type safety in their programs. I haven't written in Java since version 1.3, so maybe things have changed. But last time I checked, if you want tiny value-semantics types in Java, you're stuck with the built-in ones. One of my biggest gripes about that language. From steve at holdenweb.com Mon Apr 14 14:08:16 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 14 Apr 2008 14:08:16 -0400 Subject: py2exe, program has stoped working!? In-Reply-To: References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> <232151d6-09ed-4a1e-9922-d66c2bf0d05b@w8g2000prd.googlegroups.com> Message-ID: <48039D90.8040205@holdenweb.com> John Machin wrote: > On Apr 14, 7:24 pm, skanem... at yahoo.se wrote: >>> Is it a console program or a gui program? >> GUI >>> What happens when you run it without py2exe? >> it works perfectly, both from within python and launching from >> "windows" >> >>> Have you searched for "has stopped working" in >> (a) your source code >> yes no such message there> (b) the py2exe source code? >> >> no, will do but doubt thats the problem >> >>> Have you managed to get any py2exe-created program to run properly? >> no > > Well, perhaps you might like to look in the samples directory of the > py2exe distribution and choose a simple example and try that. > > By the way, "popup" is what you get in a web browser. What did this > "popup" look like: a panel from your GUI software? A Windows message > box? Did it have a title across the top? What was the exact text in > the popup/panel/box? Were there any options other than to close the > window? > > Which version of Python? Which Windows, what service pack? What GUI, > what version? Care to divulge the contents of your setup.py? Apart > from your GUI, what 3rd party packages/modules are you importing? FYI "xxx has stopped working" is Vista's "user-friendly" way of reporting what Windows 3 would probably have called a "General Program Fault". It pretty much hides all useful information fro the end-user, perhaps on the grounds that end users wouldn't know what to do with the information it *could* provide anyway. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From john_bailey at rochester.rr.com Mon Apr 14 14:24:45 2008 From: john_bailey at rochester.rr.com (John Bailey) Date: Mon, 14 Apr 2008 14:24:45 -0400 Subject: Game design : Making computer play References: Message-ID: On Mon, 14 Apr 2008 00:13:56 -0700 (PDT), v4vijayakumar wrote: >In computer based, two player, board games, how to make computer play? >Are there any formal ways to _teach_ computer, to choose best possible >move? > >I know this is kind of off-topic here. Please redirect me, if there >are more appropriate newsgroup. > >Many thanks. Sargon: A Computer Chess Program (Paperback) by Dan Spracklen (Author), Kathe Spracklen (Author) Search Amazon with that title. Its available for under $20. The Spracklen's book provides a concrete structure and model for a computer program which attempts to look ahead, evaluating alternative moves. Unlike AI texts which obfuscate through abstraction, theirs is quite clear even if you don't know Z80 assembly language. By reading their book (studying it might be a better phrase) I came to understand the complexity and immensity of the task. Good luck. John From stevegill7 at gmail.com Sat Apr 5 11:50:30 2008 From: stevegill7 at gmail.com (Jetus) Date: Sat, 5 Apr 2008 08:50:30 -0700 (PDT) Subject: Learning curve for new database program with Python? Message-ID: I have a need for a database program. I downloaded the db2 from ibm, and reviewed some of the documentation. My question is, what is the easiest program for me to try to learn. I will be creating a database of about 25,000 records, it will be relational. I am a beginner Python programmer, and need a database solution that is easy to grasp. I played with sql, and found that very difficult, if not overly cumbersome. A database that could work with Django would be very interesting to look at as well.. Any suggestions out there? From steve at holdenweb.com Sun Apr 20 17:26:09 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 20 Apr 2008 17:26:09 -0400 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <480B94D1.6050907@gmail.com> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B52DE.8070105@holdenweb.com> <480B94D1.6050907@gmail.com> Message-ID: <480BB4F1.9080102@holdenweb.com> Hank @ITGroup wrote: > Steve Holden wrote: >> You are suffering from a pathological condition yourself: the desire >> to optimize performance in an area where you do not have any problems. >> I would suggest you just enjoy using Python and then start to ask >> these questions again when you have a real issue that's stopping you >> from getting real work done. >> >> regards >> Steve >> > Hi, Steve, > This not simply a pathological condition. My people are keeping trying > many ways to have job done, and the memory problem became the focus we > are paying attention on at this moment. > Could you please give us some clear clues to obviously call python to > free memory. We want to control its gc operation handily as we were > using J**A. Well, now you've told us a little more about your application I can understand that you need to be careful with memory allocation. The best thing you can do is to ensure that your program is reasonably decomposed into functions. That way the local namespaces have limited lifetimes, and only the values that they return are injected into the environment. You also need to be careful in exception processing that you do not cause a reference to the stack frame to be retained, as that can be a fruitful source of references to objects, rendering them non-collectable. You appear to be stressing the limits of a single program under present-day memory constraints. I am afraid that no matter how carefully you manage object references, any difference you can make is likely to be lost in the noise as far as memory utilization is concerned, and you may have to consider using less direct methods of processing your data sets. The gc module does give you some control over the garbage collector, but generally speaking most programs don't even need that much control. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bj_666 at gmx.net Sat Apr 26 12:02:43 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 26 Apr 2008 16:02:43 GMT Subject: Setting an attribute without calling __setattr__() References: Message-ID: <67h213F2nvf5vU1@mid.uni-berlin.de> On Sat, 26 Apr 2008 08:28:38 -0700, animalMutha wrote: >> Consider reading the *second* paragraph about __setattr__ in section >> 3.4.2 of the Python Reference Manual. > > if you are simply going to answer rtfm - might as well kept it to > yourself. Yes, but if you are telling where exactly to find the wanted information in the documentation, like John did, you are teaching the OP how to fish. Which is a good thing. Much more helpful than your remark anyway. You might as well have kept it to yourself. :-? Ciao, Marc 'BlackJack' Rintsch From wizzardx at gmail.com Sun Apr 20 03:09:52 2008 From: wizzardx at gmail.com (David) Date: Sun, 20 Apr 2008 09:09:52 +0200 Subject: Checking if a text file is blank In-Reply-To: <480ae855$0$15157$607ed4bc@cv.net> References: <480ae855$0$15157$607ed4bc@cv.net> Message-ID: <18c1e6480804200009p6ad00c59n333bc15e332d6294@mail.gmail.com> > > import os > print os.lstat("friends.txt")[6] > I prefer os.lstat("friends.txt").st_size From hopeorpha308 at gmail.com Sun Apr 27 07:48:01 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:48:01 -0700 (PDT) Subject: spynomore crack Message-ID: <92c7e766-c73f-4fb8-8c77-6b7a08844d74@m3g2000hsc.googlegroups.com> spynomore crack http://wga-cracks.crackkey.net From jfgomez21 at gmail.com Thu Apr 10 13:26:45 2008 From: jfgomez21 at gmail.com (Jose) Date: Thu, 10 Apr 2008 10:26:45 -0700 (PDT) Subject: Module Conflicts References: <1592fad3-996b-4f62-ac12-42aff8272c21@8g2000hsu.googlegroups.com> <845e315c-0159-4390-954a-dc93fd1b27a1@x41g2000hsb.googlegroups.com> Message-ID: On Apr 9, 10:36 pm, Benjamin wrote: > On Apr 9, 5:33 pm, Jose wrote: > > > I have a module named math.py in a package with some class > > definitions. I am trying to import the standard python math module > > inside of math.py but It seems to be importing itself. Is there any > > way around this problem without renaming my math.py file? > > Not without some unpythonic magic. It's really not good style to name > a module the same as a stdlib one. It'll also confuse people reading > your code. Yeah but I thought since math.py was in a package, it would be okay. It's no big deal. I'll just rename my module :( From nick at craig-wood.com Tue Apr 1 13:30:05 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Tue, 01 Apr 2008 12:30:05 -0500 Subject: bsddb3 thread problem References: Message-ID: anuraguniyal at yahoo.com wrote: > In my application I am trying to access(read) a DB thru a thread while > my main thread is adding data to it and it gives following error(s) [snip] > Do anybody has a clue what I am doing wrong here? Using threads with bsddb3. I spent weeks trying to get it to behave when threading. I gave up in the end and changed to sqlite :-( At least if you make a mistake with sqlite and use the wrong handle in the wrong place when threading it gives you a very clear error. -- Nick Craig-Wood -- http://www.craig-wood.com/nick From colas.francis at gmail.com Thu Apr 17 09:20:31 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Thu, 17 Apr 2008 06:20:31 -0700 (PDT) Subject: Python and stale file handles References: Message-ID: On 17 avr, 14:43, bock... at virgilio.it wrote: > On 17 Apr, 04:22, tgiles wrote: > > > > > Hi, All! > > > I started back programming Python again after a hiatus of several > > years and run into a sticky problem that I can't seem to fix, > > regardless of how hard I try- it it starts with tailing a log file. > > > Basically, I'm trying to tail a log file and send the contents > > elsewhere in the script (here, I call it processor()). My first > > iteration below works perfectly fine- as long as the log file itself > > (logfile.log) keeps getting written to. > > > I have a shell script constantly writes to the logfile.log... If I > > happen to kill it off and restart it (overwriting the log file with > > more entries) then the python script will stop sending anything at all > > out. > > > import time, os > > > def processor(message,address): > > #do something clever here > > > #Set the filename and open the file > > filename = 'logfile.log' > > file = open(filename,'r') > > > #Find the size of the file and move to the end > > st_results = os.stat(filename) > > st_size = st_results[6] > > file.seek(st_size) > > > while 1: > > where = file.tell() > > line = file.readline() > > if not line: > > time.sleep(1) > > file.seek(where) > > else: > > print line, # already has newline > > data = line > > if not data: > > break > > else: > > processor(data,addr) > > print "Sending message '",data,"'....." > > > someotherstuffhere() > > > === > > > This is perfectly normal behavior since the same thing happens when I > > do a tail -f on the log file. However, I was hoping to build in a bit > > of cleverness in the python script- that it would note that there was > > a change in the log file and could compensate for it. > > > So, I wrote up a new script that opens the file to begin with, > > attempts to do a quick file measurement of the file (to see if it's > > suddenly stuck) and then reopen the log file if there's something > > dodgy going on. > > > However, it's not quite working the way that I really intended it to. > > It will either start reading the file from the beginning (instead of > > tailing from the end) or just sit there confuzzled until I kill it > > off. > > > === > > > import time, os > > > filename = logfile.log > > > def processor(message): > > # do something clever here > > > def checkfile(filename): > > file = open(filename,'r') > > print "checking file, first pass" > > pass1 = os.stat(filename) > > pass1_size = pass1[6] > > > time.sleep(5) > > > print "file check, 2nd pass" > > pass2 = os.stat(filename) > > pass2_size = pass2[6] > > if pass1_size == pass2_size: > > print "reopening file" > > file.close() > > file = open(filename,'r') > > else: > > print "file is OK" > > pass > > > while 1: > > checkfile(filename) > > where = file.tell() > > line = file.readline() > > print "reading file", where > > if not line: > > print "sleeping here" > > time.sleep(5) > > print "seeking file here" > > file.seek(where) > > else: > > # print line, # already has newline > > data = line > > print "readying line" > > if not data: > > print "no data, breaking here" > > break > > else: > > print "sending line" > > processor(data) > > > So, have any thoughts on how to keep a Python script from bugging out > > after a tailed file has been refreshed? I'd love to hear any thoughts > > you my have on the matter, even if it's of the 'that's the way things > > work' variety. > > > Cheers, and thanks in advance for any ideas on how to get around the > > issue. > > > tom > > Possibly, restarting the program that writes the log file creates a > new file rather than > appending to the old one?? It seems at least the op should definitely reopen the file: # create a file In [322]: f1 = open("test.txt", 'w') In [323]: f1.write("test\n") In [324]: f1.close() # check content of file In [325]: f_test1 = open("test.txt") In [326]: f_test1.readline() Out[326]: 'test\n' # check twice, we never know In [327]: f_test1.seek(0) In [328]: f_test1.readline() Out[328]: 'test\n' # rewrite over the same file In [329]: f1 = open("test.txt", 'w') In [330]: f1.write("new test\n") In [331]: f1.close() # check if ok In [332]: f_test2 = open("test.txt") In [333]: f_test2.readline() Out[333]: 'new test\n' # first file object has not seen the change In [334]: f_test1.seek(0) In [335]: f_test1.readline() Out[335]: 'test\n' From Gerry.Paneda at palm.com Wed Apr 16 17:08:29 2008 From: Gerry.Paneda at palm.com (Gerry Paneda) Date: Wed, 16 Apr 2008 14:08:29 -0700 Subject: Open source Web testing tool - cPAMIE 1.6b released Message-ID: <596402ECCC54DA40BAEE00F60CE8F93512CBD88B82@ushqwmb03.palm1.palmone.com> Hi Rob, I have been watching your videos in ShowMeDo and first of all thanks - I just started looking at Automation again and this got me started fairly easy. I do have a question though. 2.0 does not seem to have getConfig and writeScript from the one I downloaded from sourceforge. I went to the user group and applied as member but I haven't been approved yet so I can't download the file you mentioned on the thread in showmedo. Can you help me out? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From ptmcg at austin.rr.com Tue Apr 8 01:41:41 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Mon, 7 Apr 2008 22:41:41 -0700 (PDT) Subject: Welcome to the "Python-list" mailing list References: Message-ID: On Apr 7, 9:54?am, Steve Holden wrote: > Ronn Ross wrote: > > This is my first post and I'm new to Python. How would someone go about > > adding keywords to Python? It would be great to add support for > > Esperanto keywords in the language instead of English being the only > > option. > > Unfortunately the resulting language would no longer be Python. > > You need to consider software portability: Python has been very > conservative about declaring words to be "keywords" in the language, > though clearly words like "def" and "class" must necessarily be part of > the syntax. > > When you start to replace the keywords, though, your programs are no > longer runnable on all Python installations, and simple transliteration > fails because sometimes a keyword in one (natural) language will > conflict with a programmer's choice of name(s) in another. > > So it's a superficially attractive idea with some really bad downside > consequences. > > regards > ? Steve > -- > Steve Holden ? ? ? ?+1 571 484 6266 ? +1 800 494 3119 > Holden Web LLC ? ? ? ? ? ? ?http://www.holdenweb.com/ Zhpy is a Chinese-to-English keyword and variable converter. http://pypi.python.org/pypi/zhpy/1.5.2 Perhaps this could give you some ideas. -- Paul From bvidinli at gmail.com Sat Apr 26 15:16:50 2008 From: bvidinli at gmail.com (bvidinli) Date: Sat, 26 Apr 2008 22:16:50 +0300 Subject: Apologize: annoying dictionary problem, non-existing keys Message-ID: <36e8a7020804261216k41e749c4sdad93cc6c008b435@mail.gmail.com> Thank you all for your answers. i get many usefull answers and someone remembered me of avoiding cross-posting. i apologize from all of you, for cross posting and disturbing. that day was not a good day for me... it is my fault.. sory.... and have nice days... 26 Nisan 2008 Cumartesi 02:52 tarihinde Collin Winter yazd?: > 2008/4/24 bvidinli : > > I posted to so many lists because, > > > > this issue is related to all lists, > > this is an idea for python, > > this is related to development of python... > > > > why are you so much defensive ? > > > > i think ideas all important for development of python, software.... > > i am sory anyway.... hope will be helpful. > > Please consult the documentation first: > http://docs.python.org/lib/typesmapping.html . You're looking for the > get() method. > > This attribute of PHP is hardly considered a feature, and is not > something Python wishes to emulate. > > Collin Winter > > > 2008/4/24, Terry Reedy : > > > > > > > Python-dev is for discussion of development of future Python. Use > > > python-list / comp.lang.python / gmane.comp.python.general for usage > > > questions. > > > > > > > > > > > > _______________________________________________ > > > Python-Dev mailing list > > > Python-Dev at python.org > > > http://mail.python.org/mailman/listinfo/python-dev > > > Unsubscribe: http://mail.python.org/mailman/options/python-dev/bvidinli%40gmail.com > > > > > > > > > > > -- > > ?.Bahattin Vidinli > > Elk-Elektronik M?h. > > ------------------- > > iletisim bilgileri (Tercih sirasina gore): > > skype: bvidinli (sesli gorusme icin, www.skype.com) > > msn: bvidinli at iyibirisi.com > > yahoo: bvidinli > > > > +90.532.7990607 > > +90.505.5667711 > > _______________________________________________ > > > > > > Python-Dev mailing list > > Python-Dev at python.org > > http://mail.python.org/mailman/listinfo/python-dev > > Unsubscribe: http://mail.python.org/mailman/options/python-dev/collinw%40gmail.com > > > -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From jasper at peak.org Thu Apr 24 19:40:52 2008 From: jasper at peak.org (Jasper) Date: Thu, 24 Apr 2008 16:40:52 -0700 (PDT) Subject: How to find the parent of an old-style class? References: <9742ba66-eebf-43ba-8391-d0d0edb52c95@l42g2000hsc.googlegroups.com> <805bf888-722e-44a7-9c6a-66f9a28278af@b64g2000hsa.googlegroups.com> Message-ID: On Apr 24, 10:02 am, Jonathan Gardner wrote: > On Apr 24, 7:16 am, Jasper wrote: > > > I'm stuck using a library based on old style classes, and need to find > > a class's parent at runtime. > > > With new style classes you can use .__base__ to inspect a parent, but > > I can't remember how this was done in days of yore, before object. > > I've tried googling, but apparently my search term Fu is weak. :-( > > > Can anyone help me out here? There must be something simple. > > It's very odd that you need to know a class's parent. I'm interested > in hearing why you need this. In all my years, I've never had to do > this. > > Regardless, I believe you are looking for __bases__. *smack* That's what I get for programming too late into the morning; can't believe I missed that. Thanks for sorting me out! -Jasper PS I'm using a hierarchy of (never instantiated) classes as resource types in an economic sim, e.g. Resource, Luxury( Resource ), Gold( Luxury ). Prices are dicts of {resource:amount}, where resource can be something concrete like Gold, or a general group like Luxury (which could be paid with Gold, but also Ivory, etc). Payments are in dicts of {concrete-resource:amount}, and to verify correct payment I iterate through them, matching concrete resources (via their parent) to general price requirements like Luxury or Resource. I could avoid referencing __bases__ by instead iterating through price and checking issubclass(), but the logic is more complex. And yes, I know this is a bit of an unorthodox use of classes. ;-) From pylists at arcor.de Thu Apr 17 05:54:32 2008 From: pylists at arcor.de (Penny Y.) Date: Thu, 17 Apr 2008 17:54:32 +0800 Subject: about a head line Message-ID: <20080417095445.1750B23D1E1@mail-in-13.arcor-online.net> I saw some scripts have a line at its begin: # encoding:gb2312 what's this? Why need it? thanks. From bj_666 at gmx.net Wed Apr 30 07:39:07 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 30 Apr 2008 11:39:07 GMT Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> <87tzhjy4u2.fsf@physik.rwth-aachen.de> Message-ID: <67r42rF2ptbf1U1@mid.uni-berlin.de> On Wed, 30 Apr 2008 13:12:05 +0200, Torsten Bronger wrote: > However, join() is really bizarre. The list rather than the > separator should be the leading actor. You mean any iterable should be the leading actor, bacause `str.join()` works with any iterable. And that's why it is implemented *once* on string and unicode objects. Okay that's twice. :-) Ciao, Marc 'BlackJack' Rintsch From wwzaygvm at gmail.com Wed Apr 16 17:05:11 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 14:05:11 -0700 (PDT) Subject: originlab crack serial Message-ID: <3ded58e4-2e19-4da5-a9d0-1fd741e25610@a70g2000hsh.googlegroups.com> originlab crack serial http://cracks.12w.net F R E E C R A C K S From carlwuhwdmckay at gmail.com Mon Apr 21 02:08:24 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:08:24 -0700 (PDT) Subject: cracked engine block Message-ID: cracked engine block http://cracks.00bp.com F R E E C R A C K S From barbaros at ptmat.fc.ul.pt Thu Apr 24 09:45:22 2008 From: barbaros at ptmat.fc.ul.pt (barbaros) Date: Thu, 24 Apr 2008 06:45:22 -0700 (PDT) Subject: help needed with classes/inheritance References: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> <480f05d0$0$25755$426a74cc@news.free.fr> <676bac37-2816-402b-9aed-1a9c1873351b@a23g2000hsc.googlegroups.com> <48106eb5$0$21323$426a74cc@news.free.fr> Message-ID: <7a7382b6-8e5a-469d-b1ef-b853e876ec36@s50g2000hsb.googlegroups.com> Thanks to Paul McGuire and Bruno Desthuilliers for their comprehensive answers. This is exactly what I was looking for, except I did not know the correct name (composition/delegation). Now all I have to do is to study the supplied code, understand it and adapt it to my problem. Thank you very much. Cristian Barbarosie http://cmaf.ptmat.fc.ul.pt/~barbaros From skanemupp at yahoo.se Sat Apr 19 16:40:27 2008 From: skanemupp at yahoo.se (globalrev) Date: Sat, 19 Apr 2008 13:40:27 -0700 (PDT) Subject: Tkinter, getting canvas-object, how? References: <4d5c6911-7728-4dad-8d8d-7a862bf78d70@k13g2000hse.googlegroups.com> <4814820b-a3d2-44c1-9db4-0069463f079f@a23g2000hsc.googlegroups.com> <91ec0a69-767c-406b-8a41-44f8989e8eba@e39g2000hsf.googlegroups.com> Message-ID: On 19 Apr, 21:43, globalrev wrote: > On 19 Apr, 10:15, Rafa? Wysocki wrote: > > > > > skanem... at yahoo.se napisa?(a): > > > > so i load a gif onto a canvas and when i click the canvs i want to get > > > the color of the pixel that is clicked. > > > so i need to ge the object im clicking. > > > i was told in another thread to use find_withtag or find_closest but > > > it is not working, maybe im using the > > > method on the wrong object. > > > how do i do this? > > > and how do i then get specifics about that object, ie the pixel-color? > > > > Exception in Tkinter callback > > > Traceback (most recent call last): > > > File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ > > > return self.func(*args) > > > File "C:\Users\saftarn\Desktop\pythonkod\mapexperiments > > > \mapgetobject.py", line 17, in callback > > > undermouse=find_closest(master.CURRENT) > > > NameError: global name 'find_closest' is not defined > > > > from Tkinter import * > > > > master = Tk() > > > > w = Canvas(master, width=400, height=625) > > > w.pack(expand = YES, fill = BOTH) > > > > mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\Maps\provinces-of- > > > sweden.gif') > > > w.create_image(30, 30, image = mapq, anchor = NW) > > > > def key(event): > > > print "pressed", repr(event.char) > > > > def callback(event): > > > clobj=event.widget > > > ## undermouse=find_withtag(master.CURRENT) > > > undermouse=find_closest(master.CURRENT) > > > print repr(undermouse) > > > > w.bind("", key) > > > w.bind("", callback) > > > w.pack() > > > > mainloop() > > > from Tkinter import * > > > master = Tk() > > > w = Canvas(master, width=400, height=625) > > w.pack(expand = YES, fill = BOTH) > > > mapq = PhotoImage(file = 'img.gif') > > _id = w.create_image(0, 0, image = mapq, anchor = NW) > > > objects = {} # map id to object > > objects[_id] = mapq > > > def key(event): > > print "pressed", repr(event.char) > > > def callback(event): > > x, y = w.canvasx(event.x), w.canvasy(event.y) # Translates a > > window x,y coordinates to a canvas coordinate > > _id = w.find_closest(x,y)[0] # Returns tuple containing the object > > id > > obj = objects[_id] # Finds object with given id > > print 'color: %s' % obj.get(int(x), int(y)) > > > w.bind("", key) > > w.bind("", callback) > > w.pack() > > > mainloop() > > ty very much. however i dont get the %s really. is % a symbol and then > replaced by obj.get-values? > anyway when clicked i get 3values, but there is intx and inty only. > where does the 3rd value come from and how do i refer to it? nevermind i get it now From frikker at gmail.com Sun Apr 27 21:31:45 2008 From: frikker at gmail.com (blaine) Date: Sun, 27 Apr 2008 18:31:45 -0700 (PDT) Subject: Regular Expression - Matching Multiples of 3 Characters exactly. Message-ID: Hey everyone, For the regular expression gurus... I'm trying to write a string matching algorithm for genomic sequences. I'm pulling out Genes from a large genomic pattern, with certain start and stop codons on either side. This is simple enough... for example: start = AUG stop=AGG BBBBBBAUGWWWWWWAGGBBBBBB So I obviously want to pull out AUGWWWWWWAGG (and all other matches). This works great with my current regular expression. The problem, however, is that codons come in sets of 3 bases. So there are actually three different 'frames' I could be using. For example: ABCDEFGHIJ I could have ABC DEF GHI or BCD EFG HIJ or CDE FGH IJx.... etc. So finally, my question. How can I represent this in a regular expression? :) This is what I'd like to do: (Find all groups of any three characters) (Find a start codon) (find any other codons) (Find an end codon) Is this possible? It seems that I'd want to do something like this: (\w \w\w)+(AUG)(\s)(AGG)(\s)* - where \w\w\w matches EXACTLY all sets of three non-whitespace characters, followed by AUG \s AGG, and then anything else. I hope I am making sense. Obviously, however, this will make sure that ANY set of three characters exist before a start codon. Is there a way to match exactly, to say something like 'Find all sets of three, then AUG and AGG, etc.'. This way, I could scan for genes, remove the first letter, scan for more genes, remove the first letter again, and scan for more genes. This would hypothetically yield different genes, since the frame would be shifted. This might be a lot of information... I appreciate any insight. Thank you! Blaine From martin at v.loewis.de Wed Apr 16 02:24:56 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Wed, 16 Apr 2008 08:24:56 +0200 Subject: Unicode chr(150) en dash In-Reply-To: References: Message-ID: <48059bb8$0$26954$9b622d9e@news.freenet.de> > "C:\Python24\Lib\site-packages\MySQLdb\cursors.py", line 149, in > execute query = query.encode(charset) UnicodeEncodeError: 'latin-1' > codec can't encode character u'\u2013' in position 52: ordinal not in > range(256) Here it complains that it deals with the character U+2013, which is "EN DASH"; it complains that the encoding called "latin-1" does not support that character. That is a fact - Latin-1 does not support EN DASH. > When I type 'print chr(150)' into a python command line window I get > a LATIN SMALL LETTER U WITH CIRCUMFLEX > (http://www.fileformat.info/info/unicode/char/00fb/index.htm), That's because your console uses the code page 437: py> chr(150).decode("cp437") u'\xfb' py> unicodedata.name(_) 'LATIN SMALL LETTER U WITH CIRCUMFLEX' Code page 437, on your system, is the "OEM code page". > but when I do so into a IDLE window I get a hypen (chr(45). That's because IDLE uses the "ANSI code page" of your system, which is windows code page 1252. py> chr(150).decode("windows-1252") u'\u2013' py> unicodedata.name(_) 'EN DASH' You actually *don't* get the character U+002D, HYPHEN-MINUS, displayed - just a character that has, in your font, a glyph which looks similar to the glyph for HYPHEN-MINUS. However, HYPHEN-MINUS and EN DASH are different characters, and IDLE displays the latter, not the former. > I tried searching "en dash" or even "dash" into the encodings folder > of python Lib, but I couldn't find anything. You didn't ask a specific question, so I assume you are primarily after an explanation. HTH, Martin From terry.yinzhe at gmail.com Tue Apr 29 10:36:59 2008 From: terry.yinzhe at gmail.com (Terry) Date: Tue, 29 Apr 2008 07:36:59 -0700 (PDT) Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> Message-ID: On Apr 29, 3:01 pm, Dennis Lee Bieber wrote: > On Sun, 27 Apr 2008 03:27:59 -0700 (PDT), Terry > declaimed the following in comp.lang.python: > > > I'm trying to implement a message queue among threads using Queue. The > > message queue has two operations: > > PutMsg(id, msg) # this is simple, just combine the id and msg as one > > and put it into the Queue. > > WaitMsg(ids, msg) # this is the hard part > > > WaitMsg will get only msg with certain ids, but this is not possible > > in Queue object, because Queue provides no method to peek into the > > message queue and fetch only matched item. > > > Now I'm using an ugly solution, fetch all the messages and put the not > > used ones back to the queue. But I want a better performance. Is there > > any alternative out there? > > Create your own queue class -- including locking objects. > > Implement the queue itself (I've not looked at how Queue.Queue is > really done) as a priority queue (that is, a simple list ordered by your > ID -- new items are inserted after all existing items with the same or > lower ID number). > > Surround list manipulations with a lock based on a Condition. > > Now, the trick -- the .get(ID) sequence being something like (this > is pseudo-code): > > while True: > self.condition.acquire() > scan self.qlist for first entry with ID > if found: > remove entry from self.qlist > self.condition.release() > return entry > self.condition.wait() > > -=-=-=-=- the .put(ID, data) looks like > > self.condition.acquire() > scan self.qlist for position to insert (ID, data) > self.condition.notifyAll() > self.condition.release() > > -=-=-=-=- > > Essentially, if the first pass over the list does not find an entry > to return, it waits for a notify to occur... and notification will only > occur when some other thread puts new data into the list. > -- > Wulfraed Dennis Lee Bieber KD6MOG > wlfr... at ix.netcom.com wulfr... at bestiaria.com > HTTP://wlfraed.home.netcom.com/ > (Bestiaria Support Staff: web-a... at bestiaria.com) > HTTP://www.bestiaria.com/ Yes, now I have a similar solution in my code. But after read the stackless python, I'm thinking if I can move to stackless, which might improve the performance of my thread. Because I'm trying to simulate some behavior of the real world (trading), I believe there will be a lot of threads in the future in my program. From drjekil77 at gmail.com Tue Apr 8 22:17:57 2008 From: drjekil77 at gmail.com (drjekil) Date: Tue, 8 Apr 2008 19:17:57 -0700 (PDT) Subject: new user needs help! In-Reply-To: <16571823.post@talk.nabble.com> References: <16571823.post@talk.nabble.com> Message-ID: <16578029.post@talk.nabble.com> u got it! thats the thing i am trying to explain by my bad english! thanks for the help. -- View this message in context: http://www.nabble.com/new--user-needs-help%21-tp16571823p16578029.html Sent from the Python - python-list mailing list archive at Nabble.com. From duncan.booth at invalid.invalid Fri Apr 4 04:57:42 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 4 Apr 2008 08:57:42 GMT Subject: variable scope in list comprehensions References: Message-ID: Steve Holden wrote: >> For a moment I thought that maybe list comprehension has its own >> scope, but it doesn't seem to be so: >> print [[y for y in range(8)] for y in range(8)] >> print y >> >> Does anybody understand it? >> >> > This isn't _a_ list comprehension, it's *two* list comprehensions. The > interpreter computes the value if the inner list comprehension and > then duplicates eight references to it (as you will see if you change > an element). > Do you want to reconsider that statement? The interpreter recomputes the inner list comprehension eight times, there are no duplicated references. For the OP, in some languages (e.g. C) 'for' loops typically calculate the value of the loop control variable based on some expression involving the previous value. Python isn't like that. In Python the data used to compute the next value is stored internally: you cannot access it directly. That means you can reassign or delete the loop control variable if you want, but it doesn't affect the loop iteration; every time round the loop there is a fresh assignment to the variable. So the code: for y in range(8): for y in range(8): pass # or whatever the body of the loops is sort of equivalent to: __loop_control_1__ = iter(range(8)) while True: try: y = __loop_control_1__.next() except StopIteration: break __loop_control_2__ = iter(range(8)) while True: try: y = __loop_control_1__.next() except StopIteration: break pass # or whatever the body of the loops except there are no accessible variables __loop_control_1__ or __loop_control_2__. From kay.schluehr at gmx.net Sat Apr 5 06:55:30 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 5 Apr 2008 03:55:30 -0700 (PDT) Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> Message-ID: On 5 Apr., 12:26, Aldo Cortesi wrote: > Thus spake Kay Schluehr (kay.schlu... at gmx.net): > > > I'm not entirely sure what you are claiming here. From source > > inspections I can see that TestSuite instances are instantiated by the > > TestLoader and you are free to derive from TestLoader, overwrite its > > methods and pass around another instance than defaultTestLoader ( or > > a fresh instance of TestLoader which is the same thing ). > > ... and at this point your monkeypatched framework would no longer be > much more compatible with existing test suites than Pry is. A properly extended framework would of course be compatible with all existing test suites. This has nothing to do with monkeypatching. I'm not sure you even understand the concepts you are talking about. Kay From steve at holdenweb.com Wed Apr 23 23:52:41 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 23:52:41 -0400 Subject: function that accepts any amount of arguments? In-Reply-To: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> Message-ID: globalrev wrote: > if i want a function that can take any amount of arguments how do i > do? > > lets say i want a function average that accepts any number of integers > and returns the average. Use a parameter of the form *args - the asterisk tells the interpreter to collect positional arguments into a tuple. Untested: def mean(*x): total = 0.0 for v in x: total += v return v/len(x) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From dickinsm at gmail.com Wed Apr 9 09:11:48 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Wed, 9 Apr 2008 06:11:48 -0700 (PDT) Subject: what's the reasonale of loghelper() in mathmodule.c References: <49750e9d-1a63-42d2-b292-38d225b0c3c8@n1g2000prb.googlegroups.com> Message-ID: <28321dcf-71d2-4c67-bd1d-1e187015129d@u3g2000hsc.googlegroups.com> On Apr 9, 4:38?am, rockins wrote: > I cannot understand it well, can anyone explain me why and how > loghelper() can compute any base logarithm? Or could anyone give me > some reference(such as, books or papers)? loghelper is there so that log(n) can be computed for any positive integer n---it's nothing to do with computing logs to an arbitrary base. All of the other math functions convert an integer argument to a float first. That conversion fails if the integer is larger than the largest representable float (around 1.7e308 on most systems). For example: >>> from math import sqrt, log >>> sqrt(10**600) Traceback (most recent call last): File "", line 1, in OverflowError: long int too large to convert to float >>> log(10**600) 1381.5510557964274 The sqrt call first tries to convert 10**600 to a float, giving an OverflowError (even though the actual square root *is* representable as a float). The log call goes through loghelper instead, which doesn't try to convert 10**600 to a float, but instead computes the log based on the top few bits of 10**600 (in its internal binary representation) and on the number of bits required to represent 10**600. You're not going to learn much about math function implementations from mathmodule.c: all it does it wrap the platform libm functions. Mark From bignose+hates-spam at benfinney.id.au Sun Apr 27 21:43:10 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Mon, 28 Apr 2008 11:43:10 +1000 Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> <48118719$0$25846$9b622d9e@news.freenet.de> Message-ID: <87prsa4uvl.fsf@benfinney.id.au> Aaron Watters writes: > I think it's outrageous to change the basic usage for things like > dictionary.keys() when it would be so easy to leave the old > definition and add a new method like dictionary.keySet(). Except that name would be outrageously non-conformant with PEP 8. -- \ "Yesterday I parked my car in a tow-away zone. When I came back | `\ the entire area was missing." -- Steven Wright | _o__) | Ben Finney From spiro.harvey at gmail.com Thu Apr 3 17:56:14 2008 From: spiro.harvey at gmail.com (idle) Date: Thu, 3 Apr 2008 14:56:14 -0700 (PDT) Subject: expanding a variable to a dict Message-ID: I've got a variable in a loop that I'm trying to expand/translate/ readdress as an existing dict so as to add some keys into it.. eg; I have a set of existing dicts: dictFoo, dictBar, dictFrotz (names changed to protect the innocent) now I'd like to check them all for the existence of certain default keys; ie, if the dicts don't contain the keys, add them in with default values. so, I've got: for a in ['dictFoo','dictBar','dictFrotz']: if hasattr(a,'srcdir') == False: a['srcdir']='/usr/src' the error I get (which I expect) is 'str' object doesn't support item assignment. what incantation do I cast on 'a' to make the interpreter parse it as 'dictFoo' on the first iteration, 'dictBar' on the second, and so forth? and/or less importantly, what is such a transformation called, to help me target my searching? thanks From leoniaumybragg at gmail.com Sat Apr 26 06:56:51 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:56:51 -0700 (PDT) Subject: cotton patch cafe Message-ID: cotton patch cafe http://cracks.00bp.com F R E E C R A C K S From cginnowzerozeroone at microprizes.com Mon Apr 14 17:28:18 2008 From: cginnowzerozeroone at microprizes.com (Carl G.) Date: Mon, 14 Apr 2008 14:28:18 -0700 Subject: Game design : Making computer play References: <66gf8dF2ju94lU3@mid.uni-berlin.de> Message-ID: "Marc 'BlackJack' Rintsch" wrote in message news:66gf8dF2ju94lU3 at mid.uni-berlin.de... > On Mon, 14 Apr 2008 00:13:56 -0700, v4vijayakumar wrote: > >> In computer based, two player, board games, how to make computer play? >> Are there any formal ways to _teach_ computer, to choose best possible >> move? > > That depends on the type of the game. For a certain class of games one > can use the `minimax method`_ for instance. > > .. _minimax method: http://en.wikipedia.org/wiki/Minimax While checking the Wikipedia, also check out the A* (a-star) graph search algorithms: http://en.wikipedia.org/wiki/A%2A There is a table on the top-right of this page that includes other graph search algorithms. My AI games are usually built around general purpose mini-max code, possibly inplementing A* (I reuse the same code for various games). For each new two-player game, I usually only have to write new "position evaluator" code, which generates a quantitative value that gives the relative position of one player over the other for a particular board. Some games can benefit from a database of opening moves that have been shown to be be superior (this speeds up the computer's response). Carl G. From dave.opstad at monotypeimaging.com Fri Apr 25 16:34:28 2008 From: dave.opstad at monotypeimaging.com (Dave Opstad) Date: Fri, 25 Apr 2008 13:34:28 -0700 Subject: List of all Python's ____ ? References: <87wsmrdka8.fsf@mulj.homelinux.net> <480d016e$1@news.mel.dft.com.au> Message-ID: In article <480d016e$1 at news.mel.dft.com.au>, John Machin wrote: > Hrvoje Niksic wrote: > > python at bdurham.com writes: > > > >> Is there an official list of all Python's ____? > > > > http://docs.python.org/ref/specialnames.html > > __missing__ is missing :-) > > see note (10) at the bottom of http://docs.python.org/lib/typesmapping.html Yes, and __copy__ and __deepcopy__ are missing too: http://docs.python.org/lib/module-copy.html Dave From tnelson at onresolve.com Wed Apr 16 13:51:53 2008 From: tnelson at onresolve.com (Trent Nelson) Date: Wed, 16 Apr 2008 10:51:53 -0700 Subject: Global Python Sprint Weekends: May 10th-11th and June 21st-22nd. Message-ID: <87D3F9C72FBF214DB39FA4E3FE618CDC6E22F389FE@EXMBX04.exchhosting.com> Following on from the success of previous sprint/bugfix weekends and sprinting efforts at PyCon 2008, I'd like to propose the next two Global Python Sprint Weekends take place on the following dates: * May 10th-11th (four days after 2.6a3 and 3.0a5 are released) * June 21st-22nd (~week before 2.6b2 and 3.0b2 are released) It seems there are a few of the Python User Groups keen on meeting up in person and sprinting collaboratively, akin to PyCon, which I highly recommend. I'd like to nominate Saturday across the board as the day for PUGs to meet up in person, with Sunday geared more towards an online collaboration day via IRC, where we can take care of all the little things that got in our way of coding on Saturday (like finalising/preparing/reviewing patches, updating tracker and documentation, writing tests ;-). For User Groups that are planning on meeting up to collaborate, please reply to this thread on python-dev at python.org and let every- one know your intentions! As is commonly the case, #python-dev on irc.freenode.net will be the place to be over the course of each sprint weekend; a large proportion of Python developers with commit access will be present, increasing the amount of eyes available to review and apply patches. For those that have an idea on areas they'd like to sprint on and want to look for other developers to rope in (or just to communicate plans in advance), please also feel free to jump on this thread via python-dev@ and indicate your intentions. For those that haven't the foggiest on what to work on, but would like to contribute, the bugs tracker at http://bugs.python.org is the best place to start. Register an account and start searching for issues that you'd be able to lend a hand with. All contributors that submit code patches or documentation updates will typically get listed in Misc/ACKS.txt; come September when the final release of 2.6 and 3.0 come about, you'll be able to point at the tarball or .msi and exclaim loudly ``I helped build that!'', and actually back it up with hard evidence ;-) Bring on the pizza and Red Bull! Trent. From michael at stroeder.com Thu Apr 24 03:47:06 2008 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Thu, 24 Apr 2008 09:47:06 +0200 Subject: python-ldap - Operations Error In-Reply-To: <8b35f293-fc64-4d21-a621-124c8eafde59@c65g2000hsa.googlegroups.com> References: <8b35f293-fc64-4d21-a621-124c8eafde59@c65g2000hsa.googlegroups.com> Message-ID: Jason Scheirer wrote: > On Apr 23, 5:16 pm, theivi... at gmail.com wrote: >> Hello all, I am trying to integrate TurboGears with our Active >> Directory here at the office. TurboGears aside, i cannot get this to >> work. > > Seems more promising: http://tgolden.sc.sabren.com/python/active_directory.html This is based on ADSI? Then the caveat is that it only runs on Windows. Ciao, Michael. From ramesh at winfoware.com Mon Apr 21 06:43:35 2008 From: ramesh at winfoware.com (Ramesh Nathan) Date: Mon, 21 Apr 2008 16:13:35 +0530 Subject: Python Consultants required - Urgent Message-ID: <073f01c8a39c$8ec8f760$ac5ae620$@com> HI Anand, I am looking for python consultants for a couple of months. Please let me know if you could help us directly or suggest some one suitable. With warm regards, Ramesh Nathan, Head - Business Relations, Winfoware Technologies Ltd, Mobile - 0 93425 54560. Land Line - +91 080 23224418 / 23224420 HYPERLINK "http://www.winfoware.com"www.winfoware.com No virus found in this outgoing message. Checked by AVG. Version: 7.5.524 / Virus Database: 269.23.2/1388 - Release Date: 20-04-2008 15:01 -------------- next part -------------- An HTML attachment was scrubbed... URL: From tinnews at isbd.co.uk Mon Apr 7 09:05:20 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 07 Apr 2008 13:05:20 GMT Subject: Presumably an import is no faster or slower than opening a file? References: <47f8d30f$0$761$bed64819@news.gradwell.net> Message-ID: <47fa1c10$0$761$bed64819@news.gradwell.net> Paul McGuire wrote: > On Apr 6, 8:41?am, tinn... at isbd.co.uk wrote: > > I'm trying to minimise the overheads of a small Python utility, I'm > > not really too fussed about how fast it is but I would like to > > minimise its loading effect on the system as it could be called lots > > of times (and, no, I don't think there's an easy way of keeping it > > running and using the same copy repeatedly). > > > > It needs a configuration file of some sort which I want to keep > > separate from the code, is there thus anything to choose between a > > configuration file that I read after:- > > > > ? ? f = open("configFile", 'r') > > > > ... and importing a configuration written as python dictionaries or > > whatever:- > > > > ? ? import myConfig > > > > -- > > Chris Green > > Chris - > > The question is less an issue of the file overhead (both must open a > file, read its contents, and then close it) than what is done with the > file contents afterwards. > > A config file containing .INI-style or whatever content will need to > be parsed into Python data/objects, and likely use Python code to do > so. An import will use the Python compiler itself, using optimized > compiled C code to do the parsing and data/object construction. But I > think you would only see the distinction in a config file of > substantial size or complexity. If you think this will make a > substantial difference in performance, then code up a test case and > time it. > > In general, I'd say that splitting performance hairs to tip a design > choice one way or another is a misguided premature optimization. > I quite agree (about the splitting hairs bit that is), as I said before I just wanted to check that I wasn't missing anything really obvious and, thus, that there probably isn't much to choose between the two approaches. Therefore I'll decide which way to do it on the basis of 'usability'. -- Chris Green From aahz at pythoncraft.com Sun Apr 20 22:57:35 2008 From: aahz at pythoncraft.com (Aahz) Date: 20 Apr 2008 19:57:35 -0700 Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> Message-ID: In article , Carl Banks wrote: >On Apr 17, 3:37 am, Jonathan Gardner >wrote: >> >> Using 100% of the CPU is a bug, not a feature. > >No it isn't. That idea is borne of the narrowmindedness of people who >write server-like network apps. What's true for web servers isn't >true for every application. Only when you have only one application running on a machine. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ Why is this newsgroup different from all other newsgroups? From mal at egenix.com Thu Apr 24 13:41:43 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Thu, 24 Apr 2008 19:41:43 +0200 Subject: convert xhtml back to html In-Reply-To: <000901c8a62e$f36fdc80$c41ea8c0@naomi> References: <000901c8a62e$f36fdc80$c41ea8c0@naomi> Message-ID: <4810C657.3060101@egenix.com> On 2008-04-24 19:16, John Krukoff wrote: >> -----Original Message----- >> From: python-list-bounces+jkrukoff=ltgc.com at python.org [mailto:python- >> list-bounces+jkrukoff=ltgc.com at python.org] On Behalf Of Tim Arnold >> Sent: Thursday, April 24, 2008 9:34 AM >> To: python-list at python.org >> Subject: convert xhtml back to html >> >> hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop >> to >> create CHM files. That application really hates xhtml, so I need to >> convert >> self-ending tags (e.g.
) to plain html (e.g.
). >> >> Seems simple enough, but I'm having some trouble with it. regexps trip up >> because I also have to take into account 'img', 'meta', 'link' tags, not >> just the simple 'br' and 'hr' tags. Well, maybe there's a simple way to do >> that with regexps, but my simpleminded )]+/> doesn't work. I'm >> not >> enough of a regexp pro to figure out that lookahead stuff. >> >> I'm not sure where to start now; I looked at BeautifulSoup and >> BeautifulStoneSoup, but I can't see how to modify the actual tag. You could filter the XHTML through mxTidy and set the hide_endtags to 1: http://www.egenix.com/products/python/mxExperimental/mxTidy/ -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 24 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From steve at holdenweb.com Tue Apr 1 23:19:48 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 01 Apr 2008 23:19:48 -0400 Subject: generator functions: why won't this work? In-Reply-To: References: Message-ID: zillow20 at googlemail.com wrote: > Hi all, > > I'm trying to understand generator functions and the yield keyword. > I'd like to understand why the following code isn't supposed to work. > (What I would have expected it to do is, for a variable number of > arguments composed of numbers, tuples of numbers, tuples of tuples, > etc., the function would give me the next number "in sequence") > #################################### > def getNextScalar(*args): > for arg in args: > if ( isinstance(arg, tuple)): > getNextScalar(arg) > else: > yield arg > #################################### > > # here's an example that uses this function: > # creating a generator object: > g = getNextScalar(1, 2, (3,4)) > g.next() # OK: returns 1 > g.next() # OK: returns 2 > g.next() # not OK: throws StopIteration error > > #################################### > > I'm sure I'm making some unwarranted assumption somewhere, but I > haven't been able to figure it out yet (just started learning Python a > couple of days ago). > > Any help will be appreciated :) > In your recursive call you are passing a single argument, a tuple. You should create it to multiple arguments with a star. Neither do you do anything with the iterator after you create it. Try (untested) #################################### def getNextScalar(*args): for arg in args: if ( isinstance(arg, tuple)): for a in getNextScalar(*arg): yield a else: yield arg #################################### regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From alexelder at gmail.com Wed Apr 23 04:49:13 2008 From: alexelder at gmail.com (alexelder at gmail.com) Date: Wed, 23 Apr 2008 01:49:13 -0700 (PDT) Subject: "Dreaming in Code" References: <14fccf8d-eb21-4e04-9244-50bcfc84c4d7@d45g2000hsc.googlegroups.com> Message-ID: <1630250a-92e1-460c-b569-946868ffd85f@y21g2000hsf.googlegroups.com> On Apr 23, 6:12 am, Paul McGuire wrote: > Haven't seen anyone mention this book, it is a "Soul of a New Machine"- > style record of the Chandler project. Since Chandler uses Python and > Twisted, and employed a few Python celebs, I thought folks on this > list might have already read the hardcover version. I just picked up > the paperback at B&N yesterday, finished it this evening. It's a > decent read, describing a software project in laymen's terms (like > there are laymen out there who care about that sort of thing!). > > The paperback version adds a chapter including events that transpired > after the hardcover publication date, current up to about October, > '07, so that's a nice touch. > > I'm going to ask my wife to read it so she might learn what I do for a > living. > > -- Paul Hi, Paul. This book was actually the book which got me into Python! At the time of reading I was in my second year of University, utterly snowed under with Java and C related assignments/personal projects, however, I found time to read this book; I'm /so/ glad I did. I actually heard of the book from an article written by Joel 'Joel on Software', Spolsky. (you can find it here: http://www.joelonsoftware.com/items/2007/01/02.html). It's an interesting read and poses a nice insight into how software projects evolve over time. Alex. From larry.bates at websafe.com` Sun Apr 27 09:55:35 2008 From: larry.bates at websafe.com` (Larry Bates) Date: Sun, 27 Apr 2008 08:55:35 -0500 Subject: design choice: multi-threaded / asynchronous wxpython client? In-Reply-To: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: <58CdnQxBlq1FGInVnZ2dnUVZ_sednZ2d@comcast.com> bullockbefriending bard wrote: > I am a complete ignoramus and newbie when it comes to designing and > coding networked clients (or servers for that matter). I have a copy > of Goerzen (Foundations of Python Network Programming) and once > pointed in the best direction should be able to follow my nose and get > things sorted... but I am not quite sure which is the best path to > take and would be grateful for advice from networking gurus. > > I am writing a program to display horse racing tote odds in a desktop > client program. I have access to an HTTP (open one of several URLs, > and I get back an XML doc with some data... not XML-RPC.) source of > XML data which I am able to parse and munge with no difficulty at all. > I have written and successfully tested a simple command line program > which allows me to repeatedly poll the server and parse the XML. Easy > enough, but the real world production complications are: > > 1) The data for the race about to start updates every (say) 15 > seconds, and the data for earlier and later races updates only every > (say) 5 minutes. There is no point for me to be hammering the server > with requests every 15 seconds for data for races after the upcoming > race... I should query for this perhaps every 150s to be safe. But for > the upcoming race, I must not miss any updates and should query every > ~7s to be safe. So... in the middle of a race meeting the situation > might be: > race 1 (race done with, no-longer querying), race 2 (race done with, > no longer querying) race 3 (about to start, data on server for this > race updating every 15s, my client querying every 7s), races 4-8 (data > on server for these races updating every 5 mins, my client querying > every 2.5 mins) > > 2) After a race has started and betting is cut off and there are > consequently no more tote updates for that race (it is possible to > determine when this occurs precisely because of an attribute in the > XML data), I need to stop querying (say) race 3 every 7s and remove > race 4 from the 150s query group and begin querying its data every 7s. > > 3) I need to dump this data (for all races, not just current about to > start race) to text files, store it as BLOBs in a DB *and* update real > time display in a wxpython windowed client. > > My initial thought was to have two threads for the different update > polling cycles. In addition I would probably need another thread to > handle UI stuff, and perhaps another for dealing with file/DB data > write out. But, I wonder if using Twisted is a better idea? I will > still need to handle some threading myself, but (I think) only for > keeping wxpython happy by doing all this other stuff off the main > thread + perhaps also persisting received data in yet another thread. > > I have zero experience with these kinds of design choices and would be > very happy if those with experience could point out the pros and cons > of each (synchronous/multithreaded, or Twisted) for dealing with the > two differing sample rates problem outlined above. > > Many TIA! > > > > IMHO using twisted will give you the best performance and framework. Since it uses callbacks for every request, your machine could handle a LOT of different external queries and keep everything updated in WX. Might be a little tricky to get working with WX, but I recall Googling for something like this not long ago and there appeared to be sufficient information on how to get working. http://twistedmatrix.com/projects/core/documentation/howto/choosing-reactor.html Twisted even automatically uses threads to keep SQL database storage routines from blocking (see Chapter 4 of Twisted Network Programming Essentials) This is an ambitious project, good luck. -Larry From steve at holdenweb.com Sun Apr 6 22:43:39 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 06 Apr 2008 22:43:39 -0400 Subject: ANN: pry unit testing framework In-Reply-To: <20080407023442.GA16373@nullcube.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> <20080407023442.GA16373@nullcube.com> Message-ID: <47F98A5B.8010000@holdenweb.com> Aldo Cortesi wrote: > Thus spake Ben Finney (bignose+hates-spam at benfinney.id.au): > >>> I'm afraid that Pry is unashamedly incompatible with any other unit >>> testing method in existence, including but not limited to doctest, >>> unittest, nose and py.test. ;) >> Which makes the deliberate deviations from PEP 8 naming a large black >> mark against it. > > You're misunderstanding the intent of PEP 8, which was never supposed > to dogmatically enforce a naming standard on all Python projects > everywhere. You're also vastly overstating the impact of a minor naming > convention choice. Calling this a "large black mark" smacks of > scare-mongering to me. > It probably reflects personal preference, but it's a preference that many people will maintain. I understand that PEP 008 was largely directed at standard library authors and maintainers, but anything that claims wide utility should have ambitions to be included in the standard library, and hence PEP 008 conformance would be a plus. >>> Some day I might experiment with extending Pry to gather and run >>> doctests and unittests. At this stage, however, I don't believe the >>> (significant) effort would be worth it. >> That's very unfortunate. Until it plays better with others, I don't >> believe the effort of using this package will be worth it. > > Each of the third-party testing frameworks that have cropped up in this > thread extends unittest in some incompatible way. If you use any of > these extensions, it means that your unit test suite is tied to that > particular test framework. If you have an existing suite of unit tests > that you can't or don't want to convert, I'm afraid that Pry is indeed > not for you. Pry is not intended to be a general engine for running > tests written for other frameworks. > A reasonable enough point of view, but it means that you are just one of a number of competing frameworks. While you are earnest about pry's advantages you have a lot of work to do to move people away form the entrenched testing frameworks they are used to. > I should also note that converting from unittest to Pry is quite simple > - Pry's test structure is a superset of unittest's, and AutoTree was > explicitly written to make "unittest-style" testing possible, meaning > that no _structural_ change is needed for conversion. The most onerous > part is converting to assertion-based testing, something that will > improve the clarity and readability of your tests anyway. > Time will tell. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From sturlamolden at yahoo.no Tue Apr 22 13:55:05 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Tue, 22 Apr 2008 10:55:05 -0700 (PDT) Subject: subprocess module is sorely deficient? References: Message-ID: <775619e8-5ee4-4b4e-a081-47c8c6090f05@e67g2000hsa.googlegroups.com> On Apr 22, 12:52 pm, Harishankar wrote: > Sorry to start off on a negative note in the list, but I feel that the Python > subprocess module is sorely deficient because it lacks a mechanism to Have you looked at the processing module in cheese shop? From damonwischik at gmail.com Fri Apr 18 20:50:40 2008 From: damonwischik at gmail.com (damonwischik at gmail.com) Date: Fri, 18 Apr 2008 17:50:40 -0700 (PDT) Subject: How to print a unicode string? References: <54e7dba7-f7f2-4aa7-81f9-922e3bf6e6cd@m73g2000hsh.googlegroups.com> Message-ID: <7110f3b8-8304-4773-a747-31f177c1eb8b@p25g2000hsf.googlegroups.com> On Apr 19, 1:36 am, 7stud wrote: > u_str = u'hell\u00F6 w\u00F6rld' #o's with umlauts > print u_str.encode('utf-8') > > --output:-- > hell? w?rld Maybe on your system. On my system, those same commands produce hell\303\266 w\303\266rld Those \303\266 symbols are single characters -- when I move around with cursor keys, the cursor jumps across them with a single key- press. As I wrote, I'm running Python inside Emacs 22.2.1 (using python- mode). Damon. From sandip.more at gmail.com Tue Apr 29 01:36:41 2008 From: sandip.more at gmail.com (sandipm) Date: Mon, 28 Apr 2008 22:36:41 -0700 (PDT) Subject: python script as executable Message-ID: Hi, I have written a python script to run from cron. I have put #!/usr/bin/env python at top. file executes correctly when I run using python filename.py but it fails to execute when try to run it like script/command. it throws error: :No such file or directory I am editing file from eclipse for python from windows. and then uploading on linus machine to run it. any pointers? sandip From skanemupp at yahoo.se Fri Apr 4 23:57:58 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 4 Apr 2008 20:57:58 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> Message-ID: <7113d012-01bb-4426-bb40-9e2811cdb102@x41g2000hsb.googlegroups.com> On 5 Apr, 05:26, 7stud wrote: > On Apr 4, 7:06 pm, skanem... at yahoo.se wrote: > > > > > 1st question: > > > when i run this program 1 will be printed into the interpreter when i > > run it BUT without me clicking the actual button. > > when i then click the button "1", nothing happens. > > > obv i dont want any output when i dont push the button but i want it > > when i do. > > > what am i doing wrong here? > > > 2nd question: > > > i want all the buttons to have the same size. i thought i should use > > row/columnspan but i dont get that to work. > > how should i do? > > > [code] > > #! /usr/bin/env python > > from Tkinter import * > > import tkMessageBox > > > class GUIFramework(Frame): > > """This is the GUI""" > > > def __init__(self,master=None): > > """Initialize yourself""" > > > """Initialise the base class""" > > Frame.__init__(self,master) > > > """Set the Window Title""" > > self.master.title("Calculator") > > > """Display the main window" > > with a little bit of padding""" > > self.grid(padx=10,pady=10) > > self.CreateWidgets() > > > def CreateWidgets(self): > > > self.enText = Entry(self) > > self.enText.grid(row=0, column=0, columnspan=8, padx=5, > > pady=5) > > > self.enText = Entry(self) > > self.enText.grid(row=1, column=0, columnspan=8, padx=5, > > pady=5) > > > self.btnDisplay = Button(self, text="1", > > command=self.Display(1)) > > self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="2", default=ACTIVE) > > self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="3", default=ACTIVE) > > self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="+", default=ACTIVE) > > self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="4", default=ACTIVE) > > self.btnDisplay.grid(row=4, column=0, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="5", default=ACTIVE) > > self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="6", default=ACTIVE) > > self.btnDisplay.grid(row=4, column=2, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="-", default=ACTIVE) > > self.btnDisplay.grid(row=4, column=3, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="7", default=ACTIVE) > > self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="8", default=ACTIVE) > > self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="9", default=ACTIVE) > > self.btnDisplay.grid(row=5, column=2, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="*", default=ACTIVE) > > self.btnDisplay.grid(row=5, column=3, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="0", default=ACTIVE) > > self.btnDisplay.grid(row=6, column=0, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="C", default=ACTIVE) > > self.btnDisplay.grid(row=6, column=1, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="r", default=ACTIVE) > > self.btnDisplay.grid(row=6, column=2, padx=5, pady=5) > > > self.btnDisplay = Button(self, text="/", default=ACTIVE) > > self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) > > > def Display(self, xbtn): > > if xbtn==1: > > print 1 > > > if __name__ == "__main__": > > guiFrame = GUIFramework() > > guiFrame.mainloop() > > > [/code] > > If you have this function: > > def f(): > print 1 > return 10 > > and you write: > > result = f() > > The '()' is the function execution operator; it tells python to > execute the function. In this case, the function executes, and then > the return value of the function is assigned to the variable result. > If a function does not have a return statement, then the function > returns None by default. > > The same thing is happening in this portion of your code: > > command = self.Display(1) > > That code tells python to execute the Display function and assign the > function's return value to the variable command. As a result Display > executes and 1 is displayed. Then since Dispay does not have a return > statement, None is returned, and None is assigned to command. > Obviously, that is not what you want to do. > > What you want to do is assign a "function reference" to command so > that python can execute the function sometime later when you click on > the button. A function reference is just the function name without > the '()' after it. So you would write: > > command = self.Display > > But writing it like that doesn't allow *you* to pass any arguments to > Display(). In addition, *tkinter* does not pass any arguments to > Display when tkinter calls Display in response to a button click. As > a result, there is no way to pass an argument to Display. > > However, there is another way to cause a function to execute when an > event, like a button click, occurs on a widget: you use the widget's > bind() function: > > my_button.bind('', someFunc) > > The first argument tells tkinter what event to respond to. > '' is a left click. Check the docs for the different > strings that represent the different events that you can respond to. > The second argument is a function reference, which once again does not > allow you to pass any arguments to the function. However, when you > use bind() to attach a function to a widget, tkinter calls the > function and passes it one argument: the "event object". The event > object contains various pieces of information, and one piece of > information it contains is the widget upon which the event occurred, > e.g. the button that was clicked. To get the button, you write: > > Display(self, event_obj): > button = event_obj.widget > > Once you have the button, you can get the text on the button: > > Display(self, event_obj): > button = event_obj.widget > text = button.cget("text") > > if text=="1": > print 1 > > Another thing you should be aware of: self is like a class wide > bulletin board. If you are writing code inside a class method, and > there is data that you want code inside another class method to be > able to see, then post the data on the class wide bulletin board, i.e. > attach it to self. But in your code, you are doing this: > > self.btnDisplay = Button(self, text="7", default=ACTIVE) > self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > self.btnDisplay = Button(self, text="8", default=ACTIVE) > self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > As a result, your code continually overwrites self.btnDisplay. That > means you aren't preserving the data assigned to self.btnDisplay. > Therefore, the data does not need to be posted on the class wide > bulletin board for other class methods to see. So just write: > > btnDisplay = Button(self, text="7", default=ACTIVE) > btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > btnDisplay = Button(self, text="8", default=ACTIVE) > btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > As for the button sizing problem, your buttons are all the same size > and line up perfectly on mac os x 10.4.7. wow thank you so much, awesome answer i will get right to fixing this now. in regards to the buttonsizes i use windows VISTA and they have different sizes. From kyrie at uh.cu Fri Apr 25 17:29:29 2008 From: kyrie at uh.cu (Luis Zarrabeitia) Date: Fri, 25 Apr 2008 17:29:29 -0400 Subject: Goodbying Spaces In-Reply-To: <4dc0cfea0804251401p3ab96fddy99452f5a3255acde@mail.gmail.com> References: <4dc0cfea0804251401p3ab96fddy99452f5a3255acde@mail.gmail.com> Message-ID: <200804251729.29976.kyrie@uh.cu> Whats the result of using id.strip()?: In [1]: " asdfasdf ".strip() Out[1]: 'asdfasdf' It should work, I guess... Btw, you can write your code without using len in a cleaner way: try: if id[0] == ' ': id = id[1:] # Note this slice notation... except: pass try: if id[-1] == ' ': # id[-1] would be the last character id = id[:-1] # Again, a slice with only one argument except: pass Cheers, K. On Friday 25 April 2008 05:01:31 pm Victor Subervi wrote: > Hi; > Whenever I call a field from the preceeding form using cgi.FieldStorage() I > get a space on either side. I end up writing code like this to get rid of > that space: > > try: > > if id[0] == ' ': > > id = id[1:len(id)] > > except: > > pass > > try: > > if id[len(id) - 1] == ' ': > > id = id[0:len(id) - 1] > > except: > > pass > which is a nuisance. Is there a better way to do this? I have tried > id.strip() with no luck. What do? > TIA, > Victor -- Luis Zarrabeitia (aka Kyrie) Fac. de Matem?tica y Computaci?n, UH. http://profesores.matcom.uh.cu/~kyrie From bijeshn at gmail.com Mon Apr 7 06:13:06 2008 From: bijeshn at gmail.com (bijeshn) Date: Mon, 7 Apr 2008 03:13:06 -0700 (PDT) Subject: splitting an XML file on the basis on basis of XML tags References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> <47F9B845.9040205@behnel.de> Message-ID: > > What do you mean by "written down to a separate file"? Do you have a specific > format in mind? > sorry, it should be extracted into separate "files". i.e. if i have an XML file containing 10 million records, i need to split the file to 100 files containing 100,000 records each. i hope this is clearer... From banibrata.dutta at gmail.com Sun Apr 20 09:32:36 2008 From: banibrata.dutta at gmail.com (Banibrata Dutta) Date: Sun, 20 Apr 2008 19:02:36 +0530 Subject: Any reliable obfurscator for Python 2.5 In-Reply-To: References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> Message-ID: <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> On 4/20/08, Gabriel Genellina wrote: > > En Sun, 20 Apr 2008 01:55:51 -0300, Banibrata Dutta < > banibrata.dutta at gmail.com> escribi?: > > > Wanted to check if there is any known, reliable, FOSS/Libre -- > Obfurscator > > for Python 2.5 code. > > Why do you want to do that in the first place? I need to do to retain the confidentiality for certain core components, which are not supposed to be open. While I do have the option of implementing them in C/C++, I'm trying to see if I can avoid that for 2 reasons -- 1. Its a fairly large and complex set of components, and doing it in C/C++ 'might' take significantly longer. 2. I'd try to avoid having mix of languages if possible. It makes the developement easier to maintain/manage over a period of time. There is very few you can do to obfuscate Python code. You can't rename > classes nor methods nor global variables nor argument names due to the > dynamic nature of Python. All you can safely do is to remove comments and > join simple statements using ; I do not understand the nuances of dynamic languages completely, so this might be a foolish assumption, but if i make a complete, self-contained Python application (collection of modules), then just before shipping a production copy, why can't I replace 'all' symbols i.e. classes, methods, variables etc ? Esply if I'm compiling the source ? If you remove docstrings, some things may break. Even renaming local > variables isn't safe in all cases. Hmmm... but I'm aware of atleast 2 Obfuscators one commercial and one FOSS, that seem to exist for Python. The commercial one is what I might try if I don't find anything FOSS. The FOSS one seems to be a dead project. If they are (or have been) there, I guess obfuscation is a doable thing, no ? cheers, B -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -- regards, Banibrata http://www.linkedin.com/in/bdutta -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at holdenweb.com Tue Apr 8 10:11:07 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 10:11:07 -0400 Subject: Reproducing a web page and add own content to it. In-Reply-To: <1cddd2af-28be-42ee-8004-0d76978aeaa9@b9g2000prh.googlegroups.com> References: <6615blF2ifaqcU1@mid.uni-berlin.de> <1cddd2af-28be-42ee-8004-0d76978aeaa9@b9g2000prh.googlegroups.com> Message-ID: LaundroMat wrote: > On Apr 8, 2:04 pm, "Diez B. Roggisch" wrote: >> LaundroMat wrote: >>> Hi - >>> I'm working on a Django powered site where one of the required >>> functionalities is the possibility of displaying the content of >>> external pages, with an extra banner at the top where specific >>> information is displayed. In other words, I'm looking for a way to >>> reproduce an existing web page and add some HTML code to it. (I can't >>> think of an example right now, but the idea is similar to sites that >>> let you see an external page and have some site-specific text above it >>> (often stating that the content below is not part of the site the user >>> comes from)). >>> To test this, I've been downloading an external page, adding some text >>> to it and re-opening it in a browser (with the help of built-in >>> modules such as urllib2 etc). This works of course, but the external >>> page's links such as , or
>>> are evidently no longer correct. >>> Apart from parsing the whole file and trying to inject the external >>> site's domain in links such as the above (with the added inconvenience >>> of having to store the external page locally), is there an easier way >>> of accomplishing what I want? >> Using a frame? >> >> Diez > > Ack. I was too focused on importing the external web page and > redisplaying the information (I've just been reading up on > BeautifulSoup) instead of looking for an HTML based approach. > > Thanks! You could also look at adding a tag to your generated page's section. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From n00m at narod.ru Sat Apr 26 19:28:56 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 16:28:56 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> Message-ID: <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> No so simple, guys. E.g., I can't solve (in Python) this: http://www.spoj.pl/problems/INTEST/ Keep getting TLE (time limit exceeded). Any ideas? After all, it's weekend. 450. Enormous Input Test Problem code: INTEST The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime. Input The input begins with two positive integers n k (n, k<=107). The next n lines of input contain one positive integer ti, not greater than 109, each. Output Write a single integer to output, denoting how many integers ti are divisible by k. Example Input: 7 3 1 51 966369 7 9 999996 11 Output: 4 From ndbecker2 at gmail.com Fri Apr 25 09:37:07 2008 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 25 Apr 2008 09:37:07 -0400 Subject: problem with mmap Message-ID: On linux, I don't understand why: f = open ('/dev/eos', 'rw') m = mmap.mmap(f.fileno(), 1000000, prot=mmap.PROT_READ|mmap.PROT_WRITE, flags=mmap.MAP_SHARED) gives 'permission denied', but this c++ code works: #include #include #include #include #include int main() { int fd = open ("/dev/eos", O_RDWR); void* m = mmap (NULL, 1000000, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); std::cout << m << '\n'; } From ronnbus at gmail.com Mon Apr 7 10:47:15 2008 From: ronnbus at gmail.com (Ronn Ross) Date: Mon, 7 Apr 2008 10:47:15 -0400 Subject: Welcome to the "Python-list" mailing list In-Reply-To: References: Message-ID: This is my first post and I'm new to Python. How would someone go about adding keywords to Python? It would be great to add support for Esperanto keywords in the language instead of English being the only option. thx -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at craig-wood.com Mon Apr 28 05:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Mon, 28 Apr 2008 04:30:03 -0500 Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> Message-ID: s0suk3 at gmail.com wrote: > I wanted to ask for standard ways to receive data from a socket stream > (with socket.socket.recv()). It's simple when you know the amount of > data that you're going to receive, or when you'll receive data until > the remote peer closes the connection. But I'm not sure which is the > best way to receive a message with undetermined length from a stream > in a connection that you expect to remain open. Until now, I've been > doing this little trick: > > data = client.recv(256) > new = data > while len(new) == 256: > new = client.recv(256) > data += new > > That works well in most cases. But it's obviously error-prone. What if > the client sent *exactly* two hundred and fifty six bytes? It would > keep waiting for data inside the loop. Is there really a better and > standard way, or is this as best as it gets? What you are missing is that if the recv ever returns no bytes at all then the other end has closed the connection. So something like this is the correct thing to write :- data = "" while True: new = client.recv(256) if not new: break data += new >From the man page for recv RETURN VALUE These calls return the number of bytes received, or -1 if an error occurred. The return value will be 0 when the peer has performed an orderly shutdown. In the -1 case python will raise a socket.error. -- Nick Craig-Wood -- http://www.craig-wood.com/nick From casey.mcginty at gmail.com Tue Apr 22 06:12:40 2008 From: casey.mcginty at gmail.com (Casey McGinty) Date: Tue, 22 Apr 2008 00:12:40 -1000 Subject: Getting PyUnit to run Package Test Modules Message-ID: Hopefully this is an easy question for someone to answer. I have a directory structure like so: alltest.py prog.py ../package __init__.py mod1.py test_mod1.py modn. py (and so on...) Each test_mod*.py file contains some PyUnit test cases. I am using the following code in alltest.py to run all the unit test modules: mod_to_test = [package.mod1, package.mod2] def suite(): # create TestSuite object alltests = unittest.TestSuite() # load all modules define in the module list for module in map(__import__, mod_to_test): alltests.addTest(unittest.findTestCases(module)) return alltest if __name__ == '__main__': unittest.main(defaultTest='suite') My guess is there is something needed in __init__.py to get this work. Any advice? -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevin.p.dwyer at gmail.com Wed Apr 23 08:28:12 2008 From: kevin.p.dwyer at gmail.com (kdwyer) Date: Wed, 23 Apr 2008 05:28:12 -0700 (PDT) Subject: problem with dictionaries References: <480f29f8$0$11374$426a74cc@news.free.fr> Message-ID: On Apr 23, 1:22 pm, Bruno Desthuilliers wrote: > kdwyer a ?crit :> On Apr 23, 12:16 pm, Simon Strobl wrote: > (snip) > >> #!/usr/bin/python > > >> import sys > > >> frqlist = open('my_frqlist.txt', 'r') > (snip) > >> frq = {} > > >> for line in frqlist: > >> line = line.rstrip() > >> frequency, word = line.split('|') > >> frq[word] = int(frequency) > > (snip) > > > It works for me, save that you need to read the file into a list first > > You don't, unless you're using an old python versions (I'd say 2.3 or > older). Files are now their own iterators. *Fiddles with the interpreter for a moment* So they are - I'd quite forgotten about that - thanks for the reminder! K From lists at cheimes.de Sun Apr 20 13:43:17 2008 From: lists at cheimes.de (Christian Heimes) Date: Sun, 20 Apr 2008 19:43:17 +0200 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> Message-ID: <480B80B5.1050500@cheimes.de> Gabriel Genellina schrieb: > Apart from what everyone has already said, consider that FreqDist may import other modules, store global state, create other objects... whatever. > Pure python code should not have any memory leaks (if there are, it's a bug in the Python interpreter). Not-carefully-written C extensions may introduce memory problems. Pure Python code can cause memory leaks. No, that's not a bug in the interpreter but the fault of the developer. For example code that messes around with stack frames and exception object can cause nasty reference leaks. Christian From lycka at carmen.se Mon Apr 21 06:54:46 2008 From: lycka at carmen.se (Magnus Lycka) Date: Mon, 21 Apr 2008 12:54:46 +0200 Subject: Python and Db In-Reply-To: References: <5dc598e30803311050k5e8352e4g85380fb67cce5ac2@mail.gmail.com> <5dc598e30803311350o79b691bfn27330a9595bbfe53@mail.gmail.com> Message-ID: > escribi?: > >> I would like to use sqlite, But I also wanted a tutorial with the >> basis of the sql and etc, I never dealed with dbs before For practicing SQL on-line, I'd suggest sqlzoo.net. From bbxx789_05ss at yahoo.com Sat Apr 5 14:02:42 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sat, 5 Apr 2008 11:02:42 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <7113d012-01bb-4426-bb40-9e2811cdb102@x41g2000hsb.googlegroups.com> <3cf4bbc8-b828-45c5-b9a8-766ce600af43@y21g2000hsf.googlegroups.com> Message-ID: On Apr 5, 12:02?am, skanem... at yahoo.se wrote: > am i not doing that then? did u look at the code? where do i add the > bind if this: > btnDisplay = Button(self, text="1", command=self.Display) > ? ? ? ? btnDisplay.grid(row=3, column=0, padx=5, pady=5) > > is not enough? > > def Display(self, event_obj): > ? ? ? ? button = event_obj.widget > ? ? ? ? text = button.cget("text") > > ? ? ? ? if text=="1": > ? ? ? ? ? ? print 1 > > i get this exception so i need to pass another argument? im passing 2 > no? > 1) Post the line in your code that passes two arguments to Display. 2) Post the line in yoru code where you call Display. "call" means "execute", and '()' is used after a function name to execute the function. From kareta at web.de Fri Apr 18 06:14:29 2008 From: kareta at web.de (Juergen Kareta) Date: Fri, 18 Apr 2008 12:14:29 +0200 Subject: py3k s***s In-Reply-To: <66q33cF2krjf2U1@mid.uni-berlin.de> References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <66q33cF2krjf2U1@mid.uni-berlin.de> Message-ID: <66ra7oF2kjovcU1@mid.individual.net> Diez B. Roggisch schrieb: >> And I have been benefiting from Python in general, so far. Thanks, >> community. >> >> But now... I'll probably stop posting here for now, & I may stop other >> things too. >> >> Just my 2c. > > You know what I was just wondering about? All these C-written > cross-platform libraries (which Python users benefit from, most probably > including evven you) that run on different unixes & windows, which are a > much greater diversity to handle than the not-even-yet-settled > differences between Py3K & 2.x. How the heck do they do that? > > Oh, and these dreaded 64 bit processors, possibly with multi-cores, > which need changes in code as well, to be utilized to their power. > > But then, these guys most probably don't whine about diversity and > constant change, and cry out useless threats to people who probably > can't care less. > > Fare well, if you must. But getting mad over something which impact you > can't even judge right now is childish. Nothing else. > > Diez 1+ From jgardner at jonathangardner.net Thu Apr 17 13:11:27 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Thu, 17 Apr 2008 10:11:27 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> Message-ID: <6f853c25-25ea-487d-861e-c0775af60df3@s50g2000hsb.googlegroups.com> On Apr 17, 6:40 am, Steve Holden wrote: > I'd love to be wrong about that, but the GIL *has* been the subject of > extensive efforts to kill it over the last five years, and it has > survived despite the best efforts of the developers. > To add to that... In my mind, I see three options for multi-process systems: (1) Locks. (2) A global lock (GIL) (3) Learning to live with the possibility of things disappearing out from under you. In the SQL world, they chose (3). In the Java/C++/C# world, they chose (1). I like Python's compromise a lot, even though it means in a single process, you can only have one thread doing Python at a time. Usually the bits I want to parallelize on are blocking system calls to the network or disk anyway, or the result of a long calculation that updates its result all at once. So having the OS handle the tough bits while I program in a fantasy world where threads are an illusion is fine with me. Discovering a way to get rid of the GIL and not have to do (1) and (3) is truly exciting, but I've lost hope a long time ago. Besides, if it gets in the way I can always do something novel like, I don't know, spawn another Python process? From edreamleo at charter.net Sun Apr 6 13:10:31 2008 From: edreamleo at charter.net (Edward K Ream) Date: Sun, 6 Apr 2008 12:10:31 -0500 Subject: ANN: Leo 4.4.8 final Message-ID: Leo 4.4.8 final is now available at: http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106 This version features a new ipython plugin that provides a two-way bridge between Leo and IPython. See http://webpages.charter.net/edreamleo/IPythonBridge.html Leo is a text editor, data organizer, project manager and much more. See: http://webpages.charter.net/edreamleo/intro.html The highlights of Leo 4.4.8: ---------------------------- - Leo's source code is now managed by bzr: see link below. - Leo's discussion is now hosted by Google Groups: see link below. - Arguments to g.es and g.es_print can be translated using gettext. - Completed ILeo: a bridge between IPython and Leo. See http://webpages.charter.net/edreamleo/IPythonBridge.html - Minibuffer commands may have arguments. - @menu trees can now refer to commands created by @command and @button nodes. - Added support for common @commands nodes in settings files. Links: ------ Leo: http://webpages.charter.net/edreamleo/front.html Forum: http://groups.google.com/group/leo-editor Download: http://sourceforge.net/project/showfiles.php?group_id=3458 Bzr: http://code.launchpad.net/leo-editor/ Quotes: http://webpages.charter.net/edreamleo/testimonials.html -------------------------------------------------------------------- Edward K. Ream email: edreamleo at yahoo.com Leo: http://webpages.charter.net/edreamleo/front.html -------------------------------------------------------------------- From deets at nospam.web.de Tue Apr 22 08:32:06 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 14:32:06 +0200 Subject: Does Python 2.5 include or not include SQLite engine? In-Reply-To: References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> Message-ID: <67646qF2mqc8pU1@mid.uni-berlin.de> Dennis Lee Bieber schrieb: > On Mon, 21 Apr 2008 19:05:46 -0400, python at bdurham.com declaimed the > following in comp.lang.python: > >> I thought one of the major features of Python 2.5 was its embedded >> SQLite engine. >> > No, just the inclusion of the adapter became standard... The > packagers of Windows installers include the SQLite3 DLL as it isn't a > commonly available item... But many Linux versions probably include it > as an option during the OS install. AFAIK thats wrong. On my ubuntu gutsy for example, I find this: deets at absinth:~$ find /usr/lib/python2.5/ | grep -i sqlite /usr/lib/python2.5/lib-dynload/_sqlite3.so /usr/lib/python2.5/site-packages/pysqlite-2.3.2.egg-info /usr/lib/python2.5/site-packages/pysqlite2 /usr/lib/python2.5/site-packages/pysqlite2/__init__.py /usr/lib/python2.5/site-packages/pysqlite2/__init__.pyc /usr/lib/python2.5/site-packages/pysqlite2/_sqlite.so /usr/lib/python2.5/site-packages/pysqlite2/dbapi2.py /usr/lib/python2.5/site-packages/pysqlite2/dbapi2.pyc /usr/lib/python2.5/sqlite3 /usr/lib/python2.5/sqlite3/__init__.py ... As you can see, stock 2.5 ships with its OWN version of sqlite, and I additionally installed the pysqlite-wrapper for whatever reason I now can't remember. Diez From wizzardx at gmail.com Sun Apr 27 15:09:42 2008 From: wizzardx at gmail.com (David) Date: Sun, 27 Apr 2008 21:09:42 +0200 Subject: design choice: multi-threaded / asynchronous wxpython client? In-Reply-To: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: <18c1e6480804271209j676aa3adnf67e31f10d9007c1@mail.gmail.com> > 3) I need to dump this data (for all races, not just current about to > start race) to text files, store it as BLOBs in a DB *and* update real > time display in a wxpython windowed client. A few important questions: 1) How real-time must the display be? (should update immediately after you get new XML data, or is it ok to update a few seconds later?). 2) How much data is being processed at peak? (100 records a second, 1000?) 3) Does your app need to share fetched data with other apps? If so, how? (read from db, download HTML, RPC, etc). 4) Does your app need to use data from previous executions? (eg: if you restart it, does it need to have a fully populated UI, or can it start from an empty UI and start updating as it downloads new XML updates). How you answer the above questionss determines what kind of algorithm will work best. David. PS: I suggest that you contact the people you're downloading the XML from if you haven't already. eg: it might be against their TOS to constantly scrape data (I assume not, since they provide XML). You don't want them to black-list your IP address ;-). Also, maybe they have ideas for efficient data retrieval (eg: RSS feeds). From rpdooling at gmail.com Sat Apr 5 21:48:27 2008 From: rpdooling at gmail.com (Rick Dooling) Date: Sat, 5 Apr 2008 18:48:27 -0700 (PDT) Subject: Recursively Backup Directories References: Message-ID: On Apr 5, 6:56 pm, misceveryth... at gmail.com wrote: > What I would like to do > is recursively backup the specified directories . . . > but be able to specify exclusion directories (which copytree does > not appear to allow you to do). My initial thoughts were I'll > probably have to use os.path.walk for the backup source directory, but > I'm not sure how to go from there. Thanks in advance. There's a nice Python Cookbook recipe. http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/191017 I think the one in the book is newer and better http://tinyurl.com/5vr4n6 And the Cookbook is my favorite way to learn Python. rd From ragia11 at hotmail.com Thu Apr 17 03:09:44 2008 From: ragia11 at hotmail.com (ragia) Date: Thu, 17 Apr 2008 00:09:44 -0700 (PDT) Subject: regular expressions an text string Message-ID: <359c5f43-9520-4f33-b49e-45b5256f7169@a22g2000hsc.googlegroups.com> hi i have to match text string char by char to a regular expressions tht just allow digits 0-9 if other thing a ppear it shall be replaced with space.how can i do that any help? so far i have the string and can read it using a for loop...but how to match each char with the regular expressions and save the result into other string or replace it with space in that other string to have new one.. I a new in python ,thatnks in advance From meisnernel73884 at gmail.com Wed Apr 30 06:38:00 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:38:00 -0700 (PDT) Subject: vws crack Message-ID: <9b43198a-3554-443c-9853-30e3e0c81ceb@m36g2000hse.googlegroups.com> vws crack http://crack.cracksofts.com From bvidinli at gmail.com Fri Apr 18 05:45:03 2008 From: bvidinli at gmail.com (bvidinli) Date: Fri, 18 Apr 2008 12:45:03 +0300 Subject: Fwd: is file open in system ? - other than lsof In-Reply-To: References: <66p6o2F2korm2U1@mid.individual.net> Message-ID: <36e8a7020804180245k68d4d5b3y8901bed3e82cba01@mail.gmail.com> the idea of eg does not work for me because, what i do: get list of files, check 1st file open ? process 1st file, (this may take several seconds... ) check 2nd file open? i have to check it here, because 2nd file may be opened while i process file 1 process 2nd file, (this may take several seconds... ) and so on.. .... in this case, having list of open files at begining of processes is useless... anyway thanks. ---------- Forwarded message ---------- From: Nick Craig-Wood Date: 17.Nis.2008 19:30 Subject: Re: is file open in system ? - other than lsof To: python-list at python.org Thomas Guettler wrote: > bvidinli schrieb: > > is there a way to find out if file open in system ? - > > please write if you know a way other than lsof. because lsof if slow for me. > > i need a faster way. > > i deal with thousands of files... so, i need a faster / python way for this. > > thanks. > > On Linux there are symlinks from /proc/PID/fd to the open > files. You could use this: > > #!/usr/bin/env python > import os > pids=os.listdir('/proc') > for pid in sorted(pids): > try: > int(pid) > except ValueError: > continue > fd_dir=os.path.join('/proc', pid, 'fd') > for file in os.listdir(fd_dir): > try: > link=os.readlink(os.path.join(fd_dir, file)) > except OSError: > continue > print pid, link Unfortunately I think that is pretty much exactly what lsof does so is unlikely to be any faster! However if you have 1000s of files to check you only need to do the above scan once and build a dict with all open files in whereas lsof will do it once per call so that may be a useful speedup. Eg ------------------------------------------------------------ import os pids=os.listdir('/proc') open_files = {} for pid in sorted(pids): try: int(pid) except ValueError: continue fd_dir=os.path.join('/proc', pid, 'fd') try: fds = os.listdir(fd_dir) except OSError: continue for file in fds: try: link=os.readlink(os.path.join(fd_dir, file)) except OSError: continue if not os.path.exists(link): continue open_files.setdefault(link, []).append(pid) for link in sorted(open_files.keys()): print "%s : %s" % (link, ", ".join(map(str, open_files[link]))) ------------------------------------------------------------ You might want to consider http://pyinotify.sourceforge.net/ depending on exactly what you are doing... -- Nick Craig-Wood -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From hopeorpha308 at gmail.com Sun Apr 27 07:43:38 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:43:38 -0700 (PDT) Subject: bookworm crack Message-ID: <241f0e70-2e37-4036-9bc1-900ae1b5d5aa@w74g2000hsh.googlegroups.com> bookworm crack http://wga-cracks.crackkey.net From fennelllindy8241 at gmail.com Mon Apr 28 03:23:45 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:23:45 -0700 (PDT) Subject: call od duty 4 crack download Message-ID: <239f06f8-3a78-4fe9-b33f-75e568c8b279@f24g2000prh.googlegroups.com> call od duty 4 crack download http://crack.cracksofts.com From pavlovevidence at gmail.com Sat Apr 26 11:43:19 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Sat, 26 Apr 2008 08:43:19 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> Message-ID: <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> On Apr 26, 11:10 am, n00m wrote: > Both codes below read the same huge(~35MB) text file. > In the file > 1000000 lines, the length of each line < 99 chars. > > Stable result: > Python runs ~0.65s > C : ~0.70s > > Any thoughts? Yes. Most of the dirty work in the Python example is spent in tight loop written in C. This is very likely to be faster on Python on Windows than your "C" example for several reasons: 1. Python is compiled with Microsoft's C compiler, which produces more optimal code than Mingw. 2. The Python readline() function has been in the library for a long time and has had time for many developers to optimize it's performance. 3. Your "pure C" code isn't even C, let alone pure C. It's C++. On most systems, the C++ iostream libraries have a lot more overhead than C's stdio. And, finally, we must not fail to observe that you measured these times without startup, which is obviousy much greater for Python. (Of course, we only need to point this so it's not misunderstood that you're claiming this Python process will terminate faster than the C++ one.) So, I must regrettably opine that your example isn't very meaningful. > import time > t=time.time() > f=open('D:\\some.txt','r') > z=f.readlines() > f.close() > print len(z) > print time.time()-t > m=input() > print z[m] > > #include > #include > #include > #include > > using namespace std; > char vs[1002000][99]; > FILE *fp=fopen("D:\\some.txt","r"); > > int main() { > int i=0; > while (true) { > if (!fgets(vs[i],999,fp)) break; > ++i; > } > fclose(fp); > cout << i << endl; > cout << clock()/CLOCKS_PER_SEC << endl; > > int m; > cin >> m; > cout << vs[m]; > system("pause"); > return 0; > > } From george.sakkis at gmail.com Wed Apr 2 10:31:15 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 2 Apr 2008 07:31:15 -0700 (PDT) Subject: Self-referencing decorator function parameters References: <88b2c61e-8cf1-4ac0-a5d4-c968d009b544@c65g2000hsa.googlegroups.com> Message-ID: <232b144b-9e09-4baf-9e87-88b6a1d1fb07@b5g2000pri.googlegroups.com> On Apr 2, 8:30?am, Thomas Dimson wrote: > Hello, > > Originally I posted this as a bug but it was shot down pretty quickly. > I am still mildly curious about this as I'm missing a bit of > understanding of Python here. Why is it that the following code > snippet: > > def decorator( call ): > ? ? def inner(func): > ? ? ? ? def application( *args, **kwargs ): > ? ? ? ? ? ? call(*args,**kwargs) > ? ? ? ? ? ? func(*args,**kwargs) > ? ? ? ? return application > > ? ? return inner > > class DecorateMe: > ? ? @decorator( call=DecorateMe.callMe ) > ? ? def youBet( self ): > ? ? ? ? pass > > ? ? def callMe( self ): > ? ? ? ? print "Hello!" > > DecorateMe().youBet() > > Will not compile, giving: > Traceback (most recent call last): > ? File "badpython.py", line 10, in > ? ? class DecorateMe: > ? File "badpython.py", line 11, in DecorateMe > ? ? @decorator( call=DecorateMe.callMe ) > NameError: name 'DecorateMe' is not defined > > Where if you change the "call=DecorateMe.callMe" to "call=lambda x: > DecorateMe.callMe(x)" everything goes along its merry way. Nesting the > call in a lambda seems to allow it to recognize the class definition. > Any ideas as to what is going on here (other than ugly code)? The error message is pretty obvious; when the "@decorator(call=DecorateMe.callMe)" line is reached, the DecorateMe class has not been created yet, let alone the DecorateMe.callMe method. One way to make it work (for some definition of "work" ;-) is the following: # use "new-style" classes unless you have a good reason not to: # class DecorateMe(object): class DecorateMe: def callMe(self): print "Hello!" @decorator(call=callMe) def youBet(self): pass The reason this works is that at the point where @decorator is executed, callMe is already in the temporary namespace to be used for creating the DecorateMe class (although the class itself is not built yet). A subtle point is that in this case callMe is a plain function, not an (unbound) method such as DecorateMe.callMe. This may or may not matter, depending on what you do with it in the decorator. Some decorators that work fine with plain functions break if they are used to decorate methods (or vice versa) so it's good to have this in mind when writing or debugging a decorator. George From eatham at gmail.com Fri Apr 11 16:42:22 2008 From: eatham at gmail.com (Roger Dahlstrom) Date: Fri, 11 Apr 2008 13:42:22 -0700 (PDT) Subject: Windows - window status (Running vs Not Responding) References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> Message-ID: <6a7ddeb2-78ce-4409-8894-cdf72fc2ac51@m73g2000hsh.googlegroups.com> On Apr 11, 3:46 pm, Tim Golden wrote: > rdahlstrom wrote: > > On Apr 11, 1:45 pm, rdahlstrom wrote: > >> Does anyone know how to determine the window status (Running or Not > >> Responding)? I've tried various methods with no success... > > >> This would be on a variety of Windows systems, but all at least XP, > >> and mostly server 2003. Everyone will have Python 2.5.1 on them, and > >> the script would be running locally. > > >> Any ideas? > > > Basically, I'm looking for something similar to the Process.Responding > > property in System.Diagnostics... > > Well one (slightly drastic) possibility might be to use IronPython [1] > or Python.NET [2] to invoke the .Net functionality directly. AFAIK there > is no direct alternative: I believe that WMI can be a useful match > for System.Diagnostics but doesn't deal with windows (ie user-interface > elements). Presumably you could find a top-level window for each > process, using something vaguely like this [3] coupled with this [4] > and send it a suitable SendMessage to "ping" it. Haven't done it myself > but can't see why it shouldn't work. > > All a bit handwavey but maybe it'll point you somewhere... > > TJG > > [1]http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython > [2]http://pythonnet.sourceforge.net/ > [3]http://timgolden.me.uk/python/wmi_cookbook.html#running_processes > [4]http://timgolden.me.uk/python/win32_how_do_i/find-the-window-for-my-s... I had actually contemplated using ctypes and linking the .dll directly, but even though I'm running 32 bit Python, some of the machines that I want to run this on are 64 bit windows, so it doesn't work. If I get desperate, I'll check out IronPython, but I'd really like to stay (as much as possible) with our standard package (2.5.1 with wmi/win32) From Shawn at Milochik.com Fri Apr 18 11:23:08 2008 From: Shawn at Milochik.com (Shawn Milochik) Date: Fri, 18 Apr 2008 11:23:08 -0400 Subject: Checking for unique fields: performance. Message-ID: <2dc0c81b0804180823k46a220f1w77a166e6b08f67de@mail.gmail.com> I'm looping through a tab-delimited file to gather statistics on fill rates, lengths, and uniqueness. For the uniqueness, I made a dictionary with keys which correspond to the field names. The values were originally lists, where I would store values found in that field. Once I detected a duplicate, I deleted the entire element from the dictionary. Any which remained by the end are considered unique. Also, if the value was empty, the dictionary element was deleted and that field considered not unique. A friend of mine suggested changing that dictionary of lists into a dictionary of dictionaries, for performance reasons. As it turns out, the speed increase was ridiculous -- a file which took 42 minutes to run dropped down to six seconds. Here is the excerpt of the bit of code which checks for uniqueness. It's fully functional, so I'm just looking for any suggestions for improving it or any comments. Note that fieldNames is a list containing all column headers. #check for unique values #if we are still tracking that field (we haven't yet #found a duplicate value). if fieldUnique.has_key(fieldNames[index]): #if the current value is a duplicate if fieldUnique[fieldNames[index]].has_key(value): #sys.stderr.write("Field %s is not unique. Found a duplicate value after checking %d values.\n" % (fieldNames[index], lineNum)) #drop the whole hash element fieldUnique.__delitem__(fieldNames[index]) else: #add the new value to the list fieldUnique[fieldNames[index]][value] = 1 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dikkie at nospam.org Thu Apr 17 06:12:17 2008 From: dikkie at nospam.org (Dikkie Dik) Date: Thu, 17 Apr 2008 12:12:17 +0200 Subject: about a head line In-Reply-To: References: Message-ID: <48072281$0$30667$bf4948fe@news.tele2.nl> Penny Y. wrote: > I saw some scripts have a line at its begin: > > # encoding:gb2312 > > what's this? Why need it? thanks. > My guess is that it is the automatic work of some sort of editor that does not understand how encodings work. See what happens if the file was utf-16le encoded, for example. I think you can safely remove it. From sturlamolden at yahoo.no Sat Apr 19 20:33:42 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sat, 19 Apr 2008 17:33:42 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <48074f58$0$4916$e4fe514c@dreader32.news.xs4all.nl> <6002cb46-f48a-421d-a4ff-5b23bf2f9d77@2g2000hsn.googlegroups.com> <39fd7905-4835-43bb-928b-82622ed628c1@m3g2000hsc.googlegroups.com> Message-ID: On Apr 19, 10:29 pm, "sjdevn... at yahoo.com" wrote: > FWIW, NT's POSIX subsytem fork() uses (or used to use) the NULL > SectionHandle method and was POSIX certified, so it's certainly > possible. Windows Vista Ultimate comes with Interix integrated, renamed 'Subsystem for Unix based Applications' or SUA for short. Interix is even UNIX certified when a C compiler is installed. Windows also has a OS/2 subsystem which has a COW fork. Yes it is possible. One may wonder why the Win32 subsystem don't have this feature. Perhaps fork() is unfriendly to threads, like fork on Linux used to be (or is?) pthread unfriendly. Or perhaps M$ (MegaDollar) just did this to be mean. I don't know. I see the lack of fork() in Win32 as one of the major shortcomings of Windows. Anyhow, I just downloaded the WDK which supersedes the DDK. The examples in Nebbet's book do not build anymore, as there are invalid C in the WDK header files. :-( From mail2spj at yahoo.com Fri Apr 18 16:09:20 2008 From: mail2spj at yahoo.com (SPJ) Date: Fri, 18 Apr 2008 13:09:20 -0700 (PDT) Subject: No subject Message-ID: <581282.70773.qm@web50110.mail.re2.yahoo.com> I am writing a script which need's to convert an excel file to csv (text) format. For that I am using the following code: excel = win32com.client.Dispatch("Excel.Application","Quit") workbook = excel.Workbooks.Open(xlsfile) workbook.SaveAs(csvfile, FileFormat=24) # 24 represents xlCSVMSDOS workbook.Close(False) excel.Quit() I did not have any problem running this script on a windows xp machine with python 2.5.2 and windows extensions. But I get the following error when I run the same script on a windows 2003 server with the same python and windows extension installation: excel = win32com.client.Dispatch("Excel.Application","Quit") File "D:\Python25\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "D:\Python25\lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "D:\Python25\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147221005, 'Invalid class string', None, None) I verified that installation is same. Any idea's as to what might be the problem? One thing I have noticed though is I can't see Microsoft office 11.0 object library when I do combrowse on windows 2003 server. I also to tried to reinstall python and windows extension. But still no luck. I would appreciate if anyone can guide me as to why this is happening and how to resolve this. Thanks, SPJ ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ From jcd at unc.edu Fri Apr 18 11:48:38 2008 From: jcd at unc.edu (J. Cliff Dyer) Date: Fri, 18 Apr 2008 11:48:38 -0400 Subject: Another MySQL Images Question In-Reply-To: <4dc0cfea0804180813o32ed2c82o9c3f68b1a607348d@mail.gmail.com> References: <4dc0cfea0804180813o32ed2c82o9c3f68b1a607348d@mail.gmail.com> Message-ID: <1208533718.4748.16.camel@aalcdl07.lib.unc.edu> There are several problems with your SQL, but not all of them would be caught by the computer. Your SELECT statement is not parameterized. This is a security problem. *Always* parameterize your variables. Your UPDATE statement has an extraneous comma at the end, and it also has quotes around the "%s"es that you don't need, because you already parameterized that query. Your dbapi interface will provide appropriate quoting for whatever type of data you pass it. Cheers, Cliff On Fri, 2008-04-18 at 10:13 -0500, Victor Subervi wrote: > Hi; > If I grab an image in the database thus: > > sql = "select pic1 from products where id='" + str(id) + "';" > cursor.execute(sql) > pic1 = cursor.fetchall()[0][0].tostring() > # pic1 = cursor.fetchall()[0][0] // either this or the above > line > > and try and re-insert it thus: > > cursor.execute('update products set pic1="%s" where id="%s", ;', > (pic1, id)) > > it tells me I have an error in my MySQL syntax. What is the error? > TIA, > Victor -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill From steve at holdenweb.com Sat Apr 5 10:54:06 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 10:54:06 -0400 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> Message-ID: llothar wrote: [...] > Unfortunately there is no python.core mailing list that i know so i > ask here. > Well your researches can't have been that extensive: the developers live on python-dev at pythonlorg, otherwise known as comp.land.python-dev. But you will need to ask your question rather more carefully there to het a meaningful answer. Good luck. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From breily at gmail.com Mon Apr 14 03:43:34 2008 From: breily at gmail.com (Brian) Date: Mon, 14 Apr 2008 03:43:34 -0400 Subject: Java or C++? In-Reply-To: References: Message-ID: On Mon, Apr 14, 2008 at 3:24 AM, bdsatish wrote: > On Apr 14, 12:21 pm, Bob Martin wrote: > > in 342367 20080414 074410 s0s... at gmail.com wrote: > > > > >Hello, I was hoping to get some opinions on a subject. I've been > > >programming Python for almost two years now. Recently I learned Perl, > > >but frankly I'm not very comfortable with it. Now I want to move on > > >two either Java or C++, but I'm not sure which. Which one do you think > > >is a softer transition for a Python programmer? Which one do you think > > >will educate me the best? > > > > Certainly Java. It's also easier to find Java jobs than C++ jobs. > > -- > http://mail.python.org/mailman/listinfo/python-list > It may be easier to find Java jobs, but learning C++ will increase your understanding of computers a lot more than Java. Mainly in the area of memory management - C++ pointers really force you to understand whats going on below the surface. If you're not locked in to learning on those, I would suggest learning Lisp instead - it'll make you a better python programmer. -------------- next part -------------- An HTML attachment was scrubbed... URL: From cokofreedom at gmail.com Tue Apr 29 10:44:45 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Tue, 29 Apr 2008 07:44:45 -0700 (PDT) Subject: Issue with regular expressions References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> <5a75ea66-2cbb-4c41-8351-a35a70554d8d@i76g2000hsf.googlegroups.com> Message-ID: <9f2686cc-14ba-4a8e-b3a6-3cb98e3a5bba@m45g2000hsb.googlegroups.com> | # ---- Double Quote Text ---- | " # match a double quote | ( # - Two Possiblities: | \\. # match two backslashes followed by anything (include newline) | | # OR | [^"] # do not match a single quote | )* # - from zero to many | " # finally match a double quote | | | # ======== OR ======== | | # ---- Single Quote Text ---- | ' # match a single quote | ( # - Two Possiblities: | \\. # match two backslashes followed by anything (include newline) | | # OR | [^'] # do not match a single quote | )* # - from zero to many | ' # finally match a single quote | """, DOTALL|VERBOSE) Used this before (minus those | at the beginning) to find double quotes and single quotes in a file (there is more to this that looks for C++ and C style quotes but that isn't needed here), perhaps you can take it another step to not do changes to these matches? r""""(\\.|[^"])*"|'(\\.|[^'])*'""", DOTALL) is it in a single line :) From paul at subsignal.org Tue Apr 8 15:49:40 2008 From: paul at subsignal.org (paul) Date: Tue, 08 Apr 2008 21:49:40 +0200 Subject: Running a python code periodically In-Reply-To: References: Message-ID: Maryam Saeedi schrieb: > Hi, > > I was wondering if you know how can I run a python code once every five > minutes for a period of time either using python or some other program like > a bash script. See the sched module in the standard library or here: http://pypi.python.org/simple/Recur/ cheers Paul From sevenjp at gmail.com Wed Apr 2 16:54:33 2008 From: sevenjp at gmail.com (=?ISO-8859-1?Q?Jo=E3o_Neves?=) Date: Wed, 2 Apr 2008 13:54:33 -0700 (PDT) Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> <10ee2a69-f4e2-4887-8083-6b02b60dd0cd@i7g2000prf.googlegroups.com> Message-ID: On 2 Abr, 21:38, "Chris Mellon" wrote: > On Wed, Apr 2, 2008 at 2:33 PM, Jo?o Neves wrote: > > On Apr 2, 5:41 pm, "Dan Upton" wrote: > > > > The thing I've been wondering is why _is_ it read-only? In what > > > > circumstances having write access to co_code would break the language > > > > or do some other nasty stuff? > > > > > Jo?o Neves > > > > I can't speak to Python's implementation in particular, but > > > self-modifying code in general is unpleasant. It certainly is > > > possible to support it in runtime environments, but it's usually not > > > easy to do so. That is, of course, somewhat dependent on the > > > implementation of the runtime environment, and even to some degree the > > > underlying hardware. (For instance, the compiled code you want to run > > > could be in the hardware cache; if you then change the instructions at > > > those addresses in memory, it's not always straightforward to get the > > > processor to realize it needs to load the new data into the > > > instruction cache.) Plus, I suppose it might be possible to break > > > strong (even dynamic) typing if you start changing the code around > > > (although I can't construct an example off the top of my head). > > > Indeed, the caching issue is a relevant one I guess, and adding the > > mechanism to go around that might have a significant impact on > > performance. > > I haven't looked in detail into it, but I agree with your opinion > > concerning strong and dynamic typing. If type check is done while > > compiling to bytecode, there is no guarantee the modified bytecode > > will respect the rules, for instance. I don't know though, haven't > > really checked how it's done at this point. :) > > I will be fiddling around with the Python VM these days anyway, and > > since I'm going to muck around the bytecode, I might just try to see > > the effects of removing the read-only restriction from co_code. > > There is no need to overwrite co_code. Create a new code object with > your desired bytecode and use that instead. Yes, it may work (haven't tested - isn't there any problem with stuff like co_name, for instance?), but for simplicity's sake, wouldn't it be far more convenient if you could just write over co_code? :) In the end, it's all a matter of convenience, I guess. From bockman at virgilio.it Mon Apr 28 03:37:35 2008 From: bockman at virgilio.it (bockman at virgilio.it) Date: Mon, 28 Apr 2008 00:37:35 -0700 (PDT) Subject: error: (10035, 'The socket operation... References: Message-ID: <2b9b1aea-2fc2-49fb-b5ed-2ccdad718305@j22g2000hsf.googlegroups.com> On 28 Apr, 01:01, Don Hanlen wrote: > IDLE internal error in runcode() > Traceback (most recent call last): > ? File "C:\PYTHON25\lib\idlelib\rpc.py", line 235, in asyncqueue > ? ? self.putmessage((seq, request)) > ? File "C:\PYTHON25\lib\idlelib\rpc.py", line 332, in putmessage > ? ? n = self.sock.send(s[:BUFSIZE]) > error: (10035, 'The socket operation could not complete without > blocking') > > Does this look familiar to anyone? ?I can't figure out what to do > about it. ?Python 2.5, windoze. ?I get it when I execute a Tkinter op > that works elsewhere. > > changing this: > > t = self.b.create_text( > ? ? (point.baseX + 1)*self.checkerSize/2 + fudge, > ? ? y + fudge, > ? ? text = str(point.occupied), > ? ? width = self.checkerSize) > > to > > t = self.b.create_text( > ? ? (point.baseX + 1)*self.checkerSize/2 + fudge, > ? ? y + fudge, > ? ? text = str(point.occupied), > ? ? font=("Times", str(self.checkerSize/2), "bold"), > ? ? width = self.checkerSize) > > for example. ?The same code works fine elsewhere. ?I thought I'd ask > here before I try (no clue) increasing BUFSIZE in rpc.py? ?I'm not > crazy about tinkering with code I have no clue about.. > -- > don The error is EWOULDBLOCK, which you get when you configure a socket for asynchronous I/O and then try an operation which cannot be completed immediately. It is not an actual failure, it is part of the asynch socket handling issues: it means that you have to wait and try later. AFAIK (almost nothing) the Tkinter application has two processes (maybe the front-end and the interpreter) which communicate through a socket. From the traceback, I world say that the two processes communicate using RPC protocol and the rpclib module, and that this in turns uses the asyncqueue module, and one of them fails handling the EWOULDBLOCK code. I don't think that increasing BUFSIZE would solve the problem, since you will try to send more bytes in a single operation, and this would probably still result in an EWOULDBLOCK return code. Anyway, it looks like an IDLE problem, so if you can use another IDE ( Pythonwin? ), you could just ignore it, maybe submit a bug report ? Ciao ----- FB From ptmcg at austin.rr.com Sun Apr 6 12:25:35 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Sun, 6 Apr 2008 09:25:35 -0700 (PDT) Subject: Presumably an import is no faster or slower than opening a file? References: <47f8d30f$0$761$bed64819@news.gradwell.net> Message-ID: On Apr 6, 8:41?am, tinn... at isbd.co.uk wrote: > I'm trying to minimise the overheads of a small Python utility, I'm > not really too fussed about how fast it is but I would like to > minimise its loading effect on the system as it could be called lots > of times (and, no, I don't think there's an easy way of keeping it > running and using the same copy repeatedly). > > It needs a configuration file of some sort which I want to keep > separate from the code, is there thus anything to choose between a > configuration file that I read after:- > > ? ? f = open("configFile", 'r') > > ... and importing a configuration written as python dictionaries or > whatever:- > > ? ? import myConfig > > -- > Chris Green Chris - The question is less an issue of the file overhead (both must open a file, read its contents, and then close it) than what is done with the file contents afterwards. A config file containing .INI-style or whatever content will need to be parsed into Python data/objects, and likely use Python code to do so. An import will use the Python compiler itself, using optimized compiled C code to do the parsing and data/object construction. But I think you would only see the distinction in a config file of substantial size or complexity. If you think this will make a substantial difference in performance, then code up a test case and time it. In general, I'd say that splitting performance hairs to tip a design choice one way or another is a misguided premature optimization. -- Paul From andrew at acooke.org Thu Apr 17 08:25:33 2008 From: andrew at acooke.org (andrew cooke) Date: Thu, 17 Apr 2008 05:25:33 -0700 (PDT) Subject: Metaprogramming Example References: <930643c6-2d56-4fb0-aee0-a3e79231f09b@24g2000hsh.googlegroups.com> Message-ID: <32472b97-f35a-4408-96f5-2f8c8f92ae56@m73g2000hsh.googlegroups.com> On Apr 17, 7:12 am, "bruno.desthuilli... at gmail.com" wrote: [...] Thanks very much! These are useful pointers. I'll update my code accordingly. At one point you pointed out I didn't need parentheses and I agree - I was using them to avoid having a line continuation backslash (I think I read to do that in a style guide recently). One other question. I had "foo is False" and you said I need equality, which is a good point. However, in any other language "not foo" would be preferable. I was surprised you didn't suggest that (and I'm unsure now why I didn't write it that way myself). Is there some common Python standard that prefers "foo == False" to "not foo"? Thanks, Andrew PS Is there anywhere that explains why Decorators (in the context of functions/methods) are so good? I've read lots of things saying they are good, but no real justification of why. To me it looks more like "re-arranging deck chairs on the Titanic" - you're just moving where the hack happens from one place to another. Is the point that now the hack is more visible and hence modifiable? From shevitz at lanl.gov Wed Apr 30 10:23:12 2008 From: shevitz at lanl.gov (Danny Shevitz) Date: Wed, 30 Apr 2008 14:23:12 +0000 (UTC) Subject: how to convert a multiline string to an anonymous function? References: <67pmdnF2p5fhgU1@mid.uni-berlin.de> <87c29666-f64f-4f3c-97e1-a3d1dccdc49b@s50g2000hsb.googlegroups.com> <9a2dnc3tFZET9oXVnZ2dnUVZ_rqlnZ2d@pdx.net> Message-ID: Thanks All! you've solved my problem. D From ABH at MCHSI.COM Tue Apr 8 12:13:00 2008 From: ABH at MCHSI.COM (Hutch) Date: Tue, 08 Apr 2008 16:13:00 GMT Subject: Python 3.0 new integer division Message-ID: We now have a float result when two integers are divided in the same mannor as 2.4 or 2.5. I can handle that and use the Floor division but a simple question. Why in the world would you round down the last presented digit to a 6 instead of just leaving it along as an 8. For some reason rounding down for a float in Python does not seem correct. IDLE 3.0a4 >>> 12345678901234567890123456789012345678901234567890/345 3.5784576525317586e+46 >>> 12345678901234567890123456789012345678901234567890//345 35784576525317588087314367504383610663481839327 ^ ^| 35784576525317586000000000000000000000000000000 == 3.5784576525317586e+46 From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 3 06:51:08 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 03 Apr 2008 12:51:08 +0200 Subject: who said python can't be obsfucated!? In-Reply-To: References: Message-ID: <47f4b69b$0$19766$426a74cc@news.free.fr> cokofreedom at gmail.com a ?crit : > def s(c):return[]if c==[]else s([_ for _ in c[1:]if _ +s([_ for _ in c[1:]if _>=c[0]]) > > Anyone else got some wonders...? Nothing as bad, but: sig=lambda m:'@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in m.split('@')]) From http Sun Apr 6 13:09:17 2008 From: http (Paul Rubin) Date: 06 Apr 2008 10:09:17 -0700 Subject: Implementation of Crockford's Base32 Encoding? References: <345117e9-2539-4ee0-8b27-9b1a88ddde7c@a1g2000hsb.googlegroups.com> Message-ID: <7x63uukj0i.fsf@ruckus.brouhaha.com> "samslists at gmail.com" writes: > Anyone know of a Python implementation of this: http://www.crockford.com/wrmg/base32.html Is that different from the base32 encoding already in the base64 module? http://docs.python.org/lib/module-base64.html From bignose+hates-spam at benfinney.id.au Fri Apr 18 19:51:48 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Sat, 19 Apr 2008 09:51:48 +1000 Subject: How to print a unicode string? References: Message-ID: <87d4omsovf.fsf@benfinney.id.au> damonwischik at gmail.com writes: > From what I've googled, I think I need to set my locale. I don't > understand how. > > import locale > print locale.getlocale() > --> (None,None) > print locale.getdefaultlocal() > --> ('en_GB','cp1252') > print locale.normalize('en_GB.utf-8') > --> en_GB.UTF8 > locale.setlocale(locale.LC_ALL,'en_GB.UTF8') > --> locale.Error: unsupported locale setting > > I'd be grateful for advice. Just because the locale library knows the normalised name for it doesn't mean it's available on your OS. Have you confirmed that your OS (independent of Python) supports the locale you're trying to set? -- \ "Oh, I love your magazine. My favorite section is 'How To | `\ Increase Your Word Power'. That thing is really, really, | _o__) really... good." -- Homer, _The Simpsons_ | Ben Finney From woodham at cs.ubc.ca Wed Apr 23 14:08:16 2008 From: woodham at cs.ubc.ca (Bob Woodham) Date: Wed, 23 Apr 2008 18:08:16 +0000 (UTC) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> <426812d7-c217-4bfc-81b0-47ba0638a650@k13g2000hse.googlegroups.com> Message-ID: On 2008-04-22, Paul Hankin wrote: > On Apr 22, 5:50?pm, J?r?my Wagner wrote: >> Sure. Python is more readable than Perl, though I have found Python >> to have a weird behavior regarding this little issue : >> >> How can you explain that Python doesn't support the ++ opeator, >> whereas at the same time it does support the += operator ??? >> >> No python developer I know has been able to answer that. > > Because ++ is of limited use and has poor readability? > > 'x++' vs 'x += 1' saves 3 characters and is less readable. In addition, the statement x = x++; has unspecified behaviour in C. That is, it is not specified whether the value of x after execution of the statement is the old value of x or one plus the old value of x. From Robert.Bossy at jouy.inra.fr Mon Apr 14 08:48:47 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Mon, 14 Apr 2008 14:48:47 +0200 Subject: Process multiple files In-Reply-To: <2323A6D37908A847A7C32F1E3662C80E017BDF37@dc1ex01.air.org> References: <2323A6D37908A847A7C32F1E3662C80E017BDF37@dc1ex01.air.org> Message-ID: <480352AF.3080704@jouy.inra.fr> Doran, Harold wrote: > Say I have multiple text files in a single directory, for illustration > they are called "spam.txt" and "eggs.txt". All of these text files are > organized in exactly the same way. I have written a program that parses > each file one at a time. In other words, I need to run my program each > time I want to process one of these files. > > However, because I have hundreds of these files I would like to be able > to process them all in one fell swoop. The current program is something > like this: > > sample.py > new_file = open('filename.txt', 'w') > params = open('eggs.txt', 'r') > do all the python stuff here > new_file.close() > > If these files followed a naming convention such as 1.txt and 2.txt I > can easily see how these could be parsed consecutively in a loop. > However, they are not and so is it possible to modify this code such > that I can tell python to parse all .txt files in a certain directory > and then to save them as separate files? For instance, using the example > above, python would parse both spam.txt and eggs.txt and then save 2 > different files, say as spam_parsed.txt and eggs_parsed.txt. > Hi, It seems that you need glob.glob() : http://docs.python.org/lib/module-glob.html#l2h-2284 import glob for txt_filename in glob.glob('/path/to/the/dir/containing/your/files/*.txt'): print txt_filename # or do your stuff with txt_filename RB From sierra9162 at gmail.com Wed Apr 16 11:25:35 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:25:35 -0700 (PDT) Subject: kate hudson snl Message-ID: <67c10ec3-baf2-4598-a992-e8340796e763@d45g2000hsc.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From stefan_ml at behnel.de Mon Apr 7 02:03:24 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 07 Apr 2008 08:03:24 +0200 Subject: Parsing HTML? In-Reply-To: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> References: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> Message-ID: <47F9B92C.1030802@behnel.de> Benjamin wrote: > I'm trying to parse an HTML file. I want to retrieve all of the text > inside a certain tag that I find with XPath. The DOM seems to make > this available with the innerHTML element, but I haven't found a way > to do it in Python. import lxml.html as h tree = h.parse("somefile.html") text = tree.xpath("string( some/element[@condition] )") http://codespeak.net/lxml Stefan From paddy3118 at googlemail.com Thu Apr 17 14:19:03 2008 From: paddy3118 at googlemail.com (Paddy) Date: Thu, 17 Apr 2008 11:19:03 -0700 (PDT) Subject: How to make this unpickling/sorting demo faster? References: <40a5d8f1-a246-4c48-8759-5b65324f9029@m73g2000hsh.googlegroups.com> Message-ID: <493d67b3-ea8f-4662-86fc-c764a7d47a02@8g2000hse.googlegroups.com> On Apr 17, 6:15 pm, Steve Bergman wrote: > I'm involved in a discussion thread in which it has been stated that: > > """ > Anything written in a language that is > 20x slower (Perl, Python, > PHP) than C/C++ should be instantly rejected by users on those grounds > alone. > """ > THe above is applied slavishly by those who value machine time over peoples time. Do you want to work with them? - Paddy. From cokofreedom at gmail.com Thu Apr 10 08:07:15 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Thu, 10 Apr 2008 05:07:15 -0700 (PDT) Subject: How to find documentation about methods etc. for iterators References: <47fce941$0$755$bed64819@news.gradwell.net> <47fdceb8$0$754$bed64819@news.gradwell.net> Message-ID: > > This for me is Python's chief selling point: dir()....dir() and > help(). Python's two selling points are dir(), help(), and very > readable code. Python's *three* selling points are dir(), > help(), very readable code, and an almost fanatical devotion to > the BFDL. Amongst Python's selling points are such elements as > dir(), help()...I'll come in again.
> This brought a smile to my face :) From stefan_ml at behnel.de Tue Apr 22 07:34:39 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 22 Apr 2008 13:34:39 +0200 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> Message-ID: <480DCD4F.8090002@behnel.de> GD wrote: > Please remove ability to multiple inheritance in Python 3000. > > Multiple inheritance is bad for design, rarely used and contains many > problems for usual users. Ah, one more: "doctor, when I do this, it hurts!" - "then don't do that!" Stefan From bignose+hates-spam at benfinney.id.au Sat Apr 19 03:05:45 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Sat, 19 Apr 2008 17:05:45 +1000 Subject: Inheritance confusion References: <4809932c$0$12307$c3e8da3@news.astraweb.com> Message-ID: <8763uel3xy.fsf@benfinney.id.au> Hook writes: > I'm having a problem with multiple inheritance You aren't alone. Multiple inheritance (MI) is difficult to implement, and once implemented, usually difficult to understand and sometimes counterintuitive. I recommend you read and absorb the article "The Truth about super" to understand more about MI in Python. However, there are more fundamental issues: > I've got 4 files That should be irrelevant to MI problems. Please refine your example so that it's in one module, and still exhibits the problem. > When I run the script I get this: > > Traceback (most recent call last): > File "./3.py", line 20, in > Obj.Connect ('Database') > File "/mnt/isis/Projects/Python/Learning/DB_m.py", line 102, in Connect > self.TRACE ("DB::Connect (" + database + "," + mode) > File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 314, in TRACE > self.DailyLog (msg) > File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 98, in > DailyLog > dt = self.Date (time ()) > TypeError: 'module' object is not callable No, you don't. That might be what you get from *your* code, but it's not produced by the code you *posted*. (I know this if only because none of your modules have a line 98 on which to raise an exception.) So, since we don't have the code that generates that traceback, that traceback isn't useful to us for diagnosing the problem. > If you need to see all the source, can do, but it's certainly too > much for an intro message! Indeed. Instead, re-work your code (based on a copy) until it's as simple as it can be, and *still* shows the problems when you execute it. Then, if you still don't know why the traceback occurs, feel free to post that minimal example with the corresponding traceback. -- \ "Jury: A group of 12 people, who, having lied to the judge | `\ about their health, hearing, and business engagements, have | _o__) failed to fool him." -- Henry L. Mencken | Ben Finney From grflanagan at gmail.com Fri Apr 11 08:05:37 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Fri, 11 Apr 2008 05:05:37 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: On Apr 11, 12:14 pm, bdsatish wrote: > The built-in function round( ) will always "round up", that is 1.5 is > rounded to 2.0 and 2.5 is rounded to 3.0. > > If I want to round to the nearest even, that is > > my_round(1.5) = 2 # As expected > my_round(2.5) = 2 # Not 3, which is an odd num > > I'm interested in rounding numbers of the form "x.5" depending upon > whether x is odd or even. Any idea about how to implement it ? ------------------------------------------------ def myround(x): n = int(x) if abs(x - n) == 0.5: if n % 2: #it's odd return n + 1 - 2 * int(n<0) else: return n else: return round(x) assert myround(3.2) == 3 assert myround(3.6) == 4 assert myround(3.5) == 4 assert myround(2.5) == 2 assert myround(-0.5) == 0.0 assert myround(-1.5) == -2.0 assert myround(-1.3) == -1.0 assert myround(-1.8) == -2 assert myround(-2.5) == -2.0 ------------------------------------------------ From toddw at activestate.com Tue Apr 15 20:52:30 2008 From: toddw at activestate.com (Todd Whiteman) Date: Tue, 15 Apr 2008 17:52:30 -0700 Subject: Gecko 1.9 In-Reply-To: References: Message-ID: <48054DCE.3070909@activestate.com> Joe P. Cool wrote: > In 2005 I heard of plans to add Python as a second language to the > Gecko engine. Is this still true? Or has this plan been abandoned? > You can use Python inside of Mozilla (Gecko) based applications now, such as Firefox/Thunderbird/Komodo Edit/XulRunner which communicate through the Mozilla XPCOM architecture. There are builds of PyXPCOM (Python XPCOM) that can be downloaded and easily installed through the xpi extension mechanism, see: http://pyxpcomext.mozdev.org/ The Mozilla 1.9 branch (Gecko 1.9) also contains the hooks necessary to be able to use Python as a script handler, instead of having to use JavaScript. This is commonly referred to as PyDOM. To get and use PyXPCOM (Mozilla 1.8 and Mozilla 1.9): * install the above extension * or make your own build of the Mozilla application To get and use PyDOM (Mozilla 1.9): * you'll need to make your own build of the Mozilla application I'm the one working on the PyXPCOM extension, which I am hoping will eventually contain the PyDOM module as well (once I get around to making new Mozilla builds with this enabled). Cheers, Todd From wheaties.box at gmail.com Mon Apr 14 03:29:04 2008 From: wheaties.box at gmail.com (Josh) Date: Mon, 14 Apr 2008 00:29:04 -0700 (PDT) Subject: Different times between Python and System Message-ID: Hi, Anyone know why python would not show the same time that my system shows? user at computer:~$ date Mon Apr 14 01:27:36 MDT 2008 user at computer:~$ python Python 2.4.5 (#2, Mar 12 2008, 00:15:51) [GCC 4.2.3 (Debian 4.2.3-2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import datetime >>> datetime.datetime.now() datetime.datetime(2008, 4, 14, 1, 27, 50, 472350) Thanks! From skanemupp at yahoo.se Sun Apr 20 19:24:04 2008 From: skanemupp at yahoo.se (globalrev) Date: Sun, 20 Apr 2008 16:24:04 -0700 (PDT) Subject: question about the mainloop Message-ID: <52de38c4-3d1e-4be0-9b58-5d60317f1ef7@b1g2000hsg.googlegroups.com> in C?? java etc there is usually: procedure 1 procedure 2 procedure 3 main { procedure 1 procedure 2 procedure 3 } i dont get the mainloop() in python. i mean i have written some programs, for example a calculator using tkinterGUI. if i have some functions i wanna call to run the program and i wanna call them ina specific order and be able to call them from each other should this just be called in the mainloop and the mianloop then runs the "mainscript" top to bottom over and over? From ott.deb at gmail.com Thu Apr 17 15:06:14 2008 From: ott.deb at gmail.com (ott.deb at gmail.com) Date: Thu, 17 Apr 2008 12:06:14 -0700 (PDT) Subject: server 2003 activation crack Message-ID: server 2003 activation crack http://cracks.12w.net F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Fri Apr 25 21:13:26 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 25 Apr 2008 22:13:26 -0300 Subject: Pyserial - send and receive characters through linux serial port References: Message-ID: En Fri, 25 Apr 2008 20:22:37 -0300, terry escribi?: > I am trying to send a character to '/dev/ttyS0' and expect the same > character and upon receipt I want to send another character. I tired > with Pyserial but in vain. I assume you have a device attached to /dev/ttyS0 that echoes back the received characters? > Test Set up: > > 1. Send '%' to serial port and make sure it reached the serial port. > 2. Once confirmed, send another character. > > I tried with write and read methods in Pyserial but no luck. Check the communication parameters (baud rate, parity, etc.), cable, connectors, your device... AFAIK a lot of people is using pyserial so I'd look the problem elsewhere. Try posting a short code example showing your problem. -- Gabriel Genellina From billingspanshism at gmail.com Sat Apr 19 17:17:06 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:17:06 -0700 (PDT) Subject: victoria beckham background Message-ID: Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From corvettecraz92 at gmail.com Tue Apr 8 21:44:56 2008 From: corvettecraz92 at gmail.com (corvettecraz92 at gmail.com) Date: Tue, 8 Apr 2008 18:44:56 -0700 (PDT) Subject: text adventure game problem References: Message-ID: <6e247b5c-a58d-4e4e-a67a-c21d36061cf0@z38g2000hsc.googlegroups.com> On Apr 8, 9:25?pm, Andr? wrote: > On Apr 8, 10:01?pm, corvettecra... at gmail.com wrote: > > > > > okay, I'm having this one problem with a text adventure game. It's > > kind of hard to explain, but I'll do my best. > > [code] > > > def prompt_kitchen(): > > ? ? global gold > > ? ? gold_taken = False > > ? ? while True: > > ? ? ? ? prompt_kit = raw_input('>') > > ? ? ? ? if prompt_kit == 'examine cabinet 1' and not gold_taken: > > ? ? ? ? ? ? print '''This cabinet has a lot of cups in it with all > > different > > designs and shapes. Where are the people anyway? How come there's > > nobody here? > > In one of the cups you find 8 gold.''' > > ? ? ? ? ? ? gold = gold+8 > > ? ? ? ? ? ? gold_taken = True > > ? ? ? ? ? ? pass4() > > ? ? ? ? elif prompt_kit == 'examine cabinet 1' and gold_taken: > > ? ? ? ? ? ? print \ > > ? ? ? ? ? ? ? ? ? '''This cabinet has a lot of cups in it with all > > different > > designs and shapes. Where are the people anyway? How come there's > > nobody here?''' > > ? ? ? ? ? ? pass4() > > > def pass4(): > > ? ? global gold > > ? ? print 'You have', gold, 'gold' > > ? ? pass > > [/code] > > > Okay, now for my problem. > > In the above function, there's the option to examine a cabinet and get > > 8 gold. (everyone here knows that...but I'm just trying to state my > > problem...) > > Unfortunately, it kind of doesn't work. > > After the first time I 'examine cabinet 1' in my game, I get 8 gold > > and I can't get it again. > > But, If I leave the room and come back to it, then it's as if I had > > never gotten the gold the first time, and I can get it again. > > How do I fix this? > > quick guess: define gold_taken as a global variable and initialize it > outside of the function. > > Warning: avoid global variables if at all possible. > > ;-) > Andr? Here's a sample code that, in fact, does work. In this code, when run, I can only get the gold once. def prompt_house(): global gold gold_taken = False while True: prompt_hou = raw_input('>') if prompt_hou == 'examine table' and not gold_taken: print \ '''There are a lot of car magazines here. You flip through them and find 5 gold. ''' gold = gold+5 gold_taken = True elif prompt_hou == 'go west': # this gets you out of the loop go_west() # more elif choices here ... elif prompt_hou == 'examine table' and gold_taken: print '''There are a lot of car magazines here.''' go_west() def go_west(): # just a dummy funk global gold print gold pass # test gold = 0 prompt_house() But what's the difference between this and the one that I posted? From sjmachin at lexicon.net Mon Apr 14 17:27:27 2008 From: sjmachin at lexicon.net (John Machin) Date: Mon, 14 Apr 2008 14:27:27 -0700 (PDT) Subject: py2exe, program has stoped working!? References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> <232151d6-09ed-4a1e-9922-d66c2bf0d05b@w8g2000prd.googlegroups.com> Message-ID: <67526f9f-a610-4cbe-8e2c-6219a59a4d54@i36g2000prf.googlegroups.com> On Apr 15, 4:08 am, Steve Holden wrote: > John Machin wrote: > > > By the way, "popup" is what you get in a web browser. What did this > > "popup" look like: a panel from your GUI software? A Windows message > > box? Did it have a title across the top? What was the exact text in > > the popup/panel/box? Were there any options other than to close the > > window? > > > FYI "xxx has stopped working" is Vista's "user-friendly" way of > reporting what Windows 3 would probably have called a "General Program > Fault". So I found by googling "has stopped working". I'd never seen such a litany of weeping, wailing and u'\u02ad' before. > It pretty much hides all useful information fro the end-user, > perhaps on the grounds that end users wouldn't know what to do with the > information it *could* provide anyway. Thanks for the info, Steve. Sounds like it's even worse than its predecessor in Windows XP. Cheers, John From jzshao1 at gmail.com Wed Apr 16 09:36:14 2008 From: jzshao1 at gmail.com (Jonathan Shao) Date: Wed, 16 Apr 2008 09:36:14 -0400 Subject: Interesting timing issue I noticed Message-ID: *Gabriel Genellina* gagsl-py2 at yahoo.com.ar *Wed Apr 16 08:44:10 CEST 2008* > Another thing would be to rearrange the loops so the outer one executes less times; if you know that borderX< From s0suk3 at gmail.com Tue Apr 29 16:12:57 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Tue, 29 Apr 2008 13:12:57 -0700 (PDT) Subject: Simple import question about mac osx References: Message-ID: <7e99034b-78ac-4ffd-b273-f5d7489f85de@t54g2000hsg.googlegroups.com> On Apr 29, 2:17 pm, jmDesktop wrote: > On Apr 29, 2:37 pm, "Jerry Hill" wrote: > > > > > On Tue, Apr 29, 2008 at 2:14 PM, jmDesktop wrote: > > > Thanks. That worked on mac. But it does work like I said in > > > Windows. Don't know why. Mr. Chun must also be using Windows because > > > that is the way he does it in his book. > > > It shouldn't work that way on windows either. Can you tell us a > > little more about what you mean when you say you "compile this" under > > windows? Normally, python code doesn't need to be compiled, so I'm > > wondering if you're doing something different from what we expect when > > you say you compile it and then import it in the interpreter. > > > Are you by any chance writing code in IDLE, running it, then doing > > things in the interpreter? > > > -- > > Jerry > > On Windows I took the text file I created on mac with vi and opened it > in PythonWin. I ran it. It compiled. I run the import and call from > the python interpreter. Well, Python compiles automatically any .py file that you import. Of course this isn't machine code like the one from a C compiled executable. It's Python's own bytecode. But normally you shouldn't worry about that bytecode; actually, you shouldn't even be paying attention to it. All that concerns you is that you created a module and that you can import it. Leave the whole "compiling" concept to the interpreter. From ptmcg at austin.rr.com Tue Apr 29 10:26:07 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Tue, 29 Apr 2008 07:26:07 -0700 (PDT) Subject: list.reverse() References: Message-ID: <98306bd8-e41c-4fd0-beee-6ef5c6018e44@w74g2000hsh.googlegroups.com> On Apr 28, 1:12?pm, Mark Bryan Yu wrote: > This set of codes works: > > >>> x = range(5) > >>> x.reverse() > >>> x > > [4, 3, 2, 1, 0] > You can also use list slicing to get a reversed list: >>> x = range(5) >>> x [0, 1, 2, 3, 4] >>> x[::-1] [4, 3, 2, 1, 0] -- Paul From deets at nospam.web.de Sat Apr 26 14:44:09 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Sat, 26 Apr 2008 20:44:09 +0200 Subject: Calling Python code from inside php In-Reply-To: References: <679e9oF2mti63U1@mid.uni-berlin.de> <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> Message-ID: <67hbgjF2om9g0U1@mid.uni-berlin.de> Eric Wertman schrieb: >> > A simple yet dangerous and rather rubbish solution (possibly more of a >> > hack than a real implementation) could be achieved by using a >> > technique described above: >> > >> > > > echo exec('python foo.py'); >> >> This will spawn a Python interpreter, and not be particularly >> efficient. You could just as well have used CGI. > > I'm in a bit of a similar situation. I decided to use python to > solve problems where I could, in a more regimented fashion. For > instance, I have a set of functions in a script, table.py. After I > set up mod_python to handle requests to a single directory with > python, I can call this with: > > > > embedded in the page. This is probably pretty hackish too, but at > least it doesn't spawn a new process, and I don't have to solve things > that aren't related to display with php. You mean opening a local-loop socket instead of a anonymous socket, hogging at least another apache process and then possibly spawning another process if the python-script is implemented as real CGI - not fast_cgi or python - is the better solution? I doubt that. More wasteful in all aspects, with small to any gain at all. Unix uses pipes as IPC all the time. I fail to see why that is "rubbish". Diez From guillermo.listas at googlemail.com Mon Apr 21 07:57:00 2008 From: guillermo.listas at googlemail.com (Guillermo) Date: Mon, 21 Apr 2008 04:57:00 -0700 (PDT) Subject: Opposite of repr() (kind of) References: Message-ID: <546f6b82-c537-4f17-86a4-e6ea2c34e965@w5g2000prd.googlegroups.com> This must be the dumbest question ever... Solved. On Apr 21, 1:05 pm, Guillermo wrote: > Hi there, > > How can I turn a string into a callable object/function? > > I have a = 'len', and I want to do: if callable(eval(a)): print > "callable", but that doesn't quite work the way I want. :) > > Regards, > > Guillermo From steven.p.clark at gmail.com Tue Apr 8 11:15:07 2008 From: steven.p.clark at gmail.com (Steven Clark) Date: Tue, 8 Apr 2008 11:15:07 -0400 Subject: list.sort(): heaviest item? Message-ID: <663744510804080815y2eda80d2m9e34da2893e99de0@mail.gmail.com> If I have a list of items of mixed type, can I put something into it such that after a list.sort(), is guaranteed to be at the end of the list? Looking at http://www.python.org/doc/2.3.5/ref/comparisons.html "Most other types compare unequal unless they are the same object; the choice whether one object is considered smaller or larger than another one is made arbitrarily but consistently within one execution of a program." makes me unsure. It looks like "None" always ends up at the start ("lightest"), but I want the opposite ("heaviest"). -Steven From alkundry at gmail.com Thu Apr 24 02:40:26 2008 From: alkundry at gmail.com (ABDULLAH) Date: Wed, 23 Apr 2008 23:40:26 -0700 (PDT) Subject: DO YOU KNOW ANY THING ABOUT ISLAM??? Message-ID: <2429a87a-34e8-4294-9a25-b54dd2cf6791@m73g2000hsh.googlegroups.com> What you are about to read might sound unusual but it could be very enlightened. So I would be thankful if you give my article 5 minute of your value time. THANK YOU Islam is a total system of living. A Muslim is supposed to live in peace and harmony with all these segments; hence, a Muslim is any person anywhere in the world whose obedience, allegiance, and loyalty are to God, the Lord of the Universe. The legal sources of Islam are the Qur'an and the Hadith. The Qur'an is the exact word of God; its authenticity, originality and totality are intact. The Hadith is the report of the sayings, deeds and approvals of the Prophet Muhammad. The Prophet's sayings and deeds are called Sunnah. The Seerah is the writings of followers of Muhammad about the life of the Prophet. Hence, it is the life history of the Prophet Muhammad which provides examples of daily living for Muslims. Muslims are required to respect all those who are faithful and God conscious people, namely those who received messages. Christians and Jews are called People of the Book. Muslims are asked to call upon the People of the Book for common terms, namely, to worship One God, and to work together for the solutions of the many problems in the society. Some Basic Islamic Beliefs 1) Belief in God: Muslims believe in one, unique, incomparable God, Who has no son nor partner, and that none has the right to be worshipped but Him alone. He is the true God, and every other deity is false. He has the most magnificent names and sublime perfect attributes. No one shares His divinity, nor His attributes. In the Quran, God describes Himself: Say, ?He is God, the One. God, to Whom the creatures turn for their needs. He begets not, nor was He begotten, and there is none like Him.? (Quran, 112:1-4) Chapter 112 of the Quran written in Arabic calligraphy. No one has the right to be invoked, supplicated, prayed to, or shown any act of worship, but God alone. God alone is the Almighty, the Creator, the Sovereign, and the Sustainer of everything in the whole universe. He manages all affairs. He stands in need of none of His creatures, and all His creatures depend on Him for all that they need. He is the All- Hearing, the All-Seeing, and the All-Knowing. In a perfect manner, His knowledge encompasses all things, the open and the secret, and the public and the private. He knows what has happened, what will happen, and how it will happen. No affair occurs in the whole world except by His will. Whatever He wills is, and whatever He does not will is not and will never be. His will is above the will of all the creatures. He has power over all things, and He is able to do everything. He is the Most Gracious, the Most Merciful, and the Most Beneficent. In one of the sayings of the Prophet Muhammad , we are told that God is more merciful to His creatures than a mother to her child.1 God is far removed from injustice and tyranny. He is All-Wise in all of His actions and decrees. If someone wants something from God, he or she can ask God directly without asking anyone else to intercede with God for him or her. God is not Jesus, and Jesus is not God.2 Even Jesus himself rejected this. God has said in the Quran: Indeed, they have disbelieved who have said, ?God is the Messiah (Jesus), son of Mary.? The Messiah said, ?Children of Israel, worship God, my Lord and your Lord. Whoever associates partners in worship with God, then God has forbidden Paradise for him, and his home is the Fire (Hell). For the wrongdoers,3 there will be no helpers.? (Quran, 5:72) God is not a trinity. God has said in the Quran: Indeed, they disbelieve who say, ?God is the third of three (in a trinity),? when there is no god but one God. If they desist not from what they say, truly, a painful punishment will befall the disbelievers among them. Would they not rather repent to God and ask His forgiveness? For God is Oft-Forgiving, Most Merciful. The Messiah (Jesus), son of Mary, was no more than a messenger... (Quran, 5:73-75) Islam rejects that God rested on the seventh day of the creation, that He wrestled with one of His angels, that He is an envious plotter against mankind, or that He is incarnate in any human being. Islam also rejects the attribution of any human form to God. All of these are considered blasphemous. God is the Exalted. He is far removed from every imperfection. He never becomes weary. He does not become drowsy nor does he sleep. The Arabic word Allah means God (the one and only true God who created the whole universe). This word Allah is a name for God, which is used by Arabic speakers, both Arab Muslims and Arab Christians. This word cannot be used to designate anything other than the one true God. The Arabic word Allah occurs in the Quran about 2700 times. In Aramaic, a language related closely to Arabic and the language that Jesus habitually spoke,4 God is also referred to as Allah. 2) Belief in the Angels: Muslims believe in the existence of the angels and that they are honored creatures. The angels worship God alone, obey Him, and act only by His command. Among the angels is Gabriel, who brought down the Quran to Muhammad . 3) Belief in God?s Revealed Books: Muslims believe that God revealed books to His messengers as proof for mankind and as guidance for them. Among these books is the Quran, which God revealed to the Prophet Muhammad . God has guaranteed the Quran?s protection from any corruption or distortion. God has said: Indeed, We have sent down the Quran, and surely We will guard it (from corruption). (Quran, 15:9) 4) Belief in the Prophets and Messengers of God: Muslims believe in the prophets and messengers of God, starting with Adam, including Noah, Abraham, Ishmael, Isaac, Jacob, Moses, and Jesus (peace be upon them). But God?s final message to man, a reconfirmation of the eternal message, was revealed to the Prophet Muhammad . Muslims believe that Muhammad is the last prophet sent by God, as God has said: Muhammad is not the father of any one of your men, but he is the Messenger of God and the last of the prophets... (Quran, 33:40) Muslims believe that all the prophets and messengers were created human beings who had none of the divine qualities of God. 5) Belief in the Day of Judgment: Muslims believe in the Day of Judgment (the Day of Resurrection) when all people will be resurrected for God?s judgment according to their beliefs and deeds. 6) Belief in Al-Qadar: Muslims believe in Al-Qadar, which is Divine Predestination, but this belief in Divine Predestination does not mean that human beings do not have freewill. Rather, Muslims believe that God has given human beings freewill. This means that they can choose right or wrong and that they are responsible for their choices. The belief in Divine Predestination includes belief in four things: 1) God knows everything. He knows what has happened and what will happen. 2) God has recorded all that has happened and all that will happen. 3) Whatever God wills to happen happens, and whatever He wills not to happen does not happen. 4) God is the Creator of everything. For more information about Islam http://www.islam-guide.com/ From steve at holdenweb.com Thu Apr 17 04:12:00 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 17 Apr 2008 04:12:00 -0400 Subject: I just killed GIL!!! In-Reply-To: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: sturlamolden wrote: > Hello Guys... > > I just had one moment of exceptional clarity, during which realized > how I could get the GIL out of my way... It's so simple, I cannot help > wondering why nobody has thought of it before. Duh! Now I am going to > sit and and marvel at my creation for a while, and then go to bed > (it's past 2:30 a.m.) Tomorrow I will contemplate whether to sell this > little secret for big bucks, give it away for free, or just keep it to > myself... :-) > > Now you are probably thinking I reinvented the gunpowder, and are > running multiple processes. Not so. I am not running parallel > processes, like parallel python or the processing module in cheese > shop. I am running multiple THREADS. In fact, I am just using > threading.Thread. The source code is pure Python, so there is no C > magic, and I only used the stuff that's already there in the standard > library. So, I just made CPython do what everyone claim to be > impossible. One single process of CPython is using all the cpu power > of my dual-core laptop. > Quick, write it down before the drugs wear off. Sorry. I'm definitely a skeptic on this story. Put up or shut up. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Fri Apr 25 16:42:03 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Fri, 25 Apr 2008 22:42:03 +0200 Subject: problem with unicode References: <26fcc207-b864-42c7-afb3-c6945e5fe29f@m44g2000hsc.googlegroups.com> <67dvg8F2nomm6U1@mid.individual.net> Message-ID: <67eu0rF2ogf6qU1@mid.individual.net> John Machin wrote: > On Apr 25, 10:01 pm, Bjoern Schliessmann > >>> media="x???[?" >> >>> print repr(media.decode("utf-8")) >> >> u'x\u30ef\u30e6\u30ed[\u30e8' (dang, KNode doesn't autodetect encodings ...) > But that_unicode_string.encode("utf-8") produces > 'x\xe3\x83\xaf\xe3\x83\xa6\xe3\x83\xad[\xe3\x83\xa8' > which does not contain the complained-about byte 0x9c in position > 1 (or any other position) -- how can that be? Probably the OP used a different encoding. That seems even more likely given the fact that his postings have a Japanese encoding (but this one doesn't produce any 0x9c, either). Regards, Bj?rn -- BOFH excuse #346: Your/our computer(s) had suffered a memory leak, and we are waiting for them to be topped up. From lists at cheimes.de Sat Apr 12 10:59:17 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 12 Apr 2008 16:59:17 +0200 Subject: str(bytes) in Python 3.0 In-Reply-To: <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> Message-ID: <4800CE45.1030407@cheimes.de> Carl Banks schrieb: > I believe the Zen in effect here is, "In the face of ambiguity, refuse > the temptation to guess." How do you know if the bytes are utf-8 > encoded? Indeed > I'm not sure if str() returning the repr() of a bytes object (when not > passed an encoding) is the right thing, but it's probably better than > throwing an exception. The problem is, str can't decide whether it's > a type conversion operator or a formatted printing function--if it > were strongly one or the other it would be a lot more obvious what to > do. I was against it and I also wanted to have 'egg' == b'egg' raise an exception but I was overruled by Guido. At least I was allowed to implement the byte warning feature (-b and -bb arguments). I *highly* recommend that everybody runs her unit tests with the -bb option. Christian From bwljgbwn at gmail.com Tue Apr 22 05:52:48 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:52:48 -0700 (PDT) Subject: getright pro keygen Message-ID: <750fafee-fe3e-4c0c-8888-38a92b1552d9@m36g2000hse.googlegroups.com> getright pro keygen http://cracks.12w.net F R E E C R A C K S From balta96428 at gmail.com Wed Apr 23 05:54:37 2008 From: balta96428 at gmail.com (balta96428 at gmail.com) Date: Wed, 23 Apr 2008 02:54:37 -0700 (PDT) Subject: cat6 patch cables Message-ID: <7c2561ed-97dc-4f51-adf0-42f7ae50816b@24g2000hsh.googlegroups.com> cat6 patch cables http://cracks.12w.net F R E E C R A C K S From mdw at distorted.org.uk Sun Apr 6 17:10:17 2008 From: mdw at distorted.org.uk (Mark Wooding) Date: Sun, 6 Apr 2008 21:10:17 +0000 (UTC) Subject: sine in python References: Message-ID: Astan Chee wrote: > I have a math function that looks like this > sin (Theta) = 5/6 > How do I find Theta (in degrees) in python? import math theta = math.asin(5/6) * 180/math.pi -- [mdw] From kyosohma at gmail.com Tue Apr 15 09:03:24 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 15 Apr 2008 06:03:24 -0700 (PDT) Subject: hw to program on python References: <2732d09a-b0e6-4ae6-a826-9fa375fb3e86@q10g2000prf.googlegroups.com> Message-ID: <5e788345-2a4f-43f6-9b5a-28ad5a7196ff@k13g2000hse.googlegroups.com> On Apr 15, 7:47 am, ashish wrote: > hi , > python experts i want some help from u people just mail me how to > write scripts for web applications (like form coding for login page, > etc). > > i m waiting.... for ur reply by > have a nice day! I suggest you start by going to the Python website and going through some of the tutorials found there: www.python.org. When you're done, check out one of the Python Web Frameworks: Pylons, Django, TurboGears, or Zope/Plone. There are also books on the subject, such as Holden's "Python Web Programming" or Thiruvathukal's "Web Programming in Python", as well as more general books that include examples of web programming, including the Python Cookbook and Lutz's "Programming Python". Mike From goldenlaks at gmail.com Mon Apr 7 11:26:40 2008 From: goldenlaks at gmail.com (TAJMAHAL TEMPLE) Date: Mon, 7 Apr 2008 08:26:40 -0700 (PDT) Subject: WORLD TOURSIM WORLD TRAVEL WORLD PACKAGE Message-ID: <7b44c78e-c6f6-4105-ad67-f4bf9854da65@u36g2000prf.googlegroups.com> Freee... Freee.... Freeee.... http://sai-tourism-package.blogspot.com/ From ceres83 at gmail.com Mon Apr 21 04:05:30 2008 From: ceres83 at gmail.com (Mario Ceresa) Date: Mon, 21 Apr 2008 10:05:30 +0200 Subject: Pickle problem In-Reply-To: <933a2b55-7a99-4061-9dc0-4de657448f1c@s50g2000hsb.googlegroups.com> References: <933a2b55-7a99-4061-9dc0-4de657448f1c@s50g2000hsb.googlegroups.com> Message-ID: Dear Jerry and George: it works like a charm! I always thought that the first way was a quicker alternative to defining the init method... shame on me! >From now on I'll read the list every day repeating to myself: "Premature optimization is the root of all evil", "Premature optimization is the root of all evil", .... :) Thanks a lot, Mario On Fri, Apr 18, 2008 at 8:00 PM, George Sakkis wrote: > On Apr 18, 11:55 am, "Mario Ceresa" wrote: > > Hello everybody: > > I'd like to use the pickle module to save the state of an object so to > > be able to restore it later. The problem is that it holds a list of > > other objects, say numbers, and if I modify the list and restore the > > object, the list itself is not reverted to the saved one, but stays > > with one element deleted. > > > > An example session is the following: > > > > Data is A [1, 2, 3, 4] > > saving a with pickle > > Deleting an object: del a[3] > > Now data is A [1, 2, 3] > > Oops! That was an error: can you please recover to the last saved data? > > A [1, 2, 3] #### I'd like to have here A[1,2,3,4]!!!!!! > > > > Is it the intended behavior for pickle? if so, are there any way to > > save the state of my object? > > > > Code follows > > ----------------------- > > class A(object): > > objects = [] > > ----------------------- > > then I run the code: > > --------------------------------------- > > import pickle > > from core import A > > > > a = A() > > > > for i in [1,2,3,4]: > > a.objects.append(i) > > > > savedData = pickle.dumps(a) > > print "Saved data is ",a > > print "Deleting an object" > > del a.objects[3] > > print a > > print "Oops! This was an error: can you please recover the last saved data?" > > > > print pickle.loads(savedData) > > -------------------------------------------- > > > > Thank you for any help! > > > > Mario > > The problem is that the way you define 'objects', it is an attribute > of the A *class*, not the instance you create. Change the A class to: > > > class A(object): > def __init__(self): > self.objects = [] > > and rerun it; it should now work as you intended. > > HTH, > George > -- > http://mail.python.org/mailman/listinfo/python-list > From bruno.desthuilliers at gmail.com Wed Apr 23 15:53:23 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 23 Apr 2008 12:53:23 -0700 (PDT) Subject: Python development tools References: Message-ID: <09992de9-39fa-4ee6-8009-35732f3433fb@y21g2000hsf.googlegroups.com> On 23 avr, 19:39, "wongjoek... at yahoo.com" wrote: > Are there any completely free developent tools for python scripts like > IDLE. I have used IDLE , but I want to try out others also. I saw > stuff like PyCrust, but I don't see that it can run the script as > well. > Thanks, emacs + python-mode (the one from Python, not the horror that ships with recent emacs versions) + ecb (Emacs code browser) No bells and whistles, no clickodrom, but one of the most powerful combo you can get. But be warned: learning and configuring emacs is not for wheenies !-) From Lie.1296 at gmail.com Thu Apr 17 15:35:25 2008 From: Lie.1296 at gmail.com (Lie) Date: Thu, 17 Apr 2008 12:35:25 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> <01db54ab-1fca-4a51-8b98-510de224f40a@y21g2000hsf.googlegroups.com> <8e6dbc15-98f2-441d-bba4-d9ddb36f482d@i36g2000prf.googlegroups.com> Message-ID: <6f0edb21-9930-4c5f-b5fa-60e1a1d6dd29@a23g2000hsc.googlegroups.com> On Apr 13, 7:20 pm, Steve Holden wrote: > Lie wrote: > > On Apr 12, 3:44 am, hdante wrote: > [snip] > > > In short, choosing that x.0 is rounded down and x.5 is rounded up is > > arbitrary but not without a reason. > > Don't "arbitrary" and "not without a reason" directly contradict one > another? > The same as choosing between round-half-odd and round-half-even, arbitrary but not without a reason. Language-wise it is a contradiction. In a loose semantic meaning, it means there is no strong reason for choosing one above the other (round-up vs round down and round-half-even vs round-half-odd) but there are slight advantages on one that would seems silly to be mentioned as the main reason, so arbitrary but not without reason. On Apr 13, 9:28 pm, Mark Dickinson wrote: > On Apr 13, 4:18 am, Lie wrote: > [...] > > > it and there is nothing else in it, but in the second number range > > (barely above 1 to 2) the number 1.0 is not included while the number > > 2.0 is contained in it, clearly not a clean separation of numbers in > > the form of y.x where y is pre-determined and x is variable from other > > possible values of y. > > Have you considered the fact that the real numbers of > the form 1.xxxxx... are those in the range [1.0, 2.0], > including *both* endpoints? That is, 2.0 = 1.999999... > Similarly, the midpoint of this range can be written > both in the form 1.500000... and 1.499999... No, you can only include one of the endpoints, because if both endpoints are included, the integers would be a included twice on the various sets of numbers, e.g. in [1.0 - 2.0] and [2.0 - 3.0] the number 2.0 is included in both ranges, you can't be a member of both ranges because that means if you have a "fair" random number generator, the possibility of integral number to appear would be twice the possibility of non-integral numbers, well that's not a fair random number generator isn't it? > This is relevant if you think of rounding as an operation > on *decimal representations* of real numbers rather than > as an operation on real numbers themselves. I'm not sure > which point of view you're taking here. Actually, I'm on the side that think numbers should never be rounded[1], except for a final representation to human viewer who should be made aware that the numbers in the presentation should never be used for further calculation, as they are only informative but not normative. In this view, the exact rounding method is irrelevant as numbers used for calculation are never rounded while at the lower level the amount of change caused by rounding has become irrelevant because of the extra precision used. In short, if the rounding algorithm causes you a trouble in the particular field, increase the precision. [1] As computers do have limitation on storage of real number representation, this statement means that real numbers should be kept as precise as the hardware allows or to use decimal and allow extra precision generously. > Either way, your arguments don't change the fact that the > average rounding error is strictly positive for positive > quantized results, under round-half-away-from-zero. If you include negative numbers, the ARE is zero on round-half-away- from-zero, not in round-up though. From Dodin.Roman at gmail.com Fri Apr 25 04:39:52 2008 From: Dodin.Roman at gmail.com (hellt) Date: Fri, 25 Apr 2008 01:39:52 -0700 (PDT) Subject: Little novice program written in Python References: Message-ID: <0cecfed4-17e7-4e4d-9dbe-3f0ac8316c1f@y21g2000hsf.googlegroups.com> Rog?rio Brito: > Hi, All. > > I'm just getting my feet wet on Python and, just for starters, I'm coding some > elementary number theory algorithms (yes, I know that most of them are already > implemented as modules, but this is an exercise in learning the language idioms). > > As you can see from the code below, my background is in C, without too much > sophistication. > > What I would like is to receive some criticism to my code to make it more > Python'esque and, possibly, use the resources of the computer in a more > efficient way (the algorithm implemented below is the Sieve of Eratosthenes): > my variant of the sieve def GetPrimes(N): arr = [] for i in range(1,N+1): arr.append(i) #Set first item to 0, because 1 is not a prime arr[0]=0 #sieve processing s=2 while s < math.sqrt(N): if arr[s-1] != 0: j = s*s while j <= N: arr[j-1] = 0 j += s s += 1 return [x for x in arr if x != 0] From suzhi18 at googlemail.com Tue Apr 8 09:18:48 2008 From: suzhi18 at googlemail.com (suzhi18 at googlemail.com) Date: Tue, 8 Apr 2008 06:18:48 -0700 (PDT) Subject: makepy.py not working Message-ID: <03e9c33d-d957-4bc0-8568-3a40403eadb9@a70g2000hsh.googlegroups.com> Hallo, I've a problem getting makepy running. When I start the tool on my machine with doubleclick everything is fine. But when I try this in my Code: makepy.py -i "Microsoft Excel 11.0 Object Library(1.5)" I am getting an Syntax Error and command: makepy.py bring me this message on the screen: Traceback (most recent call last): File "", line 1, in NameError: name 'makepy' is not defined Any ideas what I am doing wrong? From aboudouvas at panafonet.gr Mon Apr 14 16:09:40 2008 From: aboudouvas at panafonet.gr (king kikapu) Date: Mon, 14 Apr 2008 13:09:40 -0700 (PDT) Subject: How to make python run faster References: <0baa301a-ec8c-48ef-b30e-f9c80f72e5af@u12g2000prd.googlegroups.com> Message-ID: <68ef0f67-1588-44e5-9c8f-79f929e8df75@b9g2000prh.googlegroups.com> On 14 ???, 16:48, ??? wrote: > I read this article onhttp://kortis.to/radix/python_ext/ > > And I decided to try if it's true. > > I write the program in 4 ways: > > 1. Pure C > 2. Python using C extension > 3. Python using psycho > 4. Pure Python > > And then I used timeit to test the speed of these 4. Unsurprisingly, > the time they cost were: > > 4 > 3 > 2 > 1 > > But I did noticed that 2 is a least 3 times slower than 1, not as fast > as the article stated. > > That's quite weird and I thought maybe it's because I am using > Windows. I did the same test on Linux and I found 2 only uses 1.5 > times of time of 1. > > But, it is still not as fast as 1. I have experimented too with this scenario. My conclusion is that it aint worth it to mess with C. Program only in Python and when the time comes that you want to speed up something, just use Psyco on this. And that will be more than enough. From huayang.xia at gmail.com Fri Apr 11 10:19:52 2008 From: huayang.xia at gmail.com (Huayang Xia) Date: Fri, 11 Apr 2008 07:19:52 -0700 (PDT) Subject: Convert PyIDispatch object to struct IDispatch* References: <90eee1e1-b1cc-48a9-8c09-173e92861f2c@a5g2000prg.googlegroups.com> <83260aaf-b2d7-4857-bd71-a8e7b30c6d70@n14g2000pri.googlegroups.com> Message-ID: On Apr 11, 9:47 am, Tim Golden wrote: > Huayang Xia wrote: > > On Apr 11, 12:15 am, "Gabriel Genellina" > > wrote: > >> En Thu, 10 Apr 2008 18:45:04 -0300, Huayang Xia > >> escribi?: > > >>> I am trying to use ctypes to call dll functions. One of the functions > >>> requires argument "struct IDispatch* ". I do have a PyIDispatch object > >>> in python. How can I convert this "PyIDispatch object" to "struct > >>> IDispatch* "? > >> I think a PyIDispatch object is an IDispatch* itself. > >> But you'll get better answers from the python-win32 list:http://mail.python.org/mailman/listinfo/python-win32 > > >> -- > >> Gabriel Genellina > > > Thanks for the info. > > > To call a dll function, it needs a C style IDispatch*. PyIDispatch is > > a python wrapped one. I found a reference from: > > >http://svn.python.org/projects/ctypes/trunk/comtypes/comtypes/test/te... > > > which shows how to convert C style to python style. Unfortunately i > > need the reversed version. > > > I will post the question to python-win32. > > I've had a quick look at the PyIDispatch source and I can't see any obvious > way in which the underlying IDispatch is exposed. May have missed something, > but it's possible that there's not way out. > > TJG Thanks for the info. I read somewhere that the PyIDispatch is converted to VT_DISPATCH automatically when passed to a C style function call. So from VT_DISPATCH, it should be possible to get the IDispatch. That's only a vague idea. From gherzig at fmed.uba.ar Fri Apr 4 11:27:14 2008 From: gherzig at fmed.uba.ar (Gerardo Herzig) Date: Fri, 04 Apr 2008 12:27:14 -0300 Subject: collecting results in threading app In-Reply-To: <47f64507$0$36354$742ec2ed@news.sonic.net> References: <47f64507$0$36354$742ec2ed@news.sonic.net> Message-ID: <47F648D2.9020000@fmed.uba.ar> John Nagle wrote: >Gerardo Herzig wrote: > > >>Hi all. Newbee at threads over here. Im missing some point here, but cant >>figure out which one. >> >>This little peace of code executes a 'select count(*)' over every table >>in a database, one thread per table: >> >>class TableCounter(threading.Thread): >> def __init__(self, conn, table): >> self.connection = connection.Connection(host=conn.host, >>port=conn.port, user=conn.user, password='', base=conn.base) >> threading.Thread.__init__(self) >> self.table = table >> >> def run(self): >> result = self.connection.doQuery("select count(*) from %s" % >>self.table, [])[0][0] >> print result >> return result >> >> >>class DataChecker(metadata.Database): >> >> def countAll(self): >> for table in self.tables: >> t = TableCounter(self.connection, table.name) >> t.start() >> return >> >> >>It works fine, in the sense that every run() method prints the correct >>value. >>But...I would like to store the result of t.start() in, say, a list. The >>thing is, t.start() returns None, so...what im i missing here? >>Its the desing wrong? >> >> > > 1. What interface to MySQL are you using? That's not MySQLdb. > 2. If SELECT COUNT(*) is slow, check your table definitions. > For MyISAM, it's a fixed-time operation, and even for InnoDB, > it shouldn't take that long if you have an INDEX. > 3. Threads don't return "results" as such; they're not functions. > > >As for the code, you need something like this: > >class TableCounter(threading.Thread): > def __init__(self, conn, table): > self.result = None > ... > > def run(self): > self.result = self.connection.doQuery("select count(*) from %s" % > self.table, [])[0][0] > > > def countAll(self): > mythreads = [] # list of TableCounter objects > # Start all threads > for table in self.tables: > t = TableCounter(self.connection, table.name) > mythreads.append(t) # list of counter threads > t.start() > # Wait for all threads to finish > totalcount = 0 > for mythread in mythreads: # for all threads > mythread.join() # wait for thread to finish > totalcount += mythread.result # add to result > print "Total size of all tables is:", totalcount > > > > John Nagle > > Thanks John, that certanly works. According to George's suggestion, i will take a look to the Queue module. One question about for mythread in mythreads: # for all threads mythread.join() # wait for thread to finish That code will wait for the first count(*) to finish and then continues to the next count(*). Because if is that so, it will be some kind of 'use threads, but execute one at the time'. I mean, if mytreads[0] is a very longer one, all the others will be waiting...rigth? There is an approach in which i can 'sum' after *any* thread finish? Could a Queue help me there? Thanks! Gerardo From hniksic at xemacs.org Mon Apr 28 05:42:45 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Mon, 28 Apr 2008 11:42:45 +0200 Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> Message-ID: <87od7ue2ne.fsf@mulj.homelinux.net> Nick Craig-Wood writes: > What you are missing is that if the recv ever returns no bytes at all > then the other end has closed the connection. So something like this > is the correct thing to write :- > > data = "" > while True: > new = client.recv(256) > if not new: > break > data += new This is a good case for the iter() function: buf = cStringIO.StringIO() for new in iter(partial(client.recv, 256), ''): buf.write(new) data = buf.getvalue() Note that appending to a string is almost never a good idea, since it can result in quadratic allocation. From martin at v.loewis.de Thu Apr 17 17:01:45 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Thu, 17 Apr 2008 23:01:45 +0200 Subject: I just killed GIL!!! In-Reply-To: References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> Message-ID: <4807bab9$0$27007$9b622d9e@news.freenet.de> > An there you have the answer. It's really very simple :-) I'm fairly skeptical that it actually works. If the different Python interpreters all import the same extension module (say, _socket.pyd), windows won't load the DLL twice, but only one time. So you end up with a single copy of _socket, which will have a single copy of socket.error, socket.socket, and so on. The single copy of socket.error will inherit from one specific copy of IOError. So if you import socket in a different interpreter, and raise socket.error there, and try to catch IOError, the exception won't be caught - because *that* IOError is then not a base class of socket.error. A more general approach similar to this one is known as ".NET appdomains" or "Java isolates". It requires the VM to refrain from having any global state, and to associate all "global" state with the appdomain or isolate. Python can't easily support that kind of model, because extension modules have global state all the time. Even if Python supported appdomains, you still wouldn't get any object sharing out of it. As soon as you start to share some object (but not their types), your entire type hierarchy gets messed up. FWIW, Tcl implements this model precisely: Tcl is not thread-safe in itself, but supports a interpreter-per-thread model. I'm also skeptical that this is any better than the GIL. Regards, Martin From yousaf.asad at gmail.com Sun Apr 6 13:46:02 2008 From: yousaf.asad at gmail.com (Dexter) Date: Sun, 6 Apr 2008 10:46:02 -0700 (PDT) Subject: Graph, Math and Stats Online Software Message-ID: have designed and developed Graphing tools and Math/Stats online software that is available on internet. Most of my visitor are from US academia. The list of programs include the following 1. Graphing Rectangular 2D 2. Graphing Rectangular 3D 3. Graphing Polar 4. Graphing 2D Parametric curves 5. Graphing 3D Parametric curves 6. Graphing 3D Parametric surfaces 7. Finding Area under curve (Rectangular) 8. Finding Area under curve (Polar) 9. Finding Area between curves (Rectangular) 10. Finding ArcLength (Rectangular) 11. Finding ArcLength (Parametric) 12 Finding Arc Length (Polar) 13. Finding Differentials f' (x) 14. Finding Volume (Disks) 15. Finding Volume (Washers) 16. Finding Surface Area (Disks) 17. Finding Centroid 18. Probability (Dice) 19. Measures of Central Location and Dispersion 20. Regression Analysis 21. Correlation Analysis All these programs are available on two of my sites 1. http://www.thinkanddone.com 2. http://www.britishcomputercolleges.com From ivan.illarionov at gmail.com Thu Apr 10 16:41:29 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Thu, 10 Apr 2008 13:41:29 -0700 (PDT) Subject: Module Conflicts References: <1592fad3-996b-4f62-ac12-42aff8272c21@8g2000hsu.googlegroups.com> Message-ID: <773d436c-2216-49ac-8e79-ca89618ac32f@q24g2000prf.googlegroups.com> On Apr 11, 12:31 am, Ivan Illarionov wrote: > On Apr 10, 2:33 am, Jose wrote: > > > I have a module named math.py in a package with some class > > definitions. I am trying to import the standard python math module > > inside of math.py but It seems to be importing itself. Is there any > > way around this problem without renaming my math.py file? > > Yes, if you are using Python 2.5 > > from __future__ import absolute import > > after this `import math` will always import standard math module and > `from . import math` will import your module. > > -- > Ivan I should say `from __future__ import absolute_import` And it's relatively easy to do in earlier versions too: create subdirectory `stdmath` with one `__init__.py` file with one line `import math` and than use `from stdmath import math`. and than use From deets at nospam.web.de Thu Apr 24 12:47:54 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 24 Apr 2008 18:47:54 +0200 Subject: NameError: global name 'Response' is not defined In-Reply-To: <1e84807c-aec0-4d04-97a3-1953719f4dc6@8g2000hse.googlegroups.com> References: <1e84807c-aec0-4d04-97a3-1953719f4dc6@8g2000hse.googlegroups.com> Message-ID: <67brugF2najntU1@mid.uni-berlin.de> Lalit schrieb: > Hi > > I am very new to web development. I started with Pylons. I am using > http://www.rexx.com/~dkuhlman/pylons_quick_site.html as reference to > create a sample web page using pylons. > > I got stuck up at step 4.3 i.e when modifying controller to "return > Response('

firstapp default

')" > > I am getting error of : global name > 'Response' is not defined > > It seems I am missing some package. I am not really sure. I installed > python 2.5 and through easy_install imported pakages (pylons). > > Any clues would be appreciated Better ask such questions on the Pylons mailing list. Not that it is inappropriate here - but you will receive better answers because it is more specialized. Anyway, I doubt you miss a package - I'd rather guess you miss an import-statement. Diez From ellingt8877 at gmail.com Mon Apr 28 01:44:30 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:44:30 -0700 (PDT) Subject: 1click dvd copy pro crack Message-ID: 1click dvd copy pro crack http://crack.cracksofts.com From nospam at nospam.blah Tue Apr 29 22:51:14 2008 From: nospam at nospam.blah (JYA) Date: Wed, 30 Apr 2008 12:51:14 +1000 Subject: xml.dom.minidom weirdness: bug? Message-ID: <4817dea2$0$18028$426a34cc@news.free.fr> Hi. I was writing an xmltv parser using python when I faced some weirdness that I couldn't explain. What I'm doing, is read an xml file, create another dom object and copy the element from one to the other. At no time do I ever modify the original dom object, yet it gets modified. Unless I missed something, it sounds like a bug to me. the xml file is simply: full name which I store under the name test.xmltv Here is the code, I've removed everything that isn't applicable to my description. can't make it any simpler I'm afraid: from xml.dom.minidom import Document import xml.dom.minidom def adjusttimezone(docxml, timezone): doc = Document() # Create the base element tv_xml = doc.createElement("tv") doc.appendChild(tv_xml) #Create the channel list channellist = docxml.getElementsByTagName('channel') for x in channellist: #Copy the original attributes elem = doc.createElement("channel") for y in x.attributes.keys(): name = x.attributes[y].name value = x.attributes[y].value elem.setAttribute(name,value) for y in x.getElementsByTagName('display-name'): elem.appendChild(y) tv_xml.appendChild(elem) return doc if __name__ == '__main__': handle = open('test.xmltv','r') docxml = xml.dom.minidom.parse(handle) print 'step1' print docxml.toprettyxml(indent=" ",encoding="utf-8") doc = adjusttimezone(docxml, 1000) print 'step2' print docxml.toprettyxml(indent=" ",encoding="utf-8") Now at "step 1" I will display the content of the dom object, quite natually it shows: full name After a call to adjusttimezone, "step 2" however will show: That's it ! You'll note that at no time do I modify the content of docxml, yet it gets modified. The weirdness disappear if I change the line channellist = docxml.getElementsByTagName('channel') to channellist = copy.deepcopy(docxml.getElementsByTagName('channel')) However, my understanding is that it shouldn't be necessary. Any thoughts on this weirdness ? Thanks Jean-Yves -- They who would give up an essential liberty for temporary security, deserve neither liberty or security (Benjamin Franklin) From paul at boddie.org.uk Thu Apr 24 11:15:55 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Thu, 24 Apr 2008 08:15:55 -0700 (PDT) Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> <480fa6e3$0$34491$742ec2ed@news.sonic.net> Message-ID: On 24 Apr, 16:33, Mike Driscoll wrote: > > This is a legitimate issue and one I don't know how to solve. It would > be nice to have some kind of verification process, but I'm unaware of > anything affordable. If you have any ideas, feel free to express them. It'd be interesting (perhaps amusing) to adopt the infrastructure of one of the GNU/Linux distributions to maintain and distribute packages for Windows users. For a while, I've been tempted to experiment with cross-compilers and to try and produce Windows executables, but for simple Python-only modules, all you'd really need to do to prove the concept is to develop the client-side Windows software (eg. apt-get for Windows) which downloads package lists, verifies signatures, and works out where to put the package contents. Then, you could point your client at the appropriate sources and start obtaining the packages, knowing that there is some level of authenticity in the software you're getting. Of course, a lot of this could be more easily done with Cygwin, even if you disregard Cygwin's own installer, but I imagine that Windows users want the "native" experience. Paul From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Tue Apr 29 09:44:55 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Tue, 29 Apr 2008 15:44:55 +0200 Subject: Simple unicode-safe version of str(exception)? References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> Message-ID: <67on2nF2ol856U1@mid.individual.net> "Martin v. L?wis" wrote: > e is an exception object, not a Unicode object. Er, sure, thanks for pointing that out. At first sight he should substitute "e" with "e.message" then since he tries to convert to string (for display?). Regards, Bj?rn -- BOFH excuse #366: ATM cell has no roaming feature turned on, notebooks can't connect From ch612bunn at gmail.com Sun Apr 27 09:12:09 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:12:09 -0700 (PDT) Subject: anydvd 6.1.7.4 crack Message-ID: <48c6349b-7aa3-49b0-a455-fcebcbfdafa8@27g2000hsf.googlegroups.com> anydvd 6.1.7.4 crack http://wga-cracks.crackkey.net From dave.l.harrison at gmail.com Wed Apr 9 00:34:30 2008 From: dave.l.harrison at gmail.com (David Harrison) Date: Wed, 9 Apr 2008 14:34:30 +1000 Subject: Converting a tuple to a list In-Reply-To: <00ba01c899c5$14528ae0$0a01a8c0@mobile> References: <00ba01c899c5$14528ae0$0a01a8c0@mobile> Message-ID: On 09/04/2008, Gabriel Ibanez wrote: > Hi all .. > > I'm trying to using the map function to convert a tuple to a list, without > success. > > I would like to have a lonely line that performs the same as loop of the > next script: > > ------------------------------------------- > # Conveting tuple -> list > > tupla = ((1,2), (3,4), (5,6)) > > print tupla > > lista = [] > for a in tupla: > for b in a: > lista.append(b) > print lista > ------------------------------------------- > > Any idea ? > > Thanks ... > > # Gabriel Not sure if you were looking for a method that retained the existing nested structure or not, so the following is a recursive way of turning an arbitrarily nested tuple structure into the list based equivalent: a = ((1,2), (3,4), (5,6), (7,(8,9))) def t2l(a): lst = [] for item in a: if type(item) == tuple: lst.append(t2l(item)) else: lst.append(item) return lst print t2l(a) From martin at v.loewis.de Mon Apr 28 18:30:32 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 29 Apr 2008 00:30:32 +0200 Subject: Tremendous slowdown due to garbage collection In-Reply-To: References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> <4814B904.1070804@v.loewis.de> Message-ID: <48165008.4070703@v.loewis.de> > I do not argue that Python's default GC parameters must change -- only > that applications with lots of objects may want to consider a > reconfiguration. That's exactly what I was trying to say: it's not that the parameters are useful for *all* applications (that's why they are tunable parameters), just that the defaults shouldn't change (as the OP was requesting). Regards, Martin From victorsubervi at gmail.com Fri Apr 11 13:46:27 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Fri, 11 Apr 2008 12:46:27 -0500 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> Message-ID: <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> I have worked on this many hours a day for two weeks. If there is an easier way to do it, just take a minute or two and point it out. Have you heard of the Law of Diminishing Returns? I have passed it long ago. I no longer want to waste time trying to guess at what you are trying to tell me. Victor On Fri, Apr 11, 2008 at 8:55 AM, Steve Holden wrote: > Victor Subervi wrote: > > Nope. Do not see it. My ugly stupid way works. I guess I will just > > proceed with that and write my howto accordingly. > > Victor > > > OK, but be prepared for some pretty scathing feedback. You will make it > clear you do not understand the web. I'd suggest a little more reading > first. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gagsl-py2 at yahoo.com.ar Sun Apr 20 04:13:00 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 05:13:00 -0300 Subject: python memory leak only in x86 64 linux References: Message-ID: En Wed, 16 Apr 2008 13:10:42 -0300, rkmr.em at gmail.com escribi?: > This is the code that is causing memory leak in 64 bit python [but not > in 32 bit python].. is something wrong in the code? > > [... Python code using the datetime module ...] >> the memory usage of a python app keeps growing in a x86 64 linux >> continuously, whereas in 32 bit linux this is not the case. Python >> version in both 32 bit and 64 bit linux - 2.6.24.4-64.fc8 >> Python 2.5.1 (r251:54863, Oct 30 2007, 13:45:26) >> >> i isolated the memory leak problem to a function that uses datetime >> module extensively. i use datetime.datetime.strptime, >> datetime.timedelta, datetime.datetime.now methods... In principle pure Python code should have no memory leaks - if there are, they're on Python itself. Maybe this is an allocation problem, not an actual leak; if you can write a program that reproduces the problem, post a bug at http://bugs.python.org -- Gabriel Genellina From vijayakumar.subburaj at gmail.com Mon Apr 14 06:04:27 2008 From: vijayakumar.subburaj at gmail.com (v4vijayakumar) Date: Mon, 14 Apr 2008 03:04:27 -0700 (PDT) Subject: Game design : Making computer play References: Message-ID: On Apr 14, 1:00 pm, v4vijayakumar wrote: ... > I can post initial version of the game (implemented using html/ > javascript) in couple of hours here. The game is here, http://v4vijayakumar.googlepages.com/goats-and-tigers.html From ed at leafe.com Tue Apr 1 10:21:48 2008 From: ed at leafe.com (Ed Leafe) Date: Tue, 1 Apr 2008 09:21:48 -0500 Subject: class super method In-Reply-To: <0eb3ee4e-82e2-419a-8e7b-4931f7b4effa@c26g2000prf.googlegroups.com> References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> <0eb3ee4e-82e2-419a-8e7b-4931f7b4effa@c26g2000prf.googlegroups.com> Message-ID: On Apr 1, 2008, at 8:43 AM, George Sakkis wrote: > Did you follow the links I gave by any chance? With all the gotchas > and rules of how to use it properly, it's far from what I would call > elegant. Please. Anything powerful can be dangerous if used indiscriminately. But in a language that supports multiple inheritance, it is amazingly elegant to use a simple function to create a superclass object for a class with multiple mixins at various levels of the inheritance hierarchy that "just works". Yes, having to specify the current class is a bit of a wart that is being addressed in 3.0, but the approach is still the same. > Pehaps, at least as long as you make sure that all superclasses have a > compatible signature - which in practice typically means accept > arbitrary *args and **kwargs in every class in the hierarchy like your > example. Good luck figuring out what's wrong if it's not used > consistently. See my comment above. If you do not know what you're doing, you shouldn't be doing it. This is not the fault of super(); it's the fault of a poor programmer. And I used generic *args and **kwargs in the method sig since I was using made-up class names and methods. Would you have reacted more favorably if I had used (self, foo, bar) instead? > Also doOurCustomStuffBeforeTheSuperCall() works as long as all > ancestor methods to be called need the same CustomStuff massaging. Oh, c'mon. Of course that's the case; if you are overriding method behavior, it is your job as the programmer to ensure that. Again, this is nothing to do with the super() function, and everything to do with the abilities of the developer. > In a sentence, it's better than nothing but worse than anything. I guess I must be the world's most amazing Python developer, as I've used super() extensively for years without ever suffering any of the pitfalls you and others describe. -- Ed Leafe From gagsl-py2 at yahoo.com.ar Wed Apr 30 03:44:44 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 30 Apr 2008 04:44:44 -0300 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> Message-ID: En Wed, 30 Apr 2008 04:19:22 -0300, SL escribi?: > "Lutz Horn" schreef in bericht > news:mailman.360.1209537877.12834.python-list at python.org... >> >> So just for completion, the solution is: >> >>>>> chr(ord('a') + 1) >> 'b' > > thanks :) I'm a beginner and I was expecting this to be a member of > string so I couldnt find it anywhere in the docs. And that's a very reasonable place to search; I think chr and ord are builtin functions (and not str methods) just by an historical accident. (Or is there any other reason? what's wrong with "a".ord() or str.from_ordinal(65))? -- Gabriel Genellina From cmpython at gmail.com Thu Apr 10 00:25:37 2008 From: cmpython at gmail.com (CM) Date: Wed, 9 Apr 2008 21:25:37 -0700 (PDT) Subject: How is GUI programming in Python? References: Message-ID: <1bee1004-81f5-4460-9451-25caf3738269@b64g2000hsa.googlegroups.com> On Apr 9, 9:54 pm, Chris Stewart wrote: > I've always had an interest in Python and would like to dabble in it > further. I've worked on a few very small command line programs but > nothing of any complexity. I'd like to build a really simple GUI app > that will work across Mac, Windows, and Linux. How painful is that > going to be? I used to be really familiar with Java Swing a few years > ago. I imagine it will be similar. > > Next, what would you say is the best framework I should look into? > I'm curious to hear opinions on that. > > Chris Stewart > cstewart... at gmail.com I've enjoyed using wxPython. Mature, active, native controls, lots o' widgets, killer demo, great community, cross platform (with some tweaking sometimes). From wizzardx at gmail.com Sun Apr 27 11:20:29 2008 From: wizzardx at gmail.com (David) Date: Sun, 27 Apr 2008 17:20:29 +0200 Subject: python and web programming, easy way...? In-Reply-To: <75679853-b5de-42cb-9db2-a1508f2ad67e@59g2000hsb.googlegroups.com> References: <2db36ccf-c9fd-4e7a-9697-fd5c23159287@j22g2000hsf.googlegroups.com> <75679853-b5de-42cb-9db2-a1508f2ad67e@59g2000hsb.googlegroups.com> Message-ID: <18c1e6480804270820s2858cb66m86b668ee48d0fd00@mail.gmail.com> > > www.webpy.org is supereasy to get going with. dont know which is > better for advanced stuff. > I don't think that webpy supports sessions. Their addition to webpy is a Google Summer of Code project: http://webpy.org/sessions/gsoc Also, I can't find any reference to cookies or sessions in the webpy online docs. Maybe it's possible to bolt on support with Python's Cookie module. David. From george.sakkis at gmail.com Thu Apr 24 00:41:18 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 23 Apr 2008 21:41:18 -0700 (PDT) Subject: Problem using copy.copy with my own class References: <676noiF2n7ttmU1@mid.uni-berlin.de> Message-ID: On Apr 23, 9:48?pm, Jeffrey Barish wrote: > > Here it is: > > import copy > > class Test(int): > ? ? def __new__(cls, arg1, arg2): > ? ? ? ? return int.__new__(cls, arg1) > > ? ? def __init__(self, arg1, arg2): > ? ? ? ? self.arg2 = arg2 > > if __name__ == '__main__': > ? ? t = Test(0, 0) > ? ? t_copy = copy.copy(t) First off, inheriting from a basic builtin type such as int and changing its constructor's signature is not typical; you should rethink your design unless you know what you're doing. One way to make this work is to define the special __copy__ method [1], specifying explicitly how to create a copy of a Test instance: class Test(int): ... def __copy__(self): return Test(int(self), self.arg2) The copy.copy() function looks for this special method and invokes it if it's defined. Normally (i.e. for pure Python classes that don't subclass a builtin other than object) copy.copy() is smart enough to know how to create a copy without an explicit __copy__ method, so in general you don't have to define it for every class that has to be copyable. > Traceback (most recent call last): > ? File "copytest.py", line 12, in > ? ? t_copy = copy.copy(t) > ? File "/usr/lib/python2.5/copy.py", line 95, in copy > ? ? return _reconstruct(x, rv, 0) > ? File "/usr/lib/python2.5/copy.py", line 322, in _reconstruct > ? ? y = callable(*args) > ? File "/usr/lib/python2.5/copy_reg.py", line 92, in __newobj__ > ? ? return cls.__new__(cls, *args) > TypeError: __new__() takes exactly 3 arguments (2 given) The traceback is not obvious indeed. It turns out it involves calling the arcane __reduce_ex__ special method [2] defined for int, which returns a tuple of 5 items; the second is the tuple (, 0) and these are the arguments passed to Test.__new__. So another way of fixing it is keep Test.__new__ compatible with int.__new__ by making optional all arguments after the first: class Test(int): def __new__(cls, arg1, arg2=None): return int.__new__(cls, arg1) # don't need to define __copy__ now from copy import copy t = Test(0, 0) assert copy(t) == t As a sidenote, your class works fine without changing anything when pickling/unpickling instead of copying, although pickle calls __reduce_ex__ too: from pickle import dumps,loads t = Test(0, 0) assert loads(dumps(t)) == t Perhaps someone more knowledgeable can explain the subtle differences between pickling and copying here. George [1] http://docs.python.org/lib/module-copy.html [2] http://docs.python.org/lib/node320.html From spamgrinder.trylater at gmail.com Thu Apr 17 10:06:08 2008 From: spamgrinder.trylater at gmail.com (AlFire) Date: Thu, 17 Apr 2008 09:06:08 -0500 Subject: why function got dictionary Message-ID: <48075950.7050000@gmail.com> Hi, I am seeking an explanation for following: Python 2.5.2 (r252:60911, Apr 8 2008, 21:49:41) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def g(): return ... >>> g.__dict__ {} Q: why function got dictionary? What it is used for? Thx, Andy From pavlovevidence at gmail.com Tue Apr 15 09:25:16 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 15 Apr 2008 06:25:16 -0700 (PDT) Subject: text adventure game problem References: Message-ID: <3f1023c9-97c1-40b5-8a28-0b89bf79fba1@c65g2000hsa.googlegroups.com> On Apr 11, 12:08 pm, "Neil Cerutti" wrote: > On Thu, Apr 10, 2008 at 8:25 PM, Carl Banks wrote: > > On Apr 10, 2:20 pm, Tommy Nordgren wrote: > > > > On 9 apr 2008, at 03.01, corvettecra... at gmail.com wrote: > > > > > okay, I'm having this one problem with a text adventure game. It's > > > > kind of hard to explain, but I'll do my best. > > > > [code] > > > > > def prompt_kitchen(): > > > > global gold > > > > Python is not a suitable language for Text Adventure Development. > > > Ridiculous. > > Agreed. "Not suitable" is an exaggeration. However, designing and > implementing your own adventure game framework in Python is a total > waste of time. That depends. > Don't do it excet for the sake of it. > > You can even claim one of several Python-based frameworks out of > mothballs as a starting point, if you want to use Python. > > > There are many good reasons why someone might want to use a general > > purpose language like Python to write a text adventure, > > Yes. > > > such as so > > they're not stuck with a quasi hack of a language if they have to do > > something that doesn't fit the framework anticipated by the language > > designer. > > That's not a reason, it's FUD. No, it's prudence. If I am writing a banal, been-done-a-million-times before, cookie- cutter text adventure, yes I'd just use a domain-specific language. If I am writing a unique game that does new things, sooner or later I'm going to want to do something the designer of the domain-specific language and framework didn't anticipate. And there is no uncertainty or doubt about this: when it comes to that, I don't want to be restrained by a narrow framework or domain-specific language, and I would want to be using Python, and it isn't even remotely close. The only question would be whether there's enough general purpose programming required that it would outweigh the extra work. Which, let's be honest, is not all that much for a text adventure. Carl Banks From tjreedy at udel.edu Wed Apr 23 15:10:04 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 23 Apr 2008 15:10:04 -0400 Subject: Partition list with predicate References: <925822270804230959v557ec5f5re02737709f94d3c6@mail.gmail.com> Message-ID: "Jared Grubb" wrote in message news:925822270804230959v557ec5f5re02737709f94d3c6 at mail.gmail.com... | I want a function that removes values from a list if a predicate evaluates | to True. Forget the rigamarole you posted, which has several defects. If you must modify the list in place, because you have multiple references to it: lst[:] = filter(lambda x: not pred(x), lst) Otherwise, just lst = filter(....) tjr From codewarrior at mail.com Thu Apr 3 14:21:34 2008 From: codewarrior at mail.com (kc) Date: Thu, 03 Apr 2008 13:21:34 -0500 Subject: urllib and bypass proxy Message-ID: Under MS Windows, I encountered a problem with the proxy bypass specification. In windows, the bypass specification for the proxy uses semi-colons to delimit entries. Mine happens to have two semi-colons back-to-back. Internet explorer handles this just fine but urllib equates this with ALWAYS bypass the proxy. (I'm using Python 2.5.2) This is caused because the double semi-colon is turned into an empty string entry and at the bottom of urllib.py, and empty string can always be found in a host name. Therefore it always chooses to bypass the proxy. Of course the fix is to get rid of the double colon in the bypass settings in internet explorer (which I did). But it took me an hour to track this down (first time using urllib). Perhaps a better fix would be to test for the empty string and continue the loop in that case. From urllib.py: # now check if we match one of the registry values. for test in proxyOverride: if test == "": continue test = test.replace(".", r"\.") # mask dots This is not really a bug but rather a way to be more consistent with internet explorer. If this has value, do I submit a bug report or does someone else? From mellit at gmail.com Wed Apr 23 04:36:08 2008 From: mellit at gmail.com (Anton Mellit) Date: Wed, 23 Apr 2008 01:36:08 -0700 (PDT) Subject: overriding = operator References: <23874e00-e22e-43d8-a4e7-a2a101eb822f@a1g2000hsb.googlegroups.com> Message-ID: <328e1b72-99aa-4a0b-9712-4ab231df8156@d45g2000hsc.googlegroups.com> On Apr 22, 3:54 pm, Paul McGuire wrote: > On Apr 22, 8:47 am, "Anton Mellit" wrote: > > > > > I need something like > > 'overriding' =, which is impossible, but I look for a systematic > > approach to do something instead. It seems there are two ways to do > > what I need: > > > 1. Implement a method 'assign' which generates the corresponding code > > to store value: > > > z.assign(x + y) > > > 2. Do the same as 1., but via property set methods. For example, this > > would look cleaner: > > > z.value = x + y > > > Which of these is preferrable? Does anyone know any alternative ways? > > > Anton > > If you are willing to accept '<<=' as meaning 'assign to existing' > instead of 'left shift in place', you can override this operator using > the __ilshift__ method. > > We used this technique in C++/CORBA code back in the 90's to "inject" > values into CORBA::Any variables. > > -- Paul Great idea! It conflicts with 'left shift in place', which i also need, but '=' seems more important. Anton From john106henry at hotmail.com Mon Apr 14 15:02:20 2008 From: john106henry at hotmail.com (John Henry) Date: Mon, 14 Apr 2008 12:02:20 -0700 (PDT) Subject: =?GB2312?B?UmU6INPQ1tC5+sjLuvU/?= References: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> <4801F702.5050401@arcor.de> Message-ID: On Apr 14, 11:17 am, Steve Holden wrote: > Penny Y. wrote: > > Steve Holden ??: > > >> ????????, ????????? > > > What do you mean? > > If I understand you correctly, maybe it should be, > > > ??python??????,??????. > > > Am I right? > > I have no idea. Babelfish (from which I obtained my reply as well as > whatever understanding I had of the original inquiry) translated my reply as > > But the academic society never is immediately, with will need time > > whereas yours becomes > > Studies python not to be possible on first to become, needs to proceed > in an orderly way > > Since what I entered in English was something like "Yes, Python has a > future. But it will take some study". Perhaps you can tell me whether > your translation gives the correect flavor. I'm pretty sure the > babelfish mangled my intent. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ ROFL I would not recomend using babalfish to translate between Chinese and English. It does a *horrible* job at that. But then in this particular case, it was able to convey what you wanted to say - in a rather awkward fashion. :-) From sturlamolden at yahoo.no Thu Apr 24 20:27:33 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 17:27:33 -0700 (PDT) Subject: Psyco alternative References: <1369b321-f55b-432b-b2f9-6144787509d8@h11g2000prf.googlegroups.com> <7xlk4473ai.fsf@ruckus.brouhaha.com> <651ncdF2cmik2U1@mid.uni-berlin.de> <651onqF2dripdU1@mid.uni-berlin.de> <2f3a59c2-ef31-426a-be34-bdb187ea3b22@c19g2000prf.googlegroups.com> Message-ID: On Mar 28, 8:06 pm, Paul Boddie wrote: > From what I've seen from browsing publicly accessible materials, > there's a certain commercial interest in seeing Psyco updated > somewhat. YouTube uses Psyco. From andre.roberge at gmail.com Fri Apr 4 09:54:40 2008 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Fri, 4 Apr 2008 06:54:40 -0700 (PDT) Subject: Looking for Advanced Python Tutorials References: Message-ID: <5d1d97e6-c7bc-4746-8e49-acaefc4cad3d@24g2000hsh.googlegroups.com> On Apr 4, 8:58 am, cokofree... at gmail.com wrote: > I was wondering if anyone knew of some online (free if possible) > advanced tutorials, especially ones that provides tasks and ideas for > small projects. The issue for myself is I want to improve my python > programming level, and my ability to program in general, but come up > blank thinking of a possible task or project to undertake. So with > that in mind I thought I'd ask the community if they knew of sites or > books to read up on and use as a starting block. Of course project > ideas would be great as well! > I suggest a different alternative: join an open source project. Andr? > Thanks for any help you can provide. > > Coko From nigamreetesh84 at gmail.com Wed Apr 16 04:35:29 2008 From: nigamreetesh84 at gmail.com (reetesh nigam) Date: Wed, 16 Apr 2008 01:35:29 -0700 (PDT) Subject: how turbo geras code works Message-ID: hi. actually i have developed one small project but now i want to develope a project with the help of html.. please help me out From doug.farrell at gmail.com Fri Apr 4 17:06:28 2008 From: doug.farrell at gmail.com (writeson) Date: Fri, 4 Apr 2008 14:06:28 -0700 (PDT) Subject: Python2.5 and MySQLdb Message-ID: Hi all, I'm running a CentOS 4 server and have installed Python2.5 on there (it's our development machine) in preparation of moving to Python2.5 everywhere. All looks good with our code and 2.5, except where it comes to MySQLdb, I can't get that to install on the machine. It generates a huge lists of errors and warnings from gcc when I run the python2.5 setup.py build script that comes with the tar file. Anyone have any suggestions? Thanks, Doug From skunkwerk at gmail.com Mon Apr 7 19:52:54 2008 From: skunkwerk at gmail.com (skunkwerk) Date: Mon, 7 Apr 2008 16:52:54 -0700 (PDT) Subject: popen pipe limit Message-ID: I'm getting errors when reading from/writing to pipes that are fairly large in size. To bypass this, I wanted to redirect output to a file in the subprocess.Popen function, but couldn't get it to work (even after setting Shell=True). I tried adding ">","temp.sql" after the password field but mysqldump gave me an error. the code: p1 = subprocess.Popen(["mysqldump","--all-databases","--user=user","-- password=password"], shell=True) p2 = subprocess.Popen(["gzip","-9"], stdin=p1.stdout) output = p2.communicate()[0] file=open('test.sql.gz','w') file.write(str(output)) file.close() the output: gzip: compressed data not written to a terminal. Use -f to force compression. For help, type: gzip -h mysqldump: Got errno 32 on write I'm using python rather than a shell script for this because I need to upload the resulting file to a server as soon as it's done. thanks From colas.francis at gmail.com Fri Apr 11 06:27:44 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Fri, 11 Apr 2008 03:27:44 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> On 11 avr, 12:14, bdsatish wrote: > The built-in function round( ) will always "round up", that is 1.5 is > rounded to 2.0 and 2.5 is rounded to 3.0. > > If I want to round to the nearest even, that is > > my_round(1.5) = 2 # As expected > my_round(2.5) = 2 # Not 3, which is an odd num > > I'm interested in rounding numbers of the form "x.5" depending upon > whether x is odd or even. Any idea about how to implement it ? When you say "round to the nearest even", you mean new_round(3) <> 3? Is so, you can try: In [37]: def new_round(x): ....: return round(x/2.)*2 ....: In [38]: new_round(1.5) Out[38]: 2.0 In [39]: new_round(2.5) Out[39]: 2.0 In [40]: new_round(3) Out[40]: 4.0 From nick at stinemates.org Fri Apr 18 14:32:15 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 11:32:15 -0700 Subject: py3k s***s In-Reply-To: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> Message-ID: <20080418183215.GC19281@deviL> On Mon, Apr 14, 2008 at 04:10:48PM -0700, Sverker Nilsson wrote: > do i dare to open a thread about this? > > come on you braver men > > we are at least not bought by g***le > > but why? others have said it so many times i think > > :-//// > > but why? a few syntactic 'cleanups' for the cost of a huge rewrite of > all the code that have been builtup from all the beginning when the > once great Python came along and people began to use it and write code > for it. Like all that code would have to be rewritten. blaah. > and i have perhaps been drinking but i have been p**d all week since i > began look into this:-( > -- > http://mail.python.org/mailman/listinfo/python-list Yo, no one here is a child so don't litter your title and text with hard to read bullshit. -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From hexusnexus at gmail.com Wed Apr 2 00:43:36 2008 From: hexusnexus at gmail.com (hexusnexus at gmail.com) Date: Tue, 1 Apr 2008 21:43:36 -0700 (PDT) Subject: Basic class implementation question Message-ID: I can't get call a class for some reason. This must be one of those newbie questions I hear so much about: class wontwork: def really(): print "Hello World" wontwork.really() This returns (as an error): Traceback (most recent call last): File "", line 1, in wontwork.really() TypeError: unbound method really() must be called with wontwork instance as first argument (got nothing instead) Any ideas? From cyril.giraudon at gmail.com Mon Apr 28 16:53:26 2008 From: cyril.giraudon at gmail.com (cyril giraudon) Date: Mon, 28 Apr 2008 13:53:26 -0700 (PDT) Subject: descriptor & docstring References: Message-ID: <0d65e5e6-82a9-48a1-aa90-f709f4431213@z72g2000hsb.googlegroups.com> A precision, I use python 2.5.2 under linux mandiva 2007.0 Cyril. From arnodel at googlemail.com Thu Apr 3 10:00:32 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 3 Apr 2008 07:00:32 -0700 (PDT) Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> <10ee2a69-f4e2-4887-8083-6b02b60dd0cd@i7g2000prf.googlegroups.com> <130ad0b4-504c-4b19-85fc-1bd700590ccf@u10g2000prn.googlegroups.com> Message-ID: <8d2b1900-55ba-4bca-b8e8-b9969b99ae60@i36g2000prf.googlegroups.com> On Apr 3, 11:10?am, Jo?o Neves wrote: > On Apr 3, 4:43 am, Scott David Daniels wrote: > > > Nope: ?If you change the code in-place, the whole stack's references > > to where they were running would need to get updated to corresponding > > locations in the new code. ?_That_ is a lot of work. > > Ah, there it is. Now I get it, it makes perfect sense. > Looks like I'll have to stick to the usual mechanisms! > Thanks everyone! > > --- > Jo?o Neves FWIW, when I need to 'modify' a code object / function object I use the following functions: from new import code, function code_args = ( 'argcount', 'nlocals', 'stacksize', 'flags', 'code', 'consts', 'names', 'varnames', 'filename', 'name', 'firstlineno', 'lnotab', 'freevars', 'cellvars' ) function_args = ('code', 'globals', 'name', 'defaults', 'closure') def copy_code(code_obj, **kwargs): "Return a copy of a code object, maybe changing some attributes" for arg in code_args: if not kwargs.has_key(arg): kwargs[arg] = getattr(code_obj, 'co_%s' % arg) return code(*map(kwargs.__getitem__, code_args)) def copy_function(func_obj, **kwargs): "Return a copy of a function object, maybe changing some attributes)" for arg in function_args: if not kwargs.has_key(arg): kwargs[arg] = getattr(func_obj, 'func_%s' % arg) return function(*map(kwargs.__getitem__, function_args)) # E.g. to change the code object of a function: f = copy_function(f, code=new_code_object) From needin4mation at gmail.com Wed Apr 9 08:04:20 2008 From: needin4mation at gmail.com (jmDesktop) Date: Wed, 9 Apr 2008 05:04:20 -0700 (PDT) Subject: I am worried about Python 3 Message-ID: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> I am a new Python programmer. I have always desired to learn Python, but have never had the opportunity. Recently this has changed, and I have an opportunity to get away from the .NET framework. I found Django (and other web frameworks) and began my quest to learn. I started reading Dive Into Python and anything I could find and started participating here in usenet. Then I had to read this: http://www.comp.leeds.ac.uk/nde/papers/teachpy3.html I think that every time I start a new technology (to me) it is about to change. Yes, I know that is the nature of things, but I'm always at the start of "something new." If I continue in Python 2.5.x, am I making a mistake? Is it really that different? Here is an excerpt that is causing me concern: Two new versions of the language are currently in development: version 2.6, which retains backwards compatibility with previous releases; and version 3.0, which breaks backwards compatibility to the extent that even that simplest of programs, the classic 'Hello, World', will no longer work in its current form. It makes me feel like I am wasting my time and makes it difficult to justify spending time on projects using 2.5.x and using it where I work. From hdante at gmail.com Fri Apr 11 10:29:31 2008 From: hdante at gmail.com (hdante) Date: Fri, 11 Apr 2008 07:29:31 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <31872ffc-5bc4-44c8-961d-ee4f0dc356c5@k1g2000prb.googlegroups.com> <700b1a5f-0af0-466e-abda-4d8dc784dbaa@e67g2000hsa.googlegroups.com> <220fa9fa-3ad3-4d58-b90c-478f936b5352@m1g2000pre.googlegroups.com> Message-ID: <6d63626e-8868-46e7-9a69-0ed870751263@m3g2000hsc.googlegroups.com> On Apr 11, 11:13 am, Ivan Illarionov wrote: > > Shorter version: > def round3k(x): > return x % 1 != 0.5 and round(x) or round(x / 2.) * 2. Strangely, a "faster" version is: def fast_round(x): if x % 1 != 0.5: return round(x) return 2.0*round(x/2.0) > > nums = [ 0, 2, 3.2, 3.6, 3.5, 2.5, -0.5, -1.5, -1.3, -1.8, -2.5, 0.6, > 0.7 ] > rnums = [ 0, 2, 3.0, 4.0, 4.0, 2.0, -0.0, -2.0, -1.0, -2.0, -2.0, 1.0, > 1.0 ] You shouldn't remove assertions in the smaller version. :-P > > for num, rnum in zip(nums, rnums): > assert even_round(num) == rnum, '%s != %s' % (even_round(num), > rnum) > print num, '->', even_round(num) > > It makes sense to add `from __future__ import even_round` to Python > 2.6. From python-url at phaseit.net Mon Apr 14 09:54:29 2008 From: python-url at phaseit.net (Gabriel Genellina) Date: Mon, 14 Apr 2008 13:54:29 +0000 (UTC) Subject: Python-URL! - weekly Python news and links (Apr 14) Message-ID: QOTW: "This for me is Python's chief selling point: dir()....dir() and help(). Python's two selling points are dir(), help(), and very readable code. Python's *three* selling points are dir(), help(), very readable code, and an almost fanatical devotion to the BFDL. Amongst Python's selling points ..." http://groups.google.com/group/comp.lang.python/msg/8723cc7522ddbac5 "Personally, I seem to get the most bang for my buck showing sysadmins Python generators. You can do some interesting things processing huge data files, infinite data streams, and other things with generators. This resonates well and is unusual enough to avoid debates where someone is going to argue that Python is just the same as Bash/Perl/Awk, etc." - David Beazley http://mail.python.org/pipermail/advocacy/2008-April/000562.html Rounding x.5 to nearest even number (and why it should/should not be done) http://groups.google.com/group/comp.lang.python/browse_thread/thread/9e505c8834893818/ Trying to implement readonly class properties - eventually only a Javaism: http://groups.google.com/group/comp.lang.python/browse_thread/thread/ffcc2e483e6edba6/ Demistifying the incompatible changes that will come Python 3.0: http://groups.google.com/group/comp.lang.python/browse_thread/thread/6b2112321b437af9/ Chris Lambacher nicely analyzes 3.0 for the working Pythoneer: http://opag.ca/pipermail/opag/2008-April/002734.html Seasoned developers comment on three beginners' code: http://groups.google.com/group/comp.lang.python/browse_thread/thread/22d663454f4760a7/ http://groups.google.com/group/comp.lang.python/browse_thread/thread/de537debd28cbd32/ http://groups.google.com/group/comp.lang.python/browse_thread/thread/e6fb4ad98c49ef87/ Selecting a database and/or ORM to start learning: http://groups.google.com/group/comp.lang.python/browse_thread/thread/9ee48781edc9ac4f/ A C program embeds Python: should it use multiple interpreters or multiple threads? http://groups.google.com/group/comp.lang.python/browse_thread/thread/68c0980f3db11615/ ======================================================================== Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. Just beginning with Python? This page is a great place to start: http://wiki.python.org/moin/BeginnersGuide/Programmers The Python Papers aims to publish "the efforts of Python enthusiats": http://pythonpapers.org/ The Python Magazine is a technical monthly devoted to Python: http://pythonmagazine.com Readers have recommended the "Planet" sites: http://planetpython.org http://planet.python.org comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Python411 indexes "podcasts ... to help people learn Python ..." Updates appear more-than-weekly: http://www.awaretek.com/python/index.html Steve Bethard continues the marvelous tradition early borne by Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim Lesher of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to capture useful and interesting recipes. http://aspn.activestate.com/ASPN/Cookbook/Python Many Python conferences around the world are in preparation. Watch this space for links to them. Among several Python-oriented RSS/RDF feeds available are http://www.python.org/channews.rdf http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi http://python.de/backend.php For more, see http://www.syndic8.com/feedlist.php?ShowMatch=python&ShowStatus=all The old Python "To-Do List" now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse http://www.python.org/dev/peps/pep-0042/ The online Python Journal is posted at pythonjournal.cognizor.com. editor at pythonjournal.com and editor at pythonjournal.cognizor.com welcome submission of material that helps people's understanding of Python use, and offer Web presentation of your work. del.icio.us presents an intriguing approach to reference commentary. It already aggregates quite a bit of Python intelligence. http://del.icio.us/tag/python *Py: the Journal of the Python Language* http://www.pyzine.com Archive probing tricks of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 http://groups.google.com/groups?meta=site%3Dgroups%26group%3Dcomp.lang.python.* Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://www.ddj.com/topic/python/ (requires subscription) http://groups-beta.google.com/groups?q=python-url+group:comp.lang.python*&start=0&scoring=d& http://purl.org/thecliff/python/url.html (dormant) or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python There is *not* an RSS for "Python-URL!"--at least not yet. Arguments for and against are occasionally entertained. Suggestions/corrections for next week's posting are always welcome. E-mail to should get through. To receive a new issue of this posting in e-mail each Monday morning (approximately), ask to subscribe. Mention "Python-URL!". Write to the same address to unsubscribe. -- The Python-URL! Team-- Phaseit, Inc. (http://phaseit.net) is pleased to participate in and sponsor the "Python-URL!" project. Watch this space for upcoming news about posting archives. From Robert.Bossy at jouy.inra.fr Mon Apr 14 07:44:22 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Mon, 14 Apr 2008 13:44:22 +0200 Subject: =?GB2312?B?tPC4tDogSmF2YSBvciBDKys/?= In-Reply-To: <20080414085431.D8751187B00@mail-in-14.arcor-online.net> References: <20080414085431.D8751187B00@mail-in-14.arcor-online.net> Message-ID: <48034396.1090609@jouy.inra.fr> Penny Y. wrote: > Perl is a functional language I guess you mean functional in the sense it works. RB From gagsl-py2 at yahoo.com.ar Fri Apr 4 16:09:33 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 04 Apr 2008 17:09:33 -0300 Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? References: <47F67798.3060401@gmail.com> Message-ID: En Fri, 04 Apr 2008 15:46:48 -0300, Alex9968 escribi?: > Nebur wrote: >> No, I can't reproduce it, and I don't know whom to blame (Pydev? >> Eclipse ? The File System ? A Virus that only 2 times in half a year >> deletes a single file I'm busy working with, and seems to do nothing >> else? Myself beeing schizophrenic ??) > A virus created to remind you 2 times in half a year of the importance > of backup operations ;-) . I'm joking. I don't know what is this, but > I'm interested. Because my files won't be restorable from version > control :-( Then implement it! It's not so difficult, less if you're the only one working on the files. -- Gabriel Genellina From ivan.illarionov at gmail.com Mon Apr 21 17:30:04 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Mon, 21 Apr 2008 14:30:04 -0700 (PDT) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> Message-ID: On 22 ???, 01:01, Peter Otten <__pete... at web.de> wrote: > Ivan Illarionov wrote: > > And even faster: > > a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, > > len(s), 3)))) > > if sys.byteorder == 'little': > > a.byteswap() > > > I think it's a fastest possible implementation in pure python > > Clever, but note that it doesn't work correctly for negative numbers. For > those you'd have to prepend "\xff" instead of "\0". > > Peter Thanks for correction. Another step is needed: a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, len(s), 3)))) if sys.byteorder == 'little': a.byteswap() result = [n if n < 0x800000 else n - 0x1000000 for n in a] And it's still pretty fast :) From usenet-mail at markshroyer.com Mon Apr 21 03:14:57 2008 From: usenet-mail at markshroyer.com (Mark Shroyer) Date: Mon, 21 Apr 2008 03:14:57 -0400 Subject: Is massive spam coming from me on python lists? References: Message-ID: In article , Brian Vanderburg II wrote: > I've recently gotten more than too many spam messages and all say > Sender: python-list-bounces+my=email.address at python.org. I'm wondering > if my mail list registration is now being used to spam myself and > others. If so, sorry, but I'm not the one sending messages if other are > getting them even though Sender seems to include my address (I'm not > sure about mail headers so I don't know how From: is different than > Sender:) Anyway, it seems to be a bunch of spam emails about cracks and > stuff. > > Brian Vanderburg II Nah, if anyone owes anybody an apology, then whatever mail server admins decided that it would be a good idea to accept SMTP messages before actually determining that the RCPT TO address is, in fact, deliverable, thereby creating a deluge of backscatter and filling up your inbox, should be groveling on their knees and begging *you* for forgiveness. ;) (I haven't seen any such spam messages myself; but the way I'm set up, I wouldn't receive them even if that is the case.) -- Mark Shroyer, http://markshroyer.com/contact/ I have joined others in blocking Google Groups due to excessive spam. If you want more people to see your posts, you should use another means of posting to Usenet. http://improve-usenet.org/ From lipingffeng at gmail.com Thu Apr 3 19:52:31 2008 From: lipingffeng at gmail.com (lipingffeng at gmail.com) Date: Thu, 3 Apr 2008 16:52:31 -0700 (PDT) Subject: how to do "load script; run script" in a loop in embedded python? Message-ID: <352f4111-94b5-4aa9-917b-90cd56a5f7d6@s8g2000prg.googlegroups.com> Hi, all, I am currently involved in a project that needs to load/run a python script dynamically in a C application. The sample code is as following: PyObject *LoadScript(char *file, char *func) { PyObject *pName, *pModule, *pDict, *pFunc; pName = PyString_FromString(file); pModule = PyImport_Import(pName); pDict = PyModule_GetDict(pModule); pFunc = PyDict_GetItemString(pDict, func); return pFunc; } int RunScript(PyObject *pFunc, PyObject *arglist) { PyObject *pValue = PyObject_CallFunction(pFunc, "O", arglist); int ret = PyInt_AsLong(pValue); return ret; } int main(int argc, char *argv[]) { PyObject *arglist, *pFunc; char imgData[10]; int ret; for(int i = 0; i < 10; i++) imgData[i] = 48 + i; arglist = Py_BuildValue("s#", imgData, 10); Py_SetProgramName(argv[0]); Py_Initialize(); PySys_SetArgv(argc, argv); for (int k = 0; k < 3; k++) // using loop to imitate dynamic loading/running script { pFunc = LoadScript(argv[1], argv[2]); ret = RunScript(pFunc, arglist); } Py_Finalize(); return 0; } The first loop is perfectly ok, but on the second loop, script loading is successful but running will always fail. Any ideas would be highly apprecicated. Thanks, Liping From a.harrowell at gmail.com Wed Apr 16 08:22:27 2008 From: a.harrowell at gmail.com (TYR) Date: Wed, 16 Apr 2008 05:22:27 -0700 (PDT) Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> <69795448-0534-4aed-a9a0-84f2cd3aea36@s50g2000hsb.googlegroups.com> Message-ID: Who cares? Everyone does their GUI in a browser these days - keep up, Dad. What we need is a pythonic front end. /troll From timaranz at gmail.com Thu Apr 17 17:13:55 2008 From: timaranz at gmail.com (Tim Mitchell) Date: Fri, 18 Apr 2008 09:13:55 +1200 Subject: how do I know if I'm using a debug build of python Message-ID: <4807BD93.8080809@gmail.com> Hi, A quick question: Is there any way for a python script to know if it's being executed by a debug build of python (python_d.exe) instead of python? Thanks Tim From kay.schluehr at gmx.net Sat Apr 5 18:47:47 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 5 Apr 2008 15:47:47 -0700 (PDT) Subject: ANN: pry unit testing framework References: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com> <20080405141329.GD15684@nullcube.com> <20080405213059.GA19741@nullcube.com> Message-ID: <90e7f293-64f7-4cf5-9b89-bf59b56def1f@p25g2000hsf.googlegroups.com> On 5 Apr., 23:54, Steve Holden wrote: > To be fair I wasn't commenting on the whole thread, more on the angry > nature of your final reply, and didn't really consider Kay's remarks > fully. So perhaps I could ask *both* of you to be more civil to each > other, and leave it at that? Storm in a teacup, of course. I'm sure war > won;t be declared about this. Nah, no war. It's more like sports :) http://www.youtube.com/watch?v=ur5fGSBsfq8 Regards, Kay From leoniaumybragg at gmail.com Sat Apr 26 06:55:59 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:55:59 -0700 (PDT) Subject: gothic 3 patch Message-ID: <67f0ceba-6375-4d51-9bce-ffa552ef0dfb@f63g2000hsf.googlegroups.com> gothic 3 patch http://cracks.00bp.com F R E E C R A C K S From landofdreams at gmail.com Wed Apr 30 20:10:42 2008 From: landofdreams at gmail.com (Sam) Date: Wed, 30 Apr 2008 17:10:42 -0700 (PDT) Subject: relative import broken? References: Message-ID: <9c6ba5f9-d65b-4265-baba-fc5d7936781b@d1g2000hsg.googlegroups.com> I also have a problem with relative import; I can't for the life of me figure out how to use the damn thing. I think the main problem is with getting Python to recognize the existence of a package. I have S/ p.py B/ b.py W/ pyw/ u.py ws.py and I'd like to get u.py to import all the other 3 programs. I put empty __init__.py files in all of the above directories (is this necessary?), and even manually added the pathway (r'C:\Myname\S') to sys.path, but when I execute from S import p in u.py Python gives "ImportError: No module named S". It says "No module named X" for essentially any package reference, so I think it's just not recognizing the directories as packages. The docs for relative import make this sound much easier than it is. Thanks in advance, I'm at my wit's end. -Sam On Apr 30, 9:41 am, "test" wrote: > basic noob question here. > > i am trying to reference a package, i have the structure: > > mypack/ > __init__.py > test.py > subdir1/ > __init__.py > mod1.py > subdir2/ > __init__.py > mod2.py > > can someone please tell me why the statement: > > from mypack.subdir1.mod1 import * > > does NOT work from mod2.py nor from test.py? > > instead, if i use: > > from subdir1.mod1 import * > > it works perfectly from test.py. > > ....? > > thank you, > > aj. From jens at aggergren.dk Tue Apr 29 09:15:55 2008 From: jens at aggergren.dk (Jens) Date: Tue, 29 Apr 2008 06:15:55 -0700 (PDT) Subject: Zope/DTML Infuriating... References: <3a955f90-ed80-46be-a238-1462e4fb2d0c@m3g2000hsc.googlegroups.com> Message-ID: On Apr 29, 2:45?pm, Marco Mariani wrote: > Jens wrote: > >> You might have wrong assumptions from previous PHP experiences. > > >> ?>>> 'x'+4 > >> Traceback (most recent call last): > >> ? ?File "", line 1, in > >> TypeError: cannot concatenate 'str' and 'int' objects > > > ... and the non snobby answer would have been: > > > ... ? > > Sorry. Not trying to be snobbish, only in a hurry. > > That answer would have been less useful, because there are TONS of > details in the python tutorial, that set the language apart from its > "scripting cousins". > Reading the syntax and thinking "yeah, got it, boring, next chapter" is > a common mistake I've also made sometime, especially with python when > I've been deceived by its apparent simplicity. > Then, later, the same happened with Javascript, of course. > And it's bound to happen again, as much as I'll try to be careful :-( Hey no worriest. Is this the tutorial you're referring to: http://docs.python.org/lib/typesmapping.html Is there anything better? I miss the discussion and examples that accompany most entries in php.net. From cwitts at gmail.com Thu Apr 17 06:46:37 2008 From: cwitts at gmail.com (Chris) Date: Thu, 17 Apr 2008 03:46:37 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <52vid5-cvl2.ln1@ozzie.tundraware.com> <87hce1t8k5.fsf@physik.rwth-aachen.de> Message-ID: <10fb879a-7011-4bf8-94f1-de57693c8d4f@t54g2000hsg.googlegroups.com> On Apr 17, 11:49?am, Marco Mariani wrote: > Torsten Bronger wrote: > >>> If I were you I would keep it a secret until a Hollywood producer > >>> offers big bucks for the film rights. > >> Who would play Guido, I wonder? > > > Ralf M?ller. ?No other. > > And the GIL killer? > > Clive Owen, Matt Damon, Mark Wahlberg? Marky Mark ftw, he could even rap about it his method. From sbergman27 at gmail.com Thu Apr 17 23:57:41 2008 From: sbergman27 at gmail.com (Steve Bergman) Date: Thu, 17 Apr 2008 20:57:41 -0700 (PDT) Subject: How to make this unpickling/sorting demo faster? References: <40a5d8f1-a246-4c48-8759-5b65324f9029@m73g2000hsh.googlegroups.com> <7xod88w5l5.fsf@ruckus.brouhaha.com> <672d4491-35b5-4eb5-94bc-13d4b23ba797@d45g2000hsc.googlegroups.com> <7xd4ooc81b.fsf@ruckus.brouhaha.com> Message-ID: <815a6208-8a07-4772-8646-a16fa7087ec9@a23g2000hsc.googlegroups.com> On Apr 17, 7:37?pm, Paul Rubin wrote: > Therefore the likelihood of a C or asm program > being 20x faster including disk i/o is dim. ?But realistically, > counting just CPU time, you might get a 20x speedup with assembler if > you're really determined, using x86 SSE (128-bit vector) instructions, > cache prefetching, etc. I think that the attitude that is prevalent is that although Python and other "interpreted" languages are slow, there are places where that slowness is not important and using them is OK. The point that I am trying to make with my example is that often, by leveraging the care and optimization work that others have put into the Python standard library over the years, a rather casual programmer can match or better the performance of 'average' C code. i.e. C code that was written by a good C programmer while no one was looking over his shoulder, and no pressures motivated him to spend a lot of time optimizing the C to the hilt, or switching to asm. With the reading and writing of the data (which actually works out to about 23MB, marshalled) now down to 1 second each, I'm content. In the beginning, the io time was overshadowing the sort time by a good bit. And it was the sort time that I wanted to highlight. BTW, no one has responded to my challenge to best the original sample Python code with C, C++, or asm. From bruno.desthuilliers at gmail.com Wed Apr 2 19:22:16 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 16:22:16 -0700 (PDT) Subject: Nested try...except References: <0a34849f-bcda-419b-a10f-772d76172d1f@b5g2000pri.googlegroups.com> <43d60d13-b420-414d-81c8-b8430af2aa5f@i36g2000prf.googlegroups.com> Message-ID: <33d23676-5de0-4181-8abb-f3d733cdd365@r9g2000prd.googlegroups.com> On 2 avr, 15:22, Magnus.Morab... at gmail.com wrote: > On 2 Apr, 15:15, Magnus.Morab... at gmail.com wrote: > > > > > On 2 Apr, 15:12, cokofree... at gmail.com wrote: > > > > On Apr 2, 3:06 pm, Magnus.Morab... at gmail.com wrote: > > > > > Hi, > > > > > I found the following code on the net - > > > > > http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/%3C20050924104732.5116.qm... at minotaur.apache.org%3E > > > > > def count(self): > > > > - db = sqlite.connect(self.filename, > > > > isolation_level=ISOLATION_LEVEL) > > > > - try: > > > > - try: > > > > - cur = db.cursor() > > > > - cur.execute("select count(*) from sessions") > > > > - return cur.fetchone()[0] > > > > - finally: > > > > - cur.close() > > > > - finally: > > > > - db.close() > > > > > I don't understand though why the second try is not after the line cur > > > > = db.cursor(). Can anyone explain for me why? > > > > > /Barry. > > > > Better question is why is there a try with no except... > > > > Better yet, WHY is there two TRY statements when there could quite > > > happily be only one... > > > > Towards what you are asking, I GUESS...because the author hoped to > > > handle the cases where cur failed to get assigned...but then > > > his .close method of it would likely not work anyway...I mean...does > > > this even work...YUCK > > > I shouldn't have written "Nested try...except" as the title, instead I > > mean "Nested try...finally". Sorry about that... > > > Anyway, how would you do this? That is, use a finally to close the > > network connection and the cursor? > > > Thanks for your help, > > > Barry > > Here's what I would do. Is it OK? > > def ExecuteWithNoFetching(self, queryString): > > sqlServerConnection = adodbapi.connect (";".join (connectors)) slightly OT : where this 'connectors' comes from ? > try: > cursor = sqlServerConnection.cursor() > try: > cursor.execute(queryString) > raise Exception("Exception") > sqlServerConnection.commit() > finally: > cursor.close() > finally: > sqlServerConnection.close() Else it looks ok, even if a bit parano?d. Also, opening a db connection for each and every single query might not be the best solution... And finally (no pun intented), this won't let you chain calls within a single transaction. Another, a bit more flexible solution could be something like: def run_in_transaction(*funcs): sqlServerConnection = adodbapi.connect (";".join (connectors)) try: cursor = sqlServerConnection.cursor() try: for func in funcs: func(cursor) except Exception, e: sqlServerConnection.rollback() raise else: sqlServerConnection.commit() finally: cursor.close() finally: sqlServerConnection.close() def do_something(cursor): cursor.execute("some update query") def do_something_else(cursor): cursor.execute("some select query") for row in cursor.fetchall(): if some_condition(row): cursor.execute("some update query") run_in_transaction(do_something, do_something_else) And also, there's this new 'with' statement... My 2 cents... From marco at sferacarta.com Thu Apr 3 06:07:33 2008 From: marco at sferacarta.com (Marco Mariani) Date: Thu, 03 Apr 2008 12:07:33 +0200 Subject: splitting an XML file on the basis on basis of XML tags In-Reply-To: <0Y1Jj.9751$T35.2972@tornado.fastwebnet.it> References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> <0Y1Jj.9751$T35.2972@tornado.fastwebnet.it> Message-ID: Marco Mariani wrote: >>> the XML file is almost a TB in size... >>> >> Good grief. When will people stop abusing XML this way? > > Not before somebody writes a clever xmlfs for the linux kernel :-/ Ok. I meant it as a joke, but somebody has been there and done that. Twice. http://xmlfs.modry.cz/user_documentation/ http://www.haifa.ibm.com/projects/storage/xmlfs/index.html From llothar at web.de Wed Apr 2 19:33:33 2008 From: llothar at web.de (llothar) Date: Wed, 2 Apr 2008 16:33:33 -0700 (PDT) Subject: Problems building a binary extension Message-ID: <4352a799-7934-4a36-ab51-2cdc54431f77@u10g2000prn.googlegroups.com> I works well on Linux. But on FreeBSD when i use ../bin/python setup.py build_ext --inplace to select my own build python interpreter it is not using the correct library paths and therefore complains that it can't find the - lpython2.5 library. Using python-config i also don't see that the lib directory based on the --prefix option is not used anywhere for the library. Must i set LIBRARY_PATH by hand? If i have to it seems like a bug to me, because the information is there and the build tools should use it. From llothar at web.de Sat Apr 5 09:00:06 2008 From: llothar at web.de (llothar) Date: Sat, 5 Apr 2008 06:00:06 -0700 (PDT) Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> Message-ID: <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> > Right, so you think people aren't trying to help you? I think they are not reading the question. > You display your ignorance here. The ".pyd" extension is used on Windows > as an alternative to ".dll", but both are recognized as shared > libraries. Personally I'm not really sure why they even chose to use > ".pyd", which is confusing to most Windows users. Here i agree. But having it's own identifiying extension has also some small benefits. > To depart from the platform standard would be unhelpful and confusing to > the majority of users. It's know use telling us what you think: tell us > instead the compelling reasons why your opinion is correct. Opinions, > after all, are so cheap that everyone can have one. Because i want a uniform solution. Either use "dllso" or use "pyd" but stay with one decision once made. At the moment when i build python on my ubuntu system without "--enable-shared" i get a pyd file created, if i use "--enable-shared" it is a so file. I don't know if this is a special case on Linux or the general on unix systems (i only have Linux, FreeBSD, NetBSD, OpenBSD, Solaris and MacOSX in mind). > There are ways to build distributions of Python extensions (modules or > packages involving binary code from languages like C or C++), but you > will want to understand a bit more about computing in general Believe me nobody needs to teach me anything about general programming anymore. > (and work on your social skills ;-) I don't think so. I asked a pretty simple question and as usual on usenet nobody read the question but answered to complete different topics. Answers on usenet are so cheap, everybody likes to give one - no matter if it is ontopic, right or wrong. And this does not really help. My question is simple and person who knows setup.py and distools would be able to give the answer in a small sentence if there is a strategy behind it and it's not only a bug. Unfortunately there is no python.core mailing list that i know so i ask here. From paul at science.uva.nl Tue Apr 29 10:30:09 2008 From: paul at science.uva.nl (Paul Melis) Date: Tue, 29 Apr 2008 16:30:09 +0200 Subject: Issue with regular expressions In-Reply-To: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Message-ID: Julien wrote: > Hi, > > I'm fairly new in Python and I haven't used the regular expressions > enough to be able to achieve what I want. > I'd like to select terms in a string, so I can then do a search in my > database. > > query = ' " some words" with and "without quotes " ' > p = re.compile(magic_regular_expression) $ <--- the magic happens > m = p.match(query) > > I'd like m.groups() to return: > ('some words', 'with', 'and', 'without quotes') > > Is that achievable with a single regular expression, and if so, what > would it be? Here's one way with a single regexp plus an extra filter function. >>> import re >>> p = re.compile('("([^"]+)")|([^ \t]+)') >>> m = p.findall(q) >>> m [('" some words"', ' some words', ''), ('', '', 'with'), ('', '', 'and'), ('"without quotes "', 'without quotes ', '')] >>> def f(t): ... if t[0] == '': ... return t[2] ... else: ... return t[1] ... >>> map(f, m) [' some words', 'with', 'and', 'without quotes '] If you want to strip away the leading/trailing whitespace from the quoted strings, then change the last return statement to be "return t[1].strip()". Paul From deliverable at gmail.com Thu Apr 17 02:37:32 2008 From: deliverable at gmail.com (braver) Date: Wed, 16 Apr 2008 23:37:32 -0700 (PDT) Subject: sampling without replacement Message-ID: <6017ea8d-6ee8-44ea-bdad-bf06299a9cd5@a23g2000hsc.googlegroups.com> Greetings -- I am doing a sampling without replacement, taking out random elements from an array. The picked element is then removed from the array. When my arrays were on the order of 10,000 elements long, everything was fast. But when I increased them to 1,000,000 it suddenly was hours. I tracked it down to the line I first threw in to cut out the element i: a = a[:i] + a[i+1:] It was indeed the weakest link. But when I replace it with e.g. a.pop(i) it is still slow. I wonder what approach can be taken to speed it up? Basically, the algorithm picks an element from the array at random and checks its size in a different hashtable i=>size. If the size fits into an existing accumulator, i.e. is below a threshold, we take it and delete it from the array as above. Thus just random.sample is not enough as we may not use an element we pick until we find the right one, element by element, running a cumulative statistics. Using an array is natural here as it represents "without replacement" -- we take an element by removing it from the array. But in Python it's very slow... What approaches are there to implement a shrinking array with random deletions with the magnitude of millions of elements? Cheers, Alexy From john00587 at gmail.com Mon Apr 21 01:43:12 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:43:12 -0700 (PDT) Subject: crack registration codes for pogo games Message-ID: crack registration codes for pogo games http://cracks.00bp.com F R E E C R A C K S From rickbking at comcast.net Wed Apr 9 12:27:19 2008 From: rickbking at comcast.net (Rick King) Date: Wed, 09 Apr 2008 12:27:19 -0400 Subject: Stani's python ide 'spe' editor problem (again) Message-ID: <47FCEE67.8020607@comcast.net> In my previous post about spe I didn't mention that my set up is: python 2.4.4 wxpython 2.8.3 thanks. -Rick King From john00587 at gmail.com Mon Apr 21 01:41:37 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:41:37 -0700 (PDT) Subject: ideal admin keygen Message-ID: ideal admin keygen http://cracks.00bp.com F R E E C R A C K S From marco at sferacarta.com Thu Apr 17 11:54:03 2008 From: marco at sferacarta.com (Marco Mariani) Date: Thu, 17 Apr 2008 17:54:03 +0200 Subject: Can't do a multiline assignment! In-Reply-To: References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> Message-ID: s0suk3 at gmail.com wrote: > Yes, it makes it more readable. And yes, it does make it (a lot) more > maintainable. Mainly because I don't have those four variables, I have > about thirty. And I think I won't need to one or two of them, but > maybe all of them at once. have fun with locals(), then (but please feel dirty :-) loc = locals() for var in [ 'foo', # INSERT 'bar', # COMMENT 'baz' # HERE ]: loc[var] = 42 From davecook at nowhere.net Fri Apr 11 23:43:28 2008 From: davecook at nowhere.net (David Cook) Date: Sat, 12 Apr 2008 03:43:28 GMT Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> <47FFDA87.3070703@gmail.com> Message-ID: On 2008-04-11, Gabriel Ibanez wrote: > Why is nobody talking about pyGTK ? There are no limits with licenses (I > think) The OS X port is still pretty preliminary. Dave Cook From jurgenex at hotmail.com Tue Apr 29 23:13:04 2008 From: jurgenex at hotmail.com (Jürgen Exner) Date: Wed, 30 Apr 2008 03:13:04 GMT Subject: Python's doc problems: sort References: <929d5ce9-9063-4e6c-98aa-89526f89fba3@y18g2000pre.googlegroups.com> Message-ID: <9pof14t22rpq24219q0an2748i5f054qr4@4ax.com> "xahlee at gmail.com" wrote: Is this self-promoting maniac still going at it? >Although i disliked Perl very much [...] Then why on earth do you bother polluting this NG? Back into the killfile you go jue From primoz.skale.lists at gmail.com Wed Apr 2 15:03:36 2008 From: primoz.skale.lists at gmail.com (Primoz Skale) Date: Wed, 2 Apr 2008 21:03:36 +0200 Subject: function call - default value & collecting arguments Message-ID: <_LQIj.9776$HS3.482805@news.siol.net> Hello! I am fairly new to Python, so I apologise if this is a 'newbie' question. First define a simple function: def f(a=0): print a >> f(1) 1 >>f() 0 Argument a in function f() is set at default value of 0, if it is not passed to the function at the function call. I get this! :) I also understand (fairly) how to collect arguments. For example, let's define another function: def f(*a): print a >>f(1) (1,) >>f(1,2) (1,2) >>f() () OK, everything allright till so fair. But! :) Now define third function as: def f(*a): print a[0] In this case, function only prints first argument in the tuple: >>f(1,2,3) 1 >>f(3) 3 >>f() #no arguments passed Traceback (most recent call last): File "", line 1, in f() #no arguments passed File "", line 2, in f print a[0] IndexError: tuple index out of range Then I tried to define the function as: def f(*a=(0,)): print a[0] #this should come next, but we get error msg instead, saying SyntaxError: invalid syntax but it does not work this way. Now my 'newbie' question: Why not? :) I wanted to write function in this way, because then we can call function without any arguments, and it would still print 0 (in this case). What I wanted was something like this: def f(*a=(0,)): print a[0] >>f(1,2) 1 >>f() #no args passed 0 but this of course does not work. Again, why not? Thank you for your comments. Primoz From victorsubervi at gmail.com Thu Apr 17 12:22:09 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 17 Apr 2008 11:22:09 -0500 Subject: Prob. w/ Script Posting Last Value Message-ID: <4dc0cfea0804170922n2a96be20sc424a7e67742a12e@mail.gmail.com> Hi; Gabriel provided a lovely script for showing images which I am modifying for my needs. I have the following line: print '

\n' % (d, y) where the correct values are entered for the variables, and those values increment (already tested). Here is the slightly modified script it calls: #!/usr/local/bin/python import cgitb; cgitb.enable() import MySQLdb import cgi form = cgi.FieldStorage() picid = int(form["id"].value) x = int(form["x"].value) pic = str(x) print 'Content-Type: text/html' db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor= db.cursor() sql = "select " + pic + " from products where id='" + str(picid) + "';" cursor.execute(sql) content = cursor.fetchall()[0][0].tostring() cursor.close() print 'Content-Type: image/jpeg\r\nContent-Length: %s\n' % len(content) print content I need to make it so that it will show all my images, not just the last one. Suggestions, please. TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From Lie.1296 at gmail.com Sun Apr 27 14:23:44 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 27 Apr 2008 11:23:44 -0700 (PDT) Subject: Loading associated files References: <74862697-da58-4eb7-8d60-09aaef54b7ad@j22g2000hsf.googlegroups.com> <09337541-0b3e-4aaf-b26f-06a0f689e7dc@u12g2000prd.googlegroups.com> Message-ID: <850a01c2-d59e-4ee7-a344-796fd3cbb8aa@v23g2000pro.googlegroups.com> On Apr 27, 8:21?pm, flarefi... at googlemail.com wrote: > Yep, thats pretty much exactly what i had done, those exact settings, > and it still doesnt work. As i said i looked at the other keys to > check i had done it right and a i said the settings are fine because i > can send the file to python.exe and it loads like a python file fine, > but it doesn't like passing it to my program. Have i done something > wrong with my program that simply prints the arguments?? I think either I have misunderstood the situation, you misunderstood your own situation, or you have expressed your situation incorrectly: "it loads like a python file fine". What loads like a python file fine? The python source or the data.xyz? What did you put in data.xyz? Data to be fed to your python program or python source code? Aren't we trying to load the data.xyz to your python program? Or are we trying to load data.xyz to python interpreter? Anyway, try adding quotes around the "%1", to ensure that path that contains spaces doesn't confuse the program HKEY_CLASSES_ROOT\MyApp\Shell\Open\Command => "C:\pathtomyapp \myapp.py" "%1" From deets at nospam.web.de Fri Apr 18 12:12:45 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 18 Apr 2008 18:12:45 +0200 Subject: Installing BeautifulSoup with easy_install (broken?) In-Reply-To: References: Message-ID: <66rvkdF2kqa1lU1@mid.uni-berlin.de> Larry Bates schrieb: > Info: > > Python version: ActivePython 2.5.1.1 > Platform: Windows > > I wanted to install BeautifulSoup today for a small project and decided > to use easy_install. I can install other packages just fine. > Unfortunately I get the following error from BeautifulSoup installation > attempt: > > C:\Python25\Lib\SITE-P~1>easy_install BeautifulSoup > Searching for BeautifulSoup > Reading http://pypi.python.org/simple/BeautifulSoup/ > Reading http://www.crummy.com/software/BeautifulSoup/ > Reading http://www.crummy.com/software/BeautifulSoup/download/ > Best match: BeautifulSoup 3.0.5 > Downloading > http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup- > 3.0.5.tar.gz > Processing BeautifulSoup-3.0.5.tar.gz > Running BeautifulSoup-3.0.5\setup.py -q bdist_egg --dist-dir > c:\docume~1\larry\l > ocals~1\temp\easy_install-cfdxna\BeautifulSoup-3.0.5\egg-dist-tmp-gbrpp5 > Traceback (most recent call last): > File "C:\Python25\Scripts\easy_install-script.py", line 8, in > load_entry_point('setuptools==0.6c8', 'console_scripts', > 'easy_install')() > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm > and\easy_install.py", line 1671, in main > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm > and\easy_install.py", line 1659, in with_ei_usage > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm > and\easy_install.py", line 1675, in > File "C:\Python25\lib\distutils\core.py", line 151, in setup > dist.run_commands() > File "C:\Python25\lib\distutils\dist.py", line 974, in run_commands > self.run_command(cmd) > File "C:\Python25\lib\distutils\dist.py", line 994, in run_command > cmd_obj.run() > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm > and\easy_install.py", line 211, in run > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm > and\easy_install.py", line 446, in easy_install > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm > and\easy_install.py", line 476, in install_item > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm > and\easy_install.py", line 655, in install_eggs > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm > and\easy_install.py", line 930, in build_and_install > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm > and\easy_install.py", line 919, in run_setup > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand > box.py", line 27, in run_setup > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand > box.py", line 63, in run > File > "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand > box.py", line 29, in > File "C:\VOL1\Larry\Websafe\Python\wstools\setup.py", line 2, in > import py2exe > File "C:\VOL1\Larry\Websafe\Python\wstools\unittest.py", line 3, in > > class TextCtrlTest(unittest.TestCase): > AttributeError: 'module' object has no attribute 'TestCase' > > > Thanks in advance for any "clues". I'm not sure what happens - but I think it is suspicious that these "wstools" get into the way. And it looks as if wstools.unittest imports itself, instead of the python-unittest - which must be solved with getting the sys.path fixed. Diez From cwitts at gmail.com Tue Apr 22 08:06:03 2008 From: cwitts at gmail.com (Chris) Date: Tue, 22 Apr 2008 05:06:03 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> Message-ID: <1579bc26-193d-4e65-b5f4-3cea7d8cf4f3@t63g2000hsf.googlegroups.com> On Apr 22, 1:53?pm, azrael wrote: > Which big aplications are written in python. I see its development, > But i can't come up with a big name. I know that there are a lot of > companys using python, but is there anythong big written only in > python. I want him to fuck of with his perl once and for all time http://www.python.org/about/success/ nuff said From darcy at druid.net Wed Apr 2 16:57:31 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Wed, 2 Apr 2008 16:57:31 -0400 Subject: april fools email backfires In-Reply-To: References: <7xbq4sf9wv.fsf@ruckus.brouhaha.com> Message-ID: <20080402165731.48e943b2.darcy@druid.net> On Wed, 02 Apr 2008 12:29:58 -0500 Grant Edwards wrote: > On 2008-04-02, Paul Rubin wrote: > > http://www.coboloncogs.org/INDEX.HTM > That's absolutely brilliant! I particularly like the flashing > effect that simulates an old screen-at-time mode terminal (or > maybe a storage-scope terminal?), and the faint "burn-in" text > in the background. I nearly fell off my chair when I read this one. WE EXPECT FULL CHARACTER SET SUPPORT FOR EBCDIC AND A LARGE SUBSET OF ASCII IN THE 1.34 RELEASE. TIHS WILL INCLUDE SUPPORT FOR SPECIAL CHR SUCH AS THE EURO SYMBOL AND LOWER CASE LETTERS. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From michael at stroeder.com Thu Apr 24 05:25:48 2008 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Thu, 24 Apr 2008 11:25:48 +0200 Subject: python-ldap - Operations Error In-Reply-To: References: Message-ID: theiviaxx at gmail.com wrote: >>>> import ldap >>>> l = ldap.initialize("ldap://server.net") >>>> l.simple_bind(DN, "secret") > 1 ^^^ You probably want to use the synchronous method simple_bind_s() since you want to impersonate on this LDAP connection immediately before doing anything else on that connection. >>>> l.result(1) > (97, []) Could you please use argument trace_level=2 when calling ldap.initialize() and examine the debug log? It records all method calls of your particular LDAPObject instance. l = ldap.initialize("ldap://server.net",trace_level=2) Level 2 outputs a debug log with results received. Protect this log since it also contains passwords! >>>> l.search("dc=server,dc=net", ldap.SCOPE_SUBTREE, "(sAMAccountName=user)") > OPERATIONS_ERROR: {'info': '00000000: LdapErr: DSID-0C090627, comment: > In order to perform this operation a successful bind must be completed > on the connection., data 0, vece', 'desc': 'Operations error'} Still something went wrong with your bind. Since I don't know your DN I can't say anything. The DN should be a local user in this domain and not a user from another trusted domain. If you have a complicated AD setup with various domains and delegated trust connecting to the GC (global catalog) on port 3268 might be easier. > The simple bind works fine and returns a result, when i get the > result, it returns 97 meaning successful. It would raise an exception if an LDAP error was received. > So there was a successful > bind on the connection, right? Don't know. Since I don't know your DN and AD domain configuation. I've added a new example script ms_ad_bind.py to python-ldap's Demo/ directory illustrating all the possible bind methods: http://python-ldap.cvs.sourceforge.net/*checkout*/python-ldap/python-ldap/Demo/ms_ad_bind.py?content-type=text%2Fplain For getting the SASL stuff to correctly work your DNS has to be properly set up for AD (A RRs and matching PTR RRs for the DCs). Ciao, Michael. From yuxuy501 at yahoo.com Sun Apr 20 04:08:24 2008 From: yuxuy501 at yahoo.com (yuxuy501 at yahoo.com) Date: Sun, 20 Apr 2008 01:08:24 -0700 (PDT) Subject: Noadware.net - Spyware/Adware Remover Message-ID: <06fc8db5-e553-465d-9c84-40ffdaa3c2d5@w5g2000prd.googlegroups.com> Noadware.net - Spyware/Adware Remover http://zoneweb.freeweb7.com/noadware.html From bronger at physik.rwth-aachen.de Mon Apr 28 04:21:02 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Mon, 28 Apr 2008 10:21:02 +0200 Subject: Abuse in comp.lang.python Message-ID: <87od7uie4x.fsf@physik.rwth-aachen.de> Path: uni-berlin.de!fu-berlin.de!postnews.google.com!f63g2000hsf.googlegroups.com!not-for-mail Message-ID: <8b09fc36-5ada-4e74-bd00-9911388bc681 at f63g2000hsf.googlegroups.com> From: landerdebraznpc at gmail.com Newsgroups: comp.lang.python Subject: the pink patch Date: Mon, 28 Apr 2008 00:52:20 -0700 (PDT) Lines: 10 Organization: http://groups.google.com NNTP-Posting-Host: 212.241.180.239 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1209369140 19824 127.0.0.1 (28 Apr 2008 07:52:20 GMT) X-Complaints-To: groups-abuse at google.com NNTP-Posting-Date: Mon, 28 Apr 2008 07:52:20 +0000 (UTC) Complaints-To: groups-abuse at google.com Injection-Info: f63g2000hsf.googlegroups.com; posting-host=212.241.180.239; posting-account=fGAdLgoAAABaPJnllSky1fhOhiaRCPm2 User-Agent: G2/1.0 X-HTTP-Via: 1.1 ds4204.dedicated.turbodns.co.uk:81 (squid/2.5.STABLE12) X-HTTP-UserAgent: gzip(gfe),gzip(gfe) Xref: wilson.homeunix.com comp.lang.python:23005 the pink patch http://crack.cracksofts.com From pavlovevidence at gmail.com Mon Apr 14 23:18:06 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 14 Apr 2008 20:18:06 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <0853b778-c20b-44bb-ac9b-a5803a1aecc5@e67g2000hsa.googlegroups.com> Message-ID: <53ede0ca-ad36-4b11-b693-ea500d7b6e43@e67g2000hsa.googlegroups.com> On Apr 14, 4:27 pm, Aaron Watters wrote: > > A question often asked--and I am not a big a fan of these sorts of > > questions, but it is worth thinking about--of people who are creating > > very large data structures in Python is "Why are you doing that?" > > That is, you should consider whether some kind of database solution > > would be better. You mention lots of dicts--it sounds like some > > balanced B-trees with disk loading on demand could be a good choice. > > Well, probably because you can get better > than 100x improved performance > if you don't involve the disk and use clever in memory indexing. Are you sure it won't involve disk use? I'm just throwing this out there, but if you're creating a hundreds of megabytes structure in memory there's a chance the OS will swap it out to disk, which defeats any improvements in latency you would have gotten. However, that is for the OP to decide. The reason I don't like the sort of question I posed is it's presumptuous--maybe the OP already considered and rejected this, and has taken steps to ensure the in memory data structure won't be swapped--but a database solution should at least be considered here. Carl Banks From kay.schluehr at gmx.net Sat Apr 5 05:51:41 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 5 Apr 2008 02:51:41 -0700 (PDT) Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> Message-ID: On 5 Apr., 10:26, Aldo Cortesi wrote: > So, why did I re-write it? Well, I needed a test framework that didn't > have the deep flaws that unittest has. I needed good hierarchical > fixture management. I needed something that didn't instantiate test > suites automatically, freeing me to use inheritance more naturally > within my test suites. I'm not entirely sure what you are claiming here. From source inspections I can see that TestSuite instances are instantiated by the TestLoader and you are free to derive from TestLoader, overwrite its methods and pass around another instance than defaultTestLoader ( or a fresh instance of TestLoader which is the same thing ). My impression is that unittest is bashed so much because it has Java style naming conventions i.e. for bike shading reasons not because people come up with a much improved way to create test frameworks or even understand what a framework is and create a new one just for applying a different default behaviour. The split into TestLoader, TestRunner, TestCase and TestSuite is pretty canonical and I still fail to see what can't be done with them and OO techniques. From medin0065 at gmail.com Sun Apr 20 10:45:58 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:45:58 -0700 (PDT) Subject: nero full version crack Message-ID: <8cdfd29a-0733-4631-b4d2-12eacb6cc191@m73g2000hsh.googlegroups.com> nero full version crack http://cracks.00bp.com F R E E C R A C K S From duncan.booth at invalid.invalid Wed Apr 9 06:28:35 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 9 Apr 2008 10:28:35 GMT Subject: Coping with cyclic imports References: <87bq4knmax.fsf@physik.rwth-aachen.de> <87iqyr9xoz.fsf@physik.rwth-aachen.de> Message-ID: Torsten Bronger wrote: > So, the last question is: Under which circumstances does this > happen? It happens when you import a module which imports (directly > or indictly) the current module and which comes before the current > module in the import order while the program runs. > > If you don't rely on imported things at top-level code (but only in > functions and methods which in turn must not be called from the > top-level), everything is fine. > > Can anybody confirm that this is correct? Imports are pretty straightforward really. Just remember the following: 'import' and 'from xxx import yyy' are executable statements. They execute when the running program reaches that line. If a module is not in sys.modules, then an import creates the new module entry in sys.modules and then executes the code in the module. It does not return control to the calling module until the execution has completed. If a module does exist in sys.modules then an import simply returns that module whether or not it has completed executing. That is the reason why cyclic imports may return modules which appear to be partly empty. Finally, the executing script runs in a module named __main__, importing the script under its own name will create a new module unrelated to __main__. Take that lot together and you shouldn't get any surprises when importing modules. From deets at nospam.web.de Tue Apr 15 05:11:40 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 15 Apr 2008 11:11:40 +0200 Subject: How to import C++ static library? References: Message-ID: <66j9r8F2k2iplU1@mid.uni-berlin.de> Alexander Dong Back Kim wrote: > Hi all, > > I'm very very beginner of python but I'm dare to ask this question > straight away. =P > > Is it possible to import C++ static library compiled by GCC? The > target is definitely Linux machine. > > I found some examples from Google showing the way C++ can import > Python so called embedded python. But I want to the opposite way of > this. I want to import (or include in C world terminology) the library > which is a blah.a file to reuse in python. > > Any suggestion or idea for this stupid beginner? ;) For C++, you need to create a wrapping using C++ wrapper tools. There are a few available: SWIG, Boost::Python and SIP. I can only comment personally on the latter - and can recommend it without any doubt. Diez From sanhitam at yahoo.com Thu Apr 10 16:03:37 2008 From: sanhitam at yahoo.com (Sanhita Mallick) Date: Thu, 10 Apr 2008 13:03:37 -0700 (PDT) Subject: Graphs in Python In-Reply-To: Message-ID: <460620.27259.qm@web55613.mail.re4.yahoo.com> Hi Matthieu. I have looked at that, and other similar ones all of which are based on Graphviz. My problem is that I myself am creating some large graphs,contrary to an already created network, say, a social network of python-list or my-space, downloaded from somewhere as indicated in some of the softwares.So I would like to use a graphical/visual method than typing out the nodes. But I see that these same packages are being mentioned by others - so I guess that is the only option right now. Also, I am looking for a good tutorial for basic graph implementation other than the one on python.org. Thanks. -SM --- Matthieu Brucher wrote: > Hi, > > Did you try packages dedicated to graphs, like > NetworkX ? > > Matthieu > > 2008/4/10, Sanhita Mallick : > > > > Hi. > > > > I am a newbie to Python. I am trying to implement > a > > Python code for graph manipulation. My graphs are > > about 200-500 nodes big. Excepting for the short > basic > > graph implementation info on Python.org, where can > I > > find more in depth info about how to express > graphs in > > python, and how to use them in a code? > > > > Also, does anyone know of a easy way of creating > the > > dictionary for python for a 500-node graph, > without > > typing each and every node? I found some > application > > that recognize dot file Graphviz - but I am > looking > > for a program that can let me "draw" a graph and > then > > generate the lists automatically from the drawing. > > > > Thanks. > > -SM > > > > -- > > > http://mail.python.org/mailman/listinfo/python-list > > > > > > -- > French PhD student > Website : http://matthieu-brucher.developpez.com/ > Blogs : http://matt.eifelle.com and > http://blog.developpez.com/?blog=92 > LinkedIn : > http://www.linkedin.com/in/matthieubrucher > > -- > http://mail.python.org/mailman/listinfo/python-list From nothanks at null.invalid Wed Apr 30 00:46:15 2008 From: nothanks at null.invalid (Bill) Date: Wed, 30 Apr 2008 00:46:15 -0400 Subject: timeout In-Reply-To: <1a9b19bf-5075-4bce-812d-5516d3a4e454@b9g2000prh.googlegroups.com> References: <1a9b19bf-5075-4bce-812d-5516d3a4e454@b9g2000prh.googlegroups.com> Message-ID: maehhheeyy wrote, On 4/29/2008 6:02 PM: > Hi, > > I was just wondering if there was such thing as a timeout module. Take a look at the Timer class, which is a subclass of the Thread class. Here's a link to the official Python documentation: http://www.python.org/doc/2.3.5/lib/timer-objects.html Bill From gagsl-py2 at yahoo.com.ar Sun Apr 20 04:11:54 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 05:11:54 -0300 Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> Message-ID: En Sun, 20 Apr 2008 01:55:51 -0300, Banibrata Dutta escribi?: > Wanted to check if there is any known, reliable, FOSS/Libre -- Obfurscator > for Python 2.5 code. Why do you want to do that in the first place? There is very few you can do to obfuscate Python code. You can't rename classes nor methods nor global variables nor argument names due to the dynamic nature of Python. All you can safely do is to remove comments and join simple statements using ; If you remove docstrings, some things may break. Even renaming local variables isn't safe in all cases. -- Gabriel Genellina From banibrata.dutta at gmail.com Tue Apr 22 11:26:45 2008 From: banibrata.dutta at gmail.com (Banibrata Dutta) Date: Tue, 22 Apr 2008 20:56:45 +0530 Subject: Witty retorts (was: Python Success stories) In-Reply-To: References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <87d4oi3s3c.fsf_-_@benfinney.id.au> Message-ID: <3de8e1f70804220826k76d2abe5j222079a39ad83032@mail.gmail.com> "F**k you" -- is generally an indication of "creativity blackout" followed by "frustration". Not exactly a clever retort. On 4/22/08, Max Erickson wrote: > Ben Finney wrote: > > > Carl Banks writes: > > > >> Let me tell you a little story to let you know how you should > >> act in situations like this. Some of you might have heard it > >> before. Apologies if it's a bit long. > > > > I don't know if I've heard it before; it's rather unmemorable. > > > > What lesson is it intended to teach, other than that "Fuck you" > > is somehow a "retort"? I can't see that improving too many > > situations. > > > > I got something like "Don't waste your life worrying about what some > damn clown said" out of it. > > You don't even need to swear at the clown to make it work. > > > max > > -- > http://mail.python.org/mailman/listinfo/python-list > -- regards, Banibrata http://www.linkedin.com/in/bdutta From billingspanshism at gmail.com Sat Apr 19 17:19:36 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:19:36 -0700 (PDT) Subject: victoria beckham lyrics Message-ID: Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From sjmachin at lexicon.net Thu Apr 3 19:45:19 2008 From: sjmachin at lexicon.net (John Machin) Date: Thu, 3 Apr 2008 16:45:19 -0700 (PDT) Subject: expanding a variable to a dict References: Message-ID: <76f75b0d-2355-4c18-a6e4-931c307cb5c6@u10g2000prn.googlegroups.com> On Apr 4, 9:44 am, Max M wrote: > idle skrev: > > > now I'd like to check them all for the existence of certain default > > keys; ie, if the dicts don't contain the keys, add them in with > > default values. > > > so, I've got: > > > for a in ['dictFoo','dictBar','dictFrotz']: > > if hasattr(a,'srcdir') == False: > > a['srcdir']='/usr/src' > > There are a few ways to do it. > > for a in ['dictFoo','dictBar','dictFrotz']: Ummm ... excessive apostrophes plus bonus gross syntax error, dood. Did you try running any of these snippets??? > if not a.has_key('srcdir'): a is a str object. Bang. > a['srcdir'] = '/usr/src' > > for a in ['dictFoo','dictBar','dictFrotz']: > if not 'srcdir' in a: > a['srcdir'] = '/usr/src' a is a str object. Bang. > > for a in ['dictFoo','dictBar','dictFrotz']: > a.setdefault('srcdir') = '/usr/src' SyntaxError: can't assign to function call > > -- > > hilsen/regards Max M, Denmark > > http://www.mxm.dk/ > IT's Mad Science Sure is. From deets at nospam.web.de Thu Apr 24 05:35:32 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 24 Apr 2008 11:35:32 +0200 Subject: [Python-Dev] annoying dictionary problem, non-existing keys In-Reply-To: References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> Message-ID: <67b2jqF2o55grU1@mid.uni-berlin.de> bvidinli schrieb: > I posted to so many lists because, > > this issue is related to all lists, > this is an idea for python, > this is related to development of python... > > why are you so much defensive ? > > i think ideas all important for development of python, software.... > i am sory anyway.... hope will be helpful. You could take the answers from the people (including core developers) as sign that it is *not* related to all lists. Crossposting is generally frowned upon and should be avoided. If you post here & people think that it is a python devel issue, they will indicate that. Diez From mr.ribbs at gmail.com Fri Apr 11 14:20:14 2008 From: mr.ribbs at gmail.com (Kevin Takacs) Date: Fri, 11 Apr 2008 13:20:14 -0500 Subject: About __init__ and default arguments Message-ID: Hi, I'd like to assign the value of an attribute in __init__ as the default value of an argument in a method. See below: class aphorisms(): def __init__(self, keyword): self.default = keyword def franklin(self, keyword = self.default): return "A %s in time saves nine." % (keyword) def main(): keyword = 'FOO' my_aphorism = aphorisms(keyword) print my_aphorism.franklin() print my_aphorism.franklin('BAR') if __name__ == "__main__": main() I get this error: def franklin(self, keyword = self.default): NameError: name 'self' is not defined As you might expect, I'd like to get: A FOO in time saves nine. A BAR in time saves nine. I suppose I could set the default to a string literal, test for it and if true assign the value of self.default to keyword; however, that seems clunky. Any ideas how this could be done along the lines of my proposed but faulty code? Thanks, Kevin From robert.kern at gmail.com Wed Apr 9 17:36:30 2008 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 09 Apr 2008 16:36:30 -0500 Subject: Any fancy grep utility replacements out there? In-Reply-To: References: Message-ID: <47FD36DE.9040205@gmail.com> samslists at gmail.com wrote: > Thanks to everyone who responded, and sorry for my late response. > > Grin seems like the perfect solution for me. I finally had a chance > to download it and play with it today. It's great. > > Robert...you were kind enough to ask if I had any requests. Just the > one right now of grepping through gzip files. If for some reason you > don't want to do it or don't have time to do it, I could probably do > it and send you a patch. But I imagine that since you wrote the code, > you could do it more elegantly than I could. I just checked it in. -- 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 From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 3 06:35:34 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 03 Apr 2008 12:35:34 +0200 Subject: Prototype OO In-Reply-To: References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> <47f49d4b$0$5665$426a74cc@news.free.fr> Message-ID: <47f4b2f6$0$27965$426a34cc@news.free.fr> sam a ?crit : > Bruno Desthuilliers napisa?(a): > >> Ok, I'm going to be a bit harsh, but this time I'll assume it. > >> Sam, you started this thread by asking about prototype vs class based > >> minor syntactic points that, whether you like them or not (and > > I think I will get back to this discussion after learning "descriptor > protocol" Add lookup (name resolution) rules, metaclasses, 'magic' methods etc to the list then, so you'll get a general view of Python's object model. > and maybe I will not talk about syntax then, and maybe it > won't get off topic. > > As you can see I'm novice in Python, but I can show python-experts some > newbie opinions. If somebody is an expert then he can't take a fresh > look at his many years work. This is indeed true. But be assured their are quite a few newbies (whether nwebie to Python or newbie to programming) posting here to comment on what they perceive as warts - sometimes making good points, sometimes just not knowing enough about the language's inners and/or philosophy to understand why what they think is a wart is considered a feature by more "advanced" users. As some other contributor (hi Diez !) to this thread already mentionned, "Is [Python] perfect? Heck no! But it sure is fun enough to deal with the occasional wart." From davidreynon at gmail.com Wed Apr 30 11:21:17 2008 From: davidreynon at gmail.com (korean_dave) Date: Wed, 30 Apr 2008 08:21:17 -0700 (PDT) Subject: printing inside and outside of main() module Message-ID: <9bd5c596-da19-4615-a4d8-e47b20cfb362@m73g2000hsh.googlegroups.com> This allows me to see output: ---begin of try.py print "Hello World" --end of try.py This DOESN'T though... --begin of try2.py def main(): return "Hello" --end of try2.py Can someone explain why??? From namesagame-usenet at yahoo.com Tue Apr 1 16:57:24 2008 From: namesagame-usenet at yahoo.com (gamename) Date: Tue, 1 Apr 2008 13:57:24 -0700 (PDT) Subject: Not Sure This Can Be Done... Message-ID: <46aeae28-4470-4136-a5f6-040f6468eb32@b5g2000pri.googlegroups.com> Hi, I generally have several copies of the same development environment checked out from cvs at any one time. Each development tree has a 'tools' dir containing python modules. Scattered in different places in the tree are various python scripts. What I want to do is force my scripts to always look in the closest 'tools' dir for any custom modules to import. For example: tree1/tools tree1/my_scripts/foo.py tree2/tools tree2/my_scripts/foo.py How can I make 'foo.py' always look in '../../tools' for custom modules? My preference would be to avoid changing the 'foo.py' script and have some way to resolve it via the environment (like PYTHONPATH, or .pth files, etc.). Anyone have any ideas? TIA, -T From carbanancizpo at gmail.com Fri Apr 18 16:57:01 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:57:01 -0700 (PDT) Subject: wbs pro id crack Message-ID: <31f98b5f-a3c0-447d-ab26-7c39a157bd53@p25g2000hsf.googlegroups.com> wbs pro id crack http://cracks.12w.net F R E E C R A C K S From larry.bates at websafe.com` Tue Apr 22 14:08:20 2008 From: larry.bates at websafe.com` (Larry Bates) Date: Tue, 22 Apr 2008 13:08:20 -0500 Subject: Spawing a thread and printing dots until it finishes In-Reply-To: References: Message-ID: sophie_newbie wrote: > On Apr 22, 4:41 pm, "D'Arcy J.M. Cain" wrote: >> On Tue, 22 Apr 2008 07:10:07 -0700 (PDT) >> >> >> >> sophie_newbie wrote: >>> import threading >>> class MyThread ( threading.Thread ): >>> def run ( self ): >>> myLongCommand()... >>> import time >>> t = MyThread() >>> t.start() >>> while t.isAlive(): >>> print "." >>> time.sleep(.5) >>> print "OK" >>> The thing is this doesn't print a dot every half second. It just >>> pauses for ages until the thread is finished and prints prints ".OK". >>> But if I take out the "time.sleep(.5)" line it will keep printing dots >>> really fast until the thread is finished. So it looks like its the >>> time.sleep(.5) bit that is messing this up somehow? >> We know that your main routine gives up the processor but without a >> full definition of MyThread how do we know that it ever does? I >> suspect that it hits sleep once, if at all, and then goes to the final >> print statement. In fact, I suspect that this is not exactly what you >> tried anyway. This code would not have printed ".OK" whether it >> entered the loop or not. It could have printed this; >> >> . >> OK >> >> because the print statement in the loop will print a dot on a line by >> itself. >> >> When looking for these sorts of answers you should really try to create >> a smallest program that exhibits the behaviour you are questioning and >> then cut and paste the entire script into your message unedited. Often >> enough you will even answer your own question in the process. >> >> -- >> D'Arcy J.M. Cain | Democracy is three wolveshttp://www.druid.net/darcy/ | and a sheep voting on >> +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. > > "myLongCommand()... " is a call to an function in R (the statistical > programming language) via Rpy (A python module that allows calls to > R). The call takes a couple of minutes to execute. I'm trying to build > a web front end to this R function and instead of the user looking at > a blank screen for 2-3 mins, I want to print dots to let them feel > like the program isn't hanging. > > What I am saying is that without the "time.sleep(.5)" line, the above > code will print dots on the screen continuously for 2-3 mins, filling > it up with a ridiculous ammount of dots. > > Whereas with the time.sleep line, instead of pausing for half a second > between dots, its seems to print, as you correctly pointed out: > > . > OK > > With a pause of 2-3 minutes between the . and the OK. > > I hope that clears things up a little. I haven't the faintest idea why > the code above doesn't work but hope someone has an idea. It wouldn't > be something to do with python not being able to handle multiple > threads at the same time or something? I hope there is a workaround. For a web front end you wouldn't go this route at all. You would get a progressive .GIF file that gets loaded into the client's browser and shows "activity" while the server does its thing. When the browser refreshes (after the server application completes) it would go away. You can't update a client's browser by writing dots to anything. Hope this helps. -Larry From guillermo.listas at googlemail.com Mon Apr 21 07:05:19 2008 From: guillermo.listas at googlemail.com (Guillermo) Date: Mon, 21 Apr 2008 04:05:19 -0700 (PDT) Subject: Opposite of repr() (kind of) Message-ID: Hi there, How can I turn a string into a callable object/function? I have a = 'len', and I want to do: if callable(eval(a)): print "callable", but that doesn't quite work the way I want. :) Regards, Guillermo From bbxx789_05ss at yahoo.com Sat Apr 19 03:00:05 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sat, 19 Apr 2008 00:00:05 -0700 (PDT) Subject: Inheritance confusion References: <4809932c$0$12307$c3e8da3@news.astraweb.com> Message-ID: <5ab990d0-3248-43ad-ac3d-7d3e0fc64e6f@26g2000hsk.googlegroups.com> On Apr 19, 12:37?am, Hook wrote: > Hi, > > I'm having a problem with multiple inheritance - it's clearly something > I've missed, but the web pages and books that I've consulted aren't > helping, so I'll throw myself on the mercy and collective wisdom of > Usenet! > > I've got 4 files (what I'll show has the active content removed for > brevity): > > Errors_m.py > ~~~~~~~~~~~ > class Errors (object) : > ? ? def __init__ (self, params) : > ? ? ? ? pass > > ? ? def Error (self, string) : > ? ? ? ? return 100 > > DT_m.py > ~~~~~~~ > class DT (object) : > ? ? def __init__ (self, params) : > ? ? ? ? ? ? ? ? pass > > ? ? def Date (self, epoch, pattern = 'd mmm yyyy') : > ? ? ? ? dt = datetime.datetime.fromtimestamp (epoch) > > Hook_m.py > ~~~~~~~~~ > from DT_m import DT > from Error_m import Errors > > class Hook (Errors, DT) : > ? ? def __init__ (self, params) : > ? ? ? ? DT.__init__ (self, params) > ? ? ? ? Errors.__init__ (self, params) > > DB_m.py > ~~~~~~~ > from Hook_m import Hook > > class DB (Hook) : > ? ? def __init__ (self, params) : > ? ? ? ? Hook.__init__ (self, params) > > And a test script: > > #!/usr/bin/python > > import os > import re > import string > import sys > > from DB_m import DB > > Dict = dict () > Dict ['logdir'] = '/tmp/log' > Dict ['diag'] ? = 1 > > Obj = DB (Dict) > print dir (Obj) > Obj.Connect ('Database') > > When I run the script I get this: > > Traceback (most recent call last): > ? File "./3.py", line 20, in > ? ? Obj.Connect ('Database') > ? File "/mnt/isis/Projects/Python/Learning/DB_m.py", line 102, in Connect > ? ? self.TRACE ("DB::Connect (" + database + "," + mode) > ? File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 314, in TRACE > ? ? self.DailyLog (msg) > ? File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 98, in > DailyLog > ? ? dt ? ? ? ? ?= self.Date (time ()) > TypeError: 'module' object is not callable > > Googling the "TypeError" message suggests that I've got a module and > class with the same name, but I can't see that I have. > > Can someone point me in the right direction please? > > If you need to see all the source, can do, but it's certainly too much > for an intro message! > > Thanks, > > Hook import time time() --output:-- Traceback (most recent call last): File "test1.py", line 3, in ? time() TypeError: 'module' object is not callable Did you do that somewhere? From casevh at gmail.com Fri Apr 11 01:06:53 2008 From: casevh at gmail.com (casevh) Date: Thu, 10 Apr 2008 22:06:53 -0700 (PDT) Subject: Integer dicision References: <5f499bee-a659-4e36-870c-076cb613a3e7@t12g2000prg.googlegroups.com> Message-ID: On Apr 10, 9:28 pm, bdsatish wrote: > How does (a/b) work when both 'a' and 'b' are pure integers ? Python defines the quotient and remainder from integer division so that a = qb + r and 0<=r < abs(b). C/C++ lets the remainder be negative. >>> divmod(-9,2) (-5, 1) >>> divmod(9,2) (4, 1) casevh From gagsl-py2 at yahoo.com.ar Wed Apr 2 17:05:57 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 02 Apr 2008 18:05:57 -0300 Subject: Adding Images to MySQL References: <4dc0cfea0804010536q71bce9ev38cff43923f5a4b8@mail.gmail.com> <4dc0cfea0804020605i1d600657n50b4ee132d7f7e@mail.gmail.com> Message-ID: En Wed, 02 Apr 2008 10:05:56 -0300, Victor Subervi escribi?: > I have tried the following code: > > #!/usr/local/bin/python > import _mysql > import MySQLdb > host = 'mysqldb2.ehost-services.com' > user = 'user' > passwd = 'pass' > db = 'bre' > print 'Content-Type: image/jpeg\r\n' > print '\nHi!\n' > db=MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > c=db.cursor() > imgfile=open("1.jpg",'rb') > f = imgfile.read() > sqlstr="insert into photo (id, img) values ('1', '" + > _mysql.escape_string(imgfile.read()) +"');" > c.execute(sqlstr) > imgfile.close() > c.close() > print '\nBye!\n' > > which prints Hi! but not Bye! and gives me an HTTP 200 error. I threw the > line > f = imgfile.read() > in there just to make sure it is reading the imgfile. Also, I tested it > with > all the import statements alone to make sure it was importing > everything. So > the problem is the c.execute statement. Please advise. (What a mess! I don't know where to begin...) - You say Content-Type: image/jpeg but you emit HTML code. You're lucky if you see any text at all. - HTTP 200 is not an error, it means the request was successful. - See the site logs looking for sql errors. - See the cgitb module http://docs.python.org/lib/module-cgitb.html - Have you read what I wrote in the message you're replying to? Use bound parameters instead of building the SQL values yourself. I'm keeping it at the bottom of this message - As a general advice, try to isolate the problems. Test the database stuff alone, in a local application. Test the cgi script alone, without database interaction. Test the database stuff in the web server (better if you have a shell account). Merge all and test again. - Please don't top post; quote the relevant parts and write your comments below the text you're replying to. > On Tue, Apr 1, 2008 at 1:37 PM, Gabriel Genellina > wrote: >> En Tue, 01 Apr 2008 09:36:00 -0300, Victor Subervi >> escribi?: >> >> > Hi; >> > I?m trying to figure out how to upload images into a MySQL database. >> > (Yes, >> > that is what I want to do.) I have a form that asks for data, like >> this: >> > 1ra Foto Peque?a: >> > >> > Then I send that form to a python script that processes like this: >> > cursor.execute('insert into products (' + col_names + ') values (' + >> > col_values + ');') >> > where col_names is all the names of the columns and col_values, >> > obviously, >> > the values. Works fine for strings and digits. Not so well for files >> :) >> > What >> > do? >> >> Always use bound parameters - not only it's easier and less error prone, >> it's safer too. How parameters are specified depends on the DBAPI module >> you're using - read the module documentation. I think MySQLdb accept >> dictionary-like marks: >> >> values = {'name': 'Red jar', >> 'descr': 'A nice red jar', >> 'pic': binary(picdata) >> } >> cursor.execute('''insert into products (name,description,picture) >> values (%(name)s, %(descr)s, %(pic)s);''', values) >> >> See PEP249 http://www.python.org/dev/peps/pep-0249/ and the >> documentation >> for your database module. -- Gabriel Genellina From gandalf at shopzeus.com Sun Apr 13 10:02:29 2008 From: gandalf at shopzeus.com (Laszlo Nagy) Date: Sun, 13 Apr 2008 16:02:29 +0200 Subject: PIL and true type fonts Message-ID: <48021275.8030509@shopzeus.com> Attached a screenshot from a text rendered by GIMP (left side) and PIL (right side). Same truetype font. Is this a bug in PIL? Thanks, Laszlo -------------- next part -------------- A non-text attachment was scrubbed... Name: 1.JPG Type: image/jpeg Size: 12725 bytes Desc: not available URL: From MarkCSU at gmail.com Wed Apr 16 09:08:05 2008 From: MarkCSU at gmail.com (MarkCSU at gmail.com) Date: Wed, 16 Apr 2008 06:08:05 -0700 (PDT) Subject: Serving binary content (images, etc) using BasteHTTPServer Message-ID: <556871d3-1fea-40f2-9cc6-2a4e3a80f968@k10g2000prm.googlegroups.com> I'm writing a simple web server in python using the BaseHTTPServer library. I can serve text content (ie html pages) with ease, but im running into troubles when i try to serve images. The image gets corrupted in transit and when I manually download the image from the website and look at it using a hex editor it appears that the first 60 (or first 3C in hex if it makes a helps) characters are missing. My code looks like this: def do_GET(s): # code that determines that yes this is an image s.send_response(200) s.send_header("Content-type", "image/jpeg") s.end_headers fileObj = open("1.jpg","rb") # file is harcoded until i get images being served correctly image = fileObj.read() s.wfile.write(image) From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 3 09:25:48 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 03 Apr 2008 15:25:48 +0200 Subject: who said python can't be obsfucated!? In-Reply-To: References: <47f4b69b$0$19766$426a74cc@news.free.fr> Message-ID: <47f4dadb$0$24535$426a74cc@news.free.fr> Marco Mariani a ?crit : > Bruno Desthuilliers wrote: > >> sig=lambda m:'@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p >> in m.split('@')]) > > > Pff... you call that a quicksort? > Nope, only somewhat obfuscated Python. And it seems it's at least obfuscated enough for you to believe it could be a quicksort implementation !-) From rkmr.em at gmail.com Wed Apr 16 12:10:42 2008 From: rkmr.em at gmail.com (rkmr.em at gmail.com) Date: Wed, 16 Apr 2008 09:10:42 -0700 Subject: python memory leak only in x86 64 linux In-Reply-To: References: Message-ID: This is the code that is causing memory leak in 64 bit python [but not in 32 bit python].. is something wrong in the code? now = datetime.datetime.now() oneday = datetime.timedelta(days=1) def birthdaycompare(a, b): if a is None and b: return 1 if a and b is None: return -1 if a is None and b is None: return 0 if a wrote: > the memory usage of a python app keeps growing in a x86 64 linux > continuously, whereas in 32 bit linux this is not the case. Python > version in both 32 bit and 64 bit linux - 2.6.24.4-64.fc8 > Python 2.5.1 (r251:54863, Oct 30 2007, 13:45:26) > > i isolated the memory leak problem to a function that uses datetime > module extensively. i use datetime.datetime.strptime, > datetime.timedelta, datetime.datetime.now methods... > > i tried to get some info with guppy and the code goes like this > > while True: > print heapy.heap().get_rp() > print heapy.setref() > users = globalstuff.q.get() > for u in users: > doalert(u) > > From meisnernel73884 at gmail.com Wed Apr 30 06:36:23 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:36:23 -0700 (PDT) Subject: cracks and keygens Message-ID: <4f4f07b6-b7ee-4085-9db0-01ebd139d899@8g2000hse.googlegroups.com> cracks and keygens http://crack.cracksofts.com From danb_83 at yahoo.com Sat Apr 5 23:59:02 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Sat, 5 Apr 2008 20:59:02 -0700 (PDT) Subject: id functions of ints, floats and strings References: Message-ID: On Apr 5, 9:30 pm, Steve Holden wrote: > > In fact all you can in truth say is that > > a is b --> a == b > You can't even guarantee that. >>> inf = 1e1000 >>> nan = inf / inf >>> nan is nan True >>> nan == nan False From hat at se-162.se.wtb.tue.nl Fri Apr 18 07:10:35 2008 From: hat at se-162.se.wtb.tue.nl (A.T.Hofkamp) Date: Fri, 18 Apr 2008 13:10:35 +0200 Subject: Fwd: is file open in system ? - other than lsof References: Message-ID: On 2008-04-17, bvidinli wrote: > is there another way, any python command sequence that i can check if > a file is open at the time of "before i process file" > > i am not interested in " the file may be written after i access it.." > the important point is " the time at i first access it." > > my routine is something like: > for i in listoffiles: > checkfileopen(i) > processfile() This code does not give you what you are after; in between 'checkfileopen()' and 'processfile()' somebody may open the file and mess with it. I quite doubt that you can get what you want, at OS level. Even if you get exclusive open(), you are not safe imho. After you opened the file for access (and before you perform the read() call), another process may also open it, and alter the data while you are reading. The same may happen between 2 read() calls. Note that a read() at OS level is not the same as a read() at Python (or C fread()) level. Python pretends to read an entire file in one call, but the OS is using disk-blocks of the underlying file system as unit of read/write. In other words, even if nobody messes with the file at the moment you open it, you don't necessarily get an uncorrupted file afaik. Sincerely, Albert From gagsl-py2 at yahoo.com.ar Mon Apr 14 00:55:41 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 14 Apr 2008 01:55:41 -0300 Subject: Host: header References: <20080414040454.E685730AC25@mail-in-03.arcor-online.net> Message-ID: En Mon, 14 Apr 2008 01:04:40 -0300, Penny Y. escribi?: > I have a problem with a request url,for example, I have the code below, > > import httplib > > try: > conn = httplib.HTTPConnection("192.168.1.1") > conn.request("GET", "/") > r1 = conn.getresponse() > if r1.status == 200: > result = 0 > except Exception: > result = -1 > > > but the server on 192.168.1.1 accept virtual host request only. > That's to say, I need to specify a "Host:" header in the request. > How to do it? thanks. Add a `headers` parameter to the request method. See http://docs.python.org/lib/httpconnection-objects.html Something like this (untested): headers = {'Host', 'the.host.name'} conn = httplib.HTTPConnection("192.168.1.1") conn.request("GET", "/", headers=headers) -- Gabriel Genellina From fr5478bey at gmail.com Sat Apr 26 11:40:31 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:40:31 -0700 (PDT) Subject: doom 3 crack Message-ID: <48dcecb7-dde8-4595-b2cc-1c531884bfb5@c65g2000hsa.googlegroups.com> doom 3 crack http://cracks.00bp.com F R E E C R A C K S From paddy3118 at googlemail.com Tue Apr 1 15:35:46 2008 From: paddy3118 at googlemail.com (Paddy) Date: Tue, 1 Apr 2008 12:35:46 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: On Apr 1, 6:27 pm, sprad wrote: > I'm a high school computer teacher, and I'm starting a series of > programming courses next year (disguised as "game development" classes > to capture more interest). The first year will be a gentle > introduction to programming, leading to two more years of advanced > topics. > > I was initially thinking about doing the first year in Flash/ > ActionScript, and the later years in Java. My reasoning is that Flash > has the advantage of giving a quick payoff to keep the students > interested while I sneak in some OOP concepts through ActionScript. > Once they've gotten a decent grounding there, they move on to Java for > some more heavy-duty programming. > > I've never used Python, but I keep hearing enough good stuff about it > to make me curious. > > So -- would Python be a good fit for these classes? Could it equal > Java as the later heavy-duty language? Does it have enough quickly- > accessible sparklies to unseat Flash? > > I want to believe. Evangelize away. How proficient are you in Flash/Actionscript? I suggest you try out Python/Pygame and extrapolate from that, given your available time, would you be proficient enough to teach it? - Paddy. From pylists at arcor.de Mon Apr 14 21:28:03 2008 From: pylists at arcor.de (Penny Y.) Date: Tue, 15 Apr 2008 09:28:03 +0800 Subject: =?gb2312?B?tPC4tDog09DW0Ln6yMu69T8=?= In-Reply-To: Message-ID: <20080415012810.389931CB844@mail-in-05.arcor-online.net> -----????----- ???: python-list-bounces+pylists=arcor.de at python.org [mailto:python-list-bounces+pylists=arcor.de at python.org] ?? Steve Holden ????: 2008?4?15? 2:17 ???: python-list at python.org ??: Re: ?????? >Since what I entered in English was something like "Yes, Python has a >future. But it will take some study". Perhaps you can tell me whether >your translation gives the correect flavor. I'm pretty sure the >babelfish mangled my intent. Babelfish does that thing worse. yes follow your words, the translation could be: Python????.????????, ??????. :-) From ggpolo at gmail.com Sat Apr 5 12:14:37 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sat, 5 Apr 2008 13:14:37 -0300 Subject: Tkinter: making buttons the same size? In-Reply-To: <12bad1a6-3b4b-446e-9673-8893cd6838f9@s37g2000prg.googlegroups.com> References: <12bad1a6-3b4b-446e-9673-8893cd6838f9@s37g2000prg.googlegroups.com> Message-ID: 2008/4/5, skanemupp at yahoo.se : > on windows vista these buttons dont have the same size, the "/" > shrinks a little. how do i make them the same size or prevent > shrinking? > a mac-user told me they look the same to him so maybe it doesnt shrink > on macs but it does when using VISTA. > > i tried some .propagate and extend-stuff but didnt work. > > #! /usr/bin/env python > from Tkinter import * > import tkMessageBox > > class GUIFramework(Frame): > """This is the GUI""" > > def __init__(self, master=None): > """Initialize yourself""" > > """Initialise the base class""" > Frame.__init__(self,master) > > """Set the Window Title""" > self.master.title("Calculator") > > """Display the main window" > with a little bit of padding""" > self.grid(padx=10,pady=10) > self.CreateWidgets() > > > > def CreateWidgets(self): > > > self.btnDisplay = Button(self,text='1',command=lambda > n=1:self.Display(n)) > self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) > > self.btnDisplay = Button(self,text='/',command=lambda > n="/":self.Display(n)) > self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) > Specify width=1 for both buttons. > def Display(self, number): > print number > > if __name__ == "__main__": > guiFrame = GUIFramework() > guiFrame.mainloop() > > -- > http://mail.python.org/mailman/listinfo/python-list > -- -- Guilherme H. Polo Goncalves From balta96428 at gmail.com Wed Apr 23 05:55:05 2008 From: balta96428 at gmail.com (balta96428 at gmail.com) Date: Wed, 23 Apr 2008 02:55:05 -0700 (PDT) Subject: keygen dreamfeeder 2.0.12 Message-ID: keygen dreamfeeder 2.0.12 http://cracks.12w.net F R E E C R A C K S From llothar at web.de Fri Apr 4 02:51:55 2008 From: llothar at web.de (llothar) Date: Thu, 3 Apr 2008 23:51:55 -0700 (PDT) Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' Message-ID: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> On windows everything is '.pyd' but there seems to be two ways to get this on unix? Why and what is the rule? From james at reggieband.com Sun Apr 27 09:15:06 2008 From: james at reggieband.com (james at reggieband.com) Date: Sun, 27 Apr 2008 06:15:06 -0700 (PDT) Subject: Installed python 2.5 over 2.4 and lost installed packages Message-ID: <6c77d0e5-f387-449d-9147-d7aefa3d2735@l64g2000hse.googlegroups.com> Hi all, I recently updated os x from python 2.4 to 2.5 (from python.org) and in doing so I lost my old python path entries. Python 2.4 was installed using fink. Now when I do: import sys print sys.path my old site-packages directory is not within it (the 2.4 one). So what is the right thing to do in this situation? It would be a pain to find and re-install each of the packages. Is it ok to add my old site-packages directory to the sys.path? What is the best way to do so (e.g. using .pth files or PYTHONPATH or other)? Is cp'ing the files from one place to another safe or advisable? Any help on best practices appreciated. James. From R.Brodie at rl.ac.uk Wed Apr 16 10:41:49 2008 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Wed, 16 Apr 2008 15:41:49 +0100 Subject: Serving binary content (images, etc) using BasteHTTPServer References: <556871d3-1fea-40f2-9cc6-2a4e3a80f968@k10g2000prm.googlegroups.com> Message-ID: wrote in message news:556871d3-1fea-40f2-9cc6- > s.end_headers A bare method name (without parentheses) won't get called. From guybenron at gmail.com Tue Apr 22 15:18:11 2008 From: guybenron at gmail.com (guybenron at gmail.com) Date: Tue, 22 Apr 2008 12:18:11 -0700 (PDT) Subject: Choosing log file destination in logging configuration file Message-ID: <3e85cd72-304e-4e17-8ca9-b0688a59fc14@t54g2000hsg.googlegroups.com> Hey, I have a sort of petty-neurotic question, I'm kinda pedantic and like to keep my log directories clean, and this thing is bothering me to the point of actually posting a question (couldn't find any post about this..). My application has two types of components: daemons and regular ones that are run every on crontab. Because the log structure is very similar, I want both to use the same logging configuration file. For clarity, I want all of the files to have the date as part of the filename. The TimedRotatingFileHandler has it built in (once it rotates), and I found a dirty hack to make it work for the FileHandler (see shameful code below). Basically I'm all set - have the daemons use the rotating handler, since they're, um, daemonic and on all the time, and have the regular components use the regular handler, using the dirty hack to insert the date into the filename. So far so good. In the relevant applications, the code looks something like this: logging.config.fileConfig('log.ini') logger = logging.getLogger('log.regular') logger = logging.getLogger('log.daemonic') .. and start logging. The thorn in my side is that after the fileConfig call, BOTH handlers are instantiated, meaning both types of files are created for every component, even if I don't need it: component.log (for the rotating handler) and compenent.date.log (for the regular file handler). ..So finally, here's my question: Apart from splitting the logging configuration into two separate files, is there any way to NOT create the file until you actually use it? Here's the logging configuration file for reference.. Thanks ! [loggers] keys=root,regular,daemonic [handlers] keys=fileHandler,consoleHandler,timedRotatingFileHandler [formatters] keys=simpleFormatter [logger_root] level=DEBUG handlers=consoleHandler [logger_regular] level=INFO handlers=fileHandler,consoleHandler propagate=0 qualname=log.regular [logger_daemonic] level=INFO handlers=timedRotatingFileHandler,consoleHandler propagate=0 qualname=log.daemonic [handler_timedRotatingFileHandler] class=handlers.TimedRotatingFileHandler level=INFO formatter=simpleFormatter args=('mylog.log', 'midnight') [handler_fileHandler] class=FileHandler level=INFO formatter=simpleFormatter ; sorry about the grossness args=('mylog.' + str(time.localtime().tm_year) + '_' + str(time.localtime().tm_mon).zfill(2) + '_' + str(time.localtime().tm_mday).zfill(2) + '.log', 'a') [handler_consoleHandler] class=StreamHandler level=DEBUG formatter=simpleFormatter args=(sys.stdout,) [formatter_simpleFormatter] format=%(asctime)s - %(filename)s - %(name)s - %(levelname)s - % (message)s From kyosohma at gmail.com Fri Apr 18 16:41:12 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 18 Apr 2008 13:41:12 -0700 (PDT) Subject: Error with win32com client on windows 2003 server References: Message-ID: On Apr 18, 3:12 pm, SPJ wrote: > Sorry, forgot to mention Subject in my earlier post, hence reposting. > ------------ > I am writing a script which need's to convert an excel file to csv (text) format. For that I am using the following code: > > excel = win32com.client.Dispatch("Excel.Application","Quit") > workbook = excel.Workbooks.Open(xlsfile) > workbook.SaveAs(csvfile, FileFormat=24) # 24 represents xlCSVMSDOS > workbook.Close(False) > excel.Quit() > > I did not have any problem running this script on a windows xp machine with python 2.5.2 and windows extensions. But I get the following error when I run the same script on a windows 2003 server with the same python and windows extension installation: > > excel = win32com.client.Dispatch("Excel.Application","Quit") > File "D:\Python25\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch > dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) > File "D:\Python25\lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName > return (_GetGoodDispatch(IDispatch, clsctx), userName) > File "D:\Python25\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) > com_error: (-2147221005, 'Invalid class string', None, None) > > I verified that installation is same. Any idea's as to what might be the problem? One thing I have noticed though is I can't see Microsoft office 11.0 object library when I do combrowse on windows 2003 server. I also to tried to reinstall python and windows extension. But still no luck. > > I would appreciate if anyone can guide me as to why this is happening and how to resolve this. > > Thanks, > SPJ > > ____________________________________________________________________________________ > Be a better friend, newshound, and > know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ I would recommend that you re-post to the PyWin32 user's group. They know the low-down on this stuff. You can find them here: http://mail.python.org/mailman/listinfo/python-win32 However, if you cannot access the object library, than that's probably the problem. I've no idea how to resolve that though. The gurus on the group linked above would likely know however. Mike From steve at holdenweb.com Wed Apr 9 10:03:19 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 10:03:19 -0400 Subject: I am worried about Python 3 In-Reply-To: <44c8b263-a01b-45b5-a971-faa6aa1611ec@d45g2000hsc.googlegroups.com> References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> <44c8b263-a01b-45b5-a971-faa6aa1611ec@d45g2000hsc.googlegroups.com> Message-ID: Mike Driscoll wrote: > On Apr 9, 7:04 am, jmDesktop wrote: >> I am a new Python programmer. I have always desired to learn Python, >> but have never had the opportunity. Recently this has changed, and I >> have an opportunity to get away from the .NET framework. I found >> Django (and other web frameworks) and began my quest to learn. I >> started reading Dive Into Python and anything I could find and started >> participating here in usenet. Then I had to read this: >> >> http://www.comp.leeds.ac.uk/nde/papers/teachpy3.html >> >> I think that every time I start a new technology (to me) it is about >> to change. Yes, I know that is the nature of things, but I'm always >> at the start of "something new." >> >> If I continue in Python 2.5.x, am I making a mistake? Is it really >> that different? >> >> Here is an excerpt that is causing me concern: >> >> Two new versions of the language are currently in development: version >> 2.6, which retains backwards compatibility with previous releases; and >> version 3.0, which breaks backwards compatibility to the extent that >> even that simplest of programs, the classic 'Hello, World', will no >> longer work in its current form. >> >> It makes me feel like I am wasting my time and makes it difficult to >> justify spending time on projects using 2.5.x and using it where I >> work. > > Just because there's a new version on the horizon that doesn't mean > you have to upgrade to it. There are plenty of people that still use > 2.3, such as my web host. I've only just started really using 2.5 this > year. > And for what it's worth, even after the 2.6/3.0 release (they are both due out simultaneously in August, modulo slippage) the python.org site will be advising new users to go with 2.6. The 2.X series will continue to be supported for some time (years) after the release of 3.0. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From http Thu Apr 10 13:17:25 2008 From: http (Paul Rubin) Date: 10 Apr 2008 10:17:25 -0700 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: <7xod8h39zu.fsf@ruckus.brouhaha.com> Michel Bouwmans writes: > > If by "best" you mean "easiest", that is probably tkinter, > I don't quite agree with you on this. Tkinter may be easy because it is > available by standard in Python, but that's about it in my opinion. The > API, look and performance hit is horrible. You're much better of with PyQt4 > which makes the job really simple. Well, it's a trade-off, the person wanted a cross platform gui and the #1 hurdle for something like PyQt4 is getting it to work on each of the platforms you desire to run on. With tkinter, that has already been done. I can walk up to any Linux, Windows, Mac, etc. box where Python is installed and put up a simple tkinter gui in under a minute. With anything else, I'm in installation hell for some indeterminate amount of time before I can put up "hello world", especially if I insist on installing from source (the alternative is accepting binaries from yet another third party, like handing out more and more keys to your house). I agree with you that tkinter gui's don't look as slick as PyQt4 etc. Whether that's important depends on your application's requirements. For what I've done with it so far, it's been good enough. I haven't compared the Python API's but have used some other gui toolokts on other platforms and tkinter seems comparable to the others in ease of use. I hadn't really thought about performance for something like a gui, though I guess it could matter for certain types of apps. From ajaksu at gmail.com Thu Apr 3 15:24:12 2008 From: ajaksu at gmail.com (ajaksu) Date: Thu, 3 Apr 2008 12:24:12 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> <58deb8b8-bae9-4d43-b973-3d90846726cb@b5g2000pri.googlegroups.com> Message-ID: <42106982-8d2e-4c98-b316-d6dc0a675230@a23g2000hsc.googlegroups.com> On Apr 2, 5:01?pm, John Henry wrote: > However, once I start teaching him variables, expressions, loops, and > what not, I found that (by surprise) he had great difficulties > catching on. ?Not soon after that, we had to quit. This makes me curious: how much of videogamer are you? And your son? I ask that because when I think about teaching programming to young kids, I imagine using terms they know from gaming, like "save slots" (variables/names), "memory cards" (containers), "combos" (functions, loops), "life meters" (counters), "next level" (conditionals, iteration, loops), "teammates" (helper functions), "character classes" and "characters" (class and instances), "confirm/cancel" (conditionals), etc. But I've never really tried to put all those together and find a test subject, so I'd like to know how fluent in this lingo you both were so I can assess my pseudo-didatic approach by proxy :) Regards, Daniel From ivan.illarionov at gmail.com Sat Apr 19 00:45:54 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Sat, 19 Apr 2008 04:45:54 +0000 (UTC) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> Message-ID: On Fri, 18 Apr 2008 22:30:45 -0500, Grant Edwards wrote: > On 2008-04-18, Bob Greschke wrote: > >> However, in playing around with your suggestion and Grant's code I've >> found that the struct stuff is WAY slower than doing something like >> this >> >> Value = (ord(Buf[s])*65536)+(ord(Buf[s+1])*256)+ord(Buf[s+2]) if Value >> >= 0x800000: >> Value -= 0x1000000 >> >> This is almost twice as fast just sitting here grinding through a few >> hundred thousand conversions (like 3sec vs. ~5secs just counting on my >> fingers - on an old Sun...it's a bit slow). Replacing *65536 with <<16 >> and *256 with <<8 might even be a little faster, but it's too close to >> call without really profiling it. > > I didn't know speed was important. This might be a little faster > (depending on hardware): > > Value = (ord(Buf[s])<<16) | (ord(Buf[s+1])<<8) | ord(Buf[s+2]) > > It also makes the intention a bit more obvious (at least to me). > > A decent C compiler will recognize that <<16 and <<8 are special and > just move bytes around rather than actually doing shifts. I doubt the > Python compiler does optimizations like that, but shifts are still > usually faster than multiplies (though, again, a good compiler will > recognize that multiplying by 65536 is the same as shifting by 16 and > just move bytes around). So why not put it in C extension? It's easier than most people think: from3bytes.c ============ #include PyObject* from3bytes(PyObject* self, PyObject* args) { const char * s; int len; if (!PyArg_ParseTuple(args, "s#", &s, &len)) return NULL; long n = (s[0]<<16) | (s[1]<<8) | s[2]; if (n >= 0x800000) n -= 0x1000000; return PyInt_FromLong(n); } static PyMethodDef functions[] = { {"from3bytes", (PyCFunction)from3bytes, METH_VARARGS}, {NULL, NULL, 0, NULL}, }; DL_EXPORT(void) init_from3bytes(void) { Py_InitModule("_from3bytes", functions); } buildme.py ========== import os import sys from distutils.core import Extension, setup os.chdir(os.path.dirname(os.path.abspath(__file__))) sys.argv = [sys.argv[0], 'build_ext', '-i'] setup(ext_modules = [Extension('_from3bytes', ['from3bytes.c'])]) 'python buildme.py' will create '_from3bytes.so' file 'from _from3bytes import from3bytes' will import C-optimized function Hope this helps. -- Ivan Illarionov From brian.e.munroe at gmail.com Fri Apr 25 11:06:11 2008 From: brian.e.munroe at gmail.com (Brian Munroe) Date: Fri, 25 Apr 2008 08:06:11 -0700 (PDT) Subject: Class Inheritance - What am I doing wrong? References: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> <613bc152-a6f4-4db4-8f90-593cb3f629c7@s33g2000pri.googlegroups.com> Message-ID: On Apr 24, 10:11 pm, Arnaud Delobelle wrote: > In python, use attributes starting with a single underscore (such as > _name). It tells users that they shouldn't mess with them. By > design, python doesn't include mechanisms equivalent to the Java / C++ > 'private'. Arnaud, Gabriel: Ok, Ok, I'll trust my users to not abuse my API :) I didn't realize that 'private' meant 'private, even to sub-classes' - it is all becoming clear to me now! Thanks for the help, and I'm going to re-read 'Python is Not Java' right about now (I've spent the past few months knee-deep in Java, I guess I need to cleanse myself) From ellingt8877 at gmail.com Mon Apr 28 01:46:14 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:46:14 -0700 (PDT) Subject: spy sweeper crack Message-ID: <62b9449f-1c0b-4c1c-a09a-63c5eae0b6cd@j33g2000pri.googlegroups.com> spy sweeper crack http://crack.cracksofts.com From steve at holdenweb.com Sat Apr 12 09:11:32 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 09:11:32 -0400 Subject: Tremendous slowdown due to garbage collection In-Reply-To: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> Message-ID: <4800B504.4010601@holdenweb.com> [...] > I would suggest to configure the default behaviour of the garbage > collector in such a way that this squared complexity is avoided > without requiring specific knowledge and intervention by the user. Not > being an expert in these details I would like to ask the gurus how > this could be done. > I hope this should be at least technically possible, whether it is > really desirable or important for a default installation of Python > could then be discussed once the disadvantages of such a setting would > be apparent. > > Thanks a lot for your consideration, and best regards, > Andreas > I think the linguists of the world should write better automated translation systems. Not being an expert in these details I would like to ask the gurus how it could be done. There are going to be pathological cases in any memory allocation scheme. The fact that you have apparently located one calls for you to change your approach, not for the finely-tuned well-conceived garbage collection scheme to be abandoned for your convenience. If you had made a definite proposal that could have been evaluated you request would perhaps have seemed a little more approachable. You might want to consider trying Jython, or IronPython, or PyPy, each of which comes with a different flavor of garbage collection, to see if one of the other approaches suits you better. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bronger at physik.rwth-aachen.de Thu Apr 10 12:49:50 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Thu, 10 Apr 2008 18:49:50 +0200 Subject: Cyclic relative imports don't work Message-ID: <871w5dvemp.fsf@physik.rwth-aachen.de> Hall?chen! Assume the follwing package structure: main.py package/ __init__.py [empty] moduleX.py moduleY.py main.py says: from package import moduleX moduleX.py says: from . import moduleY and moduleY.py says: from . import moduleX However, this doesn't work: bronger at wilson:~/temp/packages-test$ python main.py Traceback (most recent call last): File "main.py", line 1, in from package import moduleX File "/home/bronger/temp/packages-test/package/moduleX.py", line 1, in from . import moduleY File "/home/bronger/temp/packages-test/package/moduleY.py", line 1, in from . import moduleX ImportError: cannot import name moduleX If I turn the relative imports to absolute ones, it works. But I'd prefer the relative notation for intra-package imports. Why is this restriction? Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From gagsl-py2 at yahoo.com.ar Wed Apr 23 23:50:42 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 24 Apr 2008 00:50:42 -0300 Subject: logging doc problem References: Message-ID: En Wed, 23 Apr 2008 23:08:49 -0300, James Stroud escribi?: > Am I missing something or are the docs for logging hopelessly outdated? > > http://docs.python.org/lib/node406.html > > For example, quoting the docs > > """ > import logging > > logging.debug('A debug message') > logging.info('Some information') > logging.warning('A shot across the bows') > """ > > And the result is > > % /usr/bin/python > Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) > [GCC 4.0.1 (Apple Inc. build 5465)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > py> import logging > py> > py> logging.debug('A debug message') > Traceback (most recent call last): > File "", line 1, in > AttributeError: 'module' object has no attribute 'debug' Probably you have another logging.py and you're importing it instead of the one in the standard library. -- Gabriel Genellina From john106henry at hotmail.com Sat Apr 26 18:03:32 2008 From: john106henry at hotmail.com (John Henry) Date: Sat, 26 Apr 2008 15:03:32 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> Message-ID: On Apr 26, 8:46 am, a... at pythoncraft.com (Aahz) wrote: > In article <9028496e-30de-4853-8f57-b55d14e52... at h1g2000prh.googlegroups.com>, > John Henry wrote: > > > > >But then I looked closer. It turns out the XML file created by > >QxTransformer is *very* similar in structure when compared to the > >resource files used inPythonCard. Since there are no GUI builders > >for QxTransformer, and I can't affort to buy the one for Qooxdoo > >(Java! Yuk!), I decided to roll up my sleeves, took thePythoncard's > >Layout Manager and modified it and created my own "Poor Man's Qooxdoo > >GUI Layout Designer". > > Cute! When you have working code, please do upload to PyPI. > -- > Aahz (a... at pythoncraft.com) <*> http://www.pythoncraft.com/ > > Why is this newsgroup different from all other newsgroups? So far, I have the following widgets working: window, button, checkbox, static text, static box, list, combobox, spinner, radio button group Shouldn't be long before the following works: static line, image, image button, choice. From gagsl-py2 at yahoo.com.ar Fri Apr 25 22:02:05 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 25 Apr 2008 23:02:05 -0300 Subject: newbie question References: Message-ID: En Fri, 25 Apr 2008 19:35:58 -0300, John escribi?: > I'm working with the HTMLParser module and have implemented > HTMLParser.handle_starttag() and I see there is a separate > handle_data > method (which can be implemented), but I am not clear how to tie this > together with a given start tag, so I only get the data I want. > > For example, I'd like to get a handle on the character data ( the > number 1) immediately after the following start tag > > > > 1
> . > . > . > Any ideas? I usually don't recommend HTMLParser because a lot of HTML documents in the Web are not even remotely valid, and the parser can't handle that. BeautifulSoup is a more robust alternative: -- Gabriel Genellina From anuraguniyal at yahoo.com Tue Apr 1 03:29:22 2008 From: anuraguniyal at yahoo.com (anuraguniyal at yahoo.com) Date: Tue, 1 Apr 2008 00:29:22 -0700 (PDT) Subject: bsddb3 thread problem Message-ID: In my application I am trying to access(read) a DB thru a thread while my main thread is adding data to it and it gives following error(s) bsddb._db.DBRunRecoveryError: (-30974, 'DB_RUNRECOVERY: Fatal error, run database recovery -- PANIC: Permission denied') and sometimes bsddb._db.DBRunRecoveryError: (-30974, 'DB_RUNRECOVERY: Fatal error, run database recovery -- PANIC: fatal region error detected; run recovery') sometimes bsddb._db.DBInvalidArgError: (22, 'Invalid argument -- DB_LOCK- >lock_put: Lock is no longer valid') sometimes pure seg fault. Program received signal SIGSEGV, Segmentation fault. 0xb7c1b845 in __bam_adjust () from /usr/lib/libdb-4.4.so and some time memory usage keeps on increasing and cpu is 100% it crashes with memory error. This doesn't happen always, almost 1 in 10 cases. If i use simple python threaded function instead of threading class, it works. I have attached a simple script which tries to replicate the scenario. Do anybody has a clue what I am doing wrong here? I suppose bsddb3 DB can be accessed from mutiple threads? or do I need to specifically set DB_THREAD flag? though with db.DB_THREAD it hangs on some mutex? Thanks a lot Anurag ------- import time import os import threading import thread import shutil from bsddb3 import db class DocQueueConsumer(threading.Thread): def __init__(self, queueDB): threading.Thread.__init__(self) self.queueDB = queueDB self.setDaemon(True) def run(self): while True: self.queueDB.cursor() def crash(): path = "/tmp/test_crash" if os.path.exists(path): shutil.rmtree(path) os.mkdir(path) aBigEnv = db.DBEnv() aBigEnv.set_cachesize(0, 512*1024*1024) aBigEnv.open(path, db.DB_INIT_CDB|db.DB_INIT_MPOOL|db.DB_CREATE) queueDB = db.DB(aBigEnv) queueDB.open('mydb', dbtype=db.DB_RECNO, flags=db.DB_CREATE) DocQueueConsumer(queueDB).start() for i in xrange(10**5): if i%1000==0: print i/1000 queueDB.append("something") crash() ------- From gagsl-py2 at yahoo.com.ar Sun Apr 20 04:12:02 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 05:12:02 -0300 Subject: Calling Java Class from python References: <608239.30549.qm@web35906.mail.mud.yahoo.com> Message-ID: En Wed, 16 Apr 2008 07:37:55 -0300, Good Z escribi?: > We have developed a website in python and we need to integrate few features of third party website. They have provided us Base64EncoderDecoder Java Class and would like us to use it to encode the data before sending it to their site and decode it when received anything from their site. > > I have no idea/knowledge of Java. Can you please guide me how can i call Java class from Python scripts? Or what is the best way to handle this condition. > > Is Base64 library provided by python is compatible to Base64EncoderDecoder Java Class? If the Java class implements Base64 as defined in RFC 3548, it should be compatible with the Python base64 module. Try with some examples, including the corner cases (empty, one byte, two bytes, three bytes, length = 3n, 3n+1, 3n+2, including bytes outside the ASCII range...) -- Gabriel Genellina From usenet-nospam at well-adjusted.de Thu Apr 10 12:17:10 2008 From: usenet-nospam at well-adjusted.de (Jochen Schulz) Date: Thu, 10 Apr 2008 18:17:10 +0200 Subject: Data structure recommendation? References: <1adc3541-7775-4938-bd5a-953dd041656c@2g2000hsn.googlegroups.com> Message-ID: * bearophileHUGS at lycos.com: > > Please plug such good things. It seems the Python community is an > endless source of interesting modules I didn't know about. Your > (single) module looks very nice. I'll take a better look later. Could you please send me an email with an existing From: address? I tried to reply to you but apparently your From: is forged. J. -- I can tell a Whopper[tm] from a BigMac[tm] and Coke[tm] from Pepsi[tm]. [Agree] [Disagree] From mwilson at the-wire.com Tue Apr 1 23:11:46 2008 From: mwilson at the-wire.com (Mel) Date: Tue, 01 Apr 2008 23:11:46 -0400 Subject: generator functions: why won't this work? References: Message-ID: zillow20 at googlemail.com wrote: > I'm trying to understand generator functions and the yield keyword. > I'd like to understand why the following code isn't supposed to work. > (What I would have expected it to do is, for a variable number of > arguments composed of numbers, tuples of numbers, tuples of tuples, > etc., the function would give me the next number "in sequence") > #################################### > def getNextScalar(*args): > for arg in args: > if ( isinstance(arg, tuple)): > getNextScalar(arg) > else: > yield arg > #################################### > > # here's an example that uses this function: > # creating a generator object: > g = getNextScalar(1, 2, (3,4)) > g.next() # OK: returns 1 > g.next() # OK: returns 2 > g.next() # not OK: throws StopIteration error > > #################################### > > I'm sure I'm making some unwarranted assumption somewhere, but I > haven't been able to figure it out yet (just started learning Python a > couple of days ago). > > Any help will be appreciated :) `getNextScalar(arg)` doesn't yield anything (it creates, but doesn't use, a new generator object,) so nothing comes out. Look at >>> h = getNextScalar(1,2,(3,4),5) >>> h.next() 1 >>> h.next() 2 >>> h.next() 5 Maybe you want if isinstance (arg, tuple): for s in getNextScalar (*arg): yield s Mel. From ronnbus at gmail.com Mon Apr 7 18:32:49 2008 From: ronnbus at gmail.com (Ronn Ross) Date: Mon, 7 Apr 2008 18:32:49 -0400 Subject: playing around with python Message-ID: Hello all, I downloaded the source for version 2.5.2 and I played around and made some changes, but now I don't know how to compile on my machine to test them. Can someone tell me how to compile it to run on my machine? I'm trying to get familiar with it before I volunteer. Also, I'm running Unbuntu Linux. Thanks, Ronn -------------- next part -------------- An HTML attachment was scrubbed... URL: From exarkun at divmod.com Wed Apr 23 14:26:44 2008 From: exarkun at divmod.com (Jean-Paul Calderone) Date: Wed, 23 Apr 2008 14:26:44 -0400 Subject: Python generators (coroutines) In-Reply-To: Message-ID: <20080423182644.6859.212024454.divmod.quotient.34096@ohm> On Wed, 23 Apr 2008 10:53:03 -0700 (PDT), Michele Simionato wrote: >On Apr 23, 4:17 pm, rocco.ro... at gmail.com wrote: >> I would really like to know more about python 2.5's new generator >> characteristics that make them more powerful and analogous to >> coroutines. Is it possible for instance to employ them in situations >> where I would normally use a thread with a blocking I/O (or socket) >> operation? If it is, could someone show me how it can be done? There >> appears to be a very limited amount of documentation in this repect, >> unfortunately. >> >> Thank you. > >The real changes between Python 2.4 and Python 2.5 generators are >1) now you can have a yield inside a try .. finally statement >2) now you can send an exception to a generator > >The fact that now you can send values to a generator >is less important, since you could implement the >same in Python 2.4 with little effort (granted, with an uglier syntax) >whereas there was no way to get 1) and 2). >Anyway, if you have a blocking operation, the only solution is to use >a thread or a separate process. You could have #2. It's a trivial variation of sending a value. For example, http://twistedmatrix.com/trac/browser/trunk/twisted/internet/defer.py#L555 Jean-Paul From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 30 05:24:52 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 30 Apr 2008 11:24:52 +0200 Subject: @classmethod question In-Reply-To: References: Message-ID: <48183ad8$0$6034$426a74cc@news.free.fr> Scott SA a ?crit : > On 4/24/08, Bruno Desthuilliers (bruno.42.desthuilliers at websiteburo.invalid) wrote: > >>> It is a series of convenience methods, in this case I'm interacting >>> with a database via an ORM (object-relational model). >> out of curiosity : which one ? > > I'm rapidly becoming a "django junkie"^TM > (snip) Then if you want some "table-level" operations on your models, you should put them in a custom manager. You'll find relevant stuff here: http://www.b-list.org/weblog/2008/feb/25/managers/ http://www.djangoproject.com/documentation/model-api/#managers From lists at cheimes.de Sat Apr 12 08:48:02 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 12 Apr 2008 14:48:02 +0200 Subject: accessing individual characters in unicode strings In-Reply-To: References: Message-ID: <4800AF82.2020607@cheimes.de> Peter Robinson schrieb: > Dear list > I am at my wits end on what seemed a very simple task: > I have some greek text, nicely encoded in utf8, going in and out of a > xml database, being passed over and beautifully displayed on the web. > For example: the most common greek word of all 'kai' (or ??? if your > mailer can see utf8) > So all I want to do is: > step through this string a character at a time, and do something for > each character (actually set a width attribute somewhere else for each > character) As John already said: UTF-8 ain't unicode. UTF-8 is an encoding similar to ASCII or Latin-1 but different in its inner workings. A single character may be encoded by up to 6 bytes. I highly recommend Joel's article on unicode: The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) http://www.joelonsoftware.com/articles/Unicode.html Christian From rhamph at gmail.com Thu Apr 17 12:05:35 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Thu, 17 Apr 2008 09:05:35 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> Message-ID: <9140b6c2-fcf3-454f-a24e-0ed03b3b8e3b@k37g2000hsf.googlegroups.com> On Apr 17, 7:40 am, Steve Holden wrote: > I'd love to be wrong about that, but the GIL *has* been the subject of > extensive efforts to kill it over the last five years, and it has > survived despite the best efforts of the developers. Yo. http://code.google.com/p/python-safethread/ From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Fri Apr 25 08:01:12 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Fri, 25 Apr 2008 14:01:12 +0200 Subject: problem with unicode References: <26fcc207-b864-42c7-afb3-c6945e5fe29f@m44g2000hsc.googlegroups.com> Message-ID: <67dvg8F2nomm6U1@mid.individual.net> andreas.profous at googlemail.com wrote: > # media is a binary string (mysql escaped zipped file) > >>>> print media > x???[? ... > (works) Which encoding, perhaps UTF-8 or ISO8859-1? >>>> print unicode(media) > UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in > position 1: ordinal not in range(128) > (ok i guess print assumes you want to print to ascii) Not at all -- unicode tries to decode the byte string you gave it, but doesn't know which encoding to use, so it falls back to ASCII. You should decode all "incoming" byte strings to unicode objects using the right encoding -- here I tried yours with UTF-8. This works best using string's method "decode" which returns a unicode object. >>> media="x???[?" >>> print repr(media.decode("utf-8")) u'x\u30ef\u30e6\u30ed[\u30e8' Regards, Bj?rn -- BOFH excuse #379: We've picked COBOL as the language of choice. From tim.arnold at sas.com Thu Apr 24 12:46:17 2008 From: tim.arnold at sas.com (Tim Arnold) Date: Thu, 24 Apr 2008 12:46:17 -0400 Subject: convert xhtml back to html References: Message-ID: "Gary Herron" wrote in message news:mailman.130.1209053543.12834.python-list at python.org... > Tim Arnold wrote: >> hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop >> to create CHM files. That application really hates xhtml, so I need to >> convert self-ending tags (e.g.
) to plain html (e.g.
). >> >> Seems simple enough, but I'm having some trouble with it. regexps trip up >> because I also have to take into account 'img', 'meta', 'link' tags, not >> just the simple 'br' and 'hr' tags. Well, maybe there's a simple way to >> do that with regexps, but my simpleminded )]+/> doesn't work. >> I'm not enough of a regexp pro to figure out that lookahead stuff. >> >> I'm not sure where to start now; I looked at BeautifulSoup and >> BeautifulStoneSoup, but I can't see how to modify the actual tag. >> >> thanks, >> --Tim Arnold >> >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > Whether or not you can find an application that does what you want, I > don't know, but at the very least I can say this much. > > You should not be reading and parsing the text yourself! XHTML is valid > XML, and there a lots of ways to read and parse XML with Python. > (ElementTree is what I use, but other choices exist.) Once you use an > existing package to read your files into an internal tree structure > representation, it should be a relatively easy job to traverse the tree to > emit the tags and text you want. > > > Gary Herron > I agree and I'd really rather not parse it myself. However, ET will clean up the file which in my case includes some comments required as metadata, so that won't work. Oh, I could get ET to read it and write a new parser--I see what you mean. I think I need to subclass so I could get ET to honor those comments too. That's one way to go, I was just hoping for something easier. thanks, --Tim From fredrik at pythonware.com Sat Apr 5 08:47:45 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 14:47:45 +0200 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> Message-ID: Steve Holden wrote: > You display your ignorance here. The ".pyd" extension is used on Windows > as an alternative to ".dll", but both are recognized as shared > libraries. Personally I'm not really sure why they even chose to use > ".pyd", which is confusing to most Windows users. In UNIX/Linux > environments ".so" is the standard extension for a shared library. background: http://mail.python.org/pipermail/python-dev/1999-December/001456.html "Python cannot import every .dll file. Only .dll files that conform to the convention for Python extension modules can be imported. (The convention is that it must export an init function.) On most other platforms, shared libraries must have a specific extension (e.g. .so on most Unix). Python allows you to drop such a file into any directory where is looks for modules, and it will then direct the dynamic load support to load that specific file. This seems logical -- Python extensions must live in directories that Python searches (Python must do its own search because the search order is significant). On Windows, Python uses the same strategy. The only modification is that it is allowed to give the file a different extension, namely .pyd, to indicate that this really is a Python extension and not a regular DLL. This was mostly introduced because it is apparently common to have an existing DLL "foo.dll" and write a Python wrapper for it that is also called "foo". Clearly, two files foo.dll are too confusing, so we let you name the wrapper foo.pyd. But because the file format is essentially that of a DLL, we don't *require* this renaming; some ways of creating DLLs in the first place may make it difficult to do." From gagsl-py2 at yahoo.com.ar Sat Apr 12 21:36:31 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 12 Apr 2008 22:36:31 -0300 Subject: str(bytes) in Python 3.0 References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> <4800C677.5060703@v.loewis.de> Message-ID: En Sat, 12 Apr 2008 11:25:59 -0300, Martin v. L?wis escribi?: >> And making an utf-8 encoding default is not possible without writing a >> new function? > > There is no default encoding anymore in Python 3. This is by design, > learning from the problems in Python 2.x. So sys.getdefaultencoding() will disappear? Currently it returns "utf-8". In case it stays, what is it used for? -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Wed Apr 9 03:40:17 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 04:40:17 -0300 Subject: Can't figure out traceback: (error_proto(-ERR EOF) line 121 poplib.py References: <9904eabb-31e9-42df-b733-522aee7e3654@x19g2000prg.googlegroups.com> Message-ID: En Wed, 09 Apr 2008 02:19:47 -0300, erikcw escribi?: > I keep getting this error from poplib: > (error_proto(-ERR EOF) line 121 poplib.py > > Does this mean the connection has timed out? What can I do to deal > with it? If it happens from time to time, just wait a few minutes and retry... I've seen those errors with Yahoo. If you get it over and over with the same server, set_debuglevel(1) and inspect the transmission. -- Gabriel Genellina From rupole at hotmail.com Sat Apr 12 21:48:42 2008 From: rupole at hotmail.com (Roger Upole) Date: Sat, 12 Apr 2008 21:48:42 -0400 Subject: PythonWin Print Problem.. Build 210 References: Message-ID: "Hutch" wrote in message news:H29Mj.117410$yE1.54267 at attbi_s21... > PythonWin has been a very good ide from early version thru 2.4. > > All work ok on THREE of my computers with THREE different HP printers. > > Now comes 2.5. > Every thing seems to work the same except when I want to print out a copy > of the source code of my project (about 38 pages) > > Version 2.5 acts like it is going to print out the source code but instead > prints from several 100 to over 2000 BLANK PAGES pages and no source. > > Attempting to print out Source on SAME equipment (computers and printers) > using 2.4 (WITH NO CHANGES TO EQUIPMENT OR SOFTWARE ) results in > proper print out of source. > > Problem has been reported via direct and SourceForge but no response. > > Any body else having the same problem? > > -- > http://mail.python.org/mailman/listinfo/python-list > Did you see the response to the bug report on SF ? http://sourceforge.net/tracker/index.php?func=detail&aid=1907148&group_id=78018&atid=551954 There is also some more info in this thread on the python-win32 mailing list: http://mail.python.org/pipermail/python-win32/2006-December/005397.html Roger From dave.l.harrison at gmail.com Mon Apr 7 05:23:32 2008 From: dave.l.harrison at gmail.com (David Harrison) Date: Mon, 7 Apr 2008 19:23:32 +1000 Subject: ldap In-Reply-To: <050e9150-7bbf-4a46-8c63-9d61835b1429@d1g2000hsg.googlegroups.com> References: <050e9150-7bbf-4a46-8c63-9d61835b1429@d1g2000hsg.googlegroups.com> Message-ID: On 07/04/2008, mr.enx at alice.it wrote: > sorry, i'm new with Python. > I must do interaction beetween Python and Ldap, and I don't know how > do this. > Searching on the web I know that exists PythonLdap, but I dont'know if > this is best choise or not. > > Thank's > > -- > http://mail.python.org/mailman/listinfo/python-list > I've used python-ldap for writing scripts to interact with LDAP directories quite a few times, check it out here at the cheeseshop: http://pypi.python.org/pypi/python-ldap/ From blog534 at watchesblog.cn Fri Apr 25 10:10:11 2008 From: blog534 at watchesblog.cn (blog534 at watchesblog.cn) Date: Fri, 25 Apr 2008 07:10:11 -0700 (PDT) Subject: Brand Watches Ebel Women's 1911 Two-Tone Watch #1087221-9365P Discount, Swiss, Fake Message-ID: <5c678ff3-1a9a-46d7-a2f0-174fb0c27110@p25g2000pri.googlegroups.com> Brand Watches Ebel Women's 1911 Two-Tone Watch #1087221-9365P Discount, Swiss, Fake Browse our Ebel Women's 1911 Two-Tone Watch #1087221-9365P Swiss watches, which is sure the watch you are looking for at low price. There are more high quality designer watch Swiss for selection Ebel Women's 1911 Two-Tone Watch #1087221-9365P Link : http://www.watches-brand.com/Ebel-wristwatch-3181.html Brand : Ebel ( http://www.watches-brand.com/Ebel-Watches.html ) Model : Ebel Women's 1911 Two-Tone Watch #1087221-9365P Description :

Ebel Women's 1911 18k and Steel Watch

Sale Price : $ 209.00 Ebel Women's 1911 Two-Tone Watch #1087221-9365P Details :
  • Brand: Ebel
  • Model: 1087221-9365P
  • Band material: steel-and-18k-gold
  • Bezel material: steel-and-18k-gold
  • Case material: steel-and-18k-gold
  • Clasp type: fold-over-clasp
  • Dial color: white-mother-of-pearl
  • Dial window material: scratch-resistant-sapphire
  • Movement type: swiss-quartz
  • Water-resistant to 330 feet
Ebel Women's 1911 Two-Tone Watch #1087221-9365P is new brand Swiss, join thousands of satisfied customers and buy your Ebel with total satisfaction. A watches-brand.COM 30 Day Money Back Guarantee is included with every Ebel Fake Series for secure, risk-free online shopping. watches-brand.COM does not charge sales tax for the Fake Ebel Women's 1911 Two-Tone Watch #1087221-9365P. All of our Fake watches are shipped via EMS to worldwide. Normally it takes 3days to prepare the fake watch you ordered and 5-10days to transmit depending on the different destination.We pay for the free shipping cost for total quantity over 20 pcs. The EMS tracking NO. will be sent by email when an order is shipped from our warehouse. No more other charges from watches-brand.com such as the tax. If you have any other questions please check our other pages or feel free to email us by sales at watches-brand.com. The Same Fake Ebel Watches Series : Ebel 1911 BTR Black Strap Dial Chronograph Mens Watch 9137L73.5335145 : http://www.watches-brand.com/Ebel-wristwatch-3182.html Ebel 1911 BTR Stainless Steel Mens Watch 9240L70.6360 : http://www.watches-brand.com/Ebel-wristwatch-3183.html Ebel 1911 BTR Stainless Steel Chronograph Mens Watch 9137L72.5360 : http://www.watches-brand.com/Ebel-wristwatch-3184.html Ebel Brasilia Mens Black Dial Stainless Steel Automaic Watch 9120M41/52500 / 1215615 : http://www.watches-brand.com/Ebel-wristwatch-3185.html Ebel Brasilia Mens Silver Dial Stainless Steel Automaic Watch 9120M41/62500 / 1215614 : http://www.watches-brand.com/Ebel-wristwatch-3186.html Ebel Brasilia Men's Brown Strap Silver Dial Stainless Steel Automatic Watch 9120M41.6235134 / 1215616 : http://www.watches-brand.com/Ebel-wristwatch-3187.html Ebel Brasilia Men's Silver Dial Stainless Steel Watch 9255M41/62500 / 1215598 : http://www.watches-brand.com/Ebel-wristwatch-3188.html Ebel Sport Classic_Watch Watch 1090141/0225 : http://www.watches-brand.com/Ebel-wristwatch-3189.html Ebel Sport Classic Stainless Steel & 18k gold Mens Watch - 1187141/1225 : http://www.watches-brand.com/Ebel-wristwatch-3190.html Ebel Sport Classic Stainless Steel & 18k gold Mens Watch - 1188141/0106 : http://www.watches-brand.com/Ebel-wristwatch-3191.html Brand Watches Ebel Women's 1911 Two-Tone Watch #1087221-9365P Discount, Swiss, Fake From n00m at narod.ru Sun Apr 27 14:05:38 2008 From: n00m at narod.ru (n00m) Date: Sun, 27 Apr 2008 11:05:38 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com><10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <8ee48fc1-45af-404f-8fad-d8e1b2fb90b4@s50g2000hsb.googlegroups.com> Message-ID: Both codes by Dennis Lee Bieber are Ok. The 2nd one ("slurper") , seems , a bit faster. I only corrected the author's typo: should be "% div" instead of "/ div". And added this (don't know helped it or not): if div == 1: print lim return And of course: import psyco psyco.full() From aldo at nullcube.com Sun Apr 6 23:13:44 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Mon, 7 Apr 2008 13:13:44 +1000 Subject: ANN: pry unit testing framework In-Reply-To: References: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> Message-ID: <20080407031344.GA17217@nullcube.com> Thus spake Roy Smith (roy at panix.com): > I've been following this thread for a while with a mix of amusement and > alarm. Contributing code to the community is a good thing, and should be > celebrated. If people like it, they will use it. If they don't, it will > be ignored. None of which justifies the hostility this thread seems to > have degenerated into. I agree entirely - I've been astonished by the whole fracas myself. I'm offering Pry simply as something neat I wrote that other people might find useful, no more. > In any case, I don't understand why you say that unittest doesn't use > "assertion-based testing". They seem like assertions to me. What am > I missing? While you can use the built-in "assert" statement in unittest tests, it turns out to be annoying in practice, especially during rapid code-test-code iterations. The problem is that assert traceback errors are uninformative - when "assert a == b()" fails, there's no way to tell what a and b() were in this context. Unittest copes with this with convenience methods - instead you write self.assertEqual(a, b()), which then gives you proper error reporting. I think it was py.test that first introduced some magic that picks up the AssertionError traceback, parses the original expression, and then re-evaluates its components to give you an error featuring the "disassembled" assertion expression. This approach has been adopted by nose and independently by pry. While re-evaluation has some limitations (like not dealing well with expressions that change state), using assertions makes for more fluid and natural expression in tests. Maybe "assertion-based" is not an exact phrase to describe this - saying that these frameworks support "expanded error reporting for Python assert statements" might be more accurate. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From kveretennicov at gmail.com Wed Apr 2 16:36:30 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Wed, 2 Apr 2008 23:36:30 +0300 Subject: default method parameter behavior In-Reply-To: <879d72da-825f-4b2b-8244-87367647fb6e@f63g2000hsf.googlegroups.com> References: <879d72da-825f-4b2b-8244-87367647fb6e@f63g2000hsf.googlegroups.com> Message-ID: <4660fe300804021336s5ac4c5cja2438d64eda970ce@mail.gmail.com> On Wed, Apr 2, 2008 at 10:59 PM, wrote: > I ran into a similar situation like the following (ipython session). > Can anyone please explain why the behavior? Of course. >From http://docs.python.org/ref/function.html: Default parameter values are evaluated when the function definition is executed. This means that the expression is evaluated once, when the function is defined, and that that same ``pre-computed'' value is used for each call. This is especially important to understand when a default parameter is a mutable object, such as a list or a dictionary: if the function modifies the object (e.g. by appending an item to a list), the default value is in effect modified. -- kv From usenet at solar-empire.de Wed Apr 30 08:43:28 2008 From: usenet at solar-empire.de (Marc Christiansen) Date: Wed, 30 Apr 2008 14:43:28 +0200 Subject: xml.dom.minidom weirdness: bug? References: <4817dea2$0$18028$426a34cc@news.free.fr> Message-ID: JYA wrote: > for y in x.getElementsByTagName('display-name'): > elem.appendChild(y) Like Gabriel wrote, nodes can only have one parent. Use elem.appendChild(y.cloneNode(True)) instead. Or y.cloneNode(False), if you want a shallow copy (i.e. without any of the children, e.g. text content). Marc From steve at holdenweb.com Mon Apr 14 10:03:54 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 14 Apr 2008 10:03:54 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804140629rf1ac100m27ad9d0456cbbe2d@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> <4dc0cfea0804140629rf1ac100m27ad9d0456cbbe2d@mail.gmail.com> Message-ID: <4803644A.8010204@holdenweb.com> Victor Subervi wrote: > Thanks to all, especially Gabriel. The base64 is a good idea, but you > state a definite problem. I will look at your code at home > (offline)...thank you very much! It looks like the kicker is this line here: > > %s" % (picid, cgi.escape(title)) > > Now, why didn?t you share that before????? I can see how calling a > separate script like that would work! Again, you should have shared that > before. How was I to think of that clever trick from the bare > information you gave me earlier?? > > Steve, thank you for all your help, but do overcome your temper :)) Victor: I'm glad the penny finally dropped. You may have been treated to a modest display of exasperation, but please be assured you have not yet seen anything remotely like temper from me :-) The thing I found difficult to understand was, given your assertion on April 9 "But I am persistent. And I have built dozens of Web site with images" that you hadn't already addressed these issues. I was clearly assuming too much knowledge on your part. Hooray! You got it! Your persistence finally paid off, well done! regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From sjmachin at lexicon.net Sun Apr 6 16:53:32 2008 From: sjmachin at lexicon.net (John Machin) Date: Sun, 6 Apr 2008 13:53:32 -0700 (PDT) Subject: RELEASED Python 2.6a2 and 3.0a4 References: <47F68547.1040802@v.loewis.de> Message-ID: <59d842ed-3103-4dcd-a78b-0999446d86ad@c19g2000prf.googlegroups.com> On Apr 7, 12:50 am, "Giampaolo Rodola'" wrote: > On 6 Apr, 00:55, John Machin wrote: > > > On Apr 5, 5:45 am, "Martin v. L?wis" wrote: > > > > > The Windows x86 MSI installer is missing for both 2.6 and 3.0. > > > > And likely will continue to do so for some time. > > > Someone's got strange definitions of "missing"! > > > For each there's a link on the the ptyhon.org website, and a caveat > > about non-Administrator installation ... > > > If it's missing, then what do I expect to find in the 11.7Mb 2.6a2 msi > > that is downloading as I type? > > At the time I replied they were both missing (in fact that's why I > replied :-)). > And at the time I replied, at least one was available but the most recent information in this newsgroup was that they were unavailable and would be so for some fuzzily-denominated duration which seemed seriously long ... perhaps my two different and not totally reliable news-reading facilities skipped a posting :-) From grante at visi.com Mon Apr 28 10:45:23 2008 From: grante at visi.com (Grant Edwards) Date: Mon, 28 Apr 2008 09:45:23 -0500 Subject: Retrieving int from hex in a file. References: <9edfaaa3-4e87-4f74-90a5-c10c9daae101@r66g2000hsg.googlegroups.com> Message-ID: <5eidndBxkoWefojVnZ2dnUVZ_gednZ2d@visi> On 2008-04-28, Filipe Teixeira wrote: > Hi. > > I have to open a binary file from an old computer and recover the > information stored (or at least try to). I use: > > f=open('file.bin','rb') > a=f.read() > f.close() > > a in now a string full of hex representations in the form: > > a[6]='\x14' > a[7]='\x20' a is now a string of binary data. It doesn't contain a "hex representation" of anything. Hex is a way of printing stuff on paper or on a screen. Python doesn't store anything in hex. > I would like to convert these hex representations to int, That's your mistake: you don't have hex data. Nothing is being stored in hex in your example. > but this (the most obvious way) doesn't seem to be working > >>>> q=a[6] >>>> q > '\x14' >>>> int(q,16) That converts a hex string into an integer, you've not got a hex string. You have a string containing binary data. "4A4B4C" is a hex string. It's 6 bytes long and contains the ASCII characters '4' 'A' '4' 'B' '4' 'C'. "\x4a\x4b\4c" is just a three-byte long chunk of binary data. It was _typed_ in hex, but it's stored in binary not in hex. It's identical to "JKL". > Traceback (most recent call last): > File "", line 1, in ? > ValueError: invalid literal for int(): >>>> > > How can I do this? You can use the struct module, or you can do it explicitly like this: >>> a = 'abcdef\x12\x34qwer' >>> n = (ord(a[6])<<8) | ord(a[7]) >>> n 4660 >>> hex(n) '0x1234' >>> -- Grant Edwards grante Yow! When you get your at PH.D. will you get able to visi.com work at BURGER KING? From whatpot at gmail.com Thu Apr 24 22:50:10 2008 From: whatpot at gmail.com (Vaibhav.bhawsar) Date: Thu, 24 Apr 2008 22:50:10 -0400 Subject: how to mysqldb dict cursors Message-ID: <17d58cc40804241950i7b624e1apd2733daa79b3ed5c@mail.gmail.com> I have been trying to get the DictCursor working with mysqldb module but can't seem to. I have pasted the basic connection code and the traceback from pydev. The connection does open with the default cursor class. can't figure this one out. many thanks. import MySQLdb import sys # connect to the MySQL server try: conn = MySQLdb.connect(host="localhost",read_default_file='~/.my.cnf',db='test',cursorclass=MySQLdb.cursors.DictCursor) cur = conn.cursor() print conn except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit (1) Traceback (most recent call last): File "/Users/.....src/db/test.py", line 7, in ? conn = MySQLdb.connect(host="localhost",read_default_file='~/.my.cnf',db='te st',cursorclass=MySQLdb.cursors.DictCursor) AttributeError: 'module' object has no attribute 'cursors' -------------- next part -------------- An HTML attachment was scrubbed... URL: From jared.grubb at gmail.com Wed Apr 23 21:39:46 2008 From: jared.grubb at gmail.com (Jared Grubb) Date: Wed, 23 Apr 2008 18:39:46 -0700 Subject: Partition list with predicate In-Reply-To: References: <925822270804231808n44c44ddbx213e936319ad1ed3@mail.gmail.com> Message-ID: <925822270804231839y2eb399a2ic05ab67406c94d0d@mail.gmail.com> That almost works, except that a predicate can have "memory". For example, the predicate could be "extract every other object", which doesn't care about the value of the object (so you cant remove them later based on value!). Or your predicate might be "remove the first 5 objects that are even", which means that the predicate must be run against the list in forward order with only one test per element (like an input/output iterator in C++; running the predicate changes the predicate itself, so you cant run one pass with "pred" and then another pass with "not pred" to get the rest). Example of a case where your proposed solution wouldn't quite work: class EveryOtherOne: def __init__(self): self.parity = False def __call__(self, obj): ret, self.parity = self.parity, not self.parity return ret >>> pred = EveryOtherOne() >>> lst = [1,2,2,1] >>> extracted = [ obj for obj in lst if pred(obj) ] >>> extracted [2, 1] >>> lst = [ obj for obj in lst if obj not in extracted ] >>> lst [] On Wed, Apr 23, 2008 at 6:14 PM, Brian wrote: > On Wed, Apr 23, 2008 at 9:08 PM, Jared Grubb > wrote: > > > I guess I forgot one requirement: the removed elements need to be > > remembered. > > > > Basically, I have a list of objects in a buffer, one class operates on > > some of the objects, but other classes use others. So, a class must extract > > the ones it can handle, and leave the rest in the buffer for the other > > classes to handle. > > > > I haven't found a function that will both remove objects from a list, > > but save the ones that do get removed. > > > > Jared > > > > On 23 Apr 2008, at 10:15, Tim Golden wrote: > > > > Jared Grubb wrote: > > > > I want a function that removes values from a list if a predicate > > evaluates to True. The best I could come up with is: > > > > > > Have a look at the itertools module, and the ifilter function > > in particular. > > > > TJG > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > I would do it like this: > > # This takes out the values > extracted = [ obj for obj in lst if pred(obj) ] > # This filters out any item that was extracted > lst = [ obj for obj in list if obj not in extracted ] > > Brian -------------- next part -------------- An HTML attachment was scrubbed... URL: From duncan.booth at invalid.invalid Tue Apr 1 03:34:17 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 1 Apr 2008 07:34:17 GMT Subject: [OT] troll poll References: Message-ID: Gary Herron wrote: > Duncan Booth wrote: >> Paul Rubin wrote: >> >> >>> "Daniel Fetchinson" writes: >>> >>>> [ ] - Xah Lee >>>> [ ] - castironpi >>>> >>> I've lost track but has it been established that they are not the >>> same person? >>> >>> >> Has it actually been established that castironpi is actually a >> person? I thought it was probably a random sentence generator. >> > Ahhh... Perhaps someone is running a Turing test on us. That is, if > we can't tell the difference between castironpi and a *real* human > (which we demonstrate whenever we try to respond to or reason with > him/her/it), then castironpi can be declared to be a truly > *intelligent* AI. AFAICT, there appears no danger of that happening > yet. > > Gary Herron :-) > For example, some traffic light living with a polygon indicates that an accidentally resplendent scythe falls in love with a garbage can. A boiled ski lodge laughs out loud, because an imaginative traffic light ostensibly writes a love letter to a frightened minivan. Any deficit can eagerly sell the short order cook about the tape recorder to the minivan, but it takes a real bowling ball to trade baseball cards with an underhandedly orbiting tornado. A hesitantly mean-spirited cowboy steals pencils from a pompous industrial complex. Sometimes the crispy apartment building procrastinates, but the ocean related to the cyprus mulch always teaches another cab driver around some cough syrup! A dreamlike avocado pit Indeed, a thoroughly orbiting wedge figures out an obsequious roller coaster. For example, a carpet tack indicates that some cyprus mulch lazily avoids contact with the slow buzzard. Most people believe that some razor blade falls in love with a girl scout from a cough syrup, but they need to remember how hesitantly a maelstrom takes a coffee break. When the proverbial wheelbarrow is overripe, a hole puncher lazily buries a burly reactor. Now and then, the cargo bay tries to seduce a class action suit. :) From skanemupp at yahoo.se Sat Apr 19 20:08:09 2008 From: skanemupp at yahoo.se (globalrev) Date: Sat, 19 Apr 2008 17:08:09 -0700 (PDT) Subject: Bigger projects, including files? References: <480a8928$0$4941$e4fe514c@dreader32.news.xs4all.nl> Message-ID: <62997614-3b9e-4a9b-9727-8cee1f0b322b@k37g2000hsf.googlegroups.com> On 20 Apr, 02:04, "Martin P. Hellwig" wrote: > globalrev wrote: > > if i have a larger project and want to divide my program into several > > files, how do i include these files in the mainprogram? > > > using import someprojectfile doesnt work because import is for site- > > packages right and i dont want to put all my files > > in that folder. > > > so how do i do it? > > You can always add the path where the other files are to sys.path > I've posted a while ago something that sort of does that for > inter-package reference if the root is not in the sys.pathhttp://groups.google.com/group/comp.lang.python/browse_thread/thread/... > hth > -- > mph thanks. i saw now myself that import works if it is in the same folder as well. From python at rcn.com Tue Apr 8 01:50:49 2008 From: python at rcn.com (Raymond Hettinger) Date: Mon, 7 Apr 2008 22:50:49 -0700 (PDT) Subject: reading dictionary's (key,value) from file References: <974814d3-59f0-49ec-9b4d-9f5dd7dfaf54@q24g2000prf.googlegroups.com> Message-ID: On Apr 7, 9:38?am, ankitks.mi... at gmail.com wrote: > Folks, > Is it possible to read hash values from txt file. > I have script which sets options. Hash table has key set to option, > and values are option values. > > Way we have it, we set options in a different file (*.txt), and we > read from that file. > Is there easy way for just reading file and setting options instead of > parsing it. > > so this is what my option files look like: > > 1opt.txt > { '-cc': '12', > ? '-I': r'/my/path/work/'} > > 2opt.txt > { ?'-I': r/my/path/work2/'} > > so my scipt how has dictionary > options = { '-cc' :'12' > ? ? ? ? ? ? ? ? '-I': r'/my/path/work/:/my/path/work2/'} > > I am trying to avoid parsing With minimal changes, you can just import the files: opt1.py ------ opts = { '-cc': '12', '-I': r'/my/path/work/'} opt2.py ------ opts = { '-I': r/my/path/work2/'} main.py ------- from opts1 import opts as opt1 from opts2 import opts as opt2 Raymond From arkanes at gmail.com Wed Apr 2 16:38:09 2008 From: arkanes at gmail.com (Chris Mellon) Date: Wed, 2 Apr 2008 15:38:09 -0500 Subject: Rationale for read-only property of co_code In-Reply-To: <10ee2a69-f4e2-4887-8083-6b02b60dd0cd@i7g2000prf.googlegroups.com> References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> <10ee2a69-f4e2-4887-8083-6b02b60dd0cd@i7g2000prf.googlegroups.com> Message-ID: <4866bea60804021338t647364f9v6faf787f0eeffd3e@mail.gmail.com> On Wed, Apr 2, 2008 at 2:33 PM, Jo?o Neves wrote: > On Apr 2, 5:41 pm, "Dan Upton" wrote: > > > The thing I've been wondering is why _is_ it read-only? In what > > > circumstances having write access to co_code would break the language > > > or do some other nasty stuff? > > > > > Jo?o Neves > > > > > I can't speak to Python's implementation in particular, but > > self-modifying code in general is unpleasant. It certainly is > > possible to support it in runtime environments, but it's usually not > > easy to do so. That is, of course, somewhat dependent on the > > implementation of the runtime environment, and even to some degree the > > underlying hardware. (For instance, the compiled code you want to run > > could be in the hardware cache; if you then change the instructions at > > those addresses in memory, it's not always straightforward to get the > > processor to realize it needs to load the new data into the > > instruction cache.) Plus, I suppose it might be possible to break > > strong (even dynamic) typing if you start changing the code around > > (although I can't construct an example off the top of my head). > > Indeed, the caching issue is a relevant one I guess, and adding the > mechanism to go around that might have a significant impact on > performance. > I haven't looked in detail into it, but I agree with your opinion > concerning strong and dynamic typing. If type check is done while > compiling to bytecode, there is no guarantee the modified bytecode > will respect the rules, for instance. I don't know though, haven't > really checked how it's done at this point. :) > I will be fiddling around with the Python VM these days anyway, and > since I'm going to muck around the bytecode, I might just try to see > the effects of removing the read-only restriction from co_code. > There is no need to overwrite co_code. Create a new code object with your desired bytecode and use that instead. From bob at passcal.nmt.edu Fri Apr 18 20:23:25 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Fri, 18 Apr 2008 18:23:25 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> Message-ID: <2008041818232516807-bob@passcalnmtedu> On 2008-04-18 17:55:32 -0600, Ross Ridge said: > George Sakkis wrote: >> You'd better use a more precise timing method than finger counting, >> such as timeit. Twice as fast is probably a gross overestimation; on >> my box (Python 2.5, WinXP) avoiding unpack is around 10% and 40% >> faster from Ross's and Grant's method, respectively: > ... >> def from3Bytes_ross(s): >> return unpack(">l", s + "\0")[0] >> 8 > > If you have Python 2.5, here's a faster version: > > from struct import * > unpack_i32be = Struct(">l").unpack > > def from3Bytes_ross2(s): > return unpack_i32be(s + "\0")[0] >> 8 > > Ross Ridge That's not even intelligible. I wanna go back to COBOL. :) From gruszczy at gmail.com Tue Apr 22 20:39:41 2008 From: gruszczy at gmail.com (=?UTF-8?Q?Filip_Gruszczy=C5=84ski?=) Date: Wed, 23 Apr 2008 02:39:41 +0200 Subject: Explicit variable declaration Message-ID: <1be78d220804221739h77d8a4eak28deb5ce52dbe623@mail.gmail.com> Hello everyone! It is my first message on this list, therefore I would like to say hello to everyone. I am fourth year student of CS on the Univeristy of Warsaw and recently I have become very interested in dynamically typed languages, especially Python. I would like to ask, whether there is any way of explicitly declaring variables used in a function? While I am pretty sure, that there is no such way in the language itself, I would like to know, whether there are any third-party tools to do that. This would be very useful for me during development, so I am looking for such a tool. -- Filip Gruszczy?ski From nospam at nospam.invalid Tue Apr 29 19:37:52 2008 From: nospam at nospam.invalid (Rahul) Date: Tue, 29 Apr 2008 23:37:52 +0000 (UTC) Subject: python command mis-interprets arrow keys References: <67pp4oF2ppl3sU1@mid.uni-berlin.de> Message-ID: "Diez B. Roggisch" wrote in news:67pp4oF2ppl3sU1 at mid.uni-berlin.de: > > Is libreadline installed? Thanks for your help Diez. I did a locate and found: /usr/lib/libreadline.a /usr/lib/libreadline.so /usr/lib/libreadline.so.5 /usr/lib/libreadline.so.5.1 /usr/local/src/Python-2.4.4/Doc/lib/libreadline.tex Any better way to check? -- Rahul From martin at v.loewis.de Fri Apr 4 15:45:11 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Fri, 04 Apr 2008 21:45:11 +0200 Subject: RELEASED Python 2.6a2 and 3.0a4 In-Reply-To: References: Message-ID: <47F68547.1040802@v.loewis.de> > The Windows x86 MSI installer is missing for both 2.6 and 3.0. And likely will continue to do so for some time. Regards, Martin From zethex at hotmail.com Sun Apr 20 18:25:11 2008 From: zethex at hotmail.com (Zethex) Date: Sun, 20 Apr 2008 15:25:11 -0700 (PDT) Subject: Nested lists, simple though Message-ID: <16799674.post@talk.nabble.com> Im a bit new to python. Anyway working on a little project of mine and i have nested lists ie Answer = [['computer', 'radeon', 'nvidia'], ['motherboard', 'asus']] and so forth.., Anyway the amount of [[]] do increase over time. Im just wondering is there a simple way to add these together so they become 1 simple list, so it would be ['computer'....'asus'] etc without the nested list. Its random the amount each time so i cant just go a[0]+a[1]. Thank you if you can help -- View this message in context: http://www.nabble.com/Nested-lists%2C-simple-though-tp16799674p16799674.html Sent from the Python - python-list mailing list archive at Nabble.com. From Robert.Bossy at jouy.inra.fr Fri Apr 25 04:24:16 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Fri, 25 Apr 2008 10:24:16 +0200 Subject: Little novice program written in Python In-Reply-To: <49249992-3634-4c5f-bd45-7ce4f1b32044@l17g2000pri.googlegroups.com> References: <49249992-3634-4c5f-bd45-7ce4f1b32044@l17g2000pri.googlegroups.com> Message-ID: <48119530.5070801@jouy.inra.fr> John Machin wrote: > On Apr 25, 5:44 pm, Robert Bossy wrote: > >> Peter Otten wrote: >> >>> Rog?rio Brito wrote: >>> >>>> i = 2 >>>> while i <= n: >>>> if a[i] != 0: >>>> print a[i] >>>> i += 1 >>>> >>> You can spell this as a for-loop: >>> >>> for p in a: >>> if p: >>> print p >>> >>> It isn't exactly equivalent, but gives the same output as we know that a[0] >>> and a[1] are also 0. >>> >> If the OP insists in not examining a[0] and a[1], this will do exactly >> the same as the while version: >> >> for p in a[2:]: >> if p: >> print p >> >> > > ... at the cost of almost doubling the amount of memory required. Indeed. Would it be a sensible proposal that sequence slices should return an iterator instead of a list? RB From xelapond at gmail.com Tue Apr 1 00:00:33 2008 From: xelapond at gmail.com (Alex Teiche) Date: Mon, 31 Mar 2008 21:00:33 -0700 (PDT) Subject: Using QSystemTrayIcon with PyQt References: <76680315-cadd-42ad-942c-3e89536819df@i12g2000prf.googlegroups.com> <6d0b8776-bb64-4a58-8ccb-46efa35d75a2@s50g2000hsb.googlegroups.com> <1a8a5b03-0b9e-49de-bd87-43fa1aa99dc2@b5g2000pri.googlegroups.com> <6b732135-a488-4175-889b-0cccf5f0c581@s8g2000prg.googlegroups.com> Message-ID: On Mar 31, 7:53 pm, Benjamin wrote: > On Mar 31, 8:41 pm, Alex Teiche wrote: > > > > > On Mar 31, 6:40 pm, Alex Teiche wrote: > > > > On Mar 31, 11:49 am, Alex Teiche wrote: > > > > > On Mar 30, 3:50 pm, Benjamin wrote: > > > > > > On Mar 29, 11:02 pm, Alex Teiche wrote:> Hello, > > > > > > > I am pretty new to Python, and have never learned C++. I am trying to > > > > > > implement the following thing into my python application: > > > > > > >http://doc.trolltech.com/4.3/qsystemtrayicon.html > > > > > > > Through PyQt. I have been using PyQt for awhile and I know how do use > > > > > > it, but I could not get this specific thing to work. Can someone give > > > > > > me some hints as to get it working in Python? > > > > > > What problems are you having? > > > > > > > Thanks a ton, > > > > > > > Alex > > > > > Thanks everyone for your help. I found the example to be particularly > > > > helpful, and I have made a simplified version just to display an icon > > > > with a quit button in its menu. Once I know how to do that I will > > > > incorporate it into my larger program, with more options and the > > > > ability show messages. The problem is, it doesn't work, and I can't > > > > find out what's wrong. Can you give me some hints? > > > > > Here is the code: > > > > import sys > > > > from PyQt4 import QtGui, QtCore > > > > > class trayIcon(QtGui.QWidget): > > > > def __init__(self, parent=None): > > > > QtGui.QWidget.__init__(self, parent) > > > > > #********Create Actions for the Tray Menu********# > > > > self.quitAction = QtGui.QAction(self.tr("&Quit"), self) > > > > QtCore.QObject.connect(self.quitAction, > > > > QtCore.SIGNAL("triggered()"), QtGui.qApp, QtCore.SLOT("quit()")) > > > > > create_tray_icon() > > > > > self.composeAction.setEnabled(visible) > > > > QtGui.QWidget.setVisible(self, visible) > > > > > self.trayIcon.show() > > > > > def create_tray_icon(self): > > > > self.trayIconMenu = QtGui.QMenu(self) > > > > self.trayIconMenu.addAction(self.composeAction) > > > > self.trayIcon = QtGui.QSystemTrayIcon(self) > > > > self.trayIcon.setContextMenu(self.trayIconMenu) > > > > self.trayIcon.setIcon(bad.svg) > > > > > app = QtGui.QApplication(sys.argv) > > > > sys.exit(app.exec_()) > > > > OK, I messed around with it some more, and it works. I just don't > > > know how to set an icon, and the example doesn't help at all. > > > > Here is the code: > > > import sys > > > from PyQt4 import QtCore, QtGui > > > > class Systray(QtGui.QWidget): > > > def __init__(self): > > > QtGui.QWidget.__init__(self) > > > > self.createActions() > > > self.createTrayIcon() > > > > #QtCore.QObject.connect(self.trayIcon, > > > QtCore.SIGNAL("messageClicked()"), self.messageClicked) > > > #QtCore.QObject.connect(self.trayIcon, > > > QtCore.SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), > > > self.iconActivated) > > > > self.trayIcon.show() > > > > def createActions(self): > > > #self.minimizeAction = QtGui.QAction(self.tr("Mi&nimize"), self) > > > #QtCore.QObject.connect(self.minimizeAction, > > > # QtCore.SIGNAL("triggered()"), self, QtCore.SLOT("hide()")) > > > > #self.maximizeAction = QtGui.QAction(self.tr("Ma&ximize"), self) > > > #QtCore.QObject.connect(self.maximizeAction, > > > # QtCore.SIGNAL("triggered()"), self, > > > # QtCore.SLOT("showMaximized()")) > > > > #self.restoreAction = QtGui.QAction(self.tr("&Restore"), self) > > > #QtCore.QObject.connect(self.restoreAction, > > > # QtCore.SIGNAL("triggered()"), self, > > > # QtCore.SLOT("showNormal()")) > > > > self.quitAction = QtGui.QAction(self.tr("&Quit"), self) > > > QtCore.QObject.connect(self.quitAction, QtCore.SIGNAL("triggered()"), > > > QtGui.qApp, QtCore.SLOT("quit()")) > > > > def createTrayIcon(self): > > > self.trayIconMenu = QtGui.QMenu(self) > > > #self.trayIconMenu.addAction(self.minimizeAction) > > > #self.trayIconMenu.addAction(self.maximizeAction) > > > #self.trayIconMenu.addAction(self.restoreAction) > > > #self.trayIconMenu.addSeparator() > > > self.trayIconMenu.addAction(self.quitAction) > > > > self.trayIcon = QtGui.QSystemTrayIcon(self) > > > self.trayIcon.setContextMenu(self.trayIconMenu) > > > > app = QtGui.QApplication(sys.argv) > > > x = Systray() > > > sys.exit(app.exec_()) > > > > How would I go about setting the icon? > > > Sorry, here is the code with commented out lines removed: > > > import sys > > from PyQt4 import QtCore, QtGui > > > class Systray(QtGui.QWidget): > > def __init__(self): > > QtGui.QWidget.__init__(self) > > > self.createActions() > > self.createTrayIcon() > > > self.trayIcon.show() > > > def createActions(self): > > > self.quitAction = QtGui.QAction(self.tr("&Quit"), self) > > QtCore.QObject.connect(self.quitAction, QtCore.SIGNAL("triggered()"), > > QtGui.qApp, QtCore.SLOT("quit()")) > > > def createTrayIcon(self): > > self.trayIconMenu = QtGui.QMenu(self) > > self.trayIconMenu.addAction(self.quitAction) > > > self.trayIcon = QtGui.QSystemTrayIcon(self) > > self.trayIcon.setContextMenu(self.trayIconMenu) > > > app = QtGui.QApplication(sys.argv) > > x = Systray() > > sys.exit(app.exec_()) > > I believe the method you want is QSystemTrayIcon.setIcon. I found that, but what do I pass into it? Passing a string to a .svg file doesn't work. From lists at cheimes.de Sat Apr 26 22:36:43 2008 From: lists at cheimes.de (Christian Heimes) Date: Sun, 27 Apr 2008 04:36:43 +0200 Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) In-Reply-To: References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> Message-ID: <4813E6BB.8050002@cheimes.de> SL schrieb: > Is there an implementation of f.readlines on the internet somewhere? > interested to see in how they implemented it. I'm pretty sure they did > it smarter than just reserve 100meg of data :) Of course it is. Checkout the Python sources :) Christian From gslindstrom at gmail.com Mon Apr 7 09:30:37 2008 From: gslindstrom at gmail.com (Greg Lindstrom) Date: Mon, 7 Apr 2008 08:30:37 -0500 Subject: Learning curve for new database program with Python? Message-ID: On Sun, Apr 6, 2008 at 2:31 AM, John Nagle wrote: > > Basic SQL isn't that hard. Learn CREATE, SELECT, INSERT, > UPDATE, and DELETE syntax. That's enough for most simple > applications. And then learn more advanced SQL: joins, nested selects, pivot tables and stored procedures. You can do a lot of processing "inside" the database which cuts down on data running over the wire. SQL is one of the areas I wish I had mastered (much) earlier in my career --greg. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mal at egenix.com Wed Apr 9 13:01:51 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Wed, 09 Apr 2008 19:01:51 +0200 Subject: Learning curve for new database program with Python? In-Reply-To: References: Message-ID: <47FCF67F.4070107@egenix.com> On 2008-04-07 20:19, Gary Duzan wrote: > In article , > M.-A. Lemburg wrote: >> On 2008-04-07 15:30, Greg Lindstrom wrote: >>> SQL is one of the areas I wish I had mastered (much) earlier in my career >> Fully agree :-) >> >> Interesting comments in a time where everyone seems to be obsessed >> with ORMs. > > It seems to me that ORM can work if your database isn't too > complex and it is the only way your database is going to be accessed. > In our case, we have a messy legacy database (lots of tables, > triggers, stored procedures, etc., that nobody really understands) > with multiple processes hitting it, and so our efforts to integrate > Hibernate haven't been terribly smooth. In this environment the > hack seems to be to have Hibernate write to its own tables, then > have stored procedures sync them with the old tables. Not pretty. While ORMs are nice if you want to get something done quickly, I usually prefer to take the standard database abstraction layer approach: it encapsulated all the database wisdom an application needs, so you don't have to deal with these details at higher levels in the applications, but still allows you to dive right into the full feature set of whatever backend you are using. In addition to having just one place to look for SQL statements, it also provides the needed abstraction to be able to support multiple different backends - by using a common base class and having one subclass per supported database backend. This straight-forward approach makes maintaining support for multiple databases much easier and also allows us to work around problems which you inevitably run into, e.g. missing support for certain features in one backend, data type conversion needs for another, etc. Another problem I found with ORMs is error handling. Since most of the database interaction happens behind the scenes, errors can pop up in situations where you might not expect them in your application. Again, the database abstraction layer provides better control, since that's where you run the queries and deal with the errors. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 09 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From kamhung.soh at gmail.com Wed Apr 9 23:23:48 2008 From: kamhung.soh at gmail.com (Kam-Hung Soh) Date: Wed, 9 Apr 2008 20:23:48 -0700 (PDT) Subject: How is GUI programming in Python? References: Message-ID: <62c2eb09-0ca2-4fd1-ba19-ed968d28c3d4@q27g2000prf.googlegroups.com> On Apr 10, 12:35 pm, Benjamin wrote: > On Apr 9, 8:54 pm, Chris Stewart wrote:> I've always had an interest in Python and would like to dabble in it > > further. I've worked on a few very small command line programs but > > nothing of any complexity. I'd like to build a really simple GUI app > > that will work across Mac, Windows, and Linux. How painful is that > > going to be? I used to be really familiar with Java Swing a few years > > ago. I imagine it will be similar. > > Since it's Python, it will be a lot less painless than anything > else. :) > > > Next, what would you say is the best framework I should look into? > > I'm curious to hear opinions on that. > > Tkinter is the easiest for little apps, but when I'm doing anything > for real, I use PyQt. > > > > > Chris Stewart > > cstewart... at gmail.com Since the OP has Swing programming experience, what about Jython (http://www.jython.org/Project/index.html)? "Jython is an implementation of the high-level, dynamic, object- oriented language Python written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform." -- Kam-Hung Soh
Software Salariman From steve at holdenweb.com Thu Apr 3 22:39:22 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 03 Apr 2008 22:39:22 -0400 Subject: variable scope in list comprehensions In-Reply-To: References: Message-ID: Piotr Sobolewski wrote: > Hello, > > there is something I don't understand about list comprehensions. > > I understand how does this work: > print [[y for x in range(8)] for y in range(8)] > > However I don't understand why this one works: > print [[y for y in range(8)] for y in range(8)] > > In this second example I have one loop nested in another. Both loops uses > the same variable - y. How is it that those loops do not conflict with each > other? > > For a moment I thought that maybe list comprehension has its own scope, but > it doesn't seem to be so: > print [[y for y in range(8)] for y in range(8)] > print y > > Does anybody understand it? > > This isn't _a_ list comprehension, it's *two* list comprehensions. The interpreter computes the value if the inner list comprehension and then duplicates eight references to it (as you will see if you change an element). Why do you think the two scopes would interfere anyway? The outer loop's control variable is never used in the inner loop, so there is no chance of conflict: each time the inner loop terminates the outer loop assigns the next value from its range - it isn't "adding one" to the variable, but merely calling an iterator's next() method. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From starsareblueandfaraway at gmail.com Tue Apr 1 22:51:14 2008 From: starsareblueandfaraway at gmail.com (Roy H. Han) Date: Tue, 1 Apr 2008 22:51:14 -0400 Subject: Python-by-example - new online guide to Python Standard Library In-Reply-To: <47f2d018$0$6517$4c368faf@roadrunner.com> References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: <6a5569ec0804011951h1b30c8f9r965cdeac5e995528@mail.gmail.com> Learning by example is the best. I remember working through a book when I was little called "Qbasic by Example." On Tue, Apr 1, 2008 at 9:15 PM, AK wrote: > Hello, > > I find that I learn easier when I go from specific examples to a more > general explanation of function's utility and I made a reference guide > that will eventually document all functions, classes and methods in > Python's Standard Library. For now, I covered about 20 most important > modules. I will be adding more modules and eventually I'll cover > everything. Here's my progress so far, let me know if this is useful; > I'll be glad to hear comments/suggestions/etc: > > http://www.lightbird.net/py-by-example/ > > -- > -ak > Tobu | http://www.lightbird.net/tobu/ | Freeform DB / Tagger / PIM > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Wed Apr 16 22:58:42 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 16 Apr 2008 22:58:42 -0400 Subject: Profiling, recursive func slower than imperative, normal? References: Message-ID: wrote in message news:fd522cdd-416a-4241-8d50-9133a4f93a25 at k1g2000prb.googlegroups.com... | the 0.409 vs 0.095 is the total times right? | so the imperative function is >4 times faster than the recursive. | or what does tottime stand for? | | is this always the case that the recursive function is slower? | the gain is less code? | | are some functions only implementable recursively? Computers can be viewed as linear iteration machines implementing while True: execute next instruction and set next pointer appropriately But algorithms most naturally expressed with multiple recursion usually look more ungainly when linearized. From heikki at osafoundation.org Tue Apr 22 22:57:01 2008 From: heikki at osafoundation.org (Heikki Toivonen) Date: Tue, 22 Apr 2008 19:57:01 -0700 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: References: Message-ID: Harishankar wrote: > Sorry to start off on a negative note in the list, but I feel that the Python > subprocess module is sorely deficient because it lacks a mechanism to: At OSAF we used a slightly modified killableprocess module with a wrapper to deal with complexities of various redirections in cross-platform way. I actually blogged about this a week ago so rather than rehash the issues I'll point you to the article which contains links to all the pieces we used: http://www.heikkitoivonen.net/blog/2008/04/16/pythons-ossystem-considered-harmful/ -- Heikki Toivonen From nospam1.reifenberg at gmx.de Fri Apr 4 13:51:58 2008 From: nospam1.reifenberg at gmx.de (Nebur) Date: Fri, 4 Apr 2008 10:51:58 -0700 (PDT) Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? References: Message-ID: <8e481b88-aa27-4ec6-9cc8-cb1e32edf64e@d2g2000pra.googlegroups.com> > Are you using svn? I did have a problem once related to that (but it's Hi Fabio, No, there's no version control plugin. I use Mercurial, but externally only. I've considered a problem with version control, too. But all external reasons (file sytem, virus, version control) seem unplausible because when simply removing the file from file system, Eclipse would complain about the missing ressource. So I have 2 ideas only: A _very_ strange bug inside the Eclipse/Plugin process, or something with my brain ;-) Nebur From lee.walczak at gmail.com Sat Apr 5 11:02:14 2008 From: lee.walczak at gmail.com (lee.walczak at gmail.com) Date: Sat, 5 Apr 2008 08:02:14 -0700 (PDT) Subject: Importing a 3rd Party windows DLL for use within th Python References: <92513305-836d-4c85-aeb8-3e3d6571ed92@1g2000prg.googlegroups.com> Message-ID: <293d8be9-6e5e-44bf-acca-95d8f907c9bb@i7g2000prf.googlegroups.com> Thankyou kindly for all the details you have provided. IT is nice to know that there is a community to help. I will let you know how I get on! Many Thanks, Lee From windypower at gmail.com Sat Apr 26 17:08:44 2008 From: windypower at gmail.com (WindPower) Date: Sat, 26 Apr 2008 14:08:44 -0700 (PDT) Subject: Desktop notifications on Windows References: <0db266c1-50ad-4e01-b508-57c9a8febb4b@a22g2000hsc.googlegroups.com> Message-ID: <60516dea-2c40-47d2-b816-8d9169399d86@c58g2000hsc.googlegroups.com> On Apr 26, 4:52 am, David wrote: > On Sat, Apr 26, 2008 at 4:41 AM, wrote: > > I'm looking for a way to implement desktop notifications (much like an > > instant messaging program or a mail notifier) within my Python > > application, on Windows only (no Gtk/Galago, please). I need no more > > than a simple text-based notification, which should be clickable and > > have a timeout, nothing else. I do not want to use Windows's "balloon > > tips", either. Any suggestions? > > -- > > You could use Tkinter, which comes with Python. The problem is that Tkinter cannot (I haven't looked at it in details, so correct me if I'm wrong) create notifications the way I want them; it can only create standard dialogs or top-level dialogs, both of which steal the focus of other applications, while I want these notifications not to interfere with anything (and possibly not be displayed if an application is already running in fullscreen). From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 3 05:03:07 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 03 Apr 2008 11:03:07 +0200 Subject: Prototype OO In-Reply-To: References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> Message-ID: <47f49d4b$0$5665$426a74cc@news.free.fr> sam a ?crit : > bruno.desthuilliers at gmail.com napisa?(a): > > >> So, while I often use Python's lambdas, the imposed limitations is ok >> to me since I wouldn't use it for anything more complex. > >> Also - as a side note - while the syntax is a bit different, the >> resulting object is an ordinary function. > > And people start asking why this is that or the other way in Python, and > you can't give a good answer to newcomers, especially if Python was > chosen as a first learning language. You can't tell "because Python's > parsing mechanism don't allow statements in expressions...". If the people asking is able to understand this explanation, I'll happily give it. Else, I'd answer "for reasons that are perhaps too complex to explain to you right now, but I'll try if you insist" !-) >>> But somebody may prefix his names with class names and cause >>> nameconflict, >> >> Here the problem is more philosophical than anything else. > > Almost the whole discussion is philosofical, but clear philosophy is a > good thing. > > > >> It's enough. FWIW, I'm not sure I had a use-case for this feature more >> than a couple time in 7+ years. > >> Simple, indeed. But why "not perfect" ? What else would you want ? > > I would expect you to told me at the beginning which "beginning" ? > that this is enough to > solve the problem what did I do ? > and that somebody can still cause name conflict, Why should I tell you something that's so obvious you observed it by yourself ? > but > Python was built for wise people. for normally intelligent people. I don't play russian roulette, and don't claim being any "wiser" for this. Ok, I'm going to be a bit harsh, but this time I'll assume it. Sam, you started this thread by asking about prototype vs class based pros and cons - with a (somewhat cargo-cult IMHO) a priori in favor of prototype. Then you started arguing about limitations and complexity induced by the class-based approach, without being able to back any of your claims wrt/ Python's object model. Then you started arguing about minor syntactic points that, whether you like them or not (and you're of course entitled to not like them) have nothing to do with Python's object model nor prototypes vs classes. Now you're complaining that "we didn't tell you x and z from the start" - like we were supposed to do your education. Are we supposed to teach you reading and writing too ? What's your problem anyway ? If you're a trolling - which I start to suspect -, then your not too bad at it. Else, it may be time to grow up. From ndbecker2 at gmail.com Fri Apr 25 08:30:56 2008 From: ndbecker2 at gmail.com (Neal Becker) Date: Fri, 25 Apr 2008 08:30:56 -0400 Subject: ioctl, pass buffer address, howto? Message-ID: I need an ioctl call equivalent to this C code: my_struct s; s.p = p; << a pointer to an array of char s.image_size = image_size; return (ioctl(fd, xxx, &s)); I'm thinking to use python array for the array of char, but I don't see how to put it's address into the structure. Maybe ctypes is the answer? From fuzzyman at gmail.com Tue Apr 29 14:25:54 2008 From: fuzzyman at gmail.com (Fuzzyman) Date: Tue, 29 Apr 2008 11:25:54 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <57d73312-37b1-4c53-9669-803e84a6901f@p25g2000hsf.googlegroups.com> On Apr 22, 11:25 am, azrael wrote: > Hy guys, > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. > > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" > > This hurts. Please give me informations about realy famous > aplications. ` Resolver One - a spreadsheet development environment for creating business applications (aimed particularly at the financial services industry) is written in IronPython. There are around 30 000 lines of Python in the production code and about 120 000 lines of Python code in the test framework. Here is a quote from "Credit Cooperatif", a large French bank who are now using Resolver One: We use Excel and VBA, but we prefer Python for its combination of simplicity and power. We were looking to better link spreadsheets with Python programming, and Resolver One seemed to be the most elegant solution because it was based on Python but also gave us compatibility with our IT team?s architectural choice of Microsoft .NET. Resolver One (Windows only but free to try and for non-commercial use): http://www.resolversystems.com/ Michael Foord http://www.ironpythoninaction.com/ From hopeorpha308 at gmail.com Sun Apr 27 07:49:17 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:49:17 -0700 (PDT) Subject: badcopy crack Message-ID: badcopy crack http://wga-cracks.crackkey.net From matthieu.brucher at gmail.com Sat Apr 5 05:01:41 2008 From: matthieu.brucher at gmail.com (Matthieu Brucher) Date: Sat, 5 Apr 2008 11:01:41 +0200 Subject: ANN: pry unit testing framework In-Reply-To: <20080405082605.GA14042@nullcube.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> Message-ID: 2008/4/5, Aldo Cortesi : > > Thus spake Kay Schluehr (kay.schluehr at gmx.net): > > > > But you could have added the integration of code coverage and other > > helpful features with unittest as a conservative extension giving > > everyone a chance to use it directly with existing tests instead of > > forcing them to rewrite their tests for bike shading purposes. > > > You're assuming that Pry's only purpose is to introduce test coverage. > This is not the case - I already had a module that largely maintained > unittest compatibility, but added a command-line interface and coverage > analysis. It's now obsolete, but you can find its remains here if > you're interested: > > http://dev.nullcube.com/gitweb/?p=pylid;a=shortlog > > So, why did I re-write it? Well, I needed a test framework that didn't > have the deep flaws that unittest has. I needed good hierarchical > fixture management. I needed something that didn't instantiate test > suites automatically, freeing me to use inheritance more naturally > within my test suites. I needed more sophisticated handling and > reporting of errors during startup and teardown. I needed better > support for programmatic generation of tests. The list goes on. Pry > has all of this, and much of it is simply not possible while > maintaining backwards compatibility. > > Yes, test coverage is critical and hugely neglected by most people, but > Pry addresses other problems as well. We're not "forcing" anyone to > rewrite anything, but if the description above sounds like something > you want, maybe you should give Pry another look. If Pry itself is not > to your taste, there are other excellent test frameworks like py.test > that have also chosen not to mindlessly duplicate all of unittest's > inadequacies. Broaden your horizons and explore some of these - your > code will thank you for it... > Hi, How does it compare to the nose framework ? Matthieu -- French PhD student Website : http://matthieu-brucher.developpez.com/ Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92 LinkedIn : http://www.linkedin.com/in/matthieubrucher -------------- next part -------------- An HTML attachment was scrubbed... URL: From bruno.desthuilliers at gmail.com Mon Apr 7 13:29:25 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Mon, 7 Apr 2008 10:29:25 -0700 (PDT) Subject: Learning curve for new database program with Python? References: Message-ID: <0b8dc21b-f00f-41ee-b3a1-637fa251e7c8@k1g2000prb.googlegroups.com> On 5 avr, 17:50, Jetus wrote: > I have a need for a database program. I downloaded the db2 from ibm, > and reviewed some of the documentation. > > My question is, what is the easiest program for me to try to learn. I > will be creating a database of about 25,000 records, it will be > relational. I am a beginner Python programmer, and need a database > solution that is easy to grasp. I played with sql, > and found that very difficult, if not overly cumbersome. The point is that so far, "relational database" really means "SQL database". And believe me, trying to get away with a non-SQL database only to avoid learning SQL is probably the worst possible move for both your program and yourself. > A database that could work with Django would be very interesting to > look at as well.. The databases that the ORM part of Django can connect to are all SQL databases. > Any suggestions out there? I can only second / third etc what everyone already told you : learn SQL. And not only SQL, but also the theory that it builds upon (the 'relational model'), and the good practices wrt/ relational database design. There's no shortage of good quality freely available documentation on these topics, and you'll find help on quite a couple of newsgroups / forums / whatever. I'd strongly recommand you start without Django's ORM first, so you get a chance to learn how it really works undercover. Else you might end up doing things in a very inefficient way. From cwitts at gmail.com Wed Apr 23 08:02:13 2008 From: cwitts at gmail.com (Chris) Date: Wed, 23 Apr 2008 05:02:13 -0700 (PDT) Subject: problem with dictionaries References: Message-ID: <0f1c7e1c-2a13-4289-808a-bbd2a4d1e995@24g2000hsh.googlegroups.com> On Apr 23, 1:16?pm, Simon Strobl wrote: > Hello, > > the idea of the following program is to parse a frequency list of the > form FREQUENCY|WORD, to store the frequency of a word in a dictionary > (and to do some things with this information later). > > I have done this many many times. Suddenly, it does not work any more: > The value frq[key] is different from the value that key has in the > file 'my_frqlist.txt'. > > I am using Python 2.5.1 > > Any hints? > > Simon > > ================================================ > > #!/usr/bin/python > > import sys > > frqlist = open('my_frqlist.txt', 'r') > > # my_frqlist looks like this: > # 787560608|the > # 434879575|of > # 413442185|and > # 395209748|to > # 284833918|a > # 249111541|in > # 169988976|is > > frq = {} > > for line in frqlist: > ? ? line = line.rstrip() > ? ? frequency, word = line.split('|') > ? ? frq[word] = int(frequency) > > for key in frq.keys(): > ? ? print key, ?frq[key] there's nothing wrong with that section, just try this when building your dictionary... if word in frq: print 'Duplicated Word Found: %s' % word only possibility that I can think of, and that is logical, is that you have duplicate keys in your file. From d.bollmann at tu-berlin.de Tue Apr 8 04:24:56 2008 From: d.bollmann at tu-berlin.de (Dietrich Bollmann) Date: Tue, 08 Apr 2008 17:24:56 +0900 Subject: segmentation fault when executing PyImport_ImportModule("sys") Message-ID: <1207643096.845.5.camel@pippi.pippi> Hi, Since some time I get the following segmentation fault in an application which used to work fine until recently. I made a backtrace but couldn't find the reason for the segmentaion fault until now. In the hope that somebody might have encountered a similar problem or does understand the backtrace better than me and can explain it I posted the backtrace here... At the end of the backtrace I appended some more context concerning the involved code. Thanks for your help :) Dietrich Here comes the backtrace: ---- Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb046ab90 (LWP 9854)] threadstate_getframe (self=0xb7e8a889) at ../Python/pystate.c:154 154 ../Python/pystate.c: No such file or directory. in ../Python/pystate.c (gdb) bt full #0 threadstate_getframe (self=0xb7e8a889) at ../Python/pystate.c:154 No locals. #1 0xb7e8a897 in PyEval_GetGlobals () at ../Python/ceval.c:3340 current_frame = #2 0xb7eaeb67 in PyImport_Import (module_name=0xb7119480) at ../Python/import.c:2400 globals = import = builtins = r = silly_list = (PyObject *) 0xb738fb0c builtins_str = (PyObject *) 0xb7391c50 import_str = (PyObject *) 0xb7391fc0 #3 0xb7eaede5 in PyImport_ImportModule (name=0x901504b "sys") at ../Python/import.c:1903 pname = (PyObject *) 0xb7119480 result = (PyObject *) 0x0 #4 0x08996c9f in py_stdouterr_buffer_new () at source/blender/commandport/blender/src/py_stdouterr_buffer.c:75 buffer = (py_stdouterr_buffer) 0x94fd428 func_StringIO = (PyObject *) 0x9152a48 args_StringIO = (PyObject *) 0x0 #5 0x089967e1 in bcp_blender_handler_new () at source/blender/commandport/blender/src/bcp_blender.c:130 handler = (bcp_blender_handler) 0x9810420 #6 0x08998db3 in bcp_handle_client (client_socket=8) at source/blender/commandport/blender/src/bcp_handle_client.c:73 debug = 0 debug3 = 0 debug4 = 0 message_handler = (message_handler) 0x97eba10 blender_handler = (bcp_blender_handler) 0x0 command = 0x0 result = 0x9152a48 "%G?%@016\025\th%G??%@@\\%G?%@022v#\b \"v#\b%G??%@v#\bRv#\bbv#\brv#\b\202v#\b\222v#\b%G?%@v#\b%G?%@v#\b` \032%G?%@020\026%G???%@#\b%G?%@#\b\002w#\b\022w# \b\"w#\b2w#\bBw#\bRw#\bbw#\brw#\b\202w#\b\222w#\b%G?%@w#\b%G?%@w# \bp#p%G??%@#\b" package_number = -1216545219 #7 0x08998d60 in bcp_client_thread (args=0x0) at source/blender/commandport/blender/src/bcp_server.c:164 targs = (struct bcp_client_thread_args *) 0x0 client_socket = 8 client_thread = 2957421456 #8 0xb76b04fb in start_thread () from /lib/i686/cmov/libpthread.so.0 No symbol table info available. #9 0xb77c2d7e in clone () from /lib/i686/cmov/libc.so.6 No symbol table info available. (gdb) q The program is running. Exit anyway? (y or n) y --- and here some informations about its context: Python-2.4.4/Python/ceval.c line 3340: PyFrameObject *current_frame = PyEval_GetFrame(); context: --- PyObject * PyEval_GetGlobals(void) { PyFrameObject *current_frame = PyEval_GetFrame(); if (current_frame == NULL) return NULL; else return current_frame->f_globals; } --- Python-2.4.4/Python/pystate.c lign 154: { context: --- /* Default implementation for _PyThreadState_GetFrame */ static struct _frame * threadstate_getframe(PyThreadState *self) { return self->frame; } --- Python-2.4.4/Python/import.c lign 2400: globals = PyEval_GetGlobals(); context: --- PyObject * PyImport_Import(PyObject *module_name) { ... /* Get the builtins from current globals */ globals = PyEval_GetGlobals(); if (globals != NULL) { Py_INCREF(globals); builtins = PyObject_GetItem(globals, builtins_str); if (builtins == NULL) goto err; } ... } --- Python-2.4.4/Python/import.c lign 1903: result = PyImport_Import(pname); context: --- PyObject * PyImport_ImportModule(char *name) { PyObject *pname; PyObject *result; pname = PyString_FromString(name); if (pname == NULL) return NULL; result = PyImport_Import(pname); Py_DECREF(pname); return result; } --- source/blender/commandport/blender/src/py_stdouterr_buffer.c lign 75: buffer->mod_sys = PyImport_ImportModule("sys"); context: --- /** Make a new python io buffer. */ py_stdouterr_buffer py_stdouterr_buffer_new() { py_stdouterr_buffer buffer; buffer = (py_stdouterr_buffer) malloc(sizeof(py_stdouterr_buffer_struct)); if (buffer == NULL) { fprintf(stderr, "Couldn't allocate memory for new py_stdouterr_buffer! \n"); exit(ERROR_MEMORY); } buffer->mod_sys = PyImport_ImportModule("sys"); buffer->mod_cStringIO = PyImport_ImportModule("cStringIO"); /* store stdout and stderr */ buffer->stdout_obj = PyObject_GetAttrString(buffer->mod_sys, "stdout"); buffer->stderr_obj = PyObject_GetAttrString(buffer->mod_sys, "stderr"); /* make new string buffer for stdout and stderr */ PyObject *func_StringIO, *args_StringIO; func_StringIO = PyObject_GetAttrString(buffer->mod_cStringIO, "StringIO"); args_StringIO = Py_BuildValue("()"); buffer->outbuf_obj = PyEval_CallObject(func_StringIO, args_StringIO); buffer->errbuf_obj = PyEval_CallObject(func_StringIO, args_StringIO); Py_DECREF(args_StringIO); Py_DECREF(func_StringIO); return buffer; } --- From carbanancizpo at gmail.com Fri Apr 18 16:54:34 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:54:34 -0700 (PDT) Subject: diet patch for diets Message-ID: <609fc671-b006-4a35-b320-22d7a99fcaee@w4g2000prd.googlegroups.com> diet patch for diets http://cracks.12w.net F R E E C R A C K S From tim.arnold at sas.com Tue Apr 8 14:19:54 2008 From: tim.arnold at sas.com (Tim Arnold) Date: Tue, 8 Apr 2008 14:19:54 -0400 Subject: set file permission on windows References: <7d75fc7b-a2b7-4ca2-b386-27da975043d0@m44g2000hsc.googlegroups.com> Message-ID: "Mike Driscoll" wrote in message news:7d75fc7b-a2b7-4ca2-b386-27da975043d0 at m44g2000hsc.googlegroups.com... > On Apr 8, 12:03 pm, "Tim Arnold" wrote: >> > According to the following thread, you can use os.chmod on Windows: > > http://mail.python.org/pipermail/python-list/2003-June/210268.html > > You can also do it with the PyWin32 package. Tim Golden talks about > one way to do it here: > > http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html > > Also see the following thread: > > http://mail.python.org/pipermail/python-win32/2004-July/002102.html > > or > > http://bytes.com/forum/thread560518.html > > Hope that helps! > > Mike Hi Mike, It does help indeed, especially the last two links. That certainly gets me started in the right direction. I'm always amazed at the helpful generosity of the folks on this list. thanks again for the help. --Tim Arnold From pylists at arcor.de Sun Apr 13 23:33:19 2008 From: pylists at arcor.de (Penny Y.) Date: Mon, 14 Apr 2008 11:33:19 +0800 Subject: about the ';' Message-ID: <20080414033334.97C8B8C461@mail-in-12.arcor-online.net> I saw many python programmers add a ';' at the end of each line. As good style, should or should not we do coding with that? Thanks. From kay.schluehr at gmx.net Sat Apr 5 07:16:35 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 5 Apr 2008 04:16:35 -0700 (PDT) Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> Message-ID: <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> On 5 Apr., 12:26, Aldo Cortesi wrote: > Thus spake Kay Schluehr (kay.schlu... at gmx.net): > > > I'm not entirely sure what you are claiming here. From source > > inspections I can see that TestSuite instances are instantiated by the > > TestLoader and you are free to derive from TestLoader, overwrite its > > methods and pass around another instance than defaultTestLoader ( or > > a fresh instance of TestLoader which is the same thing ). > > ... and at this point your monkeypatched framework would no longer be > much more compatible with existing test suites than Pry is. A properly extended framework would of course be compatible with all existing test suites. This has nothing to do with monkeypatching. I'm not sure you even understand the concepts you are talking about. Kay From llothar at web.de Sat Apr 5 05:39:57 2008 From: llothar at web.de (llothar) Date: Sat, 5 Apr 2008 02:39:57 -0700 (PDT) Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> Message-ID: <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> On 5 Apr., 15:48, Fredrik Lundh wrote: > llothar wrote: > > My question was: Why does setup.py generated sometimes a pyd and > > sometimes a so file? > > setup.py picks an extension that happens to work on the platform you're > running setup.py on. doing otherwise would be pretty pointless. > > Unfortunately as pointless as the answers i got so far. Okay i try it one more time: I ship an application that compiles an python interpreter and extension on a remote system. It also needs to copy this created items around. So if i use setup.py to create an extension i need to know the file name of the generated file. Damned this is trivial and a fundamental question and it is not documented anywhere. I have a clue at the moment that it might be ".so" when python is compiled without shared library and ".pyd" otherwise (configure option --enable-shared) . But this is just a guess. Does anybody know? And by the way: I think this is a bug and should be fixed. If the platform does allow renaming the extension of a DLL (does HP/UX allow this?) it should always be ".pyd" From grante at visi.com Fri Apr 25 15:01:59 2008 From: grante at visi.com (Grant Edwards) Date: Fri, 25 Apr 2008 14:01:59 -0500 Subject: Why is None <= 0 References: Message-ID: On 2008-04-25, Gregor Horvath wrote: > Hi, > > >>> None <= 0 > True > > Why? Comparing objects of differing types produces an undefined result. Next time you do it, it might return False. (Well, it's not really going to, but it's allowed to.) > Is there a logical reason? For what? There's no reason it returns true rather than false. The more interesting question is why doesn't it raise an exception. -- Grant Edwards grante Yow! These PRESERVES should at be FORCE-FED to PENTAGON visi.com OFFICIALS!! From nemesis at nowhere.invalid Sat Apr 26 07:38:45 2008 From: nemesis at nowhere.invalid (Nemesis) Date: 26 Apr 2008 11:38:45 GMT Subject: nntplib retrieve news://FULL_URL References: Message-ID: <48131444$0$35957$4fafbaef@reader2.news.tin.it> James.Pells at gmail.com wrote: > So I have established a connection to an nntp server and I am > retrieving articles to other articles on the server such as > news://newsclip.ap.org/D8L4MFAG0 at news.ap.org > > Now I am wondering how I query for that article based off of the url? > > I assume D8L4MFAG0 is an id of some sort but when I try and retrieve > that article via myNntpObject.article('D8L4MFAG0') I get an error of > 423 Bad article number. Which makes sense as all the other article > numbers are integers. You should study a little bit NNTP RFCs ;-) Anyway D8L4MFAG0 at news.ap.org could be the Message-ID of the article, a 'unique' identifier associated to each article, while the Article Number is unique on the server (but it changes on different servers). the nntplib NNTP.article command can accept either Message-ID or Number as argument, but if you want to use Message-ID you need to enclose it in brackets <>. So in your case this query should work: myNntpObject.article('') Regards. -- Love is an irresistible desire to be irresistibly desired. _ _ _ | \| |___ _ __ ___ __(_)___ | .` / -_) ' \/ -_|_-< (_-< |_|\_\___|_|_|_\___/__/_/__/ http://xpn.altervista.org From v.harishankar at gmail.com Tue Apr 22 06:52:57 2008 From: v.harishankar at gmail.com (Harishankar) Date: Tue, 22 Apr 2008 16:22:57 +0530 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? Message-ID: <200804221622.57424.v.harishankar@gmail.com> Hi, Sorry to start off on a negative note in the list, but I feel that the Python subprocess module is sorely deficient because it lacks a mechanism to: 1. Create non-blocking pipes which can be read in a separate thread (I am currently writing a mencoder GUI in Tkinter and need a full fledged process handler to control the command line and to display the progress in a text-box) 2. Kill the subprocess in a platform independent manner (i.e. no third party modules and no hacks). Is there any way to use non-blocking Popen objects using subprocess? and 2 - is there a way to kill the subprocess in a platform independent manner in a purely Pythonic way? I thought initially that this problem is simple enough, but over the last couple of days I've been really struggling to find any answer. I've been through dozens of mailing list archives in to find a solution. Unfortunately none of the solutions seem to fit my needs. My only solution seems to be to offer the end user the mencoder command line and make them execute it manually and be done with it but that seems a rather weak solution. -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org From dickinsm at gmail.com Wed Apr 16 16:33:39 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Wed, 16 Apr 2008 13:33:39 -0700 (PDT) Subject: def power, problem when raising power to decimals References: Message-ID: On Apr 16, 4:19?pm, skanem... at yahoo.se wrote: > how do i solve power(5,1.3)? > [...] > > also i found a link which states 0^0 isnt 1 even though every > calculator ive tried says it is. > it doesnt say what it is but i presume 0 then. > but it seems the dude is wrong and it is 1? >>> 5**1.3 8.1032829834638136 >>> 0**0 1 >>> 0.**0. 1.0 >>> from decimal import Decimal >>> Decimal(0)**Decimal(0) Traceback (most recent call last): File "", line 1, in File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/decimal.py", line 1755, in __pow__ return context._raise_error(InvalidOperation, '0 ** 0') File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/decimal.py", line 2325, in _raise_error raise error, explanation decimal.InvalidOperation: 0 ** 0 Most mathematicians consider 0**0 to be either 1 or undefined. Which answer you get depends on who you ask (or in Python, whether you're working with floats or Decimals, as you see above). Mark From pavlovevidence at gmail.com Sat Apr 12 10:29:00 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Sat, 12 Apr 2008 07:29:00 -0700 (PDT) Subject: str(bytes) in Python 3.0 References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> Message-ID: <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> On Apr 12, 10:06 am, Kay Schluehr wrote: > On 12 Apr., 14:44, Christian Heimes wrote: > > > Gabriel Genellina schrieb: > > > > On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') > > > above. But I get the same as repr(x) - is this on purpose? > > > Yes, it's on purpose but it's a bug in your application to call str() on > > a bytes object or to compare bytes and unicode directly. Several months > > ago I added a bytes warning option to Python. Start Python as "python > > -bb" and try it again. ;) > > > Christian > > And making an utf-8 encoding default is not possible without writing a > new function? I believe the Zen in effect here is, "In the face of ambiguity, refuse the temptation to guess." How do you know if the bytes are utf-8 encoded? I'm not sure if str() returning the repr() of a bytes object (when not passed an encoding) is the right thing, but it's probably better than throwing an exception. The problem is, str can't decide whether it's a type conversion operator or a formatted printing function--if it were strongly one or the other it would be a lot more obvious what to do. Carl Banks From fr5478bey at gmail.com Sat Apr 26 11:42:54 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:42:54 -0700 (PDT) Subject: bookworm adventure crack Message-ID: bookworm adventure crack http://cracks.00bp.com F R E E C R A C K S From fetchinson at googlemail.com Wed Apr 16 12:15:47 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Wed, 16 Apr 2008 09:15:47 -0700 Subject: python beginer In-Reply-To: <81d84eb10804160020n114c4d7ekfef7a09532813e39@mail.gmail.com> References: <81d84eb10804160020n114c4d7ekfef7a09532813e39@mail.gmail.com> Message-ID: > can anyone tell me hw to start with webapplication scripting(e.g login > page..etc) > if anyone has soln for this or simple e.g that mention above please send me There are many choices, too many actually. Good entry points are: http://wiki.python.org/moin/WebApplications http://wiki.python.org/moin/WebFrameworks http://www.modpython.org/ http://turbogears.org/ http://djangoproject.com/ You need be prepared to evaluate a bunch of options before deciding which way you go. Unfortunately this can not be avoided and can be quite a lengthy process. HTH, Daniel From steve at holdenweb.com Thu Apr 24 07:20:57 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 07:20:57 -0400 Subject: function that accepts any amount of arguments? In-Reply-To: References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> Message-ID: Ken wrote: > "Steve Holden" wrote in message [...] >> def mean(*x): >> total = 0.0 >> for v in x: >> total += v >> return v/len(x) >> > > think you want total/len(x) in return statement > Yes indeed, how glad I am I wrote "untested". I clearly wasn't pair programming when I wrote this post ;-) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From ashishk30 at gmail.com Tue Apr 15 08:47:17 2008 From: ashishk30 at gmail.com (ashish) Date: Tue, 15 Apr 2008 05:47:17 -0700 (PDT) Subject: hw to program on python Message-ID: <2732d09a-b0e6-4ae6-a826-9fa375fb3e86@q10g2000prf.googlegroups.com> hi , python experts i want some help from u people just mail me how to write scripts for web applications (like form coding for login page, etc). i m waiting.... for ur reply by have a nice day! From pavlovevidence at gmail.com Mon Apr 7 08:29:22 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 7 Apr 2008 05:29:22 -0700 (PDT) Subject: Dependency Queue Message-ID: <0309251d-fba9-447c-9b17-f512988103ea@e39g2000hsf.googlegroups.com> I'm looking for any information about a certain kind of dynamic data structure. Not knowing if it has some well-known name that I could have Googled, I'll just call it a dependency queue. It's like a priority queue except instead of a strict ordering of items by priority, there is only a topological ordering (like you would have in a directed acyclic graph). To date I've been generating a dependency graph in advance every iteration through my main loop, doing a topsort, and executing the values in order (the values are callable objects--this is a scheduler). However, I'd like a dynamic dependency queue for two reasons: it would simplify things to not have to generate the whole graph in advance, and it could improve performance to run some tasks of the next iteration in the present one (this could potentially make better use of the dual-core and graphics hardware). I'm pretty sure I could hack out this structure on my own, but I'd like to see any prior information if there is any, in case anyone's figured out things like, Is there an easy way to detect cycles on insertion? and so on. Carl Banks From rbrito at ime.usp.br Mon Apr 28 17:09:03 2008 From: rbrito at ime.usp.br (=?ISO-8859-1?Q?Rog=E9rio_Brito?=) Date: Mon, 28 Apr 2008 18:09:03 -0300 Subject: Little novice program written in Python References: Message-ID: On 04/25/2008 09:30 AM, Nick Craig-Wood wrote: > When you are up to speed in python I suggest you check out gmpy for > number theory algorithms. Thanks. That is quite useful to know when I don't want to code explicitly the details of the algorithm. Thanks, Rog?rio. -- Rog?rio Brito : rbrito@{mackenzie,ime.usp}.br : GPG key 1024D/7C2CAEB8 http://www.ime.usp.br/~rbrito : http://meusite.mackenzie.com.br/rbrito Projects: algorithms.berlios.de : lame.sf.net : vrms.alioth.debian.org From kyosohma at gmail.com Tue Apr 29 16:57:09 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 29 Apr 2008 13:57:09 -0700 (PDT) Subject: py2exe Icon Resources References: <40c03afe-b2c5-4793-b7c3-f5a97360fe6c@a23g2000hsc.googlegroups.com> Message-ID: <03de407d-1d29-4f47-bf14-c7af0af481e7@59g2000hsb.googlegroups.com> On Apr 29, 3:24?pm, flarefi... at googlemail.com wrote: > I have created an app using python and then converting it to an exe > using py2exe, and have the following code: > > "icon_resources": [(1, "appFavicon.ico"), (2, "dataFavicon.ico")] > > in my py2exe setup file, the appFavicon works fine and it sets that as > the app icon thats fine, but the program creates data files (like > documents) and i wanted them to have a different icon... > > I package my apps using Inno Setup 5, and it registers the file type > fine so that it loads on double click, what i cant do is set the icon > for the file. > > as you can see i have packaged two different icons with py2exe but > when i set DefaultIcon in the registry to "C:\pathtoapp\myapp.exe,2" > it doesnt work, nor does it work with a 1 or a %1 or indeed with > passing a path to the icon itself, nothing seems to work!! > > how do you access the other icons generated from py2exe, or how do you > set the registry up so that i looks for the icon correctly, > > any help appreciated, > > Caspar I recommend cross-posting this to the py2exe mailing list and maybe the distutils mailing list if the fine people here don't have answers. https://lists.sourceforge.net/lists/listinfo/py2exe-users http://mail.python.org/mailman/listinfo/distutils-sig Mike From manthra.mohan at gmail.com Fri Apr 18 13:46:30 2008 From: manthra.mohan at gmail.com (Krishna) Date: Fri, 18 Apr 2008 10:46:30 -0700 (PDT) Subject: Excel Manipulation using Python References: Message-ID: On Apr 18, 11:36?am, Tim Golden wrote: > Krishna wrote: > > I was trying to delete rows in an existing .xls file using python. How > > do I do that? I was using the following code, it seem to work if I > > type in python window, but if I save it in text editor and drage and > > drop the .py file, it doesnt work. What am I doing wrong here? ?Thanks > > for your help! > > > import win32com.client > > from time import sleep > > excel = win32com.client.Dispatch("Excel.Application") > > > def Extract(): > > ? ?excel.Visible = 0 > > ? ?workbook=excel.Workbooks.Open('C:\Trial.xls') > > > ? ?i=1 > > ? ?for n in range(1,10): > > ? ? ? ? ? ?excel.Rows(i).Select > > ? ? ? ? ? ?excel.Selection.Delete > > ? ? ? ? ? ?excel.Selection.Delete > > ? ? ? ? ? ?i=i+2 > > ? ? ? ? ? ?workbook.Save() > > ? ? ? ? ? ?print "saved" > > > ? ?excel.Quit() > > Several points worthy of note: > > 1) When you're dealing with Windows filenames, either make > the strings raw -- Open (r"c:\trial.txt") -- or use the other > slashes =-- Open ("c:/trial.xls"). > > 2) You're not actually calling the Select and Delete > methods, merely referencing them. Try .Delete () etc. > > 3) You're saving the workbook every time round the loop, > but perhaps you knew that. Might prompt you everytime > as you're overwriting, but again, maybe you knew... > > TJG- Hide quoted text - > > - Show quoted text - Cool, That worked! Thanks for your help TJG! From george.sakkis at gmail.com Wed Apr 23 19:22:05 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 23 Apr 2008 16:22:05 -0700 (PDT) Subject: Parsing tuple from string? References: Message-ID: On Apr 23, 6:24?pm, Daniel wrote: > I have a list of strings, which I need to convert into tuples. ?If the > string is not in python tuple format (i.e. "('one', 'two')", "("one", > 'two')", etc.), then I can just make it a 1-tuple (i.e. return > (string,) ). ?If it is in python tuple format, I need to parse it and > return the appropriate tuple (it's ok to keep all tuple elements as > strings). > > I think eval() will work for this, but I don't know what will be in > the string, so I don't feel comfortable using that. Check out one of the safe restricted eval recipes, e.g. http://preview.tinyurl.com/6h7ous. HTH, George From ni at hao.com Sat Apr 26 14:38:32 2008 From: ni at hao.com (SL) Date: Sat, 26 Apr 2008 20:38:32 +0200 Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) In-Reply-To: References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> Message-ID: <925ee$481376ab$541fc2ec$11281@cache3.tilbu1.nb.home.nl> "SL" schreef in bericht news:bec2d$481372ed$541fc2ec$6742 at cache3.tilbu1.nb.home.nl... > > "n00m" schreef in bericht > news:6a3f8226-04c6-4ee3-b5a6-f76aca44aa31 at a23g2000hsc.googlegroups.com... >> using namespace std; >> char vs[1002000][99]; >> if (!fgets(vs[i],999,fp)) break; BTW why are you declaring the array as 99 and pass 999 to fgets to read a line? From bbxx789_05ss at yahoo.com Fri Apr 4 00:10:00 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Thu, 3 Apr 2008 21:10:00 -0700 (PDT) Subject: Parsing HTML? References: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> Message-ID: <29bcc6bc-ab2e-4ba6-a7b3-aa1f1e850ea1@y21g2000hsf.googlegroups.com> On Apr 3, 12:39?am, ben... at gmail.com wrote: > BeautifulSoup does what I need it to. ?Though, I was hoping to find > something that would let me work with the DOM the way JavaScript can > work with web browsers' implementations of the DOM. ?Specifically, I'd > like to be able to access the innerHTML element of a DOM element. > Python's built-in HTMLParser is SAX-based, so I don't want to use > that, and the minidom doesn't appear to implement this part of the > DOM. > innerHTML has never been part of the DOM. It is however a defacto browser standard. That's probably why you aren't having any luck using a python module that implements the DOM. From roger.dahlstrom at gmail.com Sat Apr 12 20:11:51 2008 From: roger.dahlstrom at gmail.com (rdahlstrom) Date: Sat, 12 Apr 2008 17:11:51 -0700 (PDT) Subject: Windows - window status (Running vs Not Responding) References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> Message-ID: <108495a2-789b-47b6-94bb-eda616b65254@c65g2000hsa.googlegroups.com> On Apr 11, 11:18 pm, Ross Ridge wrote: > rdahlstrom wrote: > >Basically, I'm looking for something similar to the Process.Responding > >property in System.Diagnostics... > > You probably want to use IsHungAppWindow(): > > IsHungAppWindow Function > > You call the IsHungAppWindow function to determine if > Microsoft Windows considers that a specified application is not > responding. An application is considered to be not responding > if it is not waiting for input, is not in startup processing, > and has not called PeekMessage within the internal timeout period > of 5 seconds. > > Syntax > > BOOL IsHungAppWindow( > HWND hWnd > ); > > ... > > You can use EnumWindows() to enumerate the all the top level windows. > > Ross Ridge > > -- > l/ // Ross Ridge -- The Great HTMU > [oo][oo] rri... at csclub.uwaterloo.ca > -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ > db // Holy crap, so simple, yet so awesome. Thanks! From landerdebraznpc at gmail.com Mon Apr 28 03:52:45 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:52:45 -0700 (PDT) Subject: keygen nfs pro street Message-ID: keygen nfs pro street http://crack.cracksofts.com From ed.leafe at rackspace.com Thu Apr 3 11:06:11 2008 From: ed.leafe at rackspace.com (Ed Leafe) Date: Thu, 3 Apr 2008 10:06:11 -0500 Subject: Looking for Agile Python Consulting Message-ID: This isn't a specific job request, which is why I'm not placing it on the Python Job Board. Rather, I'm in the process of gathering information for an upcoming project, and I need to determine what resources, if any, are available in the Python community. We're in the planning stages of a fairly long-term project (1-2 years), and the management here has been very impressed by the work of a consulting group used on another project in the company. They use Agile programming techniques, and have a lot of experience managing these sorts of projects. Unlike other projects with consultants, theirs have been very successful, and thus management is leaning towards using them for this one. The problem, though, is that these consultants are a Rails shop, and it would mean changing a large part of our coding efforts to Ruby. My very strong preference is to stay with Python, so I'm trying to locate Python-centric consultants who use a similar disciplined Agile approach so that I can propose an alternative to the Rails solution. I'm not terribly concerned with Django vs. TurboGears vs. any other framework; at this point I'm only concerned with Python vs. Ruby. If you are part of such a consulting group, or know of one that fits these requirements, please reply to me off-list. -- Ed Leafe Confidentiality Notice: This e-mail message (including any attached or embedded documents) is intended for the exclusive and confidential use of the individual or entity to which this message is addressed, and unless otherwise expressly indicated, is confidential and privileged information of Rackspace. Any dissemination, distribution or copying of the enclosed material is prohibited. If you receive this transmission in error, please notify us immediately by e-mail at abuse at rackspace.com, and delete the original message. Your cooperation is appreciated. From tjreedy at udel.edu Sat Apr 5 12:26:51 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 5 Apr 2008 12:26:51 -0400 Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com><20080405141329.GD15684@nullcube.com> Message-ID: "Steve Holden" wrote in message news:ft84g9$ola$1 at ger.gmane.org... | Aldo Cortesi wrote: | > Thus spake Kay Schluehr (kay.schluehr at gmx.net): **tweet**
b) Define a function to extract a "key" from your items such that items compare the same as their keys. For example, key(x) -> x.lower() may be used to compare text case-insensitively. Then, use a tuple (key, value) instead of the bare value. When extracting items from the queue, remember to unpack both parts. This is known as the decorate-sort-undecorate pattern; google for it. This is the approach used on your code snippet. def keyfunc(x): return x.lower() x1 = "bcd" x2 = "abC" x3 = "Z" x4 = "AbC" queue = [] insort(queue, (keyfunc(x1),x1)) print queue insort(queue, (keyfunc(x2),x2)) print queue insort(queue, (keyfunc(x3),x3)) print queue insort(queue, (keyfunc(x4),x4)) print queue print [value for (key,value) in queue] -- Gabriel Genellina From shane.lillie at gmail.com Wed Apr 9 11:30:32 2008 From: shane.lillie at gmail.com (Shane Lillie) Date: Wed, 9 Apr 2008 09:30:32 -0600 Subject: Trouble with list comprehension Message-ID: <4c3db5c00804090830p1b05748drf4ee5b8c3185ad9e@mail.gmail.com> I've got a bit of code that looks like this: for i in xrange(1000): # shuffle the doors doors = [ 'G', 'C', 'G' ] random.shuffle(doors) # save the doors that have goats (by index) goats = [ x for x in range(2) if doors[x] == 'G' ] but for some reason the list comprehension is not always returning a list with 2 elements in it (sometimes it will be just 1 element). I've tried changing to a generator as well as using filter() and all 3 give the same sort of results. It works if I use a loop, but I'd really like to know what I'm doing wrong here. Everything looks like it should be working. Thanks in advance for any suggestions. From steve at holdenweb.com Wed Apr 23 13:10:44 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 13:10:44 -0400 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. In-Reply-To: <480f6553$0$34545$742ec2ed@news.sonic.net> References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> Message-ID: John Nagle wrote: > Mike Driscoll wrote: >> Ken, >> >> On Tue, Apr 22, 2008 at 1:36 PM, Kenneth McDonald >> wrote: >>> Sadly. >>> >>> Thanks, >>> Ken >>> -- >>> http://mail.python.org/mailman/listinfo/python-list >>> >> >> I've attached the 2.4 version. I also have some Windows binaries for >> Beautiful Soup uploaded to my website: >> http://www.pythonlibrary.org/python_modules.htm > > What on earth do you need a "Windows binary" for? "BeautifulSoup" > is ONE PYTHON SOURCE FILE, "BeautifulSoup.py". It can be downloaded > here: > > http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup.py > > And yes, the site is up. > Windows installers for pure Python modules may seem daft to you, but you are familiar with the Python interpreter's filestore layout. Naive Windows users, however, would be much happier to run an installer. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From hniksic at xemacs.org Fri Apr 25 17:12:46 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Fri, 25 Apr 2008 23:12:46 +0200 Subject: Setting an attribute without calling __setattr__() References: Message-ID: <87bq3xej01.fsf@mulj.homelinux.net> Joshua Kugler writes: > self.me = [] > self.me = {} Use "object.__setattr__(self, 'me') = []" and likewise for {}. From kyosohma at gmail.com Fri Apr 25 17:28:40 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 25 Apr 2008 14:28:40 -0700 (PDT) Subject: display monochromatic images wxPython References: <43c2ef33-b08c-4161-b170-16ab346628d7@m36g2000hse.googlegroups.com> Message-ID: <74b32cb2-a03a-416e-894c-420a888d2f20@q24g2000prf.googlegroups.com> On Apr 25, 3:42?pm, "wongjoek... at yahoo.com" wrote: > Dear All, > I want to write a GUI program with wxPython displaying an image. But > the image I have is monochromatic. When I retrieve the data from the > image I end up with a list of integer. Starting from a list of integer > and knowing the width and height of the image, how do I display such > an image on a wx panel or frame ? I have had a look at the wxPython > demo but there I see only images where the data is a list of tuple > consisting of r,g ,b values. Is there are function where I directly > can input the list of array and let it display the image ? > Thanks in advance > > RR You should be able to create a wx.StaticBitmap object and then set the photo on it. Something like this: # create a blank image holder img = wx.EmptyImage(240,240) self.myImageObj = wx.StaticBitmap(self, wx.ID_ANY, wx.BitmapFromImage(img)) self.myImageObj.SetBitmap(wx.BitmapFromImage(img)) # refresh the widgets self.Refresh() # where "self" is a wx.Frame If that doesn't make sense or doesn't work in your case, please re- post the question to the wxPython's User group: http://wxpython.org/maillist.php Mike From google at mrabarnett.plus.com Wed Apr 2 15:11:12 2008 From: google at mrabarnett.plus.com (MRAB) Date: Wed, 2 Apr 2008 12:11:12 -0700 (PDT) Subject: non-terminating regex match References: Message-ID: On Apr 2, 5:01 pm, Maurizio Vitale wrote: > Has to be something really stupid, but the following never finish > (running Python 2.5.1 (r251:54863, Jan 10 2008, 18:00:49) > [GCC 4.2.1 (SUSE Linux)] on linux2). > > The intention is to match C++ identifiers, with or without namespace > qualification, with or without arguments (e.g. variables, functions and > macros). > The following should be accepted: > main > main(int,char**) > ::main > std::cout > ::std::cout > NDEBUG > > Thanks for any help. > And yes, I'm a total beginner when it comes to Python, but it seems > very strange to me that a regex match on a finite length string > doesn't terminate > Regards, > > Maurizio > > #!/usr/bin/env python > # -*- Python -*- > > import re > > if __name__ == '__main__': > r = re.compile ( > r'(?:(?P(?:(?:::)?\w+)*)::)?' > r'(?P\w+)' > r'(?:\((?P[^\)]*)\))?' > ) > match = r.search ('WITH_ALOHA_EXCEPTION_HANDLERS') I think the problem is with this bit: '(?:(?:::)?\w+)*'. The '::' is optional and also in a repeated group, so if it tries to match, say, 'abc' it can try and then backtrack all of these possibilities: abc, ab c, a bc, a b c. The longer the string, the more possibilities to try. Try this instead: r = re.compile ( r'(?P(?:::)?(?:\w+::)*)?' r'(?P\w+)' r'(?:\((?P[^\)]*)\))?' ) From nospam at invalid.com Thu Apr 24 23:09:33 2008 From: nospam at invalid.com (Jack) Date: Fri, 25 Apr 2008 03:09:33 GMT Subject: ctypes: return a pointer to a struct Message-ID: I'm not able to build IP2Location's Python interface so I'm trying to use ctypes to call its C interface. The functions return a pointer to the struct below. I haven't been able to figure out how I should declare the return type of the functions and read the fields. Any hint is appreciated. typedef struct { char *country_short; char *country_long; char *region; char *city; char *isp; float latitude; float longitude; char *domain; char *zipcode; char *timezone; char *netspeed; } IP2LocationRecord; From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 2 07:38:40 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 02 Apr 2008 13:38:40 +0200 Subject: object-relational mappers In-Reply-To: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> Message-ID: <47f37039$0$31900$426a74cc@news.free.fr> Aaron Watters a ?crit : > I've been poking around the world of object-relational > mappers and it inspired me to coin a corellary to the > the famous quote on regular expressions: > > "You have objects and a database: that's 2 problems. > So: get an object-relational mapper: > now you have 2**3 problems." > > That is to say I feel that they all make me learn > so much about the internals and features of the > O-R mapper itself that I would be better off rolling > my own queries on an as-needed basis without > wasting so many brain cells. > > comments? If you're ok with building your queries as raw string and handling your resultsets as lists of tuples, then you're right, don't waste you brain cells learning anything else than SQL and the DB-API. Now my own experience is that whenever I tried this approach for anything non-trivial, I ended up building an "ad-hoc, informally-specified bug-ridden slow implementation of half of " SQLAlchemy. Which BTW is not strictly an ORM, but primarily an attempt at a better integration of SQL into Python. So while it may feel like learning the inner complexities of SQLALchemy (or Django's ORM which is not that bad either) is "wasting brain cells", MVHO is that it's worth the time spent. But YMMV of course - IOW, do what works best for you. From __peter__ at web.de Fri Apr 25 03:21:53 2008 From: __peter__ at web.de (Peter Otten) Date: Fri, 25 Apr 2008 09:21:53 +0200 Subject: Little novice program written in Python References: Message-ID: Rog?rio Brito wrote: > i = 2 > while i <= n: > ? ? ?if a[i] != 0: > ????????print a[i] > ? ? ?i += 1 You can spell this as a for-loop: for p in a: if p: print p It isn't exactly equivalent, but gives the same output as we know that a[0] and a[1] are also 0. Peter From fetchinson at googlemail.com Mon Apr 14 21:11:44 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Mon, 14 Apr 2008 18:11:44 -0700 Subject: Interesting timing issue I noticed In-Reply-To: References: Message-ID: > The project I'm working on is motion detection, involving a bit of image > processing. No worries: no image processing background needed. > > Suffice to say that I initially wrote a script that goes through every pixel > of a 320x240 picture (turned into an array using PIL) and performs some > calculatiosn. It simply goes through every pixel in the array and performs a > simple subtraction with a known value. The idea is to try to find > differences between the two images. > > After a while, to try to speed up the calculations, I realized that I didn't > need to do all 320x240 calculations. So I implemented a slightly more > sophisticated algorithm and localized my calculations. I still do the pixel > subtractions, but I do it on a smaller scale. > > Surprisingly, when I used time.time() to time the procedures, I find that > doing all 320x240 calculations are often faster! On my machine, the former > gives me on average an execution time of around 0.125s (and consistently), > whereas the latter on average takes 0.160s. > > Why does this happen? It's hard to tell without looking at a stripped down, minimal version of your code that still shows the above behaviour. Most probably you are not computationally bound and the majority of the execution time is spent on memory read/write. For example it might happen that the version of your code that has less number of FLOPS accesses the memory more often. HTH, Daniel From kyosohma at gmail.com Wed Apr 16 09:24:18 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 16 Apr 2008 06:24:18 -0700 (PDT) Subject: Learning Tkinter References: Message-ID: <4f5750ef-987e-451e-93da-3e315190c0b2@8g2000hse.googlegroups.com> On Apr 16, 7:46 am, "Doran, Harold" wrote: > I am currently reading An Intro to Tkinter (1999) by F. Lundh. This doc > was published in 1999 and I wonder if there is a more recent version. > I've googled a bit and this version is the one I keep finding. I like > how this document is organized and also how it provides the code with > visuals of what should appear on the screen. If there are other docs I > should read, please let me know. There's some good Tkinter coverage in Lutz's tome, "Programming Python 3rd Ed." and it also shows how to do a search for a file across your file system, iirc. > > Second, I am trying to work through a couple of the examples and make > some small tweaks as I go to see how new things can work. In the first > case, I have copied the code in the book to see how the menu works and > are created as in the example menu.py below. I see how menus are created > and how the command option is used to call the function callback. > > # menu.py > from Tkinter import * > > def callback(): > print "called the callback!" > > root = Tk() > > # create a menu > menu = Menu(root) > root.config(menu=menu) > > filemenu = Menu(menu) > menu.add_cascade(label="File", menu=filemenu) > filemenu.add_command(label="New", command=harold) > filemenu.add_command(label="Open...", command=callback) > filemenu.add_separator() > filemenu.add_command(label="Exit", command=callback) > > helpmenu = Menu(menu) > menu.add_cascade(label="Help", menu=helpmenu) > helpmenu.add_command(label="About...", command=callback) > > mainloop() > > However, I now want to incorporate a basic python program with a > command. Say I have a simple program called test.py > > # test.py > filename = raw_input("Please enter the file you want to open: ") > new_file = raw_input("Save the output file as: ") > > f = open(new_file, 'w') > new = open(filename, 'r') > > for line in new: > x = line.split('\t') > print >> f, x[0],':', x[1] > f.close() > > To make this example complete assume I have a text file like this > > # data.txt > 1 one > 2 two > 3 three > 4 four > > So, the user currently just follows directions on the screen, enters the > file names, and I get what I want. I'd like to try experimenting with > gui programming to see if the python programs I have written can be made > even more user friendly. I currently use py2exe to create executables so > that others in my organization can use these programs. > > In that spirit, say I want to have a menu option that allows the user to > search their computer for this file, execute the python code and then > save the result as a user-defined filename. So, I guess my questions are > how do I associate the portion of code in menu.py > "filemenu.add_command(label="Open...", command=callback)" with an > operation that gives the user the ability to search the drives on their > machine and then once they do let python execute the code in test.py? > > Many thanks, It sounds like you want to run code from within your own program. This would require embedding a Python interpreter, which is quite possible, although I do not know how to do it. I would suggest that you just use a Tkinter-created frame/window that allows the user to enter the information into text controls rather than a command line type interface. You could even use a "Browse" button and let the user search for the file using a file dialog. Check out the sample code for such a beast in the recipe linked below: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/438123 If you do want to go the embedding route, you'll want to read the following information linked below: http://docs.python.org/api/embedding.html http://www.python.org/doc/ext/embedding.html http://www.ragestorm.net/tutorial?id=21 http://www.codeproject.com/KB/cpp/embedpython_1.aspx Hope that gets you going. Mike From paul.anton.letnes at gmail.com Mon Apr 14 08:46:27 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Mon, 14 Apr 2008 14:46:27 +0200 Subject: Process multiple files In-Reply-To: <2323A6D37908A847A7C32F1E3662C80E017BDF37@dc1ex01.air.org> References: <2323A6D37908A847A7C32F1E3662C80E017BDF37@dc1ex01.air.org> Message-ID: Funny, I'm just doing exactly this: import os def main(): dataFolder = 'data/' fileList = os.listdir(dataFolder) for file in fileList: inFile = open(dataFolder + file, 'r') print 'read inFile & do something useful here' Clear as an... egg? Cheers. Paul. Den 14. april. 2008 kl. 14.36 skrev Doran, Harold: > Say I have multiple text files in a single directory, for illustration > they are called "spam.txt" and "eggs.txt". All of these text files are > organized in exactly the same way. I have written a program that > parses > each file one at a time. In other words, I need to run my program each > time I want to process one of these files. > > However, because I have hundreds of these files I would like to be > able > to process them all in one fell swoop. The current program is > something > like this: > > sample.py > new_file = open('filename.txt', 'w') > params = open('eggs.txt', 'r') > do all the python stuff here > new_file.close() > > If these files followed a naming convention such as 1.txt and 2.txt I > can easily see how these could be parsed consecutively in a loop. > However, they are not and so is it possible to modify this code such > that I can tell python to parse all .txt files in a certain directory > and then to save them as separate files? For instance, using the > example > above, python would parse both spam.txt and eggs.txt and then save 2 > different files, say as spam_parsed.txt and eggs_parsed.txt. > > Thanks > > > > > > > -- > http://mail.python.org/mailman/listinfo/python-list From nagle at animats.com Fri Apr 18 15:26:13 2008 From: nagle at animats.com (John Nagle) Date: Fri, 18 Apr 2008 12:26:13 -0700 Subject: Python 2.5 adoption In-Reply-To: References: Message-ID: <4808f30e$0$34489$742ec2ed@news.sonic.net> Joseph Turian wrote: > How widely adopted is python 2.5? > > We are doing some development, and have a choice to make: > a) Use all the 2.5 features we want. > b) Maintain backwards compatability with 2.4. > > So I guess the question is, does anyone have a sense of what percent > of python users don't have 2.5? Desktop or server? If server, check what the major Linux distros, like Fedora Core, are shipping with. Check major shared hosting providers to see what they're offering to their customers as standard. John Nagle From tinnews at isbd.co.uk Thu Apr 3 08:15:13 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 03 Apr 2008 12:15:13 GMT Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> Message-ID: <47f4ca51$0$713$bed64819@news.gradwell.net> Jeff wrote: > def foo(sample, strings): > for s in strings: > if sample in s: > return True > return False > > This was an order of magnitude faster for me than using str.find or > str.index. That was finding rare words in the entire word-list (w/ > duplicates) of War and Peace. However it's the wrong way around, in my case 'sample' is the longer string and I want to know if s is in it. It's simple enough to do it the other way around though:- def foo(sample, strings): for s in strings: if s in sample: return True return False Using in rather than find() and making it a function would seem to be the way to go, thanks. -- Chris Green From kay.schluehr at gmx.net Sat Apr 19 10:51:48 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 19 Apr 2008 07:51:48 -0700 (PDT) Subject: Metaprogramming Example References: <930643c6-2d56-4fb0-aee0-a3e79231f09b@24g2000hsh.googlegroups.com> <32472b97-f35a-4408-96f5-2f8c8f92ae56@m73g2000hsh.googlegroups.com> Message-ID: On 17 Apr., 14:25, andrew cooke wrote: > PS Is there anywhere that explains why Decorators (in the context of > functions/methods) are so good? We had kind of an inverse discussion a while ago when someone asked about the fate of aspect oriented programming (AOP) in Python. My answer was that technically "aspect weaving" using code generators is dead in application programming [1] and decorators are handy, lightweight, local and controllable while serving very similar purposes. [1] There are occasions where source code weaving might still has its place. Profiling for example or code coverage. Just examine this interesting blog article: http://nedbatchelder.com/blog/200804/wicked_hack_python_bytecode_tracing.html and the subsequent discussion. From bob at passcal.nmt.edu Sat Apr 19 17:53:01 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Sat, 19 Apr 2008 15:53:01 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041816413450073-bob@passcalnmtedu> <2008041915500575249-bob@passcalnmtedu> Message-ID: <2008041915530150073-bob@passcalnmtedu> > > > www.greschke.com/unlinked/files/pocus.png > > > Darnit. www.greschke.com/unlinked/images/pocus.png From gagsl-py2 at yahoo.com.ar Thu Apr 24 02:05:01 2008 From: gagsl-py2 at yahoo.com.ar (gagsl-py2 at yahoo.com.ar) Date: Thu, 24 Apr 2008 03:05:01 -0300 (ART) Subject: What happened with python? messed strings? In-Reply-To: <200804202006.m3KK64ix028653@sdf-eu.org> Message-ID: <114452.7491.qm@web32808.mail.mud.yahoo.com> (top posting fixed; please keep discussion on this list) --- algaba at droog.sdf-eu.org escribi?: > In article > > you wrote: > > En Sun, 20 Apr 2008 15:54:20 -0300, > escribi?: > > > > I used extensively python and now I find this > mess with strings, > > > I can't even reproduce tutorial examples: > > >>>> "apfel".encode('utf-8') (it was with umlaut) > > > File "", line 0 > > > ^ > > > SyntaxError: 'ascii' codec can't decode byte > 0xc4 in position 1: > > > ordinal not in range(128) > > >>>> > > > Is there any good guide to this mess of codecs > and hell ? [two links to unicode introductory articles] > ok, > and how do you explain that even the tutorial > example is broken ??? Which tutorial example? -- Gabriel Genellina Los referentes m?s importantes en compra/ venta de autos se juntaron: Demotores y Yahoo! Ahora comprar o vender tu auto es m?s f?cil. Vist? ar.autos.yahoo.com/ From bronger at physik.rwth-aachen.de Wed Apr 30 07:12:05 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 30 Apr 2008 13:12:05 +0200 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> Message-ID: <87tzhjy4u2.fsf@physik.rwth-aachen.de> Hall?chen! Duncan Booth writes: > Torsten Bronger wrote: > >> The biggest ugliness though is ",".join(). No idea why this should >> be better than join(list, separator=" "). Besides, ",".join(u"x") >> yields an unicode object. This is confusing (but will probably go >> away with Python 3). > > It is only ugly because you aren't used to seeing method calls on > string literals. I am used to it. Programming very much with unicode, I use .encode and .decode very often and I like them. I consider en/decoding to be an intrinsic feature of strings, but not ord(), which is an "external", rather administrative operation on strings (and actually not even this, but on characters) for my taste. However, join() is really bizarre. The list rather than the separator should be the leading actor. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From andrew at acooke.org Mon Apr 14 21:43:39 2008 From: andrew at acooke.org (andrew cooke) Date: Mon, 14 Apr 2008 18:43:39 -0700 (PDT) Subject: Dynamic use of property() fails Message-ID: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> Hi, This is my first attempt at new classes and dynamic python, so I am probably doing something very stupid... After reading the how-to for descriptors at http://users.rcn.com/python/download/Descriptor.htm I decided I would make an object that returns attributes on read, but on setting calls an arbitrary function. My code looks like: class ActiveDAO(object): def __init__(self): self.__values__ = {} def add_field(self, name, value, on_change): self.__values__[name] = value def get(self): return self.__values__[name] def set(self, new_value): self.__values__[name] = on_change(new_value) def delete(self): raise AttributeError self.__dict__[name] = property(get, set, delete) However, when I try to use this (in a test) with code like: dao = ActiveDAO() dao.add_field("name", "value", lambda _: None) assertEqual(dao.name, "value") I get a failure because lookup of the attribute is returning "". That is quite reasonable, but I was under the expression that some magic was supposed to happen, as described in the document referenced above! Please can someone explain why there is no magic? :o( Thanks, Andrew PS I am using Python 2.5 on Linux From sales024 at aaa-replica-watch.com Tue Apr 1 00:45:10 2008 From: sales024 at aaa-replica-watch.com (sales024 at aaa-replica-watch.com) Date: Mon, 31 Mar 2008 21:45:10 -0700 (PDT) Subject: Cheap Seiko Dress Watches Replica - Seiko Watches Wholesale Message-ID: <807f68e4-f420-49f8-a10d-5f3ca904ad38@c26g2000prf.googlegroups.com> Cheap Seiko Dress Watches Replica - Seiko Watches Wholesale AAA Replica Watches : http://www.watches-replicas.com Seiko Watches Brands : http://www.watches-replicas.com/seiko-watches.html Replica Seiko Dress Watches : http://www.watches-replicas.com/seiko-dress-watches.html China largest replica watches wholesaler, wholesale up to 80% of Seiko Dress Replica Watches and Seiko Dress Fake Watch. The most famous Swiss brand name watches you can find, replica Seiko Dress Watches and fake Seiko Dress Watches are also available. All our Seiko Dress Watches replicas are crafted in high quality, You will get great profite by ordering our good cheap watches. Seiko Dress Watches All Products : Seiko Dress Mens Watch SGF526 : http://www.watches-replicas.com/Seiko-Dress-Mens-Watch-SGF526-6222.html Seiko Dress Mother-of-Pearl Two-Tone Steel Ladies Watch SUJB30 : http://www.watches-replicas.com/Seiko-SUJB30-6223.html Seiko Dress Mother-of-Pearl Two-Tone Steel Ladies Watch SUJB26 : http://www.watches-replicas.com/Seiko-SUJB26-6224.html Seiko Dress Pink Mother-of-Pearl Steel Ladies Watch SUJB29 : http://www.watches-replicas.com/Seiko-SUJB29-6225.html Seiko Dress Ladies Watch SUJE85 : http://www.watches-replicas.com/Seiko-Dress-Ladies-Watch-SUJE85-6226.html Seiko Dress Chronograph Titanium Mens Watch SND641 : http://www.watches-replicas.com/seiko-chrono-mens-watch-snd641-6227.html Seiko Dress Steel White Mens Watch SNF665 : http://www.watches-replicas.com/Seiko-Dress-Mens-Watch-SNF665-6228.html Seiko Dress Mens Watch SFLW86 : http://www.watches-replicas.com/Seiko-Dress-Mens-Watch-SFLW86-6229.html Seiko Dress Gold-Tone Stainless Steel Ladies Watch SUJD54 : http://www.watches-replicas.com/seiko-gold-tone-ladies-watch-SUJD54-6230.html Seiko Dress Two-Tone Stainless Steel Ladies Watch SXGM04 : http://www.watches-replicas.com/seiko-dress-two-tone-watch-SXGM04-6231.html Seiko Dress Two-Tone Stainless Steel Ladies Watch SWZ144 : http://www.watches-replicas.com/seiko-dress-two-tone-steel-watch-SWZ144-6232.html Seiko Dress Two-Tone Stainless Steel Mens Watch SGFA05 : http://www.watches-replicas.com/seiko-dress-two-tone-mens-watch-SGFA05-6233.html Seiko Dress Stainless Steel Mens Watch SKP323 : http://www.watches-replicas.com/seiko-dress-stainless-steel-watch-SKP323-6234.html Seiko Dress Stainless Steel Mens Watch SGFA09 : http://www.watches-replicas.com/seiko-dress-stainless-steel-watch-SGFA09-6235.html Seiko Dress Gold-Tone Stainless Steel Mens Watch SKP330 : http://www.watches-replicas.com/seiko-dress-gold-tone-stainless-SKP330-6236.html Seiko Dress Gold-Tone Stainless Steel Mens Watch SKP294 : http://www.watches-replicas.com/seiko-dress-gold-tone-mens-watch-SKP294-6237.html Seiko Day/Date Dress Gold Tone Ladies Watch SWZ058 : http://www.watches-replicas.com/seiko-ladies-watch-swz058-6238.html Seiko Day/Date Dress Ladies Watch SWZ054 : http://www.watches-replicas.com/seiko-ladies-watch-swz054-6239.html Seiko Dress Gold-Tone Ladies Watch SWZ154 : http://www.watches-replicas.com/seiko-leather-ladies-watch-swz156-6240.html Seiko Dress Two-Tone Stainless Steel Mens Watch SKP017 : http://www.watches-replicas.com/seiko-mens-watch-skp017-6241.html Seiko Day/Date Dress Gold-Tone Stainless Steel Mens Watch SGF212 : http://www.watches-replicas.com/seiko-mens-watch-sgf212-6242.html Seiko Day/Date Dress Gold-Tone Stainless Steel Mens Watch SGF206 : http://www.watches-replicas.com/seiko-mens-watch-sgf206-6243.html Seiko Day/Date Dress Two-Tone Stainless Steel Mens Watch SGF204 : http://www.watches-replicas.com/seiko-mens-watch-sgf204-6244.html Seiko Dress Chronograph Titanium Mens Watch SND641 : http://www.watches-replicas.com/seiko-chrono-mens-watch-snd671-6245.html Seiko Gold Tone Stainless Steel Ladies Dress Watch SUJ706 : http://www.watches-replicas.com/seiko-gold-tone-stainless-ladies-suj706-6246.html Seiko Gold Tone Stainless Steel Day/Date Men's Watch SGFA10 : http://www.watches-replicas.com/seiko-day-and-date-mens-watch-sgfa10-6247.html Seiko Two-tone Steel Ladies Watch SUJE89 : http://www.watches-replicas.com/seiko-ladies-watch-two-tone-suje89-6248.html Seiko Steel Pink Ladies Watch SUJE87 : http://www.watches-replicas.com/seiko-ladies-watch-suje87-6249.html Seiko Gold Tone Ladies Watch SXE372 : http://www.watches-replicas.com/Seiko-SXE372-6250.html Seiko Dress Gold-Tone Steel Ladies Watch SUJB32 : http://www.watches-replicas.com/seiko-watch-SUJB32-6251.html Seiko Dress Gold-Tone Steel White Ladies Watch SXJZ44 : http://www.watches-replicas.com/seiko-watch-SXJZ44-6252.html Seiko Dress Two-Tone Steel Blue Ladies Watch SUJ511 : http://www.watches-replicas.com/seiko-watch-SUJ511-6253.html Seiko Dress Steel Blue Leather Ladies Watch SNA467 : http://www.watches-replicas.com/seiko-watch-SNA467-6254.html Seiko Dress Two-Tone Steel White Ladies Watch SXJS67 : http://www.watches-replicas.com/seiko-watch-SXJS67-6255.html Seiko Dress Two-Tone Steel Blue Mens Watch SNA284 : http://www.watches-replicas.com/seiko-watch-SNA284-6256.html Seiko Dress Mother-of-Pearl Two-Tone Steel Ladies Watch SUJ710 : http://www.watches-replicas.com/seiko-watch-SUJ710-6257.html Seiko Dress Two-Tone Steel White Ladies Watch SXJZ48 : http://www.watches-replicas.com/seiko-watch-SXJZ48-6258.html Seiko Dress TiCN-Plated Steel Blue Mens Watch SGEA03 : http://www.watches-replicas.com/seiko-watch-SGEA03-6259.html Seiko Dress Mother-of-Pearl Gold-Tone Steel Ladies Watch SUJ712 : http://www.watches-replicas.com/seiko-watch-SUJ712-6260.html Seiko Diamond Gold-Tone Steel Champagne Ladies Watch SUJE72 : http://www.watches-replicas.com/seiko-watch-SUJE72-6261.html Seiko Diamond Two-Tone Steel Black Ladies Watch SUJE71 : http://www.watches-replicas.com/seiko-watch-SUJE71-6262.html Seiko Diamond Pink Mother-of-Pearl Steel Ladies Watch SUJE67 : http://www.watches-replicas.com/seiko-watch-SUJE67-6263.html Seiko Diamond Mother-of-Pearl Two-Tone Steel Ladies Watch SUJE69 : http://www.watches-replicas.com/seiko-watch-SUJE69-6264.html Seiko Diamond Gold-Tone Steel Black Ladies Watch SUJE70 : http://www.watches-replicas.com/seiko-watch-SUJE70-6265.html Seiko Dress Two-Tone Steel Black Mens Watch SKP308 : http://www.watches-replicas.com/Seiko-Two-Tone-Steel-Mens-Watch-SKP308-6266.html Seiko Dress Two-Tone Grey Steel Ladies Watch SUJE76 : http://www.watches-replicas.com/Seiko-Two-Tone-Black-Mens-Watch-SUJE76-6267.html Seiko Dress Two-Tone Steel Black Ladies Watch SUJE74 : http://www.watches-replicas.com/Seiko-Two-Tone-Steel-Ladies-Watch-SUJE74-6268.html Seiko Dress Two-Tone Dark Grey Steel Black Mens Watch SKP310 : http://www.watches-replicas.com/Seiko-Two-Tone-Steel-Mens-Watch-SKP310-6269.html Seiko Dress Gold-Tone Steel Bronze Satin Ladies Watch SUJD80 : http://www.watches-replicas.com/Seiko-Dress-Womens-Watch-SUJD80-6270.html Seiko Dress Gold-Tone Steel Bronze Satin Ladies Watch SXH056 : http://www.watches-replicas.com/Seiko-Dress-Womens-Watch-SXH056-6271.html Seiko Dress Steel Blue Mens Watch SNF661 : http://www.watches-replicas.com/Seiko-Dress-Mens-Watch-SNF661-6272.html Seiko Dress Steel Black Strap Ladies Watch SUJD79 : http://www.watches-replicas.com/Seiko-Dress-Womens-Watch-SUJD79-6273.html Seiko Dress Gold-Tone Steel Burgundy Leather Ladies Watch SXD788 : http://www.watches-replicas.com/Seiko-Dress-Womens-Watch-SXD788-6274.html Seiko Dress Steel Burgundy Leather Mens Watch SPA003 : http://www.watches-replicas.com/Seiko-Dress-Date-men-Watch-SPA003-6275.html Seiko Dress Steel Black Leather Mens Watch SPA001 : http://www.watches-replicas.com/Seiko-Dress-Date-Mens-Watch-SPA001-6276.html Seiko Dress Gold-Tone Steel Brown Leather Mens Watch SPA004 : http://www.watches-replicas.com/Seiko-Dress-Date-Mens-Watch-SPA004-6277.html Seiko Dress Gold-Tone Steel White Ladies Watch SXB388 : http://www.watches-replicas.com/Seiko-Dress-Womens-Watch-SXB388-6278.html Seiko Dress Steel Black Ladies Watch SXH055 : http://www.watches-replicas.com/Seiko-Dress-Womens-Watch-SXH055-6279.html Seiko Skinny White Leather Double Buckle Ladies Watch SXH049 : http://www.watches-replicas.com/Seiko-womens-watch-SXH049-6280.html Seiko Dress Gold-Tone Steel Brown Leather Mens Watch SKP304 : http://www.watches-replicas.com/Seiko-Dress-Mens-Watch-SKP304-6281.html Seiko Dress Steel Black Mens Watch SKK629 : http://www.watches-replicas.com/Seiko-Dress-Mens-Watch-SKK629-6282.html Seiko Dress Steel White Dial Ladies Watch SFQ841 : http://www.watches-replicas.com/Seiko-Dress-Womens-Watch-SFQ841-6283.html Seiko Dress Gold-tone Steel Ladies Watch SUJD92 : http://www.watches-replicas.com/Seiko-womens-watch-SUJD92-6284.html Seiko Dress Gold-tone Steel Ladies Watch SUJD84 : http://www.watches-replicas.com/Seiko-womens-watch-SUJD84-6285.html Seiko Dress Gold-Tone Steel Brown Leather Mens Watch SNT006 : http://www.watches-replicas.com/Seiko-Mens-Watch-SNT006-6286.html Seiko Titanium Two Tone Dress Ladies Watch SUJA80 : http://www.watches-replicas.com/seiko-titanium-two-tone-ladies-SUJA80-6287.html Seiko Gold Tone Stainless Steel Men's Watch SGEC70 : http://www.watches-replicas.com/seiko-gold-tone-stainless-steel-SGEC70-6288.html Seiko Gold Tone Casual Ladies Watch SXGM06 : http://www.watches-replicas.com/seiko-gold-tone-casual-ladies-SXGM06-6289.html Seiko Dress Ladies Watch SUJ703 : http://www.watches-replicas.com/seiko-dress-ladies-watch-SUJ703-6290.html Seiko Alarm Chronograph Men's Watch SNA551 : http://www.watches-replicas.com/seiko-alarm-chronograph-men-watch-SNA551-6291.html Seiko Dress Steel Black Mens Watch SNF667 : http://www.watches-replicas.com/Seiko-Dress-Mens-Watch-SNF667-6292.html Seiko Dress Gold-Tone Steel Champagne Dial Mens Watch SNF664 : http://www.watches-replicas.com/Seiko-Dress-men-Watch-SNA664-6293.html Seiko Dress Two-Tone Steel White Mens Watch SNA662 : http://www.watches-replicas.com/Seiko-Dress-men-Watch-SNA662-6294.html Seiko Dress Steel White Mens Watch SNA659 : http://www.watches-replicas.com/Seiko-Dress-Mens-Watch-SNA659-6295.html Seiko Casual Stainless Steel Mens Watch SGFA02 : http://www.watches-replicas.com/seiko-mens-watch-sgfa02-6296.html Seiko Gold-Tone Men's Watch SFWL86 : http://www.watches-replicas.com/seiko-mens-gold-watch-sfwl86-6297.html Seiko Gold Elegant Dress Seiko Ladies Watch SFQ838 : http://www.watches-replicas.com/Seiko-Dress-Watch-SFQ838-6298.html Seiko Dress Steel White Mens Watch SNF657 : http://www.watches-replicas.com/Seiko-SNF657-6299.html Seiko Dress Steel Black Mens Watch SKP297 : http://www.watches-replicas.com/Seiko-Classic-Dress-Watch-SKP297-6300.html Seiko Dress Steel Black Leather Mens Watch SKK633 : http://www.watches-replicas.com/Seiko-Classic-Dress-Watch-SKK633-6301.html Seiko Dress Steel White Mens Watch SKK627 : http://www.watches-replicas.com/Seiko-Classic-Dress-Watch-SKK627-6302.html Seiko Dress Steel White Mens Watch SKP295 : http://www.watches-replicas.com/Seiko-Classic-Dress-Watch-SKP295-6303.html Seiko Dress Two-Tone Steel White Dial Mens Watch SKP299 : http://www.watches-replicas.com/Seiko-Classic-Dress-Watch-SKP299-6304.html Seiko Dress Steel Black Mens Watch SGEC85 : http://www.watches-replicas.com/Seiko-Classic-Dress-Watch-SGEC85-6305.html Seiko Dress Steel Black Mens Watch SGEC95 : http://www.watches-replicas.com/Seiko-Classic-Dress-Watch-SGEC95-6306.html Seiko Dress Steel Blue Ladies Watch SYL793 : http://www.watches-replicas.com/Seiko-SYL793-6307.html Seiko Dress Two-Tone Steel Ladies Watch SUJB34 : http://www.watches-replicas.com/Seiko-SUJB34-6308.html Seiko Dress Two-Tone Steel Mens Watch SGG130 : http://www.watches-replicas.com/Seiko-SGG130-6309.html Seiko Dress Steel Pink Ladies Watch SUJE17 : http://www.watches-replicas.com/Seiko-SUJE17-6310.html Seiko Dress Steel Black Ladies Watch SUJD53 : http://www.watches-replicas.com/Seiko-SUJD53-6311.html Seiko Dress Steel Black Ladies Watch SUJD39 : http://www.watches-replicas.com/Seiko-SUJD39-6312.html Seiko Dress Two-Tone Steel Bangle White Ladies Watch SUJ704 : http://www.watches-replicas.com/Seiko-SUJ704-6313.html Seiko Dress Steel Mens Watch SKP293 : http://www.watches-replicas.com/Seiko-SKP293-6314.html The Same Seiko Replica Watches Series : Seiko Chronograph Watches : http://www.watches-replicas.com/seiko-chronograph-watches.html Seiko Dress Watches : http://www.watches-replicas.com/seiko-dress-watches.html Seiko Kinetic Watches : http://www.watches-replicas.com/seiko-kinetic-watches.html Seiko Coutura Watches : http://www.watches-replicas.com/seiko-coutura-watches.html Seiko Diamond Watches : http://www.watches-replicas.com/seiko-diamond-watches.html Seiko Le Grand Sport Watches : http://www.watches-replicas.com/seiko-le-grand-sport-watches.html Seiko Perpetual Calendar Watches : http://www.watches-replicas.com/seiko-perpetual-calendar-watches.html Seiko Sportura Watches : http://www.watches-replicas.com/seiko-sportura-watches.html Seiko Diver Watches : http://www.watches-replicas.com/seiko-diver-watches.html Seiko El Dorado Watches : http://www.watches-replicas.com/seiko-el-dorado-watches.html Seiko Retrograde Watches : http://www.watches-replicas.com/seiko-retrograde-watches.html Seiko Casual Watches : http://www.watches-replicas.com/seiko-casual-watches.html Hard to Find Seiko Watches : http://www.watches-replicas.com/hard-to-find-seiko-watches.html Seiko Clocks : http://www.watches-replicas.com/seiko-clocks.html From gagsl-py2 at yahoo.com.ar Wed Apr 16 02:02:04 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 03:02:04 -0300 Subject: import hooks References: <664bf2b80804151814g480eed02w739047f84d9deb6b@mail.gmail.com> Message-ID: En Tue, 15 Apr 2008 22:14:18 -0300, Patrick Stinson escribi?: > What's the current way to install an import hook? I've got an embedded > app > that has a few scripts that I want to import each other, but that are > not in > sys.modules. I intentionally keep them out of sys.modules because their > names will not be unique across the app. They will, however, be unique > between scripts that I (do* want to see each other). > Basically, I want to return a certain module from a name-based filter. > I've > already written a type in C with find_module and load_module, but it > doesn't > seem to work when I add the type to sys.path_hooks. I wrote a simple one > that worked just fine from a pure script file run through python.exe. From that description alone I can't say what's happening; you should post some code. Also, if your importer isn't disk-based, perhaps using sys.meta_path is better. -- Gabriel Genellina From sierra9162 at gmail.com Wed Apr 16 11:27:17 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:27:17 -0700 (PDT) Subject: kate hudson parents Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From bj_666 at gmx.net Sat Apr 5 03:18:12 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 5 Apr 2008 07:18:12 GMT Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> Message-ID: <65ondkF2g48puU2@mid.uni-berlin.de> On Fri, 04 Apr 2008 20:26:13 -0700, 7stud wrote: > However, there is another way to cause a function to execute when an > event, like a button click, occurs on a widget: you use the widget's > bind() function: > > my_button.bind('', someFunc) That's a bad idea because now the `Button` doesn't act like a typical button anymore. This "fires" *always* and as soon as you press the mouse button on it. Compare this with the usual and from end users point of view expected behavior that pressing down the mouse button "presses" the button widget visually but doesn't cause any action until you release the button while still over it. This for instance makes it possible to change your mind and move the mouse cursor out of the buttons area with a pressed mouse button and prevent the action of that button. The preferred way to bind actions to `Button`\s is the `command` argument. The function is called with no arguments when the button is pressed, so it has to know all data it needs to fulfill its task. Usually this is done with anonymous functions and bound default values for short pieces of "variable" data:: def __init__(self): # ... button = Button(self, text='1', command=lambda n=1: self.display(n)) # ... def display(self, number): print number Ciao, Marc 'BlackJack' Rintsch From james at reggieband.com Sun Apr 13 16:05:54 2008 From: james at reggieband.com (james at reggieband.com) Date: Sun, 13 Apr 2008 13:05:54 -0700 (PDT) Subject: Module to read input from commandline References: <2e04b64c-9a12-4e20-8d5a-546a0ec4ac7f@m36g2000hse.googlegroups.com> Message-ID: On Apr 13, 7:44 pm, thashoo... at farifluset.mailexpire.com wrote: > What you're looking for is no module, it is included in the standard > python namespace. > > raw_input > > Use it like this: > > value_a = raw_input("Please give a value for a: ") > # do your thing to value_a > > But this belongs to the real basics, I suggest you get some reading > done on python. > > GL Thanks for the response GL. What I am looking for is a module to wrap raw_input so it can handle some of the validation. e.g.) response = display_prompt( question, valid_responses, default_response ) or similar. valid_responses could be a tuple of regexp strings that would compare against a raw_input and return one in the list. Ideally I could customize the error message (for responses not in valid_response), etc. I know it isn't rocket science to write it and I have something already in place. I'd rather use a module built for the purpose now that I have several scripts that will use the functionality. Thanks! James. FYI: This is what I have so far: from re import compile def yes_no(question, default=None): """Prompt the user with a yes or no question.""" if default == "y": question = "".join((question, " [Y/n]: ")) elif default == "n": question = "".join((question, " [y/N]: ")) else: question = "".join((question, " [y/n]: ")) valid_answer = "[yn]" invalid_message = "Answer must be y or n" answer = prompt(question, valid_answer, invalid_message, default) return answer == 'y' def prompt(question, valid_answer, invalid_message, default=None): """Prompt the user with a question and validate their response.""" is_valid = False; compiled_valid_answers = compile(valid_answer) while not is_valid: answer = raw_input(question).lower() if answer == "" and default is not None: answer = default is_valid = compiled_valid_answers.match(answer) if not is_valid: print invalid_message return answer From fetchinson at googlemail.com Tue Apr 1 22:16:10 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Tue, 1 Apr 2008 19:16:10 -0700 Subject: ANN: cubictemp template engine In-Reply-To: <20080402012420.GA21586@nullcube.com> References: <20080402012420.GA21586@nullcube.com> Message-ID: > We are happy to announce release 2.0 of Cubictemp, a small, elegant > templating system for Python. > > > Features > ======== > > * Simple, well-tested and well-documented. > * Integrates tightly with Python - pass arbitrary Python objects into a > template, walk sequences and iterators, evaluate expressions. > * Default escaping helps to prevent common classes of Cross-Site > Scripting > vulnerabilities. > * Encourages separation of interface and program logic by disallowing > statements in templates. > * Tiny - only ~ 170 SLOC. There are many large, over-designed > Python templating systems out there. Cubictemp proves that a > templating > sytem can be elegant, powerful, fast and remain compact. > > > Download: http://dev.nullcube.com > > Manual: http://dev.nullcube.com/doc/cubictemp/index.html Does it support the Buffet API? Do you have any benchmarks to compare it with other template systems (in terms of speed)? Cheers, Daniel From toolmaster at 163.com Thu Apr 3 10:33:33 2008 From: toolmaster at 163.com (WaterWalk) Date: Thu, 3 Apr 2008 07:33:33 -0700 (PDT) Subject: unicode in exception traceback References: Message-ID: <5b988a00-d9d4-4aaa-bcd3-41d9af482bad@r9g2000prd.googlegroups.com> On Apr 3, 5:56 pm, Peter Otten <__pete... at web.de> wrote: > WaterWalk wrote: > > Hello. I just found on Windows when an exception is raised and > > traceback info is printed on STDERR, all the characters printed are > > just plain ASCII. Take the unicode character u'\u4e00' for example. If > > I write: > > > print u'\u4e00' > > > If the system locale is "PRC China", then this statement will print > > this character as a single Chinese character. > > > But if i write: assert u'\u4e00' == 1 > > > An AssertionError will be raised and traceback info will be put to > > STDERR, while this time, u'\u4e00' will simply be printed just as > > u'\u4e00', several ASCII characters instead of one single Chinese > > character. I use the coding directive commen(# -*- coding: utf-8 -*-)t > > on the first line of Python source file and also save it in utf-8 > > format, but the problem remains. > > > What's worse, if i directly write Chinese characters in a unicode > > string, when the traceback info is printed, they'll appear in a non- > > readable way, that is, they show themselves as something else. It's > > like printing something DBCS characters when the locale is incorrect. > > > I think this problem isn't unique. When using some other East-Asia > > characters, the same problem may recur. > > > Is there any workaround to it? > > Pass a byte string but make some effort to use the right encoding: > > >>> assert False, u"\u4e00".encode(sys.stdout.encoding or "ascii", "xmlcharrefreplace") > > Traceback (most recent call last): > File "", line 1, in > AssertionError: ? > > You might be able to do this in the except hook: > > $ cat unicode_exception_message.py > import sys > > def eh(etype, exc, tb, original_excepthook=sys.excepthook): > message = exc.args[0] > if isinstance(message, unicode): > exc.args = (message.encode(sys.stderr.encoding or "ascii", "xmlcharrefreplace"),) + exc.args[1:] > return original_excepthook(etype, exc, tb) > > sys.excepthook = eh > > assert False, u"\u4e00" > > $ python unicode_exception_message.py > Traceback (most recent call last): > File "unicode_exception_message.py", line 11, in > assert False, u"\u4e00" > AssertionError: ? > > If python cannot figure out the encoding this falls back to ascii with > xml charrefs: > > $ python unicode_exception_message.py 2>tmp.txt > $ cat tmp.txt > Traceback (most recent call last): > File "unicode_exception_message.py", line 11, in > assert False, u"\u4e00" > AssertionError: 一 > > Note that I've not done any tests; e.g. if there are exceptions with > immutable .args the except hook itself will fail. > > Peter Thanks. My brief test indicates that it works. I'll try it in more situations. From lucafbb at gmail.com Fri Apr 25 14:03:18 2008 From: lucafbb at gmail.com (Luca) Date: Fri, 25 Apr 2008 20:03:18 +0200 Subject: Newbie question about import Message-ID: <27308d500804251103t71d04b5fg1de6658ceab9d898@mail.gmail.com> Hi all. I'm trying to do something with python import but isn't working for me. Using python 2,5 I've a program structured like this: * a main module called (for example) "mommy" with an __init__.py and a file called "mommy.py" * a __version__ var defined inside the main __init__.py >From the mommy.py file I need to import the __version__ var, but I'm really not able to do this! I fear this is a very stupid task to do... my problem is that the file is called like the module. Anyone can point me to the solution? -- -- luca From dolloffdelvpg at gmail.com Wed Apr 16 08:09:01 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:09:01 -0700 (PDT) Subject: taylor swift age Message-ID: <3619c573-e170-41df-bacb-278e0b8f3b4c@r9g2000prd.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From pallavi.kale at bioanalytical.net Fri Apr 4 06:39:02 2008 From: pallavi.kale at bioanalytical.net (Pallavi Kale) Date: Fri, 4 Apr 2008 16:09:02 +0530 Subject: Python, Mysql, insert NULL Message-ID: <20080404103313.4F86267DD3@smtp10.netcore.co.in> Hello there, I was going through the thread of conversation happening around inserting null using python into mysql. I am facing a similar problem here. I have to insert say 8 values into a table using a stored procedure. Of the 8 values 2 are not null and the remaining can be null, most of the values have datatypes as int or float. When I try to pass null to these using python I keep getting None error from the sql server. I am using pymssql to talk to the database which is another reason the parameters that I pass have to be type defined that is say @solutionID = %d I, where @SolutionID is an integer type. Have anyone found a way to pass null into sql using python when the variable is other than string, please let me know I am just learning python so I am sure there must be a simpler and neater way to do it.. Thanks :-) Best regards, Pallavi Kale -------------- next part -------------- An HTML attachment was scrubbed... URL: From roger.dahlstrom at gmail.com Fri Apr 11 15:10:54 2008 From: roger.dahlstrom at gmail.com (rdahlstrom) Date: Fri, 11 Apr 2008 12:10:54 -0700 (PDT) Subject: Windows - window status (Running vs Not Responding) References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> Message-ID: On Apr 11, 1:45 pm, rdahlstrom wrote: > Does anyone know how to determine the window status (Running or Not > Responding)? I've tried various methods with no success... > > This would be on a variety of Windows systems, but all at least XP, > and mostly server 2003. Everyone will have Python 2.5.1 on them, and > the script would be running locally. > > Any ideas? Basically, I'm looking for something similar to the Process.Responding property in System.Diagnostics... From mensanator at aol.com Thu Apr 24 18:03:46 2008 From: mensanator at aol.com (Mensanator) Date: Thu, 24 Apr 2008 15:03:46 -0700 (PDT) Subject: DO YOU KNOW ANY THING ABOUT ISLAM??? References: <2429a87a-34e8-4294-9a25-b54dd2cf6791@m73g2000hsh.googlegroups.com> Message-ID: <153b6178-8ff9-43e6-a614-56db85186067@a70g2000hsh.googlegroups.com> You mean something besides wiping my ass with a rock? From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Mon Apr 28 16:02:22 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Mon, 28 Apr 2008 22:02:22 +0200 Subject: Simple unicode-safe version of str(exception)? References: Message-ID: <67moqeF2paokjU1@mid.individual.net> Russell E. Owen wrote: > I have code like this: > except Exception, e: > self.setState(self.Failed, str(e)) > which fails if the exception contains a unicode argument. Fails how? > I did, of course, try unicode(e) but that fails. Converting unicode to unicode doesn't help. Instead of just e, try using e.encode("some-encoding") where some-encoding should be your system's default encoding like utf-8 or iso8859-1. Regards, Bj?rn -- BOFH excuse #434: Please state the nature of the technical emergency From cokofreedom at gmail.com Fri Apr 4 07:58:19 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Fri, 4 Apr 2008 04:58:19 -0700 (PDT) Subject: Looking for Advanced Python Tutorials Message-ID: I was wondering if anyone knew of some online (free if possible) advanced tutorials, especially ones that provides tasks and ideas for small projects. The issue for myself is I want to improve my python programming level, and my ability to program in general, but come up blank thinking of a possible task or project to undertake. So with that in mind I thought I'd ask the community if they knew of sites or books to read up on and use as a starting block. Of course project ideas would be great as well! Thanks for any help you can provide. Coko From steve at holdenweb.com Mon Apr 21 22:10:22 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 21 Apr 2008 22:10:22 -0400 Subject: Lists: why is this behavior different for index and slice assignments? In-Reply-To: <480d435b$0$11643$607ed4bc@cv.net> References: <480d435b$0$11643$607ed4bc@cv.net> Message-ID: John Salerno wrote: > Hey all. I've decided I let my Python skills (minor though they were) > slip away so I started reading the new edition of Learning Python to > brush up. I just read about lists again and I'm wondering if someone > could explain what's going on under the hood that makes index and slice > assignments behave differently when assigning an empty list. > > For example: > > >>> L = [1, 2, 3, 4, 5] > >>> L[0:2] = [] > >>> L > [3, 4, 5] > > >>> L = [1, 2, 3, 4, 5] > >>> L[0] = [] > >>> L > [[], 2, 3, 4, 5] > > So the question is, when you assign an empty list to an index, why does > it insert an empty list, but when you assign an empty list to a slice, > it simply deletes the slice? > Assignment to a list *element* rebinds the single element to the assigned value. Assignment to a list *slice* has to be of a list, and it replaces the elements in the slice by assigned elements. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 18 11:39:34 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 18 Apr 2008 17:39:34 +0200 Subject: str class inheritance prob? In-Reply-To: <874eed0f-eeeb-4434-8a14-a3b29801a5f6@d26g2000prg.googlegroups.com> References: <874eed0f-eeeb-4434-8a14-a3b29801a5f6@d26g2000prg.googlegroups.com> Message-ID: <4808c09c$0$19986$426a74cc@news.free.fr> jkazoo at gmail.com a ?crit : > so I?m trying to create a class that inherits from str, but I want to > run some code on the value on object init. this is what I have: Others already gave you the technical solution (use __new__, not __init__). A couple remarks still: 1/ > > class Path(str): > def __init__( self, path ): > clean = str(path).replace('\\','/') > while clean.find('//') != -1: > clean = clean.replace('//','/') > > print 'cleaned on init:\t',clean > self = clean Assigning to self - or to any other local name - only impact the local namespace, it won't affect the object previously bound to that name. 2/ you may be interested in the existing path module: http://www.jorendorff.com/articles/python/path/ HTH From lists at cheimes.de Fri Apr 25 17:45:59 2008 From: lists at cheimes.de (Christian Heimes) Date: Fri, 25 Apr 2008 23:45:59 +0200 Subject: Why is None <= 0 In-Reply-To: <481228DF.5010408@ulmcnett.com> References: <481228DF.5010408@ulmcnett.com> Message-ID: <48125117.9060907@cheimes.de> > In my humble opinion, I think that comparisons involving None should > return None, but I trust that the designers came up with this for very > good reasons. As far as I know I've never been bitten by it. It's fixed in Python 3.x. Python 3.x refuses to compare objects unless one of both objects has explicit support for both types: >>> 1 < None Traceback (most recent call last): File "", line 1, in TypeError: unorderable types: int() < NoneType() From aldo at nullcube.com Sun Apr 6 20:12:52 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Mon, 7 Apr 2008 10:12:52 +1000 Subject: ANN: pry unit testing framework In-Reply-To: References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> Message-ID: <20080407001252.GA12883@nullcube.com> Thus spake Matthieu Brucher (matthieu.brucher at gmail.com): > One last question : does it take doctests into account ? I'm afraid that Pry is unashamedly incompatible with any other unit testing method in existence, including but not limited to doctest, unittest, nose and py.test. ;) Some day I might experiment with extending Pry to gather and run doctests and unittests. At this stage, however, I don't believe the (significant) effort would be worth it. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From deets at nospam.web.de Wed Apr 9 10:16:14 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 09 Apr 2008 16:16:14 +0200 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> Message-ID: <6641eaF2ics8jU1@mid.uni-berlin.de> subhabrata.iisc at hotmail.com wrote: > I thought if you know then only you can help. I am waiting for a > knowledgeable answer from a knowledgeable person. I think I can show a ALL the answers you got here so far indicate that you did NOT give enough details to actually answer the question. Moreover, you claim to observe phenomena that simply are ridiculously and obviously wrong - a1=1 a2=2 a3=a1+a2 will yield 3 under ALL circumstances. Instead, you posted random snippets of non-working code that show the worst in coding style claiming they don't work, without telling us WHAT is not working. And then you reply telling us about the greatness of Bangalore and your product to come. Which is somewhat amusing that people who claim to produce the greatest software being incapable of debugging it deems me as odd - to say the least. Because they should be more experienced. I suggest you read this: http://catb.org/~esr/faqs/smart-questions.html At least two times. And then come back and post self-contained examples of whatever behavior you observe, and this community will be as helpful as it is. But we can't read sense in anything you posted so far, despite the best efforts. So unless that changes, you won't be helped here. Diez From victorsubervi at gmail.com Thu Apr 3 08:43:57 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 3 Apr 2008 07:43:57 -0500 Subject: Strange MySQL Problem... In-Reply-To: <47f46a3e$0$36371$742ec2ed@news.sonic.net> References: <4dc0cfea0804021236n1faafabav1699fbe45acc3c01@mail.gmail.com> <47f46a3e$0$36371$742ec2ed@news.sonic.net> Message-ID: <4dc0cfea0804030543t1ad5a3abs539fa6598061c454@mail.gmail.com> Comments in line... On Thu, Apr 3, 2008 at 12:35 AM, John Nagle wrote: > Steve Holden wrote: > > Define "no longer works". > Sorry. Throws HTTP 200 error. On Thu, Apr 3, 2008 at 12:35 AM, John Nagle wrote: > John Nagle wrote: > > "works fine"? Please check again... > > The same remarks I've posted earlier apply here. > Must have missed those. Yes, the code works fine. Repeatedly. > > > In addition, you're not committing the database update. > You need to do > > connection.commit() Oh, thanks :) > > > after updating. > > In general, server side programs should have a try-block > wrapped around most of the program, with some code to display or > log errors in some useful way. Curious. Why? During testing, I understand, but after testing, why? On Thu, Apr 3, 2008 at 12:35 AM, John Nagle wrote: > Gabriel Genellina wrote: > > > print 'Content-Type: image/jpeg\r\n' > > print '\nHi!\n' > > Don't you see a conflict among those two lines? > (You're a liar: first you promise to send a nice picture and then you only > send a letter!) > LOL! Okay, make me honest ;) I want to post both text and images. What use? > > > > cursor.execute("CREATE TABLE justatest (name TEXT, ablob BLOB)") > > Note that you *always* attempt to create a table. > Yeah, I am dropping it, too. This was just some code I found online and tweaked. > > > > sql = "INSERT INTO justatest VALUES (%s, %s)" > > cursor.execute(sql, ('ramis', _mysql.escape_string(f)) ) > > You're using bound parameters now, a good thing. There is no need to > escape strings passed as parameters - in fact, it is wrong, as the adapter > will escape the text again. > In this case, the column is a BLOB, and you have to use the Binary > function: MySQLdb.Binary(f) > Nope. Threw me another HTTP 200. > > Now, if I take out this part, which I can?t see does anything at all in > > the > > code, it no longer works: > > I don't think "it no longer works" because you removed anything, but > because this script can only be run at most once. Probably you're getting > an error in the CREATE TABLE statement. > Wrong. I check the mysql and drop the table if the code throws me an HTTP 200 error. I have run this code many times now. That is what makes the whole thing so ridiculously strange to me. That code snippet, that the script insists on, is a relic from the code I tweaked. It was there to make a binary, that is all. So why do I still need the darn thing?? > > You have to look at the server error logs, else you're blind fighting. > I am blind fighting. No longer run my own server, no longer have root access. > See > other suggestions in my previous post. > Sorry. Can you repost it? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From bskaplan14 at yahoo.com Thu Apr 24 15:24:43 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Thu, 24 Apr 2008 12:24:43 -0700 (PDT) Subject: NameError: global name 'Response' is not defined Message-ID: <709609.88093.qm@web39206.mail.mud.yahoo.com> Are you importing pylons? How are you doing it? If you are doing "from pylons import Response" or "from pylons import *", then you have another problem. If you are just doing "import pylons", then you need to do "return pylons.Response(...)" ----- Original Message ---- From: Lalit To: python-list at python.org Sent: Thursday, April 24, 2008 10:27:36 AM Subject: NameError: global name 'Response' is not defined Hi I am very new to web development. I started with Pylons. I am using http://www.rexx.com/~dkuhlman/pylons_quick_site.html as reference to create a sample web page using pylons. I got stuck up at step 4.3 i.e when modifying controller to "return Response('

firstapp default

')" I am getting error of : global name 'Response' is not defined It seems I am missing some package. I am not really sure. I installed python 2.5 and through easy_install imported pakages (pylons). Any clues would be appreciated Thanks Lalit -- http://mail.python.org/mailman/listinfo/python-list ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From zhushao888 at yahoo.com.cn Mon Apr 14 06:08:11 2008 From: zhushao888 at yahoo.com.cn (008) Date: Mon, 14 Apr 2008 03:08:11 -0700 (PDT) Subject: Wholesale all electronics merchandises.........Our trademark contain nokia... the all laptops...the Apple Iphone....the Apple IPOD........the Sony Ericsson.... LG....HTC.... the Sony Playstation 3..Wii...the Microsoft xbox 360....the Sony PSP.. the Itouch(4 GB/8 GB/16 GB/32 GB) Ipod 3 rd generation Ipod Nano II.......the TomTom GPS.....the Garmin Nuvi GPS.... the Robot Dog....the Robot Dinosaur......http://www.sonyecvv.com......msn: pthongda@hotmail.com Message-ID: <8ef31eea-5abb-43fa-a5a8-13f409467d95@l28g2000prd.googlegroups.com> hi We are the most professional with the biggest wholesale electronics merchandise supply merchandise ..........We have a lot of very nice quality merchandises with the very special price our brands all sony...all LG....all NOKIA...all ipod....all GPS ..,are also available for sale at cheaper rate. They are all brand new with full accessories and 1 year international warranty, unlocked, work effectively with any network worldwide and come with user manual guide in various languages. Ipod nano 1G 45$ ,2G 55$, 4G 65$,8G 70$, 30G 100$ ,60G 120$ ps3 60GB 330$ 20GB 180$ 80GB 450$ psp 150$ wii 200$ We have all models of nokia NOKIA N95 $250 NOKIA N93 $190 NOKIA N92 $160 NOKIA N91 $170 NOKIA N90 $180 Nokia N70 $165 NOKIA N73 $180 NOKIA 7600 (UNLOCK) $150 Nokia 8800 Sirocco Gold Edtion -$250 Nokia 8800 Sirocco Black$250 We wholesale all laptops Sony VGN-CR13/B 380$ Sony VGN-CR13/L 350$ Sony VGN-CR15/B 320$ Sony VGN-CR13/P 480$ Sony VGN-C21CH 450$ Sony VGN-SZ44CN 580$ Sony VGN-C22CH/W 620$ Sony VGN-N17C 480$ Sony VGN-CR13/W 580$ Sony VGN-FZ15 560$ Apple MacBook 580$ Apple MacBook Pro(MA896CH/A)680$ Apple MacBook Pro(MA896CH/A) 630$ Apple MacBook (MB063CH/A) 580$ Apple MacBook Pro(MA895CH/A) 580$ Apple MacBook(MB062CH/A) 590$ Apple MacBook(MA700CH/A) 580$ Apple MacBook(MA701CH/A) 550$ Apple MacBook Pro ?MA610CH/A? 650$ Apple MacBook Pro (MA611CH/A) 680$ Apple MacBook (MA699CH/A) 580$ (1).all products are all original and new (2).they have 1year international warranty. (3).free shipping include ems, tnt, dhl, ups. you may choose one kind (4).deliver time is in 5days to get your door We insist the principia: Prestige first,high-quality,competitive price, best services,and timely delivery. Website: http://www.sonyecvv.com msn: pthongda at hotmail.com Fa-Fa Co., Ltd. From ivan.illarionov at gmail.com Sun Apr 13 12:35:41 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Sun, 13 Apr 2008 09:35:41 -0700 (PDT) Subject: Interesting math problem References: <3a34caaf-a279-4e86-837d-42efa4d80129@d4g2000prg.googlegroups.com> Message-ID: <3fe449cb-4060-4bb6-9605-1e1778b707f8@p39g2000prm.googlegroups.com> On Mar 19, 2:17 pm, "BJ?rn Lindqvist" wrote: > On Mon, Mar 17, 2008 at 11:57 PM, Arnaud Delobelle > > > > wrote: > > > def make_slope(distance, parts): > > > step = distance / float(parts) > > > intstep = int(step) > > > floatstep = step - intstep > > > > steps = [] > > > acc = 0.0 > > > for i in range(parts): > > > acc += floatstep > > > step = intstep > > > if acc > 0.999: > > > step += 1 > > > acc -= 1.0 > > > steps.append(step) > > > return steps > > > OK then, using list comprehensions. It is more succint, is it easier > > to read? > > > def slope(dist, parts): > > return [(i+1)*dist/parts - i*dist/parts for i in xrange(parts)] > > Congratulations! You Won! Jeff Schwab's recursive approach is also > cool but this is the most interesting abuse of integer division I have > seen. I don't think any of the variants are readable at a first > glance, but with a comment it should be ok. > > -- > mvh Bj?rn I really want to revive this discussion. Arnaud's approach is definetly cool, but it turns out that in real-world situations it doesn't work as succint as here. Try to use it to draw a simple non-anitaliased line in a standrad python array or buffer object. Suppose we have an array of unsigned bytes called `buf` where each line takes `pitch` bytes. That's what I got while trying to take advantage of this approach. No advantage at all. And what about ability to port the code to C for speed? def draw_line(buf, pitch, x, y, dx, dy): if dx == dy == 0: buf[y * pitch + x] = 0 return xdir, ydir = 1, 1 if dx < 0: xdir = -1 dx = abs(dx) if dy < 0: ydir = -1 dy = abs(dy) if dy < dx: steps = ((i+1) * dx / dy - i * dx / dy for i in xrange(dy)) for step in steps: start = y * pitch + x if xdir > 0: buf[start : start + step] = array('B', [0] * step) else: buf[start - step : start] = array('B', [0] * step) x += step * xdir y += ydir else: steps = ((i+1) * dy / dx - i * dy / dx for i in xrange(dx)) for step in steps: start = y * pitch + x if ydir > 0: for i in range(start, start + pitch * step, pitch): buf[i] = 0 else: for i in range(start, start - pitch * step, -pitch): buf[i] = 0 x += xdir y += step * ydir Please, tell me that I'm wrong and it's really possible to draw lines, do scan-conversion and so on with such a cool succint constructs! -- Ivan From mal at egenix.com Tue Apr 29 17:30:25 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Tue, 29 Apr 2008 23:30:25 +0200 Subject: Need Python alternative to Request-Tracker help desk software In-Reply-To: <0A53725C4A497848A7B3A0874B259831011B08E8@acesxch01.ADVENTISTCORP.NET> References: <0A53725C4A497848A7B3A0874B259831011B08E8@acesxch01.ADVENTISTCORP.NET> Message-ID: <48179371.5010508@egenix.com> On 2008-04-29 22:15, Sells, Fred wrote: > I've been tasked with either implementing Request-Tracker to upgrade our help desk issue tracking system or finding a Python equivalent (both in terms of functionality and wide spread use). Request-Tracker uses Apache and MySQL, which would also be appropriate to Python. > > I would prefer to go the Python route, especially since Request-Tracker is written in Perl (which I don't know). > > My initial attempts with Google were not useful due to the general nature of the keywords. > > Are there any suggestions. You should have a look at Trac (http://trac.edgewall.org/) and roundup (http://roundup.sourceforge.net/). Both are written in Python and provide excellent issue tracking. They differ a bit in design and approach to issue tracking, so you will likely need to investigate a bit further before you decide. Both are easy to extend and adapt to whatever needs you have. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 29 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From sjmachin at lexicon.net Mon Apr 21 18:39:00 2008 From: sjmachin at lexicon.net (John Machin) Date: Mon, 21 Apr 2008 22:39:00 GMT Subject: dynamically importing a module and function In-Reply-To: References: Message-ID: <480d1782$1@news.mel.dft.com.au> rkmr.em at gmail.com wrote: > Hi > I have a function data['function'], that I need to import from a file > data['module'], in the directory data['cwd'] OT: Any good reason for using a dictionary instead of a class instance (data.functiom, data.module, etc)? > > If I do this from python interactive shell (linux fedora core 8) from > dir /home/mark it works fine: > > cwd = data['cwd'] > os.chdir(cwd) > print os.getcwd() > module = __import__(data['module']) > function = getattr(module, data['function']) > This is possibly due to python using what was the current working directory when it started up. An alternative (untested): saved = sys.path sys.path = data['cwd'] module = __import__(data['module']) sys.path = saved Exception handling is left as an exercise for the reader. HTH, John From victorsubervi at gmail.com Tue Apr 1 08:36:00 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Tue, 1 Apr 2008 07:36:00 -0500 Subject: Adding Images to MySQL Message-ID: <4dc0cfea0804010536q71bce9ev38cff43923f5a4b8@mail.gmail.com> Hi; I?m trying to figure out how to upload images into a MySQL database. (Yes, that is what I want to do.) I have a form that asks for data, like this: 1ra Foto Peque?a: Then I send that form to a python script that processes like this: cursor.execute('insert into products (' + col_names + ') values (' + col_values + ');') where col_names is all the names of the columns and col_values, obviously, the values. Works fine for strings and digits. Not so well for files :) What do? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 18 04:48:14 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 18 Apr 2008 10:48:14 +0200 Subject: Metaprogramming Example In-Reply-To: <562bae18-7b8e-4863-8923-0e5a01ba7125@t54g2000hsg.googlegroups.com> References: <930643c6-2d56-4fb0-aee0-a3e79231f09b@24g2000hsh.googlegroups.com> <32472b97-f35a-4408-96f5-2f8c8f92ae56@m73g2000hsh.googlegroups.com> <39325652-e0cf-4efd-9b28-00c0fe8552cc@m73g2000hsh.googlegroups.com> <562bae18-7b8e-4863-8923-0e5a01ba7125@t54g2000hsg.googlegroups.com> Message-ID: <48086036$0$759$426a74cc@news.free.fr> andrew cooke a ?crit : > bruno: >> Ho, and yes : one day, you'll get why it's such a good thing to unite >> functions and methods !-) > > me: >> PS Is there anywhere that explains why Decorators (in the context of >> functions/methods) are so good? I've read lots of things saying they >> are good, but no real justification of why. > > in the text above i wrote "Decorators" rather than "Descriptors". it > was in response to bruno's comment, also above. sorry for the > confusion. Ho, you meant Descriptors ? Well, a first point is that the support for methods is built on a combination of two "general purpose" constructs - callable objects and the descriptor protocol - instead of being a special-case construct by itself. IOW, this is build *with* Python itself, instead of being built *into* Python. Practically, this means that (amongst other niceties) : - you can define functions outside classes and use them as instance or class methods - you can add/replaces methods dynamically on a per-class or per-instance basis - you can access the function object of a method and use it as a function - you can define your own callable types, that - if you implement the appropriate support for the descriptor protocol - will be usable as methods too > also, sorry for the inflammatory language Which one ??? > by referring to the titanic > i didn't mean that python was a disaster, rather that the "iceberg" is > still there (i am not 100% sure what the iceberg is, but it's > something > to do with making namespaces explicit in some places and not others). I guess you're thinking of the self argument, declared in the function's signature but not "explicitly passed" when calling the method ? If so, the fact is you *do* pass it explicitly - by calling the function *as a method of an objet*. Given the following definitions: def func(obj, data): print "obj : %s - data : %s" % (obj, data) class Foo(object): meth = func f = Foo() What the difference between: func(f, 42) and f.meth(42) In both cases, f is directly and explicitly involved as one of the "targets" of the call. My 2 cents... From jstroud at mbi.ucla.edu Wed Apr 23 22:08:49 2008 From: jstroud at mbi.ucla.edu (James Stroud) Date: Wed, 23 Apr 2008 19:08:49 -0700 Subject: logging doc problem Message-ID: Am I missing something or are the docs for logging hopelessly outdated? http://docs.python.org/lib/node406.html For example, quoting the docs """ import logging logging.debug('A debug message') logging.info('Some information') logging.warning('A shot across the bows') """ And the result is % /usr/bin/python Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. py> import logging py> py> logging.debug('A debug message') Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'debug' More importantly, do any good docs for logging exist, or is it touch and go? James From uniontelecardsindia at gmail.com Tue Apr 22 17:16:18 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:16:18 -0700 (PDT) Subject: Asian gay hunks extreme deep cock sucking Message-ID: <9957653d-6533-4bf3-b33f-a3673c2cc05d@a70g2000hsh.googlegroups.com> Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From spellucci at fb04373.mathematik.tu-darmstadt.de Fri Apr 4 10:58:15 2008 From: spellucci at fb04373.mathematik.tu-darmstadt.de (Peter Spellucci) Date: Fri, 4 Apr 2008 16:58:15 +0200 (CEST) Subject: Nonlinear least square problem References: <0354420e-819d-4ba3-b61a-faaffd46b65c@r9g2000prd.googlegroups.com> Message-ID: In article <0354420e-819d-4ba3-b61a-faaffd46b65c at r9g2000prd.googlegroups.com>, Uwe Kotyczka writes: >Hallo, sorry for multiposting, but I am really looking >for some hint to solve my problem. And no, I don't >use Matlab, but maybe the matlab people have an idea >nevertheless. > >I have to solve a nonlinear least square problem. >Let me tell you some background first. Imagine >you have a tool to process some work piece, say >polishing some piece of glas. The tool behaves >different on different locations of the piece, >and I can describe that behaviour. Now the tool >shall smooth the surface of the workpiece. >Next I have information about the piece before >handling it. What I have to find is optimal >time curve for the tool to obtain a perfectly >smooth surface. > >How to formulate the problem? >Given a time vector (t_j) I have a function >g which calculates the remaining error (e_i) >(e_i) = g(t_j) >The rest error is given at, say, 100 points, >(t_j) is searched at 200 points. >My idea was to make the (t_j) a function of >some few parameters (t_j) = h(p_k), say 15 >parameters. So the concatenated function >(e_i) = g(t_j) = g(h(p_k)) =: f(p_k) is to be minimized. >in the sense (e_i)-c -> Min, where c is a constant, >the end level of the surface. > >To solve this problem I use a "C" implementation >of the Levenberg-Marquardt algorithm as you can find >it in the LevMar Package (www.ics.forth.gr/~lourakis/levmar/). > >The function g contains the information about the >tool and about the initial surface. For the function >h I tried several approaches, making the time a >cubic spline of a selected times, or making it some >polynmial or... > >Now what is my problem? With the above I do find >solutions, however a lot of solutions seem to >give very similar remaining errors. The only problem >is that the corresponding time vectors, which are >(t_j_optimal) = h(p_k_optimal) look very different >from optimal solution to optimal solution. >In particular the optimization algorithm often prefers >solutions where the time vector is heavily oscillating. > >Now this is something I _must_ suppress, but I have no >idea how. The oscillation of the (t_j) depend of >the ansatz of h, of the number of parameters (p_k). >If f would be a linear function, then the matrix >representing it would be a band matrix with a lot >of diagonals nonzero. How many depends on the >ratio tool diameter to piece diameter. > >Now what are my question: Is the problem properly >formulated? Can I expect to find non-oscillating >solutions? Is it normal that taking more parameters >(p_k) makes the thing worse? What else should I >consider? Is this more verbal description sufficient? > >Thank you very much in advance. > > > > wouldn't be the normal way to describe this problem be an optimal control problem? and there will be constraints? let us take the example of the polishing problem: your tool must move over the surface and will actually operate over a (small)disk: you must design a path of the disc center such that the working area of the tool covers the whole surface. If you assume location dependent roughness, then it might be impossible directly to polish one location perfectly, such that the path must be taken several times. maybe due to heating during the polishing process, it may be necessary to introduce gaps in the path in order to avoid overheating of some area. this may take time and/or energy and you might want to solve a minimal time or minimal energy problem subject to your constraints. if you are lucky, you end up with a convex problem wwhich will exhibit a unique solution. otherwise you might be trapped in a local optimum. such a path could be modeled by a spline curve for example, and as far as I know there are already industrial solvers for types of this problem. hth peter From gagsl-py2 at yahoo.com.ar Wed Apr 16 11:23:56 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 08:23:56 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <0A685715-6D44-4D41-87C2-4B971A751E78@gmail.com> Message-ID: On 15 abr, 13:58, Michael Torrie wrote: > > After parsing this thread through a noise filter, it appears the main > concern is not the converting of _python code_ from 2 to 3, but rather > converting extensions written in C, or when python is embedded in a C > program. ?The APIs have necessarily changed, and this *will* inflict a > certain amount of pain and suffering on the developer, especially if he > needs to maintain code for both python 2 and python 3. ?However this is > just the way it is. ?It's a bit like complaining that I have to rewrite > my app with win32 calls and paradigms when I was used to win16. ?No > conversion will be completely pain free, but this jump is pretty > insignificant compared to others in the industry. Yes, at the C level you have to either live with a lot of #ifdefs, or maintain two branches. I prefer the second choice (with the help of a good SCM tool) but that's a matter of taste or convenience. -- Gabriel Genellina From mnordhoff at mattnordhoff.com Tue Apr 8 03:27:26 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Tue, 08 Apr 2008 07:27:26 +0000 Subject: Destructor? In-Reply-To: <47FB1937.5050008@mydeskfriend.com> References: <47FB1937.5050008@mydeskfriend.com> Message-ID: <47FB1E5E.6010708@mattnordhoff.com> Gabriel Rossetti wrote: > Hello everyone, > > we are writing an application that needs some cleanup to be done if the > application is quit, normally (normal termination) or by a signal like > SIGINT or SIGTERM. I know that the __del__ method exists, but unless I'm > mistaken there is no guarantee as of when it will be called, and some > objects may have already been released (at lease I've had trouble in the > past accessing certain objects from inside __del__, probably since the > parent class's __del__ has to be called first, then it's objects are > already released by the time I need to do something with them). Another > method would be to implement something using the signal module and have > a callback that does all the cleanup when the app. is > quit/terminated/interrupted and have all the child classes override that > with their cleanup code. > > What is the community's point of view on the subject? > > Thanks, > Gabriel atexit? If it's only small things, there's try...finally, of course.. -- From fredrik at pythonware.com Fri Apr 4 12:34:59 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 04 Apr 2008 18:34:59 +0200 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> Message-ID: llothar wrote: > On windows everything is '.pyd' but there seems to be two ways to get > this on unix? If you attempt to import the module "spam" on Windows, Python looks for "spam.dll" and "spam.pyd" (in addition to "spam.py/spam.pyw/spam.pyc" etc) On most Unix platforms, Python looks for "spam.so" and "spammodule.so". You can check what suffixes a given Python version uses via the "imp" module: >>> import imp >>> imp.get_suffixes() To see *where* Python is looking as well, use the "-vv" flag: $ python -vv -c "import spam" ... # trying spam.so # trying spammodule.so # trying spam.py # trying spam.pyc ... etc (-vv prints loads of stuff, so you may want to use "grep" to filter out the stuff you're interested in: $ python -vv -c "import spam" 2>&1 | grep spam or, under Windows: > python -vv -c "import spam" 2> out.txt > findstr spam out.txt ) > Why and what is the rule? If you want Python to be able to import your binary extension, make sure to use a name it looks for. From marco at sferacarta.com Thu Apr 3 10:25:07 2008 From: marco at sferacarta.com (Marco Mariani) Date: Thu, 03 Apr 2008 16:25:07 +0200 Subject: object-relational mappers In-Reply-To: <47f4e456$0$20141$426a74cc@news.free.fr> References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> <89bca327-6a3f-4128-be72-75d4a50b9bf0@13g2000hsb.googlegroups.com> <47f4e456$0$20141$426a74cc@news.free.fr> Message-ID: <7N5Jj.10079$T35.8116@tornado.fastwebnet.it> Bruno Desthuilliers wrote: >> A simple select query would be db.select('customers') or >> db.select('customers', name='John'). >> But you can also resort to plain sql as follows: db.query('select * >> from customers where name = "John"'). >> >> Simple, effective and doesn't get in your way. > > Seems nice too in another way. And no different than using SQLAlchemy's sa.select() or engine.execute(), after all. > Is that part independant of the rest of the framework ? If so, I'll have to give it a try at least for admin > scripts. My admin scripts go through SQLAlchemy as well, I just have some issues with postgres' COPY statement -- but I don't know if the DBAPI is supposed to handle that. From bbxx789_05ss at yahoo.com Sat Apr 5 15:55:26 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sat, 5 Apr 2008 12:55:26 -0700 (PDT) Subject: Tkinter, add pressed buttons onto string display string, how to? References: Message-ID: skanem... at yahoo.se wrote: > using tkinter and python i now have a small App (that will hopefully > soon be a fully functioning calculator) where u can push buttons and > the corresponding number or operator is shown. > > when u press 1, "1" appears on the screen, pres + and "+" appears etc. > > at the moment every output overwrites the previous so what i want to > do is obviosuly to add every new output to a string so that i can read > the string and perform the calculation. > > so i want: > * when pushing the button push the token of the button onto a string > * display the new string, ie "1+2" for example > * want to be able to access this string when pressing calculate so i > can figure out which operators should > be done first so it can solve something like this: "(1+2*3)(3-4/2)" > and not just simple "1+2"-stuff. > > do i have to have some global string-variable in the GUIframework > then? im not sure where to start... > input = "hello" input += " world" print input --output:-- hello A caculator program is pretty complex. Based on your rudimentary questions, I don't think you have enough programming experience to tackle a project like that yet. From marek.rocki at wp.pl Mon Apr 28 12:45:39 2008 From: marek.rocki at wp.pl (marek.rocki at wp.pl) Date: Mon, 28 Apr 2008 09:45:39 -0700 (PDT) Subject: Given a string - execute a function by the same name References: Message-ID: <376ee8c4-8cb4-45c2-83bc-5556f88c783f@m3g2000hsc.googlegroups.com> One solution may be to use globals(): >>> globals()['foo']() Regards, Marek From george.sakkis at gmail.com Sun Apr 20 12:08:27 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Sun, 20 Apr 2008 09:08:27 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: On Apr 20, 11:35?am, Eric Wertman wrote: > I was considering putting together a proposal for an alternate block > syntax for python, and I figured I'd post it here and see what the > general reactions are. ?I did some searching, and while I found a lot > of tab vs space debates, I didn't see anything like what I'm thinking > of, so forgive me if this is a very dead horse. [with apologies to Monty Python] This horse is no more! He has ceased to be! 'E's expired and gone to meet 'is maker! 'E's a stiff! Bereft of life, 'e rests in peace! THIS IS AN EX-HORSE!! :) > Generally speaking, I like the current block scheme just fine. ?I use > python on a daily basis for system administration and text parsing > tasks, and it works great for me. > > From time to time, though, I find myself needing a language for server- > side includes in web pages. ?Because of the need to indent (and > terminate indents), python seems an awkward choice for this, and it's > easy for me to see why php and perl are more popular choices for this > kind of task. ?Perhaps this is just my perception though. Look into any of the dozen Python-based template engines that are typically used for such tasks; they offer many more features than a way to indent blocks. George From ilanschnell at gmail.com Sat Apr 19 14:47:31 2008 From: ilanschnell at gmail.com (ilanschnell at gmail.com) Date: Sat, 19 Apr 2008 11:47:31 -0700 (PDT) Subject: Issue with inspect module References: <2e5e2d31-2adc-4416-a993-19bc05a512bd@w8g2000prd.googlegroups.com> Message-ID: On Apr 19, 1:41 pm, Karl-Heinz Ruskowski wrote: > > Why does the inspect module cause the output > > to be printed twice? > > I also tested it, no problem here either. I realized what the problem was. I called the file inspect.py, stupid me. Thanks From gagsl-py2 at yahoo.com.ar Sun Apr 20 00:58:58 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 01:58:58 -0300 Subject: User-defined Exceptions: is self.args OK? References: Message-ID: En Thu, 17 Apr 2008 19:11:36 -0300, Petr Jake? escribi?: > I am trying to dig through User-defined Exceptions. chapter 8.5 in > http://docs.python.org/tut/node10.html > > > I would like to know, if is it OK to add following line to the __init__ > method of the TransitionError class? > > self.args = (self.previous, self.next, self.message) Not necesarily, but you should call the base __init__, perhaps with a suitable message. Most of the time, a meaningful error message is all what I want, so I write: class FooError(Exception): pass (perhaps inheriting from ValueError or TypeError or any other more meaningful base error). Then, when something wrong is detected: if ....: raise FooError, "some %s message" % foo In your case, you appear to require more info stored in the exception. Try this (based on your code): class TransitionError(Error): # I assume Error inherits from Exception? def __init__(self, previous, next, message): self.previous = previous self.next = next Error.__init__(self, previous, next, message) # perhaps: Error.__init__(self, message) # if message already contain references to # previous and next raise TransitionError, (1, 2, "oops") Traceback (most recent call last): File "", line 1, in __main__.TransitionError: (1, 2, 'oops') -- Gabriel Genellina From the.blue.valkyrie at gmail.com Wed Apr 23 10:26:08 2008 From: the.blue.valkyrie at gmail.com (=?ISO-8859-1?Q?Cristina_Yenyxe_Gonz=E1lez_Garc=EDa?=) Date: Wed, 23 Apr 2008 16:26:08 +0200 Subject: Python Success stories In-Reply-To: References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: 2008/4/23, Reedick, Andrew : > > IIRC, Python is used in games like Eve Online (SciFi MMO) and Vampire: > Bloodlines (RPG.) Years later, a dedicated fan is still fixing/updating > the Bloodlines python scripts that control the dialogue and scripted > events. > Now that you mention it, Python was also used in the Star Wars: Knights of the Old Republic (KotOR) saga. You can even search the scripts across the disc and take a look at hilarious code comments like "this works but I don't know why" :D From python at bdurham.com Tue Apr 29 11:35:30 2008 From: python at bdurham.com (python at bdurham.com) Date: Tue, 29 Apr 2008 11:35:30 -0400 Subject: Given a string - execute a function by the same name In-Reply-To: <27f6ba19-8756-4d96-851f-2a7c585ef3c7@m44g2000hsc.googlegroups.com> References: <27f6ba19-8756-4d96-851f-2a7c585ef3c7@m44g2000hsc.googlegroups.com> Message-ID: <1209483330.17070.1250499293@webmail.messagingengine.com> Arnaud, Just when I thought my solution couldn't get any better :) Thanks for that great tip and for an excellent demonstration of using a decorator. Regards, Malcolm You could avoid #5 from the start using a decorator: functions = {} def register(func): functions[func.__name__] = func return func @register def foo(): print "Foo!" @register def bar(): print "Bar!" >>> functions {'foo': , 'bar': } >>> functions['bar']() Bar! From ch612bunn at gmail.com Sun Apr 27 09:13:23 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:13:23 -0700 (PDT) Subject: nero 8 crack Message-ID: nero 8 crack http://wga-cracks.crackkey.net From gagsl-py2 at yahoo.com.ar Sat Apr 5 20:30:06 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 05 Apr 2008 21:30:06 -0300 Subject: Recursively Backup Directories References: Message-ID: En Sat, 05 Apr 2008 20:56:31 -0300, escribi?: > I am writing a script that will backup specified folders from one hard > drive to another (for example, backup source "C:\DATA", destination "D: > \Backup"), and was thinking of using shutil. What I would like to do > is recursively backup the specified directories (which copytree will > do), but be able to specify exclusion directories (which copytree does > not appear to allow you to do). My initial thoughts were I'll > probably have to use os.path.walk for the backup source directory, but > I'm not sure how to go from there. Thanks in advance. I'd use os.walk (not os.path.walk) and shutil.copy2; use os.makedirs to create the target directory (only when it doesn't already exist). If you remove directories from the dirnames list, they're not recursed into. -- Gabriel Genellina From victorsubervi at gmail.com Fri Apr 25 17:01:31 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Fri, 25 Apr 2008 16:01:31 -0500 Subject: Goodbying Spaces Message-ID: <4dc0cfea0804251401p3ab96fddy99452f5a3255acde@mail.gmail.com> Hi; Whenever I call a field from the preceeding form using cgi.FieldStorage() I get a space on either side. I end up writing code like this to get rid of that space: try: if id[0] == ' ': id = id[1:len(id)] except: pass try: if id[len(id) - 1] == ' ': id = id[0:len(id) - 1] except: pass which is a nuisance. Is there a better way to do this? I have tried id.strip() with no luck. What do? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From vivainio at gmail.com Sun Apr 6 15:19:31 2008 From: vivainio at gmail.com (Ville Vainio) Date: Sun, 6 Apr 2008 12:19:31 -0700 (PDT) Subject: ANN: Leo 4.4.8 final References: Message-ID: <3cdc0b0d-648c-44b0-a03c-2c6233f74ada@e10g2000prf.googlegroups.com> On Apr 6, 8:10 pm, "Edward K Ream" wrote: > - Completed ILeo: a bridge between IPython and Leo. > See http://webpages.charter.net/edreamleo/IPythonBridge.html Additional note: to use ILeo, you need a new IPython. Download the not- yet-blessed release candidate (I don't foresee much changes before the final release) from: https://launchpad.net/ipython/stable/0.8.3pre It's a source distribution, so run "eggsetup.py develop" in it (if you have setuptools) or just "setup.py install" From soray6034rao at gmail.com Wed Apr 30 07:29:54 2008 From: soray6034rao at gmail.com (soray6034rao at gmail.com) Date: Wed, 30 Apr 2008 04:29:54 -0700 (PDT) Subject: microsoft office word 2007 keygen download Message-ID: microsoft office word 2007 keygen download http://crack.cracksofts.com From usenet at janc.be Wed Apr 2 23:37:43 2008 From: usenet at janc.be (Jan Claeys) Date: Thu, 03 Apr 2008 03:37:43 GMT Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: Op Wed, 02 Apr 2008 17:02:45 -0400, schreef Dan Upton: > Side rant: I think Java's just fine, as long as it's taught properly. > I'd done a little bit of C and C++ programming when I was in high > school, trying to teach myself from a book, but I never really got > pointers or objects. Going back to it after Java, it made so much more > sense, even though people will tell you "Java doesn't make you learn > about pointers." I learned about pointers while learning Pascal (and later embedded assembler) using Borland's tools. Later I learned C (and even later C++), and I've always been wondering why those languages were making simple things so complicated... -- JanC From pscott at uwc.ac.za Tue Apr 15 02:11:18 2008 From: pscott at uwc.ac.za (Paul Scott) Date: Tue, 15 Apr 2008 08:11:18 +0200 Subject: a name error In-Reply-To: <20080415055502.9F3CF292B61@mail-in-07.arcor-online.net> References: <20080415055502.9F3CF292B61@mail-in-07.arcor-online.net> Message-ID: <1208239878.6947.12.camel@paul-laptop> On Tue, 2008-04-15 at 13:54 +0800, Penny Y. wrote: > import urllib2,sys > try: > r=urllib2.urlopen("http://un-know-n.com/") > except URLError,e: > print str(e) > sys.exit(1) > > print r.info() > > > But got the errors: > > Traceback (most recent call last): > File "t1.py", line 4, in ? > except URLError,e: > NameError: name 'URLError' is not defined > > > Why these is not the name of URLError? I saw it on this module's page: You need to define the urllib first. url=urllib2 try: r=urllib2.urlopen("http://un-know-n.com/") except url.URLError,e: print str(e) sys.exit(1) print r.info() You can't just launch into a catchable exception without first defining something. --Paul -- ------------------------------------------------------------. | Chisimba PHP5 Framework - http://avoir.uwc.ac.za | :------------------------------------------------------------: -------------- next part -------------- All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm From gherron at islandtraining.com Thu Apr 10 04:40:30 2008 From: gherron at islandtraining.com (Gary Herron) Date: Thu, 10 Apr 2008 01:40:30 -0700 Subject: urgent question, about filesystem-files In-Reply-To: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> References: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> Message-ID: <47FDD27E.1040204@islandtraining.com> bvidinli wrote: > i started python programming a few months ago. > > now i need the code to understand if a file already opened in > filesystem by another process ? > > i looked at docs, howtos, but did not find related info. > note that normal file open/write operations in python, i know it. > > i specificly need to know that "is a file already open by some other > process other than python". > > > Thank you in advance > This is certainly an operating-system dependent bit of functionality. So first off, you are going to have to tell us *which* OS you're working on. Then, perhaps someone can help... Gary Herron From martin at v.loewis.de Sun Apr 6 17:50:01 2008 From: martin at v.loewis.de (=?ISO-8859-2?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 06 Apr 2008 23:50:01 +0200 Subject: Form sha1.hexdigest to sha1.digest In-Reply-To: <1d73d457-d305-4c41-9063-5676303e5ba7@c19g2000prf.googlegroups.com> References: <7c39af89-9cee-428c-a0bc-8202700c5aec@b1g2000hsg.googlegroups.com> <47F8CF66.1020805@v.loewis.de> <47F930F8.7030406@v.loewis.de> <1d73d457-d305-4c41-9063-5676303e5ba7@c19g2000prf.googlegroups.com> Message-ID: <47f94589$0$11561$9b622d9e@news.freenet.de> >>> Or hexdigest_string.decode('hex') >> I would advise against this, as it's incompatible with Python 3. > > I didn't know that, you actually made me look it up in the Python 3 > FAQ. And yes, the difference is that decode will return bytes type > instead of a string. No. The decode method on string objects is removed, you can only *encode* strings, but not decode them. > This may or may not be a problem The problem is this: py> hashlib.sha1(b"Hallo").hexdigest().decode("hex") Traceback (most recent call last): File "", line 1, in AttributeError: 'str' object has no attribute 'decode' Regards, Martin From arnodel at googlemail.com Thu Apr 24 04:53:19 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 24 Apr 2008 09:53:19 +0100 Subject: @classmethod question References: Message-ID: Scott SA writes: A side note > class RecipieClass: Recipe is a more widespread spelling, I believe. Moreover it is the convention in python that only class names are capitalized, so you don't need to append a 'Class'. class Recipe: ... clafoutis = Recipe('eggs', 'spam') -- Arnaud From maehhheeyy at gmail.com Tue Apr 29 18:02:10 2008 From: maehhheeyy at gmail.com (maehhheeyy) Date: Tue, 29 Apr 2008 15:02:10 -0700 (PDT) Subject: timeout Message-ID: <1a9b19bf-5075-4bce-812d-5516d3a4e454@b9g2000prh.googlegroups.com> Hi, I was just wondering if there was such thing as a timeout module. From tjreedy at udel.edu Tue Apr 8 00:35:30 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 8 Apr 2008 00:35:30 -0400 Subject: guide through python interpreter source code References: Message-ID: "Avi Kohn" wrote in message news:VvGdnQCSZv_yfmfanZ2dnUVZ_viunZ2d at earthlink.com... | Are there documents,books, articles that can introduce me to the python | source code base ? This has been asked before. The general answer has been to look at the code. Perhaps you can find some of the more specific answers at groups.google.com. From deets at nospam.web.de Sat Apr 19 12:38:10 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Sat, 19 Apr 2008 18:38:10 +0200 Subject: urlretrieve can't send headers In-Reply-To: References: Message-ID: <66ulg4F2lidl3U1@mid.uni-berlin.de> triplezone3 schrieb: > Hello. I'm using urllib.urlretrieve to download files, > because it provides a handy hook function. > Unfortunately, it won't let me send headers, which > could be quite useful. Is there any way I could do > this? I suggest you look into urllib2. It allows you to explicitly create an request-object that you can stuff with headers and parameters and what you like. diez From cyberco at gmail.com Tue Apr 15 17:45:39 2008 From: cyberco at gmail.com (Berco Beute) Date: Tue, 15 Apr 2008 14:45:39 -0700 (PDT) Subject: webcam (usb) access under Ubuntu References: <66jlk1F2ju6c8U1@mid.uni-berlin.de> <66kkedF2l526dU2@mid.uni-berlin.de> Message-ID: <455760fb-8229-4be3-ba7f-7c41bdcd66de@a22g2000hsc.googlegroups.com> On Apr 15, 11:18 pm, "Diez B. Roggisch" wrote: > Berco Beute schrieb: > > > Thanks, that would be great. > > Here you go. > > http://roggisch.de/vidio.tgz > > Diez Wonderful! Thank you very much! I'm running out of time, but after installing the necessary goodies using the nice package from here: http://aruiz.typepad.com/siliconisland/2006/12/allinone_win32_.html In the meantime I've switched to windows. I'm running into the problem that 'import gst' throws: =========================== >>> import gst Traceback (most recent call last): File "", line 1, in File "H:\Python25\lib\site-packages\gst-0.10\gst\__init__.py", line 87, in from _gst import * ImportError: DLL load failed: The specified module could not be found. =========================== I've tried reinstalling gstreamer (for windows): http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstreamer-0.10.17.setup.zip http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstreamer-0.10.17.win32.zip but that didn't help. I get some complaints about 'libgstinterfaces' as well... I'm too unfamiliar with these libraries to have a clue what's wrong here... I'll look into it some more tomorrow. 2B From robin at nibor.org Tue Apr 15 15:35:45 2008 From: robin at nibor.org (Robin Stocker) Date: Tue, 15 Apr 2008 21:35:45 +0200 Subject: Recurring patterns: Am I missing it, or can we get these added to the language? In-Reply-To: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: <48050391.9030506@nibor.org> Erich schrieb: > This is like split() but returns a list of exactly lenght n. This is > very useful when using unpacking, e.g.: > x, y = nsplit('foo,bar,baz', ',', 2) You could use the second argument of split: x, y = 'foo,bar,baz'.split(',', 1) Note that the number has the meaning "only split n times" as opposed to "split into n parts". Cheers, Robin From juergen.perlinger at t-online.de Sun Apr 20 16:06:38 2008 From: juergen.perlinger at t-online.de (Juergen Perlinger) Date: Sun, 20 Apr 2008 22:06:38 +0200 Subject: What happened with python? messed strings? References: Message-ID: Juergen Perlinger wrote: > algaba at droog.sdf-eu.org wrote: > [snip] > Basically you're not using ASCII encoding in your source text... You need > to define an encoding for your source if you're using german umlauts or > other fancy stuff. > > See chapter 2.1.4 of the reference manual, and add e.g. > > # -*- coding: utf-8 -*- > > as first or second line to your script. Make sure your editor talks utf-8, > or use the encoding used by your editor. cp1552 is a good choice for > windows... > stupid me. cp1252, of course. -- juergen 'pearly' perlinger "It's hard to make new errors!" From jgardner at jonathangardner.net Thu Apr 24 13:12:59 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Thu, 24 Apr 2008 10:12:59 -0700 (PDT) Subject: function that accepts any amount of arguments? References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> <4810724a$0$23390$426a74cc@news.free.fr> <63ac69bf-9f6d-42bd-8e6e-5b3b17ec7c69@z72g2000hsb.googlegroups.com> Message-ID: <933e4c97-11c8-43b0-81e0-c78ff8573792@26g2000hsk.googlegroups.com> On Apr 24, 5:28?am, malkarouri wrote: > > What's wrong with raising ZeroDivisionError (not stopping the > exception in the first place)? > Because when I use your module, call avg (or mean) without args, I should see an error that says, "Hey, you have to pass at least one value in!" ZeroDivisonError doesn't mean that. It means I tried to divide by zero. Naively, I don't see where I was dividing by zero (because I don't remember how to calculate the mean---that's what your code was for.) ValueError does mean that I didn't pass the right kind of arguments in. ValueError("No items specified") would be even clearer. (Or maybe TypeError?) In general, any exception thrown should be meaningful to the code you are throwing it to. That means they aren't familiar with how your code works. From pavlovevidence at gmail.com Sun Apr 6 22:23:20 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Sun, 6 Apr 2008 19:23:20 -0700 (PDT) Subject: sine in python References: Message-ID: On Apr 6, 5:10 pm, Mark Wooding wrote: > Astan Chee wrote: > > I have a math function that looks like this > > sin (Theta) = 5/6 > > How do I find Theta (in degrees) in python? > > import math > theta = math.asin(5/6) * 180/math.pi Careful there, bud. 5/6 might not give you the value you're expecting it to, depending on the version of Python you're using. If you're on Python 2.x, you'll want to use "from __future__ import division", or to specify 5 and 6 as floats, i.e., 5.0/6.0. (And people claim 5/6 == 0 is the "obvious" result....) Carl Banks From dickinsm at gmail.com Fri Apr 11 14:05:00 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Fri, 11 Apr 2008 11:05:00 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <31872ffc-5bc4-44c8-961d-ee4f0dc356c5@k1g2000prb.googlegroups.com> <700b1a5f-0af0-466e-abda-4d8dc784dbaa@e67g2000hsa.googlegroups.com> <220fa9fa-3ad3-4d58-b90c-478f936b5352@m1g2000pre.googlegroups.com> <6d63626e-8868-46e7-9a69-0ed870751263@m3g2000hsc.googlegroups.com> Message-ID: <7df84537-d50e-4cb7-b72f-c7a4fb5a006f@u69g2000hse.googlegroups.com> On Apr 11, 10:29 am, hdante wrote: > Strangely, a "faster" version is: > > def fast_round(x): > if x % 1 != 0.5: return round(x) > return 2.0*round(x/2.0) You should be a little bit careful with the test x%1 == 0.5 if x might be negative: >>> x = -0.5 + 2**-54 >>> x # not an exact half... -0.49999999999999994 >>> x % 1 # ... and yet x%1 == 0.5 0.5 But for x positive, it should be safe. And for this particular application, it turns out that it doesn't matter: it gives the right result for this input anyway. Mark From skanemupp at yahoo.se Fri Apr 18 15:06:00 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 18 Apr 2008 12:06:00 -0700 (PDT) Subject: Easiest way to get started with WebApps? Message-ID: <3c43f29c-3e51-48ab-be02-47402ccd1bfd@b64g2000hsa.googlegroups.com> which is the easiest module to use to just get started with webapps quicklya nd starting getting things up and running, not advanced stuff just basic. From bearophileHUGS at lycos.com Tue Apr 8 12:54:56 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Tue, 8 Apr 2008 09:54:56 -0700 (PDT) Subject: Data structure recommendation? References: Message-ID: <1adc3541-7775-4938-bd5a-953dd041656c@2g2000hsn.googlegroups.com> Jochen Schulz: > This solution may be more than you actually need, but I implemented two > metric space indexes which would do what you want (and I wanted to plug > it anyway :)): Please plug such good things. It seems the Python community is an endless source of interesting modules I didn't know about. Your (single) module looks very nice. I'll take a better look later. Few notes: Use xrange instead of range, for Psyco they are often the same, but if you don't have Psyco the range may be slower and usually requires more memory. Java is faster than Python, but if you have some care and you know how things are implemented in Python, you can often write ""fast"" Python code. In the levenshtein function you have this: for i in range(1, m+1): prev, cur = cur, [i] + [0]*n You can speed up that levenshtein, using nearly constant (heap) memory, avoiding that re-creation of prev and cur (see below for D code you can back-translate to Python). You can translate this module to D (I may even do it myself, or I may help you do it), this has several advantages: - If you are careful it may become (quite) faster than your Java version. - The resulting code may be probably as long as the Python one, or not too much longer (but it may have or not have some extra limitations. D is flexible but it's a statically typed language, unlike Python); - Coding in D may be similar enough to Java coding for you, quite differently from coding it in C; - You can then use Pyd (http://pyd.dsource.org ) to create in a very simple way a single compiled module with the functions/classes that can be called by python (no intermediate python needed). Using Pyd is quite simpler than using C + Swig or writing a C module for Python. Later you can release the D code plus the already compiled module for Win too. - Disadvantages: you don't know D, you don't know how to use Pyd, and most people out there may prefer to maintain/modify C code, even if it's 3/4 times longer than the D code. - The following is to show you an example of D code (that uses my D libs for few bits, like that range(), the min(), but it's not too much difficult to avoid using them) that you may compare to the Python one. Note that this code is generic (it's a function template), and it takes as input any array, that means Unicode Strings too (utf8, 16 bit too, 32 bit too), it runs about 105-125 times faster than a quite similar Python version (Psyco is able to speed up this Python code about 20-25 times, so this is 4-5 times faster than Psyco): int editDistance(T)(T[] s1, T[] s2) { if (len(s1) > len(s2)) { auto sa = s1; s1 = s2; s2 = sa; } auto r1 = range(len(s2) + 1); auto r2 = new int[len(r1)]; foreach (i, c1; s1) { r2[0] = i + 1; foreach (j, c2; s2) r2[j+1] = c1 == c2 ? r1[j] : min(r2[j], r1[j], r1[j+1]) + 1; auto ra = r1; r1 = r2; r2 = ra; // swap lines } return r1[$ - 1]; } If you have questions feel free to ask :-) Bye, bearophile From Robert.Bossy at jouy.inra.fr Fri Apr 25 09:00:43 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Fri, 25 Apr 2008 15:00:43 +0200 Subject: multiple pattern regular expression In-Reply-To: References: Message-ID: <4811D5FB.8040109@jouy.inra.fr> Arnaud Delobelle wrote: > micron_make writes: > > >> I am trying to parse a file whose contents are : >> >> parameter=current >> max=5A >> min=2A >> >> for a single line I used >> for line in file: >> print re.search("parameter\s*=\s*(.*)",line).groups() >> >> is there a way to match multiple patterns using regex and return a >> dictionary. What I am looking for is (pseudo code) >> >> for line in file: >> re.search("pattern1" OR "pattern2" OR ..,line) >> >> and the result should be {pattern1:match, pattern2:match...} >> >> Also should I be using regex at all here ? >> > > If every line of the file is of the form name=value, then regexps are > indeed not needed. You could do something like that. > > params = {} > for line in file: > name, value = line.strip().split('=', 2) > params[name] = value > > (untested) I might add before you stumble upon the consequences: params[name.rstrip()] = value.lstrip() Cheers, RB From duncan.booth at invalid.invalid Wed Apr 9 08:56:32 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 9 Apr 2008 12:56:32 GMT Subject: Google App Engine References: <47fc2c7c$0$36365$742ec2ed@news.sonic.net> <7e43fcd9-6207-4af2-8256-c0099a8ce0bb@1g2000prf.googlegroups.com> Message-ID: Duncan Booth wrote: > If you use authentication then again you are tied to Google accounts (or > Google Apps accounts). For a public application that would also block > attempts to move to another platform. Correcting myself: according to http://code.google.com/p/googleappengine/issues/detail?id=17 is is possible to use OpenID, it just isn't there by default. From bdsatish at gmail.com Fri Apr 11 08:33:53 2008 From: bdsatish at gmail.com (bdsatish) Date: Fri, 11 Apr 2008 05:33:53 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: HI Gerard, I think you've taken it to the best possible implementation. Thanks ! On Apr 11, 5:14 pm, Gerard Flanagan wrote: > In fact you can avoid the call to the builtin round: > > ------------------------------------------------ > def myround(x): > n = int(x) > if abs(x - n) >= 0.5 and n % 2: > return n + 1 - 2 * int(n<0) > else: > return n > > assert myround(3.2) == 3 > assert myround(3.6) == 4 > assert myround(3.5) == 4 > assert myround(2.5) == 2 > assert myround(-0.5) == 0.0 > assert myround(-1.5) == -2.0 > assert myround(-1.3) == -1.0 > assert myround(-1.8) == -2 > assert myround(-2.5) == -2.0 > ------------------------------------------------ From musiccomposition at gmail.com Wed Apr 9 22:35:18 2008 From: musiccomposition at gmail.com (Benjamin) Date: Wed, 9 Apr 2008 19:35:18 -0700 (PDT) Subject: How is GUI programming in Python? References: Message-ID: On Apr 9, 8:54 pm, Chris Stewart wrote: > I've always had an interest in Python and would like to dabble in it > further. I've worked on a few very small command line programs but > nothing of any complexity. I'd like to build a really simple GUI app > that will work across Mac, Windows, and Linux. How painful is that > going to be? I used to be really familiar with Java Swing a few years > ago. I imagine it will be similar. Since it's Python, it will be a lot less painless than anything else. :) > > Next, what would you say is the best framework I should look into? > I'm curious to hear opinions on that. Tkinter is the easiest for little apps, but when I'm doing anything for real, I use PyQt. > > Chris Stewart > cstewart... at gmail.com From deets at nospam.web.de Tue Apr 22 15:34:24 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 21:34:24 +0200 Subject: Spawing a thread and printing dots until it finishes In-Reply-To: References: Message-ID: <676sukF2nc0tuU1@mid.uni-berlin.de> Larry Bates schrieb: > sophie_newbie wrote: >> On Apr 22, 4:41 pm, "D'Arcy J.M. Cain" wrote: >>> On Tue, 22 Apr 2008 07:10:07 -0700 (PDT) >>> >>> >>> >>> sophie_newbie wrote: >>>> import threading >>>> class MyThread ( threading.Thread ): >>>> def run ( self ): >>>> myLongCommand()... >>>> import time >>>> t = MyThread() >>>> t.start() >>>> while t.isAlive(): >>>> print "." >>>> time.sleep(.5) >>>> print "OK" >>>> The thing is this doesn't print a dot every half second. It just >>>> pauses for ages until the thread is finished and prints prints ".OK". >>>> But if I take out the "time.sleep(.5)" line it will keep printing dots >>>> really fast until the thread is finished. So it looks like its the >>>> time.sleep(.5) bit that is messing this up somehow? >>> We know that your main routine gives up the processor but without a >>> full definition of MyThread how do we know that it ever does? I >>> suspect that it hits sleep once, if at all, and then goes to the final >>> print statement. In fact, I suspect that this is not exactly what you >>> tried anyway. This code would not have printed ".OK" whether it >>> entered the loop or not. It could have printed this; >>> >>> . >>> OK >>> >>> because the print statement in the loop will print a dot on a line by >>> itself. >>> >>> When looking for these sorts of answers you should really try to create >>> a smallest program that exhibits the behaviour you are questioning and >>> then cut and paste the entire script into your message unedited. Often >>> enough you will even answer your own question in the process. >>> >>> -- >>> D'Arcy J.M. Cain | Democracy is three >>> wolveshttp://www.druid.net/darcy/ | and a sheep voting on >>> +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. >> >> "myLongCommand()... " is a call to an function in R (the statistical >> programming language) via Rpy (A python module that allows calls to >> R). The call takes a couple of minutes to execute. I'm trying to build >> a web front end to this R function and instead of the user looking at >> a blank screen for 2-3 mins, I want to print dots to let them feel >> like the program isn't hanging. >> >> What I am saying is that without the "time.sleep(.5)" line, the above >> code will print dots on the screen continuously for 2-3 mins, filling >> it up with a ridiculous ammount of dots. >> >> Whereas with the time.sleep line, instead of pausing for half a second >> between dots, its seems to print, as you correctly pointed out: >> >> . >> OK >> >> With a pause of 2-3 minutes between the . and the OK. >> >> I hope that clears things up a little. I haven't the faintest idea why >> the code above doesn't work but hope someone has an idea. It wouldn't >> be something to do with python not being able to handle multiple >> threads at the same time or something? I hope there is a workaround. > > For a web front end you wouldn't go this route at all. You would get a > progressive .GIF file that gets loaded into the client's browser and shows > "activity" while the server does its thing. When the browser refreshes > (after the server application completes) it would go away. You can't > update a client's browser by writing dots to anything. Yes and no. You are right of course that the dot-thread is not working that way. But if you replace the dot-thread with the http-request-thread, the question remains: why is it blocking? Your approach doesn't tackle that. If nothing else helps, a subprocess must be spawned. Diez From kyosohma at gmail.com Tue Apr 15 15:30:49 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 15 Apr 2008 12:30:49 -0700 (PDT) Subject: Recurring patterns: Am I missing it, or can we get these added to the language? References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: <8674324c-676e-4524-aa7d-bffccbf6a550@b1g2000hsg.googlegroups.com> On Apr 15, 1:51 pm, Erich wrote: > Hello all, > > Today I found myself once again defining two functions that I use all > the time: nsplit and iterable. These little helper functions of mine > get used all the time when I work. Im sick of having to define them > (but am very good at it these days, less than 1 typo per function!). > It leads me to the following questions > > 1. Is this functionality already built in and im just missing it > 2. Is there some well known, good technique for these that I missed? > 3. Insert question I need to ask here (with a response) > > These are the funtions w/ explaination: > > def nsplit(s,p,n): > n -= 1 > l = s.split(p, n) > if len(l) < n: > l.extend([''] * (n - len(l))) > return l > > This is like split() but returns a list of exactly lenght n. This is > very useful when using unpacking, e.g.: > x, y = nsplit('foo,bar,baz', ',', 2) > > def iterable(item, count_str=False): > if not count_str and isinstance(item, str): > return False > try: > iter(item) > except: > return False > return True > This is just simple boolean test for whether or not an object is > iterable. I would like to see this in builtins, to mirror callable. > The optional count_str adds flexibility for string handling, since > sometimes I need to iterate over a string, but usually not. I > frequently use it to simplify my case handling in this type of > costruct: Just found this thread on the subject: http://mail.python.org/pipermail/python-list/2006-July/394487.html That might answer your question. > > def foo(bar): > bar = bar if iterable(bar) else [bar] > for x in bar: > .... > > Thanks for feeback, > Erich Mike From fredrik at pythonware.com Fri Apr 4 17:06:32 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 04 Apr 2008 23:06:32 +0200 Subject: Is there any way to say ignore case with "in"? In-Reply-To: <47f692f3$0$759$bed64819@news.gradwell.net> References: <47f692f3$0$759$bed64819@news.gradwell.net> Message-ID: tinnews at isbd.co.uk wrote: > Is there any way in python to say > > if string1 in string2: > > > ignoring the case of string1 and string2? if string1.lower() in string2.lower(): ... (there's no case-insensitive version of the "in" operator in stock Python) From wilk at flibuste.net Tue Apr 8 11:55:19 2008 From: wilk at flibuste.net (William Dode) Date: Tue, 8 Apr 2008 15:55:19 +0000 (UTC) Subject: Google App Engine References: Message-ID: On 08-04-2008, Duncan Booth wrote: > Google have announced a new service called 'Google App Engine' which may > be of interest to some of the people here (although if you want to sign > up you'll have to join the queue behind me): > > From the introduction: > >> What Is Google App Engine? ... It's also interesting to see that we can find django, webob and pyyaml in their sdk (license apache 2) -- William Dod? - http://flibuste.net Informaticien ind?pendant From goldtech at worldpost.com Wed Apr 9 09:15:02 2008 From: goldtech at worldpost.com (goldtech) Date: Wed, 9 Apr 2008 06:15:02 -0700 (PDT) Subject: String manipulation questions Message-ID: <8cd7b477-6fc6-47c5-b2eb-e2a4f284f7b2@m3g2000hsc.googlegroups.com> Hi, Replacing strings in a text (likely an XML) file. Some newbie questions... ... while line: counter=counter+1 if line.find(newstring) != -1: print 'match at line'+str(counter) newline = line.replace(oldstring, newstring) fileOUT.write(newline) line=fileIN.readline() .... Question1: The replace method - If a string does not have the target replacement "newstring", then newline equals oldstring? Ie. oldstring is not changed in any way? Seems to be what I observe but just want to confirm this. Question2: I'm using "line.find(newstring) != -1..." because I want to print when a replacement happens. Does "line.replace..." report indirectly somehow when it replaces? Thanks P.S. I know I should be using XSLT to transform XML - but the above seems to work for small text changes. From v.harishankar at gmail.com Tue Apr 22 09:22:29 2008 From: v.harishankar at gmail.com (Harishankar) Date: Tue, 22 Apr 2008 18:52:29 +0530 Subject: subprocess module is sorely deficient? In-Reply-To: <621dbfa0-8c3c-4ce4-80e7-cf0840c4b82f@p25g2000hsf.googlegroups.com> References: <621dbfa0-8c3c-4ce4-80e7-cf0840c4b82f@p25g2000hsf.googlegroups.com> Message-ID: <200804221852.29221.v.harishankar@gmail.com> On Tuesday 22 Apr 2008 17:54:00 Nicola Musatti wrote: > I suggest you check out this: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554 > > Cheers, > Nicola Musatti > -- > http://mail.python.org/mailman/listinfo/python-list An interesting solution. Thanks a lot for the link. -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org From pierre-yves.dupont at pibioinfo.com Fri Apr 4 11:51:52 2008 From: pierre-yves.dupont at pibioinfo.com (pierre-yves.dupont at pibioinfo.com) Date: Fri, 04 Apr 2008 17:51:52 +0200 Subject: UML reverse engineering Message-ID: <6712345.1824821207324312295.JavaMail.servlet@kundenserver> Hello, Do you know a free software witch can compute a UML class diagram from a python code. I tested many free UML softwares like BoUML, ArgoUML, Dia, PNSource (not found), UMLet and others ... But I didn't found what I needed. -- Pierre-Yves Dupont -------------- next part -------------- An HTML attachment was scrubbed... URL: From gagsl-py2 at yahoo.com.ar Sun Apr 13 16:03:04 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 13 Apr 2008 17:03:04 -0300 Subject: py2exe, program has stoped working!? References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> Message-ID: En Sun, 13 Apr 2008 10:52:06 -0300, escribi?: > so i used py2exe and i have the build and the dist-folders. > > and when im distributing my program i have to include both catalogues > right? You only have to distribute the contents of the "dist" directory. (I have no idea what the message error means) -- Gabriel Genellina From sawilla at gmail.com Mon Apr 21 19:15:15 2008 From: sawilla at gmail.com (sawilla) Date: Mon, 21 Apr 2008 16:15:15 -0700 (PDT) Subject: module error in Vista -- works as administrator References: <815eb7f8-6f00-469d-bb15-e1d9680d9646@e39g2000hsf.googlegroups.com> <480d0a52$1@news.mel.dft.com.au> Message-ID: <72da4abc-57b1-47ca-bed4-48b7244d6407@e39g2000hsf.googlegroups.com> On Apr 21, 5:42 pm, John Machin wrote: > Log on as administrator, start python in command window and do this: > > import sys > sys.path # shows where python is looking for importables > import numpy > import os.path > print os.path.abspath(numpy.__file__) # shows where it found numpy > > Log on as ordinary user, start python in command window and do this: > > import sys > sys.path > # check how this is different from the admin's sys.path > > If you can't see what to do after that, come back here with the output > from those steps. > > HTH, > John That was a great help, thank you. I now see what is causing the problem but I don't know how to fix it. I used easy_install to install several packages. When I run Python from an administrator command window all of the directories in C:\Program Files\Python25\Lib\site- packages\easy-install.pth are added to the sys.path. When I run it as a regular user, those directories are not added to the sys.path and so Python can't find the modules. I know how to manually add those directories to Python's search path but then I'll need to update the path every time I install something. How do I get Python to automatically load the easy-install.pth file for the regular user account? Reg From torriem at gmail.com Tue Apr 15 12:58:01 2008 From: torriem at gmail.com (Michael Torrie) Date: Tue, 15 Apr 2008 10:58:01 -0600 Subject: py3k s***s In-Reply-To: <0A685715-6D44-4D41-87C2-4B971A751E78@gmail.com> References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <0A685715-6D44-4D41-87C2-4B971A751E78@gmail.com> Message-ID: <4804DE99.5020200@gmail.com> Chris McAloney wrote: > *Have* you tried the 2to3 tool? It might help to lessen your > concerns a bit. Yes, Python 3 is different from 2.x, but we've known > that it was going to be for years and, as has already been pointed > out, the devs are being very careful to minimize the pain that the > changes will inflict on Python programmers, with tools such as 2to3. After parsing this thread through a noise filter, it appears the main concern is not the converting of _python code_ from 2 to 3, but rather converting extensions written in C, or when python is embedded in a C program. The APIs have necessarily changed, and this *will* inflict a certain amount of pain and suffering on the developer, especially if he needs to maintain code for both python 2 and python 3. However this is just the way it is. It's a bit like complaining that I have to rewrite my app with win32 calls and paradigms when I was used to win16. No conversion will be completely pain free, but this jump is pretty insignificant compared to others in the industry. I think the original poster is being somewhat unreasonable, though. No one is going to force him to 3. If his end users demand it, and he's selling them software, then he'll do it or else go out of business. If it's OSS, he'll either do it, or someone else will fork it and take it forward. From bvidinli at gmail.com Thu Apr 10 05:04:06 2008 From: bvidinli at gmail.com (bvidinli) Date: Thu, 10 Apr 2008 12:04:06 +0300 Subject: urgent question, about filesystem-files In-Reply-To: <36e8a7020804100201x5cf16377gfedddc8647fe8e3a@mail.gmail.com> References: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> <47FDD27E.1040204@islandtraining.com> <36e8a7020804100200m6c3a9a41h1ed3021b70f8a829@mail.gmail.com> <36e8a7020804100201x5cf16377gfedddc8647fe8e3a@mail.gmail.com> Message-ID: <36e8a7020804100204k3a3eb471w2e9b093086a8a9e3@mail.gmail.com> The need/reason for this, i write a program that should perform some operation on files, only if the file is not being used.... this is for ensuring that file is not in use, ... by any process in system.... 10.04.2008 tarihinde bvidinli yazm??: > Sory for lack of information, > > i use linux/unix > i need to solve this for linux/unix > > i tested os.open with O_EXCL flag, and some other things, that did not solve. > > i need exacly: say example file testfile, > > check if testfile already open by some other process in linux, > > > tahnks. > 2008/4/10, Gary Herron : > > > > bvidinli wrote: > > > > > i started python programming a few months ago. > > > > > > now i need the code to understand if a file already opened in > > > filesystem by another process ? > > > > > > i looked at docs, howtos, but did not find related info. > > > note that normal file open/write operations in python, i know it. > > > > > > i specificly need to know that "is a file already open by some other > > > process other than python". > > > > > > > > > > Thank you in advance > > > > > > > > > > This is certainly an operating-system dependent bit of functionality. So > > first off, you are going to have to tell us *which* OS you're working on. > > Then, perhaps someone can help... > > > > Gary Herron > > > > > > > > -- > ?.Bahattin Vidinli > Elk-Elektronik M?h. > ------------------- > iletisim bilgileri (Tercih sirasina gore): > skype: bvidinli (sesli gorusme icin, www.skype.com) > msn: bvidinli at iyibirisi.com > yahoo: bvidinli > > +90.532.7990607 > +90.505.5667711 > > > -- > ?.Bahattin Vidinli > Elk-Elektronik M?h. > ------------------- > iletisim bilgileri (Tercih sirasina gore): > skype: bvidinli (sesli gorusme icin, www.skype.com) > msn: bvidinli at iyibirisi.com > yahoo: bvidinli > > +90.532.7990607 > +90.505.5667711 > -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From pDOTpagel at helmholtz-muenchen.de Wed Apr 23 06:47:01 2008 From: pDOTpagel at helmholtz-muenchen.de (Philipp Pagel) Date: Wed, 23 Apr 2008 10:47:01 +0000 (UTC) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: azrael wrote: > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. There is only one sane way to deal with this situation: You need a common enemy. Java comes to mind ;-) cu Philipp -- Dr. Philipp Pagel Lehrstuhl f. Genomorientierte Bioinformatik Technische Universit?t M?nchen http://mips.gsf.de/staff/pagel From rasmussen.bryan at gmail.com Thu Apr 24 17:11:57 2008 From: rasmussen.bryan at gmail.com (bryan rasmussen) Date: Thu, 24 Apr 2008 23:11:57 +0200 Subject: convert xhtml back to html In-Reply-To: <4810E5CC.2000503@behnel.de> References: <4810E5CC.2000503@behnel.de> Message-ID: <3bb44c6e0804241411u1c45b420r309a02500a81fc01@mail.gmail.com> wow, that's pretty nice there. Just to know: what's the performance like on XML instances of 1 GB? Cheers, Bryan Rasmussen On Thu, Apr 24, 2008 at 9:55 PM, Stefan Behnel wrote: > Tim Arnold wrote: > > hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop to > > create CHM files. That application really hates xhtml, so I need to convert > > self-ending tags (e.g.
) to plain html (e.g.
). > > This should do the job in lxml 2.x: > > from lxml import etree > > tree = etree.parse("thefile.xhtml") > tree.write("thefile.html", method="html") > > http://codespeak.net/lxml > > Stefan > > > -- > http://mail.python.org/mailman/listinfo/python-list > From george.sakkis at gmail.com Fri Apr 11 14:31:37 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 11 Apr 2008 11:31:37 -0700 (PDT) Subject: Graphs in Python References: Message-ID: <4043676a-3a9b-4f49-8a64-7afd78ee480c@a23g2000hsc.googlegroups.com> On Apr 10, 1:05?pm, Sanhita Mallick wrote: > Hi. > > I am a newbie to Python. I am trying to implement a > Python code for graph manipulation. My graphs are > about 200-500 nodes big. Excepting for the short basic > graph implementation info on Python.org, where can I > find more in depth info about how to express graphs in > python, and how to use them in a ?code? > > Also, does anyone know of a easy way of creating the > dictionary for python for a 500-node graph, without > typing each and every node? I found some application > that recognize dot file Graphviz - but I am looking > for a program that can let me "draw" a graph and then > generate the lists automatically from the drawing. > > Thanks. > -SM A pure python package such as those mentioned in other replies is most likely fine for graphs of several hundreds nodes, but in case performance matters, you can take a look at the Python bindings of the Boost graph library [1]. George [1] http://www.osl.iu.edu/~dgregor/bgl-python/ From jergosh at wp.pl Tue Apr 8 17:25:31 2008 From: jergosh at wp.pl (=?UTF-8?B?R3J6ZWdvcnogU8WCb2Rrb3dpY3o=?=) Date: Tue, 08 Apr 2008 23:25:31 +0200 Subject: Python 3.0 new integer division In-Reply-To: References: Message-ID: <47FBE2CB.5030102@wp.pl> > If you want precision with fractions, you should be using the Decimal > type, which uses a rational. A rational, if you recall from your math > classes, is one integer divided by another. > Isn't Decimal a BCD implementation? From llothar at web.de Fri Apr 4 22:43:12 2008 From: llothar at web.de (llothar) Date: Fri, 4 Apr 2008 19:43:12 -0700 (PDT) Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> Message-ID: Thanks, my question was not how can i make python to it find. I don't have a problem. My question was: Why does setup.py generated sometimes a pyd and sometimes a so file? There must be a rule behind this. Unforunately setup.py is not well documented. Here i mean i need a specification not a tutorial, because i want to know something not do something. Don't ask why i need to know: I need to know. And maybe somebody here can drop a line before i have to dig around in the source code. From fredrik at pythonware.com Fri Apr 4 16:41:04 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 04 Apr 2008 22:41:04 +0200 Subject: Self in Interactive Interpreter In-Reply-To: References: Message-ID: kj7ny wrote: > For years it has been a slight annoyance that every time I wanted to > test a snippet of code from a class by running it in the interactive > interpreter, I had to remove all of the self. instances from the > code. After I got it working correctly, I had to put all the self.'s > back into the code to put it back into my class. wouldn't it be a lot easier to test your code by importing the module containing it into the interactive interpreter? >>>> class dummy: >>>> def __init__(self): >>>> pass or, shorter: >>> class dummy: pass From gagsl-py2 at yahoo.com.ar Wed Apr 9 01:18:17 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 02:18:17 -0300 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> Message-ID: 2008/4/8, subhabrata.iisc at hotmail.com : >> I am using Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v. >> 1310 32 bit (Intel)] on win32 with IDLE 1.2.1 >> My O/S is Windows XP SP2 I use 512 MB RAM. En Tue, 08 Apr 2008 06:02:00 -0300, Vladimir Kropylev escribi?: > yes, ths is known problem. I can just recomend you to use Linux or > FreeBSD, though cygwin maybe also possible Disregard that comment. -- Gabriel Genellina From steve at holdenweb.com Sat Apr 12 17:58:22 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 17:58:22 -0400 Subject: Tremendous slowdown due to garbage collection In-Reply-To: <32e2acc1-97cb-4911-bb0c-67965b5ff113@2g2000hsn.googlegroups.com> References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> <32e2acc1-97cb-4911-bb0c-67965b5ff113@2g2000hsn.googlegroups.com> Message-ID: andreas.eisele at gmail.com wrote: >> Martin said that the default settings for the cyclic gc works for most >> people. > > I agree. > >> Your test case has found a pathologic corner case which is *not* >> typical for common application but typical for an artificial benchmark. > > I agree that my "corner" is not typical, but I strongly disagree with > the classification as pathological. The only feature of my test case > that is not typical is the huge number of distinct objects that are > allocated. I admit that 1E7 objects is today still fairly untypical, > but there is nothing pathological about it, it is just bigger. I is > about as pathological as a file size >2G, which a few years ago seemed > so outrageous that no OS bothered to support it, but is fairly common > nowadays, so that a lack of support would appear as an arbitrary and > unmotivated limitation nowadays. We all enjoy seeing Python adopted on > a large scale and used by a broad community, so we should not accept > arbitrary size limits. You could call a string with more than 2GB > pathological, but I very much appreciate the fact that Python supports > such strings for the few cases where they are needed (on a 64 bit > architecture). Now a O(N*N) effort for large numbers of objects isn't > such a hard limit, but in practice boils down to the same effect, that > people cannot use Python in such circumstances. I would prefer it very > much if such "soft limits" could be avoided as well. > > Given there is a fairly simple workaround (thanks again to Amaury!), > the issue is not urgent, but I still think it is important in the long > run. > >> Python is optimized for regular apps, not for benchmark (like some video >> drivers). >> > > I still think it would be worthwhile to support very large numbers of > objects in a way that they can just be used, without knowledge of > special tricks, and I would be fairly optimistic that those who have > designed the current GC schemes could generalize them slightly so that > these marginal cases will work better without imposing a penalty on > the more typical cases. > I believe you are making surmises outside your range of competence there. While your faith in the developers is touching, the garbage collection scheme is something that has received a lot of attention with respect to performance under typical workloads over the years. By the way, the term "pathological" (which I believe I also used about your application) doesn't imply anything bad about your program: it's merely a shorthand way of saying that it triggers this undesirable behavior in a garbage collector that is mostly satisfactory for other purposes. >> By the way you shouldn't use range for large ranges of more than a >> thousand items. xrange() should be faster and it will definitely use >> much less memory - and memory Python 2.5 and older will never release >> again. I'm going to fix the issue for Python 2.6 and 3.0. >> > > Thanks for this hint, and for the work on the newer versions. This is > very much appreciated. > Anyway, I'm glad Amaury's workaround has solved your problem at least temporarily. Your type of workload may become more typical over time, but at the moment you are probably somewhat ahead of the mainstream here. If you know there can't be any recoverable cycles then you are probably better off just telling the garbage collector that you know better than it does. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From zillow10 at googlemail.com Thu Apr 3 18:27:47 2008 From: zillow10 at googlemail.com (zillow10 at googlemail.com) Date: Thu, 3 Apr 2008 15:27:47 -0700 (PDT) Subject: id functions of ints, floats and strings Message-ID: Hi all, I've been playing around with the identity function id() for different types of objects, and I think I understand its behaviour when it comes to objects like lists and tuples in which case an assignment r2 = r1 (r1 refers to an existing object) creates an alias r2 that refers to the same object as r1. In this case id(r1) == id(r2) (or, if you like: r1 is r2). However for r1, r2 assigned as follows: r1 = [1, 2, 3] and r2 = [1, 2, 3], (r1 is r2) is False, even if r1==r2, etc. ...this is all very well. Therefore, it seems that id(r) can be interpreted as the address of the object that 'r' refers to. My observations of its behaviour when comparing ints, floats and strings have raised some questions in my mind, though. Consider the following examples: ######################################################################### # (1) turns out to be true a = 10 b = 10 print a is b # (2) turns out to be false f = 10.0 g = 10.0 print f is g # behaviour when a list or tuple contains the same elements ("same" meaning same type and value): # define the following function, that checks if all the elements in an iterable object are equal: def areAllElementsEqual(iterable): return reduce(lambda x, y: x == y and x, iterable) != False # (3) checking if ids of all list elements are the same for different cases: a = 3*[1]; areAllElementsEqual([id(i) for i in a]) # True b = [1, 1, 1]; areAllElementsEqual([id(i) for i in b]) # True f = 3*[1.0]; areAllElementsEqual([id(i) for i in f]) # True g = [1.0, 1.0, 1.0]; areAllElementsEqual([id(i) for i in g]) # True g1 = [1.0, 1.0, 0.5+0.5]; areAllElementsEqual([id(i) for i in g1]) # False # (4) two equal floats defined inside a function body behave differently than case (1): def func(): f = 10.0 g = 10.0 return f is g print func() # True ###################################################### I didn't mention any examples with strings; they behaved like ints with respect to their id properties for all the cases I tried. While I have no particular qualms about the behaviour, I have the following questions: 1) Which of the above behaviours are reliable? For example, does a1 = a2 for ints and strings always imply that a1 is a2? 2) From the programmer's perspective, are ids of ints, floats and string of any practical significance at all (since these types are immutable)? 3) Does the behaviour of ids for lists and tuples of the same element (of type int, string and sometimes even float), imply that the tuple a = (1,) takes (nearly) the same storage space as a = 10000*(1,)? (What about a list, where elements can be changed at will?) Would appreciate your responses... AK From steve at holdenweb.com Sat Apr 12 17:44:23 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 17:44:23 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> Message-ID: <48012D37.50001@holdenweb.com> Victor Subervi wrote: > in line... > > On Fri, Apr 11, 2008 at 2:05 PM, Steve Holden > wrote: > > Victor Subervi wrote: > > I have worked on this many hours a day for two weeks. If there is an > > easier way to do it, just take a minute or two and point it out. Have > > you heard of the Law of Diminishing Returns? I have passed it > long ago. > > I no longer want to waste time trying to guess at what you are > trying to > > tell me. > > Victor > > > > On Fri, Apr 11, 2008 at 8:55 AM, Steve Holden > > > >> wrote: > Where you have > > content = col_fields[0][14].tostring() > pic = "tmp" + str(i) + ".jpg" > img = open(pic, "w") > img.write(content) > print '

' % pic > img.close() > > instead write > > print content > > > Like this, I presume? > Yes. You might need to use content.tostring() - I am not familiar with MySQL blobs. > img = open(pic, "w") > img.write(content) > print ' value="%s">' % pic > print content > # print '

\n' % pic > Does not work _at_all LOL. You will recall, also, that you once gave me > a line similar to the one commented out (but without writing then > opening the file). THAT did not work, either. So now do you see why I am > frustrated?? > > > > Then browse to the URL this program serves and you will see the image > (assuming you are still sending the image/jpeg content type). > > > Well, as I mentioned before, I am sending text/html because the page, > like almost all web pages, has a whole lot more content than just > images. Or, perhaps you are suggesting I build my pages in frames, and > have a frame for every image. Unsightly! > Dear Victor: If you cannot understand, after being told several times by different people, that pages with images in them are achieved by multiple HTTP requests, then there is little I can do to help you. > > Once you > can see the image, THEN you can write a page that refers to it. Until > you start serving the image (NOT pseudo-html with image data embedded in > it) nothing else will work. > > > My solution works just fine, thank you. It is inelegant. But it now > appears to me, and I dare say rather clearly, that this inelegance is > the fault of python itself. Perhaps this should be brought to Guido?s > attention. > Victor You can say it as clearly as you like, but if you say it too loudly you will make a laughing stock of yourself. You surely don't think that a language that supports Zope, TurboGears, Pylons and Django (to name but the first four that come to mind) is unsuitable for web programming? Please, do yourself a big favor and persist with this until you understand what you are doing wrong and how to serve dynamic images. It appears that the learning may be painful, but I guarantee it will be worthwhile. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From j.spies at hccnet.nl Mon Apr 7 16:31:20 2008 From: j.spies at hccnet.nl (Jaap Spies) Date: Mon, 07 Apr 2008 22:31:20 +0200 Subject: Mathematical Python Library In-Reply-To: References: Message-ID: <298b8$47fa8498$d4785a98$5420@cache1.tilbu1.nb.home.nl> Cameron Laird wrote: > In article , > Dennis Lee Bieber wrote: >> On Mon, 7 Apr 2008 09:05:57 -0700 (PDT), mc >> declaimed the following in comp.lang.python: >> >>> I'm looking for a library which can do mathematical stuff like >>> solving equations. Or calculation the nulls of a function and so on. >>> Does anyone know one? >>> >> Other than coding some serial/USB interface to an HP50g... >> >> Maybe SAGE? >> sympy? >> >> http://www.google.com/search?hl=en&q=python+computer+algebra+system&btnG=Google+Search > . > . > . > While there are in fact several possible approaches to symbolic mani- > pulation of "mathematical stuff" in Python, I STRONGLY recommend that > beginners in the area look into SAGE , > already mentioned above by Dennis. SAGE is life-altering software, for > those with a life focused on mathematics or related science or > engineering. +1 Jaap From hardcoded.software at gmail.com Fri Apr 25 11:23:12 2008 From: hardcoded.software at gmail.com (Virgil Dupras) Date: Fri, 25 Apr 2008 08:23:12 -0700 (PDT) Subject: Subclassing list the right way? References: Message-ID: <163ddc5c-cb17-416b-b85c-0a8945d490a9@e39g2000hsf.googlegroups.com> On Apr 25, 4:03?pm, Kirk Strauser wrote: > I want to subclass list so that each value in it is calculated at call > time. ?I had initially thought I could do that by defining my own > __getitem__, but 1) apparently that's deprecated (although I can't > find that; got a link?), and 2) it doesn't work. > > For example: > > >>> class Foo(list): > > ... ? ? def __getitem__(self, index): > ... ? ? ? ? ? ? return 5 > ...>>> a = Foo([1, 2, 3, 4, 5]) > >>> print a > [1, 2, 3, 4, 5] > >>> print a[2:4] > [3, 4] > >>> print a[3] > > 5 > > I first expected that to instead behave like: > > >>> print a > [5, 5, 5, 5, 5] > >>> print a[2:4] > > [5, 5] > > Is there a "right" way to do this? > -- > Kirk Strauser I'm not totally sure, but I think you have to implement __getslice__ as well, even if it is a deprecated magic function. My guess for this is that list implements __getslice__ and when you ask for a slice, Python checks for __getslice__ first, and then, if you don't have it, calls __getitem__. And since list has it, it's what is called. As for "print a", you have to override __str__ and __repr__ too. As a side note, the second argument to __getitem__ is not index, it's key, because this argument can either be an int index or a slice() object. From hobgoodoreneyhb at gmail.com Tue Apr 22 11:40:19 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:40:19 -0700 (PDT) Subject: cash organizer keygen Message-ID: cash organizer keygen http://cracks.12w.net F R E E C R A C K S From lbonafide at yahoo.com Mon Apr 14 09:59:43 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Mon, 14 Apr 2008 06:59:43 -0700 (PDT) Subject: How to make python run faster References: <0baa301a-ec8c-48ef-b30e-f9c80f72e5af@u12g2000prd.googlegroups.com> Message-ID: On Apr 14, 8:48 am, ??? wrote: > But, it is still not as fast as 1. So if speed is the #1 design goal, use pure C. If not, develop in pure Python and, if the application is too slow, profile the code and look for bottlenecks that can be optimized. There's a good chance that they can be resolved algorithmically, not by simply dropping down to C. From gagsl-py2 at yahoo.com.ar Wed Apr 30 05:56:38 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 30 Apr 2008 06:56:38 -0300 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> Message-ID: En Wed, 30 Apr 2008 05:00:26 -0300, Arnaud Delobelle escribi?: > "Gabriel Genellina" writes: > >> En Wed, 30 Apr 2008 04:19:22 -0300, SL escribi?: >> >>> "Lutz Horn" schreef in bericht >>> news:mailman.360.1209537877.12834.python-list at python.org... >>>> >>>> So just for completion, the solution is: >>>> >>>>>>> chr(ord('a') + 1) >>>> 'b' >>> >>> thanks :) I'm a beginner and I was expecting this to be a member of >>> string so I couldnt find it anywhere in the docs. >> >> And that's a very reasonable place to search; I think chr and ord are >> builtin functions (and not str methods) just by an historical >> accident. (Or is there any other reason? what's wrong with "a".ord() >> or str.from_ordinal(65))? > > > Not a reason, but doesn't ord() word with unicode as well? Yes, so ord() could be an instance method of both str and unicode, like upper(), strip(), and all of them... And str.from_ordinal(n)==chr(n), unicode.from_ordinal(n)==unichr(n) -- Gabriel Genellina From malaclypse2 at gmail.com Fri Apr 25 11:41:52 2008 From: malaclypse2 at gmail.com (Jerry Hill) Date: Fri, 25 Apr 2008 11:41:52 -0400 Subject: why does the following with Queue, q.put('\x02', True) not put it in the queue? In-Reply-To: <4811F484.1070901@mydeskfriend.com> References: <6eb550ae-dca4-4371-856a-15bc9625f93c@z72g2000hsb.googlegroups.com> <4811F484.1070901@mydeskfriend.com> Message-ID: <16651e80804250841ta242229ob7f996e229ff4310@mail.gmail.com> On Fri, Apr 25, 2008 at 11:11 AM, Gabriel Rossetti wrote: > yes, if you do it that way (s = '\x02') it works, but I read the data from > a file, and I that way it doesn't work.... It does work (using Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32) import Queue f = open('temp', 'w') f.write('\x02') f.close() f = open('temp', 'r') ch = f.read(1) f.close() print repr(ch) q = Queue.Queue(0) q.put(ch, True) print len(q.queue) prints the following: '\x02' 1 Perhaps you could put together an example that actually shows the behavior you're seeing. I'm not super familiar with Queue.Queue internals, but should you be accessing the undocumented q.queue (the internal deque of the Queue instance) directly? Shouldn't you be using the documented q.qsize() interface instead? -- Jerry From steve at holdenweb.com Wed Apr 2 11:59:53 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 02 Apr 2008 11:59:53 -0400 Subject: ThreadingTCPServer: sock.recv() doesn't block? In-Reply-To: References: Message-ID: Prepscius, Colin (IT) wrote: > So I'm using the ThreadingTCPServer from the python standard library > SocketServer, and calling serve_forever on it. In my handler's handle > method, I call self.request.recv(x) in a loop until I've received n > bytes. But recv() returns immediately with nothing, over and over. It > all still works, but my cpu pegs. I thought socketc.recv() was supposed > to block. Anybody know if I'm doing something wrong? > It would be easier to say if we could actually see the code for your handle() method - indeed, the whole server wouldn't hurt. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bvidinli at gmail.com Tue Apr 15 07:04:41 2008 From: bvidinli at gmail.com (bvidinli) Date: Tue, 15 Apr 2008 14:04:41 +0300 Subject: where is pythoncard program ? Message-ID: <36e8a7020804150404g755bee0eg2924e0dfe71b0a7a@mail.gmail.com> i installed pythoncard, but i could not find how to start it ? where can i find its executable/binary ? or menu item ? or command line that i should enter ? thanks. -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From victorsubervi at gmail.com Wed Apr 30 12:03:34 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 30 Apr 2008 11:03:34 -0500 Subject: Colors for Rows In-Reply-To: <20080430120116.c07f028f.darcy@druid.net> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> <20080429121105.f10c3862.darcy@druid.net> <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> <1209495803.5173.11.camel@aalcdl07.lib.unc.edu> <20080429153930.a6eddea6.darcy@druid.net> <1209500446.5510.4.camel@aalcdl07.lib.unc.edu> <4dc0cfea0804300857h6a7a8aa6l25aa0a3e82da12c0@mail.gmail.com> <20080430120116.c07f028f.darcy@druid.net> Message-ID: <4dc0cfea0804300903w725aa357wbe082269e1add170@mail.gmail.com> The problem was that z was not incrementing. It kept getting reset to 3, then incremented to 4 immediately, and reset back to 3. Stupid :/ On Wed, Apr 30, 2008 at 11:01 AM, D'Arcy J.M. Cain wrote: > On Wed, 30 Apr 2008 10:57:44 -0500 > "Victor Subervi" wrote: > > Thank you all. You helped clean up my code. The stupid mistake was in > where > > I set the initial value of the variable z. > > Really? I thought that it was odd to start in the middle of your > colour list but it didn't seem like it was an error. What do you think > was wrong with it? > > -- > D'Arcy J.M. Cain | Democracy is three wolves > http://www.druid.net/darcy/ | and a sheep voting on > +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gruszczy at gmail.com Wed Apr 23 12:13:34 2008 From: gruszczy at gmail.com (=?UTF-8?Q?Filip_Gruszczy=C5=84ski?=) Date: Wed, 23 Apr 2008 18:13:34 +0200 Subject: Explicit variable declaration In-Reply-To: References: <1be78d220804230252n4faa34e6v90b482080750e0cb@mail.gmail.com> Message-ID: <1be78d220804230913nd0b31a4g8480bd2aa9988c86@mail.gmail.com> Wow! This is extremely easy and seems to do exactly what I need. Those decorators are pretty powerful then. Thanks for your help, I'll try to use this. > def uses(names): > def decorator(f): > used = set(f.func_code.co_varnames) > declared = set(names.split()) > undeclared = used-declared > unused = declared-used > if undeclared: > raise ValueError("%s: %s assigned but not declared" > % (f.func_name, ','.join(undeclared))) > if unused: > raise ValueError("%s: %s declared but never used" > % (f.func_name, ','.join(unused))) > return f > return decorator > > Used something like this: > > >>> @uses("x y") > def f(x): > y = x+1 > return z > > >>> @uses("x y z") > def f(x): > y = x+1 > return z > > > Traceback (most recent call last): > File "", line 1, in > @uses("x y z") > File "", line 10, in decorator > raise ValueError("%s: %s declared but never used" % (f.func_name, > ','.join(unused))) > ValueError: f: z declared but never used > >>> @uses("x") > def f(x): > y = x+1 > return z > > > Traceback (most recent call last): > File "", line 1, in > @uses("x") > File "", line 8, in decorator > raise ValueError("%s: %s assigned but not declared" % (f.func_name, > ','.join(undeclared))) > ValueError: f: y assigned but not declared > > > >>> > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Filip Gruszczy?ski From skanemupp at yahoo.se Sat Apr 5 16:17:45 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 13:17:45 -0700 (PDT) Subject: Tkinter, add pressed buttons onto string display string, how to? References: Message-ID: <57605958-5589-4ebe-abdf-73c2d14c8a82@u10g2000prn.googlegroups.com> > input = "hello" > input += " world" > print input this i know. im wondering how to handle the variable in the actual program. this exception i get: Exception in Tkinter callback Traceback (most recent call last): File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ return self.func(*args) File "C:\Users\saftarn\Desktop\guiexperiments\calculatorGUI.py", line 48, in self.btnDisplay = Button(self,text='+',command=lambda n="+":self.Display(n),width=1,height=1) File "C:\Users\saftarn\Desktop\guiexperiments\calculatorGUI.py", line 92, in Display str = number + str UnboundLocalError: local variable 'str' referenced before assignment > A caculator program is pretty complex. Based on your rudimentary > questions, I don't think you have enough programming experience to > tackle a project like that yet. nah ill be fine. im new to python, not to programming. From hardcoded.software at gmail.com Thu Apr 24 16:38:47 2008 From: hardcoded.software at gmail.com (Virgil Dupras) Date: Thu, 24 Apr 2008 13:38:47 -0700 (PDT) Subject: Class Inheritance - What am I doing wrong? References: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> Message-ID: <1b90518a-e6c6-4aa7-8f59-cc197797b4fe@c65g2000hsa.googlegroups.com> On Apr 24, 10:22?pm, Brian Munroe wrote: > My example: > > class A(object): > > ? ? ? ? def __init__(self, name): > ? ? ? ? ? ? ? ? self.__name = name > > ? ? ? ? def getName(self): > ? ? ? ? ? ? ? ? return self.__name > > class B(A): > > ? ? ? ? def __init__(self,name=None): > ? ? ? ? ? ? ? ? super(A,self).__init__() > > ? ? ? ? def setName(self, name): > ? ? ? ? ? ? ? ? self.__name = name > > if __name__ == '__main__': > > ? ? ? ? a = A('class a') > ? ? ? ? print a.getName() > > ? ? ? ? b = B('class b') > ? ? ? ? print b.getName() > > ? ? ? ? b.setName('class b, reset') > ? ? ? ? print b.getName() > > I get the following error: > > mtinky:~ brian$ python teste.py > class a > Traceback (most recent call last): > ? File "teste.py", line 23, in > ? ? print b.getName() > ? File "teste.py", line 7, in getName > ? ? return self.__name > AttributeError: 'B' object has no attribute '_A__name' > > Am I *not* using super() correctly? ?Also, did I define my the class B > constructor correctly? Exactly, you used it wrong. It's super(B, self). But before you start using super() everywhere, read this: http://fuhm.net/super-harmful/ I love Python, but super() is one of those tricky things... From NikitaTheSpider at gmail.com Thu Apr 3 18:23:16 2008 From: NikitaTheSpider at gmail.com (Nikita the Spider) Date: Thu, 03 Apr 2008 18:23:16 -0400 Subject: developing web spider References: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> <47f3ab52$0$36346$742ec2ed@news.sonic.net> Message-ID: In article <47f3ab52$0$36346$742ec2ed at news.sonic.net>, John Nagle wrote: > abeen wrote: > > Hello, > > > > I would want to know which could be the best programming language for > > developing web spider. > > More information about the spider, much better,, > > As someone who actually runs a Python based web spider in production, I > should comment. > > You need a very robust parser to parse real world HTML. > Even the stock version of BeautifulSoup isn't good enough. We have a > modified version of BeautifulSoup, plus other library patches, just to > keep the parser from blowing up or swallowing the entire page into > a malformed comment or tag. Browsers are incredibly forgiving in this > regard. > > "urllib" needs extra robustness, too. The stock timeout mechanism > isn't good enough. Some sites do weird things, like open TCP connections > for HTTP but not send anything. > > Python is on the slow side for this. Python is about 60x > slower than C, and for this application, you definitely see that. > A Python based spider will go compute bound for seconds per page > on big pages. The C-based parsers for XML/HTML aren't robust enough for > this application. And then there's the Global Interpreter Lock; a multicore > CPU won't help a multithreaded compute-bound process. > > I'd recommend using Java or C# for new work in this area > if you're doing this in volume. Otherwise, you'll need to buy > many, many extra racks of servers. In practice, the big spiders > are in C or C++. I'll throw in an opinion from a different viewpoint. I'm really happy I used Python to develop my spider. I like the language, it has a good library and good community support and 3rd party modules. John, I don't know what your spider does, but you face some hurdles that I don't. For instance, since I'm focused on validation, if bizarre (invalid) HTML makes a page look like garbage, I just report the problem to the author. Performance isn't a big problem for me, either, since this is not a crawl-as-fast-as-you-can application. What you said sounds to me entirely correct for your application. The OP who asked for as much information as possible didn't give a whole lot to start with. -- Philip http://NikitaTheSpider.com/ Whole-site HTML validation, link checking and more From s0suk3 at gmail.com Sun Apr 27 14:40:05 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Sun, 27 Apr 2008 11:40:05 -0700 (PDT) Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> <48131f57$0$14357$e4fe514c@news.xs4all.nl> Message-ID: <4ca7b83c-0ca4-4e38-95e5-264780d30ec0@56g2000hsm.googlegroups.com> On Apr 26, 7:25 am, Irmen de Jong wrote: > s0s... at gmail.com wrote: > > Until now, I've been > > doing this little trick: > > > data = client.recv(256) > > new = data > > while len(new) == 256: > > new = client.recv(256) > > data += new > > Are you aware that recv() will not always return the amount of bytes asked for? > (send() is similar; it doesn't guarantee that the full buffer you pass to it will be > sent at once) > > I suggest reading this:http://www.amk.ca/python/howto/sockets/sockets.html > > --irmen So every time I use I want to send some thing, I must use totalsent = 0 while sent < len(data): sent = sock.send(data[totalsent:]) totalsent += sent instead of a simple sock.send(data)? That's kind of nasty. Also, is it better then to use sockets as file objects? Maybe unbuffered? From munrobaggers at gmail.com Mon Apr 28 22:28:02 2008 From: munrobaggers at gmail.com (Stormbringer) Date: Mon, 28 Apr 2008 19:28:02 -0700 (PDT) Subject: xcode able to run script? References: <31c47061-7038-4868-8422-a8da0f6d7437@m45g2000hsb.googlegroups.com> Message-ID: On Apr 28, 1:52?pm, Alex Pavluck wrote: > Does anyone know if it is possible to test your scripts from within > the xcode editor? ?I am currently using Uilipad on windows and there > is a sub window that lets you view your output when you launch the > script from within the ide. ?hopefully this makes sense. > > thanks, Alex Use SPE, it has this functionality plus a lot more.You can get it at: http://pythonide.blogspot.com/ From kloro2006 at gmail.com Tue Apr 15 20:27:10 2008 From: kloro2006 at gmail.com (tom arnall) Date: Tue, 15 Apr 2008 17:27:10 -0700 Subject: How to have unittest tests to be executed in the order they appear? In-Reply-To: <87zlru7le2.fsf@benfinney.id.au> References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> <87zlru7le2.fsf@benfinney.id.au> Message-ID: <200804151727.10983.kloro2006@gmail.com> On Tuesday 15 April 2008 16:23, Ben Finney wrote: > "Giampaolo Rodola'" writes: > > Is there a way to force unittest to run test methods in the order > > they appear? > > No, and this is a good thing. > > Your test cases should *not* depend on any state from other test > cases; they should function equally well when executed in any > arbitrary sequence. Dependencies between separate test cases (e.g. > "they only work correctly when run in a specific sequence") means > you're not isolating them properly. > > Use the TestCase.setUp and TestCase.tearDown methods to handle any > fixtures needed by test cases in each class of test cases. That way, > the fixtures will be set up and torn down between every test case. > Find out about test fixtures in the documentation for unittest > . > > -- > \ "All my life I've had one dream: to achieve my many goals." -- | > `\ Homer, _The Simpsons_ | > _o__) | > Ben Finney a better approach maybe is just to write your own test harness. it's trivial to write a minimal system, which is then a solid basis for the enhancements which are best for you. tom arnall arcata From bronger at physik.rwth-aachen.de Wed Apr 30 11:41:22 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 30 Apr 2008 17:41:22 +0200 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> <87tzhjy4u2.fsf@physik.rwth-aachen.de> <67rfg6F2qrcooU1@mid.uni-berlin.de> Message-ID: <87ve1zcpul.fsf@physik.rwth-aachen.de> Hall?chen! Diez B. Roggisch writes: >> However, join() is really bizarre. The list rather than the >> separator should be the leading actor. > > Certainly *not*! This would be the way ruby does it, and IMHO it > does not make sense to add join as a string-processing related > method/functionality to a general purpose sequence type. Okay, my wording was unfortunate. However, I've already twice (before and after the above posting of mine) said what I mean, namely join(list, separator), possibly with a default value for "separator". Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From kothari.alok at gmail.com Tue Apr 1 16:23:16 2008 From: kothari.alok at gmail.com (Alok Kothari) Date: Wed, 2 Apr 2008 01:53:16 +0530 Subject: XML Parsing In-Reply-To: <4660fe300804011301t64934dd0g921cd282d3af8917@mail.gmail.com> References: <4660fe300804011301t64934dd0g921cd282d3af8917@mail.gmail.com> Message-ID: Thanks ! it worked ! On Wed, Apr 2, 2008 at 1:31 AM, Konstantin Veretennicov < kveretennicov at gmail.com> wrote: > On Tue, Apr 1, 2008 at 10:42 PM, Alok Kothari > wrote: > > > Hello, > > I am new to XML parsing.Could you kindly tell me whats the > > problem with the following code: > > > > import xml.dom.minidom > > import xml.parsers.expat > > document = """Lettermanis > token>betterthan > token>JayLeno""" > > > > This document is not well-formed. It doesn't have root element. > > ... > > > > > > Traceback (most recent call last): > > File "C:/Python25/Programs/eg.py", line 20, in > > p.Parse(document, 1) > > ExpatError: junk after document element: line 1, column 33 > > > > Told ya :) > > > Try wrapping your document in root element, like > "......" > > -- > kv > -------------- next part -------------- An HTML attachment was scrubbed... URL: From upton at virginia.edu Wed Apr 23 12:27:42 2008 From: upton at virginia.edu (Dan Upton) Date: Wed, 23 Apr 2008 12:27:42 -0400 Subject: MESSAGE RESPONSE In-Reply-To: <678v5qF2me5rvU1@mid.uni-berlin.de> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> <678v5qF2me5rvU1@mid.uni-berlin.de> Message-ID: <5504f9ac0804230927ncfdb91buf7fa3e181f8a9237@mail.gmail.com> On Wed, Apr 23, 2008 at 10:24 AM, Diez B. Roggisch wrote: > Blubaugh, David A. schrieb: > > > Is there a way to block these messages. I do not want to be caught > > with filth such as this material. I could lose my job with Belcan with > > evil messages such as these messages. > > > > If I (or *anybody*) knew how to block these messages, he or she would sell > the resulting spam-filter for a fortunen that roughly amasses the one of > scrooge mc duck - and go live on the bahamas or even buy them. > > Put up with it. It's (unfortunately) part of ze internet tubes. > And as such, I find it hard to believe you could lose your job over it. From duncan.booth at invalid.invalid Wed Apr 23 11:10:49 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 23 Apr 2008 15:10:49 GMT Subject: Explicit variable declaration References: <1be78d220804230252n4faa34e6v90b482080750e0cb@mail.gmail.com> Message-ID: Steve Holden wrote: > Filip Gruszczy?"ski wrote: >> Just declaring, that they exist. Saying, that in certain function >> there would appear only specified variables. Like in smalltalk, if I >> remember correctly. >> > Icon has (had?) the same feature: if the "local" statement appeared then > the names listed in it could be assigned in the local namespace, and > assignment to other names wasn't allowed. Python being what it is, it is easy enough to add support for declaring at the top of a function which local variables it uses. I expect that actually using such functionality will waste more time than it saves, but here's a simple enough implementation: def uses(names): def decorator(f): used = set(f.func_code.co_varnames) declared = set(names.split()) undeclared = used-declared unused = declared-used if undeclared: raise ValueError("%s: %s assigned but not declared" % (f.func_name, ','.join(undeclared))) if unused: raise ValueError("%s: %s declared but never used" % (f.func_name, ','.join(unused))) return f return decorator Used something like this: >>> @uses("x y") def f(x): y = x+1 return z >>> @uses("x y z") def f(x): y = x+1 return z Traceback (most recent call last): File "", line 1, in @uses("x y z") File "", line 10, in decorator raise ValueError("%s: %s declared but never used" % (f.func_name, ','.join(unused))) ValueError: f: z declared but never used >>> @uses("x") def f(x): y = x+1 return z Traceback (most recent call last): File "", line 1, in @uses("x") File "", line 8, in decorator raise ValueError("%s: %s assigned but not declared" % (f.func_name, ','.join(undeclared))) ValueError: f: y assigned but not declared >>> From sjmachin at lexicon.net Fri Apr 25 17:34:34 2008 From: sjmachin at lexicon.net (John Machin) Date: Fri, 25 Apr 2008 14:34:34 -0700 (PDT) Subject: problem with unicode References: <26fcc207-b864-42c7-afb3-c6945e5fe29f@m44g2000hsc.googlegroups.com> <67dvg8F2nomm6U1@mid.individual.net> <67eu0rF2ogf6qU1@mid.individual.net> Message-ID: <61e7b742-4e0d-4a9d-a494-84e6c07115b1@w5g2000prd.googlegroups.com> On Apr 26, 6:42 am, Bjoern Schliessmann wrote: > John Machin wrote: > > On Apr 25, 10:01 pm, Bjoern Schliessmann >> >>> media="x???[?" > >> >>> print repr(media.decode("utf-8")) > > >> u'x\u30ef\u30e6\u30ed[\u30e8' > > (dang, KNode doesn't autodetect encodings ...) > > > But that_unicode_string.encode("utf-8") produces > > 'x\xe3\x83\xaf\xe3\x83\xa6\xe3\x83\xad[\xe3\x83\xa8' > > which does not contain the complained-about byte 0x9c in position > > 1 (or any other position) -- how can that be? > > Probably the OP used a different encoding. That seems even more > likely given the fact that his postings have a Japanese encoding > (but this one doesn't produce any 0x9c, either). > I've tried just about every Japanese encoding there is. None of those produced 0x9c. Perhaps the OP might like to tell us a bit more about "# media is a binary string (mysql escaped zipped file)". mysql, escaped, zipped -- we could be three layers of onion skin away from enlightenment. From wwzaygvm at gmail.com Wed Apr 16 17:03:48 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 14:03:48 -0700 (PDT) Subject: stalker crack Message-ID: <13009466-fc07-4c7d-b50b-58d78b5bf650@f63g2000hsf.googlegroups.com> stalker crack http://cracks.12w.net F R E E C R A C K S From jrobertoleite at gmail.com Tue Apr 29 09:22:00 2008 From: jrobertoleite at gmail.com (=?iso-8859-1?Q?Jos=E9_Roberto?=) Date: Tue, 29 Apr 2008 10:22:00 -0300 Subject: Windows Printing using win32print Message-ID: <58067CF3E0784DA3BEF22324FD03969A@hadron> Ol? KellyK! I have read your comentary about how to print with python in windows using win32print. I have trying to use in my problem : print a figure (.jpg, .png...etc) could you help me? Thanks a lot JRoberto -------------- next part -------------- An HTML attachment was scrubbed... URL: From ed at leafe.com Tue Apr 1 21:44:45 2008 From: ed at leafe.com (Ed Leafe) Date: Tue, 1 Apr 2008 20:44:45 -0500 Subject: class super method In-Reply-To: References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> <0eb3ee4e-82e2-419a-8e7b-4931f7b4effa@c26g2000prf.googlegroups.com> Message-ID: On Apr 1, 2008, at 6:10 PM, Steve Holden wrote: > Ed is a good enough designer to avoid the corner cases. Strangely > enough > the one place where I have ended up making significant use of super() > was in providing mixins for wxPython interface classes! Thanks much for the compliment. Yes, wrapping the disparate and confusing wxPython classes to have a consistent interface is where we also make the most use of super(), but our database wrappers also provide consistent functionality to all the dbapi cursors, no matter what the backend database may be. The only reason this works is that we are working with a single known class interface; we control all our own mixin class designs. With the wxPython stuff, each class has a well-defined set of methods and method signatures, and with the database stuff, we only mixin with the dbapi-standard methods, and avoid hooking into module-specific enhancements. My point in these postings is that working with multiple inheritance is fraught with potential pitfalls; super() doesn't create these pitfalls, although it can make it easier to fall into them. If you try to create a PotBelliedElephant class by using MI with a PotBelliedPig class and an Elephant class, well, you *should* crash and burn, whether you use super() or not. http://en.wikipedia.org/wiki/An_Elephant_Makes_Love_to_a_Pig -- Ed Leafe From wescpy at gmail.com Tue Apr 1 13:43:07 2008 From: wescpy at gmail.com (wesley chun) Date: Tue, 1 Apr 2008 10:43:07 -0700 Subject: [ANN] Python courses this Fall In-Reply-To: <78b3a9580708230043k35ff6729vc7fefefb2068531b@mail.gmail.com> References: <78b3a9580708230043k35ff6729vc7fefefb2068531b@mail.gmail.com> Message-ID: <78b3a9580804011043s11572e6eld7993e12f8df29dc@mail.gmail.com> FINAL ANNOUNCEMENT Need to get up-to-speed with Python as quickly as possible? Come join me, Wesley Chun, author of Prentice-Hall's well-received "Core Python Programming," for another comprehensive intro course next month in beautiful Northern California! I look forward to meeting you! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (COMPREHENSIVE) INTRODUCTION TO PYTHON: Mon-Wed, 2008 May 5-7 Although this course may appear to those new to Python, it is also perfect those who have tinkered with it and want to "fill in the gaps" and/or want to get more in-depth formal training. It combines the best of both an introduction to the language as well as a "Python Internals" training course. We will immerse you in the world of Python in only a few days. We will show you more than just its syntax (which you don't really need a book to learn, right?). Knowing more about how Python works under the covers, including the relationship between data objects and memory management, will make you a much more effective Python programmer coming out of the gate. 3 hands-on labs each day will help hammer the concepts home. Come find out why Google, Yahoo!, Disney, ILM/LucasFilm, VMware, OLPC, NASA, Ubuntu, YouTube, and Red Hat all use Python. Users supporting or jumping to Plone, Zope, TurboGears, Django, Pylons, Jython, IronPython, and Mailman will also benefit! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - WHERE: near the San Francisco Airport (SFO/San Bruno), CA, USA WEB: http://cyberwebconsulting.com (click "Python Training") LOCALS: easy freeway (101/280/380) with lots of parking plus public transit (BART and CalTrain) access via the San Bruno stations, easily accessible from all parts of the Bay Area VISITORS: free shuttle to/from the airport, free high-speed internet, free breakfast and regular evening receptions; fully-equipped suites See website for costs, venue info, and registration. Discounts are available for multiple registrations as well as for teachers/students. Hope to see you there! -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall, (c)2007,2001 http://corepython.com wesley.j.chun :: wescpy-at-gmail.com python training and technical consulting cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com From andrew at acooke.org Tue Apr 15 05:01:39 2008 From: andrew at acooke.org (andrew cooke) Date: Tue, 15 Apr 2008 02:01:39 -0700 (PDT) Subject: Dynamic use of property() fails References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> <480461f8$0$20282$426a34cc@news.free.fr> Message-ID: ignore that - i was mistaken (my test was too complex). the problem seems to be that the attribute is deleted even though __delete__ is defined. i'll look at it tomorrow. thanks again, andrew On Apr 15, 4:50 am, andrew cooke wrote: > i tried code very similar after reading the first replies and found > that it did not work as expected on setting. for example, in > > person = Person() > person.age = 27 > > "age" is set in the instance's dictionary (as 27; the descriptor is > not called), which then shadows the definition of age in the class > dictionary. > > my understanding was that the descriptor is only called in the class > context, so would be called if, say, a subclass tried to redefine > age. but maybe i am still confused. > > i am about to go to sleep. i guess i will try your code exactly > tomorrow, but it looks very close to mine which showed this problem. > are you sure your solution works? > > thanks, > andrew From corvettecraz92 at gmail.com Wed Apr 9 08:25:19 2008 From: corvettecraz92 at gmail.com (corvettecraz92 at gmail.com) Date: Wed, 9 Apr 2008 05:25:19 -0700 (PDT) Subject: text adventure game problem References: Message-ID: On Apr 9, 1:24?am, Dennis Lee Bieber wrote: > On Tue, 8 Apr 2008 18:01:01 -0700 (PDT), corvettecra... at gmail.com > declaimed the following in comp.lang.python: > > > okay, I'm having this one problem with a text adventure game. It's > > kind of hard to explain, but I'll do my best. > > [code] > > > def prompt_kitchen(): > > ? ? global gold > > ? ? gold_taken = False > > ? ? while True: > > ? ? ? ? prompt_kit = raw_input('>') > > ? ? ? ? if prompt_kit == 'examine cabinet 1' and not gold_taken: > > ? ? ? ? ? ? print '''This cabinet has a lot of cups in it with all > > different > > designs and shapes. Where are the people anyway? How come there's > > nobody here? > > In one of the cups you find 8 gold.''' > > ? ? ? ? Forgive me, but.... Ugh! > > ? ? ? ? It looks like you are defining a function for each possible room > which incorporates code for the actions possible in that room... > > ? ? ? ? I suspect I'd try to create a generic room class which has as > attributes a dictionary of actions and a dictionary of movable objects. > Along with methods that work on objects... Working an action that digs > into other objects may take some doing. > > class gobject(object): > ? ? ? ? def examine(self, item=None): > ? ? ? ? ? ? ? ? if not item: item = self > ? ? ? ? ? ? ? ? print "you look at the %s; you see %s" % ? ? ? ? ? ? ?\ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?(item.desc, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ", ".join([k for k in item.subobjs.keys()])) > ? ? ? ? def go(self, direction): > ? ? ? ? ? ? ? ? return moves[directions] > ? ? ? ? def take(self, item): > ? ? ? ? ? ? ? ? itmobj = self.subobjs[item] > ? ? ? ? ? ? ? ? del self.subobjs[item] > ? ? ? ? ? ? ? ? return itmobj > ? ? ? ? def dropto(self, itemname, item): > ? ? ? ? ? ? ? ? self.subobjs[itemname] = item > > class movobj(gobject): > ? ? ? ? def __init__(self, desc="a vague blob", subobjs=None, moves=None): > ? ? ? ? ? ? ? ? ... > > class room(gobject): > ? ? ? ? def __init__(self, desc="a bare chamber", > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? subobjs=None, moves=None): > ? ? ? ? ? ? ? ? ... > > g1 = movobj(desc="8 pieces of gold") > c1 = movobj(desc="kitchen cabinet", subobjs={"gold" : g1}) > > rooms = {"kichen" : room(desc="you are in the kitchen", > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? subobjs={"cabinet" : c1}, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? moves={"n" : rooms["dining"], > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "out" : rooms["dining"} > ? ? ? ? ? ? ? ? "dining" : room(desc="you are in the dining room", > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? moves={"s" : rooms["kitchen"} } > > player = Player() > player.location = rooms["dining"] > player.run() > > {where run() incorporates the parser loop -- something like} > while True: > ? ? ? ? self.location.examine() > ? ? ? ? command = raw_input("=> ") > ? ? ? ? words = command.split() > ? ? ? ? if words[0] in ["go", "move", "walk", "run"]: > ? ? ? ? ? ? ? ? self.location = self.location.go(words[1]) > ? ? ? ? elif words[0] in ["look", "examine", "study"]: > ? ? ? ? ? ? ? ? self.location.examine(words[1]) > ? ? ? ? elif words[0] in ["take"]: > ? ? ? ? ? ? ? ? self.subobjs[words[1]] = self.location.take(words[1]) > ? ? ? ? elif words[0] in ["drop", "leave"]: > ? ? ? ? ? ? ? ? self.location.dropto(words[1], self.subobjs[words[1]]) > ? ? ? ? ? ? ? ? del self.subobjs[words[1]] > ? ? ? ? elif ... > > {of course, this ignores adding logic for failure to find the > subobj/move in the relevant dictionary -- which should result in > > ? ? ? ? I do not see that here > or > ? ? ? ? I can not go that direction > > objects should also have attributes to indicate if they can be thrown > (and what the results are), etc. > > ? ? ? ? In the above the display should look something like (ignoring the > unchecked for missing attributes) > > you look at the dining room, you see ? (need check for empty) > => > > go s > > you look at the kitchen, you see cabinet > => > > examine cabinet > > you look at the kitchen cabinet, you see gold > => > > -- > ? ? ? ? Wulfraed ? ? ? ?Dennis Lee Bieber ? ? ? ? ? ? ? KD6MOG > ? ? ? ? wlfr... at ix.netcom.com ? ? ? ? ? ? wulfr... at bestiaria.com > ? ? ? ? ? ? ? ? HTTP://wlfraed.home.netcom.com/ > ? ? ? ? (Bestiaria Support Staff: ? ? ? ? ? ? ? web-a... at bestiaria.com) > ? ? ? ? ? ? ? ? HTTP://www.bestiaria.com/ I can't even compile your code to see how it works, Dennis. I'm confused about what that does. From kyosohma at gmail.com Mon Apr 28 20:56:15 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Mon, 28 Apr 2008 19:56:15 -0500 Subject: Automating IE 6.0 In-Reply-To: <81B200F0AB075D4D95DA50067247FFBFF15DB8@mcc-es1.MCC.local> References: <81B200F0AB075D4D95DA50067247FFBFF15DB8@mcc-es1.MCC.local> Message-ID: <4816722F.90104@gmail.com> Michael Harris wrote: > > I tried to use the sample code to print a webpage via ie and I get the > following error: > > > > Traceback (most recent call last): > > File > "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", > line 310, in RunScript > > exec codeObject in __main__.__dict__ > > File "C:\ie.py", line 14, in > > ie.ExecWB(win32com.client.constants.OLECMDID_PRINT, > win32com.client.constants.OLECMDEXECOPT_DONTPROMPTUSER) > > NameError: name 'win32com' is not defined > > > > I have the win32com module installed and I clicked on makepy.py and selected Microsoft Internet Controls (1.1). The code was: > > from win32com.client import Dispatch > from time import sleep > ie = Dispatch("InternetExplorer.Application") > ie.Visible = 1 > ie.Navigate("http://www.cnn.com" ) > if ie.Busy: > sleep(2) > # print the current IE document without prompting the user for the > printerdialog > ie.ExecWB(win32com.client.constants.OLECMDID_PRINT,win32com.client.constants > .OLECMDEXECOPT_DONTPROMPTUSER) > > > Why am I getting this error? > I don't know why this is happening, so I recommend posting it to the pywin32 group: http://mail.python.org/mailman/listinfo/python-win32 You might also check out the PAMIE project: http://sourceforge.net/projects/pamie SendKeys would also work, but it's kind of messy. Mike From starsareblueandfaraway at gmail.com Fri Apr 4 02:49:18 2008 From: starsareblueandfaraway at gmail.com (Roy H. Han) Date: Fri, 4 Apr 2008 02:49:18 -0400 Subject: Question. In-Reply-To: <661622.4034.qm@web54009.mail.re2.yahoo.com> References: <661622.4034.qm@web54009.mail.re2.yahoo.com> Message-ID: <6a5569ec0804032349v1f342206o953c4ffe76919475@mail.gmail.com> Your boyfriend is pretty funny. I tried to get my girlfriend to learn Python a long time ago but she doesn't see value in it. On Fri, Apr 4, 2008 at 12:31 AM, AJay Grimmett wrote: > My name is Amanda. My boyfriend sent me an encrypted message by using > python. I guess he thought it would be fun for me to figure it out for > myself. This one involes a whole lotta numbers. I can't read or understand > what I am supposed to do to read this message. I mean, I've read the > information, but I seriously do not understand. He sent the .py file, and > the messages that were encrypted...i just don't know how to use it to get to > the message where I can read it. Is there anyway you or someone could do it > step by step..or just do it for me?! lol. I just need to know what this > says. Apparently it's an important message and I must read it. =] Thank you > for your time. I hope to hear from you soon! > -amanda > > ------------------------------ > You rock. That's why Blockbuster's offering you one month of Blockbuster > Total Access, > No Cost. > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bronger at physik.rwth-aachen.de Mon Apr 21 03:11:56 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Mon, 21 Apr 2008 09:11:56 +0200 Subject: Is massive spam coming from me on python lists? References: <480C2DC6.4050701@aim.com> Message-ID: <87r6cz3cn7.fsf@physik.rwth-aachen.de> Hall?chen! Sjoerd Mullender writes: > On 2008-04-21 08:01, Brian Vanderburg II wrote: > >> I've recently gotten more than too many spam messages and all say >> Sender: python-list-bounces+my=email.address at python.org. [...] > > That is just mailman (the mailing list software) keeping track of > things. By the way, why does mailman change the Message-IDs when tunneling postings to the newsgroup? This destroys the thread structure. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From lscbtfws at gmail.com Sat Apr 26 12:10:36 2008 From: lscbtfws at gmail.com (lscbtfws at gmail.com) Date: Sat, 26 Apr 2008 09:10:36 -0700 (PDT) Subject: empire earth 2 crack Message-ID: <41cf24db-d86d-49bf-87b7-60fe568c1f1f@b9g2000prh.googlegroups.com> empire earth 2 crack http://cracks.00bp.com F R E E C R A C K S From soundofmp32 at gmail.com Thu Apr 17 02:49:12 2008 From: soundofmp32 at gmail.com (ghgggu) Date: Wed, 16 Apr 2008 23:49:12 -0700 (PDT) Subject: the best ABOUT MP3 this year. have alook... Message-ID: <52e61b6c-fc73-4db2-8a65-a0c9bbbe4f18@8g2000hse.googlegroups.com> http://www.soundofmp3.info From canistel at gmail.com Thu Apr 10 14:43:23 2008 From: canistel at gmail.com (canistel at gmail.com) Date: Thu, 10 Apr 2008 11:43:23 -0700 (PDT) Subject: mod_python and storing binary form data Message-ID: <7e7194df-bd2c-444f-a458-6caa91ea4ace@x41g2000hsb.googlegroups.com> Hi, I have a little python webservice that I created, and in one of the methods I need to store some binary data that was "posted"... I want to do something like this, but it doesn't work. username = form.get("username", "") message = form.get("message", "") attachment = form.get("attachment", None) ... c.execute("""INSERT INTO Message (username, message, attachment) VALUES (%s, %s, %s)""", (username, message, attachment)) "attachment" is then some binary data that was posted, but when I look in the mysql database, I see values for the attachment field which look like: Field('attachment', '\x89PNG\r\n\x1a\n\x00\x00\... so it is storing something, just not my binary data (in this case a picture). the attachment column is a longblob in mysql. From usenet-mail at markshroyer.com Thu Apr 17 12:51:26 2008 From: usenet-mail at markshroyer.com (Mark Shroyer) Date: Thu, 17 Apr 2008 12:51:26 -0400 Subject: What can we do about all the spam that the list is getting? References: <259ab201-9d2b-4e4e-88a7-e2fe277f0066@a23g2000hsc.googlegroups.com> Message-ID: In article , Grant Edwards wrote: > On 2008-04-16, Mark Shroyer wrote: > > In article > >, > > Mensanator wrote: > > > >> On Apr 16, 12:01?pm, sr... at ferg.org wrote: > >> > What can we do about all the spam that comp.lang.python is getting? > >> > Things are getting pretty bad. > >> > >> Buy Google and make them fix it. > > > > I've had pretty good luck with MT-NewsWatcher, a freeware Mac > > newsreader that performs Bayesian spam filtering. > > Thunderbird's Usenet reader also offers Bayesian filtering, > > which presumably works just as well for classifying Usenet > > spam as it does at handling email spam. > > > > So download a "real" NNTP client for whatever platform you're > > on and give its spam filter a shot; clearly Google is not > > interested in fighting spam itself. > > Plonking anything posted via google.groups is the simplest > answer. Yes, but it's hard to give him that advice with a straight face until I've convinced him to stop using Google Groups to begin with ;) -- Mark Shroyer http://markshroyer.com/contact/ From alkundry at gmail.com Wed Apr 30 05:42:55 2008 From: alkundry at gmail.com (ABDULLAH) Date: Wed, 30 Apr 2008 02:42:55 -0700 (PDT) Subject: DO YOU KNOW ANY THING ABOUT ISLAM??? References: <2429a87a-34e8-4294-9a25-b54dd2cf6791@m73g2000hsh.googlegroups.com> Message-ID: <7ffebfa6-33c1-4004-a009-532f634f986c@p25g2000hsf.googlegroups.com> On Apr 27, 1:52?pm, Lie wrote: > On Apr 24, 1:40 pm, ABDULLAH wrote: > > > What you are about to read might sound unusual but it could be very > > enlightened. So I would be thankful if you give my article 5 minute > > of > > your value time. THANK YOU > > No, it is not unusual at all, it's very normal. The only thing that's > unusual is that you misposted this in a programming language mailing > list instead of religion list. sorry if you did not like this topic I thougth it will be intresting for someone but ok as you like I will stop writing about these stuffs in this group From ivan.illarionov at gmail.com Tue Apr 29 17:35:11 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Tue, 29 Apr 2008 21:35:11 +0000 (UTC) Subject: @classmethod question References: Message-ID: On Tue, 29 Apr 2008 14:30:08 -0600, Scott SA wrote: > With that said, your reply is amazingly helpful in my quest to > understand python, Django, etc. Django is the ORM I referred to, so the > material you have written helps explain a few things. This was my intention. Django ORM uses Pyhton classes to represent tables and instances to represent rows. And they do it in a way very similat to what I had showed. Another note about classmethods: they are almost the same thing as methods of metaclasses. Classmethods are more simple to understand but at the same time they touch very complex and, as Guido call it, 'brain- exploding' topic. > I'm a little vague on the interaction of the IngredientsDescrptor VS IngredientsManager. I gather the 'Descriptor' class is called via the __get__ which then does the instance check. Could this have been done in the 'Manager' class? The descriptor trick is only needed to prevent instances from calling Manager methods. Custom descriptors are little more than just classes and AFAIK it's better to keep them separated. > I have been learning a lot from the Django code and other applications > written within it. Still, some things just don't seem to gel, even after > a host of google searches. I've not loked at the Google Apps stuff, but > will follow your advice. I think that it's better to keep things as simple as possible (other solutions in this thread are definetly more practical) and don't try to use classmethods, custom descriptors and metaclasses unless you *really* need this stuff. AFAIK all these metaprogramming tricks make sense only for frameworks and for learning Python, but make very little or no sense for smaller apps. -- Ivan From ptmcg at austin.rr.com Sun Apr 6 11:20:59 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Sun, 6 Apr 2008 08:20:59 -0700 (PDT) Subject: Is there any way to say ignore case with "in"? References: <47f692f3$0$759$bed64819@news.gradwell.net> <432d690f-44be-49a9-bc6a-1cf3445549d6@m71g2000hse.googlegroups.com> <47f8d5df$0$23304$9b622d9e@news.freenet.de> Message-ID: On Apr 6, 8:53?am, "Martin v. L?wis" wrote: > >> I know I could use:- > > >> ? ? if lower(string1) in lower(string2): > >> ? ? ? ? > > >> but it somehow feels there ought to be an easier (tidier?) way. > > > Easier? ?You mean like some kind of mind meld? > > Interestingly enough, it shouldn't be (but apparently is) obvious that > > ? ?a.lower() in b.lower() > > is a way of expressing "a is a substring of b, with case-insensitive > matching". Can we be sure that these are really the same concepts, > and if so, is > > ? a.upper() in b.upper() > > also equivalent? > > It's probably a common assumption that, for any character c, > c.lower()==c.upper().lower(). Yet, > > py> [i for i in range(65536) if unichr(i).upper().lower() != > unichr(i).lower()] > [181, 305, 383, 837, 962, 976, 977, 981, 982, 1008, 1009, 1010, 1013, > 7835, 8126] > > Take, for example, U+017F, LATIN SMALL LETTER LONG S. It's .lower() is > the same character, as the character is already in lower case. > It's .upper() is U+0053, LATIN CAPITAL LETTER S. Notice that the LONG > is gone - there is no upper-case version of a "long s". > It's .upper().lower() is U+0073, LATIN SMALL LETTER S. > > So should case-insensitive matching match the small s with the small > long s, as they have the same upper-case letter? > > Regards, > Martin Another surprise (or maybe not so surprising) - this "upper != lower" is not symmetric. Using the inverse of your list comp, I get >>> [i for i in range(65536) if unichr(i).lower().upper() != ... unichr(i).upper()] [304, 1012, 8486, 8490, 8491] Instead of 15 exceptions to the rule, conversion to upper has only 5 exceptions. So perhaps comparsion of upper's is, while not foolproof, less likely to encounter these exceptions? Or at least, simpler to code explicit tests. -- Paul From steve at holdenweb.com Wed Apr 16 12:06:09 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 16 Apr 2008 12:06:09 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: Mike Driscoll wrote: > On Apr 16, 10:09 am, Steve Holden wrote: >> Mike Driscoll wrote: >>> On Apr 16, 9:19 am, Grant Edwards wrote: >>>> This morning almost half of c.l.p was spam. In order to try to >>>> not tar both the benign google group users and the malignant >>>> ones with the same brush, I've been trying to kill usenet spam >>>> with subject patterns. But that's not a battle you can win, so >>>> I broke down and joined all the other people that just killfile >>>> everything posted via google.groups. >>>> AFAICT, if you're a google groups user your posts are not being >>>> seen by many/most experienced (read "non-google-group") users. >>>> This is mainly the fault of google who has refused to do >>>> anything to stem the flood of span that's being sent via Google >>>> Groups. >>>> -- >>>> Grant Edwards grante Yow! I would like to >>>> at urinate in an OVULAR, >>>> visi.com porcelain pool -- >>> Yeah, I noticed that Google Groups has really sucked this week. I'm >>> using the Google Groups Killfile for Greasemonkey now and it helps a >>> lot. I like Google, but my loyalty only goes to far. This is a >>> complete lack of customer service. >> Unfortunately this means Google groups users are getting exactly the >> service they are paying for. >> >> regards >> Steve >> -- >> Steve Holden +1 571 484 6266 +1 800 494 3119 >> Holden Web LLC http://www.holdenweb.com/ > > Steve, > > My workplace doesn't offer NNTP, so there is no good way to browse > c.l.py here. And I haven't been able to get NNTP to work from my home > either. > > By applying this logic to Python and Linux (or any Open Source > product), they shouldn't be used either (since I'm not paying for > them). > I'm not saying people shouldn't use Google Groups. I'm saying that Google can "justify" providing customer "support" that lives somewhere between zero and extremely crappy by not charging for the service. Without tunneling out to an NNTP proxy I don't see what other choice you have. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From terry.yinzhe at gmail.com Mon Apr 28 19:26:30 2008 From: terry.yinzhe at gmail.com (Terry) Date: Mon, 28 Apr 2008 16:26:30 -0700 (PDT) Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> <18c1e6480804270653r2e075061wf442b7b7d9f50ff6@mail.gmail.com> Message-ID: <9cca03a3-9b96-4bee-947b-baa62cd5f9a9@q24g2000prf.googlegroups.com> On Apr 28, 5:30 pm, Nick Craig-Wood wrote: > David wrote: > > Another idea would be to have multiple queues, one per thread or per > > message type "group". The producer thread pushes into the appropriate > > queues (through an intelligent PutMsg function), and the consumer > > threads pull from the queues they're interested in and ignore the > > others. > > Unfortunately a thread can only wait on one Queue at once (without > polling). So really the only efficient solution is one Queue per > thread. > > Make an intelligent PutMsg function which knows which Queue (or > Queues) each message needs to be put in and all the threads will have > to do is Queue.get() and be sure they've got a message they can deal > with. > > -- > Nick Craig-Wood --http://www.craig-wood.com/nick I do have one Queue per thread. The problem is the thread can not peek into the Queue and select msg with certain ID first. From paddy3118 at googlemail.com Wed Apr 2 11:21:35 2008 From: paddy3118 at googlemail.com (Paddy) Date: Wed, 2 Apr 2008 08:21:35 -0700 (PDT) Subject: who said python can't be obsfucated!? References: Message-ID: <65e57230-4f7c-4454-8b9c-906a62ab6b92@u36g2000prf.googlegroups.com> On Apr 2, 2:19 pm, cokofree... at gmail.com wrote: > def s(c):return[]if c==[]else s([_ for _ in c[1:]if _ +s([_ for _ in c[1:]if _>=c[0]]) > > Anyone else got some wonders...? Nope. From lucafbb at gmail.com Sun Apr 27 06:39:32 2008 From: lucafbb at gmail.com (Luca) Date: Sun, 27 Apr 2008 12:39:32 +0200 Subject: Newbie question about import In-Reply-To: References: <27308d500804251103t71d04b5fg1de6658ceab9d898@mail.gmail.com> Message-ID: <27308d500804270339p2358587ei4522e10bfd723907@mail.gmail.com> On Sat, Apr 26, 2008 at 4:14 AM, Gabriel Genellina wrote: > The short answer is: don't do that! __init__.py may import any module, but > other modules in the package should not import anything from __init__.py > The same rule applies to the main module in an application: it can import > any other required module, but no one should import main. > If you don't follow those rules you may encounter some surprises. > You *can* break the rules and actually do what you want, but I would not > reccomend it. > In this case, can't you switch the place where __version__ is defined? It > looks like a constant, so you could have it actually defined in mommy.py, > and inside __init__.py just import the value. > Ok, thanks all for helping. -- -- luca From wizzardx at gmail.com Sat Apr 26 04:52:21 2008 From: wizzardx at gmail.com (David) Date: Sat, 26 Apr 2008 10:52:21 +0200 Subject: Desktop notifications on Windows In-Reply-To: <0db266c1-50ad-4e01-b508-57c9a8febb4b@a22g2000hsc.googlegroups.com> References: <0db266c1-50ad-4e01-b508-57c9a8febb4b@a22g2000hsc.googlegroups.com> Message-ID: <18c1e6480804260152y2c4d0c62jb396d7fb545ba7e6@mail.gmail.com> On Sat, Apr 26, 2008 at 4:41 AM, wrote: > I'm looking for a way to implement desktop notifications (much like an > instant messaging program or a mail notifier) within my Python > application, on Windows only (no Gtk/Galago, please). I need no more > than a simple text-based notification, which should be clickable and > have a timeout, nothing else. I do not want to use Windows's "balloon > tips", either. Any suggestions? > -- You could use Tkinter, which comes with Python. From frikker at gmail.com Fri Apr 25 10:14:53 2008 From: frikker at gmail.com (blaine) Date: Fri, 25 Apr 2008 07:14:53 -0700 (PDT) Subject: Unix Device File Emulation References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> <480f6376$0$9037$5402220f@news.sunrise.ch> <9ee87070-be57-4a66-a152-3f36c1cc8f0c@k13g2000hse.googlegroups.com> <480f7983$0$9036$5402220f@news.sunrise.ch> <49529b68-88b4-4115-a85a-587528274a50@m73g2000hsh.googlegroups.com> Message-ID: <8905dc2d-dd0c-492f-a399-d80c2ee8e262@34g2000hsf.googlegroups.com> On Apr 24, 3:38 am, "A.T.Hofkamp" wrote: > On 2008-04-23, blaine wrote: > > > On Apr 23, 2:01 pm, "Martin Blume" wrote: > >> "blaine" schrieb > >> No, > >> while 1: > >> r = self.fifodev.readline() > >> if r: print r > >> else: time.sleep(0.1) > >> is ok (note the "if r:" clause). > > >> Martin > > > Beautiful! Thanks Martin! > > yes, but you have to follow the usual file handling rules, and close/re-open > the fifo after detecting EOF. You will be blocked on attempting to re-open > until there is another writing process. > > while 1: > fp = open('my_fifo', 'r') > while 1: > line = fp.readline() > if line == '': > break > print line.rstrip() # To prevent printing of \n in line > fp.close() > > Albert Oh, good call. Thanks a lot, that really helps. I felt that the previous solution was workable, but not perhaps 100% correct. Thanks Albert! From jpthing at online.no Wed Apr 30 06:35:10 2008 From: jpthing at online.no (John Thingstad) Date: Wed, 30 Apr 2008 12:35:10 +0200 Subject: Python's doc problems: sort References: <929d5ce9-9063-4e6c-98aa-89526f89fba3@y18g2000pre.googlegroups.com> <9pof14t22rpq24219q0an2748i5f054qr4@4ax.com> <88273bc8-5152-4dfd-9f96-1d6ee2b83f99@e53g2000hsa.googlegroups.com> Message-ID: P? Wed, 30 Apr 2008 06:26:31 +0200, skrev George Sakkis : > On Apr 29, 11:13?pm, J?rgen Exner wrote: > >> "xah... at gmail.com" wrote: >> >> Is this self-promoting maniac still going at it? >> >> >Although i disliked Perl very much [...] >> >> Then why on earth do you bother polluting this NG? >> >> Back into the killfile you go >> >> jue > > \|||/ > (o o) > ,----ooO--(_)-------. > | Please | > | don't feed the | > | TROLL's ! | > '--------------Ooo--' > |__|__| > || || > ooO Ooo Doesn't copying Rainer Joswig's troll warning constitute a copywright infrigment :) -------------- John Thingstad From medin0065 at gmail.com Sun Apr 20 10:49:56 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:49:56 -0700 (PDT) Subject: prevx1 crack Message-ID: <9f3aa585-8049-4af6-b019-697941c73163@a5g2000prg.googlegroups.com> prevx1 crack http://cracks.00bp.com F R E E C R A C K S From ptmcg at austin.rr.com Thu Apr 17 04:37:28 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Thu, 17 Apr 2008 01:37:28 -0700 (PDT) Subject: Newbie question about for...in range() structure References: Message-ID: On Apr 17, 3:30?am, "sp at k" wrote: > def fact(n): > ? ? ? ? total = 0 > ? ? ? ? n = int(n) > ? ? ? ? while n > 0: > ? ? ? ? ? ? ? ? total *= n > ? ? ? ? ? ? ? ? n -=1 > ? ? ? ? return total > My guess is that you want to initialize total to 1, not 0. -- Paul From grflanagan at gmail.com Thu Apr 10 11:34:18 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Thu, 10 Apr 2008 08:34:18 -0700 (PDT) Subject: subprocess.Popen() output to logging.StreamHandler() References: Message-ID: On Apr 10, 2:11 pm, "sven _" wrote: > Version: Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) > > My goal is to have stdout and stderr written to a logging handler. > This code does not work: > > # START > import logging, subprocess > ch = logging.StreamHandler() > ch.setLevel(logging.DEBUG) > subprocess.call(['ls', '-la'], 0, None, None, ch, ch) > # END > > Traceback (most recent call last): > File "log.py", line 5, in > subprocess.call(['ls', '-la'], 0, None, None, ch, ch) > File "/usr/lib/python2.5/subprocess.py", line 443, in call > return Popen(*popenargs, **kwargs).wait() > File "/usr/lib/python2.5/subprocess.py", line 586, in __init__ > errread, errwrite) = self._get_handles(stdin, stdout, stderr) > File "/usr/lib/python2.5/subprocess.py", line 941, in _get_handles > c2pwrite = stdout.fileno() > AttributeError: StreamHandler instance has no attribute 'fileno' > > This is because subprocess.Popen() expects file descriptors to write > to, and logging.StreamHandler() does not supply it. The StreamHandler > could supply its own stdout file descriptor, but then Popen() would > write directly to that file, bypassing all the logging fluff. > > A possible solution would be to make a named pipe (os.mkfifo()), have > Popen() write to that, and then have some horrendous hack run select() > or similar on the fifo to read from it and finally pass it to > StreamHandler. > > Are there better solutions? > > sven When you create a StreamHandler, it is associated with a particular stream, eg. sys.stdout. So when you log an event, the handler picks it up and writes it to the stream. But you seem to think that the reverse situation is true - when something is written to the stream (from an arbitrary source) then the StreamHandler instance will pick it up. This isn't the case - it doesn't work both ways. I think the only solution is to specifically log each line that you get back from Popen, as suggested by Thomas Dimson. You would perhaps like something like the code below to work but it doesn't (well, it runs, but the output of the subprocess call bypasses the Streamhandler). But then, maybe this is sufficient for you - as you've seen, you can't set the stdout of the subprocess to the StreamHandler, but you can set it to the Streamhandler's stream (if it has a fileno) - subprocess.call('svn info', stdout=ch.stream) OR subprocess.call('svn info', stdout=ch.stream.fileno()) -------------------------------------------------------- import sys import logging import subprocess ECHO_FORMAT = '%(levelname)-8s %(message)s' class ReverseReverseStreamHandler(logging.StreamHandler): def __init__(self, strm): logging.StreamHandler.__init__(self, strm) self.fileno = strm.fileno def write(self, msg): print 'This is never called!' for line in msg.splitlines(): self.emit(logging.LogRecord(None, None, "", 0, line, (), None, None)) root = logging.getLogger() console = ReverseReverseStreamHandler(sys.stdout) formatter = logging.Formatter(ECHO_FORMAT) console.setFormatter(formatter) root.addHandler(console) root.setLevel(logging.DEBUG) logging.info('---------') subprocess.call('svn info', stdout=console) logging.info('---------') -------------------------------------------------------- hth G. From steve at holdenweb.com Wed Apr 16 17:03:33 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 16 Apr 2008 17:03:33 -0400 Subject: py3k s***s In-Reply-To: References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> <09a38ca2-8c49-4eee-b6cf-58e849aea1fc@q1g2000prf.googlegroups.com> Message-ID: <480669A5.3050705@holdenweb.com> Aaron Watters wrote: > On Apr 16, 2:33 pm, Rhamphoryncus wrote: >> The point is, you can't have it both ways. Either you evolve the >> language and break things, or you keep it static and nothing breaks. > > I disagree. You can add lots of cool > stuff without breaking the existing code base, mostly. > For example the minor changes to the way ints will work will > effect almost no programs. > > I don't see the urgency to clean up what are essentially > cosmetic issues and throw out or > require rewrites for just about all existing Python > code. Python 2.6 isn't fundamentally awful like Perl 4 was. > The cost paid for these minor improvements is too high in my > book. But I suppose if it is going to happen do it sooner > rather than later. Just *please* *please* don't > systematically break the pre-existing code base again for a > very long time, preferable ever. I'm pretty sure the 3.0 compatibility breakage is a one-shot deal. If it's not I won't be the only one looking for Guido with a bog stick in my hand ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From tonal at promsoft.ru Mon Apr 28 02:57:31 2008 From: tonal at promsoft.ru (Alexandr N Zamaraev) Date: Mon, 28 Apr 2008 13:57:31 +0700 Subject: py2exe do not compile from mingw Message-ID: <4815755B.3060005@promsoft.ru> OS: WinXP Home Ru + sp2 Python: 2.5.2 py2exe: latest CSV source gcc (GCC) 3.4.5 (mingw-vista special r2) GNU ld (GNU Binutils) 2.18.50.20080109 OS: WinXP Home Ru + sp2 Python: 2.5.2 py2exe: latest CSV source gcc (GCC) 3.4.5 (mingw-vista special r2) GNU ld (GNU Binutils) 2.18.50.20080109 I have patchs for compile py2exe from latest release mingw. Correct setup, compile, and run errors. This patch union 1012785 patch and 1378533 bag patch for latest CSV source. see alse http://sourceforge.net/tracker/index.php?func=detail&aid=1953133&group_id=15583&atid=315583, http://sourceforge.net/tracker/?func=detail&aid=1378533&group_id=15583&atid=115583, http://sourceforge.net/tracker/?func=detail&aid=1012785&group_id=15583&atid=315583 From martin at v.loewis.de Tue Apr 29 17:50:41 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 29 Apr 2008 23:50:41 +0200 Subject: Simple unicode-safe version of str(exception)? In-Reply-To: References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> Message-ID: <48179831.7030308@v.loewis.de> > Should I report this as a bug? I suspect it's a misfeature. Please no. There isn't much that can be done about it, IMO. Regards, Martin From steve at holdenweb.com Mon Apr 14 14:17:11 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 14 Apr 2008 14:17:11 -0400 Subject: =?UTF-8?B?5pyJ5Lit5Zu95Lq65LmOPw==?= In-Reply-To: <4801F702.5050401@arcor.de> References: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> <4801F702.5050401@arcor.de> Message-ID: Penny Y. wrote: > Steve Holden ??: > >> ????????, ????????? >> > > What do you mean? > If I understand you correctly, maybe it should be, > > ??python??????,??????. > > Am I right? I have no idea. Babelfish (from which I obtained my reply as well as whatever understanding I had of the original inquiry) translated my reply as But the academic society never is immediately, with will need time whereas yours becomes Studies python not to be possible on first to become, needs to proceed in an orderly way Since what I entered in English was something like "Yes, Python has a future. But it will take some study". Perhaps you can tell me whether your translation gives the correect flavor. I'm pretty sure the babelfish mangled my intent. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From xng at xs4all.nl Sat Apr 19 20:04:27 2008 From: xng at xs4all.nl (Martin P. Hellwig) Date: Sun, 20 Apr 2008 02:04:27 +0200 Subject: Bigger projects, including files? In-Reply-To: References: Message-ID: <480a8928$0$4941$e4fe514c@dreader32.news.xs4all.nl> globalrev wrote: > if i have a larger project and want to divide my program into several > files, how do i include these files in the mainprogram? > > using import someprojectfile doesnt work because import is for site- > packages right and i dont want to put all my files > in that folder. > > so how do i do it? > You can always add the path where the other files are to sys.path I've posted a while ago something that sort of does that for inter-package reference if the root is not in the sys.path http://groups.google.com/group/comp.lang.python/browse_thread/thread/0e29ab20b4d4bc97 hth -- mph From miki.tebeka at gmail.com Tue Apr 1 08:36:59 2008 From: miki.tebeka at gmail.com (Miki) Date: Tue, 1 Apr 2008 05:36:59 -0700 (PDT) Subject: How to insert multiple rows in SQLite Dbase References: <50faeed7-775f-4e12-8131-21a95b5f91a8@e6g2000prf.googlegroups.com> <657h3nF2eehi8U1@mid.uni-berlin.de> Message-ID: <6fc8a682-b15e-4700-9aef-bdb4a3f980d7@e10g2000prf.googlegroups.com> > Thanks regards to your suggestion, but I don't understand why we have > to put the IF statement? It's just an example, one possible implementation could be: def parse_data(data): mapping = {} for line in data.splitlines(): if not line.strip(): continue key, value = line.split(":", 1) mapping[key] = value return mapping HTH, -- Miki http://pythonwise.blogspot.com From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 1 14:09:54 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 01 Apr 2008 20:09:54 +0200 Subject: Python in High School In-Reply-To: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: <47f27a74$0$20512$426a74cc@news.free.fr> sprad a ?crit : > I'm a high school computer teacher, and I'm starting a series of > programming courses next year (disguised as "game development" classes > to capture more interest). The first year will be a gentle > introduction to programming, leading to two more years of advanced > topics. > > I was initially thinking about doing the first year in Flash/ > ActionScript, and the later years in Java. My reasoning is that Flash > has the advantage of giving a quick payoff to keep the students > interested while I sneak in some OOP concepts through ActionScript. > Once they've gotten a decent grounding there, they move on to Java for > some more heavy-duty programming. > > I've never used Python, but I keep hearing enough good stuff about it > to make me curious. > > So -- would Python be a good fit for these classes? IMHO, yes, definitively - except that it won't introduce concepts like static typing and primitive types, since it's dynamically typed and 100% object. OTHO, it'll let you introduce quite a lot of more advanced topics (operator overloading, metaclasses, higher-order functions, closures, partial application etc) that you're less likely to grasp using Java. > Could it equal > Java as the later heavy-duty language? If you mean "is it possible to use Python to write real-world, non-trivial applications", then the answer is obviously yes. Python's use range from Q&D admin script to full-blown web application server including vector graphic GUI apps, scientific data analysis and plotting and game developpment and/or scripting. > Does it have enough quickly- > accessible sparklies to unseat Flash? Since you plan to lure poor schoolboys in by pretending to teach them game programming, you may want to have a look at pygame: http://www.pygame.org/news.html > I want to believe. Evangelize away. "Then I saw Pygame, now I'm a believer".... !-) From gherron at islandtraining.com Thu Apr 24 16:54:29 2008 From: gherron at islandtraining.com (Gary Herron) Date: Thu, 24 Apr 2008 13:54:29 -0700 Subject: Class Inheritance - What am I doing wrong? In-Reply-To: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> References: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> Message-ID: <4810F385.5010105@islandtraining.com> Brian Munroe wrote: > My example: > > class A(object): > > def __init__(self, name): > self.__name = name > > def getName(self): > return self.__name > > class B(A): > > def __init__(self,name=None): > super(A,self).__init__() > > def setName(self, name): > self.__name = name > > if __name__ == '__main__': > > a = A('class a') > print a.getName() > > b = B('class b') > print b.getName() > > b.setName('class b, reset') > print b.getName() > > I get the following error: > > mtinky:~ brian$ python teste.py > class a > Traceback (most recent call last): > File "teste.py", line 23, in > print b.getName() > File "teste.py", line 7, in getName > return self.__name > AttributeError: 'B' object has no attribute '_A__name' > > Am I *not* using super() correctly? Also, did I define my the class B > constructor correctly? > -- > http://mail.python.org/mailman/listinfo/python-list > Tell us what you are trying to do and what you expected to happen. If you are trying to do simple inheritance, you don't need the supers, and you should not invoke the name mangling implied by the double underscore. If you *are* trying to use the name mangling, then you still don't need the super. Gary Herron From hniksic at xemacs.org Mon Apr 28 10:28:26 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Mon, 28 Apr 2008 16:28:26 +0200 Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> <87od7ue2ne.fsf@mulj.homelinux.net> Message-ID: <87hcdmdpf9.fsf@mulj.homelinux.net> Nick Craig-Wood writes: >> Note that appending to a string is almost never a good idea, since it >> can result in quadratic allocation. > > My aim was clear exposition rather than the ultimate performance! That would normally be fine. My post wasn't supposed to pick performance nits, but to point out potentially quadratic behavior. > Anyway str += was optimised in python 2.4 or 2.5 (forget which) wasn't > it? That optimization works only in certain cases, when working with uninterned strings with a reference count of 1, and then only when the strings are in stored local variables, rather than in global vars or in slots. And then, it only works in CPython, not in other implementations. The optimization works by "cheating" -- breaking the immutable string abstraction in the specific cases in which it is provably safe to do so. http://utcc.utoronto.ca/~cks/space/blog/python/ExaminingStringConcatOpt examines it in some detail. Guido was reluctant to accept the patch that implements the optimization because he thought it would "change the way people write code", a sentiment expressed in http://mail.python.org/pipermail/python-dev/2004-August/046702.html This discussion shows that he was quite right in retrospect. (I'm not saying that the optimization is a bad thing, just that it is changing the "recommended" way of writing Python in a way that other implementations cannot follow.) From hobgoodoreneyhb at gmail.com Tue Apr 22 11:36:22 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:36:22 -0700 (PDT) Subject: side effects of scopolamine patch Message-ID: side effects of scopolamine patch http://cracks.12w.net F R E E C R A C K S From jasper at peak.org Thu Apr 24 10:16:47 2008 From: jasper at peak.org (Jasper) Date: Thu, 24 Apr 2008 07:16:47 -0700 (PDT) Subject: How to find the parent of an old-style class? Message-ID: <9742ba66-eebf-43ba-8391-d0d0edb52c95@l42g2000hsc.googlegroups.com> I'm stuck using a library based on old style classes, and need to find a class's parent at runtime. With new style classes you can use .__base__ to inspect a parent, but I can't remember how this was done in days of yore, before object. I've tried googling, but apparently my search term Fu is weak. :-( Can anyone help me out here? There must be something simple. -Jasper From hopeorpha308 at gmail.com Sun Apr 27 07:46:16 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:46:16 -0700 (PDT) Subject: vista ultimate crack Message-ID: <0267dab6-abd0-4e1e-991c-28b556b68735@w7g2000hsa.googlegroups.com> vista ultimate crack http://wga-cracks.crackkey.net From __peter__ at web.de Wed Apr 23 07:56:51 2008 From: __peter__ at web.de (Peter Otten) Date: Wed, 23 Apr 2008 13:56:51 +0200 Subject: problem with dictionaries References: Message-ID: Simon Strobl wrote: > the idea of the following program is to parse a frequency list of the > form FREQUENCY|WORD, to store the frequency of a word in a dictionary > (and to do some things with this information later). > > I have done this many many times. Suddenly, it does not work any more: > The value frq[key] is different from the value that key has in the > file 'my_frqlist.txt'. > > I am using Python 2.5.1 > > Any hints? The code looks OK. You probably have python reading a my_frqlist.txt that differs from the one you are looking at. Peter From bg at bg.fr Wed Apr 9 09:05:26 2008 From: bg at bg.fr (Bruno GUERPILLON) Date: Wed, 9 Apr 2008 15:05:26 +0200 Subject: List open files References: <47fb8d54$0$15068$426a74cc@news.free.fr> <47fb9789$0$881$ba4acef3@news.orange.fr> Message-ID: <47fcc014$0$22451$426a74cc@news.free.fr> "Guillaume" a ?crit dans le message de news: ftg58p$2fek$2 at biggoron.nerim.net... > Oh and don't forget to take care about saving correctly the Oracle > database ! ^^ > (private joke *giggles* j/k :)) > > Regards, > -- > Guillaume Sure Guillamne and dont forget to answer the right questions *grin* Bruno. From mobile at ibinsa.com Tue Apr 8 18:08:29 2008 From: mobile at ibinsa.com (Gabriel Ibanez) Date: Wed, 9 Apr 2008 00:08:29 +0200 Subject: Converting a tuple to a list Message-ID: <00ba01c899c5$14528ae0$0a01a8c0@mobile> Hi all .. I'm trying to using the map function to convert a tuple to a list, without success. I would like to have a lonely line that performs the same as loop of the next script: ------------------------------------------- # Conveting tuple -> list tupla = ((1,2), (3,4), (5,6)) print tupla lista = [] for a in tupla: for b in a: lista.append(b) print lista ------------------------------------------- Any idea ? Thanks ... # Gabriel From gagsl-py2 at yahoo.com.ar Tue Apr 1 02:03:17 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 03:03:17 -0300 Subject: Why prefer != over <> for Python 3.0? References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> <659gb2F2f84eoU2@mid.individual.net> <87hceo73ap.fsf@physik.rwth-aachen.de> <65anbqF2fg18bU1@mid.individual.net> <87r6drjss4.fsf@physik.rwth-aachen.de> <65c0bfF2ffipiU1@mid.individual.net> Message-ID: En Mon, 31 Mar 2008 16:17:39 -0300, Terry Reedy escribi?: > "Bjoern Schliessmann" > wrote > in message news:65c0bfF2ffipiU1 at mid.individual.net... > | > However, I'm quite sure that when Unicode has arrived almost > | > everywhere, some languages will start considering such characters > | > in their core syntax. > | > | This should be the time when there are widespread quasi-standardised > | input methods for those characters. > > C has triglyphs for keyboards missing some ASCII chars. != and <= could > easily be treated as diglyphs for the corresponding chars. In a sense > they > are already, it is just that the real things are not allowed ;=). I think it should be easy to add support for ??? and even ?, only the tokenizer has to be changed. -- Gabriel Genellina From steve at holdenweb.com Sat Apr 5 22:30:24 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 22:30:24 -0400 Subject: id functions of ints, floats and strings In-Reply-To: References: Message-ID: Gabriel Genellina wrote: > En Thu, 03 Apr 2008 19:27:47 -0300, escribi?: > >> Hi all, >> >> I've been playing around with the identity function id() for different >> types of objects, and I think I understand its behaviour when it comes >> to objects like lists and tuples in which case an assignment r2 = r1 >> (r1 refers to an existing object) creates an alias r2 that refers to >> the same object as r1. In this case id(r1) == id(r2) (or, if you >> like: r1 is r2). However for r1, r2 assigned as follows: r1 = [1, 2, >> 3] and r2 = [1, 2, 3], (r1 is r2) is False, even if r1==r2, >> etc. ...this is all very well. Therefore, it seems that id(r) can be >> interpreted as the address of the object that 'r' refers to. >> >> My observations of its behaviour when comparing ints, floats and >> strings have raised some questions in my mind, though. Consider the >> following examples: >> >> ######################################################################### >> >> # (1) turns out to be true >> a = 10 >> b = 10 >> print a is b > > ...only because CPython happens to cache small integers and return always > the same object. Try again with 10000. This is just an optimization and > the actual range of cached integer, or whether they are cached at all, is > implementation (and version) dependent. > (As integers are immutable, the optimization *can* be done, but that > doesn't mean that all immutable objects are always shared). > >> # (2) turns out to be false >> f = 10.0 >> g = 10.0 >> print f is g > > Because the above optimization isn't used for floats. > The `is` operator checks object identity: whether both operands are the > very same object (*not* a copy, or being equal: the *same* object) > ("identity" is a primitive concept) > The only way to guarantee that you are talking of the same object, is > using a reference to a previously created object. That is: > > a = some_arbitrary_object > b = a > assert a is b > > The name `b` now refers to the same object as name `a`; the assertion > holds for whatever object it is. > > In other cases, like (1) and (2) above, the literals are just handy > constructors for int and float objects. You have two objects constructed > (a and b, f and g). Whether they are identical or not is not defined; they > might be the same, or not, depending on unknown factors that might include > the moon phase; both alternatives are valid Python. > >> # (3) checking if ids of all list elements are the same for different >> cases: >> >> a = 3*[1]; areAllElementsEqual([id(i) for i in a]) # True >> b = [1, 1, 1]; areAllElementsEqual([id(i) for i in b]) # True >> f = 3*[1.0]; areAllElementsEqual([id(i) for i in f]) # True >> g = [1.0, 1.0, 1.0]; areAllElementsEqual([id(i) for i in g]) # True >> g1 = [1.0, 1.0, 0.5+0.5]; areAllElementsEqual([id(i) for i in g1]) # >> False > > Again, this is implementation dependent. If you try with a different > Python version or a different implementation you may get other results - > and that doesn't mean that any of them is broken. > >> # (4) two equal floats defined inside a function body behave >> differently than case (1): >> >> def func(): >> f = 10.0 >> g = 10.0 >> return f is g >> >> print func() # True > > Another implementation detail related to co_consts. You shouldn't rely on > it. > >> I didn't mention any examples with strings; they behaved like ints >> with respect to their id properties for all the cases I tried. > > You didn't try hard enough :) > > py> x = "abc" > py> y = ''.join(x) > py> x == y > True > py> x is y > False > > Long strings behave like big integers: they aren't cached: > > py> x = "a rather long string, full of garbage. No, this isn't garbage, > just non > sense text to fill space." > py> y = "a rather long string, full of garbage. No, this isn't garbage, > just non > sense text to fill space." > py> x == y > True > py> x is y > False > > As always: you have two statements constructing two objects. Whether they > return the same object or not, it's not defined. > >> While I have no particular qualms about the behaviour, I have the >> following questions: >> >> 1) Which of the above behaviours are reliable? For example, does a1 = >> a2 for ints and strings always imply that a1 is a2? > > If you mean: > > a1 = something > a2 = a1 > a1 is a2 > > then, from my comments above, you should be able to answer: yes, always, > not restricted to ints and strings. > > If you mean: > > a1 = someliteral > a2 = someliteral > a1 is a2 > > then: no, it isn't guaranteed at all, nor even for small integers or > strings. > >> 2) From the programmer's perspective, are ids of ints, floats and >> string of any practical significance at all (since these types are >> immutable)? > > The same significance as id() of any other object... mostly, none, except > for debugging purposes. > >> 3) Does the behaviour of ids for lists and tuples of the same element >> (of type int, string and sometimes even float), imply that the tuple a >> = (1,) takes (nearly) the same storage space as a = 10000*(1,)? (What >> about a list, where elements can be changed at will?) > > That's a different thing. A tuple maintains only references to its > elements (as any other object in Python). The memory required for a tuple > (I'm talking of CPython exclusively) is: (a small header) + n * > sizeof(pointer). So the expression 10000*(anything,) will take more space > than the singleton (anything,) because the former requires space for 10000 > pointers and the latter just one. > > You have to take into account the memory for the elements themselves; but > in both cases there is a *single* object referenced, so it doesn't matter. > Note that it doesn't matter whether that single element is an integer, a > string, mutable or immutable object: it's always the same object, already > existing, and creating that 10000-uple just increments its reference count > by 10000. > > The situation is similar for lists, except that being mutable containers, > they're over-allocated (to have room for future expansion). So the list > [anything]*10000 has a size somewhat larger than 10000*sizeof(pointer); > its (only) element increments its reference count by 10000. > In fact all you can in truth say is that a is b --> a == b The converse definitely not true. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From frikker at gmail.com Wed Apr 30 10:18:30 2008 From: frikker at gmail.com (blaine) Date: Wed, 30 Apr 2008 07:18:30 -0700 (PDT) Subject: Simple TK Question - refreshing the canvas when not in focus References: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> <4818349e$0$2959$ba620e4c@news.skynet.be> Message-ID: <182ace66-bdf6-409c-85ee-fd764de8e1c6@z72g2000hsb.googlegroups.com> Still doesn't work. I'm looking into using wx instead... This is the full code - does it work for anyone else? Just do a echo 'line 0 0 10 10' > dev.file import sys, os, time, Tkinter, threading class nokia_fkscrn(Tkinter.Toplevel): fp=None def __init__(self, file): self.fname = file # Create the FIFO pipe (hopefully /dev/screen or similar) if not os.path.exists(self.fname): os.mkfifo(self.fname) self.readthread = threading.Thread(target=self.read) self.readthread.start() self.init_canvas() def init_canvas(self): # Set up our canvas self.root = Tkinter.Tk() self.root.title('Nokia Canvas') self.canvas = Tkinter.Canvas(self.root, width =130, height=130) self.canvas.pack() self.root.mainloop() def read(self): while 1: self.fp = open(self.fname, 'r') while 1: st = self.fp.readline() if st == '': break self.process(st) self.fp.close() def process(self, line): cmd = line.split() if cmd[0] == 'line': # Draw Line args = map(int, cmd[1:]) try: color=args[4] except: color='black' if self.canvas: print 'Drawing Line:', args self.canvas.create_line(args[0], args[1], args[2], args[3], fill=color) self.canvas.update() self.canvas.focus_force() nokia = nokia_fkscrn('dev.file') From gagsl-py2 at yahoo.com.ar Thu Apr 10 18:18:17 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 19:18:17 -0300 Subject: win-shortcuts, file associates and command-line parameters ? References: <47FE6480.4090602@gmail.com> Message-ID: En Thu, 10 Apr 2008 16:03:28 -0300, Stef Mientki escribi?: > under windows I tried to make a shortcut to a py -file, to run a program. > So making a shortcut like this works perfect: > D:\PyLab_Works.py > > But the problem is that I need to give some commandline parameters to > the py-file, > and > > D:\PyLab_Works.py btc_test > But the parameter doesn't seem to arrive in the python program Check the associated command for .py files; see this message http://groups.google.com/group/comp.lang.python/msg/056ba14ae4fa57e3 -- Gabriel Genellina From andymac at bullseye.apana.org.au Mon Apr 21 05:08:07 2008 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Mon, 21 Apr 2008 20:08:07 +1100 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <480B8813.6010108@gmail.com> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B80B5.1050500@cheimes.de> <480B8813.6010108@gmail.com> Message-ID: <480C5977.3060403@bullseye.andymac.org> Hank @ITGroup wrote: > In order to deal with 400 thousands texts consisting of 80 million > words, and huge sets of corpora , I have to be care about the memory > things. I need to track every word's behavior, so there needs to be as > many word-objects as words. > I am really suffering from the memory problem, even 4G memory space can > not survive... Only 10,000 texts can kill it in 2 minutes. > By the way, my program has been optimized to ``del`` the objects after > traversing, in order not to store the information in memory all the time. In addition to all the other advice you've been given, I've found it can pay dividends in memory consumption when each instance of a value (such as a string) references only 1 object. This is often referred to as "interning". Automatic interning is only performed for a small subset of possibilities. For example: >>> z1 = 10 >>> z2 = 10 >>> z1 is z2 True >>> z1 = 1000 >>> z2 = 1000 >>> z1 is z2 False >>> z1 = 'test' >>> z2 = 'test' >>> z1 is z2 True >>> z1 = 'this is a test string pattern' >>> z2 = 'this is a test string pattern' >>> z1 is z2 False Careful use of interning can get a double boost: cutting memory consumption and allowing comparisons to short circuit on identity. It does cost in maintaining the dictionary that interns the objects though, and tracking reference counts can be much harder. -- ------------------------------------------------------------------------- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andymac at bullseye.apana.org.au (pref) | Snail: PO Box 370 andymac at pcug.org.au (alt) | Belconnen ACT 2616 Web: http://www.andymac.org/ | Australia From skanemupp at yahoo.se Sun Apr 20 23:57:38 2008 From: skanemupp at yahoo.se (globalrev) Date: Sun, 20 Apr 2008 20:57:38 -0700 (PDT) Subject: question about the mainloop References: <52de38c4-3d1e-4be0-9b58-5d60317f1ef7@b1g2000hsg.googlegroups.com> Message-ID: On 21 Apr, 04:26, "Gabriel Genellina" wrote: > En Sun, 20 Apr 2008 20:24:04 -0300, globalrev escribi?: > > > in C?? java etc there is usually: > > > procedure 1 > > procedure 2 > > procedure 3 > > > main { > > procedure 1 > > procedure 2 > > procedure 3 > > } > > > i dont get the mainloop() in python. i mean i have written some > > programs, for example a calculator using tkinterGUI. > > What you call the "mainloop" is the event loop (or message loop) used by event-driven applications as a way to dispatch all events as they happen in the system. The concept is independent of Python/C++/whatever language you choose. The key phrase is "event-driven programming":http://en.wikipedia.org/wiki/Event_driven_programming > Tkinter provides an event-driven GUI framework. Simple CLI programs are not event-driven, as your pseudo example above. > > > if i have some functions i wanna call to run the program and i wanna > > call them ina specific order and be able to call > > them from each other should this just be called in the mainloop and > > the mianloop then runs the "mainscript" top > > to bottom over and over? > > If you don't want or don't require a graphical user interface, just write the functions you need and call them from the outermost section in your script. > If you do require a GUI, you'll have to write the code in response to user actions: when the user clicks here, do this; when the user chooses that menu option, do that. > > -- > Gabriel Genellina but what i mean i dont understand is sure i can bind a function to a buttonpress but if i have a def dox(): dododo and i call it with dox() in the mainscript it will be executed once, but not again. so what does the mainloop do, 1srt time it is executed it runs the mainscript then it it sits and wait s for commands? From pavlovevidence at gmail.com Fri Apr 25 15:43:51 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Fri, 25 Apr 2008 12:43:51 -0700 (PDT) Subject: problem with mmap References: Message-ID: On Apr 25, 9:37 am, Neal Becker wrote: > On linux, I don't understand why: > > f = open ('/dev/eos', 'rw') > m = mmap.mmap(f.fileno(), 1000000, prot=mmap.PROT_READ|mmap.PROT_WRITE, > flags=mmap.MAP_SHARED) > > gives 'permission denied', Try f = open('/dev/eos', 'r+') Carl Banks From grflanagan at gmail.com Tue Apr 1 10:36:07 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Tue, 1 Apr 2008 07:36:07 -0700 (PDT) Subject: Copy Stdout to string References: Message-ID: On Apr 1, 4:03 pm, sophie_newbie wrote: > Hi, I'm wondering if its possible to copy all of stdout's output to a > string, while still being able to print on screen. I know you can > capture stdout, but I still need the output to appear on the screen > also... > > Thanks! I don't know if it's what you want, but if you're talking about the output of a single command, then the following (or a variation) should do. (using 'svn info' as the command). --------------------------------------------------- import subprocess from cStringIO import StringIO import sys buf = StringIO() def popen(cmdline): return subprocess.Popen(cmdline, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout for line in popen('svn info'): print >> sys.stdout, 'out: ' + line, print >> buf, 'buf: ' + line, print print buf.getvalue() --------------------------------------------------- From spam-trap at telus.net Wed Apr 30 21:25:40 2008 From: spam-trap at telus.net (L. Lindstrom) Date: Thu, 01 May 2008 01:25:40 GMT Subject: Python 2.6 and wrapping C libraries on Windows In-Reply-To: <60da8569-4b80-4b31-9fd0-5b2a79ec2164@k13g2000hse.googlegroups.com> References: <60da8569-4b80-4b31-9fd0-5b2a79ec2164@k13g2000hse.googlegroups.com> Message-ID: sturlamolden wrote: > On Apr 30, 8:06 pm, "L. Lindstrom" wrote: > >> I have read that Python extension modules must link to the same C >> run-time as the Python interpreter. This I can appreciate. But does this >> requirement extend to the C libraries an extension module wraps. > > This somewhat of a misconception. You cannot reliably mix and blend > CRT resources across different CRTs. This is not really a Python > problem. It applies to any program. The reason this is important for > Python C extensions, is mainly the possibility of accessing a Python > file object as a pointer to a FILE struct in C. If you get a FILE* > pointer from one CRT, you should not pass it to another CRT's fread. > Likewise, if you allocate memory with one CRT's malloc(), you should > not release the memory with another CRT's free(). As long as your > libraries don't share CRT resources, it does not matter that the link > to different CRTs for their internal work. > > > > > > SDL has functions for separating memory allocation and file access. Going back to msvcrt.dll is a last resort. I may have an idea on how to build it for msvcr90.dll. -- Lenard Lindstrom "%s@%s.%s" % ('len-l', 'telus', 'net') From kay.schluehr at gmx.net Sun Apr 13 11:45:21 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sun, 13 Apr 2008 08:45:21 -0700 (PDT) Subject: str(bytes) in Python 3.0 References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> <806cf1da-8f06-4fff-8437-7f1ca1ff9472@k10g2000prm.googlegroups.com> <8fab7cda-d915-4e13-8bb8-f449b6617778@a22g2000hsc.googlegroups.com> Message-ID: On 13 Apr., 09:24, Carl Banks wrote: > On Apr 12, 11:51 am, Kay Schluehr wrote: > > > On 12 Apr., 16:29, Carl Banks wrote: > > > > > And making an utf-8 encoding default is not possible without writing a > > > > new function? > > > > I believe the Zen in effect here is, "In the face of ambiguity, refuse > > > the temptation to guess." How do you know if the bytes are utf-8 > > > encoded? > > > How many "encodings" would you define for a Rectangle constructor? > > I'm not sure what you're insinuating. If you are arguing that it's > inappropriate for a constructor to take an "encoding" argument (as you > put it), be my guest. I wasn't commenting on that specifically. > > I was commenting on your suggestion of having str assume utf-8 > encoding, which IMO would be very unPythonic, whether you can pass > encodings to it or not. That's o.k. I don't primarily advocate default values or such things just reduction of mental and scripting overhead. We shouldn't lose the goal out of sight. I played a bit with several encodings but this didn't enable much of an impression how it will feel in real code. I can see though the inadequacy of my original claim mainly due to the overlooked fact that there isn't even a mapping of the range \x0 - \xff to utf-8 but only one from \x0 - \x7f. Same with the ASCII encoding which is limited to 7 bits as well. One has to be careful not just because "you can select the wrong encoding" but stringification with an utf-8 encoding can simply activate the exception handler even though there will be no type error! A default value shall work under all circumstances supposed you pass in an object of the correct type. From sgeiger at ncee.net Tue Apr 8 19:58:56 2008 From: sgeiger at ncee.net (Shane Geiger) Date: Tue, 08 Apr 2008 18:58:56 -0500 Subject: Converting a tuple to a list In-Reply-To: <00ba01c899c5$14528ae0$0a01a8c0@mobile> References: <00ba01c899c5$14528ae0$0a01a8c0@mobile> Message-ID: <47FC06C0.8060207@ncee.net> from goopy.functional import * tupla = ((1,2), (3,4), (5,6)) print flatten(tupla) Gabriel Ibanez wrote: > Hi all .. > > I'm trying to using the map function to convert a tuple to a list, without > success. > > I would like to have a lonely line that performs the same as loop of the > next script: > > ------------------------------------------- > # Conveting tuple -> list > > tupla = ((1,2), (3,4), (5,6)) > > print tupla > > lista = [] > for a in tupla: > for b in a: > lista.append(b) > print lista > ------------------------------------------- > > Any idea ? > > Thanks ... > > # Gabriel > > -- Shane Geiger IT Director National Council on Economic Education sgeiger at ncee.net | 402-438-8958 | http://www.ncee.net Leading the Campaign for Economic and Financial Literacy From see.signature at no.spam Thu Apr 17 07:48:38 2008 From: see.signature at no.spam (Eric Brunel) Date: Thu, 17 Apr 2008 13:48:38 +0200 Subject: Learning Tkinter References: Message-ID: On Wed, 16 Apr 2008 14:46:13 +0200, Doran, Harold wrote: [snip] > Second, I am trying to work through a couple of the examples and make > some small tweaks as I go to see how new things can work. In the first > case, I have copied the code in the book to see how the menu works and > are created as in the example menu.py below. I see how menus are created > and how the command option is used to call the function callback. > > # menu.py > from Tkinter import * > > def callback(): > print "called the callback!" > > root = Tk() > > # create a menu > menu = Menu(root) > root.config(menu=menu) > > filemenu = Menu(menu) > menu.add_cascade(label="File", menu=filemenu) > filemenu.add_command(label="New", command=harold) > filemenu.add_command(label="Open...", command=callback) > filemenu.add_separator() > filemenu.add_command(label="Exit", command=callback) > > helpmenu = Menu(menu) > menu.add_cascade(label="Help", menu=helpmenu) > helpmenu.add_command(label="About...", command=callback) > > mainloop() > > However, I now want to incorporate a basic python program with a > command. Say I have a simple program called test.py > > # test.py > filename = raw_input("Please enter the file you want to open: ") > new_file = raw_input("Save the output file as: ") > > f = open(new_file, 'w') > new = open(filename, 'r') > > for line in new: > x = line.split('\t') > print >> f, x[0],':', x[1] > f.close() > > To make this example complete assume I have a text file like this > > # data.txt > 1 one > 2 two > 3 three > 4 four > > So, the user currently just follows directions on the screen, enters the > file names, and I get what I want. I'd like to try experimenting with > gui programming to see if the python programs I have written can be made > even more user friendly. I currently use py2exe to create executables so > that others in my organization can use these programs. > In that spirit, say I want to have a menu option that allows the user to > search their computer for this file, execute the python code and then > save the result as a user-defined filename. So, I guess my questions are > how do I associate the portion of code in menu.py > "filemenu.add_command(label="Open...", command=callback)" with an > operation that gives the user the ability to search the drives on their > machine and then once they do let python execute the code in test.py? The way it's written, you'll have a hard time doing it... Since test.py already includes a "user interface" via the raw_input calls, executing test.py will always ask the user for the file names, and there's no simple way to pass them otherwise as the module is written. Considering how you asked the question, I'll assume you don't know Python very much; my apologies in advance if it's not the case... So, what I would do is rewrite the test.py script as follows: --- test.py ----------------------------------- def convert_file(filename, new_file): f = open(new_file, 'w') new = open(filename, 'r') for line in new: x = line.split('\t') print >> f, x[0],':', x[1] f.close() if __name__ == '__main__': filename = raw_input("Please enter the file you want to open: ") new_file = raw_input("Save the output file as: ") convert_file(filename, new_file) ----------------------------------------------- This is basically the same as yours in another order, and defining a function that actually does the 'functional' part without asking the user anything. The last block - starting with this weird 'if __name__ == '__main__':' - ensures the script will work as you expect when you run it alone on the command line (with 'python test.py'). This is the meaning of the test on __name__: this magical variable is set to the string '__main__' if and only if the current script is the top-most one, i.e the one you ran python on. So basically, the script now defines a function, then asks for the function parameters and calls it _only if run as the main script_. Try it; it should have the same behaviour as the script you've written. But the test on __name__ also allows to *import* this script as a module in another script without nasty side effects. This is done via the statement: import test in the other script. If test.py is written as above, this will execute the function definition, but not the body of the 'if', since test.py is no more run from the command line, but used in an import. If you didn't have this test, the module would have been *executed* by the import, and is would have asked the file names immediatly. Once you've done the import, you can then use the function it defines by calling test.convert_file. So now, in your GUI part, you can now write something like: --- menu.py ---------------------------------- ## NEW! the next line gets the 'convert_file' function import test from Tkinter import * ## NEW! the next line gets the functions used to get file names via a Tkinter GUI from tkFileDialog import askopenfilename, asksaveasfilename ## NEW! the following function is the callback for the 'Open' menu entry def open_callback(): ## Get name of the input file input_file_name = askopenfilename() if not input_file_name: ## Dialog has been cancelled return ## Get name for output file output_file_name = asksaveasfilename() if not output_file_name: ## Dialog has been cancelled return ## Do the job test.convert_file(input_file_name, output_file_name) def callback(): print "called the callback!" root = Tk() # create a menu menu = Menu(root) root.config(menu=menu) filemenu = Menu(menu) menu.add_cascade(label="File", menu=filemenu) filemenu.add_command(label="New", command=harold) ## CHANGED! put the callback function defined above here filemenu.add_command(label="Open...", command=open_callback) filemenu.add_separator() filemenu.add_command(label="Exit", command=callback) helpmenu = Menu(menu) menu.add_cascade(label="Help", menu=helpmenu) helpmenu.add_command(label="About...", command=callback) mainloop() ---------------------------------------------- Try it: it should basically do what you were asking for. HTH -- python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])" From szport at gmail.com Thu Apr 3 09:53:11 2008 From: szport at gmail.com (Zaur Shibzoukhov) Date: Thu, 3 Apr 2008 17:53:11 +0400 Subject: Application of "with" statement in py3k. Property defining/redefining. Message-ID: http://szport.blogspot.com/2008/04/application-of-with-statement-in-py3k.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From cocoa at khiltd.com Sat Apr 12 22:59:27 2008 From: cocoa at khiltd.com (Nathan Duran) Date: Sat, 12 Apr 2008 19:59:27 -0700 Subject: Advice on tools/technologies/books, etc. In-Reply-To: References: Message-ID: <022CE681-D9F5-4BAC-BAE5-A68481A306AA@khiltd.com> On Apr 12, 2008, at 6:55 PM, python-list-request at python.org wrote: > Will it be possible for me to put together an async site > with only python? Nope. Not until some browser embeds a Python interpreter in it anyway. Your primary choices are JavaScript and Flash. From kyosohma at gmail.com Wed Apr 16 11:23:50 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 16 Apr 2008 08:23:50 -0700 (PDT) Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> Message-ID: <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> On Apr 16, 10:09 am, Steve Holden wrote: > Mike Driscoll wrote: > > On Apr 16, 9:19 am, Grant Edwards wrote: > >> This morning almost half of c.l.p was spam. In order to try to > >> not tar both the benign google group users and the malignant > >> ones with the same brush, I've been trying to kill usenet spam > >> with subject patterns. But that's not a battle you can win, so > >> I broke down and joined all the other people that just killfile > >> everything posted via google.groups. > > >> AFAICT, if you're a google groups user your posts are not being > >> seen by many/most experienced (read "non-google-group") users. > >> This is mainly the fault of google who has refused to do > >> anything to stem the flood of span that's being sent via Google > >> Groups. > > >> -- > >> Grant Edwards grante Yow! I would like to > >> at urinate in an OVULAR, > >> visi.com porcelain pool -- > > > Yeah, I noticed that Google Groups has really sucked this week. I'm > > using the Google Groups Killfile for Greasemonkey now and it helps a > > lot. I like Google, but my loyalty only goes to far. This is a > > complete lack of customer service. > > Unfortunately this means Google groups users are getting exactly the > service they are paying for. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ Steve, My workplace doesn't offer NNTP, so there is no good way to browse c.l.py here. And I haven't been able to get NNTP to work from my home either. By applying this logic to Python and Linux (or any Open Source product), they shouldn't be used either (since I'm not paying for them). Mike From ajaksu at gmail.com Thu Apr 3 20:54:23 2008 From: ajaksu at gmail.com (ajaksu) Date: Thu, 3 Apr 2008 17:54:23 -0700 (PDT) Subject: displaying execution of Python code References: <1afcbf34-0a40-4d11-b12f-603f0ee8f26c@m3g2000hsc.googlegroups.com> Message-ID: On Apr 3, 6:13?pm, noahwatkins wrote: > I'll start my question by describing my desired result. I will > construct a GUI which will be used to open a Python script. I would > then like to be able to display the Python script, execute it, and > highlight the lines of the Python as they are executing. Take a look at http://codeinvestigator.googlepages.com/main From greg.jandl at gmail.com Thu Apr 24 09:36:47 2008 From: greg.jandl at gmail.com (Greg J) Date: Thu, 24 Apr 2008 06:36:47 -0700 (PDT) Subject: Curious relation References: <613aa1f7-3943-4458-ba7e-4cb29c562988@y21g2000hsf.googlegroups.com> Message-ID: On Apr 24, 12:08 am, Dan Bishop wrote: > On Apr 23, 11:51 pm, Greg J wrote: > > > I was reading the programming Reddit tonight and came across this > > (http://reddit.com/info/6gwk1/comments/): > > > >>> ([1]>2)==True > > True > > >>> [1]>(2==True) > > True > > >>> [1]>2==True > > > False > > > Odd, no? > > > So, can anyone here shed light on this one? > > A long time ago, it wasn't possible for comparison operators to raise > exceptions, so it was arbitrarily decided that numbers are less than > strings. Thus, [1]>2 and [1]>False. This explains your first two > examples. Sure, those I understood. > For the third, remember that the comparison operators are chained, so > a>b==c means (a>b) and (b==c). Since 2==True is false, so is the > entire expression. Ach! Of course. For some reason I was blanking on the chained nature of relational operators in Python. Thanks for the reminder! > > In Python 3.0, all three of these expressions will raise a TypeError. From mfb.chikazuku at gmail.com Sun Apr 13 14:11:34 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Sun, 13 Apr 2008 20:11:34 +0200 Subject: urllib2 Basic authentication, what am I doing wrong? Message-ID: <48025b26$0$6839$2d805a3e@textnews.eweka.nl> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hey everybody, I'm having a little problem with urllib2 and Basic HTTP authentication. I have the following code: auth = urllib2.HTTPPasswordMgrWithDefaultRealm() auth.add_password(None, 'https://webmail.osg-erasmus.nl/oneNet/NetStorage/', user, password) authhandler = urllib2.HTTPBasicAuthHandler(auth) opener = urllib2.build_opener(auth) opener.addheaders = [('User-agent', 'Mozilla/5.0 Something/1.0')] try: return self.opener.open('https://webmail.osg-erasmus.nl/oneNet/NetStorage/') except urllib2.HTTPError, e: print e.code print e.headers This however does not allow me to authenticate. I keep getting back a 401: 401 Date: Sun, 13 Apr 2008 18:11:32 GMT Server: Apache/2.0.54 (NETWARE) mod_perl/1.99_12 Perl/v5.8.4 PHP/5.0.5 mod_nsn/1.0_0 mod_jk/1.2.14 Set-Cookie: novellsession1=8KuAO0iLyAEAAAAAAAAAAA==; path=/ WWW-Authenticate: Basic realm="ERASMUS-TREE" Vary: accept-language,accept-charset Accept-Ranges: bytes Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1 Content-Language: en Using this nice class (adapted to urllib2) as a basehandler I see that no Authentication-header is being send out: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440574 What am I doing wrong here? I spend almost my entire free time today on this and couldn't find any problem with my code, anyone else has a thought? Thanks in advance. MFB -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFIAkzaDpaqHmOKFdQRAh8WAJ0XbQD5EEmKxVdjndRWWzjwZzWaAgCgjdhR Esk6VBkZ+bEHsxFhg8h3Sy4= =XWrv -----END PGP SIGNATURE----- From esj at harvee.org Fri Apr 4 00:35:08 2008 From: esj at harvee.org (Eric S. Johansson) Date: Fri, 04 Apr 2008 00:35:08 -0400 Subject: Unicode conversion problem (codec can't decode) Message-ID: <47F5AFFC.3060902@harvee.org> I'm having a problem (Python 2.4) converting strings with random 8-bit characters into an escape form which is 7-bit clean for storage in a database. Here's an example: body = meta['mini_body'].encode('unicode-escape') when given an 8-bit string, (in meta['mini_body']), the code fragment above yields the error below. 'ascii' codec can't decode byte 0xe1 in position 13: ordinal not in range(128) the string that generates that error is:
Reduce Wh?t You Owe by 50%. Get out of debt today!
Reduuce Interest & |V|onthlyy Payme?ts Easy, we will show you how..
Freee Quote in 10 Min.
http://www.freefromdebtin.net.cn I've read a lot of stuff about Unicode and Python and I'm pretty comfortable with how you can convert between different encoding types. What I don't understand is how to go from a byte string with 8-bit characters to an encoded string where 8-bit characters are turned into two character hexadecimal sequences. I really don't care about the character set used. I'm looking for a matched set of operations that converts the string to a seven bits a form and back to its original form. Since I need the ability to match a substring of the original text while the string is in it's encoded state, something like Unicode-escaped encoding would work well for me. unfortunately, I am missing some knowledge about encoding and decoding. I wish I knew what cjson was doing because it does the right things for my project. It takes strings or Unicode, stores everything as Unicode and then returns everything as Unicode. Quite frankly, I love to have my entire system run using Unicode strings but again, I missing some knowledge on how to force all of my modules to be Unicode by default any enlightenment would be most appreciated. ---eric -- Speech-recognition in use. It makes mistakes, I correct some. From skanemupp at yahoo.se Thu Apr 10 06:54:59 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 03:54:59 -0700 (PDT) Subject: questions about Exceptions? References: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> <71cc8c25-f5f9-4f21-a9d8-06780bf97608@f63g2000hsf.googlegroups.com> <9af81b1a-3e02-4406-b9d2-0a9b6f46566b@p39g2000prm.googlegroups.com> <0e586d5d-6799-433f-b8a4-4de5d2a87b61@h1g2000prh.googlegroups.com> <46a79564-4069-46af-b6ab-b38bd9152c2a@d45g2000hsc.googlegroups.com> Message-ID: <1f413b6e-f964-4f8d-b781-61985f86acc2@a9g2000prl.googlegroups.com> On 10 Apr, 12:38, cokofree... at gmail.com wrote: > > def Calc(): > > global nbr > > try: > > print eval(nbr) > > #a = Label(mygui, text=eval(nbr)) > > #a.place(relx=0.4, rely=0.1, anchor=CENTER) > > except: > > print "Not computable" > > nbr = "" > > > def Erase(): > > global nbr > > nbr = "" > > Seems to me you could be better off passing a parameter and a return > statement of None (or your parameter cleaned) for those functions, > which should work. Given an input, Eval it and then return None. That > way you wouldn't need the Erase... the erase() id alwys need if u wanna abort whilst u wrote something. From dieter at handshake.de Mon Apr 28 13:10:16 2008 From: dieter at handshake.de (Dieter Maurer) Date: 28 Apr 2008 19:10:16 +0200 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> Message-ID: Nick Stinemates writes on Thu, 24 Apr 2008 08:26:57 -0700: > On Tue, Apr 22, 2008 at 04:07:01AM -0700, GD wrote: > > Please remove ability to multiple inheritance in Python 3000. I hope your request will not be followed. > > Multiple inheritance is bad for design, rarely used and contains many > > problems for usual users. Multiple inheritance is very productive by supporting mixin classes. I use it extensively and get clean code quickly developped. I hate Java because it does not support multiple inheritance and forces me to write lots of tedious error prone delegations to work around this limitation. Dieter From gagsl-py2 at yahoo.com.ar Tue Apr 1 13:37:44 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 14:37:44 -0300 Subject: Adding Images to MySQL References: <4dc0cfea0804010536q71bce9ev38cff43923f5a4b8@mail.gmail.com> Message-ID: En Tue, 01 Apr 2008 09:36:00 -0300, Victor Subervi escribi?: > Hi; > I?m trying to figure out how to upload images into a MySQL database. > (Yes, > that is what I want to do.) I have a form that asks for data, like this: > 1ra Foto Peque?a: > > Then I send that form to a python script that processes like this: > cursor.execute('insert into products (' + col_names + ') values (' + > col_values + ');') > where col_names is all the names of the columns and col_values, > obviously, > the values. Works fine for strings and digits. Not so well for files :) > What > do? Always use bound parameters - not only it's easier and less error prone, it's safer too. How parameters are specified depends on the DBAPI module you're using - read the module documentation. I think MySQLdb accept dictionary-like marks: values = {'name': 'Red jar', 'descr': 'A nice red jar', 'pic': binary(picdata) } cursor.execute('''insert into products (name,description,picture) values (%(name)s, %(descr)s, %(pic)s);''', values) See PEP249 http://www.python.org/dev/peps/pep-0249/ and the documentation for your database module. -- Gabriel Genellina From dboddie at trolltech.com Tue Apr 1 09:42:07 2008 From: dboddie at trolltech.com (David Boddie) Date: Tue, 1 Apr 2008 15:42:07 +0200 Subject: PyQt - How to prevent a dialog being resized? Message-ID: <200804011542.07392.dboddie@trolltech.com> On Apr 1, 12:12 am, Kelie wrote: > > My question is as subject. I tried something like this and it doesn't > > work. > > > > def resizeEvent(self, event): > > self.size = event.oldSize() > > > > Any hint? > > If you use the Qt designer you can set the minimum- and maximum window > size to the same value, which disables resize as well. Tested with Qt4 > on Linux 2.6. But I'm pretty sure that there could be a much cleaner > way to do this. You can give a window a fixed size by calling its setFixedSize() method, but this requires you to decide its exact size in pixels. A better alternative is to call setSizeConstraint() on the window's layout with a value of SetFixedSize: http://www.riverbankcomputing.com/Docs/PyQt4/html/qlayout.html#SizeConstraint-enum This way, the layout will figure out how much space the window requires and force it to remain at that size from then on. David -- David Boddie Lead Technical Writer, Trolltech ASA From sjmachin at lexicon.net Mon Apr 7 05:17:24 2008 From: sjmachin at lexicon.net (John Machin) Date: Mon, 7 Apr 2008 02:17:24 -0700 (PDT) Subject: Python Data Utils References: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> <8eec6557-784d-4fd8-8478-8da17aedf0ab@d1g2000hsg.googlegroups.com> <85979669-64ed-49a1-b154-595bed50179f@w5g2000prd.googlegroups.com> <204305df-2cc8-4f44-8b98-5696e135a936@d45g2000hsc.googlegroups.com> Message-ID: On Apr 7, 4:22?pm, Jesse Aldridge wrote: > > > changing "( " to "(" and " )" to ")". > > Changed. But then you introduced more. > > I attempted to take out everything that could be trivially implemented > with the standard library. > This has left me with... 4 functions in S.py. ?1 one of them is used > internally, and the others aren't terribly awesome :\ ?But I think the > ones that remain are at least a bit useful :) If you want to look at stuff that can't be implemented trivially using str/unicode methods, and is more than a bit useful, google for mxTextTools. > > > A basic string normalisation-before-comparison function would > > usefully include replacing multiple internal whitespace characters by > > a single space. > > I added this functionality. Not quite. I said "whitespace", not "space". The following is the standard Python idiom for removing leading and trailing whitespace and replacing one or more whitespace characters with a single space: def normalise_whitespace(s): return ' '.join(s.split()) If your data is obtained by web scraping, you may find some people use '\xA0' aka NBSP to pad out fields. The above code will get rid of these if s is unicode; if s is str, you need to chuck a .replace('\xA0', ' ') in there somewhere. HTH, John From fredrik at pythonware.com Sat Apr 5 11:09:50 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 17:09:50 +0200 Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! In-Reply-To: References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <65ondkF2g48puU2@mid.uni-berlin.de> Message-ID: skanemupp at yahoo.se wrote: >> def __init__(self): >> # ... >> button = Button(self, >> text='1', >> command=lambda n=1: self.display(n)) >> # ... >> >> def display(self, number): >> print number > > should this really be inside the __init__ function? what's wrong with creating widgets in an __init__ method? From fredri8758lupo at gmail.com Wed Apr 23 06:08:11 2008 From: fredri8758lupo at gmail.com (fredri8758lupo at gmail.com) Date: Wed, 23 Apr 2008 03:08:11 -0700 (PDT) Subject: windows xp pro cracks Message-ID: <3f124f94-f708-4fb8-bb17-a71ed1fbbebb@t63g2000hsf.googlegroups.com> windows xp pro cracks http://cracks.12w.net F R E E C R A C K S From simon at brunningonline.net Tue Apr 8 06:29:41 2008 From: simon at brunningonline.net (Simon Brunning) Date: Tue, 8 Apr 2008 11:29:41 +0100 Subject: Learning curve for new database program with Python? In-Reply-To: References: Message-ID: <8c7f10c60804080329k7e6540fdre71adc8fe4383366@mail.gmail.com> On Mon, Apr 7, 2008 at 7:19 PM, Gary Duzan wrote: > It seems to me that ORM can work if your database isn't too > complex and it is the only way your database is going to be accessed. I'm working on a big, complex system using an ORM at the moment - http://gu.com. It's a Java/Hibernate/Spring system rather than anything Python based, but the principle is the same. We find that the ORM works great for 99% of our DB interaction, and saves a lot of tedious fiddling around. *But*, the 1% is crucial. Using an ORM doesn't mean you don't have to understand what's going on underneath. When you need to hand craft a performance critical query, or when you are chasing down a bug, you need to know SQL, and know it well. C.F. The Law of Leaky Abstractions - http://tinyurl.com/bmvn. It's not either SQL or ORM. It's both. But SQL should come first. -- Cheers, Simon B. simon at brunningonline.net http://www.brunningonline.net/simon/blog/ GTalk: simon.brunning | MSN: small_values | Yahoo: smallvalues From gabriel.rossetti at mydeskfriend.com Tue Apr 8 03:50:52 2008 From: gabriel.rossetti at mydeskfriend.com (Gabriel Rossetti) Date: Tue, 08 Apr 2008 09:50:52 +0200 Subject: Destructor? In-Reply-To: <47FB1EA8.6000801@mattnordhoff.com> References: <47FB1937.5050008@mydeskfriend.com> <47FB1E5E.6010708@mattnordhoff.com> <47FB1EA8.6000801@mattnordhoff.com> Message-ID: <47FB23DC.2040109@mydeskfriend.com> Matt Nordhoff wrote: > Matt Nordhoff wrote: > >> Gabriel Rossetti wrote: >> >>> Hello everyone, >>> >>> we are writing an application that needs some cleanup to be done if the >>> application is quit, normally (normal termination) or by a signal like >>> SIGINT or SIGTERM. I know that the __del__ method exists, but unless I'm >>> mistaken there is no guarantee as of when it will be called, and some >>> objects may have already been released (at lease I've had trouble in the >>> past accessing certain objects from inside __del__, probably since the >>> parent class's __del__ has to be called first, then it's objects are >>> already released by the time I need to do something with them). Another >>> method would be to implement something using the signal module and have >>> a callback that does all the cleanup when the app. is >>> quit/terminated/interrupted and have all the child classes override that >>> with their cleanup code. >>> >>> What is the community's point of view on the subject? >>> >>> Thanks, >>> Gabriel >>> >> atexit? >> >> If it's only small things, there's try...finally, of course.. >> > > Huh, I totally didn't know that atexit is only run on normal > terminations. Oops. Never mind. > Yes, and I just saw that windows (my app has to support Linux, Mac OS X and Windows) does not know about SIGINT and SIGTERM is apparently there for ANSI compatibility by an app has to explicitly raise it...every line of code I right I had windows more and more.... From nagle at animats.com Sat Apr 5 21:31:52 2008 From: nagle at animats.com (John Nagle) Date: Sat, 05 Apr 2008 18:31:52 -0700 Subject: Learning curve for new database program with Python? In-Reply-To: References: Message-ID: <47f82573$0$36352$742ec2ed@news.sonic.net> Jetus wrote: > I have a need for a database program. I downloaded the db2 from ibm, > and reviewed some of the documentation. > > My question is, what is the easiest program for me to try to learn. I > will be creating a database of about 25,000 records, it will be > relational. I am a beginner Python programmer, and need a database > solution that is easy to grasp. I played with sql, > and found that very difficult, if not overly cumbersome. Basic SQL isn't that hard. Learn CREATE, SELECT, INSERT, UPDATE, and DELETE syntax. That's enough for most simple applications. I'd suggest using sqlite if you're doing something that runs as a single standalone application, and MySQL if there are multiple users of the database or it's a web service. IBM's DB2 or Oracle is overkill for 25,000 records. Install MySQL and its graphical client, and play with it a bit. Create a table, type in a few records, and try various SELECT statements. That will give you a sense of how SQL works. John Nagle From ellingt8877 at gmail.com Mon Apr 28 01:45:23 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:45:23 -0700 (PDT) Subject: quickbooks premier 2007 registration crack Message-ID: <6dd92209-23f9-4619-94b3-f9803cb5d25a@34g2000hsf.googlegroups.com> quickbooks premier 2007 registration crack http://crack.cracksofts.com From kenneth.m.mcdonald at sbcglobal.net Sun Apr 20 21:58:06 2008 From: kenneth.m.mcdonald at sbcglobal.net (Kenneth McDonald) Date: Sun, 20 Apr 2008 20:58:06 -0500 Subject: Python script to automate use of Google Translate? (or other translator) Message-ID: <0FF8C4DE-8FBC-40C5-85B8-E10DD86F4CE7@sbcglobal.net> I have the need to occasionally translate a single word programatically. Would anyone have a Python script that would let me do this using Google (or another) translation service? Thanks, Ken From huayang.xia at gmail.com Thu Apr 10 17:45:04 2008 From: huayang.xia at gmail.com (Huayang Xia) Date: Thu, 10 Apr 2008 14:45:04 -0700 (PDT) Subject: Convert PyIDispatch object to struct IDispatch* Message-ID: <90eee1e1-b1cc-48a9-8c09-173e92861f2c@a5g2000prg.googlegroups.com> I am trying to use ctypes to call dll functions. One of the functions requires argument "struct IDispatch* ". I do have a PyIDispatch object in python. How can I convert this "PyIDispatch object" to "struct IDispatch* "? Thanks in advance. From torriem at gmail.com Tue Apr 15 16:16:20 2008 From: torriem at gmail.com (Michael Torrie) Date: Tue, 15 Apr 2008 14:16:20 -0600 Subject: Java or C++? In-Reply-To: <525142.84411.qm@web39208.mail.mud.yahoo.com> References: <525142.84411.qm@web39208.mail.mud.yahoo.com> Message-ID: <48050D14.6040801@gmail.com> Ben Kaplan wrote: > The fact that C# is a .NET language is also a major weakness, since you can only use it on Windows. Really? I have developed several C# .NET applications and I only use OS X and Linux. Guess I imagined it. Also, IronPython runs very well on Linux and OS X. If you'd said that the weakness was a patent minefield when running on a non-windows platform, then I'd totally agree with you. From sturlamolden at yahoo.no Fri Apr 25 15:56:21 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 25 Apr 2008 12:56:21 -0700 (PDT) Subject: Calling Python code from inside php References: Message-ID: <2327c134-a9e5-4e7f-8b7a-ccd6e080bd20@y38g2000hsy.googlegroups.com> On Apr 23, 9:08 pm, MC wrote: > If you are under Windows, you can: > - call Python's functions via Active-Scripting > - call a Python COM server (functions or properties) > > For that, use Pywin32. And, in all cases, call functions can use > parameters. This is perhaps the preferred solution if the web server is IIS and not Apache. From jeffrey at fro.man Thu Apr 10 19:49:02 2008 From: jeffrey at fro.man (Jeffrey Froman) Date: Thu, 10 Apr 2008 16:49:02 -0700 Subject: Adding classes to modules at runtime from outside that module References: Message-ID: frambooz at gmail.com wrote: > In Python, is it possible to add classes to a module at run-time? > > Say I have a module foo and a module bar. Foo has class A and B, and > bar has class C. I want to add class C to foo so I can access it as > foo.C, but i want to do it without modifying foo's source. > > Is this at all possible? Yes, possible and easy: # bar.py import foo class C(object): ... foo.C = C Jeffrey From mnordhoff at mattnordhoff.com Mon Apr 7 03:13:47 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Mon, 07 Apr 2008 07:13:47 +0000 Subject: Help replacing os.system call with subprocess call In-Reply-To: <47F9C764.9070401@mattnordhoff.com> References: <47F9B1D1.4090701@eastlink.ca> <47F9C764.9070401@mattnordhoff.com> Message-ID: <47F9C9AB.3070608@mattnordhoff.com> Matt Nordhoff wrote: > David Pratt wrote: >> Hi. I am trying to replace a system call with a subprocess call. I have >> tried subprocess.Popen and subprocess.call with but have not been >> successful. The command line would be: >> >> svnadmin dump /my/repository > svndump.db >> >> This is what I am using currently: >> >> os.system('svnadmin dump %s > %s' % (svn_dir, >> os.path.join(backup_dir, 'svndump.db'))) >> >> Many thanks. > > Try this: > > import os.path > import subprocess > > p = subprocess.Popen( > ['svnadmin', 'dump', svndir], > stdout=subprocess.PIPE, > ) > > fh = open(os.path.join(backup_dir, 'svndump.db'), 'wb') > > while True: > chunk = p.stdout.read(2**20) # 1 MB > if not chunk: > break > fh.write(chunk) > > fh.close() > > It reads svnadmin's stdout in 1 MB chunks, in case it's large enough > that reading the whole thing into RAM at once would be a bad idea. > > No error handling. For one, you might want to add a try...finally to > ensure that fh will get closed. (Or if you have Python 2.5, use a with > statement! :-) ) Also, Popen will raise an OSError if svnadmin can't be > found or something. And this isn't even considering svnadmin erroring out... > > svnadmin's stderr will go to your stderr. > > I didn't test it, but I'm pretty sure it will work. (I spotted a syntax > error while writing that though.) I don't have much experience with > Popen's stdio objects, so it's possible you'd need to do something like > call p.wait() to wait for it to exit before being able to read its stdout. > > It could be slower than the os.system version, since now Python is doing > all of the I/O, instead of your shell, but I doubt that'll be a big problem. > > (Also, insert suggestion about using a good VCS. ;-) ) This might work too: import os.path import subprocess fh = open(os.path.join(backup_dir, 'svndump.db'), 'wb') p = subprocess.Popen( ['svnadmin', 'dump', svndir], stdout=fh, ) # Wait for svnadmin to exit so that fh can be closed p.wait() fh.close() With this, svnadmin's stdout is directly set to the file. Python isn't being an intermediary reading from stdout and writing it to the file. At least, that's how I expect it would work. I didn't test this either. In particular, if Popen doesn't behave how I expect it should, it might buffer the entirety of stdout in memory or something, which would be bad if your svn repo is really large... -- From torriem at gmail.com Wed Apr 16 16:24:52 2008 From: torriem at gmail.com (Michael Torrie) Date: Wed, 16 Apr 2008 14:24:52 -0600 Subject: Finally had to plonk google gorups. In-Reply-To: References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: On Wed, Apr 16, 2008 at 11:49 AM, Mike Driscoll wrote: > I don't think I like the email list idea all that much. I'm already on > a number of them and they fill up my box like crazy. Besides that, in > email format it's hard to follow the thread, so one moment I'm reading > about the latest ding dong and the next is a response to a post from > last week. Using a good client like Thunderbird, and e-mails thread just fine. Nesting as deep as need be. On my client (I use thunderbird for everything), it looks the same whether I use NNTP or mailing lists. It's all good. As for filling up your inbox, that never happens to me. My inbox gets maybe 1 new message a day. Everything else is automatically filed into the right folder, just like how NNTP shows you individual groups. Gmail makes this very easy to do with their filters. For others there is procmail. Honestly a few minutes of work is very much worth it. For those that want to keep using nntp and put up with the spam (no server-side spam processing there), that's great, though. Finally as for threading being difficult, yes it is if you use GMail's web client. "Conversations" are *not* threads, sadly. It's a broken interface that's becoming popular unfortunately. I've always hated web forums for the same reasons. Conversations also don't deal very well with changes in the subject line that reflect new directions or forks in the current topic. > But I agree...there are other alternatives. I'll have to start trying > them again I suppose. If I have to, I guess. :) From bhawsar.vaibhav at gmail.com Fri Apr 25 02:58:53 2008 From: bhawsar.vaibhav at gmail.com (Vaibhav.bhawsar) Date: Fri, 25 Apr 2008 02:58:53 -0400 Subject: how to mysqldb dict cursors In-Reply-To: <481161FD.5020407@ulmcnett.com> References: <17d58cc40804241950i7b624e1apd2733daa79b3ed5c@mail.gmail.com> <481161FD.5020407@ulmcnett.com> Message-ID: <17d58cc40804242358s26446c42h36f875cf0ee62199@mail.gmail.com> Great both methods worked! I dont quite understand this since i imported the whole module with "import MySQLdb" Thanks! On Fri, Apr 25, 2008 at 12:45 AM, Paul McNett

wrote: > Vaibhav.bhawsar wrote: > >> I have been trying to get the DictCursor working with mysqldb module but >> can't seem to. I have pasted the basic connection code and the traceback >> from pydev. The connection does open with the default cursor class. can't >> figure this one out. many thanks. >> > > Try one of: > > """ > import MySQLdb, MySQLdb.cursors > conn = MySQLdb.connect(..., cursorclass=MySQLdb.cursors.DictCursor) > """ > > -or- > > """ > import MySQLdb, MySQLdb.cursors > conn = MySQLdb.connect(...) > cur = MySQLdb.cursors.DictCursor(conn) > """ > > I'm going off of memory here, though, but I'm at least close. > > Paul > > -- Vaibhav Bhawsar -------------- next part -------------- An HTML attachment was scrubbed... URL: From rbrito at ime.usp.br Mon Apr 28 16:44:41 2008 From: rbrito at ime.usp.br (=?ISO-8859-1?Q?Rog=E9rio_Brito?=) Date: Mon, 28 Apr 2008 17:44:41 -0300 Subject: Little novice program written in Python References: Message-ID: On 04/25/2008 01:09 AM, Dennis Lee Bieber wrote: > On Thu, 24 Apr 2008 21:31:15 -0300, Rog?rio Brito > declaimed the following in comp.lang.python: >> a = [i for i in range(0,n+1)] > > Uhm... At least in 2.4 and earlier, range() returns a list... No > need for the list-comp in that era... range() also begins with 0 Thanks for the suggestion. As I stated in my original message, I'm only "side-learning" Python, and I naturally think in list-comprehensions (it is like a set in Mathematics and you've seen that my program is Mathematical in its nature). This is exactly the kind of suggestion that I was looking for. Thanks, Rog?rio. -- Rog?rio Brito : rbrito@{mackenzie,ime.usp}.br : GPG key 1024D/7C2CAEB8 http://www.ime.usp.br/~rbrito : http://meusite.mackenzie.com.br/rbrito Projects: algorithms.berlios.de : lame.sf.net : vrms.alioth.debian.org From john106henry at hotmail.com Sun Apr 27 00:01:51 2008 From: john106henry at hotmail.com (John Henry) Date: Sat, 26 Apr 2008 21:01:51 -0700 (PDT) Subject: How do I say "Is this a function"? References: <4813D22A.8040902@v.loewis.de> Message-ID: On Apr 26, 6:08?pm, "Martin v. L?wis" wrote: > > def f1(): > > ? ?print "In f1" > > > def f3(): > > ? ?print "In f3" > > > def others(): > > ? ?print "In others" > > > for i in xrange(1,3): > > ? ?fct = "f%d()"%(i+1) > > ? ?try: > > ? ? ? exec fct > > ? ?except: > > ? ? ? others() > > I'd write that as > > for i in xrange(1,3): > ? ? globals().get("f%d" % (i+1), others)() > > Regards, > Martin Perfect. Works great. No EXEC. You guys are great. From leoniaumybragg at gmail.com Sat Apr 26 06:58:13 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:58:13 -0700 (PDT) Subject: investronica crack Message-ID: <0be60373-ed63-4a3d-8559-125db03332b9@a22g2000hsc.googlegroups.com> investronica crack http://cracks.00bp.com F R E E C R A C K S From skanemupp at yahoo.se Wed Apr 16 09:00:08 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Wed, 16 Apr 2008 06:00:08 -0700 (PDT) Subject: py2exe, program has stoped working!? References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> <232151d6-09ed-4a1e-9922-d66c2bf0d05b@w8g2000prd.googlegroups.com> Message-ID: <06add3fd-3ff9-4dce-8d33-6bc92f36b5d8@26g2000hsk.googlegroups.com> On 14 Apr, 14:11, John Machin wrote: > On Apr 14, 7:24 pm, skanem... at yahoo.se wrote: > > > > > > Is it a console program or a gui program? > > GUI > > > What happens when you run it without py2exe? > > > it works perfectly, both from within python and launching from > > "windows" > > > > Have you searched for "has stopped working" in > > > (a) your source code > > yes no such message there> (b) the py2exe source code? > > > no, will do but doubt thats the problem > > > > Have you managed to get any py2exe-created program to run properly? > > > no > > Well, perhaps you might like to look in the samples directory of the > py2exe distribution and choose a simple example and try that. > > By the way, "popup" is what you get in a web browser. What did this > "popup" look like: a panel from your GUI software? A Windows message > box? Did it have a title across the top? What was the exact text in > the popup/panel/box? Were there any options other than to close the > window? > > Which version of Python? Which Windows, what service pack? What GUI, > what version? Care to divulge the contents of your setup.py? Apart > from your GUI, what 3rd party packages/modules are you importing? its a windows message as others have said. only option to close the window. 2.5python windows vista tkinter GUI im importing tkinter and from future import division From george.sakkis at gmail.com Tue Apr 22 10:36:04 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 22 Apr 2008 07:36:04 -0700 (PDT) Subject: Remove multiple inheritance in Python 3000 References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <6760jfF2n3bn1U1@mid.uni-berlin.de> Message-ID: <6bec3c67-689a-4df2-848f-d3936a143024@f36g2000hsa.googlegroups.com> On Apr 22, 10:22?am, Carl Banks wrote: > Java (for example) allows a class to share behavior with only one > other class, and that *severely* limits the opportunities to minimize > redundancy. Not really; composition is usually a better way to share functionality and reduce redundancy than inheritance. George From ridenour4159 at gmail.com Thu Apr 24 06:17:09 2008 From: ridenour4159 at gmail.com (ridenour4159 at gmail.com) Date: Thu, 24 Apr 2008 03:17:09 -0700 (PDT) Subject: the apple patch diet Message-ID: the apple patch diet http://cracks.12w.net F R E E C R A C K S From gh at gregor-horvath.com Fri Apr 25 14:59:20 2008 From: gh at gregor-horvath.com (Gregor Horvath) Date: Fri, 25 Apr 2008 20:59:20 +0200 Subject: Why is None <= 0 In-Reply-To: References: Message-ID: D'Arcy J.M. Cain schrieb: > On Fri, 25 Apr 2008 20:27:15 +0200 > Gregor Horvath wrote: >> >>> None <= 0 >> True >> >> Why? > > Why not? Because, from http://www.python.org/dev/peps/pep-0020/ : Errors should never pass silently. In the face of ambiguity, refuse the temptation to guess. Greg From cbhoem at gmail.com Mon Apr 28 09:42:30 2008 From: cbhoem at gmail.com (cbhoem at gmail.com) Date: Mon, 28 Apr 2008 06:42:30 -0700 (PDT) Subject: Cookie Confusion - How to Set a Cookie Message-ID: <588d6a6c-0080-48a4-b768-e2c5ef551790@s50g2000hsb.googlegroups.com> Hi - I am trying my hand at python cookies. I'm confused about a few things though. Do the python cookies get written to a cookies text file? I have simple code below -- I see the cookie in my HTTP header but do not get anything in the cookie text file. I'm working on linux. print "Content-type: text/html" cookie = Cookie.SimpleCookie() cookie['Test'] = 'abc' print cookie print Are there rules about where in the header the set cookie line should be? Thanks in advance! Christian From Robert.Bossy at jouy.inra.fr Tue Apr 8 11:40:06 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Tue, 08 Apr 2008 17:40:06 +0200 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. In-Reply-To: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> Message-ID: <47FB91D6.6040601@jouy.inra.fr> Hi, First thing, I appreciate (and I'm positive we all do) if you DID'N YELL AT ME. subhabrata.iisc at hotmail.com wrote: > I am using Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v. > 1310 32 bit (Intel)] on win32 with IDLE 1.2.1 > My O/S is Windows XP SP2 I use 512 MB RAM. > I am encountering the following problems: > (i) a1=1 > a2=2 > a3=a1+a2 > print a3 > # The result is coming sometimes as 3 sometimes as vague numbers. > On all computers I work with (two at work and one at home), it always gives me 3. > (ii) x1="Bangalore is called the Silicon Valley of India" > x2="NewYork" > x3=x1.find(x2) > print x3 > # The result of x3 is coming as -1 as well as +ve numbers. > On my computer, this always gives me -1 which is what I expected since x2 not in x1. Are you sure you posted what you wanted to show us? > (iii) I have been designing one crawler using "urllib". For crawling > one web page it is perfect. But when I am giving around 100 URLs by > and their links and sublinks the IDLE is not responding. Presently I > have been running with 10 URLs but can't it be ported? > Maybe you've implemented quadratic algorithms, or even exponential. Sorry, I cannot see without more specifics... > (iv) I have designed a program with more than 500 if elif else but > sometimes it is running fine sometimes it is giving hugely erroneous > results, one view of the code: > elif a4==3: > print "YOU HAVE NOW ENTERED THREE WORDS" > if a3[0] not in a6: > if a3[1] not in a6: > if a3[2] not in a6: > print "a3[0] not in a6, a3[1] not in a6, a3[2] not > in a6" > elif a3[2] in a6: > print "a3[0] not in a6, a3[1] not in a6, a3[2] in > a6" > else: > print "NONE3.1" > elif a3[1] in a6: > if a3[2] not in a6: > print "a3[0] not in a6, a3[1] in a6, a3[2] not in > a6" > elif a3[2] in a6: > print "a3[0] not in a6,a3[1] in a6, a3[2] in a6" > else: > print "NONE3.2" > else: > print "NONE3.3" > elif a3[0] in a6: > if a3[1] not in a6: > if a3[2] not in a6: > print "a3[0] in a6, a3[1] not in a6, a3[2] not in > a6" > elif a3[2] in a6: > print "a3[0] in a6, a3[1] not in a6, a3[2] in a6" > else: > print "NONE3.4" > elif a3[1] in a6: > if a3[2] not in a6: > print "a3[0] in a6, a3[1] in a6, a3[2] not in a6" > elif a3[2] in a6: > print "a3[0] in a6, a3[1] in a6, a3[2] in a6" > else: > print "NONE3.5" > else: > print "NONE3.6" > else: > print "NONE3.7" > I guess you're looking for one or several of three strings inside a longer string. The algorithm is quadratic, no wonder your software doesn't respond for larger datasets. Someone spoke about Aho-Corasick recently on this list, you should defenitely consider it. Moreover, the least we could say is that it doesn't loks pythonic, do you think the following does the same thing as your snip? L = [] for i, x in enumerate(a3): if x in a6: L.append('a3[%d] in a6' % i) else: L.append('a3[%d] not in a6' % i) print ', '.join(L) RB From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 24 04:46:25 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 24 Apr 2008 10:46:25 +0200 Subject: @classmethod question In-Reply-To: References: Message-ID: <481048cf$0$13051$426a74cc@news.free.fr> Scott SA a ?crit : > Hi, > > I'm using the @classemethod decorator for some convenience methods > and for some reason, either mental block or otherwise, can't seem to > figure out how to elegantly detect if the call is from an instance or > not. Well, the point is that a classmethod *always* receive the class as first argument, wether it's called on the class or an instance. If that's not what you want, then you don't use the right tool. > Here's the problem: Within the class definition, 'isinstance' has nothing to compare to because the class does not appear to exist. > > This is NOT a great example, but it outlines the the code: > > class RecipieClass: > def __init__(self): > pass > > @classmethod > def get_ingrendients(self, recipie_list=None): > > if isinstnace(self,RecipieClass): > return self.do_something_interesting() > else: > return do_something_boring(recipie_list) > > Yes, I can test to see if the param exists, but that makes the call > exclusive i.e. I can _only_ call it as an instance or with a parameter. > > Why am I doing this? > > It is a series of convenience methods, in this case I'm interacting > with a database via an ORM (object-relational model). out of curiosity : which one ? > I want the ability > to call a class-ojbect and get related values, or pass some criteria and > get related values for them without collecting the records first as > instances, then iterating them. I need to call this from several places > so I want to be DRY (don't repeat yourself). > > The easiest way to describe this as an analogy would be like having a > recipie for cookies and wanting to know all of the ingredients ahead of > time. Then, at another time, wanting to know what all the ingredients > would be to make cookies, cake and bread (i.e. complete shopping list). > cookie_recipie = RecipieClass.get_recipie('cookies') > cookie_recipie.get_ingredients() > 2C Flour > 0.5 C Sugar > ... > > RecipieClass.get_ingrendients(['cookies','cake','bread']) > 8C Flour > 2C Sugar > ... > Of course any suggestions on how this might be better approached would > be interesting too. Why do you want the same method to do two different things ? You clearly have two distincts methods doing different things here, and as a user of your code I'd find your API confusing. May I suggest a much simpler approach: class Recipies(object): @property def ingredients(self): return @classmethod def get_ingredients_for(cls, *id_recipies): return print Recipie.get('cookie').ingredients print Recipies.get_ingredients_for('cookie', 'cake', 'bread') My 2 cents... From arnodel at googlemail.com Sun Apr 20 02:17:58 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sat, 19 Apr 2008 23:17:58 -0700 (PDT) Subject: manipulating class attributes from a decorator while the class is being defined References: Message-ID: <1597dce1-a489-44e7-8f32-988a16243fd9@l64g2000hse.googlegroups.com> On Apr 19, 10:19?pm, Wilbert Berendsen wrote: > Hi, is it possible to manipulate class attributes from within a decorator > while the class is being defined? > > I want to register methods with some additional values in a class attribute. > But I can't get a decorator to change a class attribute while the class is > still being defined. Something like: > > class Parser(object): > > ? regexps = [] > ? def reg(regexp): > ? ? def deco(func): > ? ? ? regexps.append((regexp, func)) > ? ? ? return func > ? ? return deco > > ? @reg(r'".*"') > ? def quoted_string(self): > ? ? pass > > How can I reach the class attribute `regexps' from within a decorator? In this particular example, it is enought to change the line def reg(regexp): to: def reg(regexp, regexps=regexps): So that 'regexps' inside reg() will point to the same object as 'regexps' outside reg(). Of course it wouldn't work well with inheritance, but it seems to me that you don't want to subclass 'Parser' anyway. If you did, you could instead have something like this: class Ruleset(list): def add(self, regexp): def decorator(func): self.append((regexp, func)) return func return decorator class Parser(object): rules = Ruleset() @rules.add(r'".*"') def quoted_string(self): pass Or, yet another solution is to change the metaclass of 'Parser' so that it populates the class's rules by scanning its attributes. HTH -- Arnaud From darcy at druid.net Wed Apr 30 12:01:16 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Wed, 30 Apr 2008 12:01:16 -0400 Subject: Colors for Rows In-Reply-To: <4dc0cfea0804300857h6a7a8aa6l25aa0a3e82da12c0@mail.gmail.com> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> <20080429121105.f10c3862.darcy@druid.net> <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> <1209495803.5173.11.camel@aalcdl07.lib.unc.edu> <20080429153930.a6eddea6.darcy@druid.net> <1209500446.5510.4.camel@aalcdl07.lib.unc.edu> <4dc0cfea0804300857h6a7a8aa6l25aa0a3e82da12c0@mail.gmail.com> Message-ID: <20080430120116.c07f028f.darcy@druid.net> On Wed, 30 Apr 2008 10:57:44 -0500 "Victor Subervi" wrote: > Thank you all. You helped clean up my code. The stupid mistake was in where > I set the initial value of the variable z. Really? I thought that it was odd to start in the middle of your colour list but it didn't seem like it was an error. What do you think was wrong with it? -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From frikker at gmail.com Wed Apr 30 10:07:28 2008 From: frikker at gmail.com (blaine) Date: Wed, 30 Apr 2008 07:07:28 -0700 (PDT) Subject: I messed up my wxPython install (Eclipse Configuration Issue) Message-ID: <18eb0a7c-96f4-41de-b44f-95fd8ba0223f@f63g2000hsf.googlegroups.com> The wxPython group is a bit stale compared to this group, so I'll give it a shot :) (READ: Originally when I started htis post, Python 2.5 at the shell did not work (identical behavior to eclipse). I'm not sure why, but it has since worked fine with no problems. Not sure whats going on there... I didn't change anything. Anyways...) Ok so I am having this problem. I am using OS X 10.4. I use MacPython and installed wxPython a few months back, and it worked great. Well I haven't done any wx development lately, and now that I'm getting back into it I can't get wx to work properly. I'm using Eclipse, too. Python 2.5 at Shell: works just fine $ python >>> import wx OLD projects in Eclipse: import wx works fine NEW projects in Eclipse (since I have started working wx again after a few months): import wx /Users/frikk/Documents/workspace/Bili_UI/src/wx.py:3: DeprecationWarning: The wxPython compatibility package is no longer automatically generated or actively maintained. Please switch to the wx package as soon as possible. from wxPython.wx import * Traceback (most recent call last): File "/Users/frikk/Documents/workspace/Bili_UI/src/nokia_fkscrn.py", line 37, in import wx File "/Users/frikk/Documents/workspace/Bili_UI/src/wx.py", line 3, in from wxPython.wx import * File "//Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/wx-2.8-mac-ansi/wxPython/__init__.py", line 15, in import _wx File "//Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/wx-2.8-mac-ansi/wxPython/_wx.py", line 3, in from _core import * File "//Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages/wx-2.8-mac-ansi/wxPython/_core.py", line 15, in import wx._core ImportError: No module named _core I feel like this may be a path issue? Any ideas on what else to look for? Both sys.path statements are the same, and I'm not sure what else I could be causing it - some configuration perhaps in Eclipse that is not being set correctly for newer projects? I also choose 'Python 2.5' from in eclipse - and it points to the same location for both projects.. Path: >>> import sys >>> sys.path ['', '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ site-packages/setuptools-0.6c8-py2.5.egg', '/Library/Frameworks/ Python.framework/Versions/2.5/lib/python2.5/site-packages/ Pygments-0.9- py2.5.egg', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ python25.zip', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/plat-darwin', '/Library/Frameworks/Python.framework/ Versions/ 2.5/lib/python2.5/plat-mac', '/Library/Frameworks/Python.framework/ Versions/2.5/lib/python2.5/plat-mac/lib-scriptpackages', '/Library/ Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk', '/ Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib- dynload', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/site-packages', '/Library/Frameworks/Python.framework/ Versions/2.5/lib/python2.5/site-packages/wx-2.8-mac-ansi'] Any suggestions would be great - its probably something pretty minor... Thanks! Blaine From tjreedy at udel.edu Thu Apr 10 12:13:26 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 10 Apr 2008 12:13:26 -0400 Subject: How to find documentation about methods etc. for iterators References: <47fce941$0$755$bed64819@news.gradwell.net> <47fdceb8$0$754$bed64819@news.gradwell.net> Message-ID: wrote in message news:47fdceb8$0$754$bed64819 at news.gradwell.net... | Terry Reedy wrote: | > | > wrote in message | > news:47fce941$0$755$bed64819 at news.gradwell.net... | > | I'm not sure if I have even phrased that right but anyway.... | > | | > | How does one find (in the standard Python documentation) information | > | about things like the iteritems() method and the enumerate() function. | > | > The Library Reference manual sections on builtin functions and dict | > methods. | > | > Or, help(enumerate) and help({}.iteritems) | > | .... but that doesn't address my problem really, how do I know that I | need to look for the words enumerate and/or iteritems? This is what | my original question was about. Do what Gabriel said: read chapters 2 and 3 of the Lib Manual. You will not necessarily remember everything, but you will have an idea of what functionalities exist and know to go look again. In a few months, read them again. As for the stdlib, at least scan through the table of contents so you have a general idea of what there is. The documentation of modules (as well as of builtins) is much improved from 10 years ago, when the only doc for some was the code. tjr From jgardner at jonathangardner.net Tue Apr 8 18:01:57 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Tue, 8 Apr 2008 15:01:57 -0700 (PDT) Subject: Python 3.0 new integer division References: Message-ID: On Apr 8, 2:25?pm, Grzegorz S?odkowicz wrote: > > Isn't Decimal a BCD implementation? Yep, you are right and I am wrong. http://www.python.org/dev/peps/pep-0327/#why-not-rational From msh at blisses.org Sun Apr 20 19:46:10 2008 From: msh at blisses.org (Matt Herzog) Date: Sun, 20 Apr 2008 18:46:10 -0500 Subject: replacing text inplace Message-ID: <20080420234610.GE16190@chicago.blisses.org> Hey All. I'm learning some python with the seemingly simple task of updating a firewall config file with the new IP address when my dhcpd server hands one out. Yeah, I know it's dangerous to edit such a file "in place" but this is just an exercise at this point. I would not mind using file handles except they seem to add complexity. The only apparent problem I have with my script so far is that it's adding lots of blank lines to the file when it updates the IP addresses. There is only one dotted quad that needs changing in a file full of dotted quads and the dhcp lease lasts for months usually so I have no qualms about putting the old IP address in the file, i.e. I won't need to manually update it very often. The address apears on lines that looks like this: block in from 71.146.250.258/32 to any group 150 So "71.146.250.258" needs to change to "71.146.250.223" or something similar. Is there a saner, cleaner way to do this that won't add new, blank lines? Most of the examples on the Intertubes are about multiple files and STDIN. This is just one file and it needs one string changed on two or three lines. The script runs from cron, not interactively. ########################################################################### import sys import string import os import fileinput import re oldip = "71.146.250.258" ifcfg_lines = os.popen("/sbin/ifconfig eth0").readlines() newip = string.split(ifcfg_lines[1])[1][-11:] if newip == oldip: print "nevermind" else: for line in fileinput.FileInput("/etc/ipf.conf",inplace=1): line = line.replace(oldip,newip) print line -- "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too dark to read." -- Groucho Marx From bob at passcal.nmt.edu Fri Apr 18 15:57:56 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Fri, 18 Apr 2008 13:57:56 -0600 Subject: 2's complement conversion. Is this right? Message-ID: <2008041813575616807-bob@passcalnmtedu> I'm reading 3-byte numbers from a file and they are signed (+8 to -8million). This seems to work, but I'm not sure it's right. # Convert the 3-characters into a number. Value1, Value2, Value3 = unpack(">BBB", Buffer[s:s+3]) Value = (Value1*65536)+(Value2*256)+Value3 if Value >= 0x800000: Value -= 0x1000000 print Value For example: 16682720 = -94496 Should it be Value -= 0x1000001 so that I get -94497, instead? Thanks! Bob From ivan.illarionov at gmail.com Fri Apr 18 12:30:00 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Fri, 18 Apr 2008 16:30:00 +0000 (UTC) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: On Fri, 18 Apr 2008 07:16:35 -0700, Aaron Watters wrote: > The big deal is that I would love to see Django become the standard > platform for web development, for example. That will be much less > likely if 60% of the contributed tools for Django don't work for Python > 3000 and 20% don't work for Python 2.6. Expecting volunteer contributors > to support both is not realistic. It's hard enough to support one > adequately. Even if you could hope to support both with the same code, > just testing in both environments would be onerous. You shouldn't worry about Django. Python 3000 port has already started [1]. And the assumption that "to support both is not realistic" may be wrong [2] in this case. [1] http://wiki.python.org/moin/PortingDjangoTo3k [2] http://groups.google.com/group/django-developers/msg/91f399820ee07ce5 -- Ivan From jcd at unc.edu Wed Apr 30 13:35:20 2008 From: jcd at unc.edu (J. Cliff Dyer) Date: Wed, 30 Apr 2008 13:35:20 -0400 Subject: Custom Classes? In-Reply-To: <4dc0cfea0804300902o7493dab2m35999b5b59deace4@mail.gmail.com> References: <4dc0cfea0804300902o7493dab2m35999b5b59deace4@mail.gmail.com> Message-ID: <1209576920.4990.17.camel@aalcdl07.lib.unc.edu> On Wed, 2008-04-30 at 11:02 -0500, Victor Subervi wrote: > Hi; > I have the following code which produces a file every time I need to > display an image from MySQL. What garbage! Surely, python is capable > of better than this, but the last time I asked for help on it, I got > no responses. Is this only possible with custom classes? Please, give > me some guidance here! > try: > > w += 1 > > getpic = "getpic" + str(w) + ".py" > > try: > > os.remove(getpic) > > except: > > pass > > code = """ > > #!/usr/local/bin/python > > import cgitb; cgitb.enable() > > import MySQLdb > > import cgi > > import sys,os > > sys.path.append(os.getcwd()) > > from login import login > > user, passwd, db, host = login() > > form = cgi.FieldStorage() > > picid = int(form["id"].value) > > x = int(form["x"].value) > > pics = > {1:'pic1',2:'pic1_thumb',3:'pic2',4:'pic2_thumb',5:'pic3',6:'pic3_thumb',7:'pic4',8:'pic4_thumb',\ > > 9:'pic5',10:'pic5_thumb',11:'pic6',12:'pic6_thumb'} > > pic = pics[x] > > print 'Content-Type: text/html' > > db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > > cursor= db.cursor() > > sql = "select " + pic + " from products where id='" + str(picid) + > "';" > > cursor.execute(sql) > > content = cursor.fetchall()[0][0].tostring() > > cursor.close() > > print 'Content-Type: image/jpeg' > > print > > print content > > """ > > script = open(getpic, "w") > > script.write(code) > > print '' > % pic > > print '

\n' % (getpic, d, > y) > > > TIA, > Victor Victor, Once again, you've posted code that doesn't work. Your outer try block is never terminated, and w is never initialized (so will raise an exception inside your try block, which you probably won't see, if you catch all exceptions. Generally speaking, unless you know what you're trying to catch, it's better to leave off the try/except block, *especially* during development. Stack traces are full of good information. Second, you never initialize w, which causes the following problem. $ python Python 2.3.4 (#1, Nov 20 2007, 15:18:15) [GCC 3.4.6 20060404 (Red Hat 3.4.6-9)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> w += 1 Traceback (most recent call last): File "", line 1, in ? NameError: name 'w' is not defined >>> Third, double-spacing your code makes it difficult to read. Take out blank lines, unless they add contextual hints which improve readability. Post working code, and I'll answer your actual question. Cheers, Cliff > -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill From wwzaygvm at gmail.com Wed Apr 16 16:58:45 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 13:58:45 -0700 (PDT) Subject: trading software cracks Message-ID: trading software cracks http://cracks.12w.net F R E E C R A C K S From steve at holdenweb.com Tue Apr 8 10:19:26 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 10:19:26 -0400 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. In-Reply-To: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> Message-ID: subhabrata.iisc at hotmail.com wrote: > I am using Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v. > 1310 32 bit (Intel)] on win32 with IDLE 1.2.1 > My O/S is Windows XP SP2 I use 512 MB RAM. > I am encountering the following problems: > (i) a1=1 > a2=2 > a3=a1+a2 > print a3 > # The result is coming sometimes as 3 sometimes as vague numbers. > Sorry, this just isn't true. There is no known implementation for which 1+2 does not equal 3. > (ii) x1="Bangalore is called the Silicon Valley of India" > x2="NewYork" > x3=x1.find(x2) > print x3 > # The result of x3 is coming as -1 as well as +ve numbers. > Presumably you get -1 when the substring isn't found. Look at the documentation of str.find() to discover *why* this happens. > (iii) I have been designing one crawler using "urllib". For crawling > one web page it is perfect. But when I am giving around 100 URLs by > and their links and sublinks the IDLE is not responding. Presently I > have been running with 10 URLs but can't it be ported? > Not enough information. "I have a program, please tell me waht is wrong with it" overtaxes even this group's psychic abilities. > (iv) I have designed a program with more than 500 if elif else but > sometimes it is running fine sometimes it is giving hugely erroneous > results, one view of the code: I am afraid that for code like this "designed" is far too kind a term. I would have suggested "thrown together". On what analysis of your problem was this solution based? > elif a4==3: > print "YOU HAVE NOW ENTERED THREE WORDS" > if a3[0] not in a6: > if a3[1] not in a6: > if a3[2] not in a6: > print "a3[0] not in a6, a3[1] not in a6, a3[2] not > in a6" > elif a3[2] in a6: > print "a3[0] not in a6, a3[1] not in a6, a3[2] in > a6" > else: > print "NONE3.1" > elif a3[1] in a6: > if a3[2] not in a6: > print "a3[0] not in a6, a3[1] in a6, a3[2] not in > a6" > elif a3[2] in a6: > print "a3[0] not in a6,a3[1] in a6, a3[2] in a6" > else: > print "NONE3.2" > else: > print "NONE3.3" > elif a3[0] in a6: > if a3[1] not in a6: > if a3[2] not in a6: > print "a3[0] in a6, a3[1] not in a6, a3[2] not in > a6" > elif a3[2] in a6: > print "a3[0] in a6, a3[1] not in a6, a3[2] in a6" > else: > print "NONE3.4" > elif a3[1] in a6: > if a3[2] not in a6: > print "a3[0] in a6, a3[1] in a6, a3[2] not in a6" > elif a3[2] in a6: > print "a3[0] in a6, a3[1] in a6, a3[2] in a6" > else: > print "NONE3.5" > else: > print "NONE3.6" > else: > print "NONE3.7" > Why it is behaving like that? Like what? You don't even say what results you expect, and only describe the results you *do* obtain as "hugely erroneous". I have a car. I have turned the ignition key but it fails to start. Please tell me what is wrong with it. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From sturlamolden at yahoo.no Fri Apr 25 11:02:01 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 25 Apr 2008 08:02:01 -0700 (PDT) Subject: Calling Python code from inside php References: <679e9oF2mti63U1@mid.uni-berlin.de> <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> Message-ID: On Apr 23, 9:13 pm, alexel... at gmail.com wrote: > A simple yet dangerous and rather rubbish solution (possibly more of a > hack than a real implementation) could be achieved by using a > technique described above: > > echo exec('python foo.py'); This will spawn a Python interpreter, and not be particularly efficient. You could just as well have used CGI. From bgeddy at home.havin.a.break Thu Apr 17 22:59:16 2008 From: bgeddy at home.havin.a.break (bgeddy) Date: Fri, 18 Apr 2008 03:59:16 +0100 Subject: how do I know if I'm using a debug build of python In-Reply-To: References: Message-ID: <98UNj.17390$2b2.11787@newsfe12.ams2> Tim Mitchell wrote: > Hi, > > A quick question: > Is there any way for a python script to know if it's being executed by a > debug build of python (python_d.exe) instead of python? > > Thanks > Tim > Not sure what this returns in Windows as I run Linux but this returns to namer of the python executable for my setup - maybe its what you want. import sys print sys.executable - will print out the name of the python executable. From needin4mation at gmail.com Fri Apr 25 09:16:08 2008 From: needin4mation at gmail.com (jmDesktop) Date: Fri, 25 Apr 2008 06:16:08 -0700 (PDT) Subject: Is 2006 too old for a book on Python? Message-ID: Hi, I wanted to buy a book on Python, but am concerned that some of them are too old. One I had come to after much research was Core Python by Wesley Chun. I looked at many others, but actually saw this one in the store and liked it. However, it is from 2006. I know there is free documentation and Dive Into Python. I just liked the one in question and was hoping for thoughts on the age of it. I am using Python 2.5.x and don' t know how different 2.3, 2,4 is from it. Thank you. From torriem at gmail.com Wed Apr 16 12:39:16 2008 From: torriem at gmail.com (Michael Torrie) Date: Wed, 16 Apr 2008 10:39:16 -0600 Subject: Finally had to plonk google gorups. In-Reply-To: <87prspydex.fsf@physik.rwth-aachen.de> References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> <87prspydex.fsf@physik.rwth-aachen.de> Message-ID: <48062BB4.8000201@gmail.com> Torsten Bronger wrote: > The admistrative overhead of mailing lists is tedious. Fortunately, > most important computer-related lists are on gmane.org. We could > list c.l.py there, too. ;-) Running a few lists myself, I don't see this. How is administrative overhead tedious? Most open source projects do it, so I wonder just how tedious it is. Of all the projects I'm associated with in lists, Python is the only one still clinging to NNTP when it appears a normal mail list is just as good. From deets at nospam.web.de Fri Apr 25 09:02:29 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 25 Apr 2008 15:02:29 +0200 Subject: PYTHONPATH breaks MySQLdb In-Reply-To: References: Message-ID: <67e33tF2orobvU1@mid.uni-berlin.de> Aljosa Mohorovic schrieb: > i have a working MySQLdb module (/usr/lib/python2.4/site-packages/ > MySQL_python-1.2.2-py2.4-linux-i686.egg), using it without problems. > > "clean shell" after login: > python -c "import MySQLdb" reports no errors > > if i export PYTHONPATH: > export PYTHONPATH=/var/www/projects/uv_portal/portal > > python -c "import MySQLdb" reports no errors as in previous case > > if i export PYTHONPATH: > export PYTHONPATH=/var/www/projects/uv_portal/portal/apps > > i get this: > python -c "import MySQLdb" > Traceback (most recent call last): > File "", line 1, in ? > ImportError: No module named MySQLdb > > is there any reason why this happens? Yes. You found a secret that nobody was supposed to know: Python doesn't allow portal applications te be written! So it scans the pythonpath for a suffix of "portal/apps", and refuses to import anything if it finds it. Seriously: yes, there must be a reason, but nobody can tell because we don't know & see what is beyond the apps-dir that might cause trouble. Generally speaking, given that you can properly import MySQLdb without any path set, you need to see if there is anything in your path that somehow gets imported first and e.g. alters the sys.path. Try python -vc 'import MySQLdb' and if that doesn't make things clearer, use strace. Diez From skanemupp at yahoo.se Thu Apr 10 07:41:06 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 04:41:06 -0700 (PDT) Subject: questions about Exceptions? References: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> <71cc8c25-f5f9-4f21-a9d8-06780bf97608@f63g2000hsf.googlegroups.com> <9af81b1a-3e02-4406-b9d2-0a9b6f46566b@p39g2000prm.googlegroups.com> <0e586d5d-6799-433f-b8a4-4de5d2a87b61@h1g2000prh.googlegroups.com> <46a79564-4069-46af-b6ab-b38bd9152c2a@d45g2000hsc.googlegroups.com> <1f413b6e-f964-4f8d-b781-61985f86acc2@a9g2000prl.googlegroups.com> Message-ID: <1473f09e-936f-4e35-830d-ecf999976c55@f63g2000hsf.googlegroups.com> On 10 Apr, 13:15, cokofree... at gmail.com wrote: > > the erase() id alwys need if u wanna abort whilst u wrote something. > > But if it is meant to only evaluate once you've pressed the enter key > (I take it?) you shouldn't need that. And if you are to abort while > evaluating it will not do that. CHANGED IT NOW TO A MUCH BETTER SOLUTION(will see if i can make a better solution with the buttons, hate big blocks of similarlooking code): from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") l = Label(mygui, text="Answer: ") l.place(relx=0.15, rely=0.2, anchor=CENTER) e = Entry(mygui) e.place(relx=0.4, rely=0.1, anchor=CENTER) def Disp(nstr): e.insert(END, nstr) def Calc(): expr=e.get() try: b = Label(mygui, text=eval(expr)) b.place(relx=0.4, rely=0.2, anchor=CENTER) except: b = Label(mygui, text="Not computable") b.place(relx=0.4, rely=0.2, anchor=CENTER) def Erase(): e.delete(0,END) b = Button(mygui, text="1",command=lambda n='1':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.4, anchor=CENTER) b = Button(mygui, text="2",command=lambda n='2':Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.4, anchor=CENTER) b = Button(mygui, text="3",command=lambda n='3':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.4, anchor=CENTER) b = Button(mygui, text="+",command=lambda n='+':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.4, anchor=CENTER) b = Button(mygui, text="4",command=lambda n='4':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.5, anchor=CENTER) b = Button(mygui, text="5",command=lambda n='5':Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.5, anchor=CENTER) b = Button(mygui, text="6",command=lambda n='6':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.5, anchor=CENTER) b = Button(mygui, text="-",command=lambda n='-':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.5, anchor=CENTER) b = Button(mygui, text="7",command=lambda n='7':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.6, anchor=CENTER) b = Button(mygui, text="8",command=lambda n='8':Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.6, anchor=CENTER) b = Button(mygui, text="9",command=lambda n='9':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.6, anchor=CENTER) b = Button(mygui, text="*",command=lambda n='*':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.6, anchor=CENTER) b = Button(mygui, text="0",command=lambda n='0':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.7, anchor=CENTER) b = Button(mygui, text="C",command=Erase, width=2, height=1) b.place(relx=0.2, rely=0.7, anchor=CENTER) b = Button(mygui, text="^",command=lambda n='**':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.7, anchor=CENTER) b = Button(mygui, text="/",command=lambda n='/':Disp(n), width=2, height=1) b.place(relx=0.4, rely=0.7, anchor=CENTER) b = Button(mygui, text=".",command=lambda n='.':Disp(n), width=2, height=1) b.place(relx=0.1, rely=0.8, anchor=CENTER) b = Button(mygui, text="(",command=lambda n='(':Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.8, anchor=CENTER) b = Button(mygui, text=")",command=lambda n=')':Disp(n), width=2, height=1) b.place(relx=0.3, rely=0.8, anchor=CENTER) b = Button(mygui, text="=",command=Calc, width=2, height=1) b.place(relx=0.4, rely=0.8, anchor=CENTER) mygui.mainloop() From desktop_specialist at yahoo.com Tue Apr 15 10:24:05 2008 From: desktop_specialist at yahoo.com (shawn s) Date: Tue, 15 Apr 2008 07:24:05 -0700 (PDT) Subject: program to Ping ip addresses Message-ID: <192124.99122.qm@web58602.mail.re3.yahoo.com> Hi I am trying to modify a small program i found off the internet as follows... I can get the 'tracert' to work and it gives me all the info back. However, when i replace the tracert with 'ping', the commamd prompt shows 'testing' and the script freezes... any suggestions as why it is doing that. import os import sys xyz = 1 while xyz==1: ip = raw_input("command >> ") zx = open("log.txt", "a") if ip.lower()=="exit": ask = raw_input("Are you sure you want to exit? (Y\\N) ") if ask.lower()=="y": sys.exit() elif ask.lower()=="n": print("That's what I thought.") else: print("Wrong choice. Retard.") elif ip.lower()=="range": stin = raw_input("Enter function: ") sec = raw_input("Enter the first 3 sections: ") b = raw_input("Enter beginning number: ") intb=int(b) e = int(raw_input("Enter ending number: ")) while intb<=e: print (stin + ' ' + sec + '.' + b ) z = os.system(stin + ' ' + sec + '.' + b ) print z if z==0: print(""+str(sec)+"."+str(b)+" is online.") zx.write(""+str(sec)+"."+str(b)+" is online.\n") elif z==1: print("Either "+str(sec)+"."+str(b)+" is offline, or ping request has been blocked.") zx.write("Either "+str(sec)+"."+str(b)+" is offline, or ping request has been blocked.\n") intb = intb + 1 b=str(intb) else: print("Wrong choice. Retard.") ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdw at distorted.org.uk Tue Apr 22 08:42:00 2008 From: mdw at distorted.org.uk (Mark Wooding) Date: Tue, 22 Apr 2008 12:42:00 +0000 (UTC) Subject: Working around buffering issues when writing to pipes References: Message-ID: sven _ wrote: > In short: unless specifically told not to, normal C stdio will use > full output buffering when connected to a pipe. It will use default > (typically unbuffered) output when connected to a tty/pty. Wrong. Standard output to a terminal is typically line-buffered. (Standard error is never buffered by default, per the ISO C standard.) > This is why subprocess.Popen() won't work with the following program > when stdout and stderr are pipes: Yes, obviously. > I went with pexpect and it works well, except that I must handle > stdout and stderr separately. There seems to be no way to do this with > pexpect, or am I mistaken? You could do it by changing the command you pass to pexpect.spawn so that it redirects its stderr to (say) a pipe. Doing this is messy, though -- you'd probably need to set the pipe's write-end fd in an environment variable or something. It's probably better to use os.pipe and pty.fork. As mentioned above, the inferior process's output will still be line-buffered unless it does something special to change this. -- [mdw] From sophacles at gmail.com Wed Apr 9 13:49:01 2008 From: sophacles at gmail.com (Erich) Date: Wed, 9 Apr 2008 10:49:01 -0700 (PDT) Subject: Google App Engine References: <47fc2c7c$0$36365$742ec2ed@news.sonic.net> <7e43fcd9-6207-4af2-8256-c0099a8ce0bb@1g2000prf.googlegroups.com> Message-ID: <3d4cae10-17bb-4d53-b84f-236287bd5893@m44g2000hsc.googlegroups.com> On Apr 9, 3:51 am, Duncan Booth wrote: > The backend data store, while it has a vaguely SQLish query language is an > object database not a relational database, i.e. more like ZODB than MySQL. > It uses similar concepts to django's data api but isn't the same. It should > be possible to write something simple to replace it, but given that you > only need to migrate away from Google when your data or page hits get > large, you need to replace it with something scalable. I have a bet with a coworker that someone will implement the api, in a way that makes migration away from Google easy, within a month. (actually, the bet is just that there will be a project with this goal). The reason I mention it here, is that he had the same comments as you regarding this. My thinking is that (if past experiences can be used as a yardstick) the python community will see this deficiency and work to correct it. As a result of that thinking, I am fairly certain that this concern is not a big concern. The authentication thing, thats a bit different. From mhansen at gmail.com Tue Apr 22 17:35:58 2008 From: mhansen at gmail.com (Mike Hansen) Date: Tue, 22 Apr 2008 14:35:58 -0700 (PDT) Subject: subprocess module is sorely deficient? References: Message-ID: > I think the best solution would be to port Pexpect to windows which > wouldn't be that difficult according to my reading of the code. If > only I had more free time! Sage ( http://www.sagemath.org ) uses pexpect fairly extensively to interface with all sorts of other systems. We recently received funding from Microsoft to do a native port of Sage (and all of its components to Windows. Part of this will most likely be a port of pexpect to Windows. --Mike From martin at v.loewis.de Sun Apr 6 09:53:34 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 06 Apr 2008 15:53:34 +0200 Subject: Is there any way to say ignore case with "in"? In-Reply-To: <432d690f-44be-49a9-bc6a-1cf3445549d6@m71g2000hse.googlegroups.com> References: <47f692f3$0$759$bed64819@news.gradwell.net> <432d690f-44be-49a9-bc6a-1cf3445549d6@m71g2000hse.googlegroups.com> Message-ID: <47f8d5df$0$23304$9b622d9e@news.freenet.de> >> I know I could use:- >> >> if lower(string1) in lower(string2): >> >> >> but it somehow feels there ought to be an easier (tidier?) way. >> > > Easier? You mean like some kind of mind meld? Interestingly enough, it shouldn't be (but apparently is) obvious that a.lower() in b.lower() is a way of expressing "a is a substring of b, with case-insensitive matching". Can we be sure that these are really the same concepts, and if so, is a.upper() in b.upper() also equivalent? It's probably a common assumption that, for any character c, c.lower()==c.upper().lower(). Yet, py> [i for i in range(65536) if unichr(i).upper().lower() != unichr(i).lower()] [181, 305, 383, 837, 962, 976, 977, 981, 982, 1008, 1009, 1010, 1013, 7835, 8126] Take, for example, U+017F, LATIN SMALL LETTER LONG S. It's .lower() is the same character, as the character is already in lower case. It's .upper() is U+0053, LATIN CAPITAL LETTER S. Notice that the LONG is gone - there is no upper-case version of a "long s". It's .upper().lower() is U+0073, LATIN SMALL LETTER S. So should case-insensitive matching match the small s with the small long s, as they have the same upper-case letter? Regards, Martin From http Wed Apr 2 21:15:41 2008 From: http (Paul Rubin) Date: 02 Apr 2008 18:15:41 -0700 Subject: Why prefer != over <> for Python 3.0? References: Message-ID: <7xlk3vg2ma.fsf@ruckus.brouhaha.com> "Hendrik van Rooyen" writes: > Some of the other veterans may want to add to this list. Overlays, lots and lots of them, in multiple levels intricately arranged. From torriem at gmail.com Tue Apr 15 13:19:31 2008 From: torriem at gmail.com (Michael Torrie) Date: Tue, 15 Apr 2008 11:19:31 -0600 Subject: Java or C++? In-Reply-To: <20080415165526.GA21682@hccnet.nl> References: <20080415165526.GA21682@hccnet.nl> Message-ID: <4804E3A3.5080200@gmail.com> egbert wrote: > What is the role or position of C# in this context ? > If I remember well, some people have said that C# is an improved > C++ or Java. > e I think C# is in a great position, and might be recommended. C# has the added advantage of being able to very easily work with IronPython. Thus if you want to develop with .NET you can easily wield the beauty of python with C# for speed or library routines. Of course Jython does the same for Java, although it's way behind in development these days. Slick python integration is one area where C# and Java would beat out C++. Sure there's Boost::Python, but the learning curve is kind of steep. Installation, even, is difficult. Python's C API is very simple and C-like, so if one chooses to use primarily a C/Python combination (typically what I do these days), it works well, but not quite as easy as IronPython and C#. Diving into the debate, I personally think all programmers, and especially computer science people, should be proficient in C. You should be able to write thousands of lines of C code, use dynamic memory allocation, data structures, etc, and have very few resource leaks if you choose your tools wisely (glib for C ought to be standard!). This is to give you a background and low-level understanding. However you're not likely to program in C professionally unless you are into systems programming, or are affiliated with core, low-level things like library development, or embedded systems. As for C++ and Java, I've found that good C++ programmers can *easily* move to Java when they want/need to. The reverse is *not typically true*. Java lends itself to too many bad habits that kill would-be C++ programmers, particular in regards to resource management and things like destruction after scope. I think that is a critical thing that people forget sometimes. Similarly people proficient in Unix and Linux computers, both use and development on, can much more easily move to Windows than the other way around. A good programmer should be able to pick up new languages and paradigms fairly easily, and become fluent in just a few weeks. For me it's typically one week, although learning frameworks and toolkits is more difficult (Java frameworks). A good exercise might be to pick up one new language per year and do something major with it (say 4000-10000 loc). Choose a new genre like web programming to explore. Whatever. Next time a little pet project comes up, try a new language or a new toolkit. Try some shell-scripting in scsh using scheme. From maehhheeyy at gmail.com Tue Apr 15 18:50:38 2008 From: maehhheeyy at gmail.com (maehhheeyy) Date: Tue, 15 Apr 2008 15:50:38 -0700 (PDT) Subject: i want to add a timeout... Message-ID: <6b75da78-91c7-481c-9d20-fca8b12294de@y18g2000pre.googlegroups.com> I want to add a timeout so that when I pull out my gps from my serial port, it would wait for a bit then loop and then see if it's there. I also want to add a print statement saying that there is no GPS device found. However when I run my code and unplug my serial port, my code will just hang until I plug it back in. This is my code right now: def GetGPS(): data = [] #Open com1: 9600,8,N,1 fi = serial.Serial(0, timeout = 1) print '[gps module] SERIAL PORT OPEN ON COM1:' can anyone help me please? Thanks. From exarkun at divmod.com Wed Apr 23 10:53:06 2008 From: exarkun at divmod.com (Jean-Paul Calderone) Date: Wed, 23 Apr 2008 10:53:06 -0400 Subject: Python generators (coroutines) In-Reply-To: Message-ID: <20080423145306.6859.1396709148.divmod.quotient.34066@ohm> On Wed, 23 Apr 2008 07:17:46 -0700 (PDT), rocco.rossi at gmail.com wrote: >I would really like to know more about python 2.5's new generator >characteristics that make them more powerful and analogous to >coroutines. Is it possible for instance to employ them in situations >where I would normally use a thread with a blocking I/O (or socket) >operation? If it is, could someone show me how it can be done? There >appears to be a very limited amount of documentation in this repect, >unfortunately. They're not coroutines. The difference between generators in Python 2.4 and in Python 2.5 is that in Python 2.5, `yield? can be used as part of an expression. If a generator is resumed via its `send? method, then the `yield? expression evaluates to the value passed to `send?. You still can't suspend execution through arbitrary stack frames; `yield? only suspends the generator it is in, returning control to the frame immediately above it on the stack. You can build a trampoline based on generators, but you can do that in Python 2.4 just as easily as you can do it in Python 2.5. Jean-Paul From mysakjs at gmail.com Fri Apr 25 22:38:46 2008 From: mysakjs at gmail.com (John) Date: Fri, 25 Apr 2008 19:38:46 -0700 (PDT) Subject: newbie question References: Message-ID: <91bff95c-9f54-439c-a388-1ad158682e8b@k13g2000hse.googlegroups.com> Thanks for the tip! From python at bdurham.com Thu Apr 24 15:37:03 2008 From: python at bdurham.com (python at bdurham.com) Date: Thu, 24 Apr 2008 15:37:03 -0400 Subject: Parsing text file with #include and #define directives Message-ID: <1209065823.20034.1249725425@webmail.messagingengine.com> I'm parsing a text file for a proprietary product that has the following 2 directives: #include #define Defined constants are referenced via <#name#> syntax. I'm looking for a single text stream that results from processing a file containing these directives. Even better would be an iterator(?) type object that tracked file names and line numbers as it returns individual lines. Is there a Python parsing library to handle this type of task or am I better off writing my own? The effort to write one from scratch doesn't seem too difficult (minus recursive file and constant loops), but I wanted to avoid re-inventing the wheel if this type of component already exists. Thank you, Malcolm From jim.vickroy at noaa.gov Wed Apr 2 14:17:33 2008 From: jim.vickroy at noaa.gov (j vickroy) Date: Wed, 02 Apr 2008 12:17:33 -0600 Subject: ANN: pry unit testing framework In-Reply-To: References: Message-ID: <47F3CDBD.1010600@noaa.gov> Aldo Cortesi wrote: > We are happy to announce the first release of Pry, a unit testing framework. > > Features > ======== > > * Built-in coverage analysis, profiling, and quick-and-dirty benchmarking > * Assertion-based tests - no ugly failUnless*, failIf*, etc. methods > * Tree-based test structure for better fixture management > * No implicit instantiation of test suits > * Powerful command-line interface > > > Download: http://dev.nullcube.com > > Manual: http://dev.nullcube.com/doc/pry/index.html > > It appears this package can not be used with Microsoft Windows because it uses the *fcntl* module which is not part of the Windows distribution. >>> import sys >>> sys.version '2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]' >>> >>> import libpry Traceback (most recent call last): File "", line 1, in File "C:\Python25\Lib\site-packages\libpry\__init__.py", line 1, in from test import * File "C:\Python25\Lib\site-packages\libpry\test.py", line 4, in import _tinytree, explain, coverage, utils File "C:\Python25\Lib\site-packages\libpry\coverage.py", line 3, in import utils File "C:\Python25\lib\site-packages\libpry\utils.py", line 1, in import os.path, fnmatch, struct, fcntl, termios, os ImportError: No module named fcntl Unfortunate, because I'm definitely interested in the code coverage and profiling features. -- jv From soren.skou.nielsen at gmail.com Tue Apr 29 05:07:04 2008 From: soren.skou.nielsen at gmail.com (Soren) Date: Tue, 29 Apr 2008 02:07:04 -0700 (PDT) Subject: SWIG Python undefined reference Message-ID: <23b925ce-cfa5-4a99-bad3-afcac09b645a@y21g2000hsf.googlegroups.com> Hi, I went through the SWIG tutorial for the example named "simple". I managed to get to the first step, creating example_wrap.c using swig, and doing: "gcc -fpic -c example_wrap.c -IC:\python24\include " to create example_wrap.o But when I needed to compile the library file using: "gcc -shared example_wrap.o -o examplemodule.so" I received a lot of undefined reference compiler errors like: example_wrap.o(.text+0x35a5):example_wrap.c: undefined reference to `_imp__PyErr _SetString' there are many other similar errors all prefaced with _imp__Py, so I am assuming there is a linker error with the python libraries. I have adjusted my PATH variable to include all the python directories (libs/ dlls). Does anyone here have any suggestions? FILES FROM TUTORIAL: //example.c #include double My_variable = 3.0; int fact(int n) { if (n <= 1) return 1; else return n*fact(n-1); } int my_mod(int x, int y) { return (x%y); } char *get_time() { time_t ltime; time(<ime); return ctime(<ime); } //*************************************************************** //example.i %module example %{ /* Put header files here or function declarations like below */ extern double My_variable; extern int fact(int n); extern int my_mod(int x, int y); extern char *get_time(); %} extern double My_variable; extern int fact(int n); extern int my_mod(int x, int y); extern char *get_time(); //*************************************************************** //setup.py from distutils.core import setup, Extension setup(name='example', version = '1.0', ext_modules=[ Extension('example', ['example.c', 'example.i']) ]) From metawilm at gmail.com Wed Apr 9 07:59:31 2008 From: metawilm at gmail.com (metawilm at gmail.com) Date: Wed, 9 Apr 2008 04:59:31 -0700 (PDT) Subject: Basic optimization of python. References: Message-ID: <16061d43-8baf-4117-88e9-28d65a6d4491@n1g2000prb.googlegroups.com> On Apr 7, 7:30 am, "??" wrote: > Howdy, > I wonder whether python compiler does basic optimizations to .py. > Eg: > t = self.a.b > t.c = ... > t.d = ... > .vs. > self.a.b.c = ... > self.a.b.d = ... > which one is more effective? Since each dot invokes a hash table lookup, it > may be time consuming. If the compiler can do expression folding, then no > manual folding is needed. The compiler can not simply do such folding, as just the act of looking up an attribute can have all kinds of side effects via the methods __getattr__ and __getattribute__ . So the second time you look up self.a the value can differ from the first time, or the attribute may not exist anymore! > Again, how about contant calculation? > Eg: > a = 1 + 2 > .vs. > a = 3 > which one is more effective? Does the compiler calculate the result at > compile time? How about constant spreading? This is safe, and is done: >>> import dis >>> def f(): x = 1 + 2 ... >>> dis.dis(f) 1 0 LOAD_CONST 3 (3) 3 STORE_FAST 0 (x) 6 LOAD_CONST 0 (None) 9 RETURN_VALUE >>> - Willem From deets at nospam.web.de Tue Apr 22 11:37:59 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 17:37:59 +0200 Subject: Does Python 2.5 include or not include SQLite engine? In-Reply-To: References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> <67646qF2mqc8pU1@mid.uni-berlin.de> Message-ID: <676f3bF2nfvqgU1@mid.uni-berlin.de> Paul Melis schrieb: > Hi, > > Diez B. Roggisch wrote: >> Dennis Lee Bieber schrieb: >> >>> On Mon, 21 Apr 2008 19:05:46 -0400, python at bdurham.com declaimed the >>> following in comp.lang.python: >>> >>>> I thought one of the major features of Python 2.5 was its embedded >>>> SQLite engine. >>>> >>> No, just the inclusion of the adapter became standard... The >>> packagers of Windows installers include the SQLite3 DLL as it isn't a >>> commonly available item... But many Linux versions probably include it >>> as an option during the OS install. >> >> >> AFAIK thats wrong. On my ubuntu gutsy for example, I find this: >> >> deets at absinth:~$ find /usr/lib/python2.5/ | grep -i sqlite >> /usr/lib/python2.5/lib-dynload/_sqlite3.so >> /usr/lib/python2.5/site-packages/pysqlite-2.3.2.egg-info >> /usr/lib/python2.5/site-packages/pysqlite2 >> /usr/lib/python2.5/site-packages/pysqlite2/__init__.py >> /usr/lib/python2.5/site-packages/pysqlite2/__init__.pyc >> /usr/lib/python2.5/site-packages/pysqlite2/_sqlite.so >> /usr/lib/python2.5/site-packages/pysqlite2/dbapi2.py >> /usr/lib/python2.5/site-packages/pysqlite2/dbapi2.pyc >> /usr/lib/python2.5/sqlite3 >> /usr/lib/python2.5/sqlite3/__init__.py >> >> ... >> >> >> As you can see, stock 2.5 ships with its OWN version of sqlite, and I >> additionally installed the pysqlite-wrapper for whatever reason I now >> can't remember. > > The _sqlite3.so is only a wrapper around the real sqlite library. > Compiling a fresh Python 2.5.2 install here gives: > > 15:46|paul at tabu:~/py25/lib/python2.5/lib-dynload> ldd _sqlite3.so > linux-gate.so.1 => (0x00748000) > libsqlite3.so.0 => /usr/lib/libsqlite3.so.0 (0x00111000) > libpthread.so.0 => /lib/libpthread.so.0 (0x00631000) > libc.so.6 => /lib/libc.so.6 (0x00d1b000) > /lib/ld-linux.so.2 (0x00749000) > > I.e. the _sqlite3 module links against the system-wide installed Sqlite > version. > > Furthermore, checking the Python source distribution will show that > there is no included version of the whole Sqlite library, only the > wrapper code. How your Linux distribution packages Python w.r.t. the > sqlite3 module is different per distro. Hm. Before posting, I checked this: http://svn.python.org/view/external/sqlite-source-3.5.7.x/ So I got the impression that because the source is there (I admit *not* checking the python source distribution itself though) and a library is in the python-lib, that python ships with sqlite. So - I stand corrected. Given the way some linux distros treat python wrt to e.g. distutils, I wonder if there is one out there that does *not* have sqlite built-in. Diez From victorsubervi at gmail.com Thu Apr 17 10:47:34 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 17 Apr 2008 09:47:34 -0500 Subject: Importing My Own Script In-Reply-To: <271813.40455.qm@web39202.mail.mud.yahoo.com> References: <271813.40455.qm@web39202.mail.mud.yahoo.com> Message-ID: <4dc0cfea0804170747o33778858k22cf4ec8e2a6f48a@mail.gmail.com> On Thu, Apr 17, 2008 at 8:52 AM, Ben Kaplan wrote: > If x and y are in the same directory, just do "import x". If not, add the > directory containing x to sys.path. Then, "import x" should work. > Well, now that?s what I thought! But no, it doesn?t work! Both scripts are in the same folder. Here?s the error: [Thu Apr 17 07:45:50 2008] [error] [client 190.166.0.245] PythonHandler mod_python.cgihandler: File "/var/www/vhosts/ livestocksling.com/httpdocs/bre/test.py", line 3, in ?\n import test2 [Thu Apr 17 07:45:50 2008] [error] [client 190.166.0.245] PythonHandler mod_python.cgihandler: ImportError: No module named test2 I?m running through Plesk, if that makes a difference. TIA, Victor > > ----- Original Message ---- > From: Victor Subervi > To: python-list at python.org > Sent: Thursday, April 17, 2008 9:45:10 AM > Subject: Importing My Own Script > > Hi: > How do I import my own script from a second script? That is, I have script > x and I want to import script y. How? > TIA, > Victor > > > ------------------------------ > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it > now. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From castironpi at gmail.com Sat Apr 26 15:31:50 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sat, 26 Apr 2008 12:31:50 -0700 (PDT) Subject: diffing and uniqing directories References: Message-ID: On Apr 26, 1:14?pm, "Rustom Mody" wrote: > Over years Ive collected tgz's of my directories. I would like to diff > and uniq them > > Now I guess it would be quite simple to write a script that does a > walk or find through a pair of directory trees, makes a SHA1 of each > file and then sorts out the files whose SHA1s are the same/different. > What is more difficult for me to do is to write a visual/gui tool to > help me do this. > > I would guess that someone in the python world must have already done > it [The alternative is to use some of the tools that come with version > control systems like git. But if I knew more about that option I would > not be stuck with tgzs in the first place ;-)] > > So if there is such software known please let me know. > > PS Also with the spam flood that has hit the python list I dont know > if this mail is being read at all or Ive fallen off the list! I don't want to give you advice; there is profit in diversity, so telling you what I use could negatively unify the diverse group. In another language I know, and I pause to defer to the old and wise on that, Visual Basic (known to make money), certain counterparts like Visual Basic for Applications allow construction of scripts in the owner's other suites. That is, you can write Basic snippets in Excel, Access, and so on. That's one benefit that private ownership leaves, but not everyone is sold on my country's currency/localcy. Perhaps it's in the future of version control systems. Of course, standardization of sufficiency to succeed comes from currency too: success isn't success if it isn't current, per se. Do you have any interest in contributing your mind or hands to developing a solid gui framework? Join a team. From spamgrinder.trylater at ggmail.com Wed Apr 23 21:18:10 2008 From: spamgrinder.trylater at ggmail.com (AlFire) Date: Wed, 23 Apr 2008 20:18:10 -0500 Subject: Python Success stories In-Reply-To: References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> <426812d7-c217-4bfc-81b0-47ba0638a650@k13g2000hse.googlegroups.com> Message-ID: <480FDFD2.8070906@ggmail.com> Bob Woodham wrote: > > x = x++; > > has unspecified behaviour in C. what about C++ From max at alcyone.com Fri Apr 25 18:52:09 2008 From: max at alcyone.com (Erik Max Francis) Date: Fri, 25 Apr 2008 15:52:09 -0700 Subject: Receive data from socket stream In-Reply-To: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> Message-ID: s0suk3 at gmail.com wrote: > I wanted to ask for standard ways to receive data from a socket stream > (with socket.socket.recv()). It's simple when you know the amount of > data that you're going to receive, or when you'll receive data until > the remote peer closes the connection. But I'm not sure which is the > best way to receive a message with undetermined length from a stream > in a connection that you expect to remain open. Until now, I've been > doing this little trick: > > data = client.recv(256) > new = data > while len(new) == 256: > new = client.recv(256) > data += new > > That works well in most cases. But it's obviously error-prone. What if > the client sent *exactly* two hundred and fifty six bytes? It would > keep waiting for data inside the loop. Is there really a better and > standard way, or is this as best as it gets? > > Sorry if this is a little off-topic and more related to networking, > but I'm using Python anyway. You solve this by having a protocol that the client and server both agree on, so that the client knows how much to read from the server. There are any number of ways of doing this, all of which depend on the kind of data you want to transfer and for what purpose. -- Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis In the final choice a solider's pack is not so heavy a burden as a prisoner's chains. -- Dwight D. Eisenhower, 1890-1969 From pscott at uwc.ac.za Wed Apr 16 01:48:37 2008 From: pscott at uwc.ac.za (Paul Scott) Date: Wed, 16 Apr 2008 07:48:37 +0200 Subject: Brand New! In-Reply-To: References: <7f1828bf-ebe7-4111-bc59-70d125facb0a@d26g2000prg.googlegroups.com> Message-ID: <1208324917.7339.10.camel@paul-laptop> On Wed, 2008-04-16 at 02:35 -0300, Gabriel Genellina wrote: > I'm unsure if teaching Javascript, VBScript and Python at the same time is > a good thing, I'd think one would get a language soup and mix all the > concepts, but if it works for you, go ahead. > For other resources, see the beginners section in the Python wiki: > http://wiki.python.org/moin/BeginnersGuide Well, as an example, I learnt Python to a decent level of competency in 2 days. I looked through the Dive into Python tuts, and then had a look at the Python GUI FAQ (Which didn't really help much, as I started with a GTK based GUI app). A little bit of Googling and a couple of questions to this list gave me everything that I needed to roll out a pretty decent application in 5 days. Oh, and just by the way, I am _not_ a Computer Scientist or anything, I am a botanist, which means that if I can do that, just about anyone that can read can do it. Python has been long on my list of TODO's, and now, finally, it is there. I have immensely enjoyed it so far, and will continue to tinker well into the future. --Paul -------------- next part -------------- All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm From grante at visi.com Sun Apr 6 14:55:22 2008 From: grante at visi.com (Grant Edwards) Date: Sun, 06 Apr 2008 13:55:22 -0500 Subject: A funnily inconsistent behavior of int and float References: Message-ID: On 2008-04-06, Lie wrote: > I've noticed some oddly inconsistent behavior with int and float: > > Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 >>>> int('- 345') > -345 > > works, IMO, it oughtn't. >>>> float('- 345.083') > Traceback (most recent call last): > File "", line 1, in > ValueError: invalid literal for float(): - 345.083 That's the behavior I'd expect. > The problem seems to be that float can't accept spaces between > the sign and the number while int can. Possibly caused by some > missing regex statement. Minor and harmless (most of the > time), but should be made known. -- Grant Edwards grante Yow! ... I live in a at FUR-LINE FALLOUT SHELTER visi.com From carbanancizpo at gmail.com Fri Apr 18 16:54:11 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:54:11 -0700 (PDT) Subject: scgrid cracks Message-ID: <37dcee38-bb8a-4694-baca-734cbdb663f4@q27g2000prf.googlegroups.com> scgrid cracks http://cracks.12w.net F R E E C R A C K S From larry.bates at websafe.com` Wed Apr 16 14:41:13 2008 From: larry.bates at websafe.com` (Larry Bates) Date: Wed, 16 Apr 2008 13:41:13 -0500 Subject: insert python script in current script In-Reply-To: References: Message-ID: Prashant wrote: > I was wondering is there any way to do this: > > I have written a class in python and __init__ goes like this: > > def __init__(self): > > self.name = 'jack' > self.age = 50 > > import data > > > > > now here there is data.py in the same directory and contents are like: > > self.address = 'your address' > self.status = 'single' > > The problem is 'self' is giving some error here. I need to know if > somehow I can do this. It's like inserting the script as it's part of > the file itself. > > Cheers > Can you give a use case for doing this. You would most likely be better doing: class person(object): def __init__(self, name=None, age=None): self.name=name self.age=age personInstance=person(name='jack', age='50) -Larry From andrei.avk at gmail.com Fri Apr 11 20:51:17 2008 From: andrei.avk at gmail.com (AK) Date: Fri, 11 Apr 2008 20:51:17 -0400 Subject: [ANN]: Python-by-Example updates Message-ID: <48000796$0$30160$4c368faf@roadrunner.com> Python-by-Example is a guide to LibRef, aiming to give examples for all functions, classes, modules, etc. Right now examples for functions in some of the most important modules are included. Over the last week, I've added examples for the following modules: re special characters, inspect, shutil, tempfile, traceback. I've also got many comments (thanks!) on formatting & colors and fixed them; I've also made the guide more suitable for printing, although it's not perfect still (no pagebreaks), that will be fixed later when I add more examples. Here's the location of Python-by-Example: http://pbe.lightbird.net/ thanks, -- -ak Tobu | http://tobu.lightbird.net/ | Freeform DB / Tagger / PIM Python-by-Example | http://pbe.lightbird.net/ | Guide to LibRef From deets at nospam.web.de Tue Apr 1 19:26:52 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 02 Apr 2008 01:26:52 +0200 Subject: Summary of threading for experienced non-Python programmers? In-Reply-To: <8763v4otts.fsf@mulj.homelinux.net> References: <87od8yolay.fsf@mulj.homelinux.net> <654ng1F2cvh8aU1@mid.uni-berlin.de> <87d4pe9caz.fsf@mulj.homelinux.net> <656vhnF2e9ao7U1@mid.uni-berlin.de> <8763v4otts.fsf@mulj.homelinux.net> Message-ID: <65fulvF2eiaalU1@mid.uni-berlin.de> > I believe you stil misunderstand. The select module doesn't provide > an inteface to aio(3). It provides an interface to select() and > poll() system calls, which don't provide asynchronous access to > regular files. I never claimed it provided access to aio. In the thread with Paul Rubin, it was clarified that there is the distinction made between blocking and non-blocknig async calls. Which you didn't mention. Don't get me wrong: I appreciate the mentioning of aio (didn't know about it beforehand) and don't dispute it's superiority. But that doesn't change that one is not forced to use threading in python (which can become very expensive) to deal with mulitple I/O streams asynchronously. >> So if I were in nitpicking-mood, your assertion still would be false > > I invite constructive nitpicking, but you are completely missing the > point. You are confusing aio(3) with select and poll. I didn't confuse anything. You didn't _mention_ aio, and I didn't even know it... >> I'm pretty sure though that tiwsted & asynchore don't poll, but >> instead use the select-module. Which at least for unix (and AFAIK >> for Windows as well) is asynchronous - you get notified if data >> arrives or has been transmitted, and otherwise your process sleeps. > > Unfortunately, this is not the case for files at all, even on Unix. > (On Windows, select doesn't work on files at all, it only accepts > sockets.) AFAIK select is used in cases where e.g. several processes are piped together to prevent blocking. Your usecase with a deliberately distorted file-server is sure relevant for certain usecases - but I don't think it qualifies as "not at all, even on Unix". To reiterate what my post was actually after: I understood it as if you didn't acknowledge the asynchronous capabilities of python which are used by widely known & successfully adopted built-in modules or 3rd-party-extensions - without resorting to C, and without forcing threads upon the users. It did *not* say that it supports every existing, more powerful and generally better asynchronous mechanism supported by any OS out there. Even though it would certainly be nice if it did :) Diez From hniksic at xemacs.org Fri Apr 25 17:16:36 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Fri, 25 Apr 2008 23:16:36 +0200 Subject: Setting an attribute without calling __setattr__() References: <87bq3xej01.fsf@mulj.homelinux.net> Message-ID: <87tzhpd497.fsf@mulj.homelinux.net> Hrvoje Niksic writes: > Joshua Kugler writes: > >> self.me = [] >> self.me = {} > > Use "object.__setattr__(self, 'me') = []" and likewise for {}. Oops, that should of course be "object.__setattr__(self, 'me', [])". From sarah.fortune at gmail.com Wed Apr 2 09:52:59 2008 From: sarah.fortune at gmail.com (sjf) Date: Wed, 2 Apr 2008 06:52:59 -0700 (PDT) Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: <7f21b6b2-81be-4c8a-bcc3-980fdae5073f@s37g2000prg.googlegroups.com> Indeed, the first thing I saw on the front page was "math.sqrt(9) - 3.0". Ok, I thought, random arithmetic expression, so what? There is already a standard way of showing a piece of code and its results. It's the interactive prompt: >>> import math >>> math.sqrt(9) 3.0 >>> Tada! On Apr 2, 12:43 pm, GHUM wrote: > Tobu, > > I like this idea. Deducting from an example is really another way to > wisdom. > > What struck me as most diffuclt to understand: > > abs(-5.5) - 5.5 > > -> you are using "-" as symbol for "will give the result", which is > really, really hard to parse. Take something else, please. Unicode has > THAT many cool symbols. Or just -> or -=> or whatever. > > Thanks for sharing that work! > > Harald From blog630 at watchesblog.cn Wed Apr 23 13:20:39 2008 From: blog630 at watchesblog.cn (blog630 at watchesblog.cn) Date: Wed, 23 Apr 2008 10:20:39 -0700 (PDT) Subject: China Wireless Mics - Wholesale Wireless Mics Manufacturer Message-ID: China Wireless Mics - Wholesale Wireless Mics Manufacturer Wireless Microphone WebSite Link: http://www.chinese-microphone.com/Wireless-Microphones.html China GuangZhou TianTuo Microphone Manufacturing Co., Ltd WebSite: http://www.chinese-microphone.com/ Microphone Products are: Wireless Microphones, Conference Microphones, Headset Microphones, and Lapel Microphones, interview microphones, wired microphones, musical instrument microphones, drum microphones, teaching microphones, recording microphones, computer's USB microphones and microphone accessories and So on. Headset Microphone Wireless Systems from zZounds.com FAQ | Sitemap | Contact Us Add Something to Your Cart. Toll Free 866.ZZOUNDS (996.8637) Open until 10PM EST Mention priority code 4RV2WX when you call Home | Guitar | Bass | Keyboard | Recording | Computer Music | Live Sound | Drums | DJ | Accessories | Blowouts SEARCH Behringer Peavey Yamaha Roland Epiphone Gibson Fender Korg Ibanez Alesis Shure Boss Mackie Zoom Akai Marshall M-Audio Vestax SKB Silvertone AKG CBI Martin Nady Fos http://www.chinese-microphone.com/Wireless-Microphones.html tex Browse All Brands Top Live Sound/PA Wireless Systems Wireless Microphone Systems Headset Microphone Wireless Systems "Over the years I have purchased several thousand dollars of murchandise from zZounds and have never had a problem." - customer on February 9, 2008 Restrict by Brand:Select a brandAKG---AKG WirelessAudio Technica---Audio Technica WirelessBehringer---Other BehringerElectro-Voice---Electro- Voice MicrophonesGeminiNady---Nady WirelessSamson---Samson Wireless MicrophonesSennheiser---Sennheiser WirelessShure---Shure Wireless MicrophonesX2 Digital Sort By:Most PopularName A to ZName Z to APrice High to LowPrice Low to High Filter By Price Range: To Availability: In Stock Items Only Filter Results 1 2 Next -> Samson Airline 77 UHF TD Wireless with Qe Fitness Headset New $329.00 List: $469.99SAVE: 29% In stock 29 people rate: 6 out of 10 Samson Airline 77 UHF Wireless systems are an unbeatable combination. Samson Concert 77 UHF True Diversity Half-Rack Receivers matched up with Samson's incredible Airline Series mini transmitters give you 'belt-pack-free' mobility at new low prices. Ultra-light, ultra-compact, and incredibly efficient, Airline Series transmitters provide flawless wireless performance for 12 hours on a single AAA battery. Learn More... Sennheiser ew152G2 Evolution G2 100 Series UHF Headset Wireless New $549.00 List: $894.99SAVE: 38% 4 payments of $137.25 In stock 46 people rate: 7 out of 10 Simply the best, most affordable way to get professional caliber UHF wireless! Sennheiser's original evolution series introduced startling new technology and innovative design. Now, they're again pushing the limits of performance, audio quality, ruggedness and ease of use. Learn More... Samson Airline 77 UHF TD Wireless with Qv Vocal Headset New $329.00 List: $469.99SAVE: 29% In stock 21 people rate: 7 out of 10 Samson Airline 77 UHF Wireless systems are an unbeatable combination. Samson Concert 77 UHF True Diversity Half-Rack Receivers matched up with Samson's incredible Airline Series mini transmitters give you 'belt-pack-free' mobility at new low prices. Ultra-light, ultra-compact, and incredibly efficient, Airline Series transmitters provide flawless wireless performance for 12 hours on a single AAA battery. Learn More... Shure PGX14/PG30 UHF Wireless Headset System New $429.00 List: $602.00SAVE: 28% Blowouts save up to $39! Call for 4 payments! In stock 1 person rates: 10 out of 10 The PG30 headset microphone in this Shure PGX wireless system offers pro-quality at an affordable price. Created for active musicians and presenters who also manage their own sound. Shure PGX Wireless improves your performance and simplifies your setup. Innovations such as automatic frequency selection and automatic transmitter setup make wireless quicker and completely worry-free. PGX systems now feature Shur http://www.chinese-microphone.com/Wireless-Microphones.html e's patented Audio Reference Companding, delivering the crystal clear sound quality that pro audio engineers trust. It's the best-sounding, simplest choice in wireless, from the leader in live performance sound. Learn More... Audio Technica ATW3192ACTH Headset Wireless System New $639.95 List: $1,099.00SAVE: 41% 4 payments of $159.98 In stock The ATW3192ACTH Headset System includes a ATWR3100 receiver and ATWT310 UniPak transmitter with AT892CWTH (beige) omnidirectional condenser headworn microphone. System also includes element covers, windscreens and a clothing clip. Learn More... Audio Technica ATW2192 Headset Wireless System New $549.95 List: $799.00SAVE: 31% 4 payments of $137.48 In stock The 2000 Series is a 10-channel frequency-agile UHF wireless system designed to suit a variety of applications, including MI/live performance, fixed installation, public address, A/V rental houses, and places of worship. It offers true diversity operation, easy setup, automatic frequency scanning with interference- free performance, and all the advantages of a high-quality, professional wireless system at an extremely affordable price. Learn More... Audio Technica ATW701H UHF Headworn Wireless System New $289.95 List: $459.00SAVE: 36% In stock 7 people rate: 7 out of 10 A- T's 700 Series Freeway wireless systems feature eight selectable frequency-coordinated channels, diversity operation, automatic frequency scanning, Tone Lock squelch and more. Diversity, frequency agility, UHF. Learn More... Audio Technica ATW701H92TH Headset Wireless System New $319.95 List: $524.95SAVE: 39% In stock Audio- Technica???s 700 Series Freeway wireless delivers professional features and sound quality unheard of in its class. These easy-to-use wireless systems feature eight selectable frequency-coordinated channels, diversity operation for increased range/reliability, automatic frequency scanning, Tone Lock squelch and more. Learn More... Samson Concert 77 UHF TD Wireless with QV Headset Transmitter New $279.00 List: $389.99SAVE: 28% In stock 9 people rate: 5 out of 10 Samson Technologies was founded 20 years ago when they introduced some of the first affordable wireless technology ever. The latest line of wireless gear in that tradition: Concert 77. UHF quality diversity wireless that anyone can afford. Learn More... Audio Technica ATW3192A Headset Wireless System New $639.95 List: $1,099.00SAVE: 41% 4 payments of $159.98 In stock The ATW3192AC Headset System includes a ATWR3100 receiver and ATWT310 UniPak transmitter with AT892CW omnidirectional condenser headworn microphone. Likewise it includes element covers, windscreens and a clothing clip. Learn More... Shure PG14/PG30 Wireless Headset System New $299.95 List: $45 0.00SAVE: 33% In stock 25 people rate: 7 out of 10 A comprehensive first step into professional wireless, Performance Gear Wireless Systems are engineered to the same uncompromising quality standards as PGX, SLX, ULX and UHF-R wireless. Marrying superior sound quality and stage-proven endurance with advanced features like Internal Antenna Diversity and frequency selectability, Performance Gear Wireless fulfils the promise of independent, confident performance in freedom from the wire. Learn More... Nady UHF3 Headset Diversity Wireless System New $134.95 List: $169.95SAVE: 20% In stock 56 people rate: 8 out of 10 The latest breakthrough in affordable UHF wireless - with state-of-the-art features for the demanding professional on a limited budget. Operates on single frequencies in the wide-open, uncluttered UHF 470 MHz - 510 MHz band. Learn More... Audio Technica ATW2192TH Headset Wireless System New $549.95 List: $799.00SAVE: 31% 4 payments of $137.48 In stock The 2000 Series is a 10-channel frequency-agile UHF wireless system designed to suit a variety of applicat http://www.chinese-microphone.com/Wireless-Microphones.html ions, including MI/live performance, fixed installation, public address, A/V rental houses, and places of worship. It offers true diversity operation, easy setup, automatic frequency scanning with interference- free performance, and all the advantages of a high-quality, professional wireless system at an extremely affordable price. Learn More... Audio Technica ATW251H Headset Wireless System New $144.95 List: $249.95SAVE: 42% In stock 1 person rates: 6 out of 10 Audio- Technica's Freeway 200 Series Wireless Systems are designed to provide reliable performance, easy setup and clear, natural sound quality. Each 200 Series professional VHF wireless system includes a receiver and either a body-pack transmitter or a handheld microphone/ transmitter on a specific crystal-controlled frequency. A novel dipole antenna system on the receiver improves operation by providing a ground element in addition to the usual signal element. Learn More... Shure PG1288/PG30 Wireless Handheld and Headset System New $549.95 List: $850.00SAVE: 35% 4 payments of $137.48 In stock 3 people rate: 7 out of 10 A comprehensive first step into professional wireless, Performance Gear Wireless Systems are engineered to the same uncompromising quality standards as PGX, SLX, ULX and UHF-R wireless. Marrying superior sound quality and stage-proven endurance with advanced features like Internal Antenna Diversity and frequency selectability, Performance Gear Wireless fulfils the promise of independent, confident performance in freedom from the wire. Learn More... Shure ULXS1430 UHF Wireless Headset System New $729.00 List: $1,101.02SAVE: 33% 4 payments of $182.25 In stock 17 people rate: 7 out of 10 ULX Standard UHF systems represent a breakthrough in performance and price for both working musicians and professional sound installers. Multiple system configurations provide limitless options, each with a choice of legendary Shure microphone transmitters. Over 1400 selectable, pre-programmed frequencies are available, and Automatic Frequency Selection provides a straight shot to a clear channel. Learn More... Samson Stage 5 Vocal Headset Wireless System New $99.00 List : $159.99SAVE: 38% In stock 24 people rate: 7 out of 10 Incredible reception, crystal clear sound in a VHF system priced to bring the freedom of wireless to everyone. The Stage 5 system offers transmitters for every application including handheld, headset and lavalier microphone styles. Great for guitars too, just plug in with a Samson GC5 guitar cable. Learn More... Behringer UL2000B UHF Wireless Headset System New $229.99 List: $289.99SAVE: 20% In stock BEHRINGER go http://www.chinese-microphone.com/Wireless-Microphones.html es wireless at a performance level and price that's unheard of! With the revolutionary ULTRALINK UL2000B true diversity headset system, you will experience one of the best performing and innovative designs available in this segment. Learn More... AKG WMS40 Pro Sports Set Single Wireless System with C444L Headset New $199.00 List: $319.00SAVE: 37% Blowouts save up to $19! Only 1 left! 8 people rate: 6 out of 10 Highly versatile: the WMS 40 PRO instrumental set. The convenient PT 40 PRO bodypack is the smallest and lightest transmitter in its class. The new C 444 L head-worn microphone from AKG is rugged, extremely easy to use, and offers outstanding price/performance. Learn More... ElectroVoice RE2 UHF Wireless Headset System with RE97 New $699.95 List: $1,020.00SAVE: 31% 4 payments of $174.98 Only 2 left! 2 people rate: 10 out of 10 The RE-2 Wireless product is available in eleven different system configurations packed in a hard plastic carrying case. The systems include transmitters and micriphones as indicated. Whether you're performing at the local rock club, lecturing at a corporate seminar, or speaking in a house of worship, the Electro- Voice RE-2 brings ease-of-use, clear sound, and clean channels to wireless. Learn More... 1 2 Next -> Related Brands X2 DigitalAudio TechnicaAudio Technica WirelessNadyNady WirelessBehringerOther Behringer GeminiSennheiserSennheiser WirelessAKGAKG Wireless Electro- VoiceElectro-Voice MicrophonesSamsonSamson Wireless MicrophonesShureShure Wireless Microphones Free Catalog First Name Last Name Address 1 Address 2 City State Zip Email Would you like to receive periodic email notices of new items, special buys, and promotions? WE WILL NOT SHARE YOUR EMAIL ADDRESS WITH ANYONE ELSE. You can unsubscribe at any time. yesno submit Tell us Is there something you want to tell us? How can we serve you better? Want to see different products? Is this shirt ugly? Let us know! Email Address submit Questions? Our musicians can help you right now! Call Toll Free: 866.ZZOUNDS (996.8637) Open until 10PM EST Mention priority code 4RV2WX when you call Toll Free En Español: 800.460.7976 9AM to 5PM EST SEARCH Add Something to Your Cart FAQ | Contact Us | Sitemap | Affiliate Program Shop with those who respect your privacy— we do. Copyright © 1996-2008, zZounds Music, LLC. Terms of use apply. Wholesale Wireless Microphone From andreas.eisele at gmail.com Sat Apr 12 12:11:08 2008 From: andreas.eisele at gmail.com (andreas.eisele at gmail.com) Date: Sat, 12 Apr 2008 09:11:08 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> Message-ID: <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> I should have been more specific about possible fixes. > > python2.5 -m timeit 'gc.disable();l=[(i,) for i in range(2000000)]' > > 10 loops, best of 3: 662 msec per loop > > > python2.5 -m timeit 'gc.enable();l=[(i,) for i in range(2000000)]' > > 10 loops, best of 3: 15.2 sec per loop > > In the latter case, the garbage collector apparently consumes about > 97% of the overall time. > In a related thread on http://bugs.python.org/issue2607 Amaury Forgeot d'Arc suggested a setting of the GC thresholds that actually solves the problem for me: > Disabling the gc may not be a good idea in a real application; I suggest > you to play with the gc.set_threshold function and set larger values, at > least while building the dictionary. (700, 1000, 10) seems to yield good > results. > python2.5 -m timeit 'gc.set_threshold(700,1000,10);l=[(i,) for i in range(2000000)]' 10 loops, best of 3: 658 msec per loop which made me suggest to use these as defaults, but then Martin v. L?wis wrote that > No, the defaults are correct for typical applications. At that point I felt lost and as the general wish in that thread was to move discussion to comp.lang.python, I brought it up here, in a modified and simplified form. > I would suggest to configure the default behaviour of the garbage > collector in such a way that this squared complexity is avoided > without requiring specific knowledge and intervention by the user. Not > being an expert in these details I would like to ask the gurus how > this could be done. > I hope this should be at least technically possible, whether it is > really desirable or important for a default installation of Python > could then be discussed once the disadvantages of such a setting would > be apparent. I still don't see what is so good about defaults that lead to O(N*N) computation for a O(N) problem, and I like Amaury's suggestion a lot, so I would like to see comments on its disadvantages. Please don't tell me that O(N*N) is good enough. For N>1E7 it isn't. About some other remarks made here: > I think the linguists of the world should write better automated > translation systems. Not being an expert in these details I would like > to ask the gurus how it could be done. I fully agree, and that is why I (as someone involved with MT) would prefer to focus on MT and not on memory allocation issues, and by the way, this is why I normally prefer to work in Python, as it normally lets me focus on the problem instead of the tool. > There are going to be pathological cases in any memory allocation > scheme. The fact that you have apparently located one calls for you to > change your approach, not for the finely-tuned well-conceived garbage > collection scheme to be abandoned for your convenience. I do not agree at all. Having to deal with N>1E7 objects is IMHO not pathological, it is just daily practice in data-oriented work (we're talking about deriving models from Gigawords, not about toy systems). > If you had made a definite proposal that could have been evaluated you > request would perhaps have seemed a little more approachable. I feel it is ok to describe a generic problem without having found the answer yet. (If you disagree: Where are your definite proposals wrt. MT ? ;-) But I admit, I should have brought up Amaury's definite proposal right away. > A question often asked ... of people who are creating > very large data structures in Python is "Why are you doing that?" > That is, you should consider whether some kind of database solution > would be better. You mention lots of dicts--it sounds like some > balanced B-trees with disk loading on demand could be a good choice. I do it because I have to count frequencies of pairs of things that appear in real data. Extremely simple stuff, only interesting because of the size of the data set. After Amaury's hint to switch GC temporarily off I can count 100M pairs tokens (18M pair types) in about 15 minutes, which is very cool, and I can do it in only a few lines of code, which is even cooler. Any approach that would touch the disk would be too slow for me, and bringing in complicated datastructures by myself would distract me too much from what I need to do. That's exactly why I use Python; it has lots of highly fine-tuned complicated stuff behind the scenes, that is just doing the right thing, so I should not have to (and I could not) re-invent this myself. Thanks for the helpful comments, Andreas From p at ulmcnett.com Wed Apr 23 23:49:04 2008 From: p at ulmcnett.com (Paul McNett) Date: Wed, 23 Apr 2008 20:49:04 -0700 Subject: function that accepts any amount of arguments? In-Reply-To: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> Message-ID: <48100330.8050502@ulmcnett.com> globalrev wrote: > if i want a function that can take any amount of arguments how do i > do? Put an asterisk before the argument name. > lets say i want a function average that accepts any number of integers > and returns the average. def avg(*args): return sum(args) / len(args) There are some dangers (at least two glaring ones) with this code, though, which I leave as an exercise for the reader. :) Paul From hat at se-162.se.wtb.tue.nl Wed Apr 16 09:20:01 2008 From: hat at se-162.se.wtb.tue.nl (A.T.Hofkamp) Date: Wed, 16 Apr 2008 15:20:01 +0200 Subject: is file open in system ? - other than lsof References: Message-ID: On 2008-04-16, bvidinli wrote: > is there a way to find out if file open in system ? - > please write if you know a way other than lsof. because lsof if slow for me. > i need a faster way. > i deal with thousands of files... so, i need a faster / python way for this. > thanks. This is not a Python question but an OS question. (Python is not going to deliver what the OS doesn't provide). Please first find an alternative way at OS level (ie ask this question at an appropiate OS news group). Once you have found that, you can think about Python support for that alternative. Sincerely, Albert From aaron.watters at gmail.com Tue Apr 29 10:07:54 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Tue, 29 Apr 2008 07:07:54 -0700 (PDT) Subject: simple chemistry in python References: <5e3717e5-1913-4bda-94b3-ae165e5fb8ba@m73g2000hsh.googlegroups.com> Message-ID: On Apr 29, 8:41 am, baoilleach wrote: > ....This file is part of the Blue Obelisk Data Repository, an effort by > several chemistry software developers to share common information.... This ref is incredibly cool. Is there a guide or meta-index for similar open scientific data repositories (not web search forms: downloadable complete data)? -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=valence From ellingt8877 at gmail.com Mon Apr 28 01:45:48 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:45:48 -0700 (PDT) Subject: mystery the lottery ticket crack Message-ID: <0870366c-8332-46ea-886f-36453249a1d0@m3g2000hsc.googlegroups.com> mystery the lottery ticket crack http://crack.cracksofts.com From sevenjp at gmail.com Wed Apr 2 12:06:58 2008 From: sevenjp at gmail.com (=?ISO-8859-1?Q?Jo=E3o_Neves?=) Date: Wed, 2 Apr 2008 09:06:58 -0700 (PDT) Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> Message-ID: On Apr 2, 4:35 pm, castiro... at gmail.com wrote: > Are Python bytes codes Python byte codes? I'm not quite sure I understood your question, sorry. > Do you foresee any machine-dependent optimizations? In my personal case, I am not looking for optimizations in the generated bytecode. Let me give a very basic example. Say we have these two functions: def inc(x): x = x + 1 def dec(x): x = x - 1 Examining the compiled bytecodes for these two functions: >>> inc.func_code.co_code '|\x00\x00d\x01\x00\x17}\x00\x00d\x00\x00S' >>> dec.func_code.co_code '|\x00\x00d\x01\x00\x18}\x00\x00d\x00\x00S' Now suppose that I wanted to mess with inc, and have it behave like dec. For that, I would like to do something like this, for instance: >>> inc.func_code.co_code = '|\x00\x00d\x01\x00\x18}\x00\x00d\x00\x00S' Of course, as of this moment, I get a TypeError exception, because co_code is read-only. The thing I've been wondering is why _is_ it read-only? In what circumstances having write access to co_code would break the language or do some other nasty stuff? Jo?o Neves From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Thu Apr 10 14:21:43 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Thu, 10 Apr 2008 20:21:43 +0200 Subject: How is GUI programming in Python? References: Message-ID: <66745nF2j0p2vU1@mid.individual.net> Chris Stewart wrote: > I've always had an interest in Python and would like to dabble in > it further. I've worked on a few very small command line programs > but nothing of any complexity. I'd like to build a really simple > GUI app that will work across Mac, Windows, and Linux. How > painful is that going to be? I've built and am maintaining a not-so-simple-anymore cross platform GUI application using wxPython (running in GNU/Linux (GTK+) and Windows (XP/Vista)). It integrates well since wxPython uses native widgets. The only problems I face are minor looks problems with some widgets, e. g. tooltips with line breaks or list controls with custom font. Custom widgets work very well. Windows fonts BTW are a real pain since they have almost no unicode characters, compared to today's GNU/Linux distributions. Regards, Bj?rn -- BOFH excuse #383: Your processor has taken a ride to Heaven's Gate on the UFO behind Hale-Bopp's comet. From mail.ilocke at gmail.com Tue Apr 29 18:29:12 2008 From: mail.ilocke at gmail.com (ivan) Date: Tue, 29 Apr 2008 15:29:12 -0700 (PDT) Subject: Simple import question about mac osx References: Message-ID: <11d9cb49-7fbe-4c47-b2a8-a5f004217c9a@x35g2000hsb.googlegroups.com> On Apr 29, 3:47?pm, "Jerry Hill" wrote: > When you run your code in pythonwin, it's just like calling 'python -i > chap2.py' ?It runs the code in chap2.py, then gives you an interpreter > window to interact with your code. ?In this case, that means that > FooClass is visible with no import at all, because it was defined in > the scope of the currently running script, as opposed to being > imported. > > You haven't said exactly how you're doing this on your mac, but I'm > guessing that you're opening a command line, starting up the python > interpreter, then going from there? > > Can someone help me out? ?I'm running into a mental block on how to > explain the difference between doing this: > C:\Python25>python -i chap2.py>>> foo1=FooClass() jmDesktop, With what Jerry stated, You can see what is happening under PythonWin interactive window by doing: >>> dir() before and after running chap2.py and see that FooClass is defined without import, which gives a clue that PythonWin is not running the script independant of the interactive window. Or try adding the following to the end of your chap2.py: print "Hello World" somevar = 12345 And run in PythonWin and see what happens to your interactive window and if somevar is defined. If you close and open PythonWin and use the interactive window without having first run chap2.py, you will find it behaves the same as the mac. Ivan From duncan.booth at invalid.invalid Wed Apr 2 09:12:35 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 2 Apr 2008 13:12:35 GMT Subject: Nested try...except References: Message-ID: Magnus.Moraberg at gmail.com wrote: > Hi, > > I found the following code on the net - > > http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/% > 3C20050924104732.5116.qmail at minotaur.apache.org%3E > > def count(self): > - db = sqlite.connect(self.filename, > isolation_level=ISOLATION_LEVEL) > - try: > - try: > - cur = db.cursor() > - cur.execute("select count(*) from sessions") > - return cur.fetchone()[0] > - finally: > - cur.close() > - finally: > - db.close() > > I don't understand though why the second try is not after the line cur >= db.cursor(). Can anyone explain for me why? > Simple: because not all code found on the net is correct. From jcd at unc.edu Tue Apr 1 16:25:05 2008 From: jcd at unc.edu (J. Cliff Dyer) Date: Tue, 01 Apr 2008 16:25:05 -0400 Subject: manipulating hex values In-Reply-To: <47F28855.50908@u4eatech.com> References: <47F26CC3.3060307@u4eatech.com> <47F28855.50908@u4eatech.com> Message-ID: <1207081505.3833.12.camel@aalcdl07.lib.unc.edu> On Tue, 2008-04-01 at 12:09 -0700, Stephen Cattaneo wrote: > > The source of my confusion is that I need to keep my bytes formated > correctly. I am using the below 'raw socket example' proof-of-concept > code as my example. (And yes, I have tried the proof-of-concept. It > works correctly. It is not my code.) > dstAddr = "\x01\x02\x03\x04\x05\x06" > dstAddr1 = "0x010203040506" > dstAddr != dstAddr1 > > Follow up question: What is the best to store my bytes up until sending > the packets? Perhaps I should use lists of decimal numbers and then > before sending convert to hex. > I.E. dstAddr = [ 1, 2, 3, 4, 5, 6] > dstAddr.prepareToSend() > txFrame = struct.pack("!6s6sh",dstAddr,srcAddr,proto) + ethData > > Is there a better way to do this? > > Thanks, > > Steve Those are not lists of decimal numbers. Those are lists of binary numbers which are represented as decimal in the default conversion to strings. py>>> assert [10, 11, 12] == [0xa, 0xb, 0xc] py>>> Don't worry about the formatting until you output them to strings. The numbers are in there, and have the proper value, regardless of how you input them. When you need to output them, you can use standard string formatting to get the format you desire: py>>> a=30 py>>> "%i is decimal" % a '30 is decimal' py>>> "%x is hexadecimal" % a '1e is hexadecimal' py>>> "0x%x is hex prepended with 0x" % a '0x1e is hex prepended with 0x' >>> "0%o is octal prepended with 0" % a '036 is octal prepended with 0' You are making your life more complicated than you need to. Cheers, Cliff From brian.e.munroe at gmail.com Thu Apr 3 00:36:42 2008 From: brian.e.munroe at gmail.com (Brian Munroe) Date: Wed, 2 Apr 2008 21:36:42 -0700 (PDT) Subject: class / module introspection? References: <3c3f09df-08cb-4309-a870-6b12a813a8af@u36g2000prf.googlegroups.com> <0f14a289-55ef-49e5-b650-60f7aca371ad@i36g2000prf.googlegroups.com> <033570bc-c5f3-4575-8dae-51780e68d2d7@m3g2000hsc.googlegroups.com> Message-ID: On Apr 2, 2:26 pm, 7stud wrote: > > You don't need that helper function, which is a little tricky to > follow: > Well, I appreciate the code sharing you did, but the helper function is nice and compact, and I didn't have much trouble following it. I ended up doing the following in the backends/__init__.py: import os availableBackendsList = [] for module in os.listdir(__path__[0]): if not module.startswith("__") and not module.startswith("."): availableBackendsList.append("backends." + module) def subpackage_import(name): mod = __import__(name) components = name.split('.') for comp in components[1:]: mod = getattr(mod, comp) return mod def get_available_backends(): return map(subpackage_import, availableBackendsList) In then in my application code, it becomes a simple matter of: import backends for x in backends.get_available_backends(): print x.PLUGIN_NAME be = x.Backend() print be.getStatus() Basically, I borrowed a page out of Dive into Python[1] and mapped each module object (system1, system2, ... systemN) to a list. [1] - Thanks Mark! - http://www.diveintopython.org/functional_programming/all_together.html From gagsl-py2 at yahoo.com.ar Tue Apr 8 00:44:38 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 08 Apr 2008 01:44:38 -0300 Subject: read large zip file References: <47fadf75$0$36387$742ec2ed@news.sonic.net> Message-ID: En Tue, 08 Apr 2008 00:10:01 -0300, John Nagle escribi?: > Gabriel Genellina wrote: >> En Sun, 06 Apr 2008 19:20:31 -0300, Brian Blais >> escribi?: >> >>> I need to read a series of large zipfiles (which only contain one >>> large text file), and I noticed that the zipfile module: >> >> Use the module from the 2.6 version; it appears to work fine even on >> Python 2.4 (see this thread > > It's easier than that: > > fd = gzip.open(filename, 'rb') > for line in fd : > processline(line) > > This works even in Python 2.4. I use this routinely for processing big > log files. That works for gzipped files, but the OP said "zipfiles" which aren't the same thing. It might be a generic term too - we'll have to wait until he gives any feedback... -- Gabriel Genellina From john106henry at hotmail.com Tue Apr 29 01:40:11 2008 From: john106henry at hotmail.com (John Henry) Date: Mon, 28 Apr 2008 22:40:11 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <473deef3-9acb-45dd-a7ca-47b0081bd28c@i36g2000prf.googlegroups.com> Message-ID: <3f7bb91e-335e-46bd-88ca-f15b26c35132@k1g2000prb.googlegroups.com> On Apr 28, 12:41 pm, John Henry wrote: > On Apr 27, 12:23 pm, Fred Pacquier wrote: > > > > > Do keep us posted ! > > > TIA, > > fp > > Check it out now. > > Only one to be added is the Multicolumn List (table), and then menus. > The other widgets (Togglebutton, BitmapCanvas, Gauge, Notebook, > CodeEditor) will not be implemented initially. > > http://test.powersystemadvisors.com table and menus all work From steve at holdenweb.com Sat Apr 12 20:58:35 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 20:58:35 -0400 Subject: Tremendous slowdown due to garbage collection In-Reply-To: <7x8wzi7f9x.fsf@ruckus.brouhaha.com> References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> <32e2acc1-97cb-4911-bb0c-67965b5ff113@2g2000hsn.googlegroups.com> <7x8wzi7f9x.fsf@ruckus.brouhaha.com> Message-ID: Paul Rubin wrote: > Steve Holden writes: >> I believe you are making surmises outside your range of competence >> there. While your faith in the developers is touching, the garbage >> collection scheme is something that has received a lot of attention >> with respect to performance under typical workloads over the years. > > Really, Python's cyclic gc is quite crude and should be upgraded to > something that doesn't fall into that quadratic behavior. There was > some fairly detailed discussion of this in another thread last time > the subject came up. I'll take your word for it. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From lists at cheimes.de Tue Apr 22 16:55:14 2008 From: lists at cheimes.de (Christian Heimes) Date: Tue, 22 Apr 2008 22:55:14 +0200 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: References: Message-ID: Nick Craig-Wood schrieb: > Nothing apart from the fact it doesn't work on windows. The buffering > will cause you grief too. If you want to do this properly under unix > use pexpect not subprocess. > > http://www.noah.org/wiki/Pexpect > > Proper non blocking IO is an absolute nightmare under Windows in my > experience! It really isn't the Windows way so you are fighting the > system the whole time. Nick is correct. The subproces tries to work around the issues with threads. But it's no more than an ugly workaround fir Windows' short comings on async file IO. It's a shame Windows implements the select() syscall in wsock32 and limits its usage to sockets. By the way I'm willing to dedicate some time to help enhancing the subprocess. Everybody is invited to submit patches and I'll review and check them into the trunk and py3k ASAP. Any help is appreciated: enhancements for async IO, doc updates, more examples ... Christian Python core developer From gagsl-py2 at yahoo.com.ar Wed Apr 9 02:36:06 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 03:36:06 -0300 Subject: makepy.py not working References: <03e9c33d-d957-4bc0-8568-3a40403eadb9@a70g2000hsh.googlegroups.com> Message-ID: En Tue, 08 Apr 2008 10:18:48 -0300, escribi?: > I've a problem getting makepy running. When I start the tool on my > machine with doubleclick everything is fine. > But when I try this in my Code: > > makepy.py -i "Microsoft Excel 11.0 Object Library(1.5)" The above is supposed to be executed as a command, in a CMD console. It's not pyton code. > I am getting an Syntax Error and command: > > makepy.py > > bring me this message on the screen: > > Traceback (most recent call last): > File "", line 1, in > NameError: name 'makepy' is not defined Same as above: makepy.py is a filename, not a Python expression. > Any ideas what I am doing wrong? What do you actually want to do? The documentation for makepy and win32com.client.gencache is in the pywin32 help files, section Quick-Starts to Python and COM. -- Gabriel Genellina From musiccomposition at gmail.com Fri Apr 18 22:44:07 2008 From: musiccomposition at gmail.com (Benjamin) Date: Fri, 18 Apr 2008 19:44:07 -0700 (PDT) Subject: How to print a unicode string? References: <4809394A.1030906@v.loewis.de> Message-ID: <871c9b6b-7ebb-45b6-bf79-009bc2e0c1ce@c65g2000hsa.googlegroups.com> On Apr 18, 7:14 pm, "Martin v. L?wis" wrote: > > From what I've googled, I think I need to set my locale. > > Not on this operating system. On Windows, you need to change > your console. If it is a cmd.exe-style console, use chcp. > For IDLE, changing the output encoding is not supported. > > If you want to output into a file, use codecs.open. > > If you absolutely want to output UTF-8 to the terminal even > though the terminal will not be able to render it correctly, > use > > sys.stdout = codecs.getwriter("UTF-8")(sys.stdout) And in Py3k? > > HTH, > Martin From rhamph at gmail.com Wed Apr 16 15:39:55 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Wed, 16 Apr 2008 12:39:55 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> <09a38ca2-8c49-4eee-b6cf-58e849aea1fc@q1g2000prf.googlegroups.com> Message-ID: <8a96fe1f-1625-4ab5-942b-217ed42782a7@e67g2000hsa.googlegroups.com> On Apr 16, 12:52 pm, Aaron Watters wrote: > On Apr 16, 2:33 pm, Rhamphoryncus wrote: > > > The point is, you can't have it both ways. Either you evolve the > > language and break things, or you keep it static and nothing breaks. > > I disagree. You can add lots of cool > stuff without breaking the existing code base, mostly. > For example the minor changes to the way ints will work will > effect almost no programs. What changes are minor though? Eliminating old-style classes should be minor, but I'm not sure it is. Applications & libraries have a way of depending on the most obscure details - even if trivially fixed, it still requires a fix. Consider "as" becoming a keyword, or True and False. In hindsight, it would have been better to add future imports for unicode literals and print-as-a-function back in 2.5. I guess the time machine was out of service. 2.6 will have to do (and that's what it's for.) I'm personally not too worried about the syntax changes though, they're superficial(!). What I am worried about is the library APIs changing to use unicode instead of bytes. It's not something you could do incrementally without providing two of every lib or two of every API - having .write() and .writeex() would suck. From j.foster.davis at gmail.com Wed Apr 16 03:26:29 2008 From: j.foster.davis at gmail.com (Jacob Davis) Date: Wed, 16 Apr 2008 00:26:29 -0700 Subject: Can't see variables declared as global in a function Message-ID: <175C22B8-EE9B-4FC2-BDB0-F1DC7EFD5F60@gmail.com> Hi. I have a hundred lines of code in a module that declare some global variables inside a function so that those variables can be used by other functions. I want to import this module so that I can more easily debug by looking at the value of individual variables. But when I try to reach these variables, I get a warning that they are not defined. I am on an Intel Mac running Leopard 10.5.2, Python 2.5 Here is an example of some code that has the same problem: #!/usr/bin/env python global isglobal isglobal=200 def somefunc(): global from_somefunc from_somefunc=5 def anotherfunc(): return from_somefunc+30 So during debugging I want to look at the variable from_somefunc here is my terminal output. I start by looking at dir(), then run somefunc(), then run anotherfunc(), then I want to look at from_somefunc but I get a warning: Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from test_vars import * >>> dir() ['__builtins__', '__doc__', '__name__', 'anotherfunc', 'isglobal', 'somefunc'] >>> somefunc() >>> anotherfunc() 35 >>> isglobal 200 >>> from_somefunc Traceback (most recent call last): File "", line 1, in NameError: name 'from_somefunc' is not defined >>> dir() ['__builtins__', '__doc__', '__name__', 'anotherfunc', 'isglobal', 'somefunc'] Is there a way that I can view from_somefunc? Thanks, Jake -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at holdenweb.com Sun Apr 13 08:20:05 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 13 Apr 2008 08:20:05 -0400 Subject: Rounding a number to nearest even In-Reply-To: <8e6dbc15-98f2-441d-bba4-d9ddb36f482d@i36g2000prf.googlegroups.com> References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> <01db54ab-1fca-4a51-8b98-510de224f40a@y21g2000hsf.googlegroups.com> <8e6dbc15-98f2-441d-bba4-d9ddb36f482d@i36g2000prf.googlegroups.com> Message-ID: Lie wrote: > On Apr 12, 3:44 am, hdante wrote: [snip] > > In short, choosing that x.0 is rounded down and x.5 is rounded up is > arbitrary but not without a reason. Don't "arbitrary" and "not without a reason" directly contradict one another? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From ivlenin at gmail.com Fri Apr 18 01:23:21 2008 From: ivlenin at gmail.com (I V) Date: Fri, 18 Apr 2008 05:23:21 GMT Subject: Database vs Data Structure? References: <61bf5f46-e917-4a98-b87f-8e5087cb07f7@a23g2000hsc.googlegroups.com> Message-ID: On Thu, 17 Apr 2008 19:30:33 -0700, erikcw wrote: > use some sort of data-structure (maybe > nested dictionaries or a custom class) and store the pickled > data-structure in a single row in the database (then unpickle the data > and query in memory). Why would you want to do this? I don't see what you would hope to gain by doing this, over just using a database. From paddy3118 at netscape.net Fri Apr 18 02:41:40 2008 From: paddy3118 at netscape.net (Donald 'Paddy' McCarthy) Date: Fri, 18 Apr 2008 07:41:40 +0100 Subject: pprint module and newer standard types Message-ID: Hi, When I try and use pprint on standard types I get varying 'quality of output'. Lists will wrap nicely to multiple lines as will dicts, but sets and defaultdicts give one long unreadable line. Is their a chance to get this changed so that more built-in types look pretty when printed with pprint? I just did a small trial on an early version of Python 3 and sets don't seem to obey pprint.pprints width argument, the same way that lists do: Python 3.0a1 (py3k:57844, Aug 31 2007, 16:54:27) [MSC v.1310 32 bit (Intel)] on win32 >>> from pprint import pprint as pp >>> pp(list(range(3)), width=4) [0, 1, 2] >>> pp(set(range(3)), width=4) {0, 1, 2} - Paddy. From deets at nospam.web.de Mon Apr 7 05:11:58 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Mon, 07 Apr 2008 11:11:58 +0200 Subject: ldap References: <050e9150-7bbf-4a46-8c63-9d61835b1429@d1g2000hsg.googlegroups.com> Message-ID: <65u6rqF2hfq7rU1@mid.uni-berlin.de> mr.enx at alice.it wrote: > sorry, i'm new with Python. > I must do interaction beetween Python and Ldap, and I don't know how > do this. > Searching on the web I know that exists PythonLdap, but I dont'know if > this is best choise or not. Who cares? Use it, and see if it's good enough for your needs. Then, if not, see if alternatives are better. There seldomly is "the best" if there are several options, because the details and quirks of various solutions might appeal to one and repulse someone else. But nobody is going to know what *you* like best. Diez From mobile at ibinsa.com Sun Apr 27 07:05:28 2008 From: mobile at ibinsa.com (Gabriel Ibanez) Date: Sun, 27 Apr 2008 13:05:28 +0200 Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com><10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <8ee48fc1-45af-404f-8fad-d8e1b2fb90b4@s50g2000hsb.googlegroups.com> Message-ID: <003601c8a856$9a8c29f0$0a01a8c0@mobile> I did something near like that several days ago. Instead of programming in C++ I did it with RM-Cobol. I used to know the times that cobol takes to read the file and search for resutls, and I was surprised about the time that Python took doing the same: really, really fast. ----- Original Message ----- From: "n00m" Newsgroups: comp.lang.python To: Sent: Sunday, April 27, 2008 6:28 AM Subject: Re: Python(2.5) reads an input file FASTER than pure C(Mingw) > One more brick. > This time I compare list.sort() vs sort(vector). > Incredible. Python does it by 8.3s / 2.75s = 3 times faster than C++. > > > import time > f=open('D:\\v.txt','r') > z=f.readlines() > f.close() > t=time.time() > z.sort() > print time.time()-t > m=int(raw_input()) > print z[m] > > > #include > #include > #include > #include > #include > #include > #include > > using namespace std; > > vector vs; > > FILE *fp=fopen("D:\\v.txt","r"); > > int main() { > int i=0; > while (true) { > char line[50]; > if (!fgets(line,50,fp)) break; > vs.push_back(line); > ++i; > } > fclose(fp); > > double t; > t=clock()/CLOCKS_PER_SEC; > sort(vs.begin(),vs.end()); > cout << clock()/CLOCKS_PER_SEC << endl; > > int m; > cin >> m; > cout << vs[m]; > getchar(); > return 0; > } > > -- > http://mail.python.org/mailman/listinfo/python-list > From tjreedy at udel.edu Wed Apr 9 18:12:27 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 9 Apr 2008 18:12:27 -0400 Subject: I am worried about Python 3 References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> Message-ID: "jmDesktop" wrote in message news:77c208d1-8163-4acf-8e88-bd704e05bc04 at e39g2000hsf.googlegroups.com... | Two new versions of the language are currently in development: version | 2.6, which retains backwards compatibility with previous releases; and | version 3.0, which breaks backwards compatibility to the extent that | even that simplest of programs, the classic 'Hello, World', will no | longer work in its current form. That change is however, the one most immediately visible to new programmers. Most of the other statements are pretty much unchanged. In any case, 'print' is an easy-to-use facade over sys.stdout.write(), with default formatting. If really concerned about it, start programs with import sys write = sys.stdout.write and use that to write out explicitly formatted strings. (Some people routinely do this for production code anyway.) tjr From python at rcn.com Thu Apr 24 22:23:35 2008 From: python at rcn.com (Raymond Hettinger) Date: Thu, 24 Apr 2008 19:23:35 -0700 (PDT) Subject: Little novice program written in Python References: Message-ID: > What I would like is to receive some criticism to my code to make it more > Python'esque and, possibly, use the resources of the computer in a more > efficient way (the algorithm implemented below is the Sieve of Eratosthenes): It looks like straight-forward code and is fine as it stands. If you want to tweak it a bit, you can avoid using a flag like "finished" by using a break-statement. Raymond From martin at v.loewis.de Mon Apr 7 16:50:51 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Mon, 07 Apr 2008 22:50:51 +0200 Subject: Data structure recommendation? In-Reply-To: References: Message-ID: <47FA892B.1050608@v.loewis.de> > I know that foo.get() will be called many times for each foo.put(). Is > there any way to achieve O(1) performance for foo.get(), maybe via > some kind of hash function? Or is the best thing to use some kind of > binary search? If you know something about the density of the input values, O(1) is possible. E.g if there is a guarantee that there will be between 1 and 10 values per unit of input, then truncate the "event time" to the next-lower int, and use that as an index k into a list; the list item will be a list of events between k and k+1. As you know that there is an upper bound to the number of such events (10), you know that searching the list will take bounded (i.e. constant) time. Likewise, as you know that there will be atleast one event per (k,k+1) interval, you know that you have to scan only one list. If you know no such thing, you'll have to use a binary search. Regards, Martin From kyosohma at gmail.com Wed Apr 16 10:26:18 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 16 Apr 2008 07:26:18 -0700 (PDT) Subject: Finally had to plonk google gorups. References: Message-ID: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> On Apr 16, 9:19 am, Grant Edwards wrote: > This morning almost half of c.l.p was spam. In order to try to > not tar both the benign google group users and the malignant > ones with the same brush, I've been trying to kill usenet spam > with subject patterns. But that's not a battle you can win, so > I broke down and joined all the other people that just killfile > everything posted via google.groups. > > AFAICT, if you're a google groups user your posts are not being > seen by many/most experienced (read "non-google-group") users. > This is mainly the fault of google who has refused to do > anything to stem the flood of span that's being sent via Google > Groups. > > -- > Grant Edwards grante Yow! I would like to > at urinate in an OVULAR, > visi.com porcelain pool -- Yeah, I noticed that Google Groups has really sucked this week. I'm using the Google Groups Killfile for Greasemonkey now and it helps a lot. I like Google, but my loyalty only goes to far. This is a complete lack of customer service. Mike From dolloffdelvpg at gmail.com Wed Apr 16 08:06:19 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:06:19 -0700 (PDT) Subject: taylor swift concert tickets Message-ID: <10dc46b8-303d-415a-b653-315c2887392b@n1g2000prb.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From bob at passcal.nmt.edu Mon Apr 21 17:06:08 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Mon, 21 Apr 2008 15:06:08 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> Message-ID: <2008042115060816807-bob@passcalnmtedu> On 2008-04-21 14:50:13 -0600, Ivan Illarionov said: > On 22 ???, 00:10, Ivan Illarionov wrote: >> On 20 ???, 04:10, George Sakkis w > rote: >> >> >> >>> On Apr 18, 9:36 pm, Ross Ridge >>> wrote: >> >>>> Ross Ridge said: >> >>>>> If you have Python 2.5, here's a faster version: >> >>>>> from struct import * >>>>> unpack_i32be = Struct(">l").unpack >> >>>>> def from3Bytes_ross2(s): >>>>> return unpack_i32be(s + "\0")[0] >> 8 >> >>>> Bob Greschke wrote: >> >>>>> That's not even intelligible. I wanna go back to COBOL. :) >> >>>> It's the same as the previous version except that it "precompiles" >>>> the struct.unpack() format string. It works similar to the way Python > >>>> handles regular expressions. >> >>> I didn't know about the Struct class; pretty neat. It's amazing that >>> this version without Psyco is as fast Bob's version with Psyco! Adding >>> Psyco to it though makes it *slower*, not faster. So here's how I'd >>> write it (if I wanted or had to stay in pure Python): >> >>> try: import psyco >>> except ImportError: >>> from struct import Struct >>> unpack_i32be = Struct(">l").unpack >>> def from3Bytes(s): >>> return unpack_i32be(s + "\0")[0] >> 8 >>> else: >>> def from3Bytes(s): >>> Value = (ord(s[0])<<16) + (ord(s[1])<<8) + ord(s[2]) >>> if Value >= 0x800000: >>> Value -= 0x1000000 >>> return Value >>> psyco.bind(from3Bytes) >> >>> HTH, >>> George >> >> I was able to get even faster pure-python version using array module: >> >> a = array.array('l', ''.join(('\0' + s[i:i+3] for i in xrange(0, >> len(s), 3)))) >> if sys.byteorder == 'little': >> a.byteswap() >> >> It actually moves bytes around on C level. >> >> test code: >> import struct >> import array >> import sys >> >> unpack_i32be = struct.Struct(">l").unpack >> s = ''.join(struct.pack('>i', 1234567)[1:]*1000) >> >> def from3bytes_ord(s): >> values = [] >> for i in xrange(0, len(s), 3): >> Value = (ord(s[i])<<16) | (ord(s[i+1])<<8) | ord(s[i+2]) >> if Value >= 0x800000: >> Value -= 0x1000000 >> values.append(Value) >> return values >> >> def from3bytes_struct(s): >> return [unpack_i32be(s[i:i+3] + "\0")[0] >> 8 for i in xrange(0, >> len(s), 3)] >> >> def from3bytes_array(s): >> a = array.array('l', ''.join(('\0' + s[i:i+3] for i in xrange(0, >> len(s), 3)))) >> if sys.byteorder == 'little': >> a.byteswap() >> return a.tolist() >> >> from timeit import Timer >> >> t1 = Timer("from3bytes_ord(s)", "from __main__ import s, >> from3bytes_ord") >> t2 = Timer("from3bytes_struct(s)", "from __main__ import s, >> from3bytes_struct") >> t3 = Timer("from3bytes_array(s)", "from __main__ import s, >> from3bytes_array") >> >> print 'ord:\t', t1.timeit(1000) >> print 'struct:\t', t2.timeit(1000) >> print 'array:\t', t3.timeit(1000) >> >> Output: >> ord: 7.08213110884 >> struct: 3.7689164405 >> array: 2.62995268952 >> >> Inspired by Guido's essayhttp://www.python.org/doc/essays/list2str/ > > And even faster: > a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, > len(s), 3)))) > if sys.byteorder == 'little': > a.byteswap() > > I think it's a fastest possible implementation in pure python Geeze! :) How did struct get so fast? I'm guessing there have been improvements since 2.3 (which is what I've been working on). I'm going to be able to go back to my IBM PC XT pretty soon. :) Thanks! From robert.kern at gmail.com Mon Apr 14 19:48:37 2008 From: robert.kern at gmail.com (Robert Kern) Date: Mon, 14 Apr 2008 18:48:37 -0500 Subject: py2exe, program has stoped working!? In-Reply-To: <67526f9f-a610-4cbe-8e2c-6219a59a4d54@i36g2000prf.googlegroups.com> References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> <232151d6-09ed-4a1e-9922-d66c2bf0d05b@w8g2000prd.googlegroups.com> <67526f9f-a610-4cbe-8e2c-6219a59a4d54@i36g2000prf.googlegroups.com> Message-ID: John Machin wrote: > So I found by googling "has stopped working". I'd never seen such a > litany of weeping, wailing and u'\u02ad' before. OT: Best use of Unicode ever. -- 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 From grante at visi.com Tue Apr 1 14:28:32 2008 From: grante at visi.com (Grant Edwards) Date: Tue, 01 Apr 2008 13:28:32 -0500 Subject: Homework help References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> <65fagoF2fiivoU1@mid.uni-berlin.de> Message-ID: On 2008-04-01, Marc 'BlackJack' Rintsch wrote: >> Write a function zip(lst1, lst2) such that zip accepts two equal >> length lists and returns a list of pairs. For example, zip(['a', 'b', >> 'c'], [10, 20, 30]) should evaluate to the list [('a', 10), ('b', 20), >> ('c', 30)]. > > Hey not even a rebinding necessary. :-) Yes it is. The problem statement is "write a function" not "select an existing standard library function" or "produce this answer in the least number of lines of code". -- Grant Edwards grante Yow! Will the third world at war keep "Bosom Buddies" visi.com off the air? From dickinsm at gmail.com Mon Apr 7 21:16:40 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Mon, 7 Apr 2008 18:16:40 -0700 (PDT) Subject: A funnily inconsistent behavior of int and float References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com><1d11875a-470a-489f-910a-b420a145eb61@a1g2000hsb.googlegroups.com><11b4793c-04cc-4898-99a8-8418d237de3e@2g2000hsn.googlegroups.com> <1255ee3e-cc1e-4ae8-96f3-5f942c389c49@t54g2000hsg.googlegroups.com> Message-ID: On Apr 7, 4:59?pm, "Terry Reedy" wrote: > "Mark Dickinson" wrote in message > > news:1255ee3e-cc1e-4ae8-96f3-5f942c389c49 at t54g2000hsg.googlegroups.com... > > Thank you for the corrections. Here is my revised proposal: > > int([number | string[, radix]) > ... Excellent! It looks to me as though this covers everything. I'm tempted to quibble about exact wordings, but probably the most productive thing to do would be just to submit this to bugs.python.org and then let Georg Brandl work his magic on it. :-) Mark From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Fri Apr 25 08:03:55 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Fri, 25 Apr 2008 14:03:55 +0200 Subject: Remove multiple inheritance in Python 3000 References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <60fc4333-6d2b-40f5-b311-031d90a38d39@k37g2000hsf.googlegroups.com> Message-ID: <67dvlbF2nomm6U2@mid.individual.net> sturlamolden wrote: > On Apr 22, 1:07 pm, GD wrote: >> Multiple inheritance is bad for design, rarely used and contains >> many problems for usual users. >> >> Every program can be designed only with single inheritance. > > That's how the Java designers were thinking as well: If MI is > allowed, programmers will suddenly get an irresistible urge to use > MI to write unmaintainable spaghetti code. So let's disallow MI > for the sake of common good. Argumenting like that, *all* programming languages had to be outlawed. 8) Regards, Bj?rn -- BOFH excuse #391: We already sent around a notice about that. From kayvoo at googlemail.com Fri Apr 18 19:50:16 2008 From: kayvoo at googlemail.com (Karl-Heinz Ruskowski) Date: Sat, 19 Apr 2008 01:50:16 +0200 Subject: python setup.py install on Vista? In-Reply-To: References: Message-ID: <200804190150.22542.kayvoo@gmail.com> hi > well using windows vista, where the h*** am i supposed to type this? you have to include the path to the python interpreter like this c:\programs\python\python.exe pythonfile.py (replace this with your path) or you set an alias called python - i don't know how to that under windows, especially visa :D good luck -- GPG key: 0x04B3BB96 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available URL: From skanemupp at yahoo.se Thu Apr 17 05:28:48 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 17 Apr 2008 02:28:48 -0700 (PDT) Subject: def power, problem when raising power to decimals References: Message-ID: <45c97b5a-e7ff-4f22-b419-62766c210406@d1g2000hsg.googlegroups.com> actually that 0**0 statement was wrong. 0**0 = 1 and should be. From aahz at pythoncraft.com Sat Apr 26 11:46:49 2008 From: aahz at pythoncraft.com (Aahz) Date: 26 Apr 2008 08:46:49 -0700 Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> Message-ID: In article <9028496e-30de-4853-8f57-b55d14e52358 at h1g2000prh.googlegroups.com>, John Henry wrote: > >But then I looked closer. It turns out the XML file created by >QxTransformer is *very* similar in structure when compared to the >resource files used in PythonCard. Since there are no GUI builders >for QxTransformer, and I can't affort to buy the one for Qooxdoo >(Java! Yuk!), I decided to roll up my sleeves, took the Pythoncard's >Layout Manager and modified it and created my own "Poor Man's Qooxdoo >GUI Layout Designer". Cute! When you have working code, please do upload to PyPI. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ Why is this newsgroup different from all other newsgroups? From jeff_barish at earthlink.net Wed Apr 23 21:48:05 2008 From: jeff_barish at earthlink.net (Jeffrey Barish) Date: Wed, 23 Apr 2008 19:48:05 -0600 Subject: Problem using copy.copy with my own class References: <676noiF2n7ttmU1@mid.uni-berlin.de> Message-ID: Marc 'BlackJack' Rintsch wrote: > Please simplify the code to a minimal example that still has the problem > and *show it to us*. It's hard to spot errors in code that nobody except > you knows. Here it is: import copy class Test(int): def __new__(cls, arg1, arg2): return int.__new__(cls, arg1) def __init__(self, arg1, arg2): self.arg2 = arg2 if __name__ == '__main__': t = Test(0, 0) t_copy = copy.copy(t) Traceback (most recent call last): File "copytest.py", line 12, in t_copy = copy.copy(t) File "/usr/lib/python2.5/copy.py", line 95, in copy return _reconstruct(x, rv, 0) File "/usr/lib/python2.5/copy.py", line 322, in _reconstruct y = callable(*args) File "/usr/lib/python2.5/copy_reg.py", line 92, in __newobj__ return cls.__new__(cls, *args) TypeError: __new__() takes exactly 3 arguments (2 given) -- Jeffrey Barish From gagsl-py2 at yahoo.com.ar Sun Apr 20 13:58:00 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 14:58:00 -0300 Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B80B5.1050500@cheimes.de> Message-ID: En Sun, 20 Apr 2008 14:43:17 -0300, Christian Heimes escribi?: > Gabriel Genellina schrieb: >> Apart from what everyone has already said, consider that FreqDist may import other modules, store global state, create other objects... whatever. >> Pure python code should not have any memory leaks (if there are, it's a bug in the Python interpreter). Not-carefully-written C extensions may introduce memory problems. > > Pure Python code can cause memory leaks. No, that's not a bug in the > interpreter but the fault of the developer. For example code that messes > around with stack frames and exception object can cause nasty reference > leaks. Ouch! May I assume that code that doesn't use stack frames nor stores references to exception objects/tracebacks is safe? -- Gabriel Genellina From fabiofz at gmail.com Fri Apr 4 17:07:28 2008 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Fri, 4 Apr 2008 18:07:28 -0300 Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? In-Reply-To: <0c8bfed7-1154-41d5-a740-6d1382180db2@d45g2000hsc.googlegroups.com> References: <0c8bfed7-1154-41d5-a740-6d1382180db2@d45g2000hsc.googlegroups.com> Message-ID: On Fri, Apr 4, 2008 at 5:05 PM, Nebur wrote: > Yes. Linux viruses are rare but useful :-) > Well, I don't think the problem a very dangerous one. The Pydev/ > Eclipse was used for much more than a year nearly daily and > intensively. The strange effect is very rare,obviously (plus the > chance that it's in my brain, as I mentioned ;-D ) so you probably can > lean back. Anyway, I'd be glad to get an even faint idea of the > problem. Hi Nebur, Well, I have absolutely no idea of what could trigger that either :( So, just wanted to point out that eclipse saves your file history (even if you do not have a vcs)... that operation can be selected by right clicking a parent folder and selecting 'restore from local history'. Cheers, Fabio From ceres83 at gmail.com Fri Apr 18 11:55:16 2008 From: ceres83 at gmail.com (Mario Ceresa) Date: Fri, 18 Apr 2008 17:55:16 +0200 Subject: Pickle problem Message-ID: Hello everybody: I'd like to use the pickle module to save the state of an object so to be able to restore it later. The problem is that it holds a list of other objects, say numbers, and if I modify the list and restore the object, the list itself is not reverted to the saved one, but stays with one element deleted. An example session is the following: Data is A [1, 2, 3, 4] saving a with pickle Deleting an object: del a[3] Now data is A [1, 2, 3] Oops! That was an error: can you please recover to the last saved data? A [1, 2, 3] #### I'd like to have here A[1,2,3,4]!!!!!! Is it the intended behavior for pickle? if so, are there any way to save the state of my object? Code follows ----------------------- class A(object): objects = [] ----------------------- then I run the code: --------------------------------------- import pickle from core import A a = A() for i in [1,2,3,4]: a.objects.append(i) savedData = pickle.dumps(a) print "Saved data is ",a print "Deleting an object" del a.objects[3] print a print "Oops! This was an error: can you please recover the last saved data?" print pickle.loads(savedData) -------------------------------------------- Thank you for any help! Mario From deets at nospam.web.de Tue Apr 29 19:30:27 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 30 Apr 2008 01:30:27 +0200 Subject: API's and hardware communication. Newbie In-Reply-To: References: <_MudnfZZ9uW0hY7VRVnyhwA@bt.com> Message-ID: <67ppciF2ppl3sU2@mid.uni-berlin.de> Grayham schrieb: > It seems to me that python needs to be extended with C in some form to able > to do what i need. I think instead of learning two languages i am going to > put all my efforts in to learning C as it seems that's where i am going to > end up. It's your decision of course. But you will end up in much more frustration than learning python (maybe by not picking an endeavour so big that it needs C on a certain level) and then after you have a good grasp of general concepts try and adapt these to other languages such as C. But again - you decide which road you prefer to go. Diez From paul at boddie.org.uk Mon Apr 21 05:01:08 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Mon, 21 Apr 2008 02:01:08 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> <48a1d10c-87cb-43c3-83f4-9c331fc1d818@m1g2000pre.googlegroups.com> Message-ID: On 21 Apr, 00:54, Dan Bishop wrote: > > We wouldn't even need that. Just a new source encoding. Then we > could write: > > # -*- coding: end-block -*- [...] Someone at EuroPython 2007 did a lightning talk showing working code which provided C-style block structuring using this mechanism. My brother then jokingly suggested to Martijn Faassen that if someone plugged the 2to3 converter in as a source file encoding handler, his worries about migrating to Python 3 would disappear. I'm waiting to see if anyone actually bothered to make that happen, albeit for amusement purposes only. Paul P.S. EuroPython 2008 is now accepting talks, especially ones on the language, Python 3000, and other implementations. See http://www.europython.org/ for details! From skanemupp at yahoo.se Thu Apr 10 12:32:17 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 09:32:17 -0700 (PDT) Subject: Tkinter: Entry, how to get INSERTpos? Message-ID: <3c5ddae0-906e-4800-80e2-bba1e6462e79@z24g2000prf.googlegroups.com> in this function i want to be able to use the cursor and delete in the middle of a number. how do i get the value of anchor or insert? i want to write: e.delete(pos-1,pos) def Backspace(): a=len(e.get()) e.delete(a-1,END) #e.delete(INSERT, END) #e.delete(ANCHOR,END) the complete program: from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") l = Label(mygui, text="Answer: ") l.place(relx=0.15, rely=0.2, anchor=CENTER) e = Entry(mygui) e.place(relx=0.48, rely=0.1, anchor=CENTER, width=173) c = Entry(mygui) c.place(relx=0.6, rely=0.2, anchor=CENTER) def Disp(nstr): e.insert(INSERT, nstr) def Calc(): expr=e.get() c.delete(0, END) try: c.insert(END, eval(expr)) except: c.insert(END, "Not computable") def Erase(): e.delete(0,END) c.delete(0, END) def Backspace(): a=len(e.get()) e.delete(a-1,END) #e.delete(INSERT, END) #e.delete(ANCHOR,END) x = 0.1 y = 0.4 for char in '123+456-789*0()/.': b = Button(mygui, text=char, command=lambda n=char:Disp(n), width=2, height=1) b.place(relx=x, rely=y, anchor=CENTER) x=x+0.1 if x==0.5: x=0.1 y=y+0.1 b = Button(mygui, text="^", command=lambda n="**":Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.8, anchor=CENTER) b = Button(mygui, text="C",command=Erase, width=2, height=1) b.place(relx=0.3, rely=0.8, anchor=CENTER) b = Button(mygui, text="c",command=Backspace, width=2, height=1) b.place(relx=0.4, rely=0.8, anchor=CENTER) b = Button(mygui, text="=",command=Calc, width=12, height=1) b.place(relx=0.25, rely=0.9, anchor=CENTER) mygui.mainloop() From subhabrata.iisc at hotmail.com Tue Apr 8 04:24:53 2008 From: subhabrata.iisc at hotmail.com (subhabrata.iisc at hotmail.com) Date: Tue, 8 Apr 2008 01:24:53 -0700 (PDT) Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. Message-ID: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> I am using Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v. 1310 32 bit (Intel)] on win32 with IDLE 1.2.1 My O/S is Windows XP SP2 I use 512 MB RAM. I am encountering the following problems: (i) a1=1 a2=2 a3=a1+a2 print a3 # The result is coming sometimes as 3 sometimes as vague numbers. (ii) x1="Bangalore is called the Silicon Valley of India" x2="NewYork" x3=x1.find(x2) print x3 # The result of x3 is coming as -1 as well as +ve numbers. (iii) I have been designing one crawler using "urllib". For crawling one web page it is perfect. But when I am giving around 100 URLs by and their links and sublinks the IDLE is not responding. Presently I have been running with 10 URLs but can't it be ported? (iv) I have designed a program with more than 500 if elif else but sometimes it is running fine sometimes it is giving hugely erroneous results, one view of the code: elif a4==3: print "YOU HAVE NOW ENTERED THREE WORDS" if a3[0] not in a6: if a3[1] not in a6: if a3[2] not in a6: print "a3[0] not in a6, a3[1] not in a6, a3[2] not in a6" elif a3[2] in a6: print "a3[0] not in a6, a3[1] not in a6, a3[2] in a6" else: print "NONE3.1" elif a3[1] in a6: if a3[2] not in a6: print "a3[0] not in a6, a3[1] in a6, a3[2] not in a6" elif a3[2] in a6: print "a3[0] not in a6,a3[1] in a6, a3[2] in a6" else: print "NONE3.2" else: print "NONE3.3" elif a3[0] in a6: if a3[1] not in a6: if a3[2] not in a6: print "a3[0] in a6, a3[1] not in a6, a3[2] not in a6" elif a3[2] in a6: print "a3[0] in a6, a3[1] not in a6, a3[2] in a6" else: print "NONE3.4" elif a3[1] in a6: if a3[2] not in a6: print "a3[0] in a6, a3[1] in a6, a3[2] not in a6" elif a3[2] in a6: print "a3[0] in a6, a3[1] in a6, a3[2] in a6" else: print "NONE3.5" else: print "NONE3.6" else: print "NONE3.7" Why it is behaving like that? If someone can help me. Best Regards, Subhabrata Banerjee, Indian Institute of Science, Bangalore, India. From fredrik at pythonware.com Sun Apr 6 16:50:46 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 06 Apr 2008 22:50:46 +0200 Subject: How to create an exe-file? In-Reply-To: <311a216f-5366-47c5-86a7-431dd23ced3e@j1g2000prb.googlegroups.com> References: <311a216f-5366-47c5-86a7-431dd23ced3e@j1g2000prb.googlegroups.com> Message-ID: skanemupp at yahoo.se wrote: > how do you create exe-files of your python-code? > > is it different depending on what libraries, GUI-frameworks you use? > > i want to create an exe-file of a pythonscript that uses Tkinter. assuming windows only, you want: http://www.py2exe.org/ also see: http://effbot.org/zone/python-compile.htm From musiccomposition at gmail.com Thu Apr 10 22:40:49 2008 From: musiccomposition at gmail.com (Benjamin) Date: Thu, 10 Apr 2008 19:40:49 -0700 (PDT) Subject: How to use my dynamic link libraries in python?? References: Message-ID: On Apr 10, 9:21 pm, "???" wrote: > Hello: > My OS is Linux, I compile my dynamic link libraries , and > want to call the function of my dynamic library through python! > How can I realize the function? Please give me some advices! Thanks You have several options. You could write a Python extension module to bind the functions in dylib to the interpreter. You could also have a look at the ctypes module. From mnordhoff at mattnordhoff.com Tue Apr 8 03:28:40 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Tue, 08 Apr 2008 07:28:40 +0000 Subject: Destructor? In-Reply-To: <47FB1E5E.6010708@mattnordhoff.com> References: <47FB1937.5050008@mydeskfriend.com> <47FB1E5E.6010708@mattnordhoff.com> Message-ID: <47FB1EA8.6000801@mattnordhoff.com> Matt Nordhoff wrote: > Gabriel Rossetti wrote: >> Hello everyone, >> >> we are writing an application that needs some cleanup to be done if the >> application is quit, normally (normal termination) or by a signal like >> SIGINT or SIGTERM. I know that the __del__ method exists, but unless I'm >> mistaken there is no guarantee as of when it will be called, and some >> objects may have already been released (at lease I've had trouble in the >> past accessing certain objects from inside __del__, probably since the >> parent class's __del__ has to be called first, then it's objects are >> already released by the time I need to do something with them). Another >> method would be to implement something using the signal module and have >> a callback that does all the cleanup when the app. is >> quit/terminated/interrupted and have all the child classes override that >> with their cleanup code. >> >> What is the community's point of view on the subject? >> >> Thanks, >> Gabriel > > atexit? > > If it's only small things, there's try...finally, of course.. Huh, I totally didn't know that atexit is only run on normal terminations. Oops. Never mind. -- From steve at holdenweb.com Tue Apr 8 17:39:10 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 17:39:10 -0400 Subject: CPython VM & byte code resources wanted In-Reply-To: <66238qF2h0kfqU1@mid.individual.net> References: <6622srF2e32hbU1@mid.individual.net> <66238qF2h0kfqU1@mid.individual.net> Message-ID: Aaron Gray wrote: > "Aaron Gray" wrote in message > news:6622srF2e32hbU1 at mid.individual.net... >> Hi, >> >> I am looking to study the CPython source code, but I cannot seem to find >> the VM code. > > Found it :) > > Python/ceval.c > >> Also is there any where a detailed list of the opcodes ? > > Still could do with an opcodes chart. > Be sure and post it on the Wiki when you finish it ;-) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bsk16 at case.edu Mon Apr 28 22:25:23 2008 From: bsk16 at case.edu (Benjamin Kaplan) Date: Mon, 28 Apr 2008 22:25:23 -0400 Subject: Python Math libraries - How to? In-Reply-To: References: Message-ID: On Mon, Apr 28, 2008 at 10:07 PM, wrote: > Hi, I am a very newbie who would very much appreciate some hints. > > Python 2.52. on Windows XP for now. Soon on Ubuntu 8 > > I am teaching myself Python following free tutorials. I can solve > problems using arithmetic, but when I try to upgrade the programs > using math libraries nothing seems to work. I downloaded a 2002 > tutorial from Zelle "An Introduction to Computer Science" where he > uses a "import math" statement to calculate a square root. I tried the > "pi" library function but it didn?t work. I tried using def Pi() it > did not work either. I am yet to find a tutorial that explains how to > declare (or initialize) and pass numbers to the functions such as > "cos(x)" and the pi which does not have a variable in it. Is just a > constant. > > Here is the arithmetic program I made that it worked before I added > the "import math" line. I erased the constant p = 3.1416 and added > the "i" for the library function "pi" in the algorithms. But I get an > error message not recognizing "pi" > > > > #volumen.py > # A program to compute the volume and surface area of a sphere > import math > > def main(): > > print "This program calculates the volume and surface area of a > sphere" > print > r = input("Please enter the radious: ") > print > r3 = r*r*r > volume = 4/3*pi*r3 > r2 = r*r > surface = 4*pi*r2 > print "The Volume is", volume, " Cubic centimeters" > print > print "The Surface area is", surface, " square centimeters" > > main() > > *** Error message ************* > > Traceback (most recent call last): > File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 20, in > > main() > File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 13, in main > volume = 4/3*pi*r3 > NameError: global name 'pi' is not defined > -- > http://mail.python.org/mailman/listinfo/python-list > pi is not a global name. When you do "import math",you aren't adding everything to the name space, you are just telling python that you are going to be using that file. You then refer to it as math.*, such as "math.pi", or "math.pow(r,3)". To use it the way you want to, you would have to do "from math import pi" instead of "import math" From wongjoekmeu at yahoo.com Tue Apr 22 12:06:34 2008 From: wongjoekmeu at yahoo.com (wongjoekmeu at yahoo.com) Date: Tue, 22 Apr 2008 09:06:34 -0700 (PDT) Subject: SWIG C++ std::cout do not output to interactive interpreter IDLE Message-ID: Dear All, I have some functions written in C++, which I try to approach from python using swig. In the C++ functions I use std::cout to print stuff to output. Everything works fine, but the only problem that I have is that when I start IDLE and use the functions what std::cout should print to the "IDLE console" simply does not appear. When I don't use IDLE but simply double click on the .py script, it works all fine. I was wondering how I could make sure that std::cout would print also to IDLE. Thanks a lot in advance for helping to answer my question. RR From bobby.connor at gmail.com Tue Apr 1 12:29:25 2008 From: bobby.connor at gmail.com (bobby.connor at gmail.com) Date: Tue, 1 Apr 2008 09:29:25 -0700 (PDT) Subject: Homework help References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> <7xfxu5ft1s.fsf@ruckus.brouhaha.com> Message-ID: <8e1f6963-1cdd-4afe-9ea5-f1886ed452ab@d21g2000prf.googlegroups.com> On Apr 1, 12:17 pm, Paul Rubin wrote: > bobby.con... at gmail.com writes: > > I don't necessarily want the answers, but need help on how to approach > > it/the steps i need to solve the problems > > What parts are you having difficulty with? Are there some course > materials and have you read them yet? I just don't know how to start the problems off From steve at holdenweb.com Sat Apr 5 07:11:04 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 07:11:04 -0400 Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! In-Reply-To: References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <7113d012-01bb-4426-bb40-9e2811cdb102@x41g2000hsb.googlegroups.com> <3cf4bbc8-b828-45c5-b9a8-766ce600af43@y21g2000hsf.googlegroups.com> Message-ID: skanemupp at yahoo.se wrote: [stuff, including quoted copies of an original program and its replacement] > > and the self. i erased, should i do it in the def __init__ as well or > only as i did in createwidgets-function? Your posts would be easier to consider if you trimmed out the stuff that's no longer relevant. I for one pretty much just skipped over them because of their tedious length. Just thought I'd mention it. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From tarundevnani at gmail.com Mon Apr 28 01:08:31 2008 From: tarundevnani at gmail.com (tarun) Date: Mon, 28 Apr 2008 10:38:31 +0530 Subject: Related to Shelve Module Message-ID: Hi All, I want to store the class instance object variables persistenlty in one file so that other file can also access for some filtering. I tired doing this using the shelve module. *Code:* class A: pass import shelve filename = 'test.db' d = shelve.open(filename) a = A() print a d['1'] = a print d['1'] d.close() *Output:* <__main__.A instance at 0x018B56C0> <__main__.A instance at 0x018B5760> *Observation:* I expect both the print statements to return the same value, The second print statement just reads the dictonary, but still the adress (0x..) is different from the first print statement. Can anyone tell me why. Also let me know if you the way of getting same value both the times. Quick help will be appreciated. Thanks & Regards, Tarun -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlwuhwdmckay at gmail.com Sat Apr 26 09:32:48 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:32:48 -0700 (PDT) Subject: call of duty 4 crack multiplayer Message-ID: <8305e313-81ea-417b-8e0a-e72076823026@x35g2000hsb.googlegroups.com> call of duty 4 crack multiplayer http://cracks.00bp.com F R E E C R A C K S From lists at cheimes.de Mon Apr 21 06:50:04 2008 From: lists at cheimes.de (Christian Heimes) Date: Mon, 21 Apr 2008 12:50:04 +0200 Subject: sys.maxint in Python 3 In-Reply-To: References: Message-ID: <480C715C.90809@cheimes.de> bearophileHUGS at lycos.com schrieb: > In some algorithms a sentinel value may be useful, so for Python 3.x > sys.maxint may be replaced by an improvement of the following infinite > and neginfinite singleton objects: Python 3.0 doesn't have sys.maxint any more since Python 3's ints are of arbitrary length. Instead of sys.maxint it has sys.maxsize; the maximum size of a positive sized size_t aka Py_ssize_t. Christian From steve at holdenweb.com Mon Apr 14 14:09:23 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 14 Apr 2008 14:09:23 -0400 Subject: =?UTF-8?B?562U5aSNOiBKYXZhIG9yIEMrKz8=?= In-Reply-To: References: Message-ID: Marco Mariani wrote: > Penny Y. wrote: > >> Javascript is different from Java at all. > > I think even rocks know that. Yet, some use of closure and > prototype-based inheritance might be interesting to the OP. > >> Why not Perl? > > Come on, learning Perl after two years of Python? How harsh. > >> Perl is a functional language, > > And gwbasic is object oriented. > > And I am Marie of Roumania. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From banibrata.dutta at gmail.com Mon Apr 28 09:25:51 2008 From: banibrata.dutta at gmail.com (Banibrata Dutta) Date: Mon, 28 Apr 2008 18:55:51 +0530 Subject: Checking for existance of feature / tools / solutions -- Something like Java webstart Message-ID: <3de8e1f70804280625j239b1c09w360072a409783a95@mail.gmail.com> Hi, I've tried searching this list & googling around a bit -- trying to see if there is a Java-Webstart like alternative for Python, the closest approximate I've found is something suggested in this post: http://mail.python.org/pipermail/python-list/2004-September/282837.html Is this still pretty much the state-of-art ? Or, is there some other, better, simpler, snappier alternative. My requirements fundamentally are to use the web-mechanism ("something" embedded in a webpage, that is able to detect whether particular (minimal) version of Python is installed on the client system, and whether my client-software (Python app) is installed or not, will possibly, first install Python (latest) if not installed, and then my client-software (Python app). If both are installed, it'd allow me to upgrade the python app (and/or Python itself prior to it). This seems to be a something that should be fairly common thing that folks might have to do! thanks & regards, Banibrata From deets at nospam.web.de Tue Apr 22 06:34:48 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 12:34:48 +0200 Subject: Python Success stories In-Reply-To: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <675tasF2kecjsU1@mid.uni-berlin.de> azrael schrieb: > Hy guys, > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. > > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" > > This hurts. Please give me informations about realy famous > aplications. This isn't worth too much, but nontheless: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html Klick on Perl & Python respectively to see who's going to need to use something else some day. But the real problem is not your friend - it's you. He hurts you because you let him. Stop getting mad about that he teases you. Diez From xnews2 at fredp.lautre.net Sun Apr 27 15:23:30 2008 From: xnews2 at fredp.lautre.net (Fred Pacquier) Date: 27 Apr 2008 19:23:30 GMT Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> Message-ID: John Henry said : > Welcome to the modernized world of Pythoncard!!! Hey, that's really neat ! I remember dabbling in Pythoncard in the early days, some years ago, it was a very interesting project. I gave it up eventually, partly because it seemed somewhat abandoned (I see it's still stuck in 2006 ?), but mostly because the wxPython dependency was either unavailable or too hefty for the sort of machines I was interested in using it on (a Sharp Zaurus then, now Nokia Internet tablets). Since then I've been doing web apps instead, hosted and used on the devices themselves. So using Pythoncard as a designer for web apps, of course that rings a bell... Do you have any idea of the computing requirements of Qooxdoo and QxTransformer, compared to a native Pythoncard app ? I wonder if your stuff would run acceptably on today's mobile platforms (the Nokias have a Firefox derivative that is reasonably competent at javascript), and would give it a try if it's not too arcane. Do keep us posted ! TIA, fp From aldo at nullcube.com Sat Apr 5 17:30:59 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Sun, 6 Apr 2008 07:30:59 +1000 Subject: ANN: pry unit testing framework In-Reply-To: References: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com> <20080405141329.GD15684@nullcube.com> Message-ID: <20080405213059.GA19741@nullcube.com> Steve, > Kay at least has a long history as a contributor in this group, so > people know how to interpret her remarks and know that her contributions > are made on the basis of a deep understanding of Python. She is far from > belonging to the "peanut gallery", and to suggest otherwise betrays > either ignorance, arrogance, or both. While I'm not a regular poster on this list, I have been reading it for nearly 10 years, so I probably have more context here than you suspect. At least one mail to this list and a number of personal emails to me suggest that it is Kay and and indeed you who are temporarily out of line with the tone of the list. A more impartial re-reading of the debate so far might make you judge my final, admittedly angry, response more fairly. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From gagsl-py2 at yahoo.com.ar Mon Apr 14 21:40:18 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 14 Apr 2008 22:40:18 -0300 Subject: =?utf-8?B?5pyJ5Lit5Zu95Lq65LmOPw==?= References: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> <4801F702.5050401@arcor.de> Message-ID: En Mon, 14 Apr 2008 16:02:20 -0300, John Henry escribi?: > On Apr 14, 11:17 am, Steve Holden wrote: >> I have no idea. Babelfish (from which I obtained my reply as well as >> whatever understanding I had of the original inquiry) translated my >> reply as >> >> But the academic society never is immediately, with will need time >> >> whereas yours becomes >> >> Studies python not to be possible on first to become, needs to proceed >> in an orderly way >> >> Since what I entered in English was something like "Yes, Python has a >> future. But it will take some study". Perhaps you can tell me whether >> your translation gives the correect flavor. I'm pretty sure the >> babelfish mangled my intent. > ROFL > > I would not recomend using babalfish to translate between Chinese and > English. It does a *horrible* job at that. It does a *horrible* job with any language. It can be used to translate from any foreign language into your native language, and then you can try to guess the meaning - but even a 5yr old boy can make more meaningful sentences than Babelfish output :) > But then in this particular case, it was able to convey what you > wanted to say - in a rather awkward fashion. :-) Probably thanks to the amazing capabilities of your human brain, not Babelfish :) -- Gabriel Genellina From esj at harvee.org Fri Apr 4 10:33:43 2008 From: esj at harvee.org (Eric S. Johansson) Date: Fri, 04 Apr 2008 10:33:43 -0400 Subject: Unicode conversion problem (codec can't decode) In-Reply-To: References: <47F5AFFC.3060902@harvee.org> Message-ID: <47F63C47.4070501@harvee.org> > > Almost there: use string-escape instead; it takes a byte string and > returns another byte string in ASCII. perfect. Exactly what I wanted. thank you so very much. > >> I really don't care about the character set used. I'm looking for a >> matched set >> of operations that converts the string to a seven bits a form and back >> to its >> original form. > > Ok, string-escape should work. But which database are you using that can't > handle 8bit strings? I tripped over some bugs with pysqlite in terms of what it should and should not accept as text. Now that I've gotten through my particular "crisis" I need to sit down and generate a test case so the problem can be fixed. thanks again. ---eric -- Speech-recognition in use. It makes mistakes, I correct some. From steve at holdenweb.com Wed Apr 9 11:11:49 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 11:11:49 -0400 Subject: import statement convention In-Reply-To: <405fef20-2593-44da-abe8-516fec7e59fa@k10g2000prm.googlegroups.com> References: <4078bcf4-e68f-45d4-93ce-335ec7a33c5a@v32g2000prd.googlegroups.com> <405fef20-2593-44da-abe8-516fec7e59fa@k10g2000prm.googlegroups.com> Message-ID: MartinRinehart at gmail.com wrote: > Thanks, all. > > Good to know no one's been beheaded. > > Yes to separating test and non-test code, but no if that will just > turn one modest module into two modules, smaller still. > > Amen to 'practicality beats purity.' > > Do wish we had a good, thorough convention set. I wrote one for Java. > It took a lot of work. ( file:/home/martin/mrwebsite/articles/code- > conventions.html ) I appreciate the sentiment, but I seem to be having problems accessing your disk from over here. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gh at ghaering.de Wed Apr 9 08:23:57 2008 From: gh at ghaering.de (=?ISO-8859-2?Q?Gerhard_H=E4ring?=) Date: Wed, 09 Apr 2008 14:23:57 +0200 Subject: is Pylons alive? In-Reply-To: References: Message-ID: <663qr1F2ig5dkU1@mid.uni-berlin.de> Mage wrote: > Hello, > > I don't want to be impolite, just in short: I am thinking about leaving > RoR and coming back to Python. I've missed the last two years in Python, > however I have been subscribed to this list and there are not too many > e-mails about Pylons in my mailbox. Why don't you take a look at the Pylons mailing list instead? http://groups.google.com/group/pylons-discuss > On my Gentoo the latest Pylons ebuild has date "jul 2007" or something > like last summer. It has testing keywords both for x86 and amd64. (No > stable version available). It's available on my debian "testing" desktop. > > Before spending much time for investigating, I would like to ask you: is > Pylons the framework I look for if I want to come back to Python and > develop MVC web apps? Of course I don't know if Pylons is the best tool for you. It is definitely alive and kicking. Anyway, I'm pretty sure there's no way around trying it out for yourself. It should only take a few hours to see if you're comfortable with it. Other alternatives: - Django - TurboGears 2.0 (I personally wouldn't bother with TurboGears 1.x at this point) - Build your own based on WSGI components, mix and match WSGI server, ORM, template engine - this is not so stupid as it may sound HTH, -- Gerhard From nagle at animats.com Wed Apr 16 13:27:26 2008 From: nagle at animats.com (John Nagle) Date: Wed, 16 Apr 2008 10:27:26 -0700 Subject: Unicode chr(150) en dash In-Reply-To: References: Message-ID: <48063434$0$36327$742ec2ed@news.sonic.net> marexposed at googlemail.com wrote: > Hello guys & girls > > I'm pasting an "en dash" > (http://www.fileformat.info/info/unicode/char/2013/index.htm) character into > a tkinter widget, expecting it to be properly stored into a MySQL database. > > I'm getting this error: > ***************************************************************************** > Exception in Tkinter callback Traceback (most recent call last): File > "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__ return > self.func(*args) File "chupadato.py", line 25, in guardar cursor.execute(a) > File "C:\Python24\Lib\site-packages\MySQLdb\cursors.py", line 149, in execute > query = query.encode(charset) UnicodeEncodeError: 'latin-1' codec can't > encode character u'\u2013' in position 52: ordinal not in range(256) > ***************************************************************************** Python and MySQL will do end to end Unicode quite well. But that's not what you're doing. How did "latin-1" get involved? If you want to use MySQL in Unicode, there are several things to be done. First, the connection has to be opened in Unicode: db = MySQLdb.connect(host="localhost", use_unicode = True, charset = "utf8", user=username, passwd=password, db=database) Yes, you have to specify both "use_unicode=True", which tells the client to talk Unicode, and set "charset" to"utf8", which tells the server to talk Unicode encoded as UTF-8". Then the tables need to be in Unicode. In SQL, ALTER DATABASE dbname DEFAULT CHARACTER SET utf8; before creating the tables. You can also change the types of existing tables and even individual fields to utf8, if necessary. (This takes time for big tables; the table is copied. But it works.) It's possible to get MySQL to store character sets other than ASCII or Unicode; you can store data in "latin1" if you want. This might make sense if, for example, all your data is in French or German, which maps well to "latin1". Unless that's your situation, go with either all-ASCII or all-Unicode. It's less confusing. John Nagle From rridge at caffeine.csclub.uwaterloo.ca Sun Apr 20 01:00:17 2008 From: rridge at caffeine.csclub.uwaterloo.ca (Ross Ridge) Date: Sun, 20 Apr 2008 01:00:17 -0400 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> Message-ID: Ross Ridge wrote: > It's the same as the previous version except that it "precompiles" > the struct.unpack() format string. =A0It works similar to the way Python > handles regular expressions. George Sakkis wrote: >I didn't know about the Struct class; pretty neat. It's amazing that >this version without Psyco is as fast Bob's version with Psyco! Unfortunately, it doesn't seem to documented in the Python 2.5 manual. The speed improvement mainly comes from avoiding the Python code in the struct module that wraps the Struct class. The struct module caches already compiled format strings, but looking format strings in the cache ends taking a fair chunk of time in my original example. Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] rridge at csclub.uwaterloo.ca -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // From pavlovevidence at gmail.com Thu Apr 10 20:25:35 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Thu, 10 Apr 2008 17:25:35 -0700 (PDT) Subject: text adventure game problem References: Message-ID: On Apr 10, 2:20 pm, Tommy Nordgren wrote: > On 9 apr 2008, at 03.01, corvettecra... at gmail.com wrote: > > > okay, I'm having this one problem with a text adventure game. It's > > kind of hard to explain, but I'll do my best. > > [code] > > > def prompt_kitchen(): > > global gold > > Python is not a suitable language for Text Adventure Development. Ridiculous. > You should use one of the several excellent free text adventure > languages instead. > In particular languages like TADS (The text adventure development > system) have strong > built-in support for the tricky command parsing. There are many good reasons why someone might want to use a general purpose language like Python to write a text adventure, such as so they're not stuck with a quasi hack of a language if they have to do something that doesn't fit the framework anticipated by the language designer. Carl Banks From bronger at physik.rwth-aachen.de Thu Apr 17 00:22:02 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Thu, 17 Apr 2008 06:22:02 +0200 Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <52vid5-cvl2.ln1@ozzie.tundraware.com> Message-ID: <87hce1t8k5.fsf@physik.rwth-aachen.de> Hall?chen! Tim Daneliuk writes: > Daniel Fetchinson wrote: > >> [...] >> >>> I just had one moment of exceptional clarity, during which >>> realized how I could get the GIL out of my way... It's so >>> simple, I cannot help wondering why nobody has thought of it >>> before. [...] >> >> If I were you I would keep it a secret until a Hollywood producer >> offers big bucks for the film rights. > > Who would play Guido, I wonder? Ralf M?ller. No other. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From gagsl-py2 at yahoo.com.ar Mon Apr 21 22:30:20 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 23:30:20 -0300 Subject: Problems replacing \ with \\ References: <0ca30eb2-3791-4910-9e78-f32e3b2a72cb@2g2000hsn.googlegroups.com> <6f7342eb-08f8-45d6-b50e-652bf77921d7@l42g2000hsc.googlegroups.com> Message-ID: (top posting corrected) En Mon, 21 Apr 2008 21:12:44 -0300, ockman at gmail.com escribi?: >> > def escape(string): >> > """ >> > Escape both single quotes and blackslashes >> > >>> x = r"fun\fun" >> > >>> escape(x) >> > 'fun\\\\fun' >> > """ >> > string = string.replace('\\', '\\\\') >> > return string >> >> > Failed example: >> > escape(x) >> > Expected: >> > 'fun\\fun' >> > Got: >> > 'fun\x0cun' >> >> Your doctest is in a triple-quoted string which contains the line: >> >> >>> x = r"fun\fun" >> which is the same as: >> >> >>> x = r"fun\x0cun" >> >> If you wrap a raw string in just quotes that is isn't a raw string any >> longer! > Thank you for the response. I'm not sure I understand the last > sentence, although I think I get the idea. How do I create a proper > doctest? r"This is a raw string" """ r"This is NOT a raw string" """ r""" r"This is a raw string too" """ What matters are the OUTER quotes. Now, why do you want to escape the text yourself? Assuming you have a DBAPI compatible module, use bound parameters when you execute the query: cursor.execute("insert ... values (?,?,?)", (name, address, year)) Those ? are placeholders for the actual values; no explicit quoting on the values is required (the module itself, or the database, takes care of it). Not all databases support the ? style, there are other ways. See http://www.python.org/dev/peps/pep-0249/ for the DB API specification. -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Thu Apr 3 19:39:57 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 20:39:57 -0300 Subject: displaying execution of Python code References: <1afcbf34-0a40-4d11-b12f-603f0ee8f26c@m3g2000hsc.googlegroups.com> Message-ID: En Thu, 03 Apr 2008 18:13:25 -0300, noahwatkins escribi?: > More technically, I am looking for direction on where to start looking > in the Python libraries for a functionality that will allow me to > execute arbitrary Python code from within a Python application. > Additionally, I need to be able to have the ability to get information > and perform actions (e.g. line number currently executing) as the code > executes. See the trace module and the sys.settrace hook. -- Gabriel Genellina From steveb428 at gmail.com Mon Apr 7 22:38:12 2008 From: steveb428 at gmail.com (steve) Date: Mon, 7 Apr 2008 19:38:12 -0700 (PDT) Subject: pyAmazon References: <137ba7ca-2be3-4c0a-ba85-187d8e172150@i36g2000prf.googlegroups.com> Message-ID: <76ff7677-143e-435c-a965-d7905385c847@h1g2000prh.googlegroups.com> I noticed it's happening at the line that does the parsing: dom = minidom.parse(usock), in pyaws/ecs.py I'll look into how to turn off the outputting. On Apr 7, 4:20 pm, steve wrote: > Anyone familiar with pyAmazon ( the latest for AWS 4.0 ), who knows > why the ItemSearch echo's the XML that is retrieved ? > > My statement is > products = ecs.ItemSearch("Duma Key", SearchIndex='Books') > > And the "products" list is populated okay, however before my script > ends ( executing script on DOS command line ), I get all of the XML > data scrolling on the screen. > Thanks From colas.francis at gmail.com Fri Apr 11 08:43:42 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Fri, 11 Apr 2008 05:43:42 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: <83e88c35-88ce-48c7-b0c9-4503789eca08@8g2000hse.googlegroups.com> On 11 avr, 14:14, Gerard Flanagan wrote: > On Apr 11, 2:05 pm, Gerard Flanagan wrote: > > > On Apr 11, 12:14 pm, bdsatish wrote: > > > > The built-in function round( ) will always "round up", that is 1.5 is > > > rounded to 2.0 and 2.5 is rounded to 3.0. > > > > If I want to round to the nearest even, that is > > > > my_round(1.5) = 2 # As expected > > > my_round(2.5) = 2 # Not 3, which is an odd num > > > > I'm interested in rounding numbers of the form "x.5" depending upon > > > whether x is odd or even. Any idea about how to implement it ? > In fact you can avoid the call to the builtin round: Alternatively, you can avoid the test using both divmod and round: In [55]: def myround(x): .....: d, m = divmod(x, 2) .....: return 2*d + 1 + round(m-1) .....: In [58]: assert myround(3.2) == 3 In [59]: assert myround(3.6) == 4 In [60]: assert myround(3.5) == 4 In [61]: assert myround(2.5) == 2 In [62]: assert myround(-0.5) == 0.0 In [63]: assert myround(-1.5) == -2.0 In [64]: assert myround(-1.3) == -1.0 In [65]: assert myround(-1.8) == -2 In [66]: assert myround(-2.5) == -2.0 From hasna1980_14 at hotmail.com Fri Apr 11 10:07:09 2008 From: hasna1980_14 at hotmail.com (ha bo) Date: Fri, 11 Apr 2008 14:07:09 +0000 Subject: unpack In-Reply-To: References: Message-ID: thank you i did find solution i did have just change: unpackedData = struct.unpack(unpackFormat, data) to unpackedData = struct.unpack(unpackFormat, data.decode('string_escape')) From: python-list-request at python.org Subject: Python-list Digest, Vol 55, Issue 179 To: python-list at python.org Date: Fri, 11 Apr 2008 15:50:04 +0200 Send Python-list mailing list submissions to python-list at python.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.python.org/mailman/listinfo/python-list or, via email, send a message with subject or body 'help' to python-list-request at python.org You can reach the person managing the list at python-list-owner at python.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Python-list digest..." --Pi?ce jointe du message transmise-- From: ivan.illarionov at gmail.com To: python-list at python.org Date: Fri, 11 Apr 2008 05:58:46 -0700 Subject: Re: Rounding a number to nearest even On Apr 11, 2:14 pm, bdsatish wrote: > The built-in function round( ) will always "round up", that is 1.5 is > rounded to 2.0 and 2.5 is rounded to 3.0. > > If I want to round to the nearest even, that is > > my_round(1.5) = 2 # As expected > my_round(2.5) = 2 # Not 3, which is an odd num > > I'm interested in rounding numbers of the form "x.5" depending upon > whether x is odd or even. Any idea about how to implement it ? def even_round(x): if x % 1 == .5 and not (int(x) % 2): return float(int(x)) else: return round(x) nums = [ 3.2, 3.6, 3.5, 2.5, -.5, -1.5, -1.3, -1.8, -2.5 ] for num in nums: print num, '->', even_round(num) 3.2 -> 3.0 3.6 -> 4.0 3.5 -> 4.0 2.5 -> 2.0 -0.5 -> 0.0 -1.5 -> -2.0 -1.3 -> -1.0 -1.8 -> -2.0 -2.5 -> -2.0 --Pi?ce jointe du message transmise-- From: steve at holdenweb.com To: python-list at python.org Date: Fri, 11 Apr 2008 09:07:42 -0400 Subject: Re: (unknown) ha bo wrote: > hi i use this programme in my application django: > import struct > MASK_CCITT = 0x1021 # CRC-CCITT mask (ISO 3309, used in X25, HDLC) > MASK_CRC16 = 0xA001 # CRC16 mask (used in ARC files) > > def updcrc(crc, data, mask=MASK_CRC16): > > data_length = len(data) > unpackFormat = '%db' % data_length > unpackedData = struct.unpack(unpackFormat, data) > > for char in data: > c = ord(char) > c = c << 8 > > for j in xrange(8): > if (crc ^ c) & 0x8000: > crc = (crc << 1) ^ mask > else: > crc = crc << 1 > c = c << 1 > > return crc & 0xffff > > > and i call this function in other function in my view: > > > def encodekey(var, expires=None, user='', trusted=False): > > import random, base64 > import updcrc > key = "%02X" % len(var) + var > key += "%02X" % len(user) + user > if expires is not None: > key += expires.strftime('%Y%m%d%H%M') > else: > year = random.choice(range(2000,2100)) > month = 23 > day = random.choice(range(1,32)) > hour = random.choice(range(1,25)) > minute = random.choice(range(1,60)) > key += "%04d%02d%02d%02d%02d" % (year, month, day, hour, minute) > > if trusted: > checksum = updcrc(42, key) > else: > checksum = updcrc(0, key) > key += "%04X" % checksum > > return base64.b64encode(key) > but it give me this error: > > > unpack requires a string argument of length 31 > > > someone can help me > Next time you report an error, please include the whole traceback, not just the exception message. That information is included for a reason. You might also want to print out the value of data in your updcrc function, since that is where the problem is occurring. Finally I might point out there is little point to the struct.unpack since you don't use its result, but I am guessing this is because your algorithm is currently in transition. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ --Pi?ce jointe du message transmise-- From: victorsubervi at gmail.com CC: python-list at python.org To: gagsl-py2 at yahoo.com.ar Date: Fri, 11 Apr 2008 08:36:02 -0500 Subject: Re: String Literal to Blob Nope. Do not see it. My ugly stupid way works. I guess I will just proceed with that and write my howto accordingly. Victor On Thu, Apr 10, 2008 at 9:01 PM, Gabriel Genellina wrote: En Thu, 10 Apr 2008 14:04:43 -0300, Victor Subervi escribi?: > Well, what I did was this: > > content = col_fields[0][14].tostring() > pic = "tmp" + str(i) + ".jpg" > img = open(pic, "w") > img.write(content) > print '

' % pic > img.close() > where I am incrementing i. Ugly. Stupid. But if it is the only way to do > it > in python, and I do not want to invest the time doing it in php, which I > think would be prettier in this instance, then I guess it will do. Your > thoughts appreciated. You REALLY should read some material on how HTTP works. I'll try to sketch a few important points. First, suppose you have an HTML page (album.html) with two images in it:

This is me: and this is my cat Suppose the URL for that page is http://some.server.com/gabriel/album.html and you type that in your favorite browser. This is what happens: 1) The sees the initial "http:" and says "I'll use HTTP". Then sees "some.server.com" and opens a connection to that server on port 80. Then sees "/gabriel.album.html" and builds an HTTP GET request for it. 2) The server receives the GET request, looks for the "album.html" document, determines the right Content-Type, and returns it specifying "Content-Type: text/html" 3) The browser receives the HTML text and tries to display it. When it encounters the first tag it looks at the src attribute; it doesn't know that image; so a *NEW* HTTP request is required. This time it says "GET /images/myself.jpg" 4) The server receives the GET request, looks for a file with that name, determines that it's a jpeg image, and returns its contents along with a "Content-Type: image/jpeg". 5) The browser receives the image and is able to display it. 6) The same thing happens with the second tag, there is a third HTTP GET request for it. Note that: - The images themselves *aren't* in the HTML page, they are somewhere else. HTML is text and contains ONLY the URI for the image. - THREE DIFFERENT requests are done to show that page. Each one returns A SINGLE OBJECT of A SINGLE TYPE. The above was using static HTML with static images. If you use CGI to generate dynamic content, it's the same thing. From the browser point of view, there is no difference: it still will generate three different requests for the three pieces (one html document with two images). Your CGI script (or scripts) will receive three different requests then: when requested for HTML, return HTML; when requested for an image, return an image. They are DIFFERENT things, DIFFERENT requests, happening at DIFFERENT times, so don't mix them. I think that combining Steve's responses and mine you now have enough information to be able to solve your problems. Perhaps if you re-read the whole thread from start you'll have now a better understanding of what's happening. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list --Pi?ce jointe du message transmise-- From: huayang.xia at gmail.com To: python-list at python.org Date: Fri, 11 Apr 2008 06:37:23 -0700 Subject: Re: Convert PyIDispatch object to struct IDispatch* On Apr 11, 12:15 am, "Gabriel Genellina" wrote: > En Thu, 10 Apr 2008 18:45:04 -0300, Huayang Xia > escribi?: > > > I am trying to use ctypes to call dll functions. One of the functions > > requires argument "struct IDispatch* ". I do have a PyIDispatch object > > in python. How can I convert this "PyIDispatch object" to "struct > > IDispatch* "? > > I think a PyIDispatch object is an IDispatch* itself. > But you'll get better answers from the python-win32 list:http://mail.python.org/mailman/listinfo/python-win32 > > -- > Gabriel Genellina Thanks for the info. To call a dll function, it needs a C style IDispatch*. PyIDispatch is a python wrapped one. I found a reference from: http://svn.python.org/projects/ctypes/trunk/comtypes/comtypes/test/test_win32com_interop.py which shows how to convert C style to python style. Unfortunately i need the reversed version. I will post the question to python-win32. --Pi?ce jointe du message transmise-- From: enleverlesX.XmcX at XmclaveauX.com To: python-list at python.org Date: Fri, 11 Apr 2008 15:38:32 +0200 Subject: Python plus After IronPython, Python + iron : http://www.golfermania.com/SnakeEyes/PYTHON-PLUS-IRON.jpg ;o) Michel Claveau --Pi?ce jointe du message transmise-- From: mail at timgolden.me.uk CC: python-list at python.org Date: Fri, 11 Apr 2008 14:47:20 +0100 Subject: Re: Convert PyIDispatch object to struct IDispatch* Huayang Xia wrote: > On Apr 11, 12:15 am, "Gabriel Genellina" > wrote: >> En Thu, 10 Apr 2008 18:45:04 -0300, Huayang Xia >> escribi?: >> >>> I am trying to use ctypes to call dll functions. One of the functions >>> requires argument "struct IDispatch* ". I do have a PyIDispatch object >>> in python. How can I convert this "PyIDispatch object" to "struct >>> IDispatch* "? >> I think a PyIDispatch object is an IDispatch* itself. >> But you'll get better answers from the python-win32 list:http://mail.python.org/mailman/listinfo/python-win32 >> >> -- >> Gabriel Genellina > > Thanks for the info. > > To call a dll function, it needs a C style IDispatch*. PyIDispatch is > a python wrapped one. I found a reference from: > > http://svn.python.org/projects/ctypes/trunk/comtypes/comtypes/test/test_win32com_interop.py > > which shows how to convert C style to python style. Unfortunately i > need the reversed version. > > I will post the question to python-win32. I've had a quick look at the PyIDispatch source and I can't see any obvious way in which the underlying IDispatch is exposed. May have missed something, but it's possible that there's not way out. TJG --Pi?ce jointe du message transmise-- From: hdante at gmail.com To: python-list at python.org Date: Fri, 11 Apr 2008 06:49:23 -0700 Subject: Re: Rounding a number to nearest even On Apr 11, 9:45 am, bdsatish wrote: > On Apr 11, 5:33 pm, bdsatish wrote: > > > > > HI Gerard, > > > I think you've taken it to the best possible implementation. Thanks ! > > On Apr 11, 5:14 pm, Gerard Flanagan wrote: > > > > In fact you can avoid the call to the builtin round: > > > > ------------------------------------------------ > > > > assert myround(3.2) == 3 > > > assert myround(3.6) == 4 > > > assert myround(3.5) == 4 > > > assert myround(2.5) == 2 > > > assert myround(-0.5) == 0.0 > > > assert myround(-1.5) == -2.0 > > > assert myround(-1.3) == -1.0 > > > assert myround(-1.8) == -2 > > > assert myround(-2.5) == -2.0 > > > ------------------------------------------------ > > OK, I was too early to praise Gerard. The following version: > > def myround(x): > n = int(x) > if abs(x - n) >= 0.5 and n % 2: > return n + 1 - 2 * int(n<0) > else: > return n > > of Gerard doesn't work for 0.6 (or 0.7, etc.) It gives the answer 0 > but I would expect 1.0 ( because 0.6 doesn't end in 0.5 at all... so > usual rules of round( ) apply) Interestingly, you could solve this by using python 3. :-) round(x[, n]) Return the floating point value x rounded to n digits after the decimal point. If n is omitted, it defaults to zero. Values are rounded to the closest multiple of 10 to the power minus n; if two multiples are equally close, rounding is done toward the even choice (so, for example, both round(0.5) and round(-0.5) are 0, and round(1.5) is 2). Delegates to x.__round__(n). My turn: ;-) def yaround(x): i = int(x) f = x - i if f != 0.5 and f != -0.5: return round(x) return 2.0*round(x/2.0) a = (-10.0, -9.0, -8.0, -4.6, -4.5, -4.4, -4.0, -3.6, -3.5, -3.4, -0.6, -0.5, -0.4, 0.0, 0.4, 0.5, 0.6, 0.9, 1.0, 1.4, 1.5, 1.6, 2.0, 2.4, 2.5, 2.6, 10.0, 100.0) b = (-10.0, -9.0, -8.0, -5.0, -4.0, -4.0, -4.0, -4.0, -4.0, -3.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 3.0, 10.0, 100.0) for i in range(len(a)): assert yaround(a[i]) == b[i] _________________________________________________________________ Lancez des recherches en toute s?curit? depuis n'importe quelle page Web. T?l?chargez GRATUITEMENT Windows Live Toolbar aujourd'hui ! http://toolbar.live.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From s0suk3 at gmail.com Sat Apr 19 08:40:21 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Sat, 19 Apr 2008 05:40:21 -0700 (PDT) Subject: winreg module, need help to understand why i'm getting exception References: Message-ID: <194c4200-b388-429c-9341-28c96f27a9a7@m73g2000hsh.googlegroups.com> On Apr 19, 6:20 am, hellt wrote: > HI all, i found winreg module fromhttp://www.rutherfurd.net/python/winreg/index.html > very useful and simple, instead _winreg. > > But i have a problem with this module, in its iterable part. > > look at the following code > > key = Key(HKLM,r"SYSTEM\CurrentControlSet\Services\Tcpip\Enum") > for i in key.values: > print i.value > > and that is the exception > > Traceback (most recent call last): > File "D:\.Projects\python\temp.py", line 21, in > for i in key.values: > File "C:\Python25\Lib\site-packages\winreg.py", line 451, in next > return self.values[self.index - 1] > File "C:\Python25\Lib\site-packages\winreg.py", line 289, in > __getitem__ > name = _winreg.EnumValue(self.hkey, key)[0] > WindowsError: [Error 259] No more data is available > > so there is some problem with iterate, i think > i am still a beginner, so i cant understand why this appears, and what > should i fix. > > if anyone have some time to look closer to this module, i will > appreciate this very much. The problem is not in your code, but in the module. The EnumValue() and EnumKey() functions in the _winreg module raise WindowsError when there are no more keys or values to retrieve. So, go inside the module and modify that line to something like: # There should be a for or a while loop around here try: name = _winreg.EnumValue(key, index) except EnvironmentError: From sjoerd at acm.org Tue Apr 15 05:22:16 2008 From: sjoerd at acm.org (Sjoerd Mullender) Date: Tue, 15 Apr 2008 11:22:16 +0200 Subject: Rounding a number to nearest even In-Reply-To: <1208196168.24295.36.camel@localhost.localdomain> References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <1208196168.24295.36.camel@localhost.localdomain> Message-ID: <480473C8.6030402@acm.org> Thomas Dybdahl Ahle wrote: > On Fri, 2008-04-11 at 03:14 -0700, bdsatish wrote: >> The built-in function round( ) will always "round up", that is 1.5 is >> rounded to 2.0 and 2.5 is rounded to 3.0. >> >> If I want to round to the nearest even, that is >> >> my_round(1.5) = 2 # As expected >> my_round(2.5) = 2 # Not 3, which is an odd num >> >> I'm interested in rounding numbers of the form "x.5" depending upon >> whether x is odd or even. Any idea about how to implement it ? > > This seams to work fine: > evenRound = lambda f: round(f/2.)*2 > >>>> [(f*.5, evenRound(f*.5)) for f in xrange(0,20)] > [(0.0, 0.0),(0.5, 0.0), > (1.0, 2.0), (1.5, 2.0), (2.0, 2.0), (2.5, 2.0), > (3.0, 4.0), (3.5, 4.0), (4.0, 4.0), (4.5, 4.0), > (5.0, 6.0), (5.5, 6.0), (6.0, 6.0), (6.5, 6.0), > (7.0, 8.0), (7.5, 8.0), (8.0, 8.0), (8.5, 8.0), > (9.0, 10.0), (9.5, 10.0)] > No, this does not work: >>> [(f*.25, evenRound(f*.25)) for f in xrange(0,20)] [(0.0, 0.0), (0.25, 0.0), (0.5, 0.0), (0.75, 0.0), (1.0, 2.0), (1.25, 2.0), (1.5, 2.0), (1.75, 2.0), (2.0, 2.0), (2.25, 2.0), (2.5, 2.0), (2.75, 2.0), (3.0, 4.0), (3.25, 4.0), (3.5, 4.0), (3.75, 4.0), (4.0, 4.0), (4.25, 4.0), (4.5, 4.0), (4.75, 4.0)] x.75 should be rounded up. -- Sjoerd Mullender -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 379 bytes Desc: OpenPGP digital signature URL: From sjmachin at lexicon.net Tue Apr 29 17:14:02 2008 From: sjmachin at lexicon.net (John Machin) Date: Tue, 29 Apr 2008 21:14:02 GMT Subject: pyExcelerator number formats and borders (was Re: PyExcerlerator details) In-Reply-To: <937af823-9581-416e-85c1-57a5b0cc69de@e39g2000hsf.googlegroups.com> References: <937af823-9581-416e-85c1-57a5b0cc69de@e39g2000hsf.googlegroups.com> Message-ID: <48178F91.4010501@lexicon.net> A_H wrote: > Hi, I'm using PyExcelerator, and it's great, If you are using the latest released version, it's not, IMO. Reading the fixed-later bug reports on Sourceforge may prompt you to get the latest version from svn. Reading the unfixed bug reports on Sourceforge may prompt you to switch to xlwt (i.e. "Excel write"), a fork of pyExcelerator (fixed known and unknown bugs, improved performance, and runs under Python 2.3) -- available from https://secure.simplistix.co.uk/svn/xlwt/trunk See also http://groups.google.com/group/python-excel [to which I've CCed this reply]. > but I can't figure out a > few things: > > > (1) I set the cell style to '0.00%' but the style does not work. That isn't a style, it's a "number format". See num_formats.py in the examples directory. > > (2) I want to place a border around the cells( x1, y1, x2, y2 ) but I > can't find any example of doing that. > Well I do see ONE example, but it erases the cells if I do it after, > or when I write to the cells that erases the outline. At the moment, neither pyExcelerator nor xlwt offer a style-setting facility that's independent of the Worksheet.write method. It could well be a useful enhancement. > Surely I don't have to tediously set each cells border? Perhaps you could suggest what you think the API for setting a border on a rectangle should be. Each cell's border has to be set somehow. With a style_setting approach, there are 8 different cases (4 sides and 4 corners). With an independent border-setting approach, there would be only 4 different cases (4 sides) ... this needs looking at to see how easily the existing data model would support it. Regards, John From mail at timgolden.me.uk Tue Apr 29 09:46:59 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 29 Apr 2008 14:46:59 +0100 Subject: Windows Printing using win32print In-Reply-To: <58067CF3E0784DA3BEF22324FD03969A@hadron> References: <58067CF3E0784DA3BEF22324FD03969A@hadron> Message-ID: <481726D3.1020300@timgolden.me.uk> Jos? Roberto wrote: > Ol? KellyK! > I have read your comentary about how to print with python in windows using win32print. > I have trying to use in my problem : print a figure (.jpg, .png...etc) could you help me? Does this help? http://timgolden.me.uk/python/win32_how_do_i/print.html#rough_and_ready TJG From mal at egenix.com Sat Apr 19 08:22:09 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Sat, 19 Apr 2008 14:22:09 +0200 Subject: How to print a unicode string? In-Reply-To: <072f2f58-2434-4848-9eb7-85033069d1f9@a22g2000hsc.googlegroups.com> References: <87d4omsovf.fsf@benfinney.id.au> <4edea21e-d45c-4467-a66d-e270365eb812@l64g2000hse.googlegroups.com> <878wzasm10.fsf@benfinney.id.au> <072f2f58-2434-4848-9eb7-85033069d1f9@a22g2000hsc.googlegroups.com> Message-ID: <4809E3F1.3000606@egenix.com> On 2008-04-19 03:09, damonwischik at gmail.com wrote: > Another poster pointed me to >>> sys.stdout = codecs.getwriter("UTF-8")(sys.stdout) > and this works great. All I want now is some reassurance that this is > the most appropriate way for me to achieve what I want (e.g. least > likely to break with future versions of Python, most in keeping with > the design of Python, easiest for me to maintain, etc.). While the above works nicely for Unicode objects you write to sys.stdout, you are going to have problems with non-ASCII 8-bit strings, e.g. binary data. Python will have to convert these to Unicode before applying the UTF-8 codec and uses the default encoding for this, which is ASCII. You could wrap sys.stdout using a codecs.EncodedFile() which provides transparent recoding, but then you have problems with Unicode objects, since the recoder assumes that it has to work with strings on input (to e.g. the .write() method). There's no ideal solution - it really depends a lot on what your application does and how it uses strings and Unicode. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 19 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From mfb.chikazuku at gmail.com Fri Apr 11 18:03:47 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Sat, 12 Apr 2008 00:03:47 +0200 Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> Message-ID: <47ffee86$0$6838$2d805a3e@textnews.eweka.nl> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Rune Strand wrote: > On Apr 10, 3:54 am, Chris Stewart wrote: > ... >> >> Next, what would you say is the best framework I should look into? >> I'm curious to hear opinions on that. > > GUI-programming in Python is a neanderthal experience. What one may > love with console scripts is turned upside-down. Projects like Boa > Constructor seemed to be a remedy, but is not developed. The Iron- > Pythonistas has a very promising RAD GUI-tool in the IronPython - > Studio, http://www.codeplex.com/IronPythonStudio - but if you're non- > Iron, only sorrow is left - unless you fancy creating GUI in a text- > editor. Something I consider waste of life. Qt Designer. And creating the GUI yourself in the text editor isn't that bad, plus you have much better control over it. MFB -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFH/+BIDpaqHmOKFdQRAskNAKCDvMAK2MQCurxJ1zopibYOzhUpNgCgq7sn NxW9nWKU9nDrybd2EoxX51w= =okW6 -----END PGP SIGNATURE----- From kyosohma at gmail.com Fri Apr 25 09:01:50 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 25 Apr 2008 06:01:50 -0700 (PDT) Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> <480fa6e3$0$34491$742ec2ed@news.sonic.net> <7xzlrj14r7.fsf@ruckus.brouhaha.com> Message-ID: On Apr 24, 1:34?pm, Paul Rubin wrote: > Paul Boddie writes: > > simple Python-only modules, all you'd really need to do to prove the > > concept is to develop the client-side Windows software (eg. apt-get > > for Windows) which downloads package lists, verifies signatures, and > > works out where to put the package contents. ... > > I thought the Windows "solution" to this was Authenticode, which is a > scheme for signing executables against certificates similar to those > used on SSL web sites. ?Of course there's been at least one notorious > forgery, but typical Linux distro repositories are probably not all > that secure either. > > In the case of a pure Python program like Beautiful Soup, I certainly > think any installation needing running code should be done by > distutils included in the Python distro. I only create binaries using the bdist_wininst or bdist_msi commands for the extensions. If you think adding a code signature will make the binaries more acceptable, I'm not against it. Certificates from Comodo don't cost too much... Mike From bronger at physik.rwth-aachen.de Mon Apr 21 09:21:36 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Mon, 21 Apr 2008 15:21:36 +0200 Subject: Finally had to plonk google gorups. References: <966256b2-fe7c-4ec5-900b-90b285311881@k10g2000prm.googlegroups.com> Message-ID: <87abjne42n.fsf@physik.rwth-aachen.de> Hall?chen! NickC writes: > Hmm, according to this thread I probably shouldn't bother even > trying to contribute to c.l.p discussions that are highlighted in > the Python- URL announcements, even in cases where I think a core > developer's perspective may be of interest. As someone that only > posts here rarely, and uses Google Groups with a Gmail address to > do so, it sounds like I'll be kill-filed by a lot of people > regardless of the contents of what I post. I don't think that their fraction is significant. Be that as it may, I'm not one of those who accept high amounts of false positives in their anti-spam strategy. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From castironpi at gmail.com Mon Apr 21 14:03:05 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Mon, 21 Apr 2008 11:03:05 -0700 (PDT) Subject: yield expression programmized-formal interpretation. (interpretation of yield expression.) Message-ID: <888d1fff-5566-47db-b1a9-6c0bb994d7da@d1g2000hsg.googlegroups.com> What if I say oath= yield or other= yield ? Does yield evaluate without parenthes? (Eth.) From gagsl-py2 at yahoo.com.ar Wed Apr 16 18:19:37 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 19:19:37 -0300 Subject: Passing the output of a thread to the caller. References: Message-ID: En Wed, 16 Apr 2008 16:29:48 -0300, Marlin Rowley escribi?: > I have a thread that I've created from a main program. I started this > thread and passed it a function to execute. Within this function are > 'print' statements. While they are directly translated to the stdout, I > would love to return them back to the program itself and store them in > an object. How would I do this? Replace sys.stdout with an object that stores the lines printed. (Due to the way the print statement works, you should not inherit from file) class PrintBuffer: def __init__(self, stream): self._stream = stream self.output = [] def write(self, text): self.output.append(text) self._stream.write(text) def __getattr__(self, name): return getattr(self._stream, name) py> import sys py> sys.stdout = PrintBuffer(sys.stdout) py> print "Hello world!" Hello world! py> print 2,"*",3,"=",2*3 2 * 3 = 6 py> print >>sys.stderr, sys.stdout.output ['Hello world!', '\n', '2', ' ', '*', ' ', '3', ' ', '=', ' ', '6', '\n'] py> -- Gabriel Genellina From johng at neutralize.com Tue Apr 8 09:43:57 2008 From: johng at neutralize.com (monk.e.boy) Date: Tue, 8 Apr 2008 06:43:57 -0700 (PDT) Subject: urlparse http://site.com/../../../page.html References: <9fdd0d8b-785a-4363-be6a-75f993527754@c65g2000hsa.googlegroups.com> Message-ID: I figured it out and blogged the answer: http://teethgrinder.co.uk/blog/Normalize-URL-path-python/ monk.e.boy From nick at stinemates.org Fri Apr 18 15:13:35 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 12:13:35 -0700 Subject: python beginer In-Reply-To: <81d84eb10804160020n114c4d7ekfef7a09532813e39@mail.gmail.com> References: <81d84eb10804160020n114c4d7ekfef7a09532813e39@mail.gmail.com> Message-ID: <20080418191335.GJ19281@deviL> On Wed, Apr 16, 2008 at 12:50:51PM +0530, ashish kamble wrote: > hi, > can anyone tell me hw to start with webapplication scripting(e.g login > page..etc) > if anyone has soln for this or simple e.g that mention above please send me > > by > > > and have a nice day > -- > http://mail.python.org/mailman/listinfo/python-list Start with learning how to type. -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From gagsl-py2 at yahoo.com.ar Fri Apr 4 02:25:29 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 04 Apr 2008 03:25:29 -0300 Subject: Unicode conversion problem (codec can't decode) References: <47F5AFFC.3060902@harvee.org> Message-ID: En Fri, 04 Apr 2008 01:35:08 -0300, Eric S. Johansson escribi?: > I'm having a problem (Python 2.4) converting strings with random 8-bit > characters into an escape form which is 7-bit clean for storage in a > database. > Here's an example: > > body = meta['mini_body'].encode('unicode-escape') > > when given an 8-bit string, (in meta['mini_body']), the code fragment > above > yields the error below. > > 'ascii' codec can't decode byte 0xe1 in position 13: ordinal not in > range(128) Because unicode-escape expects an unicode object as input; if you pass a byte string, it tries to convert it to unicode using the default encoding (ascii) and fails. > I've read a lot of stuff about Unicode and Python and I'm pretty > comfortable > with how you can convert between different encoding types. What I don't > understand is how to go from a byte string with 8-bit characters to an > encoded > string where 8-bit characters are turned into two character hexadecimal > sequences. Almost there: use string-escape instead; it takes a byte string and returns another byte string in ASCII. > I really don't care about the character set used. I'm looking for a > matched set > of operations that converts the string to a seven bits a form and back > to its > original form. Ok, string-escape should work. But which database are you using that can't handle 8bit strings? -- Gabriel Genellina From tradertrade13 at gmail.com Sat Apr 19 03:36:06 2008 From: tradertrade13 at gmail.com (tradertrade13 at gmail.com) Date: Sat, 19 Apr 2008 00:36:06 -0700 (PDT) Subject: www.tradertrade.com(accept paypal).buy sell nike shox R4sneaker trainer sports shoes.nike jordan airforce one shoes nike airmax shox shoes gucci prada timberland shoes Message-ID: We (www.tradertrade.com) china wholesale and retail new Nike Sneakers,Air Jordan Sneakers,air force ones 1s,Nike Dunks SB,Bape Sta from nike outlets and factory stores,also Nike wholesale - Jordan Shoes we supply nike sneakers jordan sneaker air force 1s ... Featuring unique gift ideas for birthdays,weddings, anniversaries & holidays.Nike Air Max LTD-Nike Air Max Ltd Shoes, Nike Air Max Ltd Trainers. ... We (www.tradertrade.com) also sale and wholesale nike shoes other styles:nike air max - nike air max Nike Air Max - Nike Air Max TN Plus,TN BURBERRY,Gucci,TN L.V.. NIKE TN REQUINS CHAUSSURES,neuves hommes Nike TN requins Chaussures:Nike Air Max TN Plus men's,Nike Shox - Mens,Womens Nike Shox basketball shoes wholesale from chinaNike Shox TL NZ R4 R5 Turbo Monster Nike shoes wholesale,Puma - Puma Shoes.Nike shoes wholesale:Puma Shoes men's women's trainers at globnikesneakers dot com Puma Shoes cheap discount shoes nike wholesale and sale to nike shop and nike We sell Nike Air Max shoes,nike air max trainers for running and training- Nike Air Max 360 95 97 2003 Tn Plus Nike shoes wholesale,air max2 cb 94,air max2 cb,air ...Nike Wholesale,Nike Sneaker,jordan Sneaker, Air Force one 1s, Dunk Dunks Jordan Jordans Air Max Shox Rift...Timberland.Timberland boots,Timberland shoes,Prada wholesale,Prada sale,Prada shop,Prada store.we wholesale and sale cheap discount Timberland men's women's,We Wholesale Cheap Jordan Shoes,Michael Jordan Shoes,Nike Jordan Basketball shoes,Nike Air Jordan.Timberland-Timberland Boots.Nike shoes wholesale:Timberland Boots men's women's trainers sneakers basketball shoes running shoes.Timberland Boots cheap discount Nike Air Max 90-Nike Air Max 90 Shoes,Nike Air Max 90 trainers. at globnikesneaker dot com nike shoes Nike Air Max -> Nike Air Max 90 (Note Mens model size 41 42 43 44 45 46.Nike shoes buy, nike shoes wholesale, buy nike shoes from china nike shoes wholesale ... (www.tradertrade.com) Nike Running shoes,nike shox and nike air max Running shoes, nike shox tl nz r4 turbo monster running shoes,nike air max tn,Puma - Puma Speed Cat. Nike shoes wholesale:Puma Speed Cat men's women's trainers sneakers basketball shoes running shoes,Nike Air Max 2003-Nike Air Max 2003 Trainers,Nike Air Max 2003 Shoes. ... Nike Air Max 2003 cheap discount shoes nike wholesale and sale to nike shop and nike store.Nike Air Max - Nike Air Max 2004 trainers. Nike shoes wholesale:Nike Air Max ... Nike Air Max 2003 cheap discount shoes nike wholesale and sale to nike shop and nike factory.Nike Air Jordan 3,nike jordan 3 retro shoes,nike air jordan 3 retro sneakers,Nike air jordan 3 shoes wholesale:Nike Air Jordan 3 men's women's trainers sneakers,Nike Shox- Nike Shox TL NZ R4 R5 Turbo Monster Nike shoes wholesale.We wholesale nike shoes: Nike Shox TL,Nike Shox NZ,Nike Shox R4,Nike Shox R5,Nike Shox Nike Air Dunk- Nike Air Dunk High.Nike shoes wholesale:Nike Air Dunk High men's women's trainers sneakers basketball shoes running shoes.Nike Air Max 97, Nike Womens Air Max 97 trainers, nike mens air max 97 trainers,nike air max 97 running shoes sell cheap with discount,Nike Air Force 1-Nike ... Nike Air force 1 High cheap discount shoes nike wholesale at globnikesneakers dot com We also sale and wholesale nike shoes other styles:nike air we sell cheap Nike Air Max 95 shoes and trainers for womens,mens and for running,trainning,tennis with all black color,pink color,red, blue..with discount,Nike air jordan shoes for wholesale,We wholesale and sale nike air jordan Basketball shoes,buy quality of nike air jordan running shoes trainers sneakers for our ...Nike cheap shoes,we sale nike shoes in cheap price,buy cheap nike shoes Adidas. Adidas shoes,Adidas wholesale,Adidas shop,Adidas store,Adidas goodyear,Adidas TMAC,Adidas wholesale and sale cheap discount Adidas.Nike Dunk - Nike Air Dunk. Nike Dunk Air Dunk Low Mid High Nike shoes wholesale.We wholesale Nike Dunk Air Dunk Men's Women's shoes wholesale at cheap discount price,Nike Air Rift-Nike Rift Air Rift Nike shoes wholesale.We wholesale nike shoes;Nike Rift shoes, Nike Air Rift shoes.Puma-Puma Joggers.Nike shoes wholesale:Puma Joggers men's women's trainers... (www.tradertrade.com) Puma Joggers cheap discount shoes nike wholesale and sale to nike shop and nike Adidas - Adidas Shoes. Nike shoes wholesale: Adidas Shoes men's women's trainers ... Adidas Shoes cheap discount shoes nike wholesale and sale to nike shop and nike Shoes. Nike Air Max. Nike Air Max TN Plus. Nike Air Max 90. Nike Air Max 91. Nike Air Max 95 ... Nike Air force 1 Low. Nike Air force 1 High. Nike Air Jordan Nike Air Max Nike Air Max 360 95 97 2003 Tn Plus ... Nike Air Max 360, Nike Air Max 95, Nike Air Max 97, Nike Air Max 2003, ... (www.tradertrade.com)Nike Air Jordan 2,Nike Jordan 2 Retro Shoes Nike Air Jordan 2 shoes wholesale: Nike Air Jordan 2 men's women's trainers sneakers sketball shoes running shoes at globnikesneakers dot com .Nike Air Max - Nike Air Max 2005, Nike Air Max 2005 Trainers.... We also sale and wholesale nike shoes other styles:nike air max - nike air max ,Nike Air Jordan 11 Retro- Nike Air Jordan XI Retro. ...Nike Air Jordan 11 cheap discount shoes nike wholesale and sale to nike shop andJordan 5-Jordan V at globnikesneakers dot com Nike Air Jordan 5 V- Nike Air Jordan 5. Nike air jordan 5 shoes wholesale:Nike Air Jordan 5 men's women's trainers sneakers basketball shoes,Nike Air Force 1-Nike ... Nike Air force 1 Low cheap discount shoes nike wholesale and ... We also sale and wholesale nike shoes other styles:nike air max ...Nike Shox Turbo- Nike Shox Turbo Oh+. Nike Shox Trubo shoes wholesale: Nike Shox ... Nike Shox Turbo oh, iv,iii shoes here at cheap price from(www.tradertrade.com) our websit: http://www.tradertrade.com Msn and Email: tradertrade01 at hotmail.com Tradertrade02 at hotmail.com From marco at sferacarta.com Wed Apr 30 07:38:38 2008 From: marco at sferacarta.com (Marco Mariani) Date: Wed, 30 Apr 2008 13:38:38 +0200 Subject: computing with characters In-Reply-To: <87tzhjy4u2.fsf@physik.rwth-aachen.de> References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> <87tzhjy4u2.fsf@physik.rwth-aachen.de> Message-ID: <1TYRj.27306$o06.18162@tornado.fastwebnet.it> Torsten Bronger wrote: > However, join() is really bizarre. The list rather than the > separator should be the leading actor. No, because join must work with _any sequence_, and there is no "sequence" type to put the join method on. This semantic certainly sets python apart from many other languages. >>> '-'.join(c for c in 'hello') 'h-e-l-l-o' >>> From mysakjs at gmail.com Fri Apr 25 18:35:58 2008 From: mysakjs at gmail.com (John) Date: Fri, 25 Apr 2008 15:35:58 -0700 (PDT) Subject: newbie question Message-ID: I'm working with the HTMLParser module and have implemented HTMLParser.handle_starttag() and I see there is a separate handle_data method (which can be implemented), but I am not clear how to tie this together with a given start tag, so I only get the data I want. For example, I'd like to get a handle on the character data ( the number 1) immediately after the following start tag 1
. . . Any ideas? From gvijaysrinivas at gmail.com Wed Apr 23 14:09:53 2008 From: gvijaysrinivas at gmail.com (vijay) Date: Wed, 23 Apr 2008 11:09:53 -0700 (PDT) Subject: Calling Python code from inside php Message-ID: Hi I have a python code performing some computation for me.I have a html page which passes certain argumnets to a php page.This php page needs to pass on the value to the Python class and get the result back. How do I go about this?? Cheers Vijay From nagle at animats.com Wed Apr 23 12:47:18 2008 From: nagle at animats.com (John Nagle) Date: Wed, 23 Apr 2008 09:47:18 -0700 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. In-Reply-To: References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> Message-ID: <480f6553$0$34545$742ec2ed@news.sonic.net> Mike Driscoll wrote: > Ken, > > On Tue, Apr 22, 2008 at 1:36 PM, Kenneth McDonald > wrote: >> Sadly. >> >> Thanks, >> Ken >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > I've attached the 2.4 version. I also have some Windows binaries for > Beautiful Soup uploaded to my website: > http://www.pythonlibrary.org/python_modules.htm What on earth do you need a "Windows binary" for? "BeautifulSoup" is ONE PYTHON SOURCE FILE, "BeautifulSoup.py". It can be downloaded here: http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup.py And yes, the site is up. John Nagle From skanemupp at yahoo.se Sat Apr 5 15:24:59 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 12:24:59 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <7113d012-01bb-4426-bb40-9e2811cdb102@x41g2000hsb.googlegroups.com> <3cf4bbc8-b828-45c5-b9a8-766ce600af43@y21g2000hsf.googlegroups.com> Message-ID: <588aff92-63c4-49fa-88d5-5430e84b72a5@r9g2000prd.googlegroups.com> it works now. here is all the code: #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self, master=None): """Initialize yourself""" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): ## """Create the Entry, set it to be a bit wider""" ## self.enText = Entry(self) ## self.enText.grid(row=0, column=0, columnspan=3) """Create the Button, set the text and the command that will be called when the button is clicked""" self.btnDisplay = Button(self, text="calculate!", state=DISABLED) self.btnDisplay.grid(row=0, column=31) self.btnDisplay = Button(self,text='1',command=lambda n=1:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='2',command=lambda n=2:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='3',command=lambda n=3:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='+',command=lambda n="+":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) self.btnDisplay = Button(self,text='4',command=lambda n=4:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='5',command=lambda n=5:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='6',command=lambda n=6:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='-',command=lambda n="-":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=3, padx=5, pady=5) self.btnDisplay = Button(self,text='7',command=lambda n=7:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='8',command=lambda n=8:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='9',command=lambda n=9:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='*',command=lambda n="*":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=3, padx=5, pady=5) self.btnDisplay = Button(self,text='0',command=lambda n=0:self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='C',command=lambda n="C":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='r',command=lambda n="r":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='/',command=lambda n="/":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) def Display(self, number): #print number self.lbText = Label(self, text=number) self.lbText.grid(row=0, column=0) if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() From boyee118 at gmail.com Fri Apr 18 21:50:18 2008 From: boyee118 at gmail.com (jincan) Date: Sat, 19 Apr 2008 09:50:18 +0800 Subject: ANN: pyspread 0.0.1 In-Reply-To: References: Message-ID: Traceback (most recent call last): File "pyspread.py", line 25, in import os, sys, bz2, pysgrid, itertools, numpy ImportError: No module named pysgrid Maybe any other package needed? 2008/4/18 Martin Manns : > pyspread 0.0.1 is now available at: > http://pyspread.sourceforge.net > > pyspread is a spreadsheet that accepts a pure python expression in > each cell. > > Highlights: > + No non-python syntax add-ons > + Access to python modules from cells > + 3D grid > + Numpy object array for representation of string entry into grid cell > + Numpy object array for representation of eval function array > + Cell access via slicing of numpy function array > + X, Y, and Z yield current cell location for relative reference > > Requires: Python 2.5, Numpy 1.0.4, and wxPython 2.8.7.1. > License: GPL > > Best Regards > Martin Manns > -- > mmanns gmx.net > -- > http://mail.python.org/mailman/listinfo/python-list > -- "OpenBookProject"-?????????? ??: http://groups.google.com/group/OpenBookProject ??: http://wiki.woodpecker.org.cn/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From toby at tobiah.org Tue Apr 15 16:36:11 2008 From: toby at tobiah.org (Tobiah) Date: Tue, 15 Apr 2008 13:36:11 -0700 Subject: Getting subprocess.call() output into a string? Message-ID: I am not sure how to capture the output of a command using subprocess without creating a temp file. I was trying this: import StringIO import subprocess file = StringIO.StringIO() subprocess.call("ls", stdout = file) Traceback (most recent call last): File "", line 6, in ? File "/usr/local/lib/python2.4/subprocess.py", line 413, in call return Popen(*args, **kwargs).wait() File "/usr/local/lib/python2.4/subprocess.py", line 534, in __init__ (p2cread, p2cwrite, File "/usr/local/lib/python2.4/subprocess.py", line 840, in _get_handles c2pwrite = stdout.fileno() AttributeError: StringIO instance has no attribute 'fileno' So how do I get the output into a string? I thought that the idea of StringIO was that it could be used where a file was expected. Thanks, Toby ** Posted from http://www.teranews.com ** From fr5478bey at gmail.com Sat Apr 26 11:39:44 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:39:44 -0700 (PDT) Subject: Capture NX 1.2 crack Message-ID: <0f283675-2fe3-4a16-8576-948896b04fe7@c58g2000hsc.googlegroups.com> Capture NX 1.2 crack http://cracks.00bp.com F R E E C R A C K S From fredri8758lupo at gmail.com Wed Apr 23 06:09:45 2008 From: fredri8758lupo at gmail.com (fredri8758lupo at gmail.com) Date: Wed, 23 Apr 2008 03:09:45 -0700 (PDT) Subject: falcon 4.0 patch Message-ID: falcon 4.0 patch http://cracks.12w.net F R E E C R A C K S From usenet-mail at markshroyer.com Wed Apr 16 15:50:45 2008 From: usenet-mail at markshroyer.com (Mark Shroyer) Date: Wed, 16 Apr 2008 15:50:45 -0400 Subject: What can we do about all the spam that the list is getting? References: <259ab201-9d2b-4e4e-88a7-e2fe277f0066@a23g2000hsc.googlegroups.com> Message-ID: In article , Mensanator wrote: > On Apr 16, 12:01?pm, sr... at ferg.org wrote: > > What can we do about all the spam that comp.lang.python is getting? > > Things are getting pretty bad. > > Buy Google and make them fix it. I've had pretty good luck with MT-NewsWatcher, a freeware Mac newsreader that performs Bayesian spam filtering. Thunderbird's Usenet reader also offers Bayesian filtering, which presumably works just as well for classifying Usenet spam as it does at handling email spam. So download a "real" NNTP client for whatever platform you're on and give its spam filter a shot; clearly Google is not interested in fighting spam itself. -- Mark Shroyer http://markshroyer.com/contact/ From s0suk3 at gmail.com Fri Apr 25 18:39:24 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Fri, 25 Apr 2008 15:39:24 -0700 (PDT) Subject: Receive data from socket stream Message-ID: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> I wanted to ask for standard ways to receive data from a socket stream (with socket.socket.recv()). It's simple when you know the amount of data that you're going to receive, or when you'll receive data until the remote peer closes the connection. But I'm not sure which is the best way to receive a message with undetermined length from a stream in a connection that you expect to remain open. Until now, I've been doing this little trick: data = client.recv(256) new = data while len(new) == 256: new = client.recv(256) data += new That works well in most cases. But it's obviously error-prone. What if the client sent *exactly* two hundred and fifty six bytes? It would keep waiting for data inside the loop. Is there really a better and standard way, or is this as best as it gets? Sorry if this is a little off-topic and more related to networking, but I'm using Python anyway. Thanks, Sebastian From fennelllindy8241 at gmail.com Mon Apr 28 03:20:01 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:20:01 -0700 (PDT) Subject: mapsource keygen Message-ID: mapsource keygen http://crack.cracksofts.com From pavlovevidence at gmail.com Sat Apr 26 17:12:17 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Sat, 26 Apr 2008 14:12:17 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> Message-ID: On Apr 26, 12:15 pm, n00m wrote: > fgets() from C++ iostream library??? Sheesh. That'll teach me to read carefully. (Ok, it probably won't.) Other two points still apply. Carl Banks From usenet at janc.be Wed Apr 2 13:10:11 2008 From: usenet at janc.be (Jan Claeys) Date: Wed, 02 Apr 2008 17:10:11 GMT Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: Op Tue, 01 Apr 2008 10:27:18 -0700, schreef sprad: > I'm a high school computer teacher, and I'm starting a series of > programming courses next year (disguised as "game development" classes > to capture more interest). The first year will be a gentle introduction > to programming, leading to two more years of advanced topics. > [...] > So -- would Python be a good fit for these classes? There are at least 3 books about game programming in python: -- JanC From kveretennicov at gmail.com Sat Apr 5 10:09:55 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Sat, 5 Apr 2008 17:09:55 +0300 Subject: urllib and bypass proxy In-Reply-To: References: Message-ID: <4660fe300804050709r7e0bc62at4538fc2fa40630e5@mail.gmail.com> On Thu, Apr 3, 2008 at 9:21 PM, kc wrote: > If this has value, do I submit a bug report or does > someone else? You do :) (http://bugs.python.org) -- kv From fr5478bey at gmail.com Sat Apr 26 11:43:18 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:43:18 -0700 (PDT) Subject: big city adventure crack Message-ID: big city adventure crack http://cracks.00bp.com F R E E C R A C K S From arnodel at googlemail.com Sat Apr 26 12:20:50 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sat, 26 Apr 2008 17:20:50 +0100 Subject: Setting an attribute without calling __setattr__() References: Message-ID: aahz at pythoncraft.com (Aahz) writes: > In article , > Arnaud Delobelle wrote: >>Joshua Kugler writes: >>> >>> self.me = [] >>> for v in obj: >>> self.me.append(ObjectProxy(v)) >> >>Note that is could be spelt: >> >>self.me = map(ObjectProxy, v) ^-- I meant obj! > > It could also be spelt: > > self.me = [ObjectProxy(v) for v in obj] > > which is my preferred spelling.... I was waiting patiently for this reply... And your preferred spelling is py3k-proof as well, of course. I don't write map(lambda x: x+1, L) or map(itemgetter('x'), L) but I like to use it when the first argument is a named function, e.g. map(str, list_of_ints). -- Arnaud From arnodel at googlemail.com Sun Apr 20 06:03:07 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 20 Apr 2008 03:03:07 -0700 (PDT) Subject: ???Python Memory Management S***s??? References: Message-ID: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> On Apr 20, 9:40?am, "Hank @ITGroup" wrote: > Hi, people! > > Greetings~ > These days I have been running a text processing program, written by > python, of cause. > In order to evaluate the memory operation, I used the codes below: > > """ > ?> string1 = ['abcde']*999999 ? ?# this took up an obvious memory space... > ?> del string1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# this freed the memory > successfully !! > > """ > For primary variants, the *del* thing works well. However, challenge the > following codes, using class-instances... > > """ > ?> from nltk import FreqDist ? ? # nltk stands for Natural Language Tool > Kit (this is not an advertisement ~_~) > ?> instance = FreqDist() > ?> instanceList = [instance]*99999 > ?> del instanceList ? ? ? ? ? ? # You can try: nothing is freed by this > """ > ??? How do you people control python to free the memory in python 2.5 or > python 2.4 ??? > Cheers!!! You mistyped your subject line; it should have read: "Help needed - I don't understand how Python manages memory" -- Arnaud From deets at nospam.web.de Mon Apr 7 12:46:01 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Mon, 07 Apr 2008 18:46:01 +0200 Subject: reading dictionary's (key,value) from file References: <974814d3-59f0-49ec-9b4d-9f5dd7dfaf54@q24g2000prf.googlegroups.com> Message-ID: <65v1f5F2bkfdlU1@mid.uni-berlin.de> ankitks.mital at gmail.com wrote: > Folks, > Is it possible to read hash values from txt file. > I have script which sets options. Hash table has key set to option, > and values are option values. > > Way we have it, we set options in a different file (*.txt), and we > read from that file. > Is there easy way for just reading file and setting options instead of > parsing it. > > so this is what my option files look like: > > 1opt.txt > { '-cc': '12', > '-I': r'/my/path/work/'} > > 2opt.txt > { '-I': r/my/path/work2/'} > > so my scipt how has dictionary > options = { '-cc' :'12' > '-I': r'/my/path/work/:/my/path/work2/'} > > I am trying to avoid parsing Use a well-known config-file-format such as the module ConfigParser supports. Diez From tinnews at isbd.co.uk Mon Apr 7 09:09:13 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 07 Apr 2008 13:09:13 GMT Subject: A file iteration question/problem References: <47f8eee1$0$759$bed64819@news.gradwell.net> <322f98fd-eb6e-4a05-a8c7-1e0c5329e955@w5g2000prd.googlegroups.com> Message-ID: <47fa1cf9$0$761$bed64819@news.gradwell.net> Arnaud Delobelle wrote: > On Apr 6, 4:40?pm, tinn... at isbd.co.uk wrote: > > I want to iterate through the lines of a file in a recursive function > > so I can't use:- > > > > ? ? f = open(listfile, 'r') > > ? ? for ln in f: > > > > because when the function calls itself it won't see any more lines in > > the file. ?E.g. more fully I want to do somthing like:- > > > > def recfun(f) > > ? ? while True: > > ? ? ? ? str = readline(f) > > ? ? ? ? if (str == "") > > ? ? ? ? ? ? break; > > ? ? ? ? # > > ? ? ? ? # do various tests > > ? ? ? ? # > > ? ? ? ? if : > > ? ? ? ? ? ? recfun(f) > > > > Is there no more elegant way of doing this than that rather clumsy > > "while True" followed by a test? > > > > -- > > Chris Green > > You could use an iterator over the lines of the file: > > def recfun(lines): > for line in lines: > # Do stuff > if condition: > recfun(lines) > > lines = iter(open(filename)) > recfun(lines) > Does that work though? If you iterate through the file with the "for line in lines:" in the first call of recfun(lines) you surely can't do "for line in lines:" and get any sort of sensible result in recursive calls of recfun(lines) can you? -- Chris Green From lscbtfws at gmail.com Sat Apr 26 12:08:38 2008 From: lscbtfws at gmail.com (lscbtfws at gmail.com) Date: Sat, 26 Apr 2008 09:08:38 -0700 (PDT) Subject: Power mp3 cutter crack Message-ID: <8781bb16-a126-40a5-a8a6-a4ae4bc1bc51@w1g2000prd.googlegroups.com> Power mp3 cutter crack http://cracks.00bp.com F R E E C R A C K S From gherron at islandtraining.com Wed Apr 9 11:46:56 2008 From: gherron at islandtraining.com (Gary Herron) Date: Wed, 09 Apr 2008 08:46:56 -0700 Subject: Trouble with list comprehension In-Reply-To: <4c3db5c00804090830p1b05748drf4ee5b8c3185ad9e@mail.gmail.com> References: <4c3db5c00804090830p1b05748drf4ee5b8c3185ad9e@mail.gmail.com> Message-ID: <47FCE4F0.9070409@islandtraining.com> Shane Lillie wrote: > I've got a bit of code that looks like this: > > for i in xrange(1000): > # shuffle the doors > doors = [ 'G', 'C', 'G' ] > random.shuffle(doors) > > # save the doors that have goats (by index) > goats = [ x for x in range(2) if doors[x] == 'G' ] > Using range(2) is wrong since range(2) is [0,1]. You want range(3) which gives [0,1,2]. Gary Herron > but for some reason the list comprehension is not always returning a > list with 2 elements in it (sometimes it will be just 1 element). I've > tried changing to a generator as well as using filter() and all 3 give > the same sort of results. It works if I use a loop, but I'd really > like to know what I'm doing wrong here. Everything looks like it > should be working. > > Thanks in advance for any suggestions. > From meisnernel73884 at gmail.com Wed Apr 30 06:36:00 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:36:00 -0700 (PDT) Subject: call of duty modern warfare keygen Message-ID: <9edc4534-c99d-4354-b439-042a4ee70da1@w74g2000hsh.googlegroups.com> call of duty modern warfare keygen http://crack.cracksofts.com From stefan_ml at behnel.de Mon Apr 7 01:59:33 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 07 Apr 2008 07:59:33 +0200 Subject: splitting an XML file on the basis on basis of XML tags In-Reply-To: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> Message-ID: <47F9B845.9040205@behnel.de> bijeshn at gmail.com schrieb: > Hi all, > > i have an XML file with the following structure:: > > > -----| > | > | > . | > . | --------------------> constitutes one record. > . | > . | > . | > | > | > ----| > > . > . > . -----------------------| > . | > . | > . |----------------------> there are n > records in between.... > . | > . | > . | > . ------------------------| > . > . > > -----| > | > | > . | > . | --------------------> constitutes one record. > . | > . | > . | > | > | > ----| > > > > Here is the main root tag of the XML, and ... > constitutes one record. What I would like to do is > to extract everything (xml tags and data) between nth tag and (n > +k)th tag. The extracted data is to be > written down to a separate file. What do you mean by "written down to a separate file"? Do you have a specific format in mind? In general, you can try this: >>> from xml.etree import cElementTree as ET >>> itercontext = ET.iterparse("thefile.xml", events=("start", "end") >>> event,root = itercontext.next() >>> for event,element in itercontext: ... if event == "end" and element.tag == "r2": ... print ET.tostring(element) # write record subtree as XML ... root.clear() # one record done, clean up everything http://effbot.org/zone/element-iterparse.htm You can also do things like ... print element.findtext("r3/r4") Read the ElementTree tutorial to learn how to extract your data: http://effbot.org/zone/element.htm#searching-for-subelements Stefan From jason.scheirer at gmail.com Thu Apr 10 17:40:39 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Thu, 10 Apr 2008 14:40:39 -0700 (PDT) Subject: get array element References: <820d8589-8529-46af-907a-90ebaac4a6f5@a22g2000hsc.googlegroups.com> Message-ID: <738309b2-2727-494f-a3d2-afc5b243e53a@u12g2000prd.googlegroups.com> On Apr 10, 10:22 am, "Bryan.Fodn... at gmail.com" wrote: > I have an array, and I would like to get the indice value. > > a = array([13,14,15,16]) > > I would like something like a.getindice(15) > > If I want 15 it would return 2 a.index(15) From carbanancizpo at gmail.com Fri Apr 18 16:57:27 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:57:27 -0700 (PDT) Subject: new parkinsons patch Message-ID: <74618f4b-bf9b-403b-a964-300ed0492efb@24g2000hsh.googlegroups.com> new parkinsons patch http://cracks.12w.net F R E E C R A C K S From aftab_d at hotmail.com Wed Apr 30 04:51:19 2008 From: aftab_d at hotmail.com (GoodieMan) Date: Wed, 30 Apr 2008 01:51:19 -0700 (PDT) Subject: Free YouTube Video Downloader Software Message-ID: <14df39f8-00b2-46df-8ca3-3eb3f579cb3e@l17g2000pri.googlegroups.com> Friends, Here is an absolutely free tool to download any video from YouTube. SmoothTube downloads videos from YouTube and converts them to MPEG format, which is supported by almost all media players and devices. It also post processes videos, smoothing out some of the compression artifacts often introduced by YouTube's file size requirements. http://freeware4.blogspot.com/2008/04/smoothtube-youtube-video-downloader.html From skunkwerk at gmail.com Wed Apr 9 20:54:39 2008 From: skunkwerk at gmail.com (skunkwerk) Date: Wed, 9 Apr 2008 17:54:39 -0700 (PDT) Subject: popen pipe limit References: Message-ID: <7ef9fa61-2dc4-4a5e-b37d-ccd541dc0a9c@p39g2000prm.googlegroups.com> On Apr 7, 6:17?pm, "Gabriel Genellina" wrote: > En Mon, 07 Apr 2008 20:52:54 -0300,skunkwerk ? > escribi?: > > > I'm getting errors when reading from/writing to pipes that are fairly > > large in size. ?To bypass this, I wanted to redirect output to a file > > in the subprocess.Popen function, but couldn't get it to work (even > > after setting Shell=True). ?I tried adding ">","temp.sql" after the > > password field but mysqldump gave me an error. > > > the code: > > p1 = subprocess.Popen(["mysqldump","--all-databases","--user=user","-- > > password=password"], shell=True) > > p2 = subprocess.Popen(["gzip","-9"], stdin=p1.stdout) > > output = p2.communicate()[0] > > file=open('test.sql.gz','w') > > file.write(str(output)) > > file.close() > > You need a pipe to chain subprocesses: > > import subprocess > p1 = ? > subprocess.Popen(["mysqldump","--all-databases","--user=user","--password=password"], ? > stdout=subprocess.PIPE) > ofile = open("test.sql.gz", "wb") > p2 = subprocess.Popen(["gzip","-9"], stdin=p1.stdout, stdout=ofile) > p1.wait() > p2.wait() > ofile.close() > > If you don't want the final file on disk: > > p1 = ? > subprocess.Popen(["mysqldump","--all-databases","--user=user","--password=password"], ? > stdout=subprocess.PIPE) > p2 = subprocess.Popen(["gzip","-9"], stdin=p1.stdout, ? > stdout=subprocess.PIPE) > while True: > ? ?chunk = p2.stdout.read(4192) > ? ?if not chunk: break > ? ?# do something with read chunk > > p1.wait() > p2.wait() > > -- > Gabriel Genellina thanks Gabriel - tried the first one and it worked great! From python.list at tim.thechases.com Thu Apr 10 05:54:29 2008 From: python.list at tim.thechases.com (Tim Chase) Date: Thu, 10 Apr 2008 04:54:29 -0500 Subject: How to find documentation about methods etc. for iterators In-Reply-To: <47fdceb8$0$754$bed64819@news.gradwell.net> References: <47fce941$0$755$bed64819@news.gradwell.net> <47fdceb8$0$754$bed64819@news.gradwell.net> Message-ID: <47FDE3D5.6040806@tim.thechases.com> > First question, what sort of 'thing' is the file object, I need to > know that if I'm to look up ways of using it. you can always use type(thing) to find out what type it is. > Second question, even if I know what sort of thing a file object > is, how do I find methods applicable to it and/or functions > applicable to it? If you don't have a web-connection under your finger tips, using dir(thing) help(thing) help(thing.method) will tell you most of what you need to know. There's the occasional gap, and it doesn't always work when the underlying object is out in C-land, rather than a pure Python object that's well-designed with doc-strings (personal complaint about mod_python's failure to return dir() contents last I checked). But for the most part I can just pull up a console debug-session with Python, enter enough to get an instance of the object in question, and then use the above commands. This for me is Python's chief selling point: dir()....dir() and help(). Python's two selling points are dir(), help(), and very readable code. Python's *three* selling points are dir(), help(), very readable code, and an almost fanatical devotion to the BFDL. Amongst Python's selling points are such elements as dir(), help()...I'll come in again. > It's a common problem in all sorts of computer fields, if you know the > name of what you want it's easy to find out details of how to use it > but if you don't know its name (or even if it exists) it's much more > difficult to find. All Monty Python-quoting aside, Python has solved this (and gives 3rd-party library developers the tools to solve as well) problem of discoverability using dir() and help(). -tkc From robert.kern at gmail.com Tue Apr 29 17:14:03 2008 From: robert.kern at gmail.com (Robert Kern) Date: Tue, 29 Apr 2008 16:14:03 -0500 Subject: accuracy issues with numpy arrays? In-Reply-To: <30fa02c6-908c-4c1c-a2ed-acb0a754ea6c@r66g2000hsg.googlegroups.com> References: <30fa02c6-908c-4c1c-a2ed-acb0a754ea6c@r66g2000hsg.googlegroups.com> Message-ID: You will want to ask numpy questions on the numpy mailing list: http://www.scipy.org/Mailing_Lists I need a little more time to mull on your problem to give you an actual answer, but I hope I can do that over there instead of here. -- 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 From newptcai at gmail.com Mon Apr 14 09:48:47 2008 From: newptcai at gmail.com (=?GB2312?B?0rvK18qr?=) Date: Mon, 14 Apr 2008 06:48:47 -0700 (PDT) Subject: How to make python run faster Message-ID: <0baa301a-ec8c-48ef-b30e-f9c80f72e5af@u12g2000prd.googlegroups.com> I read this article on http://kortis.to/radix/python_ext/ And I decided to try if it's true. I write the program in 4 ways: 1. Pure C 2. Python using C extension 3. Python using psycho 4. Pure Python And then I used timeit to test the speed of these 4. Unsurprisingly, the time they cost were: 4 > 3 > 2 > 1 But I did noticed that 2 is a least 3 times slower than 1, not as fast as the article stated. That's quite weird and I thought maybe it's because I am using Windows. I did the same test on Linux and I found 2 only uses 1.5 times of time of 1. But, it is still not as fast as 1. From bvidinli at gmail.com Thu Apr 24 04:13:25 2008 From: bvidinli at gmail.com (bvidinli) Date: Thu, 24 Apr 2008 11:13:25 +0300 Subject: annoying dictionary problem, non-existing keys Message-ID: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> i use dictionaries to hold some config data, such as: conf={'key1':'value1','key2':'value2'} and so on... when i try to process conf, i have to code every time like: if conf.has_key('key1'): if conf['key1']<>'': other commands.... this is very annoying. in php, i was able to code only like: if conf['key1']=='someth' in python, this fails, because, if key1 does not exists, it raises an exception. MY question: is there a way to directly get value of an array/tuple/dict item by key, as in php above, even if key may not exist, i should not check if key exist, i should only use it, if it does not exist, it may return only empty, just as in php.... i hope you understand my question... -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From fiacre.patrick at gmail.com Tue Apr 29 21:47:20 2008 From: fiacre.patrick at gmail.com (Andrew Lee) Date: Tue, 29 Apr 2008 21:47:20 -0400 Subject: MatplotLib errors In-Reply-To: References: Message-ID: <4817CFA8.5050003@gmail.com> Thomas Philips wrote: > I have just started using MatPlotLib, and use it to generate graphs > from Python simulations. It often happens that the graph is generated > and a Visual C++ Runtime Library error then pops up: Runtime Error! > Program C:\Pythin25\Pythonw.exe This application has requested the > Runtime to terminate in an unusual way. Please contact the > application's support team for more information. > > I'm running Python 2.5.2 under Windows XP. Any thoughts on what what > may be causing the problem? > > Thanks in advance > > Thomas Philips There is a matplotlib-sig mailing list: matplotlib-devel at lists.sourceforge.net They would have MUCH more info on your problem that can be offered in a general python group. HTH From ganeshborse at gmail.com Mon Apr 21 09:24:15 2008 From: ganeshborse at gmail.com (grbgooglefan) Date: Mon, 21 Apr 2008 06:24:15 -0700 (PDT) Subject: how to pass C++ object to another C++ function via Python function Message-ID: <1810b155-5598-4f17-a8e9-e4aa848db5de@i36g2000prf.googlegroups.com> I am trying to pass a C++ object to Python function. This Python function then calls another C++ function which then uses this C++ object to call methods of that object's class. I tried something like this, but it did not work, gave core dump. class myclass { public: myclass(){}; ~myclass(){}; void printmyname() { printf("I am myclass, num=%d\n",num); }; }; main(){ myclass myobj char funcbody[]=\ "def pyfunction(t167,classobj):\n\ onemorefunc(t167,\"NONAMe\")\n\ return 10\n\ \n\n"; // compile this Python function using PyRun_String & get its pointer by PyObject_GetAttrString. // Later call it as below: myclass myobj(23); PyObject *pTuple = 0; pTuple = PyTuple_New(2); PyTuple_SetItem(pTuple,0,PyString_FromString("NAME")); // for t167 parameter PyObject *inputarg = Py_BuildValue("OO&",pTuple,myobj); // for classobj parameter result = PyObject_CallObject(pPyEvalFunction,inputarg); } How can I pass this class object to Python function? Is it possible to set it in tuple using PyTuple_SetItem, because I may have varying number of arguments for my Python functions & that's why I can't use Py_BuildValue. From grflanagan at gmail.com Wed Apr 30 11:16:38 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Wed, 30 Apr 2008 08:16:38 -0700 (PDT) Subject: Issue with regular expressions References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Message-ID: On Apr 29, 3:46 pm, Julien wrote: > Hi, > > I'm fairly new in Python and I haven't used the regular expressions > enough to be able to achieve what I want. > I'd like to select terms in a string, so I can then do a search in my > database. > > query = ' " some words" with and "without quotes " ' > p = re.compile(magic_regular_expression) $ <--- the magic happens > m = p.match(query) > > I'd like m.groups() to return: > ('some words', 'with', 'and', 'without quotes') > > Is that achievable with a single regular expression, and if so, what > would it be? > > Any help would be much appreciated. > With simpleparse: ---------------------------------------------------------- from simpleparse.parser import Parser from simpleparse.common import strings from simpleparse.dispatchprocessor import DispatchProcessor, getString grammar = ''' text := (quoted / unquoted / ws)+ quoted := string unquoted := -ws+ ws := [ \t\r\n]+ ''' class MyProcessor(DispatchProcessor): def __init__(self, groups): self.groups = groups def quoted(self, val, buffer): self.groups.append(' '.join(getString(val, buffer) [1:-1].split())) def unquoted(self, val, buffer): self.groups.append(getString(val, buffer)) def ws(self, val, buffer): pass groups = [] parser = Parser(grammar, 'text') proc = MyProcessor(groups) parser.parse(TESTS[1][1][0], processor=proc) print groups ---------------------------------------------------------- G. From jjl at pobox.com Tue Apr 1 15:27:08 2008 From: jjl at pobox.com (John J. Lee) Date: Tue, 01 Apr 2008 19:27:08 GMT Subject: How to build a body like this use SOAPPy? References: <0b531c8c-9f33-48f5-9446-09a1cb2db313@e6g2000prf.googlegroups.com> Message-ID: <873aq5e5pv.fsf@pobox.com> qgg writes: [...] > [...] Heh, you may have picked an discouragingly spammish subject line. John From steve at holdenweb.com Wed Apr 9 10:54:35 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 10:54:35 -0400 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. In-Reply-To: <6641eaF2ics8jU1@mid.uni-berlin.de> References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> <6641eaF2ics8jU1@mid.uni-berlin.de> Message-ID: Diez B. Roggisch wrote: [...] > And then come back and post self-contained examples of whatever behavior you > observe, and this community will be as helpful as it is. But we can't read > sense in anything you posted so far, despite the best efforts. So unless > that changes, you won't be helped here. > Thank heavens you and Gabriel chimed in: I was beginning to think it was just me! regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From cokofreedom at gmail.com Thu Apr 10 06:38:38 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Thu, 10 Apr 2008 03:38:38 -0700 (PDT) Subject: questions about Exceptions? References: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> <71cc8c25-f5f9-4f21-a9d8-06780bf97608@f63g2000hsf.googlegroups.com> <9af81b1a-3e02-4406-b9d2-0a9b6f46566b@p39g2000prm.googlegroups.com> <0e586d5d-6799-433f-b8a4-4de5d2a87b61@h1g2000prh.googlegroups.com> Message-ID: <46a79564-4069-46af-b6ab-b38bd9152c2a@d45g2000hsc.googlegroups.com> > def Calc(): > global nbr > try: > print eval(nbr) > #a = Label(mygui, text=eval(nbr)) > #a.place(relx=0.4, rely=0.1, anchor=CENTER) > except: > print "Not computable" > nbr = "" > > def Erase(): > global nbr > nbr = "" Seems to me you could be better off passing a parameter and a return statement of None (or your parameter cleaned) for those functions, which should work. Given an input, Eval it and then return None. That way you wouldn't need the Erase... From mail at timgolden.me.uk Sat Apr 12 14:54:05 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Sat, 12 Apr 2008 19:54:05 +0100 Subject: Recommended "from __future__ import" options for Python 2.5.2? In-Reply-To: <1208025680.10309.1247529999@webmail.messagingengine.com> References: <1208025680.10309.1247529999@webmail.messagingengine.com> Message-ID: <4801054D.5040101@timgolden.me.uk> Malcolm Greene wrote: > Is there a consolidated list of "from __future__ import" options to > choose from? Well, that bit's easy: import __future__ print __future__.all_feature_names TJG From Lie.1296 at gmail.com Tue Apr 22 05:39:58 2008 From: Lie.1296 at gmail.com (Lie) Date: Tue, 22 Apr 2008 02:39:58 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: <16c84243-ce95-4022-be8a-9425b2b428ff@q1g2000prf.googlegroups.com> On Apr 21, 7:04 am, "Terry Reedy" wrote: > Off the top of my head: copy C and use {} to demarcate blocks and ';' to > end statements, so that '\n' is not needed and is just whitespace when > present. So, repeatedly scan for the next one of '{};'. try this: from __future__ import braces :) From robert.kern at gmail.com Thu Apr 3 19:17:00 2008 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 03 Apr 2008 18:17:00 -0500 Subject: Easy-to-install-and-use scientific graphics (plotting) package for Python 2.5.1 on Linux Ubuntu 7.1 In-Reply-To: <771b5531-5681-499f-9fda-77749b5db09f@s37g2000prg.googlegroups.com> References: <771b5531-5681-499f-9fda-77749b5db09f@s37g2000prg.googlegroups.com> Message-ID: Dr. Colombes wrote: > Is there an easy scientific graphics (plotting) package for Python > 2.5.1 running on Ubuntu Linux 7.1 ("Gutsy Gibbon")? > > A few years ago I used PyLab (a MatLab-like plotting module for > Python) on a Windows machine, but I don't know if there is a similar > easy-to-install-and-use Python 2.5.1-compatible graphics package for > Ubuntu Linux 7.1? matplotlib (which you misname PyLab) works with Python 2.5.1 on Ubuntu, too. $ sudo apt-get install python-matplotlib -- 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 From bskaplan14 at yahoo.com Tue Apr 15 15:06:32 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Tue, 15 Apr 2008 12:06:32 -0700 (PDT) Subject: Java or C++? Message-ID: <514944.97660.qm@web39205.mail.mud.yahoo.com> The fact that C# is a .NET language is also a major weakness, since you can only use it on Windows. ----- Original Message ---- From: Michael Torrie To: python-list at python.org Sent: Tuesday, April 15, 2008 1:19:31 PM Subject: Re: Java or C++? egbert wrote: > What is the role or position of C# in this context ? > If I remember well, some people have said that C# is an improved > C++ or Java. > e I think C# is in a great position, and might be recommended. C# has the added advantage of being able to very easily work with IronPython. Thus if you want to develop with .NET you can easily wield the beauty of python with C# for speed or library routines. Of course Jython does the same for Java, although it's way behind in development these days. Slick python integration is one area where C# and Java would beat out C++. Sure there's Boost::Python, but the learning curve is kind of steep. Installation, even, is difficult. Python's C API is very simple and C-like, so if one chooses to use primarily a C/Python combination (typically what I do these days), it works well, but not quite as easy as IronPython and C#. Diving into the debate, I personally think all programmers, and especially computer science people, should be proficient in C. You should be able to write thousands of lines of C code, use dynamic memory allocation, data structures, etc, and have very few resource leaks if you choose your tools wisely (glib for C ought to be standard!). This is to give you a background and low-level understanding. However you're not likely to program in C professionally unless you are into systems programming, or are affiliated with core, low-level things like library development, or embedded systems. As for C++ and Java, I've found that good C++ programmers can *easily* move to Java when they want/need to. The reverse is *not typically true*. Java lends itself to too many bad habits that kill would-be C++ programmers, particular in regards to resource management and things like destruction after scope. I think that is a critical thing that people forget sometimes. Similarly people proficient in Unix and Linux computers, both use and development on, can much more easily move to Windows than the other way around. A good programmer should be able to pick up new languages and paradigms fairly easily, and become fluent in just a few weeks. For me it's typically one week, although learning frameworks and toolkits is more difficult (Java frameworks). A good exercise might be to pick up one new language per year and do something major with it (say 4000-10000 loc). Choose a new genre like web programming to explore. Whatever. Next time a little pet project comes up, try a new language or a new toolkit. Try some shell-scripting in scsh using scheme. -- http://mail.python.org/mailman/listinfo/python-list between 0000-00-00 and 9999-99-99 ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From kyosohma at gmail.com Sat Apr 26 23:39:19 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Sat, 26 Apr 2008 20:39:19 -0700 (PDT) Subject: What to download when updating? References: Message-ID: On Apr 26, 4:57?pm, Gilles Ganault wrote: > Hello > > ? ? ? ? Out of curiosity, if I recompile a Python (wxPython) app with > py2exe, can I have customers just download the latest .exe, or are > there dependencies that require downloading the whole thing again? > > FWIW, here's the list of files that were created after running py2exe: > > myprog.exe > bz2.pyd > library.zip > MSVCR71.dll > python25.dll > unicodedata.pyd > w9xpopen.exe > wxbase28uh_net_vc.dll > wxbase28uh_vc.dll > wxmsw28uh_adv_vc.dll > wxmsw28uh_core_vc.dll > wxmsw28uh_html_vc.dll > _controls_.pyd > _core_.pyd > _gdi_.pyd > _misc_.pyd > _windows_.pyd > > Thank you. Gilles, I think you can get away with just the executable. However, there are some options in py2exe that allow you to output one file. I use GUI2Exe, a GUI to py2exe that makes it quite a bit easier to wrap these things: http://xoomer.alice.it/infinity77/main/GUI2Exe.html You just set Optimize and Compressed to 2 and Bundle Files to 1. I also use Inno Setup if I need an installer. Hope that helps! Mike From jon+usenet at unequivocal.co.uk Sat Apr 26 23:27:12 2008 From: jon+usenet at unequivocal.co.uk (Jon Ribbens) Date: Sat, 26 Apr 2008 22:27:12 -0500 Subject: Why can't timedeltas be divided? References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> Message-ID: On 2008-04-27, Martin v. L??wis wrote: >> sorry for bringing up such an old thread, but this seems important to me >> -- up to now, there are thousands [1] of python programs that use >> hardcoded time calculations. > > Would you like to work on a patch? Last time I brought up this sort of thing, it seemed fairly unanimous that the shortcomings of the datetime module were 'deliberate' and would not be fixed, patch or no patch. From fredrik at pythonware.com Sat Apr 5 11:42:00 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 17:42:00 +0200 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> Message-ID: Fredrik Lundh wrote: > and for the record, Python doesn't look for PYD files on any of the Unix > boxes I have convenient access to right now. what Ubuntu version are > you using, what Python version do you have, and what does > > $ python -c "import imp; print imp.get_suffixes()" > > print on your machine? for reference, here's what I get on Ubuntu 7.10, with the standard Python interpreter (2.5.1): $ python -c "import imp; print imp.get_suffixes()" [('.so', 'rb', 3), ('module.so', 'rb', 3), ('.py', 'U', 1), ('.pyc', 'rb', 2)] any Ubuntu gurus here that can sort this one out? From bearophileHUGS at lycos.com Mon Apr 21 05:44:53 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Mon, 21 Apr 2008 02:44:53 -0700 (PDT) Subject: sys.maxint in Python 3 Message-ID: In some algorithms a sentinel value may be useful, so for Python 3.x sys.maxint may be replaced by an improvement of the following infinite and neginfinite singleton objects: class Infinite(object): def __repr__(self): return "infinite" def __cmp__(self, other): if other is infinite: return 0 if other is neginfinite: return 1 other + 1 # type control return 1 infinite = Infinite() class NegInfinite(object): def __repr__(self): return "neginfinite" def __cmp__(self, other): if other is neginfinite: return 0 if other is infinite: return -1 other + 1 # type control return -1 neginfinite = NegInfinite() Bye, bearophile From steve at holdenweb.com Wed Apr 23 10:31:23 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 10:31:23 -0400 Subject: MESSAGE RESPONSE In-Reply-To: <27CC3060AF71DA40A5DC85F7D5B70F38033A4F2D@AWMAIL04.belcan.com> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> <27CC3060AF71DA40A5DC85F7D5B70F38033A4F2D@AWMAIL04.belcan.com> Message-ID: <480F483B.9050507@holdenweb.com> Blubaugh, David A. wrote: > Is there a way to block these messages. I do not want to be caught > with filth such as this material. I could lose my job with Belcan with > evil messages such as these messages. > > > David Blubaugh > In future please ensure you do not quote the offending URLs when sending out such messages. It's quite bad enough that the things appeared on the list once without you doing the originator the favor of repeating them. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From frikker at gmail.com Sun Apr 27 22:31:42 2008 From: frikker at gmail.com (blaine) Date: Sun, 27 Apr 2008 19:31:42 -0700 (PDT) Subject: Regular Expression - Matching Multiples of 3 Characters exactly. References: Message-ID: <5193150b-ef86-4113-8f8d-be7d99a7386f@i76g2000hsf.googlegroups.com> On Apr 27, 10:24 pm, castiro... at gmail.com wrote: > On Apr 27, 8:31 pm, blaine wrote: > > > > > Hey everyone, > > For the regular expression gurus... > > > I'm trying to write a string matching algorithm for genomic > > sequences. I'm pulling out Genes from a large genomic pattern, with > > certain start and stop codons on either side. This is simple > > enough... for example: > > > start = AUG stop=AGG > > BBBBBBAUGWWWWWWAGGBBBBBB > > > So I obviously want to pull out AUGWWWWWWAGG (and all other matches). > > This works great with my current regular expression. > > > The problem, however, is that codons come in sets of 3 bases. So > > there are actually three different 'frames' I could be using. For > > example: > > ABCDEFGHIJ > > I could have ABC DEF GHI or BCD EFG HIJ or CDE FGH IJx.... etc. > > > So finally, my question. How can I represent this in a regular > > expression? :) This is what I'd like to do: > > (Find all groups of any three characters) (Find a start codon) (find > > any other codons) (Find an end codon) > > > Is this possible? It seems that I'd want to do something like this: (\w > > \w\w)+(AUG)(\s)(AGG)(\s)* - where \w\w\w matches EXACTLY all sets of > > three non-whitespace characters, followed by AUG \s AGG, and then > > anything else. I hope I am making sense. Obviously, however, this > > will make sure that ANY set of three characters exist before a start > > codon. Is there a way to match exactly, to say something like 'Find > > all sets of three, then AUG and AGG, etc.'. This way, I could scan > > for genes, remove the first letter, scan for more genes, remove the > > first letter again, and scan for more genes. This would > > hypothetically yield different genes, since the frame would be > > shifted. > > > This might be a lot of information... I appreciate any insight. Thank > > you! > > Blaine > > Here's one idea (untested): > > s= { } > for x in range( len( genes )- 3 ): > s[ x ]= genes[ x: x+ 3 ] > > You might like Python's 'string slicing' feature. True - I could try something like that. In fact I have a 'codon' function that does exactly that. The problem is that I then have to go back through and loop over the list. I'm trying to use Regular Expressions so that my processing is quicker. Complexity is key since this genomic string is pretty large. Thanks for the suggestion though! From bruno.42.desthuilliers at websiteburo.invalid Mon Apr 21 04:26:49 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Mon, 21 Apr 2008 10:26:49 +0200 Subject: question about the mainloop In-Reply-To: <52de38c4-3d1e-4be0-9b58-5d60317f1ef7@b1g2000hsg.googlegroups.com> References: <52de38c4-3d1e-4be0-9b58-5d60317f1ef7@b1g2000hsg.googlegroups.com> Message-ID: <480c4fc9$0$19406$426a74cc@news.free.fr> globalrev a ?crit : > in C?? java etc there is usually: > > procedure 1 > procedure 2 > procedure 3 > > main { > procedure 1 > procedure 2 > procedure 3 > } > > i dont get the mainloop() in python. The 'main' function (resp. method) in C and Java has nothing to do with a "mainloop" - it's just the program entry point, IOW the function that will get called when the program is executed. Python has no such thing, since all code at the top-level is executed when the script is passed to the python runtime. The notion of "mainloop" (or event loop) is specific to event-driven programs, which, once everything is set up, enter in a loop, wait for events to come, and dispatch them to appropriate handlers. And FWIW, there's no loop in your above example - the main() function will call procedures 1, 2 and 3 sequentially then exit. > i mean i have written some > programs, for example a calculator using tkinterGUI. > > if i have some functions i wanna call to run the program You don't "call some functions" to "run the program" - you pass your script to the python runtime, and all top-level code will be executed sequentially. From snake_314 at hotmail.com Sat Apr 5 21:56:24 2008 From: snake_314 at hotmail.com (snake snake) Date: Sun, 6 Apr 2008 04:56:24 +0300 Subject: header intact. Or visitthis web page Message-ID: _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From deets at nospam.web.de Mon Apr 28 17:55:15 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Mon, 28 Apr 2008 23:55:15 +0200 Subject: cytpes **int In-Reply-To: <56674130-c04e-403e-8364-92cbd158b2f0@b9g2000prh.googlegroups.com> References: <56674130-c04e-403e-8364-92cbd158b2f0@b9g2000prh.googlegroups.com> Message-ID: <67mveuF2pauigU1@mid.uni-berlin.de> VernM schrieb: > I am using ctypes to wrap a set of functions in a DLL. It has been > going very well, and I am very impressed with ctypes. I want to call a > c function with a signature of: void func(int **cube), where the array > if ints in cube is modified by func. I want to setup cube with int > values, and access them after the call to func. I unerstand how to > setup the ctypes array, but how do I pass **cube to the function, and > how do I access the results? it should be simple. use something like (untestet): b = POINTER(c_int)() func(byref(b)) Or a = c_int() b = pointer(a) func(byref(b) Or b = POINTER(c_int)() func(pointer(b)) Diez From deets at nospam.web.de Wed Apr 2 12:35:43 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 02 Apr 2008 18:35:43 +0200 Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> Message-ID: <65hqvrF2f2susU1@mid.uni-berlin.de> > I'm not quite sure I understood your question, sorry. And you won't. He's one of the resident trolls... Better killfile him ASAP :) Diez From altami0762 at gmail.com Thu Apr 17 15:52:48 2008 From: altami0762 at gmail.com (altami0762 at gmail.com) Date: Thu, 17 Apr 2008 12:52:48 -0700 (PDT) Subject: jazz scale suggester system 3.0 crack Message-ID: jazz scale suggester system 3.0 crack http://cracks.12w.net F R E E C R A C K S From michael at stroeder.com Thu Apr 24 05:51:08 2008 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Thu, 24 Apr 2008 11:51:08 +0200 Subject: python-ldap: searching without specifying an OU? In-Reply-To: <0bbac44a-5d11-4e27-829d-ad2b2de62210@x35g2000hsb.googlegroups.com> References: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> <58546d42-bc80-4f9d-be90-e184c312e2d1@k37g2000hsf.googlegroups.com> <0ke3e5-ccc.ln1@nb2.stroeder.com> <8ef38281-a6fe-4501-b711-a24cd9f35a24@t54g2000hsg.googlegroups.com> <0bbac44a-5d11-4e27-829d-ad2b2de62210@x35g2000hsb.googlegroups.com> Message-ID: hotani wrote: > http://peeved.org/blog/2007/11/20/ BTW: This blog entry claims that LDAP_SERVER_DOMAIN_SCOPE_OID control cannot be used with python-ldap. But support for such simple LDAPv3 extended controls was added to python-ldap way back in 2005. Actually it's easy (relevant code excerpt): ---------------------------------------------------------------- import ldap from ldap.controls import BooleanControl LDAP_SERVER_DOMAIN_SCOPE_OID='1.2.840.113556.1.4.1339' [..] l = ldap.initialize(ldap_uri,trace_level=trace_level) # Switch off chasing referrals within OpenLDAP's libldap l.set_option(ldap.OPT_REFERRALS, 0) # Simple bind with user's DN and password l.simple_bind_s(dn,password) res = l.search_ext_s( 'DC=dom,DC=example,DC=com', ldap.SCOPE_ONELEVEL, '(objectClass=subentry)', ['*'], serverctrls = [ BooleanControl( LDAP_SERVER_DOMAIN_SCOPE_OID, criticality=0,controlValue=1 ) ] ) ---------------------------------------------------------------- Strange enough it has no effect. And setting criticality=1 raises an error indicating that this control is not supported although this control is explicitly mentioned in attribute 'supportedControl' of the server's rootDSE: ldap.UNAVAILABLE_CRITICAL_EXTENSION: {'info': '00000057: LdapErr: DSID-0C09068F, comment: Error processing control, data 0, vece', 'desc': 'Critical extension is unavailable'} Might depend on the domain functional level AD is running with... Ciao, Michael. From steve at holdenweb.com Wed Apr 23 00:57:25 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 00:57:25 -0400 Subject: Python Success stories In-Reply-To: <87fxtdyydy.fsf@benfinney.id.au> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <87fxtdyydy.fsf@benfinney.id.au> Message-ID: Ben Finney wrote: > Steve Holden writes: > >> Challenge him to a dual with dead kippers at twenty paces. > > Please, have some dignity! > > Challenge him to a duel with live kippers. Live, *rabid* kippers. With > frickin' laser beams on their heads. > I like your style. Though considering what it takes to kipper a herring, I'd be very surprised if there *was* any such thing as a live kipper. With or without laser beam. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From kyosohma at gmail.com Fri Apr 18 14:34:02 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 18 Apr 2008 11:34:02 -0700 (PDT) Subject: Python 2.5 adoption References: Message-ID: <0e05ad56-9521-4ac6-8849-edc44e4d6c9a@24g2000hsh.googlegroups.com> On Apr 18, 1:08 pm, Joseph Turian wrote: > How widely adopted is python 2.5? > > We are doing some development, and have a choice to make: > a) Use all the 2.5 features we want. > b) Maintain backwards compatability with 2.4. > > So I guess the question is, does anyone have a sense of what percent > of python users don't have 2.5? > > Thanks, > Joseph I think it depends more on what you want to do. If you're distributing the software, you can just "freeze" it and make binaries and then it doesn't matter. Or if you use Python at your business, you can do what we do at my workplace: Put Python on the network and run all the scripts from there. Currently, we have 2.4 on our network, but I think we can upgrade it to 2.5 without breaking anything. I develop in 2.5 and just put the finished products on our network and they usually "just work". But I have yet to find good use cases for some of the cool whizz-bang extras of 2.5, so I haven't pushed for the network upgrade. I hope to figure out when, where and how to use generators and decorators at some point, but I just haven't gotten that far a long yet, I guess. Mike From george.sakkis at gmail.com Mon Apr 21 19:10:05 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Mon, 21 Apr 2008 16:10:05 -0700 (PDT) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> Message-ID: <85c14b14-9302-41bb-9270-b7cdd65098b0@c65g2000hsa.googlegroups.com> On Apr 21, 5:30 pm, Ivan Illarionov wrote: > On 22 ???, 01:01, Peter Otten <__pete... at web.de> wrote: > > > Ivan Illarionov wrote: > > > And even faster: > > > a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, > > > len(s), 3)))) > > > if sys.byteorder == 'little': > > > a.byteswap() > > > > I think it's a fastest possible implementation in pure python > > > Clever, but note that it doesn't work correctly for negative numbers. For > > those you'd have to prepend "\xff" instead of "\0". > > > Peter > > Thanks for correction. > > Another step is needed: > > a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, > len(s), 3)))) > if sys.byteorder == 'little': > a.byteswap() > result = [n if n < 0x800000 else n - 0x1000000 for n in a] > > And it's still pretty fast :) Indeed, the array idea is paying off for largeish inputs. On my box (Python 2.5, WinXP, 2GHz Intel Core Duo), the cutoff point where from3Bytes_array becomes faster than from3Bytes_struct is close to 150 numbers (=450 bytes). The struct solution though is now almost twice as fast with Psyco enabled, while the array doesn't benefit from it. Here are some numbers from a sample run: *** Without Psyco *** size=1 from3Bytes_ord: 0.033493 from3Bytes_struct: 0.018420 from3Bytes_array: 0.089735 size=10 from3Bytes_ord: 0.140470 from3Bytes_struct: 0.082326 from3Bytes_array: 0.142459 size=100 from3Bytes_ord: 1.180831 from3Bytes_struct: 0.664799 from3Bytes_array: 0.690315 size=1000 from3Bytes_ord: 11.551990 from3Bytes_struct: 6.390999 from3Bytes_array: 5.781636 *** With Psyco *** size=1 from3Bytes_ord: 0.039287 from3Bytes_struct: 0.009453 from3Bytes_array: 0.098512 size=10 from3Bytes_ord: 0.174362 from3Bytes_struct: 0.045785 from3Bytes_array: 0.162171 size=100 from3Bytes_ord: 1.437203 from3Bytes_struct: 0.355930 from3Bytes_array: 0.800527 size=1000 from3Bytes_ord: 14.248668 from3Bytes_struct: 3.331309 from3Bytes_array: 6.946709 And here's the benchmark script: import struct from array import array def from3Bytes_ord(s): return [n if n<0x800000 else n-0x1000000 for n in ((ord(s[i])<<16) | (ord(s[i+1])<<8) | ord(s[i+2]) for i in xrange(0, len(s), 3))] unpack_i32be = struct.Struct('>l').unpack def from3Bytes_struct(s): return [unpack_i32be(s[i:i+3] + '\0')[0]>>8 for i in xrange(0,len(s),3)] def from3Bytes_array(s): a = array('l', ''.join('\0' + s[i:i+3] for i in xrange(0,len(s), 3))) a.byteswap() return [n if n<0x800000 else n-0x1000000 for n in a] def benchmark(): from timeit import Timer for n in 1,10,100,1000: print ' size=%d' % n # cycle between positive and negative buf = ''.join(struct.pack('>i', 1234567*(-1)**(i%2))[1:] for i in xrange(n)) for func in 'from3Bytes_ord', 'from3Bytes_struct', 'from3Bytes_array': print ' %s: %f' % (func, Timer('%s(buf)' % func , 'from __main__ import %s; buf=%r' % (func,buf) ).timeit(10000)) if __name__ == '__main__': s = ''.join(struct.pack('>i',v)[1:] for v in [0,1,-2,500,-500,7777,-7777,-94496,98765, -98765,8388607,-8388607,-8388608,1234567]) assert from3Bytes_ord(s) == from3Bytes_struct(s) == from3Bytes_array(s) print '*** Without Psyco ***' benchmark() import psyco; psyco.full() print '*** With Psyco ***' benchmark() George From dennis.benzinger at gmx.net Thu Apr 10 10:56:57 2008 From: dennis.benzinger at gmx.net (Dennis.Benzinger@gmx.net) Date: Thu, 10 Apr 2008 07:56:57 -0700 (PDT) Subject: tkinter, overwrite Label-text? References: Message-ID: On Apr 10, 4:37 pm, skanem... at yahoo.se wrote: > [...] > i know how to do this already. the problem is i want the text to stay > in the windowa nd not start overwriting "Answer:". > i have solved this by using an Entry for the answer as well but id > prefer using a Label. > [...] You can set the width option of the Label. For example: b = Label(mygui, text=eval(expr), width=20) Then the Label will always be 20 characters wide no matter how long the answer is. You can read more about the options for Tk widgets in . Dennis Benzinger From lbonafide at yahoo.com Tue Apr 1 23:59:44 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Tue, 1 Apr 2008 20:59:44 -0700 (PDT) Subject: the scaling of pics in pygame References: <49d8b8ae-08e3-4e86-9ced-2804b6dec4e5@b5g2000pri.googlegroups.com> Message-ID: <3de70275-c4d6-46f8-9700-17503a606c84@d62g2000hsf.googlegroups.com> On Apr 1, 9:44 pm, Jimmy wrote: > Hi, everyone > > I am using Pygame to write a small program. I tried to load a .jpg > picture into > the screen, however, the size of the pic doesn't fit into the window > properly. Can > anyone tell me how to scale the picture into the window? You might get a quicker answer at pygame.org - check the mailing list and/or docs. From nagle at animats.com Tue Apr 1 13:48:52 2008 From: nagle at animats.com (John Nagle) Date: Tue, 01 Apr 2008 10:48:52 -0700 Subject: Homework help In-Reply-To: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> Message-ID: <47f2730b$0$36409$742ec2ed@news.sonic.net> bobby.connor at gmail.com wrote: > Hey guys > I haev this homework assignment due today > I don't necessarily want the answers, but need help on how to approach > it/the steps i need to solve the problems > Thanks > > # (2 Points) Write a python function howMany(item,lst) which accepts > an item and a lst of items and returns the number of times item occurs > in lst. For example, howMany(3,[1,2,3,2,3]) should return 2. def howmany(item, lst) : return(len(filter(lambda x: x==item, lst))) > > # (2 Points) Write a python function upTo(n) which accepts a non- > negative number n and returns a list of numbers from 0 to n. For > example, upTo(3) should return the list [0, 1, 2, 3]. def howmany(n) : return(range(n+1)) That should get you started. John Nagle From s0suk3 at gmail.com Thu Apr 17 11:40:41 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 08:40:41 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> Message-ID: > Yuck! No way!! If you *want* to make your code that hard to read, I'm > sure you can find lots of ways to do so, even in Python, but don't > expect Python to change to help you toward such a dubious goal. > Well, my actual code doesn't look like that. Trust me, I like clean code. > Seriously, examine your motivations for wanting such a syntax. Does it > make the code more readable? (Absolutely not.) Does it make it more > maintainable. (Certainly not -- consider it you needed to change > CONSTANT2 to a different value some time in the future.) Yes, it makes it more readable. And yes, it does make it (a lot) more maintainable. Mainly because I don't have those four variables, I have about thirty. And I think I won't need to one or two of them, but maybe all of them at once. From Simon.Strobl at gmail.com Wed Apr 23 08:33:15 2008 From: Simon.Strobl at gmail.com (Simon Strobl) Date: Wed, 23 Apr 2008 05:33:15 -0700 (PDT) Subject: problem with dictionaries References: Message-ID: <2d4ce8cf-f5d6-4fed-8275-693a22cb6a0e@k37g2000hsf.googlegroups.com> > You musts have missed the memo. The rules of the universe > changed at 0834 UST yesterday, and all functioning Python programs > stopped working. As always, the rules of the universe have not changed. (Or, at least, I do hope so.) It seems that the cause of my problem was my switching too fast between too many and too seldom saved emacs buffers. Thanks to all for your hints. Simon From collinw at gmail.com Fri Apr 25 19:52:23 2008 From: collinw at gmail.com (Collin Winter) Date: Fri, 25 Apr 2008 16:52:23 -0700 Subject: [Python-Dev] annoying dictionary problem, non-existing keys In-Reply-To: <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> Message-ID: <43aa6ff70804251652r4f0deb39he5b2e1c71e8aabee@mail.gmail.com> 2008/4/24 bvidinli : > I posted to so many lists because, > > this issue is related to all lists, > this is an idea for python, > this is related to development of python... > > why are you so much defensive ? > > i think ideas all important for development of python, software.... > i am sory anyway.... hope will be helpful. Please consult the documentation first: http://docs.python.org/lib/typesmapping.html . You're looking for the get() method. This attribute of PHP is hardly considered a feature, and is not something Python wishes to emulate. Collin Winter > 2008/4/24, Terry Reedy : > > > > Python-dev is for discussion of development of future Python. Use > > python-list / comp.lang.python / gmane.comp.python.general for usage > > questions. > > > > > > > > _______________________________________________ > > Python-Dev mailing list > > Python-Dev at python.org > > http://mail.python.org/mailman/listinfo/python-dev > > Unsubscribe: http://mail.python.org/mailman/options/python-dev/bvidinli%40gmail.com > > > > > > -- > ?.Bahattin Vidinli > Elk-Elektronik M?h. > ------------------- > iletisim bilgileri (Tercih sirasina gore): > skype: bvidinli (sesli gorusme icin, www.skype.com) > msn: bvidinli at iyibirisi.com > yahoo: bvidinli > > +90.532.7990607 > +90.505.5667711 > _______________________________________________ > > > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: http://mail.python.org/mailman/options/python-dev/collinw%40gmail.com > From steve at holdenweb.com Tue Apr 8 20:57:47 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 20:57:47 -0400 Subject: new user needs help! In-Reply-To: <10644597.63801207701350348.JavaMail.nabble@isper.nabble.com> References: <10644597.63801207701350348.JavaMail.nabble@isper.nabble.com> Message-ID: <47FC148B.1010605@holdenweb.com> drjekil77 at gmail.com wrote: > thanks! Please keep all replies on the list: somebody else may also wish to help (and they will also pick up mistakes I make ;-) > I am working with a text filelooks like this: > #NAME AA TOPO ACCESS DSSP STRIDE Z-COORD > 1lghB A i 79.8 H H -24.58 > 1lghB V i 79.6 H H -22.06 > 1lghB H i 71.9 H H -19.94 > i need to compare those lines which has a value between 10 to 22 and presents in the following way > True/false A C D E F G H I K L M N P Q R S T V X Y W(here alfabets represents amino acids) > 1 1:1 2:0 3:0 and so on for rest of the amino acids. > > > I have given 2 examples below to make it clear a bit: > > ex.1: > #NAME AA TOPO ACCESS DSSP STRIDE Z-COORD > 1lghB A i 79.8 H H -24.58 #for that line amino acid is A and z-COORED value is more than 22,so output should be look like > > True/false A C D E F G H I K L M N P Q R S T V X Y W(here alfabets represents amino acids) > -1 1:1 2:0 3:o 4:0 so on upto 20 bcz there r 20 amino acids.and A presents in the 1st position.every line represents one amino acid with value,so output will show in which position is it(here A is in 1st position thats why its value 1:1 and all the other position o like 2:0,3:0,4:0 and if its Z-COORED value between 10-22 then true false value 1,otherwise -1. > > another ex: > > 1lghB H i 71.9 H H -19.94 # for that line amino acid is H and it has value between 10-22.so output should looks like: > > True/false A C D E F G H I K L M N P Q R S T V X Y W(here alfabets represents 20 amino acids) > > 1 1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0,every position is zero up to 20 bcz H presents in the 7th position.so it will be 1. > > so for every line, output will in 21 coulum,1st coulum for true false value,others r for 20 amino acids.true false value will be either 1 or -1,and within other 20 coulum one value will be n:1,others will be n:0.n=0,1,2,3..20. > its a bit tricky. > thank u so much for ur help > waiting for ur opinion. > So, you are using -1 for true and 1 for false? Can there be multiple amino acids on each line? Would this be a possible input: 1lghB AHG i 87.3 Q Q -23.45 If so, would this be the required output? -1 1:1 2:0 3:0 4:0 5:0 6:0 7:1 8:1 9:0 10:0 ... 19:0 20:0 There is no point trying to write more code until we understand the requirements properly. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From glasper9 at yahoo.org.au Sat Apr 12 17:06:30 2008 From: glasper9 at yahoo.org.au (Jason Stokes) Date: Sun, 13 Apr 2008 07:06:30 +1000 Subject: basic python question about for loop References: Message-ID: <1208034394.286218@chilli.pcug.org.au> "jmDesktop" wrote in message news:a6017454-6ac8-44e1-bc56-49709720a666 at e39g2000hsf.googlegroups.com... > So what is n and x in the first iteration? Sorry. I'm trying. Remember how Python's range operator works. range(n, x) constructs a list that consists of all elements starting with n and up to, but /not including/, x. For example, range(3, 7) constructs the list [3, 4, 5, 6]. So what happens if you try to construct the list range(2, 2)? In this case, Python will construct an empty list -- this is its interpretation of "up to, but not including n" for an argument like range(n, n). This is precisely what is happening in the first iteration of the first enclosing for loop. Trace through the code; see that 2 is bound to n in the first iteration; see that the inner loop then tries to construct the list range(2, n), which is range(2, 2), which is an empty list. And a "for x in []" statement will not execute even once. As it happens, your loop is perfectly correct. You are testing for divisors for a number excluding 1 and the number itself. For the number 2, the number of possible divisors satisfying this condition is an empty set. So 2 is, quite correctly, adjudged to be prime. From floris.bruynooghe at gmail.com Fri Apr 11 06:19:22 2008 From: floris.bruynooghe at gmail.com (Floris Bruynooghe) Date: Fri, 11 Apr 2008 03:19:22 -0700 (PDT) Subject: @x.setter property implementation References: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> <02cb2845-6a25-4e90-9f82-dbd68b37a5e6@p39g2000prm.googlegroups.com> <2c589c82-85e9-4db6-b8f9-156b06dd51f3@s33g2000pri.googlegroups.com> Message-ID: <3238aeb7-cd1b-463d-ad87-0d28dcee0202@a1g2000hsb.googlegroups.com> On Apr 11, 10:16 am, Floris Bruynooghe wrote: > On Apr 10, 5:09 pm, Arnaud Delobelle wrote: > > > > > On Apr 10, 3:37 pm, Floris Bruynooghe > > wrote: > > > > On Apr 7, 2:19 pm, "Andrii V. Mishkovskyi" wrote: > > > > > 2008/4/7, Floris Bruynooghe : > > > > > > Have been grepping all over the place and failed to find it. I found > > > > > the test module for them, but that doesn't get me very far... > > > > > I think you should take a look at 'descrobject.c' file in 'Objects' directory. > > > > Thanks, I found it! So after some looking around here was my > > > implementation: > > > > class myproperty(property): > > > def setter(self, func): > > > self.fset = func > > > > But that doesn't work since fset is a read only attribute (and all of > > > this is implemented in C). > > > > So I've settled with the (nearly) original proposal from Guido on > > > python-dev: > > > > def propset(prop): > > > assert isinstance(prop, property) > > > @functools.wraps > > > def helper(func): > > > return property(prop.fget, func, prop.fdel, prop.__doc__) > > > return helper > > > > The downside of this is that upgrade from 2.5 to 2.6 will require code > > > changes, I was trying to minimise those to just removing an import > > > statement. > > > > Regards > > > Floris > > > Here's an implementation of prop.setter in pure python < 2.6, but > > using sys._getframe, and the only test performed is the one below :) > > > import sys > > > def find_key(mapping, searchval): > > for key, val in mapping.iteritems(): > > if val == searchval: > > return key > > > _property = property > > > class property(property): > > def setter(self, fset): > > cls_ns = sys._getframe(1).f_locals > > propname = find_key(cls_ns, self) > > # if not propname: there's a problem! > > cls_ns[propname] = property(self.fget, fset, > > self.fdel, self.__doc__) > > return fset > > # getter and deleter can be defined the same way! > > > # -------- Example ------- > > > class Foo(object): > > @property > > def bar(self): > > return self._bar > > @bar.setter > > def setbar(self, x): > > self._bar = '<%s>' % x > > > # -------- Interactive test ----- > > > >>> foo = Foo() > > >>> foo.bar = 3 > > >>> foo.bar > > '<3>' > > >>> foo.bar = 'oeufs' > > >>> foo.bar > > '' > > > Having fun'ly yours, > > Neat! > > Unfortunatly both this one and the one I posted before work when I try > them out on the commandline but both fail when I try to use them in a > module. And I just can't figure out why. This in more detail: Imaging mod.py: import sys _property = property class property(property): """Python 2.6/3.0 style property""" def setter(self, fset): cls_ns = sys._getframe(1).f_locals for k, v in cls_ns.iteritems(): if v == self: propname = k break cls_ns[propname] = property(self.fget, fset, self.fdel, self.__doc__) return fset class Foo(object): @property def x(self): return self._x @x.setter def x(self, v): self._x = v + 1 Now enter the interpreter: >>> import mod >>> f = mod.Foo() >>> f.x = 4 >>> f.x 4 I don't feel like giving up on this now, so close... From markjreed at gmail.com Wed Apr 23 16:31:17 2008 From: markjreed at gmail.com (Mark Reed) Date: Wed, 23 Apr 2008 13:31:17 -0700 (PDT) Subject: Pythonically extract data from a list of tuples (getopt) Message-ID: So the return value from getopt.getopt() is a list of tuples, e.g. >>> import getopt >>> opts = getopt.getopt('-a 1 -b 2 -a 3'.split(), 'a:b:')[0]; opts [('-a', '1'), ('-b', '2'), ('-a', '3')] what's the idiomatic way of using this result? I can think of several possibilities. For options not allowed to occur more than once, you can turn it into a dictionary: >>> b = dict(opts)['-b']; b '2' Otherwise, you can use a list comprehension: >>> a = [arg for opt, arg in opts if opt == '-a']; a ['1', '3'] Maybe the usual idiom is to iterate through the list rather than using it in situ... >>> a = [] >>> b = None >>> for opt, arg in opts: ... if opt == '-a': ... a.append(arg) ... elif opt == '-b': ... b = arg ... else: ... raise ValueError("Unrecognized option %s" % opt) Any of the foregoing constitute The One Way To Do It? Any simpler, legible shortcuts? Thanks. From peter at sd-editions.com Sat Apr 12 01:45:25 2008 From: peter at sd-editions.com (Peter Robinson) Date: Sat, 12 Apr 2008 06:45:25 +0100 Subject: accessing individual characters in unicode strings Message-ID: Dear list I am at my wits end on what seemed a very simple task: I have some greek text, nicely encoded in utf8, going in and out of a xml database, being passed over and beautifully displayed on the web. For example: the most common greek word of all 'kai' (or ??? if your mailer can see utf8) So all I want to do is: step through this string a character at a time, and do something for each character (actually set a width attribute somewhere else for each character) Should be simple, yes? turns out to be near impossible. I tried using a simple index character routine such as ustr[0]..ustr[1]... and this gives rubbish. So I use len() to find out how long my simple greek string is, and of course it is NOT three characters long. A day of intensive searching around the lists tells me that unicode and python is a moving target: so many fixes are suggested for similar problems, none apparently working with mine. Here is the best I can do, so far I convert the utf8 string using ustr = repr(unicode(thisword, 'iso-8859-7')) for kai this gives the following: u'\u039e\u038a\u039e\xb1\u039e\u0389' so now things should be simple, yes? just go through this and identify each character... Not so simple at all. k, kappa: turns out to be TWO \u strings, not one: thus \u039e\u038a similarly, iota is also two \u strings: \u039e\u0389 alpha is a \u string followed by a \x string: \u039e\xb1 looking elsewhere in the record, my particular favourite is the midpoint character: this comes out as \u03b1\x90\xa7 ! and in the middle of all this, there are some non-unicode characters: \u039e\u038fc is o followed by c! well, I don't have many characters to deal this and I could cope with this mess by tedious matching character by character. But surely, there is a better way... help please Peter Robinson: peter at sd-editions.com From zethex at hotmail.com Sun Apr 27 14:19:37 2008 From: zethex at hotmail.com (Zethex) Date: Sun, 27 Apr 2008 11:19:37 -0700 (PDT) Subject: Mapping and Filtering Help for Lists In-Reply-To: <16925836.post@talk.nabble.com> References: <16925836.post@talk.nabble.com> Message-ID: <16926758.post@talk.nabble.com> Thank you for the help so far. Another quick question, how can I remove the special characters such as ! and ?. I also need to lowercase the words so should i use sentence = sentence.lower() ? Thank you -- View this message in context: http://www.nabble.com/Mapping-and-Filtering-Help-for-Lists-tp16925836p16926758.html Sent from the Python - python-list mailing list archive at Nabble.com. From rickbking at comcast.net Wed Apr 9 12:16:28 2008 From: rickbking at comcast.net (Rick King) Date: Wed, 09 Apr 2008 12:16:28 -0400 Subject: Stani's python ide 'spe' editor problem Message-ID: <47FCEBDC.80906@comcast.net> Hi everyone, The editor in spe on my system (win XP home sp2) does not do automatic indentation..... I can't figure out why - it used to. I'm set up with subversion so I have the very latest stuff from Stani. It's amazing how not having automatic indentation can make working in the ide such a pain. This has been going on for a while (like a few years), and the situation is deteriorating - used to be that the indentation would work for a while after restarting my system and then stop (until the next restart). Now, with his latest stuff, it doesn't work at all. Because it used to reset with a restart, it must have something to do with a dll, like the scintilla editor dll? But that's kind of hard to believe: why would the editor dll care about indentation? Anyway, I am extremely frustrated. I've tried other ide's: pythonwin (I found it inadequate for my purposes - why is a command line prompt displayed in a dialog window?) - eclipse (editor is just ok, shell does not have command history(!), and then *really* funky things started happening that I could not explain and so had to stop using it) - idle is good for small things and ok for larger projects but limited in general. I really like spe and want to continue using it. Stani himself seems pretty unreachable. Does anyone have a clue for me about what the issue is? Is no one else using this great ide? Or is no one else having this problem? Thanks for any help. -Rick King Southfield MI From arnodel at googlemail.com Mon Apr 28 14:42:50 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Mon, 28 Apr 2008 19:42:50 +0100 Subject: How to unget a line when reading from a file/stream iterator/generator? References: Message-ID: python at bdurham.com writes: > Is there an elegant way to unget a line when reading from a file/stream > iterator/generator? > > By "unget" I mean a way to push back a line into the source stream and > backtrack the iterator/generator one step? > > The only alternative I can see is to put my line reading in a while-True > loop (vs. a for-loop) that manually calls my file/stream > iterator/generator's .next() method while manually handling the > StopIteration exception. Doesn't sound too elegant. > > Is there a Pythonic design pattern/best practice that I can apply here? It seems to me that the answer depends on what you do with your unget'ed line (i.e. there is no included general purpose 'unget' replacement). If you provided some (pseudo-)code, someone might be able to find an elegant way to perform the task without the need to push back an element into an iterator. As a last resort, you could always wrap your iterator into a some 'Backtrackable' class. class Backtrackable(object): def __init__(self, iterator): self.iterator = iter(iterator) self._back = False self._last = None def __iter__(self): return self def next(self): if self._back: next = self._last else: self._last = next = self.iterator.next() self._back = False return next def back(self): if self._back: raise('Cannot backtrack twice') self._back = True >>> b = Backtrackable([1,2,3]) >>> b.next() 1 >>> b.next() 2 >>> b.back() >>> b.next() 2 >>> b.next() 3 From Lie.1296 at gmail.com Sun Apr 20 15:25:33 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 20 Apr 2008 12:25:33 -0700 (PDT) Subject: python setup.py install on Vista? References: <480B5A42.1050407@v.loewis.de> Message-ID: <10dddf35-34fd-4967-a191-88418553b5b4@y18g2000pre.googlegroups.com> On Apr 20, 9:59 pm, "Martin v. L?wis" wrote: > > It seems that quite a lot of people wondered why python doesn't set > > the environment variable to Python Path in the default installation. > > For several reasons, one being that it's not needed. Just run setup.py > as a program, i.e. don't do > > python setup.py install > > but instead do > > setup.py install > > Regards, > Martin who said it isn't needed: 1. I primarily set the EnvPath to invoke the interpreter in interactive mode, without being intervened by IDLE ('cause IDLE is extremely slow if you do a lot of print statements, most of the time you won't notice it but if we do multitude of prints it might hang for a second or two at every statement). 2. To avoid confusion with the rest of the world that uses python by calling "python" in a shell-like interface (i.e. cmd). 3. Linux-people sometimes doesn't believe that there are Windows- people that actually likes CLI, sometimes more than GUI. 4. Being such a great IDE, IDLE sometimes do odds and ends that it sometimes DoS-ed me, having a quick, alternative way to be in touch with python is a good thing, especially if you're being chased by a deadline and moving focus away from the job to repair the tool is not an option. From tjreedy at udel.edu Mon Apr 7 13:13:30 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 7 Apr 2008 13:13:30 -0400 Subject: Dependency Queue References: <0309251d-fba9-447c-9b17-f512988103ea@e39g2000hsf.googlegroups.com> Message-ID: "Carl Banks" wrote in message news:0309251d-fba9-447c-9b17-f512988103ea at e39g2000hsf.googlegroups.com... | I'm looking for any information about a certain kind of dynamic data | structure. Not knowing if it has some well-known name that I could | have Googled, I'll just call it a dependency queue. It's like a | priority queue except instead of a strict ordering of items by | priority, there is only a topological ordering (like you would have in | a directed acyclic graph). | | To date I've been generating a dependency graph in advance every | iteration through my main loop, doing a topsort, and executing the | values in order (the values are callable objects--this is a | scheduler). | | However, I'd like a dynamic dependency queue for two reasons: it would | simplify things to not have to generate the whole graph in advance, | and it could improve performance to run some tasks of the next | iteration in the present one (this could potentially make better use | of the dual-core and graphics hardware). | | I'm pretty sure I could hack out this structure on my own, but I'd | like to see any prior information if there is any, in case anyone's | figured out things like, Is there an easy way to detect cycles on | insertion? and so on. Perhaps what you want is a dynamic DAG (directed acyclic graph) with ordered labels. At any time, only the set of sources are eligible for execution, so there is no reason to flatten the whole thing. I suspect insertion with cycle detection would be easier, but I don't remember actually seeing an algorithm. tjr From deets at nospam.web.de Thu Apr 24 12:50:44 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 24 Apr 2008 18:50:44 +0200 Subject: MESSAGE RESPONSE In-Reply-To: References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com><27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com><678v5qF2me5rvU1@mid.uni-berlin.de> <5504f9ac0804230927ncfdb91buf7fa3e181f8a9237@mail.gmail.com> Message-ID: <67bs3rF2najntU2@mid.uni-berlin.de> Blubaugh, David A. schrieb: > Dear Sir, > > Belcan has an absolute zero-tolerance policy toward material such as the material described. That pairs up nicely with them having zero knowledge about the internet. Diez From wizzardx at gmail.com Sun Apr 27 11:10:49 2008 From: wizzardx at gmail.com (David) Date: Sun, 27 Apr 2008 17:10:49 +0200 Subject: design choice: multi-threaded / asynchronous wxpython client? In-Reply-To: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: <18c1e6480804270810ka59d326tb3ce21a41a6c9db0@mail.gmail.com> > > 1) The data for the race about to start updates every (say) 15 > seconds, and the data for earlier and later races updates only every > (say) 5 minutes. There is no point for me to be hammering the server > with requests every 15 seconds for data for races after the upcoming Try using an HTTP HEAD instruction instead to check if the data has changed since last time. From stef.mientki at gmail.com Thu Apr 3 13:17:00 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Thu, 03 Apr 2008 19:17:00 +0200 Subject: Python in High School In-Reply-To: <873a5fc2-0bd8-4f93-9c8c-56cda6e0090a@s37g2000prg.googlegroups.com> References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> <58deb8b8-bae9-4d43-b973-3d90846726cb@b5g2000pri.googlegroups.com> <873a5fc2-0bd8-4f93-9c8c-56cda6e0090a@s37g2000prg.googlegroups.com> Message-ID: <47F5110C.8010102@gmail.com> >> Well I doubt it's the visual environment that makes it more easy, >> color, shape and position can give some extra information though. >> I think apriori domain knowledge and flattness of information are of far >> more importance. >> The first issue is covered quit well by Robolab / Labview, >> but the second issue certainly is not. >> I'm right now working on a Labview like editor in Python, >> which does obey the demand for flatness of information. >> The first results can be seen here:http://oase.uci.kun.nl/~mientki/data_www/pylab_works/pw_animations_sc... >> >> >> cheers, >> Stef Mientki >> >> >>> And you are going to teach them Java? Oh, please don't. Let the >>> colleges torture them. :=) >>> > > What do you mean by flatness of information? > > What I mean is something like; all the information at a certain abstraction level is visible on one screen or one piece of paper, and not is available through multiple screen / multiple right-clicks etc. A wizard in general is an example of strong non-flatness of information (try adding a mail-account in Thunderbird, this could easily be put on 1 page, which clearly would give a much better overview). cheers, Stef From zedshaw at zedshaw.com Tue Apr 1 17:34:05 2008 From: zedshaw at zedshaw.com (Zed A. Shaw) Date: Tue, 1 Apr 2008 17:34:05 -0400 Subject: [ANN] Vellum 0.7: Simple Python Can Build Many Things Message-ID: <20080401173405.d7631510.zedshaw@zedshaw.com> Hi All, This is another announce for my fun little make,Rake,Scons alternative named Vellum. The goal of Vellum is to create a complete build system in the least amount of clean Python as possible, while keeping the build mechanism safe from code injection (if you need that). == STATUS I went a little nuts today and did three releases adding tons of features but very little code. It currently can be used to build most anything, but there's little documentation. I'm using to build about 6 projects of mine and it's great stuff. The big changes from today is that, if you hate YAML, then you don't have to use it at all. Period. It's all python syntax all the time with none of the >>>,<--,-->,<<< characters. This seems to make people smile. You can download 0.7 from here: https://launchpad.net/vellum/0.0/0.7 Which will also be the main project distribution page for everyone. You can get the source from there via bzr or you can go to: http://www.zedshaw.com/projects/vellum == WHAT'S IN VELLUM 0.7? This release features complete Python integration that's on equal footing with the YAML support. You don't even need to install YAML to use Vellum with just Python only builds. It also adds a bit of Pythonic syntactic sugar for the build files so that people don't freak about the "weird" syntax used in the YAML files. Now you can write this for a target: from vellum.python import * targets = {"sample": [sh("echo i did something")]} Or any combination of sh(), log(), py(), given(), and target() to describe a target. == BUILD SAFETY One problem with using Python to describe a build is that it is an executable, which means that bad things can be put in the build. That's fine if it's your build, since you should be careful. But, if you get the build from someone else you'd want to analyze the build and load it without causing anything to happen. The YAML syntax lets you do this, but the Python does not. Therefore, for the security minded there's a new option -Y that only allows YAML loading so you can restrict your builds to only trust YAML. I'll be adding more features for the build safety that will hopefully let people use Vellum to safely (or reasonably safely) build other people's stuff without getting hurt (or at least get yelled at a lot). == TINY CODE So far Vellum is pushing around 300 lines of Python. That is just awesome. Anyone interested in helping feel free to branch the bzr and register it with Launchpad. Email me when you got stuff I might be interested in and I'll pull from you, or send me patches. Suggested features that don't involve major changes are more than welcome. == NEXT FEATURES * A few recipes to make building common stuff easy, like generating setup.py and so on. * A way to load modules from trusted locations. * Documentation, built with Vellum and Idiopidae. Fun. And that should be it. -- Zed A. Shaw - Hate: http://savingtheinternetwithhate.com/ - Good: http://www.zedshaw.com/ - Evil: http://yearofevil.com/ From andrei.avk at gmail.com Thu Apr 3 18:10:51 2008 From: andrei.avk at gmail.com (AK) Date: Thu, 03 Apr 2008 17:10:51 -0500 Subject: Python-by-example - new online guide to Python Standard Library In-Reply-To: <47f514c5$0$6520$4c368faf@roadrunner.com> References: <47f2d018$0$6517$4c368faf@roadrunner.com> <47f514c5$0$6520$4c368faf@roadrunner.com> Message-ID: <47f547e0$0$12560$4c368faf@roadrunner.com> AK wrote: > > I uploaded an updated site incorporating most of the suggestions I > received and fixing some errors along the way. I will be adding more > examples to modules that are already covered and will try to add more > modules during the following week. Thanks again to all who posted advice > and comments! > I also mapped the site to a subdomain so that it's easier to access quickly: http://pbe.lightbird.net/ where 'pbe' stands for 'Python-by-Example'. -- -ak Tobu | http://tobu.lightbird.net/ | Freeform DB / Tagger / PIM Python-by-Example | http://pbe.lightbird.net/ | Guide to LibRef From mblume at freesurf.ch Wed Apr 23 14:01:39 2008 From: mblume at freesurf.ch (Martin Blume) Date: Wed, 23 Apr 2008 20:01:39 +0200 Subject: Unix Device File Emulation References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> <480f6376$0$9037$5402220f@news.sunrise.ch> <9ee87070-be57-4a66-a152-3f36c1cc8f0c@k13g2000hse.googlegroups.com> Message-ID: <480f7983$0$9036$5402220f@news.sunrise.ch> "blaine" schrieb > > > > while 1: > > r = self.fifodev.readline() > > if r: print r > > > > According to my docs, readline() returns an empty > > string at the end of the file. > > Also, you might want to sleep() between reads a > > little bit. > > > > Oh ok, that makes sense. Hmm. So do I not want to use > readline()? Or is there a way to do something like > 'block until the file is not empty'? > No, while 1: r = self.fifodev.readline() if r: print r else: time.sleep(0.1) is ok (note the "if r:" clause). Martin From tinnews at isbd.co.uk Thu Apr 3 10:13:43 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 03 Apr 2008 14:13:43 GMT Subject: How easy is it to install python as non-root user? Message-ID: <47f4e617$0$720$bed64819@news.gradwell.net> Does python install fairly easily for a non-root user? I have an ssh login account onto a Linux system that currently provides Python 2.4.3 and I'd really like to use some of the improvements in Python 2.5.x. So, if I download the Python-2.5.2.tgz file is it just the standard:- ./configure --prefix=$HOME make make install -- Chris Green From aaron.watters at gmail.com Sun Apr 27 21:31:47 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Sun, 27 Apr 2008 18:31:47 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> <48118719$0$25846$9b622d9e@news.freenet.de> <481525DE.9060208@v.loewis.de> Message-ID: On Apr 27, 9:18?pm, "Martin v. L?wis" wrote: > An existing application of an existing dict-like > object will continue to work just fine in Python 3, > right? Unless I mix my psuedodicts with standard dicts in the same list, for example, or pass them to functions intended to accept any dict-like object, including the especially important case of standard dicts. Who knows? Maybe I'm wrong about this being a much of problem. 20+ years experience warns me strongly to be very afraid, however. It would be great if I didn't have to think about it. Can anyone recommend a good book on Ruby :)? -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=unnecessary+breakage From s0suk3 at gmail.com Mon Apr 28 10:26:13 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Mon, 28 Apr 2008 07:26:13 -0700 (PDT) Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> Message-ID: <1939ddb7-fc72-4d45-8c9c-062a1d0db3e4@y21g2000hsf.googlegroups.com> On Apr 28, 4:30 am, Nick Craig-Wood wrote: > s0s... at gmail.com wrote: > > I wanted to ask for standard ways to receive data from a socket stream > > (with socket.socket.recv()). It's simple when you know the amount of > > data that you're going to receive, or when you'll receive data until > > the remote peer closes the connection. But I'm not sure which is the > > best way to receive a message with undetermined length from a stream > > in a connection that you expect to remain open. Until now, I've been > > doing this little trick: > > > data = client.recv(256) > > new = data > > while len(new) == 256: > > new = client.recv(256) > > data += new > > > That works well in most cases. But it's obviously error-prone. What if > > the client sent *exactly* two hundred and fifty six bytes? It would > > keep waiting for data inside the loop. Is there really a better and > > standard way, or is this as best as it gets? > > What you are missing is that if the recv ever returns no bytes at all > then the other end has closed the connection. So something like this > is the correct thing to write :- > > data = "" > while True: > new = client.recv(256) > if not new: > break > data += new > > From the man page for recv > > RETURN VALUE > > These calls return the number of bytes received, or -1 if an > error occurred. The return value will be 0 when the peer has > performed an orderly shutdown. > > In the -1 case python will raise a socket.error. > > -- > Nick Craig-Wood --http://www.craig-wood.com/nick But as I said in my first post, it's simple when you know the amount of data that you're going to receive, or when you'll receive data until the remote peer closes the connection. But what about receiving a message with undetermined length in a connection that you don't want to close? I already figured it out: in the case of an HTTP server/ client (which is what I'm doing), you have to look for an empty line in the message, which signals the end of the message headers. As for the body, you have to look at the Content-Length header, or, if the message body contains the "chunked" transfer-coding, you have to dynamically decode the encoding. There are other cases but those are the most influent. BTW, has anybody used sockets as file-like objects (client.makefile())? Is it more secure? More efficient? Sebastian From deets at nospam.web.de Thu Apr 3 10:49:57 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 03 Apr 2008 16:49:57 +0200 Subject: object-relational mappers In-Reply-To: <47f4eb4f$0$4959$426a74cc@news.free.fr> References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <47f37039$0$31900$426a74cc@news.free.fr> <47f4eb4f$0$4959$426a74cc@news.free.fr> Message-ID: <65k94pF2g33guU1@mid.uni-berlin.de> Bruno Desthuilliers schrieb: > Jarek Zgoda a ?crit : >> Bruno Desthuilliers napisa?(a): >> >>> Now my own experience is that whenever I tried this approach for >>> anything non-trivial, I ended up building an "ad-hoc, >>> informally-specified bug-ridden slow implementation of half of " >>> SQLAlchemy. Which BTW is not strictly an ORM, but primarily an attempt >>> at a better integration of SQL into Python. So while it may feel like >>> learning the inner complexities of SQLALchemy (or Django's ORM which is >>> not that bad either) is "wasting brain cells", MVHO is that it's worth >>> the time spent. But YMMV of course - IOW, do what works best for you. >> >> I like OR mappers, they save me lot of work. The problem is, all of them >> are very resource hungry, processing resultset of 300k objects one by >> one can effectively kill most of commodity systems. This is where raw >> SQL comes in handy. > > The problem here is not about how you build your query but about how you > retrieve your data. FWIW, SQLAlchemy provides quite a lot of "lower > level" SQL/Python integration that doesn't require the "object mapping" > part. "raw SQL" is fine, until you have to dynamically build complex > queries from user inputs and whatnot. This is where the "low-level" (ie: > non-ORM) part of SQLAlchemy shines IMHO. The same can be said for SQLObjects SQLBuilder. Even if I ended up generating SQL for some query that didn't touch the ORM-layer, it helps tremendously to write e.g subqueries and such using python-objects instead of manipulating strings. They help keeping track of already referenced tables, spit out properly escaped syntax and so forth. Diez From jorge.vargas at gmail.com Tue Apr 1 03:15:57 2008 From: jorge.vargas at gmail.com (Jorge Vargas) Date: Tue, 1 Apr 2008 07:15:57 +0000 Subject: Why prefer != over <> for Python 3.0? In-Reply-To: References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> <659gb2F2f84eoU2@mid.individual.net> <87hceo73ap.fsf@physik.rwth-aachen.de> <65anbqF2fg18bU1@mid.individual.net> <87r6drjss4.fsf@physik.rwth-aachen.de> <65c0bfF2ffipiU1@mid.individual.net> Message-ID: <32822fe60804010015m22a4e9bei5002431afe14921a@mail.gmail.com> On Tue, Apr 1, 2008 at 6:03 AM, Gabriel Genellina wrote: > En Mon, 31 Mar 2008 16:17:39 -0300, Terry Reedy > escribi?: > > > > "Bjoern Schliessmann" > > wrote > > in message news:65c0bfF2ffipiU1 at mid.individual.net... > > | > However, I'm quite sure that when Unicode has arrived almost > > | > everywhere, some languages will start considering such characters > > | > in their core syntax. > > | > > | This should be the time when there are widespread quasi-standardised > > | input methods for those characters. > > > > C has triglyphs for keyboards missing some ASCII chars. != and <= could > > easily be treated as diglyphs for the corresponding chars. In a sense > > they > > are already, it is just that the real things are not allowed ;=). > > I think it should be easy to add support for ??? and even ?, only the > tokenizer has to be changed. > show me a keyboard that has those symbols and I'm all up for it. as for the original question, the point of going unicode is not to make code unicode, but to make code's output unicode. thin of print calls and templates and comments the world's complexity in languages. sadly most english speaking people think unicode is irrelevant because ASCII has everything, but their narrow world is what's wrong. From steve at holdenweb.com Fri Apr 11 17:47:59 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 11 Apr 2008 17:47:59 -0400 Subject: Question on threads In-Reply-To: References: <47FFBC05.50309@holdenweb.com> Message-ID: <47FFDC8F.4060106@holdenweb.com> Jonathan Shao wrote: > On Fri, Apr 11, 2008 at 3:29 PM, Steve Holden > wrote: > > Jonathan Shao wrote: > > Hi all, > I'm a beginner to Python, so please bear with me. > Is there a way of guarenteeing that all created threads in a > program are finished before the main program exits? I know that > using join() can guarentee this, but from the test scripts I've > run, it seems like join() also forces each individual thread to > terminate first before the next thread can finish. So if I > create like 20 threads in a for loop, and I join() each created > thread, then join() will in effect cause the threads to be > executed in serial rather than in parallel. > > > No it won't, as in fact there is no mechanism to force a thread to > terminate in Python. When you join() each created thread the main > thread will wait for each thread to finish. Supposing the > longest-lived thread finished first then all others will immediately > return from join(). > > The only requirement it is imposing is that all sub-threads must be > finished before the main thread terminates. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > > > I guess I'm doing something wrong with join(). Here's a test script I > wrote up... > > import threading > import time > class TestThread(threading.Thread): > def __init__(self, region): > self.region = region > threading.Thread.__init__(self) > def run(self): > for loop in range(10): > print "Region " + str(self.region) + " reporting: " + str(loop) > time.sleep(2) > for x in range(10): > thr = TestThread(x) > thr.start() > thr.join() > raw_input() > In this script thread 0 will finish first... Am I doing something wrong > with join()? > Yes - you are calling it before you have started ALL your threads, thereby making hte main thread wait for the end of thread 1 before starting the next. An impressive demonstration of thread synchronization, but not quite what you want :-) Try saving the threads in a list then joining them later, like this (untested): threads = [] for x in range(10): thr = TestThread(x) thr.start() threads.append(thr) # Now all are started, wait for all to finish for thr in threads: thr.join() regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From george.sakkis at gmail.com Wed Apr 2 13:31:23 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 2 Apr 2008 10:31:23 -0700 (PDT) Subject: april fools email backfires References: <7xbq4sf9wv.fsf@ruckus.brouhaha.com> Message-ID: On Apr 2, 1:23?pm, Paul Rubin wrote: > Aaron Watters writes: > > Grapevine says that an architect/bigot at a java/spring shop sent > > out an April Fools email saying they had decided to port everything > > to Django ASAP. > > > Of course the email was taken seriously and he got a lot of positive > > feedback from line developers and savvy users/managers that they > > thought it would be a great idea; it's about time; gotta do > > something about this mess... > > Django, pah. ?They should switch to something REALLY advanced: > > http://www.coboloncogs.org/INDEX.HTM That was funny, thanks for the chuckle :) From bronger at physik.rwth-aachen.de Wed Apr 16 00:45:50 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 16 Apr 2008 06:45:50 +0200 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <101680ba-a116-414b-8fff-c5b5bd2f4b65@p39g2000prm.googlegroups.com> Message-ID: <87iqyi9zlt.fsf@physik.rwth-aachen.de> Hall?chen! lxlaurax at gmail.com writes: > On 11 abr, 20:31, sturlamolden wrote: > > [...] > > I have no experience with GUI programming in Python, but from this > discussion it seems if the type of license is not an issue (for > FOSS development), PyQt is the best tool because it is: > > (a) easier to learn and intuitive for programming (this is > important to me; I am not that smart...); > > (b) more stable (although many people have said that wxPython is > as stable as any other GUI nowadays; but not more stable (wx) than > others); > > (c) more cross-platform (many people complain that they have to do > a lot of things in wxPython for the cross-platform). > > Is (a) and (c) true or not? If so, how big are these advantages? I really don't know what someone could mean with (c). (b) is probably correct, however for both toolkits this is a not critical from my observation (writing own programs and reading reports of others). (a) is a matter of taste. I, for example, ruled out Qt because I've never understood its mentality. I've read it over and over again, but I didn't grasp it. It depends on your background probably. > The great advantage of wxPython seems to be the huge community of > users and the large number of widgets/examples/applications > available. Unless the Qt people simple can shout much louder, I think both communities are equally sized, but I don't know for sure. > Reformulating my question: > > Which GUI tool, wxPython or PyQt, is more pythonic? In my opinion: none. This was important to me, too, so I looked at it closely when I chose my GUI toolkit. wxPython is traditionally considered unpythonic which is a bit unfair now. They tweaked it a little in recent years and it is reasonable pythonic now. It still has its warts, but Qt definitely has them, too. If you want to have it clean, you must climb up to another level of abstraction (Dabo, Wax etc). I wouldn't do this because it gets slower and less well supported by a large community. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From thashooski at farifluset.mailexpire.com Sun Apr 13 14:44:21 2008 From: thashooski at farifluset.mailexpire.com (thashooski at farifluset.mailexpire.com) Date: Sun, 13 Apr 2008 11:44:21 -0700 (PDT) Subject: Module to read input from commandline References: <2e04b64c-9a12-4e20-8d5a-546a0ec4ac7f@m36g2000hse.googlegroups.com> Message-ID: What you're looking for is no module, it is included in the standard python namespace. raw_input Use it like this: value_a = raw_input("Please give a value for a: ") # do your thing to value_a But this belongs to the real basics, I suggest you get some reading done on python. GL From python at bdurham.com Sat Apr 12 14:41:20 2008 From: python at bdurham.com (Malcolm Greene) Date: Sat, 12 Apr 2008 14:41:20 -0400 Subject: Recommended "from __future__ import" options for Python 2.5.2? Message-ID: <1208025680.10309.1247529999@webmail.messagingengine.com> Is there any consensus on what "from __future__ import" options developers should be using in their Python 2.5.2 applications? Is there a consolidated list of "from __future__ import" options to choose from? Thank you, Malcolm From jeff.self at gmail.com Wed Apr 9 19:37:11 2008 From: jeff.self at gmail.com (jeffself) Date: Wed, 9 Apr 2008 16:37:11 -0700 (PDT) Subject: How can I use quotes without escaping them using CSV? References: Message-ID: On Apr 9, 5:39 pm, "Reedick, Andrew" wrote: > > -----Original Message----- > > From: python-list-bounces+jr9445=att.... at python.org [mailto:python- > > list-bounces+jr9445=att.... at python.org] On Behalf Of jeffself > > Sent: Wednesday, April 09, 2008 5:11 PM > > To: python-l... at python.org > > Subject: How can I use quotes without escaping them using CSV? > > > If I put an escape character in, it works. For example, if I use ~ as > > my escape character, my output looks like this: > > 0001[tab]Michael L. ~"Mick~" Jones[tab]189 > > > I don't want that. If I don't include an escape character, it doesn't > > work. > > > Here's my code: > > import sys > > import csv > > from readexcel import * > > > f = open("results.txt", 'wb') > > book = sys.argv[1] > > sheet = sys.argv[2] > > > xl = readexcel(book) > > sheetnames = xl.worksheets() > > > for s in sheetnames: > > if s == sheet: > > writer = csv.writer(f, delimiter='\t', quoting=csv.QUOTE_NONE) > > for row in xl.getiter(s): > > writer.writerow((row['Precinct'],row['Candidate'],unicode(int(row['Vote > > > s'])))) > > f.close() > > The documentation is pretty, uhm, obtuse, but you also need to set > quotechar. > > import sys > import csv > > names = ['Michael L. "Mick" Jones', 'Vickie A. Meyers', 'John "Jack" > Smith'] > > writer = csv.writer(sys.stdout, delimiter='\t', quotechar='', > quoting=csv.QUOTE_NONE) > for i in names: > writer.writerow(['a', i, 'b']) > > output: > a Michael L. "Mick" Jones b > a Vickie A. Meyers b > a John "Jack" Smith b > > ***** > > The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA621 I tried this but a get the following error: >>> writer = csv.writer(sys.stdout, delimiter='\t', quotechar=", quoting=csv.QUOTE_NONE) File "", line 1 writer = csv.writer(sys.stdout, delimiter='\t', quotechar=", quoting=csv.QUOTE_NONE) ^ SyntaxError: EOL while scanning single-quoted string From kveretennicov at gmail.com Tue Apr 1 15:50:17 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Tue, 1 Apr 2008 22:50:17 +0300 Subject: Is this a good time to start learning python? In-Reply-To: <1565ced8-afd7-4c32-a6ee-26f9b95d60bc@d45g2000hsc.googlegroups.com> References: <47f1140e$0$735$a729d347@news.telepac.pt> <88fa881e-e59b-4682-801c-90ef08a1480a@a22g2000hsc.googlegroups.com> <1565ced8-afd7-4c32-a6ee-26f9b95d60bc@d45g2000hsc.googlegroups.com> Message-ID: <4660fe300804011250w5a3164d3l57db02f8bc82f395@mail.gmail.com> > > > > > Backward compatibility is important. C++ could break all ties with > C > > > to "clean up" as well, but it would be a braindead move that would > > > break existing code bases upon upgrade. > > > > C++ is not C. No one "upgrades" from C to C++. > > You misunderstand. C++ has a lot of "warts" to maintain backwards > compatibility with C. The standards committee could eliminate these > warts to make the language "cleaner", but it would break a lot of > systems. > Didn't C++ "break" all C programs that happened to use "class" for identifier? :) -- kv -------------- next part -------------- An HTML attachment was scrubbed... URL: From cyberco at gmail.com Thu Apr 17 10:11:17 2008 From: cyberco at gmail.com (Berco Beute) Date: Thu, 17 Apr 2008 07:11:17 -0700 (PDT) Subject: webcam (usb) access under Ubuntu References: Message-ID: <9c260dc0-6461-4869-ba4e-63016b831dba@x41g2000hsb.googlegroups.com> On Apr 16, 2:26 pm, yoz wrote: > Berco Beute wrote: > > I've been trying to access my webcam using Python, but I failed > > miserably. The camera works fine under Ubuntu (using camora and > > skype), but I am unable to get WebCamSpy or libfg to access my webcam. > > > First I tried webcamspy (http://webcamspy.sourceforge.net/). That > > requires pySerial and pyParallel, and optionally pyI2C. Runing > > WebCamSpy results in: > > > Exception exceptions.AttributeError: "Parallel instance has no > > attribute '_fd'" in > > ignored > > > This seems to come from importing I2C. The application window opens, > > but there's an error message: > > > NO VIDEO SOURCE FOUND > > > Next I tried libfg (http://antonym.org/libfg). I built it, made the > > Python bindings and installed it. Unfortunately the following: > > >>>> import fg > >>>> grabber = fg.Grabber() > > > results in: > > > fg_open(): open video device failed: No such file or directory > > > Since the camera works fine in Ubuntu itself my guess is that the > > problem is with the python libraries (or even likelier, my usage of > > them). Is there anybody here that was successful in accessing their > > webcam on linux using Python? Else I have to reside to Windows and > > VideoCapture (which relies on the win32 api and thus is Windows-only), > > something I'd rather not do. > > > Thanks for any help, > > 2B > > > =============== > > I am uUsing: > > WebCam: Logitech QuickCam Pro 400 > > Ubuntu > > Python 2.5 > > Some time ago I was playing with writing a webcam server under Linux > using V4L - I found this bit of code which may help (it works for me). > Obviously it needs X running to work and the associated libs installed. > Note this is not my code but it was a good starting point for me to work > from. I can't find a link to the original article but credit to the author. > > import pygame > import Image > from pygame.locals import * > import sys > > import opencv > #this is important for capturing/displaying images > from opencv import highgui > > camera = highgui.cvCreateCameraCapture(0) > def get_image(): > im = highgui.cvQueryFrame(camera) > #convert Ipl image to PIL image > return opencv.adaptors.Ipl2PIL(im) > > fps = 30.0 > pygame.init() > window = pygame.display.set_mode((320,240)) > pygame.display.set_caption("WebCam Demo") > screen = pygame.display.get_surface() > > while True: > events = pygame.event.get() > for event in events: > if event.type == QUIT or event.type == KEYDOWN: > sys.exit(0) > im = get_image() > pg_img = pygame.image.frombuffer(im.tostring(), im.size, im.mode) > screen.blit(pg_img, (0,0)) > pygame.display.flip() > pygame.time.delay(int(1000 * 1.0/fps)) > > Best of Luck > Bgeddy Thank you! That seems to work under both Linux and windows. The opencv library is the clue here. I've used the ctypes wrapper for opencv provided by the first link below, but there are more options. For future reference here are some relevant links: http://wwwx.cs.unc.edu/~gb/wp/blog/2007/02/04/python-opencv-wrapper-using-ctypes/ http://opencvlibrary.sourceforge.net/ http://opencvlibrary.sourceforge.net/NoamLewis http://opencvlibrary.sourceforge.net/PythonInterface Windows specific: http://www.instructables.com/id/Using-openCV-1.0-with-python-2.5-in-Windows-XP/ http://dip.sun.ac.za/3Dvision/talks/OpenCV_in_Python_on_Windows.pps http://opencvlibrary.sourceforge.net/NoamLewis Thanks for all the help. 2B From bijeshn at gmail.com Tue Apr 8 00:26:11 2008 From: bijeshn at gmail.com (bijeshn) Date: Mon, 7 Apr 2008 21:26:11 -0700 (PDT) Subject: splitting an XML file on the basis on basis of XML tags References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> <47F9B845.9040205@behnel.de> <05edd42c-dd16-4364-92ca-43cdbb1ab547@r9g2000prd.googlegroups.com> <47FA14D1.3080608@behnel.de> Message-ID: <529f2c06-b0cd-4105-b3f1-37c934847c0c@1g2000prg.googlegroups.com> On Apr 7, 5:34?pm, Stefan Behnel wrote: > bijeshn wrote: > > the extracted files are to be XML too. ijust need to extract it raw > > (tags and data just like it is in the parent XML file..) > > Ah, so then replace the "print tostring()" line in my example by > > ? ? ET.ElementTree(element).write("outputfile.xml") > > and you're done. > > Stefan thanks a lot, Stefan.... i haven't tested out your idea yet. Will get back as soon as I do it... From sturlamolden at yahoo.no Thu Apr 17 13:33:26 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 17 Apr 2008 10:33:26 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> Message-ID: <6e3e8c87-60bd-496c-9f71-b6e9bbfcdc73@m3g2000hsc.googlegroups.com> On Apr 17, 7:16 pm, Jonathan Gardner wrote: > On Apr 17, 8:19 am, sturlamolden wrote: > > > > > An there you have the answer. It's really very simple :-) > > That's an interesting hack. > > Now, how do the processes communicate with each other without stepping > on each other's work and without using a lock? Why can't I use a lock? There is a big difference between fine-grained locking on each object (cf. Java) and a global lock for everything (cf. CPython's GIL). Fine- grained locking for each object has been tried, and was found to be a significant slow down in the single-threaded case. What if we just do fine grained locking on objects that need to be shared? What if we accept that "shared" objects are volatile and may suddenly disappear (like a weakref), and trap that as an exception? From steve at holdenweb.com Fri Apr 11 00:35:38 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 11 Apr 2008 00:35:38 -0400 Subject: Integer dicision In-Reply-To: <5f499bee-a659-4e36-870c-076cb613a3e7@t12g2000prg.googlegroups.com> References: <5f499bee-a659-4e36-870c-076cb613a3e7@t12g2000prg.googlegroups.com> Message-ID: bdsatish wrote: > How does (a/b) work when both 'a' and 'b' are pure integers ? > >>> (9/2) > 4 > >>> (-9/2) > -5 > > Why is it -5 ? I expect it to be -4 ? Because, in C/C++, 9/2 is 4 and > so negative of it, (-9/2) is -4. > > What should I do to get C-like behavior ? Use C? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From martin at v.loewis.de Fri Apr 18 18:01:04 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sat, 19 Apr 2008 00:01:04 +0200 Subject: Unicode chr(150) en dash In-Reply-To: <480887b8@news.mel.dft.com.au> References: <48063434$0$36327$742ec2ed@news.sonic.net> <7dae96d4-48c4-46c9-9aa9-33a263b84ca4@26g2000hsk.googlegroups.com> <480887b8@news.mel.dft.com.au> Message-ID: <48091A20.2070500@v.loewis.de> > 150 aka \x96 doesn't exist in ISO 8859-1. ISO-8859-1 (two hyphens) is a > superset of ISO 8859-1 (one hyphen) and adds the not-very-useful-AFAICT > control codes \x80 to \x9F. To disambiguate the two, when I want to refer to the one with the control characters, I use the name "IANA ISO-8859-1" or "the IANA version of Latin-1", or some such, to reflect the fact that it's not the ISO standard, but the (unfortunately differing) IANA registration thereof. Regards, Martin From andreas.eisele at gmail.com Sat Apr 12 12:53:13 2008 From: andreas.eisele at gmail.com (andreas.eisele at gmail.com) Date: Sat, 12 Apr 2008 09:53:13 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: Sorry, I have to correct my last posting again: > > Disabling the gc may not be a good idea in a real application; I suggest > > you to play with the gc.set_threshold function and set larger values, at > > least while building the dictionary. (700, 1000, 10) seems to yield good > > results. > > python2.5 -m timeit 'gc.set_threshold(700,1000,10);l=[(i,) for i in range(2000000)]' > > 10 loops, best of 3: 658 msec per loop > Looks nice, but it is pointless, as timeit disables gc by default, and the set_threshold hence has no effect. In order to see the real effect of this, I need to say > python2.5 -m timeit 'gc.enable();gc.set_threshold(700,1000,10);l=[(i,) for i in range(2000000)]' which gives me 10 loops, best of 3: 1.26 sec per loop Still a factor of more than 10 faster than the default settings. > which made me suggest to use these as defaults, but then > Martin v. L?wis wrote that > > > No, the defaults are correct for typical applications. Complex topic... From bignose+hates-spam at benfinney.id.au Fri Apr 18 18:56:29 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Sat, 19 Apr 2008 08:56:29 +1000 Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> Message-ID: <87lk3asrfm.fsf@benfinney.id.au> Thomas Bellman writes: > For what it's worth, Fedora 8 has Python 2.5, RHEL 5 ships with > Python 2.4, and RHEL 4 has Python 2.3. Suse and Debian, I don't > know. The current Debian "stable" branch (4.0r3, "etch", released 2008-02-17) has the 'python' package installing Python 2.4.4. The current Debian "testing" branch ("lenny", the next in line for release) has the 'python' package installing Python 2.4.5. It also has Python 2.5.2, and before too long will be installing that as the 'python' package. The current Debian "unstable" branch (never to be released, but a staging area for new package versions) has the 'python' package installing Python 2.5.2. -- \ "Pinky, are you pondering what I'm pondering?" "Umm, I think | `\ so, Brain, but three men in a tub? Ooh, that's unsanitary!" -- | _o__) _Pinky and The Brain_ | Ben Finney From duncan.booth at invalid.invalid Wed Apr 9 06:24:03 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 9 Apr 2008 10:24:03 GMT Subject: Can C.L.P.handle the load? References: <3b6737c8-9d42-4218-ac60-01df2f578746@p39g2000prm.googlegroups.com> <9bd25fd3-5133-4165-9784-fbbc21145810@24g2000hsh.googlegroups.com> Message-ID: Berco Beute wrote: > On Apr 9, 7:54 am, Paddy wrote: >> What else could we do to make c.l.p. of more use to the newbie whp may >> also be new to usenet whilst keeping c.l.p a usefull place for all? >> >> - Paddy. > > Maybe create a usenet/google group for newbies? A place to ask > beginners questions. And post a sticky to c.l.p. redirecting newbies > (or experienced pythoneers with newbie questions :). > Or just redirect them to the already existing list http://mail.python.org/mailman/listinfo/tutor What do you mean by 'post a sticky'? That sounds like a web forum thing. From dolloffdelvpg at gmail.com Wed Apr 16 08:05:09 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:05:09 -0700 (PDT) Subject: taylor swift height Message-ID: <7bd91158-fe3e-418c-a4b7-b6c4e7619e14@r9g2000prd.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From gagsl-py2 at yahoo.com.ar Thu Apr 24 00:24:11 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 24 Apr 2008 01:24:11 -0300 Subject: Problem using copy.copy with my own class References: <676noiF2n7ttmU1@mid.uni-berlin.de> <480FFF55.5070803@gmail.com> Message-ID: En Thu, 24 Apr 2008 01:21:15 -0300, Gabriel Genellina escribi?: > I agree. In case arg2 were really meaningful, use __getnewargs__ (see ) I forget to include the link: -- Gabriel Genellina From acherry at btinternet.com Fri Apr 11 07:07:36 2008 From: acherry at btinternet.com (Adrian Cherry) Date: 11 Apr 2008 12:07:36 +0100 Subject: Randall Munroe loves Python References: <869c25d9-e4d3-4629-a807-f3b203f3fb65@b1g2000hsg.googlegroups.com> Message-ID: Paul McGuire wrote in news:869c25d9-e4d3- 4629-a807-f3b203f3fb65 at b1g2000hsg.googlegroups.com: > Another xkcd plug for Python: http://xkcd.com/409/ > So Python is on a collision course with Calvin and Hobbes! Adrian From mdomans at gmail.com Tue Apr 1 13:41:18 2008 From: mdomans at gmail.com (mdomans) Date: Tue, 1 Apr 2008 10:41:18 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> Python needs no evangelizing but I can tell you that it is a powerfull tool. I prefer to think that flash is rather visualization tool than programing language, and java needs a lot of typing and a lot of reading. On the other hand python is simple to read and write, can be debuged easily, is intuitive and saves a lot of time. It also supports batteries included policy and you can't get more OO than python. From tjreedy at udel.edu Thu Apr 24 04:40:25 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 24 Apr 2008 04:40:25 -0400 Subject: Explicit variable declaration References: <1506f165-7f86-4dc7-aa29-6488eda9ae7f@l64g2000hse.googlegroups.com><5e59998b-d2e7-48cb-824b-84620f95c9bc@w5g2000prd.googlegroups.com> <1be78d220804231829k2c040fat80f6fe8b96e1b7cf@mail.gmail.com> Message-ID: "Filip Gruszczynski" wrote in message news:1be78d220804231829k2c040fat80f6fe8b96e1b7cf at mail.gmail.com... |> If you want to just declare that name exist, but doesn't want to | > declare the type, why don't you just do this: Names do not 'exist' in Python, nor do they have types. They are bound to objects that have types. Learn to program Python as Python, not one of those languages with a quite different model of names and values. | > def somefunc(): | > nonlocal = nonlocal Syntax error in 3.0. Error or nonsense in 2.x | > local = 0 # or None or [] or an initial value | > # | > return nonlocal * local | | Err.. I don't quite get. How it may help me? Could you explain? Forget the above. The only 'declarations' in Python, 'global' and 'nonlocal' are for the specialized purpose of *binding* names that are not in the local namespace of a function or nested function. They are only needed because otherwise names that get bound are otherwise assumed to be local. See the language ref section on function defs. tjr From elgrandchignon at gmail.com Tue Apr 8 23:04:48 2008 From: elgrandchignon at gmail.com (Jason) Date: Tue, 8 Apr 2008 20:04:48 -0700 (PDT) Subject: Sorting a List of Objects by an Attribute of the Objects Case-Insensitively Message-ID: <736fefbd-510f-40e9-8342-32b69a1a0c2a@t12g2000prg.googlegroups.com> Hi folks-- Basically, I have a pressing need for a combination of 5.2 "Sorting a List of Strings Case-Insensitively" & 5.3 "Sorting a List of Objects by an Attribute of the Objects" from the Python Cookbook. My first guess isn't working: import operator def sort_by_attr(seq, attr): key=operator.attrgetter(attr) key=str.lower return sorted(seq, key) ...would much appreciate any guidance! From sn at sncs.se Tue Apr 8 13:39:48 2008 From: sn at sncs.se (Sverker Nilsson) Date: Tue, 8 Apr 2008 10:39:48 -0700 (PDT) Subject: Guppy-PE / Heapy 0.1.8 Message-ID: I am happy to announce Guppy-PE 0.1.8 Guppy-PE is a library and programming environment for Python, currently providing in particular the Heapy subsystem, which supports object and heap memory sizing, profiling and debugging. It also includes a prototypical specification language, the Guppy Specification Language (GSL), which can be used to formally specify aspects of Python programs and generate tests and documentation from a common source. The current version is updated to work in 64-bit mode and with Python-2.6, and still works in 32-bit mode and with Python 2.3, 2.4 and 2.5. No other major changes have been made from Guppy 0.1.6. In the nearest future, I plan to add interactive help and more examples to the documentation, perhaps a tutorial. Look out for this in the svn HEAD according to instructions at the project home page, if you want the latest version. I will try to make a new release in perhaps a month or so. License: MIT Guppy-PE 0.1.8 is available in source tarball format on the Python Package Index (a.k.a. Cheeseshop): http://pypi.python.org/pypi/guppy/0.1.8 The project homepage is on Sourceforge: http://guppy-pe.sourceforge.net Enjoy, Sverker From aldo at nullcube.com Sat Apr 5 10:13:29 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Sun, 6 Apr 2008 01:13:29 +1100 Subject: ANN: pry unit testing framework In-Reply-To: <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com> Message-ID: <20080405141329.GD15684@nullcube.com> Thus spake Kay Schluehr (kay.schluehr at gmx.net): > Aldo, when you confuse inheritance ( using an OO framework properly ) > with monkey patching no one can draw much different conclusions than I > did. I guess you do always run the risk of being pelted with something from the peanut gallery when you release something in public - maybe I'll think twice about doing so next time. The only "confused" person here is you - I still say that it is NOT possible to provide the functionality Pry does by extending unittest in any sane way. Now, if you don't agree with this, please prove me wrong through reasoned argument or shut up. Do NOT, however, accuse me of not knowing what inheritance or monkeypatching is unless you want to look stupid and make my killfile. > But raving against unittest.py and anti-hyping it for mostly trivial > reasons and with shallow reasoning has become a fashion. Now we see > alternatives that do little more than what can be achieved by adding > two abstract methods to the TestSuite base class and overwrite a few > methods of the TestLoader base class ( maybe I'm wrong about it but I > guess the discussion has become too heated to clarify this point using > technical arguments ). > > I just felt it was a good opportunity to debunk this unittest.py anti- > hype. I'm sorry it has gone too personal. You can choose to use Pry or not, as you please. I would, however, ask that you stop whining incessantly about how it's not compatible with YOUR favourite framework, despite the fact that compatibility would gain YOU very little and ME nothing at all. As I said in my response to Michele, you lose the benefits of compatibility as soon as your tests use any of the features an extension might add. To me, this means the burden is not worth it. Since I designed and wrote Pry, I get to make that choice, not you, and the type of feeble, offensive "argument" you've provided is unlikely to change my mind. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From ivan.illarionov at gmail.com Fri Apr 11 08:58:46 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Fri, 11 Apr 2008 05:58:46 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: <69c85ba7-2ef1-4f65-954a-6d883dfdfb30@u69g2000hse.googlegroups.com> On Apr 11, 2:14 pm, bdsatish wrote: > The built-in function round( ) will always "round up", that is 1.5 is > rounded to 2.0 and 2.5 is rounded to 3.0. > > If I want to round to the nearest even, that is > > my_round(1.5) = 2 # As expected > my_round(2.5) = 2 # Not 3, which is an odd num > > I'm interested in rounding numbers of the form "x.5" depending upon > whether x is odd or even. Any idea about how to implement it ? def even_round(x): if x % 1 == .5 and not (int(x) % 2): return float(int(x)) else: return round(x) nums = [ 3.2, 3.6, 3.5, 2.5, -.5, -1.5, -1.3, -1.8, -2.5 ] for num in nums: print num, '->', even_round(num) 3.2 -> 3.0 3.6 -> 4.0 3.5 -> 4.0 2.5 -> 2.0 -0.5 -> 0.0 -1.5 -> -2.0 -1.3 -> -1.0 -1.8 -> -2.0 -2.5 -> -2.0 From schettino72 at gmail.com Sat Apr 19 15:35:22 2008 From: schettino72 at gmail.com (Eduardo Schettino) Date: Sun, 20 Apr 2008 01:05:22 +0530 Subject: [ANN] DoIt 0.1.0 Released (build tool) Message-ID: DoIt - A task execution tool (build-tool) ========================================= This is the first public release of DoIt Website: http://python-doit.sourceforge.net/ Release: DoIt 0.1.0 License: MIT About ----- DoIt is a build tool that focus not only on making/building things but on executing any kind of tasks in an efficient way. Designed to be easy to use and "get out of your way". DoIt like most build tools is used to execute tasks defined in a configuration file. Configuration files are python modules. The tasks can be python functions (or any callable) or an external shell script. DoIt automatically keeps track of declared dependencies executing only tasks that needs to be update (based on which dependencies have changed). In DoIt, unlike most(all?) build-tools, a task doesn't need to define a target file to use the execute only if not up-to-date feature. This make DoIt specially suitable for running test suites. DoIt can be used to perform any task or build anything, though it doesn't support automatic dependency discovery for any language. Cheers, Eduardo From uniontelecardsindia at gmail.com Tue Apr 22 17:12:56 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:12:56 -0700 (PDT) Subject: Extreme moresome black gay groupsex Message-ID: <44833c7d-efb5-42ab-a2be-1b9584c04a8e@59g2000hsb.googlegroups.com> Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From sturlamolden at yahoo.no Sat Apr 19 13:39:01 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sat, 19 Apr 2008 10:39:01 -0700 (PDT) Subject: why function got dictionary References: <48075950.7050000@gmail.com> Message-ID: On Apr 17, 4:06 pm, AlFire wrote: > Q: why function got dictionary? What it is used for? As previously mentioned, a function has a __dict__ like (most) other objects. You can e.g. use it to create static variables: int foobar() { static int i = 0; return i++; } is roughly equivalent to: def foobar(): foobar.i += 1 return foobar.i foobar.i = 0 From gruszczy at gmail.com Fri Apr 25 12:23:43 2008 From: gruszczy at gmail.com (=?UTF-8?Q?Filip_Gruszczy=C5=84ski?=) Date: Fri, 25 Apr 2008 18:23:43 +0200 Subject: Explicit variable declaration In-Reply-To: <1209101024.201741@chilli.pcug.org.au> References: <1506f165-7f86-4dc7-aa29-6488eda9ae7f@l64g2000hse.googlegroups.com> <5e59998b-d2e7-48cb-824b-84620f95c9bc@w5g2000prd.googlegroups.com> <1209101024.201741@chilli.pcug.org.au> Message-ID: <1be78d220804250923s26b86abaua31ac77d049eb014@mail.gmail.com> > In Python the standard patten for "declaring" variables is just to assign to > them as they are needed. If you want the effect of a declaration as you > would do in C, you can just define the variable and initialize it to 0 or > None. (Or {} for a new dictionary, or [] for a new list.) Yep, I get it and I absolutely love this about Python. What I don't actually love is situation, where I misspell and instead of setting one variable, other is created. This is why I would like to declare variables first and say, that these are the only ones, that can be set in certain function (the same with fields in a class). I am finishing a small tool, that allows to create such declarations in similar manner to Smalltalk declarations. I hope I can post a link to it soon. -- Filip Gruszczy?ski From grahn+nntp at snipabacken.se Mon Apr 21 18:26:57 2008 From: grahn+nntp at snipabacken.se (Jorgen Grahn) Date: 21 Apr 2008 22:26:57 GMT Subject: Java or C++? References: Message-ID: On Mon, 21 Apr 2008 06:14:08 -0700 (PDT), NickC wrote: > On Apr 15, 1:46 pm, Brian Vanderburg II > wrote: >> This will automatically call the constructors of any contained objects >> to initialize the string. The implicit assignment operator >> automatically performs the assignment of any contained objects. >> Destruction is also automatic. When 'p1' goes out of scope, during the >> destructor the destructor for all contained objects is called. > > Yeah, C++ does try to be helpful, and all of those automatic copy > constructor, assignment operator and destructor implementations screw > up royally when confronted with pointers I think that those are newbie problems. The rules for those three "default implementations" are simple and match what C does for structs. Use the standard containers, make a habit of forbidding copying of objects which make no sense copying, and remember the "explicit" keyword, and you will rarely have problems with this. > (and being able to use > pointers is basically the whole reason for bothering to write anything > in C or C++ in the first place). Is it? I rarely use pointers in C++ as anything but a kind of object reference, and mostly because I am forced to. I use C++ because it is an expressive language with static typing, which has access to all the hundreds of libraries with a C API on my (Unix) machine. And because it is fun to use. I use Python because it is an expressive language with dynamic typing, which has access to the most important libraries with a C API on my (Unix) machine. And because it is fun to use. > Code which relies on these default > method implementations is almost certain to be rife with memory leaks > and double-free bugs. So instead of being a convenience, they become a > painfully easy way of writing code that silently does some very, very > wrong things. I have worked with old code with those kinds of bugs. It's simple to check and fix. If a class has pointer members of the Has-A type, the constructors, operator= and destructor have to handle them (or be suppressed). If they don't, the code is broken. If you grasp the concept of invariants, it's hard to get wrong. An object of type Foo has a number of valid states. You have to make sure there are no ways to create a Foo which is in an invalid state, or destroying one without cleaning up its state. The best way is usually to construct it from members which make similar guarantees, e.g. the standard containers. > Other things like methods (including destructors!) being non-virtual > by default also make C++ code annoyingly easy to get wrong (without it > obviously looking wrong). The other side of the coin is that you can write tiny classes in C++ with *no overhead*. If my class Foo can be implemented as an integer, it doesn't need to be slower or take more space than an integer. It can have value semantics, live on the stack etc, like an integer. I assume Java programmers avoid such types, and I assume it decreases type safety in their programs. Ok, it could have been the other way around so that there was a "nonvirtual" keyword ... but on the other hand I use inheritance in C++ about as often as in Python, i.e. almost never. > The whole design of C++ is riddled with premature optimisation of > speed and memory usage in the default settings, instead of choosing > safe defaults and providing concise ways of allowing the programmer to > say "I know optimisation X is safe here, please use it". "Premature optimization" is a phrase which is always useful as a weapon, isn't it? But yeah, I think we can agree about this, at least: when you program in both Python and C++, it is painfully obvious that C++ never sacrifices speed or correctness, and it is painfully obvious that the programmer pays a price for this. Compare ... maybe, for example, the C++ standard library's very detailed and general iterator and algorithm concepts with things like Python's str.split and str.join. A function which takes a list of strings plus a delimiter and returns a string would be unthinkable in the C++ standard library. > That said, C++ code has one *huge* benefit over ordinary C code, which > is scope-controlled deletion of objects, and the associated Resource- > Acquisition-Is-Initialisation model. Yes, RAII is one big advantage over any other language I know of. Compared to good old C, I can come up with many others. I was going to say something about C++ versus Java here, but the fact is I haven't written more than a few pages of Java since it came out. The language (or the culture around it) seems to want to isolate itself from the rest of the world -- unlike C++ and Python. /Jorgen -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! From rorymckinleylists at gmail.com Sat Apr 5 16:37:57 2008 From: rorymckinleylists at gmail.com (Rory McKinley) Date: Sat, 05 Apr 2008 22:37:57 +0200 Subject: Weird scope error In-Reply-To: <47F7A41C.4090402@islandtraining.com> References: <47F79A78.4010207@gmail.com> <47F7A41C.4090402@islandtraining.com> Message-ID: <47F7E325.9060603@gmail.com> Gary Herron wrote: > Python has no such thing as this kind of a "global scope". (True, each > module has its own global scope, but that's not what you are talking > about.) So you'll have to fix the import for *every* module that needs > access to ElementTree. You might make the change as you mentioned > above for each, but really, I think you should just make ElementTree > directly importable by either installing it normally or including > .../xml/etree in your PYTHONPATH Thank you Gary and Kay for the response My apologies for being dense with regard to this: If I understand your responses correctly, the "from xml.etree import ElementTree" that I inserted is failing? And that is why I am getting the NameError in the method? Is Python just ignoring the failure? Rory From lists at cheimes.de Thu Apr 24 09:00:06 2008 From: lists at cheimes.de (Christian Heimes) Date: Thu, 24 Apr 2008 15:00:06 +0200 Subject: How to get inner exception traceback In-Reply-To: <09ce6c51-3c23-4fb7-a369-d357c0f5d287@m73g2000hsh.googlegroups.com> References: <67b8nuF2m1a1kU1@mid.individual.net> <09ce6c51-3c23-4fb7-a369-d357c0f5d287@m73g2000hsh.googlegroups.com> Message-ID: <48108456.2020405@cheimes.de> bockman at virgilio.it schrieb: > On 24 Apr, 13:20, Thomas Guettler wrote: >> Hi, >> >> How can you get the traceback of the inner exception? >> >> try: >> try: >> import does_not_exit >> except ImportError: >> raise Exception("something wrong") >> except: >> ... >> >> Background: In Django some exceptions are caught and a new >> exception gets raised. Unfortunately the real error is hard >> to find. Sometimes I help myself and change (in this example) >> ImportError to e.g. IOError and then I can see the real root >> of the problem. But maybe there is a way to get the inner >> exception and its traceback. This could be displayed in the >> debug view. >> >> Thomas >> >> -- >> Thomas Guettler,http://www.thomas-guettler.de/ >> E-Mail: guettli (*) thomas-guettler + de > > I'm not sure it ill work since sys.exc_info() might not return a deep > copy of the traceback info, > but you could try to store the inner exception and its traceback as > attributes of the outer exception: > > class ReraisedException(Exception): > def __init__(self, message, exc_info): > Exception.__init__(self, message) > self.inner_exception = exc_info > > try: > try: > import does_not_exit > except ImportError: > raise ReraisedException("Something wrong", sys.exc_info() ) > except ReraisedException, e: > ... # here you can use e.inner_exception > except: This may lead to reference cycles, please read http://docs.python.org/dev/library/sys.html#sys.exc_info Christian From mcat.schaefer at gmx.de Tue Apr 8 05:02:17 2008 From: mcat.schaefer at gmx.de (=?ISO-8859-1?Q?Michael_Sch=E4fer?=) Date: Tue, 8 Apr 2008 02:02:17 -0700 (PDT) Subject: Calling CVF-Fortran-dll with ctypes and simple structure References: <60915c2d-0c0d-42fc-8b02-5fb58e13a20c@p25g2000hsf.googlegroups.com> Message-ID: Gabriel, works perfect - even in complex nested structures! Thank you very much! > (If both Fortran and VB say "char*9", why did you choose a pointer here?) I do not know this possibility. Could you please drop me a few lines? -- Michael From fr5478bey at gmail.com Sat Apr 26 11:41:43 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:41:43 -0700 (PDT) Subject: vegas crack Message-ID: <70012696-bc78-4342-82ec-7891f0150278@a23g2000hsc.googlegroups.com> vegas crack http://cracks.00bp.com F R E E C R A C K S From m.otteneder at gmail.com Mon Apr 7 12:05:57 2008 From: m.otteneder at gmail.com (mc) Date: Mon, 7 Apr 2008 09:05:57 -0700 (PDT) Subject: Mathematical Python Library Message-ID: I'm looking for a library which can do mathematical stuff like solving equations. Or calculation the nulls of a function and so on. Does anyone know one? Thanks in advance! From bbxx789_05ss at yahoo.com Sun Apr 6 18:12:37 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sun, 6 Apr 2008 15:12:37 -0700 (PDT) Subject: Tkinter, a lot of buttons, make prog shorter? References: Message-ID: <688483d9-2c6a-4e2a-b64d-f32bb27699ec@p25g2000hsf.googlegroups.com> On Apr 6, 1:59?pm, skanem... at yahoo.se wrote: > is there anyway to make this shorter? i hate having these big blocks > of similar-looking code, very unaesthetic. > maybe doesnt matter good-code-wise? > anyway can i make some function that makes this shorter? > like put the etiquettes on the button froma string of > '123+456-789*0Cr/' ? > problem is the command and lambda-func for each button is different. > > ? ? ? ? self.btnDisplay = Button(self,text='1',command=lambda > n="1":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=3, column=0) > > ? ? ? ? self.btnDisplay = Button(self,text='2',command=lambda > n="2":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=3, column=1) > > ? ? ? ? self.btnDisplay = Button(self,text='3',command=lambda > n="3":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=3, column=2) > > ? ? ? ? self.btnDisplay = Button(self,text='+',command=lambda > n="+":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=3, column=3) > > ? ? ? ? self.btnDisplay = Button(self,text='4',command=lambda > n="4":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=4, column=0) > > ? ? ? ? self.btnDisplay = Button(self,text='5',command=lambda > n="5":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=4, column=1) > > ? ? ? ? self.btnDisplay = Button(self,text='6',command=lambda > n="6":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=4, column=2) > > ? ? ? ? self.btnDisplay = Button(self,text='-',command=lambda > n="-":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=4, column=3) > > ? ? ? ? self.btnDisplay = Button(self,text='7',command=lambda > n="7":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=5, column=0) > > ? ? ? ? self.btnDisplay = Button(self,text='8',command=lambda > n="8":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=5, column=1) > > ? ? ? ? self.btnDisplay = Button(self,text='9',command=lambda > n="9":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=5, column=2) > > ? ? ? ? self.btnDisplay = Button(self,text='*',command=lambda > n="*":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=5, column=3) > > ? ? ? ? self.btnDisplay = Button(self,text='0',command=lambda > n="0":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=6, column=0) > > ? ? ? ? self.btnDisplay = > Button(self,text='C',command=self.Clean,width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=6, column=1) > > ? ? ? ? self.btnDisplay = Button(self,text='r',command=lambda > n="r":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=6, column=2) > > ? ? ? ? self.btnDisplay = Button(self,text='/',command=lambda > n="/":self.Display(n),width=2,height=2) > ? ? ? ? self.btnDisplay.grid(row=6, column=3) You said you were an experienced programmer, but you keep posting code with the same mistakes over and over again. Why are you attaching the buttons to self? From paul.anton.letnes at gmail.com Thu Apr 10 01:57:56 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Thu, 10 Apr 2008 07:57:56 +0200 Subject: wrapping C functions in python In-Reply-To: <54b165660804091355m1326f7c0g1a5eebe3d6b5a1df@mail.gmail.com> References: <54b165660804091322w690e5e64x85c3d8f082b411b2@mail.gmail.com> <54b165660804091355m1326f7c0g1a5eebe3d6b5a1df@mail.gmail.com> Message-ID: <1C8AE033-9B8F-4514-8C52-3462CF6447A2@gmail.com> Brian and Diez: First of all, thanks for the advice. Brian: I have installed NumPy and SciPy, but I can't seem to find a wavelet transform there. The main point of this was more to learn C wrapping than to actually get a calculation done. I will probably be starting a PhD soon, doing really heavy computations. If I want to manipulate data (input / results), python is very nice, especially with gnuplot-py. However, heavy calculations should probably be done in C(++), especially as some code for this already exists. I will look into SWIG. Diez: I will look into it. Do you know a good tutorial for this? I found the "standard" tutorial on C extensions, http://www.python.org/doc/ext/intro.html , but as I mentioned, it seems to be a bit complicated to wrap heavy data structures like arrays. Cheers PA. From castironpi at gmail.com Fri Apr 25 00:43:42 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Thu, 24 Apr 2008 21:43:42 -0700 (PDT) Subject: Little novice program written in Python References: Message-ID: <766ad2f7-08ce-47b8-9c10-19aca9059b16@d45g2000hsc.googlegroups.com> On Apr 24, 11:09?pm, Dennis Lee Bieber wrote: > On Thu, 24 Apr 2008 21:31:15 -0300, Rog?rio Brito > declaimed the following in comp.lang.python: > > > a = [i for i in range(0,n+1)] > > ? ? ? ? Uhm... At least in 2.4 and earlier, range() returns a list... No > need for the list-comp in that era... range() also begins with 0 > > > > >>> n = 5 > >>> a = range(n+1) > >>> a > [0, 1, 2, 3, 4, 5] > > ? ? ? ? So just > > ? ? ? ? a = range(n+1) > > could be used. Of course, if using a version where range() and xrange() > have been unified... > > >>> c = list(xrange(n+1)) > >>> c > [0, 1, 2, 3, 4, 5] > > -- > ? ? ? ? Wulfraed ? ? ? ?Dennis Lee Bieber ? ? ? ? ? ? ? KD6MOG > ? ? ? ? wlfr... at ix.netcom.com ? ? ? ? ? ? ?wulfr... at bestiaria.com > ? ? ? ? ? ? ? ? HTTP://wlfraed.home.netcom.com/ > ? ? ? ? (Bestiaria Support Staff: ? ? ? ? ? ? ? web-a... at bestiaria.com) > ? ? ? ? ? ? ? ? HTTP://www.bestiaria.com/ You're talking hardware-native, which machines don't guarantee. Python can in another dimension of machine compatibility. Stacks are hardware native, the location of an array is not. Python can retrieve your stack in higher dimensions. Fortunately, Python's community is sturdy against counterproductivity en masse, so it's okay to hairbrain it. Cover features of improvements, though, and you might get a Bayes Net change to make and courses to steer. The community values the flexibility of machine- independency too. However, real numbers are not integers, so opinion mass of integer algorithms may favor C. But you just need micro-sales (and scales!) to examine the future of Python. Welcome to our group. From ch612bunn at gmail.com Sun Apr 27 09:20:44 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:20:44 -0700 (PDT) Subject: Alcohol 120% 1.9.6.5429 crack Message-ID: Alcohol 120% 1.9.6.5429 crack http://wga-cracks.crackkey.net From charleshixsn at earthlink.net Sun Apr 13 14:18:58 2008 From: charleshixsn at earthlink.net (Charles D Hixson) Date: Sun, 13 Apr 2008 11:18:58 -0700 Subject: class level properties In-Reply-To: References: Message-ID: <48024E92.2090608@earthlink.net> Peter Otten wrote: > Charles D Hixson wrote: > > >> I want a hundred or so read-only variables, and I'm not sure the best >> way to achieve it. >> > > What do you really want to do? I recommend that you forget about bondage and > rely upon displine: > > class Test(object): > """Never change an attribute with an uppercase name.""" > SIMPLE = "simple example working" > > Now that was easy... > > Peter > > What I'm doing it translating Java code which has a large number of "public static final (type)" variables. As to your answer ... yes, and with good discipline you can write object oriented code in C and never need a garbage collector. It's *not* a good answer. Before I'd chose that one, I'd make it necessary to instantiate the class before testing the value of it's constants. It's just that that seems to be a silly requirement, so I'd like to avoid it. (That's the "solution" that I currently have working with __getattr__.) From gherron at islandtraining.com Fri Apr 25 14:40:23 2008 From: gherron at islandtraining.com (Gary Herron) Date: Fri, 25 Apr 2008 11:40:23 -0700 Subject: Why is None <= 0 In-Reply-To: References: Message-ID: <48122597.9090909@islandtraining.com> Gregor Horvath wrote: > Hi, > > >>> None <= 0 > True > > Why? > Is there a logical reason? > > Gregor > -- > http://mail.python.org/mailman/listinfo/python-list In early Python, the decision was made that the comparison of *any* two objects was legal and would return a consistent result. So objects of different types will compare according to an ordering on their types (an implementation dependent, unspecified, but consistent ordering), and objects of the same type will be compared according to rules that make sense for that type. Other implementations have the right to compare an integer and None differently, but on a specific implementation, the result will not change. Python 3 will raise an exception on such comparisons. Gary Herron From webograph at eml.cc Sat Apr 26 20:48:22 2008 From: webograph at eml.cc (webograph) Date: Sun, 27 Apr 2008 02:48:22 +0200 Subject: Why can't timedeltas be divided? In-Reply-To: <200605251402.15646.maric@aristote.info> References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> Message-ID: <4813CD56.40800@eml.cc> On Thu, 25 May 2006, maric wrote: > > The ratio of two durations has no meaning??? > Oh, sorry, sure it has, I wanted to say "it has no meaning in timedelta provided arithmetic". > It's a ratio (no dimension) not a duration. In that sense the expected result should be a float, and the proposed operator will break the timedelta's arithmetic consistence. > > t, u, v <- timedeltas > t+u # valid > t / u # valid > t / u + v # invalid while all terms are valids > why is this a problem? not every structure has to form a closed mathematical field, and there are other cases in which dividing similar values yields another structure (think of calculating `factor = speed2/speed1; distance2 = factor * distance1`) is there any hope this can be fixed? defining timedelta/timedelta division could not break existing code because no such division is defined yet. > num_weeks = (time_diff.days * 24* 3600 + time_diff.seconds) / (7.*24*3600) this requires domain knowledge i'd expect a time structure to provide! as you can create a timedelta by timedelta(seconds=1234567), i think it is not too much to ask to have some simple way to get back the 1234567 seconds without thinking about what intervals (currently days, seconds and microseconds) are used internally. sorry for bringing up such an old thread, but this seems important to me -- up to now, there are thousands [1] of python programs that use hardcoded time calculations. regards webograph [1] http://www.google.com/codesearch?q=60|3600+24+timedelta+lang%3Apython (gave me about 2000) From sn at sncs.se Fri Apr 18 01:41:13 2008 From: sn at sncs.se (Sverker Nilsson) Date: Thu, 17 Apr 2008 22:41:13 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <66q33cF2krjf2U1@mid.uni-berlin.de> <4807dceb$1@news.mel.dft.com.au> Message-ID: <4d823ed4-d275-4d68-a4af-873b015c431d@m44g2000hsc.googlegroups.com> On Apr 18, 1:27 am, John Machin wrote: > Diez B. Roggisch wrote: > >> And I have been benefiting from Python in general, so far. Thanks, > >> community. > > >> But now... I'll probably stop posting here for now, & I may stop other > >> things too. > > >> Just my 2c. > > > You know what I was just wondering about? All these C-written > > cross-platform libraries (which Python users benefit from, most probably > > including evven you) that run on different unixes & windows, which are a > > much greater diversity to handle than the not-even-yet-settled > > differences between Py3K & 2.x. How the heck do they do that? > > > Oh, and these dreaded 64 bit processors, possibly with multi-cores, > > which need changes in code as well, to be utilized to their power. > > > But then, these guys most probably don't whine about diversity and > > constant change, and cry out useless threats to people who probably > > can't care less. > > > Fare well, if you must. But getting mad over something which impact you > > can't even judge right now is childish. Nothing else. > > At the start of this thread I was pondering the possible meaning of the > verb "to sverk". Thanks for the exposition, Diez. Yah, and I am getting all the more depressed. Thanks? From R.Brodie at rl.ac.uk Thu Apr 17 11:55:37 2008 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Thu, 17 Apr 2008 16:55:37 +0100 Subject: Unicode chr(150) en dash References: <48063434$0$36327$742ec2ed@news.sonic.net> Message-ID: wrote in message news:mailman.595.1208445083.17997.python-list at python.org... > I think I understand the unicode basic principles, what confuses me is the usage > different applications > make out of it. > > For example, I got that EN DASH out of a web page which states > at the beggining. That's why I did go for > that > encoding. But if the browser can properly decode that character using that encoding, > how come > other applications can't? Browsers tend to guess what the author intended a lot. In particular, they fudge the difference between ISO8859-1 and Windows-1252. http://en.wikipedia.org/wiki/Windows-1252 From cwitts at gmail.com Tue Apr 15 07:26:08 2008 From: cwitts at gmail.com (Chris) Date: Tue, 15 Apr 2008 04:26:08 -0700 (PDT) Subject: where is pythoncard program ? References: Message-ID: On Apr 15, 1:04?pm, bvidinli wrote: > i installed pythoncard, but i could not find how to start it ? > where can i find its executable/binary ? > or menu item ? > or command line that i should ?enter ? > > thanks. > > -- > ?.Bahattin Vidinli > Elk-Elektronik M?h. > ------------------- > iletisim bilgileri (Tercih sirasina gore): > skype: bvidinli (sesli gorusme icin,www.skype.com) > msn: bvidi... at iyibirisi.com > yahoo: bvidinli > > +90.532.7990607 > +90.505.5667711 If you installed it on a windows box it creates a folder for it Start - > Programs -> PythonCard. The files by default are located under PythonX.x\Lib\site-packages\PythonCard From istvan.albert at gmail.com Tue Apr 22 10:22:13 2008 From: istvan.albert at gmail.com (Istvan Albert) Date: Tue, 22 Apr 2008 07:22:13 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> On Apr 22, 6:25 am, azrael wrote: > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. > This hurts. Please give me informations about realy famous > aplications. you could show him what Master Yoda said when he compared Python to Perl http://www.personal.psu.edu/iua1/pythonvsperl.htm i. From d.bollmann at tu-berlin.de Wed Apr 23 05:48:33 2008 From: d.bollmann at tu-berlin.de (Dietrich Bollmann) Date: Wed, 23 Apr 2008 18:48:33 +0900 Subject: Error in Extending/Embedding FAQ, point 16: How do I tell "incomplete input" from "invalid input"? In-Reply-To: <1208880579.4557.70.camel@pippi.pippi> References: <1208877167.4557.37.camel@pippi.pippi> <1208880579.4557.70.camel@pippi.pippi> Message-ID: <1208944113.4294.32.camel@pippi.pippi> Hi, I found a solution thanks to another posting on c++-sig and an answer by Andreas Kl?ckner :) Thank you, Andreas! The thread is here: http://mail.python.org/pipermail/c++-sig/2008-April/thread.html#13470 I would like to inform the responsible of the Python Extending/Embedding FAQ, http://www.python.org/doc/faq/extending/ about the broken code in the FAQ and the solution I found. I hope this might prevent other people from the frustration I found myself in this morning (...but unfortunately also, at least partly, from the joy I am experiencing now, after finding the new solution :). Does anybody know how to contact the person in charge? Thanks, Dietrich PS: Of course, I still wonder about the "invalid syntax" error message / code I wrote about. But ok, I hope there will be some more adequate error message / code some day in the future :) On Wed, 2008-04-23 at 01:09 +0900, Dietrich Bollmann wrote: > On Wed, 2008-04-23 at 00:12 +0900, Dietrich Bollmann wrote: > > The following code for example: > > > > >>> eins = [1, > > ... 2, > > ... 3] > > >>> > > > > is accepted without any problem by the Python shell. > > > > When using the code from the FAQ and entering it line by line > > ?already the second line causes a simple "invalid syntax" error: > > > > >>> eins = [1, > > ... 2, > > File "", line 2 > > 2, > > ^ > > SyntaxError: invalid syntax > > By the way - isn't this error message / error code just "wrong" in > the given situation and therefor kind of a "bug"? > > An "end of file" or "incomplete input" error at least would > describe the situation much better - and be a better base for > functionality which is based the error code also. > > --- > > I also thought that I should explain a little bit more exactly, > what I am intending to do with the code based on > paragraph 16 (How do I tell "incomplete input" from "invalid input"?) > of the Extending/Embedding FAQ: > > I am using Python as scripting language in an application (blender). > In order to interface this application from other programs > I programmed a python command port / command socket > for this application. > > Between other clients I also wrote a shell client which connects via > the command port to the application. My goal is to make it as similar > to a normal python shell as possible - and therefor I try to also mimic > the "intelligent" way of the Python shell to react to Python input: > > - when entering a line which is a complete input, > it is immediately evaluated by the shell and the > result is printed. > > - when the last entered line is erroneous, > an error message is printed immediately > > - when the input is incomplete, Python waits > for other lines to complete the input > > - when the line is part of a function definition etc. > python waits until an empty line is entered > before accepting the input as complete. > > My problem is to understand when an input is erroneous and > when it is incomplete - which is impossible with an error message > like "invalid syntax"... > > So here again my question: How can I make the difference > between an incomplete and an erroneous input? > > The code examples in the FAQ worked fine until now - but do not > anymore for the current Python implementation. > > Thanks, Dietrich > > By the way: Does anybody know who is responsible for the FAQ > and could adapt the examples to the current Python version > by changing the code / annotating it? > > > On Wed, 2008-04-23 at 00:12 +0900, Dietrich Bollmann wrote: > Hi, > > > > Both code examples from paragraph 16 from the Python Extending / > > Embedding FAQ - 'How do I tell "incomplete input" from "invalid > input"?' > > - > > > ( http://www.python.org/doc/faq/extending/#how-do-i-tell-incomplete-input-from-invalid-input ) do not work with the current state of Python anymore. > > > > In the second code example, the error message returned by Python is > > checked in order to differentiate errors caused by an incomplete input > > from other syntax errors: > > > > if (PyArg_ParseTuple (val, "sO", &msg, &obj) && > > !strcmp (msg, "unexpected EOF while parsing")) /* E_EOF */ > > > > In the current Python version there are more error messages indicating > an > > incomplete Python input and I could make the code work for a while > > by adding the following strings to the condition: > > > > /* error messages indicating an incomplete input */ > > if (PyArg_ParseTuple(error, "sO", &message, &obj) && > > (!strcmp(message, "unexpected EOF while parsing") || > > !strcmp(message, "expected an indented block") || > > !strcmp(message, "EOF while scanning triple-quoted string") > > ) > > ) { /* E_EOF */ > > > > but recently there are also cases which generate error messages > > which are too general to be added to this list. > > > > The following code for example: > > > > >>> eins = [1, > > ... 2, > > ... 3] > > >>> > > > > is accepted without any problem by the Python shell. > > > > When using the code from the FAQ and entering it line by line > > ?already the second line causes a simple "invalid syntax" error: > > > > >>> eins = [1, > > ... 2, > > File "", line 2 > > 2, > > ^ > > SyntaxError: invalid syntax > > > > which is to general to be integrated into the list of tested > > error messages as it might be caused also by code like: > > > > >>> one two > > File "", line 1 > > one two > > ^ > > SyntaxError: invalid syntax > > > > which generates an "invalid syntax" error even in the Python shell. > > > > I also tried the first code example of paragraph > > '16 How do I tell "incomplete input" from "invalid input"?' > > of the FAQ in order to see if it could be used to make the > > difference between syntax errors and incomplete code errors. > > But - as in the case before - the returned error > > code is E_SYNTAX (14 = Syntax error) and not E_EOF (11 = End Of File) > > as should be expected. > > > > Is there anybody who has an idea how to differentiate the > > first case from the second in order to mimic the behaviour of > > the Python shell from c code? > > > > If this shouldn't be possible lists split into different lines > > couldn't be accepted anymore or the feature of the Python shell > > to described in paragraph 16 of the faq: > > > > Sometimes you want to emulate the Python interactive interpreter's > > behavior, where it gives you a continuation prompt when the input > > is incomplete (e.g. you typed the start of an "if" statement or you > > didn't close your parentheses or triple string quotes), but it > gives > > you a syntax error message immediately when the input is invalid. > > > > would have to be given up and every entered line of code would have > to > > be terminated by an empty line before evaluation :( > > > > Thanks for any help, Dietrich > > > > > > > > > > From roy at panix.com Wed Apr 23 00:56:37 2008 From: roy at panix.com (Roy Smith) Date: Wed, 23 Apr 2008 00:56:37 -0400 Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: In article , Steve Holden wrote: > Challenge him to a dual with dead kippers at twenty paces. You gotta be careful about stuff like this. You might slap him with a dead kipper only to discover he's got a dead camel in his pocket. Of course, there's always http://en.wikipedia.org/wiki/Wikipedia:Trout From deets at nospam.web.de Tue Apr 29 19:43:04 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 30 Apr 2008 01:43:04 +0200 Subject: python command mis-interprets arrow keys In-Reply-To: References: <67pp4oF2ppl3sU1@mid.uni-berlin.de> Message-ID: <67pq47F2plmb8U1@mid.uni-berlin.de> Rahul schrieb: > "Diez B. Roggisch" wrote in > news:67pp4oF2ppl3sU1 at mid.uni-berlin.de: > >> Is libreadline installed? > > Thanks for your help Diez. I did a locate and found: > > /usr/lib/libreadline.a > /usr/lib/libreadline.so > /usr/lib/libreadline.so.5 > /usr/lib/libreadline.so.5.1 > /usr/local/src/Python-2.4.4/Doc/lib/libreadline.tex > > Any better way to check? The question is if python is build with readline support. Did the python version work before, and somehow got messed up, or did you build it yourself and it never actually worked? If it's the latter case, you might try & install a possible readline-dev-package (or whatever it is called on red hat), and build again, cautiously monitoring if readline is picked up from the build-process. Diez From thinkofwhy at yahoo.ca Sun Apr 27 14:29:46 2008 From: thinkofwhy at yahoo.ca (telus news) Date: Sun, 27 Apr 2008 18:29:46 GMT Subject: diffing and uniqing directories In-Reply-To: References: <67ioqmF2nvf5vU2@mid.uni-berlin.de> Message-ID: Just so happens that I am partially finished a gui file backup app. I have many backup CDs and I wanted to consolidate them. You know, all image files in one dir, all install files in another dir, etc. My app scans the input dir tree and displays all file extensions that it finds. You can then remove any extensions that you don't want backed-up, and you can toggle to exclude the listed extensions. It also calculates min/max file sizes that you can adjust. Then the next page allows you to adjust the sub-dir depth with a slider, which displays the total number of files and total amount of memory they will take, for each sub-dir depth. You can also choose to enable versioning, whether or not to put all files into one dir or create a dir for each file type (extension), whether or not to actually backup the files, to write all input pathnames and/or output pathnames to a file. Of course, it won't backup a dir tree as a copy, it can only flatten a dir tree, so if you backup a development source dir, all files will get put into the same dir and that wouldn't be good. I've also used py2exe to make it a drag-n-drop install. What do you think? wrote in message news:bf7b9788-c108-4dad-bffe-49ff8e12bcb4 at a22g2000hsc.googlegroups.com... On Apr 27, 2:37 am, Marc 'BlackJack' Rintsch wrote: > On Sat, 26 Apr 2008 20:35:29 -0700, rustom wrote: > > On Apr 27, 12:31 am, castiro... at gmail.com wrote: > >> On Apr 26, 1:14 pm, "Rustom Mody" wrote: > >> [?] > > > If this is an answer to my question I dont understand it! > > castironpi is either a bot or trolling. Just ignore its posts. > > Ciao, > Marc 'BlackJack' Rintsch I am a bot or trolling. Bots and bot detectors were the first forms of internet life, you know. From nagle at animats.com Wed Apr 16 16:21:46 2008 From: nagle at animats.com (John Nagle) Date: Wed, 16 Apr 2008 13:21:46 -0700 Subject: Default parameter for a method In-Reply-To: <806788d2-67b7-456b-bd1e-08c50cbf0f7b@8g2000hsu.googlegroups.com> References: <806788d2-67b7-456b-bd1e-08c50cbf0f7b@8g2000hsu.googlegroups.com> Message-ID: <48065d11$0$36390$742ec2ed@news.sonic.net> s0suk3 at gmail.com wrote: > I wanted to know if there's any way to create a method that takes a > default parameter, and that parameter's default value is the return > value of another method of the same class. For example: > ... > > def meth2(self, arg=meth1()): Not good. If the default value of an argument is mutable, there are wierd effects, because the default value is bound once when the class is created, then shared between all later uses. This is almost never what was wanted or intended, and it's a common source of subtle bugs. In general, default values should be immutable constants only. There's been talk of fixing this (it's really a design bug in Python), but for now, it's still broken. (I just had horrible thoughts about the implications of binding a closure to a default argument. You don't want to go there.) John Nagle From ch612bunn at gmail.com Sun Apr 27 09:16:29 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:16:29 -0700 (PDT) Subject: kaspersky 7 crack Message-ID: kaspersky 7 crack http://wga-cracks.crackkey.net From kkuhl05 at gmail.com Tue Apr 29 01:26:33 2008 From: kkuhl05 at gmail.com (Kevin K) Date: Mon, 28 Apr 2008 22:26:33 -0700 (PDT) Subject: File IO Issues, help :( Message-ID: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> Hey everyone, I'm new to python and am trying to do a little project with it. I'm running into problems writing over a file. I read from the file and loop through for a specfic case in which I change something. After I open and give it opening options (w, r, etc) one of two things happens: either the file gets truncated and my writing never takes place (or it seems it doesnt) or everything is appended to the file and I have a double of what I started with, its never just the updated file. Can someone shed some light on this for me?? Code below: jsfile = open("../timeline.js", "r+") jscontent = jsfile.readlines() jsfile.truncate() for line in jscontent: if re.search('var d =', line): line = "var d = \""+mint['1'].ascdate()+"\"\n" print line jsfile.write(line) From fetchinson at googlemail.com Wed Apr 16 12:11:09 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Wed, 16 Apr 2008 09:11:09 -0700 Subject: Finally had to plonk google gorups. In-Reply-To: <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: > > > On Apr 16, 9:19 am, Grant Edwards wrote: > > >> This morning almost half of c.l.p was spam. In order to try to > > >> not tar both the benign google group users and the malignant > > >> ones with the same brush, I've been trying to kill usenet spam > > >> with subject patterns. But that's not a battle you can win, so > > >> I broke down and joined all the other people that just killfile > > >> everything posted via google.groups. > > > > >> AFAICT, if you're a google groups user your posts are not being > > >> seen by many/most experienced (read "non-google-group") users. > > >> This is mainly the fault of google who has refused to do > > >> anything to stem the flood of span that's being sent via Google > > >> Groups. > > > > >> -- > > >> Grant Edwards grante Yow! I would like to > > >> at urinate in an > OVULAR, > > >> visi.com porcelain pool -- > > > > > Yeah, I noticed that Google Groups has really sucked this week. I'm > > > using the Google Groups Killfile for Greasemonkey now and it helps a > > > lot. I like Google, but my loyalty only goes to far. This is a > > > complete lack of customer service. > > > > Unfortunately this means Google groups users are getting exactly the > > service they are paying for. > > > > regards > > Steve > > -- > > Steve Holden +1 571 484 6266 +1 800 494 3119 > > Holden Web LLC http://www.holdenweb.com/ > > Steve, > > My workplace doesn't offer NNTP, so there is no good way to browse > c.l.py here. And I haven't been able to get NNTP to work from my home > either. > > By applying this logic to Python and Linux (or any Open Source > product), they shouldn't be used either (since I'm not paying for > them). > > Mike Mike, Steve did not say you (or anyone) should not use google groups. He said you get what you paid for, which is certainly the case. Some open source products are good and some are worse, that's all. Full disclosure: I'm using google groups for both reading and writing. Cheers, Daniel From ajaksu at gmail.com Tue Apr 15 10:37:27 2008 From: ajaksu at gmail.com (ajaksu) Date: Tue, 15 Apr 2008 07:37:27 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> Message-ID: On Apr 14, 11:07?pm, Sverker Nilsson wrote: > What serious reports? You almost had me collecting a list of reports/references. Almost :) Google and you'll find them. Regards, Daniel From mfb.chikazuku at gmail.com Wed Apr 9 17:43:45 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Wed, 09 Apr 2008 23:43:45 +0200 Subject: Stripping scripts from HTML with regular expressions References: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: <47fd46b3$0$6838$2d805a3e@textnews.eweka.nl> Reedick, Andrew wrote: > > >> -----Original Message----- >> From: python-list-bounces+jr9445=att.com at python.org [mailto:python- >> list-bounces+jr9445=att.com at python.org] On Behalf Of Michel Bouwmans >> Sent: Wednesday, April 09, 2008 3:38 PM >> To: python-list at python.org >> Subject: Stripping scripts from HTML with regular expressions >> >> Hey everyone, >> >> I'm trying to strip all script-blocks from a HTML-file using regex. >> >> I tried the following in Python: >> >> testfile = open('testfile') >> testhtml = testfile.read() >> regex = re.compile(']*>(.*?)', re.DOTALL) > > > Aha! \b is being interpolated as a backspace character: > \b ASCII Backspace (BS) > > Always use a raw string with regexes: > regex = re.compile(r']*>(.*?)', re.DOTALL) > > Your regex should now work. > > > > ***** > > The information transmitted is intended only for the person or entity to > which it is addressed and may contain confidential, proprietary, and/or > privileged material. Any review, retransmission, dissemination or other > use of, or taking of any action in reliance upon this information by > persons or entities other than the intended recipient is prohibited. If > you received this in error, please contact the sender and delete the > material from all computers. GA622 Thanks! That did the trick. :) I was trying to use HTMLParser but that choked on the script-blocks that didn't contain comment-indicators. Guess I can now move on with this script, thank you. MFB From spam-trap at telus.net Wed Apr 30 14:06:30 2008 From: spam-trap at telus.net (L. Lindstrom) Date: Wed, 30 Apr 2008 18:06:30 GMT Subject: Python 2.6 and wrapping C libraries on Windows Message-ID: I have read that Python extension modules must link to the same C run-time as the Python interpreter. This I can appreciate. But does this requirement extend to the C libraries an extension module wraps. The case in point is Pygame and SDL. The Pygame extension modules are built with distutils, so for Python 2.6 using Visual Studio 2008 should ensure the .pyd files link to msvcr90.dll. But SDL is built using Msys/MinGW and the configure/make tool chain. This fails when linking to msvcr90.dll since the small test programs configure builds lack manifest files. They fail to load msvcr90.dll, raising an R6034 error instead. So besides heap management and FILE pointers, is there any reason SDL, or any C dependency, needs to link to the same C run-time as Python? If I ensure SDL frees memory it allocates and does not directly access a file opened by Python can I just use another C run-time such as msvcrt? -- Lenard Lindstrom "%s@%s.%s" % ('len-l', 'telus', 'net') From cmpython at gmail.com Mon Apr 7 01:34:53 2008 From: cmpython at gmail.com (CM) Date: Sun, 6 Apr 2008 22:34:53 -0700 (PDT) Subject: Learning curve for new database program with Python? References: Message-ID: On Apr 5, 11:50 am, Jetus wrote: > I have a need for a database program. I downloaded the db2 from ibm, > and reviewed some of the documentation. > > My question is, what is the easiest program for me to try to learn. I > will be creating a database of about 25,000 records, it will be > relational. I am a beginner Python programmer, and need a database > solution that is easy to grasp. I played with sql, > and found that very difficult, if not overly cumbersome. > > A database that could work with Django would be very interesting to > look at as well.. > > Any suggestions out there? >From the good people at Django: "If you want to use Django with a database, which is probably the case, you'll also need a database engine. PostgreSQL is recommended, because we're PostgreSQL fans, and MySQL, SQLite 3, and Oracle are also supported." And if you want to make it a relational database, pretty much it's SQL as the language. And that's ok--it really is not hard at all, I picked it up quick and I'm new to databases; it's rather like a natural language. I've had success with keeping things simple with Python + SQLite--just import sqlite3 and use Python code such as: cur.execute("SELECT name FROM customers WHERE city='Chicago'") See here: http://docs.python.org/lib/module-sqlite3.html Very straightforward. Don't know how Django interacts with these two, but probably quite well, or you could choose from the other database management engines listed above. From bj_666 at gmx.net Fri Apr 25 06:35:05 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 25 Apr 2008 10:35:05 GMT Subject: Little novice program written in Python References: <49249992-3634-4c5f-bd45-7ce4f1b32044@l17g2000pri.googlegroups.com> Message-ID: <67dqepF2nmg7dU1@mid.uni-berlin.de> On Fri, 25 Apr 2008 10:24:16 +0200, Robert Bossy wrote: > John Machin wrote: >> On Apr 25, 5:44 pm, Robert Bossy wrote: >> >>> Peter Otten wrote: >>> If the OP insists in not examining a[0] and a[1], this will do exactly >>> the same as the while version: >>> >>> for p in a[2:]: >>> if p: >>> print p >>> >>> >> >> ... at the cost of almost doubling the amount of memory required. > Indeed. Would it be a sensible proposal that sequence slices should > return an iterator instead of a list? I don't think so as that would break tons of code that relies on the current behavior. Take a look at `itertools.islice()` if you want/need an iterator. Ciao, Marc 'BlackJack' Rintsch From vlastimil.brom at gmail.com Sat Apr 12 11:39:00 2008 From: vlastimil.brom at gmail.com (Vlastimil Brom) Date: Sat, 12 Apr 2008 17:39:00 +0200 Subject: sqlite3 - adding tables and rows via parameters Message-ID: <9fdb569a0804120839w6916ed96ka5b53aad7ca6f565@mail.gmail.com> Hi all, I would like to ask about the usage of sqlite3 in python, more specifically about a way to pass table or column names to a SQL commands using parameters. All examples I could find use the parameter substitution with "?" for values; is it possible the specify table and column names this way? e.g. something like curs.execute(u'INSERT OR REPLACE INTO %s(%s) VALUES (?)' % ("people", "email"), ("qwe at asd.zx",)) (And the similar cases e.g.: CREATE TABLE, ALTER TABLE ... ADD.) Unfortunately, I wasn't successful in replacing the string interpolation with the substitution notation; are there maybe any hints, how to do that? Or is it ok to use string interpolation here? (Are these parts of the SQL command vulnerable too?) What I am trying to achieve is to build a database dynamically - based on the input data the respective table would be chosen, and the appropriate columns created and filled with the content. Thanks in advance for any suggestions - and sorry if I missed something obvious... Vlasta -------------- next part -------------- An HTML attachment was scrubbed... URL: From gagsl-py2 at yahoo.com.ar Thu Apr 10 18:24:47 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 19:24:47 -0300 Subject: problem with using gnuplot/demo.py References: <574751.90080.qm@web94914.mail.in2.yahoo.com> Message-ID: En Thu, 10 Apr 2008 08:59:35 -0300, Paul Anton Letnes escribi?: > Could you include some code around line 39 in demo.py? > > Also, you could try to comment out the stuff before that point, and > see if the demo runs that far. And please include the error type and message too? -- Gabriel Genellina From BrentJRogers at gmail.com Tue Apr 29 22:54:47 2008 From: BrentJRogers at gmail.com (breroger@cisco.com) Date: Tue, 29 Apr 2008 19:54:47 -0700 (PDT) Subject: QA-Test Jobs at Cisco-IronPort Message-ID: Cisco-IronPort is looking for a topnotch Quality Assurance/ Test Engineers with experience in one or more of the following: aPython, utomation framework, performance testing, email encryption, FreeBSD, white.gray box testing, API testing, web security appliances, UNIX, RAID, LDAP, SSH, DNS, SMTP, HTTP, FTP, Telnet, RDBMS, IMAP, POP and/or tested servers. These job openings are in San Bruno. Please contact me directly if you are interested in getting more information. Regards, Brent breroger at cisco.com From cyberco at gmail.com Wed Apr 16 03:41:41 2008 From: cyberco at gmail.com (Berco Beute) Date: Wed, 16 Apr 2008 00:41:41 -0700 (PDT) Subject: webcam (usb) access under Ubuntu References: <66jlk1F2ju6c8U1@mid.uni-berlin.de> <66kkedF2l526dU2@mid.uni-berlin.de> <455760fb-8229-4be3-ba7f-7c41bdcd66de@a22g2000hsc.googlegroups.com> Message-ID: <362eb242-2adc-4d7b-9c0a-95e72f4b22b6@e67g2000hsa.googlegroups.com> On Apr 15, 11:45 pm, Berco Beute wrote: > I've tried reinstalling gstreamer (for windows): > > http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstre...http://gstreamer.freedesktop.org/pkg/windows/releases/gstreamer/gstre... > > but that didn't help. I get some complaints about 'libgstinterfaces' > as well... To be more precise, when doing an 'import gst' Python shell pops up an error dialog saying: "This application has failed to start because libgstinterfaces-0.10.dll was not found." 2B From skanemupp at yahoo.se Sun Apr 13 13:03:40 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 13 Apr 2008 10:03:40 -0700 (PDT) Subject: tkinter, canvas, get color of image? Message-ID: <0e4c9708-dbe9-4f29-ac31-34f7298f2624@m1g2000pre.googlegroups.com> mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\elmapovic.gif') w.create_image(10, 10, image = mapq, anchor = NW) after doing this is there any possibility of getting the characteristics of the GIF-picture(or bitmap if i use that)? it would be very helpfull if i for example could do something like canvas.getcolor(image, mouseclick.x,mouseclick.y) if u get the point. get the color of the image where i clicked. From skanemupp at yahoo.se Tue Apr 22 16:11:37 2008 From: skanemupp at yahoo.se (globalrev) Date: Tue, 22 Apr 2008 13:11:37 -0700 (PDT) Subject: question about the mainloop References: <52de38c4-3d1e-4be0-9b58-5d60317f1ef7@b1g2000hsg.googlegroups.com> Message-ID: <01ac8fa5-fb2c-40a3-8096-d7b84d09f1c2@p25g2000hsf.googlegroups.com> On 21 Apr, 07:31, "Gabriel Genellina" wrote: > En Mon, 21 Apr 2008 00:57:38 -0300, globalrev escribi?: > > > > > On 21 Apr, 04:26, "Gabriel Genellina" wrote: > >> En Sun, 20 Apr 2008 20:24:04 -0300, globalrev escribi?: > > >> > i dont get the mainloop() in python. i mean i have written some > >> > programs, for example a calculator using tkinterGUI. > > >> What you call the "mainloop" is the event loop (or message loop) used by event-driven applications as a way to dispatch all events as they happen in the system. The concept is independent of Python/C++/whatever language you choose. The key phrase is "event-driven programming":http://en.wikipedia.org/wiki/Event_driven_programming > >> Tkinter provides an event-driven GUI framework. Simple CLI programs are not event-driven, as your pseudo example above. > > >> > if i have some functions i wanna call to run the program and i wanna > >> > call them ina specific order and be able to call > >> > them from each other should this just be called in the mainloop and > >> > the mianloop then runs the "mainscript" top > >> > to bottom over and over? > > >> If you don't want or don't require a graphical user interface, just write the functions you need and call them from the outermost section in your script. > >> If you do require a GUI, you'll have to write the code in response to user actions: when the user clicks here, do this; when the user chooses that menu option, do that. > > > but what i mean i dont understand is sure i can bind a function to a > > buttonpress but if i have a def dox(): dododo > > and i call it with dox() in the mainscript it will be executed once, > > but not again. > > so what does the mainloop do, 1srt time it is executed it runs the > > mainscript then it it sits and wait s for commands? > > What's the "mainscript"? > The "mainloop" just waits for system events like: mouse movement, mouse click, key pressed, key released, time elapsed, window is uncovered, etc. And when any event arrives, it's dispatched to its registered handler. > Python executes whatever you wrote at the top level of the script you are running, up to the root.mainloop() line. That function doesn't return until the main window is closed; all the user interaction occurs inside that call. Finally, execution resumes on the next line, if any. > I hope this answers your question; if not, try to be more specific. Maybe an example of what you want to do. > > -- > Gabriel Genellina ty everyone i get it now. From v.harishankar at gmail.com Tue Apr 22 09:55:26 2008 From: v.harishankar at gmail.com (Harishankar) Date: Tue, 22 Apr 2008 19:25:26 +0530 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: <480DE8E1.7020601@timgolden.me.uk> References: <200804221847.43924.v.harishankar@gmail.com> <480DE8E1.7020601@timgolden.me.uk> Message-ID: <200804221925.26525.v.harishankar@gmail.com> On Tuesday 22 Apr 2008 19:02:17 Tim Golden wrote: > Well if you want to, you can reproduce the same effect by using ctypes > which *is* in the standard library. But why reinvent the wheel? The reason is once again, rightly or wrongly I feel that using non-standard extensions could make it: 1. Difficult to distribute the application as I am not able to package the third-party extension with distutils. 2. Difficult to predict its behaviour with future versions of Python. > Correct. It's part of the pywin32 extensions, one of many useful packages > available to the discerning Python programmer who doesn't feel in some way > bound to whatever comes bundled with the standard library. > > TJG I wouldn't feel "bound" if I restricted the program to myself. But if I want to distribute it (as I intend to) I have to think of others as well. -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org From ankitks.mital at gmail.com Mon Apr 7 15:41:22 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Mon, 7 Apr 2008 12:41:22 -0700 (PDT) Subject: reading dictionary's (key,value) from file References: <974814d3-59f0-49ec-9b4d-9f5dd7dfaf54@q24g2000prf.googlegroups.com> Message-ID: On Apr 7, 11:55?am, Robert Bossy wrote: > ankitks.mi... at gmail.com wrote: > > Folks, > > Is it possible to read hash values from txt file. > > I have script which sets options. Hash table has key set to option, > > and values are option values. > > > Way we have it, we set options in a different file (*.txt), and we > > read from that file. > > Is there easy way for just reading file and setting options instead of > > parsing it. > > > so this is what my option files look like: > > > 1opt.txt > > { '-cc': '12', > > ? '-I': r'/my/path/work/'} > > > 2opt.txt > > { ?'-I': r/my/path/work2/'} > > > so my scipt how has dictionary > > options = { '-cc' :'12' > > ? ? ? ? ? ? ? ? '-I': r'/my/path/work/:/my/path/work2/'} > > > I am trying to avoid parsing > > For this particular case, you can use the optparse module:http://docs.python.org/lib/module-optparse.html > > Since you're obviously running commands with different set of options, I > suggest you listen to Diez. > > Cheers, > RB- Hide quoted text - > > - Show quoted text - I think I am missing lot regarding optparser module. My only option is to have option file, and I have couple of those..each user creates it's own. How can optparser help me in this regard Thank you From paul at boddie.org.uk Fri Apr 25 07:27:16 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Fri, 25 Apr 2008 04:27:16 -0700 (PDT) Subject: Problem building python in virtual machine running centos References: Message-ID: On 25 Apr, 03:05, Alexandre Gillet wrote: > > I am trying to build python-2.4.5 on Centos 5.1, which is a virtual > machine running with xen. > I am not able to build python. The compilation crash with the following: > gcc -pthread -c -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. > -I./Include -DPy_BUILD_CORE -o Objects/unicodeobject.o > Objects/unicodeobject.c > In file included from ./Include/Python.h:76, > from Objects/unicodeobject.c:39: > ./Include/object.h:228: internal compiler error: Segmentation fault > Please submit a full bug report, > with preprocessed source if appropriate. > See for instructions. > The bug is not reproducible, so it is likely a hardware or OS problem. > > Any suggestion of what am I doing wrong? You say that the bug is not reproducible, so that means that you can sometimes compile Python, or does the crash always happen when compiling some file (not necessarily the one mentioned above)? I think I've only ever seen a reproducible gcc crash once, and that had something to do with a C++ source file which I then split into two and was able to compile as these two separate parts. You might want to check the gcc version (gcc -v) and to look at bug fixes in any later versions. Generally, if you get an internal error in gcc, you aren't doing anything wrong yourself. Paul From gagsl-py2 at yahoo.com.ar Wed Apr 9 01:14:22 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 02:14:22 -0300 Subject: String Literal to Blob References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> Message-ID: En Tue, 08 Apr 2008 13:55:07 -0300, Victor Subervi escribi?: > Thanks. I apparently am printing some holder for the image. I stripped > out > most of it with this > content[0][0] Yes, because of this: content = cursor.fetchall() fetchall returns a list of rows, each row a tuple of columns. > but then I am left with this: > > array('c', '\xff\xd8\xff\xe0\\0\x10JFI...) > How do I extract an image from that? print content.tostring() Or perhaps, replace that line with content.tofile(sys.stdout) http://docs.python.org/lib/module-array.html >> > # print 'Content-Type: image/jpeg\r\nContent-Length: %d\n' % >> len(content) Once you fix the former, you can re-enable that line. >> > print 'Content-Type: image/jpeg\r\n' >> > print '\n' >> > print content >> > print '\n' >> > cursor.close() >> > >> > test() >> > The commented out line gives me a leading less than sign...and that?s >> > it. What do? Try to understand now *why* you got a single character with your previous code. -- Gabriel Genellina From arnodel at googlemail.com Sun Apr 13 04:46:02 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 13 Apr 2008 01:46:02 -0700 (PDT) Subject: Recommendation for Web Framework References: <4801b3a6$0$7713$4c368faf@roadrunner.com> Message-ID: <360b6cbb-5f8b-4de3-92cb-62000cc4d3b3@y21g2000hsf.googlegroups.com> On Apr 13, 8:18?am, James West wrote: [...] > Ideally, I'd like something like Ruby on Rails that would provide > scaffolding support so I can bootstrap the system, so to speak. I've > looked at Django, but the client is only running Apache 1.x and Python > 2.3. Django only requires Python 2.3 IIRC, and I think you can use it with FastCGI instead of mod_python. Doesn't FastCGI only require apache 1.3.x ? -- Arnaud From ernesto.adorio at gmail.com Sun Apr 6 00:18:28 2008 From: ernesto.adorio at gmail.com (ernie) Date: Sat, 5 Apr 2008 21:18:28 -0700 (PDT) Subject: Best way to check if string is an integer? References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> Message-ID: <0fdd2825-6d1c-4380-a79a-a7aac119f002@a5g2000prg.googlegroups.com> On Apr 6, 10:23 am, Roy Smith wrote: > In article , > Steve Holden wrote: > > > > This doesn't cater for negative integers. > > > No, it doesn't, but > > > s.isdigit() or (s[0] in "+-" and s[1:].isdigit) # untested > > > does. > > I think this fails on " -1". So, then you start doing > s.strip().isdigit(), and then somebody else comes up with some other > unexpected corner case... > > int(s) and catching any exception thrown just sounds like the best way. Another corner case: Is "5.0" an integer or treated as one? regards, ernie From george.sakkis at gmail.com Thu Apr 3 18:42:02 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Thu, 3 Apr 2008 15:42:02 -0700 (PDT) Subject: id functions of ints, floats and strings References: Message-ID: zillo... at googlemail.com wrote: > 1) Which of the above behaviours are reliable? For example, does a1 = > a2 for ints and strings always imply that a1 is a2? No. > 2) From the programmer's perspective, are ids of ints, floats and > string of any practical significance at all (since these types are > immutable)? No. > 3) Does the behaviour of ids for lists and tuples of the same element > (of type int, string and sometimes even float), imply that the tuple a > = (1,) takes (nearly) the same storage space as a = 10000*(1,)? (What > about a list, where elements can be changed at will?) No. Regards, George From jason.scheirer at gmail.com Sun Apr 20 18:50:33 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Sun, 20 Apr 2008 15:50:33 -0700 (PDT) Subject: Nested lists, simple though References: Message-ID: <8788db32-30b4-4cae-ab5a-bf6051249294@a9g2000prl.googlegroups.com> On Apr 20, 3:25?pm, Zethex wrote: > Im a bit new to python. ?Anyway working on a little project of mine and i > have nested lists > > ie > > Answer = [['computer', 'radeon', 'nvidia'], ['motherboard', 'asus']] > > and so forth.., > Anyway the amount of [[]] do increase over time. ?Im just wondering is there > a simple way to add these together so they become 1 simple list, so it would > be ['computer'....'asus'] etc without the nested list. ?Its random the > amount each time so i cant just go a[0]+a[1]. > Thank you if you can help > -- > View this message in context:http://www.nabble.com/Nested-lists%2C-simple-though-tp16799674p167996... > Sent from the Python - python-list mailing list archive at Nabble.com. The first idea that comes to mind is reduce(lambda x, y: x + y, list_of_lists, []) From leoniaumybragg at gmail.com Sat Apr 26 06:57:46 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:57:46 -0700 (PDT) Subject: clonedvd crack Message-ID: <129e576a-79a8-47a6-bdcb-1cda4ac54265@24g2000hsh.googlegroups.com> clonedvd crack http://cracks.00bp.com F R E E C R A C K S From deets at nospam.web.de Tue Apr 8 13:55:06 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 08 Apr 2008 19:55:06 +0200 Subject: Is the Python for statement the same as for each in other languages? In-Reply-To: <9e8bfedb-dc75-4252-84e7-4fb96bbaa6ac@l64g2000hse.googlegroups.com> References: <9e8bfedb-dc75-4252-84e7-4fb96bbaa6ac@l64g2000hse.googlegroups.com> Message-ID: <661ps1F2ae3jnU1@mid.uni-berlin.de> jmDesktop schrieb: > Thank you. It looks like it is, but I wanted to make sure I > understood. Also, I didn't see a "regular" for loop construct either > (i=0;i<=10;i++), etc. I'm still new at it, but is there one of those? Yes, it's foreach. And for your usecase, use for i in xrange(11): ... Diez From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 3 10:36:01 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 03 Apr 2008 16:36:01 +0200 Subject: object-relational mappers In-Reply-To: References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <47f37039$0$31900$426a74cc@news.free.fr> Message-ID: <47f4eb4f$0$4959$426a74cc@news.free.fr> Jarek Zgoda a ?crit : > Bruno Desthuilliers napisa?(a): > >> Now my own experience is that whenever I tried this approach for >> anything non-trivial, I ended up building an "ad-hoc, >> informally-specified bug-ridden slow implementation of half of " >> SQLAlchemy. Which BTW is not strictly an ORM, but primarily an attempt >> at a better integration of SQL into Python. So while it may feel like >> learning the inner complexities of SQLALchemy (or Django's ORM which is >> not that bad either) is "wasting brain cells", MVHO is that it's worth >> the time spent. But YMMV of course - IOW, do what works best for you. > > I like OR mappers, they save me lot of work. The problem is, all of them > are very resource hungry, processing resultset of 300k objects one by > one can effectively kill most of commodity systems. This is where raw > SQL comes in handy. The problem here is not about how you build your query but about how you retrieve your data. FWIW, SQLAlchemy provides quite a lot of "lower level" SQL/Python integration that doesn't require the "object mapping" part. "raw SQL" is fine, until you have to dynamically build complex queries from user inputs and whatnot. This is where the "low-level" (ie: non-ORM) part of SQLAlchemy shines IMHO. From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Sun Apr 27 17:38:59 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Sun, 27 Apr 2008 23:38:59 +0200 Subject: design choice: multi-threaded / asynchronous wxpython client? References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: <67ka3jF2nqkb9U1@mid.individual.net> bullockbefriending bard wrote: > 1) The data for the race about to start updates every (say) 15 > seconds, and the data for earlier and later races updates only > every > (say) 5 minutes. There is no point for me to be hammering the > server with requests every 15 seconds for data for races after the > upcoming race... I should query for this perhaps every 150s to be > safe. But for the upcoming race, I must not miss any updates and > should query every > ~7s to be safe. So... in the middle of a race meeting the > situation might be: I don't fully understand this, but can't you design the server in a way that you can connect to it and it notifies you about important things? IMHO, polling isn't ideal. > My initial thought was to have two threads for the different > update polling cycles. In addition I would probably need another > thread to handle UI stuff, and perhaps another for dealing with > file/DB data write out. No need for any additional threads. UI, networking and file I/O can operate asynchronously. Using wxPython's timers with callback functions, you should need only standard Python modules (except wx). > But, I wonder if using Twisted is a better idea? IMHO that's only advisable if you like to create own protocols and reuse them in different apps, or need full-featured customisable implementations of advanced protocols. Additionally, you'd *have to* use multiple threads: One for the Twisted event loop and one for the wxPython one. There is a wxreactor in Twisted which integrates the wxPython event loop, but I stopped using it due to strange deadlock problems which began with some wxPython version. Also, it seems it's no more in development. But my alternative works perfectly (main thread with Twisted, and a GUI thread for wxPython, communicating over Python standard queues). You'd only need additional threads if you would do heavy number crunching inside the wxPython or Twisted thread. For the respective event loop not to hang, it's advisable to use a separate thread for long-running calculations. > I have zero experience with these kinds of design choices and > would be very happy if those with experience could point out the > pros and cons of each (synchronous/multithreaded, or Twisted) for > dealing with the two differing sample rates problem outlined > above. I'd favor "as few threads as neccessary" approach. In my experience this saves pain (i. e. deadlocks and boilerplate queueing code). Regards, Bj?rn -- BOFH excuse #27: radiosity depletion From larry.bates at websafe.com` Tue Apr 22 15:21:11 2008 From: larry.bates at websafe.com` (Larry Bates) Date: Tue, 22 Apr 2008 14:21:11 -0500 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. In-Reply-To: References: Message-ID: <6oGdnT74Vugrp5PVnZ2dnUVZ_h_inZ2d@comcast.com> Kenneth McDonald wrote: > Sadly. > > Thanks, > Ken easy_install BeautifulSoup worked for me a couple of days ago. Of course you ahve to have easy_install running, but that is quite easy and makes installation of other modules quite easy. -Larry From wizzardx at gmail.com Sun Apr 20 02:26:27 2008 From: wizzardx at gmail.com (David) Date: Sun, 20 Apr 2008 08:26:27 +0200 Subject: Checking if a text file is blank In-Reply-To: References: Message-ID: <18c1e6480804192326g663a916bqa161b5fb42c11b9d@mail.gmail.com> > > Is there any way in python to check if a text file is blank? > > What I've tried to do so far is: > > f = file("friends.txt", "w") > if f.read() is True: > """do stuff""" > else: > """do other stuff""" > f.close() > > What I *mean* to do in the second line is to check if the text file is > not-blank. But apparently that's not the way to do it. > > Could someone set me straight please? You're opening your file in write mode, so it gets truncated. Add "+" to your open mode (r+ or w+) if you want to read and write. Here is the file docstring: file(name[, mode[, buffering]]) -> file object Open a file. The mode can be 'r', 'w' or 'a' for reading (default), writing or appending. The file will be created if it doesn't exist when opened for writing or appending; it will be truncated when opened for writing. Add a 'b' to the mode for binary files. Add a '+' to the mode to allow simultaneous reading and writing. If the buffering argument is given, 0 means unbuffered, 1 means line buffered, and larger numbers specify the buffer size. Add a 'U' to mode to open the file for input with universal newline support. Any line ending in the input file will be seen as a '\n' in Python. Also, a file so opened gains the attribute 'newlines'; the value for this attribute is one of None (no newline read yet), '\r', '\n', '\r\n' or a tuple containing all the newline types seen. 'U' cannot be combined with 'w' or '+' mode. Note: open() is an alias for file(). Also, comparison of a value with True is redundant in an if statement. Rather use 'if f.read():' David. From danb_83 at yahoo.com Mon Apr 21 23:30:06 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Mon, 21 Apr 2008 20:30:06 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> <48a1d10c-87cb-43c3-83f4-9c331fc1d818@m1g2000pre.googlegroups.com> Message-ID: <68f586a6-1fac-4f06-b386-ad4bd8c22d61@p25g2000pri.googlegroups.com> On Apr 21, 4:01 am, Paul Boddie wrote: > On 21 Apr, 00:54, Dan Bishop wrote: > > > > > We wouldn't even need that. Just a new source encoding. Then we > > could write: > > > # -*- coding: end-block -*- > > [...] > > Someone at EuroPython 2007 did a lightning talk showing working code > which provided C-style block structuring using this mechanism. Yes, I saw an example of that: It's what inspired my post. From jens at aggergren.dk Tue Apr 29 09:25:50 2008 From: jens at aggergren.dk (Jens) Date: Tue, 29 Apr 2008 06:25:50 -0700 (PDT) Subject: Zope/DTML Infuriating... References: <3a955f90-ed80-46be-a238-1462e4fb2d0c@m3g2000hsc.googlegroups.com> Message-ID: <7f23c8d7-b2aa-4e55-8946-fd25cd8c594b@k13g2000hse.googlegroups.com> On Apr 29, 2:45?pm, Marco Mariani wrote: > Jens wrote: > >> You might have wrong assumptions from previous PHP experiences. > > >> ?>>> 'x'+4 > >> Traceback (most recent call last): > >> ? ?File "", line 1, in > >> TypeError: cannot concatenate 'str' and 'int' objects > > > ... and the non snobby answer would have been: > > > ... ? > > Sorry. Not trying to be snobbish, only in a hurry. > > That answer would have been less useful, because there are TONS of > details in the python tutorial, that set the language apart from its > "scripting cousins". > Reading the syntax and thinking "yeah, got it, boring, next chapter" is > a common mistake I've also made sometime, especially with python when > I've been deceived by its apparent simplicity. > Then, later, the same happened with Javascript, of course. > And it's bound to happen again, as much as I'll try to be careful :-( Hey no worriest. Is this the tutorial you're referring to: http://docs.python.org/lib/typesmapping.html Is there anything better? I miss the discussion and examples that accompany most entries in php.net. From siona at chiark.greenend.org.uk Tue Apr 29 13:21:45 2008 From: siona at chiark.greenend.org.uk (Sion Arrowsmith) Date: 29 Apr 2008 18:21:45 +0100 (BST) Subject: Simple unicode-safe version of str(exception)? References: <481650E3.4060603@v.loewis.de> <67on2nF2ol856U1@mid.individual.net> Message-ID: Russell E. Owen wrote: >No. e.message is only set if the exeption object receives exactly one >argument. And not always then: >>> e1 = Exception(u"\u00fe") >>> e1.message Traceback (most recent call last): File "", line 1, in ? AttributeError: Exception instance has no attribute 'message' >That is why my replacement code reads: > errStr = ",".join([unicode(s) for s in f.args]) errStr = ",".join(e.args) There is something distinctly odd going on here, though: >>> str(e1) Traceback (most recent call last): File "", line 1, in ? UnicodeEncodeError: 'ascii' codec can't encode character u'\xfe' in position 0: ordinal not in range(128) >>> e2 = Exception(u"\u00fe", "foo") >>> str(e2) "(u'\\xfe', 'foo')" >>> -- \S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/ "Frankly I have no feelings towards penguins one way or the other" -- Arthur C. Clarke her nu become? se bera eadward ofdun hl?ddre heafdes b?ce bump bump bump From bj_666 at gmx.net Wed Apr 16 17:03:17 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 16 Apr 2008 21:03:17 GMT Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> <09a38ca2-8c49-4eee-b6cf-58e849aea1fc@q1g2000prf.googlegroups.com> Message-ID: <66n7slF2lroubU2@mid.uni-berlin.de> On Wed, 16 Apr 2008 12:32:00 -0700, Aaron Watters wrote: >> > Perhaps this will inspire improved linters and better coding >> > practices.... >> >> Better coding practices such as extensive unit tests? > > Greetings from Earth. What planet are you from? :) > > There is always the possibility that frustrated > programmers will decide that "using something other > than python" is a "better coding practice". I've seen > it happen. So the average quality of Python coders raises. Cool. ;-) Ciao, Marc 'BlackJack' Rintsch From jywlsn at comcast.net Mon Apr 14 04:15:57 2008 From: jywlsn at comcast.net (J Wilson) Date: Mon, 14 Apr 2008 03:15:57 -0500 Subject: How to get the version of a file In-Reply-To: <472baa87-2aa3-495c-ab0f-9c7f16bef769@8g2000hsu.googlegroups.com> References: <472baa87-2aa3-495c-ab0f-9c7f16bef769@8g2000hsu.googlegroups.com> Message-ID: I'm not clear on how to use this to read the version resource. Specially, I need to get the version of Palm Conduit, which is, I guess, a "carbonized" shared library... or something. ? martin.laloux at gmail.com wrote: > you need appscript "that allows you to control scriptable Mac OS X > applications from Python" > http://pypi.python.org/pypi/appscript/0.18.1 From sturlamolden at yahoo.no Sat Apr 12 16:02:21 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sat, 12 Apr 2008 13:02:21 -0700 (PDT) Subject: C API design flaw (was: Re: Multiple independent Python interpreters in a C/C++ program?) References: <624b9d79-bc02-4f52-bc97-52019bf916d0@n1g2000prb.googlegroups.com> Message-ID: <8e73acd5-b50a-4e0d-9193-8615cb38e5a2@s39g2000prd.googlegroups.com> On Apr 12, 7:05 pm, sturlamolden wrote: > In theory, a GIL private to each (sub)interpreter would make Python > more scalable. The current GIL behaves like the BKL in earlier Linux > kernels. However, some third-party software, notably Apache's > mod_python, is claimed to depend on this behaviour. I just looked into the reason why ctypes, mod_python, etc. depend on a shared GIL. Well ... PyGILState_Ensure() does not take an argument, so it does not know which interpreter's GIL to acquire. Duh! The sad fact is, the functions in Python's C API does not take the interpreter as an argument, so they default to the one that is currently active (i.e. the one that PyThreadState_Get()->interp points to). This is unlike Java's JNI, in which all functions take the "environment" (a Java VM instance) as the first argument. IMHO, I consider this a major design flaw in Python's C API. In a more well thought API, PyGILState_Ensure would take the interpreter returned by Py_NewInterpreter as an argument, and thus know the interpreter with which to synchronize. I complained about this before, but the answer I got was that the simplified GIL API would not work if interpreters has a separate GIL. Obviously it would not work as long as the PyGILState_Ensure does not take any arguments. The lack of a leading VM argument in PyGILState_Ensure, and almost every function in Python's C API, is the heart of the problem. From soltys at noabuse.com Thu Apr 17 06:27:43 2008 From: soltys at noabuse.com (Soltys) Date: Thu, 17 Apr 2008 12:27:43 +0200 Subject: about a head line In-Reply-To: References: Message-ID: Penny Y. pisze: > I saw some scripts have a line at its begin: > > # encoding:gb2312 > > what's this? Why need it? thanks. > Have a look at PEP-0263 (http://www.python.org/dev/peps/pep-0263/) From thudfoo at opensuse.us Thu Apr 24 15:13:48 2008 From: thudfoo at opensuse.us (member thudfoo) Date: Thu, 24 Apr 2008 12:13:48 -0700 Subject: function that accepts any amount of arguments? In-Reply-To: <933e4c97-11c8-43b0-81e0-c78ff8573792@26g2000hsk.googlegroups.com> References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> <4810724a$0$23390$426a74cc@news.free.fr> <63ac69bf-9f6d-42bd-8e6e-5b3b17ec7c69@z72g2000hsb.googlegroups.com> <933e4c97-11c8-43b0-81e0-c78ff8573792@26g2000hsk.googlegroups.com> Message-ID: <3d881a310804241213q2f373190i4d7c7c1ffbaeba4c@mail.gmail.com> On 4/24/08, Jonathan Gardner wrote: > On Apr 24, 5:28 am, malkarouri wrote: > > > > What's wrong with raising ZeroDivisionError (not stopping the > > exception in the first place)? > > > > > Because when I use your module, call avg (or mean) without args, I > should see an error that says, "Hey, you have to pass at least one > value in!" > > ZeroDivisonError doesn't mean that. It means I tried to divide by > zero. Naively, I don't see where I was dividing by zero (because I > don't remember how to calculate the mean---that's what your code was > for.) > > ValueError does mean that I didn't pass the right kind of arguments > in. ValueError("No items specified") would be even clearer. (Or maybe > TypeError?) > > In general, any exception thrown should be meaningful to the code you > are throwing it to. That means they aren't familiar with how your code > works. > [source]|557> def average(n, *ints): |...> return (sum(ints)+n) / (len(ints) + 1) |...> [source]|558> average (1,2,3) <558> 2 [source]|559> average(3) <559> 3 [source]|560> average(1,2) <560> 1 [source]|561> average(0) <561> 0 [source]|562> average() --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /usr/share/doc/packages/python-dateutil/source/ in () TypeError: average() takes at least 1 argument (0 given) From samslists at gmail.com Thu Apr 10 13:37:35 2008 From: samslists at gmail.com (samslists at gmail.com) Date: Thu, 10 Apr 2008 10:37:35 -0700 (PDT) Subject: from __future__ import print Message-ID: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> Am I the only one that thinks this would be useful? :) I'd really like to be able to use python 3.0's print statement in 2.x. Is this at least being considered as an option for 2.6? It seems like it would be helpful with transitioning. From http Sat Apr 12 20:46:34 2008 From: http (Paul Rubin) Date: 12 Apr 2008 17:46:34 -0700 Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> <32e2acc1-97cb-4911-bb0c-67965b5ff113@2g2000hsn.googlegroups.com> Message-ID: <7x8wzi7f9x.fsf@ruckus.brouhaha.com> Steve Holden writes: > I believe you are making surmises outside your range of competence > there. While your faith in the developers is touching, the garbage > collection scheme is something that has received a lot of attention > with respect to performance under typical workloads over the years. Really, Python's cyclic gc is quite crude and should be upgraded to something that doesn't fall into that quadratic behavior. There was some fairly detailed discussion of this in another thread last time the subject came up. From jeff_barish at earthlink.net Wed Apr 9 09:33:22 2008 From: jeff_barish at earthlink.net (Jeffrey Barish) Date: Wed, 09 Apr 2008 07:33:22 -0600 Subject: __init__.py file References: Message-ID: cesco wrote: > I need to instantiate an object (my_object) whose methods I have to > use in two files (file1.py and file2.py) which are in the same > directory. Is it possible to instantiate such object in the > __init__.py file and then directly use it in file1.py and file2.py? > If not, as I seem to experience, what is the best practice to follow > in this case? (I thought __init__.py was somehow useful for that). I do this and find the technique fantastically convenient. You don't explain what problems you encountered -- or perhaps I don't understand what you mean by using the instances "directly" -- but here's what I do: In dirA/dirB/__init__.py, I import my_object to import the my_object.py module. I then instantiate an object in __init__.py. (Note that it is a singleton because Python imports modules only once.) Import the object in file{1,2}.py with import dirA.dirB.my_object or from dirA.dirB import my_object. I use the technique only with objects that are legitimately global. -- Jeffrey Barish From yourpadre at gmail.com Tue Apr 22 10:24:20 2008 From: yourpadre at gmail.com (Miguel Beltran R.) Date: Tue, 22 Apr 2008 09:24:20 -0500 Subject: Problem with urllib2 and authentification Message-ID: Using this script for connect to Zope I have this error ---script: import urllib2 protocolo='http://' servidor='10.28.1.239/' pagina='manage' fullurl=protocolo+servidor+pagina aut=urllib2.HTTPBasicAuthHandler() aut.add_password(realm=None, uri=servidor, user='myadmin', passwd='mypass') opener=urllib2.build_opener(aut, urllib2.HTTPHandler(debuglevel=1)) print opener.open(fullurl).read() ---Error: connect: (10.28.1.239, 80) send: 'GET /manage HTTP/1.1\r\nAccept-Encoding: identity\r\nHost: 10.28.1.239\r\nConnection: close\r\nUser-agent: Python-urllib/2.4\r\n\r\n' reply: 'HTTP/1.1 401 Unauthorized\r\n' header: Server: Zope/(Zope 2.10.5-final, python 2.4.4, win32) ZServer/1.1 header: Date: Tue, 22 Apr 2008 14:14:45 GMT header: Bobo-Exception-Line: 713 header: Content-Length: 884 header: Bobo-Exception-Value: See the server error log for details header: Content-Type: text/html; charset=iso-8859-15 header: Bobo-Exception-Type: Unauthorized header: Connection: close header: Bobo-Exception-File: HTTPResponse.py header: WWW-Authenticate: basic realm="Zope" Traceback (most recent call last): File "z.py", line 15, in ? print opener.open(fullurl).read() File "/usr/local/lib/python2.4/urllib2.py", line 364, in open response = meth(req, response) File "/usr/local/lib/python2.4/urllib2.py", line 471, in http_response response = self.parent.error( File "/usr/local/lib/python2.4/urllib2.py", line 402, in error return self._call_chain(*args) File "/usr/local/lib/python2.4/urllib2.py", line 337, in _call_chain result = func(*args) File "/usr/local/lib/python2.4/urllib2.py", line 480, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 401: Unauthorized why not send authentification? I try python 2.5 on slackware 12 too on python 2.4 and 2.5 on windows xp All same error -- ________________________________________ Lo bueno de vivir un dia mas es saber que nos queda un dia menos de vida From steve at holdenweb.com Fri Apr 25 08:55:28 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 25 Apr 2008 08:55:28 -0400 Subject: function that accepts any amount of arguments? In-Reply-To: References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> Message-ID: <4811D4C0.5050500@holdenweb.com> Nick Craig-Wood wrote: > Steve Holden wrote: >> Ken wrote: >>> "Steve Holden" wrote in message >> [...] >>>> def mean(*x): >>>> total = 0.0 >>>> for v in x: >>>> total += v >>>> return v/len(x) >>>> >>> think you want total/len(x) in return statement >>> >> Yes indeed, how glad I am I wrote "untested". I clearly wasn't pair >> programming when I wrote this post ;-) > > Posting to comp.lang.python is pair programming with the entire > internet ;-) > > +1 QOTW :) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From castironpi at gmail.com Wed Apr 2 11:35:32 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 2 Apr 2008 08:35:32 -0700 (PDT) Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> Message-ID: <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> On Apr 2, 5:00?am, Jo?o Neves wrote: > Hello all, > > I've got this question that has been nagging me for a few days now. > What are the reasons for us to have co_code as read-only? I've been > trying to get some info about it, but I kept hitting the wall. > > Correct me if I'm wrong, but as far as I understand, co_code > represents the compiled bytecode that should be run when, for > instance, a function is called. Wouldn't it be beneficial for > programmers to be able to change the bytecode in runtime? I mean, one > can't, as far as I'm aware, change the bytecode by accident, so if the > programmer would wish to change a function at runtime, he could do so > at his own risk. > > If there is a higher reason behind the read-only property of co_code, > I definitely fail to see it, and would like to know what it is. If > not, why aren't we allowed to write into it? > > Thanks in advance, > > Jo?o Neves Are Python bytes codes Python byte codes? Do you foresee any machine- dependent optimizations? From larry.bates at websafe.com` Fri Apr 18 11:45:52 2008 From: larry.bates at websafe.com` (Larry Bates) Date: Fri, 18 Apr 2008 10:45:52 -0500 Subject: Installing BeautifulSoup with easy_install (broken?) Message-ID: Info: Python version: ActivePython 2.5.1.1 Platform: Windows I wanted to install BeautifulSoup today for a small project and decided to use easy_install. I can install other packages just fine. Unfortunately I get the following error from BeautifulSoup installation attempt: C:\Python25\Lib\SITE-P~1>easy_install BeautifulSoup Searching for BeautifulSoup Reading http://pypi.python.org/simple/BeautifulSoup/ Reading http://www.crummy.com/software/BeautifulSoup/ Reading http://www.crummy.com/software/BeautifulSoup/download/ Best match: BeautifulSoup 3.0.5 Downloading http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup- 3.0.5.tar.gz Processing BeautifulSoup-3.0.5.tar.gz Running BeautifulSoup-3.0.5\setup.py -q bdist_egg --dist-dir c:\docume~1\larry\l ocals~1\temp\easy_install-cfdxna\BeautifulSoup-3.0.5\egg-dist-tmp-gbrpp5 Traceback (most recent call last): File "C:\Python25\Scripts\easy_install-script.py", line 8, in load_entry_point('setuptools==0.6c8', 'console_scripts', 'easy_install')() File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm and\easy_install.py", line 1671, in main File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm and\easy_install.py", line 1659, in with_ei_usage File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm and\easy_install.py", line 1675, in File "C:\Python25\lib\distutils\core.py", line 151, in setup dist.run_commands() File "C:\Python25\lib\distutils\dist.py", line 974, in run_commands self.run_command(cmd) File "C:\Python25\lib\distutils\dist.py", line 994, in run_command cmd_obj.run() File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm and\easy_install.py", line 211, in run File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm and\easy_install.py", line 446, in easy_install File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm and\easy_install.py", line 476, in install_item File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm and\easy_install.py", line 655, in install_eggs File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm and\easy_install.py", line 930, in build_and_install File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm and\easy_install.py", line 919, in run_setup File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand box.py", line 27, in run_setup File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand box.py", line 63, in run File "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand box.py", line 29, in File "C:\VOL1\Larry\Websafe\Python\wstools\setup.py", line 2, in import py2exe File "C:\VOL1\Larry\Websafe\Python\wstools\unittest.py", line 3, in class TextCtrlTest(unittest.TestCase): AttributeError: 'module' object has no attribute 'TestCase' Thanks in advance for any "clues". -Larry From hasna1980_14 at hotmail.com Fri Apr 11 06:10:33 2008 From: hasna1980_14 at hotmail.com (ha bo) Date: Fri, 11 Apr 2008 10:10:33 +0000 Subject: No subject Message-ID: hi i use this programme in my application django: import structMASK_CCITT = 0x1021 # CRC-CCITT mask (ISO 3309, used in X25, HDLC)MASK_CRC16 = 0xA001 # CRC16 mask (used in ARC files)def updcrc(crc, data, mask=MASK_CRC16): data_length = len(data) unpackFormat = '%db' % data_length unpackedData = struct.unpack(unpackFormat, data) for char in data: c = ord(char) c = c << 8 for j in xrange(8): if (crc ^ c) & 0x8000: crc = (crc << 1) ^ mask else: crc = crc << 1 c = c << 1 return crc & 0xffff and i call this function in other function in my view: def encodekey(var, expires=None, user='', trusted=False): import random, base64 import updcrc key = "%02X" % len(var) + var key += "%02X" % len(user) + user if expires is not None: key += expires.strftime('%Y%m%d%H%M') else: year = random.choice(range(2000,2100)) month = 23 day = random.choice(range(1,32)) hour = random.choice(range(1,25)) minute = random.choice(range(1,60)) key += "%04d%02d%02d%02d%02d" % (year, month, day, hour, minute) if trusted: checksum = updcrc(42, key) else: checksum = updcrc(0, key) key += "%04X" % checksum return base64.b64encode(key) but it give me this error: unpack requires a string argument of length 31 someone can help me _________________________________________________________________ Lancez des recherches en toute s?curit? depuis n'importe quelle page Web. T?l?chargez GRATUITEMENT Windows Live Toolbar aujourd'hui ! http://toolbar.live.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at holdenweb.com Sat Apr 5 17:54:37 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 17:54:37 -0400 Subject: ANN: pry unit testing framework In-Reply-To: <20080405213059.GA19741@nullcube.com> References: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com> <20080405141329.GD15684@nullcube.com> <20080405213059.GA19741@nullcube.com> Message-ID: <47F7F51D.8010405@holdenweb.com> Aldo Cortesi wrote: > Steve, > >> Kay at least has a long history as a contributor in this group, so >> people know how to interpret her remarks and know that her contributions >> are made on the basis of a deep understanding of Python. She is far from >> belonging to the "peanut gallery", and to suggest otherwise betrays >> either ignorance, arrogance, or both. > > While I'm not a regular poster on this list, I have been reading it for > nearly 10 years, so I probably have more context here than you suspect. > At least one mail to this list and a number of personal emails to me > suggest that it is Kay and and indeed you who are temporarily out of > line with the tone of the list. A more impartial re-reading of the > debate so far might make you judge my final, admittedly angry, response > more fairly. > To be fair I wasn't commenting on the whole thread, more on the angry nature of your final reply, and didn't really consider Kay's remarks fully. So perhaps I could ask *both* of you to be more civil to each other, and leave it at that? Storm in a teacup, of course. I'm sure war won;t be declared about this. Consider the 200,000 (?) readers of the group who *didn't* complain about your post and your software as supporters, if you like :-) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From george.sakkis at gmail.com Fri Apr 4 13:58:26 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 4 Apr 2008 10:58:26 -0700 (PDT) Subject: collecting results in threading app References: <47f64507$0$36354$742ec2ed@news.sonic.net> Message-ID: On Apr 4, 1:54 pm, George Sakkis wrote: > On Apr 4, 11:27 am, Gerardo Herzig wrote: > > There is an approach in which i can 'sum' after *any* thread finish? > > > Could a Queue help me there? > > Yes, you can push each result to a queue and have the main thread wait > in a loop doing a queue.get() every time. After each get() you can do > whatever with the results so far (partial sum, update a progress bar, > etc.) > > > You can take a look at papyros [1], I forgot the link: http://pypi.python.org/pypi/papyros/ George From gagsl-py2 at yahoo.com.ar Mon Apr 28 03:58:10 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 28 Apr 2008 04:58:10 -0300 Subject: Related to Shelve Module References: Message-ID: En Mon, 28 Apr 2008 02:08:31 -0300, tarun escribi?: > Hi All, > I want to store the class instance object variables persistenlty in one file > so that other file can also access for some filtering. I tired doing this > using the shelve module. > > *Code:* > class A: > pass > > import shelve > filename = 'test.db' > d = shelve.open(filename) > > a = A() > print a > d['1'] = a > > print d['1'] > d.close() > > *Output:* > <__main__.A instance at 0x018B56C0> > <__main__.A instance at 0x018B5760> > > *Observation:* > I expect both the print statements to return the same value, The second > print statement just reads the dictonary, but still the adress (0x..) is > different from the first print statement. Can anyone tell me why. Also let > me know if you the way of getting same value both the times. By default, each time you do d['1'] you get a *different* object. A shelve isn't very smart: it stores a string representation of your object (using pickle) and each time you ask for the object, it unpickles the stored string. When used as a persistence mechanism, it doesn't matter so much, the process that created the original instance may have died eons ago. If object identity is important to you, you should remember to "fetch" the values only once in a single process, or use the writeback=True argument to the shelve constructor. But read the warning at py> d = shelve.open(filename, writeback=True) py> a = A() py> d['1'] = a py> x1 = d['1'] py> x2 = d['1'] py> x3 = d['1'] py> print a, x1 <__main__.A instance at 0x00A3D5D0> <__main__.A instance at 0x00A3D5D0> py> a is x1 is x2 is x3 True -- Gabriel Genellina From aguirre.adolfo at gmail.com Mon Apr 28 22:37:25 2008 From: aguirre.adolfo at gmail.com (aguirre.adolfo at gmail.com) Date: Mon, 28 Apr 2008 19:37:25 -0700 (PDT) Subject: Python Math libraries - How to? References: <67nevlF2q292cU1@mid.individual.net> Message-ID: Hi, thak you. I get the following: > > > *** Error message ************* > > > Traceback (most recent call last): > > File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 20, > > in > > > > main() > > File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 13, > > in main > > volume = 4/3*pi*r3 > > NameError: global name 'pi' is not defined From steve at holdenweb.com Wed Apr 16 21:13:18 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 16 Apr 2008 21:13:18 -0400 Subject: TypeNone field detection In-Reply-To: <480698b3$0$31577$ec3e2dad@news.usenetmonster.com> References: <480698b3$0$31577$ec3e2dad@news.usenetmonster.com> Message-ID: Joe Blow wrote: > What is the best way to detect a TypeNone field in a tuple, or in a list? > > I am accessing a MySQL database using the MySQLdb Python interface... this > interface returns a tuple object type in response to SQL SELECT > statements. My understanding of the MySQLdb interface is that NULL > database values are returned as a Python 'None' object. > > Because I need to create some work fields based on the contents of the > database I am doing so by copying the tuple to a list object and then > calculating these work fields as needed. My problem is that I need to be > able to detect the Python 'None' objects and convert them to an integer > zero value field to enable my calculations to work. > > I'm new to Python so I'm sure I'm overlooking something simple ? but what > is the easiest way to do a logical test for the existence of a TypeNone > field? Since there is only one instance of TypeNone (the value we reference as None) the easiest test is if x is None: There is no need to create a list first: you can create a list as you iterate over the tuple: a = (1, 2, None, "a", "b") a = [0 if x is None else x for x in a] regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From dickinsm at gmail.com Mon Apr 7 15:53:22 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Mon, 7 Apr 2008 12:53:22 -0700 (PDT) Subject: A funnily inconsistent behavior of int and float References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com> <1d11875a-470a-489f-910a-b420a145eb61@a1g2000hsb.googlegroups.com> Message-ID: <11b4793c-04cc-4898-99a8-8418d237de3e@2g2000hsn.googlegroups.com> On Apr 7, 3:15 pm, "Terry Reedy" wrote: > > My suggestions: > 1. Change signature to: int([number | string[, radix]). > This makes it clear that radix can only follow a string without having to > say so in the text. > > 2. Replace text with: > Convert a number or string to an integer. If no arguments are given, > return 0. If a number is given, return number.__int__(). Conversion of > floating point numbers to integers truncates towards zero. A string must > be a base-radix integer literal optionally preceded by '+' or '-' (with no > space in between) and optionally surrounded by whitespace. A base-n > literal consists of the digits 0 to n-1, with 'a' to 'z' (or 'A' to 'Z') > having values 10 to 35. The default radix is 10. The allowed values are 0 > and 2-36, with 0 the same as 10. > > If 0 is not the same as 10, the last would have to be changed, but I could > not detect any difference in a quick test. > > After looking at any comments here, I will consider submitting these to the > tracker. > > Terry Jan Reedy Looks good! The description should probably also mention the optional '0b', '0o' or '0x' (or '0B', '0O', '0X') allowed between the sign and the digits (or before the digits in the case of a missing sign) when base=2, base=8 or base=16. The only base 0 versus base 10 difference I could find was the following: >>> int('033', 0) Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 0: '033' [38720 refs] >>> int('033') 33 Mark From malaclypse2 at gmail.com Thu Apr 10 16:06:47 2008 From: malaclypse2 at gmail.com (Jerry Hill) Date: Thu, 10 Apr 2008 16:06:47 -0400 Subject: Python conventions In-Reply-To: References: Message-ID: <16651e80804101306p9742a62x77e34654345d8e4c@mail.gmail.com> On Thu, Apr 10, 2008 at 3:52 PM, wrote: > Daniel, PEP 8 is anything but complete. How much of the following > simple question can you answer from there: > > Given that you can name things with UpperAndLower, lowerAndUpper, > lower_and_underscore, etc., what is the convention for naming > packages, modules, classes, ... Each of those is directly addressed in PEP 8. Perhaps you should have picked a different question? -- Jerry From george.sakkis at gmail.com Fri Apr 4 13:54:51 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 4 Apr 2008 10:54:51 -0700 (PDT) Subject: collecting results in threading app References: <47f64507$0$36354$742ec2ed@news.sonic.net> Message-ID: On Apr 4, 11:27 am, Gerardo Herzig wrote: > John Nagle wrote: > >Gerardo Herzig wrote: > > >>Hi all. Newbee at threads over here. Im missing some point here, but cant > >>figure out which one. > > >>This little peace of code executes a 'select count(*)' over every table > >>in a database, one thread per table: > >> > >>class TableCounter(threading.Thread): > >> def __init__(self, conn, table): > >> self.connection = connection.Connection(host=conn.host, > >>port=conn.port, user=conn.user, password='', base=conn.base) > >> threading.Thread.__init__(self) > >> self.table = table > > >> def run(self): > >> result = self.connection.doQuery("select count(*) from %s" % > >>self.table, [])[0][0] > >> print result > >> return result > > >>class DataChecker(metadata.Database): > > >> def countAll(self): > >> for table in self.tables: > >> t = TableCounter(self.connection, table.name) > >> t.start() > >> return > >> > > >>It works fine, in the sense that every run() method prints the correct > >>value. > >>But...I would like to store the result of t.start() in, say, a list. The > >>thing is, t.start() returns None, so...what im i missing here? > >>Its the desing wrong? > > > 1. What interface to MySQL are you using? That's not MySQLdb. > > 2. If SELECT COUNT(*) is slow, check your table definitions. > > For MyISAM, it's a fixed-time operation, and even for InnoDB, > > it shouldn't take that long if you have an INDEX. > > 3. Threads don't return "results" as such; they're not functions. > > >As for the code, you need something like this: > > >class TableCounter(threading.Thread): > > def __init__(self, conn, table): > > self.result = None > > ... > > > def run(self): > > self.result = self.connection.doQuery("select count(*) from %s" % > > self.table, [])[0][0] > > > def countAll(self): > > mythreads = [] # list of TableCounter objects > > # Start all threads > > for table in self.tables: > > t = TableCounter(self.connection, table.name) > > mythreads.append(t) # list of counter threads > > t.start() > > # Wait for all threads to finish > > totalcount = 0 > > for mythread in mythreads: # for all threads > > mythread.join() # wait for thread to finish > > totalcount += mythread.result # add to result > > print "Total size of all tables is:", totalcount > > > John Nagle > > Thanks John, that certanly works. According to George's suggestion, i > will take a look to the Queue module. > One question about > > for mythread in mythreads: # for all threads > mythread.join() # wait for thread to finish > > That code will wait for the first count(*) to finish and then continues > to the next count(*). Because if is that so, it will be some kind of > 'use threads, but execute one at the time'. > I mean, if mytreads[0] is a very longer one, all the others will be > waiting...rigth? No, all will be executed in parallel; only the main thread will be waiting for the first thread to finish. So if only the first job is long, as soon as it finishes and join()s, all the others will already have finished and their join() will be instantaneous. > There is an approach in which i can 'sum' after *any* thread finish? > > Could a Queue help me there? Yes, you can push each result to a queue and have the main thread wait in a loop doing a queue.get() every time. After each get() you can do whatever with the results so far (partial sum, update a progress bar, etc.) You can take a look at papyros [1], a small package I wrote for hiding the details behind a simple Pythonic API. Using papyros, your example would look something like this: import sys from papyros import Job from papyros.multithreaded import MultiThreadedMaster # a papyros.Job subclass for each type of task you want to run concurrently class CountJob(Job): def __call__(self, connection, table_name): return connection.doQuery("select count(*) from %s" % table_name, [])[0][0] class DataChecker(metadata.Database): def countAll(self): sum_count = 0 # create a pool of 4 threads master = MultiThreadedMaster(4) # issue all the jobs for table in self.tables: master.addJob(CountJob(self.connection, table.name)) # get each processed job as soon as it finishes for job in iter(master.popProcessedJob, None): # the job arguments are available as job.args table_name = job.args[1] try: # try to get the result count = job.result except Exception, ex: # some exception was raised when executing this job print '* Exception raised for table %s: %s' % (table_name, ex) else: # job finished successfully sum_count += count print 'Table %s: count=%d (running total=%d)' % ( table_name, count, sum_count) return sum_count As you can see, any exception raised in a thread is stored and reraised on the main thread when you attempt to get the result. You can also specify a timeout in popProcessedJob() so that the main thread doesn't wait forever in case a job hangs. Last but not least, the same API is implemented both for threads and processes (using Pyro) so it's not restricted by the GIL in case the jobs are CPU-intensive. George From fr5478bey at gmail.com Sat Apr 26 11:40:07 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:40:07 -0700 (PDT) Subject: inventor12 crack Message-ID: <929dd123-66d8-4bf4-a6d1-18fc7abcd999@34g2000hsh.googlegroups.com> inventor12 crack http://cracks.00bp.com F R E E C R A C K S From NIE_DZIALA at gazeta.pl Sat Apr 5 01:22:58 2008 From: NIE_DZIALA at gazeta.pl (Piotr Sobolewski) Date: Sat, 05 Apr 2008 07:22:58 +0200 Subject: variable scope in list comprehensions References: Message-ID: Duncan Booth wrote: > For the OP, in some languages (e.g. C) 'for' loops typically calculate > the value of the loop control variable based on some expression > involving the previous value. Python isn't like that. In Python the data > used to compute the next value is stored internally: you cannot access > it directly. Great! Now everything is clear. Thanks! From paul at itdreamreal.com Mon Apr 7 22:59:04 2008 From: paul at itdreamreal.com (paul Batoum.) Date: Mon, 7 Apr 2008 19:59:04 -0700 (PDT) Subject: python, Mysql_python, storm problem Message-ID: <16547127.post@talk.nabble.com> I am actually tryng to build a database apps in python + storm which use MySQLdb 1.2.2 i actually want the auto reconnect feature of storm, which just need to change the False param of raw_connect to True in storm/databases/mysql.py so far nothing really difficult but from there i got quite a weird result: if i try the following code, it works in the shell python interpreter but not when i put it in a test.py file and call it as python test.py (will be helpfull for unittest): So to make it simple the MySQL reconnect work in the shell interpreter and i got a DisconnectionError: (2006, 'MySQL server has gone away') when i use it the other way. Let me know if one of you have ever experienced something like that Thx Code: import database import time # Test timeout cases pdb = database.Database(connect_info) res = pdb.execute(u"SHOW VARIABLES LIKE 'wait_timeout'") # set the timeout to 3 sec pdb.execute("SET wait_timeout=3") res = pdb.execute(u"SHOW VARIABLES LIKE 'wait_timeout'") res = pdb.execute("select * from country") time.sleep(5) # try a new execute, this one should pass res = pdb.execute("select * from country") -- View this message in context: http://www.nabble.com/python%2C-Mysql_python%2C-storm-problem-tp16547127p16547127.html Sent from the Python - python-list mailing list archive at Nabble.com. From hat at se-162.se.wtb.tue.nl Tue Apr 22 10:30:44 2008 From: hat at se-162.se.wtb.tue.nl (A.T.Hofkamp) Date: Tue, 22 Apr 2008 16:30:44 +0200 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? References: Message-ID: On 2008-04-22, Harishankar wrote: > Hi, > > Sorry to start off on a negative note in the list, but I feel that the Python > subprocess module is sorely deficient because it lacks a mechanism to: > > 1. Create non-blocking pipes which can be read in a separate thread (I am I don't know about threading, but you can read/write streams in a non-blocking way in Python (under Linux) with the os.read/os.write functions (these map directly to read(2)/write(2) primitives). You should first check that something can be read/written. Use eg select.select() for this. Several GUI toolkits also allow monitoring of file handles. Whether this also works at other OSes, I don't know. Alternatively, you can create your own pipes, make them non-blocking, and give the file handles to subprocess. > 2. Kill the subprocess in a platform independent manner (i.e. no third party > modules and no hacks). The concept of sub-process is platform dependent already. Usually however, closing the child input stream is sufficient for most child programs to decide that they can quit. > Is there any way to use non-blocking Popen objects using subprocess? and 2 - > is there a way to kill the subprocess in a platform independent manner in a > purely Pythonic way? I thought initially that this problem is simple enough, > but over the last couple of days I've been really struggling to find any > answer. I've been through dozens of mailing list archives in to find a > solution. Unfortunately none of the solutions seem to fit my needs. Interfacing with the rest of the world implies you are going to need services provided by the OS at one time or another. Python is rather transparent here and gives you quick access to the OS services. While this is bad for uniformity, it is good to let people make their own choices in optimally using the OS services. Python helps here by giving light-weight access to the underlying OS, making explicit what part is OS dependent. (and if still in doubt, why do you think were all the solutions you found 'not fitting'?). > My only solution seems to be to offer the end user the mencoder command line > and make them execute it manually and be done with it but that seems a rather > weak solution. This is always a good fallback. Sincerely, Albert From mal at egenix.com Thu Apr 3 16:53:54 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Thu, 03 Apr 2008 22:53:54 +0200 Subject: object-relational mappers In-Reply-To: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> Message-ID: <47F543E2.9030302@egenix.com> On 2008-04-01 22:40, Aaron Watters wrote: > I've been poking around the world of object-relational > mappers and it inspired me to coin a corellary to the > the famous quote on regular expressions: > > "You have objects and a database: that's 2 problems. > So: get an object-relational mapper: > now you have 2**3 problems." > > That is to say I feel that they all make me learn > so much about the internals and features of the > O-R mapper itself that I would be better off rolling > my own queries on an as-needed basis without > wasting so many brain cells. > > comments? I fully agree :-) -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 03 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From kay.schluehr at gmx.net Sat Apr 5 02:31:38 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Fri, 4 Apr 2008 23:31:38 -0700 (PDT) Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> Message-ID: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> On 2 Apr., 06:38, Aldo Cortesi wrote: > Hi Ben, > > > > We are happy to announce the first release of Pry, a unit testing > > > framework. > > > Thanks for the announcement, and for the software. > > > If Pry is already incompatible with xUnit (i.e. Python's 'unittest'), > > could we please have names that adhere to the Python style guide > > ? > > > In particular the method names 'setUp', 'setUpAll', 'tearDown', > > 'tearDownAll' don't comply with the style guide. Compliant names for > > those methods would be 'set_up', 'set_up_all', etc. > > Keeping fixture setUp and tearDown names the same makes the transition > from unittest to pry easier. At the moment, converting to pry is very > simple - inherit your suites from AutoTree, rewrite tests to use > assertions, and then instantiate your suites at the end of the module. > Voila! You have a nice command-line interface, coverage analysis, and > an easy path to saner, better-engineered unit tests. But you could have added the integration of code coverage and other helpful features with unittest as a conservative extension giving everyone a chance to use it directly with existing tests instead of forcing them to rewrite their tests for bike shading purposes. From benash at gmail.com Thu Apr 3 02:39:51 2008 From: benash at gmail.com (benash at gmail.com) Date: Wed, 2 Apr 2008 23:39:51 -0700 Subject: Parsing HTML? In-Reply-To: References: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> Message-ID: BeautifulSoup does what I need it to. Though, I was hoping to find something that would let me work with the DOM the way JavaScript can work with web browsers' implementations of the DOM. Specifically, I'd like to be able to access the innerHTML element of a DOM element. Python's built-in HTMLParser is SAX-based, so I don't want to use that, and the minidom doesn't appear to implement this part of the DOM. On Wed, Apr 2, 2008 at 10:37 PM, Daniel Fetchinson wrote: > > I'm trying to parse an HTML file. I want to retrieve all of the text > > inside a certain tag that I find with XPath. The DOM seems to make > > this available with the innerHTML element, but I haven't found a way > > to do it in Python. > > Have you tried http://www.google.com/search?q=python+html+parser ? > > HTH, > Daniel > From bdsatish at gmail.com Fri Apr 11 07:42:22 2008 From: bdsatish at gmail.com (bdsatish) Date: Fri, 11 Apr 2008 04:42:22 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: <6ae183c4-5172-4dea-ba22-8c38fb96927c@s39g2000prd.googlegroups.com> On Apr 11, 4:37 pm, Scott David Daniels wrote: > bdsatish wrote: > > The built-in function round( ) will always "round up", that is 1.5 is > def rounded(v): > rounded = round(v) > if divmod(v, 1)[1] == .5 and divmod(rounded, 2)[1] == 1: > if v > 0: > return rounded - 1 > return rounded + 1 > return rounded > > last = None > for n in range(-29, 28): > x = n * .25 > r = xr(x) > if r != last: > last = r > print > print '%s->%s' % (x, xr(x)), > Hi Scott, This is what I was looking for.. I forgot about divmod( ) thanks for reminding. From medin0065 at gmail.com Sun Apr 20 10:47:39 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:47:39 -0700 (PDT) Subject: dark crusade patch 1.2 Message-ID: <814d3f2a-f8ff-4c83-b300-d6106f554650@k10g2000prm.googlegroups.com> dark crusade patch 1.2 http://cracks.00bp.com F R E E C R A C K S From george.sakkis at gmail.com Thu Apr 17 00:00:58 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 16 Apr 2008 21:00:58 -0700 (PDT) Subject: Default parameter for a method References: <806788d2-67b7-456b-bd1e-08c50cbf0f7b@8g2000hsu.googlegroups.com> <48065d11$0$36390$742ec2ed@news.sonic.net> Message-ID: On Apr 16, 4:21?pm, John Nagle wrote: > In general, default values should be immutable constants only. This is more restrictive than necessary; it should rather read "In general, default values should be *treated as* immutable objects only". It's perfectly fine for a default value to be mutable if the function doesn't modify it, as in the following example: def parse(text, stopwords=set(w.strip() for w in open('stopwords.txt')): words = [w for w in text.split() if w not in stopwords] ... Since the set is not modified, there's no harm for being mutable; IOW it's no different than using a frozenset instead. Similarly for dicts, lists and other mutable containers, as long as they are treated as read-only. George From martin at v.loewis.de Sun Apr 20 14:37:12 2008 From: martin at v.loewis.de (=?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 20 Apr 2008 20:37:12 +0200 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> Message-ID: <480b8d58$0$26996$9b622d9e@news.freenet.de> > Pure Python code can cause memory leaks. No, that's not a bug in the > interpreter but the fault of the developer. For example code that messes > around with stack frames and exception object can cause nasty reference > leaks. Can you give an example, please? Regards, Martin From skanemupp at yahoo.se Sun Apr 13 11:57:29 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 13 Apr 2008 08:57:29 -0700 (PDT) Subject: Tkinter, image not appearing in function but without function Message-ID: <42a33edd-5792-47ad-a940-ecb5df23accc@a9g2000prl.googlegroups.com> why is the first program not working? when i click the screen the map is not appearing. the second program works. from Tkinter import * master = Tk() w = Canvas(master, width=700, height=600) w.pack(expand = YES, fill = BOTH) def mapper(): mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\world-map.gif') w.create_image(10, 10, image = mapq, anchor = NW) def key(event): print "pressed", repr(event.char) def callback(event): w.focus_set() print "clicked at", event.x, event.y mapper() print 'yo' square = w.create_oval(event.x-5,event.y-5,event.x+5,event.y+5, fill="black") w.bind("", key) w.bind("", callback) w.pack() mainloop() from Tkinter import * master = Tk() w = Canvas(master, width=700, height=600) w.pack(expand = YES, fill = BOTH) q=raw_input("Choose: i=India, s=sweden, else World: ") if q=="i": mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\map-india.bmp') elif q=='s': mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\provinces-of- sweden.gif') else: mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\world-map.gif') print mapq.height(), mapq.width() w.create_image(10, 10, image = mapq, anchor = NW) def key(event): print "pressed", repr(event.char) def callback(event): w.focus_set() print "clicked at", event.x, event.y square = w.create_oval(event.x-5,event.y-5,event.x+5,event.y+5, fill="black") """hur hitta om inom ratt->kolla color of """ w.bind("", key) w.bind("", callback) w.pack() mainloop() From mensanator at aol.com Sat Apr 19 19:51:12 2008 From: mensanator at aol.com (Mensanator) Date: Sat, 19 Apr 2008 16:51:12 -0700 (PDT) Subject: random.random(), random not defined!? References: <2a3931f5-481d-4831-baad-fcc9f0c0c129@m73g2000hsh.googlegroups.com> <480a57de@news.mel.dft.com.au> Message-ID: <279fb48f-2d55-4c46-a8c4-d43e90a61fc8@l42g2000hsc.googlegroups.com> On Apr 19, 3:36?pm, John Machin wrote: > globalrev wrote: > > do i need to import something to use random? > > No, you need to import random But you could alsways import it as something. >>> import random as something >>> something.random() 0.45811606256668347 From sharma.mohit80 at gmail.com Tue Apr 1 06:57:38 2008 From: sharma.mohit80 at gmail.com (sharma.mohit80 at gmail.com) Date: Tue, 1 Apr 2008 03:57:38 -0700 (PDT) Subject: Canon Laser Printer Message-ID: Canon Laser Printer - LBP2900 :- Features: * New print technologies for faster printouts with print speeds of up to 12ppm monochrome, the LBP2900 offers fast printouts at an affordable price. * Two groundbreaking Canon technologies: CAPT 2.1 and Hi-SCoA redesign the printing process for improved performance. * CAPT 2.1, or Canon advanced printing technology, harnesses the power of the PC to speed up print jobs, instead of loading up the printer with expensive memory upgrades. more features information please visit - http://www.homeshop18.com/shop/u/y/p-Computers-Q-and-Q-Peripherals-S-Printers-Q-and-Q-Scanners-S-Laser-S-Canon-Q-Laser-Q-Printer-Q---Q-LBP2900/Home_Online-pI_3952-clI_2-cI_998-pCI_925- From gggg.iiiii at gmail.com Wed Apr 9 13:17:21 2008 From: gggg.iiiii at gmail.com (G) Date: Wed, 9 Apr 2008 13:17:21 -0400 Subject: question about string formatting In-Reply-To: <42b9a3ff0804091004s4d60751fh68c82673e8e3f4c3@mail.gmail.com> References: <42b9a3ff0804091004s4d60751fh68c82673e8e3f4c3@mail.gmail.com> Message-ID: <4a7f84ac0804091017o7775a9a5k17f8434914b3dd43@mail.gmail.com> >>> import locale >>> locale.setlocale(locale.LC_ALL, '') 'en_US.UTF-8' >>> locale.format('%.2f', 1021212.12, True) '1,021,212.12' >>> On Wed, Apr 9, 2008 at 1:04 PM, Kelie wrote: > Hello, > > Is there something in Python built-in function or library that will > convert a number 1205466.654 to $1,205,466.65? To add the "$" sign and set > the decimal place is not a problem, but I don't know how to add the > thousands delimiter. > > Thanks, > > -- > Kelie > UliPad is my Python editor. > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Sat Apr 5 07:55:35 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 13:55:35 +0200 Subject: In Tkinter - having an input and an entry In-Reply-To: <29f44489-e589-4331-8bea-36fa346026d2@t54g2000hsg.googlegroups.com> References: <29f44489-e589-4331-8bea-36fa346026d2@t54g2000hsg.googlegroups.com> Message-ID: markfernandes02 at googlemail.com wrote: > Traceback (most recent call last): > File "F:\Programming\python and database\access_db8.2.py", line 129, > in ? > Tkwindow() > File "F:\Programming\python and database\access_db8.2.py", line 88, > in Tkwindow > title = stringVar() > NameError: global name 'stringVar' is not defined >>> "StringVar" == "stringVar" False From fetchinson at googlemail.com Wed Apr 9 14:22:46 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Wed, 9 Apr 2008 11:22:46 -0700 Subject: Google App Engine In-Reply-To: <3d4cae10-17bb-4d53-b84f-236287bd5893@m44g2000hsc.googlegroups.com> References: <47fc2c7c$0$36365$742ec2ed@news.sonic.net> <7e43fcd9-6207-4af2-8256-c0099a8ce0bb@1g2000prf.googlegroups.com> <3d4cae10-17bb-4d53-b84f-236287bd5893@m44g2000hsc.googlegroups.com> Message-ID: > > > The backend data store, while it has a vaguely SQLish query language is an > > object database not a relational database, i.e. more like ZODB than MySQL. > > It uses similar concepts to django's data api but isn't the same. It > should > > be possible to write something simple to replace it, but given that you > > only need to migrate away from Google when your data or page hits get > > large, you need to replace it with something scalable. > > I have a bet with a coworker that someone will implement the api, in a > way that makes migration away from Google easy, within a month. > (actually, the bet is just that there will be a project with this > goal). The reason I mention it here, is that he had the same comments > as you regarding this. My thinking is that (if past experiences can be > used as a yardstick) the python community will see this deficiency and > work to correct it. As a result of that thinking, I am fairly certain > that this concern is not a big concern. The authentication thing, > thats a bit different. The best would be if the google datastore backend would be available from sqlalchemy or sqlobject. I understand that the google datastore is not a relational database but that just means that the full power of sqlalchemy or sqlobject would not be available for this backend only a limited subset. I think this should be doable especially because GQL is very similar to SQL looks like it's really a proper subset. From goldtech at worldpost.com Fri Apr 25 11:21:28 2008 From: goldtech at worldpost.com (goldtech) Date: Fri, 25 Apr 2008 08:21:28 -0700 (PDT) Subject: Tkinter scrollbar and checkbox References: <9581b4cd-36f1-47dc-ae6e-0ca58f1b38e0@27g2000hsf.googlegroups.com> <741dfbee-530e-49af-a1fc-deb3cebbbd16@w74g2000hsh.googlegroups.com> Message-ID: <7e29cb37-4bd1-4533-9bd2-8b6616cfa542@e53g2000hsa.googlegroups.com> snip... > > I use wxPython most of the time, however effbot has a good tutorial on > scrollbars for Tkinter that I think you might find helpful: > > http://effbot.org/zone/tkinter-scrollbar-patterns.htm > > Here's another link on the subject: > > http://www.pythonware.com/library/tkinter/introduction/scrollbar.htm > > HTH > > Mike Indeed, I see it: http://effbot.org/zone/tkinter-autoscrollbar.htm Many Thanks. Lee From Scott.Daniels at Acm.Org Wed Apr 2 23:33:23 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Wed, 02 Apr 2008 20:33:23 -0700 Subject: Directed Graph Traversal In-Reply-To: <804682cb-2da6-4d85-83d4-c7425c498534@p25g2000hsf.googlegroups.com> References: <804682cb-2da6-4d85-83d4-c7425c498534@p25g2000hsf.googlegroups.com> Message-ID: bukzor wrote: > Can someone point me in the direction of a good solution of this? I'm > using it to construct a SQL query compiler, .... > Given a directed graph and a list of points in the graph, what is the > minimal subgraph that contains them all? It is preferable that the > subgraph is a tree. I did something nice (but non-redistributable) on this once: here is the driving intuition: * Start with every point a distinct color. * Add all points adjacent in the digraph as the same color; merge colors as you join them. * When you are down to to a single color, you have the minimal solution in the set you've chosen. I actually did a cheapest-first search; adding an edge each time. There is a post-join pruning step that was (as I recall) fairly simple. -Scott David Daniels Scott.Daniels at Acm.Org From pavlovevidence at gmail.com Thu Apr 17 07:06:22 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Thu, 17 Apr 2008 04:06:22 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> Message-ID: On Apr 17, 4:41 am, Sverker Nilsson wrote: > On Apr 17, 12:02 am, Carl Banks wrote: > > > > > On Apr 16, 12:40 pm, Aaron Watters wrote: > > > > On Apr 16, 12:27 pm, Rhamphoryncus wrote: > > > > > On Apr 16, 6:56 am, Aaron Watters wrote: > > > > > > I don't get it. It ain't broke. Don't fix it. > > > > > So how would you have done the old-style class to new-style class > > > > transition? > > > > I'd ignore it. I never understood it and never had > > > any need for it anyway. New-style classes and metaclasses > > > were a complicated solution to an unimportant problem in > > > my opinion. And also a fiendish way to make code > > > inscrutible -- which I thought was more of a Perl thing > > > than a Python thing, or should be. > > > > I must be missing some of the deeper issues here. Please > > > educate me. > > > The deeper issue is that you're benefiting from these "unimportant" > > changes even if you never use them yourself. > > > Carl Banks > > That just seems a BIT categorical for a statement. Who is 'you'? The Python community, more or less. The person I was replying to, specifically. > I don't see I benefit from any important or unimportant features in > py3k. I was talking about the features added in 2.x. Python 3.0 features haven't benefited many people (yet). [snip] > Just my 2c. If you don't mind me saying, I think you've given us quite a bit more than 2c in this thread. Carl Banks From corvettecraz92 at gmail.com Fri Apr 11 10:16:37 2008 From: corvettecraz92 at gmail.com (corvettecraz92 at gmail.com) Date: Fri, 11 Apr 2008 07:16:37 -0700 (PDT) Subject: text adventure game problem References: <4fb4fb0d-4cb2-4fcd-a207-a0341d92e82b@8g2000hsu.googlegroups.com> Message-ID: <7e1c3f97-ff17-4add-8d45-40f7b48dec4a@l64g2000hse.googlegroups.com> On Apr 11, 1:40?am, Dennis Lee Bieber wrote: > On Thu, 10 Apr 2008 05:06:42 -0700 (PDT), corvettecra... at gmail.com > declaimed the following in comp.lang.python: > > > okay, that explains it... > > could you provide a working example of a two-room game using your > > method please so I can understand it better? Thanks in advance! > > ? ? ? ? Okay... It isn't the best thought out system -- I have too > many specific classes... It would probably be better to put actions into > dictionaries and use some custom .getattr() to handle them. > > ? ? ? ? Will four rooms, a hidden chunk of gold, and one other movable > object suffice? Watch out for news client line wrapping. The only > parsing done is of the form: verb object; no attempt to handle: verb > direct_object filler indirect_object > > -=-=-=-=-=-=- > # > # ? TAGS.py ? ? Text Adventure Game Shell > # > > # ? I've probably defined too many special classes here > class Gobject(object): ?#Game object > ? ? def __init__(self, name, description, hidden=False, fixed=True): > ? ? ? ? self._name = name > ? ? ? ? self._description = description > ? ? ? ? self.hidden = hidden ? #hidden objects are not visible to > EXAMINE > ? ? ? ? self.fixed = fixed ? ? #fixed objects can not be taken > ? ? def _getName(self): > ? ? ? ? return self._name > ? ? name = property(_getName) > ? ? def _getDescription(self): > ? ? ? ? return self._description > ? ? description = property(_getDescription) > > class Exit(Gobject): > ? ? def __init__(self, description, target, hidden=False): > ? ? ? ? super(Exit, self).__init__(None, description, hidden) > ? ? ? ? self._target = target > ? ? def _getTarget(self): > ? ? ? ? return self._target > ? ? target = property(_getTarget) > > class Room(Gobject): ? ?#rooms (container object) > ? ? def __init__(self, name, description, exits=None, details=None): > ? ? ? ? super(Room, self).__init__(name, description, hidden=False, > fixed=True) > ? ? ? ? self._exits = exits > ? ? ? ? if details: > ? ? ? ? ? ? self._details = details ? ? #other objects that are inside > the room > ? ? ? ? else: > ? ? ? ? ? ? self._details = {} > ? ? def setExits(self, exits): > ? ? ? ? self._exits = exits > ? ? def go(self, ext): > ? ? ? ? return self._exits.get(ext, None) > ? ? def setDetails(self, details): > ? ? ? ? self._details = details > ? ? def addDetail(self, itm): > ? ? ? ? self._details[itm.name] = itm > ? ? def delDetail(self, name): > ? ? ? ? if (name in self._details and > ? ? ? ? ? ? not self._details[name].fixed): > ? ? ? ? ? ? itm = self._details[name] > ? ? ? ? ? ? del self._details[name] > ? ? ? ? else: > ? ? ? ? ? ? itm = None > ? ? ? ? return itm > ? ? def examine(self, name=None): > ? ? ? ? if not name: return self.description > ? ? ? ? if (name in self._details > ? ? ? ? ? ? and not self._details[name].hidden): > ? ? ? ? ? ? return self._details[name].description > ? ? ? ? else: > ? ? ? ? ? ? return None > ? ? def _detailedDescription(self): > ? ? ? ? items = "nothing of interest" > ? ? ? ? if self._details: > ? ? ? ? ? ? items = ", ".join([itm.name for itm in > self._details.values() > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?if not itm.hidden]) > ? ? ? ? exits = ", ".join([ext for ext in self._exits.keys() > ? ? ? ? ? ? ? ? ? ? ? ? ? ?if not self._exits[ext].hidden]) > ? ? ? ? #there must be at least one exit (the way you came in) > ? ? ? ? return "%s. In the %s you see %s. Passages lead to %s." % > (self._description, > ?self.name, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? items, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? exits) > ? ? description = property(_detailedDescription) > > class Thing(Gobject): > ? ? def __init__(self, name, description, parent, hidden=False, > fixed=False): > ? ? ? ? super(Thing, self).__init__(name, description, hidden, fixed) > ? ? ? ? self.parent = parent > ? ? def take(self): > ? ? ? ? if self.fixed: > ? ? ? ? ? ? return None > ? ? ? ? else: > ? ? ? ? ? ? self.hidden = False ? ? #if taken, one now can see it > ? ? ? ? ? ? return self.parent.delDetail(self.name) > ? ? def drop(self, parent): > ? ? ? ? self.parent.delDetail(self.name) > ? ? ? ? parent.addDetail(self) > > class TriggerThing(Thing): > ? ? def __init__(self, name, description, parent, > ? ? ? ? ? ? ? ? ?hidden=False, fixed=True, triggers=None): > ? ? ? ? super(TriggerThing, self).__init__(name, description, parent, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?hidden, fixed) > ? ? ? ? self._triggers = triggers > ? ? def _detailedDescription(self): > ? ? ? ? if self._triggers: > ? ? ? ? ? ? items = ", ".join([itm.name for itm in > self.parent._details.values() > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?if itm in self._triggers > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?and itm.hidden]) > ? ? ? ? else: > ? ? ? ? ? ? items = ", ".join([itm.name for item in > self.parent._details.values() > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?if itm.hidden]) > ? ? ? ? if not items: items = "nothing of interest" > ? ? ? ? return "%s. In the %s you see %s." % (self._description, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? self.name, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? items) > ? ? description = property(_detailedDescription) > > class Money(Thing): > ? ? # ? note: I've not worked out how to safely handle combining money > objects > ? ? def __init__(self, name, description, amount, parent, hidden=False, > fixed=False): > ? ? ? ? super(Money, self).__init__(name, description, parent, hidden, > fixed) > ? ? ? ? self._value = amount > ? ? def _detailedDescription(self): > ? ? ? ? return "%s pieces of gold" % self._value > ? ? description = property(_detailedDescription) > ? ? def combine(self, money): > ? ? ? ? self._value += money._value > > class Avatar(Gobject): > ? ? def __init__(self, name, description, location, hidden=True, > fixed=True): > ? ? ? ? super(Avatar, self).__init__(name, description, hidden, fixed) > ? ? ? ? self.location = location > ? ? ? ? self._inventory = {} > ? ? def addInv(self, itm): > ? ? ? ? itm.hidden = False > ? ? ? ? if itm.name in self._inventory: ?#presume only gold is > duplicated > ? ? ? ? ? ? self._inventory[itm.name].combine(itm) > ? ? ? ? ? ? del itm > ? ? ? ? else: > ? ? ? ? ? ? self._inventory[itm.name] = itm > ? ? def remInv(self, name): > ? ? ? ? ? ?itm = self._inventory.get(name, None) > ? ? ? ? ? ?if itm: del self._inventory[name] > ? ? ? ? ? ?return itm > ? ? def inv(self): > ? ? ? ? return ", ".join([itm for itm in self._inventory.keys()]) > > #create the universe -- first the raw rooms > room1 = Room("empty room", > ? ? ? ? ? ? ?"a completely empty room") > room2 = Room("time passages", > ? ? ? ? ? ? ?"a fourth-dimensional room having no fixed shape or size") > room3 = Room("control room", > ? ? ? ? ? ? ?"the control room of a TARDIS") > room4 = Room("locker room", > ? ? ? ? ? ? ?"a room full of storage spaces") > > #create each exit > exit1_2 = Exit("you squeeze through the mouse hole", room2) > exit1_4 = Exit("you take the doorway", room4) > exit2_3 = Exit("the TARDIS door opens and you pass in", room3, > hidden=True) > exit3_2 = Exit("you leave the TARDIS", room2) > exit3_1 = Exit("you sneak deeper into the depths of the TARDIS", room1) > exit4_1 = Exit("you move through the door", room1) > exit2_1 = Exit("you take the wormhole out", room1) > exit2_4 = Exit("you follow the light", room4) > exit4_2 = Exit("you follow the shadow", room2) > exit2_2a = Exit("as you enter the reddish passage you see yourself > leaving the room", room2) > exit2_2b = Exit("you feel a bit older as you take the blue passage", > room2) > exit2_2c = Exit("you feel confused as you cross webs of the timestream", > room2) > > #connect rooms to exits > room1.setExits({"hole" : exit1_2, > ? ? ? ? ? ? ? ? "door" : exit1_4}) > room2.setExits({"tardis" : exit2_3, > ? ? ? ? ? ? ? ? "wormhole" : exit2_1, > ? ? ? ? ? ? ? ? "light" : exit2_4, > ? ? ? ? ? ? ? ? "past" : exit2_2a, > ? ? ? ? ? ? ? ? "future" : exit2_2b, > ? ? ? ? ? ? ? ? "sideways" : exit2_2c}) > room3.setExits({"out" : exit3_2, > ? ? ? ? ? ? ? ? "in" : exit3_1}) > room4.setExits({"door" : exit4_1, > ? ? ? ? ? ? ? ? "shadow" : exit4_2}) > > #create a few non-room objects > container1 = Thing("closet", "an empty closet", room4, fixed=True) > gold = Money("gold", None, 8, room4, hidden=True) > container2 = TriggerThing("footlocker", "a fancy carved captain's > chest", room4, > ? ? ? ? ? ? ? ? ? ? ? ? ? fixed=True, triggers=[gold]) > > room4.setDetails({container1.name : container1, > ? ? ? ? ? ? ? ? ? container2.name : container2, > ? ? ? ? ? ? ? ? ? gold.name : gold}) > > #the tardis is both an exit and a thing > tardis = Thing("tardis", "a beat-up type 40 TARDIS", room2, fixed=True) > room2.setDetails({tardis.name : tardis}) > > screwdriver = Thing("screwdriver", "a well worn sonic screwdriver", > room3) > room3.setDetails({screwdriver.name : screwdriver}) > > player = Avatar("Wulfraed", "a nondescript individual", room1) > > #note: no end conditions are defined > while True: > ? ? print player.location.description > ? ? while True: > ? ? ? ? cmdstr = raw_input("command> ").strip().lower() > ? ? ? ? if cmdstr: break > ? ? words = cmdstr.split() > ? ? verb = words[0] > ? ? if len(words) > 1: > ? ? ? ? objct = words[1] > ? ? else: > ? ? ? ? objct = None > ? ? if verb in ["look", "examine"]: > ? ? ? ? if objct: > ? ? ? ? ? ? desc = player.location.examine(objct) > ? ? ? ? else: > ? ? ? ? ? ? desc = player.location.examine() > ? ? ? ? if desc: > ? ? ? ? ? ? print desc > ? ? ? ? else: > ? ? ? ? ? ? print "I don't see that here" > ? ? elif verb in ["grab", "take"]: > ? ? ? ? if objct: > ? ? ? ? ? ? itm = player.location.delDetail(objct) > ? ? ? ? ? ? if itm: > ? ? ? ? ? ? ? ? player.addInv(itm) > ? ? ? ? ? ? ? ? print "%s taken" % itm.name > ? ? ? ? ? ? else: > ? ? ? ? ? ? ? ? print "I can not %s the %s" % (verb, objct) > ? ? ? ? else: > ? ? ? ? ? ? print "%s what?" % verb > ? ? elif verb in ["drop", "leave"]: > ? ? ? ? if objct: > ? ? ? ? ? ? itm = player.remInv(objct) > ? ? ? ? ? ? if itm: > ? ? ? ? ? ? ? ? player.location.addDetail(itm) > ? ? ? ? ? ? ? ? print "%s dropped" % itm.name > ? ? ? ? ? ? else: > ? ? ? ? ? ? ? ? print "I don't have the %s" % objct > ? ? ? ? else: > ? ? ? ? ? ? print "%s what?" % verb > ? ? elif verb in ["walk", "run", "go"]: > ? ? ? ? if objct: > ? ? ? ? ? ? ext = player.location.go(objct) > ? ? ? ? ? ? if ext: > ? ? ? ? ? ? ? ? print ext.description > ? ? ? ? ? ? ? ? player.location = ext.target > ? ? ? ? ? ? else: > ? ? ? ? ? ? ? ? print "I can't go that way" > ? ? ? ? else: > ? ? ? ? ? ? print "%s where?" % verb > ? ? elif verb... > > read more ? I still can't run that....after fixing the simple stuff like 'invalid syntax', there's the "Name examine is not defined." So... From jeffrey at fro.man Mon Apr 7 14:24:47 2008 From: jeffrey at fro.man (Jeffrey Froman) Date: Mon, 07 Apr 2008 11:24:47 -0700 Subject: Tips for load balancing multiple Python apps on dual/quad core processors? References: Message-ID: <9MmdnSE8nY9t-2fanZ2dnUVZ_uevnZ2d@cablespeedwa.com> Malcolm Greene wrote: > I'm looking for tips on how to load balance running multiple Python > applications in multi-CPU environments. My understanding is that Python > applications and their threads are limited to a specific CPU. > > Background: I have a Python utility that processes email messages. I > suspect there's a lot of idle time while this utility waits on a remote > email server. While it's true that python's threads are limited to using a single CPU at a time, it sounds like your bottleneck is network IO, not CPU power. I imagine that your one CPU is doing a lot of idling, thumb-twiddling, etc., while waiting for the remote email server to respond. In such a scenario, python's threads will work fine to speed your application. On the other hand, adding CPUs to an IO-bound application isn't likely to speed it up at all. Jeffrey From __peter__ at web.de Tue Apr 29 02:35:46 2008 From: __peter__ at web.de (Peter Otten) Date: Tue, 29 Apr 2008 08:35:46 +0200 Subject: File IO Issues, help :( References: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> <1fd8deae-1ed4-493c-a508-06c528c4ee1f@r66g2000hsg.googlegroups.com> Message-ID: Kevin K wrote: > On Apr 29, 12:55 am, Peter Otten <__pete... at web.de> wrote: >> Kevin K wrote: >> > On Apr 29, 12:38 am, "Eric Wertman" wrote: >> >> chuck in a jsfile.close(). The buffer isn't flushing with what you >> >> are doing now. jsfile.flush() might work... not sure. Closing and >> >> re-opening the file for sure will help though. >> >> > Yeah sorry I forgot to include the close() in the quote but its there. >> > In fact I moved it up a bit and still no luck heres the new code: >> >> > jsfile = open("../timeline.js", "r+") >> > jscontent = jsfile.readlines() >> > jsfile.truncate() >> >> > for line in jscontent: >> > if re.search('var d =', line): >> > line = "var d = \""+mint['1'].ascdate()+"\"\n" >> > print line >> > jsfile.write(line) >> > jsfile.close() >> >> > I tried this can got the same result...?? >> >> """ >> truncate(...) >> truncate([size]) -> None. Truncate the file to at most size bytes. >> >> Size defaults to the current file position, as returned by tell(). >> """ >> >> After the readlines() call the current file position is at the end of the >> file. Try jsfile.truncate(0). >> >> Also note that readlines() reads the whole file into memory. For large >> files it would therefore be better to write to a new file and rename it >> afterwards. >> >> Peter > > Thanks Peter that seemed to be most of the problem, however I now have > a bunch of null characters in the file. Could it be an unwanted line > in the list that im writing? Oops, truncate() doesn't affect the file position. You probably need jsfile.truncate(0) jsfile.seek(0) Peter From xng at xs4all.nl Thu Apr 17 19:21:31 2008 From: xng at xs4all.nl (Martin P. Hellwig) Date: Fri, 18 Apr 2008 01:21:31 +0200 Subject: get quote enclosed field in a line In-Reply-To: References: Message-ID: <4807dc10$0$25223$e4fe514c@dreader18.news.xs4all.nl> xahlee at gmail.com wrote: > is there a simple way in perl, python, or awk/shell/pipe, that gets > the user agent field in a apache log? > > e.g. the typical line is like this: > > 189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET / > Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org > "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/ > 5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311 > Firefox/2.0.0.13" "-" > > I want the part: "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv: > 1.8.1.13) Gecko/20080311 Firefox/2.0.0.13". > > Thanks. > > Xah > xah at xahlee.org > ? http://xahlee.org/ > > ? Something like: # cut -d '"' -f 6 < httpd-access.log ? -- mph From python.list at tim.thechases.com Tue Apr 8 16:49:59 2008 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 08 Apr 2008 15:49:59 -0500 Subject: new user needs help! In-Reply-To: References: <16571823.post@talk.nabble.com> Message-ID: <47FBDA77.1030009@tim.thechases.com> > f = open("/tmp/data.txt", 'w') > > will open that file. > > You can throw the first line away with > > headings = f.next() > > Then you can loop over the rest with > > for name, aa, topo, access, dssp, stride, z in file: > # > # Then process each line here Small caveat here...Steve changed file-variables on you here, and assumed a tuple-unpacking that won't work. You'll want something like for line in f: (name, aa, topo, access, dssp, stride, z) = ( line.rstrip('\n').split('\t') # process the line here I don't know how your fields are delimited, whether by spaces or tabs. In the above code, I split by tabs, but you can just use .split() if it should be split on any white-space. It's a bit more complex if you need to split by column-offsets. -tkc From karthikk at adventnet.com Tue Apr 8 05:48:54 2008 From: karthikk at adventnet.com (Karthik) Date: Tue, 08 Apr 2008 15:18:54 +0530 Subject: Setting default version among multiple python installations Message-ID: <47FB3F86.5040702@adventnet.com> Hello, I am an absolute linux and python newbie. The linux machine(red hat version 7.2) that i managed to get my hands on had python 1.5(vintage stuff, i guess) in it. I have installed python 2.5 using the source tar. However, when i try to access python, i am taken to the older version only. How do i set python2.5 as the default version? -Karthik -------------- next part -------------- An HTML attachment was scrubbed... URL: From sjmachin at lexicon.net Sun Apr 13 19:54:14 2008 From: sjmachin at lexicon.net (John Machin) Date: Sun, 13 Apr 2008 16:54:14 -0700 (PDT) Subject: py2exe, program has stoped working!? References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> Message-ID: <232151d6-09ed-4a1e-9922-d66c2bf0d05b@w8g2000prd.googlegroups.com> On Apr 13, 11:52 pm, skanem... at yahoo.se wrote: > so i used py2exe and i have the build and the dist-folders. > > in the distfolder there is a Calculator.exe file. > > when i run it it just says "Calculator.exe has stopped working" in a > popup but the program itself never shows up. Is it a console program or a gui program? What happens when you run it without py2exe? Have you searched for "has stopped working" in (a) your source code (b) the py2exe source code? Have you managed to get any py2exe-created program to run properly? From Randy.Galbraith at gmail.com Tue Apr 22 12:46:43 2008 From: Randy.Galbraith at gmail.com (Randy Galbraith) Date: Tue, 22 Apr 2008 09:46:43 -0700 (PDT) Subject: Compiling Python 2.5.2 on AIX 5.2 References: <0b73e8e5-c301-4823-ac94-42f757456cf1@x19g2000prg.googlegroups.com> <48059DA9.5080900@v.loewis.de> <480c2364$0$26788$9b622d9e@news.freenet.de> Message-ID: On Apr 20, 10:17 pm, "Martin v. L?wis" wrote: > I recommend you disable compilation of ctypes (by removing the call > to detect_ctypes from setup.py). It's fairly unlikely that you can > manage to make ctypes work on your system. Martin, Thanks again. I'm much closer now. Here is the script I'm using to compile Python on AIX: --begin script-- cp /path/to/include/bzlib.h Include/. cat <: [Errno 22] Invalid argument and for wait4: test test_wait4 failed -- Traceback (most recent call last): File "Python-2.5.2/Lib/test/fork_wait.py", line 75, in test_wait self.wait_impl(cpid) File "Python-2.5.2/Lib/test/test_wait4.py", line 28, in wait_impl self.assertEqual(spid, cpid) AssertionError: 0 != 6840386 What do these failures indicate? Not sure of course, but will research and report back. Kind regards, -Randy Galbraith "We seem to be made to suffer. It's our lot in life." - C3PO of Star Wars From stesch at no-spoon.de Wed Apr 2 03:03:33 2008 From: stesch at no-spoon.de (Stefan Scholl) Date: Wed, 2 Apr 2008 09:03:33 +0200 Subject: developing web spider References: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> Message-ID: <2T4u1vuoI47qNv8%stesch@parsec.no-spoon.de> abeen wrote: > I would want to know which could be the best programming language for > developing web spider. Since you ask in comp.lang.python: I'd suggest APL -- Web (en): http://www.no-spoon.de/ -*- Web (de): http://www.frell.de/ From wizzardx at gmail.com Tue Apr 22 15:38:08 2008 From: wizzardx at gmail.com (David) Date: Tue, 22 Apr 2008 21:38:08 +0200 Subject: Setting expirty data on a cookie In-Reply-To: <8ba48e05-9aba-4a56-805c-cd31b43517ab@24g2000hsh.googlegroups.com> References: <8ba48e05-9aba-4a56-805c-cd31b43517ab@24g2000hsh.googlegroups.com> Message-ID: <18c1e6480804221238x574bf3dbxb9a2f25d445f190b@mail.gmail.com> On Tue, Apr 22, 2008 at 6:21 PM, sophie_newbie wrote: > Does anyone know how to do this? I can't seem to make it work. > > I'm using: > > c = Cookie.SimpleCookie() > c['data'] = "unamepwordwhatever" > c.expires = time.time() + 300 > print c > > > This doesn't seem to work, so I'm assuming isn't the correct way to > set an expiry data? Anyone able to help me out here? > You're probably looking for cookielib.Cookie From bgeddy at home.havin.a.break Mon Apr 28 08:13:17 2008 From: bgeddy at home.havin.a.break (bgeddy) Date: Mon, 28 Apr 2008 13:13:17 +0100 Subject: Retrieving int from hex in a file. In-Reply-To: <9edfaaa3-4e87-4f74-90a5-c10c9daae101@r66g2000hsg.googlegroups.com> References: <9edfaaa3-4e87-4f74-90a5-c10c9daae101@r66g2000hsg.googlegroups.com> Message-ID: Filipe Teixeira wrote: > Hi. > > I have to open a binary file from an old computer and recover the > information stored (or at least try to). I use: > > f=open('file.bin','rb') > a=f.read() > f.close() > > a in now a string full of hex representations in the form: > > a[6]='\x14' > a[7]='\x20' > > I would like to convert these hex representations to int, but this > (the most obvious way) doesn't seem to be working > >>>> q=a[6] >>>> q > '\x14' >>>> int(q,16) > Traceback (most recent call last): > File "", line 1, in ? > ValueError: invalid literal for int(): > > How can I do this? > > Thanks As you say you are trying to recover information from the old computer are you sure you want to convert the data to it's integer representation ? What I mean is in this case the string will contain the actual data read from the file, not a hex representation. It's just the python displays this data as '\x14'. BTW - are you sure it's displaying '\x20' from your data as this should be a space character i.e. " ". In the python interpreter try this: mydata="" for i in range(256): mydata+=chr(i) >> mydata This will show you the hex representation of the values in mydata that it can't display however the string is not a string of "hex values" as such, it contains the binary values 0-255. From the.blue.valkyrie at gmail.com Tue Apr 8 09:54:12 2008 From: the.blue.valkyrie at gmail.com (=?ISO-8859-1?Q?Cristina_Yenyxe_Gonz=E1lez_Garc=EDa?=) Date: Tue, 8 Apr 2008 15:54:12 +0200 Subject: UML reverse engineering In-Reply-To: <4660fe300804050617k28769016k4687246349352cdc@mail.gmail.com> References: <6712345.1824821207324312295.JavaMail.servlet@kundenserver> <4660fe300804050617k28769016k4687246349352cdc@mail.gmail.com> Message-ID: If you are a Linux user, you can also take a look at Umbrello UML (it is part of the KDE Desktop). -------------- next part -------------- An HTML attachment was scrubbed... URL: From pscott at uwc.ac.za Tue Apr 8 04:10:25 2008 From: pscott at uwc.ac.za (Paul Scott) Date: Tue, 08 Apr 2008 10:10:25 +0200 Subject: First Python project - comments welcome! In-Reply-To: <4a200ecf-a945-4cb6-8f91-0b8baf378e18@n58g2000hsf.googlegroups.com> References: <4a200ecf-a945-4cb6-8f91-0b8baf378e18@n58g2000hsf.googlegroups.com> Message-ID: <1207642225.13710.35.camel@paul-laptop> On Mon, 2008-04-07 at 06:20 -0700, bruno.desthuilliers at gmail.com wrote: > > If anyone on this list is willing/able, please do give me a few > > pointers, even if it is "This is total crap - RTFM and come back when > > you are ready" I would really appreciate it! > > Ok, since you asked for it: > Awesome feedback! Thank you very much. This is exactly what I needed. I will take this into the code as soon as I have some time to play with it again and fix it up. Much appreciated! --Paul -------------- next part -------------- All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm From fennelllindy8241 at gmail.com Mon Apr 28 03:24:11 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:24:11 -0700 (PDT) Subject: ravenhearst crack Message-ID: <80344dda-9026-44f8-aef9-eb61c2e554fc@x35g2000hsb.googlegroups.com> ravenhearst crack http://crack.cracksofts.com From Jim.Vickroy at noaa.gov Wed Apr 2 14:17:33 2008 From: Jim.Vickroy at noaa.gov (j vickroy) Date: Wed, 02 Apr 2008 12:17:33 -0600 Subject: ANN: pry unit testing framework In-Reply-To: References: Message-ID: <47F3CDBD.1010600@noaa.gov> Aldo Cortesi wrote: > We are happy to announce the first release of Pry, a unit testing framework. > > Features > ======== > > * Built-in coverage analysis, profiling, and quick-and-dirty benchmarking > * Assertion-based tests - no ugly failUnless*, failIf*, etc. methods > * Tree-based test structure for better fixture management > * No implicit instantiation of test suits > * Powerful command-line interface > > > Download: http://dev.nullcube.com > > Manual: http://dev.nullcube.com/doc/pry/index.html > > It appears this package can not be used with Microsoft Windows because it uses the *fcntl* module which is not part of the Windows distribution. >>> import sys >>> sys.version '2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]' >>> >>> import libpry Traceback (most recent call last): File "", line 1, in File "C:\Python25\Lib\site-packages\libpry\__init__.py", line 1, in from test import * File "C:\Python25\Lib\site-packages\libpry\test.py", line 4, in import _tinytree, explain, coverage, utils File "C:\Python25\Lib\site-packages\libpry\coverage.py", line 3, in import utils File "C:\Python25\lib\site-packages\libpry\utils.py", line 1, in import os.path, fnmatch, struct, fcntl, termios, os ImportError: No module named fcntl Unfortunate, because I'm definitely interested in the code coverage and profiling features. -- jv From danb_83 at yahoo.com Tue Apr 8 00:19:57 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Mon, 7 Apr 2008 21:19:57 -0700 (PDT) Subject: Newbie: How to pass a dictionary to a function? References: <516e07d1-91f9-462b-9fc0-ac6d1e474f9d@n14g2000pri.googlegroups.com> Message-ID: <1a0d619e-d910-41c9-b85b-612f50cb96b9@t36g2000prm.googlegroups.com> On Apr 7, 10:54 pm, BonusOnus wrote: > How do I pass a dictionary to a function as an argument? The same way you pass any other argument. > # Say I have a function foo... > def foo (arg=[]): It's generally a bad idea to use [] as a default argument. > x = arg['name'] > y = arg['len'] > > s = len (x) > > t = s + y > > return (s, t) Apart from the lack of indentation (and meaningless variable names), it looks correct. > # The dictionary: > > dict = {} > dict['name'] = 'Joe Shmoe' > dict['len'] = 44 "dict" is a built-in name. Don't redefine it. > # I try to pass the dictionary as an argument to a > # function > > len, string = foo (dict) Don't redefine "len" or "string" either. > # This bombs with 'TypeError: unpack non-sequence' > > What am I doing wrong with the dictionary? Runs fine for me as soon as I fixed the indentation. From gagsl-py2 at yahoo.com.ar Mon Apr 28 06:29:12 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 28 Apr 2008 07:29:12 -0300 Subject: Retrieving int from hex in a file. References: <9edfaaa3-4e87-4f74-90a5-c10c9daae101@r66g2000hsg.googlegroups.com> Message-ID: En Mon, 28 Apr 2008 07:14:51 -0300, Filipe Teixeira escribi?: > a in now a string full of hex representations in the form: > > a[6]='\x14' > a[7]='\x20' > > I would like to convert these hex representations to int, but this > (the most obvious way) doesn't seem to be working > >>>> q=a[6] >>>> q > '\x14' >>>> int(q,16) > Traceback (most recent call last): > File "", line 1, in ? > ValueError: invalid literal for int(): >>>> Use ord(q) py> help(ord) Help on built-in function ord in module __builtin__: ord(...) ord(c) -> integer Return the integer ordinal of a one-character string. py> -- Gabriel Genellina From destroooooy at gmail.com Tue Apr 29 17:16:33 2008 From: destroooooy at gmail.com (destroooooy) Date: Tue, 29 Apr 2008 14:16:33 -0700 (PDT) Subject: string translate, replace, find and the forward slash References: <1030ffc2-1bbe-4539-881d-35bf59cacd11@34g2000hsh.googlegroups.com> Message-ID: On Apr 29, 4:50 pm, Arnaud Delobelle wrote: > destroooooy writes: > > Hi folks, > > I'm finding some (what I consider) curious behavior with the string > > methods and the forward slash character. I'm writing a program to > > rename mp3 files based on their id3 tags, and I want to protect > > against goofy characters in the in tags. So I do the following: > > > unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n" > > alt_chars = "_________________________" > > > s_artist.translate(maketranstable(unsafe_chars, alt_chars)) > > > which successfully replaces everything except for forward slashes (at > > least in the files I've tested so far). If I use the "replace()" > > method, it also does not work. Escaping the forward slash changes > > nothing. "find()" however, works, and thus I've resorted to: > > > if "/" in s_artist: > > (s_l, slash, s_r) = s_artist.partition("/") > > s_artist = "_".join([s_l, s_r]) > > > which is rather uncool. It works but I'd just like to know what the > > deal is. TIA. > > It works fine here: > > marigold:junk arno$ python > Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) > [GCC 4.0.1 (Apple Inc. build 5465)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > > >>> unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n" > >>> table = range(256) > >>> for c in unsafe_chars: table[ord(c)] = ord('_') > ... > >>> table = ''.join(chr(o) for o in table) > >>> 'Jon(&Mark/Steve)'.translate(table) > 'Jon__Mark_Steve_' > > -- > Arnaud Okay, so that definitely works. Thanks! However, the chances of me coming up with that on my own were completely nonexistent, and I'd still like to know how one would use maketranstable() to get the same result... From leoniaumybragg at gmail.com Sat Apr 26 06:57:19 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:57:19 -0700 (PDT) Subject: sims 2 patch Message-ID: sims 2 patch http://cracks.00bp.com F R E E C R A C K S From george.sakkis at gmail.com Fri Apr 4 17:08:18 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 4 Apr 2008 14:08:18 -0700 (PDT) Subject: Tokenizer inconsistency wrt to new lines in comments References: <1ce40dcf-4a0a-4577-af3b-6a77ef71356c@f63g2000hsf.googlegroups.com> <6dd69a1f-96d0-4b91-b84b-a54794a31c70@u36g2000prf.googlegroups.com> <8b3fa4cc-deb9-4748-a63c-a6c7e5dd92ba@59g2000hsb.googlegroups.com> Message-ID: <644d73d0-b3ec-4a98-b722-af78604ddb6b@k13g2000hse.googlegroups.com> On Apr 4, 4:38 pm, Fredrik Lundh wrote: > George Sakkis wrote: > >> If it was a bug it has to violate a functional requirement. I can't > >> see which one. > > > Perhaps it's not a functional requirement but it came up as a real > > problem on a source colorizer I use. I count on newlines generating > > token.NEWLINE or tokenize.NL tokens in order to produce
tags. It > > took me some time and head scratching to find out why some comments > > were joined together with the following line. Now I have to check > > whether a comment ends in new line and if it does output an extra
> > tag.. it works but it's a kludge. > > well, the real kludge here is of course that you're writing your own > colorizer, when you can just go and grab Pygments: > > http://pygments.org/ > > or, if you prefer something tiny and self-contained, something like the > colorizer module in this directory: > > http://svn.effbot.org/public/stuff/sandbox/pythondoc/ > > (the element_colorizer module in the same directory gives you XHTML in > an ElementTree instead of raw HTML, if you want to postprocess things) > > First off, I didn't write it from scratch, I just tweaked a single module colorizer I had found online. Second, whether I or someone else had to deal with it is irrelevant; the point is that generate_tokens() is not consistent with respect to new lines after comments. George From tinnews at isbd.co.uk Thu Apr 3 07:37:50 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 03 Apr 2008 11:37:50 GMT Subject: Efficient way of testing for substring being one of a set? Message-ID: <47f4c18e$0$715$bed64819@news.gradwell.net> What's the neatest and/or most efficient way of testing if one of a set of strings (contained in a dictionary, list or similar) is a sub-string of a given string? I.e. I have a string delivered into my program and I want to see if any of a set of strings is a substring of the string I have been given. It's quite OK to stop at the first one found. Ideally the strings being searched through will be the keys of a dictionary but this isn't a necessity, they can just be in a list if it could be done more efficiently using a list. Is this the best one can do (ignoring the likelihood that I've got some syntax wrong) :- # l is the list # str is the incoming string answer = "" for x in l: if str.find(x) < 0: continue answer = x -- Chris Green From steve at holdenweb.com Fri Apr 25 07:38:08 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 25 Apr 2008 07:38:08 -0400 Subject: how to mysqldb dict cursors In-Reply-To: <17d58cc40804242358s26446c42h36f875cf0ee62199@mail.gmail.com> References: <17d58cc40804241950i7b624e1apd2733daa79b3ed5c@mail.gmail.com> <481161FD.5020407@ulmcnett.com> <17d58cc40804242358s26446c42h36f875cf0ee62199@mail.gmail.com> Message-ID: Vaibhav.bhawsar wrote: [top-posting amended: see below] > On Fri, Apr 25, 2008 at 12:45 AM, Paul McNett

> wrote: > > Vaibhav.bhawsar wrote: > > I have been trying to get the DictCursor working with mysqldb > module but can't seem to. I have pasted the basic connection > code and the traceback from pydev. The connection does open with > the default cursor class. can't figure this one out. many thanks. > > > Try one of: > > """ > import MySQLdb, MySQLdb.cursors > conn = MySQLdb.connect(..., cursorclass=MySQLdb.cursors.DictCursor) > """ > > -or- > > """ > import MySQLdb, MySQLdb.cursors > conn = MySQLdb.connect(...) > cur = MySQLdb.cursors.DictCursor(conn) > """ > > I'm going off of memory here, though, but I'm at least close. > > Great both methods worked! I don't quite understand this since i imported > the whole module with "import MySQLdb" > > Thanks! > The point here is that MySQLdb is a package, not a module. Some packages have their top-level __init__.py import the package's sub-modules or sub-packages to make them immediately available within the package namespace (which is why, for example, you can access os.path.* when you have imported os) and others don't. MySQLdb clearly doesn't need to import the cursors module for its own purposes. Perhaps it would be less efficient to always perfrom the import, who knows. Well, Andy Dustman does, I suppose, and possibly anyone else who reads the code, but I haven't done that myself. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gagsl-py2 at yahoo.com.ar Thu Apr 3 22:06:44 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 23:06:44 -0300 Subject: Is there an official way to add methods to an instance? References: <47F57D14.8030206@aim.com> Message-ID: En Thu, 03 Apr 2008 21:57:56 -0300, Brian Vanderburg II escribi?: > I don't know if this is the correct place to send this question. > > I've checked out some ways to get this to work. I want to be able to > add a new function to an instance of an object. I've tested two > different methods that cause problems with 'deleting'/garbage collection > (__del__ may never get called), but implemented one sort of hackishly > maybe that works find. I'm wondering if there is more of an official way > than mine. > > 1. > import new > import gc > > class A: > def __del__(x): > print "Deleting" > > def f(x): > print x > > a = A() > a.f = new.instancemethod(a,f) > a.f() # This works > del a # Not what is expected > gc.collect() # Works, but __del__ does not get called O thou of little faith, wherefore didst thou doubt? This is the simplest and preferred way, and it works! It's true that there is a reference cycle between a and a.f, but the garbage collector is able to detect it and dispose of those objects *UNLESS* any of them contains a __del__ method written in Python. See http://docs.python.org/ref/customization.html So this *is* the right way, and the object `a` would have been deleted if you had not tried to witness the deletion itself... You perturbed the system in a non trivial way just by attempting to observe it - isn't this Quantum Mechanics applied to Python programming? We need a side-effect triggered by __del__ but written in C... hmmm, what about flushing a file buffer? py> import new py> import gc py> import os py> py> class myfile(file): # just to be able to add attributes ... pass ... py> def f(x): ... print x ... py> a = myfile("a.aaa","w") py> print os.stat("a.aaa").st_size # 0 0 py> a.f = new.instancemethod(f, a) py> a.f() # This works py> a.write("X") # a single char, should stay on write buffer py> print os.stat("a.aaa").st_size # still 0 0 py> del a py> print os.stat("a.aaa").st_size # still 0 0 py> gc.collect() 3 py> print os.stat("a.aaa").st_size # now 1 1 -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Sat Apr 12 23:03:49 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 13 Apr 2008 00:03:49 -0300 Subject: String Literal to Blob References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> Message-ID: En Sat, 12 Apr 2008 16:11:20 -0300, Victor Subervi escribi?: > On Fri, Apr 11, 2008 at 2:05 PM, Steve Holden > wrote: > >> Then browse to the URL this program serves and you will see the image >> (assuming you are still sending the image/jpeg content type). > > Well, as I mentioned before, I am sending text/html because the page, > like > almost all web pages, has a whole lot more content than just images. Or, > perhaps you are suggesting I build my pages in frames, and have a frame > for > every image. Unsightly! (Oh my...!) Thanks to Helloween (the metal band) I was in the right mood to write a small example. Simple, bare, raw code: no fancy HTML, no templates, no web frameworks, using the embedded sqlite engine. It works with Python 2.5 out of the box. Each functional piece is in its own file, to emphasize the one-document-per-request rule. It is a photo album, one can upload pictures with title and description, and later see them one at a time. How to run: Create a temporary folder. Create a cgi-bin subdirectory, and copy the four scripts there. In the parent directory, execute: python -m CGIHTTPServer Using your browser, go to http://localhost:8000/cgi-bin/album.py?init=1 (the init parameter is to create the database; you can omit it once it's done). Note that there are TWO scripts involved when you want to display a picture: showpic.py returns the HTML page, containing tags like this: %s" % (picid, cgi.escape(title)) (note the src attribute) and getpic.py returns the picture itself. Note also that this is just a demo; for a real web application I would choose one of the many existing frameworks; or WSGI, or mod_python, finally cgi. And my scripts have absolutely no check for errors at all, and the HTML is not even valid. I hope you finally get the idea of how to serve dynamic content... -- Gabriel Genellina -------------- next part -------------- A non-text attachment was scrubbed... Name: upload.py Type: application/octet-stream Size: 2325 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: album.py Type: application/octet-stream Size: 1228 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: getpic.py Type: application/octet-stream Size: 499 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: showpic.py Type: application/octet-stream Size: 726 bytes Desc: not available URL: From paulgeeleher at gmail.com Tue Apr 22 12:32:38 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Tue, 22 Apr 2008 09:32:38 -0700 (PDT) Subject: Spawing a thread and printing dots until it finishes References: Message-ID: On Apr 22, 4:41 pm, "D'Arcy J.M. Cain" wrote: > On Tue, 22 Apr 2008 07:10:07 -0700 (PDT) > > > > sophie_newbie wrote: > > import threading > > class MyThread ( threading.Thread ): > > def run ( self ): > > myLongCommand()... > > > import time > > > t = MyThread() > > t.start() > > > while t.isAlive(): > > print "." > > time.sleep(.5) > > > print "OK" > > > The thing is this doesn't print a dot every half second. It just > > pauses for ages until the thread is finished and prints prints ".OK". > > But if I take out the "time.sleep(.5)" line it will keep printing dots > > really fast until the thread is finished. So it looks like its the > > time.sleep(.5) bit that is messing this up somehow? > > We know that your main routine gives up the processor but without a > full definition of MyThread how do we know that it ever does? I > suspect that it hits sleep once, if at all, and then goes to the final > print statement. In fact, I suspect that this is not exactly what you > tried anyway. This code would not have printed ".OK" whether it > entered the loop or not. It could have printed this; > > . > OK > > because the print statement in the loop will print a dot on a line by > itself. > > When looking for these sorts of answers you should really try to create > a smallest program that exhibits the behaviour you are questioning and > then cut and paste the entire script into your message unedited. Often > enough you will even answer your own question in the process. > > -- > D'Arcy J.M. Cain | Democracy is three wolveshttp://www.druid.net/darcy/ | and a sheep voting on > +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. "myLongCommand()... " is a call to an function in R (the statistical programming language) via Rpy (A python module that allows calls to R). The call takes a couple of minutes to execute. I'm trying to build a web front end to this R function and instead of the user looking at a blank screen for 2-3 mins, I want to print dots to let them feel like the program isn't hanging. What I am saying is that without the "time.sleep(.5)" line, the above code will print dots on the screen continuously for 2-3 mins, filling it up with a ridiculous ammount of dots. Whereas with the time.sleep line, instead of pausing for half a second between dots, its seems to print, as you correctly pointed out: . OK With a pause of 2-3 minutes between the . and the OK. I hope that clears things up a little. I haven't the faintest idea why the code above doesn't work but hope someone has an idea. It wouldn't be something to do with python not being able to handle multiple threads at the same time or something? I hope there is a workaround. From steve at holdenweb.com Fri Apr 11 08:52:46 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 11 Apr 2008 08:52:46 -0400 Subject: Can we send and receive data to and from Port Using Python ? In-Reply-To: <004901c77c25$130446b0$750ba8c0@patni.com> References: <004901c77c25$130446b0$750ba8c0@patni.com> Message-ID: sambasivareddy wrote: > Hi, > I am new to this group. I have some question, it is listed below. > In my application I should send some data to hardware and it will give > response that response should log in one file. To do it first should > send data to port next receive response from port (hardware) so... > > __ > > _Queries:_ > 1) Can we able to send data to serial port using python? If yes how? The usual mechanism is the pyserial module. Google is your friend. > 2) Can we able to receive data from serial port using python? If yes how? See answer to 1) > 3) Is there any function like "Register event call back?, please explain? > (Register event call back: registers a script to be called when an event > occurs) I believe you need to implement the observer pattern. There have already been several successful implementations of this, and again Google should be capable of finding them. For example: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/131499 > 4) Is it possible "parallel loops" concept in python (In my application > send data to port and receive data should be in one file and execute at > same time)? Most Python implementations support threading, and there are a number of other asynchronous service techniques. There should be absolutely no problem. > > If anyone knows answers please clarify and have any examples related to > this please send it .if u need any information regarding questions > please let me know. > Thanks in advance. > regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From carlwuhwdmckay at gmail.com Mon Apr 21 02:10:10 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:10:10 -0700 (PDT) Subject: cabbage patch kids messy face doll Message-ID: <22f9121f-5145-4350-a2f5-d653f4559898@24g2000hsh.googlegroups.com> cabbage patch kids messy face doll http://cracks.00bp.com F R E E C R A C K S From gmarketer at gmail.com Tue Apr 22 07:07:01 2008 From: gmarketer at gmail.com (GD) Date: Tue, 22 Apr 2008 04:07:01 -0700 (PDT) Subject: Remove multiple inheritance in Python 3000 Message-ID: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> Please remove ability to multiple inheritance in Python 3000. Multiple inheritance is bad for design, rarely used and contains many problems for usual users. Every program can be designed only with single inheritance. I also published this request at http://bugs.python.org/issue2667 From darcy at druid.net Thu Apr 3 13:03:38 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Thu, 3 Apr 2008 13:03:38 -0400 Subject: Why prefer != over <> for Python 3.0? In-Reply-To: References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> <87prt9coti.fsf@pobox.com> Message-ID: <20080403130338.9c1102ce.darcy@druid.net> On Thu, 03 Apr 2008 05:12:28 GMT Tim Roberts wrote: > Yes, indeed. In response to a challenge posted on one of the x86 assembler > newsgroups about two years ago, one intrepid Russian programmer produced a > generic Sudoku solver in a 65-byte executable. Yes, that's 65 BYTES -- not > KB, not MB. Wow! I would have thought that the header on most executible file formats was bigger than that these days. Or was this done as a .COM file or something like that? -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From grante at visi.com Wed Apr 16 10:19:37 2008 From: grante at visi.com (Grant Edwards) Date: Wed, 16 Apr 2008 09:19:37 -0500 Subject: Finally had to plonk google gorups. Message-ID: This morning almost half of c.l.p was spam. In order to try to not tar both the benign google group users and the malignant ones with the same brush, I've been trying to kill usenet spam with subject patterns. But that's not a battle you can win, so I broke down and joined all the other people that just killfile everything posted via google.groups. AFAICT, if you're a google groups user your posts are not being seen by many/most experienced (read "non-google-group") users. This is mainly the fault of google who has refused to do anything to stem the flood of span that's being sent via Google Groups. -- Grant Edwards grante Yow! I would like to at urinate in an OVULAR, visi.com porcelain pool -- From gagsl-py2 at yahoo.com.ar Sun Apr 20 04:11:45 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 05:11:45 -0300 Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> <87prspydex.fsf@physik.rwth-aachen.de> Message-ID: En Wed, 16 Apr 2008 14:23:57 -0300, Steve Holden escribi?: > Torsten Bronger wrote: >> The admistrative overhead of mailing lists is tedious. Fortunately, >> most important computer-related lists are on gmane.org. We could >> list c.l.py there, too. ;-) >> > c.l.py has been on gmane for years, as comp.python.general (why they > have to have their own naming hierarchy i have never understood). Because "someone" chose that name when he/she asked for the list to be added; the name gmane.comp.lang.python *could* have been used, but wasn't. (gmane uses its own hierarchy because not all mirrored lists exist as a newsgroup outside gmane, and there are potential name conflicts) -- Gabriel Genellina From john106henry at hotmail.com Thu Apr 3 20:04:53 2008 From: john106henry at hotmail.com (John Henry) Date: Thu, 3 Apr 2008 17:04:53 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> <58deb8b8-bae9-4d43-b973-3d90846726cb@b5g2000pri.googlegroups.com> <873a5fc2-0bd8-4f93-9c8c-56cda6e0090a@s37g2000prg.googlegroups.com> Message-ID: On Apr 3, 10:17 am, Stef Mientki wrote: > >> Well I doubt it's the visual environment that makes it more easy, > >> color, shape and position can give some extra information though. > >> I think apriori domain knowledge and flattness of information are of far > >> more importance. > >> The first issue is covered quit well by Robolab / Labview, > >> but the second issue certainly is not. > >> I'm right now working on a Labview like editor in Python, > >> which does obey the demand for flatness of information. > >> The first results can be seen here:http://oase.uci.kun.nl/~mientki/data_www/pylab_works/pw_animations_sc... > > >> cheers, > >> Stef Mientki > > >>> And you are going to teach them Java? Oh, please don't. Let the > >>> colleges torture them. :=) > > > What do you mean by flatness of information? > > What I mean is something like; all the information at a certain > abstraction level is visible on one screen or one piece of paper, > and not is available through multiple screen / multiple right-clicks > etc. A wizard in general is an example of strong non-flatness of > information (try adding a mail-account in Thunderbird, this could > easily be put on 1 page, which clearly would give a much better overview). > > cheers, > Stef In that sense, it would appear to me Robolab/Labview would do exactly that. Most of the programs I taught the kids to do fits on one screen. I think what you are doing is very interesting because Robolab does a fair amount of what I am seeing from your screen shots (for simple applications anyway). One day when you finish with the program, may be I can try it on my younger kid. From steve at holdenweb.com Tue Apr 8 16:38:06 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 16:38:06 -0400 Subject: new user needs help! In-Reply-To: <16571823.post@talk.nabble.com> References: <16571823.post@talk.nabble.com> Message-ID: drjekil wrote: > I am totally new in biopython and its my first program.so may be i am asking > stupid question. New? Most questions are sensible. Let's suppose that the four lines you give below are stored in a text file called "/tmp/data.txt". > I am working with a text filelooks like this: > #NAME AA TOPO ACCESS DSSP STRIDE Z-COORD > 1lghB A i 79.8 H H -24.58 > 1lghB V i 79.6 H H -22.06 > 1lghB H i 71.9 H H -19.94 f = open("/tmp/data.txt", 'w') will open that file. You can throw the first line away with headings = f.next() Then you can loop over the rest with for name, aa, topo, access, dssp, stride, z in file: # # Then process each line here # if 10.0 <= z <= 22.0: # # select on other criteria here # > i need to compare those lines which has a Z-COORED value between 10 to 22 > and presents in the following way > True/false A C D E F G H I K L M N P Q R S T V X Y W(here alfabets > represents amino acids) > 1 1:1 2:0 3:0 and so on for rest of the amino acids. > IF PRESENT IN THAT RANGE > IF not PRESENT IN THAT RANGE then > -1 1:0 2:0 so on,it should be 1 instead of 0 when it will find corresponding > amino acid for that line.say here,for 2nd line it will be 16:1. > true will represent 1,false -1. I am afraid I am having trouble understanding that last bit. Perhaps you could find some other way to say the same thing? Sometimes my understanding is not too good. > i have to cheek all the lins in the file and print it. > u have to tell simply otherwise i cant understand even,so stupid am i! "Poor at English" != "Stupid" > I will be really greatful!Thanks in advance That's the first step. Now, what's next? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From john00587 at gmail.com Mon Apr 21 01:38:22 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:38:22 -0700 (PDT) Subject: kids that fall between the cracks Message-ID: <8b85c8b2-b979-4e36-a27b-8c6ef884dfb0@w4g2000prd.googlegroups.com> kids that fall between the cracks http://cracks.00bp.com F R E E C R A C K S From deets at nospam.web.de Thu Apr 17 11:05:53 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 17 Apr 2008 17:05:53 +0200 Subject: why function got dictionary References: <48075950.7050000@gmail.com> <66p409F2lg89hU1@mid.uni-berlin.de> <4807637C.1050900@gmail.com> Message-ID: <66p7bdF2l44iiU1@mid.uni-berlin.de> AlFire wrote: > Diez B. Roggisch wrote: >>> >>> Q: why function got dictionary? What it is used for? >> >> because it is an object, and you can do e.g. >> > > you mean an object in the following sense? > > >>> isinstance(g,object) > True Yes. > > where could I read more about that? I don't know. But essentially _everything_ in python is an object. Some of them lack a __dict__ - e.g. int and float and such - for optimization reasons. But apart from that, you can treat everything as an object. Diez From mr.cerutti at gmail.com Wed Apr 16 11:26:14 2008 From: mr.cerutti at gmail.com (Neil Cerutti) Date: Wed, 16 Apr 2008 11:26:14 -0400 Subject: text adventure game problem In-Reply-To: <3f1023c9-97c1-40b5-8a28-0b89bf79fba1@c65g2000hsa.googlegroups.com> References: <3f1023c9-97c1-40b5-8a28-0b89bf79fba1@c65g2000hsa.googlegroups.com> Message-ID: <51302a8c0804160826x67749324h1428d34397dd4fd4@mail.gmail.com> On Tue, Apr 15, 2008 at 9:25 AM, Carl Banks wrote: > On Apr 11, 12:08 pm, "Neil Cerutti" wrote: > > > such as so > > > they're not stuck with a quasi hack of a language if they have to do > > > something that doesn't fit the framework anticipated by the language > > > designer. > > > > That's not a reason, it's FUD. > > No, it's prudence. > > If I am writing a banal, been-done-a-million-times before, cookie- > cutter text adventure, yes I'd just use a domain-specific language. > > If I am writing a unique game that does new things, sooner or later > I'm going to want to do something the designer of the domain-specific > language and framework didn't anticipate. And there is no uncertainty > or doubt about this: when it comes to that, I don't want to be > restrained by a narrow framework or domain-specific language, and I > would want to be using Python, and it isn't even remotely close. > > The only question would be whether there's enough general purpose > programming required that it would outweigh the extra work. Which, > let's be honest, is not all that much for a text adventure. Thanks for the more detailed response. Your reasoning is valid, but your understanding of the properties of existing text game frameworks seem to be be out of date. A usable, extensible, customizable text adventure library for use in [b]any[/b] general-purpose programming language is still a pipe dream. There aren't even very many [b]failed[/b] attempts. The decent text adventures composed from scratch in a general-purpose programming language are rare exceptions to the rule. Even among the tolerable ones, I have personally never seen one that took advantage of the general-purpose nature of its implementation language to do something that couldn't have been easily done in the handful of mature domain-specific languages. Moreover, the small, but dedicated text-adventure-playing internet community has developed expectations for the features, infrastructure and portability of their text adventures that are not trivial to meet when starting from (close to) ground zero. A few bold pioneers have managed it. If you're keen to attempt it, Python is an OK choice. The most recent success I know of was "Aunts & Butlers" [1], composed in Javascript, which made portability less of an issue than it would be for Python. There are no completed text adventures in the wild composed in Python, that I'm aware of. That doesn't mean it can't happen. [1] http://versificator.co.uk/auntsandbutlers/ -- Neil Cerutti From gagsl-py2 at yahoo.com.ar Sat Apr 12 22:51:36 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 12 Apr 2008 23:51:36 -0300 Subject: String Literal to Blob References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> Message-ID: En Sat, 12 Apr 2008 22:14:31 -0300, Jason Scheirer escribi?: > On Apr 12, 2:44 pm, Steve Holden wrote: >> Victor Subervi wrote: >> > Well, as I mentioned before, I am sending text/html because the page, >> > like almost all web pages, has a whole lot more content than just >> > images. Or, perhaps you are suggesting I build my pages in frames, and >> > have a frame for every image. Unsightly! >> >> Dear Victor: >> >> If you cannot understand, after being told several times by different >> people, that pages with images in them are achieved by multiple HTTP >> requests, then there is little I can do to help you. >> [...] >> Please, do yourself a big favor and persist with this until you >> understand what you are doing wrong and how to serve dynamic images. It >> appears that the learning may be painful, but I guarantee it will be >> worthwhile. > > There _is_ a way to embed image data in HTML that is supported by > every major browser. It is ugly. Using the RFC 2397 (http:// > www.ietf.org/rfc/rfc2397) spec for data URLs you could go > > '' % base64.b64encode(image_data) Another alternative would be to generate a multipart/related document, but I think the OP will gain a lot more understanding the simple cases than using those esoteric features. -- Gabriel Genellina From lists at cheimes.de Sat Apr 12 12:47:32 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 12 Apr 2008 18:47:32 +0200 Subject: Tremendous slowdown due to garbage collection In-Reply-To: <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: <4800E7A4.5050708@cheimes.de> andreas.eisele at gmail.com schrieb: > which made me suggest to use these as defaults, but then > Martin v. L?wis wrote that > >> No, the defaults are correct for typical applications. > > At that point I felt lost and as the general wish in that thread was > to move > discussion to comp.lang.python, I brought it up here, in a modified > and simplified form. Martin said that the default settings for the cyclic gc works for most people. Your test case has found a pathologic corner case which is *not* typical for common application but typical for an artificial benchmark. Python is optimized for regular apps, not for benchmark (like some video drivers). By the way you shouldn't use range for large ranges of more than a thousand items. xrange() should be faster and it will definitely use much less memory - and memory Python 2.5 and older will never release again. I'm going to fix the issue for Python 2.6 and 3.0. Christian From kamhung.soh at gmail.com Wed Apr 30 03:12:15 2008 From: kamhung.soh at gmail.com (Kam-Hung Soh) Date: Wed, 30 Apr 2008 17:12:15 +1000 Subject: sed to python: replace Q References: <48180348$0$34534$742ec2ed@news.sonic.net> Message-ID: On Wed, 30 Apr 2008 15:27:36 +1000, Raymond wrote: > For some reason I'm unable to grok Python's string.replace() function. > Just trying to parse a simple IP address, wrapped in square brackets, > from Postfix logs. In sed this is straightforward given: > > line = "date process text [ip] more text" > > sed -e 's/^.*\[//' -e 's/].*$//' > > yet the following Python code does nothing: > > line = line.replace('^.*\[', '', 1) > line = line.replace('].*$', '') str.replace() doesn't support regular expressions. Try: import re p = re.compile("^.*\[") q = re.compile("].*$") q.sub('',p.sub('', line)) > > Is there a decent description of string.replace() somewhere? > > Raymond Section 3.6.1 String Functions -- Kam-Hung Soh Software Salariman From saluk64007 at gmail.com Fri Apr 18 20:22:28 2008 From: saluk64007 at gmail.com (Patrick Mullen) Date: Fri, 18 Apr 2008 17:22:28 -0700 Subject: python setup.py install on Vista? In-Reply-To: References: Message-ID: On Fri, Apr 18, 2008 at 4:29 PM, globalrev wrote: > type "python setup.py install" > > that is used in most "addons" for python. > > well using windows vista, where the h*** am i supposed to type this? > > if it is not doable in windows, what do i have to do instead? just > clicking the setup.py-file never works. > -- > http://mail.python.org/mailman/listinfo/python-list > There are many problems with this on Vista. First, you need a command prompt. You can go to "start menu->all programs->accessories->command prompt" for this. But to install things in vista, you will likely need to be an administrator, and windows won't automatically ask for permission when typing "python setup.py install." So instead of clicking on command prompt, right click it, and choose "run as administrator". A faster way is to type "cmd" in the start menu search area, and wait for "cmd.exe" to come up. Run that as administrator. Once you have a command prompt, you can "cd" into the directory where you want to install the extension. Then, "c:\python25\python setup.py install" should work. If you are using 2.4 or 3.0, it would be "c:\python24\python" or "c:\python30\python" etc. If you installed python somewhere other than the default folder, then you will need to enter that path. To make this process easier, when I want to install an extension, I usually create a .bat file in the extension folder. Right click in the folder and choose new->text file. Rename the file to "install.bat". Right click the file and go to edit. Enter "c:\python25\python setup.py install" into the file and save. Then right click and choose run as administrator, and it should install. You might add a "pause" line in the bat file as well, so that if it has a problem installing, it will stay open so you can see the output. Your best solution is to uninstall vista and use linux :) From tjreedy at udel.edu Tue Apr 1 01:20:19 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 1 Apr 2008 01:20:19 -0400 Subject: Stuck in a loop References: Message-ID: wrote in message news:e131eb4b-7e78-41b2-8bfd-d7619d620f85 at c26g2000prf.googlegroups.com... |I wrote a simple algorithm and it keeps getting stuck in a loop. I | guess I'm just to tired to figure it out: The easiest way to figure out somethinglike this is to print your variables from inside the loop to see things stick, or if there is a cycle. | compcount=[5,4,2,2] | suitrank=[0,0,0,0] | | trump=2 | l,lt=0,0 | while l<4: | while lt<4: print l, lt | if l==trump: | l+=1 | if l>3: | break | if lt==trump: | lt+=1 | if compcount[l] <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> Message-ID: Gabriel Genellina wrote: > Because Python doesn't follow the "boxed variables" model. Be careful here. `Boxed types' or `boxed objects' is a technical term essentially meaning `heap-allocated objects, probably with reference semantics', which Python most definitely does use -- so this almost means the opposite of what you're talking about. Python has the same basic data model as Lisp, Ruby, Smalltalk and many other languages: a variable (or a `slot' in a compound data-object) contains a reference to value; values can referred to by many variables. Assignment simply copies these references around. This means that it's easy to end up sharing the same object between lots of variables (or structures). Contrast this to the model used by C, Pascal and other `traditional' compiled languages, where a variable is actually a container for a value, and assignment is a copying operation rather than a sharing operation. > In other languages i++ changes the "value" stored inside the box "i", > but the box itself (the variable) is still the same. Python doesn't > have boxes, it has names that refer to objects. For all builtin > numeric types, i += 1 creates a *new* object with the resulting value > and makes the name "i" refer to this new object. Note that `+=' in Python is inconsistent! For numeric types (and other immutable types, such as strings or tuples), `VAR += VALUE' means the same thing as `VAR = VAR + VALUE' (ignoring tedious issues of multiple evaluation of subexpressions -- e.g., subscripts -- in VAR), which as mentioned above causes a new reference to be stored in VAR, referring to the object which was computed by adding VALUE to the object previously referred to by VAR. For lists, it does not do this: instead, it extends the list in place, putting new values on the end of it. (This is one of the language's few obvious inconsistencies, and probably a reasonably justifiable one; but it's still worth pointing out.) To be honest, I don't see any particular reason why `++' is any more of a mutation operation than `+=' is in the languages that define it; Python is actually one of the few to define one but not the other. (The other one I can think of is Acorn's BBC BASIC, for whatever that's worth; it too lacks `++'.) But then again, one of the main conceptual advantages of `++' as an operator is that it has both pre- and post- increment variants, which are useful when used as part of a wider expression. This won't hold in Python, since assignments (which `++' assuredly ought to be) aren't allowed as subexpressions anyway. So the value of `++' would be limited to providing an abbreviation over the already quite short `+= 1'. That's not quite true, in fact: it might be useful to define other kinds of incrementing for specialist types, but I can't think of any obvious examples off the top of my head. This argument doesn't apply to `+=' which has the benefit of saving you from having to type the VAR twice (which is nontrivial if VAR contains complex subexpressions) and -- more significantly -- saves a reader from having to check whether VAR and VAR' actually match in `VAR = VAR' + VALUE' and ensures only single evaluation of subexpressions of VAR. None of this applies to `++'. So `++' is not a feature I find myself sorely missing in Python. -- [mdw] From mark_lim at symantec.com Thu Apr 17 19:27:12 2008 From: mark_lim at symantec.com (Mark Lim) Date: Thu, 17 Apr 2008 16:27:12 -0700 Subject: Building an RPM In-Reply-To: <2F12200B-934E-44D2-94E8-D3E4BDE8FB56@gmail.com> Message-ID: You could use the module compileall to create .pyc and .pyo (http://www.python.org/doc/1.5.1p1/tut/node43.html) and do this in your %build stage. Or if you don't need to ship them, strike them from the package as they will be generated as necessary. On 4/17/08 2:19 PM, "John Sutherland" wrote: > Hi everyone.. > > I'm attempting to build an RPM for Python 2.5.2, using the spec file > found in the standard tarball (Misc/RPM).. > > Currently, its failing cause it hasn't 'compiled' the tools .pyc > and .pyo's, saying the files aren't found. > > Anyone have any ideas? (running on CentOS 4.3) > > --John > > > From roy at panix.com Wed Apr 30 21:03:45 2008 From: roy at panix.com (Roy Smith) Date: Wed, 30 Apr 2008 21:03:45 -0400 Subject: We have string.isdigit(), why not string.isNumber()? References: <0d43feda-fab8-46ba-9af0-eaf497033acd@l17g2000pri.googlegroups.com> Message-ID: In article <0d43feda-fab8-46ba-9af0-eaf497033acd at l17g2000pri.googlegroups.com>, MooMaster wrote: > So it makes sense that something like 5.6 would return false. But what > if we want to make sure that our string is a valid number, ie decimals > included? Just call int(x) or float(x) inside a try block and see if if it raises an exception. From stefan_ml at behnel.de Mon Apr 21 03:24:17 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 21 Apr 2008 09:24:17 +0200 Subject: Elementtree find problem In-Reply-To: References: Message-ID: <480C4121.2000901@behnel.de> Mike Slinn wrote: > The following short Python program parses a KML file and displays the > names of all Marks and Routes: > > from elementtree.ElementTree import ElementTree > tree = ElementTree(file='test.kml') > kml = tree.getroot() > ns = 'http://earth.google.com/kml/2.1' > for folder in kml.findall("{%s}Folder/{%s}Folder/{%s}name" % (ns, ns, ns)): > print folder.text > > I want to modify the program to ignore Marks, and print out the > coordinates of each Route. Seems ElementTree v1.3 will make this task > much easier, but unfortunately the CheeseShop and the Gentoo Portage > repostitory only have v1.2.7 at this time. You can install the current developer version of ET 1.3 from here: http://svn.effbot.org/public/elementtree-1.3 Or use lxml, which comes with full-fledged XPath support. http://codespeak.net/lxml > The following code is as > close as I can get to what I want, but it doesn't run because I've > attempted to use v1.3 syntax, ended up writing complete crap instead, > and I can't understand the docs well enough for the v1.2.7 syntax. > Perhaps someone can understand what I mean and give me a clue as to how > to write this? > > from elementtree.ElementTree import ElementTree > > tree = ElementTree(file='test.kml') > kml = tree.getroot() > ns = 'http://earth.google.com/kml/2.1' > for folders in kml.findall("{%s}Folder/{%s}Folder" % (ns, ns)): > if folders["name"].text=='Routes': > print folder.findall("{%s}LineString/{%s}coordinates" % (ns, > ns)) What's "name" here? An attribute? Then this might work better: if folders.get("name") == 'Routes': or did you mean it to be a child node? if folders.findtext("name") == 'Routes': Stefan From v.harishankar at gmail.com Tue Apr 22 23:20:13 2008 From: v.harishankar at gmail.com (Harishankar) Date: Wed, 23 Apr 2008 08:50:13 +0530 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: References: Message-ID: <200804230850.13672.v.harishankar@gmail.com> On Wednesday 23 Apr 2008 08:27:01 Heikki Toivonen wrote: > At OSAF we used a slightly modified killableprocess module with a > wrapper to deal with complexities of various redirections in > cross-platform way. I actually blogged about this a week ago so rather > than rehash the issues I'll point you to the article which contains > links to all the pieces we used: > > http://www.heikkitoivonen.net/blog/2008/04/16/pythons-ossystem-considered-h >armful/ killableprocess.py looks like a good solution indeed. I actually came across your website in my searches. I just wanted to be absolutely sure that it worked because you had mentioned that it has some drawbacks. -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org From sturlamolden at yahoo.no Thu Apr 24 23:47:25 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 20:47:25 -0700 (PDT) Subject: ctypes: return a pointer to a struct References: <846077c3-beaf-4ccd-83be-1e2168c4f7fe@c65g2000hsa.googlegroups.com> <4dda2bd7-3348-496e-a594-35da0a34d4de@x35g2000hsb.googlegroups.com> Message-ID: On Apr 25, 5:39 am, "Jack" wrote: > AttributeError: 'LP_IP2LocationRecord' object has no attribute > 'country_short' As it says, LP_IP2LocationRecord has no attribute called 'country_short'. IP2LocationRecord does. Use the 'contents' attribute to dereference the pointer. That is: yourstruct.contents.country_short From lorestar at gmail.com Thu Apr 10 10:30:42 2008 From: lorestar at gmail.com (Lorenzo Stella) Date: Thu, 10 Apr 2008 07:30:42 -0700 (PDT) Subject: https and POST method Message-ID: <7956f925-1037-49ea-a360-b58d627ffb20@z24g2000prf.googlegroups.com> Hi all, I'm trying to write a simple script for sending sms via vyke... I have to make a https connection and pass some data with the POST method, like this perl script does: http://www.nutella.org/vyke.sms.txt I tried to make the same, but it simply doesn't work! Any request gives a 200 OK result... This is my code: datah = {"act": "menulogin", "username": login, "password": passwd, "menu_login_form": 1} datas = urllib.urlencode(datah) conn = httplib.HTTPSConnection("www.vyke.com") conn.connect() conn.request("POST", "/merchantsite/login.c?Distributor=MASKINA", datas) res = conn.getresponse() print "login", res.status, res.reason datah = {"act": "sendSMS", "from": numfrom, "to": numto, "message": msg, "sms_form": 1} datas = urllib.urlencode(datah) conn.request("POST", "/merchantsite/sms.c", datas) res = conn.getresponse() print "send", res.status, res.reason conn.request("GET", "/merchantsite/logout.c?Distributor=MASKINA") res = conn.getresponse() print "logout", res.status, res.reason conn.close() I don't know what to do! :-( From gagsl-py2 at yahoo.com.ar Wed Apr 16 01:35:54 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 02:35:54 -0300 Subject: Brand New! References: <7f1828bf-ebe7-4111-bc59-70d125facb0a@d26g2000prg.googlegroups.com> Message-ID: En Tue, 15 Apr 2008 20:37:40 -0300, agent E 10 escribi?: > On Apr 14, 8:37?pm, Benjamin wrote: >> On Apr 14, 9:00 pm, agent E 10 wrote:> ? ?Hi, >> I'm brand new to programming. Have any suggestions? I'm young. >> > Was it a good idea to start with python? I was planning on creating a >> > very simple program that asked yes/no questions for a school project. >> >> IMHO, Python is an excellent language to start with. Have you read the >> tutorial?http://docs.python.org/tut/tut.html > > No, I haven't. I have been reading off of this site > http://www.freenetpages.co.uk/hp/alan.gauld/ is this a good site to > learn off of? About how long will it take me to learn the basics of > the language? I'm unsure if teaching Javascript, VBScript and Python at the same time is a good thing, I'd think one would get a language soup and mix all the concepts, but if it works for you, go ahead. For other resources, see the beginners section in the Python wiki: http://wiki.python.org/moin/BeginnersGuide -- Gabriel Genellina From hdante at gmail.com Thu Apr 17 23:57:21 2008 From: hdante at gmail.com (hdante) Date: Thu, 17 Apr 2008 20:57:21 -0700 (PDT) Subject: Unicode chr(150) en dash References: <48063434$0$36327$742ec2ed@news.sonic.net> Message-ID: <7dae96d4-48c4-46c9-9aa9-33a263b84ca4@26g2000hsk.googlegroups.com> On Apr 17, 12:10 pm, marexpo... at googlemail.com wrote: > Thank you Martin and John, for you excellent explanations. > > I think I understand the unicode basic principles, what confuses me is the usage different applications make out of it. > > For example, I got that EN DASH out of a web page which states at the beggining. That's why I did go for that encoding. But if the browser can There's a trick here. Blame lax web standards and companies that don't like standards. There's no EN DASH in ISO-8859-1. The first 256 characters in Unicode are the same as ISO-8859-1, but EN DASH number is U+2013. The character code in question (which is present in the page), 150, doesn't exist in ISO-8859-1. See http://en.wikipedia.org/wiki/ISO/IEC_8859-1 (the entry for 150 is blank) The character 150 exists in Windows-1252, however, which is a non- standard clone of ISO-8859-1. http://en.wikipedia.org/wiki/Windows-1252 Who is wrong ? - The guy who wrote the web site - The browser that does the trick. - Everybody for using a non-standard encoding - Everybody for using an outdated 8-bit encoding. Don't use old 8-bit encodings. Use UTF-8. > > I might need to go for python's htmllib to avoid this, not sure. But if I don't, if I only want to just copy and paste some web pages text contents into a tkinter Text widget, what should I do to succesfully make every single character go all the way from the widget and out of tkinter into a python string variable? How did my browser knew it should render an EN DASH instead of a circumflexed lowercase u? > > This is the webpage in case you are interested, 4th line of first paragraph, there is the EN DASH:http://www.pagina12.com.ar/diario/elmundo/subnotas/102453-32303-2008-... > > Thanks a lot. > From michele.simionato at gmail.com Sat Apr 5 07:09:32 2008 From: michele.simionato at gmail.com (Michele Simionato) Date: Sat, 5 Apr 2008 04:09:32 -0700 (PDT) Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> Message-ID: <38377121-8dc4-40b8-8a8f-868a2530530c@d1g2000hsg.googlegroups.com> On Apr 5, 12:54 pm, Aldo Cortesi wrote: > Thus spake Matthieu Brucher (matthieu.bruc... at gmail.com): > > > How does it compare to the nose framework ? > > As far as the base unit testing functionality is concerned, I think > they try to address similar problems. Both have assert-based testing > with inspection and re-parsing of assert exceptions for better error > messages. Both try to provide better fixture management. Both make > programmatic test generation easier. Both have a command-line tool for > running and gathering tests. > > I like nose, but I'm biased, and of course I think Pry has some > advantages. One difference I'd point out is Pry's tree-based test > structure, which provides a number of conveniences and features (much > nicer test selection from the command line, for instance). Pry is also > less than half the size of nose, and should therefore be simpler to > extend and understand. You forgot to mention the important point that nose is compatible with unittest and many developer (including myself) would consider that a major selling point. Michele Simionato From kveretennicov at gmail.com Tue Apr 1 14:50:49 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Tue, 1 Apr 2008 21:50:49 +0300 Subject: Why prefer != over <> for Python 3.0? In-Reply-To: References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <659gb2F2f84eoU2@mid.individual.net> <87hceo73ap.fsf@physik.rwth-aachen.de> <65anbqF2fg18bU1@mid.individual.net> <87r6drjss4.fsf@physik.rwth-aachen.de> <65c0bfF2ffipiU1@mid.individual.net> <32822fe60804010015m22a4e9bei5002431afe14921a@mail.gmail.com> Message-ID: <4660fe300804011150v5155705cif40d4277df312b3d@mail.gmail.com> On Tue, Apr 1, 2008 at 12:04 PM, Gabriel Genellina wrote: > En Tue, 01 Apr 2008 04:15:57 -0300, Jorge Vargas > escribi?: > > > as for the original question, the point of going unicode is not to > > make code unicode, but to make code's output unicode. thin of print > > calls and templates and comments the world's complexity in languages. > > sadly most english speaking people think unicode is irrelevant because > > ASCII has everything, but their narrow world is what's wrong. > > Python 3 is a good step in that direction. Strings are unicode, > identifiers are not restricted to ASCII, and the default source encoding > is not ASCII anymore (but I don't remember which one). UTF-8 (http://python.org/dev/peps/pep-3120/) -- kv -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at stinemates.org Fri Apr 18 15:16:36 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 12:16:36 -0700 Subject: insert python script in current script In-Reply-To: References: Message-ID: <20080418191636.GK19281@deviL> On Wed, Apr 16, 2008 at 01:41:13PM -0500, Larry Bates wrote: > Prashant wrote: > > I was wondering is there any way to do this: > > > > I have written a class in python and __init__ goes like this: > > > > def __init__(self): > > > > self.name = 'jack' > > self.age = 50 > > > > import data > > > > > > > > > > now here there is data.py in the same directory and contents are like: > > > > self.address = 'your address' > > self.status = 'single' > > > > The problem is 'self' is giving some error here. I need to know if > > somehow I can do this. It's like inserting the script as it's part of > > the file itself. > > > > Cheers > > > > Can you give a use case for doing this. You would most likely be better doing: > > class person(object): > def __init__(self, name=None, age=None): > self.name=name > self.age=age > > > personInstance=person(name='jack', age='50) > > -Larry > -- > http://mail.python.org/mailman/listinfo/python-list Could it also be that he would like to have a base class? Cause that's what It sounds like to me! class Base: def __init__(self): self.address = "address" self.status = 1 //use numbers instead of strings :) class Person(Base): def __init__(self): Base.__init__(self) # now you have the self.address, self.status -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From kyosohma at gmail.com Wed Apr 16 12:13:33 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 16 Apr 2008 09:13:33 -0700 (PDT) Subject: Splitting MainWindow Class over several modules. References: Message-ID: <0e6b1338-8355-4fba-9db2-0cc09fc05e1e@m44g2000hsc.googlegroups.com> On Apr 16, 10:47 am, Iain King wrote: > Until recently almost all my python programs were held 1 file for 1 > program. This had grown unwieldy for one of my projects, so i decided > to refactor it, and ended up with something like this: > > --- > > import wx > > import options > import gui > import scf > > class MainWindow(wx.Frame): > def __init__(self): > self.title = "SFtools v%s" % VERSION > wx.Frame.__init__(self, None, wx.ID_ANY, self.title, size=(800,600)) > self.SetMinSize((800,600)) > > readOptions = options.readOptions > writeOptions = options.writeOptions > > createBindings = gui.createBindings > createControls = gui.createControls > createMenus = gui.createMenus > reportError = gui.reportError > > loadSCF = scf.loadSCF > onOpen = scf.onOpen > reloadSCF = scf.reloadSCF > setMenuMode = scf.setMenuMode > unloadSCF = scf.unloadSCF > > --- > > Now, this works fine. I like how it reads and that everything being > imported can be clearly seen. I have this funny feeling though, that > this isn't the standard way of doing this. What is? And is there > anything about doing it this way which could be detrimental? > > Iain I don't think there's anything wrong with it. The main thing to remember is to try to keep the interface and the logic separate. I have a fairly complex program with lots of tabs and sub tabs. So I stuck each of the tab's display code in a separate file and imported them into my main program. One good place to learn from would be the wxPython demo. See how Dunn et al did it with that. Or check out Editra's source. I know there's a few wxPython-istas that love XRC for the GUI layout stuff, so that's an option too. I don't use it myself as I couldn't figure out how to implement some of the widgets with it. Mike From tim.arnold at sas.com Thu Apr 24 11:34:11 2008 From: tim.arnold at sas.com (Tim Arnold) Date: Thu, 24 Apr 2008 11:34:11 -0400 Subject: convert xhtml back to html Message-ID: hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop to create CHM files. That application really hates xhtml, so I need to convert self-ending tags (e.g.
) to plain html (e.g.
). Seems simple enough, but I'm having some trouble with it. regexps trip up because I also have to take into account 'img', 'meta', 'link' tags, not just the simple 'br' and 'hr' tags. Well, maybe there's a simple way to do that with regexps, but my simpleminded )]+/> doesn't work. I'm not enough of a regexp pro to figure out that lookahead stuff. I'm not sure where to start now; I looked at BeautifulSoup and BeautifulStoneSoup, but I can't see how to modify the actual tag. thanks, --Tim Arnold From torriem at gmail.com Sun Apr 20 19:08:11 2008 From: torriem at gmail.com (Michael Torrie) Date: Sun, 20 Apr 2008 17:08:11 -0600 Subject: close GUI and quit script? In-Reply-To: <480BC909.6020205@gmail.com> References: <480BC909.6020205@gmail.com> Message-ID: <480BCCDB.2060503@gmail.com> Michael Torrie wrote: > globalrev wrote: >> how do i close a GUI and end the mainloop of the script? > >From a GUI callback, instruct the main loop to quit. In case you can't tell from my reply, I'm basically saying that none of us have any idea unless you actually tell us what GUI system you are using. All the GUI's I have worked with talk about this in their basic API docs and tutorials. So I suggest you look at your GUI toolkit's documentation first. From deets at nospam.web.de Tue Apr 8 08:04:41 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 08 Apr 2008 14:04:41 +0200 Subject: Reproducing a web page and add own content to it. References: Message-ID: <6615blF2ifaqcU1@mid.uni-berlin.de> LaundroMat wrote: > Hi - > > I'm working on a Django powered site where one of the required > functionalities is the possibility of displaying the content of > external pages, with an extra banner at the top where specific > information is displayed. In other words, I'm looking for a way to > reproduce an existing web page and add some HTML code to it. (I can't > think of an example right now, but the idea is similar to sites that > let you see an external page and have some site-specific text above it > (often stating that the content below is not part of the site the user > comes from)). > > To test this, I've been downloading an external page, adding some text > to it and re-opening it in a browser (with the help of built-in > modules such as urllib2 etc). This works of course, but the external > page's links such as , or > are evidently no longer correct. > > Apart from parsing the whole file and trying to inject the external > site's domain in links such as the above (with the added inconvenience > of having to store the external page locally), is there an easier way > of accomplishing what I want? Using a frame? Diez From aaron.watters at gmail.com Tue Apr 15 12:35:27 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Tue, 15 Apr 2008 09:35:27 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <0853b778-c20b-44bb-ac9b-a5803a1aecc5@e67g2000hsa.googlegroups.com> <53ede0ca-ad36-4b11-b693-ea500d7b6e43@e67g2000hsa.googlegroups.com> Message-ID: <207ca229-3309-41e4-9369-ccde5de908a1@l64g2000hse.googlegroups.com> On Apr 14, 11:18 pm, Carl Banks wrote: > However, that is for the OP to decide. The reason I don't like the > sort of question I posed is it's presumptuous--maybe the OP already > considered and rejected this, and has taken steps to ensure the in > memory data structure won't be swapped--but a database solution should > at least be considered here. Yes, you are right, especially if the index structure will be needed many times over a long period of time. Even here though, these days, you can go pretty far by loading everything into core (streaming from disk) and dumping everything out when you are done, if needed (ahem, using the preferred way to do this from python for speed and safety: marshal ;) ). Even with Btree's if you jump around in the tree the performance can be awful. This is why Nucular, for example, is designed to stream results sequentially from disk whenever possible. The one place where it doesn't do this very well (proximity searches) shows the most problems with performance (under bad circumstances like searching for two common words in proximity). -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=joys From pavlovevidence at gmail.com Sat Apr 12 10:20:13 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Sat, 12 Apr 2008 07:20:13 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> Message-ID: On Apr 12, 7:02 am, andreas.eis... at gmail.com wrote: > I would suggest to configure the default behaviour of the garbage > collector in such a way that this squared complexity is avoided > without requiring specific knowledge and intervention by the user. Not > being an expert in these details I would like to ask the gurus how > this could be done. Well, the garbage collector activates whenever allocations exceed deallocations by a certain amount, which for obvious reasons is the reason for the bottleneck wh My first stab at a suggestion would be to adjust the threshold depending on how successful it is. So if a garbage collection run collects no objects, double (or whatever) the threshold until the next run. More formulaicly, if your threshold is X, and a garbage collection pass collects Y objects, the the threshold for the next pass would be something like 2*X/(Y/X+1). Then you can create your very large data structure in only O(N log N) time. But as Steve Holden said, it'll probably mess someone else up. There's not much you can do with a garbage collector to make it please everyone. A question often asked--and I am not a big a fan of these sorts of questions, but it is worth thinking about--of people who are creating very large data structures in Python is "Why are you doing that?" That is, you should consider whether some kind of database solution would be better. You mention lots of dicts--it sounds like some balanced B-trees with disk loading on demand could be a good choice. Carl Banks From landerdebraznpc at gmail.com Mon Apr 28 03:53:35 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:53:35 -0700 (PDT) Subject: norton internet security 2007 keygen Message-ID: norton internet security 2007 keygen http://crack.cracksofts.com From adi at lspl.net Tue Apr 8 22:34:18 2008 From: adi at lspl.net (sniffer) Date: Tue, 8 Apr 2008 19:34:18 -0700 (PDT) Subject: python-com and vista Message-ID: hi all, the problem i am facing is as follows:- i have created a com component in python this registers and works fine on winxp and stuff but on vista i need to turn off user account control to get the component registered and every time i need to use the component i again have to turn it UAC off if it is on, but this component needs to be deployed on the end-users machine and so this exercise of turning on/off UAC cannot be carried out there . Any pointers on how to get this resolved ? TIA From mav at cuma.polymath-solutions.lan Wed Apr 2 12:01:59 2008 From: mav at cuma.polymath-solutions.lan (Maurizio Vitale) Date: Wed, 02 Apr 2008 16:01:59 GMT Subject: non-terminating regex match Message-ID: Has to be something really stupid, but the following never finish (running Python 2.5.1 (r251:54863, Jan 10 2008, 18:00:49) [GCC 4.2.1 (SUSE Linux)] on linux2). The intention is to match C++ identifiers, with or without namespace qualification, with or without arguments (e.g. variables, functions and macros). The following should be accepted: main main(int,char**) ::main std::cout ::std::cout NDEBUG Thanks for any help. And yes, I'm a total beginner when it comes to Python, but it seems very strange to me that a regex match on a finite length string doesn't terminate Regards, Maurizio #!/usr/bin/env python # -*- Python -*- import re if __name__ == '__main__': r = re.compile ( r'(?:(?P(?:(?:::)?\w+)*)::)?' r'(?P\w+)' r'(?:\((?P[^\)]*)\))?' ) match = r.search ('WITH_ALOHA_EXCEPTION_HANDLERS') From collardfelszkw at gmail.com Sun Apr 20 16:33:13 2008 From: collardfelszkw at gmail.com (collardfelszkw at gmail.com) Date: Sun, 20 Apr 2008 13:33:13 -0700 (PDT) Subject: jennifer aniston and paul Message-ID: <1208fb64-8976-433e-be8e-03b31076e3ad@i36g2000prf.googlegroups.com> Just few link on some Movies Movies: http://Jennifer-Aniston.12w.net F R E E C E L E B R I T Y M O V I E S From steve at holdenweb.com Sat Apr 12 18:00:46 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 18:00:46 -0400 Subject: sqlite3 - adding tables and rows via parameters In-Reply-To: <9fdb569a0804121115v43d86c49ieb0f712bd5a49679@mail.gmail.com> References: <9fdb569a0804120839w6916ed96ka5b53aad7ca6f565@mail.gmail.com> <9fdb569a0804121115v43d86c49ieb0f712bd5a49679@mail.gmail.com> Message-ID: Vlastimil Brom wrote: > > 2008/4/12, Steve Holden >: > > Vlastimil Brom wrote: > > Hi all, > > I would like to ask about the usage of sqlite3 in python, more > > specifically about a way to pass table > > or column names to a SQL commands using parameters. > > > The thing that will stop you from using a tablename as an argument to a > parameterized query is that (the) front-ends (I am familiar with) don't > allow table names to be parameterized ... > > ... > > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > ======================= > > Thank you very much for the explanation Steve! > I noticed the limitation, but wasn't sure, if if I wasn't missing > anything, as I don't have many experiences with databases (now I am > actually trying to reimplement, what was previously managed to with > nested dictionaries - hence I don't think, something more robust than > sqlite is appropriate). > But now I am not sure; are there any (security > ...) risks of using string interpolation for table and column names in the SQL commands? Or > are the values, where parametrization (with ? in sqlite3) is supported, > the only vulnerable part; whereas eg. an incorrect value of what should > be a name is safe (of course, apart from the unsuccessful command itself)? > Ultimately that depends where the table and column names come from. If they are user inputs then you are still vulnerable to SQL injection, but usually that's not the case when a query is being parameterized - usually it's values. As long as you consider the source of your data carefully you'll probably be OK. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From elgeee at yahoo.com Thu Apr 17 14:04:03 2008 From: elgeee at yahoo.com (lg) Date: Thu, 17 Apr 2008 18:04:03 GMT Subject: noobie question about mailman Message-ID: <2008041714045350073-elgeee@yahoocom> Hello, I'm pretty new to usenet and totally new to python, so.. hopefully i won't offend anyone with my naivete. I work at a non-profit organization where we use mailman for our email lists, and i've inhereted the task of being list administrator from my sadly-recently-and-unjustly-terminated coworker. Anyway, I'd to know more about working with mailman from the command line. For example, I know it must not be toooo complex to have mailman export a csv doc of all the members of a lis (instead of having to look through members using the web interface for administrators). Can anyone point me in the direction of a forum, email list, or good tutorial to get me started? Any insight *mucly* appreciated! Best, Lauren From ptmcg at austin.rr.com Tue Apr 29 10:20:44 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Tue, 29 Apr 2008 07:20:44 -0700 (PDT) Subject: Issue with regular expressions References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Message-ID: <5a75ea66-2cbb-4c41-8351-a35a70554d8d@i76g2000hsf.googlegroups.com> On Apr 29, 8:46?am, Julien wrote: > I'd like to select terms in a string, so I can then do a search in my > database. > > query = ' ? " ?some words" ?with and "without ? ?quotes ? " ?' > p = re.compile(magic_regular_expression) ? $ <--- the magic happens > m = p.match(query) > > I'd like m.groups() to return: > ('some words', 'with', 'and', 'without quotes') > > Is that achievable with a single regular expression, and if so, what > would it be? > Julien - I dabbled with re's for a few minutes trying to get your solution, then punted and used pyparsing instead. Pyparsing will run slower than re, but many people find it much easier to work with readable class names and instances rather than re's typoglyphics: from pyparsing import OneOrMore, Word, printables, dblQuotedString, removeQuotes # when a quoted string is found, remove the quotes, # then strip whitespace from the contents dblQuotedString.setParseAction(removeQuotes, lambda s:s[0].strip()) # define terms to be found in query string term = dblQuotedString | Word(printables) query_terms = OneOrMore(term) # parse query string to extract terms query = ' " some words" with and "without quotes " ' print tuple(query_terms.parseString(query)) Gives: ('some words', 'with', 'and', 'without quotes') The pyparsing wiki is at http://pyparsing.wikispaces.com. You'll find an examples page that includes a search query parser, and pointers to a number of online documentation and presentation sources. -- Paul From paul.hankin at gmail.com Thu Apr 17 14:19:48 2008 From: paul.hankin at gmail.com (Paul Hankin) Date: Thu, 17 Apr 2008 11:19:48 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <42402158-0b16-42e2-b7a0-9d9a15e8196d@24g2000hsh.googlegroups.com> Message-ID: <316ab669-fa8e-42b3-a1db-68d5b9d7e016@8g2000hsu.googlegroups.com> On Apr 17, 5:56?pm, s0s... at gmail.com wrote: > class RequestHeadersManager: > ... > ? ? def __init__(self, headers, linesep): > ? ? ? ? headersDict = parse_headers(headers, linesep) > > ? ? ? ? for header in headersDict.keys(): > ...[lots of code] Your code is pretty much equivalent to this (untested). class RequestHeadersManager(object): def __getattr__(self, field): if not hasattr(self, field): return None def __init__(self, headers, linesep): for header, value in parse_headers(headers, linesep).iteritems(): header = '_'.join(x.capitalize() for x in header.split('-')) setattr(self, header, value) You may want to add some error checking though! -- Paul Hankin From george.sakkis at gmail.com Tue Apr 1 23:17:30 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 1 Apr 2008 20:17:30 -0700 (PDT) Subject: generator functions: why won't this work? References: Message-ID: On Apr 1, 10:56 pm, zillo... at googlemail.com wrote: > Hi all, > > I'm trying to understand generator functions and the yield keyword. > I'd like to understand why the following code isn't supposed to work. > (What I would have expected it to do is, for a variable number of > arguments composed of numbers, tuples of numbers, tuples of tuples, > etc., the function would give me the next number "in sequence") > #################################### > def getNextScalar(*args): > for arg in args: > if ( isinstance(arg, tuple)): > getNextScalar(arg) > else: > yield arg > #################################### > > # here's an example that uses this function: > # creating a generator object: > g = getNextScalar(1, 2, (3,4)) > g.next() # OK: returns 1 > g.next() # OK: returns 2 > g.next() # not OK: throws StopIteration error > > #################################### > > I'm sure I'm making some unwarranted assumption somewhere, but I > haven't been able to figure it out yet (just started learning Python a > couple of days ago). > > Any help will be appreciated :) You're pretty close, there's just one more thing left. The return value of a generator function is an iterable, something you're supposed to iterate over. In the 'if' clause you call recursively the generator on arg but you don't use the result, you discard it as soon as it is returned. What you have to do is iterate over the returned iterable and yield its values: # don't need parentheses around the if expression if isinstance(arg, tuple): for scalar in getNextScalar(arg): yield scalar Hope this helps, George From castironpi at gmail.com Sun Apr 27 01:58:49 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sat, 26 Apr 2008 22:58:49 -0700 (PDT) Subject: diffing and uniqing directories References: Message-ID: <342c6959-8825-43a5-bee5-0488a2283b80@59g2000hsb.googlegroups.com> On Apr 26, 10:35?pm, rustom wrote: > On Apr 27, 12:31?am, castiro... at gmail.com wrote: > > > > > > > On Apr 26, 1:14?pm, "Rustom Mody" wrote: > > > > Over years Ive collected tgz's of my directories. I would like to diff > > > and uniq them > > > > Now I guess it would be quite simple to write a script that does a > > > walk or find through a pair of directory trees, makes a SHA1 of each > > > file and then sorts out the files whose SHA1s are the same/different. > > > What is more difficult for me to do is to write a visual/gui tool to > > > help me do this. > > > > I would guess that someone in the python world must have already done > > > it [The alternative is to use some of the tools that come with version > > > control systems like git. But if I knew more about that option I would > > > not be stuck with tgzs in the first place ;-)] > > > > So if there is such software known please let me know. > > > > PS Also with the spam flood that has hit the python list I dont know > > > if this mail is being read at all or Ive fallen off the list! > > > I don't want to give you advice; there is profit in diversity, so > > telling you what I use could negatively unify the diverse group. > > > In another language I know, and I pause to defer to the old and wise > > on that, Visual Basic (known to make money), certain counterparts like > > Visual Basic for Applications allow construction of scripts in the > > owner's other suites. ?That is, you can write Basic snippets in Excel, > > Access, and so on. ?That's one benefit that private ownership leaves, > > but not everyone is sold on my country's currency/localcy. ?Perhaps > > it's in the future of version control systems. ?Of course, > > standardization of sufficiency to succeed comes from currency too: > > success isn't success if it isn't current, per se. > > > Do you have any interest in contributing your mind or hands to > > developing a solid gui framework? ?Join a team. > > If this is an answer to my question I dont understand it!- Hide quoted text - > > - Show quoted text - The VisualBasic proprietary editors come with draggable-UIs. Thence, the analysis of utility as a function of where I'm from. OA open architecture has followed Microsoft into Office, so the free one isn't coming. Go distributing, but remember what the serial one is while the dollar's on it. It's picky. From rgarcia2009 at gmail.com Fri Apr 18 11:33:21 2008 From: rgarcia2009 at gmail.com (rgarcia) Date: Fri, 18 Apr 2008 08:33:21 -0700 (PDT) Subject: installing MySQLdb module Message-ID: <80f805f0-6829-4da3-bfb4-79875bb16114@a22g2000hsc.googlegroups.com> I've installed the developer tools package, but when running "python setup.py build" I get the following error: python setup.py build running build running build_py copying MySQLdb/release.py -> build/lib.macosx-10.3-fat-2.5/MySQLdb running build_ext building '_mysql' extension gcc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing - Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic - DNDEBUG -g -O3 -Dversion_info=(1,2,2,'final',0) -D__version__=1.2.2 -I/ Applications/xampp/xamppfiles/include/mysql -I/Library/Frameworks/ Python.framework/Versions/2.5/include/python2.5 -c _mysql.c -o build/ temp.macosx-10.3-fat-2.5/_mysql.o -arch i386 -arch ppc _mysql.c:35:23:_mysql.c:35:23: error: my_config.h: No such file or directoryerror: my_config.h: No such file or directory ... I googled around and people say you need the "-dev" package of mysql in order to have the C headers...where can you download this for mac os? Thanks, Rafael PS I am running XAMPP (http://www.keitr.com/tutorials/xampp) if that changes anything From marlin_rowley at hotmail.com Fri Apr 18 16:10:22 2008 From: marlin_rowley at hotmail.com (Marlin Rowley) Date: Fri, 18 Apr 2008 15:10:22 -0500 Subject: Which event to use for out of focus window? In-Reply-To: References: Message-ID: Bump. From: marlin_rowley at hotmail.com To: python-list at python.org Subject: Which event to use for out of focus window? Date: Fri, 18 Apr 2008 10:25:40 -0500 I think I've found a bug in the wx Library. I've created an event : EVT_IDLE that does something when the event is triggered, however, if your mouse pointer is out-of-focus on the window, the EVT_IDLE doesn't get called. It's only when the window is put into focus that the IDLE event is called. I basically want the IDLE function to be called whether the window is in focus or not. Is there a way to do this? Thanks, -M Get in touch in an instant. Get Windows Live Messenger now. _________________________________________________________________ Pack up or back up?use SkyDrive to transfer files or keep extra copies. Learn how. http://www.windowslive.com/skydrive/overview.html?ocid=TXT_TAGLM_WL_Refresh_skydrive_packup_042008 -------------- next part -------------- An HTML attachment was scrubbed... URL: From goldspin at gmail.com Fri Apr 11 11:35:05 2008 From: goldspin at gmail.com (Henry Chang) Date: Fri, 11 Apr 2008 08:35:05 -0700 Subject: Graphs in Python In-Reply-To: <531651.98983.qm@web55601.mail.re4.yahoo.com> References: <531651.98983.qm@web55601.mail.re4.yahoo.com> Message-ID: Try Google Chart with python wrapper: http://pygooglechart.slowchop.com/ http://code.google.com/apis/chart/ On Thu, Apr 10, 2008 at 10:05 AM, Sanhita Mallick wrote: > Hi. > > I am a newbie to Python. I am trying to implement a > Python code for graph manipulation. My graphs are > about 200-500 nodes big. Excepting for the short basic > graph implementation info on Python.org, where can I > find more in depth info about how to express graphs in > python, and how to use them in a code? > > Also, does anyone know of a easy way of creating the > dictionary for python for a 500-node graph, without > typing each and every node? I found some application > that recognize dot file Graphviz - but I am looking > for a program that can let me "draw" a graph and then > generate the lists automatically from the drawing. > > Thanks. > -SM > -- > http://mail.python.org/mailman/listinfo/python-list > From sn at sncs.se Wed Apr 16 02:50:12 2008 From: sn at sncs.se (Sverker Nilsson) Date: Tue, 15 Apr 2008 23:50:12 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: Thanks for your well-formulated article Providing the Python infrastructure with my program doesn't apply since I am providing a program/library that is intended to be general. So it doesn't help. All that py3k does to me, it seems, is some extra work. To be frank, no innovation. Just changes, no progress. And yes, I am p****d. Somebody compared it with MS stuff. Yes. Nothing personal, I appreciate Your comment. And all others. Sverker On Apr 15, 7:09 pm, Donn Cave wrote: > In article > <11567a1a-b184-42e6-bbf3-a655736c1... at p25g2000hsf.googlegroups.com>, > Sverker Nilsson wrote: > > > No one forces me, but sooner or later they will want a Python 3.0 and > > then a 3.1 whatever. > > > I don't want that fuzz. As about the C versions, I am not that > > worried. What's your point? > > > I just like want to write a program that will stay working. And maybe > > I can go on with something else hopefully than just compatibility > > fixes. They take some work afterall. > > > It seems hard with Python. Esp. 2 -> 3 > > Welcome to the world of Python. > > There was a period of relative stability in the '90s, culminating > with version 1.5.2, which just happens to be about the time that > people started taking Python seriously. It turns out that this > stability was only due to lack of resources, though. > > I think most of us are working under two imperatives here that > really boil down to the same thing: we want a programming > language that lets us focus on the goal of the program. On > one hand, that means things like automatic memory management > that are brought to us by newer languages (i.e., less than > 30 years old.) On the other hand it means stability that allows > our deployed code to go on working without constant intervention, > which usually we find in languages that have become utterly boring > and out of fashion (i.e., more than 30 years old.) > > It's hard to find a good compromise between these two, in an > interpreted language. I don't know what the current party line > may be on this matter, but some years back it was that you should > consider the interpreter part of your application. That is, each > application should deploy with its own dedicated Python interpreter, > complete with libraries and everything. This naturally relieves > some of the maintenance issues, since at least you can upgrade on > your own schedule, but of course it has its costs too. Anyone who > might be thinking about using Python for an application should > seriously think about this. > > Donn Cave, d... at u.washington.edu From pydev at rscorp.ab.ca Tue Apr 29 16:30:08 2008 From: pydev at rscorp.ab.ca (Scott SA) Date: Tue, 29 Apr 2008 14:30:08 -0600 Subject: @classmethod question In-Reply-To: Message-ID: On 4/23/08, Ivan Illarionov (ivan.illarionov at gmail.com) wrote: >On 24 ???, 07:27, Scott SA wrote: >> I'm using the @classemethod decorator for some convenience methods and for > >It would make sense to separate instance-level and class-level >behaviour with additional 'objects' namespace. e.g. >cookie_recipie.get_ingredients() to get ingredients only for cookie >recipie and RecipieClass.objects.get_ingrendients([....]) to get all >the ingredients. As mentioned in another reply, my example was a poor representation of what I was tryin to ask. With that said, your reply is amazingly helpful in my quest to understand python, Django, etc. Django is the ORM I referred to, so the material you have written helps explain a few things. >The elegant solution (AFAIK used by Django) would be to use metaclass >and the object with custom descriptor for class-object/table level >stuff. > >Something like this: > >class RecipieMetaclass(type): > def __new__(cls, bases, attrs): > new_cls = type.__new__(cls, name, bases, attrs) > new_cls.objects = IngredientsDescriptor(IngredientsManager()) > return new_cls > >class RecipieClass(object): > __metaclass__ = RecipieMetaclass > def get_ingredients(self, recipie_list=None): > return self.do_something_interesting(recipie_list) > >class IngredientsManager(object): > def get_ingredients(self, recipie_list=None): > return do_something_boring(recipie_list) > >class IngredientsDescriptor(object): > def __init__(self, ingredients_manager): > self.ingredients_manager = ingredients_manager > def __get__(self, instance, type=None): > if instance is not None: > raise AttributeError, "Access via %s instances is not >allowed" % type.__name__ > return self.ingredients_manager > >Then, "at another time, wanting to know what all the ingredients would >be to make cookies, cake and bread" you would call: >RecipieClass.objects.get_ingrendients(['cookies','cake','bread']) I'm a little vague on the interaction of the IngredientsDescrptor VS IngredientsManager. I gather the 'Descriptor' class is called via the __get__ which then does the instance check. Could this have been done in the 'Manager' class? >Both Django and Google Apps Engine API use similar concepts and you >can learn much more interesting looking in their source code. I have been learning a lot from the Django code and other applications written within it. Still, some things just don't seem to gel, even after a host of google searches. I've not loked at the Google Apps stuff, but will follow your advice. Thanks, Scott From hank.infotec at gmail.com Sun Apr 20 15:09:05 2008 From: hank.infotec at gmail.com (Hank @ITGroup) Date: Mon, 21 Apr 2008 05:09:05 +1000 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <480B52DE.8070105@holdenweb.com> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B52DE.8070105@holdenweb.com> Message-ID: <480B94D1.6050907@gmail.com> Steve Holden wrote: > > You are suffering from a pathological condition yourself: the desire > to optimize performance in an area where you do not have any problems. > I would suggest you just enjoy using Python and then start to ask > these questions again when you have a real issue that's stopping you > from getting real work done. > > regards > Steve > Hi, Steve, This not simply a pathological condition. My people are keeping trying many ways to have job done, and the memory problem became the focus we are paying attention on at this moment. Could you please give us some clear clues to obviously call python to free memory. We want to control its gc operation handily as we were using J**A. From Shawn at Milochik.com Wed Apr 30 13:30:19 2008 From: Shawn at Milochik.com (Shawn Milochik) Date: Wed, 30 Apr 2008 13:30:19 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: <2dc0c81b0804301029n5db13d7ej8cb71938f1980f7e@mail.gmail.com> References: <966256b2-fe7c-4ec5-900b-90b285311881@k10g2000prm.googlegroups.com> <87abjne42n.fsf@physik.rwth-aachen.de> <2dc0c81b0804300851h63500c54q8570202c9cece332@mail.gmail.com> <87r6cncp4r.fsf@physik.rwth-aachen.de> <2dc0c81b0804301029n5db13d7ej8cb71938f1980f7e@mail.gmail.com> Message-ID: <2dc0c81b0804301030x7858b8b5y14729ba3632c61b9@mail.gmail.com> How does one "plonk" stuff from Google Groups? Specifically, how can this be done in Gmail? Thanks, Shawn -------------- next part -------------- An HTML attachment was scrubbed... URL: From ridenour4159 at gmail.com Thu Apr 24 06:13:10 2008 From: ridenour4159 at gmail.com (ridenour4159 at gmail.com) Date: Thu, 24 Apr 2008 03:13:10 -0700 (PDT) Subject: civilization iv crack Message-ID: <149a253c-b561-411b-b195-14c871c8ad95@34g2000hsh.googlegroups.com> civilization iv crack http://cracks.12w.net F R E E C R A C K S From j.foster.davis at gmail.com Tue Apr 15 15:28:00 2008 From: j.foster.davis at gmail.com (Jacob Davis) Date: Tue, 15 Apr 2008 12:28:00 -0700 Subject: Module not found in script that was found in command-line interpreter. Possible Path issue? In-Reply-To: <47F519D7.5090905@activestate.com> References: <8463F6F2-4C02-48BC-BF7E-B606D4B41577@gmail.com> <47F519D7.5090905@activestate.com> Message-ID: <00AC12DC-AD44-4E65-8C8D-FACC0D39299A@gmail.com> On Apr 3, 2008, at 10:54 AM, Trent Mick wrote: > Jacob Davis wrote: >> I just installed the MySQLdb module and I have been able to get it >> to run in my command line interpreter. I am running Mac Leopard, >> and Python 2.5. >> I have tested importing and actually connecting and using a MySQL >> database, although it issues some warning: >> SnakeBite:MySQL-python-1.2.2 Snake$ python >> Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) [GCC 4.0.1 (Apple >> Computer, Inc. build 5341)] on darwin >> Type "help", "copyright", "credits" or "license" for more >> information. >>>>> import MySQLdb >> /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ >> site-packages/MySQL_python-1.2.2-py2.5-macosx-10.3-fat.egg/ >> _mysql.py:3: UserWarning: Module _mysql was already imported from > > From that message it looks like this "python" is /usr/local/bin/ > python (i.e. a separate installation than Apple's system python at / > usr/bin/python and /System/Library/Frameworks/Python.framework). > > You can tell for sure by doing: > > $ which python > >> However, while writing a .py script (with Komodo Edit) I try to >> simply import the module and the in-Komodo interpreter returns an >> error: >> Traceback (most recent call last): >> File "/Users/Snake/Documents/NPS/Thesis/Source_Code/Genetics/ >> mysql_connect_test.py", line 11, in >> import MySQLdb >> ImportError: No module named MySQLdb > > I suspect that this is because your run of Komodo Edit doesn't have > "/usr/local/bin" on its PATH and is using "/usr/bin/python" instead > of the one you typically use on the command line. > > You can configure Komodo to know about /usr/local/bin by adding a > "PATH" setting in the "Environment" prefs panel. Arguably Komodo > should just add /usr/local/bin to its runtime PATH by default, but > unfortunately it currently doesn't. Komodo doesn't pick up your > normal bash shell environment because of problems trying to get that > information in general. > > Please let me know (or on the komodo-discuss list [^1] or Komodo bug > database [^2]) if you have any problems getting that going. > > Cheers, > Trent > > [1]: http://listserv.activestate.com/mailman/listinfo/Komodo-discuss > [2]: http://bugs.activestate.com/query.cgi?product=Komodo > > -- > Trent Mick > trentm at activestate.com Thanks, that seems to have worked. I added "/usr/local/bin" to the PATH in the preferences Environment panel in Komodo. Then in preferences I went into the Python pane and changed my selected interpreter from "/usr/bin/pythonw" to the now available "/usr/local/ bin/pythonw". Thanks again, Jake From ndbecker2 at gmail.com Sat Apr 26 06:53:45 2008 From: ndbecker2 at gmail.com (Neal Becker) Date: Sat, 26 Apr 2008 06:53:45 -0400 Subject: ioctl.py References: Message-ID: Gabriel Genellina wrote: > En Fri, 25 Apr 2008 09:30:56 -0300, Neal Becker > escribi?: > >> I need an ioctl call equivalent to this C code: >> >> my_struct s; >> s.p = p; << a pointer to an array of char >> s.image_size = image_size; >> return (ioctl(fd, xxx, &s)); >> >> I'm thinking to use python array for the array of char, but I don't see >> how >> to put it's address into the structure. > > Use the array's buffer_info() method: > """buffer_info(): Return a tuple (address, length) giving the current > memory address and the length in elements of the buffer used to hold > array's contents.""" > > and you can use the struct module to build my_struct. > >> Maybe ctypes is the answer? > > It could be used too, but I think that in this case it's harder to use > ctypes. > Here is what ioctl should be: from ctypes import * libc = CDLL ('/lib/libc.so.6') #print libc.ioctl libc.ioctl.argtypes = (c_int, c_int, POINTER (eos_dl_args_t)) _IOC_WRITE = 0x1 _IOC_NRBITS= 8 _IOC_TYPEBITS= 8 _IOC_SIZEBITS= 14 _IOC_DIRBITS= 2 _IOC_NRSHIFT= 0 _IOC_TYPESHIFT= (_IOC_NRSHIFT+_IOC_NRBITS) _IOC_SIZESHIFT= (_IOC_TYPESHIFT+_IOC_TYPEBITS) _IOC_DIRSHIFT= (_IOC_SIZESHIFT+_IOC_SIZEBITS) def _IOC (dir, type, nr, size): return (((dir) << _IOC_DIRSHIFT) | \ ((type) << _IOC_TYPESHIFT) | \ ((nr) << _IOC_NRSHIFT) | \ ((size) << _IOC_SIZESHIFT)) def ioctl (fd, request, args): return libc.ioctl (fd, request, args) From gagsl-py2 at yahoo.com.ar Wed Apr 16 18:29:14 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 19:29:14 -0300 Subject: Profiling, recursive func slower than imperative, normal? References: Message-ID: En Wed, 16 Apr 2008 17:53:16 -0300, escribi?: > On Apr 16, 3:27 pm, Jean-Paul Calderone wrote: > >> Any function can be implemented without recursion, although it isn't >> always easy or fun. >> > Really? I'm curious about that, I can't figure out how that would > work. Could give an example? Say, for example, the typical: walking > through the file system hierarchy (without using os.walk(), which uses > recursion anyway!). Use a queue of pending directories to visit: start with empty queue queue.put(starting dir) while queue is not empty: dir = queue.get() list names in dir for each name: if is subdirectory: queue.put(name) else: process file -- Gabriel Genellina From miki.tebeka at gmail.com Thu Apr 17 19:24:35 2008 From: miki.tebeka at gmail.com (Miki) Date: Thu, 17 Apr 2008 16:24:35 -0700 (PDT) Subject: i want to add a timeout to my code References: <53ffe104-be3b-43e2-b5c8-4ce5886ac60d@b1g2000hsg.googlegroups.com> Message-ID: <1f70ea43-7909-4bd8-b63d-2467e8a0542f@c65g2000hsa.googlegroups.com> On Apr 17, 1:10?pm, maehhheeyy wrote: > I want to add a timeout so that when I pull out my gps from my serial > port, it would wait for a bit then loop and then see if it's there. I > also want to add a print statement saying that there is no GPS device > found. However when I run my code and unplug my serial port, my code > will just hang until I plug it back in. > This is my code right now: > > def GetGPS(): > ? ? ? data = [] > ? ? ? #Open com1: 9600,8,N,1 > ? ? ? fi = serial.Serial(0, timeout = 1) > ? ? ? print '[gps module] SERIAL PORT OPEN ON COM1:' > > can anyone help me please? Thanks. http://docs.python.org/lib/node545.html HTH, -- Miki http://pythonwise.blogspot.com From gagsl-py2 at yahoo.com.ar Mon Apr 21 01:31:12 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 02:31:12 -0300 Subject: question about the mainloop References: <52de38c4-3d1e-4be0-9b58-5d60317f1ef7@b1g2000hsg.googlegroups.com> Message-ID: En Mon, 21 Apr 2008 00:57:38 -0300, globalrev escribi?: > On 21 Apr, 04:26, "Gabriel Genellina" wrote: >> En Sun, 20 Apr 2008 20:24:04 -0300, globalrev escribi?: >> >> > i dont get the mainloop() in python. i mean i have written some >> > programs, for example a calculator using tkinterGUI. >> >> What you call the "mainloop" is the event loop (or message loop) used by event-driven applications as a way to dispatch all events as they happen in the system. The concept is independent of Python/C++/whatever language you choose. The key phrase is "event-driven programming":http://en.wikipedia.org/wiki/Event_driven_programming >> Tkinter provides an event-driven GUI framework. Simple CLI programs are not event-driven, as your pseudo example above. >> >> > if i have some functions i wanna call to run the program and i wanna >> > call them ina specific order and be able to call >> > them from each other should this just be called in the mainloop and >> > the mianloop then runs the "mainscript" top >> > to bottom over and over? >> >> If you don't want or don't require a graphical user interface, just write the functions you need and call them from the outermost section in your script. >> If you do require a GUI, you'll have to write the code in response to user actions: when the user clicks here, do this; when the user chooses that menu option, do that. >> > > but what i mean i dont understand is sure i can bind a function to a > buttonpress but if i have a def dox(): dododo > and i call it with dox() in the mainscript it will be executed once, > but not again. > so what does the mainloop do, 1srt time it is executed it runs the > mainscript then it it sits and wait s for commands? What's the "mainscript"? The "mainloop" just waits for system events like: mouse movement, mouse click, key pressed, key released, time elapsed, window is uncovered, etc. And when any event arrives, it's dispatched to its registered handler. Python executes whatever you wrote at the top level of the script you are running, up to the root.mainloop() line. That function doesn't return until the main window is closed; all the user interaction occurs inside that call. Finally, execution resumes on the next line, if any. I hope this answers your question; if not, try to be more specific. Maybe an example of what you want to do. -- Gabriel Genellina From tundra at tundraware.com Thu Apr 17 11:51:55 2008 From: tundra at tundraware.com (Tim Daneliuk) Date: Thu, 17 Apr 2008 10:51:55 -0500 Subject: I just killed GIL!!! In-Reply-To: References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <52vid5-cvl2.ln1@ozzie.tundraware.com> <87hce1t8k5.fsf@physik.rwth-aachen.de> Message-ID: MRAB wrote: > On Apr 17, 5:22 am, Torsten Bronger > wrote: >> Hall?chen! >> >> Tim Daneliuk writes: >>> Daniel Fetchinson wrote: >>>> [...] >>>>> I just had one moment of exceptional clarity, during which >>>>> realized how I could get the GIL out of my way... It's so >>>>> simple, I cannot help wondering why nobody has thought of it >>>>> before. [...] >>>> If I were you I would keep it a secret until a Hollywood producer >>>> offers big bucks for the film rights. >>> Who would play Guido, I wonder? >> Ralf M?ller. No other. >> > If you're not careful Hollywood might re-invent Guido as an all- > American hero, Guy Ross! :-) "DIE HARD WITH NO GIL - He's Back And He's Pissed..." -- ---------------------------------------------------------------------------- Tim Daneliuk tundra at tundraware.com PGP Key: http://www.tundraware.com/PGP/ From duncan.booth at invalid.invalid Thu Apr 3 10:36:55 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 3 Apr 2008 14:36:55 GMT Subject: Nested try...except References: <670a8cc4-e3e0-412f-b259-5977f6d2f62d@a70g2000hsh.googlegroups.com> Message-ID: Carl Banks wrote: > Perhaps the advent of with blocks will help reduce this error in the > future. Indeed, and to encourage its use I think this thread ought to include the 'with statement' form of the function: from __future__ import with_statement from contextlib import closing def count(self): with closing(sqlite.connect( self.filename,isolation_level=ISOLATION_LEVEL)) as db: with closing(db.cursor()) as cur: cur.execute("select count(*) from sessions") return cur.fetchone()[0] From landerdebraznpc at gmail.com Mon Apr 28 03:55:47 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:55:47 -0700 (PDT) Subject: system mechanic 7 keygen Message-ID: system mechanic 7 keygen http://crack.cracksofts.com From Laundro at gmail.com Tue Apr 8 15:55:24 2008 From: Laundro at gmail.com (LaundroMat) Date: Tue, 8 Apr 2008 12:55:24 -0700 (PDT) Subject: Reproducing a web page and add own content to it. References: <6615blF2ifaqcU1@mid.uni-berlin.de> <1cddd2af-28be-42ee-8004-0d76978aeaa9@b9g2000prh.googlegroups.com> Message-ID: On Apr 8, 4:11 pm, Steve Holden wrote: > LaundroMat wrote: > > On Apr 8, 2:04 pm, "Diez B. Roggisch" wrote: > >> LaundroMat wrote: > >>> Hi - > >>> I'm working on a Django powered site where one of the required > >>> functionalities is the possibility of displaying the content of > >>> external pages, with an extra banner at the top where specific > >>> information is displayed. In other words, I'm looking for a way to > >>> reproduce an existing web page and add some HTML code to it. (I can't > >>> think of an example right now, but the idea is similar to sites that > >>> let you see an external page and have some site-specific text above it > >>> (often stating that the content below is not part of the site the user > >>> comes from)). > >>> To test this, I've been downloading an external page, adding some text > >>> to it and re-opening it in a browser (with the help of built-in > >>> modules such as urllib2 etc). This works of course, but the external > >>> page's links such as , or > >>> are evidently no longer correct. > >>> Apart from parsing the whole file and trying to inject the external > >>> site's domain in links such as the above (with the added inconvenience > >>> of having to store the external page locally), is there an easier way > >>> of accomplishing what I want? > >> Using a frame? > > >> Diez > > > Ack. I was too focused on importing the external web page and > > redisplaying the information (I've just been reading up on > > BeautifulSoup) instead of looking for an HTML based approach. > > > Thanks! > > You could also look at adding a tag to your generated page's > section. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ True, but I suppose that users would no longer see the top banner added by me when they click on one of the links on the external site's page. I'm a bit hesitant about using frames however, but reading up on them makes me think the application I have in mind for them might be the generally accepted exception to the rule that frames are bad :) Anyway. Thanks for the help! From fredri8758lupo at gmail.com Wed Apr 23 06:10:37 2008 From: fredri8758lupo at gmail.com (fredri8758lupo at gmail.com) Date: Wed, 23 Apr 2008 03:10:37 -0700 (PDT) Subject: keygen download Message-ID: keygen download http://cracks.12w.net F R E E C R A C K S From roger.miller at nova-sol.com Thu Apr 3 21:43:30 2008 From: roger.miller at nova-sol.com (Roger Miller) Date: Thu, 3 Apr 2008 18:43:30 -0700 (PDT) Subject: Is there an official way to add methods to an instance? References: Message-ID: <0db32c33-04a9-4993-9d5a-a617c575a4d7@u36g2000prf.googlegroups.com> On Apr 3, 2:57 pm, Brian Vanderburg II wrote: > > I've checked out some ways to get this to work. I want to be able to > add a new function to an instance of an object. I've tested two > different methods that cause problems with 'deleting'/garbage collection > (__del__ may never get called), but implemented one sort of hackishly > maybe that works find. I'm wondering if there is more of an official way > than mine. > Maybe I'm missing something, but the boring old straightforward approach works for me: class A: def __del__(self): print "Deleting" def f(x): print x a = A() a.f = f a.f(42) del a Output: 42 Deleting From darcy at druid.net Thu Apr 17 12:33:35 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Thu, 17 Apr 2008 12:33:35 -0400 Subject: Can't do a multiline assignment! In-Reply-To: References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> Message-ID: <20080417123335.cc11b9fb.darcy@druid.net> On Thu, 17 Apr 2008 09:19:32 -0700 (PDT) s0suk3 at gmail.com wrote: > I'm building a web server. The many variables are names of header > fields. One part of the code looks like this (or at least I'd like it > to): > > class RequestHeadersManager: > > # General header fields > Cache_Control = \ > Connection = \ > Date = \ > Pragma = \ > Trailer = \ > Transfer_Encoding = \ > Upgrade = \ > Via = \ > Warning = \ > > # Request header fields > Accept = \ > Accept_Charset = \ > Accept_Encoding = \ > Accept_Language = \ > Authorization = \ > ... > > Etc etc etc. At the end they'll all be assign to None. Then, when > initialized, __init__() will the the string of headers, parse them, > and use those variables shown above to assign to the header values. Of > course a normal request won't include all of those headers, so the > others will remain None. That's what I want. So basically you want a class that has a dict of headers which __init__ assigns to and to get a header you basically return O.get(header). -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From paulgeeleher at gmail.com Mon Apr 21 11:13:27 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Mon, 21 Apr 2008 08:13:27 -0700 (PDT) Subject: Problem setting cookie in Internet Explorer Message-ID: Hi, I'm using the python to set a cookie when a user logs in. Thing is it doesn't seem to be setting properly in Internet Explorer. It works grand in Firefox. Its basically: c = Cookie.SimpleCookie() c['username'] = uname c['password'] = pword print c print pageContent And thats it. I've a suspicion that it could be something to do with the expiry time of the cookie. But I'm really not sure and don't really know where to go with it. I've tried it on Internet Explorer on 2 machines and get the same problem. Thanks for any help... From jkazoo at gmail.com Wed Apr 16 14:43:18 2008 From: jkazoo at gmail.com (jkazoo at gmail.com) Date: Wed, 16 Apr 2008 11:43:18 -0700 (PDT) Subject: str class inheritance prob? Message-ID: <874eed0f-eeeb-4434-8a14-a3b29801a5f6@d26g2000prg.googlegroups.com> so I?m trying to create a class that inherits from str, but I want to run some code on the value on object init. this is what I have: class Path(str): def __init__( self, path ): clean = str(path).replace('\\','/') while clean.find('//') != -1: clean = clean.replace('//','/') print 'cleaned on init:\t',clean self = clean so clearly the clean variable is what I want value of the string to be, but that?s decidedly not the case. so running this: a=Path('path///with\\nasty/////crap_in_it/') print a gives me this: cleaned on init: path/with/nasty/crap_in_it/ path///with\nasty/////crap_in_it/ what gives? what am I doing wrong, and can I do what I?m trying to here? thanks. From martin at v.loewis.de Sun Apr 6 09:25:58 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 06 Apr 2008 15:25:58 +0200 Subject: Form sha1.hexdigest to sha1.digest In-Reply-To: <7c39af89-9cee-428c-a0bc-8202700c5aec@b1g2000hsg.googlegroups.com> References: <7c39af89-9cee-428c-a0bc-8202700c5aec@b1g2000hsg.googlegroups.com> Message-ID: <47F8CF66.1020805@v.loewis.de> > How can convert string from sha1.hexdigest() to string that is the > same, like from sha1.digest() Use binascii.unhexlify. HTH, Martin From sjmachin at lexicon.net Thu Apr 17 19:00:45 2008 From: sjmachin at lexicon.net (John Machin) Date: Thu, 17 Apr 2008 23:00:45 GMT Subject: Request a short code review In-Reply-To: References: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> Message-ID: <4807d69a$1@news.mel.dft.com.au> james at reggieband.com wrote: >> I am not necessarily looking to make the code shorter or more >> functional or anything in particular. However if you spot something >> to improve then I am happy to learn. > > To give an example of what I mean I have already altered the code: > > def output_random_lesson_of_type(self, type=None): > """Output a lesson of a specific type. > If no type is passed in then output any type.""" "any" type? Perhaps you mean all types. > output_lessons = self.lesson_data["lessons"] > if type: > filtered_lessons = filter(lambda x: x["type"] == type, > self.lesson_data["lessons"]) filter/map/reduce/lambda is not to everyone's taste; consider using a list comprehension: filtered_lessons = [x for x in self.lesson_data["lessons"] if x["type"] == type] Now you need to go up a level ... when you find yourself using dictionaries with constant string keys that are words, it's time to consider whether you should really be using classes: filtered_lessons = [x for x in self.lesson_data.lessons if x.type == type] > if filtered_lessons: > output_lessons = filtered_lessons > else: > print "Unable to find lessons of type %s." % type So the error action is to print a vague message on stdout and choose from all lessons? > return self.output_random(output_lessons) > > Changes: > - Respected a column width of 80 If you really care about people who are still using green-screen terminals or emulations thereof, make it < 80 -- some (most? all?) terminals will produce an annoying blank line if the text is exactly 80 bytes long. > - Created the output_lessons variable, assigned it to a default. > This remove an else statement and reduced the call to > self.output_random to a single instance in the return statement ... and also makes folk who are interested in what happens in the error(?) case read backwards to see what lessons will be used. HTH, John From soray6034rao at gmail.com Wed Apr 30 07:30:19 2008 From: soray6034rao at gmail.com (soray6034rao at gmail.com) Date: Wed, 30 Apr 2008 04:30:19 -0700 (PDT) Subject: age of empires 3 crack serial Message-ID: age of empires 3 crack serial http://crack.cracksofts.com From nick at stinemates.org Wed Apr 23 14:40:32 2008 From: nick at stinemates.org (Nick Stinemates) Date: Wed, 23 Apr 2008 11:40:32 -0700 Subject: Calling Python code from inside php In-Reply-To: References: Message-ID: <20080423184032.GA15639@deviL> On Wed, Apr 23, 2008 at 11:09:53AM -0700, vijay wrote: > Hi > I have a python code performing some computation for me.I have a > html page which passes certain argumnets to a php page.This php page > needs to pass on the value to the Python class and get the result > back. > How do I go about this?? > > > Cheers > Vijay > -- > http://mail.python.org/mailman/listinfo/python-list Why not just write it all in Python? -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From floris.bruynooghe at gmail.com Fri Apr 4 07:27:54 2008 From: floris.bruynooghe at gmail.com (Floris Bruynooghe) Date: Fri, 4 Apr 2008 04:27:54 -0700 (PDT) Subject: Ignoring windows registry PythonPath subkeys Message-ID: <133d93d0-8100-446c-909d-3b25d79af0a2@t54g2000hsg.googlegroups.com> Hi We basically want the same as the OP in [1], i.e. when python starts up we don't want to load *any* sys.path entries from the registry, including subkeys of the PythonPath key. The result of that thread seems to be to edit PC/getpathp.c[2] and recompile. This isn't that much of a problem since we're compiling python anyway, but is that really still the only way? Surely this isn't such an outlandish requirement? Regards Floris [1] http://groups.google.com/group/comp.lang.python/browse_frm/thread/4df87ffb23ac0c78/1b47f905eb3f990a?lnk=gst&q=sys.path+registry#1b47f905eb3f990a [2] By looking at getpathp.c it seems just commenting out the two calls to getpythonregpath(), for machinepath and userpath should work in most cases. From half.italian at gmail.com Mon Apr 14 21:21:42 2008 From: half.italian at gmail.com (Sean DiZazzo) Date: Mon, 14 Apr 2008 18:21:42 -0700 (PDT) Subject: text adventure game problem References: Message-ID: <2eea810c-8dfd-42b2-a0f3-d5071fdb7886@q10g2000prf.googlegroups.com> On Apr 8, 6:01?pm, corvettecra... at gmail.com wrote: > okay, I'm having this one problem with a text adventure game. It's > kind of hard to explain, but I'll do my best. > [code] > > def prompt_kitchen(): > ? ? global gold > ? ? gold_taken = False > ? ? while True: > ? ? ? ? prompt_kit = raw_input('>') > ? ? ? ? if prompt_kit == 'examine cabinet 1' and not gold_taken: > ? ? ? ? ? ? print '''This cabinet has a lot of cups in it with all > different > designs and shapes. Where are the people anyway? How come there's > nobody here? > In one of the cups you find 8 gold.''' > ? ? ? ? ? ? gold = gold+8 > ? ? ? ? ? ? gold_taken = True > ? ? ? ? ? ? pass4() > ? ? ? ? elif prompt_kit == 'examine cabinet 1' and gold_taken: > ? ? ? ? ? ? print \ > ? ? ? ? ? ? ? ? ? '''This cabinet has a lot of cups in it with all > different > designs and shapes. Where are the people anyway? How come there's > nobody here?''' > ? ? ? ? ? ? pass4() > > def pass4(): > ? ? global gold > ? ? print 'You have', gold, 'gold' > ? ? pass > [/code] > > Okay, now for my problem. > In the above function, there's the option to examine a cabinet and get > 8 gold. (everyone here knows that...but I'm just trying to state my > problem...) > Unfortunately, it kind of doesn't work. > After the first time I 'examine cabinet 1' in my game, I get 8 gold > and I can't get it again. > But, If I leave the room and come back to it, then it's as if I had > never gotten the gold the first time, and I can get it again. > How do I fix this? Thank you! Just downloaded and am about to have a blast into the past with PlanetFall! From duncan.booth at invalid.invalid Tue Apr 29 05:32:10 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 29 Apr 2008 09:32:10 GMT Subject: Why is None <= 0 References: <481226f9$0$20866$9b622d9e@news.freenet.de> Message-ID: =?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?= wrote: > (FWIW, in 2.x, x>=4?, it's None < numbers < anything else; > numbers are ordered by value, everything else is ordered > by type name, then by address, unless comparison functions > are implemented). Quite apart from Jon pointing out that this isn't true for all cases when copmparing against None, the other half also isn't true: >>> class C: pass >>> C() < 5 True That happens at least in Python 2.5.2 on win32. Yet another reason to avoid old-style classes. From fredri8758lupo at gmail.com Wed Apr 23 06:08:46 2008 From: fredri8758lupo at gmail.com (fredri8758lupo at gmail.com) Date: Wed, 23 Apr 2008 03:08:46 -0700 (PDT) Subject: soundtap keygen Message-ID: soundtap keygen http://cracks.12w.net F R E E C R A C K S From ang.usenet at gmail.com Tue Apr 8 16:35:34 2008 From: ang.usenet at gmail.com (Aaron Gray) Date: Tue, 8 Apr 2008 21:35:34 +0100 Subject: CPython VM & byte code resources wanted References: <6622srF2e32hbU1@mid.individual.net> Message-ID: <66238qF2h0kfqU1@mid.individual.net> "Aaron Gray" wrote in message news:6622srF2e32hbU1 at mid.individual.net... > Hi, > > I am looking to study the CPython source code, but I cannot seem to find > the VM code. Found it :) Python/ceval.c > Also is there any where a detailed list of the opcodes ? Still could do with an opcodes chart. Thanks, Aaron From steve at holdenweb.com Fri Apr 11 15:29:09 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 11 Apr 2008 15:29:09 -0400 Subject: Question on threads In-Reply-To: References: Message-ID: <47FFBC05.50309@holdenweb.com> Jonathan Shao wrote: > Hi all, > > I'm a beginner to Python, so please bear with me. > > Is there a way of guarenteeing that all created threads in a program are > finished before the main program exits? I know that using join() can > guarentee this, but from the test scripts I've run, it seems like join() > also forces each individual thread to terminate first before the next > thread can finish. So if I create like 20 threads in a for loop, and I > join() each created thread, then join() will in effect cause the threads > to be executed in serial rather than in parallel. > No it won't, as in fact there is no mechanism to force a thread to terminate in Python. When you join() each created thread the main thread will wait for each thread to finish. Supposing the longest-lived thread finished first then all others will immediately return from join(). The only requirement it is imposing is that all sub-threads must be finished before the main thread terminates. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From jzgoda at o2.usun.pl Wed Apr 9 14:56:40 2008 From: jzgoda at o2.usun.pl (Jarek Zgoda) Date: Wed, 09 Apr 2008 20:56:40 +0200 Subject: Parsing locale specific dates, currency, numbers In-Reply-To: References: <42b9a3ff0804091004s4d60751fh68c82673e8e3f4c3@mail.gmail.com> <16651e80804091031u5fc752e6s90b54c8675108088@mail.gmail.com> Message-ID: Malcolm Greene pisze: > The locale module provides the ability to format dates, currency and > numbers according to a specific locale. > > Is there a corresponding module for parsing locale's output to convert > locale formatted dates, currency, and numbers back to their native data > types on the basis of a specified locale? > > In other words, a module that will reverse the outputs of locale on a > locale specific basis. There are some attempts in Babel (http://babel.edgewall.org/), but the devs themselves claim the routines are incomplete. You might want to check it, though. -- Jarek Zgoda http://zgodowie.org/ "We read Knuth so you don't have to" - Tim Peters From steve at holdenweb.com Fri Apr 11 09:07:42 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 11 Apr 2008 09:07:42 -0400 Subject: (unknown) In-Reply-To: References: Message-ID: ha bo wrote: > hi i use this programme in my application django: > import struct > MASK_CCITT = 0x1021 # CRC-CCITT mask (ISO 3309, used in X25, HDLC) > MASK_CRC16 = 0xA001 # CRC16 mask (used in ARC files) > > def updcrc(crc, data, mask=MASK_CRC16): > > data_length = len(data) > unpackFormat = '%db' % data_length > unpackedData = struct.unpack(unpackFormat, data) > > for char in data: > c = ord(char) > c = c << 8 > > for j in xrange(8): > if (crc ^ c) & 0x8000: > crc = (crc << 1) ^ mask > else: > crc = crc << 1 > c = c << 1 > > return crc & 0xffff > > > and i call this function in other function in my view: > > > def encodekey(var, expires=None, user='', trusted=False): > > import random, base64 > import updcrc > key = "%02X" % len(var) + var > key += "%02X" % len(user) + user > if expires is not None: > key += expires.strftime('%Y%m%d%H%M') > else: > year = random.choice(range(2000,2100)) > month = 23 > day = random.choice(range(1,32)) > hour = random.choice(range(1,25)) > minute = random.choice(range(1,60)) > key += "%04d%02d%02d%02d%02d" % (year, month, day, hour, minute) > > if trusted: > checksum = updcrc(42, key) > else: > checksum = updcrc(0, key) > key += "%04X" % checksum > > return base64.b64encode(key) > but it give me this error: > > > unpack requires a string argument of length 31 > > > someone can help me > Next time you report an error, please include the whole traceback, not just the exception message. That information is included for a reason. You might also want to print out the value of data in your updcrc function, since that is where the problem is occurring. Finally I might point out there is little point to the struct.unpack since you don't use its result, but I am guessing this is because your algorithm is currently in transition. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From goldenlaks at gmail.com Fri Apr 4 04:47:29 2008 From: goldenlaks at gmail.com (TAJMAHAL TEMPLE) Date: Fri, 4 Apr 2008 01:47:29 -0700 (PDT) Subject: INDIAN TAJ-MAHAL Message-ID: http://ttdtemple.blogspot.com/ From wbsoft at xs4all.nl Fri Apr 11 02:31:04 2008 From: wbsoft at xs4all.nl (Wilbert Berendsen) Date: Fri, 11 Apr 2008 08:31:04 +0200 Subject: pty.spawn directs stderr to stdout Message-ID: <200804110831.05351.wbsoft@xs4all.nl> Hi, using pty.spawn() it seems that stderr output of the spawned process is directed to stdout. Is there a way to keep stderr separate and only direct stdin and stdout to the pty? TIA, w best regards, Wilbert Berendsen -- http://www.wilbertberendsen.nl/ "You must be the change you wish to see in the world." -- Mahatma Gandhi From michele.petrazzo at TOGLIunipex.it Thu Apr 24 09:43:38 2008 From: michele.petrazzo at TOGLIunipex.it (Michele Petrazzo) Date: Thu, 24 Apr 2008 15:43:38 +0200 Subject: annoying dictionary problem, non-existing keys In-Reply-To: References: Message-ID: bvidinli wrote: > i use dictionaries to hold some config data, such as: > > conf={'key1':'value1','key2':'value2'} and so on... > > when i try to process conf, i have to code every time like: if > conf.has_key('key1'): if conf['key1']<>'': other commands.... > > > this is very annoying. in php, i was able to code only like: if > conf['key1']=='someth' > > in python, this fails, because, if key1 does not exists, it raises an > exception. > That is one of python rules: >>> import this (cut) Explicit is better than implicit. (cut) php hide some thing that python expose. > MY question: is there a way to directly get value of an > array/tuple/dict item by key, as in php above, even if key may not > exist, i should not check if key exist, i should only use it, if it > does not exist, it may return only empty, just as in php.... > > i hope you understand my question... > You can simple modify the dict behavior: >>> class my_dict(dict): ... def __getitem__(self, item): ... if item in self: ... return super(my_dict, self).__getitem__(item) ... else: ... return '' ... >>> d = my_dict() >>> d["a"] '' >>> d["a"] = 5 >>> d["a"] 5 >>> Michele From hdante at gmail.com Sat Apr 26 17:27:32 2008 From: hdante at gmail.com (hdante) Date: Sat, 26 Apr 2008 14:27:32 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> Message-ID: <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> On Apr 26, 5:54?pm, n00m wrote: > hdante: > > I run your code quite a few times. > Its time = 0.734s. > Of mine = 0.703-0.718s. > > PS All I have is an ancient Mingw compiler (~1.9.5v) in Dev-C++. Okay, now I believe in you. :-P The next step would be to reimplement readline. From hbloftis at uncc.edu Mon Apr 21 02:33:47 2008 From: hbloftis at uncc.edu (Hunter) Date: Mon, 21 Apr 2008 08:33:47 +0200 (CEST) Subject: Conditional for...in failing with utf-8, Spanish book translation Message-ID: Hi all, This is my first Usenet post! I've run into a wall with my first Python program. I'm writing some simple code to take a text file that's utf-8 and in Spanish and to use online translation tools to convert it, word-by-word, into English. Then I'm generating a PDF with both of the languages. Most of this is working great, but I get intermittent errors of the form: --- Translating coche(coche)... Already cached! English: car Translating ahora(ahora)... tw returned now English: now Translating mismo?(mismo)... Already cached! English: same Translating ?A(?a)... iconv: illegal input sequence at position 0 tw returned error: the required parameter "srctext" is missing English: error: the required parameter "srctext" is missing --- The output should look like: Translating Raw_Text(lowercaserawtextwithoutpunctuation)... tw returned englishtranslation English: englishtranslation I've narrowed the problem down to a simple test program. Check this out: --- # -*- coding: utf-8 -*- acceptable = "abcdefghijklmnopqrstuvwxyz????" # this line will work acceptable = "abcdefghijklmnopqrstuvwxyz?????" # this line won't #wtf? word = "?A" word_key = ''.join([c for c in word.lower() if c in acceptable]) print "word_key = " + word_key --- Any ideas? I'm really stumped! Thanks, Hunter From colas.francis at gmail.com Wed Apr 16 05:56:30 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Wed, 16 Apr 2008 02:56:30 -0700 (PDT) Subject: insert python script in current script References: Message-ID: <967e0362-2d5e-464d-bd22-a0019bc1458a@y21g2000hsf.googlegroups.com> On 16 avr, 09:42, "Prashant" wrote: > I was wondering is there any way to do this: > > I have written a class in python and __init__ goes like this: > > def __init__(self): > > self.name = 'jack' > self.age = 50 > > import data > > now here there is data.py in the same directory and contents are like: > > self.address = 'your address' > self.status = 'single' > > The problem is 'self' is giving some error here. I need to know if > somehow I can do this. It's like inserting the script as it's part of > the file itself. The purpose of import is to build a module object, which implies executing the module file but in a new context. If you simply want to execute some code in a file, you can try execfile("filename"): In [243]: class A(object): .....: def __init__(self): .....: execfile("test.py") .....: In [244]: a=A() In [245]: a.a Out[245]: 1 In [246]: open("test.py").read() Out[246]: 'self.a = 1\n' But do you really want to execute some arbitrary code or to initialize values with some kind of configuration file? > > Cheers From jeffober at gmail.com Thu Apr 3 08:08:13 2008 From: jeffober at gmail.com (Jeff) Date: Thu, 3 Apr 2008 05:08:13 -0700 (PDT) Subject: Get all strings matching given RegExp References: Message-ID: <10be5458-055f-4d9a-af81-de9a6e533729@d1g2000hsg.googlegroups.com> I don't think there is any built in way. Regular expressions are compiled into an expanded pattern internally, but I don't think that it is anything that would be useful for you to directly access. If you are interested in a lot of work, you could do something with PLY and write an re parser that would expand it into a series of possible textual matches :) From python-url at phaseit.net Mon Apr 7 09:14:11 2008 From: python-url at phaseit.net (Gabriel Genellina) Date: Mon, 7 Apr 2008 13:14:11 +0000 (UTC) Subject: Python-URL! - weekly Python news and links (Apr 7) Message-ID: QOTW: "Describing [Python] as a 'scripting language' is like describing a fully-equipped professional kitchen as 'a left-over warming room'." - Steven D'Aprano "[S]ocial measures are the only thing that *can* properly deal with these issues [in this case, naming conflicts, functionality non-partitioning, ...--naming issues, really]." - Ben Finney Python 2.6a2 and 3.0a4 have been released, two new alpha versions of the next major releases: http://groups.google.com/group/comp.lang.python/browse_thread/thread/6cf534b1163b627/ A long thread: Object-Relational Mappers (ORM), pros and cons: http://groups.google.com/group/comp.lang.python/browse_thread/thread/a9b670f2a2b5be42/ Generator functions with recursive calls: why must a loop be explicit? http://groups.google.com/group/comp.lang.python/browse_thread/thread/8923ccee2062473a/ Since 3.0 will be ready soon, why should anyone new to the language bother to learn the old 2.X? http://groups.google.com/group/comp.lang.python/browse_thread/thread/44ace1486d840678/ Adding methods to a single instance: http://groups.google.com/group/comp.lang.python/browse_thread/thread/ba80ed8bf095b12f/ Teaching Python in high school: http://groups.google.com/group/comp.lang.python/browse_thread/thread/846ca6453d396fe0/ Python-by-example, examples covering all the standard library modules. http://groups.google.com/group/comp.lang.python/browse_thread/thread/d94853f357614b25/ http://www.lightbird.net/py-by-example/ Incorrect usage of the try/finally construct: http://groups.google.com/group/comp.lang.python/browse_thread/thread/ac8d61438c4c00ca/ super() - when to use (and when not to use it): http://groups.google.com/group/comp.lang.python/browse_thread/thread/22a35db06b0e9764/ Testing whether any string from a set is contained within another string: http://groups.google.com/group/comp.lang.python/browse_thread/thread/5261983811a04956/ ======================================================================== Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. Just beginning with Python? This page is a great place to start: http://wiki.python.org/moin/BeginnersGuide/Programmers The Python Papers aims to publish "the efforts of Python enthusiats": http://pythonpapers.org/ The Python Magazine is a technical monthly devoted to Python: http://pythonmagazine.com Readers have recommended the "Planet" sites: http://planetpython.org http://planet.python.org comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Python411 indexes "podcasts ... to help people learn Python ..." Updates appear more-than-weekly: http://www.awaretek.com/python/index.html Steve Bethard continues the marvelous tradition early borne by Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim Lesher of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donate.html Kurt B. Kaiser publishes a weekly report on faults and patches. http://www.google.com/groups?as_usubject=weekly%20python%20patch Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to capture useful and interesting recipes. http://aspn.activestate.com/ASPN/Cookbook/Python Many Python conferences around the world are in preparation. Watch this space for links to them. Among several Python-oriented RSS/RDF feeds available are http://www.python.org/channews.rdf http://bootleg-rss.g-blog.net/pythonware_com_daily.pcgi http://python.de/backend.php For more, see http://www.syndic8.com/feedlist.php?ShowMatch=python&ShowStatus=all The old Python "To-Do List" now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse http://www.python.org/dev/peps/pep-0042/ The online Python Journal is posted at pythonjournal.cognizor.com. editor at pythonjournal.com and editor at pythonjournal.cognizor.com welcome submission of material that helps people's understanding of Python use, and offer Web presentation of your work. del.icio.us presents an intriguing approach to reference commentary. It already aggregates quite a bit of Python intelligence. http://del.icio.us/tag/python *Py: the Journal of the Python Language* http://www.pyzine.com Archive probing tricks of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 http://groups.google.com/groups?meta=site%3Dgroups%26group%3Dcomp.lang.python.* Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://www.ddj.com/topic/python/ (requires subscription) http://groups-beta.google.com/groups?q=python-url+group:comp.lang.python*&start=0&scoring=d& http://purl.org/thecliff/python/url.html (dormant) or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python There is *not* an RSS for "Python-URL!"--at least not yet. Arguments for and against are occasionally entertained. Suggestions/corrections for next week's posting are always welcome. E-mail to should get through. To receive a new issue of this posting in e-mail each Monday morning (approximately), ask to subscribe. Mention "Python-URL!". Write to the same address to unsubscribe. -- The Python-URL! Team-- Phaseit, Inc. (http://phaseit.net) is pleased to participate in and sponsor the "Python-URL!" project. Watch this space for upcoming news about posting archives. From kranz at theorie.physik.uni-goettingen.de Sat Apr 12 06:53:11 2008 From: kranz at theorie.physik.uni-goettingen.de (Till Kranz) Date: Sat, 12 Apr 2008 12:53:11 +0200 Subject: Confused about Boost.Python & bjam Message-ID: Hi, I tried to get started with Boost.Python. unfortunately I never used the bjam build system before. As it is explained in the documentation I tried to adapt the the files form the examples directory. I copied 'Jamroot', 'boost_build.jam' and 'extending.cpp' to '~/test/'. But I am lost as to what to do now. The docu says I should adjust the 'use-project' path. But what to? I am using a Gentoo system, so there is no boost directory. The librarys are in /usr/lib/ the boost build stuff is in /usr/share/boost-build and the include files are in /usr/include/boost/. If anyone could post minimal Jamroot & boost_build.jam files for this setting I would be realy grateful. I think I will be able to figure out everything else, once I have a working example. Thanks in advance Till From bronger at physik.rwth-aachen.de Wed Apr 30 07:48:01 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 30 Apr 2008 13:48:01 +0200 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> <87tzhjy4u2.fsf@physik.rwth-aachen.de> <1TYRj.27306$o06.18162@tornado.fastwebnet.it> Message-ID: <87iqxzy366.fsf@physik.rwth-aachen.de> Hall?chen! Marco Mariani writes: > Torsten Bronger wrote: > >> However, join() is really bizarre. The list rather than the >> separator should be the leading actor. > > No, because join must work with _any sequence_, and there is no > "sequence" type to put the join method on. No, but for the sake of aesthetics (that's what we're talking here after all), it would be better to have it as the first argument in a build-in function. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From orpap at nus.edu.sg Mon Apr 21 12:28:49 2008 From: orpap at nus.edu.sg (orpap at nus.edu.sg) Date: Mon, 21 Apr 2008 09:28:49 -0700 (PDT) Subject: Financial Modeling with Python by Shayne Fletcher, Christopher Gardner Message-ID: Just saw at amazon.com reference to the following book that might be available later this year: Financial Modeling with Python [IMPORT] (Hardcover) by Shayne Fletcher (Author), Christopher Gardner (Author) Availability: Sign up to be notified when this item becomes available. Product Details * Hardcover: 352 pages * Publisher: John Wiley and Sons Ltd (November 10, 2008) * ISBN-10: 0470987847 * ISBN-13: 978-0470987841 * Shipping Weight: 1.7 pounds Would be nice if the authors or publisher could post to this group an outline or draft table of contents of the book. From hobgoodoreneyhb at gmail.com Tue Apr 22 11:45:31 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:45:31 -0700 (PDT) Subject: cracked eggs Message-ID: <3aa17072-5e76-4388-a5dc-7f5912b5306e@f36g2000hsa.googlegroups.com> cracked eggs http://cracks.12w.net F R E E C R A C K S From kyosohma at gmail.com Wed Apr 9 15:25:34 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 9 Apr 2008 12:25:34 -0700 (PDT) Subject: Displaying vtk files in a wxPython window References: <45b2ab4c-b7a1-450e-a084-e487f231aeca@q1g2000prf.googlegroups.com> Message-ID: <062bd9ce-5a21-4d7d-afba-2d88979e7270@u69g2000hse.googlegroups.com> On Apr 9, 1:38 pm, rocksportrocker wrote: > Hi, > > I want to visualize some vtk-files within a wxPython Window. Google > did not help me > very much, I only found some tools for Tk, what is no solution for me. > > I'm sure I am not the first one who asks this question.... > > Any hints ? > > Greetings, Uwe Hi Uwe, I've never done this, but I found the following: http://www.vtk.org/pipermail/vtkusers/2004-July/075208.html It seems to be an example of using wxPython and vtk. I'm also pretty sure I've seen this topic discussed on the wxPython user's list. You might want to re-post there: http://wxpython.org/maillist.php I also found these links: http://www.people.cornell.edu/pages/ajd27/VTK/lebbin_wxPython.html http://www.wxpython.org/docs/api/wx.lib.vtk-module.html Mike From soltys at noabuse.com Fri Apr 18 02:55:08 2008 From: soltys at noabuse.com (Soltys) Date: Fri, 18 Apr 2008 08:55:08 +0200 Subject: How to set proxy for a python script to run In-Reply-To: <94243913-cdcb-47a2-b000-a236fe0e8009@p25g2000hsf.googlegroups.com> References: <94243913-cdcb-47a2-b000-a236fe0e8009@p25g2000hsf.googlegroups.com> Message-ID: Adam pisze: > Hi, everyone, I am using /usr/share/system-config-language/ > language_gui.py in Python. > For some reason I have to bypass the firewall using a proxy. I read > the urllib reference and set http_proxy="my proxy". But it didn't > work. Is there anyway that we can set the proxy? I did sth. like this: proxy_url = "http://user:pass at proxy.yourproxy.org:8080" proxy_support = urllib2.ProxyHandler({'http': proxy_url}) opener = urllib2.build_opener(proxy_support) urllib2.install_opener(opener) src = urllib2.urlopen(url) now you can easily read from src. -- Soltys "Free software is a matter of liberty not price" From jzshao1 at gmail.com Mon Apr 14 20:06:48 2008 From: jzshao1 at gmail.com (Jonathan Shao) Date: Mon, 14 Apr 2008 20:06:48 -0400 Subject: Interesting timing issue I noticed Message-ID: The project I'm working on is motion detection, involving a bit of image processing. No worries: no image processing background needed. Suffice to say that I initially wrote a script that goes through every pixel of a 320x240 picture (turned into an array using PIL) and performs some calculatiosn. It simply goes through every pixel in the array and performs a simple subtraction with a known value. The idea is to try to find differences between the two images. After a while, to try to speed up the calculations, I realized that I didn't need to do all 320x240 calculations. So I implemented a slightly more sophisticated algorithm and localized my calculations. I still do the pixel subtractions, but I do it on a smaller scale. Surprisingly, when I used time.time() to time the procedures, I find that doing all 320x240 calculations are often faster! On my machine, the former gives me on average an execution time of around 0.125s (and consistently), whereas the latter on average takes 0.160s. Why does this happen? -- "Perhaps we all give the best of our hearts uncritically, to those who hardly think about us in return." ~ T.H.White -------------- next part -------------- An HTML attachment was scrubbed... URL: From bj_666 at gmx.net Sun Apr 13 13:12:48 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 13 Apr 2008 17:12:48 GMT Subject: Tkinter, image not appearing in function but without function References: <42a33edd-5792-47ad-a940-ecb5df23accc@a9g2000prl.googlegroups.com> Message-ID: <66et8fF2ju94lU2@mid.uni-berlin.de> On Sun, 13 Apr 2008 08:57:29 -0700, skanemupp wrote: > why is the first program not working? when i click the screen the map > is not appearing. > > the second program works. > > > > from Tkinter import * > > master = Tk() > > w = Canvas(master, width=700, height=600) > w.pack(expand = YES, fill = BOTH) > > def mapper(): > mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\world-map.gif') > w.create_image(10, 10, image = mapq, anchor = NW) > > def key(event): > print "pressed", repr(event.char) > > def callback(event): > w.focus_set() > print "clicked at", event.x, event.y > mapper() > print 'yo' > square = w.create_oval(event.x-5,event.y-5,event.x+5,event.y+5, > fill="black") > > w.bind("", key) > w.bind("", callback) > w.pack() > > > mainloop() Python doesn't know that the Tk side still needs the image and frees the memory when `mapper()` is done and `mapq` the only name to the `PhotoImage` instance goes out of scope. Ciao, Marc 'BlackJack' Rintsch From banibrata.dutta at gmail.com Sun Apr 20 00:55:51 2008 From: banibrata.dutta at gmail.com (Banibrata Dutta) Date: Sun, 20 Apr 2008 10:25:51 +0530 Subject: Any reliable obfurscator for Python 2.5 Message-ID: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> Hi, Wanted to check if there is any known, reliable, FOSS/Libre -- Obfurscator for Python 2.5 code. -- regards, Banibrata http://www.linkedin.com/in/bdutta -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrick.waldo at gmail.com Wed Apr 2 14:39:58 2008 From: patrick.waldo at gmail.com (patrick.waldo at gmail.com) Date: Wed, 2 Apr 2008 11:39:58 -0700 (PDT) Subject: xlrd and cPickle.dump References: <34e62ddb-477f-4a99-97a5-21a7b148d244@e67g2000hsa.googlegroups.com> <47f22a41@news.mel.dft.com.au> <0d46a213-9f95-43b5-835b-d74d8403626b@c19g2000prf.googlegroups.com> <6acbf9b4-161b-47db-9a91-b2448ee63c34@c26g2000prf.googlegroups.com> <12375df7-387d-424d-84a8-76beb664ae47@59g2000hsb.googlegroups.com> Message-ID: <8abe8ae1-84c9-4f80-ab37-31497a4d273c@a23g2000hsc.googlegroups.com> >FWIW, it works here on 2.5.1 without errors or warnings. Ouput is: >2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] >0.6.1 I guess it's a version issue then... I forgot about sorted! Yes, that would make sense! Thanks for the input. On Apr 2, 4:23 pm, patrick.wa... at gmail.com wrote: > Still no luck: > > Traceback (most recent call last): > File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework > \scriptutils.py", line 310, in RunScript > exec codeObject in __main__.__dict__ > File "C:\text analysis\pickle_test2.py", line 13, in ? > cPickle.dump(Data_sheet, pickle_file, -1) > PicklingError: Can't pickle : attribute lookup > __builtin__.module failed > > My code remains the same, except I added 'wb' and the -1 following > your suggestions: > > import cPickle,xlrd, sys > > print sys.version > print xlrd.__VERSION__ > > data_path = """C:\\test\\test.xls""" > pickle_path = """C:\\test\\pickle.pickle""" > > book = xlrd.open_workbook(data_path) > Data_sheet = book.sheet_by_index(0) > > pickle_file = open(pickle_path, 'wb')cPickle.dump(Data_sheet, pickle_file, -1) > pickle_file.close() > > To begin with (I forgot to mention this before) I get this error: > WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non- > zero > > I'm not sure what this means. > > > What do you describe as "simple manipulations"? Please describe your > > computer, including how much memory it has. > > I have a 1.8Ghz HP dv6000 with 2Gb of ram, which should be speedy > enough for my programming projects. However, when I try to print out > the rows in the excel file, my computer gets very slow and choppy, > which makes experimenting slow and frustrating. Maybe cPickle won't > solve this problem at all! For this first part, I am trying to make > ID numbers for the different permutation of categories, topics, and > sub_topics. So I will have [book,non-fiction,biography],[book,non- > fiction,history-general],[book,fiction,literature], etc.. > so I want the combination of > [book,non-fiction,biography] = 1 > [book,non-fiction,history-general] = 2 > [book,fiction,literature] = 3 > etc... > > My code does this, except sort returns None, which is strange. I just > want an alphabetical sort of the first option, which sort should do > automatically. When I do a test like>>>nest_list = [['bbc', 'cds'], ['jim', 'ex'],['abc', 'sd']] > >>>nest_list.sort() > > [['abc', 'sd'], ['bbc', 'cds'], ['jim', 'ex']] > It works fine, but not for my rows. > > Here's the code (unpickled/unsorted): > import xlrd, pyExcelerator > > path_file = "C:\\text_analysis\\test.xls" > book = xlrd.open_workbook(path_file) > ProcFT_QC = book.sheet_by_index(0) > log_path = "C:\\text_analysis\\ID_Log.log" > logfile = open(log_path,'wb') > > set_rows = [] > rows = [] > db = {} > n=0 > while n rows.append(ProcFT_QC.row_values(n, 6,9)) > n+=1 > print rows.sort() #Outputs None > ID = 1 > for row in rows: > if row not in set_rows: > set_rows.append(row) > db[ID] = row > entry = str(ID) + '|' + str(row).strip('u[]') + '\r\n' > logfile.write(entry) > ID+=1 > logfile.close() > > > Also, any good reason for sticking with Python 2.4? > > Trying to learn Zope/Plone too, so I'm sticking with Python 2.4. > > Thanks again From python at bdurham.com Fri Apr 25 07:56:10 2008 From: python at bdurham.com (python at bdurham.com) Date: Fri, 25 Apr 2008 07:56:10 -0400 Subject: Parsing text file with #include and #define directives In-Reply-To: References: Message-ID: <1209124570.1537.1249832039@webmail.messagingengine.com> Arnaud, Wow!!! That's beautiful. Thank you very much! Malcolm I think it's straightforward enough to be dealt with simply. Here is a solution that doesn't handle errors but should work with well-formed input and handles recursive expansions. expand(filename) returns an iterator over expanded lines in the file, inserting lines of included files. import re def expand(filename): defines = {} def define_repl(matchobj): return defines[matchobj.group(1)] define_regexp = re.compile('#(.+?)#') for line in open(filename): if line.startswith('#include '): recfilename = line.strip().split(None, 1)[1] for recline in expand(recfilename): yield recline elif line.startswith('#define '): _, name, value = line.strip().split(None, 2) defines[name] = value else: yield define_regexp.sub(define_repl, line) It would be easy to modify it to keep track of line numbers and file names. From marli305nugent at gmail.com Sat Apr 26 09:47:02 2008 From: marli305nugent at gmail.com (marli305nugent at gmail.com) Date: Sat, 26 Apr 2008 06:47:02 -0700 (PDT) Subject: cracks full downloads Message-ID: <839dcb67-e059-4b31-8e64-35049123a8f9@24g2000hsh.googlegroups.com> cracks full downloads http://cracks.00bp.com F R E E C R A C K S From pavlovevidence at gmail.com Wed Apr 30 13:58:45 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Wed, 30 Apr 2008 10:58:45 -0700 (PDT) Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> Message-ID: On Apr 30, 6:47 am, Duncan Booth wrote: > Torsten Bronger wrote: > > The biggest ugliness though is ",".join(). No idea why this should > > be better than join(list, separator=" "). Besides, ",".join(u"x") > > yields an unicode object. This is confusing (but will probably go > > away with Python 3). > > It is only ugly because you aren't used to seeing method calls on string > literals. I'm used to seeing it and I think it's ugly. Too terribly convenient to not use, though (which is why I'm used to seeing it). Carl Banks From roy at panix.com Sat Apr 12 12:52:09 2008 From: roy at panix.com (Roy Smith) Date: Sat, 12 Apr 2008 12:52:09 -0400 Subject: unittest: which directory structure? References: <87zlrzw1f5.fsf@physik.rwth-aachen.de> Message-ID: In article <87zlrzw1f5.fsf at physik.rwth-aachen.de>, Torsten Bronger wrote: > Hall?chen! > > I try to port my doctests to unittest. I've found good turorials > about *writing* unit tests but not about organising the files. > > What's the best way to arrange the test source files? I made a > directory called "tests" on the same level as my package, with > (roughly) one test module per package module and wanted to call each > of them from my Makefile or from some sort of root test module. When I first started using unittest, I did the same thing you did -- I put the test files in some other directory. This forced me into having to play the same sorts of tricks you're playing with sys.path so you could import your modules into the test framework. It also turned out to be more work for me during normal development, having to go into one directory to edit a test, then into another to edit the class being tested. Ultimately, I've come to the conclusion that just putting the production code and tests in the same directory is easier. Your next decision is how to name the files. You could put the tests for foo.py in test_foo.py, or foo_test.py (or a million other minor variations on spelling and punctuation). Using a "test_" *prefix* means all the tests sort to the end of the directory listing, so the production code and the test code stay separated from each other. Using a _test *suffix*, means the tests for a given module sort next to the module itself. This is the sort of decision which, while ultimately unimportant, has the ability to consume the entire development group in days (if not weeks) of religious debate. Just pick a style, go with it, and make sure everybody on the team sticks with the same style. From john00587 at gmail.com Mon Apr 21 01:44:01 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:44:01 -0700 (PDT) Subject: crack for spyware doctor Message-ID: crack for spyware doctor http://cracks.00bp.com F R E E C R A C K S From grahn+nntp at snipabacken.se Mon Apr 21 16:49:40 2008 From: grahn+nntp at snipabacken.se (Jorgen Grahn) Date: 21 Apr 2008 20:49:40 GMT Subject: Python 2.5 adoption References: <1da03626-2d4b-4e01-ba47-93f9d5c8f57f@l64g2000hse.googlegroups.com> Message-ID: On Fri, 18 Apr 2008 12:49:25 -0700 (PDT), George Sakkis wrote: > On Apr 18, 2:08?pm, Joseph Turian wrote: >> How widely adopted is python 2.5? >> >> We are doing some development, and have a choice to make: >> a) Use all the 2.5 features we want. >> b) Maintain backwards compatability with 2.4. >> >> So I guess the question is, does anyone have a sense of what percent >> of python users don't have 2.5? > > Perhaps you should ask the inverse question too: what 2.5 features do > you find so compelling that you are willing to break compatibility > with 2.4 ? FWIW, the only new 2.5 feature I have been using in > practice is the conditional expressions, and I could easily live > without them. 2.4 is still pretty decent, and a major upgrade from > 2.3. Another data point: I write some Python code in my work and some for hobby/private use, and I am very happy with 2.3. List comprehensions (or whatever they are called) and generators are the most recent features I would hate living without. OP: keep in mind that your users do not see any gain from you using 2.5. All they see is something that makes your software harder to install. At some point you can dismiss them as living in the Stone Age, but the Stone Age is currently 2.1 or something. Maybe 2.2 is, too. /Jorgen -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! From Laundro at gmail.com Tue Apr 8 07:31:42 2008 From: Laundro at gmail.com (LaundroMat) Date: Tue, 8 Apr 2008 04:31:42 -0700 (PDT) Subject: Reproducing a web page and add own content to it. Message-ID: Hi - I'm working on a Django powered site where one of the required functionalities is the possibility of displaying the content of external pages, with an extra banner at the top where specific information is displayed. In other words, I'm looking for a way to reproduce an existing web page and add some HTML code to it. (I can't think of an example right now, but the idea is similar to sites that let you see an external page and have some site-specific text above it (often stating that the content below is not part of the site the user comes from)). To test this, I've been downloading an external page, adding some text to it and re-opening it in a browser (with the help of built-in modules such as urllib2 etc). This works of course, but the external page's links such as , or are evidently no longer correct. Apart from parsing the whole file and trying to inject the external site's domain in links such as the above (with the added inconvenience of having to store the external page locally), is there an easier way of accomplishing what I want? Thanks, Mathieu From mobile at ibinsa.com Fri Apr 18 18:32:00 2008 From: mobile at ibinsa.com (Gabriel Ibanez) Date: Sat, 19 Apr 2008 00:32:00 +0200 Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> Message-ID: <002a01c8a1a4$051a5760$0a01a8c0@mobile> Debian Etch (stable) has Python 2.4 ----- Original Message ----- From: "Thomas Bellman" Newsgroups: comp.lang.python To: Sent: Friday, April 18, 2008 8:50 PM Subject: Re: Python 2.5 adoption > John Nagle writes: > >> Desktop or server? > >> If server, check what the major Linux distros, like Fedora >> Core, are shipping with. > > For server, you should probably rather look at distros like > RHEL/CentOS, Suse and Debian Stable. > > For what it's worth, Fedora 8 has Python 2.5, RHEL 5 ships with > Python 2.4, and RHEL 4 has Python 2.3. Suse and Debian, I don't > know. > >> Check major shared hosting providers to see what they're offering >> to their customers as standard. > > I would expect that to often depend on what OS version they are > using. And RHEL/CentOS 4 is still quite common, so if you want > to reach a large "customer base", make sure that your Python > programs work with Python 2.3. > > > -- > Thomas Bellman, Lysator Computer Club, Link??ping University, Sweden > "Don't tell me I'm burning the candle at both ! bellman @ lysator.liu.se > ends -- tell me where to get more wax!!" ! Make Love -- Nicht Wahr! > -------------------------------------------------------------------------------- > -- > http://mail.python.org/mailman/listinfo/python-list From jergosh at wp.pl Tue Apr 15 15:12:30 2008 From: jergosh at wp.pl (=?UTF-8?B?R3J6ZWdvcnogU8WCb2Rrb3dpY3o=?=) Date: Tue, 15 Apr 2008 21:12:30 +0200 Subject: Java or C++? In-Reply-To: References: Message-ID: <4804FE1E.8000100@wp.pl> > You must be joking - better designed? C++ was a botch to an already poor > language. > Although I'm relatively new to the concept that C++ is too difficult to use, I would concede that with certain mindset and priorities Java may be a valid choice. Not so if one is willing to expand knowledge about programming and find a complement for Python. Where I can't agree is that C is a poor language. You may prefer Unix was written in Pascal but C is still an excellent language, if no longer 'general-purpose.' C++ continues its philosophy of granting as much control as possible to the programmer. Whether it's a good or bad thing is debatable and depends on purpose for which you're using it. > Personally I find Java very satisfying to write. > Bing. From santoshanmsoft at gmail.com Tue Apr 29 02:56:29 2008 From: santoshanmsoft at gmail.com (santoshanmsoft at gmail.com) Date: Mon, 28 Apr 2008 23:56:29 -0700 (PDT) Subject: Acer Aspire 4520NWXMi Athlon LX.AHS0C.011LE Notebook Message-ID: <3141aa14-f8dd-46bc-9566-7f5182c16d1d@n1g2000prb.googlegroups.com> Features: * Based on the powerful and affordable AMD Turion? 64 X2 Mobile Technology, the Aspire 4520 is well suited for any home computing environment. Featuring impressive graphics solutions from NVIDIA?, a 14.1"Acer CrystalBrite? display, ultra-realistic Dolby? surround sound, they excel at video/audio playback, gaming and multitasking. Packaged in Acer's cool new chassis design, The Aspire 4520 is a vibrant beacon of style and class that are sure to become a focal point of the home or office. Processor AMD Athlon X2 TK53 * 1024MB DDR2 533MHz Memory (1GB) * 160GB Hard Disk Drive * 8X DVD-Super Multi double-layer drive * 14.1-inch (35.81 cm) WXGA TFT LCD. Specifications: * Operating System Linux * Processor: AMD Athlon X2 TK53 * Chipset: NVIDIA nForce * Memory: 1024MB DDR2 667MHz Memory * Screen Size 35.81 cms (14.1 wide) * Optical Drive 8X DVD Super Multi double layer drive * Hard Disk Drive: 160 GB HDD * Bluetooth Integrated bluetooth 2.0+EDR * Card Reader 5-in-1 Card reader * LAN: Gigabit LAN * Camera: Acer Crystal Eye Webcam supporting Primalite Technology * Ports & Others: Four USB 2.0 Ports, Dolby Stereo Speakers Warranty: Standard warranty on Notebooks - 1 year Carry-In local (India) warranty and 1 year International Travellers Warranty (Both run concurrently). Features: * Based on the powerful and affordable AMD Turion? 64 X2 Mobile Technology, the Aspire 4520 is well suited for any home computing environment. Featuring impressive graphics solutions from NVIDIA?, a 14.1"Acer CrystalBrite? display, ultra-realistic Dolby? surround sound, they excel at video/audio playback, gaming and multitasking. Packaged in Acer's cool new chassis design, The Aspire 4520 is a vibrant beacon of style and class that are sure to become a focal point of the home or office. Processor AMD Athlon X2 TK53 * 1024MB DDR2 533MHz Memory (1GB) * 160GB Hard Disk Drive * 8X DVD-Super Multi double-layer drive * 14.1-inch (35.81 cm) WXGA TFT LCD. Specifications: * Operating System Linux * Processor: AMD Athlon X2 TK53 * Chipset: NVIDIA nForce * Memory: 1024MB DDR2 667MHz Memory * Screen Size 35.81 cms (14.1 wide) * Optical Drive 8X DVD Super Multi double layer drive * Hard Disk Drive: 160 GB HDD * Bluetooth Integrated bluetooth 2.0+EDR * Card Reader 5-in-1 Card reader * LAN: Gigabit LAN * Camera: Acer Crystal Eye Webcam supporting Primalite Technology * Ports & Others: Four USB 2.0 Ports, Dolby Stereo Speakers Warranty: Standard warranty on Notebooks - 1 year Carry-In local (India) warranty and 1 year International Travellers Warranty (Both run concurrently). http://homeshop18.com/shop/faces/tiles/product.jsp?productID=20265&catalogueID=2&categoryID=920 From na at na.com Wed Apr 23 03:17:35 2008 From: na at na.com (Achillez) Date: Wed, 23 Apr 2008 07:17:35 GMT Subject: Script to convert Tcl scripts to Python? Message-ID: Hi, I have a 10k+ line Tcl program that I would like to auto convert over to Python. Do any scripts exist that can convert ~90% of the standard Tcl syntax over to Python? I know Python doesn't handle strings, but just for general syntax e.g., puts > print, expr > math operations thanks From dickinsm at gmail.com Fri Apr 11 15:27:43 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Fri, 11 Apr 2008 12:27:43 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> Message-ID: <5b1b5304-f076-4240-b685-6aa6c4cc209a@u3g2000hsc.googlegroups.com> On Apr 11, 2:33?pm, Lie wrote: > In this table, we consider that a number is rounded down when the > number is equal to truncated value (the number without fractional > part), while round up is equal to truncated value + 1 or truncated > value -1 if value is negative (Actually this is not round-half-up > algorithm, it's a round-half-away-from-zero algorithm, but lets just > consider that to be the same for now). In this revised table, you get > 10 round ups and 10 round down (i.e. Average Rounding Error == 0), > while by rounding to nearest even you get 9 round up and 11 round down > (i.e. Average Rounding Error != 0). No: if you interpret average to mean 'mean' (add up the (signed) rounding errors from the 20 cases you list and divide by 20) you'll find that the average rounding error is indeed 0 for round-half-to- even, and 0.05 for round-half-away-from-0, just as Mikael said. > Another mistake, in an unquantized value the probability of getting > exactly 0.5 (or any other number specified) is not 0 but an > infinitesimal (i.e. lim(x) where x -> 0 (BUT NOT ZERO)) I'm not sure you'll get many takers for this point of view. If X is a random variable uniformly distributed on the interval [0, 1) then the probability that X == 0.5 is indeed exactly 0, using conventional definitions. (And if you're not using conventional definitions, you should say so....) Mark From martin at v.loewis.de Thu Apr 17 15:12:30 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Thu, 17 Apr 2008 21:12:30 +0200 Subject: Unicode chr(150) en dash In-Reply-To: References: <48063434$0$36327$742ec2ed@news.sonic.net> Message-ID: <4807a11f$0$7672$9b622d9e@news.freenet.de> > For example, I got that EN DASH out of a web page which states version="1.0" encoding="ISO-8859-1"?> at the beggining. That's why I > did go for that encoding. But if the browser can properly decode that > character using that encoding, how come other applications can't? Please do trust us that ISO-8859-1 does *NOT* support EN DASH. There are two possible explanations for the behavior you observed: a) even though the file was declared ISO-8859-1, the data in it actually didn't use that encoding. The browser somehow found out, and chose a different encoding from the declared one. b) the web page contained the character reference – (or –), or the entity reference –. XML allows to support arbitrary Unicode characters even in a file that is encoded with ASCII. > I might need to go for python's htmllib to avoid this, not sure. But > if I don't, if I only want to just copy and paste some web pages text > contents into a tkinter Text widget, what should I do to succesfully > make every single character go all the way from the widget and out of > tkinter into a python string variable? How did my browser knew it > should render an EN DASH instead of a circumflexed lowercase u? Read the source of the web page to be certain. > This is the webpage in case you are interested, 4th line of first > paragraph, there is the EN DASH: > http://www.pagina12.com.ar/diario/elmundo/subnotas/102453-32303-2008-04-15.html Ok, this says – in several places, as well as “ and ” HTH, Martin From ewertman at gmail.com Sat Apr 26 21:39:50 2008 From: ewertman at gmail.com (Eric Wertman) Date: Sat, 26 Apr 2008 21:39:50 -0400 Subject: learning with python question (HtTLaPP) In-Reply-To: References: <98acecbd-9de2-4ebf-927b-ac6bc1fbc3fd@b5g2000pri.googlegroups.com> <53d6254f-895f-48fb-8ab9-3929c403f11b@v23g2000pro.googlegroups.com> Message-ID: <92da89760804261839y42a064a4r88f2d6b2154edf12@mail.gmail.com> On Sat, Apr 26, 2008 at 7:50 PM, wrote: > ok.. I finally made something that works.. Please let me know what you > think: > > >>> def lines(letters): > fin = open('words.txt') > count = 0 > rescount = 0 # count the number of results > results = "" # there are words that contain the letters > for line in fin: > needs = 0 > x = str(line.strip()) > for ch in letters: > if ch not in x: > pass > else: > needs = needs + 1 > if needs == len(letters): > rescount += 1 > results = results + '\n' + x > count += 1 > print count, 'lines searched' > print results, '\n' > print 'result count is: ', rescount That's pretty much it.. I'm guessing you are assuming your file has one word per line? I took a shot at it, without using the regex module: file = open('spyware') my_string = 'uzi' length = len(my_string) words = [] for line in file : chunks = line.strip().split() for chunk in chunks : x = 0 for char in my_string : x = chunk.rfind(char,x) if x > 0 : words.append(chunk) print '\n'.join(words) or with the re module: import re text = open('words.txt').read() pattern = '\S*u\S*z\S*i\S*' stuff = re.findall(pattern,text) count = len(stuff) print "Found %d words :" % (count) print "\n".join(stuff) From steve at holdenweb.com Thu Apr 24 21:27:42 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 21:27:42 -0400 Subject: Psyco alternative In-Reply-To: References: Message-ID: sturlamolden wrote: > On Apr 25, 2:15 am, Steve Holden wrote: > >> I believe, without the benefit of recent experience, that the R stands >> for Restricted. Thus and RPython program must of necessity also be a >> valid Python program. Or do you know something I don't? > > That is correct. But RPython is not anything like Python, I would not > even call it a dynamically typed language. It is actually more like > Fortran 77 with a Python look and feel. That seems a little harsh: it's Python-in-a-strait-jacket. The fact remains that since RPython programs also run under the standard interpreter (albeit a factor of maybe a hundred times more slowly) their claim of self-hosting is valid. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bronger at physik.rwth-aachen.de Wed Apr 16 13:45:31 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 16 Apr 2008 19:45:31 +0200 Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> <87prspydex.fsf@physik.rwth-aachen.de> Message-ID: <87fxtly9qc.fsf@physik.rwth-aachen.de> Hall?chen! Steve Holden writes: > Torsten Bronger wrote: > >> [...] >> >> The admistrative overhead of mailing lists is tedious. >> Fortunately, most important computer-related lists are on >> gmane.org. We could list c.l.py there, too. ;-) > > c.l.py has been on gmane for years, as comp.python.general (why > they have to have their own naming hierarchy i have never > understood). Oops, I overlooked this amongst all these interesting groups. ;-) But I don't need it either. Apparently, it also depends on the NNTP server admin team, and I have a very good one (http://www.individual.net/). I also see spam, but not much (7 among the most recent 1000 postings on c.l.py). Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From kapardhib at gmail.com Mon Apr 21 00:09:59 2008 From: kapardhib at gmail.com (kapardhi bvn) Date: Mon, 21 Apr 2008 09:39:59 +0530 Subject: Accessing parallel port interrupts using python or any c python binding ? Message-ID: <384662990804202109w7180365cu99599ca1628a5736@mail.gmail.com> Any body can tell me an efficient way of reading parallel port at high speed. this is basically to extend ISA and other bus interfacing. please help thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: From gagsl-py2 at yahoo.com.ar Mon Apr 28 22:59:59 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 28 Apr 2008 23:59:59 -0300 Subject: descriptor & docstring References: Message-ID: En Mon, 28 Apr 2008 14:35:40 -0300, cyril giraudon escribi?: > Hello, > > I try to use python descriptors to define attributes with default > value (the code is reported below). > But apparently, it breaks the docstring mechanism. > > help(Basis) shows the right help but help(Rectangle) shows only two > lines : > " > Help on class Rectangle in module basis2: > > Rectangle = > " > If the Rectangle.length attribute is removed, the help is OK. > > Secondly, the __doc__ attribute of a PhysicalValue instance doesn't > seem to be read. > > I don't understand. > > Any idea ? This looks like a soup of descriptors, metaclasses and properties... I'll write a two step example. I assume that you want to define an attribute with a default value: when not explicitely set, it returns the default value. This can be implemented with an existing descriptor: property. The only special thing is to handle the default value. Step 1: Our first attempt will let us write something like this: class X(object: length = property_default("length", 12., "This is the length property") We have to write property_default so it returns a property object with the right fget and fset methods. Let's use the same convention as your code, property "foo" will store its value at attribute "_foo". def property_default(prop_name, default_value=None, doc=None): attr_name = '_'+prop_name def fget(self, attr_name=attr_name, default_value=default_value): return getattr(self, attr_name, default_value) def fset(self, value, attr_name=attr_name, default_value=default_value): if value == default_value: delattr(self, attr_name) else: setattr(self, attr_name, value) return property(fget=fget, fset=fset, doc=doc) When setting the same value as the default, the instance attribute is removed (so the default will be used when retrieving the value later). I think this is what you intended to do. That's all. The classes look like this: # just to use a more meaningful name, if you wish PhysicalValue = property_default # A basis class class Basis(object): """ Tempest basis class """ # A concrete class class Rectangle(Basis): """ A beautiful Rectangle """ length = PhysicalValue("length", 12., "This is the length property") py> r = Rectangle() py> print r.length 12.0 py> r.length = 13.5 py> print r.length 13.5 py> dir(r) ['__class__', ... '_length', 'length'] py> r.length = 12 py> dir(r) ['__class__', ... 'length'] Help works too: py> help(Rectangle) Help on class Rectangle in module __main__: class Rectangle(Basis) | A beautiful Rectangle | | Method resolution order: | Rectangle | Basis | __builtin__.object | [...] py> help(Rectangle.length) Help on property: This is the length property Step 2: The problem with the property_default declaration above is that it repeats the name "length". If we want to comply with the DRY principle, we can use a metaclass (note that the previous solution doesn't require a custom metaclass). In the class declaration, we only have to store the parameters needed to define the property; later, when the class is created (the metaclass __new__ method), we replace those parameters with an actual property object. The fget/gset implementation is the same as above. class property_default(object): """Store info for defining a property with a default value. Replaced with a real property instance at class creation time. """ def __init__(self, default_value, doc=None): self.default_value = default_value self.doc = doc # just to use a more meaningful name, if you wish class PhysicalValue(property_default): pass class PropDefaultMetaClass(type): def __new__(cls, name, bases, dct): # replace all property_default declarations # with an actual property object # (we can't modify dct at the same time # we iterate over it, so collect the new items # into another dictionary) newprops = {} for prop_name, prop in dct.iteritems(): if isinstance(prop, property_default): attr_name = '_'+prop_name def fget(self, attr_name=attr_name, default_value=prop.default_value): return getattr(self, attr_name, default_value) def fset(self, value, attr_name=attr_name, default_value=prop.default_value): if value == default_value: delattr(self, attr_name) else: setattr(self, attr_name, value) newprops[prop_name] = property( fget=fget, fset=fset, doc=prop.doc) dct.update(newprops) return super(MyMetaClass, cls).__new__(cls, name, bases, dct) # A basis class class Basis(object): """ Tempest basis class """ __metaclass__ = PropDefaultMetaClass # A concrete class class Rectangle(Basis): """ A beautiful Rectangle """ length = PhysicalValue(12., "This is the length property") The usage and behavior is the same as in step 1, only that we can omit the "length" parameter to PhysicalValue. -- Gabriel Genellina From flarefight at googlemail.com Thu Apr 24 11:14:31 2008 From: flarefight at googlemail.com (flarefight at googlemail.com) Date: Thu, 24 Apr 2008 08:14:31 -0700 (PDT) Subject: Loading associated files Message-ID: <74862697-da58-4eb7-8d60-09aaef54b7ad@j22g2000hsf.googlegroups.com> I am trying to make a a simple databasing GUI interface and and have created a module to deal with parsing the data from a file and a GUI based program that displays this data using PyQt4, i know how to register files in the system registry using python and also using Inno Setup which i use to package my applications, but i cant work out how if a file is doubled clicked on to send the path of that file to python. I have looked into passing command line arguments to python and can send a specific pathname to python but ideally what i need is a generic command that i can write to the registry that passes the pathname of whichever file was doubled clicked!?! am i asking too much/does it exist/is there an easier way to do this!! CC From Robert.Bossy at jouy.inra.fr Tue Apr 15 11:43:25 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Tue, 15 Apr 2008 17:43:25 +0200 Subject: use object method without initializing object In-Reply-To: References: Message-ID: <4804CD1D.7040208@jouy.inra.fr> Reckoner wrote: > would it be possible to use one of an object's methods without > initializing the object? > > In other words, if I have: > > class Test: > def __init__(self): > print 'init' > def foo(self): > print 'foo' > > and I want to use the foo function without hitting the > initialize constructor function. > > Is this possible? > Hi, Yes. It is possible and it is called "class method". That is to say, it is a method bound to the class, and not to the class instances. In pragmatic terms, class methods have three differences from instance methods: 1) You have to declare a classmethod as a classmethod with the classmethod() function, or the @classmethod decorator. 2) The first argument is not the instance but the class: to mark this clearly, it is usually named cls, instead of self. 3) Classmethods are called with class objects, which looks like this: ClassName.class_method_name(...). In your example, this becomes: class Test(object): def __init__(self): print 'init' @classmethod def foo(cls): print 'foo' Now call foo without instantiating a Test: Test.foo() RB From mhansen at gmail.com Tue Apr 22 16:12:07 2008 From: mhansen at gmail.com (Mike Hansen) Date: Tue, 22 Apr 2008 13:12:07 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <82ab65e6-90ec-44db-a030-2251e9df7af4@p25g2000hsf.googlegroups.com> On Apr 22, 3:25 am, azrael wrote: > Hy guys, > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. > > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" > > This hurts. Please give me informations about realy famous > aplications. Sage ( http://www.sagemath.org ) is a pretty large Python computer algebra system ( about 150,000 unique lines of Python and 75,000 unique lines of Cython as a rough estimate). Python turned out to be an _excellent_ language do this in since it allows for quick development time for many things that aren't speed dependent while allowing a seemless transition to fast code with Cython. --Mike From greg.jandl at gmail.com Thu Apr 24 00:51:36 2008 From: greg.jandl at gmail.com (Greg J) Date: Wed, 23 Apr 2008 21:51:36 -0700 (PDT) Subject: Curious relation Message-ID: <613aa1f7-3943-4458-ba7e-4cb29c562988@y21g2000hsf.googlegroups.com> I was reading the programming Reddit tonight and came across this (http://reddit.com/info/6gwk1/comments/): >>> ([1]>2)==True True >>> [1]>(2==True) True >>> [1]>2==True False Odd, no? So, can anyone here shed light on this one? From steve at holdenweb.com Thu Apr 10 19:01:43 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 10 Apr 2008 19:01:43 -0400 Subject: How is GUI programming in Python? In-Reply-To: <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: Michel Bouwmans wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Mike Driscoll wrote: > >> On Apr 10, 12:05 pm, Michel Bouwmans wrote: >>> -----BEGIN PGP SIGNED MESSAGE----- >>> Hash: SHA1 >>> >>> >>> >>> Paul Rubin wrote: >>>> Chris Stewart writes: >>>>> I've always had an interest in Python and would like to dabble in it >>>>> further. I've worked on a few very small command line programs but >>>>> nothing of any complexity. I'd like to build a really simple GUI app >>>>> that will work across Mac, Windows, and Linux. How painful is that >>>>> going to be? I used to be really familiar with Java Swing a few years >>>>> ago. I imagine it will be similar. >>>>> ... >>>>> Next, what would you say is the best framework I should look into? >>>> If by "best" you mean "easiest", that is probably tkinter, which >>>> comes with python. It is somewhat rudimentary and the widgets that >>>> come with it don't look so great. But if you just want to put up >>>> GUI's with basic functionality and not much glitz, it is ok for most >>>> such purposes. >>>> out how to use >>> I don't quite agree with you on this. Tkinter may be easy because it is >>> available by standard in Python, but that's about it in my opinion. The >>> API, look and performance hit is horrible. You're much better of with >>> PyQt4 which makes the job really simple. >>> >>> MFB >>> -----BEGIN PGP SIGNATURE----- >>> Version: GnuPG v1.4.7 (GNU/Linux) >>> >>> iD8DBQFH/kjhDpaqHmOKFdQRAj+kAJ0d3aHqpv/mh7kSqtDqUFXtJsxi1gCfU5UP >>> 2Ygw9ttRIYX+ioMyBVUNsVo= >>> =stR5 >>> -----END PGP SIGNATURE----- >> I see a lot of people recommend using pyQt, but they never mention the >> controversy that surrounds its licensing. There have been many posts >> on the subject already, but if the OP ever decides to sell anything >> they create, I've heard that QT's licensing is kind of squirrelly. >> Maybe this has been straightened out? >> >> I looked at the website and found it fairly confusing. And don't you >> need to download QT itself? >> >> Mike > > Yeah, the licensing of Qt is either be open-source (under one of the > Qt-exception licenses licenses so no exclusivity for the GPL anymore) or > pay for the commercial version. So yes, if you would like to sell it as > closed-source software you will need to buy the commercial version of Qt > and PyQt. In other words: you will have to pay twice. Don't forget that you > can also sell open-source software, so you don't have to pay. ;) > I don't think PyQt has any licensing restrictions to speak of, only the underlying Qt platform (though it's a while since I looked). regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From ewertman at gmail.com Sun Apr 20 12:34:58 2008 From: ewertman at gmail.com (Eric Wertman) Date: Sun, 20 Apr 2008 09:34:58 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: <1d7f2d78-11fd-49f4-877c-73e95f449332@b64g2000hsa.googlegroups.com> > Look into any of the dozen Python-based template engines that are > typically used for such tasks; they offer many more features than a > way to indent blocks. > > George I definitely will.. could you throw out some examples though? Thanks! Eric From filipe.tg at gmail.com Mon Apr 28 06:14:51 2008 From: filipe.tg at gmail.com (Filipe Teixeira) Date: Mon, 28 Apr 2008 03:14:51 -0700 (PDT) Subject: Retrieving int from hex in a file. Message-ID: <9edfaaa3-4e87-4f74-90a5-c10c9daae101@r66g2000hsg.googlegroups.com> Hi. I have to open a binary file from an old computer and recover the information stored (or at least try to). I use: f=open('file.bin','rb') a=f.read() f.close() a in now a string full of hex representations in the form: a[6]='\x14' a[7]='\x20' I would like to convert these hex representations to int, but this (the most obvious way) doesn't seem to be working >>> q=a[6] >>> q '\x14' >>> int(q,16) Traceback (most recent call last): File "", line 1, in ? ValueError: invalid literal for int(): >>> How can I do this? Thanks From see.signature at no.spam Wed Apr 30 04:14:43 2008 From: see.signature at no.spam (Eric Brunel) Date: Wed, 30 Apr 2008 10:14:43 +0200 Subject: Simple TK Question - refreshing the canvas when not in focus References: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> <01b7e1cd-2e30-4751-9be5-63684af6530d@8g2000hse.googlegroups.com> Message-ID: On Tue, 29 Apr 2008 17:09:18 +0200, blaine wrote: [snip] > I'll try the update() again. I would want to use that on the canvas > itself right? Not the root window? Well, in fact, there is no difference at all... In tcl/tk, update is a function, and isn't applied to a particular widget. Any call to the update method on any widget should refresh the whole GUI. HTH -- python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])" From greg.ewing at canterbury.ac.nz Thu Apr 24 19:25:50 2008 From: greg.ewing at canterbury.ac.nz (Greg Ewing) Date: Fri, 25 Apr 2008 11:25:50 +1200 Subject: [Python-Dev] annoying dictionary problem, non-existing keys In-Reply-To: <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> Message-ID: <481116FE.9030501@canterbury.ac.nz> bvidinli wrote: > I posted to so many lists because, > > this issue is related to all lists, > this is an idea for python, > this is related to development of python... You shouldn't post to every group that you think might be vaguely relevant. You should pick *one* that you think is *most* relevant and try that. If you pick the wrong group, chances are you'll be politely redirected to a more relevant one. In this case, it's python-list or comp.lang.python, because this is clearly a usage question, not a request or suggestion for changing the language or its implementation (which is what python-ideas and pytho-dev are for). Posting to many groups at once tends to annoy people, because the readerships of related groups often overlap considerably, so many people get multiple copies of the message. -- Greg From leoniaumybragg at gmail.com Sat Apr 26 06:56:25 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:56:25 -0700 (PDT) Subject: dark crusade patch Message-ID: <6451716b-30ef-4ff1-8327-7e5fa8364bd3@l42g2000hsc.googlegroups.com> dark crusade patch http://cracks.00bp.com F R E E C R A C K S From markfernandes02 at googlemail.com Sat Apr 5 10:00:10 2008 From: markfernandes02 at googlemail.com (markfernandes02 at googlemail.com) Date: Sat, 5 Apr 2008 07:00:10 -0700 (PDT) Subject: In Tkinter - having an input and an entry References: <29f44489-e589-4331-8bea-36fa346026d2@t54g2000hsg.googlegroups.com> Message-ID: On Apr 5, 12:55 pm, Fredrik Lundh wrote: > markfernande... at googlemail.com wrote: > > Traceback (most recent call last): > > File "F:\Programming\python and database\access_db8.2.py", line 129, > > in ? > > Tkwindow() > > File "F:\Programming\python and database\access_db8.2.py", line 88, > > in Tkwindow > > title = stringVar() > > NameError: global name 'stringVar' is not defined > > >>> "StringVar" == "stringVar" > False > > Thanks it sorted out my 'StringVar' problem. I now have another problem... Exception in Tkinter callback Traceback (most recent call last): File "D:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__ return self.func(*args) TypeError: Insert() takes at least 1 argument (0 given) Code below def Insert(self, *row): global cursor, title, author, pubdate, accessDatabase sqlInsert = "INSERT INTO Book_table (Bookname, BookAutor, Publicationdate) VALUES('title + ',' author + ',' pubdate)" myconn = odbc.odbc('accessDatabase') #accessDatabase is the main connection fn. to db stored on HardDrive cursor = myconn.cursor() cursor.execute(sqlInsert) myconn.commit() cursor.close() myconn.close() Tkanks for your tech support. Mark From grante at visi.com Fri Apr 18 23:30:45 2008 From: grante at visi.com (Grant Edwards) Date: Fri, 18 Apr 2008 22:30:45 -0500 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> Message-ID: On 2008-04-18, Bob Greschke wrote: > However, in playing around with your suggestion and Grant's code I've > found that the struct stuff is WAY slower than doing something like this > > Value = (ord(Buf[s])*65536)+(ord(Buf[s+1])*256)+ord(Buf[s+2]) > if Value >= 0x800000: > Value -= 0x1000000 > > This is almost twice as fast just sitting here grinding through a few > hundred thousand conversions (like 3sec vs. ~5secs just counting on my > fingers - on an old Sun...it's a bit slow). Replacing *65536 with <<16 > and *256 with <<8 might even be a little faster, but it's too close to > call without really profiling it. I didn't know speed was important. This might be a little faster (depending on hardware): Value = (ord(Buf[s])<<16) | (ord(Buf[s+1])<<8) | ord(Buf[s+2]) It also makes the intention a bit more obvious (at least to me). A decent C compiler will recognize that <<16 and <<8 are special and just move bytes around rather than actually doing shifts. I doubt the Python compiler does optimizations like that, but shifts are still usually faster than multiplies (though, again, a good compiler will recognize that multiplying by 65536 is the same as shifting by 16 and just move bytes around). -- Grant Edwards grante Yow! If elected, Zippy at pledges to each and every visi.com American a 55-year-old houseboy... From bob at passcal.nmt.edu Mon Apr 21 18:51:13 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Mon, 21 Apr 2008 16:51:13 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> <2008042115060816807-bob@passcalnmtedu> Message-ID: <2008042116511375249-bob@passcalnmtedu> Something is fishy. I just ran this simple-minded thing and I'm, again, getting better times for ord() than I am for unpack() on a 2.8GHz OSX iMac with 2.5.1. This is the iterate so many times you can use your wristwatch method: ---- #! /usr/bin/env python from os import system from struct import unpack print "unpack 1" system("date") for x in xrange(0, 100000000): Value = unpack(">B", "a") system("date") print print "ord 1" system("date") for x in xrange(0, 100000000): Value = ord("a") system("date") print print "unpack 3" system("date") for x in xrange(0, 100000000): Value = unpack(">BBB", "abc") system("date") print print "ord 3" system("date") for x in xrange(0, 100000000): Value = (ord("a") << 16)+(ord("b") << 8)+ord("c") system("date") ---- Unpack 1 is about 1m20s Ord 1 is about 20s Unpack 3 is about 1m20s Ord 3 is about 1m03s after averaging a few runs. From bdsatish at gmail.com Fri Apr 11 07:07:51 2008 From: bdsatish at gmail.com (bdsatish) Date: Fri, 11 Apr 2008 04:07:51 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> Message-ID: <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> On Apr 11, 3:27 pm, colas.fran... at gmail.com wrote: > On 11 avr, 12:14, bdsatish wrote: > > > The built-in function round( ) will always "round up", that is 1.5 is > > rounded to 2.0 and 2.5 is rounded to 3.0. > > > If I want to round to the nearest even, that is > > > my_round(1.5) = 2 # As expected > > my_round(2.5) = 2 # Not 3, which is an odd num > > > I'm interested in rounding numbers of the form "x.5" depending upon > > whether x is odd or even. Any idea about how to implement it ? > > When you say "round to the nearest even", you mean new_round(3) <> 3? No. not at all. The clause "nearest even" comes into picture only when a number is of form "x.5" or else it's same as builtin round( ). new_round(3.0) must be 3.0 itself. Here is the mathematical definition of what I want: If 'n' is an integer, new_round(n+0.5) = n if n/2 is integer new_round(n+0.5) = (n+1) if (n+1)/2 is integer In all other cases, new_round() behave similarly as round( ). Here are the results I expect: new_round(3.2) = 3 new_round(3.6) = 4 new_round(3.5) = 4 new_round(2.5) = 2 new_round(-0.5) = 0.0 new_round(-1.5) = -2.0 new_round(-1.3) = -1.0 new_round(-1.8) = -2 new_round(-2.5) = -2.0 The built-in function doesnt meet my needs for round(-2.5) or round(2.5) From irmen.NOSPAM at xs4all.nl Sat Apr 26 08:25:57 2008 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Sat, 26 Apr 2008 14:25:57 +0200 Subject: Receive data from socket stream In-Reply-To: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> Message-ID: <48131f57$0$14357$e4fe514c@news.xs4all.nl> s0suk3 at gmail.com wrote: > Until now, I've been > doing this little trick: > > data = client.recv(256) > new = data > while len(new) == 256: > new = client.recv(256) > data += new Are you aware that recv() will not always return the amount of bytes asked for? (send() is similar; it doesn't guarantee that the full buffer you pass to it will be sent at once) I suggest reading this: http://www.amk.ca/python/howto/sockets/sockets.html --irmen From ohad.frand at percello.com Wed Apr 30 12:55:51 2008 From: ohad.frand at percello.com (Ohad Frand) Date: Wed, 30 Apr 2008 19:55:51 +0300 Subject: listing computer hard drives with python Message-ID: Hi I am looking for a way to get a list of all active logical hard drives of the computer (["c:","d:"..]) Thanks, Ohad -------------- next part -------------- An HTML attachment was scrubbed... URL: From deets at nospam.web.de Tue Apr 29 19:26:17 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 30 Apr 2008 01:26:17 +0200 Subject: python command mis-interprets arrow keys In-Reply-To: References: Message-ID: <67pp4oF2ppl3sU1@mid.uni-berlin.de> Rahul schrieb: > My python command line seems messed up. I can't seem to be able to use my > backspace key nor my arrow keys. > > I only get control characters: ^[[A^[[D^[[D^[[D^[[C^[[C^[[C etc. > > I access my Linux box via a SecureCRT console. Only after opening the > python interpreter does this occur. Linux command like is OK. vim > interprets keystrokes correctly. So do other interpreters e.g. gnuplot. > > $LANG $TERM > en_US xterm-color > > Versions: > Python 2.4.4 > GCC 4.1.2 20070925 (Red Hat 4.1.2-33) > > > Any sugesstions? Google did not throw anything relevant. Is libreadline installed? Diez From leoniaumybragg at gmail.com Sat Apr 26 07:00:52 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 04:00:52 -0700 (PDT) Subject: shredder 2 3 serial crack Message-ID: shredder 2 3 serial crack http://cracks.00bp.com F R E E C R A C K S From jr9445 at ATT.COM Wed Apr 9 16:26:44 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Wed, 9 Apr 2008 15:26:44 -0500 Subject: Stripping scripts from HTML with regular expressions In-Reply-To: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> References: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: > -----Original Message----- > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > list-bounces+jr9445=att.com at python.org] On Behalf Of Michel Bouwmans > Sent: Wednesday, April 09, 2008 3:38 PM > To: python-list at python.org > Subject: Stripping scripts from HTML with regular expressions > > Hey everyone, > > I'm trying to strip all script-blocks from a HTML-file using regex. > > I tried the following in Python: > > testfile = open('testfile') > testhtml = testfile.read() > regex = re.compile(']*>(.*?)', re.DOTALL) Aha! \b is being interpolated as a backspace character: \b ASCII Backspace (BS) Always use a raw string with regexes: regex = re.compile(r']*>(.*?)', re.DOTALL) Your regex should now work. ***** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA622 From altami0762 at gmail.com Thu Apr 17 15:49:55 2008 From: altami0762 at gmail.com (altami0762 at gmail.com) Date: Thu, 17 Apr 2008 12:49:55 -0700 (PDT) Subject: e-6 patch Message-ID: <08205506-86a7-4880-bba8-0d958e99eaa0@8g2000hse.googlegroups.com> e-6 patch http://cracks.12w.net F R E E C R A C K S From paul.anton.letnes at gmail.com Thu Apr 10 07:59:35 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Thu, 10 Apr 2008 13:59:35 +0200 Subject: problem with using gnuplot/demo.py In-Reply-To: <574751.90080.qm@web94914.mail.in2.yahoo.com> References: <574751.90080.qm@web94914.mail.in2.yahoo.com> Message-ID: Could you include some code around line 39 in demo.py? Also, you could try to comment out the stuff before that point, and see if the demo runs that far. Paul. > hi > i want to use gnuplot with python > i installed it seemingly successfully > but when i try to run demo.py it gives the following error > > > Traceback (most recent call last): > File "C:\Python23\Lib\site-packages\Gnuplot\demo.py", line 113, in ? > demo() > File "C:\Python23\Lib\site-packages\Gnuplot\demo.py", line 39, in > demo > g.reset() > File "C:\Python23\Lib\site-packages\Gnuplot\_Gnuplot.py", line > 355, in reset > self('reset') > File "C:\Python23\Lib\site-packages\Gnuplot\_Gnuplot.py", line > 199, in __call__ > self.gnuplot(s) > File "C:\Python23\Lib\site-packages\Gnuplot\gp_win32.py", line > 125, in __call__ > self.write(s + '\n') > > > im using python23 & gnuplot1.7 > > please help > > From Chandigarh to Chennai - find friends all over India. Click > here.-- > http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From walter at livinglogic.de Thu Apr 24 12:46:15 2008 From: walter at livinglogic.de (=?ISO-8859-1?Q?Walter_D=F6rwald?=) Date: Thu, 24 Apr 2008 18:46:15 +0200 Subject: convert xhtml back to html In-Reply-To: References: Message-ID: <4810B957.3090800@livinglogic.de> Arnaud Delobelle wrote: > "Tim Arnold" writes: > >> hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop to >> create CHM files. That application really hates xhtml, so I need to convert >> self-ending tags (e.g.
) to plain html (e.g.
). >> >> Seems simple enough, but I'm having some trouble with it. regexps trip up >> because I also have to take into account 'img', 'meta', 'link' tags, not >> just the simple 'br' and 'hr' tags. Well, maybe there's a simple way to do >> that with regexps, but my simpleminded )]+/> doesn't work. I'm not >> enough of a regexp pro to figure out that lookahead stuff. > > Hi, I'm not sure if this is very helpful but the following works on > the very simple example below. > >>>> import re >>>> xhtml = '

hello spam
bye

' >>>> xtag = re.compile(r'<([^>]*?)/>') >>>> xtag.sub(r'<\1>', xhtml) > '

hello spam
bye

' You might try XIST (http://www.livinglogic.de/Python/xist): Code looks like this: from ll.xist import parsers from ll.xist.ns import html xhtml = '

hello spam
bye

' doc = parsers.parsestring(xhtml) print doc.bytes(xhtml=0) This outputs:

hello spam
bye

(and a warning that the alt attribute is missing in the img ;)) Servus, Walter From pydev at rscorp.ab.ca Wed Apr 30 13:09:23 2008 From: pydev at rscorp.ab.ca (Scott SA) Date: Wed, 30 Apr 2008 11:09:23 -0600 Subject: PIL and IPTC Message-ID: On 4/30/08, Jumping Arne (arnlen at mac.com) wrote: >I'm completely new to PIL and I'm trying to read IPTC info, I understand that >it's possible but I can't find out how (and for once Google doesn't seem to >be able to help). Does anyone have an example of how it's done? Some basic PIL info: has a tutorial and more info It has been a while since I had to do it but effectively, you need to open the image before you can extract the IPTC as I recall. This should give you a starting point: from PIL import IptcImagePlugin dir(IptcImagePlugin) then... help(IptcImagePlugin.getiptcinfo) A Google Search for 'how-to' gives some insight The process is similar to reading EXIF info, I suggest you look there and modify as necessary. So a modified search to include EXIF While not PIL exclusive, the following should be useful: There are also separate libraries for IPTC with Python bindings. One is called libiptcdata. It lives here: Another example using IPTCInfo: And another python-based (non PIL) one here: While not a direct answer, I hope this is helpful, Scott From sbergman27 at gmail.com Thu Apr 17 13:15:34 2008 From: sbergman27 at gmail.com (Steve Bergman) Date: Thu, 17 Apr 2008 10:15:34 -0700 (PDT) Subject: How to make this unpickling/sorting demo faster? Message-ID: <40a5d8f1-a246-4c48-8759-5b65324f9029@m73g2000hsh.googlegroups.com> I'm involved in a discussion thread in which it has been stated that: """ Anything written in a language that is > 20x slower (Perl, Python, PHP) than C/C++ should be instantly rejected by users on those grounds alone. """ I've challenged someone to beat the snippet of code below in C, C++, or assembler, for reading in one million pairs of random floats and sorting them by the second member of the pair. I'm not a master Python programmer. Is there anything I could do to make this even faster than it is? Also, if I try to write the resulting list of tuples back out to a gdbm file, it takes a good 14 seconds, which is far longer than the reading and sorting takes. The problem seems to be that the 'f' flag to gdbm.open() is being ignored and writes are being sync'd to disk either on each write, or on close. I'd really prefer to let the OS decide when to actually write to disk. I'm using python 2.5.2, libgdm 1.8.3, and python-gdbm 2.5.2 under Ubuntu 8.4 beta and an x86_64 architechture. Thanks for any tips. ===== import cPickle, gdbm, operator dbmIn = gdbm.open('float_pairs_in.pickel') print "Reading pairs..." pairs = cPickle.loads(dbmIn['pairs']) print "Sorting pairs..." pairs.sort(key=operator.itemgetter(1)) print "Done!" ===== The input file was created with this: ===== import random, gdbm, cPickle print "Creating pairs file..." pairs = [(random.random(), random.random(),) for pair in range(0,1000000)] dbmOut = gdbm.open('float_pairs_in.pickel', 'nf') dbmOut['pairs'] = cPickle.dumps(pairs, 2) dbmOut.close() print "Done!" ===== From rkmr.em at gmail.com Thu Apr 24 00:19:10 2008 From: rkmr.em at gmail.com (rkmr.em at gmail.com) Date: Wed, 23 Apr 2008 21:19:10 -0700 Subject: dynamically importing a module and function In-Reply-To: <480d27a3@news.mel.dft.com.au> References: <480d1782$1@news.mel.dft.com.au> <480d27a3@news.mel.dft.com.au> Message-ID: On Mon, Apr 21, 2008 at 4:47 PM, John Machin wrote: > > > saved = sys.path > > > sys.path = data['cwd'] > > > module = __import__(data['module']) > > > sys.path = saved > > > > > > > > import os > > > > > os.chdir('/home/mark/work/proj1') > > > > > import sys > > > > > sys.path.append('/home/mark/work/proj1') > > > > > module = __import__('app') > > > > > function = getattr(module, 'new') > > > > > function(1) > > > > > > > > > > > > > > 1 > > > > It's not at all obvious that the "works in shell" code is the same as the > code in your script. > > Consider the possibility that as a result of frantic experimentation you > have multiple copies of app.* with varying contents lying around. thanks a lot! there was a file app.pyc lying around in the dir from which i was running the script... From slocumb.daphn at gmail.com Fri Apr 18 07:39:36 2008 From: slocumb.daphn at gmail.com (slocumb.daphn at gmail.com) Date: Fri, 18 Apr 2008 04:39:36 -0700 (PDT) Subject: Ableton live 4.1.4 crack Message-ID: <37f60071-fd9b-4f08-b85e-6ff27fe8e4bb@24g2000hsh.googlegroups.com> Ableton live 4.1.4 crack From lists at cheimes.de Sat Apr 12 08:48:02 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 12 Apr 2008 14:48:02 +0200 Subject: accessing individual characters in unicode strings In-Reply-To: References: Message-ID: <4800AF82.2020607@cheimes.de> Peter Robinson schrieb: > Dear list > I am at my wits end on what seemed a very simple task: > I have some greek text, nicely encoded in utf8, going in and out of a > xml database, being passed over and beautifully displayed on the web. > For example: the most common greek word of all 'kai' (or ??? if your > mailer can see utf8) > So all I want to do is: > step through this string a character at a time, and do something for > each character (actually set a width attribute somewhere else for each > character) As John already said: UTF-8 ain't unicode. UTF-8 is an encoding similar to ASCII or Latin-1 but different in its inner workings. A single character may be encoded by up to 6 bytes. I highly recommend Joel's article on unicode: The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) http://www.joelonsoftware.com/articles/Unicode.html Christian From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 3 10:06:15 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 03 Apr 2008 16:06:15 +0200 Subject: object-relational mappers In-Reply-To: <89bca327-6a3f-4128-be72-75d4a50b9bf0@13g2000hsb.googlegroups.com> References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> <89bca327-6a3f-4128-be72-75d4a50b9bf0@13g2000hsb.googlegroups.com> Message-ID: <47f4e456$0$20141$426a74cc@news.free.fr> Luis M. Gonz?lez a ?crit : > I have come to the same conclusion. > ORMs make easy things easier, but difficult things impossible... Not my experience with SQLAlchemy. Ok, I still not had an occasion to test it against stored procedures, but when it comes to complex queries, it did the trick so far - and (warning: front-end developper considerations ahead) happened to be much more usable than raw strings to dynamically *build* the queries. > The best approach I've seen so far is webpy's (if we are talking of > web apps). > It isn't an ORM, it is just a way to make the database api easier to > use. > Queries don't return objects, they return something similar to > dictionaries, which can be used with dot notation ( for example, > result.name is equal to result['name'] ). > > A simple select query would be db.select('customers') or > db.select('customers', name='John'). > But you can also resort to plain sql as follows: db.query('select * > from customers where name = "John"'). > > Simple, effective and doesn't get in your way. Seems nice too in another way. Is that part independant of the rest of the framework ? If so, I'll have to give it a try at least for admin scripts. From jgardner at jonathangardner.net Thu Apr 17 13:19:11 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Thu, 17 Apr 2008 10:19:11 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> <87tzi05vrm.fsf@mulj.homelinux.net> Message-ID: On Apr 17, 9:48 am, sturlamolden wrote: > On Apr 17, 5:46 pm, Hrvoje Niksic wrote: > > > Have you tackled the communication problem? The way I see it, one > > interpreter cannot "see" objects created in the other because they > > have separate pools of ... everything. They can communicate by > > passing serialized objects through ctypes, but that sounds like the > > solutions that use processes. > > I see two solutions to that. > > It is possible to use fine-grained locking on the objects that need to > be communicated. And you'll pay a price for every lock/unlock operation, in addition to the added complexity of the code (which you are already beginning to see.) That's been tried in Python, and everyone agreed that the GIL was the better compromise. > The other option is to use serialized Queues like the processing > module in cheese shop. You mean pipes, files, and sockets? You should check out Stackless's channels. Not a new or unique concept, but a very powerful one that everyone should be familiar with. From adam_no_spam at no_s.p.a.m.bregenzer.net Sun Apr 13 00:57:42 2008 From: adam_no_spam at no_s.p.a.m.bregenzer.net (Adam Bregenzer) Date: Sat, 12 Apr 2008 23:57:42 -0500 Subject: Controlling copying and pickling of objects written in C Message-ID: <3_idnfMhL8pbD5zVnZ2dnUVZ_tPinZ2d@speakeasy.net> I am writing an extension and have "hidden" data included in the object's C structure that is not visible to python. I am unsure what would happen to that data if the python object were copied or pickled and would prefer to raise an exception whenever code tries to copy/deep copy/pickle or marshal the object since it would not make sense. Where would I look to control that? Thanks, Adam From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 29 04:55:13 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 29 Apr 2008 10:55:13 +0200 Subject: list.reverse() In-Reply-To: References: Message-ID: <4816e26a$0$30938$426a74cc@news.free.fr> Mark Bryan Yu a ?crit : > This set of codes works: > >>>> x = range(5) >>>> x.reverse() >>>> x > [4, 3, 2, 1, 0] > > But this doesn't: > >>>> x = range(5).reverse() >>>> print x > None This works just as expected - at least for anyone having read the doc. > Please explain this behavior. range(5) returns a list from 0 to 4 and > reverse just reverses the items on the list that is returned by > range(5). Why is x None (null)? Because that's what list.reverse() returns. Call it a wart if you want (FWIW, I do), but at least that's well documented. From ivan.illarionov at gmail.com Sat Apr 19 01:35:12 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Sat, 19 Apr 2008 05:35:12 +0000 (UTC) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> Message-ID: On Sat, 19 Apr 2008 04:45:54 +0000, Ivan Illarionov wrote: > On Fri, 18 Apr 2008 22:30:45 -0500, Grant Edwards wrote: > >> On 2008-04-18, Bob Greschke wrote: >> >>> However, in playing around with your suggestion and Grant's code I've >>> found that the struct stuff is WAY slower than doing something like >>> this >>> >>> Value = (ord(Buf[s])*65536)+(ord(Buf[s+1])*256)+ord(Buf[s+2]) if >>> Value >>> >= 0x800000: >>> Value -= 0x1000000 >>> >>> This is almost twice as fast just sitting here grinding through a few >>> hundred thousand conversions (like 3sec vs. ~5secs just counting on my >>> fingers - on an old Sun...it's a bit slow). Replacing *65536 with >>> <<16 and *256 with <<8 might even be a little faster, but it's too >>> close to call without really profiling it. >> >> I didn't know speed was important. This might be a little faster >> (depending on hardware): >> >> Value = (ord(Buf[s])<<16) | (ord(Buf[s+1])<<8) | ord(Buf[s+2]) >> >> It also makes the intention a bit more obvious (at least to me). >> >> A decent C compiler will recognize that <<16 and <<8 are special and >> just move bytes around rather than actually doing shifts. I doubt the >> Python compiler does optimizations like that, but shifts are still >> usually faster than multiplies (though, again, a good compiler will >> recognize that multiplying by 65536 is the same as shifting by 16 and >> just move bytes around). > > So why not put it in C extension? > > It's easier than most people think: > > > from3bytes.c > ============ > #include > > PyObject* > from3bytes(PyObject* self, PyObject* args) { > const char * s; > int len; > if (!PyArg_ParseTuple(args, "s#", &s, &len)) > return NULL; > long n = (s[0]<<16) | (s[1]<<8) | s[2]; if (n >= 0x800000) > n -= 0x1000000; > return PyInt_FromLong(n); > } > > static PyMethodDef functions[] = { > {"from3bytes", (PyCFunction)from3bytes, METH_VARARGS}, {NULL, > NULL, 0, NULL}, > }; > > > DL_EXPORT(void) > init_from3bytes(void) > { > Py_InitModule("_from3bytes", functions); > } > > buildme.py > ========== > import os > import sys > from distutils.core import Extension, setup > > os.chdir(os.path.dirname(os.path.abspath(__file__))) sys.argv = > [sys.argv[0], 'build_ext', '-i'] setup(ext_modules = > [Extension('_from3bytes', ['from3bytes.c'])]) > > 'python buildme.py' will create '_from3bytes.so' file 'from _from3bytes > import from3bytes' will import C-optimized function > > Hope this helps. Sorry, the right code should be: PyObject* from3bytes(PyObject* self, PyObject* args) { const char * s; int len; if (!PyArg_ParseTuple(args, "s#", &s, &len)) return NULL; long n = ((((unsigned char)s[0])<<16) | (((unsigned char)s[1])<<8) | ((unsigned char)s[2])); if (n >= 0x800000) n -= 0x1000000; return PyInt_FromLong(n); } From ed at leafe.com Tue Apr 1 19:59:55 2008 From: ed at leafe.com (Ed Leafe) Date: Tue, 1 Apr 2008 18:59:55 -0500 Subject: What motivates all unpaid volunteers at Pycon? In-Reply-To: <6ffcb45b-abb9-4d5e-8237-0f8c6bacab08@i29g2000prf.googlegroups.com> References: <7b539c8e-af4c-4409-81bc-d94e687eea59@i7g2000prf.googlegroups.com> <12d7412e-9f87-4798-a319-a78a27f68d00@e6g2000prf.googlegroups.com> <6ffcb45b-abb9-4d5e-8237-0f8c6bacab08@i29g2000prf.googlegroups.com> Message-ID: <2D7EB6ED-E617-41EC-A15D-6EED754E49FE@leafe.com> On Apr 1, 2008, at 5:37 PM, seberino at spawar.navy.mil wrote: > What do the people get back who did all the hard work at registration > desk and > preparing conference attendee bags? ...who did all hotel preparations? You'll have to ask them. When I've been a part of events like this, just knowing that I contributed is a great feeling. I also usually end up meeting several people I might not have otherwise met, and invariably that makes the experience much, much richer. -- Ed Leafe From chris.ortner at googlemail.com Sat Apr 26 16:49:56 2008 From: chris.ortner at googlemail.com (Chris Ortner) Date: Sat, 26 Apr 2008 13:49:56 -0700 (PDT) Subject: python and web programming, easy way...? References: Message-ID: On Apr 26, 9:36 pm, bvidinli wrote: > Please provide me the quickest/most appropriate solution for web > programming in python. > i will try to switch to python in ehcp too.. > > Currently my web programs are simple Object Oriented programs, that > basicly uses a few files, in php. > i use sessions in use authentications. > i currently use php because it is fairly easy to install/run on apache.. > you just put it on server, it runs.. i look something like this for > python. because python programming is much better than php. Give the web application framework Django a try. Greetings, Chris From aldo at nullcube.com Tue Apr 1 21:24:20 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Wed, 2 Apr 2008 12:24:20 +1100 Subject: ANN: cubictemp template engine Message-ID: <20080402012420.GA21586@nullcube.com> We are happy to announce release 2.0 of Cubictemp, a small, elegant templating system for Python. Features ======== * Simple, well-tested and well-documented. * Integrates tightly with Python - pass arbitrary Python objects into a template, walk sequences and iterators, evaluate expressions. * Default escaping helps to prevent common classes of Cross-Site Scripting vulnerabilities. * Encourages separation of interface and program logic by disallowing statements in templates. * Tiny - only ~ 170 SLOC. There are many large, over-designed Python templating systems out there. Cubictemp proves that a templating sytem can be elegant, powerful, fast and remain compact. Download: http://dev.nullcube.com Manual: http://dev.nullcube.com/doc/cubictemp/index.html -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From skanemupp at yahoo.se Sun Apr 6 19:11:47 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 6 Apr 2008 16:11:47 -0700 (PDT) Subject: Prevent GUI layout from changing? References: Message-ID: On 6 Apr, 22:15, "Gabriel Genellina" wrote: > En Sun, 06 Apr 2008 15:12:55 -0300, escribi?: > > I can't help with your sizing problem, I don't know grids. But don't do > this: > > > def Display(self, number): > > self.expr = self.expr + number > > self.lbText = Label(self, text=self.expr) > > self.lbText.grid(row=0, column=0) > > > def Calculate(self): > > self.expr = str(eval(self.expr))#try catch tex 3+6+ > > self.lbText = Label(self, text=self.expr) > > self.lbText.grid(row=1, column=1) > > self.expr = "" > > You're creating a *new* Label object for each keystroke (they stack on the > same place and only the newest is visible, I presume). > Instead, you should change the text inside the existing widget: > > self.lbText.config(text=self.expr) > > (there is no need to reposition the widget) > Label is described herehttp://effbot.org/tkinterbook/label.htm > and you may want to learn to use Tkinter variables: http://effbot.org/tkinterbook/variable.htm > > -- > Gabriel Genellina the problem is that when i start writing long numbers the window grows bigger which is really annoying. is that ebcause of what u said? as of now i can see exactly the expression i typed and the answer it is just annoing that it doesnt stay the same size. From aguirre.adolfo at gmail.com Mon Apr 28 22:08:01 2008 From: aguirre.adolfo at gmail.com (aguirre.adolfo at gmail.com) Date: Mon, 28 Apr 2008 19:08:01 -0700 (PDT) Subject: Python Math libraries - How to? Message-ID: Hi, I am a very newbie who would very much appreciate some hints. Python 2.52. on Windows XP for now. Soon on Ubuntu 8 I am teaching myself Python following free tutorials. I can solve problems using arithmetic, but when I try to upgrade the programs using math libraries nothing seems to work. I downloaded a 2002 tutorial from Zelle "An Introduction to Computer Science" where he uses a "import math" statement to calculate a square root. I tried the "pi" library function but it didn?t work. I tried using def Pi() it did not work either. I am yet to find a tutorial that explains how to declare (or initialize) and pass numbers to the functions such as "cos(x)" and the pi which does not have a variable in it. Is just a constant. Here is the arithmetic program I made that it worked before I added the "import math" line. I erased the constant p = 3.1416 and added the "i" for the library function "pi" in the algorithms. But I get an error message not recognizing "pi" #volumen.py # A program to compute the volume and surface area of a sphere import math def main(): print "This program calculates the volume and surface area of a sphere" print r = input("Please enter the radious: ") print r3 = r*r*r volume = 4/3*pi*r3 r2 = r*r surface = 4*pi*r2 print "The Volume is", volume, " Cubic centimeters" print print "The Surface area is", surface, " square centimeters" main() *** Error message ************* Traceback (most recent call last): File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 20, in main() File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 13, in main volume = 4/3*pi*r3 NameError: global name 'pi' is not defined From stefan_ml at behnel.de Thu Apr 24 15:55:56 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Thu, 24 Apr 2008 21:55:56 +0200 Subject: convert xhtml back to html In-Reply-To: References: Message-ID: <4810E5CC.2000503@behnel.de> Tim Arnold wrote: > hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop to > create CHM files. That application really hates xhtml, so I need to convert > self-ending tags (e.g.
) to plain html (e.g.
). This should do the job in lxml 2.x: from lxml import etree tree = etree.parse("thefile.xhtml") tree.write("thefile.html", method="html") http://codespeak.net/lxml Stefan From tgiles at gmail.com Wed Apr 16 22:22:00 2008 From: tgiles at gmail.com (tgiles) Date: Wed, 16 Apr 2008 19:22:00 -0700 (PDT) Subject: Python and stale file handles Message-ID: Hi, All! I started back programming Python again after a hiatus of several years and run into a sticky problem that I can't seem to fix, regardless of how hard I try- it it starts with tailing a log file. Basically, I'm trying to tail a log file and send the contents elsewhere in the script (here, I call it processor()). My first iteration below works perfectly fine- as long as the log file itself (logfile.log) keeps getting written to. I have a shell script constantly writes to the logfile.log... If I happen to kill it off and restart it (overwriting the log file with more entries) then the python script will stop sending anything at all out. import time, os def processor(message,address): #do something clever here #Set the filename and open the file filename = 'logfile.log' file = open(filename,'r') #Find the size of the file and move to the end st_results = os.stat(filename) st_size = st_results[6] file.seek(st_size) while 1: where = file.tell() line = file.readline() if not line: time.sleep(1) file.seek(where) else: print line, # already has newline data = line if not data: break else: processor(data,addr) print "Sending message '",data,"'....." someotherstuffhere() === This is perfectly normal behavior since the same thing happens when I do a tail -f on the log file. However, I was hoping to build in a bit of cleverness in the python script- that it would note that there was a change in the log file and could compensate for it. So, I wrote up a new script that opens the file to begin with, attempts to do a quick file measurement of the file (to see if it's suddenly stuck) and then reopen the log file if there's something dodgy going on. However, it's not quite working the way that I really intended it to. It will either start reading the file from the beginning (instead of tailing from the end) or just sit there confuzzled until I kill it off. === import time, os filename = logfile.log def processor(message): # do something clever here def checkfile(filename): file = open(filename,'r') print "checking file, first pass" pass1 = os.stat(filename) pass1_size = pass1[6] time.sleep(5) print "file check, 2nd pass" pass2 = os.stat(filename) pass2_size = pass2[6] if pass1_size == pass2_size: print "reopening file" file.close() file = open(filename,'r') else: print "file is OK" pass while 1: checkfile(filename) where = file.tell() line = file.readline() print "reading file", where if not line: print "sleeping here" time.sleep(5) print "seeking file here" file.seek(where) else: # print line, # already has newline data = line print "readying line" if not data: print "no data, breaking here" break else: print "sending line" processor(data) So, have any thoughts on how to keep a Python script from bugging out after a tailed file has been refreshed? I'd love to hear any thoughts you my have on the matter, even if it's of the 'that's the way things work' variety. Cheers, and thanks in advance for any ideas on how to get around the issue. tom From kayvoo at googlemail.com Sat Apr 19 17:47:33 2008 From: kayvoo at googlemail.com (Karl-Heinz Ruskowski) Date: Sat, 19 Apr 2008 23:47:33 +0200 Subject: manipulating class attributes from a decorator while the class is being defined In-Reply-To: <200804192319.14735.wbsoft@xs4all.nl> References: <200804192319.14735.wbsoft@xs4all.nl> Message-ID: <200804192347.40335.kayvoo@gmail.com> > How can I reach the class attribute `regexps' from within a decorator? Now, the first way that comes to my mind is simply overloading the class and set your regexps variable in your new class. The other way is to create an object and set it more manually (obj.regexps = ['.*']). Which for me is an ugly this to do because the first way is far more elegant :) -- GPG key: 0x04B3BB96 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available URL: From bskaplan14 at yahoo.com Sun Apr 27 09:33:57 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Sun, 27 Apr 2008 06:33:57 -0700 (PDT) Subject: Installed python 2.5 over 2.4 and lost installed packages Message-ID: <133019.97041.qm@web39206.mail.mud.yahoo.com> I don't know what the best practice is, but just creating sym links into site-packages will work, and it saves the extra memory from cp'ing. ----- Original Message ---- From: "james at reggieband.com" To: python-list at python.org Sent: Sunday, April 27, 2008 9:15:06 AM Subject: Installed python 2.5 over 2.4 and lost installed packages Hi all, I recently updated os x from python 2.4 to 2.5 (from python.org) and in doing so I lost my old python path entries. Python 2.4 was installed using fink. Now when I do: import sys print sys.path my old site-packages directory is not within it (the 2.4 one). So what is the right thing to do in this situation? It would be a pain to find and re-install each of the packages. Is it ok to add my old site-packages directory to the sys.path? What is the best way to do so (e.g. using .pth files or PYTHONPATH or other)? Is cp'ing the files from one place to another safe or advisable? Any help on best practices appreciated. James. -- http://mail.python.org/mailman/listinfo/python-list ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From darcy at druid.net Wed Apr 23 10:58:46 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Wed, 23 Apr 2008 10:58:46 -0400 Subject: MESSAGE RESPONSE In-Reply-To: <480F483B.9050507@holdenweb.com> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> <27CC3060AF71DA40A5DC85F7D5B70F38033A4F2D@AWMAIL04.belcan.com> <480F483B.9050507@holdenweb.com> Message-ID: <20080423105846.e163bf1f.darcy@druid.net> On Wed, 23 Apr 2008 10:31:23 -0400 Steve Holden wrote: > Blubaugh, David A. wrote: > > Is there a way to block these messages. I do not want to be caught > > with filth such as this material. I could lose my job with Belcan with > > evil messages such as these messages. > > > In future please ensure you do not quote the offending URLs when sending > out such messages. It's quite bad enough that the things appeared on the > list once without you doing the originator the favor of repeating them. Even worse, some people are blocking Google Groups and never even saw those postings until David reposted them from a non-Google account. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From noagbodjivictor at gmail.com Fri Apr 25 06:28:19 2008 From: noagbodjivictor at gmail.com (noagbodjivictor at gmail.com) Date: Fri, 25 Apr 2008 03:28:19 -0700 (PDT) Subject: Can you recommend a book? Message-ID: Hello all, I learned Python with the book "Programming Python" by John Zelle. But today this book is a little bit old. My Python is some kind old. I need a book that will help me brush my style and keep me up to date. I would like one with practical examples. Can you recommend one? From george.sakkis at gmail.com Fri Apr 18 15:49:25 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 18 Apr 2008 12:49:25 -0700 (PDT) Subject: Python 2.5 adoption References: Message-ID: <1da03626-2d4b-4e01-ba47-93f9d5c8f57f@l64g2000hse.googlegroups.com> On Apr 18, 2:08?pm, Joseph Turian wrote: > How widely adopted is python 2.5? > > We are doing some development, and have a choice to make: > a) Use all the 2.5 features we want. > b) Maintain backwards compatability with 2.4. > > So I guess the question is, does anyone have a sense of what percent > of python users don't have 2.5? Perhaps you should ask the inverse question too: what 2.5 features do you find so compelling that you are willing to break compatibility with 2.4 ? FWIW, the only new 2.5 feature I have been using in practice is the conditional expressions, and I could easily live without them. 2.4 is still pretty decent, and a major upgrade from 2.3. George From kay.schluehr at gmx.net Fri Apr 18 16:17:32 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Fri, 18 Apr 2008 13:17:32 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <14107338-3bf1-45cb-983a-687f46f19503@d45g2000hsc.googlegroups.com> Message-ID: <86338087-cc95-4701-b3c6-83b2b01a16c4@m36g2000hse.googlegroups.com> On 18 Apr., 20:07, Aaron Watters wrote: > I don't really know, but I think "fixing" the above issue for > string.format(...) might involve changing the representation of > every python stack frame... not worth it in this case if there > is any penalty (afaik there isn't). In Python 2.6 the format function simply calls PyDict_GetItem on the dictionary object and raises a KeyError if it fails. A dict emulation would require one more lookup if the fast lookup has no result. It would be a speed penalty in the general case if this lookup would be implemented in PyDict_GetItem but handling a special case in the format implementation might not look that bad. From dennis.benzinger at gmx.net Thu Apr 10 10:29:45 2008 From: dennis.benzinger at gmx.net (Dennis.Benzinger@gmx.net) Date: Thu, 10 Apr 2008 07:29:45 -0700 (PDT) Subject: tkinter, overwrite Label-text? References: Message-ID: On Apr 10, 3:47 pm, skanem... at yahoo.se wrote: > [...] > i use the Label-widget. Then you should be able to connect a variable to your widget like I wrote in my previous post. Just try out the example from the Python documentation. Of course in your case entrythingy would be the Label-widget. Take care to assign values to your variable by using the set function. Dennis Benzinger From dolloffdelvpg at gmail.com Wed Apr 16 08:08:38 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:08:38 -0700 (PDT) Subject: taylor swift bio Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From danb_83 at yahoo.com Sat Apr 26 19:25:47 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Sat, 26 Apr 2008 16:25:47 -0700 (PDT) Subject: How do I say "Is this a function"? References: Message-ID: <96f62c7c-f951-4dc3-9af3-6cdd74cfa23b@v26g2000prm.googlegroups.com> On Apr 26, 6:17 pm, John Henry wrote: > How do I determine is something a function? > > For instance, I don't want to relying on exceptions below: > > def f1(): > print "In f1" > > def f3(): > print "In f3" > > def others(): > print "In others" > > for i in xrange(1,3): > fct = "f%d()"%(i+1) > try: > exec fct > except: > others() > > I wish to say: > > if value of fct is a funtion, invoke it, otherwise invoke others(). > > Thanks, hasattr(fct, '__call__') And be careful about using the exec statement. From JesseAldridge at gmail.com Mon Apr 7 02:22:03 2008 From: JesseAldridge at gmail.com (Jesse Aldridge) Date: Sun, 6 Apr 2008 23:22:03 -0700 (PDT) Subject: Python Data Utils References: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> <8eec6557-784d-4fd8-8478-8da17aedf0ab@d1g2000hsg.googlegroups.com> <85979669-64ed-49a1-b154-595bed50179f@w5g2000prd.googlegroups.com> Message-ID: <204305df-2cc8-4f44-8b98-5696e135a936@d45g2000hsc.googlegroups.com> > Docstrings go *after* the def statement. Fixed. > changing "( " to "(" and " )" to ")". Changed. I attempted to take out everything that could be trivially implemented with the standard library. This has left me with... 4 functions in S.py. 1 one of them is used internally, and the others aren't terribly awesome :\ But I think the ones that remain are at least a bit useful :) > The penny drops :-) yeah, yeah > Not in all places ... look at the ends_with function. BTW, this should > be named something like "fuzzy_ends_with". fixed > fuzzy_match(None, None) should return False. changed > 2. make_fuzzy function: first two statements should read "s = > s.replace(.....)" instead of "s.replace(.....)". fixed > 3. Fuzzy matching functions are specialised to an application; I can't > imagine that anyone would be particularly interested in those that you > provide. I think it's useful in many cases. I use it all the time. It helps guard against annoying input errors. > A basic string normalisation-before-comparison function would > usefully include replacing multiple internal whitespace characters by > a single space. I added this functionality. > 5. Casual inspection of your indentation function gave the impression > that it was stuffed Fixed Thanks for the feedback. From tjreedy at udel.edu Wed Apr 9 17:56:53 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 9 Apr 2008 17:56:53 -0400 Subject: Google App Engine References: <47fc2c7c$0$36365$742ec2ed@news.sonic.net><7e43fcd9-6207-4af2-8256-c0099a8ce0bb@1g2000prf.googlegroups.com> Message-ID: "Duncan Booth" wrote in message news:Xns9A7B6452B3786duncanbooth at 127.0.0.1... | There are several things which would make moving away from Google tricky: I noticed that too, but it does have the virtue that development is done on one's own machine rather than keeping everying on the ISP's machines, like one web-stite 'quick' builder I have seen. From bj_666 at gmx.net Sun Apr 27 03:37:58 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 27 Apr 2008 07:37:58 GMT Subject: diffing and uniqing directories References: Message-ID: <67ioqmF2nvf5vU2@mid.uni-berlin.de> On Sat, 26 Apr 2008 20:35:29 -0700, rustom wrote: > On Apr 27, 12:31?am, castiro... at gmail.com wrote: >> On Apr 26, 1:14?pm, "Rustom Mody" wrote: >> [?] > > If this is an answer to my question I dont understand it! castironpi is either a bot or trolling. Just ignore its posts. Ciao, Marc 'BlackJack' Rintsch From jgardner at jonathangardner.net Mon Apr 14 01:25:09 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Sun, 13 Apr 2008 22:25:09 -0700 (PDT) Subject: urllib working differently when run from crontab References: Message-ID: On Apr 13, 8:50?pm, VictorMiller wrote: > I've written a python script which, using urllib, and urllib2 will > fetch a number of files that that I'm interested in from various > websites (they're updated everyday). ?When I run the script from my > command line everything works as intended. ?However, when the script > is run from crontab every single url that I attempt to open gets > "connection refused". ?Has anyone ever seen anything like this? ?If > so, what's causing it, and what can I do about it? > Try su'ing as the user and running the scripts. Maybe that will shed some light on the problem. From victorsubervi at gmail.com Tue Apr 8 12:55:07 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Tue, 8 Apr 2008 11:55:07 -0500 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> Message-ID: <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> Thanks. I apparently am printing some holder for the image. I stripped out most of it with this content[0][0] but then I am left with this: array('c', '\xff\xd8\xff\xe0\\0\x10JFI...) How do I extract an image from that? TIA, Victor On Tue, Apr 8, 2008 at 11:15 AM, Steve Holden wrote: > Victor Subervi wrote: > > Hi: > > I am able (finally) to upload an image to the database. However, when I > > try to retrieve it, I get a string literal. Here is my code: > > > > #!/usr/local/bin/python > > import cgitb; cgitb.enable() > > import MySQLdb > > def test(): > > host = 'mysqldb2.ehost-services.com < > http://mysqldb2.ehost-services.com>' > > user = 'user' > > passwd = 'pass' > > db = 'bre' > > db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > > cursor= db.cursor() > > cursor.execute('select pic1 from products where id="3";') > > content = cursor.fetchall() > > # print 'Content-Type: image/jpeg\r\nContent-Length: %d\n' % > len(content) > > print 'Content-Type: image/jpeg\r\n' > > print '\n' > > print content > > print '\n' > > cursor.close() > > > > test() > > (Apparently, Plesk doesn?t like if __name__ == '__main__': ) > > The commented out line gives me a leading less than sign...and that?s > > it. What do? > > TIA, > > Victor > > > Your headers indicate you intend to serve a JPEG image, so you should > *not* then include HTML. Take a look at the HTML of a web page with an > image inside it (look for the tag) and you will see that > HTML pages reference images as separate web resources. > > Thus once you have printed out your HTML headers you should them > immediately send the contents of the database column. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zolotoiklo at mail.ru Thu Apr 24 07:02:58 2008 From: zolotoiklo at mail.ru (=?KOI8-R?B?+s/Mz9TPyiDrzM/O?=) Date: Thu, 24 Apr 2008 04:02:58 -0700 (PDT) Subject: =?KOI8-R?B?1MXSzc/CxczYxQ==?= Message-ID: Shop Body - ????????-??????? ??????? ??? ??????? ? ????????. ?? ???? ?????????? ?????? ???????? ?????? ??? ???????? ????? ???????????? ? ??????????? ?????? ??????? ?????????????? ????: ?????, ???????, ???????, ?????????? ??????, ??????? ??? ????????? ? ??????? ?????????, ????????? ? ??????????????, ???????? ???????????? ? ??????????, ?????? ??? ????? ?? ?????? ?????????? http://shopbody.ru/ From noahwatkins at gmail.com Thu Apr 3 17:13:25 2008 From: noahwatkins at gmail.com (noahwatkins) Date: Thu, 3 Apr 2008 14:13:25 -0700 (PDT) Subject: displaying execution of Python code Message-ID: <1afcbf34-0a40-4d11-b12f-603f0ee8f26c@m3g2000hsc.googlegroups.com> I'll start my question by describing my desired result. I will construct a GUI which will be used to open a Python script. I would then like to be able to display the Python script, execute it, and highlight the lines of the Python as they are executing. More technically, I am looking for direction on where to start looking in the Python libraries for a functionality that will allow me to execute arbitrary Python code from within a Python application. Additionally, I need to be able to have the ability to get information and perform actions (e.g. line number currently executing) as the code executes. Thanks, Noah From tinnews at isbd.co.uk Sun Apr 6 06:39:41 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 06 Apr 2008 10:39:41 GMT Subject: mailbox.Maildir(), confusing documentation References: <47f4f4f4$0$715$bed64819@news.gradwell.net> Message-ID: <47f8a86d$0$753$bed64819@news.gradwell.net> Peter Otten <__peter__ at web.de> wrote: > tinnews at isbd.co.uk wrote: > > > Having got my Python 2.5.2 installed I'm trying some things out with > > the mailbox.Maildir() class. > > > > If I do the following:- > > > > import maibox > > mailbox.Maildir("/home/isbd/Mail/Li/pytest") > > > > then the pytest Maildir mailbox is created - which is great but isn't > > documented. If the above creates the maildir then what is the > > mailbox.Maildir.add_folder() method for? I tried > > mailbox.Maildir.add_folder() and it appeared to do nothing, it didn't > > produce any errors either. > > You didn't expect the dot, it seems: > I didn't 'expect' the dot because it's not standard maildir syntax, it's just one particular way of doing it. ... but thanks for pointing out what was going on. :-) > >>> import mailbox > >>> m = mailbox.Maildir("alpha") > >>> m.add_folder("beta") > > >>> > $ find . > . > ./alpha > ./alpha/tmp > ./alpha/cur > ./alpha/new > ./alpha/.beta > ./alpha/.beta/tmp > ./alpha/.beta/cur > ./alpha/.beta/new > ./alpha/.beta/maildirfolder > $ > > Peter -- Chris Green From bearophileHUGS at lycos.com Thu Apr 10 17:11:26 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Thu, 10 Apr 2008 14:11:26 -0700 (PDT) Subject: Graphs in Python References: Message-ID: <384e6ccf-107b-4126-8878-ef75a21ddb23@1g2000prg.googlegroups.com> Sanhita Mallick>where can I find more in depth info about how to express graphs in python, and how to use them in a code?< You can look here: https://networkx.lanl.gov/wiki My version: http://sourceforge.net/projects/pynetwork/ Bye, bearophile From bronger at physik.rwth-aachen.de Wed Apr 30 05:06:52 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 30 Apr 2008 11:06:52 +0200 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> Message-ID: <87y76vyamr.fsf@physik.rwth-aachen.de> Hall?chen! SL writes: > "Gabriel Genellina" schreef in bericht > news:mailman.365.1209541507.12834.python-list at python.org... > >> En Wed, 30 Apr 2008 04:19:22 -0300, SL escribi?: And >> that's a very reasonable place to search; I think chr and ord are >> builtin functions (and not str methods) just by an historical >> accident. (Or is there any other reason? what's wrong with >> "a".ord() or str.from_ordinal(65))? > > yes when you know other OO languages you expect this. Anyone know > why builtins were chosen? Just curious *Maybe* for aesthetical reasons. I find ord(c) more pleasent for the eye. YMMV. The biggest ugliness though is ",".join(). No idea why this should be better than join(list, separator=" "). Besides, ",".join(u"x") yields an unicode object. This is confusing (but will probably go away with Python 3). Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From chita323f at casema.nl Tue Apr 29 04:30:21 2008 From: chita323f at casema.nl (RJ vd Oest) Date: Tue, 29 Apr 2008 10:30:21 +0200 Subject: need help of regular expression genius Message-ID: <001301c8a9d3$4c447e90$c17a5553@vanderOest> -------------- next part -------------- An HTML attachment was scrubbed... URL: From hdante at gmail.com Sat Apr 26 14:48:04 2008 From: hdante at gmail.com (hdante) Date: Sat, 26 Apr 2008 11:48:04 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> Message-ID: <847a2819-9684-4bd9-a445-5fd24f6eb768@e39g2000hsf.googlegroups.com> On Apr 26, 12:10?pm, n00m wrote: > Both codes below read the same huge(~35MB) text file. > In the file > 1000000 lines, the length of each line < 99 chars. > > Stable result: > Python runs ~0.65s > C : ~0.70s > > Any thoughts? > > import time > t=time.time() > f=open('D:\\some.txt','r') > z=f.readlines() > f.close() > print len(z) > print time.time()-t > m=input() > print z[m] > > #include > #include > #include > #include > > using namespace std; > char vs[1002000][99]; > FILE *fp=fopen("D:\\some.txt","r"); > > int main() { > ? ? int i=0; > ? ? while (true) { > ? ? ? ? if (!fgets(vs[i],999,fp)) break; > ? ? ? ? ++i; > ? ? } > ? ? fclose(fp); > ? ? cout << i << endl; > ? ? cout << clock()/CLOCKS_PER_SEC << endl; > > ? ? int m; > ? ? cin >> m; > ? ? cout << vs[m]; > ? ? system("pause"); > return 0; > > } > > First try again with pure C code and compile with a C compiler, not with C++ code and C++ compiler. Then, tweak the code to use more buffering, to make it more similar to readline code, like this (not tested): #include #include char vs[1002000][100]; char buffer[65536]; int main(void) { FILE *fp; int i, m; clock_t begin, end; double t; begin = clock(); fp = fopen("cvspython.txt", "r"); i = 0; setvbuf(fp, buffer, _IOFBF, sizeof(buffer)); while(1) { if(!fgets(vs[i], 100, fp)) break; ++i; } fclose(fp); printf("%d\n", i); end = clock(); t = (double)(end - begin)/CLOCKS_PER_SEC; printf("%g\n", t); scanf("%d", &m); printf("%s\n", vs[m]); getchar(); return 0; } Finally, repeat your statement again, if necessary. From Lie.1296 at gmail.com Sun Apr 20 05:16:40 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 20 Apr 2008 02:16:40 -0700 (PDT) Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> Message-ID: <78426dcc-81b1-478a-8c72-bb1b3700d21c@v23g2000pro.googlegroups.com> On Apr 19, 1:08 am, Joseph Turian wrote: > How widely adopted is python 2.5? > > We are doing some development, and have a choice to make: > a) Use all the 2.5 features we want. > b) Maintain backwards compatability with 2.4. > There is another choice: Develop with future in mind because it's possible that when you finished version 1, what seemed to be future would become the present. This is especially if the project is big and requires years to complete. On Apr 19, 5:13 pm, Graham Breed wrote: > My web host uses 1.5.2. That is painful. If them using 1.5.2 is painful for you ask the host to install something newer (AFAIK it is possible to run several python versions side-by-side) or prepare yourself to move to other host. From darcy at druid.net Tue Apr 22 13:25:07 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Tue, 22 Apr 2008 13:25:07 -0400 Subject: Spawing a thread and printing dots until it finishes In-Reply-To: References: Message-ID: <20080422132507.0be52092.darcy@druid.net> On Tue, 22 Apr 2008 09:32:38 -0700 (PDT) sophie_newbie wrote: > On Apr 22, 4:41 pm, "D'Arcy J.M. Cain" wrote: > > We know that your main routine gives up the processor but without a > > full definition of MyThread how do we know that it ever does? I > > suspect that it hits sleep once, if at all, and then goes to the final > > print statement. In fact, I suspect that this is not exactly what you > > tried anyway. This code would not have printed ".OK" whether it > > entered the loop or not. It could have printed this; > > > > . > > OK > > > > because the print statement in the loop will print a dot on a line by > > itself. > "myLongCommand()... " is a call to an function in R (the statistical > programming language) via Rpy (A python module that allows calls to > R). The call takes a couple of minutes to execute. I'm trying to build > a web front end to this R function and instead of the user looking at > a blank screen for 2-3 mins, I want to print dots to let them feel > like the program isn't hanging. > > What I am saying is that without the "time.sleep(.5)" line, the above > code will print dots on the screen continuously for 2-3 mins, filling > it up with a ridiculous ammount of dots. Does it ever finish? It seems to me that it would loop forever if you never give up the processor. Remember, threads are not processes. > Whereas with the time.sleep line, instead of pausing for half a second > between dots, its seems to print, as you correctly pointed out: > > . > OK > > With a pause of 2-3 minutes between the . and the OK. Exactly. It prints the first dot and then gives up the processor to your other thread. That thread runs for 2 to 3 minutes and then completes giving up the processor. At that point your sleep has slept for at least .5 seconds so the first thread if free to run. It then checks the condition of the loop, sees that it is finished and continues on the the next statement which prints the "OK" and exits. > I hope that clears things up a little. I haven't the faintest idea why > the code above doesn't work but hope someone has an idea. It wouldn't > be something to do with python not being able to handle multiple > threads at the same time or something? I hope there is a workaround. I think that there are two things that you need to wrap your head around before understanding what is happening here. First, threads are NOT pre-emptive. Unless your thread gives up the processor it will run forever. The sleep call is one way to give up the processor. Second, sleep() does not return as soon as the time given has expired. The argument is the MINIMUM amount of time that it waits. After that the thread that slept is put back onto the run queue and is now a candidate to be given the processor. Your other thread still has to give up the processor before it can run again and even then there may be other threads on the queue ahead of yours. So, does your thread ever give up the processor other than by dying? -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From zolotoiklo at mail.ru Sun Apr 6 11:24:43 2008 From: zolotoiklo at mail.ru (=?KOI8-R?B?+s/Mz9TPyiDrzM/O?=) Date: Sun, 6 Apr 2008 08:24:43 -0700 (PDT) Subject: =?KOI8-R?B?wc7UyS3DxczMwMzJ1M7ZxSDCwc7LySAozcHT0w==?= =?KOI8-R?B?wdbO2cUg18HL1dXNztnFIMLBzsvJKQ==?= Message-ID: <4a3e3650-8245-4421-b745-d1d6d8e6d354@a5g2000prg.googlegroups.com> ????????? ???????? ??????? <> ??????????? ??? ??????? ? ???????????? ?????????? ? ?????????????? ???????? , ????? ??? ?????????, ???????, ???????, ???????????? ?????; ?????????, ??????, ?????????, ??????, ??????? , ? ????? ??? ??????? ?????????. <> ?????????? ??? ?????????? ??????-???????, ?? ???? ???????? ?????????? ?????? ????? ? ????? ? ????, ?????????? ?? ???????, ???? ?????????? ?????????? ? ???????. ??? ???????????? ????????????? ???????? ????? <> ???? ????????????? ??????? ????????? ?????? ??? ??????, ????? ?????????? ??????? ??????? ???? ??????? ?? ???????. ???????????? ? ???? ??????? ??? ????????? ???????????? ??????????? ?????????????. ??? ???????? ???????????? ?????? ?????????? ???????? ????? ?? ???????? ????? ? ??????? ????????. ??? ?????? ???????? ?????? ???????? ???????? ?????? ?????? ???????? ???????? (??? ??????? ?????? - ?? ????? ???????????). ??? ???, ????????? ? ????????? ?????? ??????????????? ???????? ?? ???????? ????? ? ??????. ??? ??????????? ??????? ?????? ?????????? ???????, ??????? ???????, ????????? ??????????? ????. ??? ?????????? ?????? ?????? ??????????? ?????? . ??? ????????? ????-??????????? ??????? ???????????? ????????? ???????: ???????? ?????? ???????? ?? ?????????? ???????? ???? ?????????????? ? ????????? ??????????, ??? ???? ??????? ?????? ???????????. ???????? ??????????, ??? ???? ??? ??????? ?????? ??????? ?????? ?????????? ?? ??????????. ????-??????????? ????? http://shopbody.ru/chudo-banka.htm From steve at holdenweb.com Mon Apr 7 10:54:52 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 07 Apr 2008 10:54:52 -0400 Subject: Welcome to the "Python-list" mailing list In-Reply-To: References: Message-ID: Ronn Ross wrote: > This is my first post and I'm new to Python. How would someone go about > adding keywords to Python? It would be great to add support for > Esperanto keywords in the language instead of English being the only > option. > Unfortunately the resulting language would no longer be Python. You need to consider software portability: Python has been very conservative about declaring words to be "keywords" in the language, though clearly words like "def" and "class" must necessarily be part of the syntax. When you start to replace the keywords, though, your programs are no longer runnable on all Python installations, and simple transliteration fails because sometimes a keyword in one (natural) language will conflict with a programmer's choice of name(s) in another. So it's a superficially attractive idea with some really bad downside consequences. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From andre.roberge at gmail.com Tue Apr 8 21:55:11 2008 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Tue, 8 Apr 2008 18:55:11 -0700 (PDT) Subject: text adventure game problem References: <6e247b5c-a58d-4e4e-a67a-c21d36061cf0@z38g2000hsc.googlegroups.com> Message-ID: <20bb5b82-9cf2-4983-b9d0-b50c718a6b85@k10g2000prm.googlegroups.com> On Apr 8, 10:44?pm, corvettecra... at gmail.com wrote: > On Apr 8, 9:25?pm, Andr? wrote: > > > > > On Apr 8, 10:01?pm, corvettecra... at gmail.com wrote: > > > > okay, I'm having this one problem with a text adventure game. It's > > > kind of hard to explain, but I'll do my best. > > > [code] > > > > def prompt_kitchen(): > > > ? ? global gold > > > ? ? gold_taken = False > > > ? ? while True: > > > ? ? ? ? prompt_kit = raw_input('>') > > > ? ? ? ? if prompt_kit == 'examine cabinet 1' and not gold_taken: > > > ? ? ? ? ? ? print '''This cabinet has a lot of cups in it with all > > > different > > > designs and shapes. Where are the people anyway? How come there's > > > nobody here? > > > In one of the cups you find 8 gold.''' > > > ? ? ? ? ? ? gold = gold+8 > > > ? ? ? ? ? ? gold_taken = True > > > ? ? ? ? ? ? pass4() > > > ? ? ? ? elif prompt_kit == 'examine cabinet 1' and gold_taken: > > > ? ? ? ? ? ? print \ > > > ? ? ? ? ? ? ? ? ? '''This cabinet has a lot of cups in it with all > > > different > > > designs and shapes. Where are the people anyway? How come there's > > > nobody here?''' > > > ? ? ? ? ? ? pass4() > > > > def pass4(): > > > ? ? global gold > > > ? ? print 'You have', gold, 'gold' > > > ? ? pass > > > [/code] > > > > Okay, now for my problem. > > > In the above function, there's the option to examine a cabinet and get > > > 8 gold. (everyone here knows that...but I'm just trying to state my > > > problem...) > > > Unfortunately, it kind of doesn't work. > > > After the first time I 'examine cabinet 1' in my game, I get 8 gold > > > and I can't get it again. > > > But, If I leave the room and come back to it, then it's as if I had > > > never gotten the gold the first time, and I can get it again. > > > How do I fix this? > > > quick guess: define gold_taken as a global variable and initialize it > > outside of the function. > > > Warning: avoid global variables if at all possible. > > > ;-) > > Andr? > > Here's a sample code that, in fact, does work. In this code, when run, > I can only get the gold once. > > def prompt_house(): > ? ? global gold > ? ? gold_taken = False > ? ? while True: > ? ? ? ? prompt_hou = raw_input('>') > ? ? ? ? if prompt_hou == 'examine table' and not gold_taken: > ? ? ? ? ? ? print \ > ? ? ? ? ? ? ? ? ? '''There are a lot of car magazines here. > You flip through them and find 5 gold. > ''' > ? ? ? ? ? ? gold = gold+5 > ? ? ? ? ? ? gold_taken = True > ? ? ? ? elif prompt_hou == 'go west': > ? ? ? ? ? ? # this gets you out of the loop The above comment is wrong. > ? ? ? ? ? ? go_west() > ? ? ? ? ? ? # more elif choices here ... > ? ? ? ? elif prompt_hou == 'examine table' and gold_taken: > ? ? ? ? ? ? print '''There are a lot of car magazines here.''' > ? ? ? ? ? ? go_west() > def go_west(): > # just a dummy funk > ? ? global gold > ? ? print gold > ? ? pass The "pass" statement is redundant. > ? ? ? ? ? ? ? ? # test > gold = 0 > prompt_house() > > But what's the difference between this and the one that I posted? It is hard to say as you are not posting the entire code. As I indicated above, you wrote a comment indicating that a given choice was taking you out of the loop - which could only happen through a break statement. You may want to post a ("small") code sample that can be run by itself and reproduces the problem behaviour you observe. The sample you posted include infinite loops with no way to get out, so your original claim that you could leave the room and come back is highly suspicious ;-) Andr? From gagsl-py2 at yahoo.com.ar Sun Apr 20 04:12:01 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 05:12:01 -0300 Subject: Calling Java Class from python References: <608239.30549.qm@web35906.mail.mud.yahoo.com> Message-ID: En Wed, 16 Apr 2008 07:37:55 -0300, Good Z escribi?: > We have developed a website in python and we need to integrate few features of third party website. They have provided us Base64EncoderDecoder Java Class and would like us to use it to encode the data before sending it to their site and decode it when received anything from their site. > > I have no idea/knowledge of Java. Can you please guide me how can i call Java class from Python scripts? Or what is the best way to handle this condition. > > Is Base64 library provided by python is compatible to Base64EncoderDecoder Java Class? If the Java class implements Base64 as defined in RFC 3548, it should be compatible with the Python base64 module. Try with some examples, including the corner cases (empty, one byte, two bytes, three bytes, length = 3n, 3n+1, 3n+2, including bytes outside the ASCII range...) -- Gabriel Genellina From steven.p.clark at gmail.com Tue Apr 8 11:49:39 2008 From: steven.p.clark at gmail.com (Steven Clark) Date: Tue, 8 Apr 2008 11:49:39 -0400 Subject: Data structure recommendation? In-Reply-To: References: <663744510804071339g639bfdccl63de8be66fe52df1@mail.gmail.com> Message-ID: <663744510804080849n32c07461yfc3816771cfb7eca@mail.gmail.com> > bisect is definitely the way to go. You should take care with > floating point precision, though. One way to do this is to choose a > number of digits of precision that you want, and then internally to > your class, multiply the keys by 10**precision and truncate, so that > you are working with ints internal to the Foo class. Thanks for the reply. Can you explain how I could be bitten by floating point precision here? I'm familiar with how&why 1.3*3 != 3.9, etc., but I'm not sure how it applies here, or what you are gaining by converting to int. What do you guys think of this approach which uses tuples: from bisect import insort_right, bisect_right class Heavy(object): def __cmp__(self, other): return 1 heavy = Heavy() class Foo(object): def __init__(self): self.data = [] def __setitem__(self, k, v): #if k's are the same, will be sorted by v's. may or may not be desireable insort_right(self.data, (k, v)) def __getitem__(self, k): i = bisect_right(self.data, (k, heavy)) if i == 0: return None else: return self.data[i-1][1] def main(): foo = Foo() assert(foo[1.5] == None) foo[1.3] = 'a' foo[2.6] = 'b' assert(foo[1.2999] == None) assert(foo[1.3] == 'a') assert(foo[1.5] == 'a') assert(foo[2.6] == 'b') assert(foo[7.8] == 'b') foo[5.0] = 'c' assert(foo[7.8] == 'c') print('Foo checks passed.') if __name__ == '__main__': main() From john00587 at gmail.com Mon Apr 21 01:42:01 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:42:01 -0700 (PDT) Subject: boilsoft rm convertor crack Message-ID: <5e5581ca-7334-4c0a-9ef4-62fd7514542d@r9g2000prd.googlegroups.com> boilsoft rm convertor crack http://cracks.00bp.com F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Sun Apr 20 22:26:52 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 23:26:52 -0300 Subject: question about the mainloop References: <52de38c4-3d1e-4be0-9b58-5d60317f1ef7@b1g2000hsg.googlegroups.com> Message-ID: En Sun, 20 Apr 2008 20:24:04 -0300, globalrev escribi?: > in C?? java etc there is usually: > > procedure 1 > procedure 2 > procedure 3 > > main { > procedure 1 > procedure 2 > procedure 3 > } > > i dont get the mainloop() in python. i mean i have written some > programs, for example a calculator using tkinterGUI. > What you call the "mainloop" is the event loop (or message loop) used by event-driven applications as a way to dispatch all events as they happen in the system. The concept is independent of Python/C++/whatever language you choose. The key phrase is "event-driven programming": http://en.wikipedia.org/wiki/Event_driven_programming Tkinter provides an event-driven GUI framework. Simple CLI programs are not event-driven, as your pseudo example above. > if i have some functions i wanna call to run the program and i wanna > call them ina specific order and be able to call > them from each other should this just be called in the mainloop and > the mianloop then runs the "mainscript" top > to bottom over and over? If you don't want or don't require a graphical user interface, just write the functions you need and call them from the outermost section in your script. If you do require a GUI, you'll have to write the code in response to user actions: when the user clicks here, do this; when the user chooses that menu option, do that. -- Gabriel Genellina From kdoiron at sympatico.ca Tue Apr 8 11:17:46 2008 From: kdoiron at sympatico.ca (Kevin) Date: Tue, 8 Apr 2008 08:17:46 -0700 (PDT) Subject: Problem with smtplib and py2exe References: <3ff2767a-bbd8-4e0e-bbf4-3fa72bdca5e7@8g2000hsu.googlegroups.com> Message-ID: <2f783320-3364-4954-b763-1f4f3fe1f26c@y21g2000hsf.googlegroups.com> Thanks, Terry, you pointed me in the right direction with the reference to the "DEBUG". I dug out my "Learning Python" book, to read up on the debugger, and one of the things I came across was a section on IDLE's debugger. It said essentially that if you get an error that doesn't make sense when you're trying to run another program (in this case, py2exe) with IDLE, then run the program from the command line instead. I did that, and much to my surprise, I was able to generate the 'exe' that I needed. I guess the incompatibility isn't necessarily between 'py2exe' and 'smtplib' after all, but between 'py2exe' and 'IDLE'. From rahul at amplifysystems.com Mon Apr 21 02:29:01 2008 From: rahul at amplifysystems.com (Rahul Ka) Date: Mon, 21 Apr 2008 02:29:01 -0400 Subject: Python Developer, DIRECT CLIENT REQUIREMENT: Please Respond Message-ID: Hi , We have this urgent DIRECT client requirement . Please let me know if you have suitable candidates. Please send me their resume rate and contact details ASAP. TITLE: Python Developer LOCATION: Silver spring, MD DUARTION:6 Months + JOB REQUIREMENTS Strong C++ and Python experience 5 to 7 years of UNIX experience 5 to 7 years of TCP/IP network development experience 3 to 5 years of Oracle DB experience- Good to have Payment industry knowledge a plus With Warm Regards and Wishes ! RAHUL Marketing Executive AMPLIFY SYSTEMS E Mail:rahul at amplifysystems.com Phone :603-791-4428 Fax :267-284-6042 From nagle at animats.com Thu Apr 3 01:35:51 2008 From: nagle at animats.com (John Nagle) Date: Wed, 02 Apr 2008 22:35:51 -0700 Subject: Strange MySQL Problem... In-Reply-To: References: <4dc0cfea0804021236n1faafabav1699fbe45acc3c01@mail.gmail.com> Message-ID: <47f46a3e$0$36371$742ec2ed@news.sonic.net> Gabriel Genellina wrote: > En Wed, 02 Apr 2008 16:36:43 -0300, Victor Subervi > escribi?: > >> I have this code which works fine: > > "works fine"? Please check again... > The same remarks I've posted earlier apply here. In addition, you're not committing the database update. You need to do connection.commit() after updating. In general, server side programs should have a try-block wrapped around most of the program, with some code to display or log errors in some useful way. John Nagle From skanemupp at yahoo.se Thu Apr 10 04:15:19 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 01:15:19 -0700 (PDT) Subject: questions about Exceptions? Message-ID: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> is there a general philosophy as to when to use exceptions and when not to? like here: def Calc(): global nbr try: print eval(nbr) except: print "Not computable" nbr = "" i have a calculator and nbr is a string that contains '0123456789+-*/' if the string ends on +-*/ it will throw an exception(unexpected EOF). i could easily prevent the exceptions here with an if-statement, is that preferrable and why? also when u throw exceptions should u catch the speicfic one? i guess only if u want it to do soemthing special since catching only only one exception logicall would abort the program if another one is thrown? From theiviaxx at gmail.com Thu Apr 24 01:54:15 2008 From: theiviaxx at gmail.com (theiviaxx at gmail.com) Date: Wed, 23 Apr 2008 22:54:15 -0700 (PDT) Subject: python-ldap - Operations Error References: <8b35f293-fc64-4d21-a621-124c8eafde59@c65g2000hsa.googlegroups.com> Message-ID: Thanks for that last link, i'll try that tomorrow :) As for the tgolden modules, i will use that in a pinch, but it means our server has to be a windows box. just trying to keep this as open as possible :) Thanks again From sevenjp at gmail.com Wed Apr 2 11:53:09 2008 From: sevenjp at gmail.com (=?ISO-8859-1?Q?Jo=E3o_Neves?=) Date: Wed, 2 Apr 2008 08:53:09 -0700 (PDT) Subject: wsdl (soap) without code generation References: <65hi7dF2ade57U1@mid.individual.net> Message-ID: <76e1e2cd-d048-4ca5-9f6d-a1638da73b3c@u10g2000prn.googlegroups.com> On Apr 2, 3:06 pm, Thomas Guettler wrote: > Hi, > > I looked for a solution to talk to a web service which > offers its signature with a wsdl file. > > I googled for 'wsdl python' and found ZSI. > > This project uses code generation. That's something > I don't like. > > The book 'dive into python' uses SOAPpy. This looks > better since it does not generate source code. > But the last release and first release is from 2001. > > ZSI seems to have integrated SOAPpy. > > I am new to WSDL and SOAP. Do I need a WSDL parsing > routine at all? I guess my wsdl definition won't change > during the next years. So I could read the wsdl with > my eyes and make a fitting soap call... > > Any thoughts? > > -- > Thomas Guettler,http://www.thomas-guettler.de/ > E-Mail: guettli (*) thomas-guettler + de I've been using SOAPpy directly in one of my projects, and so far my experience couldn't be better. SOAPpy can handle (hand-written) WSDLs well enough for me, and so far it has given me no problems at all. From rpmuller at gmail.com Sat Apr 19 15:55:05 2008 From: rpmuller at gmail.com (Rick Muller) Date: Sat, 19 Apr 2008 12:55:05 -0700 (PDT) Subject: Frame work for simple physics web applications Message-ID: <2b0b8b6c-8086-4bf6-8f47-27bc5c9c788c@v23g2000pro.googlegroups.com> I'd like to use my webserver to distribute some simple python physics apps. Ideally, I'd like to use some simple form to input a few pieces of data, call a python program, and return some image from a plot or some other rendering. This is easy to do using CGI, but I was wondering whether anyone on the list could recommend that would look a little more polished and professional. Let's say I want to input a wave vector k, and then input a plot of sin(k*x). I would like to have a simple form input for k, and then display an image of the plot. What I'm doing is a little more varied than this, but the common thread is that in each application I need to input several pieces of data and then display some image. I can probably think of 20 different applications right off the bat that I'd like to deploy. The idea behind this is to put together some simple toy models for quantum computing qubits that my experimental collaborators can play with without having to install Python, NumPy, and MatPlotLib themselves. (I understand, of course, that such an installation might be "good for them", but I'd rather not fight that battle just now.) I could, of course, write a Jython applet for this, but this would require my re-learning how to use the Java API, and it has been a few years for me. Do any of the AJAX frameworks for Python compare in simplicity to writing a simple CGI script? I've been impressed with web.py, since it seems pretty easy to use, but I would go to the trouble of learning one of the bigger frameworks if they would provide a more elegant solution. My web skillz are obviously several years out of date, so I'd like some guidance on the best way to update them. Thanks in advance, Rick From tjreedy at udel.edu Sun Apr 20 23:54:58 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 20 Apr 2008 23:54:58 -0400 Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> <48a1d10c-87cb-43c3-83f4-9c331fc1d818@m1g2000pre.googlegroups.com> Message-ID: "Dan Bishop" wrote in message news:48a1d10c-87cb-43c3-83f4-9c331fc1d818 at m1g2000pre.googlegroups.com... | We wouldn't even need that. Just a new source encoding. Then we | could write: | | # -*- coding: end-block -*- Ummm.. source encoding refers to how unicode chars/codepoints are represented as bytes. This syntax is copied from emacs and uses standard terms. What would you expect an encoding aware editor to do with something like the above? From kveretennicov at gmail.com Wed Apr 2 13:45:07 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Wed, 2 Apr 2008 20:45:07 +0300 Subject: xlrd and cPickle.dump In-Reply-To: <12375df7-387d-424d-84a8-76beb664ae47@59g2000hsb.googlegroups.com> References: <34e62ddb-477f-4a99-97a5-21a7b148d244@e67g2000hsa.googlegroups.com> <47f22a41@news.mel.dft.com.au> <0d46a213-9f95-43b5-835b-d74d8403626b@c19g2000prf.googlegroups.com> <6acbf9b4-161b-47db-9a91-b2448ee63c34@c26g2000prf.googlegroups.com> <12375df7-387d-424d-84a8-76beb664ae47@59g2000hsb.googlegroups.com> Message-ID: <4660fe300804021045r676ddf8au623b0d1cc2595c20@mail.gmail.com> On Wed, Apr 2, 2008 at 5:23 PM, wrote: > Still no luck: > > Traceback (most recent call last): > File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework > \scriptutils.py", line 310, in RunScript > exec codeObject in __main__.__dict__ > File "C:\text analysis\pickle_test2.py", line 13, in ? > cPickle.dump(Data_sheet, pickle_file, -1) > PicklingError: Can't pickle : attribute lookup > __builtin__.module failed > > My code remains the same, except I added 'wb' and the -1 following > your suggestions: > > import cPickle,xlrd, sys > > print sys.version > print xlrd.__VERSION__ > > data_path = """C:\\test\\test.xls""" > pickle_path = """C:\\test\\pickle.pickle""" > > book = xlrd.open_workbook(data_path) > Data_sheet = book.sheet_by_index(0) > > pickle_file = open(pickle_path, 'wb') > cPickle.dump(Data_sheet, pickle_file, -1) > pickle_file.close() > FWIW, it works here on 2.5.1 without errors or warnings. Ouput is: 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] 0.6.1 ... > My code does this, except sort returns None, which is strange. list.sort() is documented to return None. See sorted(). -- kv -------------- next part -------------- An HTML attachment was scrubbed... URL: From wizzardx at gmail.com Sun Apr 27 14:18:42 2008 From: wizzardx at gmail.com (David) Date: Sun, 27 Apr 2008 20:18:42 +0200 Subject: design choice: multi-threaded / asynchronous wxpython client? In-Reply-To: <6fd9f065-630c-44ec-b8ca-348b0eabb3d7@y18g2000pre.googlegroups.com> References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> <6fd9f065-630c-44ec-b8ca-348b0eabb3d7@y18g2000pre.googlegroups.com> Message-ID: <18c1e6480804271118v129838b9v2d8a4c82b8fca612@mail.gmail.com> > Date is the time of the server response and not last data update. Data > is definitely time of server response to my request and bears no > relation to when the live XML data was updated. I know this for a fact > because right now there is no active race meeting and any data still > available is static and many hours old. I would not feel confident > rejecting incoming data as duplicate based only on same content length > criterion. Am I missing something here? It looks like the data is dynamically generated on the server, so the web server doesn't know if/when the data changed. You will usually see this for static content (images, html files, etc). You could go by the Cache-Control line and only fetch data every 30 seconds, but it's possible for you to miss some updates this way. Another thing you could try (if necessary, this is a bit of an overkill) - download the first part of the XML (GET request with a range header), and check the timestamp you mentinoed. If that changed then re-request the doc (a download resume is risky, the XML might change between your 2 requests). David. From fetchinson at googlemail.com Fri Apr 11 19:53:12 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Fri, 11 Apr 2008 16:53:12 -0700 Subject: matplotlib in fedora 8, png format and easy_instal failure on 64bit machine Message-ID: Hi folks, I have a number of issues with matplotlib and was wondering if any of you had similar experiences: 1. I was trying to use the stock matplotlib package that comes with fedora 8, python-matplotlib-0.90.1-2.fc8 for saving graphs in png format. This failed, because the written files are all empty. The unix 'file' utility reports that the file is actually png but when viewed in any image viewer the image is just plain white. Jpg format works though. 2. I tried grabbing the most recent matplotlib version via easy_install but it failed compiling it and as far as I could see the reason was that it tried to use the 32bit libraries instead of the 64bit ones (my machine is a core 2 duo). Does anyone of you use matplotlib on a 64bit machine for writing png's? Which version do you use? Cheers, Daniel From carlwuhwdmckay at gmail.com Sat Apr 26 09:29:11 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:29:11 -0700 (PDT) Subject: serial numbers crack Message-ID: serial numbers crack http://cracks.00bp.com F R E E C R A C K S From sierra9162 at gmail.com Wed Apr 16 11:26:48 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:26:48 -0700 (PDT) Subject: kate hudson pic Message-ID: <93b74cb1-35d1-4877-9416-8910122df0e0@8g2000hsu.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From zzvladimir at gmail.com Tue Apr 8 05:02:00 2008 From: zzvladimir at gmail.com (Vladimir Kropylev) Date: Tue, 8 Apr 2008 13:02:00 +0400 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. In-Reply-To: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> Message-ID: yes, ths is known problem. I can just recomend you to use Linux or FreeBSD, though cygwin maybe also possible 2008/4/8, subhabrata.iisc at hotmail.com : > I am using Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v. > 1310 32 bit (Intel)] on win32 with IDLE 1.2.1 > My O/S is Windows XP SP2 I use 512 MB RAM. > I am encountering the following problems: > (i) a1=1 > a2=2 > a3=a1+a2 > print a3 > # The result is coming sometimes as 3 sometimes as vague numbers. > > (ii) x1="Bangalore is called the Silicon Valley of India" > x2="NewYork" > x3=x1.find(x2) > print x3 > # The result of x3 is coming as -1 as well as +ve numbers. > > (iii) I have been designing one crawler using "urllib". For crawling > one web page it is perfect. But when I am giving around 100 URLs by > and their links and sublinks the IDLE is not responding. Presently I > have been running with 10 URLs but can't it be ported? > > (iv) I have designed a program with more than 500 if elif else but > sometimes it is running fine sometimes it is giving hugely erroneous > results, one view of the code: > elif a4==3: > print "YOU HAVE NOW ENTERED THREE WORDS" > if a3[0] not in a6: > if a3[1] not in a6: > if a3[2] not in a6: > print "a3[0] not in a6, a3[1] not in a6, a3[2] not > in a6" > elif a3[2] in a6: > print "a3[0] not in a6, a3[1] not in a6, a3[2] in > a6" > else: > print "NONE3.1" > elif a3[1] in a6: > if a3[2] not in a6: > print "a3[0] not in a6, a3[1] in a6, a3[2] not in > a6" > elif a3[2] in a6: > print "a3[0] not in a6,a3[1] in a6, a3[2] in a6" > else: > print "NONE3.2" > else: > print "NONE3.3" > elif a3[0] in a6: > if a3[1] not in a6: > if a3[2] not in a6: > print "a3[0] in a6, a3[1] not in a6, a3[2] not in > a6" > elif a3[2] in a6: > print "a3[0] in a6, a3[1] not in a6, a3[2] in a6" > else: > print "NONE3.4" > elif a3[1] in a6: > if a3[2] not in a6: > print "a3[0] in a6, a3[1] in a6, a3[2] not in a6" > elif a3[2] in a6: > print "a3[0] in a6, a3[1] in a6, a3[2] in a6" > else: > print "NONE3.5" > else: > print "NONE3.6" > else: > print "NONE3.7" > Why it is behaving like that? > If someone can help me. > Best Regards, > Subhabrata Banerjee, > Indian Institute of Science, > Bangalore, > India. > > -- > http://mail.python.org/mailman/listinfo/python-list > From joe.p.cool at googlemail.com Tue Apr 15 18:28:31 2008 From: joe.p.cool at googlemail.com (Joe P. Cool) Date: Tue, 15 Apr 2008 15:28:31 -0700 (PDT) Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> <47ffee86$0$6838$2d805a3e@textnews.eweka.nl> <15e5c81b-0b21-44f0-9282-0d1495bc6bb3@z24g2000prf.googlegroups.com> <480011b7$0$28883$c83e3ef6@nn1-read.tele2.net> Message-ID: On 12 Apr., 03:34, baalbek wrote: > Delphi/Object Pascal simply sucks big time! I disagree. Delphi/Object Pascal with the VCL (Visual Component Library) is one of the most sophisticated IDEs ever, even better than Qt IMO. The only drawback is that it is Windows only. > No real control of your GUI design with Delphi, just a lot of point and > click Wrong. It does have a GUI builder - a very good one - and you can do point and click creation of GUIs (nothing wrong with that) but you can also do pure text editor code only programming with it. >?(did anyone mention waste of one's life?), and don't get me started on that > primitive, complete utter waste of language called Object Pascal! I'm no big Pascal fan either but Object Pascal has a decent string library and better container literals than C/C++ and Java. The language itself is a matter of taste and I don't waste my time discussing it. > Python/wxPython/Glade == real programmer's toolkit > > Object Pascal/Delphi == the hobbyist/beginner's toolkit I'm pretty sure that there are more professional software products written in Delphi than in wxPython. From s0suk3 at gmail.com Thu Apr 17 13:02:55 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 10:02:55 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <1952579a-3cfb-44ea-92aa-658daa64aee4@a70g2000hsh.googlegroups.com> Message-ID: <564dd82b-8670-4ead-a3c8-a22b30a3eb73@m73g2000hsh.googlegroups.com> On Apr 17, 11:46 am, Arnaud Delobelle wrote: > > Why not do something like: > > class RequestHeadersManager: > > def __init__(self, string): > self._fields = {} > # Populate self.fields with fields defined in 'string' > > def __getitem__(self, fieldname): > return self._fields.get(fieldname, None) > > This way you don't need to prebind all possible fields to None, and a > field is accessible by its actual name, which should be easier to > remember than an identifier derived from a field name. Moreover you > can more easily do some group manipulation of fields (e.g. print them > all > > def print_fields(self): > for name, value in self._fields.iteritems(): > print "%s: %s" % (name, value) > ) > I do it with all the separate variables mainly for performance. If I had the headers in a dict, I'd be looking up a string in a list of strings (the keys of the dict) everytime I check for a header. Not that that's going to take more that 0.1 seconds, but the program is still small and simple. As it gets bigger, more features are gonna slow things down. From kyosohma at gmail.com Sun Apr 27 15:42:34 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Sun, 27 Apr 2008 12:42:34 -0700 (PDT) Subject: Installed python 2.5 over 2.4 and lost installed packages References: <6c77d0e5-f387-449d-9147-d7aefa3d2735@l64g2000hse.googlegroups.com> Message-ID: <361ca6be-9764-4cff-bd2e-b5f992d5feb7@8g2000hse.googlegroups.com> On Apr 27, 8:15?am, ja... at reggieband.com wrote: > Hi all, > > I recently updated os x from python 2.4 to 2.5 (from python.org) and > in doing so I lost my old python path entries. Python 2.4 was > installed using fink. ?Now when I do: > > import sys > print sys.path > > my old site-packages directory is not within it (the 2.4 one). > > So what is the right thing to do in this situation? ?It would be a > pain to find and re-install each of the packages. ?Is it ok to add my > old site-packages directory to the sys.path? ?What is the best way to > do so (e.g. using .pth files or PYTHONPATH or other)? ?Is cp'ing the > files from one place to another safe or advisable? > > Any help on best practices appreciated. > > James. As long as the Python extensions or packages are pure ones, then copying them over shouldn't hurt anything. If you have some that have C/C++ links (such as PIL or pywin32), then you'll need to reinstall those manually. Mike From bskaplan14 at yahoo.com Thu Apr 17 13:04:11 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Thu, 17 Apr 2008 10:04:11 -0700 (PDT) Subject: Importing My Own Script Message-ID: <69481.40675.qm@web39203.mail.mud.yahoo.com> It might be something in mod python. Try asking on their mailing list. ----- Original Message ---- From: Victor Subervi To: Ben Kaplan Cc: python-list at python.org Sent: Thursday, April 17, 2008 10:47:34 AM Subject: Re: Importing My Own Script On Thu, Apr 17, 2008 at 8:52 AM, Ben Kaplan wrote: If x and y are in the same directory, just do "import x". If not, add the directory containing x to sys.path. Then, "import x" should work. Well, now that?s what I thought! But no, it doesn?t work! Both scripts are in the same folder. Here?s the error: [Thu Apr 17 07:45:50 2008] [error] [client 190.166.0.245] PythonHandler mod_python.cgihandler: File "/var/www/vhosts/livestocksling.com/httpdocs/bre/test.py", line 3, in ?\n import test2 [Thu Apr 17 07:45:50 2008] [error] [client 190.166.0.245] PythonHandler mod_python.cgihandler: ImportError: No module named test2 I?m running through Plesk, if that makes a difference. TIA, Victor ----- Original Message ---- From: Victor Subervi To: python-list at python.org Sent: Thursday, April 17, 2008 9:45:10 AM Subject: Importing My Own Script Hi: How do I import my own script from a second script? That is, I have script x and I want to import script y. How? TIA, Victor Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From hall.jeff at gmail.com Tue Apr 15 14:19:28 2008 From: hall.jeff at gmail.com (hall.jeff at gmail.com) Date: Tue, 15 Apr 2008 11:19:28 -0700 (PDT) Subject: Preferred method for "Assignment by value" References: <8562becb-9fef-415d-9640-05ef80123596@a5g2000prg.googlegroups.com> Message-ID: <534f02b3-1eda-4332-96ae-3db3d4b4f44a@s33g2000pri.googlegroups.com> I think the fundamental "disconnect" is this issue of mutability and immutability that people talk about (mainly regarding tuples and whether they should be thought of as static lists or not) Coming from VBA I have a tendency to think of everything as an array... So when I create the following test=[1,2],[3,4],[5,6] I'm annoyed to find out that I can change do the following test[1][1] = 3 but i can't do test[1] = [3,3] and so I throw tuples out the window and never use them again... The mental disconnect I had (until now) was that my original tuple was in affect "creating" 3 objects (the lists) within a 4th object (the tuple)... Previously, I'd been thinking of the tuple as one big object (mentally forcing them into the same brain space as multi-dimensional arrays in VBA) This was a nice "aha" moment for me... From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 24 07:15:00 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 24 Apr 2008 13:15:00 +0200 Subject: Python development tools In-Reply-To: <87fxtcnvj7.fsf@physik.rwth-aachen.de> References: <09992de9-39fa-4ee6-8009-35732f3433fb@y21g2000hsf.googlegroups.com> <87fxtcnvj7.fsf@physik.rwth-aachen.de> Message-ID: <48106ba0$0$11087$426a34cc@news.free.fr> Torsten Bronger a ?crit : > Hall?chen! > > bruno.desthuilliers at gmail.com writes: > >> On 23 avr, 19:39, "wongjoek... at yahoo.com" >> wrote: >> >>> Are there any completely free developent tools for python scripts >>> like IDLE. I have used IDLE , but I want to try out others >>> also. I saw stuff like PyCrust, but I don't see that it can run >>> the script as well. >> emacs + python-mode (the one from Python, not the horror that >> ships with recent emacs versions) > > What's so bad about it? I'd have to reinstall it to tell you exactly, but I do remember something really bad wrt/ the embedded python-shell, which is one the very strength of the emacs+python-mode combo. > I just installed python-mode (is this the one with the "py-" > prefixes?), It's the one with ;; Copyright (C) 1992,1993,1994 Tim Peters > and it ends multi-line strings at single quotes. it chokes on unbalanced single quotes in triple-single-quoted strings, and on unbalanced double-quotes in triple-double-quoted strings, yes. Given that I never use triple-single-quoted strings (and don't remember having seen such a thing in the thousands of third-part .py files I've read so far), I'd qualify this as at most a very minor annoyance. Not having proper python-shell and pdb integration is wwwwaaaayyyy more annoying IMHO. From george.sakkis at gmail.com Sun Apr 20 18:59:01 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Sun, 20 Apr 2008 15:59:01 -0700 (PDT) Subject: Nested lists, simple though References: <8788db32-30b4-4cae-ab5a-bf6051249294@a9g2000prl.googlegroups.com> Message-ID: <8f3afcd8-e679-44c3-a1ff-86ccec140979@a1g2000hsb.googlegroups.com> On Apr 20, 6:50?pm, Jason Scheirer wrote: > On Apr 20, 3:25?pm, Zethex wrote: > > > > > Im a bit new to python. ?Anyway working on a little project of mine and i > > have nested lists > > > ie > > > Answer = [['computer', 'radeon', 'nvidia'], ['motherboard', 'asus']] > > > and so forth.., > > Anyway the amount of [[]] do increase over time. ?Im just wondering is there > > a simple way to add these together so they become 1 simple list, so it would > > be ['computer'....'asus'] etc without the nested list. ?Its random the > > amount each time so i cant just go a[0]+a[1]. > > Thank you if you can help > > -- > The first idea that comes to mind is reduce(lambda x, y: x + y, > list_of_lists, []) s/first/worst/ There, I fixed it for you. From nospam at here.com Sun Apr 27 18:10:49 2008 From: nospam at here.com (Dennis) Date: Sun, 27 Apr 2008 23:10:49 +0100 Subject: A small and very basic python question Message-ID: Could anyone tell me how this line of code is working: filter(lambda x: x in string.letters, text) I understand that it's filtering the contents of the variable text and I know that lambda is a kind of embedded function. What I'd like to know is how it would be written if it was a normal function. From paulgeeleher at gmail.com Tue Apr 1 11:13:26 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Tue, 1 Apr 2008 08:13:26 -0700 (PDT) Subject: Copy Stdout to string References: Message-ID: <67533661-fe7b-407b-a406-040eddb417cb@e10g2000prf.googlegroups.com> On Apr 1, 3:03 pm, sophie_newbie wrote: > Hi, I'm wondering if its possible to copy all of stdout's output to a > string, while still being able to print on screen. I know you can > capture stdout, but I still need the output to appear on the screen > also... > > Thanks! I found this, it pretty much does the job, easily modified to write to a variable instead of a file: http://www.answermysearches.com/python-how-to-print-to-screen-and-a-file-at-the-same-time/52/ From http Tue Apr 1 12:17:51 2008 From: http (Paul Rubin) Date: 01 Apr 2008 09:17:51 -0700 Subject: Homework help References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> Message-ID: <7xfxu5ft1s.fsf@ruckus.brouhaha.com> bobby.connor at gmail.com writes: > I don't necessarily want the answers, but need help on how to approach > it/the steps i need to solve the problems What parts are you having difficulty with? Are there some course materials and have you read them yet? From sam at mas.pl Wed Apr 2 11:54:59 2008 From: sam at mas.pl (sam) Date: Wed, 02 Apr 2008 17:54:59 +0200 Subject: wsdl (soap) without code generation In-Reply-To: <65hi7dF2ade57U1@mid.individual.net> References: <65hi7dF2ade57U1@mid.individual.net> Message-ID: Thomas Guettler napisa?(a): > I googled for 'wsdl python' and found ZSI. This is current solution, but it is quite new and actively developed, so newer versions are sometimes not compatibile with old ones. So if you use distribution provided packages (eg Debian) you can have troubles after system upgrade and regenerating stub. > This project uses code generation. That's something > I don't like. But after you have generated files it is easy to use that tool -- just call a function and grab result. With ZSI you don't have to generate code, but you will have to do more coding to invoke a call. > I am new to WSDL and SOAP. Do I need a WSDL parsing > routine at all? I guess my wsdl definition won't change > during the next years. So I could read the wsdl with > my eyes and make a fitting soap call... No -- you don't have to read WSDL at all! Just make somebody else do it for you. SOAP is just about sending and receiving text, but you have to keep that properely formated. You don't have to use automation of WSDL and XML parsing. For example visit: http://soapclient.com/soaptest.html put your wsdl file address, click Retrieve. Then fill forms and see what is response and reply -- they will be your templates. Then write simple Python programs with socks sending and receiving templates on http (or https) port. If you gave me your wsdl file address I could probably give more precise help. Here goes example: http://www.ibm.com/developerworks/library/ws-pyth5/#code3 From michael at stroeder.com Fri Apr 4 06:03:27 2008 From: michael at stroeder.com (=?ISO-8859-15?Q?Michael_Str=F6der?=) Date: Fri, 04 Apr 2008 12:03:27 +0200 Subject: object-relational mappers In-Reply-To: References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> Message-ID: M.-A. Lemburg wrote: > On 2008-04-01 22:40, Aaron Watters wrote: >> I've been poking around the world of object-relational >> mappers and it inspired me to coin a corellary to the >> the famous quote on regular expressions: >> >> "You have objects and a database: that's 2 problems. >> So: get an object-relational mapper: >> now you have 2**3 problems." >> >> That is to say I feel that they all make me learn >> so much about the internals and features of the >> O-R mapper itself that I would be better off rolling >> my own queries on an as-needed basis without >> wasting so many brain cells. >> >> comments? > > I fully agree :-) BTW: Some people implemented O/R mappers above python-ldap. All implementations I saw up to now are falling short regarding the complexity of the LDAP attribute sub-types, the syntactical rules for attribute type descriptive names and attribute name aliasing. So first a developer has also to evaluate whether a O/R mapper is really complete before using it. Ciao, Michael. From deets at nospam.web.de Thu Apr 10 09:47:28 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 10 Apr 2008 15:47:28 +0200 Subject: Code-convention checker and possibly reformatter Message-ID: <666k4cF2iltl5U1@mid.uni-berlin.de> Hi, my new company requires me to adhere to some coding conventions - order of imports, amount of whitespace between method definitions and such stuff. Because I'm a lazy a**, I'd like to have some automatic checker that will ensure that I'm following the conventions. Now I know & use pylint - but the docs are sparse, and so I wonder if and how one writes plugins for it. Of course I also dabbled with tokenize and compiler - but those two either are to lowlevel or already to abstract (the former forces me to re-create trees on my own, the latter throws away to much data, e.g. comments and whitespace) So - any suggestions how to proceed? Diez From deets at nospam.web.de Tue Apr 29 18:40:05 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 30 Apr 2008 00:40:05 +0200 Subject: timeout In-Reply-To: <1a9b19bf-5075-4bce-812d-5516d3a4e454@b9g2000prh.googlegroups.com> References: <1a9b19bf-5075-4bce-812d-5516d3a4e454@b9g2000prh.googlegroups.com> Message-ID: <67pme5F2p5fhgU2@mid.uni-berlin.de> maehhheeyy schrieb: > Hi, > > I was just wondering if there was such thing as a timeout module. time.sleep? Diez From victorsubervi at gmail.com Tue Apr 29 08:57:37 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Tue, 29 Apr 2008 07:57:37 -0500 Subject: Goodbying Spaces In-Reply-To: <200804251729.29976.kyrie@uh.cu> References: <4dc0cfea0804251401p3ab96fddy99452f5a3255acde@mail.gmail.com> <200804251729.29976.kyrie@uh.cu> Message-ID: <4dc0cfea0804290557j127de13frbca4c81a2447c669@mail.gmail.com> On Fri, Apr 25, 2008 at 4:29 PM, Luis Zarrabeitia wrote: > > Whats the result of using id.strip()?: > > In [1]: " asdfasdf ".strip() > Out[1]: 'asdfasdf' > > It should work, I guess... It didn?t for some reason. That was the first thing I tried. > > > Btw, you can write your code without using len in a cleaner way: > > try: > if id[0] == ' ': > id = id[1:] # Note this slice notation... > except: > pass > > try: > if id[-1] == ' ': # id[-1] would be the last character > id = id[:-1] # Again, a slice with only one argument > except: > pass Oh, yeah. Forgot about that. Thanks! Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From dotancohen at gmail.com Sat Apr 5 11:58:51 2008 From: dotancohen at gmail.com (Dotan Cohen) Date: Sat, 5 Apr 2008 18:58:51 +0300 Subject: Learning curve for new database program with Python? In-Reply-To: References: Message-ID: <880dece00804050858l34c67f2ds58773cb7fd2e0cca@mail.gmail.com> On 05/04/2008, Jetus wrote: > I have a need for a database program. I downloaded the db2 from ibm, > and reviewed some of the documentation. > > My question is, what is the easiest program for me to try to learn. I > will be creating a database of about 25,000 records, it will be > relational. I am a beginner Python programmer, and need a database > solution that is easy to grasp. I played with sql, > and found that very difficult, if not overly cumbersome. > > A database that could work with Django would be very interesting to > look at as well.. > > Any suggestions out there? > I haven't used _any_ database with Python, but for PHP I found sqlite to be very easy to work with. Take a look at it. Dotan Cohen http://what-is-what.com http://gibberish.co.il ?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? From spamgrinder.trylater at gmail.com Thu Apr 17 10:52:15 2008 From: spamgrinder.trylater at gmail.com (AlFire) Date: Thu, 17 Apr 2008 09:52:15 -0500 Subject: why objects of old style classes are instances of 'object' Message-ID: <4807641F.8030209@gmail.com> Hi, Q: from the subject, why objects of old style classes are instances of 'object'? >>> class a():pass >>> A=a() >>> isinstance(A,object) True I would expect False Thx, Andy From victorsubervi at gmail.com Wed Apr 30 12:02:10 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 30 Apr 2008 11:02:10 -0500 Subject: Custom Classes? Message-ID: <4dc0cfea0804300902o7493dab2m35999b5b59deace4@mail.gmail.com> Hi; I have the following code which produces a file every time I need to display an image from MySQL. What garbage! Surely, python is capable of better than this, but the last time I asked for help on it, I got no responses. Is this only possible with custom classes? Please, give me some guidance here! try: w += 1 getpic = "getpic" + str(w) + ".py" try: os.remove(getpic) except: pass code = """ #!/usr/local/bin/python import cgitb; cgitb.enable() import MySQLdb import cgi import sys,os sys.path.append(os.getcwd()) from login import login user, passwd, db, host = login() form = cgi.FieldStorage() picid = int(form["id"].value) x = int(form["x"].value) pics = {1:'pic1',2:'pic1_thumb',3:'pic2',4:'pic2_thumb',5:'pic3',6:'pic3_thumb',7:'pic4',8:'pic4_thumb',\ 9:'pic5',10:'pic5_thumb',11:'pic6',12:'pic6_thumb'} pic = pics[x] print 'Content-Type: text/html' db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor= db.cursor() sql = "select " + pic + " from products where id='" + str(picid) + "';" cursor.execute(sql) content = cursor.fetchall()[0][0].tostring() cursor.close() print 'Content-Type: image/jpeg' print print content """ script = open(getpic, "w") script.write(code) print '' % pic print '

\n' % (getpic, d, y) TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From ptmcg at austin.rr.com Thu Apr 10 11:21:05 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Thu, 10 Apr 2008 08:21:05 -0700 (PDT) Subject: Stripping scripts from HTML with regular expressions References: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: <15ae3307-3019-4faa-9cb4-c2248a5eaeba@l64g2000hse.googlegroups.com> On Apr 9, 2:38?pm, Michel Bouwmans wrote: > Hey everyone, > > I'm trying to strip all script-blocks from a HTML-file using regex. > > I tried the following in Python: > > testfile = open('testfile') > testhtml = testfile.read() > regex = re.compile(']*>(.*?)', re.DOTALL) > result = regex.sub('', blaat) > print result > > This strips far more away then just the script-blocks. Am I missing > something from the regex-implementation from Python or am I doing something > else wrong? > > greetz > MFB This pyparsing-based HTML stripper (http://pyparsing.wikispaces.com/ space/showimage/htmlStripper.py) strips *all* HTML tags, scripts, and comments. To pare down to just stripping scripts, just change this line: firstPass = (htmlComment | scriptBody | commonHTMLEntity | anyTag | anyClose ).transformString(targetHTML) to: firstPass = scriptBody.transformString(targetHTML) -- Paul From gagsl-py2 at yahoo.com.ar Tue Apr 8 00:53:44 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 08 Apr 2008 01:53:44 -0300 Subject: ImportError: No module named MySQLdb References: <12b075a10804072035j42c85d4m3e4b45778d9697c4@mail.gmail.com> Message-ID: En Tue, 08 Apr 2008 00:35:29 -0300, syed mehdi escribi?: > I have been working in python from some time now, > while writing a python script i used: import MySQLdb in my script to do > some > database related operations. > When i tried to execute the same script on another system it gave me an > error as: > "ImportError: No module named MySQLdb" > though mysqldb was already installed on that system, and python 2.5.2 was > present on that machine. > i have tried uninstalling and installing of mysql again and again but to > no > avail. MySQL (the database engine) is not the same as MySQLdb (the Python package). You have to download and install it: http://mysql-python.sourceforge.net/ -- Gabriel Genellina From skanemupp at yahoo.se Sat Apr 19 19:54:29 2008 From: skanemupp at yahoo.se (globalrev) Date: Sat, 19 Apr 2008 16:54:29 -0700 (PDT) Subject: Bigger projects, including files? Message-ID: if i have a larger project and want to divide my program into several files, how do i include these files in the mainprogram? using import someprojectfile doesnt work because import is for site- packages right and i dont want to put all my files in that folder. so how do i do it? From skanemupp at yahoo.se Sat Apr 19 15:43:21 2008 From: skanemupp at yahoo.se (globalrev) Date: Sat, 19 Apr 2008 12:43:21 -0700 (PDT) Subject: Tkinter, getting canvas-object, how? References: <4d5c6911-7728-4dad-8d8d-7a862bf78d70@k13g2000hse.googlegroups.com> <4814820b-a3d2-44c1-9db4-0069463f079f@a23g2000hsc.googlegroups.com> Message-ID: <91ec0a69-767c-406b-8a41-44f8989e8eba@e39g2000hsf.googlegroups.com> On 19 Apr, 10:15, Rafa? Wysocki wrote: > skanem... at yahoo.se napisa?(a): > > > > > so i load a gif onto a canvas and when i click the canvs i want to get > > the color of the pixel that is clicked. > > so i need to ge the object im clicking. > > i was told in another thread to use find_withtag or find_closest but > > it is not working, maybe im using the > > method on the wrong object. > > how do i do this? > > and how do i then get specifics about that object, ie the pixel-color? > > > Exception in Tkinter callback > > Traceback (most recent call last): > > File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ > > return self.func(*args) > > File "C:\Users\saftarn\Desktop\pythonkod\mapexperiments > > \mapgetobject.py", line 17, in callback > > undermouse=find_closest(master.CURRENT) > > NameError: global name 'find_closest' is not defined > > > from Tkinter import * > > > master = Tk() > > > w = Canvas(master, width=400, height=625) > > w.pack(expand = YES, fill = BOTH) > > > mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\Maps\provinces-of- > > sweden.gif') > > w.create_image(30, 30, image = mapq, anchor = NW) > > > def key(event): > > print "pressed", repr(event.char) > > > def callback(event): > > clobj=event.widget > > ## undermouse=find_withtag(master.CURRENT) > > undermouse=find_closest(master.CURRENT) > > print repr(undermouse) > > > w.bind("", key) > > w.bind("", callback) > > w.pack() > > > mainloop() > > from Tkinter import * > > master = Tk() > > w = Canvas(master, width=400, height=625) > w.pack(expand = YES, fill = BOTH) > > mapq = PhotoImage(file = 'img.gif') > _id = w.create_image(0, 0, image = mapq, anchor = NW) > > objects = {} # map id to object > objects[_id] = mapq > > def key(event): > print "pressed", repr(event.char) > > def callback(event): > x, y = w.canvasx(event.x), w.canvasy(event.y) # Translates a > window x,y coordinates to a canvas coordinate > _id = w.find_closest(x,y)[0] # Returns tuple containing the object > id > obj = objects[_id] # Finds object with given id > print 'color: %s' % obj.get(int(x), int(y)) > > w.bind("", key) > w.bind("", callback) > w.pack() > > mainloop() ty very much. however i dont get the %s really. is % a symbol and then replaced by obj.get-values? anyway when clicked i get 3values, but there is intx and inty only. where does the 3rd value come from and how do i refer to it? From steve at holdenweb.com Sat Apr 19 04:25:01 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 19 Apr 2008 04:25:01 -0400 Subject: python setup.py install on Vista? In-Reply-To: References: Message-ID: Patrick Mullen wrote: > On Fri, Apr 18, 2008 at 4:29 PM, globalrev wrote: >> type "python setup.py install" >> >> that is used in most "addons" for python. >> >> well using windows vista, where the h*** am i supposed to type this? >> >> if it is not doable in windows, what do i have to do instead? just >> clicking the setup.py-file never works. >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > There are many problems with this on Vista. First, you need a command > prompt. You can go to "start menu->all programs->accessories->command > prompt" for this. But to install things in vista, you will likely > need to be an administrator, and windows won't automatically ask for > permission when typing "python setup.py install." So instead of > clicking on command prompt, right click it, and choose "run as > administrator". A faster way is to type "cmd" in the start menu > search area, and wait for "cmd.exe" to come up. Run that as > administrator. A quicker way to get an adminstrator command tool is to bring up the run dialog with Windows-R, enter "cmd" then hit CTRL/SHIFT/Enter. > > Once you have a command prompt, you can "cd" into the directory where > you want to install the extension. Then, "c:\python25\python setup.py > install" should work. If you are using 2.4 or 3.0, it would be > "c:\python24\python" or "c:\python30\python" etc. If you installed > python somewhere other than the default folder, then you will need to > enter that path. > > To make this process easier, when I want to install an extension, I > usually create a .bat file in the extension folder. Right click in > the folder and choose new->text file. Rename the file to > "install.bat". Right click the file and go to edit. Enter > "c:\python25\python setup.py install" into the file and save. Then > right click and choose run as administrator, and it should install. > You might add a "pause" line in the bat file as well, so that if it > has a problem installing, it will stay open so you can see the output. > > Your best solution is to uninstall vista and use linux :) You're right, Vista's a pain. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From tjreedy at udel.edu Mon Apr 7 22:28:00 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 7 Apr 2008 22:28:00 -0400 Subject: A funnily inconsistent behavior of int and float References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com><1d11875a-470a-489f-910a-b420a145eb61@a1g2000hsb.googlegroups.com><11b4793c-04cc-4898-99a8-8418d237de3e@2g2000hsn.googlegroups.com><1255ee3e-cc1e-4ae8-96f3-5f942c389c49@t54g2000hsg.googlegroups.com> Message-ID: "Mark Dickinson" wrote in message | Excellent! | It looks to me as though this covers everything. I'm tempted to | quibble about exact wordings, but probably the most productive thing to do | would be just to submit this to bugs.python.org and then let Georg Brandl | work his magic on it. :-) http://bugs.python.org/issue2580 tjr From musiccomposition at gmail.com Tue Apr 22 22:45:03 2008 From: musiccomposition at gmail.com (Benjamin) Date: Tue, 22 Apr 2008 19:45:03 -0700 (PDT) Subject: Explicit variable declaration References: Message-ID: <1506f165-7f86-4dc7-aa29-6488eda9ae7f@l64g2000hse.googlegroups.com> On Apr 22, 7:39 pm, "Filip Gruszczy?ski" wrote: > Hello everyone! > > It is my first message on this list, therefore I would like to say > hello to everyone. I am fourth year student of CS on the Univeristy of > Warsaw and recently I have become very interested in dynamically typed > languages, especially Python. > > I would like to ask, whether there is any way of explicitly declaring > variables used in a function? While I am pretty sure, that there is no > such way in the language itself, I would like to know, whether there > are any third-party tools to do that. This would be very useful for me > during development, so I am looking for such a tool. You mean the type? Not in 2.x, but in 3.x, there are function annotations: def a_function(arg1: int, arg2: str) -> None: pass > > -- > Filip Gruszczy?ski From bj_666 at gmx.net Wed Apr 9 15:16:41 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 9 Apr 2008 19:16:41 GMT Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> <6641eaF2ics8jU1@mid.uni-berlin.de> Message-ID: <664j0pF2iji99U2@mid.uni-berlin.de> On Wed, 09 Apr 2008 16:16:14 +0200, Diez B. Roggisch wrote: > And then you reply telling us about the greatness of Bangalore and your > product to come. Which is somewhat amusing that people who claim to produce > the greatest software being incapable of debugging it deems me as odd - to > say the least. That's not odd, that's perfectly normal for really clever code: Debugging is twice as hard as writing the code in the first place.Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan ;-) Ciao, Marc 'BlackJack' Rintsch From aaron.watters at gmail.com Fri Apr 18 10:16:35 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Fri, 18 Apr 2008 07:16:35 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: On Apr 17, 12:27 pm, Michael Torrie wrote: > What's the big deal? The big deal is that I would love to see Django become the standard platform for web development, for example. That will be much less likely if 60% of the contributed tools for Django don't work for Python 3000 and 20% don't work for Python 2.6. Expecting volunteer contributors to support both is not realistic. It's hard enough to support one adequately. Even if you could hope to support both with the same code, just testing in both environments would be onerous. It would be another matter entirely if py3k offered major new functionality like full stackless microthreads but it doesn't (afaik -- correct me please). >From my perspective it's just a pain in the @$$. By the way, full stackless microthreads don't seem to require breaking most (or any) existing code. I really like developing in Python -- but it's hard to keep doing it when the growth curve is so slow and a so many people have deep reservations about it, inspired in part, justifiably, by nonsense like this. In fact, I basically stopped. Then I came back. Now I'm wondering if it was such a good idea... -- Aaron Watters ==== http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=stupid+bug From fetchinson at googlemail.com Tue Apr 15 23:26:19 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Tue, 15 Apr 2008 20:26:19 -0700 Subject: Interesting timing issue I noticed In-Reply-To: References: Message-ID: > Can I then simply ignore the time data then? I do see better performance > obviously the smaller the box is, but I guess my issues is how seriously to > take all this data. Because I can't claim "performance improvement" if there > isn't really much of an improvement. > > On Tue, Apr 15, 2008 at 11:04 PM, Daniel Fetchinson < > fetchinson at googlemail.com> wrote: > > > > I've written up a stripped down version of the code. I apologize for > > the bad > > > coding; I am in a bit of a hurry. > > > > > > import random > > > import sys > > > import time > > > > > > sizeX = 320 > > > sizeY = 240 > > > borderX = 20 > > > borderY = 20 > > > > > > # generates a zero matrix > > > def generate_zero(): > > > matrix = [[0 for y in range(sizeY)] for x in range(sizeX)] > > > return matrix > > > # fills zero matrix > > > def fill_matrix(in_mat): > > > mat = in_mat > > > for x in range(sizeX): > > > for y in range(sizeY): > > > mat[x][y] = random.randint(1, 100) > > > return mat > > > ###################################################################### > > > # COMPUTES ONLY A PART OF THE ARRAY > > > def back_diff_one(back_array, fore_array, box): > > > diff_array = generate_zero() > > > > > > start = time.time() > > > for x in range(sizeX): > > > for y in range(borderY): > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > for y in range((sizeY - borderY), sizeY): > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > for y in range(borderY, (sizeY - borderY)): > > > for x in range(borderX): > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > for x in range((sizeX - borderX), sizeX): > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > > > > # tracks object > > > if (len(box) != 0): > > > for x in range(box[0], box[2]): > > > for y in range(box[1], box[3]): > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > print "time one inside = " + str(time.time() - start) > > > return diff_array > > > ###################################################################### > > > # COMPUTES EVERY ELEMENT IN THE ARRAY > > > def back_diff_two(back_array, fore_array): > > > diff_array = generate_zero() > > > start = time.time() > > > for y in range(sizeY): > > > for x in range(sizeX): > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > end = time.time() > > > print "time two inside = " + str(end - start) > > > return diff_array > > > ###################################################################### > > > # CODE TO TEST BOTH FUNCTIONS > > > back = fill_matrix(generate_zero()) > > > fore = fill_matrix(generate_zero()) > > > box = [20, 20, 268, 240] > > > start1 = time.time() > > > diff1 = back_diff_one(back, fore, box) > > > print "time one outside = " + str(time.time() - start1) > > > start2 = time.time() > > > diff2 = back_diff_two(back, fore) > > > print "time one outside = " + str(time.time() - start2) > > > > > > Here are some results from several test runs: > > > > > > time one inside = 0.0780000686646 > > > time one outside = 0.125 > > > time two inside = 0.0780000686646 > > > time two outside = 0.141000032425 > > > >>> ================================ RESTART > > > ================================ > > > >>> > > > time one inside = 0.0629999637604 > > > time one outside = 0.125 > > > time two inside = 0.0789999961853 > > > time two outside = 0.125 > > > >>> ================================ RESTART > > > ================================ > > > >>> > > > time one inside = 0.0620000362396 > > > time one outside = 0.139999866486 > > > time two inside = 0.0780000686646 > > > time two outside = 0.125 > > > >>> ================================ RESTART > > > ================================ > > > >>> > > > time one inside = 0.0780000686646 > > > time one outside = 0.172000169754 > > > time two inside = 0.0789999961853 > > > time two outside = 0.125 > > > >>> ================================ RESTART > > > ================================ > > > >>> > > > time one inside = 0.0780000686646 > > > time one outside = 0.125 > > > time two inside = 0.0780000686646 > > > time two outside = 0.125 > > > >>> ================================ RESTART > > > ================================ > > > >>> > > > time one inside = 0.0620000362396 > > > time one outside = 0.155999898911 > > > time two inside = 0.0780000686646 > > > time two outside = 0.125 > > > >>> ================================ RESTART > > > ================================ > > > >>> > > > time one inside = 0.077999830246 > > > time one outside = 0.125 > > > time two inside = 0.077999830246 > > > time two outside = 0.125 > > > >>> ================================ RESTART > > > ================================ > > > >>> > > > time one inside = 0.0780000686646 > > > time one outside = 0.171000003815 > > > time two inside = 0.077999830246 > > > time two outside = 0.125 > > > >>> ================================ RESTART > > > ================================ > > > >>> > > > time one inside = 0.0629999637604 > > > time one outside = 0.18799996376 > > > time two inside = 0.0620000362396 > > > time two outside = 0.125 > > > > > > Why is a large percentage of the time, the execution time for the > > > (ostensibly smaller) first loop is actually equal to or LARGER than the > > > second? > > > > > > First of all, your method of timing is not the best. Use the timeit > > module instead: http://docs.python.org/lib/module-timeit.html > > > > Second of all the number of subtractions is not that different between > > the two variants of your functions. back_diff_one does 75360 > > subtractions per call while back_diff_two does 76800, these two > > numbers are almost the same. It's true that back_diff_one first only > > calculates a part of the arrays but after "# tracks object" you do a > > bunch of more substractions that will make up the total count. > > > > HTH, > > Daniel > > Please keep the discussion on the list. Yes, if I were you I would discard your original timing data and redo it using the timeit module. Whatever that gives should be reliable and you can start from there. In any case your two functions are doing roughly the same number of operations. HTH, Daniel From tjreedy at udel.edu Wed Apr 30 16:28:51 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 30 Apr 2008 16:28:51 -0400 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> <87tzhjy4u2.fsf@physik.rwth-aachen.de> <1TYRj.27306$o06.18162@tornado.fastwebnet.it> Message-ID: "Marco Mariani" wrote in message news:1TYRj.27306$o06.18162 at tornado.fastwebnet.it... | Torsten Bronger wrote: | | > However, join() is really bizarre. The list rather than the | > separator should be the leading actor. | | No, because join must work with _any sequence_, and there is no | "sequence" type to put the join method on. More generally, it works with any iterable, including dicts... From chris at subtlety.com Sun Apr 6 15:56:43 2008 From: chris at subtlety.com (Chris Bergstresser) Date: Sun, 6 Apr 2008 14:56:43 -0500 Subject: Odd PyQt4 crash on exit when importing on windows Message-ID: <7b0045ed0804061256y57c80619jb81b04e1de709e37@mail.gmail.com> Hi all -- I'm having an odd import issue with PyQt4. If I create two files, like so .... --- xbomb.py --------------- from PyQt4.QtGui import * import sys, ybomb app = QApplication(sys.argv) if __name__ == "__main__": main_win = QMainWindow() main_win.show() sys.exit(qApp.exec_()) --- ybomb.py ---------------- import xbomb ------------------------------------ ... as you can see, the *only* thing ybomb.py does is import the original file. I can run xbomb just fine. However, when I close the dialog it displays, I get a "python.exe has encountered a problem and needs to close. We are sorry for the inconvenience." crash on Windows XP. Obviously, removing either of the import statements fixes the problem. I think I can disentangle my real code so the files don't import each other, but what's going on? Are other people seeing the same behavior? -- Chris From benash at gmail.com Thu Apr 3 00:59:07 2008 From: benash at gmail.com (Benjamin) Date: Wed, 2 Apr 2008 21:59:07 -0700 (PDT) Subject: Parsing HTML? Message-ID: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> I'm trying to parse an HTML file. I want to retrieve all of the text inside a certain tag that I find with XPath. The DOM seems to make this available with the innerHTML element, but I haven't found a way to do it in Python. From olivier.parisy at neuf.REMOVE.fr Sun Apr 27 18:05:06 2008 From: olivier.parisy at neuf.REMOVE.fr (Olivier Parisy) Date: Mon, 28 Apr 2008 00:05:06 +0200 Subject: python and web programming, easy way...? References: <2db36ccf-c9fd-4e7a-9697-fd5c23159287@j22g2000hsf.googlegroups.com> <75679853-b5de-42cb-9db2-a1508f2ad67e@59g2000hsb.googlegroups.com> Message-ID: David a ?crit : > Also, I can't find any reference to cookies or sessions in the webpy > online docs. Maybe it's possible to bolt on support with Python's > Cookie module. The web.py cookbook describes how to use sessions and cookies: http://webpy.org/cookbook Regards, Olivier. From john106henry at hotmail.com Tue Apr 29 12:17:01 2008 From: john106henry at hotmail.com (John Henry) Date: Tue, 29 Apr 2008 09:17:01 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <473deef3-9acb-45dd-a7ca-47b0081bd28c@i36g2000prf.googlegroups.com> <3f7bb91e-335e-46bd-88ca-f15b26c35132@k1g2000prb.googlegroups.com> <827bdae6-4422-4226-a543-af53f5b7e01b@s33g2000pri.googlegroups.com> Message-ID: <083b58e8-522a-4c01-b612-c592fe69fcd1@i36g2000prf.googlegroups.com> On Apr 29, 8:28 am, Panyasan wrote: > > Christian, > > > It appears you're missing a file. Where did you placed my program? I > > see that there are two places being mentioned: > > > > no resource file for /Users/bibliograph/Programme/PythonCard/tools/ > > > layoutEditor/multipropertyEditor > > > and > > > > File "/Library/Python/2.5/site-packages/PythonCard/tools/ > > > layoutEditor/layoutEditor.py", line 556, in createDC > > I unzipped the folder you uploaded and placed it in the PythonCard/ > tools folder. I get the same error if I try to start the default > resourceEditor.py or layoutEditor.py scripts, so it does not seem to > have to do with your modifications. > When I copy multipropertyEditor.rsrc.py files from PythodCard/tools/ > resourceEditor/modules folder to PythodCard/tools/resourceEditor/, it > will throw the error about a different file - might this be some kind > of PATH error? > > C. It certainly looks like it's not finding a file. Not knowing Mac or Linux, I don't know how files are searched. There are a whole bunch of test programs that comes with Pythoncard. Do they work? (Not all of them will work - some requires a database) From duncan.booth at invalid.invalid Mon Apr 14 09:15:48 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 14 Apr 2008 13:15:48 GMT Subject: Process multiple files References: Message-ID: "Doran, Harold" wrote: > If these files followed a naming convention such as 1.txt and 2.txt I > can easily see how these could be parsed consecutively in a loop. > However, they are not and so is it possible to modify this code such > that I can tell python to parse all .txt files in a certain directory > and then to save them as separate files? For instance, using the example > above, python would parse both spam.txt and eggs.txt and then save 2 > different files, say as spam_parsed.txt and eggs_parsed.txt. > This isn't exactly what you asked for, but have you looked at the fileinput module: it will process a list of filenames pointing stdin at each file in turn, optionally it can work inplace, but without that option I think it is pretty close to what you want (warning, untested code follows): output = None for line in fileinput.input(n for n in glob.glob('*.txt') if not n.endswith('_parsed.txt')): if fileinput.isfirstline(): if output: output.close() output = open(fileinput.filename().replace('.', '_parsed.', 1), 'w') print >>output, "parsed:", line.strip() if output: output.close() From otsaloma at cc.hut.fi Sun Apr 6 20:26:15 2008 From: otsaloma at cc.hut.fi (Osmo Salomaa) Date: Mon, 07 Apr 2008 03:26:15 +0300 Subject: py.test and test coverage analysis ? In-Reply-To: References: Message-ID: <1207527975.13270.3.camel@localhost> On ke, 2008-04-02 at 11:23 -0600, j vickroy wrote: > Could someone offer a suggestion on how to combine coverage analysis > with py.test. Use the '-x' option to coverage.py to run py.test, then '-rm' to view the results. I use about the following shell script; additionally I find some grepping of the second command useful. #!/bin/sh coverage.py -x $(which py.test) "$@" || exit 1 coverage.py -rm -o /usr,/var rm -f .coverage -- Osmo Salomaa From bbxx789_05ss at yahoo.com Fri Apr 18 20:36:12 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Fri, 18 Apr 2008 17:36:12 -0700 (PDT) Subject: How to print a unicode string? References: Message-ID: <54e7dba7-f7f2-4aa7-81f9-922e3bf6e6cd@m73g2000hsh.googlegroups.com> On Apr 18, 5:38?pm, damonwisc... at gmail.com wrote: > I'd like to print out a unicode string. > > I'm running Python inside Emacs, which understands utf-8, so I want to > force Python to send utf-8 to sys.stdout. > > From what I've googled, I think I need to set my locale. I don't > understand how. > > import locale > print locale.getlocale() > --> (None,None) > print locale.getdefaultlocal() > --> ('en_GB','cp1252') > print locale.normalize('en_GB.utf-8') > --> en_GB.UTF8 > locale.setlocale(locale.LC_ALL,'en_GB.UTF8') > --> ?locale.Error: unsupported locale setting > > I'd be grateful for advice. > Damon. u_str = u'hell\u00F6 w\u00F6rld' #o's with umlauts print u_str.encode('utf-8') --output:-- hellö wörld From wizzardx at gmail.com Sun Apr 27 02:57:31 2008 From: wizzardx at gmail.com (David) Date: Sun, 27 Apr 2008 08:57:31 +0200 Subject: problem with listdir In-Reply-To: References: Message-ID: <18c1e6480804262357l1233d389gd4fec58d5e20fb7@mail.gmail.com> On Sat, Apr 26, 2008 at 7:56 PM, jimgardener wrote: > > > * Run cmd.exe and see if you can run "dir f:\\code\\python\pgmgallery/*.*" > > > > that causes a message 'Invalid switch - "*.*".' > > Probably because on the command-line, / means a command-line option. Been a while since I used DOS. Try this instead: dir f:\code\python\pgmgallery\*.*" David. From pylists at arcor.de Mon Apr 14 00:04:40 2008 From: pylists at arcor.de (Penny Y.) Date: Mon, 14 Apr 2008 12:04:40 +0800 Subject: Host: header Message-ID: <20080414040454.E685730AC25@mail-in-03.arcor-online.net> Hello, I have a problem with a request url,for example, I have the code below, import httplib try: conn = httplib.HTTPConnection("192.168.1.1") conn.request("GET", "/") r1 = conn.getresponse() if r1.status == 200: result = 0 except Exception: result = -1 but the server on 192.168.1.1 accept virtual host request only. That's to say, I need to specify a "Host:" header in the request. How to do it? thanks. From lew at lewscanon.com Tue Apr 22 23:56:34 2008 From: lew at lewscanon.com (Lew) Date: Tue, 22 Apr 2008 23:56:34 -0400 Subject: pop langs website ranking In-Reply-To: <1208919347_3071@news.newsgroups.com> References: <41fbaf27-a80b-402b-b406-c048a65a8643@b64g2000hsa.googlegroups.com> <315e13cc-3d21-4f2f-8503-835ea79069e2@x35g2000hsb.googlegroups.com> <1208919347_3071@news.newsgroups.com> Message-ID: Gerry Ford wrote: > "Paul McGuire" wrote in message > news:315e13cc-3d21-4f2f-8503-835ea79069e2 at x35g2000hsb.googlegroups.com... > On Apr 22, 4:41 pm, "xah... at gmail.com" wrote: >> In February, i spent few hours researching the popularity of some >> computer language websites. >> > I seem to recall this exact same post from *last* February. > > --->I remember it too. Xah is quite the self-promoter. Massive > cross-posters don't have anything to say for me. So don't do it. -- Lew From matthieu.brucher at gmail.com Sun Apr 6 06:03:45 2008 From: matthieu.brucher at gmail.com (Matthieu Brucher) Date: Sun, 6 Apr 2008 12:03:45 +0200 Subject: ANN: pry unit testing framework In-Reply-To: <20080405105459.GB15154@nullcube.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> Message-ID: 2008/4/5, Aldo Cortesi : > > Thus spake Matthieu Brucher (matthieu.brucher at gmail.com): > > > > How does it compare to the nose framework ? > > > As far as the base unit testing functionality is concerned, I think > they try to address similar problems. Both have assert-based testing > with inspection and re-parsing of assert exceptions for better error > messages. Both try to provide better fixture management. Both make > programmatic test generation easier. Both have a command-line tool for > running and gathering tests. > > I like nose, but I'm biased, and of course I think Pry has some > advantages. One difference I'd point out is Pry's tree-based test > structure, which provides a number of conveniences and features (much > nicer test selection from the command line, for instance). Pry is also > less than half the size of nose, and should therefore be simpler to > extend and understand. > > At any rate, feel free to take a look at Pry and see what you think. > One last question : does it take doctests into account ? Thanks for the last answer ;) Matthieu -- French PhD student Website : http://matthieu-brucher.developpez.com/ Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92 LinkedIn : http://www.linkedin.com/in/matthieubrucher -------------- next part -------------- An HTML attachment was scrubbed... URL: From deets at nospam.web.de Fri Apr 18 08:27:31 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 18 Apr 2008 14:27:31 +0200 Subject: py3k s***s In-Reply-To: References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <66q33cF2krjf2U1@mid.uni-berlin.de> Message-ID: <66rie3F2leg20U1@mid.uni-berlin.de> Robin Becker schrieb: > I'm in the process of attempting a straightforward port of a relatively > simple package which does most of its work by writing out files with a > more or less complicated set of possible encodings. So far I have used > all the 2to3 tools and a lot of effort, but still don't have a working > version. This must be the worst way to convert people to unicode. When > tcl went through this they chose the eminently sensible route of not > choosing a separate unicode type (they used utf8 byte strings instead). > Not only has python chosen to burden itself with two string types, but > with 3 they've swapped roles. This is certainly the first time I've had > to decide on an encoding before writing simple text to a file. Which is the EXACT RIGHT THING TO DO! see below. > > Of course we may end up with a better language, but it will be a > worse(more complex) tool for many simple tasks. Using a complex writing > with many glyphs costs effort no matter how you do it, but I just use > ascii :( and it's still an effort. > > I find the differences in C/OS less hard to understand than why I need > bytes(x,'encoding') everywhere I just used to use str(x). If you google my name + unicode, you see that I'm often answering questions regarding unicode. I wouldn't say I'm a recognized expert on the subject, but I certainly do know enough to deal with it whenever I encounter it. And from my experience with the problems in general, and specificly in python, as well as trying to help others I can say that: - 95% of the times, the problem is in front of the keyboard. - programmers stubbornly refuse to *learn* what unicode is, and what an encoding is, and what role utf-8 plays. Instead, the resort to a voodoo-approach of throwing in various encode/decode-calls + a good deal of cat's feces in hope of wriggling themselves out of the problem. - it is NOT sensible to use utf8 as unicode-"type" - that is as bad as it can get because you don't see the errors, but instead mangle your data and end up with a byte-string-mess. If that is your road to heaven, by all means chose it - and don't use unicode at all. and be prepared for damnation :) If your programs worked for now, but don't do anymore because of Py3K introducing mandatory unicode-objects for string-literals it pretty much follows that they *seem* to work, but very, very probably fail in the face of actual i18nized data. The *only* sensible thing to do is follow these simple rules - and these apply with python 2.x, and will be enforced by 3k which is a good thing IMHO: - when you read data from somewhere, make sure you know which encoding it has, and *immediatly* convert it to unicode - when you write data, make sure you know which encoding you want it to have (in doubt, chose utf-8 to prevent loss of data) and apply it. - XML-parsers take byte-strings & spit out unicode. Period. I neither want to imply that you are an Idiot nor that unicode doesn't have it's complexities. And I'd love to say that Python wouldn't add to these by having two string-types. But the *real* problem is that it used to have only bytestrings, and finally Py3K will solve that issue. Diez From hniksic at xemacs.org Tue Apr 15 06:07:29 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Tue, 15 Apr 2008 12:07:29 +0200 Subject: Dynamic use of property() fails References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> <87wsmz4l5g.fsf@mulj.homelinux.net> <48046af8$0$16166$426a74cc@news.free.fr> Message-ID: <87hce34eji.fsf@mulj.homelinux.net> Bruno Desthuilliers writes: >> However, if you know what you're doing, you can simply customize your >> class's __getattribute__ to do what *you* want for your objects. > > > But bear in mind that, beside possible unwanted side-effectn, you'll > get a non-negligible performance hit - __getattribute__ being, as the > name implies, invoked on each and every attribute lookup. That's unavoidable, though -- whatever you do to customize your class in Python, the result will be slower than the C code built into Python. Fortunately, not every object is performance-critical. In this case, __getattribute__ buys you per-instance customization not otherwise available. The code you posted is probably more efficient, but at the cost of losing the ability to customize specific instances of the class. From MartinRinehart at gmail.com Thu Apr 10 15:52:11 2008 From: MartinRinehart at gmail.com (MartinRinehart at gmail.com) Date: Thu, 10 Apr 2008 12:52:11 -0700 (PDT) Subject: Python conventions References: Message-ID: Daniel Fetchinson wrote: > I'm sorry to disappoint you but this project has already been completed: > > http://www.python.org/dev/peps/pep-0008/ Daniel, PEP 8 is anything but complete. How much of the following simple question can you answer from there: Given that you can name things with UpperAndLower, lowerAndUpper, lower_and_underscore, etc., what is the convention for naming packages, modules, classes, ... PEP 8 very much reminds me of Sun's Java conventions - a start, but only a start. Also, in part, controversial. (How wide do you think Python code should be?) Finally, lacking in basic organization. (This seems to be a disease that infects almost all standards.) We can do better. As a guess, GvR would be happy to have someone fill out PEP 8. From fr5478bey at gmail.com Sat Apr 26 11:42:06 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:42:06 -0700 (PDT) Subject: navigon 6 crack Message-ID: <6b365493-5cee-4f5f-8f51-b655e63c3d7f@i76g2000hsf.googlegroups.com> navigon 6 crack http://cracks.00bp.com F R E E C R A C K S From carbanancizpo at gmail.com Fri Apr 18 16:56:12 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:56:12 -0700 (PDT) Subject: winxp keygen Message-ID: <757fef36-63c6-4f48-a3e4-335dc886d442@x41g2000hsb.googlegroups.com> winxp keygen http://cracks.12w.net F R E E C R A C K S From carsten.haese at gmail.com Fri Apr 4 19:28:58 2008 From: carsten.haese at gmail.com (Carsten Haese) Date: Fri, 4 Apr 2008 16:28:58 -0700 (PDT) Subject: Python2.5 and MySQLdb References: Message-ID: On Apr 4, 5:06 pm, writeson wrote: > It > generates a huge lists of errors and warnings from gcc when I run the > python2.5 setup.py build script that comes with the tar file. Anyone > have any suggestions? I suggest you post a couple of those error messages here, so that we can help you without guessing. -- Carsten Haese http://informixdb.sourceforge.net From zolotoiklo at mail.ru Sat Apr 26 06:46:19 2008 From: zolotoiklo at mail.ru (=?KOI8-R?B?+s/Mz9TPyiDrzM/O?=) Date: Sat, 26 Apr 2008 03:46:19 -0700 (PDT) Subject: =?KOI8-R?B?wsXM2MUgTWFpZGVuZm9ybQ==?= Message-ID: <775dee46-dae9-4791-90c0-41693e9dc437@j22g2000hsf.googlegroups.com> ???????????? ??????????? ????? Maidenform USA - ??????? ?????????????? ????? ????? ???? ? ???. ????????? ????-????? (??????????? ?????) ??????? ??????? ????????? ?? ???????????? ??????????? ????????? ? ???????? ?????????? ????. ??????? ????????? ??????????? ??????? ???????????? ?????????????? ????????? ??????? ??????. ????????? ?????????? ???? ? ?????????????? ????????, ??????????? ????? ????????? ??? ?????????? ???????. ????? Maidenform http://shopbody.ru/maidenform6224.htm From enleverlesX.XmcX at XmclaveauX.com Tue Apr 15 06:18:05 2008 From: enleverlesX.XmcX at XmclaveauX.com (Méta-MCI (MVP)) Date: Tue, 15 Apr 2008 12:18:05 +0200 Subject: [ANN] Data Plotting Library DISLIN 9.3 In-Reply-To: References: Message-ID: <48048358$0$850$ba4acef3@news.orange.fr> Hi, Thanks! I like DISLIN (even if I use it very little). @+ -- Michel Claveau From mishok13 at gmail.com Thu Apr 10 14:06:03 2008 From: mishok13 at gmail.com (Andrii V. Mishkovskyi) Date: Thu, 10 Apr 2008 21:06:03 +0300 Subject: from __future__ import print In-Reply-To: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> References: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> Message-ID: <192840a00804101106t2e0d687erc13d9ebf096448e3@mail.gmail.com> 2008/4/10, samslists at gmail.com : > Am I the only one that thinks this would be useful? :) > > I'd really like to be able to use python 3.0's print statement in > 2.x. Is this at least being considered as an option for 2.6? It > seems like it would be helpful with transitioning. It's not only considered but have been already implemented. Enjoy. :) Python 2.6a2+ (trunk:62269, Apr 10 2008, 20:18:42) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from __future__ import print_function >>> print "asd" File "", line 1 print "foo" ^ SyntaxError: invalid syntax >>> print("foo") foo > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Wbr, Andrii Mishkovskyi. He's got a heart of a little child, and he keeps it in a jar on his desk. From samuel.progin at gmail.com Fri Apr 18 03:41:05 2008 From: samuel.progin at gmail.com (Sam) Date: Fri, 18 Apr 2008 00:41:05 -0700 (PDT) Subject: Request a short code review References: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> Message-ID: <4aaa7c04-99c9-40df-87de-999152a139ab@c65g2000hsa.googlegroups.com> Hello, I would personally avoid using "type" as variable name, or key, because built-in class type already exists. As I understand your code, it was not your intention to override it. ++ Sam From bdsatish at gmail.com Mon Apr 14 03:24:49 2008 From: bdsatish at gmail.com (bdsatish) Date: Mon, 14 Apr 2008 00:24:49 -0700 (PDT) Subject: Java or C++? References: Message-ID: On Apr 14, 12:21 pm, Bob Martin wrote: > in 342367 20080414 074410 s0s... at gmail.com wrote: > > >Hello, I was hoping to get some opinions on a subject. I've been > >programming Python for almost two years now. Recently I learned Perl, > >but frankly I'm not very comfortable with it. Now I want to move on > >two either Java or C++, but I'm not sure which. Which one do you think > >is a softer transition for a Python programmer? Which one do you think > >will educate me the best? > Certainly Java. It's also easier to find Java jobs than C++ jobs. From jens at aggergren.dk Tue Apr 29 08:19:32 2008 From: jens at aggergren.dk (Jens) Date: Tue, 29 Apr 2008 05:19:32 -0700 (PDT) Subject: Zope/DTML Infuriating... References: Message-ID: <3a955f90-ed80-46be-a238-1462e4fb2d0c@m3g2000hsc.googlegroups.com> On Apr 29, 1:59?pm, Marco Mariani wrote: > Jens wrote: > > I've the checked that i'm referring to the variables correctly, so the > > only explanation i can come up with, is that '+' doesn't result in a > > string concatenation (with implicit typecast to string of the integer > > variable(this is a interpreted language after all)). > > No, sorry. You really need to read the python tutorial at the very least. > You might have wrong assumptions from previous PHP experiences. > > ?>>> 'x'+4 > Traceback (most recent call last): > ? ?File "", line 1, in > TypeError: cannot concatenate 'str' and 'int' objects > ?> ... and the non snobby answer would have been: ... From altami0762 at gmail.com Thu Apr 17 15:49:07 2008 From: altami0762 at gmail.com (altami0762 at gmail.com) Date: Thu, 17 Apr 2008 12:49:07 -0700 (PDT) Subject: zillatube cracks keygens Message-ID: zillatube cracks keygens http://cracks.12w.net F R E E C R A C K S From castironpi at gmail.com Fri Apr 18 11:23:15 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Fri, 18 Apr 2008 08:23:15 -0700 (PDT) Subject: python persistence References: <8b1723d9-67c8-4fe5-b07b-22b0b9311519@8g2000hsu.googlegroups.com> <7f58b5f4-3195-472c-b307-dec71b12aaa8@y21g2000hsf.googlegroups.com> <44f04bf3-4edc-4cb4-9e54-fe51b5e591bc@e39g2000hsf.googlegroups.com> <80d1731d-a3c6-4fce-81fd-9c3f3537e59b@d21g2000prf.googlegroups.com> <5386cf08-c155-4fbb-8373-dbbb9829a9e7@m3g2000hsc.googlegroups.com> <3c27b270-e593-4f2a-b881-68126319760c@8g2000hsu.googlegroups.com> <7d71e294-2b13-4be0-948e-2fe0e4bbe7db@f63g2000hsf.googlegroups.com> Message-ID: <2d0db2c2-85ba-4987-9bf7-86109380d325@c65g2000hsa.googlegroups.com> On Apr 1, 3:21?pm, castiro... at gmail.com wrote: > On Apr 1, 11:34?am, "Gabriel Genellina" > > En Tue, 01 Apr 2008 08:47:33 -0300, escribi?: > > > > >> >>>> c['0']= type('None',(),{}) > > >> > Traceback (most recent call last): > > >> > pickle.PicklingError: Can't pickle : it's not > > >> > found as __main__.None > > > >> Don't do that then. Or use the available pickle hooks to customize how ? > > >> such classes may be pickled. All persistence mechanisms have ? > > >> limitations. > > > > I don't see a problem with that; except that binaries come from > > > disks. ?You could have a Python session that runs entirely on disks + > > > the ALU. > > > (ALU? Do you mean CPU?) I don't understand this. Most programs are read ? > > ?from disk. Most data is read from disk. > > > > I want to know if any, and correct me here, simple > > > modification can store live objects. ?I call a.append(it) and the > > > memory update takes place on disk instead. > > > Using ZODB, a.append(it) would mark `a` as dirty. When you latter commit ? > > the transaction, it is stored back on disk. > > > > If you require that all objects referenced by on-disk objects be on- > > > disk, that's an easy workaround. > > > ZODB already does that. > > It's pretty close, but the database connection can get bulky. ?If you > had: > ?_______________________ > | ? ? ? ? ______________________ > |File ? ?| PyOb1 | PyOb2 | ?.. ?| > | ? ? ? ?|_______|_______|______| > |_______________________ > > on disk, updating the reference counts and attributes would take a > long time, but it's just right for some core applications. > > Strictly, I'm not in the "real" programming world [snip]. My intentions may be pedagogical but I can guarantee good. I am following the cases where databases are way-out-of-proportion techniques, and you only need small numbers persistent. I am looking for a step-by-step of everything that happens in line one of the following program: #!/windows a= [ ] What c-l-py says is that the compilation flags vary widely enough to make my destination worthless. Accepting concern, please only reply in readers' free time. I expect I wish to override routines and macros which are buried pretty deep and used pretty pervasively throughout Python and inner user extension modules, so I'll reemphasize that I'm only interested in pass-time hobbyage. Consultants need not reply (but of course may). I foresee that writing my own disk-based-heap may be in order, which would be why Bruno keeps directing us to relationals. I would want an arena file/pool file. Zoom out to the big picture: Session 1: >>> managingfolder= '/live/Python/' >>> manager['a']= [ 0 ] Session 2: >>> managingfolder= '/live/Python/' >>> manager['a'] [ 0 ] >>> manager['a'].append( 0 ) Session 3: >>> managingfolder= '/live/Python/' >>> manager['a'] [ 0, 0 ] I would kind of expect a file per the diagram in obmalloc.c, and I expect to specialize in CPython. Object-specific allocators _____ ______ ______ ________ [ int ] [ dict ] [ list ] ... [ string ] Python core | +3 | <----- Object-specific memory -----> | <-- Non-object memory --> | struct pool_header and struct arena_object would probably appear, and to explify priorities, performance would be a low priority, and it's a high priority to stay all in Python. (Aside, I certainly would maintain Python is yes, still Python.) From pylists at arcor.de Tue Apr 15 01:54:43 2008 From: pylists at arcor.de (Penny Y.) Date: Tue, 15 Apr 2008 13:54:43 +0800 Subject: a name error Message-ID: <20080415055502.9F3CF292B61@mail-in-07.arcor-online.net> Hello, I run this small script: import urllib2,sys try: r=urllib2.urlopen("http://un-know-n.com/") except URLError,e: print str(e) sys.exit(1) print r.info() But got the errors: Traceback (most recent call last): File "t1.py", line 4, in ? except URLError,e: NameError: name 'URLError' is not defined Why these is not the name of URLError? I saw it on this module's page: http://www.python.org/doc/lib/module-urllib2.html Thanks. From reachmsn at hotmail.com Wed Apr 9 04:02:10 2008 From: reachmsn at hotmail.com (reachmsn at hotmail.com) Date: Wed, 9 Apr 2008 01:02:10 -0700 (PDT) Subject: Cannot understand the detailedly the following code References: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> Message-ID: <10a83944-b17a-4c3f-992b-1754c0a5e9b1@s33g2000pri.googlegroups.com> On Apr 8, 5:45?pm, "A.T.Hofkamp" wrote: > On 2008-04-08, reach... at hotmail.com wrote: > > [deleted a long piece of text by our BDFL about recursive graph path-finding algorithm] > > > after first writing the inductive part ... for node in > > graph[start] .... > > and then by trial and error put square brackets around path in the > > Basis part. Can someone please explain how to write this code. Thanks! > > The same as any other function. > (the trick with recursive functions is not to think about recursion. Instead, > pretend you are calling another function that happens to have the same name.) > > As for the actual procedure of writing a function: > > First define the input and output parameters/values of the function. > (ie what goes in, and what comes out) > > For recursive functions, there are always two cases, a terminating case, and a > reduction case. In the first case, you may not use the recursive function, in > the latter function you should. > Both cases should use the information available from the input parameters, and > provide a result that matches with the output requirements of the function. Add > a if/then/else that distinguishes between what case you have, and you're done. > > Sincerely, > Albert Ok following these instructions one gets def find_all_paths(graph, start, end, path=[]): path= path+ [start] for node in graph[start]: find_all_paths(graph, node, end, path) Now > > First define the input and output parameters/values of the function. > (ie what goes in, and what comes out) Now what will be the output parameters - there is a Return statement. Input parameters are graph, vertexes start, node, end and path. Also how would you write the terminating and reduction cases after this. Actually i'm not clear how to proceed writing this recursive function. Thanks! From frikker at gmail.com Tue Apr 29 09:29:20 2008 From: frikker at gmail.com (blaine) Date: Tue, 29 Apr 2008 06:29:20 -0700 (PDT) Subject: Why is None <= 0 References: <481226f9$0$20866$9b622d9e@news.freenet.de> Message-ID: <4d86a7ce-8f3f-493b-b1c2-a2659817b215@k13g2000hse.googlegroups.com> On Apr 29, 5:32 am, Duncan Booth wrote: > =?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?= wrote: > > (FWIW, in 2.x, x>=4?, it's None < numbers < anything else; > > numbers are ordered by value, everything else is ordered > > by type name, then by address, unless comparison functions > > are implemented). > > Quite apart from Jon pointing out that this isn't true for all cases when > copmparing against None, the other half also isn't true: > > >>> class C: pass > >>> C() < 5 > > True > > That happens at least in Python 2.5.2 on win32. Yet another reason to avoid > old-style classes. Sorry - but what are new style classes? From python.list at tim.thechases.com Mon Apr 14 08:57:30 2008 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 14 Apr 2008 07:57:30 -0500 Subject: Process multiple files In-Reply-To: <2323A6D37908A847A7C32F1E3662C80E017BDF37@dc1ex01.air.org> References: <2323A6D37908A847A7C32F1E3662C80E017BDF37@dc1ex01.air.org> Message-ID: <480354BA.103@tim.thechases.com> > new_file = open('filename.txt', 'w') > params = open('eggs.txt', 'r') > do all the python stuff here > new_file.close() > > If these files followed a naming convention such as 1.txt and 2.txt I > can easily see how these could be parsed consecutively in a loop. > However, they are not and so is it possible to modify this code such > that I can tell python to parse all .txt files in a certain directory > and then to save them as separate files? For instance, using the example > above, python would parse both spam.txt and eggs.txt and then save 2 > different files, say as spam_parsed.txt and eggs_parsed.txt. import os for fname in os.listdir('.'): if not fname.lower().endswith('.txt'): continue new_file_name = '%s_parsed%s' % tuple( new_file = open(new_file_name, 'w') params = open(fname) # do all the python stuff here params.close() new_file.close() -tkc From nick at stinemates.org Thu Apr 24 11:26:57 2008 From: nick at stinemates.org (Nick Stinemates) Date: Thu, 24 Apr 2008 08:26:57 -0700 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> Message-ID: <20080424152657.GA7426@deviL> On Tue, Apr 22, 2008 at 04:07:01AM -0700, GD wrote: > Please remove ability to multiple inheritance in Python 3000. > > Multiple inheritance is bad for design, rarely used and contains many > problems for usual users. > > Every program can be designed only with single inheritance. > > I also published this request at http://bugs.python.org/issue2667 > -- > http://mail.python.org/mailman/listinfo/python-list You make strong, compelling arguments............ -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From stefan_ml at behnel.de Tue Apr 22 07:09:13 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 22 Apr 2008 13:09:13 +0200 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> Message-ID: <480DC759.9020703@behnel.de> GD wrote: > Please remove ability to multiple inheritance in Python 3000. I'm so happy *that's* a dead parrot, all right. Stefan From rubrum at pacbell.net Fri Apr 4 20:28:45 2008 From: rubrum at pacbell.net (Michael Press) Date: Fri, 04 Apr 2008 17:28:45 -0700 Subject: Nonlinear least square problem References: <0354420e-819d-4ba3-b61a-faaffd46b65c@r9g2000prd.googlegroups.com> Message-ID: In article <0354420e-819d-4ba3-b61a-faaffd46b65c at r9g2000prd.googlegroups.com>, Uwe Kotyczka wrote: > Hallo, sorry for multiposting, but I am really looking > for some hint to solve my problem. And no, I don't > use Matlab, but maybe the matlab people have an idea > nevertheless. No apology required, since you seem to have cross-posted appropriately, and not multi-posted. Multi-posting is posting the same message one at a time to more than one group. I see in the Newsgroups: header line that you posted to several groups at once. Furthermore the number of groups is not out of bounds, and the groups are appropriate to the question and, presumably, your interests. Unfortunately, I cannot help with the actual question. :) -- Michael Press From sn at sncs.se Fri Apr 18 01:39:46 2008 From: sn at sncs.se (Sverker Nilsson) Date: Thu, 17 Apr 2008 22:39:46 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <66q33cF2krjf2U1@mid.uni-berlin.de> Message-ID: On Apr 18, 12:59 am, "Diez B. Roggisch" wrote: > > And I have been benefiting from Python in general, so far. Thanks, > > community. > > > But now... I'll probably stop posting here for now, & I may stop other > > things too. > > > Just my 2c. > > You know what I was just wondering about? All these C-written > cross-platform libraries (which Python users benefit from, most probably > including evven you) that run on different unixes & windows, which are a > much greater diversity to handle than the not-even-yet-settled > differences between Py3K & 2.x. How the heck do they do that? > > Oh, and these dreaded 64 bit processors, possibly with multi-cores, > which need changes in code as well, to be utilized to their power. > > But then, these guys most probably don't whine about diversity and > constant change, and cry out useless threats to people who probably > can't care less. > > Fare well, if you must. But getting mad over something which impact you > can't even judge right now is childish. Nothing else. > > Diez Some whine. Some just don't care. Why not whine? From duncan.booth at invalid.invalid Tue Apr 29 11:11:05 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 29 Apr 2008 15:11:05 GMT Subject: Why is None <= 0 References: <481226f9$0$20866$9b622d9e@news.freenet.de> <4d86a7ce-8f3f-493b-b1c2-a2659817b215@k13g2000hse.googlegroups.com> Message-ID: blaine wrote: > On Apr 29, 5:32 am, Duncan Booth wrote: >> =?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?= >> wrote: >> > (FWIW, in 2.x, x>=4?, it's None < numbers < anything else; >> > numbers are ordered by value, everything else is ordered >> > by type name, then by address, unless comparison functions >> > are implemented). >> >> Quite apart from Jon pointing out that this isn't true for all cases >> when copmparing against None, the other half also isn't true: >> >> >>> class C: pass >> >>> C() < 5 >> >> True >> >> That happens at least in Python 2.5.2 on win32. Yet another reason to >> avoid old-style classes. > > Sorry - but what are new style classes? > New style classes are anything type derived from object. e.g. class D(object): pass or (since list is derived from object): class E(list): pass Old style classes are those which either have old-style base classes or no base class at all (and no __metaclass__ either but don't worry about that for now) e.g. the class C above. The problem with old style classes is that various things either work subtly differently or don't work at all, but you don't get much warning. So basically steer clear of them. An example of something which doesn't work with old style classes would be the @property decorator: you can get the property, but setting it simply overwrites the property with the new value. See http://www.google.co.uk/search?q=python+%22new+style%22 for more information. From kib2 at free.fr Thu Apr 24 17:06:11 2008 From: kib2 at free.fr (kib) Date: Thu, 24 Apr 2008 23:06:11 +0200 Subject: Psyco alternative In-Reply-To: References: <1369b321-f55b-432b-b2f9-6144787509d8@h11g2000prf.googlegroups.com> <7xlk4473ai.fsf@ruckus.brouhaha.com> <651ncdF2cmik2U1@mid.uni-berlin.de> <651onqF2dripdU1@mid.uni-berlin.de> Message-ID: <4810f649$0$23674$426a74cc@news.free.fr> Christian Tismer a ?crit : > bearophileHUGS at lycos.com wrote: >> Diez B. Roggisch: >>> the author says that the approach is flawed, so at *some* >>> point it will be discontinued. >> >> Can't Psyco be improved, so it can compile things like: >> >> nums = (i for i in xrange(200000) if i % 2) >> print sum(nums) > > Although my main goal is to support PyPy as much as possible, > I am currently taking a pause in favor of filling the gap > for psyco, supporting generators. The details are not yet > settled, maybe we choose to change the project name, > to avoid the author getting bugged with questions about > this extra stuff. > > - chris > Maybe try Psychotic http://code.google.com/p/psychotic/ I really like the screencast ! ...sorry for the bad joke :) From laurent.ploix at gmail.com Tue Apr 8 05:39:04 2008 From: laurent.ploix at gmail.com (=?ISO-8859-1?Q?m=E9choui?=) Date: Tue, 8 Apr 2008 02:39:04 -0700 (PDT) Subject: Is there an official way to add methods to an instance? References: <7xve2yas87.fsf@ruckus.brouhaha.com> <47f61041$0$27969$426a34cc@news.free.fr> <47f645e6$0$36354$742ec2ed@news.sonic.net> Message-ID: <9a4cde09-d1a0-4205-aea8-1ee32d4fb1b3@a70g2000hsh.googlegroups.com> On Apr 4, 5:25 pm, John Nagle wrote: > Bruno Desthuilliers wrote: > > Paul Rubin a ?crit : > >> Brian Vanderburg II writes: > >>> I've checked out some ways to get this to work. I want to be able to > >>> add a new function to an instance of an object. > > >> Ugh. Avoid that if you can. > > > Why so ? OO is about objects, not classes, and adding methods on a > > per-object basis is perfectly legitimate. > > It's what professional programmers call a "l33t feature", > one not suitable for production code. Typically such features > are used by programmers with about two years experience, > trying too hard to prove that they're cool. > > John Nagle Yes, and the reason is quite obvious: if you read the code of the class, you can't see the function. That makes it much more difficult to understand and to debug. From roger.dahlstrom at gmail.com Fri Apr 11 13:45:57 2008 From: roger.dahlstrom at gmail.com (rdahlstrom) Date: Fri, 11 Apr 2008 10:45:57 -0700 (PDT) Subject: Windows - window status (Running vs Not Responding) Message-ID: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> Does anyone know how to determine the window status (Running or Not Responding)? I've tried various methods with no success... This would be on a variety of Windows systems, but all at least XP, and mostly server 2003. Everyone will have Python 2.5.1 on them, and the script would be running locally. Any ideas? From george.sakkis at gmail.com Wed Apr 30 12:56:43 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 30 Apr 2008 09:56:43 -0700 (PDT) Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> Message-ID: <74c070ce-1b8f-4746-9d1c-ac2227aaf515@y21g2000hsf.googlegroups.com> On Apr 30, 5:06?am, Torsten Bronger wrote: > Hall?chen! > > SL writes: > > "Gabriel Genellina" schreef in bericht > >news:mailman.365.1209541507.12834.python-list at python.org... > > >> En Wed, 30 Apr 2008 04:19:22 -0300, SL escribi?: And > >> that's a very reasonable place to search; I think chr and ord are > >> builtin functions (and not str methods) just by an historical > >> accident. (Or is there any other reason? what's wrong with > >> "a".ord() or str.from_ordinal(65))? > > > yes when you know other OO languages you expect this. Anyone know > > why builtins were chosen? Just curious > > *Maybe* for aesthetical reasons. ?I find ord(c) more pleasent for > the eye. ?YMMV. > > The biggest ugliness though is ",".join(). ?No idea why this should > be better than join(list, separator=" "). ? Seconded. While we're at it, a third optional 'encode=str' argument should be added, to the effect of: def join(iterable, sep=' ', encode=str): return sep.join(encode(x) for x in iterable) I can't count the times I've been bitten by TypeErrors raised on ','.join(s) if s contains non-string objects; having to do ','.join(map(str,s)) or ','.join(str(x) for x in s) gets old fast. "Explicit is better than implicit" unless there is an obvious default. George From aaron.watters at gmail.com Wed Apr 16 08:56:55 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 16 Apr 2008 05:56:55 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: On Apr 15, 12:30 am, Sverker Nilsson wrote: > No one forces me, but sooner or later they will want a Python 3.0 and > then a 3.1 whatever. > > I don't want that fuzz. As about the C versions, I am not that > worried. What's your point? > > I just like want to write a program that will stay working. Maybe I'll see the wisdom of py 3k eventually, if I don't die first, but I have to agree with Sverker's general comments. Just yesterday I had a conversation with someone who thinks maybe Ruby is better than Python -- the one really good argument Python has against nearly all contenders is all the stuff out there you can get so easily -- all the stuff that py3k will break -- most of which won't get ported -- and if it does can we be sure it will be tested properly? No, probably you will end up beta testing someone's quick port of what used to be rock solid code... This was quite rightly pointed out to me, and I had to agree that it was a pretty good point. In my opinion python's adherence to backwards compatibility has been a bit mythological anyway -- many new python versions have broken my old code for no good reason. This is an irritant when you have thousands of users out there who suddenly drop your code, blame you and python, and move on to use something else. Honestly, how hard would it have been to provide standard backwards support for the old regex module as a standard module which simply translated one regex string format to another, for example? I don't get it. It ain't broke. Don't fix it. At long last Python has a full head of steam and py3k is just confusing everyone. But I've been wrong before (twice). I also once thought generators were a mistake :) (but I still think full stackless would be much better, which python seems to be very slowly moving towards.....) -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=nonsense From george.sakkis at gmail.com Wed Apr 30 20:00:01 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 30 Apr 2008 17:00:01 -0700 (PDT) Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> <74c070ce-1b8f-4746-9d1c-ac2227aaf515@y21g2000hsf.googlegroups.com> Message-ID: <353ad234-1c1b-4224-90ab-4b5299532a91@k13g2000hse.googlegroups.com> On Apr 30, 3:53 pm, Mel wrote: > George Sakkis wrote: > > def join(iterable, sep=' ', encode=str): > > return sep.join(encode(x) for x in iterable) > > Actually > > return encode(sep).join(encode(x) for x in iterable) > > lest you get TypeErrors for non-string separators. Well separator is almost always a string literal or at least known to be a string, so that TypeError has never occured to me. George From mnordhoff at mattnordhoff.com Thu Apr 24 02:56:09 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Thu, 24 Apr 2008 06:56:09 +0000 Subject: library to do easy shell scripting in Python In-Reply-To: <480FEED6.8080309@gmail.com> References: <480FEED6.8080309@gmail.com> Message-ID: <48102F09.806@mattnordhoff.com> Wow, this message turned out to be *LONG*. And it also took a long time to write. But I had fun with it, so ok. :-) Michael Torrie wrote: > Recently a post that mentioned a recipe that extended subprocess to > allow killable processes caused me to do some thinking. Some of my > larger bash scripts are starting to become a bit unwieldy (hundreds of > lines of code). Yet for many things bash just works out so well because > it is so close to the file system and processes. As part of another > project, I now have need of a really good library to make it almost as > easy to do things in Python as it is in Bash. With a simple wrapper > around subprocess, I'm pretty much able to do most things. Most of my > complicated bash hackery involves using awk, sed, grep, and cut to > process text, which python does quite nicely, thank you very much. But > there's a few things to add. > > To wit, I'm wanting to write a library that can deal with the following > things: > > - spawn a process, feed it std in, get stdout, stderr, and err code. > This is largely already accomplished by subprocess It is accomplished by subprocess.Popen: The 'communicate' method handles stdin, stdout and stderr, waiting for the process to terminate. The 'wait' method just waits for the process to terminate and returns the return code. The 'returncode' attribute contains the return code (or None if the process hasn't terminated yet). You could write a convenience wrapper function if you want to do this in a more terse way. > - spawn off processes as background daemons Couldn't you do this with subprocess by doing subprocess.Popen([prog]) and, well, nothing else? (You may have/want to set stdin/stdout/stderr too. I dunno.) > - spawn multiple processes and pipe output to input. > - can do fancier things like bash does, like combine stderr/stdout, > switch stderr/stdout, redirects to and from files That's possible with subprocess. See this paragraph of : > stdin, stdout and stderr specify the executed programs' standard input, standard output and standard error file handles, respectively. Valid values are PIPE, an existing file descriptor (a positive integer), an existing file object, and None. PIPE indicates that a new pipe to the child should be created. With None, no redirection will occur; the child's file handles will be inherited from the parent. Additionally, stderr can be STDOUT, which indicates that the stderr data from the applications should be captured into the same file handle as for stdout. And also . Not the least verbose, but pretty simple, and I bet it can do anything bash can. > - transparently allow a python function or object to be a part of > the pipeline at any stage. Hmmm. I can't think very well at the moment, but you could create file-like objects that do...I dunno, callbacks or something. Simple and incomplete mockup: class Pipe(object): def __init__(self, from_fh, to_fh, from_callback=None, to_callback=None): self.from_fh = from_fh self.to_fh = to_fh self.from_callback = from_callback self.to_callback = to_callback def read(self, *args, **kwargs): data = self.from_fh.read(*args, **kwargs) if self.from_callback is not None: self.from_callback(data) return data def write(self, data): # XXX Call the callback before or after the data is actually written? if self.to_callback is not None: self.to_callback(data) return self.to_fh.write(data) That just passes input and output through itself, also passing it to callback functions. You'd have to add all the other methods too, like readline and __iter__... Maybe inheriting from 'file' would get most of them. I dunno how it works internally. > Questions include, how would one design the interface for things, like > assembling pipes? Several ideas include: > > pipe([prog1,args],[prog2,args],...) > > or > > run([prog1,args]).pipe([prog2,args]).pipe(...) > > The former doesn't deal very well with re-plumbing of the pipes, nor is > there an easy way to redirect to and from a file. The second syntax is > more flexible but a bit cumbersome. Also it doesn't allow redirection > or flexible plumbing either. > > Any ideas on how I could design this? Ok, the below is an edited-down, more formal-sounding brain dump. Idea 1: >>> run([prog, args], from_fh, to_fh, from_callback, to_callback).run(...) It would basically just automate the construction of the intermediary pipe objects suggested above. It could also be done with tuples, like: >>> run([prog, args], (from_fh, to_fh), (from_callback, to_callback)).run(...) Idea 2: This one would parse a list similar to a bash command line. run('prog', '>>out', '|', 'other_prog', 'arg', '>', 'foo.txt') Which would be like a bash: `prog 2>&1 | other_prog arg >foo.txt` ("2>&1" is how you combine stdout and stderr, right?) "<", ">", ">>" and "|" would be keywords that behave similarly to bash. You would use e.g. ['>', 'foo.txt'] to pass the argument to the keywords. Along with string filenames, it would accept file-like objects and file descriptors like subprocess.Popen does. ">>out", would be equivalent to bash's "2>&1". Similar things like ">err" would work too. They would be entirely separate keywords, not ['>>', 'out'] or something, so you could use "out" as the filename if you wanted to. If the last command in the pipeline didn't have its stdout and stderr redirected somewhere, their file objects would be returned. If you wanted them going to your regular stdout and stderr, I guess you would have to end the pipeline with [">out", ">>err"]. I just realized I made a mistake: In my keywords, I used ">x" for stdout and ">>x" for stderr. Bash uses ">x" and ">>x", and "2>x" and "2>>x", respectively. That could be changed, or we could just leave it all confusing-like. ;-) Idea 3: You could be dirty and just use os.system(). ;-) -- From cokofreedom at gmail.com Thu Apr 10 02:30:43 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Wed, 9 Apr 2008 23:30:43 -0700 (PDT) Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> <6641eaF2ics8jU1@mid.uni-berlin.de> <664j0pF2iji99U2@mid.uni-berlin.de> <89872ea1-dc03-4647-b0bc-9d316df3efb5@q1g2000prf.googlegroups.com> Message-ID: Umm, Mesopotamia is an area geographically located between the Tigris and Euphrates rivers, Bangalore isn't anywhere near that. And most of that is presently under American control. If you don't want to give out your code then try explaining it better. What is the input, what is the output, how are you currently processing. Describe these and people might be willing to aid more. Or complain more about how unhelpful people are. Suits us. From kst-u at mib.org Wed Apr 2 23:09:17 2008 From: kst-u at mib.org (Keith Thompson) Date: Wed, 02 Apr 2008 20:09:17 -0700 Subject: Recursive function won't compile References: <65iafeF2g9cvvU1@mid.uni-berlin.de> Message-ID: <87lk3v4ote.fsf@kvetch.smov.org> "Diez B. Roggisch" writes: >> #include >> #include >> >> def RecursiveFact(n): >> if(n>1): >> return n*RecursiveFact(n-1) >> else: >> return 1 >> >> fact = RecursiveFact(31) >> print fact >> >> fact = "End of program" >> print fact >> >> >> ......but yet it still gives the right answer. How is this possible? > > Given that you obviously don't use python, but some weird cross-breed > beteween python and C - who are we to judge the semantics of that > chimera? What do you mean? Aren't these: #include perfectly valid comments in Python? Followups redirected. -- Keith Thompson (The_Other_Keith) Nokia "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister" From alapidas at student.umass.edu Sat Apr 12 19:07:00 2008 From: alapidas at student.umass.edu (Andrew Lapidas) Date: Sat, 12 Apr 2008 19:07:00 -0400 Subject: PyGTK GUI update without signals from GUI Message-ID: Hi All: I am currently having a problem updating a GUI. I am using PyGTK and Glade to design an interface for a project. This interface contains no buttons, just images, labels, and a progress bar. The code for the project is small, and it basically does some things independent of the GUI in an infinite loop. I need the project code to update the GUI intermittently. I have found, though, that generally it seems that the gtk.main loop is looking for signals from the GUI and I cannot figure out how to give it signals from another application. I have thought spawning a new thread from the __init__ in the GUI and somehow having it send signals to gtk.main, but I do not know if this will work. Any opinions or ideas on this subject would be greatly appreciated. Thank you in advance, Andy From gagsl-py2 at yahoo.com.ar Sat Apr 5 01:15:10 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 05 Apr 2008 02:15:10 -0300 Subject: Pickle to Source - Gabriel Genellina? References: <163089.29394.qm@web65515.mail.ac4.yahoo.com> Message-ID: En Fri, 04 Apr 2008 22:47:47 -0300, $P!D3R DelSol escribi?: > I found this 3 year old message asking about doing the same exact thing > I am trying to do. This is one wheel I REALLY don't want to re-invent. > Can anyone point me to code that does this? > >> I want to convert from pickle format to python source code. That is, >> given an existing pickle, I want to produce a textual representation >> which, when evaluated, yields the original object (as if I had >> unpickled the pickle). See the answer from J P Calderone on that thread about aot in Twisted, that's the only thing I know of. I finally used an XML representation, somewhat legible by humans. -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Wed Apr 23 23:39:10 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 24 Apr 2008 00:39:10 -0300 Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> <56ebf54a-3a60-433f-b073-81963d9f1007@l64g2000hse.googlegroups.com> Message-ID: En Wed, 23 Apr 2008 08:43:56 -0300, Paul Boddie escribi?: > On 23 Apr, 11:12, Mark Wooding wrote: >> Gabriel Genellina wrote: >> > Because Python doesn't follow the "boxed variables" model. >> >> Be careful here. `Boxed types' or `boxed objects' is a technical term >> essentially meaning `heap-allocated objects, probably with reference >> semantics', which Python most definitely does use -- so this almost >> means the opposite of what you're talking about. > > I think Gabriel meant "variables as boxes" - the classic description > of variables in "old school" programming languages, which is in > contrast to the "variables as labels" model used by Python. Yes, I used the wrong expression here. Paul is right, I was thinking of "variables" as a "box" with a label written on it, and a value inside. That model is not valid in Python. -- Gabriel Genellina From urquhart.nak at gmail.com Wed Apr 30 06:27:29 2008 From: urquhart.nak at gmail.com (urquhart.nak at gmail.com) Date: Wed, 30 Apr 2008 03:27:29 -0700 (PDT) Subject: avg crack Message-ID: <60601d36-a21d-4b55-bce6-8c5525d32589@z24g2000prf.googlegroups.com> avg crack http://crack.cracksofts.com From sturlamolden at yahoo.no Thu Apr 17 12:48:42 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 17 Apr 2008 09:48:42 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> <87tzi05vrm.fsf@mulj.homelinux.net> Message-ID: On Apr 17, 5:46 pm, Hrvoje Niksic wrote: > Have you tackled the communication problem? The way I see it, one > interpreter cannot "see" objects created in the other because they > have separate pools of ... everything. They can communicate by > passing serialized objects through ctypes, but that sounds like the > solutions that use processes. I see two solutions to that. It is possible to use fine-grained locking on the objects that need to be communicated. ctypes can pass PyObject* pointers (ctypes.py_object), or we could resort to some C. When interpreter A get a PyObject* pointer from B (a total of four bytes on my computer), interpreter A can: (1) Acquire B's GIL (2) Increment the refcount of the PyObject* (3) Release B's GIL (4) Use the object as its own (synchronization is required) Sharing PyObject* pointer has the possibility of shooting your leg off. But I believe the small quirks can be worked out. The other option is to use serialized Queues like the processing module in cheese shop. I don't think it will be faster than similar mechanisms based on IPC, because object serialization and deserialization are the more expensive parts. From gherron at islandtraining.com Mon Apr 28 14:31:25 2008 From: gherron at islandtraining.com (Gary Herron) Date: Mon, 28 Apr 2008 11:31:25 -0700 Subject: list.reverse() In-Reply-To: References: Message-ID: <481617FD.7030702@islandtraining.com> Mark Bryan Yu wrote: > This set of codes works: > > >>>> x = range(5) >>>> x.reverse() >>>> x >>>> > [4, 3, 2, 1, 0] > > But this doesn't: > > >>>> x = range(5).reverse() >>>> print x >>>> > None > > Please explain this behavior. range(5) returns a list from 0 to 4 and > reverse just reverses the items on the list that is returned by > range(5). Why is x None (null)? > -- > http://mail.python.org/mailman/listinfo/python-list > Because you are misusing reverse. It is an operation on a list that reverses the list in place. It is meant to be used only in the situation where you already have the list and want to reorder it: x = .... list ... x.reverse() # reorders, but returns nothing ... now use x ... You might look at the builtin reversed(list): http://www.python.org/doc/faq/programming/#how-do-i-iterate-over-a-sequence-in-reverse-order Gary Herron From sjmachin at lexicon.net Thu Apr 17 19:50:18 2008 From: sjmachin at lexicon.net (John Machin) Date: Thu, 17 Apr 2008 23:50:18 GMT Subject: get quote enclosed field in a line In-Reply-To: References: Message-ID: <4807e238$1@news.mel.dft.com.au> xahlee at gmail.com wrote: > is there a simple way in perl, python, or awk/shell/pipe, that gets > the user agent field in a apache log? > > e.g. the typical line is like this: > > 189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET / > Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org > "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/ > 5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311 > Firefox/2.0.0.13" "-" > > I want the part: "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv: > 1.8.1.13) Gecko/20080311 Firefox/2.0.0.13". > C:\junk>type xah.py import cStringIO, csv, pprint line = '''189.139.109.235 - etc etc etc''' f = cStringIO.StringIO(line) reader = csv.reader(f, delimiter=" ") row = reader.next() pprint.pprint(row) C:\junk>xah.py ['189.139.109.235', '-', '-', '[07/Apr/2008:00:00:16', '-0400]', 'GET / Periodic_dosage_dir/lacru/manara.html HTTP/1.1', '200', '1933', 'xahlee.org', 'http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311 Fi refox/2.0.0.13', '-'] If you don't like that, just hang about -- there's sure to be a pyparsing bus coming by real soon now :-) Cheers, John From bhawsar.vaibhav at gmail.com Fri Apr 25 13:16:11 2008 From: bhawsar.vaibhav at gmail.com (Vaibhav.bhawsar) Date: Fri, 25 Apr 2008 13:16:11 -0400 Subject: how to mysqldb dict cursors In-Reply-To: References: <17d58cc40804241950i7b624e1apd2733daa79b3ed5c@mail.gmail.com> <481161FD.5020407@ulmcnett.com> <17d58cc40804242358s26446c42h36f875cf0ee62199@mail.gmail.com> Message-ID: <17d58cc40804251016x7fc0f2far816c0bb09bbebd80@mail.gmail.com> Hmm that explains it! Thank you. v On Fri, Apr 25, 2008 at 7:38 AM, Steve Holden wrote: > Vaibhav.bhawsar wrote: > [top-posting amended: see below] > >> On Fri, Apr 25, 2008 at 12:45 AM, Paul McNett

> p at ulmcnett.com>> wrote: >> >> Vaibhav.bhawsar wrote: >> >> I have been trying to get the DictCursor working with mysqldb >> module but can't seem to. I have pasted the basic connection >> code and the traceback from pydev. The connection does open with >> the default cursor class. can't figure this one out. many thanks. >> >> >> Try one of: >> >> """ >> import MySQLdb, MySQLdb.cursors >> conn = MySQLdb.connect(..., cursorclass=MySQLdb.cursors.DictCursor) >> """ >> >> -or- >> >> """ >> import MySQLdb, MySQLdb.cursors >> conn = MySQLdb.connect(...) >> cur = MySQLdb.cursors.DictCursor(conn) >> """ >> >> I'm going off of memory here, though, but I'm at least close. >> >> > Great both methods worked! I don't quite understand this since i > imported > > the whole module with "import MySQLdb" > > > > Thanks! > > > The point here is that MySQLdb is a package, not a module. Some packages > have their top-level __init__.py import the package's sub-modules or > sub-packages to make them immediately available within the package namespace > (which is why, for example, you can access os.path.* when you have imported > os) and others don't. > > MySQLdb clearly doesn't need to import the cursors module for its own > purposes. Perhaps it would be less efficient to always perfrom the import, > who knows. Well, Andy Dustman does, I suppose, and possibly anyone else who > reads the code, but I haven't done that myself. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Vaibhav Bhawsar -------------- next part -------------- An HTML attachment was scrubbed... URL: From frikker at gmail.com Wed Apr 30 10:19:49 2008 From: frikker at gmail.com (blaine) Date: Wed, 30 Apr 2008 07:19:49 -0700 (PDT) Subject: list.reverse() References: <4816e26a$0$30938$426a74cc@news.free.fr> <98c4ad4d-3174-40cd-b281-84e318d699d3@24g2000hsh.googlegroups.com> Message-ID: On Apr 29, 8:51 pm, Roy Smith wrote: > In article > <98c4ad4d-3174-40cd-b281-84e318d69... at 24g2000hsh.googlegroups.com>, > > blaine wrote: > > Check out this cool little trick I recently learned: > > >>> x=range(5) > > >>> x.reverse() or x > > [4, 3, 2, 1, 0] > > > Useful for returning lists that you need to sort or reverse without > > wasting that precious extra line :) > > > What it does: x.reverse() does the reverse and returns None. or is > > bitwise, so it sees that 'None' is not 'True' and then continues to > > process the next operand, x. x or'd with None will always be x (and x > > has just been changed by the reverse()). So you get the new value of > > x :) > > Please don't do that in any code I have to read and understand. Cool > little tricks have no place in good code. > > >>> x = range(5) > >>> x.reverse() > >>> x > > [4, 3, 2, 1, 0] > > does the same thing, and it a lot easier to understand. I buy my newlines > in the big box at Costo, so I don't mind using a few extra ones here or > there. haha true - i usually don't use shortcuts, it kind of defeats the purpose of the readability of python :) From Robert.Bossy at jouy.inra.fr Mon Apr 7 12:55:14 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Mon, 07 Apr 2008 18:55:14 +0200 Subject: reading dictionary's (key,value) from file In-Reply-To: <974814d3-59f0-49ec-9b4d-9f5dd7dfaf54@q24g2000prf.googlegroups.com> References: <974814d3-59f0-49ec-9b4d-9f5dd7dfaf54@q24g2000prf.googlegroups.com> Message-ID: <47FA51F2.2040101@jouy.inra.fr> ankitks.mital at gmail.com wrote: > Folks, > Is it possible to read hash values from txt file. > I have script which sets options. Hash table has key set to option, > and values are option values. > > Way we have it, we set options in a different file (*.txt), and we > read from that file. > Is there easy way for just reading file and setting options instead of > parsing it. > > so this is what my option files look like: > > 1opt.txt > { '-cc': '12', > '-I': r'/my/path/work/'} > > 2opt.txt > { '-I': r/my/path/work2/'} > > so my scipt how has dictionary > options = { '-cc' :'12' > '-I': r'/my/path/work/:/my/path/work2/'} > > I am trying to avoid parsing > For this particular case, you can use the optparse module: http://docs.python.org/lib/module-optparse.html Since you're obviously running commands with different set of options, I suggest you listen to Diez. Cheers, RB From soray6034rao at gmail.com Wed Apr 30 07:28:44 2008 From: soray6034rao at gmail.com (soray6034rao at gmail.com) Date: Wed, 30 Apr 2008 04:28:44 -0700 (PDT) Subject: the sims 2 crack Message-ID: the sims 2 crack http://crack.cracksofts.com From paul at science.uva.nl Tue Apr 29 07:18:32 2008 From: paul at science.uva.nl (Paul Melis) Date: Tue, 29 Apr 2008 13:18:32 +0200 Subject: SWIG Python undefined reference In-Reply-To: <23b925ce-cfa5-4a99-bad3-afcac09b645a@y21g2000hsf.googlegroups.com> References: <23b925ce-cfa5-4a99-bad3-afcac09b645a@y21g2000hsf.googlegroups.com> Message-ID: Instead of manually trying to get all the options to gcc correct you might want to look at using distutils for compiling your extension. See the SWIG documentation, section 30.2.2 (http://www.swig.org/Doc1.3/Python.html#Python_nn6) Paul Soren wrote: > Hi, > > I went through the SWIG tutorial for the example named "simple". > > I managed to get to the first step, creating example_wrap.c using > swig, and doing: > "gcc -fpic -c example_wrap.c -IC:\python24\include " to create > example_wrap.o > > But when I needed to compile the library file using: > "gcc -shared example_wrap.o -o examplemodule.so" I received a lot of > undefined reference compiler errors like: > > example_wrap.o(.text+0x35a5):example_wrap.c: undefined reference to > `_imp__PyErr > _SetString' > > there are many other similar errors all prefaced with _imp__Py, so I > am assuming there is a linker error with the python libraries. I have > adjusted my PATH variable to include all the python directories (libs/ > dlls). > > Does anyone here have any suggestions? > > FILES FROM TUTORIAL: > > > //example.c > #include > double My_variable = 3.0; > > int fact(int n) { > if (n <= 1) return 1; > else return n*fact(n-1); > } > > int my_mod(int x, int y) { > return (x%y); > } > > char *get_time() > { > time_t ltime; > time(<ime); > return ctime(<ime); > } > //*************************************************************** > > //example.i > %module example > %{ > /* Put header files here or function declarations like below */ > extern double My_variable; > extern int fact(int n); > extern int my_mod(int x, int y); > extern char *get_time(); > %} > > extern double My_variable; > extern int fact(int n); > extern int my_mod(int x, int y); > extern char *get_time(); > //*************************************************************** > > //setup.py > from distutils.core import setup, Extension > > setup(name='example', > version = '1.0', > ext_modules=[ > Extension('example', ['example.c', 'example.i']) > ]) From pavlovevidence at gmail.com Tue Apr 22 09:38:10 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 22 Apr 2008 06:38:10 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: On Apr 22, 6:25 am, azrael wrote: > Hy guys, > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. > > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" > > This hurts. Please give me informations about realy famous > aplications. Let me tell you a little story to let you know how you should act in situations like this. Some of you might have heard it before. Apologies if it's a bit long. There was once a young man who absolutely loved clowns. He always dreamed of meeting a clown, and laughing at their silly antics, but he lived in a rural small town and never got to see any. Then one day when the circus came to town. The young man was unbelievably excited, he was finally going to be able to see a clown! He camped out at the ticket booth and was the first in line to get a ticket, because he so loved clowns that he wanted to sit right up front. The yound man never had a better time in his life, watching all the clowns and their funny tricks. Then a young talented clown came out to work the crowd. He went right up to the young man, who couldn't believe his luck: a clown was doing his act with him! The clown asked the man, "Are you front end of an ass?" The young man said, "Um, no." Then the clown asked the man, "Are you the rear end of an ass?" The young man, a little confused, said, "No." Then the clown, with nearly perfect comedic timing, said, "Then you must be no end of an ass!" The crowd roared with laughter, but the young man was crushed. He couldn't believe that the clowns he adored so much could be so mean. He went home from the circus utterly distraught and humiliated, and soon fell into a deep depression. He eventually lost his job, then his home. He became a vagrant and spent his days living on the streets. The years passed by. One day, the now old man saw that the circus was coming back to town. And not only that, but the same clown who had humiliated him years ago was headlining the circus. It brought back terrible and long- suppressed memories, which he told to a social worker at the homeless shelter he was staying at. The social worker felt very moved by the old man's story, and told the old man, "You know, maybe you could overcome with your problems if you could face that clown again and give him his comeupance." The old man was horrified. After the incident he had developed an intense fear of clowns. Yet he somehow felt the social worker was right. "I'd like to do that," he said, "but what if the clown humilates me again?" "Don't worry," said the social worker, "I have the perfect retort." So the social worker and the old man bought front row seats to the circus. Within a few minutes, the old man was enjoying himself immensely. It was the best therapy he'd ever had, and the old man felt that after so many years he would finally be able to put his life back together. Until the final act. The same clown who had humiliated the old man many years before was now an old veteran on his final tour. The clown went right up to the old man and began to work the same routine. ("Don't worry," whispered the social worker to he old man as the clown approached, "I have perfect retort.") The clown asked the old man, "Are you front end of an ass?" The old man said, "No." Then the clown asked the old man, "Are you the rear end of an ass?" The old man, positively scared, meekly said, "No." Then the clown, with utterly perfect comedic timing, said, "Then you must be no end of an ass!" The crowd roared with laughter. The man was humiliated again. But the social winked at him, indicating that he would soon give the clown the perfect retort. The old man couldn't wait to hear what it was. Suddenly the social worker stood up and shouted, "Hey clown!" The crowd hushed, and clown whirled around to look at him. "F**k you!" (It makes even more sense when you consider that Perl programmers pretty much are clowns.) Carl Banks From upton at virginia.edu Wed Apr 16 15:06:55 2008 From: upton at virginia.edu (Dan Upton) Date: Wed, 16 Apr 2008 15:06:55 -0400 Subject: Interesting timing issue I noticed In-Reply-To: References: Message-ID: <5504f9ac0804161206tb4b0d0dl423176dddf70d6ce@mail.gmail.com> On Wed, Apr 16, 2008 at 2:54 PM, Gabriel Genellina wrote: > En Wed, 16 Apr 2008 10:36:14 -0300, Jonathan Shao > escribi?: > > *Gabriel Genellina* gagsl-py2 at yahoo.com.ar > > > > *Wed Apr 16 08:44:10 CEST 2008* > > >> Another thing would be to rearrange the loops so the outer one executes > > less times; if you know that borderX< > better to swap the inner and outer loops above. > > Thank you for the tip on xrange. > > Even if I swap the inner and outer loops, I would still be doing the same > > number of computations, am I right (since I still need to go through the > > same number of elements)? I'm not seeing how a loop swap would lead to > > fewer > > computations, since I still need to calculate the outer rim of elements > > in > > the array (defined by borderX and borderY). > > You minimize the number of "for" statements executed, and the number of > xrange objects created. Both take some time in Python. > > > import timeit > > f1 = """ > for i in xrange(10): > for j in xrange(1000): > i,j > """ > > f2 = """ > for j in xrange(1000): > for i in xrange(10): > i,j > """ > > print timeit.Timer(f1).repeat(number=1000) > print timeit.Timer(f2).repeat(number=1000) > > > Output: > [2.0405478908632233, 2.041863979919242, 2.0397852240997167] > [2.8623411634718821, 2.8330055914927783, 2.8361752680857535] > > The second (using the largest outer loop) is almost 40% slower than the > first one. "Simplified" Big-Oh complexity analysis isn't enough in cases > like this. > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > For large multidimensional arrays you may also see speed differences depending on traversal order due to cache effects. For instance, if the arrays are stored row-major, then processing an array a row at a time means you're getting a bunch of memory accesses contiguous in memory (so the cache loading a line at a time means you'll have several hits per one load), while accessing it by column means you'll probably have to go out to memory a lot (depending on whether the hardware has a prefetcher or how good it is, I suppose). Just something to consider. From marli305nugent at gmail.com Sat Apr 26 09:53:41 2008 From: marli305nugent at gmail.com (marli305nugent at gmail.com) Date: Sat, 26 Apr 2008 06:53:41 -0700 (PDT) Subject: xp password crack Message-ID: xp password crack http://cracks.00bp.com F R E E C R A C K S From python at bdurham.com Tue Apr 29 08:10:41 2008 From: python at bdurham.com (python at bdurham.com) Date: Tue, 29 Apr 2008 08:10:41 -0400 Subject: Given a string - execute a function by the same name Message-ID: <1209471041.12820.1250459017@webmail.messagingengine.com> Bruno, Thank you for your detailed analysis. I learned a lot about Python reading everyone's responses. For development I'm using #5: "globals().get("func")" because its seamless to add additional functionality. But when I release into production I'm going to shift to #3: "Place all my functions in dictionary and lookup the function to be called". This technique will allow me to precisely control the dynamic nature of my application. Thanks again to everyone who contributed on this thread. Regards, Malcolm From phil at riverbankcomputing.com Fri Apr 11 04:10:27 2008 From: phil at riverbankcomputing.com (Phil Thompson) Date: Fri, 11 Apr 2008 09:10:27 +0100 Subject: How is GUI programming in Python? In-Reply-To: References: <7xod8h39zu.fsf@ruckus.brouhaha.com> Message-ID: <200804110910.27091.phil@riverbankcomputing.com> On Friday 11 April 2008, David Cook wrote: > On 2008-04-10, Paul Rubin wrote: > > Well, it's a trade-off, the person wanted a cross platform gui and the > > #1 hurdle for something like PyQt4 is getting it to work on each of > > the platforms you desire to run on. > > Installing Pyqt on windows involves a couple "click to install" EXEs. On > Linux, one uses yum or apt. Only on Mac is it marginally a bit harder. > > Dave Cook Actually, on Windows it's only one .exe as the PyQt GPL binary installer includes Qt and all it's tools (and the eric IDE, and PyQwt). Phil From laurent.pointal at laposte.net Tue Apr 1 16:06:32 2008 From: laurent.pointal at laposte.net (Laurent Pointal) Date: 01 Apr 2008 20:06:32 GMT Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: <47f295c8$0$868$ba4acef3@news.orange.fr> Le Tue, 01 Apr 2008 12:35:46 -0700, Paddy a ?crit?: > On Apr 1, 6:27 pm, sprad wrote: >> >> I want to believe. Evangelize away. > > How proficient are you in Flash/Actionscript? I suggest you try out > Python/Pygame and extrapolate from that, given your available time, > would you be proficient enough to teach it? And if you want to do easy and simple 3D graphics programming, look at VPython http://www.vpython.org/ -- Laurent POINTAL - laurent.pointal at laposte.net From sashulika at gmail.com Sun Apr 6 08:38:37 2008 From: sashulika at gmail.com (LMZ) Date: Sun, 6 Apr 2008 05:38:37 -0700 (PDT) Subject: Form sha1.hexdigest to sha1.digest Message-ID: <7c39af89-9cee-428c-a0bc-8202700c5aec@b1g2000hsg.googlegroups.com> How can convert string from sha1.hexdigest() to string that is the same, like from sha1.digest() thanks for your help! Alexandr. From mccle27252 at gmail.com Mon Apr 21 03:53:30 2008 From: mccle27252 at gmail.com (mccle27252 at gmail.com) Date: Mon, 21 Apr 2008 00:53:30 -0700 (PDT) Subject: mystery case files huntsville 1.6 keygen Message-ID: <91f2262d-e941-41a8-87c5-e92e3b9eb3f1@i36g2000prf.googlegroups.com> mystery case files huntsville 1.6 keygen http://cracks.00bp.com F R E E C R A C K S From micro_passion at yahoo.com Fri Apr 25 08:30:18 2008 From: micro_passion at yahoo.com (micron_make) Date: Fri, 25 Apr 2008 05:30:18 -0700 (PDT) Subject: multiple pattern regular expression Message-ID: <16895148.post@talk.nabble.com> I am trying to parse a file whose contents are : parameter=current max=5A min=2A for a single line I used for line in file: print re.search("parameter\s*=\s*(.*)",line).groups() is there a way to match multiple patterns using regex and return a dictionary. What I am looking for is (pseudo code) for line in file: re.search("pattern1" OR "pattern2" OR ..,line) and the result should be {pattern1:match, pattern2:match...} Also should I be using regex at all here ? -rohit -- View this message in context: http://www.nabble.com/multiple-pattern-regular-expression-tp16895148p16895148.html Sent from the Python - python-list mailing list archive at Nabble.com. From bj_666 at gmx.net Sun Apr 20 05:37:13 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 20 Apr 2008 09:37:13 GMT Subject: ???Python Memory Management S***s??? References: Message-ID: <670h69F2m6j0tU1@mid.uni-berlin.de> On Sun, 20 Apr 2008 18:40:26 +1000, Hank @ITGroup wrote: > In order to evaluate the memory operation, I used the codes below: > > """ > > string1 = ['abcde']*999999 # this took up an obvious memory space... > > del string1 # this freed the memory > successfully !! Indirectly. ``del`` does not delete objects but just names, so you deleted the name `string1` and then the garbage collector kicked in and freed the list object as it was not reachable by other references anymore. > """ > For primary variants, the *del* thing works well. However, challenge the > following codes, using class-instances... > > """ > > from nltk import FreqDist # nltk stands for Natural Language Tool > Kit (this is not an advertisement ~_~) > > instance = FreqDist() > > instanceList = [instance]*99999 > > del instanceList # You can try: nothing is freed by this > """ How do you know this? And did you spot the difference between 999999 and 99999!? Are you aware that both lists contain many references to a *single* object, so the memory consumption has very little to do with the type of object you put into the list? In the second case you still hold a reference to that single instance though. Ciao, Marc 'BlackJack' Rintsch From grante at visi.com Sun Apr 20 20:07:28 2008 From: grante at visi.com (Grant Edwards) Date: Sun, 20 Apr 2008 19:07:28 -0500 Subject: replacing text inplace References: Message-ID: <5tqdnSsck5hdR5bVnZ2dnUVZ_j-dnZ2d@visi> On 2008-04-20, Matt Herzog wrote: > I'm learning some python with the seemingly simple task of > updating a firewall config file with the new IP address when > my dhcpd server hands one out. Yeah, I know it's dangerous to > edit such a file "in place" I don't see how what you're doing is editing a file "in place". > but this is just an exercise at this point. I would not mind > using file handles except they seem to add complexity. Do you mean file objects? > The only apparent problem I have with my script so far is that > it's adding lots of blank lines to the file when it updates > the IP addresses. When you do this: for line in inputfile: Each instance of 'line' has a newline at the end of it. When you do this: print line The print operation adds another newline. Try it this way: print line, The comma tells print not to append a newline after it has printed "line". > So "71.146.250.258" needs to change to "71.146.250.223" or something similar. > > Is there a saner, cleaner way to do this that won't add new, > blank lines? sed -i s/71.146.250.258/71.146.250.223/g filename I suppose one probably should escape the dots in the input regex... -- Grant Edwards grante Yow! With YOU, I can be at MYSELF ... We don't NEED visi.com Dan Rather ... From gert.cuykens at gmail.com Wed Apr 30 07:04:45 2008 From: gert.cuykens at gmail.com (gert) Date: Wed, 30 Apr 2008 04:04:45 -0700 (PDT) Subject: ssh References: <867f5bc7-3748-4303-9f29-9d8044f0d315@m3g2000hsc.googlegroups.com> Message-ID: Eric Wertman wrote: > >from popen2 import Popen3 > >def ssh(host,command) : > ''' Wraps ssh commands ''' > ssh_exec = ['/usr/bin/ssh -qnx -F ssh_config', host, command] > cmd = ' '.join(ssh_exec) > output,errors,status = process(cmd) > return output,errors,status > >def process(cmd) : > proc = Popen3(cmd,-1) > output = proc.fromchild.readlines() > errors = proc.childerr.readlines() > status = proc.poll() > return output,errors,status thanks, what happens with the ssh connection after def process(cmd) is done Do i not need to remove the 'else' for it to work ? Also can i execute multiple commands at once ? import os, time def ssh(user, rhost, pw, cmd): pid, fd = os.forkpty() if pid == 0: os.execv("/bin/ssh", ["/bin/ssh", "-l", user, rhost] + cmd) time.sleep(0.2) os.read(fd, 1000) time.sleep(0.2) os.write(fd, pw + "\n") time.sleep(0.2) res = '' s = os.read(fd, 1) while s: res += s s = os.read(fd, 1) return res print ssh('username', 'serverdomain.com', 'Password', ['ls -l']) From fairwinds at eastlink.ca Mon Apr 7 01:32:01 2008 From: fairwinds at eastlink.ca (David Pratt) Date: Mon, 07 Apr 2008 02:32:01 -0300 Subject: Help replacing os.system call with subprocess call Message-ID: <47F9B1D1.4090701@eastlink.ca> Hi. I am trying to replace a system call with a subprocess call. I have tried subprocess.Popen and subprocess.call with but have not been successful. The command line would be: svnadmin dump /my/repository > svndump.db This is what I am using currently: os.system('svnadmin dump %s > %s' % (svn_dir, os.path.join(backup_dir, 'svndump.db'))) Many thanks. From bressert at gmail.com Wed Apr 16 02:45:18 2008 From: bressert at gmail.com (eli) Date: Tue, 15 Apr 2008 23:45:18 -0700 (PDT) Subject: subplot function in matplotlib Message-ID: <368ac3ca-ed20-494d-9f09-00d06701857d@k37g2000hsf.googlegroups.com> Does anyone know a workaround to plotting beyond 9 subplots in matplotlib? It would be nice to have 20 plots under the subplot function for example (poster). Cheers, Eli From cokofreedom at gmail.com Wed Apr 2 09:19:08 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Wed, 2 Apr 2008 06:19:08 -0700 (PDT) Subject: who said python can't be obsfucated!? Message-ID: def s(c):return[]if c==[]else s([_ for _ in c[1:]if _=c[0]]) Anyone else got some wonders...? From steve at holdenweb.com Fri Apr 25 00:37:11 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 25 Apr 2008 00:37:11 -0400 Subject: Installation in a local directory In-Reply-To: <2008042500101716807-seanmmcdaniel@gmailcom> References: <2008042500101716807-seanmmcdaniel@gmailcom> Message-ID: Sean McDaniel wrote: > Hi y'all, > > I'm trying to perform a local install of python at work in my user > directory. Everything compiles correctly, but I can't seem to tell the > configure script the location of the bin and lib directories where I > want my stuff. I've think I've passed the correct flags to the > 'configure' script. > > make clean > ./configure --enable-shared --prefix=/user/mcdaniel/arch32 > make > > where arch32 contains the the lib and bin directories where I want my > python stuff to go. Unfortunately these directories are not written to; > everything ends up in the default location from where I ran 'make'. > Moreover, if I add a symbolic link from the python binary (which I can > run directly without problems) to the bin directory so that my PATH will > recognize the new python, I get an error about loading shared libraries. > > I'm making on a 32 bit new debian system. > > Thank you for your help, > Did you run "make install" yet? It's that step that moves the binaries to where they should live. As it says in http://www.python.org/download/releases/2.5/ """Change to the Python-2.5 directory and run the "./configure", "make", "make install" commands to compile and install Python.""" regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bikthh at live.cn Sun Apr 13 03:18:14 2008 From: bikthh at live.cn (bikthh at live.cn) Date: Sun, 13 Apr 2008 00:18:14 -0700 (PDT) Subject: =?GB2312?B?09DW0Ln6yMu69T8=?= Message-ID: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> Python????????????????. From sturlamolden at yahoo.no Sun Apr 20 20:35:31 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sun, 20 Apr 2008 17:35:31 -0700 (PDT) Subject: Nested lists, simple though References: Message-ID: On Apr 21, 12:25 am, Zethex wrote: > Anyway the amount of [[]] do increase over time. You can flatten a nested list using a closure and recursion: def flatten(lst): tmp = [] def _flatten(lst): for elem in lst: if type(elem) != list: tmp.append(elem) else: _flatten(elem) _flatten(lst) return tmp However, CPython does not recurse very fast, but Cython and Pyrex do. First, get rid of the closure, it is not supported in Cython or Pyrex (at least not yet). Then change the recursive function to a cdef, i.e. a normal C function which is called without the overhead of Python's attribute lookup: cdef _flatten(lst, tmp): for elem in lst: if type(elem) != list: tmp.append(elem) else: _flatten(elem, tmp) def flatten(lst): tmp = [] _flatten(lst, tmp) return tmp Compile this with Cython or Pyrex, and you get a very fast nested list flattener. This also shows how easy it is to boost the performance of Python code using Cython. From bdsatish at gmail.com Fri Apr 11 00:28:36 2008 From: bdsatish at gmail.com (bdsatish) Date: Thu, 10 Apr 2008 21:28:36 -0700 (PDT) Subject: Integer dicision Message-ID: <5f499bee-a659-4e36-870c-076cb613a3e7@t12g2000prg.googlegroups.com> How does (a/b) work when both 'a' and 'b' are pure integers ? >> (9/2) 4 >> (-9/2) -5 Why is it -5 ? I expect it to be -4 ? Because, in C/C++, 9/2 is 4 and so negative of it, (-9/2) is -4. What should I do to get C-like behavior ? From Lie.1296 at gmail.com Tue Apr 29 18:19:32 2008 From: Lie.1296 at gmail.com (Lie) Date: Tue, 29 Apr 2008 15:19:32 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <2d06b319-e2fd-4790-af61-6f90b9b1b3b1@m1g2000pre.googlegroups.com> <41e72e61-6413-41f3-a162-dbcc1ec5fcee@f63g2000hsf.googlegroups.com> Message-ID: On Apr 28, 2:14?am, n00m wrote: > Lie wrote: > > On Apr 27, 6:28?am, n00m wrote: > > > No so simple, guys. > > > E.g., I can't solve (in Python) this:http://www.spoj.pl/problems/INTEST/ > > > Keep getting TLE (time limit exceeded). Any ideas? After all, it's > > > weekend. > > > > 450. Enormous Input Test > > > Problem code: INTEST > > > > The purpose of this problem is to verify whether the method you are > > > using to read input data is sufficiently fast to handle problems > > > branded with the enormous Input/Output warning. You are expected to be > > > able to process at least 2.5MB of input data per second at runtime. > > > > Input > > > The input begins with two positive integers n k (n, k<=107). The next > > > n lines of input contain one positive integer ti, not greater than > > > 109, each. > > > > Output > > > Write a single integer to output, denoting how many integers ti are > > > divisible by k. > > > > Example > > > Input: > > > 7 3 > > > 1 > > > 51 > > > 966369 > > > 7 > > > 9 > > > 999996 > > > 11 > > > > Output: > > > 4 > > > The problem is faulty. > > First, the bottleneck on reading a huge input is the harddisk speed > > and the string processing, the result of the competition doesn't prove > > anything but how fast the string processor and the harddisk is. > > Python's string processing is not a very fast one as it creates a copy > > of the string every now and then. > > In case you didn't pay attention: > Python and C++ were tested on the same PC. In case you didn't pay attention, what I'm mainly concerned about is running the same algorithm in the same machine in the same programming language but in different phase of the moon that would give two significantly different timing. Harddisk seek time is based on harddisk's fragmentation, MFT's (or equivalent) size, what "other" program are currently doing with the harddisk, and by harddisk age. You can't avoid fragmentation, except if you ghosted the harddisk and reinstall the OS after every test. You can't prevent the OS to switch to other tasks while the test is running they might possibly requested for a huge harddisk query. And I'm sure you can't prevent hardware degradation (although the impact of this is probably not significant). Heck I can go on to other phases of the moon like how full and fragmented the memory (RAM) is, how much swap is being used. My secondary concern, is how the string processing is done in the language. In python, every string operation creates a new string, in C, a string processing is just a mere address passing, for this test, the security given by python is unnecessary since it is read only. We know which one is the more superior in speed, but we can't do anything about this since this is implementation detail of the language. From van.lindberg at gmail.com Thu Apr 24 18:37:06 2008 From: van.lindberg at gmail.com (VanL) Date: Thu, 24 Apr 2008 17:37:06 -0500 Subject: Billing system written in python In-Reply-To: <40847e660804240833q4e4210dyb8a561899635fb77@mail.gmail.com> References: <40847e660804240833q4e4210dyb8a561899635fb77@mail.gmail.com> Message-ID: <48110B92.4070609@gmail.com> AC Perdon wrote: > I was thinking of using django but Im more looking in to a > ready made billing system that I will just do some tweaking and fine > tunning to meet our need. like jbilling. Look at Fivedash (fivedash.com), it may be what you need. From rridge at caffeine.csclub.uwaterloo.ca Fri Apr 18 21:36:05 2008 From: rridge at caffeine.csclub.uwaterloo.ca (Ross Ridge) Date: Fri, 18 Apr 2008 21:36:05 -0400 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> Message-ID: Ross Ridge said: > If you have Python 2.5, here's a faster version: > > from struct import * > unpack_i32be = Struct(">l").unpack > > def from3Bytes_ross2(s): > return unpack_i32be(s + "\0")[0] >> 8 Bob Greschke wrote: > That's not even intelligible. I wanna go back to COBOL. :) It's the same as the previous version except that it "precompiles" the struct.unpack() format string. It works similar to the way Python handles regular expressions. Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] rridge at csclub.uwaterloo.ca -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // From rustompmody at gmail.com Sun Apr 27 23:40:26 2008 From: rustompmody at gmail.com (rustom) Date: Sun, 27 Apr 2008 20:40:26 -0700 (PDT) Subject: diffing and uniqing directories References: <67ioqmF2nvf5vU2@mid.uni-berlin.de> Message-ID: On Apr 27, 11:29?pm, "telus news" wrote: > Just so happens that I am partially finished a gui file backup app. I have > many backup CDs and I wanted to consolidate them. You know, all image files > in one dir, all install files in another dir, etc. My app scans the input > dir tree and displays all file extensions that it finds. You can then remove > any extensions that you don't want backed-up, and you can toggle to exclude > the listed extensions. It also calculates min/max file sizes that you can > adjust. I guess what I am looking for is a merge app more than a backup app. > > Then the next page allows you to adjust the sub-dir depth with a slider, > which displays the total number of files and total amount of memory they > will take, for each sub-dir depth. You can also choose to enable versioning, > whether or not to put all files into one dir or create a dir for each file > type (extension), whether or not to actually backup the files, to write all > input pathnames and/or output pathnames to a file. Of course, it won't > backup a dir tree as a copy, it can only flatten a dir tree, That wont do for me. > so if you > backup a development source dir, all files will get put into the same dir > and that wouldn't be good. > > I've also used py2exe to make it a drag-n-drop install. What do you think? Im working (mostly) on linux From wizzardx at gmail.com Tue Apr 15 16:02:55 2008 From: wizzardx at gmail.com (David) Date: Tue, 15 Apr 2008 22:02:55 +0200 Subject: Recurring patterns: Am I missing it, or can we get these added to the language? In-Reply-To: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: <18c1e6480804151302j2b6a981cs1f880c09520bd17c@mail.gmail.com> > Today I found myself once again defining two functions that I use all > the time: nsplit and iterable. These little helper functions of mine > get used all the time when I work. Im sick of having to define them > (but am very good at it these days, less than 1 typo per function!). > It leads me to the following questions How about creating an erichtools module? From gagsl-py2 at yahoo.com.ar Fri Apr 11 16:29:03 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 11 Apr 2008 13:29:03 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> Message-ID: On 11 abr, 15:33, Lie wrote: > On Apr 11, 10:19 pm, Mikael Olofsson wrote: > > That's exactly how I was taught to do rounding in what-ever low-level > > class it was. The idea is to avoid a bias, which assumes that the > > original values are already quantized. Assume that we have values > > quantized to one decimal only, and assume that all values of this > > decimal are equally likely. Also assume that the integer part of our > > numbers are equally likely to be even or odd. Then the average rounding > > error when rounding to integers will be 0.05 if you always round up when > > the decimal is 5. If you round towards an even number instead when the > > decimal is 5, then you will round up half of those times, and round down > > the other half, and the average rounding error will be 0. That's the > > idea. Of course you could argue that it would be even more fair to make > > the choice based on the tossing of a fair coin. > > That old-school rounding method you're taught is based on a wrong > assumption of the nature of number. In the past, rounding algorithm is > based on this: > > Original => (RoundUp(u|d|n), RoundNearestEven(u|d|n) > ... > 1.0 => 1(n), 1(n) > 1.1 => 1(d), 1(d) > 1.2 => 1(d), 1(d) > 1.3 => 1(d), 1(d) > 1.4 => 1(d), 1(d) > 1.5 => 2(u), 2(u) > 1.6 => 2(u), 2(u) > 1.7 => 2(u), 2(u) > 1.8 => 2(u), 2(u) > 1.9 => 2(u), 2(u) > 2.0 => 2(n), 2(n) > 2.1 => 2(d), 2(d) > 2.2 => 2(d), 2(d) > 2.3 => 2(d), 2(d) > 2.4 => 2(d), 2(d) > 2.5 => 3(u), 2(d) > 2.6 => 3(u), 3(u) > 2.7 => 3(u), 3(u) > 2.8 => 3(u), 3(u) > 2.9 => 3(u), 3(u) > ... > > In this used-to-be-thought-correct table, Round Ups algorithm have 2 > Unrounded, 8 Round Down, and 10 Round Ups which seems incorrect while > Round Even have 2 Unrounded, 9 Round Down, and 9 Round Up which seems > correct. The misunderstanding comes from a view that thinks that there > is such thing as Not Rounded while in fact the only number that is Not > Rounded is 1 and 2 while 1.0 and 2.0 must still be rounded, in > practice we can just say that all number must be rounded somewhere. That's not correct. If the numbers to be rounded come from a measurement, the left column is not just a number but the representant of an interval (as Mikael said, the're quantized). 2.3 means that the measurement was closer to 2.3 than to 2.2 or 2.4 - that is, [2.25, 2.35) (it doesn't really matter which side is open or closed). It is this "interval" behavior that forces the "round-to-even-on-halves" rule. So, the numbers 1.6-2.4 on the left column cover the interval [1.55, 2.45) and there is no doubt that they should be rounded to 2.0 because all of them are closer to 2.0 than to any other integer. Similarly [2.55, 3.45) are all rounded to 3. But what to do with [2.45, 2.55), the interval represented by 2.5? We can assume a uniform distribution here even if the whole distribution is not (because we're talking of the smallest measurable range). So half of the time the "true value" would have been < 2.5, and we should round to 2. And half of the time it's > 2.5 and we should round to 3. Rounding always to 3 introduces a certain bias in the process. Rounding randomly (tossing a coin, by example) would be fair, but people usually prefer more deterministic approaches. If the number of intervals is not so small, the "round even" rule provides a way to choose from that two possibilities with equal probability. So when we round 2.5 we are actually rounding an interval which could be equally be rounded to 2 or to 3, and the same for 3.5, 4.5 etc. If the number of such intervals is big, choosing the even number helps to make as many rounds up as rounds down. If the number of such intervals is small, *any* apriori rule will introduce a bias. > > Note that if you do not have quantized values and assuming that the > > fraction part is evenly distributed between 0 and 1, than this whole > > argument is moot. The probability of getting exactly 0.5 is zero in that > > case, just as the probability of getting any other specified number is zero. > > Another mistake, in an unquantized value the probability of getting > exactly 0.5 (or any other number specified) is not 0 but an > infinitesimal (i.e. lim(x) where x -> 0 (BUT NOT ZERO)) That limit IS zero. And the probability of getting exactly a certain real number, or any finite set of real numbers, is zero too (assuming the usual definition of probability over infinite sets). But we're not actually talking about real numbers here. -- Gabriel Genellina From lists at cheimes.de Tue Apr 29 19:48:42 2008 From: lists at cheimes.de (Christian Heimes) Date: Wed, 30 Apr 2008 01:48:42 +0200 Subject: Sending Cntrl-C ?? In-Reply-To: References: <0274834e-17e1-4a95-88ec-f2aa77aeb3a9@k10g2000prm.googlegroups.com> Message-ID: gamename schrieb: > Thanks, Christian. Would that work on win32 as well? No, Windows doesn't support the same, rich set of signal as Unix OSes. Christian From pavlovevidence at gmail.com Wed Apr 16 18:02:03 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Wed, 16 Apr 2008 15:02:03 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> Message-ID: On Apr 16, 12:40 pm, Aaron Watters wrote: > On Apr 16, 12:27 pm, Rhamphoryncus wrote: > > > On Apr 16, 6:56 am, Aaron Watters wrote: > > > > I don't get it. It ain't broke. Don't fix it. > > > So how would you have done the old-style class to new-style class > > transition? > > I'd ignore it. I never understood it and never had > any need for it anyway. New-style classes and metaclasses > were a complicated solution to an unimportant problem in > my opinion. And also a fiendish way to make code > inscrutible -- which I thought was more of a Perl thing > than a Python thing, or should be. > > I must be missing some of the deeper issues here. Please > educate me. The deeper issue is that you're benefiting from these "unimportant" changes even if you never use them yourself. Carl Banks From gagsl-py2 at yahoo.com.ar Mon Apr 14 21:50:07 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 14 Apr 2008 22:50:07 -0300 Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> Message-ID: En Mon, 14 Apr 2008 22:02:38 -0300, Sverker Nilsson escribi?: > I tried out py3k on my project, http://guppy-pe.sf.net And what happened? I've seen that your project already supports Python 2.6 so the migration path to 3.0 should be easy. -- Gabriel Genellina From bskaplan14 at yahoo.com Sun Apr 13 13:11:18 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Sun, 13 Apr 2008 10:11:18 -0700 (PDT) Subject: Module to read input from commandline Message-ID: <823886.56858.qm@web39208.mail.mud.yahoo.com> Unless I misunderstand your needs, you could just use raw_input(prompt) to get your answers. ----- Original Message ---- From: "james at reggieband.com" To: python-list at python.org Sent: Sunday, April 13, 2008 11:12:06 AM Subject: Module to read input from commandline Hi all, I did some quick searching but I haven't found anything like I want. It probably has to do with the terms I am searching for so if I describe what I want then I hope someone can point me to a good module. I want to take input from the user at the command line. e.g.) Would you like to continue [Y/n]: y What is your favorite color: green .... You get the idea. Basic question answer stuff. It should handle default options, case insensitivity, etc. Perhaps the module would compare the inputted text against a regexp for validation. If the module had an interface similar to OptParse that would be nice. Anyone know of a decent module that handles this type of thing? Writing from scratch would be simple but why re-invent the wheel. Cheers, James. -- http://mail.python.org/mailman/listinfo/python-list __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From deets at nospam.web.de Tue Apr 22 08:33:07 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 14:33:07 +0200 Subject: Does Python 2.5 include or not include SQLite engine? In-Reply-To: References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> Message-ID: <67648mF2mqc8pU2@mid.uni-berlin.de> python at bdurham.com schrieb: > While reading feedback to my post "Does Python 2.5.2's embedded SQLite > support full text searching?" I noticed that there appears to be some > confusion regarding whether Python 2.5 includes the SQLite engine. > > My Windows 2.5.2 binary download includes SQLite. > > But other posters claim otherwise, re: Linux releases of Python 2.5? > > I thought one of the major features of Python 2.5 was its embedded > SQLite engine. > > Thoughts? It is embedded. Period. You can install the pysqlite wrapper additionally, if you need a newer/differen sqlite version. It will be available as a different module, though. Diez From tgrav at mac.com Tue Apr 1 12:35:54 2008 From: tgrav at mac.com (Tommy Grav) Date: Tue, 1 Apr 2008 12:35:54 -0400 Subject: Homework help In-Reply-To: <8e1f6963-1cdd-4afe-9ea5-f1886ed452ab@d21g2000prf.googlegroups.com> References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> <7xfxu5ft1s.fsf@ruckus.brouhaha.com> <8e1f6963-1cdd-4afe-9ea5-f1886ed452ab@d21g2000prf.googlegroups.com> Message-ID: <217C141C-F7F2-480B-BC74-12BE90FB5EBA@mac.com> On Apr 1, 2008, at 12:29 PM, bobby.connor at gmail.com wrote: > On Apr 1, 12:17 pm, Paul Rubin wrote: >> bobby.con... at gmail.com writes: >>> I don't necessarily want the answers, but need help on how to >>> approach >>> it/the steps i need to solve the problems >> >> What parts are you having difficulty with? Are there some course >> materials and have you read them yet? > > I just don't know how to start the problems off How about reading the course material and then firing up python and trying some code. When you have done that and have questions regarding your code you are more than welcome back with questions. Cheers TG From bj_666 at gmx.net Wed Apr 2 14:02:18 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 2 Apr 2008 18:02:18 GMT Subject: Understanding bmp image files References: <2537c458-b4d5-480d-8407-168a2b59a27e@u10g2000prn.googlegroups.com> Message-ID: <65i01aF2embp3U1@mid.uni-berlin.de> On Wed, 02 Apr 2008 10:51:39 -0700, pranav wrote: > I want to read a BMP file, do some processing and then write it in a > new file. The problem is in the third step. For reading the file, i > have converted the file into decimal numbers, representing the pixel > values. You have converted the data into numbers, not "decimal" numbers. > Then i perform calculations on those decimal numbers. Now i am > unable to convert those into the format as required by the "bmp" file. > Any one, who is into image reading/manipulation, please help. How have you converted the bytes into numbers and why can't you reverse that step? Ciao, Marc 'BlackJack' Rintsch From marli305nugent at gmail.com Sat Apr 26 09:51:29 2008 From: marli305nugent at gmail.com (marli305nugent at gmail.com) Date: Sat, 26 Apr 2008 06:51:29 -0700 (PDT) Subject: norton internet security 2006 crack Message-ID: <44fe8d34-a889-406b-9c00-0db7fe3c3bc4@t54g2000hsg.googlegroups.com> norton internet security 2006 crack http://cracks.00bp.com F R E E C R A C K S From sjmachin at lexicon.net Fri Apr 25 08:38:22 2008 From: sjmachin at lexicon.net (John Machin) Date: Fri, 25 Apr 2008 05:38:22 -0700 (PDT) Subject: problem with unicode References: <26fcc207-b864-42c7-afb3-c6945e5fe29f@m44g2000hsc.googlegroups.com> Message-ID: <160a3724-fa7c-403b-bde7-981797ab3205@j33g2000pri.googlegroups.com> On Apr 25, 9:15 pm, "andreas.prof... at googlemail.com" wrote: > Hi everybody, > > I'm using the win32 console and have the following short program > excerpt > > # media is a binary string (mysql escaped zipped file) > > >> print media > > x???[? ... > (works) > > >> print unicode(media) > > UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position > 1: ordinal not in range(128) > (ok i guess print assumes you want to print to ascii) Guessing is no substitute for reading the manual. print has nothing to do with your problem; the problem is unicode(media) -- as you specified no encoding, it uses the default encoding, which is ascii [unless you have been mucking about, which is not recommended]. As the 2nd byte is 0x9c, ascii is going nowhere. > > >> print unicode(media).encode('utf-8') > > UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position > 1: ordinal not in range(128) > (why does this not work?) Already unicode(media) "doesn't work", so naturally(?) unicode(media).whatever() won't be better -- whatever won't be called. > > # mapString is a unicode string (i think at least)>> print "'" + mapString + "'" > > ' yu_200703_hello\ 831 v1234.9874 ' > > >> mystr = "%s %s" % (mapString, media) > > UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position > 1: ordinal not in range(128) > > >> mystr = "%s %s" % (mapString.encode('utf-8'), media.encode('utf-8')) > > UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position > 1: ordinal not in range(128) This is merely repeating the original problem. > > I don't know what to do. I just want to concatenate two string where > apparently one is a binary string, the other one is a unicode string > and I always seem to get this error. > > Any help is appreciated :) We need a clue or two; do this and let us know what it says: print type(media), repr(media) print type(mapString), repr(mapString) import sys; print sys.stdout.encoding Also you say that "print media" works. Do you mean that it produces some meaningful text that you understand? What I see on the screen in Google Groups is the following 6 characters: LATIN SMALL LETTER X KATAKANA LETTER WA KATAKANA LETTER YU KATAKANA LETTER RO LEFT SQUARE BRACKET KATAKANA LETTER YO Is that what you see? What is it that you call "win32 console"? From python.list at tim.thechases.com Sat Apr 5 20:28:31 2008 From: python.list at tim.thechases.com (Tim Chase) Date: Sat, 05 Apr 2008 19:28:31 -0500 Subject: Best way to check if string is an integer? In-Reply-To: <47F8095D.40905@datanet.ab.ca> References: <47F8095D.40905@datanet.ab.ca> Message-ID: <47F8192F.2050806@tim.thechases.com> > I always do it the first way. It is simpler, and should be faster. Ditto. Using int() is best. It's clear, it's correct, and it should be as fast as it gets. >> if c in '0123456789': >> print "integer" >> else: >> print "char" > > Also, the second way will only work on single-digit numbers > (you would have to iterate over the entire string with a for > loop to use it on numbers with more than one digit). It also catches things like c="1234" but misses negative numbers too. It's a bad solution on a number of levels. The isdigit() method of a string does much of what int() does for testing "is this an int" except that it too misses negative numbers. -tkc From fiacre.patrick at gmail.com Sun Apr 20 23:21:20 2008 From: fiacre.patrick at gmail.com (Andrew Lee) Date: Sun, 20 Apr 2008 23:21:20 -0400 Subject: Checking if a text file is blank In-Reply-To: References: <480ae855$0$15157$607ed4bc@cv.net> Message-ID: <480c07b7$0$11616$607ed4bc@cv.net> David wrote: >> import os >> print os.lstat("friends.txt")[6] >> > > I prefer os.lstat("friends.txt").st_size MUCH easier to remember!!!! Thanks! From inq1ltd at inqvista.com Sun Apr 6 20:12:01 2008 From: inq1ltd at inqvista.com (jim-on-linux) Date: Sun, 06 Apr 2008 20:12:01 -0400 Subject: Tkinter, repaint?, keep size? In-Reply-To: <6ff2ce5f-9ba3-492c-b062-324c91e652a0@e10g2000prf.googlegroups.com> References: <6ff2ce5f-9ba3-492c-b062-324c91e652a0@e10g2000prf.googlegroups.com> Message-ID: <200804062012.01208.inq1ltd@inqvista.com> On Sunday 06 April 2008 13:24, skanemupp at yahoo.se wrote: > so my calculator is almost done for u that > have read my previous posts. > i have some minor problems i have to fix > though. > > *one is i need to repaint once i have > performed a calculation so that the old > results are not left on the screen. cant > find a method for that. you can use "wigit".update(). The update method update will redraw wigits as necessary. If you have the state of the wigit set to DISABLE then set it to ACTIVE before using .update(). > > *another is now when i write the > expression to be evaluated it resizes the > window as the text grows. > i want the windowsize and all the > buttonplacements stay constant, how do i > achieve this? I like to make a separate frame for buttons. master = Tk() master.title =('My Project') buttonFrame = Frame(master) buttonFrame.grid(row = 0 column = 1) you could use a dictionary that contains the the text and the command and loop the key to build the buttons. Make x = x+1, y = y+1 for row and column or otherwise as you need. button = Button(buttonframe, text = key, width = 2) button1.grid(row = x, column = y, sticky = NSEW) put other stuff into the master using another frame and grid it in some other column and or row. If you make all buttons the same size inside the frame they will keep their size even if you have more text then the button will hold. There is a lot more but this is the way I would proceed. jim-on-linux http://www.inqvista.com From windypower at gmail.com Fri Apr 25 22:41:46 2008 From: windypower at gmail.com (windypower at gmail.com) Date: Fri, 25 Apr 2008 19:41:46 -0700 (PDT) Subject: Desktop notifications on Windows Message-ID: <0db266c1-50ad-4e01-b508-57c9a8febb4b@a22g2000hsc.googlegroups.com> I'm looking for a way to implement desktop notifications (much like an instant messaging program or a mail notifier) within my Python application, on Windows only (no Gtk/Galago, please). I need no more than a simple text-based notification, which should be clickable and have a timeout, nothing else. I do not want to use Windows's "balloon tips", either. Any suggestions? From ankitks.mital at gmail.com Mon Apr 7 12:38:39 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Mon, 7 Apr 2008 09:38:39 -0700 (PDT) Subject: reading dictionary's (key,value) from file Message-ID: <974814d3-59f0-49ec-9b4d-9f5dd7dfaf54@q24g2000prf.googlegroups.com> Folks, Is it possible to read hash values from txt file. I have script which sets options. Hash table has key set to option, and values are option values. Way we have it, we set options in a different file (*.txt), and we read from that file. Is there easy way for just reading file and setting options instead of parsing it. so this is what my option files look like: 1opt.txt { '-cc': '12', '-I': r'/my/path/work/'} 2opt.txt { '-I': r/my/path/work2/'} so my scipt how has dictionary options = { '-cc' :'12' '-I': r'/my/path/work/:/my/path/work2/'} I am trying to avoid parsing From ivan.illarionov at gmail.com Sun Apr 13 08:27:55 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Sun, 13 Apr 2008 05:27:55 -0700 (PDT) Subject: Looking for a way to include Pyhtho scripting INSIDE a python program References: <48017af0$0$36399$742ec2ed@news.sonic.net> Message-ID: On Apr 13, 7:16 am, John Antypas wrote: > Hello all, > > I'm writing in tool in Python that manipulates various data objects read > from various streams. I wanted to give the user a chance to do advanced > work that could not easily be done from a GUI. > > At first, I tried putting in a lightweight scripting language, and then > I thought, why not include Python in itself -- it is certainly powerful > enough. > > I had assumed I'd present the user with a text window in which they > could type arbitrary python code. I'd wrap that code around a function > and pass that function a call of objects they could manipulate by > calling the methods of that class. > > 1. How can a python program invoke ANOTHER interpreter? > 2. How can I pass the class in as its argument and get the modified > class back? > > I know I can do something very ugly -- call a C method that calls a new > python interpreter but that seems VERY ugly. > > Help? > > Thanks. You don't need to envoke another interpreter. Python can interpret arbitrary python code with exec statement. Wrap user's string inside function definition, and exec it. You might want to disable words like `import`, `exec` and `eval` in user's code because it's a big security risk. -- Ivan Illarionov From fiacre.patrick at gmail.com Wed Apr 23 06:49:31 2008 From: fiacre.patrick at gmail.com (Andrew Lee) Date: Wed, 23 Apr 2008 06:49:31 -0400 Subject: help needed with classes/inheritance In-Reply-To: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> References: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> Message-ID: <480f13e8$0$15157$607ed4bc@cv.net> barbaros wrote: > Hello everybody, > > I am building a code for surface meshes (triangulations for instance). > I need to implement Body objects (bodies can be points, segments, > triangles and so on), then a Mesh will be a collection of bodies, > together with their neighbourhood relations. > I also need OrientedBody objects, which consist in a body > together with a plus or minus sign to describe its orientation. > So, basically an OrientedBody is just a Body with an > integer label stuck on it. > > I implemented it in a very crude manner: > ------------------------------------------ > class Body: > [...] > class OrientedBody: > def __init__ (self,b,orient=1): > # b is an already existing body > assert isinstance(b,Body) > self.base = b > self.orientation = orient > ------------------------------------------- class Body(object) : ... class OrientedBody (Body): def __init__(self, orientation = 1) : Body.__init__(self) self.orientation = orientation as noted But, also. as a rule of thumb .. if you are using "isinstance" in a class to determine what class a parameter is ... you have broken the OO contract. Remember, every class ought to have a well defined internal state and a well defined interface to its state. If I write -- class foo (object): def __init__ : pass def some_func (self, val) : if isinstance (val, "bar") : .... Then I am either doing something very wrong or very clever (either can get me in trouble) In Python it is preferred that I write two functions some_func_a and some_func_b e.g. def some_func_a (self, val = None, class = bar) : assert(isinstance (class, "bar"), True) .... def some_func_b (self, val = None, class = baz) : assert (isinstance (class, "baz"), True) C++ and Java try to enforce the OO contract by making data and methods private, protected or public. Which helps -- but leads to some confusion (what is protected inheritance in C++????) Python exposes all of its classes internals to everyone -- but that doesn't mean you should touch them!! As Larry Wall once wrote, "There is a difference between, 'do not enter my living room because I asked you not to' and 'do not enter my living room because I have a shotgun'" Python adopts the 'do not touch my private parts because I asked you not to' idiom. (In C++, only friends can touch your privates ... ;-) So -- be mindful that checking the class of well defined parameters at anytime is breaking the contract -- you may need to do it -- but it is more likely that you aren't adhering to good OOD. Does that make any sense? Seriously -- I have not had any coffee yet and I am still new at Python. -- Andrew > > My question is: can it be done using inheritance ? > I recall that I need three distinct objects: > the basic (non-oriented) body, the same body with positive > orientation and the same body with negative orientation. > > Thank you. Cristian Barbarosie > http://cmaf.fc.ul.pt/~barbaros From smmehadi at gmail.com Fri Apr 18 04:52:43 2008 From: smmehadi at gmail.com (syed mehdi) Date: Fri, 18 Apr 2008 14:22:43 +0530 Subject: python server side scripting with apache2 Message-ID: <12b075a10804180152ob8ca5b9iacf0a9f0d8822c5e@mail.gmail.com> Hi Guys, I want to do server side scripting in python for one of my applications. So after installing apache2, python lib for apache2 (libapache2....), and doing some changes in default file in /etc/apache2/sites-available i was able to execute python scripts in /var/www/ directory from client side. but i want to place all of my python scripts in some other directory like /home/username/myserver, so what changes i have to make in configuration files at /etc/apache2/apache2.conf or some other place (like /etc/apache2/sites-available/default), so that my server side scripts placed in this folder (/home/username/myserver) gets executed from client side using some url like http://machine-ip/home/username/myserver/abc.py. Thanks & Regards Syed -------------- next part -------------- An HTML attachment was scrubbed... URL: From watches0684 at global-replica-watch.com Tue Apr 22 23:11:27 2008 From: watches0684 at global-replica-watch.com (watches0684 at global-replica-watch.com) Date: Tue, 22 Apr 2008 20:11:27 -0700 (PDT) Subject: Designer Versace V Bag - Khaki 6532 Khaki Handbags, Replica, Fake Message-ID: <22c54b4b-be65-4aab-bcaf-8bb7004a813b@l64g2000hse.googlegroups.com> Designer Versace V Bag - Khaki 6532 Khaki Handbags, Replica, Fake Our Versace V Bag - Khaki 6532 Khaki is a vibrant mix of style and pleasure, offering you exact copies of the original handbags. If you need a cool and most welcomed change to your style, a change you certainly deserve, choose one of the many bags ReplicasHandbag.com offers at a great price. Versace V Bag - Khaki Link : http://www.replicashandbag.com/Versace-6532-Khaki.html Brand : Versace ( http://www.replicashandbag.com/Versace-Handbags.html ) Model : 6532 Khaki Sale Price : $ 215.00 Versace V Bag - Khaki Details : Khaki color Versace leather bagGold chain with khaki leather handleGold color Versace logo at the frontZipper closure and magnetic snap cloure on topInside it has one flat pocketComes with serial numbers, authenticity card, dust bag, and care booklet SIZE : 18.1" x 12.2" x 9.4" You may find the most affordable Designer Versace Handbags on our website replicashandbag.com while high quality can be guaranteed. Our Replica Versace Bags is made with special care to reach the level of an original one. Here you will find luxury items are no longer something you ever hesitate going for. To meet your expectation, we only provide Versace Fake Handbags that is perfectly imitated, featuring the slight details of originals. All of our replica handbags are shipped via EMS to worldwide. Normally it takes 3days to prepare the fake bags you ordered and 5-10days to transmit depending on the different destination.We pay for the free shipping cost for total quantity over 20 pcs. The EMS tracking NO. will be sent by email when an order is shipped from our warehouse. No more other charges from replicashandbag.com such as the tax. If you have any other questions please check our other pages or feel free to email us by sales at replicashandbag.com. The Same Replica Versace Handbags Series : Designer Versace V Bag - Khaki 6532 Khaki Handbags, Replica, Fake From maxerickson at gmail.com Tue Apr 22 11:19:27 2008 From: maxerickson at gmail.com (Max Erickson) Date: Tue, 22 Apr 2008 15:19:27 +0000 (UTC) Subject: Witty retorts (was: Python Success stories) References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <87d4oi3s3c.fsf_-_@benfinney.id.au> Message-ID: Ben Finney wrote: > Carl Banks writes: > >> Let me tell you a little story to let you know how you should >> act in situations like this. Some of you might have heard it >> before. Apologies if it's a bit long. > > I don't know if I've heard it before; it's rather unmemorable. > > What lesson is it intended to teach, other than that "Fuck you" > is somehow a "retort"? I can't see that improving too many > situations. > I got something like "Don't waste your life worrying about what some damn clown said" out of it. You don't even need to swear at the clown to make it work. max From arnodel at googlemail.com Thu Apr 3 18:12:01 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 3 Apr 2008 15:12:01 -0700 (PDT) Subject: expanding a variable to a dict References: Message-ID: On Apr 3, 10:56?pm, idle wrote: > I've got a variable in a loop that I'm trying to expand/translate/ > readdress as an existing dict so as to add some keys into it.. > > eg; I have a set of existing dicts: dictFoo, dictBar, dictFrotz (names > changed to protect the innocent) > > now I'd like to check them all for the existence of certain default > keys; ie, if the dicts don't contain the keys, add them in with > default values. > > so, I've got: > > for a in ['dictFoo','dictBar','dictFrotz']: > ? ? if hasattr(a,'srcdir') == False: > ? ? ? ? a['srcdir']='/usr/src' > > the error I get (which I expect) is 'str' object doesn't support item > assignment. > > what incantation do I cast on 'a' to make the interpreter parse it as > 'dictFoo' on the first iteration, 'dictBar' on the second, and so > forth? > > and/or less importantly, what is such a transformation called, to help > me target my searching? > > thanks You want a to iterate through the dictionary *objects*, not *names*, so write for a in [dictFoo, dictBar, dictFrotz]: ... BTW, hasattr() is not what you want as it check the existence of an attribute, i.e. a.hasattr('x') means that a.x exists; you could write the whole thing as: for a in dictFoo, dictBar, dictFrotz: if 'srcdir' not in a: a['srcdir'] = '/usr/src' Or more concisely: for a in ... : a.setdefault('srcdir', '/usr/src') For more information, help(dict) is your friend :) HTH -- Arnaud From patrickkidd.lists at gmail.com Wed Apr 9 12:31:22 2008 From: patrickkidd.lists at gmail.com (Patrick Stinson) Date: Wed, 9 Apr 2008 10:31:22 -0600 Subject: problem using import from PyRun_String In-Reply-To: References: <664bf2b80804081801u79ae9192h90c03c84c1ef35ce@mail.gmail.com> Message-ID: <664bf2b80804090931y78d9e34dof268784cc6a6cde9@mail.gmail.com> Well, I eventually want to add an import hook, but for now I'd rather just get the import statement working normally again. I have embedded python as a scripting engine in my application. To do this, I create a new empty module, run the script text using PyRun_String() passing the module's __dict__ as locals and globals. This populates the module's __dict__ with the resulting object references from the script text. As I said before I must be forgetting some other module init stuff because I had to manually populate the modules' __dict__ with references from the __builtin__ module in order to get the basic stuff like abs, range, etc. I understand what __builtin__ is used for, but the C struct pointing to the code frame that contains the import statement has a builtin member that apparently does not contain the __import__ function, hence my question. There must be some difference in the way code is parsed and a copy of the __builtin__ module is passed normally and the way I am doing it. So, finding the place where this module bootstrapping normally happens would be awesome, because I sort of feel like I'm hacking this method running into problems like this. I'll definitely be putting together a wiki on this topic before long. Seems like an application scripting engine is incredibly easy to implement if you already know all the tricks, we're just lacking docs. On Wed, Apr 9, 2008 at 1:00 AM, Gabriel Genellina wrote: > En Tue, 08 Apr 2008 22:01:18 -0300, Patrick Stinson > escribi?: > > > I'm creating a module with PyModule_New(), and running a string buffer > as > > the module's text using PyRun_String and passing the module's __dict__ > to > > locals and globals. > > Why? Do you want to fake what import does? > > > I'm having a problem using the import statement from > > within PyRun_String(). It complains about "__import__ not found", which > > after a quick grep it looks like the exception is raised from > > PyExc_EvalFrameEx() in ceval.c after f->f_builtins module doesn't > contain > > "__import__". > > What __builtin__ module does that point to? a quick print of the > > __builtin__ holds all the builtin objects, what a surprise! :) > http://docs.python.org/lib/module-builtin.html > > > Any help? > > What do you want to do actually? > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Patrick Kidd Stinson http://www.patrickkidd.com/ http://pkaudio.sourceforge.net/ http://pksampler.sourceforge.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From kamhung.soh at gmail.com Mon Apr 21 19:07:49 2008 From: kamhung.soh at gmail.com (Kam-Hung Soh) Date: Tue, 22 Apr 2008 09:07:49 +1000 Subject: Is massive spam coming from me on python lists? References: Message-ID: On Mon, 21 Apr 2008 16:01:42 +1000, Brian Vanderburg II wrote: > I've recently gotten more than too many spam messages and all say > Sender: python-list-bounces+my=email.address at python.org. I'm wondering > if my mail list registration is now being used to spam myself and > others. If so, sorry, but I'm not the one sending messages if other are > getting them even though Sender seems to include my address (I'm not > sure about mail headers so I don't know how From: is different than > Sender:) Anyway, it seems to be a bunch of spam emails about cracks and > stuff. > > Brian Vanderburg II No worries. People should (I hope) just ignore the sender address when they receive spam. -- Kam-Hung Soh Software Salariman From sumoee at gmail.com Thu Apr 17 07:45:15 2008 From: sumoee at gmail.com (sumoee at gmail.com) Date: Thu, 17 Apr 2008 04:45:15 -0700 (PDT) Subject: #####SOUTH INDIAN SEX GIRLS SEX###### Message-ID: <20cb4dd8-a897-4f89-886d-c13a4b94a168@8g2000hse.googlegroups.com> http://rajtrytry.dubaimlm.com free Register On $ 100 Free dubai companey Relised Paymend free join form free free 100 dollors free 4days only http://rajtrytry.dubaimlm.com http://rajtrytry.dubaimlm.com http://rajtrytry.dubaimlm.com http://rajtrytry.dubaimlm.com se SEX SEX SWEX SEX WEB SITE NO BIOTECH http://bisblogs.blogspot.com/ http://bisblogs.blogspot.com/ From gagsl-py2 at yahoo.com.ar Mon Apr 21 21:32:08 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 22:32:08 -0300 Subject: yield expression programmized-formal interpretation. (interpretation of yield expression.) References: <888d1fff-5566-47db-b1a9-6c0bb994d7da@d1g2000hsg.googlegroups.com> Message-ID: En Mon, 21 Apr 2008 15:03:05 -0300, escribi?: > What if I say > > oath= yield > > or > > other= yield > > ? > > Does yield evaluate without parenthes? (Eth.) You can't use yield except in a generator function. From and the grammar definition at you can see that assignment_stmt ::= (target_list "=")+ (expression_list | yield_expression) yield_expression ::= "yield" [expression_list] The last expression_list is optional so a bare yield should be allowed in the right hand side of an assignment, as if it were `yield None` (I think such behavior is specified in the original PEP). Let's try: py> def gen(): ... x = yield ... y = yield "second" ... yield x, y ... py> g = gen() py> print g.next() None py> print g.send(123) second py> print g.send(456) (123, 456) py> print g.send(789) Traceback (most recent call last): File "", line 1, in StopIteration -- Gabriel Genellina From john106henry at hotmail.com Sat Apr 26 19:11:11 2008 From: john106henry at hotmail.com (John Henry) Date: Sat, 26 Apr 2008 16:11:11 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <5b326b53-22fc-43f3-8423-bfc49d05ccc3@j22g2000hsf.googlegroups.com> Message-ID: On Apr 26, 4:05 pm, castiro... at gmail.com wrote: > On Apr 26, 5:03 pm, John Henry wrote: > > > > > On Apr 26, 8:46 am, a... at pythoncraft.com (Aahz) wrote: > > > > In article <9028496e-30de-4853-8f57-b55d14e52... at h1g2000prh.googlegroups.com>, > > > John Henry wrote: > > > > >But then I looked closer. It turns out the XML file created by > > > >QxTransformer is *very* similar in structure when compared to the > > > >resource files used inPythonCard. Since there are no GUI builders > > > >for QxTransformer, and I can't affort to buy the one for Qooxdoo > > > >(Java! Yuk!), I decided to roll up my sleeves, took thePythoncard's > > > >Layout Manager and modified it and created my own "Poor Man's Qooxdoo > > > >GUI Layout Designer". > > > > Cute! When you have working code, please do upload to PyPI. > > > -- > > > Aahz (a... at pythoncraft.com) <*> http://www.pythoncraft.com/ > > > > Why is this newsgroup different from all other newsgroups? > > > So far, I have the following widgets working: > > > window, button, checkbox, static text, static box, list, combobox, > > spinner, radio button group > > > Shouldn't be long before the following works: > > > static line, image, image button, choice.- Hide quoted text - > > > - Show quoted text - > > Should static text GUI class support the operations of a string? Say what? From steve at holdenweb.com Fri Apr 11 14:34:36 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 11 Apr 2008 14:34:36 -0400 Subject: About __init__ and default arguments In-Reply-To: References: Message-ID: Kevin Takacs wrote: > Hi, > > I'd like to assign the value of an attribute in __init__ as the default > value of an argument in a method. See below: > > class aphorisms(): > def __init__(self, keyword): > self.default = keyword > > def franklin(self, keyword = self.default): > return "A %s in time saves nine." % (keyword) > > def main(): > keyword = 'FOO' > my_aphorism = aphorisms(keyword) > print my_aphorism.franklin() > print my_aphorism.franklin('BAR') > > if __name__ == "__main__": > main() > > I get this error: > def franklin(self, keyword = self.default): > NameError: name 'self' is not defined > > As you might expect, I'd like to get: > A FOO in time saves nine. > A BAR in time saves nine. > > I suppose I could set the default to a string literal, test for it and if > true assign the value of self.default to keyword; however, that seems > clunky. Any ideas how this could be done along the lines of my proposed > but faulty code? > def franklink(self, keyword=None): if keyword is None: keyword = self.keyword would be the usual way to do it. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From nachogomez at gmail.com Thu Apr 17 15:18:32 2008 From: nachogomez at gmail.com (=?UTF-8?Q?Ra=C3=BAl_G=C3=B3mez_C.?=) Date: Fri, 18 Apr 2008 14:48:32 +1930 Subject: Importing My Own Script In-Reply-To: <69481.40675.qm@web39203.mail.mud.yahoo.com> References: <69481.40675.qm@web39203.mail.mud.yahoo.com> Message-ID: <684b0a740804171218t2fff48c6s6c39acc5b38eb761@mail.gmail.com> Victor, you can do this in order to load your own modules: import sys,os sys.path.append(os.getcwd()) import your_module On Fri, Apr 18, 2008 at 12:34 PM, Ben Kaplan wrote: > It might be something in mod python. Try asking on their mailing list. > > ----- Original Message ---- > From: Victor Subervi > To: Ben Kaplan > Cc: python-list at python.org > Sent: Thursday, April 17, 2008 10:47:34 AM > Subject: Re: Importing My Own Script > > On Thu, Apr 17, 2008 at 8:52 AM, Ben Kaplan wrote: > > > If x and y are in the same directory, just do "import x". If not, add > > the directory containing x to sys.path. Then, "import x" should work. > > > > Well, now that?s what I thought! But no, it doesn?t work! Both scripts are > in the same folder. Here?s the error: > > [Thu Apr 17 07:45:50 2008] [error] [client 190.166.0.245] PythonHandler > mod_python.cgihandler: File "/var/www/vhosts/ > livestocksling.com/httpdocs/bre/test.py", line 3, in ?\n import test2 > [Thu Apr 17 07:45:50 2008] [error] [client 190.166.0.245] PythonHandler > mod_python.cgihandler: ImportError: No module named test2 > I?m running through Plesk, if that makes a difference. > TIA, > Victor > > > > > > ----- Original Message ---- > > From: Victor Subervi > > To: python-list at python.org > > Sent: Thursday, April 17, 2008 9:45:10 AM > > Subject: Importing My Own Script > > > > Hi: > > How do I import my own script from a second script? That is, I have > > script x and I want to import script y. How? > > TIA, > > Victor > > > > > > ------------------------------ > > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try > > it now. > > > > > > ------------------------------ > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it > now. > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Nacho Linux Counter #156439 -------------- next part -------------- An HTML attachment was scrubbed... URL: From sjdevnull at yahoo.com Wed Apr 16 15:33:10 2008 From: sjdevnull at yahoo.com (sjdevnull at yahoo.com) Date: Wed, 16 Apr 2008 12:33:10 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> <09a38ca2-8c49-4eee-b6cf-58e849aea1fc@q1g2000prf.googlegroups.com> Message-ID: <5c5c130e-dade-4663-87b5-f3ab748cc9e3@y21g2000hsf.googlegroups.com> On Apr 16, 2:52 pm, Aaron Watters wrote: > I disagree. You can add lots of cool > stuff without breaking the existing code base, mostly. > For example the minor changes to the way ints will work will > effect almost no programs. Wow, I'd venture that the division changes with ints are the only thing I'm really concerned about breaking in 3.0, both because they're more likely to slip by without being immediately noticed and because they're likely to be foreign going forward for people used to C-style integer division (ie most of the programmers in our office). Even them I don't see as a huge roadblock, but a "erase old ways of thinking" bugaboo for a while. But the rest of the changes are pretty obvious and well warned about by 2to3 and the interpreter. From ashishk30 at gmail.com Wed Apr 16 03:20:51 2008 From: ashishk30 at gmail.com (ashish kamble) Date: Wed, 16 Apr 2008 12:50:51 +0530 Subject: python beginer Message-ID: <81d84eb10804160020n114c4d7ekfef7a09532813e39@mail.gmail.com> hi, can anyone tell me hw to start with webapplication scripting(e.g login page..etc) if anyone has soln for this or simple e.g that mention above please send me by and have a nice day -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin at v.loewis.de Tue Apr 1 19:03:20 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Wed, 02 Apr 2008 01:03:20 +0200 Subject: What motivates all unpaid volunteers at Pycon? In-Reply-To: <6ffcb45b-abb9-4d5e-8237-0f8c6bacab08@i29g2000prf.googlegroups.com> References: <7b539c8e-af4c-4409-81bc-d94e687eea59@i7g2000prf.googlegroups.com> <12d7412e-9f87-4798-a319-a78a27f68d00@e6g2000prf.googlegroups.com> <6ffcb45b-abb9-4d5e-8237-0f8c6bacab08@i29g2000prf.googlegroups.com> Message-ID: <47F2BF38.8090208@v.loewis.de> > What do the people get back who did all the hard work at registration > desk and > preparing conference attendee bags? ...who did all hotel preparations? I think these questions are better asked at the pycon organizers list, than on comp.lang.python (which none of the volunteers may actually read to answer your questions). Regards, Martin From Robert.Bossy at jouy.inra.fr Fri Apr 25 09:05:20 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Fri, 25 Apr 2008 15:05:20 +0200 Subject: Little novice program written in Python In-Reply-To: <67dqepF2nmg7dU1@mid.uni-berlin.de> References: <49249992-3634-4c5f-bd45-7ce4f1b32044@l17g2000pri.googlegroups.com> <67dqepF2nmg7dU1@mid.uni-berlin.de> Message-ID: <4811D710.7080709@jouy.inra.fr> Marc 'BlackJack' Rintsch wrote: >> Indeed. Would it be a sensible proposal that sequence slices should >> return an iterator instead of a list? >> > > I don't think so as that would break tons of code that relies on the > current behavior. Take a look at `itertools.islice()` if you want/need > an iterator. A pity, imvho. Though I can live with islice() even if it is not as powerful as the [:] notation. RB From lobais at gmail.com Mon Apr 14 14:02:48 2008 From: lobais at gmail.com (Thomas Dybdahl Ahle) Date: Mon, 14 Apr 2008 20:02:48 +0200 Subject: Rounding a number to nearest even In-Reply-To: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: <1208196168.24295.36.camel@localhost.localdomain> On Fri, 2008-04-11 at 03:14 -0700, bdsatish wrote: > The built-in function round( ) will always "round up", that is 1.5 is > rounded to 2.0 and 2.5 is rounded to 3.0. > > If I want to round to the nearest even, that is > > my_round(1.5) = 2 # As expected > my_round(2.5) = 2 # Not 3, which is an odd num > > I'm interested in rounding numbers of the form "x.5" depending upon > whether x is odd or even. Any idea about how to implement it ? This seams to work fine: evenRound = lambda f: round(f/2.)*2 >>> [(f*.5, evenRound(f*.5)) for f in xrange(0,20)] [(0.0, 0.0),(0.5, 0.0), (1.0, 2.0), (1.5, 2.0), (2.0, 2.0), (2.5, 2.0), (3.0, 4.0), (3.5, 4.0), (4.0, 4.0), (4.5, 4.0), (5.0, 6.0), (5.5, 6.0), (6.0, 6.0), (6.5, 6.0), (7.0, 8.0), (7.5, 8.0), (8.0, 8.0), (8.5, 8.0), (9.0, 10.0), (9.5, 10.0)] -- Best Regards, Med Venlig Hilsen, Thomas From ptmcg at austin.rr.com Thu Apr 24 12:08:10 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Thu, 24 Apr 2008 09:08:10 -0700 (PDT) Subject: Ideas for parsing this text? References: Message-ID: On Apr 24, 10:42?am, "Eric Wertman" wrote: > I'm sure there are cooler ways to do some of that. ?I spent most of my > time expanding the characters that constitute content. ?I'm concerned > that over time I'll have things break as other characters show up. > Specifically a few of the nodes are of German locale.. so I could get > some odd international characters. > If you want to add international characters without going to Unicode, a first cut would be to add pyparsing's string constant "ascii8bit". > It looks like pyparser has a constant for printable characters. ?I'm > not sure if I can just use that, without worrying about it? > I would discourage you from using printables, since it also includes '[', ']', and '"', which are significant to other elements of the parser (but you could create your own variable initialized with printables, and then use replace("[","") etc. to strip out the offending characters). I'm also a little concerned that you needed to add \t and \n to the content word - was this really necessary? None of your examples showed such words, and I would rather have you let pyparsing skip over the whitespace as is its natural behavior. -- Paul From arnodel at googlemail.com Fri Apr 11 14:41:39 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Fri, 11 Apr 2008 11:41:39 -0700 (PDT) Subject: About __init__ and default arguments References: Message-ID: <2965bd09-1eeb-44b4-bdd5-80c3bb5cb504@m1g2000pre.googlegroups.com> On Apr 11, 7:20?pm, Kevin Takacs wrote: > Hi, > > I'd like to assign the value of an attribute in __init__ as the default > value of an argument in a method. ?See below: > > class aphorisms(): > ? ? def __init__(self, keyword): > ? ? ? ? self.default = keyword > > ? ? def franklin(self, keyword = self.default): > ? ? ? ? return "A %s in time saves nine." % (keyword) > > def main(): > ? ? keyword = 'FOO' > ? ? my_aphorism = aphorisms(keyword) > ? ? print my_aphorism.franklin() > ? ? print my_aphorism.franklin('BAR') > > if __name__ == "__main__": > ? ? main() > > I get this error: > def franklin(self, keyword = self.default): > NameError: name 'self' is not defined > > As you might expect, I'd like to get: > A FOO in time saves nine. > A BAR in time saves nine. > > I suppose I could set the default to a string literal, test for it and if > true assign the value of self.default to keyword; however, that seems > clunky. ?Any ideas how this could be done along the lines of my proposed > but faulty code? > > Thanks, > Kevin The idiom is: def franklin(self, keyword=None): if keyword is None: keyword = self.default HTH -- Arnaud From mattheww at chiark.greenend.org.uk Wed Apr 16 19:32:15 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 17 Apr 2008 00:32:15 +0100 (BST) Subject: How to have unittest tests to be executed in the order they appear? References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> <87zlru7le2.fsf@benfinney.id.au> <87fxtlwi03.fsf@benfinney.id.au> Message-ID: <7nk*FmAas@news.chiark.greenend.org.uk> Ben Finney wrote: > Surely, since "suddenly" implies you changed one small area of the > code, that area of the code is the best place to look for what caused > the failure. Imagine that "suddenly" immediately follows "I upgraded to etch". -M- From landofdreams at gmail.com Wed Apr 30 23:46:15 2008 From: landofdreams at gmail.com (Sam) Date: Wed, 30 Apr 2008 20:46:15 -0700 (PDT) Subject: relative import broken? References: <9c6ba5f9-d65b-4265-baba-fc5d7936781b@d1g2000hsg.googlegroups.com> <87prs6x1ye.fsf@mulj.homelinux.net> Message-ID: <103668f6-8995-4179-a468-4ff6c7f82bba@c65g2000hsa.googlegroups.com> On Apr 30, 9:11 pm, Hrvoje Niksic wrote: > Sam writes: > > I also have a problem with relative import; I can't for the life of me > > figure out how to use the damn thing. I think the main problem is with > > getting Python to recognize the existence of a package. I have > > > S/ > > p.py > > B/ > > b.py > > W/ > > pyw/ > > u.py > > ws.py > > > and I'd like to get u.py to import all the other 3 programs. I put > > empty __init__.py files in all of the above directories (is this > > necessary?), and even manually added the pathway (r'C:\Myname\S') to > > sys.path, but when I execute > > > from S import p > > > in u.py Python gives "ImportError: No module named S". > > A silly question: is the directory that contains "S" in PYTHONPATH or > in sys.path? It's in sys.path. I'm not sure how to access or change PYTHONPATH from within a program (I'm running everything in IDLE). I'm using Windows, btw. > > > The docs for relative import make this sound much easier than it is. > > It's supposed to be just as easy as it sounds. For example: > > $ mkdir S > $ touch S/p.py > $ touch S/__init__.py > $ python > Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 > Type "help", "copyright", "credits" or "license" for more information.>>> from S import p > >>> p > > From paulgeeleher at gmail.com Thu Apr 24 07:41:35 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Thu, 24 Apr 2008 04:41:35 -0700 (PDT) Subject: Setting expirty data on a cookie References: <8ba48e05-9aba-4a56-805c-cd31b43517ab@24g2000hsh.googlegroups.com> Message-ID: On Apr 22, 8:38 pm, David wrote: > On Tue, Apr 22, 2008 at 6:21 PM,sophie_newbie wrote: > > Does anyone know how to do this? I can't seem to make it work. > > > I'm using: > > > c = Cookie.SimpleCookie() > > c['data'] = "unamepwordwhatever" > > c.expires = time.time() + 300 > > print c > > > This doesn't seem to work, so I'm assuming isn't the correct way to > > set an expiry data? Anyone able to help me out here? > > You're probably looking for cookielib.Cookie I don't think so, to give you a more complete picture, if I run this code: import Cookie import time c = Cookie.SimpleCookie() c['data'] = "unamepwordwhatever" c.expires = time.time() + 300 print c This codes gives an output of: "Set-Cookie: data=unamepwordwhatever" As in there is no mention of an expiry date, when surely there should be? Thanks for any advice. From bressert at gmail.com Tue Apr 29 17:03:47 2008 From: bressert at gmail.com (eli) Date: Tue, 29 Apr 2008 14:03:47 -0700 (PDT) Subject: accuracy issues with numpy arrays? Message-ID: <30fa02c6-908c-4c1c-a2ed-acb0a754ea6c@r66g2000hsg.googlegroups.com> Hi, I'm writing a quick script to import a fits (astronomy) image that has very low values for each pixel. Mostly on the order of 10^-9. I have written a python script that attempts to take low values and put them in integer format. I basically do this by taking the mean of the 1000 lowest pixel values, excluding zeros, and dividing the rest of the image by that mean. Unfortunately, when I try this in practice, *all* of the values in the image are being treated as zeros. But, if I doFor example, I take the pixel that I know has the highest value and do x = scipy.ndimage.maximum(image) print x 1.7400700016878545e-05 The script is below. Thanks for the help. Eli import pyfits as p import scipy as s import scipy.ndimage as nd import numpy as n def flux2int(name): d = p.getdata(name) x,y = n.shape(d) l = x*y arr1 = n.array(d.reshape(x*y,1)) temp = n.unique(arr1[0]) # This is where the bug starts. All values are treated as zeros. Hence only one value remains, zero. arr1 = arr1.sort() arr1 = n.array(arr1) arr1 = n.array(arr1[s.where(arr1 >= temp)]) val = n.mean(arr1[0:1000]) d = d*(1.0/val) d = d.round() p.writeto(name[0,]+'fixed.fits',d,h) From landerdebraznpc at gmail.com Mon Apr 28 03:56:39 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:56:39 -0700 (PDT) Subject: dvd cloner crack Message-ID: <85c822c1-43ba-4727-96ea-d354c193b5c5@p25g2000hsf.googlegroups.com> dvd cloner crack http://crack.cracksofts.com From ptmcg at austin.rr.com Tue Apr 29 12:56:26 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Tue, 29 Apr 2008 09:56:26 -0700 (PDT) Subject: Issue with regular expressions References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> <5a75ea66-2cbb-4c41-8351-a35a70554d8d@i76g2000hsf.googlegroups.com> Message-ID: <14bb9a25-01bc-4639-93b3-5658eded2aa8@f36g2000hsa.googlegroups.com> On Apr 29, 9:20?am, Paul McGuire wrote: > On Apr 29, 8:46?am, Julien wrote: > > > I'd like to select terms in a string, so I can then do a search in my > > database. > > > query = ' ? " ?some words" ?with and "without ? ?quotes ? " ?' > > p = re.compile(magic_regular_expression) ? $ <--- the magic happens > > m = p.match(query) > > > I'd like m.groups() to return: > > ('some words', 'with', 'and', 'without quotes') > Oh! It wasn't until Matimus's post that I saw that you wanted the interior whitespace within the quoted strings collapsed also. Just add another parse action to the chain of functions on dblQuotedString: # when a quoted string is found, remove the quotes, # then strip whitespace from the contents, then # collapse interior whitespace dblQuotedString.setParseAction(removeQuotes, lambda s:s[0].strip(), lambda s:" ".join(s[0].split())) Plugging this into the previous script now gives: ('some words', 'with', 'and', 'without quotes') -- Paul From adam_no_spam at no_s.p.a.m.bregenzer.net Sun Apr 13 19:47:32 2008 From: adam_no_spam at no_s.p.a.m.bregenzer.net (Adam Bregenzer) Date: Sun, 13 Apr 2008 18:47:32 -0500 Subject: Controlling copying and pickling of objects written in C References: <3_idnfMhL8pbD5zVnZ2dnUVZ_tPinZ2d@speakeasy.net> Message-ID: <-vidncuD_58JBp_VnZ2dnUVZ_t7inZ2d@speakeasy.net> On Sun, 13 Apr 2008 16:49:51 -0300, Gabriel Genellina wrote: > En Sun, 13 Apr 2008 01:57:42 -0300, Adam Bregenzer > escribi?: > >> I am writing an extension and have "hidden" data included in the >> object's C structure that is not visible to python. I am unsure what >> would happen to that data if the python object were copied or pickled >> and would prefer to raise an exception whenever code tries to copy/deep >> copy/pickle or marshal the object since it would not make sense. Where >> would I look to control that? > > You could raise an exception in __getstate__ - that would make pickle > fail, and probably copy too but I'm not sure of that. Thank you for pointing me in the right direction. Implementing __getstate__ does trigger the exception for copy, however I seem to get the most helpful error messages by implementing __reduce__ and __getstate__ with a reduce related exception message and implementing __copy__ with a copy related exception message. Final question: What is the best exception to use. I am using NotImplementedError since it is deliberately not implemented. Is that correct or would a TypeError exception be more appropriate? Thanks, Adam From TimeHorse at gmail.com Mon Apr 21 07:29:09 2008 From: TimeHorse at gmail.com (TimeHorse) Date: Mon, 21 Apr 2008 04:29:09 -0700 (PDT) Subject: Help with Python+Bazaar+Launchpad Message-ID: Hello, I am trying to to create a branch of the bzr mirror for the current Python Trunk 2.6 development so I can finish my work on Issue 2636. I am not a core developer but am trying to create this branch so it can be reviewed by a core developer I am working with. Because I develop on multiple machines, I want to set up a central repository for my branch database and would like to use Launchpad to host it. Python's bzr archive is mirrored on launchpad via the bzr address lp:python, so that should be the parent branch. I can create a branch on 1 machine locally, but I cannot upload (push) that branch onto launchpad, which is preventing me from doing my development because I don't have access to all machines at all times. I need to have one shared branch between all my development platforms. So, I have tried and failed at all the following: 1) Click the create branch button on the launchpad interface; this creates an empty branch which cannot be populated. 2) Branch from lp:python to a local install then branch from that then try and upload to launchpad. But that means my branch is the child of the child of the mainline-trunk, so merging is too complicated. 3) Branch directly onto launchpad via "bzr branch lp:python bzr+ssh:// @bazaar.launchpad.net/~/python/". This creates a NON-empty branch on Launchpad but I cannot check it out or pull it. Also, it would not be created as a tree-less (--no-trees) which is how it should be created. 4) I have tried to directly use my first branch from step 2 (from lp:python to my local disc) to push an instance onto launchpad, but this creates an empty branch too, and as an empty branch it cannot be checked out or pulled. I know the type of Bazaar setup I want is the type specified in Chapter 5 of the User Guild: decentralized, multi-platform, single- or multiple-user. I just can't figure out how to do that with a branch from python. Chapter 5 talks about setting up a new database with init-repo and pushing new content, but I want to take a branch of an existing database and push it to the public launchpad server. I just can't for the life of me figure out how to do it. I have bzr 1.3 and 1.3.1 and neither have succeeded. Any help would be greatly appreciated as I've totally lost an entire weekend of development which I could have used to complete item 1 of my issue and run gprof over the new engine. I really need help with all this difficult administrative stuff so I can get back to development and get things done in time for the June beta. PLEASE HELP! From paul at boddie.org.uk Thu Apr 3 09:11:40 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Thu, 3 Apr 2008 06:11:40 -0700 (PDT) Subject: Parsing HTML? References: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> Message-ID: <8fc83bb8-ed37-4317-9e3c-bf01f1a0e944@s19g2000prg.googlegroups.com> On 3 Apr, 06:59, Benjamin wrote: > I'm trying to parse an HTML file. I want to retrieve all of the text > inside a certain tag that I find with XPath. The DOM seems to make > this available with the innerHTML element, but I haven't found a way > to do it in Python. With libxml2dom you'd do the following: 1. Parse the file using libxml2dom.parse with html set to a true value. 2. Use the xpath method on the document to select the desired element. 3. Use the toString method on the element to get the text of the element (including start and end tags), or the textContent property to get the text between the tags. See the Package Index page for more details: http://www.python.org/pypi/libxml2dom Paul From pscott at uwc.ac.za Mon Apr 7 07:35:58 2008 From: pscott at uwc.ac.za (Paul Scott) Date: Mon, 07 Apr 2008 13:35:58 +0200 Subject: First Python project - comments welcome! In-Reply-To: References: <1207555415.6966.88.camel@paul-laptop> Message-ID: <1207568158.6966.116.camel@paul-laptop> On Mon, 2008-04-07 at 07:05 -0400, Steve Holden wrote: > The code looks pretty good to someone that doesn't know Gtk graphics. > Err, neither do I, so I guess that means its OK? :) > 184: self.wTree2=gtk.glade.XML(globaldir+"podder.glade","serverdialogue") > > could really do with using os.path.join() if you want to be easily > cross-platform. Similarly the other places you use globaldir+"...". > Ah, OK, will take that into cognisance. Main use of the application will be on Ubuntu based laptops in lecture theatres, so I am not overly concerned, however, in the interests of writing better code, and maybe even making it useful to others outside of my project, I will try and fix it up. > At line 321 you loop while True over a Queue.Queue object until the > QueueEmpty exception is raised, then break out of the loop. It would be > easier to loop while not queue.empty(). I know the docs say that this > function is not reliable due to multi-threading semantics, but I doubt > it will make your program less responsive. > That class is not yet even implemented. I put that code in there to do an upload progress bar for the XML-RPC call, but can't yet figure out how to do it properly. That being said, I will take your notes into consideration when I get to it. Thanks! > You even put docstrings on your code. WEll done, you are going to enjoy > Python. Force of habit. :) Thanks very much for your comments, I *really* appreciate it! --Paul -------------- next part -------------- All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm From wizzardx at gmail.com Sun Apr 27 15:22:39 2008 From: wizzardx at gmail.com (David) Date: Sun, 27 Apr 2008 21:22:39 +0200 Subject: design choice: multi-threaded / asynchronous wxpython client? In-Reply-To: <708eaa6d-3893-407e-83ec-4e6104b0a130@q24g2000prf.googlegroups.com> References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> <002cd046-f11d-482e-a67d-4a10a97687a1@x19g2000prg.googlegroups.com> <708eaa6d-3893-407e-83ec-4e6104b0a130@q24g2000prf.googlegroups.com> Message-ID: <18c1e6480804271222j3bb46333g4457d8af40d49667@mail.gmail.com> > Tempting thought, but one of the problems with this kind of horse > racing tote data is that a lot of it is for combinations of runners > rather than single runners. Whilst there might be (say) 14 horses in a > race, there are 91 quinella price combinations (1-2 through 13-14, > i.e. the 2-subsets of range(1, 15)) and 364 trio price combinations. > It is not really practical (I suspect) to have database tables with > columns for that many combinations? If you normalise your tables correctly, these will be represented as one-to many or many-to-many relationships in your database. Like the other poster I don't know the first thing about horses, and I may be misunderstanding something, but here is one (basic) normalised db schema: tables & descriptions: - horse - holds info about each horse - race - one record per race. Has times, etc - race_hourse - holds records linking horses and races together. You can derive all possible horse combinations from the above info. You don't need to store it in the db unless you need to link something else to it (eg: betting data). In which case: - combination - represents one combination of horses. - combination_horse - links a combinaition to 1 horse. 1 of these per horse per combination. - bet - Represents a bet. Has foreign relationship with combination (and other tables, eg: better, race) With a structure like the above you don't need hudreds of database columns :-) David. From skanemupp at yahoo.se Thu Apr 10 06:00:38 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 03:00:38 -0700 (PDT) Subject: questions about Exceptions? References: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> <71cc8c25-f5f9-4f21-a9d8-06780bf97608@f63g2000hsf.googlegroups.com> Message-ID: <9af81b1a-3e02-4406-b9d2-0a9b6f46566b@p39g2000prm.googlegroups.com> On 10 Apr, 10:51, cokofree... at gmail.com wrote: > In general you should only catch the exceptions you want to catch, > therefore avoiding the issue of catching "unexpected" ones, for > instances the programming unexpectandly closing. > > Well, exception handling is expensive (when it catches one) so it > really is up to you. If you are using eval and know it might "EOF" > then you should probably look to handle that. The main IF statement > style I can think of (checking the end of the string) wouldn't be much > of an improvement. > > Currently I would be very worried about seeing that code as it breaks > a number of "conventions". However it depends on the importance of the > code to wherever or not you should change this. (Global variable, the > use of Eval, the CATCH ALL except and the setting of a global variable > at the end.) > > I've seen a good few (simple and advanced) calculator examples using > python on the NET, it might be worth looking at some to see their > style of coding a calculator to help your own. i know about the GLOBAL stuff, i might rewrite the program using classes later so i can avoid this. i am mainly playin with tkinter for now. i was thinking the same check with if at the beginning and end of the string so there isnt a */ but also if someone uses /// or soemthing like that in the middle it crashes so it is hard to cover every case, esp since **5 means ^5. is the use of if also expensive? From ridenour4159 at gmail.com Thu Apr 24 06:16:44 2008 From: ridenour4159 at gmail.com (ridenour4159 at gmail.com) Date: Thu, 24 Apr 2008 03:16:44 -0700 (PDT) Subject: intervideo windvd keygen Message-ID: intervideo windvd keygen http://cracks.12w.net F R E E C R A C K S From kveretennicov at gmail.com Tue Apr 1 16:01:39 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Tue, 1 Apr 2008 23:01:39 +0300 Subject: XML Parsing In-Reply-To: References: Message-ID: <4660fe300804011301t64934dd0g921cd282d3af8917@mail.gmail.com> On Tue, Apr 1, 2008 at 10:42 PM, Alok Kothari wrote: > Hello, > I am new to XML parsing.Could you kindly tell me whats the > problem with the following code: > > import xml.dom.minidom > import xml.parsers.expat > document = """Lettermanis token>betterthan token>JayLeno""" > This document is not well-formed. It doesn't have root element. ... > > Traceback (most recent call last): > File "C:/Python25/Programs/eg.py", line 20, in > p.Parse(document, 1) > ExpatError: junk after document element: line 1, column 33 > Told ya :) Try wrapping your document in root element, like "......" -- kv -------------- next part -------------- An HTML attachment was scrubbed... URL: From bblais at bryant.edu Sat Apr 19 22:26:55 2008 From: bblais at bryant.edu (Brian Blais) Date: Sat, 19 Apr 2008 22:26:55 -0400 Subject: Frame work for simple physics web applications In-Reply-To: <2b0b8b6c-8086-4bf6-8f47-27bc5c9c788c@v23g2000pro.googlegroups.com> References: <2b0b8b6c-8086-4bf6-8f47-27bc5c9c788c@v23g2000pro.googlegroups.com> Message-ID: <383314A8-C2B6-403C-9B38-B8448D035D0D@bryant.edu> On Apr 19, 2008, at Apr 19:3:55 PM, Rick Muller wrote: > Do any of the AJAX frameworks for Python compare in simplicity to > writing a simple CGI script? I've been impressed with web.py, since it > seems pretty easy to use, but I would go to the trouble of learning > one of the bigger frameworks if they would provide a more elegant > solution. > I'd highly recommend web.py. You can even run it as a cgi script, if you want, but it has its own webserver. For larger scale stuff, they give directions for running it behind apache or lighttpd. It's very easy and flexible. are you using matplotlib for the plots? bb -- Brian Blais bblais at bryant.edu http://web.bryant.edu/~bblais -------------- next part -------------- An HTML attachment was scrubbed... URL: From Robert.Bossy at jouy.inra.fr Mon Apr 28 12:44:15 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Mon, 28 Apr 2008 18:44:15 +0200 Subject: Given a string - execute a function by the same name In-Reply-To: <1209400401.22706.1250293015@webmail.messagingengine.com> References: <1209400401.22706.1250293015@webmail.messagingengine.com> Message-ID: <4815FEDF.6080305@jouy.inra.fr> python at bdurham.com wrote: > I'm parsing a simple file and given a line's keyword, would like to call > the equivalently named function. > > There are 3 ways I can think to do this (other than a long if/elif > construct): > > 1. eval() > > 2. Convert my functions to methods and use getattr( myClass, "method" ) > > 3. Place all my functions in dictionary and lookup the function to be > called > > Any suggestions on the "best" way to do this? (3) is the securest way since the input file cannot induce unexpected behaviour. With this respect (1) is a folly and (2) is a good compromise since you still can write a condition before passing "method" to getattr(). Btw, if you look into the guts, you'll realize that (2) is nearly the same as (3)... RB From bruno.desthuilliers at gmail.com Thu Apr 17 10:33:52 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Thu, 17 Apr 2008 07:33:52 -0700 (PDT) Subject: why function got dictionary References: <48075950.7050000@gmail.com> Message-ID: <35f145d8-ee1c-406e-a036-7aa9ff62d971@c65g2000hsa.googlegroups.com> On 17 avr, 16:06, AlFire wrote: > Hi, > > I am seeking an explanation for following: > > Python 2.5.2 (r252:60911, Apr 8 2008, 21:49:41) > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> def g(): return > ... > >>> g.__dict__ > {} > > Q: why function got dictionary? What it is used for? A: everything (or almost) in Python is an object. Including functions, classes, modules etc. From patrickkidd.lists at gmail.com Thu Apr 17 09:30:08 2008 From: patrickkidd.lists at gmail.com (Patrick Stinson) Date: Thu, 17 Apr 2008 07:30:08 -0600 Subject: import hooks In-Reply-To: References: <664bf2b80804151814g480eed02w739047f84d9deb6b@mail.gmail.com> <664bf2b80804160504x72c870d8pdbfe8105a0c5ed11@mail.gmail.com> Message-ID: <664bf2b80804170630j47e6c7a8r692f5d80af2cc13f@mail.gmail.com> Right on, that seemed to work, thanks. This is different than sys.path_hooks though, which requires a callable or string subclass? After some experimentation it looks like you can disallow an import by raising an import error from your meta_path hook. It seems a little weird that python will then raise a new ImportError from import.c:find_module(), but I guess the behavior is desirable.. On Wed, Apr 16, 2008 at 5:17 PM, Gabriel Genellina wrote: > En Wed, 16 Apr 2008 09:04:36 -0300, Patrick Stinson > escribi?: > > > I am defining a simple finder/loader object and adding it to > > sys.meta_path > > like this: > > > > PyRun_SimpleString("import sys; import ousiainternal; sys.meta_path = > > [ousiainternal.OusiaImporter]"); > > You should append to the existing meta_path, not replace it, erasing any > previous content. > And it must be an *instance* of your importer, not the type itself. > Note that you're polluting the __main__ module namespace by using > PyRun_SimpleString; I'd use API calls like PySys_GetObject("meta_path") > and PyList_Append (PEP 302 guarantees it is a list). > > > "sys.meta_path.append(Importer)\n"; > > Here you append to sys.meta_path, but fail to create the instance first. > > > PyRun_SimpleString(importer_source); > > You should check the return value; I bet you got a -1 (failure). > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Patrick Kidd Stinson http://www.patrickkidd.com/ http://pkaudio.sourceforge.net/ http://pksampler.sourceforge.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From deets at nospam.web.de Tue Apr 8 11:53:57 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 08 Apr 2008 17:53:57 +0200 Subject: import statement convention References: <4078bcf4-e68f-45d4-93ce-335ec7a33c5a@v32g2000prd.googlegroups.com> Message-ID: <661iphF2i9sqvU1@mid.uni-berlin.de> MartinRinehart at gmail.com wrote: > By convention, I've read, your module begins with its import > statements. Is this always sensible? > > I put imports that are needed for testing in the test code at the end > of the module. If only a bit of the module has a visual interface, why > pollute the global namespace with 'from Tkinter import *'? Wouldn't > that be better done in a separate class or function? > > Can we do a better job with a thoughtful rewrite of this convention? Or you could write explicit tests in explicit modules instead of mingling both aspects together in one file. Would that be a thoughtful rewrite of your code? Diez From matiassurdi at gmail.com Thu Apr 17 03:11:39 2008 From: matiassurdi at gmail.com (Matias Surdi) Date: Thu, 17 Apr 2008 09:11:39 +0200 Subject: I just killed GIL!!! In-Reply-To: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: It's april 1st again??? sturlamolden escribi?: > Hello Guys... > > I just had one moment of exceptional clarity, during which realized > how I could get the GIL out of my way... It's so simple, I cannot help > wondering why nobody has thought of it before. Duh! Now I am going to > sit and and marvel at my creation for a while, and then go to bed > (it's past 2:30 a.m.) Tomorrow I will contemplate whether to sell this > little secret for big bucks, give it away for free, or just keep it to > myself... :-) > > Now you are probably thinking I reinvented the gunpowder, and are > running multiple processes. Not so. I am not running parallel > processes, like parallel python or the processing module in cheese > shop. I am running multiple THREADS. In fact, I am just using > threading.Thread. The source code is pure Python, so there is no C > magic, and I only used the stuff that's already there in the standard > library. So, I just made CPython do what everyone claim to be > impossible. One single process of CPython is using all the cpu power > of my dual-core laptop. > > > > > From stefan_ml at behnel.de Tue Apr 22 02:59:40 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 22 Apr 2008 08:59:40 +0200 Subject: py3k concerns. An example In-Reply-To: References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: <480D8CDC.8030606@behnel.de> Gabriel Genellina wrote: >> Has the standard library changed that much? I thought was it mainly the >> deletion of old seldom used modules that happens in new releases anyways. > > *and* renaming of old module names that don't follow PEP8, and merging > others into packages for better structure. > That's another point where using the 2to3 tool is necesary -it takes > care of such changes- unless one wants to maintain two branches. conditional imports were never a problem in Python. Once things are in their final place, you can add a try-except and import from two different places - unless (I assume) you want to use 2to3, which might even break this approach. Stefan From dhong at gist.ac.kr Tue Apr 29 20:00:13 2008 From: dhong at gist.ac.kr (Dongpyo Hong) Date: Wed, 30 Apr 2008 12:00:13 +1200 Subject: swig -python can't find _xxx.dll for windows Message-ID: <61B007AA-8ED3-499F-B787-DB6F2511A124@gist.ac.kr> Dear all, I wrapped c++ code with swig, and made _xxx.dll file. But, when I import xxx.py file from Python interpreter: import xxx it keeps saying that "ImportError: No module named _xxx" I checked sys.path and PATH environment. Why is that? Any explanation? --Dongpyo ===== Dongpyo Hong Research Assistant GIST U-VR Lab http://uvr.gist.ac.kr http://uvr.gist.ac.kr/~dhong Tel. +82-62-970-3157 (2279) Fax. +82-62-970-2204 Email. dhong at gist.ac.kr or dongpyo.hong at gmail.com ===== -------------- next part -------------- An HTML attachment was scrubbed... URL: From grante at visi.com Fri Apr 25 20:44:11 2008 From: grante at visi.com (Grant Edwards) Date: Fri, 25 Apr 2008 19:44:11 -0500 Subject: MESSAGE RESPONSE References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> <678v5qF2me5rvU1@mid.uni-berlin.de> <4e89b45d-198c-48ca-a3a6-3ba42448cb2b@e53g2000hsa.googlegroups.com> Message-ID: On 2008-04-25, ajaksu wrote: >> And as such, I find it hard to believe you could lose your job >> over it. > > Me too. That is, until I tried to Google Belcan and Blubaugh > together. May I suggest a new thread to clear that ugly > results? :D I know it's not nice to laugh at things like that, but I can't help it... I never saw the original message, so I didn't know exactly what he was objecting to. I did know that what he was doing was, well, let's just say counter-productive. -- Grant Edwards grante Yow! .. Now KEN and BARBIE at are PERMANENTLY ADDICTED to visi.com MIND-ALTERING DRUGS... From lbonafide at yahoo.com Tue Apr 1 12:57:55 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Tue, 1 Apr 2008 09:57:55 -0700 (PDT) Subject: Is this a good time to start learning python? References: <47f1140e$0$735$a729d347@news.telepac.pt> Message-ID: On Mar 31, 1:36?pm, "Gabriel Genellina" wrote: > Don't be scared by the "backwards incompatible" tag - it's the way to get ? > rid of nasty things that could not be dropped otherwise. I would consider breaking production code to be "nasty" as well. From rui.maciel at gmail.com Tue Apr 1 07:39:56 2008 From: rui.maciel at gmail.com (Rui Maciel) Date: Tue, 01 Apr 2008 12:39:56 +0100 Subject: Is this a good time to start learning python? References: <47f1140e$0$735$a729d347@news.telepac.pt> Message-ID: <47f21f31$0$755$a729d347@news.telepac.pt> After reading all replies I've decided to keep the subscription to this group, crank up the tutorials and start getting my head around Python. Thanks for all the helpful replies. Kudos, everyone! Rui Maciel From erikwickstrom at gmail.com Wed Apr 9 01:19:47 2008 From: erikwickstrom at gmail.com (erikcw) Date: Tue, 8 Apr 2008 22:19:47 -0700 (PDT) Subject: Can't figure out traceback: (error_proto(-ERR EOF) line 121 poplib.py Message-ID: <9904eabb-31e9-42df-b733-522aee7e3654@x19g2000prg.googlegroups.com> Hi, I keep getting this error from poplib: (error_proto(-ERR EOF) line 121 poplib.py Does this mean the connection has timed out? What can I do to deal with it? Thanks! Erik From popuser at christest2.dc.k12us.com Thu Apr 3 15:24:14 2008 From: popuser at christest2.dc.k12us.com (Pop User) Date: Thu, 03 Apr 2008 15:24:14 -0400 Subject: Efficient way of testing for substring being one of a set? In-Reply-To: References: <47f4c18e$0$715$bed64819@news.gradwell.net> <0c7fd327-7b96-4c20-8c74-a528e280b5f3@r9g2000prd.googlegroups.com> Message-ID: <47F52EDE.50904@christest2.dc.k12us.com> bearophileHUGS at lycos.com wrote: > Dennis Benzinger: >> You could use the Aho-Corasick algorithm > Aho-Corasick_algorithm>. >> I don't know if there's a Python implementation yet. > > http://hkn.eecs.berkeley.edu/~dyoo/python/ahocorasick/ > http://nicolas.lehuen.com/download/pytst/ can do it as well. From marco at sferacarta.com Mon Apr 14 07:06:49 2008 From: marco at sferacarta.com (Marco Mariani) Date: Mon, 14 Apr 2008 13:06:49 +0200 Subject: =?GB2312?B?tPC4tDogSmF2YSBvciBDKys/?= In-Reply-To: References: Message-ID: Penny Y. wrote: > Javascript is different from Java at all. I think even rocks know that. Yet, some use of closure and prototype-based inheritance might be interesting to the OP. > Why not Perl? Come on, learning Perl after two years of Python? How harsh. > Perl is a functional language, And gwbasic is object oriented. From pavlovevidence at gmail.com Wed Apr 2 14:14:42 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Wed, 2 Apr 2008 11:14:42 -0700 (PDT) Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> Message-ID: <25b1f081-94dc-461f-b836-9eba2b0907df@c65g2000hsa.googlegroups.com> On Apr 2, 10:52 am, sam wrote: > Then I say: > > -- __id is awful, because it is a trick to prefix names > > and gurus say: > > -- it is good solution for name conflicts > > But somebody may prefix his names with class names and cause nameconflict, so > maybe it is not so good? I would prefer to hear something like "other solutions > were very complex, and our zen says 'Simple is better than complex.', so we > decided to use this simple and not perfect solution" The stated purpose of the name mangling attributes is to minimize accidental conflicts, not to enforce data hiding. Carl Banks From diljeet_kr at yahoo.com Thu Apr 10 07:25:27 2008 From: diljeet_kr at yahoo.com (diljeet kaur) Date: Thu, 10 Apr 2008 16:55:27 +0530 (IST) Subject: problem with using gnuplot/demo.py Message-ID: <574751.90080.qm@web94914.mail.in2.yahoo.com> hi i want to use gnuplot with python i installed it seemingly successfully but when i try to run demo.py it gives the following error Traceback (most recent call last): File "C:\Python23\Lib\site-packages\Gnuplot\demo.py", line 113, in ? demo() File "C:\Python23\Lib\site-packages\Gnuplot\demo.py", line 39, in demo g.reset() File "C:\Python23\Lib\site-packages\Gnuplot\_Gnuplot.py", line 355, in reset self('reset') File "C:\Python23\Lib\site-packages\Gnuplot\_Gnuplot.py", line 199, in __call__ self.gnuplot(s) File "C:\Python23\Lib\site-packages\Gnuplot\gp_win32.py", line 125, in __call__ self.write(s + '\n') im using python23 & gnuplot1.7 please help Save all your chat conversations. Find them online at http://in.messenger.yahoo.com/webmessengerpromo.php -------------- next part -------------- An HTML attachment was scrubbed... URL: From inq1ltd at inqvista.com Fri Apr 11 22:48:17 2008 From: inq1ltd at inqvista.com (jim-on-linux) Date: Fri, 11 Apr 2008 22:48:17 -0400 Subject: tkinter, annoying grid-problem In-Reply-To: <094b0808-053a-4a36-be11-694bb3835bb5@q1g2000prf.googlegroups.com> References: <094b0808-053a-4a36-be11-694bb3835bb5@q1g2000prf.googlegroups.com> Message-ID: <200804112248.18121.inq1ltd@inqvista.com> On Friday 11 April 2008 18:41, skanemupp at yahoo.se wrote: > so my little calculator works perfectly > now. just having some trouble with the > layout. > this whole tkinter-thing seems to be more > tricky than it should be. how can i make > the 4 column of buttons have the same > distance and size between them as the > other 3 columns? and how can i make the > top entry end where the 2nd row entry > ends(meaning the top entry will be > longer)? > > why are the 4th row split from the others? > hard to fix the problems when u dont even > understand why things happen. seems so > llogical a lot of it. i change something > then something unexpected happens. > Look this file over. I built two additional frames. You can control the looks of the progect easier with the additional frames. The calculator DOES NOT WORK. You will have to have to play with it to get the results that you want, which you can do. jim-on-linux http://www.inqvista.com ###################################### class Calc : def __init__ (self) : self.mygui = Tk() self.mygui.title("Calculator") self.MkButtons() def MkButtons(self): mygui = self.mygui dataFra = Frame(mygui) dataFra.grid(row = 0, column = 0) l = Label(dataFra, text="Answer: ") l.grid(row=0, column=0, sticky=EW) self.e = Entry(dataFra) self.e.grid(row=1, column=0, sticky=EW) c = Entry(dataFra) c.grid(row=2, column=0, sticky=EW) x = 1 y = 4 butFra = Frame(mygui) butFra.grid(row=1, column=0) for n in '123+456-789*0()/.': b = Button(butFra, text= n, command = lambda :self.Disp(n), width=2, height=1) b.grid(row=y, column=x, sticky=W) x=x+1 if x==5: x=1 y=y+1 b = Button(butFra, text="^", command=self.Disp, width=2, height=1) b.grid(row=8, column=2, sticky=W) b = Button(butFra, text="C",command=self.Erase, width=2, height=1) b.grid(row=8, column=3, sticky=W) b = Button(butFra, text="c",command=self.Backspace, width=2, height=1) b.grid(row=8, column=4, sticky=W) b = Button(butFra, text="=",command=self.Calc, width=18, height=1) b.grid(row=9, column=1, columnspan=4, sticky=EW) def Disp(self, n): print n, '## n cal 68\n' n = ord(n) self.e.insert( 0,str( n)) def Calc(self): expr=e.get() c.delete(0, END) try: c.insert(END, eval(expr)) except: c.insert(END, "Not computable") def Erase(self): e.delete(0,END) c.delete(0, END) def Backspace(self): a=len(e.get()) e.delete(a-1,END) #e.delete(INSERT, END) #e.delete(ANCHOR,END) if __name__ == '__main__' : Calc() mainloop() ################################### ################################### > from __future__ import division > import Tkinter > from Tkinter import * > > mygui = Tkinter.Tk() > > mygui.title("Calculator") > > l = Label(mygui, text="Answer: ") > l.grid(row=2, column=1, columnspan=2, > sticky=W) > > e = Entry(mygui) > e.grid(row=1, column=1, columnspan=4, > sticky=W) > > c = Entry(mygui) > c.grid(row=2, column=3, columnspan=4, > sticky=W) > > def Disp(nstr): > e.insert(INSERT, nstr) > > def Calc(): > expr=e.get() > c.delete(0, END) > try: > c.insert(END, eval(expr)) > except: > c.insert(END, "Not computable") > > def Erase(): > e.delete(0,END) > c.delete(0, END) > > def Backspace(): > a=len(e.get()) > e.delete(a-1,END) > #e.delete(INSERT, END) > #e.delete(ANCHOR,END) > > > x = 1 > y = 4 > for char in '123+456-789*0()/.': > b = Button(mygui, text=char, > command=lambda n=char:Disp(n), width=2, > height=1) > b.grid(row=y, column=x, sticky=W) > x=x+1 > if x==5: > x=1 > y=y+1 > > b = Button(mygui, text="^", command=lambda > n="**":Disp(n), width=2, height=1) > b.grid(row=8, column=2, sticky=W) > b = Button(mygui, text="C",command=Erase, > width=2, height=1) b.grid(row=8, column=3, > sticky=W) b = Button(mygui, > text="c",command=Backspace, width=2, > height=1) b.grid(row=8, column=4, > sticky=W) b = Button(mygui, > text="=",command=Calc, width=18, height=1) > b.grid(row=9, column=1, columnspan=4, > sticky=W) > > mygui.mainloop() From steve at holdenweb.com Sat Apr 5 17:54:37 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 17:54:37 -0400 Subject: ANN: pry unit testing framework In-Reply-To: <20080405213059.GA19741@nullcube.com> References: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com> <20080405141329.GD15684@nullcube.com> <20080405213059.GA19741@nullcube.com> Message-ID: <47F7F51D.8010405@holdenweb.com> Aldo Cortesi wrote: > Steve, > >> Kay at least has a long history as a contributor in this group, so >> people know how to interpret her remarks and know that her contributions >> are made on the basis of a deep understanding of Python. She is far from >> belonging to the "peanut gallery", and to suggest otherwise betrays >> either ignorance, arrogance, or both. > > While I'm not a regular poster on this list, I have been reading it for > nearly 10 years, so I probably have more context here than you suspect. > At least one mail to this list and a number of personal emails to me > suggest that it is Kay and and indeed you who are temporarily out of > line with the tone of the list. A more impartial re-reading of the > debate so far might make you judge my final, admittedly angry, response > more fairly. > To be fair I wasn't commenting on the whole thread, more on the angry nature of your final reply, and didn't really consider Kay's remarks fully. So perhaps I could ask *both* of you to be more civil to each other, and leave it at that? Storm in a teacup, of course. I'm sure war won;t be declared about this. Consider the 200,000 (?) readers of the group who *didn't* complain about your post and your software as supporters, if you like :-) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From zedshaw at zedshaw.com Sat Apr 5 13:43:06 2008 From: zedshaw at zedshaw.com (Zed A. Shaw) Date: Sat, 5 Apr 2008 13:43:06 -0400 Subject: [ANN] Vellum 0.8: No More YAML, Some Python Message-ID: <20080405134306.b2bc65d6.zedshaw@zedshaw.com> Hello Everyone, This is a very fast announcement to say that I've managed to remove YAML from Vellum, but also to remove Python while still giving you Python. :-) Check out the latest Vellum: http://www.zedshaw.com/projects/vellum/ https://launchpad.net/vellum And you'll notice that the build descriptions are all Python, that you load other build descriptions with import statements, and yet it's still not actually running these build scripts. What the latest Vellum does is use a minimalist parser (vellum/parser.g) that is able to parse just that much syntax and build the data structure. This makes the build files safe from having injected code, but still gives you a full Python build description. This release is still in development, but if you want to install it, first install Zapps: http://www.zedshaw.com/projects/zapps/ And then you can install Vellum. Comments are welcome, especially about the actual safety of the code in vellum/parser.g and vellum/parser.py (generated by Zapps). Have fun. -- Zed A. Shaw - Hate: http://savingtheinternetwithhate.com/ - Good: http://www.zedshaw.com/ - Evil: http://yearofevil.com/ From bruno.desthuilliers at gmail.com Wed Apr 2 18:55:19 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 15:55:19 -0700 (PDT) Subject: function call - default value & collecting arguments References: <_LQIj.9776$HS3.482805@news.siol.net> <7e50544d-6daf-48c2-bb82-be06d3590450@8g2000hsu.googlegroups.com> Message-ID: On 2 avr, 22:32, "Primoz Skale" wrote: > >> I also understand (fairly) how to collect arguments. For example, let's > >> define another function: > > >> def f(*a): > >> print a > > > This means that f takes any number of optional positional arguments. > > If nothing is passed, within f, 'a' will be an empty tuple. Note that > > this is *not* the usual way to define a function taking multiple > > (mandatory) arguments. > > M. Lutz in "Learning Python" had defined it this way. What is the *usual* > way in this case? You mean : "what's the usual way to define a function taking multiple *mandatory* arguments" ? I'd think it's explained in your book ??? def f(a, b, c): print a, b, c But this is such a cs101 point that we're surely misunderstanding each other here. > > > or (slightly more involved, and certainly overkill): > > > def with_default_args(default): > > def decorator(func): > > def wrapper(*args): > > if not args: > > args = default > > return func(*args) > > return wrapper > > return decorator > > > @with_default_args((0,)) > > def f(*a): > > print a[0] > > Now, this is interesting. Thanks! :) Dont take this as a "recommanded" solution to your problem - it was (mostly) to be exhaustive (and a bit on the "showing off" side too to be honest). From arnodel at googlemail.com Sun Apr 6 12:20:56 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 6 Apr 2008 09:20:56 -0700 (PDT) Subject: append to a sublist - please help References: <47f8f743$0$2983$ba620e4c@news.skynet.be> Message-ID: <6e0d2a37-d57e-4fe3-be43-0c0b4eb3c57c@1g2000prg.googlegroups.com> On Apr 6, 5:16?pm, Helmut Jarausch wrote: > Hi, > > I must be blind but I don't see what's going wrong > with > > G=[[]]*2 > > G[0].append('A') > G[1].append('B') > print G[0] > > gives > > ['A', 'B'] > > as well as > print G[1] > > I was expecting > ['A'] > and > ['B'] > respectively. > > Many thanks for enlightening me, > Helmut. > > -- > Helmut Jarausch > > Lehrstuhl fuer Numerische Mathematik > RWTH - Aachen University > D 52056 Aachen, Germany This is in the top two FAQ, here is the relevant section: http://www.python.org/doc/faq/programming/#how-do-i-create-a-multidimensional-list HTH -- Arnaud From nagle at animats.com Thu Apr 10 23:57:20 2008 From: nagle at animats.com (John Nagle) Date: Thu, 10 Apr 2008 20:57:20 -0700 Subject: Python conventions In-Reply-To: References: Message-ID: <47fedf0e$0$36390$742ec2ed@news.sonic.net> Daniel Fetchinson wrote: > I'm sorry to disappoint you but this project has already been completed: > > http://www.python.org/dev/peps/pep-0008/ Good point. It's probably time for CPython to enforce the rule that you can indent with either tabs or spaces, but cannot mix them. Which to use is ideological; mixing them is a bug. John Nagle From sami.islam at NOSPAMbtinternet.com Sun Apr 6 08:41:40 2008 From: sami.islam at NOSPAMbtinternet.com (Sami) Date: Sun, 06 Apr 2008 13:41:40 +0100 Subject: Problems trying to hook own exception function to sys.excepthook In-Reply-To: References: Message-ID: <8r6dneajtO-cWGXanZ2dnUVZ8s7inZ2d@bt.com> Peter Otten wrote: > Sami wrote: > >> Hello, >> >> I am new to Python. >> >> I tried to hook my own ExceptionPrintingFunction sys.excepthook but it >> does not work. >> >> This is what I wrote: >> ----------------------------------------------------------------------- >> import sys >> >> def MyOwnExceptHook(typ, val, tb): >> print "Inside my own hook" >> >> sys.excepthook = MyOwnExceptHook >> >> x = 1/0 >> ----------------------------------------------------------------------- >> This is what I get >> ----------------------------------------------------------------------- >> Traceback (most recent call last): >> File >> "E:/Home/Programming/Python/TryProjects/ExceptHandling1/Except5.py", >> line 8, in >> x = 1/0 >> ZeroDivisionError: integer division or modulo by zero >> ----------------------------------------------------------------------- >> >> I never see "Inside my own hook" which tells me that the hook is not >> being called. What I really want to test is to stop the exception from >> propagating further and leave the program intact. >> >> What am I doing wrong? Please let me know if there are any other newbie >> groups that I should probably try in stead. > > Are you running your code from within idle? It wraps your script in > something like > > try: > # run script > except: > # show traceback > > (Have a look at InteractiveInterpreter.runcode() in code.py if you are > interested in the actual code) > > So your except hook never gets to see the exception and therefore won't be > invoked. Run your script from the commandline and you will see the > behaviour you expected. > > Peter > Great!! Thank you. I have been trying since yesterday to get to the bottom of this. Does this mean that one should always use the command line to run a python program? Sami From gagsl-py2 at yahoo.com.ar Tue Apr 22 15:35:27 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 22 Apr 2008 16:35:27 -0300 Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> Message-ID: En Tue, 22 Apr 2008 13:50:54 -0300, J?r?my Wagner escribi?: > Sure. Python is more readable than Perl, though I have found Python > to have a weird behavior regarding this little issue : > > How can you explain that Python doesn't support the ++ opeator, > whereas at the same time it does support the += operator ??? > > No python developer I know has been able to answer that. Because Python doesn't follow the "boxed variables" model. In other languages i++ changes the "value" stored inside the box "i", but the box itself (the variable) is still the same. Python doesn't have boxes, it has names that refer to objects. For all builtin numeric types, i += 1 creates a *new* object with the resulting value and makes the name "i" refer to this new object. i++ would be confusing because it looks like a mutating operation over i, but in fact it would be an assignment. -- Gabriel Genellina From skip at pobox.com Fri Apr 11 12:24:33 2008 From: skip at pobox.com (skip at pobox.com) Date: Fri, 11 Apr 2008 11:24:33 -0500 Subject: Multiple independent Python interpreters in a C/C++ program? Message-ID: <18431.37057.886339.853171@montanaro-dyndns-org.local> This question was posed to me today. Given a C/C++ program we can clearly embed a Python interpreter in it. Is it possible to fire up multiple interpreters in multiple threads? For example: C++ main thread 1 Py_Initialize() thread 2 Py_Initialize() Do I wind up with two completely independent interpreters, one per thread? I'm thinking this doesn't work (there are bits which aren't thread-safe and are only protected by the GIL), but wanted to double-check to be sure. Thanks, Skip From bj_666 at gmx.net Sat Apr 5 17:17:50 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 5 Apr 2008 21:17:50 GMT Subject: Tkinter, add pressed buttons onto string display string, how to? References: <57605958-5589-4ebe-abdf-73c2d14c8a82@u10g2000prn.googlegroups.com> Message-ID: <65q8juF2gq610U2@mid.uni-berlin.de> On Sat, 05 Apr 2008 13:17:45 -0700, skanemupp wrote: >> input = "hello" >> input += " world" >> print input > > this i know. im wondering how to handle the variable in the actual > program. this exception i get: > Exception in Tkinter callback > Traceback (most recent call last): > File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ > return self.func(*args) > File "C:\Users\saftarn\Desktop\guiexperiments\calculatorGUI.py", > line 48, in > self.btnDisplay = Button(self,text='+',command=lambda > n="+":self.Display(n),width=1,height=1) > File "C:\Users\saftarn\Desktop\guiexperiments\calculatorGUI.py", > line 92, in Display > str = number + str > UnboundLocalError: local variable 'str' referenced before assignment Just like the message says: You are trying to use `str` (on the right hand side of the assignment) before anything is bound to that name. Ciao, Marc 'BlackJack' Rintsch From kveretennicov at gmail.com Tue Apr 8 18:22:47 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Wed, 9 Apr 2008 01:22:47 +0300 Subject: makepy.py not working In-Reply-To: <03e9c33d-d957-4bc0-8568-3a40403eadb9@a70g2000hsh.googlegroups.com> References: <03e9c33d-d957-4bc0-8568-3a40403eadb9@a70g2000hsh.googlegroups.com> Message-ID: <4660fe300804081522g61c51b1fk1fe038f530dbde1b@mail.gmail.com> On Tue, Apr 8, 2008 at 4:18 PM, wrote: > Hallo, > > I've a problem getting makepy running. When I start the tool on my > machine with doubleclick everything is fine. > But when I try this in my Code: > > makepy.py -i "Microsoft Excel 11.0 Object Library(1.5)" This syntax is used to run makepy.py script from command line. > > I am getting an Syntax Error and command: > > makepy.py > > bring me this message on the screen: > > Traceback (most recent call last): > File "", line 1, in > NameError: name 'makepy' is not defined > > Any ideas what I am doing wrong? Python interpreter obviously accepts only valid python code, like this: import win32com.client.makepy win32com.client.makepy.ShowInfo("Microsoft Excel 11.0 Object Library(1.5)") -- kv From paulgeeleher at gmail.com Thu Apr 24 07:32:58 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Thu, 24 Apr 2008 04:32:58 -0700 (PDT) Subject: Spawing a thread and printing dots until it finishes References: Message-ID: <8df7dc55-7f93-4569-9643-21b4c99e2f33@l42g2000hsc.googlegroups.com> On Apr 22, 3:10 pm, sophie_newbie wrote: > Hi, I'm trying to write a piece of code that spawns a thread and > prints dots every half second until the thread spawned is finished. > Code is > something like this: > > import threading > class MyThread ( threading.Thread ): > def run ( self ): > myLongCommand()... > > import time > > t = MyThread() > t.start() > > while t.isAlive(): > print "." > time.sleep(.5) > > print "OK" > > The thing is this doesn't print a dot every half second. It just > pauses for ages until the thread is finished and prints prints ".OK". > But if I take out the "time.sleep(.5)" line it will keep printing dots > really fast until the thread is finished. So it looks like its the > time.sleep(.5) bit that is messing this up somehow? > > Any ideas? > > Thanks! As it happens I've managed to come up with a solution to this problem using a subprocess rather than a thread. Its not exactly rocket science but I thought I'd post it anyway. There are 3 files: ########## dots.py ####################### # a script to print a dot every half second until it is terminated import time import sys while 1 == 1: sys.stdout.write(".") sys.stdout.flush() time.sleep(.5) ######### PrintDots.py ###################### # This is a simple class to spawn off another process that prints dots repeatedly on screen # when printDots() is called and stops when stopDots is called. It is useful in cgi-scripts # where you may want to let the user know that something is happening, rather than looking # at a blank screen for a couple of minutes. import time import subprocess import os from signal import SIGTERM class PrintDots: # the constructor, called when an object is created. def __init__(self): self.pid = 0 # the location of the script that prints the dots self.dotsScript = "dots.py" def printDots(self): self.pid = subprocess.Popen( [ "python", self.dotsScript] ).pid def stopDots(self): os.kill(self.pid, SIGTERM) ############ mainFile.py ############################## # The above can then be called from any cgi-script as follows from PrintDots import PrintDots p = PrintDots() p.printDots() print "Doing R Stuff" my_Call_To_R_That_Takes_A_Long_Time() p.stopDots() print "OK" ############ And low and behold dots are printed on screen every half second while python is talking to R, with an output like this: Doing R Stuff.................................OK From carlwuhwdmckay at gmail.com Sat Apr 26 09:29:41 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:29:41 -0700 (PDT) Subject: fentanyl patch Message-ID: <1f222cea-1d75-4c92-840f-4db724d628de@w7g2000hsa.googlegroups.com> fentanyl patch http://cracks.00bp.com F R E E C R A C K S From bvidinli at gmail.com Wed Apr 23 15:23:55 2008 From: bvidinli at gmail.com (bvidinli) Date: Wed, 23 Apr 2008 22:23:55 +0300 Subject: Python development tools In-Reply-To: References: Message-ID: <36e8a7020804231223l29cae152o266c0d9bcde821d5@mail.gmail.com> i saw boa constructor to be most close to delphi in python editors.. it is still far away from delphi but, it is closest anyway. 2008/4/23, wongjoekmeu at yahoo.com : > Are there any completely free developent tools for python scripts like > IDLE. I have used IDLE , but I want to try out others also. I saw > stuff like PyCrust, but I don't see that it can run the script as > well. > Thanks, > > RR > > -- > http://mail.python.org/mailman/listinfo/python-list > -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From timr at probo.com Tue Apr 1 02:03:14 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 01 Apr 2008 06:03:14 GMT Subject: CTypes, 64 bit windows, 32 bit dll References: <5a0d8c47-f1b7-4eae-9911-b312a1166757@d1g2000hsg.googlegroups.com> Message-ID: <5uj3v39d6e4ok6o7qda4vagfg4h68kv4th@4ax.com> rdahlstrom wrote: >On Mar 31, 12:53 pm, "mimi.vx" wrote: >> On Mar 31, 4:22 pm, rdahlstrom wrote: >> >> > So I have a 64 bit Windows 2003 system, running python 2.5.1.1. >> >> > I can import a Windows .dll (msvcrt or whatever) using ctypes, but >> > when attempting to import another application-specific .dll (tibrv.dll >> > if anyone is familiar with it), I receive the error WindowsError: >> > [Error 193] %1 is not a valid Win32 application. >> >> > I know there's a Windows on Windows (wow) which allows 32 bit >> > processes to run on 64 bit windows - is there a way to work this in >> > somehow? Maybe I'm barking up the wrong tree? >>... >> >> all dlls and python must be 32bit or 64bit, no mixed ... > >Crap, no way to make a 32 bit load, even using the wowexec? No. In Win64, a process is either entirely 32-bit, or entirely 64-bit. To do the kind of crossing you seek, you would need to create a separate process for the 32-bit DLL and use interprocess communication. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From tim.arnold at sas.com Fri Apr 25 13:29:54 2008 From: tim.arnold at sas.com (Tim Arnold) Date: Fri, 25 Apr 2008 13:29:54 -0400 Subject: convert xhtml back to html References: Message-ID: "bryan rasmussen" wrote in message news:mailman.138.1209061180.12834.python-list at python.org... > I'll second the recommendation to use xsl-t, set the output to html. > > > The code for an XSL-T to do it would be basically: > version="1.0"> > > > > > you would probably want to do other stuff than just copy it out but > that's another case. > > Also, from my recollection the solution in CHM to make XHTML br > elements behave correctly was
as opposed to
, at any rate > I've done projects generating CHM and my output markup was well formed > XML at all occasions. > > Cheers, > Bryan Rasmussen Thanks Bryan, Walter, John, Marc, and Stefan. I finally went with the xslt transform which works very well and is simple. regexps would work, but they just scare me somehow. Brian, my tags were formatted as
but the help compiler would issue warnings on each one resulting in log files with thousands of warnings. It did finish the compile though, but it made understanding the logs too painful. Stefan, I *really* look forward to being able to use lxml when I move to RH linux next month. I've been using hp10.20 and never could get the requisite libraries to compile. Once I make that move, maybe I won't have as many markup related questions here! thanks again to all for the great suggestions. --Tim Arnold From hniksic at xemacs.org Wed Apr 9 08:03:14 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Wed, 09 Apr 2008 14:03:14 +0200 Subject: Basic optimization of python. References: <663p3lF2go90rU1@mid.uni-berlin.de> Message-ID: <877if7b5h9.fsf@mulj.homelinux.net> "Diez B. Roggisch" writes: >> Eg: >> a = 1 + 2 >> .vs. >> a = 3 >> which one is more effective? Does the compiler calculate the result at >> compile time? How about constant spreading? > > Algebraic optimizations aren't done AFAIK Just try it: Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> dis.dis(lambda: 10+5) 1 0 LOAD_CONST 2 (15) 3 RETURN_VALUE From jcd at sdf.lonestar.org Fri Apr 18 07:27:37 2008 From: jcd at sdf.lonestar.org (J. Clifford Dyer) Date: Fri, 18 Apr 2008 07:27:37 -0400 Subject: Unicode chr(150) en dash In-Reply-To: <20080418102856.fdf5ddf3.marexposed@googlemail.com> References: <48063434$0$36327$742ec2ed@news.sonic.net> <7dae96d4-48c4-46c9-9aa9-33a263b84ca4@26g2000hsk.googlegroups.com> <20080418102856.fdf5ddf3.marexposed@googlemail.com> Message-ID: <1208518057.6200.6.camel@jcd-desktop> On Fri, 2008-04-18 at 10:28 +0100, marexposed at googlemail.com wrote: > On Thu, 17 Apr 2008 20:57:21 -0700 (PDT) > hdante wrote: > > > Don't use old 8-bit encodings. Use UTF-8. > > Yes, I'll try. But is a problem when I only want to read, not that I'm trying to write or create the content. > To blame I suppose is Microsoft's commercial success. They won't adhere to standars if that doesn't make sense for their business. > > I'll change the approach trying to filter the contents with htmllib and mapping on my own those troubling characters. > Anyway this has been a very instructive dive into unicode for me, I've got things cleared up now. > > Thanks to everyone for the great help. > There are a number of code points (150 being one of them) that are used in cp1252, which are reserved for control characters in ISO-8859-1. Those characters will pretty much never be used in ISO-8859-1 documents. If you're expecting documents of both types coming in, test for the presence of those characters, and assume cp1252 for those documents. Something like: for c in control_chars: if c in encoded_text: unicode_text = encoded_text.decode('cp1252') break else: unicode_text = encoded_text.decode('latin-1') Note that the else matches the for, not the if. You can figure out the characters to match on by looking at the wikipedia pages for the encodings. Cheers, Cliff From nospam1.reifenberg at gmx.de Sat Apr 5 03:41:48 2008 From: nospam1.reifenberg at gmx.de (Nebur) Date: Sat, 5 Apr 2008 00:41:48 -0700 (PDT) Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? References: <47F67798.3060401@gmail.com> Message-ID: <9c46f378-9d6f-4445-be73-d70a1da6ffb2@m44g2000hsc.googlegroups.com> > Implement what? The virus? I haven't said that I'm interested in virus, > I meant I'd like to know WHAT is this No, this was a misunderstanding. What we meant was: when you want to implement a virus, you should use a version control :- D Nebur From kelle.lavoni at gmail.com Wed Apr 16 11:17:09 2008 From: kelle.lavoni at gmail.com (kelle.lavoni at gmail.com) Date: Wed, 16 Apr 2008 08:17:09 -0700 (PDT) Subject: kate hudson bathing suit Message-ID: <7bf02760-96c0-4a34-96bd-50c6a8b9f565@l64g2000hse.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From bijeshn at gmail.com Fri Apr 4 02:07:48 2008 From: bijeshn at gmail.com (bijeshn) Date: Thu, 3 Apr 2008 23:07:48 -0700 (PDT) Subject: splitting an XML file on the basis on basis of XML tags References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> <65klukF2fp6mkU1@mid.uni-berlin.de> Message-ID: <1228b2c2-1dc3-4a7a-8f75-30edfc903dab@d21g2000prf.googlegroups.com> On Apr 3, 11:28?pm, "Diez B. Roggisch" wrote: > > I abuse it because I can (and because I don't generally work with XML > > files larger than 20-30meg) :) > > And the OP never said the XML file for 1TB in size, which makes things > > different. > > Even with small xml-files your advice was not very sound. Yes, it's > tempting to use regexes to process xml. But usually one falls flat on > his face soon - because of whitespace or attribute order or > versus or .. or .. or. > > Use an XML-parser. That's what they are for. And especially with the > pythonic ones like element-tree (and the compatible lxml), its even more > straight-forward than using rexes. > > Diez yeah, i plan to use SAX.. but the thing is how do you do it with that?.... forget 1 TB for now... how do you split an XML file which is something like 70-80 GB... on the basis of my need (thats the post.)? From skanemupp at yahoo.se Sat Apr 5 13:04:56 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 10:04:56 -0700 (PDT) Subject: Tkinter: making buttons the same size? References: <12bad1a6-3b4b-446e-9673-8893cd6838f9@s37g2000prg.googlegroups.com> Message-ID: <3753aa85-c844-4e54-8213-142e50fd8a7e@b5g2000pri.googlegroups.com> how do i do that? i get this error: self.btnDisplay = Button(self,text='1',command=lambda n=1:self.Display(n)) self.btnDisplay.grid(row=3, column=0, padx=5, pady=5, width=1) self.btnDisplay = Button(self,text='/',command=lambda n="/":self.Display(n)) self.btnDisplay.grid(row=6, column=3, padx=5, pady=5, width=1) Traceback (most recent call last): File "C:\Users\saftarn\Desktop\guiexperiments \calcguiworkingshort.py", line 37, in guiFrame = GUIFramework() File "C:\Users\saftarn\Desktop\guiexperiments \calcguiworkingshort.py", line 20, in __init__ self.CreateWidgets() File "C:\Users\saftarn\Desktop\guiexperiments \calcguiworkingshort.py", line 28, in CreateWidgets self.btnDisplay.grid(row=3, column=0, padx=5, pady=5, width=1) File "C:\Python25\lib\lib-tk\Tkinter.py", line 1859, in grid_configure + self._options(cnf, kw)) TclError: bad option "-width": must be -column, -columnspan, -in, - ipadx, -ipady, -padx, -pady, -row, -rowspan, or -sticky From barbaros at ptmat.fc.ul.pt Wed Apr 23 04:54:13 2008 From: barbaros at ptmat.fc.ul.pt (barbaros) Date: Wed, 23 Apr 2008 01:54:13 -0700 (PDT) Subject: help needed with classes/inheritance Message-ID: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> Hello everybody, I am building a code for surface meshes (triangulations for instance). I need to implement Body objects (bodies can be points, segments, triangles and so on), then a Mesh will be a collection of bodies, together with their neighbourhood relations. I also need OrientedBody objects, which consist in a body together with a plus or minus sign to describe its orientation. So, basically an OrientedBody is just a Body with an integer label stuck on it. I implemented it in a very crude manner: ------------------------------------------ class Body: [...] class OrientedBody: def __init__ (self,b,orient=1): # b is an already existing body assert isinstance(b,Body) self.base = b self.orientation = orient ------------------------------------------- My question is: can it be done using inheritance ? I recall that I need three distinct objects: the basic (non-oriented) body, the same body with positive orientation and the same body with negative orientation. Thank you. Cristian Barbarosie http://cmaf.fc.ul.pt/~barbaros From mcaloney at gmail.com Tue Apr 15 11:35:52 2008 From: mcaloney at gmail.com (Chris McAloney) Date: Tue, 15 Apr 2008 11:35:52 -0400 Subject: py3k s***s In-Reply-To: <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: <0A685715-6D44-4D41-87C2-4B971A751E78@gmail.com> On 15-Apr-08, at 12:30 AM, Sverker Nilsson wrote: > No one forces me, but sooner or later they will want a Python 3.0 and > then a 3.1 whatever. > > I don't want that fuzz. As about the C versions, I am not that > worried. What's your point? > > I just like want to write a program that will stay working. And maybe > I can go on with something else hopefully than just compatibility > fixes. They take some work afterall. > > It seems hard with Python. Esp. 2 -> 3 I couldn't help but notice that not only did you not address Gabriel's most important question, you excluded it from the quote below and changed the comma to a period. Gabriel said: "There is a strategy to migrate from 2.x to 3.0, including the 2to3 tool. Have you used it?" *Have* you tried the 2to3 tool? It might help to lessen your concerns a bit. Yes, Python 3 is different from 2.x, but we've known that it was going to be for years and, as has already been pointed out, the devs are being very careful to minimize the pain that the changes will inflict on Python programmers, with tools such as 2to3. Chris > On Apr 15, 5:41 am, "Gabriel Genellina" > wrote: >> En Mon, 14 Apr 2008 23:38:56 -0300, Sverker Nilsson >> escribi?: >> >> >> >>> On Apr 15, 3:50 am, "Gabriel Genellina" >>> wrote: >>>> En Mon, 14 Apr 2008 22:02:38 -0300, Sverker Nilsson >>>> escribi?: >> >>>>> I tried out py3k on my project,http://guppy-pe.sf.net >> >>>> And what happened? >>>> I've seen that your project already supports Python 2.6 so the >>>> migration >>>> path to 3.0 should be easy. >> >>> 2.6 was no big deal, It was an annoyance that they had to make >>> 'as' a >>> reserved word. Annoyances were also with 2.4, and 2.5. No big >>> problems, I could make guppy backwards compatible to 2.3. But that >>> seems not to be possible with Python 3.x ... it is a MUCH bigger >>> change. And it would require a fork of the code bases, in C, >>> Guido has >>> written tha or to sprinkle with #ifdefs. Would not happen soon >>> for me. >>> It takes some work anyways. Do you volunteer, Guido van Rossum? :-) >> >>> It's not exactly easy. Perhaps not very hard anyways. But think of >>> 1000's of such projects. How many do you think there are? I think >>> many. How many do yo think care? I think few. >> >>> When it has been the fuzz with versions before, then I could have >>> the >>> same code still work with older versions. But now it seems I have to >>> fork TWO codes. It's becoming too much. Think of the time you could >>> write a program in C or even C++ and then it'll work. How do you >>> think >>> eg writers of bash or other unix utilities come along. Do they >>> have to >>> rewrite their code each year? No, it stays. And they can be happy >>> about that, and go on to other things. Why should I have to think >>> about staying compatible with the newest fancy Python all the >>> time? NO >>> -- but the answer may be, they don't care, though the others (C/C++, >>> as they rely on) do. :-( >> >> You can stay with Python 2.6 and not support 3.0; nobody will >> force you to >> use it. And nobody will come and wipe out your Python >> installation, be it >> 2.6, 2.1 or whatever. And if you still enjoy using Python 1.5, >> please keep >> using it - it won't disappear the day after 3.0 becomes available. >> >> Regarding the C language: yes, souce code *had* to be modified for >> newer >> versions of the language and/or compiler. See by example, the new >> "restrict" keyword in C99, or the boolean names. The C guys are >> much more >> concerned about backwards compatibility than Python, but they can't >> guarantee that (at risk of freezing the language). The 3.0 >> incompatibilities are all justified, anyway, and Python is >> changing (as a >> language) much more than C - and that's a good thing. >> >> There is a strategy to migrate from 2.x to 3. From ABH at MCHSI.COM Sun Apr 13 12:07:23 2008 From: ABH at MCHSI.COM (Hutch) Date: Sun, 13 Apr 2008 16:07:23 GMT Subject: PythonWin Print Problem.. Build 210 References: Message-ID: <%cqMj.118543$yE1.5692@attbi_s21> "Roger Upole" wrote in message news:mailman.346.1208051713.17997.python-list at python.org... > > "Hutch" wrote in message > news:H29Mj.117410$yE1.54267 at attbi_s21... >> PythonWin has been a very good ide from early version thru 2.4. >> >> All work ok on THREE of my computers with THREE different HP printers. >> >> Now comes 2.5. >> Every thing seems to work the same except when I want to print out a copy >> of the source code of my project (about 38 pages) >> >> Version 2.5 acts like it is going to print out the source code but >> instead >> prints from several 100 to over 2000 BLANK PAGES pages and no source. >> >> Attempting to print out Source on SAME equipment (computers and printers) >> using 2.4 (WITH NO CHANGES TO EQUIPMENT OR SOFTWARE ) results in >> proper print out of source. >> >> Problem has been reported via direct and SourceForge but no response. >> >> Any body else having the same problem? >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > Did you see the response to the bug report on SF ? > http://sourceforge.net/tracker/index.php?func=detail&aid=1907148&group_id=78018&atid=551954 > > There is also some more info in this thread on the python-win32 mailing > list: > http://mail.python.org/pipermail/python-win32/2006-December/005397.html > > Roger Sorry to report after uninstalling both Python 2.5 and Pythonwin 2.5 and reinstalling.. THE PROBLEM IS STILL WITH US... From wizzardx at gmail.com Sun Apr 27 09:53:31 2008 From: wizzardx at gmail.com (David) Date: Sun, 27 Apr 2008 15:53:31 +0200 Subject: Question regarding Queue object In-Reply-To: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> Message-ID: <18c1e6480804270653r2e075061wf442b7b7d9f50ff6@mail.gmail.com> > WaitMsg will get only msg with certain ids, but this is not possible > in Queue object, because Queue provides no method to peek into the > message queue and fetch only matched item. > > Now I'm using an ugly solution, fetch all the messages and put the not > used ones back to the queue. But I want a better performance. Is there > any alternative out there? > You could try a defaultdict containing queues, one queue per message ID. Or you could implement your own thread-safe LookAheadQueue class. David From aahz at pythoncraft.com Fri Apr 4 13:28:21 2008 From: aahz at pythoncraft.com (Aahz) Date: 4 Apr 2008 10:28:21 -0700 Subject: troll poll References: <65eee6F2eg18jU1@mid.uni-berlin.de> <143a9f24-668e-4e30-a803-c272da27f3ff@s13g2000prd.googlegroups.com> Message-ID: In article <143a9f24-668e-4e30-a803-c272da27f3ff at s13g2000prd.googlegroups.com>, alex23 wrote: > >That is awesome, thank you so much for posting this. The usual >response to complaining about the lack of a killfile for Google Groups >has been "use a decent client", but as I'm constantly moving between >machines having a consistent app for usenet has more value to me. That's why I ssh into my ISP for trn3.6 ;-) -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "It is easier to optimize correct code than to correct optimized code." --Bill Harlan From gdetre at princeton.edu Tue Apr 15 21:59:38 2008 From: gdetre at princeton.edu (gdetre at princeton.edu) Date: Tue, 15 Apr 2008 18:59:38 -0700 (PDT) Subject: OverflowError: regular expression code size limit exceeded Message-ID: <3a2194c6-c753-460a-b797-085f0b2228fa@m36g2000hse.googlegroups.com> Dear all, I'm trying to get a large, machine-generated regular expression (many thousands of characters) to work in Python on a Mac (running Leopard), and I keep banging my head against this brick wall: >>> update_implicit_link_regexp_temp() Traceback (most recent call last): File "", line 1, in File "/Users/greg/elisp/freex/freex_sqlalchemy.py", line 715, in update_implicit_link_regexp_temp impLinkRegexp = re.compile(aliasRegexpStr,re.IGNORECASE| re.MULTILINE) File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/re.py", line 180, in compile return _compile(pattern, flags) File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/re.py", line 231, in _compile p = sre_compile.compile(pattern, flags) File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/sre_compile.py", line 530, in compile groupindex, indexgroup OverflowError: regular expression code size limit exceeded I have successfully run this regular expression many times under linux. I tried it first with the default python iinstallation on Leopard, 2.5.1, but I've also tried it with tthe latest .dmg i could find on the python.org site: Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin I'm really lost about how to proceed. Any ideas? Thank you, Greg From sturlamolden at yahoo.no Fri Apr 11 19:18:40 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 11 Apr 2008 16:18:40 -0700 (PDT) Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> <47ffee86$0$6838$2d805a3e@textnews.eweka.nl> <15e5c81b-0b21-44f0-9282-0d1495bc6bb3@z24g2000prf.googlegroups.com> Message-ID: <1e299792-b744-47c5-ae1d-6fb78639f840@w8g2000prd.googlegroups.com> On Apr 12, 12:32 am, Rune Strand wrote: > produce "what I want" without _wasting life_. But Boa is too unstable, > and does not claim otherwise, and there's no descent alternative I'm > aware of. wxFormDesigner is the best there is for wx. QtDesigner ditto for Qt. Glade ditto for GTK. To use them with Python, you should have the GUI saved in an xml resource (.xrc, .ui, or .glade respectively). From aahz at pythoncraft.com Mon Apr 7 20:44:31 2008 From: aahz at pythoncraft.com (Aahz) Date: 7 Apr 2008 17:44:31 -0700 Subject: troll poll References: <143a9f24-668e-4e30-a803-c272da27f3ff@s13g2000prd.googlegroups.com> <93477f36-fd07-4659-b3ab-29b9cc35bb8d@w5g2000prd.googlegroups.com> Message-ID: In article <93477f36-fd07-4659-b3ab-29b9cc35bb8d at w5g2000prd.googlegroups.com>, alex23 wrote: >(Aahz) wrote: >> alex23 wrote: >>> >>>The usual >>>response to complaining about the lack of a killfile for Google Groups >>>has been "use a decent client", but as I'm constantly moving between >>>machines having a consistent app for usenet has more value to me. >> >> That's why I ssh into my ISP for trn3.6 ;-) > >So what you're saying is, basically, "use a decent client"? :) Partially, but I'm also saying that you should use a decent platform. ;-) -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "It is easier to optimize correct code than to correct optimized code." --Bill Harlan From steve at holdenweb.com Wed Apr 16 11:09:37 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 16 Apr 2008 11:09:37 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> Message-ID: Mike Driscoll wrote: > On Apr 16, 9:19 am, Grant Edwards wrote: >> This morning almost half of c.l.p was spam. In order to try to >> not tar both the benign google group users and the malignant >> ones with the same brush, I've been trying to kill usenet spam >> with subject patterns. But that's not a battle you can win, so >> I broke down and joined all the other people that just killfile >> everything posted via google.groups. >> >> AFAICT, if you're a google groups user your posts are not being >> seen by many/most experienced (read "non-google-group") users. >> This is mainly the fault of google who has refused to do >> anything to stem the flood of span that's being sent via Google >> Groups. >> >> -- >> Grant Edwards grante Yow! I would like to >> at urinate in an OVULAR, >> visi.com porcelain pool -- > > Yeah, I noticed that Google Groups has really sucked this week. I'm > using the Google Groups Killfile for Greasemonkey now and it helps a > lot. I like Google, but my loyalty only goes to far. This is a > complete lack of customer service. > Unfortunately this means Google groups users are getting exactly the service they are paying for. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From steve at holdenweb.com Thu Apr 3 02:51:42 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 03 Apr 2008 02:51:42 -0400 Subject: splitting an XML file on the basis on basis of XML tags In-Reply-To: References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> Message-ID: <47F47E7E.3000406@holdenweb.com> bijeshn wrote: > On Apr 2, 5:37 pm, Chris wrote: >> bije... at gmail.com wrote: >>> Hi all, >>> i have an XML file with the following structure:: >>> >>> -----| >>> | >>> | >>> . | >>> . | --------------------> constitutes one record. >>> . | >>> . | >>> . | >>> | >>> | >>> ----| >>> >>> . >>> . >>> . -----------------------| >>> . | >>> . | >>> . |----------------------> there are n >>> records in between.... >>> . | >>> . | >>> . | >>> . ------------------------| >>> . >>> . >>> >>> -----| >>> | >>> | >>> . | >>> . | --------------------> constitutes one record. >>> . | >>> . | >>> . | >>> | >>> | >>> ----| >>> >>> Here is the main root tag of the XML, and ... >>> constitutes one record. What I would like to do is >>> to extract everything (xml tags and data) between nth tag and (n >>> +k)th tag. The extracted data is to be >>> written down to a separate file. >>> Thanks... >> You could create a generator expression out of it: >> >> txt = """ >> 1 >> 2 >> 3 >> 4 >> 5 >> >> """ >> l = len(txt.split('r2>'))-1 >> a = ('%sr2>'%i for j,i in enumerate(txt.split('r2>')) if 0 < j < l >> and i.replace('>','').replace('<','').strip()) >> >> Now you have a generator you can iterate through with a.next() or >> alternatively you could just create a list out of it by replacing the >> outer parens with square brackets.- Hide quoted text - >> >> - Show quoted text - > > Hmmm... will look into it.. Thanks > > the XML file is almost a TB in size... > Good grief. When will people stop abusing XML this way? > so SAX will have to be the parser.... i'm thinking of doing something > to split the file using SAX > ... Any suggestions on those lines..? If there are any other parsers > suitable, please suggest... You could try pulldom, but the documentation is disgraceful. ElementTree.iterparse *might* help. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From sturlamolden at yahoo.no Wed Apr 16 20:57:11 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Wed, 16 Apr 2008 17:57:11 -0700 (PDT) Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <101680ba-a116-414b-8fff-c5b5bd2f4b65@p39g2000prm.googlegroups.com> Message-ID: <5a826503-cf65-43a0-bfba-39b9d8faaaf7@a1g2000hsb.googlegroups.com> On Apr 16, 4:17 am, lxlau... at gmail.com wrote: > Reformulating my question: > > Which GUI tool, wxPython or PyQt, is more pythonic? (Please, ignore > the license issue because I am thinking about FOSS) None of them, all three of them (you forgot PyGTK), or it doesn't matter more. Nobody with their head screwed on right hand code a UI. There are graphical UI designers for that - QtDesigner, Glade, wxFormBuilder. Notice how the VB, Delphi and .NET crowds are doing the same. From svensven at gmail.com Tue Apr 22 06:46:24 2008 From: svensven at gmail.com (sven _) Date: Tue, 22 Apr 2008 12:46:24 +0200 Subject: Working around buffering issues when writing to pipes Message-ID: <3a4166890804220346y5696765cu235065d694c9f4af@mail.gmail.com> Keywords: subprocess stdout stderr unbuffered pty tty pexpect flush setvbuf I'm trying to find a solution to . In short: unless specifically told not to, normal C stdio will use full output buffering when connected to a pipe. It will use default (typically unbuffered) output when connected to a tty/pty. This is why subprocess.Popen() won't work with the following program when stdout and stderr are pipes: #include #include int main() { int i; for(i = 0; i < 5; i++) { printf("stdout ding %d\n", i); fprintf(stderr, "stderr ding %d\n", i); sleep(1); } return 0; } Then subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) is read using polling, but the pipes don't return any data until the program is done. As expected, specifying a bufsize of 0 or 1 in the Popen() call has no effect. See end of mail for example Python scripts. Unfortunately, changing the child program to flush stdout/err or specifying setvbuf(stdout,0,_IONBF,0); is an undesired workaround in this case. I went with pexpect and it works well, except that I must handle stdout and stderr separately. There seems to be no way to do this with pexpect, or am I mistaken? Are there alternative ways of solving this? Perhaps some way of I'm on Linux, and portability to other platforms is not a requirement. s #Test script using subprocess: import subprocess cmd = '/tmp/slow' # The C program shown above print 'Starting...' proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) while True: lineout = proc.stdout.readline() lineerr = proc.stderr.readline() exitcode = proc.poll() if (not lineout and not lineerr) and exitcode is not None: break if not lineout == '': print lineout.strip() if not lineerr == '': print 'ERR: ' + lineerr.strip() print 'Done.' #Test script using pexpect, merging stdout and stderr: import sys import pexpect cmd = '/home/sveniu/dev/logfetch/bin/slow' print 'Starting...' child = pexpect.spawn(cmd, timeout=100, maxread=1, logfile=sys.stdout) try: while True: child.expect('\n') except pexpect.EOF: pass print 'Done.' From sales024 at aaa-replica-watch.com Tue Apr 1 00:44:56 2008 From: sales024 at aaa-replica-watch.com (sales024 at aaa-replica-watch.com) Date: Mon, 31 Mar 2008 21:44:56 -0700 (PDT) Subject: Cheap Girard Perregaux Classic Elegance Watches Replica - Girard Perregaux Watches Wholesale Message-ID: Cheap Girard Perregaux Classic Elegance Watches Replica - Girard Perregaux Watches Wholesale AAA Replica Watches : http://www.watches-replicas.com Girard Perregaux Watches Brands : http://www.watches-replicas.com/girard-perregaux-watches.html Replica Girard Perregaux Classic Elegance Watches : http://www.watches-replicas.com/girard-perregaux-classic-elegance-watches.html China largest replica watches wholesaler, wholesale up to 80% of Girard Perregaux Classic Elegance Replica Watches and Girard Perregaux Classic Elegance Fake Watch. The most famous Swiss brand name watches you can find, replica Girard Perregaux Classic Elegance Watches and fake Girard Perregaux Classic Elegance Watches are also available. All our Girard Perregaux Classic Elegance Watches replicas are crafted in high quality, You will get great profite by ordering our good cheap watches. Girard Perregaux Classic Elegance Watches All Products : Girard Perragaux Classic Elegance 18kt White Gold Brown Leather Mens Watch 49800.0.53.1041 : http://www.watches-replicas.com/GP-49800-0-53-1041-2719.html Girard Perragaux Classic Elegance 18kt Rose Gold Brown Leather Mens Watch 49800.0.52.1041 : http://www.watches-replicas.com/GP-49800-0-52-1041-2720.html Girard Perragaux Classic Elegance 18kt Yellow Gold Brown Leather Mens Watch 49800.0.51.1041 : http://www.watches-replicas.com/GP-49800-0-51-1041-2721.html Girard Perragaux Classic Elegance Stainless Steel Brown Leather Mens Watch 49460.0.11.8158A : http://www.watches-replicas.com/GP-49460-0-11-8158A-2722.html Girard Perragaux Classic Elegance Stainless Steel Brown Leather Mens Watch 49460.0.11.6456A : http://www.watches-replicas.com/GP-49460-0-11-6456A-2723.html Girard Perragaux Classic Elegance Stainless Steel Mens Watch 49400.1.11.817 : http://www.watches-replicas.com/GP-49400-1-11-817-2724.html Girard Perragaux Classic Elegance Stainless Steel Mens Watch 49400.1.11.615 : http://www.watches-replicas.com/GP-49400-1-11-615-2725.html Girard Perragaux Classic Elegance 18kt White Gold Brown Leather Mens Watch 49400.0.53.917 : http://www.watches-replicas.com/GP-49400-0-53-917-2726.html Girard Perragaux Classic Elegance Stainless Steel Mens Watch 25980.1.11.6156 : http://www.watches-replicas.com/GP-25980-1-11-6156-2727.html Girard Perregaux Classic Elegance Mens Watch 49850-52-151-BACD : http://www.watches-replicas.com/girard-perregaux-watch-49850-52-151-BACD-2703.html Girard Perregaux Classic Elegance Mens Watch 49805-53-252-BA6A : http://www.watches-replicas.com/girard-perregaux-watch-49805-53-252-BA6A-2704.html Girard Perregaux Classic Elegance Stainless Steel Mens Watch 49570-1-11-644 : http://www.watches-replicas.com/girard-perregaux-49570-1-11-644-2705.html Girard Perregaux Classic Elegance Stainless Steel Brown Leather Mens Watch 49570-0-11-114 : http://www.watches-replicas.com/girard-perregaux-49570-0-11-114-2706.html Girard Perregaux Classic Elegance 18kt White Gold Black Leather Mens Watch 49530-0-53-4124 : http://www.watches-replicas.com/girard-perregaux-49530-0-53-4124-2707.html Girard Perregaux Classic Elegance 18kt Rose Gold Brown Leather Mens Watch 49530-0-52-7437 : http://www.watches-replicas.com/girard-perregaux-49530-0-52-7437-2708.html Girard Perregaux Classic Elegance 18kt Yellow Gold Brown Leather Mens Watch 49530-0-51-2122 : http://www.watches-replicas.com/girard-perregaux-49530-0-51-2122-2709.html Girard Perregaux Classic Elegance 18kt Yellow Gold Brown Leather Mens Watch 49530-0-51-1121 : http://www.watches-replicas.com/girard-perregaux-49530-0-51-1121-2710.html Girard Perregaux Classic Elegance Stainless Steel Brown Leather Mens Watch 49530-0-11-4154 : http://www.watches-replicas.com/girard-perregaux-49530-0-11-4154-2711.html Girard Perregaux Classic Elegance Stainless Steel Mens Watch 24990-1-11-1041 : http://www.watches-replicas.com/girard-perregaux-24990-1-11-1041-2712.html Girard Perregaux Classic Elegance Stainless Steel Mens Watch 24980-1-11-1041 : http://www.watches-replicas.com/girard-perregaux-24980-1-11-1041-2713.html Girard Perragaux Classic Elegance Stainless Steel Black Leather Mens Watch 49530.0.11.4154 : http://www.watches-replicas.com/girard-perregaux-watch-49530-0-11-4154-2714.html Girard Perragaux Classic Elegance 18kt White Gold Black Leather Mens Watch 49530.0.53.4124 : http://www.watches-replicas.com/GP-49530-0-53-4124-2715.html Girard Perragaux Classic Elegance Stainless Steel Mens Watch 49350.1.11.614 : http://www.watches-replicas.com/GP-49350-1-11-614-2716.html Girard Perragaux Classic Elegance 18kt Yellow Gold Brown Leather Mens Watch 90120.0.51.8158 : http://www.watches-replicas.com/GP-90120-0-51-8158-2717.html Girard Perragaux Classic Elegance 18kt White Gold Brown Leather Mens Watch 49800.0.53.6046 : http://www.watches-replicas.com/GP-49800-0-53-6046-2718.html Girard Perragaux Classic Elegance 18kt Rose Gold Brown Leather Mens Watch 25980.0.52.8158 : http://www.watches-replicas.com/GP-25980-0-52-8158-2728.html Girard Perragaux Classic Elegance Titanium Mens Watch 49800.T. 21.6046 : http://www.watches-replicas.com/GP-49800-T-21-6046-2729.html Girard Perragaux Classic Elegance 18kt Yellow Gold Brown Leather Mens Watch 49800.0.51.2742A : http://www.watches-replicas.com/GP-49800-0-51-2742A-2730.html Girard Perragaux Classic Elegance Stainless Steel Brown Leather Mens Watch 49350.0.11.614 : http://www.watches-replicas.com/GP-49350-0-11-614-2731.html The Same Girard Perregaux Replica Watches Series : Girard Perregaux Ferrari Watches : http://www.watches-replicas.com/girard-perregaux-ferrari-watches.html Girard Perregaux Classic Elegance Watches : http://www.watches-replicas.com/girard-perregaux-classic-elegance-watches.html Girard Perregaux Richeville Watches : http://www.watches-replicas.com/girard-perregaux-richeville-watches.html Girard Perregaux Collection Lady Watches : http://www.watches-replicas.com/girard-perregaux-collection-lady-watches.html Girard Perregaux Vintage 1945 Watches : http://www.watches-replicas.com/girard-perregaux-vintage-1945-watches.html Girard Perregaux Sport Classique Watches : http://www.watches-replicas.com/girard-perregaux-sport-classique-watches.html Girard Perregaux Cat's Eye Watches : http://www.watches-replicas.com/girard-perregaux-cats-eye-watches.html Girard Perregaux Seahawk II Watches : http://www.watches-replicas.com/girard-perregaux-seahawk-ii-watches.html Girard Perregaux Laureato EVO3 Watches : http://www.watches-replicas.com/girard-perregaux-laureato-evo3-watches.html Girard Perregaux Worldwide Time Control Watches : http://www.watches-replicas.com/girard-perregaux-worldwide-time-control-watches.html Girard Perregaux Foudrayante Watches : http://www.watches-replicas.com/girard-perregaux-foudrayante-watches.html From grg2 at comcast.net Tue Apr 29 11:35:19 2008 From: grg2 at comcast.net (A_H) Date: Tue, 29 Apr 2008 08:35:19 -0700 (PDT) Subject: PyExcerlerator details Message-ID: <937af823-9581-416e-85c1-57a5b0cc69de@e39g2000hsf.googlegroups.com> Hi, I'm using PyExcelerator, and it's great, but I can't figure out a few things: (1) I set the cell style to '0.00%' but the style does not work. (2) I want to place a border around the cells( x1, y1, x2, y2 ) but I can't find any example of doing that. Well I do see ONE example, but it erases the cells if I do it after, or when I write to the cells that erases the outline. Surely I don't have to tediously set each cells border? Help? From gagsl-py2 at yahoo.com.ar Fri Apr 4 17:33:29 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 04 Apr 2008 18:33:29 -0300 Subject: python bisect questions References: <6bb6927b-f553-40db-a142-2ce86b9e819f@q27g2000prf.googlegroups.com> Message-ID: En Fri, 04 Apr 2008 18:08:57 -0300, escribi?: >> b) Define a function to extract a "key" from your items such that items >> ? >> compare the same as their keys. For example, key(x) -> x.lower() may be >> ? >> used to compare text case-insensitively. >> Then, use a tuple (key, value) instead of the bare value. When >> extracting ? >> items from the queue, remember to unpack both parts. This is known as >> the ? >> decorate-sort-undecorate pattern; google for it. >> This is the approach used on your code snippet. >> > I liked decorate-sort-undecorate pattern idea. > But is there anyway I can provide information for tie breaking. > so for case, where keyfunc(x) returns same values, > I need to provide additional tie-breaking rules, is that possible to > do? Use as much elements in the tuple as you need. By example, you could have (year, month, amount, invoice_object) - you would get invocies sorted by year, then by month, then by amount. -- Gabriel Genellina From mathieu.malaterre at gmail.com Tue Apr 15 11:23:23 2008 From: mathieu.malaterre at gmail.com (mathieu) Date: Tue, 15 Apr 2008 08:23:23 -0700 (PDT) Subject: ImportError: No module named dl Message-ID: <270c17d0-53b0-451d-ac07-5578524139f4@m1g2000pre.googlegroups.com> Hi there, I cannot figure out where did the 'dl' module went when running python on AMD64 (debian stable). According to the documentation, I have : python >>> import sys >>> help(sys.setdlopenflags) ... setdlopenflags(...) sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL) ... But when -as suggested by the doc- to load dl, I am getting: >>> import dl Traceback (most recent call last): File "", line 1, in ? ImportError: No module named dl dl module is extremely important since I need to load shared lib with RTLD_GLOBAL (and not RTLD_LOCAL) Ref: http://gcc.gnu.org/ml/gcc/2002-05/msg00869.html & http://lists.apple.com/archives/xcode-users/2006/Feb/msg00234.html Thanks -Mathieu From wizzardx at gmail.com Sun Apr 27 11:37:03 2008 From: wizzardx at gmail.com (David) Date: Sun, 27 Apr 2008 17:37:03 +0200 Subject: Question regarding Queue object In-Reply-To: References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> <18c1e6480804270653r2e075061wf442b7b7d9f50ff6@mail.gmail.com> Message-ID: <18c1e6480804270837s4ed11345jb1e5615accbaea6e@mail.gmail.com> (re-cc-ing the list) On Sun, Apr 27, 2008 at 4:40 PM, Terry Yin wrote: > Defaultdict is not an option because there will be a lot of message IDs (and > increasing). I will implement LookAheadQueue class by overriding the Queue > class. > > Thanks for your kind advice. > > BTW, I have been in old-fashion telecommunication R&D for years, where > messages and state machines are heavily used in software development. And > this makes me automatically resort to messages between task-specific > processes/threads when designing any software, even in python. I'm wondering > if this is the right choice, or it's already not a modern way of design. > There are a lot of ways you could go about it, those 2 were the first that came to mind. Another idea would be to have multiple queues, one per thread or per message type "group". The producer thread pushes into the appropriate queues (through an intelligent PutMsg function), and the consumer threads pull from the queues they're interested in and ignore the others. If your apps are heavily threaded you might take a look at Stackless Python: http://www.stackless.com/ David. From timr at probo.com Fri Apr 18 02:55:28 2008 From: timr at probo.com (Tim Roberts) Date: Fri, 18 Apr 2008 06:55:28 GMT Subject: why function got dictionary References: <48075950.7050000@gmail.com> <66p409F2lg89hU1@mid.uni-berlin.de> <4807637C.1050900@gmail.com> Message-ID: <27hg04d4g7o0hsirp2q15uamh201jec56i@4ax.com> AlFire wrote: >Diez B. Roggisch wrote: >>> >>> Q: why function got dictionary? What it is used for? >> >> because it is an object, and you can do e.g. >> > >you mean an object in the following sense? > > >>> isinstance(g,object) >True > >where could I read more about that? This is a very useful feature. As just one example, the CherryPy web server framework lets you define a class to handle one directory in a web site, where each page is mapped to member functions. However, you also need to include support functions that should not be exposed as web pages. To do that, you just add an "exposed" attribute to the function: class MyWebPage: ... def index( self, ... ): pass index.exposed = 1 def notExposed( self, ... ): pass def request( self, ... ): pass request.exposed = 1 -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From deets at nospam.web.de Sat Apr 12 09:44:55 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Sat, 12 Apr 2008 15:44:55 +0200 Subject: Wrapping C++ class with SWIG, Mac OS X In-Reply-To: References: <66aglpF2ihunjU1@mid.uni-berlin.de> Message-ID: <66bsn3F2jbcl7U1@mid.uni-berlin.de> Paul Anton Letnes schrieb: > Okay, installed SIP. Looks promising, following the tutorial on > http://www.riverbankcomputing.com/static/Docs/sip4/sipref.html#using-sip > It should be noted that I am working on a Mac - I know there are some > differences, but it's still UNIX and should work somehow. > > Anyway, I copy-paste and create the Word.h header, write an > implementation in Word.cpp, the SIP wrapper Word.sip and the > configure.py script. I now run configure and make, creating the > following error: > > ~/Desktop/SIP_example $ python configure.py > ~/Desktop/SIP_example $ make > c++ -c -pipe -fPIC -Os -Wall -W -I. -I/sw/include/python2.5 -o > sipwordcmodule.o sipwordcmodule.cpp > c++ -c -pipe -fPIC -Os -Wall -W -I. -I/sw/include/python2.5 -o > sipwordWord.o sipwordWord.cpp > c++ -headerpad_max_install_names -bundle -undefined dynamic_lookup -o > word.so sipwordcmodule.o sipwordWord.o -lword > ld: library not found for -lword > collect2: ld returned 1 exit status > make: *** [word.so] Error 1 > ~/Desktop/SIP_example $ > > SWIG at least works nicely with C... Too bad I know so little about > compilers and libraries, I don't quite understand what the linker (ld) > is complaining about. The simplest tutorial should anyway work? Not knowing C/C++ & linking is certainly something that will get you when trying to wrap libs written in these languages. I'm on OSX myself, and can say that as a unixish system, it is rather friendly to self-compliation needs. However, without having the complete sources & libs, I can't really comment much - the only thing that is clear from above is that the linker does not find the file libword.dylib which you of course need to have somewhere. The good news is that once you've teached the linker where to find it (using LDFLAGS or other means) you are (modulo debugging) done - SIP has apparently grokked your .sip-file. Of course you also must make the library available at runtime. So it must be installed on a location (or that location given with DYLD_LIBRARY_PATH) where the dynamic loader will find it. Diez From xahlee at gmail.com Tue Apr 29 22:48:39 2008 From: xahlee at gmail.com (xahlee at gmail.com) Date: Tue, 29 Apr 2008 19:48:39 -0700 (PDT) Subject: Python's doc problems: sort Message-ID: <929d5ce9-9063-4e6c-98aa-89526f89fba3@y18g2000pre.googlegroups.com> Of my Python and Perl tutorial at http://xahlee.org/perl-python/index.html the most popular page is ?Sorting in Python and Perl? http://xahlee.org/perl-python/sort_list.html For example, in last week, that page is fetched 550 times. The second most popular page, trails quite a distance. Here's the top 3 pages and their number of times fetched: 550 http://xahlee.org/perl-python/sort_list.html 341 http://xahlee.org/perl-python/system_calls.html 222 http://xahlee.org/perl-python/index.html Note that the first 2 pages are far more popular than the entry page the table of contents. Apparently, and also verified by my web log, that people have difficulty in using sort, and they find my pages thru web search engines. ------------------ In 2005, i wrote over ten essays detailing Python's documentation problems. One of them is titled: ?Python Doc Problem Example: sort()? http://xahlee.org/perl-python/python_doc_sort.html It's been 3 years, and python has gone from 2.4.x to 2.5.2. Looking at the current version of the doc, apparently, Python doc of that page hasn't improved a bit. I want to emphasize a point here, as i have done quite emphatically in the past. The Python documentation, is the world's worst technical writing. As far as technical writing goes, it is even worse than Perl's in my opinion. Although i disliked Perl very much, in part that it is lead by a cult figure that manipulates and deceives the populace, but there is at least one aspect of Perl community that is very positive, namely, embrace all walks of life. This aspect is taken by a Perl derivative the Pretty Home Page, and its success surpassed Perl, yet without Perl's cult string. Now, in my experience, the Python community, is filled with politics more so than Perl, and far more fucking assholes with high hats. Python priests: go fuck yourselfs. (disclaimer: all statements about actual persons in this post are statements of opinion.) ---------------------- Now, i find it pertinent to post my essay about the sort documentation problem again. The HTML version with colors and formatting is here: http://xahlee.org/perl-python/python_doc_sort.html Below is a abridged textual version. ------------------------------------- Python Doc Problem Example: sort() Python doc ?3.6.4 Mutable Sequence Types? at http://python.org/doc/2.4/lib/typesseq-mutable.html in which contains the documentation of the ?sort? method of a list. Quote: ?...? As a piece of documentation, this is a lousy one. The question Python doc writers need to ask when evaluating this piece of doc are these: * Can a experienced programer who is expert at several languages but new to Python, and also have read the official Python tutorial, can he, read this doc, and know exactly how to use sort with all the options? * Can this piece of documentation be rewritten fairly easily, so that the answer to the previous question is a resounding yes? To me, the answers to the above questions are No and Yes. Here are some issues with the doc: ? In the paragraph about the ?key? parameter, the illustration given is: ?cmp=str.lower?. It should be be ?key=str.lower? ? This doc lacks examples. One or two examples will help a lot, especially to less experienced programers. (which comprises the majority of readers) In particular, it should give a full example of using the comparison function and one with the ?key? parameter. Examples are particularly needed here because these parameters are functions, often with the ?lambda? construct. These are unusual and advanced constructs among imperative languages. ? This doc fails to mention what happens when the predicate and the shortcut version conflicts. e.g. ?myList.sort(cmp=lambda x,y: cmp(x[0], y[0]), key=lambda x: str(x[1]) )? ? The notation the Python doc has adopted for indicating the syntax of optional parameters, does not give a clear view just exactly what combination of optional parameters can be omitted. The notation: ?s.sort([cmp[, key[, reverse]]])? gives the impression that only trailing arguments can be omitted, which is not true. ? The doc gives no indication of how to omit a optional arg. Should it be ?nul?, ?Null?, 0, or left empty? Since it doesn't give any examples, doc reader who isn't Python experts is left to guess at how true/false values are presented in Python. ? On the whole, the way this doc is written does not give a clear picture of the roles of the supplied options, nor how to use them. Suggested Quick Remedy: add a example of using the cmp function. And a example using the ?key? function. Add a example of Using one of them and with reverse. (the examples need not to come with much explanations. One sentence annotation is better than none.) Other than that, the way the doc is laid out with a terse table and run-on footnotes (employed in several places in Python doc) is not inductive. For a better improvement, there needs to be a overhaul of the organization and the attitude of the entire doc. The organization needs to be programing based, as opposed to implementation or computer science based. (in this regard, one can learn from the Perl folks). As to attitude, the writing needs to be Python-as-is, as opposed to computer science framework, as indicated in the early parts of this critique series. Addendum, 200510: Since Python 2.4 released in 2005-03, a new built-in function sorted() was added. There's no mention of it at the doc page of the sort() method. Addendum, 2005-10 Here's further example of Python's extreme low quality of documentation. In particular, what follows focuses on the bad writing skill aspect, and comments on some language design and quality issues of Python. From the Official Python documentation of the sort() method, at: http://python.org/doc/2.4.2/lib/typesseq-mutable.html, Quote: ?The sort() method takes optional arguments for controlling the comparisons.? It should be ?optional parameter? not ?optional argument?. Their difference is that ?parameter? indicates the variable, while ?argument? indicates the actual value. ?... for controlling the comparisons.? This is a bad writing caused by lack of understanding. No, it doesn't ?control the comparison?. The proper way to say it is that ?the comparison function specifies an order?. ?The sort() and reverse() methods modify the list in place for economy of space when sorting or reversing a large list. To remind you that they operate by side effect, they don't return the sorted or reversed list. ? This is a example of tech-geeking drivel. The sort() and reverse() methods are just the way they are. Their design and behavior are really not for some economy or remind programers of something. The Python doc is bulked with these irrelevant drivels. These littered inanities dragged down the whole quality and effectiveness of the doc. ?Changed in version 2.4: Support for key and reverse was added.? ?In general, the key and reverse conversion processes are much faster than specifying an equivalent cmp function. This is because cmp is called multiple times for each list element while key and reverse touch each element only once.? When sorting something, one needs to specify a order. The easiest way is to simply list all the elements as a sequence. That way, their order is clearly laid out. However, this is in general not feasible and impractical. Therefore, we devised a mathematically condensed way to specify the order, by defining a function f(x,y) that can take any two elements and tell us which one comes first. This, is the gist of sorting a list in any programing language. The ordering function, being a mathematically condensed way of specifying the order, has some constraints. For example, the function should not tell us x < y and y < x. (For a complete list of these constraints, see http://xahlee.org/perl-python/sort_list.html ) With this ordering function, it is all sort needed to sort a list. Anything more is interface complexity. The optional parameters ?key? and ?reverse? in Python's sort method is a interface complexity. What happened here is that a compiler optimization problem is evaded by moving it into the language syntax for programers to worry about. If the programer does not use the ?key? syntax when sorting a large matrix (provided that he knew in advance of the list to be sorted or the ordering function), then he is penalized by a severe inefficiency by a order of magnitude of execution time. This situation, of moving compiler problems to the syntax surface is common in imperative languages. ?Changed in version 2.3: Support for None as an equivalent to omitting cmp was added.? This is a epitome of catering towards morons. ?myList.sort()? is perfect but Pythoners had to add ?myList.sort(None)? interface complexity just because idiots need it. The motivation here is simple: a explicit ?None? gives coding monkeys a direct sensory input of the fact that ?there is no comparison function?. This is like the double negative in black English ?I ain't no gonna do it!?. Logically, ?None? is not even correct and leads to bad thinking. What really should be stated in the doc, is that ?the default ordering function to sort() is the ?cmp? function.?. ?Starting with Python 2.3, the sort() method is guaranteed to be stable. A sort is stable if it guarantees not to change the relative order of elements that compare equal -- this is helpful for sorting in multiple passes (for example, sort by department, then by salary grade).? One is quite surprised to read this. For about a decade of a language's existence, its sort functionality is not smart enough to preserve order?? A sort that preserves original order isn't something difficult to implement. What we have here is sloppiness and poor quality common in OpenSource projects. Also note the extreme low quality of the writing. It employs the jargon ?stable sort? then proceed to explain what it is, then in trying to illustrate the situation, it throws ?multiple passes? and the mysterious ?by department, by salary?. Here's a suggested rewrite: ?Since Python 2.3, the result of sort() no longer rearrange elements where the comparison function returns 0.? Xah xah at xahlee.org ? http://xahlee.org/ ? From willem at stack.nl Mon Apr 14 04:29:03 2008 From: willem at stack.nl (Willem) Date: Mon, 14 Apr 2008 08:29:03 +0000 (UTC) Subject: Game design : Making computer play References: Message-ID: v4vijayakumar wrote: ) On Apr 14, 12:35 pm, Richard Heathfield wrote: )> v4vijayakumar said: )> > In computer based, two player, board games, how to make computer play? )> )> Write some code that works out what the computer player should do. If you )> want a better answer, ask a better question. ) ) I am just implementing a game played in my village (Tamilnadu / ) India), called "aadupuli" (goats and tigers). There are only 23 ) positions and 18 characters (15 goats and 3 tigers). Some of you might ) be aware of this. Odd, I thought there were 25 positions, 20 goats and 4 tigers. *googles* Oh wait, that is Bagh Chal. Roughly the same rules, different board layout and number of tigers. ) I can post initial version of the game (implemented using html/ ) javascript) in couple of hours here. ) ) Welcome any help in making computer to play one of these player. If the board is that small then an exhaustive search might work, but then the computer would be unbeatable. Minmax would be best I guess. SaSW, Willem -- Disclaimer: I am in no way responsible for any of the statements made in the above text. For all I know I might be drugged or something.. No I'm not paranoid. You all think I'm paranoid, don't you ! #EOT From mgi820 at motorola.com Mon Apr 7 14:19:51 2008 From: mgi820 at motorola.com (Gary Duzan) Date: Mon, 7 Apr 2008 18:19:51 +0000 (UTC) Subject: Learning curve for new database program with Python? References: Message-ID: In article , M.-A. Lemburg wrote: >On 2008-04-07 15:30, Greg Lindstrom wrote: >> >> SQL is one of the areas I wish I had mastered (much) earlier in my career > >Fully agree :-) > >Interesting comments in a time where everyone seems to be obsessed >with ORMs. It seems to me that ORM can work if your database isn't too complex and it is the only way your database is going to be accessed. In our case, we have a messy legacy database (lots of tables, triggers, stored procedures, etc., that nobody really understands) with multiple processes hitting it, and so our efforts to integrate Hibernate haven't been terribly smooth. In this environment the hack seems to be to have Hibernate write to its own tables, then have stored procedures sync them with the old tables. Not pretty. Gary Duzan From nospam1.reifenberg at gmx.de Fri Apr 4 11:38:07 2008 From: nospam1.reifenberg at gmx.de (Nebur) Date: Fri, 4 Apr 2008 08:38:07 -0700 (PDT) Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? Message-ID: Hi folks developing with Pydev/Eclipse, this is the second time in about half a year that the following surprise bites me: I've switched between some files in Pydev/Eclipse using the FileNavigator, and when I want to go back to my last-edited *.py file, it is missing. No more in the FileNavigator, no more in the OpenFiles-List of the Editor. Removed anywhere. Erased from the file system. Restorable from the version control only. Only a young orphan *.pyc file is sitting around, showing me I haven't dreamed of editing the file two minutes before. I'm sure I did no delete operations with eclipse, and I'm sure I did not use another application than eclipse in the meantime. No, I can't reproduce it, and I don't know whom to blame (Pydev? Eclipse ? The File System ? A Virus that only 2 times in half a year deletes a single file I'm busy working with, and seems to do nothing else? Myself beeing schizophrenic ??) Someone else already had this effect ? Nebur PS: Debian Etch 64Bit/JFS,Eclipse3.3,Pydev1.3.14. From steve at holdenweb.com Wed Apr 9 08:19:39 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 08:19:39 -0400 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. In-Reply-To: <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> Message-ID: subhabrata.iisc at hotmail.com wrote: [...] > If you know anyone in Bangalore, India expert in python kindly > send him across I can show him the problem in my machine and Indian > Institute of Science(IISc-locally known as TATA INSTITUTE) is a > distinguished place.Any one should know it. > I am in no mood of doing a joke. [...] >> I have a car. I have turned the ignition key but it fails to start. >> Please tell me what is wrong with it. >> Please understand: this is the Internet. The chances that a random responder will know anyone in Bangalore are vanishingly small. I wasn't joking: I was simply (perhaps sarcastically) pointing out that you do not provide enough information for anyone to help with your problem, since you don't explain what the problem is. Fortunately nobody is under any obligation to help here, it's simply done out of kindness. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gagsl-py2 at yahoo.com.ar Wed Apr 9 01:26:56 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 02:26:56 -0300 Subject: Setting default version among multiple python installations References: <47FB3F86.5040702@adventnet.com> Message-ID: En Tue, 08 Apr 2008 06:48:54 -0300, Karthik escribi?: > I am an absolute linux and python newbie. The linux machine(red hat > version 7.2) that i managed to get my hands on had python 1.5(vintage > stuff, i guess) in it. I have installed python 2.5 using the source tar. > However, when i try to access python, i am taken to the older version > only. Have you actually compiled and installed it? See http://docs.python.org/dev/using/index.html -- Gabriel Genellina From stefan_ml at behnel.de Fri Apr 25 06:37:04 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 25 Apr 2008 12:37:04 +0200 Subject: Can you recommend a book? In-Reply-To: References: Message-ID: <4811B450.3030000@behnel.de> noagbodjivictor at gmail.com wrote: > Hello all, I learned Python with the book "Programming Python" by John > Zelle. But today this book is a little bit old. My Python is some kind > old. I need a book that will help me brush my style and keep me up to > date. I would like one with practical examples. > > Can you recommend one? http://wiki.python.org/moin/PythonBooks Stefan From http Wed Apr 2 13:23:28 2008 From: http (Paul Rubin) Date: 02 Apr 2008 10:23:28 -0700 Subject: april fools email backfires References: Message-ID: <7xbq4sf9wv.fsf@ruckus.brouhaha.com> Aaron Watters writes: > Grapevine says that an architect/bigot at a java/spring shop sent > out an April Fools email saying they had decided to port everything > to Django ASAP. > > Of course the email was taken seriously and he got a lot of positive > feedback from line developers and savvy users/managers that they > thought it would be a great idea; it's about time; gotta do > something about this mess... Django, pah. They should switch to something REALLY advanced: http://www.coboloncogs.org/INDEX.HTM From ivory91044 at gmail.com Tue Apr 29 04:56:23 2008 From: ivory91044 at gmail.com (ivory91044 at gmail.com) Date: Tue, 29 Apr 2008 01:56:23 -0700 (PDT) Subject: patch barracks Message-ID: <09e760d0-f5d8-4804-838f-38eea1c78eff@l42g2000hsc.googlegroups.com> patch barracks http://crack.cracksofts.com From malaclypse2 at gmail.com Wed Apr 16 15:18:15 2008 From: malaclypse2 at gmail.com (Jerry Hill) Date: Wed, 16 Apr 2008 15:18:15 -0400 Subject: str class inheritance prob? In-Reply-To: <587C2C9324493D4B96BD6BBCDEAC321AA956C8@exchange3.valvesoftware.com> References: <587C2C9324493D4B96BD6BBCDEAC321AA956C8@exchange3.valvesoftware.com> Message-ID: <16651e80804161218m729af1eer6306a7ec69a8cd70@mail.gmail.com> On Wed, Apr 16, 2008 at 2:35 PM, Hamish McKenzie wrote: > so I'm trying to create a class that inherits from str, but I want to run > some code on the value on object init. this is what I have: You actually want to run your code when creating the new object, not when initializing it. In python, those are two separate steps. Creation of an instance is handled by the class's __new__ method, and initialization is handled by __init__. This makes a big difference when you inherit from an immutable type like str. Try something like this instead: class Path(str): def __new__( cls, path ): clean = str(path).replace('\\','/') while clean.find('//') != -1: clean = clean.replace('//','/') print 'cleaned on __new__:\t',clean return str.__new__(cls, clean) -- Jerry From fennelllindy8241 at gmail.com Mon Apr 28 03:15:32 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:15:32 -0700 (PDT) Subject: strawberry patch Message-ID: strawberry patch http://crack.cracksofts.com From nick at stinemates.org Fri Apr 18 15:17:35 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 12:17:35 -0700 Subject: how turbo geras code works In-Reply-To: References: Message-ID: <20080418191735.GL19281@deviL> On Wed, Apr 16, 2008 at 01:35:29AM -0700, reetesh nigam wrote: > hi. > actually i have developed one small project but now i want to > develope a project with the help of html.. > please help me out > -- > http://mail.python.org/mailman/listinfo/python-list OK. Done -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From deets at nospam.web.de Tue Apr 15 08:32:37 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 15 Apr 2008 14:32:37 +0200 Subject: webcam (usb) access under Ubuntu References: Message-ID: <66jlk1F2ju6c8U1@mid.uni-berlin.de> Berco Beute wrote: > I've been trying to access my webcam using Python, but I failed > miserably. The camera works fine under Ubuntu (using camora and > skype), but I am unable to get WebCamSpy or libfg to access my webcam. > > First I tried webcamspy (http://webcamspy.sourceforge.net/). That > requires pySerial and pyParallel, and optionally pyI2C. Runing > WebCamSpy results in: > > Exception exceptions.AttributeError: "Parallel instance has no > attribute '_fd'" in > ignored > > This seems to come from importing I2C. The application window opens, > but there's an error message: > > NO VIDEO SOURCE FOUND > > Next I tried libfg (http://antonym.org/libfg). I built it, made the > Python bindings and installed it. Unfortunately the following: > >>>>import fg >>>>grabber = fg.Grabber() > > results in: > > fg_open(): open video device failed: No such file or directory > > Since the camera works fine in Ubuntu itself my guess is that the > problem is with the python libraries (or even likelier, my usage of > them). Is there anybody here that was successful in accessing their > webcam on linux using Python? Else I have to reside to Windows and > VideoCapture (which relies on the win32 api and thus is Windows-only), > something I'd rather not do. It has been *ages* since I did this - so take it with a grain of salt. However, back then I was able to access a video camera using gqcam. Looking into the source of that revealed that all it did were some simple ioctl-calls and reading from a /dev/video*-device. That did the trick for me... Additionally, you might consider using gstreamer + the python bindings for that. I was also successful using them - if I remember this conversation tonight or so, I'll send you the sources. Diez Diez From martin at v.loewis.de Fri Apr 25 03:24:09 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Fri, 25 Apr 2008 09:24:09 +0200 Subject: py3k concerns. An example In-Reply-To: <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> Message-ID: <48118719$0$25846$9b622d9e@news.freenet.de> > In my view using a conversion tool on an ongoing basis is > not an option. It just adds a dependancy. What happens when > the conversion tool is upgraded in a non-backwards-compatible > way? Or do we have assurance that it won't be ;)? The latter: if you include a copy of the converter with your package, it won't change unless you change it. If you rely on the copy of the converter that ships with Python 3.0, you have the assurance that it won't change in a non-backwards-compatible manner in all of 3.0.y. Of course, the copies include in later 3.x releases may change, but you'll have to test for the later 3.x releases, anyway, as they may show incompatible changes themselves. > Will changes to the converter > mean that the users of my > converted libraries have to start > using my tools in a different way? No. If the 2to3 converter is changed to support additional source patterns to convert, it either won't affect your code (if you don't use the pattern), or it may convert some of your code that it didn't previously - then that conversion may or may not be correct. So as a consequence, your library may stop working; then you'll have to adjust either your library, or go back to an older version of the converter. In no case, however, will the users of the library need to adjust their code to changing 2to3 output. 2to3 won't change the library API. > I have no interest in adding additional dependancies, > with an additional degree of freedom to break. Then remove the freedom by fixing a specific 2to3 version (e.g. by including it). > So if I want to support both I have to do everything > twice in the expected case and in the best case test > everything twice, at the same time, if I want to > support both versions and keep features in sync. This I don't understand. Why do you think you have to do everything twice? > I still think it's a shame [...] > pps: I have to note that it would be nice if the > ad-hominem (sp?) invective would drop out of > these threads -- it doesn't add a lot, I think. shame 1 a. a painful emotion caused by consciousness of guilt, shortcoming, or impropriety 2 a condition of humiliating disgrace or disrepute So who do you think should feel guilt? Or should be disgraced or disreputed? Regards, Martin From deets at nospam.web.de Tue Apr 1 17:05:22 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 01 Apr 2008 23:05:22 +0200 Subject: Not Sure This Can Be Done... In-Reply-To: <46aeae28-4470-4136-a5f6-040f6468eb32@b5g2000pri.googlegroups.com> References: <46aeae28-4470-4136-a5f6-040f6468eb32@b5g2000pri.googlegroups.com> Message-ID: <65fmclF2f352gU1@mid.uni-berlin.de> gamename schrieb: > Hi, > > I generally have several copies of the same development environment > checked out from cvs at any one time. Each development tree has a > 'tools' dir containing python modules. Scattered in different places > in the tree are various python scripts. > > What I want to do is force my scripts to always look in the closest > 'tools' dir for any custom modules to import. For example: > > tree1/tools > tree1/my_scripts/foo.py > > tree2/tools > tree2/my_scripts/foo.py > > How can I make 'foo.py' always look in '../../tools' for custom > modules? My preference would be to avoid changing the 'foo.py' script > and have some way to resolve it via the environment (like PYTHONPATH, > or .pth files, etc.). > > Anyone have any ideas? Use virtualenv to create a local python, and activate that when developing for that branch. Alternatively, you can of course manipulate the PYTHONPATH yourself - but why should you if virtualenv takes care of that for you? Diez From marexposed at googlemail.com Tue Apr 15 23:25:48 2008 From: marexposed at googlemail.com (marexposed at googlemail.com) Date: Wed, 16 Apr 2008 04:25:48 +0100 Subject: Unicode chr(150) en dash Message-ID: <20080416042548.f5a47b2e.marexposed@googlemail.com> Hello guys & girls I'm pasting an "en dash" (http://www.fileformat.info/info/unicode/char/2013/index.htm) character into a tkinter widget, expecting it to be properly stored into a MySQL database. I'm getting this error: ***************************************************************************** Exception in Tkinter callback Traceback (most recent call last): File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__ return self.func(*args) File "chupadato.py", line 25, in guardar cursor.execute(a) File "C:\Python24\Lib\site-packages\MySQLdb\cursors.py", line 149, in execute query = query.encode(charset) UnicodeEncodeError: 'latin-1' codec can't encode character u'\u2013' in position 52: ordinal not in range(256) ***************************************************************************** Variable 'a' in 'cursor.execute(a)' contains a proper SQL statement, which includes the 'en dash' character just pasted into the Text widget. When I type 'print chr(150)' into a python command line window I get a LATIN SMALL LETTER U WITH CIRCUMFLEX (http://www.fileformat.info/info/unicode/char/00fb/index.htm), but when I do so into a IDLE window I get a hypen (chr(45). Funny thing I quite don't understand is, when I do paste that 'en dash' character into a python command window (I'm using MSWindows), the character is conveniently converted to chr(45) which is a hyphen (I wouldn't mind if I could do that by coding, I mean 'adapting' by visual similarity). I tried searching "en dash" or even "dash" into the encodings folder of python Lib, but I couldn't find anything. I'm using Windows Vista english, Python 2.4, latest MySQLdb. Default encoding changed (while testing) into "iso-8859-1". Thanks for any help. From simon at brunningonline.net Mon Apr 7 09:09:14 2008 From: simon at brunningonline.net (Simon Brunning) Date: Mon, 7 Apr 2008 14:09:14 +0100 Subject: Learning curve for new database program with Python? In-Reply-To: <47f82573$0$36352$742ec2ed@news.sonic.net> References: <47f82573$0$36352$742ec2ed@news.sonic.net> Message-ID: <8c7f10c60804070609r6b2a8a6eo650f77ff0af0d35e@mail.gmail.com> On Sun, Apr 6, 2008 at 2:31 AM, John Nagle wrote: > > Basic SQL isn't that hard. Learn CREATE, SELECT, INSERT, > UPDATE, and DELETE syntax. That's enough for most simple > applications. Agreed. What's more, I've found SQL to be the single most transferable skill in IT.. No matter what language and platform you find yourself working on, you'll find an SQL driven relational database somewhere in the mix. Learning SQL isn't a waste of time, I guarantee it. -- Cheers, Simon B. simon at brunningonline.net http://www.brunningonline.net/simon/blog/ From cokofreedom at gmail.com Wed Apr 2 09:12:05 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Wed, 2 Apr 2008 06:12:05 -0700 (PDT) Subject: Nested try...except References: Message-ID: On Apr 2, 3:06 pm, Magnus.Morab... at gmail.com wrote: > Hi, > > I found the following code on the net - > > http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/%3C20050924104732.5116.qm... at minotaur.apache.org%3E > > def count(self): > - db = sqlite.connect(self.filename, > isolation_level=ISOLATION_LEVEL) > - try: > - try: > - cur = db.cursor() > - cur.execute("select count(*) from sessions") > - return cur.fetchone()[0] > - finally: > - cur.close() > - finally: > - db.close() > > I don't understand though why the second try is not after the line cur > = db.cursor(). Can anyone explain for me why? > > /Barry. Better question is why is there a try with no except... Better yet, WHY is there two TRY statements when there could quite happily be only one... Towards what you are asking, I GUESS...because the author hoped to handle the cases where cur failed to get assigned...but then his .close method of it would likely not work anyway...I mean...does this even work...YUCK From ewertman at gmail.com Thu Apr 24 11:42:16 2008 From: ewertman at gmail.com (Eric Wertman) Date: Thu, 24 Apr 2008 11:42:16 -0400 Subject: Ideas for parsing this text? In-Reply-To: References: Message-ID: <92da89760804240842n17d95461g21d740a6db394346@mail.gmail.com> Thanks to everyone for the help and feedback. It's amazing to me that I've been dealing with odd log files and other outputs for quite a while, and never really stumbled onto a parser as a solution. I got this far, with Paul's help, which manages my current set of files: from pyparsing import nestedExpr,Word,alphanums,QuotedString from pprint import pprint import re import glob files = glob.glob('wsout/*') for file in files : text = open(file).read() text = re.sub('"\[',' [',text) # These 2 lines just drop double quotes text = re.sub('\]"','] ',text) # that aren't related to a string text = re.sub('\[\]','None',text) # this drops the empty [] text = '[ ' + text + ' ]' # Needs an outer layer content = Word(alphanums+"-_./()*=#\\${}| :,;\t\n\r@?&%%") | QuotedString('"',multiline=True) structure = nestedExpr("[", "]", content).parseString(text) pprint(structure[0].asList()) I'm sure there are cooler ways to do some of that. I spent most of my time expanding the characters that constitute content. I'm concerned that over time I'll have things break as other characters show up. Specifically a few of the nodes are of German locale.. so I could get some odd international characters. It looks like pyparser has a constant for printable characters. I'm not sure if I can just use that, without worrying about it? At any rate, thumbs up on the parser! Definitely going to add to my toolbox. On Thu, Apr 24, 2008 at 8:19 AM, Mark Wooding wrote: > > Eric Wertman wrote: > > > I have a set of files with this kind of content (it's dumped from > > WebSphere): > > > > [propertySet "[[resourceProperties "[[[description "This is a required > > property. This is an actual database name, and its not the locally > > catalogued database name. The Universal JDBC Driver does not rely on > > > information catalogued in the DB2 database directory."] > > [name databaseName] > > [required true] > > [type java.lang.String] > > [value DB2Foo]] ...> > > Looks to me like S-expressions with square brackets instead of the > normal round ones. I'll bet that the correct lexical analysis is > approximately > > [ open-list > propertySet symbol > " open-string > [ open-list > [ open-list > resourceProperties symbol > " open-string (not close-string!) > ... > > so it also looks as if strings aren't properly escaped. > > This is definitely not a pretty syntax. I'd suggest an initial > tokenization pass for the lexical syntax > > [ open-list > ] close-list > "[ open-qlist > ]" close-qlist > "..." string > whitespace ignore > anything-else symbol > > Correct nesting should give you two kinds of lists -- which I've shown > as `list' and `qlist' (for quoted-list), though given the nastiness of > the dump you showed, there's no guarantee of correctness. > > Turn the input string (or file) into a list (generator?) of lexical > objects above; then scan that recursively. The lists (or qlists) seem > to have two basic forms: > > * properties, that is a list of the form [SYMBOL VALUE ...] which can > be thought of as a declaration that some property, named by the > SYMBOL, has a particular VALUE (or maybe VALUEs); and > > * property lists, which are just lists of properties. > > Property lists can be usefully turned into Python dictionaries, indexed > by their SYMBOLs, assuming that they don't try to declare the same > property twice. > > There are, alas, other kinds of lists too -- one of the property lists > contains a property `[value []]' which simply contains an empty list. > > The right first-cut rule for disambiguation is probably that a property > list is a non-empty list, all of whose items look like properties, and a > property is an entry in a property list, and (initially at least) > restrict properties to the simple form [SYMBOL VALUE] rather than > allowing multiple values. > > Does any of this help? > > (In fact, this syntax looks so much like a demented kind of S-expression > that I'd probably try to parse it, initially at least, by using a Common > Lisp system's reader and a custom readtable, but that may not be useful > to you.) > > -- [mdw] > > > > -- > http://mail.python.org/mailman/listinfo/python-list > From cokofreedom at gmail.com Fri Apr 11 07:19:29 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Fri, 11 Apr 2008 04:19:29 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> Message-ID: <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> couldn't you just do. #untested new_round(n): answer = round(n) # is answer now odd if answer % 2: return answer - 1 else: return answer From Lie.1296 at gmail.com Mon Apr 7 16:59:36 2008 From: Lie.1296 at gmail.com (Lie) Date: Mon, 7 Apr 2008 13:59:36 -0700 (PDT) Subject: A funnily inconsistent behavior of int and float References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com> <1d11875a-470a-489f-910a-b420a145eb61@a1g2000hsb.googlegroups.com> Message-ID: <79bf5ab5-ff30-4b30-b268-1c77a5dce97f@l28g2000prd.googlegroups.com> On Apr 8, 2:15?am, "Terry Reedy" wrote: (snip) > 2. Replace text with: > Convert a number or string to an integer. ?If no arguments are given, > return 0. ?If a number is given, return number.__int__(). ?Conversion of > floating point numbers to integers truncates towards zero. ?A string must > be a base-radix integer literal optionally preceded by '+' or '-' (with no > space in between) and optionally surrounded by whitespace. ?A base-n > literal consists of the digits 0 to n-1, with 'a' to 'z' (or 'A' to 'Z') > having values 10 to 35. ?The default radix is 10. The allowed values are 0 > and 2-36, with 0 the same as 10. > > If 0 is not the same as 10, the last would have to be changed, but I could > not detect any difference in a quick test. One thing though, I think it should say "may be surrounded by whitespace" as opposed to "optionally surrounded by whitespace". On Apr 7, 1:55 am, Grant Edwards wrote: > On 2008-04-06, Lie wrote: > > > I've noticed some oddly inconsistent behavior with int and float: > > > Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) > > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > >>>> int('- 345') > > -345 > > > works, > > IMO, it oughtn't. > > >>>> float('- 345.083') > > Traceback (most recent call last): > > File "", line 1, in > > ValueError: invalid literal for float(): - 345.083 > > That's the behavior I'd expect. Sorry to confuse you, by works I mean that the interpreter doesn't complain at all, I didn't mean that it works as it should be. From bj_666 at gmx.net Sun Apr 20 09:59:10 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 20 Apr 2008 13:59:10 GMT Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> Message-ID: <6710hdF2mi30gU1@mid.uni-berlin.de> On Sun, 20 Apr 2008 22:46:37 +1000, Hank @ITGroup wrote: > Apology for the previous offensive title~~ > :) > Thanks, Rintsch, Arnaud and Daniel, for replying so soon. > > I redid the experiment. What following is the record - > > ``starting python`` # == Windows Task Manager: > Python.exe *4,076 *K memory-usage == > >>> st1='abcdefg'*999999 # == 10,952 K == > >>> del st1 # == *4,104*K == > >>> st1='abcdefg'*999999 # == 10,952 K == > >>> del st1 # == 4,104 K == > > >>> li = ['abcde']*999999 # == 8,024 K == > >>> del li # == *4,108* K == > > >>> from nltk import FreqDist # == 17,596 == > >>> fd = FreqDist() # == 17,596 == > >>> for i in range(999999):fd.inc(i) # == 53,412 == > >>> del fd # == *28,780* == > >>> fd2 = FreqDist() # == 28,780 == > >>> for i in range(999999):fd2.inc(i) # == 53,412 == > >>> del fd2 # == 28,780 K == > > >>> def foo(): > ... fd3 = FreqDist() > ... for i in range(999999):fd3.inc(i) > > >>> foo() # == *28,788* K == > > >>> def bar(): > ... fd4 = FreqDist() > ... for i in range(999999):fd4.inc(i) > ... del fd4 > # == 28,788 K == > >>> bar() # == 28,788 K == > > > That is my question, after ``del``, sometimes the memory space returns > back as nothing happened, sometimes not... ... > What exactly was happening??? Something. Really it's a bit complex and implementation dependent. Stop worrying about it until it really becomes a problem. First of all there's no guarantee that memory will be reported as free by the OS because it is up to the C runtime library if it "gives back" freed memory to the OS or not. Second the memory management of Python involves "arenas" of objects that only get freed when all objects in it are freed. Third some types and ranges of objects get special treatment as integers that are allocated, some even preallocated and never freed again. All this is done to speed things up because allocating and deallocating loads of small objects is an expensive operation. Bottom line: let the Python runtime manage the memory and forget about the ``del`` keyword. It is very seldom used in Python and if used then to delete a reference from a container and not "bare" names. In your `bar()` function it is completely unnecessary for example because the name `fd4` disappears right after that line anyway. Ciao, Marc 'BlackJack' Rintsch From ivan.illarionov at gmail.com Thu Apr 24 01:21:17 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Wed, 23 Apr 2008 22:21:17 -0700 (PDT) Subject: @classmethod question References: Message-ID: On 24 ???, 07:27, Scott SA wrote: > Hi, > > I'm using the @classemethod decorator for some convenience methods and for some reason, either mental block or otherwise, can't seem to figure out how to elegantly detect if the call is from an instance or not. > > Here's the problem: Within the class definition, 'isinstance' has nothing to compare to because the class does not appear to exist. > > This is NOT a great example, but it outlines the the code: > > class RecipieClass: > def __init__(self): > pass > > @classmethod > def get_ingrendients(self, recipie_list=None): > > if isinstnace(self,RecipieClass): > return self.do_something_interesting() > else: > return do_something_boring(recipie_list) > > Yes, I can test to see if the param exists, but that makes the call exclusive i.e. I can _only_ call it as an instance or with a parameter. > > Why am I doing this? > > It is a series of convenience methods, in this case I'm interacting with a database via an ORM (object-relational model). I want the ability to call a class-ojbect and get related values, or pass some criteria and get related values for them without collecting the records first as instances, then iterating them. I need to call this from several places so I want to be DRY (don't repeat yourself). > > The easiest way to describe this as an analogy would be like having a recipie for cookies and wanting to know all of the ingredients ahead of time. Then, at another time, wanting to know what all the ingredients would be to make cookies, cake and bread (i.e. complete shopping list). > > cookie_recipie = RecipieClass.get_recipie('cookies') > cookie_recipie.get_ingredients() > 2C Flour > 0.5 C Sugar > ... > > RecipieClass.get_ingrendients(['cookies','cake','bread']) > 8C Flour > 2C Sugar > ... > > Of course any suggestions on how this might be better approached would be interesting too. > > TIA, > > Scott Hi, It would make sense to separate instance-level and class-level behaviour with additional 'objects' namespace. e.g. cookie_recipie.get_ingredients() to get ingredients only for cookie recipie and RecipieClass.objects.get_ingrendients([....]) to get all the ingredients. The elegant solution (AFAIK used by Django) would be to use metaclass and the object with custom descriptor for class-object/table level stuff. Something like this: class RecipieMetaclass(type): def __new__(cls, bases, attrs): new_cls = type.__new__(cls, name, bases, attrs) new_cls.objects = IngredientsDescriptor(IngredientsManager()) return new_cls class RecipieClass(object): __metaclass__ = RecipieMetaclass def get_ingredients(self, recipie_list=None): return self.do_something_interesting(recipie_list) class IngredientsManager(object): def get_ingredients(self, recipie_list=None): return do_something_boring(recipie_list) class IngredientsDescriptor(object): def __init__(self, ingredients_manager): self.ingredients_manager = ingredients_manager def __get__(self, instance, type=None): if instance is not None: raise AttributeError, "Access via %s instances is not allowed" % type.__name__ return self.ingredients_manager Then, "at another time, wanting to know what all the ingredients would be to make cookies, cake and bread" you would call: RecipieClass.objects.get_ingrendients(['cookies','cake','bread']) Both Django and Google Apps Engine API use similar concepts and you can learn much more interesting looking in their source code. Regards, -- Ivan From response1 at antypas.net Sat Apr 12 23:16:00 2008 From: response1 at antypas.net (John Antypas) Date: Sat, 12 Apr 2008 20:16:00 -0700 Subject: Looking for a way to include Pyhtho scripting INSIDE a python program Message-ID: <48017af0$0$36399$742ec2ed@news.sonic.net> Hello all, I'm writing in tool in Python that manipulates various data objects read from various streams. I wanted to give the user a chance to do advanced work that could not easily be done from a GUI. At first, I tried putting in a lightweight scripting language, and then I thought, why not include Python in itself -- it is certainly powerful enough. I had assumed I'd present the user with a text window in which they could type arbitrary python code. I'd wrap that code around a function and pass that function a call of objects they could manipulate by calling the methods of that class. 1. How can a python program invoke ANOTHER interpreter? 2. How can I pass the class in as its argument and get the modified class back? I know I can do something very ugly -- call a C method that calls a new python interpreter but that seems VERY ugly. Help? Thanks. From hobgoodoreneyhb at gmail.com Tue Apr 22 11:37:35 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:37:35 -0700 (PDT) Subject: kalkulator ip crack Message-ID: <21e86bcb-bbcc-4631-954a-2c285cc93cfc@m3g2000hsc.googlegroups.com> kalkulator ip crack http://cracks.12w.net F R E E C R A C K S From aaron.watters at gmail.com Wed Apr 30 11:44:19 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 30 Apr 2008 08:44:19 -0700 (PDT) Subject: best way to host a membership site References: <53034dcc-7346-4f71-889c-3278c9e813ec@w1g2000prd.googlegroups.com> Message-ID: On Apr 30, 10:43 am, Jeroen Ruigrok van der Werven wrote: >.... > Werkzeug -http://werkzeug.pocoo.org/ .... Wow. An initial glance looks great! I need help with pronunciation, though :(. (also, I'm a little disappointed because I made some notes that looked a little like this...) -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=slip+nibble From rhamph at gmail.com Wed Apr 16 13:42:38 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Wed, 16 Apr 2008 10:42:38 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> Message-ID: <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> On Apr 16, 10:40 am, Aaron Watters wrote: > On Apr 16, 12:27 pm, Rhamphoryncus wrote: > > > On Apr 16, 6:56 am, Aaron Watters wrote: > > > > I don't get it. It ain't broke. Don't fix it. > > > So how would you have done the old-style class to new-style class > > transition? > > I'd ignore it. I never understood it and never had > any need for it anyway. New-style classes and metaclasses > were a complicated solution to an unimportant problem in > my opinion. And also a fiendish way to make code > inscrutible -- which I thought was more of a Perl thing > than a Python thing, or should be. > > I must be missing some of the deeper issues here. Please > educate me. >>> type(3) >>> (3).__class__ Traceback (most recent call last): File "", line 1, in ? AttributeError: 'int' object has no attribute '__class__' >>> class Foo: pass ... >>> type(Foo()) >>> Foo().__class__ With new-style classes, (3).__class__ returns int and type(Foo()) returns Foo. Of course a lot of other aspects were redesigned at the same time, such as how attributes/methods are looked up. The consequence of that is we got descriptors. Seems like a fair trade to me. Another example of an incompatible change was this: >>> 2**32 Traceback (most recent call last): File "", line 1, in ? OverflowError: integer exponentiation In recent versions of 2.x you get this instead: >>> 2**32 4294967296L Finally, 3.0 changes it to this: >>> 2**32 4294967296 Personally, I find all these changes to be a good thing. They make the language cleaner and more useful. The only reason to not make the changes is that old, crufty, unmaintained libraries & applications might depend on them somehow. If that's more important to you, what you really want is a language who's specs are frozen - much like C effectively is. I hope python doesn't become that for a long time yet, as there's too much it could do better. From turian at gmail.com Fri Apr 18 14:08:45 2008 From: turian at gmail.com (Joseph Turian) Date: Fri, 18 Apr 2008 11:08:45 -0700 (PDT) Subject: Python 2.5 adoption Message-ID: How widely adopted is python 2.5? We are doing some development, and have a choice to make: a) Use all the 2.5 features we want. b) Maintain backwards compatability with 2.4. So I guess the question is, does anyone have a sense of what percent of python users don't have 2.5? Thanks, Joseph From mr.cerutti at gmail.com Fri Apr 11 12:08:17 2008 From: mr.cerutti at gmail.com (Neil Cerutti) Date: Fri, 11 Apr 2008 12:08:17 -0400 Subject: text adventure game problem In-Reply-To: References: Message-ID: <51302a8c0804110908y2afc91ew2aa8ae83383c03dd@mail.gmail.com> On Thu, Apr 10, 2008 at 8:25 PM, Carl Banks wrote: > On Apr 10, 2:20 pm, Tommy Nordgren wrote: > > > On 9 apr 2008, at 03.01, corvettecra... at gmail.com wrote: > > > > > okay, I'm having this one problem with a text adventure game. It's > > > kind of hard to explain, but I'll do my best. > > > [code] > > > > > def prompt_kitchen(): > > > global gold > > > > > Python is not a suitable language for Text Adventure Development. > > Ridiculous. Agreed. "Not suitable" is an exaggeration. However, designing and implementing your own adventure game framework in Python is a total waste of time. Don't do it except for the sake of it. You can even claim one of several Python-based frameworks out of mothballs as a starting point, if you want to use Python. > There are many good reasons why someone might want to use a general > purpose language like Python to write a text adventure, Yes. > such as so > they're not stuck with a quasi hack of a language if they have to do > something that doesn't fit the framework anticipated by the language > designer. That's not a reason, it's FUD. -- Neil Cerutti From bvidinli at gmail.com Tue Apr 15 04:58:57 2008 From: bvidinli at gmail.com (bvidinli) Date: Tue, 15 Apr 2008 11:58:57 +0300 Subject: Boa: howto make child windows really child Message-ID: <36e8a7020804150158m4db54387g3f3a5852db6fe12d@mail.gmail.com> i just started using Boa constructor, but, i dont like child windows floatin,g on my desktop. how can i make all child windows of boa all together, docked in one parent boa window... i found in preferences, general, childFrameStyle, i set it to wx.FRAME_FLOAT_ON_PARENT|wx.FRAME_TOOL_WINDOW but, it did not help as i want it to be... any help is welcome... -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From s0suk3 at gmail.com Thu Apr 17 11:32:49 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 08:32:49 -0700 (PDT) Subject: Unicode chr(150) en dash References: <48063434$0$36327$742ec2ed@news.sonic.net> Message-ID: <77d74442-f47f-4ef1-8cdd-ab93362f16de@l42g2000hsc.googlegroups.com> On Apr 17, 10:10 am, marexpo... at googlemail.com wrote: > Thank you Martin and John, for you excellent explanations. > > I think I understand the unicode basic principles, what confuses me is the usage different applications make out of it. > > For example, I got that EN DASH out of a web page which states at the beggining. That's why I did go for that encoding. But if the browser can properly decode that character using that encoding, how come other applications can't? > > I might need to go for python's htmllib to avoid this, not sure. But if I don't, if I only want to just copy and paste some web pages text contents into a tkinter Text widget, what should I do to succesfully make every single character go all the way from the widget and out of tkinter into a python string variable? How did my browser knew it should render an EN DASH instead of a circumflexed lowercase u? > > This is the webpage in case you are interested, 4th line of first paragraph, there is the EN DASH:http://www.pagina12.com.ar/diario/elmundo/subnotas/102453-32303-2008-... > > Thanks a lot. > Simplemente escribe en ingles. Like this, see? No encodings mess. From hdante at gmail.com Wed Apr 2 09:58:23 2008 From: hdante at gmail.com (hdante) Date: Wed, 2 Apr 2008 06:58:23 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> Message-ID: <77738358-fc19-48a5-83b6-25e5b7e265b8@a1g2000hsb.googlegroups.com> On Apr 2, 10:50 am, Aaron Watters wrote: > > Try Rails' ActiveRecord. Your problems should reduce to (lg lg > > 2)^(1/12). > > python> (log(log(2)))**(1.0/12.0) > Traceback (most recent call last): > File "", line 1, in ? > ValueError: negative number cannot be raised to a fractional power > > So you are saying the problems will get really complex? :) lg(x) == log_2(x) lg(lg(2))^(1/12) == 0. (fortunately I didn't write 3 lg's). :-P > > > Seriously, you'll forget there's a relational database below. (there > > are even intefaces for "relational lists", "trees", etc.) > > My experience with this sort of thing is that it is a bit > like morphine. It can feel really good, and in emergencies I don't have this much experience on either. ;-) > it can save you a lot of pain. But if you use it too often > and too seriously you end up with really big problems. > > -- Aaron Watters > > ===http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=mysterious+obj... From nick at craig-wood.com Wed Apr 2 04:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Wed, 02 Apr 2008 03:30:03 -0500 Subject: bsddb3 thread problem References: <1c00d777-b1eb-438a-85b6-8096a7453829@u36g2000prf.googlegroups.com> Message-ID: anuraguniyal at yahoo.com wrote: > > > Using threads with bsddb3. ?I spent weeks trying to get it to behave > > when threading. ?I gave up in the end and changed to sqlite :-( > > > So does it mean that I will have to use threading locks around access > methods? or that will also fail mysteriously :) In theory bsddb is thread safe if you pass the right flags into the constructor. In practice I had to read the source code of the python interface to work out what flags I was supposed to be passing at all and I'm not convinced I ever got them right. It is really quite confusing the way bsddb objects get constructed! In practice bdsdb just locked up and crashed in lots of odd ways when I abused it with threads, whereas sqlite gave me nice error messages saying something like "you made this handle in thread X but now you are trying to use it in thread Y which won't work". You can probably make bsddb work with threads, but I wasted too much time trying without success! -- Nick Craig-Wood -- http://www.craig-wood.com/nick From ptmcg at austin.rr.com Thu Apr 17 22:39:12 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Thu, 17 Apr 2008 19:39:12 -0700 (PDT) Subject: get quote enclosed field in a line References: <4807e238$1@news.mel.dft.com.au> Message-ID: <06abd891-daa1-428f-a921-bbd3a46fa7cd@m73g2000hsh.googlegroups.com> On Apr 17, 6:50?pm, John Machin wrote: > xah... at gmail.com wrote: > > is there a simple way in perl, python, or awk/shell/pipe, that gets > > the user agent field in a apache log? > > > e.g. the typical line is like this: > > > 189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET / > > Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org > > "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/ > > 5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311 > > Firefox/2.0.0.13" "-" > > > I want the part: "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv: > > 1.8.1.13) Gecko/20080311 Firefox/2.0.0.13". > > C:\junk>type xah.py > import cStringIO, csv, pprint > line = '''189.139.109.235 - etc etc etc''' > f = cStringIO.StringIO(line) > reader = csv.reader(f, delimiter=" ") > row = reader.next() > pprint.pprint(row) > > C:\junk>xah.py > ['189.139.109.235', > ? '-', > ? '-', > ? '[07/Apr/2008:00:00:16', > ? '-0400]', > ? 'GET / Periodic_dosage_dir/lacru/manara.html HTTP/1.1', > ? '200', > ? '1933', > ? 'xahlee.org', > ? 'http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html', > ? 'Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) > Gecko/20080311 Fi > refox/2.0.0.13', > ? '-'] > > If you don't like that, just hang about -- there's sure to be a > pyparsing bus coming by real soon now :-) > > Cheers, > John Beep, beep! You can find a pyparsing-based log server file parser at http://pyparsing.wikispaces.com/space/showimage/httpServerLogParser.py. Vrooom! -- Paul From dcoffin at gmail.com Mon Apr 28 10:48:58 2008 From: dcoffin at gmail.com (dcoffin at gmail.com) Date: Mon, 28 Apr 2008 07:48:58 -0700 (PDT) Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> <18c1e6480804270653r2e075061wf442b7b7d9f50ff6@mail.gmail.com> Message-ID: <5b8a7008-d463-41cb-ba67-1440fe00dfb4@y21g2000hsf.googlegroups.com> I've never used it myself but you may find candygram interesting; http://candygram.sourceforge.net, which AFAIK implements Erlang-style message queues in Python. From reacocard at gmail.com Sat Apr 5 23:50:58 2008 From: reacocard at gmail.com (reacocard) Date: Sat, 5 Apr 2008 20:50:58 -0700 (PDT) Subject: httplib VERY slow Message-ID: <8486e357-1cab-4b30-a060-1750068929ac@1g2000prg.googlegroups.com> Hi, I'm writing a download manager in python, and httplib is being very slow when pulling from localhost or even other servers on the local network. I'm getting about 10MB in 14s with httplib, while wget hits 80MB in less than 3s. You can find the code I made to benchmark this here: http://pastebin.ca/973486 (noslor is mapped to my IP in / etc/hosts) Does anyone have any idea what might be causing this, and how I can fix it? I'm using python2.5 under Ubuntu Linux 8.04 with apache2 for the webserver. Thanks in advance. From deets at nospam.web.de Wed Apr 9 08:09:39 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 09 Apr 2008 14:09:39 +0200 Subject: Basic optimization of python. References: <16061d43-8baf-4117-88e9-28d65a6d4491@n1g2000prb.googlegroups.com> Message-ID: <663q0vF2hnrh2U1@mid.uni-berlin.de> > This is safe, and is done: > >>>> import dis >>>> def f(): x = 1 + 2 > ... >>>> dis.dis(f) > 1 0 LOAD_CONST 3 (3) > 3 STORE_FAST 0 (x) > 6 LOAD_CONST 0 (None) > 9 RETURN_VALUE >>>> So I stand corrected. Any idea when that was introduced? Diez From python.tsp at gmail.com Wed Apr 9 04:29:24 2008 From: python.tsp at gmail.com (pramod sridhar) Date: Wed, 9 Apr 2008 13:59:24 +0530 Subject: Need Help Message-ID: Hello, I would like to access type library files (.tlb) from python. The application (with .tlb extension) controls an external instrument over standard GPIB interface. Is it possible to control this application from Python? If so, how ? Can anyone share or send link of some examples ? Many Thanks in advance, Pramod -------------- next part -------------- An HTML attachment was scrubbed... URL: From antroy at gmail.com Thu Apr 3 10:49:20 2008 From: antroy at gmail.com (Ant) Date: Thu, 3 Apr 2008 07:49:20 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> <88b07549-9751-489b-968f-c3d2db0aba79@s13g2000prd.googlegroups.com> Message-ID: <5c1011e2-37f4-4e3b-bf46-a8cd26710cb2@u36g2000prf.googlegroups.com> On Apr 3, 2:27 pm, George Sakkis wrote: ... > It's even prettier in 2.5: > > any(word in name for word in words) > > George And arguably the most readable yet! From arnodel at googlemail.com Thu Apr 24 04:43:40 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 24 Apr 2008 09:43:40 +0100 Subject: annoying dictionary problem, non-existing keys References: Message-ID: bvidinli writes: > i use dictionaries to hold some config data, > such as: > > conf={'key1':'value1','key2':'value2'} > and so on... > > when i try to process conf, i have to code every time like: > if conf.has_key('key1'): > if conf['key1']<>'': > other commands.... > > > this is very annoying. Especially when you don't have to do this. > in php, i was able to code only like: > if conf['key1']=='someth' > > in python, this fails, because, if key1 does not exists, it raises > an exception. > > MY question: is there a way to directly get value of an > array/tuple/dict item by key, as in php above, even if key may not > exist, i should not check if key exist, i should only use it, if it > does not exist, it may return only empty, just as in php.... At the interactive prompt, type 'help(dict)' and read carefully about the different methods provided by dictionary objects (one called 'get' may be of particular interest to you). HTH -- Arnaud From joeblow at nowhere.nohow Sat Apr 19 06:40:24 2008 From: joeblow at nowhere.nohow (Joe Blow) Date: 19 Apr 2008 10:40:24 GMT Subject: TypeNone field detection References: <480698b3$0$31577$ec3e2dad@news.usenetmonster.com> Message-ID: <4809cc17$0$2862$ec3e2dad@news.usenetmonster.com> On Wed, 16 Apr 2008 21:13:18 -0400, Steve Holden wrote: > > Since there is only one instance of TypeNone (the value we reference as > None) the easiest test is > > if x is None: > Thanks... the "if x is None:" statement is exactly what I was looking for. From deets at nospam.web.de Fri Apr 18 03:28:37 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 18 Apr 2008 09:28:37 +0200 Subject: Can't do a multiline assignment! In-Reply-To: References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <42402158-0b16-42e2-b7a0-9d9a15e8196d@24g2000hsh.googlegroups.com> <0f5c3363-7e23-4a19-b7f8-021f1d6e3f6c@t54g2000hsg.googlegroups.com> Message-ID: <66r0tlF2m5ltpU1@mid.uni-berlin.de> Michael Torrie schrieb: > s0suk3 at gmail.com wrote: >> You didn't really write that at the Python's interpreter, did you? >> It's wrong. The way that would really go at the interpreter is like > > I did actually run it through the interpreter, but I didn't copy and > past it to the e-mail. Thought that I saw this behavior, but clearly I > must not have. > >> classvar1 and classvar2 might be class variables, but in they don't >> work as they would in C++ or Java (like the ones you declare with the >> 'static' modified). > > Still, it's not pythonic to define instance variables in this way, as > far as I can tell. I've seen & used that for quite a while. It is more clear to provide defaults that way. Diez From malaclypse2 at gmail.com Wed Apr 9 13:31:30 2008 From: malaclypse2 at gmail.com (Jerry Hill) Date: Wed, 9 Apr 2008 13:31:30 -0400 Subject: question about string formatting In-Reply-To: <42b9a3ff0804091004s4d60751fh68c82673e8e3f4c3@mail.gmail.com> References: <42b9a3ff0804091004s4d60751fh68c82673e8e3f4c3@mail.gmail.com> Message-ID: <16651e80804091031u5fc752e6s90b54c8675108088@mail.gmail.com> On Wed, Apr 9, 2008 at 1:04 PM, Kelie wrote: > Is there something in Python built-in function or library that will convert > a number 1205466.654 to $1,205,466.65? To add the "$" sign and set the > decimal place is not a problem, but I don't know how to add the thousands > delimiter. The locale module provides this functionality. >>> import locale >>> locale.setlocale(locale.LC_ALL, '') 'English_United States.1252' >>> print locale.currency(1205466.654) $1205466.65 >>> locale.currency(1205466.654, grouping=true) $1,205,466.65 That's using the default locale. For me, that's US English. Other languages and countries have different ways of showing currency: >>> locale.setlocale(locale.LC_ALL, "fr") 'French_France.1252' >>> print locale.currency(1205466.654, grouping=True) 1 205 466,65 ? -- Jerry From mwilson at the-wire.com Wed Apr 30 15:53:16 2008 From: mwilson at the-wire.com (Mel) Date: Wed, 30 Apr 2008 15:53:16 -0400 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> <74c070ce-1b8f-4746-9d1c-ac2227aaf515@y21g2000hsf.googlegroups.com> Message-ID: George Sakkis wrote: > def join(iterable, sep=' ', encode=str): > return sep.join(encode(x) for x in iterable) Actually return encode(sep).join(encode(x) for x in iterable) lest you get TypeErrors for non-string separators. Mel. From torriem at gmail.com Thu Apr 17 19:47:14 2008 From: torriem at gmail.com (Michael Torrie) Date: Thu, 17 Apr 2008 17:47:14 -0600 Subject: Finally had to plonk google gorups. In-Reply-To: References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <4807E182.60604@gmail.com> Mike Driscoll wrote: > I'm confused. First you say Gmail is create for filtering and then you > say it has a broken interface. I like Gmail for some things, but my > inability to create folders is one thing that really bugs me. I can > set up Thunderbird to accept mail from Gmail and do it that way > though. I assume when you say that you only get 1 email in your inbox, > you mean one "errant" email and the rest get filtered to your other > folders, correct? Gmail is perfectly capable of being used by traditional e-mail clients like Thunderbird via IMAP. When this is done, I see mail in folders and threads. The filtering itself is done by the gmail server. You do have to use the web interface to set up the filtering, but once that is done Thunderbird works fabulously. The Gmail webmail interface displays threads in a fundamentally broken way, though. > > Thanks for the response. It's always interesting to see how others > have dealt with the issue. > > Mike From skanemupp at yahoo.se Sat Apr 5 17:23:50 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 14:23:50 -0700 (PDT) Subject: Tkinter, add pressed buttons onto string display string, how to? References: <57605958-5589-4ebe-abdf-73c2d14c8a82@u10g2000prn.googlegroups.com> <65q8juF2gq610U2@mid.uni-berlin.de> Message-ID: <649d9748-c389-411d-9794-9753ddf434b0@d1g2000pra.googlegroups.com> > Just like the message says: You are trying to use `str` (on the right hand > side of the assignment) before anything is bound to that name. > > Ciao, > Marc 'BlackJack' Rintsch i know but i want the variable str(which i found out is a reserved word so i changed it) to be accessible all over __init__ right? so i tried to delcare it in __init__ in the beginning of the framework class but then when i access it in the method Display i get that error. so how should i declare this variable to be able to access it everywhere? i want another method "calculate" that can access the same string later and do the calculations(writing some other code now that will read and interpret that). From steve at holdenweb.com Wed Apr 2 09:59:17 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 02 Apr 2008 09:59:17 -0400 Subject: generator functions: why won't this work? In-Reply-To: <0aaeddf2-ee63-426e-afb3-0e1acb15adef@r9g2000prd.googlegroups.com> References: <0aaeddf2-ee63-426e-afb3-0e1acb15adef@r9g2000prd.googlegroups.com> Message-ID: zillow10 at googlemail.com wrote: > On Apr 2, 4:42 am, "Gabriel Genellina" wrote: >> En Tue, 01 Apr 2008 23:56:50 -0300, escribi?: >> >>> I'm trying to understand generator functions and the yield keyword. >>> I'd like to understand why the following code isn't supposed to work. >>> (What I would have expected it to do is, for a variable number of >>> arguments composed of numbers, tuples of numbers, tuples of tuples, >>> etc., the function would give me the next number "in sequence") >>> #################################### >>> def getNextScalar(*args): >>> for arg in args: >>> if ( isinstance(arg, tuple)): >>> getNextScalar(arg) >>> else: >>> yield arg >>> #################################### >> You're not the first one in getting confused. After all, this schema works >> well for other recursive constructs. >> Perhaps a progression of working code samples will help to understand what >> happens here. The simplest thing would be to just print the items as >> they're encountered, in a recursive call: >> >> py> data = (1, 2, (3,4,(5,6),7)) >> py> >> py> print "1) using print" >> 1) using print >> py> >> py> def getNextScalar(args): >> ... for arg in args: >> ... if isinstance(arg, tuple): >> ... getNextScalar(arg) >> ... else: >> ... print arg >> ... >> py> getNextScalar(data) >> 1 >> 2 >> 3 >> 4 >> 5 >> 6 >> 7 >> >> Now one could try to collect the numbers in a list: >> >> py> print "2) using extend" >> 2) using extend >> py> >> py> def getNextScalar(args): >> ... result = [] >> ... for arg in args: >> ... if isinstance(arg, tuple): >> ... result.extend(getNextScalar(arg)) >> ... else: >> ... result.append(arg) >> ... return result >> ... >> py> getNextScalar(data) >> [1, 2, 3, 4, 5, 6, 7] >> >> Note that we use two different list methods: for individual items, we use >> "append", but for tuples we use "extend" in the recursive call. If extend >> weren't available, we could emulate it with append: >> >> py> print "3) using append" >> 3) using append >> py> >> py> def getNextScalar(args): >> ... result = [] >> ... for arg in args: >> ... if isinstance(arg, tuple): >> ... for item in getNextScalar(arg): >> ... result.append(item) >> ... else: >> ... result.append(arg) >> ... return result >> ... >> py> getNextScalar(data) >> [1, 2, 3, 4, 5, 6, 7] >> >> See how we need an additional loop to iterate over the results that we get >> from the recursive call. >> Now instead of building an intermediate result list, we delegate such task >> over the caller, and we use a generator that just yields items; this way, >> we remove all references to the result list and all result.append calls >> become yield statements. The inner loop has to remain the same. The yield >> statement acts somewhat as an "append" over an outer list created by the >> generator's caller. >> >> py> print "4) using yield" >> 4) using yield >> py> >> py> def getNextScalar(args): >> ... for arg in args: >> ... if isinstance(arg, tuple): >> ... for item in getNextScalar(arg): >> ... yield item >> ... else: >> ... yield arg >> ... >> py> getNextScalar(data) >> >> py> list(getNextScalar(data)) >> [1, 2, 3, 4, 5, 6, 7] >> >> I hope it's more clear now why you have to use yield on the recursive call >> too. >> >> >> Perhaps this: >> >> yield *iterable >> >> could be used as a shortcut for this: >> >> for __temp in iterable: yield __temp >> >> >> >> -- >> Gabriel Genellina > > Thanks to everyone for your very helpful replies. I think I was trying > to use generator functions without first having really read about > iterators (something I still haven't done, although I've managed to > extrapolate some details based on your comments), and therefore really > "putting the cart before the horse". I was interpreting > getNextScalar(arg) on line 3 as a function call in the usual sense > rather than an object that was being created but never used. > > I have a question about the other issue that was pointed out. With > reference to the following (corrected) code: > > def getNextScalar(*args): > for arg in args: > if(isinstance(arg, tuple)): > for f in getNextScalar(*arg): # why not getNextScalar(arg)? > yield f > else: > yield arg > > although I've verified that the line 4 needs to be "for f in > getNextScalar(*arg)" rather than "for f in getNextScalar(arg)" when > passing multiple arguments to the function, I'd just like to test my > understanding of this. Suppose I create the following generator > object: > > g = getNextScalar(1, 2, (3, 4), 5) > > when the iterator reaches the tuple argument (3, 4) then, according to > Steve and George, the * in *arg causes this tuple to be expanded into > positional arguments, and it makes sense to do it this way. But what > happens when getNextScalar(arg) is used instead? I presume that (3,4) > is passed as a single tuple argument, if(isinstance(arg, tuple)) is > true, and the tuple is passed again as an the argument to > getNextScalar()... ad infinitum. The alternative is to define a > function that takes a tuple, as Gabriel has done. > Either approach would work - it just seemed to make more sense to use existing functionality and recurse (at least to me). You should try removing the * from the recursive call. I expect you would find that you (eventually) experience a stack overflow due to the infinite nature of the recursion. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bbxx789_05ss at yahoo.com Sat Apr 5 15:56:25 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sat, 5 Apr 2008 12:56:25 -0700 (PDT) Subject: Tkinter, add pressed buttons onto string display string, how to? References: Message-ID: <370358c4-c7f3-48da-885a-714df9c1a3bb@u69g2000hse.googlegroups.com> On Apr 5, 1:55?pm, 7stud wrote: > skanem... at yahoo.se wrote: > > using tkinter and python i now have a small App (that will hopefully > > soon be a fully functioning calculator) where u can push buttons and > > the corresponding number or operator is shown. > > > when u press 1, "1" appears on the screen, pres + and "+" appears etc. > > > at the moment every output overwrites the previous so what i want to > > do is obviosuly to add every new output to a string so that i can read > > the string and perform the calculation. > > > so i want: > > * ?when pushing the button push the token of the button onto a string > > * display the new string, ie "1+2" for example > > * want to be able to access this string when pressing calculate so i > > can figure out which operators should > > be done first so it can solve something like this: "(1+2*3)(3-4/2)" > > and not just simple "1+2"-stuff. > > > do i have to have some global string-variable in the GUIframework > > then? im not sure where to start... > > input = "hello" > input += " world" > print input > > --output:-- > hello > > A caculator program is pretty complex. ?Based on your rudimentary > questions, I don't think you have enough programming experience to > tackle a project like that yet. --output:-- hello world From marco at sferacarta.com Wed Apr 16 09:16:27 2008 From: marco at sferacarta.com (Marco Mariani) Date: Wed, 16 Apr 2008 15:16:27 +0200 Subject: py3k s***s In-Reply-To: References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: Aaron Watters wrote: > stuff out there you can get so easily -- all the stuff that py3k > will break -- most of which won't get ported -- and if it does can > we be sure it will be tested properly? No, probably you will end > up beta testing someone's quick port of what used to be rock > solid code... This was quite rightly pointed out to me, and > I had to agree that it was a pretty good point. Do you mean Ruby's track in providing backward compatibility is better than Python's? Googling for that a bit, I would reckon otherwise. From james at reggieband.com Fri Apr 18 14:10:09 2008 From: james at reggieband.com (james at reggieband.com) Date: Fri, 18 Apr 2008 11:10:09 -0700 (PDT) Subject: Request a short code review References: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> Message-ID: <33a50f5b-f82d-41aa-b28f-b00dba4bf2eb@m73g2000hsh.googlegroups.com> Thank you all for posting insightful and useful comments. Here is what I have based on your input: def output_random_lesson_of_type(self, lesson_type=None): """Output a lesson of a specific type. If no type is passed in then output all types.""" lessons = self.lesson_data["lessons"] if lesson_type: lessons = [x for x in lessons if x["type"] == lesson_type] rand_lesson = choice(lessons) inputs = self.create_lesson_inputs(rand_lesson) print rand_lesson["output"] % inputs return rand_lesson, inputs Changes: - generator expression instead of filter - removed keyword 'type' in favor of lesson_type - wrap to 78 columns - remove error-check -- allow it to fail in the choice statement. I've decided to make a valid lesson_type an invariant anyway so the appropriate thing would be an assert - but I'll settle for a throw from choice if it receives an empty list - moved self.output_random logic into this function The lesson data is loaded from YAML which explains why it is inside a dictionary instead of a class. I am currently exploring ways to allow me to easily switch my data providers between SQLAlchemy and YAML. Cheers again. This is very valuable for me. I am a true believer that if one takes care in the smallest of methods then the larger code- base will be all the better. James. From mdboldin at gmail.com Wed Apr 16 11:33:27 2008 From: mdboldin at gmail.com (mmm) Date: Wed, 16 Apr 2008 08:33:27 -0700 (PDT) Subject: Creating arithmetic sequences Message-ID: <54221025-2f61-40ad-beef-82cc74234d87@e39g2000hsf.googlegroups.com> I wrote the code below to create simple arithmetic sequences that are iter-able I.e., this would basically combine the NUMPY arange(start,end,step) to range(start,end), with step not necessarily an integer. The code below is in its simplest form and I want to generalize the sequence types (multiplicative, cumulative, gauss ...), but first I need the simple SEQA( ) function to be more robust. The problem is the three test code functions produces different results based on step. I understand why steps such as 0.1 have rounding and machine math issues, and before I try to solve this I thought it was worth asking if this problem has been solved (so I do not re-invent the wheel). Another way to put my question, is there a PYTHON function that emulates SEQA() in APTECH?s GAUSS language and produces iterable lists ? Note I originally wrote the three versions below see which is fastest, but each is fast enough such that I care more about robustness now. ## Python arithmetic sequence implimentation ## MDB April 16 2008 from numpy import array, arange, floor import time # simple arithmetic sequence def seqa1(start,end,step=1): n= floor( (end-start) / float(step) ) x= [start,] for i in xrange(0,n): x.append(x[-1]+step) return x ##faster seq creation def seqa2(start,end,step=1): n= floor( (end-start) / float(step) ) x= [ start+i*step for i in xrange(0,n) ] return x ##fastest seq creation as array, also allow array --> different type def seqa3(start,end,step=1.0,type=array): x=arange(start,end,step) if type==array: pass elif type==list or type==None or type=='' : x=list(x) elif type==tuple: x=tuple(x) elif type==dict: x= dict(zip(range(1,len(x)),tuple(x))) elif type==set: x= set(x) return x if (1): start=1 end=2 step= 0.10 t0=time.time() x1=seqa1(start,end,step) print 'SEQA1 Time= ', time.time()-t0 t0=time.time() x2=seqa2(start,end+step,step) print 'SEQA2 Time= ', time.time()-t0 print 'Check for X1,X2 equivalence-- ', (x1==x2) t0=time.time() x3=seqa3(start,end+step,step,list) print 'SEQA3 Time= ', time.time()-t0 print 'Check for X2,X3 equivalence-- ', (x2==x3) From m.bless at gmx.de Sun Apr 20 09:49:07 2008 From: m.bless at gmx.de (Martin Bless) Date: Sun, 20 Apr 2008 15:49:07 +0200 Subject: codec for html/xml entities!? References: <48084C97.4040400@behnel.de> Message-ID: <2ohm04hm4sk0rn019tk1ntrii74hu8ajdo@4ax.com> [Stefan Behnel] wrote & schrieb: >Martin Bless wrote: >> What's a good way to encode and decode those entities like € or >> € ? > >Hmm, since you provide code, I'm not quite sure what your actual question is. - What's a GOOD way? - Am I reinventing the wheel? - Are there well tested, fast, state of the art, builtin ways? - Is something like line.decode('htmlentities') out there? - Am I in conformity with relevant RFCs? (I'm hoping so ...) >So I'll just comment on the code here. > > >> def entity2uc(entity): >> """Convert entity like { to unichr. >> >> Return (result,True) on success or (input string, False) >> otherwise. Example: >> entity2cp('€') -> (u'\u20ac',True) >> entity2cp('€') -> (u'\u20ac',True) >> entity2cp('€') -> (u'\u20ac',True) >> entity2cp('&foobar;') -> ('&foobar;',False) >> """ > >Is there a reason why you return a tuple instead of just returning the >converted result and raising an exception if the conversion fails? Mainly a matter of style. When I'll be using the function in future this way it's unambigously clear that there might have been unconverted entities. But I don't have to deal with the details of how this has been discovered. And may be I'd like to change the algorithm in future? This way it's nicely encapsulated. Have a nice day Martin From manisharoy20 at gmail.com Tue Apr 15 04:59:43 2008 From: manisharoy20 at gmail.com (......ADMISSION IN TOP 10 IIT's and ENGINNERING COLLEGE.......) Date: Tue, 15 Apr 2008 01:59:43 -0700 (PDT) Subject: Req. Designation - Jr. Software Engineer(QA) Message-ID: <6e48117f-4f82-49fc-a82e-5798231c99c2@d26g2000prg.googlegroups.com> Req. Designation - Jr. Software Engineer(QA) Company - Allindia Technologies Limited. Criteria - Any Degree SALARY - 2.5 to 3.5 lakhs PA. How to apply -: 1] Click the below link and first complete your profile with your school and college. http://www.batchmates.com/MGMhome.asp?refid=1970195&reflink=22635 2] After completing your all details,check your email and confirm your registration. 3] Finally,go to careers and apply for the above mentioned post(After completing your profile,you must check your email and confirm your registration before applying for the given job). Visit and join http://www.batchmates.com/MGMhome.asp?refid=1970195&reflink=22635 Pls Note:- After registering with your school/college,please check your email immediately. Check the confirmation key or confirmation link. Then only apply for the job,otherwise your application will be rejected. From nick at craig-wood.com Tue Apr 22 08:30:02 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Tue, 22 Apr 2008 07:30:02 -0500 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? References: Message-ID: Harishankar wrote: > Sorry to start off on a negative note in the list, but I feel that the Python > subprocess module is sorely deficient because it lacks a mechanism to: > > 1. Create non-blocking pipes which can be read in a separate thread (I am > currently writing a mencoder GUI in Tkinter and need a full fledged process > handler to control the command line and to display the progress in a > text-box) > > 2. Kill the subprocess in a platform independent manner (i.e. no third party > modules and no hacks). You are correct on both of those points. Subprocess isn't for interacting with subprocesses - this should be written in large letters in the help! > Is there any way to use non-blocking Popen objects using > subprocess? There is a recipe in the cookbook http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554 Which I've used and it works. you can also (if on unix) use http://www.noah.org/wiki/Pexpect I think the best solution would be to port Pexpect to windows which wouldn't be that difficult according to my reading of the code. If only I had more free time! > and 2 - is there a way to kill the subprocess in a platform > independent manner in a purely Pythonic way? I thought initially > that this problem is simple enough, but over the last couple of > days I've been really struggling to find any answer. I've been > through dozens of mailing list archives in to find a > solution. Unfortunately none of the solutions seem to fit my needs. No... This is the best I came up with to add to the subprocess recipe above import os from subprocess import * from subprocess import mswindows from time import sleep if mswindows: import win32api else: import signal class PopenNB(Popen): # - see cookbook recipe for rest of stuff # ... def kill(self, killpg=False): """ Kill the running process """ pid = self.pid if mswindows: # Kill the process using win32api and pid - ignore errors try: PROCESS_TERMINATE = 1 handle = win32api.OpenProcess(PROCESS_TERMINATE, False, pid) win32api.TerminateProcess(handle, -1) win32api.CloseHandle(handle) except pywintypes.error: pass else: # Kill the process by sending the pid / process group a signal if killpg: try: pgid = os.getpgid(pid) except OSError: killpg = False try: if killpg: os.killpg(pgid, signal.SIGTERM) else: os.kill(pid, signal.SIGTERM) except OSError: return sleep(1.0) try: if killpg: os.killpg(pgid, signal.SIGKILL) else: os.kill(pid, signal.SIGKILL) except OSError: return -- Nick Craig-Wood -- http://www.craig-wood.com/nick From donnyf at gmail.com Tue Apr 29 08:52:41 2008 From: donnyf at gmail.com (donnyf at gmail.com) Date: Tue, 29 Apr 2008 05:52:41 -0700 (PDT) Subject: Using Python to verify streaming tv/radio station links Message-ID: Hi guys. I've put together a website ( http://worldwidemediaproject.com ) that is a database of internet streaming tv/radio stations from around the world. I have built the site with all users in mind. The site should be Linux, Unix, Mac, Win, etc friendly as I do not hide the actual stream link or force the user to use an embedded player to view/listen to the streams. In fact, you can even download the streams you like as a playlist that you can load into your player of choice (and even a few PVR software plugins). In building the site, I have enabled the user to report stations that are nonfunctional. In addition to this, I would like to automate the checking of the links in the database as well as any user submitted links. What I am wanting to do is to script this with a simple for loop which would loop through a file containing the station stream link as well as the station id. I'd like to pass each through some kind of verification function and if a connection is made then the stream is good and move on to the next. If the connection fails then the stream is bad, I would like to add the station id to a file containing all 'nonfunctional' streams that I can later automate to flag the stations. Is there an easy way to use python to verify a stream exists? I've done a little experimenting with sockets and was able to connect to my usenet server and talk to it, but I don't really know what's involved with connecting to streaming windows media, real media and winamp servers or what to expect as far as connection status messages. I am not unfamiliar with python, but I am far from an expert. If anyone could give me a hand with this or give me a push in the right direction I would greatly appreciate it! Many thanks! From george.sakkis at gmail.com Mon Apr 28 16:16:08 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Mon, 28 Apr 2008 13:16:08 -0700 (PDT) Subject: How to unget a line when reading from a file/stream iterator/generator? References: Message-ID: On Apr 28, 2:07?pm, pyt... at bdurham.com wrote: > Is there an elegant way to unget a line when reading from a file/stream > iterator/generator? > > By "unget" I mean a way to push back a line into the source stream and > backtrack the iterator/generator one step? > > The only alternative I can see is to put my line reading in a while-True > loop (vs. a for-loop) that manually calls my file/stream > iterator/generator's .next() method while manually handling the > StopIteration exception. Doesn't sound too elegant. > > Is there a Pythonic design pattern/best practice that I can apply here? > > Thank you, > Malcolm http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502304 HTH, George From wizzardx at gmail.com Tue Apr 15 17:16:01 2008 From: wizzardx at gmail.com (David) Date: Tue, 15 Apr 2008 23:16:01 +0200 Subject: Getting subprocess.call() output into a string? In-Reply-To: References: Message-ID: <18c1e6480804151416j7dd49d78p8888132ca01a5237@mail.gmail.com> > > Still, about StringIO... > The module description says you can use it to read and write strings as files, not that you can use strings *everywhere* you can use files. In your specific case, StringIO doesn't work, because the stdout redirection takes place at the operating system level (which uses real file handles), rather than in a python library (for which StringIO would probably work). David. From pylists at arcor.de Sat Apr 12 12:31:32 2008 From: pylists at arcor.de (Penny Y.) Date: Sun, 13 Apr 2008 00:31:32 +0800 Subject: mod_python Message-ID: <4800E3E4.3080508@arcor.de> Hello, I want to rewrite a request url under apache2.0 based on its special header, like, the "Accept-Encoding:" one. With C I think I can do it, but since I get begin with python,so I ask that can I do it under mod_python? what's the guide? Thanks. From hv at tbz-pariv.de Fri Apr 4 08:13:46 2008 From: hv at tbz-pariv.de (Thomas Guettler) Date: Fri, 04 Apr 2008 14:13:46 +0200 Subject: wsdl (soap) without code generation In-Reply-To: <65hi7dF2ade57U1@mid.individual.net> References: <65hi7dF2ade57U1@mid.individual.net> Message-ID: <65mkbqF2gtptsU1@mid.individual.net> ... Thank you for your answers. I tried to parse the wsdl with two libraries. (axis2 (java) and SOAPPy). Both fail because there is no entry for 'service'. The wsdl is from SAP XI. Has someone hints? Thomas -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de From steve at holdenweb.com Fri Apr 11 09:55:18 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 11 Apr 2008 09:55:18 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> <47FCF421.6000807@holdenweb.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> Message-ID: Victor Subervi wrote: > Nope. Do not see it. My ugly stupid way works. I guess I will just > proceed with that and write my howto accordingly. > Victor > OK, but be prepared for some pretty scathing feedback. You will make it clear you do not understand the web. I'd suggest a little more reading first. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From fr5478bey at gmail.com Sat Apr 26 11:38:31 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:38:31 -0700 (PDT) Subject: Treasures Of Montezuma crack Message-ID: Treasures Of Montezuma crack http://cracks.00bp.com F R E E C R A C K S From kamhung.soh at gmail.com Wed Apr 30 03:01:37 2008 From: kamhung.soh at gmail.com (Kam-Hung Soh) Date: Wed, 30 Apr 2008 17:01:37 +1000 Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> Message-ID: On Wed, 30 Apr 2008 16:13:17 +1000, SL wrote: > How can I compute with the integer values of characters in python? > Like 'a' + 1 equals 'b' etc Try: ord('a') See also: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65117 -- Kam-Hung Soh Software Salariman From gagsl-py2 at yahoo.com.ar Wed Apr 16 18:49:27 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 19:49:27 -0300 Subject: def power, problem when raising power to decimals References: <48067bdb@news.mel.dft.com.au> Message-ID: En Wed, 16 Apr 2008 19:21:18 -0300, John Machin escribi?: > skanemupp at yahoo.se wrote: >> also i found a link which states 0^0 isnt 1 even though every >> calculator ive tried says it is. >> it doesnt say what it is but i presume 0 then. >> but it seems the dude is wrong and it is 1? > > Of the possible results of 0 ** 0 (i.e. 1, 0, and NaN), 1 seems to be > the least implausible. It allows X ** 0 to be 1 for all X. But a result of 0 would allow 0 ** X to be 0 for all X. (btw, this is the reason lim(x**x) for x->0 does not exist) -- Gabriel Genellina From paulgeeleher at gmail.com Mon Apr 21 13:08:10 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Mon, 21 Apr 2008 10:08:10 -0700 (PDT) Subject: Problem setting cookie in Internet Explorer References: <10655938-e458-4866-a56b-9a989054f055@w4g2000prd.googlegroups.com> Message-ID: <54bddf5e-cea7-4177-b9da-bf068ce6041e@l28g2000prd.googlegroups.com> On Apr 21, 4:24 pm, Mike Driscoll wrote: > On Apr 21, 10:13 am, sophie_newbie wrote: > > > > > Hi, > > > I'm using the python to set a cookie when a user logs in. Thing is it > > doesn't seem to be setting properly in Internet Explorer. It works > > grand in Firefox. Its basically: > > > c = Cookie.SimpleCookie() > > > c['username'] = uname > > > c['password'] = pword > > > print c > > > print pageContent > > > And thats it. I've a suspicion that it could be something to do with > > the expiry time of the cookie. But I'm really not sure and don't > > really know where to go with it. I've tried it on Internet Explorer on > > 2 machines and get the same problem. > > > Thanks for any help... > > Did you make sure cookies are enabled in Internet Explorer? > > You might also take a look at these pages: > > http://www.voidspace.org.uk/python/articles/cookielib.shtmlhttp://www.voidspace.org.uk/python/recipebook.shtml#cookielib > > They seem quite informative. > > Mike Ya cookies are def enabled, will check that out thanks! From kyosohma at gmail.com Mon Apr 21 11:24:29 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Mon, 21 Apr 2008 08:24:29 -0700 (PDT) Subject: Problem setting cookie in Internet Explorer References: Message-ID: <10655938-e458-4866-a56b-9a989054f055@w4g2000prd.googlegroups.com> On Apr 21, 10:13 am, sophie_newbie wrote: > Hi, > > I'm using the python to set a cookie when a user logs in. Thing is it > doesn't seem to be setting properly in Internet Explorer. It works > grand in Firefox. Its basically: > > c = Cookie.SimpleCookie() > > c['username'] = uname > > c['password'] = pword > > print c > > print pageContent > > And thats it. I've a suspicion that it could be something to do with > the expiry time of the cookie. But I'm really not sure and don't > really know where to go with it. I've tried it on Internet Explorer on > 2 machines and get the same problem. > > Thanks for any help... Did you make sure cookies are enabled in Internet Explorer? You might also take a look at these pages: http://www.voidspace.org.uk/python/articles/cookielib.shtml http://www.voidspace.org.uk/python/recipebook.shtml#cookielib They seem quite informative. Mike From victorsubervi at gmail.com Fri Apr 18 11:13:32 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Fri, 18 Apr 2008 10:13:32 -0500 Subject: Another MySQL Images Question Message-ID: <4dc0cfea0804180813o32ed2c82o9c3f68b1a607348d@mail.gmail.com> Hi; If I grab an image in the database thus: sql = "select pic1 from products where id='" + str(id) + "';" cursor.execute(sql) pic1 = cursor.fetchall()[0][0].tostring() # pic1 = cursor.fetchall()[0][0] // either this or the above line and try and re-insert it thus: cursor.execute('update products set pic1="%s" where id="%s", ;', (pic1, id)) it tells me I have an error in my MySQL syntax. What is the error? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan_ml at behnel.de Mon Apr 7 02:12:43 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 07 Apr 2008 08:12:43 +0200 Subject: How to get an XML DOM while offline? In-Reply-To: References: Message-ID: <47F9BB5B.30604@behnel.de> william tanksley wrote: > I want to parse my iTunes Library xml. All was well, until I unplugged > and left for the train (where I get most of my personal projects > done). All of a sudden, I discovered that apparently the presence of a > DOCTYPE in the iTunes XML makes xml.dom.minidom insist on accessing > the Internet... So suddenly I was unable to do any work. > > I don't want to modify the iTunes XML; iTunes rewrites it too often. > How can I prevent xml.dom.minidom from dying when it can't access the > Internet? > > Is there a simpler way to read the iTunes XML? (It's merely a plist, > so the format is much simpler than general XML.) Try lxml. Since version 2.0, its parsers will not access the network unless you tell it to do so. http://codespeak.net/lxml It's also much easier to use than minidom and much faster: http://blog.ianbicking.org/2008/03/30/python-html-parser-performance/ Stefan From steve at holdenweb.com Mon Apr 14 19:38:42 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 14 Apr 2008 19:38:42 -0400 Subject: py2exe, program has stoped working!? In-Reply-To: <67526f9f-a610-4cbe-8e2c-6219a59a4d54@i36g2000prf.googlegroups.com> References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> <232151d6-09ed-4a1e-9922-d66c2bf0d05b@w8g2000prd.googlegroups.com> <67526f9f-a610-4cbe-8e2c-6219a59a4d54@i36g2000prf.googlegroups.com> Message-ID: John Machin wrote: > On Apr 15, 4:08 am, Steve Holden wrote: >> John Machin wrote: >> >>> By the way, "popup" is what you get in a web browser. What did this >>> "popup" look like: a panel from your GUI software? A Windows message >>> box? Did it have a title across the top? What was the exact text in >>> the popup/panel/box? Were there any options other than to close the >>> window? >> >> FYI "xxx has stopped working" is Vista's "user-friendly" way of >> reporting what Windows 3 would probably have called a "General Program >> Fault". > > So I found by googling "has stopped working". I'd never seen such a > litany of weeping, wailing and u'\u02ad' before. > >> It pretty much hides all useful information fro the end-user, >> perhaps on the grounds that end users wouldn't know what to do with the >> information it *could* provide anyway. > > Thanks for the info, Steve. Sounds like it's even worse than its > predecessor in Windows XP. You could say "it sucks" and not be a million miles away. Particularly since Windows Explorer is itself one of the programs that quite frequently "stops working". regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From mail at microcorp.co.za Wed Apr 2 04:41:39 2008 From: mail at microcorp.co.za (Hendrik van Rooyen) Date: Wed, 2 Apr 2008 10:41:39 +0200 Subject: Why prefer != over <> for Python 3.0? Message-ID: <001e01c8949d$7bd6a520$03000080@hendrik> John J. Lee wrote: >How did programmers manage back then in 32k? Some of the answers, in no particular sequence, are: Tight, small operating systems that did the minimum. Assembler. Sequential Processing: - small tasks with multiple passes on tape ( like the concept of Unix pipes ) Overlays. Character based menu systems. No OO. Code structured to the point of incomprehensibility: - if ten or so instructions looked similar, you forced calls instead of inlining. Procedural languages, close to the metal. Small, fixed length, fixed type character based data structures. Some of the other veterans may want to add to this list. - Hendrik From ramesh at winfoware.com Mon Apr 21 06:43:35 2008 From: ramesh at winfoware.com (Ramesh Nathan) Date: Mon, 21 Apr 2008 16:13:35 +0530 Subject: Required Python Consultants Message-ID: <073a01c8a39c$8dc1e7a0$a945b6e0$@com> Hi, I am looking for Python consultants to work with us for couple of months. The location is Bangalore, India. Anybody interested, please contact me. With warm regards, Ramesh Nathan, Head - Business Relations, Winfoware Technologies Ltd, Mobile - 0 93425 54560. Email ? HYPERLINK "mailto:ramesh at winfoware.com"ramesh at winfoware.com Land Line - +91 080 23224418 / 23224420 HYPERLINK "http://www.winfoware.com"www.winfoware.com No virus found in this outgoing message. Checked by AVG. Version: 7.5.524 / Virus Database: 269.23.2/1388 - Release Date: 20-04-2008 15:01 -------------- next part -------------- An HTML attachment was scrubbed... URL: From bignose+hates-spam at benfinney.id.au Mon Apr 7 10:36:37 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Tue, 08 Apr 2008 00:36:37 +1000 Subject: Adherence to PEP 8 for published code References: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> <87d4p2mcrp.fsf_-_@benfinney.id.au> Message-ID: <871w5h20lm.fsf@benfinney.id.au> Aldo Cortesi writes: > This is getting silly. Agreed. > Let's recap. You are upset Not at all. -- \ "We spend the first twelve months of our children's lives | `\ teaching them to walk and talk and the next twelve years | _o__) telling them to sit down and shut up." -- Phyllis Diller | Ben Finney From wesbrooks at gmail.com Tue Apr 22 08:03:02 2008 From: wesbrooks at gmail.com (Wesley Brooks) Date: Tue, 22 Apr 2008 13:03:02 +0100 Subject: Python Success stories In-Reply-To: <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> Message-ID: http://panela.blog-city.com/python_at_google_greg_stein__sdforum.htm Google big enough? ...or look at the companies on the "NASA uses Python... ...so does:" box on the top (nearly top any how!) right of http://www.python.org/ On 22/04/2008, azrael wrote: > Which big aplications are written in python. I see its development, > But i can't come up with a big name. I know that there are a lot of > companys using python, but is there anythong big written only in > python. I want him to fuck of with his perl once and for all time > > -- > http://mail.python.org/mailman/listinfo/python-list > From DrColombes at yahoo.com Thu Apr 3 18:40:02 2008 From: DrColombes at yahoo.com (Dr. Colombes) Date: Thu, 3 Apr 2008 15:40:02 -0700 (PDT) Subject: Easy-to-install-and-use scientific graphics (plotting) package for Python 2.5.1 on Linux Ubuntu 7.1 Message-ID: <771b5531-5681-499f-9fda-77749b5db09f@s37g2000prg.googlegroups.com> Is there an easy scientific graphics (plotting) package for Python 2.5.1 running on Ubuntu Linux 7.1 ("Gutsy Gibbon")? A few years ago I used PyLab (a MatLab-like plotting module for Python) on a Windows machine, but I don't know if there is a similar easy-to-install-and-use Python 2.5.1-compatible graphics package for Ubuntu Linux 7.1? Thanks for any suggestions. From kosh at aesaeion.com Tue Apr 29 11:37:28 2008 From: kosh at aesaeion.com (William Heymann) Date: Tue, 29 Apr 2008 09:37:28 -0600 Subject: Zope/DTML Infuriating... In-Reply-To: References: Message-ID: <200804290937.28491.kosh@aesaeion.com> On Tuesday 29 April 2008, Jens wrote: > Hello Everyone. > > >

    > >
  • >
    >
> > I think you are going to really regret doing things this way, it is only going to make your life much harder regardless of if you are using zpt or dtml by doing stuff like this inside the template. The most correct way in zope to do this is to use a python script object and have the dtml call that. For example your python script would have return ['main%s' % i for i in range(1,10)] and your dtml would have
This leads to much cleaner and easier to maintain systems. From http Tue Apr 15 12:55:41 2008 From: http (Paul Rubin) Date: 15 Apr 2008 09:55:41 -0700 Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <0853b778-c20b-44bb-ac9b-a5803a1aecc5@e67g2000hsa.googlegroups.com> <53ede0ca-ad36-4b11-b693-ea500d7b6e43@e67g2000hsa.googlegroups.com> <207ca229-3309-41e4-9369-ccde5de908a1@l64g2000hse.googlegroups.com> Message-ID: <7xtzi312ia.fsf@ruckus.brouhaha.com> Aaron Watters writes: > Even with Btree's if you jump around in the tree the performance can > be awful. The Linux file cache really helps. The simplest approach is to just "cat" the index files to /dev/null a few times an hour. Slightly faster (what I do with Solr) is mmap the files into memory and read a byte from each page now and then. Assuming (as in Lucene) that the index file format is compressed, this approach is far more ram-efficient than actually unpacking the index into data structures. though of course you take the overhead (a few microseconds) of a couple system calls at each access to the index even when it's all in cache. From sturlamolden at yahoo.no Wed Apr 23 21:08:46 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Wed, 23 Apr 2008 18:08:46 -0700 (PDT) Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. References: Message-ID: <6f45892f-c518-4924-bb92-8ce79368c1ab@t63g2000hsf.googlegroups.com> On Apr 22, 8:36 pm, Kenneth McDonald wrote: > Sadly. I can easily access: http://www.crummy.com/software/BeautifulSoup/ From usenet at solar-empire.de Thu Apr 3 07:17:57 2008 From: usenet at solar-empire.de (Marc Christiansen) Date: Thu, 3 Apr 2008 13:17:57 +0200 Subject: Get all strings matching given RegExp References: Message-ID: <50rec5-4d6.ln1@pluto.solar-empire.de> Alex9968 wrote: > Can I get sequence of all strings that can match a given regular > expression? For example, for expression '(a|b)|(x|y)' it would be ['ax', > 'ay', 'bx', 'by'] > > It would be useful for example to pass these strings to a search engine > not supporting RegExp (therefore adding such support to it). A program > can also let user specify sequence of strings using RegExp (filenames to > process, etc.). If there are other types of expressions for these > purposes, please let me know. > > I know that for some expressions there would be infinite amount of > matching strings, but these aren't the cases I'm considering. It'd still > be possible if string length is limited (there might be large but finite > number of matching strings). This will give you all (byte-)strings upto a given length which match a given regular expression. But beware, it can be slow ;) import re all_chars = [chr(i) for i in xrange(256)] def gen_strings(length, alphabet=all_chars): if length == 1: for c in alphabet: yield c else: for i in alphabet: yield c for s in gen_strings(length - 1, alphabet): yield c + s def regex_matches(regex, max_length, alphabet=all_chars): r = re.compile('(' + regex + r')\Z') return (s for s in gen_strings(max_length, alphabet) if r.match(s)) Marc From rhamph at gmail.com Sat Apr 12 11:56:58 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Sat, 12 Apr 2008 08:56:58 -0700 (PDT) Subject: Multiple independent Python interpreters in a C/C++ program? References: Message-ID: <9f97ea5b-f6c1-4d75-8f20-956c48b855af@i36g2000prf.googlegroups.com> On Apr 11, 10:24 am, s... at pobox.com wrote: > This question was posed to me today. Given a C/C++ program we can clearly > embed a Python interpreter in it. Is it possible to fire up multiple > interpreters in multiple threads? For example: > > C++ main > thread 1 > Py_Initialize() > thread 2 > Py_Initialize() > > Do I wind up with two completely independent interpreters, one per thread? > I'm thinking this doesn't work (there are bits which aren't thread-safe and > are only protected by the GIL), but wanted to double-check to be sure. Since they interpreters would never truly be separate, I think it's best to bite the bullet and use multiple threads within one interpreter. The only really difference is pure python modules aren't duplicated, but why would you need that? Surely not for any kind of security. From pavlovevidence at gmail.com Tue Apr 22 12:26:47 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 22 Apr 2008 09:26:47 -0700 (PDT) Subject: Remove multiple inheritance in Python 3000 References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <6760jfF2n3bn1U1@mid.uni-berlin.de> <676desF2nrgitU1@mid.uni-berlin.de> Message-ID: <6728a814-32df-41cd-8f6e-c86750d9f91f@p25g2000hsf.googlegroups.com> On Apr 22, 11:10 am, "Diez B. Roggisch" wrote: > > 2. Java interfaces solve a different problem than MI (used properly) > > does: interfaces are there to make types polymorphic, whereas > > inheritance's main use is to share behavior. > > But the *goal* of the polymorphy is mainly to have shared behavior. Not at all. The goal of polymorphism is to have objects of different types usable in the same situation. Two such classes might share some behavior, but they don't have to. Carl Banks From tjreedy at udel.edu Mon Apr 7 13:59:08 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 7 Apr 2008 13:59:08 -0400 Subject: Welcome to the "Python-list" mailing list References: Message-ID: "Ronn Ross" wrote in message news:d1c466d40804070747x34588c19id6f9050bf3cf5411 at mail.gmail.com... | This is my first post and I'm new to Python. How would someone go about | adding keywords to Python? It would be great to add support for Esperanto | keywords in the language instead of English being the only option. If you want other-language keywords, you should either use a translator processor or an editor that will do keyword substitution. I do not know of such but I would not be surprised if there is one. I suspect this sort of thing will more likely happen with Python 3, which will allow unicode keywords. PS. Subject lines should reflect the subject of the post. From darcy at druid.net Fri Apr 25 14:50:57 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Fri, 25 Apr 2008 14:50:57 -0400 Subject: Why is None <= 0 In-Reply-To: References: Message-ID: <20080425145057.12b9a1e7.darcy@druid.net> On Fri, 25 Apr 2008 20:27:15 +0200 Gregor Horvath wrote: > >>> None <= 0 > True > > Why? Why not? > Is there a logical reason? Everything in Python can compare to everything else. It is up to the programmer to make sure that they are comparing reasonable things. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From colas.francis at gmail.com Mon Apr 14 11:48:26 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Mon, 14 Apr 2008 08:48:26 -0700 (PDT) Subject: eval modifies passed dict References: <2b2398b1-042e-46bb-b840-ea9e07d87bd1@2g2000hsn.googlegroups.com> Message-ID: <511feb86-3915-46da-9bd8-d02de87eb2de@b1g2000hsg.googlegroups.com> On 14 avr, 17:23, Janto Dreijer wrote: > It seems eval is modifying the passed in locals/globals. This is > behaviour I did not expect and is really messing up my web.py app. > > Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information.>>> d = dict(a=1) > >>> d.keys() > ['a'] > >>> eval("a", d) > 1 > >>> d.keys() > > ['a', '__builtins__'] > > That can't be right. >From the documentation of eval[1] "If the globals dictionary is present and lacks '__builtins__', the current globals are copied into globals before expression is parsed." [1]http://docs.python.org/lib/built-in-funcs.html From robert.kern at gmail.com Fri Apr 11 13:55:28 2008 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 11 Apr 2008 12:55:28 -0500 Subject: Rounding a number to nearest even In-Reply-To: <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> Message-ID: cokofreedom at gmail.com wrote: > Strange request though, why do you need it that way, because 2.5 is > CLOSER to 3 than to 2... Uhhh, no it isn't. (3 - 2.5) == (2.5 - 2) -- 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 From jyoung79 at kc.rr.com Wed Apr 16 10:00:20 2008 From: jyoung79 at kc.rr.com (jyoung79 at kc.rr.com) Date: Wed, 16 Apr 2008 9:00:20 -0500 Subject: Get oldest folder Message-ID: <30689728.337521208354420713.JavaMail.root@hrndva-web15-z02> Hi Tim, Thanks very much for your help! I'm still just learning Python and really appreciate seeing other peoples examples on how they work with Python. Thanks again for taking the time to share this. Jay >> I'd like to be able to get the path to the oldest folder in whatever directory >> I'm currently in. Is there a simple way to go about this? >> I'd like it to run on both OS X and Windows XP. >> I found this example but was curious if there's a better way to do this? >Better: I don't know. Alternative, certainly: > >import os, glob >PATH = "c:/python25/lib/site-packages" >print min ((f for f in glob.glob (os.path.join (PATH, "*")) if os.path.isdir (f)), key=os.path.getctime) > >TJG From bronger at physik.rwth-aachen.de Tue Apr 1 03:36:32 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Tue, 01 Apr 2008 09:36:32 +0200 Subject: Why prefer != over <> for Python 3.0? References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> <659gb2F2f84eoU2@mid.individual.net> <87hceo73ap.fsf@physik.rwth-aachen.de> <65anbqF2fg18bU1@mid.individual.net> <87r6drjss4.fsf@physik.rwth-aachen.de> <65c0bfF2ffipiU1@mid.individual.net> Message-ID: <878wzyyqkf.fsf@physik.rwth-aachen.de> Hall?chen! Jorge Vargas writes: > On Tue, Apr 1, 2008 at 6:03 AM, Gabriel Genellina > wrote: > >> [...] >> >> I think it should be easy to add support for ??? and even ?, >> only the tokenizer has to be changed. >> > show me a keyboard that has those symbols and I'm all up for it. For <= I have to press three buttons, for ? I have to press four buttons. Not much of a difference. ;-) However, I'm slightly disappointed with the UTF-8 support in some mail clients involved in this thread, so Unicode surely has not arrived yet. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From gagsl-py2 at yahoo.com.ar Wed Apr 9 02:26:29 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 03:26:29 -0300 Subject: Cannot understand the detailedly the following code References: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> Message-ID: En Tue, 08 Apr 2008 09:45:35 -0300, A.T.Hofkamp escribi?: > On 2008-04-08, reachmsn at hotmail.com wrote: > > [deleted a long piece of text by our BDFL about recursive graph > path-finding algorithm] > >> after first writing the inductive part ... for node in >> graph[start] .... >> and then by trial and error put square brackets around path in the >> Basis part. Can someone please explain how to write this code. Thanks! > > The same as any other function. > (the trick with recursive functions is not to think about recursion. > Instead, > pretend you are calling another function that happens to have the same > name.) But our BDFL played some tricks to make both functions look more similar than they would instead. Take the "single path" variant: def find_path(graph, start, end, path=[]): path = path + [start] if start == end: return path if not graph.has_key(start): return None for node in graph[start]: if node not in path: newpath = find_path(graph, node, end, path) if newpath: return newpath return None Why are those "return None" there, if not to be replaced by "return []"? Nobody writes that final one at least. Anyway, using the current Python version, it's easier to mutate the above function into a generator of all posible solutions; I hope the OP finds the mutation easier to follow: def find_all_paths(graph, start, end, path=[]): path = path + [start] if start == end: yield path return if start not in graph: return for node in graph[start]: if node not in path: for newpath in find_all_paths(graph, node, end, path): yield newpath The last two lines might be replaced in Python 3 by: yield *find_all_paths if this patch is accepted: http://bugs.python.org/issue2292 -- Gabriel Genellina From sturlamolden at yahoo.no Fri Apr 18 21:29:42 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 18 Apr 2008 18:29:42 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <48074f58$0$4916$e4fe514c@dreader32.news.xs4all.nl> <6002cb46-f48a-421d-a4ff-5b23bf2f9d77@2g2000hsn.googlegroups.com> Message-ID: <39fd7905-4835-43bb-928b-82622ed628c1@m3g2000hsc.googlegroups.com> On 18 Apr, 21:28, "sjdevn... at yahoo.com" wrote: > Passing a NULL SectionHandle to NTCreateProcess/CreateProcessEx > results in a fork-style copy-on-write duplicate of the current process. I know about NtCreateProcess and ZwCreateProcess, but they just create an empty process - no context, no thread(s), no DLLs loaded, etc. There is even an example code of how to implement fork() with ZwCreateProcess in Nebbet's book on NT kernel internals, but apparently it doesn't work quite well. (Right now I cannot even make it compile, because WDK headers are fubar with invalid C; even Microsoft's own compiler does not accept them.) Searching with Google, I find several claims that there is a "CreateProcessEx", which can do a COW fork of a process in the Win32 subsystem. I cannot find it documented anywhere. It is also not exported by kernel32.dll. If you know how this function is defined and which DLL exports it, please post it. But I suspect it does not exist. From samslists at gmail.com Thu Apr 3 18:20:59 2008 From: samslists at gmail.com (samslists at gmail.com) Date: Thu, 3 Apr 2008 15:20:59 -0700 (PDT) Subject: Bug in shlex?? Message-ID: I'm trying to use shlex.split to simulate what would happen in the shell. The docs say that it should be as close as possible to the posix shell parsing rules. If you type the following into a posix compliant shell echo '\?foo' you get back: \?foo (I've tested this in dash, bash and zsh---all give the same results.) Now here's what happens in python: Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import shlex >>> shlex.split("'\?foo'") ['\\?foo'] >>> I think this is a bug? Or am I just misunderstanding? Here is the relevant section of the Posix specification on shell parsing: 2.2.2 Single-Quotes Enclosing characters in single-quotes ( '' ) shall preserve the literal value of each character within the single-quotes. A single- quote cannot occur within single-quotes. That's from http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_03 Thanks for any help! From steve at holdenweb.com Tue Apr 8 17:40:31 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 17:40:31 -0400 Subject: Best way to check if string is an integer? In-Reply-To: <5fa6c12e0804081332r2a58d39gc44ce1ef8cb69052@mail.gmail.com> References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> <0fdd2825-6d1c-4380-a79a-a7aac119f002@a5g2000prg.googlegroups.com> <96d2fe53-96bf-43d8-a58d-8269846bf0df@b64g2000hsa.googlegroups.com> <2033313.fb3g3XYCIP@montana.com> <5fa6c12e0804081332r2a58d39gc44ce1ef8cb69052@mail.gmail.com> Message-ID: Martin Marcher wrote: > hmmm > > int() does miss some stuff: > >>>> 1E+1 > 10.0 >>>> int("1E+1") > Traceback (most recent call last): > File "", line 1, in > ValueError: invalid literal for int() with base 10: '1E+1' > > I wonder how you parse this? > > I honestly thought until right now int() would understand that and > wanted to show that case as ease of use, I was wrong, so how do you > actually cast this type of input to an integer? > > thanks > martin > > int(float("1E+1")) # untested regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gagsl-py2 at yahoo.com.ar Mon Apr 7 22:47:42 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 07 Apr 2008 23:47:42 -0300 Subject: Translating keywords References: Message-ID: En Mon, 07 Apr 2008 14:59:08 -0300, Terry Reedy escribi?: > "Ronn Ross" wrote in message > news:d1c466d40804070747x34588c19id6f9050bf3cf5411 at mail.gmail.com... > | This is my first post and I'm new to Python. How would someone go about > | adding keywords to Python? It would be great to add support for > Esperanto > | keywords in the language instead of English being the only option. > > If you want other-language keywords, you should either use a translator > processor or an editor that will do keyword substitution. I do not know > of > such but I would not be surprised if there is one. I suspect this sort > of > thing will more likely happen with Python 3, which will allow unicode > keywords. Python 3 allows for unicode identifiers, but I don'k know any plans for using unicode keywords too. Looks funny: ? x ? values: if x ? forbidden ? x ? y: print(x, ?(x), ?(x)) print(?(values)) near = ? a,b,?=0.01: a-? ? b ? a+? for x in values: if x not in forbidden and x!=y: print(x, gamma(x), math.sqrt(x)) print(sum(values)) near = lambda a,b,eps=0.01: a-eps <= b <= a+eps -- Gabriel Genellina From hall.jeff at gmail.com Tue Apr 15 14:02:13 2008 From: hall.jeff at gmail.com (hall.jeff at gmail.com) Date: Tue, 15 Apr 2008 11:02:13 -0700 (PDT) Subject: Preferred method for "Assignment by value" References: <6a3ed8f0-b82c-4cd3-b36e-1d94f8a30fe3@n1g2000prb.googlegroups.com> Message-ID: <7047986d-f6cc-4189-81f6-47da1ecf1902@k1g2000prb.googlegroups.com> Thank you both, the assigning using slicing works perfectly (as I'm sure you knew it would)... It just didn't occur to me because it seemed a little nonintuitive... The specific application was def dicttolist (inputdict): finallist=[] for k, v in inputdict.iteritems(): temp = v temp.insert(0,k) finallist.append(temp) return finallist to convert a dictionary to a list. We deal with large amounts of bankdata which the dictionary is perfect for since loan number is a perfect key... at the end, though, I have to throw it into a csv file and the csv writer doesn't like dictionaries (since the key is an iterable string it iterates over each value in the key) by changing temp = v[:] the code worked perfectly (although changing temp.insert(0,k) to temp = [k] + temp also worked fine... I didn't like that as I knew it was a workaround) Thanks again for the help From steve at holdenweb.com Sat Apr 5 22:24:33 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 22:24:33 -0400 Subject: Tkinter, add pressed buttons onto string display string, how to? In-Reply-To: <195771d1-1bb3-4d62-b9c3-920db5a912ac@y21g2000hsf.googlegroups.com> References: <57605958-5589-4ebe-abdf-73c2d14c8a82@u10g2000prn.googlegroups.com> <65q8juF2gq610U2@mid.uni-berlin.de> <649d9748-c389-411d-9794-9753ddf434b0@d1g2000pra.googlegroups.com> <195771d1-1bb3-4d62-b9c3-920db5a912ac@y21g2000hsf.googlegroups.com> Message-ID: 7stud wrote: >>> Just like the message says: You are trying to use `str` (on the right hand >>> side of the assignment) before anything is bound to that name. >>> Ciao, >>> Marc 'BlackJack' Rintsch >> i know but i want the variable str(which i found out is a reserved >> word so i changed it) to be accessible all over __init__ right? >> > > "all over __init__" ? You could practice with a trivial example to > discover how things work in python: > > def f(): > num = 10 > print num > > f() > > def g(): > print num > num = 10 > > g() > > >> so i tried to delcare it in __init__ in the beginning of the framework >> class but then when i access it in the method Display i get that >> error. >> >> so how should i declare this variable to be able to access it >> everywhere? >> > > You don't declare variables in python. You just start using a > variable when you need it. In other words you don't do this: > > string my_str > my_str = "hello" > > You just write: > > my_str = "hello" > > >> i want another method "calculate" that can access the same string >> later and do the calculations(writing some other code now that will >> read and interpret that). > > Does this look familiar: > >> Another thing you should be aware of: self is like a class wide >> bulletin board. If you are writing code inside a class method, and >> there is data that you want code inside another class method to be >> able to see, then post the data on the class wide bulletin board, i.e. >> attach it to self. But in your code, you are doing this: >> >> self.btnDisplay = Button(self, text="7", default=ACTIVE) >> self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) >> >> self.btnDisplay = Button(self, text="8", default=ACTIVE) >> self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) >> >> As a result, your code continually overwrites self.btnDisplay. That >> means you aren't preserving the data assigned to self.btnDisplay. >> Therefore, the data does not need to be posted on the class wide >> bulletin board for other class methods to see. So just write: >> >> btnDisplay = Button(self, text="7", default=ACTIVE) >> btnDisplay.grid(row=5, column=0, padx=5, pady=5) >> >> btnDisplay = Button(self, text="8", default=ACTIVE) >> btnDisplay.grid(row=5, column=1, padx=5, pady=5) To pick nits, "str" is not a reserved word (normally referred to in Python as s "keyword"). It's perfectly possible to write: >>> def str(x): ... return "Fooled you!" ... >>> str(3.14148) 'Fooled you!' >>> and have your program work. But it's not generally good practice to *shadow* built-in names, even when nothing stops you from doing so, simply because there is usually a group somewhere with an investment in using the standard names, and you will make their lives more difficult. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From skanemupp at yahoo.se Wed Apr 23 23:43:02 2008 From: skanemupp at yahoo.se (globalrev) Date: Wed, 23 Apr 2008 20:43:02 -0700 (PDT) Subject: function that accepts any amount of arguments? Message-ID: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> if i want a function that can take any amount of arguments how do i do? lets say i want a function average that accepts any number of integers and returns the average. From gillet at scripps.edu Fri Apr 25 14:11:48 2008 From: gillet at scripps.edu (Alexandre Gillet) Date: Fri, 25 Apr 2008 11:11:48 -0700 Subject: Problem building python in virtual machine running centos In-Reply-To: <1209085558.20290.3.camel@solomon> References: <1209085558.20290.3.camel@solomon> Message-ID: <1209147108.1283.2.camel@solomon> Thanks for your answers. I did solve my problem. I upgraded my glibc libraries and it seems to solve the problem. I was able to build python-2.4.5 using gcc 4.1.2 (glibc-2.5-18.el5_1.1) Alex On Thu, 2008-04-24 at 18:05 -0700, Alexandre Gillet wrote: > Hi, > > I am trying to build python-2.4.5 on Centos 5.1, which is a virtual > machine running with xen. > I am not able to build python. The compilation crash with the following: > gcc -pthread -c -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. > -I./Include -DPy_BUILD_CORE -o Objects/unicodeobject.o > Objects/unicodeobject.c > In file included from ./Include/Python.h:76, > from Objects/unicodeobject.c:39: > ./Include/object.h:228: internal compiler error: Segmentation fault > Please submit a full bug report, > with preprocessed source if appropriate. > See for instructions. > The bug is not reproducible, so it is likely a hardware or OS problem. > > > Any suggestion of what am I doing wrong? > > Thanks > Alex > From kelle.lavoni at gmail.com Wed Apr 16 11:17:35 2008 From: kelle.lavoni at gmail.com (kelle.lavoni at gmail.com) Date: Wed, 16 Apr 2008 08:17:35 -0700 (PDT) Subject: who is kate hudson dating Message-ID: <08589ee0-590e-4568-b056-71c728f4bb0f@l42g2000hsc.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From gandalf at shopzeus.com Mon Apr 21 05:28:22 2008 From: gandalf at shopzeus.com (Laszlo Nagy) Date: Mon, 21 Apr 2008 05:28:22 -0400 Subject: PIL font encoding Message-ID: <480C5E36.7090505@shopzeus.com> def getfnt(size): return ImageFont.truetype("cartoon.ttf",size,encoding='unic') Using the above function, I cannot draw special german characters. E.g. u'L\xfctgendorf' It will print "Lutgendorf" instead of "L?tgendorf". Much more interesting is that I can also do this: def getfnt(size): return ImageFont.truetype("cartoon.ttf",size,encoding='put_somethin_here_it_has_no_effect WHAT?????? ') Same results. Shouldn't the truetype constructor raise an exception if the encoding is invalid and/or not available with the selected font? BTW my "cartoon.ttf" font is able to print "L?tgendorf". I have tested it from GIMP. So I'm 100% sure that the problem is with PIL. Thank you, Laszlo From ganeshborse at gmail.com Mon Apr 21 18:11:31 2008 From: ganeshborse at gmail.com (grbgooglefan) Date: Mon, 21 Apr 2008 15:11:31 -0700 (PDT) Subject: how to pass C++ object to another C++ function via Python function References: <1810b155-5598-4f17-a8e9-e4aa848db5de@i36g2000prf.googlegroups.com> Message-ID: On Apr 21, 10:17?pm, "Gabriel Genellina" wrote: > En Mon, 21 Apr 2008 10:24:15 -0300, grbgooglefan escribi?: > > > I am trying to pass a C++ object to Python function. This Python > > function then calls another C++ function which then uses this C++ > > object to call methods of that object's class. > > > I tried something like this, but it did not work, gave core dump. > > You can't pass any arbitrary C object to a Python function. > In this case you can use a PyCObject, a Python box around a void* pointer. > Seehttp://docs.python.org/api/cObjects.html Yup, I looked at http://www.python.org/doc/ext/using-cobjects.html also. I could not find in this example where is CObject used or converted back from Python to C. Is there any tutorial which I can use for this? From aaron.watters at gmail.com Mon Apr 14 16:27:42 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Mon, 14 Apr 2008 13:27:42 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> Message-ID: <0853b778-c20b-44bb-ac9b-a5803a1aecc5@e67g2000hsa.googlegroups.com> > A question often asked--and I am not a big a fan of these sorts of > questions, but it is worth thinking about--of people who are creating > very large data structures in Python is "Why are you doing that?" > That is, you should consider whether some kind of database solution > would be better. You mention lots of dicts--it sounds like some > balanced B-trees with disk loading on demand could be a good choice. Well, probably because you can get better than 100x improved performance if you don't involve the disk and use clever in memory indexing. BTW, I think the default behaviour of the gc is pretty silly. I tend to disable automatic gc and explicitly put in collections when I know I'm done with some big operation these days. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=dumb+slow From paul.anton.letnes at gmail.com Fri Apr 11 16:18:35 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Fri, 11 Apr 2008 22:18:35 +0200 Subject: Wrapping C++ class with SWIG, Mac OS X Message-ID: Hello guys, (related to previous thread on wrapping C/C++ in Python, trying the SWIG approach.) Trying to map a C++ class to python, one method for now. Running the following commands to "compile": -------------------------------------- #!/usr/bin/env bash MOD_NAME=Wavelet swig -c++ -python -o ${MOD_NAME}_wrap.cpp ${MOD_NAME}.i gcc -c++ -fPIC -c ${MOD_NAME}.cpp -o ${MOD_NAME}.o -I/usr/include/ python2.5 -I/usr/lib/python2.5 gcc -c++ -fPIC -c ${MOD_NAME}_wrap.cpp -o ${MOD_NAME}_wrap.o -I/usr/ include/python2.5 -I/usr/lib/python2.5 gcc -bundle -flat_namespace -undefined suppress -o _${MOD_NAME}.so $ {MOD_NAME}.o ${MOD_NAME}_wrap.o -------------------------------------- The source code is: -------------------------------------- Wavelet.h -------------------------------------- #ifndef _WAVELET_H_ #define _WAVELET_H_ #include #include using namespace std; class Wavelet { public: Wavelet(vector theV); ~Wavelet(); vector GetDaub4Trans(); private: vector v; }; #endif /*_WAVELET_H_*/ -------------------------------------- and Wavelet.cpp: -------------------------------------- #include "wavelet.h" Wavelet::Wavelet(vector theV) { this->v = theV; } Wavelet::~Wavelet() { // Nothing for now } vector Wavelet::GetDaub4Trans() { vector retV = vector(); retV.push_back(3.14); retV.push_back(2.71); retV.push_back(1.62); return retV; // just to test the approach - everything in here I can fix later. } -------------------------------------- This seems to compile, but in python I get: -------------------------------------- $ python imPython 2.5.2 (r252:60911, Mar 30 2008, 22:49:33) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import Wavelet Traceback (most recent call last): File "", line 1, in File "Wavelet.py", line 7, in import _Wavelet ImportError: dlopen(./_Wavelet.so, 2): Symbol not found: __ZNKSt11logic_error4whatEv Referenced from: /Users/paul/Desktop/Wavelet_SWIG_Cpp/_Wavelet.so Expected in: flat namespace >>> -------------------------------------- Any ideas or tips? SWIG seems very nice for simple C methods where you pass an int and return an int, but I can't seem to figure out the syntaxes etc for more complicated stuff - arrays, vector, C++, ... Appreciate any help! Cheers, Paul. From tkpmep at gmail.com Tue Apr 29 17:18:32 2008 From: tkpmep at gmail.com (Thomas Philips) Date: Tue, 29 Apr 2008 14:18:32 -0700 (PDT) Subject: MatplotLib errors Message-ID: I have just started using MatPlotLib, and use it to generate graphs from Python simulations. It often happens that the graph is generated and a Visual C++ Runtime Library error then pops up: Runtime Error! Program C:\Pythin25\Pythonw.exe This application has requested the Runtime to terminate in an unusual way. Please contact the application's support team for more information. I'm running Python 2.5.2 under Windows XP. Any thoughts on what what may be causing the problem? Thanks in advance Thomas Philips From hdante at gmail.com Sat Apr 26 21:02:25 2008 From: hdante at gmail.com (hdante) Date: Sat, 26 Apr 2008 18:02:25 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> Message-ID: <54dc008c-a747-4507-a2d5-9b4ddccbd5b9@e53g2000hsa.googlegroups.com> On Apr 26, 8:28?pm, n00m wrote: > No so simple, guys. > E.g., I can't solve (in Python) this:http://www.spoj.pl/problems/INTEST/ > Keep getting TLE (time limit exceeded). Any ideas? After all, it's > weekend. > > 450. Enormous Input Test > Problem code: INTEST > > The purpose of this problem is to verify whether the method you are > using to read input data is sufficiently fast to handle problems > branded with the enormous Input/Output warning. You are expected to be > able to process at least 2.5MB of input data per second at runtime. > > Input > The input begins with two positive integers n k (n, k<=107). The next > n lines of input contain one positive integer ti, not greater than > 109, each. > > Output > Write a single integer to output, denoting how many integers ti are > divisible by k. > > Example > Input: > 7 3 > 1 > 51 > 966369 > 7 > 9 > 999996 > 11 > > Output: > 4 Maybe the problem is not in reading the input. PS: you can throw a lot of time away in that site. :-) From rjh at see.sig.invalid Mon Apr 14 04:12:56 2008 From: rjh at see.sig.invalid (Richard Heathfield) Date: Mon, 14 Apr 2008 08:12:56 +0000 Subject: Game design : Making computer play References: Message-ID: <54KdnSk6WoWSjJ7VRVnyiQA@bt.com> [comp.programming added, and followups set to that group] v4vijayakumar said: > On Apr 14, 12:35 pm, Richard Heathfield wrote: >> v4vijayakumar said: >> > In computer based, two player, board games, how to make computer play? >> >> Write some code that works out what the computer player should do. If >> you want a better answer, ask a better question. > > I am just implementing a game played in my village (Tamilnadu / > India), called "aadupuli" (goats and tigers). There are only 23 > positions and 18 characters (15 goats and 3 tigers). Some of you might > be aware of this. > > I can post initial version of the game (implemented using html/ > javascript) in couple of hours here. > > Welcome any help in making computer to play one of these player. comp.programming would be a better group. I've found a picture of the board, but I can't find the rules anywhere, without which the task is impossible. Can you tell us what they are? If you reply, I suggest you do so in comp.programming. -- Richard Heathfield Email: -http://www. +rjh@ Google users: "Usenet is a strange place" - dmr 29 July 1999 From the.blue.valkyrie at gmail.com Sat Apr 19 14:31:20 2008 From: the.blue.valkyrie at gmail.com (=?ISO-8859-1?Q?Cristina_Yenyxe_Gonz=E1lez_Garc=EDa?=) Date: Sat, 19 Apr 2008 20:31:20 +0200 Subject: Issue with inspect module In-Reply-To: <2e5e2d31-2adc-4416-a993-19bc05a512bd@w8g2000prd.googlegroups.com> References: <2e5e2d31-2adc-4416-a993-19bc05a512bd@w8g2000prd.googlegroups.com> Message-ID: 2008/4/19, ilanschnell at gmail.com : > Hi, Hello, > I have this trivial program: > > import inspect > class A: > def __init__(self, a): > self.a = a > def __str__(self): > return 'A(%s)' % self.a > a = A(8) > print a > > the output is: > A(8) > A(8) > > Why does the inspect module cause the output > to be printed twice? > I have just run it on the CPython interpreter and it works well. Have you tried it without the 'import inspect' line and checked there is no problem? Or maybe are you using another interpreter? From marexposed at googlemail.com Thu Apr 17 14:41:49 2008 From: marexposed at googlemail.com (marexposed at googlemail.com) Date: Thu, 17 Apr 2008 19:41:49 +0100 Subject: MySQL hardcoding? Message-ID: <20080417194149.eddefdc8.marexposed@googlemail.com> I've got this error (see the path in last line) db=MySQLdb.connect(host='localhost',use_unicode = True, charset = "Windows-1251",user='root',passwd='12',db='articulos') File "C:\Python24\Lib\site-packages\MySQLdb\__init__.py", line 74, in Connect return Connection(*args, **kwargs) File "C:\Python24\lib\site-packages\MySQLdb\connections.py", line 198, in __init__ self.set_character_set(charset) File "C:\Python24\lib\site-packages\MySQLdb\connections.py", line 277, in set_character_set super(Connection, self).set_character_set(charset) OperationalError: (2019, "Can't initialize character set Windows-1251 (path: C:\\mysql\\\\share\\charsets\\)") The truth of the matter is, MySQL is not installed in that path, but into Program Files. I don't know where the hardcoding is, but it is certainly somewhere. Except MySQL is reporting a wrong installation path. I haven't found any other topic in the list about this problem. I'm using Python 2.4 and latest MySQLdb. Have anyone heard of this issue and how to fix it? Thanks a lot. From mobile at ibinsa.com Tue Apr 8 15:01:20 2008 From: mobile at ibinsa.com (Gabriel Ibanez) Date: Tue, 8 Apr 2008 21:01:20 +0200 Subject: Running a python code periodically References: Message-ID: <02f401c899aa$ef2b6df0$0a01a8c0@mobile> Hi, On Linux/Unix: $ man at You could create a bash script using this command. Keep in mind that the script must "schedule" itself again. There's other way: using the cron daemon (crond). Its programming depends on the used distro. I hope this helps. Regards .. ----- Original Message ----- From: Maryam Saeedi To: python-list at python.org Sent: Tuesday, April 08, 2008 7:53 PM Subject: Running a python code periodically Hi, I was wondering if you know how can I run a python code once every five minutes for a period of time either using python or some other program like a bash script. Thanks, Maryam ------------------------------------------------------------------------------ -- http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail.ilocke at gmail.com Tue Apr 29 17:27:32 2008 From: mail.ilocke at gmail.com (ivan) Date: Tue, 29 Apr 2008 14:27:32 -0700 (PDT) Subject: Tix.HList - Move Cursor Message-ID: Hello, How do I move the keyboard cursor position in a Tix.HList? I am using an HList with the right mouse button bound to pop up a menu. If the right click is done on an unselected item, I change the selection to that item. This works, however the keyboard cursor position remains at the last item selected with arrow keys or left click. How can I move this as well as the selection? def onrightclick(event): rightselected=hlist1.nearest(event.y) if hlist1.selection_includes(rightselected) <> "0": callpopup(rightselected) else: hlist1.selection_clear() hlist1.selection_set(rightselected) callpopup(rightselected) hlist1.bind("", onrightclick) Thanks, Ivan From ncoghlan at gmail.com Mon Apr 21 08:51:40 2008 From: ncoghlan at gmail.com (NickC) Date: Mon, 21 Apr 2008 05:51:40 -0700 (PDT) Subject: Finally had to plonk google gorups. References: Message-ID: <966256b2-fe7c-4ec5-900b-90b285311881@k10g2000prm.googlegroups.com> Hmm, according to this thread I probably shouldn't bother even trying to contribute to c.l.p discussions that are highlighted in the Python- URL announcements, even in cases where I think a core developer's perspective may be of interest. As someone that only posts here rarely, and uses Google Groups with a Gmail address to do so, it sounds like I'll be kill-filed by a lot of people regardless of the contents of what I post. *shrug* Ah well, such is life. Cheers, Nick. From http Fri Apr 11 04:20:12 2008 From: http (Paul Rubin) Date: 11 Apr 2008 01:20:12 -0700 Subject: How is GUI programming in Python? References: <7xod8h39zu.fsf@ruckus.brouhaha.com> Message-ID: <7xmyo0hkg3.fsf@ruckus.brouhaha.com> Phil Thompson writes: > > Installing Pyqt on windows involves a couple "click to install" EXEs. On > > Linux, one uses yum or apt. Only on Mac is it marginally a bit harder. > > Actually, on Windows it's only one .exe as the PyQt GPL binary installer > includes Qt and all it's tools (and the eric IDE, and PyQwt). Generally I prefer to minimize the number of installs, and especially minimize the number of binary installs. And my experience with yum and apt has generally been dependency hell, especially when installing from sources. But anyway, I consider zero installs to be far superior to any number greater than zero. From george.sakkis at gmail.com Mon Apr 21 19:16:46 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Mon, 21 Apr 2008 16:16:46 -0700 (PDT) Subject: Code question References: <60ffc058-488f-4e58-b3c9-a60c21595c6f@w8g2000prd.googlegroups.com> Message-ID: On Apr 21, 4:42?pm, Matimus wrote: > On Apr 21, 12:05 pm, wrote: > > > > > I've been trying to figure out a way to combine lists similar to how zip() works. ?The main > > difference though is I want to work with different length lists and combine them. ?I came up with > > the example below, which returns a list like I'm wanting. ?I'm assuming it's somewhat efficient > > (although I wonder if the lists were huge that the 'if' statement might slow things down?). > > > If anyone has time, I was wondering if you could share your thoughts on whether this is an > > efficient way to do something like this, if it's horrible and slow, etc. > > > Thanks! > > > Jay > > > # ---------------------------- > > > def combineLists(theLists): > > ? ? cntList = len(theLists) > > ? ? lenList = [len(x) for x in theLists] > > > ? ? maxList = max(lenList) > > > ? ? combinedList = [] > > > ? ? for x in range(maxList): > > ? ? ? ? for n in range(cntList): > > ? ? ? ? ? ? if lenList[n] > x: combinedList.append(theLists[n][x]) > > > ? ? print combinedList > > > combineLists([a, b, c]) > > > # ---------------------------- > > > # --> ['a', '1', 'a1', 'b', '2', 'b2', 'c', 'c3', 'd4', 'e5'] > > I would probably do something like this: > > >>> def combine(*seqs): > > ... ? ?seqs = [iter(s) for s in seqs] > ... ? ?while seqs: > ... ? ? ? for g in seqs: > ... ? ? ? ? ?try: > ... ? ? ? ? ? ? yield g.next() > ... ? ? ? ? ?except StopIteration: > ... ? ? ? ? ? ? seqs.remove(g) > ...>>> a = 'abc' > >>> b = '12' > >>> c = 'a1 b2 c3 d4 e5'.split() > >>> list(combine(a,b,c)) > > ['a', '1', 'a1', 'b', '2', 'b2', 'c', 'c3', 'd4', 'e5'] > > It has the advantage that it uses the generator protocol, so you can > pass in any type of sequence. It uses arbitrary arguments to make its > use closer to that of zip. It is also a generator, so it takes > advantage of lazy evaluation. Notice that there is never any checking > of length. > > Matt A similar solution using the itertools module: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/528936 George From carlwuhwdmckay at gmail.com Mon Apr 21 02:09:43 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:09:43 -0700 (PDT) Subject: dark crusade 1.11 patch Message-ID: dark crusade 1.11 patch http://cracks.00bp.com F R E E C R A C K S From kveretennicov at gmail.com Wed Apr 2 15:38:07 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Wed, 2 Apr 2008 22:38:07 +0300 Subject: non-terminating regex match In-Reply-To: References: <65i0i3F2embp3U2@mid.uni-berlin.de> Message-ID: <4660fe300804021238v6e2c526ax1fdf29012d5ecd1d@mail.gmail.com> On Wed, Apr 2, 2008 at 9:32 PM, Maurizio Vitale wrote: > Marc 'BlackJack' Rintsch writes: > > > On Wed, 02 Apr 2008 16:01:59 +0000, Maurizio Vitale wrote: > > > >> And yes, I'm a total beginner when it comes to Python, but it seems > >> very strange to me that a regex match on a finite length string > >> doesn't terminate > > > > It does terminate, you just don't wait long enough. Try it with fewer > > characters and then increase the identifier character by character and > > watch the time of the runs grow exponentially. > > > > Ok. Now, my assumption was that re.compile would produce a DFA (or NFA) > and the match would then being linear in the size of the string. > No, it's easy to come up with regex that would perform exponentially by nesting repeated groups. > Apparently this is not the case, so is there anything that can be done > to the regex itself to make sure that whatever re.compile produces is > more efficient? Avoid catastrophic backtracking: http://www.regular-expressions.info/catastrophic.html -- kv -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Mon Apr 7 09:14:58 2008 From: __peter__ at web.de (Peter Otten) Date: Mon, 07 Apr 2008 15:14:58 +0200 Subject: A file iteration question/problem References: <47f8eee1$0$759$bed64819@news.gradwell.net> <322f98fd-eb6e-4a05-a8c7-1e0c5329e955@w5g2000prd.googlegroups.com> <47fa1cf9$0$761$bed64819@news.gradwell.net> Message-ID: tinnews at isbd.co.uk wrote: > Arnaud Delobelle wrote: >> You could use an iterator over the lines of the file: >> >> def recfun(lines): >> for line in lines: >> # Do stuff >> if condition: >> recfun(lines) >> >> lines = iter(open(filename)) >> recfun(lines) > Does that work though? If you iterate through the file with the "for > line in lines:" in the first call of recfun(lines) you surely can't do > "for line in lines:" and get any sort of sensible result in recursive > calls of recfun(lines) can you? Don't speculate, try it. Peter From __peter__ at web.de Wed Apr 16 15:27:20 2008 From: __peter__ at web.de (Peter Otten) Date: Wed, 16 Apr 2008 21:27:20 +0200 Subject: Default parameter for a method References: <806788d2-67b7-456b-bd1e-08c50cbf0f7b@8g2000hsu.googlegroups.com> Message-ID: Cliff Wells wrote: > > On Wed, 2008-04-16 at 13:47 -0500, Larry Bates wrote: >> s0suk3 at gmail.com wrote: >> > I wanted to know if there's any way to create a method that takes a >> > default parameter, and that parameter's default value is the return >> > value of another method of the same class. For example: >> > >> > class A: >> > def __init__(self): >> > self.x = 1 >> > >> > def meth1(self): >> > return self.x >> > >> > def meth2(self, arg=meth1()): >> > # The default `arg' should would take the return value of >> > meth1() >> > print '"arg" is', arg >> > >> > This obviously doesn't work. I know I could do >> > >> > ... >> > def meth2(self, arg=None): >> > if arg is None: >> > arg = self.meth1() >> > >> > but I'm looking for a more straightforward way. >> >> You can write this as: >> >> def meth2(self, arg=None): >> arg = arg or self.meth1() >> >> IMHO - You can't get much more "straightforward" than that. > > What if arg is 0 an empty list or anything else that's "False"? > > def meth2(self, arg=None): > arg = (arg is not None) or self.meth1() > > is what you want. No, it's not: >>> for arg in None, 0, "yadda": ... print "---", arg, "---" ... if arg is None: arg = "call method" ... print "OP:", arg ... print "Larry:", arg or "call method" ... print "Cliff:", (arg is not None) or "call method" ... --- None --- OP: call method Larry: call method Cliff: True --- 0 --- OP: 0 Larry: call method Cliff: True --- yadda --- OP: yadda Larry: yadda Cliff: True Peter From brenNOSPAMbarn at NObrenSPAMbarn.net Wed Apr 2 20:00:16 2008 From: brenNOSPAMbarn at NObrenSPAMbarn.net (OKB (not okblacke)) Date: Thu, 03 Apr 2008 00:00:16 GMT Subject: function call - default value & collecting arguments References: <_LQIj.9776$HS3.482805@news.siol.net> Message-ID: Primoz Skale wrote: > OK, everything allright till so fair. But! :) Now define third > function as: > > def f(*a): > print a[0] > > In this case, function only prints first argument in the tuple: > >>>f(1,2,3) > 1 >>>f(3) > 3 >>>f() #no arguments passed > Traceback (most recent call last): > File "", line 1, in > f() #no arguments passed > File "", line 2, in f > print a[0] > IndexError: tuple index out of range > > Then I tried to define the function as: > > def f(*a=(0,)): > print a[0] #this should come next, but we get error msg instead, > saying > > SyntaxError: invalid syntax > > but it does not work this way. Now my 'newbie' question: Why not? > :) I wanted to write function in this way, because then we can call > function without any arguments, and it would still print 0 (in this > case). > > What I wanted was something like this: > > def f(*a=(0,)): > print a[0] > >>>f(1,2) > 1 >>>f() #no args passed 0 When you use the *a syntax, you're saying that you want a to contain a tuple of all the arguments. When you try *a=(0,), you seem to be saying that you want a to hold all the arguments, or, if there are none, you want to pretend that it was called with one argument, namely 0. Well, if you want to ensure that there is at least one argument, and print that first one, and make it zero if it's not supplied, why are you using the *a syntax? You're clearly treating that first argument distinctly, since you want to apply a default value to it but not to any others. Just do this: def f(a, *b): print a -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown From mccredie at gmail.com Fri Apr 25 12:56:06 2008 From: mccredie at gmail.com (Matimus) Date: Fri, 25 Apr 2008 09:56:06 -0700 (PDT) Subject: Subclassing list the right way? References: Message-ID: On Apr 25, 7:03 am, Kirk Strauser wrote: > I want to subclass list so that each value in it is calculated at call > time. I had initially thought I could do that by defining my own > __getitem__, but 1) apparently that's deprecated (although I can't > find that; got a link?), and 2) it doesn't work. > > For example: > > >>> class Foo(list): > > ... def __getitem__(self, index): > ... return 5 > ...>>> a = Foo([1, 2, 3, 4, 5]) > >>> print a > [1, 2, 3, 4, 5] > >>> print a[2:4] > [3, 4] > >>> print a[3] > > 5 > > I first expected that to instead behave like: > > >>> print a > [5, 5, 5, 5, 5] > >>> print a[2:4] > > [5, 5] > > Is there a "right" way to do this? > -- > Kirk Strauser The built in types are very optimized. You can't make any assumptions about how overriding methods on them will affect other method calls. >From the docs: __getitem__( self, key) Called to implement evaluation of self[key]. For sequence types, the accepted keys should be integers and slice objects. Note that the special interpretation of negative indexes (if the class wishes to emulate a sequence type) is up to the __getitem__() method. If key is of an inappropriate type, TypeError may be raised; if of a value outside the set of indexes for the sequence (after any special interpretation of negative values), IndexError should be raised. For mapping types, if key is missing (not in the container), KeyError should be raised. Note: for loops expect that an IndexError will be raised for illegal indexes to allow proper detection of the end of the sequence. What that basicly says is that it affects what is returned by a[x]. >>> class Foo(list): ... def __getitem__(self, index): ... return 5 ... >>> a = Foo([1, 2, 3, 4, 5]) >>> print a # a.__str__ called [1, 2, 3, 4, 5] >>> print a[2:4] # a.__getslice__ called [3, 4] >>> print a[3] # a.__getitem__ called 5 The _right_ way? Well, it depends on what you really want to do. If you really want to calculate the value at call time but have it behave exactly as a list in every way, then you will have to override pretty much any method that deals with the values normally stored in the list object. That means any method that either returns values stored in the object, accepts as a parameter values stored in the object or uses the values stored in the object in any way. Methods that return values stored in the object: __getitem__ __getslice__ pop Methods that accept as a parameter values stored in the object: __contains__ count remove index Methods that use values stored in the object in some way: __add__ __eq__ __ge__ __gt__ __iadd__ __imul__ __le__ __lt__ __mul__ __ne__ __reduce__ __reduce_ex__? I'm not sure about this one, I think it is for pickling __repr__ __reversed__ __rmul__ __str__ __iter__ sort reverse I know that Py3.0 is going to implement Abstract Base Classes. I don't know if that is going to clean up this behavior or not. So, you can either write a lot of code or restrict the way you use lists to a limited amount of functionality. There is a third option, which is to calculate the values when storing. This might be a little easier, but if you want to ensure that values returned by all methods are the same type as your class you are back to overriding a lot of methods. Matt From nick at craig-wood.com Fri Apr 18 06:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Fri, 18 Apr 2008 05:30:03 -0500 Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> <9140b6c2-fcf3-454f-a24e-0ed03b3b8e3b@k37g2000hsf.googlegroups.com> Message-ID: Rhamphoryncus wrote: > On Apr 17, 7:40 am, Steve Holden wrote: > > I'd love to be wrong about that, but the GIL *has* been the subject of > > extensive efforts to kill it over the last five years, and it has > > survived despite the best efforts of the developers. > > Yo. http://code.google.com/p/python-safethread/ Sounds very interesting. I particularly liked this bit from the web page - an excellent solution to fine grained locking. Sending only immutable objects between threads is very like the functional approach used by Erlang which is extremely good at concurrency. ------------------------------------------------------------ Which objects can be shared between threads You probably know how to append to a list or modify a dict. When confronted with threading though you may start to wonder, what happens if two threads modify a list or a dict simultaneously? There's two common answers to this: * 1. Corruption. This is the default in C, and to a lesser degree Java. It doesn't limit you much and can be faster, but it requires some deep voodoo to know when you're using it right. * 2. Locks. All the operations internally lock the object. This makes them individually correct, but they'll be wrong again if you try to compose them into larger operations. It also adds a significant performance penalty. My priority is making it easy to write correct programs, and neither of those options are good enough. Instead, I take a third option as my default: * 3. Make sharing impossible, avoiding the question. list and dict cannot be shared between threads. Any attempt to pass a list or dict into something like a Queue will raise a TypeError. This ensures any thread interaction is explicit, rather than implicit. See also: The Zen of Python Of course if you couldn't share any objects then you'd just have processes, which are quite awkward to use. Instead, I only make mutable objects like list and dict unshareable, while immutable int and str objects can still be shared. Further, mutable objects that provide an explicit API for use between threads are also shareable. ------------------------------------------------------------ -- Nick Craig-Wood -- http://www.craig-wood.com/nick From torriem at gmail.com Tue Apr 8 21:52:33 2008 From: torriem at gmail.com (Michael Torrie) Date: Tue, 08 Apr 2008 19:52:33 -0600 Subject: Python Leopard DLL Hell In-Reply-To: <54b165660804081819g4787f4d9g821c7269af7b4c66@mail.gmail.com> References: <54b165660804081819g4787f4d9g821c7269af7b4c66@mail.gmail.com> Message-ID: <47FC2161.5020905@gmail.com> Brian Cole wrote: > That appears to be working correctly at first glance. The argument to > dlopen is the correct shared library. Unfortunately, either python or > OS X is lying to me here. If I inspect the python process with OS X's > Activity Monitor and look at the "Open Files and Ports" tab, it shows > that the _foo.so shared library is actually the one located inside > $DYLD_LIBRARY_PATH. > > So this problem may not be python's, but I place it here as a first > shot (maybe I'm using the imp module incorrectly). Sounds like you're going to need to learn how to use dtrace. Then you can more closely monitor exactly what python and the loader are doing. dtrace is very complicated (borrowed from Solaris) but extremely powerful. Worth learning anyway, but sounds like it's probably the debugging tool you need. Another thing you can do is check through the python source code and see how the os x-specific code is handling this type of situation. From vivainio at gmail.com Wed Apr 23 11:17:34 2008 From: vivainio at gmail.com (Ville M. Vainio) Date: Wed, 23 Apr 2008 15:17:34 GMT Subject: Unix Device File Emulation In-Reply-To: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> Message-ID: blaine wrote: > example usage: echo 'line 0 0 10 10' > /dev/screen > > On the actual embedded device this is handled by a kernel module. We > can spit commands into it as fast as we can and the kernel module can > keep up. This is typical unix device file behavior. > > Any suggestions or advice would be splendid. Thanks! Assuming you are on unix, have you considered FIFO's, os.mkfifo()? From ceo.ch2008 at hotmail.com Sat Apr 19 19:19:59 2008 From: ceo.ch2008 at hotmail.com (ceo.ch2008 at hotmail.com) Date: Sat, 19 Apr 2008 16:19:59 -0700 (PDT) Subject: www.crazysupplier.com cheap nike shoes nike air jordans Manufacturer, Buyer, Supplier ... Message-ID: China wholesaler of cheap air jordan shoes,wholesale jordans,wholesale jordans from china,wholesale nike jordans (www.crazysupplier.com) Buy new jordan 23 shoes, air jordan 23 shoes,jordan xx3,nike jordan xxiii,new air jordan 23 shoes,AJ23,jordan 23 (www.crazysupplier.com) cheap Air jordan xxiii,Jordan 23,cheap wholesale jordan 23,cheap buy air jordan 23,cheap air jordan XX3,XXIII from china (www.crazysupplier.com) cheap wholesale jordans,china wholesalers,Jordans cheap wholesale price,buy cheap jordans,air jordan suppliers from china (www.crazysupplier.com) AJ XXIII,aj23,aj xx3,Nike jordan 23,air jordan xx3,Air jordan xxiii,air jordan 23,new jordan xxiii,cheap jordan xx3,buy from china (www.crazysupplier.com) Jordan shoes xxiii,air jordan shoes 23,new jordan 23,xx3,new jordan 23 shoes,Nike Air jordan 23,xx3 jordan,xx3 shoes,nike jordan xxiii (www.crazysupplier.com) Nike air jordan force 23,ajf23,air jordan 23 fusions,nike jordan 23 fusions,AJF xx3, Jordan XX3 fusions,air force jordan 23 xx3,xxiii fusions,nike air jordan fusions xxiii Mixed jordans,air jordan mix,air jordan 3 force one,ajf3,jordan 3 fusions,Air force one jordan iii fusions,Nike air jordan 3 iii X air force one fusions, air force jordan 3 iii fusions, air jordan 4 v fusions, AJF4,air force one jordan v 4,nike AJF4 fusions (www.crazysupplier.com) Nike Jordan countdown pack 10/13,Nike Jordan Countdown Pack (14/9),Nike Air Jordan Collezione (Countdown Pack 10 / 13) Wholesale Air Jordan 12 Fusions (www.crazysupplier.com) china wholesaler Air Jordan 5 x AF1 Fusions Black/Red Sneaker (www.crazysupplier.com) wholesale Air Jordan Force 12 Fusions (www.crazysupplier.com) Air Jordan V x Air Force 1 Fusion,air force 1 jordans (www.crazysupplier.com) Nike Air Jordan Force XII Fusion (www.crazysupplier.com) Air Jordan XII x AF1 Fusion (www.crazysupplier.com) AIR FORCE 1 AIR JORDAN V fusion (www.crazysupplier.com) Nike Air Jordan XII Fusions (www.crazysupplier.com) Nike Air Jordan IV Fusions,Air jordan 4 plus air force 1 (www.myshoesdepot.com) Nike AF1 Air Jordan Fusions wholesale (www.crazysupplier.com) Nike Air Jordan Fusions XII Mid (www.crazysupplier.com) Men's Nike Air Jordan Fusion XII Mid (www.crazysupplier.com) Air Jordan "Fusions": AJ XII x Air Force 1 (www.crazysupplier.com) Sell Air Jordan 12 fusion sneakers (www.crazysupplier.com) Air Jordan 5 (V) x Air Force 1 (One) - Fusion (www.crazysupplier.com) air jordan 12 air force one 1 fusion (www.crazysupplier.com) Air Jordan fusion XII (www.crazysupplier.com) Nike fusion shoes,air jordan 4 fusion,AJF4 fusions,Jordan 4 plus af1 fusion,nike jordan fusion Wholesale Air jordan 4 x air force 1 fusions (www.crazysupplier.com) Wholesale cheap jordans and air force ones site at (www.crazysupplier.com) wholesale Air Jordan 12 Fusion,air jordan 5 x air force 1 Fusion (www.crazysupplier.com) (www.crazysupplier.com) Wholesale New Air Jordan 12 Fusion,Air Jordan 12 X Air Force 1 Wholesale New Air Jordan 12 Fusion,Air Jordan 12 X Air Force 1 cheap Air Jordan 5 x Air Force one Fusion (www.crazysupplier.com) discount Air Jordan 5 and Air Force one Fusion (www.crazysupplier.com) Air Jordan 12 x Air Force One china online store (www.crazysupplier.com) (www.crazysupplier.com) Air Jordan V x Air Force 1 Fusion Air Jordan 12 x Air Force Ones Fusion (www.crazysupplier.com) Nike AF1 x Air Jordan 5. Nike Air Force Ones Shoes & Air Jordan 5. wholesale Air Jordan 5 (V) x Air Force 1 Fusion (www.crazysupplier.com) From kotecha.ravi at googlemail.com Fri Apr 4 08:56:58 2008 From: kotecha.ravi at googlemail.com (Ravi Kotecha) Date: Fri, 4 Apr 2008 05:56:58 -0700 (PDT) Subject: Looking for Advanced Python Tutorials References: Message-ID: <440c1624-ad9d-4038-bce5-68a2b4ed539a@e10g2000prf.googlegroups.com> On Apr 4, 12:58 pm, cokofree... at gmail.com wrote: > I was wondering if anyone knew of some online (free if possible) > advanced tutorials, especially ones that provides tasks and ideas for > small projects. The issue for myself is I want to improve my python > programming level, and my ability to program in general, but come up > blank thinking of a possible task or project to undertake. So with > that in mind I thought I'd ask the community if they knew of sites or > books to read up on and use as a starting block. Of course project > ideas would be great as well! > > Thanks for any help you can provide. > > Coko Project Euler is a site where you work through mathematical problems using any programming language you like. Once you solve a problem you can see everyone elses solutions and Python is quite popular on that site so you'll see some very clever uses of Python there. I like it a lot for when I haven't got anything better to code: http://projecteuler.net/ - Ravi From tinnews at isbd.co.uk Tue Apr 15 05:08:56 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 15 Apr 2008 09:08:56 GMT Subject: =?UTF-8?B?562U5aSNOg==?= =?UTF-8?B?IOacieS4reWbveS6uuS5jj8=?= References: Message-ID: <480470a8$0$752$bed64819@news.gradwell.net> Penny Y. wrote: > -----????----- > ???: python-list-bounces+pylists=arcor.de at python.org > [mailto:python-list-bounces+pylists=arcor.de at python.org] ?? Steve Holden > ????: 2008?4?15? 2:17 > ???: python-list at python.org > ??: Re: ?????? > > > >Since what I entered in English was something like "Yes, Python has a > >future. But it will take some study". Perhaps you can tell me whether > >your translation gives the correect flavor. I'm pretty sure the > >babelfish mangled my intent. > > > > Babelfish does that thing worse. > yes follow your words, the translation could be: > > Python????.????????, ??????. > > :-) > > Coo, I was just about to ask why I couldn't see most of the characters displayed correctly and now, when I hit reply, I do! :-) So that has solved the conundrum for me, my editor is set up correctly for UTF-8 but my news program's pager isn't. Not that I can read the chinese characters but it's rather nice being able to display them. :-) -- Chris Green From hobgoodoreneyhb at gmail.com Tue Apr 22 11:43:32 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:43:32 -0700 (PDT) Subject: mucaca cracks Message-ID: <8a4a9349-9031-4bb0-924f-060fe39f4703@s50g2000hsb.googlegroups.com> mucaca cracks http://cracks.12w.net F R E E C R A C K S From john106henry at hotmail.com Wed Apr 2 18:29:28 2008 From: john106henry at hotmail.com (John Henry) Date: Wed, 2 Apr 2008 15:29:28 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> <58deb8b8-bae9-4d43-b973-3d90846726cb@b5g2000pri.googlegroups.com> Message-ID: <873a5fc2-0bd8-4f93-9c8c-56cda6e0090a@s37g2000prg.googlegroups.com> On Apr 2, 1:32 pm, Stef Mientki wrote: > John Henry wrote: > > On Apr 1, 11:10 am, sprad wrote: > > >> On Apr 1, 11:41 am, mdomans wrote: > > >>> Python needs no evangelizing but I can tell you that it is a powerfull > >>> tool. I prefer to think that flash is rather visualization tool than > >>> programing language, and java needs a lot of typing and a lot of > >>> reading. On the other hand python is simple to read and write, can be > >>> debuged easily, is intuitive and saves a lot of time. It also supports > >>> batteries included policy and you can't get more OO than python. > > >> One advantage of Flash is that we can have something moving on the > >> screen from day one, and add code to it piece by piece for things like > >> keyboard or mouse control, more and more complex physics, etc. Is > >> there an equivalent project in Python? > > > I downloaded the "How to Think Like a Python Programmer" book and read > > it. I think it's a fine reference book for the purpose you > > indicated. > > > Here's my 2 cents on the subject. > > > I had been a volunteer mentor to my son's middle school robotic team > > for several years and I have some experiences, therefore, in how kids > > react to "programming". Granted, high school kids are "bigger kids" - > > but they are kids nevertheless. > > > Last summer, I experimented teaching my own kid Python. He was in 7th > > grade going onto 8th grade. He was the main goto person for the > > robotic team and had no trouble learning the common applications such > > as the Microsoft Office suite, and had some experience in ICONic > > programming (Lego Mindstorm). So, I tried to see what would happen if > > he tries to learn Python - using somewhat similar approach you are > > taking: start with something visually appealing on day one. Instead > > of Flash, I used Pythoncard - a no-brainer Python GUI construction > > toolkit. He was really excited seeing how easy it was to have tic-tae- > > toe type program up so easily (we are taking minutes - not hours) and > > was very interested and motivated to continue. So far so good. > > However, once I start teaching him variables, expressions, loops, and > > what not, I found that (by surprise) he had great difficulties > > catching on. Not soon after that, we had to quit. > > > We - as adults - take many things for granted and sometimes don't > > remember, or don't understand how kids learn. My experience tells me > > that in order to teach today's video game generation of kids, the > > approach really has to be entirely visual. After I abandoned my > > attempt to teach my kid Python, I started them on Robolab - a > > simplified version of LabView and to my delight, they were able to > > cook up a few simple programs (like fibonacci series and so forth) > > without too much effort - although my own kid had some minor trouble > > understanding the concept of a container (LabView's version of a > > variable). > > > I don't know if you have access to LabView or Robolab or similar > > packages but if you do, I would highly recommend those. LabView is > > every bit as powerful, full-featured, and "real-life" as many of the > > other languages and I believe that kids will have a much easier time > > learning computer programming with it. > > Well I doubt it's the visual environment that makes it more easy, > color, shape and position can give some extra information though. > I think apriori domain knowledge and flattness of information are of far > more importance. > The first issue is covered quit well by Robolab / Labview, > but the second issue certainly is not. > I'm right now working on a Labview like editor in Python, > which does obey the demand for flatness of information. > The first results can be seen here:http://oase.uci.kun.nl/~mientki/data_www/pylab_works/pw_animations_sc... > > cheers, > Stef Mientki > > > And you are going to teach them Java? Oh, please don't. Let the > > colleges torture them. :=) What do you mean by flatness of information? From misceverything at gmail.com Sat Apr 5 19:56:31 2008 From: misceverything at gmail.com (misceverything at gmail.com) Date: Sat, 5 Apr 2008 16:56:31 -0700 (PDT) Subject: Recursively Backup Directories Message-ID: I am writing a script that will backup specified folders from one hard drive to another (for example, backup source "C:\DATA", destination "D: \Backup"), and was thinking of using shutil. What I would like to do is recursively backup the specified directories (which copytree will do), but be able to specify exclusion directories (which copytree does not appear to allow you to do). My initial thoughts were I'll probably have to use os.path.walk for the backup source directory, but I'm not sure how to go from there. Thanks in advance. From adelagon at gmail.com Wed Apr 9 04:05:45 2008 From: adelagon at gmail.com (Alvin Delagon) Date: Wed, 9 Apr 2008 16:05:45 +0800 Subject: PyArg_ParseTuple for structs or binary data Message-ID: <7a01f6c00804090105h7cba73f0g53687349d8dcd574@mail.gmail.com> Hello fellow pythonistas, I'm currently writing a simple python SCTP module in C. So far it works sending and receiving strings from it. The C sctp function sctp_sendmsg() has been wrapped and my function looks like this: sendMessage(PyObject *self, PyObject *args) { const char *msg = ""; if (!PyArg_ParseTuple(args, "s", &msg)) return NULL; snprintf(buffer, 1025, msg); ret = sctp_sendmsg(connSock, (void *)buffer, (size_t)strlen(buffer), 0, 0, 0x03000000, 0, 0, 0, 0); return Py_BuildValue("b", ""); } I'm going to construct an SS7 packet in python using struct.pack(). Here's the question, how am I going to pass the packet I wrote in python to my module? Thanks in advance! :) --- Alvin Delagon -------------- next part -------------- An HTML attachment was scrubbed... URL: From bronger at physik.rwth-aachen.de Wed Apr 16 13:01:16 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 16 Apr 2008 19:01:16 +0200 Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> <87prspydex.fsf@physik.rwth-aachen.de> Message-ID: <87lk3dybs3.fsf@physik.rwth-aachen.de> Hall?chen! Michael Torrie writes: > Torsten Bronger wrote: > >> The admistrative overhead of mailing lists is tedious. >> Fortunately, most important computer-related lists are on >> gmane.org. We could list c.l.py there, too. ;-) > > Running a few lists myself, I don't see this. How is > administrative overhead tedious? Most open source projects do it, > so I wonder just how tedious it is. Of all the projects I'm > associated with in lists, Python is the only one still clinging to > NNTP when it appears a normal mail list is just as good. Perish the thought that I ever have to go back to mailing lists again! Finding the web page, entering name and email address and a password, waiting for request for confirmation, sending out confirmation, clicking away welcome message, setting filter in email program, and doing the same for unsubscribing a few days later after having found out that it's not so interesting after all. No. Just going to the group list, search the group, pressing "U" -- and getting all the postings of the past, too! And for unsubscribing, press "U" again. No email address, no password, no filters, no hassle. And spam is also very rare in my groups. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From musiccomposition at gmail.com Tue Apr 15 22:36:35 2008 From: musiccomposition at gmail.com (Benjamin) Date: Tue, 15 Apr 2008 19:36:35 -0700 (PDT) Subject: Brand New! References: <7f1828bf-ebe7-4111-bc59-70d125facb0a@d26g2000prg.googlegroups.com> Message-ID: <2b897fe3-59e8-4268-9821-d203bb7d9d6e@a22g2000hsc.googlegroups.com> On Apr 15, 6:37 pm, agent E 10 wrote: > On Apr 14, 8:37 pm, Benjamin wrote: > > > On Apr 14, 9:00 pm, agent E 10 wrote:> Hi, I'm brand new to programming. Have any suggestions? I'm young. > > > Was it a good idea to start with python? I was planning on creating a > > > very simple program that asked yes/no questions for a school project. > > > IMHO, Python is an excellent language to start with. Have you read the > > tutorial?http://docs.python.org/tut/tut.html > > > > -Thanks!- Hide quoted text - > > > - Show quoted text - > > No, I haven't. I have been reading off of this sitehttp://www.freenetpages.co.uk/hp/alan.gauld/is this a good site to > learn off of? About how long will it take me to learn the basics of > the language? I took a brief glance. It seems like a good start! Compared to other programming languages, Python is very easily to learn. > -Thanks 4 all ur help! Agent E 10 From ivan.illarionov at gmail.com Thu Apr 10 12:30:28 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Thu, 10 Apr 2008 09:30:28 -0700 (PDT) Subject: wrapping C functions in python References: <54b165660804091322w690e5e64x85c3d8f082b411b2@mail.gmail.com> <54b165660804091355m1326f7c0g1a5eebe3d6b5a1df@mail.gmail.com> Message-ID: <1ce459fb-475b-4370-8fd4-a5193600cb23@w1g2000prd.googlegroups.com> On Apr 10, 9:57 am, Paul Anton Letnes wrote: [...] > , but as I mentioned, it seems to be a bit complicated to wrap heavy > data structures like arrays. Hello, I suggest that you might take a look at how other people solved the same problems. The great example is path.c inside PIL [1]. `PyPath_Flatten` function creates C array from Python data, `path_to_list` converts C array into Python list and `path_map` applies a Python function to C array. Also take a look at Python buffer interface [2] - use array module on Python side instead of lists and you'll have almost instant C arrays from Python data and vice versa. 1: http://effbot.org/downloads/Imaging-1.1.6.tar.gz 2: http://docs.python.org/api/buffer-structs.html Regards, -- Ivan From robert.spilleboudt.no.sp.am at skynet.be Thu Apr 10 06:12:38 2008 From: robert.spilleboudt.no.sp.am at skynet.be (Robert.Spilleboudt ) Date: Thu, 10 Apr 2008 12:12:38 +0200 Subject: urgent question, about filesystem-files In-Reply-To: References: Message-ID: <47fde816$0$2956$ba620e4c@news.skynet.be> bvidinli wrote: > i started python programming a few months ago. > > now i need the code to understand if a file already opened in > filesystem by another process ? > > i looked at docs, howtos, but did not find related info. > note that normal file open/write operations in python, i know it. > > i specificly need to know that "is a file already open by some other > process other than python". > > > Thank you in advance This is a OS function. With Linux you use the command lsof (as root). A Python program can call such a command, but you have to parse the output. Robert From frambooz at gmail.com Fri Apr 11 08:54:03 2008 From: frambooz at gmail.com (frambooz at gmail.com) Date: Fri, 11 Apr 2008 05:54:03 -0700 (PDT) Subject: Adding classes to modules at runtime from outside that module References: Message-ID: On Apr 10, 8:05?pm, Andrew Warkentin wrote: > framb... at gmail.com wrote: > > ?In Python, is it possible to add classes to a module at run-time? > > > ?Say I have a module foo and a module bar. Foo has class A and B, and > >bar has class C. I want to add class C to foo so I can access it as > >foo.C, but i want to do it without modifying foo's source. > > > ?Is this at all possible? > > Yes. > > You would do something like > > import foo > import bar > > foo.C = bar.C Wow. That was a lot easier than expected. Thanks, all. ` Rogier From castironpi at gmail.com Wed Apr 2 13:11:30 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 2 Apr 2008 10:11:30 -0700 (PDT) Subject: generator functions: why won't this work? References: Message-ID: <19359dad-3022-4e83-99e4-8f8093116bcb@a1g2000hsb.googlegroups.com> On Apr 1, 10:42?pm, "Gabriel Genellina" wrote: > En Tue, 01 Apr 2008 23:56:50 -0300, escribi?: > > ? ?yield *iterable > > could be used as a shortcut for this: > > ? ?for __temp in iterable: yield __temp How serious were you about that? From stefan_ml at behnel.de Mon Apr 7 02:09:55 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 07 Apr 2008 08:09:55 +0200 Subject: html DOM In-Reply-To: References: Message-ID: <47F9BAB3.9080407@behnel.de> Sam the Cat wrote: > Is there a package that would allow me the same or similar functionality > for modifying html code via the DOM model as I have in JavaScript ? I'd > like to parse an html file, then modify it and save the result. I am > not trying to do this online, rather I would like to do this on a batch > of files stored on my hard drive. I have found several packages that > allow me to parse and dissect html but none that allow me to modify the > object and save the results -- perhaps I am overlooking the obvious http://codespeak.net/lxml/lxmlhtml.html Here are some performance comparisons of HTML parsers: http://blog.ianbicking.org/2008/03/30/python-html-parser-performance/ Stefan From yoz at home.havin.us Wed Apr 16 08:26:04 2008 From: yoz at home.havin.us (yoz) Date: Wed, 16 Apr 2008 13:26:04 +0100 Subject: webcam (usb) access under Ubuntu In-Reply-To: References: Message-ID: Berco Beute wrote: > I've been trying to access my webcam using Python, but I failed > miserably. The camera works fine under Ubuntu (using camora and > skype), but I am unable to get WebCamSpy or libfg to access my webcam. > > First I tried webcamspy (http://webcamspy.sourceforge.net/). That > requires pySerial and pyParallel, and optionally pyI2C. Runing > WebCamSpy results in: > > Exception exceptions.AttributeError: "Parallel instance has no > attribute '_fd'" in > ignored > > This seems to come from importing I2C. The application window opens, > but there's an error message: > > NO VIDEO SOURCE FOUND > > Next I tried libfg (http://antonym.org/libfg). I built it, made the > Python bindings and installed it. Unfortunately the following: > >>>> import fg >>>> grabber = fg.Grabber() > > results in: > > fg_open(): open video device failed: No such file or directory > > Since the camera works fine in Ubuntu itself my guess is that the > problem is with the python libraries (or even likelier, my usage of > them). Is there anybody here that was successful in accessing their > webcam on linux using Python? Else I have to reside to Windows and > VideoCapture (which relies on the win32 api and thus is Windows-only), > something I'd rather not do. > > Thanks for any help, > 2B > > =============== > I am uUsing: > WebCam: Logitech QuickCam Pro 400 > Ubuntu > Python 2.5 Some time ago I was playing with writing a webcam server under Linux using V4L - I found this bit of code which may help (it works for me). Obviously it needs X running to work and the associated libs installed. Note this is not my code but it was a good starting point for me to work from. I can't find a link to the original article but credit to the author. import pygame import Image from pygame.locals import * import sys import opencv #this is important for capturing/displaying images from opencv import highgui camera = highgui.cvCreateCameraCapture(0) def get_image(): im = highgui.cvQueryFrame(camera) #convert Ipl image to PIL image return opencv.adaptors.Ipl2PIL(im) fps = 30.0 pygame.init() window = pygame.display.set_mode((320,240)) pygame.display.set_caption("WebCam Demo") screen = pygame.display.get_surface() while True: events = pygame.event.get() for event in events: if event.type == QUIT or event.type == KEYDOWN: sys.exit(0) im = get_image() pg_img = pygame.image.frombuffer(im.tostring(), im.size, im.mode) screen.blit(pg_img, (0,0)) pygame.display.flip() pygame.time.delay(int(1000 * 1.0/fps)) Best of Luck Bgeddy From rustompmody at gmail.com Mon Apr 21 10:48:28 2008 From: rustompmody at gmail.com (rustom) Date: Mon, 21 Apr 2008 07:48:28 -0700 (PDT) Subject: Java or C++? References: Message-ID: On Apr 14, 11:44?am, s0s... at gmail.com wrote: > Hello, I was hoping to get some opinions on a subject. I've been > programming Python for almost two years now. Recently I learned Perl, > but frankly I'm not very comfortable with it. Now I want to move on > two either Java or C++, but I'm not sure which. Which one do you think > is a softer transition for a Python programmer? Which one do you think > will educate me the best? The movement from knowing no programming language to knowing one is invariably a much larger one than the shift from one to two (see http://en.wikipedia.org/wiki/Diminishing_returns). That is you are likely to get much less from this shift than what you got from python two years ago. So before you make this shift do ask yourself: have you got the best of what python has to offer? I taught python in the univ for a number of years and I would always tell my students that the library reference gave a better conspectus of modern day computer science/IT than anything else I knew of. [That not too many of them listened is another matter :-) ] Then python has a lot of advanced (new) stuff: generators and generator expressions, comprehensions, lambdas and functional programming, descriptors and protocols.... That said you can of course choose your second language to optimize your learning (where optimize could be minimize or maximize!) One language that is promising (and under active development) is curl. (http://www.curl.com) It is targeted to be like C++ in efficiency (native compiler not VM or interpreter) like C#/Java in its OOP with gc style like Javascript in supporting dynamic rich web apps in addition to replacing HTML From hank.infotec at gmail.com Sun Apr 20 08:46:37 2008 From: hank.infotec at gmail.com (Hank @ITGroup) Date: Sun, 20 Apr 2008 22:46:37 +1000 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> Message-ID: <480B3B2D.6040206@gmail.com> Apology for the previous offensive title~~ :) Thanks, Rintsch, Arnaud and Daniel, for replying so soon. I redid the experiment. What following is the record - ``starting python`` # == Windows Task Manager: Python.exe *4,076 *K memory-usage == >>> st1='abcdefg'*999999 # == 10,952 K == >>> del st1 # == *4,104*K == >>> st1='abcdefg'*999999 # == 10,952 K == >>> del st1 # == 4,104 K == >>> li = ['abcde']*999999 # == 8,024 K == >>> del li # == *4,108* K == >>> from nltk import FreqDist # == 17,596 == >>> fd = FreqDist() # == 17,596 == >>> for i in range(999999):fd.inc(i) # == 53,412 == >>> del fd # == *28,780* == >>> fd2 = FreqDist() # == 28,780 == >>> for i in range(999999):fd2.inc(i) # == 53,412 == >>> del fd2 # == 28,780 K == >>> def foo(): ... fd3 = FreqDist() ... for i in range(999999):fd3.inc(i) >>> foo() # == *28,788* K == >>> def bar(): ... fd4 = FreqDist() ... for i in range(999999):fd4.inc(i) ... del fd4 # == 28,788 K == >>> bar() # == 28,788 K == That is my question, after ``del``, sometimes the memory space returns back as nothing happened, sometimes not... ... What exactly was happening??? Best regards to all PYTHON people ~~ !!! Python Team are great !!! From rhamph at gmail.com Fri Apr 18 12:29:11 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Fri, 18 Apr 2008 09:29:11 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> <9140b6c2-fcf3-454f-a24e-0ed03b3b8e3b@k37g2000hsf.googlegroups.com> Message-ID: On Apr 18, 4:30 am, Nick Craig-Wood wrote: > Rhamphoryncus wrote: > > On Apr 17, 7:40 am, Steve Holden wrote: > > > I'd love to be wrong about that, but the GIL *has* been the subject of > > > extensive efforts to kill it over the last five years, and it has > > > survived despite the best efforts of the developers. > > > Yo. http://code.google.com/p/python-safethread/ > > Sounds very interesting. I particularly liked this bit from the web > page - an excellent solution to fine grained locking. Sending only > immutable objects between threads is very like the functional approach > used by Erlang which is extremely good at concurrency. Although superficially similar, the details of Erlang are actually pretty different. It copies all objects passed between threads - it was originally designed for fault tolerance (entire nodes going down), not concurrency. If you want a shared mutable object you need to use a "process" as one, treating it as an actor. Hopefully you can do most of it in a one-way, message driven style, as otherwise you're going to be transforming your synchronous calls into a series of callbacks. If you have a node farm, you want to upgrade it incrementally, and you want it to be fault tolerant (nodes go down at random without kill the whole thing), Erlang is much better than safethread. That's at a significant cost though, as it's only good at the one style. Safethread is much better at a style useful on a single desktop. From gagsl-py2 at yahoo.com.ar Mon Apr 28 02:45:12 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 28 Apr 2008 03:45:12 -0300 Subject: learning with python question (HtTLaPP) References: <98acecbd-9de2-4ebf-927b-ac6bc1fbc3fd@b5g2000pri.googlegroups.com> <53d6254f-895f-48fb-8ab9-3929c403f11b@v23g2000pro.googlegroups.com> Message-ID: En Sat, 26 Apr 2008 20:50:57 -0300, escribi?: > ok.. I finally made something that works.. Please let me know what you > think: > >>>> def lines(letters): > fin = open('words.txt') > count = 0 > rescount = 0 # count the number of results > results = "" # there are words that contain the letters > for line in fin: > needs = 0 > x = str(line.strip()) > for ch in letters: > if ch not in x: > pass > else: > needs = needs + 1 > if needs == len(letters): > rescount += 1 > results = results + '\n' + x > count += 1 > print count, 'lines searched' > print results, '\n' > print 'result count is: ', rescount That's pretty good. Some improvements: - The "natural" way to collect the results is using a list, appending words to it. Later you can print it one word per line or in any other format you want. Also, we don't need the "rescount" variable: it's just the length of the list. > needs = 0 > for ch in letters: > if ch not in x: > pass > else: > needs = needs + 1 > if needs == len(letters): The overall idea is to test whether ALL letters are in the word `x`, ok? So as soon as we find a letter that isn't in the word, we are sure the test failed and we can break out of the loop. And if we get up to the last step, that means that all the letters were in the word (else we would not have got so far). So we don't have to count the letters; instead, we can use the "else" clause of the for loop (it means "the loop was exhausted completely".) - I don't like the names "x" nor "ch"; I'm using "word" and "letter" instead. This is the revised version: def lines(letters): fin = open('words.txt') count = 0 results = [] # there are words that contain the letters for line in fin: word = line.strip() for letter in letters: if letter not in x: break else: results.append(word) count += 1 print count, 'lines searched' print '\n'.join(results), '\n' print 'result count is: ', len(results) That "\n".join(...) means "concatenate all the items in the list using \n as a separator between items" and it's a pretty common idiom in Python. -- Gabriel Genellina From kveretennicov at gmail.com Sat Apr 5 09:17:36 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Sat, 5 Apr 2008 16:17:36 +0300 Subject: UML reverse engineering In-Reply-To: <6712345.1824821207324312295.JavaMail.servlet@kundenserver> References: <6712345.1824821207324312295.JavaMail.servlet@kundenserver> Message-ID: <4660fe300804050617k28769016k4687246349352cdc@mail.gmail.com> On Fri, Apr 4, 2008 at 6:51 PM, wrote: > Hello, > > Do you know a free software witch can compute a UML class diagram from a > python code. I tested many free UML softwares like BoUML, ArgoUML, Dia, > PNSource (not found) ... Did you mean /PyNSource/ ? (http://www.atug.com/andypatterns/pynsource.htm) -- kv From bob at passcal.nmt.edu Mon Apr 21 19:06:39 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Mon, 21 Apr 2008 17:06:39 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> <2008042115060816807-bob@passcalnmtedu> <2008042116511375249-bob@passcalnmtedu> Message-ID: <2008042117063950073-bob@passcalnmtedu> On 2008-04-21 16:51:13 -0600, Bob Greschke said: JUST COMPLETELY IGNORE THAT LAST ONE. What a dope. Here: #! /usr/bin/env python from os import system from struct import unpack print "unpack 1" system("date") for x in xrange(0, 100000000): Value = unpack(">B", "a")[0] if Value > 0x800000: Value -= 0x1000000 system("date") print print "ord 1" system("date") for x in xrange(0, 100000000): Value = ord("a") if Value > 0x800000: Value -= 0x1000000 system("date") print print "unpack 3" system("date") for x in xrange(0, 100000000): Value1, Value2, Value3 = unpack(">BBB", "abc") Value = (Value1 << 16)+(Value2 << 8)+Value3 if Value > 0x800000: Value -= 0x1000000 system("date") print print "ord 3" system("date") for x in xrange(0, 100000000): Value = (ord("a") << 16)+(ord("b") << 8)+ord("c") if Value > 0x800000: Value -= 0x1000000 system("date") Still, the differences between unpack and ord are significant (I just threw in the if's for fun). From nick at stinemates.org Fri Apr 18 15:03:26 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 12:03:26 -0700 Subject: How to have unittest tests to be executed in the order they appear? In-Reply-To: <20080415151439.7065a31a.darcy@druid.net> References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> <20080415151439.7065a31a.darcy@druid.net> Message-ID: <20080418190326.GH19281@deviL> On Tue, Apr 15, 2008 at 03:14:39PM -0400, D'Arcy J.M. Cain wrote: > > However, do consider writing your tests so that order is irrelevant. > If a test depends on a previous test running then it isn't a proprt > self-contained test. For one thing, you can't run a single test that > way if you wanted to. > Agreed! -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From wwzaygvm at gmail.com Wed Apr 16 16:55:21 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 13:55:21 -0700 (PDT) Subject: windows live onecare keygen Message-ID: <1cb70d69-7794-40a9-abea-250c356657a7@p25g2000pri.googlegroups.com> windows live onecare keygen http://cracks.12w.net F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Tue Apr 8 01:12:01 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 08 Apr 2008 02:12:01 -0300 Subject: Newbie: How to pass a dictionary to a function? References: <516e07d1-91f9-462b-9fc0-ac6d1e474f9d@n14g2000pri.googlegroups.com> Message-ID: En Tue, 08 Apr 2008 00:54:09 -0300, BonusOnus escribi?: > How do I pass a dictionary to a function as an argument? The indentation is lost, so it's not easy to check your program. > # Say I have a function foo... Original: def foo(arg=[]). An empty list isn't a good default value here, perhaps you intended to use {}? Anyway, don't use mutable default values; see this FAQ entry: http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects def foo(arg): x = arg['name'] y = arg['len'] s = len(x) t = s + y return s, t # don't use dict as a variable name, you're hiding the builtin dict type my_dict = {} my_dict['name'] = 'Joe Shmoe' my_dict['len'] = 44 # don't use len as a name either # nor string! length, string = foo(my_dict) > # This bombs with 'TypeError: unpack non-sequence' > What am I doing wrong with the dictionary? Nothing. Written as above, it works fine. Don't retype your programs, always copy & paste from the same source you're executing. If you get an exception, post the entire traceback with the exact exception name and message. -- Gabriel Genellina From Robert.Bossy at jouy.inra.fr Thu Apr 24 04:24:37 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Thu, 24 Apr 2008 10:24:37 +0200 Subject: annoying dictionary problem, non-existing keys In-Reply-To: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> Message-ID: <481043C5.20409@jouy.inra.fr> bvidinli wrote: > i use dictionaries to hold some config data, > such as: > > conf={'key1':'value1','key2':'value2'} > and so on... > > when i try to process conf, i have to code every time like: > if conf.has_key('key1'): > if conf['key1']<>'': > other commands.... > > > this is very annoying. > in php, i was able to code only like: > if conf['key1']=='someth' > > in python, this fails, because, if key1 does not exists, it raises an exception. > > MY question: > is there a way to directly get value of an array/tuple/dict item by key, > as in php above, even if key may not exist, i should not check if key exist, > i should only use it, if it does not exist, it may return only empty, > just as in php.... > > i hope you understand my question... > If I understand correctly you want default values for non-existing keys. There are two ways for achieving this: Way 1: use the get() method of the dict object: conf.get(key, default) which is the same as: conf[key] if key in conf else default Way 2: make conf a defaultdict instead of a dict, the documentation is there: http://docs.python.org/lib/defaultdict-objects.html Hope this helps, RB From martin at v.loewis.de Tue Apr 22 01:03:53 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 22 Apr 2008 07:03:53 +0200 Subject: py3k concerns. An example In-Reply-To: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: <480D71B9.40909@v.loewis.de> > In py3k string%dictionary is going away. Why do you say that? It's not going away in Python 3.0. Regards, Martin From rridge at caffeine.csclub.uwaterloo.ca Fri Apr 11 23:18:04 2008 From: rridge at caffeine.csclub.uwaterloo.ca (Ross Ridge) Date: Fri, 11 Apr 2008 23:18:04 -0400 Subject: Windows - window status (Running vs Not Responding) References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> Message-ID: rdahlstrom wrote: >Basically, I'm looking for something similar to the Process.Responding >property in System.Diagnostics... You probably want to use IsHungAppWindow(): IsHungAppWindow Function You call the IsHungAppWindow function to determine if Microsoft Windows considers that a specified application is not responding. An application is considered to be not responding if it is not waiting for input, is not in startup processing, and has not called PeekMessage within the internal timeout period of 5 seconds. Syntax BOOL IsHungAppWindow( HWND hWnd ); ... You can use EnumWindows() to enumerate the all the top level windows. Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] rridge at csclub.uwaterloo.ca -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // From maxerickson at gmail.com Sat Apr 12 08:35:24 2008 From: maxerickson at gmail.com (Max Erickson) Date: Sat, 12 Apr 2008 12:35:24 +0000 (UTC) Subject: [ANN]: Python-by-Example updates References: <48000796$0$30160$4c368faf@roadrunner.com> Message-ID: AK wrote: > Python-by-Example is a guide to LibRef, aiming to give examples > for all functions, classes, modules, etc. Right now examples > for functions in some of the most important modules are > included. > > http://pbe.lightbird.net/ > > thanks, > The second set of examples on the page for decimal doesn't look quite right. The first couple of lines: getcontext().prec = 6 # Decimal('3.0') Decimal("3.0") # Decimal('3.1415926535') I would assume that the " = 6" isn't getting processed correctly. max From roger.dahlstrom at gmail.com Tue Apr 1 06:52:27 2008 From: roger.dahlstrom at gmail.com (rdahlstrom) Date: Tue, 1 Apr 2008 03:52:27 -0700 (PDT) Subject: CTypes, 64 bit windows, 32 bit dll References: <5a0d8c47-f1b7-4eae-9911-b312a1166757@d1g2000hsg.googlegroups.com> <5uj3v39d6e4ok6o7qda4vagfg4h68kv4th@4ax.com> Message-ID: <1cb61f8f-1caf-460e-89a3-c5f202e3179c@59g2000hsb.googlegroups.com> On Apr 1, 2:03 am, Tim Roberts wrote: > rdahlstrom wrote: > >On Mar 31, 12:53 pm, "mimi.vx" wrote: > >> On Mar 31, 4:22 pm, rdahlstrom wrote: > > >> > So I have a 64 bit Windows 2003 system, running python 2.5.1.1. > > >> > I can import a Windows .dll (msvcrt or whatever) using ctypes, but > >> > when attempting to import another application-specific .dll (tibrv.dll > >> > if anyone is familiar with it), I receive the error WindowsError: > >> > [Error 193] %1 is not a valid Win32 application. > > >> > I know there's a Windows on Windows (wow) which allows 32 bit > >> > processes to run on 64 bit windows - is there a way to work this in > >> > somehow? Maybe I'm barking up the wrong tree? > >>... > > >> all dlls and python must be 32bit or 64bit, no mixed ... > > >Crap, no way to make a 32 bit load, even using the wowexec? > > No. In Win64, a process is either entirely 32-bit, or entirely 64-bit. To > do the kind of crossing you seek, you would need to create a separate > process for the 32-bit DLL and use interprocess communication. > -- > Tim Roberts, t... at probo.com > Providenza & Boekelheide, Inc. Shoot. Alright, thanks for your help. I guess I'll have to roll out a 64-bit version of the tibco software. From deets at nospam.web.de Thu Apr 17 10:08:45 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 17 Apr 2008 16:08:45 +0200 Subject: why function got dictionary References: <48075950.7050000@gmail.com> Message-ID: <66p409F2lg89hU1@mid.uni-berlin.de> AlFire wrote: > Hi, > > I am seeking an explanation for following: > > Python 2.5.2 (r252:60911, Apr 8 2008, 21:49:41) > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> def g(): return > ... > >>> g.__dict__ > {} > > Q: why function got dictionary? What it is used for? because it is an object, and you can do e.g. g.exposed = True or similar stuff. Diez From sjmachin at lexicon.net Sat Apr 5 20:12:55 2008 From: sjmachin at lexicon.net (John Machin) Date: Sat, 5 Apr 2008 17:12:55 -0700 (PDT) Subject: while-loops enter the last time after condition is filled? References: Message-ID: On Apr 6, 9:53 am, skanem... at yahoo.se wrote: > it seems to me from my results that when i use a while-loop it will > execute once after the condition is met. > > ie the conditions is met the code executes one time more and then > quits. The syntax is this: while condition: do_something() Do you mean that it executes do_something() only once, but you expect it to execute more that once? Or should we interpret your seemingly inconsistent statement by changing "condition(s) is met" to "condition(s) is NOT met" -- in other words, it is executing one EXTRA time after you expect it to have stopped? Perhaps you should supply a short example of runnable code (including print statements to show what is happening), the actual output that you got when you ran that code, and what was the output that you expected. From zillow10 at googlemail.com Thu Apr 3 18:30:44 2008 From: zillow10 at googlemail.com (zillow10 at googlemail.com) Date: Thu, 3 Apr 2008 15:30:44 -0700 (PDT) Subject: id functions of ints, floats and strings References: Message-ID: On Apr 3, 11:27 pm, zillo... at googlemail.com wrote: > Hi all, > > I've been playing around with the identity function id() for different > types of objects, and I think I understand its behaviour when it comes > to objects like lists and tuples in which case an assignment r2 = r1 > (r1 refers to an existing object) creates an alias r2 that refers to > the same object as r1. In this case id(r1) == id(r2) (or, if you > like: r1 is r2). However for r1, r2 assigned as follows: r1 = [1, 2, > 3] and r2 = [1, 2, 3], (r1 is r2) is False, even if r1==r2, > etc. ...this is all very well. Therefore, it seems that id(r) can be > interpreted as the address of the object that 'r' refers to. > > My observations of its behaviour when comparing ints, floats and > strings have raised some questions in my mind, though. Consider the > following examples: > > ######################################################################### > > # (1) turns out to be true > a = 10 > b = 10 > print a is b > > # (2) turns out to be false > f = 10.0 > g = 10.0 > print f is g > > # behaviour when a list or tuple contains the same elements ("same" > meaning same type and value): > > # define the following function, that checks if all the elements in an > iterable object are equal: > > def areAllElementsEqual(iterable): > return reduce(lambda x, y: x == y and x, iterable) != False > > # (3) checking if ids of all list elements are the same for different > cases: > > a = 3*[1]; areAllElementsEqual([id(i) for i in a]) # True > b = [1, 1, 1]; areAllElementsEqual([id(i) for i in b]) # True > f = 3*[1.0]; areAllElementsEqual([id(i) for i in f]) # True > g = [1.0, 1.0, 1.0]; areAllElementsEqual([id(i) for i in g]) # True > g1 = [1.0, 1.0, 0.5+0.5]; areAllElementsEqual([id(i) for i in g1]) # > False > > # (4) two equal floats defined inside a function body behave > differently than case (1): > > def func(): > f = 10.0 > g = 10.0 > return f is g > > print func() # True > > ###################################################### > > I didn't mention any examples with strings; they behaved like ints > with respect to their id properties for all the cases I tried. > While I have no particular qualms about the behaviour, I have the > following questions: > > 1) Which of the above behaviours are reliable? For example, does a1 = > a2 for ints and strings always imply that a1 is a2? > 2) From the programmer's perspective, are ids of ints, floats and > string of any practical significance at all (since these types are > immutable)? > 3) Does the behaviour of ids for lists and tuples of the same element > (of type int, string and sometimes even float), imply that the tuple a > = (1,) takes (nearly) the same storage space as a = 10000*(1,)? (What > about a list, where elements can be changed at will?) > > Would appreciate your responses... > > AK Question 1 should read "For example, does a1 == a2 for ints ..." From namesagame-usenet at yahoo.com Wed Apr 30 14:06:13 2008 From: namesagame-usenet at yahoo.com (gamename) Date: Wed, 30 Apr 2008 11:06:13 -0700 (PDT) Subject: Sending Cntrl-C ?? References: <0274834e-17e1-4a95-88ec-f2aa77aeb3a9@k10g2000prm.googlegroups.com> Message-ID: <8d53535b-b00e-40b4-b65f-1ca126884592@k10g2000prm.googlegroups.com> > win32api.GenerateConsoleCtrlEvent(win32con.CTRL_C_EVENT, pgid) How do you determine the value of 'pgid'? From sales024 at aaa-replica-watch.com Tue Apr 1 00:45:19 2008 From: sales024 at aaa-replica-watch.com (sales024 at aaa-replica-watch.com) Date: Mon, 31 Mar 2008 21:45:19 -0700 (PDT) Subject: Cheap Chopard Happy Diamonds Watches Replica - Chopard Watches Wholesale Message-ID: <1bb1da1f-e53b-4eec-afdb-bcd05e43c706@e6g2000prf.googlegroups.com> Cheap Chopard Happy Diamonds Watches Replica - Chopard Watches Wholesale AAA Replica Watches : http://www.watches-replicas.com Chopard Watches Brands : http://www.watches-replicas.com/chopard-watches.html Replica Chopard Happy Diamonds Watches : http://www.watches-replicas.com/chopard-happy-diamonds-watches.html China largest replica watches wholesaler, wholesale up to 80% of Chopard Happy Diamonds Replica Watches and Chopard Happy Diamonds Fake Watch. The most famous Swiss brand name watches you can find, replica Chopard Happy Diamonds Watches and fake Chopard Happy Diamonds Watches are also available. All our Chopard Happy Diamonds Watches replicas are crafted in high quality, You will get great profite by ordering our good cheap watches. Chopard Happy Diamonds Watches All Products : Chopard Happy Diamonds Ladies Watch 20/7469 RG MOP Tan : http://www.watches-replicas.com/Chopard-Ladies-Watch-20-7469-RGMOPTan-2314.html Chopard Happy Diamonds Ladies Watch 20/7450-20 : http://www.watches-replicas.com/chopard-happy-diamonds-watch-20-7450-20-2315.html The Same Chopard Replica Watches Series : Chopard Happy Sport Watches : http://www.watches-replicas.com/chopard-happy-sport-watches.html Chopard Happy Beach and Happy Fish Watches : http://www.watches-replicas.com/chopard-happy-beach-and-happy-fish-watches.html Chopard Mille Miglia Watches : http://www.watches-replicas.com/chopard-mille-miglia-watches.html Chopard Happy Snowflake Watches : http://www.watches-replicas.com/chopard-happy-snowflake-watches.html Chopard Imperiale Watches : http://www.watches-replicas.com/chopard-imperiale-watches.html Chopard La Strada Watches : http://www.watches-replicas.com/chopard-la-strada-watches.html Chopard Happy Sport Good Luck Clover Watches : http://www.watches-replicas.com/chopard-happy-sport-good-luck-clover-watches.html Chopard LUC Watches : http://www.watches-replicas.com/chopard-luc-watches.html Chopard H Watches : http://www.watches-replicas.com/chopard-h-watches.html Chopard Happy Spirit Watches : http://www.watches-replicas.com/chopard-happy-spirit-watches.html Chopard Happy Diamonds Watches : http://www.watches-replicas.com/chopard-happy-diamonds-watches.html Chopard Ice Cube Watches : http://www.watches-replicas.com/chopard-ice-cube-watches.html Other Chopard Watches : http://www.watches-replicas.com/other-chopard-watches.html Chopard Happy Sport Happy Hearts Watches : http://www.watches-replicas.com/chopard-happy-sport-happy-hearts-watches.html From bignose+hates-spam at benfinney.id.au Tue Apr 15 19:18:30 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Wed, 16 Apr 2008 09:18:30 +1000 Subject: Testing for callable or iterable (was: Recurring patterns: Am I missing it, or can we get these added to the language?) References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: <874pa2906x.fsf@benfinney.id.au> Erich writes: > def iterable(item, count_str=False): > if not count_str and isinstance(item, str): > return False > try: > iter(item) > except: > return False > return True > This is just simple boolean test for whether or not an object is > iterable. I would like to see this in builtins, to mirror callable. Note that 'callable' is being removed in Python 3.0 . To mirror this, I recommend you remove usage of your 'iterable' function too :-) Seriously, the Pythonic way to handle this is to examine *why* you need to know whether an object is iterable. The only reason I can think of that makes any sense is that you're going to actually iterate over it at some point. In which case, you should omit this 'iterable' check and just iterate over the object when you need to. Python will raise the appropriate exception when it doesn't behave as you expect. No need to LBYL, when Python will tell you about the problem at the time you need to know. Or, you could use the equivalent of the suggestion in PEP 3100: just use 'hasattr(obj, "__iter__")'. But this is inferior to just following EAFP. -- \ "I hope if dogs ever take over the world, and they chose a | `\ king, they don't just go by size, because I bet there are some | _o__) Chihuahuas with some good ideas." -- Jack Handey | Ben Finney From stefan_ml at behnel.de Tue Apr 29 02:14:44 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 29 Apr 2008 08:14:44 +0200 Subject: Sphinx 0.2 released In-Reply-To: References: Message-ID: <4816BCD4.5050600@behnel.de> Hi Georg, Georg Brandl wrote: > I'm pleased to announce the release 0.2 of Sphinx, the Python documentation > generation tool. There were some intermediate smaller releases in the 0.1 > series, but for 0.2 there are quite a lot new features and fixes. > > What is it? > =========== > > Sphinx is a tool that makes it easy to create intelligent and beautiful > documentation for Python projects (or other documents consisting of > multiple reStructuredText source files). I'm wondering, would there be any way to bridge to epydoc? It would be cool to have the two integrated so that you could generate API docs and written docs in one step, with the same look-and-feel. (BTW: yes, I'm advocating not to implement another API documentation tool, but to integrate with an existing one. I would think epydoc matches the requirements quite well here). Stefan From davecook at nowhere.net Thu Apr 10 05:54:03 2008 From: davecook at nowhere.net (David Cook) Date: Thu, 10 Apr 2008 09:54:03 GMT Subject: How is GUI programming in Python? References: Message-ID: <%slLj.46543$f8.32888@newsfe23.lga> On 2008-04-10, Chris Stewart wrote: > I've always had an interest in Python and would like to dabble in it > further. I've worked on a few very small command line programs but > nothing of any complexity. I'd like to build a really simple GUI app > that will work across Mac, Windows, and Linux. How painful is that > going to be? With wxpython and pyqt, it can be relatively painless. You can often just copy your code directly from one OS to the other and run it, and py2exe makes it easy to distribute python apps to windows users. I haven't tried packaging on OS X (with py2app?). > I used to be really familiar with Java Swing a few years > ago. I imagine it will be similar. Yes, the broad principles (event driven, single-threaded event loop) are pretty much the same. Note, if you really like Swing, you can use it from Jython. Your app would install and look like any other Java app to users (Jython is just another jar in your distribution), for good or ill. > Next, what would you say is the best framework I should look into? > I'm curious to hear opinions on that. We use wxPython at work because of the more liberal license. It's very capable and works well for us. However, for my own projects, I've switched to pyqt, which offers more complete application help (e.g. things like Actions) and uses MVC from the ground up rather than as an afterthought. I also find the pyqt API cleaner and more consistent; some aspects of wxpython still seem clunky to me. And the auto-completion solution offered on the wxPython wiki doesn't work on Mac, which pretty much killed it for my project. Dave Cook From bdsatish at gmail.com Thu Apr 24 07:13:49 2008 From: bdsatish at gmail.com (bdsatish) Date: Thu, 24 Apr 2008 04:13:49 -0700 (PDT) Subject: restructured text in python Message-ID: <807d9398-0099-4eee-b0a2-5cb0fbff2124@s33g2000pri.googlegroups.com> Hi all, I have a python prog: #!/usr/bin/env """ Author: BDS Version: 1.0 """ def Hello(): """ Prints a Hello World to the screen""" print "Hello, World" if __name__ == "__main__": Hello() I want to use ReSt (reStructuredText) in my docstrings or comments. Any example of how to do it, w.r.t. above code ? Also how to invoke rst on the Python code to do the processing ? I know how to write in RST but I want to know how to process the resulting Python code From c.boulanger at qxtransformer.org Tue Apr 29 14:30:23 2008 From: c.boulanger at qxtransformer.org (Panyasan) Date: Tue, 29 Apr 2008 11:30:23 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <473deef3-9acb-45dd-a7ca-47b0081bd28c@i36g2000prf.googlegroups.com> <3f7bb91e-335e-46bd-88ca-f15b26c35132@k1g2000prb.googlegroups.com> <827bdae6-4422-4226-a543-af53f5b7e01b@s33g2000pri.googlegroups.com> <083b58e8-522a-4c01-b612-c592fe69fcd1@i36g2000prf.googlegroups.com> Message-ID: <2978ec5b-fd7c-4fb1-9aa5-4bb88ba46ee8@m73g2000hsh.googlegroups.com> On 29 Apr., 18:17, John Henry wrote: > > There are a whole bunch of test programs that comes with Pythoncard. > Do they work? (Not all of them will work - some requires a database) Yes, the examples work. Just the resourceEditor.py and the layoutEditor.py in the distributed version and your modified layoutEditor.py don't. From tatu.kairi at gmail.com Wed Apr 2 08:58:17 2008 From: tatu.kairi at gmail.com (tatu.kairi at gmail.com) Date: Wed, 2 Apr 2008 05:58:17 -0700 (PDT) Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: <76c1d6f1-acfc-4464-9bb7-63c3bae0275e@q27g2000prf.googlegroups.com> On Apr 2, 2:43 pm, GHUM wrote: > Tobu, > > I like this idea. Deducting from an example is really another way to > wisdom. > > What struck me as most diffuclt to understand: > > abs(-5.5) - 5.5 > > -> you are using "-" as symbol for "will give the result", which is > really, really hard to parse. Take something else, please. Unicode has > THAT many cool symbols. Or just -> or -=> or whatever. > > Thanks for sharing that work! > > Harald Or just use comments to indicate text that tells what the code does. I too agree you need to change the '-'. From txtoth at gmail.com Thu Apr 24 15:14:32 2008 From: txtoth at gmail.com (Xavier Toth) Date: Thu, 24 Apr 2008 14:14:32 -0500 Subject: where can I find gdkimlib (imlib bindings)? Message-ID: I'm trying to get some old code that imported GdkImlib to work but I can't find these a current version of these binding, anyone know where they are? -------------- next part -------------- An HTML attachment was scrubbed... URL: From jura.grozni at gmail.com Tue Apr 22 07:53:38 2008 From: jura.grozni at gmail.com (azrael) Date: Tue, 22 Apr 2008 04:53:38 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> Which big aplications are written in python. I see its development, But i can't come up with a big name. I know that there are a lot of companys using python, but is there anythong big written only in python. I want him to fuck of with his perl once and for all time From srf99 at ferg.org Wed Apr 16 12:58:12 2008 From: srf99 at ferg.org (srf99 at ferg.org) Date: Wed, 16 Apr 2008 09:58:12 -0700 (PDT) Subject: question about setup.py and CC and LDSHARED env variables on Solaris Message-ID: Recently I was trying to compile/install cx_Oracle on our Solaris system. When I ran "python setup.py build" I got the following message: "/usr/ucb/cc: language optional software package not installed" I Googled around and discovered that this is a frequently-encountered issue on Solaris systems, because Solaris systems don't have the Solaris C compiler installed by default. (We certainly don't. We use gcc instead.) After poking around in the source code for distutils, I figured out that I could get setup.py to work if -- *before* running setup.py -- I set two environment variables: export CC=gcc export LDSHARED="gcc -G" Afterward, in searching the Web, I couldn't find any documentation to tell me that I had to do this, or why, or when. So my question is: Does anyone know the location of documentation (about distutils, or about using setup.py) that tells you - that you have to do this, - why you have to do it, - the circumstances under which you have to do it? I'm a Unix newbie, so I may very well have missed something obvious. Thanks in advance, -- Steve Ferg From carsten.haese at gmail.com Fri Apr 25 20:40:55 2008 From: carsten.haese at gmail.com (Carsten Haese) Date: Fri, 25 Apr 2008 20:40:55 -0400 Subject: multiple pattern regular expression In-Reply-To: References: <1209131456.20871.1249849011@webmail.messagingengine.com> Message-ID: Nick Stinemates wrote: > On Fri, Apr 25, 2008 at 09:50:56AM -0400, python at bdurham.com wrote: >> How about this? >> >> for line in file: >> # ignore lines without = assignment >> if '=' in line: >> property, value = line.strip().split( '=', 1 ) >> property = property.strip().lower() >> value = value.strip() >> >> # do something with property, value >> >> Malcolm > > This works until you have: > string=The sum of 2+2=4 Actually, it still works, because Malcolm used split()'s maxsplit parameter. -- Carsten Haese http://informixdb.sourceforge.net From sturlamolden at yahoo.no Sat Apr 12 13:00:07 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sat, 12 Apr 2008 10:00:07 -0700 (PDT) Subject: Multiple independent Python interpreters in a C/C++ program? References: Message-ID: <88e07a03-afd4-451e-b815-925a9aa7bc6c@b9g2000prh.googlegroups.com> On Apr 11, 6:24 pm, s... at pobox.com wrote: > Do I wind up with two completely independent interpreters, one per thread? > I'm thinking this doesn't work (there are bits which aren't thread-safe and > are only protected by the GIL), but wanted to double-check to be sure. You can create a new interpreter with a call to Py_NewInterpreter. However, the GIL is a global object for the process. If you have more than two interpreters in the process, they share the same GIL. In tcl, each thread has its own interpreter instance and no GIL is shared. This circumvents most of the problems with a global GIL. In theory, a GIL private to each interpreter would make Python more scalable. The current GIL behaves like the BKL in earlier Linux kernels. However, some third-party software, notably Apache's mod_python, is claimed to depend on this behaviour. From goon12 at gmail.com Tue Apr 29 14:26:19 2008 From: goon12 at gmail.com (Joe Riopel) Date: Tue, 29 Apr 2008 14:26:19 -0400 Subject: Colors for Rows In-Reply-To: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> Message-ID: <6a2ccd190804291126s591e6813y61a23b2f63b2500e@mail.gmail.com> On Tue, Apr 29, 2008 at 10:33 AM, Victor Subervi wrote: > Hi; > > > why doesn't this work? > It never increments z! Yet, if I print z, it will increment and change the > bgcolor! Why?! Are you only trying to "print '\n' % bg" once, or for each iteration of the loop? It might have been the way your message was formatted, but the try/except look like it's out of the for loop. So the print will only run once, after the loop has gone through all d's in id. From arnlen at mac.com Wed Apr 16 09:31:04 2008 From: arnlen at mac.com (Jumping Arne) Date: Wed, 16 Apr 2008 15:31:04 +0200 Subject: Image handling - stupid question References: <0001HW.C42B9FB90009B7E8B01AD9AF@news.individual.de> Message-ID: <0001HW.C42BCC38001425DCB04379AF@news.individual.de> On Wed, 16 Apr 2008 12:21:13 +0200, Jumping Arne wrote (in article <0001HW.C42B9FB90009B7E8B01AD9AF at news.individual.de>): > I'm going to try to write some imange manipulation code (scaling, reading > EXIF and IPTC info) and just want to ask if PIL is *THE* library to use? > > I looked at and noticed that the > latest version is from Dec 2006. > > In my experience that means that either it's abandoned or that it's very good > and stable. > Sounds like PIL is a safe option, thanks. From maxm at mxm.dk Tue Apr 29 09:17:01 2008 From: maxm at mxm.dk (Max M) Date: Tue, 29 Apr 2008 15:17:01 +0200 Subject: Given a string - execute a function by the same name In-Reply-To: <1209471041.12820.1250459017@webmail.messagingengine.com> References: <1209471041.12820.1250459017@webmail.messagingengine.com> Message-ID: <48171FCD.90902@mxm.dk> python at bdurham.com skrev: > Bruno, > But when I release into production I'm going to shift to #3: "Place all > my functions in dictionary and lookup the function to be called". This > technique will allow me to precisely control the dynamic nature of my > application. Just one tiny note: What you will be doing is a variation of the factory pattern. So this search might give you some new ideas: http://www.google.dk/search?hl=en&q=python+factory+pattern -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science From http Thu Apr 17 03:41:33 2008 From: http (Paul Rubin) Date: 17 Apr 2008 00:41:33 -0700 Subject: sampling without replacement References: <6017ea8d-6ee8-44ea-bdad-bf06299a9cd5@a23g2000hsc.googlegroups.com> Message-ID: <7xwsmxudw2.fsf@ruckus.brouhaha.com> braver writes: > Using an array is natural here as it represents "without replacement" > -- we take an element by removing it from the array. But in Python > it's very slow... What approaches are there to implement a shrinking > array with random deletions with the magnitude of millions of > elements? The obvious way is use random.sample(), is there some reason you don't do that? Alternatively, when you select an element a[k] from the middle of the array, instead of deleting that element and moving the rest down (del a[k]), do something like: k = random.randint(0,len(a)-1) selection = a[k] a[k] = a[-1] a.pop() That deletes the last element (avoiding moving them around) after storing it in the newly freed slot. Of course it messes up the order of the array, which won't matter for selecting random elements, but might matter for some other reason in your program. From weiss02121 at gmail.com Tue Apr 15 19:47:26 2008 From: weiss02121 at gmail.com (weiss02121 at gmail.com) Date: Tue, 15 Apr 2008 16:47:26 -0700 (PDT) Subject: lindsay lohan com Message-ID: Just few link on some Lindsay Lohan Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From ewertman at gmail.com Tue Apr 29 22:20:44 2008 From: ewertman at gmail.com (Eric Wertman) Date: Tue, 29 Apr 2008 22:20:44 -0400 Subject: ssh In-Reply-To: <867f5bc7-3748-4303-9f29-9d8044f0d315@m3g2000hsc.googlegroups.com> References: <867f5bc7-3748-4303-9f29-9d8044f0d315@m3g2000hsc.googlegroups.com> Message-ID: <92da89760804291920v79f503b6h7dcdf1de7a8db204@mail.gmail.com> I don't know about the best way.. I use this function, it works ok for me. I have an ssh key stashed already for my user ID, but you could look at the ssh options and supply one on the command line if you needed to. from popen2 import Popen3 def ssh(host,command) : ''' Wraps ssh commands ''' ssh_exec = ['/usr/bin/ssh -qnx -F ssh_config', host, command] cmd = ' '.join(ssh_exec) output,errors,status = process(cmd) return output,errors,status def process(cmd) : proc = Popen3(cmd,-1) output = proc.fromchild.readlines() errors = proc.childerr.readlines() status = proc.poll() return output,errors,status I somtimes call ssh via a Thread object if I need to run a few at the same time. In regards to your question, fork() creates a complete copy of the running process, and returns a 0 in the child (copy). The parent gets the PID of the child as a return code. I don't think there's anything wrong with what you are doing though. I just found that the popen2 module was the easiest to deal with. subprocess is nice, if you have 2.5, but I have to keep 2.3 ish most of the time. The function above could theoretically block if the error pipe gets full before I get to reading it. I can't recall ever getting that much back on stderr though.. so I'm taking the chance. Eric On Tue, Apr 29, 2008 at 9:29 PM, gert wrote: > Is this the best way to use ssh ? > How can i use ssh keys instead of passwords ? > I dont understand what happens when pid does not equal 0 , where does > the cmd get executed when pid is not 0 ? > How do you close the connection ? > > # http://mail.python.org/pipermail/python-list/2002-July/155390.html > import os, time > > def ssh(user, rhost, pw, cmd): > pid, fd = os.forkpty() > if pid == 0: > os.execv("/bin/ssh", ["/bin/ssh", "-l", user, rhost] + cmd) > else: > time.sleep(0.2) > os.read(fd, 1000) > time.sleep(0.2) > os.write(fd, pw + "\n") > time.sleep(0.2) > res = '' > s = os.read(fd, 1) > while s: > res += s > s = os.read(fd, 1) > return res > > print ssh('username', 'serverdomain.com', 'Password', ['ls -l']) > -- > http://mail.python.org/mailman/listinfo/python-list > From sturlamolden at yahoo.no Fri Apr 25 09:34:27 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 25 Apr 2008 06:34:27 -0700 (PDT) Subject: Remove multiple inheritance in Python 3000 References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <60fc4333-6d2b-40f5-b311-031d90a38d39@k37g2000hsf.googlegroups.com> <67dvlbF2nomm6U2@mid.individual.net> Message-ID: <1b19d810-3f47-434b-8935-17911b50bc14@f36g2000hsa.googlegroups.com> On Apr 25, 2:03 pm, Bjoern Schliessmann wrote: > > That's how the Java designers were thinking as well: If MI is > > allowed, programmers will suddenly get an irresistible urge to use > > MI to write unmaintainable spaghetti code. So let's disallow MI > > for the sake of common good. > > Argumenting like that, *all* programming languages had to be > outlawed. 8) James Gosling, grossed by C++ iostreams, also used this argument to disallow operator overloading in Java (except for the String class). That is why Python has NumPy and Java does not. From pavlovevidence at gmail.com Tue Apr 29 16:10:03 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 29 Apr 2008 13:10:03 -0700 (PDT) Subject: list.reverse() References: <4816e26a$0$30938$426a74cc@news.free.fr> Message-ID: <1def8a8f-a50d-424e-9e2a-da517b9891af@34g2000hsh.googlegroups.com> On Apr 29, 9:32 am, Roy Smith wrote: > The reasoning goes along the lines of, "reverse in place is an expensive > operation, so we don't want to make it too easy for people to do". At > least that's the gist of what I got out of the argument the many times it > has come up. Except reversing a list in place isn't expensive at all. I assume you meant "reverse NOT in-place". You're pretty much right but you're missing a step. That an in-place operation is cheaper is the main reason why reverse is destructive, that is true. But it returns None mostly to avoid confusing the user, who is likely to assume that the operation is non-destructive (or forget that it isn't). Carl Banks From deets at nospam.web.de Thu Apr 3 14:28:33 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 03 Apr 2008 20:28:33 +0200 Subject: splitting an XML file on the basis on basis of XML tags In-Reply-To: References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> Message-ID: <65klukF2fp6mkU1@mid.uni-berlin.de> > I abuse it because I can (and because I don't generally work with XML > files larger than 20-30meg) :) > And the OP never said the XML file for 1TB in size, which makes things > different. Even with small xml-files your advice was not very sound. Yes, it's tempting to use regexes to process xml. But usually one falls flat on his face soon - because of whitespace or attribute order or versus or .. or .. or. Use an XML-parser. That's what they are for. And especially with the pythonic ones like element-tree (and the compatible lxml), its even more straight-forward than using rexes. Diez From jason.scheirer at gmail.com Wed Apr 23 21:06:53 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Wed, 23 Apr 2008 18:06:53 -0700 (PDT) Subject: python-ldap - Operations Error References: Message-ID: <8b35f293-fc64-4d21-a621-124c8eafde59@c65g2000hsa.googlegroups.com> On Apr 23, 5:16?pm, theivi... at gmail.com wrote: > Hello all, I am trying to integrate TurboGears with our Active > Directory here at the office. ?TurboGears aside, i cannot get this to > work. ?The simplest thing i can do to test this is: > > >>> import ldap > >>> l = ldap.initialize("ldap://server.net") > >>> l.simple_bind(DN, "secret") > 1 > >>> l.result(1) > (97, []) > >>> l.search("dc=server,dc=net", ldap.SCOPE_SUBTREE, "(sAMAccountName=user)") > > OPERATIONS_ERROR: {'info': '00000000: LdapErr: DSID-0C090627, comment: > In order to perform this operation a successful bind must be completed > on the connection., data 0, vece', 'desc': 'Operations error'} > > The simple bind works fine and returns a result, when i get the > result, it returns 97 meaning successful. ?So there was a successful > bind on the connection, right? ?I'm really not sure where the problems > lies. ?Is it with the way im connecting or is it something to do with > our AD server? > > Thanks Seems more promising: http://tgolden.sc.sabren.com/python/active_directory.html Also, same problem: http://groups.google.com/group/turbogears/browse_thread/thread/10fcd1f9e920d0a8 Also: http://peeved.org/blog/2007/11/20/ Google is pretty awesome when you paste in literal error strings. From aaron.watters at gmail.com Wed Apr 16 12:09:05 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 16 Apr 2008 09:09:05 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <86063f29-21a8-4d5b-a374-cee0723e0852@a22g2000hsc.googlegroups.com> Message-ID: <6894d371-3c3e-4c24-b7ec-4c254ed24afe@24g2000hsh.googlegroups.com> On Apr 16, 11:15 am, Gabriel Genellina wrote: > On 16 abr, 09:56, Aaron Watters wrote: > > > In my opinion python's adherence to backwards compatibility > > has been a bit mythological anyway -- many new python versions > > have broken my old code for no good reason. This is an irritant > > when you have thousands of users out there who suddenly drop > > your code, blame you and python, and move on to use something else. > > Honestly, how hard would it have been to provide standard backwards > > support for the old regex module as a standard module which simply > > translated one regex string format to another, for example? > > Do you mean this? > > py> import reconvert > py> help(reconvert)... Yes I mean it. Actually I was unaware of/forgot reconvert, but it doesn't matter because it doesn't solve the problem of code I wrote that has long ago escaped into the wild no longer working. There are other examples too, having to do with things as simple as a name change in a standard module that broke old code of mine for what I regard as silly cosmetic reasons. I hope you are right about py3k conversions being pain free and routine. I'm suspicious about it however. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=cause+pain From mediocre_person at hotmail.com Thu Apr 3 01:08:42 2008 From: mediocre_person at hotmail.com (Nick J Chackowsky) Date: Thu, 03 Apr 2008 00:08:42 -0500 Subject: Python in High School In-Reply-To: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: <47f45ae2$0$26037$88260bb3@free.teranews.com> sprad wrote: > I'm a high school computer teacher, and I'm starting a series of > programming courses next year (disguised as "game development" classes > to capture more interest). The first year will be a gentle > introduction to programming, leading to two more years of advanced > topics. > I have taught high school comp. sci. for a number of years, using Pascal, Ada, C++, Visual Basic, and Python as languages. Python has, in my opinion, given the students the best opportunity to really discover what programming and computer science are all about. Very high level code without the enormous learning curve for the "extras", plus easy debugging and useful error messages make it ideal. class Example { // your program begins with a call to main() public static void main(String args[]){ System.out.println("this is a simple Java program"); } } vs print ("This is a simple Python program.") Once a student has a grasp of Python and programming, he/she is better prepared to understand _why_ Java and C++ _need_ all the declarations, decorations, and specifications, and why they might be useful. But it's sure nice to start doing real programming in such a simple, elegant environment. Nick. -- Posted via a free Usenet account from http://www.teranews.com From steve at holdenweb.com Thu Apr 24 13:41:34 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 13:41:34 -0400 Subject: function that accepts any amount of arguments? In-Reply-To: <933e4c97-11c8-43b0-81e0-c78ff8573792@26g2000hsk.googlegroups.com> References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> <4810724a$0$23390$426a74cc@news.free.fr> <63ac69bf-9f6d-42bd-8e6e-5b3b17ec7c69@z72g2000hsb.googlegroups.com> <933e4c97-11c8-43b0-81e0-c78ff8573792@26g2000hsk.googlegroups.com> Message-ID: Jonathan Gardner wrote: > On Apr 24, 5:28 am, malkarouri wrote: >> What's wrong with raising ZeroDivisionError (not stopping the >> exception in the first place)? >> > > Because when I use your module, call avg (or mean) without args, I > should see an error that says, "Hey, you have to pass at least one > value in!" > > ZeroDivisonError doesn't mean that. It means I tried to divide by > zero. Naively, I don't see where I was dividing by zero (because I > don't remember how to calculate the mean---that's what your code was > for.) > > ValueError does mean that I didn't pass the right kind of arguments > in. ValueError("No items specified") would be even clearer. (Or maybe > TypeError?) > > In general, any exception thrown should be meaningful to the code you > are throwing it to. That means they aren't familiar with how your code > works. > This is Advice. Software Engineering's next door ;-) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From ABH at MCHSI.COM Tue Apr 8 13:19:47 2008 From: ABH at MCHSI.COM (Hutch) Date: Tue, 08 Apr 2008 17:19:47 GMT Subject: Python 3.0 new integer division References: Message-ID: "Matimus" wrote in message news:b6eafdd4-dbf8-4269-962f-531126bb10c0 at s33g2000pri.googlegroups.com... > On Apr 8, 9:13 am, "Hutch" wrote: >> We now have a float result when two integers are divided in the same >> mannor >> as 2.4 or 2.5. >> I can handle that and use the Floor division but a simple question. >> >> Why in the world would you round down the last presented digit to a 6 >> instead of just leaving it along as an 8. >> For some reason rounding down for a float in Python does not seem >> correct. >> >> IDLE 3.0a4 >> >> >>> 12345678901234567890123456789012345678901234567890/345 >> >> 3.5784576525317586e+46 >> >> >>> 12345678901234567890123456789012345678901234567890//345 >> >> 35784576525317588087314367504383610663481839327 >> ^ >> ^| >> 35784576525317586000000000000000000000000000000 == >> 3.5784576525317586e+46 > > This just has to do with the way floating point numbers are > represented in memory. More information: > http://docs.python.org/tut/node16.html > > Matt Was thinking IBM decimal when I asked the question --should have remembered detail of floats. Thanks Hutch From Lie.1296 at gmail.com Fri Apr 4 19:49:36 2008 From: Lie.1296 at gmail.com (Lie) Date: Fri, 4 Apr 2008 16:49:36 -0700 (PDT) Subject: Newbie Question - Overloading == References: <85edb5fb-eae8-4e8f-8f77-0ee4668063cd@u69g2000hse.googlegroups.com> <7eb5d21a-c4de-4655-ab93-9221d996f424@i7g2000prf.googlegroups.com> Message-ID: On Apr 1, 2:22?pm, Duncan Booth wrote: > "bruno.desthuilli... at gmail.com" wrote: > >> Surely an A isn't equal to every other object which just happens to > >> have the same attributes 'a' and 'b'? > > > And why not ?-) > > >> I would have thoughts the tests want to be > >> something like: > > >> class A: > >> ? ? def __eq__(self,other): > >> ? ? ? ? ?return (isinstance(other, A) and > >> ? ? ? ? ? ? self.a == other.a and self.b == other.b) > > >> (and similar for B) with either an isinstance or exact match required > >> for the type. > > > I don't think there's a clear rule here. Python is dynamically typed > > for good reasons, and MHO is that you should not fight against this > > unless you have equally good reasons to do so. > > I fully agree with that, but an apple != a pear, even if they are the same > size and colour. There will be some types where you can have equality > between objects of different types (e.g. int/float), but more often the > fact that they are different types wil automatically mean they are not > equal. Even though an apple != a pear, sometimes when we just don't need to care between their differences we can treat them as equal, that's what duck typing is. It really depends on your need if you decided to use or not to use isinstance checking, in most cases you'd want them to be checked, but sometimes you just want to know whether the two objects has the same values on their relevant attributes. From grante at visi.com Wed Apr 23 12:31:55 2008 From: grante at visi.com (Grant Edwards) Date: Wed, 23 Apr 2008 11:31:55 -0500 Subject: MESSAGE RESPONSE References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> Message-ID: On 2008-04-22, Blubaugh, David A. wrote: > Is there a way to block these messages. I do not want to be caught > with filth such as this material. I could lose my job with Belcan with > evil messages such as these messages. No, not really. That's one reason I never use my work e-mail address for anything public (Usenet, mailing lists, etc.) -- Grant Edwards grante Yow! I'm into SOFTWARE! at visi.com From mccle27252 at gmail.com Mon Apr 21 03:53:54 2008 From: mccle27252 at gmail.com (mccle27252 at gmail.com) Date: Mon, 21 Apr 2008 00:53:54 -0700 (PDT) Subject: spy sweeper 5.5 crack serial Message-ID: <3d8fd45d-02ba-40aa-8e18-a22009d8daff@z24g2000prf.googlegroups.com> spy sweeper 5.5 crack serial http://cracks.00bp.com F R E E C R A C K S From roy at panix.com Wed Apr 16 19:35:10 2008 From: roy at panix.com (Roy Smith) Date: Wed, 16 Apr 2008 19:35:10 -0400 Subject: How to have unittest tests to be executed in the order they appear? References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> <87zlru7le2.fsf@benfinney.id.au> <87fxtlwi03.fsf@benfinney.id.au> Message-ID: Ben Finney wrote: > Surely, since "suddenly" implies you changed one small area of the > code, that area of the code is the best place to look for what caused > the failure. Sometimes it's the environment that's changed. Yes, I know, a good unit test doesn't depend on the environment, but in real life, that's sometimes difficult to achieve. From carbanancizpo at gmail.com Fri Apr 18 16:59:09 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:59:09 -0700 (PDT) Subject: crack in the world Message-ID: <4a827462-769f-4c06-a98b-c357d30d51e5@2g2000hsn.googlegroups.com> crack in the world http://cracks.12w.net F R E E C R A C K S From roy at panix.com Sun Apr 20 14:49:33 2008 From: roy at panix.com (Roy Smith) Date: Sun, 20 Apr 2008 14:49:33 -0400 Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> <480b6133$0$34498$742ec2ed@news.sonic.net> <3eac67b4-da0a-4926-9ca4-942271513ad2@26g2000hsk.googlegroups.com> Message-ID: In article <3eac67b4-da0a-4926-9ca4-942271513ad2 at 26g2000hsk.googlegroups.com>, sturlamolden wrote: > On Apr 20, 5:28 pm, JB Stern wrote: > > > Curious Steve, how do you pay the rent and by what authority do you > > speak for "The Python world"? Your opinion couldn't be more wrong for > > programmers like myself who live by the code they write (as opposed to > > its support). > > > Are you afraid to show the code to your customer? Are you afraid it > will give you a bad reputatio? Are you worried about loosing future > contracts? Is your code really that bad? Then you better keep it > hidden from sight. > > If this is the case, my advice to you would be to find a different > profession. Perhaps flipping burgers at McDonald's fits your talent? Even if this were worded in a less rude manner, it would be a silly argument. For many businesses, keeping their source code secret is important. Whether you agree with their reasons or not, they feel it is important to them. Hiding your source code is not easy (perhaps impossible) in Python, for reasons which have been covered at length on a regular basis in this forum. If you only ship .pyc or .pyo files, there is still enough information recoverable in the field that most businesses which want to keep their source code hidden would feel excessively exposed. Producing software is all about using tools. Every tool has advantages and disadvantages. The key to using tools effectively is understanding what those are and how they impact your business. If you are lucky, you will find a tool which meets your needs perfectly. More often, you have to weigh all the factors and make the best compromise you can. If keeping your source code secret is of critical importance to your business, then Python is probably the wrong tool to be using to write an application that you're going to ship to customers. If keeping your source code secret is not important to you, that doesn't mean those who do consider it important are stupid, or evil, or better suited for a career spatially reorienting meat by-product patties at a popular restaurant chain. They just have different needs than you do. From deets at nospam.web.de Tue Apr 15 07:49:48 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 15 Apr 2008 13:49:48 +0200 Subject: How to import C++ static library? References: <66j9r8F2k2iplU1@mid.uni-berlin.de> Message-ID: <66jj3oF2ki84vU1@mid.uni-berlin.de> > > Diez: I tried SWIG, and it works nicely with C. For C++, I didn't > manage to make it work. I tried SIP; I have some problems compiling > etc. Would it be too much to ask you to supply a working example of a > (simple, stupid) C++ class and the necessary SIP files? Preferably for > Mac OS X, but Linux is also interesting I guess. I do have some code at home, if I remember this I'll try & post it. However, I suggest you get PyQt and inspect it. And actually I found the SIP-documentation _very_ helpful! Diez From sn at sncs.se Mon Apr 14 19:10:48 2008 From: sn at sncs.se (Sverker Nilsson) Date: Mon, 14 Apr 2008 16:10:48 -0700 (PDT) Subject: py3k s***s Message-ID: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> do i dare to open a thread about this? come on you braver men we are at least not bought by g***le but why? others have said it so many times i think :-//// but why? a few syntactic 'cleanups' for the cost of a huge rewrite of all the code that have been builtup from all the beginning when the once great Python came along and people began to use it and write code for it. Like all that code would have to be rewritten. blaah. and i have perhaps been drinking but i have been p**d all week since i began look into this:-( From alex at computronix.com Thu Apr 3 23:41:19 2008 From: alex at computronix.com (Alex VanderWoude) Date: Fri, 04 Apr 2008 03:41:19 GMT Subject: Figuring out what class instance contains you Message-ID: Consider the following module: ================================ class NewDict(dict): parent = None def __setitem__(self, key, value): print "My parent is", self.parent super(NewDict, self).__setitem__(key, value) class Zero(object): children = NewDict() def __init__(self): self.children.parent = self class One(Zero): pass class Two(One): pass a = One() a.children["spam"] = "baked beans" b = Two() b.children["eggs"] = "bacon" ================================ When the above module is executed, the output looks something like this: My parent is <__main__.One object at 0x00BA27B0> My parent is <__main__.Two object at 0x00B9D170> ...which is great, just what I wanted. Each dictionary instance reports correctly which object instance is its container. However, I would like to find some automagic way of having NewDict figure out what object instance it is on without resorting to having the container class instance poke a reference to itself into the NewDict instance (i.e. the line in Zero.__init__()). I have tried using inspect.getmembers() and walking up the sys._getframe() stack, but to no avail. Am I missing something here? Or is it simply not possible for the NewDict instance to figure out for itself what its container is? From kay.schluehr at gmx.net Sat Apr 12 10:06:43 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 12 Apr 2008 07:06:43 -0700 (PDT) Subject: str(bytes) in Python 3.0 References: Message-ID: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> On 12 Apr., 14:44, Christian Heimes wrote: > Gabriel Genellina schrieb: > > > On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') > > above. But I get the same as repr(x) - is this on purpose? > > Yes, it's on purpose but it's a bug in your application to call str() on > a bytes object or to compare bytes and unicode directly. Several months > ago I added a bytes warning option to Python. Start Python as "python > -bb" and try it again. ;) > > Christian And making an utf-8 encoding default is not possible without writing a new function? From victorsubervi at gmail.com Thu Apr 17 09:45:10 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 17 Apr 2008 08:45:10 -0500 Subject: Importing My Own Script Message-ID: <4dc0cfea0804170645o73b8c72exff0fae3a5b120f8e@mail.gmail.com> Hi: How do I import my own script from a second script? That is, I have script x and I want to import script y. How? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From aahz at pythoncraft.com Sun Apr 20 22:50:25 2008 From: aahz at pythoncraft.com (Aahz) Date: 20 Apr 2008 19:50:25 -0700 Subject: Finally had to plonk google gorups. References: Message-ID: In article , Grant Edwards wrote: > >This morning almost half of c.l.p was spam. In order to try to not tar >both the benign google group users and the malignant ones with the same >brush, I've been trying to kill usenet spam with subject patterns. But >that's not a battle you can win, so I broke down and joined all the >other people that just killfile everything posted via google.groups. For some reason, I don't see that much. Maybe it's because my ISP still honors cancels. ;-) -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "It is easier to optimize correct code than to correct optimized code." --Bill Harlan From marco at sferacarta.com Tue Apr 29 07:59:07 2008 From: marco at sferacarta.com (Marco Mariani) Date: Tue, 29 Apr 2008 13:59:07 +0200 Subject: Zope/DTML Infuriating... In-Reply-To: References: Message-ID: Jens wrote: > I've the checked that i'm referring to the variables correctly, so the > only explanation i can come up with, is that '+' doesn't result in a > string concatenation (with implicit typecast to string of the integer > variable(this is a interpreted language after all)). No, sorry. You really need to read the python tutorial at the very least. You might have wrong assumptions from previous PHP experiences. >>> 'x'+4 Traceback (most recent call last): File "", line 1, in TypeError: cannot concatenate 'str' and 'int' objects >>> From ellingt8877 at gmail.com Mon Apr 28 01:44:05 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:44:05 -0700 (PDT) Subject: software utility to crack games Message-ID: software utility to crack games http://crack.cracksofts.com From mattheww at chiark.greenend.org.uk Tue Apr 1 18:16:29 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 01 Apr 2008 23:16:29 +0100 (BST) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> Message-ID: <1Ul*p0k-r@news.chiark.greenend.org.uk> Aaron Watters wrote: > I've been poking around the world of object-relational > mappers and it inspired me to coin a corellary to the > the famous quote on regular expressions: > "You have objects and a database: that's 2 problems. > So: get an object-relational mapper: > now you have 2**3 problems." > That is to say I feel that they all make me learn > so much about the internals and features of the > O-R mapper itself that I would be better off rolling > my own queries on an as-needed basis without > wasting so many brain cells. That is the conclusion I have come to. When a difficult question comes up, you end up having to know the exact requirements and behaviour of the underlying database anyway. Then once you know what sequence of commands you need to be issued, you have to figure out how to persuade the ORM to do it (and not something similar but subtly wrong). At this stage it's getting in your way. -M- From lbonafide at yahoo.com Tue Apr 15 13:37:15 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Tue, 15 Apr 2008 10:37:15 -0700 (PDT) Subject: Java or C++? References: Message-ID: On Apr 15, 11:55?am, egbert wrote: > What is the role or position of C# in this context ? > If I remember well, some people have said that C# is an improved > C++ or Java. C# is more similar to Java than C++. Neither is very similar to C++, except in some cosmetic syntactic ways. Personally, that would be my last choice. C++ is the most portable of the three, and the only non- proprietary one (like Python). From evenson at gmail.com Sun Apr 20 13:07:51 2008 From: evenson at gmail.com (evenrik) Date: Sun, 20 Apr 2008 10:07:51 -0700 (PDT) Subject: Checking if a text file is blank References: Message-ID: <5c73a304-797e-49b5-bae5-78ed20715785@1g2000prg.googlegroups.com> On Apr 20, 2:04 pm, elno... at gmail.com wrote: > Greetings! > > I've just started learning python, so this is probably one of those > obvious questions newbies ask. > > Is there any way in python to check if a text file is blank? > > What I've tried to do so far is: > > f = file("friends.txt", "w") > if f.read() is True: > """do stuff""" > else: > """do other stuff""" > f.close() > > What I *mean* to do in the second line is to check if the text file is > not-blank. But apparently that's not the way to do it. > > Could someone set me straight please? I use os.path.getsize(path) for this purpose. From marco at sferacarta.com Thu Apr 3 08:56:26 2008 From: marco at sferacarta.com (Marco Mariani) Date: Thu, 03 Apr 2008 14:56:26 +0200 Subject: who said python can't be obsfucated!? In-Reply-To: <47f4b69b$0$19766$426a74cc@news.free.fr> References: <47f4b69b$0$19766$426a74cc@news.free.fr> Message-ID: Bruno Desthuilliers wrote: > sig=lambda m:'@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p > in m.split('@')]) Pff... you call that a quicksort? From http://www.p-nand-q.com/python/obfuscated_python.html import sys funcs = range(10) def A(_,o): _[3]=_[5]() def B(_,o): o[_[2]]=_[9]() def C(_,o): _[3]=_[7]() def D(_,o): o[_[1]]=_[14]() def E(_,o): _[1]=_[4]() def F(_,o): _[2]=_[6]() def G(_,o,O): if _[O[0]]():return O[-1](_,o) or 1 def H(o, start, stop): _=[o[stop],[lambda x,y:x+y,lambda x,y:x-y,lambda x, y:y|1,0,0][1](start,funcs[4](range(funcs[3](), len(o[:])))),stop,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] for i in range(4,19): _[i]=lambda _=_,o=o,s="reduce([lambda x,y:x+y,lambda "\ "x,y:x-y,lambda x,y:y|1,0,0][0],[_[1],funcs[4]("\ "range(eval(\"funcs[3]()\"),_[10]()))])$funcs[4"\ "](range(eval(\"funcs[3]()\"),_[10]()))$[lambda"\ " x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,0,0][1]"\ "(_[2],funcs[4](range(funcs[3](),_[10]())))$fun"\ "cs[4](range(funcs[3](),_[10]()))$range(_[10]()"\ "*_[10]())$o[:][_[1]]$len(o[:])$not _[3]$_[1]=="\ "_[2]$o[:][_[1]]>_[0]$o[:][_[2]]$o[_[2]]<_[0]$_"\ "[2]==_[1]$_[11]() and not E(_,0) and not G(_,o"\ ",[12,A]) and not G(_,o,[13,B])$_[11]() and not"\ " F(_,_) and not G(_,o,[16,C]) and not G(_,o,[1"\ "5,D])".split('$')[:][i-4]:eval("eval('eval(s)')") while _[11](): while _[17](): pass while _[18](): pass o[_[2]] = _[0] return _[2] def quicksort(list,start,stop): exec('funcs[3] = lambda:reduce([lambda x,y:x+y,lambda x,y'\ ':x-y,lambda x,y:y|1,0,0][1],[[lambda x,y:x+y,lambda'\ ' x,y:x-y,lambda x,y:y|1,0,0][2](200,200)]*2)\nfuncs'\ '[4] = lambda x:reduce(lambda x,y:y%2,range(eval("re'\ 'duce([lambda x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,'\ '0,0][2],[len(o[:]),len(o[:])])"),eval("reduce([lamb'\ 'da x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,0,0][2],[l'\ 'en(o[:]),len(o[:])])")+((len(o)and 3)or 3)))\nif st'\ 'art < stop:\n\tsplit = H(list, start, stop)\n\tquic'\ 'ksort(list, start, [lambda x,y:x+y,lambda x,y:x-y,l'\ 'ambda x,y: y|1,0,0][1](split,funcs[4](funcs[3]())))'\ '\n\tquicksort(list, reduce([lambda x,y:x+y,lambda x'\ ',y:x-y,lambda x,y:y|1,0,0][0],[split,funcs[4](funcs'\ '[3]())]), stop)\n') # test code: 2000 elements to sort list = [] import whrandom,time for i in range(2000): list.append(whrandom.randint(1,100)) start = time.clock() quicksort(list,0,len(list)-1) print "Sorting took %.2f" % (time.clock() - start) # just a test loop to see if everything *is* sorted element = -1 for i in list: if i >= element: element = i else: print "FUNK DAT: %20s" % str(i) break From cesugden at gmail.com Thu Apr 24 12:39:26 2008 From: cesugden at gmail.com (Chris) Date: Thu, 24 Apr 2008 09:39:26 -0700 (PDT) Subject: Installer Message-ID: Hey all, I've created a python program that relies on pysqlite, wxpython, and matplotlib. Is there any way of creating an installer that will install all these modules, python 2.5 and my program? Thanks. From pavlovevidence at gmail.com Tue Apr 22 10:22:12 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 22 Apr 2008 07:22:12 -0700 (PDT) Subject: Remove multiple inheritance in Python 3000 References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <6760jfF2n3bn1U1@mid.uni-berlin.de> Message-ID: On Apr 22, 7:30 am, "Diez B. Roggisch" wrote: > GD schrieb: > > > Please remove ability to multiple inheritance in Python 3000. > > > Multiple inheritance is bad for design, rarely used and contains many > > problems for usual users. > > > Every program can be designed only with single inheritance. > > Yes, sure. And that's why Java grew interfaces & it's class-diagrams are > hilariously complex. Because using single inheritance is so much better. I have a couple issues with this, though I wholeheartedly agree with the sentiment: 1. Java didn't grow interfaces, they were there from the start. 2. Java interfaces solve a different problem than MI (used properly) does: interfaces are there to make types polymorphic, whereas inheritance's main use is to share behavior. Too many people believe polymorphism is the only noble goal of OO. If that were true, there'd be no reason for multiple inheritance, or single inheritance for that matter. But in my opinion, minimizing code redundancy by allowing classes to share behaviors is far more useful and important. That's why I wholeheartedly favor MI: it allows classes to share behavior with restraints. Java (for example) allows a class to share behavior with only one other class, and that *severely* limits the opportunities to minimize redundancy. Carl Banks From arnodel at googlemail.com Fri Apr 11 07:02:22 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Fri, 11 Apr 2008 04:02:22 -0700 (PDT) Subject: @x.setter property implementation References: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> <02cb2845-6a25-4e90-9f82-dbd68b37a5e6@p39g2000prm.googlegroups.com> <2c589c82-85e9-4db6-b8f9-156b06dd51f3@s33g2000pri.googlegroups.com> <3238aeb7-cd1b-463d-ad87-0d28dcee0202@a1g2000hsb.googlegroups.com> Message-ID: <41ba2942-3462-4882-9f56-18139c1f916b@x41g2000hsb.googlegroups.com> On Apr 11, 11:19?am, Floris Bruynooghe wrote: [...] > > Unfortunatly both this one and the one I posted before work when I try > > them out on the commandline but both fail when I try to use them in a > > module. ?And I just can't figure out why. > > This in more detail: Imaging mod.py: > > import sys > > _property = property > > class property(property): > ? ? """Python 2.6/3.0 style property""" > ? ? def setter(self, fset): > ? ? ? ? cls_ns = sys._getframe(1).f_locals > ? ? ? ? for k, v in cls_ns.iteritems(): > ? ? ? ? ? ? if v == self: > ? ? ? ? ? ? ? ? propname = k > ? ? ? ? ? ? ? ? break > ? ? ? ? cls_ns[propname] = property(self.fget, fset, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? self.fdel, self.__doc__) > ? ? ? ? return fset > > class Foo(object): > ? ? @property > ? ? def x(self): > ? ? ? ? return self._x > > ? ? @x.setter > ? ? def x(self, v): ^^^^^ Don't call this 'x', it will override the property, change it to 'setx' and everything will work. The same probably goes for your own 'propset' decorator function. > ? ? ? ? self._x = v + 1 > > Now enter the interpreter: > >> import mod > >>> f = mod.Foo() > >>> f.x = 4 > >>> f.x > > 4 > > I don't feel like giving up on this now, so close... -- Arnaud From ivan.illarionov at gmail.com Fri Apr 11 10:13:28 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Fri, 11 Apr 2008 07:13:28 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <31872ffc-5bc4-44c8-961d-ee4f0dc356c5@k1g2000prb.googlegroups.com> <700b1a5f-0af0-466e-abda-4d8dc784dbaa@e67g2000hsa.googlegroups.com> Message-ID: <220fa9fa-3ad3-4d58-b90c-478f936b5352@m1g2000pre.googlegroups.com> On Apr 11, 5:49 pm, hdante wrote: > On Apr 11, 9:45 am, bdsatish wrote: > > > > > On Apr 11, 5:33 pm, bdsatish wrote: > > > > HI Gerard, > > > > I think you've taken it to the best possible implementation. Thanks ! > > > On Apr 11, 5:14 pm, Gerard Flanagan wrote: > > > > > In fact you can avoid the call to the builtin round: > > > > > ------------------------------------------------ > > > > > assert myround(3.2) == 3 > > > > assert myround(3.6) == 4 > > > > assert myround(3.5) == 4 > > > > assert myround(2.5) == 2 > > > > assert myround(-0.5) == 0.0 > > > > assert myround(-1.5) == -2.0 > > > > assert myround(-1.3) == -1.0 > > > > assert myround(-1.8) == -2 > > > > assert myround(-2.5) == -2.0 > > > > ------------------------------------------------ > > > OK, I was too early to praise Gerard. The following version: > > > def myround(x): > > n = int(x) > > if abs(x - n) >= 0.5 and n % 2: > > return n + 1 - 2 * int(n<0) > > else: > > return n > > > of Gerard doesn't work for 0.6 (or 0.7, etc.) It gives the answer 0 > > but I would expect 1.0 ( because 0.6 doesn't end in 0.5 at all... so > > usual rules of round( ) apply) > > Interestingly, you could solve this by using python 3. :-) > round(x[, n]) > Return the floating point value x rounded to n digits after the > decimal point. If n is omitted, it defaults to zero. Values are > rounded to the closest multiple of 10 to the power minus n; if two > multiples are equally close, rounding is done toward the even choice > (so, for example, both round(0.5) and round(-0.5) are 0, and > round(1.5) is 2). Delegates to x.__round__(n). > > My turn: ;-) > > def yaround(x): > i = int(x) > f = x - i > if f != 0.5 and f != -0.5: return round(x) > return 2.0*round(x/2.0) > > a = (-10.0, -9.0, -8.0, -4.6, -4.5, -4.4, -4.0, -3.6, -3.5, > -3.4, -0.6, -0.5, -0.4, 0.0, 0.4, 0.5, 0.6, 0.9, 1.0, > 1.4, 1.5, 1.6, 2.0, 2.4, 2.5, 2.6, 10.0, 100.0) > > b = (-10.0, -9.0, -8.0, -5.0, -4.0, -4.0, -4.0, -4.0, -4.0, > -3.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, > 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 3.0, 10.0, 100.0) > > for i in range(len(a)): > assert yaround(a[i]) == b[i] Shorter version: def round3k(x): return x % 1 != 0.5 and round(x) or round(x / 2.) * 2. nums = [ 0, 2, 3.2, 3.6, 3.5, 2.5, -0.5, -1.5, -1.3, -1.8, -2.5, 0.6, 0.7 ] rnums = [ 0, 2, 3.0, 4.0, 4.0, 2.0, -0.0, -2.0, -1.0, -2.0, -2.0, 1.0, 1.0 ] for num, rnum in zip(nums, rnums): assert even_round(num) == rnum, '%s != %s' % (even_round(num), rnum) print num, '->', even_round(num) It makes sense to add `from __future__ import even_round` to Python 2.6. From silfheed at gmail.com Fri Apr 11 03:36:11 2008 From: silfheed at gmail.com (Silfheed) Date: Fri, 11 Apr 2008 00:36:11 -0700 (PDT) Subject: CDATA and lxml Message-ID: <5ebe3201-80a6-45ba-8b88-e8ece6883efa@w8g2000prd.googlegroups.com> Heyas So first off I know that CDATA is generally hated and just shouldn't be done, but I'm simply required to parse it and spit it back out. Parsing is pretty easy with lxml, but it's the spitting back out that's giving me issues. The fact that lxml strips all the CDATA stuff off isnt really a big issue either, so long as I can create CDATA blocks later with <>&'s showing up instead of <>& . I've scoured through the lxml docs, but probably not hard enough, so anyone know the page I'm looking for or have a quick how to? Thanks! From dickinsm at gmail.com Thu Apr 17 09:38:11 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Thu, 17 Apr 2008 06:38:11 -0700 (PDT) Subject: def power, problem when raising power to decimals References: Message-ID: <88a9c416-2a52-450f-9608-4ad6ac6e1abc@p25g2000hsf.googlegroups.com> On Apr 16, 11:03?pm, "Terry Reedy" wrote: > | decimal.InvalidOperation: 0 ** 0 > > I would think of this as a bug unless the standard Decimal follows demands > this. It does. From http://www2.hursley.ibm.com/decimal/daops.html#refpower : "If both operands are zero, or if the left-hand operand is less than zero and the right-hand operand does not have an integral value[7] or is infinite, an Invalid operation condition is raised, the result is [0,qNaN], and the following rules do not apply." I'm hoping that this will change with the next update of the standard. Mark From skanemupp at yahoo.se Thu Apr 10 08:11:53 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 05:11:53 -0700 (PDT) Subject: questions about Exceptions? References: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> <71cc8c25-f5f9-4f21-a9d8-06780bf97608@f63g2000hsf.googlegroups.com> <9af81b1a-3e02-4406-b9d2-0a9b6f46566b@p39g2000prm.googlegroups.com> <0e586d5d-6799-433f-b8a4-4de5d2a87b61@h1g2000prh.googlegroups.com> <46a79564-4069-46af-b6ab-b38bd9152c2a@d45g2000hsc.googlegroups.com> <1f413b6e-f964-4f8d-b781-61985f86acc2@a9g2000prl.googlegroups.com> <1473f09e-936f-4e35-830d-ecf999976c55@f63g2000hsf.googlegroups.com> Message-ID: <1feb1641-ed06-448a-849b-20a365efc4c7@c19g2000prf.googlegroups.com> from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") l = Label(mygui, text="Answer: ") l.place(relx=0.15, rely=0.2, anchor=CENTER) e = Entry(mygui) e.place(relx=0.4, rely=0.1, anchor=CENTER) def Disp(nstr): e.insert(END, nstr) def Calc(): expr=e.get() try: b = Label(mygui, text=eval(expr)) b.place(relx=0.4, rely=0.2, anchor=CENTER) except: b = Label(mygui, text="Not computable") b.place(relx=0.4, rely=0.2, anchor=CENTER) def Erase(): e.delete(0,END) x = 0.1 y = 0.4 for char in '123+456-789*0^./()': b = Button(mygui, text=char,command=lambda n=char:Disp(n), width=2, height=1) b.place(relx=x, rely=y, anchor=CENTER) x=x+0.1 if x==0.5: x=0.1 y=y+0.1 b = Button(mygui, text="C",command=Erase, width=2, height=1) b.place(relx=0.3, rely=0.8, anchor=CENTER) b = Button(mygui, text="=",command=Calc, width=2, height=1) b.place(relx=0.4, rely=0.8, anchor=CENTER) mygui.mainloop() From kyosohma at gmail.com Wed Apr 23 13:56:02 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 23 Apr 2008 10:56:02 -0700 (PDT) Subject: Python development tools References: Message-ID: <72fa1da4-ae68-4493-8fbc-a7d21d1c3b8c@y21g2000hsf.googlegroups.com> On Apr 23, 12:39?pm, "wongjoek... at yahoo.com" wrote: > Are there any completely free developent tools for python scripts like > IDLE. I have used IDLE , but I want to try out others also. I saw > stuff like PyCrust, but I don't see that it can run the script as > well. > Thanks, > > RR Check out PyDev for Eclipse. It's like Visual Studio for Python...I actually find it kind of clunky, but it is cool! To see what else there is, check out the Python wiki: http://wiki.python.org/moin/PythonEditors Mike From littlesweetmelon at gmail.com Mon Apr 7 01:30:50 2008 From: littlesweetmelon at gmail.com (=?GB2312?B?zPC5zw==?=) Date: Mon, 7 Apr 2008 13:30:50 +0800 Subject: Basic optimization of python. Message-ID: Howdy, I wonder whether python compiler does basic optimizations to .py. Eg: t = self.a.b t.c = ... t.d = ... .vs. self.a.b.c = ... self.a.b.d = ... which one is more effective? Since each dot invokes a hash table lookup, it may be time consuming. If the compiler can do expression folding, then no manual folding is needed. Again, how about contant calculation? Eg: a = 1 + 2 .vs. a = 3 which one is more effective? Does the compiler calculate the result at compile time? How about constant spreading? Best regards, --- ShenLei -------------- next part -------------- An HTML attachment was scrubbed... URL: From skanemupp at yahoo.se Sun Apr 6 16:38:20 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 6 Apr 2008 13:38:20 -0700 (PDT) Subject: How to create an exe-file? Message-ID: <311a216f-5366-47c5-86a7-431dd23ced3e@j1g2000prb.googlegroups.com> how do you create exe-files of your python-code? is it different depending on what libraries, GUI-frameworks you use? i want to create an exe-file of a pythonscript that uses Tkinter. From nospam at invalid.com Thu Apr 24 23:39:58 2008 From: nospam at invalid.com (Jack) Date: Fri, 25 Apr 2008 03:39:58 GMT Subject: ctypes: return a pointer to a struct References: <846077c3-beaf-4ccd-83be-1e2168c4f7fe@c65g2000hsa.googlegroups.com> <4dda2bd7-3348-496e-a594-35da0a34d4de@x35g2000hsb.googlegroups.com> Message-ID: Thanks for the prompt and detailed reply. I tried that but was getting this error: AttributeError: 'LP_IP2LocationRecord' object has no attribute 'country_short' Here's my version, which I think is equivalent to yours: (as a matter of fact, I also tried yours and got the same error.) class IP2LocationRecord(Structure): _fields_ = [("country_short", c_char_p), ("country_long", c_char_p), ("region", c_char_p), ("city", c_char_p), ("isp", c_char_p), ("latitude", c_float), ("longitude", c_float), ("domain", c_char_p), ("zipcode", c_char_p), ("timezone", c_char_p), ("netspeed", c_char_p)] IP2Location_get_all.restype = POINTER(IP2LocationRecord) IP2LocationObj = IP2Location_open(thisdir + '/IP-COUNTRY-SAMPLE.BIN') rec = IP2Location_get_all(IP2LocationObj, '64.233.167.99') print rec.country_short IP2Location_close(IP2LocationObj) "sturlamolden" wrote in message news:4dda2bd7-3348-496e-a594-35da0a34d4de at x35g2000hsb.googlegroups.com... > On Apr 25, 5:15 am, sturlamolden wrote: > >> First define a struct type IP2LocationRecord by subclassing from >> ctypes.Structure. Then define a pointer type as >> ctypes.POINTER(IP2LocationRecord) and set that as the function's >> restype attribute. See the ctypes tutorial or reference for details. > > Which is to say: > > import ctypes > > class IP2LocationRecord(ctypes.Structure): > _fields_ = [ > ('country_short', ctypes.c_char_p), > ('country_long', ctypes.c_char_p), > ('region', ctypes.c_char_p), > ('city', ctypes.c_char_p), > ('isp', ctypes.c_char_p), > ('latitude', ctypes.c_float), > ('longitude', ctypes.c_float), > ('domain', ctypes.c_char_p), > ('zipcode', ctypes.c_char_p), > ('timezone', ctypes.c_char_p), > ('netspeed', ctypes.c_char_p), > ] > > IP2LocationRecord_Ptr_t = ctypes.POINTER(IP2LocationRecord) > > function.restype = IP2LocationRecord_Ptr_t > > From apavluck at gmail.com Mon Apr 28 13:52:11 2008 From: apavluck at gmail.com (Alex Pavluck) Date: Mon, 28 Apr 2008 10:52:11 -0700 (PDT) Subject: xcode able to run script? Message-ID: <31c47061-7038-4868-8422-a8da0f6d7437@m45g2000hsb.googlegroups.com> Does anyone know if it is possible to test your scripts from within the xcode editor? I am currently using Uilipad on windows and there is a sub window that lets you view your output when you launch the script from within the ide. hopefully this makes sense. thanks, Alex From deets at nospam.web.de Wed Apr 9 16:58:23 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 09 Apr 2008 22:58:23 +0200 Subject: basic python question about for loop In-Reply-To: References: Message-ID: <664ovoF2iq9i0U1@mid.uni-berlin.de> jmDesktop schrieb: > From the Python.org tutorial: > >>>> for n in range(2, 10): > ... for x in range(2, n): > ... if n % x == 0: > ... print n, 'equals', x, '*', n/x > ... break > ... else: > ... # loop fell through without finding a factor > ... print n, 'is a prime number' > ... > 2 is a prime number > 3 is a prime number > 4 equals 2 * 2 > 5 is a prime number > 6 equals 2 * 3 > 7 is a prime number > 8 equals 2 * 4 > 9 equals 3 * 3 > > > > first time 2 mod 2, 2/2, no remainder == 0, what am I doing wrong? > Why did it fall through? print out what range(2, n) for n == 2 is. And if you didn't know - 2 *IS* a prime. Diez From gagsl-py2 at yahoo.com.ar Sat Apr 5 01:28:42 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 05 Apr 2008 02:28:42 -0300 Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <7113d012-01bb-4426-bb40-9e2811cdb102@x41g2000hsb.googlegroups.com> <3cf4bbc8-b828-45c5-b9a8-766ce600af43@y21g2000hsf.googlegroups.com> Message-ID: En Sat, 05 Apr 2008 02:02:45 -0300, escribi?: > one thing i dont rally get, i ahve to add my_button.bind() somewhere? > i changed the stuff u said though and i get this error(the program > executes though and i can press the buttons): Either use command, or bind. command requires a function with no parameters (or a bound method with self alone). bind uses a function with a single parameter, the event (or a bound method with self and event parameters). See the Tkinter book: http://www.effbot.org/tkinterbook/tkinter-events-and-bindings.htm http://www.effbot.org/tkinterbook/button.htm -- Gabriel Genellina From lists at cheimes.de Sun Apr 20 12:07:41 2008 From: lists at cheimes.de (Christian Heimes) Date: Sun, 20 Apr 2008 18:07:41 +0200 Subject: Alternate indent proposal for python 3000 In-Reply-To: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: Eric Wertman schrieb: > I was considering putting together a proposal for an alternate block > syntax for python, and I figured I'd post it here and see what the > general reactions are. I did some searching, and while I found a lot > of tab vs space debates, I didn't see anything like what I'm thinking > of, so forgive me if this is a very dead horse. You are definitely too late to propose a change for py3k. > I feel that including some optional means to block code would be a big > step in getting wider adoption of the language in web development and > in general. I do understand though, that the current strict indenting > is part of the core of the language, so... thoughts? Why should Python repeat the mistakes other languages did with SSI or inline code? Python favors the MVC separation of code and layout. Christian From ian.team.python at saltmob.com Tue Apr 8 22:21:51 2008 From: ian.team.python at saltmob.com (ian) Date: Tue, 8 Apr 2008 19:21:51 -0700 (PDT) Subject: style question - hasattr Message-ID: In old python code i would use 'has_key' to determine if an element was present in a dictionary. Python 3.0 will even removed 'has_key'. The reason for removal is that using the 'in' operator is a cleaner syntax and having two ways to achieve the same result is against the principle of the language. Ok, so what about 'hasattr' ?? hasattr(myObject,'property') seems equivalent to 'property' in dir(myObject) I would suggest that using the 'in' is cleaner in this case also. Is there a performance penalty here? Or is there reason why the two are not actually the same? Which style is preferred?? From deets at nospam.web.de Tue Apr 1 18:57:47 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 02 Apr 2008 00:57:47 +0200 Subject: Not Sure This Can Be Done... In-Reply-To: <13777863-548e-4318-9b03-d64ccc3eebea@d21g2000prf.googlegroups.com> References: <46aeae28-4470-4136-a5f6-040f6468eb32@b5g2000pri.googlegroups.com> <65fmclF2f352gU1@mid.uni-berlin.de> <13777863-548e-4318-9b03-d64ccc3eebea@d21g2000prf.googlegroups.com> Message-ID: <65fsveF2ej0d1U1@mid.uni-berlin.de> gamename schrieb: >> Use virtualenv to create a local python, and activate that when >> developing for that branch. > > Thanks for the suggestion, but that's the problem: having to activate > it. > Isn't there some way to simply have the local script look at a > specified > dir rather than starting a virtual environment? You can only do that yourself - you can write a helper-module that will inspect the environment, locates the module, and appends it path to sys.path. Diez From gh at ghaering.de Thu Apr 10 05:06:21 2008 From: gh at ghaering.de (=?ISO-8859-1?Q?Gerhard_H=E4ring?=) Date: Thu, 10 Apr 2008 11:06:21 +0200 Subject: I am worried about Python 3 In-Reply-To: <47fce3ca$0$36346$742ec2ed@news.sonic.net> References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> <47fce3ca$0$36346$742ec2ed@news.sonic.net> Message-ID: <6663kdF2j5bs0U1@mid.uni-berlin.de> John Nagle wrote: > jmDesktop wrote: > >> If I continue in Python 2.5.x, am I making a mistake? Is it really >> that different? > > No. It may never happen, either. The Perl crowd tried > something like this, Perl 6, which was announced in 2000 and still > hasn't come out. The C++ standards committee has been working on a > revision of C++ since the 1990s, and that hasn't happened either. > > The general consensus is that Python 3.x isn't much of an > improvement over the existing language. There's just not much > demand for it. The difference is that Guido learnt from the mistakes of Perl 6 and set much more realistic (moderate) goals for Python 3.0. Unlike others, I think that Python 3.0 will get popular sooner than you think. Imagine: - you're the developer of an Open Source Python library - for fame and glory, you port it to Python 3.0 - you realize that maintaining two branches is cumbersome - Python 3.0 becomes first class - Users switch to ... -- Gerhard From stef.mientki at gmail.com Fri Apr 11 17:40:00 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Fri, 11 Apr 2008 23:40:00 +0200 Subject: win-shortcuts, file associates and command-line parameters ? In-Reply-To: References: <47FE6480.4090602@gmail.com> Message-ID: <47FFDAB0.1020502@gmail.com> Gabriel Genellina wrote: > En Thu, 10 Apr 2008 16:03:28 -0300, Stef Mientki > escribi?: > > >> under windows I tried to make a shortcut to a py -file, to run a program. >> So making a shortcut like this works perfect: >> D:\PyLab_Works.py >> >> But the problem is that I need to give some commandline parameters to >> the py-file, >> and >> >> D:\PyLab_Works.py btc_test >> But the parameter doesn't seem to arrive in the python program >> > > Check the associated command for .py files; see this message > http://groups.google.com/group/comp.lang.python/msg/056ba14ae4fa57e3 > > Didn't work for me winXP-SP2, even after a restart :-( But anyway thanks for the effort. cheers, Stef Mientki From victorsubervi at gmail.com Thu Apr 17 15:19:12 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 17 Apr 2008 14:19:12 -0500 Subject: Error Handling Message-ID: <4dc0cfea0804171219l7e4c749dpfd13f9bb35294e1a@mail.gmail.com> Hi; I have the following code: try: cursor.execute(sql) print '?Exito en introducir!
' print 'Esta p?gina va a regresar a la p?gina principal del carrito de compras en 10 segundos.' except IntegrityError: print 'Lo siento, pero el ID que entraste est? usado actualmente por otra entrada. Favor de dar para atr?z y escojer otro n?mero.' except OperationalError: print 'Lo siento, pero has a?adido un car?cter extra?o a un n?mero (o en "ID", "precio", "rec?maras" o "ba?os". Favor de dar para atr?z y escojer otro n?mero.' except: print 'Lo siento, pero hay un error. Favor de dar para atr?z y averiguar donde est? el error, y reintentar.' When I enter and ID that is not a number, it should trigger the IntegrityError. Instead, I get this in the error log: [Thu Apr 17 12:06:37 2008] [error] [client 190.166.0.245] PythonHandler mod_python.cgihandler: NameError: global name 'IntegrityError' is not defined, referer: http://livestocksling.com/bre/iud.py When I enter a non-digit in a float, I should get an OperationalError. Instead, I get more garbage: [Thu Apr 17 12:10:38 2008] [error] [client 190.166.0.245] PythonHandler mod_python.cgihandler: NameError: global name 'OperationalError' is not defined, referer: http://livestocksling.com/bre/iud.py What do? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From hat at se-162.se.wtb.tue.nl Thu Apr 24 03:38:16 2008 From: hat at se-162.se.wtb.tue.nl (A.T.Hofkamp) Date: Thu, 24 Apr 2008 09:38:16 +0200 Subject: Unix Device File Emulation References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> <480f6376$0$9037$5402220f@news.sunrise.ch> <9ee87070-be57-4a66-a152-3f36c1cc8f0c@k13g2000hse.googlegroups.com> <480f7983$0$9036$5402220f@news.sunrise.ch> <49529b68-88b4-4115-a85a-587528274a50@m73g2000hsh.googlegroups.com> Message-ID: On 2008-04-23, blaine wrote: > On Apr 23, 2:01 pm, "Martin Blume" wrote: >> "blaine" schrieb >> No, >> while 1: >> r = self.fifodev.readline() >> if r: print r >> else: time.sleep(0.1) >> is ok (note the "if r:" clause). >> >> Martin > > Beautiful! Thanks Martin! yes, but you have to follow the usual file handling rules, and close/re-open the fifo after detecting EOF. You will be blocked on attempting to re-open until there is another writing process. while 1: fp = open('my_fifo', 'r') while 1: line = fp.readline() if line == '': break print line.rstrip() # To prevent printing of \n in line fp.close() Albert From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 1 14:23:32 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 01 Apr 2008 20:23:32 +0200 Subject: Python in High School In-Reply-To: References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> Message-ID: <47f27da1$0$17187$426a74cc@news.free.fr> sprad a ?crit : > On Apr 1, 11:41 am, mdomans wrote: >> Python needs no evangelizing but I can tell you that it is a powerfull >> tool. I prefer to think that flash is rather visualization tool than >> programing language, and java needs a lot of typing and a lot of >> reading. On the other hand python is simple to read and write, can be >> debuged easily, is intuitive and saves a lot of time. It also supports >> batteries included policy and you can't get more OO than python. > > One advantage of Flash is that we can have something moving on the > screen from day one, and add code to it piece by piece for things like > keyboard or mouse control, more and more complex physics, etc. Is > there an equivalent project in Python? see my other answer in this thread. From nagle at animats.com Fri Apr 4 13:54:49 2008 From: nagle at animats.com (John Nagle) Date: Fri, 04 Apr 2008 10:54:49 -0700 Subject: collecting results in threading app In-Reply-To: References: <47f64507$0$36354$742ec2ed@news.sonic.net> Message-ID: <47f668d2$0$36340$742ec2ed@news.sonic.net> Gerardo Herzig wrote: > John Nagle wrote: > >> Gerardo Herzig wrote: > Thanks John, that certanly works. According to George's suggestion, i > will take a look to the Queue module. > One question about > > for mythread in mythreads: # for all threads > mythread.join() # wait for thread to finish > > > That code will wait for the first count(*) to finish and then continues > to the next count(*). Because if is that so, it will be some kind of > 'use threads, but execute one at the time'. No, all the threads are started in the first loop, and can run their MySQL queries concurrently. Once all threads have been started, the second loop (above) waits for all of them to finish. John Nagle From davidf at sjsoft.com Tue Apr 1 03:55:52 2008 From: davidf at sjsoft.com (David Fraser) Date: Tue, 1 Apr 2008 00:55:52 -0700 (PDT) Subject: counting using variable length string as base References: <0d2b84b7-efd0-4e53-98da-01ff1d3c6b9e@s8g2000prg.googlegroups.com> <4d1d7d83-8155-4c1a-a807-0b5c951e1192@d21g2000prf.googlegroups.com> Message-ID: <415b6d3e-b9c8-4b24-88ae-1fd47f28258f@2g2000hsn.googlegroups.com> On Mar 31, 8:18 pm, "Gabriel Genellina" wrote: > En Mon, 31 Mar 2008 09:30:00 -0300, Graeme Glass > escribi?: > > > On Mar 27, 11:01 am, Peter Otten <__pete... at web.de> wrote: > >> a b c aa ab ac ba bb bc ca cb cc aaa aab aac aba abb abc aca acb acc > >> baa bab > >> bac bba bbb bbc bca bcb bcc > > > Here is a cool solution we came up with during a little interactive > > session at our local meet up. > > (http://www.python.org.za/pugs/cape-town/cape-town) > > > s = 'abcdef' > > ["".join([s[j] for j in range(len(s)) if x & (1 << j)]) for x in > > range(1,2**len(s)) ] > > But it's doesn't generate the right sequence, and a lot of elements are > missing. For 'abc': > ['a', 'b', 'ab', 'c', 'ac', 'bc', 'abc'] > It lacks ba, bb, ca, cb, cc, all b??, all c?? - see the sequence quoted > above. Indeed, the following shold do the trick although it's fairly inefficient: n=(len(s)+1) ; z = [''] + list(s) ; all = sorted(dict.fromkeys("".join(z[(x/(n**j))%n] for j in range(n)) for x in range(1,n**n))) Cheers David From rune.strand at gmail.com Fri Apr 11 18:32:10 2008 From: rune.strand at gmail.com (Rune Strand) Date: Fri, 11 Apr 2008 15:32:10 -0700 (PDT) Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> <47ffee86$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: <15e5c81b-0b21-44f0-9282-0d1495bc6bb3@z24g2000prf.googlegroups.com> On Apr 12, 12:03 am, Michel Bouwmans wrote: > > Qt Designer. And creating the GUI yourself in the text editor isn't that > bad, plus you have much better control over it. If you like designing isual elements in an editor, that's fine for me! I don't, And as I don't do it all the time, I tend to forget constructional details and waste life googling. So for me it's pain without cognition. AKA waste of life. Numerous RAD' env's, fx Delphi, suggests this kind of incredibly boring almost pre-historic, self-pestering non-sense pain is ancient, and I happen to agree. It's an orthodox and monkish way of programming. Some like it that way and that's none of my business. I don't like it that way. Designing GUI in a text-editor (for me) always produce a : "good enough" and consumes a lot of life. The Boa constructor / Delphi way produce "what I want" without _wasting life_. But Boa is too unstable, and does not claim otherwise, and there's no descent alternative I'm aware of. So, GUI Python still sucks far too much. Console and web Python indeed does not. So if the Python Foundation arrange a "Descent RAD" effort, I'll happily donate $100 for starters. I think Python should be just as easily GUI'able as it is Console'able. Python is soon 20 years old! From tkpmep at hotmail.com Fri Apr 11 14:03:17 2008 From: tkpmep at hotmail.com (tkpmep at hotmail.com) Date: Fri, 11 Apr 2008 11:03:17 -0700 (PDT) Subject: Cannot start RPy - need win32api References: <743ee4e0-bd05-4291-b587-1e8c6237656b@f36g2000hsa.googlegroups.com> Message-ID: <7f1c34ee-04a3-4ea4-aadd-f99cf8425a51@y21g2000hsf.googlegroups.com> Thanks a mill - works like a charm! From gagsl-py2 at yahoo.com.ar Thu Apr 3 10:34:13 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 11:34:13 -0300 Subject: Strange MySQL Problem... References: <4dc0cfea0804021236n1faafabav1699fbe45acc3c01@mail.gmail.com> <47f46a3e$0$36371$742ec2ed@news.sonic.net> <4dc0cfea0804030543t1ad5a3abs539fa6598061c454@mail.gmail.com> Message-ID: En Thu, 03 Apr 2008 09:43:57 -0300, Victor Subervi escribi?: >> Steve Holden wrote: >> Define "no longer works". > Sorry. Throws HTTP 200 error. HTTP 200 means OK. >> > The same remarks I've posted earlier apply here. > Must have missed those. Yes, the code works fine. Repeatedly. http://groups.google.com/group/comp.lang.python/browse_thread/thread/b732eee4e91b1868/ >> In general, server side programs should have a try-block >> wrapped around most of the program, with some code to display or >> log errors in some useful way. > Curious. Why? During testing, I understand, but after testing, why? display or *log* errors... >> Gabriel Genellina wrote: >> > print 'Content-Type: image/jpeg\r\n' >> > print '\nHi!\n' >> >> Don't you see a conflict among those two lines? >> (You're a liar: first you promise to send a nice picture and then you >> only >> send a letter!) > LOL! Okay, make me honest ;) I want to post both text and images. What > use? *post*? This is the server response. Return either text *or* an image (the text may be an html referencing the image) >> > sql = "INSERT INTO justatest VALUES (%s, %s)" >> > cursor.execute(sql, ('ramis', _mysql.escape_string(f)) ) >> >> You're using bound parameters now, a good thing. There is no need to >> escape strings passed as parameters - in fact, it is wrong, as the >> adapter >> will escape the text again. >> In this case, the column is a BLOB, and you have to use the Binary >> function: MySQLdb.Binary(f) >> > > Nope. Threw me another HTTP 200. Again, HTTP 200 means OK. See section 10.2.1 at http://www.faqs.org/rfcs/rfc2616.html > Wrong. I check the mysql and drop the table if the code throws me an HTTP > 200 error. I have run this code many times now. That is what makes the > whole > thing so ridiculously strange to me. That code snippet, that the script > insists on, is a relic from the code I tweaked. It was there to make a > binary, that is all. So why do I still need the darn thing?? Test it locally (just the database thing, no web), test the cgi script without database interaction, only then join the two. >> You have to look at the server error logs, else you're blind fighting. > I am blind fighting. No longer run my own server, no longer have root > access. But you can read the server logs at least? Your code is throwing exceptions but you're not seeing them. Use the cgitb module http://docs.python.org/lib/module-cgitb.html -- Gabriel Genellina From Robert.Bossy at jouy.inra.fr Thu Apr 17 04:39:08 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Thu, 17 Apr 2008 10:39:08 +0200 Subject: Profiling, recursive func slower than imperative, normal? In-Reply-To: References: Message-ID: <48070CAC.6020005@jouy.inra.fr> Gabriel Genellina wrote: > En Wed, 16 Apr 2008 17:53:16 -0300, escribi?: > > >> On Apr 16, 3:27 pm, Jean-Paul Calderone wrote: >> >> >>> Any function can be implemented without recursion, although it isn't >>> always easy or fun. >>> >>> >> Really? I'm curious about that, I can't figure out how that would >> work. Could give an example? Say, for example, the typical: walking >> through the file system hierarchy (without using os.walk(), which uses >> recursion anyway!). >> > > Use a queue of pending directories to visit: > > start with empty queue > queue.put(starting dir) > while queue is not empty: > dir = queue.get() > list names in dir > for each name: > if is subdirectory: queue.put(name) > else: process file > Hi, In that case, I'm not sure you get any performance gain since the queue has basically the same role as the stack in the recursive version. A definitive answer calls for an actual test, though. Anyway if you want to process the tree depth-first, the queue version falls in the "not fun" category. Cheers, RB From limodou at gmail.com Fri Apr 25 02:10:52 2008 From: limodou at gmail.com (limodou) Date: Fri, 25 Apr 2008 14:10:52 +0800 Subject: [ANN]UliPad 3.9 released! Message-ID: <505f13c0804242310n62b0720fs60f36b83d8ea9ab4@mail.gmail.com> UliPad is a flexible editor, based on wxPython. It's has many features,just like:class browser, code auto-complete, html viewer, directory browser, wizard, etc. The main feature is the usage of mixin. This makes UliPad can be extended easily. So you can write your own mixin or plugin, or simple script, these can be easy and seamless integrated with UliPad. New Features and Changes: #. Add php.acp thanks for ?? #. Replace old snippet with new snippet, more details please see <`Snippet Howto `_> #. Binding F5 to editor but not MainFrame, and add F5(Refresh) support in Directory Browser. #. Improve python class browser, threading update, change some icons #. Add indent cursor move functionality see <`Indent Moving Howto `_> #. Improve threading document modification process, so you can get better efficiency #. Introduce meide(http://code.google.com/p/meide) project to simplify the interface creation #. Add FNB.FNB_DROPDOWN_TABS_LIST style to EditorCtrl #. Change auto file check in Editor on_set_focus event handler #. Change DDE to asyncore and asynchat framework #. Change preference dialog from notebook to treebook #. Add icon set theme support #. Add strip line ending when saving functionality option in Preferences #. Strip leading space when doing "Run in Shell" #. Add auto detect python interpreter in windows platform #. Improve ReST document render, and fix the setfocus lost bug when auto modified the html output, thanks a lot to ygao #. Change setmenutext to use fix width to set the menu text, replace with '\t' #. Chanage notebook left double click to right double click(enlarge notebook size) #. Add search text count in Find & Replace pane #. Add line ending mixture check when saving file feature #. Improve preference dialog input assistant checkbox process. When you check the first checkbox(Enable input assistant) it'll automatically toggle other 5 checkboxes. #. Change new toolbutton to dropdown toolbutton, and it can remember the last new file type(select new type menu first), then when you select new menu, it'll create a new file with the last new file type #. Improve command search and pairprog plugin caret display process #. Add auto new version of UliPad check #. Add slice language syntax support #. Add auto pop up project setting dialog when adding directory to directoy browser window #. Add Open Explorer Window Here menu to editoctrl tab context menu #. Add open snippet tool button, change open dirbrowser and open snippet toolbutton to check toolbutton #. Change ``explorer.exe %s`` as ``explorer.exe /e, %s`` in windows platform #. Add copy filename to clipboard menu on document area tab context menu #. Add wrap text feature, via [Edit]->[Format]->[Wrap Text...] New Plugins: #. canvas_test_plugin, you can directly test DC api #. web2py_plugin, supply web2py shell Bug fix: #. Fix webopen twice open bug #. Fix editor shortcuts key caption error #. Fix if set DROP_DOWN_TABS_LIST style, right arrow will disappear bug #. Fix utf-16 convertion bug #. Fix mako tag auto complete bug #issue 14 #. Fix if lines are folded, when goto hiding lines will no effect bug #. Fix DDE bug, thanks to LP #. Fix webopen bug, can't correctly deal with 'mailto:' #. Fix smart tabs bug #. Fix copy and paste lineending is not correct bug #. Fix tab invisible bug after changing size or changing the page title #. Fix template line-ending not match the default line-ending setting #. Fix password widget is not Password type widget bug #. Fix script filename cannot be unicode(chinese) bug #. Fix syntax check exception process bug #. Fix ruler bug UliPad has ported to code.google.com, so you can visit the new project site at: http://code.google.com/p/ulipad, and also visit the new svn address. Recommends using source version. source version download: http://ulipad.googlecode.com/files/ulipad.3.9.zip window exe version: http://ulipad.googlecode.com/files/ulipad.3.9.exe maillist: http://groups.google.com/group/ulipad ulipad snippets site: http://ulipad.appspot.com (hosted by GAE) Hope you enjoy it. -- I like python! UliPad <>: http://code.google.com/p/ulipad/ UliSpot <>: http://ulipad.appspot.com My Blog: http://www.donews.net/limodou From jens at aggergren.dk Tue Apr 29 11:50:38 2008 From: jens at aggergren.dk (Jens) Date: Tue, 29 Apr 2008 08:50:38 -0700 (PDT) Subject: Zope/DTML Infuriating... References: Message-ID: <3473a8d5-e113-464e-825c-e88a7758ce9d@d45g2000hsc.googlegroups.com> On Apr 29, 3:16?pm, Christian Heimes wrote: > Jens schrieb: > > > Hello Everyone. > > > I am relatively new to Zope(using it for a work project) and I was > > wondering if someone here could help me out or at least refer me to a > > decent documentationg for Zope/DTML/Python (at the detail level of > > php.net or Java API reference). ?http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/ > > isn't really detailed enough for my taste. if it doesn't contain a > > exhautive description of all available base classes it's simply no > > good as a reference resource. > > Are you forced to use DTML for the job? ZPT are far superior and easier > to work with, if you have to output HTML. > > Christian For now, I have to use DTML as I am building on an existing solution. I might look into ZPT's but I have limited time and theres no to time at this point to redo everything as ZPT. In the long run we're probably going in a completely different direction, but that a another story. I like some aspects of zope but I find that it ends up sitting between two chairs. On one hand it want's to be a templating language which is easy to get into for novices, but on the other hand you really have be familiar with python to be able to so stuff thats only slighty more complicated then standard SSI. And don't get me started on the whole security philosophy. @Marco: Thanks for the links :-) Python may be one of those really elegant languages, but the reference is really sub standard. Checkout the layout of php.net for comparison. Think what you will about php, but the reference is excellent. For that matter check out msdn section on old-school asp, or even the common-lisp documentation(http://www.lispworks.com/ documentation/HyperSpec/Front/Contents.htm) It's accessibility like that i'm missing. It shouldn't take 10 min and a usenet post to figure to how to basic stuff like string concatenation. And theres still plenty of unanswered questions after checking the reference: - What is the exact definition of the operator e.g. op + (, ) -> , op + (, ) : , op + ( ... - What is the exact operator precedence - Why is it, when primitive data types seem to be objects (similar to javascript), that type casting is done through build-in functions rather than methods, e.g. String.toInt('5') or '5'.toInt() or x = Integer.fromString('5'). From altami0762 at gmail.com Thu Apr 17 15:51:01 2008 From: altami0762 at gmail.com (altami0762 at gmail.com) Date: Thu, 17 Apr 2008 12:51:01 -0700 (PDT) Subject: cabage patch kids Message-ID: <590761ac-184d-4e30-a034-a0aa5ca78a5c@b64g2000hsa.googlegroups.com> cabage patch kids http://cracks.12w.net F R E E C R A C K S From andrei.avk at gmail.com Wed Apr 2 14:50:10 2008 From: andrei.avk at gmail.com (AK) Date: Wed, 02 Apr 2008 13:50:10 -0500 Subject: Python-by-example - new online guide to Python Standard Library In-Reply-To: References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: <47f3c751$0$6477$4c368faf@roadrunner.com> Terry Reedy wrote: > "AK" wrote in message > news:47f2d018$0$6517$4c368faf at roadrunner.com... > > || I'll be glad to hear comments/suggestions/etc: > | > | http://www.lightbird.net/py-by-example/ > > Using - as the example/return delimiter does not work. > If you do not want to substantially lengthen the document by going to > >>>> sqrt(9) > 3 > > then use Python's a comment symbol. > > sqrt(9) # 3 > -or- > sqrt(9) # returns 3 (but I think I prefer the first) > > which clearly is not an arithmetic expression and which can be > cut-and-pasted into the interactive interpreter. This also works nicely > for invalid examples. > > sqrt(-9) # raises ValueError > > Terry Jan Reedy > > > > > > > Thanks to everybody who replied, I will implement the change as per Terry's advice. I'm still considering whether to use the standard interpreter syntax, i.e. >>> ... \n result; my reason for not doing that is that I will often have a whole screen of function / result lines and if I were to add a new line for the result, that'd make two pages out of one, which I think is a bit too much. In current docs there are not so many examples, so that space is not multiplied quite so much, and using interactive interpreter way of showing result is not nearly as much of a problem. However, I'm still thinking this over and it seems that almost everyone wants to see it done in that way, I might still go for two lines. I'll also be posting updates as the work progresses.. thx, -- -ak Tobu | http://www.lightbird.net/tobu/ | Freeform DB / Tagger / PIM Python-by-Example | http://www.lightbird.net/py-by-example/ | Guide to LibRef From bvidinli at gmail.com Thu Apr 17 04:39:23 2008 From: bvidinli at gmail.com (bvidinli) Date: Thu, 17 Apr 2008 11:39:23 +0300 Subject: Fwd: is file open in system ? - other than lsof In-Reply-To: References: Message-ID: <36e8a7020804170139s5986efd1p6fa5f799be0c592@mail.gmail.com> Here is (hope) complete info for my question: i use linux/unix i use python 2.3 my subject is a single file at a time. but i have to check thousands of files in a loop. so, since there is thousands of files to process, i dont want to use like os.system('lsof filename') because lsof is slow regarding, when you called it thousands of times. is there another way, any python command sequence that i can check if a file is open at the time of "before i process file" i am not interested in " the file may be written after i access it.." the important point is " the time at i first access it." my routine is something like: for i in listoffiles: checkfileopen(i) processfile() thats it... i hope this will clear my question.. thank you a lot. ---------- Forwarded message ---------- From: Chris McAloney Date: 16.Nis.2008 17:00 Subject: Re: is file open in system ? - other than lsof To: python-list at python.org On 16-Apr-08, at 9:20 AM, A.T.Hofkamp wrote: > On 2008-04-16, bvidinli wrote: >> is there a way to find out if file open in system ? - >> please write if you know a way other than lsof. because lsof if >> slow for me. >> i need a faster way. >> i deal with thousands of files... so, i need a faster / python way >> for this. >> thanks. > > This is not a Python question but an OS question. > (Python is not going to deliver what the OS doesn't provide). > > Please first find an alternative way at OS level (ie ask this > question at an > appropiate OS news group). Once you have found that, you can think > about Python > support for that alternative. I agree with Albert that this is very operating-system specific. Since you mentioned 'lsof', I'll assume that you are at least using a Unix variant, meaning that the fcntl module will be available to you, so you can check if the file is already locked. Beyond that, I think more information on your application would be necessary before we could give you a solid answer. Do you only need to know if the file is open, or do you want only the files that are open for writing? If you only care about the files that are open for writing, then checking for a write-lock with fcntl will probably do the trick. Are you planning to check all of the "thousands of files" individually to determine if they're open? If so, I think it's unlikely that doing this from Python will actually be faster than a single 'lsof' call. If you're on Linux, you might also want to have a look at the /proc directory tree ("man proc"), as this is where lsof gets its information from on Linux machines. Chris -- http://mail.python.org/mailman/listinfo/python-list -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From fredri8758lupo at gmail.com Wed Apr 23 06:10:11 2008 From: fredri8758lupo at gmail.com (fredri8758lupo at gmail.com) Date: Wed, 23 Apr 2008 03:10:11 -0700 (PDT) Subject: automotive expert program key crack Message-ID: automotive expert program key crack http://cracks.12w.net F R E E C R A C K S From python at bdurham.com Mon Apr 7 14:15:29 2008 From: python at bdurham.com (Malcolm Greene) Date: Mon, 07 Apr 2008 14:15:29 -0400 Subject: Tips for load balancing multiple Python apps on dual/quad core processors? Message-ID: <1207592129.27594.1246549665@webmail.messagingengine.com> I'm looking for tips on how to load balance running multiple Python applications in multi-CPU environments. My understanding is that Python applications and their threads are limited to a specific CPU. Background: I have a Python utility that processes email messages. I suspect there's a lot of idle time while this utility waits on a remote email server. I would like to run as many simultaneous copies of this utility as possible without overwhelming the server these utilities are running on. My thought is that I should write a dispatcher that monitors CPU load and launches/cancels multiple instances of my utility with specific job queues to process. Is there a cross-platform way to monitor CPU load? Is there a pre-existing Python module I should be looking at for building (subclassing) my dispatcher? Thanks! Malcolm From arnodel at googlemail.com Sun Apr 6 12:18:09 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 6 Apr 2008 09:18:09 -0700 (PDT) Subject: A file iteration question/problem References: <47f8eee1$0$759$bed64819@news.gradwell.net> Message-ID: <322f98fd-eb6e-4a05-a8c7-1e0c5329e955@w5g2000prd.googlegroups.com> On Apr 6, 4:40?pm, tinn... at isbd.co.uk wrote: > I want to iterate through the lines of a file in a recursive function > so I can't use:- > > ? ? f = open(listfile, 'r') > ? ? for ln in f: > > because when the function calls itself it won't see any more lines in > the file. ?E.g. more fully I want to do somthing like:- > > def recfun(f) > ? ? while True: > ? ? ? ? str = readline(f) > ? ? ? ? if (str == "") > ? ? ? ? ? ? break; > ? ? ? ? # > ? ? ? ? # do various tests > ? ? ? ? # > ? ? ? ? if : > ? ? ? ? ? ? recfun(f) > > Is there no more elegant way of doing this than that rather clumsy > "while True" followed by a test? > > -- > Chris Green You could use an iterator over the lines of the file: def recfun(lines): for line in lines: # Do stuff if condition: recfun(lines) lines = iter(open(filename)) recfun(lines) Or if you want the filename to be the argument of you function, wrap it in a non-recursive function: def fun(filename): lines = iter(open(filename)) def recfun(): for line in lines: # Do stuff if condition: recfun() recfun() HTH -- Arnaud From shevitz at lanl.gov Tue Apr 29 18:33:02 2008 From: shevitz at lanl.gov (Danny Shevitz) Date: Tue, 29 Apr 2008 22:33:02 +0000 (UTC) Subject: how to convert a multiline string to an anonymous function? Message-ID: Simple question here: I have a multiline string representing the body of a function. I have control over the string, so I can use either of the following: str = ''' print state return True ''' str = ''' def f(state): print state return True ''' and I want to convert this into the function: def f(state): print state return True but return an anonmyous version of it, a la 'return f' so I can assign it independently. The body is multiline so lambda doesn't work. I sort of need something like: def function_constructor(str): f = eval(str) # What should this be return f functions = {} for node in nodes: function[node] = function_constructor(node.text) I'm getting stuck because 'def' doesn't seem to work in an eval function, and exec actually modifies the namespace, so I run into collisions if I use the function more than once. I know I'm missing something stupid here, but I'm stuck just the same... thanks, Danny From nobody at devnull.spamcop.net Mon Apr 14 10:15:58 2008 From: nobody at devnull.spamcop.net (Twayne) Date: Mon, 14 Apr 2008 14:15:58 GMT Subject: Python Workshop References: Message-ID: > Hi, > > We are to hold a workshop about python (introduction). It will be two > one hour and half sessions. > I wanted to know which subjects do you suggest to be presented and is > there a good presentation file (powerpoint or ...) about this on the > net. > We thought that it may be good that first session covers the > introduction, zen of python, python coding syntax and the second > session will be about application, libraries or so. > I really appreciate if you tell me your ideas? Depends; what's the experiene level of the audience? "Introductory" is a pretty vague concept; introductory to what audience? -- -- Regards, Twayne Open Office isn't just for wimps anymore; OOo is a GREAT MS Office replacement www.openoffice.org From bronger at physik.rwth-aachen.de Tue Apr 29 16:34:26 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Tue, 29 Apr 2008 22:34:26 +0200 Subject: Simple unicode-safe version of str(exception)? References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> <67on2nF2ol856U1@mid.individual.net> <87zlrcmxuk.fsf@physik.rwth-aachen.de> Message-ID: <87myncmmct.fsf@physik.rwth-aachen.de> Hall?chen! Russell E. Owen writes: > Torsten Bronger wrote: > >> Russell E. Owen writes: >> >>> [...] >>> >>> So...to repeat the original question, is there any simpler >>> unicode-safe replacement for str(exception)? >> >> Please show us the tracebacks you get becuae unicode(s) must >> fail, too, if there are non-ASCII characters involved. > > Why? > > [...] > >>>> ",".join([unicode(s) for s in e.args]) > u'\xb0' I thought you wanted to have a string. But this is again a unicode. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From bvidinli at gmail.com Mon Apr 14 09:20:56 2008 From: bvidinli at gmail.com (bvidinli) Date: Mon, 14 Apr 2008 16:20:56 +0300 Subject: Python GUI programming and boa or better ? In-Reply-To: <36e8a7020804140620q1a1eb7d2xf4e8b3d753a1b62c@mail.gmail.com> References: <36e8a7020804140620q1a1eb7d2xf4e8b3d753a1b62c@mail.gmail.com> Message-ID: <36e8a7020804140620m2a44b8e8n6c5548d0af8fa0a3@mail.gmail.com> I program in python for about 2-3 monthos. I just started/tested gui programming with many tools. i tested boa last, it is the closest tool to delphi in GUI tools that i used. I managed to play with it a bit. If you have any other tool which you know better than Boa Constructor, please write in here. Any other suggestion about python GUI programming is welcome. thanks. -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From sean.m.mcdaniel at gmail.com Fri Apr 25 00:10:17 2008 From: sean.m.mcdaniel at gmail.com (Sean McDaniel) Date: Fri, 25 Apr 2008 00:10:17 -0400 Subject: Installation in a local directory Message-ID: <2008042500101716807-seanmmcdaniel@gmailcom> Hi y'all, I'm trying to perform a local install of python at work in my user directory. Everything compiles correctly, but I can't seem to tell the configure script the location of the bin and lib directories where I want my stuff. I've think I've passed the correct flags to the 'configure' script. make clean ./configure --enable-shared --prefix=/user/mcdaniel/arch32 make where arch32 contains the the lib and bin directories where I want my python stuff to go. Unfortunately these directories are not written to; everything ends up in the default location from where I ran 'make'. Moreover, if I add a symbolic link from the python binary (which I can run directly without problems) to the bin directory so that my PATH will recognize the new python, I get an error about loading shared libraries. I'm making on a 32 bit new debian system. Thank you for your help, Sean McDaniel From patrickkidd.lists at gmail.com Tue Apr 8 21:01:18 2008 From: patrickkidd.lists at gmail.com (Patrick Stinson) Date: Tue, 8 Apr 2008 19:01:18 -0600 Subject: problem using import from PyRun_String Message-ID: <664bf2b80804081801u79ae9192h90c03c84c1ef35ce@mail.gmail.com> I'm creating a module with PyModule_New(), and running a string buffer as the module's text using PyRun_String and passing the module's __dict__ to locals and globals. I'm having a problem using the import statement from within PyRun_String(). It complains about "__import__ not found", which after a quick grep it looks like the exception is raised from PyExc_EvalFrameEx() in ceval.c after f->f_builtins module doesn't contain "__import__". What __builtin__ module does that point to? a quick print of the content of __builtin__ in CPython code shows a function for the "__import__" key, and I manually added all of the contents of __builtin__ to the module's dict, which was empty before. Any help? Cheers -- Patrick Kidd Stinson http://www.patrickkidd.com/ http://pkaudio.sourceforge.net/ http://pksampler.sourceforge.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From wwzaygvm at gmail.com Wed Apr 16 17:05:53 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 14:05:53 -0700 (PDT) Subject: slovar crack Message-ID: slovar crack http://cracks.12w.net F R E E C R A C K S From sjmachin at lexicon.net Tue Apr 1 17:53:51 2008 From: sjmachin at lexicon.net (John Machin) Date: Tue, 1 Apr 2008 14:53:51 -0700 (PDT) Subject: xlrd and cPickle.dump References: <34e62ddb-477f-4a99-97a5-21a7b148d244@e67g2000hsa.googlegroups.com> <47f22a41@news.mel.dft.com.au> <0d46a213-9f95-43b5-835b-d74d8403626b@c19g2000prf.googlegroups.com> Message-ID: <6acbf9b4-161b-47db-9a91-b2448ee63c34@c26g2000prf.googlegroups.com> On Apr 2, 7:19 am, patrick.wa... at gmail.com wrote: > > How many megabytes is "extremely large"? How many seconds does it take > > to open it with xlrd.open_workbook? > > The document is 15mb ad 50,000+ rows (for test purposes I will use a > smaller sample), 15 Mb is not large. E.g. 120 Mb is large. > but my computer hangs (ie it takes a long time) when > I try to do simple manipulations What do you describe as "simple manipulations"? Please describe your computer, including how much memory it has. > and the documentation leads me to > believe cPickle will be more efficient. The doc says that *IF* you need to read the XLS file multiple times, you can use xlrd.open_workbook() once and save a pickled copy. Then you can c.Pickle.load() from the pickled file multiple times; typically this is about 10 times as fast. BUT this is just a faster way of getting an xlrd.Book object ... not relevant to any subsequent "simple manipulations". You should not be manipulating an xlrd.Book object; treat it as read-only. > If this is not true, then I > don't have a problem (ie I just have to wait), but I still would like > to figure out how to pickle an xlrd object anyways. > > > You only need one of the above imports at the best of times, and for > > what you are attempting to do, you don't need pyExcelerator at all. > > Using pyExcelerator was a guess, because the traditional way didn't > work and I thought it may be because it's an Excel file. Don't guess. If the docs say it wants a file to write to, don't give it None. Especially don't use a function/method call with silly side effects. > Secondly, I > import it twice because sometimes, and I don't know why, PythonWin > does not import pyExcelerator the first time. This has only been true > with pyExcelerator. This seems exceedingly unlikely to me. Try asking on the pywin32 mailing list. > > > > data_path = """C:\test.xls""" > > > It is extremely unlikely that you have a file whose basename begins with > > a TAB ('\t') character. Please post the code that you actually ran. > > you're right, I had just quickly erased my documents and settings > folder to make it smaller for an example. I'm far too astonished by that (and your habit of putting any old bunch of files in your root directory) to make any coherent comment. > > > > Please post the minimal pyExcelerator-free script that demonstrates your > > problem. Ensure that it includes the following line: > > import sys; print sys.version; print xlrd.__VERSION__ > > Also post the output and the traceback (in full). > > As to copy_reg.py, I downloaded Activestate Python 2.4 and that was > it, so I have had no other version on my computer. > > Here's the code: > > import cPickle,xlrd, sys > > print sys.version > print xlrd.__VERSION__ > > data_path = """C:\\test\\test.xls""" > pickle_path = """C:\\test\\pickle.pickle""" > > book = xlrd.open_workbook(data_path) > Data_sheet = book.sheet_by_index(0) > > pickle_file = open(pickle_path, 'w') Use 'wb' ... > cPickle.dump(book, pickle_file) ... use cPickle.dump(book, pickle_file, -1) # latest protocol *I WAS WRONG* (happens sometimes) when I said I couldn't reproduce your problem with Python 2.4; my test/demo/timing code was using -1 by default. Note: as well as not complaining about contained file objects, protocol -1 can be 10 times the speed of protocol 0 and produce a pickle file half the size. > pickle_file.close() > > Here's the output: > > 2.4.3 (#69, Apr 11 2006, 15:32:42) [MSC v.1310 32 bit (Intel)] > 0.6.1 > Traceback (most recent call last): > File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework > \scriptutils.py", line 310, in RunScript > exec codeObject in __main__.__dict__ > File "C:\text analysis\pickle_test2.py", line 13, in ? > cPickle.dump(book, pickle_file) > File "C:\Python24\lib\copy_reg.py", line 69, in _reduce_ex > raise TypeError, "can't pickle %s objects" % base.__name__ > TypeError: can't pickle module objects > > Thanks for the advice! Here's some more: try to *understand* the "hanging" / "simple manipulations" problem before you start implementing solutions. Also, any good reason for sticking with Python 2.4? HTH, John From cwitts at gmail.com Tue Apr 15 05:31:36 2008 From: cwitts at gmail.com (Chris) Date: Tue, 15 Apr 2008 02:31:36 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <1208196168.24295.36.camel@localhost.localdomain> Message-ID: <526792b1-acc2-4e48-8e9f-cc2641134958@k37g2000hsf.googlegroups.com> On Apr 15, 11:22?am, Sjoerd Mullender wrote: > Thomas Dybdahl Ahle wrote: > > On Fri, 2008-04-11 at 03:14 -0700, bdsatish wrote: > >> The built-in function round( ) will always "round up", that is 1.5 is > >> rounded to 2.0 and 2.5 is rounded to 3.0. > > >> If I want to round to the nearest even, that is > > >> my_round(1.5) = 2 ? ? ? ?# As expected > >> my_round(2.5) = 2 ? ? ? ?# Not 3, which is an odd num > > >> I'm interested in rounding numbers of the form "x.5" depending upon > >> whether x is odd or even. Any idea about how to implement it ? > > > This seams to work fine: > > evenRound = lambda f: round(f/2.)*2 > > >>>> [(f*.5, evenRound(f*.5)) for f in xrange(0,20)] > > [(0.0, 0.0),(0.5, 0.0), > > (1.0, 2.0), (1.5, 2.0), (2.0, 2.0), (2.5, 2.0), > > (3.0, 4.0), (3.5, 4.0), (4.0, 4.0), (4.5, 4.0), > > (5.0, 6.0), (5.5, 6.0), (6.0, 6.0), (6.5, 6.0), > > (7.0, 8.0), (7.5, 8.0), (8.0, 8.0), (8.5, 8.0), > > (9.0, 10.0), (9.5, 10.0)] > > No, this does not work:>>> [(f*.25, evenRound(f*.25)) for f in xrange(0,20)] > > [(0.0, 0.0), (0.25, 0.0), (0.5, 0.0), (0.75, 0.0), (1.0, 2.0), (1.25, > 2.0), (1.5, 2.0), (1.75, 2.0), (2.0, 2.0), (2.25, 2.0), (2.5, 2.0), > (2.75, 2.0), (3.0, 4.0), (3.25, 4.0), (3.5, 4.0), (3.75, 4.0), (4.0, > 4.0), (4.25, 4.0), (4.5, 4.0), (4.75, 4.0)] > > x.75 should be rounded up. > > -- > Sjoerd Mullender > > ?signature.asc > 1KDownload even is closer to even.75 than even+1.25. Why should it be rounded up ? From rkmr.em at gmail.com Mon Apr 21 17:53:15 2008 From: rkmr.em at gmail.com (rkmr.em at gmail.com) Date: Mon, 21 Apr 2008 14:53:15 -0700 Subject: dynamically importing a module and function In-Reply-To: References: Message-ID: there was a mistake in my prev mail.. it is not able to successfully import the module. abcde is in directory /home/mark/work/proj1, but it is looking for it in /home/mark from where i am running the script.. though i changed cwd using os.chdir() function > File "/home/mark/app.py", line 5, in > import abcde > ImportError: No module named abcde On Mon, Apr 21, 2008 at 2:46 PM, rkmr.em at gmail.com wrote: > Hi > I have a function data['function'], that I need to import from a file > data['module'], in the directory data['cwd'] > > If I do this from python interactive shell (linux fedora core 8) from > dir /home/mark it works fine: > > cwd = data['cwd'] > os.chdir(cwd) > print os.getcwd() > module = __import__(data['module']) > function = getattr(module, data['function']) > > But if I put this in a file /home/mark/work/common/funcq.py and run it > from /home/mark, it throws me error like this.. how to fix this? it > imports the module successfully, but it is not looking for subsequent > modules in the os.getcwd().. > > /home/mark/work/proj1 > Traceback (most recent call last): > File "/home/mark/work/common/funcq.py", line 60, in > if __name__ == '__main__':do() > File "/home/mark/work/common/funcq.py", line 33, in do > module = __import__(data['module']) > File "/home/mark/app.py", line 5, in > import abcde > ImportError: No module named abcde > From grante at visi.com Wed Apr 16 12:35:27 2008 From: grante at visi.com (Grant Edwards) Date: Wed, 16 Apr 2008 11:35:27 -0500 Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <6rGdnfc8nvJSt5vVnZ2dnUVZ_oDinZ2d@visi> On 2008-04-16, Michael Torrie wrote: >> My workplace doesn't offer NNTP, so there is no good way to browse >> c.l.py here. Browse it via the mailing list using gmane.org. There are no ads and your postings won't get plonked by everybody. >> And I haven't been able to get NNTP to work from my home >> either. > > I rarely use NNTP these days. I access c.l.py exclusively via > e-mail, and that works very well. In some cases there is a > lot of spam that gets filtered out of the nntp side, but makes > it through to the smtp side (like that religious spam a few > months back). But I see absolutely none of the google groups > problems that Grant mentioned. I view my python list mail in > gmail, and get about 1-2 spam messages a day in the python > list. > > This official python list is one of the few lists that's even > still on nntp. All my other ones (gnome, gtk, openldap, > clamav, freeradius, etc) are all e-mail mailing lists only and > it works very well. In fact, I think it's much better since > list subscription can actually be controlled by someone. Since gmane.org makes all the e-mail lists I care about available via NNTP, I can still use a news client to read "e-mail mailing lists only". I've always found that news clients are much better at handling things like mailing lists than e-mail clients. -- Grant Edwards grante Yow! Quick, sing me the at BUDAPEST NATIONAL ANTHEM!! visi.com From jcd at unc.edu Thu Apr 17 11:39:53 2008 From: jcd at unc.edu (J. Cliff Dyer) Date: Thu, 17 Apr 2008 11:39:53 -0400 Subject: More Fun With MySQL and Images In-Reply-To: <4dc0cfea0804170752x789cce43xe1ea6aeba498ccd1@mail.gmail.com> References: <4dc0cfea0804170742g39965533yfaf260bcf4da4301@mail.gmail.com> <4dc0cfea0804170752x789cce43xe1ea6aeba498ccd1@mail.gmail.com> Message-ID: <1208446793.4433.18.camel@aalcdl07.lib.unc.edu> On Thu, 2008-04-17 at 09:52 -0500, Victor Subervi wrote: > Never mind. Apparently, these tags throw it for that loop: > print '\n' > I?m surprised they would, but gratified I found the problem. > Victor > > Why does that surprise you? A jpeg has a well-defined header that tells whatever application is rendering it what to look for. By putting those tags at the beginning of the data sent to your browser, you're no longer getting a well-formed jpeg. The header is wrong. As an experiment, if you're on *nix, or have access to a decent shell, try this: $ echo '' > newfile.jpg $ cat /path/to/any_normal_jpeg >> newfile.jpg $ echo '' >> newfile.jpg If you don't have access to a shell, open a JPEG with your favorite text editor, and manually add "" to the beginning, and save it out. Then try to open newfile in any piece of software of your choosing. It's no longer a well-formed jpeg, so it won't work. That's exactly what you're asking the browser to do. I guess this isn't really python related, so my apologies for that. Cheers, Cliff -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill From n00m at narod.ru Sat Apr 26 16:12:43 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 13:12:43 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> Message-ID: <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> >> char vs[1002000][99]; In the file 1001622(or so) records like phone number + f/l names. So the reserving makes sense, i think. Populating of vector is by zillion times slower. >> Is there an implementation of f.readlines on the internet somewhere? I was greatly surprised how fast it is. As a matter of fact, it's the point of my message here. >> BTW why are you declaring the array as 99 and pass 999 to fgets to read a line? It doesn't matter. All the same, reading of a current line stopped at '\n'. Big number 999(9999,99999,...) just ensures that each line is read up to its end. >> fgets is part of the standard C++ library and it lives in the std namespace. I thought it's from . Anyway, it does not matter. PS Thanx for the code. 2All: Origin of my "discovery" is from http://www.spoj.pl/ranks/SBANK/start=400 I never thought it can be done in Python (there are a couple of Py solutions even faster than mine) and without stuff like radix sort etc. From sjoerd at acm.org Mon Apr 21 02:59:34 2008 From: sjoerd at acm.org (Sjoerd Mullender) Date: Mon, 21 Apr 2008 08:59:34 +0200 Subject: Is massive spam coming from me on python lists? In-Reply-To: <480C2DC6.4050701@aim.com> References: <480C2DC6.4050701@aim.com> Message-ID: <480C3B56.40909@acm.org> On 2008-04-21 08:01, Brian Vanderburg II wrote: > I've recently gotten more than too many spam messages and all say > Sender: python-list-bounces+my=email.address at python.org. I'm wondering > if my mail list registration is now being used to spam myself and > others. If so, sorry, but I'm not the one sending messages if other are > getting them even though Sender seems to include my address (I'm not > sure about mail headers so I don't know how From: is different than > Sender:) Anyway, it seems to be a bunch of spam emails about cracks and > stuff. > > Brian Vanderburg II That is just mailman (the mailing list software) keeping track of things. If there were a bounce, mailman can determine from the address of the bounce message (the bounce gets sent back to the Sender, not the From) which address bounced. So *all* python-list messages you get have that Sender. In other words, these spams do not come from you. -- Sjoerd Mullender From kyosohma at gmail.com Wed Apr 16 13:49:10 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 16 Apr 2008 10:49:10 -0700 (PDT) Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: On Apr 16, 12:40 pm, "D'Arcy J.M. Cain" wrote: > On Wed, 16 Apr 2008 08:23:50 -0700 (PDT) > > Mike Driscoll wrote: > > My workplace doesn't offer NNTP, so there is no good way to browse > > c.l.py here. And I haven't been able to get NNTP to work from my home > > either. > > Hi Mike; > > I am half way to killing Google groups myself. Your message, and > allother Google groups messages, is coloured so that I can evaluate how > much I will miss. So far it looks like it will make reading this group a > whole lot more pleasant and so I will probably kill them soon. > > There are alternatives. I run an ISP http://www.Vex.Net/ > that offers NNTP access to my shell users. You can also receive > this group as a mailing list which is how I read it. Google is not the > only option out there. > > -- > D'Arcy J.M. Cain | Democracy is three wolveshttp://www.druid.net/darcy/ | and a sheep voting on > +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. I don't think I like the email list idea all that much. I'm already on a number of them and they fill up my box like crazy. Besides that, in email format it's hard to follow the thread, so one moment I'm reading about the latest ding dong and the next is a response to a post from last week. But I agree...there are other alternatives. I'll have to start trying them again I suppose. Mike From deets at nospam.web.de Wed Apr 23 08:26:23 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 23 Apr 2008 14:26:23 +0200 Subject: Subprocess module In-Reply-To: References: Message-ID: <678o84F2mkgm2U1@mid.uni-berlin.de> Dominique.Holzwarth at ch.delarue.com schrieb: > Hello all > > I want to convert a tex file into a pdf by using pdflatex. For that, I thought the 'subprocess' module might be a good option. My code doesn't work at all tho: > > Import os, subprocess > > def main(): > scriptpath = os.path.dirname(__file__) > > p = subprocess.Popen("pdflatex --include-directory=%s --output-directory=%s/output --aux-directory=%s/temp --interaction=nonstopmode myFile.tex" > % (scriptpath, scriptpath, scriptpath), > stdin=subprocess.PIPE, > stdout=subprocess.PIPE, > stderr=subprocess.PIPE, > shell=True, > cwd=scriptpath) > (child_stdin, > child_stdout, > child_stderr) = (p.stdin, p.stdout, p.stderr) > print 'stdin' > print child_stdin > print 'stdout' > print child_stdout > print 'stderr' > print child_stderr > > When I run that code I get the following printouts: > > stdin > ', mode 'wb' at 0x009E7968> > stdout > ', mode 'rb' at 0x009E7A40> > stderr > ', mode 'rb' at 0x009E79F8> > Done Just a guess - but how about consuming the very verbose latex ouptut? Otherwise latex will stop when the stdout-pipe is full. And beware of the interactive prompte of latex - that thing has bitten me more than once. Diez From tjreedy at udel.edu Mon Apr 7 16:16:24 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 7 Apr 2008 16:16:24 -0400 Subject: reading dictionary's (key,value) from file References: <974814d3-59f0-49ec-9b4d-9f5dd7dfaf54@q24g2000prf.googlegroups.com> Message-ID: You can use execfile (or exec, in 3.0) function to execute code in a file in the present context. From fredrik at pythonware.com Mon Apr 7 02:52:08 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 07 Apr 2008 08:52:08 +0200 Subject: How to get an XML DOM while offline? In-Reply-To: <47F9BB5B.30604@behnel.de> References: <47F9BB5B.30604@behnel.de> Message-ID: Stefan Behnel wrote: >> Is there a simpler way to read the iTunes XML? (It's merely a plist, >> so the format is much simpler than general XML.) > > Try lxml. Since version 2.0, its parsers will not access the network unless > you tell it to do so. > > http://codespeak.net/lxml which makes it true for all ET implementations (the whole idea that parsing a file should result in unexpected network access is of course a potential security risk and one of a number of utterly stupid design decisions in XML). you'll find plist reading code here, btw: http://effbot.org/zone/element-iterparse.htm#incremental-decoding replace the import with "from xml.etree import cElementTree" if you're running 2.5. (not sure if that one works with lxml, though, but that should be fixable. you can at least reuse the unmarshaller dict). From weiss02121 at gmail.com Tue Apr 15 19:49:00 2008 From: weiss02121 at gmail.com (weiss02121 at gmail.com) Date: Tue, 15 Apr 2008 16:49:00 -0700 (PDT) Subject: lindsay lohan breast Message-ID: <3f70fba3-fa43-404e-9fbb-0aedc889a629@t12g2000prg.googlegroups.com> Just few link on some Lindsay Lohan Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From sgeiger at ncee.net Tue Apr 15 09:27:00 2008 From: sgeiger at ncee.net (Shane Geiger) Date: Tue, 15 Apr 2008 08:27:00 -0500 Subject: hw to program on python In-Reply-To: <66jo14F2jfjnbU1@mid.uni-berlin.de> References: <2732d09a-b0e6-4ae6-a826-9fa375fb3e86@q10g2000prf.googlegroups.com> <66jo14F2jfjnbU1@mid.uni-berlin.de> Message-ID: <4804AD24.8000309@ncee.net> ashish, While you are waiting for Diez to arrive, you should check out this Web site: http://www.google.com. It has some interesting content. Perhaps you can find information there that will help you to ask a better question. Here is another page you should look at: http://www.catb.org/~esr/faqs/smart-questions.html All joking aside, this hasn't been an easily answered question. The creator of Python, Guido, was asking a similar question not so long ago: http://www.artima.com/weblogs/viewpost.jsp?thread=146149 The latest and greatest from Guido's company is Google App Engine, which you might want to learn about. http://www.techcrunch.com/2008/04/07/google-jumps-head-first-into-web-services-with-google-app-engine/ http://code.google.com/appengine/ http://www.computerworld.com.au/index.php/id;1913502382;fp;4;fpid;611908207 http://googleblog.blogspot.com/2008/04/developers-start-your-engines.html http://googleappengine.blogspot.com/2008/04/introducing-google-app-engine-our-new.html Shane Diez B. Roggisch wrote: > ashish wrote: > > >> hi , >> python experts i want some help from u people just mail me how to >> write scripts for web applications (like form coding for login page, >> etc). >> >> >> i m waiting.... for ur reply by >> > > While you are waiting, would a nice back-rub & and a good portion of powder > sugar gently blown up your behind be in order? I'd plain love to drop by & > give that to you, to make the dreaded waiting for the amassing expert > advice a bit more comfortable! > > Diez > -- Shane Geiger IT Director National Council on Economic Education sgeiger at ncee.net | 402-438-8958 | http://www.ncee.net Leading the Campaign for Economic and Financial Literacy From pavlovevidence at gmail.com Mon Apr 14 11:20:13 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 14 Apr 2008 08:20:13 -0700 (PDT) Subject: Java or C++? References: Message-ID: On Apr 14, 2:44 am, s0s... at gmail.com wrote: > Hello, I was hoping to get some opinions on a subject. I've been > programming Python for almost two years now. Recently I learned Perl, > but frankly I'm not very comfortable with it. Now I want to move on > two either Java or C++, but I'm not sure which. Which one do you think > is a softer transition for a Python programmer? Which one do you think > will educate me the best? If you weren't comfortable with Perl my bet is that you'll be less comfortable with C++ than Java. It's softer transition to Java than to C++ from just about any starting point. Carl Banks From dickinsm at gmail.com Sun Apr 13 10:28:22 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Sun, 13 Apr 2008 07:28:22 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> <01db54ab-1fca-4a51-8b98-510de224f40a@y21g2000hsf.googlegroups.com> <8e6dbc15-98f2-441d-bba4-d9ddb36f482d@i36g2000prf.googlegroups.com> Message-ID: On Apr 13, 4:18?am, Lie wrote: [...] > it and there is nothing else in it, but in the second number range > (barely above 1 to 2) the number 1.0 is not included while the number > 2.0 is contained in it, clearly not a clean separation of numbers in > the form of y.x where y is pre-determined and x is variable from other > possible values of y. Have you considered the fact that the real numbers of the form 1.xxxxx... are those in the range [1.0, 2.0], including *both* endpoints? That is, 2.0 = 1.999999... Similarly, the midpoint of this range can be written both in the form 1.500000... and 1.499999... This is relevant if you think of rounding as an operation on *decimal representations* of real numbers rather than as an operation on real numbers themselves. I'm not sure which point of view you're taking here. Either way, your arguments don't change the fact that the average rounding error is strictly positive for positive quantized results, under round-half-away-from-zero. Mark From stef.mientki at gmail.com Sat Apr 19 18:21:57 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Sun, 20 Apr 2008 00:21:57 +0200 Subject: Frame work for simple physics web applications In-Reply-To: References: <2b0b8b6c-8086-4bf6-8f47-27bc5c9c788c@v23g2000pro.googlegroups.com> <6bdd161d-6e92-4de6-8dba-d5c11b08990f@a22g2000hsc.googlegroups.com> Message-ID: <480A7085.6040002@gmail.com> Rick Muller wrote: > On Apr 19, 2:44 pm, globalrev wrote: > > >> www.vpython.orgmight be what you are looking for. >> > > Except, if I'm not mistaken, vpython isn't a web framework. It would > work if I wanted to write some python scripts and have other people > run them, but I want to run everything through a web page, so I don't > have to worry about installing python on everyone's computer So what should the students use when they want to explore quantum computing outside the scope you're offering ? C++, MatLab, LabView perhaps, this looks to me like an unique opportunity to promote Python. > and > distributing updates of all of my scripts. > I'm not familiar with this, but isn't it possible to run scripts from a website locally ? cheers, Stef From paul at science.uva.nl Fri Apr 25 08:16:44 2008 From: paul at science.uva.nl (Paul Melis) Date: Fri, 25 Apr 2008 14:16:44 +0200 Subject: Problem building python in virtual machine running centos In-Reply-To: References: Message-ID: Paul Boddie wrote: > On 25 Apr, 03:05, Alexandre Gillet wrote: > >>I am trying to build python-2.4.5 on Centos 5.1, which is a virtual >>machine running with xen. >>I am not able to build python. The compilation crash with the following: >>gcc -pthread -c -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. >>-I./Include -DPy_BUILD_CORE -o Objects/unicodeobject.o >>Objects/unicodeobject.c >>In file included from ./Include/Python.h:76, >> from Objects/unicodeobject.c:39: >>./Include/object.h:228: internal compiler error: Segmentation fault >>Please submit a full bug report, >>with preprocessed source if appropriate. >>See for instructions. >>The bug is not reproducible, so it is likely a hardware or OS problem. >> >>Any suggestion of what am I doing wrong? > > > You say that the bug is not reproducible, so that means that you can "The bug is not reproducible, so it is likely a hardware or OS problem." This line is printed by GCC itself, not the OP Paul > sometimes compile Python, or does the crash always happen when > compiling some file (not necessarily the one mentioned above)? I think > I've only ever seen a reproducible gcc crash once, and that had > something to do with a C++ source file which I then split into two and > was able to compile as these two separate parts. You might want to > check the gcc version (gcc -v) and to look at bug fixes in any later > versions. Generally, if you get an internal error in gcc, you aren't > doing anything wrong yourself. > > Paul From musiccomposition at gmail.com Wed Apr 2 22:29:09 2008 From: musiccomposition at gmail.com (Benjamin) Date: Wed, 2 Apr 2008 19:29:09 -0700 (PDT) Subject: Classes in modules References: <0cace2e1-6dbc-428f-9e53-ffb99ba42aab@e6g2000prf.googlegroups.com> Message-ID: <3d4c576e-127a-4499-bdbe-3c4faecd2275@a70g2000hsh.googlegroups.com> On Apr 2, 8:05 pm, hexusne... at gmail.com wrote: > I'm trying to get this source code split into multiple files: > > http://pygermanwhist.googlecode.com/files/pygermanwhist.12.py > > I've been trying to make so that I have one class per file for easier > readability. My problem is that the interpreter keeps saying that it > can't find methods and so forth whenever I try to split the code up. Have you read the modules part of the tutorial? http://docs.python.org/tut/node8.html > > This has been a recurring problem for me in languages such as C++ and > Java. I'm used to programming in C. From mcknight0219 at gmail.com Tue Apr 1 22:44:04 2008 From: mcknight0219 at gmail.com (Jimmy) Date: Tue, 1 Apr 2008 19:44:04 -0700 (PDT) Subject: the scaling of pics in pygame Message-ID: <49d8b8ae-08e3-4e86-9ced-2804b6dec4e5@b5g2000pri.googlegroups.com> Hi, everyone I am using Pygame to write a small program. I tried to load a .jpg picture into the screen, however, the size of the pic doesn't fit into the window properly. Can anyone tell me how to scale the picture into the window? thanks! From terry.yinzhe at gmail.com Mon Apr 28 19:28:12 2008 From: terry.yinzhe at gmail.com (Terry) Date: Mon, 28 Apr 2008 16:28:12 -0700 (PDT) Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> <18c1e6480804270653r2e075061wf442b7b7d9f50ff6@mail.gmail.com> <5b8a7008-d463-41cb-ba67-1440fe00dfb4@y21g2000hsf.googlegroups.com> Message-ID: On Apr 28, 10:48 pm, "dcof... at gmail.com" wrote: > I've never used it myself but you may find candygram interesting;http://candygram.sourceforge.net, which AFAIK implements Erlang-style > message queues in Python. Thank you. I will look at candygram and stackless. I believe my solution lies in either of them. From jzgoda at o2.usun.pl Mon Apr 7 05:00:55 2008 From: jzgoda at o2.usun.pl (Jarek Zgoda) Date: Mon, 07 Apr 2008 11:00:55 +0200 Subject: csv.DictReader and unicode In-Reply-To: References: Message-ID: Laszlo Nagy napisa?(a): > This program > > fin = codecs.open(fname,"r",encoding="UTF-8") > eader = csv.DictReader(fin) > for values in reader: > pass > > results in: > > File "run.py", line 23, in process_file > for values in reader: > File "/usr/local/lib/python2.5/csv.py", line 83, in next > row = self.reader.next() > UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in > position 13: ordinal not in range(128) > > As you can see the exception is thrown in csv.py. How it is possible? > The csv.DictReader should not use ascii codec for anything, because the > file encoding is UTF-8. Reader works with byte strings, not unicode objects. -- Jarek Zgoda Skype: jzgoda | GTalk: zgoda at jabber.aster.pl | voice: +48228430101 "We read Knuth so you don't have to." (Tim Peters) From uniontelecardsindia at gmail.com Tue Apr 22 17:17:45 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:17:45 -0700 (PDT) Subject: Nasty gangbang gay trio in the fields Message-ID: Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From garionphx at gmail.com Thu Apr 17 17:19:45 2008 From: garionphx at gmail.com (John Sutherland) Date: Thu, 17 Apr 2008 14:19:45 -0700 Subject: Building an RPM Message-ID: <2F12200B-934E-44D2-94E8-D3E4BDE8FB56@gmail.com> Hi everyone.. I'm attempting to build an RPM for Python 2.5.2, using the spec file found in the standard tarball (Misc/RPM).. Currently, its failing cause it hasn't 'compiled' the tools .pyc and .pyo's, saying the files aren't found. Anyone have any ideas? (running on CentOS 4.3) --John From dotancohen at gmail.com Sat Apr 19 18:22:06 2008 From: dotancohen at gmail.com (Dotan Cohen) Date: Sun, 20 Apr 2008 01:22:06 +0300 Subject: Python for Series 40 Nokia? In-Reply-To: References: Message-ID: <880dece00804191522hde8c4d4u7678b1cecd29df60@mail.gmail.com> On 18/04/2008, colemichae at gmail.com wrote: > On Apr 18, 8:46 am, "Dotan Cohen" wrote: > > I had once heard something about python running on a Series 40 Nokia, > > but I am unable to google anything concrete. Might it have been > > Jython? Is there a known implementation of Python for the series 40 > > (which is not Symbian, by the way)? Will Jython work in such an > > environment? > > > > Thanks in advance. > > there is a comment here of using jython on a nokia S40 > Nokia 7210 SDK for Nokia Series 40 platform. > http://bookshelf.sourceforge.net/en/src-build.html > > So i think i will work. > > I am using a S60 and works well, I have a GPS program in Python, > Editors, Ogg player, and other assorted items. > > I myself purchased the Nokia N70 purely because of the Python ability > it had.. Thanks. I have tried to avoid Symbian phones as they are slow and irresponsive to input in my experience. That said, I loved my N-Gage and irresponsiveness really was my only complaint with the device. Perhaps if the newer models are more responsive, then I will switch so that I can run Python on it. Thanks. Dotan Cohen http://what-is-what.com http://gibberish.co.il ?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? From ewertman at gmail.com Sat Apr 26 18:02:58 2008 From: ewertman at gmail.com (Eric Wertman) Date: Sat, 26 Apr 2008 18:02:58 -0400 Subject: learning with python question (HtTLaPP) In-Reply-To: <53d6254f-895f-48fb-8ab9-3929c403f11b@v23g2000pro.googlegroups.com> References: <98acecbd-9de2-4ebf-927b-ac6bc1fbc3fd@b5g2000pri.googlegroups.com> <53d6254f-895f-48fb-8ab9-3929c403f11b@v23g2000pro.googlegroups.com> Message-ID: <92da89760804261502h4f7aea3p739a176ef14f06b3@mail.gmail.com> > Is the way I wrote the function inherently wrong? What I wrote I would not say that. I think a lot of people probably start off like that with python. You'll find in most cases that manually keeping counters isn't necessary. If you really want to learn python though, I would suggest using built in functions and libraries as much as possible, as that's where the real power comes from (IMO). > returns the sequence, however I'm trying to make the output match for > the letters in the string entered, not necessarily the string > sequence. > Only the sequence shows up 'uzi'. I don't get words like 'unzip' or > 'Zurich' . I've only barely started on invocation and maybe writing > something like I'm describing is above what level I'm currently at. This would be a more difficult approach.. Where you are doing the comparison step: if letters in line.strip(): It's trying to match the exact string "uzi", not any of the individual letters. You would need to look for each letter independently and then make sure they were in the right order to match the other words. From workitharder at gmail.com Thu Apr 3 12:38:31 2008 From: workitharder at gmail.com (bukzor) Date: Thu, 3 Apr 2008 09:38:31 -0700 (PDT) Subject: Directed Graph Traversal References: <804682cb-2da6-4d85-83d4-c7425c498534@p25g2000hsf.googlegroups.com> Message-ID: <8495625e-608e-4c8c-b7f8-f5e47e09082d@c19g2000prf.googlegroups.com> On Apr 2, 8:33 pm, Scott David Daniels wrote: > bukzor wrote: > > Can someone point me in the direction of a good solution of this? I'm > > using it to construct a SQL query compiler, .... > > Given a directed graph and a list of points in the graph, what is the > > minimal subgraph that contains them all? It is preferable that the > > subgraph is a tree. > > I did something nice (but non-redistributable) on this once: here is the > driving intuition: > > * Start with every point a distinct color. > * Add all points adjacent in the digraph as the same color; merge > colors as you join them. > * When you are down to to a single color, you have the minimal solution > in the set you've chosen. > > I actually did a cheapest-first search; adding an edge each time. > There is a post-join pruning step that was (as I recall) fairly simple. > > -Scott David Daniels > Scott.Dani... at Acm.Org That sounds like a kind of iterative deepening search, which is what I'm planning to do. Once I have it written up, I'll post for your pythonic enjoyment. --Buck From nospam at nospam.com Sat Apr 26 17:57:25 2008 From: nospam at nospam.com (Gilles Ganault) Date: Sat, 26 Apr 2008 23:57:25 +0200 Subject: [py2exe] What to download when updating? Message-ID: Hello Out of curiosity, if I recompile a Python (wxPython) app with py2exe, can I have customers just download the latest .exe, or are there dependencies that require downloading the whole thing again? FWIW, here's the list of files that were created after running py2exe: myprog.exe bz2.pyd library.zip MSVCR71.dll python25.dll unicodedata.pyd w9xpopen.exe wxbase28uh_net_vc.dll wxbase28uh_vc.dll wxmsw28uh_adv_vc.dll wxmsw28uh_core_vc.dll wxmsw28uh_html_vc.dll _controls_.pyd _core_.pyd _gdi_.pyd _misc_.pyd _windows_.pyd Thank you. From corvettecraz92 at gmail.com Tue Apr 8 21:01:01 2008 From: corvettecraz92 at gmail.com (corvettecraz92 at gmail.com) Date: Tue, 8 Apr 2008 18:01:01 -0700 (PDT) Subject: text adventure game problem Message-ID: okay, I'm having this one problem with a text adventure game. It's kind of hard to explain, but I'll do my best. [code] def prompt_kitchen(): global gold gold_taken = False while True: prompt_kit = raw_input('>') if prompt_kit == 'examine cabinet 1' and not gold_taken: print '''This cabinet has a lot of cups in it with all different designs and shapes. Where are the people anyway? How come there's nobody here? In one of the cups you find 8 gold.''' gold = gold+8 gold_taken = True pass4() elif prompt_kit == 'examine cabinet 1' and gold_taken: print \ '''This cabinet has a lot of cups in it with all different designs and shapes. Where are the people anyway? How come there's nobody here?''' pass4() def pass4(): global gold print 'You have', gold, 'gold' pass [/code] Okay, now for my problem. In the above function, there's the option to examine a cabinet and get 8 gold. (everyone here knows that...but I'm just trying to state my problem...) Unfortunately, it kind of doesn't work. After the first time I 'examine cabinet 1' in my game, I get 8 gold and I can't get it again. But, If I leave the room and come back to it, then it's as if I had never gotten the gold the first time, and I can get it again. How do I fix this? From carlwuhwdmckay at gmail.com Mon Apr 21 02:07:04 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:07:04 -0700 (PDT) Subject: 89th mp brigade patch Message-ID: <189bd725-d100-4740-ba74-5d06ff492eb3@l64g2000hse.googlegroups.com> 89th mp brigade patch http://cracks.00bp.com F R E E C R A C K S From arnodel at googlemail.com Mon Apr 14 11:55:35 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Mon, 14 Apr 2008 08:55:35 -0700 (PDT) Subject: eval modifies passed dict References: <2b2398b1-042e-46bb-b840-ea9e07d87bd1@2g2000hsn.googlegroups.com> Message-ID: <0bc1464d-684e-476f-b9f3-800325b0a82b@y18g2000pre.googlegroups.com> On Apr 14, 4:23?pm, Janto Dreijer wrote: > It seems eval is modifying the passed in locals/globals. This is > behaviour I did not expect and is really messing up my web.py app. Reading the documentation would be a good start: From http://docs.python.org/lib/built-in-funcs.html: eval( expression[, globals[, locals]]) The arguments are a string and optional globals and locals. If provided, globals must be a dictionary. If provided, locals can be any mapping object. Changed in version 2.4: formerly locals was required to be a dictionary. The expression argument is parsed and evaluated as a Python expression (technically speaking, a condition list) using the globals and locals dictionaries as global and local name space. If the globals dictionary is present and lacks '__builtins__', the current globals are copied into globals before expression is parsed. -- Arnaud From pDOTpagel at helmholtz-muenchen.de Fri Apr 11 10:28:47 2008 From: pDOTpagel at helmholtz-muenchen.de (Philipp Pagel) Date: Fri, 11 Apr 2008 14:28:47 +0000 (UTC) Subject: Graphs in Python References: Message-ID: greg_kr wrote: > You should use Python with R. Google for Rpy, this is the best > Graphing you can do with Python The OP was refering to graph as in 'graph-theory', not plotting data. Of course, R has some packages for dealing with graphs in the former sense but I don't think that's a good solution to the OP's problem. cu Philipp -- Dr. Philipp Pagel Lehrstuhl f. Genomorientierte Bioinformatik Technische Universit?t M?nchen http://mips.gsf.de/staff/pagel From pydev at rscorp.ab.ca Tue Apr 29 14:42:41 2008 From: pydev at rscorp.ab.ca (Scott SA) Date: Tue, 29 Apr 2008 12:42:41 -0600 Subject: @classmethod question In-Reply-To: <481048cf$0$13051$426a74cc@news.free.fr> Message-ID: On 4/24/08, Bruno Desthuilliers (bruno.42.desthuilliers at websiteburo.invalid) wrote: >> It is a series of convenience methods, in this case I'm interacting >> with a database via an ORM (object-relational model). > >out of curiosity : which one ? I'm rapidly becoming a "django junkie"^TM >> I want the ability >> to call a class-ojbect and get related values, or pass some criteria and >> get related values for them without collecting the records first as >> instances, then iterating them. I need to call this from several places >> so I want to be DRY (don't repeat yourself). >> >> The easiest way to describe this as an analogy would be like having a >> recipie for cookies and wanting to know all of the ingredients ahead of >> time. Then, at another time, wanting to know what all the ingredients >> would be to make cookies, cake and bread (i.e. complete shopping list). > >> cookie_recipie = RecipieClass.get_recipie('cookies') >> cookie_recipie.get_ingredients() >> 2C Flour >> 0.5 C Sugar >> ... >> >> RecipieClass.get_ingrendients(['cookies','cake','bread']) >> 8C Flour >> 2C Sugar >> ... > > > Of course any suggestions on how this might be better approached >would > be interesting too. > >Why do you want the same method to do two different things ? You clearly >have two distincts methods doing different things here, and as a user of In retrospect, my example was poorer than I first thought - or was it my spec. Regardless, it wasn't quite right. The question/premise should have been: Is there an effective/accptable way to include class-related utilities that are callable _without_ instantiating an object? I now get the feeling that some of what I was thinking of would be considered bad form and should be separated into the application or a library of sorts. > your code I'd find your API confusing. May I suggest a much simpler >approach: > >class Recipies(object): > @property > def ingredients(self): > return > > @classmethod > def get_ingredients_for(cls, *id_recipies): > return > >print Recipie.get('cookie').ingredients >print Recipies.get_ingredients_for('cookie', 'cake', 'bread') Yes, thank you. While my example didn't accurately portray my original thoughts, this is an educational example of merit. I'm still crossing the bridge of conceptual understanding into practical application. Decoration appears very useful, it's practical application requires a level of thought I'm not fluent. Google is helping. >My 2 cents... You're short-changing yourself ;-) Thanks for your input, Scott From mdw at distorted.org.uk Tue Apr 22 08:47:26 2008 From: mdw at distorted.org.uk (Mark Wooding) Date: Tue, 22 Apr 2008 12:47:26 +0000 (UTC) Subject: Segfault accessing dictionary in C Python module References: Message-ID: Mitko Haralanov wrote: > value = PyDict_GetItem (new_dict, key); You're not calling Py_DECREF on this value are you? That's a no-no, since you're borrowing the dictionary's reference. -- [mdw] From gagsl-py2 at yahoo.com.ar Mon Apr 28 21:04:42 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 28 Apr 2008 22:04:42 -0300 Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> <87od7ue2ne.fsf@mulj.homelinux.net> Message-ID: En Mon, 28 Apr 2008 19:29:33 -0300, escribi?: > A question regarding cStringIO.StringIO(): is there a way to do get > getvalue() to return all the bytes after the current file position > (not before)? For example > > buf = cStringIO.StringIO() > buf.write("foo bar") > buf.seek(3) > buf.getvalue(True) # the True argument means > # to return the bytes up > # to the current file position > > That returns 'foo'. Is there a way to get it to return ' bar'? buf.read() - the obvious answer, once you know it :) -- Gabriel Genellina From bj_666 at gmx.net Mon Apr 28 07:39:45 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 28 Apr 2008 11:39:45 GMT Subject: Need help on left padding References: Message-ID: <67lrc1F2o7iv7U3@mid.uni-berlin.de> On Mon, 28 Apr 2008 04:37:02 -0700, rajesh kataraki wrote: > My requirement is I am using one variable ex. var = 5 which is > integer. > And this variable, I m using in some string. But I want this var > to be used as 005 again integer in this string. In [22]: '%03d' % 5 Out[22]: '005' Ciao, Marc 'BlackJack' Rintsch From hdante at gmail.com Fri Apr 25 20:13:02 2008 From: hdante at gmail.com (hdante) Date: Fri, 25 Apr 2008 17:13:02 -0700 (PDT) Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> Message-ID: <5c5e740d-6974-4aa6-8a79-468ce68a6e37@e53g2000hsa.googlegroups.com> On Apr 25, 7:39?pm, s0s... at gmail.com wrote: > I wanted to ask for standard ways to receive data from a socket stream > (with socket.socket.recv()). It's simple when you know the amount of > data that you're going to receive, or when you'll receive data until > the remote peer closes the connection. But I'm not sure which is the > best way to receive a message with undetermined length from a stream > in a connection that you expect to remain open. Until now, I've been > doing this little trick: > > data = client.recv(256) > new = data > while len(new) == 256: > ? ? new = client.recv(256) > ? ? data += new > > That works well in most cases. But it's obviously error-prone. What if > the client sent *exactly* two hundred and fifty six bytes? It would > keep waiting for data inside the loop. Is there really a better and > standard way, or is this as best as it gets? > > Sorry if this is a little off-topic and more related to networking, > but I'm using Python anyway. > > Thanks, > Sebastian done = False remaining = '' while done == False: data = client.recv(256) done, remaining = process(remaining + data) PS: are you sure you shouldn't be using RPC or SOAP ? From gagsl-py2 at yahoo.com.ar Wed Apr 16 19:17:40 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 20:17:40 -0300 Subject: import hooks References: <664bf2b80804151814g480eed02w739047f84d9deb6b@mail.gmail.com> <664bf2b80804160504x72c870d8pdbfe8105a0c5ed11@mail.gmail.com> Message-ID: En Wed, 16 Apr 2008 09:04:36 -0300, Patrick Stinson escribi?: > I am defining a simple finder/loader object and adding it to > sys.meta_path > like this: > > PyRun_SimpleString("import sys; import ousiainternal; sys.meta_path = > [ousiainternal.OusiaImporter]"); You should append to the existing meta_path, not replace it, erasing any previous content. And it must be an *instance* of your importer, not the type itself. Note that you're polluting the __main__ module namespace by using PyRun_SimpleString; I'd use API calls like PySys_GetObject("meta_path") and PyList_Append (PEP 302 guarantees it is a list). > "sys.meta_path.append(Importer)\n"; Here you append to sys.meta_path, but fail to create the instance first. > PyRun_SimpleString(importer_source); You should check the return value; I bet you got a -1 (failure). -- Gabriel Genellina From alderos at terra.com.br Sun Apr 13 20:42:49 2008 From: alderos at terra.com.br (Alderos Martins) Date: Sun, 13 Apr 2008 22:42:49 -0200 Subject: Remove my mail, please ! Message-ID: Please, remove my mail in to python list. I don?t receive mails. Thank?s. Alderos. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ptmcg at austin.rr.com Wed Apr 23 12:41:27 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Wed, 23 Apr 2008 09:41:27 -0700 (PDT) Subject: help needed with classes/inheritance References: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> <480f05d0$0$25755$426a74cc@news.free.fr> <676bac37-2816-402b-9aed-1a9c1873351b@a23g2000hsc.googlegroups.com> Message-ID: On Apr 23, 10:44?am, barbaros wrote: > > If I understand correctly, in the above implementation I cannot > define firstly a (non-oriented) body, and then build, on top of it, > two bodies with opposite orientations. The point is, I want > both oriented bodies to share the same base Body object. What you are describing is composition+delegation, not inheritance, and it would be the same answer in Java, C++, or OO-langue-du-jour. Python makes delegation to the contained object easier than the others (except maybe for OOldj) - no need to implement all the methods of the contained object in the container, that just delegate the call to the contained; use __getattr__ to get attributes of the contained object that are not defined on the container (methods are attributes, too) as shown below. No inheritance in this example at all. -- Paul class BodyWithoutOrientation(object): def __init__(self,color): self.color = color def show_orientation(self): print "I don't lean one way or the other" class OrientedBody(object): def __init__(self,base,orientation): self.base_body = base self.orientation = orientation def show_orientation(self): print "I lean to the " + \ { OrientedBody.RIGHT : "right", OrientedBody.LEFT : "left", }[self.orientation], print "and my color is " + self.color # delegate any other attr lookups to the base_body object def __getattr__(self,attr): return getattr(self.base_body,attr) OrientedBody.RIGHT = object() OrientedBody.LEFT = object() class LeftRightBody(object): def __init__(self,b): self.common_base = b self.left = OrientedBody(b,OrientedBody.LEFT) self.right = OrientedBody(b,OrientedBody.RIGHT) def show_orientation(self): print "I do both of these:" print "- ", self.left.show_orientation() print "- ", self.right.show_orientation() base = BodyWithoutOrientation("purple") lr = LeftRightBody(base) base.show_orientation() lr.show_orientation() Prints: I don't lean one way or the other I do both of these: - I lean to the left and my color is purple - I lean to the right and my color is purple From arnodel at googlemail.com Tue Apr 8 16:33:45 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Tue, 8 Apr 2008 13:33:45 -0700 (PDT) Subject: CPython VM & byte code resources wanted References: <6622srF2e32hbU1@mid.individual.net> Message-ID: On Apr 8, 9:29?pm, "Aaron Gray" wrote: > Hi, > > I am looking to study the CPython source code, but I cannot seem to find the > VM code. > Also is there any where a detailed ?list of the opcodes ? > > Many thanks in advance, > > Aaron Bytecodes: http://docs.python.org/lib/bytecodes.html VM: Python/ceval.c HTH -- Arnaud From sandip.more at gmail.com Tue Apr 29 01:58:09 2008 From: sandip.more at gmail.com (sandipm) Date: Mon, 28 Apr 2008 22:58:09 -0700 (PDT) Subject: python script as executable References: Message-ID: <4e7ff885-616f-4041-a9b0-4dc6e6c892b2@p39g2000prm.googlegroups.com> thanks it worked On Apr 29, 10:49 am, "Eric Wertman" wrote: > Try to ftp it in ascii mode, or find a dos2unix utility .. the file > has probably got \r\n (windows) line terminators in it.. causes > problems. I guess it's also possible that /usr/bin/env doesn't > exist... not likely though. > > On Tue, Apr 29, 2008 at 1:36 AM, sandipm wrote: > > Hi, > > I have written a python script to run from cron. > > I have put #!/usr/bin/env python at top. file executes correctly when > > I run using python filename.py but > > it fails to execute when try to run it like script/command. > > it throws error: > > :No such file or directory > > > I am editing file from eclipse for python from windows. and then > > uploading on linus machine to run it. > > > any pointers? > > > sandip > > -- > > http://mail.python.org/mailman/listinfo/python-list From john106henry at hotmail.com Sat Apr 26 19:17:59 2008 From: john106henry at hotmail.com (John Henry) Date: Sat, 26 Apr 2008 16:17:59 -0700 (PDT) Subject: How do I say "Is this a function"? Message-ID: How do I determine is something a function? For instance, I don't want to relying on exceptions below: def f1(): print "In f1" def f3(): print "In f3" def others(): print "In others" for i in xrange(1,3): fct = "f%d()"%(i+1) try: exec fct except: others() I wish to say: if value of fct is a funtion, invoke it, otherwise invoke others(). Thanks, From wilson.t.thompson at gmail.com Fri Apr 4 18:07:59 2008 From: wilson.t.thompson at gmail.com (wilson) Date: Fri, 4 Apr 2008 15:07:59 -0700 (PDT) Subject: displaying pgm file in python Message-ID: i converted an 8bit rgb .jpg file into .pgm using adobe photoshop and a plugin from http://photoshop.pluginsworld.com/plugins/adobe/362/richard-rosenman/portable-pixmap-importer-exporter.html I want to check if this file can be properly displayed. Image opening and show() in PIL fails to do it so i tried Tkinter i created a canvas in a tkinter gui and tried self.myimg=PhotoImage(file="mytestpic.pgm") self.selimgtag=self.canvorig.create_image(70,100,image=self.myimg) self.canvorig.update_idletasks() this causes AttributeError snd says can't identify image file I checked the asci text of .pgm file ,it starts with a line P2 and then several lines with integers..can someone tell me if there is a way to display this properly thanks W From vinay_sajip at yahoo.co.uk Thu Apr 10 13:13:33 2008 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Thu, 10 Apr 2008 10:13:33 -0700 (PDT) Subject: subprocess.Popen() output to logging.StreamHandler() References: Message-ID: <6b02e27c-916f-42a7-b2e0-75af51bba343@h1g2000prh.googlegroups.com> On Apr 10, 1:11 pm, "sven _" wrote: > Version: Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) > > My goal is to have stdout and stderr written to alogginghandler. > This code does not work: > > # START > importlogging, subprocess > ch =logging.StreamHandler() > ch.setLevel(logging.DEBUG) > subprocess.call(['ls', '-la'], 0, None, None, ch, ch) > # END > > Traceback (most recent call last): > File "log.py", line 5, in > subprocess.call(['ls', '-la'], 0, None, None, ch, ch) > File "/usr/lib/python2.5/subprocess.py", line 443, in call > return Popen(*popenargs, **kwargs).wait() > File "/usr/lib/python2.5/subprocess.py", line 586, in __init__ > errread, errwrite) = self._get_handles(stdin, stdout, stderr) > File "/usr/lib/python2.5/subprocess.py", line 941, in _get_handles > c2pwrite = stdout.fileno() > AttributeError: StreamHandler instance has no attribute 'fileno' > > This is because subprocess.Popen() expects file descriptors to write > to, andlogging.StreamHandler() does not supply it. The StreamHandler > could supply its own stdout file descriptor, but then Popen() would > write directly to that file, bypassing all theloggingfluff. > > A possible solution would be to make a named pipe (os.mkfifo()), have > Popen() write to that, and then have some horrendous hack run select() > or similar on the fifo to read from it and finally pass it to > StreamHandler. > > Are there better solutions? > > sven Thomas was almost right, but not quite - you can't call info on a Handler instance, only on a Logger instance. The following script: import logging import subprocess logging.basicConfig(level=logging.INFO) # will log to stderr of this script s = subprocess.Popen( ['ls','-la'], stdout=subprocess.PIPE ) while 1: line = s.stdout.readline() exitcode = s.poll() if (not line) and (exitcode is not None): break line = line[:-1] logging.info("%s", line) produces the following output: INFO:root:total 204 INFO:root:drwxr-xr-x 35 vinay vinay 4096 2008-04-10 18:06 . INFO:root:drwxr-xr-x 3 root root 4096 2008-03-22 07:09 .. INFO:root:-rw------- 1 vinay vinay 685 2008-04-10 17:26 .bash_history INFO:root:-rw-r--r-- 1 vinay vinay 220 2008-03-22 07:09 .bash_logout INFO:root:-rw-r--r-- 1 vinay vinay 2327 2008-03-22 07:09 .bashrc INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-04-05 02:21 .bluefish INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-03-22 07:18 .cache INFO:root:drwxr-xr-x 5 vinay vinay 4096 2008-03-22 07:32 .config INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Desktop INFO:root:-rw------- 1 vinay vinay 28 2008-04-10 00:33 .dmrc INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Documents INFO:root:-rw------- 1 vinay vinay 16 2008-03-22 07:17 .esd_auth INFO:root:lrwxrwxrwx 1 vinay vinay 26 2008-03-22 07:09 Examples -> / usr/share/example-content INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-04-10 00:21 .fontconfig INFO:root:drwx------ 4 vinay vinay 4096 2008-04-10 17:23 .gconf INFO:root:drwx------ 2 vinay vinay 4096 2008-04-10 17:43 .gconfd INFO:root:-rw-r----- 1 vinay vinay 0 2008-03-24 19:13 .gksu.lock INFO:root:drwx------ 9 vinay vinay 4096 2008-04-10 00:31 .gnome2 INFO:root:drwx------ 2 vinay vinay 4096 2008-03-22 07:17 .gnome2_private INFO:root:drwx------ 2 vinay vinay 4096 2008-04-10 00:33 .gnupg INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-04-10 00:33 .gstreamer-0.10 INFO:root:-rw-r--r-- 1 vinay vinay 108 2008-04-10 00:33 .gtk- bookmarks INFO:root:dr-x------ 2 vinay vinay 0 2008-04-10 00:33 .gvfs INFO:root:-rw------- 1 vinay vinay 167 2008-04-10 00:33 .ICEauthority INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-03-22 07:18 .local INFO:root:drwx------ 3 vinay vinay 4096 2008-03-22 07:18 .metacity INFO:root:drwx------ 4 vinay vinay 4096 2008-03-24 19:13 .mozilla INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Music INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-04-10 00:31 .nautilus INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-04-05 02:09 .netbeans INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-04-05 02:09 .netbeans- registration INFO:root:drwx------ 3 vinay vinay 4096 2008-04-05 02:15 .openoffice.org2 INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Pictures INFO:root:-rw-r--r-- 1 vinay vinay 566 2008-03-22 07:09 .profile INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Public INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 08:01 .pulse INFO:root:-rw------- 1 vinay vinay 256 2008-03-22 07:17 .pulse- cookie INFO:root:-rw-r--r-- 1 vinay vinay 1973 2008-04-10 18:06 .recently- used.xbel INFO:root:drwx------ 2 vinay vinay 4096 2008-03-22 07:17 .ssh INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-04-05 02:09 .subversion INFO:root:-rw-r--r-- 1 vinay vinay 0 2008-03-22 07:34 .sudo_as_admin_successful INFO:root:drwxr-xr-x 4 vinay vinay 4096 2008-03-22 09:10 .sudoku INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Templates INFO:root:-rw-r--r-- 1 vinay vinay 297 2008-04-10 18:06 test.py INFO:root:-rw-r--r-- 1 vinay vinay 291 2008-04-10 18:06 test.py~ INFO:root:-rwxr--r-- 1 vinay vinay 75 2008-03-22 07:33 update INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 08:22 .update- manager-core INFO:root:drwx------ 2 vinay vinay 4096 2008-03-22 07:18 .update- notifier INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Videos INFO:root:drwxr-xr-x 7 vinay vinay 4096 2007-10-08 14:56 vmware-tools- distrib INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-04-07 00:19 .wapi INFO:root:-rw------- 1 vinay vinay 121 2008-04-10 00:33 .Xauthority INFO:root:-rw-r--r-- 1 vinay vinay 146 2008-04-09 21:33 .xscreensaver-getimage.cache INFO:root:-rw-r--r-- 1 vinay vinay 5102 2008-04-10 17:31 .xsession- errors vinay at zeta-hardy:~$ python test.py | more INFO:root:total 204 INFO:root:drwxr-xr-x 35 vinay vinay 4096 2008-04-10 18:07 . INFO:root:drwxr-xr-x 3 root root 4096 2008-03-22 07:09 .. INFO:root:-rw------- 1 vinay vinay 685 2008-04-10 17:26 .bash_history INFO:root:-rw-r--r-- 1 vinay vinay 220 2008-03-22 07:09 .bash_logout INFO:root:-rw-r--r-- 1 vinay vinay 2327 2008-03-22 07:09 .bashrc INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-04-05 02:21 .bluefish INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-03-22 07:18 .cache INFO:root:drwxr-xr-x 5 vinay vinay 4096 2008-03-22 07:32 .config INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Desktop INFO:root:-rw------- 1 vinay vinay 28 2008-04-10 00:33 .dmrc INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Documents INFO:root:-rw------- 1 vinay vinay 16 2008-03-22 07:17 .esd_auth INFO:root:lrwxrwxrwx 1 vinay vinay 26 2008-03-22 07:09 Examples -> / usr/share/example-content INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-04-10 00:21 .fontconfig INFO:root:drwx------ 4 vinay vinay 4096 2008-04-10 17:23 .gconf INFO:root:drwx------ 2 vinay vinay 4096 2008-04-10 17:43 .gconfd INFO:root:-rw-r----- 1 vinay vinay 0 2008-03-24 19:13 .gksu.lock INFO:root:drwx------ 9 vinay vinay 4096 2008-04-10 00:31 .gnome2 INFO:root:drwx------ 2 vinay vinay 4096 2008-03-22 07:17 .gnome2_private INFO:root:drwx------ 2 vinay vinay 4096 2008-04-10 00:33 .gnupg INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-04-10 00:33 .gstreamer-0.10 INFO:root:-rw-r--r-- 1 vinay vinay 108 2008-04-10 00:33 .gtk- bookmarks INFO:root:dr-x------ 2 vinay vinay 0 2008-04-10 00:33 .gvfs INFO:root:-rw------- 1 vinay vinay 167 2008-04-10 00:33 .ICEauthority INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-03-22 07:18 .local INFO:root:drwx------ 3 vinay vinay 4096 2008-03-22 07:18 .metacity INFO:root:drwx------ 4 vinay vinay 4096 2008-03-24 19:13 .mozilla INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Music INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-04-10 00:31 .nautilus INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-04-05 02:09 .netbeans INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-04-05 02:09 .netbeans- registration INFO:root:drwx------ 3 vinay vinay 4096 2008-04-05 02:15 .openoffice.org2 INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Pictures INFO:root:-rw-r--r-- 1 vinay vinay 566 2008-03-22 07:09 .profile INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Public INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 08:01 .pulse INFO:root:-rw------- 1 vinay vinay 256 2008-03-22 07:17 .pulse- cookie INFO:root:-rw-r--r-- 1 vinay vinay 1973 2008-04-10 18:07 .recently- used.xbel INFO:root:drwx------ 2 vinay vinay 4096 2008-03-22 07:17 .ssh INFO:root:drwxr-xr-x 3 vinay vinay 4096 2008-04-05 02:09 .subversion INFO:root:-rw-r--r-- 1 vinay vinay 0 2008-03-22 07:34 .sudo_as_admin_successful INFO:root:drwxr-xr-x 4 vinay vinay 4096 2008-03-22 09:10 .sudoku INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Templates INFO:root:-rw-r--r-- 1 vinay vinay 339 2008-04-10 18:07 test.py INFO:root:-rw-r--r-- 1 vinay vinay 303 2008-04-10 18:07 test.py~ INFO:root:-rwxr--r-- 1 vinay vinay 75 2008-03-22 07:33 update INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 08:22 .update- manager-core INFO:root:drwx------ 2 vinay vinay 4096 2008-03-22 07:18 .update- notifier INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-03-22 07:17 Videos INFO:root:drwxr-xr-x 7 vinay vinay 4096 2007-10-08 14:56 vmware-tools- distrib INFO:root:drwxr-xr-x 2 vinay vinay 4096 2008-04-07 00:19 .wapi INFO:root:-rw------- 1 vinay vinay 121 2008-04-10 00:33 .Xauthority INFO:root:-rw-r--r-- 1 vinay vinay 146 2008-04-09 21:33 .xscreensaver-getimage.cache INFO:root:-rw-r--r-- 1 vinay vinay 5102 2008-04-10 17:31 .xsession- errors You should be able to adapt this to your specific requirement. Regards, Vinay Sajip N.B. This test was run using Python 2.5.2 on Ubuntu Hardy Heron (beta): Python 2.5.2 (r252:60911, Apr 8 2008, 21:49:41) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 From john00587 at gmail.com Mon Apr 21 01:38:46 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:38:46 -0700 (PDT) Subject: gutterball 2 crack Message-ID: <134ec4fc-9c54-4a60-8cb9-6b2df443d3ed@w1g2000prd.googlegroups.com> gutterball 2 crack http://cracks.00bp.com F R E E C R A C K S From sturlamolden at yahoo.no Thu Apr 24 20:07:52 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 17:07:52 -0700 (PDT) Subject: Psyco alternative References: <1369b321-f55b-432b-b2f9-6144787509d8@h11g2000prf.googlegroups.com> <7xlk4473ai.fsf@ruckus.brouhaha.com> <651ncdF2cmik2U1@mid.uni-berlin.de> Message-ID: On Mar 27, 4:02 pm, king kikapu wrote: > As for psyco, are there any alternatives to use now ? When Cython has implemented all of Python's syntax, we can replace CPython's compiler and bytecode interpreter with Cython and a C compiler. Cython can be one or two orders of magnitude faster than CPython. From steve at holdenweb.com Sun Apr 20 10:27:42 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 20 Apr 2008 10:27:42 -0400 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <480B3B2D.6040206@gmail.com> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> Message-ID: <480B52DE.8070105@holdenweb.com> Hank @ITGroup wrote: > Apology for the previous offensive title~~ > :) > Thanks, Rintsch, Arnaud and Daniel, for replying so soon. > > I redid the experiment. What following is the record - > > ``starting python`` # == Windows Task Manager: > Python.exe *4,076 *K memory-usage == > >>> st1='abcdefg'*999999 # == 10,952 K == > >>> del st1 # == *4,104*K == > >>> st1='abcdefg'*999999 # == 10,952 K == > >>> del st1 # == 4,104 K == > > >>> li = ['abcde']*999999 # == 8,024 K == > >>> del li # == *4,108* K == > > >>> from nltk import FreqDist # == 17,596 == > >>> fd = FreqDist() # == 17,596 == > >>> for i in range(999999):fd.inc(i) # == 53,412 == > >>> del fd # == *28,780* == > >>> fd2 = FreqDist() # == 28,780 == > >>> for i in range(999999):fd2.inc(i) # == 53,412 == > >>> del fd2 # == 28,780 K == > > >>> def foo(): > ... fd3 = FreqDist() > ... for i in range(999999):fd3.inc(i) > > >>> foo() # == *28,788* K == > > >>> def bar(): > ... fd4 = FreqDist() > ... for i in range(999999):fd4.inc(i) > ... del fd4 > # == 28,788 K == > >>> bar() # == 28,788 K == > > > That is my question, after ``del``, sometimes the memory space returns > back as nothing happened, sometimes not... ... > What exactly was happening??? > > Best regards to all PYTHON people ~~ > !!! Python Team are great !!! > It doesn't really make that much sense to watch memory usage as you have been doing. Your first test case appears to trigger a specific pathology, where the memory allocator actually returns the memory to the operating system when the garbage collector manages to free all of it. Most often this doesn't happen - a chunk of memory might be 99.99% free but still have one small piece used, and so while there is a large amount of "free" memory for Python to allocate without requesting more process memory, this won't be reflected in any external measurement. You are suffering from a pathological condition yourself: the desire to optimize performance in an area where you do not have any problems. I would suggest you just enjoy using Python (its memory management doesn't suck at all, so your title line was inflammatory and simply highlights your lack of knowledge) and then start to ask these questions again when you have a real issue that's stopping you from getting real work done. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From victorsubervi at gmail.com Thu Apr 10 10:46:11 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 10 Apr 2008 09:46:11 -0500 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> <47FCF421.6000807@holdenweb.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> Message-ID: <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> Okay, here is where we find the fly in the ointment. If I run this code: #! /usr/bin/python import MySQLdb print "Content-type: image/jpeg\r\n" host = 'mysqldb2.ehost-services.com' db = 'benobeno_bre' user = 'benobeno' passwd = '21122112' connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor = connection.cursor() cursor.execute('select pic1 from products where id="2";') content = cursor.fetchall()[0][0] content = content.tostring() print content f = open("2.jpg", "w") f.write(content) f.close() all is well :) If, however, I change two lines to make it an html page: #! /usr/bin/python import MySQLdb # print "Content-type: image/jpeg\r\n" print "Content-type: text/html\n" host = 'mysqldb2.ehost-services.com' db = 'benobeno_bre' user = 'benobeno' passwd = '21122112' connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor = connection.cursor() cursor.execute('select pic1 from products where id="2";') content = cursor.fetchall()[0][0] content = content.tostring() print '

' % content # print content f = open("2.jpg", "w") f.write(content) f.close() it prints garbage. It does not yield the image. Now, what? TIA. Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From deets at nospam.web.de Wed Apr 9 13:41:40 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 09 Apr 2008 19:41:40 +0200 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. In-Reply-To: <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> Message-ID: <664detF2fmo9dU1@mid.uni-berlin.de> subhabrata.iisc at hotmail.com schrieb: > Hi Steve, > comp.lang.python is supposed to be a serious group not anyone knowing > nothing and giving comment. Well, original code snippet I don't know > why an expert person like you fails to understand, I told it almost > can't you guess the next portion? And this is outright outrageous. You are actually *aware* that people must guess what you mean and expect them to do so, sparing yourself the work of providing better information - willfully? This is as close to impertinence as it can get. Diez From gagsl-py2 at yahoo.com.ar Fri Apr 25 21:46:39 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 25 Apr 2008 22:46:39 -0300 Subject: ioctl, pass buffer address, howto? References: Message-ID: En Fri, 25 Apr 2008 09:30:56 -0300, Neal Becker escribi?: > I need an ioctl call equivalent to this C code: > > my_struct s; > s.p = p; << a pointer to an array of char > s.image_size = image_size; > return (ioctl(fd, xxx, &s)); > > I'm thinking to use python array for the array of char, but I don't see > how > to put it's address into the structure. Use the array's buffer_info() method: """buffer_info(): Return a tuple (address, length) giving the current memory address and the length in elements of the buffer used to hold array's contents.""" and you can use the struct module to build my_struct. > Maybe ctypes is the answer? It could be used too, but I think that in this case it's harder to use ctypes. -- Gabriel Genellina From dteslenko at gmail.com Mon Apr 14 05:33:32 2008 From: dteslenko at gmail.com (Dmitry Teslenko) Date: Mon, 14 Apr 2008 13:33:32 +0400 Subject: pygtk + threading.Timer Message-ID: <91325fec0804140233y3bbb5708i1afe66467693954e@mail.gmail.com> Hello! I have simple chat application with pygtk UI. I want some event (for example update user list) to have place every n seconds. What's the best way to archive it? I tried threading.Timer but result is following: all events wait till exit of gtk main loop and only then they occur. Thanks in advance From mail at timgolden.me.uk Tue Apr 22 09:32:17 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 22 Apr 2008 14:32:17 +0100 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: <200804221847.43924.v.harishankar@gmail.com> References: <200804221847.43924.v.harishankar@gmail.com> Message-ID: <480DE8E1.7020601@timgolden.me.uk> Harishankar wrote: > On Tuesday 22 Apr 2008 18:00:02 Nick Craig-Wood wrote: >> There is a recipe in the cookbook >> >> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554 >> >> Which I've used and it works. > Thanks. I found that recipe too. I was hoping I could cook up something > similar without having to use the module win32api... Well if you want to, you can reproduce the same effect by using ctypes which *is* in the standard library. But why reinvent the wheel? > By the way, the win32api seems to be a nonstandard module (i.e. not present in > the main distribution). Correct. It's part of the pywin32 extensions, one of many useful packages available to the discerning Python programmer who doesn't feel in some way bound to whatever comes bundled with the standard library. TJG From mccredie at gmail.com Mon Apr 28 12:49:26 2008 From: mccredie at gmail.com (Matimus) Date: Mon, 28 Apr 2008 09:49:26 -0700 (PDT) Subject: Given a string - execute a function by the same name References: Message-ID: <78196696-e5fd-4e35-a666-966c945b5a05@l64g2000hse.googlegroups.com> On Apr 28, 9:33 am, pyt... at bdurham.com wrote: > I'm parsing a simple file and given a line's keyword, would like to call > the equivalently named function. > > There are 3 ways I can think to do this (other than a long if/elif > construct): > > 1. eval() > > 2. Convert my functions to methods and use getattr( myClass, "method" ) > > 3. Place all my functions in dictionary and lookup the function to be > called > > Any suggestions on the "best" way to do this? > > Thank you, > Malcolm You can always import yourself and use getattr on that module. in file "mytest.py": def foo(): print "foo called" def call_by_name(name, *args, **kwargs): import mytest f = getattr(mytest, "foo") f(*args, **kwargs) if __name__ == "__main__": call_by_name('foo') Alternatively you can import __main__ if you are always going to be running directly from that file. Matt From soren.skou.nielsen at gmail.com Thu Apr 10 06:30:53 2008 From: soren.skou.nielsen at gmail.com (Soren) Date: Thu, 10 Apr 2008 03:30:53 -0700 (PDT) Subject: Sorting Directories from files in a os.listdir?? References: <9354f263-b833-4845-a226-1ad3a47b1e6a@p25g2000pri.googlegroups.com> Message-ID: On Apr 10, 12:14 pm, "Gabriel Genellina" wrote: > En Thu, 10 Apr 2008 06:55:13 -0300, Soren > escribi?: > > > I'd like to read the filenames in a directory, but not the > > subdirectories, os.listdir() gives me everything... how do I separate > > the directory names from the filenames? Is there another way of doing > > this? > > Check each returned name using os.path.isfile > (untested): > > def files_only(path): > return [filename for filename in os.listdir(path) > if os.path.isfile(os.path.join(path, filename))] > > -- > Gabriel Genellina Thanks everyone! That worked! :) From noname9968 at gmail.com Thu Apr 3 05:50:52 2008 From: noname9968 at gmail.com (Alex9968) Date: Thu, 03 Apr 2008 13:50:52 +0400 Subject: Get all strings matching given RegExp Message-ID: <47F4A87C.7020701@gmail.com> Can I get sequence of all strings that can match a given regular expression? For example, for expression '(a|b)|(x|y)' it would be ['ax', 'ay', 'bx', 'by'] It would be useful for example to pass these strings to a search engine not supporting RegExp (therefore adding such support to it). A program can also let user specify sequence of strings using RegExp (filenames to process, etc.). If there are other types of expressions for these purposes, please let me know. I know that for some expressions there would be infinite amount of matching strings, but these aren't the cases I'm considering. It'd still be possible if string length is limited (there might be large but finite number of matching strings). Thanks From rowen at cesmail.net Mon Apr 28 15:28:38 2008 From: rowen at cesmail.net (Russell E. Owen) Date: Mon, 28 Apr 2008 12:28:38 -0700 Subject: Simple unicode-safe version of str(exception)? Message-ID: I have code like this: except Exception, e: self.setState(self.Failed, str(e)) which fails if the exception contains a unicode argument. I did, of course, try unicode(e) but that fails. The following works, but seems rather messy: except Exception, e: errStr = ",".join([unicode(s) for s in f.args]) self.setState(self.Failed, errStr) Is there a simpler solution that works in Python 2.3-2.5? -- Russell From breily at gmail.com Wed Apr 23 21:14:18 2008 From: breily at gmail.com (Brian) Date: Wed, 23 Apr 2008 21:14:18 -0400 Subject: Partition list with predicate In-Reply-To: <925822270804231808n44c44ddbx213e936319ad1ed3@mail.gmail.com> References: <925822270804231808n44c44ddbx213e936319ad1ed3@mail.gmail.com> Message-ID: On Wed, Apr 23, 2008 at 9:08 PM, Jared Grubb wrote: > I guess I forgot one requirement: the removed elements need to be > remembered. > > Basically, I have a list of objects in a buffer, one class operates on > some of the objects, but other classes use others. So, a class must extract > the ones it can handle, and leave the rest in the buffer for the other > classes to handle. > > I haven't found a function that will both remove objects from a list, but > save the ones that do get removed. > > Jared > > On 23 Apr 2008, at 10:15, Tim Golden wrote: > > Jared Grubb wrote: > > I want a function that removes values from a list if a predicate evaluates > to True. The best I could come up with is: > > > Have a look at the itertools module, and the ifilter function > in particular. > > TJG > -- > http://mail.python.org/mailman/listinfo/python-list > > > > -- > http://mail.python.org/mailman/listinfo/python-list > I would do it like this: # This takes out the values extracted = [ obj for obj in lst if pred(obj) ] # This filters out any item that was extracted lst = [ obj for obj in list if obj not in extracted ] Brian -------------- next part -------------- An HTML attachment was scrubbed... URL: From gagsl-py2 at yahoo.com.ar Mon Apr 7 21:17:31 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 07 Apr 2008 22:17:31 -0300 Subject: popen pipe limit References: Message-ID: En Mon, 07 Apr 2008 20:52:54 -0300, skunkwerk escribi?: > I'm getting errors when reading from/writing to pipes that are fairly > large in size. To bypass this, I wanted to redirect output to a file > in the subprocess.Popen function, but couldn't get it to work (even > after setting Shell=True). I tried adding ">","temp.sql" after the > password field but mysqldump gave me an error. > > the code: > p1 = subprocess.Popen(["mysqldump","--all-databases","--user=user","-- > password=password"], shell=True) > p2 = subprocess.Popen(["gzip","-9"], stdin=p1.stdout) > output = p2.communicate()[0] > file=open('test.sql.gz','w') > file.write(str(output)) > file.close() You need a pipe to chain subprocesses: import subprocess p1 = subprocess.Popen(["mysqldump","--all-databases","--user=user","--password=password"], stdout=subprocess.PIPE) ofile = open("test.sql.gz", "wb") p2 = subprocess.Popen(["gzip","-9"], stdin=p1.stdout, stdout=ofile) p1.wait() p2.wait() ofile.close() If you don't want the final file on disk: p1 = subprocess.Popen(["mysqldump","--all-databases","--user=user","--password=password"], stdout=subprocess.PIPE) p2 = subprocess.Popen(["gzip","-9"], stdin=p1.stdout, stdout=subprocess.PIPE) while True: chunk = p2.stdout.read(4192) if not chunk: break # do something with read chunk p1.wait() p2.wait() -- Gabriel Genellina From bskaplan14 at yahoo.com Thu Apr 17 09:52:44 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Thu, 17 Apr 2008 06:52:44 -0700 (PDT) Subject: Importing My Own Script Message-ID: <271813.40455.qm@web39202.mail.mud.yahoo.com> If x and y are in the same directory, just do "import x". If not, add the directory containing x to sys.path. Then, "import x" should work. ----- Original Message ---- From: Victor Subervi To: python-list at python.org Sent: Thursday, April 17, 2008 9:45:10 AM Subject: Importing My Own Script Hi: How do I import my own script from a second script? That is, I have script x and I want to import script y. How? TIA, Victor ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From pscott at uwc.ac.za Tue Apr 1 00:30:07 2008 From: pscott at uwc.ac.za (Paul Scott) Date: Tue, 01 Apr 2008 06:30:07 +0200 Subject: Command line input In-Reply-To: <00c99698-e5cb-49dd-88fd-8130623a4e45@e6g2000prf.googlegroups.com> References: <00c99698-e5cb-49dd-88fd-8130623a4e45@e6g2000prf.googlegroups.com> Message-ID: <1207024207.7016.2.camel@paul-laptop> On Mon, 2008-03-31 at 12:39 -0700, hexusnexus at gmail.com wrote: > How do I receive input from the command line in Python? I have used: sys.argv[ 1 ] I have been doing Python for around 2 days now, so please do double check that! --Paul -------------- next part -------------- All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm From torppa at staff.megabaud.fi Sun Apr 27 12:26:11 2008 From: torppa at staff.megabaud.fi (Jarkko Torppa) Date: Sun, 27 Apr 2008 16:26:11 GMT Subject: design choice: multi-threaded / asynchronous wxpython client? References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: On 2008-04-27, David wrote: >> >> 1) The data for the race about to start updates every (say) 15 >> seconds, and the data for earlier and later races updates only every >> (say) 5 minutes. There is no point for me to be hammering the server >> with requests every 15 seconds for data for races after the upcoming > > Try using an HTTP HEAD instruction instead to check if the data has > changed since last time. Get If-Modified-Since is still better (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html 14.25) -- Jarkko Torppa From hdante at gmail.com Fri Apr 11 09:49:23 2008 From: hdante at gmail.com (hdante) Date: Fri, 11 Apr 2008 06:49:23 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <31872ffc-5bc4-44c8-961d-ee4f0dc356c5@k1g2000prb.googlegroups.com> Message-ID: <700b1a5f-0af0-466e-abda-4d8dc784dbaa@e67g2000hsa.googlegroups.com> On Apr 11, 9:45 am, bdsatish wrote: > On Apr 11, 5:33 pm, bdsatish wrote: > > > > > HI Gerard, > > > I think you've taken it to the best possible implementation. Thanks ! > > On Apr 11, 5:14 pm, Gerard Flanagan wrote: > > > > In fact you can avoid the call to the builtin round: > > > > ------------------------------------------------ > > > > assert myround(3.2) == 3 > > > assert myround(3.6) == 4 > > > assert myround(3.5) == 4 > > > assert myround(2.5) == 2 > > > assert myround(-0.5) == 0.0 > > > assert myround(-1.5) == -2.0 > > > assert myround(-1.3) == -1.0 > > > assert myround(-1.8) == -2 > > > assert myround(-2.5) == -2.0 > > > ------------------------------------------------ > > OK, I was too early to praise Gerard. The following version: > > def myround(x): > n = int(x) > if abs(x - n) >= 0.5 and n % 2: > return n + 1 - 2 * int(n<0) > else: > return n > > of Gerard doesn't work for 0.6 (or 0.7, etc.) It gives the answer 0 > but I would expect 1.0 ( because 0.6 doesn't end in 0.5 at all... so > usual rules of round( ) apply) Interestingly, you could solve this by using python 3. :-) round(x[, n]) Return the floating point value x rounded to n digits after the decimal point. If n is omitted, it defaults to zero. Values are rounded to the closest multiple of 10 to the power minus n; if two multiples are equally close, rounding is done toward the even choice (so, for example, both round(0.5) and round(-0.5) are 0, and round(1.5) is 2). Delegates to x.__round__(n). My turn: ;-) def yaround(x): i = int(x) f = x - i if f != 0.5 and f != -0.5: return round(x) return 2.0*round(x/2.0) a = (-10.0, -9.0, -8.0, -4.6, -4.5, -4.4, -4.0, -3.6, -3.5, -3.4, -0.6, -0.5, -0.4, 0.0, 0.4, 0.5, 0.6, 0.9, 1.0, 1.4, 1.5, 1.6, 2.0, 2.4, 2.5, 2.6, 10.0, 100.0) b = (-10.0, -9.0, -8.0, -5.0, -4.0, -4.0, -4.0, -4.0, -4.0, -3.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 3.0, 10.0, 100.0) for i in range(len(a)): assert yaround(a[i]) == b[i] From duncan.booth at invalid.invalid Tue Apr 8 15:10:57 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 8 Apr 2008 19:10:57 GMT Subject: Google App Engine References: Message-ID: William Dode wrote: > On 08-04-2008, Duncan Booth wrote: >> Google have announced a new service called 'Google App Engine' which >> may be of interest to some of the people here (although if you want >> to sign up you'll have to join the queue behind me): >> >> From the introduction: >> >>> What Is Google App Engine? > ... > > It's also interesting to see that we can find django, webob and pyyaml > in their sdk (license apache 2) > Yes, it says you can use almost any Python web framework but django is the preferred one. Some of the comments at http://www.techcrunch.com/2008/04/07/google-jumps-head-first-into-web-services-with-google-app-engine/ sound kind of upset, e.g.: "Python will be a deal breaker for many " or "Python only. What a weird decision. Not business and community-friendly at all." From skanemupp at yahoo.se Fri Apr 4 21:06:11 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 4 Apr 2008 18:06:11 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! Message-ID: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> 1st question: when i run this program 1 will be printed into the interpreter when i run it BUT without me clicking the actual button. when i then click the button "1", nothing happens. obv i dont want any output when i dont push the button but i want it when i do. what am i doing wrong here? 2nd question: i want all the buttons to have the same size. i thought i should use row/columnspan but i dont get that to work. how should i do? [code] #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self,master=None): """Initialize yourself""" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): self.enText = Entry(self) self.enText.grid(row=0, column=0, columnspan=8, padx=5, pady=5) self.enText = Entry(self) self.enText.grid(row=1, column=0, columnspan=8, padx=5, pady=5) self.btnDisplay = Button(self, text="1", command=self.Display(1)) self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="2", default=ACTIVE) self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="3", default=ACTIVE) self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="+", default=ACTIVE) self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) self.btnDisplay = Button(self, text="4", default=ACTIVE) self.btnDisplay.grid(row=4, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="5", default=ACTIVE) self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="6", default=ACTIVE) self.btnDisplay.grid(row=4, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="-", default=ACTIVE) self.btnDisplay.grid(row=4, column=3, padx=5, pady=5) self.btnDisplay = Button(self, text="7", default=ACTIVE) self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="8", default=ACTIVE) self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="9", default=ACTIVE) self.btnDisplay.grid(row=5, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="*", default=ACTIVE) self.btnDisplay.grid(row=5, column=3, padx=5, pady=5) self.btnDisplay = Button(self, text="0", default=ACTIVE) self.btnDisplay.grid(row=6, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="C", default=ACTIVE) self.btnDisplay.grid(row=6, column=1, padx=5, pady=5) self.btnDisplay = Button(self, text="r", default=ACTIVE) self.btnDisplay.grid(row=6, column=2, padx=5, pady=5) self.btnDisplay = Button(self, text="/", default=ACTIVE) self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) def Display(self, xbtn): if xbtn==1: print 1 if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() [/code] From dstromberglists at gmail.com Tue Apr 15 15:18:26 2008 From: dstromberglists at gmail.com (Dan Stromberg) Date: Tue, 15 Apr 2008 19:18:26 GMT Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> <47FFDA87.3070703@gmail.com> Message-ID: <6c7Nj.1738$pS4.1299@newssvr13.news.prodigy.net> On Sat, 12 Apr 2008 03:43:28 +0000, David Cook wrote: > On 2008-04-11, Gabriel Ibanez wrote: > >> Why is nobody talking about pyGTK ? There are no limits with licenses >> (I think) > > The OS X port is still pretty preliminary. > > Dave Cook I often use pygtk for my *ix projects, because it has a nice license and it comes with most Linux distributions now. It's also an easy install on windows using cygwin. But I've never looked into it on Mac. From caibiner789 at yahoo.com.cn Sat Apr 19 13:12:26 2008 From: caibiner789 at yahoo.com.cn (bm123456) Date: Sat, 19 Apr 2008 10:12:26 -0700 (PDT) Subject: wholesale cheap air jordans sneakers dunks,Shox,max,adidas,puma, Message-ID: <4778adac-7592-4171-922e-5c64d98cc22d@q1g2000prf.googlegroups.com> Dear cheapers? wholesaleshoescn Global Trade Co.,LTD,is a leading brand sports shoes wholesaler in China. It has a wide range of nike,nike max series,nike Shox,jordans,air force one,Dunk, Bape sta, adidas,Gucci,Timberland boots etc to offer. We also supply brand bags and fashion clothes, Jeans. All the shoes are packed with original boxes with retro cards, and the tags. We try our best to provide you with good quality and competitive price. The number of your order starts from one. Hope to hear from your reply. We have confidence that you will be 100% satisfied with products. We are looking forward to doing business with you. If you are interested in our shoes, please feel free to contact us. pls link google search http://www.wholesaleshoescn.com Dear Sir or Madam: WELCOME TO wholesaleshoescn Global Trade Co.,LTD. we are wholesale :jordans sneakers incluing air jordans sneaker, michael jordans sneaker,we also wholesale jordans sneakers, cheap jordans sneakers, retro jordans sneakers,baby jordans sneakers for cheap and cheapize and get your latest exclusive jordans sneakers,The third is air force 1s incluing spongebob air force 1s,womens air force 1s, air force 1s lyrics,high top air force 1s,easter egg air force 1s, rasheed wallace air force 1s, scarface air force 1s,mr catoon air force 1s,mid air force 1s, airbrush air force 1s,painted air force 1s, neew green air force 1s,all white air force 1s,kid air force 1s,2007 air force 1s,yellow,pink,white stash air force 1s. nike basketball sneakers,womens nike sneakers,rare nike sneakers, rare nike sneakers,nike retro snakers,exlusive nike sneakers, you can get wholesale nike sneaker's price with discount for cheap nike shoes and cheap nike sneakers. pls link google search http://www.wholesaleshoescn.com China Factory Wholesale Cheap:Air Jordans Sneakers,Air Force 1s Shoes,Dunks,Shox,Max,Adidas,Puma,Brand Hoodies,Timberland Shoes,Jeans,Bags,Including Custom in http://WWW.WHOLESALESHOESCN.COM Wholesale Jordans Shoes,Cheap Jordan Sneakers; We Wholesale Jordan Shoes at Cheap Price,wholesale women's,wholesale men's,wholesale shoes,wholesale Nike Shoes Air Jordans,wholesale nike Jordans,Kids Jordan Sneakers,Authentic Jordan Sneakers,Baby Jordans Sneakers,wholesale nike shoes,wholesale nike,wholesale nikes,Michael Jordan Sneakers,Air Jordan Sneakers,cheap wholesale jordans,china custom jordans,jordans made in china,Boys Jordan Sneakers,New Jordans Sneakers,wholesale Air Jordans,wholesale Air Jordans 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ,cheap Jordans,cheap nike Jordans,Air Jordans 23,Air Jordans XX3,Discount air Jordans,cheap nike air Jordans,wholesalers cheap Jordans,Warehouse Jordanss,cheap nikes Jordans,cheap air Jordans,cheap nike's air Jordans. pls link google search http://www.wholesaleshoescn.com/product.asp?bigclassid=5 Dear cheapers? wholesaleshoescn Global Trade Co.,LTD,is a leading brand sports shoes wholesaler in China. It has a wide range of nike,nike max series,nike Shox,jordans,air force one,Dunk, Bape sta, adidas,Gucci,Timberland boots etc to offer. We also supply brand bags and fashion clothes, Jeans. All the shoes are packed with original boxes with retro cards, and the tags. We try our best to provide you with good quality and competitive price. The number of your order starts from one. Hope to hear from your reply. We have confidence that you will be 100% satisfied with products. We are looking forward to doing business with you. If you are interested in our shoes, please feel free to contact us. pls link google search http://www.wholesaleshoescn.com Dear Sir or Madam: WELCOME TO wholesaleshoescn Global Trade Co.,LTD. we are wholesale :jordans sneakers incluing air jordans sneaker, michael jordans sneaker,we also wholesale jordans sneakers, cheap jordans sneakers, retro jordans sneakers,baby jordans sneakers for cheap and cheapize and get your latest exclusive jordans sneakers,The third is air force 1s incluing spongebob air force 1s,womens air force 1s, air force 1s lyrics,high top air force 1s,easter egg air force 1s, rasheed wallace air force 1s, scarface air force 1s,mr catoon air force 1s,mid air force 1s, airbrush air force 1s,painted air force 1s, neew green air force 1s,all white air force 1s,kid air force 1s,2007 air force 1s,yellow,pink,white stash air force 1s. nike basketball sneakers,womens nike sneakers,rare nike sneakers, rare nike sneakers,nike retro snakers,exlusive nike sneakers, you can get wholesale nike sneaker's price with discount for cheap nike shoes and cheap nike sneakers. pls link google search http://www.wholesaleshoescn.com China Factory Wholesale Cheap:Air Jordans Sneakers,Air Force 1s Shoes,Dunks,Shox,Max,Adidas,Puma,Brand Hoodies,Timberland Shoes,Jeans,Bags,Including Custom in http://WWW.WHOLESALESHOESCN.COM Wholesale Jordans Shoes,Cheap Jordan Sneakers; We Wholesale Jordan Shoes at Cheap Price,wholesale women's,wholesale men's,wholesale shoes,wholesale Nike Shoes Air Jordans,wholesale nike Jordans,Kids Jordan Sneakers,Authentic Jordan Sneakers,Baby Jordans Sneakers,wholesale nike shoes,wholesale nike,wholesale nikes,Michael Jordan Sneakers,Air Jordan Sneakers,cheap wholesale jordans,china custom jordans,jordans made in china,Boys Jordan Sneakers,New Jordans Sneakers,wholesale Air Jordans,wholesale Air Jordans 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ,cheap Jordans,cheap nike Jordans,Air Jordans 23,Air Jordans XX3,Discount air Jordans,cheap nike air Jordans,wholesalers cheap Jordans,Warehouse Jordanss,cheap nikes Jordans,cheap air Jordans,cheap nike's air Jordans. pls link google search http://www.wholesaleshoescn.com/product.asp?bigclassid=5 Dear cheapers? wholesaleshoescn Global Trade Co.,LTD,is a leading brand sports shoes wholesaler in China. It has a wide range of nike,nike max series,nike Shox,jordans,air force one,Dunk, Bape sta, adidas,Gucci,Timberland boots etc to offer. We also supply brand bags and fashion clothes, Jeans. All the shoes are packed with original boxes with retro cards, and the tags. We try our best to provide you with good quality and competitive price. The number of your order starts from one. Hope to hear from your reply. We have confidence that you will be 100% satisfied with products. We are looking forward to doing business with you. If you are interested in our shoes, please feel free to contact us. pls link google search http://www.wholesaleshoescn.com Dear Sir or Madam: WELCOME TO wholesaleshoescn Global Trade Co.,LTD. we are wholesale :jordans sneakers incluing air jordans sneaker, michael jordans sneaker,we also wholesale jordans sneakers, cheap jordans sneakers, retro jordans sneakers,baby jordans sneakers for cheap and cheapize and get your latest exclusive jordans sneakers,The third is air force 1s incluing spongebob air force 1s,womens air force 1s, air force 1s lyrics,high top air force 1s,easter egg air force 1s, rasheed wallace air force 1s, scarface air force 1s,mr catoon air force 1s,mid air force 1s, airbrush air force 1s,painted air force 1s, neew green air force 1s,all white air force 1s,kid air force 1s,2007 air force 1s,yellow,pink,white stash air force 1s. nike basketball sneakers,womens nike sneakers,rare nike sneakers, rare nike sneakers,nike retro snakers,exlusive nike sneakers, you can get wholesale nike sneaker's price with discount for cheap nike shoes and cheap nike sneakers. pls link google search http://www.wholesaleshoescn.com China Factory Wholesale Cheap:Air Jordans Sneakers,Air Force 1s Shoes,Dunks,Shox,Max,Adidas,Puma,Brand Hoodies,Timberland Shoes,Jeans,Bags,Including Custom in http://WWW.WHOLESALESHOESCN.COM Wholesale Jordans Shoes,Cheap Jordan Sneakers; We Wholesale Jordan Shoes at Cheap Price,wholesale women's,wholesale men's,wholesale shoes,wholesale Nike Shoes Air Jordans,wholesale nike Jordans,Kids Jordan Sneakers,Authentic Jordan Sneakers,Baby Jordans Sneakers,wholesale nike shoes,wholesale nike,wholesale nikes,Michael Jordan Sneakers,Air Jordan Sneakers,cheap wholesale jordans,china custom jordans,jordans made in china,Boys Jordan Sneakers,New Jordans Sneakers,wholesale Air Jordans,wholesale Air Jordans 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ,cheap Jordans,cheap nike Jordans,Air Jordans 23,Air Jordans XX3,Discount air Jordans,cheap nike air Jordans,wholesalers cheap Jordans,Warehouse Jordanss,cheap nikes Jordans,cheap air Jordans,cheap nike's air Jordans. pls link google search http://www.wholesaleshoescn.com/product.asp?bigclassid=5 From pylists at arcor.de Mon Apr 14 04:37:16 2008 From: pylists at arcor.de (Penny Y.) Date: Mon, 14 Apr 2008 16:37:16 +0800 Subject: =?gb2312?B?tPC4tDogtPC4tDogaG93IHRvIHJlbW92ZSBcbiBpbiB0aGUgbGlzdA==?= In-Reply-To: Message-ID: <20080414083724.46958236E44@mail-in-16.arcor-online.net> that's right. got it thanks. -----????----- ???: python-list-bounces+pylists=arcor.de at python.org [mailto:python-list-bounces+pylists=arcor.de at python.org] ?? Eric Brunel ????: 2008?4?14? 16:17 ???: python-list at python.org ??: Re: ??: how to remove \n in the list (please avoid top-posting... corrected) On Mon, 14 Apr 2008 09:08:06 +0200, Penny Y. wrote: > -----????----- > ???: python-list-bounces+pylists=arcor.de at python.org > [mailto:python-list-bounces+pylists=arcor.de at python.org] ?? Gabriel > Genellina > ????: 2008?4?14? 12:59 > ???: python-list at python.org > ??: Re: how to remove \n in the list > > En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam > escribi?: > >> hi, >> l=['5\n', '2\n', '7\n', '3\n', '6\n'] >> >> how to remove \n from the given list > > l is is very poor name... I'll use lines instead: > > lines[:] = [line.rstrip('\n') for line in lines] > --- > > why not just: > > lines = [line.rstrip('\n') for line in lines] > > > what's the difference between lines[:] and lines here? Thanks. Compare: >>> lines = ['5\n', '2\n', '7\n', '3\n', '6\n'] >>> lines2 = lines >>> lines = [line.rstrip('\n') for line in lines] >>> lines ['5', '2', '7', '3', '6'] >>> lines2 ['5\n', '2\n', '7\n', '3\n', '6\n'] with: >>> lines = ['5\n', '2\n', '7\n', '3\n', '6\n'] >>> lines2 = lines >>> lines[:] = [line.rstrip('\n') for line in lines] >>> lines ['5', '2', '7', '3', '6'] >>> lines2 ['5', '2', '7', '3', '6'] Assigning to lines[:] changes the original list. Assigning to lines rebinds the name to the result of the list comprehension, but doesn't affect the original list. HTH -- python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])" -- http://mail.python.org/mailman/listinfo/python-list From Stephen.Cattaneo at u4eatech.com Tue Apr 8 16:36:13 2008 From: Stephen.Cattaneo at u4eatech.com (Stephen Cattaneo) Date: Tue, 8 Apr 2008 13:36:13 -0700 Subject: Running a python code periodically In-Reply-To: References: Message-ID: If your on a *NIX just use cron. Execute 'crontab -e' edit the file as desired and save see man crontab for formatting. Cheers, Steve ________________________________ From: Maryam Saeedi [mailto:ma.saeedi at gmail.com] Sent: Tuesday, April 08, 2008 10:54 AM To: python-list at python.org Subject: Running a python code periodically Hi, I was wondering if you know how can I run a python code once every five minutes for a period of time either using python or some other program like a bash script. Thanks, Maryam -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin.laloux at gmail.com Mon Apr 14 04:06:03 2008 From: martin.laloux at gmail.com (martin.laloux at gmail.com) Date: Mon, 14 Apr 2008 01:06:03 -0700 (PDT) Subject: How to get the version of a file References: Message-ID: <472baa87-2aa3-495c-ab0f-9c7f16bef769@8g2000hsu.googlegroups.com> you need appscript "that allows you to control scriptable Mac OS X applications from Python" http://pypi.python.org/pypi/appscript/0.18.1 From bronger at physik.rwth-aachen.de Sat Apr 12 11:14:22 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Sat, 12 Apr 2008 17:14:22 +0200 Subject: unittest: which directory structure? Message-ID: <87zlrzw1f5.fsf@physik.rwth-aachen.de> Hall?chen! I try to port my doctests to unittest. I've found good turorials about *writing* unit tests but not about organising the files. What's the best way to arrange the test source files? I made a directory called "tests" on the same level as my package, with (roughly) one test module per package module and wanted to call each of them from my Makefile or from some sort of root test module. However, I cannot easily import the to-be-tested module. Currently, I begin every test module with # append the local package path to sys.path import sys, os.path rootpath = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0] sys.path.append(rootpath) in order to be able to import the source modules. I surely have missed something because this is only a workaround solution. Thanks for any hints! Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From victorsubervi at gmail.com Wed Apr 9 10:54:18 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 9 Apr 2008 10:54:18 -0400 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> Message-ID: <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> On Wed, Apr 9, 2008 at 10:24 AM, Steve Holden wrote: > Victor Subervi wrote: > > On Wed, Apr 9, 2008 at 1:14 AM, Gabriel Genellina > > > wrote: > > Now all you have to do is what I told you in the first place, which is > to remove the print statements before and after "print content". That is what I figured after I sent the email. However, I had tried that with a test script and the working script, with bad results. Here is the test script that should have worked flawlessly: #! /usr/bin/python import MySQLdb print "Content-type: image/jpeg\r\n" host = 'host' db = 'bre' user = 'user' passwd = 'pass' connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor = connection.cursor() cursor.execute('select img from photo where id="7";') content = cursor.fetchall() print "Content-Type: image/jpeg\nContent-Length: %d\n" % len(content) print content connection.commit() connection.close() This prints out the URL as an image! No idea why. But it does not produce the desired image. The following is the heart of the script for display. I tried entering the Content-type where indicated, but it produces everything up to the image, then produces the result of code from the exception... cursor.execute('select id from products where category="' + category + '" order by sort_factor desc, price desc;') ids = cursor.fetchall() if len(ids[0]) != 0: for id in ids: for d in id: print '\n' cursor.execute('select * from products where id = ' + str(d) + ';') col_fields = cursor.fetchall() if lang == 'es': print 'ID: ', col_fields[0][0], '
' print 'Nombre: ', col_fields[0][2], '
' print 'T?tulo: ', col_fields[0][6], '
' print 'Descripci?n: ', col_fields[0][9], '
' print 'Precio: ', col_fields[0][11], '
' print 'Rec?maras: ', col_fields[0][12], '
' print 'Ba?os: ', col_fields[0][13], '
' content = col_fields[0][14].tostring() print "Content-Type: image/jpeg\nContent-Length: %d\n" % len(content) print content, '

' ... except: if lang == 'es': print 'Lo siento. Todav?a no tenemos propiedades para ense?arse en la categor?a de ', category, '.\n

' > You are NOT generating HTML, you are generating a JPEG image. I am producing both, and this is causing me confusion. BTW, when we are finally done with this, I will write a nice how-to (since there is not one in python, while php has some nice ones) on how to do this, and give you and Gabrielle all your due credit. I will post it to this list, because that is sure to rank highly in google right away. Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From charleshixsn at earthlink.net Sat Apr 12 15:36:51 2008 From: charleshixsn at earthlink.net (Charles D Hixson) Date: Sat, 12 Apr 2008 12:36:51 -0700 Subject: class level properties Message-ID: <48010F53.1000809@earthlink.net> I'm trying to construct read-only variables at the class level. I've been unsuccessful. Any suggestions? Mixing @classmethod and @property doesn't appear to produce workable code. Ditto for mixing @classmethod and __getattr__. (The property approach compiles, but execution says that you can't execute properties.) I've got a rather large number of variables, so I don't want to define function accessors for each of them, and I *REALLY* don't want to have to access them as functions rather than variables or properties. From jon+usenet at unequivocal.co.uk Wed Apr 16 11:19:20 2008 From: jon+usenet at unequivocal.co.uk (Jon Ribbens) Date: Wed, 16 Apr 2008 10:19:20 -0500 Subject: Finally had to plonk google gorups. References: Message-ID: On 2008-04-16, Grant Edwards wrote: > But that's not a battle you can win, so I broke down and joined all > the other people that just killfile everything posted via google.groups. I did the same about an hour ago. From bj_666 at gmx.net Sat Apr 5 16:11:56 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 5 Apr 2008 20:11:56 GMT Subject: Tkinter: making buttons the same size? References: <12bad1a6-3b4b-446e-9673-8893cd6838f9@s37g2000prg.googlegroups.com> <3753aa85-c844-4e54-8213-142e50fd8a7e@b5g2000pri.googlegroups.com> Message-ID: <65q4ocF2gq610U1@mid.uni-berlin.de> On Sat, 05 Apr 2008 10:04:56 -0700, skanemupp wrote: > how do i do that? Please include enough from the post you are answering to make the context clear for someone who has not received the previous message. BTW I don't think the `width` argument of the `Button()` call is the best solution. Take a look at the options of the `grid()` call and figure out how to tell that the content of the cell should fill it, so that the Buttons in the grid automatically are equally sized in each row and column. Ciao, Marc 'BlackJack' Rintsch From aahz at pythoncraft.com Mon Apr 21 10:28:19 2008 From: aahz at pythoncraft.com (Aahz) Date: 21 Apr 2008 07:28:19 -0700 Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> Message-ID: In article <23bf20ad-9996-4b79-97ef-7930a228c4a3 at t54g2000hsg.googlegroups.com>, Joseph Turian wrote: > >Basically, we're planning on releasing it as open-source, and don't >want to alienate a large percentage of potential users. Datapoint: my company still uses 2.3 and *might* upgrade to 2.4 and later this year. Basically, any company with lots of servers has a good chance to still be stuck with 2.2/2.3 (we only dropped 2.2 last fall). -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ Why is this newsgroup different from all other newsgroups? From cheapair at 163.com Fri Apr 18 05:12:30 2008 From: cheapair at 163.com (cheapair at 163.com) Date: Fri, 18 Apr 2008 02:12:30 -0700 (PDT) Subject: Air Max 90 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn )Air Mir 90 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Message-ID: <43915149-31fb-41b6-99ec-ea837d60043f@m71g2000hse.googlegroups.com> We are the professional and serious wholesaler of brand products,such as shoes, clothing, handbags, sunglasses, hats, belts, and so on.We have many brands such as nike,adidas,puma,Gucci,North face.All goods are with best service,highest quality,competitive price,and safe timely deliverry If you are interested in these goods,don?t hasitate to cantact us please. our website: http://www. top-saler.cn MSN(email): top-saler at hotmail.com Air Max 360 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 90 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn )Air Mir 90 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max LTD paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) air Max LTD paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 2003 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 2003 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 87 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 95 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 95 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 97 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 95 360 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 90 360 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air zoom hateu paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 91 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 87 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 89 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max Tn paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Tn Air Max Tn paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Bape paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) new Bape paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Old bape paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Dunk paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) s Dunk paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) High Dunk paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Dunk paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox NZ paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox R3 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox R4 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox R5 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 360 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 90 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn )Air Mir 90 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max LTD paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) air Max LTD paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 2003 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 2003 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 87 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 95 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 95 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 97 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 95 360 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 90 360 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air zoom hateu paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 91 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 87 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max 89 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Air Max Tn paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Tn Air Max Tn paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Bape paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) new Bape paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Old bape paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Dunk paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) s Dunk paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) High Dunk paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Dunk paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox NZ paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox R3 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox R4 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) Shox R5 paypal wholesaler ( paypal accept ) ( www.gotoorder.cn ) From dullrich at sprynet.com Wed Apr 2 09:17:40 2008 From: dullrich at sprynet.com (David C. Ullrich) Date: Wed, 02 Apr 2008 08:17:40 -0500 Subject: Homework help References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> Message-ID: On Tue, 1 Apr 2008 09:11:12 -0700 (PDT), bobby.connor at gmail.com wrote: >Hey guys >I haev this homework assignment due today >I don't necessarily want the answers, but need help on how to approach >it/the steps i need to solve the problems I can see at least two possible approaches: Approach 1: (i) post the problems on the internet (ii) carefully copy the solutions Approach 2: (i) learn a little bit about the material you were supposed to learn I'll leave the second step in Approach 2 as an exercise... >Thanks > ># (2 Points) Write a python function howMany(item,lst) which accepts >an item and a lst of items and returns the number of times item occurs >in lst. For example, howMany(3,[1,2,3,2,3]) should return 2. > ># (2 Points) Write a python function upTo(n) which accepts a non- >negative number n and returns a list of numbers from 0 to n. For >example, upTo(3) should return the list [0, 1, 2, 3]. > ># (2 Points) Write a python function duplicate(lst) which accepts a >lst of items and returns a list with the items duplicated. For >example, duplicate([1,2,2,3]) should return the list [1, 1, 2, 2, 2, >2, 3, 3]. > ># (2 Points) Write a python function dotProduct(a,b) which accepts two >lists of integers a and b that are of equal length and which returns >the dot product of a and b. I.e., the sum a0 * b0 + ... + an-1 * bn-1 >where n is the length of the lists. For example: > >dotProduct([1,2,3],[4,5,6]) is 1*4 + 2*5 + 3*6 = 4 + 10 + 18 = 32 > ># (2 Points) A pair (exp0, exp1) is a combination of expressions that >are attached together by their joint membership in the pair. For >example: > >>>> (1+2, 'This') >(3, 'This') > >A component of a pair can be obtained using an index in brackets as >with lists (and strings!). For example: > >>>> (33,44)[0] >33 > >Write a function zip(lst1, lst2) such that zip accepts two equal >length lists and returns a list of pairs. For example, zip(['a', 'b', >'c'], [10, 20, 30]) should evaluate to the list [('a', 10), ('b', 20), >('c', 30)]. > ># (2 Points) Write a function unzip(lst) such that unzip accepts a >list of pairs and returns two lists such that lst == zip(unzip(lst)). >For example, unzip([('a', 10), ('b', 20), ('c', 30)] should evaluate >to the pair (['a', 'b', 'c'], [10, 20, 30]). > ># (2 Points) Write a python function isAscending(lst) which accepts a >non-empty list of integers and returns True if the numbers in the list >are in ascending order. Otherwise it should return False. For example, >isAscending([1]) should evaluate to True while isAscending([1,2,2]) >should return False. David C. Ullrich From jkugler at bigfoot.com Fri Apr 25 17:01:45 2008 From: jkugler at bigfoot.com (Joshua Kugler) Date: Fri, 25 Apr 2008 13:01:45 -0800 Subject: Setting an attribute without calling __setattr__() Message-ID: OK, I'm sure the answer is staring me right in the face--whether that answer be "you can't do that" or "here's the really easy way--but I am stuck. I'm writing an object to proxy both lists (subscriptable iterables, really) and dicts. My init lookslike this: def __init__(self, obj=None): if type(obj).__name__ in 'list|tuple|set|frozenset': self.me = [] for v in obj: self.me.append(ObjectProxy(v)) elif type(obj) == dict: self.me = {} for k,v in obj.items(): self.me[k] = ObjectProxy(v) and I have a __setattr__ defined like so: def __setattr__(self, name, value): self.me[name] = ObjectProxy(value) You can probably see the problem. While doing an init, self.me = {} or self.me = [] calls __setattr__, which then ends up in an infinite loop, and even it it succeeded self.me['me'] = {} is not what I wanted in the first place. Is there a way to define self.me without it firing __setattr__? If not, it's not a huge deal, as having this class read-only for now won't be a problem, but I was just trying to make it read/write. Thanks! j From zillow10 at googlemail.com Wed Apr 2 14:42:54 2008 From: zillow10 at googlemail.com (zillow10 at googlemail.com) Date: Wed, 2 Apr 2008 11:42:54 -0700 (PDT) Subject: generator functions: why won't this work? References: <0aaeddf2-ee63-426e-afb3-0e1acb15adef@r9g2000prd.googlegroups.com> Message-ID: <8f38c3e6-1b1c-468e-8ea2-47c21322621f@i36g2000prf.googlegroups.com> On Apr 2, 3:57 pm, Mel wrote: > zillo... at googlemail.com wrote: > > I'd just like to test my > > > understanding of this. Suppose I create the following generator > > object: > > > g = getNextScalar(1, 2, (3, 4), 5) > > > when the iterator reaches the tuple argument (3, 4) then, according to > > Steve and George, the * in *arg causes this tuple to be expanded into > > positional arguments, and it makes sense to do it this way. But what > > happens when getNextScalar(arg) is used instead? > > Try it: > > Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> def a (arg): > ... print arg > ... > >>> def astar (*arg): > ... print arg > ... > >>> a(3,4) > Traceback (most recent call last): > File "", line 1, in > TypeError: a() takes exactly 1 argument (2 given) > >>> astar(3,4) > (3, 4) > >>> a((3,4)) > (3, 4) > >>> astar((3,4)) > ((3, 4),) > >>> > > Mel. Well, I understand that (unless I missed the point you're trying to make). But with respect to the example I quoted: def getNextScalar(*args): for arg in args: if(isinstance(arg, tuple)): for f in getNextScalar(arg): # should use *arg yield f else: yield arg where the function is declared as def getNextScalar(*arg), but is called using getNextScalar(arg), with arg being a tuple: here the generator is being passed a single argument, so there's no TypeError as in your example. However, it fails - as I understand it - because the function keeps passing the same tuple (being unable to access the elements inside it) and goes into an infinite loop: >>> # works for this example, but not very useful: >>> g = getNextScalar(1, 2, 3, 4) >>> for i in g: print i 1 2 3 4 # third argument is a tuple: >>> g = getNextScalar(1, 2, (3, 4)) >>> for i in g: print i 1 2 Traceback (most recent call last): File "", line 1, in for i in g: File "", line 4, in getNextScalar for f in getNextScalar(arg): File "", line 4, in getNextScalar for f in getNextScalar(arg): File "", line 4, in getNextScalar for f in getNextScalar(arg): ... AK From fabianosidler at my-mail.ch Sat Apr 26 20:03:13 2008 From: fabianosidler at my-mail.ch (Fabiano Sidler) Date: Sun, 27 Apr 2008 02:03:13 +0200 Subject: How do I say "Is this a function"? In-Reply-To: References: Message-ID: <4813C2C1.3000106@my-mail.ch> John Henry schrieb: > exec fct You don't want this. You want to store the function in a list instead: l = [ f1, f3, others ] for i in [0,1]: l[i]() Greetings, Fabiano From sturlamolden at yahoo.no Tue Apr 15 16:49:15 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Tue, 15 Apr 2008 13:49:15 -0700 (PDT) Subject: Preferred method for "Assignment by value" References: Message-ID: <84ac1334-b450-490e-a83b-0876274f46b3@26g2000hsk.googlegroups.com> On Apr 15, 7:23 pm, hall.j... at gmail.com wrote: > test = [[1],[2]] > x = test[0] Python names are pointer to values. Python behaves like Lisp - not like Visual Basic or C#. Here you make x point to the object which is currently pointed to by the first element in the list test. If you now reassign test[0] = [2], x is still pointing to [1]. > x[0] = 5 > test>>> [[5],[2]] > > x = 1 Here you reassign x to point to an int object vith value 1. In other words, x is no longer pointing to the same object as the first element in the list test. That is why get this: > test > > >>>[[5],[2]] > x > >>> 1 > test = [[1,2],[3,4]] > I need to do some data manipulation with the first list in the above > list without changing > obviously x = test[0] will not work as any changes i make will alter > the original... You make a slice, e.g. x = [from:until:stride] Now x is pointing to a new list object, containing a subset of the elements in list. If you reassign elements in x, test will still be the same. The point to remember, is that a list does not contain values, but pointers to values. This can be very different from arrays in C, VB, Java or C#: a = [1,2,3,4,5] in Python is different from int a[] = {1,2,3,4,5}; The Python statement makes a list of five pointers, each pointing to an immutable int object on the heap. The C statement allocates a buffer of 5 ints on the stack. If you can read C, the Python statement a = [1,2,3,4,5] is thus similar to something like int **a, i, amortize_padding=4; a = malloc(5 * sizeof(int*) + amortize_padding*sizeof(int*)); for (i=0; i<5; i++) { a[i] = malloc(sizeof(int)); *a[i] = i; } From castironpi at gmail.com Sat Apr 19 16:45:44 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sat, 19 Apr 2008 13:45:44 -0700 (PDT) Subject: Database vs Data Structure? References: <61bf5f46-e917-4a98-b87f-8e5087cb07f7@a23g2000hsc.googlegroups.com> Message-ID: <49da20a3-1625-4fbb-90fe-8fb917ff5e5d@f36g2000hsa.googlegroups.com> On Apr 19, 1:27?pm, Scott David Daniels wrote: > castiro... at gmail.com wrote: > > On Apr 18, 12:23 am, I V wrote: > >> On Thu, 17 Apr 2008 19:30:33 -0700, erikcw wrote: > >>> use some sort of data-structure (maybe > >>> nested dictionaries or a custom class) and store the pickled > >>> data-structure in a single row in the database (then unpickle the data > >>> and query in memory). > >> Why would you want to do this? I don't see what you would hope to gain by > >> doing this, over just using a database. > > > Are databases truly another language from Python, fundamentally? > > Yes. ?A fair amount of study went into them. ?Databases are about > information that survives the over an extended period of time (months > or years, not hours). > > Classic qualities for a database that don't normally apply to Python > (all properties of a "transaction" -- bundled set of changes): > ? ? ?* Atomicity: > ? ? ? ? A transaction either is fully applied or not applied at all. > ? ? ?* Consistency: > ? ? ? ? Transactions applied to a database with invariants preserve > ? ? ? ? those invariants (things like balance sheets totals). > ? ? ?* Isolation: > ? ? ? ? Each transactions happens as if it were happening at its own > ? ? ? ? moment in time -- tou don't worry about other transactions > ? ? ? ? interleaved with your transaction. > ? ? ?* Durability: > ? ? ? ? Once a transaction actually makes it into the database, it stays > ? ? ? ? there and doesn't magically fail a long time later. > > -Scott David Daniels > Scott.Dani... at Acm.Org Scott, Classical qualities for Python that don't normally apply to a database are: * Encapsulation * Modularity (Besides for social factors,) I make case that database language is always better to start learning than program language. They have no properties of databases. Hold that databases are slightly less sophisticated than language, and you hold rates at which data comes from the universe. Note, information isn't terribly well quantified, but is empirical. Note, matter comes from the universe too, but information goes to heads and we care. I hold it's proper to distinguish, though: you're doing the usual things to data from the real world, but it seems like things I want to do to computer screen are hard to do to a computer screen. I'm sensitive to money (want>0); why doesn't it want to do computers? I'd rather just animate plastics. Hook some up to it. Build roads and surfboards. (No snowboards; it's water; or it's way below it.) Plus get a bunch from the A.C. lines. Data always come from the universe, i.e. from matter. Just another way to make money with it. Everyone can make money, what's the problem with SQL? From meisnernel73884 at gmail.com Wed Apr 30 06:38:27 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:38:27 -0700 (PDT) Subject: rar password crack Message-ID: rar password crack http://crack.cracksofts.com From hamish at valvesoftware.com Wed Apr 16 14:35:44 2008 From: hamish at valvesoftware.com (Hamish McKenzie) Date: Wed, 16 Apr 2008 11:35:44 -0700 Subject: str class inheritance prob? Message-ID: <587C2C9324493D4B96BD6BBCDEAC321AA956C8@exchange3.valvesoftware.com> so I'm trying to create a class that inherits from str, but I want to run some code on the value on object init. this is what I have: class Path(str): def __init__( self, path ): clean = str(path).replace('\\','/') while clean.find('//') != -1: clean = clean.replace('//','/') print 'cleaned on init:\t',clean self = clean so clearly the clean variable is what I want value of the string to be, but that's decidedly not the case. so running this: a=Path('path///with\\nasty/////crap_in_it/') print a gives me this: cleaned on init: path/with/nasty/crap_in_it/ path///with\nasty/////crap_in_it/ what gives? what am I doing wrong, and can I do what I'm trying to here? thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From Magnus.Moraberg at gmail.com Wed Apr 2 09:15:33 2008 From: Magnus.Moraberg at gmail.com (Magnus.Moraberg at gmail.com) Date: Wed, 2 Apr 2008 06:15:33 -0700 (PDT) Subject: Nested try...except References: Message-ID: <0a34849f-bcda-419b-a10f-772d76172d1f@b5g2000pri.googlegroups.com> On 2 Apr, 15:12, cokofree... at gmail.com wrote: > On Apr 2, 3:06 pm, Magnus.Morab... at gmail.com wrote: > > > > > Hi, > > > I found the following code on the net - > > > http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/%3C20050924104732.5116.qm... at minotaur.apache.org%3E > > > def count(self): > > - db = sqlite.connect(self.filename, > > isolation_level=ISOLATION_LEVEL) > > - try: > > - try: > > - cur = db.cursor() > > - cur.execute("select count(*) from sessions") > > - return cur.fetchone()[0] > > - finally: > > - cur.close() > > - finally: > > - db.close() > > > I don't understand though why the second try is not after the line cur > > = db.cursor(). Can anyone explain for me why? > > > /Barry. > > Better question is why is there a try with no except... > > Better yet, WHY is there two TRY statements when there could quite > happily be only one... > > Towards what you are asking, I GUESS...because the author hoped to > handle the cases where cur failed to get assigned...but then > his .close method of it would likely not work anyway...I mean...does > this even work...YUCK I shouldn't have written "Nested try...except" as the title, instead I mean "Nested try...finally". Sorry about that... Anyway, how would you do this? That is, use a finally to close the network connection and the cursor? Thanks for your help, Barry From mmanns at gmx.net Sat Apr 19 16:07:14 2008 From: mmanns at gmx.net (Martin Manns) Date: Sat, 19 Apr 2008 22:07:14 +0200 Subject: ANN: pyspread 0.0.1 References: Message-ID: On Fri, 18 Apr 2008 04:46:38 +0200 Martin Manns wrote: > pyspread 0.0.1 is now available at: > http://pyspread.sourceforge.net Hi, I updated to version 0.0.2 that fixes the tarballs and zip files. Any information about the package working on different platforms is appreciated. I got it working on Gentoo and on Debian (python 2.4). Best Regards Martin From hopeorpha308 at gmail.com Sun Apr 27 07:44:32 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:44:32 -0700 (PDT) Subject: stalker shadow of chernobyl crack Message-ID: stalker shadow of chernobyl crack http://wga-cracks.crackkey.net From __peter__ at web.de Sun Apr 6 05:26:35 2008 From: __peter__ at web.de (Peter Otten) Date: Sun, 06 Apr 2008 11:26:35 +0200 Subject: Problems trying to hook own exception function to sys.excepthook References: Message-ID: Sami wrote: > Hello, > > I am new to Python. > > I tried to hook my own ExceptionPrintingFunction sys.excepthook but it > does not work. > > This is what I wrote: > ----------------------------------------------------------------------- > import sys > > def MyOwnExceptHook(typ, val, tb): > print "Inside my own hook" > > sys.excepthook = MyOwnExceptHook > > x = 1/0 > ----------------------------------------------------------------------- > This is what I get > ----------------------------------------------------------------------- > Traceback (most recent call last): > File > "E:/Home/Programming/Python/TryProjects/ExceptHandling1/Except5.py", > line 8, in > x = 1/0 > ZeroDivisionError: integer division or modulo by zero > ----------------------------------------------------------------------- > > I never see "Inside my own hook" which tells me that the hook is not > being called. What I really want to test is to stop the exception from > propagating further and leave the program intact. > > What am I doing wrong? Please let me know if there are any other newbie > groups that I should probably try in stead. Are you running your code from within idle? It wraps your script in something like try: # run script except: # show traceback (Have a look at InteractiveInterpreter.runcode() in code.py if you are interested in the actual code) So your except hook never gets to see the exception and therefore won't be invoked. Run your script from the commandline and you will see the behaviour you expected. Peter From marco at sferacarta.com Thu Apr 3 09:43:52 2008 From: marco at sferacarta.com (Marco Mariani) Date: Thu, 03 Apr 2008 15:43:52 +0200 Subject: object-relational mappers In-Reply-To: References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> Message-ID: Tim Golden wrote: > I've recently used Elixir and found it very useful for a small-scale > database with no more than a dozen tables, well-structured and > easily understood. I'd certainly use it again for anything like that > to save me writing what would amount to boilerplate SQL. But I'd > hate to imagine it in the context of my day job: a messy, organic > and sprawling SQL Server database with over 1,000 tables, let alone > views, procedures and so on. That's the scenario where the rest of SQLAlchemy (beyond Elixir, that is, and with reflection turned to 11) can do mucho bueno. From medin0065 at gmail.com Sun Apr 20 10:44:43 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:44:43 -0700 (PDT) Subject: police shoulder patch trade Message-ID: police shoulder patch trade http://cracks.00bp.com F R E E C R A C K S From andreww591 at gmail.com Fri Apr 11 05:23:08 2008 From: andreww591 at gmail.com (Andrew Warkentin) Date: Fri, 11 Apr 2008 03:23:08 -0600 Subject: Suitable libraries for implementing a "push"-type matching engine? Message-ID: <47FF2DFC.6040502@gmail.com> I am trying to write a matching engine for a matching language for a filtering proxy compatible with that of The Proxomitron. The matching language is basically an extended superset of shell-style globs, with functionality comparable to regexps (see http://www.proxomitron.info/45/help/Matching%20Rules.html). Can anyone recommend any Python libraries that would be suitable for my purposes? I think that I can implement a parser for the patterns themselves with pyparsing, but I'm not sure if anything suitable for finding matches in an input stream of text exists. I don't want to reinvent the wheel if I don't have to. A matching engine for a filtering proxy has to be able to handle partial input and "hold" data until enough is received to determine whether there is a match (or else the entire document would have to be held until the end is reached, filtered, and then sent all at once to the remote client, and that would make it appear much less responsive and possibly break some applications). I also need to be able to associate specific patterns (matching commands and certain backslash-escapes) with functions that are called to determine if they match. From stefan_ml at behnel.de Fri Apr 25 02:16:57 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 25 Apr 2008 08:16:57 +0200 Subject: convert xhtml back to html In-Reply-To: References: <4810E5CC.2000503@behnel.de> Message-ID: <48117759.4090909@behnel.de> bryan rasmussen top-posted: > On Thu, Apr 24, 2008 at 9:55 PM, Stefan Behnel wrote: >> from lxml import etree >> >> tree = etree.parse("thefile.xhtml") >> tree.write("thefile.html", method="html") >> >> http://codespeak.net/lxml > > wow, that's pretty nice there. > > Just to know: what's the performance like on XML instances of 1 GB? That's a pretty big file, although you didn't mention what kind of XML language you want to handle and what you want to do with it. lxml is pretty conservative in terms of memory: http://blog.ianbicking.org/2008/03/30/python-html-parser-performance/ But the exact numbers depend on your data. lxml holds the XML tree in memory, which is a lot bigger than the serialised data. So, for example, if you have 2GB of RAM and want to parse a serialised 1GB XML file full of little one-element integers into an in-memory tree, get prepared for lunch. With a lot of long text string content instead, it might still fit. However, lxml also has a couple of step-by-step and stream parsing APIs: http://codespeak.net/lxml/parsing.html#the-target-parser-interface http://codespeak.net/lxml/parsing.html#the-feed-parser-interface http://codespeak.net/lxml/parsing.html#iterparse-and-iterwalk They might do what you want. Stefan From HDoran at air.org Mon Apr 14 08:36:28 2008 From: HDoran at air.org (Doran, Harold) Date: Mon, 14 Apr 2008 08:36:28 -0400 Subject: Process multiple files Message-ID: <2323A6D37908A847A7C32F1E3662C80E017BDF37@dc1ex01.air.org> Say I have multiple text files in a single directory, for illustration they are called "spam.txt" and "eggs.txt". All of these text files are organized in exactly the same way. I have written a program that parses each file one at a time. In other words, I need to run my program each time I want to process one of these files. However, because I have hundreds of these files I would like to be able to process them all in one fell swoop. The current program is something like this: sample.py new_file = open('filename.txt', 'w') params = open('eggs.txt', 'r') do all the python stuff here new_file.close() If these files followed a naming convention such as 1.txt and 2.txt I can easily see how these could be parsed consecutively in a loop. However, they are not and so is it possible to modify this code such that I can tell python to parse all .txt files in a certain directory and then to save them as separate files? For instance, using the example above, python would parse both spam.txt and eggs.txt and then save 2 different files, say as spam_parsed.txt and eggs_parsed.txt. Thanks From tracyde at gmail.com Wed Apr 2 10:59:57 2008 From: tracyde at gmail.com (Derek Tracy) Date: Wed, 2 Apr 2008 10:59:57 -0400 Subject: Manipulate Large Binary Files Message-ID: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> I am trying to write a script that reads in a large binary file (over 2Gb) saves the header file (169088 bytes) into one file then take the rest of the data and dump it into anther file. I generated code that works wonderfully for files under 2Gb in size but the majority of the files I am dealing with are over the 2Gb limit INPUT = open(infile, 'rb') header = FH.read(169088) ary = array.array('H', INPUT.read()) INPUT.close() OUTF1 = open(outfile1, 'wb') OUTF1.write(header) OUTF2 = open(outfile2, 'wb') ary.tofile(OUTF2) When I try to use the above on files over 2Gb I get: OverflowError: requested number of bytes is more than a Python string can hold Does anybody have an idea as to how I can get by this hurdle? I am working in an environment that does not allow me to freely download modules to use. Python version 2.5.1 R/S -- --------------------------------- Derek Tracy tracyde at gmail.com --------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From dblubaugh at belcan.com Tue Apr 22 18:13:51 2008 From: dblubaugh at belcan.com (Blubaugh, David A.) Date: Tue, 22 Apr 2008 18:13:51 -0400 Subject: Lucky gay sucking cock while butt fucked deep In-Reply-To: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> Message-ID: <27CC3060AF71DA40A5DC85F7D5B70F38033A4F29@AWMAIL04.belcan.com> Is there a way to block these messages. I do not want to be caught with filth such as this material. I could lose my job with Belcan with evil messages such as these messages. David Blubaugh -----Original Message----- From: uniontelecardsindia at gmail.com [mailto:uniontelecardsindia at gmail.com] Sent: Tuesday, April 22, 2008 5:14 PM To: python-list at python.org Subject: Lucky gay sucking cock while butt fucked deep Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . This e-mail transmission contains information that is confidential and may be privileged. It is intended only for the addressee(s) named above. If you receive this e-mail in error, please do not read, copy or disseminate it in any manner. If you are not the intended recipient, any disclosure, copying, distribution or use of the contents of this information is prohibited. Please reply to the message immediately by informing the sender that the message was misdirected. After replying, please erase it from your computer system. Your assistance in correcting this error is appreciated. From bignose+hates-spam at benfinney.id.au Tue Apr 8 21:20:41 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Wed, 09 Apr 2008 11:20:41 +1000 Subject: import statement convention References: <4078bcf4-e68f-45d4-93ce-335ec7a33c5a@v32g2000prd.googlegroups.com> Message-ID: <87fxtvomc6.fsf@benfinney.id.au> MartinRinehart at gmail.com writes: > By convention, I've read, your module begins with its import > statements. Is this always sensible? There are exceptions, but the benefits are great: It's very easy to see what this module requires, without needing to execute it. > I put imports that are needed for testing in the test code at the > end of the module. If only a bit of the module has a visual > interface, why pollute the global namespace with 'from Tkinter > import *'? Wouldn't that be better done in a separate class or > function? If your test code requires the Tkinter module but the rest of the code doesn't, why pollute the functional module with such test code? Move it to a separate unit test module. -- \ ?Never do anything against conscience even if the state demands | `\ it.? ?Albert Einstein | _o__) | Ben Finney From steve at holdenweb.com Sat Apr 5 22:14:15 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 22:14:15 -0400 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> Message-ID: <47F831F7.4000709@holdenweb.com> Fredrik Lundh wrote: > Fredrik Lundh wrote: > >> and for the record, Python doesn't look for PYD files on any of the Unix >> boxes I have convenient access to right now. what Ubuntu version are >> you using, what Python version do you have, and what does >> >> $ python -c "import imp; print imp.get_suffixes()" >> >> print on your machine? > > for reference, here's what I get on Ubuntu 7.10, with the standard > Python interpreter (2.5.1): > > $ python -c "import imp; print imp.get_suffixes()" > [('.so', 'rb', 3), ('module.so', 'rb', 3), ('.py', 'U', 1), > ('.pyc', 'rb', 2)] > > any Ubuntu gurus here that can sort this one out? > I wouldn't claim to be an Ubuntu guru but it seems as though the Ubuntu team decide that you would be able to import extension module YYY either from YYY.so or from YYYmodule.so. IF you are asking *why* then I'd have to answer that I have no idea at all. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From simone.brunozzi at gmail.com Tue Apr 8 10:14:56 2008 From: simone.brunozzi at gmail.com (Simone Brunozzi) Date: Tue, 8 Apr 2008 07:14:56 -0700 (PDT) Subject: Looking for Conferences/Events on Django, Python, MySQL, etc in Europe 2008? References: <7fb0f408-1a2e-4ee1-a179-092f83eb1591@8g2000hsu.googlegroups.com> Message-ID: <8100c94f-3205-480c-9f8a-f56b4ac8b7f3@8g2000hsu.googlegroups.com> On Apr 8, 12:36 pm, "Simon Brunning" wrote: > On Tue, Apr 8, 2008 at 10:10 AM, Simone Brunozzi > > wrote: > > Greetings! > > > I'm looking for conferences or events about Python, Django, Dabatases, > > Mysql, > > PHP, Ruby in Europe (or nearby locations like north africa and middle > > east) in 2008. > > Do you have any suggestions? > > PyCon UK 2008 - 12th to 14th September 2008 - . > > -- > Cheers, > Simon B. > si... at brunningonline.nethttp://www.brunningonline.net/simon/blog/ Thanks a lot! From jkugler at bigfoot.com Wed Apr 9 14:57:07 2008 From: jkugler at bigfoot.com (Joshua Kugler) Date: Wed, 09 Apr 2008 10:57:07 -0800 Subject: Google App Engine References: Message-ID: Duncan Booth wrote: > http://www.techcrunch.com/2008/04/07/google-jumps-head-first-into-web-services-with-google-app-engine/ > "Python only. What a weird decision. Not business and > community-friendly at all." Translation: "Not over-engineered-top-heavy-overly-complex-job-security-inducing-Java-enterprise friendly." j From gagsl-py2 at yahoo.com.ar Sun Apr 20 13:29:32 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 14:29:32 -0300 Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: En Sun, 20 Apr 2008 13:42:05 -0300, Matthew Woodcraft escribi?: > An alternative scheme for describing the block structure could be > useful in other cases, though. For example, if you wanted to support > putting snippets of Python in configuration files, or spreadsheet > cells. > [...] If someone wrote a library for this and it proved popular, I expect it > would be considered for the standard library. There is "pindent.py" in the Tools/scripts directory: # ... When called as "pindent -r" it assumes its input is a # Python program with block-closing comments but with its indentation # messed up, and outputs a properly indented version. # A "block-closing comment" is a comment of the form '# end ' # where is the keyword that opened the block ... def foobar(a, b): if a == b: a = a+1 elif a < b: b = b-1 if b > a: a = a-1 # end if else: print 'oops!' # end if # end def foobar -- Gabriel Genellina From aldo at nullcube.com Sat Apr 5 06:54:59 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Sat, 5 Apr 2008 21:54:59 +1100 Subject: ANN: pry unit testing framework In-Reply-To: References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> Message-ID: <20080405105459.GB15154@nullcube.com> Thus spake Matthieu Brucher (matthieu.brucher at gmail.com): > How does it compare to the nose framework ? As far as the base unit testing functionality is concerned, I think they try to address similar problems. Both have assert-based testing with inspection and re-parsing of assert exceptions for better error messages. Both try to provide better fixture management. Both make programmatic test generation easier. Both have a command-line tool for running and gathering tests. I like nose, but I'm biased, and of course I think Pry has some advantages. One difference I'd point out is Pry's tree-based test structure, which provides a number of conveniences and features (much nicer test selection from the command line, for instance). Pry is also less than half the size of nose, and should therefore be simpler to extend and understand. At any rate, feel free to take a look at Pry and see what you think. Regards, Aldo -- Aldo Cortesi Managing Director M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From sjmachin at lexicon.net Mon Apr 21 17:04:49 2008 From: sjmachin at lexicon.net (John Machin) Date: Mon, 21 Apr 2008 21:04:49 GMT Subject: List of all Python's ____ ? In-Reply-To: <87wsmrdka8.fsf@mulj.homelinux.net> References: <87wsmrdka8.fsf@mulj.homelinux.net> Message-ID: <480d016e$1@news.mel.dft.com.au> Hrvoje Niksic wrote: > python at bdurham.com writes: > >> Is there an official list of all Python's ____? > > http://docs.python.org/ref/specialnames.html __missing__ is missing :-) see note (10) at the bottom of http://docs.python.org/lib/typesmapping.html From aahz at pythoncraft.com Sun Apr 20 22:47:35 2008 From: aahz at pythoncraft.com (Aahz) Date: 20 Apr 2008 19:47:35 -0700 Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: In article <739039ff-10f6-4369-9886-3af628798c22 at 2g2000hsn.googlegroups.com>, Mike Driscoll wrote: > >My workplace doesn't offer NNTP, so there is no good way to browse >c.l.py here. And I haven't been able to get NNTP to work from my home >either. Can you use ssh? Get a shell account somewhere else. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "It is easier to optimize correct code than to correct optimized code." --Bill Harlan From george.sakkis at gmail.com Fri Apr 25 22:41:27 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 25 Apr 2008 19:41:27 -0700 (PDT) Subject: Setting an attribute without calling __setattr__() References: Message-ID: <8b41c868-5630-4bdf-b780-8925ca382cef@34g2000hsh.googlegroups.com> On Apr 25, 5:01 pm, Joshua Kugler wrote: > My init lookslike this: > > def __init__(self, obj=None): > if type(obj).__name__ in 'list|tuple|set|frozenset': > self.me = [] > for v in obj: > self.me.append(ObjectProxy(v)) > elif type(obj) == dict: > self.me = {} > for k,v in obj.items(): > self.me[k] = ObjectProxy(v) As an aside, unrelated to your question, Python encourages "duck typing" instead of exact type matching. Unless you have a good reason to restrict obj to one of the 5 types you hardcoded (a rather rare need), it is more flexible to write it as: def __init__(self, obj=None): if hasattr(obj, 'items'): # assume obj is a mapping type instance self.me = dict((k,ObjectProxy(v)) for k,v in obj.items()) else: try: # check if obj is an iterable instance self.me = map(ObjectProxy, obj) except TypeError: # handle other cases here # self.me = ... A downside of this flexibility is that it may be more liberal than it should. For instance, if obj just happens to have an 'items()' method but it's not really a mapping type, the assumption is violated. Python 3 deals with such potential ambiguities by introducing Abstract Base Classes (ABCs) [1] that allow a class to make explicit its semantics. So in Py3K the hasattr() test above would rather be written as "isinstance(obj, Mapping)", where Mapping is the ABC that represents (read-only) mappings. A more difficult problem is that even if a class derives from some ABC, you may not always want to treat its instances as such. The typical gotcha is that strings are iterable, but in many (most?) applications they are to be treated as atomic values, not as sequences of characters. So in the example above if obj is a string, self.me will be a list of ObjectProxy instances, one per character; probably not what you intend. Of course we can check for "isinstance(obj,str)" but then we're back at explicit type checking. There is no general way to express something lke "atomic value that also happens to be iterable (but pretend it's not)" because it's inherently domain- dependent. George [1] http://www.python.org/dev/peps/pep-3119/ From aldo at nullcube.com Sat Apr 5 08:07:08 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Sat, 5 Apr 2008 23:07:08 +1100 Subject: ANN: pry unit testing framework In-Reply-To: <740c3aec0804050426m39837404i8e8d6c232bef7724@mail.gmail.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <740c3aec0804050426m39837404i8e8d6c232bef7724@mail.gmail.com> Message-ID: <20080405120708.GB15684@nullcube.com> Thus spake BJ?rn Lindqvist (bjourne at gmail.com): > Isn't nose tree-based too? You can select both single test-cases > suites or directories to run. Well, in a way, perhaps. But not in the sense that Pry is. In Pry you can nest test fixtures (setUp/tearDown pairs) within test fixtures, allowing arbitrarily deep fixture hierarchies. You can then address any sub-tree in this hierarchy from the command-line. This structure turns out to be terribly useful in practice, when, for example, developing database applications. > Anyway, I don't think comparisions with nose is fair, because nose is > the best of the best and all other test runners fall short of it. :) I'll take your word for it. ;) Unfortunately, the more bang per line of code argument won't do, since the number of lines of code in your nose example and the Pry example matches almost exactly. Unless, of course, you were joking and that was precisely the point you were trying to make... in which case I apologise and you can ignore this... ;) Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From nagle at animats.com Mon Apr 7 14:27:48 2008 From: nagle at animats.com (John Nagle) Date: Mon, 07 Apr 2008 11:27:48 -0700 Subject: Orphaned child processes In-Reply-To: <51102b91-dedc-4ad6-a936-c29df47f30ab@r9g2000prd.googlegroups.com> References: <51102b91-dedc-4ad6-a936-c29df47f30ab@r9g2000prd.googlegroups.com> Message-ID: <47fa650f$0$36329$742ec2ed@news.sonic.net> rocco.rossi at gmail.com wrote: > I'm using the Python processing module. I've just run into a problem > though. Actually, it's a more general problem that isn't specific to > this module, but to the handling of Unix (Linux processes) in general. > Suppose for instance that for some reason or another, after forking > several child processes, the main process terminates or gets killed > (or segfaults or whatever) and the child processes are orphaned. Is > there any way to automatically arrange things so that they auto- > terminate or, in other words, is there a way to make the child > processes terminate when the parent terminates? > > Thank you. Put a thread in the child which reads stdin, and make stdin connect to a pipe from the parent. When the parent terminates, the child will get a SIGPIPE error and raise an exception. John Nagle From bbxx789_05ss at yahoo.com Wed Apr 2 17:26:05 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Wed, 2 Apr 2008 14:26:05 -0700 (PDT) Subject: class / module introspection? References: <3c3f09df-08cb-4309-a870-6b12a813a8af@u36g2000prf.googlegroups.com> <0f14a289-55ef-49e5-b650-60f7aca371ad@i36g2000prf.googlegroups.com> Message-ID: <033570bc-c5f3-4575-8dae-51780e68d2d7@m3g2000hsc.googlegroups.com> On Apr 2, 1:27?pm, Brian Munroe wrote: > On Apr 2, 12:07 pm, Brian Munroe wrote: > > > > > This gives me ['system1','system2'] - which I can then use __import__ > > on. > > Addendum, thanks Bruno! > > I also required the helper function (my_import) from the Python docs > You don't need that helper function, which is a little tricky to follow: If you have a module name as a string, you can use the builtin function __import__ to import the module, e.g. x = __import__("mymod") x.myfunc() Note that you have to assign the return value of __import__ to a variable. Thereafter you use the variable to access the module's functions. However, when you use __import__ with a package, it behaves in a peculiar manner: it returns the top level package object. For example, if you write: x = __import__("mypackage.subpack.myfuncs") then x is a reference to mypackage--not mypackage.subpack.myfuncs. In order to execute a function in the module myfuncs, you need to write: x.subpack.myfuncs.f(). Or, if you check the docs, you can make __import__ return the rightmost module in the module string by writing: x = __import__("mypackage.subpack.myfuncs", globals(), locals(), ["subpack.myfuncs"]) The last argument is what makes __import__ return a lower level module in the package hierarchy. To solve your problem, you can do something like the following: Directory structure ------------------- ../mypackage __init__.py /system1 __init__.py myfuncs.py /system2 __init__.py myfuncs.py system1/myfuncs.py ------------ def f(): print "system1 here" system2/myfuncs.py ----------------- def f(): print "system2 here" import sys import os #Get all the file names contained in mypackage: fnames = os.listdir("../mypackage") print fnames #Separate out the directory names(which are the sub packages): os.chdir("../mypackage") #so abspath() below can construct full paths package_dirs = [] for fname in fnames: abs_path = os.path.abspath(fname) #need full path for isdir() print abs_path, if os.path.isdir(abs_path): print 'dir' package_dirs.append(fname) else: print 'file' print package_dirs sys.path.append("../") #directs python to search the specified #dir for any modules that are imported #Import the sub packages: for dir in package_dirs: modname = "%s.%s.%s" % ("mypackage", dir, "myfuncs") modname_minus_toplevel_packname = "%s.%s" % (dir, "myfuncs") mod = __import__(modname, globals(), locals(), [modname_minus_toplevel_packname]) mod.f() --output:-- ['__init__.py', '__init__.pyc', 'system1', 'system2'] /Users/me/2testing/mypackage/__init__.py file /Users/me/2testing/mypackage/__init__.pyc file /Users/me/2testing/mypackage/system1 dir /Users/me/2testing/mypackage/system2 dir ['system1', 'system2'] system1 here system2 here From nick at craig-wood.com Mon Apr 28 05:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Mon, 28 Apr 2008 04:30:03 -0500 Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> <18c1e6480804270653r2e075061wf442b7b7d9f50ff6@mail.gmail.com> Message-ID: David wrote: > Another idea would be to have multiple queues, one per thread or per > message type "group". The producer thread pushes into the appropriate > queues (through an intelligent PutMsg function), and the consumer > threads pull from the queues they're interested in and ignore the > others. Unfortunately a thread can only wait on one Queue at once (without polling). So really the only efficient solution is one Queue per thread. Make an intelligent PutMsg function which knows which Queue (or Queues) each message needs to be put in and all the threads will have to do is Queue.get() and be sure they've got a message they can deal with. -- Nick Craig-Wood -- http://www.craig-wood.com/nick From danb_83 at yahoo.com Wed Apr 30 21:04:20 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Wed, 30 Apr 2008 18:04:20 -0700 (PDT) Subject: We have string.isdigit(), why not string.isNumber()? References: <0d43feda-fab8-46ba-9af0-eaf497033acd@l17g2000pri.googlegroups.com> Message-ID: On Apr 30, 7:56 pm, MooMaster wrote: > N00b question alert! I did a search for isdigit() in the group > discussion, and it didn't look like the question had been asked in the > first 2 pages, so sorry if it was... > > The manual documentation says: > "isdigit( ) > > Return true if all characters in the string are digits and there is at > least one character, false otherwise. > For 8-bit strings, this method is locale-dependent. " > > So it makes sense that something like 5.6 would return false. But what > if we want to make sure that our string is a valid number, ie decimals > included? > > I know how to write a regexp or method or whatever to do this, my main > question is *why* something like an isNumber() method is not baked > into the class. Does such functionality exist somewhere else in the > standard library that I'm just missing? A string s is a valid number if float(s) does not raise a ValueError. From samslists at gmail.com Mon Apr 21 18:48:40 2008 From: samslists at gmail.com (samslists at gmail.com) Date: Mon, 21 Apr 2008 15:48:40 -0700 (PDT) Subject: Problems replacing \ with \\ Message-ID: <0ca30eb2-3791-4910-9e78-f32e3b2a72cb@2g2000hsn.googlegroups.com> Hi... Here's a weird problem...I'm trying to escape a bunch of data to put into a database. Here's what I have: def escape(string): """ Escape both single quotes and blackslashes >>> x = r"fun\fun" >>> escape(x) 'fun\\\\fun' """ string = string.replace('\\', '\\\\') return string Now the commands in the doctest work when I type them by hand into the python interpreter! >>> x = r"fun\fun" >>> escape(x) 'fun\\\\fun' But they don't work when I actually run them with doctest: Failed example: escape(x) Expected: 'fun\\fun' Got: 'fun\x0cun' Why? Thanks! From steve at holdenweb.com Sat Apr 5 22:08:45 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 22:08:45 -0400 Subject: Best way to check if string is an integer? In-Reply-To: <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> Message-ID: <47F830AD.9050106@holdenweb.com> John Machin wrote: > On Apr 6, 9:25 am, Mark Dickinson wrote: >> On Apr 5, 6:19 pm, skanem... at yahoo.se wrote: >> >>> which is the best way to check if a string is an number or a char? >>> could the 2nd example be very expensive timewise if i have to check a >>> lot of strings? >> You might be interested in str.isdigit: >> >>>>> print str.isdigit.__doc__ >> S.isdigit() -> bool >> >> Return True if all characters in S are digits >> and there is at least one character in S, False otherwise. >> > > This doesn't cater for negative integers. > No, it doesn't, but s.isdigit() or (s[0] in "+-" and s[1:].isdigit) # untested does. and *may* be quicker than other examples. Not that speed is usually a concern in validation routines anyway ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From balta96428 at gmail.com Wed Apr 23 06:00:06 2008 From: balta96428 at gmail.com (balta96428 at gmail.com) Date: Wed, 23 Apr 2008 03:00:06 -0700 (PDT) Subject: crack how to make Message-ID: <5f690ef1-d5da-42a9-85e1-885cedbe6ed4@k37g2000hsf.googlegroups.com> crack how to make http://cracks.12w.net F R E E C R A C K S From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 3 10:22:30 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 03 Apr 2008 16:22:30 +0200 Subject: How easy is it to install python as non-root user? In-Reply-To: <47f4e617$0$720$bed64819@news.gradwell.net> References: <47f4e617$0$720$bed64819@news.gradwell.net> Message-ID: <47f4e825$0$20141$426a74cc@news.free.fr> tinnews at isbd.co.uk a ?crit : > Does python install fairly easily for a non-root user? > > I have an ssh login account onto a Linux system that currently > provides Python 2.4.3 and I'd really like to use some of the > improvements in Python 2.5.x. > > So, if I download the Python-2.5.2.tgz file is it just the standard:- > > ./configure --prefix=$HOME > make > make install > IIRC there's something like make altinstall - but you'd better read the doc (INSTALL.txt anyone ?) From kyosohma at gmail.com Tue Apr 8 17:12:26 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 8 Apr 2008 14:12:26 -0700 (PDT) Subject: Running a python code periodically References: Message-ID: On Apr 8, 3:01 pm, Larry Bates wrote: > paul wrote: > > Maryam Saeedi schrieb: > >> Hi, > > >> I was wondering if you know how can I run a python code once every five > >> minutes for a period of time either using python or some other program > >> like > >> a bash script. > > > See the sched module in the standard library or here: > >http://pypi.python.org/simple/Recur/ > > > cheers > > Paul > > You could use cron also. > > -Larry And if you're on Windows, you can use the Scheduled Task Manager. Mike From breily at gmail.com Tue Apr 8 18:36:18 2008 From: breily at gmail.com (Brian) Date: Tue, 8 Apr 2008 18:36:18 -0400 Subject: Converting a tuple to a list In-Reply-To: References: <00ba01c899c5$14528ae0$0a01a8c0@mobile> Message-ID: On Tue, Apr 8, 2008 at 6:22 PM, Steve Holden wrote: > Gabriel Ibanez wrote: > > Hi all .. > > > > I'm trying to using the map function to convert a tuple to a list, > without > > success. > > > > I would like to have a lonely line that performs the same as loop of the > > next script: > > > > ------------------------------------------- > > # Conveting tuple -> list > > > > tupla = ((1,2), (3,4), (5,6)) > > > > print tupla > > > > lista = [] > > for a in tupla: > > for b in a: > > lista.append(b) > > print lista > > ------------------------------------------- > > > > Any idea ? > > > > Thanks ... > > > > # Gabriel > > > list(tupla) > > would probably do it. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > That would just make a list of tuples, I think he wants [1, 2, 3, 4, 5, 6]. Try: l = [x for z in t for x in z] --Brian -------------- next part -------------- An HTML attachment was scrubbed... URL: From marli305nugent at gmail.com Sat Apr 26 09:49:53 2008 From: marli305nugent at gmail.com (marli305nugent at gmail.com) Date: Sat, 26 Apr 2008 06:49:53 -0700 (PDT) Subject: windows xp crack serial Message-ID: <9ec0182b-0db2-4599-a935-fdd1eccffc3d@y38g2000hsy.googlegroups.com> windows xp crack serial http://cracks.00bp.com F R E E C R A C K S From magdoll at gmail.com Tue Apr 29 20:11:46 2008 From: magdoll at gmail.com (Magdoll) Date: Tue, 29 Apr 2008 17:11:46 -0700 (PDT) Subject: best way to host a membership site Message-ID: <53034dcc-7346-4f71-889c-3278c9e813ec@w1g2000prd.googlegroups.com> Hi, I know this is potentially off-topic, but because python is the language I'm most comfortable with and I've previously had experiences with plone, I'd as much advice as possible on this. I want to host a site where people can register to become a user. They should be able to maintain their own "showroom", where they can show blog entries (maybe just by linking to their own blogs on some other blog/album-hosting site like Xanga), put up pictures (again, I'm not thinking about actually hosting these data, since there are already plenty of places to put your pictures and blogs). The most important thing is they will be able to build up a "profile" where I can store in a DB. The profile will include membership information - for now, think of it as "member X owns item A,B,C and gave comments on A such and such, also member X is a male white caucasian between his 20-30 who likes outdoors". Eventually, I want this to be a simple social- networking site where people can share a very particular hobby (I'm doing it for comsetics and for a very targeted group that are active bloggers, so they'll be somewhat web-salient) and the backend can collect enough data (while maintaining privacy) to build up a recommendation system similar to Netflix's movie recommendations, or Match.com if you will. I want to know that given I know python best and I abhor C#/ASP, what is the best thing to use. A friend recommended Ruby on Rails - not to instigate war here, but I'd welcome comments on that (I don't know Ruby, but I'll learn). I've used PLONE before, but back then I remembered the site ran incredably slow (or it could just be the server), and there were issues with upgrades. I want to minimze time on trying to learn how to write an interface for users to register and manage their own space. Also I want an infrastructure that's not too rigid so if in the future I want to add more apps it's not to hard. I've also heard about django, but not enough to know how far it'll get me. I'm open to all sorts of suggestions. Thanks! - Magdoll From fetchinson at googlemail.com Mon Apr 21 14:05:02 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Mon, 21 Apr 2008 11:05:02 -0700 Subject: Does Python 2.5.2's embedded SQLite support full text searching? In-Reply-To: <1208794249.15992.1249049327@webmail.messagingengine.com> References: <1208794249.15992.1249049327@webmail.messagingengine.com> Message-ID: > Does Python 2.5.2's embedded SQLite support full text searching? > > Any recommendations on a source where one can find out which SQLite > features are enabled/disabled in each release of Python? I'm trying to > figure out what's available in 2.5.2 as well as what to expect in 2.6 > and 3.0. Sqlite itself is not distributed with python. Only a python db api compliant wrapper is part of the python stdlib and as such it is completely independent of the sqlite build. In other words, if your sqlite build supports full text searching you can use it through the python sqlite wrapper (that is part of the stdlib) and if it doesn't then not. This is true for any sqlite feature though. So if you need an sqlite feature just go ahead and build your own sqlite with that feature enabled and use that feature with the stock python sqlite wrapper that comes with the stdlib. HTH, Daniel From george.sakkis at gmail.com Thu Apr 3 09:27:14 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Thu, 3 Apr 2008 06:27:14 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> <88b07549-9751-489b-968f-c3d2db0aba79@s13g2000prd.googlegroups.com> Message-ID: On Apr 3, 9:00 am, Jeff wrote: > On Apr 3, 8:44 am, Ant wrote: > > > > > On Apr 3, 12:37 pm, tinn... at isbd.co.uk wrote: > > > > What's the neatest and/or most efficient way of testing if one of a > > > A different approach: > > > >>> words = ["he", "sh", "bla"] > > >>> name = "blah" > > >>> True in (word in name for word in words) > > > True > > > >>> name = "bling" > > >>> True in (word in name for word in words) > > > False > > > Perhaps not as obvious or readable as Jeff's example, but is > > essentially doing the same thing using generator syntax. > > That's pretty :) It's even prettier in 2.5: any(word in name for word in words) George From s0suk3 at gmail.com Wed Apr 16 11:14:28 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Wed, 16 Apr 2008 08:14:28 -0700 (PDT) Subject: Default parameter for a method Message-ID: <806788d2-67b7-456b-bd1e-08c50cbf0f7b@8g2000hsu.googlegroups.com> I wanted to know if there's any way to create a method that takes a default parameter, and that parameter's default value is the return value of another method of the same class. For example: class A: def __init__(self): self.x = 1 def meth1(self): return self.x def meth2(self, arg=meth1()): # The default `arg' should would take the return value of meth1() print '"arg" is', arg This obviously doesn't work. I know I could do ... def meth2(self, arg=None): if arg is None: arg = self.meth1() but I'm looking for a more straightforward way. From nullgraph at gmail.com Wed Apr 16 09:31:04 2008 From: nullgraph at gmail.com (nullgraph at gmail.com) Date: Wed, 16 Apr 2008 06:31:04 -0700 (PDT) Subject: vary number of loops Message-ID: Hi everyone, I'm new to Python and the notion of lambda, and I'm trying to write a function that would have a varying number of nested for loops depending on parameter n. This just smells like a job for lambda for me, but I can't figure out how to do it. Any hint? For example, for n=2, I want the function to look something like: def foo(2) generate 2 sets of elements A, B # mix elements by: for a_elt in A for b_elt in B form all combinations of them If n=3, I want to have 3 sets of elements and mix them up using 3 for loops. Any help is greatly appreciated, nullgraph From mccredie at gmail.com Tue Apr 8 12:32:24 2008 From: mccredie at gmail.com (Matimus) Date: Tue, 8 Apr 2008 09:32:24 -0700 (PDT) Subject: Python 3.0 new integer division References: Message-ID: On Apr 8, 9:13 am, "Hutch" wrote: > We now have a float result when two integers are divided in the same mannor > as 2.4 or 2.5. > I can handle that and use the Floor division but a simple question. > > Why in the world would you round down the last presented digit to a 6 > instead of just leaving it along as an 8. > For some reason rounding down for a float in Python does not seem correct. > > IDLE 3.0a4 > > >>> 12345678901234567890123456789012345678901234567890/345 > > 3.5784576525317586e+46 > > >>> 12345678901234567890123456789012345678901234567890//345 > > 35784576525317588087314367504383610663481839327 > ^ > ^| > 35784576525317586000000000000000000000000000000 == 3.5784576525317586e+46 This just has to do with the way floating point numbers are represented in memory. More information: http://docs.python.org/tut/node16.html Matt From stefan_ml at behnel.de Mon Apr 7 10:02:21 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 07 Apr 2008 16:02:21 +0200 Subject: Dependency Queue In-Reply-To: <0309251d-fba9-447c-9b17-f512988103ea@e39g2000hsf.googlegroups.com> References: <0309251d-fba9-447c-9b17-f512988103ea@e39g2000hsf.googlegroups.com> Message-ID: <47FA296D.5020000@behnel.de> Carl Banks wrote: > I'm looking for any information about a certain kind of dynamic data > structure. Not knowing if it has some well-known name that I could > have Googled, I'll just call it a dependency queue. It's like a > priority queue except instead of a strict ordering of items by > priority, there is only a topological ordering (like you would have in > a directed acyclic graph). > > To date I've been generating a dependency graph in advance every > iteration through my main loop, doing a topsort, and executing the > values in order (the values are callable objects--this is a > scheduler). > > However, I'd like a dynamic dependency queue for two reasons: it would > simplify things to not have to generate the whole graph in advance, > and it could improve performance to run some tasks of the next > iteration in the present one (this could potentially make better use > of the dual-core and graphics hardware). > > I'm pretty sure I could hack out this structure on my own, but I'd > like to see any prior information if there is any, in case anyone's > figured out things like, Is there an easy way to detect cycles on > insertion? and so on. You might consider flattening your graph to map it onto a heap (see the heapq module). One way to do that might be to assign a different power of two to each node and calculate the priority of each node as the sum of its parent's numbers. That way, a child will always have a higher value (== lower priority) than its parents, so the heap will return it after its parents. If you also want a unique priority instead of the same one for all children of the same set of parents, adding the number of the child itself will give you a (possibly arbitrary) unique priority. This (or a similar approach) may or may not solve your problem, depending on how you determine the dependencies. Stefan From n00m at narod.ru Sun Apr 27 15:14:17 2008 From: n00m at narod.ru (n00m) Date: Sun, 27 Apr 2008 12:14:17 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <2d06b319-e2fd-4790-af61-6f90b9b1b3b1@m1g2000pre.googlegroups.com> Message-ID: <41e72e61-6413-41f3-a162-dbcc1ec5fcee@f63g2000hsf.googlegroups.com> Lie wrote: > On Apr 27, 6:28?am, n00m wrote: > > No so simple, guys. > > E.g., I can't solve (in Python) this:http://www.spoj.pl/problems/INTEST/ > > Keep getting TLE (time limit exceeded). Any ideas? After all, it's > > weekend. > > > > 450. Enormous Input Test > > Problem code: INTEST > > > > The purpose of this problem is to verify whether the method you are > > using to read input data is sufficiently fast to handle problems > > branded with the enormous Input/Output warning. You are expected to be > > able to process at least 2.5MB of input data per second at runtime. > > > > Input > > The input begins with two positive integers n k (n, k<=107). The next > > n lines of input contain one positive integer ti, not greater than > > 109, each. > > > > Output > > Write a single integer to output, denoting how many integers ti are > > divisible by k. > > > > Example > > Input: > > 7 3 > > 1 > > 51 > > 966369 > > 7 > > 9 > > 999996 > > 11 > > > > Output: > > 4 > > The problem is faulty. > First, the bottleneck on reading a huge input is the harddisk speed > and the string processing, the result of the competition doesn't prove > anything but how fast the string processor and the harddisk is. > Python's string processing is not a very fast one as it creates a copy > of the string every now and then. In case you didn't pay attention: Python and C++ were tested on the same PC. From bruno.desthuilliers at gmail.com Wed Apr 2 18:41:28 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 15:41:28 -0700 (PDT) Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> <7xwsngyu05.fsf@ruckus.brouhaha.com> <7x8wzw80rf.fsf@ruckus.brouhaha.com> Message-ID: <0d97babc-1174-4537-a7eb-e60164521863@s13g2000prd.googlegroups.com> On 2 avr, 22:23, Paul Rubin wrote: > "bruno.desthuilli... at gmail.com" writes: > > Fine. But totally irrelevant here - this is comp.lang.python, not > > comp.lang.c, and we *do not* (I repeat : we *do not*) face the same > > safety and security problems as those existing in C. > > We have it better than they do in some ways. >In some other ways, we have > it worse. Care to elaborate ? Or are we supposed to guess ?-) From phil at riverbankcomputing.com Thu Apr 3 06:53:26 2008 From: phil at riverbankcomputing.com (Phil Thompson) Date: Thu, 3 Apr 2008 11:53:26 +0100 Subject: State of ctypes Support on HP-UX? Message-ID: <200804031153.26234.phil@riverbankcomputing.com> Could somebody confirm how well ctypes is supported on HP-UX (for both PA-RISC and Itanium) for both Python v2.4 and v2.5? I don't have access to an HP system and Google doesn't come up with a definitive answer (which may just mean it works fine, but prior experience with HP means I'd like more specific assurances). Thanks, Phil From paul at subsignal.org Thu Apr 10 15:24:55 2008 From: paul at subsignal.org (paul) Date: Thu, 10 Apr 2008 21:24:55 +0200 Subject: Running a python code periodically In-Reply-To: References: Message-ID: Larry Bates schrieb: > paul wrote: >> Maryam Saeedi schrieb: >>> Hi, >>> >>> I was wondering if you know how can I run a python code once every five >>> minutes for a period of time either using python or some other program >>> like >>> a bash script. >> See the sched module in the standard library or here: >> http://pypi.python.org/simple/Recur/ >> >> cheers >> Paul >> > You could use cron also. I hate external dependencies! Whats worse is the need to fiddle with settings in different locations. All of a sudden, arcane looking crontabs are configuration files you have to care about. Better to avoid that. cheers Paul From deets at nospam.web.de Tue Apr 15 17:35:57 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 15 Apr 2008 23:35:57 +0200 Subject: How to import C++ static library? In-Reply-To: References: <66j9r8F2k2iplU1@mid.uni-berlin.de> Message-ID: <66klecF2khhndU1@mid.uni-berlin.de> > Diez: I tried SWIG, and it works nicely with C. For C++, I didn't manage > to make it work. I tried SIP; I have some problems compiling etc. Would > it be too much to ask you to supply a working example of a (simple, > stupid) C++ class and the necessary SIP files? Preferably for Mac OS X, > but Linux is also interesting I guess. http://roggisch.de/IrrSinn.tgz That's a pet-project of mine. You won't make it compile though! Just see if it works for you as a template. Diez From maxkhesin at gmail.com Sun Apr 6 09:48:15 2008 From: maxkhesin at gmail.com (xamdam) Date: Sun, 6 Apr 2008 06:48:15 -0700 (PDT) Subject: appropriate python version Message-ID: <0790632f-db07-45ef-9bcd-7e1b592d33be@u69g2000hse.googlegroups.com> Sorry if this is a stupid q, I am trying to figure out the appropriate version of Python(2.4 or 2.5) for an XP 64 system running on an Intel Core2 Quad. Python.org has a to a 64bit build, but it specifies Itanium as the target. Should I just be using the regular build? I was also thinking of getting the Enthought edition (http:// code.enthought.com/enthon/) - would their binary work with the setup, and what would be the downside of using it over the special 64bit build? thanks, max. From sn at sncs.se Thu Apr 17 04:42:07 2008 From: sn at sncs.se (Sverker Nilsson) Date: Thu, 17 Apr 2008 01:42:07 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> Message-ID: On Apr 17, 12:02 am, Carl Banks wrote: > On Apr 16, 12:40 pm, Aaron Watters wrote: > > > > > On Apr 16, 12:27 pm, Rhamphoryncus wrote: > > > > On Apr 16, 6:56 am, Aaron Watters wrote: > > > > > I don't get it. It ain't broke. Don't fix it. > > > > So how would you have done the old-style class to new-style class > > > transition? > > > I'd ignore it. I never understood it and never had > > any need for it anyway. New-style classes and metaclasses > > were a complicated solution to an unimportant problem in > > my opinion. And also a fiendish way to make code > > inscrutible -- which I thought was more of a Perl thing > > than a Python thing, or should be. > > > I must be missing some of the deeper issues here. Please > > educate me. > > The deeper issue is that you're benefiting from these "unimportant" > changes even if you never use them yourself. > > Carl Banks That just seems a BIT categorical for a statement. Who is 'you'? I don't see I benefit from any important or unimportant features in py3k. External libraries I rely on, I can benefit from --- But it would take SOME while to get those libraries ported to py3k, if ever. And I have been benefiting from Python in general, so far. Thanks, community. But now... I'll probably stop posting here for now, & I may stop other things too. Just my 2c. Sverker From grahn+nntp at snipabacken.se Wed Apr 9 15:47:51 2008 From: grahn+nntp at snipabacken.se (Jorgen Grahn) Date: 9 Apr 2008 19:47:51 GMT Subject: Running a python code periodically References: Message-ID: On Tue, 08 Apr 2008 15:01:36 -0500, Larry Bates wrote: > paul wrote: >> Maryam Saeedi schrieb: >>> Hi, >>> >>> I was wondering if you know how can I run a python code once every five >>> minutes for a period of time either using python or some other program like >>> a bash script. >> >> See the sched module in the standard library or here: >> http://pypi.python.org/simple/Recur/ > You could use cron also. Yeah, although cron has minute-resolution, so 5 min is fairly close to the limit of what you can do. Also, the poster mentioned "for a period of time" and that makes me suspect that (s)he really wants the code to make a decision about when to stop executing. /Jorgen -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! From andrei.avk at gmail.com Wed Apr 2 17:01:56 2008 From: andrei.avk at gmail.com (AK) Date: Wed, 02 Apr 2008 16:01:56 -0500 Subject: Python-by-example - new online guide to Python Standard Library In-Reply-To: <30730d40-8f7e-48bd-bb0f-3a95e814b20f@t54g2000hsg.googlegroups.com> References: <47f2d018$0$6517$4c368faf@roadrunner.com> <47f3c751$0$6477$4c368faf@roadrunner.com> <30730d40-8f7e-48bd-bb0f-3a95e814b20f@t54g2000hsg.googlegroups.com> Message-ID: <47f3e642$0$6130$4c368faf@roadrunner.com> CM wrote: > On Apr 2, 2:50 pm, AK wrote: >> Terry Reedy wrote: >>> "AK" wrote in message >>> news:47f2d018$0$6517$4c368faf at roadrunner.com... >>> || I'll be glad to hear comments/suggestions/etc: >>> | >>> |http://www.lightbird.net/py-by-example/ >>> Using - as the example/return delimiter does not work. >>> If you do not want to substantially lengthen the document by going to >>>>>> sqrt(9) >>> 3 >>> then use Python's a comment symbol. >>> sqrt(9) # 3 >>> -or- >>> sqrt(9) # returns 3 (but I think I prefer the first) >>> which clearly is not an arithmetic expression and which can be >>> cut-and-pasted into the interactive interpreter. This also works nicely >>> for invalid examples. >>> sqrt(-9) # raises ValueError >>> Terry Jan Reedy >> Thanks to everybody who replied, I will implement the change as per >> Terry's advice. I'm still considering whether to use the standard >> interpreter syntax, i.e. >>> ... \n result; my reason for not doing that >> is that I will often have a whole screen of function / result lines and >> if I were to add a new line for the result, that'd make two pages out of >> one, which I think is a bit too much. In current docs there are not so >> many examples, so that space is not multiplied quite so much, and using >> interactive interpreter way of showing result is not nearly as much of >> a problem. However, I'm still thinking this over and it seems that >> almost everyone wants to see it done in that way, I might still go for >> two lines. I'll also be posting updates as the work progresses.. >> >> thx, >> >> -- >> -ak >> Tobu |http://www.lightbird.net/tobu/| Freeform DB / Tagger / PIM >> Python-by-Example |http://www.lightbird.net/py-by-example/| Guide >> to LibRef > > You should also change the look of the page to be more high-contrast. > The grayish text in a gray box and the light green text...all too > subtle to see. Not easy for well-sighted people let alone those with > poorer vision. Try make things visually very obvious, bolded headers, > etc. If so, and with the change of showing the result not with an "-" > symbol, it will be much stronger. Thank you for doing it. Okay, will do. In fact this is the second time in as many days that I get a comment on my proposed designs to use more contrasted text vs. background (in fact, for the other design about 3-4 people mentioned this topic). I really had no idea many people have trouble with that. To me, less contrasted text looks smoother and more aesthetically pleasing to the eye, unless I have to read 3 pages or more of condensed text. I also do eye excercises religiously every day:-), so this may train the eyes to see small details better, but I design for other people to use, therefore I will of course try to make it as easy to read for as many people as possible.. Thanks for the comment! I will update the site tomorrow morning with all the changes.. -- -ak Tobu | http://www.lightbird.net/tobu/ | Freeform DB / Tagger / PIM Python-by-Example | http://www.lightbird.net/py-by-example/ | Guide to LibRef From terry.yinzhe at gmail.com Tue Apr 29 10:51:55 2008 From: terry.yinzhe at gmail.com (Terry) Date: Tue, 29 Apr 2008 07:51:55 -0700 (PDT) Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> <18c1e6480804270653r2e075061wf442b7b7d9f50ff6@mail.gmail.com> <9cca03a3-9b96-4bee-947b-baa62cd5f9a9@q24g2000prf.googlegroups.com> Message-ID: <898a6373-a0e7-451f-962b-ec1ed6fc9341@u12g2000prd.googlegroups.com> On Apr 29, 5:30 pm, Nick Craig-Wood wrote: > Terry wrote: > > On Apr 28, 5:30 pm, Nick Craig-Wood wrote: > > > David wrote: > > > > Another idea would be to have multiple queues, one per thread or per > > > > message type "group". The producer thread pushes into the appropriate > > > > queues (through an intelligent PutMsg function), and the consumer > > > > threads pull from the queues they're interested in and ignore the > > > > others. > > > > Unfortunately a thread can only wait on one Queue at once (without > > > polling). So really the only efficient solution is one Queue per > > > thread. > > > > Make an intelligent PutMsg function which knows which Queue (or > > > Queues) each message needs to be put in and all the threads will have > > > to do is Queue.get() and be sure they've got a message they can deal > > > with. > > > I do have one Queue per thread. The problem is the thread can not peek > > into the Queue and select msg with certain ID first. > > My point is don't put messages that the thread doesn't need in the > queue in the first place. Ie move that logic into PutMsg. > > -- > Nick Craig-Wood --http://www.craig-wood.com/nick Well, I'm simulating the real world. It's like that you wouldn't drop or proceed a task when you already started your lunch, just save it and process it later when you finish your lunch. Of course the task sender can send the task again and again if he got not ack from you. But that's just one possible situation in the real world, and not an efficient one. From gagsl-py2 at yahoo.com.ar Thu Apr 10 18:06:41 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 19:06:41 -0300 Subject: Reading floats through Telnet object? References: Message-ID: En Thu, 10 Apr 2008 15:58:44 -0300, Marlin Rowley escribi?: > Is there any function that allows reading a stream of floats through the > Telnet Object? There doesn't seem to be a way to control reading from > the socket accept read_until() and that requires a string. There are several read_* methods, none of them fits you? -- Gabriel Genellina From medin0065 at gmail.com Sun Apr 20 10:45:11 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:45:11 -0700 (PDT) Subject: cracked vacuum line heater Message-ID: cracked vacuum line heater http://cracks.00bp.com F R E E C R A C K S From ptmcg at austin.rr.com Thu Apr 3 13:33:28 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Thu, 3 Apr 2008 10:33:28 -0700 (PDT) Subject: Get all strings matching given RegExp References: Message-ID: <44ec9a60-811f-4883-a741-3857ab811096@x41g2000hsb.googlegroups.com> On Apr 3, 4:50?am, Alex9968 wrote: > Can I get sequence of all strings that can match a given regular > expression? For example, for expression '(a|b)|(x|y)' it would be ['ax', > 'ay', 'bx', 'by'] > Actually, this regex will only match 'a', 'b', 'x', or 'y' (assuming you meant to bracket it with leading '^' and trailing '$'). To get the set you listed, you would need to invert '(a|b)(x|y)'. The thread that Gabriel Genellina referenced includes a link to a pyparsing regex inverter (http://pyparsing-public.wikispaces.com/space/ showimage/invRegex.py), which I used to test your regex - I've added both regexes in the test cases of that script. Some of the other test cases include regexes for all US time zones, and all chemical symbols. -- Paul From andre.roberge at gmail.com Tue Apr 8 21:25:20 2008 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Tue, 8 Apr 2008 18:25:20 -0700 (PDT) Subject: text adventure game problem References: Message-ID: On Apr 8, 10:01?pm, corvettecra... at gmail.com wrote: > okay, I'm having this one problem with a text adventure game. It's > kind of hard to explain, but I'll do my best. > [code] > > def prompt_kitchen(): > ? ? global gold > ? ? gold_taken = False > ? ? while True: > ? ? ? ? prompt_kit = raw_input('>') > ? ? ? ? if prompt_kit == 'examine cabinet 1' and not gold_taken: > ? ? ? ? ? ? print '''This cabinet has a lot of cups in it with all > different > designs and shapes. Where are the people anyway? How come there's > nobody here? > In one of the cups you find 8 gold.''' > ? ? ? ? ? ? gold = gold+8 > ? ? ? ? ? ? gold_taken = True > ? ? ? ? ? ? pass4() > ? ? ? ? elif prompt_kit == 'examine cabinet 1' and gold_taken: > ? ? ? ? ? ? print \ > ? ? ? ? ? ? ? ? ? '''This cabinet has a lot of cups in it with all > different > designs and shapes. Where are the people anyway? How come there's > nobody here?''' > ? ? ? ? ? ? pass4() > > def pass4(): > ? ? global gold > ? ? print 'You have', gold, 'gold' > ? ? pass > [/code] > > Okay, now for my problem. > In the above function, there's the option to examine a cabinet and get > 8 gold. (everyone here knows that...but I'm just trying to state my > problem...) > Unfortunately, it kind of doesn't work. > After the first time I 'examine cabinet 1' in my game, I get 8 gold > and I can't get it again. > But, If I leave the room and come back to it, then it's as if I had > never gotten the gold the first time, and I can get it again. > How do I fix this? quick guess: define gold_taken as a global variable and initialize it outside of the function. Warning: avoid global variables if at all possible. ;-) Andr? From mal at egenix.com Thu Apr 24 05:34:30 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Thu, 24 Apr 2008 11:34:30 +0200 Subject: @classmethod question In-Reply-To: References: Message-ID: <48105426.2070001@egenix.com> On 2008-04-24 05:27, Scott SA wrote: > Hi, > > I'm using the @classemethod decorator for some convenience methods and for some reason, either mental block or otherwise, can't seem to figure out how to elegantly detect if the call is from an instance or not. > > Here's the problem: Within the class definition, 'isinstance' has nothing to compare to because the class does not appear to exist. > > This is NOT a great example, but it outlines the the code: > > class RecipieClass: > def __init__(self): > pass > > @classmethod > def get_ingrendients(self, recipie_list=None): > > if isinstnace(self,RecipieClass): > return self.do_something_interesting() > else: > return do_something_boring(recipie_list) > > Yes, I can test to see if the param exists, but that makes the call exclusive i.e. I can _only_ call it as an instance or with a parameter. I would turn the above method into a regular instance method and then add a new function or static method which then returns the summary output. A class method is clearly wrong here, since those are meant to be called with the class as first argument, e.g. to count the number of instances created from a class. > Why am I doing this? > > It is a series of convenience methods, in this case I'm interacting with a database via an ORM (object-relational model). I want the ability to call a class-ojbect and get related values, or pass some criteria and get related values for them without collecting the records first as instances, then iterating them. I need to call this from several places so I want to be DRY (don't repeat yourself). > > The easiest way to describe this as an analogy would be like having a recipie for cookies and wanting to know all of the ingredients ahead of time. Then, at another time, wanting to know what all the ingredients would be to make cookies, cake and bread (i.e. complete shopping list). > > cookie_recipie = RecipieClass.get_recipie('cookies') > cookie_recipie.get_ingredients() > 2C Flour > 0.5 C Sugar > ... > > RecipieClass.get_ingrendients(['cookies','cake','bread']) > 8C Flour > 2C Sugar > ... > > Of course any suggestions on how this might be better approached would be interesting too. > > TIA, > > Scott > -- > http://mail.python.org/mailman/listinfo/python-list -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 24 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From bvidinli at gmail.com Thu Apr 10 05:01:13 2008 From: bvidinli at gmail.com (bvidinli) Date: Thu, 10 Apr 2008 12:01:13 +0300 Subject: Fwd: urgent question, about filesystem-files In-Reply-To: <36e8a7020804100200m6c3a9a41h1ed3021b70f8a829@mail.gmail.com> References: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> <47FDD27E.1040204@islandtraining.com> <36e8a7020804100200m6c3a9a41h1ed3021b70f8a829@mail.gmail.com> Message-ID: <36e8a7020804100201x5cf16377gfedddc8647fe8e3a@mail.gmail.com> Sory for lack of information, i use linux/unix i need to solve this for linux/unix i tested os.open with O_EXCL flag, and some other things, that did not solve. i need exacly: say example file testfile, check if testfile already open by some other process in linux, tahnks. 2008/4/10, Gary Herron : > bvidinli wrote: > > > i started python programming a few months ago. > > > > now i need the code to understand if a file already opened in > > filesystem by another process ? > > > > i looked at docs, howtos, but did not find related info. > > note that normal file open/write operations in python, i know it. > > > > i specificly need to know that "is a file already open by some other > > process other than python". > > > > > > Thank you in advance > > > > > > This is certainly an operating-system dependent bit of functionality. So > first off, you are going to have to tell us *which* OS you're working on. > Then, perhaps someone can help... > > Gary Herron > > -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From sturlamolden at yahoo.no Thu Apr 24 20:08:45 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 17:08:45 -0700 (PDT) Subject: Psyco alternative References: <1369b321-f55b-432b-b2f9-6144787509d8@h11g2000prf.googlegroups.com> <7xlk4473ai.fsf@ruckus.brouhaha.com> <651ncdF2cmik2U1@mid.uni-berlin.de> <651onqF2dripdU1@mid.uni-berlin.de> <47EBB42D.9090206@behnel.de> <25b14b32-8fce-4e79-b236-c64fa96744e8@e23g2000prf.googlegroups.com> Message-ID: On Mar 27, 5:01 pm, king kikapu wrote: > Hmmm...thanks but i think Pyrex-like solution is not the ideal one. > Coming from C# and having 8 years of expertise on it, i have gain a > very positive thinking about jit compilers and i think that psyco (ok, > a just-in-time specializer) is a more easy (and more correct) way to > go that mixing 2 languages. From no at spam.com Tue Apr 29 16:54:38 2008 From: no at spam.com (Grayham) Date: Tue, 29 Apr 2008 21:54:38 +0100 Subject: API's and hardware communication. Newbie References: <_MudnfZZ9uW0hY7VRVnyhwA@bt.com> Message-ID: It seems to me that python needs to be extended with C in some form to able to do what i need. I think instead of learning two languages i am going to put all my efforts in to learning C as it seems that's where i am going to end up. Thank you both for the feed back and links Regards Grayham From ocollioud at gmail.com Thu Apr 3 06:59:22 2008 From: ocollioud at gmail.com (olive) Date: Thu, 3 Apr 2008 03:59:22 -0700 (PDT) Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> <47f49d4b$0$5665$426a74cc@news.free.fr> Message-ID: On 3 avr, 10:32, sam wrote: > Bruno Desthuilliers napisa?(a): > > > Ok, I'm going to be a bit harsh, but this time I'll assume it. > > Sam, you started this thread by asking about prototype vs class based > > minor syntactic points that, whether you like them or not (and > > I think I will get back to this discussion after learning "descriptor protocol" > and maybe I will not talk about syntax then, and maybe it won't get off topic. may I recommend this http://www.cafepy.com/article/ (the first 2)? From mail2spj at yahoo.com Fri Apr 18 16:12:34 2008 From: mail2spj at yahoo.com (SPJ) Date: Fri, 18 Apr 2008 13:12:34 -0700 (PDT) Subject: Error with win32com client on windows 2003 server Message-ID: <576371.68812.qm@web50108.mail.re2.yahoo.com> Sorry, forgot to mention Subject in my earlier post, hence reposting. ------------ I am writing a script which need's to convert an excel file to csv (text) format. For that I am using the following code: excel = win32com.client.Dispatch("Excel.Application","Quit") workbook = excel.Workbooks.Open(xlsfile) workbook.SaveAs(csvfile, FileFormat=24) # 24 represents xlCSVMSDOS workbook.Close(False) excel.Quit() I did not have any problem running this script on a windows xp machine with python 2.5.2 and windows extensions. But I get the following error when I run the same script on a windows 2003 server with the same python and windows extension installation: excel = win32com.client.Dispatch("Excel.Application","Quit") File "D:\Python25\Lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "D:\Python25\lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "D:\Python25\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147221005, 'Invalid class string', None, None) I verified that installation is same. Any idea's as to what might be the problem? One thing I have noticed though is I can't see Microsoft office 11.0 object library when I do combrowse on windows 2003 server. I also to tried to reinstall python and windows extension. But still no luck. I would appreciate if anyone can guide me as to why this is happening and how to resolve this. Thanks, SPJ ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ From jgardner at jonathangardner.net Thu Apr 17 03:37:47 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Thu, 17 Apr 2008 00:37:47 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> On Apr 16, 5:37?pm, sturlamolden wrote: > One single process of CPython is using all the cpu power > of my dual-core laptop. Are they stuck in a while loop, waiting for their resource to become available? Using 100% of the CPU is a bug, not a feature. If you can't rewrite your algorithm to be disk or network bound, next optimization step is C. From balta96428 at gmail.com Wed Apr 23 05:54:11 2008 From: balta96428 at gmail.com (balta96428 at gmail.com) Date: Wed, 23 Apr 2008 02:54:11 -0700 (PDT) Subject: firecad crack Message-ID: <44deb87e-9a76-4ac1-a07e-4cbb952da004@e39g2000hsf.googlegroups.com> firecad crack http://cracks.12w.net F R E E C R A C K S From martin at v.loewis.de Sun Apr 20 14:51:07 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 20 Apr 2008 20:51:07 +0200 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B80B5.1050500@cheimes.de> Message-ID: <480b909c$0$20038$9b622d9e@news.freenet.de> > In order to deal with 400 thousands texts consisting of 80 million > words, and huge sets of corpora , I have to be care about the memory > things. I need to track every word's behavior, so there needs to be as > many word-objects as words. > I am really suffering from the memory problem, even 4G memory space can > not survive... Only 10,000 texts can kill it in 2 minutes. > By the way, my program has been optimized to ``del`` the objects after > traversing, in order not to store the information in memory all the time. It may then well be that your application leaks memory, however, the examples that you have given so far don't demonstrate that. Most likely, you still keep references to objects at some point, causing the leak. It's fairly difficult to determine the source of such a problem. As a starting point, I recommend to do print len(gc.get_objects()) several times in the program, to see how the number of (gc-managed) objects increases. This number should continually grow up, or else you don't have a memory leak (or one in a C module which would be even harder to determine). Then, from time to time, call import gc from collections import defaultdict def classify(): counters = defaultdict(lambda:0) for o in gc.get_objects(): counters[type(o)] += 1 counters = [(freq, t) for t,freq in counters.items()] counters.sort() for freq,t in counters[-10:]: print t.__name__, freq a number of times, and see what kind of objects get allocated. Then, for the most frequent kind of object, investigate whether any of them "should" have been deleted. If any, try to find out a) whether the code that should have released them was executed, and b) why they are still referenced (use gc.get_referrers for that). And so on. Regards, Martin From tinnews at isbd.co.uk Thu Apr 10 04:24:24 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 10 Apr 2008 08:24:24 GMT Subject: How to find documentation about methods etc. for iterators References: <47fce941$0$755$bed64819@news.gradwell.net> Message-ID: <47fdceb8$0$754$bed64819@news.gradwell.net> Terry Reedy wrote: > > wrote in message > news:47fce941$0$755$bed64819 at news.gradwell.net... > | I'm not sure if I have even phrased that right but anyway.... > | > | How does one find (in the standard Python documentation) information > | about things like the iteritems() method and the enumerate() function. > > The Library Reference manual sections on builtin functions and dict > methods. > > Or, help(enumerate) and help({}.iteritems) > .... but that doesn't address my problem really, how do I know that I need to look for the words enumerate and/or iteritems? This is what my original question was about. There I was thinking that there has to be an easy way to get line numbers as I read lines from a file but not knowing how to find out how to do it:- First question, what sort of 'thing' is the file object, I need to know that if I'm to look up ways of using it. Second question, even if I know what sort of thing a file object is, how do I find methods applicable to it and/or functions applicable to it? The possibility that I might want either a method or a function adds to the fun. In my original query it seemed odd that some objects have the iteritems *method* whereas other objects have the enumerate *function*. It's a common problem in all sorts of computer fields, if you know the name of what you want it's easy to find out details of how to use it but if you don't know its name (or even if it exists) it's much more difficult to find. I've only been using Python for a few months and most of the time I can find my way to what I need but this area of "what things can I do with this object" still eludes me sometimes. What *I* need (I'm not sure if this is a universal requirement though) is some consistent way of firstly finding out what sort of an object something is (i.e. in this case, what sort of object is a file) and then getting a list of methods that I can apply to that object (O.K., this may need some hierachy or other classification to keep it sane, but hopefully you can see where I'm going). -- Chris Green From gagsl-py2 at yahoo.com.ar Sun Apr 13 15:37:20 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 13 Apr 2008 16:37:20 -0300 Subject: toplevel, get latest entry? References: Message-ID: En Sat, 12 Apr 2008 17:50:36 -0300, escribi?: > windows vista and python 2.5, is there a way to get the latest command > entered? would be very useful. > > if not by default, anything i could download or write myself? Do you mean inside the interpreter? Use up arrow/down arrow. Type a few characters and press F8 to search for matches. F7 to select from a list. Courtesy of doskey. -- Gabriel Genellina From claird at lairds.us Mon Apr 7 14:47:27 2008 From: claird at lairds.us (Cameron Laird) Date: Mon, 7 Apr 2008 18:47:27 +0000 Subject: Mathematical Python Library References: Message-ID: In article , Dennis Lee Bieber wrote: >On Mon, 7 Apr 2008 09:05:57 -0700 (PDT), mc >declaimed the following in comp.lang.python: > >> I'm looking for a library which can do mathematical stuff like >> solving equations. Or calculation the nulls of a function and so on. >> Does anyone know one? >> > Other than coding some serial/USB interface to an HP50g... > > Maybe SAGE? > sympy? > >http://www.google.com/search?hl=en&q=python+computer+algebra+system&btnG=Google+Search . . . While there are in fact several possible approaches to symbolic mani- pulation of "mathematical stuff" in Python, I STRONGLY recommend that beginners in the area look into SAGE , already mentioned above by Dennis. SAGE is life-altering software, for those with a life focused on mathematics or related science or engineering. From blog534 at watchesblog.cn Fri Apr 25 10:10:00 2008 From: blog534 at watchesblog.cn (blog534 at watchesblog.cn) Date: Fri, 25 Apr 2008 07:10:00 -0700 (PDT) Subject: Brand Watches Seiko Men's Premier Alarm Chronograph Watch # SNA209P1 Discount, Swiss, Fake Message-ID: <6f0299c8-98fd-491b-97ce-51c5afe30329@w5g2000prd.googlegroups.com> Brand Watches Seiko Men's Premier Alarm Chronograph Watch # SNA209P1 Discount, Swiss, Fake Browse our Seiko Men's Premier Alarm Chronograph Watch # SNA209P1 Swiss watches, which is sure the watch you are looking for at low price. There are more high quality designer watch Swiss for selection Seiko Men's Premier Alarm Chronograph Watch # SNA209P1 Link : http://www.watches-brand.com/Seiko-wristwatch-7566.html Brand : Seiko ( http://www.watches-brand.com/Seiko-Watches.html ) Model : Seiko Men's Premier Alarm Chronograph Watch # SNA209P1 Description :

Seiko Men's Premier Alarm Chronograph Watch . 100 meters water resistant. LumiBrite Hands & Markers. Curved Sapphire Crystal. Alarm hands can indicate the time in a different time zone. Chronograph can measure up to 60 minutes in 1/5 seconds. Alarm can be set on a 12-hour basis with two small hands. Hour, minute and small second hands. White dial. # SNA209 #.

Sale Price : $ 229.00 Seiko Men's Premier Alarm Chronograph Watch # SNA209P1 Details :
  • Watches-Price Sales Rank: #61722 in Watches
  • Brand: Seiko
  • Model: SNA209
  • Band material: stainless-steel
  • Case material: stainless-steel
  • Dial color: White
  • Movement type: Quartz
  • Water-resistant to 100 meters
Seiko Men's Premier Alarm Chronograph Watch # SNA209P1 is new brand Swiss, join thousands of satisfied customers and buy your Seiko with total satisfaction. A watches-brand.COM 30 Day Money Back Guarantee is included with every Seiko Fake Series for secure, risk-free online shopping. watches-brand.COM does not charge sales tax for the Fake Seiko Men's Premier Alarm Chronograph Watch # SNA209P1. All of our Fake watches are shipped via EMS to worldwide. Normally it takes 3days to prepare the fake watch you ordered and 5-10days to transmit depending on the different destination.We pay for the free shipping cost for total quantity over 20 pcs. The EMS tracking NO. will be sent by email when an order is shipped from our warehouse. No more other charges from watches-brand.com such as the tax. If you have any other questions please check our other pages or feel free to email us by sales at watches-brand.com. The Same Fake Seiko Watches Series : Seiko Men's Premier Automatic (Made in Japan) Watch # SPB003J1 : http://www.watches-brand.com/Seiko-wristwatch-7567.html Seiko Men's Premier Automatic (Made in Japan) Watch # SPB005J1 : http://www.watches-brand.com/Seiko-wristwatch-7568.html Seiko Men's Premier Automatic All Stainless-Steel Watch with a Black Dial. Model: SPB001J : http://www.watches-brand.com/Seiko-wristwatch-7569.html Seiko Men's Premier Chronograph Watch SDWG45 : http://www.watches-brand.com/Seiko-wristwatch-7570.html Seiko Men's Premier Chronograph Watch SDWG47 : http://www.watches-brand.com/Seiko-wristwatch-7571.html Seiko Men's Premier Kinetic Auto Relay Watch with Blue Dial. Model: SNG037 : http://www.watches-brand.com/Seiko-wristwatch-7572.html Seiko Men's Premier Kinetic Direct Drive Quartz- Kinetic 100M Water Resistant Watch # SRG001P1 : http://www.watches-brand.com/Seiko-wristwatch-7573.html Seiko Men's Premier Kinetic Direct Drive Quartz- Kinetic 100M Water Resistant Watch # SRG001P2 : http://www.watches-brand.com/Seiko-wristwatch-7574.html Seiko Men's Premier Kinetic Perpetual Calendar Black Dial Watch # SNP005P1 : http://www.watches-brand.com/Seiko-wristwatch-7575.html Seiko Men's Premier Kinetic Perpetual Calendar Silver Dial with Seiko Original Leather Strap Watch # SNP015P1 : http://www.watches-brand.com/Seiko-wristwatch-7576.html Brand Watches Seiko Men's Premier Alarm Chronograph Watch # SNA209P1 Discount, Swiss, Fake From colas.francis at gmail.com Thu Apr 17 12:35:10 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Thu, 17 Apr 2008 09:35:10 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> Message-ID: <3a0c68fb-6cea-455a-92f4-2ded30a79528@a23g2000hsc.googlegroups.com> On 17 avr, 18:19, s0s... at gmail.com wrote: > On Apr 17, 10:54 am, colas.fran... at gmail.com wrote: > > > On 17 avr, 17:40, s0s... at gmail.com wrote: > > > Out of sheer curiosity, why do you need thirty (hand-specified and > > dutifully commented) names to the same constant object if you know > > there will always be only one object? > > I'm building a web server. The many variables are names of header > fields. One part of the code looks like this (or at least I'd like it > to): > > class RequestHeadersManager: > > # General header fields > Cache_Control = \ > Connection = \ > Date = \ > Pragma = \ > Trailer = \ > Transfer_Encoding = \ > Upgrade = \ > Via = \ > Warning = \ > > # Request header fields > Accept = \ > Accept_Charset = \ > Accept_Encoding = \ > Accept_Language = \ > Authorization = \ > ... > > Etc etc etc. At the end they'll all be assign to None. Then, when > initialized, __init__() will the the string of headers, parse them, > and use those variables shown above to assign to the header values. Of > course a normal request won't include all of those headers, so the > others will remain None. That's what I want. Ah, so they are not constant, I was mislead by the name 'CONSTANTn' in your OP. But why would you insist on: """ # helpful comment CONSTANT1 = \ # there too CONSTANT2 = \ CONSTANT3 = \ None """ rather than: """ # helpful comment CONSTANT1 = None # there too CONSTANT2 = None CONSTANT3 = None """ or even: """ CONSTANT = None # helpful comment CONSTANT1 = CONSTANT # there too CONSTANT2 = CONSTANT CONSTANT3 = CONSTANT """ (hopefully you don't consider those names in your code. ^ ^) From andrew at acooke.org Sat Apr 19 10:34:40 2008 From: andrew at acooke.org (andrew cooke) Date: Sat, 19 Apr 2008 07:34:40 -0700 (PDT) Subject: Metaprogramming Example References: <930643c6-2d56-4fb0-aee0-a3e79231f09b@24g2000hsh.googlegroups.com> <32472b97-f35a-4408-96f5-2f8c8f92ae56@m73g2000hsh.googlegroups.com> <39325652-e0cf-4efd-9b28-00c0fe8552cc@m73g2000hsh.googlegroups.com> <562bae18-7b8e-4863-8923-0e5a01ba7125@t54g2000hsg.googlegroups.com> <48086036$0$759$426a74cc@news.free.fr> Message-ID: On Apr 18, 4:48 am, Bruno Desthuilliers wrote: [...] > Practically, this means that (amongst other niceties) : > - you can define functions outside classes and use them as instance or > class methods > - you can add/replaces methods dynamically on a per-class or > per-instance basis > - you can access the function object of a method and use it as a function > - you can define your own callable types, that - if you implement the > appropriate support for the descriptor protocol - will be usable as > methods too ok, that's convincing (i had thought the majority of these were already possible, albeit with some kind of hard-coded "magic" behind the scenes). [...] > > by referring to the titanic > > i didn't mean that python was a disaster, rather that the "iceberg" is > > still there (i am not 100% sure what the iceberg is, but it's > > something > > to do with making namespaces explicit in some places and not others). > > I guess you're thinking of the self argument, declared in the function's > signature but not "explicitly passed" when calling the method ? not really. more to do with when namespaces (i am not sure i have the right term - the dictionary that provides the mapping from name to object) are explicit or implicit. for example, python has closures (implicit lookup) and "self" (explicit lookup). but as i said, i don't have a clear argument - something just feels "odd". at the same time, i know that language design is a practical business and so this is probably not important. finally, thank you for pointing me to sql alchemy (i think it was you?). it really is excellent. andrew From kyosohma at gmail.com Fri Apr 11 15:54:22 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 11 Apr 2008 12:54:22 -0700 (PDT) Subject: Windows - window status (Running vs Not Responding) References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> Message-ID: <5f4a5d63-c862-4d25-8849-6a36dd4e138d@m3g2000hsc.googlegroups.com> On Apr 11, 2:10 pm, rdahlstrom wrote: > On Apr 11, 1:45 pm, rdahlstrom wrote: > > > Does anyone know how to determine the window status (Running or Not > > Responding)? I've tried various methods with no success... > > > This would be on a variety of Windows systems, but all at least XP, > > and mostly server 2003. Everyone will have Python 2.5.1 on them, and > > the script would be running locally. > > > Any ideas? > > Basically, I'm looking for something similar to the Process.Responding > property in System.Diagnostics... Hmmm...I think you should re-post to the Python win32 group. They'll know the answer, if there is one. Here's the link to get signed up: http://mail.python.org/mailman/listinfo/python-win32 Also, you might take a look at the WMI module: http://tgolden.sc.sabren.com/python/wmi.html I'm pretty sure it can do that, but I don't know how. I did find an article on it: http://www.informit.com/articles/article.aspx?p=19489&seqNum=4 If you're better than I am, you can probably translate this to the Python equivalent. Zenoss also has some monitoring software that's open source Python code. Mike From ladynikon at gmail.com Wed Apr 9 08:51:38 2008 From: ladynikon at gmail.com (Danyelle Gragsone) Date: Wed, 9 Apr 2008 08:51:38 -0400 Subject: Very good Python Book. Free download : Beginning Python: From Novice to Professional In-Reply-To: References: Message-ID: <59f9c5160804090551p6132c027vb04ef2123c857e24@mail.gmail.com> HEH From paul.anton.letnes at gmail.com Tue Apr 15 15:58:42 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Tue, 15 Apr 2008 21:58:42 +0200 Subject: Java or C++? In-Reply-To: <95983d3d-d751-4472-af3c-5e1b74fd538f@n14g2000pri.googlegroups.com> References: <480424FC.5040802@aim.com> <95983d3d-d751-4472-af3c-5e1b74fd538f@n14g2000pri.googlegroups.com> Message-ID: Well, if you're new - first find the function, then how to use it, this funny %d5 (or something, don't remember) syntax - it's hard compared to: cout << 5 or similar stream tricks, or just 5 + "" in Java, or just str(5) in Python. Anyway, small tasks are very hard for C newbies. Den 15. april. 2008 kl. 19.35 skrev lbonafide at yahoo.com: > On Apr 15, 3:07 am, Paul Anton Letnes > wrote: > > >> but C bogs you down with administrative stuff (try converting an int >> to a string; I found myself googling for an hour!). > > It took an hour to find sprintf()? > -- > http://mail.python.org/mailman/listinfo/python-list From martin at v.loewis.de Sat Apr 5 17:45:29 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sat, 05 Apr 2008 23:45:29 +0200 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> Message-ID: <47f7f2f9$0$10630$9b622d9e@news.freenet.de> > There must be a rule behind this. There are multiple rules behind this. Python normally uses the same extension for shared libraries as the operating system, as the operating system may refuse to load them if it doesn't. So it *can't* use .pyd on Unix, because that might not work (on some implementations of Unix). It can't use .dll on Windows, because that may (and did) conflict with existing DLLs, hence it uses .pyd. Depending on the system, an extension module may have one of these suffixes: - .so - module.so - .sl - module.sl - .exe - .EXE - module.exe - module.EXE - .pyd - _d.pyd Regards, Martin From Hook at somewhere.nowhere.co.au.it Sat Apr 19 02:37:33 2008 From: Hook at somewhere.nowhere.co.au.it (Hook) Date: 19 Apr 2008 06:37:33 GMT Subject: Inheritance confusion Message-ID: <4809932c$0$12307$c3e8da3@news.astraweb.com> Hi, I'm having a problem with multiple inheritance - it's clearly something I've missed, but the web pages and books that I've consulted aren't helping, so I'll throw myself on the mercy and collective wisdom of Usenet! I've got 4 files (what I'll show has the active content removed for brevity): Errors_m.py ~~~~~~~~~~~ class Errors (object) : def __init__ (self, params) : pass def Error (self, string) : return 100 DT_m.py ~~~~~~~ class DT (object) : def __init__ (self, params) : pass def Date (self, epoch, pattern = 'd mmm yyyy') : dt = datetime.datetime.fromtimestamp (epoch) Hook_m.py ~~~~~~~~~ from DT_m import DT from Error_m import Errors class Hook (Errors, DT) : def __init__ (self, params) : DT.__init__ (self, params) Errors.__init__ (self, params) DB_m.py ~~~~~~~ from Hook_m import Hook class DB (Hook) : def __init__ (self, params) : Hook.__init__ (self, params) And a test script: #!/usr/bin/python import os import re import string import sys from DB_m import DB Dict = dict () Dict ['logdir'] = '/tmp/log' Dict ['diag'] = 1 Obj = DB (Dict) print dir (Obj) Obj.Connect ('Database') When I run the script I get this: Traceback (most recent call last): File "./3.py", line 20, in Obj.Connect ('Database') File "/mnt/isis/Projects/Python/Learning/DB_m.py", line 102, in Connect self.TRACE ("DB::Connect (" + database + "," + mode) File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 314, in TRACE self.DailyLog (msg) File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 98, in DailyLog dt = self.Date (time ()) TypeError: 'module' object is not callable Googling the "TypeError" message suggests that I've got a module and class with the same name, but I can't see that I have. Can someone point me in the right direction please? If you need to see all the source, can do, but it's certainly too much for an intro message! Thanks, Hook From carlwuhwdmckay at gmail.com Sat Apr 26 09:33:45 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:33:45 -0700 (PDT) Subject: keygen fifa 08 Message-ID: <3728b524-26cc-4628-9871-c04b94392f46@d1g2000hsg.googlegroups.com> keygen fifa 08 http://cracks.00bp.com F R E E C R A C K S From coleb2 at gmail.com Wed Apr 9 16:55:43 2008 From: coleb2 at gmail.com (Brian Cole) Date: Wed, 9 Apr 2008 14:55:43 -0600 Subject: wrapping C functions in python In-Reply-To: References: <54b165660804091322w690e5e64x85c3d8f082b411b2@mail.gmail.com> Message-ID: <54b165660804091355m1326f7c0g1a5eebe3d6b5a1df@mail.gmail.com> SWIG is a program that automatically generates code to interface Python (and many other languages) with C/C++. If you plan to create lasting software libraries to be accessed from Python and C it is quite a robust way to do so. Essentially, you feed it header files, compile your code and the code generated by swig as a shared library, then import the functions like you would a normal python module. If all you need is to make some numerical code run faster it may be more of a learning curve then you bargain for. Perhaps trying NumPy is more appropriate. http://numpy.scipy.org/ -Brian On Wed, Apr 9, 2008 at 2:44 PM, Paul Anton Letnes wrote: > Hi, and thanks. > > > However, being a newbie, I now have to ask: What is SWIG? I have heard the > name before, but haven't understood what it is, why I need it, or similar. > Could you please supply some hints? > > > -Paul > > > Den 9. april. 2008 kl. 22.22 skrev Brian Cole: > > > > > > > > > > We use the following SWIG (www.swig.org) typemap to perform such > operations: > > > > %typemap(in) (int argc, char **argv) { > > if (!PySequence_Check($input)) { > > PyErr_SetString(PyExc_ValueError,"Expected a sequence"); > > return NULL; > > } > > $1 = PySequence_Length($input); > > $2 = (char**)alloca($1*sizeof(char*)); > > for (Py_ssize_t i = 0; i < $1; ++i) { > > PyObject *o = PySequence_GetItem($input, i); > > $2[i] = PyString_AsString(o); > > } > > } > > > > That one works for mapping a python sequence (such as a list) into the > > argc, argv arguments commonly passed into main. > > > > -Brian > > > > On Wed, Apr 9, 2008 at 2:13 PM, Paul Anton Letnes > > wrote: > > > > > Hello etc. > > > > > > > > > I am a "scientific" user of Python, and hence have to write some > performance > > > critical algorithms. Right now, I am learning Python, so this is a > "newbie" > > > question. > > > > > > I would like to wrap some heavy C functions inside Python, specifically > a > > > wavelet transform. I am beginning to become aquainted with the functions > > > PyArg_ParseTuple() and Py_BuildValue(). However, I am unable to figure > out > > > how to pass Python list -> C function or C array -> return value in > Python. > > > I manage to build and run the C function, print to screen, pass string > as > > > argument, return an int, etc. The thing which is missing is the magic > > > array/list... > > > > > > > > > Thanks in advance! I fart in your general direction. > > > Paul. > > > -- > > > http://mail.python.org/mailman/listinfo/python-list > > > > > > > > -- > > > > http://mail.python.org/mailman/listinfo/python-list > > > > From tjreedy at udel.edu Tue Apr 15 17:35:19 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 15 Apr 2008 17:35:19 -0400 Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> Message-ID: "Sverker Nilsson" wrote in message news:eda75e1a-904e-4916-9489-934cb679a516 at m44g2000hsc.googlegroups.com... | What serious reports? http://wiki.python.org/moin/Early2to3Migrations From ellingt8877 at gmail.com Mon Apr 28 01:50:08 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:50:08 -0700 (PDT) Subject: diskeeper 2007 crack Message-ID: diskeeper 2007 crack http://crack.cracksofts.com From fredrik at pythonware.com Sat Apr 5 04:48:11 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 10:48:11 +0200 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> Message-ID: llothar wrote: > My question was: Why does setup.py generated sometimes a pyd and > sometimes a so file? setup.py picks an extension that happens to work on the platform you're running setup.py on. doing otherwise would be pretty pointless. From steve at holdenweb.com Thu Apr 10 19:06:46 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 10 Apr 2008 19:06:46 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> <47FCF421.6000807@holdenweb.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> Message-ID: Victor Subervi wrote: > Well, what I did was this: > > content = col_fields[0][14].tostring() > pic = "tmp" + str(i) + ".jpg" > img = open(pic, "w") > img.write(content) > print '

' % pic > img.close() > where I am incrementing i. Ugly. Stupid. But if it is the only way to do > it in python, and I do not want to invest the time doing it in php, > which I think would be prettier in this instance, then I guess it will > do. Your thoughts appreciated. > Victor > It is not the only way to do it on Python, it's not even an especially good way. But I suggest you either read what I have already written more carefully, or study HTTP and HTML until you understand what you are doing unnecessarily wrong. There is absolutely no need to save the images to the file store (otherwise there would be no point in having them in the database in the first place). You simply need to understand how to serve them dynamically. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From darcy at druid.net Tue Apr 29 15:31:08 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Tue, 29 Apr 2008 15:31:08 -0400 Subject: Colors for Rows In-Reply-To: <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> <20080429121105.f10c3862.darcy@druid.net> <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> Message-ID: <20080429153108.87bf8db8.darcy@druid.net> On Tue, 29 Apr 2008 13:14:34 -0500 "Victor Subervi" wrote: > On Tue, Apr 29, 2008 at 11:11 AM, D'Arcy J.M. Cain wrote: > > > for d in (1,2,3,4,5,6): > > > > I changed id to a sequence so that the example actually runs. Please > > run your examples first and cut and paste them into the message after > > you are sure that it runs. > > Not sure what you mean here. The example runs. It prints out bgcolor="#ffffff"> every time. No it doesn't. Perhaps you had something that worked but you did not include a definition of "id" in your code so it crashed right away. > > print '' % bg, d > > Huh? You?re asking for one variable, then giving two! How?s that work? No, I am asking print to display two items. The first is "'' % bg" and the second, following the comma, is "d" which I simply added to show what iteration we were on. I assume that you would be printing some data from "id" in the real code and wrapping it in tags. > I think you understand. I want the row color to alternate, every fourth row > color being the same (or a series of 4) Here is the output of the program I posted: 1 2 3 4 5 6 BTW, I am running Python 2.4.4. You? > > print '' % bg[z % 4], d > > I tried that just for fun. It gave a bg of ?f?. Again, how are you > incorporating d? Here is the complete script with the exact same output as above: #! /usr/bin/env python z = 3 bg = ('#ffffff', '#d2d2d2', '#F6E5DF', '#EAF8D5') for d in (1,2,3,4,5,6): z += 1 print '' % bg[z % 4], d -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From skanemupp at yahoo.se Mon Apr 14 07:28:43 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Mon, 14 Apr 2008 04:28:43 -0700 (PDT) Subject: Game design : Making computer play References: Message-ID: On 14 Apr, 09:13, v4vijayakumar wrote: > In computer based, two player, board games, how to make computer play? > Are there any formal ways to _teach_ computer, to choose best possible > move? > > I know this is kind of off-topic here. Please redirect me, if there > are more appropriate newsgroup. > > Many thanks. can you post a link to the game so I can see the rules and how the board looks. /hopefully going to india soon From tjreedy at udel.edu Sun Apr 13 02:22:03 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 13 Apr 2008 02:22:03 -0400 Subject: Where is the function of 'apply' always used? References: <84cefd1a-58de-485b-b00b-77218d2d054c@c19g2000prf.googlegroups.com> Message-ID: "???" wrote in message news:84cefd1a-58de-485b-b00b-77218d2d054c at c19g2000prf.googlegroups.com... | I'am a beginner of Python.In the course of reading the Python book,I | found the function:apply;But | I don't understand its use.Help! Apply has been deprecated. It has been replaced by the use of *args in function calls. It is only still present for old code and will disappear in 3.0. So you do not need it and should ignore it for now. From deets at nospam.web.de Thu Apr 10 03:51:57 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 10 Apr 2008 09:51:57 +0200 Subject: wrapping C functions in python In-Reply-To: References: <54b165660804091322w690e5e64x85c3d8f082b411b2@mail.gmail.com> <54b165660804091355m1326f7c0g1a5eebe3d6b5a1df@mail.gmail.com> Message-ID: <665v97F2ifd5rU1@mid.uni-berlin.de> Paul Anton Letnes schrieb: > Brian and Diez: > > First of all, thanks for the advice. > > Brian: > > I have installed NumPy and SciPy, but I can't seem to find a wavelet > transform there. > > The main point of this was more to learn C wrapping than to actually get > a calculation done. I will probably be starting a PhD soon, doing really > heavy computations. If I want to manipulate data (input / results), > python is very nice, especially with gnuplot-py. However, heavy > calculations should probably be done in C(++), especially as some code > for this already exists. > > I will look into SWIG. > > > Diez: > > I will look into it. Do you know a good tutorial for this? I found the > "standard" tutorial on C extensions, > http://www.python.org/doc/ext/intro.html , but as I mentioned, it seems > to be a bit complicated to wrap heavy data structures like arrays. ctypes is documented as part of the python 2.5 standard lib documentation. And google helps as always. diez From urquhart.nak at gmail.com Wed Apr 30 06:29:12 2008 From: urquhart.nak at gmail.com (urquhart.nak at gmail.com) Date: Wed, 30 Apr 2008 03:29:12 -0700 (PDT) Subject: crack the sims 2 hm stuff Message-ID: crack the sims 2 hm stuff http://crack.cracksofts.com From wlindley at ups.edu Thu Apr 17 18:14:24 2008 From: wlindley at ups.edu (Walker Lindley) Date: Thu, 17 Apr 2008 15:14:24 -0700 Subject: pyexpat.so not importing Message-ID: <9c8d48280804171514l66a42ea0w710d070e11dc07d2@mail.gmail.com> Hopefully this is a relatively common problem. I'm working on a web service using ZSI running on Apache. The client generates a request just fine, but when the server tries to parse it, it fails while importing pyexpat.so. Specifically what's happening (after I traced the call stack down) is that xml.parsers.expat is being imported and that module consists of a single line: from pyexpat import * And that line is failing. Since it's running from within Apache, I don't get a full error message, but I print a message to Apache's error log before and after that line executes. The message before it prints and the message after it does not. So something's going wrong during that import, but since it's a compiled file, I don't really know what. Is there a way to get better information about what's going wrong? Has someone else had this problem and fixed it? Thanks, Walker -------------- next part -------------- An HTML attachment was scrubbed... URL: From needin4mation at gmail.com Wed Apr 9 16:51:22 2008 From: needin4mation at gmail.com (jmDesktop) Date: Wed, 9 Apr 2008 13:51:22 -0700 (PDT) Subject: basic python question about for loop Message-ID: >From the Python.org tutorial: >>> for n in range(2, 10): ... for x in range(2, n): ... if n % x == 0: ... print n, 'equals', x, '*', n/x ... break ... else: ... # loop fell through without finding a factor ... print n, 'is a prime number' ... 2 is a prime number 3 is a prime number 4 equals 2 * 2 5 is a prime number 6 equals 2 * 3 7 is a prime number 8 equals 2 * 4 9 equals 3 * 3 first time 2 mod 2, 2/2, no remainder == 0, what am I doing wrong? Why did it fall through? http://www.python.org/doc/current/tut/node6.html#SECTION006300000000000000000 Thanks. From arnodel at googlemail.com Sat Apr 12 16:18:57 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sat, 12 Apr 2008 13:18:57 -0700 (PDT) Subject: class level properties References: Message-ID: On Apr 12, 8:36?pm, Charles D Hixson wrote: > I'm trying to construct read-only variables at the class level. ?I've > been unsuccessful. ?Any suggestions? > > Mixing @classmethod and @property doesn't appear to produce workable > code. ?Ditto for mixing @classmethod and __getattr__. ?(The property > approach compiles, but execution says that you can't execute properties.) > > I've got a rather large number of variables, so I don't want to define > function accessors for each of them, and I *REALLY* don't want to have > to access them as functions rather than variables or properties. Metaclasses, of course! >>> class MetaX(type): ... @property ... def spam(self): return 'eggs' ... >>> class X(object): ... __metaclass__ = MetaX ... >>> X.spam 'eggs' >>> HTH -- Arnaud From jason.scheirer at gmail.com Tue Apr 1 16:40:34 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Tue, 1 Apr 2008 13:40:34 -0700 (PDT) Subject: XML Parsing References: Message-ID: <57834854-6622-476c-915e-d5563487f0c6@c19g2000prf.googlegroups.com> On Apr 1, 12:42 pm, Alok Kothari wrote: > Hello, > I am new to XML parsing.Could you kindly tell me whats the > problem with the following code: > > import xml.dom.minidom > import xml.parsers.expat > document = """Lettermanis token>betterthan token>JayLeno""" > > # 3 handler functions > def start_element(name, attrs): > print 'Start element:', name, attrs > def end_element(name): > print 'End element:', name > def char_data(data): > print 'Character data:', repr(data) > > p = xml.parsers.expat.ParserCreate() > > p.StartElementHandler = start_element > p.EndElementHandler = end_element > p.CharacterDataHandler = char_data > p.Parse(document, 1) > > OUTPUT: > > Start element: token {u'pos': u'nn'} > Character data: u'Letterman' > End element: token > > Traceback (most recent call last): > File "C:/Python25/Programs/eg.py", line 20, in > p.Parse(document, 1) > ExpatError: junk after document element: line 1, column 33 Your XML is wrong. Don't put line breaks between . From Dominique.Holzwarth at ch.delarue.com Wed Apr 23 08:20:16 2008 From: Dominique.Holzwarth at ch.delarue.com (Dominique.Holzwarth at ch.delarue.com) Date: Wed, 23 Apr 2008 13:20:16 +0100 Subject: Subprocess module Message-ID: <5213E58D85BC414998FA553C701E386C0EDD125B52@SGBD012511.dlrmail.ad.delarue.com> Hello all I want to convert a tex file into a pdf by using pdflatex. For that, I thought the 'subprocess' module might be a good option. My code doesn't work at all tho: Import os, subprocess def main(): scriptpath = os.path.dirname(__file__) p = subprocess.Popen("pdflatex --include-directory=%s --output-directory=%s/output --aux-directory=%s/temp --interaction=nonstopmode myFile.tex" % (scriptpath, scriptpath, scriptpath), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, cwd=scriptpath) (child_stdin, child_stdout, child_stderr) = (p.stdin, p.stdout, p.stderr) print 'stdin' print child_stdin print 'stdout' print child_stdout print 'stderr' print child_stderr When I run that code I get the following printouts: stdin ', mode 'wb' at 0x009E7968> stdout ', mode 'rb' at 0x009E7A40> stderr ', mode 'rb' at 0x009E79F8> Done The pdf file however is not created, nor are there any tex-temporary files (like *.log or *.aux) created. If I include a 'p.wait()' I see the python.exe and the pdflatex.exe processes are running, but I have it to terminate them manually (they never finish). My system is winXP btw. Does anyone have an idea what could be wrong? The reason why I want to use the Popen class is because it has the wait() function, so I can wait for the childprocess (pdflatex) to terminate before I start it again (because you need to run pdflatex several times to get all the references/index things correct in the generated pdf). Thanks for help, Dominique From ivan.illarionov at gmail.com Mon Apr 21 16:10:26 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Mon, 21 Apr 2008 13:10:26 -0700 (PDT) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> Message-ID: <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> On 20 ???, 04:10, George Sakkis wrote: > On Apr 18, 9:36 pm, Ross Ridge > wrote: > > > > > Ross Ridge said: > > > > If you have Python 2.5, here's a faster version: > > > > from struct import * > > > unpack_i32be = Struct(">l").unpack > > > > def from3Bytes_ross2(s): > > > return unpack_i32be(s + "\0")[0] >> 8 > > > Bob Greschke wrote: > > > > That's not even intelligible. I wanna go back to COBOL. :) > > > It's the same as the previous version except that it "precompiles" > > the struct.unpack() format string. It works similar to the way Python > > handles regular expressions. > > I didn't know about the Struct class; pretty neat. It's amazing that > this version without Psyco is as fast Bob's version with Psyco! Adding > Psyco to it though makes it *slower*, not faster. So here's how I'd > write it (if I wanted or had to stay in pure Python): > > try: import psyco > except ImportError: > from struct import Struct > unpack_i32be = Struct(">l").unpack > def from3Bytes(s): > return unpack_i32be(s + "\0")[0] >> 8 > else: > def from3Bytes(s): > Value = (ord(s[0])<<16) + (ord(s[1])<<8) + ord(s[2]) > if Value >= 0x800000: > Value -= 0x1000000 > return Value > psyco.bind(from3Bytes) > > HTH, > George I was able to get even faster pure-python version using array module: a = array.array('l', ''.join(('\0' + s[i:i+3] for i in xrange(0, len(s), 3)))) if sys.byteorder == 'little': a.byteswap() It actually moves bytes around on C level. test code: import struct import array import sys unpack_i32be = struct.Struct(">l").unpack s = ''.join(struct.pack('>i', 1234567)[1:]*1000) def from3bytes_ord(s): values = [] for i in xrange(0, len(s), 3): Value = (ord(s[i])<<16) | (ord(s[i+1])<<8) | ord(s[i+2]) if Value >= 0x800000: Value -= 0x1000000 values.append(Value) return values def from3bytes_struct(s): return [unpack_i32be(s[i:i+3] + "\0")[0] >> 8 for i in xrange(0, len(s), 3)] def from3bytes_array(s): a = array.array('l', ''.join(('\0' + s[i:i+3] for i in xrange(0, len(s), 3)))) if sys.byteorder == 'little': a.byteswap() return a.tolist() from timeit import Timer t1 = Timer("from3bytes_ord(s)", "from __main__ import s, from3bytes_ord") t2 = Timer("from3bytes_struct(s)", "from __main__ import s, from3bytes_struct") t3 = Timer("from3bytes_array(s)", "from __main__ import s, from3bytes_array") print 'ord:\t', t1.timeit(1000) print 'struct:\t', t2.timeit(1000) print 'array:\t', t3.timeit(1000) Output: ord: 7.08213110884 struct: 3.7689164405 array: 2.62995268952 Inspired by Guido's essay http://www.python.org/doc/essays/list2str/ From fetchinson at googlemail.com Wed Apr 2 02:37:12 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Tue, 1 Apr 2008 23:37:12 -0700 Subject: developing web spider In-Reply-To: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> References: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> Message-ID: > I would want to know which could be the best programming language for > developing web spider. > More information about the spider, much better,, I hear Larry and Sergei were not exactly unsuccessful with a python implementation although you might of course try something even better :) If you are less ambitious have a look at http://nikitathespider.com/ which is also a spider in python. Cheers, Daniel From bockman at virgilio.it Thu Apr 17 08:43:36 2008 From: bockman at virgilio.it (bockman at virgilio.it) Date: Thu, 17 Apr 2008 05:43:36 -0700 (PDT) Subject: Python and stale file handles References: Message-ID: On 17 Apr, 04:22, tgiles wrote: > Hi, All! > > I started back programming Python again after a hiatus of several > years and run into a sticky problem that I can't seem to fix, > regardless of how hard I try- it it starts with tailing a log file. > > Basically, I'm trying to tail a log file and send the contents > elsewhere in the script (here, I call it processor()). My first > iteration below works perfectly fine- as long as the log file itself > (logfile.log) keeps getting written to. > > I have a shell script constantly writes to the logfile.log... If I > happen to kill it off and restart it (overwriting the log file with > more entries) then the python script will stop sending anything at all > out. > > import time, os > > def processor(message,address): > ? ? ? ? #do something clever here > > #Set the filename and open the file > filename = 'logfile.log' > file = open(filename,'r') > > #Find the size of the file and move to the end > st_results = os.stat(filename) > st_size = st_results[6] > file.seek(st_size) > > while 1: > ? ? where = file.tell() > ? ? line = file.readline() > ? ? if not line: > ? ? ? ? time.sleep(1) > ? ? ? ? file.seek(where) > ? ? else: > ? ? ? ? print line, # already has newline > ? ? ? ? data = line > ? ? ? ? if not data: > ? ? ? ? ? ? break > ? ? ? ? else: > ? ? ? ? ? ? ? ? processor(data,addr) > ? ? ? ? ? ? ? ? print "Sending message '",data,"'....." > > someotherstuffhere() > > === > > This is perfectly normal behavior since the same thing happens when I > do a tail -f on the log file. However, I was hoping to build in a bit > of cleverness in the python script- that it would note that there was > a change in the log file and could compensate for it. > > So, I wrote up a new script that opens the file to begin with, > attempts to do a quick file measurement of the file (to see if it's > suddenly stuck) and then reopen the log file if there's something > dodgy going on. > > However, it's not quite working the way that I really intended it to. > It will either start reading the file from the beginning (instead of > tailing from the end) or just sit there confuzzled until I kill it > off. > > === > > import time, os > > filename = logfile.log > > def processor(message): > ? ? # do something clever here > > def checkfile(filename): > ? ? file = open(filename,'r') > ? ? print "checking file, first pass" > ? ? pass1 = os.stat(filename) > ? ? pass1_size = pass1[6] > > ? ? time.sleep(5) > > ? ? print "file check, 2nd pass" > ? ? pass2 = os.stat(filename) > ? ? pass2_size = pass2[6] > ? ? if pass1_size == pass2_size: > ? ? ? ? print "reopening file" > ? ? ? ? file.close() > ? ? ? ? file = open(filename,'r') > ? ? else: > ? ? ? ? print "file is OK" > ? ? ? ? pass > > while 1: > ? ? ? ? checkfile(filename) > ? ? where = file.tell() > ? ? line = file.readline() > ? ? print "reading file", where > ? ? if not line: > ? ? ? ? print "sleeping here" > ? ? ? ? time.sleep(5) > ? ? ? ? print "seeking file here" > ? ? ? ? file.seek(where) > ? ? else: > ? ? ? ? # print line, # already has newline > ? ? ? ? data = line > ? ? ? ? print "readying line" > ? ? ? ? if not data: > ? ? ? ? ? ? print "no data, breaking here" > ? ? ? ? ? ? break > ? ? ? ? else: > ? ? ? ? ? ? print "sending line" > ? ? ? ? ? ? processor(data) > > So, have any thoughts on how to keep a Python script from bugging out > after a tailed file has been refreshed? I'd love to hear any thoughts > you my have on the matter, even if it's of the 'that's the way things > work' variety. > > Cheers, and thanks in advance for any ideas on how to get around the > issue. > > tom Possibly, restarting the program that writes the log file creates a new file rather than appending to the old one?? I think you should always reopen the file between the first and the second pass of your checkfile function, and then: - if the file has the same size, it is probably the same file (but it would better to check the update time!), so seek to the end of it - otherwise, its a new file, and then start reading it from the beginning To reduce the number of seeks, you could perform checkfile only if for N cycles you did not get any data. Ciao ----- FB From marlin_rowley at hotmail.com Tue Apr 15 22:44:49 2008 From: marlin_rowley at hotmail.com (Marlin Rowley) Date: Tue, 15 Apr 2008 21:44:49 -0500 Subject: How is GUI programming in Python? In-Reply-To: References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <101680ba-a116-414b-8fff-c5b5bd2f4b65@p39g2000prm.googlegroups.com> Message-ID: Hmm.. I'm just now learning wxPython and it's very very easy to me. Perhaps because I've delved into other GUI APIs like GLUT and Windows DirectX. Programming in C++ seems a pain when coming from Python. I'll let you know more when I delve more into it. -M > From: lxlaurax at gmail.com> Subject: Re: How is GUI programming in Python?> Date: Tue, 15 Apr 2008 19:17:31 -0700> To: python-list at python.org> > On 11 abr, 20:31, sturlamolden wrote:> > On Apr 11, 5:01 am, "Gabriel Genellina" > > wrote:> >> > > Another annoying thing with the Qt license is that you have to choose it> > > at the very start of the project. You cannot develop something using the> > > open source license and later decide to switch to the commercial licence> > > and buy it.> >> > Trolltech is afraid companies will buy one licence when the task is> > done, as oppsed to one license per developer. In a commercial setting,> > the Qt license is not expensive. It is painful for hobbyists wanting> > to commercialize their products.> > I have no experience with GUI programming in Python, but from this> discussion it seems if the type of license is not an issue (for FOSS> development), PyQt is the best tool because it is:> (a) easier to learn and intuitive for programming (this is important> to me; I am not that smart...);> (b) more stable (although many people have said that wxPython is as> stable as any other GUI nowadays; but not more stable (wx) than> others);> (c) more cross-platform (many people complain that they have to do a> lot of things in wxPython for the cross-platform).> > Is (a) and (c) true or not? If so, how big are these advantages?> > The great advantage of wxPython seems to be the huge community of> users and the large number of widgets/examples/applications available.> > Reformulating my question:> > Which GUI tool, wxPython or PyQt, is more pythonic? (Please, ignore> the license issue because I am thinking about FOSS)> > Laura> -- > http://mail.python.org/mailman/listinfo/python-list _________________________________________________________________ Use video conversation to talk face-to-face with Windows Live Messenger. http://www.windowslive.com/messenger/connect_your_way.html?ocid=TXT_TAGLM_WL_Refresh_messenger_video_042008 -------------- next part -------------- An HTML attachment was scrubbed... URL: From maxm at mxm.dk Mon Apr 28 18:12:58 2008 From: maxm at mxm.dk (Max M) Date: Tue, 29 Apr 2008 00:12:58 +0200 Subject: Given a string - execute a function by the same name In-Reply-To: <1209400401.22706.1250293015@webmail.messagingengine.com> References: <1209400401.22706.1250293015@webmail.messagingengine.com> Message-ID: <48164BEA.7010602@mxm.dk> python at bdurham.com skrev: > I'm parsing a simple file and given a line's keyword, would like to call > the equivalently named function. > > There are 3 ways I can think to do this (other than a long if/elif > construct): > > 1. eval() > > 2. Convert my functions to methods and use getattr( myClass, "method" ) > > 3. Place all my functions in dictionary and lookup the function to be > called > > Any suggestions on the "best" way to do this? No reason to use eval. use either getattr(obj, "method")() or functions['method'] They are basically the same thing. The dict of functions is a bit safer. You don't risk calling a built in method on your object . Which you risk doing with something like: getattr(obj, 'join') -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science From hdante at gmail.com Fri Apr 25 22:47:10 2008 From: hdante at gmail.com (hdante) Date: Fri, 25 Apr 2008 19:47:10 -0700 (PDT) Subject: problem with unicode References: <26fcc207-b864-42c7-afb3-c6945e5fe29f@m44g2000hsc.googlegroups.com> Message-ID: <74543e67-6ec3-4d62-8e86-af4215b19579@y38g2000hsy.googlegroups.com> On Apr 25, 8:15?am, "andreas.prof... at googlemail.com" wrote: > > I don't know what to do. I just want to concatenate two string where > apparently one is a binary string, the other one is a unicode string > and I always seem to get this error. Please explain better what you want to do with the merged unicode + binary string. > > Any help is appreciated :) From v.harishankar at gmail.com Tue Apr 22 09:17:43 2008 From: v.harishankar at gmail.com (Harishankar) Date: Tue, 22 Apr 2008 18:47:43 +0530 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: References: Message-ID: <200804221847.43924.v.harishankar@gmail.com> On Tuesday 22 Apr 2008 18:00:02 Nick Craig-Wood wrote: > There is a recipe in the cookbook > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554 > > Which I've used and it works. Thanks. I found that recipe too. I was hoping I could cook up something similar without having to use the module win32api, but looks like that's not the case. > > you can also (if on unix) use > > http://www.noah.org/wiki/Pexpect > I'm on Linux. Debian. Pexpect would do the job fine too. The only thing is it's a third party module and so would reduce the portability of my application. But never mind. I guess I have to make a compromise one way or the other. > import os > from subprocess import * > from subprocess import mswindows > from time import sleep > > if mswindows: > import win32api > else: > import signal > > class PopenNB(Popen): > # - see cookbook recipe for rest of stuff > # ... > def kill(self, killpg=False): > """ > Kill the running process > """ > pid = self.pid > if mswindows: > # Kill the process using win32api and pid - ignore errors > try: > PROCESS_TERMINATE = 1 > handle = win32api.OpenProcess(PROCESS_TERMINATE, False, > pid) win32api.TerminateProcess(handle, -1) > win32api.CloseHandle(handle) > except pywintypes.error: > pass > else: > # Kill the process by sending the pid / process group a > signal > if killpg: > try: > pgid = os.getpgid(pid) > except OSError: > killpg = False > try: > if killpg: > os.killpg(pgid, signal.SIGTERM) > else: > os.kill(pid, signal.SIGTERM) > except OSError: > return > sleep(1.0) > try: > if killpg: > os.killpg(pgid, signal.SIGKILL) > else: > os.kill(pid, signal.SIGKILL) > except OSError: > return Thanks for this bit of code. It should probably be adaptible to my needs. By the way, the win32api seems to be a nonstandard module (i.e. not present in the main distribution). -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org From billingspanshism at gmail.com Sat Apr 19 17:18:38 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:18:38 -0700 (PDT) Subject: photos of victoria beckham Message-ID: Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From arnodel at googlemail.com Mon Apr 7 14:54:28 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Mon, 7 Apr 2008 11:54:28 -0700 (PDT) Subject: A file iteration question/problem References: <47f8eee1$0$759$bed64819@news.gradwell.net> <322f98fd-eb6e-4a05-a8c7-1e0c5329e955@w5g2000prd.googlegroups.com> <47fa1cf9$0$761$bed64819@news.gradwell.net> Message-ID: <51d5bba5-9a38-4f12-ba1e-ad82e661f59e@k10g2000prm.googlegroups.com> On Apr 7, 2:09?pm, tinn... at isbd.co.uk wrote: > Arnaud Delobelle wrote: > > def recfun(lines): > > ? ? for line in lines: > > ? ? ? ? # Do stuff > > ? ? ? ? if condition: > > ? ? ? ? ? ? recfun(lines) > > > lines = iter(open(filename)) > > recfun(lines) > > Does that work though? ?If you iterate through the file with the "for > line in lines:" in the first call of recfun(lines) you surely can't do > "for line in lines:" and get any sort of sensible result in recursive > calls of recfun(lines) can you? Try it! The keyword is iterator. Here is an example of how this would work, but since you didn't believe me I changed the context (strings not files) and I didn't make it as simple as possible ;) def reclist(string): chariter = iter(string + ' ') def rec(): l = [] word = '' for c in chariter: if c.isalnum(): word += c elif word and (c.isspace() or c in '[]'): l.append(word) word = '' if c == ']': return l elif c == '[': l.append(rec()) return l return rec() >>> reclist('40 and 2 eggs but no spam') ['40', 'and', '2', 'eggs', 'but', 'no', 'spam'] >>> reclist('[[40 and 2] eggs] but [no spam]') [[['40', 'and', '2'], 'eggs'], 'but', ['no', 'spam']] >>> -- Arnaud From gagsl-py2 at yahoo.com.ar Wed Apr 16 02:44:10 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 03:44:10 -0300 Subject: Interesting timing issue I noticed References: Message-ID: En Tue, 15 Apr 2008 23:24:01 -0300, Jonathan Shao escribi?: > I've written up a stripped down version of the code. I apologize for the > bad > coding; I am in a bit of a hurry. First things first: I think you will gain inmensely using NumPy: http://numpy.scipy.org/ My timings were 62 and 47ms with your code; after I modified it slightly, 39 and 48ms (for the "on3" and "two" functions). The changes: - instead of a list of lists, I used a defaultdict with (x,y) as the keys. That is, instead of matrix[x][y], I use matrix[x,y] - I converted all range -> xrange Some lines showing the changes: # generates a zero matrix def generate_zero(): import collections matrix = collections.defaultdict(int) return matrix def back_diff_one(back_array, fore_array, box): diff_array = generate_zero() start = time.time() for x in xrange(sizeX): for y in xrange(borderY): idx = x,y diff_array[idx] = back_array[idx] - fore_array[idx] for y in xrange((sizeY - borderY), sizeY): idx = x,y diff_array[idx] = back_array[idx] - fore_array[idx] for y in xrange(borderY, (sizeY - borderY)): for x in xrange(borderX): idx = x,y diff_array[idx] = back_array[idx] - fore_array[idx] for x in xrange((sizeX - borderX), sizeX): idx = x,y diff_array[idx] = back_array[idx] - fore_array[idx] Probably most of the time was spent on creating that many range objects in the inner loops. xrange objects are rather cheap, but you may try pre-creating them in advance before entering the loops. Another thing would be to rearrange the loops so the outer one executes less times; if you know that borderX< (Pdb) myclass MyClass( 0, 0, 'A string', 123.45) (Pdb) copy.copy(myclass) *** TypeError: TypeError('__new__() takes at least 4 arguments (2 given)',) I see 4 arguments (actually, 5 because Python is passing cls invisibly to __new__). Does anyone have an idea what is going on here? I have not defined __new__ in MyClass above. I can make the problem go away on one platform by defining __new__ as return MyClass(self, self.arg1, self.arg2, self.arg3) but I understand that return value to be the default, so I don't see why defining that method makes a difference. On another platform, that definition causes a different problem (I seem to be getting None as the return value of the copy in some cases). By the way, I have simplified somewhat the code in the explanation. In case it might matter, know that there are actually two classes that exhibit this problem. In one, there is actually a fourth argument in the __new__ method that has a default value (the float above), which is why the error message says that __new__ expects *at least* 4 arguments. In the other, the last argument is a parg collector. I have also had trouble pickling these classes. I surmise that pickle uses copy. -- Jeffrey Barish From bvidinli at gmail.com Wed Apr 16 08:50:25 2008 From: bvidinli at gmail.com (bvidinli) Date: Wed, 16 Apr 2008 15:50:25 +0300 Subject: is file open in system ? - other than lsof Message-ID: <36e8a7020804160550g6fba661cx7249426f35e7d635@mail.gmail.com> is there a way to find out if file open in system ? - please write if you know a way other than lsof. because lsof if slow for me. i need a faster way. i deal with thousands of files... so, i need a faster / python way for this. thanks. -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From weiss02121 at gmail.com Tue Apr 15 19:47:50 2008 From: weiss02121 at gmail.com (weiss02121 at gmail.com) Date: Tue, 15 Apr 2008 16:47:50 -0700 (PDT) Subject: lindsay lohan coke Message-ID: <8ee1238d-4776-4095-b29c-9272ccb96a58@u12g2000prd.googlegroups.com> Just few link on some Lindsay Lohan Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From jerry.fleming at saybot.com Mon Apr 14 04:21:26 2008 From: jerry.fleming at saybot.com (Jerry Fleming) Date: Mon, 14 Apr 2008 16:21:26 +0800 Subject: =?UTF-8?B?5pyJ5Lit5Zu95Lq65LmOPw==?= In-Reply-To: References: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> Message-ID: Penny Y. wrote: > bikthh at live.cn ??: >> Python????????????????. > > hehe, so humorous you are! > Yes I think python has good future. > But it depends on what you use it to do. > If you're a singer, a financier, a historian etc, you don't need python. A singer uses his/here throat; a financier uses the abacus -- well, traditionally. Anyway, python is useful only when computer is useful. It is helpful for programming guru, and newbies as well to do the 'quick tricks'. > But if you are playing in computer programming, it's valuable for you to > take some time learning python. > btw,I'm also newbie to python,but I like it. > > --penny From sjmachin at lexicon.net Tue Apr 22 18:12:03 2008 From: sjmachin at lexicon.net (John Machin) Date: Tue, 22 Apr 2008 22:12:03 GMT Subject: list manipulation In-Reply-To: References: <78158460-8508-4453-a2dc-c5814dda8839@59g2000hsb.googlegroups.com> Message-ID: <480e62b4$1@news.mel.dft.com.au> Mike Driscoll wrote: > Well you could always do something like this: > > output = ';'.join(roadList) > > Which will put single quotes on the ends. No, it doesn't. You are conflating foo and repr(foo). I suppose if you want to be > silly, you could do this: > > output = '"%s"' % ';'.join(roadList) *IF* your first effort were to put single quotes on the ends ('the-text') then your second effort would certainly produce something silly ... either '"the-text"' or "'the-text'" depending on which of the assignment or the join method you imagined was producing the single quotes. From lbonafide at yahoo.com Mon Apr 14 07:51:45 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Mon, 14 Apr 2008 04:51:45 -0700 (PDT) Subject: Java or C++? References: Message-ID: On Apr 14, 2:24?am, bdsatish wrote: > On Apr 14, 12:21 pm, Bob Martin wrote: > > > in 342367 20080414 074410 s0s... at gmail.com wrote: > > > >Hello, I was hoping to get some opinions on a subject. I've been > > >programming Python for almost two years now. Recently I learned Perl, > > >but frankly I'm not very comfortable with it. Now I want to move on > > >two either Java or C++, but I'm not sure which. Which one do you think > > >is a softer transition for a Python programmer? Which one do you think > > >will educate me the best? > > Certainly Java. It's also easier to find Java jobs than C++ jobs. Depending on the field, that is. From gabriel.rossetti at mydeskfriend.com Fri Apr 25 11:11:00 2008 From: gabriel.rossetti at mydeskfriend.com (Gabriel Rossetti) Date: Fri, 25 Apr 2008 17:11:00 +0200 Subject: why does the following with Queue, q.put('\x02', True) not put it in the queue? In-Reply-To: <6eb550ae-dca4-4371-856a-15bc9625f93c@z72g2000hsb.googlegroups.com> References: <6eb550ae-dca4-4371-856a-15bc9625f93c@z72g2000hsb.googlegroups.com> Message-ID: <4811F484.1070901@mydeskfriend.com> Arimaz SA Av. du 24 Janvier 11 Ateliers de la Ville de Renens, Atelier 5 1020 Renens, Switzerland www.mydeskfriend.com Mob: +41-(0)79-539-0069 Tel: +41-(0)21-566-7343 sturlamolden wrote: > On Apr 25, 4:38 pm, Gabriel Rossetti > wrote: > >> Hello, >> >> I'm having some trouble with the Queue class, for some reason, if I do >> this (ch == ) : >> >> q = Queue.Queue(0) >> repr(ch) >> q.put(ch, True) >> len(q.queue) >> > > >>>> from Queue import Queue >>>> q = Queue(0) >>>> s = '\x02' >>>> q.put(s,True) >>>> len(q.queue) >>>> > 1 > > > > yes, if you do it that way (s = '\x02') it works, but I read the data from a file, and I that way it doesn't work.... From musiccomposition at gmail.com Mon Apr 14 22:37:56 2008 From: musiccomposition at gmail.com (Benjamin) Date: Mon, 14 Apr 2008 19:37:56 -0700 (PDT) Subject: Brand New! References: <7f1828bf-ebe7-4111-bc59-70d125facb0a@d26g2000prg.googlegroups.com> Message-ID: On Apr 14, 9:00 pm, agent E 10 wrote: > Hi, I'm brand new to programming. Have any suggestions? I'm young. > Was it a good idea to start with python? I was planning on creating a > very simple program that asked yes/no questions for a school project. IMHO, Python is an excellent language to start with. Have you read the tutorial? http://docs.python.org/tut/tut.html > -Thanks! From torriem at gmail.com Wed Apr 23 22:22:14 2008 From: torriem at gmail.com (Michael Torrie) Date: Wed, 23 Apr 2008 20:22:14 -0600 Subject: library to do easy shell scripting in Python Message-ID: <480FEED6.8080309@gmail.com> Recently a post that mentioned a recipe that extended subprocess to allow killable processes caused me to do some thinking. Some of my larger bash scripts are starting to become a bit unwieldy (hundreds of lines of code). Yet for many things bash just works out so well because it is so close to the file system and processes. As part of another project, I now have need of a really good library to make it almost as easy to do things in Python as it is in Bash. With a simple wrapper around subprocess, I'm pretty much able to do most things. Most of my complicated bash hackery involves using awk, sed, grep, and cut to process text, which python does quite nicely, thank you very much. But there's a few things to add. To wit, I'm wanting to write a library that can deal with the following things: - spawn a process, feed it std in, get stdout, stderr, and err code. This is largely already accomplished by subprocess - spawn off processes as background daemons - spawn multiple processes and pipe output to input. - can do fancier things like bash does, like combine stderr/stdout, switch stderr/stdout, redirects to and from files - transparently allow a python function or object to be a part of the pipeline at any stage. Questions include, how would one design the interface for things, like assembling pipes? Several ideas include: pipe([prog1,args],[prog2,args],...) or run([prog1,args]).pipe([prog2,args]).pipe(...) The former doesn't deal very well with re-plumbing of the pipes, nor is there an easy way to redirect to and from a file. The second syntax is more flexible but a bit cumbersome. Also it doesn't allow redirection or flexible plumbing either. Any ideas on how I could design this? From usenet at janc.be Mon Apr 21 16:43:25 2008 From: usenet at janc.be (Jan Claeys) Date: Mon, 21 Apr 2008 20:43:25 GMT Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: Op Thu, 03 Apr 2008 00:06:34 -0700, schreef Dennis Lee Bieber: > On Thu, 03 Apr 2008 03:37:43 GMT, Jan Claeys declaimed > the following in comp.lang.python: > >> Later I learned C (and even later C++), and I've always been wondering >> why those languages were making simple things so complicated... > > Could it be that they are closer to being high-level assembly > languages meant to get close to the hardware (especially of the PDP > series that C originated on), whereas Pascal was designed to just be a > language meant for teaching algorithms and programming, not originally > intended for production efforts? Pointers in Borland's Pascal (and FreePascal) are bare machine pointers, with optional typing for the referenced value; I've never seen anything you could do with C pointers that you couldn't do with Borland Pascal pointers. (And I think the reason why pointers in C looked complicated is that the C syntax for pointers is inconsistent...) -- JanC From lists at cheimes.de Tue Apr 22 17:15:44 2008 From: lists at cheimes.de (Christian Heimes) Date: Tue, 22 Apr 2008 23:15:44 +0200 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: <480e5367$0$17314$9b622d9e@news.freenet.de> References: <480e5367$0$17314$9b622d9e@news.freenet.de> Message-ID: <480E5580.4090302@cheimes.de> Martin v. L?wis schrieb: >> 2. Kill the subprocess in a platform independent manner (i.e. no third party >> modules and no hacks). > > What's wrong with the .terminate method of the Popen object? It's brand new ;) Christian From contact at pythonxy.com Thu Apr 10 04:38:08 2008 From: contact at pythonxy.com (Python(x,y) - Python for Scientists) Date: Thu, 10 Apr 2008 10:38:08 +0200 (CEST) Subject: Python(x,y) - Free Python distribution for Scientists Message-ID: <58619.132.165.76.2.1207816688.squirrel@secure.nuxit.net> Dear all, The scientists among you may be interested in Python(x,y), a new scientific-oriented Python distribution. This Python/Eclipse distribution is freely available as a one-click Windows installer (a release for GNU/Linux with similar features will follow soon): http://www.pythonxy.com Please do not hesitate to forward this announcement... Thanks a lots, PR -- P. Raybaut Python(x,y) http://www.pythonxy.com From gagsl-py2 at yahoo.com.ar Wed Apr 30 05:12:03 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 30 Apr 2008 06:12:03 -0300 Subject: Sending Cntrl-C ?? References: <0274834e-17e1-4a95-88ec-f2aa77aeb3a9@k10g2000prm.googlegroups.com> Message-ID: En Tue, 29 Apr 2008 20:48:42 -0300, Christian Heimes escribi?: > gamename schrieb: >> Thanks, Christian. Would that work on win32 as well? > > No, Windows doesn't support the same, rich set of signal as Unix OSes. True but irrelevant to the question. To the OP: you can download the pywin32 package from sourceforge, and use win32api.GenerateConsoleCtrlEvent(win32con.CTRL_C_EVENT, pgid) or call the same function using ctypes. See http://msdn.microsoft.com/en-us/library/ms683155(VS.85).aspx for some important remarks. -- Gabriel Genellina From soray6034rao at gmail.com Wed Apr 30 07:29:07 2008 From: soray6034rao at gmail.com (soray6034rao at gmail.com) Date: Wed, 30 Apr 2008 04:29:07 -0700 (PDT) Subject: daylight savings time patch Message-ID: <888a5d55-49b8-4b16-834d-67687c9ad062@a70g2000hsh.googlegroups.com> daylight savings time patch http://crack.cracksofts.com From stefan_ml at behnel.de Tue Apr 22 03:36:52 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Tue, 22 Apr 2008 09:36:52 +0200 Subject: Java or C++? In-Reply-To: <2eae6385-1257-48fc-b793-31d0225503ba@f36g2000hsa.googlegroups.com> References: <2eae6385-1257-48fc-b793-31d0225503ba@f36g2000hsa.googlegroups.com> Message-ID: <480D9594.1050505@behnel.de> hdante wrote: > 6. If you just want to speed-up your python programs or offer some > special, system-specific or optimized behavior to your python > applications, or you just want to complement your python knowledge, > learn C. "Learn C", ok, but then go and use Cython instead. Stefan From skanemupp at yahoo.se Sun Apr 27 05:56:26 2008 From: skanemupp at yahoo.se (globalrev) Date: Sun, 27 Apr 2008 02:56:26 -0700 (PDT) Subject: python and web programming, easy way...? References: <2db36ccf-c9fd-4e7a-9697-fd5c23159287@j22g2000hsf.googlegroups.com> Message-ID: <75679853-b5de-42cb-9db2-a1508f2ad67e@59g2000hsb.googlegroups.com> On 27 Apr, 04:26, miya wrote: > On Apr 26, 4:36 pm, bvidinli wrote: > > > > > Hi, > > > i use currently python for console programming. > > in past, i tried it for web programming, to use it instead of php. > > Unfortunately, i failed in my attempt to switch to python. > > Currently, i make many webbased programs and a "Easy Hosting Control > > Panel " (www.ehcp.net) that runs on php, > > ehcp is a hosting control panel in beta stage.. > > > in fact, i use python, love it and want to switch to it in my all > > projects, including webbased programs and ehcp. > > Can your recomment me the easiest, most usable way to use python in > > web programming.. > > > in past, in my first attemt... i was able to run python as as apache > > cgi, runned it basicly, > > but i had many difficulties especially in sessions, cookies... > > > maybe currently there is a solution, but i dont know. > > > Please provide me the quickest/most appropriate solution for web > > programming in python. > > i will try to switch to python in ehcp too.. > > > Currently my web programs are simple Object Oriented programs, that > > basicly uses a few files, in php. > > i use sessions in use authentications. > > i currently use php because it is fairly easy to install/run on apache.. > > you just put it on server, it runs.. i look something like this for > > python. because python programming is much better than php. > > > Thank you a lot. > > > -- > > ?.Bahattin Vidinli > > Elk-Elektronik M?h. > > ------------------- > > iletisim bilgileri (Tercih sirasina gore): > > skype: bvidinli (sesli gorusme icin,www.skype.com) > > msn: bvidi... at iyibirisi.com > > yahoo: bvidinli > > > +90.532.7990607 > > +90.505.5667711 > > Django is the way to go for web development. > > http://www.djangoproject.com/ > > cya > > -- > Nicol?s Miyasato ( miya ) www.webpy.org is supereasy to get going with. dont know which is better for advanced stuff. From oakley at bardo.clearlight.com Fri Apr 11 11:11:37 2008 From: oakley at bardo.clearlight.com (Bryan Oakley) Date: Fri, 11 Apr 2008 15:11:37 GMT Subject: tkinter, overwrite Label-text? In-Reply-To: <403d094e-2704-40c0-a0b3-dd335b19af85@m1g2000pre.googlegroups.com> References: <666s2qF2il38sU1@mid.uni-berlin.de> <403d094e-2704-40c0-a0b3-dd335b19af85@m1g2000pre.googlegroups.com> Message-ID: skanemupp at yahoo.se wrote: > ok but i have trouble using grid. if i try to use a Label witht he > text answer in the following code it doenst work very well. > Can you describe "have trouble"? What sort of trouble -- syntax errors, the text never shows up, etc? Following is my attempt to use a label and textvariables for both the label widget and the entry widget. Caveat emptor: I've *never* written a tkinter program before in my life. I'm a tcl/tk expert but I'm learning python and this is my very first attempt. I took the liberty to reorganize the code slightly. There are still resize behaviors I don't like but let's tackle one problem at a time (rest assured: the problems are all solvable). Does this do what you want? from __future__ import division import Tkinter from Tkinter import * def main(): root = Tkinter.Tk() makeUI(root) root.mainloop() exit() def makeUI(root): global entryVariable global displayVariable displayVariable = StringVar() entryVariable = StringVar() root.title("Calculator") entry = Entry(root, textvariable=entryVariable) entry.grid(row=1, column=1, columnspan=4, sticky="nsew") display=Label(root, textvariable=displayVariable) display.grid(row=2, column=1, columnspan=4, stick="nsew") x = 1 y = 4 for char in '123+456-789*0()/.': b = Button(root, text=char, command=lambda n=char:Disp(n), width=2, height=1) b.grid(row=y, column=x) x=x+1 if x==5: x=1 y=y+1 b = Button(root, text="^", command=lambda n="**":Disp(n), width=2,height=1) b.grid(row=8, column=2) b = Button(root, text="C",command=Erase, width=2, height=1) b.grid(row=8, column=3) b = Button(root, text="c",command=Backspace, width=2, height=1) b.grid(row=8, column=4) b = Button(root, text="=",command=Calc, width=18, height=1) b.grid(row=9, column=1, columnspan=8) def Disp(nstr): global entryVariable tmp=entryVariable.get() tmp+=nstr entryVariable.set(tmp) def Calc(): global entryVariable global displayVariable expr=entryVariable.get() displayVariable.set("") try: displayVariable.set(eval(expr)) except: displayVariable.set("Not computable") def Erase(): global entryVariable global displayVariable entryVariable.set("") displayVariable.set("") def Backspace(): global entryVariable tmp=entryVariable.get() tmp=tmp[0:-1] entryVariable.set(tmp) main() From pecora at anvil.nrl.navy.mil Mon Apr 21 13:59:54 2008 From: pecora at anvil.nrl.navy.mil (Lou Pecora) Date: Mon, 21 Apr 2008 13:59:54 -0400 Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> <8f3a768d-0b4c-4077-9aef-a66898882f03@m1g2000pre.googlegroups.com> Message-ID: In article <8f3a768d-0b4c-4077-9aef-a66898882f03 at m1g2000pre.googlegroups.com>, castironpi at gmail.com wrote: > On Apr 21, 9:28?am, a... at pythoncraft.com (Aahz) wrote: > > > > > > Why is this newsgroup different from all other newsgroups? ? > > Different is a verbally atomic relation. It's a Passover question. -- -- Lou Pecora From ajaksu at gmail.com Mon Apr 14 20:58:25 2008 From: ajaksu at gmail.com (ajaksu) Date: Mon, 14 Apr 2008 17:58:25 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> Message-ID: On Apr 14, 8:10?pm, Sverker Nilsson wrote: > do i dare to open ?a thread about this? Yeah, you sure do! > come on you braver men Yeah! > we are at least not bought by g***le Hell no! > but why? others have said it so many times i think Huh?! > :-//// ?! Whatever! > but why? a few syntactic 'cleanups' for the cost of a huge rewrite of > all the code that have been builtup from all the beginning when the > once great Python came along and people began to use it and write code > for it. Like all that code would have to be rewritten. blaah. Yeah! Woo-hoo! Wait... What? No, no, you got it all wrong. Python developers are being extra-careful and doing a lot of hard work to keep things sane, allow easy migration, etc. > and i have perhaps been drinking but i have been p**d all week since i > began look into this:-( Ah, OK, calm down and look again. Things are way better than you think, but there is a lot of FUD going on too, so focus on serious, reliable reports. Cheers, Daniel From ntv1534 at gmail.com Wed Apr 30 20:56:06 2008 From: ntv1534 at gmail.com (MooMaster) Date: Wed, 30 Apr 2008 17:56:06 -0700 (PDT) Subject: We have string.isdigit(), why not string.isNumber()? Message-ID: <0d43feda-fab8-46ba-9af0-eaf497033acd@l17g2000pri.googlegroups.com> N00b question alert! I did a search for isdigit() in the group discussion, and it didn't look like the question had been asked in the first 2 pages, so sorry if it was... The manual documentation says: "isdigit( ) Return true if all characters in the string are digits and there is at least one character, false otherwise. For 8-bit strings, this method is locale-dependent. " So it makes sense that something like 5.6 would return false. But what if we want to make sure that our string is a valid number, ie decimals included? I know how to write a regexp or method or whatever to do this, my main question is *why* something like an isNumber() method is not baked into the class. Does such functionality exist somewhere else in the standard library that I'm just missing? From arnodel at googlemail.com Fri Apr 11 16:48:44 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Fri, 11 Apr 2008 13:48:44 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> <5b1b5304-f076-4240-b685-6aa6c4cc209a@u3g2000hsc.googlegroups.com> Message-ID: <63799d41-1889-42cc-89a6-4ec576dbc2b5@q24g2000prf.googlegroups.com> On Apr 11, 8:27?pm, Mark Dickinson wrote: > On Apr 11, 2:33?pm, Lie wrote: [...] > > Another mistake, in an unquantized value the probability of getting > > exactly 0.5 (or any other number specified) is not 0 but an > > infinitesimal (i.e. lim(x) where x -> 0 (BUT NOT ZERO)) > > I'm not sure you'll get many takers for this point of view. ?If X is > a random variable uniformly distributed on the interval [0, 1) then > the probability that X == 0.5 is indeed exactly 0, using conventional > definitions. ?(And if you're not using conventional definitions, you > should say so....) And I would like to know what unconventional - but mathematically meaningful - definitions lead to lim x != 0 x -> 0 -- Arnaud From ch612bunn at gmail.com Sun Apr 27 09:18:24 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:18:24 -0700 (PDT) Subject: norton internet security 2008 crack Message-ID: <28c5e948-1722-4317-bd1a-939a136d4a08@k13g2000hse.googlegroups.com> norton internet security 2008 crack http://wga-cracks.crackkey.net From bblais at bryant.edu Wed Apr 30 11:35:23 2008 From: bblais at bryant.edu (Brian Blais) Date: Wed, 30 Apr 2008 11:35:23 -0400 Subject: simple chemistry in python In-Reply-To: <4817BFF2.9030907@al.com.au> References: <5e3717e5-1913-4bda-94b3-ae165e5fb8ba@m73g2000hsh.googlegroups.com> <4817BFF2.9030907@al.com.au> Message-ID: <251FABCD-BAAC-4451-968E-2561E3AE47B4@bryant.edu> > > baoilleach wrote: >> >> If you are familiar with parsing XML, much of the data you need is >> stored in the following file: >> http://bodr.svn.sourceforge.net/viewvc/*checkout*/bodr/trunk/bodr/ >> elements/elements.xml?revision=34&content-type=text%2Fplain Here's a quick BeautifulSoup script to read it into a python dict. It misses anything not a scalar, but you can easily modify it to include arrays, etc... in the xml. hope it's useful. certainly a neat site! bb -- Brian Blais bblais at bryant.edu http://web.bryant.edu/~bblais from __future__ import with_statement from BeautifulSoup import BeautifulSoup with open('elements.xml') as fid: soup=BeautifulSoup(fid) all_atoms=soup('atom') element=soup('atom',{'id':'H'})[0] elements={} for atom in all_atoms: info={} id=atom['id'] scalars=atom('scalar') for s in scalars: dictref=s['dictref'] # seems to have a bo at the beginning datatype=s['datatype'] # seems to have a xsd: at the beginning contents=s.contents[0] if datatype=='xsd:Integer': value=int(contents) elif datatype=='xsd:int': value=int(contents) elif datatype=='xsd:float': value=float(contents) else: value=contents key=dictref[3:] info[key]=value elements[id]=info -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.sakkis at gmail.com Wed Apr 30 00:26:31 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 29 Apr 2008 21:26:31 -0700 (PDT) Subject: Python's doc problems: sort References: <929d5ce9-9063-4e6c-98aa-89526f89fba3@y18g2000pre.googlegroups.com> <9pof14t22rpq24219q0an2748i5f054qr4@4ax.com> Message-ID: <88273bc8-5152-4dfd-9f96-1d6ee2b83f99@e53g2000hsa.googlegroups.com> On Apr 29, 11:13?pm, J?rgen Exner wrote: > "xah... at gmail.com" wrote: > > Is this self-promoting maniac still going at it? > > >Although i disliked Perl very much [...] > > Then why on earth do you bother polluting this NG? > > Back into the killfile you go > > jue \|||/ (o o) ,----ooO--(_)-------. | Please | | don't feed the | | TROLL's ! | '--------------Ooo--' |__|__| || || ooO Ooo From paul at boddie.org.uk Wed Apr 23 07:51:18 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Wed, 23 Apr 2008 04:51:18 -0700 (PDT) Subject: subprocess module is sorely deficient? References: <811891.72800.qm@web39208.mail.mud.yahoo.com> Message-ID: <48d2c7cd-baa9-4815-bae0-cfa1cf481d28@r66g2000hsg.googlegroups.com> On 23 Apr, 13:17, Harishankar wrote: > On Wednesday 23 Apr 2008 15:11:21 Ben Kaplan wrote: > > I don't know about all Linux distros, but my Ubuntu machine (8.04 Beta), > > has the 'TERM' (xterm) and 'COLORTERM' (gnome-terminal) keys in os.environ. > > You might be able to use that to ensure that the terminal is installed, but > > you should probably look at a couple of other popular distros first to make > > sure that the key is there. > > This is set on Debian too. Thanks. I should be able to use this environment > variable on most Linux distributions, I suspect. Here on RHEL 4, COLORTERM has an empty value. I suppose that the freedesktop.org standards should cover this kind of thing, and there are some scripts out there which attempt to provide cross-desktop support on Free Software desktops: http://portland.freedesktop.org/wiki/XdgUtils Similarly, the desktop module should provide support for various desktop features, but opening command line windows or terminals isn't yet possible: http://www.python.org/pypi/desktop It'd be interesting to know if we could find out (or make up) reliable ways of opening the user's preferred terminal application. Paul From aahz at pythoncraft.com Mon Apr 21 09:20:59 2008 From: aahz at pythoncraft.com (Aahz) Date: 21 Apr 2008 06:20:59 -0700 Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: In article , Carl Banks wrote: >On Apr 20, 10:57 pm, a... at pythoncraft.com (Aahz) wrote: >> In article , >> Carl Banks wrote: >>>On Apr 17, 3:37 am, Jonathan Gardner >>>wrote: >>>> >>>> Using 100% of the CPU is a bug, not a feature. >>> >>>No it isn't. That idea is borne of the narrowmindedness of people who >>>write server-like network apps. What's true for web servers isn't >>>true for every application. >> >> Only when you have only one application running on a machine. > >Needless pedantry. > >"Using 100% of the CPU time a OS allow a process to have is not >necessarily a bug." Happy? Not really; my comment is about the same level of pedantry as yours. Jonathan's comment was clearly in the context of inappropriate CPU usage (e.g. spin-polling). Obviously, there are cases where hammering on the CPU for doing a complex calculation may be appropriate, but in those cases, you will want to ensure that your application gets as much CPU as possible by removing all unnecessary CPU usage by other apps. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ Why is this newsgroup different from all other newsgroups? From andreas.eisele at gmail.com Sat Apr 12 16:01:48 2008 From: andreas.eisele at gmail.com (andreas.eisele at gmail.com) Date: Sat, 12 Apr 2008 13:01:48 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: <32e2acc1-97cb-4911-bb0c-67965b5ff113@2g2000hsn.googlegroups.com> > Martin said that the default settings for the cyclic gc works for most > people. I agree. > Your test case has found a pathologic corner case which is *not* > typical for common application but typical for an artificial benchmark. I agree that my "corner" is not typical, but I strongly disagree with the classification as pathological. The only feature of my test case that is not typical is the huge number of distinct objects that are allocated. I admit that 1E7 objects is today still fairly untypical, but there is nothing pathological about it, it is just bigger. I is about as pathological as a file size >2G, which a few years ago seemed so outrageous that no OS bothered to support it, but is fairly common nowadays, so that a lack of support would appear as an arbitrary and unmotivated limitation nowadays. We all enjoy seeing Python adopted on a large scale and used by a broad community, so we should not accept arbitrary size limits. You could call a string with more than 2GB pathological, but I very much appreciate the fact that Python supports such strings for the few cases where they are needed (on a 64 bit architecture). Now a O(N*N) effort for large numbers of objects isn't such a hard limit, but in practice boils down to the same effect, that people cannot use Python in such circumstances. I would prefer it very much if such "soft limits" could be avoided as well. Given there is a fairly simple workaround (thanks again to Amaury!), the issue is not urgent, but I still think it is important in the long run. > Python is optimized for regular apps, not for benchmark (like some video > drivers). > I still think it would be worthwhile to support very large numbers of objects in a way that they can just be used, without knowledge of special tricks, and I would be fairly optimistic that those who have designed the current GC schemes could generalize them slightly so that these marginal cases will work better without imposing a penalty on the more typical cases. > By the way you shouldn't use range for large ranges of more than a > thousand items. xrange() should be faster and it will definitely use > much less memory - and memory Python 2.5 and older will never release > again. I'm going to fix the issue for Python 2.6 and 3.0. > Thanks for this hint, and for the work on the newer versions. This is very much appreciated. Andreas From john106henry at hotmail.com Sun Apr 27 00:04:58 2008 From: john106henry at hotmail.com (John Henry) Date: Sat, 26 Apr 2008 21:04:58 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> Message-ID: <1d8af3e3-c287-4d5b-a481-ca8c650f732f@s33g2000pri.googlegroups.com> On Apr 26, 3:03?pm, John Henry wrote: > On Apr 26, 8:46 am, a... at pythoncraft.com (Aahz) wrote: > > > > > > > In article <9028496e-30de-4853-8f57-b55d14e52... at h1g2000prh.googlegroups.com>, > > John Henry ? wrote: > > > >But then I looked closer. ?It turns out the XML file created by > > >QxTransformer is *very* similar in structure when compared to the > > >resource files used inPythonCard. ?Since there are no GUI builders > > >for QxTransformer, and I can't affort to buy the one for Qooxdoo > > >(Java! ?Yuk!), I decided to roll up my sleeves, took thePythoncard's > > >Layout Manager and modified it and created my own "Poor Man's Qooxdoo > > >GUI Layout Designer". > > > Cute! ?When you have working code, please do upload to PyPI. > > -- > > Aahz (a... at pythoncraft.com) ? ? ? ? ? <*> ? ? ? ?http://www.pythoncraft.com/ > > > Why is this newsgroup different from all other newsgroups? > > So far, I have the following widgets working: > > window, button, checkbox, static text, static box, list, combobox, > spinner, radio button group > > Shouldn't be long before the following works: > > static line, image, image button, choice.- Hide quoted text - > > - Show quoted text - All of the above works! TextFields next. From arnodel at googlemail.com Tue Apr 29 14:28:47 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Tue, 29 Apr 2008 19:28:47 +0100 Subject: Zope/DTML Infuriating... References: <3473a8d5-e113-464e-825c-e88a7758ce9d@d45g2000hsc.googlegroups.com> Message-ID: Jens writes: [...] > @Marco: Thanks for the links :-) Python may be one of those really > elegant languages, but the reference is really sub > standard. Checkout the layout of php.net for comparison. Think what > you will about php, but the reference is excellent. For that matter > check out msdn section on old-school asp, or even the common-lisp > documentation(http://www.lispworks.com/ > documentation/HyperSpec/Front/Contents.htm) Beauty is in the eye of the beholder. I'm used to the python doc layout, and I can find my way round it pretty fast. What I like about it is that it is organised thematically, so it is usually possible to think your way to where the relevant documentation is. Moreover, Python has a very useful help functionality: * at the interactive prompt: >>> help(someobject) >>> help(somemodule) Will give you lots of useful information * At the shell prompt: $ pydoc --> documentation about keyword > It's accessibility like that i'm missing. It shouldn't take 10 min > and a usenet post to figure to how to basic stuff like string > concatenation. It takes time to learn a language, and that includes learning how the documentation is organised. > And theres still plenty of unanswered questions after checking the > reference: > > - What is the exact definition of the operator e.g. op + (, > ) -> , op + (, ) : , op + ( ... The answers are here (in the library reference you checked): http://docs.python.org/lib/types.html > - What is the exact operator precedence That's a language feature, so it's in the *language* reference. http://docs.python.org/ref/summary.html > - Why is it, when primitive data types seem to be objects (similar to > javascript), that type casting is done through build-in functions > rather than methods, e.g. String.toInt('5') or '5'.toInt() or x = > Integer.fromString('5'). Because Python is not Javascript? In fact some are methods, e.g. str(x) is shorthand for x.__str__(). -- Arnaud From spe.stani.be at gmail.com Mon Apr 7 09:15:35 2008 From: spe.stani.be at gmail.com (SPE - Stani's Python Editor) Date: Mon, 7 Apr 2008 06:15:35 -0700 (PDT) Subject: Please test Phatch on Windows (was Re: ANN: Phatch = PHoto bATCH processor and renamer based on PIL) References: <15f9eaeb-8d02-4090-922e-97a65c20fe51@e23g2000prf.googlegroups.com> Message-ID: <95db4f1d-636b-4d61-94d7-6b65704604f3@s8g2000prg.googlegroups.com> Hi Steve, Thanks for the confirmation. It is indeed good news. Feel free to send me privately some screenshots. BTW, I just released Phatch 0.1.3 which is the final version for Ubuntu Hardy. Stani On Mar 31, 3:44?am, Steve Holden wrote: > Stani: > > You'll be happy to hear that it appears (after a quick test) to work on > Vista, though I blush to admit I actually have a Python running on that > platform. > > The font selection is much better than in previous versions - although > the names aren't quite the full font names it's pretty easy to tell > which one will be used. > > regards > ? Steve > > SPE - Stani's Python Editor wrote: > > > > > I have been working the last couple of days purely on bug fixing and > > to port the code ofPhatchfully to Windows as there were many issues. > > This has improved: > > -Phatchcan now create droplets on Windows (win32 extensions > > required) > > - Installed fonts are retrieved from the Windows registry > > - Image file dialogs are now working correctly > > - Missing icons are added (including aphatch.ico) and are now > > displayed in the windows titlebars > > - Image Inspector was missing a panel > > - Preview in Image Inspector now displays correctly > > - (...) > > > Besides thatPhatchnow features for all platforms: > > - fonts can be defined with a nice dropdown autocomplete list > > - drop down lists with convenient values in all actions > > - the action masks now ships with some predefined masks (such as torn > > edges) > > - right click in the actions dialog box to see the source of an action > > - View>Droplet nows shows the name of the action box rendered in the > > logo > > - Dutch translation is 100% complete > > > As such no new features have been added, but the user experience feels > > much more polished now. > > > Please read *carefully* the installation instructions first: > >http://photobatch.wikidot.com/install#toc6 > > > People who have been usingPhatchbefore should clear their font cache > > (if it exists). Simply delete the file: > > C:\Documents and Settings\Username\.phatch\fonts > > > I did thePhatchport on a Windows 2000 machine, so I am curious to > > hear howPhatchworks on Windows XP and Vista. I will fix any bug (as > > far as possible) which is reported quickly in the next couple of days. > > > You can help translatingPhatchhere: > >https://translations.launchpad.net/phatch/trunk/+pots/phatch > > > Thanks in advance, > > > Stani > > > On 18 feb, 15:58, "SPE - Stani's Python Editor" > > wrote: > >> I'm pleased to announce the release ofPhatchwhich is a > >> powerful batch processor and renamer.Phatchexposes a big part of the > >> Python Imaging Library through an user friendly GUI. (It is using > >> python-pyexiv2 to offer more extensive EXIF and IPTC support.)Phatch > >> is not targeted at manipulating individual pictures (such as with > >> Gimp), but repeating the same actions on hundreds or thousands of > >> images. > > >> If you know PIL and have some nice recipes laying around, it is very > >> easy to write plugins asPhatchgenerates the corresponding GUI > >> automagically just like in Django. Any existings PIL scripts can be > >> added very easily. Let me know if you want to contribute or have any > >> questions. > > >> Homepage:http://photobatch.stani.be(freedownload link below) > >> Tutorials:http://photobatch.wikidot.com/tutorials > >> Translations:https://translations.launchpad.net/phatch/trunk/+pots/phatch > >> License: GPLv3 > >> Screenshot:http://photobatch.wikidot.com/local--files/start/Screenshot-Phatch3d.jpg > >> (the perspective and reflection is produced byPhatchitself) > > >> Phatchhas many features, like: > >> - EXIF information inspector with thumbnail > >> - limit jpeg file size when saving > >> - tons of actions organized by tags (including perspective, round > >> corners, shadow, reflection, ...) > >> - console version (Phatchcan now run without a gui on servers) > >> - batch rename and copy files based on exif metadata > >> - data stamping (http://photobatch.wikidot.com) > >> - online documentation wiki (http://photobatch.wikidot.com) > > >> Linux only features: > >> - desktop or panel droplets on which images or folders can be dropped > >> (will be ported to Windows & Mac) > >> - Nautilus and desktop integration (with its own mime type and > >> nautilus extension) > >> - manpage with examples > > >> With python-pyexiv2 the following featues are added: > >> - embedding the original EXIF and IPTC tags in the image > > >> All actions mostly have a separate pil function in their source code, > >> so they could be read as a recipe book for PIL: > >> * Auto Contrast - Maximize image contrast > >> * Background - Put colour under transparent image > >> * Border - Crop or add border to all sides > >> * Brightness - Adjust brightness from black to white > >> * Canvas - Crop the image or enlarge canvas without resizing the image > >> * Colorize - Colorize grayscale image > >> * Common - Copies the most common pixel value > >> * Contrast - Adjust from grey to black & white > >> * Convert Mode - Convert the color mode of an image (grayscale, RGB, > >> RGBA or CMYK) > >> * Copy - Copy image file > >> * Effect - Blur, Sharpen, Emboss, Smooth, ... > >> * Equalize - Equalize the image histogram > >> * Fit - Downsize and crop image with fixed ratio > >> * Grayscale - Fade all colours to gray > >> * Invert - Invert the colors of the image (negative) > >> * Maximum - Copies the maximum pixel value > >> * Mask - Apply a transparency mask > >> * Median - Copies the median pixel value > >> * Minimum - Copies the minimum pixel value > >> * Offset - Offset by distance and wrap around > >> * Posterize - Reduce the number of bits of colour channel > >> * Perspective - Shear 2d or 3d > >> * Rank - Copies the rank'th pixel value > >> * Reflect - Drops a reflection > >> * Rename - Rename image file > >> * Rotate - Rotate with random angle > >> * Round - Round or crossed corners with variable radius and corners > >> * Saturation - Adjust saturation from grayscale to high > >> * Save - Save an image with variable compression in different types > >> * Scale - Scale an image with different resample filters. > >> * Shadow - Drop a blurred shadow under a photo with variable position, > >> blur and color > >> * Solarize - Invert all pixel values above threshold > >> * Text - Write text at a given position > >> * Transpose - Flip or rotate an image by 90 degrees > >> * Watermark - Apply a watermark image with variable placement (offset, > >> scaling, tiling) and opacity > > >> I developPhatchon Ubuntu/Linux, but I have tested and polished it > >> regularly on Windows and Mac Os X. (Only the droplet functionality > >> needs to be ported.)Phatchis submitted to Debian unstable and > >> Ubuntu Hardy. Packagers for other platforms are welcome. > > >> Requirements: > >> - PIL 1.1.5 or higher > >> - wxPython 2.6 or higher > >> - pyexiv2 (optional) > >> - python nautilus bindings (optional) > > >> Best regards, > >> Stani > >> --http://pythonide.stani.be > > -- > Steve Holden ? ? ? ?+1 571 484 6266 ? +1 800 494 3119 > Holden Web LLC ? ? ? ? ? ? ?http://www.holdenweb.com/ From pavlovevidence at gmail.com Mon Apr 7 18:47:28 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 7 Apr 2008 15:47:28 -0700 (PDT) Subject: Dependency Queue References: <0309251d-fba9-447c-9b17-f512988103ea@e39g2000hsf.googlegroups.com> Message-ID: On Apr 7, 1:13 pm, "Terry Reedy" wrote: > "Carl Banks" wrote in message > > news:0309251d-fba9-447c-9b17-f512988103ea at e39g2000hsf.googlegroups.com... > | I'm looking for any information about a certain kind of dynamic data > | structure. Not knowing if it has some well-known name that I could > | have Googled, I'll just call it a dependency queue. It's like a > | priority queue except instead of a strict ordering of items by > | priority, there is only a topological ordering (like you would have in > | a directed acyclic graph). > | > | To date I've been generating a dependency graph in advance every > | iteration through my main loop, doing a topsort, and executing the > | values in order (the values are callable objects--this is a > | scheduler). > | > | However, I'd like a dynamic dependency queue for two reasons: it would > | simplify things to not have to generate the whole graph in advance, > | and it could improve performance to run some tasks of the next > | iteration in the present one (this could potentially make better use > | of the dual-core and graphics hardware). > | > | I'm pretty sure I could hack out this structure on my own, but I'd > | like to see any prior information if there is any, in case anyone's > | figured out things like, Is there an easy way to detect cycles on > | insertion? and so on. > > Perhaps what you want is a dynamic DAG (directed acyclic graph) with > ordered labels. At any time, only the set of sources are eligible for > execution, so there is no reason to flatten the whole thing. I suspect > insertion with cycle detection would be easier, but I don't remember > actually seeing an algorithm. Yes, a dynamically updating DAG is probably how I'd implement it, that's straightforward enough. What I'm looking for is any prior work on uncovering properties and useful algorithms for the situations that would come up. Like is there a chapter of some book devoted to them? Carl Banks From roy at panix.com Thu Apr 10 08:57:39 2008 From: roy at panix.com (Roy Smith) Date: Thu, 10 Apr 2008 08:57:39 -0400 Subject: I am worried about Python 3 References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> <47fce3ca$0$36346$742ec2ed@news.sonic.net> <6663kdF2j5bs0U1@mid.uni-berlin.de> Message-ID: Gerhard H?ring wrote: > The difference is that Guido learnt from the mistakes of Perl 6 and set > much more realistic (moderate) goals for Python 3.0. Another difference is that by the time Perl 6 was being worked on, there were other new things on the horizon. People wanting something better than Perl 5 were looking at Python, Ruby, or Tcl. You're not going to convince your customers to upgrade to a new flavor of duct tape when they're already playing with velcro. From marli305nugent at gmail.com Sat Apr 26 09:54:08 2008 From: marli305nugent at gmail.com (marli305nugent at gmail.com) Date: Sat, 26 Apr 2008 06:54:08 -0700 (PDT) Subject: red alert 2 cd crack Message-ID: <83dd0afd-42a5-465c-b525-0bdb63515ede@26g2000hsk.googlegroups.com> red alert 2 cd crack http://cracks.00bp.com F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Sun Apr 20 21:48:09 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 22:48:09 -0300 Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480b8d58$0$26996$9b622d9e@news.freenet.de> <480BA644.9090701@cheimes.de> Message-ID: En Sun, 20 Apr 2008 17:23:32 -0300, Christian Heimes escribi?: > Martin v. L?wis schrieb: >> Can you give an example, please? > > http://trac.edgewall.org/ contains at least one example of a reference > leak. It's holding up the release of 0.11 for a while. *scnr* > > The problem is also covered by the docs at > http://docs.python.org/dev/library/sys.html#sys.exc_info Ah, you scared me for a while... :) Holding the traceback from sys.exc_info is not a memory leak, just prevents *a lot* of objects reaching refcount 0 as long as the execution frames are refering to them. Don't store a traceback more than needed and it should be fine... -- Gabriel Genellina From aaron.watters at gmail.com Wed Apr 16 14:10:20 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 16 Apr 2008 11:10:20 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> Message-ID: On Apr 16, 1:42 pm, Rhamphoryncus wrote: > The only reason to not make the > changes is that old, crufty, unmaintained libraries & applications > might depend on them somehow. If that's more important to you, what > you really want is a language who's specs are frozen - much like C > effectively is. I hope python doesn't become that for a long time > yet, as there's too much it could do better. I'm feeling a bit old, crufty, and unmaintained myself, but I'll try not to take offense. There is a difference between something that works fine until the rug gets pulled out and something that needs fixing. It's a shame to junk stuff that works. Also in the case of C/java etc changing the infrastructure is less scary because you usually find out about problems when the compile or link fails. For Python you may not find out about it until the program has been run many times. Perhaps this will inspire improved linters and better coding practices.... I suppose if the py3k migration inspires tons of insomniac young programmers to seek fame and admiration by cleaning up ancient libraries, it would be a good thing. It seems to have happened in the Perl4->5 migration some years ago. Could happen again. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=repeatedly+hammer From pavlovevidence at gmail.com Wed Apr 9 03:16:13 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Wed, 9 Apr 2008 00:16:13 -0700 (PDT) Subject: Converting a tuple to a list References: <00ba01c899c5$14528ae0$0a01a8c0@mobile> Message-ID: <38cb266f-259a-4458-8f12-6641091c94b3@s50g2000hsb.googlegroups.com> On Apr 8, 6:46 pm, "Gabriel Ibanez" wrote: > Gabriel Ibanez wrote: > > Hi all .. > > > I'm trying to using the map function to convert a tuple to a list, without > > success. > > > I would like to have a lonely line that performs the same as loop of the > > next script: > > > ------------------------------------------- > > # Conveting tuple -> list > > > tupla = ((1,2), (3,4), (5,6)) > > > print tupla > > > lista = [] > > for a in tupla: > > for b in a: > > lista.append(b) > > print lista > > ------------------------------------------- > > > Any idea ? > > > Thanks ... > > > # Gabriel > > list(tupla) > > would probably do it. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > --http://mail.python.org/mailman/listinfo/python-list > > That would just make a list of tuples, I think he wants [1, 2, 3, 4, 5, 6]. > > Try: l = [x for z in t for x in z] > > --Brian > > --------------- > > Thanks Steve and Brian, > > Brian: that is !! > > However, it's a bit difficult to understand now. I have read it several > times :) A list comp is straightforwardly equivalent to nested for loops. To read, it may be easeier to write it out as loops: l = [] for z in t: for x in z: l.append(x) Which, you'll note, it the same as your working code only with different names. Carl Banks From drjekil77 at gmail.com Wed Apr 9 17:02:01 2008 From: drjekil77 at gmail.com (drjekil) Date: Wed, 9 Apr 2008 14:02:01 -0700 (PDT) Subject: new user needs help! In-Reply-To: <16571823.post@talk.nabble.com> References: <16571823.post@talk.nabble.com> Message-ID: <16596608.post@talk.nabble.com> I have done something so far about that problem,but its not the good way to do it need ur comments about that.... from string import *; import sys myfile = open("/afs/pdc.kth.se/home/d/debnath/membrane/1a91A.txt") a = myfile.readlines() data = myfile.readlines() for line in myfile.readlines(): fields = line.split('\t') items=fields.strip() list1.append(items[1]) for i in aminoacid: if 10.0 <= z <= 22.0: matches.append([1,i]) #here i am getting comment! bash-3.1$ python bb.py File "bb.py", line 16 matches.append([1,i]) ^ IndentationError: expected an indented block else: matches.append([-1,i]) print "#T/F A C D E F G H I K L M N P Q R S T V W X Y Z" for a in range(0,len(matches),1): if matches[a][0]==1: if matches[a][1]=='A': print "1 1:1 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" elif matches[a][1]=='C': print "1 1:0 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" elif matches[a][1]=='D': print " 1 1:0 2:0 3:1 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" """ if matches[a][1]=='E' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:1 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='F' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:1 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='G' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:1 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='H' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='I' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:1 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='K' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:1 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='L' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:1 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='M' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:1 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='N' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:1 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='P' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:1 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='Q' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='R' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:1 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='S' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:1 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='T' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:1 18:0 19:0 20:0 21:0" if matches[a][1]=='V' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:1 19:0 20:0 21:0" if matches[a][1]=='X' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:1 20:0 21:0" if matches[a][1]=='Y' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:1 21:0" if matches[a][1]=='Z' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:1" """ else: if matches[a][1]=='A': print "-1 1:1 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" elif matches[a][1]=='C': print "-1 1:0 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" elif matches[a][1]=='D': print " 1 1:0 2:0 3:1 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" """ if matches[a][1]=='E' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:1 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='F' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:1 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='G' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:1 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='H' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='I' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:1 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='K' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:1 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='L' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:1 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='M' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:1 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='N' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:1 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='P' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:1 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='Q' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='R' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:1 16:0 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='S' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:1 17:0 18:0 19:0 20:0 21:0" if matches[a][1]=='T' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:1 18:0 19:0 20:0 21:0" if matches[a][1]=='V' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:1 19:0 20:0 21:0" if matches[a][1]=='X' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:1 20:0 21:0" if matches[a][1]=='Y' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:1 21:0" if matches[a][1]=='Z' and matches[a][0]==1: print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:1" waiting for ur opinion. thanks -- View this message in context: http://www.nabble.com/new--user-needs-help%21-tp16571823p16596608.html Sent from the Python - python-list mailing list archive at Nabble.com. From arnodel at googlemail.com Sun Apr 27 13:00:54 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 27 Apr 2008 18:00:54 +0100 Subject: removing extension References: <67jok9F2o7iv7U2@mid.uni-berlin.de> Message-ID: Marc 'BlackJack' Rintsch writes: > Not exactly. In the case of no extension `os.path.splitext()` still works: > > In [14]: 'foo/bar.txt'.rsplit('.') > Out[14]: ['foo/bar', 'txt'] > > In [15]: 'foo/bar'.rsplit('.') > Out[15]: ['foo/bar'] > > In [16]: os.path.splitext('foo/bar') > Out[16]: ('foo/bar', '') And crucially, it still works correctly if the file has no extension but a directory in the path has one: >>> 'foo.baz/bar'.rsplit('.') ['foo', 'baz/bar'] >>> os.path.splitext('foo.baz/bar') ('foo.baz/bar', '') Conclusion: forget about str.rsplit() (which I suggested), use os.path.splitext() instead :) -- Arnaud From gagsl-py2 at yahoo.com.ar Fri Apr 25 22:14:40 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 25 Apr 2008 23:14:40 -0300 Subject: Newbie question about import References: <27308d500804251103t71d04b5fg1de6658ceab9d898@mail.gmail.com> Message-ID: En Fri, 25 Apr 2008 15:03:18 -0300, Luca escribi?: > Hi all. I'm trying to do something with python import but isn't working > for me. > > Using python 2,5 I've a program structured like this: > > * a main module called (for example) "mommy" with an __init__.py and a > file called "mommy.py" > * a __version__ var defined inside the main __init__.py > >> From the mommy.py file I need to import the __version__ var, but I'm > really not able to do this! I fear this is a very stupid task to do... > my problem is that the file is called like the module. > > Anyone can point me to the solution? The short answer is: don't do that! __init__.py may import any module, but other modules in the package should not import anything from __init__.py The same rule applies to the main module in an application: it can import any other required module, but no one should import main. If you don't follow those rules you may encounter some surprises. You *can* break the rules and actually do what you want, but I would not reccomend it. In this case, can't you switch the place where __version__ is defined? It looks like a constant, so you could have it actually defined in mommy.py, and inside __init__.py just import the value. -- Gabriel Genellina From deets at nospam.web.de Thu Apr 17 18:59:39 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 18 Apr 2008 00:59:39 +0200 Subject: py3k s***s In-Reply-To: References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> Message-ID: <66q33cF2krjf2U1@mid.uni-berlin.de> > And I have been benefiting from Python in general, so far. Thanks, > community. > > But now... I'll probably stop posting here for now, & I may stop other > things too. > > Just my 2c. You know what I was just wondering about? All these C-written cross-platform libraries (which Python users benefit from, most probably including evven you) that run on different unixes & windows, which are a much greater diversity to handle than the not-even-yet-settled differences between Py3K & 2.x. How the heck do they do that? Oh, and these dreaded 64 bit processors, possibly with multi-cores, which need changes in code as well, to be utilized to their power. But then, these guys most probably don't whine about diversity and constant change, and cry out useless threats to people who probably can't care less. Fare well, if you must. But getting mad over something which impact you can't even judge right now is childish. Nothing else. Diez From v.harishankar at gmail.com Tue Apr 22 23:09:49 2008 From: v.harishankar at gmail.com (Harishankar) Date: Wed, 23 Apr 2008 08:39:49 +0530 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: References: Message-ID: <200804230839.49560.v.harishankar@gmail.com> On Wednesday 23 Apr 2008 02:25:14 Christian Heimes wrote: > Nick Craig-Wood schrieb: > > Nothing apart from the fact it doesn't work on windows. The buffering > > will cause you grief too. If you want to do this properly under unix > > use pexpect not subprocess. > > > > http://www.noah.org/wiki/Pexpect > > > > Proper non blocking IO is an absolute nightmare under Windows in my > > experience! It really isn't the Windows way so you are fighting the > > system the whole time. > > Nick is correct. The subproces tries to work around the issues with > threads. But it's no more than an ugly workaround fir Windows' short > comings on async file IO. It's a shame Windows implements the select() > syscall in wsock32 and limits its usage to sockets. > > By the way I'm willing to dedicate some time to help enhancing the > subprocess. Everybody is invited to submit patches and I'll review and > check them into the trunk and py3k ASAP. Any help is appreciated: > enhancements for async IO, doc updates, more examples ... > > Christian > Python core developer Thanks a lot to everybody who's been following this discussion. Very interesting indeed. I'm currently thinking of working around this problem by actually opening a new terminal window and running the command from there, thus allowing the user full control over the process. Is there any platform independent way to launch a terminal window from a desktop (Windows, Linux, etc.)? -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org From lists at cheimes.de Sat Apr 12 08:41:42 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 12 Apr 2008 14:41:42 +0200 Subject: Multiple independent Python interpreters in a C/C++ program? In-Reply-To: <669jv8F2jrimvU1@mid.uni-berlin.de> References: <669jv8F2jrimvU1@mid.uni-berlin.de> Message-ID: Diez B. Roggisch schrieb: > AFAIK there was a thread a few month ago that stated that this is > actually possible - but mostly 3rd-party-c-extension aren't capable of > supporting that. Martin von Loewis had a word in that, maybe googling > with that in mind reveals the discussion. > > And of course its a *bad* idea to pass objects between threads... http://www.python.org/dev/peps/pep-3121/ Christian From tracyde at gmail.com Thu Apr 3 14:31:37 2008 From: tracyde at gmail.com (Derek Tracy) Date: Thu, 3 Apr 2008 14:31:37 -0400 Subject: Manipulate Large Binary Files In-Reply-To: <7xlk3vctea.fsf@ruckus.brouhaha.com> References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> <9999810b0804021109n77f2c990p7b10d92e9344ad00@mail.gmail.com> <7xlk3vctea.fsf@ruckus.brouhaha.com> Message-ID: <1247DD9D-C204-48C3-B624-6F79FE96B89C@gmail.com> --------------------------- Derek Tracy tracyde at gmail.com --------------------------- On Apr 3, 2008, at 3:03 AM, Paul Rubin <"http:// phr.cx"@NOSPAM.invalid> wrote: > Derek Martin writes: >>> Both are clocking in at the same time (1m 5sec for 2.6Gb), are there >>> any ways I can optimize either solution? > > Getting 40+ MB/sec through a file system is pretty impressive. > Sounds like a RAID? > >> That said, due to normal I/O generally involving double-buffering, >> you >> might be able to speed things up noticably by using Memory-Mapped I/O >> (MMIO). It depends on whether or not the implementation of the >> Python >> things you're using already use MMIO under the hood, and whether or >> not MMIO happens to be broken in your OS. :) > > Python has the mmap module and I use it sometimes, but it's not > necessarily the right thing for something like this. Each page you > try to read from results in own delay while the resulting page fault > is serviced, so any overlapped i/o you get comes from the OS being > nice enough to do some predictive readahead for you on sequential > access if it does that. By coincidence there are a couple other > threads mentioning AIO which is a somewhat more powerful mechanism. > > -- > http://mail.python.org/mailman/listinfo/python-list From fw3 at hotmail.co.jp Thu Apr 3 16:03:43 2008 From: fw3 at hotmail.co.jp (wang frank) Date: Thu, 3 Apr 2008 20:03:43 +0000 Subject: Is Leo better than Vim and emacs? In-Reply-To: <3H6Jj.17$i_5.5@newsfe06.lga> References: <3H6Jj.17$i_5.5@newsfe06.lga> Message-ID: Hi, Thanks for developing Leo. I have been using Vim for long time to write code. Is it a good time to switch to Leo? what is the advantage of Leo against vim and emacs? Thanks Frank _________________________________________________________________ ?????????????????IE7?MSN??????????????? http://promotion.msn.co.jp/ie7/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin.laloux at gmail.com Sun Apr 20 05:19:07 2008 From: martin.laloux at gmail.com (martin.laloux at gmail.com) Date: Sun, 20 Apr 2008 02:19:07 -0700 (PDT) Subject: installing MySQLdb module References: <80f805f0-6829-4da3-bfb4-79875bb16114@a22g2000hsc.googlegroups.com> Message-ID: search, search, search http://groups.google.be/group/comp.lang.python/browse_thread/thread/d75a491b8dbc3880/7d4f8eea29e23992?hl=fr&lnk=gst&q=MySQLdb+mac#7d4f8eea29e23992 From smmehadi at gmail.com Mon Apr 7 23:35:29 2008 From: smmehadi at gmail.com (syed mehdi) Date: Tue, 8 Apr 2008 09:05:29 +0530 Subject: ImportError: No module named MySQLdb Message-ID: <12b075a10804072035j42c85d4m3e4b45778d9697c4@mail.gmail.com> Hi Guys, I have been working in python from some time now, while writing a python script i used: import MySQLdb in my script to do some database related operations. When i tried to execute the same script on another system it gave me an error as: "ImportError: No module named MySQLdb" though mysqldb was already installed on that system, and python 2.5.2 was present on that machine. i have tried uninstalling and installing of mysql again and again but to no avail. please help me resolve the issue. Thanks & Regards Syed -------------- next part -------------- An HTML attachment was scrubbed... URL: From bbxx789_05ss at yahoo.com Tue Apr 1 01:12:27 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Mon, 31 Mar 2008 22:12:27 -0700 (PDT) Subject: Looking for indent advice howto in emacs python-mode References: Message-ID: <82ac2b10-dae7-4d63-bc8e-29bf47ad7385@n58g2000hsf.googlegroups.com> On Mar 31, 10:32?am, "Steven W. Orr" wrote: > Here's what I want to do: > > if ( ( v == 1 ) > ? ?or ( v == 2 ) > ? ?or ( v == 3 ) ): > ? ? ?pass > python indenting = 4 spaces From wuwei23 at gmail.com Wed Apr 2 06:52:33 2008 From: wuwei23 at gmail.com (alex23) Date: Wed, 2 Apr 2008 03:52:33 -0700 (PDT) Subject: the scaling of pics in pygame References: <49d8b8ae-08e3-4e86-9ced-2804b6dec4e5@b5g2000pri.googlegroups.com> Message-ID: <3c28d833-b336-4665-a692-d9d462a355c2@q27g2000prf.googlegroups.com> On Apr 2, 12:44 pm, Jimmy wrote: > I am using Pygame to write a small program. I tried to load a .jpg > picture into > the screen, however, the size of the pic doesn't fit into the window > properly. Can > anyone tell me how to scale the picture into the window? Have you tried the Pygame documentation? http://www.pygame.org/docs/ref/transform.html#pygame.transform.scale - alex23 From kay.schluehr at gmx.net Fri Apr 4 15:18:48 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Fri, 4 Apr 2008 12:18:48 -0700 (PDT) Subject: Tokenizer inconsistency wrt to new lines in comments References: <1ce40dcf-4a0a-4577-af3b-6a77ef71356c@f63g2000hsf.googlegroups.com> Message-ID: <6dd69a1f-96d0-4b91-b84b-a54794a31c70@u36g2000prf.googlegroups.com> On 4 Apr., 18:22, George Sakkis wrote: > The tokenize.generate_tokens function seems to handle in a context- > sensitive manner the new line after a comment: > > >>> from StringIO import StringIO > >>> from tokenize import generate_tokens > > >>> text = ''' > > ... # hello world > ... x = ( > ... # hello world > ... ) > ... ''' > > >>> for t in generate_tokens(StringIO(text).readline): > > ... print repr(t[1]) > ... > '\n' > '# hello world\n' > 'x' > '=' > '(' > '\n' > '# hello world' > '\n' > ')' > '\n' > '' > > Is there a reason that the newline is included in the first comment > but not in the second, or is it a bug ? > > George I guess it's just an artifact of handling line continuations within expressions where a different rule is applied. For compilation purposes both the newlines within expressions as well as the comments are irrelevant. There are even two different token namely NEWLINE and NL which are produced for newlines. NL and COMMENT will be ignored. NEWLINE is relevant for the parser. If it was a bug it has to violate a functional requirement. I can't see which one. Kay From fabiofz at gmail.com Wed Apr 9 14:11:21 2008 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Wed, 9 Apr 2008 15:11:21 -0300 Subject: Pydev shell (was: Re: Stani's python ide 'spe' editor problem) Message-ID: > Anyway, I am extremely frustrated. I've tried other ide's: pythonwin (I > found it inadequate for my purposes - why is a command line prompt > displayed in a dialog window?) - eclipse (editor is just ok, shell does > not have command history(!), and then *really* funky things started > happening that I could not explain and so had to stop using it) - idle > is good for small things and ok for larger projects but limited in general. Hi Rick, The new release has an actual console shell (with code-completion, history, etc: see http://pydev.sourceforge.net/ for more details). Aside from that, which 'funky' things started happening? Cheers, Fabio From jr9445 at ATT.COM Wed Apr 9 16:11:05 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Wed, 9 Apr 2008 15:11:05 -0500 Subject: Stripping scripts from HTML with regular expressions In-Reply-To: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> References: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: > -----Original Message----- > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > list-bounces+jr9445=att.com at python.org] On Behalf Of Michel Bouwmans > Sent: Wednesday, April 09, 2008 3:38 PM > To: python-list at python.org > Subject: Stripping scripts from HTML with regular expressions > > Hey everyone, > > I'm trying to strip all script-blocks from a HTML-file using regex. > > I tried the following in Python: > > testfile = open('testfile') > testhtml = testfile.read() > regex = re.compile(']*>(.*?)', re.DOTALL) > result = regex.sub('', blaat) > print result > > This strips far more away then just the script-blocks. Am I missing > something from the regex-implementation from Python or am I doing > something > else wrong? > [Insert obligatory comment about using a html specific parser (HTMLParser) instead of regexes.] Actually your regex didn't appear to strip anything. You probably saw stuff disappear because blaat != testhtml: testhtml = testfile.read() result = regex.sub('', blaat) Try this: import re testfile = open('a.html') testhtml = testfile.read() regex = re.compile('(.*?)', re.DOTALL) result = regex.sub('',testhtml) print result From mikael at isy.liu.se Fri Apr 11 11:19:50 2008 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 11 Apr 2008 17:19:50 +0200 Subject: Rounding a number to nearest even In-Reply-To: <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> Message-ID: cokofreedom at gmail.com commented about rounding towards even numbers from mid-way between integers as opposed to for instance always rounding up in those cases: > Strange request though, why do you need it that way, because 2.5 is > CLOSER to 3 than to 2... That's exactly how I was taught to do rounding in what-ever low-level class it was. The idea is to avoid a bias, which assumes that the original values are already quantized. Assume that we have values quantized to one decimal only, and assume that all values of this decimal are equally likely. Also assume that the integer part of our numbers are equally likely to be even or odd. Then the average rounding error when rounding to integers will be 0.05 if you always round up when the decimal is 5. If you round towards an even number instead when the decimal is 5, then you will round up half of those times, and round down the other half, and the average rounding error will be 0. That's the idea. Of course you could argue that it would be even more fair to make the choice based on the tossing of a fair coin. Note that if you do not have quantized values and assuming that the fraction part is evenly distributed between 0 and 1, than this whole argument is moot. The probability of getting exactly 0.5 is zero in that case, just as the probability of getting any other specified number is zero. That said, measurements are in practice always quantized, and rounding towards an even number when mid-way between avoids an average error of half the original precision. As a side-note: The the smallest coin in Swedish currency SEK is 0.50, but prices in stores are given with two decimals, i.e. with precision 0.01. But what if your goods add up to 12.34? The standard in Swedish stores, after adding the prices of your goods, is to round the number to the nearest whole or half SEK, which means that decimals 25 and 75 are mid-way between. In those cases the rounding is usually done to the nearest whole SEK, which is based on precicely the above reasoning. If they did not do that, I could argue that they are stealing on average 0.005 SEK from me every time I go to the store. Well... I could live with that, since 0.005 SEK is a ridiculously small amount, and even if I make thousands of such transactions per year, it still sums up to a neglectable amount. Another side-note: My 12-year old son is now being taught to always round up from mid-way between. Yet another example of the degradation of maths in schools. /MiO From mccle27252 at gmail.com Mon Apr 21 03:52:35 2008 From: mccle27252 at gmail.com (mccle27252 at gmail.com) Date: Mon, 21 Apr 2008 00:52:35 -0700 (PDT) Subject: pes 6 stadium patch download Message-ID: <4549f459-bba8-4889-8a40-6e866cded233@b5g2000pri.googlegroups.com> pes 6 stadium patch download http://cracks.00bp.com F R E E C R A C K S From pavlovevidence at gmail.com Tue Apr 22 14:53:25 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 22 Apr 2008 11:53:25 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> Message-ID: <8460ba2c-c6fd-41e7-a4a9-6dc2892d6ac8@l42g2000hsc.googlegroups.com> On Apr 22, 12:50 pm, J?r?my Wagner wrote: > Sure. Python is more readable than Perl, though I have found Python > to have a weird behavior regarding this little issue : > > How can you explain that Python doesn't support the ++ opeator, > whereas at the same time it does support the += operator ??? Because "Features A and B are in language X. Python adds Feature A. Therefore Python must also add Feature B (or it'll be weird)" is not valid logic. Carl Banks From dennis.benzinger at gmx.net Thu Apr 10 09:28:45 2008 From: dennis.benzinger at gmx.net (Dennis.Benzinger@gmx.net) Date: Thu, 10 Apr 2008 06:28:45 -0700 (PDT) Subject: tkinter, overwrite Label-text? References: Message-ID: On Apr 10, 2:35 pm, skanem... at yahoo.se wrote: > using python And tkinter. > > i have a GUI that outputs a text among other things. after input form > user i want this text to be *)cleared and/or > *)overwritten. > > what is the best way to achieve that? > [...] Which widget do you use? Some widgets can be connected to variables so that when the variable changes the widget is automatically update. Have a look . HTH, Dennis Benzinger From bruno.desthuilliers at gmail.com Wed Apr 2 14:04:00 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 11:04:00 -0700 (PDT) Subject: class / module introspection? References: Message-ID: <3c3f09df-08cb-4309-a870-6b12a813a8af@u36g2000prf.googlegroups.com> On 2 avr, 18:03, Brian Munroe wrote: > I'm struggling with an architectural problem and could use some > advice. > > I'm writing an application that will gather statuses from disparate > systems. Because new systems show up all the time, I'm trying to > design a plugin architecture that will allow people to contribute new > backends by just dropping a package/module into a specific directory. > The object methods in these backends will conform to a documented API > that the main application will call. > > Currently I have something that looks like this: > > src/ > backends/ > system1/ > __init__.py > system2/ > __init__.py > ... > > Then from my application (main.py) I can simply call: > > from backends import system1 > > be1 = system1.Backend() > be1.getStatus() > > This would work great if I knew about system1 and system2 ahead of > time, but that isn't the case. Having to rewrite main.py every time a > new backend module comes along is obviously a stupid idea too. I've > been thinking I need some kind of introspection, but I've been reading > about it and a whole mess of design pattern stuff, so my head is > swimming and I am totally unsure of what the best approach is. > > My guess is that I need to load all the backends at runtime Anyway, almost everything happens at runtime in Python !-) More seriously: the answer is in the doc. http://www.python.org/doc/2.3.5/lib/built-in-funcs.html read about the __import__ function, experiment in your interactive python shell, and you should be done in a couple minutes. From schettino72 at gmail.com Sat Apr 19 15:39:57 2008 From: schettino72 at gmail.com (Eduardo Schettino) Date: Sun, 20 Apr 2008 01:09:57 +0530 Subject: random.random(), random not defined!? In-Reply-To: <2a3931f5-481d-4831-baad-fcc9f0c0c129@m73g2000hsh.googlegroups.com> References: <2a3931f5-481d-4831-baad-fcc9f0c0c129@m73g2000hsh.googlegroups.com> Message-ID: On Sun, Apr 20, 2008 at 12:58 AM, globalrev wrote: > do i need to import something to use random? > -- you need to import random :) Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import random >>> random.random() 0.76018998919085967 From domiriel at gmail.com Mon Apr 21 10:44:15 2008 From: domiriel at gmail.com (domiriel at gmail.com) Date: Mon, 21 Apr 2008 07:44:15 -0700 (PDT) Subject: Finding the selected file in Windows Explorer Message-ID: Hi! I need to find the selected file(s) in a Windows Explorer window from another program (I'd look at the window that last had focus). I found something in the following page that should do the trick: http://blogs.msdn.com/oldnewthing/archive/2004/07/20/188696.aspx However, it is not Python and, while I'm a competent Python programmer, Win32, COM and the like are somewhat outside my competences. Does any one know how to do something similar in Python? Tks! Domiriel From rridge at caffeine.csclub.uwaterloo.ca Fri Apr 18 16:37:21 2008 From: rridge at caffeine.csclub.uwaterloo.ca (Ross Ridge) Date: Fri, 18 Apr 2008 16:37:21 -0400 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> Message-ID: Bob Greschke wrote: >I'm reading 3-byte numbers from a file and they are signed (+8 to >-8million). This seems to work, but I'm not sure it's right. > ># Convert the 3-characters into a number. > Value1, Value2, Value3 = unpack(">BBB", Buffer[s:s+3]) > Value = (Value1*65536)+(Value2*256)+Value3 > if Value >= 0x800000: > Value -= 0x1000000 > print Value > >For example: >16682720 = -94496 > >Should it be Value -= 0x1000001 so that I get -94497, instead? Your first case is correct, "Value -= 0x1000000". The value 0xFFFFFFF should be -1 and 0xFFFFFFF - 0x1000000 == -1. An alternative way of doing this: Value = unpack(">l", Buffer[s:s+3] + "\0")[0] >> 8 Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] rridge at csclub.uwaterloo.ca -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // From eatham at gmail.com Fri Apr 11 16:39:10 2008 From: eatham at gmail.com (Roger Dahlstrom) Date: Fri, 11 Apr 2008 13:39:10 -0700 (PDT) Subject: Windows - window status (Running vs Not Responding) References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> Message-ID: <22aa2ee2-6df9-4884-9aaf-232250a8c23f@y21g2000hsf.googlegroups.com> On Apr 11, 3:46 pm, Tim Golden wrote: > rdahlstrom wrote: > > On Apr 11, 1:45 pm, rdahlstrom wrote: > >> Does anyone know how to determine the window status (Running or Not > >> Responding)? I've tried various methods with no success... > > >> This would be on a variety of Windows systems, but all at least XP, > >> and mostly server 2003. Everyone will have Python 2.5.1 on them, and > >> the script would be running locally. > > >> Any ideas? > > > Basically, I'm looking for something similar to the Process.Responding > > property in System.Diagnostics... > > Well one (slightly drastic) possibility might be to use IronPython [1] > or Python.NET [2] to invoke the .Net functionality directly. AFAIK there > is no direct alternative: I believe that WMI can be a useful match > for System.Diagnostics but doesn't deal with windows (ie user-interface > elements). Presumably you could find a top-level window for each > process, using something vaguely like this [3] coupled with this [4] > and send it a suitable SendMessage to "ping" it. Haven't done it myself > but can't see why it shouldn't work. > > All a bit handwavey but maybe it'll point you somewhere... > > TJG > > [1]http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython > [2]http://pythonnet.sourceforge.net/ > [3]http://timgolden.me.uk/python/wmi_cookbook.html#running_processes > [4]http://timgolden.me.uk/python/win32_how_do_i/find-the-window-for-my-s... You know, I thought about sending it a message, but I found that, in testing, I am able to move, resize, and copy text from a "Not Responding" window. I was having a tough time figuring out a suitable message that I could send a generic window, one that I had no idea about what it had available to me. Other than sending it a graceful exit message (which I really don't want to do), have you any ides about what to send it? From sn at sncs.se Mon Apr 14 21:02:38 2008 From: sn at sncs.se (Sverker Nilsson) Date: Mon, 14 Apr 2008 18:02:38 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> Message-ID: <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> On Apr 15, 1:34 am, Steve Holden wrote: > Sverker Nilsson wrote: > > do i dare to open a thread about this? > > > come on you braver men > > > we are at least not bought by g***le > > > but why? others have said it so many times i think > > > :-//// > > > but why? a few syntactic 'cleanups' for the cost of a huge rewrite of I have sobered up abit, it doesnt matter much I tried out py3k on my project, http://guppy-pe.sf.net And i have looked into py3k also at the list and read quite a bit about it. no fun, to me at least Try it yourself, all contributions are welcome of course Sverker > > all the code that have been builtup from all the beginning when the > > once great Python came along and people began to use it and write code > > for it. Like all that code would have to be rewritten. blaah. > > and i have perhaps been drinking but i have been p**d all week since i > > began look into this:-( > > Perhaps you should sober up and look at the reality of Python 3, which > has deliberately avoided a complete rewrite. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ From python at bdurham.com Mon Apr 21 19:05:46 2008 From: python at bdurham.com (python at bdurham.com) Date: Mon, 21 Apr 2008 19:05:46 -0400 Subject: Does Python 2.5 include or not include SQLite engine? In-Reply-To: References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> Message-ID: <1208819146.23409.1249124463@webmail.messagingengine.com> While reading feedback to my post "Does Python 2.5.2's embedded SQLite support full text searching?" I noticed that there appears to be some confusion regarding whether Python 2.5 includes the SQLite engine. My Windows 2.5.2 binary download includes SQLite. But other posters claim otherwise, re: Linux releases of Python 2.5? I thought one of the major features of Python 2.5 was its embedded SQLite engine. Thoughts? Malcolm From nospam at nospam.invalid Tue Apr 29 20:06:49 2008 From: nospam at nospam.invalid (Rahul) Date: Wed, 30 Apr 2008 00:06:49 +0000 (UTC) Subject: python command mis-interprets arrow keys References: <67pp4oF2ppl3sU1@mid.uni-berlin.de> <67pq47F2plmb8U1@mid.uni-berlin.de> Message-ID: "Diez B. Roggisch" wrote in news:67pq47F2plmb8U1 @mid.uni-berlin.de: > > The question is if python is build with readline support. Did the python > version work before, and somehow got messed up, or did you build it > yourself and it never actually worked? I suspect we upgraded our RHEL and that broke it. Has never worked after. Is there a way to extract what cmd-line options my python was compiled with? Might be worth it before I go the long-painful route of re-installing. -- Rahul From python at bdurham.com Fri Apr 25 09:50:56 2008 From: python at bdurham.com (python at bdurham.com) Date: Fri, 25 Apr 2008 09:50:56 -0400 Subject: multiple pattern regular expression In-Reply-To: References: Message-ID: <1209131456.20871.1249849011@webmail.messagingengine.com> How about this? for line in file: # ignore lines without = assignment if '=' in line: property, value = line.strip().split( '=', 1 ) property = property.strip().lower() value = value.strip() # do something with property, value Malcolm From andrei.avk at gmail.com Sat Apr 5 09:45:55 2008 From: andrei.avk at gmail.com (AK) Date: Sat, 05 Apr 2008 08:45:55 -0500 Subject: Python-by-example - new online guide to Python Standard Library In-Reply-To: References: <47f2d018$0$6517$4c368faf@roadrunner.com> <47f617b0$0$16689$4c368faf@roadrunner.com> Message-ID: <47f77492$0$1096$4c368faf@roadrunner.com> ivan wrote: > Very cool. > Have you thought about making a printable version that doesn't wrap > any lines that shouldn't be and has page breaks at good spots? > > -- > ivan Hi ivan, I will work on that after I finalize modules that are already there. I think this would be better than having people print out the guide and then either have print out again in a couple of weeks or stuck with using a very outdated guide. So, I think it will be one to three weeks at most before printable version is available.. Glad you like Python by Example! thx, -- -ak Tobu | http://tobu.lightbird.net/ | Freeform DB / Tagger / PIM Python-by-Example | http://pbe.lightbird.net/ | Guide to LibRef From andrew at acooke.org Fri Apr 25 23:02:21 2008 From: andrew at acooke.org (andrew cooke) Date: Fri, 25 Apr 2008 20:02:21 -0700 (PDT) Subject: Logging ancestors ignored if config changes? Message-ID: <7770a385-e26d-4ad9-bc72-fa1228034c3b@26g2000hsk.googlegroups.com> Hi, I am seeing some odd behaviour with logging which would be explained if loggers that are not defined explicitly (but which are controlled via their ancestors) must be created after the logging system is configured via fileConfig(). That's a bit abstract, so here's the problem itself: I define my log within a module by doing import logging log = logging.getLogger(__name__) Now typically __name__ will be something like "acooke.utils.foo". That happens before the application configures logging, which it does by calling logging.config.fileConfig() to load a configuration. If I do that, then I don't see any logging output from "acooke.utils.foo" (when using "log" from above after "fileConfig" has been called) unless I explicitly define a logger with that name. Neither root nor an "acooke" logger, defined in the config file, are called. Is this a bug? Am I doing something stupid? To me the above seems like a natural way of using the system... Thanks, Andrew From castironpi at gmail.com Wed Apr 16 08:26:28 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 16 Apr 2008 05:26:28 -0700 (PDT) Subject: Preferred method for "Assignment by value" References: <8562becb-9fef-415d-9640-05ef80123596@a5g2000prg.googlegroups.com> <534f02b3-1eda-4332-96ae-3db3d4b4f44a@s33g2000pri.googlegroups.com> Message-ID: On Apr 15, 3:51?pm, sturlamolden wrote: > On Apr 15, 8:19 pm, hall.j... at gmail.com wrote: > > > Coming from VBA I have a tendency to think of everything as an > > array... > > Coding to much in Visual Basic, like Fortran 77, is bad for your mind. The distinction you're looking for is: VB: set a= collection a= collection Every assignment is a 'set'. From floris.bruynooghe at gmail.com Fri Apr 11 05:16:17 2008 From: floris.bruynooghe at gmail.com (Floris Bruynooghe) Date: Fri, 11 Apr 2008 02:16:17 -0700 (PDT) Subject: @x.setter property implementation References: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> <02cb2845-6a25-4e90-9f82-dbd68b37a5e6@p39g2000prm.googlegroups.com> <2c589c82-85e9-4db6-b8f9-156b06dd51f3@s33g2000pri.googlegroups.com> Message-ID: On Apr 10, 5:09 pm, Arnaud Delobelle wrote: > On Apr 10, 3:37 pm, Floris Bruynooghe > wrote: > > > > > On Apr 7, 2:19 pm, "Andrii V. Mishkovskyi" wrote: > > > > 2008/4/7, Floris Bruynooghe : > > > > > Have been grepping all over the place and failed to find it. I found > > > > the test module for them, but that doesn't get me very far... > > > > I think you should take a look at 'descrobject.c' file in 'Objects' directory. > > > Thanks, I found it! So after some looking around here was my > > implementation: > > > class myproperty(property): > > def setter(self, func): > > self.fset = func > > > But that doesn't work since fset is a read only attribute (and all of > > this is implemented in C). > > > So I've settled with the (nearly) original proposal from Guido on > > python-dev: > > > def propset(prop): > > assert isinstance(prop, property) > > @functools.wraps > > def helper(func): > > return property(prop.fget, func, prop.fdel, prop.__doc__) > > return helper > > > The downside of this is that upgrade from 2.5 to 2.6 will require code > > changes, I was trying to minimise those to just removing an import > > statement. > > > Regards > > Floris > > Here's an implementation of prop.setter in pure python < 2.6, but > using sys._getframe, and the only test performed is the one below :) > > import sys > > def find_key(mapping, searchval): > for key, val in mapping.iteritems(): > if val == searchval: > return key > > _property = property > > class property(property): > def setter(self, fset): > cls_ns = sys._getframe(1).f_locals > propname = find_key(cls_ns, self) > # if not propname: there's a problem! > cls_ns[propname] = property(self.fget, fset, > self.fdel, self.__doc__) > return fset > # getter and deleter can be defined the same way! > > # -------- Example ------- > > class Foo(object): > @property > def bar(self): > return self._bar > @bar.setter > def setbar(self, x): > self._bar = '<%s>' % x > > # -------- Interactive test ----- > > >>> foo = Foo() > >>> foo.bar = 3 > >>> foo.bar > '<3>' > >>> foo.bar = 'oeufs' > >>> foo.bar > '' > > Having fun'ly yours, Neat! Unfortunatly both this one and the one I posted before work when I try them out on the commandline but both fail when I try to use them in a module. And I just can't figure out why. Floris From ott.deb at gmail.com Thu Apr 17 15:04:11 2008 From: ott.deb at gmail.com (ott.deb at gmail.com) Date: Thu, 17 Apr 2008 12:04:11 -0700 (PDT) Subject: rks fax crack Message-ID: <2c7200b1-bdb0-4f3f-a1bb-b7b55e621d61@f36g2000hsa.googlegroups.com> rks fax crack http://cracks.12w.net F R E E C R A C K S From jzgoda at o2.usun.pl Thu Apr 3 09:56:01 2008 From: jzgoda at o2.usun.pl (Jarek Zgoda) Date: Thu, 03 Apr 2008 15:56:01 +0200 Subject: object-relational mappers In-Reply-To: <47f37039$0$31900$426a74cc@news.free.fr> References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <47f37039$0$31900$426a74cc@news.free.fr> Message-ID: Bruno Desthuilliers napisa?(a): > Now my own experience is that whenever I tried this approach for > anything non-trivial, I ended up building an "ad-hoc, > informally-specified bug-ridden slow implementation of half of " > SQLAlchemy. Which BTW is not strictly an ORM, but primarily an attempt > at a better integration of SQL into Python. So while it may feel like > learning the inner complexities of SQLALchemy (or Django's ORM which is > not that bad either) is "wasting brain cells", MVHO is that it's worth > the time spent. But YMMV of course - IOW, do what works best for you. I like OR mappers, they save me lot of work. The problem is, all of them are very resource hungry, processing resultset of 300k objects one by one can effectively kill most of commodity systems. This is where raw SQL comes in handy. -- Jarek Zgoda Skype: jzgoda | GTalk: zgoda at jabber.aster.pl | voice: +48228430101 "We read Knuth so you don't have to." (Tim Peters) From stanc at al.com.au Fri Apr 18 05:04:08 2008 From: stanc at al.com.au (Astan Chee) Date: Fri, 18 Apr 2008 19:04:08 +1000 Subject: testing client-server sockets In-Reply-To: References: <4808627F.5040906@al.com.au> Message-ID: <48086408.4070205@al.com.au> Server code: import os, sys, socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host = '' port = 5602 s.bind((host,port)) try: s.listen(1) while 1: conn, addr = s.accept() print 'client is at', addr data = conn.recv(1000000) data = data * 10 z = raw_input() conn.send(data) conn.close() except Exception: s.close() Client code: import sys, os, socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host = 'hostIP' port = 5602 s.connect((host,port)) s.send(dlg.user.GetValue()) i =0 while True: data = s.recv(1000000) i+=1 if (i<5): print data if not data: break print 'received', len(data), 'bytes' s.close() David Harrison wrote: > On 18/04/2008, Astan Chee wrote: > >> Hi, >> I have a client-server socket script in python. Something like this >> http://ubuntuforums.org/showthread.php?t=208962 >> Now the problem I have is that I want to try to connect the client to >> the server on the same machine, but it gives me a 'port already in use' >> error. I just want the client to connect to the server for testing >> purposes. Any suggestions on how I should do this? >> Thanks >> Astan >> > > Can you post the client / server code for us ? It sounds like it's > likely to be a minor bug. > > -- "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." Animal Logic http://www.animallogic.com Please think of the environment before printing this email. This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. -------------- next part -------------- An HTML attachment was scrubbed... URL: From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 3 04:33:34 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 03 Apr 2008 10:33:34 +0200 Subject: Python in High School In-Reply-To: References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: <47f4965f$0$29986$426a74cc@news.free.fr> Jan Claeys a ?crit : (snip) > I learned about pointers while learning Pascal (and later embedded > assembler) using Borland's tools. > > Later I learned C (and even later C++), and I've always been wondering why > those languages were making simple things so complicated... > Similar pattern here : I had difficulties grasping pointers in C, then learned them in Pascal and got enlightned. Then I was able to use them correctly in C. From bijeshn at gmail.com Wed Apr 2 08:05:45 2008 From: bijeshn at gmail.com (bijeshn at gmail.com) Date: Wed, 2 Apr 2008 05:05:45 -0700 (PDT) Subject: splitting an XML file on the basis on basis of XML tags Message-ID: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> Hi all, i have an XML file with the following structure:: -----| | | . | . | --------------------> constitutes one record. . | . | . | | | ----| . . . -----------------------| . | . | . |----------------------> there are n records in between.... . | . | . | . ------------------------| . . -----| | | . | . | --------------------> constitutes one record. . | . | . | | | ----| Here is the main root tag of the XML, and ... constitutes one record. What I would like to do is to extract everything (xml tags and data) between nth tag and (n +k)th tag. The extracted data is to be written down to a separate file. Thanks... From gagsl-py2 at yahoo.com.ar Wed Apr 2 17:57:09 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 02 Apr 2008 18:57:09 -0300 Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> Message-ID: En Wed, 02 Apr 2008 09:23:21 -0300, sam escribi?: > Gabriel Genellina napisa?(a): > >>>>> 1. You have different syntax for named and unnamed (lambdas) >>>>> functions. Functions and methods are different things in Python even >>>>> if they have same syntax. But all these are still a pieces of code >>>>> that you use repeatedly to make some task. >>>>> >>>> A knife and scissors are both used to cut things, but that doesn't >>>> mean >>>> they are the same. >>> >>> Well -- sometimes you have to use many, many types of scissors. >> >> I don't get the point - weren't you criticizing Python for having many >> different kind of functions? > > Yes. Funciton is always a piece of code (program) that does something. > There is > no need for different syntax. Guido has regretted lambda for a long time; it was scheduled for deletion on Python 3000 [2] but finally will stay [3]. Class methods and instance methods are not just standard functions; instance methods were plain functions before 2.2 and the Class object was in charge of doing the "self magic". Now the descriptor protocol provides far more possibilities. > And you said that it is good to have these two types of syntax. It > sounds like: > "it is good to have knife and scissors to cut the _same_ thing, because > they are > not the same". I didn't say that (note that you trimmed most attribution lines) but I like to have "short anonymous functions" altough the syntax might be different. Perhaps in Python 4000. >> What are those programmers needs? > > Programmers need to protect name in a namespace. Name mangling is not > the best > choice. Why to "protect" names in a namespace? We are all adults here. Name mangling is a reasonable and simple way to avoid name conflicts in a shared namespace. I don't know whether it's the "best" way or not, but has worked fine for me for a long time. [1] http://www.python.org/doc/essays/ppt/regrets/PythonRegrets.ppt (couldn't find easily an older reference, but there are) [2] http://www.artima.com/weblogs/viewpost.jsp?thread=98196 [3] http://mail.python.org/pipermail/python-dev/2006-February/060415.html -- Gabriel Genellina From hniksic at xemacs.org Tue Apr 15 03:24:26 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Tue, 15 Apr 2008 09:24:26 +0200 Subject: Dynamic use of property() fails References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> Message-ID: <871w5760np.fsf@mulj.homelinux.net> "Gabriel Genellina" writes: > The "magic" happens when the descriptor is found in the *class*, not > in the instance. I think it's detailed in Hettinger's document. The document is wrong here: Alternatively, it is more common for a descriptor to be invoked automatically upon attribute access. For example, obj.d looks up d in the dictionary of obj. If d defines the method __get__, then d.__get__(obj) is invoked according to the precedence rules listed below. This sounds plausible and might have led Andrew to believe that his code should work. It should instead say "in the dictionary of obj's type" or something to that effect. I asked Raymond about it some time ago, and he agreed that it's an error, but he apparently didn't get around to fixing it. The actual code examples in the document are, of course, correct. From fabiofz at gmail.com Fri Apr 4 12:28:13 2008 From: fabiofz at gmail.com (Fabio Zadrozny) Date: Fri, 4 Apr 2008 13:28:13 -0300 Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? In-Reply-To: References: Message-ID: Hi Nebur, Are you using svn? I did have a problem once related to that (but it's more related to the svn plugin than to pydev)... I think that for some reason the undo seems to be mapped to a creation of a file that came from svn (I don't remember exactly how to reproduce it, but I do remember it was associated only with svn -- cvs didn't have that problem -- but it was something like trying to make undo on a file that didn't have anything changed and then it would go to the svn and remove another file). Cheers, Fabio On Fri, Apr 4, 2008 at 12:38 PM, Nebur wrote: > Hi folks developing with Pydev/Eclipse, > > this is the second time in about half a year that the following > surprise bites me: > > I've switched between some files in Pydev/Eclipse using the > FileNavigator, and when I want to go back to my last-edited *.py file, > it is missing. > No more in the FileNavigator, no more in the OpenFiles-List of the > Editor. Removed anywhere. Erased from the file system. Restorable from > the version control only. > Only a young orphan *.pyc file is sitting around, showing me I haven't > dreamed of editing the file two minutes before. > I'm sure I did no delete operations with eclipse, and I'm sure I did > not use another application than eclipse in the meantime. > > No, I can't reproduce it, and I don't know whom to blame (Pydev? > Eclipse ? The File System ? A Virus that only 2 times in half a year > deletes a single file I'm busy working with, and seems to do nothing > else? Myself beeing schizophrenic ??) > > Someone else already had this effect ? > Nebur > > > PS: Debian Etch 64Bit/JFS,Eclipse3.3,Pydev1.3.14. > -- > http://mail.python.org/mailman/listinfo/python-list > From kinch1967 at gmail.com Sun Apr 27 12:20:45 2008 From: kinch1967 at gmail.com (bullockbefriending bard) Date: Sun, 27 Apr 2008 09:20:45 -0700 (PDT) Subject: design choice: multi-threaded / asynchronous wxpython client? References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: <6fd9f065-630c-44ec-b8ca-348b0eabb3d7@y18g2000pre.googlegroups.com> On Apr 27, 10:10?pm, David wrote: > > ?1) The data for the race about to start updates every (say) 15 > > ?seconds, and the data for earlier and later races updates only every > > ?(say) 5 minutes. There is ?no point for me to be hammering the server > > ?with requests every 15 seconds for data for races after the upcoming > > Try using an HTTP HEAD instruction instead to check if the data has > changed since last time. Thanks for the suggestion... am I going about this the right way here? import urllib2 request = urllib2.Request("http://get-rich.quick.com") request.get_method = lambda: "HEAD" http_file = urllib2.urlopen(request) print http_file.headers ->>> Age: 0 Date: Sun, 27 Apr 2008 16:07:11 GMT Content-Length: 521 Content-Type: text/xml; charset=utf-8 Expires: Sun, 27 Apr 2008 16:07:41 GMT Cache-Control: public, max-age=30, must-revalidate Connection: close Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET X-AspNet-Version: 1.1.4322 Via: 1.1 jcbw-nc3 (NetCache NetApp/5.5R4D6) Date is the time of the server response and not last data update. Data is definitely time of server response to my request and bears no relation to when the live XML data was updated. I know this for a fact because right now there is no active race meeting and any data still available is static and many hours old. I would not feel confident rejecting incoming data as duplicate based only on same content length criterion. Am I missing something here? Actually there doesn't seem to be too much difficulty performance-wise in fetching and parsing (minidom) the XML data and checking the internal (it's an attribute) update time stamp in the parsed doc. If timings got really tight, presumably I could more quickly check each doc's time stamp with SAX (time stamp comes early in data as one might reasonably expect) before deciding whether to go the whole hog with minidom if the time stamp has in fact changed since I last polled the server. But if there is something I don't get about HTTP HEAD approach, please let me know as a simple check like this would obviously be a good thing for me. From vafada at gmail.com Mon Apr 28 14:12:44 2008 From: vafada at gmail.com (Mark Bryan Yu) Date: Mon, 28 Apr 2008 11:12:44 -0700 (PDT) Subject: list.reverse() Message-ID: This set of codes works: >>> x = range(5) >>> x.reverse() >>> x [4, 3, 2, 1, 0] But this doesn't: >>> x = range(5).reverse() >>> print x None Please explain this behavior. range(5) returns a list from 0 to 4 and reverse just reverses the items on the list that is returned by range(5). Why is x None (null)? From s0suk3 at gmail.com Wed Apr 30 10:12:47 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Wed, 30 Apr 2008 07:12:47 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: <874c3c53-8a9a-4050-8c8d-fdd763fa36fb@m73g2000hsh.googlegroups.com> On Apr 12, 11:11 am, andreas.eis... at gmail.com wrote: > I should have been more specific about possible fixes. > > > > python2.5 -m timeit 'gc.disable();l=[(i,) for i in range(2000000)]' > > > 10 loops, best of 3: 662 msec per loop > > > > python2.5 -m timeit 'gc.enable();l=[(i,) for i in range(2000000)]' > > > 10 loops, best of 3: 15.2 sec per loop > > > In the latter case, thegarbagecollector apparently consumes about > > 97% of the overall time. > > In a related thread onhttp://bugs.python.org/issue2607 > Amaury Forgeot d'Arc suggested a setting of the GC > thresholds that actually solves the problem for me: > > > Disabling the gc may not be a good idea in a real application; I suggest > > you to play with the gc.set_threshold function and set larger values, at > > least while building the dictionary. (700, 1000, 10) seems to yield good > > results. > > python2.5 -m timeit 'gc.set_threshold(700,1000,10);l=[(i,) for i in range(2000000)]' > > 10 loops, best of 3: 658 msec per loop > > which made me suggest to use these as defaults, but then > Martin v. L?wis wrote that > > > No, the defaults are correct for typical applications. > > At that point I felt lost and as the general wish in that thread was > to move > discussion to comp.lang.python, I brought it up here, in a modified > and simplified form. > > > I would suggest to configure the default behaviour of thegarbage > > collector in such a way that this squared complexity is avoided > > without requiring specific knowledge and intervention by the user. Not > > being an expert in these details I would like to ask the gurus how > > this could be done. > > I hope this should be at least technically possible, whether it is > > really desirable or important for a default installation of Python > > could then be discussed once the disadvantages of such a setting would > > be apparent. > > I still don't see what is so good about defaults that lead to O(N*N) > computation for a O(N) problem, and I like Amaury's suggestion a lot, > so I would like to see comments on its disadvantages. Please don't > tell me that O(N*N) is good enough. For N>1E7 it isn't. > > About some other remarks made here: > > > I think the linguists of the world should write better automated > > translation systems. Not being an expert in these details I would like > > to ask the gurus how it could be done. > > I fully agree, and that is why I (as someone involved with MT) would > prefer to focus on MT and not on memory allocation issues, and by the > way, this is why I normally prefer to work in Python, as it normally > lets me focus on the problem instead of the tool. > > > There are going to be pathological cases in any memory allocation > > scheme. The fact that you have apparently located one calls for you to > > change your approach, not for the finely-tuned well-conceivedgarbage > > collection scheme to be abandoned for your convenience. > > I do not agree at all. Having to deal with N>1E7 objects is IMHO not > pathological, it is just daily practice in data-oriented work (we're > talking about deriving models from Gigawords, not about toy systems). > > > If you had made a definite proposal that could have been evaluated you > > request would perhaps have seemed a little more approachable. > > I feel it is ok to describe a generic problem without having found > the answer yet. > (If you disagree: Where are your definite proposals wrt. MT ? ;-) > But I admit, I should have brought up Amaury's definite proposal > right away. > > > A question often asked ... of people who are creating > > very large data structures in Python is "Why are you doing that?" > > That is, you should consider whether some kind of database solution > > would be better. You mention lots of dicts--it sounds like some > > balanced B-trees with disk loading on demand could be a good choice. > > I do it because I have to count frequencies of pairs of things that > appear in real data. Extremely simple stuff, only interesting because > of the size of the data set. After Amaury's hint to switch GC > temporarily > off I can count 100M pairs tokens (18M pair types) in about 15 > minutes, > which is very cool, and I can do it in only a few lines of code, which > is even cooler. > Any approach that would touch the disk would be too slow for me, and > bringing in complicated datastructures by myself would distract me > too much from what I need to do. That's exactly why I use Python; > it has lots of highly fine-tuned complicated stuff behind the scenes, > that is just doing the right thing, so I should not have to (and I > could > not) re-invent this myself. > > Thanks for the helpful comments, > Andreas In the issue at bugs.python.org, why do you say "Do I have to switch to Perl or C to get this done???", as if Perl and C were similar languages? If we were to look at Python, Perl, and C together, Python and Perl would be similar languages, and C would be quite something different, *specially* regarding the discussed issue: speed. So what do you mean by saying "Perl or C"? From sturlamolden at yahoo.no Sun Apr 20 14:11:07 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sun, 20 Apr 2008 11:11:07 -0700 (PDT) Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> <480b6133$0$34498$742ec2ed@news.sonic.net> Message-ID: <3eac67b4-da0a-4926-9ca4-942271513ad2@26g2000hsk.googlegroups.com> On Apr 20, 5:28 pm, JB Stern wrote: > Curious Steve, how do you pay the rent and by what authority do you > speak for "The Python world"? Your opinion couldn't be more wrong for > programmers like myself who live by the code they write (as opposed to > its support). Are you afraid to show the code to your customer? Are you afraid it will give you a bad reputatio? Are you worried about loosing future contracts? Is your code really that bad? Then you better keep it hidden from sight. If this is the case, my advice to you would be to find a different profession. Perhaps flipping burgers at McDonald's fits your talent? From nmiyasato at gmail.com Sat Apr 26 22:26:27 2008 From: nmiyasato at gmail.com (miya) Date: Sat, 26 Apr 2008 19:26:27 -0700 (PDT) Subject: python and web programming, easy way...? References: Message-ID: <2db36ccf-c9fd-4e7a-9697-fd5c23159287@j22g2000hsf.googlegroups.com> On Apr 26, 4:36 pm, bvidinli wrote: > Hi, > > i use currently python for console programming. > in past, i tried it for web programming, to use it instead of php. > Unfortunately, i failed in my attempt to switch to python. > Currently, i make many webbased programs and a "Easy Hosting Control > Panel " (www.ehcp.net) that runs on php, > ehcp is a hosting control panel in beta stage.. > > in fact, i use python, love it and want to switch to it in my all > projects, including webbased programs and ehcp. > Can your recomment me the easiest, most usable way to use python in > web programming.. > > in past, in my first attemt... i was able to run python as as apache > cgi, runned it basicly, > but i had many difficulties especially in sessions, cookies... > > maybe currently there is a solution, but i dont know. > > Please provide me the quickest/most appropriate solution for web > programming in python. > i will try to switch to python in ehcp too.. > > Currently my web programs are simple Object Oriented programs, that > basicly uses a few files, in php. > i use sessions in use authentications. > i currently use php because it is fairly easy to install/run on apache.. > you just put it on server, it runs.. i look something like this for > python. because python programming is much better than php. > > Thank you a lot. > > -- > ?.Bahattin Vidinli > Elk-Elektronik M?h. > ------------------- > iletisim bilgileri (Tercih sirasina gore): > skype: bvidinli (sesli gorusme icin,www.skype.com) > msn: bvidi... at iyibirisi.com > yahoo: bvidinli > > +90.532.7990607 > +90.505.5667711 Django is the way to go for web development. http://www.djangoproject.com/ cya -- Nicol?s Miyasato ( miya ) From bruno.desthuilliers at gmail.com Wed Apr 2 16:01:40 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 13:01:40 -0700 (PDT) Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> <7xwsngyu05.fsf@ruckus.brouhaha.com> Message-ID: On 2 avr, 20:46, Paul Rubin wrote: > "bruno.desthuilli... at gmail.com" writes: > > Here the problem is more philosophical than anything else. Python's > > philosophy is that most programmers are responsible and normally > > intelligent, so treating them all like retarted dummies because > > someone might one day do something stupid is just wasting everyone's > > time. This is also why there's no language-enforced access > > restriction, only a simple stupid convention to denote implementation > > stuff from API. The fact is that it JustWork. > > Additional Principles for C1X (new) > ... > 12. Trust the programmer, as a goal, is outdated in respect to the > security and safety programming communities. While it should not > be totally disregarded as a facet of the spirit of C, the > C1X version of the C Standard should take into account that > programmers need the ability to check their work. > > C - The C1X Charter > Document: WG14 N1250, p. 3http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1250.pdf Fine. But totally irrelevant here - this is comp.lang.python, not comp.lang.c, and we *do not* (I repeat : we *do not*) face the same safety and security problems as those existing in C. From kyosohma at gmail.com Tue Apr 22 23:18:17 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 22 Apr 2008 22:18:17 -0500 Subject: about python In-Reply-To: <12826269.63521208919025392.JavaMail.servlet@perfora> References: <12826269.63521208919025392.JavaMail.servlet@perfora> Message-ID: <480EAA79.6090900@gmail.com> mranjan at varshyl.com wrote: > How can python execute in browser? > > > Mukul > -- > http://mail.python.org/mailman/listinfo/python-list > Check out IronPython, which you can use with Silverlight or Mono. Or you could look at any of the cool Python Web Frameworks, such as TurboGears, Pylons, CherryPy, or Django. Mike From marco at sferacarta.com Tue Apr 29 09:49:25 2008 From: marco at sferacarta.com (Marco Mariani) Date: Tue, 29 Apr 2008 15:49:25 +0200 Subject: Zope/DTML Infuriating... In-Reply-To: <5493f048-db28-4f72-8265-99fd33c79f93@56g2000hsm.googlegroups.com> References: <3a955f90-ed80-46be-a238-1462e4fb2d0c@m3g2000hsc.googlegroups.com> <5493f048-db28-4f72-8265-99fd33c79f93@56g2000hsm.googlegroups.com> Message-ID: Jens wrote: > Hey no worriest. Is this the tutorial you're referring to: > > http://docs.python.org/lib/typesmapping.html > > Is there anything better? That's the library reference - the one to keep under the pillow. It also documents the core -- i.e. builtin objects. As for the language semantics, I suggest the whole of http://docs.python.org/tut/ then a bit of http://docs.python.org/ref/ref.html A good alternative could be the new edition of Python in a Nutshell. The author has a very clear style and leaves no corners uncovered. > I miss the discussion and examples that accompany most entries in php.net. This is a post + comments about strong/weak typing, although not an in-depth analyses. http://www.artima.com/forums/flat.jsp?forum=106&thread=7590 From lists at cheimes.de Sat Apr 12 10:59:17 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 12 Apr 2008 16:59:17 +0200 Subject: str(bytes) in Python 3.0 In-Reply-To: <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> Message-ID: <4800CE45.1030407@cheimes.de> Carl Banks schrieb: > I believe the Zen in effect here is, "In the face of ambiguity, refuse > the temptation to guess." How do you know if the bytes are utf-8 > encoded? Indeed > I'm not sure if str() returning the repr() of a bytes object (when not > passed an encoding) is the right thing, but it's probably better than > throwing an exception. The problem is, str can't decide whether it's > a type conversion operator or a formatted printing function--if it > were strongly one or the other it would be a lot more obvious what to > do. I was against it and I also wanted to have 'egg' == b'egg' raise an exception but I was overruled by Guido. At least I was allowed to implement the byte warning feature (-b and -bb arguments). I *highly* recommend that everybody runs her unit tests with the -bb option. Christian From lbonafide at yahoo.com Wed Apr 16 14:28:33 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Wed, 16 Apr 2008 11:28:33 -0700 (PDT) Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <0f58fb99-f441-4978-b750-1c0adb45eee4@e67g2000hsa.googlegroups.com> On Apr 16, 11:06?am, Steve Holden wrote: > I'm not saying people shouldn't use Google Groups. I'm saying that > Google can "justify" providing customer "support" that lives somewhere > between zero and extremely crappy by not charging for the service. It's even worse than that. Click on one of these spam links and you'll see Google ads. Why would Google have any motivation to stop selling ads? From sean_mcilroy at yahoo.com Sat Apr 12 15:40:04 2008 From: sean_mcilroy at yahoo.com (Sean McIlroy) Date: Sat, 12 Apr 2008 12:40:04 -0700 (PDT) Subject: override the interpreter's parser? Message-ID: <0e23fcab-4169-4ba8-ace4-6aa4a4b95947@q1g2000prf.googlegroups.com> hi all i'd like to write a module that, when run in the interpreter, would cause the interpreter to read certain strings that would normally be rejected as syntax errors (strings beginning with the @ symbol, say) and pass them on to an object defined in the aforementioned module. where should i look to start finding out how to do this? thanks for any help. peace stm From aahz at pythoncraft.com Mon Apr 7 20:47:46 2008 From: aahz at pythoncraft.com (Aahz) Date: 7 Apr 2008 17:47:46 -0700 Subject: Recursively Backup Directories References: Message-ID: In article , Jorgen Grahn wrote: > >I believe it is better to write a script which drives a widely known >and well-tested copying utility. On Unix these include tar, cpio and >rsync -- don't know which ones are common under DOS (xcopy?) Just use pax (I haven't bothered learning it because I haven't used Windows in years, but it's the only cross-platform archive/copy tool available). -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "It is easier to optimize correct code than to correct optimized code." --Bill Harlan From stargaming at gmail.com Fri Apr 4 15:04:28 2008 From: stargaming at gmail.com (Robert Lehmann) Date: 04 Apr 2008 19:04:28 GMT Subject: generator functions: why won't this work? References: <19359dad-3022-4e83-99e4-8f8093116bcb@a1g2000hsb.googlegroups.com> Message-ID: <47f67bbc$0$26905$9b622d9e@news.freenet.de> On Wed, 02 Apr 2008 19:04:30 -0300, Gabriel Genellina wrote: > En Wed, 02 Apr 2008 14:11:30 -0300, escribi?: > >> On Apr 1, 10:42?pm, "Gabriel Genellina" wrote: >>> En Tue, 01 Apr 2008 23:56:50 -0300, >>> escribi?: >>> >>> ? ?yield *iterable >>> >>> could be used as a shortcut for this: >>> >>> ? ?for __temp in iterable: yield __temp >> >> How serious were you about that? > > Not so much, I haven't thougth enough on it. Looks fine in principle, > but yield expressions may be a problem. Issue 2292: "Missing *-unpacking generalizations" http://bugs.python.org/issue2292 Discussion on python-3000.devel: http://thread.gmane.org/gmane.comp.python.python-3000.devel/12131 -- Robert "Stargaming" Lehmann From steve at holdenweb.com Tue Apr 8 22:22:40 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 22:22:40 -0400 Subject: new user needs help! In-Reply-To: <73decd360804081914l3545f622yb63b6f9e8cbcd714@mail.gmail.com> References: <10644597.63801207701350348.JavaMail.nabble@isper.nabble.com> <47FC148B.1010605@holdenweb.com> <73decd360804081914l3545f622yb63b6f9e8cbcd714@mail.gmail.com> Message-ID: <47FC2870.5000006@holdenweb.com> drjekil (or should that be mrhyde?): Once again, *please* make sure you reply to the list. Personal replies are much less likely to get attention. regards Steve drjekil sayer wrote: > u got it! > thats what i am trying to explain with my bad english! > thanks once again. > > > On 4/9/08, *Steve Holden* > wrote: > > drjekil77 at gmail.com wrote: > > thanks! > > > Please keep all replies on the list: somebody else may also wish to > help (and they will also pick up mistakes I make ;-) > > I am working with a text filelooks like this: > #NAME AA TOPO ACCESS DSSP STRIDE Z-COORD > 1lghB A i 79.8 H H -24.58 > 1lghB V i 79.6 H H -22.06 > 1lghB H i 71.9 H H -19.94 > i need to compare those lines which has a value between 10 to 22 > and presents in the following way > True/false A C D E F G H I K L M N P Q R S T V X Y W(here > alfabets represents amino acids) > 1 1:1 2:0 3:0 and so on for rest of the amino acids. > > > I have given 2 examples below to make it clear a bit: > > ex.1: > #NAME AA TOPO ACCESS DSSP STRIDE Z-COORD > 1lghB A i 79.8 H H -24.58 > #for that line amino acid is A and z-COORED > value is more than 22,so output should be look like > > True/false A C D E F G H I K L M N P Q R S T V X Y W(here > alfabets represents amino acids) > -1 1:1 2:0 3:o 4:0 so on upto 20 bcz there r 20 amino acids.and > A presents in the 1st position.every line represents one amino > acid with value,so output will show in which position is it(here > A is in 1st position thats why its value 1:1 and all the other > position o like 2:0,3:0,4:0 and if its Z-COORED value between > 10-22 then true false value 1,otherwise -1. > > another ex: > > 1lghB H i 71.9 H H -19.94 # for that line amino acid > is H and it has value between 10-22.so output should looks like: > > True/false A C D E F G H I K L M N P Q R S T V X Y W(here > alfabets represents 20 amino acids) > > 1 1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0,every position is zero up to > 20 bcz H presents in the 7th position.so it will be 1. > > so for every line, output will in 21 coulum,1st coulum for true > false value,others r for 20 amino acids.true false value will be > either 1 or -1,and within other 20 coulum one value will be > n:1,others will be n:0.n=0,1,2,3..20. > its a bit tricky. > thank u so much for ur help > waiting for ur opinion. > > > So, you are using -1 for true and 1 for false? Can there be multiple > amino acids on each line? > > Would this be a possible input: > > 1lghB AHG i 87.3 Q Q -23.45 > > If so, would this be the required output? > > -1 1:1 2:0 3:0 4:0 5:0 6:0 7:1 8:1 9:0 10:0 ... 19:0 20:0 > > There is no point trying to write more code until we understand the > requirements properly. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From andreas.profous at googlemail.com Fri Apr 25 07:15:55 2008 From: andreas.profous at googlemail.com (andreas.profous at googlemail.com) Date: Fri, 25 Apr 2008 04:15:55 -0700 (PDT) Subject: problem with unicode Message-ID: <26fcc207-b864-42c7-afb3-c6945e5fe29f@m44g2000hsc.googlegroups.com> Hi everybody, I'm using the win32 console and have the following short program excerpt # media is a binary string (mysql escaped zipped file) >> print media x???[? ... (works) >> print unicode(media) UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position 1: ordinal not in range(128) (ok i guess print assumes you want to print to ascii) >> print unicode(media).encode('utf-8') UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position 1: ordinal not in range(128) (why does this not work?) # mapString is a unicode string (i think at least) >> print "'" + mapString + "'" ' yu_200703_hello\ 831 v1234.9874 ' >> mystr = "%s %s" % (mapString, media) UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position 1: ordinal not in range(128) >> mystr = "%s %s" % (mapString.encode('utf-8'), media.encode('utf-8')) UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position 1: ordinal not in range(128) I don't know what to do. I just want to concatenate two string where apparently one is a binary string, the other one is a unicode string and I always seem to get this error. Any help is appreciated :) From fennelllindy8241 at gmail.com Mon Apr 28 03:16:13 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:16:13 -0700 (PDT) Subject: recipe for crack cocaine Message-ID: recipe for crack cocaine http://crack.cracksofts.com From paul at science.uva.nl Tue Apr 22 09:54:42 2008 From: paul at science.uva.nl (Paul Melis) Date: Tue, 22 Apr 2008 15:54:42 +0200 Subject: Python Success stories In-Reply-To: <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> Message-ID: <480DEE22.4040702@science.uva.nl> azrael wrote: > Which big aplications are written in python. I see its development, > But i can't come up with a big name. I know that there are a lot of > companys using python, but is there anythong big written only in > python. I want him to fuck of with his perl once and for all time Not really "big" in terms of lines of code, but definitely well-known and widespread: the official BitTorrent client is written in Python (and has been since the beginning I believe). Regards, Paul From jason.scheirer at gmail.com Tue Apr 22 23:46:36 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Tue, 22 Apr 2008 20:46:36 -0700 (PDT) Subject: about python References: Message-ID: <917df937-7241-4996-bb90-43d1bfbc54d8@e39g2000hsf.googlegroups.com> On Apr 22, 7:50?pm, mran... at varshyl.com wrote: > How can python execute in browser? > > Mukul Very carefully. Alternately, applets/Jython. From marlin_rowley at hotmail.com Fri Apr 25 11:38:13 2008 From: marlin_rowley at hotmail.com (Marlin Rowley) Date: Fri, 25 Apr 2008 10:38:13 -0500 Subject: Having problems with wxPython - HELP!! Message-ID: I'm desperately spending too much time trying to understand wxPython and it's leading me nowhere. I'm trying to make a script that will create a window, and then immediately fill this window with a background color. I also want to be able to fill this window with a background color anytime I need to, therefore I put it in a function called "InitBuffer()". Problem 1: Python doesn't clear the window with "Grey" (my background color) when it is initially created. Why? Problem 2: OnPaint() seems to always get called for whatever reason. Fine. But I only want it to refresh the contents of the window. So, if I draw to the Client window a series of rectangles, the ONLY thing I want OnPaint() to do is refresh what has already been draw to the screen. The ONLY time it should clear the screen is when I call InitBuffer(). How do I do this? Here's my code: # Mental Ray Thread class runMentalRayThread(threading.Thread): def __init__(self,sFile,renderWindow): threading.Thread.__init__(self) self.filename = sFile self.threadID = os.getpid() self.renderBuffer = renderWindow # poll the file using yet another thread. When that returns, # capture the mental ray stream and render to the canvas. def run(self): self.portInfo = queryMentalRay(self.filename) self.renderBuffer.InitBuffer() scanMR(self.portInfo[0], self.portInfo[1], self) # Render Window class RenderWindow(wx.Window): def __init__(self,parent,ID,pos,size): wx.Window.__init__(self,parent,ID,pos,size) self.renderThread = runMentalRayThread(filename,self) self.SetBackgroundColour("Grey") self.Bind(wx.EVT_IDLE, self.OnIdle) self.Bind(wx.EVT_CLOSE, self.OnClose) self.Bind(wx.EVT_PAINT, self.OnPaint) self.InitBuffer() # Our initial buffer must be set and background cleared. def InitBuffer(self): print 'InitBuffer() called...' self.ClearBackground() # Idle function. Wait for a render def OnIdle(self,event): if not self.renderThread.isAlive(): print 'Starting thread to poll Mental Ray...' self.renderThread = runMentalRayThread(filename,self) self.renderThread.start() # Refreshes the window. def OnPaint(self,event): print 'OnPaint() called...' dc = wx.PaintDC(self) # Closing the render window, we need to # kill the thread attached to Mental Ray. def OnClose(self,event): if self.renderThread.isAlive(): # kill the thread os.popen("kill -9 "+str(self.renderThread.threadID)) _________________________________________________________________ Spell a grand slam in this game where word skill meets World Series. Get in the game. http://club.live.com/word_slugger.aspx?icid=word_slugger_wlhm_admod_april08 -------------- next part -------------- An HTML attachment was scrubbed... URL: From reachmsn at hotmail.com Thu Apr 10 22:57:29 2008 From: reachmsn at hotmail.com (reachmsn at hotmail.com) Date: Thu, 10 Apr 2008 19:57:29 -0700 (PDT) Subject: Cannot understand the detailedly the following code References: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> <10a83944-b17a-4c3f-992b-1754c0a5e9b1@s33g2000pri.googlegroups.com> Message-ID: On Apr 9, 8:12?pm, "A.T.Hofkamp" wrote: > On 2008-04-09, reach... at hotmail.com wrote: > > > > > > > On Apr 8, 5:45?pm, "A.T.Hofkamp" wrote: > > Ok following these instructions one gets > > > def find_all_paths(graph, start, end, path=[]): > > ?path= path+ [start] > > > ?for node in graph[start]: > > > ? ?find_all_paths(graph, node, end, path) > > >> First define the input and output parameters/values of the function. > >> (ie what goes in, and what comes out) > > > Now what will be the output parameters - there is a Return statement. > > Input parameters are graph, vertexes start, node, end and path. Also > > how would you write the terminating and reduction cases after this. > > Actually i'm not clear how to proceed writing this recursive function. > > Thanks! > > Don't look at code, don't even think about it (it gives you too much confusing > details). > > Instead, have a beer, sit down in a sunny spot, and do mothing for a while. > > Think about the function as a (black) box. You don't know what is in it (it is > not important yet). That box is the function (many people prefer to draw a > rectangular shape on a sheet of paper, and consider that to be the function). > What data does the box need to do its work, and what does it produce after > it has done its work? > > (suppose you are given the task of 'finding all paths'. What information do you > need to acomplish this task, and what information do you write down as result?) > > A simple example of a multiplication task: One needs 2 numbers to do the task, > and the result is another number. Note that at this stage, you don't worry > about HOW you do the task, only WHAT GOES IN AND WHAT COMES OUT. > (actually, HOW depends on INPUT. Multiplication of 2 and 5 can be done > differently from multiplication of > 230698762085269459068388639078903870385790368703879038285790 and > 5938063786093895682682968390789380834687387689762897. For this reason, deciding > the strategy of solving the problem comes after establishing input and output). > > Sincerely, > Albert > PS email will give you shorter response times.- Hide quoted text - > > - Show quoted text - Hello, Thank you for the suggestion of relaxing! After that the black box function you mentioned looks like this- Output- path1 path 2 | ... path n | | | ---------------------- | | | | | function -find_ | | _all_paths() | | | ---------------------- | | | | Input - graph, start, end i.e. you give, the graph, the start and end vertices as inputs and you get the output as a listing of all the paths. This is where I got to. It would be very nice if you could kindly hint on how to proceed further. Thank you so much for your time! Thanks & Regards, Anshu From billingspanshism at gmail.com Sat Apr 19 17:17:49 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:17:49 -0700 (PDT) Subject: victoria beckham blonde Message-ID: Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From gagsl-py2 at yahoo.com.ar Tue Apr 1 05:04:29 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 06:04:29 -0300 Subject: Why prefer != over <> for Python 3.0? References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> <659gb2F2f84eoU2@mid.individual.net> <87hceo73ap.fsf@physik.rwth-aachen.de> <65anbqF2fg18bU1@mid.individual.net> <87r6drjss4.fsf@physik.rwth-aachen.de> <65c0bfF2ffipiU1@mid.individual.net> <32822fe60804010015m22a4e9bei5002431afe14921a@mail.gmail.com> Message-ID: En Tue, 01 Apr 2008 04:15:57 -0300, Jorge Vargas escribi?: > as for the original question, the point of going unicode is not to > make code unicode, but to make code's output unicode. thin of print > calls and templates and comments the world's complexity in languages. > sadly most english speaking people think unicode is irrelevant because > ASCII has everything, but their narrow world is what's wrong. Python 3 is a good step in that direction. Strings are unicode, identifiers are not restricted to ASCII, and the default source encoding is not ASCII anymore (but I don't remember which one). So this is now possible with 3.0: >>> a?o = 2008 >>> print("halag?e?o") halag?e?o >>> print("halag?e?o".encode("latin1")) b'halag\xfce\xf1o' -- Gabriel Genellina From version5 at gmail.com Wed Apr 2 09:52:08 2008 From: version5 at gmail.com (nnp) Date: Wed, 2 Apr 2008 14:52:08 +0100 Subject: Python queue madness Message-ID: <28749c0e0804020652o74a9491an9eef9ba1813434fb@mail.gmail.com> Hey guys, Basically I have a system where component 1, 2 and 3 communicate with each other using two Python Queues, we'll call them R and W. Here is what is happening 1 writes data to W and reads from R 2 reads data from W and writes data it receives from 3 to R (but not data it receives from 1) 3 writes to W The problem is that data being written by 1 to W is appearing back on R. I have verified that 1 never writes to R and that 2 never writes data it receives from 1 to R, by overwriting the put() and put_nowait() methods of R. Is there any other way for data to get onto a queue or are there any known bugs with Python's Queue module that could lead to this kind of behaviour? -nnp -- http://www.smashthestack.org http://www.unprotectedhex.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From johng at neutralize.com Tue Apr 8 06:41:26 2008 From: johng at neutralize.com (monk.e.boy) Date: Tue, 8 Apr 2008 03:41:26 -0700 (PDT) Subject: urlparse http://site.com/../../../page.html Message-ID: <9fdd0d8b-785a-4363-be6a-75f993527754@c65g2000hsa.googlegroups.com> Hi, Can anyone help me with the urlparse: >>> import urlparse >>> urlparse.urljoin( 'http://site.com/path/', '../../../../path/' ) 'http://site.com/../../../path/' >>> urlparse.urljoin( 'http://site.com/', '../../../../path/' ) 'http://site.com/../../../../path/' >>> urlparse.urljoin( 'http://site.com/', '/path/../path/.././path/./' ) 'http://site.com/path/../path/.././path/./' I'm sure these should all return: http://site.com/path/ I tested all these in firefox -- I built a page with these links as anchors and mouse_over them to see what Firefox thinks they should be. I also know that google parses these URLs into http://site.com/path/ because one of our website has the above links in as a test. Is this a bug in urlparse? I'm not sure. Can anyone help me write something that will create the url I want. Should I look at os.path to help? I would like it to work on both Win and Linux :-) thanks monk.e.boy From hotani at gmail.com Wed Apr 23 13:54:39 2008 From: hotani at gmail.com (hotani) Date: Wed, 23 Apr 2008 10:54:39 -0700 (PDT) Subject: python-ldap: searching without specifying an OU? References: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> <58546d42-bc80-4f9d-be90-e184c312e2d1@k37g2000hsf.googlegroups.com> <0ke3e5-ccc.ln1@nb2.stroeder.com> Message-ID: <8ef38281-a6fe-4501-b711-a24cd9f35a24@t54g2000hsg.googlegroups.com> It seems the only way I can bind is by using this format: simple_bind_s('user at server.local','password') If I try using a DN, it fails every time. This will not work: simple_bind_s('cn=user,dc=server,dc=local', 'password') Errors out with "invalid credentials": ldap.INVALID_CREDENTIALS: {'info': '80090308: LdapErr: DSID-0C090334, comment: AcceptSecurityContext error, data 525, vece', 'desc': 'Invalid credentials'} If I put the *wrong* credentials in the first format, it will fail - which seems to indicate the bind is working. With that 'successful' (?) bind, it is returning the bind error from my earlier post only when I leave out the OU when searching. From lbonafide at yahoo.com Wed Apr 2 08:08:40 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Wed, 2 Apr 2008 05:08:40 -0700 (PDT) Subject: Where can I find : References: <13uu56hn1vdqb9d@corp.supernews.com> <768026ee-b9f1-4445-bd02-088a2f725a9d@b64g2000hsa.googlegroups.com> Message-ID: On Mar 30, 1:22 am, castiro... at gmail.com wrote: > > That's weird. I feel like I could go on about an introductory program > for days and days, la. > > I usually start (both times) with interpreted vs. compiled. It's a > layer of abstraction. But it's very weird; the layers can't tell > either of each other apart. I can hand you the machine instructions, > the names of circuitry, that run Line 1 to Line 9 one time, but you > can't tell the difference between the code and the data. > > Some of it lingers in post-perceptive operations: the memory system, > for the record. Some lingers long times. So far it equates to > different Pythons produce different Pythons, however, though, so I'll > ask the spell checker. Python.get_back_in_skin(). Weird. > > I'm not sure if it makes any difference. The binary you run is > Python.exe. It's already running, then you feed it a raw string, not > on disk without loss of generality. The translation is a little hard > to find too. > > Python :: mingw-c++ : > Python.exe :: mingw-c++.exe : > what? :: machine instructions.exe > > In Python there's a for-loop that's the exact same as one in machine > instructions. > > 0101 b1= 1000 > 0110 if a < b0 goto b1 > 0111 b2= b2+ 1 > > accumulates a number in register b2. You probably want interface and > graphics primitives. Sometimes I feel like "with a scroll bar" > suffices to specify all the detail you need; there's too many > options. (I can do this and this and ... scroll bar, please.) You > know the episode of Star Trek NG where Barclay takes over the > Enterprise. > > I'd also like to be able to write (write) a series of instructions and > have it loop, and debug in vivo, as though a BASIC program were > running and I could edit lines in its doing so, maybe time Windows > Media visualization codecs in time. You could tell story lines and > have it refine, post-inspiration. > > You might be surprised how much repetition in instructions Lines 1 > through 9 (of -code-) share, in both sides of the analogy. Anyone > work with a VAX? What? From steve at holdenweb.com Tue Apr 8 22:35:33 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 22:35:33 -0400 Subject: import statement convention In-Reply-To: <87fxtvomc6.fsf@benfinney.id.au> References: <4078bcf4-e68f-45d4-93ce-335ec7a33c5a@v32g2000prd.googlegroups.com> <87fxtvomc6.fsf@benfinney.id.au> Message-ID: Ben Finney wrote: > MartinRinehart at gmail.com writes: > >> By convention, I've read, your module begins with its import >> statements. Is this always sensible? > > There are exceptions, but the benefits are great: It's very easy to > see what this module requires, without needing to execute it. > >> I put imports that are needed for testing in the test code at the >> end of the module. If only a bit of the module has a visual >> interface, why pollute the global namespace with 'from Tkinter >> import *'? Wouldn't that be better done in a separate class or >> function? > > If your test code requires the Tkinter module but the rest of the code > doesn't, why pollute the functional module with such test code? Move > it to a separate unit test module. > If your test code is the only part of the module that needs Tkinter I'd be perfectly happy seeing the import guarded by the if __name__ == "__main__" condition. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From sam at mas.pl Thu Apr 3 05:32:09 2008 From: sam at mas.pl (sam) Date: Thu, 03 Apr 2008 11:32:09 +0200 Subject: Prototype OO In-Reply-To: <47f49d4b$0$5665$426a74cc@news.free.fr> References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> <47f49d4b$0$5665$426a74cc@news.free.fr> Message-ID: Bruno Desthuilliers napisa?(a): > Ok, I'm going to be a bit harsh, but this time I'll assume it. > Sam, you started this thread by asking about prototype vs class based > minor syntactic points that, whether you like them or not (and I think I will get back to this discussion after learning "descriptor protocol" and maybe I will not talk about syntax then, and maybe it won't get off topic. As you can see I'm novice in Python, but I can show python-experts some newbie opinions. If somebody is an expert then he can't take a fresh look at his many years work. Anyway -- thank you for spending time and giving explanations. From fairwinds at eastlink.ca Mon Apr 7 11:26:36 2008 From: fairwinds at eastlink.ca (David Pratt) Date: Mon, 07 Apr 2008 12:26:36 -0300 Subject: Help replacing os.system call with subprocess call In-Reply-To: <47FA2B72.9050802@mattnordhoff.com> References: <47F9B1D1.4090701@eastlink.ca> <47F9C764.9070401@mattnordhoff.com> <47FA23E7.7040809@eastlink.ca> <47FA2B72.9050802@mattnordhoff.com> Message-ID: <47FA3D2C.2010504@eastlink.ca> Hi Matt. Many thanks. Sorry I had not seen your second post. I'll give this a try and time the completion to compare the differences and post back later today to show os.system, buffered imput and using a file directly for stdout. Regards, David Matt Nordhoff wrote: > David Pratt wrote: >> Hi David and Matt. I appreciate your help which has got me moving >> forward again so many thanks for your reply. I have been using >> subprocess.Popen a fair bit but this was the first time I had to use >> subprocess to capture large file output. The trouble I was having was >> with the process would just hang. Chunking was the solution. I guess I >> assumed this would be taken care of in the internals. >> >> Overall, I wish subprocess had some better documentation since it is >> definitely not a drop in replacement for os.system. In other >> circumstances I am using subprocess.call() for simple calls which works >> fine. >> >> The speed of this solution is slower than os.system. Would a queue of >> some kind be needed to speed this up? Has anyone implemented something >> like this? Many thanks. >> >> Regards, >> David > > Did you see my second message? That should help performance. If not, I'm > totally out of my depth and have no idea at all. Sorry. > > (How much slower? 10%? 200%?) From martin at v.loewis.de Mon Apr 21 01:17:24 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Mon, 21 Apr 2008 07:17:24 +0200 Subject: Compiling Python 2.5.2 on AIX 5.2 In-Reply-To: References: <0b73e8e5-c301-4823-ac94-42f757456cf1@x19g2000prg.googlegroups.com> <48059DA9.5080900@v.loewis.de> Message-ID: <480c2364$0$26788$9b622d9e@news.freenet.de> > Thus it would seem use cif here resulted in a segment violation. I'll > continue to research this issue and report back to the group as I know > more. Perhaps solving the issue with the 'c' and 'm' libraries > (whatever they might be) will make the core dump go away. However, > for tonight, I'll need to stop here. I recommend you disable compilation of ctypes (by removing the call to detect_ctypes from setup.py). It's fairly unlikely that you can manage to make ctypes work on your system. Regards, Martin From deets at nospam.web.de Thu Apr 10 06:23:56 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Thu, 10 Apr 2008 12:23:56 +0200 Subject: call python from c -> pass and return arrays/lists References: Message-ID: <66686oF2j0ddsU1@mid.uni-berlin.de> Pieter wrote: > Hi all, > > I'm trying to call a python function from c. I need to pass an > 2D-array to python and the python function returns a 2D-list back to > c. I googled arround and I found how to pass ints/strings/... back and > forth, but didn't find anything on passing arrays. > > For an int it's as simple as this: > > PyArg_Parse(ret,"i#", &my_long); > > But I hacve no idea how to parse python lists to a c-array? You return a list, parse that as object, and then work with the sequence-protocol on them. UNTESTED: PyArg_Parse(ret,"o", &the_list); if(PySequence_Check(the_list) { int size = PySequence_Size(the_list); int *result = malloc(sizof(int) * size); for(int i = 0; i < size; i++) { PyObject *item = PySequence_GetItem(the_list, i); if(PyInt_Check(item)) { result[i] = PyInt_AsLong(item); } else { return NULL; } } Diez From rbrito at ime.usp.br Mon Apr 28 16:51:55 2008 From: rbrito at ime.usp.br (=?ISO-8859-1?Q?Rog=E9rio_Brito?=) Date: Mon, 28 Apr 2008 17:51:55 -0300 Subject: Little novice program written in Python References: Message-ID: On 04/25/2008 01:30 AM, Steve Holden wrote: > Rog?rio Brito wrote: >> I'm just getting my feet wet on Python and, just for starters, I'm >> coding some elementary number theory algorithms (yes, I know that most >> of them are already implemented as modules, but this is an exercise in >> learning the language idioms). > Your Python is actually pretty good - if Raymond Hettinger pronounces it > OK then few would dare to disagree. Thank you. > As for your English, though, the word you sought was "Pythonic" (not > that you will ever find such a word in Webster's dictionary). To suggest > that your code is Pythonesque would mean you found it farcical or > ridiculous (like a Monty Python sketch), which it clearly is not. I didn't know about the pejorative meaning of Pythonesque. :-) Thanks for the comment on my English (which should be obvious that I'm not a native speaker). > PS: I think either my mailer or yours has mangled the indentation. I think that it was mine. Thanks, Rog?rio Brito. -- Rog?rio Brito : rbrito@{mackenzie,ime.usp}.br : GPG key 1024D/7C2CAEB8 http://www.ime.usp.br/~rbrito : http://meusite.mackenzie.com.br/rbrito Projects: algorithms.berlios.de : lame.sf.net : vrms.alioth.debian.org From bronger at physik.rwth-aachen.de Wed Apr 16 14:05:57 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 16 Apr 2008 20:05:57 +0200 Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <87abjty8sa.fsf@physik.rwth-aachen.de> Hall?chen! D'Arcy J.M. Cain writes: > On Wed, 16 Apr 2008 09:11:09 -0700 > "Daniel Fetchinson" wrote: > >> Full disclosure: I'm using google groups for both reading and >> writing. > > You are? Maybe, but not with this posting. It was sent through the mailing list. By the way, the "References:" header seems to get lost sometimes through the mailing list when reading it as a Usenet group, so that the discussion trees become a mess. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From rocco.rossi at gmail.com Mon Apr 7 10:30:06 2008 From: rocco.rossi at gmail.com (rocco.rossi at gmail.com) Date: Mon, 7 Apr 2008 07:30:06 -0700 (PDT) Subject: Orphaned child processes Message-ID: <51102b91-dedc-4ad6-a936-c29df47f30ab@r9g2000prd.googlegroups.com> I'm using the Python processing module. I've just run into a problem though. Actually, it's a more general problem that isn't specific to this module, but to the handling of Unix (Linux processes) in general. Suppose for instance that for some reason or another, after forking several child processes, the main process terminates or gets killed (or segfaults or whatever) and the child processes are orphaned. Is there any way to automatically arrange things so that they auto- terminate or, in other words, is there a way to make the child processes terminate when the parent terminates? Thank you. From grante at visi.com Fri Apr 25 20:38:56 2008 From: grante at visi.com (Grant Edwards) Date: Fri, 25 Apr 2008 19:38:56 -0500 Subject: Why is None <= 0 References: Message-ID: On 2008-04-25, D'Arcy J.M. Cain wrote: > On Fri, 25 Apr 2008 20:27:15 +0200 > Gregor Horvath wrote: >> >>> None <= 0 >> True >> >> Why? > > Why not? > >> Is there a logical reason? > > Everything in Python can compare to everything else. Not true. Python 2.4.4 (#1, Mar 20 2008, 09:20:52) [GCC 3.4.6 (Gentoo 3.4.6-r2, ssp-3.4.6-1.0, pie-8.7.10)] on linux2 >>> 3j < 7 Traceback (most recent call last): File "", line 1, in ? TypeError: no ordering relation is defined for complex numbers > It is up to the programmer to make sure that they are > comparing reasonable things. True. -- Grant Edwards grante Yow! BEEP-BEEP!! I'm a at '49 STUDEBAKER!! visi.com From gagsl-py2 at yahoo.com.ar Wed Apr 9 03:00:13 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 04:00:13 -0300 Subject: problem using import from PyRun_String References: <664bf2b80804081801u79ae9192h90c03c84c1ef35ce@mail.gmail.com> Message-ID: En Tue, 08 Apr 2008 22:01:18 -0300, Patrick Stinson escribi?: > I'm creating a module with PyModule_New(), and running a string buffer as > the module's text using PyRun_String and passing the module's __dict__ to > locals and globals. Why? Do you want to fake what import does? > I'm having a problem using the import statement from > within PyRun_String(). It complains about "__import__ not found", which > after a quick grep it looks like the exception is raised from > PyExc_EvalFrameEx() in ceval.c after f->f_builtins module doesn't contain > "__import__". > What __builtin__ module does that point to? a quick print of the __builtin__ holds all the builtin objects, what a surprise! :) http://docs.python.org/lib/module-builtin.html > Any help? What do you want to do actually? -- Gabriel Genellina From michael at stroeder.com Wed Apr 23 06:11:44 2008 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Wed, 23 Apr 2008 12:11:44 +0200 Subject: python-ldap: searching without specifying an OU? In-Reply-To: <58546d42-bc80-4f9d-be90-e184c312e2d1@k37g2000hsf.googlegroups.com> References: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> <58546d42-bc80-4f9d-be90-e184c312e2d1@k37g2000hsf.googlegroups.com> Message-ID: <0ke3e5-ccc.ln1@nb2.stroeder.com> hotani wrote: > Thanks for the response. The user I'm connecting as should have full > access but I'll double check tomorrow. > > This is the LDAP error that is returned when I leave out the OU: > > {'info': '00000000: LdapErr: DSID-0C090627, comment: In order to > perform this operation a successful bind must be completed on the > connection., data 0, vece', 'desc': 'Operations error'} This clearly indicates that the bind was not successful and you're trying anonymous search access here which is not allowed in default configuration of AD. I'm not sure whether you can allow anonymous access at ou-level. You could try to use trace_level=2 to check whether bind is really successful and which bind-DN and credentials are actually used. Ciao, Michael. From gherron at islandtraining.com Mon Apr 28 12:53:54 2008 From: gherron at islandtraining.com (Gary Herron) Date: Mon, 28 Apr 2008 09:53:54 -0700 Subject: Given a string - execute a function by the same name In-Reply-To: <1209400401.22706.1250293015@webmail.messagingengine.com> References: <1209400401.22706.1250293015@webmail.messagingengine.com> Message-ID: <48160122.8080907@islandtraining.com> python at bdurham.com wrote: > I'm parsing a simple file and given a line's keyword, would like to call > the equivalently named function. > > There are 3 ways I can think to do this (other than a long if/elif > construct): > > 1. eval() > > 2. Convert my functions to methods and use getattr( myClass, "method" ) > > 3. Place all my functions in dictionary and lookup the function to be > called > > Any suggestions on the "best" way to do this? > > Thank you, > Malcolm > -- > http://mail.python.org/mailman/listinfo/python-list > You are on the right track with (2), but you need not do any conversion. All objects that have attributes (and a function is an attribute) can be looked up with getattr. For instance, from a module (function getcwd from modules os): >>> import os >>> getattr(os,'getcwd') >>> getattr(os,'getcwd')() '/home/gherron' You can use getattr with objects, classes, modules, and probably more. Gary Herron From stanc at al.com.au Fri Apr 18 04:57:35 2008 From: stanc at al.com.au (Astan Chee) Date: Fri, 18 Apr 2008 18:57:35 +1000 Subject: testing client-server sockets Message-ID: <4808627F.5040906@al.com.au> Hi, I have a client-server socket script in python. Something like this http://ubuntuforums.org/showthread.php?t=208962 Now the problem I have is that I want to try to connect the client to the server on the same machine, but it gives me a 'port already in use' error. I just want the client to connect to the server for testing purposes. Any suggestions on how I should do this? Thanks Astan -- "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." Animal Logic http://www.animallogic.com Please think of the environment before printing this email. This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. From s0suk3 at gmail.com Tue Apr 22 12:32:36 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Tue, 22 Apr 2008 09:32:36 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: On Apr 22, 5:25?am, azrael wrote: > Hy guys, > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. > > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" > > This hurts. Please give me informations about realy famous > aplications. Those would be insulting statements, but only if he wouldn't be a Perl programmer. Everyone knows Perl's best days are long gone. Perl is not a competent language anymore. I bet your friend is a system administrator or something like that, because the only use for Perl is writing quick-and-dirty scripts, and that's something that sysadmins do the whole day. Anyway, seeing that nobody has posted on the "big applications" matter, here are some examples: Zope ( http://www.zope.org ), Medusa ( http://www.nightmare.com/medusa ), Grail ( http://grail.sourceforge.net ). On the "Python vs. Perl" matter, well, just search "Python Perl" on Google or some other search engine, you'll literally find nothing but pages talking about how Python is better than Perl. On the other hand, I do admit that there's no other language better than Perl to write a 3-10 line long program. In those cases, the Perl version will not only be smaller than the C version, but even smaller than the Python version. This is mostly due to Perls default variables and "magic" events (like reading a line of a file directly into $_ when you're doing while () {...}, or automatically converting between integer/string or scalar/list depending on the operators and context ). But a competent developer won't be writing such small scripts, unless, as I said, you're a sysadmin or something like that. Otherwise, there's no reason to use something as ugly and unconventional as Perl. From luismgz at gmail.com Thu Apr 3 11:34:24 2008 From: luismgz at gmail.com (=?ISO-8859-1?Q?Luis_M=2E_Gonz=E1lez?=) Date: Thu, 3 Apr 2008 08:34:24 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> <89bca327-6a3f-4128-be72-75d4a50b9bf0@13g2000hsb.googlegroups.com> <47f4e456$0$20141$426a74cc@news.free.fr> Message-ID: <366134d3-2e6b-4521-9197-c8236326cf30@e39g2000hsf.googlegroups.com> On 3 abr, 11:06, Bruno Desthuilliers wrote: > Luis M. Gonz?lez a ?crit : > > > I have come to the same conclusion. > > ORMs make easy things easier, but difficult things impossible... > > Not my experience with SQLAlchemy. Ok, I still not had an occasion to > test it against stored procedures, but when it comes to complex queries, > it did the trick so far - and (warning: front-end developper > considerations ahead) happened to be much more usable than raw strings > to dynamically *build* the queries. > > > The best approach I've seen so far is webpy's (if we are talking of > > web apps). > > It isn't an ORM, it is just a way to make the database api easier to > > use. > > Queries don't return objects, they return something similar to > > dictionaries, which can be used with dot notation ( for example, > > result.name is equal to result['name'] ). > > > A simple select query would be db.select('customers') or > > db.select('customers', name='John'). > > But you can also resort to plain sql as follows: db.query('select * > > from customers where name = "John"'). > > > Simple, effective and doesn't get in your way. > > Seems nice too in another way. Is that part independant of the rest of > the framework ? If so, I'll have to give it a try at least for admin > scripts. Yes, webpy's db api can be used in stand-alone scripts if you want. See below: import web db = web.database(dbn='mysql', db='northwind', user='root') x = db.select('employees') for i in x: print i.FirstName, i.LastName ... Another good thing is that, since queries return Storage objects (similar to dictionaries), they are much more flexible. Suppose that you get the results of a form sent via a POST method, and you want to insert this data into your database. You would simple write: i = web.input() db.insert('orders', **i) So everything related to CRUD operations are is easy to do, without having to mess with objects. I think this sticks strictly to the KISS principle, keeping it simple, with less overhead, less layers of abstraction and therefore, less bugs and complications. And it matchs perfectly webpy's philosofy for creating web apps. Luis From hobgoodoreneyhb at gmail.com Tue Apr 22 11:40:59 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:40:59 -0700 (PDT) Subject: photodraw crack Message-ID: photodraw crack http://cracks.12w.net F R E E C R A C K S From lists at cheimes.de Sat Apr 12 11:13:51 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 12 Apr 2008 17:13:51 +0200 Subject: str(bytes) in Python 3.0 In-Reply-To: <87k5j3f7m8.fsf@pobox.com> References: <87k5j3f7m8.fsf@pobox.com> Message-ID: <4800D1AF.9020808@cheimes.de> John J. Lee schrieb: > Why hasn't the one-argument str(bytes_obj) been designed to raise an > exception in Python 3? See for yourself: $ ./python Python 3.0a4+ (py3k:0, Apr 11 2008, 15:31:31) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> str(b'') "b''" [38544 refs] >>> bytes("") Traceback (most recent call last): File "", line 1, in TypeError: string argument without an encoding [38585 refs] $ ./python -b Python 3.0a4+ (py3k:0, Apr 11 2008, 15:31:31) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> str(b'') __main__:1: BytesWarning: str() on a bytes instance "b''" [38649 refs] Christian From mfb.chikazuku at gmail.com Sun Apr 13 18:39:58 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Mon, 14 Apr 2008 00:39:58 +0200 Subject: urllib2 Basic authentication, what am I doing wrong? References: <48025b26$0$6839$2d805a3e@textnews.eweka.nl> <1b67f420-db80-4890-8370-6476063cfadf@f63g2000hsf.googlegroups.com> Message-ID: <48029a0f$0$6838$2d805a3e@textnews.eweka.nl> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Max Erickson wrote: > On Apr 13, 2:11?pm, Michel Bouwmans wrote: > >> Using this nice class (adapted to urllib2) as a basehandler I see that no >> Authentication-header is being send >> out:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440574 >> >> What am I doing wrong here? I spend almost my entire free time today on >> this and couldn't find any problem with my code, anyone else has a >> thought? Thanks in advance. >> >> MFB > > I've attempted to use a password manager and auth manager and failed > in the past, so this is only a guess, but presumably, between the > realm and uri that you are providing to the password manager, it isn't > providing a password for the page you want to load. I've had success > just explicitly setting the authorization header, using the method > discussed in the comments on this page: > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/267197 > > > max Thanks for that tip. I tried that and found out that I was still being rejected eventhough the correct Authorization was being send. I then experimented a bit with liveHTTPheaders and it's replay function in firefox and found out that it needed the cookie to succesfully authenticate. I'll try to fix it with that knowledge. Strange software I'm dealing with here, that's for sure. MFB -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFIAovCDpaqHmOKFdQRAuHXAJ9vGNdR2e8s8iA0Z5zIzxASjES3LgCfbVSU 339iu5iO1rv1Ufh0xNntNeY= =2xbX -----END PGP SIGNATURE----- From arnodel at googlemail.com Tue Apr 29 17:46:13 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Tue, 29 Apr 2008 22:46:13 +0100 Subject: string translate, replace, find and the forward slash References: <1030ffc2-1bbe-4539-881d-35bf59cacd11@34g2000hsh.googlegroups.com> Message-ID: destroooooy writes: > On Apr 29, 4:50 pm, Arnaud Delobelle wrote: >> >> marigold:junk arno$ python >> Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) >> [GCC 4.0.1 (Apple Inc. build 5465)] on darwin >> Type "help", "copyright", "credits" or "license" for more information. >> >> >>> unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n" >> >>> table = range(256) >> >>> for c in unsafe_chars: table[ord(c)] = ord('_') >> ... >> >>> table = ''.join(chr(o) for o in table) >> >>> 'Jon(&Mark/Steve)'.translate(table) >> 'Jon__Mark_Steve_' >> >> -- >> Arnaud > > > Okay, so that definitely works. Thanks! > > However, the chances of me coming up with that on my own were > completely nonexistent, and I'd still like to know how one would use > maketranstable() to get the same result... Do you mean maketrans() from the string module? I didn't know about it, but I've tried it and it works too: >>> import string >>> unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n" >>> alt_chars = "_________________________" >>> table = string.maketrans(unsafe_chars, alt_chars) >>> "a/b/c".translate(table) 'a_b_c' >>> -- Arnaud From ron.longo at cox.net Sun Apr 13 18:28:27 2008 From: ron.longo at cox.net (Ron Provost) Date: Sun, 13 Apr 2008 18:28:27 -0400 Subject: A "Fixed" Tk Text widget Message-ID: <001d01c89db5$b245cf20$6501a8c0@aristotle> I have just completed and uploaded to the Tkinter wiki a "Fixed" version of the Tk Text widget called EnhancedText. This new widget (subclassed from Text) is intended to fix some of the quirks of the Text widget involving cursor movement. Namely, in Text, the cursor moves by paragraph rather than display-line when using the Up and Down arrow keys and it jumps to the beginning and end of a paragraph when using the 'Home' and 'End' keys. EnhancedText rewrites all the event handling of the Text widget. With EnhancedText, Up, Down, Home and End now move according to display lines rather than Paragraphs. This widget can be found here http://tkinter.unpythonic.net/wiki/EnhancedText. Thanks for any comments, bug reports, etc. Ron Longo -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob at passcal.nmt.edu Sat Apr 19 17:50:05 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Sat, 19 Apr 2008 15:50:05 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041816413450073-bob@passcalnmtedu> Message-ID: <2008041915500575249-bob@passcalnmtedu> On 2008-04-18 21:33:34 -0600, Grant Edwards said: > On 2008-04-18, Bob Greschke wrote: > >> I'm on a Solaris 8 with Python 2.3.4 and when crunching >> through, literally, millions and millions of samples of >> seismic data fingers point out the difference nicely. :) I'll >> look into this more on some of our bigger better faster >> machines (there is no -m option for timeit on the Sun :). The >> Sun is just what I develop on. If stuff runs fast enough to >> keep me awake on there over an ssh'ed X11 connection it should run even >> better on the real field equipment (Macs, >> Linuxes, WinXPs). > > If time is an issue, I might write a C program to convert the > files from 24-bit numbers to 32-bit numbers. Then you can use > numpy to load huge arrays of them in a single whack. Yes you could. :) But this is all in real time (as in 'gotta have it right now' real time). Plus we're dealing with 100's of files (instruments) at a time. It'll be 1000's of instruments this summer up in Canada. Here's the program having happily crunched away at nearly twice the speed it was the day before yesterday. www.greschke.com/unlinked/files/pocus.png The white dots come from the 3-byte integers and make up the green line which makes up one 'logical' chunk (in this case they recorded for 60mins at a time) of a whole data file with one file per instrument. Generally we just take a quick look at the green lines to make sure the instruments were working, and pull out the bad ones so they don't get used again until they've been looked at. Zooming in to the level where you can see the individual samples is used to (more) accurately determine the time when an [intentional] explosion was set off. You use instruments placed near the shot holes for that. Simple. :) Bob From skanemupp at yahoo.se Fri Apr 18 12:20:26 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 18 Apr 2008 09:20:26 -0700 (PDT) Subject: Tkinter, getting canvas-object, how? Message-ID: <4d5c6911-7728-4dad-8d8d-7a862bf78d70@k13g2000hse.googlegroups.com> so i load a gif onto a canvas and when i click the canvs i want to get the color of the pixel that is clicked. so i need to ge the object im clicking. i was told in another thread to use find_withtag or find_closest but it is not working, maybe im using the method on the wrong object. how do i do this? and how do i then get specifics about that object, ie the pixel-color? Exception in Tkinter callback Traceback (most recent call last): File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ return self.func(*args) File "C:\Users\saftarn\Desktop\pythonkod\mapexperiments \mapgetobject.py", line 17, in callback undermouse=find_closest(master.CURRENT) NameError: global name 'find_closest' is not defined from Tkinter import * master = Tk() w = Canvas(master, width=400, height=625) w.pack(expand = YES, fill = BOTH) mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\Maps\provinces-of- sweden.gif') w.create_image(30, 30, image = mapq, anchor = NW) def key(event): print "pressed", repr(event.char) def callback(event): clobj=event.widget ## undermouse=find_withtag(master.CURRENT) undermouse=find_closest(master.CURRENT) print repr(undermouse) w.bind("", key) w.bind("", callback) w.pack() mainloop() From sbergman27 at gmail.com Thu Apr 17 18:33:49 2008 From: sbergman27 at gmail.com (Steve Bergman) Date: Thu, 17 Apr 2008 15:33:49 -0700 (PDT) Subject: How to make this unpickling/sorting demo faster? References: <40a5d8f1-a246-4c48-8759-5b65324f9029@m73g2000hsh.googlegroups.com> <7xod88w5l5.fsf@ruckus.brouhaha.com> Message-ID: <672d4491-35b5-4eb5-94bc-13d4b23ba797@d45g2000hsc.googlegroups.com> Thanks for the help. Yes, I see now that gdbm is really superfluous. Not having used pickel before, I started from the example in "Python in a Nutshell" which uses anydbm. Using a regular file saves some time. By far, the biggest improvement has come from using marshall rather than cPickel. Especially for writing. gc.disable() shaved off another 20%. I can't use psyco because I'm on x86_64. And my goal is to demonstrate how Python can combine simplicity, readability, *and* speed when the standard library is leveraged properly. So, in this case, calling C or assembler code would defeat the purpose, as would partitioning into smaller arrays. And my processor is single core. I started at about 7 seconds to just read in and sort, and at 20 seconds to read, sort, and write. I can now read in, sort, and write back out in almost exactly 5 seconds, thanks to marshal and your suggestions. I'll look into struct and ctypes. Although I know *of* them, I'm not very familiar *with* them. Thank you, again, for your help. From kyosohma at gmail.com Tue Apr 22 23:25:14 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 22 Apr 2008 22:25:14 -0500 Subject: list manipulation In-Reply-To: <480e62b4$1@news.mel.dft.com.au> References: <78158460-8508-4453-a2dc-c5814dda8839@59g2000hsb.googlegroups.com> <480e62b4$1@news.mel.dft.com.au> Message-ID: <480EAC1A.1010505@gmail.com> John Machin wrote: > Mike Driscoll wrote: > >> Well you could always do something like this: >> >> output = ';'.join(roadList) >> >> Which will put single quotes on the ends. > > No, it doesn't. You are conflating foo and repr(foo). > > I suppose if you want to be >> silly, you could do this: >> >> output = '"%s"' % ';'.join(roadList) > > *IF* your first effort were to put single quotes on the ends > ('the-text') then your second effort would certainly produce something > silly ... either '"the-text"' or "'the-text'" depending on which of > the assignment or the join method you imagined was producing the > single quotes. > -- > http://mail.python.org/mailman/listinfo/python-list Well, in IDLE's output, it looked like what the OP wanted and the OP seemed to find my examples helpful. Besides, you did almost the exact same thing in your final example. Mike From jewelry087 at jewelry-wholesaler.net Thu Apr 3 00:28:53 2008 From: jewelry087 at jewelry-wholesaler.net (jewelry087 at jewelry-wholesaler.net) Date: Wed, 2 Apr 2008 21:28:53 -0700 (PDT) Subject: Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 Message-ID: <0a735ceb-adcc-4eac-80c3-e8a51bcdc6c5@q27g2000prf.googlegroups.com> Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 Link : http://www.aaa-replica-watch.com/Chopard_27_8361_23.html Buy the cheapest Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 in toppest Replica . www.aaa-replica-watch.com helps you to save money! Chopard-27-8361-23 , Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 , Replia , Cheap , Fake , imitation , Chopard Watches Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 Information : Brand : Chopard Watches (http://www.aaa-replica-watch.com/ Replica_Chopard.html ) Gender : Ladies Model : Chopard-27-8361-23 Case Material : Stainless Steel Case Diameter : 27/8361-23 Dial Color : White Bezel : 104 Diamonds Movement : Quartz Clasp : Black Leather Water Resistant : 30m/100ft Crystal : Scratch Resistant Sapphire Our Price : $ 225.00 Stainless steel case. Black leather strap. White dial with 7 floating diamonds. Bezel set with 104 diamonds. Date displays at 6 o'clock position. Sapphire cabochon crown. 4 sapphire cabochon lugs. Quartz movement. Water resistant at 30 meters (100 feet). Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 Replica, With the mix of finest craftsmanship and contemporary styling, not only does it reflect the time but also care you put into looking good. choose one to promote your quality and make yourself impressive among people .Lowest Price Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 Thank you for choosing www.aaa-replica-watch.com as your reliable dealer of quality waches including Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 . we guarantee every watch you receive will be exact watch you ordered. Each watch sold enjoy one year Warranty for free repair. Every order from aaa-replica-watches is shipped via EMS, the customer is responsible for the shipping fee on the first order, but since the second watch you buy from our site, the shipping cost is free. Please note that If the total amount of payment is over $600(USD), the customer is required to contact our customer service before sending the money in case failed payment. If you have any other questions please check our other pages or feel free to email us by service at aaa-replica-watch.com. Cheapest Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 The Same Chopard Watches Series : Chopard Happy Sport Diamond 18kt Yellow Gold And Steel Ladies Watch 27/8251-23/11 : http://www.aaa-replica-watch.com/Chopard_27_8251_23_11.html Chopard Happy Sport Diamond 18kt Yellow Gold And Steel Ladies Watch 27/8249-23 : http://www.aaa-replica-watch.com/Chopard_27_8249_23_WH.html Chopard Happy Sport Diamond 18kt Yellow Gold And Steel Blue Ladies Watch 27/8249-23 : http://www.aaa-replica-watch.com/Chopard_27_8249_23_BU.html Chopard Happy Sport Black/White Diamond 18kt White Gold Mens Watch 28/3340-50 : http://www.aaa-replica-watch.com/Chopard_28_3340_50.html Chopard Happy Sport Diamond Steel Pink Ladies Watch 27/8245-21 : http://www.aaa-replica-watch.com/Chopard_27_8245_21.html Chopard Happy Sport Diamond Moon/Stars Steel Ladies Watch 27/8250-21 : http://www.aaa-replica-watch.com/Chopard_27_8250_21.html Chopard Happy Sport Diamond Steel Ladies Mini Watch 27/8294-23 2R : http://www.aaa-replica-watch.com/Chopard_27_8294_23.html Chopard Happy Beach Diamond Fish Steel Blue Mini Ladies Watch 27/8923 : http://www.aaa-replica-watch.com/Chopard_278923_DKBLUE.html Chopard Happy Beach Jeweled Fish Black Rubber Unisex Watch 27/8921-402 : http://www.aaa-replica-watch.com/Chopard_278921_402_BK.html Chopard Happy Beach Diamond Fish Steel Blue Mini Ladies Watch 27/8923 : http://www.aaa-replica-watch.com/Chopard_27_8923.html Chopard Happy Beach Diamond Fish Steel Black Unisex Watch 28/8347-8 : http://www.aaa-replica-watch.com/Chopard_28_8347_8.html Chopard Happy Beach Diamond Fish Steel Blue Ladies Watch 27/8925 : http://www.aaa-replica-watch.com/Chopard_27_8925.html cheap ,lowest price , AAA Best Chopard Happy Sport Diamond Steel Black Ladies Watch 27/8361-23 From kyosohma at gmail.com Tue Apr 15 15:27:36 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 15 Apr 2008 12:27:36 -0700 (PDT) Subject: Recurring patterns: Am I missing it, or can we get these added to the language? References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: On Apr 15, 1:51 pm, Erich wrote: > Hello all, > > Today I found myself once again defining two functions that I use all > the time: nsplit and iterable. These little helper functions of mine > get used all the time when I work. Im sick of having to define them > (but am very good at it these days, less than 1 typo per function!). > It leads me to the following questions > > 1. Is this functionality already built in and im just missing it > 2. Is there some well known, good technique for these that I missed? > 3. Insert question I need to ask here (with a response) > > These are the funtions w/ explaination: > > def nsplit(s,p,n): > n -= 1 > l = s.split(p, n) > if len(l) < n: > l.extend([''] * (n - len(l))) > return l > The split() method has a maxsplit parameter that I think does the same thing. For example: >>> temp = 'foo,bar,baz' >>> temp.split(',', 1) ['foo', 'bar,baz'] See the docs for more info: http://docs.python.org/lib/string-methods.html > This is like split() but returns a list of exactly lenght n. This is > very useful when using unpacking, e.g.: > x, y = nsplit('foo,bar,baz', ',', 2) > > def iterable(item, count_str=False): > if not count_str and isinstance(item, str): > return False > try: > iter(item) > except: > return False > return True > This is just simple boolean test for whether or not an object is > iterable. I would like to see this in builtins, to mirror callable. > The optional count_str adds flexibility for string handling, since > sometimes I need to iterate over a string, but usually not. I > frequently use it to simplify my case handling in this type of > costruct: > > def foo(bar): > bar = bar if iterable(bar) else [bar] > for x in bar: > .... > > Thanks for feeback, > Erich Not sure about the other one, but you might look at itertools. Mike From john106henry at hotmail.com Sat Apr 26 02:18:24 2008 From: john106henry at hotmail.com (John Henry) Date: Fri, 25 Apr 2008 23:18:24 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. Message-ID: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> For serveral years, I have been looking for a way to migrate away from desktop GUI/client-server programming onto the browser based network computing model of programming. Unfortunately, up until recently, browser based programs are very limited - due to the limitation of HTML itself. Eventhough PythonCard hasn't keep up with the latest widgets in wxpython, the programs so created still works a lot better - until now. If you look at programs at some of the major sites these days - like Google calendar, Netflix, blockbuster, and so forth - you would undoubtedly notice that the quality of the programs are pretty much at par with the desktop programs we use everyday. Since the curious mind wanted to know how these programs are done, I started investigating and found out that what a difference a few years have made to Javascript - the once much hated beast of the Internet age - and during my search for perfection, I found Qooxdoo (http:// qooxdoo.org/). Qooxdoo is a Javascript toolkit that sits on top of Ajax. Take a look at some of the *impressive* widgets at http://demo.qooxdoo.org/current/showcase/#Form. So, what's that got to do with Pythoncard? Read on. After trying for a few days learning Qooxdoo, my head really really hurts. Getting too old to learn this stuff, I was mumbling. Then I looked some more. I found QxTransformer (http:// sites.google.com/a/qxtransformer.org/qxtransformer/Home) which is a XSLT toolkit that creats XML code that invoke qooxdoo. So, what's that got to do with Pythoncard? Read on. After trying for a few days learning QxTransformer, my head really really hurts. Getting too old to learn this stuff, I was mumbling. I want Pythoncard. Damn Pythoncard! Once you got hooked, everything else looks impossibly complicated and unproductive. But then I looked closer. It turns out the XML file created by QxTransformer is *very* similar in structure when compared to the resource files used in PythonCard. Since there are no GUI builders for QxTransformer, and I can't affort to buy the one for Qooxdoo (Java! Yuk!), I decided to roll up my sleeves, took the Pythoncard's Layout Manager and modified it and created my own "Poor Man's Qooxdoo GUI Layout Designer". The result? See the partially completed application at: http://test.powersystemadvisors.com/ and the same application running from the desktop: http://test.powersystemadvisors.com/desktopHelloWorld.jpg It shouldn't be long before I can fill in the gaps and have the GUI builder maps the rest of the Pythoncard widgets to Qooxdoo widgets. Once I've done that, I can have the same application running from the desktop, or from the browser. And it shouldn't take more than minutes to create such applications. Welcome to the modernized world of Pythoncard!!! From nemesis at nowhere.invalid Mon Apr 21 15:14:56 2008 From: nemesis at nowhere.invalid (Nemesis) Date: 21 Apr 2008 19:14:56 GMT Subject: Does Python 2.5.2's embedded SQLite support full text searching? References: Message-ID: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> Ed Leafe wrote: >> Sqlite itself is not distributed with python. Only a python db api >> compliant wrapper is part of the python stdlib and as such it is >> completely independent of the sqlite build. > > Don't most binary distributions include SQLite itself? I installed > 2.5.2 on a new WinXP VM, and SQLite is working fine. So did I. I installed py2.5.2 on windows and didn't install SQLite, and I'm using the module sqlitedb without problems. -- Let us make a special effort to stop communicating with each other, so we can have some conversation. _ _ _ | \| |___ _ __ ___ __(_)___ | .` / -_) ' \/ -_|_-< (_-< |_|\_\___|_|_|_\___/__/_/__/ http://xpn.altervista.org From gagsl-py2 at yahoo.com.ar Fri Apr 25 00:07:56 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 25 Apr 2008 01:07:56 -0300 Subject: How to get inner exception traceback References: <67b8nuF2m1a1kU1@mid.individual.net> Message-ID: En Thu, 24 Apr 2008 08:20:29 -0300, Thomas Guettler escribi?: > How can you get the traceback of the inner exception? > > try: > try: > import does_not_exit > except ImportError: > raise Exception("something wrong") > except: > ... > > > Background: In Django some exceptions are caught and a new > exception gets raised. Unfortunately the real error is hard > to find. Sometimes I help myself and change (in this example) > ImportError to e.g. IOError and then I can see the real root > of the problem. But maybe there is a way to get the inner > exception and its traceback. This could be displayed in the > debug view. You already got a couple ways to do it - but I'd ask why do you want to mask the original exception? If you don't have anything valuable to do with it, just don't catch it. Or raise the *same* exception+context, perhaps after modifying it a bit: try: try: import does_not_exist except ImportError, e: e.args = ("Something is wrong with the plugin system\nDetails: %s" % e.args,) raise # <-- note the "bare" raise except: import traceback print "An error has occurred" print sys.exc_info()[1] print sys.exc_info()[0].__name__ traceback.print_tb(sys.exc_info()[2]) # or whatever you want to do with the exception -- Gabriel Genellina From dblubaugh at belcan.com Thu Apr 24 12:28:29 2008 From: dblubaugh at belcan.com (Blubaugh, David A.) Date: Thu, 24 Apr 2008 12:28:29 -0400 Subject: MESSAGE RESPONSE References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com><27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com><678v5qF2me5rvU1@mid.uni-berlin.de> <5504f9ac0804230927ncfdb91buf7fa3e181f8a9237@mail.gmail.com> Message-ID: <27CC3060AF71DA40A5DC85F7D5B70F3801185540@AWMAIL04.belcan.com> Dear Sir, Belcan has an absolute zero-tolerance policy toward material such as the material described. Thank you for your Concern, David Blubaugh ________________________________ From: Dan Upton [mailto:upton at virginia.edu] Sent: Wed 4/23/2008 12:27 PM To: python-list at python.org Subject: Re: MESSAGE RESPONSE On Wed, Apr 23, 2008 at 10:24 AM, Diez B. Roggisch wrote: > Blubaugh, David A. schrieb: > > > Is there a way to block these messages. I do not want to be caught > > with filth such as this material. I could lose my job with Belcan with > > evil messages such as these messages. > > > > If I (or *anybody*) knew how to block these messages, he or she would sell > the resulting spam-filter for a fortunen that roughly amasses the one of > scrooge mc duck - and go live on the bahamas or even buy them. > > Put up with it. It's (unfortunately) part of ze internet tubes. > And as such, I find it hard to believe you could lose your job over it. This e-mail transmission contains information that is confidential and may be privileged. It is intended only for the addressee(s) named above. If you receive this e-mail in error, please do not read, copy or disseminate it in any manner. If you are not the intended recipient, any disclosure, copying, distribution or use of the contents of this information is prohibited. Please reply to the message immediately by informing the sender that the message was misdirected. After replying, please erase it from your computer system. Your assistance in correcting this error is appreciated. From mdboldin at gmail.com Wed Apr 23 11:15:12 2008 From: mdboldin at gmail.com (mmm) Date: Wed, 23 Apr 2008 08:15:12 -0700 (PDT) Subject: DTD validation and xmlproc Message-ID: I found Python code to validate a XML document basd on DTD file layout. The code uses the 'xmlproc' package and these module loading steps from xml.parsers.xmlproc import xmlproc from xml.parsers.xmlproc import xmlval from xml.parsers.xmlproc import xmldtd Unfortunately, the xml package no longer seems to hold the xmlproc module. As a standalone the xmlproc module seems to be no longer maintained and was subsumed in PyXML a few years ago and that package is no longer maintained (as best I can tell, or maybe was subsumed in the base Python 2.x packages) My problem is I can not get the old xmlproc package files that i did find to work with Python 2.5. I am willing to learn and use new xml procedures, but I found nothng pre-written to validate agaisnt a given DTD file. Any advice would be welcome, even a good tutorial on XML validation usiog Python. From gagsl-py2 at yahoo.com.ar Sun Apr 20 04:12:24 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 05:12:24 -0300 Subject: Request a short code review References: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> <33a50f5b-f82d-41aa-b28f-b00dba4bf2eb@m73g2000hsh.googlegroups.com> Message-ID: En Fri, 18 Apr 2008 15:10:09 -0300, escribi?: > lessons = self.lesson_data["lessons"] > if lesson_type: > lessons = [x for x in lessons if x["type"] == lesson_type] > > Changes: > - generator expression instead of filter The above is not a generator expression, it's a list comprehension. They look similar. This is a list comprehension: py> a = [x for x in range(10) if x % 2 == 0] py> a [0, 2, 4, 6, 8] Note that it uses [] and returns a list. This is a generator expression: py> g = (x for x in range(10) if x % 2 == 0) py> g py> g.next() 0 py> g.next() 2 py> for item in g: ... print item ... 4 6 8 Note that it uses () and returns a generator object. The generator is a block of code that runs lazily, only when the next item is requested. A list is limited by the available memory, a generator may yield infinite items. > Cheers again. This is very valuable for me. I am a true believer > that if one takes care in the smallest of methods then the larger code- > base will be all the better. Sure. -- Gabriel Genellina From danb_83 at yahoo.com Sun Apr 27 18:41:37 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Sun, 27 Apr 2008 15:41:37 -0700 (PDT) Subject: A small and very basic python question References: Message-ID: <13361dd1-5269-4afd-b2ca-972d32f09bf9@w1g2000prd.googlegroups.com> On Apr 27, 5:26 pm, Dennis wrote: > Dennis wrote: > > Could anyone tell me how this line of code is working: > > > filter(lambda x: x in string.letters, text) > > > I understand that it's filtering the contents of the variable text and I > > know that lambda is a kind of embedded function. > > > What I'd like to know is how it would be written if it was a normal > > function. > > I didn't give up after posting and managed to grasp this whole lambda > thing! No need to respond now :-) I understood it the moment I tried to > type out, instead of just thinking in my head, what was going on as a > normal function. I will respond anyway, just to say that you COULD have written: ''.join(char for char in text if char.isalpha()) thus avoiding lambda altogether. From ellingt8877 at gmail.com Mon Apr 28 01:51:43 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:51:43 -0700 (PDT) Subject: fostex ds-8 digital patch bay Message-ID: <2b421ec5-c9d3-4d6b-a9e4-f74405e0d5a3@k1g2000prb.googlegroups.com> fostex ds-8 digital patch bay http://crack.cracksofts.com From bruno.desthuilliers at gmail.com Sun Apr 6 11:35:09 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Sun, 6 Apr 2008 08:35:09 -0700 (PDT) Subject: Presumably an import is no faster or slower than opening a file? References: <47f8d30f$0$761$bed64819@news.gradwell.net> Message-ID: <546467f9-807c-475b-a2ae-9e8faae03825@u3g2000hsc.googlegroups.com> On 6 avr, 15:41, tinn... at isbd.co.uk wrote: > I'm trying to minimise the overheads of a small Python utility, I'm > not really too fussed about how fast it is but I would like to > minimise its loading effect on the system as it could be called lots > of times (and, no, I don't think there's an easy way of keeping it > running and using the same copy repeatedly). > > It needs a configuration file of some sort which I want to keep > separate from the code, is there thus anything to choose between a > configuration file that I read after:- > > f = open("configFile", 'r') > > ... and importing a configuration written as python dictionaries or > whatever:- > > import myConfig In both cases, you'll have to open a file. In the first case, you'll have to parse it each time the script is executed. In the second case, the first import will take care of compiling the python source to byte- code and save it in a myConfig.pyc file. As long as the myConfig.py does not change, subsequent import will directly use the .pyc, so you'll save on the parsing/compiling time. FWIW, you can even "manually" compile the myConfig.py file, after each modification, and only keep the myConfig.pyc in your python path, so you'll never get the small overhead of the "search .py / search .pyc / compare modification time / compile / save" cycle. While we're at it, if you worry about the "overhead" of loading the conf file, you'd better make sure that either you force the script compilation and keep the .py out of the path, or at least keep the script.py file as lightweight as possible (ie : "import somelib; somelib.main()", where all the real code is in somelib.py), since by default, only imported modules get their bytecode saved to .pyc file. Now I may be wrong but I seriously doubt it'll make a huge difference anyway, and if so, you'd really preferer to have a long running process to avoid the real overhead of launching a Python interpreter. My 2 cents... > -- > Chris Green From jeffober at gmail.com Thu Apr 3 08:03:10 2008 From: jeffober at gmail.com (Jeff) Date: Thu, 3 Apr 2008 05:03:10 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> Message-ID: def foo(sample, strings): for s in strings: if sample in s: return True return False This was an order of magnitude faster for me than using str.find or str.index. That was finding rare words in the entire word-list (w/ duplicates) of War and Peace. From nullgraph at gmail.com Wed Apr 16 17:26:09 2008 From: nullgraph at gmail.com (nullgraph at gmail.com) Date: Wed, 16 Apr 2008 14:26:09 -0700 (PDT) Subject: vary number of loops References: <480604BE.3090002@tim.thechases.com> Message-ID: On Apr 16, 10:12 am, "Reedick, Andrew" wrote: > > -----Original Message----- > > From: python-list-bounces+jr9445=att.... at python.org [mailto:python- > > list-bounces+jr9445=att.... at python.org] On Behalf Of Tim Chase > > Sent: Wednesday, April 16, 2008 9:53 AM > > To: nullgr... at gmail.com > > Cc: python-l... at python.org > > Subject: Re: vary number of loops > > > > If n=3, I want to have 3 sets of elements and mix them up using 3 > for > > > loops. > > > You might be ineterested in this thread: > > >http://mail.python.org/pipermail/python-list/2008-January/473650.html > > > where various solutions were proposed and their various merits > > evaluated. > > I second that. The thread compared building loops on the fly, building > comprehensions nested to arbitrarily levels, recursion (sloooow!), a > slick cookbook recipe using iterators, etc. and provided timings for > each method. Definitely worth bookmarking. > Yes, I second that second :) Very nice thread, I'm leaning toward the "pythonic method" from there, but thanks for all the other solutions suggested here. Guess I need to go play with lambda more... nullgraph From nyamatongwe+thunder at gmail.com Mon Apr 14 17:35:07 2008 From: nyamatongwe+thunder at gmail.com (Neil Hodgson) Date: Mon, 14 Apr 2008 21:35:07 GMT Subject: Confused about Boost.Python & bjam In-Reply-To: References: Message-ID: Till Kranz: > I tried to get started with Boost.Python. unfortunately I never used the > bjam build system before. As it is explained in the documentation I > tried to adapt the the files form the examples directory. I copied > 'Jamroot', 'boost_build.jam' and 'extending.cpp' to '~/test/'. But I am > lost as to what to do now. Yes, Boost.Python is difficult to use and the documentation isn't that clear. I've pretty much given up for now but I do have a project called SinkWorld that works with Boost.Python. You can access the CVS at http://scintilla.cvs.sourceforge.net/scintilla/sinkworld/ and the jam config files are in the tentacle/python directory as http://scintilla.cvs.sourceforge.net/scintilla/sinkworld/tentacle/python/Jamfile?revision=1.6&view=markup http://scintilla.cvs.sourceforge.net/scintilla/sinkworld/tentacle/python/boost-build.jam?revision=1.2&view=markup http://scintilla.cvs.sourceforge.net/scintilla/sinkworld/tentacle/python/Jamrules?revision=1.2&view=markup There is a mailing list which may be able to help: http://mail.python.org/mailman/listinfo/c++-sig Neil From thinkofwhy at yahoo.ca Wed Apr 30 14:58:32 2008 From: thinkofwhy at yahoo.ca (thinkofwhy) Date: Wed, 30 Apr 2008 18:58:32 GMT Subject: calling variable function name ? In-Reply-To: References: <57461074-8fd1-4e65-9bc9-2ac916aa1fb5@y21g2000hsf.googlegroups.com> Message-ID: Try a dictionary: def funcA(blah, blah) def funcB(blah, blah) def funcC(blah, blah) functions = {'A': funcA, 'B': funcB, 'C': funcC} user_func = 'A' functions[user_func] #execute function "Arnaud Delobelle" wrote in message news:m28wyvba54.fsf at googlemail.com... > TkNeo writes: > >> >> George - Thanks for your reply but what you >> suggested is not working: >> >> def FA(param1,param2): >> print "FA" + param1 + " " + param2 >> def FA(param1,param2): >> print "FB" + param1 + " " + param2 >> def FA(param1,param2): >> print "FC" + param1 + " " + param2 >> >> temp = sys.argv[1] >> >> func = globals()["F" + temp] >> func("Hello", "World") >> >> >> I ran the script with first parameter as B and >> i get the following >> message >> KeyError: 'FB' > > Perhaps if you call your three function FA, FB, > FC instead of FA, FA, > FA it'll help? > > -- > Arnaud From arnodel at googlemail.com Tue Apr 8 15:56:38 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Tue, 8 Apr 2008 12:56:38 -0700 (PDT) Subject: calling variable function name ? References: Message-ID: On Apr 8, 8:52?pm, TkNeo wrote: > I don't know the exact terminology in python, but this is something i > am trying to do > > i have 3 functions lets say > FA(param1,param2) > FB(param1,param2) > FC(param1,param2) > > temp = "B" #something entered by user. now i want to call FB. I don't > want to do an if else because if have way too many methods like > this... > > var = "F" + temp > var(param1, param2) > > This does not work ofcourse. Does anyone know how to implement this ? F = { 'A': FA, 'B':FB, 'C':FC } F['A'](param1, param2) HTH -- Arnaud From bwljgbwn at gmail.com Tue Apr 22 05:51:50 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:51:50 -0700 (PDT) Subject: xp pro crack Message-ID: xp pro crack http://cracks.12w.net F R E E C R A C K S From jgodoy at gmail.com Sun Apr 27 13:14:39 2008 From: jgodoy at gmail.com (Jorge Godoy) Date: Sun, 27 Apr 2008 14:14:39 -0300 Subject: design choice: multi-threaded / asynchronous wxpython client? References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> <002cd046-f11d-482e-a67d-4a10a97687a1@x19g2000prg.googlegroups.com> <708eaa6d-3893-407e-83ec-4e6104b0a130@q24g2000prf.googlegroups.com> Message-ID: bullockbefriending bard wrote: > Tempting thought, but one of the problems with this kind of horse > racing tote data is that a lot of it is for combinations of runners > rather than single runners. Whilst there might be (say) 14 horses in a > race, there are 91 quinella price combinations (1-2 through 13-14, > i.e. the 2-subsets of range(1, 15)) and 364 trio price combinations. > It is not really practical (I suspect) to have database tables with > columns for that many combinations? > > I certainly DO have a horror of having my XML / whatever else formats > getting out of sync. I also have to worry about the tote company later > changing their XML format. From that viewpoint, there is indeed a lot > to be said for storing the tote data as numbers in tables. I don't understand anything about horse races... But it should be possible to normalize such information into some tables (not necessarily one). But then, there is nothing that prevents you from having dozens of columns on one table if it is needed (it might not be the most efficient solution performance and disk space-wise depending on what you have, but it works). Using things like that you can even enhance your system and provide more information about each horse, its race history, price history, etc. I love working with data and statistics, so even though I don't know the rules and workings of horse racings, I can think of several things I'd like to track or extract from the information you seem to have :-) How does that price thing work? Are these the ratio of payings for bets? What is a quinella or a trio? Two or three horses in a defined order winning the race? From vinay_sajip at yahoo.co.uk Sat Apr 26 11:05:31 2008 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Sat, 26 Apr 2008 08:05:31 -0700 (PDT) Subject: Logging ancestors ignored if config changes? References: <7770a385-e26d-4ad9-bc72-fa1228034c3b@26g2000hsk.googlegroups.com> Message-ID: <589e7281-07f4-4ad4-a074-fe0818321e21@56g2000hsm.googlegroups.com> On 26 Apr, 04:02, andrew cooke wrote: > Hi, > > I am seeing some odd behaviour withloggingwhich would be explained > if loggers that are not defined explicitly (but which are controlled > via their ancestors) must be created after theloggingsystem is > configured via fileConfig(). > > That's a bit abstract, so here's the problem itself: I define my log > within a module by doing > > importlogging > log =logging.getLogger(__name__) > > Now typically __name__ will be something like "acooke.utils.foo". > > That happens before the application configureslogging, which it does > by callinglogging.config.fileConfig() to load a configuration. > > If I do that, then I don't see anyloggingoutput from > "acooke.utils.foo" (when using "log" from above after "fileConfig" has > been called) unless I explicitly define a logger with that name. > Neither root nor an "acooke" logger, defined in the config file, are > called. > > Is this a bug? Am I doing something stupid? To me the above seems > like a natural way of using the system... > > Thanks, > Andrew It's not a bug, it's by design (for better or worse). A call to fileConfig disables all existing loggers which are not explicitly named in the new configuration. Configuration is intended for one-off use rather than in an incremental mode. Better approaches would be to defer creation of the loggers programmatically until after the configuration call, or else to name them explicitly in the configuration. Regards, Vinay Sajip From leoniaumybragg at gmail.com Sat Apr 26 07:01:19 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 04:01:19 -0700 (PDT) Subject: neupro patch Message-ID: neupro patch http://cracks.00bp.com F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Wed Apr 9 03:17:21 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 04:17:21 -0300 Subject: set file permission on windows References: Message-ID: En Tue, 08 Apr 2008 14:03:06 -0300, Tim Arnold escribi?: > hi, I need to set file permissions on some directory trees in windows > using > Python. The hard way: Use the function SetFileSecurity, the pywin32 package exposes it. See the Microsoft documentation at http://msdn2.microsoft.com/en-us/library/aa374860(VS.85).aspx The easy way: the cacls command -- Gabriel Genellina From nwang1981 at gmail.com Mon Apr 14 12:54:30 2008 From: nwang1981 at gmail.com (=?GB2312?B?zfXE/g==?=) Date: Mon, 14 Apr 2008 12:54:30 -0400 Subject: Java or C++? In-Reply-To: References: Message-ID: My idea, if you really love Python and never think about erasing it from your mind, go for C (not C++). A script language plus C can solve every problem you need to solve. Also Python works pretty fine with C. If you want a better job, maybe Java. Not sure though. If you want to educate yourself about Computer Science (including but not solely programming), maybe List/Scheme/Haskell. If you want to challenge yourself, seriously, go for C++. On Mon, Apr 14, 2008 at 2:44 AM, wrote: > Hello, I was hoping to get some opinions on a subject. I've been > programming Python for almost two years now. Recently I learned Perl, > but frankly I'm not very comfortable with it. Now I want to move on > two either Java or C++, but I'm not sure which. Which one do you think > is a softer transition for a Python programmer? Which one do you think > will educate me the best? > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Sun Apr 20 20:04:22 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 20 Apr 2008 20:04:22 -0400 Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: "Matthew Woodcraft" wrote in message news:hLC*ZjUas at news.chiark.greenend.org.uk... | Terry Reedy wrote: | | > But you do not really need a variant. Just define a preprocessor | > function 'blockify' which converts code in an alternate syntax to | > regular indented block syntax. Then | > | > exec(blockify(alt_code_string)) | | You can do it like that, but if it were to become part of the standard | distribution it would be nice to avoid having to tokenise the code | twice. For the motivating example I was responding to -- short snippets of code in html/xml/etc, that is completely a non-issue. Any such scheme is very unlikely to become part of the stdlib and if it were, it would have to first be tested and beat out competitors. A preprocessor written in Python is the obvious way to test and gain acceptance. | (You could define the new block scheme in such a way that | 'blockify' doesn't need to tokenise, Off the top of my head: copy C and use {} to demarcate blocks and ';' to end statements, so that '\n' is not needed and is just whitespace when present. So, repeatedly scan for the next one of '{};'. | but I think it would end up a bit ugly.) For beautiful, stick with standard Python. Terry Jan Reedy From sierra9162 at gmail.com Wed Apr 16 11:26:05 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:26:05 -0700 (PDT) Subject: kate hudson ryder Message-ID: <57995519-8691-4dca-96e1-789da3789c43@u69g2000hse.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From steve at holdenweb.com Wed Apr 2 12:09:03 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 02 Apr 2008 12:09:03 -0400 Subject: Manipulate Large Binary Files In-Reply-To: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> Message-ID: Derek Tracy wrote: > I am trying to write a script that reads in a large binary file (over > 2Gb) saves the header file (169088 bytes) into one file then take the > rest of the data and dump it into anther file. I generated code that > works wonderfully for files under 2Gb in size but the majority of the > files I am dealing with are over the 2Gb limit > > INPUT = open(infile, 'rb') > header = FH.read(169088) > > ary = array.array('H', INPUT.read()) > Replace this line with a loop that reads 10MB or 100MB chunks at a time. There is little reason to read the whole file in to write it out again. regards Steve > INPUT.close() > > OUTF1 = open(outfile1, 'wb') > OUTF1.write(header) > > OUTF2 = open(outfile2, 'wb') > ary.tofile(OUTF2) > > > When I try to use the above on files over 2Gb I get: > OverflowError: requested number of bytes is more than a Python > string can hold > > Does anybody have an idea as to how I can get by this hurdle? > > I am working in an environment that does not allow me to freely download > modules to use. Python version 2.5.1 > > > > R/S -- > --------------------------------- > Derek Tracy > tracyde at gmail.com > --------------------------------- > -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From ewertman at gmail.com Tue Apr 29 01:38:51 2008 From: ewertman at gmail.com (Eric Wertman) Date: Tue, 29 Apr 2008 01:38:51 -0400 Subject: File IO Issues, help :( In-Reply-To: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> References: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> Message-ID: <92da89760804282238w4a790932yb5ebb5a22038e3d3@mail.gmail.com> chuck in a jsfile.close(). The buffer isn't flushing with what you are doing now. jsfile.flush() might work... not sure. Closing and re-opening the file for sure will help though. On Tue, Apr 29, 2008 at 1:26 AM, Kevin K wrote: > Hey everyone, I'm new to python and am trying to do a little project > with it. I'm running into problems writing over a file. I read from > the file and loop through for a specfic case in which I change > something. After I open and give it opening options (w, r, etc) one of > two things happens: either the file gets truncated and my writing > never takes place (or it seems it doesnt) or everything is appended to > the file and I have a double of what I started with, its never just > the updated file. Can someone shed some light on this for me?? Code > below: > > jsfile = open("../timeline.js", "r+") > jscontent = jsfile.readlines() > jsfile.truncate() > > for line in jscontent: > if re.search('var d =', line): > line = "var d = \""+mint['1'].ascdate()+"\"\n" > print line > jsfile.write(line) > -- > http://mail.python.org/mailman/listinfo/python-list > From victorsubervi at gmail.com Sat Apr 12 15:11:20 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Sat, 12 Apr 2008 14:11:20 -0500 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> Message-ID: <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> in line... On Fri, Apr 11, 2008 at 2:05 PM, Steve Holden wrote: > Victor Subervi wrote: > > I have worked on this many hours a day for two weeks. If there is an > > easier way to do it, just take a minute or two and point it out. Have > > you heard of the Law of Diminishing Returns? I have passed it long ago. > > I no longer want to waste time trying to guess at what you are trying to > > tell me. > > Victor > > > > On Fri, Apr 11, 2008 at 8:55 AM, Steve Holden > > wrote: > Where you have > > content = col_fields[0][14].tostring() > pic = "tmp" + str(i) + ".jpg" > img = open(pic, "w") > img.write(content) > print '

' % pic > img.close() > > instead write > > print content Like this, I presume? img = open(pic, "w") img.write(content) print '' % pic print content # print '

\n' % pic Does not work _at_all LOL. You will recall, also, that you once gave me a line similar to the one commented out (but without writing then opening the file). THAT did not work, either. So now do you see why I am frustrated?? > > > Then browse to the URL this program serves and you will see the image > (assuming you are still sending the image/jpeg content type). Well, as I mentioned before, I am sending text/html because the page, like almost all web pages, has a whole lot more content than just images. Or, perhaps you are suggesting I build my pages in frames, and have a frame for every image. Unsightly! > Once you > can see the image, THEN you can write a page that refers to it. Until > you start serving the image (NOT pseudo-html with image data embedded in > it) nothing else will work. My solution works just fine, thank you. It is inelegant. But it now appears to me, and I dare say rather clearly, that this inelegance is the fault of python itself. Perhaps this should be brought to Guido?s attention. Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From billingspanshism at gmail.com Sat Apr 19 17:16:22 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:16:22 -0700 (PDT) Subject: victoria beckham new haircut Message-ID: <45ee676d-2ac0-4cdb-8900-7c0e011899b8@c65g2000hsa.googlegroups.com> Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From fetchinson at googlemail.com Sun Apr 6 13:41:40 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Sun, 6 Apr 2008 10:41:40 -0700 Subject: @x.setter property implementation In-Reply-To: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> References: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> Message-ID: > I found out about the new methods on properties, .setter() > and .deleter(), in python 2.6. Obviously that's a very tempting > syntax and I don't want to wait for 2.6... > > It would seem this can be implemented entirely in python code, and I > have seen hints in this directrion. So before I go and try to invent > this myself does anyone know if there is an "official" implementation > of this somewhere that we can steal until we move to 2.6? The 2.6 source? From steve at holdenweb.com Sun Apr 13 08:05:53 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 13 Apr 2008 08:05:53 -0400 Subject: String Literal to Blob In-Reply-To: <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> Message-ID: Jason Scheirer wrote: [...] > > There _is_ a way to embed image data in HTML that is supported by > every major browser. It is ugly. Using the RFC 2397 (http:// > www.ietf.org/rfc/rfc2397) spec for data URLs you could go > > '' % base64.b64encode(image_data) > > Obviously you need to import the base64 module somewhere in your code > and base64-encoded data is about a third larger than it would be > otherwise, so embedding anything particularly large is going to be a > huge pain and affect page load times pretty badly. This is hardly likely to help someone who hasn't yet grasped the concept of referencing graphics and prefers to write database output to disk to serve it statically. But who knows, maybe it will ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From steve at holdenweb.com Wed Apr 9 17:04:03 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 17:04:03 -0400 Subject: basic python question about for loop In-Reply-To: References: Message-ID: jmDesktop wrote: >>From the Python.org tutorial: > >>>> for n in range(2, 10): > ... for x in range(2, n): > ... if n % x == 0: > ... print n, 'equals', x, '*', n/x > ... break > ... else: > ... # loop fell through without finding a factor > ... print n, 'is a prime number' > ... > 2 is a prime number > 3 is a prime number > 4 equals 2 * 2 > 5 is a prime number > 6 equals 2 * 3 > 7 is a prime number > 8 equals 2 * 4 > 9 equals 3 * 3 > > > > first time 2 mod 2, 2/2, no remainder == 0, what am I doing wrong? > Why did it fall through? > >>> range(2, 2) [] >>> The loop body executes zero times. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From jjl at pobox.com Sat Apr 12 10:52:31 2008 From: jjl at pobox.com (John J. Lee) Date: Sat, 12 Apr 2008 14:52:31 GMT Subject: str(bytes) in Python 3.0 References: Message-ID: <87k5j3f7m8.fsf@pobox.com> Christian Heimes writes: > Gabriel Genellina schrieb: >> On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') >> above. But I get the same as repr(x) - is this on purpose? > > Yes, it's on purpose but it's a bug in your application to call str() on > a bytes object or to compare bytes and unicode directly. Several months > ago I added a bytes warning option to Python. Start Python as "python > -bb" and try it again. ;) Why hasn't the one-argument str(bytes_obj) been designed to raise an exception in Python 3? John From c.boulanger at qxtransformer.org Tue Apr 29 11:28:30 2008 From: c.boulanger at qxtransformer.org (Panyasan) Date: Tue, 29 Apr 2008 08:28:30 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <473deef3-9acb-45dd-a7ca-47b0081bd28c@i36g2000prf.googlegroups.com> <3f7bb91e-335e-46bd-88ca-f15b26c35132@k1g2000prb.googlegroups.com> <827bdae6-4422-4226-a543-af53f5b7e01b@s33g2000pri.googlegroups.com> Message-ID: > Christian, > > It appears you're missing a file. Where did you placed my program? I > see that there are two places being mentioned: > > > no resource file for /Users/bibliograph/Programme/PythonCard/tools/ > > layoutEditor/multipropertyEditor > > and > > > File "/Library/Python/2.5/site-packages/PythonCard/tools/ > > layoutEditor/layoutEditor.py", line 556, in createDC I unzipped the folder you uploaded and placed it in the PythonCard/ tools folder. I get the same error if I try to start the default resourceEditor.py or layoutEditor.py scripts, so it does not seem to have to do with your modifications. When I copy multipropertyEditor.rsrc.py files from PythodCard/tools/ resourceEditor/modules folder to PythodCard/tools/resourceEditor/, it will throw the error about a different file - might this be some kind of PATH error? C. From gagsl-py2 at yahoo.com.ar Wed Apr 2 23:29:08 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 00:29:08 -0300 Subject: Strange MySQL Problem... References: <4dc0cfea0804021236n1faafabav1699fbe45acc3c01@mail.gmail.com> Message-ID: En Wed, 02 Apr 2008 16:36:43 -0300, Victor Subervi escribi?: > I have this code which works fine: "works fine"? Please check again... The same remarks I've posted earlier apply here. > print 'Content-Type: image/jpeg\r\n' > print '\nHi!\n' Don't you see a conflict among those two lines? (You're a liar: first you promise to send a nice picture and then you only send a letter!) > cursor.execute("CREATE TABLE justatest (name TEXT, ablob BLOB)") Note that you *always* attempt to create a table. > sql = "INSERT INTO justatest VALUES (%s, %s)" > cursor.execute(sql, ('ramis', _mysql.escape_string(f)) ) You're using bound parameters now, a good thing. There is no need to escape strings passed as parameters - in fact, it is wrong, as the adapter will escape the text again. In this case, the column is a BLOB, and you have to use the Binary function: MySQLdb.Binary(f) > Now, if I take out this part, which I can?t see does anything at all in > the > code, it no longer works: I don't think "it no longer works" because you removed anything, but because this script can only be run at most once. Probably you're getting an error in the CREATE TABLE statement. You have to look at the server error logs, else you're blind fighting. See other suggestions in my previous post. Specially, try to make things work *locally*, and only when it's working fine, move on to the web part. -- Gabriel Genellina From paul.anton.letnes at gmail.com Tue Apr 15 04:07:15 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Tue, 15 Apr 2008 10:07:15 +0200 Subject: Java or C++? In-Reply-To: <480424FC.5040802@aim.com> References: <480424FC.5040802@aim.com> Message-ID: <6DDC1DFC-74EA-4788-96B3-23ECEAB8EA11@gmail.com> Brian: Impressive! This is the most balanced, well-informed and interesting reply to this debate. I would like to make some comments even so. I have tried all languages, and consider myself agnostic. However, I would like to roughly repeat what James Gosling (Java inventor) said at a lecture I attended: Java is nice because you can work in Java everywhere now - from embedded to desktops to supercomputers and servers. And, I would like to make my own comment: Java is the language I have tried which gives you the most help as a developer. For every crash, there is a complete and useful stack trace. Using Eclipse, you can auto-generate much of the 'boilerplate' code which is claimed to make Java boring to write (get, set, constructors...). It also more or less tells you how to fix small bugs - ';' and } missing for example. Even python is less helpful; concider "Unexpected indent" or the very informative "incorrect syntax" when you forget a ) or a : . C (or C++) for learning to talk to the metal, Java or Python for object orientation, Java will give you the most help, Python gets you started quickly, C++ is the hardest to understand in every detail, but C bogs you down with administrative stuff (try converting an int to a string; I found myself googling for an hour!). I tried this infamous "extending in C" and I would forget that until you know both C and python a bit more... Also, extending python in C++ or Java is possible - I didn't manage C++ yet, and Java I didn't try. Cheers! Paul. Den 15. april. 2008 kl. 05.46 skrev Brian Vanderburg II: >> My idea, if you really love Python and never think about erasing it >> from your mind, go for C (not C++). A script language plus C can >> solve >> every problem you need to solve. Also Python works pretty fine with >> C. > I agree mostly with this one. Scripting is very nice when writing an > application especially one that needs to change very often. Plus > there > are several toolkits and existing libraries available for Python. > I've > used wxPython some with it, and it came in handy for a few > applications > that I would have normally written in C++/wxWidgets and have to > recompile every few weeks to suit my needs (data extraction tools/etc) > > However there are cases when a compiled language is better, especially > anything that needs to be 'fast' and have a lower overhead. I > wouldn't > use Python to create a very graphics intensive game or anything, > though > it can be used with pygame/PyOpenGL for some nice simple stuff. Also > everything in Python is an object so it can start to consume memory > when > handling very large data sets. And since there is no guarantee of > when > garbage collection occurs, simply 'deleting' an item does not ensure > it > is completely gone, especially if there are cyclic references, though > that can be handled by using 'gc.collect()'. > > > > I consider C++ just a simplification of C, in the sense that it > makes it > easier to do things that would take more work to be done in C. One > can > still use C++ without all of the more complicated aspects but still > take > advantages of other aspects. > > C has the advantage that it does not to anything behind your back. > This > is very useful especially for any form of system development or where > you must know exactly what is going on. It is still possible to do > 'object oriented' development in C, it just requires some more > typing to > set up whatever is needed. Even things like COM for windows can be > done > in C, it just requires manually building the 'vtable' so to speak. > Also, C seems to avoid the use of temporaries where as C++ can use > them > in conversions and assignments automatically if needed. > > C++ makes some of it easier by doing certain things for you. Take a > string object for example. In C, assignment would only do a memory > copy > operation: > > String a, b; > b = a; > > The statement 'b = a' would only copy the memory and pointers from 'b' > to 'a' which means they would both point to the same buffer. To avoid > this, a copy constructor or assignment operator can be implemented > when > using C++. The same in C would be something like: > > String_Assign(&b, &a); /* instead of b = a */ > > Then if a structure contains objects, more work is needed. For > example, > in C: > > typedef struct Name > { > String honorary; > String first; > String middle; > String last; > String lineage; > } Name; > > void Name_Create(Name* name) > { > String_Create(&name->honorary); > String_Create(&name->first); > String_Create(&name->middle); > String_Create(&name->last); > String_Create(&name->lineage); > } > > void Name_Assign(Name* self, Name* other) > { > String_Assign(&self->honorary, &other->honorary); > String_Assign(&self->first, &other->first); > String_Assign(&self->middle, &other->middle); > String_Assign(&self->last, &other->last); > String_Assign(&self->lineage, &other->lineage); > } > > Name p1, p2; > Name_Create(&p1); > Name_Create(&p2); > Name_Assign(&p2, &p1); > > But in C++, this is no problem: > > Name p1, p2; > p2 = p1; > > This will automatically call the constructors of any contained objects > to initialize the string. The implicit assignment operator > automatically performs the assignment of any contained objects. > Destruction is also automatic. When 'p1' goes out of scope, during > the > destructor the destructor for all contained objects is called. > > And if you want more control you can implement the default and copy > constructors, destructor, and assignment operator, and tell them to do > what you want. Just beware because the explicit constructors only > calls > default constructors of any parent classes (even the copy constructor) > unless an initializer list is used, and an explicit assignment will > not > automatically do assignment of parent classes. > > Neither C nor C++ is really better, it depends on the what needs to be > done. C does only what it is told, and also has easier external > linkage > since there is no name mangling. C++ does a lot of the needed stuff > automatically, but explicit constructors and assignment operators can > still be declared to control them, and frequently doing the same thing > in C++ takes fewer lines of code than in C. > > As for Java, I think it is 'overly-used' in some areas, especially in > embedded development. I attended NC State and during orientation this > representative was talking about a small little robotic device and how > it had a full Java VM inside it and it only took '6 minutes to boot'. > Some claim it is for portability that Java is so good in embedded > devices. But still, if the program is moved to another device, it may > still need to be changed and recompiled if the new devices has > different > IO pins, timers, interrupts, etc. Most chips have a C > compiler/translator available, and the same program could have been > written in C, compiled directly to the machine code needed for the > device, 'booted' immediately, and not needed a Java VM as well. If > portability to other devices is desired then an abstract layer could > be > created in the program and the device/hardware specific code could be > seperated to that layer seperatly from the rest of the program. > > Well, all of that is just my opinion though, not meant to offend > anyone. > > > > > -- > http://mail.python.org/mailman/listinfo/python-list From ang.usenet at gmail.com Tue Apr 8 16:29:13 2008 From: ang.usenet at gmail.com (Aaron Gray) Date: Tue, 8 Apr 2008 21:29:13 +0100 Subject: CPython VM & byte code resources wanted Message-ID: <6622srF2e32hbU1@mid.individual.net> Hi, I am looking to study the CPython source code, but I cannot seem to find the VM code. Also is there any where a detailed list of the opcodes ? Many thanks in advance, Aaron From aahz at pythoncraft.com Fri Apr 4 16:41:47 2008 From: aahz at pythoncraft.com (Aahz) Date: 4 Apr 2008 13:41:47 -0700 Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: In article , Jan Claeys wrote: > >There are at least 3 books about game programming in python: > STAY AWAY Speaking as half of the tech-editing team for this book (the formal title is _Game Programming: The L Line, The Express Line to Learning_), I recommend staying as far as possible from this book. It does an okay job of teaching pygame, but it does a poor job of teaching Python (for example, it does not mention dicts) and therefore has a number of flaws from a pedagogical perspective, *plus* there are some bugs in the code. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "It is easier to optimize correct code than to correct optimized code." --Bill Harlan From ockman at gmail.com Thu Apr 3 19:34:26 2008 From: ockman at gmail.com (ockman at gmail.com) Date: Thu, 3 Apr 2008 16:34:26 -0700 (PDT) Subject: Bug in shlex?? References: Message-ID: <2dfd3aa7-7380-4825-b54b-88b49051ded0@b1g2000hsg.googlegroups.com> Gabriel... I feel foolish...(and wish I had the two hours back I spent on this). :) Thank you so much! > The result is a list containing a single string. The string contains 5 > characters: a single backslash, a question mark, three letters. The > backslash is the escape character, as in '\n' (a single character, > newline). A backslash by itself is represented (both by repr() and in > string literals) by doubling it. > > If you print the value, you'll see a single \: > > print shlex.split("'\?foo'")[0] > > -- > Gabriel Genellina From kyosohma at gmail.com Mon Apr 14 10:01:04 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Mon, 14 Apr 2008 07:01:04 -0700 (PDT) Subject: Python GUI programming and boa or better ? References: Message-ID: <5797f944-2540-4899-9de8-b123f2f90818@a22g2000hsc.googlegroups.com> On Apr 14, 8:20 am, bvidinli wrote: > I program in python for about 2-3 monthos. > I just started/tested gui programming with many tools. > i tested boa last, it is the closest tool to delphi in tui tools that i used. > > I managed to play with it a bit. > > If you have any other tool which you know better than Boa Constructor, > please write in here. > > Any other suggestion about python GUI programming is welcome. > thanks. > > -- > ?.Bahattin Vidinli > Elk-Elektronik M?h. > ------------------- > iletisim bilgileri (Tercih sirasina gore): > skype: bvidinli (sesli gorusme icin,www.skype.com) > msn: bvidi... at iyibirisi.com > yahoo: bvidinli > > +90.532.7990607 > +90.505.5667711 You'll probably want to take a look at the Python GUI FAQ for Python: http://www.python.org/doc/faq/gui/ And the Python Wiki has information on the many editors out there, including some GUI ones: http://wiki.python.org/moin/PythonEditors I hand-code all of my mine, although occasionally I'll use Visual Studio to create the look and then code wxPython to match. Mike From ronnbus at gmail.com Mon Apr 7 18:29:28 2008 From: ronnbus at gmail.com (Ronn Ross) Date: Mon, 7 Apr 2008 18:29:28 -0400 Subject: playing around with python Message-ID: Hello, I download the source for -------------- next part -------------- An HTML attachment was scrubbed... URL: From hall.jeff at gmail.com Tue Apr 15 13:23:02 2008 From: hall.jeff at gmail.com (hall.jeff at gmail.com) Date: Tue, 15 Apr 2008 10:23:02 -0700 (PDT) Subject: Preferred method for "Assignment by value" Message-ID: As a relative new comer to Python, I haven't done a heck of a lot of hacking around with it. I had my first run in with Python's quirky (to me at least) tendency to assign by reference rather than by value (I'm coming from a VBA world so that's the terminology I'm using). I was surprised that these two cases behave so differently test = [[1],[2]] x = test[0] x[0] = 5 test >>> [[5],[2]] x = 1 test >>>[[5],[2]] x >>> 1 Now I've done a little reading and I think I understand the problem... My issue is, "What's the 'best practise' way of assigning just the value of something to a new name?" i.e. test = [[1,2],[3,4]] I need to do some data manipulation with the first list in the above list without changing obviously x = test[0] will not work as any changes i make will alter the original... I found that I could do this: x = [] + test[0] that gets me a "pure" (i.e. unconnected to test[0] ) list but that concerned me as a bit kludgy Thanks for you time and help. From jkugler at bigfoot.com Tue Apr 29 15:20:53 2008 From: jkugler at bigfoot.com (Joshua Kugler) Date: Tue, 29 Apr 2008 11:20:53 -0800 Subject: Setting an attribute without calling __setattr__() References: Message-ID: animalMutha wrote: >> Consider reading the *second* paragraph about __setattr__ in section >> 3.4.2 of the Python Reference Manual. > > if you are simply going to answer rtfm - might as well kept it to > yourself. For what it's worth, I (the original poster) am glad he answered that way. It showed me the section and paragraph I had overlooked when reading through the docs the first time. j From Scott.Daniels at Acm.Org Wed Apr 2 23:25:17 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Wed, 02 Apr 2008 20:25:17 -0700 Subject: Python in High School In-Reply-To: <47f295c8$0$868$ba4acef3@news.orange.fr> References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <47f295c8$0$868$ba4acef3@news.orange.fr> Message-ID: Laurent Pointal wrote: > Le Tue, 01 Apr 2008 12:35:46 -0700, Paddy a ?crit : > And if you want to do easy and simple 3D graphics programming, look at > VPython > > http://www.vpython.org/ I offer a _strong_ second -- Nowhere in computing have I seen it easier to create stereoscopic views of 3-D things with a tiny amount of code without facing a wall when you exceed their example space. You owe it to yourself to spend a long weekend working through VPython; you will be _shocked_ at what you can do after three full days of hard work. Imagine: Ruth Chabay and Bruce Sherwood built this code in order to teach intro physics: they thought that (and continue to teach classes as if) it was _easier_ to teach Python and the physics than to teach physics alone! -Scott David Daniels Scott.Daniels at Acm.Org From sjmachin at lexicon.net Thu Apr 17 18:00:21 2008 From: sjmachin at lexicon.net (John Machin) Date: Thu, 17 Apr 2008 22:00:21 GMT Subject: MySQL hardcoding? In-Reply-To: References: Message-ID: <4807c872$1@news.mel.dft.com.au> marexposed at googlemail.com wrote: > I've got this error (see the path in last line) > > db=MySQLdb.connect(host='localhost',use_unicode = True, charset = "Windows-1251",user='root',passwd='12',db='articulos') Can't help with the answer to your question, but this may stave off yet another question: The empirical evidence from other recent postings is that you are mucking about with Spanish-language newspaper "articulos" on the web ... so why charset = "Windows-1251", which is Cyrillic (i.e. Russian etc)?? Perhaps you mean 1252 which is Microsoft's latin1 with extras. HTH, John From carbanancizpo at gmail.com Fri Apr 18 16:53:47 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:53:47 -0700 (PDT) Subject: microsoft office 2003 product key crack Message-ID: microsoft office 2003 product key crack http://cracks.12w.net F R E E C R A C K S From marco at sferacarta.com Tue Apr 29 08:45:30 2008 From: marco at sferacarta.com (Marco Mariani) Date: Tue, 29 Apr 2008 14:45:30 +0200 Subject: Zope/DTML Infuriating... In-Reply-To: <3a955f90-ed80-46be-a238-1462e4fb2d0c@m3g2000hsc.googlegroups.com> References: <3a955f90-ed80-46be-a238-1462e4fb2d0c@m3g2000hsc.googlegroups.com> Message-ID: Jens wrote: >> You might have wrong assumptions from previous PHP experiences. >> >> >>> 'x'+4 >> Traceback (most recent call last): >> File "", line 1, in >> TypeError: cannot concatenate 'str' and 'int' objects >> > > ... and the non snobby answer would have been: > > ... Sorry. Not trying to be snobbish, only in a hurry. That answer would have been less useful, because there are TONS of details in the python tutorial, that set the language apart from its "scripting cousins". Reading the syntax and thinking "yeah, got it, boring, next chapter" is a common mistake I've also made sometime, especially with python when I've been deceived by its apparent simplicity. Then, later, the same happened with Javascript, of course. And it's bound to happen again, as much as I'll try to be careful :-( From lutz.georg.horn at googlemail.com Wed Apr 30 02:37:18 2008 From: lutz.georg.horn at googlemail.com (Lutz Horn) Date: Wed, 30 Apr 2008 08:37:18 +0200 Subject: sed to python: replace Q In-Reply-To: <48180348$0$34534$742ec2ed@news.sonic.net> References: <48180348$0$34534$742ec2ed@news.sonic.net> Message-ID: <7c85a2590804292337n68ff0289rcc29deb4678b6012@mail.gmail.com> Hi, 2008/4/30 Raymond : > For some reason I'm unable to grok Python's string.replace() function. replace() does not work with regular expressions. > Is there a decent description of string.replace() somewhere? Use re.sub(). >>> import re >>> line = "date process text [ip] more text" >>> re.sub('].*$', '', re.sub('^.*\[', '', line, 1)) 'ip' Lutz From namesagame-usenet at yahoo.com Sat Apr 5 14:03:56 2008 From: namesagame-usenet at yahoo.com (gamename) Date: Sat, 5 Apr 2008 11:03:56 -0700 (PDT) Subject: Not Sure This Can Be Done... References: <46aeae28-4470-4136-a5f6-040f6468eb32@b5g2000pri.googlegroups.com> <170a668f-4a65-471f-ad03-03231235b314@e6g2000prf.googlegroups.com> Message-ID: Thanks! Good suggestion(s) all. Maybe I can get this done. :) -T On Apr 1, 4:49 pm, MrJean1 wrote: > In any script upon startup, sys.path[0] contains the full path of the > directory where the script is located. See lib/module-sys.html> under 'path'. > > it should be straightforward from here (untested though). In each > script, get the sys.path[0] string, split it using os.path, replace > the last item with 'tools' and join again with os.path. If the > resulting string is not in sys.path, insert it after sys.path[0]. > > /Jean Brouwers > > On Apr 1, 1:57 pm, gamename wrote: > > > Hi, > > > I generally have several copies of the same development environment > > checked out from cvs at any one time. Each development tree has a > > 'tools' dir containing python modules. Scattered in different places > > in the tree are various python scripts. > > > What I want to do is force my scripts to always look in the closest > > 'tools' dir for any custom modules to import. For example: > > > tree1/tools > > tree1/my_scripts/foo.py > > > tree2/tools > > tree2/my_scripts/foo.py > > > How can I make 'foo.py' always look in '../../tools' for custom > > modules? My preference would be to avoid changing the 'foo.py' script > > and have some way to resolve it via the environment (like PYTHONPATH, > > or .pth files, etc.). > > > Anyone have any ideas? > > TIA, > > -T From sturlamolden at yahoo.no Sun Apr 20 17:55:19 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sun, 20 Apr 2008 14:55:19 -0700 (PDT) Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> <480b6133$0$34498$742ec2ed@news.sonic.net> <3eac67b4-da0a-4926-9ca4-942271513ad2@26g2000hsk.googlegroups.com> Message-ID: <8d09a9d0-12ae-4edc-a80a-ef96058a025a@m73g2000hsh.googlegroups.com> On Apr 20, 8:49 pm, Roy Smith wrote: > Hiding your source code is not easy (perhaps impossible) in Python, for > reasons which have been covered at length on a regular basis in this forum. > If you only ship .pyc or .pyo files, there is still enough information > recoverable in the field that most businesses which want to keep their > source code hidden would feel excessively exposed. Every know and then, I see someone complaining you cannot sell programs written i Python or Java, because the bytecodes are so easily reverse engineered. The same guys usually have no problem with C#, because the executable are called 'something.exe'. The fact that a .NET executable also contain bytecodes, seems to be of little significance. It is very easy to obfuscate Python bytecodes beyond normal comprehension. All that is required is to put the .pyc files in a zipped folder and encrypt it. Then it's a matter of triviality to produce a C program that decrypts the zipped folder, embeds a Python interpreter, and runs the decrypted program. But even this scheme is not foolproof against an extremely skilled and determined adversary. Nothing really is. What measures to take depend on the threat. If the threat prevents distribution of code in any form, one can always provide critical parts as a web service and distribute nothing except XML. From davidreynon at gmail.com Wed Apr 23 10:02:46 2008 From: davidreynon at gmail.com (korean_dave) Date: Wed, 23 Apr 2008 07:02:46 -0700 (PDT) Subject: python-doc Message-ID: Hi all. I am using this to try to document my python-coded apps. http://effbot [DOT] org/zone/pythondoc [DOT] htm i am using windows XP professional. I have put the install directory of pythondoc.py in my path file. So i "cd" to the directory containing the python scripts I wish to python-doc, typing in "python-doc.py scriptname.py" and after about 1 second, i get nothing. No error, but again, no indication that this process has been completed. I have no idea where to look for html files. I checked all relevant directories that might have it (the directory containing the pythondoc.py script, etc.). Please help... Maybe my syntax is incorrect? Thanks, -Dave From software at ginstrom.com Wed Apr 16 23:01:11 2008 From: software at ginstrom.com (Ryan Ginstrom) Date: Thu, 17 Apr 2008 12:01:11 +0900 Subject: Splitting MainWindow Class over several modules. In-Reply-To: <0e6b1338-8355-4fba-9db2-0cc09fc05e1e@m44g2000hsc.googlegroups.com> References: <0e6b1338-8355-4fba-9db2-0cc09fc05e1e@m44g2000hsc.googlegroups.com> Message-ID: <191901c8a037$4b08ea20$0203a8c0@MOUSE> > On Behalf Of Mike Driscoll > I don't think there's anything wrong with it. The main thing > to remember is to try to keep the interface and the logic > separate. I have a fairly complex program with lots of tabs > and sub tabs. So I stuck each of the tab's display code in a > separate file and imported them into my main program. There are also several signaling techniques that make it easy to separate the GUI logic from the message-processing logic. Or you could simply have a controller class that instantiates the GUI class and registers itself as the message listener. Regards, Ryan Ginstrom From n00m at narod.ru Sat Apr 26 22:02:03 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 19:02:03 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <54dc008c-a747-4507-a2d5-9b4ddccbd5b9@e53g2000hsa.googlegroups.com> <3a7541ae-8aa2-46d5-93a3-115f9e2a3c38@l42g2000hsc.googlegroups.com> Message-ID: Btw seems all accepted pyth solutions (for this prob) used Psyco. From duncan.booth at invalid.invalid Wed Apr 9 04:51:58 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 9 Apr 2008 08:51:58 GMT Subject: Google App Engine References: <47fc2c7c$0$36365$742ec2ed@news.sonic.net> <7e43fcd9-6207-4af2-8256-c0099a8ce0bb@1g2000prf.googlegroups.com> Message-ID: Jason Scheirer wrote: > On Apr 8, 7:50 pm, John Nagle wrote: >> Duncan Booth wrote: >> > Google have announced a new service called 'Google App Engine' >> > which may be of interest to some of the people here >> >> OK, now we need a compatibility layer so you can move apps from >> Google App Engine to your own servers. You don't want to be locked >> into a single vendor solution, especially when they reserve the right >> to start charging. >> >> Their data store uses a subset of SQL, so it's probably possible >> to write a conversion layer allowing use of MySQL. >> >> John Nagle > > It supports Django, and more importantly, WSGI, so any 'framework' you > build on top of it should transfer out. Heck, you have a stand-alone > python script that comes with the developer kit for hosting your apps > on YOUR computer that you could port to use YOUR database and be done > with it. Write your own ORM or just some decent OO code for handling > data access so the database access layer can be swapped out and you > are golden. I really doubt getting away from the Googe App Engine is > going to be too terribly difficult for any intermediate Python > programmer, assuming good up-front application design. There are several things which would make moving away from Google tricky: The backend data store, while it has a vaguely SQLish query language is an object database not a relational database, i.e. more like ZODB than MySQL. It uses similar concepts to django's data api but isn't the same. It should be possible to write something simple to replace it, but given that you only need to migrate away from Google when your data or page hits get large, you need to replace it with something scalable. The data store is the *only* writeable storage your application can access, so there isn't much scope to write applications without using it. If you use authentication then again you are tied to Google accounts (or Google Apps accounts). For a public application that would also block attempts to move to another platform. The standalone script for testing is just for testing: it dummies out user authentication (login accepts anything), and it only accepts a single request at a time. From acp.dev at gmail.com Thu Apr 24 11:33:49 2008 From: acp.dev at gmail.com (AC Perdon) Date: Thu, 24 Apr 2008 23:33:49 +0800 Subject: Billing system written in python Message-ID: <40847e660804240833q4e4210dyb8a561899635fb77@mail.gmail.com> Hi, I would like to develop a billing system for a cable tv system, basically what it does is have subscribers in db, compute billing statement, print for statement for distribution something like that. I was evaluating jbilling its a java base billing system that uses tomcat,mysql or postgress DB and java. Im looking similar to this but its written in python so that I wont start from scratch. Why not use jbilling instead if it solve you problem? Will the reason Im looking for a python solution is I want to learn python and java is bit complicated for me at this time since Im just a newbie in programing. Any suggestion? I was thinking of using django but Im more looking in to a ready made billing system that I will just do some tweaking and fine tunning to meet our need. like jbilling. Thanks, AC -- -- AC Perdon Registered Linux User #340122 -------------- next part -------------- An HTML attachment was scrubbed... URL: From markfernandes02 at googlemail.com Sat Apr 5 05:56:15 2008 From: markfernandes02 at googlemail.com (markfernandes02 at googlemail.com) Date: Sat, 5 Apr 2008 02:56:15 -0700 (PDT) Subject: In Tkinter - having an input and an entry Message-ID: I need some advice, I am creating a python program to communicate with an MS Access db in python 2.4. I can fetch records but cannot insert records. def Insert(self, *row): global cursor, title, author, pubdate sqlInsert = "INSERT INTO Book_table" sqlInsert = sqlInsert + "(Bookname, BookAutor, " sqlInsert = sqlInsert + "Publicationdate) VALUES ('" sqlInsert = sqlInsert + title + "', '" sqlInsert = sqlInsert + author + "', " sqlInsert = sqlInsert + pubdate + ") " myconn = odbc.odbc('accessDatabase') cursor = myconn.cursor() cursor.execute(sqlInsert) myconn.commit() cursor.close() myconn.close() The above code does not work. Also with Tkinter, i want to have user input records into the db, i cannot get what the user inputs into the entry to become a string variable. If you can help it would be most appreciated. Thanks in advanced Mark From darcy at druid.net Wed Apr 16 14:03:51 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Wed, 16 Apr 2008 14:03:51 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: <48062BB4.8000201@gmail.com> References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> <87prspydex.fsf@physik.rwth-aachen.de> <48062BB4.8000201@gmail.com> Message-ID: <20080416140351.5ba60204.darcy@druid.net> On Wed, 16 Apr 2008 10:39:16 -0600 Michael Torrie wrote: > Running a few lists myself, I don't see this. How is administrative > overhead tedious? Most open source projects do it, so I wonder just how > tedious it is. Of all the projects I'm associated with in lists, Python > is the only one still clinging to NNTP when it appears a normal mail > list is just as good. Especially given that Mailman, a Python program, can handle all the heavy lifting anyway. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From __peter__ at web.de Wed Apr 30 12:18:03 2008 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Apr 2008 18:18:03 +0200 Subject: printing inside and outside of main() module References: <9bd5c596-da19-4615-a4d8-e47b20cfb362@m73g2000hsh.googlegroups.com> <48189ac0$0$9742$426a74cc@news.free.fr> Message-ID: Bruno Desthuilliers wrote: > Peter Otten a ?crit : >> korean_dave wrote: >> >>> This allows me to see output: >>> >>> ---begin of try.py >>> print "Hello World" >>> --end of try.py >>> >>> This DOESN'T though... >>> >>> --begin of try2.py >>> def main(): >>> return "Hello" >> main() # add this >>> --end of try2.py >>> >>> Can someone explain why??? >> >> Python doesn't call the main() function; you have to invoke it >> explicitly. > > > And while we're at it, your main function *returns* a value, but doesn't > *print* anything. > Ouch! From maehhheeyy at gmail.com Tue Apr 29 17:47:40 2008 From: maehhheeyy at gmail.com (maehhheeyy) Date: Tue, 29 Apr 2008 14:47:40 -0700 (PDT) Subject: i want to add a timeout to my code References: <53ffe104-be3b-43e2-b5c8-4ce5886ac60d@b1g2000hsg.googlegroups.com> <1f70ea43-7909-4bd8-b63d-2467e8a0542f@c65g2000hsa.googlegroups.com> Message-ID: On Apr 17, 4:24?pm, Miki wrote: > On Apr 17, 1:10?pm,maehhheeyy wrote: > > > I want to add a timeout so that when I pull out my gps from my serial > > port, it would wait for a bit then loop and then see if it's there. I > > also want to add a print statement saying that there is no GPS device > > found. However when I run my code and unplug my serial port, my code > > will just hang until I plug it back in. > > This is my code right now: > > > def GetGPS(): > > ? ? ? data = [] > > ? ? ? #Open com1: 9600,8,N,1 > > ? ? ? fi = serial.Serial(0, timeout = 1) > > ? ? ? print '[gps module] SERIAL PORT OPEN ON COM1:' > > > can anyone help me please? Thanks. > > http://docs.python.org/lib/node545.html > > HTH, > -- > Miki http://pythonwise.blogspot.com I tried the code onto my codes but what came out was that in the line signal.signal(signal.SIGSLRM, handler), an attributeError appeared reading that 'module' object has no attribute 'SIGALRM' From http Mon Apr 14 20:41:12 2008 From: http (Paul Rubin) Date: 14 Apr 2008 17:41:12 -0700 Subject: pgdb: Debugging Python extensions made easier References: Message-ID: <7xzlrw7xw7.fsf@ruckus.brouhaha.com> SteveD writes: > pgdb.zip is an addition to scite-debug, which adds source debugging to > the popular SciTE programmer's editor. ... > I know the FAQ says that this is not possible, but the FAQ is somewhat > outdated. GDB is quite happy with pending breakpoints to unresolved > libraries, but you have to reassure it. I'm not sure what FAQ or what is supposed to be impossible but I've used gdb in the past to debug python extensions without running into insurmountable problems that I remember. From carlwuhwdmckay at gmail.com Mon Apr 21 02:10:37 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:10:37 -0700 (PDT) Subject: transmac crack Message-ID: transmac crack http://cracks.00bp.com F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Thu Apr 10 06:14:46 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 07:14:46 -0300 Subject: Sorting Directories from files in a os.listdir?? References: <9354f263-b833-4845-a226-1ad3a47b1e6a@p25g2000pri.googlegroups.com> Message-ID: En Thu, 10 Apr 2008 06:55:13 -0300, Soren escribi?: > I'd like to read the filenames in a directory, but not the > subdirectories, os.listdir() gives me everything... how do I separate > the directory names from the filenames? Is there another way of doing > this? Check each returned name using os.path.isfile (untested): def files_only(path): return [filename for filename in os.listdir(path) if os.path.isfile(os.path.join(path, filename))] -- Gabriel Genellina From victorsubervi at gmail.com Wed Apr 16 09:16:45 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 16 Apr 2008 08:16:45 -0500 Subject: String Literal to Blob In-Reply-To: <1208274907.4718.2.camel@aalcdl07.lib.unc.edu> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> <4dc0cfea0804140629rf1ac100m27ad9d0456cbbe2d@mail.gmail.com> <4803644A.8010204@holdenweb.com> <4dc0cfea0804150804l2d3832f0sd8f1d9405934063@mail.gmail.com> <1208274907.4718.2.camel@aalcdl07.lib.unc.edu> Message-ID: <4dc0cfea0804160616u19c3cda8wb0936abd7fc7e201@mail.gmail.com> The _keywords_ are _essential_. It is currently published at the end of a long and exhaustive thread. This is not good. It should be republished correctly, and with the kw people will use to search. For example, I would never have thought to search for a photo album. Victor On Tue, Apr 15, 2008 at 10:55 AM, J. Cliff Dyer wrote: > It is published. On comp.lang.python. Google groups has it, so google > (search) will find it. > > Cheers, > Cliff > > > On Tue, 2008-04-15 at 17:04 +0200, Victor Subervi wrote: > > Gabriel; > > > > That's really nice code you wrote. I will rewrite my app accordingly, > > after I catch a breather! Say, would you please publish this > > somewhere? Why should I write a howto on this and credit you when all > > I would be doing is republishing (plagerizing) what you published? > > Please insert these keywords: mysql, image, python, mysqldb and maybe > > picture and photo (you already have photo). Call it something like > > "MySQL/Python Tutorial for Posting and Retrieving Images / Photo > > Album". I ask you to do this because I scoured google looking for just > > what you've provided and it simply isn't out there. At all. There are > > nice howto's in php. Please post this for those interested in python, > > somewhere like the cookbook. > > > > Thanks, > > > > Victor > > > > > > > > On Tue, Apr 15, 2008 at 3:23 AM, Gabriel Genellina > > wrote: > > En Mon, 14 Apr 2008 11:03:54 -0300, Steve Holden > > > > escribi?: > > > Victor Subervi wrote: > > >> Thanks to all, especially Gabriel. [...] > > >> Steve, thank you for all your help, but do overcome your > > temper :)) > > > > > > > > I'm glad the penny finally dropped. You may have been > > treated to a > > > modest display of exasperation, but please be assured you > > have not yet > > > seen anything remotely like temper from me :-) > > > > > > And I'm glad to see that you finally "got it", too! > > > > -- > > Gabriel Genellina > > > > -- > > > > http://mail.python.org/mailman/listinfo/python-list > > > > > -- > Oook, > J. Cliff Dyer > Carolina Digital Library and Archives > UNC Chapel Hill > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From arnodel at googlemail.com Tue Apr 15 13:48:52 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Tue, 15 Apr 2008 10:48:52 -0700 (PDT) Subject: Preferred method for "Assignment by value" References: Message-ID: <8562becb-9fef-415d-9640-05ef80123596@a5g2000prg.googlegroups.com> On Apr 15, 6:23?pm, hall.j... at gmail.com wrote: > As a relative new comer to Python, I haven't done a heck of a lot of > hacking around with it. I had my first run in with Python's quirky (to > me at least) tendency to assign by reference rather than by value (I'm > coming from a VBA world so that's the terminology I'm using). I was > surprised that these two cases behave so differently Perhaps it is better to think that you bind the name 'x' to the object '42' when you write 'x=42'. > test = [[1],[2]] > x = test[0] > x[0] = 5 > test>>> [[5],[2]] > > x = 1 > test > > >>>[[5],[2]] > x > >>> 1 > > Now I've done a little reading and I think I understand the problem... > My issue is, "What's the 'best practise' way of assigning just the > value of something to a new name?" > > i.e. > test = [[1,2],[3,4]] > I need to do some data manipulation with the first list in the above > list without changing > obviously x = test[0] will not work as any changes i make will alter > the original... > I found that I could do this: > x = [] + test[0] > > that gets me a "pure" (i.e. unconnected to test[0] ) list but that > concerned me as a bit kludgy > > Thanks for you time and help. To create a new list with the same elements as a sequence seq, you can use list(seq). 'list' is the type of lists, it is also a 'constructor' for list objects (the same goes for other common buit-in types, such as 'int', 'float', 'str', 'tuple', 'dict'). E.g. >>> foo = [1, 2, 3] >>> bar = list(foo) >>> foo[0] = 4 >>> foo [4, 2, 3] >>> foo = [1, 2, 3] >>> bar = list(foo) >>> bar[0] = 4 >>> bar [4, 2, 3] >>> foo [1, 2, 3] >>> HTH -- Arnaud From antroy at gmail.com Thu Apr 3 08:44:23 2008 From: antroy at gmail.com (Ant) Date: Thu, 3 Apr 2008 05:44:23 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> Message-ID: <88b07549-9751-489b-968f-c3d2db0aba79@s13g2000prd.googlegroups.com> On Apr 3, 12:37 pm, tinn... at isbd.co.uk wrote: > What's the neatest and/or most efficient way of testing if one of a A different approach: >>> words = ["he", "sh", "bla"] >>> name = "blah" >>> True in (word in name for word in words) True >>> name = "bling" >>> True in (word in name for word in words) False Perhaps not as obvious or readable as Jeff's example, but is essentially doing the same thing using generator syntax. From kyosohma at gmail.com Tue Apr 8 16:41:35 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 8 Apr 2008 13:41:35 -0700 (PDT) Subject: new user needs help! References: Message-ID: <8ffe37a3-2d74-4d14-b8ae-94f8984061b3@b64g2000hsa.googlegroups.com> On Apr 8, 2:55 pm, drjekil wrote: > I am totally new in biopython and its my first program.so may be i am asking > stupid question. > I am working with a text filelooks like this: > #NAME AA TOPO ACCESS DSSP STRIDE Z-COORD > 1lghB A i 79.8 H H -24.58 > 1lghB V i 79.6 H H -22.06 > 1lghB H i 71.9 H H -19.94 > i need to compare those lines which has a Z-COORED value between 10 to 22 > and presents in the following way > True/false A C D E F G H I K L M N P Q R S T V X Y W(here alfabets > represents amino acids) > 1 1:1 2:0 3:0 and so on for rest of the amino acids. > IF PRESENT IN THAT RANGE > IF not PRESENT IN THAT RANGE then > -1 1:0 2:0 so on,it should be 1 instead of 0 when it will find corresponding > amino acid for that line.say here,for 2nd line it will be 16:1. > true will represent 1,false -1. > i have to cheek all the lins in the file and print it. > u have to tell simply otherwise i cant understand even,so stupid am i! > I will be really greatful!Thanks in advance > -- > View this message in context:http://www.nabble.com/new--user-needs-help%21-tp16571823p16571823.html > Sent from the Python - python-list mailing list archive at Nabble.com. To read the file, do something like this: f = open('path/to/filename') for line in f.readlines(): # do something print line See http://docs.python.org/lib/bltin-file-objects.html for more information. You'll want to look at using "if" statements to do the various conditions and you'll probably need to use string slicing/splitting to get the correct part of the line to do the comparison. So, something like f = open('path/to/filename') for line in f.readlines(): parts = line.split() zcoord = parts[-1] if zcoord > 10 and zcoord < 22: # do something pass print line Resources: http://docs.python.org/ref/if.html http://www.ibiblio.org/g2swap/byteofpython/read/if-statement.html http://docs.python.org/lib/string-methods.html http://www.diveintopython.org/native_data_types/joining_lists.html Mike From bronger at physik.rwth-aachen.de Sun Apr 20 14:02:37 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Sun, 20 Apr 2008 20:02:37 +0200 Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B80B5.1050500@cheimes.de> Message-ID: <87myno2yma.fsf@physik.rwth-aachen.de> Hall?chen! Gabriel Genellina writes: > En Sun, 20 Apr 2008 14:43:17 -0300, Christian Heimes > escribi?: > >> Gabriel Genellina schrieb: >> >>> Apart from what everyone has already said, consider that >>> FreqDist may import other modules, store global state, create >>> other objects... whatever. Pure python code should not have any >>> memory leaks (if there are, it's a bug in the Python >>> interpreter). Not-carefully-written C extensions may introduce >>> memory problems. >> >> Pure Python code can cause memory leaks. No, that's not a bug in >> the interpreter but the fault of the developer. For example code >> that messes around with stack frames and exception object can >> cause nasty reference leaks. > > Ouch! > May I assume that code that doesn't use stack frames nor stores > references to exception objects/tracebacks is safe? Circular referencing is no leaking on the C level but in a way it is memory leaking, too. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From george.sakkis at gmail.com Thu Apr 24 01:15:42 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 23 Apr 2008 22:15:42 -0700 (PDT) Subject: Parsing tuple from string? References: Message-ID: <48749047-d762-434d-b67f-125c2b25e612@26g2000hsk.googlegroups.com> On Apr 24, 12:21?am, Daniel wrote: > On Apr 23, 4:22 pm, George Sakkis wrote:> On Apr 23, 6:24 pm, Daniel wrote: > > > > I have a list of strings, which I need to convert into tuples. ?If the > > > string is not in python tuple format (i.e. "('one', 'two')", "("one", > > > 'two')", etc.), then I can just make it a 1-tuple (i.e. return > > > (string,) ). ?If it is in python tuple format, I need to parse it and > > > return the appropriate tuple (it's ok to keep all tuple elements as > > > strings). > > > > I think eval() will work for this, but I don't know what will be in > > > the string, so I don't feel comfortable using that. > > > Check out one of the safe restricted eval recipes, e.g.http://preview.tinyurl.com/6h7ous. > > Thank you very much! You're welcome. By the way, there's a caveat: simple_eval() doesn't require a comma between tuple/list elements or dict pairs: >>> simple_eval('(2 3)') (2, 3) >>> simple_eval('[1 2 ,3]') [1, 2, 3] >>> simple_eval('{ 1:"a" 2:"b"}') {1: 'a', 2: 'b'} Also parenthesized values are evaluated as 1-tuples >>> simple_eval('(2)') (2,) Since it doesn't evaluate general expressions anyway, that's not necessarily a problem. In any case, making it strict is left as an exercise to the reader :) George From umpsumps at gmail.com Sat Apr 26 18:23:11 2008 From: umpsumps at gmail.com (umpsumps at gmail.com) Date: Sat, 26 Apr 2008 15:23:11 -0700 (PDT) Subject: learning with python question (HtTLaPP) References: <98acecbd-9de2-4ebf-927b-ac6bc1fbc3fd@b5g2000pri.googlegroups.com> <53d6254f-895f-48fb-8ab9-3929c403f11b@v23g2000pro.googlegroups.com> Message-ID: <27197fb8-87af-4c86-971b-fb6d37511188@w4g2000prd.googlegroups.com> This is what I'm stuck on. I keep doing things like: for line in fin: for ch in letters: if ch not in line: I've tried for ch in letters: for line in fin: too.. Should I use a while statement? What's the best way to compare a group of letters to a line? > This would be a more difficult approach.. ? Where you are doing the > comparison step: > > if letters in line.strip(): > > It's trying to match the exact string "uzi", not any of the individual > letters. ?You would need to look for each letter independently and > then make sure they were in the right order to match the other words. From sjmachin at lexicon.net Fri Apr 25 18:17:54 2008 From: sjmachin at lexicon.net (John Machin) Date: Fri, 25 Apr 2008 15:17:54 -0700 (PDT) Subject: Subclassing datetime.date does not seem to work References: <4811FF57.5040200@comcast.net> Message-ID: On Apr 26, 7:43 am, Christian Heimes wrote: > Rick King schrieb: > > > > > I would like to subclass datetime.date so that I can write: > > > d = date2('12312008') > > > I tried: > > > from datetime import date > > class date2(date): > > def __init__( self, strng ): > > mm,dd,yy = int(strng[:2]), int(strng[2:4]), int(strng[4:]) > > date.__init__(self,yy,mm,dd) > > > But then this statement: > > d = date2('12312008') > > > Causes: > > TypeError: function takes exactly 3 arguments (1 given) > > > Is there something basically wrong with subclassing date? > > -Rick King > > datetime.date is a C extension class. Subclassing of extension classes > may not always work as you'd expect it. > ... and in this case it's a sledgehammer to crack a nut: >>> from datetime import date >>> def date_from_string(strng): ... mm, dd, yy = int(strng[:2]), int(strng[2:4]), int(strng[4:]) ... return date(yy, mm, dd) ... >>> date_from_string('12312008') datetime.date(2008, 12, 31) >>> Consider also: >>> import datetime >>> datetime.datetime.strptime('12312008', '%m%d%Y').date() datetime.date(2008, 12, 31) From robin at reportlab.com Fri Apr 18 07:54:44 2008 From: robin at reportlab.com (Robin Becker) Date: Fri, 18 Apr 2008 12:54:44 +0100 Subject: py3k s***s In-Reply-To: <66q33cF2krjf2U1@mid.uni-berlin.de> References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <66q33cF2krjf2U1@mid.uni-berlin.de> Message-ID: <48088C04.6090002@chamonix.reportlab.co.uk> Diez B. Roggisch wrote: . > You know what I was just wondering about? All these C-written > cross-platform libraries (which Python users benefit from, most probably > including evven you) that run on different unixes & windows, which are a > much greater diversity to handle than the not-even-yet-settled > differences between Py3K & 2.x. How the heck do they do that? . I'm in the process of attempting a straightforward port of a relatively simple package which does most of its work by writing out files with a more or less complicated set of possible encodings. So far I have used all the 2to3 tools and a lot of effort, but still don't have a working version. This must be the worst way to convert people to unicode. When tcl went through this they chose the eminently sensible route of not choosing a separate unicode type (they used utf8 byte strings instead). Not only has python chosen to burden itself with two string types, but with 3 they've swapped roles. This is certainly the first time I've had to decide on an encoding before writing simple text to a file. Of course we may end up with a better language, but it will be a worse(more complex) tool for many simple tasks. Using a complex writing with many glyphs costs effort no matter how you do it, but I just use ascii :( and it's still an effort. I find the differences in C/OS less hard to understand than why I need bytes(x,'encoding') everywhere I just used to use str(x). -old fart-ly yrs- Robin Becker From rhamph at gmail.com Sun Apr 13 12:09:58 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Sun, 13 Apr 2008 09:09:58 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> <32e2acc1-97cb-4911-bb0c-67965b5ff113@2g2000hsn.googlegroups.com> <7x8wzi7f9x.fsf@ruckus.brouhaha.com> Message-ID: <5e471fea-b70d-4e46-ae70-2a86d59a4190@v26g2000prm.googlegroups.com> On Apr 12, 6:58 pm, Steve Holden wrote: > Paul Rubin wrote: > > Steve Holden writes: > >> I believe you are making surmises outside your range of competence > >> there. While your faith in the developers is touching, the garbage > >> collection scheme is something that has received a lot of attention > >> with respect to performance under typical workloads over the years. > > > Really, Python's cyclic gc is quite crude and should be upgraded to > > something that doesn't fall into that quadratic behavior. There was > > some fairly detailed discussion of this in another thread last time > > the subject came up. > > I'll take your word for it. I discussed it not too long ago, but I can't seem to find the thread.. Basically, python's gen2 collections are to blame. You get a full (gen2) collection a linear number of times for a linear number of allocations, but the cost of each collection is also linear, giving you O(n**2) cost. I think it's fairly clear that it should not be that expensive. From a.ktechnology5 at yahoo.com Tue Apr 22 17:34:44 2008 From: a.ktechnology5 at yahoo.com (a.ktechnology5 at yahoo.com) Date: Tue, 22 Apr 2008 14:34:44 -0700 (PDT) Subject: New technology data storage. Get 2GB Free (Limited time offer) Message-ID: <1fca0ea5-abe3-4dda-aa2e-e4f9d59f28e5@59g2000hsb.googlegroups.com> Get free 2GB online web drive. Get a secure 2GB free online storage solution. Forget the hassles of CDs, floppies and tape drives for your data storage. Whether it is your tax return, music collection or irreplaceable digital photographs, you have the piece of mind that your data is stored in our high security data center. Save your files, documents, music collection online. You can share your stored documents with your friends and family. Store, share, stream, manage and access your files online easily. Protected against virus attacks or worms and other threats. Better, larger and cheaper than USB flash drive. Free offer is for limited time period. Hurry up! Visit now: http://www.aktechnology.net/data_storage.asp FARWARD THIS MESSAGE TO FRIENDS & FAMILY BECAUSE FREE ACCOUNTS ARE LIMITED. From kay.schluehr at gmx.net Sat Apr 5 09:01:28 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 5 Apr 2008 06:01:28 -0700 (PDT) Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> Message-ID: <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com> Aldo, when you confuse inheritance ( using an OO framework properly ) with monkey patching no one can draw much different conclusions than I did. I'm still very positive about the integration of code coverage tools with UT frameworks and of course I've nothing against adding a CLI. Actually *this* is a good reason to advance an existing framework and enable more components to be hooked in. But raving against unittest.py and anti-hyping it for mostly trivial reasons and with shallow reasoning has become a fashion. Now we see alternatives that do little more than what can be achieved by adding two abstract methods to the TestSuite base class and overwrite a few methods of the TestLoader base class ( maybe I'm wrong about it but I guess the discussion has become too heated to clarify this point using technical arguments ). I just felt it was a good opportunity to debunk this unittest.py anti- hype. I'm sorry it has gone too personal. Regards, Kay From darcy at druid.net Tue Apr 15 15:14:39 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Tue, 15 Apr 2008 15:14:39 -0400 Subject: How to have unittest tests to be executed in the order they appear? In-Reply-To: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> Message-ID: <20080415151439.7065a31a.darcy@druid.net> On Tue, 15 Apr 2008 12:02:48 -0700 (PDT) "Giampaolo Rodola'" wrote: > Hi there. > Is there a way to force unittest to run test methods in the order they > appear? Since they run in alphabetical order why not just rename them to the order you want them to run? Something like this: def test_010_z(self): def test_020_b(self): def test_030_d(self): Note the numbering scheme that allows tests to be added between the existing ones if necessary. However, do consider writing your tests so that order is irrelevant. If a test depends on a previous test running then it isn't a proprt self-contained test. For one thing, you can't run a single test that way if you wanted to. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From s0suk3 at gmail.com Thu Apr 17 12:19:32 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 09:19:32 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> Message-ID: On Apr 17, 10:54 am, colas.fran... at gmail.com wrote: > On 17 avr, 17:40, s0s... at gmail.com wrote: > > Out of sheer curiosity, why do you need thirty (hand-specified and > dutifully commented) names to the same constant object if you know > there will always be only one object? I'm building a web server. The many variables are names of header fields. One part of the code looks like this (or at least I'd like it to): class RequestHeadersManager: # General header fields Cache_Control = \ Connection = \ Date = \ Pragma = \ Trailer = \ Transfer_Encoding = \ Upgrade = \ Via = \ Warning = \ # Request header fields Accept = \ Accept_Charset = \ Accept_Encoding = \ Accept_Language = \ Authorization = \ ... Etc etc etc. At the end they'll all be assign to None. Then, when initialized, __init__() will the the string of headers, parse them, and use those variables shown above to assign to the header values. Of course a normal request won't include all of those headers, so the others will remain None. That's what I want. From dhong at gist.ac.kr Tue Apr 29 23:35:29 2008 From: dhong at gist.ac.kr (Dongpyo Hong) Date: Wed, 30 Apr 2008 15:35:29 +1200 Subject: swig -python can't find _xxx.dll for windows In-Reply-To: <61B007AA-8ED3-499F-B787-DB6F2511A124@gist.ac.kr> References: <61B007AA-8ED3-499F-B787-DB6F2511A124@gist.ac.kr> Message-ID: <4AEBEDF8-D283-45F0-BC93-110C9FF412C5@gist.ac.kr> Well, after several hours' googling I just found that Python for Windows only allow .pyd instead of .dll. When I just renamed .dll to .pyd, it just worked fine. But I don't still get the reason why. Anyone can explain this? --Dongpyo On Apr 30, 2008, at 12:00 PM, Dongpyo Hong wrote: > Dear all, > > I wrapped c++ code with swig, and made _xxx.dll file. > But, when I import xxx.py file from Python interpreter: import xxx > it keeps saying that "ImportError: No module named _xxx" > I checked sys.path and PATH environment. > > Why is that? Any explanation? > > --Dongpyo > ===== > Dongpyo Hong > Research Assistant > GIST U-VR Lab http://uvr.gist.ac.kr > http://uvr.gist.ac.kr/~dhong > Tel. +82-62-970-3157 (2279) > Fax. +82-62-970-2204 > Email. dhong at gist.ac.kr or dongpyo.hong at gmail.com > ===== > > > > > > ===== Dongpyo Hong Research Assistant GIST U-VR Lab http://uvr.gist.ac.kr http://uvr.gist.ac.kr/~dhong Tel. +82-62-970-3157 (2279) Fax. +82-62-970-2204 Email. dhong at gist.ac.kr or dongpyo.hong at gmail.com ===== -------------- next part -------------- An HTML attachment was scrubbed... URL: From exarkun at divmod.com Fri Apr 18 14:49:20 2008 From: exarkun at divmod.com (Jean-Paul Calderone) Date: Fri, 18 Apr 2008 14:49:20 -0400 Subject: py3k s***s In-Reply-To: <20080418183215.GC19281@deviL> Message-ID: <20080418184920.6859.2120221760.divmod.quotient.31835@ohm> On Fri, 18 Apr 2008 11:32:15 -0700, Nick Stinemates wrote: > [snip] > >Yo, no one here is a child Hi Nick, Actually, there are a number of young people on the list. So let's keep things civil and try to avoid using harsh language. Thanks! Jean-Paul From skanemupp at yahoo.se Sun Apr 20 16:27:26 2008 From: skanemupp at yahoo.se (globalrev) Date: Sun, 20 Apr 2008 13:27:26 -0700 (PDT) Subject: cherrypy-webapp-code? Message-ID: <31715060-fca3-4a03-b5c4-b6403315aa76@a23g2000hsc.googlegroups.com> anyone have a small cherrypy-webapp and are willing to post the code. could be a nonsense-app just wanna see some code. From bignose+hates-spam at benfinney.id.au Fri Apr 18 02:46:15 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Fri, 18 Apr 2008 16:46:15 +1000 Subject: How to have unittest tests to be executed in the order they appear? References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> <87zlru7le2.fsf@benfinney.id.au> <87fxtlwi03.fsf@benfinney.id.au> Message-ID: <87mynr4q4o.fsf@benfinney.id.au> Roy Smith writes: > Ben Finney wrote: > > > Surely, since "suddenly" implies you changed one small area of the > > code, that area of the code is the best place to look for what caused > > the failure. > > Sometimes it's the environment that's changed. Yes, I know, a good > unit test doesn't depend on the environment, but in real life, > that's sometimes difficult to achieve. Fair enough, I hadn't considered that case of "suddenly". In that case, I would recommend a change to the test *reporter*, so that the tests are still run in an arbitrary sequence, but the failures are reported in some desired sequence. -- \ ?Holy tintinnabulation, Batman!? ?Robin | `\ | _o__) | Ben Finney From steve at holdenweb.com Wed Apr 9 10:24:16 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 10:24:16 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> Message-ID: Victor Subervi wrote: > On Wed, Apr 9, 2008 at 1:14 AM, Gabriel Genellina > > wrote: > > > Thanks. I apparently am printing some holder for the image. I > stripped > > out > > most of it with this > > content[0][0] > > but then I am left with this: > > > > array('c', '\xff\xd8\xff\xe0\\0\x10JFI...) > > How do I extract an image from that? > > print content.tostring() > > > Now *that* gave me something that *looks* a lot more like an image from > a programmers perspective, but still no image... > ????JFIF... > Actually, it does not copy and paste well, but you can see it for the > moment here: > http://livestocksling.com/test/python/Shop/display_es2.py > So, how do I convert *that* to a real live image? > > > Or perhaps, replace that line with content.tofile(sys.stdout) > > > Printed nothing. > > > >> > print 'Content-Type: image/jpeg\r\n' > >> > print '\n' > >> > print content > >> > print '\n' > >> > cursor.close() > >> > > >> > test() > > >> > The commented out line gives me a leading less than sign...and > that?s > >> > it. What do? > > Try to understand now *why* you got a single character with your > previous > code. > > > No clue :/ > > BTW, for purposes of documentation, it appears that, when sending the > form with the image to the script that processes the form, the following > is inadvisable: > > form = cgi.FieldStorage() > pic1 = form.getfirst('pic1', '') > > This appears to work better: > > form = cgi.FieldStorage() > imgfile=open("pixel.gif",'rb') > pixel = imgfile.read() > pic1 = form.getfirst('pic1', pixel) > > because it gives a binary default. The string appears to screw things up. > Victor > Now all you have to do is what I told you in the first place, which is to remove the print statements before and after "print content". You are NOT generating HTML, you are generating a JPEG image. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From cousinstanley at gmail.com Mon Apr 28 23:37:22 2008 From: cousinstanley at gmail.com (Cousin Stanley) Date: Tue, 29 Apr 2008 05:37:22 +0200 (CEST) Subject: Python Math libraries - How to? References: Message-ID: > > Here is the arithmetic program I made that it worked before I added > the "import math" line. > > #volumen.py > # A program to compute the volume and surface area of a sphere > import math > > .... > NameError: global name 'pi' is not defined > .... >>> from math import * >>> >>> def surface( r ) : ... return 4 * pi * r ** 2 ... >>> def volume( r ) : ... return ( 4. / 3. ) * pi * r ** 3 ... >>> for n in range( 1 , 11 ) : ... s = surface( n ) ... v = volume( n ) ... print ' %2d .... %9.4f .... %9.4f ' % ( n , s , v ) ... -- Stanley C. Kitching Human Being Phoenix, Arizona From grahn+nntp at snipabacken.se Sun Apr 6 02:52:18 2008 From: grahn+nntp at snipabacken.se (Jorgen Grahn) Date: 6 Apr 2008 06:52:18 GMT Subject: Best way to check if string is an integer? References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> <0fdd2825-6d1c-4380-a79a-a7aac119f002@a5g2000prg.googlegroups.com> <96d2fe53-96bf-43d8-a58d-8269846bf0df@b64g2000hsa.googlegroups.com> Message-ID: On Sat, 5 Apr 2008 22:02:10 -0700 (PDT), Paddy wrote: > On Apr 6, 5:18 am, ernie wrote: >> On Apr 6, 10:23 am, Roy Smith wrote: >> > int(s) and catching any exception thrown just sounds like the best way. >> >> Another corner case: Is "5.0" an integer or treated as one? > In Python, 5.0 is a float "5.0" is a string, and you need to make your > mind up about what type you want "5.0" to be represented as in your > program and code accordingly. int('5.0') raises an exception rather than rounding or truncating to 5. That is probably what most people want, and it seems the original poster wanted that, too. I always use int(n). If I ever find a situation where I want another syntax for integers for some specialized use, I'll approach it as a normal parsing problem and use regexes and so on -- wrapped in a function. The problem becomes clearer if you look at floats. There are many different ways to write a float[0], and Python parses them better and faster than you and me. /Jorgen [0] There would have been more if Python had supported hexadecimal floating-point literals, like (I believe) C does. -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! From robert.kern at gmail.com Thu Apr 10 17:38:29 2008 From: robert.kern at gmail.com (Robert Kern) Date: Thu, 10 Apr 2008 16:38:29 -0500 Subject: wrapping C functions in python In-Reply-To: <1C8AE033-9B8F-4514-8C52-3462CF6447A2@gmail.com> References: <54b165660804091322w690e5e64x85c3d8f082b411b2@mail.gmail.com> <54b165660804091355m1326f7c0g1a5eebe3d6b5a1df@mail.gmail.com> <1C8AE033-9B8F-4514-8C52-3462CF6447A2@gmail.com> Message-ID: Paul Anton Letnes wrote: > Brian and Diez: > > First of all, thanks for the advice. > > Brian: > > I have installed NumPy and SciPy, but I can't seem to find a wavelet > transform there. Well, you will definitely want to use numpy arrays instead of lists or the standard library's arrays to communicate with your C code. ctypes with numpy is probably more straightforward than using SWIG with any of the three. http://www.scipy.org/Cookbook/Ctypes You may also want to check out pywt: http://pypi.python.org/pypi/PyWavelets/ -- 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 From kar1107 at gmail.com Wed Apr 30 19:20:58 2008 From: kar1107 at gmail.com (Karthik Gurusamy) Date: Wed, 30 Apr 2008 16:20:58 -0700 (PDT) Subject: ssh References: <867f5bc7-3748-4303-9f29-9d8044f0d315@m3g2000hsc.googlegroups.com> Message-ID: <9216be73-c835-4eaf-b90b-b7783f5a4770@r9g2000prd.googlegroups.com> On Apr 29, 6:29 pm, gert wrote: > Is this the best way to use ssh ? > How can i use ssh keys instead of passwords ? > I dont understand what happens when pid does not equal 0 , where does > the cmd get executed when pid is not 0 ? > How do you close the connection ? > > #http://mail.python.org/pipermail/python-list/2002-July/155390.html > import os, time > > def ssh(user, rhost, pw, cmd): > pid, fd = os.forkpty() > if pid == 0: > os.execv("/bin/ssh", ["/bin/ssh", "-l", user, rhost] + cmd) > else: > time.sleep(0.2) > os.read(fd, 1000) > time.sleep(0.2) > os.write(fd, pw + "\n") > time.sleep(0.2) > res = '' > s = os.read(fd, 1) > while s: > res += s > s = os.read(fd, 1) > return res > > print ssh('username', 'serverdomain.com', 'Password', ['ls -l']) If ssh is being used interactively (such as being prompted from password), look into pexpect module. http://www.noah.org/wiki/Pexpect Else try the subprocess module (or even commands module); these are lot simpler to program than the more primitive os.execv/os.read/write. If you have already setup keys, ssh should work passwordless whether it's interactive or not (AFAIK). Karthik From steve at holdenweb.com Mon Apr 7 16:58:42 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 07 Apr 2008 16:58:42 -0400 Subject: Data structure recommendation? In-Reply-To: <663744510804071339g639bfdccl63de8be66fe52df1@mail.gmail.com> References: <663744510804071339g639bfdccl63de8be66fe52df1@mail.gmail.com> Message-ID: Steven Clark wrote: > Hi all- > > I'm looking for a data structure that is a bit like a dictionary or a > hash map. In particular, I want a mapping of floats to objects. > However, I want to map a RANGE of floats to an object. > > This will be used for timestamped storage / lookup, where the float > represents the timestamp. > get(x) should return the object with the "newest" (biggest) timestamp > y <= x, if it exists. > Example: > > foo = Foo() > > foo.get(1.5) > -> None > foo.put(1.3, 'a') > foo.put(2.6, 'b') > foo.get(1.5) > -> 'a' > foo.get(7.8) > -> 'b' > foo.put(5.0, 'c') > foo.get(7.8) > -> 'c' > > In otherwords, by the end here, for foo.get(x), > x < 1.3 maps to None, > 1.3 <= x < 2.6 maps to 'a', > 2.6 <= x < 5.0 maps to 'b', > 5.0 <= x maps to 'c'. > > I know that foo.get() will be called many times for each foo.put(). Is > there any way to achieve O(1) performance for foo.get(), maybe via > some kind of hash function? Or is the best thing to use some kind of > binary search? > I believe the best way to implement this would be a binary search (bisect?) on the actual times, which would be O(log N). Though since they are timestamps they should be monotonically increasing, in which case at least you don't have to go to the expense of sorting them. "Some kind of hash function" won't hack it, since the purpose of a hash function is to map a large number of (possibly) evenly-distributed (potential) keys as nearly as possible randomly across a much smaller set of actual values. You might try messing around with reducing the precision of the numbers to home in on a gross region, but I am not convinced that does anything other than re-spell binary search if carried to extremes. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From ivan.illarionov at gmail.com Tue Apr 22 17:02:09 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Tue, 22 Apr 2008 14:02:09 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <965898d3-5bcf-4525-9f1c-e938a5f92117@m44g2000hsc.googlegroups.com> On 22 ???, 14:25, azrael wrote: [....] > This hurts. Please give me informations about realy famous > aplications. What do you mean by "really famous"? Information is here: http://www.python.org/about/quotes/ Are YouTube and Google famous enough? -- Ivan From sturlamolden at yahoo.no Fri Apr 11 16:31:42 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 11 Apr 2008 13:31:42 -0700 (PDT) Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> Message-ID: <3efcdcb2-1506-41a0-b148-1e1a60581032@h1g2000prh.googlegroups.com> On Apr 11, 8:35 pm, Steve Holden wrote: > wxDesigner. IMHO, wxFormBuilder is better. http://wxformbuilder.org/ http://preview.tinyurl.com/6l8wp4 From petr.jakes at tpc.cz Thu Apr 17 18:11:36 2008 From: petr.jakes at tpc.cz (=?UTF-8?Q?Petr_Jake=C5=A1?=) Date: Fri, 18 Apr 2008 00:11:36 +0200 Subject: User-defined Exceptions: is self.args OK? Message-ID: Hi, I have posted this via google.groups, but I have discovered many of you are filtering such a postings. So this is my second try from the mail client. I am trying to dig through User-defined Exceptions. chapter 8.5 in http://docs.python.org/tut/node10.html I would like to know, if is it OK to add following line to the __init__ method of the TransitionError class? self.args = (self.previous, self.next, self.message) If I do not add this argument to the class, object created by exception does not include values from self.previous, self.next, self.message attributes in the print traceback.format_exc() for example: ===== 8< snipp 8< ======== class TransitionError(Error): def __init__(self, previous, next, message): self.previous = previous self.next = next self.message = message try: raise TransitionError('previous error %s' % 'fooo', 'nextBar', 'this is foo bar message') except TransitionError, err: print err print err.args import traceback, sys print sys.exc_info() traceback.print_exc() ===== 8< snipp 8< ======== Thanks for your replies. Petr Jakes -------------- next part -------------- An HTML attachment was scrubbed... URL: From duncan.booth at invalid.invalid Wed Apr 9 09:32:55 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 9 Apr 2008 13:32:55 GMT Subject: String manipulation questions References: <8cd7b477-6fc6-47c5-b2eb-e2a4f284f7b2@m3g2000hsc.googlegroups.com> Message-ID: goldtech wrote: > Question1: The replace method - If a string does not have the target > replacement "newstring", then newline equals oldstring? Ie. oldstring > is not changed in any way? Seems to be what I observe but just want to > confirm this. Yes. > > Question2: I'm using "line.find(newstring) != -1..." because I want > to print when a replacement happens. Does "line.replace..." report > indirectly somehow when it replaces? Just do the line.replace() and then test for a change. Question 3 (which I'm sure you meant to ask really) ... No, you shouldn't be using a while loop here. Use a for loop and the enumerate builtin: for counter, line in enumerate(fileIN): newline = line.replace(oldstring, newstring) if newline != line: print 'match at line', counter+1 fileOUT.write(newline) From gpk at kochanski.org Sun Apr 6 13:59:17 2008 From: gpk at kochanski.org (Greg Kochanski) Date: Sun, 06 Apr 2008 18:59:17 +0100 Subject: Tweaking PEP-234 to improve Duck Typing Message-ID: <47F90F75.90804@kochanski.org> Id'a like to raise an issue that was partially discussed in 2006 ( http://groups.google.co.uk/group/comp.lang.python/browse_thread/thread/1811df36f2a131fd/435ba1cae670aecf?lnk=st&q=python+iterators+duck+typing#435ba1cae670aecf ) with the half-promise that it would be revisited before Python 3000. Now's the last chance. What is Duck Typing? Ultimately, the goal is that if you do something stupid, Python will give you a big fat error message fairly soon after the stupid code was executed. Without effective duck typing, we'd be forced to put in lots of test code everywhere, something like assert isinstance(x, list) Doing so would be bad because our python would become cluttered and less able to be polymorphic/reused. Nuff said. Now, where does duck typing fail in modern Python? In this case: def foo(x): for i in x: doSomething(i) for i in x: somethingElse(i) Function foo() is unsafe as part of any API because you never know whether someone is going to pass it a list or an iterator. For me, doing scientific programming, this is a *very* common use case. doSomething() may collect statistics or look for bad data, then somethingElse() does the main computation. Now, if foo() is somehow passed an iterator, the second loop will fail silently, leading to much hair pulling and gnashing of teeth. Some might say "serves you right for making a mistake!", but I've always suspected that such people go around insulting victims of traffic accidents. Of *course* there are ways to work around the problem. Using Java is one, adding assert statements is another, writing detailed docstrings is a third. However, none are nearly as good as duck typing. Adding "x=list(x)" near the top of the function should work, but at a horrible cost in efficiency if it's a big list. It seems that the 2006 discussion barely missed the right solution: 1) Create a new standard exception IteratorExhausted; it will be a subclass of StopIteration. 2) StopIteration is raised when the iterator runs out of data. If it.next() is called again, then IteratorExhausted should be raised. 3) For loops will be set to trap IteratorExhausted and raise and error (perhaps raise a TypeError, "Iterator used in two for loops"). POSITIVE IMPACT: This will reduce the transition difficulties to python 3.0 due to changes of zip() and other functions from lists to iterators. Any code of the form foo(zip(a,b)) or foo(map(...)) or foo(filter(...)) or a few other things would become silently wrong in python 3.0. With this modification, it will be noisy wrong. (Much better!) Since IteratorExhausted is a subclass of StopIteration, normal uses of StopIteration will be unaffected. Code that sticks to the current PEP-234 will continue to work absolutely unchanged. NEGATIVE IMPACT: Code in the form below will fail noisily if it was intended to be used with current PEP-234 iterators and if the upper loop does not terminate early. (But it will work correctly if handed a list.) def bar(x): for i in x: if someThing(i): break for i in x: anotherThing(i) However, note that this code will give different results depending if it is passed an iterator or a list, so it's somewhat dangerous anyway. I suspect this is a rare case compared to all the python 3.0 upheaval. However, it can be fixed fairly easily and efficiently by simply putting a try...except statement around the second "for" loop. I believe that it will add no silent failures to 2.5 code run on Python3.0 and will convert many silent failures into noisy failures. In my book, that's a Good Thing. Overall, I believe it will reduce the pain of Python 3.0 and increase the uptake rate. Comments appreciated. (Not that I could avoid them, anyway!) From victorsubervi at gmail.com Mon Apr 14 09:29:57 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Mon, 14 Apr 2008 08:29:57 -0500 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> Message-ID: <4dc0cfea0804140629rf1ac100m27ad9d0456cbbe2d@mail.gmail.com> Thanks to all, especially Gabriel. The base64 is a good idea, but you state a definite problem. I will look at your code at home (offline)...thank you very much! It looks like the kicker is this line here: %s" % (picid, cgi.escape(title)) Now, why didn?t you share that before????? I can see how calling a separate script like that would work! Again, you should have shared that before. How was I to think of that clever trick from the bare information you gave me earlier?? Steve, thank you for all your help, but do overcome your temper :)) Victor On Sun, Apr 13, 2008 at 7:05 AM, Steve Holden wrote: > Jason Scheirer wrote: > [...] > > > > There _is_ a way to embed image data in HTML that is supported by > > every major browser. It is ugly. Using the RFC 2397 (http:// > > www.ietf.org/rfc/rfc2397) spec for data URLs you could go > > > > '' % base64.b64encode(image_data) > > > > Obviously you need to import the base64 module somewhere in your code > > and base64-encoded data is about a third larger than it would be > > otherwise, so embedding anything particularly large is going to be a > > huge pain and affect page load times pretty badly. > > This is hardly likely to help someone who hasn't yet grasped the concept > of referencing graphics and prefers to write database output to disk to > serve it statically. But who knows, maybe it will ... > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From szport at gmail.com Thu Apr 3 09:53:12 2008 From: szport at gmail.com (Zaur Shibzoukhov) Date: Thu, 3 Apr 2008 17:53:12 +0400 Subject: Application of "with" statement in py3k. Property defining/redefining. Message-ID: http://szport.blogspot.com/2008/04/application-of-with-statement-in-py3k.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From aaron.watters at gmail.com Wed Apr 30 16:04:33 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 30 Apr 2008 13:04:33 -0700 (PDT) Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> <4814B904.1070804@v.loewis.de> Message-ID: > I do not argue that Python's default GC parameters must change -- only > that applications with lots of objects may want to consider a > reconfiguration. I would argue that changing the GC to some sort of adaptive strategy should at least be investigated. Having an app which doesn't need gc spending most of its time doing gc is annoying, to say the least. Of course any such change should be tested and analysed thoroughly before it goes into Python 2.6.1 or whatever and it would be great if there were several alternatives considered and compared. Hmmm. I think this would make an excellent computer science Master's Thesis topic. Anybody looking for a topic? -- Aaron Watters ==== http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=use+while+fresh From gagsl-py2 at yahoo.com.ar Mon Apr 21 02:13:58 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 03:13:58 -0300 Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: En Fri, 18 Apr 2008 12:58:56 -0300, Aaron Watters escribi?: > Why is the migration to py3k a concern? > For example I have libraries which use string%dictionary > substitution where the dictionary is actually an object > which emulates a dictionary. The __getitem__ for > the object can be very expensive and is only called when > needed by the string substitution. > > In py3k string%dictionary is going away. Why? > I have no idea. But not soon. It's not listed in PEP 3100 and according to this message http://mail.python.org/pipermail/python-3000/2008-April/013094.html %s formatting will not disappear until Python 3.3 You have plenty of time to evaluate alternatives. Your code may become obsolete even before 3.3 is shipped. -- Gabriel Genellina From floris.bruynooghe at gmail.com Sun Apr 6 12:16:52 2008 From: floris.bruynooghe at gmail.com (Floris Bruynooghe) Date: Sun, 6 Apr 2008 09:16:52 -0700 (PDT) Subject: @x.setter property implementation Message-ID: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> Hello I found out about the new methods on properties, .setter() and .deleter(), in python 2.6. Obviously that's a very tempting syntax and I don't want to wait for 2.6... It would seem this can be implemented entirely in python code, and I have seen hints in this directrion. So before I go and try to invent this myself does anyone know if there is an "official" implementation of this somewhere that we can steal until we move to 2.6? Cheers Floris From kyosohma at gmail.com Mon Apr 7 08:54:19 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Mon, 7 Apr 2008 05:54:19 -0700 (PDT) Subject: Wxpython. Is it possible to change layout in a running application? Selfmade listbox References: <716c0f27-bca6-4642-a8ec-cdbb0b23e6e8@h1g2000prh.googlegroups.com> Message-ID: <105355bb-2d56-491e-8764-e4c34a0de8c5@d45g2000hsc.googlegroups.com> On Apr 7, 6:50 am, Soren wrote: > Hi, > > Id like to make my own special listbox.. I want to able (at the push > of a button) to add another item to my special listbox... each item is > a panel with a label, some buttons and maybe a text control. > > I've tried adding a new panel object with the stuff i want to the > sizer i'm using for my listbox (which is a panel which can contain > other panels)... and then run update() and refresh() on everything... > But it doesn't work.. i see a panel appearing, but it's just a small > square in the corner of my "listbox" panel, and it only works the > first time... nothing new appears when I push the button again. > > Is it at all possible to do this? Has anyone created something > similar? Does anyone know what i'm doing wrong? > > Thanks, > Soren I'm pretty sure it's possible, but as Iain pointed out, it's hard to guess what you're doing wrong without some code. Try making a sample app that demonstrates the issue: http://wiki.wxpython.org/MakingSampleApps Also, you will probably receive more help at the wxPython specific list, found here: http://wxpython.org/maillist.php HTH Mike From mav at cuma.polymath-solutions.lan Wed Apr 2 14:32:54 2008 From: mav at cuma.polymath-solutions.lan (Maurizio Vitale) Date: Wed, 02 Apr 2008 18:32:54 GMT Subject: non-terminating regex match References: <65i0i3F2embp3U2@mid.uni-berlin.de> Message-ID: Marc 'BlackJack' Rintsch writes: > On Wed, 02 Apr 2008 16:01:59 +0000, Maurizio Vitale wrote: > >> And yes, I'm a total beginner when it comes to Python, but it seems >> very strange to me that a regex match on a finite length string >> doesn't terminate > > It does terminate, you just don't wait long enough. Try it with fewer > characters and then increase the identifier character by character and > watch the time of the runs grow exponentially. > Ok. Now, my assumption was that re.compile would produce a DFA (or NFA) and the match would then being linear in the size of the string. Apparently this is not the case, so is there anything that can be done to the regex itself to make sure that whatever re.compile produces is more efficient? Thanks, Maurizio From tnelson at onresolve.com Tue Apr 22 13:52:57 2008 From: tnelson at onresolve.com (Trent Nelson) Date: Tue, 22 Apr 2008 10:52:57 -0700 Subject: Python script to automate use of Google Translate? (or other translator) In-Reply-To: References: Message-ID: <87D3F9C72FBF214DB39FA4E3FE618CDC6E243C7BF2@EXMBX04.exchhosting.com> > > I have the need to occasionally translate a single word > > programatically. Would anyone have a Python script that > > would let me do this using Google (or another) translation > > service? As a matter of fact, yes, I do! This happens to be my most favourite piece of Python code I've ever written, too... In [1]: from translate import * In [2]: translate('French', 'The quick brown fox jumped over the lazy dog.') Le renard brun rapide a saut? par-dessus le chien paresseux. In [3]: translate('German', 'The quick brown fox jumped over the lazy dog.') Der schnelle braune Fuchs sprang ?ber den faulen Hund. In [4]: translate('Spanish', 'The quick brown fox jumped over the lazy dog.') El zorro marr?n r?pido salt? sobre el perro perezoso. And translate.py: import sys from urllib import urlopen, urlencode from BeautifulSoup import BeautifulSoup url = 'http://babelfish.altavista.com/tr' languages = { 'French' : 'en_fr', 'German' : 'en_de', 'Italian' : 'en_it', 'Spanish' : 'en_es', 'Russian' : 'en_ru', 'Portuguese': 'en_pt', 'Dutch' : 'en_nl', 'Japanese' : 'en_ja', } def translate(lang, text): kwds = { 'trtext' : text, 'lp' : languages[lang]} soup = BeautifulSoup(urlopen(url, urlencode(kwds))) print soup.find('div', style='padding:10px;').string if __name__ == '__main__': translate(sys.argv[1], sys.argv[2]) Enjoy! Regards, Trent. From sturlamolden at yahoo.no Mon Apr 21 12:34:39 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Mon, 21 Apr 2008 09:34:39 -0700 (PDT) Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B52DE.8070105@holdenweb.com> <2be5608d-560d-4712-b104-f2341a7fa569@t63g2000hsf.googlegroups.com> Message-ID: On Apr 21, 4:09 am, "Gabriel Genellina" wrote: > I'm not sure if this will help the OP at all - going into a world of dangling pointers, keeping track of ownership, releasing memory by hand... One of the good things of Python is automatic memory management. Ensuring that all references to an object are released (the standard Python way) is FAR easier than doing all that by hand. The owner was complaining he could not manually release memory using del, as if it was Python's equivalent of a C++ delete[] operator. I showed him how it could be done. I did not say manual memory management is a good idea. From carlwuhwdmckay at gmail.com Sat Apr 26 09:34:36 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:34:36 -0700 (PDT) Subject: garmin keygen Message-ID: <8c636918-323e-4894-8b0c-8b381c627816@56g2000hsm.googlegroups.com> garmin keygen http://cracks.00bp.com F R E E C R A C K S From jason.scheirer at gmail.com Fri Apr 18 21:34:42 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Fri, 18 Apr 2008 18:34:42 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <0ebcf70f-c6d6-4ee7-9ef8-7cd2221ef906@t12g2000prg.googlegroups.com> <879750f6-614a-45ed-8f18-f0b7ae5ea9a2@26g2000hsk.googlegroups.com> Message-ID: <5e6abd62-56a6-4a8f-b4b9-8e3eb160c733@p39g2000prm.googlegroups.com> On Apr 18, 4:19 pm, Kay Schluehr wrote: > On 18 Apr., 23:09, Matimus wrote: > > > The reason it doesn't work is that you are unpacking the dictionary > > with **, and you have done nothing to define any keys or define a > > length. > > This is a non-issue. The class derives from dict; it has all the > desired attributes. It is also not a problem in particular because > these properties are not requested by format ( at least not in the > code I have examined which was admittedly just a critical section that > caused the exception ). > > > Adding to that... don't worry about py3k. Nobody is forcing you to > > switch. In fact, you are encouraged not to until you are comfortable. > > Py3k won't _break_ your code. You wrote the code for Python 2.x use it > > in 2.x. Python 2.x probably has a good 5-10 years remaining. > > These advices start to get annoying. > > Software hardly ever exists in isolation for the sake of the beauty of > the algorithm but is supplementary to a large framework/engine/ > library. So if e.g. Django switches to 3 everyone who works with it > has to switch sooner or later as well or lose track otherwise, no > matter how long Python 1.5.2 or Python 2.5.2 or whatever version will > be maintained. If Pythons code base becomes fragmented it will be > harmful and affect almost everyones work. This has happened before, though -- I remember the pain of moving to 2.0 from the 1.5 branch way back when, and it wasn't getting my 1.5 code to work in 2.0, it was being jealous of all the cool features of 2.0 that I had to wait to get. I was working in production with 1.5 in 2000 and all the libraries available for Python gradually stopped supporting 1.5 to pick up interesting 2.0 features that actually made them easier to work with, and new libraries all began to assume you were using a 2.0+ Python version because that's what was current. By 2003-2004 everyone I knew had switched over to 2.0, but by then I had had nearly 5 years to port my legacy 1.5 code to 2.0, take advantage of the 2.0 version's features, and do plenty of testing of my 1.5 codebase in 2.0 before I switched my production systems over. Not to mention the fact that plenty of warning was offered BEFORE 2.0 was released and 1.5 was not abruptly ended, but gradually phased out until only the teeniest far ends of the long tail were using it. The 2.6->3.0 process is going to be even less of a pain than the 1.5->2.0 conversion, which was not hard at all going forward into it. You may not want to switch, but by the time you decide to it will be pretty easy to move on -- the extreme opposite reality being your application will be so frozen that both your Python version and your codebase will be fossils, left to hum on completely unchanged on some forgotten server like so much other legacy code. From fetchinson at googlemail.com Tue Apr 15 23:04:51 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Tue, 15 Apr 2008 20:04:51 -0700 Subject: Interesting timing issue I noticed In-Reply-To: References: Message-ID: > I've written up a stripped down version of the code. I apologize for the bad > coding; I am in a bit of a hurry. > > import random > import sys > import time > > sizeX = 320 > sizeY = 240 > borderX = 20 > borderY = 20 > > # generates a zero matrix > def generate_zero(): > matrix = [[0 for y in range(sizeY)] for x in range(sizeX)] > return matrix > # fills zero matrix > def fill_matrix(in_mat): > mat = in_mat > for x in range(sizeX): > for y in range(sizeY): > mat[x][y] = random.randint(1, 100) > return mat > ###################################################################### > # COMPUTES ONLY A PART OF THE ARRAY > def back_diff_one(back_array, fore_array, box): > diff_array = generate_zero() > > start = time.time() > for x in range(sizeX): > for y in range(borderY): > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > for y in range((sizeY - borderY), sizeY): > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > for y in range(borderY, (sizeY - borderY)): > for x in range(borderX): > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > for x in range((sizeX - borderX), sizeX): > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > # tracks object > if (len(box) != 0): > for x in range(box[0], box[2]): > for y in range(box[1], box[3]): > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > print "time one inside = " + str(time.time() - start) > return diff_array > ###################################################################### > # COMPUTES EVERY ELEMENT IN THE ARRAY > def back_diff_two(back_array, fore_array): > diff_array = generate_zero() > start = time.time() > for y in range(sizeY): > for x in range(sizeX): > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > end = time.time() > print "time two inside = " + str(end - start) > return diff_array > ###################################################################### > # CODE TO TEST BOTH FUNCTIONS > back = fill_matrix(generate_zero()) > fore = fill_matrix(generate_zero()) > box = [20, 20, 268, 240] > start1 = time.time() > diff1 = back_diff_one(back, fore, box) > print "time one outside = " + str(time.time() - start1) > start2 = time.time() > diff2 = back_diff_two(back, fore) > print "time one outside = " + str(time.time() - start2) > > Here are some results from several test runs: > > time one inside = 0.0780000686646 > time one outside = 0.125 > time two inside = 0.0780000686646 > time two outside = 0.141000032425 > >>> ================================ RESTART > ================================ > >>> > time one inside = 0.0629999637604 > time one outside = 0.125 > time two inside = 0.0789999961853 > time two outside = 0.125 > >>> ================================ RESTART > ================================ > >>> > time one inside = 0.0620000362396 > time one outside = 0.139999866486 > time two inside = 0.0780000686646 > time two outside = 0.125 > >>> ================================ RESTART > ================================ > >>> > time one inside = 0.0780000686646 > time one outside = 0.172000169754 > time two inside = 0.0789999961853 > time two outside = 0.125 > >>> ================================ RESTART > ================================ > >>> > time one inside = 0.0780000686646 > time one outside = 0.125 > time two inside = 0.0780000686646 > time two outside = 0.125 > >>> ================================ RESTART > ================================ > >>> > time one inside = 0.0620000362396 > time one outside = 0.155999898911 > time two inside = 0.0780000686646 > time two outside = 0.125 > >>> ================================ RESTART > ================================ > >>> > time one inside = 0.077999830246 > time one outside = 0.125 > time two inside = 0.077999830246 > time two outside = 0.125 > >>> ================================ RESTART > ================================ > >>> > time one inside = 0.0780000686646 > time one outside = 0.171000003815 > time two inside = 0.077999830246 > time two outside = 0.125 > >>> ================================ RESTART > ================================ > >>> > time one inside = 0.0629999637604 > time one outside = 0.18799996376 > time two inside = 0.0620000362396 > time two outside = 0.125 > > Why is a large percentage of the time, the execution time for the > (ostensibly smaller) first loop is actually equal to or LARGER than the > second? First of all, your method of timing is not the best. Use the timeit module instead: http://docs.python.org/lib/module-timeit.html Second of all the number of subtractions is not that different between the two variants of your functions. back_diff_one does 75360 subtractions per call while back_diff_two does 76800, these two numbers are almost the same. It's true that back_diff_one first only calculates a part of the arrays but after "# tracks object" you do a bunch of more substractions that will make up the total count. HTH, Daniel From aguirre.adolfo at gmail.com Mon Apr 28 22:58:42 2008 From: aguirre.adolfo at gmail.com (aguirre.adolfo at gmail.com) Date: Mon, 28 Apr 2008 19:58:42 -0700 (PDT) Subject: Python Math libraries - How to? References: Message-ID: <29c9735b-46fc-4650-b82a-1147a3efb2ad@c58g2000hsc.googlegroups.com> Thank you :-), I?ll do Adolfo > > pi is not a global name. When you do "import math",you aren't adding > everything to the name space, you are just telling python that you are > going to be using that file. You then refer to it as math.*, such as > "math.pi", or "math.pow(r,3)". To use it the way you want to, you > would have to do "from math import pi" instead of "import math" From __peter__ at web.de Wed Apr 30 06:17:08 2008 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Apr 2008 12:17:08 +0200 Subject: File IO Issues, help :( References: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> <1fd8deae-1ed4-493c-a508-06c528c4ee1f@r66g2000hsg.googlegroups.com> Message-ID: Dennis Lee Bieber wrote: > On Tue, 29 Apr 2008 08:35:46 +0200, Peter Otten <__peter__ at web.de> > declaimed the following in comp.lang.python: > > >> jsfile.truncate(0) >> jsfile.seek(0) >> > I'd suggest first doing the seek to start, then do the truncate I usually overwrite the file, and that shows. Is there a usecase where truncate() with an argument actually makes sense? Peter From noname9968 at gmail.com Fri Apr 4 14:46:48 2008 From: noname9968 at gmail.com (Alex9968) Date: Fri, 04 Apr 2008 22:46:48 +0400 Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? In-Reply-To: References: Message-ID: <47F67798.3060401@gmail.com> Nebur wrote: > No, I can't reproduce it, and I don't know whom to blame (Pydev? > Eclipse ? The File System ? A Virus that only 2 times in half a year > deletes a single file I'm busy working with, and seems to do nothing > else? Myself beeing schizophrenic ??) A virus created to remind you 2 times in half a year of the importance of backup operations ;-) . I'm joking. I don't know what is this, but I'm interested. Because my files won't be restorable from version control :-( From ewertman at gmail.com Sun Apr 20 11:35:57 2008 From: ewertman at gmail.com (Eric Wertman) Date: Sun, 20 Apr 2008 08:35:57 -0700 (PDT) Subject: Alternate indent proposal for python 3000 Message-ID: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> I was considering putting together a proposal for an alternate block syntax for python, and I figured I'd post it here and see what the general reactions are. I did some searching, and while I found a lot of tab vs space debates, I didn't see anything like what I'm thinking of, so forgive me if this is a very dead horse. Generally speaking, I like the current block scheme just fine. I use python on a daily basis for system administration and text parsing tasks, and it works great for me. >From time to time, though, I find myself needing a language for server- side includes in web pages. Because of the need to indent (and terminate indents), python seems an awkward choice for this, and it's easy for me to see why php and perl are more popular choices for this kind of task. Perhaps this is just my perception though. I feel that including some optional means to block code would be a big step in getting wider adoption of the language in web development and in general. I do understand though, that the current strict indenting is part of the core of the language, so... thoughts? From fairwinds at eastlink.ca Mon Apr 7 23:30:15 2008 From: fairwinds at eastlink.ca (David Pratt) Date: Tue, 08 Apr 2008 00:30:15 -0300 Subject: Help replacing os.system call with subprocess call In-Reply-To: <47FA3D2C.2010504@eastlink.ca> References: <47F9B1D1.4090701@eastlink.ca> <47F9C764.9070401@mattnordhoff.com> <47FA23E7.7040809@eastlink.ca> <47FA2B72.9050802@mattnordhoff.com> <47FA3D2C.2010504@eastlink.ca> Message-ID: <47FAE6C7.5010804@eastlink.ca> Hi Matt. My apologies, I was away a good part of the day and evening today. Here are the numbers for the different methods: original os.system call: 29.685759 s buffered stdout call: 213.370982 s (with 1mb buffer) direct to stdout call: 33.378756 s The second method worked great and is essentially equivalent in execution time to original call :-). This has got me smiling. Many thanks Matt for your help, particularly working through the second example that provided equivalent speed. Regards, David David Pratt wrote: > Hi Matt. Many thanks. Sorry I had not seen your second post. I'll give > this a try and time the completion to compare the differences and post > back later today to show os.system, buffered imput and using a file > directly for stdout. > > Regards, > David > > Matt Nordhoff wrote: >> David Pratt wrote: >>> Hi David and Matt. I appreciate your help which has got me moving >>> forward again so many thanks for your reply. I have been using >>> subprocess.Popen a fair bit but this was the first time I had to use >>> subprocess to capture large file output. The trouble I was having was >>> with the process would just hang. Chunking was the solution. I guess I >>> assumed this would be taken care of in the internals. >>> >>> Overall, I wish subprocess had some better documentation since it is >>> definitely not a drop in replacement for os.system. In other >>> circumstances I am using subprocess.call() for simple calls which works >>> fine. >>> >>> The speed of this solution is slower than os.system. Would a queue of >>> some kind be needed to speed this up? Has anyone implemented something >>> like this? Many thanks. >>> >>> Regards, >>> David >> Did you see my second message? That should help performance. If not, I'm >> totally out of my depth and have no idea at all. Sorry. >> >> (How much slower? 10%? 200%?) From castironpi at gmail.com Tue Apr 1 16:21:17 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Tue, 1 Apr 2008 13:21:17 -0700 (PDT) Subject: python persistence References: <8b1723d9-67c8-4fe5-b07b-22b0b9311519@8g2000hsu.googlegroups.com> <7f58b5f4-3195-472c-b307-dec71b12aaa8@y21g2000hsf.googlegroups.com> <44f04bf3-4edc-4cb4-9e54-fe51b5e591bc@e39g2000hsf.googlegroups.com> <80d1731d-a3c6-4fce-81fd-9c3f3537e59b@d21g2000prf.googlegroups.com> <5386cf08-c155-4fbb-8373-dbbb9829a9e7@m3g2000hsc.googlegroups.com> <3c27b270-e593-4f2a-b881-68126319760c@8g2000hsu.googlegroups.com> <7d71e294-2b13-4be0-948e-2fe0e4bbe7db@f63g2000hsf.googlegroups.com> Message-ID: On Apr 1, 11:34?am, "Gabriel Genellina" wrote: > En Tue, 01 Apr 2008 08:47:33 -0300, escribi?: > > >> >>>> c['0']= type('None',(),{}) > >> > Traceback (most recent call last): > >> > pickle.PicklingError: Can't pickle : it's not > >> > found as __main__.None > > >> Don't do that then. Or use the available pickle hooks to customize how ? > >> such classes may be pickled. All persistence mechanisms have ? > >> limitations. > > > I don't see a problem with that; except that binaries come from > > disks. ?You could have a Python session that runs entirely on disks + > > the ALU. > > (ALU? Do you mean CPU?) I don't understand this. Most programs are read ? > ?from disk. Most data is read from disk. > > > I want to know if any, and correct me here, simple > > modification can store live objects. ?I call a.append(it) and the > > memory update takes place on disk instead. > > Using ZODB, a.append(it) would mark `a` as dirty. When you latter commit ? > the transaction, it is stored back on disk. > > > If you require that all objects referenced by on-disk objects be on- > > disk, that's an easy workaround. > > ZODB already does that. It's pretty close, but the database connection can get bulky. If you had: _______________________ | ______________________ |File | PyOb1 | PyOb2 | .. | | |_______|_______|______| |_______________________ on disk, updating the reference counts and attributes would take a long time, but it's just right for some core applications. Strictly, I'm not in the "real" programming world, so if it's just a few free steps to a database then I'm speculating. If it's not, then writing database code needlessly complicates programs in some cases. A default implementation might even take an explicit destroy statement, essentially being a run-time swap file or random-access pickles. A possibility is to launch a manager in a separate process, so authors don't have to bother with writeback. I'm actually almost looking at off-loading protocols on this one. Cache is guaranteed to be up to date, so cache a file in memory, and manipulate it so it has Python bits. The object comes to survive the program. Call stack is still in volatile. > Using ZODB, a.append(it) would mark `a` as dirty. When you latter commit > the transaction, it is stored back on disk. Python changes are committed on line. ZODB does -not- do that. A pretty close change would be: Open file Interpret file as generator, halted at yield but started, Call send and next What does the code for that look like? From n00m at narod.ru Sun Apr 27 02:21:44 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 23:21:44 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <8ee48fc1-45af-404f-8fad-d8e1b2fb90b4@s50g2000hsb.googlegroups.com> Message-ID: <65aa8711-7fbc-4d07-900f-9067d8a5f7fd@m44g2000hsc.googlegroups.com> Oops... I spotted a slip in my C++ code. Forgot " - t" in cout << clock()/CLOCKS_PER_SEC << endl; The correct proportion is 7.5s / 2.75s = 2.7 times. From ptmcg at austin.rr.com Tue Apr 1 21:01:01 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Tue, 1 Apr 2008 18:01:01 -0700 (PDT) Subject: BeautiflSoup -- getting all the attributes of a tag? References: Message-ID: <75bc9d29-dc13-4339-a221-8189d1f5aa4a@n58g2000hsf.googlegroups.com> On Apr 1, 6:28?pm, 7stud wrote: > On Apr 1, 5:25?pm, 7stud wrote: > > > > > > > You can treat a tag like a dictionary to obtain a specific attribute: > > > import BeautifulSoup as bs > > > html = "
hello
" > > > doc = bs.BeautifulSoup(html) > > div = doc.find("div") > > print div > > print div["x"] > > > --output:-- > > a > > > But you can't iterate over a tag to get all the attributes: > > > import BeautifulSoup as bs > > > html = "
hello
" > > > doc = bs.BeautifulSoup(html) > > div = doc.find("div") > > > for key in div: > > ? ? print key, div[key] > > > --output:-- > > hello > > Traceback (most recent call last): > > ? File "test1.py", line 9, in ? > > ? ? print key, div[key] > > ? File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ > > python2.4/site-packages/BeautifulSoup.py", line 430, in __getitem__ > > ? ? return self._getAttrMap()[key] > > KeyError: u'hello' > > > How can you get all the attributes when you don't know the attribute > > names ahead of time? > > I figured it out: > > import BeautifulSoup as bs > > html = "
hello
" > > doc = bs.BeautifulSoup(html) > div = doc.find("div") > > for attr, val in div.attrs: > ? ? print "%s:%s" % (attr, val) > > --output:-- > x:a > y:b > z:c- Hide quoted text - > Just for another datapoint, here's how it looks with pyparsing. -- Paul from pyparsing import makeHTMLTags,SkipTo html = """
hello
""" # HTML tags match case-insensitive'ly divStart,divEnd = makeHTMLTags("DIV") divTag = divStart + SkipTo(divEnd)("body") + divEnd for div in divTag.searchString(html): print div.dump() print # dict-like access to results for k in div.keys(): print k,div[k] # object.attribute access to results print div.body print div.x print div.y print Prints: ['DIV', ['x', 'a'], ['y', 'b'], ['z', 'c'], False, 'hello', '
'] - body: hello - empty: False - endDiv:
- startDiv: ['DIV', ['x', 'a'], ['y', 'b'], ['z', 'c'], False] - empty: False - x: a - y: b - z: c - x: a - y: b - z: c body hello endDiv y b x a z c startDiv ['DIV', ['x', 'a'], ['y', 'b'], ['z', 'c'], False] empty False hello a b From Robert.Bossy at jouy.inra.fr Fri Apr 25 03:44:32 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Fri, 25 Apr 2008 09:44:32 +0200 Subject: Little novice program written in Python In-Reply-To: References: Message-ID: <48118BE0.8010406@jouy.inra.fr> Peter Otten wrote: > Rog?rio Brito wrote: > > >> i = 2 >> while i <= n: >> if a[i] != 0: >> print a[i] >> i += 1 >> > > You can spell this as a for-loop: > > for p in a: > if p: > print p > > It isn't exactly equivalent, but gives the same output as we know that a[0] > and a[1] are also 0. > If the OP insists in not examining a[0] and a[1], this will do exactly the same as the while version: for p in a[2:]: if p: print p Cheers, RB From rorymckinleylists at gmail.com Sat Apr 5 11:27:52 2008 From: rorymckinleylists at gmail.com (Rory McKinley) Date: Sat, 05 Apr 2008 17:27:52 +0200 Subject: Weird scope error Message-ID: <47F79A78.4010207@gmail.com> Hi I am trying to use the TidyHTMLTreeBuilder module which is part of elementtidy, but I am getting what appears to be some sort of scope error and it is scrambling my n00b brain. The module file (TidyHTMLTreeBuilder.py) tried to import ElementTree by doing the following: from elementtree import ElementTree This bombed, so after a bit of poking around I replaced it with : from xml.etree import ElementTree This appears to have worked. However, when I try and parse a file using the function : TidyHTMLTreeBuilder.parse('weather_ct.html') I receive the following error: Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.5/site-packages/elementtidy/TidyHTMLTreeBuilder.py", line 107, in parse return ElementTree.parse(source, TreeBuilder()) NameError: global name 'ElementTree' is not defined The code producing the error is as follows: def parse(source): return ElementTree.parse(source, TreeBuilder()) Surely, if the from... import has worked, ElementTree is in the global scope and should therefore be accessible to the function parse? Can anybody help? THanks From Scott.Daniels at Acm.Org Fri Apr 11 07:37:03 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Fri, 11 Apr 2008 04:37:03 -0700 Subject: Rounding a number to nearest even In-Reply-To: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: bdsatish wrote: > The built-in function round( ) will always "round up", that is 1.5 is > rounded to 2.0 and 2.5 is rounded to 3.0. > > If I want to round to the nearest even, that is > > my_round(1.5) = 2 # As expected > my_round(2.5) = 2 # Not 3, which is an odd num > > I'm interested in rounding numbers of the form "x.5" depending upon > whether x is odd or even. Any idea about how to implement it ? def rounded(v): rounded = round(v) if divmod(v, 1)[1] == .5 and divmod(rounded, 2)[1] == 1: if v > 0: return rounded - 1 return rounded + 1 return rounded last = None for n in range(-29, 28): x = n * .25 r = xr(x) if r != last: last = r print print '%s->%s' % (x, xr(x)), -7.25->-7.0 -7.0->-7.0 -6.75->-7.0 -6.5->-6.0 -6.25->-6.0 -6.0->-6.0 -5.75->-6.0 -5.5->-6.0 -5.25->-5.0 -5.0->-5.0 -4.75->-5.0 -4.5->-4.0 -4.25->-4.0 -4.0->-4.0 -3.75->-4.0 -3.5->-4.0 -3.25->-3.0 -3.0->-3.0 -2.75->-3.0 -2.5->-2.0 -2.25->-2.0 -2.0->-2.0 -1.75->-2.0 -1.5->-2.0 -1.25->-1.0 -1.0->-1.0 -0.75->-1.0 -0.5->0.0 -0.25->-0.0 0.0->0.0 0.25->0.0 0.5->0.0 0.75->1.0 1.0->1.0 1.25->1.0 1.5->2.0 1.75->2.0 2.0->2.0 2.25->2.0 2.5->2.0 2.75->3.0 3.0->3.0 3.25->3.0 3.5->4.0 3.75->4.0 4.0->4.0 4.25->4.0 4.5->4.0 4.75->5.0 5.0->5.0 5.25->5.0 5.5->6.0 5.75->6.0 6.0->6.0 6.25->6.0 6.5->6.0 6.75->7.0 From cokofreedom at gmail.com Wed Apr 23 11:15:12 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Wed, 23 Apr 2008 08:15:12 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: Civilisation 4 uses Python everywhere and is the main tool used by Modders of the game. From searyan at gmail.com Wed Apr 30 12:42:15 2008 From: searyan at gmail.com (Sean Ryan) Date: Wed, 30 Apr 2008 17:42:15 +0100 Subject: Python -v import behavior Message-ID: <357b87b40804300942v371152b0u9dcc6d8b8d0a3b32@mail.gmail.com> Hi all, (A similar question was posted by a colleague, but did not appear to reach comp.lang.python or this list). I am wondering if the -v option causes the python application to be more tolerant to module import warnings and / or errors. The reason is that a module is failing to import correctly (generating an ImportError exception). Examining this closer we re-ran the script using the -v option. to find that "Unsatisfied symbol" errors we being displayed during import (cx_Oracle 4.3.1, python 2.5.1, HP-UX 11, oracle 9.2). However, the module is usable from the python prompt (when using -v) displayed, i.e. dir (cx_Oracle) works correctly, as does database interaction. Without the -v option the script is halted due to the ImportError exception. My questions are: 1. Is there a way to mimic the seemingly more tolerant import behavior of python -v without producing the verbose output ? 2. Is the behavior described above expected and documented ? Thanks and best regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: From fennelllindy8241 at gmail.com Mon Apr 28 03:24:43 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:24:43 -0700 (PDT) Subject: crack acrylic sheet repair Message-ID: crack acrylic sheet repair http://crack.cracksofts.com From info at wingware.com Mon Apr 28 11:29:47 2008 From: info at wingware.com (Wingware) Date: Mon, 28 Apr 2008 11:29:47 -0400 Subject: Wing IDE 3.1beta3 released Message-ID: <4815ED6B.2070605@wingware.com> Hi, Wingware has released version 3.1 beta3 of Wing IDE, an integrated development environment for the Python programming language. It is available from: http://wingware.com/wingide/beta This release includes the following changes: * How-To and improvements for using Wing IDE with Google App Engine * Scan for sys.path changes in main debug file (e.g. for Zope buildouts) * Preference to auto-strip trailing white space on save * Many vi mode improvements * Testing tool enhancements, including better support for test names that are not method names * Sped up stepping in the debugger * Set encoding for stdin/out/err in debug processes for better handling of non-ascii input and output * Fixed problems with debugging stackless tasklets * Python Shell allows spawned threads to run, rather than stopping all threads * Improved support for debugging code invoked by execfile() * Better autocompletion support for an x defined by 'import x.y.z' * More bug fixes, including also all those found in Wing 3.0.5 Please see the change log for a detailed list of changes: http://wingware.com/pub/wingide/prerelease/3.1.0-b3/CHANGELOG.txt Version 3.1 introduces a number of new features and includes bug fixes not found in the 3.0 series, as follows: * Files within .zip or .egg files can be displayed in the editor * Support for pkg_resources based namespace packages * Support for doctest and nose unit test frameworks (**) * Updated code analysis support for Python 2.5 constructs * Improved support for tasklets in Stackless Python * In-line argument entry of code templates/snippets (tab and back tab to traverse fields; arrow keys to change template indent, Esc to exit data entry mode) (**) * Include templates by name in autocompleter (**) * Simple word list driven auto-completion when working in non-Python files (*) * Open from Project for quick selection of files from the Project by typing a fragment (*) * Find Symbol for quick Goto-Definition for symbols in the current Python file by typing a fragment (*) * Show gi_running and gi_frame in Stack Data for generators * Sort menus and lists using more natural sorting so x2.py comes before x10.py * Preference to strip trailing white space on save * Scan for straightforward sys.path changes in main debug file * How-To and improvements for using Wing IDE with Google App Engine * Many bug fixes not in Wing 3.0.x (*)'d items are available in Wing IDE Personal or Professional only. (**)'d items are available in Wing IDE Professional only. *About Wing IDE* Wing IDE is an integrated development environment for the Python programming language. It provides powerful debugging, editing, code intelligence, testing, and search capabilities that reduce development and debugging time, cut down on coding errors, and make it easier to understand and navigate Python code. Wing IDE is available in three product levels: Wing IDE Professional is the full-featured Python IDE, Wing IDE Personal offers a reduced feature set at a low price, and Wing IDE 101 is a free scaled back version designed for teaching entry level programming courses with Python. System requirements are Windows 2000 or later, OS X 10.3.9 or later for PPC or Intel (requires X11 Server), or a recent Linux system (either 32 or 64 bit). *Purchasing & Upgrading* Wing IDE Professional & Wing IDE Personal are commercial software and require a license to run. Wing 3.1 is a free upgrade for all Wing IDE 3.0 users. Any 2.x license sold after May 2nd 2006 is free to upgrade; others cost 1/2 the normal price to upgrade. To upgrade a 2.x license or purchase a new 3.x license: Upgrade https://wingware.com/store/upgrade Purchase https://wingware.com/store/purchase -- The Wingware Team Wingware | Python IDE Advancing Software Development www.wingware.com From hank.infotec at gmail.com Sun Apr 20 04:40:26 2008 From: hank.infotec at gmail.com (Hank @ITGroup) Date: Sun, 20 Apr 2008 18:40:26 +1000 Subject: ???Python Memory Management S***s??? Message-ID: <480B017A.7020801@gmail.com> Hi, people! Greetings~ These days I have been running a text processing program, written by python, of cause. In order to evaluate the memory operation, I used the codes below: """ > string1 = ['abcde']*999999 # this took up an obvious memory space... > del string1 # this freed the memory successfully !! """ For primary variants, the *del* thing works well. However, challenge the following codes, using class-instances... """ > from nltk import FreqDist # nltk stands for Natural Language Tool Kit (this is not an advertisement ~_~) > instance = FreqDist() > instanceList = [instance]*99999 > del instanceList # You can try: nothing is freed by this """ ??? How do you people control python to free the memory in python 2.5 or python 2.4 ??? Cheers!!! From carbanancizpo at gmail.com Fri Apr 18 16:58:45 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:58:45 -0700 (PDT) Subject: battlefield 2 patch 1.41 Message-ID: battlefield 2 patch 1.41 http://cracks.12w.net F R E E C R A C K S From b0bm00r3 at gmail.com Sun Apr 27 08:05:10 2008 From: b0bm00r3 at gmail.com (philly_bob) Date: Sun, 27 Apr 2008 05:05:10 -0700 (PDT) Subject: Random/anonymous class methods Message-ID: <801e1c38-ae54-443c-8d87-9745db7ef270@59g2000hsb.googlegroups.com> In the sample program below, I want to send a random method to a class instance. In other words, I don't know which method to send until run-time. How can I send ch, which is my random choice, to the myclass instance? Thanks, Bob= #### import random class myclass(object): def meth1(self): print 'meth1' def meth2(self): print 'meth2' c=myclass() meths=['meth1', 'meth2'] ch=random.choice(meths) c.ch() From ed at leafe.com Mon Apr 21 14:58:25 2008 From: ed at leafe.com (Ed Leafe) Date: Mon, 21 Apr 2008 13:58:25 -0500 Subject: Does Python 2.5.2's embedded SQLite support full text searching? In-Reply-To: References: <1208794249.15992.1249049327@webmail.messagingengine.com> Message-ID: <77ED9B94-7AC7-497F-9F5B-DA4ACBC39F29@leafe.com> On Apr 21, 2008, at 1:05 PM, Daniel Fetchinson wrote: > Sqlite itself is not distributed with python. Only a python db api > compliant wrapper is part of the python stdlib and as such it is > completely independent of the sqlite build. Don't most binary distributions include SQLite itself? I installed 2.5.2 on a new WinXP VM, and SQLite is working fine. -- Ed Leafe From mav at cuma.polymath-solutions.lan Wed Apr 2 22:16:47 2008 From: mav at cuma.polymath-solutions.lan (Maurizio Vitale) Date: Thu, 03 Apr 2008 02:16:47 GMT Subject: non-terminating regex match References: Message-ID: MRAB writes: > > I think the problem is with this bit: '(?:(?:::)?\w+)*'. The '::' is > optional and also in a repeated group, so if it tries to match, say, > 'abc' it can try and then backtrack all of these possibilities: abc, > ab c, a bc, a b c. The longer the string, the more possibilities to > try. Try this instead: > > r = re.compile ( > r'(?P(?:::)?(?:\w+::)*)?' > r'(?P\w+)' > r'(?:\((?P[^\)]*)\))?' > ) That was indeed the problem. Your version is ok w/ the minor difference that the named group includes the '::' at the end. This can be easily stripped off. Or maybe the regexp can be massaged further. Thanks a lot, Maurizio From grante at visi.com Tue Apr 1 22:46:12 2008 From: grante at visi.com (Grant Edwards) Date: Tue, 01 Apr 2008 21:46:12 -0500 Subject: manipulating hex values References: <47F26CC3.3060307@u4eatech.com> Message-ID: On 2008-04-01, Stephen Cattaneo wrote: >>> I am relatively new to socket programming. I am attempting to >>> use raw sockets to spoof my IP address. >> >> Don't bother to try... > > Is there a better solution to spoofing my IP. then using raw > sockets You'll have to define "spoofing my IP", but I suspect that what you're trying can't be done by using raw sockets. > (I'm working on a machine with multiple interfaces and need to > be able to some how specify which interface that traffic needs > to be sent/recieved to/from) That's what routing tables are for. If you want to send packets using a particular IP, then configure an interface so that it has that adrress, and then bind your socket to that address. > The source of my confusion is that I need to keep my bytes formated > correctly. I am using the below 'raw socket example' proof-of-concept > code as my example. OK. > (And yes, I have tried the proof-of-concept. It works > correctly. It is not my code.) I know. It's my code. :) I wrote Python's raw socket support code and the example code that is floating around the 'net. > dstAddr = "\x01\x02\x03\x04\x05\x06" > dstAddr1 = "0x010203040506" > dstAddr != dstAddr1 Right. > Follow up question: What is the best to store my bytes up > until sending the packets? That depends on what you want to do with them. Ultimately, they need to be strings when they're sent out the socket (in Python a "string" is really just an array of 8-bit bytes). The best way to store them is entirely dependent on how you want to manipulate them before they're sent. > Perhaps I should use lists of decimal numbers and then > before sending convert to hex. Again: you're not converting them to hex. You're converting them to a python "string" object which is really just an array of bytes. Stop saying "hex" when you're talking about a string (array of bytes). "hex" is a way to _represent_ a value textually. It's simply a format used when print a value on paper or a screen. The value itself isn't hex any more than a particular instance of Canis lupus familiaris is "English" because somebody spells it "dog" instead of "chien" or "Hund". > I.E. dstAddr = [ 1, 2, 3, 4, 5, 6] > dstAddr.prepareToSend() I presume you know that list objects don't have a method called prepareToSend(). > txFrame = struct.pack("!6s6sh",dstAddr,srcAddr,proto) + ethData > > Is there a better way to do this? It's not at all clear what "this" is. If you want to convert from a list (or any sequence, really) of integer objects to a string where each integer is converted into a single byte within the string, then here are a few ways: import operator import struct intlist = [1,2,3,4,5,6] s1 = ''.join(chr(b) for b in intlist) s2 = reduce(operator.add,[chr(b) for b in intlist]) s3 = struct.pack("6B",*tuple(intlist)) print repr(s1) print repr(s2) print repr(s3) print s1==s2 print s2==s3 When run you get this: '\x01\x02\x03\x04\x05\x06' '\x01\x02\x03\x04\x05\x06' '\x01\x02\x03\x04\x05\x06' True True I think the third alternative using struct.pack() is the most readable, but others will no doubt disagree. -- Grant Edwards grante Yow! I'm GLAD I at remembered to XEROX all visi.com my UNDERSHIRTS!! From enrique_1984_00 at hotmail.com Thu Apr 24 14:36:02 2008 From: enrique_1984_00 at hotmail.com (Enrique Alvarez) Date: Thu, 24 Apr 2008 14:36:02 -0400 Subject: question Message-ID: hi, I want to ask something about programming in python, I'm beginning, I download the souce code of an antispyware in python I m talking about nixory: http://nixory.sourceforge.net/ this is a antyspyware only for mozilla firefox and my question is: how could I implement more functions of this antispyware....well I want that the program could scan spywares in cookies of internet explorer too...... do have some idea of this??? how could I scan the dlls files in cookies IE......?in python? ?? what libraries do I must to use?? please help me friends........any suggest......... Thanks in advance _________________________________________________________________ Connect to the next generation of MSN Messenger? http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline -------------- next part -------------- An HTML attachment was scrubbed... URL: From mgreene at bdurham.com Fri Apr 25 07:09:22 2008 From: mgreene at bdurham.com (Malcolm Greene) Date: Fri, 25 Apr 2008 07:09:22 -0400 Subject: Can you recommend a book? In-Reply-To: <1209121653.26409.1249825743@webmail.messagingengine.com> References: <1209121653.26409.1249825743@webmail.messagingengine.com> Message-ID: <1209121762.26539.1249826113@webmail.messagingengine.com> My two favorites: - Core Python Programming by Chun - Learning Python by Lutz Malcolm From Lie.1296 at gmail.com Sun Apr 6 13:29:55 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 6 Apr 2008 10:29:55 -0700 (PDT) Subject: A funnily inconsistent behavior of int and float Message-ID: I've noticed some oddly inconsistent behavior with int and float: Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 >>> int('- 345') -345 works, but >>> float('- 345.083') Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for float(): - 345.083 The problem seems to be that float can't accept spaces between the sign and the number while int can. Possibly caused by some missing regex statement. Minor and harmless (most of the time), but should be made known. From gherron at islandtraining.com Sun Apr 13 11:18:53 2008 From: gherron at islandtraining.com (Gary Herron) Date: Sun, 13 Apr 2008 08:18:53 -0700 Subject: Call a classmethod on a variable class name In-Reply-To: References: Message-ID: <4802245D.9070700@islandtraining.com> Matthew Keene wrote: > I would like to be able to call a specific classmethod on a class name > that is going to be passed from another parameter. In other words, I > have a call that looks something like: > > x = Foo.bar() > > and I would like to generalise this so that I can make this call on any > particular class which provides the bar classmethod. > > I have implemented this using exec, like so: > > className = parameters.className > exec "x = " + className + ".bar()" > Yuck. No. Don't do that. As a general rule, anything you could build and put into an exec is a functionality that is exposed more directly by Python. > but this feels somewhat clumsy. (I do have the requisite exception > handling to cope with the supplied class not existing or not > implementing the bar method, by the way). > > Is there any more Pythonesque way of doing this ? I guess what I'm > probably looking for is something like the way I understand the send > function works in Ruby > First off, if possible, don't pass the class name, but instead pass the class itself: class SomeClass: def foo(): ... whatever... ... parameters.theClass = SomeClass ... parameters.theClass.bar() If you can't do that, then look up that class from the class name and make your call: class SomeClass: def foo(): ... whatever... ... parameters.className = 'SomeClass' ... theClass = globals()[parameters.className] parameters.theClass.bar() (Hint: It matters not whether foo is a classmethod, saticmathod or normal method.) Gary Herron From svensven at gmail.com Thu Apr 10 14:57:29 2008 From: svensven at gmail.com (svensven) Date: Thu, 10 Apr 2008 20:57:29 +0200 Subject: subprocess.Popen() output to logging.StreamHandler() In-Reply-To: <4a1e850d-064f-49b8-87c7-140f10fc88c3@z38g2000hsc.googlegroups.com> References: <4a1e850d-064f-49b8-87c7-140f10fc88c3@z38g2000hsc.googlegroups.com> Message-ID: <47FE6319.5030005@gmail.com> Thomas Dimson wrote: > On Apr 10, 8:11 am, "sven _" wrote: >> My goal is to have stdout and stderr written to a logging handler. >> This code does not work: >> >> # START >> import logging, subprocess >> ch = logging.StreamHandler() >> ch.setLevel(logging.DEBUG) >> subprocess.call(['ls', '-la'], 0, None, None, ch, ch) >> # END > > What is wrong with doing something like: > > import logging, subprocess > ch = logging.StreamHandler() > ch.setLevel(logging.DEBUG) > > s = subprocess.Popen( ['ls','-la'], stdout=subprocess.PIPE ) > while 1: > ch.info( s.stdout.readline() ) > if s.poll() == None: > break > > Perhaps not the most efficient or clean solution, but that is how I > usually do it (note: I didn't test the above code). Thanks, Thomas. That was actually far less messy than I had imagined. I got it to work -- almost work -- using this code: import logging, subprocess logger = logging.getLogger("simple_example") logger.setLevel(logging.DEBUG) ch = logging.StreamHandler() ch.setLevel(logging.DEBUG) formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") ch.setFormatter(formatter) logger.addHandler(ch) s = subprocess.Popen(["ping", "-c", "5", "127.0.0.1"], stdout=subprocess.PIPE, bufsize=1024) while s.poll() == None: logger.info( s.stdout.readline().strip() ) The problem is that the .poll() seems to be a bit too agressive, so the while loop will quit before the process actually finishes. In the ping example above, it will show the pings, but it will skip the summary at the end. The response by Vinay Sajip seems to work just fine, though. Sven From cliff at develix.com Wed Apr 16 15:05:14 2008 From: cliff at develix.com (Cliff Wells) Date: Wed, 16 Apr 2008 12:05:14 -0700 Subject: Default parameter for a method In-Reply-To: References: <806788d2-67b7-456b-bd1e-08c50cbf0f7b@8g2000hsu.googlegroups.com> Message-ID: <1208372714.1289.2.camel@portableevil.develix.com> On Wed, 2008-04-16 at 13:47 -0500, Larry Bates wrote: > s0suk3 at gmail.com wrote: > > I wanted to know if there's any way to create a method that takes a > > default parameter, and that parameter's default value is the return > > value of another method of the same class. For example: > > > > class A: > > def __init__(self): > > self.x = 1 > > > > def meth1(self): > > return self.x > > > > def meth2(self, arg=meth1()): > > # The default `arg' should would take the return value of > > meth1() > > print '"arg" is', arg > > > > This obviously doesn't work. I know I could do > > > > ... > > def meth2(self, arg=None): > > if arg is None: > > arg = self.meth1() > > > > but I'm looking for a more straightforward way. > > You can write this as: > > def meth2(self, arg=None): > arg = arg or self.meth1() > > IMHO - You can't get much more "straightforward" than that. What if arg is 0 an empty list or anything else that's "False"? def meth2(self, arg=None): arg = (arg is not None) or self.meth1() is what you want. Regards, Cliff From bronger at physik.rwth-aachen.de Wed Apr 23 16:52:44 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 23 Apr 2008 22:52:44 +0200 Subject: Python development tools References: <09992de9-39fa-4ee6-8009-35732f3433fb@y21g2000hsf.googlegroups.com> Message-ID: <87fxtcnvj7.fsf@physik.rwth-aachen.de> Hall?chen! bruno.desthuilliers at gmail.com writes: > On 23 avr, 19:39, "wongjoek... at yahoo.com" > wrote: > >> Are there any completely free developent tools for python scripts >> like IDLE. I have used IDLE , but I want to try out others >> also. I saw stuff like PyCrust, but I don't see that it can run >> the script as well. > > emacs + python-mode (the one from Python, not the horror that > ships with recent emacs versions) What's so bad about it? I just installed python-mode (is this the one with the "py-" prefixes?), and it ends multi-line strings at single quotes. That's bad. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From gagsl-py2 at yahoo.com.ar Thu Apr 3 09:14:47 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 10:14:47 -0300 Subject: non-terminating regex match References: Message-ID: En Wed, 02 Apr 2008 13:01:59 -0300, Maurizio Vitale escribi?: > The intention is to match C++ identifiers, with or without namespace > qualification, with or without arguments (e.g. variables, functions and > macros). > The following should be accepted: > main > main(int,char**) > ::main > std::cout > ::std::cout > NDEBUG What about foo(int(*f)(int)) ? You can't match a function definition with a regular expression alone, due to the nested (). The r.e. can recognize an identifier; you can later see whether there is a ( and scan up to the matching ). -- Gabriel Genellina From nospam at nospam.blah Wed Apr 30 20:33:59 2008 From: nospam at nospam.blah (JYA) Date: Thu, 1 May 2008 10:33:59 +1000 Subject: best way to host a membership site References: <53034dcc-7346-4f71-889c-3278c9e813ec@w1g2000prd.googlegroups.com> Message-ID: <48190ff7$0$19248$426a34cc@news.free.fr> Hi On 2008-04-30 10:11:46 +1000, Magdoll said: > is the best thing to use. A friend recommended Ruby on Rails - not to > instigate war here, but I'd welcome comments on that (I don't know You should have a look at Pylons then. It is similar in essence to Ruby on Rails, but using Pythons. http://pylonshq.com/ -- They who would give up an essential liberty for temporary security, deserve neither liberty or security (Benjamin Franklin) From george.sakkis at gmail.com Tue Apr 29 20:03:16 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 29 Apr 2008 17:03:16 -0700 (PDT) Subject: Code/test ratio wrt static vs dynamic typing [was: Re: Python Success stories] References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <57d73312-37b1-4c53-9669-803e84a6901f@p25g2000hsf.googlegroups.com> Message-ID: On Apr 29, 2:25?pm, Fuzzyman wrote: > There are around 30 000 lines of Python in the production code and > about 120 000 lines of Python code in the test framework. A rather off-topic and perhaps naive question, but isn't a 1:4 production/test ratio a bit too much ? Is there a guesstimate of what percentage of this test code tests for things that you would get for free in a statically typed language ? I'm just curious whether this argument against dynamic typing - that you end up doing the job of a static compiler in test code - holds in practice. George From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 24 07:43:25 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 24 Apr 2008 13:43:25 +0200 Subject: function that accepts any amount of arguments? In-Reply-To: References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> Message-ID: <4810724a$0$23390$426a74cc@news.free.fr> Paul McNett a ?crit : > > def avg(*args): > return sum(args) / len(args) > > There are some dangers (at least two glaring ones) with this code, > though, which I leave as an exercise for the reader. try: avg("toto", 42) except TypeError, e: print "this is the first one : %s" % e try: avg() except ZeroDivisionError, e: print "this is the second : %s" % e As far as I'm concerned, I would not handle the first one in the avg function - just document that avg expects numeric args. Not quite sure what's the best thing to do in the second case - raise a ValueError if args is empty, or silently return 0.0 - but I'd tend to choose the first solution (Python's Zen, verses 9-11). From skanemupp at yahoo.se Wed Apr 16 12:35:17 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Wed, 16 Apr 2008 09:35:17 -0700 (PDT) Subject: Profiling very small/quick functions, help!? Message-ID: <1ed0cde8-d04c-444b-9b47-9bea16ae409d@f63g2000hsf.googlegroups.com> i use this code to profile. however for small standard functions it just says 0 seconds. so one solution is to run the function a very big number of times(how big?). but the bottom code doesnt work, it just runs the same profiling 10000 times insetad of running the fucntion 10K times and evaluate the time of all thsoe 10K times. ao how to solve this? if __name__=="__main__": try: from cProfile import run except: from profile import run run("tests()") if __name__=="__main__": try: from cProfile import run except: from profile import run for x in range(1, 10000): run("power(10,10)") From arnodel at googlemail.com Sun Apr 27 08:11:27 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 27 Apr 2008 13:11:27 +0100 Subject: Random/anonymous class methods References: <801e1c38-ae54-443c-8d87-9745db7ef270@59g2000hsb.googlegroups.com> Message-ID: philly_bob writes: > In the sample program below, I want to send a random method to a class > instance. > In other words, I don't know which method to send until run-time. How > can I send ch, which is my random choice, to the myclass instance? > > Thanks, > > Bob= > > #### > import random > > class myclass(object): > def meth1(self): > print 'meth1' > def meth2(self): > print 'meth2' > > c=myclass() > meths=['meth1', 'meth2'] > ch=random.choice(meths) > c.ch() This will work: getattr(c, ch)() Getattr(c, "meth1") is equivalent to c.meth1. Or you could do: meths = [c.meth1, c.meth2] ch = random.choice(meths) ch() -- Arnaud From sjmachin at lexicon.net Wed Apr 9 19:07:54 2008 From: sjmachin at lexicon.net (John Machin) Date: Wed, 9 Apr 2008 16:07:54 -0700 (PDT) Subject: How can I use quotes without escaping them using CSV? References: Message-ID: On Apr 10, 7:39 am, "Reedick, Andrew" wrote: > > -----Original Message----- > > From: python-list-bounces+jr9445=att.... at python.org [mailto:python- > > list-bounces+jr9445=att.... at python.org] On Behalf Of jeffself > > Sent: Wednesday, April 09, 2008 5:11 PM > > To: python-l... at python.org > > Subject: How can I use quotes without escaping them using CSV? > > > If I put an escape character in, it works. For example, if I use ~ as > > my escape character, my output looks like this: > > 0001[tab]Michael L. ~"Mick~" Jones[tab]189 > > > I don't want that. If I don't include an escape character, it doesn't > > work. which means an exception is raised: _csv.Error: need to escape, but no escapechar set > > > Here's my code: [snip] > > writer = csv.writer(f, delimiter='\t', quoting=csv.QUOTE_NONE) [snip] > > The documentation is pretty, uhm, obtuse, but you also need to set > quotechar. Uhm, "obtuse" applies to angles and people :-) I could agree with "obscure". > > import sys > import csv > > names = ['Michael L. "Mick" Jones', 'Vickie A. Meyers', 'John "Jack" > Smith'] > > writer = csv.writer(sys.stdout, delimiter='\t', quotechar='', > quoting=csv.QUOTE_NONE) > for i in names: > writer.writerow(['a', i, 'b']) > > output: > a Michael L. "Mick" Jones b > a Vickie A. Meyers b > a John "Jack" Smith b > > ***** > Here's my call: (1) Code bug: when quoting is set to QUOTE_NONE, it should ignore the setting of quotechar -- it's irrelevant. (2) Documentation bug: """ quotechar A one-character string .... """ but the code allows setting quotechar to '' and to None. Both work around the OP's problem; whether they have identical effect in other situations, I haven't explored. Cheers, John From medin0065 at gmail.com Sun Apr 20 10:48:25 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:48:25 -0700 (PDT) Subject: vuescan 8.4.13 crack Message-ID: <5e53bfe9-b192-439a-ae8e-ae4b49c05dd7@w1g2000prd.googlegroups.com> vuescan 8.4.13 crack http://cracks.00bp.com F R E E C R A C K S From nick at stinemates.org Fri Apr 18 15:01:02 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 12:01:02 -0700 Subject: program to Ping ip addresses In-Reply-To: <192124.99122.qm@web58602.mail.re3.yahoo.com> References: <192124.99122.qm@web58602.mail.re3.yahoo.com> Message-ID: <20080418190102.GG19281@deviL> On Tue, Apr 15, 2008 at 07:24:05AM -0700, shawn s wrote: > Hi > > I am trying to modify a small program i found off the internet as follows... I can get the 'tracert' to work and it gives me all the info back. However, when i replace the tracert with 'ping', the commamd prompt shows 'testing' and the script freezes... any suggestions as why it is doing that. > > import os > import sys > xyz = 1 > > while xyz==1: > ip = raw_input("command >> ") > zx = open("log.txt", "a") > > if ip.lower()=="exit": > ask = raw_input("Are you sure you want to exit? (Y\\N) ") > > if ask.lower()=="y": > sys.exit() > elif ask.lower()=="n": > print("That's what I thought.") > else: > print("Wrong choice. Retard.") > > elif ip.lower()=="range": > stin = raw_input("Enter function: ") > sec = raw_input("Enter the first 3 sections: ") > b = raw_input("Enter beginning number: ") > intb=int(b) > e = int(raw_input("Enter ending number: ")) > > while intb<=e: > print (stin + ' ' + sec + '.' + b ) > z = os.system(stin + ' ' + sec + '.' + b ) > print z > > if z==0: > print(""+str(sec)+"."+str(b)+" is online.") > zx.write(""+str(sec)+"."+str(b)+" is online.\n") > elif z==1: > print("Either "+str(sec)+"."+str(b)+" is offline, or ping request has been blocked.") > zx.write("Either "+str(sec)+"."+str(b)+" is offline, or ping request has been blocked.\n") > > intb = intb + 1 > b=str(intb) > > else: > > print("Wrong choice. Retard.") > I love that you call the users of your app retards :) That rocks! ping runs forever. tracert doesnt. try: > ping -w 5 -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From fennelllindy8241 at gmail.com Mon Apr 28 03:25:39 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:25:39 -0700 (PDT) Subject: imtoo crack Message-ID: imtoo crack http://crack.cracksofts.com From weiss02121 at gmail.com Tue Apr 15 19:48:13 2008 From: weiss02121 at gmail.com (weiss02121 at gmail.com) Date: Tue, 15 Apr 2008 16:48:13 -0700 (PDT) Subject: lindsay lohan cocaine video Message-ID: <5c35bdd9-9e8c-4e03-842a-84272676b459@n14g2000pri.googlegroups.com> Just few link on some Lindsay Lohan Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From toolmaster at 163.com Thu Apr 3 04:45:00 2008 From: toolmaster at 163.com (WaterWalk) Date: Thu, 3 Apr 2008 01:45:00 -0700 (PDT) Subject: unicode in exception traceback Message-ID: Hello. I just found on Windows when an exception is raised and traceback info is printed on STDERR, all the characters printed are just plain ASCII. Take the unicode character u'\u4e00' for example. If I write: print u'\u4e00' If the system locale is "PRC China", then this statement will print this character as a single Chinese character. But if i write: assert u'\u4e00' == 1 An AssertionError will be raised and traceback info will be put to STDERR, while this time, u'\u4e00' will simply be printed just as u'\u4e00', several ASCII characters instead of one single Chinese character. I use the coding directive commen(# -*- coding: utf-8 -*-)t on the first line of Python source file and also save it in utf-8 format, but the problem remains. What's worse, if i directly write Chinese characters in a unicode string, when the traceback info is printed, they'll appear in a non- readable way, that is, they show themselves as something else. It's like printing something DBCS characters when the locale is incorrect. I think this problem isn't unique. When using some other East-Asia characters, the same problem may recur. Is there any workaround to it? From mmanns at gmx.net Sat Apr 26 23:21:56 2008 From: mmanns at gmx.net (Martin Manns) Date: Sun, 27 Apr 2008 05:21:56 +0200 Subject: ANN: pyspread 0.0.4 Message-ID: Hi, The newest version pyspread 0.0.4 now runs on + GTK + Windows + Mac (not tested myself but got positive reports) New features in 0.0.4: + Column, line and table insertion and deletion + Themeable toolbar Feedback is very welcome! Best Regards Martin From matthewcroberts at gmail.com Sat Apr 12 21:48:52 2008 From: matthewcroberts at gmail.com (Matt) Date: Sat, 12 Apr 2008 18:48:52 -0700 (PDT) Subject: Advice on tools/technologies/books, etc. Message-ID: I would like to create a web-based tool for risk management. The tool actually currently exists, but it was programmed in about 1998 using old VB, etc, and we are updating it & moving it to the web. Basically, as a first step, i'd like to create a basic web site that takes user input, gets data from MySQL (i might pickle it, not yet sure) and then runs some numpy routines & outputs the results. This will give us a platform to develop the backend. My intermediate goal is to have an asynchronous site in which as users adjust settings, the computations are run & graphs updated. (the computations are pretty simple, btw). My fantasy goal would be to combine that w/ google gears so the users could use it online or offline, but that's probably just fantasy. So, here are my constraints: I know Python & HTML (and lots of other non-germane languages) but I don't know any javascript or ruby or XML. What is the lowest cost path from here to there? I have been totally out of the loop for this whole web 2.0 thing (I'm an economics professor). Will it be possible for me to put together an async site with only python? (I hesitate to use the term AJAX, b/c its unclear to me how generic it is--do all async sites use javascript? can someone clarify this?) If so, does it make sense to go ahead and start trying to learn Turbogears or Pylons? Will they be able to create async sites? Is there an easier way to do it? (Easy defined as me not having to learn a 7th programming language) I have looked at Spyce, and that seems an easy way to do the basic (step 1) site, but its not at all clear that I can do async with it. CherryPy looks like it has a steeper learning curve, but it also appears that the route to async is clearer. I know where I want to go, and I know what I can do now. I don't mind getting deeper into Python, but I'd love not to have to learn a bunch of other languages if I can avoid it. Any thoughts/comments? TIA, Matt. From ed at leafe.com Tue Apr 1 14:12:17 2008 From: ed at leafe.com (Ed Leafe) Date: Tue, 1 Apr 2008 13:12:17 -0500 Subject: class super method In-Reply-To: <42479e00-c73d-436f-ae1a-bbc24365ccd3@e23g2000prf.googlegroups.com> References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> <42479e00-c73d-436f-ae1a-bbc24365ccd3@e23g2000prf.googlegroups.com> Message-ID: <3D421F14-BB9C-4321-AD31-C416EC220A5C@leafe.com> On Apr 1, 2008, at 12:53 PM, Michele Simionato wrote: > It is just that you did not run (yet) in a corner case of super. The > interesting question would be: did any of your users run into issues > using you library which is heavily relying on super? Especially when > composing it with their own classes? None so far, and our users are pretty good about reporting bugs! > I personally have changed my opinion about multiple inheritance over > the years. > At the beginning I thought it was a very cool idea, but now I think it > is a pretty bad idea. If I were to design a language, I would not > implement multiple inheritance. In Python I never use multiple > inheritance and actually I try very hard to avoid even single > inheritance, preferring composition whenever it is viable. I think MI is great as long as you understand how to use it. I would never encourage anyone to mix dissimilar classes; that's just poor design. But a well-designed mixin class is a wonderful thing. I also don't consider inheritance and composition to be either/or choices. Both can (and usually should) be part of a well-designed application. In my experience, using either incorrectly can get you in trouble. -- Ed Leafe From python at bdurham.com Mon Apr 21 17:05:20 2008 From: python at bdurham.com (python at bdurham.com) Date: Mon, 21 Apr 2008 17:05:20 -0400 Subject: List of all Python's ____ ? In-Reply-To: <87wsmrdka8.fsf@mulj.homelinux.net> References: <87wsmrdka8.fsf@mulj.homelinux.net> Message-ID: <1208811920.4195.1249106841@webmail.messagingengine.com> Hrvoje, >> Is there an official list of all Python's ____? > http://docs.python.org/ref/specialnames.html Wonderful!! Thank you very much. Regards, Malcolm From gagsl-py2 at yahoo.com.ar Thu Apr 10 05:09:22 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 06:09:22 -0300 Subject: How to find documentation about methods etc. for iterators References: <47fce941$0$755$bed64819@news.gradwell.net> <47fdceb8$0$754$bed64819@news.gradwell.net> Message-ID: En Thu, 10 Apr 2008 05:24:24 -0300, escribi?: > Terry Reedy wrote: >> >> wrote in message >> news:47fce941$0$755$bed64819 at news.gradwell.net... >> | I'm not sure if I have even phrased that right but anyway.... >> | >> | How does one find (in the standard Python documentation) information >> | about things like the iteritems() method and the enumerate() function. >> >> The Library Reference manual sections on builtin functions and dict >> methods. >> >> Or, help(enumerate) and help({}.iteritems) >> > .... but that doesn't address my problem really, how do I know that I > need to look for the words enumerate and/or iteritems? This is what > my original question was about. You'll have to read at least section 2 (built-in objects) and section 3 (built-in types) in the Library Reference: http://docs.python.org/lib/ That's the most important part to know. > There I was thinking that there has to be an easy way to get line > numbers as I read lines from a file but not knowing how to find out > how to do it:- > > First question, what sort of 'thing' is the file object, I need to > know that if I'm to look up ways of using it. > > Second question, even if I know what sort of thing a file object > is, how do I find methods applicable to it and/or functions > applicable to it? You look for 'file object' in the index and find http://docs.python.org/lib/bltin-file-objects.html > The possibility that I might want either a method or a function adds > to the fun. In my original query it seemed odd that some objects have > the iteritems *method* whereas other objects have the enumerate > *function*. Other objects don't "have" the enumerate function, enumerate is a builtin function that can be used with any sequence or iterable object. Your know it because you have read section 2.1 in the Library Reference as I've told you a few lines above :) > It's a common problem in all sorts of computer fields, if you know the > name of what you want it's easy to find out details of how to use it > but if you don't know its name (or even if it exists) it's much more > difficult to find. Yes, certainly. Python comes with "batteries included" and there are many of them. You don't have to read the whole Library Reference from begin to end, but at least have a look at the titles so you know that certain thing exists. > I've only been using Python for a few months and most of the time I > can find my way to what I need but this area of "what things can I do > with this object" still eludes me sometimes. What *I* need (I'm not > sure if this is a universal requirement though) is some consistent way > of firstly finding out what sort of an object something is (i.e. in > this case, what sort of object is a file) and then getting a list of > methods that I can apply to that object (O.K., this may need some > hierachy or other classification to keep it sane, but hopefully you > can see where I'm going). A file is... a file: py> f = open("temp.txt","r") py> type(f) You can invoke the help system with any object: py> help(f) Help on file object: class file(object) | file(name[, mode[, buffering]]) -> file object | | Open a file. The mode can be 'r', 'w' or 'a' for reading (default), | writing or appending. The file will be created if it doesn't exist | when opened for writing or appending; [blah...] [... including all methods defined in the file class ...] You can use help with a particular methods or function too: py> help(f.write) Help on built-in function write: write(...) write(str) -> None. Write string str to file. Note that due to buffering, [blah...] You can use dir(something) to see which attributes (including methods) an object has: py> dir(f) ['__class__', '__delattr__', '__doc__', ... 'close', 'closed', 'encoding', ... 'write', 'writelines', 'xreadlines'] Hope this helps. -- Gabriel Genellina From sjoerd at acm.org Mon Apr 21 03:49:26 2008 From: sjoerd at acm.org (Sjoerd Mullender) Date: Mon, 21 Apr 2008 09:49:26 +0200 Subject: Is massive spam coming from me on python lists? In-Reply-To: <87r6cz3cn7.fsf@physik.rwth-aachen.de> References: <480C2DC6.4050701@aim.com> <87r6cz3cn7.fsf@physik.rwth-aachen.de> Message-ID: <480C4706.9040207@acm.org> Torsten Bronger wrote: > Hall?chen! > > Sjoerd Mullender writes: > >> On 2008-04-21 08:01, Brian Vanderburg II wrote: >> >>> I've recently gotten more than too many spam messages and all say >>> Sender: python-list-bounces+my=email.address at python.org. [...] >> That is just mailman (the mailing list software) keeping track of >> things. > > By the way, why does mailman change the Message-IDs when tunneling > postings to the newsgroup? This destroys the thread structure. I have no idea. There is no setting in the mailman administration interface that I can see that influences this. Perhaps submit this as a bugreport to mailman? -- Sjoerd Mullender -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 379 bytes Desc: OpenPGP digital signature URL: From pydecker at gmail.com Thu Apr 10 12:56:05 2008 From: pydecker at gmail.com (Peter Decker) Date: Thu, 10 Apr 2008 11:56:05 -0500 Subject: How is GUI programming in Python? In-Reply-To: References: Message-ID: On Wed, Apr 9, 2008 at 8:54 PM, Chris Stewart wrote: > I've always had an interest in Python and would like to dabble in it > further. I've worked on a few very small command line programs but > nothing of any complexity. I'd like to build a really simple GUI app > that will work across Mac, Windows, and Linux. How painful is that > going to be? I used to be really familiar with Java Swing a few years > ago. I imagine it will be similar. > > Next, what would you say is the best framework I should look into? > I'm curious to hear opinions on that. I've found wxPython to be the best all-around choice: it looks right on Mac, Win and Gtk/Linux, as it uses native controls. The one downside is that its C++ roots show, and make for somewhat ugly and unPythonic code. I've been using the Dabo framework (http://dabodev.com) for over a year now, and it's great. They use wxPython for the UI, but wrap it in a consistent and intelligent layer that makes development much simpler and straightforward. -- # p.d. From gherron at islandtraining.com Tue Apr 15 13:44:19 2008 From: gherron at islandtraining.com (Gary Herron) Date: Tue, 15 Apr 2008 10:44:19 -0700 Subject: Preferred method for "Assignment by value" In-Reply-To: References: Message-ID: <4804E973.7030009@islandtraining.com> hall.jeff at gmail.com wrote: > As a relative new comer to Python, I haven't done a heck of a lot of > hacking around with it. I had my first run in with Python's quirky (to > me at least) tendency to assign by reference rather than by value (I'm > coming from a VBA world so that's the terminology I'm using). I was > surprised that these two cases behave so differently > > test = [[1],[2]] > x = test[0] > x[0] = 5 > test > >>>> [[5],[2]] >>>> > x = 1 > test > >>>> [[5],[2]] >>>> > x > >>>> 1 >>>> > > Now I've done a little reading and I think I understand the problem... > My issue is, "What's the 'best practise' way of assigning just the > value of something to a new name?" > > i.e. > test = [[1,2],[3,4]] > I need to do some data manipulation with the first list in the above > list without changing > obviously x = test[0] will not work as any changes i make will alter > the original... > I found that I could do this: > x = [] + test[0] > > that gets me a "pure" (i.e. unconnected to test[0] ) list but that > concerned me as a bit kludgy > > Thanks for you time and help. > If you want a *copy* of an object (or portion thereof), you must explicitly *specify* a copy. THere are different ways of doing that depending on the object in question. Lists (and slices thereof) can be copied to a new list withthe slice syntax: L[1:4] will copy a limited portion, and L[:] will copy the whole list. The kind of copy is only one level deep -- the contents of the copy will be references to the contents of L Dictionaries have a copy method that creates a new dictionary. Again this copy is only one level deep. The copy modules provides a more general way to copy objects. It provides the ability to produce both shallow and deep copies. A small note: In a dozen years of programming in Python, I've used these various copy methods perhaps a dozen times or less. If you find you are copying structures often, you are probably not using Python as effectively as you could. Gary Herron From svensven at gmail.com Thu Apr 10 08:11:55 2008 From: svensven at gmail.com (sven _) Date: Thu, 10 Apr 2008 14:11:55 +0200 Subject: subprocess.Popen() output to logging.StreamHandler() Message-ID: <3a4166890804100511q6fc9a5e0qb636eeb5b3e949e3@mail.gmail.com> Version: Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) My goal is to have stdout and stderr written to a logging handler. This code does not work: # START import logging, subprocess ch = logging.StreamHandler() ch.setLevel(logging.DEBUG) subprocess.call(['ls', '-la'], 0, None, None, ch, ch) # END Traceback (most recent call last): File "log.py", line 5, in subprocess.call(['ls', '-la'], 0, None, None, ch, ch) File "/usr/lib/python2.5/subprocess.py", line 443, in call return Popen(*popenargs, **kwargs).wait() File "/usr/lib/python2.5/subprocess.py", line 586, in __init__ errread, errwrite) = self._get_handles(stdin, stdout, stderr) File "/usr/lib/python2.5/subprocess.py", line 941, in _get_handles c2pwrite = stdout.fileno() AttributeError: StreamHandler instance has no attribute 'fileno' This is because subprocess.Popen() expects file descriptors to write to, and logging.StreamHandler() does not supply it. The StreamHandler could supply its own stdout file descriptor, but then Popen() would write directly to that file, bypassing all the logging fluff. A possible solution would be to make a named pipe (os.mkfifo()), have Popen() write to that, and then have some horrendous hack run select() or similar on the fifo to read from it and finally pass it to StreamHandler. Are there better solutions? sven From torriem at gmail.com Sun Apr 6 11:52:32 2008 From: torriem at gmail.com (Michael Torrie) Date: Sun, 06 Apr 2008 09:52:32 -0600 Subject: appropriate python version In-Reply-To: <0790632f-db07-45ef-9bcd-7e1b592d33be@u69g2000hse.googlegroups.com> References: <0790632f-db07-45ef-9bcd-7e1b592d33be@u69g2000hse.googlegroups.com> Message-ID: <47F8F1C0.40203@gmail.com> xamdam wrote: > Sorry if this is a stupid q, > I am trying to figure out the appropriate version of Python(2.4 or > 2.5) for an XP 64 system running on an Intel Core2 Quad. Python.org > has a to a 64bit build, but it specifies Itanium as the target. Should > I just be using the regular build? Itanium is a different processor and architecture. It simply won't run on your Core2 Quad. You need an x86-64bit build. > I was also thinking of getting the Enthought edition (http:// > code.enthought.com/enthon/) - would their binary work with the setup, > and what would be the downside of using it over the special 64bit > build? Seeing as the special 64bit build appears to be for itanium (from what you say here), I'd say the question is moot! From hobgoodoreneyhb at gmail.com Tue Apr 22 11:41:38 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:41:38 -0700 (PDT) Subject: diablo 2 lod patch Message-ID: <881d8be9-f26d-4681-8eaf-6a773e038243@t63g2000hsf.googlegroups.com> diablo 2 lod patch http://cracks.12w.net F R E E C R A C K S From goldspin at gmail.com Tue Apr 8 11:23:46 2008 From: goldspin at gmail.com (Henry Chang) Date: Tue, 8 Apr 2008 08:23:46 -0700 Subject: Google App Engine In-Reply-To: References: Message-ID: This is very interesting. Thanks for sharing! On Tue, Apr 8, 2008 at 1:55 AM, Duncan Booth wrote: > Google have announced a new service called 'Google App Engine' which may > be of interest to some of the people here (although if you want to sign > up you'll have to join the queue behind me): > > >From the introduction: > > > What Is Google App Engine? > > > > Google App Engine lets you run your web applications on Google's > > infrastructure. App Engine applications are easy to build, easy to > > maintain, and easy to scale as your traffic and data storage needs > > grow. With App Engine, there are no servers to maintain: You just > > upload your application, and it's ready to serve your users. > > > > You can serve your app using a free domain name on the appspot.com > > domain, or use Google Apps to serve it from your own domain. You can > > share your application with the world, or limit access to members of > > your organization. > > > > App Engine costs nothing to get started. Sign up for a free account, > > and you can develop and publish your application for the world to see, > > at no charge and with no obligation. A free account can use up to > > 500MB of persistent storage and enough CPU and bandwidth for about 5 > > million page views a month. > > > > During the preview release of Google App Engine, only free accounts > > are available. In the near future, you will be able to purchase > > additional computing resources. The Application Environment > > > > Google App Engine makes it easy to build an application that runs > > reliably, even under heavy load and with large amounts of data. The > > environment includes the following features: > > > > * dynamic web serving, with full support for common web > > technologies > > * persistent storage with queries, sorting and transactions > > * automatic scaling and load balancing > > * APIs for authenticating users and sending email using Google > > Accounts > > * a fully featured local development environment that > > simulates Google App Engine on your computer > > > > Google App Engine applications are implemented using the Python > > programming language. The runtime environment includes the full Python > > language and most of the Python standard library. > > > > Although Python is currently the only language supported by Google App > > Engine, we look forward to supporting more languages in the future. > > http://code.google.com/appengine > > > -- > http://mail.python.org/mailman/listinfo/python-list > From siona at chiark.greenend.org.uk Thu Apr 17 13:07:21 2008 From: siona at chiark.greenend.org.uk (Sion Arrowsmith) Date: 17 Apr 2008 18:07:21 +0100 (BST) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> Message-ID: wrote: >In Python, you usually can use parentheses to split something over >several lines. But you can't use parentheses for an assignment of >several lines. Yes you can, you just need an iterable of the right length on the other side for the tuple unpacking to work: >>> (CONSTANT1, ... # This isn't a syntax error ... CONSTANT2, ... CONSTANT3, #and neither is this ... CONSTANT) = [1] * 4 >>> [ (k, v) for k, v in locals().items() if k.startswith("CONSTANT") ] [('CONSTANT', 1), ('CONSTANT1', 1), ('CONSTANT3', 1), ('CONSTANT2', 1)] >>> -- \S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/ "Frankly I have no feelings towards penguins one way or the other" -- Arthur C. Clarke her nu become? se bera eadward ofdun hl?ddre heafdes b?ce bump bump bump From mail at timgolden.me.uk Thu Apr 3 03:56:31 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 03 Apr 2008 08:56:31 +0100 Subject: Python for low-level Windows programming In-Reply-To: References: Message-ID: <47F48DAF.9070707@timgolden.me.uk> haxier wrote: > I've some experience with Python in desktop apps, but now I'm looking > to code a tool like Kee-Pass[1] which must have access to some low- > level primitives in a windows environment: hooks when windows are > displayed, automatic form fill, and so on in a variety of scenarios > (desktop apps, web-based apps, citrix...) > > Is this possible without too much pain? I know I can code it with C# > or C++ but tha'ts a road to avoid, if possible. Well of course I don't know exactly what you'd need, but the answer's certainly Yes :) In short, even native Python comes with the ctypes module which will let you call -- with only a little working out the structures -- into any Windows DLL or COM interface (the latter via the comtypes extension). But in any case the pywin32 packages and various other open source projects have already done a lot of the work for you. Plus it's easy enough to write your own extension which does the dirty work in C and exposes it to Python as functions, objects or whatever suits your purposes. Good luck! TJG From wwzaygvm at gmail.com Wed Apr 16 16:53:48 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 13:53:48 -0700 (PDT) Subject: audio mid recorder 3.95 and crack Message-ID: <0260377e-672e-432f-9471-9a3bc16541e3@b9g2000prh.googlegroups.com> audio mid recorder 3.95 and crack http://cracks.12w.net F R E E C R A C K S From supercooper at gmail.com Wed Apr 30 13:40:20 2008 From: supercooper at gmail.com (supercooper) Date: Wed, 30 Apr 2008 10:40:20 -0700 (PDT) Subject: PIL and IPTC References: <0001HW.C43E4BB60060D69EB01AD9AF@news.individual.de> Message-ID: <0054980b-e4c3-459f-a57a-a5b98b85dfd4@y38g2000hsy.googlegroups.com> On Apr 30, 9:15 am, Jumping Arne wrote: > I'm completely new to PIL and I'm trying to read IPTC info, I understand that > it's possible but I can't find out how (and for once Google doesn't seem to > be able to help). Does anyone have an example of how it's done? I use the IPTCInfo module with great success. Its very easy to work with to read/write IPTC metadata: http://pypi.python.org/pypi/IPTCInfo/1.9.2-rc5 HTH From ott.deb at gmail.com Thu Apr 17 15:05:47 2008 From: ott.deb at gmail.com (ott.deb at gmail.com) Date: Thu, 17 Apr 2008 12:05:47 -0700 (PDT) Subject: digital rights management crack Message-ID: digital rights management crack http://cracks.12w.net F R E E C R A C K S From bdsatish at gmail.com Fri Apr 11 08:45:58 2008 From: bdsatish at gmail.com (bdsatish) Date: Fri, 11 Apr 2008 05:45:58 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: <31872ffc-5bc4-44c8-961d-ee4f0dc356c5@k1g2000prb.googlegroups.com> On Apr 11, 5:33 pm, bdsatish wrote: > HI Gerard, > > I think you've taken it to the best possible implementation. Thanks ! > On Apr 11, 5:14 pm, Gerard Flanagan wrote: > > > In fact you can avoid the call to the builtin round: > > > ------------------------------------------------ > > > assert myround(3.2) == 3 > > assert myround(3.6) == 4 > > assert myround(3.5) == 4 > > assert myround(2.5) == 2 > > assert myround(-0.5) == 0.0 > > assert myround(-1.5) == -2.0 > > assert myround(-1.3) == -1.0 > > assert myround(-1.8) == -2 > > assert myround(-2.5) == -2.0 > > ------------------------------------------------ OK, I was too early to praise Gerard. The following version: def myround(x): n = int(x) if abs(x - n) >= 0.5 and n % 2: return n + 1 - 2 * int(n<0) else: return n of Gerard doesn't work for 0.6 (or 0.7, etc.) It gives the answer 0 but I would expect 1.0 ( because 0.6 doesn't end in 0.5 at all... so usual rules of round( ) apply) From speedman2010 at gmail.com Wed Apr 30 07:08:26 2008 From: speedman2010 at gmail.com (speedman2010) Date: Wed, 30 Apr 2008 04:08:26 -0700 (PDT) Subject: Essentio CS5110 the first produced desktop from asus Message-ID: <5053a61f-7971-4d8f-b725-f8ce93f87dc8@24g2000hsh.googlegroups.com> When I search web as every day I was surprised when I readied that ASUA company announced about it is new Essentio CS5110 desktop and I Saied " cool ASUS enter to the world of desktop manufactories " because ASUS produced good product and have a good Reputation On computer market and I waited for this step a long time To read more go to http://computerworld4y.blogspot.com/ From robert.spilleboudt.no.sp.am at skynet.be Thu Apr 10 15:52:19 2008 From: robert.spilleboudt.no.sp.am at skynet.be (Robert.Spilleboudt ) Date: Thu, 10 Apr 2008 21:52:19 +0200 Subject: Running a python code periodically In-Reply-To: References: Message-ID: <47fe6ff3$0$2956$ba620e4c@news.skynet.be> paul wrote: > Maryam Saeedi schrieb: >> Hi, >> >> I was wondering if you know how can I run a python code once every five >> minutes for a period of time either using python or some other program >> like >> a bash script. > > See the sched module in the standard library or here: > http://pypi.python.org/simple/Recur/ > > cheers > Paul > In a Python loop, use time.sleep(300) to wait 300 seconds. If you use Tkinter, there is another method to call periodically a function. Robert From breily at gmail.com Tue Apr 8 18:40:24 2008 From: breily at gmail.com (Brian) Date: Tue, 8 Apr 2008 18:40:24 -0400 Subject: Converting a tuple to a list In-Reply-To: References: <00ba01c899c5$14528ae0$0a01a8c0@mobile> Message-ID: On Tue, Apr 8, 2008 at 6:36 PM, Brian wrote: > > > On Tue, Apr 8, 2008 at 6:22 PM, Steve Holden wrote: > > > Gabriel Ibanez wrote: > > > Hi all .. > > > > > > I'm trying to using the map function to convert a tuple to a list, > > without > > > success. > > > > > > I would like to have a lonely line that performs the same as loop of > > the > > > next script: > > > > > > ------------------------------------------- > > > # Conveting tuple -> list > > > > > > tupla = ((1,2), (3,4), (5,6)) > > > > > > print tupla > > > > > > lista = [] > > > for a in tupla: > > > for b in a: > > > lista.append(b) > > > print lista > > > ------------------------------------------- > > > > > > Any idea ? > > > > > > Thanks ... > > > > > > # Gabriel > > > > > list(tupla) > > > > would probably do it. > > > > regards > > Steve > > -- > > Steve Holden +1 571 484 6266 +1 800 494 3119 > > Holden Web LLC http://www.holdenweb.com/ > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > > > That would just make a list of tuples, I think he wants [1, 2, 3, 4, 5, > 6]. > > Try: l = [x for z in t for x in z] Edit: Assuming t is tupla from your code. > > > --Brian > -------------- next part -------------- An HTML attachment was scrubbed... URL: From needin4mation at gmail.com Tue Apr 29 15:17:27 2008 From: needin4mation at gmail.com (jmDesktop) Date: Tue, 29 Apr 2008 12:17:27 -0700 (PDT) Subject: Simple import question about mac osx References: Message-ID: On Apr 29, 2:37?pm, "Jerry Hill" wrote: > On Tue, Apr 29, 2008 at 2:14 PM, jmDesktop wrote: > > ?Thanks. ?That worked on mac. ?But it does work like I said in > > ?Windows. ?Don't know why. ?Mr. Chun must also be using Windows because > > ?that is the way he does it in his book. > > It shouldn't work that way on windows either. ?Can you tell us a > little more about what you mean when you say you "compile this" under > windows? ?Normally, python code doesn't need to be compiled, so I'm > wondering if you're doing something different from what we expect when > you say you compile it and then import it in the interpreter. > > Are you by any chance writing code in IDLE, running it, then doing > things in the interpreter? > > ?-- > Jerry On Windows I took the text file I created on mac with vi and opened it in PythonWin. I ran it. It compiled. I run the import and call from the python interpreter. From bignose+hates-spam at benfinney.id.au Wed Apr 2 00:06:54 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Wed, 02 Apr 2008 15:06:54 +1100 Subject: ANN: pry unit testing framework References: Message-ID: <87zlscx5lt.fsf@benfinney.id.au> Aldo Cortesi writes: > We are happy to announce the first release of Pry, a unit testing > framework. Thanks for the announcement, and for the software. If Pry is already incompatible with xUnit (i.e. Python's 'unittest'), could we please have names that adhere to the Python style guide ? In particular the method names 'setUp', 'setUpAll', 'tearDown', 'tearDownAll' don't comply with the style guide. Compliant names for those methods would be 'set_up', 'set_up_all', etc. -- \ "Here is a test to see if your mission on earth is finished. If | `\ you are alive, it isn't." -- Francis Bacon | _o__) | Ben Finney From imliujie at gmail.com Wed Apr 23 02:48:00 2008 From: imliujie at gmail.com (Jack) Date: Wed, 23 Apr 2008 14:48:00 +0800 Subject: =?UTF-8?B?5pyJ5Lit5Zu95Lq65LmOPw==?= In-Reply-To: References: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> Message-ID: <480EDBA0.7070908@gmail.com> Jeroen Ruigrok van der Werven ??: > (My Mandarin is not very good.) > > -On [20080413 09:24], bikthh at live.cn (bikthh at live.cn) wrote: >> Python????????????????. > > Python indeed does have a good future. > I am not quite sure with ??????? if you are asking for someone to > teach to you or if you want to teach others. > ????????????C++ -------------- next part -------------- A non-text attachment was scrubbed... Name: jack_l_china.vcf Type: text/x-vcard Size: 124 bytes Desc: not available URL: From ajaksu at gmail.com Fri Apr 18 11:52:07 2008 From: ajaksu at gmail.com (ajaksu) Date: Fri, 18 Apr 2008 08:52:07 -0700 (PDT) Subject: What can we do about all the spam that the list is getting? References: <259ab201-9d2b-4e4e-88a7-e2fe277f0066@a23g2000hsc.googlegroups.com> Message-ID: <88eeaf57-fb34-49e5-a770-26ce5a0c63c9@k13g2000hse.googlegroups.com> On 16 abr, 14:01, sr... at ferg.org wrote: > What can we do about all the spam that comp.lang.python is getting? > Things are getting pretty bad. I'm reporting most spam, but I don't have high hopes Google cares. We could start a new group (non-usenet Google Groups allow message removal), but I guess most people would rather simply plonk GG posts. Perhaps we could find a way to tag spam threads that would auto-plonk those threads in our preferred reader (email, newsreader and Greasemonkey killfile)? This has the drawback that spam posted to ham threads would be hard to block... Regards, Daniel P.S.: I prefer posting from Google Groups, I'd rather avoid posting at all than having to use a different client... From nagle at animats.com Sat Apr 26 01:15:05 2008 From: nagle at animats.com (John Nagle) Date: Fri, 25 Apr 2008 22:15:05 -0700 Subject: Why is None <= 0 In-Reply-To: References: Message-ID: <4812b799$0$34553$742ec2ed@news.sonic.net> Gregor Horvath wrote: > D'Arcy J.M. Cain schrieb: >> On Fri, 25 Apr 2008 20:27:15 +0200 >> Gregor Horvath wrote: >>> >>> None <= 0 >>> True >>> >>> Why? >> >> Why not? > > Because, from http://www.python.org/dev/peps/pep-0020/ : > > Errors should never pass silently. > In the face of ambiguity, refuse the temptation to guess. > > Greg Good point. The problem is the typical one; Python did not originally have a Boolean type, and the retrofit resulted in weird semantics. C has the same issue. John Nagle From enleverlesX.XmcX at XmclaveauX.com Fri Apr 11 09:38:32 2008 From: enleverlesX.XmcX at XmclaveauX.com (Méta-MCI (MVP)) Date: Fri, 11 Apr 2008 15:38:32 +0200 Subject: Python plus Message-ID: <47ff69e4$0$842$ba4acef3@news.orange.fr> After IronPython, Python + iron : http://www.golfermania.com/SnakeEyes/PYTHON-PLUS-IRON.jpg ;o) Michel Claveau From usenet-mail-0306.20.chr0n0ss at spamgourmet.com Sat Apr 26 06:30:37 2008 From: usenet-mail-0306.20.chr0n0ss at spamgourmet.com (Bjoern Schliessmann) Date: Sat, 26 Apr 2008 12:30:37 +0200 Subject: Pyserial - send and receive characters through linux serial port References: Message-ID: <67geidF2p1bmkU1@mid.individual.net> terry wrote: > I am trying to send a character to '/dev/ttyS0' and expect the > same character and upon receipt I want to send another character. > I tired with Pyserial but in vain. Pyserial works very well for me (despite the device I connect to has quite a screwed protocol and implementation). > Test Set up: > > 1. Send '%' to serial port and make sure it reached the serial > port. 2. Once confirmed, send another character. > > I tried with write and read methods in Pyserial but no luck. Are you actaully trying to get lucky by doing this, or are you observing a specific problem, e.g. nothing is received or wrong characters are received? Also, by what are they received? Regards, Bj?rn -- BOFH excuse #139: UBNC (user brain not connected) From stef.mientki at gmail.com Tue Apr 29 15:40:24 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Tue, 29 Apr 2008 21:40:24 +0200 Subject: __getattr__ and recursion ? Message-ID: <481779A8.6070208@gmail.com> hello, I tried to find an easy way to add properties (attributes) to a number of different components. So I wrote a class, from which all these components are derived. By trial and error I created the code below, which now works, but there is one thing I don't understand: in the line indicated with "<<== 1" I'm not allowed to use for item in self.extra_getters : because it will result in an infinite recursion. But in the line indicated with "<<== 2" , I am allowed ... ... why is this allowed ?? thanks, Stef Mientki # *********************************************************************** # *********************************************************************** class _add_attribs ( object ) : def __init__ ( self ) : self.extra_setters = {} self.extra_getters = {} def _add_attrib ( self, text, setter = None, getter = None ) : if setter : self.extra_setters [ text ] = setter if getter : self.extra_getters [ text ] = getter # ********************************************************* # always called instead of the normal mechanism # ********************************************************* def __setattr__ ( self, attr, value ) : for item in self.extra_setters : if item == attr : self.extra_setters [ item ] ( value ) break else : self.__dict__[attr] = value # ********************************************************* # only called when not found with the normal mechanism # ********************************************************* def __getattr__ ( self, attr ) : try : for item in self.__dict__['extra_getters'] : <<== 1 if item == attr : return self.extra_getters [ item ] ( ) <<== 2 except : return [] # *********************************************************************** From gagsl-py2 at yahoo.com.ar Tue Apr 22 11:55:58 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 22 Apr 2008 12:55:58 -0300 Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <675tasF2kecjsU1@mid.uni-berlin.de> Message-ID: En Tue, 22 Apr 2008 07:34:48 -0300, Diez B. Roggisch escribi?: > azrael schrieb: >> A friend of mine i a proud PERL developer which always keeps making >> jokes on python's cost. >> >> Please give me any arguments to cut him down about his commnets >> like :"keep programing i python. maybe, one day, you will be able to >> program in VisualBasic" >> >> This hurts. Please give me informations about realy famous >> aplications. > > This isn't worth too much, but nontheless: > > http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html Also, you can enter the Python main site, on the right and very prominently you have a link to many successful stories: http://www.python.org/about/success/ > But the real problem is not your friend - it's you. He hurts you because > you let him. Stop getting mad about that he teases you. I agree. -- Gabriel Genellina From oakley at bardo.clearlight.com Tue Apr 15 18:46:07 2008 From: oakley at bardo.clearlight.com (Bryan Oakley) Date: Tue, 15 Apr 2008 22:46:07 GMT Subject: tkinter, canvas, get color of image? In-Reply-To: References: <0e4c9708-dbe9-4f29-ac31-34f7298f2624@m1g2000pre.googlegroups.com> Message-ID: skanemupp at yahoo.se wrote: > On 13 Apr, 19:19, Bryan Oakley wrote: >> skanem... at yahoo.se wrote: >>> mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\elmapovic.gif') >>> w.create_image(10, 10, image = mapq, anchor = NW) >>> after doing this is there any possibility of getting the >>> characteristics of the GIF-picture(or bitmap if i use that)? >>> it would be very helpfull if i for example could do something like >>> canvas.getcolor(image, mouseclick.x,mouseclick.y) if u get the point. >>> get the color of the image where i clicked. >> The image isn't "painted" on the canvas, so to answer your specific >> question, no, you can't get the color of a pixel on the canvas in the >> way that you ask. >> >> However, when you click on the canvas you can get the item that was >> clicked on and the x/y of the click. From that you can figure out which >> pixel of the image is under the cursor. And from that you can query the >> image for the color of a specific pixel. > > > how do i get the item? > http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_image-method > > with any of those methods? > > when i click the mouse i can get event.object u mean? You can use find_closest to find the object closest to the x,y of the event. You can also do find_withtag(tk.CURRENT) which returns the item under the mouse pointer. From lutz.georg.horn at googlemail.com Wed Apr 30 02:44:26 2008 From: lutz.georg.horn at googlemail.com (Lutz Horn) Date: Wed, 30 Apr 2008 08:44:26 +0200 Subject: computing with characters In-Reply-To: <481813E2.2030302@islandtraining.com> References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> Message-ID: <7c85a2590804292344p7875dcf8te5d219a4b37a2153@mail.gmail.com> Hi, 2008/4/30 Gary Herron : > SL wrote: > > How can I compute with the integer values of characters in python? > > Like 'a' + 1 equals 'b' etc > > You can get an integer value from a character with the ord() function. So just for completion, the solution is: >>> chr(ord('a') + 1) 'b' Lutz -- Do you want a Google Mail invitation? Just write me an email! From samslists at gmail.com Sun Apr 6 16:40:11 2008 From: samslists at gmail.com (samslists at gmail.com) Date: Sun, 6 Apr 2008 13:40:11 -0700 (PDT) Subject: Implementation of Crockford's Base32 Encoding? References: <345117e9-2539-4ee0-8b27-9b1a88ddde7c@a1g2000hsb.googlegroups.com> <3EF041EA-8E9A-4DAA-B690-FC725D9E25D6@gmail.com> Message-ID: <9d34f801-29cc-4c19-80d2-2ebdcc41d0bc@8g2000hse.googlegroups.com> Gabriel... I looked at Zooko's encoding. I didn't really like that the first 16 characters weren't the same as for base 16, [0-9a-f]. I hadn't considered the need for padding. Zooko doesn't seem to use it either. How does he get around it? Thanks p.s. Paul...yes it is different. :) On Apr 6, 7:15 am, "Gabriel Genellina" wrote: > En Sun, 06 Apr 2008 06:07:18 -0300, Petite Abeille > escribi?: > > > On Apr 6, 2008, at 9:20 AM, samsli... at gmail.com wrote: > > >> Anyone know of aPythonimplementation of this: > >>http://www.crockford.com/wrmg/base32.html > > > Not sure aboutCrockford'sBase32encoding itself, but here is an > > implementation of Bryce "Zooko" Wilcox-O'Hearn's "human-oriented > > base-32 encoding": > > >https://zooko.com/repos/z-base-32/base32/ > >https://zooko.com/repos/z-base-32/base32/DESIGN > > The design and rationale looks better. TheCrockfordversion is > ill-defined in the sense that you can't recover the exact input string > length in some cases; by example both "\x00"*4 and "\x00"*5 share the same > encoding. > base-64 encoding, by example, uses '=' as pad bytes at the end to avoid > this problem. > > -- > Gabriel Genellina From goodz158 at yahoo.com Wed Apr 16 06:37:55 2008 From: goodz158 at yahoo.com (Good Z) Date: Wed, 16 Apr 2008 03:37:55 -0700 (PDT) Subject: Calling Java Class from python Message-ID: <608239.30549.qm@web35906.mail.mud.yahoo.com> All, We have developed a website in python and we need to integrate few features of third party website. They have provided us Base64EncoderDecoder Java Class and would like us to use it to encode the data before sending it to their site and decode it when received anything from their site. I have no idea/knowledge of Java. Can you please guide me how can i call Java class from Python scripts? Or what is the best way to handle this condition. Is Base64 library provided by python is compatible to Base64EncoderDecoder Java Class? Regards, Mike ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From bbxx789_05ss at yahoo.com Fri Apr 4 20:16:30 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Fri, 4 Apr 2008 17:16:30 -0700 (PDT) Subject: Is there any way to say ignore case with "in"? References: <47f692f3$0$759$bed64819@news.gradwell.net> Message-ID: <432d690f-44be-49a9-bc6a-1cf3445549d6@m71g2000hse.googlegroups.com> On Apr 4, 2:43?pm, tinn... at isbd.co.uk wrote: > Is there any way in python to say > > ? ? if string1 in string2: > ? ? ? ? > > ignoring the case of string1 and string2? > > I know I could use:- > > ? ? if lower(string1) in lower(string2): > ? ? ? ? > > but it somehow feels there ought to be an easier (tidier?) way. > Easier? You mean like some kind of mind meld? From timr at probo.com Wed Apr 30 02:32:21 2008 From: timr at probo.com (Tim Roberts) Date: Wed, 30 Apr 2008 06:32:21 GMT Subject: File IO Issues, help :( References: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> Message-ID: Kevin K wrote: >On Apr 29, 12:38 am, "Eric Wertman" wrote: >> chuck in a jsfile.close(). The buffer isn't flushing with what you >> are doing now. jsfile.flush() might work... not sure. Closing and >> re-opening the file for sure will help though. >> > >Yeah sorry I forgot to include the close() in the quote but its there. >In fact I moved it up a bit and still no luck heres the new code: > >jsfile = open("../timeline.js", "r+") >jscontent = jsfile.readlines() >jsfile.truncate() > >for line in jscontent: > if re.search('var d =', line): > line = "var d = \""+mint['1'].ascdate()+"\"\n" > print line > jsfile.write(line) >jsfile.close() > >I tried this can got the same result...?? That's not what he meant. He meant: jsfile = open("../timeline.js", "r") jscontent = jsfile.readlines() jsfile.close() jsfile = open("../timeline.js", "w") ...etc... You have to decide whether this makes more sense to you than the seek/truncate solution. Personally, I'd prefer the close/open. Or even: jscontent = open("../timeline.js", "r").readlines() jsfile = open("../timeline.js", "w") ... etc ... -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From ajaksu at gmail.com Sun Apr 20 21:00:55 2008 From: ajaksu at gmail.com (ajaksu) Date: Sun, 20 Apr 2008 18:00:55 -0700 (PDT) Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> <480b6133$0$34498$742ec2ed@news.sonic.net> Message-ID: <7dbfc62c-b642-40d5-a55b-2d3d9efc3bd0@2g2000hsn.googlegroups.com> On Apr 20, 3:31?pm, Steve Holden wrote: > JB "My first post on c.l.py" Stern wrote: > > Curious Steve, how do you pay the rent and by what authority do you > > speak for "The Python world"? [snip] > I don't claim to speak *for* the > whole Python world, but as chairman of the Python Software Foundation ROTFLMAO From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 22 08:58:00 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 22 Apr 2008 14:58:00 +0200 Subject: Python Success stories In-Reply-To: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <480de0d0$0$24455$426a74cc@news.free.fr> azrael a ?crit : > Hy guys, > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. s/proud/stupid/ > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" > > This hurts. Please give me informations about realy famous > aplications. Don't let cretins hurt you. One of my best friends who is a die-hard Perl addict really loves Python too, and finds this kind of pissing contests more than stupid. From dave.l.harrison at gmail.com Mon Apr 7 01:45:33 2008 From: dave.l.harrison at gmail.com (David Harrison) Date: Mon, 7 Apr 2008 15:45:33 +1000 Subject: Help replacing os.system call with subprocess call In-Reply-To: References: <47F9B1D1.4090701@eastlink.ca> Message-ID: On 07/04/2008, David Harrison wrote: > On 07/04/2008, David Pratt wrote: > > Hi. I am trying to replace a system call with a subprocess call. I have > > tried subprocess.Popen and subprocess.call with but have not been > > successful. The command line would be: > > > > svnadmin dump /my/repository > svndump.db > > > > This is what I am using currently: > > > > os.system('svnadmin dump %s > %s' % (svn_dir, > > os.path.join(backup_dir, 'svndump.db'))) > > > > Many thanks. > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > > Hey David, > > Your probably want something like the following (code untested and off > the cuff ;-) ) > > Cheers > Dave > > --- > > import subprocess > > p = subprocess.Popen( > [ "svnadmin", "dump" ], > stdin=subprocess.PIPE, > stdout=subprocess.PIPE, > stderr=subprocess.PIPE, > close_fds=True > ) > (child_stdout, child_stdin) = (p.stdout, p.stdin) > > f = open('svndump.db') > f.write(child_stdout.read()) > f.close() My inner pendant kicked in so I tested the code using [ 'ls', '-lha' ] and found that the file object should be f = open('svndump.db', 'w') instead :-) From ang.usenet at gmail.com Tue Apr 8 16:56:53 2008 From: ang.usenet at gmail.com (Aaron Gray) Date: Tue, 8 Apr 2008 21:56:53 +0100 Subject: CPython VM & byte code resources wanted References: <6622srF2e32hbU1@mid.individual.net> Message-ID: <6624goF2icl0vU1@mid.individual.net> >Bytecodes: >http://docs.python.org/lib/bytecodes.html > >VM: >Python/ceval.c Thanks, Aaron From bockman at virgilio.it Wed Apr 16 03:04:07 2008 From: bockman at virgilio.it (bockman at virgilio.it) Date: Wed, 16 Apr 2008 00:04:07 -0700 (PDT) Subject: tkinter, event.widget, what do i get? References: <7caa5089-2ea9-4e18-9117-7431d7403976@l42g2000hsc.googlegroups.com> <3a6f6d87-0102-4995-a033-501137b3f934@s50g2000hsb.googlegroups.com> Message-ID: <953034b6-e4d0-4671-b518-92ed3e837b2b@59g2000hsb.googlegroups.com> On 16 Apr, 01:45, skanem... at yahoo.se wrote: > On 16 Apr, 00:24, "Gabriel Genellina" wrote: > > > > > > > En Tue, 15 Apr 2008 17:45:08 -0300, escribi?: > > > > when calling function hmm here, what do i get? the widget i clicked > > > on? > > > if i have a canvs on wich i have a bitmap and i click on the bitmap, > > > is the event.widget then the bitmap? > > > can i get info about the bitmap then? like color of the pixel i > > > clicked. if so, how? > > > > w.bind("", key) > > > w.bind("", hmm) > > > > def hmm(event): > > > ? ? return event.widget > > > Why don't you try by yourself? You can use: print repr(something) > > > -- > > Gabriel Genellina > > i get > > thing is i get that even though i click outside the image. > and what can i do with this number anyway?- Nascondi testo tra virgolette - > > - Mostra testo tra virgolette - If your image is a canvas item (i.e. created with canvas create_image method), then you can use the method tag_bind to handle events specific of that item. In that case, the callback argument is a Tkinter.Event instance. Ciao ----- FB From danfolkes at gmail.com Fri Apr 25 09:33:10 2008 From: danfolkes at gmail.com (Daniel Folkes) Date: Fri, 25 Apr 2008 06:33:10 -0700 (PDT) Subject: Can you recommend a book? References: Message-ID: On Apr 25, 6:28?am, "noagbodjivic... at gmail.com" wrote: > Hello all, I learned Python with the book "Programming Python" by John > Zelle. But today this book is a little bit old. My Python is some kind > old. I need a book that will help me brush my style and keep me up to > date. I would like one with practical examples. > > Can you recommend one? Learning Python followed by Programming Python. You should be able to find them in a Library too. From kirk.strauser at gmail.com Fri Apr 25 10:03:26 2008 From: kirk.strauser at gmail.com (Kirk Strauser) Date: Fri, 25 Apr 2008 07:03:26 -0700 (PDT) Subject: Subclassing list the right way? Message-ID: I want to subclass list so that each value in it is calculated at call time. I had initially thought I could do that by defining my own __getitem__, but 1) apparently that's deprecated (although I can't find that; got a link?), and 2) it doesn't work. For example: >>> class Foo(list): ... def __getitem__(self, index): ... return 5 ... >>> a = Foo([1, 2, 3, 4, 5]) >>> print a [1, 2, 3, 4, 5] >>> print a[2:4] [3, 4] >>> print a[3] 5 I first expected that to instead behave like: >>> print a [5, 5, 5, 5, 5] >>> print a[2:4] [5, 5] Is there a "right" way to do this? -- Kirk Strauser From jhenRemoveThis at talk21.com Mon Apr 28 22:20:37 2008 From: jhenRemoveThis at talk21.com (John Henderson) Date: Tue, 29 Apr 2008 12:20:37 +1000 Subject: Python Math libraries - How to? References: Message-ID: <67nevlF2q292cU1@mid.individual.net> aguirre.adolfo at gmail.com wrote: > Hi, I am a very newbie who would very much appreciate some > hints. > > Python 2.52. on Windows XP for now. Soon on Ubuntu 8 > > I am teaching myself Python following free tutorials. I can > solve problems using arithmetic, but when I try to upgrade the > programs using math libraries nothing seems to work. I > downloaded a 2002 tutorial from Zelle "An Introduction to > Computer Science" where he uses a "import math" statement to > calculate a square root. I tried the > "pi" library function but it didn?t work. I tried using def > Pi() it did not work either. I am yet to find a tutorial that > explains how to declare (or initialize) and pass numbers to > the functions such as "cos(x)" and the pi which does not have > a variable in it. Is just a constant. > > Here is the arithmetic program I made that it worked before I > added > the "import math" line. I erased the constant p = 3.1416 and > added the "i" for the library function "pi" in the algorithms. > But I get an error message not recognizing "pi" > > > > #volumen.py > # A program to compute the volume and surface area of a sphere > import math Change that line, "import math", to: from math import * and it'll work. I'm learning too, so some proficient person might be able to explain the difference to both of us :) John > > def main(): > > print "This program calculates the volume and surface area > of a > sphere" > print > r = input("Please enter the radious: ") > print > r3 = r*r*r > volume = 4/3*pi*r3 > r2 = r*r > surface = 4*pi*r2 > print "The Volume is", volume, " Cubic centimeters" > print > print "The Surface area is", surface, " square > centimeters" > > main() > > *** Error message ************* > > Traceback (most recent call last): > File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 20, > in > > main() > File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 13, > in main > volume = 4/3*pi*r3 > NameError: global name 'pi' is not defined From sevenjp at gmail.com Wed Apr 2 15:33:25 2008 From: sevenjp at gmail.com (=?ISO-8859-1?Q?Jo=E3o_Neves?=) Date: Wed, 2 Apr 2008 12:33:25 -0700 (PDT) Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> Message-ID: <10ee2a69-f4e2-4887-8083-6b02b60dd0cd@i7g2000prf.googlegroups.com> On Apr 2, 5:41 pm, "Dan Upton" wrote: > > The thing I've been wondering is why _is_ it read-only? In what > > circumstances having write access to co_code would break the language > > or do some other nasty stuff? > > > Jo?o Neves > > I can't speak to Python's implementation in particular, but > self-modifying code in general is unpleasant. It certainly is > possible to support it in runtime environments, but it's usually not > easy to do so. That is, of course, somewhat dependent on the > implementation of the runtime environment, and even to some degree the > underlying hardware. (For instance, the compiled code you want to run > could be in the hardware cache; if you then change the instructions at > those addresses in memory, it's not always straightforward to get the > processor to realize it needs to load the new data into the > instruction cache.) Plus, I suppose it might be possible to break > strong (even dynamic) typing if you start changing the code around > (although I can't construct an example off the top of my head). Indeed, the caching issue is a relevant one I guess, and adding the mechanism to go around that might have a significant impact on performance. I haven't looked in detail into it, but I agree with your opinion concerning strong and dynamic typing. If type check is done while compiling to bytecode, there is no guarantee the modified bytecode will respect the rules, for instance. I don't know though, haven't really checked how it's done at this point. :) I will be fiddling around with the Python VM these days anyway, and since I'm going to muck around the bytecode, I might just try to see the effects of removing the read-only restriction from co_code. > > In short, you need a good reason to support self-modifying code, and > my guess is nobody could come up with one for Python. > > -dan From what I've seen, Python has some support for lambda expressions, albeit it may be limited. Self-modifying code would greatly enhance this feature, I guess. Well, at least from a Lisp newbie perspective. :) --- Jo?o Neves From reachmsn at hotmail.com Tue Apr 15 04:00:07 2008 From: reachmsn at hotmail.com (reachmsn at hotmail.com) Date: Tue, 15 Apr 2008 01:00:07 -0700 (PDT) Subject: Cannot understand the detailedly the following code References: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> <10a83944-b17a-4c3f-992b-1754c0a5e9b1@s33g2000pri.googlegroups.com> Message-ID: <351a72fb-298a-461c-b42f-36da9d2f0d06@w8g2000prd.googlegroups.com> On Apr 11, 10:27?am, "Gabriel Genellina" wrote: > > If you want to understand how recursion works, or how you can actually ? > construct a recursive function step by step, see this excellent post by ? > Neil Cerutti: > > http://groups.google.com/group/comp.lang.python/msg/9f0b10631fd47886 > Hi, I did read the above post by Cerutti but I'm still having trouble writing this recursive function. I will be grateful if someone can kindly guide me. Regards, Anshu From filipe.tg at gmail.com Mon Apr 28 08:54:58 2008 From: filipe.tg at gmail.com (Filipe Teixeira) Date: Mon, 28 Apr 2008 05:54:58 -0700 (PDT) Subject: Retrieving int from hex in a file. References: <9edfaaa3-4e87-4f74-90a5-c10c9daae101@r66g2000hsg.googlegroups.com> Message-ID: > > Use ord(q) > > py> help(ord) > Help on built-in function ord in module __builtin__: > > ord(...) > ord(c) -> integer > > Return the integer ordinal of a one-character string. > > py> > > -- > Gabriel Genellina Thank you Gabriel. It fit's my purpose. From martin at v.loewis.de Wed Apr 16 15:56:20 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Wed, 16 Apr 2008 21:56:20 +0200 Subject: Does Python use a special home-made parser, or does it use Yacc? In-Reply-To: <236a2391-ac15-4910-8d47-5741256486d1@1g2000prf.googlegroups.com> References: <236a2391-ac15-4910-8d47-5741256486d1@1g2000prf.googlegroups.com> Message-ID: <480659e4$0$27007$9b622d9e@news.freenet.de> Robert wrote: > Or some other pre-packaged parser tool? None of them: it's not YACC, not a pre-packaged parser tool, and not a home-made parser. Instead, it uses pgen, a parser tool that is included in the Python distribution (whether *that* was made at home or at work, I don't know :-). Regards, Martin From google at mrabarnett.plus.com Tue Apr 1 17:37:41 2008 From: google at mrabarnett.plus.com (MRAB) Date: Tue, 1 Apr 2008 14:37:41 -0700 (PDT) Subject: Why prefer != over <> for Python 3.0? References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> Message-ID: <84aaed5f-d151-48e9-bfc0-cc69f12b6ec4@f63g2000hsf.googlegroups.com> On Mar 30, 7:59 pm, "Gabriel Genellina" wrote: > En Sun, 30 Mar 2008 11:10:20 -0300, MRAB > escribi?: > > > > > On Mar 30, 6:35 am, "Gabriel Genellina" > > wrote: > >> En Sun, 30 Mar 2008 02:11:33 -0300, hdante escribi?: > > >> > BTW, my opinion is that it's already time that programmer editors > >> > have input methods advanced enough for generating this: > > >> > if x ? 0: > >> > ?y ? s: > >> > if y ? 0: f1(y) > >> > else: f2(y) > > >> Fine if you have the right keyboard... Try to write APL with a standard > >> keyboard :) > > > There was a version of APL for the Sinclair QL which replaced the > > standard APL symbols with keywords. > > Wow, APL on 8 bits? > Now there is (or perhaps there was) J, a reincarnation of APL by Iverson > himself that uses ASCII characters only. > The Sinclair QL used the Motorola 68008, which was like the 68000 (a 32-bit processor) but with an 8-bit external data bus instead of a 16- bit one; that made the system cheaper to build, but as the instructions were multiples of 16 bits long every instruction required at least 2 memory accesses, which made it slower. Nice clean processor though, unlike the 8086... :-) From mail at timgolden.me.uk Wed Apr 23 13:12:45 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Wed, 23 Apr 2008 18:12:45 +0100 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. In-Reply-To: <480f6553$0$34545$742ec2ed@news.sonic.net> References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> Message-ID: <480F6E0D.2070808@timgolden.me.uk> John Nagle wrote: > Mike Driscoll wrote: >> Ken, >> >> On Tue, Apr 22, 2008 at 1:36 PM, Kenneth McDonald >> wrote: >>> Sadly. >>> >>> Thanks, >>> Ken >>> -- >>> http://mail.python.org/mailman/listinfo/python-list >>> >> >> I've attached the 2.4 version. I also have some Windows binaries for >> Beautiful Soup uploaded to my website: >> http://www.pythonlibrary.org/python_modules.htm > > What on earth do you need a "Windows binary" for? "BeautifulSoup" > is ONE PYTHON SOURCE FILE, "BeautifulSoup.py". Ummm.. Why does it bother you? Mike seems to be offering a public service to Windows users: by downloading the .exe, I can double-click on one file, have the module or package installed (whether it contains one .py file or twenty or a series of compiled extension modules and their respective DLLs) and for a bonus it's registered in the system packages directory [*] and is therefore uninstallable from there. It's not much different from a Linux distro offering BeautifulSoup via its module repository: apt-get or yum or whatever. Certainly, if you prefer, then go to PyPI or to the source address which you helpfully provided and download the one python source file. I'm sure I don't mind. TJG [*] Which isn't, admittedly, what everyone wants to happen... From urquhart.nak at gmail.com Wed Apr 30 06:27:54 2008 From: urquhart.nak at gmail.com (urquhart.nak at gmail.com) Date: Wed, 30 Apr 2008 03:27:54 -0700 (PDT) Subject: patch management Message-ID: patch management http://crack.cracksofts.com From bockman at virgilio.it Wed Apr 2 13:33:41 2008 From: bockman at virgilio.it (Francesco Bochicchio) Date: Wed, 02 Apr 2008 19:33:41 +0200 Subject: who said python can't be obsfucated!? References: Message-ID: On Wed, 02 Apr 2008 07:19:08 -0700, cokofreedom wrote: > def s(c):return[]if c==[]else s([_ for _ in c[1:]if _ +s([_ for _ in c[1:]if _>=c[0]]) > > Anyone else got some wonders...? Not so good: it took me only one minute to anderstand that is a recursive sort ... or it is? I read it as: """ the function s applied to a list is equal to the empty list if the input list is empty, otherwise it is equal to the result of the function s applied to all the elements smaller than the first one plus the first element plus the function sort applied to all the elements greater or equal to the first one, except the first one itself. """ I like the almost one-to-one corrispondence between the code elements and the components of the sentence describing the function. Now _that_ is an human-friendly syntax :-) Ciao ---- FB From tracyde at gmail.com Wed Apr 2 14:09:45 2008 From: tracyde at gmail.com (Derek Tracy) Date: Wed, 2 Apr 2008 14:09:45 -0400 Subject: Manipulate Large Binary Files In-Reply-To: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> Message-ID: <9999810b0804021109n77f2c990p7b10d92e9344ad00@mail.gmail.com> On Wed, Apr 2, 2008 at 10:59 AM, Derek Tracy wrote: > I am trying to write a script that reads in a large binary file (over 2Gb) saves the header file (169088 bytes) into one file then take the rest of the data and dump it into anther file. I generated code that works wonderfully for files under 2Gb in size but the majority of the files I am dealing with are over the 2Gb limit > > INPUT = open(infile, 'rb') > header = FH.read(169088) > > ary = array.array('H', INPUT.read()) > > INPUT.close() > > OUTF1 = open(outfile1, 'wb') > OUTF1.write(header) > > OUTF2 = open(outfile2, 'wb') > ary.tofile(OUTF2) > > > When I try to use the above on files over 2Gb I get: > OverflowError: requested number of bytes is more than a Python string can hold > > Does anybody have an idea as to how I can get by this hurdle? > > I am working in an environment that does not allow me to freely download modules to use. Python version 2.5.1 > > > > R/S -- > --------------------------------- > Derek Tracy > tracyde at gmail.com > --------------------------------- > I know have 2 solutions, one using partial and the other using array Both are clocking in at the same time (1m 5sec for 2.6Gb), are there any ways I can optimize either solution? Would turning off the read/write buff increase speed? -- --------------------------------- Derek Tracy tracyde at gmail.com http://twistedcode.blogspot.com --------------------------------- From severian at severian.org Wed Apr 16 10:26:09 2008 From: severian at severian.org (Severian) Date: Wed, 16 Apr 2008 10:26:09 -0400 Subject: Embedding Python in my C++ application Message-ID: <48060c3a$0$18426$39cecf19@news.twtelecom.net> I am working on embedding Python 2.5 in my C++ application, and I have a few questions: 1) My application is multi-threaded; what problems should I be aware of if I create a separate interpreter in each working thread? The documentation is a bit vague (or perhaps I haven't found the right place). Calls into my application are already thread-safe. 2) Rather than implementing my own editor in C++, I would like to be able to use existing tools to some degree, such as a python editor, interactive interpreter and perhaps even debugger, without impacting the main (GUI) thread of my application. Is there an example application, or any hints from someone who has done this? 3) Because my program links statically with the C runtime (on Windows), and Python links with it dynamically, there are some things that cannot be passed back and forth, such as C file handles and FILE pointers. Is anyone aware of other issues this may cause? I will greatly appreciate help with these questions, or advice on embedding Python in general! Thanks, Sev From jzgoda at o2.usun.pl Wed Apr 9 08:25:41 2008 From: jzgoda at o2.usun.pl (Jarek Zgoda) Date: Wed, 09 Apr 2008 14:25:41 +0200 Subject: is Pylons alive? In-Reply-To: References: Message-ID: Mage napisa?(a): > I don't want to be impolite, just in short: I am thinking about leaving > RoR and coming back to Python. I've missed the last two years in Python, > however I have been subscribed to this list and there are not too many > e-mails about Pylons in my mailbox. > > On my Gentoo the latest Pylons ebuild has date "jul 2007" or something > like last summer. It has testing keywords both for x86 and amd64. (No > stable version available). It's available on my debian "testing" desktop. > > Before spending much time for investigating, I would like to ask you: is > Pylons the framework I look for if I want to come back to Python and > develop MVC web apps? Latest commit is dated 2008-04-06, so I suppose it's alive, just no release was done in last time. -- Jarek Zgoda Skype: jzgoda | GTalk: zgoda at jabber.aster.pl | voice: +48228430101 "We read Knuth so you don't have to." (Tim Peters) From kj7ny at nakore.com Fri Apr 4 16:20:55 2008 From: kj7ny at nakore.com (kj7ny) Date: Fri, 4 Apr 2008 13:20:55 -0700 (PDT) Subject: Self in Interactive Interpreter Message-ID: Hope this hasn't been posted hundreds of times. I have never seen it before, but could have missed it. For years it has been a slight annoyance that every time I wanted to test a snippet of code from a class by running it in the interactive interpreter, I had to remove all of the self. instances from the code. After I got it working correctly, I had to put all the self.'s back into the code to put it back into my class. The other day my brain had a functional synapse and I realized I could just start my interactive session with: >>> class dummy: >>> def __init__(self): >>> pass >>> self=dummy() I could then just set up my test variables something like: >>> self.x='Hello' >>> self.y='World' And I could then use class type code such as: >>> print self.x, self.y I no longer had to remove and then replace all of the self. notation from my code snippets. So far I haven't seen why I shouldn't to this. I haven't had any problems using it, but I haven't used it that much. If there is a good reason to NOT do it, let me know. Otherwise I hope this helps anyone who has been annoyed by the same thing. Thanks, From lbonafide at yahoo.com Tue Apr 1 14:57:21 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Tue, 1 Apr 2008 11:57:21 -0700 (PDT) Subject: Is this a good time to start learning python? References: <47f1140e$0$735$a729d347@news.telepac.pt> Message-ID: <88fa881e-e59b-4682-801c-90ef08a1480a@a22g2000hsc.googlegroups.com> On Apr 1, 12:47?pm, "Gabriel Genellina" wrote: > En Tue, 01 Apr 2008 13:57:55 -0300, escribi?: > > > On Mar 31, 1:36?pm, "Gabriel Genellina" > > wrote: > > >> Don't be scared by the "backwards incompatible" tag - it's the way to ? > >> get ? > >> rid of nasty things that could not be dropped otherwise. > > > I would consider breaking production code to be "nasty" as well. > > Please explain how the existence of Python 3.0 would break your production ? > code. The existence of battery acid won't hurt me either, unless I come into contact with it. If one eventually upgrades to 3.0 -- which is ostensibly the desired path -- their code could break and require fixing. Backward compatibility is important. C++ could break all ties with C to "clean up" as well, but it would be a braindead move that would break existing code bases upon upgrade. From fennelllindy8241 at gmail.com Mon Apr 28 03:14:59 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:14:59 -0700 (PDT) Subject: risk2 no disk patch Message-ID: risk2 no disk patch http://crack.cracksofts.com From python.tsp at gmail.com Wed Apr 30 06:03:38 2008 From: python.tsp at gmail.com (pramod sridhar) Date: Wed, 30 Apr 2008 15:33:38 +0530 Subject: help: Question regarding parallel communication using python Message-ID: Hello, I would like from my Python application to control 2 (or more devices) using the existing port's interface in my PC,like serial (COM1) or Parallel port (lpt) or any other like PCI...etc. The control mechanism usually involves sending messages to the connected devices in parallel. For instance, I would like to send a command to a target connected on COM port and at the same time would like to read the value of a Digital multimeter over other COM port ( or may be via USB with some adapter) My Question is: - Is it possible to achieve the above in Python ? - Do we need to use any kind of Parallel processing to achieve this ? - If so, Which of the available packages (like pypar or Pydusa..etc) suits best ? Please suggest. Thank you very much in advance, With Regards, Pramod -------------- next part -------------- An HTML attachment was scrubbed... URL: From tinnews at isbd.co.uk Thu Apr 3 10:42:25 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 03 Apr 2008 14:42:25 GMT Subject: How easy is it to install python as non-root user? References: <47f4e617$0$720$bed64819@news.gradwell.net> <47f4e825$0$20141$426a74cc@news.free.fr> Message-ID: <47f4ecd1$0$712$bed64819@news.gradwell.net> Bruno Desthuilliers wrote: > tinnews at isbd.co.uk a ?crit : > > Does python install fairly easily for a non-root user? > > > > I have an ssh login account onto a Linux system that currently > > provides Python 2.4.3 and I'd really like to use some of the > > improvements in Python 2.5.x. > > > > So, if I download the Python-2.5.2.tgz file is it just the standard:- > > > > ./configure --prefix=$HOME > > make > > make install > > > IIRC there's something like make altinstall - but you'd better read the > doc (INSTALL.txt anyone ?) > Well it seems to work perfectly! :-) I just did the usual sequence as noted above and I seem to have a working Python 2.5.2 of my very own. I didn't need 'make altinstall' because I don't need to be able to see the existing Python 2.4.3. It takes a few Mb of disk space but since my free quote is 3Gb or something that doesn't really worry me. I'm impressed, well done Python developers. -- Chris Green From deets at nospam.web.de Wed Apr 23 10:34:11 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 23 Apr 2008 16:34:11 +0200 Subject: Python generators (coroutines) In-Reply-To: References: Message-ID: <678vnoF2nd7eoU1@mid.uni-berlin.de> rocco.rossi at gmail.com schrieb: > I would really like to know more about python 2.5's new generator > characteristics that make them more powerful and analogous to > coroutines. Is it possible for instance to employ them in situations > where I would normally use a thread with a blocking I/O (or socket) > operation? If it is, could someone show me how it can be done? There > appears to be a very limited amount of documentation in this repect, > unfortunately. What do you mean by "new generator characteristics"? AFAIK generators have been around at least since python2.3. Newer versions of python include things like generator expressions (since 2.4 I believe). However, generators don't help anything in blocking IO-situations, because they rely on co-operatively re-scheduling using yield. Of course you could try & use non-blocking IO with them, but I don't see that there is much to them. Or you could go & use a single poll/select in your main-thread, and on arrival of data process that data with generators that re-schedule in between so that you can react on newer data. Depending on your scenario this might reduce latency. Diez From bockman at virgilio.it Sat Apr 26 05:07:45 2008 From: bockman at virgilio.it (Francesco Bochicchio) Date: Sat, 26 Apr 2008 11:07:45 +0200 Subject: problem with listdir References: Message-ID: On Sat, 26 Apr 2008 01:24:23 -0700, jimgardener wrote: > hi > i have a directory containing .pgm files of P5 type.i wanted to read > the pixel values of these files ,so as a firststep i wrote code to > make a list of filenames using listdir > > pgmdir="f:\code\python\pgmgallery" # where i have pgm files > g2=listdir(pgmdir) > > i get the following error > WindowsError: [Error 123] The filename, directory name, or volume > label syntax is incorrect: 'f:\\code\\python\pgmgallery/*.*' > > i am running python on winXP ..can anyone tell me why i get this > error? Did you try using a raw string as pathname pgmdir=r"f:\code\python\pgmgallery" ? AFAIK, the character '\' in interpreted in Python as the beginning of an escape sequence (such as '\n') and it should be doubled ( as in the error message) or a raw string should be used, telling Python that there are no escape sequences inside. However, from the message it looks like the path as been understood as such, so this might not be the case. Ciao ----- FB From spocksplanet at gmail.com Thu Apr 17 13:02:22 2008 From: spocksplanet at gmail.com (sp@k) Date: Thu, 17 Apr 2008 10:02:22 -0700 (PDT) Subject: Newbie question about for...in range() structure References: Message-ID: <93bf7c9f-f6b7-4d04-8d6f-c9c0ce024326@a23g2000hsc.googlegroups.com> > My guess is that you want to initialize total to 1, not 0. > D'oh! Yes, you are right, thank you. From victorsubervi at gmail.com Wed Apr 9 12:11:28 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 9 Apr 2008 12:11:28 -0400 Subject: String Literal to Blob In-Reply-To: <47FCDC77.7030407@holdenweb.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> Message-ID: <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> On Wed, Apr 9, 2008 at 11:10 AM, Steve Holden wrote: > Victor Subervi wrote: > > > On Wed, Apr 9, 2008 at 10:24 AM, Steve Holden > steve at holdenweb.com>> wrote: > > connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > > cursor = connection.cursor() > > cursor.execute('select img from photo where id="7";') > > content = cursor.fetchall() > > > > Bzzt! Nope. Cursor.fetchall() returns a list (length 1) or tuples (length > 1) here, so this should be > > content = cursor.fetchall()[0][0] > > or, perhaps better > > content = cursor.fetchone()[0] I tried both of these, and they, too, gave me the same identical image of the url, not the image I am after. > > > You really don't understand how the web works, do you? I am just really, really, stupid, Steve. Please forgive me for being so stupid. But I am persistent. And I have built dozens of Web site with images. > In order to include an image in a page your browser must make TWO > requests. The first is for an HTML page that will reference the image in > this way: > > > > Seeing this img tag causes the browser to make a SECOND request, which the > script I corrected above should respond to with an image. > > The bytestream is critical in the image response. Even one misplaced byte > will mess things up terribly. In my stupidity, I have assumed you meant this: content = col_fields[0][14].tostring() print '

' Obviously I am wrong. Could you please give me a little more insight? > BTW, when we are finally done with this, I will write a nice how-to (since > > there is not one in python, while php has some nice ones) on how to do this, > > and give you and Gabrielle all your due credit. I will post it to this list, > > because that is sure to rank highly in google right away. > > Victor > > > > That's great, though hardly the point of the exercise. I think Google > already know about Gabriel (*not* Gabrielle) and me already ... Well, I just thought it might be a good way to get the information out, since it is not out there yet. And I believe it is only proper to give credit where credit is due. I would not be doing this to praise you. Rather, I would be doing this because it is needed, and I would feel wrong for not crediting those who deserve credit. Please let me know, however, if you feel otherwise. TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From flarefight at googlemail.com Sun Apr 27 09:21:48 2008 From: flarefight at googlemail.com (flarefight at googlemail.com) Date: Sun, 27 Apr 2008 06:21:48 -0700 (PDT) Subject: Loading associated files References: <74862697-da58-4eb7-8d60-09aaef54b7ad@j22g2000hsf.googlegroups.com> <09337541-0b3e-4aaf-b26f-06a0f689e7dc@u12g2000prd.googlegroups.com> Message-ID: Yep, thats pretty much exactly what i had done, those exact settings, and it still doesnt work. As i said i looked at the other keys to check i had done it right and a i said the settings are fine because i can send the file to python.exe and it loads like a python file fine, but it doesn't like passing it to my program. Have i done something wrong with my program that simply prints the arguments?? From zaleos at gmail.com Wed Apr 2 04:31:59 2008 From: zaleos at gmail.com (Oolon Colluphid) Date: Wed, 2 Apr 2008 01:31:59 -0700 (PDT) Subject: IM status with appscript Message-ID: hi, i need access to application attributes of IM (like Adium, aMsn, MS Messenger) on Mac platform via appscript module. once instantiated the application object with: app=app("Adium") i don't know how recover information like status, and i have find no references. can someone help me? From bignose+hates-spam at benfinney.id.au Sun Apr 27 10:14:02 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Mon, 28 Apr 2008 00:14:02 +1000 Subject: Random/anonymous class methods References: <801e1c38-ae54-443c-8d87-9745db7ef270@59g2000hsb.googlegroups.com> Message-ID: <87tzhn4c7p.fsf@benfinney.id.au> philly_bob writes: > How can I send ch, which is my random choice, to the myclass > instance? > > Thanks, > > Bob= > > #### > import random > > class myclass(object): > def meth1(self): > print 'meth1' > def meth2(self): > print 'meth2' > > c=myclass() > meths=['meth1', 'meth2'] > ch=random.choice(meths) > c.ch() Functions (including methods) are objects, and can be referenced and bound like any other object:: >>> import random >>> class OptionDispatcher(object): ... def option_a(self): ... print "option a" ... def option_b(self): ... print "option b" ... >>> dispatcher = OptionDispatcher() >>> choice = dispatcher.option_a >>> choice() option a >>> choice = dispatcher.option_b >>> choice() option b >>> options = [dispatcher.option_a, dispatcher.option_b] >>> choice = random.choice(options) >>> choice() option a >>> -- \ ?I must say that I find television very educational. The | `\ minute somebody turns it on, I go to the library and read a | _o__) book.? ?Groucho Marx | Ben Finney From grante at visi.com Thu Apr 17 14:30:18 2008 From: grante at visi.com (Grant Edwards) Date: Thu, 17 Apr 2008 13:30:18 -0500 Subject: What can we do about all the spam that the list is getting? References: <259ab201-9d2b-4e4e-88a7-e2fe277f0066@a23g2000hsc.googlegroups.com> Message-ID: On 2008-04-17, Mark Shroyer wrote: >>> So download a "real" NNTP client for whatever platform you're >>> on and give its spam filter a shot; clearly Google is not >>> interested in fighting spam itself. >> >> Plonking anything posted via google.groups is the simplest >> answer. > > Yes, but it's hard to give him that advice with a straight > face until I've convinced him to stop using Google Groups to > begin with ;) When using Google Groups can one kill all posts made via Google Groups? Presuming he has no burning need to see his own posts (something that can't be said for everybody in the history of Usenet), it might still be a viable approach. -- Grant Edwards grante Yow! VICARIOUSLY experience at some reason to LIVE!! visi.com From http Tue Apr 1 04:12:26 2008 From: http (Paul Rubin) Date: 01 Apr 2008 01:12:26 -0700 Subject: counting using variable length string as base References: Message-ID: <7xlk3yro2d.fsf@ruckus.brouhaha.com> Grimsqueaker writes: > Basically I want to find every possible order of every combination. > Its easy if you know how many characters there will be in your string > (use nested for loops), but I am stuck with the variable length > string. I think I have to use a generator but I'm not sure exactly how. > > Can anyone give me a pointer in the right direction? The basic idea is to use recursion to get the effect of nested for loops except to an arbitrary depth. You don't need a generator. From brianc at temple.edu Wed Apr 9 13:36:38 2008 From: brianc at temple.edu (Brian Cole) Date: Wed, 9 Apr 2008 11:36:38 -0600 Subject: Python Leopard DLL Hell In-Reply-To: <47FC2161.5020905@gmail.com> References: <54b165660804081819g4787f4d9g821c7269af7b4c66@mail.gmail.com> <47FC2161.5020905@gmail.com> Message-ID: <54b165660804091036n40aef4c9r98aabe2a059fc19e@mail.gmail.com> I have learned that this is a specific behavior of OS X. I have submitted a formal bug report to Apple about the problem. It appears that this is documented by Apple as acceptable: http://developer.apple.com/documentation/DeveloperTools/Reference/MachOReference/Reference/reference.html#//apple_ref/c/func/dlopen Whereas, linux will respect the fact you gave it a specific shared library: http://linux.die.net/man/3/dlopen If I am provided a workaround by apple I will post a python patch. A little scary that someone can circumvent my application by just setting an environment variable. -Brian Cole On Tue, Apr 8, 2008 at 7:52 PM, Michael Torrie wrote: > Brian Cole wrote: > > That appears to be working correctly at first glance. The argument to > > dlopen is the correct shared library. Unfortunately, either python or > > OS X is lying to me here. If I inspect the python process with OS X's > > Activity Monitor and look at the "Open Files and Ports" tab, it shows > > that the _foo.so shared library is actually the one located inside > > $DYLD_LIBRARY_PATH. > > > > So this problem may not be python's, but I place it here as a first > > shot (maybe I'm using the imp module incorrectly). > > Sounds like you're going to need to learn how to use dtrace. Then you > can more closely monitor exactly what python and the loader are doing. > dtrace is very complicated (borrowed from Solaris) but extremely > powerful. Worth learning anyway, but sounds like it's probably the > debugging tool you need. > > Another thing you can do is check through the python source code and see > how the os x-specific code is handling this type of situation. > > -- > http://mail.python.org/mailman/listinfo/python-list > From sjmachin at lexicon.net Sun Apr 20 02:01:59 2008 From: sjmachin at lexicon.net (John Machin) Date: Sun, 20 Apr 2008 06:01:59 GMT Subject: 2's complement conversion. Is this right? In-Reply-To: References: <2008041813575616807-bob@passcalnmtedu> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> Message-ID: <480adc56@news.mel.dft.com.au> Ross Ridge wrote: > Ross Ridge wrote: >> It's the same as the previous version except that it "precompiles" >> the struct.unpack() format string. =A0It works similar to the way Python >> handles regular expressions. > > George Sakkis wrote: >> I didn't know about the Struct class; pretty neat. It's amazing that >> this version without Psyco is as fast Bob's version with Psyco! > > Unfortunately, it doesn't seem to documented in the Python 2.5 manual. It seems to me that it's documented: http://docs.python.org/lib/struct-objects.html The struct module doc page (http://docs.python.org/lib/module-struct.html) provides links but no explicit mention of the Struct class in its text. From torriem at gmail.com Mon Apr 21 22:10:03 2008 From: torriem at gmail.com (Michael Torrie) Date: Mon, 21 Apr 2008 20:10:03 -0600 Subject: Lists: why is this behavior different for index and slice assignments? In-Reply-To: <480d435b$0$11643$607ed4bc@cv.net> References: <480d435b$0$11643$607ed4bc@cv.net> Message-ID: <480D48FB.4000405@gmail.com> John Salerno wrote: > So the question is, when you assign an empty list to an index, why does > it insert an empty list, but when you assign an empty list to a slice, > it simply deletes the slice? I would say this is consistent behavior because a list slice is also a list itself. Whereas a list element is just that. A reference to an object that can be rebound. In the latter case you are rebinding a single list item to an empty list. From mnordhoff at mattnordhoff.com Sun Apr 27 11:06:54 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Sun, 27 Apr 2008 15:06:54 +0000 Subject: removing extension In-Reply-To: References: Message-ID: <4814968E.4090604@mattnordhoff.com> Arnaud Delobelle wrote: > More simply, use the rsplit() method of strings: > >>>> path = r'C:\myimages\imageone.jpg' >>>> path.rsplit('.', 1) > ['C:\\myimages\\imageone', 'jpg'] > > >>>> path = r"C:\blahblah.blah\images.20.jpg" >>>> path.rsplit('.', 1) > ['C:\\blahblah.blah\\images.20', 'jpg'] > > HTH There's os.path.splitext(), which probably does just about exactly that. -- From aaron.watters at gmail.com Tue Apr 1 16:40:19 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Tue, 1 Apr 2008 13:40:19 -0700 (PDT) Subject: object-relational mappers Message-ID: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> I've been poking around the world of object-relational mappers and it inspired me to coin a corellary to the the famous quote on regular expressions: "You have objects and a database: that's 2 problems. So: get an object-relational mapper: now you have 2**3 problems." That is to say I feel that they all make me learn so much about the internals and features of the O-R mapper itself that I would be better off rolling my own queries on an as-needed basis without wasting so many brain cells. comments? -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=mild+exponential+growth From bvidinli at gmail.com Mon Apr 28 05:42:55 2008 From: bvidinli at gmail.com (bvidinli) Date: Mon, 28 Apr 2008 12:42:55 +0300 Subject: apache module: python and web programming, easy way...? Message-ID: <36e8a7020804280242t3f050b86o2574942cae460484@mail.gmail.com> is there any apache module, you know, that i can just install with apt-get, then put my .py file, and run it ? 2008/4/27 David : > > > > www.webpy.org is supereasy to get going with. dont know which is > > better for advanced stuff. > > > > I don't think that webpy supports sessions. Their addition to webpy is > a Google Summer of Code project: > > http://webpy.org/sessions/gsoc > > Also, I can't find any reference to cookies or sessions in the webpy > online docs. Maybe it's possible to bolt on support with Python's > Cookie module. > > David. > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From danb_83 at yahoo.com Tue Apr 22 22:27:22 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Tue, 22 Apr 2008 19:27:22 -0700 (PDT) Subject: Explicit variable declaration References: Message-ID: <29cc373e-7c27-42cf-980e-733a7bfe6aa5@f63g2000hsf.googlegroups.com> On Apr 22, 7:39 pm, "Filip Gruszczy?ski" wrote: > Hello everyone! > > It is my first message on this list, therefore I would like to say > hello to everyone. I am fourth year student of CS on the Univeristy of > Warsaw and recently I have become very interested in dynamically typed > languages, especially Python. > > I would like to ask, whether there is any way of explicitly declaring > variables used in a function? While I am pretty sure, that there is no > such way in the language itself, I would like to know, whether there > are any third-party tools to do that. This would be very useful for me > during development, so I am looking for such a tool. def a_function(args): # Local variables: item, item2 ... ;-) From x31equsenet at gmail.com Fri Apr 11 10:50:33 2008 From: x31equsenet at gmail.com (Graham Breed) Date: Fri, 11 Apr 2008 07:50:33 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: <63e33f12-cd06-46c7-90fe-0495c45514cf@n1g2000prb.googlegroups.com> On Apr 11, 6:14 pm, bdsatish wrote: > The built-in function round( ) will always "round up", that is 1.5 is > rounded to 2.0 and 2.5 is rounded to 3.0. > > If I want to round to the nearest even, that is > > my_round(1.5) = 2 # As expected > my_round(2.5) = 2 # Not 3, which is an odd num If you care about such details, you may be better off using decimals instead of floats. > I'm interested in rounding numbers of the form "x.5" depending upon > whether x is odd or even. Any idea about how to implement it ? import decimal decimal.Decimal("1.5").to_integral( rounding=decimal.ROUND_HALF_EVEN) decimal.Decimal("2.5").to_integral( rounding=decimal.ROUND_HALF_EVEN) ROUND_HALF_EVEN is the default, but maybe that can be changed, so explicit is safest. If you really insist, import decimal def my_round(f): d = decimal.Decimal(str(f)) rounded = d.to_integral(rounding=decimal.ROUND_HALF_EVEN) return int(rounded) Graham From collardfelszkw at gmail.com Sun Apr 20 16:32:59 2008 From: collardfelszkw at gmail.com (collardfelszkw at gmail.com) Date: Sun, 20 Apr 2008 13:32:59 -0700 (PDT) Subject: jennifer aniston paul sculfor Message-ID: <989eef80-b825-44ac-80dc-c1176e038444@l28g2000prd.googlegroups.com> Just few link on some Movies Movies: http://Jennifer-Aniston.12w.net F R E E C E L E B R I T Y M O V I E S From steve at holdenweb.com Tue Apr 8 15:35:30 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 15:35:30 -0400 Subject: Google App Engine In-Reply-To: References: Message-ID: Duncan Booth wrote: [...] > Yes, it says you can use almost any Python web framework but django is the > preferred one. > > Some of the comments at > http://www.techcrunch.com/2008/04/07/google-jumps-head-first-into-web-services-with-google-app-engine/ > sound kind of upset, e.g.: "Python will be a deal breaker for many?" > or "Python only. What a weird decision. Not business and community-friendly at all." Right, but that's people for you. If you watch the announcement video Guido specifically says that other languages will be supported and Python is merely the first. That decision wasn't Guido's, either. But people will always prefer complaining on the grounds of insufficient information to keeping quiet on the basis of knowledge. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From skanemupp at yahoo.se Sun Apr 20 18:36:12 2008 From: skanemupp at yahoo.se (globalrev) Date: Sun, 20 Apr 2008 15:36:12 -0700 (PDT) Subject: close GUI and quit script? Message-ID: how do i close a GUI and end the mainloop of the script? From stef.mientki at gmail.com Mon Apr 28 12:29:38 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Mon, 28 Apr 2008 18:29:38 +0200 Subject: class or class-instance ? In-Reply-To: <67ld5cF2jm4mjU1@mid.uni-berlin.de> References: <67ld5cF2jm4mjU1@mid.uni-berlin.de> Message-ID: <4815FB72.2030904@gmail.com> > > There is a > > isclass > > in the module inspect. > > Diez thanks Diez, that's exactly what I was looking for. cheers, Stef From mail at nospam.glenstark.net Fri Apr 18 06:32:10 2008 From: mail at nospam.glenstark.net (glen stark) Date: 18 Apr 2008 12:32:10 +0200 Subject: What can we do about all the spam that the list is getting? References: <259ab201-9d2b-4e4e-88a7-e2fe277f0066@a23g2000hsc.googlegroups.com> Message-ID: <480878aa$1_6@news.bluewin.ch> On Thu, 17 Apr 2008 13:30:18 -0500, Grant Edwards wrote: > When using Google Groups can one kill all posts made via Google Groups? > Presuming he has no burning need to see his own posts (something that > can't be said for everybody in the history of Usenet), it might still be > a viable approach. The problem is, if we had followed that advice, none of us would have seen his post. From phil at freehackers.org Tue Apr 1 08:56:15 2008 From: phil at freehackers.org (BlueBird) Date: Tue, 1 Apr 2008 05:56:15 -0700 (PDT) Subject: Using QSystemTrayIcon with PyQt References: <76680315-cadd-42ad-942c-3e89536819df@i12g2000prf.googlegroups.com> <6d0b8776-bb64-4a58-8ccb-46efa35d75a2@s50g2000hsb.googlegroups.com> <1a8a5b03-0b9e-49de-bd87-43fa1aa99dc2@b5g2000pri.googlegroups.com> <6b732135-a488-4175-889b-0cccf5f0c581@s8g2000prg.googlegroups.com> Message-ID: On Apr 1, 6:00 am, Alex Teiche wrote: > On Mar 31, 7:53 pm, Benjamin wrote: > > > > > On Mar 31, 8:41 pm, Alex Teiche wrote: > > > > On Mar 31, 6:40 pm, Alex Teiche wrote: > > > > > On Mar 31, 11:49 am, Alex Teiche wrote: > > > > > > On Mar 30, 3:50 pm, Benjamin wrote: > > > > > > > On Mar 29, 11:02 pm, Alex Teiche wrote:> Hello, > > > > > > > > I am pretty new to Python, and have never learned C++. I am trying to > > > > > > > implement the following thing into my python application: > > > > > > > >http://doc.trolltech.com/4.3/qsystemtrayicon.html > > > > > > > > Through PyQt. I have been using PyQt for awhile and I know how do use > > > > > > > it, but I could not get this specific thing to work. Can someone give > > > > > > > me some hints as to get it working in Python? > > > > > > > What problems are you having? > > > > > > > > Thanks a ton, > > > > > > > > Alex > > > > > > Thanks everyone for your help. I found the example to be particularly > > > > > helpful, and I have made a simplified version just to display an icon > > > > > with a quit button in its menu. Once I know how to do that I will > > > > > incorporate it into my larger program, with more options and the > > > > > ability show messages. The problem is, it doesn't work, and I can't > > > > > find out what's wrong. Can you give me some hints? > > > > > > Here is the code: > > > > > import sys > > > > > from PyQt4 import QtGui, QtCore > > > > > > class trayIcon(QtGui.QWidget): > > > > > def __init__(self, parent=None): > > > > > QtGui.QWidget.__init__(self, parent) > > > > > > #********Create Actions for the Tray Menu********# > > > > > self.quitAction = QtGui.QAction(self.tr("&Quit"), self) > > > > > QtCore.QObject.connect(self.quitAction, > > > > > QtCore.SIGNAL("triggered()"), QtGui.qApp, QtCore.SLOT("quit()")) > > > > > > create_tray_icon() > > > > > > self.composeAction.setEnabled(visible) > > > > > QtGui.QWidget.setVisible(self, visible) > > > > > > self.trayIcon.show() > > > > > > def create_tray_icon(self): > > > > > self.trayIconMenu = QtGui.QMenu(self) > > > > > self.trayIconMenu.addAction(self.composeAction) > > > > > self.trayIcon = QtGui.QSystemTrayIcon(self) > > > > > self.trayIcon.setContextMenu(self.trayIconMenu) > > > > > self.trayIcon.setIcon(bad.svg) > > > > > > app = QtGui.QApplication(sys.argv) > > > > > sys.exit(app.exec_()) > > > > > OK, I messed around with it some more, and it works. I just don't > > > > know how to set an icon, and the example doesn't help at all. > > > > > Here is the code: > > > > import sys > > > > from PyQt4 import QtCore, QtGui > > > > > class Systray(QtGui.QWidget): > > > > def __init__(self): > > > > QtGui.QWidget.__init__(self) > > > > > self.createActions() > > > > self.createTrayIcon() > > > > > #QtCore.QObject.connect(self.trayIcon, > > > > QtCore.SIGNAL("messageClicked()"), self.messageClicked) > > > > #QtCore.QObject.connect(self.trayIcon, > > > > QtCore.SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), > > > > self.iconActivated) > > > > > self.trayIcon.show() > > > > > def createActions(self): > > > > #self.minimizeAction = QtGui.QAction(self.tr("Mi&nimize"), self) > > > > #QtCore.QObject.connect(self.minimizeAction, > > > > # QtCore.SIGNAL("triggered()"), self, QtCore.SLOT("hide()")) > > > > > #self.maximizeAction = QtGui.QAction(self.tr("Ma&ximize"), self) > > > > #QtCore.QObject.connect(self.maximizeAction, > > > > # QtCore.SIGNAL("triggered()"), self, > > > > # QtCore.SLOT("showMaximized()")) > > > > > #self.restoreAction = QtGui.QAction(self.tr("&Restore"), self) > > > > #QtCore.QObject.connect(self.restoreAction, > > > > # QtCore.SIGNAL("triggered()"), self, > > > > # QtCore.SLOT("showNormal()")) > > > > > self.quitAction = QtGui.QAction(self.tr("&Quit"), self) > > > > QtCore.QObject.connect(self.quitAction, QtCore.SIGNAL("triggered()"), > > > > QtGui.qApp, QtCore.SLOT("quit()")) > > > > > def createTrayIcon(self): > > > > self.trayIconMenu = QtGui.QMenu(self) > > > > #self.trayIconMenu.addAction(self.minimizeAction) > > > > #self.trayIconMenu.addAction(self.maximizeAction) > > > > #self.trayIconMenu.addAction(self.restoreAction) > > > > #self.trayIconMenu.addSeparator() > > > > self.trayIconMenu.addAction(self.quitAction) > > > > > self.trayIcon = QtGui.QSystemTrayIcon(self) > > > > self.trayIcon.setContextMenu(self.trayIconMenu) > > > > > app = QtGui.QApplication(sys.argv) > > > > x = Systray() > > > > sys.exit(app.exec_()) > > > > > How would I go about setting the icon? > > > > Sorry, here is the code with commented out lines removed: > > > > import sys > > > from PyQt4 import QtCore, QtGui > > > > class Systray(QtGui.QWidget): > > > def __init__(self): > > > QtGui.QWidget.__init__(self) > > > > self.createActions() > > > self.createTrayIcon() > > > > self.trayIcon.show() > > > > def createActions(self): > > > > self.quitAction = QtGui.QAction(self.tr("&Quit"), self) > > > QtCore.QObject.connect(self.quitAction, QtCore.SIGNAL("triggered()"), > > > QtGui.qApp, QtCore.SLOT("quit()")) > > > > def createTrayIcon(self): > > > self.trayIconMenu = QtGui.QMenu(self) > > > self.trayIconMenu.addAction(self.quitAction) > > > > self.trayIcon = QtGui.QSystemTrayIcon(self) > > > self.trayIcon.setContextMenu(self.trayIconMenu) > > > > app = QtGui.QApplication(sys.argv) > > > x = Systray() > > > sys.exit(app.exec_()) > > > I believe the method you want is QSystemTrayIcon.setIcon. > > I found that, but what do I pass into it? Passing a string to a .svg > file doesn't work. http://www.riverbankcomputing.com/Docs/PyQt4/html/qsystemtrayicon.html#setIcon So, you must pass a QIcon. Now, the doc of QIcon: http://www.riverbankcomputing.com/Docs/PyQt4/html/qicon.html Oh, the list of supported file format is described separately in: http://www.riverbankcomputing.com/Docs/PyQt4/html/qimagereader.html#supportedImageFormats I see that svg is not part of that list. So, it is not surprising that it does not work but there are plenty of other formats that will work. It took me about 20 seconds to solve your problem by reading the appropriate documentation. I suggest you do that too in the future... regards, Philippe From gagsl-py2 at yahoo.com.ar Sun Apr 20 12:04:51 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 13:04:51 -0300 Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> Message-ID: En Sun, 20 Apr 2008 10:32:36 -0300, Banibrata Dutta escribi?: > On 4/20/08, Gabriel Genellina wrote: >> >> En Sun, 20 Apr 2008 01:55:51 -0300, Banibrata Dutta < >> banibrata.dutta at gmail.com> escribi?: >> >> > Wanted to check if there is any known, reliable, FOSS/Libre -- >> Obfurscator >> > for Python 2.5 code. >> >> Why do you want to do that in the first place? > > > I need to do to retain the confidentiality for certain core components, > which are not supposed to be open. While I do have the option of > implementing them in C/C++, I'm trying to see if I can avoid that for 2 > reasons -- > 1. Its a fairly large and complex set of components, and doing it in C/C++ > 'might' take significantly longer. > 2. I'd try to avoid having mix of languages if possible. It makes the > developement easier to maintain/manage over a period of time. > > There is very few you can do to obfuscate Python code. You can't rename >> classes nor methods nor global variables nor argument names due to the >> dynamic nature of Python. All you can safely do is to remove comments and >> join simple statements using ; > > > I do not understand the nuances of dynamic languages completely, so this > might be a foolish assumption, but if i make a complete, self-contained > Python application (collection of modules), then just before shipping a > production copy, why can't I replace 'all' symbols i.e. classes, methods, > variables etc ? Esply if I'm compiling the source ? Because *any* string can be used to retrieve an attribute, it is not easy to replace *every* occurence of an attribute name (the code may use arbitrary expressions with getattr). The code may contain external references to class names (e.g. pickles, logging config files) that must be kept; also code that uses exec/eval will not find the referenced objects. Even local names are necesary in some cases like "%(some)s %(format)d" % locals(). > If you remove docstrings, some things may break. Even renaming local >> variables isn't safe in all cases. > > Hmmm... but I'm aware of atleast 2 Obfuscators one commercial and one FOSS, > that seem to exist for Python. The commercial one is what I might try if I > don't find anything FOSS. The FOSS one seems to be a dead project. If they > are (or have been) there, I guess obfuscation is a doable thing, no ? Sure, it can be done - with a lot of care, and I'm sure *some* code will fail. You may distribute compiled .pyc files - that's enough for most people who cares at all. Paranoids use a modified version of the interpreter incompatible with the standard one. In any case, bug reports (including tracebacks) are less valuable and harder to read. -- Gabriel Genellina From tinnews at isbd.co.uk Thu Apr 10 16:50:51 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 10 Apr 2008 20:50:51 GMT Subject: How to find documentation about methods etc. for iterators References: <47fce941$0$755$bed64819@news.gradwell.net> <47fdceb8$0$754$bed64819@news.gradwell.net> Message-ID: <47fe7dab$0$757$bed64819@news.gradwell.net> Terry Reedy wrote: > > wrote in message > news:47fdceb8$0$754$bed64819 at news.gradwell.net... > | Terry Reedy wrote: > | > > | > wrote in message > | > news:47fce941$0$755$bed64819 at news.gradwell.net... > | > | I'm not sure if I have even phrased that right but anyway.... > | > | > | > | How does one find (in the standard Python documentation) information > | > | about things like the iteritems() method and the enumerate() > function. > | > > | > The Library Reference manual sections on builtin functions and dict > | > methods. > | > > | > Or, help(enumerate) and help({}.iteritems) > | > > | .... but that doesn't address my problem really, how do I know that I > | need to look for the words enumerate and/or iteritems? This is what > | my original question was about. > > Do what Gabriel said: read chapters 2 and 3 of the Lib Manual. You will > not necessarily remember everything, but you will have an idea of what > functionalities exist and know to go look again. In a few months, read > them again. > > As for the stdlib, at least scan through the table of contents so you have > a general idea of what there is. The documentation of modules (as well as > of builtins) is much improved from 10 years ago, when the only doc for some > was the code. > OK, thanks all for the replies. I know I will get more familiar with what's available as I use Python more. I have the O'Reilly "Python in a Nutshell" which I use for basic reference, with the helpful replies in this thread I should be able to find my way. -- Chris Green From bloqueador.rastreador at localizador.gps.com Fri Apr 4 17:49:33 2008 From: bloqueador.rastreador at localizador.gps.com (bloqueador sem mensalidade) Date: Fri, 4 Apr 2008 18:49:33 -0300 Subject: 455 bloqueador veicular sem mensalidades - =?ISO-8859-1?Q?http://bloqueadorgsm.vilabol.uol.com.br=11?= 4555333208173502757727274 Message-ID: Bloqueador ve?cluar com tecnologia gsm - Sem mensalidades Tenha toda seguran?a para seu carro com um pre?o justo. Apenas R$ 299,00 ( sem mensalidades ) http://bloqueadorgsm.vila.bol.com.br/ Compare e Compre. Rastreador de Ve?culo Rastreadores de Ve?culos Rastreador GPS Rastreadores GPS Rastreador Ituran Rastreadores Ituran Rastreador Port?til Rastreadores Port?teis. Assist?ncia 24 Horas Visite agora mesmo nosso site. http://bloqueadorgsm.vila.bol.com.br/ Graber - Teletrim - Tele Trim - Ituran - Rastreadores gps , Localizadores, Bloqueadores Graber - Teletrim - Tele Trim - Ituran - Rastreadores gps , Localizadores, Bloqueadores Graber - Teletrim - Tele Trim - Ituran - Rastreadores gps , Localizadores, Bloqueadores Graber - Teletrim - Tele Trim - Ituran - Rastreadores gps , Localizadores, Bloqueadores Graber - Teletrim - Tele Trim - Ituran - Rastreadores gps , Localizadores, Bloqueadores HTigfm&n(>'qai?5"!Co'IuTsX.5APO=7\pcuWJ6 From duncan.booth at invalid.invalid Tue Apr 22 13:45:45 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 22 Apr 2008 17:45:45 GMT Subject: Lists: why is this behavior different for index and slice assignments? References: <480d435b$0$11643$607ed4bc@cv.net> Message-ID: Steve Holden wrote: > Assignment to a list *element* rebinds the single element to the > assigned value. Assignment to a list *slice* has to be of a list, and it > replaces the elements in the slice by assigned elements. > Assignment to a list *slice* just has use an iterable, it doesn't actually have to be another list. From ni at hao.com Wed Apr 30 04:51:54 2008 From: ni at hao.com (SL) Date: Wed, 30 Apr 2008 10:51:54 +0200 Subject: computing with characters In-Reply-To: References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl><481813E2.2030302@islandtraining.com><61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> Message-ID: <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> "Gabriel Genellina" schreef in bericht news:mailman.365.1209541507.12834.python-list at python.org... > En Wed, 30 Apr 2008 04:19:22 -0300, SL escribi?: > And that's a very reasonable place to search; I think chr and ord are > builtin functions (and not str methods) just by an historical accident. > (Or is there any other reason? what's wrong with "a".ord() or > str.from_ordinal(65))? yes when you know other OO languages you expect this. Anyone know why builtins were chosen? Just curious > > -- > Gabriel Genellina > From mnordhoff at mattnordhoff.com Thu Apr 3 10:42:05 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Thu, 03 Apr 2008 14:42:05 +0000 Subject: How easy is it to install python as non-root user? In-Reply-To: <47f4e617$0$720$bed64819@news.gradwell.net> References: <47f4e617$0$720$bed64819@news.gradwell.net> Message-ID: <47F4ECBD.504@mattnordhoff.com> tinnews at isbd.co.uk wrote: > Does python install fairly easily for a non-root user? > > I have an ssh login account onto a Linux system that currently > provides Python 2.4.3 and I'd really like to use some of the > improvements in Python 2.5.x. > > So, if I download the Python-2.5.2.tgz file is it just the standard:- > > ./configure --prefix=$HOME > make > make install It is easy, but on an oldish Debian box, I ran into problems where the headers for some libraries weren't available, so my Python install didn't support readline or bzip2 (or perhaps other things too). -- From jgardner at jonathangardner.net Tue Apr 8 12:24:57 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Tue, 8 Apr 2008 09:24:57 -0700 (PDT) Subject: Python 3.0 new integer division References: Message-ID: On Apr 8, 9:13?am, "Hutch" wrote: > We now have a float result when two integers are divided in the same mannor > as 2.4 or 2.5. > I can handle that and use the Floor division but a simple question. > > Why in the world would you round down the last presented digit to a 6 > instead of just leaving it along as an 8. > For some reason rounding down for a float in Python does not seem correct. > > IDLE 3.0a4 > > >>> 12345678901234567890123456789012345678901234567890/345 > > 3.5784576525317586e+46 > > >>> 12345678901234567890123456789012345678901234567890//345 > > 35784576525317588087314367504383610663481839327 > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^| > 35784576525317586000000000000000000000000000000 ?== 3.5784576525317586e+46 Floats are weird that way. Part of the problem is you are representing a decimal number (base 10) in binary (base 2). The other part is that you can't increment floats by a very tiny amount. In other words, a + b = a for floats when b is sufficiently small but not zero. Blame floats, not Python. If you want precision with fractions, you should be using the Decimal type, which uses a rational. A rational, if you recall from your math classes, is one integer divided by another. From kayvoo at googlemail.com Sat Apr 19 14:41:14 2008 From: kayvoo at googlemail.com (Karl-Heinz Ruskowski) Date: Sat, 19 Apr 2008 20:41:14 +0200 Subject: Issue with inspect module In-Reply-To: <2e5e2d31-2adc-4416-a993-19bc05a512bd@w8g2000prd.googlegroups.com> References: <2e5e2d31-2adc-4416-a993-19bc05a512bd@w8g2000prd.googlegroups.com> Message-ID: <200804192041.14425.kayvoo@gmail.com> > Why does the inspect module cause the output > to be printed twice? I also tested it, no problem here either. From s0suk3 at gmail.com Wed Apr 16 16:35:09 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Wed, 16 Apr 2008 13:35:09 -0700 (PDT) Subject: str class inheritance prob? References: <874eed0f-eeeb-4434-8a14-a3b29801a5f6@d26g2000prg.googlegroups.com> Message-ID: <5a6531dc-b8f9-4fda-b4fe-0341eeaf12b6@a9g2000prl.googlegroups.com> On Apr 16, 1:43 pm, jka... at gmail.com wrote: > so I?m trying to create a class that inherits from str, but I want to > run some code on the value on object init. this is what I have: > > class Path(str): > def __init__( self, path ): > clean = str(path).replace('\\','/') > while clean.find('//') != -1: > clean = clean.replace('//','/') > > print 'cleaned on init:\t',clean > self = clean > > so clearly the clean variable is what I want value of the string to > be, but that?s decidedly not the case. so running this: > > a=Path('path///with\\nasty/////crap_in_it/') > print a > > gives me this: > > cleaned on init: path/with/nasty/crap_in_it/ > path///with\nasty/////crap_in_it/ > > what gives? what am I doing wrong, and can I do what I?m trying to > here? > thanks. Regardless of the problem you have initializing the class, why do you need to inherit from str? Actually, why do you even need a class? Unless you're dealing something more complex that you didn't mention here, that should be just a simple function. From andrew at acooke.org Thu Apr 17 17:46:59 2008 From: andrew at acooke.org (andrew cooke) Date: Thu, 17 Apr 2008 14:46:59 -0700 (PDT) Subject: Metaprogramming Example References: <930643c6-2d56-4fb0-aee0-a3e79231f09b@24g2000hsh.googlegroups.com> <32472b97-f35a-4408-96f5-2f8c8f92ae56@m73g2000hsh.googlegroups.com> <39325652-e0cf-4efd-9b28-00c0fe8552cc@m73g2000hsh.googlegroups.com> Message-ID: <562bae18-7b8e-4863-8923-0e5a01ba7125@t54g2000hsg.googlegroups.com> bruno: > Ho, and yes : one day, you'll get why it's such a good thing to unite > functions and methods !-) me: > PS Is there anywhere that explains why Decorators (in the context of > functions/methods) are so good? I've read lots of things saying they > are good, but no real justification of why. in the text above i wrote "Decorators" rather than "Descriptors". it was in response to bruno's comment, also above. sorry for the confusion. also, sorry for the inflammatory language - by referring to the titanic i didn't mean that python was a disaster, rather that the "iceberg" is still there (i am not 100% sure what the iceberg is, but it's something to do with making namespaces explicit in some places and not others). anyway, it was only a small point. thanks for all the replies. didn't respond earlier as i was at work. now i can go back and polish that code... andrew From tkpmep at hotmail.com Fri Apr 11 12:47:15 2008 From: tkpmep at hotmail.com (tkpmep at hotmail.com) Date: Fri, 11 Apr 2008 09:47:15 -0700 (PDT) Subject: Cannot start RPy - need win32api Message-ID: I'm running Python 2.5.2 on Windows XP and need to interface with R, so I downloaded the R 2.6.2 statistical package and installed it, and did the same for RPy 1.02 (i made sure I got the version for Python 2.5 and R 2.62.). When I go to the Python command line and type >>> from rpy import * I get the following error message: Traceback (most recent call last): File "", line 1, in from rpy import * File "C:\Python25\lib\site-packages\rpy.py", line 88, in import win32api ImportError: No module named win32api >>> What on earth is win32api, where can I find it, and where ought I to put it? Thanks in advance Thomas Philips From lists at cheimes.de Sat Apr 12 08:44:44 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 12 Apr 2008 14:44:44 +0200 Subject: str(bytes) in Python 3.0 In-Reply-To: References: Message-ID: <4800AEBC.5060307@cheimes.de> Gabriel Genellina schrieb: > On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') > above. But I get the same as repr(x) - is this on purpose? Yes, it's on purpose but it's a bug in your application to call str() on a bytes object or to compare bytes and unicode directly. Several months ago I added a bytes warning option to Python. Start Python as "python -bb" and try it again. ;) Christian From aldo at nullcube.com Tue Apr 1 21:16:16 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Wed, 2 Apr 2008 12:16:16 +1100 Subject: ANN: pry unit testing framework Message-ID: <20080402011616.GA21488@nullcube.com> We are happy to announce the first release of Pry, a unit testing framework. Features ======== * Built-in coverage analysis, profiling, and quick-and-dirty benchmarking * Assertion-based tests - no ugly failUnless*, failIf*, etc. methods * Tree-based test structure for better fixture management * No implicit instantiation of test suits * Powerful command-line interface Download: http://dev.nullcube.com Manual: http://dev.nullcube.com/doc/pry/index.html -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From paddy3118 at googlemail.com Wed Apr 9 01:54:55 2008 From: paddy3118 at googlemail.com (Paddy) Date: Tue, 8 Apr 2008 22:54:55 -0700 (PDT) Subject: Can C.L.P.handle the load? References: <3b6737c8-9d42-4218-ac60-01df2f578746@p39g2000prm.googlegroups.com> Message-ID: <9bd25fd3-5133-4165-9784-fbbc21145810@24g2000hsh.googlegroups.com> On Apr 8, 7:51 pm, Berco Beute wrote: > It's wonderful news for Python. It will definitely be a boost for > Python's (and Django's) popularity. Python finally seems to be on > every developers mind at the moment. Looks like it's showtime for > Python! I'm waiting for the rush of new users to c.l.p :-) If it comes, then aren't regularly posted FAQ's newbie friendly? Is their a good FAQ already around that we can regularly point newbies to? What else could we do to make c.l.p. of more use to the newbie whp may also be new to usenet whilst keeping c.l.p a usefull place for all? - Paddy. From afandimscit at gmail.com Mon Apr 21 07:10:39 2008 From: afandimscit at gmail.com (afandi) Date: Mon, 21 Apr 2008 04:10:39 -0700 (PDT) Subject: How to insert multiple rows in SQLite Dbase References: <50faeed7-775f-4e12-8131-21a95b5f91a8@e6g2000prf.googlegroups.com> <657h3nF2eehi8U1@mid.uni-berlin.de> Message-ID: <7e579f34-9c2c-4a3d-a438-77cb7f30803a@v23g2000pro.googlegroups.com> On Apr 1, 12:22 am, afandi wrote: > On Mar 30, 4:46 am, Gerhard H?ring wrote: > > > > > Gabriel Genellina wrote: > > > [...] > > > and execute: > > > cur.executemany("insert into log (IP, EntryDate, Requestt, ErrorCode) > > > values (:ip, :date, :request, :errorcode)", values) > > > It's probably worth mentioning that pysqlite's executemany() accepts > > anything iterable for its parameter. So you don't need to build a list > > beforehand to enjoy the performance boost of executemany(). > > > The deluxe version with generators could look like this: > > > def parse_logfile(): > > logf = open(...) > > for line in logf: > > if ...: > > row = (value1, value2, value3) > > yield row > > logf.close() > > > ... > > > cur.executemany("insert into ... values (c1, c2, c3)", parse_logfile()) > > > -- Gerhard > > > PS: pysqlite internally has a statement cache since verson 2.2, so > >multipleexecute() calls are almost as fast as executemany(). > > Thanks regards to your suggestion, but I don't understand why we have > to put the IF statement? I have the solution.Thanks split it using REgex to [] [] [] parse to Database From bruno.42.desthuilliers at websiteburo.invalid Mon Apr 21 04:35:51 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Mon, 21 Apr 2008 10:35:51 +0200 Subject: manipulating class attributes from a decorator while the class is being defined In-Reply-To: References: Message-ID: <480c51e7$0$15329$426a74cc@news.free.fr> Wilbert Berendsen a ?crit : > Hi, is it possible to manipulate class attributes from within a decorator > while the class is being defined? > > I want to register methods with some additional values in a class attribute. > But I can't get a decorator to change a class attribute while the class is > still being defined. Something like: > > class Parser(object): > > regexps = [] > def reg(regexp): > def deco(func): > regexps.append((regexp, func)) > return func > return deco > > @reg(r'".*"') > def quoted_string(self): > pass > > How can I reach the class attribute `regexps' from within a decorator? Simple answer : you can't. Because, as you noticed, the class object doesn't exist yet. The canonical solutions are either to store regexps outside the class (ie: as a module level variable) - which can be problematic in some cases -, or to use a two-pass scheme using a decorator and a metaclass, where the decorator annotate the function with required informations for latter processing, and the metaclass do the effective processing. There are of course other solutions, some of them possibly simpler. The 'best' solution of course depends on intented use of your class... HTH From jzshao1 at gmail.com Fri Apr 11 17:29:36 2008 From: jzshao1 at gmail.com (Jonathan Shao) Date: Fri, 11 Apr 2008 17:29:36 -0400 Subject: Question on threads In-Reply-To: <47FFBC05.50309@holdenweb.com> References: <47FFBC05.50309@holdenweb.com> Message-ID: On Fri, Apr 11, 2008 at 3:29 PM, Steve Holden wrote: > Jonathan Shao wrote: > > > Hi all, > > I'm a beginner to Python, so please bear with me. > > Is there a way of guarenteeing that all created threads in a program > > are finished before the main program exits? I know that using join() can > > guarentee this, but from the test scripts I've run, it seems like join() > > also forces each individual thread to terminate first before the next thread > > can finish. So if I create like 20 threads in a for loop, and I join() each > > created thread, then join() will in effect cause the threads to be executed > > in serial rather than in parallel. > > > > > No it won't, as in fact there is no mechanism to force a thread to > terminate in Python. When you join() each created thread the main thread > will wait for each thread to finish. Supposing the longest-lived thread > finished first then all others will immediately return from join(). > > The only requirement it is imposing is that all sub-threads must be > finished before the main thread terminates. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > I guess I'm doing something wrong with join(). Here's a test script I wrote up... import threading import time class TestThread(threading.Thread): def __init__(self, region): self.region = region threading.Thread.__init__(self) def run(self): for loop in range(10): print "Region " + str(self.region) + " reporting: " + str(loop) time.sleep(2) for x in range(10): thr = TestThread(x) thr.start() thr.join() raw_input() In this script thread 0 will finish first... Am I doing something wrong with join()? -------------- next part -------------- An HTML attachment was scrubbed... URL: From simone.brunozzi at gmail.com Tue Apr 8 05:10:01 2008 From: simone.brunozzi at gmail.com (Simone Brunozzi) Date: Tue, 8 Apr 2008 02:10:01 -0700 (PDT) Subject: Looking for Conferences/Events on Django, Python, MySQL, etc in Europe 2008? Message-ID: <7fb0f408-1a2e-4ee1-a179-092f83eb1591@8g2000hsu.googlegroups.com> Greetings! I'm looking for conferences or events about Python, Django, Dabatases, Mysql, PHP, Ruby in Europe (or nearby locations like north africa and middle east) in 2008. Do you have any suggestions? Thanks a lot! From python at bdurham.com Wed Apr 9 13:50:28 2008 From: python at bdurham.com (Malcolm Greene) Date: Wed, 09 Apr 2008 13:50:28 -0400 Subject: Parsing locale specific dates, currency, numbers In-Reply-To: <16651e80804091031u5fc752e6s90b54c8675108088@mail.gmail.com> References: <42b9a3ff0804091004s4d60751fh68c82673e8e3f4c3@mail.gmail.com> <16651e80804091031u5fc752e6s90b54c8675108088@mail.gmail.com> Message-ID: <1207763428.21865.1246989365@webmail.messagingengine.com> The locale module provides the ability to format dates, currency and numbers according to a specific locale. Is there a corresponding module for parsing locale's output to convert locale formatted dates, currency, and numbers back to their native data types on the basis of a specified locale? In other words, a module that will reverse the outputs of locale on a locale specific basis. Thanks! Malcolm From martin at v.loewis.de Sun Apr 27 13:33:56 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 27 Apr 2008 19:33:56 +0200 Subject: Tremendous slowdown due to garbage collection In-Reply-To: References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: <4814B904.1070804@v.loewis.de> > Martin said it but nevertheless it might not be true. > > We observed similar very bad behaviour -- in a Web application server. > Apparently, the standard behaviour is far from optimal when the > system contains a large number of objects and occationally, large > numbers of objects are created in a short time. > We have seen such behaviour during parsing of larger XML documents, for > example (in our Web application). I don't want to claim that the *algorithm* works for all typically applications well. I just claim that the *parameters* of it are fine. The OP originally proposed to change the parameters, making garbage collection run less frequently. This would a) have bad consequences in terms of memory consumption on programs that do have allocation spikes, and b) have no effect on the asymptotic complexity of the algorithm in the case discussed. It may well be that other algorithms would perform better, but none have been contributed. Regards, Martin From tpatch at loftware.com Wed Apr 16 09:50:44 2008 From: tpatch at loftware.com (tpatch at loftware.com) Date: Wed, 16 Apr 2008 09:50:44 -0400 Subject: RotatingFileHandler - ShouldRollover error Message-ID: <4ECBD915C6F1254AB1AFF4B9F08287B2176F4253C0@loftexchange.loftwareinc.com> I am using the RotatingFileHandler logger with Python 2.5 on Windows and I am getting an error on the rollover. When the log file gets close to the size where it needs to rollover, I start getting the following error for every log message. Does anyone have a solution to this problem? Traceback (most recent call last): File "C:\Python25\Lib\logging\handlers.py", line 73, in emit if self.shouldRollover(record): File "C:\Python25\Lib\logging\handlers.py", line 147, in shouldRollover self.stream.seek(0, 2) #due to non-posix-compliant Windows feature ValueError: I/O operation on closed file My configuration file is setup as such: [handler_file_detailed] class:handlers.RotatingFileHandler level:DEBUG formatter:detailed mode=a maxsize=4000000 backcount=5 args:('python.log','a',4000000,5) Thanks, Todd -------------- next part -------------- An HTML attachment was scrubbed... URL: From fn681 at ncf.ca Tue Apr 1 07:20:54 2008 From: fn681 at ncf.ca (Colin J. Williams) Date: Tue, 01 Apr 2008 07:20:54 -0400 Subject: Is this a good time to start learning python? In-Reply-To: References: <47f1140e$0$735$a729d347@news.telepac.pt> Message-ID: Terry Reedy wrote: > "Rui Maciel" wrote in message > news:47f1140e$0$735$a729d347 at news.telepac.pt... > | Recently I woke up inclined to take up the task of learning another > | programming language. I've already dipped my toes in Perl (I've read > online > | tutorials and wrote a couple of irrelevant pet projects) but, as the > | computers at my workplace only sport the python interpreter, it probably > | means that learning python will end up serving me better, at least in the > | short run. Plus, you know how Perl goes. > > If you intend to use Python on the computer at your workplace, then learn > the version installed there. > > | So far the decision seems to be a no brainer. Yet, Python 3000 will > arrive > | in a few months. As it isn't backwards compatible with today's Python, > | there is the risk that no matter what I learn until then, I will end up > | having to re-learn at least a considerable part of the language. > > Most of the changes are deletions and additions, rather than changes. > > 3.0a4 will be out in a few days. If you had no reason to use anything > else, I would consider starting with that. (But the IDLE IDE on Windows > may still not work right.) Replace IDLE by PyScripter and then you have a good development environment for Python 3000. Colin W. > > | To put it in other words, I fear that I will be wasting my time. > > If you learn and use 2.x, then avoid things that are going away. In > particular: > > Unless you need to learn about old-style classes, I would not bother with > them and the differences from new, soon to be the only style, classes. > Derive all your classes from object or a subclass thereof. > > Use // for integer floor division (ie, when you want 1/2 == 0. > Use 'from __future__ import division' if you use '/' in a file where both > operands > might be ints and you would want 1/2==.5. > > | At least that is what a clueless newbie believes. As this group is > | frequented by people who have more insight into all things pythonesque, > | what are your thoughts on this? > > Diverse, I am sure ;-) > > Terry Jan Reedy > > > From stef.mientki at gmail.com Wed Apr 23 19:03:58 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Thu, 24 Apr 2008 01:03:58 +0200 Subject: Python script to automate use of Google Translate? (or other translator) In-Reply-To: <87D3F9C72FBF214DB39FA4E3FE618CDC6E243C7BF2@EXMBX04.exchhosting.com> References: <87D3F9C72FBF214DB39FA4E3FE618CDC6E243C7BF2@EXMBX04.exchhosting.com> Message-ID: <480FC05E.2030202@gmail.com> Trent Nelson wrote: >>> I have the need to occasionally translate a single word >>> programatically. Would anyone have a Python script that >>> would let me do this using Google (or another) translation >>> service? >>> > > As a matter of fact, yes, I do! This happens to be my most favourite piece of Python code I've ever written, too... > thanks Trent, that's really beautiful !! cheers, Stef From JesseAldridge at gmail.com Sun Apr 6 00:43:29 2008 From: JesseAldridge at gmail.com (Jesse Aldridge) Date: Sat, 5 Apr 2008 21:43:29 -0700 (PDT) Subject: Python Data Utils Message-ID: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> In an effort to experiment with open source, I put a couple of my utility files up here. What do you think? From knight at baldmt.com Sat Apr 19 00:28:37 2008 From: knight at baldmt.com (Steven Knight) Date: Fri, 18 Apr 2008 21:28:37 -0700 Subject: ANNOUNCE: SCons 0.98.1 (candidate for 1.0) is now available Message-ID: SCons is a software construction tool (build tool, or make tool) written in Python. It is based on the design which won the Software Carpentry build tool competition in August 2000. Version 0.98.1 of SCons has been released and is now available at the SCons download page: http://www.scons.org/download.php RPM and Debian packages and a Win32 installer are all available, in addition to the traditional .tar.gz and .zip files. This release is considered a candidate for the (long-awaited) official 1.0 SCons release. We welcome and encourage widespread testing and use of this release to try to identify any problems. Please report your bugs following the guidelines at: http://scons.tigris.org/bug-submission.html WHAT'S NEW IN THIS RELEASE? This release contains a huge number of new features, fix, performance improvements, and other changes since the last widely-publicized release (0.97, last year). For a description of important changes that affect upgrading and backwards compatibility, please see our release notes: http://scons.tigris.org/RELEASE.txt For a very complete list of changes, please see our change log: http://scons.tigris.org/CHANGES.txt ABOUT SCONS Distinctive features of SCons include: - a global view of all dependencies; no multiple passes to get everything built properly - configuration files are Python scripts, allowing the full use of a real scripting language to solve difficult build problems - the ability to scan files for implicit dependencies (#include files); - improved parallel build (-j) support that provides consistent build speedup regardless of source tree layout - use of MD5 signatures to decide if a file has really changed; no need to "touch" files to fool make that something is up-to-date - easily extensible through user-defined Builder and Scanner objects - build actions can be Python code, as well as external commands A scons-users mailing list is available for those interested in getting started using SCons. You can subscribe by sending email to: users-subscribe at scons.tigris.org Alternatively, we invite you to subscribe to the (very) low-volume scons-announce mailing list to receive notification when new versions of SCons become available: announce-subscribe at scons.tigris.org On behalf of the SCons team, --SK From s0suk3 at gmail.com Tue Apr 29 13:54:18 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Tue, 29 Apr 2008 10:54:18 -0700 (PDT) Subject: Simple import question about mac osx References: Message-ID: On Apr 29, 12:46 pm, jmDesktop wrote: > On Apr 29, 1:16 pm, jmDesktop wrote: > > > > > Hi, I have this code (learning from Core Python, Chun's book), module > > named chap2.py. > > > class FooClass(object): > > version=0.1 > > > def __init__(self, nm='John Doe'): > > self.name=nm > > print 'Created a class instance for ', nm > > def showname(self): > > print 'Your name is', self.name > > print 'My name is', self.__class__.__name__ > > > On Windows, if I compile this and then in the python interpreter type: > > > >>> import chap2 > > >>> foo1=FooClass() > > > Created a class instance for John Doe > > > If I do the same think on my Mac OS X 10.5.2 > > > NameError: name 'FooClass' is not defined. > > > I thought it was the path and did export PATH=$PATH:/mypath/ > > topythoncode > > > but it did not help. > > > What am I doing wrong? Thank you. > > forgot to say that on the mac I can do import chap2, but when I try > and instantiate I get the error above. It shouldn't work under Windows, either. You have to qualify the name of the class with the name of the module, as in chap2.FooClass(). Or you can type "from chap2 import FooClass" and then you'll be able to simply say FooClass(). From deets at nospam.web.de Fri Apr 25 09:29:49 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 25 Apr 2008 15:29:49 +0200 Subject: Calling Python code from inside php In-Reply-To: References: <679e9oF2mti63U1@mid.uni-berlin.de> <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> <679hd5F2nj6csU1@mid.uni-berlin.de> Message-ID: <67e4n4F2o0sfcU1@mid.uni-berlin.de> Nick Stinemates schrieb: >> While I certainly prefer to use Python wherever I can, that does not mean >> that there aren't cases where legacy systems or other constraints make this >> impossible. If I have e.g. a type3-based website - "how on earth" should I >> replace that with Python (without wasting a lot of time)? > > I don't understand how the 2 are mutually exclusive? > > You can have PHP and Python bindings installed on the same Apache > server, unless I'm mistaken? What about having to set up & maintain (which might not even possible on a cheap hoster) two configs for that - just for having a few lines of python being run? And how do you go about session-state sharing and so forth? After all the scipt might need to be access controlled based on login state. I don't say that there aren't options to run python more direct. I argumented against a rather bold statement of Mr. alexelder: """ A simple yet dangerous and rather rubbish solution (possibly more of a hack than a real implementation) could be achieved by using a technique described above: """ Diez From steve at holdenweb.com Wed Apr 23 00:41:17 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 00:41:17 -0400 Subject: Python Success stories In-Reply-To: References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> Message-ID: <480EBDED.5010600@holdenweb.com> Nikita the Spider wrote: > In article > <7e595409-be62-4b8c-9819-a14cd363d751 at c65g2000hsa.googlegroups.com>, > azrael wrote: > >> Which big aplications are written in python. I see its development, >> But i can't come up with a big name. I know that there are a lot of >> companys using python, but is there anythong big written only in >> python. I want him to fuck of with his perl once and for all time > > Why are either of you so emotionally attached to the tools you use? > > I don't know your friend, but my guess is that he's not interested in a > logical argument, so he won't be impressed even if you claim that God > himself wrote the Universe in Python. I think he enjoys saying this > stuff simply because you react to it. It's pretty sad that he can't find > something better to do with his time. > It's even sadder that he doesn't need to. [...] regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From skanemupp at yahoo.se Thu Apr 10 09:47:52 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 06:47:52 -0700 (PDT) Subject: tkinter, overwrite Label-text? References: Message-ID: On 10 Apr, 15:28, "Dennis.Benzin... at gmx.net" wrote: > On Apr 10, 2:35 pm, skanem... at yahoo.se wrote: > > > using python And tkinter. > > > i have a GUI that outputs a text among other things. after input form > > user i want this text to be *)cleared and/or > > *)overwritten. > > > what is the best way to achieve that? > > [...] > > Which widget do you use? > > Some widgets can be connected to variables so that when the variable > changes the widget is automatically update. > Have a look . > > HTH, > Dennis Benzinger i use the Label-widget. From Jiang.Adam at gmail.com Fri Apr 18 02:52:04 2008 From: Jiang.Adam at gmail.com (Adam) Date: Thu, 17 Apr 2008 23:52:04 -0700 (PDT) Subject: How to set proxy for a python script to run Message-ID: Hi, I am using a script written in Python. For some reasons I should pass the fireware by proxy setting. But it seems not work when I set the 'http_proxy' 'ftp_proxy' environment variable. I also expored 'HTTP_PROXY' 'FTP_PROXY', but the problem remained. How can I set proxy for it to run the script? From paddy3118 at googlemail.com Wed Apr 9 00:58:45 2008 From: paddy3118 at googlemail.com (Paddy) Date: Tue, 8 Apr 2008 21:58:45 -0700 (PDT) Subject: Sorting a List of Objects by an Attribute of the Objects Case-Insensitively References: <736fefbd-510f-40e9-8342-32b69a1a0c2a@t12g2000prg.googlegroups.com> Message-ID: <0912a817-2cdc-4a19-83d2-1d8befed4f4b@24g2000hsh.googlegroups.com> On Apr 9, 4:04 am, Jason wrote: > Hi folks-- > > Basically, I have a pressing need for a combination of 5.2 "Sorting a > List of Strings Case-Insensitively" & 5.3 "Sorting a List of Objects > by an Attribute of the Objects" from the Python Cookbook. > > My first guess isn't working: > > import operator > def sort_by_attr(seq, attr): > key=operator.attrgetter(attr) > key=str.lower > return sorted(seq, key) > > ...would much appreciate any guidance! HiJason, Try key= lambda x: x.attr.lower() The above should calculate the key only once for the items to be sorted rather than using cmp which calculates more than that. - Paddy. From victorsubervi at gmail.com Thu Apr 17 10:52:39 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 17 Apr 2008 09:52:39 -0500 Subject: More Fun With MySQL and Images In-Reply-To: <4dc0cfea0804170742g39965533yfaf260bcf4da4301@mail.gmail.com> References: <4dc0cfea0804170742g39965533yfaf260bcf4da4301@mail.gmail.com> Message-ID: <4dc0cfea0804170752x789cce43xe1ea6aeba498ccd1@mail.gmail.com> Never mind. Apparently, these tags throw it for that loop: print '\n' I?m surprised they would, but gratified I found the problem. Victor On Thu, Apr 17, 2008 at 9:42 AM, Victor Subervi wrote: > Hi again: > Here is my code, an edit of Gabriel?s: > > #!/usr/local/bin/python > import cgitb; cgitb.enable() > import MySQLdb > def test(): > host = 'host' > db = 'db' > user = 'user' > passwd = 'pass' > db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > cursor= db.cursor() > cursor.execute('select pic1 from products where id="2";') > content = cursor.fetchall()[0][0].tostring() > f = open("somefile.jpg", "w") > f.write(content) > f.close() > print 'Content-Type: image/jpeg\r\nContent-Length: %d\n' % len(content) > print '\n' > print content > print '\n' > cursor.close() > > test() > Now, when I surf to the url of this script, it prints out garbage that is > a literal of the image, but not the image itself. However, if I surf to > ?somefile.jpg?, I see the image!! Am I losing my mind?? What?s wrong here? > TIA, > Victor > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fetchinson at googlemail.com Mon Apr 14 00:43:43 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Sun, 13 Apr 2008 21:43:43 -0700 Subject: Recommendation for Web Framework In-Reply-To: <4801b3a6$0$7713$4c368faf@roadrunner.com> References: <4801b3a6$0$7713$4c368faf@roadrunner.com> Message-ID: On Sun, Apr 13, 2008 at 12:18 AM, James West wrote: > Let me explain my situation a bit. > > I've been contracted to develop an ecommerce site. It's nothing too > huge but requires a lot of custom development that's not typical for > your run of the mill webstore. I've got about three weeks to get the > project delivered and I've written quite a bit of code already. > > I'd like to find some sort of tool to generate some of the repetative > bits like data management (think phpMyAdmin but for Python) so I don't > have to write a stupid mangement script for every single module (users, > customers, inventory, etc). I know there's tools out there that will do > this for ASP code with a SQL server backend, but I haven't seen > anything for Python outside of the web application frameworks. > > Ideally, I'd like something like Ruby on Rails that would provide > scaffolding support so I can bootstrap the system, so to speak. I've > looked at Django, but the client is only running Apache 1.x and Python > 2.3. I've given Turbo Gears a try, but couldn't get SQLObject to run > (threw an error that I didn't have time to struggle with). So basically > I need something with low dependencies, easy to develop in, and > releatively easy to deploy. > > Anyone have any recommendations? I really need something on which I can > ramp up quickly to get this project out of the door fast. I'm also a > framework newbie, so I know there's a learning curve. > > Any input is appreciated, thank you. > > - james > > -- > http://mail.python.org/mailman/listinfo/python-list > Have you looked at http://code.google.com/p/dbsprockets/ and/or http://code.google.com/p/dbsprockets/wiki/DBMechanic ? HTH, Daniel -------------- next part -------------- An HTML attachment was scrubbed... URL: From see.signature at no.spam Wed Apr 30 10:01:53 2008 From: see.signature at no.spam (Eric Brunel) Date: Wed, 30 Apr 2008 16:01:53 +0200 Subject: Simple TK Question - refreshing the canvas when not in focus References: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> <4818349e$0$2959$ba620e4c@news.skynet.be> Message-ID: On Wed, 30 Apr 2008 10:58:06 +0200, Robert.Spilleboudt wrote: > blaine wrote: >> Hey everyone! >> I'm not very good with Tk, and I am using a very simple canvas to >> draw some pictures (this relates to that nokia screen emulator I had a >> post about a few days ago). >> Anyway, all is well, except one thing. When I am not in the program, >> and the program receives a draw command (from a FIFO pipe), the canvas >> does not refresh until I click into the program. How do I force it to >> refresh, or force the window to gain focus? It seems like pretty >> common behavior, but a few things that I've tried have not worked. >> Class screen(): >> def __init__(self): >> self.root = Tkinter.Tk() >> self.root.title('Nokia Canvas') >> self.canvas = Tkinter.Canvas(self.root, width =130, >> height=130) >> self.canvas.pack() >> self.root.mainloop() >> Then somewhere a long the line I do: >> self.canvas.create_line(args[0], args[1], args[2], >> args[3], fill=color) >> self.canvas.pack() >> I've tried self.root.set_focus(), self.root.force_focus(), >> self.canvas.update(), etc. but I can't get it. >> Thanks! >> Blaine > When you read the pipe, do you generate an event? Probably not , and Tk > is event-driven and should never update the canvas if there is no event. > This is how I understand Tk. > > I have a Tk program who reads a audio signal (from an RC transmitter) . > I generate a event every 100 msec , and "process" refresh the canvas. > Starting the sequence: > id = root.after(100,process) will call "process" after 100 msec > At the end of "process", repeat: > id = root.after(100,process) > Robert Your method actually works and is in fact even clearer: you explicitely give back the control to the main event loop by sending the event. But the call to 'update' should also work, since it also gives back the control to the main event loop, implicitely however. BTW, the pending events *are* treated by a call to update, which can cause some surprises... -- python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])" From Dodin.Roman at gmail.com Fri Apr 25 07:26:48 2008 From: Dodin.Roman at gmail.com (hellt) Date: Fri, 25 Apr 2008 04:26:48 -0700 (PDT) Subject: Can you recommend a book? References: <1209121653.26409.1249825743@webmail.messagingengine.com> Message-ID: On 25 ???, 15:09, "Malcolm Greene" wrote: > My two favorites: > > - Core Python Programming by Chun > - Learning Python by Lutz > > Malcolm Learning Python (Lutz) is very good, reading right now. From olivier.losinger at gmail.com Mon Apr 14 04:39:56 2008 From: olivier.losinger at gmail.com (olivier.losinger at gmail.com) Date: Mon, 14 Apr 2008 01:39:56 -0700 (PDT) Subject: Py2exe Json Message-ID: I want to use json with py2exe but when I execute the program I have this errors : "Runtime Error : maximun recursion depth exceeded" Here is my code : import json jsonstr='{"toto":"toto"}' print json.read(jsonstr) and my setup #!/usr/bin/env python # -*- coding: latin-1 -*- import sys, os, getopt from distutils.core import setup, Extension import py2exe includes = ["encodings", "encodings.*",] options = {"py2exe": { # create a compressed zip archive "compressed": 1, "optimize": 2, "includes": includes, "packages": ["encodings", "email","json"] }} version_string='1.2' setup(name="test_json", options=options, version=version_string, description="Test json", console=['debugjson.py'], data_files=[] ) Have you got an idea ? From cokofreedom at gmail.com Wed Apr 30 05:47:13 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Wed, 30 Apr 2008 02:47:13 -0700 (PDT) Subject: Code/test ratio wrt static vs dynamic typing [was: Re: Python Success stories] References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <57d73312-37b1-4c53-9669-803e84a6901f@p25g2000hsf.googlegroups.com> Message-ID: <263d5498-821f-4705-9e1d-cc9e97a98e07@34g2000hsf.googlegroups.com> > > A rather off-topic and perhaps naive question, but isn't a 1:4 > production/test ratio a bit too much ? Is there a guesstimate of what > percentage of this test code tests for things that you would get for > free in a statically typed language ? I'm just curious whether this > argument against dynamic typing - that you end up doing the job of a > static compiler in test code - holds in practice. > > George To me it seems like more of an argument for a (more) concise Test Framework for Python, or at least a fully fledge IDE beyond pyDev. From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 4 07:50:45 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 04 Apr 2008 13:50:45 +0200 Subject: Is there an official way to add methods to an instance? In-Reply-To: References: Message-ID: <47f6160e$0$19004$426a74cc@news.free.fr> Peter Otten a ?crit : (snip) > Anyway, here is one more option to add too the zoo: > >>>> class A(object): > ... def __init__(self, f, x): > ... self._f = f > ... self.x = x > ... @property > ... def f(self): > ... return self._f.__get__(self) > ... def __del__(self): > ... print "deleting" > ... This is nice but requires that you know in advance how many methods you're going to add and how they will be named (which is not a bad thing in itself - on the contrary - but may not be what the OP is after), and that you can add these methods at instanciation time. A variant could be: class A(object): def __init__(self, x): self.x = x def __getattr__(self, name): target = '_' + name # avoids recursion if hasattr(self, target): func = getattr(self, target) if hasattr(func, '__get__'): return func.__get__(self, type(self)) # nothing found, bye... raise AttributeError( "%s object has no attribute %s" % (self, name) ) a = A(21) a._foo = lambda self: "answer is %s" % (self.x * 2) print a.foo() From skanemupp at yahoo.se Sat Apr 5 11:29:43 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 08:29:43 -0700 (PDT) Subject: Tkinter: making buttons the same size? Message-ID: <12bad1a6-3b4b-446e-9673-8893cd6838f9@s37g2000prg.googlegroups.com> on windows vista these buttons dont have the same size, the "/" shrinks a little. how do i make them the same size or prevent shrinking? a mac-user told me they look the same to him so maybe it doesnt shrink on macs but it does when using VISTA. i tried some .propagate and extend-stuff but didnt work. #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self, master=None): """Initialize yourself""" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): self.btnDisplay = Button(self,text='1',command=lambda n=1:self.Display(n)) self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='/',command=lambda n="/":self.Display(n)) self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) def Display(self, number): print number if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() From pylists at arcor.de Thu Apr 17 22:41:36 2008 From: pylists at arcor.de (Penny Y.) Date: Fri, 18 Apr 2008 10:41:36 +0800 Subject: get quote enclosed field in a line In-Reply-To: Message-ID: <20080418024152.3566B292B61@mail-in-07.arcor-online.net> Hello, I don't know Python's RE very well. But using Perl's RE you can get it. > cat t1.pl $x=qq{189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET /Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311Firefox/2.0.0.13" "-"}; $ua = ($x=~/\"(.+?)\"/g)[-2]; print $ua,"\n"; > perl t1.pl Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311Firefox/2.0.0.13 > -----????----- > ???: python-list-bounces+pylists=arcor.de at python.org > [mailto:python-list-bounces+pylists=arcor.de at python.org] ?? > xahlee at gmail.com > > e.g. the typical line is like this: > > 189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET / > Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org > "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/ > 5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311 > Firefox/2.0.0.13" "-" > > I want the part: "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv: > 1.8.1.13) Gecko/20080311 Firefox/2.0.0.13". From gagsl-py2 at yahoo.com.ar Mon Apr 21 19:58:42 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 20:58:42 -0300 Subject: how to pass C++ object to another C++ function via Python function References: <1810b155-5598-4f17-a8e9-e4aa848db5de@i36g2000prf.googlegroups.com> <673m48F2lucb5U1@mid.uni-berlin.de> Message-ID: En Mon, 21 Apr 2008 11:19:24 -0300, Diez B. Roggisch escribi?: > Gabriel Genellina wrote: >> You can't pass any arbitrary C object to a Python function. >> In this case you can use a PyCObject, a Python box around a void* >> pointer. >> See http://docs.python.org/api/cObjects.html > > Neat! Didn't know about that one. I found it just by chance. The title alone in the API reference isn't very descriptive... -- Gabriel Genellina From nagle at animats.com Sat Apr 12 12:39:46 2008 From: nagle at animats.com (John Nagle) Date: Sat, 12 Apr 2008 09:39:46 -0700 Subject: Tremendous slowdown due to garbage collection In-Reply-To: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> Message-ID: <4800e342$0$36326$742ec2ed@news.sonic.net> andreas.eisele at gmail.com wrote: > In an application dealing with very large text files, I need to create > dictionaries indexed by tuples of words (bi-, tri-, n-grams) or nested > dictionaries. The number of different data structures in memory grows > into orders beyond 1E7. > > It turns out that the default behaviour of Python is not very suitable > for such a situation, as garbage collection occasionally traverses all > objects in memory (including all tuples) in order to find out which > could be collected. This leads to the sitation that creating O(N) > objects effectively takes O(N*N) time. Do your data structures need garbage collection? CPython is a reference counted system with garbage collection as a backup to catch cycles. Try using weak back-pointers in your data structures to avoid creating cycles. John Nagle From deets at nospam.web.de Wed Apr 9 07:54:01 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 09 Apr 2008 13:54:01 +0200 Subject: Basic optimization of python. References: Message-ID: <663p3lF2go90rU1@mid.uni-berlin.de> ?? wrote: > Howdy, > I wonder whether python compiler does basic optimizations to .py. > Eg: > t = self.a.b > t.c = ... > t.d = ... > .vs. > self.a.b.c = ... > self.a.b.d = ... > which one is more effective? Since each dot invokes a hash table lookup, > it may be time consuming. If the compiler can do expression folding, then > no manual folding is needed. It can't do that because of no guarantee can be made that self.a has no side-effects, and consequently doesn't do it. > Again, how about contant calculation? > Eg: > a = 1 + 2 > .vs. > a = 3 > which one is more effective? Does the compiler calculate the result at > compile time? How about constant spreading? Algebraic optimizations aren't done AFAIK - and it's debatable if the mu-secs saved by that would be worth the effort, as if *they* matter, you obviously are in number-crunching mode and should resort to libs such as Numpy to do your work. Diez From xkenneth at gmail.com Fri Apr 25 17:02:56 2008 From: xkenneth at gmail.com (xkenneth) Date: Fri, 25 Apr 2008 14:02:56 -0700 (PDT) Subject: Oilfield Applications: WITS AND WITSML Message-ID: <1e78af71-9c41-4a50-a5d0-a862f25db8f3@f36g2000hsa.googlegroups.com> All, If anyone has any interest in developing a bit of code for generating WITS and WITSML in python, then drop me a line. I've started a project on google apps, "PyWITS", and I plan to support both WITS and WITSML through a set of standard libraries. I would really appreciate help from other developers or input from anyone. Drop me a line if you're interested. Regards, Kenneth Miller From aguirre.adolfo at gmail.com Mon Apr 28 22:57:12 2008 From: aguirre.adolfo at gmail.com (aguirre.adolfo at gmail.com) Date: Mon, 28 Apr 2008 19:57:12 -0700 (PDT) Subject: Python Math libraries - How to? References: Message-ID: > > Thank you. I?ll try all methods to figure out the convenience of each Adolfo > > From sawilla at gmail.com Fri Apr 25 12:04:33 2008 From: sawilla at gmail.com (sawilla) Date: Fri, 25 Apr 2008 09:04:33 -0700 (PDT) Subject: module error in Vista -- works as administrator References: <815eb7f8-6f00-469d-bb15-e1d9680d9646@e39g2000hsf.googlegroups.com> <480d0a52$1@news.mel.dft.com.au> <72da4abc-57b1-47ca-bed4-48b7244d6407@e39g2000hsf.googlegroups.com> <480d2369@news.mel.dft.com.au> Message-ID: <1ca8d4a1-7e98-4269-8e3b-c67fa757f9b1@b64g2000hsa.googlegroups.com> The access writes to easy-install.pth for regular users is read and execute. The output of sys.path for regular users is: ['', 'C:\\Program Files\\Python25\\lib\\site-packages\ \setuptools-0.6c8-py2.5.eg g', 'C:\\Program Files\\Python25\\python25.zip', 'C:\\Program Files\ \Python25\\D LLs', 'C:\\Program Files\\Python25\\lib', 'C:\\Program Files\\Python25\ \lib\\pla t-win', 'C:\\Program Files\\Python25\\lib\\lib-tk', 'C:\\Program Files\ \Python25 ', 'C:\\Program Files\\Python25\\lib\\site-packages'] The output of sys.path for the admin user is: ['', 'C:\\Program Files\\Python25\\lib\\site-packages\ \setuptools-0.6c8-py2.5.eg g', 'C:\\Program Files\\Python25\\lib\\site-packages\\networkx-0.36- py2.5.egg', 'C:\\Program Files\\Python25\\lib\\site-packages\\numpy-1.0.4-py2.5- win32.egg', 'C:\\Program Files\\Python25\\lib\\site-packages\\scipy-0.6.0-py2.5- win32.egg', 'C:\\Program Files\\Python25\\lib\\site-packages\\matplotlib-0.91.2- py2.5-win32. egg', 'C:\\Program Files\\Python25\\lib\\site-packages\\dot2tex-2.7.0- py2.5.egg' , 'C:\\Program Files\\Python25\\lib\\site-packages\\pydot-1.0.2- py2.5.egg', 'C:\ \Program Files\\Python25\\lib\\site-packages\\pyparsing-1.4.11-py2.5- win32.egg', 'C:\\Program Files\\Python25\\python25.zip', 'C:\\Program Files\ \Python25\\DLLs ', 'C:\\Program Files\\Python25\\lib', 'C:\\Program Files\\Python25\ \lib\\plat-w in', 'C:\\Program Files\\Python25\\lib\\lib-tk', 'C:\\Program Files\ \Python25', 'C:\\Program Files\\Python25\\lib\\site-packages'] The contents of easy-install.pth are: import sys; sys.__plen = len(sys.path) ./setuptools-0.6c8-py2.5.egg ./networkx-0.36-py2.5.egg ./numpy-1.0.4-py2.5-win32.egg ./scipy-0.6.0-py2.5-win32.egg ./matplotlib-0.91.2-py2.5-win32.egg ./dot2tex-2.7.0-py2.5.egg ./pydot-1.0.2-py2.5.egg ./pyparsing-1.4.11-py2.5-win32.egg import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys, '__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new) The location where numpy is found: >>> print os.path.abspath(numpy.__file__) C:\Program Files\Python25\lib\site-packages\numpy-1.0.4-py2.5-win32.egg \numpy\__ init__.pyc So I believe I need to have the easy-install.pth file executed automatically for regular users but I don't know how to do this. Reg On Apr 21, 7:29?pm, John Machin wrote: > sawillawrote: > > On Apr 21, 5:42 pm, John Machin wrote: > >> Log on as administrator, start python in command window and do this: > > >> import sys > >> sys.path # shows where python is looking for importables > >> import numpy > >> import os.path > >> print os.path.abspath(numpy.__file__) # shows where it found numpy > > >> Log on as ordinary user, start python in command window and do this: > > >> import sys > >> sys.path > >> # check how this is different from the admin's sys.path > > >> If you can't see what to do after that, come back here with the output > >> from those steps. > > >> HTH, > >> John > > > That was a great help, thank you. I now see what is causing the > > problem but I don't know how to fix it. I used easy_install to install > > several packages. When I run Python from an administrator command > > window all of the directories in C:\Program Files\Python25\Lib\site- > > packages\easy-install.pth are added to the sys.path. When I run it as > > a regular user, those directories are not added to the sys.path and so > > Python can't find the modules. > > > I know how to manually add those directories to Python's search path > > but then I'll need to update the path every time I install something. > > How do I get Python to automatically load the easy-install.pth file > > for the regular user account? > > > Reg > > """ > If you can't see what to do after that, come back here with the output > from those steps. > """ > in particular what is in sys.path for the non-admin user. > Also what are the access rights to the easy-install.pth file?- Hide quoted text - > > - Show quoted text - From gagsl-py2 at yahoo.com.ar Thu Apr 3 21:04:06 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 22:04:06 -0300 Subject: regarding memoize function References: <94a9e7e6-a623-4783-81da-f69654e51349@e10g2000prf.googlegroups.com> Message-ID: En Thu, 03 Apr 2008 21:21:11 -0300, Dan Bishop escribi?: > On Apr 3, 6:33 pm, ankitks.mi... at gmail.com wrote: >> I saw example of memoize function...here is snippet >> >> def memoize(fn, slot): >> def memoized_fn(obj, *args): >> if hasattr(obj, slot): >> return getattr(obj, slot) >> else: >> val = fn(obj, *args) >> setattr(obj, slot, val) >> return val >> return memoized_fn >> >> and I am really clueless, about what it does. I know in general we try >> to keep computed values for future usage. But I am having hard-time >> visualizing it. >> What is obj here? and what does *args means? > > *args is Python's syntax for variadic functions. In case the strange name gives you nothing, see section 4.7 in the Tutorial [1] For a much simpler implementation, see this FAQ entry [2] [1] http://docs.python.org/tut/node6.html#SECTION006700000000000000000 [2] http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects -- Gabriel Genellina From nick at craig-wood.com Tue Apr 1 13:30:05 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Tue, 01 Apr 2008 12:30:05 -0500 Subject: Homework help References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> Message-ID: bobby.connor at gmail.com wrote: > Hey guys > I haev this homework assignment due today > I don't necessarily want the answers, but need help on how to approach > it/the steps i need to solve the problems > Thanks > > # (2 Points) Write a python function howMany(item,lst) which accepts > an item and a lst of items and returns the number of times item occurs > in lst. For example, howMany(3,[1,2,3,2,3]) should return 2. Read section 4.1, 4.2 and 4.6 from here http://docs.python.org/tut/node6.html -- Nick Craig-Wood -- http://www.craig-wood.com/nick From Dodin.Roman at gmail.com Sat Apr 19 07:20:20 2008 From: Dodin.Roman at gmail.com (hellt) Date: Sat, 19 Apr 2008 04:20:20 -0700 (PDT) Subject: winreg module, need help to understand why i'm getting exception Message-ID: HI all, i found winreg module from http://www.rutherfurd.net/python/winreg/index.html very useful and simple, instead _winreg. But i have a problem with this module, in its iterable part. look at the following code key = Key(HKLM,r"SYSTEM\CurrentControlSet\Services\Tcpip\Enum") for i in key.values: print i.value and that is the exception Traceback (most recent call last): File "D:\.Projects\python\temp.py", line 21, in for i in key.values: File "C:\Python25\Lib\site-packages\winreg.py", line 451, in next return self.values[self.index - 1] File "C:\Python25\Lib\site-packages\winreg.py", line 289, in __getitem__ name = _winreg.EnumValue(self.hkey, key)[0] WindowsError: [Error 259] No more data is available so there is some problem with iterate, i think i am still a beginner, so i cant understand why this appears, and what should i fix. if anyone have some time to look closer to this module, i will appreciate this very much. thanks. From hv at tbz-pariv.de Tue Apr 8 04:09:54 2008 From: hv at tbz-pariv.de (Thomas Guettler) Date: Tue, 08 Apr 2008 10:09:54 +0200 Subject: Destructor? In-Reply-To: References: Message-ID: <660niiF2hrfpvU1@mid.individual.net> Duncan Booth schrieb: > [*] except of course for things like power failure. You simply cannot > catch *all* terminations. And 'kill -SIGKILL' can't be caught, since this signal never reaches the process. The os just removes the processes. Thomas -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de From martin at v.loewis.de Sun Apr 6 02:03:34 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 06 Apr 2008 08:03:34 +0200 Subject: RELEASED Python 2.6a2 and 3.0a4 In-Reply-To: References: <47F68547.1040802@v.loewis.de> Message-ID: <47f867b6$0$26887$9b622d9e@news.freenet.de> John Machin wrote: > On Apr 5, 5:45 am, "Martin v. L?wis" wrote: >>> The Windows x86 MSI installer is missing for both 2.6 and 3.0. >> And likely will continue to do so for some time. >> >> > > Someone's got strange definitions of "missing"! Rather a flexible definition of "some time"; this turned out to be roughly 40 hours. Regards, Martin From victorsubervi at gmail.com Wed Apr 30 11:57:44 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 30 Apr 2008 10:57:44 -0500 Subject: Colors for Rows In-Reply-To: <1209500446.5510.4.camel@aalcdl07.lib.unc.edu> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> <20080429121105.f10c3862.darcy@druid.net> <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> <1209495803.5173.11.camel@aalcdl07.lib.unc.edu> <20080429153930.a6eddea6.darcy@druid.net> <1209500446.5510.4.camel@aalcdl07.lib.unc.edu> Message-ID: <4dc0cfea0804300857h6a7a8aa6l25aa0a3e82da12c0@mail.gmail.com> Thank you all. You helped clean up my code. The stupid mistake was in where I set the initial value of the variable z. Victor On Tue, Apr 29, 2008 at 3:20 PM, J. Cliff Dyer wrote: > On Tue, 2008-04-29 at 15:39 -0400, D'Arcy J.M. Cain wrote: > > On Tue, 29 Apr 2008 15:03:23 -0400 > > "J. Cliff Dyer" wrote: > > > Or, if you aren't sure how many colors you'll be using, try the more > > > robust: > > > > > > bg[z % len(bg)] > > > > Good point although I would have calculated the length once at the > > start rather than each time through the loop. > > > > Good catch. Thanks. What's that they say about eyes and bugs? > > Cheers, > Cliff > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From wilson.t.thompson at gmail.com Sun Apr 27 06:34:02 2008 From: wilson.t.thompson at gmail.com (wilson) Date: Sun, 27 Apr 2008 03:34:02 -0700 (PDT) Subject: removing extension Message-ID: i was trying to convert all images in a folder to another type and save the new images in a separate folder.for that i wrote a class and coded some part class ConvertImgs: def __init__(self,infldr,outfldr): if os.path.isdir(infldr): self.infldr=infldr self.outfldr=outfldr else: print "no such folder,exits program" exit(1) if not os.path.isdir(self.outfldr): os.mkdir(self.outfldr) print "made:",self.outfldr for x in os.listdir(infldr): self.origlist=[os.path.normpath(os.path.join(self.infldr,x)) for x in os.listdir(infldr)] ... the self.origlist returns a list of filenames in infolder.I would like to get them as 'C:\\myimages\\imageone' instead of 'C:\\myimages\ \imageone.jpg' sothat i can add a diff extension to all those strings in the list and save in diff format(ie change 'C:\\myimages\\imageone' to 'C:\\myimages\\imageone.gif ' and save in gif format).but i don't know how to remove those extension from the namestring ..can someone help? W From tdimson at gmail.com Wed Apr 9 18:51:00 2008 From: tdimson at gmail.com (Thomas Dimson) Date: Wed, 9 Apr 2008 15:51:00 -0700 (PDT) Subject: Ctypes and C Infinite Callback Loops References: Message-ID: <89cc7b91-21a3-4627-8aac-c0e0a320db4e@z38g2000hsc.googlegroups.com> On Apr 9, 1:24 am, Dennis Lee Bieber wrote: > On Tue, 8 Apr 2008 16:49:27 -0700 (PDT), Thomas Dimson > declaimed the following in comp.lang.python: > > > > > I assume there is some issue with the global interpreter lock or that > > you can't exit the infinite loop from above Python. Any suggestions on > > how I can design this so the thread will be able to issue exits/raise > > exceptions just like a regular thread? Is there a way of terminating > > this thread from the python interpreter or ctypes.pythonapi? > > No... as I recall, you can't /EXIT/ Python from a sub-thread... > Which is what sys.exit() or whatever is trying to do -- shut down the > entire program, not just the thread. The error you get indicates that > the thread doing the shutdown wants to wait for the sub-thread to finish > -- but /it/ IS the sub-thread. Even console interrupts have to be > delivered to the main program. > > The only safe way to terminate a thread is to be able to code it > such that /it/ responds to an externally set value (a boolean, read a > message off a Queue, etc.) and for IT to then exit. Based upon the > sample you showed, that would require the C main loop to be checking for > a shutdown signal... If the API to that main loop library doesn't > include a shutdown capability I'd suggest it is a less than complete > library... And the only thing I'd suggest is not using a Python thread, > but instead spawning a separate process that somehow communicates to the > parent process -- and which can be forceably killed using OS specific > capabilities... "kill -9 pid" > > -- > Wulfraed Dennis Lee Bieber KD6MOG > wlfr... at ix.netcom.com wulfr... at bestiaria.com > HTTP://wlfraed.home.netcom.com/ > (Bestiaria Support Staff: web-a... at bestiaria.com) > HTTP://www.bestiaria.com/ Thanks for the response, it put me in the right direction (I didn't realize there was no way of exiting the interpreter directly from a non-main thread). If anyone ever has the same problem, the solution I ended up using went like this: I created a wrapper around the infinite loop call that had a setjmp in it, exiting if setjmp was non-zero. Inside each callback function, I had a try/except statement that caught all exceptions. If it had an exception, it would set a thread- specific exception variable to sys.exc_info() and then call a C function that did a longjmp. The thread would first call the wrapper to the infinite loop. If the wrapper returns (because of a longjmp), it would check the thread- specific exception variable for a non-None value and raise the very same exception (with the same traceback) if it found it. A fairly large hack, but it seemed to do the job. Thanks again. From sturlamolden at yahoo.no Sun Apr 20 16:19:43 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sun, 20 Apr 2008 13:19:43 -0700 (PDT) Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B52DE.8070105@holdenweb.com> Message-ID: <2be5608d-560d-4712-b104-f2341a7fa569@t63g2000hsf.googlegroups.com> On Apr 20, 9:09 pm, "Hank @ITGroup" wrote: > Could you please give us some clear clues to obviously call python to > free memory. We want to control its gc operation handily as we were > using J**A. If you want to get rid of a Python object, the only way to do that is to get rid of every reference to the object. This is no different from Java. If you just want to deallocate and allocate memory to store text, Python lets you do that the same way as C: from __future__ import with_statement import os from ctypes import c_char, c_char_p, c_long, cdll from threading import Lock _libc = cdll.msvcr71 if os.name == 'nt' else cdll.libc _lock = Lock() def string_heapalloc(n): ''' allocate a mutable string using malloc ''' with _lock: malloc = _libc.malloc malloc.argtypes = [c_long] malloc.restype = c_char * n memset = _libc.memset memset.restype = None memset.argtypes = [c_char * n, c_char, c_long] tmp = malloc(n) memset(tmp,'0',n) return tmp def string_heapfree(s): ''' free an allocated string ''' with _lock: free = _libc.free free.restype = None free.argtypes = [c_char_p] ptr_first_char = c_char_p( s[0] ) free(ptr_first_char) if __name__ == '__main__': s = string_heapalloc(1000) s[:26] = 'abcdefghijklmnopqrstuvwxyz' print s[:] string_heapfree(s) From ankitks.mital at gmail.com Thu Apr 3 19:33:41 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Thu, 3 Apr 2008 16:33:41 -0700 (PDT) Subject: regarding memoize function Message-ID: I saw example of memoize function...here is snippet def memoize(fn, slot): def memoized_fn(obj, *args): if hasattr(obj, slot): return getattr(obj, slot) else: val = fn(obj, *args) setattr(obj, slot, val) return val return memoized_fn and I am really clueless, about what it does. I know in general we try to keep computed values for future usage. But I am having hard-time visualizing it. What is obj here? and what does *args means? Thanks From aljosa.mohorovic at gmail.com Fri Apr 25 08:56:12 2008 From: aljosa.mohorovic at gmail.com (Aljosa Mohorovic) Date: Fri, 25 Apr 2008 05:56:12 -0700 (PDT) Subject: PYTHONPATH breaks MySQLdb Message-ID: i have a working MySQLdb module (/usr/lib/python2.4/site-packages/ MySQL_python-1.2.2-py2.4-linux-i686.egg), using it without problems. "clean shell" after login: python -c "import MySQLdb" reports no errors if i export PYTHONPATH: export PYTHONPATH=/var/www/projects/uv_portal/portal python -c "import MySQLdb" reports no errors as in previous case if i export PYTHONPATH: export PYTHONPATH=/var/www/projects/uv_portal/portal/apps i get this: python -c "import MySQLdb" Traceback (most recent call last): File "", line 1, in ? ImportError: No module named MySQLdb is there any reason why this happens? Aljosa Mohorovic From stefan_ml at behnel.de Sat Apr 26 17:56:59 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Sat, 26 Apr 2008 23:56:59 +0200 Subject: Parsing HTML? In-Reply-To: <76811693-7617-4952-88d3-d1368c4500c5@1g2000prg.googlegroups.com> References: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> <47F9B92C.1030802@behnel.de> <76811693-7617-4952-88d3-d1368c4500c5@1g2000prg.googlegroups.com> Message-ID: <4813A52B.9070206@behnel.de> Benjamin wrote: > On Apr 6, 11:03 pm, Stefan Behnel wrote: >> Benjamin wrote: >>> I'm trying to parse an HTML file. I want to retrieve all of the text >>> inside a certain tag that I find with XPath. The DOM seems to make >>> this available with the innerHTML element, but I haven't found a way >>> to do it in Python. >> import lxml.html as h >> tree = h.parse("somefile.html") >> text = tree.xpath("string( some/element[@condition] )") >> >> http://codespeak.net/lxml >> >> Stefan > > I actually had trouble getting this to work. I guess only new version > of lxml have the html module, and I couldn't get it installed. lxml > does look pretty cool, though. Yes, the above code requires lxml 2.x. However, older versions should allow you to do this: import lxml.etree as et parser = etree.HTMLParser() tree = h.parse("somefile.html", parser) text = tree.xpath("string( some/element[@condition] )") lxml.html is just a dedicated package that makes HTML handling beautiful. It's not required for parsing HTML and doing general XML stuff with it. Stefan From tjreedy at udel.edu Mon Apr 7 15:15:29 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 7 Apr 2008 15:15:29 -0400 Subject: A funnily inconsistent behavior of int and float References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com> <1d11875a-470a-489f-910a-b420a145eb61@a1g2000hsb.googlegroups.com> Message-ID: "Mark Dickinson" wrote in message news:1d11875a-470a-489f-910a-b420a145eb61 at a1g2000hsb.googlegroups.com... | On Apr 7, 6:43 am, "Colin J. Williams" wrote: | > This is good but the documentation for | > 3.0 is missing the syntax documentation | > from 2.5 | | Is | | http://docs.python.org/dev/3.0/reference/lexical_analysis.html#integer-literals | | the documentation that you're looking for? | | But it seems to me that Lie's original point isn't really | about integer *literals* anyway---it's about the behaviour | of the built-in int() function when applied to a string. So | | http://docs.python.org/dev/3.0/library/functions.html#int | | is probably the appropriate place in the documentation. And | I agree that it could be made clearer exactly what strings are | acceptable here. Agreed. It says "If radix is zero, the interpretation is the same as for integer literals." But integer literals are unsigned. Is radix 0 any different from the default of radix 10? It also says "If the argument is a string, it must contain a possibly signed number of arbitrary size, possibly embedded in whitespace." But only integers, not 'numbers' as some would understand that, are accepted. My suggestions: 1. Change signature to: int([number | string[, radix]). This makes it clear that radix can only follow a string without having to say so in the text. 2. Replace text with: Convert a number or string to an integer. If no arguments are given, return 0. If a number is given, return number.__int__(). Conversion of floating point numbers to integers truncates towards zero. A string must be a base-radix integer literal optionally preceded by '+' or '-' (with no space in between) and optionally surrounded by whitespace. A base-n literal consists of the digits 0 to n-1, with 'a' to 'z' (or 'A' to 'Z') having values 10 to 35. The default radix is 10. The allowed values are 0 and 2-36, with 0 the same as 10. If 0 is not the same as 10, the last would have to be changed, but I could not detect any difference in a quick test. After looking at any comments here, I will consider submitting these to the tracker. Terry Jan Reedy From cwitts at gmail.com Thu Apr 10 04:07:44 2008 From: cwitts at gmail.com (Chris) Date: Thu, 10 Apr 2008 01:07:44 -0700 (PDT) Subject: new user needs help! References: <16571823.post@talk.nabble.com> Message-ID: On Apr 9, 11:02?pm, drjekil wrote: > I have done something so far about that problem,but its not the good way to > do it > > need ur comments about that.... > > from string import ?*; > import sys > > myfile = open("/afs/pdc.kth.se/home/d/debnath/membrane/1a91A.txt") > a = myfile.readlines() > data = myfile.readlines() > for line in myfile.readlines(): > ? ? ? ?fields = line.split('\t') > > ? ? ? ?items=fields.strip() > ? ? ? ?list1.append(items[1]) > > for i in aminoacid: > ? ? if ?10.0 <= z <= 22.0: > ? ? matches.append([1,i]) > #here i am getting comment! ?bash-3.1$ python bb.py > ? File "bb.py", line 16 > ? ? matches.append([1,i]) > ? ? ? ? ? ^ > IndentationError: expected an indented block > > ? ? else: > ? ? matches.append([-1,i]) > You are getting the indentation error because you need to tab the lines in after your 'if' and 'else' statements. After that is fixed you should get an Attribute Error on the 'items=fields.strip()' as a list doesn't have access to strip. import string myfile = open("/afs/pdc.kth.se/home/d/debnath/membrane/1a91A.txt", 'rb') AMINO_ACIDS = ['A','B','C',......'X','Y','Z'] for line in myfile: # Files are iterable themselves. try: fields = map(string.strip, line.split('\t')) # This will strip every column for you name, aa, topo, access, tssp, stride, z = fields except IndexError: # In case you don't have enough elements print 'Not enough elements on the line, moving along' if 10 <= z <= 22: # You only wanted between those Z-Coords ? if aa in AMINO_ACIDS: # Now actually process the data you want > print "#T/F ?A ?C ?D ?E ?F ?G ?H ?I ?K ?L ?M ?N ?P ?Q ?R ?S ?T ?V ?W ?X ?Y > Z" > > for a in range(0,len(matches),1): > > ? ? if ? ? matches[a][0]==1: > > ? ? if matches[a][1]=='A': > ? ? ? ? print "1 ?1:1 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 > 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? elif matches[a][1]=='C': > ? ? ? ? print "1 ?1:0 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 > 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? elif matches[a][1]=='D': > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:1 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > """ ? ?if matches[a][1]=='E' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:1 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='F' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:1 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='G' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:1 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='H' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='I' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:1 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='K' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:1 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='L' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:1 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='M' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:1 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='N' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:1 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='P' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:1 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='Q' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='R' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:1 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='S' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:1 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='T' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:1 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='V' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:1 19:0 20:0 21:0" > ? ? if matches[a][1]=='X' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:1 20:0 21:0" > ? ? if matches[a][1]=='Y' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:1 21:0" > ? ? if matches[a][1]=='Z' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:1" > > """ > ? ? else: > ? ? if matches[a][1]=='A': > ? ? ? ? print "-1 ?1:1 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 > 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? elif matches[a][1]=='C': > ? ? ? ? ? ? print "-1 ?1:0 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? elif matches[a][1]=='D': > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:1 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > """ ? ?if matches[a][1]=='E' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:1 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='F' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:1 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='G' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:1 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='H' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='I' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:1 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='K' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:1 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='L' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:1 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='M' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:1 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='N' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:1 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='P' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:1 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='Q' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='R' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:1 16:0 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='S' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:1 17:0 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='T' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:1 18:0 19:0 20:0 21:0" > ? ? if matches[a][1]=='V' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:1 19:0 20:0 21:0" > ? ? if matches[a][1]=='X' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:1 20:0 21:0" > ? ? if matches[a][1]=='Y' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:1 21:0" > ? ? if matches[a][1]=='Z' and matches[a][0]==1: > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:1" > ? ?waiting for ur opinion. > ? ?thanks > > -- > View this message in context:http://www.nabble.com/new--user-needs-help%21-tp16571823p16596608.html > Sent from the Python - python-list mailing list archive at Nabble.com. Masses of print statements might work for debugging but you can get a better structure through something else. If you have a specific message for those you could always build a dictionary containing the messages and access them like.... msg_dict = {'A':'Message for A', 'B':'Message for B',......,'Z':'Message for Z'} for part1, part2 in matches: # You have a 2 element structure, (part1, part2) inside the list and lists are iterable if part2 == 1: # Test the value try: print msg_dict[part1] except KeyError: print 'Amino Acid listed not on record' # or you can just simply pass over and not log anything Hope that helps. Chris From deets at nospam.web.de Wed Apr 16 06:25:52 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 16 Apr 2008 12:25:52 +0200 Subject: Image handling - stupid question References: <0001HW.C42B9FB90009B7E8B01AD9AF@news.individual.de> Message-ID: <66m2icF2lo3ghU3@mid.uni-berlin.de> Jumping Arne wrote: > I'm going to try to write some imange manipulation code (scaling, reading > EXIF and IPTC info) and just want to ask if PIL is *THE* library to use? > > I looked at and noticed that the > latest version is from Dec 2006. > > In my experience that means that either it's abandoned or that it's very > good and stable. Certainly the latter. Diez From __peter__ at web.de Tue Apr 29 01:55:53 2008 From: __peter__ at web.de (Peter Otten) Date: Tue, 29 Apr 2008 07:55:53 +0200 Subject: File IO Issues, help :( References: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> Message-ID: Kevin K wrote: > On Apr 29, 12:38 am, "Eric Wertman" wrote: >> chuck in a jsfile.close(). The buffer isn't flushing with what you >> are doing now. jsfile.flush() might work... not sure. Closing and >> re-opening the file for sure will help though. >> > > Yeah sorry I forgot to include the close() in the quote but its there. > In fact I moved it up a bit and still no luck heres the new code: > > jsfile = open("../timeline.js", "r+") > jscontent = jsfile.readlines() > jsfile.truncate() > > for line in jscontent: > if re.search('var d =', line): > line = "var d = \""+mint['1'].ascdate()+"\"\n" > print line > jsfile.write(line) > jsfile.close() > > I tried this can got the same result...?? """ truncate(...) truncate([size]) -> None. Truncate the file to at most size bytes. Size defaults to the current file position, as returned by tell(). """ After the readlines() call the current file position is at the end of the file. Try jsfile.truncate(0). Also note that readlines() reads the whole file into memory. For large files it would therefore be better to write to a new file and rename it afterwards. Peter From bearophileHUGS at lycos.com Tue Apr 8 18:11:41 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Tue, 8 Apr 2008 15:11:41 -0700 (PDT) Subject: Data structure recommendation? References: <1adc3541-7775-4938-bd5a-953dd041656c@2g2000hsn.googlegroups.com> Message-ID: Few more notes on the code: You may use the @property in such situations (or you may just use attributes, dropping the property). Note that Python doesn't inline functions calls like Java HotSpot does quite often. def __children(self): raise NotImplementedError() children = property(__children) ==> (not tested!) @property def __children(self): raise NotImplementedError() If the profiling shows this is s slow, and it's used on lot of items, there are faster O(1) algorithms for this, like this one: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/466330 @staticmethod def determine_median(numbers): return sorted(numbers)[ len(numbers) / 2 ] I have seen you use lot of double underscores (I think one may often suffice, but usually two aren't a problem): def __children(self): Stripped of comments, docstrings, and empty lines the code is just 280 lines long (it's 1498 with them!), so a translation doesn't seem too much work (expecially if the original version was Java). The code seem really well commented, organized, etc. And I like it, it looks better than 90+% of the commercial Python code I see :-) Bye, bearophile From fennelllindy8241 at gmail.com Mon Apr 28 03:18:02 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:18:02 -0700 (PDT) Subject: crack addict Message-ID: crack addict http://crack.cracksofts.com From drjekil77 at gmail.com Tue Apr 8 15:55:33 2008 From: drjekil77 at gmail.com (drjekil) Date: Tue, 8 Apr 2008 12:55:33 -0700 (PDT) Subject: new user needs help! Message-ID: <16571823.post@talk.nabble.com> I am totally new in biopython and its my first program.so may be i am asking stupid question. I am working with a text filelooks like this: #NAME AA TOPO ACCESS DSSP STRIDE Z-COORD 1lghB A i 79.8 H H -24.58 1lghB V i 79.6 H H -22.06 1lghB H i 71.9 H H -19.94 i need to compare those lines which has a Z-COORED value between 10 to 22 and presents in the following way True/false A C D E F G H I K L M N P Q R S T V X Y W(here alfabets represents amino acids) 1 1:1 2:0 3:0 and so on for rest of the amino acids. IF PRESENT IN THAT RANGE IF not PRESENT IN THAT RANGE then -1 1:0 2:0 so on,it should be 1 instead of 0 when it will find corresponding amino acid for that line.say here,for 2nd line it will be 16:1. true will represent 1,false -1. i have to cheek all the lins in the file and print it. u have to tell simply otherwise i cant understand even,so stupid am i! I will be really greatful!Thanks in advance -- View this message in context: http://www.nabble.com/new--user-needs-help%21-tp16571823p16571823.html Sent from the Python - python-list mailing list archive at Nabble.com. From cokofreedom at gmail.com Thu Apr 10 07:15:53 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Thu, 10 Apr 2008 04:15:53 -0700 (PDT) Subject: questions about Exceptions? References: <2840d452-c9d5-4444-a06e-71360842c229@8g2000hsu.googlegroups.com> <71cc8c25-f5f9-4f21-a9d8-06780bf97608@f63g2000hsf.googlegroups.com> <9af81b1a-3e02-4406-b9d2-0a9b6f46566b@p39g2000prm.googlegroups.com> <0e586d5d-6799-433f-b8a4-4de5d2a87b61@h1g2000prh.googlegroups.com> <46a79564-4069-46af-b6ab-b38bd9152c2a@d45g2000hsc.googlegroups.com> <1f413b6e-f964-4f8d-b781-61985f86acc2@a9g2000prl.googlegroups.com> Message-ID: > the erase() id alwys need if u wanna abort whilst u wrote something. But if it is meant to only evaluate once you've pressed the enter key (I take it?) you shouldn't need that. And if you are to abort while evaluating it will not do that. From john00587 at gmail.com Mon Apr 21 01:42:48 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:42:48 -0700 (PDT) Subject: irc proxy search crack Message-ID: irc proxy search crack http://cracks.00bp.com F R E E C R A C K S From andrew at acooke.org Sat Apr 26 08:21:06 2008 From: andrew at acooke.org (andrew cooke) Date: Sat, 26 Apr 2008 05:21:06 -0700 (PDT) Subject: Logging ancestors ignored if config changes? References: <7770a385-e26d-4ad9-bc72-fa1228034c3b@26g2000hsk.googlegroups.com> Message-ID: One way to handle this is to make creation of module-level Loggers lazy, and make sure that logging initialisation occurs before any other logging is actually used (which is not so hard - just init log at the start of the application). Of course, there's a performance hit... For example: class Log(object): def __init__(self, name): super(Log, self).__init__() self._name = name self._lazy = None def __getattr__(self, key): if not self._lazy: self._lazy = logging.getLogger(self._name) return getattr(self._lazy, key) and then, in some module: from acooke.util.log import Log log = Log(__name__) [...] class Foo(object): def my_method(self): log.debug("this works as expected") Andrew From ch612bunn at gmail.com Sun Apr 27 09:15:58 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:15:58 -0700 (PDT) Subject: Microsoft Office Home and Student 2007 crack Message-ID: <3cf140a3-0ad2-4a63-a71a-297c679c25ff@l64g2000hse.googlegroups.com> Microsoft Office Home and Student 2007 crack http://wga-cracks.crackkey.net From Lie.1296 at gmail.com Sun Apr 20 05:55:52 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 20 Apr 2008 02:55:52 -0700 (PDT) Subject: python setup.py install on Vista? References: Message-ID: On Apr 19, 6:29 am, globalrev wrote: > type "python setup.py install" > > that is used in most "addons" for python. > > well using windows vista, where the h*** am i supposed to type this? > > if it is not doable in windows, what do i have to do instead? just > clicking the setup.py-file never works. It seems that quite a lot of people wondered why python doesn't set the environment variable to Python Path in the default installation. While most Windows users that are flattered with GUI (IDLE) doesn't really care about it, they'd have trouble when trying to run python from command prompt. To set your environment variable: 1. Right-click the Computer icon 2. Choose "Properties" from the context menu 3. Click the "Advanced system settings" link 4. Click the "Environment Variables" button 5. Add Python's installation path (usually C:\PythonXX where XX is the Python version) to System Variables to the end of the path lists 6. Test it, try opening a command prompt and type "python" or "python filename.py" outside Python installation directory From torriem at gmail.com Thu Apr 17 13:00:35 2008 From: torriem at gmail.com (Michael Torrie) Date: Thu, 17 Apr 2008 11:00:35 -0600 Subject: How to know if a module is thread-safe In-Reply-To: <4807805b$0$884$ba4acef3@news.orange.fr> References: <4807805b$0$884$ba4acef3@news.orange.fr> Message-ID: <48078233.2060903@gmail.com> J?r?my Wagner wrote: > Hi, I recently tried to use the subprocess module > within a threading.Thread class, but it appears the module > is not thread-safe. http://bugs.python.org/issue1731717 Pretty bad bug, really, since subprocess is supposed to be the replacement for all the other mechanisms like popen2 and os.popen* > > What is the policy of python regarding thread-safety of a module ? I personally don't know. But any module that's not thread safe would be a bug in my mind. From gagsl-py2 at yahoo.com.ar Mon Apr 21 01:32:06 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 02:32:06 -0300 Subject: Accessing parallel port interrupts using python or any c python binding ? References: <384662990804202109w7180365cu99599ca1628a5736@mail.gmail.com> Message-ID: En Mon, 21 Apr 2008 01:09:59 -0300, kapardhi bvn escribi?: > Any body can tell me an efficient way of reading parallel port at high > speed. > this is basically to extend ISA and other bus interfacing. See pyparallel (part of the pyserial package) -- Gabriel Genellina From Scott.Daniels at Acm.Org Thu Apr 17 21:28:08 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Thu, 17 Apr 2008 18:28:08 -0700 Subject: Request a short code review In-Reply-To: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> References: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> Message-ID: james at reggieband.com wrote: > Here is a method I came across that I would like to clean up: > > > def output_random_lesson_of_type(self, type=None): > """Output a lesson of a specific type - if no type is passed in > then output any type.""" > if type: > filtered_lessons = filter(lambda x: x["type"] == type, > self.lesson_data["lessons"]) > if filtered_lessons: > lesson = self.output_random(filtered_lessons) > else: > print "Unable to find lessons of type %s." % type > else: > lesson = self.output_random(self.lesson_data["lessons"]) > return lesson Simplest: Just let the error float up to where it is caught import random def output_random_lesson_of_type(self, type=None): """Output a lesson of a specific type - None mans any type.""" lessons = self.lesson_data["lessons"] if type is not None: lessons = [x for x in lessons if x["type"] == type] return random.choice(lessons) Or, if you really want to print your message, change that last line to: try: return random.choice(lessons) except IndexError: print "Unable to find lessons of type %s." % type raise -Scott David Daniels Scott.Daniels at Acm.Org From __peter__ at web.de Mon Apr 28 07:03:31 2008 From: __peter__ at web.de (Peter Otten) Date: Mon, 28 Apr 2008 13:03:31 +0200 Subject: Retrieving int from hex in a file. References: <9edfaaa3-4e87-4f74-90a5-c10c9daae101@r66g2000hsg.googlegroups.com> Message-ID: Filipe Teixeira wrote: > I have to open a binary file from an old computer and recover the > information stored (or at least try to). I use: > I would like to convert these hex representations to int, but this If you want to do it efficiently have a look at the array module: >>> import os, array >>> a = array.array("B") >>> filename = "/usr/bin/python" >>> a.fromfile(open(filename, "rb"), os.path.getsize(filename)) >>> a[10] 0 >>> a[:10] array('B', [127, 69, 76, 70, 2, 1, 1, 0, 0, 0]) Peter From martin at v.loewis.de Sun Apr 27 13:25:06 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 27 Apr 2008 19:25:06 +0200 Subject: Why can't timedeltas be divided? In-Reply-To: References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> <48142747$0$20906$9b622d9e@news.freenet.de> Message-ID: <4814B6F2.5010604@v.loewis.de> > Well, http://bugs.python.org/issue1673409 seems very closely related. I can't see the relationship. This issue is about conversion methods, not about arithmetic. Regards, Martin From sjmachin at lexicon.net Fri Apr 25 17:22:21 2008 From: sjmachin at lexicon.net (John Machin) Date: Fri, 25 Apr 2008 14:22:21 -0700 (PDT) Subject: Setting an attribute without calling __setattr__() References: Message-ID: On Apr 26, 7:01 am, Joshua Kugler wrote: > OK, I'm sure the answer is staring me right in the face--whether that answer > be "you can't do that" or "here's the really easy way--but I am stuck. I'm > writing an object to proxy both lists (subscriptable iterables, really) and > dicts. > > My init lookslike this: > > def __init__(self, obj=None): > if type(obj).__name__ in 'list|tuple|set|frozenset': > self.me = [] > for v in obj: > self.me.append(ObjectProxy(v)) > elif type(obj) == dict: > self.me = {} > for k,v in obj.items(): > self.me[k] = ObjectProxy(v) > > and I have a __setattr__ defined like so: > > def __setattr__(self, name, value): > self.me[name] = ObjectProxy(value) > > You can probably see the problem. > > While doing an init, self.me = {} or self.me = [] calls __setattr__, which > then ends up in an infinite loop, and even it it succeeded > > self.me['me'] = {} > > is not what I wanted in the first place. > > Is there a way to define self.me without it firing __setattr__? > Consider reading the *second* paragraph about __setattr__ in section 3.4.2 of the Python Reference Manual. From colas.francis at gmail.com Mon Apr 14 12:28:22 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Mon, 14 Apr 2008 09:28:22 -0700 (PDT) Subject: eval modifies passed dict References: <2b2398b1-042e-46bb-b840-ea9e07d87bd1@2g2000hsn.googlegroups.com> Message-ID: <6ca01677-685f-432e-b32f-167ce0b37c58@d1g2000hsg.googlegroups.com> On 14 avr, 18:05, Duncan Booth wrote: > Janto Dreijer wrote: > > It seems eval is modifying the passed in locals/globals. This is > > behaviour I did not expect and is really messing up my web.py app. > > > Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) > > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > > Type "help", "copyright", "credits" or "license" for more information. > >>>> d = dict(a=1) > >>>> d.keys() > > ['a'] > >>>> eval("a", d) > > 1 > >>>> d.keys() > > ['a', '__builtins__'] > > > That can't be right. > > That can exactly be right. > > The current document is (I think) wrong or at the least misleading. It > says: > > > If the globals dictionary is present and lacks '__builtins__', the > > current globals are copied into globals before expression is parsed. > > I think it should say: > > > If the globals dictionary is present and lacks '__builtins__', the > > current value of __builtins__ is added to globals before expression > > is parsed. > > i.e. only a single variable is assigned, other globals aren't copied. Indeed: Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> globals().keys() ['__builtins__', '__name__', '__doc__'] >>> b = 2 >>> d = {'a': 1} >>> eval('a', d) 1 >>> d.keys() ['a', '__builtins__'] From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 22 08:50:11 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 22 Apr 2008 14:50:11 +0200 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> Message-ID: <480ddefc$0$22219$426a74cc@news.free.fr> GD a ?crit : > Please remove ability to multiple inheritance in Python 3000. Please dont. > Multiple inheritance is bad for design, rarely used and contains many > problems for usual users. Don't blame the tool for your unability to use it properly. > Every program can be designed only with single inheritance. Every program can be implemented in machine code. From hdante at gmail.com Fri Apr 18 13:33:02 2008 From: hdante at gmail.com (hdante) Date: Fri, 18 Apr 2008 10:33:02 -0700 (PDT) Subject: Unicode chr(150) en dash References: <48063434$0$36327$742ec2ed@news.sonic.net> <7dae96d4-48c4-46c9-9aa9-33a263b84ca4@26g2000hsk.googlegroups.com> <480887b8@news.mel.dft.com.au> Message-ID: On Apr 18, 8:36 am, John Machin wrote: > hdante wrote: > > > The character code in question (which is present in the page), 150, > > doesn't exist in ISO-8859-1. > > Are you sure? Consider (re-)reading all of the Wikipedia article. > > 150 aka \x96 doesn't exist in ISO 8859-1. ISO-8859-1 (two hyphens) is a > superset of ISO 8859-1 (one hyphen) and adds the not-very-useful-AFAICT > control codes \x80 to \x9F. > > > See > > > http://en.wikipedia.org/wiki/ISO/IEC_8859-1(the entry for 150 is > > blank) > > You must have been looking at the table of the "lite" ISO 8859-1 (one > hyphen). Reading further you will see \x96 described as SPA or "Start of > Guarded Area". Then there is the ISO-8859-1 (two hyphens) table, > including \x96. > > HTH, > John Sorry, that's right, I should have been referring to the second table. From mail at timgolden.me.uk Fri Apr 11 16:22:18 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 11 Apr 2008 21:22:18 +0100 Subject: Windows - window status (Running vs Not Responding) In-Reply-To: <5f4a5d63-c862-4d25-8849-6a36dd4e138d@m3g2000hsc.googlegroups.com> References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> <5f4a5d63-c862-4d25-8849-6a36dd4e138d@m3g2000hsc.googlegroups.com> Message-ID: <47FFC87A.1080209@timgolden.me.uk> Mike Driscoll wrote: > http://www.informit.com/articles/article.aspx?p=19489&seqNum=4 > > If you're better than I am, you can probably translate this to the > Python equivalent. Zenoss also has some monitoring software that's > open source Python code. I'm afraid that article only allows you to determine whether a known executable is running, If that's what the OP's after, then you can do as much by querying WMI thusly: import wmi c = wmi.WMI () EXE = "notepad.exe" for process in c.Win32_Process (Caption=EXE): print process break else: print "None found" TJG From ridenour4159 at gmail.com Thu Apr 24 06:12:46 2008 From: ridenour4159 at gmail.com (ridenour4159 at gmail.com) Date: Thu, 24 Apr 2008 03:12:46 -0700 (PDT) Subject: crack spyder Message-ID: crack spyder http://cracks.12w.net F R E E C R A C K S From dickinsm at gmail.com Sun Apr 6 18:12:31 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Sun, 6 Apr 2008 15:12:31 -0700 (PDT) Subject: A funnily inconsistent behavior of int and float References: Message-ID: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com> On Apr 6, 1:29?pm, Lie wrote: > I've noticed some oddly inconsistent behavior with int and float: > > Python 2.5.1 (r251:54863, Mar ?7 2008, 03:39:23) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2>>> int('- ? ? ? ? ?345') > > -345 > > works, but > > >>> float('- ? ? ? 345.083') > > Traceback (most recent call last): > ? File "", line 1, in > ValueError: invalid literal for float(): - ? ? ? 345.083 This is a known issue, that has been fixed for Python 3.0. It was decided not to risk breakage by changing this in Python 2.x. See: http://bugs.python.org/issue1779 Mark From ewertman at gmail.com Fri Apr 25 16:03:28 2008 From: ewertman at gmail.com (Eric Wertman) Date: Fri, 25 Apr 2008 16:03:28 -0400 Subject: Calling Python code from inside php In-Reply-To: References: <679e9oF2mti63U1@mid.uni-berlin.de> <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> Message-ID: <92da89760804251303y4288a5fapf0386a00dfed06e9@mail.gmail.com> > > A simple yet dangerous and rather rubbish solution (possibly more of a > > hack than a real implementation) could be achieved by using a > > technique described above: > > > > > echo exec('python foo.py'); > > This will spawn a Python interpreter, and not be particularly > efficient. You could just as well have used CGI. I'm in a bit of a similar situation. I decided to use python to solve problems where I could, in a more regimented fashion. For instance, I have a set of functions in a script, table.py. After I set up mod_python to handle requests to a single directory with python, I can call this with: embedded in the page. This is probably pretty hackish too, but at least it doesn't spawn a new process, and I don't have to solve things that aren't related to display with php. From patrickkidd.lists at gmail.com Fri Apr 11 15:28:33 2008 From: patrickkidd.lists at gmail.com (Patrick Stinson) Date: Fri, 11 Apr 2008 13:28:33 -0600 Subject: frozen/builtin modules and new interpreter instances Message-ID: <664bf2b80804111228l50561a30y1f6bbd56e7cf556@mail.gmail.com> So when creating a new interpreter (thread state) are you expected to re-set PyImport_FrozenModules and call yImport_ExtendInittab() again? the former seems to get corrupted between Py_Initialize() and Py_NewInterpreter(). I know that modules are not shared between interpreter instances, and it would be nice to know how to handle built-in, frozen, and statically linked modules. Any generic help on this topic would be great. Thanks! -- Patrick Kidd Stinson http://www.patrickkidd.com/ http://pkaudio.sourceforge.net/ http://pksampler.sourceforge.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From soray6034rao at gmail.com Wed Apr 30 07:29:31 2008 From: soray6034rao at gmail.com (soray6034rao at gmail.com) Date: Wed, 30 Apr 2008 04:29:31 -0700 (PDT) Subject: ulead video studio 8 serial crack Message-ID: <34ebac8a-68fe-4734-9a35-2b5727cb3444@8g2000hse.googlegroups.com> ulead video studio 8 serial crack http://crack.cracksofts.com From nagle at animats.com Mon Apr 28 14:41:41 2008 From: nagle at animats.com (John Nagle) Date: Mon, 28 Apr 2008 11:41:41 -0700 Subject: Tremendous slowdown due to garbage collection In-Reply-To: References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: <48161A65.6040705@animats.com> Dieter Maurer wrote: > Christian Heimes writes on Sat, 12 Apr 2008 18:47:32 +0200: >> andreas.eisele at gmail.com schrieb: >>> which made me suggest to use these as defaults, but then > We observed similar very bad behaviour -- in a Web application server. > Apparently, the standard behaviour is far from optimal when the > system contains a large number of objects and occationally, large > numbers of objects are created in a short time. > We have seen such behaviour during parsing of larger XML documents, for > example (in our Web application). Our solution to that was to modify BeautifulSoup to use weak pointers. All the pointers towards the root and towards previous parts of the document are "weak". As a result, reference counting alone is sufficient to manage the tree. We still keep GC enabled, but it doesn't find much to collect. John Nagle SiteTruth From bryon.mayo at gmail.com Sun Apr 13 00:16:24 2008 From: bryon.mayo at gmail.com (Bryon) Date: Sat, 12 Apr 2008 21:16:24 -0700 (PDT) Subject: Looking for a way to include Pyhtho scripting INSIDE a python program References: <48017af0$0$36399$742ec2ed@news.sonic.net> Message-ID: On Apr 12, 10:16 pm, John Antypas wrote: > Hello all, > > I'm writing in tool in Python that manipulates various data objects read > from various streams. I wanted to give the user a chance to do advanced > work that could not easily be done from a GUI. > > At first, I tried putting in a lightweight scripting language, and then > I thought, why not include Python in itself -- it is certainly powerful > enough. > > I had assumed I'd present the user with a text window in which they > could type arbitrary python code. I'd wrap that code around a function > and pass that function a call of objects they could manipulate by > calling the methods of that class. > > 1. How can a python program invoke ANOTHER interpreter? > 2. How can I pass the class in as its argument and get the modified > class back? > > I know I can do something very ugly -- call a C method that calls a new > python interpreter but that seems VERY ugly. > > Help? > > Thanks. I'm very new to python but I think this is what you're looking for http://pydoc.org/2.5.1/__builtin__.html#-compile From skanemupp at yahoo.se Sat Apr 5 01:05:35 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 4 Apr 2008 22:05:35 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <7113d012-01bb-4426-bb40-9e2811cdb102@x41g2000hsb.googlegroups.com> <3cf4bbc8-b828-45c5-b9a8-766ce600af43@y21g2000hsf.googlegroups.com> Message-ID: On 5 Apr, 07:02, skanem... at yahoo.se wrote: > On 5 Apr, 05:57, skanem... at yahoo.se wrote: > > > > > On 5 Apr, 05:26, 7stud wrote: > > > > On Apr 4, 7:06 pm, skanem... at yahoo.se wrote: > > > > > 1st question: > > > > > when i run this program 1 will be printed into the interpreter when i > > > > run it BUT without me clicking the actual button. > > > > when i then click the button "1", nothing happens. > > > > > obv i dont want any output when i dont push the button but i want it > > > > when i do. > > > > > what am i doing wrong here? > > > > > 2nd question: > > > > > i want all the buttons to have the same size. i thought i should use > > > > row/columnspan but i dont get that to work. > > > > how should i do? > > > > > [code] > > > > #! /usr/bin/env python > > > > from Tkinter import * > > > > import tkMessageBox > > > > > class GUIFramework(Frame): > > > > """This is the GUI""" > > > > > def __init__(self,master=None): > > > > """Initialize yourself""" > > > > > """Initialise the base class""" > > > > Frame.__init__(self,master) > > > > > """Set the Window Title""" > > > > self.master.title("Calculator") > > > > > """Display the main window" > > > > with a little bit of padding""" > > > > self.grid(padx=10,pady=10) > > > > self.CreateWidgets() > > > > > def CreateWidgets(self): > > > > > self.enText = Entry(self) > > > > self.enText.grid(row=0, column=0, columnspan=8, padx=5, > > > > pady=5) > > > > > self.enText = Entry(self) > > > > self.enText.grid(row=1, column=0, columnspan=8, padx=5, > > > > pady=5) > > > > > self.btnDisplay = Button(self, text="1", > > > > command=self.Display(1)) > > > > self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="2", default=ACTIVE) > > > > self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="3", default=ACTIVE) > > > > self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="+", default=ACTIVE) > > > > self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="4", default=ACTIVE) > > > > self.btnDisplay.grid(row=4, column=0, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="5", default=ACTIVE) > > > > self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="6", default=ACTIVE) > > > > self.btnDisplay.grid(row=4, column=2, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="-", default=ACTIVE) > > > > self.btnDisplay.grid(row=4, column=3, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="7", default=ACTIVE) > > > > self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="8", default=ACTIVE) > > > > self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="9", default=ACTIVE) > > > > self.btnDisplay.grid(row=5, column=2, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="*", default=ACTIVE) > > > > self.btnDisplay.grid(row=5, column=3, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="0", default=ACTIVE) > > > > self.btnDisplay.grid(row=6, column=0, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="C", default=ACTIVE) > > > > self.btnDisplay.grid(row=6, column=1, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="r", default=ACTIVE) > > > > self.btnDisplay.grid(row=6, column=2, padx=5, pady=5) > > > > > self.btnDisplay = Button(self, text="/", default=ACTIVE) > > > > self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) > > > > > def Display(self, xbtn): > > > > if xbtn==1: > > > > print 1 > > > > > if __name__ == "__main__": > > > > guiFrame = GUIFramework() > > > > guiFrame.mainloop() > > > > > [/code] > > > > If you have this function: > > > > def f(): > > > print 1 > > > return 10 > > > > and you write: > > > > result = f() > > > > The '()' is the function execution operator; it tells python to > > > execute the function. In this case, the function executes, and then > > > the return value of the function is assigned to the variable result. > > > If a function does not have a return statement, then the function > > > returns None by default. > > > > The same thing is happening in this portion of your code: > > > > command = self.Display(1) > > > > That code tells python to execute the Display function and assign the > > > function's return value to the variable command. As a result Display > > > executes and 1 is displayed. Then since Dispay does not have a return > > > statement, None is returned, and None is assigned to command. > > > Obviously, that is not what you want to do. > > > > What you want to do is assign a "function reference" to command so > > > that python can execute the function sometime later when you click on > > > the button. A function reference is just the function name without > > > the '()' after it. So you would write: > > > > command = self.Display > > > > But writing it like that doesn't allow *you* to pass any arguments to > > > Display(). In addition, *tkinter* does not pass any arguments to > > > Display when tkinter calls Display in response to a button click. As > > > a result, there is no way to pass an argument to Display. > > > > However, there is another way to cause a function to execute when an > > > event, like a button click, occurs on a widget: you use the widget's > > > bind() function: > > > > my_button.bind('', someFunc) > > > > The first argument tells tkinter what event to respond to. > > > '' is a left click. Check the docs for the different > > > strings that represent the different events that you can respond to. > > > The second argument is a function reference, which once again does not > > > allow you to pass any arguments to the function. However, when you > > > use bind() to attach a function to a widget, tkinter calls the > > > function and passes it one argument: the "event object". The event > > > object contains various pieces of information, and one piece of > > > information it contains is the widget upon which the event occurred, > > > e.g. the button that was clicked. To get the button, you write: > > > > Display(self, event_obj): > > > button = event_obj.widget > > > > Once you have the button, you can get the text on the button: > > > > Display(self, event_obj): > > > button = event_obj.widget > > > text = button.cget("text") > > > > if text=="1": > > > print 1 > > > > Another thing you should be aware of: self is like a class wide > > > bulletin board. If you are writing code inside a class method, and > > > there is data that you want code inside another class method to be > > > able to see, then post the data on the class wide bulletin board, i.e. > > > attach it to self. But in your code, you are doing this: > > > > self.btnDisplay = Button(self, text="7", default=ACTIVE) > > > self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > > > self.btnDisplay = Button(self, text="8", default=ACTIVE) > > > self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > > > As a result, your code continually overwrites self.btnDisplay. That > > > means you aren't preserving the data assigned to self.btnDisplay. > > > Therefore, the data does not need to be posted on the class wide > > > bulletin board for other class methods to see. So just write: > > > > btnDisplay = Button(self, text="7", default=ACTIVE) > > > btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > > > btnDisplay = Button(self, text="8", default=ACTIVE) > > > btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > > > As for the button sizing problem, your buttons are all the same size > > > and line up perfectly on mac os x 10.4.7. > > > wow thank you so much, awesome answer i will get right to fixing this > > now. > > > in regards to the buttonsizes i use windows VISTA and they have > > different sizes. > > one thing i dont rally get, i ahve to add my_button.bind() somewhere? > i changed the stuff u said though and i get this error(the program > executes though and i can press the buttons): > > Exception in Tkinter callback > Traceback (most recent call last): > File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ > return self.func(*args) > TypeError: Display() takes exactly 2 arguments (1 given) > > current version: > #! /usr/bin/env python > from Tkinter import * > import tkMessageBox > > class GUIFramework(Frame): > """This is the GUI""" > > def __init__(self,master=None): > """Initialize yourself""" > > """Initialise the base class""" > Frame.__init__(self,master) > > """Set the Window Title""" > self.master.title("Calculator") > > """Display the main window" > with a little bit of padding""" > self.grid(padx=10,pady=10) > self.CreateWidgets() > > def CreateWidgets(self): > > enText = Entry(self) > enText.grid(row=0, column=0, columnspan=8, padx=5, pady=5) > > enText = Entry(self) > enText.grid(row=1, column=0, columnspan=8, padx=5, pady=5) > > btnDisplay = Button(self, text="1", command=self.Display) > btnDisplay.grid(row=3, column=0, padx=5, pady=5) > > btnDisplay = Button(self, text="2", default=ACTIVE) > btnDisplay.grid(row=3, column=1, padx=5, pady=5) > > btnDisplay = Button(self, text="3", default=ACTIVE) > btnDisplay.grid(row=3, column=2, padx=5, pady=5) > > btnDisplay = Button(self, text="+", default=ACTIVE) > btnDisplay.grid(row=3, column=3, padx=5, pady=5) > > btnDisplay = Button(self, text="4", default=ACTIVE) > btnDisplay.grid(row=4, column=0, padx=5, pady=5) > > self.btnDisplay = Button(self, text="5", default=ACTIVE) > self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) > > btnDisplay = Button(self, text="6", default=ACTIVE) > btnDisplay.grid(row=4,... > > l?s mer ? and the self. i erased, should i do it in the def __init__ as well or only as i did in createwidgets-function? From lscbtfws at gmail.com Sat Apr 26 12:12:11 2008 From: lscbtfws at gmail.com (lscbtfws at gmail.com) Date: Sat, 26 Apr 2008 09:12:11 -0700 (PDT) Subject: dfx audio enhancer crack Message-ID: <44802168-6243-4d37-9221-52247a4f561f@q1g2000prf.googlegroups.com> dfx audio enhancer crack http://cracks.00bp.com F R E E C R A C K S From sjmachin at lexicon.net Sat Apr 19 16:36:49 2008 From: sjmachin at lexicon.net (John Machin) Date: Sat, 19 Apr 2008 20:36:49 GMT Subject: random.random(), random not defined!? In-Reply-To: <2a3931f5-481d-4831-baad-fcc9f0c0c129@m73g2000hsh.googlegroups.com> References: <2a3931f5-481d-4831-baad-fcc9f0c0c129@m73g2000hsh.googlegroups.com> Message-ID: <480a57de@news.mel.dft.com.au> globalrev wrote: > do i need to import something to use random? No, you need to import random From gagsl-py2 at yahoo.com.ar Fri Apr 11 00:05:52 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 11 Apr 2008 01:05:52 -0300 Subject: Module Conflicts References: <1592fad3-996b-4f62-ac12-42aff8272c21@8g2000hsu.googlegroups.com> <773d436c-2216-49ac-8e79-ca89618ac32f@q24g2000prf.googlegroups.com> Message-ID: En Thu, 10 Apr 2008 17:41:29 -0300, Ivan Illarionov escribi?: > On Apr 11, 12:31 am, Ivan Illarionov > wrote: >> On Apr 10, 2:33 am, Jose wrote: >> >> > I have a module named math.py in a package with some class >> > definitions. I am trying to import the standard python math module >> > inside of math.py but It seems to be importing itself. Is there any >> > way around this problem without renaming my math.py file? >> >> Yes, if you are using Python 2.5 >> >> from __future__ import absolute_import >> >> after this `import math` will always import standard math module and >> `from . import math` will import your module. > > And it's relatively easy to do in earlier versions too: > create subdirectory `stdmath` with one `__init__.py` file with one > line `import math` and than use `from stdmath import math`. Ah, thanks, it seems that the idea can be extended to almost all the standard library. Create a directory "stdlib" somewhere on sys.path, with a single file __init__.py containing this single line: __path__.append("path/to/python/standard/lib") Now, `import stdlib.gzip` will import the standard gzip module, even if there is a gzip.py in the current directory or in some other place along sys.path. That is, we have made a package out of the standard library. Unfortunately it doesn't work for math as-is because math is a builtin module (at least on Windows), but this should work for all other "normal" Python-level modules. (It's a hack, and I would never use this on production code, but it may be useful sometimes) -- Gabriel Genellina From sjmachin at lexicon.net Tue Apr 22 17:50:10 2008 From: sjmachin at lexicon.net (John Machin) Date: Tue, 22 Apr 2008 21:50:10 GMT Subject: list manipulation In-Reply-To: References: <78158460-8508-4453-a2dc-c5814dda8839@59g2000hsb.googlegroups.com> Message-ID: <480e5d93$1@news.mel.dft.com.au> Joe Riopel wrote: > On Tue, Apr 22, 2008 at 4:55 PM, DataSmash wrote: >> Hello, >> >> I have a list that looks like this: >> roadList = ["Motorways","Local","Arterial"] >> >> I want to apply some code so that the output looks like this: >> "Motorways;Local;Arterial" >> How can this be done with the LEAST amount of code? > > Not sure if it's LEAST amount of code, or the best, but it works. It's definitely not the least (see below) and it doesn't work -- it puts a ; after the last list item. > >>>> li = ["Motorways","Local","Arterial"] >>>> '\"%s\"' % (''.join(['%s;' % (x,) for x in li]),) > '"Motorways;Local;Arterial;"' That is littered with redundant punctuation. Removing it: >>> '"%s"' % ''.join('%s;' % x for x in li) '"Motorways;Local;Arterial;"' Note: that would need the [] put back for Python < 2.4. But in any case we can further reduce it like this: >>> '"%s;"' % ';'.join(li) '"Motorways;Local;Arterial;"' >>> Now we have minimal, legible code which works on Python back to 2.1 at least and is only one thump of the Delete key away from what the OP asked for. HTH, John From n00m at narod.ru Sat Apr 26 12:15:17 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 09:15:17 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> Message-ID: <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> fgets() from C++ iostream library??? I guess if I'd came up with "Python reads SLOWER than C" I'd get another (not less) smart explanation "why it's so". From andrew at acooke.org Tue Apr 15 05:08:24 2008 From: andrew at acooke.org (andrew cooke) Date: Tue, 15 Apr 2008 02:08:24 -0700 (PDT) Subject: Dynamic use of property() fails References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> <480461f8$0$20282$426a34cc@news.free.fr> Message-ID: OK, fixed my bug - it does work. Now sleep... Thanks again, Andrew From jkn at nicorp.co.uk Wed Apr 2 16:00:53 2008 From: jkn at nicorp.co.uk (Jon Nicoll) Date: Wed, 02 Apr 2008 21:00:53 +0100 Subject: who said python can't be obsfucated!? References: Message-ID: <18WdnajQathueG7anZ2dnUVZ8sninZ2d@plusnet> cokofreedom at gmail.com wrote: > def s(c):return[]if c==[]else s([_ for _ in c[1:]if _ +s([_ for _ in c[1:]if _>=c[0]]) > > Anyone else got some wonders...? looks like one of castironpi's postings... J^n From mal at egenix.com Thu Apr 17 07:33:43 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Thu, 17 Apr 2008 13:33:43 +0200 Subject: Python module for reading FilePro files? In-Reply-To: References: Message-ID: <48073597.9070503@egenix.com> On 2008-04-16 15:53, Steve Bergman wrote: > Does anyone know of a Python package or module to read data files from > the venerable old Filepro crossplatform database/IDE? No, but there is Filepro support in PHP, so you could write a PHP script which reads the data and then exports it to some other database format which can be read by Python. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 17 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From ajaksu at gmail.com Wed Apr 2 16:57:12 2008 From: ajaksu at gmail.com (ajaksu) Date: Wed, 2 Apr 2008 13:57:12 -0700 (PDT) Subject: Recursive function won't compile References: Message-ID: On Apr 2, 5:23?pm, bc1... at googlemail.com wrote: > #include > #include > > def RecursiveFact(n): > ? ? if(n>1): > ? ? ? ? return n*RecursiveFact(n-1) > ? ? else: > ? ? ? ? return 1 > > fact = RecursiveFact(31) > print fact The output is 8222838654177922817725562880000000 and is correct. But the "#include"s tell me you're a bit confused. Have you tried running "python yourscript.py" (where "yourscript.py" is the filename you saved the above program to)? HTH, Daniel From sturlamolden at yahoo.no Sun Apr 20 20:48:09 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sun, 20 Apr 2008 17:48:09 -0700 (PDT) Subject: Nested lists, simple though References: Message-ID: On Apr 21, 2:35 am, sturlamolden wrote: > This also shows how easy it is to boost the performance of Python code > using Cython. We can improve this further by getting rid of the tmp.append attribue lookup: cdef _flatten(lst, append): for elem in lst: if type(elem) != list: append(elem) else: _flatten(elem, append) def flatten(lst): tmp = [] _flatten(lst, tmp.append) return tmp From jcd at unc.edu Fri Apr 18 13:27:10 2008 From: jcd at unc.edu (J. Cliff Dyer) Date: Fri, 18 Apr 2008 13:27:10 -0400 Subject: py3k concerns. An example In-Reply-To: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: <1208539630.5081.17.camel@aalcdl07.lib.unc.edu> On Fri, 2008-04-18 at 08:58 -0700, Aaron Watters wrote: > Why is the migration to py3k a concern? > For example I have libraries which use string%dictionary > substitution where the dictionary is actually an object > which emulates a dictionary. The __getitem__ for > the object can be very expensive and is only called when > needed by the string substitution. > > In py3k string%dictionary is going away. Why? > I have no idea. > > The replacement is a string.format(...) method > which supports dictionary calling. > string.format(**dictionary) > But dictionary > calling doesn't support dictionary emulation. > So in the example below the substitution works > but the call fails. > > === code > > class fdict(dict): > def __getitem__(self, item): > return "got("+item+")" > > def fn(**d): > print d["boogie"] > > if __name__=="__main__": > fd = fdict() > print "attempting string substitution with fake dictionary" > print > print "hello there %(boogie)s" % fd # <-- works > print > print "now attempting function call with fake dictionary" > print > fn(**fd) # <-- fails > > === output > > % python2.6 dtest.py > attempting string substitution with fake dictionary > > hello there got(boogie) > > now attempting function call with fake dictionary > > Traceback (most recent call last): > File "dtest.py", line 17, in > fn(**fd) > File "dtest.py", line 7, in fn > print d["boogie"] > KeyError: 'boogie' > > ==== end of output > > Consequently there is no simple way to translate > my code, I think. I suspect you will find this kind of subtle > issue in many places. Or worse, you won't find it > until after your program has been installed > in production. > > It's a damn shame because > if string%dict was just left in it wouldn't be an issue. > > Also, if making f(**d) support dict emulation > has any negative performance implications > then I don't want it please. > > sigh. -- Aaron Watters > > === > http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=crack+open > I was with you on this issue right up until that last paragraph. You want it, but only if its free. That's ridiculous. Every thing a computer does requires processor cycles. Do you really mean to tell me that string interpolation has been a major bottleneck for you? Now I think you're just whining because you like to hear yourself whine. Try coming up with a real standard for evaluation. How much of a performance hit will actually cause you trouble? 1% extra on string interpolation? 10%? 50%? 200%? You do provide a link to a website called xfeedme.com. And I just fed you. IHBT. HAND. :-/ -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill From martin at v.loewis.de Sun Apr 27 13:33:56 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 27 Apr 2008 19:33:56 +0200 Subject: Tremendous slowdown due to garbage collection In-Reply-To: References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: <4814B904.1070804@v.loewis.de> > Martin said it but nevertheless it might not be true. > > We observed similar very bad behaviour -- in a Web application server. > Apparently, the standard behaviour is far from optimal when the > system contains a large number of objects and occationally, large > numbers of objects are created in a short time. > We have seen such behaviour during parsing of larger XML documents, for > example (in our Web application). I don't want to claim that the *algorithm* works for all typically applications well. I just claim that the *parameters* of it are fine. The OP originally proposed to change the parameters, making garbage collection run less frequently. This would a) have bad consequences in terms of memory consumption on programs that do have allocation spikes, and b) have no effect on the asymptotic complexity of the algorithm in the case discussed. It may well be that other algorithms would perform better, but none have been contributed. Regards, Martin From kyosohma at gmail.com Fri Apr 25 09:17:56 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 25 Apr 2008 06:17:56 -0700 (PDT) Subject: Environment Variables References: Message-ID: On Apr 25, 8:07?am, Krishna wrote: > Environment variable set up is the most confusing part for me all the > time. Please help me with the following questions: > > When I install python in a new system, I will go to environment > variables (system variables) and set "path" pointing to C:\Python25 > and thats all I do. > I type python from "cmd" window and its converting to python window > for python execution. All fine up to this point. > Now, I want to drag and drop python (.py) files to this window and > execute it. My python files are located in different directories > inside C: and outside C:. When I do that, I get errors and the file is > not found and its not imported. ALso, inside the .py file, if I have a > command to open a different file, it doesnt see that either. How do I > overcome these basic difficulties in python. I wish I can open any > file and work on that using python. > > Thanks for your help! > Krishna I'm pretty sure you can't do that in a command window. I tried it on my Windows XP machine and all I get in my instance of IDLE is the path to the file. It DOES work with PythonWin, which is the ActiveState version of Python. The only difference is that it include the win32 modules and has a more advanced editor. You can probably get this to work in other more advanced editors, like WingIDE or PyDev too. Mike From gillet at scripps.edu Thu Apr 24 21:05:58 2008 From: gillet at scripps.edu (Alexandre Gillet) Date: Thu, 24 Apr 2008 18:05:58 -0700 Subject: Problem building python in virtual machine running centos Message-ID: <1209085558.20290.3.camel@solomon> Hi, I am trying to build python-2.4.5 on Centos 5.1, which is a virtual machine running with xen. I am not able to build python. The compilation crash with the following: gcc -pthread -c -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -o Objects/unicodeobject.o Objects/unicodeobject.c In file included from ./Include/Python.h:76, from Objects/unicodeobject.c:39: ./Include/object.h:228: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See for instructions. The bug is not reproducible, so it is likely a hardware or OS problem. Any suggestion of what am I doing wrong? Thanks Alex -- o Alexandre Gillet Ph.D. email: gillet at scripps.edu / The Scripps Research Institute, o Dept. Molecular Biology, MB-5, \ 10550 North Torrey Pines Road, o La Jolla, CA 92037-1000, USA. / tel: (858) 784-2053 o fax: (858) 784-2860 web: http://mgl.scripps.edu/projects/tangible_models/ From mitko at qlogic.com Mon Apr 21 20:00:16 2008 From: mitko at qlogic.com (Mitko Haralanov) Date: Mon, 21 Apr 2008 17:00:16 -0700 Subject: Segfault accessing dictionary in C Python module Message-ID: <20080421170016.6d6fb378@hematite.mv.qlogic.com> I have a Python module that I have written using the C API and I am having a problem accessing a dictionary from that module. Here is what I have done: 1. In my init function I call module = Py_InitModule ("name", methods); 2. then I get the module's __dict__ structure: dict = PyModule_GetDict (module); 3. Later, I insert a dictionary that I have constructed using the PyDict_* API new_dict = PyDict_New (); PyDict_SetItemString (dict, "dict_name", new_dict); Here is the problem: In one of my methods, I need to retrieve the new_dict dictionary and use it to get a value out of it. I get the dictionary using the PyObject_GetAttrString function: new_dict = PyObject_GetAttrString (module, "dict_name"); (module is a global variable for the file) I make the key from an int with: key = PyInt_FromLong (state); (where state is an int variable) and then get the value for that key: value = PyDict_GetItem (new_dict, key); The problem is that for the first few times I call the function, everything work but after that value (which should contain a PyString) starts getting random values and eventually my program crashes with a segfault. When I try to print the address of the dict variable returned by PyObject_GetAttrString() I always get the same value, so the function is returning the same thing. However, when I try to print the string representation of the return value with this: obj = PyObject_Str (new_dict); if (PyString_Check (obj)) printf ("%s\n", PyString_AsString (obj)); it works the first few calls and then my program segfaults at the PyObject_Str (new_dict) call. As far as I know, I have done everything by the book yet I can't seem to figure out where the problem is. Any help would be great? Thank you -- Mitko Haralanov mitko at qlogic.com Senior Software Engineer 650.934.8064 HSG InfiniBand Engineering http://www.qlogic.com ========================================== There are never any bugs you haven't found yet. From gagsl-py2 at yahoo.com.ar Wed Apr 16 01:43:07 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 02:43:07 -0300 Subject: tkinter, event.widget, what do i get? References: <7caa5089-2ea9-4e18-9117-7431d7403976@l42g2000hsc.googlegroups.com> <3a6f6d87-0102-4995-a033-501137b3f934@s50g2000hsb.googlegroups.com> Message-ID: En Tue, 15 Apr 2008 20:45:24 -0300, escribi?: > On 16 Apr, 00:24, "Gabriel Genellina" wrote: >> En Tue, 15 Apr 2008 17:45:08 -0300, escribi?: >> >> > when calling function hmm here, what do i get? the widget i clicked >> > on? >> > if i have a canvs on wich i have a bitmap and i click on the bitmap, >> > is the event.widget then the bitmap? >> > can i get info about the bitmap then? like color of the pixel i >> > clicked. if so, how? >> >> > w.bind("", key) >> > w.bind("", hmm) >> >> > def hmm(event): >> > return event.widget >> >> Why don't you try by yourself? You can use: print repr(something) > > i get > > thing is i get that even though i click outside the image. So you answered your first question yourself: event.widget is the canvas, not the bitmap. On another thread you get the other answer. > and what can i do with this number anyway? With that specific number, nothing. The whole text says two things: - *what* the object is: a Tkinter.Canvas instance - *which* one: this is not the same one as -- Gabriel Genellina From castironpi at gmail.com Wed Apr 2 13:08:29 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 2 Apr 2008 10:08:29 -0700 (PDT) Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> Message-ID: On Apr 2, 11:41?am, "Dan Upton" wrote: > > ?The thing I've been wondering is why _is_ it read-only? In what > > ?circumstances having write access to co_code would break the language > > ?or do some other nasty stuff? > > > ?Jo?o Neves > > I can't speak to Python's implementation in particular, but > self-modifying code in general is unpleasant. ?It certainly is > possible to support it in runtime environments, but it's usually not > easy to do so. ?That is, of course, somewhat dependent on the > implementation of the runtime environment, and even to some degree the > underlying hardware. ?(For instance, the compiled code you want to run > could be in the hardware cache; if you then change the instructions at > those addresses in memory, it's not always straightforward to get the > processor to realize it needs to load the new data into the > instruction cache.) ?Plus, I suppose it might be possible to break > strong (even dynamic) typing if you start changing the code around > (although I can't construct an example off the top of my head). > > In short, you need a good reason to support self-modifying code, and > my guess is nobody could come up with one for Python. > > -dan Not in the least. You can avoid a lot of if statements, if you have so many, by enumerating functions to call. "Then call this", i.e. turn functions on and off. However, there may be data structures which can accomplish this in constant time too... any takers? From basilisk96 at gmail.com Tue Apr 1 17:57:57 2008 From: basilisk96 at gmail.com (Basilisk96) Date: Tue, 1 Apr 2008 14:57:57 -0700 (PDT) Subject: Is this a good time to start learning python? References: <47f1140e$0$735$a729d347@news.telepac.pt> Message-ID: On Mar 31, 11:40 am, Rui Maciel wrote: > Recently I woke up inclined to take up the task of learning another > programming language. I've already dipped my toes in Perl (I've read online > tutorials and wrote a couple of irrelevant pet projects) but, as the > computers at my workplace only sport the python interpreter, it probably > means that learning python will end up serving me better, at least in the > short run. Plus, you know how Perl goes. > > So far the decision seems to be a no brainer. Yet, Python 3000 will arrive > in a few months. As it isn't backwards compatible with today's Python, > there is the risk that no matter what I learn until then, I will end up > having to re-learn at least a considerable part of the language. To put it > in other words, I fear that I will be wasting my time. > > At least that is what a clueless newbie believes. As this group is > frequented by people who have more insight into all things pythonesque, > what are your thoughts on this? > > Thanks for the help > Rui Maciel Think of it this way - A.) If you start learning Python 2.5 *today*, and then Python3k comes out in a few months and (at worst) breaks all your code, you will still have less code to patch than the person who learned Python 2.3 two years ago :) B.) If you start learning Python 2.5 *tomorrow*... who knows, we might not be alive tomorrow. Seize the day. Seriously, I have watched Guido's GoogleTalk on Py3k plans, and the changes are not all that scary. I'm looking forward to it. Cheers, -Basilisk96 From sam at mas.pl Thu Apr 3 04:20:48 2008 From: sam at mas.pl (sam) Date: Thu, 03 Apr 2008 10:20:48 +0200 Subject: Prototype OO In-Reply-To: References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> Message-ID: Gabriel Genellina napisa?(a): >> Yes. Funciton is always a piece of code (program) that does something. >> There is >> no need for different syntax. > > Guido has regretted lambda for a long time; it was scheduled for > deletion on Python 3000 [2] but finally will stay [3]. Thanks for that info and links. > Class methods and instance methods are not just standard functions; > instance methods were plain functions before 2.2 and the Class object > was in charge of doing the "self magic". Now the descriptor protocol > provides far more possibilities. Actually I don't know what is "descriptor protocol", so maybe I should have finished discussing. I will aslo search for "self magic" -- some pieces of old code, or something. > I didn't say that (note that you trimmed most attribution lines) but I > like to have "short anonymous functions" altough the syntax might be > different. Perhaps in Python 4000. And I say "syntax should be the same". These are only opinions, so forgive me for wasting your time. From hdante at gmail.com Fri Apr 25 23:04:32 2008 From: hdante at gmail.com (hdante) Date: Fri, 25 Apr 2008 20:04:32 -0700 (PDT) Subject: problem with mmap References: Message-ID: <316a2265-4328-4443-a622-fda37ada52e9@e39g2000hsf.googlegroups.com> On Apr 25, 4:43?pm, Carl Banks wrote: > On Apr 25, 9:37 am, Neal Becker wrote: > > > On linux, I don't understand why: > > > f = open ('/dev/eos', 'rw') > > m = mmap.mmap(f.fileno(), 1000000, prot=mmap.PROT_READ|mmap.PROT_WRITE, > > flags=mmap.MAP_SHARED) > > > gives 'permission denied', > > Try > > f = open('/dev/eos', 'r+') > > Carl Banks The equivalent code in python should be: import os, mmap f = os.open('/dev/eos', os.O_RDWR) m = mmap.mmap(f, 1000000, prot=mmap.PROT_READ|mmap.PROT_WRITE, flags=mmap.MAP_SHARED) That should work like the C++ code. From noah at noah.org Wed Apr 9 16:11:02 2008 From: noah at noah.org (Noah) Date: Wed, 9 Apr 2008 13:11:02 -0700 (PDT) Subject: Control process execution References: <1d1bbea2-a503-4db5-bd3f-c45c29916b9c@13g2000hsb.googlegroups.com> Message-ID: On Apr 6, 5:30 am, Wesley Mesquita wrote: > I am trying to create a test environment to a couple C applications > (simple UDP and TCP server/clients), so I want to write this in python > and I m looking for ways to do it. Basically I need an execution timer > and timeout control (to kill the apps in certain situations). Looking > at google, I found the Pexpect package, but I m a little bit lost in > using it. Pexpect might be good. But if you are just looking at running an application without talking to it interactively then you might be able to just get by with os.process. -- Noah From n00m at narod.ru Sat Apr 26 21:43:48 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 18:43:48 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <54dc008c-a747-4507-a2d5-9b4ddccbd5b9@e53g2000hsa.googlegroups.com> Message-ID: <3a7541ae-8aa2-46d5-93a3-115f9e2a3c38@l42g2000hsc.googlegroups.com> I'm there since summer 2004 :) (with several time breaks) From skanemupp at yahoo.se Thu Apr 10 08:35:23 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 05:35:23 -0700 (PDT) Subject: tkinter, overwrite Label-text? Message-ID: using python And tkinter. i have a GUI that outputs a text among other things. after input form user i want this text to be *)cleared and/or *)overwritten. what is the best way to achieve that? also, how do i make Label-text expand to the right and not to the left? From steve at holdenweb.com Wed Apr 9 11:10:47 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 11:10:47 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> Message-ID: <47FCDC77.7030407@holdenweb.com> Victor Subervi wrote: > On Wed, Apr 9, 2008 at 10:24 AM, Steve Holden > wrote: > > Victor Subervi wrote: > > On Wed, Apr 9, 2008 at 1:14 AM, Gabriel Genellina > > > >> wrote: > > > > Now all you have to do is what I told you in the first place, which is > to remove the print statements before and after "print content". > > > That is what I figured after I sent the email. However, I had tried that > with a test script and the working script, with bad results. Here is the > test script that should have worked flawlessly: > > #! /usr/bin/python > > import MySQLdb > > print "Content-type: image/jpeg\r\n" > host = 'host' > db = 'bre' > user = 'user' > passwd = 'pass' > connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > cursor = connection.cursor() > cursor.execute('select img from photo where id="7";') > content = cursor.fetchall() Bzzt! Nope. Cursor.fetchall() returns a list (length 1) or tuples (length 1) here, so this should be content = cursor.fetchall()[0][0] or, perhaps better content = cursor.fetchone()[0] > print "Content-Type: image/jpeg\nContent-Length: %d\n" % len(content) > print content > connection.commit() The line above is completely unnecessary if the database has not been changed. > connection.close() > > This prints out the URL as an image! No idea why. But it does not > produce the desired image. > I've no idea why either, but try fixing the script and see what that does. > The following is the heart of the script for display. I tried entering > the Content-type where indicated, but it produces everything up to the > image, then produces the result of code from the exception... > > cursor.execute('select id from products where category="' + category > + '" order by sort_factor desc, price desc;') > ids = cursor.fetchall() > if len(ids[0]) != 0: > for id in ids: > for d in id: > print '\n' > cursor.execute('select * from products where id = ' + str(d) + > ';') > col_fields = cursor.fetchall() > if lang == 'es': > print 'ID: ', col_fields[0][0], '
' > print 'Nombre: ', col_fields[0][2], '
' > print 'T?tulo: ', col_fields[0][6], '
' > print 'Descripci?n: ', col_fields[0][9], '
' > print 'Precio: ', col_fields[0][11], '
' > print 'Rec?maras: ', col_fields[0][12], '
' > print 'Ba?os: ', col_fields[0][13], '
' > content = col_fields[0][14].tostring() > print "Content-Type: image/jpeg\nContent-Length: %d\n" % > len(content) > print content, '

' You really don't understand how the web works, do you? In order to include an image in a page your browser must make TWO requests. The first is for an HTML page that will reference the image in this way: Seeing this img tag causes the browser to make a SECOND request, which the script I corrected above should respond to with an image. The bytestream is critical in the image response. Even one misplaced byte will mess things up terribly. > ... > except: > if lang == 'es': > print 'Lo siento. Todav?a no tenemos propiedades para ense?arse en > la categor?a de ', category, '.\n

' > > > > You are NOT generating HTML, you are generating a JPEG image. > > > I am producing both, and this is causing me confusion. Read an explanation of HTML and images if my brief treatise above was insufficient. > BTW, when we are finally done with this, I will write a nice how-to > (since there is not one in python, while php has some nice ones) on how > to do this, and give you and Gabrielle all your due credit. I will post > it to this list, because that is sure to rank highly in google right away. > Victor > That's great, though hardly the point of the exercise. I think Google already know about Gabriel (*not* Gabrielle) and me already ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From castironpi at gmail.com Wed Apr 23 16:55:20 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 23 Apr 2008 13:55:20 -0700 (PDT) Subject: Partition list with predicate References: <925822270804230959v557ec5f5re02737709f94d3c6@mail.gmail.com> Message-ID: On Apr 23, 2:26?pm, Steve Holden wrote: > Terry Reedy wrote: > > "Jared Grubb" wrote in message > >news:925822270804230959v557ec5f5re02737709f94d3c6 at mail.gmail.com... > > | I want a function that removes values from a list if a predicate > > evaluates > > | to True. > > > Forget the rigamarole you posted, which has several defects. > > If you must modify the list in place, because you have multiple references > > to it: > > > lst[:] = filter(lambda x: not pred(x), lst) > > Wouldn't > > lst[:] = [x for x in lst if not pred(x)] > > be more direct? > > > Otherwise, just lst = filter(....) > > And similarly > > lst = [x for x in lst if not pred(x)] > > regards > ? Steve > -- > Steve Holden ? ? ? ?+1 571 484 6266 ? +1 800 494 3119 > Holden Web LLC ? ? ? ? ? ? ?http://www.holdenweb.com/ And, actually, if you aren't using the GIL, immutables historically come with locks, which carries concerns with reality (spatialty +localty), i.e. money, if your technique gains from computer speed, but there's a right one for a market nitch. It could be that computers are doing all they can for everybody's public's good, so if so, every alternative will be profitable recreationally only. No reason you can't write a mutable structure that supports multiple references and keep it off the hard drive, but without defining Clear( time0, b ) + Set( time0, b ), you can't beat macrolocks without micros. And of course, neither RAM nor magnetics offer stereo (two-dimensional +) seek mechanisms today. But we'll be allocating squares of memory eventually. All technologies are inevitable. From balta96428 at gmail.com Wed Apr 23 05:53:20 2008 From: balta96428 at gmail.com (balta96428 at gmail.com) Date: Wed, 23 Apr 2008 02:53:20 -0700 (PDT) Subject: vala's pumpkin patch Message-ID: <0878f546-bdb4-4b99-ac45-d34ea0c6c836@z72g2000hsb.googlegroups.com> vala's pumpkin patch http://cracks.12w.net F R E E C R A C K S From dieter at handshake.de Sun Apr 27 13:15:58 2008 From: dieter at handshake.de (Dieter Maurer) Date: 27 Apr 2008 19:15:58 +0200 Subject: Tremendous slowdown due to garbage collection In-Reply-To: References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: Christian Heimes writes on Sat, 12 Apr 2008 18:47:32 +0200: > andreas.eisele at gmail.com schrieb: > > which made me suggest to use these as defaults, but then > > Martin v. L?wis wrote that > > > >> No, the defaults are correct for typical applications. > > > > At that point I felt lost and as the general wish in that thread was > > to move > > discussion to comp.lang.python, I brought it up here, in a modified > > and simplified form. > > Martin said that the default settings for the cyclic gc works for most > people. Your test case has found a pathologic corner case which is *not* > typical for common application but typical for an artificial benchmark. > Python is optimized for regular apps, not for benchmark (like some video > drivers). Martin said it but nevertheless it might not be true. We observed similar very bad behaviour -- in a Web application server. Apparently, the standard behaviour is far from optimal when the system contains a large number of objects and occationally, large numbers of objects are created in a short time. We have seen such behaviour during parsing of larger XML documents, for example (in our Web application). Dieter From sn at sncs.se Mon Apr 14 21:38:30 2008 From: sn at sncs.se (Sverker Nilsson) Date: Mon, 14 Apr 2008 18:38:30 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> Message-ID: <61bbc2b5-d3cf-4791-a7c6-d642878c41d4@b64g2000hsa.googlegroups.com> On Apr 15, 2:58 am, ajaksu wrote: > On Apr 14, 8:10 pm, Sverker Nilsson wrote:> do i dare to open a thread about this? > > Yeah, you sure do! > > > come on you braver men > > Yeah! > > > we are at least not bought by g***le > > Hell no! > > > but why? others have said it so many times i think > > Huh?! > > > :-//// > > ?! Whatever! > > > but why? a few syntactic 'cleanups' for the cost of a huge rewrite of > > all the code that have been builtup from all the beginning when the > > once great Python came along and people began to use it and write code > > for it. Like all that code would have to be rewritten. blaah. > > Yeah! Woo-hoo! > Wait... What? No, no, you got it all wrong. Python developers are > being extra-careful and doing a lot of hard work to keep things sane, > allow easy migration, etc. > > > and i have perhaps been drinking but i have been p**d all week since i > > began look into this:-( > > Ah, OK, calm down and look again. Things are way better than you > think, but there is a lot of FUD going on too, so focus on serious, > reliable reports. > > Cheers, > Daniel I was serious! It's just from my right brain half. I take it you are ironic, I appreciate it, hope we will hear from some Director..... doesnt matter perhapss I said what I said, now I am just trollin or trying How do one troll best? I know but I can also sell you Rolexes for a good price... S-- And what should I say? Perhaps that the debate on the the py3k list is ---- I cant find the word because i am swedish, but it is just that most people or some are so concerned about they having 'commit- privileges' that the don't dare say anything contoversial that would go against mr. GVR. so this is a much freer forum.Not that I am more intelligent than GVR but we can at least debate, though I doubt he has the time:-) So, regrds to all and hope you guys want to continut the debate... Sverker From spe.stani.be at gmail.com Mon Apr 7 09:20:32 2008 From: spe.stani.be at gmail.com (SPE - Stani's Python Editor) Date: Mon, 7 Apr 2008 06:20:32 -0700 (PDT) Subject: Wxpython. Is it possible to change layout in a running application? Selfmade listbox References: <716c0f27-bca6-4642-a8ec-cdbb0b23e6e8@h1g2000prh.googlegroups.com> <105355bb-2d56-491e-8764-e4c34a0de8c5@d45g2000hsc.googlegroups.com> Message-ID: On Apr 7, 2:54?pm, Mike Driscoll wrote: > On Apr 7, 6:50 am, Soren wrote: > > Hi, > > > Id like to make my own special listbox.. I want to able (at the push > > of a button) to add another item to my special listbox... each item is > > a panel with a label, some buttons and maybe a text control. > > > I've tried adding a new panel object with the stuff i want to the > > sizer i'm using for my listbox (which is a panel which can contain > > other panels)... and then run update() and refresh() on everything... > > But it doesn't work.. i see a panel appearing, but it's just a small > > square in the corner of my "listbox" panel, and it only works the > > first time... nothing new appears when I push the button again. > > > Is it at all possible to do this? Has anyone created something > > similar? Does anyone know what i'm doing wrong? To remove any doubt, yes this is possible. I guess you forgot to call the Layout method of the sizer (only update or refresh won't help). > Also, you will probably receive more help at the wxPython specific > list, found here: > > http://wxpython.org/maillist.php That is indeed the best list for wxpython related issues. Good luck, Stani -- Phatch - Photo Batch Processor - http://photobatch.stani.be SPE - Python Editor - http://pythonide.stani.be From bearophileHUGS at lycos.com Wed Apr 9 09:46:52 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Wed, 9 Apr 2008 06:46:52 -0700 (PDT) Subject: Basic optimization of python. References: Message-ID: ShenLei: > t = self.a.b > t.c = ... > t.d = ... > .vs. > self.a.b.c = ... > self.a.b.d = ... > which one is more effective? Since each dot invokes a hash table lookup, it > may be time consuming. If the compiler can do expression folding, then no > manual folding is needed. Removing dots creating a temporary variable speeds up the program, but doing it is useful only in special critical spots, like inside certain large loops, etc. A similar optimization is to use a local instead of a global: from foo import bar def baz(bar=bar): for i in xrange(100000): bar(...) Note that with psyco you often don't need such things. Bye, bearophile From steveo at syslang.net Tue Apr 8 11:31:21 2008 From: steveo at syslang.net (Steven W. Orr) Date: Tue, 8 Apr 2008 11:31:21 -0400 (EDT) Subject: wxPython scrolling question. Message-ID: I just discovered Accelerator entries so my wx app is now able to exit by typing Ctrl-Q. Can someone please tell me what to use to cause a pane to scroll up and down using the middle mouse scroll roller thingy? I looked and found wxCURSOR_MIDDLE_BUTTON but I suspect that's only good for clicking with the middle mouse button. I also found something called WXK_SCROLL, but how do I tell which direction the scroll is going? TIA -- Time flies like the wind. Fruit flies like a banana. Stranger things have .0. happened but none stranger than this. Does your driver's license say Organ ..0 Donor?Black holes are where God divided by zero. Listen to me! We are all- 000 individuals! What if this weren't a hypothetical question? steveo at syslang.net From steve at holdenweb.com Wed Apr 9 11:50:36 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 11:50:36 -0400 Subject: Trouble with list comprehension In-Reply-To: <4c3db5c00804090830p1b05748drf4ee5b8c3185ad9e@mail.gmail.com> References: <4c3db5c00804090830p1b05748drf4ee5b8c3185ad9e@mail.gmail.com> Message-ID: Shane Lillie wrote: > I've got a bit of code that looks like this: > > for i in xrange(1000): > # shuffle the doors > doors = [ 'G', 'C', 'G' ] > random.shuffle(doors) > > # save the doors that have goats (by index) > goats = [ x for x in range(2) if doors[x] == 'G' ] > > but for some reason the list comprehension is not always returning a > list with 2 elements in it (sometimes it will be just 1 element). I've > tried changing to a generator as well as using filter() and all 3 give > the same sort of results. It works if I use a loop, but I'd really > like to know what I'm doing wrong here. Everything looks like it > should be working. > > Thanks in advance for any suggestions. Hint: len(range(2)) != 3 regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From marek.rocki at wp.pl Sun Apr 6 15:54:50 2008 From: marek.rocki at wp.pl (marek.rocki at wp.pl) Date: Sun, 6 Apr 2008 12:54:50 -0700 (PDT) Subject: Form sha1.hexdigest to sha1.digest References: <7c39af89-9cee-428c-a0bc-8202700c5aec@b1g2000hsg.googlegroups.com> <47F8CF66.1020805@v.loewis.de> Message-ID: Martin v. L?wis napisa?(a): > > How can convert string from sha1.hexdigest() to string that is the > > same, like from sha1.digest() > > Use binascii.unhexlify. > > HTH, > Martin Or hexdigest_string.decode('hex') From needin4mation at gmail.com Wed Apr 9 17:03:30 2008 From: needin4mation at gmail.com (jmDesktop) Date: Wed, 9 Apr 2008 14:03:30 -0700 (PDT) Subject: basic python question about for loop References: Message-ID: On Apr 9, 4:59?pm, "Reedick, Andrew" wrote: > > -----Original Message----- > > From: python-list-bounces+jr9445=att.... at python.org [mailto:python- > > list-bounces+jr9445=att.... at python.org] On Behalf Of jmDesktop > > Sent: Wednesday, April 09, 2008 4:51 PM > > To: python-l... at python.org > > Subject: basic python question about for loop > > > >From the Python.org tutorial: > > > >>> for n in range(2, 10): > > ... ? ? for x in range(2, n): > > ... ? ? ? ? if n % x == 0: > > ... ? ? ? ? ? ? print n, 'equals', x, '*', n/x > > ... ? ? ? ? ? ? break > > ... ? ? else: > > ... ? ? ? ? # loop fell through without finding a factor > > ... ? ? ? ? print n, 'is a prime number' > > ... > > 2 is a prime number > > 3 is a prime number > > 4 equals 2 * 2 > > 5 is a prime number > > 6 equals 2 * 3 > > 7 is a prime number > > 8 equals 2 * 4 > > 9 equals 3 * 3 > > > first time 2 mod 2, 2/2, no remainder == 0, what am I doing wrong? > > Why did it fall through? > > a) 2 is prime, so nothing is wrong. > > b) Range isn't doing what you think it's doing: > > >>> print range(2,2) > [] > >>> print range(2,3) > [2] > >>> print range(2,4) > [2, 3] > >>> print range(2,5) > > [2, 3, 4] > > > > >>> print range(1,1) > [] > >>> print range(1,2) > [1] > >>> print range(1,3) > [1, 2] > > ***** > > The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA622- Hide quoted text - > > - Show quoted text - So what is n and x in the first iteration? Sorry. I'm trying. From tjreedy at udel.edu Wed Apr 9 17:40:14 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 9 Apr 2008 17:40:14 -0400 Subject: basic python question about for loop References: Message-ID: |So what is n and x in the first iteration? Sorry. I'm trying. When n == 2, the inner loop executes 0 times (the length of range(2,n)) and then falls thru to the else clause, printing the correct answer. From mranjan at varshyl.com Tue Apr 22 22:50:25 2008 From: mranjan at varshyl.com (mranjan at varshyl.com) Date: Tue, 22 Apr 2008 22:50:25 -0400 Subject: about python Message-ID: <12826269.63521208919025392.JavaMail.servlet@perfora> How can python execute in browser? Mukul From sturlamolden at yahoo.no Thu Apr 24 23:50:52 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 20:50:52 -0700 (PDT) Subject: ctypes: return a pointer to a struct References: <846077c3-beaf-4ccd-83be-1e2168c4f7fe@c65g2000hsa.googlegroups.com> <4dda2bd7-3348-496e-a594-35da0a34d4de@x35g2000hsb.googlegroups.com> Message-ID: <0cfc062c-f83e-46ab-b215-3372258422ff@k37g2000hsf.googlegroups.com> On Apr 25, 5:39 am, "Jack" wrote: > IP2Location_get_all.restype = POINTER(IP2LocationRecord) > IP2LocationObj = IP2Location_open(thisdir + '/IP-COUNTRY-SAMPLE.BIN') > rec = IP2Location_get_all(IP2LocationObj, '64.233.167.99') > print rec.country_short print rec.contents.country_short From bwljgbwn at gmail.com Tue Apr 22 05:49:51 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:49:51 -0700 (PDT) Subject: evra patch Message-ID: evra patch http://cracks.12w.net F R E E C R A C K S From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 25 10:56:43 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 25 Apr 2008 16:56:43 +0200 Subject: Class Inheritance - What am I doing wrong? In-Reply-To: <613bc152-a6f4-4db4-8f90-593cb3f629c7@s33g2000pri.googlegroups.com> References: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> <613bc152-a6f4-4db4-8f90-593cb3f629c7@s33g2000pri.googlegroups.com> Message-ID: <4811f129$0$23023$426a34cc@news.free.fr> Brian Munroe a ?crit : > Ok, so thanks everyone for the helpful hints. That *was* a typo on my > part (should've been super(B...) not super(A..), but I digress) > > I'm building a public API. Along with the API I have a few custom > types that I'm expecting API users to extend, if they need too. If I > don't use name mangling, isn't that considered bad practice (read not > defensive programming) to not protect those 'private' fields? There would be a lot to say about whether defensive programming is a good practice or not. At least in the context of hi-level languages with exception handling and automatic memory management. Anyway: - there's just no way to make anything truly "private" in Python - the convention is that attributes (including methods - they are attributes too) whose name starts with a single leading underscore are implementation stuff and should not be messed with. IOW, the contract is "mess with them and you're on your own". - name mangling is only useful when you really need to make sure an implementation attribute won't be *accidentally* shadowed. These attributes should only be used by methods that are not themselves supposed to be overridden or extended by user code. FWIW, I must have used them less than half a dozen times in 7+ years (and I wrote more than a couple mini-frameworks, with lot of black-juju metaclasses and custom descriptors magic in them). So just use single-leading-underscore for implementation attributes, and document what the users are supposed to extend and what they're supposed to leave alone. My 2 cents. From hniksic at xemacs.org Tue Apr 29 10:41:35 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Tue, 29 Apr 2008 16:41:35 +0200 Subject: Issue with regular expressions References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Message-ID: <87prs83eqo.fsf@mulj.homelinux.net> Julien writes: > I'm fairly new in Python and I haven't used the regular expressions > enough to be able to achieve what I want. > I'd like to select terms in a string, so I can then do a search in my > database. > > query = ' " some words" with and "without quotes " ' > p = re.compile(magic_regular_expression) $ <--- the magic happens > m = p.match(query) I don't think you can achieve this with a single regular expression. Your best bet is to use p.findall() to find all plausible matches, and then rework them a bit. For example: p = re.compile(r'"[^"]*"|[\S]+') p.findall(query) ['" some words"', 'with', 'and', '"without quotes "'] At that point, you can easily iterate through the list and remove the quotes and excess whitespace. From python at bdurham.com Mon Apr 21 16:22:41 2008 From: python at bdurham.com (python at bdurham.com) Date: Mon, 21 Apr 2008 16:22:41 -0400 Subject: List of all Python's ____ ? Message-ID: <1208809361.28412.1249098609@webmail.messagingengine.com> Is there an official list of all Python's ____? I'm learning Python and trying to get an idea of what ____ are available and specifically, what ____ are used by each native Python data type? Thanks! Malcolm From hobgoodoreneyhb at gmail.com Tue Apr 22 11:42:54 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:42:54 -0700 (PDT) Subject: symptoms of crack addiction Message-ID: <2c18a1ab-8748-4363-8309-ca582030fa47@a23g2000hsc.googlegroups.com> symptoms of crack addiction http://cracks.12w.net F R E E C R A C K S From andrei.avk at gmail.com Thu Apr 3 14:33:03 2008 From: andrei.avk at gmail.com (AK) Date: Thu, 03 Apr 2008 13:33:03 -0500 Subject: Python-by-example - new online guide to Python Standard Library In-Reply-To: <47f2d018$0$6517$4c368faf@roadrunner.com> References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: <47f514c5$0$6520$4c368faf@roadrunner.com> AK wrote: > Hello, > > I find that I learn easier when I go from specific examples to a more > general explanation of function's utility and I made a reference guide > that will eventually document all functions, classes and methods in > Python's Standard Library. For now, I covered about 20 most important > modules. I will be adding more modules and eventually I'll cover > everything. Here's my progress so far, let me know if this is useful; > I'll be glad to hear comments/suggestions/etc: > > http://www.lightbird.net/py-by-example/ > I uploaded an updated site incorporating most of the suggestions I received and fixing some errors along the way. I will be adding more examples to modules that are already covered and will try to add more modules during the following week. Thanks again to all who posted advice and comments! -- -ak Tobu | http://www.lightbird.net/tobu/ | Freeform DB / Tagger / PIM Python-by-Example | http://www.lightbird.net/py-by-example/ | Guide to LibRef From theller at python.net Wed Apr 30 03:14:12 2008 From: theller at python.net (Thomas Heller) Date: Wed, 30 Apr 2008 09:14:12 +0200 Subject: py2exe Icon Resources In-Reply-To: <40c03afe-b2c5-4793-b7c3-f5a97360fe6c@a23g2000hsc.googlegroups.com> References: <40c03afe-b2c5-4793-b7c3-f5a97360fe6c@a23g2000hsc.googlegroups.com> Message-ID: <67qki0F2nqiddU1@mid.individual.net> flarefight at googlemail.com schrieb: > I have created an app using python and then converting it to an exe > using py2exe, and have the following code: > > "icon_resources": [(1, "appFavicon.ico"), (2, "dataFavicon.ico")] > > in my py2exe setup file, the appFavicon works fine and it sets that as > the app icon thats fine, but the program creates data files (like > documents) and i wanted them to have a different icon... > > I package my apps using Inno Setup 5, and it registers the file type > fine so that it loads on double click, what i cant do is set the icon > for the file. > > as you can see i have packaged two different icons with py2exe but > when i set DefaultIcon in the registry to "C:\pathtoapp\myapp.exe,2" > it doesnt work, nor does it work with a 1 or a %1 or indeed with > passing a path to the icon itself, nothing seems to work!! > > how do you access the other icons generated from py2exe, or how do you > set the registry up so that i looks for the icon correctly, > There was a problem in the icon resources code in py2exe which was recently fixed in CVS but there is not yet a binary release of this code. Maybe it solves your problem... Thomas From billingspanshism at gmail.com Sat Apr 19 17:18:23 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:18:23 -0700 (PDT) Subject: victoria beckham 2007 Message-ID: <48784072-cba2-4a4e-93ab-ee8d6bda64c3@f36g2000hsa.googlegroups.com> Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From bruno.desthuilliers at gmail.com Tue Apr 8 07:59:41 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Tue, 8 Apr 2008 04:59:41 -0700 (PDT) Subject: Is there an official way to add methods to an instance? References: <7xve2yas87.fsf@ruckus.brouhaha.com> <47f61041$0$27969$426a34cc@news.free.fr> <47f645e6$0$36354$742ec2ed@news.sonic.net> <9a4cde09-d1a0-4205-aea8-1ee32d4fb1b3@a70g2000hsh.googlegroups.com> Message-ID: <41a305bf-9667-46af-9c4f-2b8800c3d038@e67g2000hsa.googlegroups.com> On 8 avr, 11:39, m?choui wrote: > On Apr 4, 5:25 pm, John Nagle wrote: > > > > > Bruno Desthuilliers wrote: > > > Paul Rubin a ?crit : > > >> Brian Vanderburg II writes: > > >>> I've checked out some ways to get this to work. I want to be able to > > >>> add a new function to an instance of an object. > > > >> Ugh. Avoid that if you can. > > > > Why so ? OO is about objects, not classes, and adding methods on a > > > per-object basis is perfectly legitimate. > > > It's what professional programmers call a "l33t feature", > > one not suitable for production code. Typically such features > > are used by programmers with about two years experience, > > trying too hard to prove that they're cool. @john: I've ten years of experience, definitively don't care about looking "cool" or "l33t", and sorry, but I won't buy your purely ideological arguments. This reminds me of the lead engineer in one of my first job forbidding using OO because he didn't get it, or some Java guy trying to convince me that a language with dynamic typing and no access restriction could not be used for "production code". > > John Nagle > > Yes, and the reason is quite obvious: if you read the code of the > class, you can't see the function. That makes it much more difficult > to understand and to debug. Then we should forbid inheritence - you don't see the inherited functions when reading the code of the class. And we should forbid monkey-patching, metaclasses and quite a lot of other things as well. And also, we should go back to static typing - with dynamic typing, you don't know by reading the signature of a function what kind of arguments it expects. C'mon, be serious guys. As everything else, the problem is not with the feature, but with knowing how to properly use it and how to not abuse it. If you don't trust the programmer, then don't use a dynamic language. You know where to find Java and Ada... From elgrandchignon at gmail.com Tue Apr 8 23:33:23 2008 From: elgrandchignon at gmail.com (Jason) Date: Tue, 8 Apr 2008 20:33:23 -0700 (PDT) Subject: Sorting a List of Objects by an Attribute of the Objects Case-Insensitively References: <736fefbd-510f-40e9-8342-32b69a1a0c2a@t12g2000prg.googlegroups.com> Message-ID: <7688aa08-d533-4b25-9a21-335ffebe573d@a22g2000hsc.googlegroups.com> On Apr 8, 8:26 pm, "David Harrison" wrote: > On 09/04/2008, Jason wrote: > > > Hi folks-- > > > Basically, I have a pressing need for a combination of 5.2 "Sorting a > > List of Strings Case-Insensitively" & 5.3 "Sorting a List of Objects > > by an Attribute of the Objects" from the Python Cookbook. > > > My first guess isn't working: > > > import operator > > def sort_by_attr(seq, attr): > > key=operator.attrgetter(attr) > > key=str.lower > > return sorted(seq, key) > > > ...would much appreciate any guidance! > > You're probably looking for the built-in function sorted, > > e.g. > > class Foo: > def __init__(self, value): > self.value = value > > def __repr__(self): > return self.value > > a = [Foo('c'), Foo('B'), Foo('A')] > > print sorted( > a, > cmp=lambda x,y: cmp(x.lower(), y.lower()), > key=lambda x: x.value > ) Hey-- thanks! I actually figured out something that works quite nicely since I posted: def sort_by_attr_case_insensitive(seq, attr): return sorted(seq, cmp=lambda x,y: cmp(x.lower(), y.lower()), key=operator.attrgetter(attr)) From ajaksu at gmail.com Fri Apr 25 19:00:18 2008 From: ajaksu at gmail.com (ajaksu) Date: Fri, 25 Apr 2008 16:00:18 -0700 (PDT) Subject: MESSAGE RESPONSE References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> <678v5qF2me5rvU1@mid.uni-berlin.de> Message-ID: <4e89b45d-198c-48ca-a3a6-3ba42448cb2b@e53g2000hsa.googlegroups.com> On Apr 23, 1:27?pm, "Dan Upton" wrote: > On Wed, Apr 23, 2008 at 10:24 AM, Diez B. Roggisch wrote: > > > Blubaugh, David A. schrieb: > > > > Is there a way to block these messages. ? I do not want to be caught > > > with filth such as this material. ?I could lose my job with Belcan with > > > evil messages such as these messages. > > > ?If I (or *anybody*) knew how to block these messages, he or she would sell > > the resulting spam-filter for a fortunen that roughly amasses the one of > > scrooge mc duck ?- and go live on the bahamas or even buy them. > > > ?Put up with it. It's (unfortunately) part of ze internet tubes. > > And as such, I find it hard to believe you could lose your job over it. Me too. That is, until I tried to Google Belcan and Blubaugh together. May I suggest a new thread to clear that ugly results? :D From gagsl-py2 at yahoo.com.ar Thu Apr 10 23:01:42 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 11 Apr 2008 00:01:42 -0300 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: En Thu, 10 Apr 2008 20:01:43 -0300, Steve Holden escribi?: > Michel Bouwmans wrote: >> >> Mike Driscoll wrote: >>> I see a lot of people recommend using pyQt, but they never mention the >>> controversy that surrounds its licensing. There have been many posts >>> on the subject already, but if the OP ever decides to sell anything >>> they create, I've heard that QT's licensing is kind of squirrelly. >>> Maybe this has been straightened out? >>> >>> I looked at the website and found it fairly confusing. And don't you >>> need to download QT itself? >>> >>> Mike >> >> Yeah, the licensing of Qt is either be open-source (under one of the >> Qt-exception licenses licenses so no exclusivity for the GPL anymore) or >> pay for the commercial version. So yes, if you would like to sell it as >> closed-source software you will need to buy the commercial version of Qt >> and PyQt. In other words: you will have to pay twice. Don't forget that >> you >> can also sell open-source software, so you don't have to pay. ;) >> > I don't think PyQt has any licensing restrictions to speak of, only the > underlying Qt platform (though it's a while since I looked). Yes, you have to buy separate licenses for both PyQt and Qt. From the PyQt home page: """PyQt v4 is licensed under the GNU GPL and under a commercial license on all platforms. [...] You can purchase the commercial version of PyQt here. PyQt does not include a copy of Qt. You must obtain a correctly licensed copy of Qt yourself.""" Another annoying thing with the Qt license is that you have to choose it at the very start of the project. You cannot develop something using the open source license and later decide to switch to the commercial licence and buy it. -- Gabriel Genellina From gherron at islandtraining.com Thu Apr 24 12:11:50 2008 From: gherron at islandtraining.com (Gary Herron) Date: Thu, 24 Apr 2008 09:11:50 -0700 Subject: convert xhtml back to html In-Reply-To: References: Message-ID: <4810B146.4080707@islandtraining.com> Tim Arnold wrote: > hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop to > create CHM files. That application really hates xhtml, so I need to convert > self-ending tags (e.g.
) to plain html (e.g.
). > > Seems simple enough, but I'm having some trouble with it. regexps trip up > because I also have to take into account 'img', 'meta', 'link' tags, not > just the simple 'br' and 'hr' tags. Well, maybe there's a simple way to do > that with regexps, but my simpleminded )]+/> doesn't work. I'm not > enough of a regexp pro to figure out that lookahead stuff. > > I'm not sure where to start now; I looked at BeautifulSoup and > BeautifulStoneSoup, but I can't see how to modify the actual tag. > > thanks, > --Tim Arnold > > > -- > http://mail.python.org/mailman/listinfo/python-list > Whether or not you can find an application that does what you want, I don't know, but at the very least I can say this much. You should not be reading and parsing the text yourself! XHTML is valid XML, and there a lots of ways to read and parse XML with Python. (ElementTree is what I use, but other choices exist.) Once you use an existing package to read your files into an internal tree structure representation, it should be a relatively easy job to traverse the tree to emit the tags and text you want. Gary Herron From aaron.watters at gmail.com Wed Apr 16 13:29:36 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 16 Apr 2008 10:29:36 -0700 (PDT) Subject: Profiling very small/quick functions, help!? References: <1ed0cde8-d04c-444b-9b47-9bea16ae409d@f63g2000hsf.googlegroups.com> Message-ID: <6025f1e4-b5d7-4cee-a255-236db4191b92@2g2000hsn.googlegroups.com> On Apr 16, 12:35 pm, skanem... at yahoo.se wrote: > if __name__=="__main__": > try: > from cProfile import run > except: > from profile import run > for x in range(1, 10000): > run("power(10,10)") def test1(): for x in xrange(1,10000): test = power(10,10) if __name__=="__main__": try: from cProfile import run except: from profile import run for x in range(1, 10000): run("test1()") all the best! -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=jar From deets at nospam.web.de Mon Apr 21 10:19:24 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Mon, 21 Apr 2008 16:19:24 +0200 Subject: how to pass C++ object to another C++ function via Python function References: <1810b155-5598-4f17-a8e9-e4aa848db5de@i36g2000prf.googlegroups.com> Message-ID: <673m48F2lucb5U1@mid.uni-berlin.de> Gabriel Genellina wrote: > En Mon, 21 Apr 2008 10:24:15 -0300, grbgooglefan > escribi?: > >> I am trying to pass a C++ object to Python function. This Python >> function then calls another C++ function which then uses this C++ >> object to call methods of that object's class. >> >> I tried something like this, but it did not work, gave core dump. > > You can't pass any arbitrary C object to a Python function. > In this case you can use a PyCObject, a Python box around a void* pointer. > See http://docs.python.org/api/cObjects.html > Neat! Didn't know about that one. Diez From frikker at gmail.com Wed Apr 30 14:09:52 2008 From: frikker at gmail.com (blaine) Date: Wed, 30 Apr 2008 11:09:52 -0700 (PDT) Subject: I messed up my wxPython install (Eclipse Configuration Issue) References: <18eb0a7c-96f4-41de-b44f-95fd8ba0223f@f63g2000hsf.googlegroups.com> <436f8226-64a5-440a-92f4-afd7dd348e1c@m73g2000hsh.googlegroups.com> Message-ID: <20525ad9-2679-4bc8-a117-66eca4a8dc13@r66g2000hsg.googlegroups.com> On Apr 30, 1:14 pm, Mike Driscoll wrote: > blaine wrote: > > The wxPython group is a bit stale compared to this group, so I'll give > > it a shot :) > > What does that mean? The wxPython group is almost always very quick to > respond with relevant answers. > > As to your question, I think Peter is correct. Your wx.py and wx.pyc > files are masking the wx package. > > Mike I didn't mean anything by it, I promise. This group is just amazing - there are always very active topics and I get responses in no time. The wxPython group I noticed only has had recent discussions a few times in the past month, and their subscribers aren't as high as the Python group. That worked. You guys are awesome, thank you! I can't believe I named that test script wx.py - duh. Thank you for your help! Blaine From sable at users.sourceforge.net Mon Apr 14 06:09:10 2008 From: sable at users.sourceforge.net (=?ISO-8859-1?Q?S=E9bastien_Sabl=E9?=) Date: Mon, 14 Apr 2008 12:09:10 +0200 Subject: Sybase module 0.39 released Message-ID: <48032D46.4050203@users.sourceforge.net> WHAT IS IT: The Sybase module provides a Python interface to the Sybase relational database system. It supports all of the Python Database API, version 2.0 with extensions. The module is available here: http://downloads.sourceforge.net/python-sybase/python-sybase-0.39.tar.gz The module home page is here: http://python-sybase.sourceforge.net/ MAJOR CHANGES SINCE 0.38: * Added type mapping as proposed in http://www.uniqsys.com/~carsten/typemap.html by Carsten Haese * Handle engineer notation of numbers in numeric * Added support for CS_DATE_TYPE * Added support for python Decimal objects in databuf * Possibility to use ct_cursor for some requests * Refactoring - merged Fetchers, CTCursor and CmdCursor in Cursor * Refactored _cancel_cmd * Added a prepare method to Cursor * Additional 'locale' argument to connect and Connection to set the locale of the connection thanks to patch by Harri Pasanen * Better compliance with DBAPI: returns None in nextset when no more set * Added conversion from string to int when assigning to a CS_INT_TYPE DataBuf BUGS CORRECTED SINCE 0.39pre1: * Corrected "undefined symbol" date_datafmt for Sybase versions where CS_DATE_TYPE is not defined (as reported by Alexey Morsov) BUGS CORRECTED SINCE 0.38: * Corrected documentation about CS_CONTEXT Objects thanks to bug report by Derek Harland (close tracker 1748109) * Corrected bug in close() if connection killed from outside thanks to patch by Derek Harland (close tracker 1746220) * Corrected bug if inherit from Sybase.Connection thanks to patch by Derek Harland (close tracker 1719789) * Optimization in fetchall - using fetchmany instead of fetchone to avoid locking time penalty, thanks to patch by Derek Harland (close tracker 1746908) * Corrections to compile with bcp-support against freetds thanks to patch by Klaus-Martin Hansche (close tracker 1724088) * Corrected documentation to compile with FreeTDS and Threads thanks to Derek Harland (close tracker 1709043) * Corrected bug in databuf_alloc: Sybase reports the wrong maxlength for numeric type - verified with Sybase 12.5 - thanks to patch provided by Phil Porter * Better detection of Sybase libraries * the C API to datetime only exists since python 2.4 - disable datetime with previous versions * Corrected python long handling (using CS_NUMERIC instead of CS_LONG which is unspecified) * Corrected various compilation warnings (some linked to python 2.5) The full ChangeLog is here: https://python-sybase.svn.sourceforge.net/svnroot/python-sybase/tags/r0_39/ChangeLog From http Thu Apr 3 03:03:09 2008 From: http (Paul Rubin) Date: 03 Apr 2008 00:03:09 -0700 Subject: Manipulate Large Binary Files References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> <9999810b0804021109n77f2c990p7b10d92e9344ad00@mail.gmail.com> Message-ID: <7xlk3vctea.fsf@ruckus.brouhaha.com> Derek Martin writes: > > Both are clocking in at the same time (1m 5sec for 2.6Gb), are there > > any ways I can optimize either solution? Getting 40+ MB/sec through a file system is pretty impressive. Sounds like a RAID? > That said, due to normal I/O generally involving double-buffering, you > might be able to speed things up noticably by using Memory-Mapped I/O > (MMIO). It depends on whether or not the implementation of the Python > things you're using already use MMIO under the hood, and whether or > not MMIO happens to be broken in your OS. :) Python has the mmap module and I use it sometimes, but it's not necessarily the right thing for something like this. Each page you try to read from results in own delay while the resulting page fault is serviced, so any overlapped i/o you get comes from the OS being nice enough to do some predictive readahead for you on sequential access if it does that. By coincidence there are a couple other threads mentioning AIO which is a somewhat more powerful mechanism. From sevenjp at gmail.com Thu Apr 3 06:10:48 2008 From: sevenjp at gmail.com (=?ISO-8859-1?Q?Jo=E3o_Neves?=) Date: Thu, 3 Apr 2008 03:10:48 -0700 (PDT) Subject: Rationale for read-only property of co_code References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> <10ee2a69-f4e2-4887-8083-6b02b60dd0cd@i7g2000prf.googlegroups.com> Message-ID: <130ad0b4-504c-4b19-85fc-1bd700590ccf@u10g2000prn.googlegroups.com> On Apr 3, 4:43 am, Scott David Daniels wrote: > Nope: If you change the code in-place, the whole stack's references > to where they were running would need to get updated to corresponding > locations in the new code. _That_ is a lot of work. Ah, there it is. Now I get it, it makes perfect sense. Looks like I'll have to stick to the usual mechanisms! Thanks everyone! --- Jo?o Neves From dickinsm at gmail.com Mon Apr 7 09:55:23 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Mon, 7 Apr 2008 06:55:23 -0700 (PDT) Subject: A funnily inconsistent behavior of int and float References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com> Message-ID: <1d11875a-470a-489f-910a-b420a145eb61@a1g2000hsb.googlegroups.com> On Apr 7, 6:43 am, "Colin J. Williams" wrote: > This is good but the documentation for > 3.0 is missing the syntax documentation > from 2.5 Is http://docs.python.org/dev/3.0/reference/lexical_analysis.html#integer-literals the documentation that you're looking for? But it seems to me that Lie's original point isn't really about integer *literals* anyway---it's about the behaviour of the built-in int() function when applied to a string. So http://docs.python.org/dev/3.0/library/functions.html#int is probably the appropriate place in the documentation. And I agree that it could be made clearer exactly what strings are acceptable here. Mark From lscbtfws at gmail.com Sat Apr 26 12:11:24 2008 From: lscbtfws at gmail.com (lscbtfws at gmail.com) Date: Sat, 26 Apr 2008 09:11:24 -0700 (PDT) Subject: age of empires III crack Message-ID: <5666d9a5-bcd8-42ed-a01e-27354a1efd8f@n1g2000prb.googlegroups.com> age of empires III crack http://cracks.00bp.com F R E E C R A C K S From cokofreedom at gmail.com Tue Apr 8 06:16:23 2008 From: cokofreedom at gmail.com (cokofreedom at gmail.com) Date: Tue, 8 Apr 2008 03:16:23 -0700 (PDT) Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> Message-ID: <31ef4e30-59bd-4d50-a4e1-5e8b9d73ba88@a23g2000hsc.googlegroups.com> 'I have designed a program with more than 500 if elif else' This was your first mistake... (ii) x3=x1.find(x2) returns an integer corresponding to the start position in x1 where it found x2, otherwise it will return -1. (i) ... what kind of vague numbers? It should just give you an integer response... From cstewart913 at gmail.com Wed Apr 9 21:54:33 2008 From: cstewart913 at gmail.com (Chris Stewart) Date: Wed, 9 Apr 2008 21:54:33 -0400 Subject: How is GUI programming in Python? Message-ID: I've always had an interest in Python and would like to dabble in it further. I've worked on a few very small command line programs but nothing of any complexity. I'd like to build a really simple GUI app that will work across Mac, Windows, and Linux. How painful is that going to be? I used to be really familiar with Java Swing a few years ago. I imagine it will be similar. Next, what would you say is the best framework I should look into? I'm curious to hear opinions on that. Chris Stewart cstewart913 at gmail.com From gherron at islandtraining.com Thu Apr 3 18:12:46 2008 From: gherron at islandtraining.com (Gary Herron) Date: Thu, 03 Apr 2008 15:12:46 -0700 Subject: expanding a variable to a dict In-Reply-To: References: Message-ID: <47F5565E.8040109@islandtraining.com> idle wrote: > I've got a variable in a loop that I'm trying to expand/translate/ > readdress as an existing dict so as to add some keys into it.. > > eg; I have a set of existing dicts: dictFoo, dictBar, dictFrotz (names > changed to protect the innocent) > > now I'd like to check them all for the existence of certain default > keys; ie, if the dicts don't contain the keys, add them in with > default values. > > so, I've got: > > for a in ['dictFoo','dictBar','dictFrotz']: > if hasattr(a,'srcdir') == False: > a['srcdir']='/usr/src' > > the error I get (which I expect) is 'str' object doesn't support item > assignment. > > what incantation do I cast on 'a' to make the interpreter parse it as > 'dictFoo' on the first iteration, 'dictBar' on the second, and so > forth? > > and/or less importantly, what is such a transformation called, to help > me target my searching? > > thanks > Try this: for a in [dictFoo, dictBar, dictFrotz]: if 'srcdir' in a: a['srcdir']='/usr/src' Gary Herron From deets at nospam.web.de Tue Apr 15 10:33:05 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 15 Apr 2008 16:33:05 +0200 Subject: webcam (usb) access under Ubuntu References: <66jlk1F2ju6c8U1@mid.uni-berlin.de> Message-ID: <66jsltF2k8dp9U1@mid.uni-berlin.de> Berco Beute wrote: > Thanks, that would be great. > > While I'm at it I wondering how to display a video preview. Here's > someone using VideoCapture (the win32 lib) and PyGame, but I'd rather > use a GUI framework and preview/capture videos directly. gstreamer has a preview window. Diez From breily at gmail.com Tue Apr 8 01:03:20 2008 From: breily at gmail.com (Brian) Date: Tue, 8 Apr 2008 01:03:20 -0400 Subject: Newbie: How to pass a dictionary to a function? In-Reply-To: <0178aef6-46ce-47a4-a2a4-882514e2aacd@k1g2000prb.googlegroups.com> References: <516e07d1-91f9-462b-9fc0-ac6d1e474f9d@n14g2000pri.googlegroups.com> <0178aef6-46ce-47a4-a2a4-882514e2aacd@k1g2000prb.googlegroups.com> Message-ID: Plus you probably don't want to set [] as default argument and then try to access it like a dictionary; you'll get an exception if you ever call just foo(), with no argument. On Tue, Apr 8, 2008 at 12:57 AM, Jason Scheirer wrote: > On Apr 7, 8:54 pm, BonusOnus wrote: > > How do I pass a dictionary to a function as an argument? > > > > # Say I have a function foo... > > def foo (arg=[]): > > x = arg['name'] > > y = arg['len'] > > > > s = len (x) > > > > t = s + y > > > > return (s, t) > > > > # The dictionary: > > > > dict = {} > > dict['name'] = 'Joe Shmoe' > > dict['len'] = 44 > > > > # I try to pass the dictionary as an argument to a > > # function > > > > len, string = foo (dict) > > > > # This bombs with 'TypeError: unpack non-sequence' > > > > What am I doing wrong with the dictionary? > > You want to > return s, t > NOT return (s, t) -- this implicitly only returns ONE item > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jcd at unc.edu Wed Apr 16 14:18:00 2008 From: jcd at unc.edu (J. Cliff Dyer) Date: Wed, 16 Apr 2008 14:18:00 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <1208369880.5771.1.camel@aalcdl07.lib.unc.edu> On Wed, 2008-04-16 at 12:06 -0400, Steve Holden wrote: > Mike Driscoll wrote: > > On Apr 16, 10:09 am, Steve Holden wrote: > >> Mike Driscoll wrote: > >>> On Apr 16, 9:19 am, Grant Edwards wrote: > >>>> This morning almost half of c.l.p was spam. In order to try to > >>>> not tar both the benign google group users and the malignant > >>>> ones with the same brush, I've been trying to kill usenet spam > >>>> with subject patterns. But that's not a battle you can win, so > >>>> I broke down and joined all the other people that just killfile > >>>> everything posted via google.groups. > >>>> AFAICT, if you're a google groups user your posts are not being > >>>> seen by many/most experienced (read "non-google-group") users. > >>>> This is mainly the fault of google who has refused to do > >>>> anything to stem the flood of span that's being sent via Google > >>>> Groups. > >>>> -- > >>>> Grant Edwards grante Yow! I would like to > >>>> at urinate in an OVULAR, > >>>> visi.com porcelain pool -- > >>> Yeah, I noticed that Google Groups has really sucked this week. I'm > >>> using the Google Groups Killfile for Greasemonkey now and it helps a > >>> lot. I like Google, but my loyalty only goes to far. This is a > >>> complete lack of customer service. > >> Unfortunately this means Google groups users are getting exactly the > >> service they are paying for. > >> > >> regards > >> Steve > >> -- > >> Steve Holden +1 571 484 6266 +1 800 494 3119 > >> Holden Web LLC http://www.holdenweb.com/ > > > > Steve, > > > > My workplace doesn't offer NNTP, so there is no good way to browse > > c.l.py here. And I haven't been able to get NNTP to work from my home > > either. > > > > By applying this logic to Python and Linux (or any Open Source > > product), they shouldn't be used either (since I'm not paying for > > them). > > > I'm not saying people shouldn't use Google Groups. I'm saying that > Google can "justify" providing customer "support" that lives somewhere > between zero and extremely crappy by not charging for the service. > > Without tunneling out to an NNTP proxy I don't see what other choice you > have. > > regards > Steve You could subscribe via email, and keep your own archive. If you use an email client with decent adaptive spam filter (i.e. not outlook), you won't even notice the spam floating by. It worked like a charm for me until I switched to digest view :) -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill From skanemupp at yahoo.se Fri Apr 18 19:29:28 2008 From: skanemupp at yahoo.se (globalrev) Date: Fri, 18 Apr 2008 16:29:28 -0700 (PDT) Subject: python setup.py install on Vista? Message-ID: type "python setup.py install" that is used in most "addons" for python. well using windows vista, where the h*** am i supposed to type this? if it is not doable in windows, what do i have to do instead? just clicking the setup.py-file never works. From cwitts at gmail.com Wed Apr 2 08:37:27 2008 From: cwitts at gmail.com (Chris) Date: Wed, 2 Apr 2008 05:37:27 -0700 (PDT) Subject: splitting an XML file on the basis on basis of XML tags References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> Message-ID: bije... at gmail.com wrote: > Hi all, > > i have an XML file with the following structure:: > > > -----| > | > | > . | > . | --------------------> constitutes one record. > . | > . | > . | > | > | > ----| > > . > . > . -----------------------| > . | > . | > . |----------------------> there are n > records in between.... > . | > . | > . | > . ------------------------| > . > . > > -----| > | > | > . | > . | --------------------> constitutes one record. > . | > . | > . | > | > | > ----| > > > > Here is the main root tag of the XML, and ... > constitutes one record. What I would like to do is > to extract everything (xml tags and data) between nth tag and (n > +k)th tag. The extracted data is to be > written down to a separate file. > > Thanks... You could create a generator expression out of it: txt = """ 1 2 3 4 5 """ l = len(txt.split('r2>'))-1 a = ('%sr2>'%i for j,i in enumerate(txt.split('r2>')) if 0 < j < l and i.replace('>','').replace('<','').strip()) Now you have a generator you can iterate through with a.next() or alternatively you could just create a list out of it by replacing the outer parens with square brackets. From kveretennicov at gmail.com Sun Apr 6 07:14:14 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Sun, 6 Apr 2008 14:14:14 +0300 Subject: Python Data Utils In-Reply-To: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> References: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> Message-ID: <4660fe300804060414v70a53166j5e14333d39b50243@mail.gmail.com> On Sun, Apr 6, 2008 at 7:43 AM, Jesse Aldridge wrote: > In an effort to experiment with open source, I put a couple of my > utility files up here. What do you think? Would you search for, install, learn and use these modules if *someone else* created them? -- kv From collardfelszkw at gmail.com Sun Apr 20 16:32:45 2008 From: collardfelszkw at gmail.com (collardfelszkw at gmail.com) Date: Sun, 20 Apr 2008 13:32:45 -0700 (PDT) Subject: jennifer aniston paul Message-ID: Just few link on some Movies Movies: http://Jennifer-Aniston.12w.net F R E E C E L E B R I T Y M O V I E S From donn at u.washington.edu Fri Apr 11 16:02:39 2008 From: donn at u.washington.edu (Donn Cave) Date: Fri, 11 Apr 2008 13:02:39 -0700 Subject: pty.spawn directs stderr to stdout References: Message-ID: In article , Wilbert Berendsen wrote: > Hi, > > using pty.spawn() it seems that stderr output of the spawned process is > directed to stdout. Is there a way to keep stderr separate and only direct > stdin and stdout to the pty? There is, of course. First, you have to decide where you want unit 2 ("stderr") to go, and then get the spawned process to redirect it there. If a disk file will do, then your question is just "how do I redirect error output to a disk file, in ___" (fill in the blank with language used to implement the spawned process - UNIX shell? Python? C?) More likely, you want the spawned process' error output to go wherever the parent's error output was going. This is a little trickier. Ideally, your spawned shell script can conveniently take a new parameter that identifies the new file descriptor unit number for error output. In this case, use fd2 = os.dup(2) to get a new duplicate, add a parameter like -e str(fd2), and in the spawned process, redirect from that unit - in UNIX shell, exec 2>&$fd2 Or you could use an environment variable to identify the backup error unit, if the command line parameter option isn't available for some reason. Donn Cave, donn at u.washington.edu From john00587 at gmail.com Mon Apr 21 01:40:48 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:40:48 -0700 (PDT) Subject: crack and digichat 5 Message-ID: <98a4c42d-e686-4191-9967-c065a303798d@r9g2000prd.googlegroups.com> crack and digichat 5 http://cracks.00bp.com F R E E C R A C K S From vijayakumar.subburaj at gmail.com Mon Apr 14 03:13:56 2008 From: vijayakumar.subburaj at gmail.com (v4vijayakumar) Date: Mon, 14 Apr 2008 00:13:56 -0700 (PDT) Subject: Game design : Making computer play Message-ID: In computer based, two player, board games, how to make computer play? Are there any formal ways to _teach_ computer, to choose best possible move? I know this is kind of off-topic here. Please redirect me, if there are more appropriate newsgroup. Many thanks. From mrmakent at cox.net Wed Apr 23 16:51:09 2008 From: mrmakent at cox.net (Mike Kent) Date: Wed, 23 Apr 2008 13:51:09 -0700 (PDT) Subject: Pythonically extract data from a list of tuples (getopt) References: Message-ID: <8a3f5274-6fb7-4319-ab86-d18c9bbbf9fe@59g2000hsb.googlegroups.com> You could use http://docs.python.org/lib/module-optparse.html From deets at nospam.web.de Wed Apr 23 10:24:37 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 23 Apr 2008 16:24:37 +0200 Subject: MESSAGE RESPONSE In-Reply-To: References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> Message-ID: <678v5qF2me5rvU1@mid.uni-berlin.de> Blubaugh, David A. schrieb: > Is there a way to block these messages. I do not want to be caught > with filth such as this material. I could lose my job with Belcan with > evil messages such as these messages. If I (or *anybody*) knew how to block these messages, he or she would sell the resulting spam-filter for a fortunen that roughly amasses the one of scrooge mc duck - and go live on the bahamas or even buy them. Put up with it. It's (unfortunately) part of ze internet tubes. Diez From exarkun at divmod.com Fri Apr 11 13:23:13 2008 From: exarkun at divmod.com (Jean-Paul Calderone) Date: Fri, 11 Apr 2008 13:23:13 -0400 Subject: pyOpenSSL 0.7 In-Reply-To: 0 Message-ID: <20080411172313.6859.586410116.divmod.quotient.28168@ohm> pyOpenSSL is a wrapper around a subset of the OpenSSL API, including support for X509 certificates, public and private keys, and and SSL connections. pyOpenSSL 0.7 fixes a number of memory leaks and memory corruption issues. It also exposes several new OpenSSL APIs to Python: * SSL_get_shutdown and SSL_set_shutdown exposed as OpenSSL.SSL.Connection.get_shutdown and OpenSSL.SSL.Connection.set_shutdown * SSL_SENT_SHUTDOWN and SSL_RECEIVED_SHUTDOWN exposed as OpenSSL.SSL.SENT_SHUTDOWN and OpenSSL.SSL.RECEIVED_SHUTDOWN * X509_verify_cert_error_string exposed as OpenSSL.crypto.X509_verify_cert_error_string * X509.get_serial_number and X509.set_serial_number now accept long integers * Expose notBefore and notAfter on X509 certificates for inspection and mutation * Expose low-level X509Name state with X509Name.get_components * Expose hashing and DER access on X509Names pyOpenSSL home page: http://pyopenssl.sourceforge.net/ pyOpenSSL downloads: http://sourceforge.net/project/showfiles.php?group_id=31249 Jean-Paul Calderone From watches0560 at global-replica-watch.com Fri Apr 25 12:04:31 2008 From: watches0560 at global-replica-watch.com (watches0560 at global-replica-watch.com) Date: Fri, 25 Apr 2008 09:04:31 -0700 (PDT) Subject: Brand Watches Ebel Classic Brown Leather Strap Date Mens Watch 9120F51.6235134 Discount, Swiss, Fake Message-ID: <18cf6db3-7812-4da1-a745-2df4c5545060@b9g2000prh.googlegroups.com> Brand Watches Ebel Classic Brown Leather Strap Date Mens Watch 9120F51.6235134 Discount, Swiss, Fake Browse our Ebel Classic Brown Leather Strap Date Mens Watch 9120F51.6235134 Swiss watches, which is sure the watch you are looking for at low price. There are more high quality designer watch Swiss for selection Ebel Classic Brown Leather Strap Date Mens Watch 9120F51.6235134 Link : http://www.watches-brand.com/Ebel-wristwatch-3195.html Brand : Ebel ( http://www.watches-brand.com/Ebel-Watches.html ) Model : Ebel Classic Brown Leather Strap Date Mens Watch 9120F51.6235134 Description :

Stainless Steel Case & Bezel, Silver Dial, Brown Crocodile Leather Strap, Date Display, Roman Numeral Hour Markers, Self Winding Automatic Movement, Scratch Resistant Sapphire Crystal, Deployment Buckle, Water Resistant up to 165FT

Sale Price : $ 245.00 Ebel Classic Brown Leather Strap Date Mens Watch 9120F51.6235134 Details :
  • Brand: Ebel
  • Model: 9120F51.6235134
  • Band material: Leather
  • Bezel material: stainless-steel
  • Case material: stainless-steel
  • Clasp type: deployment-buckle
  • Dial color: silver
  • Dial window material: scratch-resistant-sapphire
  • Movement type: Swiss Automatic Movement
  • Water-resistant to 165 feet
Ebel Classic Brown Leather Strap Date Mens Watch 9120F51.6235134 is new brand Swiss, join thousands of satisfied customers and buy your Ebel with total satisfaction. A watches-brand.COM 30 Day Money Back Guarantee is included with every Ebel Fake Series for secure, risk- free online shopping. watches-brand.COM does not charge sales tax for the Fake Ebel Classic Brown Leather Strap Date Mens Watch 9120F51.6235134. All of our Fake watches are shipped via EMS to worldwide. Normally it takes 3days to prepare the fake watch you ordered and 5-10days to transmit depending on the different destination.We pay for the free shipping cost for total quantity over 20 pcs. The EMS tracking NO. will be sent by email when an order is shipped from our warehouse. No more other charges from watches-brand.com such as the tax. If you have any other questions please check our other pages or feel free to email us by sales at watches-brand.com. The Same Fake Ebel Watches Series : Ebel Classic Two-Tone Black Leather Strap Mens Watch 1255F41.0235136 : http://www.watches-brand.com/Ebel-wristwatch-3196.html Ebel Classic Wave Mens Watch 9187151/20125 : http://www.watches-brand.com/Ebel-wristwatch-3197.html Ebel Men's Type E Stainless Steel Black Dial Watch, Model - 9187C41/5716 : http://www.watches-brand.com/Ebel-wristwatch-3198.html Ebel Men's Type E Stainless Steel Rubber Band Watch, Model - 9187C41/06C35606 : http://www.watches-brand.com/Ebel-wristwatch-3199.html Ebel Men's E Type Watch #9187C41-3716 : http://www.watches-brand.com/Ebel-wristwatch-3200.html Ebel Men's E Type Watch #9187C51-5716 : http://www.watches-brand.com/Ebel-wristwatch-3201.html Ebel Men's E Type Automatic Watch #9330C41-0716 : http://www.watches-brand.com/Ebel-wristwatch-3202.html Ebel Men's E Type Watch #9187C41-0716 : http://www.watches-brand.com/Ebel-wristwatch-3203.html Ebel Men's E Type Watch #9187C41-56C35606 : http://www.watches-brand.com/Ebel-wristwatch-3204.html Ebel Men's E Type Watch #9187C51-06C35606 : http://www.watches-brand.com/Ebel-wristwatch-3205.html Brand Watches Ebel Classic Brown Leather Strap Date Mens Watch 9120F51.6235134 Discount, Swiss, Fake From skanemupp at yahoo.se Tue Apr 15 15:46:53 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Tue, 15 Apr 2008 12:46:53 -0700 (PDT) Subject: tkinter, canvas, get color of image? References: <0e4c9708-dbe9-4f29-ac31-34f7298f2624@m1g2000pre.googlegroups.com> Message-ID: On 13 Apr, 19:19, Bryan Oakley wrote: > skanem... at yahoo.se wrote: > > mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\elmapovic.gif') > > w.create_image(10, 10, image = mapq, anchor = NW) > > > after doing this is there any possibility of getting the > > characteristics of the GIF-picture(or bitmap if i use that)? > > > it would be very helpfull if i for example could do something like > > canvas.getcolor(image, mouseclick.x,mouseclick.y) if u get the point. > > get the color of the image where i clicked. > > The image isn't "painted" on the canvas, so to answer your specific > question, no, you can't get the color of a pixel on the canvas in the > way that you ask. > > However, when you click on the canvas you can get the item that was > clicked on and the x/y of the click. From that you can figure out which > pixel of the image is under the cursor. And from that you can query the > image for the color of a specific pixel. how do i get the item? http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_image-method with any of those methods? when i click the mouse i can get event.object u mean? From steve at holdenweb.com Sun Apr 6 22:54:22 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 06 Apr 2008 22:54:22 -0400 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> <47F831F7.4000709@holdenweb.com> Message-ID: Fredrik Lundh wrote: > Steve Holden wrote: > >>> for reference, here's what I get on Ubuntu 7.10, with the standard >>> Python interpreter (2.5.1): >>> >>> $ python -c "import imp; print imp.get_suffixes()" >>> [('.so', 'rb', 3), ('module.so', 'rb', 3), ('.py', 'U', 1), >>> ('.pyc', 'rb', 2)] >>> >>> any Ubuntu gurus here that can sort this one out? >>> >> I wouldn't claim to be an Ubuntu guru but it seems as though the Ubuntu >> team decide that you would be able to import extension module YYY either >> from YYY.so or from YYYmodule.so. IF you are asking *why* then I'd have >> to answer that I have no idea at all. > > oh, the ".so" and "module.so" is standard Python behaviour (see my first > post in this thread). what I cannot figure out is how "llothar" has > managed to get setup.py to build extensions that an Ubuntu Python cannot > load, without noticing. > Well, at least *I* learned something in this thread. I had missed that second paragraph in your first post, and hadn't realised it from other sources. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From martin at v.loewis.de Sat Apr 19 03:59:49 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sat, 19 Apr 2008 09:59:49 +0200 Subject: How to print a unicode string? In-Reply-To: References: <4809394A.1030906@v.loewis.de> Message-ID: <4809A675.70300@v.loewis.de> > Is it possible to change an > environment variable, so that Python uses this coding automatically? No. > Or pass a command-line argument when Emacs python-mode invokes the > Python interpreter? No. > Or execute this line of Python in a startup script > which is invoked whenever a new Python session is started? Yes, you can add the code I suggested to sitecustomize.py. Regards, Martin From cwitts at gmail.com Thu Apr 3 06:27:56 2008 From: cwitts at gmail.com (Chris) Date: Thu, 3 Apr 2008 03:27:56 -0700 (PDT) Subject: splitting an XML file on the basis on basis of XML tags References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> Message-ID: On Apr 3, 8:51?am, Steve Holden wrote: > bijeshn wrote: > > On Apr 2, 5:37 pm, Chris wrote: > >> bije... at gmail.com wrote: > >>> Hi all, > >>> ? ? ? ? ?i have an XML file with the following structure:: > >>> > >>> -----| > >>> ? ? | > >>> ? ? | > >>> . ? ? ? ? ? | > >>> . ? ? ? ? ? | ? ? ? ? --------------------> constitutes one record. > >>> . ? ? ? ? ? | > >>> . ? ? ? ? ? | > >>> . ? ? ? ? ? | > >>> ? ?| > >>> ? ?| > >>> ----| > >>> > >>> . > >>> . > >>> . ? ?-----------------------| > >>> . ? ? ? ? ? ? ? ? ? ? ? ? ? | > >>> . ? ? ? ? ? ? ? ? ? ? ? ? ? | > >>> . ? ? ? ? ? ? ? ? ? ? ? ? ? |----------------------> there are n > >>> records in between.... > >>> . ? ? ? ? ? ? ? ? ? ? ? ? ? | > >>> . ? ? ? ? ? ? ? ? ? ? ? ? ? | > >>> . ? ? ? ? ? ? ? ? ? ? ? ? ? | > >>> . ? ------------------------| > >>> . > >>> . > >>> > >>> -----| > >>> ? ? | > >>> ? ? | > >>> . ? ? ? ? ? | > >>> . ? ? ? ? ? | ? ? ? ? --------------------> constitutes one record. > >>> . ? ? ? ? ? | > >>> . ? ? ? ? ? | > >>> . ? ? ? ? ? | > >>> ? ?| > >>> ? ?| > >>> ----| > >>> > >>> ? ? ? ?Here is the main root tag of the XML, and ... > >>> constitutes one record. What I would like to do is > >>> to extract everything (xml tags and data) between nth tag and (n > >>> +k)th tag. The extracted data is to be > >>> written down to a separate file. > >>> Thanks... > >> You could create a generator expression out of it: > > >> txt = """ > >> ? ? 1 > >> ? ? 2 > >> ? ? 3 > >> ? ? 4 > >> ? ? 5 > >> ? ? > >> ? ? """ > >> l = len(txt.split('r2>'))-1 > >> a = ('%sr2>'%i for j,i in enumerate(txt.split('r2>')) if 0 < j < l > >> and i.replace('>','').replace('<','').strip()) > > >> Now you have a generator you can iterate through with a.next() or > >> alternatively you could just create a list out of it by replacing the > >> outer parens with square brackets.- Hide quoted text - > > >> - Show quoted text - > > > Hmmm... will look into it.. Thanks > > > the XML file is almost a TB in size... > > Good grief. When will people stop abusing XML this way? > > > so SAX will have to be the parser.... i'm thinking of doing something > > to split the file using SAX > > ... Any suggestions on those lines..? If there are any other parsers > > suitable, please suggest... > > You could try pulldom, but the documentation is disgraceful. > > ElementTree.iterparse *might* help. > > regards > ? Steve > > -- > Steve Holden ? ? ? ?+1 571 484 6266 ? +1 800 494 3119 > Holden Web LLC ? ? ? ? ? ? ?http://www.holdenweb.com/ I abuse it because I can (and because I don't generally work with XML files larger than 20-30meg) :) And the OP never said the XML file for 1TB in size, which makes things different. From here at softcom.net Thu Apr 24 23:04:55 2008 From: here at softcom.net (Sal) Date: Thu, 24 Apr 2008 20:04:55 -0700 (PDT) Subject: Remove old version before upgrade? Message-ID: I'm currently running Windows version 2.5.1 and would like to upgrade to 2.5.2. My question is, can I just go ahead and install the new version over the old or should I remove the old version with add/ remove programs first? The old version is in a directory named Python25. From mail at timgolden.me.uk Fri Apr 18 11:36:43 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 18 Apr 2008 16:36:43 +0100 Subject: Excel Manipulation using Python In-Reply-To: References: Message-ID: <4808C00B.2090009@timgolden.me.uk> Krishna wrote: > I was trying to delete rows in an existing .xls file using python. How > do I do that? I was using the following code, it seem to work if I > type in python window, but if I save it in text editor and drage and > drop the .py file, it doesnt work. What am I doing wrong here? Thanks > for your help! > > import win32com.client > from time import sleep > excel = win32com.client.Dispatch("Excel.Application") > > def Extract(): > excel.Visible = 0 > workbook=excel.Workbooks.Open('C:\Trial.xls') > > i=1 > for n in range(1,10): > excel.Rows(i).Select > excel.Selection.Delete > excel.Selection.Delete > i=i+2 > workbook.Save() > print "saved" > > excel.Quit() Several points worthy of note: 1) When you're dealing with Windows filenames, either make the strings raw -- Open (r"c:\trial.txt") -- or use the other slashes =-- Open ("c:/trial.xls"). 2) You're not actually calling the Select and Delete methods, merely referencing them. Try .Delete () etc. 3) You're saving the workbook every time round the loop, but perhaps you knew that. Might prompt you everytime as you're overwriting, but again, maybe you knew... TJG From marion at everautumn.com Thu Apr 3 14:08:20 2008 From: marion at everautumn.com (marion at everautumn.com) Date: Thu, 3 Apr 2008 11:08:20 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: <902504ff-410f-4cfc-b76b-89535b5276cc@2g2000hsn.googlegroups.com> On Apr 1, 1:27?pm, sprad wrote: > I'm a high school computer teacher, and I'm starting a series of > programming courses next year (disguised as "game development" classes > to capture more interest). The first year will be a gentle > introduction to programming, leading to two more years of advanced > topics. > > I was initially thinking about doing the first year in Flash/ > ActionScript, and the later years in Java. My reasoning is that Flash > has the advantage of giving a quick payoff to keep the students > interested while I sneak in some OOP concepts through ActionScript. > Once they've gotten a decent grounding there, they move on to Java for > some more heavy-duty programming. > > I've never used Python, but I keep hearing enough good stuff about it > to make me curious. > > So -- would Python be a good fit for these classes? Could it equal > Java as the later heavy-duty language? Does it have enough quickly- > accessible sparklies to unseat Flash? > > I want to believe. Evangelize away. I am a strong support of teaching programming in middle and high school. Kids have the potential of being more than just passive consumers of other programmers work. That is best illustrated by the growth of game mod'rs writing their own levels for computer games. I think I agree with all of the positive, supporting posts about Python. I would just like to add that Python (and PyGame) are open source and so your students can download it at home and have fun exploring it on their own time (at their own pace). I think that is a real positive. From steve at holdenweb.com Mon Apr 7 07:05:49 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 07 Apr 2008 07:05:49 -0400 Subject: First Python project - comments welcome! In-Reply-To: <1207555415.6966.88.camel@paul-laptop> References: <1207555415.6966.88.camel@paul-laptop> Message-ID: Paul Scott wrote: > I have started, and made some progress (OK it works, but needs some > love) on my first real Python application. > > http://cvs2.uwc.ac.za/trac/python_tools/browser/podder > > I would love some feedback on what I have done. In total this has taken > me 5 nights to do (I am working on it at night as PHP, not Python, is my > day job), so it can probably do with *lots* of improvement. All code is > GPL. > > If anyone on this list is willing/able, please do give me a few > pointers, even if it is "This is total crap - RTFM and come back when > you are ready" I would really appreciate it! > > Many thanks, and thank you to this community for helping me through the > initial bumps of getting into Python - a great dev tool IMHO! > The code looks pretty good to someone that doesn't know Gtk graphics. 184: self.wTree2=gtk.glade.XML(globaldir+"podder.glade","serverdialogue") could really do with using os.path.join() if you want to be easily cross-platform. Similarly the other places you use globaldir+"...". At line 321 you loop while True over a Queue.Queue object until the QueueEmpty exception is raised, then break out of the loop. It would be easier to loop while not queue.empty(). I know the docs say that this function is not reliable due to multi-threading semantics, but I doubt it will make your program less responsive. You even put docstrings on your code. WEll done, you are going to enjoy Python. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gnewsg at gmail.com Thu Apr 10 06:15:08 2008 From: gnewsg at gmail.com (Giampaolo Rodola') Date: Thu, 10 Apr 2008 03:15:08 -0700 (PDT) Subject: Sorting Directories from files in a os.listdir?? References: <9354f263-b833-4845-a226-1ad3a47b1e6a@p25g2000pri.googlegroups.com> Message-ID: <37182914-e2d9-4308-b78e-43c9a5431dbb@f63g2000hsf.googlegroups.com> On 10 Apr, 11:55, Soren wrote: > Hi, > > I'd like to read the filenames in a directory, but not the > subdirectories, os.listdir() gives me everything... how do I separate > the directory names from the filenames? Is there another way of doing > this? > > Thanks! I guess you have no other way than using os.path.isfile or os.path.isdir for every entry returned by os.listdir. --- Giampaolo http://code.google.com/p/pyftpdlib From tismer at stackless.com Thu Apr 24 15:49:45 2008 From: tismer at stackless.com (Christian Tismer) Date: Thu, 24 Apr 2008 12:49:45 -0700 Subject: Psyco alternative In-Reply-To: References: <1369b321-f55b-432b-b2f9-6144787509d8@h11g2000prf.googlegroups.com> <7xlk4473ai.fsf@ruckus.brouhaha.com> <651ncdF2cmik2U1@mid.uni-berlin.de> <651onqF2dripdU1@mid.uni-berlin.de> Message-ID: <4810E459.8040500@stackless.com> bearophileHUGS at lycos.com wrote: > Diez B. Roggisch: >> the author says that the approach is flawed, so at *some* >> point it will be discontinued. > > Can't Psyco be improved, so it can compile things like: > > nums = (i for i in xrange(200000) if i % 2) > print sum(nums) Although my main goal is to support PyPy as much as possible, I am currently taking a pause in favor of filling the gap for psyco, supporting generators. The details are not yet settled, maybe we choose to change the project name, to avoid the author getting bugged with questions about this extra stuff. - chris -- Christian Tismer :^) tismerysoft GmbH : Have a break! Take a ride on Python's Johannes-Niemeyer-Weg 9A : *Starship* http://starship.python.net/ 14109 Berlin : PGP key -> http://wwwkeys.pgp.net/ work +49 30 802 86 56 mobile +49 173 24 18 776 fax +49 30 80 90 57 05 PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04 whom do you want to sponsor today? http://www.stackless.com/ From sturlamolden at yahoo.no Fri Apr 4 19:19:03 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 4 Apr 2008 16:19:03 -0700 (PDT) Subject: Importing a 3rd Party windows DLL for use within th Python References: <92513305-836d-4c85-aeb8-3e3d6571ed92@1g2000prg.googlegroups.com> Message-ID: <82662184-347d-4277-93b5-5bbeef31792a@q27g2000prf.googlegroups.com> On Apr 5, 12:58 am, lee.walc... at gmail.com wrote: > Is it possible for someone to provide the information on the steps > necessary to access this DLL and treat it like any other pyd library? > Maybe there is already a tutorial available for performing this task? > Is this task straight forward? Short answer: Read the ctypes tutorial and reference. http://python.net/crew/theller/ctypes/tutorial.html http://python.net/crew/theller/ctypes/reference.html Other options: - Write a pyd wrapper manually in C - Write a pyd wrapper using Pyrex or Cython - Write a pyd wrapper using Swig - Write a pyd wrapper using Boost.Python or PyCXX - Inline C++ using scipy.weave From ott.deb at gmail.com Thu Apr 17 15:05:22 2008 From: ott.deb at gmail.com (ott.deb at gmail.com) Date: Thu, 17 Apr 2008 12:05:22 -0700 (PDT) Subject: fable keygen Message-ID: <60201293-e258-4ec7-8b97-8d10ece7a9d4@a23g2000hsc.googlegroups.com> fable keygen http://cracks.12w.net F R E E C R A C K S From martin at v.loewis.de Tue Apr 22 17:06:47 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 22 Apr 2008 23:06:47 +0200 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: References: Message-ID: <480e5367$0$17314$9b622d9e@news.freenet.de> > 2. Kill the subprocess in a platform independent manner (i.e. no third party > modules and no hacks). What's wrong with the .terminate method of the Popen object? Regards, Martin From ni at hao.com Wed Apr 30 02:13:17 2008 From: ni at hao.com (SL) Date: Wed, 30 Apr 2008 08:13:17 +0200 Subject: computing with characters Message-ID: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> How can I compute with the integer values of characters in python? Like 'a' + 1 equals 'b' etc From bockman at virgilio.it Sat Apr 26 05:28:39 2008 From: bockman at virgilio.it (Francesco Bochicchio) Date: Sat, 26 Apr 2008 11:28:39 +0200 Subject: display monochromatic images wxPython References: <43c2ef33-b08c-4161-b170-16ab346628d7@m36g2000hse.googlegroups.com> Message-ID: On Fri, 25 Apr 2008 14:42:17 -0700, wongjoekmeu at yahoo.com wrote: > Dear All, > I want to write a GUI program with wxPython displaying an image. But > the image I have is monochromatic. When I retrieve the data from the > image I end up with a list of integer. Starting from a list of integer > and knowing the width and height of the image, how do I display such > an image on a wx panel or frame ? I have had a look at the wxPython > demo but there I see only images where the data is a list of tuple > consisting of r,g ,b values. Is there are function where I directly > can input the list of array and let it display the image ? > Thanks in advance > > RR I think that RGB colors with the same amount of R,G, and B levels always result in some shade of gray. If so, you could try building your image data by convering each numver in a triplet of equal numbers. Ciao ---- FB From gherron at islandtraining.com Wed Apr 16 03:12:24 2008 From: gherron at islandtraining.com (Gary Herron) Date: Wed, 16 Apr 2008 00:12:24 -0700 Subject: Mailing list question In-Reply-To: <397280.11586.qm@web45815.mail.sp1.yahoo.com> References: <397280.11586.qm@web45815.mail.sp1.yahoo.com> Message-ID: <4805A6D8.6060007@islandtraining.com> python newbie wrote: > Hello, > Just curious; can I post a basic programming question to this mailing > list? You just did. :-) (Real answer: Yes. We're pretty newbie friendly here.) Gary Herron > > Thanks in advance. > > Pete > > ------------------------------------------------------------------------ > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try > it now. > From v.harishankar at gmail.com Wed Apr 23 05:31:54 2008 From: v.harishankar at gmail.com (Harishankar) Date: Wed, 23 Apr 2008 15:01:54 +0530 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: References: <200804230839.49560.v.harishankar@gmail.com> Message-ID: <200804231501.54730.v.harishankar@gmail.com> On Wednesday 23 Apr 2008 14:46:20 Christian Heimes wrote: > Harishankar schrieb: > > Is there any platform independent way to launch a terminal window from a > > desktop (Windows, Linux, etc.)? > > No, there isn't. It usually not possible to create a graphical terminal > window on a remote server. > > Christian Ah, well, since my application is a desktop tool and it requires a GUI I'm doing something like this: However, I have to then force the user to use xterm (which is a popular/common X Terminal) if (sys.platform.startswith ('win'): # launch the windows cmd.exe with the command ... else: # warn the user that xterm is required and then launch xterm ... -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org From martin.laloux at gmail.com Wed Apr 16 08:40:03 2008 From: martin.laloux at gmail.com (martin.laloux at gmail.com) Date: Wed, 16 Apr 2008 05:40:03 -0700 (PDT) Subject: Python crashes consistently References: Message-ID: <25f1364c-fc01-4d4c-9443-ac7396efe299@a70g2000hsh.googlegroups.com> I agree, use the official python http://www.python.org/ftp/python/2.5.2/python-2.5.2-macosx.dmg I'm also using OS X 10.4.11 and I have no problem for installing numpy http://www.scipy.org/Installing_SciPy/Mac_OS_X or you can download Pre-built binaries from http://pythonmac.org/packages/py25-fat/index.html or http://trichech.us/?page_id=5 From george.sakkis at gmail.com Tue Apr 1 23:24:01 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 1 Apr 2008 20:24:01 -0700 (PDT) Subject: generator functions: why won't this work? References: Message-ID: On Apr 1, 11:17 pm, George Sakkis wrote: > On Apr 1, 10:56 pm, zillo... at googlemail.com wrote: > > > > > Hi all, > > > I'm trying to understand generator functions and the yield keyword. > > I'd like to understand why the following code isn't supposed to work. > > (What I would have expected it to do is, for a variable number of > > arguments composed of numbers, tuples of numbers, tuples of tuples, > > etc., the function would give me the next number "in sequence") > > #################################### > > def getNextScalar(*args): > > for arg in args: > > if ( isinstance(arg, tuple)): > > getNextScalar(arg) > > else: > > yield arg > > #################################### > > > # here's an example that uses this function: > > # creating a generator object: > > g = getNextScalar(1, 2, (3,4)) > > g.next() # OK: returns 1 > > g.next() # OK: returns 2 > > g.next() # not OK: throws StopIteration error > > > #################################### > > > I'm sure I'm making some unwarranted assumption somewhere, but I > > haven't been able to figure it out yet (just started learning Python a > > couple of days ago). > > > Any help will be appreciated :) > > You're pretty close, there's just one more thing left. The return > value of a generator function is an iterable, something you're > supposed to iterate over. In the 'if' clause you call recursively the > generator on arg but you don't use the result, you discard it as soon > as it is returned. What you have to do is iterate over the returned > iterable and yield its values: > > # don't need parentheses around the if expression > if isinstance(arg, tuple): > for scalar in getNextScalar(arg): > yield scalar > > Hope this helps, > George Just after hitting send I noticed a second unrelated issue that has to do with the generator's signature. Since you define it to take any positional arguments instead of a single argument (as I mistakenly assumed), the right way to call it recursively is expand the tuple arg into positional arguments: getNextScalar(*arg) instead of getNextScalar(arg): # don't need parentheses around the if expression if isinstance(arg, tuple): for scalar in getNextScalar(*arg): yield scalar George From grante at visi.com Fri Apr 18 23:33:34 2008 From: grante at visi.com (Grant Edwards) Date: Fri, 18 Apr 2008 22:33:34 -0500 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041816413450073-bob@passcalnmtedu> Message-ID: On 2008-04-18, Bob Greschke wrote: > I'm on a Solaris 8 with Python 2.3.4 and when crunching > through, literally, millions and millions of samples of > seismic data fingers point out the difference nicely. :) I'll > look into this more on some of our bigger better faster > machines (there is no -m option for timeit on the Sun :). The > Sun is just what I develop on. If stuff runs fast enough to > keep me awake on there over an ssh'ed X11 connection it > should run even better on the real field equipment (Macs, > Linuxes, WinXPs). If time is an issue, I might write a C program to convert the files from 24-bit numbers to 32-bit numbers. Then you can use numpy to load huge arrays of them in a single whack. -- Grant Edwards grante Yow! .. he dominates the at DECADENT SUBWAY SCENE. visi.com From danb_83 at yahoo.com Tue Apr 8 21:25:05 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Tue, 8 Apr 2008 18:25:05 -0700 (PDT) Subject: text adventure game problem References: Message-ID: <63bcd116-6646-4acd-a36a-b2dd5a1706b2@s37g2000prg.googlegroups.com> On Apr 8, 8:01 pm, corvettecra... at gmail.com wrote: > okay, I'm having this one problem with a text adventure game. It's > kind of hard to explain, but I'll do my best. > [code] > > def prompt_kitchen(): > global gold > gold_taken = False > while True: > prompt_kit = raw_input('>') > if prompt_kit == 'examine cabinet 1' and not gold_taken: > print '''This cabinet has a lot of cups in it with all > different > designs and shapes. Where are the people anyway? How come there's > nobody here? > In one of the cups you find 8 gold.''' > gold = gold+8 > gold_taken = True > pass4() > elif prompt_kit == 'examine cabinet 1' and gold_taken: > print \ > '''This cabinet has a lot of cups in it with all > different > designs and shapes. Where are the people anyway? How come there's > nobody here?''' > pass4() > > def pass4(): > global gold > print 'You have', gold, 'gold' > pass > [/code] > > Okay, now for my problem. > In the above function, there's the option to examine a cabinet and get > 8 gold. (everyone here knows that...but I'm just trying to state my > problem...) > Unfortunately, it kind of doesn't work. > After the first time I 'examine cabinet 1' in my game, I get 8 gold > and I can't get it again. > But, If I leave the room and come back to it, then it's as if I had > never gotten the gold the first time, and I can get it again. That's because your function starts with "gold_taken = False". The easiest fix is to make gold_taken a global variable initialized outside the function, like you're already doing with gold. From gagsl-py2 at yahoo.com.ar Wed Apr 30 05:24:00 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 30 Apr 2008 06:24:00 -0300 Subject: Who makes up these rules, anyway? References: Message-ID: En Tue, 29 Apr 2008 13:15:33 -0300, Roel Schroeven escribi?: > Cameron Laird schreef: >> In article , >> Gabriel Genellina wrote: >>> Explicit variable declaration for functions: >>> >>> http://groups.google.com/group/comp.lang.python/browse_thread/thread/6c4a508edd2fbe04/ >> . >> A reader notes that this thread actually lived during 2004 (!) [...] > > I assumed it was a mix-up with the recent thread with the same name: > http://groups.google.com/group/comp.lang.python/browse_thread/thread/f3832259c6da530 Yes, sorry! The worst part is that I *did* notice it was an old thread, but somehow I messed the links at the end. -- Gabriel Genellina From bvidinli at gmail.com Wed Apr 16 04:26:18 2008 From: bvidinli at gmail.com (bvidinli) Date: Wed, 16 Apr 2008 11:26:18 +0300 Subject: How is GUI programming in Python? In-Reply-To: <69795448-0534-4aed-a9a0-84f2cd3aea36@s50g2000hsb.googlegroups.com> References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> <69795448-0534-4aed-a9a0-84f2cd3aea36@s50g2000hsb.googlegroups.com> Message-ID: <36e8a7020804160126j17b9f0c8r11986ff2d3cec8c7@mail.gmail.com> So many gui toolkits, designers.... none of them makes up half of Delphi... unfortunately... i try to use Boa now, easiest of all others on linux/python, but it is far away from Delphi- delphi like... Why dont those toolkits/designers come together and build a single, powerfull ide ? 2008/4/16, bockman at virgilio.it : > On 11 Apr, 20:19, Rune Strand wrote: > > On Apr 10, 3:54 am, Chris Stewart wrote: > > ... > > > > > > > > > Next, what would you say is the best framework I should look into? > > > I'm curious to hear opinions on that. > > > > GUI-programming in Python is a neanderthal experience. What one may > > love with console scripts is turned upside-down. Projects like Boa > > Constructor seemed to be a remedy, but is not developed. The Iron- > > Pythonistas has a very promising RAD GUI-tool in the IronPython - > > Studio,http://www.codeplex.com/IronPythonStudio- but if you're non- > > Iron, only sorrow is left - unless you fancy creating GUI in a text- > > editor. Something I consider waste of life. > > If you refer to lack of GUI designer, every toolkit usable by python - > barring Tkinter - has a GUI > designer wich can be used: > > pygtk -> Glade > pywx -> wxDesigner, rxced, ... > pyqt -> QDesigner, ... > > All can generate python code and/or generate files that can be used by > python program to > create the whole GUI with a few function calls (e.g. libglade ). > > If you refer to the lack of visual programming ala visualstudio or > JBorland, you might be right, > but I personally found that visual programming makes for very > unmaintenable code, especially if you have to > fix something and you don't have the IDE with you (and this has > happened many times to me). > Therefore I now prefer a clean separation between the GUI (described > in someting like glade files or .xrc files) > and my code. > > BTW, once learned to use the right layout managers, even building a > GUI from scratch is not such a PITA, since you > don't have to manually place each widget anymore, but only define the > structure of packers and grids and then > adjust borders and such with some -limited IME - experimentation. I > know people that prefer this approach to any GUI builder, having > developed their own little library to help reducing the boilerplate > (and in Python you can do nice things with decorators ans such ... ). > > So maybe yes, in python you might not have the fancy world of visual > programming, but neither are deprived of tools > that make your work easier. > > Ciao > ----- > FB > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From nick at stinemates.org Sat Apr 26 01:04:54 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 25 Apr 2008 22:04:54 -0700 Subject: multiple pattern regular expression In-Reply-To: References: <1209131456.20871.1249849011@webmail.messagingengine.com> Message-ID: <20080426050454.GA15172@deviL> On Fri, Apr 25, 2008 at 08:40:55PM -0400, Carsten Haese wrote: > Nick Stinemates wrote: >> On Fri, Apr 25, 2008 at 09:50:56AM -0400, python at bdurham.com wrote: >>> How about this? >>> >>> for line in file: >>> # ignore lines without = assignment >>> if '=' in line: >>> property, value = line.strip().split( '=', 1 ) >>> property = property.strip().lower() >>> value = value.strip() >>> >>> # do something with property, value >>> >>> Malcolm >> This works until you have: >> string=The sum of 2+2=4 > > Actually, it still works, because Malcolm used split()'s maxsplit > parameter. > > -- > Carsten Haese > http://informixdb.sourceforge.net > -- > http://mail.python.org/mailman/listinfo/python-list Didn't see that -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From NikitaTheSpider at gmail.com Tue Apr 8 11:13:28 2008 From: NikitaTheSpider at gmail.com (Nikita the Spider) Date: Tue, 08 Apr 2008 11:13:28 -0400 Subject: urlparse http://site.com/../../../page.html References: <9fdd0d8b-785a-4363-be6a-75f993527754@c65g2000hsa.googlegroups.com> Message-ID: In article , "monk.e.boy" wrote: > I figured it out and blogged the answer: > > http://teethgrinder.co.uk/blog/Normalize-URL-path-python/ Thanks for letting us know of a solution. You might also be interested in Fourthought's URI library which contains a function called Absolutize() to do just what you're asking. It also claims to do a better job of parsing URIs than some of the functions in stock Python library. I've been using it heavily for quite a while and it has served me well. http://4suite.org/ -- Philip http://NikitaTheSpider.com/ Whole-site HTML validation, link checking and more From nick at stinemates.org Fri Apr 25 18:34:35 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 25 Apr 2008 15:34:35 -0700 Subject: MESSAGE RESPONSE In-Reply-To: <67bs3rF2najntU2@mid.uni-berlin.de> References: <5504f9ac0804230927ncfdb91buf7fa3e181f8a9237@mail.gmail.com> <67bs3rF2najntU2@mid.uni-berlin.de> Message-ID: <20080425223435.GA12662@deviL> On Thu, Apr 24, 2008 at 06:50:44PM +0200, Diez B. Roggisch wrote: > Blubaugh, David A. schrieb: >> Dear Sir, >> Belcan has an absolute zero-tolerance policy toward material such as the >> material described. > > That pairs up nicely with them having zero knowledge about the internet. > ZING! -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From hopeorpha308 at gmail.com Sun Apr 27 07:48:27 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:48:27 -0700 (PDT) Subject: Nero 7 premium reloaded crack Message-ID: Nero 7 premium reloaded crack http://wga-cracks.crackkey.net From jeffrey at fro.man Tue Apr 15 16:48:18 2008 From: jeffrey at fro.man (Jeffrey Froman) Date: Tue, 15 Apr 2008 13:48:18 -0700 Subject: Recurring patterns: Am I missing it, or can we get these added to the language? References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: Tim Chase wrote: > def nsplit(s, delim=None, maxsplit=None): > if maxsplit: > results = s.split(delim, maxsplit) > result_len = len(results) > if result_len < maxsplit: > results.extend([''] * (maxsplit - result_len) > return results > else: > return s.split(delim) I'll add a couple more suggestions: 1. Delay the test for maxsplit, as str.split() does the right thing if maxsplit is None. 2. Use a generator to pad the list, to avoid interim list creation. This works fine, because list.extend() accepts any iterable. This also shortens the code a bit, because xrange() does the right thing in this case with negative numbers. For example: def nsplit(s, delim=None, maxsplit=None): results = s.split(delim, maxsplit) if maxsplit is not None: results.extend('' for i in xrange(maxsplit - len(results))) return results Jeffrey From reachmsn at hotmail.com Tue Apr 15 03:57:19 2008 From: reachmsn at hotmail.com (reachmsn at hotmail.com) Date: Tue, 15 Apr 2008 00:57:19 -0700 (PDT) Subject: Cannot understand the detailedly the following code References: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> <10a83944-b17a-4c3f-992b-1754c0a5e9b1@s33g2000pri.googlegroups.com> Message-ID: On Apr 11, 10:27?am, "Gabriel Genellina" wrote: > En Thu, 10 Apr 2008 23:57:29 -0300, escribi?: > > > i.e. you give, the graph, the start and end vertices as inputs and you > > get the output as a listing of all the paths. This is where I got to. > > It would be very nice if you could kindly hint on how to proceed > > further. Thank you so much for your time! > > If you want to understand how recursion works, or how you can actually ? > construct a recursive function step by step, see this excellent post by ? > Neil Cerutti: > > http://groups.google.com/group/comp.lang.python/msg/9f0b10631fd47886 > > -- > Gabriel Genellina Hi, I did read the post by Neil Cerutti, but I still am unable to write this recursive function. I will appreciate it if someone can kindly guide me. Thanks, Anshu From hat at se-162.se.wtb.tue.nl Tue Apr 8 08:45:35 2008 From: hat at se-162.se.wtb.tue.nl (A.T.Hofkamp) Date: Tue, 08 Apr 2008 14:45:35 +0200 Subject: Cannot understand the detailedly the following code References: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> Message-ID: On 2008-04-08, reachmsn at hotmail.com wrote: [deleted a long piece of text by our BDFL about recursive graph path-finding algorithm] > after first writing the inductive part ... for node in > graph[start] .... > and then by trial and error put square brackets around path in the > Basis part. Can someone please explain how to write this code. Thanks! The same as any other function. (the trick with recursive functions is not to think about recursion. Instead, pretend you are calling another function that happens to have the same name.) As for the actual procedure of writing a function: First define the input and output parameters/values of the function. (ie what goes in, and what comes out) For recursive functions, there are always two cases, a terminating case, and a reduction case. In the first case, you may not use the recursive function, in the latter function you should. Both cases should use the information available from the input parameters, and provide a result that matches with the output requirements of the function. Add a if/then/else that distinguishes between what case you have, and you're done. Sincerely, Albert From gnewsg at gmail.com Tue Apr 15 15:02:48 2008 From: gnewsg at gmail.com (Giampaolo Rodola') Date: Tue, 15 Apr 2008 12:02:48 -0700 (PDT) Subject: How to have unittest tests to be executed in the order they appear? Message-ID: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> Hi there. Is there a way to force unittest to run test methods in the order they appear? I'll try to explain. My test suite appears as something like this: import unittest from test.test_support import TestSkipped, run_unittest class TestCase(unittest.TestCase): def test_z(self): ... def test_b(self): ... def test_d(self): ... if __name__ == '__main__': run_unittest(TestCase) I'd like the tests to be executed in the order they are defined (test_z, test_b and finally test_d). Is there a way to do that? Thanks in advance. --- Giampaolo http://code.google.com/p/pyftpdlib/ From python at bdurham.com Mon Apr 21 12:10:49 2008 From: python at bdurham.com (python at bdurham.com) Date: Mon, 21 Apr 2008 12:10:49 -0400 Subject: Does Python 2.5.2's embedded SQLite support full text searching? Message-ID: <1208794249.15992.1249049327@webmail.messagingengine.com> Does Python 2.5.2's embedded SQLite support full text searching? Any recommendations on a source where one can find out which SQLite features are enabled/disabled in each release of Python? I'm trying to figure out what's available in 2.5.2 as well as what to expect in 2.6 and 3.0. Thank you, Malcolm From tokyo246 at gmail.com Fri Apr 4 13:29:19 2008 From: tokyo246 at gmail.com (Kenji Noguchi) Date: Fri, 4 Apr 2008 10:29:19 -0700 Subject: developing web spider In-Reply-To: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> References: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> Message-ID: <2ba587f0804041029k75a0595le3e28f56921cbb41@mail.gmail.com> Attached is a essence of my crawler. This collects tag in a given URL HTML parsing is not a big deal as "tidy" does all for you. It converts a broken HTML to a valid XHTML. From that point there're wealth of XML libraries. Just write whatever you want such as element handler. I've extended it for multi-thread, limit the number of thread for a specific web host, more flexible element handling, etc, etc. SQLite is nice for making URL db by the way. Kenji Noguchi -------------- next part -------------- A non-text attachment was scrubbed... Name: crawler.py Type: text/x-python Size: 2583 bytes Desc: not available URL: From gagsl-py2 at yahoo.com.ar Thu Apr 3 08:32:02 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 09:32:02 -0300 Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> Message-ID: En Thu, 03 Apr 2008 05:20:48 -0300, sam escribi?: > Gabriel Genellina napisa?(a): > >> Class methods and instance methods are not just standard functions; >> instance methods were plain functions before 2.2 and the Class object >> was in charge of doing the "self magic". Now the descriptor protocol >> provides far more possibilities. > > Actually I don't know what is "descriptor protocol", so maybe I should > have > finished discussing. I will aslo search for "self magic" -- some pieces > of old > code, or something. I meant the way instance methods acquire their "self" argument; the transformation from someobject.foo(arg1,arg2) into (ClassOfSomeobject.foo)(someobject, arg1, arg2) that classic classes do themselves and could not be changed nor extended. The descriptor protocol provides a way for attributes to modify the way they're handled; this is how instance methods get their self argument, and allows for the existence of class methods, static methods, and properties, among other things. The descriptor protocol is very important for Python and understanding it is a good idea, but not before you are rather fluent with the language or it will be fairly incomprehensible. -- Gabriel Genellina From jeffober at gmail.com Thu Apr 3 09:00:14 2008 From: jeffober at gmail.com (Jeff) Date: Thu, 3 Apr 2008 06:00:14 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> <88b07549-9751-489b-968f-c3d2db0aba79@s13g2000prd.googlegroups.com> Message-ID: On Apr 3, 8:44?am, Ant wrote: > On Apr 3, 12:37 pm, tinn... at isbd.co.uk wrote: > > > What's the neatest and/or most efficient way of testing if one of a > > A different approach: > > >>> words = ["he", "sh", "bla"] > >>> name = "blah" > >>> True in (word in name for word in words) > > True > > >>> name = "bling" > >>> True in (word in name for word in words) > > False > > Perhaps not as obvious or readable as Jeff's example, but is > essentially doing the same thing using generator syntax. That's pretty :) From dickinsm at gmail.com Wed Apr 9 15:35:55 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Wed, 9 Apr 2008 12:35:55 -0700 (PDT) Subject: Python 3.0 new integer division References: Message-ID: On Apr 8, 6:01 pm, Jonathan Gardner wrote: > On Apr 8, 2:25 pm, Grzegorz S?odkowicz wrote: > > > > > Isn't Decimal a BCD implementation? > > Yep, you are right and I am wrong.http://www.python.org/dev/peps/pep-0327/#why-not-rational Strictly speaking, BCD doesn't come into it: the coefficient of a Decimal instance is stored simply as a string of digits. This is pretty wasteful in terms of space: 1 byte per decimal digit instead of the 4 bits per digit that BCD gives, but it's convenient and fairly efficient. An alternative representation that's gained popularity recently is DPD (densely packed decimal), which packs 3 decimal digits into 10 bits in a clever way that allows reasonably efficient extraction of any one of the 3 digits. Decimal doesn't use this either. :) Mark From python at bdurham.com Mon Apr 28 14:07:42 2008 From: python at bdurham.com (python at bdurham.com) Date: Mon, 28 Apr 2008 14:07:42 -0400 Subject: How to unget a line when reading from a file/stream iterator/generator? Message-ID: <1209406062.7586.1250312147@webmail.messagingengine.com> Is there an elegant way to unget a line when reading from a file/stream iterator/generator? By "unget" I mean a way to push back a line into the source stream and backtrack the iterator/generator one step? The only alternative I can see is to put my line reading in a while-True loop (vs. a for-loop) that manually calls my file/stream iterator/generator's .next() method while manually handling the StopIteration exception. Doesn't sound too elegant. Is there a Pythonic design pattern/best practice that I can apply here? Thank you, Malcolm From buzzard at urubu.freeserve.co.uk Tue Apr 15 15:07:14 2008 From: buzzard at urubu.freeserve.co.uk (duncan smith) Date: Tue, 15 Apr 2008 20:07:14 +0100 Subject: Preferred method for "Assignment by value" In-Reply-To: <7047986d-f6cc-4189-81f6-47da1ecf1902@k1g2000prb.googlegroups.com> References: <6a3ed8f0-b82c-4cd3-b36e-1d94f8a30fe3@n1g2000prb.googlegroups.com> <7047986d-f6cc-4189-81f6-47da1ecf1902@k1g2000prb.googlegroups.com> Message-ID: hall.jeff at gmail.com wrote: > Thank you both, the assigning using slicing works perfectly (as I'm > sure you knew it would)... It just didn't occur to me because it > seemed a little nonintuitive... The specific application was > > def dicttolist (inputdict): > finallist=[] > for k, v in inputdict.iteritems(): > temp = v > temp.insert(0,k) > finallist.append(temp) > > return finallist > Maybe, finallist = [[k] + v for k, v in inputdict.iteritems()] the list concatenation creating new lists. Duncan From ivan.illarionov at gmail.com Sun Apr 13 13:43:32 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Sun, 13 Apr 2008 10:43:32 -0700 (PDT) Subject: Looking for a way to include Pyhtho scripting INSIDE a python program References: <48017af0$0$36399$742ec2ed@news.sonic.net> Message-ID: <6c5bca34-71b7-4ebb-8ae9-cf894fac5168@c19g2000prf.googlegroups.com> On Apr 13, 8:20 pm, Bryan Oakley wrote: > Ivan Illarionov wrote: > > You don't need to envoke another interpreter. > > Python can interpret arbitrary python code with exec statement. > > Wrap user's string inside function definition, and exec it. > > > You might want to disable words like `import`, `exec` and `eval` in > > user's code because it's a big security risk. > > The above statement is exactly why one would want to eval the code > inside a separate interpreter. Not just for security, but to prevent > user code from stomping all over the application code by creating or > destroying global resources. > > Is it possible to create a nested interpreter like you can do in some > other languages? Yes. Call PyRun_SimpleString from ctypes or call PyRun_SimpleString from custom python extension. But it does nothing what exec can't do. We have: exec `something` in `where_we_exec` if `where_we_exec` is an empty dictionary the exec'd code has no access to app code or global resources. Even more, it's harder to control the nested interpreter than strings about to be exec'd. And you still have to worry about security. So, not only you gain nothing by this approach, you make your software more vulnerable. The code like `import os\n os.*killme*` or eval("__import__('os').*killme*") will be harder to disable. -- Ivan From huayang.xia at gmail.com Fri Apr 11 09:37:23 2008 From: huayang.xia at gmail.com (Huayang Xia) Date: Fri, 11 Apr 2008 06:37:23 -0700 (PDT) Subject: Convert PyIDispatch object to struct IDispatch* References: <90eee1e1-b1cc-48a9-8c09-173e92861f2c@a5g2000prg.googlegroups.com> Message-ID: <83260aaf-b2d7-4857-bd71-a8e7b30c6d70@n14g2000pri.googlegroups.com> On Apr 11, 12:15 am, "Gabriel Genellina" wrote: > En Thu, 10 Apr 2008 18:45:04 -0300, Huayang Xia > escribi?: > > > I am trying to use ctypes to call dll functions. One of the functions > > requires argument "struct IDispatch* ". I do have a PyIDispatch object > > in python. How can I convert this "PyIDispatch object" to "struct > > IDispatch* "? > > I think a PyIDispatch object is an IDispatch* itself. > But you'll get better answers from the python-win32 list:http://mail.python.org/mailman/listinfo/python-win32 > > -- > Gabriel Genellina Thanks for the info. To call a dll function, it needs a C style IDispatch*. PyIDispatch is a python wrapped one. I found a reference from: http://svn.python.org/projects/ctypes/trunk/comtypes/comtypes/test/test_win32com_interop.py which shows how to convert C style to python style. Unfortunately i need the reversed version. I will post the question to python-win32. From fn681 at ncf.ca Mon Apr 7 19:31:36 2008 From: fn681 at ncf.ca (Colin J. Williams) Date: Mon, 07 Apr 2008 20:31:36 -0300 Subject: A funnily inconsistent behavior of int and float In-Reply-To: References: <9ab07ffa-7473-4940-b24a-33f801d9c9dc@m44g2000hsc.googlegroups.com> <1d11875a-470a-489f-910a-b420a145eb61@a1g2000hsb.googlegroups.com> Message-ID: Terry Reedy wrote: > "Mark Dickinson" wrote in message > news:1d11875a-470a-489f-910a-b420a145eb61 at a1g2000hsb.googlegroups.com... > | On Apr 7, 6:43 am, "Colin J. Williams" wrote: > | > This is good but the documentation for > | > 3.0 is missing the syntax documentation > | > from 2.5 > | > | Is > | > | > http://docs.python.org/dev/3.0/reference/lexical_analysis.html#integer-literals > | > | the documentation that you're looking for? Yes, thanks. I missed it. Colin W. > | > | But it seems to me that Lie's original point isn't really > | about integer *literals* anyway---it's about the behaviour > | of the built-in int() function when applied to a string. So > | > | http://docs.python.org/dev/3.0/library/functions.html#int > | > | is probably the appropriate place in the documentation. And > | I agree that it could be made clearer exactly what strings are > | acceptable here. > > Agreed. > > It says "If radix is zero, the interpretation is the same as for integer > literals." > But integer literals are unsigned. Is radix 0 any different from the > default of radix 10? > > It also says "If the argument is a string, it must contain a possibly > signed number of arbitrary size, possibly embedded in whitespace." But > only integers, not 'numbers' as some would understand that, are accepted. > > My suggestions: > 1. Change signature to: int([number | string[, radix]). > This makes it clear that radix can only follow a string without having to > say so in the text. > > 2. Replace text with: > Convert a number or string to an integer. If no arguments are given, > return 0. If a number is given, return number.__int__(). Conversion of > floating point numbers to integers truncates towards zero. A string must > be a base-radix integer literal optionally preceded by '+' or '-' (with no > space in between) and optionally surrounded by whitespace. A base-n > literal consists of the digits 0 to n-1, with 'a' to 'z' (or 'A' to 'Z') > having values 10 to 35. The default radix is 10. The allowed values are 0 > and 2-36, with 0 the same as 10. > > If 0 is not the same as 10, the last would have to be changed, but I could > not detect any difference in a quick test. > > After looking at any comments here, I will consider submitting these to the > tracker. > > Terry Jan Reedy > > > From samslists at gmail.com Thu Apr 3 22:29:18 2008 From: samslists at gmail.com (samslists at gmail.com) Date: Thu, 3 Apr 2008 19:29:18 -0700 (PDT) Subject: Any fancy grep utility replacements out there? References: Message-ID: Thanks to everyone who responded, and sorry for my late response. Grin seems like the perfect solution for me. I finally had a chance to download it and play with it today. It's great. Robert...you were kind enough to ask if I had any requests. Just the one right now of grepping through gzip files. If for some reason you don't want to do it or don't have time to do it, I could probably do it and send you a patch. But I imagine that since you wrote the code, you could do it more elegantly than I could. Thanks! P.S. Robert....this program totally deserves a real web page, not just being buried in an svn repository. I spent a lot of time looking for a tool like this that was written in python. I imagine others have as well, and have simply given up. On Mar 18, 7:16 pm, Robert Kern wrote: > I have agrep-like utility I call "grin". I wrote it mostly to recursivelygrep > SVN source trees while ignoring the garbage under the .svn/ directories and more > or less do exactly what I need most frequently without configuration. It could > easily be extended to open gzip files with GzipFile. > > https://svn.enthought.com/svn/sandbox/grin/trunk/ > > Let me know if you have any requests. From saluk64007 at gmail.com Mon Apr 21 21:15:48 2008 From: saluk64007 at gmail.com (Patrick Mullen) Date: Mon, 21 Apr 2008 18:15:48 -0700 Subject: Python 2.5 adoption In-Reply-To: References: <1da03626-2d4b-4e01-ba47-93f9d5c8f57f@l64g2000hse.googlegroups.com> Message-ID: On Mon, Apr 21, 2008 at 1:49 PM, Jorgen Grahn wrote: > OP: keep in mind that your users do not see any gain from you using > 2.5. All they see is something that makes your software harder to > install. At some point you can dismiss them as living in the Stone Age, > but the Stone Age is currently 2.1 or something. Maybe 2.2 is, too. Except for the memory bug which 2.5 fixed (not giving memory back), which in some cases with 2.4 could be a really large issue. But in that case you get the benefit whether it was "coded for" 2.5 or not. So it is still safest to develop for a lower common denominator. For me, the best things about 2.5 were the memory fixes/performance, and the inclusion of ctypes in the standard library. The language upgrades are mostly corner cases. If I were the OP, and those corner situations aren't too big of an issue, I would restrict my usage to 2.4 or even 2.3 to allow easier adoption of the software. From asmodai at in-nomine.org Wed Apr 30 10:43:03 2008 From: asmodai at in-nomine.org (Jeroen Ruigrok van der Werven) Date: Wed, 30 Apr 2008 16:43:03 +0200 Subject: best way to host a membership site In-Reply-To: <53034dcc-7346-4f71-889c-3278c9e813ec@w1g2000prd.googlegroups.com> References: <53034dcc-7346-4f71-889c-3278c9e813ec@w1g2000prd.googlegroups.com> Message-ID: <20080430144303.GH56542@nexus.in-nomine.org> -On [20080430 02:16], Magdoll (magdoll at gmail.com) wrote: >Also I want an infrastructure that's not too rigid so if in the future I >want to add more apps it's not to hard. Not to belittle Django, but for what I wanted to do with it, it was too restraining. I instead went with a combination of: Werkzeug - http://werkzeug.pocoo.org/ SQLAlchemy - http://www.sqlalchemy.org/ Genshi - http://genshi.edgewall.org/ (although some people might prefer Jinja is they like Django's templating - http://jinja.pocoo.org/) Babel - http://babel.edgewall.org/ This provided me with a lot of flexibility, more than Django could've provided me with (but hey, welcome to the general limitation of frameworks). -- Jeroen Ruigrok van der Werven / asmodai ????? ?????? ??? ?? ?????? http://www.in-nomine.org/ | http://www.rangaku.org/ | GPG: 2EAC625B The human race is challenged more than ever before to demonstrate our mastery -- not over nature but of ourselves... From sturlamolden at yahoo.no Thu Apr 17 11:19:44 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 17 Apr 2008 08:19:44 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> Message-ID: On 17 Apr, 10:25, "Martin v. L?wis" wrote: > help progress at all. I think neither was the case in this thread - > the guy claimed that he actually did something about the GIL, and > now we are all waiting for him to also tell us what it is that he > did. Ok, I did not remove the GIL, but I found a way to remove its notorious side effect on SMPs. So I am going to reveal it now. Forgive my strange sence of humor at 3 o'clock in the morning. First, think about this: (1) What is the GIL? (2) Where does it live? (3) How can it be manually released? The answer to this is: (1) A critical section (a lock/mutex object) (2) As a global object in Python25.dll on my computer (3) Using Python's C API or calling methods in a ctypes.CDLL object The Python C API has the ability to embed Python interpreters. You do this by importing Python25.dll into the process. ctypes has the ability to call functions in a DLL. So is it possible to embed Python in Python? And what would be consequence be? First, if I try to load a DLL more than once, Windows will detect this and just give me a handle to the currently imported library. So by importing Python25.dll with ctypes, I can just make my Python interpreter talk to itself through its own CAPI. Yes I can create sub interpreters using PyNew_Interpreter, but they all share the same GIL, so it's not useful here. So here is what I suddendly realized, and please don't laugh, its so simple its almost silly: I make some copies of Python25.dll, and call them Python25-1.dll, Python25-2.dll, Python25-3.dll, Python25-4.dll, etc. Then I load them all into my current Python process as ctypes.CDLL objects. Tada! I now have a pool of independent Python interpreters, not sharing the GIL, but still living in the same process. I can make the different interpreters talk to each other, including manipulating each other's GIL, using the using ctypes and Python's C API for embedding. So why does this circumvent the GIL? Because ctypes releases it before calling functions form a CDLL object. If I use my main interpreter to delegate a task to one of its embedded 'children', its GIL will be released while it is waiting for the answer. Associating each embedded interpreter with a threading.Thread is all that remains. The GIL is released while the thread operating the child interpreter is blocked. An there you have the answer. It's really very simple :-) Regards, Sturla Molden From fetchinson at googlemail.com Tue Apr 15 23:31:52 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Tue, 15 Apr 2008 20:31:52 -0700 Subject: Interesting timing issue I noticed In-Reply-To: References: Message-ID: On 4/15/08, Daniel Fetchinson wrote: > > Can I then simply ignore the time data then? I do see better performance > > obviously the smaller the box is, but I guess my issues is how seriously > to > > take all this data. Because I can't claim "performance improvement" if > there > > isn't really much of an improvement. > > > > On Tue, Apr 15, 2008 at 11:04 PM, Daniel Fetchinson < > > fetchinson at googlemail.com> wrote: > > > > > > I've written up a stripped down version of the code. I apologize for > > > the bad > > > > coding; I am in a bit of a hurry. > > > > > > > > import random > > > > import sys > > > > import time > > > > > > > > sizeX = 320 > > > > sizeY = 240 > > > > borderX = 20 > > > > borderY = 20 > > > > > > > > # generates a zero matrix > > > > def generate_zero(): > > > > matrix = [[0 for y in range(sizeY)] for x in range(sizeX)] > > > > return matrix > > > > # fills zero matrix > > > > def fill_matrix(in_mat): > > > > mat = in_mat > > > > for x in range(sizeX): > > > > for y in range(sizeY): > > > > mat[x][y] = random.randint(1, 100) > > > > return mat > > > > ###################################################################### > > > > # COMPUTES ONLY A PART OF THE ARRAY > > > > def back_diff_one(back_array, fore_array, box): > > > > diff_array = generate_zero() > > > > > > > > start = time.time() > > > > for x in range(sizeX): > > > > for y in range(borderY): > > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > > for y in range((sizeY - borderY), sizeY): > > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > > for y in range(borderY, (sizeY - borderY)): > > > > for x in range(borderX): > > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > > for x in range((sizeX - borderX), sizeX): > > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > > > > > > # tracks object > > > > if (len(box) != 0): > > > > for x in range(box[0], box[2]): > > > > for y in range(box[1], box[3]): > > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > > print "time one inside = " + str(time.time() - start) > > > > return diff_array > > > > ###################################################################### > > > > # COMPUTES EVERY ELEMENT IN THE ARRAY > > > > def back_diff_two(back_array, fore_array): > > > > diff_array = generate_zero() > > > > start = time.time() > > > > for y in range(sizeY): > > > > for x in range(sizeX): > > > > diff_array[x][y] = back_array[x][y] - fore_array[x][y] > > > > end = time.time() > > > > print "time two inside = " + str(end - start) > > > > return diff_array > > > > ###################################################################### > > > > # CODE TO TEST BOTH FUNCTIONS > > > > back = fill_matrix(generate_zero()) > > > > fore = fill_matrix(generate_zero()) > > > > box = [20, 20, 268, 240] > > > > start1 = time.time() > > > > diff1 = back_diff_one(back, fore, box) > > > > print "time one outside = " + str(time.time() - start1) > > > > start2 = time.time() > > > > diff2 = back_diff_two(back, fore) > > > > print "time one outside = " + str(time.time() - start2) > > > > > > > > Here are some results from several test runs: > > > > > > > > time one inside = 0.0780000686646 > > > > time one outside = 0.125 > > > > time two inside = 0.0780000686646 > > > > time two outside = 0.141000032425 > > > > >>> ================================ RESTART > > > > ================================ > > > > >>> > > > > time one inside = 0.0629999637604 > > > > time one outside = 0.125 > > > > time two inside = 0.0789999961853 > > > > time two outside = 0.125 > > > > >>> ================================ RESTART > > > > ================================ > > > > >>> > > > > time one inside = 0.0620000362396 > > > > time one outside = 0.139999866486 > > > > time two inside = 0.0780000686646 > > > > time two outside = 0.125 > > > > >>> ================================ RESTART > > > > ================================ > > > > >>> > > > > time one inside = 0.0780000686646 > > > > time one outside = 0.172000169754 > > > > time two inside = 0.0789999961853 > > > > time two outside = 0.125 > > > > >>> ================================ RESTART > > > > ================================ > > > > >>> > > > > time one inside = 0.0780000686646 > > > > time one outside = 0.125 > > > > time two inside = 0.0780000686646 > > > > time two outside = 0.125 > > > > >>> ================================ RESTART > > > > ================================ > > > > >>> > > > > time one inside = 0.0620000362396 > > > > time one outside = 0.155999898911 > > > > time two inside = 0.0780000686646 > > > > time two outside = 0.125 > > > > >>> ================================ RESTART > > > > ================================ > > > > >>> > > > > time one inside = 0.077999830246 > > > > time one outside = 0.125 > > > > time two inside = 0.077999830246 > > > > time two outside = 0.125 > > > > >>> ================================ RESTART > > > > ================================ > > > > >>> > > > > time one inside = 0.0780000686646 > > > > time one outside = 0.171000003815 > > > > time two inside = 0.077999830246 > > > > time two outside = 0.125 > > > > >>> ================================ RESTART > > > > ================================ > > > > >>> > > > > time one inside = 0.0629999637604 > > > > time one outside = 0.18799996376 > > > > time two inside = 0.0620000362396 > > > > time two outside = 0.125 > > > > > > > > Why is a large percentage of the time, the execution time for the > > > > (ostensibly smaller) first loop is actually equal to or LARGER than > the > > > > second? > > > > > > > > > First of all, your method of timing is not the best. Use the timeit > > > module instead: http://docs.python.org/lib/module-timeit.html > > > > > > Second of all the number of subtractions is not that different between > > > the two variants of your functions. back_diff_one does 75360 > > > subtractions per call while back_diff_two does 76800, these two > > > numbers are almost the same. It's true that back_diff_one first only > > > calculates a part of the arrays but after "# tracks object" you do a > > > bunch of more substractions that will make up the total count. > > > > > > HTH, > > > Daniel > > > > > Please keep the discussion on the list. > > Yes, if I were you I would discard your original timing data and redo > it using the timeit module. Whatever that gives should be reliable and > you can start from there. In any case your two functions are doing > roughly the same number of operations. > > HTH, > Daniel > BTW, using the following ###################################################################### # CODE TO TEST BOTH FUNCTIONS back = fill_matrix(generate_zero()) fore = fill_matrix(generate_zero()) box = [20, 20, 268, 240] def test1( ): diff1 = back_diff_one(back, fore, box) def test2( ): diff2 = back_diff_two(back, fore) if __name__=='__main__': from timeit import Timer t = Timer("test1( )", "from __main__ import test1") print t.timeit( 50 ) t = Timer("test2( )", "from __main__ import test2") print t.timeit( 50 ) and removing all your timing code from the two functions gives 1.63772082329 1.82889485359 which is consistent with your expectation that the version that computes only a part of the image runs faster. But only marginally, which is again consistent with the fact that the number of operations is only marginally different. HTH, Daniel From bignose+hates-spam at benfinney.id.au Fri Apr 18 20:53:15 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Sat, 19 Apr 2008 10:53:15 +1000 Subject: How to print a unicode string? References: <87d4omsovf.fsf@benfinney.id.au> <4edea21e-d45c-4467-a66d-e270365eb812@l64g2000hse.googlegroups.com> Message-ID: <878wzasm10.fsf@benfinney.id.au> damonwischik at gmail.com writes: > On Apr 19, 12:51 am, Ben Finney wrote: > > Just because the locale library knows the normalised name for it > > doesn't mean it's available on your OS. Have you confirmed that > > your OS (independent of Python) supports the locale you're trying > > to set? > > No. How do I found out which locales my OS supports? (I'm running > Windows XP.) Can't help you there. > Why does it matter what locales my OS supports, when all I want is > to set the encoding to be used for the output Because the Python 'locale' module is all about using the OS's (actually, the underlying C library's) locale support. The locale you request with 'locale.setlocale' needs to be supported by the locale database, which is independent of any specific application, be it Python, Emacs, or otherwise. -- \ "Two rules to success in life: 1. Don't tell people everything | `\ you know." -- Sassan Tat | _o__) | Ben Finney From deets at nospam.web.de Sun Apr 6 17:17:05 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Sun, 06 Apr 2008 23:17:05 +0200 Subject: How to create an exe-file? In-Reply-To: <8da70474-6ade-4515-8346-8f02a04ff24e@b9g2000prh.googlegroups.com> References: <311a216f-5366-47c5-86a7-431dd23ced3e@j1g2000prb.googlegroups.com> <8da70474-6ade-4515-8346-8f02a04ff24e@b9g2000prh.googlegroups.com> Message-ID: <65ssuoF2h8gpeU1@mid.uni-berlin.de> skanemupp at yahoo.se schrieb: > On 6 Apr, 22:50, Fredrik Lundh wrote: >> skanem... at yahoo.se wrote: >>> how do you create exe-files of your python-code? >>> is it different depending on what libraries, GUI-frameworks you use? >>> i want to create an exe-file of a pythonscript that uses Tkinter. >> assuming windows only, you want: >> >> http://www.py2exe.org/ >> >> also see: >> >> http://effbot.org/zone/python-compile.htm >> >> > > > ty. > > a good thing about python is the portability though. but u cant make > an exe that can be used on mac too, ie one exe fpr both? No. But you can use the same python-sources, without any or only a few platform specific changes. > if i want to make an exe for mac, what do i need? google py2app. Diez From toddw at activestate.com Thu Apr 17 15:28:23 2008 From: toddw at activestate.com (Todd Whiteman) Date: Thu, 17 Apr 2008 12:28:23 -0700 Subject: Python plugin for Firefox In-Reply-To: References: Message-ID: <4807A4D7.8090305@activestate.com> zelegolas wrote: > Hi, > > It's may be a stupid question but do you if someone tried to create a > python plugin for firefox? > If you know an Open Source project let me know... > > Thanks This was asked just recently on the list (included responses below): Joe P. Cool wrote: > > In 2005 I heard of plans to add Python as a second language to the > > Gecko engine. Is this still true? Or has this plan been abandoned? > > You can use Python inside of Mozilla (Gecko) based applications now, such as Firefox/Thunderbird/Komodo Edit/XulRunner which communicate through the Mozilla XPCOM architecture. There are builds of PyXPCOM (Python XPCOM) that can be downloaded and easily installed through the xpi extension mechanism, see: http://pyxpcomext.mozdev.org/ The Mozilla 1.9 branch (Gecko 1.9) also contains the hooks necessary to be able to use Python as a script handler, instead of having to use JavaScript. This is commonly referred to as PyDOM. To get and use PyXPCOM (Mozilla 1.8 and Mozilla 1.9): * install the above extension * or make your own build of the Mozilla application To get and use PyDOM (Mozilla 1.9): * you'll need to make your own build of the Mozilla application I'm the one working on the PyXPCOM extension, which I am hoping will eventually contain the PyDOM module as well (once I get around to making new Mozilla builds with this enabled). Cheers, Todd From steve.j.donovan at gmail.com Mon Apr 14 09:01:24 2008 From: steve.j.donovan at gmail.com (SteveD) Date: Mon, 14 Apr 2008 06:01:24 -0700 (PDT) Subject: pgdb: Debugging Python extensions made easier Message-ID: Hi guys, http://luaforge.net/frs/?group_id=327 pgdb.zip is an addition to scite-debug, which adds source debugging to the popular SciTE programmer's editor. gdbpy.zip is a standalone version which can be run from Emacs. These allow you to single-step from Python to C code in a debugger session. To use pgdb, install scite-debug (either on top of an existing SciTE installation or with one of the packaged all-in-one versions) and unzip into the same directory. gdbpy requires Lua 5.1, but there are no other dependencies. In both cases, read the release notes. I know the FAQ says that this is not possible, but the FAQ is somewhat outdated. GDB is quite happy with pending breakpoints to unresolved libraries, but you have to reassure it. This technique is a generalization of one that I used to solve the equivalent problem with debugging Lua extensions. steve d. From spocksplanet at gmail.com Thu Apr 17 04:30:50 2008 From: spocksplanet at gmail.com (sp@k) Date: Thu, 17 Apr 2008 01:30:50 -0700 (PDT) Subject: Newbie question about for...in range() structure Message-ID: Hi there, I'm new to Python and I've been writing a rudimentary exercise in Deitel's Python: How to Program, and I found that this code exhibits a weird behavior. When I run the script, the for...range(1,11) structure always starts with zero--and I've tried plugging other values as well! >From the Python commandline, though, this structure produces a normal 1,2,3,4,5,6,7,8,9,10 output. Can anyone tell me what I am doing wrong here? input = raw_input("Please enter a value you wish to factorialize:") def fact(n): total = 0 n = int(n) while n > 0: total *= n n -=1 return total print "%d" % fact(input) e = 1 for val in range(1,11): if val == 0: continue else: e += 1/fact(val) print "Where n is 10, e = %d\n\n" % e e2 = 1 input = raw_input("Enter x:") for val in range(1,11): if val == 0: continue else: e2 += (float(input) ** val)/(fact(val)) print "Where the n is 10, e**x = %d\n\n" %e From victorsmiller at gmail.com Sun Apr 13 23:50:07 2008 From: victorsmiller at gmail.com (VictorMiller) Date: Sun, 13 Apr 2008 20:50:07 -0700 (PDT) Subject: urllib working differently when run from crontab Message-ID: I've written a python script which, using urllib, and urllib2 will fetch a number of files that that I'm interested in from various websites (they're updated everyday). When I run the script from my command line everything works as intended. However, when the script is run from crontab every single url that I attempt to open gets "connection refused". Has anyone ever seen anything like this? If so, what's causing it, and what can I do about it? Victor From skanemupp at yahoo.se Sat Apr 5 18:19:59 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 15:19:59 -0700 (PDT) Subject: Best way to check if string is an integer? Message-ID: which is the best way to check if a string is an number or a char? could the 2nd example be very expensive timewise if i have to check a lot of strings? this value = raw_input() try: value = int(value) except ValueError: print "value is not an integer" or: c=raw_input("yo: ") if c in '0123456789': print "integer" else: print "char" or some other way? From upton at virginia.edu Tue Apr 1 14:00:19 2008 From: upton at virginia.edu (Dan Upton) Date: Tue, 1 Apr 2008 14:00:19 -0400 Subject: Homework help In-Reply-To: <65fagoF2fiivoU1@mid.uni-berlin.de> References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> <65fagoF2fiivoU1@mid.uni-berlin.de> Message-ID: <5504f9ac0804011100t38c5237bm5e68449b9b6a92ce@mail.gmail.com> > > Write a function zip(lst1, lst2) such that zip accepts two equal > > length lists and returns a list of pairs. For example, zip(['a', 'b', > > 'c'], [10, 20, 30]) should evaluate to the list [('a', 10), ('b', 20), > > ('c', 30)]. > > Hey not even a rebinding necessary. :-) > We had some exercises like this in Scheme in my undergrad programming languages class (specifically, rewriting map/mapcar). It's not that the method doesn't already exist in the language, it's more about understanding what's going on at a lower level. From gagsl-py2 at yahoo.com.ar Sat Apr 5 16:04:41 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 05 Apr 2008 17:04:41 -0300 Subject: Adding Images To MySQL References: <4dc0cfea0804050732x7dc2ac41n64d56dda9da27a82@mail.gmail.com> Message-ID: En Sat, 05 Apr 2008 11:32:00 -0300, Victor Subervi escribi?: >> * *- You say Content-Type: image/jpeg but you emit HTML code. You're >> lucky > if you see any > >> * *text at all. > > Well, I tried Content-Type: text/html and that threw an HTTP 500 Error. If your script raised any exception, that's the expected code. (500 = internal error = your code has errors). But it's not very useful for debugging; using cgitb or wrapping the code in try/except as has already been suggested, lets you see the exception and traceback. >> * *- HTTP 200 is not an error, it means the request was successful. > > When it doesn?t execute the code, how can it be called successful? If it > doesn?t execute the code, how can you say it?s not an error? What is it, > then? Well, your web server thinks all went ok... BTW, you did't provide details about it, I *guess* you're using CGI because of the print "Content-Type" line. >> * *- As a general advice, try to isolate the problems. Test the database > stuff alone, in a local >> * *application. Test the cgi script alone, without database interaction. > Test the database stuff in >> * *the web server (better if you have a shell account). Merge all and >> test > again. > > Very good advice. Please help me understand how to do that. > > This is what I have done. I have tried these: > > sql = "'insert into products (" + col_names + ") values (" + val + ")', > (" + > col_names + ")" > > cursor.execute(sql) > > and > > sql = "'insert into products (" + col_names + ") values (" + val + ")'" > > cursor.execute(sql, (col_names,)) > > Neither work. You got a syntax error, I guess. What's that ' at the start? I'll try to explain it from the ground up. This would be a valid SQL statement:: insert into PRODUCTS (PRODID, NAME, DESCRIPTION) values (123, 'Easter egg 80g', 'A longer description'); In Python, you need the SQL text inside a string:: sql = "insert into PRODUCTS (PRODID, NAME, DESCRIPTION) " \ "values (123, 'Easter egg 80g', 'A longer description');" and you can execute it with:: cursor.execute(sql) That would be OK when you create the database for the first time. Later your boss comes in and says: "We've got bigger eggs! Code 124, 150g each. We need them in the database". You write an sql statement similar to above. Some days later, they decide to sell bubble gum. Forty-two different sizes and flavors and brands. You don't want to write all that sql statements by hand. Your first thought is to build the sql text by pieces:: sql = "insert into PRODUCTS (PRODID, NAME, DESCRIPTION) " \ "values ("+str(prodid)+", '"+prodname+"', '"+description+"');" But then you remember to have read something about sql injection and you don't like that mess of " + ) ' ( anyway. After reading some articles about DBAPI 2, PEP 249, the MySQLdb module, you write this:: sql = "insert into PRODUCTS (PRODID, NAME, DESCRIPTION) " \ "values (%s,%s,%s);" cursor.execute(sql, (prodid, prodname, description)) and it works fine. Note that execute has two arguments: first, a string with the sql statement text; second, a tuple containing the values. The %s in the sql text are placeholders, they're replaced with the corresponding value from the second argument. And there is no ' anywhere. > However, if I print what that code spits out: > > sql = "'insert into products (" + col_names + ") values (" + val + ")', > (" + > col_names + ")" > > print sql > > then copy and paste it into a cursor.execute() statement, viola! > Everything > works _just_fine_. Go figure. Why?? What you have done has no sense - why do you think it should work? py> a = "2 " + ", " + "3" py> pow(a) Traceback (most recent call last): File "", line 1, in TypeError: pow expected at least 2 arguments, got 1 py> print a 2 , 3 py> pow(2 , 3) 8 Your first attempt used a long string with embedded quotes, it is a *single* argument to execute. If you print it and interpret the result as Python code, there are two items: now you are passing *two* arguments to execute. > pic1 = _mysql.escape_string(f) > > It does not like this (forgot error): > > pic1 = MySQLdb.Binary(f) You should make the above work. Look at the exception, read the error message, look at the traceback. There are a lot of info there. > Escaping the string, I can successfully load this image into the > database, > along with all the other fields. Now, when I load an image from the form > on > the previous page with this code: > > > print '"', MySQLdb.Binary(data[14]), '"' > > and send the form off to the next page, when I process it on that page Why do you do *that*??? That element is for the user to upload a file; if the file is already on the server, why do you transfer it from server to client and back to server? I doubt it can work this way. And why are you using Binary here? Binary is for sql stuff and you're building an HTML page here. (btw, didn't you say that Binary doesn't work?). > pic1 = _mysql.escape_string(pic1) > > print pic1 > > it prints out a messy binary that (almost) starts with something like > ?This > program can only be run in Win32?, whatever that means. But a binary is > printed. (It may be an infinite binary, I stopped it after a few > minutes.) Looks like a .exe; somehow you managed to upload a .exe instead of a jpg, I presume... > Now, if I stick it into the cursor.execute like I did above, it throws an > HTTP non-error non-posting-to-the-database 200 error. I?m more than > happy to > separate all this garbage out for further testing, but I don?t know how > to > do that. Your help is very much appreciated. It seems you have a basic misunderstanding of how web applications work. Reading a book like "Python Web Programming" by Steve Holden might help. http://www.amazon.com/Python-Programming-Landmark-Steve-Holden/dp/0735710902 -- Gabriel Genellina From bruno.desthuilliers at gmail.com Sat Apr 19 14:33:41 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Sat, 19 Apr 2008 11:33:41 -0700 (PDT) Subject: why function got dictionary References: <48075950.7050000@gmail.com> Message-ID: On 19 avr, 19:39, sturlamolden wrote: > On Apr 17, 4:06 pm, AlFire wrote: > > > Q: why function got dictionary? What it is used for? > > As previously mentioned, a function has a __dict__ like (most) other > objects. > > You can e.g. use it to create static variables: > > int foobar() > { > static int i = 0; > return i++; > > } > > is roughly equivalent to: > > def foobar(): > foobar.i += 1 > return foobar.i > foobar.i = 0 barfoo = foobar foobar = lambda x : x And boom. 'static' variables are better implemented using either closures, mutable default arguments or custom callable types. From jeff.self at gmail.com Wed Apr 9 19:39:23 2008 From: jeff.self at gmail.com (jeffself) Date: Wed, 9 Apr 2008 16:39:23 -0700 (PDT) Subject: How can I use quotes without escaping them using CSV? References: Message-ID: <35a28105-1178-4784-8247-d483e55694c7@f63g2000hsf.googlegroups.com> On Apr 9, 5:39 pm, "Reedick, Andrew" wrote: > > -----Original Message----- > > From: python-list-bounces+jr9445=att.... at python.org [mailto:python- > > list-bounces+jr9445=att.... at python.org] On Behalf Of jeffself > > Sent: Wednesday, April 09, 2008 5:11 PM > > To: python-l... at python.org > > Subject: How can I use quotes without escaping them using CSV? > > > If I put an escape character in, it works. For example, if I use ~ as > > my escape character, my output looks like this: > > 0001[tab]Michael L. ~"Mick~" Jones[tab]189 > > > I don't want that. If I don't include an escape character, it doesn't > > work. > > > Here's my code: > > import sys > > import csv > > from readexcel import * > > > f = open("results.txt", 'wb') > > book = sys.argv[1] > > sheet = sys.argv[2] > > > xl = readexcel(book) > > sheetnames = xl.worksheets() > > > for s in sheetnames: > > if s == sheet: > > writer = csv.writer(f, delimiter='\t', quoting=csv.QUOTE_NONE) > > for row in xl.getiter(s): > > writer.writerow((row['Precinct'],row['Candidate'],unicode(int(row['Vote > > > s'])))) > > f.close() > > The documentation is pretty, uhm, obtuse, but you also need to set > quotechar. > > import sys > import csv > > names = ['Michael L. "Mick" Jones', 'Vickie A. Meyers', 'John "Jack" > Smith'] > > writer = csv.writer(sys.stdout, delimiter='\t', quotechar='', > quoting=csv.QUOTE_NONE) > for i in names: > writer.writerow(['a', i, 'b']) > > output: > a Michael L. "Mick" Jones b > a Vickie A. Meyers b > a John "Jack" Smith b > > ***** > > The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA621 I set quotechar="" and was able to get it to work. I'll try this at work tomorrow! From steve at holdenweb.com Wed Apr 23 11:28:04 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 11:28:04 -0400 Subject: Error Message In-Reply-To: <14A2A120D369B6469BB154B2D2DC34D20AD1195E@EXCHVS01.ad.sfwmd.gov> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com><27CC3060AF71DA40A5DC85F7D5B70F38033A4F2D@AWMAIL04.belcan.com> <480F483B.9050507@holdenweb.com> <14A2A120D369B6469BB154B2D2DC34D20AD1195E@EXCHVS01.ad.sfwmd.gov> Message-ID: Ahmed, Shakir wrote: > I am getting application error message ? The instruction at ?0x7c910f29? > referenced memory at ?0xffffffff?. The memory could not be ?read?. I am > running one python script and it is running good without any exception > or error message but getting this message when I am closing python 2.4.1 > application. > > > > Any idea or help is highly appreciated. > The error is at line 317 of your script. [Translation: we cannot know what is wrong with a program we have never seen]. Are you using the ctypes library, or some other extension module? It may be that in invalid pointer is causing problems for the garbage collector during shutdown, for example. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From mishok13 at gmail.com Mon Apr 7 09:19:49 2008 From: mishok13 at gmail.com (Andrii V. Mishkovskyi) Date: Mon, 7 Apr 2008 16:19:49 +0300 Subject: @x.setter property implementation In-Reply-To: References: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> Message-ID: <192840a00804070619h6621cbc7k8cd790ccffe4bd47@mail.gmail.com> 2008/4/7, Floris Bruynooghe : > > Have been grepping all over the place and failed to find it. I found > the test module for them, but that doesn't get me very far... > I think you should take a look at 'descrobject.c' file in 'Objects' directory. -- Wbr, Andrii Mishkovskyi. He's got a heart of a little child, and he keeps it in a jar on his desk. From bruno.desthuilliers at gmail.com Wed Apr 2 15:52:47 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 12:52:47 -0700 (PDT) Subject: function call - default value & collecting arguments References: <_LQIj.9776$HS3.482805@news.siol.net> Message-ID: <7e50544d-6daf-48c2-bb82-be06d3590450@8g2000hsu.googlegroups.com> On 2 avr, 21:03, "Primoz Skale" wrote: > Hello! > > I am fairly new to Python, so I apologise if this is a 'newbie' question. > > First define a simple function: > > def f(a=0): > print a > > >> f(1) > 1 > >>f() > > 0 > > Argument a in function f() is set at default value of 0, if it is not passed > to the function at the function call. I get this! :) > > I also understand (fairly) how to collect arguments. For example, let's > define another function: > > def f(*a): > print a This means that f takes any number of optional positional arguments. If nothing is passed, within f, 'a' will be an empty tuple. Note that this is *not* the usual way to define a function taking multiple (mandatory) arguments. > >>f(1) > (1,) > >>f(1,2) > (1,2) > >>f() > > () > > OK, everything allright till so fair. But! :) Now define third function as: > > def f(*a): > print a[0] > > In this case, function only prints first argument in the tuple: *If* there's one. > >>f(1,2,3) > 1 > >>f(3) > 3 > >>f() #no arguments passed IndexError ? > Traceback (most recent call last): > File "", line 1, in > f() #no arguments passed > File "", line 2, in f > print a[0] > IndexError: tuple index out of range Bingo. > Then I tried to define the function as: > > def f(*a=(0,)): SyntaxError ? > print a[0] #this should come next, but we get error msg instead, saying > > SyntaxError: invalid syntax Bingo. > but it does not work this way. Now my 'newbie' question: Why not? :) Condescending answer : "because" !-) (Sorry, couldn't resist.) More seriously, I can't tell you why this is not allowed, but : > I wanted to write function in this way, because then we can call function > without any arguments, and it would still print 0 (in this case). def f(*a): try: print a[0] except IndexError: print 0 or def f(*a): if not a: a = (0,) print a[0] or (slightly more involved, and certainly overkill): def with_default_args(default): def decorator(func): def wrapper(*args): if not args: args = default return func(*args) return wrapper return decorator @with_default_args((0,)) def f(*a): print a[0] HTH From ybc2084 at gmail.com Thu Apr 10 04:42:53 2008 From: ybc2084 at gmail.com (rockins) Date: Thu, 10 Apr 2008 01:42:53 -0700 (PDT) Subject: what's the reasonale of loghelper() in mathmodule.c References: <49750e9d-1a63-42d2-b292-38d225b0c3c8@n1g2000prb.googlegroups.com> <28321dcf-71d2-4c67-bd1d-1e187015129d@u3g2000hsc.googlegroups.com> Message-ID: <03fb9a52-21de-4478-bcdc-80f6fc6f9409@s13g2000prd.googlegroups.com> On Apr 9, 9:11 pm, Mark Dickinson wrote: > On Apr 9, 4:38 am,rockins wrote: > > > I cannot understand it well, can anyone explain me why and how > > loghelper() can compute any base logarithm? Or could anyone give me > > some reference(such as, books or papers)? > > loghelper is there so that log(n) can be computed for any positive > integer n---it's nothing to do with computing logs to an arbitrary > base. > > All of the other math functions convert an integer argument to a float > first. That conversion fails if the integer is larger than the > largest > representable float (around 1.7e308 on most systems). For example: > > >>> from math import sqrt, log > >>> sqrt(10**600) > > Traceback (most recent call last): > File "", line 1, in > OverflowError: long int too large to convert to float>>> log(10**600) > > 1381.5510557964274 > > The sqrt call first tries to convert 10**600 to a float, giving an > OverflowError (even though the actual square root *is* representable > as a float). The log call goes through loghelper instead, which > doesn't try to convert 10**600 to a float, but instead computes > the log based on the top few bits of 10**600 (in its internal > binary representation) and on the number of bits required to > represent 10**600. > > You're not going to learn much about math function implementations > from mathmodule.c: all it does it wrap the platform libm functions. > > Mark Thanks Marks, your explanation is very clear. Yes, I do not need to learn much about the math functions' implementation of libm, I just need to know why there exists loghelper() in mathmodule.c; I have checked Python's longobject.c, I think I have understood why loghelper() is needed now. Since Python can represent arbitrary precision long integer object, so for logarithm it indeed need to deal with very huge number. Doesn't it? If there's any misunderstanding of mine, please point out. Thank you very much. -rockins From gherron at islandtraining.com Thu Apr 17 12:44:51 2008 From: gherron at islandtraining.com (Gary Herron) Date: Thu, 17 Apr 2008 09:44:51 -0700 Subject: Can't do a multiline assignment! In-Reply-To: References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> Message-ID: <48077E83.5050404@islandtraining.com> s0suk3 at gmail.com wrote: > On Apr 17, 10:54 am, colas.fran... at gmail.com wrote: > >> On 17 avr, 17:40, s0s... at gmail.com wrote: >> >> Out of sheer curiosity, why do you need thirty (hand-specified and >> dutifully commented) names to the same constant object if you know >> there will always be only one object? >> > > I'm building a web server. The many variables are names of header > fields. One part of the code looks like this (or at least I'd like it > to): > > class RequestHeadersManager: > > # General header fields > Cache_Control = \ > Connection = \ > Date = \ > Pragma = \ > Trailer = \ > Transfer_Encoding = \ > Upgrade = \ > Via = \ > Warning = \ > > # Request header fields > Accept = \ > Accept_Charset = \ > Accept_Encoding = \ > Accept_Language = \ > Authorization = \ > ... > But. *What's the point* of doing it this way. I see 14 variables being assigned a value, but I don't see the value, they are getting. Reading this bit if code provides no useful information unless I'm willing to scan down the file until I find the end of this mess. And in that scanning I have to make sure I don't miss the one single line that does not end in a backslash. (Your ellipsis conveniently left out the *one* important line needed to understand what this code is doing, but even if you had included it, I'd have to scan *all* lines to understand what a single value is being assigned. There is *no way* you can argue that code is clearer than this: # General header fields Cache_Control = None Connection = None Date = None Pragma = None ... Gary Herron > Etc etc etc. At the end they'll all be assign to None. Then, when > initialized, __init__() will the the string of headers, parse them, > and use those variables shown above to assign to the header values. Of > course a normal request won't include all of those headers, so the > others will remain None. That's what I want. > From deets at nospam.web.de Tue Apr 22 07:30:36 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 13:30:36 +0200 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> Message-ID: <6760jfF2n3bn1U1@mid.uni-berlin.de> GD schrieb: > Please remove ability to multiple inheritance in Python 3000. > > Multiple inheritance is bad for design, rarely used and contains many > problems for usual users. > > Every program can be designed only with single inheritance. Yes, sure. And that's why Java grew interfaces & it's class-diagrams are hilariously complex. Because using single inheritance is so much better. Diez From nick at craig-wood.com Thu Apr 17 12:30:04 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Thu, 17 Apr 2008 11:30:04 -0500 Subject: is file open in system ? - other than lsof References: <66p6o2F2korm2U1@mid.individual.net> Message-ID: Thomas Guettler wrote: > bvidinli schrieb: > > is there a way to find out if file open in system ? - > > please write if you know a way other than lsof. because lsof if slow for me. > > i need a faster way. > > i deal with thousands of files... so, i need a faster / python way for this. > > thanks. > > On Linux there are symlinks from /proc/PID/fd to the open > files. You could use this: > > #!/usr/bin/env python > import os > pids=os.listdir('/proc') > for pid in sorted(pids): > try: > int(pid) > except ValueError: > continue > fd_dir=os.path.join('/proc', pid, 'fd') > for file in os.listdir(fd_dir): > try: > link=os.readlink(os.path.join(fd_dir, file)) > except OSError: > continue > print pid, link Unfortunately I think that is pretty much exactly what lsof does so is unlikely to be any faster! However if you have 1000s of files to check you only need to do the above scan once and build a dict with all open files in whereas lsof will do it once per call so that may be a useful speedup. Eg ------------------------------------------------------------ import os pids=os.listdir('/proc') open_files = {} for pid in sorted(pids): try: int(pid) except ValueError: continue fd_dir=os.path.join('/proc', pid, 'fd') try: fds = os.listdir(fd_dir) except OSError: continue for file in fds: try: link=os.readlink(os.path.join(fd_dir, file)) except OSError: continue if not os.path.exists(link): continue open_files.setdefault(link, []).append(pid) for link in sorted(open_files.keys()): print "%s : %s" % (link, ", ".join(map(str, open_files[link]))) ------------------------------------------------------------ You might want to consider http://pyinotify.sourceforge.net/ depending on exactly what you are doing... -- Nick Craig-Wood -- http://www.craig-wood.com/nick From kkuhl05 at gmail.com Tue Apr 29 01:46:25 2008 From: kkuhl05 at gmail.com (Kevin K) Date: Mon, 28 Apr 2008 22:46:25 -0700 (PDT) Subject: File IO Issues, help :( References: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> Message-ID: On Apr 29, 12:38 am, "Eric Wertman" wrote: > chuck in a jsfile.close(). The buffer isn't flushing with what you > are doing now. jsfile.flush() might work... not sure. Closing and > re-opening the file for sure will help though. > Yeah sorry I forgot to include the close() in the quote but its there. In fact I moved it up a bit and still no luck heres the new code: jsfile = open("../timeline.js", "r+") jscontent = jsfile.readlines() jsfile.truncate() for line in jscontent: if re.search('var d =', line): line = "var d = \""+mint['1'].ascdate()+"\"\n" print line jsfile.write(line) jsfile.close() I tried this can got the same result...?? From m.zaki.mirza at gmail.com Mon Apr 14 03:49:13 2008 From: m.zaki.mirza at gmail.com (xakee) Date: Mon, 14 Apr 2008 00:49:13 -0700 (PDT) Subject: Java or C++? References: Message-ID: <41b4eea8-8e53-413b-b860-789fc062638c@u69g2000hse.googlegroups.com> On Apr 14, 11:44?am, s0s... at gmail.com wrote: > Hello, I was hoping to get some opinions on a subject. I've been > programming Python for almost two years now. Recently I learned Perl, > but frankly I'm not very comfortable with it. Now I want to move on > two either Java or C++, but I'm not sure which. Which one do you think > is a softer transition for a Python programmer? Which one do you think > will educate me the best? Well if you need an easier transition, go for java. But personally i would recommend you to go for C/C++. There are a few very solid reasons for that. 1. You can still use ur python konwledge, integrate python with you applications, extend python with C/C++ .. and so on. That would not only benefit you but the whole community. 2. C/C++ is likely to teach you more things in this transition than java will. You probably know all the good software engineering stuff and things like that maybe, (which you can still use in python) but going to C/C++ you can actually delve into systems programming and things like that. When you do that, again, you can extend python and contribute to the community. 3. When you get hold of c/c++, there will be lesser friction in you forever to transition to any other language. I appriciate that you chose python in the first place since that is what i advocate as well ... the way i see programming should be taught or taken up is like : bash/shell scripting -> python/perl -> c/c++ -> assembly .... (from there on, given you give enough time to the end parts, you should not have any difficulty going to C#/Java/VB/Delphi or whatever for some nice RAD or even production level performance not-so-critical applications). So if you're intrested in system programming getting to know how things get done, have a SOLID computing background and give python what python gave you, go for C/C++. From gagsl-py2 at yahoo.com.ar Wed Apr 16 14:54:21 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 15:54:21 -0300 Subject: Interesting timing issue I noticed References: Message-ID: En Wed, 16 Apr 2008 10:36:14 -0300, Jonathan Shao escribi?: > *Gabriel Genellina* gagsl-py2 at yahoo.com.ar > > *Wed Apr 16 08:44:10 CEST 2008* >> Another thing would be to rearrange the loops so the outer one executes > less times; if you know that borderX< better to swap the inner and outer loops above. > Thank you for the tip on xrange. > Even if I swap the inner and outer loops, I would still be doing the same > number of computations, am I right (since I still need to go through the > same number of elements)? I'm not seeing how a loop swap would lead to > fewer > computations, since I still need to calculate the outer rim of elements > in > the array (defined by borderX and borderY). You minimize the number of "for" statements executed, and the number of xrange objects created. Both take some time in Python. import timeit f1 = """ for i in xrange(10): for j in xrange(1000): i,j """ f2 = """ for j in xrange(1000): for i in xrange(10): i,j """ print timeit.Timer(f1).repeat(number=1000) print timeit.Timer(f2).repeat(number=1000) Output: [2.0405478908632233, 2.041863979919242, 2.0397852240997167] [2.8623411634718821, 2.8330055914927783, 2.8361752680857535] The second (using the largest outer loop) is almost 40% slower than the first one. "Simplified" Big-Oh complexity analysis isn't enough in cases like this. -- Gabriel Genellina From steve at holdenweb.com Wed Apr 23 08:01:25 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 08:01:25 -0400 Subject: Explicit variable declaration In-Reply-To: <1be78d220804230252n4faa34e6v90b482080750e0cb@mail.gmail.com> References: <1506f165-7f86-4dc7-aa29-6488eda9ae7f@l64g2000hse.googlegroups.com> <1be78d220804230252n4faa34e6v90b482080750e0cb@mail.gmail.com> Message-ID: Filip Gruszczy?ski wrote: >> You mean the type? Not in 2.x, but in 3.x, there are function >> annotations: >> >> def a_function(arg1: int, arg2: str) -> None: pass > > Nope, I don't like types ;-) 3.x seems pretty revolutionary, and this > typing can be appreciated by some people. > >> Declaring what about them? If you mean declaring the type, remember >> that Python deliberately allows any name to be bound to any object; >> type declarations can't be enforced without losing a lot of the power >> of Python. > > Just declaring, that they exist. Saying, that in certain function > there would appear only specified variables. Like in smalltalk, if I > remember correctly. > Icon has (had?) the same feature: if the "local" statement appeared then the names listed in it could be assigned in the local namespace, and assignment to other names wasn't allowed. A lot of people assume that's what the __slots__ feature of the new object model is for, but it isn't: it's actually a memory conservation device for circumstances when millions of objects must be created in an application. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From nospam1.reifenberg at gmx.de Sat Apr 5 03:36:48 2008 From: nospam1.reifenberg at gmx.de (Nebur) Date: Sat, 5 Apr 2008 00:36:48 -0700 (PDT) Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? References: <0c8bfed7-1154-41d5-a740-6d1382180db2@d45g2000hsc.googlegroups.com> Message-ID: <53f83c02-817b-490d-86ba-b600d453d183@m3g2000hsc.googlegroups.com> > So, just wanted to point out that eclipse saves your file history > (even if you do not have a vcs)... that operation can be selected by > right clicking a parent folder and selecting 'restore from local > history'. Fabio, you are right; this feature should help to compensate ... but in my case, the Eclipse said "No deleted ressources in local history for selected container". I'm not familiar with the Local-History feature (since using a vcs), so it may be misconfigured. (The setting in Preferences/Workspace/ LocalHistore are at default: 7 days to keep files, 50 maximum entries per file, max.file size 1MB - which should be enough. ). Hm. Anyway, I don't see any idea how to track down what happened. So lets close the thread and simply continue working. * This is a good occasion to state that Pydev/Eclipse still is a very efficient IDE in my opinion, and (aside from this mystery here) it is perfectly stable for >>1 year now! This must be said, to correct any potential misimpression. Ciao, Nebur From jarausch at skynet.be Wed Apr 23 11:15:44 2008 From: jarausch at skynet.be (Helmut Jarausch) Date: Wed, 23 Apr 2008 17:15:44 +0200 Subject: Unix Device File Emulation In-Reply-To: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> Message-ID: <480f52a0$0$2951$ba620e4c@news.skynet.be> blaine wrote: > Hey everyone, > So I've got a quick query for advice. > > We have an embedded device in which we are displaying to an LCD > device that sits at /dev/screen. This device is not readily available > all the time, so I am needing to write an emulator. This will > basically just monitor a file, /dev/screen for example, and write the > commands to a TK or WxWindows canvas. > > So sending 'line 0 0 10 10' will draw a line on my canvas from (0,0) > to (10,10). > > My question: Whats the best way to set up a monitor (in python) of > this file? Would I simply open up the file for read, check for > changes, get any updated data, and clear the file? Or is there some > standard way of doing something like this that guarantees no overlap > or data loss? > > example usage: echo 'line 0 0 10 10' > /dev/screen > > On the actual embedded device this is handled by a kernel module. We > can spit commands into it as fast as we can and the kernel module can > keep up. This is typical unix device file behavior. > > Any suggestions or advice would be splendid. Thanks! > Blaine It looks as if you need something like the Unix 'tail -f' command. Perhaps here is some help http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/414771 http://mail.python.org/pipermail/python-list/2002-August/157510.html http://pyinotify.sourceforge.net/ -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany From bruno.desthuilliers at gmail.com Wed Apr 2 19:00:54 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 16:00:54 -0700 (PDT) Subject: Nested try...except References: <0a34849f-bcda-419b-a10f-772d76172d1f@b5g2000pri.googlegroups.com> <43d60d13-b420-414d-81c8-b8430af2aa5f@i36g2000prf.googlegroups.com> <7d992474-f90b-4c8f-b359-a1857f570c92@8g2000hse.googlegroups.com> Message-ID: On 2 avr, 18:25, Nanjundi wrote: > On Apr 2, 9:22 am, Magnus.Morab... at gmail.com wrote: > > > > > On 2 Apr, 15:15, Magnus.Morab... at gmail.com wrote: > > > > On 2 Apr, 15:12, cokofree... at gmail.com wrote: > > > > > On Apr 2, 3:06 pm, Magnus.Morab... at gmail.com wrote: > > > > > > Hi, > > > > > > I found the following code on the net - > > > > > > http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/%3C20050924104732.5116.qm... at minotaur.apache.org%3E > > > > > > def count(self): > > > > > - db = sqlite.connect(self.filename, > > > > > isolation_level=ISOLATION_LEVEL) > > > > > - try: > > > > > - try: > > > > > - cur = db.cursor() > > > > > - cur.execute("select count(*) from sessions") > > > > > - return cur.fetchone()[0] > > > > > - finally: > > > > > - cur.close() > > > > > - finally: > > > > > - db.close() > > > > > > I don't understand though why the second try is not after the line cur > > > > > = db.cursor(). Can anyone explain for me why? > > > > > > /Barry. > > > > > Better question is why is there a try with no except... > > > > > Better yet, WHY is there two TRY statements when there could quite > > > > happily be only one... > > > > > Towards what you are asking, I GUESS...because the author hoped to > > > > handle the cases where cur failed to get assigned...but then > > > > his .close method of it would likely not work anyway...I mean...does > > > > this even work...YUCK > > > > I shouldn't have written "Nested try...except" as the title, instead I > > > mean "Nested try...finally". Sorry about that... > > > > Anyway, how would you do this? That is, use a finally to close the > > > network connection and the cursor? > > > > Thanks for your help, > > > > Barry > > > Here's what I would do. Is it OK? > > > def ExecuteWithNoFetching(self, queryString): > > > sqlServerConnection = adodbapi.connect (";".join (connectors)) > > try: > > cursor = sqlServerConnection.cursor() > > try: > > cursor.execute(queryString) > > raise Exception("Exception") > > sqlServerConnection.commit() > > finally: > > cursor.close() > > finally: > > sqlServerConnection.close() > > No.. Why do you have raise statement? > "sqlServerConnection.commit()" never gets executed. It's demonstration code. > -N From gagsl-py2 at yahoo.com.ar Fri Apr 4 02:17:34 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 04 Apr 2008 03:17:34 -0300 Subject: Figuring out what class instance contains you References: Message-ID: En Fri, 04 Apr 2008 00:41:19 -0300, Alex VanderWoude escribi?: > Consider the following module: > > ================================ > class NewDict(dict): > parent = None > > def __setitem__(self, key, value): > print "My parent is", self.parent > super(NewDict, self).__setitem__(key, value) > > class Zero(object): > children = NewDict() > > def __init__(self): > self.children.parent = self > > class One(Zero): > pass > > class Two(One): > pass > > a = One() > a.children["spam"] = "baked beans" > b = Two() > b.children["eggs"] = "bacon" > ================================ > > When the above module is executed, the output looks something like this: > > My parent is <__main__.One object at 0x00BA27B0> > My parent is <__main__.Two object at 0x00B9D170> > > ...which is great, just what I wanted. Each dictionary instance reports > correctly which object instance is its container. But only if you create a single instance of each class, because "children" is a class attribute (behaves as it were shared among all instances). Then you need an instance attribute, initialized in __init__. So why not set the parent at this time? py> class NewDict(dict): pass ... py> class Zero(object): ... def __init__(self): ... self.children = NewDict() ... self.children.parent = self ... py> class One(Zero): ... pass ... py> class Two(One): ... pass ... py> a = One() py> a.children["spam"] = "baked beans" py> b = Two() py> b.children["eggs"] = "bacon" py> c = Two() py> c.children["foo"] = "bar" py> print a.children.parent is a True py> print b.children.parent is b True py> print c.children.parent is c True > However, I would like to find some automagic way of having NewDict > figure out what object instance it is on without resorting to having the > container class instance poke a reference to itself into the NewDict > instance (i.e. the line in Zero.__init__()). Unless there are more contrains that you haven't told us, the above example looks as the simplest approach. -- Gabriel Genellina From billingspanshism at gmail.com Sat Apr 19 17:18:52 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:18:52 -0700 (PDT) Subject: david & victoria beckham Message-ID: <0742fdb0-b791-47d3-90c0-670610743b8e@m73g2000hsh.googlegroups.com> Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From spamgrinder.trylater at gmail.com Thu Apr 17 10:49:32 2008 From: spamgrinder.trylater at gmail.com (AlFire) Date: Thu, 17 Apr 2008 09:49:32 -0500 Subject: why function got dictionary In-Reply-To: <66p409F2lg89hU1@mid.uni-berlin.de> References: <48075950.7050000@gmail.com> <66p409F2lg89hU1@mid.uni-berlin.de> Message-ID: <4807637C.1050900@gmail.com> Diez B. Roggisch wrote: >> >> Q: why function got dictionary? What it is used for? > > because it is an object, and you can do e.g. > you mean an object in the following sense? >>> isinstance(g,object) True where could I read more about that? Andy From carlwuhwdmckay at gmail.com Mon Apr 21 02:08:51 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:08:51 -0700 (PDT) Subject: wheel of fortune crack Message-ID: wheel of fortune crack http://cracks.00bp.com F R E E C R A C K S From nick at craig-wood.com Tue Apr 29 05:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Tue, 29 Apr 2008 04:30:03 -0500 Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> <18c1e6480804270653r2e075061wf442b7b7d9f50ff6@mail.gmail.com> <9cca03a3-9b96-4bee-947b-baa62cd5f9a9@q24g2000prf.googlegroups.com> Message-ID: Terry wrote: > On Apr 28, 5:30 pm, Nick Craig-Wood wrote: > > David wrote: > > > Another idea would be to have multiple queues, one per thread or per > > > message type "group". The producer thread pushes into the appropriate > > > queues (through an intelligent PutMsg function), and the consumer > > > threads pull from the queues they're interested in and ignore the > > > others. > > > > Unfortunately a thread can only wait on one Queue at once (without > > polling). So really the only efficient solution is one Queue per > > thread. > > > > Make an intelligent PutMsg function which knows which Queue (or > > Queues) each message needs to be put in and all the threads will have > > to do is Queue.get() and be sure they've got a message they can deal > > with. > > I do have one Queue per thread. The problem is the thread can not peek > into the Queue and select msg with certain ID first. My point is don't put messages that the thread doesn't need in the queue in the first place. Ie move that logic into PutMsg. -- Nick Craig-Wood -- http://www.craig-wood.com/nick From Christna.Giri at gmail.com Fri Apr 4 14:50:56 2008 From: Christna.Giri at gmail.com (Student) Date: Fri, 4 Apr 2008 11:50:56 -0700 (PDT) Subject: Training course in Los Angeles? Message-ID: <11dbf7dd-ab12-43b6-9cdd-94a9a8fcc114@g1g2000pra.googlegroups.com> Is there a training course in advanced-level Python in the Los Angeles area? We are looking for web-development in particular. From futurescale at gmail.com Tue Apr 15 09:48:30 2008 From: futurescale at gmail.com (Cliff Hall) Date: Tue, 15 Apr 2008 06:48:30 -0700 (PDT) Subject: PureMVC Python / Google App Engine Demo - Blog Message-ID: <8e43fbbc-3cb0-44be-8862-a6d2f00dc9af@m44g2000hsc.googlegroups.com> PureMVC is an extremely lightweight MVC framework based upon proven design patterns. Originally written for ActionScript 3 (Flash, Flex, AIR) it has been ported to nearly all major languages and platforms. Here is a simple blog example using the PureMVC Framework for Python: http://trac.puremvc.org/Demo_Python_GoogleAppEngine_Blog -=Cliff> From kay.schluehr at gmx.net Sat Apr 5 17:27:25 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 5 Apr 2008 14:27:25 -0700 (PDT) Subject: Weird scope error References: <47F79A78.4010207@gmail.com> <47F7A41C.4090402@islandtraining.com> <47F7E325.9060603@gmail.com> Message-ID: <43917932-3381-4130-8aca-a2dd05a19ee2@t36g2000prm.googlegroups.com> On 5 Apr., 23:08, Michael Torrie wrote: > You need to either fix all these imports in these other modules (that > are probably in the site_packages folder), or modify the python import > path so that it can find ElementTree directly. I'd prefer to set an alias in the module cache: >>> import sys >>> import xml.etree >>> sys.modules["elementree"] = xml.etree >>> from elementree import ElementTree >>> From damonwischik at gmail.com Fri Apr 18 19:38:04 2008 From: damonwischik at gmail.com (damonwischik at gmail.com) Date: Fri, 18 Apr 2008 16:38:04 -0700 (PDT) Subject: How to print a unicode string? Message-ID: I'd like to print out a unicode string. I'm running Python inside Emacs, which understands utf-8, so I want to force Python to send utf-8 to sys.stdout. >From what I've googled, I think I need to set my locale. I don't understand how. import locale print locale.getlocale() --> (None,None) print locale.getdefaultlocal() --> ('en_GB','cp1252') print locale.normalize('en_GB.utf-8') --> en_GB.UTF8 locale.setlocale(locale.LC_ALL,'en_GB.UTF8') --> locale.Error: unsupported locale setting I'd be grateful for advice. Damon. From s0suk3 at gmail.com Wed Apr 16 12:26:03 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Wed, 16 Apr 2008 09:26:03 -0700 (PDT) Subject: Default parameter for a method... again Message-ID: <614159c3-1bb9-4026-b7f3-7817f69de505@t54g2000hsg.googlegroups.com> I had posted this before but all the spam whipped it out... I wanted to know if there's any way to create a method that takes a default parameter, and that parameter's default value is the return value of another method of the same class. For example: class A: def __init__(self): self.x = 1 def meth1(self): return self.x def meth2(self, arg=meth1()): # The default `arg' should would take thereturn value of meth1() print '"arg" is', arg This obviously doesn't work. I know I could do ... def meth2(self, arg=None): if arg is None: arg = self.meth1() but I'm looking for a more straightforward way. From arnodel at googlemail.com Fri Apr 25 05:29:15 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Fri, 25 Apr 2008 10:29:15 +0100 Subject: Little novice program written in Python References: <0cecfed4-17e7-4e4d-9dbe-3f0ac8316c1f@y21g2000hsf.googlegroups.com> Message-ID: hellt writes: > my variant of the sieve Since you posted it, you are also looking for advice to improve your code ;) > def GetPrimes(N): > arr = [] > for i in range(1,N+1): > arr.append(i) This is the same as: arr = range(1, N+1) !-) > #Set first item to 0, because 1 is not a prime > arr[0]=0 > #sieve processing > s=2 remove this line > while s < math.sqrt(N): for s in xrange(2, int(math.sqrt(N))+1): > if arr[s-1] != 0: if arr[s-1]: > j = s*s remove this line > while j <= N: for j in xrange(s*s, N+1, s): > arr[j-1] = 0 > j += s remove this line > s += 1 remove this line > return [x for x in arr if x != 0] return filter(None, arr) Altogether now: def getprimes(N): arr = range(1, N+1) arr[0] = 0 for s in xrange(2, int(math.sqrt(N))+1): if arr[s-1]: for j in xrange(s*s, N+1, s): arr[j-1] = 0 return filter(None, arr) It's the same, but it looks a bit less like the litteral translation of some C code. Lastly, the lines: for j in xrange(s*s, N+1, s): arr[j-1] = 0 from above can be condensed using extended slices: arr[s*s-1 : N+1 : s] = [0] * (N/s - s + 1) (If I can count correctly) Giving the following, slightly shorter and probably faster: def getprimes(N): arr = range(1, N+1) arr[0] = 0 for s in xrange(2, int(math.sqrt(N))+1): if arr[s-1]: arr[s*s-1 : N+1 : s] = [0] * (N/s - s + 1) return filter(None, arr) If it was me, I would include 0 in the array, giving the slightly simpler: def getprimes(N): arr = range(N+1) arr[1] = 0 for s in xrange(2, int(math.sqrt(N))+1): if arr[s]: arr[s*s : N+1 : s] = [0] * (N/s - s + 1) return filter(None, arr) (I think) This all needs to be tested. -- Arnaud From spe.stani.be at gmail.com Thu Apr 17 08:38:46 2008 From: spe.stani.be at gmail.com (SPE - Stani's Python Editor) Date: Thu, 17 Apr 2008 05:38:46 -0700 (PDT) Subject: PHATCH: PHoto bATCH processor with EXIF and IPTC support for all platforms Message-ID: <808b0684-19bc-432e-811b-590a451ac899@a22g2000hsc.googlegroups.com> Phatch is a simple to use cross-platform GUI Photo Batch Processor Phatch handles all popular image formats and can duplicate (sub)folder hierarchies. It can batch resize, rotate, apply perspective, shadows, rounded corners, ... and more in minutes instead of hours or days if you do it manually. Phatch allows you to use EXIF and IPTC tags for renaming and data stamping. Phatch also supports a console version to batch photos on web servers. What is new? Until Phatch could only save EXIF and IPTC tags on Linux. Now this feature is available for all platforms hanks to the work of Robin Mills who managed to compile pyexiv2 and all its dependencies and get it to work on MacOS X (Tiger and Leopard, PPC and Intel) and x86 Windows. You can grab the libraries from here: http://www.clanmills.com/articles/gpsexiftags/ (Look for "Download the libraries click here" somewhere in the middle). I have not tested this myself yet, but assumes that it will work. Any volunteers to test this with Phatch Homepage: http://photobatch.stani.be (free download link below) Tutorials: http://photobatch.wikidot.com/tutorials Translations: https://translations.launchpad.net/phatch/trunk/+pots/phatch License: GPLv3 Screenshot: http://photobatch.wikidot.com/local--files/start/Screenshot-Phatch3d.jpg (the perspective and reflection is produced by Phatch itself) Phatch has many features, like: - EXIF information inspector with thumbnail - limit jpeg file size when saving - tons of actions organized by tags (including perspective, round corners, shadow, reflection, ...) - console version (Phatch can now run without a gui on servers) - batch rename and copy files based on exif metadata - data stamping (http://photobatch.wikidot.com) - online documentation wiki (http://photobatch.wikidot.com) - desktop or panel droplets on which images or folders can be dropped (available on Linux & Windows) Linux only features: - Nautilus and desktop integration (with its own mime type and nautilus extension) - manpage with examples With python-pyexiv2 the following featues are added: - embedding the original EXIF and IPTC tags in the image You can install Phatch for any platform if you read these instructions first: http://photobatch.wikidot.com/install From steve at holdenweb.com Thu Apr 24 07:33:52 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 07:33:52 -0400 Subject: annoying dictionary problem, non-existing keys In-Reply-To: <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> Message-ID: bvidinli wrote: > I posted to so many lists because, > > this issue is related to all lists, No, it isn't, as you would have discovered had you bothered to read the purpose of each list. For example, python-help and python-dev are mutually exclusive. > this is an idea for python, It isn't an idea for Python at all. It's you, telling the world that you haven't really used Python much and haven't read the manuals but would nevertheless like us to consider your ideas for improving the language. > this is related to development of python... > No it isn't. Python already has the feature you requested. > why are you so much defensive ? > Terry wasn't being defensive, he was protecting you form the abue you would receive of you kept posting to the wrong list! > i think ideas all important for development of python, software.... > i am sory anyway.... hope will be helpful. > We hope you will be helpful too. For now it would probably be best to start by posting your questions on the regular comp.lang.python group, which is generally suitable for beginners who know something about programming. If you are new to programming as well then the python-tutor list would be more useful. Ask with a little humility (the people who answer questions here are doing it out of the goodness of their hearts, remember) and soon you will be able to pass their assistance on, returning the favor they did for you. Welcome to the Python community. regards Steve > 2008/4/24, Terry Reedy : >> Python-dev is for discussion of development of future Python. Use >> python-list / comp.lang.python / gmane.comp.python.general for usage >> questions. -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From sturlamolden at yahoo.no Thu Apr 24 20:25:15 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 17:25:15 -0700 (PDT) Subject: Psyco alternative References: Message-ID: On Apr 25, 2:15 am, Steve Holden wrote: > I believe, without the benefit of recent experience, that the R stands > for Restricted. Thus and RPython program must of necessity also be a > valid Python program. Or do you know something I don't? That is correct. But RPython is not anything like Python, I would not even call it a dynamically typed language. It is actually more like Fortran 77 with a Python look and feel. From hniksic at xemacs.org Tue Apr 15 03:44:43 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Tue, 15 Apr 2008 09:44:43 +0200 Subject: Dynamic use of property() fails References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> Message-ID: <87wsmz4l5g.fsf@mulj.homelinux.net> andrew cooke writes: > This is my first attempt at new classes and dynamic python, so I am > probably doing something very stupid... After reading the how-to for > descriptors at http://users.rcn.com/python/download/Descriptor.htm I > decided I would make an object that returns attributes on read, but on > setting calls an arbitrary function. > > My code looks like: > class ActiveDAO(object): > def __init__(self): > self.__values__ = {} > def add_field(self, name, value, on_change): > self.__values__[name] = value > def get(self): return self.__values__[name] > def set(self, new_value): self.__values__[name] = > on_change(new_value) > def delete(self): raise AttributeError > self.__dict__[name] = property(get, set, delete) As others explained, descriptors are called for descriptors found in class attributes, not in ones in instance attributes. Calling them for the latter would be dangerous because it might accidentally invoke magic whenever you store the "wrong" kind of object in an instance attribute. Also, in many cases (slots), instance property access is *implemented* using class property descriptors, so calling descriptors on objects retrieved from the instance would mean that the descriptor would have to be invoked twice. However, if you know what you're doing, you can simply customize your class's __getattribute__ to do what *you* want for your objects. For example: def __getattribute__(self, name): dict = object.__getattribute__(self, '__dict__') # self.__dict__ would infloop if name in dict: o = dict[name] # call the descriptor even if found in an object in __dict__ if hasattr(o, '__get__'): return o.__get__(self, type(self)) return o return object.__getattribute__(self, name) With that addition: >>> dao = ActiveDAO() >>> dao.add_field('name', 'value', lambda _: None) >>> dao.name 'value' >>> dao.__dict__['name'] From gagsl-py2 at yahoo.com.ar Tue Apr 1 13:47:37 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 14:47:37 -0300 Subject: Is this a good time to start learning python? References: <47f1140e$0$735$a729d347@news.telepac.pt> Message-ID: En Tue, 01 Apr 2008 13:57:55 -0300, escribi?: > On Mar 31, 1:36?pm, "Gabriel Genellina" > wrote: > >> Don't be scared by the "backwards incompatible" tag - it's the way to >> get ? >> rid of nasty things that could not be dropped otherwise. > > I would consider breaking production code to be "nasty" as well. Please explain how the existence of Python 3.0 would break your production code. -- Gabriel Genellina From paul.anton.letnes at gmail.com Sat Apr 12 08:46:53 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Sat, 12 Apr 2008 14:46:53 +0200 Subject: Wrapping C++ class with SWIG, Mac OS X In-Reply-To: <66aglpF2ihunjU1@mid.uni-berlin.de> References: <66aglpF2ihunjU1@mid.uni-berlin.de> Message-ID: <09DACA88-AEF5-40FE-A408-655AD5FE489A@gmail.com> Okay, installed SIP. Looks promising, following the tutorial on http://www.riverbankcomputing.com/static/Docs/sip4/sipref.html#using-sip It should be noted that I am working on a Mac - I know there are some differences, but it's still UNIX and should work somehow. Anyway, I copy-paste and create the Word.h header, write an implementation in Word.cpp, the SIP wrapper Word.sip and the configure.py script. I now run configure and make, creating the following error: ~/Desktop/SIP_example $ python configure.py ~/Desktop/SIP_example $ make c++ -c -pipe -fPIC -Os -Wall -W -I. -I/sw/include/python2.5 -o sipwordcmodule.o sipwordcmodule.cpp c++ -c -pipe -fPIC -Os -Wall -W -I. -I/sw/include/python2.5 -o sipwordWord.o sipwordWord.cpp c++ -headerpad_max_install_names -bundle -undefined dynamic_lookup -o word.so sipwordcmodule.o sipwordWord.o -lword ld: library not found for -lword collect2: ld returned 1 exit status make: *** [word.so] Error 1 ~/Desktop/SIP_example $ SWIG at least works nicely with C... Too bad I know so little about compilers and libraries, I don't quite understand what the linker (ld) is complaining about. The simplest tutorial should anyway work? Cheers Paul. > > Can't help on SWIG - all I can say is that SIP which is used to wrap > the > large and template-ridden C++-GUI-Toolkit Qt worked flawlessly for me. > Maybe you should try that. > > Diez > -- > http://mail.python.org/mailman/listinfo/python-list From fetchinson at googlemail.com Thu Apr 3 01:37:45 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Wed, 2 Apr 2008 22:37:45 -0700 Subject: Parsing HTML? In-Reply-To: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> References: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> Message-ID: > I'm trying to parse an HTML file. I want to retrieve all of the text > inside a certain tag that I find with XPath. The DOM seems to make > this available with the innerHTML element, but I haven't found a way > to do it in Python. Have you tried http://www.google.com/search?q=python+html+parser ? HTH, Daniel From cwitts at gmail.com Thu Apr 10 04:17:29 2008 From: cwitts at gmail.com (Chris) Date: Thu, 10 Apr 2008 01:17:29 -0700 (PDT) Subject: new user needs help! References: <16571823.post@talk.nabble.com> Message-ID: On Apr 10, 10:07?am, Chris wrote: > On Apr 9, 11:02?pm, drjekil wrote: > > > > > I have done something so far about that problem,but its not the good way to > > do it > > > need ur comments about that.... > > > from string import ?*; > > import sys > > > myfile = open("/afs/pdc.kth.se/home/d/debnath/membrane/1a91A.txt") > > a = myfile.readlines() > > data = myfile.readlines() > > for line in myfile.readlines(): > > ? ? ? ?fields = line.split('\t') > > > ? ? ? ?items=fields.strip() > > ? ? ? ?list1.append(items[1]) > > > for i in aminoacid: > > ? ? if ?10.0 <= z <= 22.0: > > ? ? matches.append([1,i]) > > #here i am getting comment! ?bash-3.1$ python bb.py > > ? File "bb.py", line 16 > > ? ? matches.append([1,i]) > > ? ? ? ? ? ^ > > IndentationError: expected an indented block > > > ? ? else: > > ? ? matches.append([-1,i]) > > You are getting the indentation error because you need to tab the > lines in after your 'if' and 'else' statements. ?After that is fixed > you should get an Attribute Error on the 'items=fields.strip()' as a > list doesn't have access to strip. > > import string > myfile = open("/afs/pdc.kth.se/home/d/debnath/membrane/1a91A.txt", > 'rb') > > AMINO_ACIDS = ['A','B','C',......'X','Y','Z'] > > for line in myfile: ? # Files are iterable themselves. > > ? ? try: > ? ? ? ? fields = map(string.strip, line.split('\t')) ?# This will > strip every column for you > ? ? ? ? name, aa, topo, access, tssp, stride, z = fields > ? ? except IndexError: ? ?# In case you don't have enough elements > ? ? ? ? print 'Not enough elements on the line, moving along' > > ? ? if 10 <= z <= 22: ? # You only wanted between those Z-Coords ? > ? ? ? ? if aa in AMINO_ACIDS: > ? ? ? ? ? ? # Now actually process the data you want > > > > > print "#T/F ?A ?C ?D ?E ?F ?G ?H ?I ?K ?L ?M ?N ?P ?Q ?R ?S ?T ?V ?W ?X ?Y > > Z" > > > for a in range(0,len(matches),1): > > > ? ? if ? ? matches[a][0]==1: > > > ? ? if matches[a][1]=='A': > > ? ? ? ? print "1 ?1:1 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 > > 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? elif matches[a][1]=='C': > > ? ? ? ? print "1 ?1:0 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 > > 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? elif matches[a][1]=='D': > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:1 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > """ ? ?if matches[a][1]=='E' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:1 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='F' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:1 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='G' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:1 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='H' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='I' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:1 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='K' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:1 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='L' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:1 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='M' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:1 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='N' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:1 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='P' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:1 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='Q' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='R' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:1 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='S' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:1 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='T' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:1 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='V' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:1 19:0 20:0 21:0" > > ? ? if matches[a][1]=='X' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:1 20:0 21:0" > > ? ? if matches[a][1]=='Y' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:1 21:0" > > ? ? if matches[a][1]=='Z' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:1" > > > """ > > ? ? else: > > ? ? if matches[a][1]=='A': > > ? ? ? ? print "-1 ?1:1 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 > > 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? elif matches[a][1]=='C': > > ? ? ? ? ? ? print "-1 ?1:0 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? elif matches[a][1]=='D': > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:1 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > """ ? ?if matches[a][1]=='E' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:1 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='F' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:1 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='G' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:1 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='H' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='I' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:1 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='K' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:1 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='L' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:1 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='M' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:1 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='N' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:1 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='P' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:1 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='Q' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='R' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:1 16:0 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='S' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:1 17:0 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='T' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:1 18:0 19:0 20:0 21:0" > > ? ? if matches[a][1]=='V' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:1 19:0 20:0 21:0" > > ? ? if matches[a][1]=='X' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:1 20:0 21:0" > > ? ? if matches[a][1]=='Y' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:1 21:0" > > ? ? if matches[a][1]=='Z' and matches[a][0]==1: > > > ? ? ? ? print " ? ?1 ?1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:1" > > ? ?waiting for ur opinion. > > ? ?thanks > > > -- > > View this message in context:http://www.nabble.com/new--user-needs-help%21-tp16571823p16596608.html > > Sent from the Python - python-list mailing list archive at Nabble.com. > > Masses of print statements might work for debugging but you can get a > better structure through something else. ?If you have a specific > message for those you could always build a dictionary containing the > messages and access them like.... > > msg_dict = {'A':'Message for A', 'B':'Message for... > > read more ? whoops, forgot the continue statement after the index error for line in myfile: # Files are iterable themselves. try: fields = map(string.strip, line.split('\t')) # This will strip every column for you name, aa, topo, access, tssp, stride, z = fields except IndexError: # In case you don't have enough elements print 'Not enough elements on the line, moving along' continue # This will take your code to the top of the loop and start the next iteration instead of continuing through the code From bruno.42.desthuilliers at wtf.websiteburo.oops.com Tue Apr 1 04:57:47 2008 From: bruno.42.desthuilliers at wtf.websiteburo.oops.com (Bruno Desthuilliers) Date: Tue, 01 Apr 2008 10:57:47 +0200 Subject: Prototype OO In-Reply-To: References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> Message-ID: <47f1f90b$0$27429$426a74cc@news.free.fr> sam a ?crit : > Steven D'Aprano napisa?(a): > >>> I can see that Python and Javascript inheritance model is almost the >>> same. Both languages are dynamically typed. And it seems that using >>> "classes" in Python makes some things more complicated then it is >>> necessary (eg functions, methods and lambdas are differen beeing in >>> Python concept). >> >> Please explain why you think that functions are more complicated in >> Python because of the class model. > > Sorry for a late reply (I was out of the office). > > > 1. You have different syntax for named and unnamed (lambdas) functions. That doesn't make the resulting object different, and this has nothing to do with Python's object model. > Functions and methods are different things in Python even if they have > same syntax. There's *no* syntax for Python methods. Whether you define it at the module's top level, within a class statement or within another function, what you define is a function, period. It's the collaboration between the attribute lookup mechanism and the function objects themselves that yields method objects. > 2. Static function doesn't need to reference "self", and Python forces > programmer to put "self" explicitly. > Then you have to do some "tricks" > on function to become static. Hem... Shouldn't smoke that weird weed they gave you, for sure... If you're talking about staticmethods, they - by definition - don't take the instance as first param. And the 'trick' is mostly: decorate the function with the staticmethod type. Here's how you do it: class Parrot(object): @staticmethod def vroom(): print "vroom" No self, no trick. Now anyway, staticmethod are rarely used - usually, all you need is a plain function (remember that Python doesn't force you into putting everything in a class). Now this still have nothing to do with Python being class-based (for a definition of class-based that's *very* different from Java). > Python is said "nothing is really > private", but interpreter does some "tricks" to make __id hidden for a > class. Not to hide it, but to avoid name clash. > > Some opinions: > > 1. In early days you could do OOP in C -- you just used additional > parameter in a function. While possible, OO in C is definitively a PITA (cf GTK+, OOPC etc). > Then C++ appeared to make life easier: "when > you write mystring.toupper(), then toupper function gets hidden argument > called "this"". Programs are written in a high level object oriented > languages now. In these languages you still use the same syntax > mystring.toupper(), but now you don't pass object to a function (as in > C), but you act on that object. So in the body of toupper() you can > REFERENCE object "mystring". So why do I have to put that "strange" > argument "self"? To allow a simple, uniform and *highly* flexible way to handle functions and methods. Learn about Python's object model (you obviously don't have a clue about it), and specially about the descriptor protocol and how functions implement it, take time to experiment with it and think about all it let you do that you just can't do in C+ or Java, and then I'll be happy to continue this discussion. > This is not only my opinion > (http://apache.ece.arizona.edu/~edatools/Python/Prototypes.htm). Without > "self" you would use same syntax for ordinary functions, methods, and > lambdas. Once again, there's *no* syntax difference between functions and methods, because you *never* define a method. wrt/ lambda, the problem has to do with Python being statemement-based and having significant indentation. > 2. Something is private because you can't reference that from outside > the scope. The wrong way is to make object properties private by > declaring them private or to do hidden actions (__id). For example all > local variables in function are private, because you can't access them > from outside that function. Why desn't this work for objects? Because Python's designer didn't think that language-enforced access restriction was such a good idea. BTW, where are "private" attributes in javascript ?-) > Again this is not only my opinion -- > http://www.crockford.com/javascript/private.html. Answer: a dirty trick using closures... Sam, seriously, why don't start with *learning* about Python's object model ? Seriously ? Not that it's "perfect", not that you have to like it, but if you hope your criticism to be taken seriously, you'd better know what you're talking about. My 2 cents... From paddy3118 at googlemail.com Tue Apr 15 02:58:03 2008 From: paddy3118 at googlemail.com (Paddy) Date: Mon, 14 Apr 2008 23:58:03 -0700 (PDT) Subject: How to make a "command line basd" interactive program? References: Message-ID: <48caf19e-6d43-4357-ac5d-08b6589bd816@m3g2000hsc.googlegroups.com> On Apr 15, 6:35 am, Evan wrote: > that's great, a custom shell is what I need. > > Thanks all > Evan And for the quick-n-dirty there is: python -i yourscript.py Which runs your script then drops you into the interpreter. - Paddy. From patrick.waldo at gmail.com Wed Apr 2 10:23:23 2008 From: patrick.waldo at gmail.com (patrick.waldo at gmail.com) Date: Wed, 2 Apr 2008 07:23:23 -0700 (PDT) Subject: xlrd and cPickle.dump References: <34e62ddb-477f-4a99-97a5-21a7b148d244@e67g2000hsa.googlegroups.com> <47f22a41@news.mel.dft.com.au> <0d46a213-9f95-43b5-835b-d74d8403626b@c19g2000prf.googlegroups.com> <6acbf9b4-161b-47db-9a91-b2448ee63c34@c26g2000prf.googlegroups.com> Message-ID: <12375df7-387d-424d-84a8-76beb664ae47@59g2000hsb.googlegroups.com> Still no luck: Traceback (most recent call last): File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework \scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\text analysis\pickle_test2.py", line 13, in ? cPickle.dump(Data_sheet, pickle_file, -1) PicklingError: Can't pickle : attribute lookup __builtin__.module failed My code remains the same, except I added 'wb' and the -1 following your suggestions: import cPickle,xlrd, sys print sys.version print xlrd.__VERSION__ data_path = """C:\\test\\test.xls""" pickle_path = """C:\\test\\pickle.pickle""" book = xlrd.open_workbook(data_path) Data_sheet = book.sheet_by_index(0) pickle_file = open(pickle_path, 'wb') cPickle.dump(Data_sheet, pickle_file, -1) pickle_file.close() To begin with (I forgot to mention this before) I get this error: WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non- zero I'm not sure what this means. > What do you describe as "simple manipulations"? Please describe your > computer, including how much memory it has. I have a 1.8Ghz HP dv6000 with 2Gb of ram, which should be speedy enough for my programming projects. However, when I try to print out the rows in the excel file, my computer gets very slow and choppy, which makes experimenting slow and frustrating. Maybe cPickle won't solve this problem at all! For this first part, I am trying to make ID numbers for the different permutation of categories, topics, and sub_topics. So I will have [book,non-fiction,biography],[book,non- fiction,history-general],[book,fiction,literature], etc.. so I want the combination of [book,non-fiction,biography] = 1 [book,non-fiction,history-general] = 2 [book,fiction,literature] = 3 etc... My code does this, except sort returns None, which is strange. I just want an alphabetical sort of the first option, which sort should do automatically. When I do a test like >>>nest_list = [['bbc', 'cds'], ['jim', 'ex'],['abc', 'sd']] >>>nest_list.sort() [['abc', 'sd'], ['bbc', 'cds'], ['jim', 'ex']] It works fine, but not for my rows. Here's the code (unpickled/unsorted): import xlrd, pyExcelerator path_file = "C:\\text_analysis\\test.xls" book = xlrd.open_workbook(path_file) ProcFT_QC = book.sheet_by_index(0) log_path = "C:\\text_analysis\\ID_Log.log" logfile = open(log_path,'wb') set_rows = [] rows = [] db = {} n=0 while n Also, any good reason for sticking with Python 2.4? Trying to learn Zope/Plone too, so I'm sticking with Python 2.4. Thanks again From skunkwerk at gmail.com Sun Apr 13 16:54:18 2008 From: skunkwerk at gmail.com (skunkwerk) Date: Sun, 13 Apr 2008 13:54:18 -0700 (PDT) Subject: subprocess.popen function with quotes References: <7f550baf-0622-42a1-bc01-157cf955bca3@i12g2000prf.googlegroups.com> <00e26c78-0d4d-47c2-bf60-601d690b5be3@e23g2000prf.googlegroups.com> <73b93526-fc81-4df7-824f-2e30b3a25456@h11g2000prf.googlegroups.com> <13ukphrj8hng018@corp.supernews.com> Message-ID: On Mar 26, 10:33?pm, skunkwerk wrote: > On Mar 26, 8:05?am, Jeffrey Froman wrote: > > > > >skunkwerkwrote: > > > p = subprocess.Popen(['rename','-vn','s/(.*)\.htm$/ > > > model.html/','*.htm'],stdout=subprocess.PIPE,stderr=subprocess.PIPE) > > > print p.communicate()[0] > > > > i change to print p.communicate()[1] in case the output is blank the > > > first time > > > > this is the output: > > > *.htm renamed as model.html > > > Without shell=True, your glob characters will not be expanded. Hence, the > > command looks for a file actually named "*.htm" > > > > when I add shell=True to the subprocess command, I get the following > > > output: > > > Usage: rename [-v] [-n] [-f] perlexpr [filenames] > > > Here the use of the shell may be confounding the arguments passed. Your > > command will probably work better if you avoid using shell=True. However, > > you will need to perform your own globbing: > > > # Untested (no perl-rename here): > > > command = ['rename','-vn', 's/(.*)\.htm$/model.html/'] > > files = glob.glob('*.htm') > > command.extend(files) > > p = subprocess.Popen( > > ? ? command, > > ? ? stdout=subprocess.PIPE, > > ? ? stderr=subprocess.PIPE, > > ? ? ) > > > Jeffrey > > thanks Jeffrey, that worked like a charm! I'm trying to detect when the subprocess has terminated using the wait() function - but when there is an error with the call to rename (ie the file doesn't exist) rename (when run from the command line just terminates and displays the error). In the code above, though, my call to p.wait() just hangs when rename should throw an error... I've tried adding shell=True but that stops the rename from working. any ideas? thanks From jared.grubb at gmail.com Wed Apr 23 12:59:25 2008 From: jared.grubb at gmail.com (Jared Grubb) Date: Wed, 23 Apr 2008 09:59:25 -0700 Subject: Partition list with predicate Message-ID: <925822270804230959v557ec5f5re02737709f94d3c6@mail.gmail.com> I want a function that removes values from a list if a predicate evaluates to True. The best I could come up with is: def extract(lst, pred): idx = 0 ret = [] for obj in lst[:]: if pred(obj): ret.append(obj) lst.pop(idx) else: idx += 1 return ret Anybody have a better, more Pythonic solution? One of my failed attempts was this code, which fails when the predicate itself has "state": def extract(lst, pred): # BAD: Would not work in a case like pred = "extract every other object" ret = filter(lst, pred) for obj in ret: lst.remove(obj) return ret -------------- next part -------------- An HTML attachment was scrubbed... URL: From soren.skou.nielsen at gmail.com Mon Apr 7 07:50:36 2008 From: soren.skou.nielsen at gmail.com (Soren) Date: Mon, 7 Apr 2008 04:50:36 -0700 (PDT) Subject: Wxpython. Is it possible to change layout in a running application? Selfmade listbox Message-ID: <716c0f27-bca6-4642-a8ec-cdbb0b23e6e8@h1g2000prh.googlegroups.com> Hi, Id like to make my own special listbox.. I want to able (at the push of a button) to add another item to my special listbox... each item is a panel with a label, some buttons and maybe a text control. I've tried adding a new panel object with the stuff i want to the sizer i'm using for my listbox (which is a panel which can contain other panels)... and then run update() and refresh() on everything... But it doesn't work.. i see a panel appearing, but it's just a small square in the corner of my "listbox" panel, and it only works the first time... nothing new appears when I push the button again. Is it at all possible to do this? Has anyone created something similar? Does anyone know what i'm doing wrong? Thanks, Soren From subhabrata.iisc at hotmail.com Thu Apr 10 01:59:24 2008 From: subhabrata.iisc at hotmail.com (subhabrata.iisc at hotmail.com) Date: Wed, 9 Apr 2008 22:59:24 -0700 (PDT) Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> <6641eaF2ics8jU1@mid.uni-berlin.de> <664j0pF2iji99U2@mid.uni-berlin.de> Message-ID: <89872ea1-dc03-4647-b0bc-9d316df3efb5@q1g2000prf.googlegroups.com> I am getting the comments. So any one can post any comment like Steve knows nothing of Python. California has still lot to catch up to be at par with Mesopatamia. comp.lang.python seems a group of fools. Anyhow, all I learnt take whichever suits and ignore rest many people have lot of time to carry out lot of nonsense. Well I should have looked for a paid help and my stand about not giving out my code in open forum stands as prolific. Better not lose time unnecessarily going back to work and debugging the problems is much sensical work that I can do instead of listening to jokes in the morning!!!! Marc 'BlackJack' Rintsch wrote: > On Wed, 09 Apr 2008 16:16:14 +0200, Diez B. Roggisch wrote: > > > And then you reply telling us about the greatness of Bangalore and your > > product to come. Which is somewhat amusing that people who claim to produce > > the greatest software being incapable of debugging it deems me as odd - to > > say the least. > > That's not odd, that's perfectly normal for really clever code: > > Debugging is twice as hard as writing the code in the first > place.Therefore, if you write the code as cleverly as possible, you > are, by definition, not smart enough to debug it. -- Brian W. Kernighan > > ;-) > > Ciao, > Marc 'BlackJack' Rintsch From tnelson at onresolve.com Wed Apr 23 16:17:17 2008 From: tnelson at onresolve.com (Trent Nelson) Date: Wed, 23 Apr 2008 13:17:17 -0700 Subject: Python development tools In-Reply-To: References: Message-ID: <87D3F9C72FBF214DB39FA4E3FE618CDC6E2456CD31@EXMBX04.exchhosting.com> > Are there any completely free developent tools for python > scripts like IDLE. I have used IDLE , but I want to try out > others also. I saw stuff like PyCrust, but I don't see that > it can run the script as well. > Thanks, Ignoring the 'free' part of your question, I've recently moved from PyDev to Wing IDE (www.wingware.com), and would highly recommend it. Trent. From deets at nospam.web.de Mon Apr 21 09:59:20 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Mon, 21 Apr 2008 15:59:20 +0200 Subject: Nested lists, simple though References: <8788db32-30b4-4cae-ab5a-bf6051249294@a9g2000prl.googlegroups.com> Message-ID: <673kujF2n1u62U1@mid.uni-berlin.de> > The first idea that comes to mind is reduce(lambda x, y: x + y, > list_of_lists, []) Which is not helping for arbitrary nested lists, as the OP wanted. Diez From jason.scheirer at gmail.com Fri Apr 18 15:52:06 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Fri, 18 Apr 2008 12:52:06 -0700 (PDT) Subject: Easiest way to get started with WebApps? References: <3c43f29c-3e51-48ab-be02-47402ccd1bfd@b64g2000hsa.googlegroups.com> Message-ID: <37550c25-9d9f-49be-af27-b69b742c995c@n1g2000prb.googlegroups.com> On Apr 18, 12:06 pm, skanem... at yahoo.se wrote: > which is the easiest module to use to just get started with webapps > quicklya nd starting getting things up and running, not advanced stuff > just basic. web.py is probably the most reasonable small webapp framework to get going (it's a very small download and install, with little to no configuration). It does lack a lot of features you may eventually want and you will have to roll yourself, but I really strongly recommend it if you already know something about web programming. I've had a lot of success teaching newbie swith TurboGears, but that's pretty heavyweight and every time you mention it everyone asks why you don't just use Django or Pylons. From billingspanshism at gmail.com Sat Apr 19 17:19:07 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:19:07 -0700 (PDT) Subject: david beckham and victoria beckham Message-ID: Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From mnordhoff at mattnordhoff.com Fri Apr 25 09:08:49 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Fri, 25 Apr 2008 13:08:49 +0000 Subject: problem with unicode In-Reply-To: <26fcc207-b864-42c7-afb3-c6945e5fe29f@m44g2000hsc.googlegroups.com> References: <26fcc207-b864-42c7-afb3-c6945e5fe29f@m44g2000hsc.googlegroups.com> Message-ID: <4811D7E1.2030308@mattnordhoff.com> andreas.profous at googlemail.com wrote: > Hi everybody, > > I'm using the win32 console and have the following short program > excerpt > > # media is a binary string (mysql escaped zipped file) > >>> print media > x???[? ... > (works) > >>> print unicode(media) > UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position > 1: ordinal not in range(128) > (ok i guess print assumes you want to print to ascii) > I don't know what to do. I just want to concatenate two string where > apparently one is a binary string, the other one is a unicode string > and I always seem to get this error. > > Any help is appreciated :) You should read the Python Unicode documentation, such as: and maybe a non-Python-specific article: -- From cor at clsnet.nl Tue Apr 22 18:24:41 2008 From: cor at clsnet.nl (Cor Gest) Date: Tue, 22 Apr 2008 22:24:41 +0000 Subject: pop langs website ranking References: <41fbaf27-a80b-402b-b406-c048a65a8643@b64g2000hsa.googlegroups.com> Message-ID: <873apda5p2.fsf@atthis.clsnet.nl> Some entity, AKA "xahlee at gmail.com" wrote this mindboggling stuff: (selectively-snipped) > My website is now actually ranked higher than PaulGraham.com ! well well, so your site is more popular. You can make it even more popular, you know. Just rename some lame article about how to make a kitty-litter into mytinypussy.html and your hitrate will become astronomical. Cor -- Mijn Tools zijn zo Modern dat ze allemaal eindigen op "saurus" SPAM DELENDA EST http://www.clsnet.nl/mail.php Spamipuku rules the spamwave (defvar My-Computer '((OS . "GNU/Emacs") (IPL . "GNU/Linux"))) From danb_83 at yahoo.com Sun Apr 20 18:54:45 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Sun, 20 Apr 2008 15:54:45 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: <48a1d10c-87cb-43c3-83f4-9c331fc1d818@m1g2000pre.googlegroups.com> On Apr 20, 11:42 am, Matthew Woodcraft wrote: > Christian Heimes wrote: > > >> I feel that including some optional means to block code would be a big > >> step in getting wider adoption of the language in web development and > >> in general. I do understand though, that the current strict indenting > >> is part of the core of the language, so... thoughts? > > Why should Python repeat the mistakes other languages did with SSI or > > inline code? Python favors the MVC separation of code and layout. > > An alternative scheme for describing the block structure could be > useful in other cases, though. For example, if you wanted to support > putting snippets of Python in configuration files, or spreadsheet > cells. > > There's no need to support the new scheme in .py files, so it seems to > me that this doesn't have to be done in the core language. All that's > needed is a variant of 'eval' which expects the alternate scheme, and > that could be prototyped just using text manipulation and the normal > 'eval'. We wouldn't even need that. Just a new source encoding. Then we could write: # -*- coding: end-block -*- def _itoa(num, base): """Return the string representation of a number in the given base.""" if num == 0: return DIGITS[0] end if negative = num < 0 if negative: num = -num end if digits = [] while num: num, last_digit = divmod(num, base) digits.append(DIGITS[last_digit]) end while if negative: digits.append('-') end if return ''.join(reversed(digits)) end def From grg2 at comcast.net Wed Apr 16 10:25:40 2008 From: grg2 at comcast.net (A_H) Date: Wed, 16 Apr 2008 07:25:40 -0700 (PDT) Subject: matplotlib psd Message-ID: <548eaca3-4797-4b77-8583-e176056618ba@d1g2000hsg.googlegroups.com> Kudos to matplotlib in python, it's a real slick package. But I'd like to do several power spectrum density calls [ psd() ] and control the color of each. I don't see any obvious option for this. Any hints? From jtanis at mdchs.org Wed Apr 2 13:22:12 2008 From: jtanis at mdchs.org (James Tanis) Date: Wed, 2 Apr 2008 13:22:12 -0400 Subject: Manipulate Large Binary Files In-Reply-To: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> Message-ID: <74530989b6fe0985f0e21c96093678e2@portal.mdchs.org> "Derek Tracy" wrote: > > INPUT = open(infile, 'rb') > header = FH.read(169088) > > ary = array.array('H', INPUT.read()) > > INPUT.close() > > OUTF1 = open(outfile1, 'wb') > OUTF1.write(header) > > OUTF2 = open(outfile2, 'wb') > ary.tofile(OUTF2) > > > When I try to use the above on files over 2Gb I get: > OverflowError: requested number of bytes is more than a Python string > can hold > > Does anybody have an idea as to how I can get by this hurdle? > If it were me I'd loop until EOF and do small(er) read/write operations rather then attempt to put a whole 2gb file into a single string. Even if it was possible, you'd be using over 2gb of ram for a single operation. Also INPUT.read() returns a string from what I understand.. ary = array.array('c', INPUT.read()) might be more appropriate, but I'm not positive. Anyway I took a short look through array and using ary.fromfile(f, n) might be more appropriate. Using a loop, read some "machine values" with ary.fromfile(f, n) and write them with ary.tofile(f). Catch the EOFError when it is thrown.. I'd imagine that could work. -- James Tanis Technology Coordinator Monsignor Donovan Catholic High School? e: jtanis at mdchs.org p: (706)433-0223 From destroooooy at gmail.com Tue Apr 29 16:39:08 2008 From: destroooooy at gmail.com (destroooooy) Date: Tue, 29 Apr 2008 13:39:08 -0700 (PDT) Subject: string translate, replace, find and the forward slash Message-ID: <1030ffc2-1bbe-4539-881d-35bf59cacd11@34g2000hsh.googlegroups.com> Hi folks, I'm finding some (what I consider) curious behavior with the string methods and the forward slash character. I'm writing a program to rename mp3 files based on their id3 tags, and I want to protect against goofy characters in the in tags. So I do the following: unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n" alt_chars = "_________________________" s_artist.translate(maketranstable(unsafe_chars, alt_chars)) which successfully replaces everything except for forward slashes (at least in the files I've tested so far). If I use the "replace()" method, it also does not work. Escaping the forward slash changes nothing. "find()" however, works, and thus I've resorted to: if "/" in s_artist: (s_l, slash, s_r) = s_artist.partition("/") s_artist = "_".join([s_l, s_r]) which is rather uncool. It works but I'd just like to know what the deal is. TIA. From ridenour4159 at gmail.com Thu Apr 24 06:14:57 2008 From: ridenour4159 at gmail.com (ridenour4159 at gmail.com) Date: Thu, 24 Apr 2008 03:14:57 -0700 (PDT) Subject: xxx crack Message-ID: <4cea9ef9-3699-4586-a947-c2a4ae04d9eb@t54g2000hsg.googlegroups.com> xxx crack http://cracks.12w.net F R E E C R A C K S From fetchinson at googlemail.com Sat Apr 26 01:47:28 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Fri, 25 Apr 2008 22:47:28 -0700 Subject: MESSAGE RESPONSE In-Reply-To: References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> <678v5qF2me5rvU1@mid.uni-berlin.de> <4e89b45d-198c-48ca-a3a6-3ba42448cb2b@e53g2000hsa.googlegroups.com> Message-ID: > >> And as such, I find it hard to believe you could lose your job > >> over it. > > > > Me too. That is, until I tried to Google Belcan and Blubaugh > > together. May I suggest a new thread to clear that ugly > > results? :D > > I know it's not nice to laugh at things like that, but I can't > help it... > > I never saw the original message, so I didn't know exactly what > he was objecting to. I did know that what he was doing was, > well, let's just say counter-productive. Same here :) I had no idea what this thread is about until I searched for belcan and Blubaugh. David! It's actually very simple to filter messages, you just need to install a spam filter like spamassassin or something similar. Then you will not get fired from belcan because of your "I'm feeling lucky" google hit. From bronger at physik.rwth-aachen.de Tue Apr 29 12:26:11 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Tue, 29 Apr 2008 18:26:11 +0200 Subject: Simple unicode-safe version of str(exception)? References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> <67on2nF2ol856U1@mid.individual.net> Message-ID: <87zlrcmxuk.fsf@physik.rwth-aachen.de> Hall?chen! Russell E. Owen writes: > [...] > > So...to repeat the original question, is there any simpler > unicode-safe replacement for str(exception)? Please show us the tracebacks you get becuae unicode(s) must fail, too, if there are non-ASCII characters involved. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From diesch at spamfence.net Wed Apr 30 04:34:47 2008 From: diesch at spamfence.net (Florian Diesch) Date: Wed, 30 Apr 2008 10:34:47 +0200 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> <480fa6e3$0$34491$742ec2ed@news.sonic.net> <7xzlrj14r7.fsf@ruckus.brouhaha.com> <4811edad$0$34525$742ec2ed@news.sonic.net> Message-ID: <7inle5-sgo.ln1@mid.florian-diesch.de> John Nagle wrote: > Perl has CPAN, which is reasonably comprehensive and presents modules > in a uniform way. If you need a common Perl module that's not in the > Perl distro, it's probably in CPAN. "Installing a new module can be as > simple as typing perl -MCPAN -e 'install Chocolate::Belgian'." > So Perl has exactly that. > > Python's Cheese Shop is just a list of links to packages > elsewhere. There's no uniformity, no standard installation, no > standard uninstallation, and no standard version control. Python has easy_install Florian -- ----------------------------------------------------------------------- ** Hi! I'm a signature virus! Copy me into your signature, please! ** ----------------------------------------------------------------------- From musiccomposition at gmail.com Tue Apr 1 22:34:47 2008 From: musiccomposition at gmail.com (Benjamin) Date: Tue, 1 Apr 2008 19:34:47 -0700 (PDT) Subject: Using QSystemTrayIcon with PyQt References: <76680315-cadd-42ad-942c-3e89536819df@i12g2000prf.googlegroups.com> <6d0b8776-bb64-4a58-8ccb-46efa35d75a2@s50g2000hsb.googlegroups.com> <1a8a5b03-0b9e-49de-bd87-43fa1aa99dc2@b5g2000pri.googlegroups.com> <6b732135-a488-4175-889b-0cccf5f0c581@s8g2000prg.googlegroups.com> Message-ID: <29632af8-2ed5-434a-aaaa-1c1c51dd4f1d@m44g2000hsc.googlegroups.com> On Apr 1, 7:56 am, BlueBird wrote: > On Apr 1, 6:00 am, Alex Teiche wrote: > > > > > On Mar 31, 7:53 pm, Benjamin wrote: > > > > On Mar 31, 8:41 pm, Alex Teiche wrote: > > > > > On Mar 31, 6:40 pm, Alex Teiche wrote: > > > > > > On Mar 31, 11:49 am, Alex Teiche wrote: > > > > > > > On Mar 30, 3:50 pm, Benjamin wrote: > > > > > > > > On Mar 29, 11:02 pm, Alex Teiche wrote:> Hello, > > > > > > > > > I am pretty new to Python, and have never learned C++. I am trying to > > > > > > > > implement the following thing into my python application: > > > > > > > > >http://doc.trolltech.com/4.3/qsystemtrayicon.html > > > > > > > > > Through PyQt. I have been using PyQt for awhile and I know how do use > > > > > > > > it, but I could not get this specific thing to work. Can someone give > > > > > > > > me some hints as to get it working in Python? > > > > > > > > What problems are you having? > > > > > > > > > Thanks a ton, > > > > > > > > > Alex > > > > > > > Thanks everyone for your help. I found the example to be particularly > > > > > > helpful, and I have made a simplified version just to display an icon > > > > > > with a quit button in its menu. Once I know how to do that I will > > > > > > incorporate it into my larger program, with more options and the > > > > > > ability show messages. The problem is, it doesn't work, and I can't > > > > > > find out what's wrong. Can you give me some hints? > > > > > > > Here is the code: > > > > > > import sys > > > > > > from PyQt4 import QtGui, QtCore > > > > > > > class trayIcon(QtGui.QWidget): > > > > > > def __init__(self, parent=None): > > > > > > QtGui.QWidget.__init__(self, parent) > > > > > > > #********Create Actions for the Tray Menu********# > > > > > > self.quitAction = QtGui.QAction(self.tr("&Quit"), self) > > > > > > QtCore.QObject.connect(self.quitAction, > > > > > > QtCore.SIGNAL("triggered()"), QtGui.qApp, QtCore.SLOT("quit()")) > > > > > > > create_tray_icon() > > > > > > > self.composeAction.setEnabled(visible) > > > > > > QtGui.QWidget.setVisible(self, visible) > > > > > > > self.trayIcon.show() > > > > > > > def create_tray_icon(self): > > > > > > self.trayIconMenu = QtGui.QMenu(self) > > > > > > self.trayIconMenu.addAction(self.composeAction) > > > > > > self.trayIcon = QtGui.QSystemTrayIcon(self) > > > > > > self.trayIcon.setContextMenu(self.trayIconMenu) > > > > > > self.trayIcon.setIcon(bad.svg) > > > > > > > app = QtGui.QApplication(sys.argv) > > > > > > sys.exit(app.exec_()) > > > > > > OK, I messed around with it some more, and it works. I just don't > > > > > know how to set an icon, and the example doesn't help at all. > > > > > > Here is the code: > > > > > import sys > > > > > from PyQt4 import QtCore, QtGui > > > > > > class Systray(QtGui.QWidget): > > > > > def __init__(self): > > > > > QtGui.QWidget.__init__(self) > > > > > > self.createActions() > > > > > self.createTrayIcon() > > > > > > #QtCore.QObject.connect(self.trayIcon, > > > > > QtCore.SIGNAL("messageClicked()"), self.messageClicked) > > > > > #QtCore.QObject.connect(self.trayIcon, > > > > > QtCore.SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), > > > > > self.iconActivated) > > > > > > self.trayIcon.show() > > > > > > def createActions(self): > > > > > #self.minimizeAction = QtGui.QAction(self.tr("Mi&nimize"), self) > > > > > #QtCore.QObject.connect(self.minimizeAction, > > > > > # QtCore.SIGNAL("triggered()"), self, QtCore.SLOT("hide()")) > > > > > > #self.maximizeAction = QtGui.QAction(self.tr("Ma&ximize"), self) > > > > > #QtCore.QObject.connect(self.maximizeAction, > > > > > # QtCore.SIGNAL("triggered()"), self, > > > > > # QtCore.SLOT("showMaximized()")) > > > > > > #self.restoreAction = QtGui.QAction(self.tr("&Restore"), self) > > > > > #QtCore.QObject.connect(self.restoreAction, > > > > > # QtCore.SIGNAL("triggered()"), self, > > > > > # QtCore.SLOT("showNormal()")) > > > > > > self.quitAction = QtGui.QAction(self.tr("&Quit"), self) > > > > > QtCore.QObject.connect(self.quitAction, QtCore.SIGNAL("triggered()"), > > > > > QtGui.qApp, QtCore.SLOT("quit()")) > > > > > > def createTrayIcon(self): > > > > > self.trayIconMenu = QtGui.QMenu(self) > > > > > #self.trayIconMenu.addAction(self.minimizeAction) > > > > > #self.trayIconMenu.addAction(self.maximizeAction) > > > > > #self.trayIconMenu.addAction(self.restoreAction) > > > > > #self.trayIconMenu.addSeparator() > > > > > self.trayIconMenu.addAction(self.quitAction) > > > > > > self.trayIcon = QtGui.QSystemTrayIcon(self) > > > > > self.trayIcon.setContextMenu(self.trayIconMenu) > > > > > > app = QtGui.QApplication(sys.argv) > > > > > x = Systray() > > > > > sys.exit(app.exec_()) > > > > > > How would I go about setting the icon? > > > > > Sorry, here is the code with commented out lines removed: > > > > > import sys > > > > from PyQt4 import QtCore, QtGui > > > > > class Systray(QtGui.QWidget): > > > > def __init__(self): > > > > QtGui.QWidget.__init__(self) > > > > > self.createActions() > > > > self.createTrayIcon() > > > > > self.trayIcon.show() > > > > > def createActions(self): > > > > > self.quitAction = QtGui.QAction(self.tr("&Quit"), self) > > > > QtCore.QObject.connect(self.quitAction, QtCore.SIGNAL("triggered()"), > > > > QtGui.qApp, QtCore.SLOT("quit()")) > > > > > def createTrayIcon(self): > > > > self.trayIconMenu = QtGui.QMenu(self) > > > > self.trayIconMenu.addAction(self.quitAction) > > > > > self.trayIcon = QtGui.QSystemTrayIcon(self) > > > > self.trayIcon.setContextMenu(self.trayIconMenu) > > > > > app = QtGui.QApplication(sys.argv) > > > > x = Systray() > > > > sys.exit(app.exec_()) > > > > I believe the method you want is QSystemTrayIcon.setIcon. > > > I found that, but what do I pass into it? Passing a string to a .svg > > file doesn't work. > > http://www.riverbankcomputing.com/Docs/PyQt4/html/qsystemtrayicon.htm... > > So, you must pass a QIcon. > > Now, the doc of QIcon:http://www.riverbankcomputing.com/Docs/PyQt4/html/qicon.html > > Oh, the list of supported file format is described separately in:http://www.riverbankcomputing.com/Docs/PyQt4/html/qimagereader.html#s... > > I see that svg is not part of that list. So, it is not surprising that > it does not work but there are plenty of other formats that will work. Well, you can use the QtSvg module to add support for them. > > It took me about 20 seconds to solve your problem by reading the > appropriate documentation. I suggest you do that too in the future... > > regards, > > Philippe From grante at visi.com Wed Apr 2 17:19:48 2008 From: grante at visi.com (Grant Edwards) Date: Wed, 02 Apr 2008 16:19:48 -0500 Subject: april fools email backfires References: <7xbq4sf9wv.fsf@ruckus.brouhaha.com> Message-ID: On 2008-04-02, D'Arcy J.M. Cain wrote: > I nearly fell off my chair when I read this one. > > WE EXPECT FULL CHARACTER SET SUPPORT FOR EBCDIC AND A LARGE SUBSET > OF ASCII IN THE 1.34 RELEASE. TIHS WILL INCLUDE SUPPORT FOR SPECIAL CHR > SUCH AS THE EURO SYMBOL AND LOWER CASE LETTERS. Just don't hold your breath waiting for curly braces... -- Grant Edwards grante Yow! It's NO USE ... I've at gone to "CLUB MED"!! visi.com From grante at visi.com Wed Apr 2 13:29:58 2008 From: grante at visi.com (Grant Edwards) Date: Wed, 02 Apr 2008 12:29:58 -0500 Subject: april fools email backfires References: <7xbq4sf9wv.fsf@ruckus.brouhaha.com> Message-ID: On 2008-04-02, Paul Rubin wrote: > Django, pah. They should switch to something REALLY advanced: > > http://www.coboloncogs.org/INDEX.HTM ROTFLMAO! That's absolutely brilliant! I particularly like the flashing effect that simulates an old screen-at-time mode terminal (or maybe a storage-scope terminal?), and the faint "burn-in" text in the background. -- Grant Edwards grante Yow! I'm having an at EMOTIONAL OUTBURST!! But, visi.com uh, WHY is there a WAFFLE in my PAJAMA POCKET?? From xng at xs4all.nl Sat Apr 5 22:04:12 2008 From: xng at xs4all.nl (Martin P. Hellwig) Date: Sun, 06 Apr 2008 04:04:12 +0200 Subject: sys.path and importing modules from other directories Message-ID: <47f82f9e$0$15728$e4fe514c@dreader26.news.xs4all.nl> Hello all, I had some troubles in the past how to arrange my packages and modules, because I usually don't develop my stuff in the Lib\site-packages directory I have some troubles when importing depending modules that are in 'sibling' directories. Like in the following scenario: pkg_root\ -__init__ - common\ - - __init__ - - something - other\ - - __init__ - - working_on So when I am busy with 'working_on' and want to import from common something it won't let me do that because I don't have pkg_root in my path. No biggy here, I just add the pkg_root to the path. Once I am finished most of the time all modules are initiated from a module directly at the pkg_root level so then importing works without worries. However it has irritated me enough that I wrote a little script I called 'relative_path.py' that I put in my python path that does these things for me, so that I only need to import that one and set the parent path, probably I missed a point here somewhere but if not maybe somebody else finds it useful. So while I am developing the depending modules, these modules begin with: import relative_path relative_path.add_package_root() +++ import os, sys def getparent(depth=0): "Returns the absolute pathname of (grand)parents directory." # By default it returns the current working directory. # The level of 'grand' is set by depth. getcwd = os.getcwd sep = os.sep abspath = os.path.abspath if depth == 0: grand = None else: grand = depth * -1 # Main function # From the current working directory get the absolute path, # split it and join the wanted portion of the list. pathname = sep.join(abspath(getcwd()).split(sep)[:grand]) # Make sure to throw an exception if depth results in an empty string. if len(pathname) == 0: raise_string = "(grand)Parent depth of %s is before root." % depth raise(LookupError(raise_string)) else: return(pathname) def add_package_root(directory=1): "Add a parent directory relative to cwd to sys.path, default the first." sys.path.append(getparent(directory)) +++ -- mph From stef.mientki at gmail.com Wed Apr 2 16:32:39 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Wed, 02 Apr 2008 22:32:39 +0200 Subject: Python in High School In-Reply-To: <58deb8b8-bae9-4d43-b973-3d90846726cb@b5g2000pri.googlegroups.com> References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> <58deb8b8-bae9-4d43-b973-3d90846726cb@b5g2000pri.googlegroups.com> Message-ID: <47F3ED67.90300@gmail.com> John Henry wrote: > On Apr 1, 11:10 am, sprad wrote: > >> On Apr 1, 11:41 am, mdomans wrote: >> >> >>> Python needs no evangelizing but I can tell you that it is a powerfull >>> tool. I prefer to think that flash is rather visualization tool than >>> programing language, and java needs a lot of typing and a lot of >>> reading. On the other hand python is simple to read and write, can be >>> debuged easily, is intuitive and saves a lot of time. It also supports >>> batteries included policy and you can't get more OO than python. >>> >> One advantage of Flash is that we can have something moving on the >> screen from day one, and add code to it piece by piece for things like >> keyboard or mouse control, more and more complex physics, etc. Is >> there an equivalent project in Python? >> > > I downloaded the "How to Think Like a Python Programmer" book and read > it. I think it's a fine reference book for the purpose you > indicated. > > Here's my 2 cents on the subject. > > I had been a volunteer mentor to my son's middle school robotic team > for several years and I have some experiences, therefore, in how kids > react to "programming". Granted, high school kids are "bigger kids" - > but they are kids nevertheless. > > Last summer, I experimented teaching my own kid Python. He was in 7th > grade going onto 8th grade. He was the main goto person for the > robotic team and had no trouble learning the common applications such > as the Microsoft Office suite, and had some experience in ICONic > programming (Lego Mindstorm). So, I tried to see what would happen if > he tries to learn Python - using somewhat similar approach you are > taking: start with something visually appealing on day one. Instead > of Flash, I used Pythoncard - a no-brainer Python GUI construction > toolkit. He was really excited seeing how easy it was to have tic-tae- > toe type program up so easily (we are taking minutes - not hours) and > was very interested and motivated to continue. So far so good. > However, once I start teaching him variables, expressions, loops, and > what not, I found that (by surprise) he had great difficulties > catching on. Not soon after that, we had to quit. > > We - as adults - take many things for granted and sometimes don't > remember, or don't understand how kids learn. My experience tells me > that in order to teach today's video game generation of kids, the > approach really has to be entirely visual. After I abandoned my > attempt to teach my kid Python, I started them on Robolab - a > simplified version of LabView and to my delight, they were able to > cook up a few simple programs (like fibonacci series and so forth) > without too much effort - although my own kid had some minor trouble > understanding the concept of a container (LabView's version of a > variable). > > I don't know if you have access to LabView or Robolab or similar > packages but if you do, I would highly recommend those. LabView is > every bit as powerful, full-featured, and "real-life" as many of the > other languages and I believe that kids will have a much easier time > learning computer programming with it. > Well I doubt it's the visual environment that makes it more easy, color, shape and position can give some extra information though. I think apriori domain knowledge and flattness of information are of far more importance. The first issue is covered quit well by Robolab / Labview, but the second issue certainly is not. I'm right now working on a Labview like editor in Python, which does obey the demand for flatness of information. The first results can be seen here: http://oase.uci.kun.nl/~mientki/data_www/pylab_works/pw_animations_screenshots.html cheers, Stef Mientki > And you are going to teach them Java? Oh, please don't. Let the > colleges torture them. :=) > From arnlen at mac.com Wed Apr 30 10:15:50 2008 From: arnlen at mac.com (Jumping Arne) Date: Wed, 30 Apr 2008 16:15:50 +0200 Subject: PIL and IPTC Message-ID: <0001HW.C43E4BB60060D69EB01AD9AF@news.individual.de> I'm completely new to PIL and I'm trying to read IPTC info, I understand that it's possible but I can't find out how (and for once Google doesn't seem to be able to help). Does anyone have an example of how it's done? From paul.anton.letnes at gmail.com Wed Apr 9 16:13:59 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Wed, 9 Apr 2008 22:13:59 +0200 Subject: wrapping C functions in python Message-ID: Hello etc. I am a "scientific" user of Python, and hence have to write some performance critical algorithms. Right now, I am learning Python, so this is a "newbie" question. I would like to wrap some heavy C functions inside Python, specifically a wavelet transform. I am beginning to become aquainted with the functions PyArg_ParseTuple() and Py_BuildValue(). However, I am unable to figure out how to pass Python list -> C function or C array -> return value in Python. I manage to build and run the C function, print to screen, pass string as argument, return an int, etc. The thing which is missing is the magic array/list... Thanks in advance! I fart in your general direction. Paul. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdw at distorted.org.uk Wed Apr 23 10:38:45 2008 From: mdw at distorted.org.uk (Mark Wooding) Date: Wed, 23 Apr 2008 14:38:45 +0000 (UTC) Subject: [Python 2.4/2.5] subprocess module is sorely deficient? References: <811891.72800.qm@web39208.mail.mud.yahoo.com> Message-ID: Harishankar wrote: > On Wednesday 23 Apr 2008 15:11:21 Ben Kaplan wrote: >> I don't know about all Linux distros, but my Ubuntu machine (8.04 Beta), >> has the 'TERM' (xterm) and 'COLORTERM' (gnome-terminal) keys in os.environ. > This is set on Debian too. Thanks. I should be able to use this environment > variable on most Linux distributions, I suspect. No! The TERM variable is not the name of a terminal emulation program! It's a terminal name intended to be looked up in the termcap and/or terminfo databases. For example, I use pterm as my terminal, but it (correctly) sets TERM=xterm. I'd suggest trying to run (in order, until one actually works): $X_TERMINAL_EMULATOR, sensible-x-terminal-emulator, x-terminal-emulator, xterm. -- [mdw] From pauljefferson at gmail.com Mon Apr 28 14:45:42 2008 From: pauljefferson at gmail.com (Paul Jefferson) Date: Mon, 28 Apr 2008 19:45:42 +0100 Subject: Newbie Help - Alarms Message-ID: Hi, I'm new to this having previously done some programming in Game Maker. In Game Maker there was a function (Alarm) that lets you run a block of code run every x seconds without freezing up the whole program waiting for it. Is there an equavalant for this built in Python beacuse I can't find it? Thanks for any help, Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: From bockman at virgilio.it Sat Apr 5 09:22:19 2008 From: bockman at virgilio.it (Francesco Bochicchio) Date: 05 Apr 2008 13:22:19 GMT Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> Message-ID: <47f77d0a$0$17945$5fc30a8@news.tiscali.it> Il Fri, 04 Apr 2008 20:26:13 -0700, 7stud ha scritto: > On Apr 4, 7:06?pm, skanem... at yahoo.se wrote: >> 1st question: >> >> when i run this program 1 will be printed into the interpreter when i >> run it BUT without me clicking the actual button. when i then click the >> button "1", nothing happens. >> >> obv i dont want any output when i dont push the button but i want it >> when i do. >> >> what am i doing wrong here? >> ... > > The same thing is happening in this portion of your code: > > command = self.Display(1) > > That code tells python to execute the Display function and assign the > function's return value to the variable command. As a result Display > executes and 1 is displayed. Then since Dispay does not have a return > statement, None is returned, and None is assigned to command. Obviously, > that is not what you want to do. > > What you want to do is assign a "function reference" to command so that > python can execute the function sometime later when you click on the > button. A function reference is just the function name without the '()' > after it. So you would write: > > command = self.Display > > But writing it like that doesn't allow *you* to pass any arguments to > Display(). In addition, *tkinter* does not pass any arguments to > Display when tkinter calls Display in response to a button click. As a > result, there is no way to pass an argument to Display. > It should be added here that in Python you have several ways get around this Tkinter limitation and pass an user argument to the callback. Once upon a time , back in Python 1.x, I used to do something like this: class CallIt: def __init__(self, f, *args): self.f = f self.args = args def __call__(self): return apply(self.f, self.args) and then, to do what the OP wanted to do: command = CallIt(self.Display, 1) but nowadays, you can achieve the same effect with: command = functtools.partial(self.Display,1) Ciao ---- FB From grflanagan at gmail.com Mon Apr 21 08:23:40 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Mon, 21 Apr 2008 05:23:40 -0700 (PDT) Subject: manipulating class attributes from a decorator while the class is being defined References: Message-ID: On Apr 19, 11:19 pm, Wilbert Berendsen wrote: > Hi, is it possible to manipulate class attributes from within a decorator > while the class is being defined? > > I want to register methods with some additional values in a class attribute. > But I can't get a decorator to change a class attribute while the class is > still being defined. Something like: > > class Parser(object): > > regexps = [] > def reg(regexp): > def deco(func): > regexps.append((regexp, func)) > return func > return deco > > @reg(r'".*"') > def quoted_string(self): > pass > > How can I reach the class attribute `regexps' from within a decorator? > > Thanks for any help, > Wilbert Berendsen > > --http://www.wilbertberendsen.nl/ > "You must be the change you wish to see in the world." > -- Mahatma Gandhi --------------------------------------------------- def reg(regexp): def deco(func): def inner(self, *args, **kw): if not hasattr(self, 'regexps'): self.regexps = [] self.regexps.append((regexp, func)) return func(self, *args, **kw) return inner return deco class Parser(object): regexps = [] @reg(r'".*"') def quoted_string(self): print 'hi' p = Parser() p.quoted_string() print p.regexps --------------------------------------------------- From arnodel at googlemail.com Thu Apr 24 16:33:07 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 24 Apr 2008 21:33:07 +0100 Subject: Parsing text file with #include and #define directives References: Message-ID: python at bdurham.com writes: > I'm parsing a text file for a proprietary product that has the following > 2 directives: > > #include > #define > > Defined constants are referenced via <#name#> syntax. > > I'm looking for a single text stream that results from processing a file > containing these directives. Even better would be an iterator(?) type > object that tracked file names and line numbers as it returns individual > lines. > > Is there a Python parsing library to handle this type of task or am I > better off writing my own? > > The effort to write one from scratch doesn't seem too difficult (minus > recursive file and constant loops), but I wanted to avoid re-inventing > the wheel if this type of component already exists. > > Thank you, > > Malcolm I think it's straightforward enough to be dealt with simply. Here is a solution that doesn't handle errors but should work with well-formed input and handles recursive expansions. expand(filename) returns an iterator over expanded lines in the file, inserting lines of included files. import re def expand(filename): defines = {} def define_repl(matchobj): return defines[matchobj.group(1)] define_regexp = re.compile('#(.+?)#') for line in open(filename): if line.startswith('#include '): recfilename = line.strip().split(None, 1)[1] for recline in expand(recfilename): yield recline elif line.startswith('#define '): _, name, value = line.strip().split(None, 2) defines[name] = value else: yield define_regexp.sub(define_repl, line) It would be easy to modify it to keep track of line numbers and file names. HTH -- Arnaud From adelagon at gmail.com Thu Apr 10 03:17:59 2008 From: adelagon at gmail.com (Alvin Delagon) Date: Thu, 10 Apr 2008 15:17:59 +0800 Subject: PyArg_ParseTuple for structs or binary data Message-ID: <7a01f6c00804100017u116dc4c3oc3a95f634663a5cb@mail.gmail.com> Hello Gabriel, I just recently discovered that struct.pack does return a string. Everything works fine now. Thanks for the heads up! static PyObject * sendMessage(PyObject *self, PyObject *args) { char *msg = ""; int len; if (!PyArg_ParseTuple(args, "s#", &msg, &len)) return NULL; ret = sctp_sendmsg(connSock, msg, len, 0, 0, 0x03000000, 0, 0x01, 0, 0); return Py_BuildValue("l", ret); } --- Alvin Delagon -------------- next part -------------- An HTML attachment was scrubbed... URL: From info at wingware.com Mon Apr 28 11:28:57 2008 From: info at wingware.com (Wingware) Date: Mon, 28 Apr 2008 11:28:57 -0400 Subject: Wing IDE 3.0.5 released Message-ID: <4815ED39.2080502@wingware.com> Hi, We're happy to announce version 3.0.5 of Wing IDE, an integrated development environment for the Python programming language. It is available from: http://wingware.com/downloads Version 3.0.5 is a bug fix release that adds many vi mode improvements, improves stability, and fixes other usability bugs. See the change log at http://wingware.com/pub/wingide/3.0.5/CHANGELOG.txt for details. It is a free upgrade for all Wing 3.0 users. *About Wing IDE* Wing IDE is an integrated development environment for the Python programming language. It provides powerful debugging, editing, code intelligence, testing, and search capabilities that reduce development and debugging time, cut down on coding errors, and make it easier to understand and navigate Python code. New features added in Wing 3.0 include: * Multi-threaded debugger * Debug value tooltips in editor, debug probe, and interactive shell * Autocompletion and call tips in debug probe and interactive shell * Automatically updating project directories * Testing tool, currently supporting unittest derived tests (*) * OS Commands tool for executing and interacting with external commands (*) * Rewritten indentation analysis and conversion (*) * Introduction of Wing IDE 101, a free edition for beginning programmers * Available as a .deb package for Debian and Ubuntu * Support for Stackless Python * Support for 64 bit Python on Windows and Linux (*)'d items are available in Wing IDE Professional only. System requirements are Windows 2000 or later, OS X 10.3.9 or later for PPC or Intel (requires X11 Server), or a recent Linux system (either 32 or 64 bit). *Purchasing and Upgrading* Wing IDE Professional & Wing IDE Personal are commercial software and require a license to run. To upgrade a 2.x license or purchase a new 3.x license: Upgrade https://wingware.com/store/upgrade Purchase https://wingware.com/store/purchase Any 2.x license sold after May 2nd 2006 is free to upgrade; others cost 1/2 the normal price to upgrade. -- The Wingware Team Wingware | Python IDE Advancing Software Development www.wingware.com From arnodel at googlemail.com Fri Apr 25 01:11:45 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Fri, 25 Apr 2008 06:11:45 +0100 Subject: Class Inheritance - What am I doing wrong? References: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> <613bc152-a6f4-4db4-8f90-593cb3f629c7@s33g2000pri.googlegroups.com> Message-ID: Brian Munroe writes: > Ok, so thanks everyone for the helpful hints. That *was* a typo on my > part (should've been super(B...) not super(A..), but I digress) > > I'm building a public API. Along with the API I have a few custom > types that I'm expecting API users to extend, if they need too. If I > don't use name mangling, isn't that considered bad practice (read not > defensive programming) to not protect those 'private' fields? The problem is that you are using name mangling for an attribute which is accessed by several generations of a class hierarchy. Name mangling is only useful for attributes you *don't* want to share with subclasses (or bases). In python, use attributes starting with a single underscore (such as _name). It tells users that they shouldn't mess with them. By design, python doesn't include mechanisms equivalent to the Java / C++ 'private'. -- Arnaud From arnlen at mac.com Wed Apr 16 06:21:13 2008 From: arnlen at mac.com (Jumping Arne) Date: Wed, 16 Apr 2008 12:21:13 +0200 Subject: Image handling - stupid question Message-ID: <0001HW.C42B9FB90009B7E8B01AD9AF@news.individual.de> I'm going to try to write some imange manipulation code (scaling, reading EXIF and IPTC info) and just want to ask if PIL is *THE* library to use? I looked at and noticed that the latest version is from Dec 2006. In my experience that means that either it's abandoned or that it's very good and stable. From mnordhoff at mattnordhoff.com Tue Apr 8 11:27:23 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Tue, 08 Apr 2008 15:27:23 +0000 Subject: import statement convention In-Reply-To: <4078bcf4-e68f-45d4-93ce-335ec7a33c5a@v32g2000prd.googlegroups.com> References: <4078bcf4-e68f-45d4-93ce-335ec7a33c5a@v32g2000prd.googlegroups.com> Message-ID: <47FB8EDB.9040903@mattnordhoff.com> MartinRinehart at gmail.com wrote: > By convention, I've read, your module begins with its import > statements. Is this always sensible? > > I put imports that are needed for testing in the test code at the end > of the module. If only a bit of the module has a visual interface, why > pollute the global namespace with 'from Tkinter import *'? Wouldn't > that be better done in a separate class or function? > > Can we do a better job with a thoughtful rewrite of this convention? I don't think anyone has been beheaded for breaking from convention when there's a good reason... The Zen of Python does say "Although practicality beats purity.". (One useful related thing is the lazy import modules developed by e.g. Bazaar and Mercurial, where you can "import foo" at the top level, but the import won't really be done until it's actually used.) -- From frikker at gmail.com Wed Apr 23 12:09:37 2008 From: frikker at gmail.com (blaine) Date: Wed, 23 Apr 2008 09:09:37 -0700 (PDT) Subject: Unix Device File Emulation References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> Message-ID: On Apr 23, 11:17 am, "Ville M. Vainio" wrote: > blaine wrote: > > example usage: echo 'line 0 0 10 10' > /dev/screen > > > On the actual embedded device this is handled by a kernel module. We > > can spit commands into it as fast as we can and the kernel module can > > keep up. This is typical unix device file behavior. > > > Any suggestions or advice would be splendid. Thanks! > > Assuming you are on unix, have you considered FIFO's, os.mkfifo()? Thank you - this is exactly what I need, I believe. I'm having a problem though. The os.mkfifo() works fine, but when I read from the file my blocking calls dont work as intended... See below: # Fake Nokia Screen Emulator import sys, os class nokia_fkscrn: def __init__(self, file): if not os.path.exists(file): os.mkfifo(file) self.fifodev = open(file, 'r') def read(self): while 1: r = self.fifodev.readline() print r nokia = nokia_fkscrn('dev.file') nokia.read() This works at first, but when I write to the 'dev.file' for the first time, the text is displayed as intended, but then the program just keeps spitting out blank lines. I can continue to write to the file (using echo 'test\n' > dev.file) and this shows up in my output, but amist a giant mass of scrolling blank lines. This also causes my CPU usage to shoot up to 100%. Any ideas? This is OS X 10.4 -Blaine From tim.arnold at sas.com Thu Apr 24 12:48:18 2008 From: tim.arnold at sas.com (Tim Arnold) Date: Thu, 24 Apr 2008 12:48:18 -0400 Subject: convert xhtml back to html References: Message-ID: "Arnaud Delobelle" wrote in message news:m28wz3cjd1.fsf at googlemail.com... > "Tim Arnold" writes: > >> hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop >> to >> create CHM files. That application really hates xhtml, so I need to >> convert >> self-ending tags (e.g.
) to plain html (e.g.
). >> >> Seems simple enough, but I'm having some trouble with it. regexps trip up >> because I also have to take into account 'img', 'meta', 'link' tags, not >> just the simple 'br' and 'hr' tags. Well, maybe there's a simple way to >> do >> that with regexps, but my simpleminded )]+/> doesn't work. I'm >> not >> enough of a regexp pro to figure out that lookahead stuff. > > Hi, I'm not sure if this is very helpful but the following works on > the very simple example below. > >>>> import re >>>> xhtml = '

hello spam
bye

' >>>> xtag = re.compile(r'<([^>]*?)/>') >>>> xtag.sub(r'<\1>', xhtml) > '

hello spam
bye

' > > > -- > Arnaud Thanks for that. It is helpful--I guess I had a brain malfunction. Your example will work for me I'm pretty sure, except in some cases where the IMG alt text contains a gt sign. I'm not sure that's even possible, so maybe this will do the job. thanks, --Tim From ricky.zhou at gmail.com Tue Apr 8 00:09:36 2008 From: ricky.zhou at gmail.com (Ricky Zhou) Date: Tue, 8 Apr 2008 00:09:36 -0400 Subject: Newbie: How to pass a dictionary to a function? In-Reply-To: <516e07d1-91f9-462b-9fc0-ac6d1e474f9d@n14g2000pri.googlegroups.com> References: <516e07d1-91f9-462b-9fc0-ac6d1e474f9d@n14g2000pri.googlegroups.com> Message-ID: <20080408040936.GR32030@Max> On 2008-04-07 08:54:09 PM, BonusOnus wrote: > How do I pass a dictionary to a function as an argument? > > > # Say I have a function foo... > def foo (arg=[]): Try: def foo(arg={}): Thanks, Ricky -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available URL: From p at ulmcnett.com Fri Apr 25 14:54:23 2008 From: p at ulmcnett.com (Paul McNett) Date: Fri, 25 Apr 2008 11:54:23 -0700 Subject: Why is None <= 0 In-Reply-To: References: Message-ID: <481228DF.5010408@ulmcnett.com> Gregor Horvath wrote: > >>> None <= 0 > True More accurately: >>> None < 0 True > Why? > Is there a logical reason? None is "less than" everything except for itself: >>> None < 'a' True >>> None < False True >>> None == None True In my humble opinion, I think that comparisons involving None should return None, but I trust that the designers came up with this for very good reasons. As far as I know I've never been bitten by it. Paul From fn681 at ncf.ca Sun Apr 6 17:03:55 2008 From: fn681 at ncf.ca (Colin J. Williams) Date: Sun, 06 Apr 2008 18:03:55 -0300 Subject: A funnily inconsistent behavior of int and float In-Reply-To: References: Message-ID: Grant Edwards wrote: > On 2008-04-06, Lie wrote: > >> I've noticed some oddly inconsistent behavior with int and float: >> >> Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) >> [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 >>>>> int('- 345') >> -345 >> >> works, > > IMO, it oughtn't. Agreed it seems inconsistent with the integer literal syntax Python 2.5 Docs: 2.4.4 Integer and long integer literals Python 3.0 doesn't appear to spell out the literal syntax. It would be helpful if it did. Colin W. [snip] From bvidinli at gmail.com Thu Apr 24 04:36:52 2008 From: bvidinli at gmail.com (bvidinli) Date: Thu, 24 Apr 2008 11:36:52 +0300 Subject: [Python-Dev] annoying dictionary problem, non-existing keys In-Reply-To: References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> Message-ID: <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> I posted to so many lists because, this issue is related to all lists, this is an idea for python, this is related to development of python... why are you so much defensive ? i think ideas all important for development of python, software.... i am sory anyway.... hope will be helpful. 2008/4/24, Terry Reedy : > Python-dev is for discussion of development of future Python. Use > python-list / comp.lang.python / gmane.comp.python.general for usage > questions. > > > > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: http://mail.python.org/mailman/options/python-dev/bvidinli%40gmail.com > -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From bruno.42.desthuilliers at websiteburo.invalid Mon Apr 14 04:03:58 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Mon, 14 Apr 2008 10:03:58 +0200 Subject: Java or C++? In-Reply-To: References: Message-ID: <48030fd7$0$27271$426a74cc@news.free.fr> s0suk3 at gmail.com a ?crit : > Hello, I was hoping to get some opinions on a subject. I've been > programming Python for almost two years now. Recently I learned Perl, > but frankly I'm not very comfortable with it. Now I want to move on > two either Java or C++, but I'm not sure which. Which one do you think > is a softer transition for a Python programmer? Which one do you think > will educate me the best? if it's for educational purpose, then you have absolutely nothing to learn from Java. On the hi-level languages side, I'd rather recommend Haskell or OCaml (functional programming) and/or Erlang (concurrent programming). And if you want to go the 'close to the metal' way, then better to learn C. My 2 cents... From deets at nospam.web.de Wed Apr 9 08:33:48 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 09 Apr 2008 14:33:48 +0200 Subject: I am worried about Python 3 References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> Message-ID: <663re9F2i3ikcU1@mid.uni-berlin.de> jmDesktop wrote: > I am a new Python programmer. I have always desired to learn Python, > but have never had the opportunity. Recently this has changed, and I > have an opportunity to get away from the .NET framework. I found > Django (and other web frameworks) and began my quest to learn. I > started reading Dive Into Python and anything I could find and started > participating here in usenet. Then I had to read this: > > http://www.comp.leeds.ac.uk/nde/papers/teachpy3.html > > I think that every time I start a new technology (to me) it is about > to change. Yes, I know that is the nature of things, but I'm always > at the start of "something new." > > If I continue in Python 2.5.x, am I making a mistake? Is it really > that different? > > Here is an excerpt that is causing me concern: > > Two new versions of the language are currently in development: version > 2.6, which retains backwards compatibility with previous releases; and > version 3.0, which breaks backwards compatibility to the extent that > even that simplest of programs, the classic 'Hello, World', will no > longer work in its current form. > > It makes me feel like I am wasting my time and makes it difficult to > justify spending time on projects using 2.5.x and using it where I > work. The above statement is greatly exaggerated. Yes, print will become a function so print "hello world" won't work anymore. But most of python will stay the same, and you certainly don't waste time. Learning 2.x is perfectly sensible, as it is the stable version supported by e.g. providers and of course the community - and will be so for years to come. Diez From http Sat Apr 5 16:09:35 2008 From: http (Paul Rubin) Date: 05 Apr 2008 13:09:35 -0700 Subject: Tkinter, add pressed buttons onto string display string, how to? References: Message-ID: <7xr6dkrrls.fsf@ruckus.brouhaha.com> skanemupp at yahoo.se writes: > using tkinter and python i now have a small App (that will hopefully > soon be a fully functioning calculator) where u can push buttons and > the corresponding number or operator is shown. I wrote something like that a long time ago, one of my first python scripts. http://nightsong.com/phr/python/calc.py From gagsl-py2 at yahoo.com.ar Wed Apr 23 01:16:24 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 23 Apr 2008 02:16:24 -0300 Subject: IDLE gripe and question References: <95f218ba-4925-491a-bf9c-047ac201e0c7@2g2000hsn.googlegroups.com> Message-ID: En Wed, 23 Apr 2008 01:30:47 -0300, Mensanator escribi?: > On Apr 22, 7:42?pm, Dick Moores wrote: >> I have IDLE 1.2.1, on Win XP, Python 2.5.1. >> >> The first time I use File | Open to open a script, the Open dialogue >> box always opens at E:\Python25\Lib\idlelib. Most of the scripts I >> want to access are in E:\PythonWork. There doesn't seem to be a way >> to change the default folder to E:\PythonWork, but is there? > > First, find the shortcut that lauches IDLE. > > On my Vista system it's in > C:\Program Data\Microsoft\Windows\Start Menu\Programs\Python 2.5 > > XP will be different, I think there're start menu directories under > each user and a default one. That's the way to go. But note that you don't have to find where the shortcut lives: just navigate to the desired menu item in the Start menu, right-click on it and select Properties. -- Gabriel Genellina From yzghan at gmail.com Tue Apr 22 17:54:37 2008 From: yzghan at gmail.com (yzghan at gmail.com) Date: Tue, 22 Apr 2008 14:54:37 -0700 (PDT) Subject: python has memory leak? Message-ID: <1d48c77d-cc93-41ce-b644-1a8e52713e1d@b64g2000hsa.googlegroups.com> Hi all, I feel that my python script is leaking memory. And this is a test I have: log.write("[" + timestamp() + "] " + "test() ... memory usage: " + " ".join(repr(i/(1024*1024)) for i in getMemInfo()) + "\n") m = {} i = 1000*1000 while i > 0: i = i - 1 m.setdefault(i, []).append(i) log.write("[" + timestamp() + "] " + "test() ... memory usage: " + " ".join(repr(i/(1024*1024)) for i in getMemInfo()) + "\n") m = {} log.write("[" + timestamp() + "] " + "test() done. memory usage: " + " ".join(repr(i/(1024*1024)) for i in getMemInfo()) + "\n") >From which I got: [17:44:50] test() ... memory usage: 55L 55L [17:44:53] test() ... memory usage: 143L 143L [17:44:53] test() done. memory usage: 125L 143L In the above code getMemInfo is my func to return current and peak memory usage in bytes. Can some expert explain how python manages memory? The version of my python is: Python 2.4.4 Stackless 3.1b3 060516 (#71, Oct 31 2007, 14:22:28) [MSC v.1310 32 bit (Intel)] on win32 Many thanks, GH From fredrik at pythonware.com Sat Apr 5 07:29:27 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 13:29:27 +0200 Subject: In Tkinter - having an input and an entry In-Reply-To: References: Message-ID: markfernandes02 at googlemail.com wrote: > I can fetch records but cannot insert records. > > def Insert(self, *row): > global cursor, title, author, pubdate using globals to pass arguments to a function/method is usually not a good idea. any reason you cannot pass them in as arguments? > sqlInsert = "INSERT INTO Book_table" > sqlInsert = sqlInsert + "(Bookname, BookAutor, " > sqlInsert = sqlInsert + "Publicationdate) VALUES ('" > sqlInsert = sqlInsert + title + "', '" > sqlInsert = sqlInsert + author + "', " > sqlInsert = sqlInsert + pubdate + ") " > myconn = odbc.odbc('accessDatabase') if you're doing multiple insertions, it's usually better to connect once and reuse the connection object. > cursor = myconn.cursor() > cursor.execute(sqlInsert) > myconn.commit() > cursor.close() > myconn.close() > > The above code does not work. define "does not work". do you get a traceback, a database error, some other problem? can you perhaps post the traceback? > Also with Tkinter, i want to have user input records into the db, i > cannot get what the user inputs into the entry to become a string > variable. what did you try? you can get input data from the Entry widget in several ways, including calling the "get" method or using StringVar objects; see http://effbot.org/tkinterbook/entry.htm#patterns for some code snippets. From michele.simionato at gmail.com Wed Apr 30 23:50:43 2008 From: michele.simionato at gmail.com (Michele Simionato) Date: Wed, 30 Apr 2008 20:50:43 -0700 (PDT) Subject: ]ANN[ Vellum 0.16: Lots Of Documentation and Watching References: Message-ID: On Apr 29, 9:51 am, "Zed A. Shaw" wrote: > However, I'm curious to get other people's thoughts. For what concerns the license, I would say that GPL3 is fine: for a tool basically any kind of license is fine, since the tool is external to the code, so this is a minor point. I am curious about two other things, though, perhaps answered in the book but I had no time to read it all. First question: are you saying that vellum does NOT keep track of already built files and recompile everything each time, i.e. it is really in a different ballpark from make and similar build tools? Second question: what about docutils? A Pythonista would expect a documentation tool to use reST and I am sure plenty of us out there have articles/documents (even books) in reST and would be interested in building them. OTOH I would not be interested in learning yet another lightweight markup language or to go back to TeX. Is the Vellum book written in reST? Michele Simionato From wuwei23 at gmail.com Tue Apr 1 21:19:58 2008 From: wuwei23 at gmail.com (alex23) Date: Tue, 1 Apr 2008 18:19:58 -0700 (PDT) Subject: Python Audio PAN (left or right) and channels References: <881813a7-cbbb-48ab-9a4f-53da6fb0a69f@c26g2000prf.googlegroups.com> Message-ID: On Apr 2, 4:04 am, ilgufoeiltuc... at gmail.com wrote: > I need to play mp3 files on different channels and listen Channel 0 on > the left earphone and Channel 1 on the right... > How can I play mp3 files in different channel and pan the output? Hey Mark, Have you taken a look at GStreamer? What you're after could probably be done from a CLI using gstreamer, but it also has python bindings if you're wanting to integrate it with your own code. GStreamer: http://gstreamer.freedesktop.org/ Docs for python bindings: http://pygstdocs.berlios.de/ Hope this helps. - alex23 From steve at holdenweb.com Thu Apr 17 13:53:37 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 17 Apr 2008 13:53:37 -0400 Subject: Can't do a multiline assignment! In-Reply-To: <48077E83.5050404@islandtraining.com> References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <48077E83.5050404@islandtraining.com> Message-ID: Gary Herron wrote: > s0suk3 at gmail.com wrote: >> On Apr 17, 10:54 am, colas.fran... at gmail.com wrote: >> >>> On 17 avr, 17:40, s0s... at gmail.com wrote: >>> >>> Out of sheer curiosity, why do you need thirty (hand-specified and >>> dutifully commented) names to the same constant object if you know >>> there will always be only one object? >>> >> I'm building a web server. The many variables are names of header >> fields. One part of the code looks like this (or at least I'd like it >> to): >> >> class RequestHeadersManager: >> >> # General header fields >> Cache_Control = \ >> Connection = \ >> Date = \ >> Pragma = \ >> Trailer = \ >> Transfer_Encoding = \ >> Upgrade = \ >> Via = \ >> Warning = \ >> >> # Request header fields >> Accept = \ >> Accept_Charset = \ >> Accept_Encoding = \ >> Accept_Language = \ >> Authorization = \ >> ... >> > > But. *What's the point* of doing it this way. I see 14 variables > being assigned a value, but I don't see the value, they are getting. > Reading this bit if code provides no useful information unless I'm > willing to scan down the file until I find the end of this mess. And in > that scanning I have to make sure I don't miss the one single line that > does not end in a backslash. (Your ellipsis conveniently left out the > *one* important line needed to understand what this code is doing, but > even if you had included it, I'd have to scan *all* lines to understand > what a single value is being assigned. > > There is *no way* you can argue that code is clearer than this: > > # General header fields > Cache_Control = None > Connection = None > Date = None > Pragma = None > ... > Thank you, you saved me from making that point. It doesn't even seem like there's a need for each header to reference the same value (though in this case they will, precisely because there is only one None object). regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From george.sakkis at gmail.com Sat Apr 19 20:10:30 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Sat, 19 Apr 2008 17:10:30 -0700 (PDT) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> Message-ID: <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> On Apr 18, 9:36?pm, Ross Ridge wrote: > Ross Ridge said: > > > If you have Python 2.5, here's a faster version: > > > ? ?from struct import * > > ? ?unpack_i32be = Struct(">l").unpack > > > ? ?def from3Bytes_ross2(s): > > ? ? ? ?return unpack_i32be(s + "\0")[0] >> 8 > > Bob Greschke ? wrote: > > > That's not even intelligible. ?I wanna go back to COBOL. :) > > It's the same as the previous version except that it "precompiles" > the struct.unpack() format string. ?It works similar to the way Python > handles regular expressions. I didn't know about the Struct class; pretty neat. It's amazing that this version without Psyco is as fast Bob's version with Psyco! Adding Psyco to it though makes it *slower*, not faster. So here's how I'd write it (if I wanted or had to stay in pure Python): try: import psyco except ImportError: from struct import Struct unpack_i32be = Struct(">l").unpack def from3Bytes(s): return unpack_i32be(s + "\0")[0] >> 8 else: def from3Bytes(s): Value = (ord(s[0])<<16) + (ord(s[1])<<8) + ord(s[2]) if Value >= 0x800000: Value -= 0x1000000 return Value psyco.bind(from3Bytes) HTH, George From kyosohma at gmail.com Wed Apr 30 14:30:17 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 30 Apr 2008 11:30:17 -0700 (PDT) Subject: I messed up my wxPython install (Eclipse Configuration Issue) References: <18eb0a7c-96f4-41de-b44f-95fd8ba0223f@f63g2000hsf.googlegroups.com> <436f8226-64a5-440a-92f4-afd7dd348e1c@m73g2000hsh.googlegroups.com> <20525ad9-2679-4bc8-a117-66eca4a8dc13@r66g2000hsg.googlegroups.com> Message-ID: On Apr 30, 1:09 pm, blaine wrote: > On Apr 30, 1:14 pm, Mike Driscoll wrote: > > > blaine wrote: > > > The wxPython group is a bit stale compared to this group, so I'll give > > > it a shot :) > > > What does that mean? The wxPython group is almost always very quick to > > respond with relevant answers. > > > As to your question, I think Peter is correct. Your wx.py and wx.pyc > > files are masking the wx package. > > > Mike > > I didn't mean anything by it, I promise. This group is just amazing - > there are always very active topics and I get responses in no time. > The wxPython group I noticed only has had recent discussions a few > times in the past month, and their subscribers aren't as high as the > Python group. > That's weird...I subscribe to the wxPython group and I got 10 digests on the 28th. Typically they send out 2-5 digests per day. Where are you getting this information? This looks up-to-date: http://lists.wxwidgets.org/pipermail/wxpython-users/ > That worked. You guys are awesome, thank you! I can't believe I named > that test script wx.py - duh. Thank you for your help! > Blaine No problem. Glad it worked! That's always something to look for when you get that type of error, btw. Mike From rridge at caffeine.csclub.uwaterloo.ca Mon Apr 21 15:42:41 2008 From: rridge at caffeine.csclub.uwaterloo.ca (Ross Ridge) Date: Mon, 21 Apr 2008 15:42:41 -0400 Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: Carl Banks wrote: > If you don't like Python 3, DON'T USE IT. That's the plan. Paul McGuire wrote: >I've read this position a number of times in this and related threads, >and it overlooks one constituency of Python developers - those who >develop and support modules for use by other Python users. As the >supporter of pyparsing, I really can't just "not use" Py3 - ignoring >Py3 means shutting out/holding back those of my users who do want to >use it, and pretty much consigning my module to eventual dustbin >status. Eh. You can ingore it until your users start asking for it. >Ideally, I can implement some form of cross-compatible code >so that I need maintain only a single code base, and I have managed to >do so on a number of fronts (with the help of Robert A. Clark): >- add support for both __bool__ and __nonzero__ (__nonzero__ calls >__bool__, so that upgrading to Py3 actually saves a function call) Doing sometthing like the following would save the function call in both cases: class C(object): def __bool__(self): return False __nonzero__ = __bool__ >- convert isinstance(x,basestring) to isinstance(x,__BASESTRING__) and >dynamically set __BASESTRING__ to basestring or str >- similar treatment for sys.maxint/maxsize -> __MAX_INT__ I don't thiink using double underscores here is appropriate. It suggests it's part of the language. Since "basestring" is no longer part of the language, you could do: if "basestring" not in globals(): basestring = str >Overall, I think I'm getting off pretty easy, but then pyparsing is a >small module with very limited use of the standard lib. Has the standard library changed that much? I thought was it mainly the deletion of old seldom used modules that happens in new releases anyways. >[...] And as much as we all love Python-the-language, language features >alone do not help a language and its community of users to grow >and proliferate. I think most would agree that it is the cornucopia >of libraries that really make Python an environment for developing >production applications. Definately. Ross Ridge -- l/ // Ross Ridge -- The Great HTMU [oo][oo] rridge at csclub.uwaterloo.ca -()-/()/ http://www.csclub.uwaterloo.ca/~rridge/ db // From sjmachin at lexicon.net Fri Apr 18 07:36:28 2008 From: sjmachin at lexicon.net (John Machin) Date: Fri, 18 Apr 2008 11:36:28 GMT Subject: Unicode chr(150) en dash In-Reply-To: <7dae96d4-48c4-46c9-9aa9-33a263b84ca4@26g2000hsk.googlegroups.com> References: <48063434$0$36327$742ec2ed@news.sonic.net> <7dae96d4-48c4-46c9-9aa9-33a263b84ca4@26g2000hsk.googlegroups.com> Message-ID: <480887b8@news.mel.dft.com.au> hdante wrote: > > The character code in question (which is present in the page), 150, > doesn't exist in ISO-8859-1. Are you sure? Consider (re-)reading all of the Wikipedia article. 150 aka \x96 doesn't exist in ISO 8859-1. ISO-8859-1 (two hyphens) is a superset of ISO 8859-1 (one hyphen) and adds the not-very-useful-AFAICT control codes \x80 to \x9F. > See > > http://en.wikipedia.org/wiki/ISO/IEC_8859-1 (the entry for 150 is > blank) You must have been looking at the table of the "lite" ISO 8859-1 (one hyphen). Reading further you will see \x96 described as SPA or "Start of Guarded Area". Then there is the ISO-8859-1 (two hyphens) table, including \x96. HTH, John From patrickkidd.lists at gmail.com Tue Apr 15 21:14:18 2008 From: patrickkidd.lists at gmail.com (Patrick Stinson) Date: Tue, 15 Apr 2008 19:14:18 -0600 Subject: import hooks Message-ID: <664bf2b80804151814g480eed02w739047f84d9deb6b@mail.gmail.com> What's the current way to install an import hook? I've got an embedded app that has a few scripts that I want to import each other, but that are not in sys.modules. I intentionally keep them out of sys.modules because their names will not be unique across the app. They will, however, be unique between scripts that I (do* want to see each other). Basically, I want to return a certain module from a name-based filter. I've already written a type in C with find_module and load_module, but it doesn't seem to work when I add the type to sys.path_hooks. I wrote a simple one that worked just fine from a pure script file run through python.exe. Thanks! -- Patrick Kidd Stinson http://www.patrickkidd.com/ http://pkaudio.sourceforge.net/ http://pksampler.sourceforge.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From torriem at gmail.com Sun Apr 20 18:51:53 2008 From: torriem at gmail.com (Michael Torrie) Date: Sun, 20 Apr 2008 16:51:53 -0600 Subject: close GUI and quit script? In-Reply-To: References: Message-ID: <480BC909.6020205@gmail.com> globalrev wrote: > how do i close a GUI and end the mainloop of the script? >From a GUI callback, instruct the main loop to quit. From juergen.perlinger at t-online.de Sun Apr 20 15:45:02 2008 From: juergen.perlinger at t-online.de (Juergen Perlinger) Date: Sun, 20 Apr 2008 21:45:02 +0200 Subject: socket.AF_INET References: Message-ID: Matt Herzog wrote: > Hi All. > > I'm trying to write a script that will send me an email message when my IP > address changes on a specific NIC. On Linux, the script works. On FreeBSD, > it fails with: > > [snip] > > def get_ip_address(ifname): > s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) > return socket.inet_ntoa(fcntl.ioctl( > s.fileno(), > 0x8915, # SIOCGIFADDR > struct.pack('256s', ifname[:15]) )[20:24]) > [OT: sorry Matt, hit email instead followup twice... stupid me] My bets are that the SIOCGIFADDR opcode has a different numerical value for BSD. Even if some names are portable, the numerical values aren't! I don't have BSD, but using find /usr/include -type f -name '*.h' | xargs grep SIOCGIFADDR /dev/null should give some hints... -- juergen 'pearly' perlinger "It's hard to make new errors!" From pavlovevidence at gmail.com Sat Apr 19 05:56:40 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Sat, 19 Apr 2008 02:56:40 -0700 (PDT) Subject: Python 2.5 adoption References: Message-ID: <4bfdf595-287f-4b66-b062-559d05eb2873@d1g2000hsg.googlegroups.com> On Apr 18, 2:08 pm, Joseph Turian wrote: > How widely adopted is python 2.5? > > We are doing some development, and have a choice to make: > a) Use all the 2.5 features we want. > b) Maintain backwards compatability with 2.4. > > So I guess the question is, does anyone have a sense of what percent > of python users don't have 2.5? One possible barometer for the situation is what's the oldest version of Python to have been supported in the most bug-fix releases? ...In which case you need to maintain backwards compatibility with 2.3. (I bring this up to illustrate that if there are people clamoring for a 2.3 updates, there are probably quite a few supporting 2.4 as well.) Carl Banks From s0suk3 at gmail.com Thu Apr 17 13:46:22 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 10:46:22 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <42402158-0b16-42e2-b7a0-9d9a15e8196d@24g2000hsh.googlegroups.com> Message-ID: <0f5c3363-7e23-4a19-b7f8-021f1d6e3f6c@t54g2000hsg.googlegroups.com> On Apr 17, 12:24 pm, Michael Torrie wrote: > s0s... at gmail.com wrote: > > > > There! That's the whole code. I guess the way you suggest is simpler > > and a bit more intuitive, but I was figuring that the way I suggested > > it is more stylish. > > Umm, doesn't defining all those members in the class lead to class > variables, not instance variables? I believe the recommended way of > making it clear what instance variables to expect is to initialize them > all in __init__. Currently in your implementation, each instance of > your class is going to share the same variables for all those fields you > defined, which probably isn't what you want. > > consider: > > class myclass(object): > classvar1=None > classvar2=None > > def __init__(self,test): > self.instancevar1=test > > >>> a=myclass(3) > >>> b=myclass(6) > >>> a.classvar1=9 > >>> a.classvar1 > 9 > >>> b.classvar1 > 9 > >>> a.instancevar1 > 3 > >>> b.instancevar1 > > 6 > > Also, your idea of checking the length of the headers to reduce the > number of string comparisons is a great case of premature optimization. > First it does not clarify the code, making it harder to follow. > Second, since web servers are I/O bound, it likely does nothing to > improve speed. > > So my recommendation is to use a bunch of self.HEADER_NAME=None > declarations in __init__(). This is the expected way of doing it and > all python programmers who are looking at your code will immediately > recognize that they are instance variables. You didn't really write that at the Python's interpreter, did you? It's wrong. The way that would really go at the interpreter is like this: >>> class myclass(object): ... classvar1=None ... classvar2=None ... def __init__(self,test): ... self.instancevar1=test ... >>> >>> a = myclass(3) >>> b = myclass(6) >>> >>> a.classvar1 = 9 >>> a.classvar1 9 >>> b.classvar1 >>> # Nothing was output in this line because b.classvar1 is still None ... >>> a.instancevar1 3 >>> b.instancevar1 6 classvar1 and classvar2 might be class variables, but in they don't work as they would in C++ or Java (like the ones you declare with the 'static' modified). From simon at brunningonline.net Tue Apr 8 06:36:09 2008 From: simon at brunningonline.net (Simon Brunning) Date: Tue, 8 Apr 2008 11:36:09 +0100 Subject: Looking for Conferences/Events on Django, Python, MySQL, etc in Europe 2008? In-Reply-To: <7fb0f408-1a2e-4ee1-a179-092f83eb1591@8g2000hsu.googlegroups.com> References: <7fb0f408-1a2e-4ee1-a179-092f83eb1591@8g2000hsu.googlegroups.com> Message-ID: <8c7f10c60804080336u1cb687d9occ950bf266688a68@mail.gmail.com> On Tue, Apr 8, 2008 at 10:10 AM, Simone Brunozzi wrote: > Greetings! > > I'm looking for conferences or events about Python, Django, Dabatases, > Mysql, > PHP, Ruby in Europe (or nearby locations like north africa and middle > east) in 2008. > Do you have any suggestions? PyCon UK 2008 - 12th to 14th September 2008 - . -- Cheers, Simon B. simon at brunningonline.net http://www.brunningonline.net/simon/blog/ From steve at holdenweb.com Thu Apr 24 23:54:42 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 23:54:42 -0400 Subject: Psyco alternative In-Reply-To: References: <8b7d9523-1d15-41e5-8b69-39f8250e6a6f@i76g2000hsf.googlegroups.com> Message-ID: sturlamolden wrote: > On Apr 25, 4:57 am, Steve Holden wrote: > >> I am simply pointing out that RPython is used for efficiency, not to do >> things that can't be done in standard Python. > > Yes. And if we only use a very small subset of Python, it would in > effect be a form of assembly code. Hence my comment about the Turing > complete subset. > Since you obviously insist on having the last word I promise not to reply to your next post. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From cyu021 at gmail.com Mon Apr 14 21:44:54 2008 From: cyu021 at gmail.com (James Yu) Date: Tue, 15 Apr 2008 09:44:54 +0800 Subject: click on hyper link and got 404 error Message-ID: <60bb95410804141844t229b7e87x7fb7831d3969eff6@mail.gmail.com> I am using "mod_python.publisher" to generate my web page that contains serveral links to local files. I also replace the path with my domain name like this: curDir = os.path.dirname(__file__) link = 'http://' + hostname + '/' + os.path.basename(curDir) + '/' files = os.listdir(curDir) for i in files: body = body + '
' + i + '' + '
' However, browser give me 404 error whenever I click on any of the links. Is there something wrong with how I build my file links ? Thanks, -- This is a UTF-8 formatted mail ----------------------------------------------- James C.-C.Yu -------------- next part -------------- An HTML attachment was scrubbed... URL: From castironpi at gmail.com Sun Apr 27 06:46:05 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sun, 27 Apr 2008 03:46:05 -0700 (PDT) Subject: problem with listdir References: Message-ID: <31152c20-31a8-4fbd-abdc-5d2b3ccbe048@r66g2000hsg.googlegroups.com> On Apr 27, 1:57?am, David wrote: > On Sat, Apr 26, 2008 at 7:56 PM, jimgardener wrote: > > > ?> * Run cmd.exe and see if you can run "dir f:\\code\\python\pgmgallery/*.*" > > > ?that causes a message 'Invalid switch - "*.*".' > > Probably because on the command-line, / means a command-line option. > Been a while since I used DOS. > > Try this instead: > > dir f:\code\python\pgmgallery\*.*" > > David. Try typing listdir( '.' ), which is Windows for 'the current path [being used]', at an interpreter. listdir does not accept wildcards, (surmisably since reg.exes are more powerful) and try ending with a slash. From skip at pobox.com Sun Apr 27 18:45:34 2008 From: skip at pobox.com (skip at pobox.com) Date: Sun, 27 Apr 2008 17:45:34 -0500 Subject: Looking for a change of pace? Message-ID: <18453.526.662526.696535@montanaro-dyndns-org.local> Have you been "Idol"ed and "Survivor"ed to death? Are you tired of Tiger winning just about every golf tournament he enters? Are you sick to deatch of the circus the Democratic primary race has become? Is it too early in the season to get excited about the prospect of a Red Line World Series between the Cubs and the White Sox? Well, here's something you can do that might be a nice change of pace: 1. Change directory to your Python sandbox or distribution. 2. At your Python prompt execute import random, os print random.choice(os.listdir("Doc/library")) 3. Check and clean up the displayed documentation. Submit a patch to bugs.python.org if necessary. 4. Be happy. Skip From Magnus.Moraberg at gmail.com Wed Apr 2 09:22:50 2008 From: Magnus.Moraberg at gmail.com (Magnus.Moraberg at gmail.com) Date: Wed, 2 Apr 2008 06:22:50 -0700 (PDT) Subject: Nested try...except References: <0a34849f-bcda-419b-a10f-772d76172d1f@b5g2000pri.googlegroups.com> Message-ID: <43d60d13-b420-414d-81c8-b8430af2aa5f@i36g2000prf.googlegroups.com> On 2 Apr, 15:15, Magnus.Morab... at gmail.com wrote: > On 2 Apr, 15:12, cokofree... at gmail.com wrote: > > > > > On Apr 2, 3:06 pm, Magnus.Morab... at gmail.com wrote: > > > > Hi, > > > > I found the following code on the net - > > > > http://mail-archives.apache.org/mod_mbox/httpd-python-cvs/200509.mbox/%3C20050924104732.5116.qm... at minotaur.apache.org%3E > > > > def count(self): > > > - db = sqlite.connect(self.filename, > > > isolation_level=ISOLATION_LEVEL) > > > - try: > > > - try: > > > - cur = db.cursor() > > > - cur.execute("select count(*) from sessions") > > > - return cur.fetchone()[0] > > > - finally: > > > - cur.close() > > > - finally: > > > - db.close() > > > > I don't understand though why the second try is not after the line cur > > > = db.cursor(). Can anyone explain for me why? > > > > /Barry. > > > Better question is why is there a try with no except... > > > Better yet, WHY is there two TRY statements when there could quite > > happily be only one... > > > Towards what you are asking, I GUESS...because the author hoped to > > handle the cases where cur failed to get assigned...but then > > his .close method of it would likely not work anyway...I mean...does > > this even work...YUCK > > I shouldn't have written "Nested try...except" as the title, instead I > mean "Nested try...finally". Sorry about that... > > Anyway, how would you do this? That is, use a finally to close the > network connection and the cursor? > > Thanks for your help, > > Barry Here's what I would do. Is it OK? def ExecuteWithNoFetching(self, queryString): sqlServerConnection = adodbapi.connect (";".join (connectors)) try: cursor = sqlServerConnection.cursor() try: cursor.execute(queryString) raise Exception("Exception") sqlServerConnection.commit() finally: cursor.close() finally: sqlServerConnection.close() From nicola.musatti at gmail.com Tue Apr 22 08:24:00 2008 From: nicola.musatti at gmail.com (Nicola Musatti) Date: Tue, 22 Apr 2008 05:24:00 -0700 (PDT) Subject: subprocess module is sorely deficient? References: Message-ID: <621dbfa0-8c3c-4ce4-80e7-cf0840c4b82f@p25g2000hsf.googlegroups.com> On Apr 22, 12:52 pm, Harishankar wrote: > Hi, > > Sorry to start off on a negative note in the list, but I feel that the Python > subprocess module is sorely deficient because it lacks a mechanism to: > > 1. Create non-blocking pipes which can be read in a separate thread (I am > currently writing a mencoder GUI in Tkinter and need a full fledged process > handler to control the command line and to display the progress in a > text-box) I suggest you check out this: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554 Cheers, Nicola Musatti From severian at severian.org Wed Apr 16 14:43:24 2008 From: severian at severian.org (Severian) Date: Wed, 16 Apr 2008 14:43:24 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: <6cadnYCFdNpR2ZvVnZ2dnUVZ_tPinZ2d@visi> References: <28d12cc8-5375-4e95-8e37-f872d238a1bd@b64g2000hsa.googlegroups.com> <6cadnYCFdNpR2ZvVnZ2dnUVZ_tPinZ2d@visi> Message-ID: <48064885$0$18426$39cecf19@news.twtelecom.net> Grant Edwards wrote: > On 2008-04-16, Mensanator wrote: >> On Apr 16, 9:19 am, Grant Edwards wrote: >>> This morning almost half of c.l.p was spam. In order to try >>> to not tar both the benign google group users and the >>> malignant ones with the same brush, I've been trying to kill >>> usenet spam with subject patterns. But that's not a battle >>> you can win, so I broke down and joined all the other people >>> that just killfile everything posted via google.groups. >> Not very bright, eh? >> >>> AFAICT, if you're a google groups user your posts are not being >>> seen by many/most experienced (read "non-google-group") users. >>> This is mainly the fault of google who has refused to do >>> anything to stem the flood of span that's being sent via Google >>> Groups. >> Duh. > > My. That was certainly a well-reasoned and well-written > response. Well, it did come from an AOL user posting from Google groups . From castironpi at gmail.com Sat Apr 26 19:05:07 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sat, 26 Apr 2008 16:05:07 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> Message-ID: <5b326b53-22fc-43f3-8423-bfc49d05ccc3@j22g2000hsf.googlegroups.com> On Apr 26, 5:03?pm, John Henry wrote: > On Apr 26, 8:46 am, a... at pythoncraft.com (Aahz) wrote: > > > > > > > In article <9028496e-30de-4853-8f57-b55d14e52... at h1g2000prh.googlegroups.com>, > > John Henry ? wrote: > > > >But then I looked closer. ?It turns out the XML file created by > > >QxTransformer is *very* similar in structure when compared to the > > >resource files used inPythonCard. ?Since there are no GUI builders > > >for QxTransformer, and I can't affort to buy the one for Qooxdoo > > >(Java! ?Yuk!), I decided to roll up my sleeves, took thePythoncard's > > >Layout Manager and modified it and created my own "Poor Man's Qooxdoo > > >GUI Layout Designer". > > > Cute! ?When you have working code, please do upload to PyPI. > > -- > > Aahz (a... at pythoncraft.com) ? ? ? ? ? <*> ? ? ? ?http://www.pythoncraft.com/ > > > Why is this newsgroup different from all other newsgroups? > > So far, I have the following widgets working: > > window, button, checkbox, static text, static box, list, combobox, > spinner, radio button group > > Shouldn't be long before the following works: > > static line, image, image button, choice.- Hide quoted text - > > - Show quoted text - Should static text GUI class support the operations of a string? From john106henry at hotmail.com Sun Apr 27 16:55:55 2008 From: john106henry at hotmail.com (John Henry) Date: Sun, 27 Apr 2008 13:55:55 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <1d8af3e3-c287-4d5b-a481-ca8c650f732f@s33g2000pri.googlegroups.com> <472056db-8812-42b2-a4fe-3a2accd7571b@8g2000hse.googlegroups.com> Message-ID: <18305718-c56c-49ef-92d6-83aa93a923d2@w5g2000prd.googlegroups.com> On Apr 27, 11:36 am, Ron Stephens wrote: > John, > > This is very interesting! Please do make this available. I love > PythonCard, but I am doing mainly web programming these days. > > I will mention this on my next podcast. Can you do a slider? > > Ron Stephens > Python411www.awaretek.com/python/index.html Not sure if Qooxdoo supports slider yet. I have to ask. From sturlamolden at yahoo.no Sat Apr 19 15:34:22 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sat, 19 Apr 2008 12:34:22 -0700 (PDT) Subject: why function got dictionary References: <48075950.7050000@gmail.com> Message-ID: On Apr 19, 8:33 pm, "bruno.desthuilli... at gmail.com" wrote: > barfoo = foobar > foobar = lambda x : x > > And boom. That's why I used the qualifier 'roughly equivalent' and not simply 'equivalent'. From fennelllindy8241 at gmail.com Mon Apr 28 03:14:11 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:14:11 -0700 (PDT) Subject: morrowind no cd crack Message-ID: morrowind no cd crack http://crack.cracksofts.com From gabriel.rossetti at mydeskfriend.com Tue Apr 8 03:05:27 2008 From: gabriel.rossetti at mydeskfriend.com (Gabriel Rossetti) Date: Tue, 08 Apr 2008 09:05:27 +0200 Subject: Destructor? Message-ID: <47FB1937.5050008@mydeskfriend.com> Hello everyone, we are writing an application that needs some cleanup to be done if the application is quit, normally (normal termination) or by a signal like SIGINT or SIGTERM. I know that the __del__ method exists, but unless I'm mistaken there is no guarantee as of when it will be called, and some objects may have already been released (at lease I've had trouble in the past accessing certain objects from inside __del__, probably since the parent class's __del__ has to be called first, then it's objects are already released by the time I need to do something with them). Another method would be to implement something using the signal module and have a callback that does all the cleanup when the app. is quit/terminated/interrupted and have all the child classes override that with their cleanup code. What is the community's point of view on the subject? Thanks, Gabriel From brian.e.munroe at gmail.com Wed Apr 2 12:03:52 2008 From: brian.e.munroe at gmail.com (Brian Munroe) Date: Wed, 2 Apr 2008 09:03:52 -0700 (PDT) Subject: class / module introspection? Message-ID: I'm struggling with an architectural problem and could use some advice. I'm writing an application that will gather statuses from disparate systems. Because new systems show up all the time, I'm trying to design a plugin architecture that will allow people to contribute new backends by just dropping a package/module into a specific directory. The object methods in these backends will conform to a documented API that the main application will call. Currently I have something that looks like this: src/ backends/ system1/ __init__.py system2/ __init__.py ... Then from my application (main.py) I can simply call: from backends import system1 be1 = system1.Backend() be1.getStatus() This would work great if I knew about system1 and system2 ahead of time, but that isn't the case. Having to rewrite main.py every time a new backend module comes along is obviously a stupid idea too. I've been thinking I need some kind of introspection, but I've been reading about it and a whole mess of design pattern stuff, so my head is swimming and I am totally unsure of what the best approach is. My guess is that I need to load all the backends at runtime - then introspect the loaded classes? Any suggestions would be greatly appreciated. From benash at gmail.com Sat Apr 26 17:26:04 2008 From: benash at gmail.com (Benjamin) Date: Sat, 26 Apr 2008 14:26:04 -0700 (PDT) Subject: Parsing HTML? References: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> <47F9B92C.1030802@behnel.de> Message-ID: <76811693-7617-4952-88d3-d1368c4500c5@1g2000prg.googlegroups.com> On Apr 6, 11:03?pm, Stefan Behnel wrote: > Benjamin wrote: > > I'm trying to parse an HTML file. ?I want to retrieve all of the text > > inside a certain tag that I find with XPath. ?The DOM seems to make > > this available with the innerHTML element, but I haven't found a way > > to do it in Python. > > ? ? import lxml.html as h > ? ? tree = h.parse("somefile.html") > ? ? text = tree.xpath("string( some/element[@condition] )") > > http://codespeak.net/lxml > > Stefan I actually had trouble getting this to work. I guess only new version of lxml have the html module, and I couldn't get it installed. lxml does look pretty cool, though. From http Wed Apr 2 16:23:00 2008 From: http (Paul Rubin) Date: 02 Apr 2008 13:23:00 -0700 Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> <7xwsngyu05.fsf@ruckus.brouhaha.com> Message-ID: <7x8wzw80rf.fsf@ruckus.brouhaha.com> "bruno.desthuilliers at gmail.com" writes: > Fine. But totally irrelevant here - this is comp.lang.python, not > comp.lang.c, and we *do not* (I repeat : we *do not*) face the same > safety and security problems as those existing in C. We have it better than they do in some ways. In some other ways, we have it worse. From bwljgbwn at gmail.com Tue Apr 22 05:55:35 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:55:35 -0700 (PDT) Subject: adobe cs2 crack Message-ID: adobe cs2 crack http://cracks.12w.net F R E E C R A C K S From primoz.skale.lists at gmail.com Thu Apr 3 04:00:19 2008 From: primoz.skale.lists at gmail.com (Primoz Skale) Date: Thu, 3 Apr 2008 10:00:19 +0200 Subject: function call - default value & collecting arguments References: <_LQIj.9776$HS3.482805@news.siol.net> <7e50544d-6daf-48c2-bb82-be06d3590450@8g2000hsu.googlegroups.com> Message-ID: wrote in message news:a3105c47-c016-49b0-8b19-841c26414b43 at s19g2000prg.googlegroups.com... > On 2 avr, 22:32, "Primoz Skale" wrote: >> >> I also understand (fairly) how to collect arguments. For example, >> >> let's >> >> define another function: >> >> >> def f(*a): >> >> print a >> >> > This means that f takes any number of optional positional arguments. >> > If nothing is passed, within f, 'a' will be an empty tuple. Note that >> > this is *not* the usual way to define a function taking multiple >> > (mandatory) arguments. >> >> M. Lutz in "Learning Python" had defined it this way. What is the *usual* >> way in this case? > > You mean : "what's the usual way to define a function taking multiple > *mandatory* arguments" ? I'd think it's explained in your book ??? > > def f(a, b, c): > print a, b, c > > But this is such a cs101 point that we're surely misunderstanding each > other here. > Yes, this was misunderstanding. I thought you meant defining with the *a, and not with a,b,c, etc....Thanks anyway :) >> >> > or (slightly more involved, and certainly overkill): >> >> > def with_default_args(default): >> > def decorator(func): >> > def wrapper(*args): >> > if not args: >> > args = default >> > return func(*args) >> > return wrapper >> > return decorator >> >> > @with_default_args((0,)) >> > def f(*a): >> > print a[0] >> >> Now, this is interesting. Thanks! :) > > Dont take this as a "recommanded" solution to your problem - it was > (mostly) to be exhaustive (and a bit on the "showing off" side too to > be honest). > No of course not - but it is interesting... P. From bbxx789_05ss at yahoo.com Sat Apr 5 05:16:07 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sat, 5 Apr 2008 02:16:07 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <7113d012-01bb-4426-bb40-9e2811cdb102@x41g2000hsb.googlegroups.com> <3cf4bbc8-b828-45c5-b9a8-766ce600af43@y21g2000hsf.googlegroups.com> Message-ID: skanem... at yahoo.se wrote: > > one thing i dont rally get, i ahve to add my_button.bind() somewhere? > i changed the stuff u said though and i get this error(the program > executes though and i can press the buttons): > > Exception in Tkinter callback > Traceback (most recent call last): > File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ > return self.func(*args) > TypeError: Display() takes exactly 2 arguments (1 given) > > > current version: > #! /usr/bin/env python > from Tkinter import * > import tkMessageBox > > class GUIFramework(Frame): > """This is the GUI""" > > def __init__(self,master=None): > """Initialize yourself""" > > """Initialise the base class""" > Frame.__init__(self,master) > > """Set the Window Title""" > self.master.title("Calculator") > > """Display the main window" > with a little bit of padding""" > self.grid(padx=10,pady=10) > self.CreateWidgets() > > def CreateWidgets(self): > > enText = Entry(self) > enText.grid(row=0, column=0, columnspan=8, padx=5, pady=5) > > enText = Entry(self) > enText.grid(row=1, column=0, columnspan=8, padx=5, pady=5) > > btnDisplay = Button(self, text="1", command=self.Display) > btnDisplay.grid(row=3, column=0, padx=5, pady=5) You still have this in your code: btnDisplay = Button(self, text="1", command=self.Display) I suggest you reread my earlier post again. Or, follow the advice given by Marc 'BlackJack' Rintsch (preferable). But whatever you do, don't use both command and bind(). From grante at visi.com Fri Apr 11 18:05:50 2008 From: grante at visi.com (Grant Edwards) Date: Fri, 11 Apr 2008 17:05:50 -0500 Subject: Question on threads References: <47FFBC05.50309@holdenweb.com> Message-ID: On 2008-04-11, Steve Holden wrote: > Yes - you are calling it before you have started ALL your > threads, thereby making hte main thread wait for the end of > thread 1 before starting the next. An impressive demonstration > of thread synchronization, Well, that's one way to get rid of the need for the GIL... -- Grant Edwards grante Yow! Where's th' DAFFY at DUCK EXHIBIT?? visi.com From mail at timgolden.me.uk Thu Apr 24 04:49:56 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 24 Apr 2008 09:49:56 +0100 Subject: python-ldap - Operations Error In-Reply-To: References: <8b35f293-fc64-4d21-a621-124c8eafde59@c65g2000hsa.googlegroups.com> Message-ID: <481049B4.5030708@timgolden.me.uk> Michael Str?der wrote: > Jason Scheirer wrote: >> On Apr 23, 5:16 pm, theivi... at gmail.com wrote: >>> Hello all, I am trying to integrate TurboGears with our Active >>> Directory here at the office. TurboGears aside, i cannot get this to >>> work. >> >> Seems more promising: >> http://tgolden.sc.sabren.com/python/active_directory.html > > This is based on ADSI? > Then the caveat is that it only runs on Windows. Yes, it's Windows-only. (I've no idea if it would run under something like WINE). TJG From gagsl-py2 at yahoo.com.ar Thu Apr 10 04:31:27 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 05:31:27 -0300 Subject: email header decoding fails References: Message-ID: En Wed, 09 Apr 2008 23:12:00 -0300, ZeeGeek escribi?: > It seems that the decode_header function in email.Header fails when > the string is in the following form, > > '=?gb2312?Q?=D0=C7=C8=FC?=(revised)' > > That's when a non-encoded string follows the encoded string without > any whitespace. In this case, decode_header function treats the whole > string as non-encoded. Is there a work around for this problem? That header does not comply with RFC2047 (MIME Part Three: Message Header Extensions for Non-ASCII Text) Section 5 (1) An 'encoded-word' may replace a 'text' token (as defined by RFC 822) in any Subject or Comments header field, any extension message header field, or any MIME body part field for which the field body is defined as '*text'. [...] Ordinary ASCII text and 'encoded-word's may appear together in the same header field. However, an 'encoded-word' that appears in a header field defined as '*text' MUST be separated from any adjacent 'encoded-word' or 'text' by 'linear-white-space'. Section 5 (3) As a replacement for a 'word' entity within a 'phrase', for example, one that precedes an address in a From, To, or Cc header. [...] An 'encoded-word' that appears within a 'phrase' MUST be separated from any adjacent 'word', 'text' or 'special' by 'linear-white-space'. -- Gabriel Genellina From karthikk at adventnet.com Wed Apr 9 04:17:49 2008 From: karthikk at adventnet.com (Karthik) Date: Wed, 09 Apr 2008 13:47:49 +0530 Subject: Setting default version among multiple python installations In-Reply-To: References: <47FB3F86.5040702@adventnet.com> <47FC57F8.40106@adventnet.com> Message-ID: <47FC7BAD.7060901@adventnet.com> Gabriel Genellina wrote: > En Wed, 09 Apr 2008 02:45:28 -0300, Karthik > escribi?: > > >> if i type python2.5 i am able to use the latest python, but if i simply >> type python it taken me to the older version. (it is a minor annoyance, >> but I want to know how to fix it) >> > > From the README file: > > There's an executable /usr/bin/python which is Python > 1.5.2 on most older Red Hat installations; several key Red Hat > tools > require this version. Python 2.1.x may be installed as > /usr/bin/python2. The Makefile installs Python as > /usr/local/bin/python, which may or may not take precedence > over /usr/bin/python, depending on how you have set up $PATH. > > yes, that seems to be the case. i changed the order of entries in $PATH, and now things are working now. thanks for your help. (Lesson learnt: if it says README, better read it completely, dont stop at "Congratulations on getting this far. :-)" ) -Karthik -------------- next part -------------- An HTML attachment was scrubbed... URL: From bronger at physik.rwth-aachen.de Tue Apr 29 17:57:18 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Tue, 29 Apr 2008 23:57:18 +0200 Subject: Simple unicode-safe version of str(exception)? References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> <48179831.7030308@v.loewis.de> Message-ID: <87iqy0miip.fsf@physik.rwth-aachen.de> Hall?chen! Martin v. L?wis writes: >> Should I report this as a bug? I suspect it's a misfeature. > > Please no. There isn't much that can be done about it, IMO. One could give Exception a __unicode__ method. On the other hand, this kind of conversion of an exception to something printable is a quite ugly kludge anyway in my opinion, so it needn't special support. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From mensanator at aol.com Wed Apr 16 13:48:23 2008 From: mensanator at aol.com (Mensanator) Date: Wed, 16 Apr 2008 10:48:23 -0700 (PDT) Subject: Finally had to plonk google gorups. References: Message-ID: <28d12cc8-5375-4e95-8e37-f872d238a1bd@b64g2000hsa.googlegroups.com> On Apr 16, 9:19?am, Grant Edwards wrote: > This morning almost half of c.l.p was spam. ?In order to try to > not tar both the benign google group users and the malignant > ones with the same brush, I've been trying to kill usenet spam > with subject patterns. ?But that's not a battle you can win, so > I broke down and joined all the other people that just killfile > everything posted via google.groups. Not very bright, eh? > > AFAICT, if you're a google groups user your posts are not being > seen by many/most experienced (read "non-google-group") users. > This is mainly the fault of google who has refused to do > anything to stem the flood of span that's being sent via Google > Groups. Duh. > > -- > Grant Edwards ? ? ? ? ? ? ? ? ? grante ? ? ? ? ? ? Yow! I would like to > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? at ? ? ? ? ? ? ? urinate in an OVULAR, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?visi.com ? ? ? ? ? ?porcelain pool -- From danb_83 at yahoo.com Thu Apr 24 01:08:49 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Wed, 23 Apr 2008 22:08:49 -0700 (PDT) Subject: Curious relation References: <613aa1f7-3943-4458-ba7e-4cb29c562988@y21g2000hsf.googlegroups.com> Message-ID: On Apr 23, 11:51 pm, Greg J wrote: > I was reading the programming Reddit tonight and came across this > (http://reddit.com/info/6gwk1/comments/): > > >>> ([1]>2)==True > True > >>> [1]>(2==True) > True > >>> [1]>2==True > > False > > Odd, no? > > So, can anyone here shed light on this one? A long time ago, it wasn't possible for comparison operators to raise exceptions, so it was arbitrarily decided that numbers are less than strings. Thus, [1]>2 and [1]>False. This explains your first two examples. For the third, remember that the comparison operators are chained, so a>b==c means (a>b) and (b==c). Since 2==True is false, so is the entire expression. In Python 3.0, all three of these expressions will raise a TypeError. From http Wed Apr 2 14:46:50 2008 From: http (Paul Rubin) Date: 02 Apr 2008 11:46:50 -0700 Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> Message-ID: <7xwsngyu05.fsf@ruckus.brouhaha.com> "bruno.desthuilliers at gmail.com" writes: > Here the problem is more philosophical than anything else. Python's > philosophy is that most programmers are responsible and normally > intelligent, so treating them all like retarted dummies because > someone might one day do something stupid is just wasting everyone's > time. This is also why there's no language-enforced access > restriction, only a simple stupid convention to denote implementation > stuff from API. The fact is that it JustWork. Additional Principles for C1X (new) ... 12. Trust the programmer, as a goal, is outdated in respect to the security and safety programming communities. While it should not be totally disregarded as a facet of the spirit of C, the C1X version of the C Standard should take into account that programmers need the ability to check their work. C - The C1X Charter Document: WG14 N1250, p. 3 http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1250.pdf From __peter__ at web.de Mon Apr 21 17:01:14 2008 From: __peter__ at web.de (Peter Otten) Date: Mon, 21 Apr 2008 23:01:14 +0200 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> Message-ID: Ivan Illarionov wrote: > And even faster: > a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, > len(s), 3)))) > if sys.byteorder == 'little': > a.byteswap() > > I think it's a fastest possible implementation in pure python Clever, but note that it doesn't work correctly for negative numbers. For those you'd have to prepend "\xff" instead of "\0". Peter From paul at boddie.org.uk Thu Apr 17 06:42:23 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Thu, 17 Apr 2008 03:42:23 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: <8ff14bb5-7919-47e8-b64a-9512e0d1b412@l64g2000hse.googlegroups.com> On 16 Apr, 15:16, Marco Mariani wrote: > > Do you mean Ruby's track in providing backward compatibility is better > than Python's? > > Googling for that a bit, I would reckon otherwise. So would I, but then it isn't the Ruby developers that are *promising* to break backward compatibility *and* claiming that it's a good thing. This means that those wanting to sell Ruby as a solution can play the political game and claim a better roadmap even if they end up causing more disruption than Python 3.x does: it's like electioneering on a platform of "no new taxes" and then breaking that promise after gaining power. I find myself agreeing strongly with Aaron about this. Lots of things were considered "wrong" with Python over the years, but I'm unconvinced about the remedy: http://wiki.python.org/moin/PythonWarts There seems to be a lot of "out with the old" in the Free Software world of late. Another example: KDE 3.x eventually finds itself in products with widespread distribution; the developers bring out a less capable version (but with more "bling") that everyone is now supposedly working on instead; momentum is lost. Paul From gherzig at fmed.uba.ar Fri Apr 4 10:42:16 2008 From: gherzig at fmed.uba.ar (Gerardo Herzig) Date: Fri, 04 Apr 2008 11:42:16 -0300 Subject: collecting results in threading app Message-ID: <47F63E48.80002@fmed.uba.ar> Hi all. Newbee at threads over here. Im missing some point here, but cant figure out which one. This little peace of code executes a 'select count(*)' over every table in a database, one thread per table: class TableCounter(threading.Thread): def __init__(self, conn, table): self.connection = connection.Connection(host=conn.host, port=conn.port, user=conn.user, password='', base=conn.base) threading.Thread.__init__(self) self.table = table def run(self): result = self.connection.doQuery("select count(*) from %s" % self.table, [])[0][0] print result return result class DataChecker(metadata.Database): def countAll(self): for table in self.tables: t = TableCounter(self.connection, table.name) t.start() return It works fine, in the sense that every run() method prints the correct value. But...I would like to store the result of t.start() in, say, a list. The thing is, t.start() returns None, so...what im i missing here? Its the desing wrong? thanks! Gerardo From gnewsg at gmail.com Fri Apr 4 07:26:47 2008 From: gnewsg at gmail.com (Giampaolo Rodola') Date: Fri, 4 Apr 2008 04:26:47 -0700 (PDT) Subject: RELEASED Python 2.6a2 and 3.0a4 References: Message-ID: On 4 Apr, 03:47, Barry Warsaw wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On behalf of the Python development team and the Python community, I'm ? > happy to announce the second alpha release of Python 2.6, and the ? > fourth alpha release of Python 3.0. > > Please note that these are alpha releases, and as such are not ? > suitable for production environments. ?We continue to strive for a ? > high degree of quality, but there are still some known problems and ? > the feature sets have not been finalized. ?These alphas are being ? > released to solicit feedback and hopefully discover bugs, as well as ? > allowing you to determine how changes in 2.6 and 3.0 might impact ? > you. ?If you find things broken or incorrect, please submit a bug ? > report at > > ? ?http://bugs.python.org > > For more information and downloadable distributions, see the Python ? > 2.6 web > site: > > ? ?http://www.python.org/download/releases/2.6/ > > and the Python 3.0 web site: > > ? ?http://www.python.org/download/releases/3.0/ > > We are planning one more alpha release of each version, followed by ? > two beta releases, with the final releases planned for August 2008. ? > See PEP 361 for release details: > > ? ? ?http://www.python.org/dev/peps/pep-0361/ > > Enjoy, > - -Barry > > Barry Warsaw > ba... at python.org > Python 2.6/3.0 Release Manager > (on behalf of the entire python-dev team) > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.8 (Darwin) > > iQCVAwUBR/WImHEjvBPtnXfVAQJmoQP+MzqNDI+Xt8zua/FE7Ca4TVXoIIy2uoOm > I1i3+vmevZ9vtAb9hcGwfEgPY4LSwb9Js4KnJJWMPaMuFJK4NgGoiMdj+t42zDbQ > bEzfBUOCoVkejLRxIQnWeJf1Hu8JocYyCHIRffv57/QdKpHuiSs8aE8GIT3STo3o > I88H5NY1GgI= > =WT2z > -----END PGP SIGNATURE----- The Windows x86 MSI installer is missing for both 2.6 and 3.0. --- Giampaolo http://code.google.com/p/pyftpdlib From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 23 08:45:45 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 23 Apr 2008 14:45:45 +0200 Subject: help needed with classes/inheritance In-Reply-To: <480f13e8$0$15157$607ed4bc@cv.net> References: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> <480f13e8$0$15157$607ed4bc@cv.net> Message-ID: <480f2f6c$0$2660$426a74cc@news.free.fr> Andrew Lee a ?crit : (snip) > as a rule of thumb .. if you are using "isinstance" in a class to > determine what class a parameter is ... you have broken the OO contract. Nope. > Remember, every class ought to have a well defined internal state and a > well defined interface to its state. I don't see how the part about the internal state relates to the problem here. > If I write -- > > class foo (object): > def __init__ : > pass > > def some_func (self, val) : > if isinstance (val, "bar") : > .... > > Then I am either doing something very wrong If you do so in a desperate attempt to emulate static typing in Python, then yes, you're doing something very wrong. Else: > or very clever Not necessarily. Given Python's dynamic typing, there's no builtin OneObviousWay(tm) way to dispatch on different functions based on argument's type - something often done in statically typed OOPLs using method overridding (ie: different methods with same name but different signatures). Doing a manual dispatch based on argument's type, while not good OO style, is sometimes the simplest working solution, and a good enough one for the problem at hand. Having different methods for different arg types has the drawback that you don't have one single generic function/method that you can use as a callback. Having a real multidispatch (or rule-based dispatch etc) system either builtin or in the stdlib would indeed be much cleaner. Until then, there are a couple third-part packages solving this problem, but it can be overkill for simple problems (and add unneeded/unwanted dependencies). my 2 cents. From medin0065 at gmail.com Sun Apr 20 10:49:33 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:49:33 -0700 (PDT) Subject: anachronox patch Message-ID: <9a6617e9-4fd7-44c0-8611-e99bf6a593d8@w1g2000prd.googlegroups.com> anachronox patch http://cracks.00bp.com F R E E C R A C K S From c.boulanger at qxtransformer.org Tue Apr 29 04:57:05 2008 From: c.boulanger at qxtransformer.org (Panyasan) Date: Tue, 29 Apr 2008 01:57:05 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <473deef3-9acb-45dd-a7ca-47b0081bd28c@i36g2000prf.googlegroups.com> <3f7bb91e-335e-46bd-88ca-f15b26c35132@k1g2000prb.googlegroups.com> Message-ID: Hi, I am one of the two developers working on the xml-to-javascript converter (qxtransformer) John has mentioned and we are thrilled that our project has found a use in the PythonCard community. However, we have a problem getting PythonCard to work on our Macs (Mac OS 10.5 Leopard). We should probably be asking this on the PythonCard help list, but since the list seems to be somewhat deserted (very few posts) and John is active here and people seem to be using PythonCard, maybe someone has an idea. It might be very simple and stupid - I have never worked with python before. I am using - PythonCard 0.8.2 release on Leopard, which is copied by setup.py to / Library/Python/2.5/site-packages - John's layoutEditor package, (http://qxtransformer.googlegroups.com/ web/layoutEditor.zip) PythonCard email list says that Leopard and PythonCard 0.8.2 seem to like each other generally: http://sourceforge.net/mailarchive/forum.php?thread_name=EE5213D5-A005-4ED0-9512-111B6D4F06A7%40bu.edu&forum_name=pythoncard-users and I can get the examples working. However, when I start John's modified layoutEditor.py, I get an empty window and the following error is thrown: no resource file for /Users/bibliograph/Programme/PythonCard/tools/ layoutEditor/multipropertyEditor Traceback (most recent call last): File "/BinaryCache/wxWidgets/wxWidgets-11~57/Root/System/Library/ Frameworks/Python.framework/Versions/2.5/Extras/lib/python/wx-2.8-mac- unicode/wx/_core.py", line 14095, in File "/Library/Python/2.5/site-packages/PythonCard/tools/ layoutEditor/layoutEditor.py", line 153, in on_initialize self.propertyEditorWindow = model.childWindow(self, PropertyEditor) File "/Library/Python/2.5/site-packages/PythonCard/model.py", line 213, in childWindow rsrc = resource.ResourceFile(filename).getResource() File "/Library/Python/2.5/site-packages/PythonCard/resource.py", line 45, in __init__ self.dictionary = util.readAndEvalFile(rsrcFileName) File "/Library/Python/2.5/site-packages/PythonCard/util.py", line 39, in readAndEvalFile f = open(filename) TypeError: coercing to Unicode: need string or buffer, NoneType found there is a file PythonCard/tools/layoutEditor/modules/ multipropertyEditor.rsrc.py When I resize the window, I get the following errors Tue Apr 29 10:48:08 noname Python[40440] : CGContextConcatCTM: invalid context Tue Apr 29 10:48:08 noname Python[40440] : CGContextSaveGState: invalid context Tue Apr 29 10:48:08 noname Python[40440] : doClip: invalid context Tue Apr 29 10:48:08 noname Python[40440] : CGContextSaveGState: invalid context Tue Apr 29 10:48:08 noname Python[40440] : CGContextSetBlendMode: invalid context Tue Apr 29 10:48:08 noname Python[40440] : CGContextSetShouldAntialias: invalid context Traceback (most recent call last): File "/Library/Python/2.5/site-packages/PythonCard/model.py", line 884, in _dispatch handler(background, aWxEvent) File "/Library/Python/2.5/site-packages/PythonCard/tools/ layoutEditor/layoutEditor.py", line 560, in on_size self.createDC() File "/Library/Python/2.5/site-packages/PythonCard/tools/ layoutEditor/layoutEditor.py", line 556, in createDC dc.SetLogicalFunction(wx.INVERT) File "/BinaryCache/wxWidgets/wxWidgets-11~57/Root/System/Library/ Frameworks/Python.framework/Versions/2.5/Extras/lib/python/wx-2.8-mac- unicode/wx/_gdi.py", line 4079, in SetLogicalFunction wx._core.PyAssertionError: C++ assertion "status == noErr" failed at ../src/mac/carbon/graphics.cpp(1324) in EnsureIsValid(): Cannot nest wxDCs on the same window Thanks for any pointers, Christian From john106henry at hotmail.com Thu Apr 10 15:19:30 2008 From: john106henry at hotmail.com (John Henry) Date: Thu, 10 Apr 2008 12:19:30 -0700 (PDT) Subject: How is GUI programming in Python? References: Message-ID: <2345bb35-50c0-4c2f-8ea0-7498fe6f89b4@p39g2000prm.googlegroups.com> On Apr 9, 6:54 pm, Chris Stewart wrote: > I've always had an interest in Python and would like to dabble in it > further. I've worked on a few very small command line programs but > nothing of any complexity. I'd like to build a really simple GUI app > that will work across Mac, Windows, and Linux. How painful is that > going to be? I used to be really familiar with Java Swing a few years > ago. I imagine it will be similar. > > Next, what would you say is the best framework I should look into? > I'm curious to hear opinions on that. > > Chris Stewart > cstewart... at gmail.com If you are looking for something "really simple", my vote still goes to PythonCard. It has been around a looooooooooong time, very mature, stable, and comes with sufficient widgets to get most daily job done. True, it hasn't been updated to include some of the newer widgets but there are plenty in the package already. The danger is that once you get hooked in using Pythoncard, it's hard to leave because everything else looks soooooooo "non really simple". I've looked at every other Python GUI package. In my humble opinion, none came close to being "really simple" than Pythoncard. It's too bad the more capable people in the Python community doesn't pick up the ball and continue to run with it. For me, I am now migrating away from doing desktop GUI apps into browse based applications with a Python backend, and qooxdoo frontend. So, for me, Pythoncard will be my last desktop GUI tool package. From skanemupp at yahoo.se Sun Apr 13 05:17:53 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 13 Apr 2008 02:17:53 -0700 (PDT) Subject: latest command from toplevel? Message-ID: windows vista and python 2.5, is there a way to get the latest command entered? would be very useful. if not by default, anything i could download or write myself? From xng at xs4all.nl Thu Apr 17 09:21:09 2008 From: xng at xs4all.nl (Martin P. Hellwig) Date: Thu, 17 Apr 2008 15:21:09 +0200 Subject: I just killed GIL!!! In-Reply-To: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: <48074f58$0$4916$e4fe514c@dreader32.news.xs4all.nl> sturlamolden wrote: You killed the GIL, you bastard! :-) > Hello Guys... > > I just had one moment of exceptional clarity, during which realized > how I could get the GIL out of my way... It's so simple, I cannot help > wondering why nobody has thought of it before. Duh! Now I am going to > sit and and marvel at my creation for a while, and then go to bed > (it's past 2:30 a.m.) Tomorrow I will contemplate whether to sell this > little secret for big bucks, give it away for free, or just keep it to > myself... :-) > Sounds good, though I have a question. Is it transparent, meaning I can just write my code the way I used too and it makes the decision for itself to spread the tasks on multiple CPU's without me to worry about shared memory, spinlocks, deadlocks and out of order inter-depending processing of subtask without heaving having so much overhead that it has no performance advantage? If not, what is the advantage above already present solutions? -- mph From jgardner at jonathangardner.net Thu Apr 17 13:16:05 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Thu, 17 Apr 2008 10:16:05 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> Message-ID: On Apr 17, 8:19 am, sturlamolden wrote: > > An there you have the answer. It's really very simple :-) > That's an interesting hack. Now, how do the processes communicate with each other without stepping on each other's work and without using a lock? Once you get that solved, I am sure the entire computing world will beat a path to your door. (Hint: This is the kind of thing Stroustrup, Guido, and Alonzo Church have thought a lot about, just to name a few.) By the way, you do know that you can recompile Python from source code, and that you have the freedom to modify that source code. If you want to remove the GIL and see what happens, just make the calls to acquire and release the GIL do nothing. See how far that will get you. From rbrito at ime.usp.br Thu Apr 24 20:31:15 2008 From: rbrito at ime.usp.br (=?ISO-8859-1?Q?Rog=E9rio_Brito?=) Date: Thu, 24 Apr 2008 21:31:15 -0300 Subject: Little novice program written in Python Message-ID: Hi, All. I'm just getting my feet wet on Python and, just for starters, I'm coding some elementary number theory algorithms (yes, I know that most of them are already implemented as modules, but this is an exercise in learning the language idioms). As you can see from the code below, my background is in C, without too much sophistication. What I would like is to receive some criticism to my code to make it more Python'esque and, possibly, use the resources of the computer in a more efficient way (the algorithm implemented below is the Sieve of Eratosthenes): - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #!/usr/bin/env python n = int(raw_input()) a = [i for i in range(0,n+1)] a[1] = 0 # not a prime prime = 1 # last used prime finished = False while (not finished): prime = prime + 1 # find new prime while prime*prime <= n and a[prime] == 0: prime += 1 # cross the composite numbers if prime*prime <= n: j = 2*prime while j <= n: a[j] = 0 j += prime else: finished = True # print out the prime numbers i = 2 while i <= n: if a[i] != 0: print a[i] i += 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Thank you for any help in improving this program, -- Rog?rio Brito : rbrito@{mackenzie,ime.usp}.br : GPG key 1024D/7C2CAEB8 http://www.ime.usp.br/~rbrito : http://meusite.mackenzie.com.br/rbrito Projects: algorithms.berlios.de : lame.sf.net : vrms.alioth.debian.org From mobile at ibinsa.com Fri Apr 25 14:44:22 2008 From: mobile at ibinsa.com (Gabriel Ibanez) Date: Fri, 25 Apr 2008 20:44:22 +0200 Subject: print some text References: <7ac7b11d-6c9b-477c-8c0d-b038bc760918@c58g2000hsc.googlegroups.com> Message-ID: <01b301c8a704$615e58e0$0a01a8c0@mobile> Hi ! Other idea (old style school): def printing(): f=open("lpt1", "w") f.write("\nSomething to print\f") f.close() Cheers.. - Ibanez - ----- Original Message ----- From: Newsgroups: comp.lang.python To: Sent: Wednesday, April 23, 2008 10:27 PM Subject: Re: print some text On Apr 23, 2:05 pm, barronmo wrote: > I'm a beginner searching for an easy way to print the contents of a > text control. So far I've come up with the following(difficulties): > > 1) using wxPython > -convert to HTML and then print (I don't know anything about > HTML) > -use wx.Printout (Seems complicated; may be beyond my abilities) > > 2) create a text file and then print it out (can create but can only > print with the win32api.ShellExecute method so this solution doesn't > help me on my Linus laptop) > > 3) use ReportLab to create .pdf and then print that out (again, can > create but can't print in Linux) > > Thanks for any help. > > Mike Write out an HTML file, write back if you need a quick one, then print that with a browser. -- http://mail.python.org/mailman/listinfo/python-list From flarefight at googlemail.com Sun Apr 27 18:13:06 2008 From: flarefight at googlemail.com (flarefight at googlemail.com) Date: Sun, 27 Apr 2008 15:13:06 -0700 (PDT) Subject: Loading associated files References: <74862697-da58-4eb7-8d60-09aaef54b7ad@j22g2000hsf.googlegroups.com> <09337541-0b3e-4aaf-b26f-06a0f689e7dc@u12g2000prd.googlegroups.com> <850a01c2-d59e-4ee7-a344-796fd3cbb8aa@v23g2000pro.googlegroups.com> Message-ID: No you didnt misunderstand the situation, i think i have confused matters though!! When Ive got it working my program will read the data within the file. But obviously for it to do that it needs to know where the file is, hence the whole discussion. However to test things were working, just with regards the setting up of the registry, and since the contents of the file are essentially irrelevant for the test, i made the test file a valid python file so that i could test the registry setup by sending it to python.exe. It doesnt need to be and wont be a python file, ultimately it will contain some cPickle data which the program reads from the file. But as i said i need it to know the path of the file it needs to unpickle. And there are already "" around my %1 sign. It currently reads "C:\test \test.py" "%1", where test.py is the short program that simply reads the sys.argv that i posted further up. From leoniaumybragg at gmail.com Sat Apr 26 06:58:39 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:58:39 -0700 (PDT) Subject: crack addict behavior Message-ID: crack addict behavior http://cracks.00bp.com F R E E C R A C K S From trentm at activestate.com Tue Apr 22 13:41:38 2008 From: trentm at activestate.com (Trent Mick) Date: Tue, 22 Apr 2008 10:41:38 -0700 Subject: Does Python 2.5 include or not include SQLite engine? In-Reply-To: <3de8e1f70804212233o4e62c52s2a4d140deaa44355@mail.gmail.com> References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> <1208819146.23409.1249124463@webmail.messagingengine.com> <3de8e1f70804212233o4e62c52s2a4d140deaa44355@mail.gmail.com> Message-ID: <480E2352.5050005@activestate.com> Whether a Python installation includes the SQLite 3 bindings typically depends on: 1. Python version: core support for the SQLite 3 bindings (i.e. the "sqlite3" module) was added in Python 2.5. Earlier versions of Python may also have a 3rd-party package/module that adds SQLite bindings, of course. 2. The Python distro: The binary Python 2.5 installers from python.org (for Windows and Mac OS X [^1]) and ActiveState, i.e. ActivePython, (for Windows, Mac OS X, Linux, Solaris, HP-UX and AIX) include the "sqlite3" module as part of the installer. I don't know about other Python distributions. 3. Platform: Commonly on Linux one will get Python from the Linux distro's own packaging utility (e.g., apt-get, rpm, synaptic, yum, etc.) Typically the Linux distros will break up a Python installation into multiple packages. So an installation of, say, the "python2.5" package will often not have the "sqlite3" module. To get it you would have to install the separate "python2.5-sqlite" package. (Note: the names of these packages vary with Linux distro and version of that distro.) Cheers, Trent [1]: I could be wrong about whether the Mac OS X binary installer for Python 2.5 from python.org includes the "sqlite3" module -- I haven't checked -- but I presume it does. Banibrata Dutta wrote: > Doesn't this depend on the source / distro ? My Python is from the > ActivePython distro, while I am not sure (since I've just about started > playing with it), I haven't seen SQLite included ... possible that I > missed it. > > On 4/22/08, *python at bdurham.com * > > wrote: > > While reading feedback to my post "Does Python 2.5.2's embedded SQLite > support full text searching?" I noticed that there appears to be some > confusion regarding whether Python 2.5 includes the SQLite engine. > > My Windows 2.5.2 binary download includes SQLite. > > But other posters claim otherwise, re: Linux releases of Python 2.5? > > I thought one of the major features of Python 2.5 was its embedded > SQLite engine. > > Thoughts? -- Trent Mick trentm at activestate.com From skanemupp at yahoo.se Sat Apr 12 11:55:37 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 12 Apr 2008 08:55:37 -0700 (PDT) Subject: tkinter, editing an entry, int-value of insert? References: Message-ID: <2d68dadf-6548-40b5-999b-e42ac750a668@w8g2000prd.googlegroups.com> solved this: def Backspace(): st = e.index(INSERT) e.delete(st-1,st) From nicola.musatti at gmail.com Thu Apr 24 05:03:11 2008 From: nicola.musatti at gmail.com (Nicola Musatti) Date: Thu, 24 Apr 2008 02:03:11 -0700 (PDT) Subject: Java or C++? References: Message-ID: On Apr 21, 3:14 pm, NickC wrote: > On Apr 15, 1:46 pm, Brian Vanderburg II > wrote: [...] > Yeah, C++ does try to be helpful, and all of those automatic copy > constructor, assignment operator and destructor implementations screw > up royally when confronted with pointers (and being able to use > pointers is basically the whole reason for bothering to write anything > in C or C++ in the first place). Code which relies on these default > method implementations is almost certain to be rife with memory leaks > and double-free bugs. So instead of being a convenience, they become a > painfully easy way of writing code that silently does some very, very > wrong things. When a class includes a pointer data member, there is no single, right way to handle it. C++ automatically generated member functions are defined so as to be consistent in dealing with *values*. Any C++ programmer that hasn't learnt this simple fact, shouldn't be trusted with any programming language. Python and especially Java will only make it harder to spot the mess he is making. > Other things like methods (including destructors!) being non-virtual > by default also make C++ code annoyingly easy to get wrong (without it > obviously looking wrong). I can see how that might be confusing for programmer coming from Python, but it's more natural for those coming from C. > The whole design of C++ is riddled with premature optimisation of > speed and memory usage in the default settings, instead of choosing > safe defaults and providing concise ways of allowing the programmer to > say "I know optimisation X is safe here, please use it". I absolutely agree. > And the result? Any serious project in the language has to adopt it's > own techniques for avoiding all those traps, and those techniques are > likely to eliminate any supposed optimisations provided by the choices > of the C++ committee, while filling a code base with boilerplate that > only exists for the purpose of working around defects in the language > design (Scott Meyers has written at length about the worst of these > issues, far more clearly and eloquently than I ever could [1]). Did you give up on C++ in the early nineties? Things have changed a lot since then. Many standard/commonly accepted solutions to the problems you mention can be found in the C++ standard library and in Boost (http://boost.org). With std::vector and boost::shared_ptr you can go an extremely long way without giving pointers any special considerations. Cheers, Nicola Musatti From george.sakkis at gmail.com Mon Apr 28 22:49:57 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Mon, 28 Apr 2008 19:49:57 -0700 (PDT) Subject: How to unget a line when reading from a file/stream iterator/generator? References: Message-ID: <5e3854fa-557f-4475-8123-346346767097@k13g2000hse.googlegroups.com> On Apr 28, 10:10?pm, pyt... at bdurham.com wrote: > George, > > > Is there an elegant way to unget a line when reading from a file/stream iterator/generator? > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502304 > > That's exactly what I was looking for! > > For those following this thread, the above recipe creates a generic > object that wraps any iterator with an 'unget' ("push") capability. > Clean and elegant! > > Thank you, > Malcolm A small suggestion: since unget is expected to be called infrequently, next should better be faster for the common case instead of penalizing it with a try/except: def next(self): if not self.pushed_back: return self.it.next() else: return self.pushed_back.pop() George From ellingt8877 at gmail.com Mon Apr 28 01:50:40 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:50:40 -0700 (PDT) Subject: amateur crack whores Message-ID: <785397dc-cb82-452a-9579-a7b482ff140f@l25g2000prd.googlegroups.com> amateur crack whores http://crack.cracksofts.com From kyosohma at gmail.com Fri Apr 11 15:21:41 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 11 Apr 2008 12:21:41 -0700 (PDT) Subject: Profiling programs/scripts? References: Message-ID: On Apr 11, 1:49 pm, skanem... at yahoo.se wrote: > how do i profile a program? i found out that there are some profilers > included in the standard library but couldnt really figure out how to > access/use them Are you talking about using PyChecker or nose or what? In other words, do you want to check your script for errors, documentation issues, compliance with PEPs or something else? Maybe you mean introspection? If the latter, here are a few links on the subject: http://www.ibm.com/developerworks/library/l-pyint.html http://www.diveintopython.org/power_of_introspection/index.html http://www.ginstrom.com/scribbles/2007/10/24/python-introspection-with-the-inspect-module/ If you want to do code coverage, PEPs stuff or checking for errors, use PyChecker and PyLint or nose. See the following for more info: http://www.logilab.org/857 http://pychecker.sourceforge.net/ http://somethingaboutorange.com/mrl/projects/nose/ Mike From jens at aggergren.dk Tue Apr 29 08:20:14 2008 From: jens at aggergren.dk (Jens) Date: Tue, 29 Apr 2008 05:20:14 -0700 (PDT) Subject: Zope/DTML Infuriating... References: Message-ID: <6db28964-d1ff-4c48-8e6d-ddee30e8e31a@y21g2000hsf.googlegroups.com> On Apr 29, 1:59?pm, Marco Mariani wrote: > Jens wrote: > > I've the checked that i'm referring to the variables correctly, so the > > only explanation i can come up with, is that '+' doesn't result in a > > string concatenation (with implicit typecast to string of the integer > > variable(this is a interpreted language after all)). > > No, sorry. You really need to read the python tutorial at the very least. > You might have wrong assumptions from previous PHP experiences. > > ?>>> 'x'+4 > Traceback (most recent call last): > ? ?File "", line 1, in > TypeError: cannot concatenate 'str' and 'int' objects > ?> ... and the non snobby answer would have been: ... From tim.arnold at sas.com Wed Apr 9 13:03:06 2008 From: tim.arnold at sas.com (Tim Arnold) Date: Wed, 9 Apr 2008 13:03:06 -0400 Subject: set file permission on windows References: <7d75fc7b-a2b7-4ca2-b386-27da975043d0@m44g2000hsc.googlegroups.com> Message-ID: "Tim Golden" wrote in message news:mailman.59.1207681890.17997.python-list at python.org... > Tim Arnold wrote: >> "Mike Driscoll" wrote in message >> news:7d75fc7b-a2b7-4ca2-b386-27da975043d0 at m44g2000hsc.googlegroups.com... >>> On Apr 8, 12:03 pm, "Tim Arnold" wrote: >>>> >> >>> According to the following thread, you can use os.chmod on Windows: >>> >>> http://mail.python.org/pipermail/python-list/2003-June/210268.html >>> >>> You can also do it with the PyWin32 package. Tim Golden talks about >>> one way to do it here: >>> >>> http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html >>> >>> Also see the following thread: >>> >>> http://mail.python.org/pipermail/python-win32/2004-July/002102.html >>> >>> or >>> >>> http://bytes.com/forum/thread560518.html >>> >>> Hope that helps! >>> >>> Mike >> >> Hi Mike, >> It does help indeed, especially the last two links. > > Hi, Tim. For the purposes of improving that page of mine linked > above, would you mind highlighting what made it less useful > than the last two links? On the surface, it seems to match your > use case pretty closely. Was there too much information? Too > little? Poor formatting? Just didn't feel right? I've a small set > of security-related pages in train and I'd rather produce something which > people find useful. > > Thanks > > TJG Hi TJG. Thanks for the site. Unfortunately, I mis-typed in the previous reply and that should have been the 'first two links' instead of 'last two links'. In fact I bookmarked your site so I can re-read the material and I copied the code to play around with. Excellent example--it contains just what I needed to know, esp. since it replaces the dacl instead of modifying one. Now I can remove access for 'Everybody' by simply not including it in the new dacl. thanks! --Tim Arnold From ladynikon at gmail.com Sun Apr 20 12:22:37 2008 From: ladynikon at gmail.com (Danyelle Gragsone) Date: Sun, 20 Apr 2008 12:22:37 -0400 Subject: prevx1 crack In-Reply-To: <9f3aa585-8049-4af6-b019-697941c73163@a5g2000prg.googlegroups.com> References: <9f3aa585-8049-4af6-b019-697941c73163@a5g2000prg.googlegroups.com> Message-ID: <59f9c5160804200922h7541f8edgd5289fceb574e2ca@mail.gmail.com> what the ... From tjreedy at udel.edu Tue Apr 8 23:59:52 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 8 Apr 2008 23:59:52 -0400 Subject: style question - hasattr References: Message-ID: "ian" wrote in message news:a59f2b47-d1c2-4db5-82a6-34746af5d1dc at w8g2000prd.googlegroups.com... | In old python code i would use 'has_key' to determine if an element | was present in a dictionary. | | Python 3.0 will even removed 'has_key'. The reason for removal is that | using the 'in' operator is a cleaner syntax and having two ways to | achieve the same result is against the principle of the language. | | Ok, so what about 'hasattr' ?? | hasattr(myObject,'property') | seems equivalent to | 'property' in dir(myObject) | | I would suggest that using the 'in' is cleaner in this case also. Is | there a performance penalty here? Yes, the construction of the dir. And I think there may be slight differences between the two. tjr From bronger at physik.rwth-aachen.de Thu Apr 24 07:28:04 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Thu, 24 Apr 2008 13:28:04 +0200 Subject: Python development tools References: <09992de9-39fa-4ee6-8009-35732f3433fb@y21g2000hsf.googlegroups.com> <87fxtcnvj7.fsf@physik.rwth-aachen.de> <48106ba0$0$11087$426a34cc@news.free.fr> Message-ID: <873apbqypn.fsf@physik.rwth-aachen.de> Hall?chen! Bruno Desthuilliers writes: > [...] > >> and it ends multi-line strings at single quotes. > > it chokes on unbalanced single quotes in triple-single-quoted > strings, and on unbalanced double-quotes in triple-double-quoted > strings, yes. Given that I never use triple-single-quoted strings > (and don't remember having seen such a thing in the thousands of > third-part .py files I've read so far), I'd qualify this as at > most a very minor annoyance. Not having proper python-shell and > pdb integration is wwwwaaaayyyy more annoying IMHO. My formulation was unfortunate. What doesn't work (at least for me) is something like """This is a docstring in which some "variables" are quoted.""" Here, "variables" doesn't seem to belong to the docstring for python-mode. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From watches0560 at global-replica-watch.com Fri Apr 25 12:04:21 2008 From: watches0560 at global-replica-watch.com (watches0560 at global-replica-watch.com) Date: Fri, 25 Apr 2008 09:04:21 -0700 (PDT) Subject: Brand Watches Seiko Men's Watches Premier SNA745P - AA Discount, Swiss, Fake Message-ID: <31119dff-a2e4-4523-a998-0d1803e0581e@i36g2000prf.googlegroups.com> Brand Watches Seiko Men's Watches Premier SNA745P - AA Discount, Swiss, Fake Browse our Seiko Men's Watches Premier SNA745P - AA Swiss watches, which is sure the watch you are looking for at low price. There are more high quality designer watch Swiss for selection Seiko Men's Watches Premier SNA745P - AA Link : http://www.watches-brand.com/Seiko-wristwatch-7594.html Brand : Seiko ( http://www.watches-brand.com/Seiko-Watches.html ) Model : Seiko Men's Watches Premier SNA745P - AA Description :

Seiko watches - indispensable for today's lifestyle. Seiko watches - an important accessory for today's lifestyle.

Sale Price : $ 245.00 Seiko Men's Watches Premier SNA745P - AA Details :
  • Brand: Seiko
  • Band material: Black Leather Strap
  • Case material: Stainless Steel
  • Dial color: Black
  • Movement type: Quartz
  • Water-resistant to 100 meters
Seiko Men's Watches Premier SNA745P - AA is new brand Swiss, join thousands of satisfied customers and buy your Seiko with total satisfaction. A watches-brand.COM 30 Day Money Back Guarantee is included with every Seiko Fake Series for secure, risk-free online shopping. watches-brand.COM does not charge sales tax for the Fake Seiko Men's Watches Premier SNA745P - AA. All of our Fake watches are shipped via EMS to worldwide. Normally it takes 3days to prepare the fake watch you ordered and 5-10days to transmit depending on the different destination.We pay for the free shipping cost for total quantity over 20 pcs. The EMS tracking NO. will be sent by email when an order is shipped from our warehouse. No more other charges from watches-brand.com such as the tax. If you have any other questions please check our other pages or feel free to email us by sales at watches-brand.com. The Same Fake Seiko Watches Series : Seiko Men's Watches Premier SNL039 - 5 : http://www.watches-brand.com/Seiko-wristwatch-7595.html Seiko Men's Watches Premier SNL041 - 5 : http://www.watches-brand.com/Seiko-wristwatch-7596.html Seiko Men's Watches Premier SNL041P - AA : http://www.watches-brand.com/Seiko-wristwatch-7597.html Seiko Men's Watches Premier SNL041P2 - AA : http://www.watches-brand.com/Seiko-wristwatch-7598.html Seiko Men's Watches Premier SNL042P - AA : http://www.watches-brand.com/Seiko-wristwatch-7599.html Seiko Men's Watches Premier SNL044P - AA : http://www.watches-brand.com/Seiko-wristwatch-7600.html Seiko Men's Watches Premier SNP001P - AA : http://www.watches-brand.com/Seiko-wristwatch-7601.html Seiko Men's Watches Premier SNP003P - AA : http://www.watches-brand.com/Seiko-wristwatch-7602.html Seiko Men's Watches Premier SNP004P - AA : http://www.watches-brand.com/Seiko-wristwatch-7603.html Seiko Men's Watches Premier SNP005P - AA : http://www.watches-brand.com/Seiko-wristwatch-7604.html Brand Watches Seiko Men's Watches Premier SNA745P - AA Discount, Swiss, Fake From kyosohma at gmail.com Thu Apr 24 13:36:29 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Thu, 24 Apr 2008 10:36:29 -0700 (PDT) Subject: Installer References: Message-ID: <5fa6a753-82a3-4465-9e47-165fd5f312c8@t54g2000hsg.googlegroups.com> On Apr 24, 11:39?am, Chris wrote: > Hey all, > > I've created a python program that relies on pysqlite, wxpython, and > matplotlib. Is there any way of creating an installer that will > install all these modules, python 2.5 and my program? > > Thanks. Chris, If all you're doing is creating an installer for your custom Python program to be run on PCs without Python, then you should take a look at py2exe or gui2exe (a py2exe wrapper). I use the latter to roll my program into an exe, then I use Inno Setup (which is free) to create the installer. Mike From ajaksu at gmail.com Wed Apr 2 11:55:22 2008 From: ajaksu at gmail.com (ajaksu) Date: Wed, 2 Apr 2008 08:55:22 -0700 (PDT) Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: On Apr 1, 10:15?pm, AK wrote: > Hello, Hiya > I find that I learn easier when I go from specific examples to a more > general explanation of function's utility and I made a reference guide > that will eventually document all functions, classes and methods in > Python's Standard Library. Thanks a lot, this is a great resource. > For now, I covered about 20 most important > modules. I will be adding more modules and eventually I'll cover > everything. Here's my progress so far, let me know if this is useful; > I'll be glad to hear comments/suggestions/etc: > > http://www.lightbird.net/py-by-example/ > Content is nice, presentation can be tweaked towards making examples easier to understand and run on the interactive console. I suggest taking a look at PyMOTW[1] and Crunchy[2][3] for nice ideas. Best regards, Daniel [1] http://www.doughellmann.com/projects/PyMOTW/ [2] http://code.google.com/p/crunchy/ [3] http://us.pycon.org/2008/conference/schedule/event/46/ From google at mrabarnett.plus.com Mon Apr 21 20:08:08 2008 From: google at mrabarnett.plus.com (MRAB) Date: Mon, 21 Apr 2008 17:08:08 -0700 (PDT) Subject: Problems replacing \ with \\ References: <0ca30eb2-3791-4910-9e78-f32e3b2a72cb@2g2000hsn.googlegroups.com> Message-ID: On Apr 21, 11:48 pm, "samsli... at gmail.com" wrote: > Hi... > > Here's a weird problem...I'm trying to escape a bunch of data to put > into a database. > > Here's what I have: > > def escape(string): > """ > Escape both single quotes and blackslashes > >>> x = r"fun\fun" > >>> escape(x) > 'fun\\\\fun' > """ > string = string.replace('\\', '\\\\') > return string > > Now the commands in the doctest work when I type them by hand into the > python interpreter!>>> x = r"fun\fun" > >>> escape(x) > > 'fun\\\\fun' > > But they don't work when I actually run them with doctest: > Failed example: > escape(x) > Expected: > 'fun\\fun' > Got: > 'fun\x0cun' > > Why? > > Thanks! Your doctest is in a triple-quoted string which contains the line: >>> x = r"fun\fun" ^^ which is the same as: >>> x = r"fun\x0cun" ^^^^ If you wrap a raw string in just quotes that is isn't a raw string any longer! HTH From eduardo.padoan at gmail.com Tue Apr 1 15:11:34 2008 From: eduardo.padoan at gmail.com (Eduardo O. Padoan) Date: Tue, 1 Apr 2008 16:11:34 -0300 Subject: Is this a good time to start learning python? In-Reply-To: <88fa881e-e59b-4682-801c-90ef08a1480a@a22g2000hsc.googlegroups.com> References: <47f1140e$0$735$a729d347@news.telepac.pt> <88fa881e-e59b-4682-801c-90ef08a1480a@a22g2000hsc.googlegroups.com> Message-ID: On Tue, Apr 1, 2008 at 3:57 PM, wrote: > On Apr 1, 12:47 pm, "Gabriel Genellina" > wrote: > > En Tue, 01 Apr 2008 13:57:55 -0300, escribi?: > > > > > > On Mar 31, 1:36 pm, "Gabriel Genellina" > > > wrote: > > > > >> Don't be scared by the "backwards incompatible" tag - it's the way to > > >> get > > >> rid of nasty things that could not be dropped otherwise. > > > > > I would consider breaking production code to be "nasty" as well. > > > > > Please explain how the existence of Python 3.0 would break your production > > code. > > The existence of battery acid won't hurt me either, unless I come into > contact with it. If one eventually upgrades to 3.0 -- which is > ostensibly the desired path -- their code could break and require > fixing. And how would this happen? I dont know of any good software distribution that upgrades a component to another major revision without asking first. The desired path is that, if somene wants to port his software to Python 3.0, that he follow the migration plan. Final users will install Python 3.0 as python3.0 anyway, with Python 2.x as default 'python' binary. > Backward compatibility is important. C++ could break all ties with C > to "clean up" as well, but it would be a braindead move that would > break existing code bases upon upgrade. > C++ is not C. No one "upgrades" from C to C++. -- Eduardo de Oliveira Padoan http://www.advogato.org/person/eopadoan/ Bookmarks: http://del.icio.us/edcrypt From danb_83 at yahoo.com Thu Apr 3 19:28:09 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Thu, 3 Apr 2008 16:28:09 -0700 (PDT) Subject: sine in python References: <92f00617-28ee-4104-bd04-a48f87d84785@q27g2000prf.googlegroups.com> Message-ID: On Apr 3, 6:09 pm, zillo... at googlemail.com wrote: > On Apr 3, 11:58 pm, Astan Chee wrote: > > > > > Hi, > > I have a math function that looks like this > > sin (Theta) = 5/6 > > How do I find Theta (in degrees) in python? I am aware of the math.sin > > function, but is there a reverse? maybe a sine table in python? > > Thanks > > Astan > > import math > If you now do > dir(math) > you'll see that the module has the functions 'asin' and 'degrees' that > find the inverse sine of a number, and convert radians to degrees, > respectively Better yet, do help(math) which will display the docstrings. From hexade at gmail.com Sun Apr 13 06:13:09 2008 From: hexade at gmail.com (Hexade) Date: Sun, 13 Apr 2008 03:13:09 -0700 (PDT) Subject: SQLite OperationalError near "?" References: <7e592f06-42b5-4834-8f7c-34c9bc44aceb@s39g2000prd.googlegroups.com> Message-ID: <1c355a11-da2b-40fe-9dba-61bd866abbc6@8g2000hsu.googlegroups.com> On 13 avr, 03:00, John Machin wrote: > On Apr 13, 8:45 am, Hexade wrote: > > > Hello > > > I would like to use the safe "?" placeholder in my SQLite requests but > > I got the following error: > > > Traceback (most recent call last): > > ? (...) > > ? cursor.execute("SELECT ? FROM ? WHERE name = ? ", (key, self.table, > > self.name)) > > OperationalError: near "?": syntax error > > > key, self.table and self.name are standart strings. > > > Any idea about how to solve this problem ? > > You may like to read the answer to the question on sqlite3 that was > posted 45 minutes before yours. Thank you. I guess you are speaking about http://groups.google.com/group/comp.lang.python/browse_thread/thread/50a8ad977ed31e2a# From steve at holdenweb.com Thu Apr 24 22:57:07 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 22:57:07 -0400 Subject: Psyco alternative In-Reply-To: <8b7d9523-1d15-41e5-8b69-39f8250e6a6f@i76g2000hsf.googlegroups.com> References: <8b7d9523-1d15-41e5-8b69-39f8250e6a6f@i76g2000hsf.googlegroups.com> Message-ID: sturlamolden wrote: > On Apr 25, 3:27 am, Steve Holden wrote: > >> That seems a little harsh: it's Python-in-a-strait-jacket. >> >> The fact remains that since RPython programs also run under the standard >> interpreter (albeit a factor of maybe a hundred times more slowly) their >> claim of self-hosting is valid. > > What is the smallest subset of Python needed to make a Turing complete > computer language? And would you still call that Python? > That's completely irrelevant. Let's just step back a bit. You started this by saying: > On Mar 27, 4:44 pm, Jean-Paul Calderone wrote: > >> > PyPy is self-hosted and has been for some time (a year or so?). > > This is technically not correct. PyPy is hosted by RPython, which is > not Python but a different language all together. I am simply pointing out that RPython is used for efficiency, not to do things that can't be done in standard Python. Since everything that is done in RPython can also be done, albeit more slowly, in standard Python, the claim to be self-hosting is valid despite your disagreement. In other words, you can take the PyPy translator and run it on CPython. The fact that they choose to use restricted Python instead in their "production" system is merely an optimization. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From billingspanshism at gmail.com Sat Apr 19 17:17:20 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:17:20 -0700 (PDT) Subject: rock and republic victoria beckham Message-ID: <445c4b3b-25ff-4537-a48e-6897febce861@y21g2000hsf.googlegroups.com> Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From usenet-nospam at well-adjusted.de Tue Apr 8 11:02:05 2008 From: usenet-nospam at well-adjusted.de (Jochen Schulz) Date: Tue, 8 Apr 2008 17:02:05 +0200 Subject: Data structure recommendation? References: Message-ID: * Steven Clark: > Hi all- > > I'm looking for a data structure that is a bit like a dictionary or a > hash map. In particular, I want a mapping of floats to objects. > However, I want to map a RANGE of floats to an object. This solution may be more than you actually need, but I implemented two metric space indexes which would do what you want (and I wanted to plug it anyway :)): http://well-adjusted.de/mspace.py/ You can do arbitrary range searches and nearest-neighbour search in these indexes provided you have a metric distance function for the objects you want to index. The distance function in your case would simply be the absolute difference between your floats. If every log message was contained in objects of this type: class LogMessage(object) def __init__(self, timestamp, object): self.timestamp = timestamp self.message = message you could write a distance function for these objects like this: def log_distance(log1, log2): return abs(log1.timestamp - log2.timestamp) and then you would create and search an index like this: from mspace import VPTree index = VPTree(all_log_messages, log_distance) index.search(single_msg, 10) The last line would yield all log messages within ten seconds (or whatever the unit of your timestamps is) of the given LogMessage single_msg. You could also use index.nn_search(single_msg, 3) To find the three messages closest to the given single_msg. Searching should be quite fast (O(log(n)), but indexing might take some time (O(n*log(n))). The problem is that VPTrees have to be constructed from the complete data set initially. They cannot grow. The alternative from mspace.py, BKTrees, may grow over time but they don't work with non-discrete distances. If you want to use them, you'd have to convert your timestamps to int/long first. J. -- In the west we kill people like chickens. [Agree] [Disagree] From anuraguniyal at yahoo.com Tue Apr 1 23:42:54 2008 From: anuraguniyal at yahoo.com (anuraguniyal at yahoo.com) Date: Tue, 1 Apr 2008 20:42:54 -0700 (PDT) Subject: bsddb3 thread problem References: <391d152a-aa74-40e2-804e-14f30756fda3@u10g2000prn.googlegroups.com> Message-ID: <658d94dd-d636-411d-a915-2a9d254417e0@d21g2000prf.googlegroups.com> On Apr 1, 9:02?pm, Rhamphoryncus wrote: > It's my understanding that the connection is NOT thread-safe. ?Your > thread should be using an entirely separate connection.- Hide quoted text - > Can you please explain that, which connection you are talking about? How to modify my test script for that? rgds Anurag From XX.XmcX at XX.XmclaveauX.com Wed Apr 23 15:08:10 2008 From: XX.XmcX at XX.XmclaveauX.com (MC) Date: Wed, 23 Apr 2008 21:08:10 +0200 Subject: Calling Python code from inside php References: Message-ID: Hi! If you are under Windows, you can: - call Python's functions via Active-Scripting - call a Python COM server (functions or properties) For that, use Pywin32. And, in all cases, call functions can use parameters. -- @-salutations Michel Claveau From ptmcg at austin.rr.com Wed Apr 2 14:05:49 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Wed, 2 Apr 2008 11:05:49 -0700 (PDT) Subject: Understanding bmp image files References: <2537c458-b4d5-480d-8407-168a2b59a27e@u10g2000prn.googlegroups.com> Message-ID: <4afbfaaf-1a31-4ffa-b987-5a7c18f6097d@24g2000hsh.googlegroups.com> On Apr 2, 12:51?pm, pranav wrote: > Hello, > I want to read a BMP file, do some processing and then write it in a > new file. The problem is in the third step. For reading the file, i > have converted the file into decimal numbers, representing the pixel > values. Then i perform calculations on those decimal numbers. Now i am > unable to convert those into the format as required by the "bmp" file. > Any one, who is into image reading/manipulation, please help. Here is a link to a *very* crude BMP file utility I wrote a long time ago. (http://www.geocities.com/ptmcg/python/index.html#bmp) Follow the highlighted "module" link to see the underlying code - there are methods for saving the BMP data to a file. Perhaps those samples might give you some insight on what is required. (I would probably rewrite this to use the struct module nowadays, but this code works as is.) -- Paul From pydev at rscorp.ab.ca Wed Apr 23 23:27:13 2008 From: pydev at rscorp.ab.ca (Scott SA) Date: Wed, 23 Apr 2008 21:27:13 -0600 Subject: @classmethod question Message-ID: Hi, I'm using the @classemethod decorator for some convenience methods and for some reason, either mental block or otherwise, can't seem to figure out how to elegantly detect if the call is from an instance or not. Here's the problem: Within the class definition, 'isinstance' has nothing to compare to because the class does not appear to exist. This is NOT a great example, but it outlines the the code: class RecipieClass: def __init__(self): pass @classmethod def get_ingrendients(self, recipie_list=None): if isinstnace(self,RecipieClass): return self.do_something_interesting() else: return do_something_boring(recipie_list) Yes, I can test to see if the param exists, but that makes the call exclusive i.e. I can _only_ call it as an instance or with a parameter. Why am I doing this? It is a series of convenience methods, in this case I'm interacting with a database via an ORM (object-relational model). I want the ability to call a class-ojbect and get related values, or pass some criteria and get related values for them without collecting the records first as instances, then iterating them. I need to call this from several places so I want to be DRY (don't repeat yourself). The easiest way to describe this as an analogy would be like having a recipie for cookies and wanting to know all of the ingredients ahead of time. Then, at another time, wanting to know what all the ingredients would be to make cookies, cake and bread (i.e. complete shopping list). cookie_recipie = RecipieClass.get_recipie('cookies') cookie_recipie.get_ingredients() 2C Flour 0.5 C Sugar ... RecipieClass.get_ingrendients(['cookies','cake','bread']) 8C Flour 2C Sugar ... Of course any suggestions on how this might be better approached would be interesting too. TIA, Scott From s0suk3 at gmail.com Thu Apr 17 13:58:04 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 10:58:04 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <1952579a-3cfb-44ea-92aa-658daa64aee4@a70g2000hsh.googlegroups.com> <564dd82b-8670-4ead-a3c8-a22b30a3eb73@m73g2000hsh.googlegroups.com> Message-ID: <98406333-c7c0-4b98-845d-c18895644c4a@t54g2000hsg.googlegroups.com> On Apr 17, 12:34 pm, Michael Torrie wrote: > > Another thing to consider is that referencing a member of a class or > instance already *is* a dictionary lookup. It's how python works. Thus > dictionaries are optimized to be fast. Since strings are immutable, > python hashes them into a fast lookup pointer. So every time you say > mydict["mykey"], it already knows the lookup pointer (hash) for "mykey" > (the string) and can find the dictionary entry very quickly, ideally in > O(1) time (well maybe log(N)). Thus putting your headers in a > dictionary is actually a really good idea for performance reasons. I didn't know about that, thanks. So after all the trouble I went through writing those 200 loc I actually maid it worse... From tjreedy at udel.edu Mon Apr 14 13:36:42 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 14 Apr 2008 13:36:42 -0400 Subject: Different times between Python and System References: <66292b91-a2ed-44d1-8fe6-9f4ecd87299b@w1g2000prd.googlegroups.com> Message-ID: "Josh" wrote in message news:66292b91-a2ed-44d1-8fe6-9f4ecd87299b at w1g2000prd.googlegroups.com... | Hmm... That didn't work out so well that time. I feel like an | idiot. Previously there has been an hour difference between the | system time and the time that python reports. That suggests a (temporary?) problem with standard vs. daylight time. From brian.e.munroe at gmail.com Wed Apr 2 16:04:05 2008 From: brian.e.munroe at gmail.com (Brian Munroe) Date: Wed, 2 Apr 2008 13:04:05 -0700 (PDT) Subject: class / module introspection? References: <3c3f09df-08cb-4309-a870-6b12a813a8af@u36g2000prf.googlegroups.com> <0f14a289-55ef-49e5-b650-60f7aca371ad@i36g2000prf.googlegroups.com> <85761ed1-afe8-48cc-8c6d-73183e6692a9@i7g2000prf.googlegroups.com> Message-ID: On Apr 2, 12:33 pm, "bruno.desthuilli... at gmail.com" wrote: > > Why not do the import here, so you store a real module instead of a > name ? > Right now I'm still in the prototyping phase and haven't really thought everything through. I needed the names because I am populating a GUI selection list element. I also assumed that I could then lazy load the modules I needed... Thanks for the help though, you've gotten me past my first of many (I'm sure) hurdles! -- brian From matiassurdi at gmail.com Mon Apr 14 03:41:41 2008 From: matiassurdi at gmail.com (Matias Surdi) Date: Mon, 14 Apr 2008 09:41:41 +0200 Subject: Remote mac address Message-ID: Anyone knows how having the IP address of a host on the lan could I get the mac address of that hosr? p/d: Parsing the output of arp -a is not an option. Thanks a lot! From sam at mas.pl Wed Apr 2 08:23:21 2008 From: sam at mas.pl (sam) Date: Wed, 02 Apr 2008 14:23:21 +0200 Subject: Prototype OO In-Reply-To: References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> Message-ID: Gabriel Genellina napisa?(a): >>>> 1. You have different syntax for named and unnamed (lambdas) >>>> functions. Functions and methods are different things in Python even >>>> if they have same syntax. But all these are still a pieces of code >>>> that you use repeatedly to make some task. >>>> >>> A knife and scissors are both used to cut things, but that doesn't mean >>> they are the same. >> >> Well -- sometimes you have to use many, many types of scissors. > > I don't get the point - weren't you criticizing Python for having many > different kind of functions? Yes. Funciton is always a piece of code (program) that does something. There is no need for different syntax. And you said that it is good to have these two types of syntax. It sounds like: "it is good to have knife and scissors to cut the _same_ thing, because they are not the same". > What are those programmers needs? Programmers need to protect name in a namespace. Name mangling is not the best choice. From roy at panix.com Sun Apr 20 10:12:20 2008 From: roy at panix.com (Roy Smith) Date: Sun, 20 Apr 2008 10:12:20 -0400 Subject: from __future__ import print References: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> <670um2F2ljorfU1@mid.uni-berlin.de> Message-ID: "Diez B. Roggisch" wrote: > You are aware that it is only one character more to type? I'm not arguing for print vs. print(), but I do want to comment on the "character count" argument. I'm a pretty good typist, the result of having been forced in junior high school (in the mid 70's) to learn typing the "right way" -- on a typewriter with blank keycaps. It forced you to really learn to touch-type. I don't know if this was some touchy-feely idea that if they girls had to learn to type (after all, they were all going to be secretaries) then it's only fair to make the boys learn it too. Or, if they were just amazingly prescient about computers taking over the world and typing becoming an important high-tech skill. Either way, I learned to touch type. That being said, hitting the space bar is pretty much a freebie. You can do it with either thumb(*), and you don't have to move your fingers from the home row. To get the ( and ), you have to reach way up to the top row with one hand and down hit the shift key with the opposite pinkie. A much costlier operation in terms of maintaining a good typing speed. On the other hand, it's a well known (or at least well believed :-)) fact that code is read many more times than it's written. Making something easier to read is much more important than making it easy to type. (*) Oddly enough, as I type this and pay attention to what my fingers are doing, I find that I almost exclusively use the *left* thumb, which I never noticed before. From Lie.1296 at gmail.com Sun Apr 27 14:34:05 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 27 Apr 2008 11:34:05 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> Message-ID: <2d06b319-e2fd-4790-af61-6f90b9b1b3b1@m1g2000pre.googlegroups.com> On Apr 27, 6:28?am, n00m wrote: > No so simple, guys. > E.g., I can't solve (in Python) this:http://www.spoj.pl/problems/INTEST/ > Keep getting TLE (time limit exceeded). Any ideas? After all, it's > weekend. > > 450. Enormous Input Test > Problem code: INTEST > > The purpose of this problem is to verify whether the method you are > using to read input data is sufficiently fast to handle problems > branded with the enormous Input/Output warning. You are expected to be > able to process at least 2.5MB of input data per second at runtime. > > Input > The input begins with two positive integers n k (n, k<=107). The next > n lines of input contain one positive integer ti, not greater than > 109, each. > > Output > Write a single integer to output, denoting how many integers ti are > divisible by k. > > Example > Input: > 7 3 > 1 > 51 > 966369 > 7 > 9 > 999996 > 11 > > Output: > 4 The problem is faulty. First, the bottleneck on reading a huge input is the harddisk speed and the string processing, the result of the competition doesn't prove anything but how fast the string processor and the harddisk is. Python's string processing is not a very fast one as it creates a copy of the string every now and then. From bockman at virgilio.it Thu Apr 24 10:41:35 2008 From: bockman at virgilio.it (bockman at virgilio.it) Date: Thu, 24 Apr 2008 07:41:35 -0700 (PDT) Subject: How to get inner exception traceback References: <67b8nuF2m1a1kU1@mid.individual.net> <09ce6c51-3c23-4fb7-a369-d357c0f5d287@m73g2000hsh.googlegroups.com> Message-ID: On 24 Apr, 15:00, Christian Heimes wrote: > bock... at virgilio.it schrieb: > : > > > class ReraisedException(Exception): > > ? ? def __init__(self, message, exc_info): > > ? ? ? ? Exception.__init__(self, message) > > ? ? ? ? self.inner_exception = exc_info > > > ?try: > > ? ? ? try: > > ? ? ? ? ? import does_not_exit > > ? ? ? except ImportError: > > ? ? ? ? ? ?raise ReraisedException("Something wrong", sys.exc_info() ) > > ?except ReraisedException, e: > > ? ? ?... # here you can use e.inner_exception > > ?except: > > This may lead to reference cycles, please readhttp://docs.python.org/dev/library/sys.html#sys.exc_info > > Christian- Nascondi testo tra virgolette - > > - Mostra testo tra virgolette - Thanks. I was not aware of that (Last time I read that section, the warning was not there). I usually do something like that in my scripts: try: do_something() except: err, detail, tb = sys.exc_info() print err, detail traceback.print_tb(tb) According to the document you linked to, also this causes circular reference, although in my case it is ininfluent , since I usually do it only before exiting a program after a fatal error. However, this seems like a dark spot in the implementation of CPython. Do you now if this has/will be cleaned in Python 3.x ? I'd like to see a 'print_tb' method in the exception class, so that I could do something like this: try: do_something() except Exception, e : # I know, in python 3.0 the syntax will be different print e e.print_tb() Ciao ------- F.B. From aldo at nullcube.com Sat Apr 5 06:26:06 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Sat, 5 Apr 2008 21:26:06 +1100 Subject: ANN: pry unit testing framework In-Reply-To: References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> Message-ID: <20080405102606.GA15154@nullcube.com> Thus spake Kay Schluehr (kay.schluehr at gmx.net): > I'm not entirely sure what you are claiming here. From source > inspections I can see that TestSuite instances are instantiated by the > TestLoader and you are free to derive from TestLoader, overwrite its > methods and pass around another instance than defaultTestLoader ( or > a fresh instance of TestLoader which is the same thing ). ... and at this point your monkeypatched framework would no longer be much more compatible with existing test suites than Pry is. > My impression is that unittest is bashed so much because it has Java > style naming conventions i.e. for bike shading reasons Do you mean bike shedding, perhaps? At any rate, your impression is mostly incorrect. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 23 05:48:12 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 23 Apr 2008 11:48:12 +0200 Subject: help needed with classes/inheritance In-Reply-To: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> References: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> Message-ID: <480f05d0$0$25755$426a74cc@news.free.fr> barbaros a ?crit : > Hello everybody, > > I am building a code for surface meshes (triangulations for instance). > I need to implement Body objects (bodies can be points, segments, > triangles and so on), then a Mesh will be a collection of bodies, > together with their neighbourhood relations. > I also need OrientedBody objects, which consist in a body > together with a plus or minus sign to describe its orientation. > So, basically an OrientedBody is just a Body with an > integer label stuck on it. > > I implemented it in a very crude manner: > ------------------------------------------ > class Body: Unless you need compatibility with pre-2.2 Python versions, use a new-style class instead: class Body(object): > [...] > class OrientedBody: > def __init__ (self,b,orient=1): > # b is an already existing body > assert isinstance(b,Body) > self.base = b > self.orientation = orient > ------------------------------------------- > > My question is: can it be done using inheritance ? Technically, yes: class OrientedBody(Body): def __init__(self, orient=1): Body.__init__(self) self.orient = 1 Now if it's the right thing to do is another question... Another possible design could be to have an orient attribute on the Body class itself, with 0 => non-oriented (default), 1 => 'plus', -1 => 'minus' (or any other convention, depending on how you use this attribute). From grante at visi.com Thu Apr 17 09:49:53 2008 From: grante at visi.com (Grant Edwards) Date: Thu, 17 Apr 2008 08:49:53 -0500 Subject: What can we do about all the spam that the list is getting? References: <259ab201-9d2b-4e4e-88a7-e2fe277f0066@a23g2000hsc.googlegroups.com> Message-ID: On 2008-04-16, Mark Shroyer wrote: > In article >, > Mensanator wrote: > >> On Apr 16, 12:01?pm, sr... at ferg.org wrote: >> > What can we do about all the spam that comp.lang.python is getting? >> > Things are getting pretty bad. >> >> Buy Google and make them fix it. > > I've had pretty good luck with MT-NewsWatcher, a freeware Mac > newsreader that performs Bayesian spam filtering. > Thunderbird's Usenet reader also offers Bayesian filtering, > which presumably works just as well for classifying Usenet > spam as it does at handling email spam. > > So download a "real" NNTP client for whatever platform you're > on and give its spam filter a shot; clearly Google is not > interested in fighting spam itself. Plonking anything posted via google.groups is the simplest answer. -- Grant Edwards grante Yow! Am I accompanied by a at PARENT or GUARDIAN? visi.com From urquhart.nak at gmail.com Wed Apr 30 06:28:22 2008 From: urquhart.nak at gmail.com (urquhart.nak at gmail.com) Date: Wed, 30 Apr 2008 03:28:22 -0700 (PDT) Subject: microsoft office 2007 crack Message-ID: <561a471a-9ead-4bc7-b32a-ad169b26a2f6@z24g2000prf.googlegroups.com> microsoft office 2007 crack http://crack.cracksofts.com From bjourne at gmail.com Sun Apr 27 12:27:07 2008 From: bjourne at gmail.com (=?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=) Date: Sun, 27 Apr 2008 18:27:07 +0200 Subject: design choice: multi-threaded / asynchronous wxpython client? In-Reply-To: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: <740c3aec0804270927w43c2d5eal67d927811e91522b@mail.gmail.com> I think twisted is overkill for this problem. Threading, elementtree and urllib should more than suffice. One thread polling the server for each race with the desired polling interval. Each time some data is treated, that thread sends a signal containing information about what changed. The gui listens to the signal and will, if needed, update itself with the new information. The database handler also listens to the signal and updates the db. 2008/4/27, bullockbefriending bard : > I am a complete ignoramus and newbie when it comes to designing and > coding networked clients (or servers for that matter). I have a copy > of Goerzen (Foundations of Python Network Programming) and once > pointed in the best direction should be able to follow my nose and get > things sorted... but I am not quite sure which is the best path to > take and would be grateful for advice from networking gurus. > > I am writing a program to display horse racing tote odds in a desktop > client program. I have access to an HTTP (open one of several URLs, > and I get back an XML doc with some data... not XML-RPC.) source of > XML data which I am able to parse and munge with no difficulty at all. > I have written and successfully tested a simple command line program > which allows me to repeatedly poll the server and parse the XML. Easy > enough, but the real world production complications are: > > 1) The data for the race about to start updates every (say) 15 > seconds, and the data for earlier and later races updates only every > (say) 5 minutes. There is no point for me to be hammering the server > with requests every 15 seconds for data for races after the upcoming > race... I should query for this perhaps every 150s to be safe. But for > the upcoming race, I must not miss any updates and should query every > ~7s to be safe. So... in the middle of a race meeting the situation > might be: > race 1 (race done with, no-longer querying), race 2 (race done with, > no longer querying) race 3 (about to start, data on server for this > race updating every 15s, my client querying every 7s), races 4-8 (data > on server for these races updating every 5 mins, my client querying > every 2.5 mins) > > 2) After a race has started and betting is cut off and there are > consequently no more tote updates for that race (it is possible to > determine when this occurs precisely because of an attribute in the > XML data), I need to stop querying (say) race 3 every 7s and remove > race 4 from the 150s query group and begin querying its data every 7s. > > 3) I need to dump this data (for all races, not just current about to > start race) to text files, store it as BLOBs in a DB *and* update real > time display in a wxpython windowed client. > > My initial thought was to have two threads for the different update > polling cycles. In addition I would probably need another thread to > handle UI stuff, and perhaps another for dealing with file/DB data > write out. But, I wonder if using Twisted is a better idea? I will > still need to handle some threading myself, but (I think) only for > keeping wxpython happy by doing all this other stuff off the main > thread + perhaps also persisting received data in yet another thread. > > I have zero experience with these kinds of design choices and would be > very happy if those with experience could point out the pros and cons > of each (synchronous/multithreaded, or Twisted) for dealing with the > two differing sample rates problem outlined above. > > Many TIA! > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- mvh Bj?rn From deets at nospam.web.de Wed Apr 2 05:40:20 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 02 Apr 2008 11:40:20 +0200 Subject: IM status with appscript References: Message-ID: <65h2l0F2fba8bU1@mid.uni-berlin.de> Oolon Colluphid wrote: > hi, > i need access to application attributes of IM (like Adium, aMsn, MS > Messenger) on Mac platform via appscript module. > once instantiated the application object with: app=app("Adium") > i don't know how recover information like status, and i have find no > references. Use the appscript examples + the OS X script-editor to see what scriptable properties exactly the IM-application offers. You can drag the application-icon into the script-library. Diez From arnodel at googlemail.com Sun Apr 27 07:51:50 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 27 Apr 2008 12:51:50 +0100 Subject: removing extension References: Message-ID: Lie writes: > On Apr 27, 6:05 pm, Lie wrote: >> >> I don't know if this is the simplest way, but you can use re module. >> >> import re >> pat = re.compile(r'(.*?)\..*') > > Sorry, this line should be: > pat = re.compile(r'(.*)\..*') > > or paths like these wouldn't pass correctly: > "C:\\blahblah.blah\\images.20.jpg" > >> name = pat.search('C:\\myimages\\imageone.jpg').group(1) >> print name More simply, use the rsplit() method of strings: >>> path = r'C:\myimages\imageone.jpg' >>> path.rsplit('.', 1) ['C:\\myimages\\imageone', 'jpg'] >>> path = r"C:\blahblah.blah\images.20.jpg" >>> path.rsplit('.', 1) ['C:\\blahblah.blah\\images.20', 'jpg'] HTH -- Arnaud From kyosohma at gmail.com Tue Apr 8 16:44:14 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 8 Apr 2008 13:44:14 -0700 (PDT) Subject: new user needs help! References: <16571823.post@talk.nabble.com> Message-ID: On Apr 8, 3:38 pm, Steve Holden wrote: > drjekil wrote: > > I am totally new in biopython and its my first program.so may be i am asking > > stupid question. > > New? Most questions are sensible. > > Let's suppose that the four lines you give below are stored in a text > file called "/tmp/data.txt". > > > I am working with a text filelooks like this: > > #NAME AA TOPO ACCESS DSSP STRIDE Z-COORD > > 1lghB A i 79.8 H H -24.58 > > 1lghB V i 79.6 H H -22.06 > > 1lghB H i 71.9 H H -19.94 > > f = open("/tmp/data.txt", 'w') > > will open that file. Don't do that! You will overwrite the original! > > You can throw the first line away with > > headings = f.next() I forgot to throw away the first line in my code though...so mine has errors too. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ Mike From dickinsm at gmail.com Sat Apr 5 19:25:49 2008 From: dickinsm at gmail.com (Mark Dickinson) Date: Sat, 5 Apr 2008 16:25:49 -0700 (PDT) Subject: Best way to check if string is an integer? References: Message-ID: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> On Apr 5, 6:19?pm, skanem... at yahoo.se wrote: > which is the best way to check if a string is an number or a char? > could the 2nd example be very expensive timewise if i have to check a > lot of strings? You might be interested in str.isdigit: >>> print str.isdigit.__doc__ S.isdigit() -> bool Return True if all characters in S are digits and there is at least one character in S, False otherwise. Mark From ankitks.mital at gmail.com Thu Apr 3 18:21:19 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Thu, 3 Apr 2008 15:21:19 -0700 (PDT) Subject: python bisect questions References: <6bb6927b-f553-40db-a142-2ce86b9e819f@q27g2000prf.googlegroups.com> Message-ID: On Apr 3, 4:24?pm, "Terry Reedy" wrote: > wrote in message > > news:6bb6927b-f553-40db-a142-2ce86b9e819f at q27g2000prf.googlegroups.com... > |I am week on functional programming, and having hard time > | understanding this: > | > | class myPriorityQueue: > | ? ? ?def __init__(self, f=lamda x:x): > | ? ? ? ? ? ? ?self.A = [] > | ? ? ? ? ? ? ?self.f = f > | > | ? ? ?def append(self, item) > | ? ? ? ? ? ? ?bisect.insort(self.A, (self.f(item), item)) > | ? ?............ > | > | now I know we are inserting items(user defined type objects) in list A > | base on sorting order provided by function A. > | but what I don't understand is bisect command > | what does bisect.insort(self.A, (self.f(item), item)) doing here is doc insort_right(a, x[, lo[, hi]]) Insert item x in list a, and keep it sorted assuming a is sorted. If x is already in a, insert it to the right of the rightmost x. Optional args lo (default 0) and hi (default len(a)) bound the slice of a to be searched. but I am still confuse. self.A is my list a. and item is x that I am trying to insert. So it needs to be of type item not (self.f(item), item) It doesn't say anything pass sorting function self.f(item). Also I am new to Python Please help? > > The snippet is missing 'import bisect'. ?The module is documented in the > Lib Ref. ?Or, in the interpreter, help(bisect.insort) redirects you to > help(bisect.insort_right), which will answer your question. > > | isn't it is returning truple of (self.f(item), item)). > > no, see doc > > | why it is not > | biset.insort(self.A, item) > | A.sort(f) > > Efficiency, given that self.A is already sorted. > > tjr From sjmachin at lexicon.net Mon Apr 21 19:47:43 2008 From: sjmachin at lexicon.net (John Machin) Date: Mon, 21 Apr 2008 23:47:43 GMT Subject: dynamically importing a module and function In-Reply-To: References: <480d1782$1@news.mel.dft.com.au> Message-ID: <480d27a3@news.mel.dft.com.au> rkmr.em at gmail.com wrote: > On Mon, Apr 21, 2008 at 3:39 PM, John Machin wrote: >> rkmr.em at gmail.com wrote: >>> data['module'], in the directory data['cwd'] >> OT: Any good reason for using a dictionary instead of a class instance >> (data.functiom, data.module, etc)? > not really, i just wanted to stick to primitive python data types. > > >>> If I do this from python interactive shell (linux fedora core 8) from >>> dir /home/mark it works fine: >>> >>> cwd = data['cwd'] >>> os.chdir(cwd) >>> print os.getcwd() >>> module = __import__(data['module']) >>> function = getattr(module, data['function']) >>> >>> > >> saved = sys.path >> sys.path = data['cwd'] >> module = __import__(data['module']) >> sys.path = saved > > now the module gets loaded, but i am not able to get the function from > the module, though it works fine in the interactive-shell > > Traceback (most recent call last): > File "/home/mark/work/common/funcq.py", line 62, in > if __name__ == '__main__':do() > File "/home/mark/work/common/funcq.py", line 35, in do > function = getattr(module, data['function']) > AttributeError: 'module' object has no attribute 'new' > > > this works in shell though.. >>>> import os >>>> os.chdir('/home/mark/work/proj1') >>>> import sys >>>> sys.path.append('/home/mark/work/proj1') >>>> module = __import__('app') >>>> function = getattr(module, 'new') >>>> function(1) > 1 It's not at all obvious that the "works in shell" code is the same as the code in your script. Consider the possibility that as a result of frantic experimentation you have multiple copies of app.* with varying contents lying around. Try this in your script so that you can see exactly what it is doing, instead of comparing it to a strawman: print "attempting to import", whatever module = __import__(whatever) print "got", module.__name__, "from", os.path.abspath(module.__file__) print "module contents":, dir(module) From fetchinson at googlemail.com Sun Apr 20 17:10:13 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Sun, 20 Apr 2008 14:10:13 -0700 Subject: I would like to learn scripting in Python too! In-Reply-To: <8339da0f0804201151s1ba691e3n970c2827abc22cae@mail.gmail.com> References: <8339da0f0804201151s1ba691e3n970c2827abc22cae@mail.gmail.com> Message-ID: > I am a software tester and I see lot of testers on the forums saying Python > is a wonderful scripting language that testers use on a daily basis. > > I would also like to learn to script in Python but I do not have any > programming background. This is a good starting point: http://wiki.python.org/moin/BeginnersGuide HTH, Daniel From gabriel.rossetti at mydeskfriend.com Wed Apr 2 09:12:57 2008 From: gabriel.rossetti at mydeskfriend.com (Gabriel Rossetti) Date: Wed, 02 Apr 2008 15:12:57 +0200 Subject: Python in High School In-Reply-To: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> Message-ID: <47F38659.4020101@mydeskfriend.com> sprad wrote: > I'm a high school computer teacher, and I'm starting a series of > programming courses next year (disguised as "game development" classes > to capture more interest). The first year will be a gentle > introduction to programming, leading to two more years of advanced > topics. > > I was initially thinking about doing the first year in Flash/ > ActionScript, and the later years in Java. My reasoning is that Flash > has the advantage of giving a quick payoff to keep the students > interested while I sneak in some OOP concepts through ActionScript. > Once they've gotten a decent grounding there, they move on to Java for > some more heavy-duty programming. > > I've never used Python, but I keep hearing enough good stuff about it > to make me curious. > > So -- would Python be a good fit for these classes? Could it equal > Java as the later heavy-duty language? Does it have enough quickly- > accessible sparklies to unseat Flash? > > I want to believe. Evangelize away. > I think it's a good idea (to use python), Mr. Swinnen, a high school teacher in Belgium wrote a book out of the course that he created for his programming class : Apprendre ? programmer avec Python, 2e ?dition, O'Reilly. His course was originally a translation of Allen B. Downey's Open-source book (see : http://www.greenteapress.com/free_books.html). I think this is proof of concept, no? Gabriel From hopeorpha308 at gmail.com Sun Apr 27 07:47:10 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:47:10 -0700 (PDT) Subject: Chocolatier crack Message-ID: <05fb47a8-e6b6-4e64-a4df-35e5e5167130@w7g2000hsa.googlegroups.com> Chocolatier crack http://wga-cracks.crackkey.net From arnodel at googlemail.com Sun Apr 13 05:01:31 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 13 Apr 2008 02:01:31 -0700 (PDT) Subject: Call a classmethod on a variable class name References: Message-ID: <3b34f7c2-7692-4426-8740-2e0d84fdf472@k37g2000hsf.googlegroups.com> On Apr 13, 9:51?am, Matthew Keene wrote: > I would like to be able to call a specific classmethod on a class name > that is going to be passed from another parameter. ?In other words, I > have a call that looks something like: > > ? ?x = Foo.bar() > > and I would like to generalise this so that I can make this call on any > particular class which provides the bar classmethod. > > I have implemented this using exec, like so: > > ? className = parameters.className > ? exec "x = " + className + ".bar()" > > but this feels somewhat clumsy. ?(I do have the requisite exception > handling to cope with the supplied class not existing or not > implementing the bar method, by the way). > > Is there any more Pythonesque way of doing this ? ?I guess what I'm > probably looking for is something like the way I understand the send > function works in Ruby If your class lives in the current global namespace, you can get it with >>> cls = globals()[classname] Then you can access its .bar() method directly: >>> cls.bar() Example: >>> class Foo(object): ... @classmethod ... def bar(cls): print 'Oh my Baz!' ... >>> globals()['Foo'] >>> globals()['Foo'].bar() Oh my Baz! If your class lives in a module, just do getattr(module, classname) instead to get the class object. HTH -- Arnaud From rorymckinleylists at gmail.com Sun Apr 6 03:13:40 2008 From: rorymckinleylists at gmail.com (Rory McKinley) Date: Sun, 06 Apr 2008 09:13:40 +0200 Subject: Weird scope error[SOLVED?] In-Reply-To: <43917932-3381-4130-8aca-a2dd05a19ee2@t36g2000prm.googlegroups.com> References: <47F79A78.4010207@gmail.com> <47F7A41C.4090402@islandtraining.com> <47F7E325.9060603@gmail.com> <43917932-3381-4130-8aca-a2dd05a19ee2@t36g2000prm.googlegroups.com> Message-ID: <47F87824.30907@gmail.com> Kay Schluehr wrote: > On 5 Apr., 23:08, Michael Torrie wrote: > >> You need to either fix all these imports in these other modules (that >> are probably in the site_packages folder), or modify the python import >> path so that it can find ElementTree directly. > > I'd prefer to set an alias in the module cache: > >>>> import sys >>>> import xml.etree >>>> sys.modules["elementree"] = xml.etree >>>> from elementree import ElementTree >>>> > Thank you Kay, Michael, and Gary for all suggestions and patience. I had actually changed the import inside the module itself, but it was still complaining. I was testing using the interactive console. This morning, without actually touching the module file again, I fired up the console and bingo! it works. So, it appears that the console was perhaps "cacheing" the module - does that make sense? Thanks Rory From skanemupp at yahoo.se Sat Apr 5 19:53:14 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 16:53:14 -0700 (PDT) Subject: while-loops enter the last time after condition is filled? Message-ID: it seems to me from my results that when i use a while-loop it will execute once after the condition is met. ie the conditions is met the code executes one time more and then quits. From webograph at eml.cc Sun Apr 27 06:40:05 2008 From: webograph at eml.cc (webograph) Date: Sun, 27 Apr 2008 12:40:05 +0200 Subject: Why can't timedeltas be divided? In-Reply-To: <48142747$0$20906$9b622d9e@news.freenet.de> References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> <48142747$0$20906$9b622d9e@news.freenet.de> Message-ID: <48145805.4040208@eml.cc> On 2008-04-27 09:12, Martin v. L?wis wrote: >> Last time I brought up this sort of thing, it seemed fairly unanimous >> that the shortcomings of the datetime module were 'deliberate' and >> would not be fixed, patch or no patch. >> > Ok, so then if the answer to my question is "yes", the first step > should be to discuss it on python-dev. i've had a look at the source code and written a small patch (attached; contains a case in classical/floor division as well as truediv). is there a defined escalation procedure from python-list to python-dev or should i just send the suggestion+patch there? regards webograph ps: i hope the patch conforms to python c coding style (most of it is just copy/pasted and modified). -------------- next part -------------- A non-text attachment was scrubbed... Name: datetime_datetime_division.patch Type: text/x-diff Size: 2185 bytes Desc: not available URL: From billingspanshism at gmail.com Sat Apr 19 17:17:34 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:17:34 -0700 (PDT) Subject: victoria beckham news Message-ID: <354bf216-66be-44eb-97af-01c893c1ab79@k37g2000hsf.googlegroups.com> Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From gagsl-py2 at yahoo.com.ar Thu Apr 3 10:08:21 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 11:08:21 -0300 Subject: Get all strings matching given RegExp References: <47F4A87C.7020701@gmail.com> Message-ID: En Thu, 03 Apr 2008 06:50:52 -0300, Alex9968 escribi?: > Can I get sequence of all strings that can match a given regular > expression? For example, for expression '(a|b)|(x|y)' it would be ['ax', > 'ay', 'bx', 'by'] See this thread: http://groups.google.com/group/comp.lang.python/browse_thread/thread/bc6e305844aeee82/ -- Gabriel Genellina From smmehadi at gmail.com Wed Apr 9 10:14:33 2008 From: smmehadi at gmail.com (syed mehdi) Date: Wed, 9 Apr 2008 19:44:33 +0530 Subject: argument to python cgi script Message-ID: <12b075a10804090714l44b012e6oe35a9e471d68a059@mail.gmail.com> Hi Guys, If someone can help me in telling how can i pass arguments to python cgi script then that will be good. like if i want to pass "some argument" to my remote python script, by calling something like: http://localhost/cgi-bin/test.py?some\ argument. What is the correct way of sending arguments in this way, and how can i decode/receive them in test.py Thanks & Regards Syed -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Thu Apr 10 08:33:16 2008 From: __peter__ at web.de (Peter Otten) Date: Thu, 10 Apr 2008 14:33:16 +0200 Subject: Sorting Directories from files in a os.listdir?? References: <9354f263-b833-4845-a226-1ad3a47b1e6a@p25g2000pri.googlegroups.com> Message-ID: Scott David Daniels wrote: >> I'd like to read the filenames in a directory, but not the >> subdirectories, os.listdir() gives me everything... how do I separate >> the directory names from the filenames? Is there another way of doing >> this? >> >> Thanks! > > import os > base, files, dirs = iter(os.walk(dirname)).next() > # now files is files and dirs is directories (and base == dirname) >>> import os >>> os.listdir(".") ['fifo', 'dir', 'file'] # a fifo, a directory, and a file >>> w = os.walk(".") >>> w is iter(w) # calling iter() is a noop here True >>> w.next() ('.', ['dir'], ['fifo', 'file']) # base, dirs, files; everything that is not # a directory goes into the files list Peter From martin at v.loewis.de Fri Apr 18 20:14:02 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sat, 19 Apr 2008 02:14:02 +0200 Subject: How to print a unicode string? In-Reply-To: References: Message-ID: <4809394A.1030906@v.loewis.de> > From what I've googled, I think I need to set my locale. Not on this operating system. On Windows, you need to change your console. If it is a cmd.exe-style console, use chcp. For IDLE, changing the output encoding is not supported. If you want to output into a file, use codecs.open. If you absolutely want to output UTF-8 to the terminal even though the terminal will not be able to render it correctly, use sys.stdout = codecs.getwriter("UTF-8")(sys.stdout) HTH, Martin From sn at sncs.se Mon Apr 14 22:38:56 2008 From: sn at sncs.se (Sverker Nilsson) Date: Mon, 14 Apr 2008 19:38:56 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> Message-ID: <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> On Apr 15, 3:50 am, "Gabriel Genellina" wrote: > En Mon, 14 Apr 2008 22:02:38 -0300, Sverker Nilsson escribi?: > > > I tried out py3k on my project,http://guppy-pe.sf.net > > And what happened? > I've seen that your project already supports Python 2.6 so the migration > path to 3.0 should be easy. > > -- > Gabriel Genellina 2.6 was no big deal, It was an annoyance that they had to make 'as' a reserved word. Annoyances were also with 2.4, and 2.5. No big problems, I could make guppy backwards compatible to 2.3. But that seems not to be possible with Python 3.x ... it is a MUCH bigger change. And it would require a fork of the code bases, in C, Guido has written tha or to sprinkle with #ifdefs. Would not happen soon for me. It takes some work anyways. Do you volunteer, Guido van Rossum? :-) It's not exactly easy. Perhaps not very hard anyways. But think of 1000's of such projects. How many do you think there are? I think many. How many do yo think care? I think few. When it has been the fuzz with versions before, then I could have the same code still work with older versions. But now it seems I have to fork TWO codes. It's becoming too much. Think of the time you could write a program in C or even C++ and then it'll work. How do you think eg writers of bash or other unix utilities come along. Do they have to rewrite their code each year? No, it stays. And they can be happy about that, and go on to other things. Why should I have to think about staying compatible with the newest fancy Python all the time? NO -- but the answer may be, they don't care, though the others (C/C++, as they rely on) do. :-( Sverker From jason.scheirer at gmail.com Tue Apr 1 16:50:25 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Tue, 1 Apr 2008 13:50:25 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> Message-ID: <3bc57bca-febe-4f2e-a990-407c9904c810@c26g2000prf.googlegroups.com> On Apr 1, 1:40 pm, Aaron Watters wrote: > I've been poking around the world of object-relational > mappers and it inspired me to coin a corellary to the > the famous quote on regular expressions: > > "You have objects and a database: that's 2 problems. > So: get an object-relational mapper: > now you have 2**3 problems." > > That is to say I feel that they all make me learn > so much about the internals and features of the > O-R mapper itself that I would be better off rolling > my own queries on an as-needed basis without > wasting so many brain cells. > > comments? > > -- Aaron Watters > > ===http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=mild+exponenti... You're going to have to learn how any of the OR mappers work to get anything reasonable out of them, and you are going to need to commit and invest the time to learn how one works. I would argue that you should try making a prototype using one or two OR mappers (or just use SQLAlchemy/Elixir and be done with it) with your existing database and see which most efficiently does what you need it to. If you get to the point where the queries are getting too complex to reasonably manage as python code, then yeah, use raw SQL because that is what it's good for. Most OR mappers will allow you to sprinkle in raw SQL as needed. I think it's natural to be paralyzed by all the choices you have, but just start writing some code and go from there. From leoniaumybragg at gmail.com Sat Apr 26 06:59:04 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:59:04 -0700 (PDT) Subject: windows xp sp2 activation crack Message-ID: windows xp sp2 activation crack http://cracks.00bp.com F R E E C R A C K S From istvan.albert at gmail.com Wed Apr 23 21:56:27 2008 From: istvan.albert at gmail.com (Istvan Albert) Date: Wed, 23 Apr 2008 18:56:27 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> <426812d7-c217-4bfc-81b0-47ba0638a650@k13g2000hse.googlegroups.com> Message-ID: <74415ef0-e395-4a31-90eb-e2645a65d464@e39g2000hsf.googlegroups.com> On Apr 23, 2:08 pm, Bob Woodham wrote: > x = x++; > > has unspecified behaviour in C. That is, it is not specified > whether the value of x after execution of the statement is the > old value of x or one plus the old value of x. unspecified means that the result could be anything: old value, old value+1, -2993882, "trallalla", core dump, stack overflow etc... in Java the behavior is specified, but many might find the result counterintuitive: int x = 0; x = x++; System.out.println(x); prints 0, if I recall it correctly the ++ mutates after the assignment takes place, therefore it increments the old value that then summarily discarded. i. From gagsl-py2 at yahoo.com.ar Sun Apr 20 14:53:06 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 15:53:06 -0300 Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B80B5.1050500@cheimes.de> <87myno2yma.fsf@physik.rwth-aachen.de> Message-ID: En Sun, 20 Apr 2008 15:02:37 -0300, Torsten Bronger escribi?: > Gabriel Genellina writes: >> En Sun, 20 Apr 2008 14:43:17 -0300, Christian Heimes >> escribi?: >>> Gabriel Genellina schrieb: >>> >>>> Apart from what everyone has already said, consider that >>>> FreqDist may import other modules, store global state, create >>>> other objects... whatever. Pure python code should not have any >>>> memory leaks (if there are, it's a bug in the Python >>>> interpreter). Not-carefully-written C extensions may introduce >>>> memory problems. >>> >>> Pure Python code can cause memory leaks. No, that's not a bug in >>> the interpreter but the fault of the developer. For example code >>> that messes around with stack frames and exception object can >>> cause nasty reference leaks. >> >> Ouch! >> May I assume that code that doesn't use stack frames nor stores >> references to exception objects/tracebacks is safe? > > Circular referencing is no leaking on the C level but in a way it is > memory leaking, too. The garbage collector will eventually dispose of the cycle, unless you use __del__. Of course it's better if the code itself breaks the cycle when it's done using the objects. The above comment about stack frames and exceptions does not refer to this situation, I presume. -- Gabriel Genellina From aaron.watters at gmail.com Tue Apr 29 16:35:47 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Tue, 29 Apr 2008 13:35:47 -0700 (PDT) Subject: Cookie Confusion - How to Set a Cookie References: <588d6a6c-0080-48a4-b768-e2c5ef551790@s50g2000hsb.googlegroups.com> Message-ID: <94d81004-fc6d-4ff9-9500-143864a6d7a7@f63g2000hsf.googlegroups.com> > Thanks for the code, Aaron. I will give it a try. > > I've been reading some more about cookielib and am not sure whether I > should use Cookie or cookielib. This is what I want to do: a user is > going to login. Upon a successful login, I want to write their name > and date/time of visit to a cookie file. Which is the correct python > module to use? Cookie does parsing and generation of cookie strings for server-side applications like your CGI script. The cookielib module is designed for either implementing a client like a web browser or emulating a client/browser (for web scraping, for example). I think you want to use Cookie. The distinction could be made clearer in the docs, imho. Also, when you say "write the cookie file" I think you mean "store the cookie to the client browser". This should happen automatically when you send the cookie header to the client correctly (if the client is configured to cooperate). -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=default+does+nothing From martin at v.loewis.de Thu Apr 24 04:21:32 2008 From: martin at v.loewis.de (=?ISO-8859-9?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Thu, 24 Apr 2008 10:21:32 +0200 Subject: [Python-Dev] annoying dictionary problem, non-existing keys In-Reply-To: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> Message-ID: <4810430C.5020709@v.loewis.de> > this is very annoying. Posting to so many lists is even more annoying. You might not get a single helpful answer just because people are so frustrated by this behavior. Regards, Martin From lists at cheimes.de Wed Apr 23 08:58:00 2008 From: lists at cheimes.de (Christian Heimes) Date: Wed, 23 Apr 2008 14:58:00 +0200 Subject: Subprocess module In-Reply-To: <5213E58D85BC414998FA553C701E386C0EDD125B52@SGBD012511.dlrmail.ad.delarue.com> References: <5213E58D85BC414998FA553C701E386C0EDD125B52@SGBD012511.dlrmail.ad.delarue.com> Message-ID: <480F3258.1010801@cheimes.de> Dominique.Holzwarth at ch.delarue.com schrieb: > Hello all > > I want to convert a tex file into a pdf by using pdflatex. For that, I thought the 'subprocess' module might be a good option. My code doesn't work at all tho: > > Import os, subprocess > > def main(): > scriptpath = os.path.dirname(__file__) > > p = subprocess.Popen("pdflatex --include-directory=%s --output-directory=%s/output --aux-directory=%s/temp --interaction=nonstopmode myFile.tex" > % (scriptpath, scriptpath, scriptpath), > stdin=subprocess.PIPE, > stdout=subprocess.PIPE, > stderr=subprocess.PIPE, > shell=True, > cwd=scriptpath) > (child_stdin, > child_stdout, > child_stderr) = (p.stdin, p.stdout, p.stderr) > print 'stdin' > print child_stdin > print 'stdout' > print child_stdout > print 'stderr' > print child_stderr > > When I run that code I get the following printouts: > > stdin > ', mode 'wb' at 0x009E7968> > stdout > ', mode 'rb' at 0x009E7A40> > stderr > ', mode 'rb' at 0x009E79F8> > Done The pdflatex job stales when the standard stream buffers are full. Why do you need stdin anyway? The community method should do the trick for you: out, err = p.communicate() I also suggest you use the form ["pdflatex", "--include-directory="+scriptpath ...] instead of a single string + shell=True. Christian From gagsl-py2 at yahoo.com.ar Thu Apr 3 18:44:16 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 19:44:16 -0300 Subject: Bug in shlex?? References: Message-ID: En Thu, 03 Apr 2008 19:20:59 -0300, samslists at gmail.com escribi?: > I'm trying to use shlex.split to simulate what would happen in the > shell. The docs say that it should be as close as possible to the > posix shell parsing rules. > > If you type the following into a posix compliant shell > > echo '\?foo' > > you get back: > \?foo > > (I've tested this in dash, bash and zsh---all give the same results.) > > Now here's what happens in python: > > Python 2.5.1 (r251:54863, Mar 7 2008, 03:39:23) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> import shlex >>>> shlex.split("'\?foo'") > ['\\?foo'] >>>> > > I think this is a bug? Or am I just misunderstanding? The result is a list containing a single string. The string contains 5 characters: a single backslash, a question mark, three letters. The backslash is the escape character, as in '\n' (a single character, newline). A backslash by itself is represented (both by repr() and in string literals) by doubling it. If you print the value, you'll see a single \: print shlex.split("'\?foo'")[0] -- Gabriel Genellina From bockman at virgilio.it Tue Apr 29 04:32:48 2008 From: bockman at virgilio.it (bockman at virgilio.it) Date: Tue, 29 Apr 2008 01:32:48 -0700 (PDT) Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> Message-ID: <16c06038-2421-478e-ba28-8131f7d552d8@b1g2000hsg.googlegroups.com> On 27 Apr, 12:27, Terry wrote: > Hello! > > I'm trying to implement a message queue among threads using Queue. The > message queue has two operations: > PutMsg(id, msg) # ?this is simple, just combine the id and msg as one > and put it into the Queue. > WaitMsg(ids, msg) # this is the hard part > > WaitMsg will get only msg with certain ids, but this is not possible > in Queue object, because Queue provides no method to peek into the > message queue and fetch only matched item. > > Now I'm using an ugly solution, fetch all the messages and put the not > used ones back to the queue. But I want a better performance. Is there > any alternative out there? > > This is my current solution: > > ? ? def _get_with_ids(self,wait, timeout, ids): > ? ? ? ? to = timeout > ? ? ? ? msg = None > ? ? ? ? saved = [] > ? ? ? ? while True: > ? ? ? ? ? ? start = time.clock() > ? ? ? ? ? ? msg =self.q.get(wait, to) > ? ? ? ? ? ? if msg and msg['id'] in ids: > ? ? ? ? ? ? ? ? break; > ? ? ? ? ? ? # not the expecting message, save it. > ? ? ? ? ? ? saved.append(msg) > ? ? ? ? ? ? to = to - (time.clock()-start) > ? ? ? ? ? ? if to <= 0: > ? ? ? ? ? ? ? ? break > ? ? ? ? # put the saved messages back to the queue > ? ? ? ? for m in saved: > ? ? ? ? ? ? self.q.put(m, True) > ? ? ? ? return msg > > br, Terry Wy put them back in the queue? You could have a defaultdict with the id as key and a list of unprocessed messages with that id as items. Your _get_by_ids function could first look into the unprocessed messages for items with that ids and then look into the queue, putting any unprocessed item in the dictionary, for later processing. This should improve the performances, with a little complication of the method code (but way simpler that implementing your own priority-based queue). Ciao ----- FB From kenneth.m.mcdonald at sbcglobal.net Tue Apr 22 14:36:27 2008 From: kenneth.m.mcdonald at sbcglobal.net (Kenneth McDonald) Date: Tue, 22 Apr 2008 13:36:27 -0500 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. Message-ID: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> Sadly. Thanks, Ken From needin4mation at gmail.com Tue Apr 29 13:16:08 2008 From: needin4mation at gmail.com (jmDesktop) Date: Tue, 29 Apr 2008 10:16:08 -0700 (PDT) Subject: Simple import question about mac osx Message-ID: Hi, I have this code (learning from Core Python, Chun's book), module named chap2.py. class FooClass(object): version=0.1 def __init__(self, nm='John Doe'): self.name=nm print 'Created a class instance for ', nm def showname(self): print 'Your name is', self.name print 'My name is', self.__class__.__name__ On Windows, if I compile this and then in the python interpreter type: >>> import chap2 >>> foo1=FooClass() Created a class instance for John Doe >>> If I do the same think on my Mac OS X 10.5.2 NameError: name 'FooClass' is not defined. I thought it was the path and did export PATH=$PATH:/mypath/ topythoncode but it did not help. What am I doing wrong? Thank you. From gagsl-py2 at yahoo.com.ar Thu Apr 3 22:08:46 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 23:08:46 -0300 Subject: Is there an official way to add methods to an instance? References: <0db32c33-04a9-4993-9d5a-a617c575a4d7@u36g2000prf.googlegroups.com> Message-ID: En Thu, 03 Apr 2008 22:43:30 -0300, Roger Miller escribi?: > On Apr 3, 2:57 pm, Brian Vanderburg II > wrote: >> >> I've checked out some ways to get this to work. I want to be able to >> add a new function to an instance of an object. I've tested two >> different methods that cause problems with 'deleting'/garbage collection >> (__del__ may never get called), but implemented one sort of hackishly >> maybe that works find. I'm wondering if there is more of an official way >> than mine. >> > > Maybe I'm missing something, but the boring old straightforward > approach works for me: > > class A: > def __del__(self): > print "Deleting" > > def f(x): > print x > > a = A() > a.f = f > a.f(42) > del a This doesn't create an instance method. You can't access `a` (as `self`) from inside f. -- Gabriel Genellina From pyth0nc0d3r at gmail.com Tue Apr 8 20:31:59 2008 From: pyth0nc0d3r at gmail.com (Lamonte Harris) Date: Tue, 8 Apr 2008 19:31:59 -0500 Subject: How would I go about checking if urllib2 timed out? Message-ID: Can someone explain to me how I would do error handling to check if the current proxy timed out on when trying to connect to the web page: import urllib2 proxy=urllib2.ProxyHandler({'http':'24.232.167.22:80'}) opener=urllib2.build_opener(proxy) f=opener.open('http://www.whatismyipaddress.com' ) print f.read() If someone could help me, thank you very much, I'm still very new to error handling -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Sun Apr 6 17:55:52 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 06 Apr 2008 23:55:52 +0200 Subject: How to create an exe-file? In-Reply-To: <8da70474-6ade-4515-8346-8f02a04ff24e@b9g2000prh.googlegroups.com> References: <311a216f-5366-47c5-86a7-431dd23ced3e@j1g2000prb.googlegroups.com> <8da70474-6ade-4515-8346-8f02a04ff24e@b9g2000prh.googlegroups.com> Message-ID: skanemupp at yahoo.se wrote: > a good thing about python is the portability though. but u cant make > an exe that can be used on mac too, ie one exe fpr both? you can create a portable python archive, but EXE files are windows only. > if i want to make an exe for mac, what do i need? see the second link I posted for the answer. From the.doag at gmail.com Thu Apr 24 00:21:26 2008 From: the.doag at gmail.com (Daniel) Date: Wed, 23 Apr 2008 21:21:26 -0700 (PDT) Subject: Parsing tuple from string? References: Message-ID: On Apr 23, 4:22 pm, George Sakkis wrote: > On Apr 23, 6:24 pm, Daniel wrote: > > > I have a list of strings, which I need to convert into tuples. If the > > string is not in python tuple format (i.e. "('one', 'two')", "("one", > > 'two')", etc.), then I can just make it a 1-tuple (i.e. return > > (string,) ). If it is in python tuple format, I need to parse it and > > return the appropriate tuple (it's ok to keep all tuple elements as > > strings). > > > I think eval() will work for this, but I don't know what will be in > > the string, so I don't feel comfortable using that. > > Check out one of the safe restricted eval recipes, e.g.http://preview.tinyurl.com/6h7ous. > Thank you very much! > HTH, > George From umpsumps at gmail.com Sat Apr 26 17:39:13 2008 From: umpsumps at gmail.com (umpsumps at gmail.com) Date: Sat, 26 Apr 2008 14:39:13 -0700 (PDT) Subject: learning with python question (HtTLaPP) References: <98acecbd-9de2-4ebf-927b-ac6bc1fbc3fd@b5g2000pri.googlegroups.com> Message-ID: <53d6254f-895f-48fb-8ab9-3929c403f11b@v23g2000pro.googlegroups.com> Eric, Thank you for helping. Is the way I wrote the function inherently wrong? What I wrote returns the sequence, however I'm trying to make the output match for the letters in the string entered, not necessarily the string sequence. For example if I search words.txt with my function for 'uzi' I get this: >>> searchtxt('uzi') gauziest gauzier fuzing fuzils fuzil frouziest frouzier defuzing 113809 lines searched.. 8 uzi words present Only the sequence shows up 'uzi'. I don't get words like 'unzip' or 'Zurich' . I've only barely started on invocation and maybe writing something like I'm describing is above what level I'm currently at. On Apr 26, 2:20?pm, "Eric Wertman" wrote: > > ?Python Programmer" and have been trying to write a script that checks > > ?'words.txt' for parameters (letters) given. ?The problem that is the i > > ?can only get results for the exact sequence of parameter 'letters'. > > The "re" module comes to mind: > > text = open('words.txt','r').read() > letters = 'sequence' > results = re.findall(letters,text) > > result_count = len(results) > > # one word per line: > for result in results : > ? ? print result > > # one line > print ' '.join(results) > > of course, you may need to invest a little time in regular expression > syntax to get exactly what you want, but I think you'll find that's > not wasted effort, as this is pretty standard and used in a lot of > other places. From bronger at physik.rwth-aachen.de Wed Apr 9 05:36:44 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Wed, 09 Apr 2008 11:36:44 +0200 Subject: Coping with cyclic imports References: <87bq4knmax.fsf@physik.rwth-aachen.de> Message-ID: <87iqyr9xoz.fsf@physik.rwth-aachen.de> Hall?chen! Jeffrey Froman writes: > [...] > > Cyclic imports are not a problem by themselves, but cyclic > definitions are. Thus: > > # a.py > import b > x = 1 > > # b.py > import a > x = 2 > > works fine, but: > > # a.py > import b > x = 1 > > # b.py > import a > x = a.x + 1 # circular definition > > does not. Okay, thanks, but after some own investigations, I think that the clever bit is somewhere else. The above works if you call a.py as the main program, because then a.py is not yet loaded as such when "import a" is executed. So a.py gets executed twice, once by "import a", and once after the whole import thing as the main program. Actually, there seems to be only one case that is dangerous: If you import a module cyclicly, it may be that you only get its name imported but this name points to a yet empty module. Then, you must not refer to things in it while the current module itself is executed. But you may well refer to things in it from functions or methods, because they are called much later, when the whole bunch of modules is already completely loaded and populated. Consequently, "from a import x" also fails if a is incomplete. So, the last question is: Under which circumstances does this happen? It happens when you import a module which imports (directly or indictly) the current module and which comes before the current module in the import order while the program runs. If you don't rely on imported things at top-level code (but only in functions and methods which in turn must not be called from the top-level), everything is fine. Can anybody confirm that this is correct? Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From kay.schluehr at gmx.net Sat Apr 5 11:55:04 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 5 Apr 2008 08:55:04 -0700 (PDT) Subject: Weird scope error References: Message-ID: <7b2a52ad-f036-46bb-b2fb-8eca8dbf7081@b5g2000pri.googlegroups.com> On 5 Apr., 17:27, Rory McKinley wrote: > Hi > > I am trying to use the TidyHTMLTreeBuilder module which is part of > elementtidy, but I am getting what appears to be some sort of scope > error and it is scrambling my n00b brain. > > The module file (TidyHTMLTreeBuilder.py) tried to import ElementTree by > doing the following: > > from elementtree import ElementTree > > This bombed, so after a bit of poking around I replaced it with : > > from xml.etree import ElementTree > > This appears to have worked. However, when I try and parse a file using > the function : > TidyHTMLTreeBuilder.parse('weather_ct.html') > > I receive the following error: > > Traceback (most recent call last): > File "", line 1, in > File > "/usr/lib/python2.5/site-packages/elementtidy/TidyHTMLTreeBuilder.py", > line 107, in parse > return ElementTree.parse(source, TreeBuilder()) > NameError: global name 'ElementTree' is not defined > > The code producing the error is as follows: > > def parse(source): > return ElementTree.parse(source, TreeBuilder()) > > Surely, if the from... import has worked, ElementTree is in the global > scope and should therefore be accessible to the function parse? > > Can anybody help? > > THanks The problem stems from the fact that TidyHTMLTreeBuilder uses a different import path assuming that the elementtree package is found somewhere in the pythonpath e.g. in site-packages and not in the builtins. I guess this problem will be resolved when you install the elementree package again. From mattheww at chiark.greenend.org.uk Wed Apr 2 15:45:33 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 02 Apr 2008 20:45:33 +0100 (BST) Subject: plpythonu+postgrs anybody using it? References: Message-ID: Martin Marcher wrote: > My main concern is that when things start getting more complicated > that everytime a SP is called an instance of the interpreter ist > started which would be a huge slowdown, so does plpythonu run > continiously a python process or does it start one everytime a SP is > called? I'm not using plpythonu, but nobody else seems to be jumping to answer so I'll have a go. I'm fairly sure but not certain that what I say below is true. When you use PL/Python, there is no separate Python process. The Python interpreter is dynamically linked into each PostgreSQL back-end process when it first calls a PL/Python function. That means that whatever the overhead is for initialising the Python interpreter, it will be paid at most once per database connection. If you find that this overhead is too high, a connection pooling system like pgpool might help. -M- From sawilla at gmail.com Mon Apr 21 17:14:24 2008 From: sawilla at gmail.com (sawilla) Date: Mon, 21 Apr 2008 14:14:24 -0700 (PDT) Subject: module error in Vista -- works as administrator Message-ID: <815eb7f8-6f00-469d-bb15-e1d9680d9646@e39g2000hsf.googlegroups.com> First, I'm new to Python. I'm getting and error when I run Python 2.5.2 as a regular user in Vista but not when I run Python as an administrator. For example, if I type "import numpy" after I launch python from an adminstrator-privileged command window it loads fine. However, from a regular-user command window I get: >>> import numpy Traceback (most recent call last): File "", line 1, in ImportError: No module named numpy Thanks in advance for your help. Reg From deets at nospam.web.de Wed Apr 23 15:35:43 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 23 Apr 2008 21:35:43 +0200 Subject: Calling Python code from inside php In-Reply-To: <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> References: <679e9oF2mti63U1@mid.uni-berlin.de> <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> Message-ID: <679hd5F2nj6csU1@mid.uni-berlin.de> > A simple yet dangerous and rather rubbish solution (possibly more of a > hack than a real implementation) could be achieved by using a > technique described above: > > echo exec('python foo.py'); > ?> What is rubbish about that - except from the obvious cleansing of input variables that has to take place? Python has a whole module dedicated to that rubbish, called subprocess. > I would look into pyphp though. This method has so many issues > attached to it it's hardly worth bothering with. > I'm with Nick when I say why on earth are you needing to call Python > from within PHP as opposed to using only Python or only PHP? While I certainly prefer to use Python wherever I can, that does not mean that there aren't cases where legacy systems or other constraints make this impossible. If I have e.g. a type3-based website - "how on earth" should I replace that with Python (without wasting a lot of time)? Diez From michael.harris at MCC-CORP.COM Mon Apr 28 13:42:00 2008 From: michael.harris at MCC-CORP.COM (Michael Harris) Date: Mon, 28 Apr 2008 13:42:00 -0400 Subject: Automating IE 6.0 Message-ID: <81B200F0AB075D4D95DA50067247FFBFF15DB8@mcc-es1.MCC.local> I tried to use the sample code to print a webpage via ie and I get the following error: Traceback (most recent call last): File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py" , line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\ie.py", line 14, in ie.ExecWB(win32com.client.constants.OLECMDID_PRINT, win32com.client.constants.OLECMDEXECOPT_DONTPROMPTUSER) NameError: name 'win32com' is not defined I have the win32com module installed and I clicked on makepy.py and selected Microsoft Internet Controls (1.1). The code was: from win32com.client import Dispatch from time import sleep ie = Dispatch("InternetExplorer.Application") ie.Visible = 1 ie.Navigate("http://www.cnn.com" ) if ie.Busy: sleep(2) # print the current IE document without prompting the user for the printerdialog ie.ExecWB(win32com.client.constants.OLECMDID_PRINT,win32com.client.const ants .OLECMDEXECOPT_DONTPROMPTUSER) Why am I getting this error? -------------- next part -------------- An HTML attachment was scrubbed... URL: From patrickkidd.lists at gmail.com Wed Apr 16 08:04:36 2008 From: patrickkidd.lists at gmail.com (Patrick Stinson) Date: Wed, 16 Apr 2008 06:04:36 -0600 Subject: import hooks In-Reply-To: References: <664bf2b80804151814g480eed02w739047f84d9deb6b@mail.gmail.com> Message-ID: <664bf2b80804160504x72c870d8pdbfe8105a0c5ed11@mail.gmail.com> I am defining a simple finder/loader object and adding it to sys.meta_path like this: PyRun_SimpleString("import sys; import ousiainternal; sys.meta_path = [ousiainternal.OusiaImporter]"); The following C code defines the loader object: static void MyImporter_dealloc(PyObject *self) { self->ob_type->tp_free(self); } static int MyImporter_init(MyImporter *self, PyObject *args, PyObject *kwds) { return 0; } static PyObject * MyImporter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { MyOutput *self; self = (MyOutput *)type->tp_alloc(type, 0); return (PyObject *)self; } /* Check whether we can satisfy the import of the module named by 'fullname'. Return self if we can, None if we can't. FYI: MyImporter imports modules from the local instrument. */ static PyObject * MyImporter_find_module(PyObject *obj, PyObject *args) { MyImporter *self = (MyImporter *)obj; PyObject *path = NULL; char *fullname; if (!PyArg_ParseTuple(args, "s|O", &fullname, &path)) return NULL; mod = lookup_module_in_my_app(name); //borrowed ref if(mod == NULL); { Py_INCREF(Py_None); return Py_None; } Py_INCREF(self); return (PyObject *)self; } /* Load and return the module named by 'fullname'. */ static PyObject * MyImporter_load_module(PyObject *obj, PyObject *args) { MyImporter *self = (MyImporter *)obj; PyObject *mod = NULL; char *fullname; if (!PyArg_ParseTuple(args, "s", &fullname)) return NULL; mod = lookup_module_in_my_app(name); // borrowed ref if(mod) Py_INCREF(mod); return mod; } static PyMethodDef MyImporter_methods[] = { {"find_module", MyImporter_find_module, METH_VARARGS, "find a module"}, {"load_module", MyImporter_load_module, METH_VARARGS, "load a module"}, {NULL, NULL} /* sentinel */ }; static PyTypeObject MyImporterType = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "Myinternal.MyImporter", /*tp_name*/ sizeof( MyImporter), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor) MyImporter_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash */ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ "import hook for loading embedded modules", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ MyImporter_methods, /* tp_methods */ 0, //MyImporter_members, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ (initproc) MyImporter_init, /* tp_init */ 0, /* tp_alloc */ MyImporter_new, /* tp_new */ }; A simpler example that yields the same results would be this: static const char *importer_source = "import sys\n" "class Importer:\n" " def __init__(self, path):\n" " print \'Import.__init__\', path\n" " def find_module(self, fullname, path=None):\n" " print self\n" " if fullname == \'bleh\':\n" " return self\n" " def load_module(self, fullname):\n" " print self\n" " if fullname == \'bleh\':\n" " return sys\n" "sys.meta_path.append(Importer)\n"; PyRun_SimpleString(importer_source); For both examples none of the methods are called (I set breakpoints for the C functions) but a statement like "import os" or PyImport_ImportModule("traceback") don't work. Thanks for your help On Wed, Apr 16, 2008 at 12:02 AM, Gabriel Genellina wrote: > En Tue, 15 Apr 2008 22:14:18 -0300, Patrick Stinson > escribi?: > > > What's the current way to install an import hook? I've got an embedded > > app > > that has a few scripts that I want to import each other, but that are > > not in > > sys.modules. I intentionally keep them out of sys.modules because their > > names will not be unique across the app. They will, however, be unique > > between scripts that I (do* want to see each other). > > Basically, I want to return a certain module from a name-based filter. > > I've > > already written a type in C with find_module and load_module, but it > > doesn't > > seem to work when I add the type to sys.path_hooks. I wrote a simple one > > that worked just fine from a pure script file run through python.exe. > > From that description alone I can't say what's happening; you should post > some code. > Also, if your importer isn't disk-based, perhaps using sys.meta_path is > better. > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Patrick Kidd Stinson http://www.patrickkidd.com/ http://pkaudio.sourceforge.net/ http://pksampler.sourceforge.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From bg at bg.fr Tue Apr 8 11:56:01 2008 From: bg at bg.fr (Bruno GUERPILLON) Date: Tue, 8 Apr 2008 17:56:01 +0200 Subject: List open files References: <47fb8d54$0$15068$426a74cc@news.free.fr> Message-ID: <47fb968c$0$22371$426a74cc@news.free.fr> "Mike Driscoll" a ?crit dans le message de news: c62d02f7-62c4-447d-a456-261fefb8b021 at e67g2000hsa.googlegroups.com... > On Apr 8, 10:16 am, "Bruno GUERPILLON" wrote: >> Hi, >> >> I'd like, in a WIN32 environment, list all open files. >> Anyone got a clue how to do this ? >> >> Regards, >> >> Bruno. > > XP comes with a utility called OpenFiles.exe which supposedly gives > this functionality. You can use Python's subprocess command to run it > and parse its output. > > Mike Thanks for the answer Mike. Well, Openfiles.exe list only file opened vi Network. I'd like to know the local opene files list. Regards From irishhacker at gmail.com Wed Apr 16 15:47:25 2008 From: irishhacker at gmail.com (Robert) Date: Wed, 16 Apr 2008 12:47:25 -0700 (PDT) Subject: Does Python use a special home-made parser, or does it use Yacc? Message-ID: <236a2391-ac15-4910-8d47-5741256486d1@1g2000prf.googlegroups.com> Or some other pre-packaged parser tool? From tjreedy at udel.edu Mon Apr 7 17:12:19 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 7 Apr 2008 17:12:19 -0400 Subject: Problem with smtplib and py2exe References: <3ff2767a-bbd8-4e0e-bbf4-3fa72bdca5e7@8g2000hsu.googlegroups.com> Message-ID: "Kevin" wrote in message news:3ff2767a-bbd8-4e0e-bbf4-3fa72bdca5e7 at 8g2000hsu.googlegroups.com... | Hi everyone, | | I'm running Python 2.5.1 on an XP-Pro platform, with all the updates | (SP2, etc) installed. I have a program (send_file.py) that sends a | file to a service provider, using an ftp connection. The program | works properly, and I've created an 'exe' of it, using py2exe. It was | distrubuted to my user base a couple of weeks ago and seems to be | working well. None of the users have Python installed on their | machines, thus the need for an 'exe' for the program. | | I now need to add an email function to the program, to automatically | send an email to a select user list when the program is completed. | I've made the appropriate modifications to my code, and the program | works properly when I run it from Python. When I try to make an exe | out of my new program, however, I get the following error: | | Traceback (most recent call last): | File "C:/Python25/send_ftp/setup.py", line 17, in | console = [{"script": 'send_file.py'}] ) | File "C:\Python25\lib\distutils\core.py", line 168, in setup | raise SystemExit, "error: " + str(msg) I would go to that line in that file (it is in the except: part of a try: statement) and file the function call that raised the exception and ... There seems to be a DEBUG variable, which might also give more info. | SystemExit: error: command 'C:\Python25\pythonw.exe' failed with exit | status 1 | | The 'setup.py' script is the same one I used to generate the 'exe' of | the original program. The email-related code was added to my | 'send_file.py' program as a function - it's not a separate module. If | all of the changes are commented out, the py2exe function works. But | as soon as I activate even the line "import smtplib", the py2exe | process spits out the error above. | | If I put only the email portions of code in a test program, and run it | from Python, it works, but if I try make an 'exe' out of the test | program, I get the same error as above. | | Is there an inherent incompatibility between smtplib and py2exe? Does | anyone have any ideas of how I can fix this problem? tjr From hypocrite at lawyer.com Wed Apr 16 08:46:27 2008 From: hypocrite at lawyer.com (Pete Crite) Date: Wed, 16 Apr 2008 22:46:27 +1000 Subject: Python crashes consistently In-Reply-To: <66m7s3F2l8kitU1@mid.uni-berlin.de> References: <66m7s3F2l8kitU1@mid.uni-berlin.de> Message-ID: <2903FA81-F84F-418A-B73E-ED0F22828755@lawyer.com> Thanks for the quick reply, Just to clarify (sorry, I'm a bit of a command line newbie): Do you mean to install Python from the .dmg - i.e. into /usr/local/ bin? And then to install Numpy directly as well (manually, from source), then continue with the MacPorts installation of Gnumeric (i.e. into /opt/local/)? Thanks, Pete. On 16/04/2008, at 9:56 PM, Diez B. Roggisch wrote: > > Pete Crite wrote: > >> Hello, >> >> I've been trying to install Gnumeric via MacPorts recently, but I >> can't get past the installation of py25-numpy. > > You are using the wrong python version. Don't use MacPorts for > this, because > it will install a local, non-framework version of python - which > will do > you no good if you e.g. want to use any OSX-specific stuff. > > > Use the official 2.5 framework version. And then install Numpy > yourself > (which is a bit annoying I admit, as you need to install e.g. a > fortran > compiler, but it is pretty well documented) > > Diez > -- > http://mail.python.org/mailman/listinfo/python-list > From gagsl-py2 at yahoo.com.ar Wed Apr 16 15:21:45 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 16 Apr 2008 16:21:45 -0300 Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <86063f29-21a8-4d5b-a374-cee0723e0852@a22g2000hsc.googlegroups.com> <6894d371-3c3e-4c24-b7ec-4c254ed24afe@24g2000hsh.googlegroups.com> Message-ID: En Wed, 16 Apr 2008 13:09:05 -0300, Aaron Watters escribi?: > On Apr 16, 11:15 am, Gabriel Genellina wrote: >> On 16 abr, 09:56, Aaron Watters wrote: >> >> > In my opinion python's adherence to backwards compatibility >> > has been a bit mythological anyway -- many new python versions >> > have broken my old code for no good reason. This is an irritant >> > when you have thousands of users out there who suddenly drop >> > your code, blame you and python, and move on to use something else. > Yes I mean it. Actually I was unaware > of/forgot reconvert, but it doesn't > matter because it doesn't solve the problem of code I wrote that > has long ago escaped into the wild no longer working. There are > other examples too, having to do with things as simple as a name > change in a standard module that broke old > code of mine for what I regard as silly cosmetic reasons. Yes, there was some cases like that in the past, but I think that now there is a strict policy for backwards compatibility, including at least one .n release with deprecation warnings before removing old things. Anyway, sometimes incompatible changes appear in the standard library - perhaps because less developers are looking at them in detail? > I hope you are right about py3k conversions being pain > free and routine. I'm suspicious about it however. Well, I would not say "pain free", but certainly it's not as terrible as some people imply... -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Sun Apr 13 15:49:51 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 13 Apr 2008 16:49:51 -0300 Subject: Controlling copying and pickling of objects written in C References: <3_idnfMhL8pbD5zVnZ2dnUVZ_tPinZ2d@speakeasy.net> Message-ID: En Sun, 13 Apr 2008 01:57:42 -0300, Adam Bregenzer escribi?: > I am writing an extension and have "hidden" data included in the object's > C structure that is not visible to python. I am unsure what would happen > to that data if the python object were copied or pickled and would prefer > to raise an exception whenever code tries to copy/deep copy/pickle or > marshal the object since it would not make sense. Where would I look to > control that? You could raise an exception in __getstate__ - that would make pickle fail, and probably copy too but I'm not sure of that. -- Gabriel Genellina From leoniaumybragg at gmail.com Sat Apr 26 06:59:33 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 03:59:33 -0700 (PDT) Subject: exelon patch Message-ID: <1c7ff1bf-3d6a-4705-95c7-4e6627014bf2@8g2000hse.googlegroups.com> exelon patch http://cracks.00bp.com F R E E C R A C K S From mal at egenix.com Fri Apr 4 06:19:45 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Fri, 04 Apr 2008 12:19:45 +0200 Subject: Unicode conversion problem (codec can't decode) In-Reply-To: References: Message-ID: <47F600C1.7050404@egenix.com> On 2008-04-04 08:18, Jason Scheirer wrote: > On Apr 3, 9:35 pm, "Eric S. Johansson" wrote: >> I'm having a problem (Python 2.4) converting strings with random 8-bit >> characters into an escape form which is 7-bit clean for storage in a database. If you don't want to process the 7-bit form in any way, there are a couple of encodings which you could use: >> Here's an example: >> >> body = meta['mini_body'].encode('unicode-escape') >> >> when given an 8-bit string, (in meta['mini_body']), the code fragment above >> yields the error below. >> >> 'ascii' codec can't decode byte 0xe1 in position 13: ordinal not in range(128) Try this: body = meta['mini_body'].decode('latin-1').encode('unicode-escape') mini_body = body.decode('unicode-escape').encode('latin-1') or this: body = meta['mini_body'].decode('latin-1').encode('utf-7') mini_body = body.decode('utf-7').encode('latin-1') If all you need is the 7-bit form, you're probably better of with a base64 encoding: body = meta['mini_body'].encode('base64') mini_body = body.decode('base64') >> the string that generates that error is: >> >>
Reduce Wh?t You Owe by 50%. Get out of debt today!
Reduuce Interest & >> |V|onthlyy Payme?ts Easy, we will show you how..
Freee Quote in 10 >> Min.
http://www.freefromdebtin.net.cn Looks like spam :-) -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 04 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From mnordhoff at mattnordhoff.com Fri Apr 25 09:28:49 2008 From: mnordhoff at mattnordhoff.com (Matt Nordhoff) Date: Fri, 25 Apr 2008 13:28:49 +0000 Subject: Is 2006 too old for a book on Python? In-Reply-To: References: Message-ID: <4811DC91.9050406@mattnordhoff.com> jmDesktop wrote: > Hi, I wanted to buy a book on Python, but am concerned that some of > them are too old. One I had come to after much research was Core > Python by Wesley Chun. I looked at many others, but actually saw this > one in the store and liked it. However, it is from 2006. I know > there is free documentation and Dive Into Python. I just liked the > one in question and was hoping for thoughts on the age of it. I am > using Python 2.5.x and don' t know how different 2.3, 2,4 is from it. > > Thank you. Python 2.x releases maintain backwards compatibility. There are nice features that have come since 2.3, but it's not like it's a different language. You could learn from a slightly old book, then do some research to find out what you missed. ('with' statement, ternary operator, smaller things in the stdlib. Maybe generators? What else?) Now, Python 3 will break backwards compatibility and make more significant changes than usual, but it will still be basically the same language, so the same thing applies. And anyway, it won't be very relevant for a few years. -- From paddy3118 at googlemail.com Tue Apr 1 01:27:39 2008 From: paddy3118 at googlemail.com (Paddy) Date: Mon, 31 Mar 2008 22:27:39 -0700 (PDT) Subject: standard input, for s in f, and buffering References: <65bg55F2esfc1U3@mid.uni-berlin.de> Message-ID: On Mar 31, 11:47 pm, Jorgen Grahn wrote: > On 31 Mar 2008 06:54:29 GMT, Marc 'BlackJack' Rintsch wrote: > > > > > On Sun, 30 Mar 2008 21:02:44 +0000, Jorgen Grahn wrote: > > >> I realize this has to do with the extra read-ahead buffering documented for > >> file.next() and that I can work around it by using file.readline() > >> instead. > > >> The problem is, "for s in f" is the elegant way of reading files line > >> by line. With readline(), I need a much uglier loop. I cannot find a > >> better one than this: > > >> while 1: > >> s = sys.stdin.readline() > >> if not s: break > >> print '####', s , > > >> And also, "for s in f" works on any iterator f -- so I have to choose > >> between two evils: an ugly, non-idiomatic and limiting loop, or one > >> which works well until it is used interactively. > > >> Is there a way around this? Or are the savings in execution time or > >> I/O so large that everyone is willing to tolerate this bug? > > > You can use ``for line in lines:`` and pass ``iter(sys.stdin.readline,'')`` > > as iterable for `lines`. > > Thanks. I wasn't aware that building an iterator was that easy. The > tiny example program then becomes > > #!/usr/bin/env python > import sys > > f = iter(sys.stdin.readline, '') > for s in f: > print '####', s , > > It is still not the elegant interface I'd prefer, though. Maybe I do > prefer handling file-like objects to handling iterators, after all. > > By the way, I timed the three solutions given so far using 5 million > lines of standard input. It went like this: > > for s in file : 1 > iter(readline, ''): 1.30 (i.e. 30% worse than for s in file) > while 1 : 1.45 (i.e. 45% worse than for s in file) > Perl while(<>) : 0.65 > > I suspect most of the slowdown comes from the interpreter having to > execute more user code, not from lack of extra heavy input buffering. > > /Jorgen > > -- > // Jorgen Grahn \X/ snipabacken.se> R'lyeh wgah'nagl fhtagn! Hi Juergen, >From the python manpage: -u Force stdin, stdout and stderr to be totally unbuffered. On systems where it matters, also put stdin, stdout and stderr in binary mode. Note that there is internal buffering in xreadlines(), readlines() and file-object iterators ("for line in sys.stdin") which is not influenced by this option. To work around this, you will want to use "sys.stdin.readline()" inside a "while 1:" loop. Maybe try adding the python -u option? Buffering is supposed to help when processing large amounts of I/O, but gives the 'many lines in before any output' that you saw originally. If the program is to be mainly used to handle millions of lines from a pipe or file, then why not leave the buffering in? If you need both interactive and batch friendly I/O modes you might need to add the ability to switch between two modes for your program. - Paddy. From awaretek at gmail.com Sun Apr 27 14:36:45 2008 From: awaretek at gmail.com (Ron Stephens) Date: Sun, 27 Apr 2008 11:36:45 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <1d8af3e3-c287-4d5b-a481-ca8c650f732f@s33g2000pri.googlegroups.com> <472056db-8812-42b2-a4fe-3a2accd7571b@8g2000hse.googlegroups.com> Message-ID: John, This is very interesting! Please do make this available. I love PythonCard, but I am doing mainly web programming these days. I will mention this on my next podcast. Can you do a slider? Ron Stephens Python411 www.awaretek.com/python/index.html From gagsl-py2 at yahoo.com.ar Mon Apr 14 00:17:21 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 14 Apr 2008 01:17:21 -0300 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <47ff8489$0$6841$2d805a3e@textnews.eweka.nl> <48010fe5$0$6840$2d805a3e@textnews.eweka.nl> Message-ID: En Sat, 12 Apr 2008 15:38:22 -0300, Michel Bouwmans escribi?: > Gabriel Genellina wrote: >> En Fri, 11 Apr 2008 11:31:42 -0300, Michel Bouwmans >> escribi?: >>> Gabriel Genellina wrote: >> >>>> Another annoying thing with the Qt license is that you have >>>> to choose it >>>> at the very start of the project. You cannot developsomething using >>>> the >>>> open source license and later decide to switch to thecommercial >>>> licence and buy it. >>> >>> Unless you're a company with a risk of being checked forlegal software >>> etc., you can always ignore that allthough not very legal. >> >> I just ignore Qt itself. > > Then you're ignorant. What do you prefer than? Yes I am. But that doesn't change the fact that I don't like Qt, I don't like Qt license, my company doesn't use Qt and probably will never use it, and what we do prefer is not your business. -- Gabriel Genellina From jesse.k.rosenthal at gmail.com Mon Apr 7 12:52:41 2008 From: jesse.k.rosenthal at gmail.com (jesse.k.rosenthal at gmail.com) Date: Mon, 7 Apr 2008 09:52:41 -0700 (PDT) Subject: pylirc question: clearing the queue Message-ID: <19045397-5cff-4eae-8684-43f2eddd0405@59g2000hsb.googlegroups.com> Hi all, Is there a way in the pylirc module to either (a) get it to stop listening for a period of time, or (b) clear the queue of any stored up commands? I have a script that starts mplayer, and I use my remote while I'm running mplayer. The shell script waits (subrpocess.Popen.wait()) for the mplayer process to complete, but then it always runs through all the keypresses I've been sending mplayer. So i would like it to either stop listening until I give it a certain command, or to simply clear the queue (I could tell it to that after I return from wait()). Any ideas? Thanks, Jesse From landerdebraznpc at gmail.com Mon Apr 28 03:54:22 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:54:22 -0700 (PDT) Subject: crack and digichat Message-ID: crack and digichat http://crack.cracksofts.com From hdante at gmail.com Sat Apr 26 15:03:40 2008 From: hdante at gmail.com (hdante) Date: Sat, 26 Apr 2008 12:03:40 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> Message-ID: On Apr 26, 1:15?pm, n00m wrote: > fgets() from C++ iostream library??? > fgets is part of the standard C++ library and it lives in the std namespace. > I guess if I'd came up with "Python reads SLOWER than C" > I'd get another (not less) smart explanation "why it's so". From bj_666 at gmx.net Sun Apr 13 11:42:58 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 13 Apr 2008 15:42:58 GMT Subject: How to Choose an Unlimited Web Hosting for free References: <02d391b5-f72f-4f99-8f40-dbc304aa22fe@q24g2000prf.googlegroups.com> <4802276d$0$36379$742ec2ed@news.sonic.net> Message-ID: <66eo01F2ju94lU1@mid.uni-berlin.de> On Sun, 13 Apr 2008 08:42:52 -0700, John Nagle wrote: > Unlimited Free Domain & Web Hosting wrote: >> How to Choose an Unlimited Web Hosting >> 1) Visit www.xxxxxxx.com to get domain and hosting >> 2) Unlimited Bandwidth ,this mean unlimited data transmission for your >> client access. >> 2) Unlimited Space , you can upload file for unlimited . >> 3) Unlimited Email , many of email account can created . >> 5) SSL Security , used SSL / HTTPS to protect your web . >> 6) LINUX , WINDOWS and MAC , can access form many operating system. > > This is some spamming "reseller" for Xxxx Hosting. And now you've spread the spam to those whose news servers filtered the original message. Thanks... Ciao, Marc 'BlackJack' Rintsch From martin at v.loewis.de Sun Apr 20 16:46:02 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 20 Apr 2008 22:46:02 +0200 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480b8d58$0$26996$9b622d9e@news.freenet.de> Message-ID: <480bab8a$0$26764$9b622d9e@news.freenet.de> > http://trac.edgewall.org/ contains at least one example of a reference > leak. It's holding up the release of 0.11 for a while. *scnr* All my investigations on possible memory leaks in Trac have only confirmed that Python does _not_, I repeat, it does *NOT* leak any memory in Trac. Instead, what appears as a leak is an unfortunate side effect of the typical malloc implementation which prevents malloc from returning memory to the system. The memory hasn't leaked, and is indeed available for further allocations by trac. > The problem is also covered by the docs at > http://docs.python.org/dev/library/sys.html#sys.exc_info Ah, but that's not a *reference* leak. If Python (or an extension module) contains a reference leak, that's a bug. A reference leak is a leak where the reference counter is increased without ever being decreased (i.e. without the application having a chance to ever decrease it correctly). In this case, it's just a cyclic reference, which will get released whenever the garbage collector runs next, so it's not a memory leak. Regards, Martin From s0suk3 at gmail.com Thu Apr 17 12:56:24 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 09:56:24 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> Message-ID: <42402158-0b16-42e2-b7a0-9d9a15e8196d@24g2000hsh.googlegroups.com> On Apr 17, 11:44 am, Gary Herron wrote: > But. *What's the point* of doing it this way. I see 14 variables > being assigned a value, but I don't see the value, they are getting. > Reading this bit if code provides no useful information unless I'm > willing to scan down the file until I find the end of this mess. And in > that scanning I have to make sure I don't miss the one single line that > does not end in a backslash. (Your ellipsis conveniently left out the > *one* important line needed to understand what this code is doing, but > even if you had included it, I'd have to scan *all* lines to understand > what a single value is being assigned. > > There is *no way* you can argue that code is clearer than this: > > # General header fields > Cache_Control = None > Connection = None > Date = None > Pragma = None class RequestHeadersManager: # General header fields Cache_Control = \ Connection = \ Date = \ Pragma = \ Trailer = \ Transfer_Encoding = \ Upgrade = \ Via = \ Warning = \ # Request header fields Accept = \ Accept_Charset = \ Accept_Encoding = \ Accept_Language = \ Authorization = \ Expect = \ From = \ Host = \ If_Match = \ If_Modified_Since = \ If_None_Match = \ If_Range = \ If_Unmodified_Since = \ Max_Forwards = \ Proxy_Authorization = \ Range = \ Referer = \ TE = \ User_Agent = \ # Entity header fields Allow = \ Content_Encoding = \ Content_Language = \ Content_Length = \ Content_Location = \ Content_MD5 = \ Content_Range = \ Content_Type = \ Expires = \ Last_Modified = \ None def __init__(self, headers, linesep): headersDict = parse_headers(headers, linesep) for header in headersDict.keys(): charsLength = len(header) if charsLength == 10: if header == "connection": self.Connection = headersDict["connection"] elif header == "user-agent": self.User_Agent = headersDict["user-agent"] elif charsLength == 15: if header == "accept-encoding": self.Accept_Encoding = headersDict["accept- encoding"] elif header == "accept-language": self.Accept_Language = headersDict["accept- language"] elif charsLength == 17: if header == "if-modified-since": self.If_Modified_Since = headersDict["if-modified- since"] elif header == "transfer-encoding": self.Transfer_Encoding = headersDict["transfer- encoding"] elif charsLength == 2: if header == "te": self.TE = headersDict["te"] elif charsLength == 3: if header == "via": self.Via = headersDict["via"] elif charsLength == 4: if header == "date": self.Date = headersDict["date"] elif header == "host": self.Host = headersDict["host"] elif header == "from": self.From = headersDict["from"] elif charsLength == 5: if header == "allow": self.Allow = headersDict["allow"] elif header == "range": self.Range = headersDict["range"] elif charsLength == 6: if header == "accept": self.Accept = headersDict["accept"] elif header == "expect": self.Expect = headersDict["expect"] elif header == "pragma": self.Pragma = headersDict["pragma"] elif charsLength == 7: if header == "expires": self.Expires = headersDict["expires"] elif header == "referer": self.Referer = headersDict["referer"] elif header == "trailer": self.Trailer = headersDict["trailer"] elif header == "upgrade": self.Upgrade = headersDict["upgrade"] elif header == "warning": self.Warning = headersDict["warning"] elif charsLength == 8: if header == "if-match": self.If_Match = headersDict["if-match"] elif header == "if-range": self.If_Range = headersDict["if-range"] elif charsLength == 11: if header == "content-md5": self.Content_MD5 = headersDict["content-md5"] elif charsLength == 12: if header == "content-type": self.Content_Type = headersDict["content-type"] elif header == "max-forwards": self.Max_Forwards = headersDict["max-forwards"] elif charsLength == 13: if header == "authorization": self.Authorization = headersDict["authorization"] elif header == "cache-control": self.Cache_Control = headersDict["cache-control"] elif header == "content-range": self.Content_Range = headersDict["content-range"] elif header == "if-none-match": self.If_None_Match = headersDict["if-none-match"] elif header == "last-modified": self.Last_Modified = headersDict["last-modified"] elif charsLength == 14: if header == "accept-charset": self.Accept_Charset = headersDict["accept- charset"] elif header == "content-length": self.Content_Length = headersDict["content- length"] elif charsLength == 16: if header == "content-encoding": self.Content_Encoding = headersDict["content- encoding"] elif header == "content-language": self.Content_Language = headersDict["content- language"] elif header == "content-location": self.Content_Location = headersDict["content- location"] elif charsLength == 19: if header == "if-unmodified-since": self.If_Unmodified_Since = headersDict["if- unmodified-since"] elif header == "proxy-authorization": self.Proxy_Authorization = headersDict["proxy- authorization"] There! That's the whole code. I guess the way you suggest is simpler and a bit more intuitive, but I was figuring that the way I suggested it is more stylish. From stefan_ml at behnel.de Fri Apr 18 03:24:07 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 18 Apr 2008 09:24:07 +0200 Subject: codec for html/xml entities!? In-Reply-To: References: Message-ID: <48084C97.4040400@behnel.de> Martin Bless wrote: > What's a good way to encode and decode those entities like € or > € ? Hmm, since you provide code, I'm not quite sure what your actual question is. So I'll just comment on the code here. > def entity2uc(entity): > """Convert entity like { to unichr. > > Return (result,True) on success or (input string, False) > otherwise. Example: > entity2cp('€') -> (u'\u20ac',True) > entity2cp('€') -> (u'\u20ac',True) > entity2cp('€') -> (u'\u20ac',True) > entity2cp('&foobar;') -> ('&foobar;',False) > """ Is there a reason why you return a tuple instead of just returning the converted result and raising an exception if the conversion fails? Stefan From andrei.avk at gmail.com Sat Apr 12 03:55:21 2008 From: andrei.avk at gmail.com (AK) Date: Sat, 12 Apr 2008 03:55:21 -0400 Subject: [ANN]: Python-by-Example updates In-Reply-To: <4800620a$0$906$ba4acef3@news.orange.fr> References: <48000796$0$30160$4c368faf@roadrunner.com> <4800620a$0$906$ba4acef3@news.orange.fr> Message-ID: <48006ae9$0$4065$4c368faf@roadrunner.com> M?ta-MCI (MVP) wrote: > Hi! > Good! Thanks. > I found a bad link, for "traceback module" > @-salutations > > Michel Claveau > You're right! I forgot to upload that file, it's fixed now - thanks for noticing! -- -ak Tobu | http://tobu.lightbird.net/ | Freeform DB / Tagger / PIM Python-by-Example | http://pbe.lightbird.net/ | Guide to LibRef From jergosh at wp.pl Mon Apr 14 11:02:08 2008 From: jergosh at wp.pl (=?UTF-8?B?R3J6ZWdvcnogU8WCb2Rrb3dpY3o=?=) Date: Mon, 14 Apr 2008 17:02:08 +0200 Subject: Java or C++? In-Reply-To: References: Message-ID: <480371F0.9090104@wp.pl> > Hello, I was hoping to get some opinions on a subject. I've been > programming Python for almost two years now. Recently I learned Perl, > but frankly I'm not very comfortable with it. Now I want to move on > two either Java or C++, but I'm not sure which. Which one do you think > is a softer transition for a Python programmer? Which one do you think > will educate me the best? > I can't say from personal experience (it was C, C++, then Python for me) but I think you'll find Java very annoying, especially if you value Python for elegance. Both C++ and Java have different philosophy than Python, but C++ is better designed and more flexible. As for the 'number of jobs' argument, sure there are more Java jobs but this is offset by the number of Java programmers. Cheers, Greg From gert.cuykens at gmail.com Tue Apr 29 21:29:26 2008 From: gert.cuykens at gmail.com (gert) Date: Tue, 29 Apr 2008 18:29:26 -0700 (PDT) Subject: ssh Message-ID: <867f5bc7-3748-4303-9f29-9d8044f0d315@m3g2000hsc.googlegroups.com> Is this the best way to use ssh ? How can i use ssh keys instead of passwords ? I dont understand what happens when pid does not equal 0 , where does the cmd get executed when pid is not 0 ? How do you close the connection ? # http://mail.python.org/pipermail/python-list/2002-July/155390.html import os, time def ssh(user, rhost, pw, cmd): pid, fd = os.forkpty() if pid == 0: os.execv("/bin/ssh", ["/bin/ssh", "-l", user, rhost] + cmd) else: time.sleep(0.2) os.read(fd, 1000) time.sleep(0.2) os.write(fd, pw + "\n") time.sleep(0.2) res = '' s = os.read(fd, 1) while s: res += s s = os.read(fd, 1) return res print ssh('username', 'serverdomain.com', 'Password', ['ls -l']) From vivainio at gmail.com Thu Apr 10 11:27:39 2008 From: vivainio at gmail.com (Ville Vainio) Date: Thu, 10 Apr 2008 08:27:39 -0700 (PDT) Subject: is Pylons alive? References: Message-ID: <423388b6-33f1-4abc-8192-70f484f0ced3@h1g2000prh.googlegroups.com> On Apr 9, 2:25 pm, Mage wrote: > Before spending much time for investigating, I would like to ask you: is > Pylons the framework I look for if I want to come back to Python and > develop MVC web apps? Why not play with Django and the Google App Engine that everyone is raving about: http://code.google.com/appengine/ Zope is also becoming a realistic choice now that it's getting easier through Grok... From the.blue.valkyrie at gmail.com Fri Apr 11 05:47:25 2008 From: the.blue.valkyrie at gmail.com (=?ISO-8859-1?Q?Cristina_Yenyxe_Gonz=E1lez_Garc=EDa?=) Date: Fri, 11 Apr 2008 11:47:25 +0200 Subject: How to make a "command line basd" interactive program? In-Reply-To: References: Message-ID: 2008/4/11, Evan : > > > Hope this hasn't been posted hundreds of times. I'm new for this. > > Before using python for this kind of script, I was using TCL to write > down a "command line based" interactive program. it likes a "tclsh", > or "python" command, after that, you can work under a prompt, for > example, " - >> ", and then you can execute any commands what you > defined in script. > > Now, in python, are there any common way(class) to finish this work? > or does anybody has a example to do that? I think the simplest way is using the InteractiveConsole class from the 'code' module. It shows a prompt, reads the commands you type and checks and executes them. Doc here: http://docs.python.org/lib/module-code.html This way the TCL part could be not necessary, though. If you need some special functionality (e.g., storing the commands you type), you can subclass it easily. Thanks, > Evan > Hope it helps :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From altami0762 at gmail.com Thu Apr 17 15:50:27 2008 From: altami0762 at gmail.com (altami0762 at gmail.com) Date: Thu, 17 Apr 2008 12:50:27 -0700 (PDT) Subject: call of duty keygen Message-ID: call of duty keygen http://cracks.12w.net F R E E C R A C K S From kyosohma at gmail.com Tue Apr 15 16:31:55 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 15 Apr 2008 13:31:55 -0700 (PDT) Subject: Recurring patterns: Am I missing it, or can we get these added to the language? References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: <665ee38f-a190-4891-9f61-963705a5ed12@e67g2000hsa.googlegroups.com> On Apr 15, 3:15 pm, Tim Chase wrote: > > My suggestion would just be to create your own utils.py module > that holds your commonly used tools and re-uses them > > -tkc Well, I almost said that, but I was trying to find some "battery" included that he could use since the OP seemed to want one. I'm sure there's a geeky way to do this with lambdas or list comprehensions too. Thanks for the feedback though. Mike From tomupton33 at yahoo.com Wed Apr 30 06:12:42 2008 From: tomupton33 at yahoo.com (mickey333) Date: Wed, 30 Apr 2008 03:12:42 -0700 (PDT) Subject: free fiction Message-ID: <61ea07f5-0a1b-4518-afc1-f23060699b19@k37g2000hsf.googlegroups.com> http://www.authspot.com/Short-Stories/Sunfish.107015 From enleverlesX.XmcX at XmclaveauX.com Sat Apr 12 03:11:11 2008 From: enleverlesX.XmcX at XmclaveauX.com (Méta-MCI (MVP)) Date: Sat, 12 Apr 2008 09:11:11 +0200 Subject: [ANN]: Python-by-Example updates In-Reply-To: <48000796$0$30160$4c368faf@roadrunner.com> References: <48000796$0$30160$4c368faf@roadrunner.com> Message-ID: <4800620a$0$906$ba4acef3@news.orange.fr> Hi! Good! Thanks. I found a bad link, for "traceback module" @-salutations Michel Claveau From bwljgbwn at gmail.com Tue Apr 22 05:50:39 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:50:39 -0700 (PDT) Subject: xp cracks Message-ID: <3f608723-e380-4099-af23-38ac6f9d92f5@k10g2000prm.googlegroups.com> xp cracks http://cracks.12w.net F R E E C R A C K S From Bonus.Onus at gmail.com Mon Apr 7 23:54:09 2008 From: Bonus.Onus at gmail.com (BonusOnus) Date: Mon, 7 Apr 2008 20:54:09 -0700 (PDT) Subject: Newbie: How to pass a dictionary to a function? Message-ID: <516e07d1-91f9-462b-9fc0-ac6d1e474f9d@n14g2000pri.googlegroups.com> How do I pass a dictionary to a function as an argument? # Say I have a function foo... def foo (arg=[]): x = arg['name'] y = arg['len'] s = len (x) t = s + y return (s, t) # The dictionary: dict = {} dict['name'] = 'Joe Shmoe' dict['len'] = 44 # I try to pass the dictionary as an argument to a # function len, string = foo (dict) # This bombs with 'TypeError: unpack non-sequence' What am I doing wrong with the dictionary? From turian at gmail.com Fri Apr 18 15:16:16 2008 From: turian at gmail.com (Joseph Turian) Date: Fri, 18 Apr 2008 12:16:16 -0700 (PDT) Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> Message-ID: <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> Basically, we're planning on releasing it as open-source, and don't want to alienate a large percentage of potential users. From http Tue Apr 15 02:44:58 2008 From: http (Paul Rubin) Date: 14 Apr 2008 23:44:58 -0700 Subject: pgdb: Debugging Python extensions made easier References: <7xzlrw7xw7.fsf@ruckus.brouhaha.com> <20484252-e346-4263-9f61-75a678134a77@8g2000hse.googlegroups.com> Message-ID: <7x3apnwr9x.fsf@ruckus.brouhaha.com> SteveD writes: > The point being that with a newish GDB (the current mingw GDB I think I was using an older gdb, but under linux, so it's possible that under mingw there are or were different issues. From drjekil77 at gmail.com Tue Apr 8 15:54:47 2008 From: drjekil77 at gmail.com (drjekil) Date: Tue, 8 Apr 2008 12:54:47 -0700 (PDT) Subject: new user needs help! Message-ID: <16571784.post@talk.nabble.com> I am totally new in biopython and its my first program.so may be i am asking stupid question. I am working with a text filelooks like this: #NAME AA TOPO ACCESS DSSP STRIDE Z-COORD 1lghB A i 79.8 H H -24.58 1lghB V i 79.6 H H -22.06 1lghB H i 71.9 H H -19.94 i need to compare those lines which has a value between 10 to 22 and presents in the following way True/false A C D E F G H I K L M N P Q R S T V X Y W(here alfabets represents amino acids) 1 1:1 2:0 3:0 and so on for rest of the amino acids. IF PRESENT IN THAT RANGE IF not PRESENT IN THAT RANGE then -1 1:0 2:0 so on,it should be 1 instead of 0 when it will find corresponding amino acid for that line.say here,for 2nd line it will be 16:1. true will represent 1,false -1. i have to cheek all the lins in the file and print it. u have to tell simply otherwise i cant understand even,so stupid am i! I will be really greatful!Thanks in advance -- View this message in context: http://www.nabble.com/new--user-needs-help%21-tp16571784p16571784.html Sent from the Python - python-list mailing list archive at Nabble.com. From paul at boddie.org.uk Fri Apr 25 10:31:36 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Fri, 25 Apr 2008 07:31:36 -0700 (PDT) Subject: Problem building python in virtual machine running centos References: Message-ID: <6f818ad0-fe79-45a9-aa31-a00e337f93aa@a70g2000hsh.googlegroups.com> On 25 Apr, 14:16, Paul Melis wrote: > > "The bug is not reproducible, so it is likely a hardware or OS problem." > > This line is printed by GCC itself, not the OP It's a strange thing for anyone to claim in an error message, though, especially if it is reproducible. Perhaps some people have special criteria for reproducibility. Paul From lists at cheimes.de Mon Apr 21 06:50:04 2008 From: lists at cheimes.de (Christian Heimes) Date: Mon, 21 Apr 2008 12:50:04 +0200 Subject: sys.maxint in Python 3 In-Reply-To: References: Message-ID: <480C715C.90809@cheimes.de> bearophileHUGS at lycos.com schrieb: > In some algorithms a sentinel value may be useful, so for Python 3.x > sys.maxint may be replaced by an improvement of the following infinite > and neginfinite singleton objects: Python 3.0 doesn't have sys.maxint any more since Python 3's ints are of arbitrary length. Instead of sys.maxint it has sys.maxsize; the maximum size of a positive sized size_t aka Py_ssize_t. Christian From gagsl-py2 at yahoo.com.ar Thu Apr 10 03:28:43 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 04:28:43 -0300 Subject: argument to python cgi script References: <12b075a10804090714l44b012e6oe35a9e471d68a059@mail.gmail.com> Message-ID: En Wed, 09 Apr 2008 11:14:33 -0300, syed mehdi escribi?: > Hi Guys, > If someone can help me in telling how can i pass arguments to python cgi > script then that will be good. > like if i want to pass "some argument" to my remote python script, by > calling something like: > http://localhost/cgi-bin/test.py?some\ argument. > What is the correct way of sending arguments in this way, and how can i > decode/receive them in test.py Encoding: py> args = {'some': 'argument', 'x': 1, 'z': 23.4} py> import urllib py> urllib.urlencode(args) 'x=1&z=23.4&some=argument' You can then use urllib.urlopen or urllib2.urlopen to send the HTTP request and retrieve the response. http://docs.python.org/lib/module-urllib.html In the server side, use cgi.FieldStorage: form = cgi.FieldStorage() x = form.getfirst('x', 0) # '1' y = form.getfirst('y', 0) # '0' z = form.getfirst('z', 0) # '23.4' http://docs.python.org/lib/module-cgi.html -- Gabriel Genellina From a.vikohn at gmail.com Mon Apr 7 23:16:03 2008 From: a.vikohn at gmail.com (Avi Kohn) Date: Mon, 7 Apr 2008 23:16:03 -0400 Subject: guide through python interpreter source code Message-ID: Are there documents,books, articles that can introduce me to the python source code base ? Thank you! Avi From terry.yinzhe at gmail.com Sun Apr 27 06:27:59 2008 From: terry.yinzhe at gmail.com (Terry) Date: Sun, 27 Apr 2008 03:27:59 -0700 (PDT) Subject: Question regarding Queue object Message-ID: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> Hello! I'm trying to implement a message queue among threads using Queue. The message queue has two operations: PutMsg(id, msg) # this is simple, just combine the id and msg as one and put it into the Queue. WaitMsg(ids, msg) # this is the hard part WaitMsg will get only msg with certain ids, but this is not possible in Queue object, because Queue provides no method to peek into the message queue and fetch only matched item. Now I'm using an ugly solution, fetch all the messages and put the not used ones back to the queue. But I want a better performance. Is there any alternative out there? This is my current solution: def _get_with_ids(self,wait, timeout, ids): to = timeout msg = None saved = [] while True: start = time.clock() msg =self.q.get(wait, to) if msg and msg['id'] in ids: break; # not the expecting message, save it. saved.append(msg) to = to - (time.clock()-start) if to <= 0: break # put the saved messages back to the queue for m in saved: self.q.put(m, True) return msg br, Terry From Robert.Bossy at jouy.inra.fr Mon Apr 14 04:11:42 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Mon, 14 Apr 2008 10:11:42 +0200 Subject: Java or C++? In-Reply-To: References: Message-ID: <480311BE.1020404@jouy.inra.fr> s0suk3 at gmail.com wrote: > Hello, I was hoping to get some opinions on a subject. I've been > programming Python for almost two years now. Recently I learned Perl, > but frankly I'm not very comfortable with it. Now I want to move on > two either Java or C++, but I'm not sure which. Which one do you think > is a softer transition for a Python programmer? Which one do you think > will educate me the best? > Hi, I vote for Java, it will be relatively smoother if you come from Python. Java adds a bit of type-checking which is a good thing to learn to code with. Also with Java, you'll learn to dig into an API documentation. Brian suggests C++, personnally, I'd rather advise C for learning about computers themselves and non-GC memory management. C++ is just too nasty. If your goal is exclusively education, I suggest a functional language (choose Haskell or any ML dialect) or even a predicate-based language (Prolog or Mercury, but the latter is pretty hardcore). These languages have quite unusual ways of looking at algorithm implementations and they will certainly expand your programming culture. Cheers, RB From andrew at acooke.org Tue Apr 15 04:50:18 2008 From: andrew at acooke.org (andrew cooke) Date: Tue, 15 Apr 2008 01:50:18 -0700 (PDT) Subject: Dynamic use of property() fails References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> <480461f8$0$20282$426a34cc@news.free.fr> Message-ID: On Apr 15, 4:06 am, Bruno Desthuilliers wrote: > The canonical solution is to use a custom descriptor instead of a property: > > class Field(object): > def __init__(self, name, onchange): > self.name = name > self.onchange = onchange > > def __get__(self, instance, cls): > if instance is None: > # called on the class > return self > # called on instance > return instance._values[self.name] > > def __set__(self, instance, value): > instance._values[name] = self.onchange(value) > > class ActiveDAO(object): > def __init__(self): > self._values = [] > > class Person(ActiveDAO): > name = Field('firstname', lambda v: v.strip().capitalize()) > age = Field('age', lambda v : int(v)) i tried code very similar after reading the first replies and found that it did not work as expected on setting. for example, in person = Person() person.age = 27 "age" is set in the instance's dictionary (as 27; the descriptor is not called), which then shadows the definition of age in the class dictionary. my understanding was that the descriptor is only called in the class context, so would be called if, say, a subclass tried to redefine age. but maybe i am still confused. i am about to go to sleep. i guess i will try your code exactly tomorrow, but it looks very close to mine which showed this problem. are you sure your solution works? thanks, andrew From Lie.1296 at gmail.com Sun Apr 6 13:49:42 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 6 Apr 2008 10:49:42 -0700 (PDT) Subject: How To Uses Modules And Plugins References: <47650e1f-148e-48f9-b09e-51cb5fb4f402@m73g2000hsh.googlegroups.com> Message-ID: <50b915ac-176e-4edf-8355-db9f8c31d51e@z24g2000prf.googlegroups.com> On Apr 7, 12:28 am, mar... at everautumn.com wrote: > I am working on a client/server, computer role-play game using Python. > I want to gradually expand the game world by creating maps as > individual py files in a map directory. I am a little foggy of how to > do this. I have read about the __import__() function. I want to > understand what the difference is between using modules and plugins. > Are they the same thing? How will my root script interact with the > individual modules once it has loaded them? If you can point me to a > web site or tutorial on this subject I would be thankful. I think you're doing it with the wrong approach, a map is a data so it should not be placed in a .py file, instead it should be placed in something like .map files which is read by your program to generate the map object. To read a file in python, use: f = file('path/path/file.map', 'r') # for reading g = file('path/path/file.map', 'rw') # for read and write m = f.readline() # To read until meeting a '\n' n = f.read() # To read until EOF (End of File) for line in g: # # To read the file line by line # using the very convenient for # f.close() # Don't forget to close the file after use g.close() From danb_83 at yahoo.com Sat Apr 12 14:00:23 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Sat, 12 Apr 2008 11:00:23 -0700 (PDT) Subject: str(bytes) in Python 3.0 References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> Message-ID: On Apr 12, 9:29 am, Carl Banks wrote: > On Apr 12, 10:06 am, Kay Schluehr wrote: > > > On 12 Apr., 14:44, Christian Heimes wrote: > > > > Gabriel Genellina schrieb: > > > > > On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') > > > > above. But I get the same as repr(x) - is this on purpose? > > > > Yes, it's on purpose but it's a bug in your application to call str() on > > > a bytes object or to compare bytes and unicode directly. Several months > > > ago I added a bytes warning option to Python. Start Python as "python > > > -bb" and try it again. ;) > > > And making an utf-8 encoding default is not possible without writing a > > new function? > > I believe the Zen in effect here is, "In the face of ambiguity, refuse > the temptation to guess." How do you know if the bytes are utf-8 > encoded? True, you can't KNOW that. Maybe the author of those bytes actually MEANT to say '??C??mo est??s?' instead of '?C?mo est?s?'. However, it's statistically unlikely for a non-UTF-8-encoded string to just happen to be valid UTF-8. From kamhung.soh at gmail.com Mon Apr 14 02:12:41 2008 From: kamhung.soh at gmail.com (Kam-Hung Soh) Date: Sun, 13 Apr 2008 23:12:41 -0700 (PDT) Subject: how to remove \n in the list References: <2ba667ab-6818-47eb-8595-79ed970728f7@q1g2000prf.googlegroups.com> Message-ID: On Apr 14, 2:58 pm, "Gabriel Genellina" wrote: > En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam > escribi?: > > > hi, > > l=['5\n', '2\n', '7\n', '3\n', '6\n'] > > > how to remove \n from the given list > > l is is very poor name... I'll use lines instead: > > lines[:] = [line.rstrip('\n') for line in lines] > > -- > Gabriel Genellina Also: map(str.rstrip, l) -- Kam-Hung Soh Software Salariman From skanemupp at yahoo.se Sun Apr 6 14:12:55 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 6 Apr 2008 11:12:55 -0700 (PDT) Subject: Prevent GUI layout from changing? Message-ID: when i added the results-LABEL the buttons have changed place. meh why cant i just put buttons and stuff on a specific coordinate and have them staying there? #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self, master=None): """Initialize yourself""" self.expr = "" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): ## """Create the Entry, set it to be a bit wider""" ## self.enText = Entry(self) ## self.enText.grid(row=0, column=0, columnspan=3) """Create the Button, set the text and the command that will be called when the button is clicked""" self.btnDisplay = Button(self, text="calculate!", command=self.Calculate) self.btnDisplay.grid(row=0, column=31) """Create the Button, set the text and the command that will be called when the button is clicked""" self.lbText = Label(self, text="Results: ") self.lbText.grid(row=1, column=0) self.btnDisplay = Button(self,text='1',command=lambda n="1":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='2',command=lambda n="2":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='3',command=lambda n="3":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='+',command=lambda n="+":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=3, column=3, padx=5, pady=5) self.btnDisplay = Button(self,text='4',command=lambda n="4":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='5',command=lambda n="5":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='6',command=lambda n="6":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='-',command=lambda n="-":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=4, column=3, padx=5, pady=5) self.btnDisplay = Button(self,text='7',command=lambda n="7":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='8',command=lambda n="8":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='9',command=lambda n="9":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='*',command=lambda n="*":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=5, column=3, padx=5, pady=5) self.btnDisplay = Button(self,text='0',command=lambda n="0":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='C',command=self.Clean) self.btnDisplay.grid(row=6, column=1, padx=5, pady=5) self.btnDisplay = Button(self,text='r',command=lambda n="r":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=2, padx=5, pady=5) self.btnDisplay = Button(self,text='/',command=lambda n="/":self.Display(n),width=1,height=1) self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) def Display(self, number): self.expr = self.expr + number self.lbText = Label(self, text=self.expr) self.lbText.grid(row=0, column=0) def Calculate(self): self.expr = str(eval(self.expr))#try catch tex 3+6+ self.lbText = Label(self, text=self.expr) self.lbText.grid(row=1, column=1) self.expr = "" def Clean(self): self.expr = "" #self.update() if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() From deets at nospam.web.de Wed Apr 16 08:20:25 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 16 Apr 2008 14:20:25 +0200 Subject: webcam (usb) access under Ubuntu References: <66jlk1F2ju6c8U1@mid.uni-berlin.de> <66kkedF2l526dU2@mid.uni-berlin.de> <455760fb-8229-4be3-ba7f-7c41bdcd66de@a22g2000hsc.googlegroups.com> <362eb242-2adc-4d7b-9c0a-95e72f4b22b6@e67g2000hsa.googlegroups.com> <66m26hF2lo3ghU1@mid.uni-berlin.de> <590f00ea-15d3-480a-9fa8-c28c32a292b2@e39g2000hsf.googlegroups.com> Message-ID: <66m995F2lchhkU1@mid.uni-berlin.de> Berco Beute wrote: > On Apr 16, 12:19 pm, "Diez B. Roggisch" wrote: >> Maybe if you are now using windows, there are better options - but I'm a >> *nix-boy :) >> >> Diez > > So am I :), but the application I'm writing has to run on *that other > operating system from the 90's*. > I'm trying hard not to implement the application in C#/.Net, but I'm > running out of open source alternatives. VideoCapture *almost* worked > and now I'm stranded at the gstreamer road as well... How's that saying? "If your in Rom, do as the Romans do". Don't fight Windows. And take IronPython to mitigate the pain of using it :) Diez From seberino at spawar.navy.mil Tue Apr 1 18:37:22 2008 From: seberino at spawar.navy.mil (seberino at spawar.navy.mil) Date: Tue, 1 Apr 2008 15:37:22 -0700 (PDT) Subject: What motivates all unpaid volunteers at Pycon? References: <7b539c8e-af4c-4409-81bc-d94e687eea59@i7g2000prf.googlegroups.com> <12d7412e-9f87-4798-a319-a78a27f68d00@e6g2000prf.googlegroups.com> Message-ID: <6ffcb45b-abb9-4d5e-8237-0f8c6bacab08@i29g2000prf.googlegroups.com> On Apr 1, 11:45 am, Ed Leafe wrote: Assuming that people get nothing back by participating in a > community, yes, it would be curious. My experience, though, is that I > get a lot more out of it than I could ever contribute. IOW, it's a > great example of synergy. What do the people get back who did all the hard work at registration desk and preparing conference attendee bags? ...who did all hotel preparations? Chris From marlin_rowley at hotmail.com Wed Apr 16 15:29:48 2008 From: marlin_rowley at hotmail.com (Marlin Rowley) Date: Wed, 16 Apr 2008 14:29:48 -0500 Subject: Passing the output of a thread to the caller. Message-ID: I have a thread that I've created from a main program. I started this thread and passed it a function to execute. Within this function are 'print' statements. While they are directly translated to the stdout, I would love to return them back to the program itself and store them in an object. How would I do this? -M _________________________________________________________________ Use video conversation to talk face-to-face with Windows Live Messenger. http://www.windowslive.com/messenger/connect_your_way.html?ocid=TXT_TAGLM_WL_Refresh_messenger_video_042008 -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavlovevidence at gmail.com Thu Apr 10 06:39:35 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Thu, 10 Apr 2008 03:39:35 -0700 (PDT) Subject: I am worried about Python 3 References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> <47fce3ca$0$36346$742ec2ed@news.sonic.net> Message-ID: <83fda3fc-cedc-4105-862d-9e00d74817e3@24g2000hsh.googlegroups.com> On Apr 9, 11:53 am, John Nagle wrote: > jmDesktop wrote: > > If I continue in Python 2.5.x, am I making a mistake? Is it really > > that different? > > No. It may never happen, either. The Perl crowd tried > something like this, Perl 6, which was announced in 2000 and still > hasn't come out. The C++ standards committee has been working on a > revision of C++ since the 1990s, and that hasn't happened either. You're not paying attention if you think there's it's still doubt over whether Python 3 will happen. > The general consensus is that Python 3.x isn't much of an > improvement over the existing language. I'm going to have to opine that you pulled this out of your ass. > There's just not much demand for it. Well that's a little mode defensible seeing that we really don't know how people will react. Carl Banks From s0suk3 at gmail.com Mon Apr 14 02:44:10 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Sun, 13 Apr 2008 23:44:10 -0700 (PDT) Subject: Java or C++? Message-ID: Hello, I was hoping to get some opinions on a subject. I've been programming Python for almost two years now. Recently I learned Perl, but frankly I'm not very comfortable with it. Now I want to move on two either Java or C++, but I'm not sure which. Which one do you think is a softer transition for a Python programmer? Which one do you think will educate me the best? From colas.francis at gmail.com Wed Apr 16 09:53:39 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Wed, 16 Apr 2008 06:53:39 -0700 (PDT) Subject: vary number of loops References: Message-ID: <7cf04150-06f3-4198-b55f-ffe14ef0e050@y21g2000hsf.googlegroups.com> On 16 avr, 15:31, nullgr... at gmail.com wrote: > Hi everyone, > > I'm new to Python and the notion of lambda, and I'm trying to write a > function that would have a varying number of nested for loops > depending on parameter n. This just smells like a job for lambda for > me, but I can't figure out how to do it. Any hint? > > For example, for n=2, I want the function to look something like: > > def foo(2) > generate 2 sets of elements A, B > # mix elements by: > for a_elt in A > for b_elt in B > form all combinations of them > > If n=3, I want to have 3 sets of elements and mix them up using 3 for > loops. > > Any help is greatly appreciated, > > nullgraph You can try recursion in a more classic manner: In [283]: def foo(n): .....: def bar(n): .....: my_elts = xrange(2) .....: if n<=0: .....: raise StopIteration .....: elif n<=1: .....: for elt in my_elts: .....: yield (elt,) .....: else: .....: for elt in my_elts: .....: for o_elt in bar(n-1): .....: yield (elt,)+o_elt .....: for elt in bar(n): .....: print elt .....: In [284]: foo(2) (0, 0) (0, 1) (1, 0) (1, 1) In [285]: foo(3) (0, 0, 0) (0, 0, 1) (0, 1, 0) (0, 1, 1) (1, 0, 0) (1, 0, 1) (1, 1, 0) (1, 1, 1) In this case, I have an inner function to generate the whole set of elements and then an outer loop to process them. Note that you can have the generation of my_elts depend on rank n of recursion (that is the index of the set in your list). From wizzardx at gmail.com Sat Apr 26 03:54:21 2008 From: wizzardx at gmail.com (David) Date: Sat, 26 Apr 2008 09:54:21 +0200 Subject: problem with listdir In-Reply-To: References: Message-ID: <18c1e6480804260054s2802dbf8teff9dc8284745b4d@mail.gmail.com> > > i get the following error > WindowsError: [Error 123] The filename, directory name, or volume > label syntax is incorrect: 'f:\\code\\python\pgmgallery/*.*' > > i am running python on winXP ..can anyone tell me why i get this > error? > -- >From some Googling, it looks like this error can happen in Windows when you have registry problems. This isn't a Python problem as far as I can tell. A few things for you to try: * Try running your code on another machine with the same directory. * Run cmd.exe and see if you can run "dir f:\\code\\python\pgmgallery/*.*" * Try using other drives besides F: (C: is a good start) * Try using other directories under F: drive in your program and see when you start hitting the problem. David. From sjmachin at lexicon.net Tue Apr 1 08:27:50 2008 From: sjmachin at lexicon.net (John Machin) Date: Tue, 01 Apr 2008 12:27:50 GMT Subject: xlrd and cPickle.dump In-Reply-To: <34e62ddb-477f-4a99-97a5-21a7b148d244@e67g2000hsa.googlegroups.com> References: <34e62ddb-477f-4a99-97a5-21a7b148d244@e67g2000hsa.googlegroups.com> Message-ID: <47f22a41@news.mel.dft.com.au> patrick.waldo at gmail.com wrote: > Hi all, > > Sorry for the repeat I needed to reform my question and had some > problems...silly me. Indeed. Is omitting the traceback part of the "reformation"? > > The xlrd documentation says: > "Pickleable. Default is true. In Python 2.4 or earlier, setting to > false will cause use of array.array objects which save some memory but > can't be pickled. In Python 2.5, array.arrays are used > unconditionally. Note: if you have large files that you need to read > multiple times, it can be much faster to cPickle.dump() the xlrd.Book > object once, and use cPickle.load() multiple times." > > I'm using Python 2.4 and I have an extremely large excel file that I > need to work with. How many megabytes is "extremely large"? How many seconds does it take to open it with xlrd.open_workbook? > The documentation leads me to believe that cPickle > will be a more efficient option, but I am having trouble pickling the > excel file. So far, I have this: > > import cPickle,xlrd > import pyExcelerator > from pyExcelerator import * You only need one of the above imports at the best of times, and for what you are attempting to do, you don't need pyExcelerator at all. > > data_path = """C:\test.xls""" It is extremely unlikely that you have a file whose basename begins with a TAB ('\t') character. Please post the code that you actually ran. > pickle_path = """C:\pickle.xls""" > > book = xlrd.open_workbook(data_path) > Data_sheet = book.sheet_by_index(0) > > wb=pyExcelerator.Workbook() > proc = wb.add_sheet("proc") > > #Neither of these work > #1) pyExcelerator try > #cPickle.dump(book,wb.save(pickle_path)) > #2) Normal pickle try > #pickle_file = open(pickle_path, 'w') > #cPickle.dump(book, pickle_file) > #file.close() > and the last bit of the pre-freormation traceback was """ File "C:\Python24\lib\copy_reg.py", line 69, in _reduce_ex raise TypeError, "can't pickle %s objects" % base.__name__ TypeError: can't pickle file objects """ I can reproduce that behaviour with Python 2.2, also with 2.1 (different error message, same meaning). However it works OK with Python 2.3.5, 2.4.3, and 2.5.2. Precisely which version of Python 2.4 are you using? Are you in the habit of copying library files like copy_reg.py from one version to another? The second argument of cPickle.dump is an open file. wb.save(pickle_path) will write an empty/default spreadsheet file to the given path (this is utterly pointless) and then return None. So once you get over the first problem, you will have the second: None is not an open file. The whole pyExcelerator carry-on is quite irrelevant to your problem. Please post the minimal pyExcelerator-free script that demonstrates your problem. Ensure that it includes the following line: import sys; print sys.version; print xlrd.__VERSION__ Also post the output and the traceback (in full). Cheers, John From pavlovevidence at gmail.com Thu Apr 17 04:18:49 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Thu, 17 Apr 2008 01:18:49 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> Message-ID: On Apr 17, 3:37 am, Jonathan Gardner wrote: > Using 100% of the CPU is a bug, not a feature. No it isn't. That idea is borne of the narrowmindedness of people who write server-like network apps. What's true for web servers isn't true for every application. > If you can't rewrite > your algorithm to be disk or network bound, next optimization step is > C. I'm sorry, but I don't like being told to use C. Perhaps I would like the expressiveness of Python, am willing to accept the cost in performance, but would also like to take advantage of technology to get performance gains when I can? What's so unreasonable about that? Look, the GIL is not a good thing. It's a trade off. Probably a good one, too, considering the history of Python's development and the way it simplifies writing extensions. But it's not, by itself, a good thing. For the record, I am not complaining about that GIL. As I said, I understand and approve of why it's there. I am, however, complaining about attitude that if you want to be free of the GIL you're doing something wrong. Carl Banks From roy at panix.com Sun Apr 6 22:46:14 2008 From: roy at panix.com (Roy Smith) Date: Sun, 06 Apr 2008 22:46:14 -0400 Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> Message-ID: In article , Aldo Cortesi wrote: > I should also note that converting from unittest to Pry is quite simple > - Pry's test structure is a superset of unittest's, and AutoTree was > explicitly written to make "unittest-style" testing possible, meaning > that no _structural_ change is needed for conversion. The most onerous > part is converting to assertion-based testing, something that will > improve the clarity and readability of your tests anyway. I've been following this thread for a while with a mix of amusement and alarm. Contributing code to the community is a good thing, and should be celebrated. If people like it, they will use it. If they don't, it will be ignored. None of which justifies the hostility this thread seems to have degenerated into. In any case, I don't understand why you say that unittest doesn't use "assertion-based testing". They seem like assertions to me. What am I missing? From gagsl-py2 at yahoo.com.ar Tue Apr 8 02:32:33 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 08 Apr 2008 03:32:33 -0300 Subject: Translating keywords References: <873apwubmm.fsf@physik.rwth-aachen.de> Message-ID: En Tue, 08 Apr 2008 03:03:13 -0300, Torsten Bronger escribi?: > Gabriel Genellina writes: >> >> Python 3 allows for unicode identifiers, but I don'k know any >> plans for using unicode keywords too. Looks funny: >> >> ? x ? values: >> if x ? forbidden ? x ? y: >> print(x, ?(x), ?(x)) >> print(?(values)) >> near = ? a,b,?=0.01: a-? ? b ? a+? > > As far as I've understood it, only letters are allowed in > identifiers rather than arbitrary Unicode code points. Yes, this was of course a futuristic exercise of imagination, even replacing keywords with some symbols. Anyway the only non-alphabetic identifier is ?; ? could replace ?, and all others are allowed letters in Python 3. -- Gabriel Genellina From tinnews at isbd.co.uk Thu Apr 3 11:17:08 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 03 Apr 2008 15:17:08 GMT Subject: mailbox.Maildir(), confusing documentation Message-ID: <47f4f4f4$0$715$bed64819@news.gradwell.net> Having got my Python 2.5.2 installed I'm trying some things out with the mailbox.Maildir() class. If I do the following:- import maibox mailbox.Maildir("/home/isbd/Mail/Li/pytest") then the pytest Maildir mailbox is created - which is great but isn't documented. If the above creates the maildir then what is the mailbox.Maildir.add_folder() method for? I tried mailbox.Maildir.add_folder() and it appeared to do nothing, it didn't produce any errors either. Anyway I'm happy that mailbox.Maildir() will create maildirs and it means I can do basically what I want but the documentation could be a bit more helpful. Are there any HowTos or FAQs for this (quite new I know) part of Python? -- Chris Green From reachmsn at hotmail.com Wed Apr 9 03:56:27 2008 From: reachmsn at hotmail.com (reachmsn at hotmail.com) Date: Wed, 9 Apr 2008 00:56:27 -0700 (PDT) Subject: Cannot understand the detailedly the following code References: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> Message-ID: <874ad604-f2c1-4f0c-84c8-724723215d76@q10g2000prf.googlegroups.com> On Apr 8, 5:45?pm, "A.T.Hofkamp" wrote: > On 2008-04-08, reach... at hotmail.com wrote: > > [deleted a long piece of text by our BDFL about recursive graph path-finding algorithm] > > > after first writing the inductive part ... for node in > > graph[start] .... > > and then by trial and error put square brackets around path in the > > Basis part. Can someone please explain how to write this code. Thanks! > > The same as any other function. > (the trick with recursive functions is not to think about recursion. Instead, > pretend you are calling another function that happens to have the same name.) > > As for the actual procedure of writing a function: > > First define the input and output parameters/values of the function. > (ie what goes in, and what comes out) > > For recursive functions, there are always two cases, a terminating case, and a > reduction case. In the first case, you may not use the recursive function, in > the latter function you should. > Both cases should use the information available from the input parameters, and > provide a result that matches with the output requirements of the function. Add > a if/then/else that distinguishes between what case you have, and you're done. > > Sincerely, > Albert OK so trying to follow your instructions I have- def find_all_paths(graph, start, end, path=[]): for node in graph[start]: From spam-trap at telus.net Mon Apr 28 14:27:32 2008 From: spam-trap at telus.net (L. Lindstrom) Date: Mon, 28 Apr 2008 18:27:32 GMT Subject: Python 2.6, building SDL for Pygame Message-ID: I build the Pygame releases for Windows. Pygame wraps the Simple Directmedia Layer (SDL) C library. I am doing preliminary research into porting Pygame to Python 2.6. For Pythons 2.4 and 2.5 the Pygame extension modules are built with MinGW. They link cleanly against msvcr71.dll. A custom SDL, also linked to msvcr71.dll, is used. It is built with Msys/MinGW using the configure/make tool chain. For Python 2.6 I expect Visual Studio 2008 will be required to build the Pygame extension modules. However, I am at a loss as to how to build SDL so it also links against msvcr90.dll. Windows' side=by-side assemblies get in the way. The Msys build process fails. The first test program configure compiles and runs refuses to load msvcr90.dll. It raises an R6034 error. How important is it that a C library uses the same C run-time as the Python extension module that wraps it? If it is not critical then the SDL library will just use msvcrt.dll for Pygame and Python 2.6. -- Lenard Lindstrom "%s@%s.%s" % ('len-l', 'telus', 'net') From jimgardener at gmail.com Sat Apr 26 13:56:31 2008 From: jimgardener at gmail.com (jimgardener) Date: Sat, 26 Apr 2008 10:56:31 -0700 (PDT) Subject: problem with listdir References: Message-ID: > * Run cmd.exe and see if you can run "dir f:\\code\\python\pgmgallery/*.*" > that causes a message 'Invalid switch - "*.*".' > * Try using other directories under F: drive in your program and see> when you start hitting the problem. i tried that..on some directories in the same drive this gives correct result and returns a list of filenames.however the error occurs on other directories ,looks like a weird windows problem! From sam at mas.pl Wed Apr 2 10:52:30 2008 From: sam at mas.pl (sam) Date: Wed, 02 Apr 2008 16:52:30 +0200 Subject: Prototype OO In-Reply-To: <47f38ad8$0$10664$426a34cc@news.free.fr> References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> Message-ID: Bruno Desthuilliers napisa?(a): > Don't misunderstand me : I'm not saying that class-based is better (or > worse) than prototype, I'm not saying that Python is perfect, I'm not > saying that your points are not worth any consideration, I'm just saying > that, from your arguments, I have the very strong impression that you > don't know enough about Python's object model to understand it's > coherence and strength (and I've probably expressed it a rather harsh > way - please bear with me). If I'm wrong, please say so, pardon me and > we'll move ahead. I understand you. Thanks for spending time to write all that things. The point is that when I say: -- you should have same syntax of lambdas and ordinary functions then Python gurus say: -- lambda is very good and is so special, that has its own syntax But it seems to me, that lambda syntax was introduced because of interpreter limitations -- indentation and expressions. So it is not perfect, but must be as it is now. Then I say: -- __id is awful, because it is a trick to prefix names and gurus say: -- it is good solution for name conflicts But somebody may prefix his names with class names and cause nameconflict, so maybe it is not so good? I would prefer to hear something like "other solutions were very complex, and our zen says 'Simple is better than complex.', so we decided to use this simple and not perfect solution" From victorsubervi at gmail.com Tue Apr 22 08:41:41 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Tue, 22 Apr 2008 07:41:41 -0500 Subject: Error Handling In-Reply-To: References: <4dc0cfea0804171219l7e4c749dpfd13f9bb35294e1a@mail.gmail.com> Message-ID: <4dc0cfea0804220541l6b8f0512u19f599e67b2c5e6@mail.gmail.com> That worked. Thanks! Victor On Sun, Apr 20, 2008 at 11:02 PM, Gabriel Genellina wrote: > En Thu, 17 Apr 2008 16:19:12 -0300, Victor Subervi < > victorsubervi at gmail.com> escribi?: > > > try: > > cursor.execute(sql) > > print '?Exito en introducir!
' > > print 'Esta p?gina va a regresar a la p?gina principal del > carrito > > de compras en 10 segundos.' > > except IntegrityError: > > print 'Lo siento, pero el ID que entraste est? usado actualmente > por > > otra entrada. Favor de dar para atr?z y escojer otro n?mero.' > > except OperationalError: > > print 'Lo siento, pero has a?adido un car?cter extra?o a un n?mero > (o > > en "ID", "precio", "rec?maras" o "ba?os". Favor de dar para atr?z y > escojer > > otro n?mero.' > > except: > > print 'Lo siento, pero hay un error. Favor de dar para atr?z y > > averiguar donde est? el error, y reintentar.' > > When I enter and ID that is not a number, it should trigger the > > IntegrityError. Instead, I get this in the error log: > > > > [Thu Apr 17 12:06:37 2008] [error] [client 190.166.0.245] PythonHandler > > mod_python.cgihandler: NameError: global name 'IntegrityError' is not > > defined, referer: http://livestocksling.com/bre/iud.py > > Looks like IntegrityError and OperationalError are defined inside your > database module. Either use: > > from my_database_module import IntegrityError, OperationalError > > try > ... > except OperationalError: ... > except IntegrityError: ... > except Exception: ... > > or else: > > import my_database_module > > try > ... > except my_database_module.OperationalError: ... > except my_database_module.IntegrityError: ... > except Exception: ... > > It's the same as any other symbol, like math.sqrt or os.rename > > Note that I've not used a bare except: clause; it's not a good idea. > sys.exit() raises the SystemExit exception, and pressing Ctrl-C raises > KeyboardInterrupt; a bare except: will catch them, effectively nullifying > the intended purpose. > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdw at distorted.org.uk Tue Apr 22 15:20:26 2008 From: mdw at distorted.org.uk (Mark Wooding) Date: Tue, 22 Apr 2008 19:20:26 +0000 (UTC) Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. References: Message-ID: Kenneth McDonald wrote: > Sadly. python-beautifulsoup is a Debian package, so ftp://ftp.debian.org/debian/pool/main/b/beautifulsoup/beautifulsoup_3.0.4.orig.tar.gz should be a copy of the (unmodified) upstream source. -- [mdw] From kyosohma at gmail.com Thu Apr 24 10:23:25 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Thu, 24 Apr 2008 07:23:25 -0700 (PDT) Subject: Tkinter scrollbar and checkbox References: <9581b4cd-36f1-47dc-ae6e-0ca58f1b38e0@27g2000hsf.googlegroups.com> Message-ID: <741dfbee-530e-49af-a1fc-deb3cebbbd16@w74g2000hsh.googlegroups.com> On Apr 24, 7:11?am, goldtech wrote: > Hi, > > I'm stumped on how to have a scrollbar with a long list of checkboxes. > Given code like: > > from Tkinter import * > root = Tk() > states = [] > for i in range(150): > ? ? var = IntVar() > ? ? chk = Checkbutton(root, text=str(i), variable=var) > ? ? chk.grid(sticky=W) > ? ? states.append(var) > root.mainloop() > print map((lambda var: var.get()), states) > > I've tried adding this to a frame then adding the frame to a canvas > and it gets complicated rather quickly... > > Is there a simple way to add a scroll bar? > > Thanks I use wxPython most of the time, however effbot has a good tutorial on scrollbars for Tkinter that I think you might find helpful: http://effbot.org/zone/tkinter-scrollbar-patterns.htm Here's another link on the subject: http://www.pythonware.com/library/tkinter/introduction/scrollbar.htm HTH Mike From gagsl-py2 at yahoo.com.ar Thu Apr 24 01:37:15 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 24 Apr 2008 02:37:15 -0300 Subject: @classmethod question References: Message-ID: En Thu, 24 Apr 2008 00:27:13 -0300, Scott SA escribi?: > I'm using the @classemethod decorator for some convenience methods and > for some reason, either mental block or otherwise, can't seem to figure > out how to elegantly detect if the call is from an instance or not. > > Here's the problem: Within the class definition, 'isinstance' has > nothing to compare to because the class does not appear to exist. > > This is NOT a great example, but it outlines the the code: > > class RecipieClass: > def __init__(self): > pass > @classmethod > def get_ingrendients(self, recipie_list=None): > if isinstnace(self,RecipieClass): > return self.do_something_interesting() > else: > return do_something_boring(recipie_list) > > Yes, I can test to see if the param exists, but that makes the call > exclusive i.e. I can _only_ call it as an instance or with a parameter. Then you can't use a classmethod. A class method can *only* be called on the defining class or a subclass of it, or using an instance of those classes, but in any case the first argument (usually called "cls", not "self") is the *class* on which you called it. > > Why am I doing this? > > It is a series of convenience methods, in this case I'm interacting with > a database via an ORM (object-relational model). I want the ability to > call a class-ojbect and get related values, or pass some criteria and > get related values for them without collecting the records first as > instances, then iterating them. I need to call this from several places > so I want to be DRY (don't repeat yourself). > > The easiest way to describe this as an analogy would be like having a > recipie for cookies and wanting to know all of the ingredients ahead of > time. Then, at another time, wanting to know what all the ingredients > would be to make cookies, cake and bread (i.e. complete shopping list). > cookie_recipie = RecipieClass.get_recipie('cookies') > cookie_recipie.get_ingredients() > 2C Flour > 0.5 C Sugar > ... > RecipieClass.get_ingrendients(['cookies','cake','bread']) > 8C Flour > 2C Sugar > ... > > Of course any suggestions on how this might be better approached would > be interesting too. I'm not sure if I get the idea right, but it looks like two different classes to me, a Recipe and a RecipeSet: class Recipe: def __init__(self, recipe_name) """a Recipe given its name""" def get_ingredients(self) """a list of ingredients for this recipe""" class RecipeSet: def __init__(self, recipe_names): """a set of recipes considered together""" self.recipe_names = recipe_names def get_ingredients(self) """a summarized list of ingredients for all given recipes""" cookie_recipie = Recipe('cookies') cookie_recipie.get_ingredients() 2C Flour 0.5 C Sugar ... all_ingredients = RecipeSet(['cookies','cake','bread']).get_ingrendients() 8C Flour 2C Sugar ... -- Gabriel Genellina From james at reggieband.com Sun Apr 13 11:12:06 2008 From: james at reggieband.com (james at reggieband.com) Date: Sun, 13 Apr 2008 08:12:06 -0700 (PDT) Subject: Module to read input from commandline Message-ID: <2e04b64c-9a12-4e20-8d5a-546a0ec4ac7f@m36g2000hse.googlegroups.com> Hi all, I did some quick searching but I haven't found anything like I want. It probably has to do with the terms I am searching for so if I describe what I want then I hope someone can point me to a good module. I want to take input from the user at the command line. e.g.) Would you like to continue [Y/n]: y What is your favorite color: green .... You get the idea. Basic question answer stuff. It should handle default options, case insensitivity, etc. Perhaps the module would compare the inputted text against a regexp for validation. If the module had an interface similar to OptParse that would be nice. Anyone know of a decent module that handles this type of thing? Writing from scratch would be simple but why re-invent the wheel. Cheers, James. From wilson.t.thompson at gmail.com Sun Apr 27 09:42:13 2008 From: wilson.t.thompson at gmail.com (wilson) Date: Sun, 27 Apr 2008 06:42:13 -0700 (PDT) Subject: convert images Message-ID: hi i converted some P5 type .pgm images to .jpg using x=Image.open("oldimage.pgm") imsz=x.size newimg=Image.new('L',imsz) newimg.putdata(x.getdata()) newimg.save("newimg.jpg") when i again check the pixel data for these images using getdata() method i,I find that they are slightly different ie if oldimage.pgm has pixels [29 31 38 ..., 10 4 18] then the corresponding jpg image has [29 31 38 ..., 10 3 17] why this difference? shouldn't they be identical?can someone pls explain this? From jcd at sdf.lonestar.org Tue Apr 29 16:20:46 2008 From: jcd at sdf.lonestar.org (J. Cliff Dyer) Date: Tue, 29 Apr 2008 16:20:46 -0400 Subject: Colors for Rows In-Reply-To: <20080429153930.a6eddea6.darcy@druid.net> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> <20080429121105.f10c3862.darcy@druid.net> <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> <1209495803.5173.11.camel@aalcdl07.lib.unc.edu> <20080429153930.a6eddea6.darcy@druid.net> Message-ID: <1209500446.5510.4.camel@aalcdl07.lib.unc.edu> On Tue, 2008-04-29 at 15:39 -0400, D'Arcy J.M. Cain wrote: > On Tue, 29 Apr 2008 15:03:23 -0400 > "J. Cliff Dyer" wrote: > > Or, if you aren't sure how many colors you'll be using, try the more > > robust: > > > > bg[z % len(bg)] > > Good point although I would have calculated the length once at the > start rather than each time through the loop. > Good catch. Thanks. What's that they say about eyes and bugs? Cheers, Cliff From watches0802 at global-replica-watch.com Sat Apr 19 06:18:07 2008 From: watches0802 at global-replica-watch.com (watches0802 at global-replica-watch.com) Date: Sat, 19 Apr 2008 03:18:07 -0700 (PDT) Subject: Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch - Replica Watch Fake Message-ID: <89bacae3-0280-424e-8ab5-5d1cd914e963@a5g2000prg.googlegroups.com> Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch - Replica Watch Fake Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch Link : http://www.watchesprice.net/Replica-Bulova-2208.html Replica Watches Home : http://www.watchesprice.net/ Replica Bulova Brands : http://www.watchesprice.net/Bulova-Replica.html Replica Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch --- one of best selling replica watches, it is crafted in high quality, please click image 'buy now' to buy this chic but inexpensive replica to save you a lot of money . Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch Description: no Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch Details: Brand: Bulova Band material: stainless-steel Bezel material: stainless-steel Case material: stainless-steel Clasp type: deployment-buckle Dial color: mother-of-pearl Dial window material: anti-reflective-sapphire Movement type: Quartz Water-resistant to 330 feet Thank you for choosing www.watchesprice.net as your reliable dealer of quality waches including Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch . we guarantee every watch you receive will be exact watch you ordered. Each watch sold enjoy one year Warranty for free repair. Every order from aaa- replica-watches is shipped via EMS, the customer is responsible for the shipping fee on the first order, but since the second watch you buy from our site, the shipping cost is free. Please note that If the total amount of payment is over $600(USD), the customer is required to contact our customer service before sending the money in case failed payment. If you have any other questions please check our other pages or feel free to email us by service at watchesprice.net. Cheapest Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch The Same Bulova Series : Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch : http://www.watchesprice.net/Replica-Bulova-2209.html Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Bezel Women's Watch : http://www.watchesprice.net/Replica-Bulova-2210.html Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Markers Diamond Bezel Women's Watch : http://www.watchesprice.net/Replica-Bulova-2211.html Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Markers Diamond Bezel Women's Watch : http://www.watchesprice.net/Replica-Bulova-2212.html Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Markers Diamond Bezel Women's Watch : http://www.watchesprice.net/Replica-Bulova-2213.html Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Markers Rotating Bezel Women's Watch : http://www.watchesprice.net/Replica-Bulova-2214.html Bulova Watches, Bulova Ladies' Sport Marine Star Mother of Pearl Dial Diamond Markers Women's Watch : http://www.watchesprice.net/Replica-Bulova-2215.html Bulova Watches, Bulova Ladies' Sport Marine Star Silver, Pink and Blue Interchangebale Bezel 35 Diamonds Women's Watch : http://www.watchesprice.net/Replica-Bulova-2216.html Bulova Watches, Bulova Ladies' Sport Marine Star Two Tone Steel and Gold Diamond Bezel Women's Watch : http://www.watchesprice.net/Replica-Bulova-2217.html Bulova Watches, Bulova Ladies' Sport Marine Star Two Tone Steel and Rose Gold Diamond Bezel Mother of Pearl Dial Women's Watch : http://www.watchesprice.net/Replica-Bulova-2218.html Bulova Watches, Bulova Latest Edition in Stainless Steel or Two Tone with or without Diamond Bezel Women's Watch : http://www.watchesprice.net/Replica-Bulova-2219.html Bulova Watches- Bulova Ladies' Bracelet Two Tone Steel and Gold Women's Watch : http://www.watchesprice.net/Replica-Bulova-2220.html From corvettecraz92 at gmail.com Tue Apr 8 22:14:26 2008 From: corvettecraz92 at gmail.com (corvettecraz92 at gmail.com) Date: Tue, 8 Apr 2008 19:14:26 -0700 (PDT) Subject: text adventure game problem References: <6e247b5c-a58d-4e4e-a67a-c21d36061cf0@z38g2000hsc.googlegroups.com> <20bb5b82-9cf2-4983-b9d0-b50c718a6b85@k10g2000prm.googlegroups.com> Message-ID: On Apr 8, 9:55?pm, Andr? wrote: > On Apr 8, 10:44?pm, corvettecra... at gmail.com wrote: > > > > > On Apr 8, 9:25?pm, Andr? wrote: > > > > On Apr 8, 10:01?pm, corvettecra... at gmail.com wrote: > > > > > okay, I'm having this one problem with a text adventure game. It's > > > > kind of hard to explain, but I'll do my best. > > > > [code] > > > > > def prompt_kitchen(): > > > > ? ? global gold > > > > ? ? gold_taken = False > > > > ? ? while True: > > > > ? ? ? ? prompt_kit = raw_input('>') > > > > ? ? ? ? if prompt_kit == 'examine cabinet 1' and not gold_taken: > > > > ? ? ? ? ? ? print '''This cabinet has a lot of cups in it with all > > > > different > > > > designs and shapes. Where are the people anyway? How come there's > > > > nobody here? > > > > In one of the cups you find 8 gold.''' > > > > ? ? ? ? ? ? gold = gold+8 > > > > ? ? ? ? ? ? gold_taken = True > > > > ? ? ? ? ? ? pass4() > > > > ? ? ? ? elif prompt_kit == 'examine cabinet 1' and gold_taken: > > > > ? ? ? ? ? ? print \ > > > > ? ? ? ? ? ? ? ? ? '''This cabinet has a lot of cups in it with all > > > > different > > > > designs and shapes. Where are the people anyway? How come there's > > > > nobody here?''' > > > > ? ? ? ? ? ? pass4() > > > > > def pass4(): > > > > ? ? global gold > > > > ? ? print 'You have', gold, 'gold' > > > > ? ? pass > > > > [/code] > > > > > Okay, now for my problem. > > > > In the above function, there's the option to examine a cabinet and get > > > > 8 gold. (everyone here knows that...but I'm just trying to state my > > > > problem...) > > > > Unfortunately, it kind of doesn't work. > > > > After the first time I 'examine cabinet 1' in my game, I get 8 gold > > > > and I can't get it again. > > > > But, If I leave the room and come back to it, then it's as if I had > > > > never gotten the gold the first time, and I can get it again. > > > > How do I fix this? > > > > quick guess: define gold_taken as a global variable and initialize it > > > outside of the function. > > > > Warning: avoid global variables if at all possible. > > > > ;-) > > > Andr? > > > Here's a sample code that, in fact, does work. In this code, when run, > > I can only get the gold once. > > > def prompt_house(): > > ? ? global gold > > ? ? gold_taken = False > > ? ? while True: > > ? ? ? ? prompt_hou = raw_input('>') > > ? ? ? ? if prompt_hou == 'examine table' and not gold_taken: > > ? ? ? ? ? ? print \ > > ? ? ? ? ? ? ? ? ? '''There are a lot of car magazines here. > > You flip through them and find 5 gold. > > ''' > > ? ? ? ? ? ? gold = gold+5 > > ? ? ? ? ? ? gold_taken = True > > ? ? ? ? elif prompt_hou == 'go west': > > ? ? ? ? ? ? # this gets you out of the loop > > The above comment is wrong. > > > ? ? ? ? ? ? go_west() > > ? ? ? ? ? ? # more elif choices here ... > > ? ? ? ? elif prompt_hou == 'examine table' and gold_taken: > > ? ? ? ? ? ? print '''There are a lot of car magazines here.''' > > ? ? ? ? ? ? go_west() > > def go_west(): > > # just a dummy funk > > ? ? global gold > > ? ? print gold > > ? ? pass > > The "pass" statement is redundant. > > > ? ? ? ? ? ? ? ? # test > > gold = 0 > > prompt_house() > > > But what's the difference between this and the one that I posted? > > It is hard to say as you are not posting the entire code. ?As I > indicated above, you wrote a comment indicating that a given choice > was taking you out of the loop - which could only happen through a > break statement. ?You may want to post a ("small") code sample that > can be run by itself and reproduces the problem behaviour you > observe. ?The sample you posted include infinite loops with no way to > get out, so your original claim that you could leave the room and come > back is highly suspicious ;-) > > Andr? Here ya go...this is an excerpt from my main code, with an example room added on. gold = 0 def kitchen(): print 'you have', gold, 'gold' print '''You are in the kitchen of the house. There is a lot of cooking equipment here, along with 3 cabinets, a food pantry, and a drawer. At the far end of the room is an icebox and a stove. To the south there is a living room, and to the east is a den.''' print prompt_kitchen() def prompt_kitchen(): global gold gold_taken = False while True: prompt_kit = raw_input('>') if prompt_kit == 'examine cabinet 1' and not gold_taken: print '''This cabinet has a lot of cups in it with all different designs and shapes. Where are the people anyway? How come there's nobody here? In one of the cups you find 8 gold.''' gold = gold+8 gold_taken = True pass4() elif prompt_kit == 'examine cabinet 1' and gold_taken: print \ '''This cabinet has a lot of cups in it with all different designs and shapes. Where are the people anyway? How come there's nobody here?''' pass4() elif prompt_kit == 'south': extra_room() def extra_room(): print 'you have', gold, 'gold' print 'This is a dead end room. Go north.' kitchen() def pass4(): global gold print 'You have', gold, 'gold' pass kitchen() From skanemupp at yahoo.se Sun Apr 6 15:59:48 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 6 Apr 2008 12:59:48 -0700 (PDT) Subject: Tkinter, a lot of buttons, make prog shorter? Message-ID: is there anyway to make this shorter? i hate having these big blocks of similar-looking code, very unaesthetic. maybe doesnt matter good-code-wise? anyway can i make some function that makes this shorter? like put the etiquettes on the button froma string of '123+456-789*0Cr/' ? problem is the command and lambda-func for each button is different. self.btnDisplay = Button(self,text='1',command=lambda n="1":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=3, column=0) self.btnDisplay = Button(self,text='2',command=lambda n="2":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=3, column=1) self.btnDisplay = Button(self,text='3',command=lambda n="3":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=3, column=2) self.btnDisplay = Button(self,text='+',command=lambda n="+":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=3, column=3) self.btnDisplay = Button(self,text='4',command=lambda n="4":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=4, column=0) self.btnDisplay = Button(self,text='5',command=lambda n="5":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=4, column=1) self.btnDisplay = Button(self,text='6',command=lambda n="6":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=4, column=2) self.btnDisplay = Button(self,text='-',command=lambda n="-":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=4, column=3) self.btnDisplay = Button(self,text='7',command=lambda n="7":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=5, column=0) self.btnDisplay = Button(self,text='8',command=lambda n="8":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=5, column=1) self.btnDisplay = Button(self,text='9',command=lambda n="9":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=5, column=2) self.btnDisplay = Button(self,text='*',command=lambda n="*":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=5, column=3) self.btnDisplay = Button(self,text='0',command=lambda n="0":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=6, column=0) self.btnDisplay = Button(self,text='C',command=self.Clean,width=2,height=2) self.btnDisplay.grid(row=6, column=1) self.btnDisplay = Button(self,text='r',command=lambda n="r":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=6, column=2) self.btnDisplay = Button(self,text='/',command=lambda n="/":self.Display(n),width=2,height=2) self.btnDisplay.grid(row=6, column=3) From roy at panix.com Sat Apr 5 22:23:27 2008 From: roy at panix.com (Roy Smith) Date: Sat, 05 Apr 2008 22:23:27 -0400 Subject: Best way to check if string is an integer? References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> Message-ID: In article , Steve Holden wrote: > > This doesn't cater for negative integers. > > > No, it doesn't, but > > s.isdigit() or (s[0] in "+-" and s[1:].isdigit) # untested > > does. I think this fails on " -1". So, then you start doing s.strip().isdigit(), and then somebody else comes up with some other unexpected corner case... int(s) and catching any exception thrown just sounds like the best way. From martin at v.loewis.de Mon Apr 28 18:29:08 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 29 Apr 2008 00:29:08 +0200 Subject: py3k concerns. An example In-Reply-To: References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> <48118719$0$25846$9b622d9e@news.freenet.de> <481525DE.9060208@v.loewis.de> Message-ID: <48164FB4.3000204@v.loewis.de> > Unless I mix my psuedodicts with standard dicts > in the same list, for example, or pass them to > functions intended to accept any dict-like object, > including the especially important case of standard > dicts. > > Who knows? Maybe I'm wrong about this being a much of > problem. I think so. I expect that in the typical application, you either won't notice the difference in behavior at all, or you get an exception the first time, in which case you can easily adjust the code to support both cases. This expectation is supported by experience both from adjusting the Python standard library itself, and from converting Django to Python 3. In my experience (from the same applications), by far the most significant change in Python 3 is the change to the meaning of string literals, and the disposal of the 2.x str type. Regards, Martin From roy at panix.com Wed Apr 9 09:50:53 2008 From: roy at panix.com (Roy Smith) Date: Wed, 09 Apr 2008 09:50:53 -0400 Subject: I am worried about Python 3 References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> <663r0mF2iji99U1@mid.uni-berlin.de> Message-ID: In article <663r0mF2iji99U1 at mid.uni-berlin.de>, Marc 'BlackJack' Rintsch wrote: > There will be a `2to3.py` program coming with Python??2.6 that tries to > convert most changes automatically. You may have to change the 2.6 code > in a way that makes the automatic conversion possible but it is a > important goal for the Python developers to make the transition as smooth > as possible as far as I can tell. People who have been using good software engineering practices like writing lots of automated tests, will have some confidence that the conversion went well. People who haven't written any tests will probably be afraid of any big changes to the environment (and rightfully so). But, to answer the OP's question, to wit, "If I continue in Python 2.5.x, am I making a mistake?", I would say not. For somebody learning a new language, what you seek is stability. You want everything to be well documented, and to work as documented. You want a large community of people who already know what you are learning, and are able to help. Likewise, you want a good selection of books to provide tutorial and reference help. And a good set of well-tested tools and add-on modules. You'll get all those from Python 2.5. If you go with 3.0, you'll be on the bleeding edge. My advice is to stay with what's stable today and come back and look at 3.0 in a year or so when you know what you're doing better, and the ecosystem has caught up with code. And, write those automated tests, so when the time does come to switch, you can do so with confidence :-) From castironpi at gmail.com Wed Apr 23 16:57:59 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 23 Apr 2008 13:57:59 -0700 (PDT) Subject: Python development tools References: <09992de9-39fa-4ee6-8009-35732f3433fb@y21g2000hsf.googlegroups.com> <87fxtcnvj7.fsf@physik.rwth-aachen.de> Message-ID: <5e606054-901a-464a-bc77-7aadd4637d33@b64g2000hsa.googlegroups.com> On Apr 23, 3:52?pm, Torsten Bronger wrote: > Hall?chen! > > bruno.desthuilli... at gmail.com writes: > > On 23 avr, 19:39, "wongjoek... at yahoo.com" > > wrote: > > >> Are there any completely free developent tools for python scripts > >> like IDLE. I have used IDLE , but I want to try out others > >> also. I saw stuff like PyCrust, but I don't see that it can run > >> the script as well. > > > emacs + python-mode (the one from Python, not the horror that > > ships with recent emacs versions) > > What's so bad about it? > > I just installed python-mode (is this the one with the "py-" > prefixes?), and it ends multi-line strings at single quotes. ?That's > bad. > > Tsch?, > Torsten. > > -- > Torsten Bronger, aquisgrana, europa vetus > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Jabber ID: bron... at jabber.org > ? ? ? ? ? ? ? ?(Seehttp://ime.webhop.orgfor further contact info.) Did you guys see PyPE editor? It just come out. From kj7ny at nakore.com Sun Apr 6 05:05:47 2008 From: kj7ny at nakore.com (kj7ny) Date: Sun, 6 Apr 2008 02:05:47 -0700 (PDT) Subject: Self in Interactive Interpreter References: Message-ID: <22a3ca84-242c-48de-b55c-d402d91ac280@b5g2000pri.googlegroups.com> On Apr 4, 1:41 pm, Fredrik Lundh wrote: > kj7nywrote: > > For years it has been a slight annoyance that every time I wanted to > > test a snippet of code from a class by running it in the interactive > > interpreter, I had to remove all of the self. instances from the > > code. After I got it working correctly, I had to put all the self.'s > > back into the code to put it back into my class. > > wouldn't it be a lot easier to test your code by importing the module > containing it into the interactive interpreter? > > >>>> class dummy: > >>>> def __init__(self): > >>>> pass > > or, shorter: > > >>> class dummy: pass > > Didn't know about the >>> class dummy: pass option. It makes sense now that I see it. Just hadn't ever tried it, I guess. Thanks! With some of my larger applications, it doesn't seem to work well to try to run the whole thing in the interpreter. At least for me, I am not a big IDE sort of programmer. I am much more comfortable in vim and command line stuff. I suppose I should use the IDE more. I wasn't offering this "tip" as a cure all. It was just an observation should it be of use to someone out there. However, I greatly appreciate your improvement on the example I gave. I will use your class dummy: pass approach from now on. Thanks, From __peter__ at web.de Wed Apr 30 10:57:10 2008 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Apr 2008 16:57:10 +0200 Subject: I messed up my wxPython install (Eclipse Configuration Issue) References: <18eb0a7c-96f4-41de-b44f-95fd8ba0223f@f63g2000hsf.googlegroups.com> Message-ID: blaine wrote: > The wxPython group is a bit stale compared to this group, so I'll give > it a shot :) > > (READ: Originally when I started htis post, Python 2.5 at the shell > did not work (identical behavior to eclipse). I'm not sure why, but > it has since worked fine with no problems. Not sure whats going on > there... I didn't change anything. Anyways...) > > Ok so I am having this problem. I am using OS X 10.4. I use > MacPython and installed wxPython a few months back, and it worked > great. Well I haven't done any wx development lately, and now that > I'm getting back into it I can't get wx to work properly. I'm using > Eclipse, too. > > Python 2.5 at Shell: works just fine > $ python >>>> import wx > > OLD projects in Eclipse: import wx works fine > NEW projects in Eclipse (since I have started working wx again after a > few months): > import wx > /Users/frikk/Documents/workspace/Bili_UI/src/wx.py:3: Rename your script wx.py to something that doesn't clash with the installed modules, e.g. my_wx.py. And don't forget to remove /Users/frikk/Documents/workspace/Bili_UI/src/wx.pyc # note the .pyc suffix too. Peter > DeprecationWarning: The wxPython compatibility package is no longer > automatically generated or actively maintained. Please switch to the > wx package as soon as possible. > from wxPython.wx import * > Traceback (most recent call last): > File "/Users/frikk/Documents/workspace/Bili_UI/src/nokia_fkscrn.py", > line 37, in > import wx > File "/Users/frikk/Documents/workspace/Bili_UI/src/wx.py", line 3, > in > from wxPython.wx import * > File "//Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/wx-2.8-mac-ansi/wxPython/__init__.py", line > 15, in > import _wx > File "//Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/wx-2.8-mac-ansi/wxPython/_wx.py", line 3, in > > from _core import * > File "//Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages/wx-2.8-mac-ansi/wxPython/_core.py", line 15, > in > import wx._core > ImportError: No module named _core > > I feel like this may be a path issue? Any ideas on what else to look > for? Both sys.path statements are the same, and I'm not sure what else > I could be causing it - some configuration perhaps in Eclipse that is > not being set correctly for newer projects? I also choose 'Python 2.5' > from in eclipse - and it points to the same location for both > projects.. Path: >>>> import sys >>>> sys.path > > ['', '/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ > site-packages/setuptools-0.6c8-py2.5.egg', '/Library/Frameworks/ > Python.framework/Versions/2.5/lib/python2.5/site-packages/ > Pygments-0.9- > py2.5.egg', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python25.zip', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/plat-darwin', '/Library/Frameworks/Python.framework/ > Versions/ > 2.5/lib/python2.5/plat-mac', '/Library/Frameworks/Python.framework/ > Versions/2.5/lib/python2.5/plat-mac/lib-scriptpackages', '/Library/ > Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk', '/ > Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib- > dynload', '/Library/Frameworks/Python.framework/Versions/2.5/lib/ > python2.5/site-packages', '/Library/Frameworks/Python.framework/ > Versions/2.5/lib/python2.5/site-packages/wx-2.8-mac-ansi'] > > Any suggestions would be great - its probably something pretty > minor... Thanks! > > Blaine From aaron.watters at gmail.com Wed Apr 16 13:12:35 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 16 Apr 2008 10:12:35 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> Message-ID: > Since you don't care about any of the changes or features, and you > don't care if your users care, I'm not sure why you aren't just using > python 2.1. It's not like it's being erased via time machine. "Just > keep using the old thing" is a perfectly valid and extremely common > futureproofing scenario. Well for one thing newer versions of python are faster and they come installed on other peoples linux and mac boxes. If I were only interested in the box sitting in front of me it sure would be a lot simpler. In reality even in a simple environment I have to support 2.3 running on a 32 bit platform and 2.4 running on a 64 bit platform with the same code. This is more of a pain than it should be. Don't get me wrong. I like things like generators that actually are useful (and amazingly fast also, I must say). I'd also love to be able to use stackless which would be even cooler but I can't because no-one else uses it to a first order approximation and I don't want to be responsible for installing it all over the place... I'm interested in developing software for/getting software from the python environment, ecosystem and community. In the short term I foresee everything bifurcating into two separate code bases, and I think that's a shame, and I don't really see the need. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=nightmare From danb_83 at yahoo.com Sat Apr 12 15:30:08 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Sat, 12 Apr 2008 12:30:08 -0700 (PDT) Subject: Recommended "from __future__ import" options for Python 2.5.2? References: Message-ID: <2c97adca-7f34-4ffb-bc8d-858ccf9d0917@w4g2000prd.googlegroups.com> On Apr 12, 1:41 pm, "Malcolm Greene" wrote: > Is there any consensus on what "from __future__ import" options > developers should be using in their Python 2.5.2 applications? > > Is there a consolidated list of "from __future__ import" options to > choose from? Just look inside the __future__ module. * nested_scopes * generators Already mandatory features. You don't need to import them. * with_statement Import this one if you're using the feature. And for forward compatibility, don't use "with" as a variable name. * absolute_import I haven't followed this one. * division ALWAYS import this in new modules. Otherwise, you'll be very likely to get burned my code as simple as def mean(seq): return sum(seq) / len(seq) From semanticist at gmail.com Wed Apr 9 00:41:27 2008 From: semanticist at gmail.com (Miles) Date: Wed, 9 Apr 2008 00:41:27 -0400 Subject: style question - hasattr In-Reply-To: References: Message-ID: On Tue, Apr 8, 2008 at 10:21 PM, ian wrote: > Ok, so what about 'hasattr' ?? > hasattr(myObject,'property') > seems equivalent to > 'property' in dir(myObject) > > I would suggest that using the 'in' is cleaner in this case also. Is > there a performance penalty here? Or is there reason why the two are > not actually the same? >>> class HasAll(object): ... def __getattr__(self, name): pass ... >>> hasattr(HasAll(), 'spam') True >>> 'spam' in dir(HasAll()) False >From the docs: "Because dir() is supplied primarily as a convenience for use at an interactive prompt, it tries to supply an interesting set of names more than it tries to supply a rigorously or consistently defined set of names, and its detailed behavior may change across releases. ... [hasattr] is implemented by calling getattr(object, name) and seeing whether it raises an exception or not." http://docs.python.org/lib/built-in-funcs.html > Which style is preferred?? Don't test for the existence of the attribute if you're going to get it when it exists; just go ahead and get it. try: x = myObject.property except AttributeError: x = None - Miles From meisnernel73884 at gmail.com Wed Apr 30 06:37:23 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:37:23 -0700 (PDT) Subject: wep key crack Message-ID: <23fa3fdc-7055-4b68-ad41-ad7d66e1d964@r66g2000hsg.googlegroups.com> wep key crack http://crack.cracksofts.com From hdante at gmail.com Fri Apr 11 16:44:15 2008 From: hdante at gmail.com (hdante) Date: Fri, 11 Apr 2008 13:44:15 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> Message-ID: <01db54ab-1fca-4a51-8b98-510de224f40a@y21g2000hsf.googlegroups.com> On Apr 11, 3:33 pm, Lie wrote: > > That old-school rounding method you're taught is based on a wrong > assumption of the nature of number. In the past, rounding algorithm is > based on this: > > Original => (RoundUp(u|d|n), RoundNearestEven(u|d|n) > ... > 1.0 => 1(n), 1(n) > 1.1 => 1(d), 1(d) > 1.2 => 1(d), 1(d) > 1.3 => 1(d), 1(d) > 1.4 => 1(d), 1(d) > 1.5 => 2(u), 2(u) > 1.6 => 2(u), 2(u) > 1.7 => 2(u), 2(u) > 1.8 => 2(u), 2(u) > 1.9 => 2(u), 2(u) > 2.0 => 2(n), 2(n) > 2.1 => 2(d), 2(d) > 2.2 => 2(d), 2(d) > 2.3 => 2(d), 2(d) > 2.4 => 2(d), 2(d) > 2.5 => 3(u), 2(d) > 2.6 => 3(u), 3(u) > 2.7 => 3(u), 3(u) > 2.8 => 3(u), 3(u) > 2.9 => 3(u), 3(u) > ... > > In this used-to-be-thought-correct table, Round Ups algorithm have 2 > Unrounded, 8 Round Down, and 10 Round Ups which seems incorrect while > Round Even have 2 Unrounded, 9 Round Down, and 9 Round Up which seems > correct. The misunderstanding comes from a view that thinks that there > is such thing as Not Rounded while in fact the only number that is Not > Rounded is 1 and 2 while 1.0 and 2.0 must still be rounded, in > practice we can just say that all number must be rounded somewhere. > > Original => (RoundUp(u|d), RoundNearestEven(u|d) > ... > 1.0 => 1(d), 1(d) > 1.1 => 1(d), 1(d) > 1.2 => 1(d), 1(d) > 1.3 => 1(d), 1(d) > 1.4 => 1(d), 1(d) > 1.5 => 2(u), 2(u) > 1.6 => 2(u), 2(u) > 1.7 => 2(u), 2(u) > 1.8 => 2(u), 2(u) > 1.9 => 2(u), 2(u) > 2.0 => 2(d), 2(d) > 2.1 => 2(d), 2(d) > 2.2 => 2(d), 2(d) > 2.3 => 2(d), 2(d) > 2.4 => 2(d), 2(d) > 2.5 => 3(u), 2(d) > 2.6 => 3(u), 3(u) > 2.7 => 3(u), 3(u) > 2.8 => 3(u), 3(u) > 2.9 => 3(u), 3(u) > ... > > In this table, we consider that a number is rounded down when the But then, the "Round up" table gives inconsistent results if, by the same argument, we consider 2.0 -> 2 rounding up. (you get 12 round ups and 8 round downs just by "rethinking" the argument). So, "rounding up" is, at the same time, better and worse than rounding to nearest even. > > Another side-note: My 12-year old son is now being taught to always > > round up from mid-way between. Yet another example of the degradation of > > maths in schools. > > A false assertion from a false understanding. The use of Round Up > algorithm is a refinement of the false understanding we used to > practice in the past. The assertion is false, because there's no problem in rounding up, truncating, etc. Just consider the amount of code snippets in this thread. A simpler solution may solve a lot of problems. From joeblow at nowhere.nohow Wed Apr 16 20:24:20 2008 From: joeblow at nowhere.nohow (Joe Blow) Date: 17 Apr 2008 00:24:20 GMT Subject: TypeNone field detection Message-ID: <480698b3$0$31577$ec3e2dad@news.usenetmonster.com> What is the best way to detect a TypeNone field in a tuple, or in a list? I am accessing a MySQL database using the MySQLdb Python interface... this interface returns a tuple object type in response to SQL SELECT statements. My understanding of the MySQLdb interface is that NULL database values are returned as a Python 'None' object. Because I need to create some work fields based on the contents of the database I am doing so by copying the tuple to a list object and then calculating these work fields as needed. My problem is that I need to be able to detect the Python 'None' objects and convert them to an integer zero value field to enable my calculations to work. I'm new to Python so I'm sure I'm overlooking something simple ? but what is the easiest way to do a logical test for the existence of a TypeNone field? From robert.kern at gmail.com Fri Apr 4 16:01:08 2008 From: robert.kern at gmail.com (Robert Kern) Date: Fri, 04 Apr 2008 15:01:08 -0500 Subject: Any fancy grep utility replacements out there? In-Reply-To: <2a1695f7-5e1a-46f3-9c69-76a930e5dd10@e39g2000hsf.googlegroups.com> References: <2a1695f7-5e1a-46f3-9c69-76a930e5dd10@e39g2000hsf.googlegroups.com> Message-ID: Floris Bruynooghe wrote: > I tried to find something similar a while ago and found ack[1]. I do > realise it's written in perl but it does the job nicely. Never needed > to search in zipfiles though, just unzipping them in /tmp would always > work... Yup, I used ack for a little while before writing grin. Unfortunately, I got hooked on context lines and these were unimplemented in ack. -- 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 From gagsl-py2 at yahoo.com.ar Mon Apr 14 04:11:50 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 14 Apr 2008 05:11:50 -0300 Subject: =?utf-8?B?562U5aSNOiBob3cgdG8gcmVtb3ZlIFxuIGluIHRoZSBsaXN0?= References: <20080414070819.D4CA335E6A5@mail-in-06.arcor-online.net> Message-ID: En Mon, 14 Apr 2008 04:08:06 -0300, Penny Y. escribi?: >> lines[:] = [line.rstrip('\n') for line in lines] > > why not just: > > lines = [line.rstrip('\n') for line in lines] > > > what's the difference between lines[:] and lines here? Thanks. My version (using [:]) replaces the *contents* of the original list, but the list itself remains the same object. Yours (without the [:]) reasigns a new list to the old name; the *contents* are the same as the former version, but now the name "lines" refers to a different list. Depending on the context, the difference may be important or not. -- Gabriel Genellina From steve at holdenweb.com Sun Apr 20 10:06:41 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 20 Apr 2008 10:06:41 -0400 Subject: Another MySQL Images Question In-Reply-To: References: <4dc0cfea0804180813o32ed2c82o9c3f68b1a607348d@mail.gmail.com> Message-ID: Dennis Lee Bieber wrote: > On Sat, 19 Apr 2008 03:46:54 +0200, Karl-Heinz Ruskowski > declaimed the following in comp.lang.python: > >> Hi, >> >>> cursor.execute('update products set pic1="%s" where id="%s", ;', >>> (pic1, id)) >> Shouldn't it be something like >> cursor.execute('update products set pic1="%s" where id="%s", ;' % (pic1, id)) > > It should be NEITHER... > > The latter is relying on Python to fill in the parameters. The > former is relying (preferred) for the DB-API adapter to correctly format > the parameters (It is a coincidence that MySQLdb internally uses Python > % formatting, so the place holders are %s, where others use ?) > > To be fully compliant it should be > > cursor.execute("update products set pic1=%s where id=%s", > (pic1, id)) > > NOTE: no trailing , > no trailing ; > no embedded " -- the DB-API spec is that IT will properly > supply whatever quotes or escapes are needed to ensure the data > fits the syntax. This is also why most will not function if one tries to > make the table or field names parameters -- the DB-API will quote them > too, and > > update "products" set "pic1" = "something" > > is much different from > > update products set pic1="something" > Many versions of SQL do actually allow you to quote table names, allowing names with otherwise illegal characters like spaces in them. Double-quotes are typically used for such quoting (though Microsoft, to be different, tends to use brackets). Single-quotes should be used for string literals, although certain sloppy implementations of SQL do also allow double-quotes. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From wbsoft at xs4all.nl Sat Apr 12 15:41:59 2008 From: wbsoft at xs4all.nl (Wilbert Berendsen) Date: Sat, 12 Apr 2008 21:41:59 +0200 Subject: pty.spawn directs stderr to stdout In-Reply-To: References: Message-ID: <200804122142.00091.wbsoft@xs4all.nl> Op vrijdag 11 april 2008, schreef Donn Cave: > More likely, you want the spawned process' error output to go wherever > the parent's error output was going. ?This is a little trickier. I ended up writing a small script that basically reimplements fork() from the pty module, where then STDERR is not dup'ed to the pty. I'm currently trying to combine subprocess.Popen with pty.openpty ... tx, Wilbert Berendsen -- http://www.wilbertberendsen.nl/ "You must be the change you wish to see in the world." -- Mahatma Gandhi From mccredie at gmail.com Tue Apr 15 13:46:03 2008 From: mccredie at gmail.com (Matimus) Date: Tue, 15 Apr 2008 10:46:03 -0700 (PDT) Subject: Preferred method for "Assignment by value" References: Message-ID: <6a3ed8f0-b82c-4cd3-b36e-1d94f8a30fe3@n1g2000prb.googlegroups.com> On Apr 15, 10:23 am, hall.j... at gmail.com wrote: > As a relative new comer to Python, I haven't done a heck of a lot of > hacking around with it. I had my first run in with Python's quirky (to > me at least) tendency to assign by reference rather than by value (I'm > coming from a VBA world so that's the terminology I'm using). I was > surprised that these two cases behave so differently > > test = [[1],[2]] > x = test[0] > x[0] = 5 > test>>> [[5],[2]] > > x = 1 > test > > >>>[[5],[2]] > x > >>> 1 > > Now I've done a little reading and I think I understand the problem... > My issue is, "What's the 'best practise' way of assigning just the > value of something to a new name?" > > i.e. > test = [[1,2],[3,4]] > I need to do some data manipulation with the first list in the above > list without changing > obviously x = test[0] will not work as any changes i make will alter > the original... > I found that I could do this: > x = [] + test[0] > > that gets me a "pure" (i.e. unconnected to test[0] ) list but that > concerned me as a bit kludgy > > Thanks for you time and help. I think you understand the concept, basically you want to make a copy. Ether of these are acceptable: x = test[0][:] OR x = list(test[0]) this will also work: import copy x = copy(test[0]) Matt From aldo at nullcube.com Sun Apr 6 22:34:42 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Mon, 7 Apr 2008 12:34:42 +1000 Subject: ANN: pry unit testing framework In-Reply-To: <87prt2mq8l.fsf@benfinney.id.au> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> Message-ID: <20080407023442.GA16373@nullcube.com> Thus spake Ben Finney (bignose+hates-spam at benfinney.id.au): > > I'm afraid that Pry is unashamedly incompatible with any other unit > > testing method in existence, including but not limited to doctest, > > unittest, nose and py.test. ;) > > Which makes the deliberate deviations from PEP 8 naming a large black > mark against it. You're misunderstanding the intent of PEP 8, which was never supposed to dogmatically enforce a naming standard on all Python projects everywhere. You're also vastly overstating the impact of a minor naming convention choice. Calling this a "large black mark" smacks of scare-mongering to me. > > Some day I might experiment with extending Pry to gather and run > > doctests and unittests. At this stage, however, I don't believe the > > (significant) effort would be worth it. > > That's very unfortunate. Until it plays better with others, I don't > believe the effort of using this package will be worth it. Each of the third-party testing frameworks that have cropped up in this thread extends unittest in some incompatible way. If you use any of these extensions, it means that your unit test suite is tied to that particular test framework. If you have an existing suite of unit tests that you can't or don't want to convert, I'm afraid that Pry is indeed not for you. Pry is not intended to be a general engine for running tests written for other frameworks. I should also note that converting from unittest to Pry is quite simple - Pry's test structure is a superset of unittest's, and AutoTree was explicitly written to make "unittest-style" testing possible, meaning that no _structural_ change is needed for conversion. The most onerous part is converting to assertion-based testing, something that will improve the clarity and readability of your tests anyway. Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From martin at marcher.name Tue Apr 8 16:33:17 2008 From: martin at marcher.name (Martin Marcher) Date: Tue, 8 Apr 2008 22:33:17 +0200 Subject: Best way to check if string is an integer? In-Reply-To: <5fa6c12e0804081332r2a58d39gc44ce1ef8cb69052@mail.gmail.com> References: <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> <0fdd2825-6d1c-4380-a79a-a7aac119f002@a5g2000prg.googlegroups.com> <96d2fe53-96bf-43d8-a58d-8269846bf0df@b64g2000hsa.googlegroups.com> <2033313.fb3g3XYCIP@montana.com> <5fa6c12e0804081332r2a58d39gc44ce1ef8cb69052@mail.gmail.com> Message-ID: <5fa6c12e0804081333k377343d4sedf6adc7ff1c7183@mail.gmail.com> arg, as posted earlier: int("10.0") fails, it will of course work with float("1E+1") sorry for the noise... On Tue, Apr 8, 2008 at 10:32 PM, Martin Marcher wrote: > hmmm > > int() does miss some stuff: > > >>> 1E+1 > 10.0 > >>> int("1E+1") > Traceback (most recent call last): > File "", line 1, in > ValueError: invalid literal for int() with base 10: '1E+1' > > I wonder how you parse this? > > I honestly thought until right now int() would understand that and > wanted to show that case as ease of use, I was wrong, so how do you > actually cast this type of input to an integer? > > thanks > martin > > > -- > http://tumblr.marcher.name > https://twitter.com/MartinMarcher > http://www.xing.com/profile/Martin_Marcher > http://www.linkedin.com/in/martinmarcher > > You are not free to read this message, > by doing so, you have violated my licence > and are required to urinate publicly. Thank you. > -- http://tumblr.marcher.name https://twitter.com/MartinMarcher http://www.xing.com/profile/Martin_Marcher http://www.linkedin.com/in/martinmarcher You are not free to read this message, by doing so, you have violated my licence and are required to urinate publicly. Thank you. From m.moghimi at gmail.com Mon Apr 14 05:16:27 2008 From: m.moghimi at gmail.com (m.moghimi) Date: Mon, 14 Apr 2008 02:16:27 -0700 (PDT) Subject: Python Workshop Message-ID: Hi, We are to hold a workshop about python (introduction). It will be two one hour and half sessions. I wanted to know which subjects do you suggest to be presented and is there a good presentation file (powerpoint or ...) about this on the net. We thought that it may be good that first session covers the introduction, zen of python, python coding syntax and the second session will be about application, libraries or so. I really appreciate if you tell me your ideas? From ivan_chernetsky at tutby.by Thu Apr 3 11:39:51 2008 From: ivan_chernetsky at tutby.by (Ivan Chernetsky) Date: Thu, 3 Apr 2008 17:39:51 +0200 (CEST) Subject: PyXMPP and GTalk Message-ID: Hello! Here is the example from PyXMPP package: http://pyxmpp.jajcus.net/trac/browser/trunk/examples/echobot.py And here is output: From s0suk3 at gmail.com Thu Apr 17 10:59:51 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 07:59:51 -0700 (PDT) Subject: Can't do a multiline assignment! Message-ID: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> I was shocked a while ago when a discovered that in Python you can't do a multiline assignment with comments between the lines. For example, let's say I want to assign a bunch of variables to an initial, single value. In C or a similar language you would do: CONSTANT1 = /* This is some constant */ CONSTANT2 = CONSTANT3 = /*This is yet some other constant */ CONSTANT = 1; In Python, you usually can use parentheses to split something over several lines. But you can't use parentheses for an assignment of several lines. For that, you can use the line continuation character ('\'): CONSTANT1 = \ CONSTANT2 = \ CONSTANT3 = \ 1 But I realized that you can't do this: CONSTANT1 = \ # Oops... syntax error CONSTANT2 = \ CONSTANT3 = \ # This is also a syntax error # And this too \ 1 Does anyone know of a way to put the comments between lines like that? I find this limitation very annoying. From fiacre.patrick at gmail.com Thu Apr 17 11:53:55 2008 From: fiacre.patrick at gmail.com (Andrew Lee) Date: Thu, 17 Apr 2008 11:53:55 -0400 Subject: Can't do a multiline assignment! In-Reply-To: References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> Message-ID: <4807723a$0$15206$607ed4bc@cv.net> s0suk3 at gmail.com wrote: >> Yuck! No way!! If you *want* to make your code that hard to read, I'm >> sure you can find lots of ways to do so, even in Python, but don't >> expect Python to change to help you toward such a dubious goal. >> > > Well, my actual code doesn't look like that. Trust me, I like clean > code. > >> Seriously, examine your motivations for wanting such a syntax. Does it >> make the code more readable? (Absolutely not.) Does it make it more >> maintainable. (Certainly not -- consider it you needed to change >> CONSTANT2 to a different value some time in the future.) > Use a dictionary? > Yes, it makes it more readable. And yes, it does make it (a lot) more > maintainable. Mainly because I don't have those four variables, I have > about thirty. And I think I won't need to one or two of them, but > maybe all of them at once. From zedshaw at zedshaw.com Wed Apr 16 05:43:54 2008 From: zedshaw at zedshaw.com (Zed A. Shaw) Date: Wed, 16 Apr 2008 05:43:54 -0400 Subject: [ANN] Vellum 0.13: Simple Python Build Tool (usable now) Message-ID: <20080416054354.8260fbe1.zedshaw@zedshaw.com> Hello Everyone, Insomnia has blessed me with the ability to make another release of Vellum for all to play with and try using. Features in this release: * The ability to make your own commands for your build specs in plain old Python as a Python module. * The docstring comments on your vellum commands become dynamic documentation for vellum via: vellum -C. * Lots of documentation, comments, cleaned up code, and a more complete test suite. * Importing other build specs as recipes and importing python modules are all unified and cleaned up. * Still only 620 lines of Python code which is damn amazing. DOCUMENTATION I wrote a bunch of documentation tonight, and will be doing a more complete manual soon: http://zedshaw.com/projects/vellum/ This page is cleaned up and lays out how to use vellum, write a build.vel file, and write your own commands. DOWNLOADS First, you should grab Zapps and install that: http://zedshaw.com/projects/zapps/ Then you can grab Vellum with easy_install: $ sudo easy_install vellum Or, get it from http://launchpad.net/vellum/ ANNOUNCMENTS You can subscribe to Vellum's RSS feed at: https://launchpad.net/vellum/+announcements FEEDBACK Let me know if you run into anything, and if you like it or hate it. Otherwise, enjoy the gear. -- Zed A. Shaw - Hate: http://savingtheinternetwithhate.com/ - Good: http://www.zedshaw.com/ - Evil: http://yearofevil.com/ From msh at blisses.org Sat Apr 19 11:11:07 2008 From: msh at blisses.org (Matt Herzog) Date: Sat, 19 Apr 2008 10:11:07 -0500 Subject: socket.AF_INET Message-ID: <20080419151107.GZ16190@chicago.blisses.org> Hi All. I'm trying to write a script that will send me an email message when my IP address changes on a specific NIC. On Linux, the script works. On FreeBSD, it fails with: Traceback (most recent call last): File "./pyifcheck.py", line 22, in if get_ip_address('xl0') == IPADDY: File "./pyifcheck.py", line 18, in get_ip_address struct.pack('256s', ifname[:15]) )[20:24]) IOError: [Errno 25] Inappropriate ioctl for device The script is below. ################################################################### SENDMAIL = "/usr/sbin/sendmail" IPADDY = "85.126.250.328" #IFCONFIG = "/sbin/ifconfig import os import smtplib import socket import fcntl import struct def get_ip_address(ifname): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa(fcntl.ioctl( s.fileno(), 0x8915, # SIOCGIFADDR struct.pack('256s', ifname[:15]) )[20:24]) #get_ip_address('xl0') if get_ip_address('xl0') == IPADDY: print "nevermind" else: p = os.popen("%s -t" % SENDMAIL, "w") p.write("To: matthew.herzog at gmail.com\n") p.write("Subject: YOUR IP ADDRESS HAS CHANGED\n") p.write("\n") # blank line separating headers from body p.write("Your IP addy has changed to $getipaddy\n") p.write("some more text\n") sts = p.close() if sts != 0: print "Sendmail exit status", sts ############################################################################## Thanks for any suggestions. -- "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too dark to read." -- Groucho Marx From aaron.watters at gmail.com Wed Apr 16 14:52:35 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 16 Apr 2008 11:52:35 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> <09a38ca2-8c49-4eee-b6cf-58e849aea1fc@q1g2000prf.googlegroups.com> Message-ID: On Apr 16, 2:33 pm, Rhamphoryncus wrote: > The point is, you can't have it both ways. Either you evolve the > language and break things, or you keep it static and nothing breaks. I disagree. You can add lots of cool stuff without breaking the existing code base, mostly. For example the minor changes to the way ints will work will effect almost no programs. I don't see the urgency to clean up what are essentially cosmetic issues and throw out or require rewrites for just about all existing Python code. Python 2.6 isn't fundamentally awful like Perl 4 was. The cost paid for these minor improvements is too high in my book. But I suppose if it is going to happen do it sooner rather than later. Just *please* *please* don't systematically break the pre-existing code base again for a very long time, preferable ever. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=whack From erikwickstrom at gmail.com Thu Apr 17 23:37:34 2008 From: erikwickstrom at gmail.com (erikcw) Date: Thu, 17 Apr 2008 20:37:34 -0700 (PDT) Subject: Database vs Data Structure? Message-ID: Hi, I'm working on a web application where each user will be creating several "projects" in there account, each with 1,000-50,000 objects. Each object will consist of a unique name, an id, and some meta data. The number of objects will grow and shrink as the user works with their project. I'm trying to decided whether to store the objects in the database (each object gets it's own row) or to use some sort of data-structure (maybe nested dictionaries or a custom class) and store the pickled data-structure in a single row in the database (then unpickle the data and query in memory). A few requirements: -Fast/scalable (web app) -able to query objects based on name and id. -will play nicely with versioning (undo/redo) Any input on the best way to go? Thanks! Erik From fredrik at pythonware.com Sat Apr 5 09:30:10 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 15:30:10 +0200 Subject: When does a binary extension gets the file extension '.pyd' and when is it '.so' In-Reply-To: <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> References: <4932ef72-2061-4e05-8f88-dece7eeeede1@s37g2000prg.googlegroups.com> <1bb0b73e-f127-485d-ba64-7e7286979335@p39g2000prm.googlegroups.com> <7d4fe5f3-fcdf-440d-a0f4-afa0e6da44bf@m1g2000pre.googlegroups.com> Message-ID: llothar wrote: > I don't think so. I asked a pretty simple question and as usual on > usenet nobody read the question did *you* read your own question? it took you three posts before you mentioned what you were trying to do, and four posts before you bothered to mention that you're seeing this behaviour on Ubuntu. and for the record, Python doesn't look for PYD files on any of the Unix boxes I have convenient access to right now. what Ubuntu version are you using, what Python version do you have, and what does $ python -c "import imp; print imp.get_suffixes()" print on your machine? From aaron.watters at gmail.com Mon Apr 28 14:37:01 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Mon, 28 Apr 2008 11:37:01 -0700 (PDT) Subject: Cookie Confusion - How to Set a Cookie References: <588d6a6c-0080-48a4-b768-e2c5ef551790@s50g2000hsb.googlegroups.com> Message-ID: On Apr 28, 9:42 am, cbh... at gmail.com wrote: > ....I see the cookie in my HTTP header > but do not get anything in the cookie text file. I'm working on > linux. > > print "Content-type: text/html" > cookie = Cookie.SimpleCookie() > cookie['Test'] = 'abc' > print cookie > print > > Are there rules about where in the header the set cookie line should > be? Hi Christian. I think the cookie can go anywhere in the header, but I usually put it before the content-type. If you want to store the cookie to a file, or even better, to a database of some sort, you have to do it yourself, the Cookie module doesn't do it for you, I hope. # store cookie to /tmp/cookie.txt file("/tmp/cookie.txt","w").write(str(cookie)) For parsing cookies, I stole and modified this from the Django source (for use in a cgi script): === from Cookie import SimpleCookie import os # stolen and modified from Django def parse_cookie(cookie=None, environ=None): if cookie is None: if environ is None: environ = os.environ cookie = environ.get('HTTP_COOKIE', '') if cookie == '': return {} c = SimpleCookie() c.load(cookie) cookiedict = {} for key in c.keys(): cookiedict[key] = c.get(key).value return cookiedict === All the best. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=monster From cyberco at gmail.com Tue Apr 15 10:19:36 2008 From: cyberco at gmail.com (Berco Beute) Date: Tue, 15 Apr 2008 07:19:36 -0700 (PDT) Subject: webcam (usb) access under Ubuntu References: <66jlk1F2ju6c8U1@mid.uni-berlin.de> Message-ID: Thanks, that would be great. While I'm at it I wondering how to display a video preview. Here's someone using VideoCapture (the win32 lib) and PyGame, but I'd rather use a GUI framework and preview/capture videos directly. 2B > It has been *ages* since I did this - so take it with a grain of salt. > However, back then I was able to access a video camera using gqcam. Looking > into the source of that revealed that all it did were some simple > ioctl-calls and reading from a /dev/video*-device. > > That did the trick for me... > > Additionally, you might consider using gstreamer + the python bindings for > that. I was also successful using them - if I remember this conversation > tonight or so, I'll send you the sources. > > Diez > > Diez From steve at holdenweb.com Wed Apr 2 20:13:36 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 02 Apr 2008 20:13:36 -0400 Subject: Strange MySQL Problem... In-Reply-To: <4dc0cfea0804021236n1faafabav1699fbe45acc3c01@mail.gmail.com> References: <4dc0cfea0804021236n1faafabav1699fbe45acc3c01@mail.gmail.com> Message-ID: Victor Subervi wrote: > Hi; > I have this code which works fine: > > #!/usr/local/bin/python > import _mysql > import MySQLdb, cPickle > host = 'mysqldb2.ehost-services.com ' > user = 'user' > passwd = 'pass' > db = 'bre' > print 'Content-Type: image/jpeg\r\n' > print '\nHi!\n' > connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > imgfile=open("1.jpg",'rb') > f = imgfile.read() > cursor = connection.cursor() > cursor.execute("CREATE TABLE justatest (name TEXT, ablob BLOB)") > names = 'aramis', 'athos', 'porthos' > data = {} > for name in names: > datum = list(name) > datum.sort() > data[name] = cPickle.dumps(datum, 1) > sql = "INSERT INTO justatest VALUES (%s, %s)" > cursor.execute(sql, ('ramis', _mysql.escape_string(f)) ) > imgfile.close() > connection.close() > print '\nBye!\n' > Now, if I take out this part, which I can?t see does anything at all in > the code, it no longer works: > > names = 'aramis', 'athos', 'porthos' > data = {} > for name in names: > datum = list(name) > datum.sort() > data[name] = cPickle.dumps(datum, 1) > Why? > TIA, > Victor > Define "no longer works". regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From ivan.illarionov at gmail.com Thu Apr 17 16:48:19 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Thu, 17 Apr 2008 20:48:19 +0000 (UTC) Subject: index of list of lists References: Message-ID: On Thu, 17 Apr 2008 05:15:52 +0300, Daniel NL wrote: > yes, there's a thread with the same title, but I believe mine is more > appropriate title. > so, as much as I search on the web, read manuals, tutorials, mail-lists > (including this one) I cannot figure it out how to search a string in a > list of lists. > like this one: > > someList = [['somestring', 1, 2], ['oneother', 2, 4]] > > I want to search "somestring" in someList which is in practice a list of > aprox. 200 lists. (hey, I'm a newbie python programmer, don't judge me). > is the list.index the wrong approach? should I use numpy, numarray, > something else? can anyone, be kind and help me with this? You probably need something like this: [x for x, y, z in someList if x == 'somestring'] or this: for x, y, z in someList: if x == 'somestring': return x -- Ivan From svensven at gmail.com Thu Apr 10 15:05:20 2008 From: svensven at gmail.com (svensven) Date: Thu, 10 Apr 2008 21:05:20 +0200 Subject: subprocess.Popen() output to logging.StreamHandler() In-Reply-To: <6b02e27c-916f-42a7-b2e0-75af51bba343@h1g2000prh.googlegroups.com> References: <6b02e27c-916f-42a7-b2e0-75af51bba343@h1g2000prh.googlegroups.com> Message-ID: <47FE64F0.10904@gmail.com> Vinay Sajip wrote: > On Apr 10, 1:11 pm, "sven _" wrote: >> My goal is to have stdout and stderr written to a logginghandler. > > Thomas was almost right, but not quite - you can't call info on a > Handler instance, only on a Logger instance. The following script: Yes, but that was easily fixed. Still there seemed to be a problem there with the .poll(), since it would think the process ended while it was actually running. The result was that only some of the command output was shown. > import logging > import subprocess > > logging.basicConfig(level=logging.INFO) # will log to stderr of this > script > > s = subprocess.Popen( ['ls','-la'], stdout=subprocess.PIPE ) > while 1: > line = s.stdout.readline() > exitcode = s.poll() > if (not line) and (exitcode is not None): > break > line = line[:-1] > logging.info("%s", line) This works perfectly, as far as I can tell. You seem to use another conditional, though. I'll take a closer look at this tomorrow. Thanks for the clean solution, Vinay. sven From kayvoo at googlemail.com Fri Apr 18 21:46:54 2008 From: kayvoo at googlemail.com (Karl-Heinz Ruskowski) Date: Sat, 19 Apr 2008 03:46:54 +0200 Subject: Another MySQL Images Question In-Reply-To: <4dc0cfea0804180813o32ed2c82o9c3f68b1a607348d@mail.gmail.com> References: <4dc0cfea0804180813o32ed2c82o9c3f68b1a607348d@mail.gmail.com> Message-ID: <200804190347.00462.kayvoo@gmail.com> Hi, > cursor.execute('update products set pic1="%s" where id="%s", ;', > (pic1, id)) Shouldn't it be something like cursor.execute('update products set pic1="%s" where id="%s", ;' % (pic1, id)) -- GPG key: 0x04B3BB96 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available URL: From kcemjz at yahoo.com Fri Apr 4 00:31:23 2008 From: kcemjz at yahoo.com (AJay Grimmett) Date: Thu, 3 Apr 2008 21:31:23 -0700 (PDT) Subject: Question. Message-ID: <661622.4034.qm@web54009.mail.re2.yahoo.com> My name is Amanda. My boyfriend sent me an encrypted message by using python. I guess he thought it would be fun for me to figure it out for myself. This one involes a whole lotta numbers. I can't read or understand what I am supposed to do to read this message. I mean, I've read the information, but I seriously do not understand. He sent the .py file, and the messages that were encrypted...i just don't know how to use it to get to the message where I can read it. Is there anyway you or someone could do it step by step..or just do it for me?! lol. I just need to know what this says. Apparently it's an important message and I must read it. =] Thank you for your time. I hope to hear from you soon! -amanda --------------------------------- You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost. -------------- next part -------------- An HTML attachment was scrubbed... URL: From frikker at gmail.com Wed Apr 23 11:02:30 2008 From: frikker at gmail.com (blaine) Date: Wed, 23 Apr 2008 08:02:30 -0700 (PDT) Subject: Unix Device File Emulation Message-ID: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> Hey everyone, So I've got a quick query for advice. We have an embedded device in which we are displaying to an LCD device that sits at /dev/screen. This device is not readily available all the time, so I am needing to write an emulator. This will basically just monitor a file, /dev/screen for example, and write the commands to a TK or WxWindows canvas. So sending 'line 0 0 10 10' will draw a line on my canvas from (0,0) to (10,10). My question: Whats the best way to set up a monitor (in python) of this file? Would I simply open up the file for read, check for changes, get any updated data, and clear the file? Or is there some standard way of doing something like this that guarantees no overlap or data loss? example usage: echo 'line 0 0 10 10' > /dev/screen On the actual embedded device this is handled by a kernel module. We can spit commands into it as fast as we can and the kernel module can keep up. This is typical unix device file behavior. Any suggestions or advice would be splendid. Thanks! Blaine From skanemupp at yahoo.se Sat Apr 19 16:44:27 2008 From: skanemupp at yahoo.se (globalrev) Date: Sat, 19 Apr 2008 13:44:27 -0700 (PDT) Subject: Frame work for simple physics web applications References: <2b0b8b6c-8086-4bf6-8f47-27bc5c9c788c@v23g2000pro.googlegroups.com> Message-ID: <6bdd161d-6e92-4de6-8dba-d5c11b08990f@a22g2000hsc.googlegroups.com> On 19 Apr, 21:55, Rick Muller wrote: > I'd like to use my webserver to distribute some simple python physics > apps. Ideally, I'd like to use some simple form to input a few pieces > of data, call a python program, and return some image from a plot or > some other rendering. This is easy to do using CGI, but I was > wondering whether anyone on the list could recommend that would look a > little more polished and professional. > > Let's say I want to input a wave vector k, and then input a plot of > sin(k*x). I would like to have a simple form input for k, and then > display an image of the plot. What I'm doing is a little more varied > than this, but the common thread is that in each application I need to > input several pieces of data and then display some image. I can > probably think of 20 different applications right off the bat that I'd > like to deploy. > > The idea behind this is to put together some simple toy models for > quantum computing qubits that my experimental collaborators can play > with without having to install Python, NumPy, and MatPlotLib > themselves. (I understand, of course, that such an installation might > be "good for them", but I'd rather not fight that battle just now.) > > I could, of course, write a Jython applet for this, but this would > require my re-learning how to use the Java API, and it has been a few > years for me. > > Do any of the AJAX frameworks for Python compare in simplicity to > writing a simple CGI script? I've been impressed with web.py, since it > seems pretty easy to use, but I would go to the trouble of learning > one of the bigger frameworks if they would provide a more elegant > solution. > > My web skillz are obviously several years out of date, so I'd like > some guidance on the best way to update them. > > Thanks in advance, > > Rick www.vpython.org might be what you are looking for. From kf9150 at gmail.com Wed Apr 9 13:04:12 2008 From: kf9150 at gmail.com (Kelie) Date: Wed, 9 Apr 2008 07:04:12 -1000 Subject: question about string formatting Message-ID: <42b9a3ff0804091004s4d60751fh68c82673e8e3f4c3@mail.gmail.com> Hello, Is there something in Python built-in function or library that will convert a number 1205466.654 to $1,205,466.65? To add the "$" sign and set the decimal place is not a problem, but I don't know how to add the thousands delimiter. Thanks, -- Kelie UliPad is my Python editor. -------------- next part -------------- An HTML attachment was scrubbed... URL: From Lie.1296 at gmail.com Sun Apr 6 03:13:52 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 6 Apr 2008 00:13:52 -0700 (PDT) Subject: Looking for Advanced Python Tutorials References: Message-ID: On Apr 4, 6:58 pm, cokofree... at gmail.com wrote: > I was wondering if anyone knew of some online (free if possible) > advanced tutorials, especially ones that provides tasks and ideas for > small projects. The issue for myself is I want to improve my python > programming level, and my ability to program in general, but come up > blank thinking of a possible task or project to undertake. So with > that in mind I thought I'd ask the community if they knew of sites or > books to read up on and use as a starting block. Of course project > ideas would be great as well! > > Thanks for any help you can provide. > > Coko You might be interested in Python challenge: http://www.pythonchallenge.com/ It's a series of puzzles that involve learning the edges of Python (most of the puzzle can be solved with any programming language, but some involve Python-only features, e.g. pickle) From donn at u.washington.edu Mon Apr 7 19:07:25 2008 From: donn at u.washington.edu (Donn Cave) Date: Mon, 07 Apr 2008 16:07:25 -0700 Subject: Orphaned child processes References: <51102b91-dedc-4ad6-a936-c29df47f30ab@r9g2000prd.googlegroups.com> <47fa650f$0$36329$742ec2ed@news.sonic.net> Message-ID: In article <47fa650f$0$36329$742ec2ed at news.sonic.net>, John Nagle wrote: > rocco.rossi at gmail.com wrote: > > I'm using the Python processing module. I've just run into a problem > > though. Actually, it's a more general problem that isn't specific to > > this module, but to the handling of Unix (Linux processes) in general. > > Suppose for instance that for some reason or another, after forking > > several child processes, the main process terminates or gets killed > > (or segfaults or whatever) and the child processes are orphaned. Is > > there any way to automatically arrange things so that they auto- > > terminate or, in other words, is there a way to make the child > > processes terminate when the parent terminates? > > > > Thank you. > > Put a thread in the child which reads stdin, and make stdin > connect to a pipe from the parent. When the parent terminates, > the child will get a SIGPIPE error and raise an exception. > > John Nagle That could work, but not precisely in that manner. You get SIGPIPE when you write to a closed pipe. When you read from one, you get end of file, i.e., a normal return with 0 bytes. When you test it, make sure to try a configuration with more than one child process. Since the parent holds the write end of the pipe, subsequently forked child processes could easily inherit it, and they'll hold it open and spoil the effect. Donn Cave, donn at u.washington.edu From nospam1.reifenberg at gmx.de Fri Apr 4 16:05:57 2008 From: nospam1.reifenberg at gmx.de (Nebur) Date: Fri, 4 Apr 2008 13:05:57 -0700 (PDT) Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? References: Message-ID: <0c8bfed7-1154-41d5-a740-6d1382180db2@d45g2000hsc.googlegroups.com> Yes. Linux viruses are rare but useful :-) Well, I don't think the problem a very dangerous one. The Pydev/ Eclipse was used for much more than a year nearly daily and intensively. The strange effect is very rare,obviously (plus the chance that it's in my brain, as I mentioned ;-D ) so you probably can lean back. Anyway, I'd be glad to get an even faint idea of the problem. From tjreedy at udel.edu Sat Apr 5 12:34:27 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 5 Apr 2008 12:34:27 -0400 Subject: RELEASED Python 2.6a2 and 3.0a4 References: <47F68547.1040802@v.loewis.de> Message-ID: "Kay Schluehr" wrote in message news:f4ac789e-c98f-4cf2-9236-f1ac609c44de at b1g2000hsg.googlegroups.com... On 4 Apr., 21:45, "Martin v. L?wis" wrote: > > The Windows x86 MSI installer is missing for both 2.6 and 3.0. > > And likely will continue to do so for some time. Fine. Is there also a reason? ========================== On PyDev, Martin gave just (but only) a bit more detail, to the effect that he has run into problems with the new Microsoft compiler being used for 2.6/3.0 that apparently did not crop up with the previous alpha releases a month ago. I think we should be patient and not bug him for more. Terry From upton at virginia.edu Wed Apr 2 12:41:59 2008 From: upton at virginia.edu (Dan Upton) Date: Wed, 2 Apr 2008 12:41:59 -0400 Subject: Rationale for read-only property of co_code In-Reply-To: References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> Message-ID: <5504f9ac0804020941t645de4f2xe0ed0dbc92509021@mail.gmail.com> > The thing I've been wondering is why _is_ it read-only? In what > circumstances having write access to co_code would break the language > or do some other nasty stuff? > > Jo?o Neves I can't speak to Python's implementation in particular, but self-modifying code in general is unpleasant. It certainly is possible to support it in runtime environments, but it's usually not easy to do so. That is, of course, somewhat dependent on the implementation of the runtime environment, and even to some degree the underlying hardware. (For instance, the compiled code you want to run could be in the hardware cache; if you then change the instructions at those addresses in memory, it's not always straightforward to get the processor to realize it needs to load the new data into the instruction cache.) Plus, I suppose it might be possible to break strong (even dynamic) typing if you start changing the code around (although I can't construct an example off the top of my head). In short, you need a good reason to support self-modifying code, and my guess is nobody could come up with one for Python. -dan From kyosohma at gmail.com Thu Apr 10 16:24:09 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Thu, 10 Apr 2008 13:24:09 -0700 (PDT) Subject: win-shortcuts, file associates and command-line parameters ? References: Message-ID: <0cbfd58c-a6af-4b40-a67f-09735ce4a448@m71g2000hse.googlegroups.com> On Apr 10, 2:03 pm, Stef Mientki wrote: > hello, > > under windows I tried to make a shortcut to a py -file, to run a program. > So making a shortcut like this works perfect: > D:\PyLab_Works.py > > But the problem is that I need to give some commandline parameters to > the py-file, > and > > D:\PyLab_Works.py btc_test > But the parameter doesn't seem to arrive in the python program > > If I start with the python interpreter, the parameters do arrive at the > program > P:\pythonw.exe D:\PyLab_Works.py btc_test > Although this method works, > it makes the creation of shortcuts difficult (the paths are in real much > longer). > > Is there a way to pass the commandline parameters correctly, > without explicitly specifying the python interpreter ? > > thanks, > Stef Mientki I'm not sure what you're doing wrong. It works for me. I do have Python on my system path though. I did this: Created a shortcut to my script (test.py). Right-clicked it and chose Properties. Changed it to look like this: C:\Python25\test.py -i Pressed Ok and ran it. It received my parameter just fine. If you want to use pythonw.exe by default, you'll want to change the extension of your script to *.pyw Mike From steve at holdenweb.com Wed Apr 9 12:51:45 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 12:51:45 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> Message-ID: <47FCF421.6000807@holdenweb.com> Victor Subervi wrote: > On Wed, Apr 9, 2008 at 11:10 AM, Steve Holden > wrote: > > Victor Subervi wrote: > > On Wed, Apr 9, 2008 at 10:24 AM, Steve Holden > > >> wrote: > connection = MySQLdb.connect(host=host, user=user, > passwd=passwd, db=db) > cursor = connection.cursor() > cursor.execute('select img from photo where id="7";') > content = cursor.fetchall() > > > Bzzt! Nope. Cursor.fetchall() returns a list (length 1) or tuples > (length 1) here, so this should be > > content = cursor.fetchall()[0][0] > > or, perhaps better > > content = cursor.fetchone()[0] > > > I tried both of these, and they, too, gave me the same identical image > of the url, not the image I am after. > I'm having a problem believing this, but I don't think you are lying. Are you *sure* you have stored the correct omages in your database? The fact remains that cursor.fetchall() will return a list containing one tuple containing (what you believe is) your image, so there is NO way your code above can do what you want. I can therefore only assume that this is a CGI script and that your web server does something *extremely* funky when it gets a CGI output it isn't expecting. But this doesn't make a lot of sense. > > > You really don't understand how the web works, do you? > > > I am just really, really, stupid, Steve. Please forgive me for being so > stupid. But I am persistent. And I have built dozens of Web site with > images. > Stupidity and ignorance are entirely different things, and you (current) ignorance in no way implies stupidity. We all have to learn. However, if you bring up one of the pages from one of your many web sites containing an image, and get your browser to display the HTML of that page you will surely find that the image does not appear direectly in the HTML, but instead appears as a tag in the HTML. Something like: though the src attribute doesn't really need to be that complex. > > In order to include an image in a page your browser must make TWO > requests. The first is for an HTML page that will reference the > image in this way: > > > > Seeing this img tag causes the browser to make a SECOND request, > which the script I corrected above should respond to with an image. > > The bytestream is critical in the image response. Even one misplaced > byte will mess things up terribly. > > > In my stupidity, I have assumed you meant this: > > content = col_fields[0][14].tostring() > print '

' > Well, here I have no idea what the content of your database might be, but if the fifteenth column you retrieve is the web server path to the graphic, that should be right except for the spaces around it, which might give trouble. You might consider instead content = col_fields[0][14].tostring() print '

' % content to omit them. > Obviously I am wrong. Could you please give me a little more insight? > Forget HTML for now. If you direct your browser to the URL on which your server is serving the graphic then it should be displayed in the browser window. Until that happy condition pertains, we are stabbing around in the dark. > BTW, when we are finally done with this, I will write a nice > how-to (since there is not one in python, while php has some > nice ones) on how to do this, and give you and Gabrielle all > your due credit. I will post it to this list, because that is > sure to rank highly in google right away. > Victor > > That's great, though hardly the point of the exercise. I think > Google already know about Gabriel (*not* Gabrielle) and me already ... > > > Well, I just thought it might be a good way to get the information out, > since it is not out there yet. And I believe it is only proper to give > credit where credit is due. I would not be doing this to praise you. > Rather, I would be doing this because it is needed, and I would feel > wrong for not crediting those who deserve credit. Please let me know, > however, if you feel otherwise. It's not that I mind, but I do feel that this knowledge is already available, though clearly I might be wrong ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gagsl-py2 at yahoo.com.ar Thu Apr 3 20:50:03 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 21:50:03 -0300 Subject: id functions of ints, floats and strings References: Message-ID: En Thu, 03 Apr 2008 19:27:47 -0300, escribi?: > Hi all, > > I've been playing around with the identity function id() for different > types of objects, and I think I understand its behaviour when it comes > to objects like lists and tuples in which case an assignment r2 = r1 > (r1 refers to an existing object) creates an alias r2 that refers to > the same object as r1. In this case id(r1) == id(r2) (or, if you > like: r1 is r2). However for r1, r2 assigned as follows: r1 = [1, 2, > 3] and r2 = [1, 2, 3], (r1 is r2) is False, even if r1==r2, > etc. ...this is all very well. Therefore, it seems that id(r) can be > interpreted as the address of the object that 'r' refers to. > > My observations of its behaviour when comparing ints, floats and > strings have raised some questions in my mind, though. Consider the > following examples: > > ######################################################################### > > # (1) turns out to be true > a = 10 > b = 10 > print a is b ...only because CPython happens to cache small integers and return always the same object. Try again with 10000. This is just an optimization and the actual range of cached integer, or whether they are cached at all, is implementation (and version) dependent. (As integers are immutable, the optimization *can* be done, but that doesn't mean that all immutable objects are always shared). > # (2) turns out to be false > f = 10.0 > g = 10.0 > print f is g Because the above optimization isn't used for floats. The `is` operator checks object identity: whether both operands are the very same object (*not* a copy, or being equal: the *same* object) ("identity" is a primitive concept) The only way to guarantee that you are talking of the same object, is using a reference to a previously created object. That is: a = some_arbitrary_object b = a assert a is b The name `b` now refers to the same object as name `a`; the assertion holds for whatever object it is. In other cases, like (1) and (2) above, the literals are just handy constructors for int and float objects. You have two objects constructed (a and b, f and g). Whether they are identical or not is not defined; they might be the same, or not, depending on unknown factors that might include the moon phase; both alternatives are valid Python. > # (3) checking if ids of all list elements are the same for different > cases: > > a = 3*[1]; areAllElementsEqual([id(i) for i in a]) # True > b = [1, 1, 1]; areAllElementsEqual([id(i) for i in b]) # True > f = 3*[1.0]; areAllElementsEqual([id(i) for i in f]) # True > g = [1.0, 1.0, 1.0]; areAllElementsEqual([id(i) for i in g]) # True > g1 = [1.0, 1.0, 0.5+0.5]; areAllElementsEqual([id(i) for i in g1]) # > False Again, this is implementation dependent. If you try with a different Python version or a different implementation you may get other results - and that doesn't mean that any of them is broken. > # (4) two equal floats defined inside a function body behave > differently than case (1): > > def func(): > f = 10.0 > g = 10.0 > return f is g > > print func() # True Another implementation detail related to co_consts. You shouldn't rely on it. > I didn't mention any examples with strings; they behaved like ints > with respect to their id properties for all the cases I tried. You didn't try hard enough :) py> x = "abc" py> y = ''.join(x) py> x == y True py> x is y False Long strings behave like big integers: they aren't cached: py> x = "a rather long string, full of garbage. No, this isn't garbage, just non sense text to fill space." py> y = "a rather long string, full of garbage. No, this isn't garbage, just non sense text to fill space." py> x == y True py> x is y False As always: you have two statements constructing two objects. Whether they return the same object or not, it's not defined. > While I have no particular qualms about the behaviour, I have the > following questions: > > 1) Which of the above behaviours are reliable? For example, does a1 = > a2 for ints and strings always imply that a1 is a2? If you mean: a1 = something a2 = a1 a1 is a2 then, from my comments above, you should be able to answer: yes, always, not restricted to ints and strings. If you mean: a1 = someliteral a2 = someliteral a1 is a2 then: no, it isn't guaranteed at all, nor even for small integers or strings. > 2) From the programmer's perspective, are ids of ints, floats and > string of any practical significance at all (since these types are > immutable)? The same significance as id() of any other object... mostly, none, except for debugging purposes. > 3) Does the behaviour of ids for lists and tuples of the same element > (of type int, string and sometimes even float), imply that the tuple a > = (1,) takes (nearly) the same storage space as a = 10000*(1,)? (What > about a list, where elements can be changed at will?) That's a different thing. A tuple maintains only references to its elements (as any other object in Python). The memory required for a tuple (I'm talking of CPython exclusively) is: (a small header) + n * sizeof(pointer). So the expression 10000*(anything,) will take more space than the singleton (anything,) because the former requires space for 10000 pointers and the latter just one. You have to take into account the memory for the elements themselves; but in both cases there is a *single* object referenced, so it doesn't matter. Note that it doesn't matter whether that single element is an integer, a string, mutable or immutable object: it's always the same object, already existing, and creating that 10000-uple just increments its reference count by 10000. The situation is similar for lists, except that being mutable containers, they're over-allocated (to have room for future expansion). So the list [anything]*10000 has a size somewhat larger than 10000*sizeof(pointer); its (only) element increments its reference count by 10000. -- Gabriel Genellina From arnodel at googlemail.com Thu Apr 24 16:43:28 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 24 Apr 2008 21:43:28 +0100 Subject: Class Inheritance - What am I doing wrong? References: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> Message-ID: Brian Munroe writes: > My example: > > class A(object): > > def __init__(self, name): > self.__name = name > > def getName(self): > return self.__name > > class B(A): > > def __init__(self,name=None): > super(A,self).__init__() > > def setName(self, name): > self.__name = name > > if __name__ == '__main__': > > a = A('class a') > print a.getName() > > b = B('class b') > print b.getName() > > b.setName('class b, reset') > print b.getName() > > I get the following error: > > mtinky:~ brian$ python teste.py > class a > Traceback (most recent call last): > File "teste.py", line 23, in > print b.getName() > File "teste.py", line 7, in getName > return self.__name > AttributeError: 'B' object has no attribute '_A__name' > > Am I *not* using super() correctly? Also, did I define my the class B > constructor correctly? You have fallen victim to the Name Mangling Trap [1]. Replace the leading double underscore in the __name attribute with a single one, and Python shall calm down and let your code behave as you expect it to. That is, if you also pass the name parameter to super(A,self).__init__ in B's __init__ method [1] http://docs.python.org/ref/atom-identifiers.html -- Arnaud From sasha at theotheralex.com Fri Apr 4 01:47:48 2008 From: sasha at theotheralex.com (shurik) Date: Thu, 3 Apr 2008 22:47:48 -0700 (PDT) Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: that's great! thanks for putting this together. what about the inspect module? and particularly getsource :) On Apr 1, 6:15?pm, AK wrote: > Hello, > > I find that I learn easier when I go from specific examples to a more > general explanation of function's utility and I made a reference guide > that will eventually document all functions, classes and methods in > Python's Standard Library. For now, I covered about 20 most important > modules. I will be adding more modules and eventually I'll cover > everything. Here's my progress so far, let me know if this is useful; > I'll be glad to hear comments/suggestions/etc: > > http://www.lightbird.net/py-by-example/ > > -- > ? -ak > ? ?Tobu |http://www.lightbird.net/tobu/| Freeform DB / Tagger / PIM From roy at panix.com Tue Apr 29 09:32:46 2008 From: roy at panix.com (Roy Smith) Date: Tue, 29 Apr 2008 09:32:46 -0400 Subject: list.reverse() References: <4816e26a$0$30938$426a74cc@news.free.fr> Message-ID: In article <4816e26a$0$30938$426a74cc at news.free.fr>, Bruno Desthuilliers wrote: > Mark Bryan Yu a ?crit : > > This set of codes works: > > > >>>> x = range(5) > >>>> x.reverse() > >>>> x > > [4, 3, 2, 1, 0] > > > > But this doesn't: > > > >>>> x = range(5).reverse() > >>>> print x > > None > > This works just as expected - at least for anyone having read the doc. > > > Please explain this behavior. range(5) returns a list from 0 to 4 and > > reverse just reverses the items on the list that is returned by > > range(5). Why is x None (null)? > > Because that's what list.reverse() returns. Call it a wart if you want > (FWIW, I do), but at least that's well documented. The reasoning goes along the lines of, "reverse in place is an expensive operation, so we don't want to make it too easy for people to do". At least that's the gist of what I got out of the argument the many times it has come up. And, yes, I agree with Bruno that it's a wart. What you want to do is look at the reversed() function. Not only does it return something (other than Null), but it is much faster because it doesn't have to store the reversed list anywhere. What it returns is an iterator which walks the list in reverse order. If you really want it as a list, you can turn it into one (with the list() constructor), or you can just iterate over it with a for loop. Same with list.sort() vs. the global sorted(). >>> range(5) [0, 1, 2, 3, 4] >>> reversed(range(5)) >>> list(reversed(range(5))) [4, 3, 2, 1, 0] >>> for i in reversed(range(5)): ... print i ... 4 3 2 1 0 >>> From hopeorpha308 at gmail.com Sun Apr 27 07:44:56 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:44:56 -0700 (PDT) Subject: dvdfabplatinum crack Message-ID: dvdfabplatinum crack http://wga-cracks.crackkey.net From mcat.schaefer at gmx.de Mon Apr 7 08:19:03 2008 From: mcat.schaefer at gmx.de (=?ISO-8859-1?Q?Michael_Sch=E4fer?=) Date: Mon, 7 Apr 2008 05:19:03 -0700 (PDT) Subject: Calling CVF-Fortran-dll with ctypes and simple structure Message-ID: <60915c2d-0c0d-42fc-8b02-5fb58e13a20c@p25g2000hsf.googlegroups.com> Hi all, I deal with the old problem passing characters from python to a fortran dll build with CFV6.6c. I reduced our complex structure to a simple one. Here is the Fortran code: SUBROUTINE DEMO2L(s) C sample for calling CVF6.6c-DLLs from C vb/vba/python with simple structure !DEC$ ATTRIBUTES DLLEXPORT::DEMO2L TYPE rcDEMO INTEGER a REAL b CHARACTER c*9 END TYPE TYPE(rcDEMO) :: s C WRITE(*,*) s.a, s.b, s.c C sample calculation: s.a = s.a*10 s.b = s.b**2.3 s.c = 'Sample' RETURN END From VB the calling is very simple: Declare Sub DEMO2L Lib "release\demo1l.dll" (ByRef k As rcDEMO) Type rcDEMO a As Long b As Single c As String * 9 End Type Dim k As rcDEMO Sub run() k.a = 2 k.b = 3# k.c = "Test" Call DEMO2L(k) Debug.Print k.a, k.b, k.c End Sub and result to: " 20 12,5135 Sample" When I try this from python: from ctypes import * class rcDemo(Structure): _fields_ = [ ('a', c_int), ('b', c_float), ('c', c_char_p), ] mydll = windll.LoadLibrary("release\DEMO1L.DLL") rc = rcDemo() rc.a = 2 rc.b = 3. rc.c = "Test56789" mydll.DEMO2L(byref(rc)) print rc.a print rc.b print ">" + rc.c + "<" I got " 2 3.000000 ???" from the debug print in Fortran and 20 12.513502121 Traceback (most recent call last): File "run_demo.py", line 21, in ? print ">" + rc.c + "<" ValueError: invalid string pointer 0x706D6153 from Python. When passing only the string in a argument list instead of the structure and considering to pass the length of the string as 2nd argument I am be able to send this characters to the dll and receive a changed value back. Have anyone an idea or perhaps a solution ;-) doing this in a structure? Thank you! Michael From sjmachin at lexicon.net Mon Apr 21 17:42:45 2008 From: sjmachin at lexicon.net (John Machin) Date: Mon, 21 Apr 2008 21:42:45 GMT Subject: module error in Vista -- works as administrator In-Reply-To: <815eb7f8-6f00-469d-bb15-e1d9680d9646@e39g2000hsf.googlegroups.com> References: <815eb7f8-6f00-469d-bb15-e1d9680d9646@e39g2000hsf.googlegroups.com> Message-ID: <480d0a52$1@news.mel.dft.com.au> sawilla wrote: > First, I'm new to Python. I'm getting and error when I run Python > 2.5.2 as a regular user in Vista but not when I run Python as an > administrator. > > For example, if I type "import numpy" after I launch python from an > adminstrator-privileged command window it loads fine. However, from a > regular-user command window I get: > >>>> import numpy > Traceback (most recent call last): > File "", line 1, in > ImportError: No module named numpy > Log on as administrator, start python in command window and do this: import sys sys.path # shows where python is looking for importables import numpy import os.path print os.path.abspath(numpy.__file__) # shows where it found numpy Log on as ordinary user, start python in command window and do this: import sys sys.path # check how this is different from the admin's sys.path If you can't see what to do after that, come back here with the output from those steps. HTH, John From grante at visi.com Thu Apr 17 09:52:37 2008 From: grante at visi.com (Grant Edwards) Date: Thu, 17 Apr 2008 08:52:37 -0500 Subject: Finally had to plonk google gorups. References: <4806bcec$0$25058$607ed4bc@cv.net> Message-ID: On 2008-04-17, John Salerno wrote: > Grant Edwards wrote: >> This morning almost half of c.l.p was spam. In order to try to >> not tar both the benign google group users and the malignant >> ones with the same brush, I've been trying to kill usenet spam >> with subject patterns. But that's not a battle you can win, so >> I broke down and joined all the other people that just killfile >> everything posted via google.groups. >> >> AFAICT, if you're a google groups user your posts are not being >> seen by many/most experienced (read "non-google-group") users. >> This is mainly the fault of google who has refused to do >> anything to stem the flood of span that's being sent via Google >> Groups. > > How exactly do you killfile an entire source like that? I use slrn, so I put this in my .score file: Score:: = -9999 Organization: http://groups.google.com Message-ID: .*googlegroups.com > Is it possible with Thunderbird? I've no idea. -- Grant Edwards grante Yow! UH-OH!! I put on at "GREAT HEAD-ON TRAIN visi.com COLLISIONS of the 50's" by mistake!!! From jesus.aguillon at gmail.com Sun Apr 13 16:26:29 2008 From: jesus.aguillon at gmail.com (Jaguillo) Date: Sun, 13 Apr 2008 13:26:29 -0700 (PDT) Subject: PythonWin Print Problem.. Build 210 References: <%cqMj.118543$yE1.5692@attbi_s21> Message-ID: <0ca21bfd-5eb1-45da-ad1d-094367590d25@z24g2000prf.googlegroups.com> On Apr 13, 9:07 am, "Hutch" wrote: > "Roger Upole" wrote in message > > news:mailman.346.1208051713.17997.python-list at python.org... > > > > > > > "Hutch" wrote in message > >news:H29Mj.117410$yE1.54267 at attbi_s21... > >> PythonWin has been a very good ide from early version thru 2.4. > > >> All work ok on THREE of my computers with THREE different HP printers. > > >> Now comes 2.5. > >> Every thing seems to work the same except when I want to print out a copy > >> of the source code of my project (about 38 pages) > > >> Version 2.5 acts like it is going to print out the source code but > >> instead > >> prints from several 100 to over 2000 BLANK PAGES pages and no source. > > >> Attempting to print out Source on SAME equipment (computers and printers) > >> using 2.4 (WITH NO CHANGES TO EQUIPMENT OR SOFTWARE ) results in > >> proper print out of source. > > >> Problem has been reported via direct and SourceForge but no response. > > >> Any body else having the same problem? > > >> -- > >>http://mail.python.org/mailman/listinfo/python-list > > > Did you see the response to the bug report on SF ? > >http://sourceforge.net/tracker/index.php?func=detail&aid=1907148&grou... > > > There is also some more info in this thread on the python-win32 mailing > > list: > >http://mail.python.org/pipermail/python-win32/2006-December/005397.html > > > Roger > > Sorry to report after uninstalling both Python 2.5 and Pythonwin 2.5 and > reinstalling.. THE PROBLEM IS STILL WITH US... Did you make the change that Roger suggested in the file view.py per the link: http://mail.python.org/pipermail/python-win32/2006-December/005397.html It has been working for me on Python 2.5. -Jesus From torriem at gmail.com Thu Apr 17 12:27:29 2008 From: torriem at gmail.com (Michael Torrie) Date: Thu, 17 Apr 2008 10:27:29 -0600 Subject: py3k s***s In-Reply-To: References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: <48077A71.1030709@gmail.com> Aaron Watters wrote: > What I'm saying is that, for example, there are a lot > of cool tools out there for using Python to manipulate > postscript and latex and such. Most of those tools > require no maintenance, and the authors are not paying > any attention to them, and they aren't interested in > messing with them anymore. What makes you think these tools are all going to mysteriously stop working? Python 2.x will be around for a long, long time. Currently there are still Python 1.5 apps that are still in use and circulation and, with Python 1.5 installed, still work fine. The same for Python 2.x. Honestly I don't understand all this FUD over the move to Python 3.x Those that want/need to migrate will. Others won't have to. What's the big deal? Further, 90% of these little, finished utilities are pure python, and so converting them to Python 3.x is a trivial mechanical conversion if the maintainer cared. From deets at nospam.web.de Wed Apr 30 10:53:57 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 30 Apr 2008 16:53:57 +0200 Subject: computing with characters In-Reply-To: <87tzhjy4u2.fsf@physik.rwth-aachen.de> References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> <87tzhjy4u2.fsf@physik.rwth-aachen.de> Message-ID: <67rfg6F2qrcooU1@mid.uni-berlin.de> > However, join() is really bizarre. The list rather than the > separator should be the leading actor. Certainly *not*! This would be the way ruby does it, and IMHO it does not make sense to add join as a string-processing related method/functionality to a general purpose sequence type. And as others have pointed out, this would also mean that e.g. def sgen(): for i in xrange(100): yield str(i) sgen.join(":") wouldn't work or even further spread the join-functionality over even more objects. An argument for the original ord/chr debate btw is orthogonality: if you want ord to be part of a string, you'd want chr to be part of ints - which leads to ugly code due to parsing problems: (100).chr() Diez From mysakjs at gmail.com Fri Apr 25 18:16:07 2008 From: mysakjs at gmail.com (JMysak) Date: Fri, 25 Apr 2008 15:16:07 -0700 (PDT) Subject: newbie question Message-ID: I'm working with the HTMLParser module and have implemented HTMLParser.handle_starttag() and I see there is a separate handle_data method (which can be implemented), but I am not clear how to tie this together with a given start tag, so I only get the data I want. For example, I'd like to get a handle on the character data ( the number 1) immediately after the following start tag 1
. . . Any ideas? From M8R-yfto6h at mailinator.com Sun Apr 27 23:09:58 2008 From: M8R-yfto6h at mailinator.com (Mark Tolonen) Date: Sun, 27 Apr 2008 20:09:58 -0700 Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> <48131f57$0$14357$e4fe514c@news.xs4all.nl> <4ca7b83c-0ca4-4e38-95e5-264780d30ec0@56g2000hsm.googlegroups.com> Message-ID: wrote in message news:4ca7b83c-0ca4-4e38-95e5-264780d30ec0 at 56g2000hsm.googlegroups.com... > On Apr 26, 7:25 am, Irmen de Jong wrote: >> s0s... at gmail.com wrote: >> > Until now, I've been >> > doing this little trick: >> >> > data = client.recv(256) >> > new = data >> > while len(new) == 256: >> > new = client.recv(256) >> > data += new >> >> Are you aware that recv() will not always return the amount of bytes >> asked for? >> (send() is similar; it doesn't guarantee that the full buffer you pass to >> it will be >> sent at once) >> >> I suggest reading >> this:http://www.amk.ca/python/howto/sockets/sockets.html >> >> --irmen > > So every time I use I want to send some thing, I must use > > totalsent = 0 > while sent < len(data): > sent = sock.send(data[totalsent:]) > totalsent += sent > > instead of a simple sock.send(data)? That's kind of nasty. Also, is it > better then to use sockets as file objects? Maybe unbuffered? I think you meant: while totalsent < len(data): Python also has the sendall() function. -Mark From ellingt8877 at gmail.com Mon Apr 28 01:49:34 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:49:34 -0700 (PDT) Subject: keygen studio Message-ID: <1e3b1aa9-e47a-49c6-af28-fd1d8737f437@z24g2000prf.googlegroups.com> keygen studio http://crack.cracksofts.com From cool.sumitc at gmail.com Mon Apr 7 02:54:46 2008 From: cool.sumitc at gmail.com (Sumit) Date: Sun, 6 Apr 2008 23:54:46 -0700 (PDT) Subject: while-loops enter the last time after condition is filled? References: Message-ID: <8b3cf9b5-4add-4f13-9f18-7f16c0384d94@n14g2000pri.googlegroups.com> On Apr 6, 4:53?am, skanem... at yahoo.se wrote: > it seems to me from my results that when i use a while-loop it will > execute once after the condition is met. Perhaps your condition is wrong. Please provide the code where this occured. From kay.schluehr at gmx.net Sat Apr 12 11:51:04 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 12 Apr 2008 08:51:04 -0700 (PDT) Subject: str(bytes) in Python 3.0 References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> <436931a6-9ed1-4a84-83ad-c35df915df4c@m44g2000hsc.googlegroups.com> Message-ID: <806cf1da-8f06-4fff-8437-7f1ca1ff9472@k10g2000prm.googlegroups.com> On 12 Apr., 16:29, Carl Banks wrote: > > And making an utf-8 encoding default is not possible without writing a > > new function? > > I believe the Zen in effect here is, "In the face of ambiguity, refuse > the temptation to guess." How do you know if the bytes are utf-8 > encoded? How many "encodings" would you define for a Rectangle constructor? Making things infinitely configurable is very nice and shows that the programmer has worked hard. Sometimes however it suffices to provide a mandatory default and some supplementary conversion methods. This still won't exhaust all possible cases but provides a reasonable coverage. From fetchinson at googlemail.com Wed Apr 16 22:25:51 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Wed, 16 Apr 2008 19:25:51 -0700 Subject: index of list of lists In-Reply-To: <1208398552l.41837l.0l@ns.bitcarrier.eu> References: <1208398552l.41837l.0l@ns.bitcarrier.eu> Message-ID: > yes, there's a thread with the same title, but I believe mine is more > appropriate title. > so, as much as I search on the web, read manuals, tutorials, mail-lists > (including this one) I cannot figure it out how to search a string in a > list of lists. > like this one: > > someList = [['somestring', 1, 2], ['oneother', 2, 4]] > > I want to search "somestring" in someList which is in practice a list > of aprox. 200 lists. (hey, I'm a newbie python programmer, don't judge > me). > is the list.index the wrong approach? > should I use numpy, numarray, something else? > can anyone, be kind and help me with this? someList = [['somestring', 1, 2], ['oneother', 2, 4]] for alist in someList: if alist[0] == 'somestring': print "Found it at index %d" % someList.index( alist ) # if you know it will only occur once you might say: break HTH, Daniel From cyberco at gmail.com Tue Apr 8 14:51:53 2008 From: cyberco at gmail.com (Berco Beute) Date: Tue, 8 Apr 2008 11:51:53 -0700 (PDT) Subject: Google App Engine References: Message-ID: <3b6737c8-9d42-4218-ac60-01df2f578746@p39g2000prm.googlegroups.com> It's wonderful news for Python. It will definitely be a boost for Python's (and Django's) popularity. Python finally seems to be on every developers mind at the moment. Looks like it's showtime for Python! From bg at bg.fr Tue Apr 8 11:16:41 2008 From: bg at bg.fr (Bruno GUERPILLON) Date: Tue, 8 Apr 2008 17:16:41 +0200 Subject: List open files Message-ID: <47fb8d54$0$15068$426a74cc@news.free.fr> Hi, I'd like, in a WIN32 environment, list all open files. Anyone got a clue how to do this ? Regards, Bruno. From bruno.desthuilliers at gmail.com Thu Apr 17 14:42:56 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Thu, 17 Apr 2008 11:42:56 -0700 (PDT) Subject: noobie question about mailman References: <2008041714045350073-elgeee@yahoocom> Message-ID: <9b791903-d935-46fd-9ec4-49df4ed273d5@2g2000hsn.googlegroups.com> On 17 avr, 20:04, lg wrote: > Hello, > > I'm pretty new to usenet and totally new to python, so.. hopefully i > won't offend anyone with my naivete. I work at a non-profit > organization where we use mailman for our email lists, and i've > inhereted the task of being list administrator from my > sadly-recently-and-unjustly-terminated coworker. > > Anyway, I'd to know more about working with mailman from the command > line. For example, I know it must not be toooo complex to have mailman > export a csv doc of all the members of a lis (instead of having to look > through members using the web interface for administrators). Can > anyone point me in the direction of a forum, email list, or good > tutorial to get me started? Any insight *mucly* appreciated! A general rule is to start with the project's page, doc and mailinglist. Here we have (first hit on google for 'mailman'): http://www.gnu.org/software/mailman/ which itself points to - amongst other ressources - the documentation: http://www.gnu.org/software/mailman/docs.html and the mailing list: http://www.gnu.org/software/mailman/lists.html All questions related to mailman itself should go there, since that's where you'll find the most knowledgeable peoples. And don't forget to read the doc before posting your questions - not understanding some point in the doc is ok, failing to find something in the doc is ok, but failing to *read* the doc first is a big mistake. If the answers to your questions wrt/ mailmain require more Python knowledge than you actually have, then start with Python's doc (and the tutorial), then post here, and we'll gladly help if we can. Also, since you mention being new to usenet, the following might be a good read too: http://catb.org/~esr/faqs/smart-questions.html NB: don't take what's written there to the letter - there are hopefully some newsgroups that are very tolerant and newbie-friendly (like this one here) - but understanding the overall spirit may help you getting best answers. HTH Bruno From gagsl-py2 at yahoo.com.ar Tue Apr 8 00:10:52 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 08 Apr 2008 01:10:52 -0300 Subject: Adding Images To MySQL References: <4dc0cfea0804050732x7dc2ac41n64d56dda9da27a82@mail.gmail.com> <4dc0cfea0804071117n49dd6faam90032dbc787487e5@mail.gmail.com> Message-ID: En Mon, 07 Apr 2008 15:17:26 -0300, Victor Subervi escribi?: >> sql = "insert into PRODUCTS (PRODID, NAME, DESCRIPTION) " \ >> "values (%s,%s,%s);" >> cursor.execute(sql, (prodid, prodname, description)) >> >> and it works fine. >> >> Note that execute has two arguments: first, a string with the sql >> statement text; second, a tuple containing the values. The %s in the sql >> text are placeholders, they're replaced with the corresponding value >> from >> the second argument. And there is no ' anywhere. > > Well, what I did, that now works, was essentially what you suggested, and > simply assigned null values to variables that accept null values in the > database. That works. What I was trying to do was build up just those > variables that were to be updated or entered, and supply only those > arguments. At this point it is rather academic, but can that be done? Suppose you have the list of non-null column names in a variable `col_names` and their values in another list `col_values` column_part = ','.join(col_names) # all,column,names,with,commas pct_part = ','.join('%s' for _ in col_names) # as many "%s" as columns sql = "insert into PRODUCTS (%s) values (%s);" % (column_part, pct_part) cursor.execute(sql, col_values) Perhaps you find more convenient to build a dictionary with column name, value: ok, then col_names above would be the keys() from the dictionary, and you can figure out how to get col_values. > Amazingly (because I thought I had tested this) both the escape string > and > the db Binary work now. Glad to see that. > I said it did not work in the other page, but now it does. Anyway, what > gets > uploaded is a binary string. How can I convert that into a pretty > picture? By serving it as the appropiate MIME type, image/jpeg by example. You don't have to "convert" anything, just return the same thing previously stored in the database. Again, test locally first: see if you can store a picture in the database and then retrieve it again without problems (locally, not thru the web). Next step would be to use the web server but no database access, just reading a picture from a file: content = open('image.jpg', 'rb').read() print "Content-Type: image/jpeg\nContent-Length: %d\n" % len(content) print content The last step would be to replace the first line with a database query. -- Gabriel Genellina From johnjsal at gmailNOSPAM.com Wed Apr 23 23:12:33 2008 From: johnjsal at gmailNOSPAM.com (John Salerno) Date: Wed, 23 Apr 2008 23:12:33 -0400 Subject: Lists: why is this behavior different for index and slice assignments? In-Reply-To: <480e832d@news.mel.dft.com.au> References: <480d435b$0$11643$607ed4bc@cv.net> <480e7f61$0$25046$607ed4bc@cv.net> <480e832d@news.mel.dft.com.au> Message-ID: <480ffaae$0$11639$607ed4bc@cv.net> John Machin wrote: > Deletion occurs *only* in the corner case where there are no "assigned > elements" i.e. only if the RHS list (sequence) is *empty*. Oh, it was my understanding that deletion always occurs, even when the section is being assigned a non-empty value, i.e. delete the slice and insert new value. Otherwise > there would be no point at all in the language having assignment to a > slice -- del L[0:2] would suffice. Right, but I'm wondering why a statement like L[0:2] = [] doesn't assign an empty list as the new element in L. For example: L = [1, 2, 3, 4, 5] L[0:2] = [] Why doesn't L now equal [[], 3, 4, 5] as it does with an index assignment? > >>> L[0:2] = tuple('foobar') > >>> L > ['f', 'o', 'o', 'b', 'a', 'r', 3, 4, 5] Hmm...why doesn't L equal [('f', 'o', 'o', 'b', 'a', 'r'), 3, 4, 5] ? Shouldn't L be a 4 item list instead of 9? From sales024 at aaa-replica-watch.com Tue Apr 1 00:44:44 2008 From: sales024 at aaa-replica-watch.com (sales024 at aaa-replica-watch.com) Date: Mon, 31 Mar 2008 21:44:44 -0700 (PDT) Subject: Cheap Oris TT3 Watches Replica - Oris Watches Wholesale Message-ID: Cheap Oris TT3 Watches Replica - Oris Watches Wholesale AAA Replica Watches : http://www.watches-replicas.com Oris Watches Brands : http://www.watches-replicas.com/oris-watches.html Replica Oris TT3 Watches : http://www.watches-replicas.com/oris-tt3-watches.html China largest replica watches wholesaler, wholesale up to 80% of Oris TT3 Replica Watches and Oris TT3 Fake Watch. The most famous Swiss brand name watches you can find, replica Oris TT3 Watches and fake Oris TT3 Watches are also available. All our Oris TT3 Watches replicas are crafted in high quality, You will get great profite by ordering our good cheap watches. Oris TT3 Watches All Products : Oris TT3 Day Date Titanium Mens Watch 635-7589-7067MB : http://www.watches-replicas.com/oris-tt3-day-date-watch-635-7589-7067MB-3455.html Oris TT3 Day Date Titanium Black Rubber Mens Watch 635-7588-7069RS : http://www.watches-replicas.com/oris-tt3-day-date-watch-63575887069RS-3456.html Oris TT3 Day Date Titanium Mens Watch 635-7589-7067RS : http://www.watches-replicas.com/oris-tt3-day-date-watch-635-7589-7067RS-3457.html Oris TT3 Day Date Titanium Mens Watch 635-7589-7064RS : http://www.watches-replicas.com/oris-tt3-day-date-watch-635-7589-7064RS-3458.html Oris TT3 Day Date Titanium Mens Watch 635-7589-7064MB : http://www.watches-replicas.com/oris-tt3-day-date-watch-635-7589-7064MB-3459.html Oris TT3 Day Date Titanium Mens Watch 635-7588-7069MB : http://www.watches-replicas.com/oris-tt3-day-date-watch-635-7588-7069MB-3460.html Oris TT3 Day Date Titanium Mens Watch 635-7588-7067RS : http://www.watches-replicas.com/oris-tt3-day-date-watch-635-7588-7067RS-3461.html Oris TT3 Day Date Titanium Mens Watch 635-7588-7064MB : http://www.watches-replicas.com/oris-tt3-day-date-watch-635-7588-7064MB-3462.html Oris TT3 Day Date Titanium Mens Watch 635-7589-7067MB : http://www.watches-replicas.com/oris-tt3-day-date-watch-635-7588-7067MB-3463.html The Same Oris Replica Watches Series : Oris Williams F1 Watches : http://www.watches-replicas.com/oris-williams-f1-watches.html Oris Frank Sinatra Watches : http://www.watches-replicas.com/oris-frank-sinatra-watches.html Oris Artelier Watches : http://www.watches-replicas.com/oris-artelier-watches.html Oris Big Crown Watches : http://www.watches-replicas.com/oris-big-crown-watches.html Oris Flight Timer Watches : http://www.watches-replicas.com/oris-flight-timer-watches.html Newly Added Oris Watches : http://www.watches-replicas.com/newly-added-oris-watches.html Oris Divers Watches : http://www.watches-replicas.com/oris-divers-watches.html Oris TT3 Watches : http://www.watches-replicas.com/oris-tt3-watches.html From gagsl-py2 at yahoo.com.ar Mon Apr 21 10:17:03 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 11:17:03 -0300 Subject: how to pass C++ object to another C++ function via Python function References: <1810b155-5598-4f17-a8e9-e4aa848db5de@i36g2000prf.googlegroups.com> Message-ID: En Mon, 21 Apr 2008 10:24:15 -0300, grbgooglefan escribi?: > I am trying to pass a C++ object to Python function. This Python > function then calls another C++ function which then uses this C++ > object to call methods of that object's class. > > I tried something like this, but it did not work, gave core dump. You can't pass any arbitrary C object to a Python function. In this case you can use a PyCObject, a Python box around a void* pointer. See http://docs.python.org/api/cObjects.html > // compile this Python function using PyRun_String & get its pointer > by PyObject_GetAttrString. > // Later call it as below: > myclass myobj(23); > PyObject *pTuple = 0; > pTuple = PyTuple_New(2); > PyTuple_SetItem(pTuple,0,PyString_FromString("NAME")); // for t167 > parameter > PyObject *inputarg = Py_BuildValue("OO&",pTuple,myobj); // for > classobj parameter > > result = PyObject_CallObject(pPyEvalFunction,inputarg); > } > > How can I pass this class object to Python function? > Is it possible to set it in tuple using PyTuple_SetItem, because I may > have varying number of arguments for my Python functions & that's why > I can't use Py_BuildValue. You have to check every call for errors, and pay attention to the reference counts! The argument passing is wrong. You never set the second tuple element. An easier way is using PyObject_CallFunctionObjArgs(function, arg1, arg2, NULL) -- Gabriel Genellina From sturlamolden at yahoo.no Sun Apr 20 10:22:41 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sun, 20 Apr 2008 07:22:41 -0700 (PDT) Subject: "Help needed - I don't understand how Python manages memory" References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> Message-ID: <7cbe5fed-a9c5-46ef-82e9-90340f676b90@l42g2000hsc.googlegroups.com> On Apr 20, 2:46 pm, "Hank @ITGroup" wrote: > That is my question, after ``del``, sometimes the memory space returns > back as nothing happened, sometimes not... ... > What exactly was happening??? Python has a garbage collector. Objects that cannot be reached from any scope is reclaimed, sooner or later. This includes objects with reference count of zero, or objects that participate in unreachable reference cycles. Since Python uses a reference counting scheme, it does not tend to accumulate so much garbage as Java or .NET. When the reference count for an object drops to zero, it is immediately freed. You cannot control when Python's garbage collector frees an object from memory. What del does is to delete the object reference from the current scope. It does not delete the object from memory. That is, the del statement decrements the reference count by one, and removes the reference from the current scope. Whether it should removed completely depends on whether someone else is using it. The object is not reclaimed unless the reference count has dropped all the way down to zero. If there still are references to the object other places in your program, it is not reclaimed upon your call to del. From stefan_ml at behnel.de Fri Apr 11 05:59:39 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Fri, 11 Apr 2008 11:59:39 +0200 Subject: CDATA and lxml In-Reply-To: <5ebe3201-80a6-45ba-8b88-e8ece6883efa@w8g2000prd.googlegroups.com> References: <5ebe3201-80a6-45ba-8b88-e8ece6883efa@w8g2000prd.googlegroups.com> Message-ID: <47FF368B.4030708@behnel.de> Silfheed wrote: > So first off I know that CDATA is generally hated and just shouldn't > be done, but I'm simply required to parse it and spit it back out. > Parsing is pretty easy with lxml, but it's the spitting back out > that's giving me issues. The fact that lxml strips all the CDATA > stuff off isnt really a big issue either, so long as I can create > CDATA blocks later with <>&'s showing up instead of <>& . > I've scoured through the lxml docs, but probably not hard enough, so > anyone know the page I'm looking for or have a quick how to? There's nothing in the docs because lxml doesn't allow you to create CDATA sections. You're not the first one asking that, but so far, no one really had a take on this. It's not as trivial as it sounds. Removing the CDATA sections in the parser is just for fun. It simplifies the internal tree traversal and text aggregation, so this would be affected if we allowed CDATA content in addition to normal text content. It's not that hard, it's just that it hasn't been done so far. Stefan From fetchinson at googlemail.com Thu Apr 10 13:14:29 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Thu, 10 Apr 2008 10:14:29 -0700 Subject: Python conventions In-Reply-To: References: Message-ID: > I assembled a good conventions set for Java. View it at > http://www.martinrinehart.com/articles/code-conventions.html (is that > better, Steve?) > > It followed a logical organization; it was built from four other > extensive (if not well-organized) convention sets and it scrupulously > avoided injecting my own biases. Where there were disagreements, they > were noted and the opposing viewpoints explained. > > I'm appointing myself project secretary of a similar effort for > Python, until we can find someone better qualified (Python experience > pre-dating my late '07 start would be better qualified). The > secretary's job is to ask questions and correctly record answers. > First question: > > global (e.g., what language for comments) > package > module > class > methods > data > function > statement > expression > variable > > Is this a good outer-level organization? > > For each topic, cover: > > documentation > naming convention(s) > format > > Second question: are the above the items we cover for each topic? > Others? I'm sorry to disappoint you but this project has already been completed: http://www.python.org/dev/peps/pep-0008/ Cheers, Daniel From deets at nospam.web.de Wed Apr 23 14:42:44 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 23 Apr 2008 20:42:44 +0200 Subject: Calling Python code from inside php In-Reply-To: References: Message-ID: <679e9oF2mti63U1@mid.uni-berlin.de> vijay schrieb: > Hi > I have a python code performing some computation for me.I have a > html page which passes certain argumnets to a php page.This php page > needs to pass on the value to the Python class and get the result > back. > How do I go about this?? Write a commandline-app in python, that does the work for you. Invoke that using php. Or use something like pyphp - but I haven't used it, can't comment on its usability/support etc. Diez From miki.tebeka at gmail.com Mon Apr 14 23:48:28 2008 From: miki.tebeka at gmail.com (Miki) Date: Mon, 14 Apr 2008 20:48:28 -0700 (PDT) Subject: How to get the version of a file References: Message-ID: <60199810-f80d-46e6-b402-df4707ff2d1a@w1g2000prd.googlegroups.com> Hello J, > Does anyone know how to get the version of an application on OS X (i.e. > the version string that appears in the "Version" field in the "Get Info" > window for an application)? > > I'm running OS 10.4.11, python 2.5. #!/usr/bin/env python from xml.etree.cElementTree import iterparse from os.path import isfile def get_version(app): info_file = "/Applications/%s.app/Contents/Info.plist" % app if not isfile(info_file): raise KeyError("No version file found") get = 0 for event, element in iterparse(open(info_file)): if get: return element.text if (element.tag == "key") and (element.text == "CFBundleVersion"): get = 1 raise KeyError("Can't find CFBundleVersion key") if __name__ == "__main__": from sys import argv print get_version(argv[1]) HTH, -- Miki http://pythonwise.blogspot.com From musiccomposition at gmail.com Tue Apr 15 22:41:16 2008 From: musiccomposition at gmail.com (Benjamin) Date: Tue, 15 Apr 2008 19:41:16 -0700 (PDT) Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <101680ba-a116-414b-8fff-c5b5bd2f4b65@p39g2000prm.googlegroups.com> Message-ID: <60a51c16-30fc-4d74-a50c-11f7f51138e7@b1g2000hsg.googlegroups.com> On Apr 15, 9:17 pm, lxlau... at gmail.com wrote: > On 11 abr, 20:31, sturlamolden wrote: > > > On Apr 11, 5:01 am, "Gabriel Genellina" > > wrote: > > > > Another annoying thing with the Qt license is that you have to choose it > > > at the very start of the project. You cannot develop something using the > > > open source license and later decide to switch to the commercial licence > > > and buy it. > > > Trolltech is afraid companies will buy one licence when the task is > > done, as oppsed to one license per developer. In a commercial setting, > > the Qt license is not expensive. It is painful for hobbyists wanting > > to commercialize their products. > > I have no experience with GUI programming in Python, but from this > discussion it seems if the type of license is not an issue (for FOSS > development), PyQt is the best tool because it is: > (a) easier to learn and intuitive for programming (this is important > to me; I am not that smart...); > (b) more stable (although many people have said that wxPython is as > stable as any other GUI nowadays; but not more stable (wx) than > others); > (c) more cross-platform (many people complain that they have to do a > lot of things in wxPython for the cross-platform). > > Is (a) and (c) true or not? If so, how big are these advantages? I find the PyQt API very well designed and intuitive. You can easily write simple cross-platform apps in wxPython or PyQt, but wxPython tends to have sketchy support in some places. Trolltech tries really hard to smooth over all the platform differences, so I find it a bit cleaner. > > The great advantage of wxPython seems to be the huge community of > users and the large number of widgets/examples/applications available. > > Reformulating my question: > > Which GUI tool, wxPython or PyQt, is more pythonic? (Please, ignore > the license issue because I am thinking about FOSS) None of them are very pythonic because they are all based on C++ toolkits. (sigh) > > Laura From steve at holdenweb.com Wed Apr 23 01:40:58 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 01:40:58 -0400 Subject: Python Success stories In-Reply-To: References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: Roy Smith wrote: > In article , > Steve Holden wrote: > >> Challenge him to a dual with dead kippers at twenty paces. > > You gotta be careful about stuff like this. You might slap him with a dead > kipper only to discover he's got a dead camel in his pocket. > > Of course, there's always http://en.wikipedia.org/wiki/Wikipedia:Trout Damn, pilchards, that was it! regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From georgeencina at gmail.com Mon Apr 7 02:43:01 2008 From: georgeencina at gmail.com (georgeencina at gmail.com) Date: Sun, 6 Apr 2008 23:43:01 -0700 (PDT) Subject: Getting jabber:iq:last with xmpppy Message-ID: <19d54615-591d-4251-af63-630e2d53d30b@m36g2000hse.googlegroups.com> Hi, I'm trying to do the following with the xmpppy library: - log on to the google jabber server - get idle time of one specific person on my roster. Idle time means the values of jabber:iq:last. When I do this in pidgin with the xmpp console open, I get the following conversation: (me) (other person) Now, I'd like to do the same in python. I'm logged in to the server with the following code. import xmpp login = 'georgeencina' # @gmail.com pwd = 'secret' cnx = xmpp.Client('gmail.com') cnx.connect( server=('talk.google.com',5223) ) cnx.auth(login,pwd, 'idlewatcher') What would be the next step? I saw there is an xmpp.Iq class, which I suppose is what I need to work with to construct the message I observed in Pidgin. Does anyone have some quick lines of code on how to construct and send the message, and how to receive the response? Thanks, George From micro_passion at yahoo.com Mon Apr 28 07:03:36 2008 From: micro_passion at yahoo.com (micron_make) Date: Mon, 28 Apr 2008 04:03:36 -0700 (PDT) Subject: multiple pattern regular expression In-Reply-To: <4811D5FB.8040109@jouy.inra.fr> References: <16895148.post@talk.nabble.com> <4811D5FB.8040109@jouy.inra.fr> Message-ID: <16936657.post@talk.nabble.com> each of the suggested methods fit in. I have started trying them. -Rohit -- View this message in context: http://www.nabble.com/multiple-pattern-regular-expression-tp16895148p16936657.html Sent from the Python - python-list mailing list archive at Nabble.com. From pylists at arcor.de Mon Apr 14 04:54:09 2008 From: pylists at arcor.de (Penny Y.) Date: Mon, 14 Apr 2008 16:54:09 +0800 Subject: =?gb2312?B?tPC4tDogSmF2YSBvciBDKys/?= In-Reply-To: Message-ID: <20080414085431.D8751187B00@mail-in-14.arcor-online.net> Javascript is different from Java at all. Why not Perl? Perl is a functional language, that will show you another way of programming. Also C is good, will teach you some system level knowledge. :) -----????----- ???: python-list-bounces+pylists=arcor.de at python.org [mailto:python-list-bounces+pylists=arcor.de at python.org] ?? Marco Mariani ????: 2008?4?14? 16:38 ???: python-list at python.org ??: Re: Java or C++? s0suk3 at gmail.com wrote: > Which one do you think will educate me the best? Advanced javascript might teach you something too, and be very useful at the same time. From __peter__ at web.de Sun Apr 6 16:45:30 2008 From: __peter__ at web.de (Peter Otten) Date: Sun, 06 Apr 2008 22:45:30 +0200 Subject: Tkinter, a lot of buttons, make prog shorter? References: Message-ID: skanemupp at yahoo.se wrote: > is there anyway to make this shorter? i hate having these big blocks > of similar-looking code, very unaesthetic. > maybe doesnt matter good-code-wise? > anyway can i make some function that makes this shorter? > like put the etiquettes on the button froma string of > '123+456-789*0Cr/' ? > problem is the command and lambda-func for each button is different. You can look up the command in a dictionary: commands = {"C": self.Clean} top = 3 for i, text in enumerate("123+456-789*0Cr/"): row, column = divmod(i, 4) try: command = commands[text] except KeyError: def command(n=text): self.Display(n) button = Button(self, text=text, command=command, width=2, height=2) button.grid(row=top+row, column=column) The problem with this is that the shorter code may take a bit longer to understand, so that there is no net win for the reader. A compromise would be to define a helper function: def make_button(self, row, column, text, command): # implementation left as an exercise # use it: self.make_button(3, 0, "1", lambda n="1": ...) self.make_button(3, 1, "2", lambda n="2": ...) ... Peter From pavlovevidence at gmail.com Wed Apr 9 02:26:06 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 8 Apr 2008 23:26:06 -0700 (PDT) Subject: text adventure game problem References: Message-ID: On Apr 9, 1:24 am, Dennis Lee Bieber wrote: > On Tue, 8 Apr 2008 18:01:01 -0700 (PDT), corvettecra... at gmail.com > declaimed the following in comp.lang.python: > > > okay, I'm having this one problem with a text adventure game. It's > > kind of hard to explain, but I'll do my best. > > [code] > > > def prompt_kitchen(): > > global gold > > gold_taken = False > > while True: > > prompt_kit = raw_input('>') > > if prompt_kit == 'examine cabinet 1' and not gold_taken: > > print '''This cabinet has a lot of cups in it with all > > different > > designs and shapes. Where are the people anyway? How come there's > > nobody here? > > In one of the cups you find 8 gold.''' > > Forgive me, but.... Ugh! > > It looks like you are defining a function for each possible room > which incorporates code for the actions possible in that room... > > I suspect I'd try to create a generic room class which has as > attributes a dictionary of actions and a dictionary of movable objects. > Along with methods that work on objects... Working an action that digs > into other objects may take some doing. [snip] I don't know about you, but I usually start with specific cases like this and then generalize them. This could be a baby step, or merely a first stage of evolution. Carl Banks From google at mrabarnett.plus.com Thu Apr 17 11:42:35 2008 From: google at mrabarnett.plus.com (MRAB) Date: Thu, 17 Apr 2008 08:42:35 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <52vid5-cvl2.ln1@ozzie.tundraware.com> <87hce1t8k5.fsf@physik.rwth-aachen.de> Message-ID: On Apr 17, 5:22 am, Torsten Bronger wrote: > Hall?chen! > > Tim Daneliuk writes: > > Daniel Fetchinson wrote: > > >> [...] > > >>> I just had one moment of exceptional clarity, during which > >>> realized how I could get the GIL out of my way... It's so > >>> simple, I cannot help wondering why nobody has thought of it > >>> before. [...] > > >> If I were you I would keep it a secret until a Hollywood producer > >> offers big bucks for the film rights. > > > Who would play Guido, I wonder? > > Ralf M?ller. No other. > If you're not careful Hollywood might re-invent Guido as an all- American hero, Guy Ross! :-) From dolloffdelvpg at gmail.com Wed Apr 16 08:09:24 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:09:24 -0700 (PDT) Subject: taylor swift a place in this world lyrics Message-ID: <1da57e7a-3462-4f7b-8a0f-beccfa48380c@d26g2000prg.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From matthieu.brucher at gmail.com Sat Apr 5 13:42:33 2008 From: matthieu.brucher at gmail.com (Matthieu Brucher) Date: Sat, 5 Apr 2008 19:42:33 +0200 Subject: =?ISO-8859-1?Q?Re:_[Python-Fr]_"keyword_arguments"_en_fran=E7ais?= In-Reply-To: <20080405172929.GA14059@phare.normalesup.org> References: <20080405172929.GA14059@phare.normalesup.org> Message-ID: J'appelle ?a les arguments nomm?s (parfois en anglais on parle de named argument). Je pense que tu parles des arguments donn?s dans les **kwargs, c'est ?a ? On parle aussi d'arguments formels, par opposition aux arguments positionnels lors d'un appel directement ? une fonction : pour machin(0, x=1), le premier est un argument positionnel, le second est un argument formel. Matthieu 2008/4/5, Gael Varoquaux : > > Je voudrais savoir s'il y a un moyen canonique d'appeller les "keyword > arguments" en fran?ais. > > Merci, > > Ga?l > > > -- > Gerez vos abonnements aux listes de diffusion : http://listes.aful.org > -- French PhD student Website : http://matthieu-brucher.developpez.com/ Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92 LinkedIn : http://www.linkedin.com/in/matthieubrucher -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Tue Apr 1 02:00:14 2008 From: timr at probo.com (Tim Roberts) Date: Tue, 01 Apr 2008 06:00:14 GMT Subject: Rubik's cube translation References: <3f3817e8-db90-4bbb-9d6e-cddf042ff6de@a22g2000hsc.googlegroups.com> <489180f4-aa43-4d98-a67d-71ce06ea9152@x41g2000hsb.googlegroups.com> Message-ID: <1mj3v35u8ai9bijik3gggdrdhm07qaf7v0@4ax.com> castironpi at gmail.com wrote: > >What if this is connected: > >>>> D >array([[1, 2, 3], > [4, 5, 6], > [6, 7, 8]]) >>>> E >array([[6, 7, 8], > [0, 0, 0], > [0, 0, 0]]) > >--> > >>>> D >array([[1, 2, 3], > [4, 5, 6], > [6, 7, 8]]) >>>> E >array([[6, 7, 8], > [0, 0, 0], > [0, 0, 0]]) >>>> numpy.rot90( D ) >array([[3, 6, 8], > [2, 5, 7], > [1, 4, 6]]) >--> >>>> E >array([[1, 4, 6], > [0, 0, 0], > [0, 0, 0]]) > >? If you don't want changes to D to affect E, then you need to disconnect them when you create them. If you create D and E so that they contain references to the same lists, then this kind of thing will happen. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From suzhi18 at googlemail.com Wed Apr 9 03:38:43 2008 From: suzhi18 at googlemail.com (suzhi18 at googlemail.com) Date: Wed, 9 Apr 2008 00:38:43 -0700 (PDT) Subject: makepy.py not working References: <03e9c33d-d957-4bc0-8568-3a40403eadb9@a70g2000hsh.googlegroups.com> Message-ID: <76357711-bdb8-400b-8b61-1361f02d7d36@m44g2000hsc.googlegroups.com> Ok, thanks for your help. After looking into the makepy.py file it was clear that this is only a command for the CMD console. I want to write a function which generates this .py file of the excel objects. I will now send the command to the CMD threw my python code. thanks again. suzhi From mail at timgolden.me.uk Tue Apr 8 15:11:17 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 08 Apr 2008 20:11:17 +0100 Subject: set file permission on windows In-Reply-To: References: <7d75fc7b-a2b7-4ca2-b386-27da975043d0@m44g2000hsc.googlegroups.com> Message-ID: <47FBC355.3060203@timgolden.me.uk> Tim Arnold wrote: > "Mike Driscoll" wrote in message > news:7d75fc7b-a2b7-4ca2-b386-27da975043d0 at m44g2000hsc.googlegroups.com... >> On Apr 8, 12:03 pm, "Tim Arnold" wrote: >>> > >> According to the following thread, you can use os.chmod on Windows: >> >> http://mail.python.org/pipermail/python-list/2003-June/210268.html >> >> You can also do it with the PyWin32 package. Tim Golden talks about >> one way to do it here: >> >> http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html >> >> Also see the following thread: >> >> http://mail.python.org/pipermail/python-win32/2004-July/002102.html >> >> or >> >> http://bytes.com/forum/thread560518.html >> >> Hope that helps! >> >> Mike > > Hi Mike, > It does help indeed, especially the last two links. Hi, Tim. For the purposes of improving that page of mine linked above, would you mind highlighting what made it less useful than the last two links? On the surface, it seems to match your use case pretty closely. Was there too much information? Too little? Poor formatting? Just didn't feel right? I've a small set of security-related pages in train and I'd rather produce something which people find useful. Thanks TJG From karthikk at adventnet.com Thu Apr 24 04:48:24 2008 From: karthikk at adventnet.com (Karthik) Date: Thu, 24 Apr 2008 14:18:24 +0530 Subject: [Python-Dev] annoying dictionary problem, non-existing keys In-Reply-To: <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> Message-ID: <48104958.2070904@adventnet.com> bvidinli wrote: > I posted to so many lists because, > > this issue is related to all lists, > this is an idea for python, > this is related to development of python... > > why are you so much defensive ? > > i think ideas all important for development of python, software.... > i am sory anyway.... hope will be helpful. > > 2008/4/24, Terry Reedy : > >> Python-dev is for discussion of development of future Python. Use >> python-list / comp.lang.python / gmane.comp.python.general for usage >> questions. >> >> >> >> _______________________________________________ >> Python-Dev mailing list >> Python-Dev at python.org >> http://mail.python.org/mailman/listinfo/python-dev >> Unsubscribe: http://mail.python.org/mailman/options/python-dev/bvidinli%40gmail.com >> >> > > > Is this an acceptable alternative? try: if conf['key1'] == 'something': except KeyError: pass Regards, Karthik -------------- next part -------------- An HTML attachment was scrubbed... URL: From jgodoy at gmail.com Sun Apr 27 12:12:21 2008 From: jgodoy at gmail.com (Jorge Godoy) Date: Sun, 27 Apr 2008 13:12:21 -0300 Subject: design choice: multi-threaded / asynchronous wxpython client? References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> <002cd046-f11d-482e-a67d-4a10a97687a1@x19g2000prg.googlegroups.com> Message-ID: bullockbefriending bard wrote: > A further complication is that at a later point, I will want to do > real-time time series prediction on all this data (viz. predicting > actual starting prices at post time x minutes in the future). Assuming > I can quickly (enough) retrieve the relevant last n tote data samples > from the database in order to do this, then it will indeed be much > simpler to make things much more DB-centric... as opposed to > maintaining all this state/history in program data structures and > updating it in real time. If instead of storing XML and YAML you store the data points, you can do everything from inside the database. PostgreSQL supports Python stored procedures / functions and also support using R in the same way, for manipulating data. Then you can work with everything and just retrieve the resulting information. You might try storing the raw data and the XML / YAML, but I believe that keeping those sync'ed might cause you some extra work. From fetchinson at googlemail.com Mon Apr 14 16:49:38 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Mon, 14 Apr 2008 13:49:38 -0700 Subject: mod_python In-Reply-To: <4800E3E4.3080508@arcor.de> References: <4800E3E4.3080508@arcor.de> Message-ID: > I want to rewrite a request url under apache2.0 based on its special > header, like, the "Accept-Encoding:" one. > > With C I think I can do it, but since I get begin with python,so I ask > that can I do it under mod_python? what's the guide? The guide is this: http://modpython.org/live/current/doc-html/ HTH, Daniel From dolloffdelvpg at gmail.com Wed Apr 16 08:07:28 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:07:28 -0700 (PDT) Subject: taylor swift come in with the rain Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From easta01 at yahoo.com Thu Apr 24 05:11:05 2008 From: easta01 at yahoo.com (easta01 at yahoo.com) Date: Thu, 24 Apr 2008 02:11:05 -0700 (PDT) Subject: Get Your Frozen Pills Message-ID: <06e3b653-816c-45ad-9541-b844dd986f5f@w4g2000prd.googlegroups.com> http://twilight.110mb.com/gb/piac1.html From malaclypse2 at gmail.com Tue Apr 29 14:37:49 2008 From: malaclypse2 at gmail.com (Jerry Hill) Date: Tue, 29 Apr 2008 14:37:49 -0400 Subject: Simple import question about mac osx In-Reply-To: References: Message-ID: <16651e80804291137u2a21e219h13a2571bd04c7388@mail.gmail.com> On Tue, Apr 29, 2008 at 2:14 PM, jmDesktop wrote: > Thanks. That worked on mac. But it does work like I said in > Windows. Don't know why. Mr. Chun must also be using Windows because > that is the way he does it in his book. It shouldn't work that way on windows either. Can you tell us a little more about what you mean when you say you "compile this" under windows? Normally, python code doesn't need to be compiled, so I'm wondering if you're doing something different from what we expect when you say you compile it and then import it in the interpreter. Are you by any chance writing code in IDLE, running it, then doing things in the interpreter? -- Jerry From colas.francis at gmail.com Thu Apr 17 05:56:56 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Thu, 17 Apr 2008 02:56:56 -0700 (PDT) Subject: def power, problem when raising power to decimals References: <48067bdb@news.mel.dft.com.au> Message-ID: <94e82923-02b0-4575-8bf9-93f0d0a0f33f@k13g2000hse.googlegroups.com> On 17 avr, 00:49, "Gabriel Genellina" wrote: > En Wed, 16 Apr 2008 19:21:18 -0300, John Machin > escribi?: > > > skanem... at yahoo.se wrote: > >> also i found a link which states 0^0 isnt 1 even though every > >> calculator ive tried says it is. > >> it doesnt say what it is but i presume 0 then. > >> but it seems the dude is wrong and it is 1? > > > Of the possible results of 0 ** 0 (i.e. 1, 0, and NaN), 1 seems to be > > the least implausible. It allows X ** 0 to be 1 for all X. > > But a result of 0 would allow 0 ** X to be 0 for all X. (btw, this is the > reason lim(x**x) for x->0 does not exist) lim(x**x) for x->0+ is well defined, exists and equals 1. [1] As x**x is continuous in 0+, it is widely customary to have: 0**0:=1 [1] Recall that x**x := exp(x*log(x)) The limit of x*log(x) for x->0 is 0 [2] therefore lim(x**x) for x->0 is 1. [2] Let y = 1/x; x*log(x)= -log(y)/y and the limit of log(y)/y for y-> +inf is 0. From skye.shaw at gmail.com Fri Apr 18 02:35:45 2008 From: skye.shaw at gmail.com (Skye Shaw!@#$) Date: Thu, 17 Apr 2008 23:35:45 -0700 (PDT) Subject: get quote enclosed field in a line References: <4807dc10$0$25223$e4fe514c@dreader18.news.xs4all.nl> Message-ID: > xah... at gmail.com wrote: > > is there a simple way in perl, python, or awk/shell/pipe, that gets > > the user agent field in a apache log? > Something like: > # cut -d '"' -f 6 < httpd-access.log > ? > -- > mph Doesn't it feel like autosplit mode never gets any run time? perl -laF'"' -ne'print $F[5]' access_log From larry.bates at websafe.com Thu Apr 3 23:31:00 2008 From: larry.bates at websafe.com (Larry Bates) Date: Thu, 03 Apr 2008 22:31:00 -0500 Subject: Parsing HTML? In-Reply-To: <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> <36936849-2801-440e-894f-db7c62f6ae66@e10g2000prf.googlegroups.com> Message-ID: <1207279859.7571.220.camel@fc8.home.com> On Wed, 2008-04-02 at 21:59 -0700, Benjamin wrote: > I'm trying to parse an HTML file. I want to retrieve all of the text > inside a certain tag that I find with XPath. The DOM seems to make > this available with the innerHTML element, but I haven't found a way > to do it in Python. I use ElementTree (built into Python 2.5) for this type of XLM query. -Larry From steve at holdenweb.com Wed Apr 23 07:57:24 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 07:57:24 -0400 Subject: Error in Extending/Embedding FAQ, point 16: How do I tell "incomplete input" from "invalid input"? In-Reply-To: <1208944113.4294.32.camel@pippi.pippi> References: <1208877167.4557.37.camel@pippi.pippi> <1208880579.4557.70.camel@pippi.pippi> <1208944113.4294.32.camel@pippi.pippi> Message-ID: Dietrich: The web maintainers list is pydotorg at python.org. Your message will be held for moderation, but will be seen by the team who maintain the web site. regards Steve PS: Anyone who wants to *help* maintain the web site should also email that list. It helps if you are already known to other members of the Python community, but it's not essential. Dietrich Bollmann wrote: > Hi, > > I found a solution thanks to another posting on c++-sig and an answer by > Andreas Kl?ckner :) > > Thank you, Andreas! > > The thread is here: > http://mail.python.org/pipermail/c++-sig/2008-April/thread.html#13470 > > I would like to inform the responsible of the Python Extending/Embedding > FAQ, http://www.python.org/doc/faq/extending/ about the broken code in > the FAQ and the solution I found. > > I hope this might prevent other people from the frustration I found > myself in this morning (...but unfortunately also, at least partly, > from the joy I am experiencing now, after finding the new solution :). > > Does anybody know how to contact the person in charge? > > Thanks, > > Dietrich > > PS: > > Of course, I still wonder about the "invalid syntax" error message / > code I wrote about. But ok, I hope there will be some more adequate > error message / code some day in the future :) > > On Wed, 2008-04-23 at 01:09 +0900, Dietrich Bollmann wrote: >> On Wed, 2008-04-23 at 00:12 +0900, Dietrich Bollmann wrote: >>> The following code for example: >>> >>> >>> eins = [1, >>> ... 2, >>> ... 3] >>> >>> >>> >>> is accepted without any problem by the Python shell. >>> >>> When using the code from the FAQ and entering it line by line >>> ?already the second line causes a simple "invalid syntax" error: >>> >>> >>> eins = [1, >>> ... 2, >>> File "", line 2 >>> 2, >>> ^ >>> SyntaxError: invalid syntax >> By the way - isn't this error message / error code just "wrong" in >> the given situation and therefor kind of a "bug"? >> >> An "end of file" or "incomplete input" error at least would >> describe the situation much better - and be a better base for >> functionality which is based the error code also. >> >> --- >> >> I also thought that I should explain a little bit more exactly, >> what I am intending to do with the code based on >> paragraph 16 (How do I tell "incomplete input" from "invalid input"?) >> of the Extending/Embedding FAQ: >> >> I am using Python as scripting language in an application (blender). >> In order to interface this application from other programs >> I programmed a python command port / command socket >> for this application. >> >> Between other clients I also wrote a shell client which connects via >> the command port to the application. My goal is to make it as similar >> to a normal python shell as possible - and therefor I try to also mimic >> the "intelligent" way of the Python shell to react to Python input: >> >> - when entering a line which is a complete input, >> it is immediately evaluated by the shell and the >> result is printed. >> >> - when the last entered line is erroneous, >> an error message is printed immediately >> >> - when the input is incomplete, Python waits >> for other lines to complete the input >> >> - when the line is part of a function definition etc. >> python waits until an empty line is entered >> before accepting the input as complete. >> >> My problem is to understand when an input is erroneous and >> when it is incomplete - which is impossible with an error message >> like "invalid syntax"... >> >> So here again my question: How can I make the difference >> between an incomplete and an erroneous input? >> >> The code examples in the FAQ worked fine until now - but do not >> anymore for the current Python implementation. >> >> Thanks, Dietrich >> >> By the way: Does anybody know who is responsible for the FAQ >> and could adapt the examples to the current Python version >> by changing the code / annotating it? >> >> >> On Wed, 2008-04-23 at 00:12 +0900, Dietrich Bollmann wrote: >> Hi, >>> Both code examples from paragraph 16 from the Python Extending / >>> Embedding FAQ - 'How do I tell "incomplete input" from "invalid >> input"?' >>> - >>> >> ( http://www.python.org/doc/faq/extending/#how-do-i-tell-incomplete-input-from-invalid-input ) do not work with the current state of Python anymore. >>> In the second code example, the error message returned by Python is >>> checked in order to differentiate errors caused by an incomplete input >>> from other syntax errors: >>> >>> if (PyArg_ParseTuple (val, "sO", &msg, &obj) && >>> !strcmp (msg, "unexpected EOF while parsing")) /* E_EOF */ >>> >>> In the current Python version there are more error messages indicating >> an >>> incomplete Python input and I could make the code work for a while >>> by adding the following strings to the condition: >>> >>> /* error messages indicating an incomplete input */ >>> if (PyArg_ParseTuple(error, "sO", &message, &obj) && >>> (!strcmp(message, "unexpected EOF while parsing") || >>> !strcmp(message, "expected an indented block") || >>> !strcmp(message, "EOF while scanning triple-quoted string") >>> ) >>> ) { /* E_EOF */ >>> >>> but recently there are also cases which generate error messages >>> which are too general to be added to this list. >>> >>> The following code for example: >>> >>> >>> eins = [1, >>> ... 2, >>> ... 3] >>> >>> >>> >>> is accepted without any problem by the Python shell. >>> >>> When using the code from the FAQ and entering it line by line >>> ?already the second line causes a simple "invalid syntax" error: >>> >>> >>> eins = [1, >>> ... 2, >>> File "", line 2 >>> 2, >>> ^ >>> SyntaxError: invalid syntax >>> >>> which is to general to be integrated into the list of tested >>> error messages as it might be caused also by code like: >>> >>> >>> one two >>> File "", line 1 >>> one two >>> ^ >>> SyntaxError: invalid syntax >>> >>> which generates an "invalid syntax" error even in the Python shell. >>> >>> I also tried the first code example of paragraph >>> '16 How do I tell "incomplete input" from "invalid input"?' >>> of the FAQ in order to see if it could be used to make the >>> difference between syntax errors and incomplete code errors. >>> But - as in the case before - the returned error >>> code is E_SYNTAX (14 = Syntax error) and not E_EOF (11 = End Of File) >>> as should be expected. >>> >>> Is there anybody who has an idea how to differentiate the >>> first case from the second in order to mimic the behaviour of >>> the Python shell from c code? >>> >>> If this shouldn't be possible lists split into different lines >>> couldn't be accepted anymore or the feature of the Python shell >>> to described in paragraph 16 of the faq: >>> >>> Sometimes you want to emulate the Python interactive interpreter's >>> behavior, where it gives you a continuation prompt when the input >>> is incomplete (e.g. you typed the start of an "if" statement or you >>> didn't close your parentheses or triple string quotes), but it >> gives >>> you a syntax error message immediately when the input is invalid. >>> >>> would have to be given up and every entered line of code would have >> to >>> be terminated by an empty line before evaluation :( >>> >>> Thanks for any help, Dietrich >>> >>> >>> >>> >> > > -- > http://mail.python.org/mailman/listinfo/python-list -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From lbonafide at yahoo.com Tue Apr 1 15:20:13 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Tue, 1 Apr 2008 12:20:13 -0700 (PDT) Subject: Is this a good time to start learning python? References: <47f1140e$0$735$a729d347@news.telepac.pt> <88fa881e-e59b-4682-801c-90ef08a1480a@a22g2000hsc.googlegroups.com> Message-ID: <1565ced8-afd7-4c32-a6ee-26f9b95d60bc@d45g2000hsc.googlegroups.com> On Apr 1, 2:11?pm, "Eduardo O. Padoan" wrote: > On Tue, Apr 1, 2008 at 3:57 PM, ? wrote: > > On Apr 1, 12:47 pm, "Gabriel Genellina" > > ?wrote: > > ?> En Tue, 01 Apr 2008 13:57:55 -0300, escribi?: > > > ?> > On Mar 31, 1:36 pm, "Gabriel Genellina" > > ?> > wrote: > > > ?> >> Don't be scared by the "backwards incompatible" tag - it's the way to > > ?> >> get > > ?> >> rid of nasty things that could not be dropped otherwise. > > > ?> > I would consider breaking production code to be "nasty" as well. > > > > Please explain how the existence of Python 3.0 would break your production > > ?> code. > > > ?The existence of battery acid won't hurt me either, unless I come into > > ?contact with it. ?If one eventually upgrades to 3.0 -- which is > > ?ostensibly the desired path -- their code could break and require > > ?fixing. > > And how would this happen? I dont know of any good software > distribution that upgrades a component to another major revision > without asking first. The desired path is that, if somene wants to > port his software to Python 3.0, that he follow the migration plan. Of course, that's the point. If you want to upgrade to the next version of Python, you have to fix your code. That stinks. Your other alternative is to remain stuck with Python 2.x, but eventually the support for that will dry up. > Final users will install Python 3.0 as python3.0 anyway, with Python > 2.x as default 'python' binary. > > > ?Backward compatibility is important. ? C++ could break all ties with C > > ?to "clean up" as well, but it would be a braindead move that would > > ?break existing code bases upon upgrade. > > C++ is not C. No one "upgrades" from C to C++. You misunderstand. C++ has a lot of "warts" to maintain backwards compatibility with C. The standards committee could eliminate these warts to make the language "cleaner", but it would break a lot of systems. From sturlamolden at yahoo.no Thu Apr 24 22:31:34 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 19:31:34 -0700 (PDT) Subject: Psyco alternative References: Message-ID: <8b7d9523-1d15-41e5-8b69-39f8250e6a6f@i76g2000hsf.googlegroups.com> On Apr 25, 3:27 am, Steve Holden wrote: > That seems a little harsh: it's Python-in-a-strait-jacket. > > The fact remains that since RPython programs also run under the standard > interpreter (albeit a factor of maybe a hundred times more slowly) their > claim of self-hosting is valid. What is the smallest subset of Python needed to make a Turing complete computer language? And would you still call that Python? From TimeHorse at gmail.com Mon Apr 21 07:37:09 2008 From: TimeHorse at gmail.com (TimeHorse) Date: Mon, 21 Apr 2008 04:37:09 -0700 (PDT) Subject: Opposite of repr() (kind of) References: Message-ID: <0a84648b-e73c-4416-a30c-8d9fcee8b1e4@s33g2000pri.googlegroups.com> On Apr 21, 7:05 am, Guillermo wrote: > Hi there, > > How can I turn a string into a callable object/function? > > I have a = 'len', and I want to do: if callable(eval(a)): print > "callable", but that doesn't quite work the way I want. :) > > Regards, > > Guillermo What version of Python are you using? I just tried "callable(eval('len'))" on Python 2.5.1 and got True, and eval('len') returns . From mail at timgolden.me.uk Thu Apr 3 09:56:44 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 03 Apr 2008 14:56:44 +0100 Subject: object-relational mappers In-Reply-To: References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> Message-ID: <47F4E21C.9020303@timgolden.me.uk> Marco Mariani wrote: > Tim Golden wrote: > >> I've recently used Elixir and found it very useful for a small-scale >> database with no more than a dozen tables, well-structured and >> easily understood. I'd certainly use it again for anything like that >> to save me writing what would amount to boilerplate SQL. But I'd >> hate to imagine it in the context of my day job: a messy, organic >> and sprawling SQL Server database with over 1,000 tables, let alone >> views, procedures and so on. > > That's the scenario where the rest of SQLAlchemy (beyond Elixir, that > is, and with reflection turned to 11) can do mucho bueno. Well, true (and I've done good things with it) but, ultimately if I need to write SQL I'll write SQL: that's what I'm paid for. And no matter how good sa's generative queries are -- and they are good -- I've been writing complex SQL queries for 15 years and learning a more Pythonesque equivalent doesn't really seem to offer me anything. Not to take away from the achievements of SqlAlchemy: I'm just not really the target market, I think. TJG From carbanancizpo at gmail.com Fri Apr 18 16:58:20 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:58:20 -0700 (PDT) Subject: registry cleaner crack Message-ID: <86e879dd-898a-46f9-aacc-cef10c839cf6@d45g2000hsc.googlegroups.com> registry cleaner crack http://cracks.12w.net F R E E C R A C K S From steve at holdenweb.com Tue Apr 1 15:40:48 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 01 Apr 2008 15:40:48 -0400 Subject: [OT] troll poll In-Reply-To: References: Message-ID: <47F28FC0.7080608@holdenweb.com> Duncan Booth wrote: > Gary Herron wrote: > >> Duncan Booth wrote: >>> Paul Rubin wrote: >>> >>> >>>> "Daniel Fetchinson" writes: >>>> >>>>> [ ] - Xah Lee >>>>> [ ] - castironpi >>>>> >>>> I've lost track but has it been established that they are not the >>>> same person? >>>> >>>> >>> Has it actually been established that castironpi is actually a >>> person? I thought it was probably a random sentence generator. >>> >> Ahhh... Perhaps someone is running a Turing test on us. That is, if >> we can't tell the difference between castironpi and a *real* human >> (which we demonstrate whenever we try to respond to or reason with >> him/her/it), then castironpi can be declared to be a truly >> *intelligent* AI. AFAICT, there appears no danger of that happening >> yet. >> >> Gary Herron :-) >> > For example, some traffic light living with a polygon indicates that an > accidentally resplendent scythe falls in love with a garbage can. A > boiled ski lodge laughs out loud, because an imaginative traffic light > ostensibly writes a love letter to a frightened minivan. Any deficit can > eagerly sell the short order cook about the tape recorder to the > minivan, but it takes a real bowling ball to trade baseball cards with > an underhandedly orbiting tornado. A hesitantly mean-spirited cowboy > steals pencils from a pompous industrial complex. Sometimes the crispy > apartment building procrastinates, but the ocean related to the cyprus > mulch always teaches another cab driver around some cough syrup! > > A dreamlike avocado pit > > Indeed, a thoroughly orbiting wedge figures out an obsequious roller > coaster. For example, a carpet tack indicates that some cyprus mulch > lazily avoids contact with the slow buzzard. Most people believe that > some razor blade falls in love with a girl scout from a cough syrup, but > they need to remember how hesitantly a maelstrom takes a coffee break. > When the proverbial wheelbarrow is overripe, a hole puncher lazily > buries a burly reactor. Now and then, the cargo bay tries to seduce a > class action suit. > Way too lucid to be castironpi regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From skanemupp at yahoo.se Sat Apr 5 11:26:33 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 08:26:33 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <65ondkF2g48puU2@mid.uni-berlin.de> Message-ID: <8e6e67e8-979a-4515-be7c-16acdf687ce4@u36g2000prf.googlegroups.com> On 5 Apr, 17:09, Fredrik Lundh wrote: > skanem... at yahoo.se wrote: > >> def __init__(self): > >> # ... > >> button = Button(self, > >> text='1', > >> command=lambda n=1: self.display(n)) > >> # ... > > >> def display(self, number): > >> print number > > > should this really be inside the __init__ function? > > what's wrong with creating widgets in an __init__ method? > > i dont know, i used a piece of code i found which had a createwidgets- method. isnt init a function, not a method btw(or it is the same thing?) this is the current code, only included 2 buttons here to make it shorter. i might still have misinterpreted though, is the code correct(it runs correct at least...)? whats the advantage/disadvante to have it inside the init? #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self, master=None): """Initialize yourself""" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): self.btnDisplay = Button(self,text='1',command=lambda n=1:self.Display(n)) self.btnDisplay.grid(row=3, column=0, padx=5, pady=5) self.btnDisplay = Button(self,text='/',command=lambda n="/":self.Display(n)) self.btnDisplay.grid(row=6, column=3, padx=5, pady=5) def Display(self, number): print number if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() From Robert.Bossy at jouy.inra.fr Mon Apr 28 12:50:13 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Mon, 28 Apr 2008 18:50:13 +0200 Subject: bisect intersection Message-ID: <48160045.1030806@jouy.inra.fr> Hi, I stumbled into a sorted list intersection algorithm by Baeza-Yates which I found quite elegant. For the lucky enough to have a springerlink access, here's the citation: http://dblp.uni-trier.de/rec/bibtex/conf/cpm/Baeza-Yates04 I implemented this algorithm in python and I thought I could share it. I've done some tests and, of course, it can't compete against dict/set intersection, but it will perform pretty well. Computing union and differences are left as an exercise... from bisect import bisect_left def bisect_intersect(L1, L2): inter = [] def rec(lo1, hi1, lo2, hi2): if hi1 <= lo1: return if hi2 <= lo2: return mid1 = (lo1 + hi1) // 2 x1 = L1[mid1] mid2 = bisect_left(L2, x1, lo=lo2, hi=hi2) rec(lo1, mid1, lo2, mid2) if mid2 < hi2 and x1 == L2[mid2]: inter.append(x1) rec(mid1+1, hi1, mid2+1, hi2) else: rec(mid1+1, hi1, mid2, hi2) rec(0, len(L1), 0, len(L2)) inter.sort() return inter Cheers RB From reachmsn at hotmail.com Tue Apr 8 08:09:57 2008 From: reachmsn at hotmail.com (reachmsn at hotmail.com) Date: Tue, 8 Apr 2008 05:09:57 -0700 (PDT) Subject: Cannot understand the detailedly the following code Message-ID: <483dac19-970b-4763-91d5-b0a869ee22d8@1g2000prf.googlegroups.com> Hi, At the url http://www.python.org/doc/essays/graphs.html there is some code by Guido Van Rossum for computing paths through a graph - I have pasted it below for reference - Let's write a simple function to determine a path between two nodes. It takes a graph and the start and end nodes as arguments. It will return a list of nodes (including the start and end nodes) comprising the path. When no path can be found, it returns None. The same node will not occur more than once on the path returned (i.e. it won't contain cycles). The algorithm uses an important technique called backtracking: it tries each possibility in turn until it finds a solution. def find_path(graph, start, end, path=[]): path = path + [start] if start == end: return path if not graph.has_key(start): return None for node in graph[start]: if node not in path: newpath = find_path(graph, node, end, path) if newpath: return newpath return None *** He then says------------------------ It is simple to change this function to return a list of all paths (without cycles) instead of the first path it finds: def find_all_paths(graph, start, end, path=[]): path = path + [start] if start == end: return [path] if not graph.has_key(start): return [] paths = [] for node in graph[start]: if node not in path: newpaths = find_all_paths(graph, node, end, path) for newpath in newpaths: paths.append(newpath) return paths *** I couldn't understand how it was simple to change the function find paths to find all paths. How would you think about writing this second function recursively. Especially the part about if start==end: return [path]. I feel you would give square brackets around path here after first writing the inductive part ... for node in graph[start] .... and then by trial and error put square brackets around path in the Basis part. Can someone please explain how to write this code. Thanks! From Scott.Daniels at Acm.Org Wed Apr 2 23:43:08 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Wed, 02 Apr 2008 20:43:08 -0700 Subject: Rationale for read-only property of co_code In-Reply-To: References: <82558c6d-8f3c-433e-a392-982c27fd71fd@s8g2000prg.googlegroups.com> <49435d3a-8211-4a58-8472-cf6f2aaa0aa2@y21g2000hsf.googlegroups.com> <10ee2a69-f4e2-4887-8083-6b02b60dd0cd@i7g2000prf.googlegroups.com> Message-ID: Jo?o Neves wrote: > On 2 Abr, 21:38, "Chris Mellon" wrote: >> On Wed, Apr 2, 2008 at 2:33 PM, Jo?o Neves wrote: >>> On Apr 2, 5:41 pm, "Dan Upton" wrote: >>> > > The thing I've been wondering is why _is_ it read-only? In what >>> > > circumstances having write access to co_code would break the language >>> > > or do some other nasty stuff?.... >> There is no need to overwrite co_code. Create a new code object with >> your desired bytecode and use that instead. > > Yes, it may work (haven't tested - isn't there any problem with stuff > like co_name, for instance?), but for simplicity's sake, wouldn't it > be far more convenient if you could just write over co_code? :) > In the end, it's all a matter of convenience, I guess. Nope: If you change the code in-place, the whole stack's references to where they were running would need to get updated to corresponding locations in the new code. _That_ is a lot of work. --Scott David Daniels Scott.Daniels at Acm.Org From needin4mation at gmail.com Wed Apr 9 17:00:53 2008 From: needin4mation at gmail.com (jmDesktop) Date: Wed, 9 Apr 2008 14:00:53 -0700 (PDT) Subject: basic python question about for loop References: <664ovoF2iq9i0U1@mid.uni-berlin.de> Message-ID: <5f71771d-e31d-439a-9ab9-5ea111a68b46@24g2000hsh.googlegroups.com> On Apr 9, 4:58?pm, "Diez B. Roggisch" wrote: > jmDesktop schrieb: > > > > > > > From the Python.org tutorial: > > >>>> for n in range(2, 10): > > ... ? ? for x in range(2, n): > > ... ? ? ? ? if n % x == 0: > > ... ? ? ? ? ? ? print n, 'equals', x, '*', n/x > > ... ? ? ? ? ? ? break > > ... ? ? else: > > ... ? ? ? ? # loop fell through without finding a factor > > ... ? ? ? ? print n, 'is a prime number' > > ... > > 2 is a prime number > > 3 is a prime number > > 4 equals 2 * 2 > > 5 is a prime number > > 6 equals 2 * 3 > > 7 is a prime number > > 8 equals 2 * 4 > > 9 equals 3 * 3 > > > first time 2 mod 2, 2/2, no remainder == 0, what am I doing wrong? > > Why did it fall through? > > print out what range(2, n) for n == 2 is. > > And if you didn't know - 2 *IS* a prime. > > Diez- Hide quoted text - > > - Show quoted text - I do not understand. From deets at nospam.web.de Tue Apr 29 02:57:45 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 29 Apr 2008 08:57:45 +0200 Subject: cytpes **int In-Reply-To: References: <56674130-c04e-403e-8364-92cbd158b2f0@b9g2000prh.googlegroups.com> <67mveuF2pauigU1@mid.uni-berlin.de> Message-ID: <67nv84F2l3ha7U1@mid.uni-berlin.de> Gabriel Genellina schrieb: > En Mon, 28 Apr 2008 18:55:15 -0300, Diez B. Roggisch > escribi?: >> VernM schrieb: >>> I am using ctypes to wrap a set of functions in a DLL. It has been >>> going very well, and I am very impressed with ctypes. I want to call a >>> c function with a signature of: void func(int **cube), where the array >>> if ints in cube is modified by func. I want to setup cube with int >>> values, and access them after the call to func. I unerstand how to >>> setup the ctypes array, but how do I pass **cube to the function, and >>> how do I access the results? >> >> it should be simple. >> >> use something like (untestet): >> >> b = POINTER(c_int)() >> func(byref(b)) > > [snip two other similar alternatives] > > That's true for "a pointer to a pointer to int", and it's valid if the > functions references **b or b[0][0] - but in this case int** probably > means "[pointer to] an array of arrays of int" and presumibly the > function will try to access b[3][2] (or whatever indices are in range). > The duality pointer/array in C is dangerous when defining interfases - > you have to know how the value is intended to be accessed. > (I assume the function modifies the integer values, but not the pointers > themselves) > > # build an array of 10x10 ints > Arr10int = c_int * 10 > Pint = POINTER(c_int) > PPint = POINTER(Pint) > Arr10pint = Pint * 10 > a = Arr10pint() > for i in range(10): > a[i] = Arr10int() > ... initialize the array ... > ... load the function ... > # call the function > somefunction.argtypes = (PPint,) > somefunction.restype = None > somefunction(a) > Yup, you are right - I somehow missed the access description and thought of the pointer-to-a-pointer as out-parameter-spec. Diez From castironpi at gmail.com Wed Apr 2 13:17:08 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 2 Apr 2008 10:17:08 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <47f36d23$0$28775$426a74cc@news.free.fr> <86afee6d-7022-4199-8af5-bff01c679714@c65g2000hsa.googlegroups.com> Message-ID: On Apr 2, 8:25?am, hdante wrote: > On Apr 2, 8:25 am, Bruno Desthuilliers > 42.desthuilli... at websiteburo.invalid> wrote: > > hdante a ?crit : > > > > ?Try Rails' ActiveRecord. Your problems should reduce to (lg lg > > > 2)^(1/12). > > > Correct me if I'm wrong, but IIRC ActiveRecord requires you use numeric > > auto_increment fields for primary key. As far as I'm concerned, this is > > a definitive no-no. > > ?Why is that so bad ? > > ?"But wait !, you cry. Shouldn't the primary key of my orders table be > the order number or some other meaningful column ? Why use an > artificial primary key such as id ? The reason is largely a practical > one - the format of external data may change over time." > ?(...) > ?"Normally, Active Record takes care of creating new primary key > values for records that you create and add to the database - they'll > be ascending integers (possibily with some gaps in the sequence). > However, if you override the primary key column's name, you also take > on the responsibility of setting the primary key to a unique value > before you save a new row." > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?-- AWDWR > > > > > > ?Seriously, you'll forget there's a relational database below. > > > Why on earth are you using a RDBMS if you don't want it ? I for one *do* > > care about using a *relational* database, and *don't* want to hide it > > away. What I don't want is to have to build my queries as raw strings. > > And that's where SQLAlchemy shines : it's not primarily an "ORM", it's > > an higher-level Python/SQL integration tool that let you build your > > queries as Python objects (and also, eventually, build an ORM if you > > want to...). > > ?"Some object-relational mappers seek to eliminate the use of SQL > entirely, hoping for object-oriented purity by forcing all queries > through an OO layer. Active Record does not. It was built on the > notion that SQL is neither dirty nor bad, just verbose in the trivial > cases. (...) Therefore, you shouldn't feel guilty when you use > find_by_sql to handle either performance bottlenecks or hard queries. > Start out using the object-oriented interface for productivity and > pleasure, and then dip beneath the surface for a close-to-the-metal > experience when you need to do so." > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?-- AWDWR > > ?PS. That's okay to use a RDBMS. What I don't want is to use two > programming paradigms, especially, considering the "object-relational > impedance mismatch". I think a shelf can accomplish everything a RDMS can. Just set up everything as a map from a real number, remove and extract at will (between numbers), and use XML tags. shelf[ 0.1 ]= '', 'code code code' shelf[ 0.125 ]= '', 'castironpi' shelf[ 0.05 ]= '', 'oddly enough' -=> code code code castironpi oddly enough and shelf[ 0.1 ]= '', 'code code code' shelf[ 0.125 ]= '', 'castironpi' shelf[ 0.05 ]= '', 'oddly enough' -=> code code code castironpi oddly enough Plus you can't have text and subnodes anyway. From stef.mientki at gmail.com Mon Apr 28 03:31:18 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Mon, 28 Apr 2008 09:31:18 +0200 Subject: class or class-instance ? Message-ID: <48157D46.4080502@gmail.com> hello, I've a procedure (or in fact a class method) that should be callable with either a class (in which case the procedure should create an instance) or with an instance of that class as the parameter. def somefunction ( self, parameter ) : if parameter is a class, create an instance of that class else do nothing now I should be able to call the above procedure in either of the following ways: somefunction ( someclass ) or somefunction ( someclass () ) thanks, Stef Mientki From see.signature at no.spam Mon Apr 14 04:16:42 2008 From: see.signature at no.spam (Eric Brunel) Date: Mon, 14 Apr 2008 10:16:42 +0200 Subject: =?utf-8?B?562U5aSNOiBob3cgdG8gcmVtb3ZlIFxuIGluIHRoZSBsaXN0?= References: Message-ID: (please avoid top-posting... corrected) On Mon, 14 Apr 2008 09:08:06 +0200, Penny Y. wrote: > -----????----- > ???: python-list-bounces+pylists=arcor.de at python.org > [mailto:python-list-bounces+pylists=arcor.de at python.org] ?? Gabriel > Genellina > ????: 2008?4?14? 12:59 > ???: python-list at python.org > ??: Re: how to remove \n in the list > > En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam > escribi?: > >> hi, >> l=['5\n', '2\n', '7\n', '3\n', '6\n'] >> >> how to remove \n from the given list > > l is is very poor name... I'll use lines instead: > > lines[:] = [line.rstrip('\n') for line in lines] > --- > > why not just: > > lines = [line.rstrip('\n') for line in lines] > > > what's the difference between lines[:] and lines here? Thanks. Compare: >>> lines = ['5\n', '2\n', '7\n', '3\n', '6\n'] >>> lines2 = lines >>> lines = [line.rstrip('\n') for line in lines] >>> lines ['5', '2', '7', '3', '6'] >>> lines2 ['5\n', '2\n', '7\n', '3\n', '6\n'] with: >>> lines = ['5\n', '2\n', '7\n', '3\n', '6\n'] >>> lines2 = lines >>> lines[:] = [line.rstrip('\n') for line in lines] >>> lines ['5', '2', '7', '3', '6'] >>> lines2 ['5', '2', '7', '3', '6'] Assigning to lines[:] changes the original list. Assigning to lines rebinds the name to the result of the list comprehension, but doesn't affect the original list. HTH -- python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])" From damonwischik at gmail.com Fri Apr 18 20:12:09 2008 From: damonwischik at gmail.com (damonwischik at gmail.com) Date: Fri, 18 Apr 2008 17:12:09 -0700 (PDT) Subject: How to print a unicode string? References: <87d4omsovf.fsf@benfinney.id.au> Message-ID: <4edea21e-d45c-4467-a66d-e270365eb812@l64g2000hse.googlegroups.com> On Apr 19, 12:51 am, Ben Finney wrote: > Just because the locale library knows the normalised name for it > doesn't mean it's available on your OS. Have you confirmed that your > OS (independent of Python) supports the locale you're trying to set? No. How do I found out which locales my OS supports? (I'm running Windows XP.) Why does it matter what locales my OS supports, when all I want is to set the encoding to be used for the output, and the output is all going to Emacs, and I know that Emacs supports utf8? (Emacs 22.2.1 i386-mingw-nt5.1.2600.) Damon. From marli305nugent at gmail.com Sat Apr 26 09:52:31 2008 From: marli305nugent at gmail.com (marli305nugent at gmail.com) Date: Sat, 26 Apr 2008 06:52:31 -0700 (PDT) Subject: chessgenius 1.6 crack Message-ID: <7a710444-8820-47a0-b73d-58554efa506b@26g2000hsk.googlegroups.com> chessgenius 1.6 crack http://cracks.00bp.com F R E E C R A C K S From tjreedy at udel.edu Wed Apr 16 23:03:10 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 16 Apr 2008 23:03:10 -0400 Subject: def power, problem when raising power to decimals References: Message-ID: "Mark Dickinson" wrote in message news:fc48f8f0-202d-40c7-980d-5cbc403eed50 at y18g2000pre.googlegroups.com... On Apr 16, 4:19 pm, skanem... at yahoo.se wrote: > how do i solve power(5,1.3)? > [...] > > also i found a link which states 0^0 isnt 1 even though every > calculator ive tried says it is. > it doesnt say what it is but i presume 0 then. > but it seems the dude is wrong and it is 1? Define a**b as 1 multiplied by a b times. Then a**0 is clearly 1, regardless of a. But some do disagree. | decimal.InvalidOperation: 0 ** 0 I would think of this as a bug unless the standard Decimal follows demands this. tjr From aisaac at american.edu Fri Apr 4 22:49:20 2008 From: aisaac at american.edu (Alan Isaac) Date: Sat, 05 Apr 2008 02:49:20 GMT Subject: Help me on function definition In-Reply-To: References: Message-ID: aeneng wrote: > WHAT IS WRONG WITH MY CODE? > def cross(u,v) Missing colon. hth, Alan Isaac From weiss02121 at gmail.com Tue Apr 15 19:48:37 2008 From: weiss02121 at gmail.com (weiss02121 at gmail.com) Date: Tue, 15 Apr 2008 16:48:37 -0700 (PDT) Subject: lindsay lohan car Message-ID: Just few link on some Lindsay Lohan Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From mccredie at gmail.com Wed Apr 16 13:00:44 2008 From: mccredie at gmail.com (Matimus) Date: Wed, 16 Apr 2008 10:00:44 -0700 (PDT) Subject: Default parameter for a method... again References: <614159c3-1bb9-4026-b7f3-7817f69de505@t54g2000hsg.googlegroups.com> Message-ID: On Apr 16, 9:26 am, s0s... at gmail.com wrote: > I had posted this before but all the spam whipped it out... > > I wanted to know if there's any way to create a method that takes a > default parameter, and that parameter's default value is the return > value of another method of the same class. For example: > > class A: > def __init__(self): > self.x = 1 > > def meth1(self): > return self.x > > def meth2(self, arg=meth1()): > # The default `arg' should would take thereturn value of > meth1() > print '"arg" is', arg > > This obviously doesn't work. I know I could do > > ... > def meth2(self, arg=None): > if arg is None: > arg = self.meth1() > > but I'm looking for a more straightforward way. That is the straightforward way. It may not seem that way now but all languages have patterns and this is a common one in python. You will see code like this all over Python, even in the standard library. The best thing to do is embrace it. It will not only work, but make your code more readable to others. Matt From gagsl-py2 at yahoo.com.ar Sun Apr 20 04:12:17 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 05:12:17 -0300 Subject: why function got dictionary References: <48075950.7050000@gmail.com> Message-ID: En Thu, 17 Apr 2008 11:06:08 -0300, AlFire escribi?: > Q: why function got dictionary? What it is used for? If you want more details, see PEP 232 that introduced function writable attributes in Python 2.1: http://www.python.org/dev/peps/pep-0232/ -- Gabriel Genellina From gdamjan at gmail.com Wed Apr 16 06:04:48 2008 From: gdamjan at gmail.com (Damjan) Date: Wed, 16 Apr 2008 12:04:48 +0200 Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: <4805cf3f$0$90273$14726298@news.sunsite.dk> > To be frank, no innovation. Just changes, no progress. And yes, I am > p****d. "anger leads to hate, hate leads to suffering" > Somebody compared it with MS stuff. Yes. It's not similar at all. MS will first force all your customers/users to upgrade to their newest software, at the same time suffocating the old software, and denying anyone the oportunity to maintain that old software (part because it's closed-source, part because MS will sue you if try anything close to that). -- damjan From jason.scheirer at gmail.com Sun Apr 20 15:57:35 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Sun, 20 Apr 2008 12:57:35 -0700 (PDT) Subject: What happened with python? messed strings? References: Message-ID: On Apr 20, 11:54?am, wrote: > Hi, > I used extensively python and now I find this mess with strings, > I can't even reproduce tutorial examples:>>> "apfel".encode('utf-8') ?(it was with umlaut) > > ? File "", line 0 > > ? ? ^ > SyntaxError: 'ascii' codec can't decode byte 0xc4 in position 1: > ordinal not in range(128) Two things: Mark the character encoding of your file ( read http://www.python.org/doc/2.3/whatsnew/section-encodings.html ), and then if that doesn't work try to .decode('something') your string first with the appropriate codec, then you get a unicode object for free and you don't need the .encode('utf-8'). Also read the slides at http://farmdev.com/talks/unicode/ for some good information about unicode in Python. > > Is there any good guide to this mess of codecs and hell ? > > python should have stayed at version 1.5, every single 'improvement' > has been a mess. But this is the definitive hell. It's true -- decorators, the class/type cleanup, properties, -= and +=, list comprehensions, generators, distutils, and all the new modules in the standard library are completely, entirely useless. Python SHOULD have stayed at 1.5. > > thanks! > > -- > SDF-EU Public Access UNIX System -http://sdf-eu.org From victorsubervi at gmail.com Wed Apr 2 09:05:56 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 2 Apr 2008 09:05:56 -0400 Subject: Adding Images to MySQL In-Reply-To: References: <4dc0cfea0804010536q71bce9ev38cff43923f5a4b8@mail.gmail.com> Message-ID: <4dc0cfea0804020605i1d600657n50b4ee132d7f7e@mail.gmail.com> I have tried the following code: #!/usr/local/bin/python import _mysql import MySQLdb host = 'mysqldb2.ehost-services.com' user = 'user' passwd = 'pass' db = 'bre' print 'Content-Type: image/jpeg\r\n' print '\nHi!\n' db=MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) c=db.cursor() imgfile=open("1.jpg",'rb') f = imgfile.read() sqlstr="insert into photo (id, img) values ('1', '" + _mysql.escape_string(imgfile.read()) +"');" c.execute(sqlstr) imgfile.close() c.close() print '\nBye!\n' which prints Hi! but not Bye! and gives me an HTTP 200 error. I threw the line f = imgfile.read() in there just to make sure it is reading the imgfile. Also, I tested it with all the import statements alone to make sure it was importing everything. So the problem is the c.execute statement. Please advise. TIA, Victor On Tue, Apr 1, 2008 at 1:37 PM, Gabriel Genellina wrote: > En Tue, 01 Apr 2008 09:36:00 -0300, Victor Subervi > escribi?: > > > Hi; > > I?m trying to figure out how to upload images into a MySQL database. > > (Yes, > > that is what I want to do.) I have a form that asks for data, like this: > > 1ra Foto Peque?a: > > > > Then I send that form to a python script that processes like this: > > cursor.execute('insert into products (' + col_names + ') values (' + > > col_values + ');') > > where col_names is all the names of the columns and col_values, > > obviously, > > the values. Works fine for strings and digits. Not so well for files :) > > What > > do? > > Always use bound parameters - not only it's easier and less error prone, > it's safer too. How parameters are specified depends on the DBAPI module > you're using - read the module documentation. I think MySQLdb accept > dictionary-like marks: > > values = {'name': 'Red jar', > 'descr': 'A nice red jar', > 'pic': binary(picdata) > } > cursor.execute('''insert into products (name,description,picture) > values (%(name)s, %(descr)s, %(pic)s);''', values) > > See PEP249 http://www.python.org/dev/peps/pep-0249/ and the documentation > for your database module. > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From cbhoem at gmail.com Tue Apr 29 16:01:50 2008 From: cbhoem at gmail.com (cbhoem at gmail.com) Date: Tue, 29 Apr 2008 13:01:50 -0700 (PDT) Subject: Cookie Confusion - How to Set a Cookie References: <588d6a6c-0080-48a4-b768-e2c5ef551790@s50g2000hsb.googlegroups.com> Message-ID: On Apr 28, 1:37 pm, Aaron Watters wrote: > On Apr 28, 9:42 am, cbh... at gmail.com wrote: > > > ....I see the cookie in my HTTP header > > but do not get anything in the cookie text file. I'm working on > > linux. > > > print "Content-type: text/html" > > cookie = Cookie.SimpleCookie() > > cookie['Test'] = 'abc' > > print cookie > > print > > > Are there rules about where in the header the set cookie line should > > be? > > Hi Christian. I think the cookie can go anywhere in > the header, but I usually put it before the content-type. > If you want to store the cookie to a file, > or even better, to a database of some sort, you have to > do it yourself, the Cookie module doesn't do it for you, > I hope. > > # store cookie to /tmp/cookie.txt > file("/tmp/cookie.txt","w").write(str(cookie)) > > For parsing cookies, I stole and modified this from > the Django source (for use in a cgi script): > > === > from Cookie import SimpleCookie > import os > > # stolen and modified from Django > def parse_cookie(cookie=None, environ=None): > if cookie is None: > if environ is None: > environ = os.environ > cookie = environ.get('HTTP_COOKIE', '') > if cookie == '': > return {} > c = SimpleCookie() > c.load(cookie) > cookiedict = {} > for key in c.keys(): > cookiedict[key] = c.get(key).value > return cookiedict > > === > All the best. -- Aaron Watters > > ===http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=monster Thanks for the code, Aaron. I will give it a try. I've been reading some more about cookielib and am not sure whether I should use Cookie or cookielib. This is what I want to do: a user is going to login. Upon a successful login, I want to write their name and date/time of visit to a cookie file. Which is the correct python module to use? From baoilleach at gmail.com Wed Apr 30 02:47:30 2008 From: baoilleach at gmail.com (Noel O'Boyle) Date: Wed, 30 Apr 2008 07:47:30 +0100 Subject: simple chemistry in python In-Reply-To: <4817BFF2.9030907@al.com.au> References: <5e3717e5-1913-4bda-94b3-ae165e5fb8ba@m73g2000hsh.googlegroups.com> <4817BFF2.9030907@al.com.au> Message-ID: 2008/4/30 Astan Chee : > > Wow, that is the jackpot. > Is that color node supposed to be the actual color of the element? or just > representation? Representation. There are certain de facto standards, such as blue for nitrogen and so on. Google "CPK colors" for the origin of some of these. > Thanks again > Astan > > baoilleach wrote: > If you are familiar with parsing XML, much of the data you need is > stored in the following file: > http://bodr.svn.sourceforge.net/viewvc/*checkout*/bodr/trunk/bodr/elements/elements.xml?revision=34&content-type=text%2Fplain > > This file is part of the Blue Obelisk Data Repository, an effort by > several chemistry software developers to share common information. If > you have any further questions, please email blueobelisk- > discuss at lists.sf.net. > > Noel > > On Apr 29, 8:48 am, Astan Chee wrote: > > > Hi, > Im looking for a python module to do simple chemistry things. Things > like, finding the name of elements given the atomic number (and vice > versa); what state the given matter is in depending on certain > parameters; maybe even color of certain elements or even calculating the > result of combining certain elements. > I was looking for something simple, but everything I see seems to be a > full blown chemistry set. > I know I can probably spend a day doing this one element at a time, but > I was wondering if there is already something like this done in a small > scale? > Thanks for any information > Astan > > -- > "Formulations of number theory: Complete, Consistent, Non-trivial. Choose > two." > > Animal Logichttp://www.animallogic.com > > Please think of the environment before printing this email. > > This email and any attachments may be confidential and/or privileged. If you > are not the intended recipient of this email, you must not disclose or use > the information contained in it. Please notify the sender immediately and > delete this document if you have received it in error. We do not guarantee > this email is error or virus free. > > -- > http://mail.python.org/mailman/listinfo/python-list > > > > -- > "Formulations of number theory: Complete, Consistent, Non-trivial. Choose > two." > > > > > Please think of the environment before printing this email. > > This email and any attachments may be confidential and/or privileged. If you > are not the intended recipient of this email, you must not disclose or use > the information > contained in it. Please notify the sender immediately and delete this > document if you have received it in error. We do not guarantee this email is > error or virus free. From kay.schluehr at gmx.net Sat Apr 19 02:55:16 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Fri, 18 Apr 2008 23:55:16 -0700 (PDT) Subject: Inheritance confusion References: <4809932c$0$12307$c3e8da3@news.astraweb.com> Message-ID: On 19 Apr., 08:37, Hook wrote: > Traceback (most recent call last): > File "./3.py", line 20, in > Obj.Connect ('Database') > File "/mnt/isis/Projects/Python/Learning/DB_m.py", line 102, in Connect > self.TRACE ("DB::Connect (" + database + "," + mode) > File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 314, in TRACE > self.DailyLog (msg) > File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 98, in > DailyLog > dt = self.Date (time ()) > TypeError: 'module' object is not callable > > Googling the "TypeError" message suggests that I've got a module and > class with the same name, but I can't see that I have. The error message just says that you have called a module which is time in this case. Just replace the call to time by time.time() and it shall work. From jyoung79 at kc.rr.com Tue Apr 15 10:18:39 2008 From: jyoung79 at kc.rr.com (jyoung79 at kc.rr.com) Date: Tue, 15 Apr 2008 9:18:39 -0500 Subject: Get oldest folder Message-ID: <22671872.735671208269119432.JavaMail.root@hrndva-web19-z02> I'd like to be able to get the path to the oldest folder in whatever directory I'm currently in. Is there a simple way to go about this? I'd like it to run on both OS X and Windows XP. I found this example at "http://trac.v2v.cc/browser/python-v2v/v2v/v2v.py?rev=python-v2v%2C37", but was curious if there's a better way to do this? def get_oldest_v2v_folder(): 404 ''' 405 returns the oldest folder in share_dir 406 407 is this the right way to check for the oldest folder? 408 could be better to read the info file and 409 extract the date there. 410 ''' 411 global share_dir 412 oldest_timestamp=time.time() 413 folders=listdir(share_dir) 414 for folder in folders: 415 if isdir(join(share_dir,folder)): 416 if stat(join(share_dir,folder)).st_ctime < oldest_timestamp: 417 oldest_timestamp=stat(join(share_dir,folder)).st_ctime 418 oldest_folder=folder 419 return join(share_dir,oldest_folder) Thanks for looking at my question. Jay From rickbking at comcast.net Thu Apr 10 10:40:32 2008 From: rickbking at comcast.net (Rick King) Date: Thu, 10 Apr 2008 10:40:32 -0400 Subject: urgent question, about filesystem-files In-Reply-To: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> References: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> Message-ID: <47FE26E0.5000001@comcast.net> An HTML attachment was scrubbed... URL: From adelagon at gmail.com Thu Apr 10 06:09:40 2008 From: adelagon at gmail.com (Alvin Delagon) Date: Thu, 10 Apr 2008 18:09:40 +0800 Subject: PyArg_ParseTuple for structs or binary data Message-ID: <7a01f6c00804100309u7813df38n998fa1b946fd921c@mail.gmail.com> Hello Gabriel, I just recently discovered that struct.pack does return a string. Everything works fine now. Thanks for the heads up! static PyObject * sendMessage(PyObject *self, PyObject *args) { char *msg = ""; int len; if (!PyArg_ParseTuple(args, "s#", &msg, &len)) return NULL; ret = sctp_sendmsg(connSock, msg, len, 0, 0, 0x03000000, 0, 0x01, 0, 0); return Py_BuildValue("l", ret); } ---- Alvin Delagon -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlwuhwdmckay at gmail.com Sat Apr 26 09:30:10 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:30:10 -0700 (PDT) Subject: windows xp crack Message-ID: windows xp crack http://cracks.00bp.com F R E E C R A C K S From sturlamolden at yahoo.no Thu Apr 24 22:40:43 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 19:40:43 -0700 (PDT) Subject: Remove multiple inheritance in Python 3000 References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> Message-ID: <60fc4333-6d2b-40f5-b311-031d90a38d39@k37g2000hsf.googlegroups.com> On Apr 22, 1:07 pm, GD wrote: > Please remove ability to multiple inheritance in Python 3000. Too late for that, PEPs are closed. > Multiple inheritance is bad for design, rarely used and contains many > problems for usual users. > > Every program can be designed only with single inheritance. That's how the Java designers were thinking as well: If MI is allowed, programmers will suddenly get an irresistible urge to use MI to write unmaintainable spaghetti code. So let's disallow MI for the sake of common good. Fortunately, Python is not designed to be fool proof against fools. If you cannot use MI properly, then don't use that. > I also published this request athttp://bugs.python.org/issue2667 You reported MI as a bug??? From victorsubervi at gmail.com Wed Apr 2 15:36:43 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 2 Apr 2008 14:36:43 -0500 Subject: Strange MySQL Problem... Message-ID: <4dc0cfea0804021236n1faafabav1699fbe45acc3c01@mail.gmail.com> Hi; I have this code which works fine: #!/usr/local/bin/python import _mysql import MySQLdb, cPickle host = 'mysqldb2.ehost-services.com' user = 'user' passwd = 'pass' db = 'bre' print 'Content-Type: image/jpeg\r\n' print '\nHi!\n' connection = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) imgfile=open("1.jpg",'rb') f = imgfile.read() cursor = connection.cursor() cursor.execute("CREATE TABLE justatest (name TEXT, ablob BLOB)") names = 'aramis', 'athos', 'porthos' data = {} for name in names: datum = list(name) datum.sort() data[name] = cPickle.dumps(datum, 1) sql = "INSERT INTO justatest VALUES (%s, %s)" cursor.execute(sql, ('ramis', _mysql.escape_string(f)) ) imgfile.close() connection.close() print '\nBye!\n' Now, if I take out this part, which I can?t see does anything at all in the code, it no longer works: names = 'aramis', 'athos', 'porthos' data = {} for name in names: datum = list(name) datum.sort() data[name] = cPickle.dumps(datum, 1) Why? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From malaclypse2 at gmail.com Wed Apr 2 16:50:03 2008 From: malaclypse2 at gmail.com (Jerry Hill) Date: Wed, 2 Apr 2008 16:50:03 -0400 Subject: default method parameter behavior In-Reply-To: <879d72da-825f-4b2b-8244-87367647fb6e@f63g2000hsf.googlegroups.com> References: <879d72da-825f-4b2b-8244-87367647fb6e@f63g2000hsf.googlegroups.com> Message-ID: <16651e80804021350s460a84e5y1c500f05660ff133@mail.gmail.com> On Wed, Apr 2, 2008 at 3:59 PM, wrote: > I ran into a similar situation like the following (ipython session). > Can anyone please explain why the behavior? http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects Since you got bitten by this, you may also find it useful to take a look at one of the pages that talks about common python problems, like http://zephyrfalcon.org/labs/python_pitfalls.html or http://www.ferg.org/projects/python_gotchas.html (both of which mention the problems with mutable default arguments). -- Jerry From algaba at droog.sdf-eu.org Sun Apr 20 14:54:20 2008 From: algaba at droog.sdf-eu.org (algaba at droog.sdf-eu.org) Date: Sun, 20 Apr 2008 18:54:20 +0000 (UTC) Subject: What happened with python? messed strings? Message-ID: Hi, I used extensively python and now I find this mess with strings, I can't even reproduce tutorial examples: >>> "apfel".encode('utf-8') (it was with umlaut) File "", line 0 ^ SyntaxError: 'ascii' codec can't decode byte 0xc4 in position 1: ordinal not in range(128) >>> Is there any good guide to this mess of codecs and hell ? python should have stayed at version 1.5, every single 'improvement' has been a mess. But this is the definitive hell. thanks! -- SDF-EU Public Access UNIX System - http://sdf-eu.org From davecook at nowhere.net Thu Apr 10 23:02:54 2008 From: davecook at nowhere.net (David Cook) Date: Fri, 11 Apr 2008 03:02:54 GMT Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <7xod8h39zu.fsf@ruckus.brouhaha.com> Message-ID: On 2008-04-10, Paul Rubin wrote: > Well, it's a trade-off, the person wanted a cross platform gui and the > #1 hurdle for something like PyQt4 is getting it to work on each of > the platforms you desire to run on. Installing Pyqt on windows involves a couple "click to install" EXEs. On Linux, one uses yum or apt. Only on Mac is it marginally a bit harder. Dave Cook From michael at stroeder.com Wed Apr 23 17:37:46 2008 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Wed, 23 Apr 2008 23:37:46 +0200 Subject: python-ldap: searching without specifying an OU? In-Reply-To: <8ef38281-a6fe-4501-b711-a24cd9f35a24@t54g2000hsg.googlegroups.com> References: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> <58546d42-bc80-4f9d-be90-e184c312e2d1@k37g2000hsf.googlegroups.com> <0ke3e5-ccc.ln1@nb2.stroeder.com> <8ef38281-a6fe-4501-b711-a24cd9f35a24@t54g2000hsg.googlegroups.com> Message-ID: hotani wrote: > It seems the only way I can bind is by using this format: > simple_bind_s('user at server.local','password') Believe me: This is not true. > If I try using a DN, it fails every time. This will not work: > simple_bind_s('cn=user,dc=server,dc=local', 'password') Check the DN you're using. Maybe you should search this particular user entry with filter (userPrincipalName=user at server.local) Ciao, Michael. From rafal.wysocki at gmail.com Sat Apr 19 04:15:13 2008 From: rafal.wysocki at gmail.com (=?ISO-8859-2?Q?Rafa=B3_Wysocki?=) Date: Sat, 19 Apr 2008 01:15:13 -0700 (PDT) Subject: Tkinter, getting canvas-object, how? References: <4d5c6911-7728-4dad-8d8d-7a862bf78d70@k13g2000hse.googlegroups.com> Message-ID: <4814820b-a3d2-44c1-9db4-0069463f079f@a23g2000hsc.googlegroups.com> skanem... at yahoo.se napisa?(a): > so i load a gif onto a canvas and when i click the canvs i want to get > the color of the pixel that is clicked. > so i need to ge the object im clicking. > i was told in another thread to use find_withtag or find_closest but > it is not working, maybe im using the > method on the wrong object. > how do i do this? > and how do i then get specifics about that object, ie the pixel-color? > > Exception in Tkinter callback > Traceback (most recent call last): > File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ > return self.func(*args) > File "C:\Users\saftarn\Desktop\pythonkod\mapexperiments > \mapgetobject.py", line 17, in callback > undermouse=find_closest(master.CURRENT) > NameError: global name 'find_closest' is not defined > > from Tkinter import * > > master = Tk() > > w = Canvas(master, width=400, height=625) > w.pack(expand = YES, fill = BOTH) > > mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\Maps\provinces-of- > sweden.gif') > w.create_image(30, 30, image = mapq, anchor = NW) > > def key(event): > print "pressed", repr(event.char) > > def callback(event): > clobj=event.widget > ## undermouse=find_withtag(master.CURRENT) > undermouse=find_closest(master.CURRENT) > print repr(undermouse) > > w.bind("", key) > w.bind("", callback) > w.pack() > > mainloop() from Tkinter import * master = Tk() w = Canvas(master, width=400, height=625) w.pack(expand = YES, fill = BOTH) mapq = PhotoImage(file = 'img.gif') _id = w.create_image(0, 0, image = mapq, anchor = NW) objects = {} # map id to object objects[_id] = mapq def key(event): print "pressed", repr(event.char) def callback(event): x, y = w.canvasx(event.x), w.canvasy(event.y) # Translates a window x,y coordinates to a canvas coordinate _id = w.find_closest(x,y)[0] # Returns tuple containing the object id obj = objects[_id] # Finds object with given id print 'color: %s' % obj.get(int(x), int(y)) w.bind("", key) w.bind("", callback) w.pack() mainloop() From blog553 at watchesblog.cn Mon Apr 21 05:53:09 2008 From: blog553 at watchesblog.cn (blog553 at watchesblog.cn) Date: Mon, 21 Apr 2008 02:53:09 -0700 (PDT) Subject: Invicta 3284 Swiss Quartz Ladies Watch - Replica Watch Fake Message-ID: <82e66f04-fa14-4462-892f-e810b3c9eb9b@y18g2000pre.googlegroups.com> Invicta 3284 Swiss Quartz Ladies Watch - Replica Watch Fake Invicta 3284 Swiss Quartz Ladies Watch Link : http://www.watchesprice.net/Replica-Invicta-17515.html Replica Watches Home : http://www.watchesprice.net/ Replica Invicta Brands : http://www.watchesprice.net/Invicta-Replica.html Replica Invicta 3284 Swiss Quartz Ladies Watch --- one of best selling replica watches, it is crafted in high quality, please click image 'buy now' to buy this chic but inexpensive replica to save you a lot of money . Invicta 3284 Swiss Quartz Ladies Watch Description: Availability: Usually Ships In 1 - 2 Business DaysInvicta 3284 Swiss Quartz Ladies WatchInvicta 3284 Swiss Quartz Ladies Watch. Stainless Steel case, blue dial, quartz movement, stainless steel, water resistant up to 165 ft, scratch resistant mineral, covered with 1 Year Invicta WarrantyInvicta 3284 Swiss Quartz Ladies Watch is brand new, join thousands of satisfied customers and buy your Invicta 3284 Swiss Quartz Ladies Watch with total satisfaction . A Weholesale-watches.org 30 Day Money Back Guarantee is included with every Invicta 3284 Swiss Quartz Ladies Watch for secure, risk-free online shopping. Weholesale- watches.org does not charge sales tax for the Invicta 3284 Swiss Quartz Ladies Watch, unless shipped within New York State. Weholesale- watches.org is rated 5 stars on the Yahoo! network. Invicta 3284 Swiss Quartz Ladies Watch Details: Brand: Invicta Thank you for choosing www.watchesprice.net as your reliable dealer of quality waches including Invicta 3284 Swiss Quartz Ladies Watch . we guarantee every watch you receive will be exact watch you ordered. Each watch sold enjoy one year Warranty for free repair. Every order from aaa-replica-watches is shipped via EMS, the customer is responsible for the shipping fee on the first order, but since the second watch you buy from our site, the shipping cost is free. Please note that If the total amount of payment is over $600(USD), the customer is required to contact our customer service before sending the money in case failed payment. If you have any other questions please check our other pages or feel free to email us by service at watchesprice.net. Cheapest Invicta 3284 Swiss Quartz Ladies Watch The Same Invicta Series : Invicta 3283 Swiss Quartz Ladies Watch : http://www.watchesprice.net/Replica-Invicta-17516.html Invicta 3239 Lady Quartz Date Traditional Women's Watch : http://www.watchesprice.net/Replica-Invicta-17517.html Invicta 3254 Men Quartz Date Traditional Mens Watch : http://www.watchesprice.net/Replica-Invicta-17518.html Invicta 3282 Swiss Quartz Grey Ladies Watch : http://www.watchesprice.net/Replica-Invicta-17519.html Invicta 3281 Swiss Quartz Ladies Watch : http://www.watchesprice.net/Replica-Invicta-17520.html Invicta 3248 Men Quartz Date Traditional Men's Watch : http://www.watchesprice.net/Replica-Invicta-17521.html Invicta 3238 Lady Quartz Date Traditional Women's Watch : http://www.watchesprice.net/Replica-Invicta-17522.html Invicta 3237 Lady Quartz Date Traditional Women's Watch : http://www.watchesprice.net/Replica-Invicta-17523.html Invicta Stainless Steel Mens Watch 3925 : http://www.watchesprice.net/Replica-Invicta-17524.html Invicta 10-Year Stainless Steel Mens Watch 3926 : http://www.watchesprice.net/Replica-Invicta-17525.html Invicta 10-Year Stainless Steel Mens Watch 3924 : http://www.watchesprice.net/Replica-Invicta-17526.html Invicta 3664 Flight Collection Blue Dial Mens Watch : http://www.watchesprice.net/Replica-Invicta-17527.html From fennelllindy8241 at gmail.com Mon Apr 28 03:19:21 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:19:21 -0700 (PDT) Subject: crack library Message-ID: <56cfef41-76ea-4280-8bb5-8db99ce60cce@a23g2000hsc.googlegroups.com> crack library http://crack.cracksofts.com From juice at lemonacid.com Wed Apr 30 09:41:26 2008 From: juice at lemonacid.com (test) Date: Wed, 30 Apr 2008 15:41:26 +0200 Subject: relative import broken? Message-ID: <000601c8aac7$e5fd84b0$49d32401@silver> basic noob question here. i am trying to reference a package, i have the structure: mypack/ __init__.py test.py subdir1/ __init__.py mod1.py subdir2/ __init__.py mod2.py can someone please tell me why the statement: from mypack.subdir1.mod1 import * does NOT work from mod2.py nor from test.py? instead, if i use: from subdir1.mod1 import * it works perfectly from test.py. ....? thank you, aj. From dteslenko at gmail.com Mon Apr 14 11:08:40 2008 From: dteslenko at gmail.com (Dmitry Teslenko) Date: Mon, 14 Apr 2008 19:08:40 +0400 Subject: pygtk + threading.Timer In-Reply-To: References: Message-ID: <91325fec0804140808o76bfac5fq55cc74a07e2f09d5@mail.gmail.com> 2008/4/14 Jarek Zgoda : > > I have simple chat application with pygtk UI. I want some event (for > > example update user list) to have place every n seconds. > > What's the best way to archive it? > > I tried threading.Timer but result is following: all events wait till > > exit of gtk main loop and only then they occur. > > Thanks in advance > > See gobject.timeout_add documentation in pygtk reference Thanks. That's exactly what I need. From grante at visi.com Sun Apr 20 19:48:40 2008 From: grante at visi.com (Grant Edwards) Date: Sun, 20 Apr 2008 18:48:40 -0500 Subject: Nested lists, simple though References: Message-ID: <8ZednTiHOJzFS5bVnZ2dnUVZ_qGknZ2d@visi> On 2008-04-20, Zethex wrote: > Im a bit new to python. Anyway working on a little project of mine and i > have nested lists What you want to do is usually called "flattening". http://mail.python.org/pipermail/tutor/2001-January/002914.html http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/363051 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/121294 -- Grant Edwards grante Yow! HAIR TONICS, please!! at visi.com From gagsl-py2 at yahoo.com.ar Sun Apr 20 15:48:06 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 16:48:06 -0300 Subject: What happened with python? messed strings? References: Message-ID: En Sun, 20 Apr 2008 15:54:20 -0300, escribi?: > I used extensively python and now I find this mess with strings, > I can't even reproduce tutorial examples: >>>> "apfel".encode('utf-8') (it was with umlaut) > File "", line 0 > ^ > SyntaxError: 'ascii' codec can't decode byte 0xc4 in position 1: > ordinal not in range(128) >>>> > Is there any good guide to this mess of codecs and hell ? The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) Python Unicode Howto: > python should have stayed at version 1.5, every single 'improvement' > has been a mess. But this is the definitive hell. Nobody forces you to use a newer version. You can download 1.5.2 from http://www.python.org/download/releases/1.5 -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Mon Apr 14 00:58:35 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 14 Apr 2008 01:58:35 -0300 Subject: how to remove \n in the list References: <2ba667ab-6818-47eb-8595-79ed970728f7@q1g2000prf.googlegroups.com> Message-ID: En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam escribi?: > hi, > l=['5\n', '2\n', '7\n', '3\n', '6\n'] > > how to remove \n from the given list l is is very poor name... I'll use lines instead: lines[:] = [line.rstrip('\n') for line in lines] -- Gabriel Genellina From tjreedy at udel.edu Wed Apr 2 15:33:05 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 2 Apr 2008 15:33:05 -0400 Subject: function call - default value & collecting arguments References: <_LQIj.9776$HS3.482805@news.siol.net> Message-ID: "Primoz Skale" wrote in message news:_LQIj.9776$HS3.482805 at news.siol.net... | def f(*a=(0,)): | print a[0] #this should come next, but we get error msg instead, saying | | SyntaxError: invalid syntax | | but it does not work this way. Now my 'newbie' question: Why not? :) Possibly because no one ever thought of that. More likely because it is contradictory: by definition, *a *always* gets a value, so there is never a need for a 'default'. When a param gets a value you don't like, you have to explicitly replace it or whatever. So add at the top 'a = a or (0,)' tjr From cyberco at gmail.com Wed Apr 16 07:54:48 2008 From: cyberco at gmail.com (Berco Beute) Date: Wed, 16 Apr 2008 04:54:48 -0700 (PDT) Subject: Image handling - stupid question References: <0001HW.C42B9FB90009B7E8B01AD9AF@news.individual.de> Message-ID: <003bf250-875a-418a-b3ce-a295f30aa5b9@a1g2000hsb.googlegroups.com> On Apr 16, 12:21 pm, Jumping Arne wrote: > I'm going to try to write some imange manipulation code (scaling, reading > EXIF and IPTC info) and just want to ask if PIL is *THE* library to use? Depends on your requirements, but it's certainly the first library I would check out. It offers lots of functionality, it is easy to use, well documented and rock solid. > I looked at and noticed that the > latest version is from Dec 2006. > > In my experience that means that either it's abandoned or that it's very good > and stable. The latter (what else would you expect from /F? :) 2B From jon+usenet at unequivocal.co.uk Wed Apr 23 21:16:51 2008 From: jon+usenet at unequivocal.co.uk (Jon Ribbens) Date: Wed, 23 Apr 2008 20:16:51 -0500 Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <6a6cb6a0-3907-4b5d-a0cd-07609571ab0b@m44g2000hsc.googlegroups.com> <480e176c$0$884$ba4acef3@news.orange.fr> Message-ID: On 2008-04-23, Mark Wooding wrote: > Python is actually one of the few to define one but not the other. (The > other one I can think of is Acorn's BBC BASIC, for whatever that's > worth; it too lacks `++'.) You should've added it in Termite Basic then :-p From mccredie at gmail.com Mon Apr 21 19:59:30 2008 From: mccredie at gmail.com (Matimus) Date: Mon, 21 Apr 2008 16:59:30 -0700 (PDT) Subject: Code question References: <60ffc058-488f-4e58-b3c9-a60c21595c6f@w8g2000prd.googlegroups.com> Message-ID: On Apr 21, 4:16 pm, George Sakkis wrote: > On Apr 21, 4:42 pm, Matimus wrote: > > > > > On Apr 21, 12:05 pm, wrote: > > > > I've been trying to figure out a way to combine lists similar to how zip() works. The main > > > difference though is I want to work with different length lists and combine them. I came up with > > > the example below, which returns a list like I'm wanting. I'm assuming it's somewhat efficient > > > (although I wonder if the lists were huge that the 'if' statement might slow things down?). > > > > If anyone has time, I was wondering if you could share your thoughts on whether this is an > > > efficient way to do something like this, if it's horrible and slow, etc. > > > > Thanks! > > > > Jay > > > > # ---------------------------- > > > > def combineLists(theLists): > > > cntList = len(theLists) > > > lenList = [len(x) for x in theLists] > > > > maxList = max(lenList) > > > > combinedList = [] > > > > for x in range(maxList): > > > for n in range(cntList): > > > if lenList[n] > x: combinedList.append(theLists[n][x]) > > > > print combinedList > > > > combineLists([a, b, c]) > > > > # ---------------------------- > > > > # --> ['a', '1', 'a1', 'b', '2', 'b2', 'c', 'c3', 'd4', 'e5'] > > > I would probably do something like this: > > > >>> def combine(*seqs): > > > ... seqs = [iter(s) for s in seqs] > > ... while seqs: > > ... for g in seqs: > > ... try: > > ... yield g.next() > > ... except StopIteration: > > ... seqs.remove(g) > > ...>>> a = 'abc' > > >>> b = '12' > > >>> c = 'a1 b2 c3 d4 e5'.split() > > >>> list(combine(a,b,c)) > > > ['a', '1', 'a1', 'b', '2', 'b2', 'c', 'c3', 'd4', 'e5'] > > > It has the advantage that it uses the generator protocol, so you can > > pass in any type of sequence. It uses arbitrary arguments to make its > > use closer to that of zip. It is also a generator, so it takes > > advantage of lazy evaluation. Notice that there is never any checking > > of length. > > > Matt > > A similar solution using the itertools module:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/528936 > > George Very nice. I was wondering if there would be a way to pull that try/ except block outside of the for loop. Jay: use this solution. It has all of the advantages I list for my solution, only it should be faster, and lazier. Matt From george.sakkis at gmail.com Fri Apr 4 12:22:13 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 4 Apr 2008 09:22:13 -0700 (PDT) Subject: Tokenizer inconsistency wrt to new lines in comments Message-ID: <1ce40dcf-4a0a-4577-af3b-6a77ef71356c@f63g2000hsf.googlegroups.com> The tokenize.generate_tokens function seems to handle in a context- sensitive manner the new line after a comment: >>> from StringIO import StringIO >>> from tokenize import generate_tokens >>> >>> text = ''' ... # hello world ... x = ( ... # hello world ... ) ... ''' >>> >>> for t in generate_tokens(StringIO(text).readline): ... print repr(t[1]) ... '\n' '# hello world\n' 'x' '=' '(' '\n' '# hello world' '\n' ')' '\n' '' Is there a reason that the newline is included in the first comment but not in the second, or is it a bug ? George From gagsl-py2 at yahoo.com.ar Thu Apr 3 00:39:27 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Apr 2008 01:39:27 -0300 Subject: Python queue madness References: <28749c0e0804020652o74a9491an9eef9ba1813434fb@mail.gmail.com> Message-ID: En Wed, 02 Apr 2008 10:52:08 -0300, nnp escribi?: > Basically I have a system where component 1, 2 and 3 communicate with > each > other using two Python Queues, we'll call them R and W. Here is what is > happening > > 1 writes data to W and reads from R > 2 reads data from W and writes data it receives from 3 to R (but not > data it > receives from 1) > 3 writes to W > > The problem is that data being written by 1 to W is appearing back on R. > I > have verified that 1 never writes to R and that 2 never writes data it > receives from 1 to R, by overwriting the put() and put_nowait() methods > of > R. > > Is there any other way for data to get onto a queue or are there any > known > bugs with Python's Queue module that could lead to this kind of > behaviour? Yes, your own code :) Perhaps you put mutable objects into the queue, like a list? and later modify the list in another place? -- Gabriel Genellina From python at bdurham.com Tue Apr 29 10:48:33 2008 From: python at bdurham.com (python at bdurham.com) Date: Tue, 29 Apr 2008 10:48:33 -0400 Subject: Given a string - execute a function by the same name In-Reply-To: <48171FCD.90902@mxm.dk> References: <1209471041.12820.1250459017@webmail.messagingengine.com> <48171FCD.90902@mxm.dk> Message-ID: <1209480513.8422.1250489215@webmail.messagingengine.com> Hi Max, Thank you for pointing out the pattern of my request. Using your google query (http://www.google.dk/search?hl=en&q=python+factory+pattern) I found the following description of what I'm doing. Command Dispatch Pattern http://www.suttoncourtenay.org.uk/duncan/accu/pythonpatterns.html#id26 Regards, Malcolm From goldspin at gmail.com Wed Apr 2 00:53:34 2008 From: goldspin at gmail.com (Henry Chang) Date: Tue, 1 Apr 2008 21:53:34 -0700 Subject: Basic class implementation question In-Reply-To: References: Message-ID: Try this. class wontwork: def really(self): print "Hello World" wontwork().really() On Tue, Apr 1, 2008 at 9:43 PM, wrote: > I can't get call a class for some reason. This must be one of those > newbie questions I hear so much about: > > class wontwork: > def really(): > print "Hello World" > > wontwork.really() > > This returns (as an error): > > Traceback (most recent call last): > File "", line 1, in > wontwork.really() > TypeError: unbound method really() must be called with wontwork > instance as first argument (got nothing instead) > > Any ideas? > -- > http://mail.python.org/mailman/listinfo/python-list > From duncan.booth at invalid.invalid Tue Apr 15 05:47:27 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 15 Apr 2008 09:47:27 GMT Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <1208196168.24295.36.camel@localhost.localdomain> <526792b1-acc2-4e48-8e9f-cc2641134958@k37g2000hsf.googlegroups.com> Message-ID: Chris wrote: > even is closer to even.75 than even+1.25. Why should it be rounded > up ? Because the OP wants to round values to the nearest integer. Only values of the form 'x.5' which have two nearest values use 'nearest even' to disambiguate the result. See http://en.wikipedia.org/wiki/Rounding#Round-to-even_method That's the way I was taught to round numbers when at primary school. From ncoghlan at gmail.com Mon Apr 21 09:14:08 2008 From: ncoghlan at gmail.com (NickC) Date: Mon, 21 Apr 2008 06:14:08 -0700 (PDT) Subject: Java or C++? References: Message-ID: On Apr 15, 1:46 pm, Brian Vanderburg II wrote: > This will automatically call the constructors of any contained objects > to initialize the string. The implicit assignment operator > automatically performs the assignment of any contained objects. > Destruction is also automatic. When 'p1' goes out of scope, during the > destructor the destructor for all contained objects is called. Yeah, C++ does try to be helpful, and all of those automatic copy constructor, assignment operator and destructor implementations screw up royally when confronted with pointers (and being able to use pointers is basically the whole reason for bothering to write anything in C or C++ in the first place). Code which relies on these default method implementations is almost certain to be rife with memory leaks and double-free bugs. So instead of being a convenience, they become a painfully easy way of writing code that silently does some very, very wrong things. Other things like methods (including destructors!) being non-virtual by default also make C++ code annoyingly easy to get wrong (without it obviously looking wrong). The whole design of C++ is riddled with premature optimisation of speed and memory usage in the default settings, instead of choosing safe defaults and providing concise ways of allowing the programmer to say "I know optimisation X is safe here, please use it". And the result? Any serious project in the language has to adopt it's own techniques for avoiding all those traps, and those techniques are likely to eliminate any supposed optimisations provided by the choices of the C++ committee, while filling a code base with boilerplate that only exists for the purpose of working around defects in the language design (Scott Meyers has written at length about the worst of these issues, far more clearly and eloquently than I ever could [1]). That said, C++ code has one *huge* benefit over ordinary C code, which is scope-controlled deletion of objects, and the associated Resource- Acquisition-Is-Initialisation model. Even without using exceptions (although those are handy as well), RAII is an excellent way of guaranteeing that memory is freed, files are closed, or other resources are released when a block of code is finished. RAII was actually one of the inspirations behind the final form of PEP 343's with statement. Cheers, Nick. [1]http://www.amazon.com/Effective-Specific-Addison-Wesley- Professional-Computing/dp/0201924889 From bvidinli at gmail.com Mon Apr 14 09:42:28 2008 From: bvidinli at gmail.com (bvidinli at gmail.com) Date: Mon, 14 Apr 2008 14:42:28 +0100 (BST) Subject: A Question Message-ID: <200804141342.CBB81112@manxnetsf02.manx.net> Fertler? From deets at nospam.web.de Fri Apr 11 21:13:19 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Sat, 12 Apr 2008 03:13:19 +0200 Subject: Wrapping C++ class with SWIG, Mac OS X In-Reply-To: References: Message-ID: <66aglpF2ihunjU1@mid.uni-berlin.de> Paul Anton Letnes schrieb: > Hello guys, > > > (related to previous thread on wrapping C/C++ in Python, trying the SWIG > approach.) > Trying to map a C++ class to python, one method for now. Running the > following commands to "compile": > > -------------------------------------- > #!/usr/bin/env bash > > MOD_NAME=Wavelet > > > swig -c++ -python -o ${MOD_NAME}_wrap.cpp ${MOD_NAME}.i > > gcc -c++ -fPIC -c ${MOD_NAME}.cpp -o ${MOD_NAME}.o > -I/usr/include/python2.5 -I/usr/lib/python2.5 > > gcc -c++ -fPIC -c ${MOD_NAME}_wrap.cpp -o ${MOD_NAME}_wrap.o > -I/usr/include/python2.5 -I/usr/lib/python2.5 > > gcc -bundle -flat_namespace -undefined suppress -o _${MOD_NAME}.so > ${MOD_NAME}.o ${MOD_NAME}_wrap.o > -------------------------------------- > > The source code is: > -------------------------------------- > Wavelet.h > -------------------------------------- > #ifndef _WAVELET_H_ > #define _WAVELET_H_ > > #include > #include > > using namespace std; > > class Wavelet > { > > public: > Wavelet(vector theV); > ~Wavelet(); > vector GetDaub4Trans(); > > private: > vector v; > > }; > > > #endif /*_WAVELET_H_*/ > -------------------------------------- > and Wavelet.cpp: > -------------------------------------- > #include "wavelet.h" > > Wavelet::Wavelet(vector theV) > { > this->v = theV; > } > > Wavelet::~Wavelet() > { > // Nothing for now > } > > vector Wavelet::GetDaub4Trans() > { > vector retV = vector(); > retV.push_back(3.14); > retV.push_back(2.71); > retV.push_back(1.62); > return retV; > // just to test the approach - everything in here I can fix later. > } > -------------------------------------- > This seems to compile, but in python I get: > -------------------------------------- > $ python > imPython 2.5.2 (r252:60911, Mar 30 2008, 22:49:33) > [GCC 4.0.1 (Apple Inc. build 5465)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > >>> import Wavelet > Traceback (most recent call last): > File "", line 1, in > File "Wavelet.py", line 7, in > import _Wavelet > ImportError: dlopen(./_Wavelet.so, 2): Symbol not found: > __ZNKSt11logic_error4whatEv > Referenced from: /Users/paul/Desktop/Wavelet_SWIG_Cpp/_Wavelet.so > Expected in: flat namespace > > >>> > -------------------------------------- > > Any ideas or tips? SWIG seems very nice for simple C methods where you > pass an int and return an int, but I can't seem to figure out the > syntaxes etc for more complicated stuff - arrays, vector, C++, ... > Appreciate any help! Can't help on SWIG - all I can say is that SIP which is used to wrap the large and template-ridden C++-GUI-Toolkit Qt worked flawlessly for me. Maybe you should try that. Diez From alexdbkim at gmail.com Tue Apr 15 03:42:56 2008 From: alexdbkim at gmail.com (Alexander Dong Back Kim) Date: Tue, 15 Apr 2008 00:42:56 -0700 (PDT) Subject: How to import C++ static library? Message-ID: Hi all, I'm very very beginner of python but I'm dare to ask this question straight away. =P Is it possible to import C++ static library compiled by GCC? The target is definitely Linux machine. I found some examples from Google showing the way C++ can import Python so called embedded python. But I want to the opposite way of this. I want to import (or include in C world terminology) the library which is a blah.a file to reuse in python. Any suggestion or idea for this stupid beginner? ;) cheers, Alex From mail at timgolden.me.uk Sat Apr 12 01:58:05 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Sat, 12 Apr 2008 06:58:05 +0100 Subject: Windows - window status (Running vs Not Responding) In-Reply-To: References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> Message-ID: <48004F6D.2010100@timgolden.me.uk> Ross Ridge wrote: > rdahlstrom wrote: >> Basically, I'm looking for something similar to the Process.Responding >> property in System.Diagnostics... > > You probably want to use IsHungAppWindow(): Brilliant! So simple when you find out. Thanks. (Added to my list of things I never knew I never knew about Windows). TJG From deets at nospam.web.de Tue Apr 22 15:17:18 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 22 Apr 2008 21:17:18 +0200 Subject: Spawing a thread and printing dots until it finishes In-Reply-To: References: Message-ID: <676ruhF2lt14mU1@mid.uni-berlin.de> > I think that there are two things that you need to wrap your head > around before understanding what is happening here. First, threads are > NOT pre-emptive. Unless your thread gives up the processor it will run > forever. The sleep call is one way to give up the processor. That is not correct, at least not on usual OSes. The posix-threads as well as windows threads *are* preemptive. > Second, sleep() does not return as soon as the time given has expired. > The argument is the MINIMUM amount of time that it waits. After that > the thread that slept is put back onto the run queue and is now a > candidate to be given the processor. Your other thread still has to > give up the processor before it can run again and even then there may > be other threads on the queue ahead of yours. > > So, does your thread ever give up the processor other than by dying? It shouldn't need to. It will be rescheduled. The code looks ok to me - the problem seems to be in the R-Python as Gabriel pointed out. Diez From mail at timgolden.me.uk Fri Apr 11 09:47:20 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 11 Apr 2008 14:47:20 +0100 Subject: Convert PyIDispatch object to struct IDispatch* In-Reply-To: <83260aaf-b2d7-4857-bd71-a8e7b30c6d70@n14g2000pri.googlegroups.com> References: <90eee1e1-b1cc-48a9-8c09-173e92861f2c@a5g2000prg.googlegroups.com> <83260aaf-b2d7-4857-bd71-a8e7b30c6d70@n14g2000pri.googlegroups.com> Message-ID: <47FF6BE8.2030606@timgolden.me.uk> Huayang Xia wrote: > On Apr 11, 12:15 am, "Gabriel Genellina" > wrote: >> En Thu, 10 Apr 2008 18:45:04 -0300, Huayang Xia >> escribi?: >> >>> I am trying to use ctypes to call dll functions. One of the functions >>> requires argument "struct IDispatch* ". I do have a PyIDispatch object >>> in python. How can I convert this "PyIDispatch object" to "struct >>> IDispatch* "? >> I think a PyIDispatch object is an IDispatch* itself. >> But you'll get better answers from the python-win32 list:http://mail.python.org/mailman/listinfo/python-win32 >> >> -- >> Gabriel Genellina > > Thanks for the info. > > To call a dll function, it needs a C style IDispatch*. PyIDispatch is > a python wrapped one. I found a reference from: > > http://svn.python.org/projects/ctypes/trunk/comtypes/comtypes/test/test_win32com_interop.py > > which shows how to convert C style to python style. Unfortunately i > need the reversed version. > > I will post the question to python-win32. I've had a quick look at the PyIDispatch source and I can't see any obvious way in which the underlying IDispatch is exposed. May have missed something, but it's possible that there's not way out. TJG From steve at holdenweb.com Wed Apr 23 15:26:37 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 15:26:37 -0400 Subject: Partition list with predicate In-Reply-To: References: <925822270804230959v557ec5f5re02737709f94d3c6@mail.gmail.com> Message-ID: Terry Reedy wrote: > "Jared Grubb" wrote in message > news:925822270804230959v557ec5f5re02737709f94d3c6 at mail.gmail.com... > | I want a function that removes values from a list if a predicate > evaluates > | to True. > > Forget the rigamarole you posted, which has several defects. > If you must modify the list in place, because you have multiple references > to it: > > lst[:] = filter(lambda x: not pred(x), lst) > Wouldn't lst[:] = [x for x in lst if not pred(x)] be more direct? > Otherwise, just lst = filter(....) > And similarly lst = [x for x in lst if not pred(x)] regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From ptmcg at austin.rr.com Fri Apr 11 06:46:43 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Fri, 11 Apr 2008 03:46:43 -0700 (PDT) Subject: Randall Munroe loves Python Message-ID: <869c25d9-e4d3-4629-a807-f3b203f3fb65@b1g2000hsg.googlegroups.com> Another xkcd plug for Python: http://xkcd.com/409/ From bj_666 at gmx.net Mon Apr 14 03:26:05 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 14 Apr 2008 07:26:05 GMT Subject: Game design : Making computer play References: Message-ID: <66gf8dF2ju94lU3@mid.uni-berlin.de> On Mon, 14 Apr 2008 00:13:56 -0700, v4vijayakumar wrote: > In computer based, two player, board games, how to make computer play? > Are there any formal ways to _teach_ computer, to choose best possible > move? That depends on the type of the game. For a certain class of games one can use the `minimax method`_ for instance. .. _minimax method: http://en.wikipedia.org/wiki/Minimax Ciao, Marc 'BlackJack' Rintsch From ni at hao.com Wed Apr 30 03:19:22 2008 From: ni at hao.com (SL) Date: Wed, 30 Apr 2008 09:19:22 +0200 Subject: computing with characters In-Reply-To: References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl><481813E2.2030302@islandtraining.com> Message-ID: <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> "Lutz Horn" schreef in bericht news:mailman.360.1209537877.12834.python-list at python.org... > Hi, > > 2008/4/30 Gary Herron : >> SL wrote: >> > How can I compute with the integer values of characters in python? >> > Like 'a' + 1 equals 'b' etc >> >> You can get an integer value from a character with the ord() function. > > So just for completion, the solution is: > >>>> chr(ord('a') + 1) > 'b' thanks :) I'm a beginner and I was expecting this to be a member of string so I couldnt find it anywhere in the docs. From sjmachin at lexicon.net Mon Apr 14 08:11:13 2008 From: sjmachin at lexicon.net (John Machin) Date: Mon, 14 Apr 2008 05:11:13 -0700 (PDT) Subject: py2exe, program has stoped working!? References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> <232151d6-09ed-4a1e-9922-d66c2bf0d05b@w8g2000prd.googlegroups.com> Message-ID: On Apr 14, 7:24 pm, skanem... at yahoo.se wrote: > > Is it a console program or a gui program? > GUI > > What happens when you run it without py2exe? > > it works perfectly, both from within python and launching from > "windows" > > > Have you searched for "has stopped working" in > > (a) your source code > yes no such message there> (b) the py2exe source code? > > no, will do but doubt thats the problem > > > Have you managed to get any py2exe-created program to run properly? > > no Well, perhaps you might like to look in the samples directory of the py2exe distribution and choose a simple example and try that. By the way, "popup" is what you get in a web browser. What did this "popup" look like: a panel from your GUI software? A Windows message box? Did it have a title across the top? What was the exact text in the popup/panel/box? Were there any options other than to close the window? Which version of Python? Which Windows, what service pack? What GUI, what version? Care to divulge the contents of your setup.py? Apart from your GUI, what 3rd party packages/modules are you importing? From jphalip at gmail.com Tue Apr 29 09:46:05 2008 From: jphalip at gmail.com (Julien) Date: Tue, 29 Apr 2008 06:46:05 -0700 (PDT) Subject: Issue with regular expressions Message-ID: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Hi, I'm fairly new in Python and I haven't used the regular expressions enough to be able to achieve what I want. I'd like to select terms in a string, so I can then do a search in my database. query = ' " some words" with and "without quotes " ' p = re.compile(magic_regular_expression) $ <--- the magic happens m = p.match(query) I'd like m.groups() to return: ('some words', 'with', 'and', 'without quotes') Is that achievable with a single regular expression, and if so, what would it be? Any help would be much appreciated. Thanks!! Julien From sturlamolden at yahoo.no Thu Apr 24 20:19:44 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 17:19:44 -0700 (PDT) Subject: Psyco alternative References: <1369b321-f55b-432b-b2f9-6144787509d8@h11g2000prf.googlegroups.com> <7xlk4473ai.fsf@ruckus.brouhaha.com> <651ncdF2cmik2U1@mid.uni-berlin.de> <651onqF2dripdU1@mid.uni-berlin.de> <47EBB42D.9090206@behnel.de> <25b14b32-8fce-4e79-b236-c64fa96744e8@e23g2000prf.googlegroups.com> Message-ID: On Mar 27, 5:01 pm, king kikapu wrote: > Hmmm...thanks but i think Pyrex-like solution is not the ideal one. > Coming from C# and having 8 years of expertise on it, i have gain a > very positive thinking about jit compilers and i think that psyco (ok, > a just-in-time specializer) is a more easy (and more correct) way to > go that mixing 2 languages. The problem with Python, when we are talking out jit compilation, is it's reliance on attribute lookups in hash tables. Java and C# do not have dynamically bound attributes, and can implement classes using vtables. Attributes cannot be rebound in Java or C#. A Python jit cannot even do elementary optimizations like keeping an integer in a register. This makes it a lot easier to make an efficient jit compiler for Java or C#. Python is more like Common Lisp. There is no efficient jit for Lisp. But there are very fast implementations that depend on optional static typing (e.g. SBCL and CMUCL). That could be an option of Python as well, by including something like Cython and a C compiler. Any module that has a cdef is passed to Cython and CC instead of the usual bytecode compiler and interpreter. From mr.enx at alice.it Mon Apr 7 03:19:01 2008 From: mr.enx at alice.it (mr.enx at alice.it) Date: Mon, 7 Apr 2008 00:19:01 -0700 (PDT) Subject: ldap Message-ID: <050e9150-7bbf-4a46-8c63-9d61835b1429@d1g2000hsg.googlegroups.com> sorry, i'm new with Python. I must do interaction beetween Python and Ldap, and I don't know how do this. Searching on the web I know that exists PythonLdap, but I dont'know if this is best choise or not. Thank's From gagsl-py2 at yahoo.com.ar Sun Apr 20 04:12:09 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 05:12:09 -0300 Subject: Checking for unique fields: performance. References: <2dc0c81b0804180823k46a220f1w77a166e6b08f67de@mail.gmail.com> Message-ID: En Fri, 18 Apr 2008 12:23:08 -0300, Shawn Milochik escribi?: > I'm looping through a tab-delimited file to gather statistics on fill rates, > lengths, and uniqueness. > > For the uniqueness, I made a dictionary with keys which correspond to the > field names. The values were originally lists, where I would store values > found in that field. Once I detected a duplicate, I deleted the entire > element from the dictionary. Any which remained by the end are considered > unique. Also, if the value was empty, the dictionary element was deleted and > that field considered not unique. > > A friend of mine suggested changing that dictionary of lists into a > dictionary of dictionaries, for performance reasons. As it turns out, the > speed increase was ridiculous -- a file which took 42 minutes to run dropped > down to six seconds. A dictionary with keys is perfectly reasonable. But a *list* of values has to be searched linearly for every value: a O(n) process. As your friend suggested, searching a dictionary requires O(1) time. A set is even better in this case, because you don't have any use for the values in the inner dictionary (sets and dictionaries are very similar in the implementation). > Here is the excerpt of the bit of code which checks for uniqueness. It's > fully functional, so I'm just looking for any suggestions for improving it > or any comments. Note that fieldNames is a list containing all column > headers. > > #check for unique values > #if we are still tracking that field (we haven't yet > #found a duplicate value). > if fieldUnique.has_key(fieldNames[index]): > #if the current value is a duplicate > if fieldUnique[fieldNames[index]].has_key(value): > #sys.stderr.write("Field %s is not unique. Found a > duplicate value after checking %d values.\n" % (fieldNames[index], lineNum)) > #drop the whole hash element > fieldUnique.__delitem__(fieldNames[index]) > else: > #add the new value to the list > fieldUnique[fieldNames[index]][value] = 1 > - Instead of using fieldNames[index] all along the place, save it in a variable. - Your code doesn't show it, but if you are traversing the fieldNames vector like this: for index in range(len(fieldNames)): ... using fieldNames[index] ... it's better to use: for fieldName in fieldNames: ... using fieldName all along the place ... - Instead of a.has_key(b), use: b in a - Instead of fieldUnique.__delitem__(fieldNames[index]) use: del fieldUnique[fieldName] (In normal code, __special__ methods are never used) #check for unique values #if we are still tracking that field (we haven't yet #found a duplicate value). if fieldName in fieldUnique: #if the current value is a duplicate if value in fieldUnique[fieldName]: #drop the whole field as it's not unique del fieldUnique[fieldName] else: #add the new value to the set fieldUnique[fieldName].add(value) else: # use a set to store the unique values fieldUnique[fieldName] = set([value]) -- Gabriel Genellina From meisnernel73884 at gmail.com Wed Apr 30 06:37:59 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:37:59 -0700 (PDT) Subject: rar password crack Message-ID: <9be5e1ec-9d73-4f0c-bf92-5dc2dd6547e8@e53g2000hsa.googlegroups.com> rar password crack http://crack.cracksofts.com From arnodel at googlemail.com Sat Apr 26 01:37:19 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sat, 26 Apr 2008 06:37:19 +0100 Subject: Setting an attribute without calling __setattr__() References: Message-ID: Joshua Kugler writes: [...] > self.me = [] > for v in obj: > self.me.append(ObjectProxy(v)) Note that is could be spelt: self.me = map(ObjectProxy, v) -- Arnaud From mwilson at the-wire.com Wed Apr 2 10:57:50 2008 From: mwilson at the-wire.com (Mel) Date: Wed, 02 Apr 2008 10:57:50 -0400 Subject: generator functions: why won't this work? References: <0aaeddf2-ee63-426e-afb3-0e1acb15adef@r9g2000prd.googlegroups.com> Message-ID: zillow10 at googlemail.com wrote: I'd just like to test my > understanding of this. Suppose I create the following generator > object: > > g = getNextScalar(1, 2, (3, 4), 5) > > when the iterator reaches the tuple argument (3, 4) then, according to > Steve and George, the * in *arg causes this tuple to be expanded into > positional arguments, and it makes sense to do it this way. But what > happens when getNextScalar(arg) is used instead? Try it: Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def a (arg): ... print arg ... >>> def astar (*arg): ... print arg ... >>> a(3,4) Traceback (most recent call last): File "", line 1, in TypeError: a() takes exactly 1 argument (2 given) >>> astar(3,4) (3, 4) >>> a((3,4)) (3, 4) >>> astar((3,4)) ((3, 4),) >>> Mel. From meisnernel73884 at gmail.com Wed Apr 30 06:36:57 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:36:57 -0700 (PDT) Subject: soul patch Message-ID: <82de0c8d-54d3-4ddb-a78d-67deadfa75bf@f63g2000hsf.googlegroups.com> soul patch http://crack.cracksofts.com From skanemupp at yahoo.se Sun Apr 6 13:24:34 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 6 Apr 2008 10:24:34 -0700 (PDT) Subject: Tkinter, repaint?, keep size? Message-ID: <6ff2ce5f-9ba3-492c-b062-324c91e652a0@e10g2000prf.googlegroups.com> so my calculator is almost done for u that have read my previous posts. i have some minor problems i have to fix though. *one is i need to repaint once i have performed a calculation so that the old results are not left on the screen. cant find a method for that. *another is now when i write the expression to be evaluated it resizes the window as the text grows. i want the windowsize and all the buttonplacements stay constant, how do i achieve this? From martin at v.loewis.de Fri Apr 25 14:46:17 2008 From: martin at v.loewis.de (=?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Fri, 25 Apr 2008 20:46:17 +0200 Subject: Why is None <= 0 In-Reply-To: References: Message-ID: <481226f9$0$20866$9b622d9e@news.freenet.de> >>>> None <= 0 > True > > Why? > Is there a logical reason? None is smaller than anything. The choice of making it so is arbitrary, however, Python 2.x tries to impose a total order on all objects (with varying success), therefore, it is necessary to take arbitrary choices. (FWIW, in 2.x, x>=4?, it's None < numbers < anything else; numbers are ordered by value, everything else is ordered by type name, then by address, unless comparison functions are implemented). Regards, Martin From jyoung79 at kc.rr.com Mon Apr 21 15:05:12 2008 From: jyoung79 at kc.rr.com (jyoung79 at kc.rr.com) Date: Mon, 21 Apr 2008 14:05:12 -0500 Subject: Code question Message-ID: <29695217.1653031208804712889.JavaMail.root@hrndva-web20-z02> I've been trying to figure out a way to combine lists similar to how zip() works. The main difference though is I want to work with different length lists and combine them. I came up with the example below, which returns a list like I'm wanting. I'm assuming it's somewhat efficient (although I wonder if the lists were huge that the 'if' statement might slow things down?). If anyone has time, I was wondering if you could share your thoughts on whether this is an efficient way to do something like this, if it's horrible and slow, etc. Thanks! Jay # ---------------------------- a = ['a', 'b', 'c'] b = ['1', '2'] c = ['a1', 'b2', 'c3', 'd4', 'e5'] def combineLists(theLists): cntList = len(theLists) lenList = [len(x) for x in theLists] maxList = max(lenList) combinedList = [] for x in range(maxList): for n in range(cntList): if lenList[n] > x: combinedList.append(theLists[n][x]) print combinedList combineLists([a, b, c]) # ---------------------------- # --> ['a', '1', 'a1', 'b', '2', 'b2', 'c', 'c3', 'd4', 'e5'] From m.bless at gmx.de Fri Apr 18 03:06:18 2008 From: m.bless at gmx.de (Martin Bless) Date: Fri, 18 Apr 2008 09:06:18 +0200 Subject: codec for html/xml entities!? Message-ID: Hi friends, I've been OFF-Python now for quite a while and am glad being back. At least to some part as work permits. Q: What's a good way to encode and decode those entities like € or € ? I need isolated functions to process lines. Looking at the xml and sgmlib stuff I didn't really get a clue as to what's the most pythonic way. Are there library functions I didn't see? FYI, here is what I hacked down and what will probably (hopefully...) do the job. Feel free to comment. # -*- coding: iso-8859-1 -*- """\ entity_stuff.py, mb, 2008-03-14, 2008-03-18 """ import htmlentitydefs import re RE_OBJ_entity = re.compile('(&.+?;)') def entity2uc(entity): """Convert entity like { to unichr. Return (result,True) on success or (input string, False) otherwise. Example: entity2cp('€') -> (u'\u20ac',True) entity2cp('€') -> (u'\u20ac',True) entity2cp('€') -> (u'\u20ac',True) entity2cp('&foobar;') -> ('&foobar;',False) """ gotCodepoint = False gotUnichr = False if entity.startswith('&#'): if entity[2] == 'x': base = 16 digits = entity[3:-1] else: base = 10 digits = entity[2:-1] try: v = int(digits,base) gotCodepoint = True except: pass else: v = htmlentitydefs.name2codepoint.get(entity[1:-1],None) if not v is None: gotCodepoint = True if gotCodepoint: try: v = unichr(v) gotUnichr = True except: pass if gotUnichr: return v, gotUnichr else: return entity, gotUnichr def line_entities_to_uc(line): result = [] cntProblems = 0 for e in RE_OBJ_entity.split(line): if e.startswith('&'): e,success = entity2uc(e) if not success: cntProblems += 1 result.append(e) return u''.join(result), cntProblems def uc2entity(uc): cp = ord(uc) if cp > 127: name = htmlentitydefs.codepoint2name.get(cp,None) if name: result = '&%s;' % name else: result = '&#x%x;' % cp else: result = chr(cp) return result def encode_line(line): return ''.join([uc2entity(u) for u in line]) if 1 and __name__=="__main__": import codecs infile = 'temp.ascii.xml' outfile = 'temp.utf8.xml' of = codecs.open(outfile,'wb','utf-8') totalProblems = 0 totalLines = 0 for line in file(infile,'rb'): line2, cntProblems = line_entities_to_uc(line) of.write(line2) totalLines += 1 totalProblems += cntProblems of.close() print print "Summary:" print " Infile : %s" % (infile,) print " Outfile: %s" % (outfile,) print ' %8d %s %s' % (totalLines, ['lines','line'][totalLines==1], 'written.') print ' %8d %s %s' % (totalProblems, ['entities','entity'][totalProblems==1], 'left unconverted.') print '%s' % ('Done.',) Have a nice day and ru, Martin (read you, ;-) From tjreedy at udel.edu Sun Apr 6 16:34:23 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 6 Apr 2008 16:34:23 -0400 Subject: Tkinter, a lot of buttons, make prog shorter? References: Message-ID: wrote in message news:c9bf3bb9-71e4-48f6-aae0-fa9400ca8155 at j1g2000prb.googlegroups.com... | is there anyway to make this shorter? i hate having these big blocks | of similar-looking code, very unaesthetic. | maybe doesnt matter good-code-wise? | anyway can i make some function that makes this shorter? | like put the etiquettes on the button froma string of | '123+456-789*0Cr/' ? | problem is the command and lambda-func for each button is different. | | | self.btnDisplay = Button(self,text='1',command=lambda | n="1":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=3, column=0) | | self.btnDisplay = Button(self,text='2',command=lambda | n="2":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=3, column=1) | | self.btnDisplay = Button(self,text='3',command=lambda | n="3":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=3, column=2) | | self.btnDisplay = Button(self,text='+',command=lambda | n="+":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=3, column=3) | | self.btnDisplay = Button(self,text='4',command=lambda | n="4":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=4, column=0) | | self.btnDisplay = Button(self,text='5',command=lambda | n="5":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=4, column=1) | | self.btnDisplay = Button(self,text='6',command=lambda | n="6":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=4, column=2) | | self.btnDisplay = Button(self,text='-',command=lambda | n="-":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=4, column=3) | | self.btnDisplay = Button(self,text='7',command=lambda | n="7":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=5, column=0) | | self.btnDisplay = Button(self,text='8',command=lambda | n="8":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=5, column=1) | | self.btnDisplay = Button(self,text='9',command=lambda | n="9":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=5, column=2) | | self.btnDisplay = Button(self,text='*',command=lambda | n="*":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=5, column=3) | | self.btnDisplay = Button(self,text='0',command=lambda | n="0":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=6, column=0) | | self.btnDisplay = | Button(self,text='C',command=self.Clean,width=2,height=2) | self.btnDisplay.grid(row=6, column=1) | | self.btnDisplay = Button(self,text='r',command=lambda | n="r":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=6, column=2) | | self.btnDisplay = Button(self,text='/',command=lambda | n="/":self.Display(n),width=2,height=2) | self.btnDisplay.grid(row=6, column=3) With the exception of the 'C' button, the only thing different is the label and position. I believe (untested, obviously) def btn(self, txt, r, c): self.btnDisplay = Button(self, text=txt, command=lambda: self.Display(txt), width=2,height=2) self.btnDisplay.grid(row=r, column=r) will work. tjr From daitangio at gmail.com Wed Apr 30 10:13:49 2008 From: daitangio at gmail.com (Giovanni Giorgi) Date: Wed, 30 Apr 2008 07:13:49 -0700 (PDT) Subject: Python Search Engine powered by Google Message-ID: <7e5be687-4644-49df-bbda-b4dcde63011b@d1g2000hsg.googlegroups.com> Hi all, I am working on a customized python search engine: http://blog.objectsroot.com/python/ It is done using a special feature of Google, and it is focused on python I'd like to have the contribution of other guys out of there to fine tuning it. Feel free to use it and give me your feedback. You can leave a comment on my blog. Bye bye From sierra9162 at gmail.com Wed Apr 16 11:23:09 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:23:09 -0700 (PDT) Subject: kate hudson tattoo Message-ID: <2cb4a8f1-7f6d-4956-9016-c6da9d8f65ab@b1g2000hsg.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From Lie.1296 at gmail.com Tue Apr 8 16:52:11 2008 From: Lie.1296 at gmail.com (Lie) Date: Tue, 8 Apr 2008 13:52:11 -0700 (PDT) Subject: Translating keywords References: Message-ID: <6537f3aa-512f-466e-ac31-6fa1266be8dc@k10g2000prm.googlegroups.com> On Apr 7, 9:54 pm, Steve Holden wrote: > Ronn Ross wrote: > > This is my first post and I'm new to Python. How would someone go about > > adding keywords to Python? It would be great to add support for > > Esperanto keywords in the language instead of English being the only > > option. > > Unfortunately the resulting language would no longer be Python. > > You need to consider software portability: Python has been very > conservative about declaring words to be "keywords" in the language, > though clearly words like "def" and "class" must necessarily be part of > the syntax. > > When you start to replace the keywords, though, your programs are no > longer runnable on all Python installations, and simple transliteration > fails because sometimes a keyword in one (natural) language will > conflict with a programmer's choice of name(s) in another. I think it might be possible to create a translation table, where this native-language code would be accompanied by an extra file that maps the replaced keywords with Python keywords. And before the code is compiled, it's preprocessed to map the native-language keywords to Python keyword. But I think if such feature is made available, it would crack the language into lots of sub-languages and that would make code exchange hard, and it wouldn't be long before people start being creative and added language support for languages like Klingon or Pig Latin. On Apr 8, 12:47?pm, Arnaud Delobelle wrote: > On Apr 8, 3:47?am, "Gabriel Genellina" wrote: > > > Python 3 allows for unicode identifiers, but I don'k know any plans for ? > > using unicode keywords too. Looks funny: > > > ? x ? values: > > ? ?if x ? forbidden ? x ? y: > > ? ? ?print(x, ?(x), ?(x)) > > print(?(values)) > > near = ? a,b,?=0.01: a-? ? b ? a+? > > It's all in the eye of the beholder: to me it looks readable, but > that's because I've spent 10 years of my life reading and writing > stuff like that. ?Although I would use ? and ? as aliases for all() > and exists() :) > > -- > Arnaud It looks readable to a mathematician, but not to a regular person or even a regular programmer not specializing in mathematics. And the single downside why I think using symbols is bad is because you can't Google with those. And if you don't know Greek (or whatever language the symbol comes from), you can't even name the symbol to search for the meaning. From c.boulanger at qxtransformer.org Tue Apr 29 16:16:04 2008 From: c.boulanger at qxtransformer.org (Panyasan) Date: Tue, 29 Apr 2008 13:16:04 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <473deef3-9acb-45dd-a7ca-47b0081bd28c@i36g2000prf.googlegroups.com> <3f7bb91e-335e-46bd-88ca-f15b26c35132@k1g2000prb.googlegroups.com> <827bdae6-4422-4226-a543-af53f5b7e01b@s33g2000pri.googlegroups.com> <083b58e8-522a-4c01-b612-c592fe69fcd1@i36g2000prf.googlegroups.com> <2978ec5b-fd7c-4fb1-9aa5-4bb88ba46ee8@m73g2000hsh.googlegroups.com> Message-ID: On 29 Apr., 20:30, Panyasan wrote: > On 29 Apr., 18:17, John Henry wrote: > > > > > There are a whole bunch of test programs that comes with Pythoncard. > > Do they work? (Not all of them will work - some requires a database) > > Yes, the examples work. Just the resourceEditor.py and the > layoutEditor.py in the distributed version and your modified > layoutEditor.py don't. Ok, here is how it works for me: copy all the *.rsrc.py from the modules subdirectory to the parent directory. This works for the standard resourceEditor folder and your custom layoutEditor folder. What the heck. Now I can deal with more productive things... From bignose+hates-spam at benfinney.id.au Sat Apr 26 00:47:26 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Sat, 26 Apr 2008 14:47:26 +1000 Subject: Why is None <= 0 References: Message-ID: <87d4od5ijl.fsf@benfinney.id.au> Grant Edwards writes: > On 2008-04-25, D'Arcy J.M. Cain wrote: > > On Fri, 25 Apr 2008 20:27:15 +0200 > > Gregor Horvath wrote: > >> >>> None <= 0 > >> True > > Everything in Python can compare to everything else. > > Not true. Even more untrue in Python 3.0: Comparisons other than == and != between disparate types will raise an exception unless explicitly supported by the type -- \ "We demand rigidly defined areas of doubt and uncertainty!" -- | `\ Vroomfondel, _The Hitch-Hiker's Guide To The Galaxy_, Douglas | _o__) Adams | Ben Finney From sjmachin at lexicon.net Sat Apr 12 05:33:58 2008 From: sjmachin at lexicon.net (John Machin) Date: Sat, 12 Apr 2008 02:33:58 -0700 (PDT) Subject: accessing individual characters in unicode strings References: Message-ID: On Apr 12, 3:45 pm, Peter Robinson wrote: > Dear list > I am at my wits end on what seemed a very simple task: > I have some greek text, nicely encoded in utf8, going in and out of a > xml database, being passed over and beautifully displayed on the web. > For example: the most common greek word of all 'kai' (or ??? if your > mailer can see utf8) > So all I want to do is: > step through this string a character at a time, and do something for > each character (actually set a width attribute somewhere else for each > character) > > Should be simple, yes? > turns out to be near impossible. I tried using a simple index > character routine such as ustr[0]..ustr[1]... and this gives rubbish. > So I use len() to find out how long my simple greek string is, and of > course it is NOT three characters long. The utf8-encoded incarnation is three characters long and it's six bytes long. utf-8 is not unicode. > > A day of intensive searching around the lists tells me that unicode > and python is a moving target: so many fixes are suggested for similar > problems, none apparently working with mine. > > Here is the best I can do, so far > I convert the utf8 string using > ustr = repr(unicode(thisword, 'iso-8859-7')) Don't do that. If you have a utf8 string, convert it to unicode like this: ustr = unicode(the_utf8_string, 'utf8') If you have a string encoded in iso-8859-7, convert it to unicode like this: ustr = unicode(the_iso_8859_7_string, 'iso-8859-7') Then inspect it like this: print repr(ustr) Here's a sample interactive session: >>> thisword = '\xce\xba\xce\xb1\xce\xb9' >>> ustr = unicode(thisword, 'utf8') >>> len(ustr) 3 >>> print repr(ustr) u'\u03ba\u03b1\u03b9' >>> import unicodedata >>> [unicodedata.name(x) for x in ustr] ['GREEK SMALL LETTER KAPPA', 'GREEK SMALL LETTER ALPHA', 'GREEK SMALL LETTER IOTA'] Suggested reading: the Python Unicode HOWTO at http://www.amk.ca/python/howto/unicode This may be handy: http://unicode.org/charts/PDF/U0370.pdf HTH, John From carlwuhwdmckay at gmail.com Sat Apr 26 09:32:18 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:32:18 -0700 (PDT) Subject: cabbage patch dolls Message-ID: <5139a47c-d67c-4b34-b83c-2cfbccaeba39@j22g2000hsf.googlegroups.com> cabbage patch dolls http://cracks.00bp.com F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Tue Apr 1 20:45:31 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 21:45:31 -0300 Subject: XML Parsing References: <5f1019b7-47e1-4fcf-a00c-b982c6b2fd79@f63g2000hsf.googlegroups.com> Message-ID: En Tue, 01 Apr 2008 20:44:41 -0300, 7stud escribi?: >> ? ? ? ? ? I am new to XML parsing.Could you kindly tell me whats the >> problem with the following code: >> >> import xml.dom.minidom >> import xml.parsers.expat > > I don't know if you are aware of the BeautifulSoup module: > Or ElementTree: import xml.etree.ElementTree as ET doctext = """LettermanisbetterthanJayLeno""" doc = ET.fromstring(doctext) for token in doc.findall("token"): print 'pos:', token.get('pos') print 'text:', token.text -- Gabriel Genellina From castironpi at gmail.com Wed Apr 2 14:10:53 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 2 Apr 2008 11:10:53 -0700 (PDT) Subject: python persistence References: <8b1723d9-67c8-4fe5-b07b-22b0b9311519@8g2000hsu.googlegroups.com> <7f58b5f4-3195-472c-b307-dec71b12aaa8@y21g2000hsf.googlegroups.com> <44f04bf3-4edc-4cb4-9e54-fe51b5e591bc@e39g2000hsf.googlegroups.com> <80d1731d-a3c6-4fce-81fd-9c3f3537e59b@d21g2000prf.googlegroups.com> <5386cf08-c155-4fbb-8373-dbbb9829a9e7@m3g2000hsc.googlegroups.com> <3c27b270-e593-4f2a-b881-68126319760c@8g2000hsu.googlegroups.com> <7d71e294-2b13-4be0-948e-2fe0e4bbe7db@f63g2000hsf.googlegroups.com> Message-ID: <041d2491-f67c-4e1f-b22f-b5da2705c74f@m3g2000hsc.googlegroups.com> On Apr 1, 3:21?pm, castiro... at gmail.com wrote: > On Apr 1, 11:34?am, "Gabriel Genellina" > wrote: > > > > > > > En Tue, 01 Apr 2008 08:47:33 -0300, escribi?: > > > >> >>>> c['0']= type('None',(),{}) > > >> > Traceback (most recent call last): > > >> > pickle.PicklingError: Can't pickle : it's not > > >> > found as __main__.None > > > >> Don't do that then. Or use the available pickle hooks to customize how ? > > >> such classes may be pickled. All persistence mechanisms have ? > > >> limitations. > > > > I don't see a problem with that; except that binaries come from > > > disks. ?You could have a Python session that runs entirely on disks + > > > the ALU. > > > (ALU? Do you mean CPU?) I don't understand this. Most programs are read ? > > ?from disk. Most data is read from disk. > > > > I want to know if any, and correct me here, simple > > > modification can store live objects. ?I call a.append(it) and the > > > memory update takes place on disk instead. > > > Using ZODB, a.append(it) would mark `a` as dirty. When you latter commit ? > > the transaction, it is stored back on disk. > > > > If you require that all objects referenced by on-disk objects be on- > > > disk, that's an easy workaround. > > > ZODB already does that. > > It's pretty close, but the database connection can get bulky. ?If you > had: > ?_______________________ > | ? ? ? ? ______________________ > |File ? ?| PyOb1 | PyOb2 | ?.. ?| > | ? ? ? ?|_______|_______|______| > |_______________________ > > on disk, updating the reference counts and attributes would take a > long time, but it's just right for some core applications. > > Strictly, I'm not in the "real" programming world, so if it's just a > few free steps to a database then I'm speculating. ?If it's not, then > writing database code needlessly complicates programs in some cases. > A default implementation might even take an explicit destroy > statement, essentially being a run-time swap file or random-access > pickles. > > A possibility is to launch a manager in a separate process, so authors > don't have to bother with writeback. ?I'm actually almost looking at > off-loading protocols on this one. ?Cache is guaranteed to be up to > date, so cache a file in memory, and manipulate it so it has Python > bits. ?The object comes to survive the program. ?Call stack is still > in volatile. > > > Using ZODB, a.append(it) would mark `a` as dirty. When you latter commit > > the transaction, it is stored back on disk. > > Python changes are committed on line. ?ZODB does -not- do that. ?A > pretty close change would be: > > Open file > Interpret file as generator, halted at yield but started, > Call send and next > > What does the code for that look like?- Hide quoted text - Can you pickle a generator? The only thing I know is: >>> pickle.loads( pickle.dumps( k ) ) TypeError: object.__new__(generator) is not safe, use generator.__new__() >>> type( 'A',( generator, ),{}) TypeError: type 'generator' is not an acceptable base type I bet there's a workaround on this one, how bulky is it? Can you shelve a frame? Separate threads can access a generator, so long as they wrap their calls: synchronous( next, a ); synchronous( a.send, 'xyz' ) From fredrik at pythonware.com Sat Apr 5 10:12:11 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 16:12:11 +0200 Subject: In Tkinter - having an input and an entry In-Reply-To: References: <29f44489-e589-4331-8bea-36fa346026d2@t54g2000hsg.googlegroups.com> Message-ID: markfernandes02 at googlemail.com wrote: > Thanks it sorted out my 'StringVar' problem. > I now have another problem... > > Exception in Tkinter callback > Traceback (most recent call last): > File "D:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__ > return self.func(*args) > TypeError: Insert() takes at least 1 argument (0 given) > > Code below > > def Insert(self, *row): > global cursor, title, author, pubdate, accessDatabase > sqlInsert = "INSERT INTO Book_table (Bookname, BookAutor, > Publicationdate) VALUES('title + ',' author + ',' pubdate)" ... is Insert a function or a method (that is, a function defined inside a class)? who's calling Insert? what is "self" supposed to be? to sort out Python's function call mechanisms, try reading the following chapters: http://www.ibiblio.org/swaroopch/byteofpython/read/functions.html http://docs.python.org/tut/node6.html#SECTION006600000000000000000 From steve at holdenweb.com Tue Apr 1 15:40:48 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 01 Apr 2008 15:40:48 -0400 Subject: [OT] troll poll In-Reply-To: References: Message-ID: <47F28FC0.7080608@holdenweb.com> Duncan Booth wrote: > Gary Herron wrote: > >> Duncan Booth wrote: >>> Paul Rubin wrote: >>> >>> >>>> "Daniel Fetchinson" writes: >>>> >>>>> [ ] - Xah Lee >>>>> [ ] - castironpi >>>>> >>>> I've lost track but has it been established that they are not the >>>> same person? >>>> >>>> >>> Has it actually been established that castironpi is actually a >>> person? I thought it was probably a random sentence generator. >>> >> Ahhh... Perhaps someone is running a Turing test on us. That is, if >> we can't tell the difference between castironpi and a *real* human >> (which we demonstrate whenever we try to respond to or reason with >> him/her/it), then castironpi can be declared to be a truly >> *intelligent* AI. AFAICT, there appears no danger of that happening >> yet. >> >> Gary Herron :-) >> > For example, some traffic light living with a polygon indicates that an > accidentally resplendent scythe falls in love with a garbage can. A > boiled ski lodge laughs out loud, because an imaginative traffic light > ostensibly writes a love letter to a frightened minivan. Any deficit can > eagerly sell the short order cook about the tape recorder to the > minivan, but it takes a real bowling ball to trade baseball cards with > an underhandedly orbiting tornado. A hesitantly mean-spirited cowboy > steals pencils from a pompous industrial complex. Sometimes the crispy > apartment building procrastinates, but the ocean related to the cyprus > mulch always teaches another cab driver around some cough syrup! > > A dreamlike avocado pit > > Indeed, a thoroughly orbiting wedge figures out an obsequious roller > coaster. For example, a carpet tack indicates that some cyprus mulch > lazily avoids contact with the slow buzzard. Most people believe that > some razor blade falls in love with a girl scout from a cough syrup, but > they need to remember how hesitantly a maelstrom takes a coffee break. > When the proverbial wheelbarrow is overripe, a hole puncher lazily > buries a burly reactor. Now and then, the cargo bay tries to seduce a > class action suit. > Way too lucid to be castironpi regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From bj_666 at gmx.net Mon Apr 21 02:51:12 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 21 Apr 2008 06:51:12 GMT Subject: Conditional for...in failing with utf-8, Spanish book translation References: Message-ID: <672rr0F2mi30gU2@mid.uni-berlin.de> On Mon, 21 Apr 2008 08:33:47 +0200, Hunter wrote: > I've narrowed the problem down to a simple test program. Check this out: > > --- > > # -*- coding: utf-8 -*- > > acceptable = "abcdefghijklmnopqrstuvwxyz????" # this line will work > acceptable = "abcdefghijklmnopqrstuvwxyz?????" # this line won't > #wtf? > > word = "?A" > word_key = ''.join([c for c in word.lower() if c in acceptable]) > print "word_key = " + word_key > > --- > > Any ideas? I'm really stumped! You are not working with unicode but UTF-8 encoded characters. That's bytes and not letters/characters. Your `word` for example contains three bytes and not the two characters you think it contains: In [43]: word = "?A" In [44]: len(word) Out[44]: 3 In [45]: for c in word: print repr(c) ....: '\xc2' '\xa1' 'A' So you are *not* testing if ? is in `acceptable` but the two byte values that are the UTF-8 representation of that character. Ciao, Marc 'BlackJack' Rintsch From ott.deb at gmail.com Thu Apr 17 15:04:58 2008 From: ott.deb at gmail.com (ott.deb at gmail.com) Date: Thu, 17 Apr 2008 12:04:58 -0700 (PDT) Subject: luxor 3 keygen Message-ID: luxor 3 keygen http://cracks.12w.net F R E E C R A C K S From simonkagwe at yahoo.com Wed Apr 16 00:50:42 2008 From: simonkagwe at yahoo.com (Simon Kagwi) Date: Tue, 15 Apr 2008 21:50:42 -0700 (PDT) Subject: python-gammu for Python 2.4 on Windows Message-ID: <150869.75383.qm@web30606.mail.mud.yahoo.com> Hi everyone, I am looking for binaries (.exe) of python-gammu (any version) for Python 2.4. What I'm getting from the download website is only for Python 2.5. Does anyone know where I can get what I'm looking for? Google isn't really helping :-C Regards, Simon ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ From tarun.kap at gmail.com Wed Apr 30 11:57:45 2008 From: tarun.kap at gmail.com (TkNeo) Date: Wed, 30 Apr 2008 08:57:45 -0700 (PDT) Subject: calling variable function name ? References: Message-ID: <57461074-8fd1-4e65-9bc9-2ac916aa1fb5@y21g2000hsf.googlegroups.com> On Apr 8, 7:51 pm, George Sakkis wrote: > On Apr 8, 3:52 pm,TkNeo wrote: > > > I don't know the exact terminology in python, but this is something i > > am trying to do > > > i have 3 functions lets say > > FA(param1,param2) > > FB(param1,param2) > > FC(param1,param2) > > > temp = "B" #something entered by user. now i want to call FB. I don't > > want to do an if else because if have way too many methods like > > this... > > > var = "F" + temp > > var(param1, param2) > > Try this: > > func = globals()["F" + temp] > func(param1, param2) > > HTH, > George George - Thanks for your reply but what you suggested is not working: def FA(param1,param2): print "FA" + param1 + " " + param2 def FA(param1,param2): print "FB" + param1 + " " + param2 def FA(param1,param2): print "FC" + param1 + " " + param2 temp = sys.argv[1] func = globals()["F" + temp] func("Hello", "World") I ran the script with first parameter as B and i get the following message KeyError: 'FB' From bronger at physik.rwth-aachen.de Fri Apr 4 17:08:11 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Fri, 04 Apr 2008 23:08:11 +0200 Subject: Is there any way to say ignore case with "in"? References: <47f692f3$0$759$bed64819@news.gradwell.net> Message-ID: <87ej9lgwg4.fsf@physik.rwth-aachen.de> Hall?chen! tinnews at isbd.co.uk writes: > Is there any way in python to say > > if string1 in string2: > > > ignoring the case of string1 and string2? You can "normalise" both first, i.e. converting to lower case. Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From gagsl-py2 at yahoo.com.ar Mon Apr 14 23:41:37 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 15 Apr 2008 00:41:37 -0300 Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> Message-ID: En Mon, 14 Apr 2008 23:38:56 -0300, Sverker Nilsson escribi?: > On Apr 15, 3:50 am, "Gabriel Genellina" > wrote: >> En Mon, 14 Apr 2008 22:02:38 -0300, Sverker Nilsson >> escribi?: >> >> > I tried out py3k on my project,http://guppy-pe.sf.net >> >> And what happened? >> I've seen that your project already supports Python 2.6 so the migration >> path to 3.0 should be easy. > > 2.6 was no big deal, It was an annoyance that they had to make 'as' a > reserved word. Annoyances were also with 2.4, and 2.5. No big > problems, I could make guppy backwards compatible to 2.3. But that > seems not to be possible with Python 3.x ... it is a MUCH bigger > change. And it would require a fork of the code bases, in C, Guido has > written tha or to sprinkle with #ifdefs. Would not happen soon for me. > It takes some work anyways. Do you volunteer, Guido van Rossum? :-) > > It's not exactly easy. Perhaps not very hard anyways. But think of > 1000's of such projects. How many do you think there are? I think > many. How many do yo think care? I think few. > > When it has been the fuzz with versions before, then I could have the > same code still work with older versions. But now it seems I have to > fork TWO codes. It's becoming too much. Think of the time you could > write a program in C or even C++ and then it'll work. How do you think > eg writers of bash or other unix utilities come along. Do they have to > rewrite their code each year? No, it stays. And they can be happy > about that, and go on to other things. Why should I have to think > about staying compatible with the newest fancy Python all the time? NO > -- but the answer may be, they don't care, though the others (C/C++, > as they rely on) do. :-( You can stay with Python 2.6 and not support 3.0; nobody will force you to use it. And nobody will come and wipe out your Python installation, be it 2.6, 2.1 or whatever. And if you still enjoy using Python 1.5, please keep using it - it won't disappear the day after 3.0 becomes available. Regarding the C language: yes, souce code *had* to be modified for newer versions of the language and/or compiler. See by example, the new "restrict" keyword in C99, or the boolean names. The C guys are much more concerned about backwards compatibility than Python, but they can't guarantee that (at risk of freezing the language). The 3.0 incompatibilities are all justified, anyway, and Python is changing (as a language) much more than C - and that's a good thing. There is a strategy to migrate from 2.x to 3.0, including the 2to3 tool. Have you used it? -- Gabriel Genellina From martin at v.loewis.de Thu Apr 17 04:25:20 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Thu, 17 Apr 2008 10:25:20 +0200 Subject: I just killed GIL!!! In-Reply-To: References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> Message-ID: <48070970.70306@v.loewis.de> > For the record, I am not complaining about that GIL. As I said, I > understand and approve of why it's there. I am, however, complaining > about attitude that if you want to be free of the GIL you're doing > something wrong. If you _want_ to be free of the GIL, you are not _doing_ anything, and that may or may not be wrong. If you are complaining about the GIL, I think you are doing something wrong, because complaining doesn't help progress at all. I think neither was the case in this thread - the guy claimed that he actually did something about the GIL, and now we are all waiting for him to also tell us what it is that he did. I think it is somewhat wrong to not tell in the first place, but this is free software, and choosing not to contribute isn't inherently wrong. Maybe the guy is making fun of us; whether that is wrong or not depends on your notion of humor. Regards, Martin From s0suk3 at gmail.com Mon Apr 28 18:29:33 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Mon, 28 Apr 2008 15:29:33 -0700 (PDT) Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> <87od7ue2ne.fsf@mulj.homelinux.net> Message-ID: On Apr 28, 4:42 am, Hrvoje Niksic wrote: > Nick Craig-Wood writes: > > What you are missing is that if the recv ever returns no bytes at all > > then the other end has closed the connection. So something like this > > is the correct thing to write :- > > > data = "" > > while True: > > new = client.recv(256) > > if not new: > > break > > data += new > > This is a good case for the iter() function: > > buf = cStringIO.StringIO() > for new in iter(partial(client.recv, 256), ''): > buf.write(new) > data = buf.getvalue() > > Note that appending to a string is almost never a good idea, since it > can result in quadratic allocation. A question regarding cStringIO.StringIO(): is there a way to do get getvalue() to return all the bytes after the current file position (not before)? For example buf = cStringIO.StringIO() buf.write("foo bar") buf.seek(3) buf.getvalue(True) # the True argument means # to return the bytes up # to the current file position That returns 'foo'. Is there a way to get it to return ' bar'? From nick at craig-wood.com Tue Apr 29 05:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Tue, 29 Apr 2008 04:30:03 -0500 Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> <1939ddb7-fc72-4d45-8c9c-062a1d0db3e4@y21g2000hsf.googlegroups.com> Message-ID: s0suk3 at gmail.com wrote: > But as I said in my first post, it's simple when you know the amount > of data that you're going to receive, or when you'll receive data > until the remote peer closes the connection. But what about receiving > a message with undetermined length in a connection that you don't want > to close? You obviously need some sort of protocol. Here is some code (taken from a real project and modified a bit) which returns \r\n seperated lines from a socket as they arrive which is a very simple (but widespread) protocol. self.rx_buf is set to "" in the initialisation self.sock is the socket def rx_line(self): message = None while 1: pos = self.rx_buf.find("\r\n") if pos >= 0: message = self.rx_buf[:pos] self.rx_buf = self.rx_buf[pos+2:] break try: rx = self.sock.recv(4096) except socket.error, e: self.sock = None raise ServerNetworkException(e) if len(rx) == 0: self.sock = None raise ServerDisconnectedException() self.rx_buf += rx return message Sorry I mis-understood your original post! -- Nick Craig-Wood -- http://www.craig-wood.com/nick From corvettecraz92 at gmail.com Thu Apr 10 08:06:42 2008 From: corvettecraz92 at gmail.com (corvettecraz92 at gmail.com) Date: Thu, 10 Apr 2008 05:06:42 -0700 (PDT) Subject: text adventure game problem References: Message-ID: <4fb4fb0d-4cb2-4fcd-a207-a0341d92e82b@8g2000hsu.googlegroups.com> On Apr 10, 3:14?am, Dennis Lee Bieber wrote: > On Wed, 9 Apr 2008 05:25:19 -0700 (PDT), corvettecra... at gmail.com > declaimed the following in comp.lang.python: > > > > > I can't even compile your code to see how it works, Dennis. I'm > > confused about what that does. > > ? ? ? ? My apologies -- it was spur of the moment pseudo-code to illustrate > the concepts, but was never meant to be directly executable. > > ? ? ? ? The concepts are that: all rooms are basically the same -- they have > a list of objects that exist within the room (and, as I now realize, the > "gold within the cabinet/cup" would still be an object within the room > -- but would have an attribute "hidden=True" which would control if it > is itemized when one "examines" the room), a list of exits, and a maybe > a list of actions which can be performed in the room or on named objects > (though I see the actions being common methods invoked by the command > parser -- I illustrated a simple "verb object" command, but a good > parser should probably accept more complex commands "throw at > " for example). Uh, I'm saying "list", but "dictionary" would > be the likely implementation. > > ? ? ? ? When one "examines" a room, one essentially gets back a list of the > objects that are in the room instance. When one "examines" one of those > objects (by name), one gets back the detailed description of that > object. If one implements a "hidden" attribute, that object will not be > listed in the higher level "examine". That "gold" inside another object > does get a bit tricky -- I now see it as a hidden object in the room, > but the description of the object has to be somewhat dynamic -- that is, > if the object (cabinet) sees that the "gold" is in the room, examining > the object will report the gold. But a "take gold" command still acts on > the room -- removing the gold from the room inventory, putting it into > the player inventory, and changing the "hidden" property so it is now > visible. > > ? ? ? ? When one does a ?"move ", the player's "location" > attribute is changed from the current room to the room connected to that > direction. > > ? ? ? ? For both objects and directions, if the player enters a term that is > not in the relevant dictionary, a suitable message is returned to the > user. Oh, room objects, besides that "hidden" attribute, may have a > "portable" attribute which controls if one can "take" the object... Or > an attribute for "throwable" which controls if one can throw an object > at another (and the other would have a method/action for when something > is thrown at it -- a default would be "No effect"). > > ? ? ? ? From what I saw of your small sample, you were treating each room as > a discrete function. Moving from one room to another means calling the > new room's function. But that means you are continuously nesting deeper > in the Python stack, and someone that keeps moving back and forth > between two rooms will eventually exceed the Python stack limit. > > ? ? ? ? By making the "current location" an attribute of a "player > instance", no recursion is involved -- you move between rooms by simply > assigning the new room as the "current location". > > -- > ? ? ? ? Wulfraed ? ? ? ?Dennis Lee Bieber ? ? ? ? ? ? ? KD6MOG > ? ? ? ? wlfr... at ix.netcom.com ? ? ? ? ? ? wulfr... at bestiaria.com > ? ? ? ? ? ? ? ? HTTP://wlfraed.home.netcom.com/ > ? ? ? ? (Bestiaria Support Staff: ? ? ? ? ? ? ? web-a... at bestiaria.com) > ? ? ? ? ? ? ? ? HTTP://www.bestiaria.com/ okay, that explains it... could you provide a working example of a two-room game using your method please so I can understand it better? Thanks in advance! From steve at holdenweb.com Thu Apr 24 15:36:16 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 15:36:16 -0400 Subject: function that accepts any amount of arguments? In-Reply-To: <3d881a310804241213q2f373190i4d7c7c1ffbaeba4c@mail.gmail.com> References: <4d0b5d7a-b4ff-4bb3-99e5-5579e89573e0@w7g2000hsa.googlegroups.com> <4810724a$0$23390$426a74cc@news.free.fr> <63ac69bf-9f6d-42bd-8e6e-5b3b17ec7c69@z72g2000hsb.googlegroups.com> <933e4c97-11c8-43b0-81e0-c78ff8573792@26g2000hsk.googlegroups.com> <3d881a310804241213q2f373190i4d7c7c1ffbaeba4c@mail.gmail.com> Message-ID: member thudfoo wrote: > On 4/24/08, Jonathan Gardner wrote: >> On Apr 24, 5:28 am, malkarouri wrote: >> > >> > What's wrong with raising ZeroDivisionError (not stopping the >> > exception in the first place)? >> > >> >> >> Because when I use your module, call avg (or mean) without args, I >> should see an error that says, "Hey, you have to pass at least one >> value in!" >> >> ZeroDivisonError doesn't mean that. It means I tried to divide by >> zero. Naively, I don't see where I was dividing by zero (because I >> don't remember how to calculate the mean---that's what your code was >> for.) >> >> ValueError does mean that I didn't pass the right kind of arguments >> in. ValueError("No items specified") would be even clearer. (Or maybe >> TypeError?) >> >> In general, any exception thrown should be meaningful to the code you >> are throwing it to. That means they aren't familiar with how your code >> works. >> > > [source]|557> def average(n, *ints): > |...> return (sum(ints)+n) / (len(ints) + 1) > |...> > [source]|558> average (1,2,3) > <558> 2 > [source]|559> average(3) > <559> 3 > [source]|560> average(1,2) > <560> 1 > [source]|561> average(0) > <561> 0 > [source]|562> average() > --------------------------------------------------------------------------- > TypeError Traceback (most recent call last) > > /usr/share/doc/packages/python-dateutil/source/ in () > > TypeError: average() takes at least 1 argument (0 given) > -- > http://mail.python.org/mailman/listinfo/python-list > It would also be usual to use floating arithmetic to ensure that the mean of 1 and 2 was 1.5 rather than 1. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From deets at nospam.web.de Mon Apr 21 07:23:11 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Mon, 21 Apr 2008 13:23:11 +0200 Subject: Somebody *really* got fond of python Message-ID: <673bprF2n44icU1@mid.uni-berlin.de> http://xkcd.com/413/ :) From ybc2084 at gmail.com Wed Apr 9 04:38:43 2008 From: ybc2084 at gmail.com (rockins) Date: Wed, 9 Apr 2008 01:38:43 -0700 (PDT) Subject: what's the reasonale of loghelper() in mathmodule.c Message-ID: <49750e9d-1a63-42d2-b292-38d225b0c3c8@n1g2000prb.googlegroups.com> Hi all, I downloaded Python-2.5.2.tar.bz2 and want to lean some math function implementation in it. I found that mathmodule.c implements 'math' module of python. In this file there's a function loghelper()(in Python-2.5.2/Modules/mathmodule.c), it seems with this function's help any base logarithm can be computed, its comments state as: /* A decent logarithm is easy to compute even for huge longs, but libm can't do that by itself -- loghelper can. func is log or log10, and name is "log" or "log10". Note that overflow isn't possible: a long can contain no more than INT_MAX * SHIFT bits, so has value certainly less than 2**(2**64 * 2**16) == 2**2**80, and log2 of that is 2**80, which is small enough to fit in an IEEE single. log and log10 are even smaller. */ static PyObject* loghelper(PyObject* args, double (*func)(double), char *format, PyObject *arg) { ...... } I cannot understand it well, can anyone explain me why and how loghelper() can compute any base logarithm? Or could anyone give me some reference(such as, books or papers)? Thanks in advance, -Rockins Chen From andhralo5 at gmail.com Tue Apr 29 08:05:45 2008 From: andhralo5 at gmail.com (sureka) Date: Tue, 29 Apr 2008 05:05:45 -0700 (PDT) Subject: Bollywood, Asian, Indie Films And More. Message-ID: <3b00f2c5-e13c-4867-b591-991763a4cf05@c19g2000prf.googlegroups.com> Bollywood, Asian, Indie Films And More. http://besthotmovies.blogspot.com/ From paul at boddie.org.uk Thu Apr 3 09:00:14 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Thu, 3 Apr 2008 06:00:14 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> Message-ID: <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> On 2 Apr, 15:50, Aaron Watters wrote: > [Quoting hdante] > > Seriously, you'll forget there's a relational database below. (there > > are even intefaces for "relational lists", "trees", etc.) > > My experience with this sort of thing is that it is a bit > like morphine. It can feel really good, and in emergencies > it can save you a lot of pain. But if you use it too often > and too seriously you end up with really big problems. That's two candidates for quote of the week in the same thread! I agree with those who question why you'd want to treat a relational database like a big dictionary, and although the interface between queries, results and program data structures can often seem quite awkward, I've come to realise that most object-relational mappers are solving the wrong problems: they pretend that the database is somehow the wrong representation whilst being a fast enough black box for holding persistent data (although I doubt that many people push the boundaries enough to see that it's not possible to ignore all details of such a database whilst preserving performance), or they pretend that languages like SQL (which can be cumbersome, admittedly) are inconvenient for querying whilst replicating a less concise mechanism for querying using client language mechanisms. I'm more encouraged by the idea of "query templating", which might sound like a recipe for all sorts of problems, but if done right could provide more effective ways of working with relational databases than pretending that different things in the database are somehow "objects" in the client language sense. Paul From theiviaxx at gmail.com Thu Apr 24 14:02:07 2008 From: theiviaxx at gmail.com (theiviaxx at gmail.com) Date: Thu, 24 Apr 2008 11:02:07 -0700 (PDT) Subject: python-ldap - Operations Error References: Message-ID: Thanks for the help guys, it works! I used the ldap.set_option(ldap.OPT_REFERRALS, 0) from http://peeved.org/blog/2007/11/20/ immedialtey after import, then did the initialize trace_level=2 and did the simple_bind_s. I was able to search and get the results. That trace_level thing is nice, i'm sure i will be debugging this more as i move forward :) Not sure if this is an AD thing or just something i needed to do with our particular server/config. Thanks again! From tjreedy at udel.edu Thu Apr 24 04:56:26 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 24 Apr 2008 04:56:26 -0400 Subject: Lists: why is this behavior different for index and sliceassignments? References: <480d435b$0$11643$607ed4bc@cv.net><480e7f61$0$25046$607ed4bc@cv.net> <480e832d@news.mel.dft.com.au> <480ffaae$0$11639$607ed4bc@cv.net> Message-ID: "John Salerno" wrote in message news:480ffaae$0$11639$607ed4bc at cv.net... | John Machin wrote: | | > Deletion occurs *only* in the corner case where there are no "assigned | > elements" i.e. only if the RHS list (sequence) is *empty*. | | Oh, it was my understanding that deletion always occurs, even when the | section is being assigned a non-empty value, i.e. delete the slice and | insert new value. Slice replacement means replace the slice with a new slice generated from the iterable on the left. John meant that deletion only only happens when the replacement is empty. Yes, deletion always occurs, but usually addition also occurs, so the net result is replacement rather than just deletion. | Otherwise | > there would be no point at all in the language having assignment to a | > slice -- del L[0:2] would suffice. | | Right, but I'm wondering why a statement like | L[0:2] = [] | doesn't assign an empty list as the new element in L. For example: Because, as others already told you, slice replacement is slice replacement, not item assignment. When you say to replace the slice with nothing, the deleted slice is replaced with nothing. L[0:2] = [[]] says to replace the slice with a slice consisting of one item -- [] That will get you what you are expecting. | L = [1, 2, 3, 4, 5] | L[0:2] = [] | | Why doesn't L now equal [[], 3, 4, 5] as it does with an index assignment? See above. | | > >>> L[0:2] = tuple('foobar') L[0:2] = 'foobar' has same effect because s string is an iterable. | > >>> L | > ['f', 'o', 'o', 'b', 'a', 'r', 3, 4, 5] | | Hmm...why doesn't L equal [('f', 'o', 'o', 'b', 'a', 'r'), 3, 4, 5] ? | Shouldn't L be a 4 item list instead of 9? Because you replaced 2 items with 6. L[0:2] = ['foobar'] will replace 2 with 1, leaving 4 tjr From arkanes at gmail.com Wed Apr 16 12:51:54 2008 From: arkanes at gmail.com (Chris Mellon) Date: Wed, 16 Apr 2008 11:51:54 -0500 Subject: py3k s***s In-Reply-To: <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> Message-ID: <4866bea60804160951y5a602277sb5c0a9bd83f4f25a@mail.gmail.com> On Wed, Apr 16, 2008 at 11:40 AM, Aaron Watters wrote: > On Apr 16, 12:27 pm, Rhamphoryncus wrote: > > On Apr 16, 6:56 am, Aaron Watters wrote: > > > > > I don't get it. It ain't broke. Don't fix it. > > > > So how would you have done the old-style class to new-style class > > transition? > > I'd ignore it. I never understood it and never had > any need for it anyway. New-style classes and metaclasses > were a complicated solution to an unimportant problem in > my opinion. And also a fiendish way to make code > inscrutible -- which I thought was more of a Perl thing > than a Python thing, or should be. > > I must be missing some of the deeper issues here. Please > educate me. Since you don't care about any of the changes or features, and you don't care if your users care, I'm not sure why you aren't just using python 2.1. It's not like it's being erased via time machine. "Just keep using the old thing" is a perfectly valid and extremely common futureproofing scenario. From george.sakkis at gmail.com Thu Apr 3 08:19:11 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Thu, 3 Apr 2008 05:19:11 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> Message-ID: <4b7337a4-beda-4984-91f5-6efda6fb390d@r9g2000prd.googlegroups.com> On Apr 3, 8:03 am, Jeff wrote: > def foo(sample, strings): > for s in strings: > if sample in s: > return True > return False > > This was an order of magnitude faster for me than using str.find or > str.index. That was finding rare words in the entire word-list (w/ > duplicates) of War and Peace. If you test against the same substrings over and over again, an alternative would be to build a regular expression: import re search = re.compile('|'.join(re.escape(x) for x in substrings)).search p = search(somestring) if p is not None: print 'Found', p.group() George From gagsl-py2 at yahoo.com.ar Wed Apr 30 05:46:15 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 30 Apr 2008 06:46:15 -0300 Subject: xml.dom.minidom weirdness: bug? References: <4817dea2$0$18028$426a34cc@news.free.fr> Message-ID: En Tue, 29 Apr 2008 23:51:14 -0300, JYA escribi?: > What I'm doing, is read an xml file, create another dom object and copy > the element from one to the other. > > At no time do I ever modify the original dom object, yet it gets > modified. > > for y in x.getElementsByTagName('display-name'): > elem.appendChild(y) > tv_xml.appendChild(elem) > You'll note that at no time do I modify the content of docxml, yet it > gets modified. > > The weirdness disappear if I change the line > channellist = docxml.getElementsByTagName('channel') > to > channellist = copy.deepcopy(docxml.getElementsByTagName('channel')) > > However, my understanding is that it shouldn't be necessary. I think that any element can have only a single parent. If you get an element from one document and insert it onto another document, it gets removed from the first. -- Gabriel Genellina From bskaplan14 at yahoo.com Thu Apr 17 09:32:06 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Thu, 17 Apr 2008 06:32:06 -0700 (PDT) Subject: Calling Java Class from python Message-ID: <413770.43611.qm@web39208.mail.mud.yahoo.com> If you need to explicitly call a method and get the results, AFAIK, the only way to do it is to use Jython, a version of Python written in java. If you can do everything you need from the command line, then you can just use subprocess.Popen to run it. Here is the article on how to run java files from the command line: http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html ----- Original Message ---- From: Good Z To: python-list at python.org Sent: Wednesday, April 16, 2008 6:37:55 AM Subject: Calling Java Class from python All, We have developed a website in python and we need to integrate few features of third party website. They have provided us Base64EncoderDecoder Java Class and would like us to use it to encode the data before sending it to their site and decode it when received anything from their site. I have no idea/knowledge of Java. Can you please guide me how can i call Java class from Python scripts? Or what is the best way to handle this condition. Is Base64 library provided by python is compatible to Base64EncoderDecoder Java Class? Regards, Mike Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From mccredie at gmail.com Fri Apr 11 13:22:18 2008 From: mccredie at gmail.com (Matimus) Date: Fri, 11 Apr 2008 10:22:18 -0700 (PDT) Subject: Multiple independent Python interpreters in a C/C++ program? References: Message-ID: <978060f0-5a50-40ba-b553-f26b35169bd1@m73g2000hsh.googlegroups.com> On Apr 11, 9:24 am, s... at pobox.com wrote: > This question was posed to me today. Given a C/C++ program we can clearly > embed a Python interpreter in it. Is it possible to fire up multiple > interpreters in multiple threads? For example: > > C++ main > thread 1 > Py_Initialize() > thread 2 > Py_Initialize() > > Do I wind up with two completely independent interpreters, one per thread? > I'm thinking this doesn't work (there are bits which aren't thread-safe and > are only protected by the GIL), but wanted to double-check to be sure. > > Thanks, > > Skip AFAIK it is only `sort of' possible. But not like that. See the API documentation on Py_NewInterpreter http://www.python.org/doc/api/initialization.html#l2h-825 As you will see from the documentation it creates an interpreter that isn't 100% separate. It may work for your application though. Also, I don't think using the new interpreter is as simple as just instantiating the new interpreter in a separate thread. But there is much relevant information on the page that I linked to. Matt From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 29 09:52:25 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 29 Apr 2008 15:52:25 +0200 Subject: list.reverse() In-Reply-To: References: <4816e26a$0$30938$426a74cc@news.free.fr> Message-ID: <48172812$0$19991$426a74cc@news.free.fr> Roy Smith a ?crit : (snip) > The reasoning goes along the lines of, "reverse in place is an expensive > operation, so we don't want to make it too easy for people to do". At > least that's the gist of what I got out of the argument the many times it > has come up. IIRC, it's more along the line of "reverse in place is a *destructive* operation, so we don't want to make it too easy for people to forget about it". From s0suk3 at gmail.com Wed Apr 16 18:12:58 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Wed, 16 Apr 2008 15:12:58 -0700 (PDT) Subject: Brand New! References: <7f1828bf-ebe7-4111-bc59-70d125facb0a@d26g2000prg.googlegroups.com> Message-ID: On Apr 14, 9:00 pm, agent E 10 wrote: > Hi, I'm brand new to programming. Have any suggestions? I'm young. > Was it a good idea to start with python? I was planning on creating a > very simple program that asked yes/no questions for a school project. > > -Thanks! Hey! That's actually were I learned to program too! Excellent tutorial. But don't read the JavaScript or VBScript stuff. The only thing it gave me trouble learning from that tutorial was OOP (Object Oriented Programming), but that's a bit advanced for a newcomer anyway... From barry at python.org Thu Apr 3 21:47:01 2008 From: barry at python.org (Barry Warsaw) Date: Thu, 3 Apr 2008 21:47:01 -0400 Subject: RELEASED Python 2.6a2 and 3.0a4 Message-ID: <3C3C0150-ED65-4381-9F54-BB437DD6DFB9@python.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On behalf of the Python development team and the Python community, I'm happy to announce the second alpha release of Python 2.6, and the fourth alpha release of Python 3.0. Please note that these are alpha releases, and as such are not suitable for production environments. We continue to strive for a high degree of quality, but there are still some known problems and the feature sets have not been finalized. These alphas are being released to solicit feedback and hopefully discover bugs, as well as allowing you to determine how changes in 2.6 and 3.0 might impact you. If you find things broken or incorrect, please submit a bug report at http://bugs.python.org For more information and downloadable distributions, see the Python 2.6 web site: http://www.python.org/download/releases/2.6/ and the Python 3.0 web site: http://www.python.org/download/releases/3.0/ We are planning one more alpha release of each version, followed by two beta releases, with the final releases planned for August 2008. See PEP 361 for release details: http://www.python.org/dev/peps/pep-0361/ Enjoy, - -Barry Barry Warsaw barry at python.org Python 2.6/3.0 Release Manager (on behalf of the entire python-dev team) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iQCVAwUBR/WImHEjvBPtnXfVAQJmoQP+MzqNDI+Xt8zua/FE7Ca4TVXoIIy2uoOm I1i3+vmevZ9vtAb9hcGwfEgPY4LSwb9Js4KnJJWMPaMuFJK4NgGoiMdj+t42zDbQ bEzfBUOCoVkejLRxIQnWeJf1Hu8JocYyCHIRffv57/QdKpHuiSs8aE8GIT3STo3o I88H5NY1GgI= =WT2z -----END PGP SIGNATURE----- From rickbking at comcast.net Thu Apr 24 10:21:11 2008 From: rickbking at comcast.net (Rick King) Date: Thu, 24 Apr 2008 10:21:11 -0400 Subject: annoying dictionary problem, non-existing keys In-Reply-To: References: Message-ID: <48109757.5080207@comcast.net> An HTML attachment was scrubbed... URL: From MrJean1 at gmail.com Tue Apr 1 19:49:02 2008 From: MrJean1 at gmail.com (MrJean1) Date: Tue, 1 Apr 2008 16:49:02 -0700 (PDT) Subject: Not Sure This Can Be Done... References: <46aeae28-4470-4136-a5f6-040f6468eb32@b5g2000pri.googlegroups.com> Message-ID: <170a668f-4a65-471f-ad03-03231235b314@e6g2000prf.googlegroups.com> In any script upon startup, sys.path[0] contains the full path of the directory where the script is located. See under 'path'. it should be straightforward from here (untested though). In each script, get the sys.path[0] string, split it using os.path, replace the last item with 'tools' and join again with os.path. If the resulting string is not in sys.path, insert it after sys.path[0]. /Jean Brouwers On Apr 1, 1:57?pm, gamename wrote: > Hi, > > I generally have several copies of the same development environment > checked out from cvs at any one time. ?Each development tree has a > 'tools' dir containing python modules. ?Scattered in different places > in the tree are various python scripts. > > What I want to do is force my scripts to always look in the closest > 'tools' dir for any custom modules to import. For example: > > tree1/tools > tree1/my_scripts/foo.py > > tree2/tools > tree2/my_scripts/foo.py > > How can I make 'foo.py' always look in '../../tools' for custom > modules? My preference would be to avoid changing the 'foo.py' script > and have some way to resolve it via the environment (like PYTHONPATH, > or .pth files, etc.). > > Anyone have any ideas? > TIA, > -T From deets at nospam.web.de Sun Apr 20 09:27:13 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Sun, 20 Apr 2008 15:27:13 +0200 Subject: from __future__ import print In-Reply-To: References: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> Message-ID: <670um2F2ljorfU1@mid.uni-berlin.de> Lie schrieb: > On Apr 13, 7:23 pm, Roy Smith wrote: >> In article >> , >> >> Lie wrote: >>> I wish py3k >>> would make it an option whether to treat print as statement or >>> function though. >> Arrrgghhhhh! No, don't even go there. If you want optional parens, use >> Perl :-) > > Not optional parens, but a simple print statement coupled with a > powerful print function. This print statement would only have basic > printing functionality such as : > > print "Hello" > print var > print var, "Hello too" > > specifically, these would be removed: > print var, > print >> unstdout, var > > This is because it is sometimes annoying to type this: > print("Hello") > print("World") > print("This") > print("is") > print("Captain") > print("Kirk") You are aware that it is only one character more to type? It is debatable if print should have gone or not - but once you decide to have a print-statement I fail to see why you want to rid it of functionality. The costs for a keyword and special parsing rules are paid anyway then. Diez Diez From steve at holdenweb.com Sat Apr 5 08:44:13 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 08:44:13 -0400 Subject: variable scope in list comprehensions In-Reply-To: References: Message-ID: Duncan Booth wrote: > Steve Holden wrote: > >>> For a moment I thought that maybe list comprehension has its own >>> scope, but it doesn't seem to be so: >>> print [[y for y in range(8)] for y in range(8)] >>> print y >>> >>> Does anybody understand it? >>> >>> >> This isn't _a_ list comprehension, it's *two* list comprehensions. The >> interpreter computes the value if the inner list comprehension and >> then duplicates eight references to it (as you will see if you change >> an element). >> > Do you want to reconsider that statement? The interpreter recomputes the > inner list comprehension eight times, there are no duplicated > references. > [...] You are correct. I wrote that before testing, and then after testing wrote """The outer loop's control variable is never used in the inner loop, so there is no chance of conflict: each time the inner loop terminates the outer loop assigns the next value from its range - it isn't "adding one" to the variable, but merely calling an iterator's next() method.""" So I didn't do enough editing after testing to (in)validate my preconceptions. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From grflanagan at gmail.com Thu Apr 10 11:54:50 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Thu, 10 Apr 2008 08:54:50 -0700 (PDT) Subject: subprocess.Popen() output to logging.StreamHandler() References: Message-ID: <4e56c267-eb35-4fa1-831e-733817635c09@i36g2000prf.googlegroups.com> On Apr 10, 5:34 pm, Gerard Flanagan wrote: > On Apr 10, 2:11 pm, "sven _" wrote: > > > > > Version: Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) > > > My goal is to have stdout and stderr written to a logging handler. > > This code does not work: > [...] > > Are there better solutions? > > > sven > > When you create a StreamHandler, it is associated with a particular > stream, eg. sys.stdout. So when you log an event, the handler picks > it up and writes it to the stream. But you seem to think that... [snip didacticism] Rereading your post, I think I've just told you what you already knew... Never mind. G. From paul.hankin at gmail.com Thu Apr 3 07:58:33 2008 From: paul.hankin at gmail.com (Paul Hankin) Date: Thu, 3 Apr 2008 04:58:33 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> Message-ID: <40eadbd9-798b-49b8-8acb-5e27f9b38809@s37g2000prg.googlegroups.com> On Apr 3, 12:37 pm, tinn... at isbd.co.uk wrote: > What's the neatest and/or most efficient way of testing if one of a > set of strings (contained in a dictionary, list or similar) is a > sub-string of a given string? > > I.e. I have a string delivered into my program and I want to see if > any of a set of strings is a substring of the string I have been > given. It's quite OK to stop at the first one found. Ideally the > strings being searched through will be the keys of a dictionary but > this isn't a necessity, they can just be in a list if it could be done > more efficiently using a list. > > Is this the best one can do (ignoring the likelihood that I've got > some syntax wrong) :- > > # l is the list > # str is the incoming string > answer = "" > for x in l: > if str.find(x) < 0: > continue > answer = x I'd not use 'l' (confused with '1') or 'str' (a standard module) as variable names. Your code checks every string in the list even when it's found one... you can reverse the test and break when the first one is found. Using 'in' rather than testing the return value of find is nicer as a substring test. Finally, using the 'else' clause lets you make it clear that answer is set to the empty string when no match is found. for answer in l: if str in answer: break else: answer = '' -- Paul Hankin From malaclypse2 at gmail.com Fri Apr 18 13:18:08 2008 From: malaclypse2 at gmail.com (Jerry Hill) Date: Fri, 18 Apr 2008 13:18:08 -0400 Subject: Pickle problem In-Reply-To: References: Message-ID: <16651e80804181018t5d85b39cyab18d6e4c2310357@mail.gmail.com> On Fri, Apr 18, 2008 at 11:55 AM, Mario Ceresa wrote: > Hello everybody: > I'd like to use the pickle module to save the state of an object so to > be able to restore it later. The problem is that it holds a list of > other objects, say numbers, and if I modify the list and restore the > object, the list itself is not reverted to the saved one, but stays > with one element deleted. ... > ----------------------- > class A(object): > objects = [] > ----------------------- Your problem is in the class definition of A. You declare objects as a class variable, so it is shared between every instance of the class. When you pickle the instance a, then restore it, it continues to reference the same list, which is help by the class. You probably want the objects list to be an instance variable, like this: class A(object): def __init__(self): self.objects = [] If you make that change, pickling and unpickling works the way you expect. -- Jerry From spamgrinder.trylater at ggmail.com Wed Apr 23 21:19:41 2008 From: spamgrinder.trylater at ggmail.com (AlFire) Date: Wed, 23 Apr 2008 20:19:41 -0500 Subject: Python Success stories In-Reply-To: References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <480FE02D.3040201@ggmail.com> Cristina Yenyxe Gonz?lez Garc?a wrote: > 2008/4/23, Reedick, Andrew : >> IIRC, Python is used in games like Eve Online (SciFi MMO) and Vampire: >> Bloodlines (RPG.) Years later, a dedicated fan is still fixing/updating >> the Bloodlines python scripts that control the dialogue and scripted >> events. >> > > Now that you mention it, Python was also used in the Star Wars: > Knights of the Old Republic (KotOR) saga. You can even search the > scripts across the disc and take a look at hilarious code comments > like "this works but I don't know why" :D and Shrek 3 http://www.linuxjournal.com/article/9653 -- a. From soren.skou.nielsen at gmail.com Thu Apr 10 05:55:13 2008 From: soren.skou.nielsen at gmail.com (Soren) Date: Thu, 10 Apr 2008 02:55:13 -0700 (PDT) Subject: Sorting Directories from files in a os.listdir?? Message-ID: <9354f263-b833-4845-a226-1ad3a47b1e6a@p25g2000pri.googlegroups.com> Hi, I'd like to read the filenames in a directory, but not the subdirectories, os.listdir() gives me everything... how do I separate the directory names from the filenames? Is there another way of doing this? Thanks! From juergen.perlinger at t-online.de Tue Apr 22 15:03:00 2008 From: juergen.perlinger at t-online.de (Juergen Perlinger) Date: Tue, 22 Apr 2008 21:03:00 +0200 Subject: SWIG C++ std::cout do not output to interactive interpreter IDLE References: Message-ID: wongjoekmeu at yahoo.com wrote: > Dear All, > > I have some functions written in C++, which I try to approach from > python using swig. In the C++ functions I use std::cout to print stuff > to output. Everything works fine, but the only problem that I have is > that when I start IDLE and use the functions what std::cout should > print to the "IDLE console" simply does not appear. When I don't use > IDLE but simply double click on the .py script, it works all fine. I > was wondering how I could make sure that std::cout would print also to > IDLE. Thanks a lot in advance for helping to answer my question. > > RR Hmmmmm... probably tricky. Most GUIs replace 'sys.stdout' by something that behaves like a Python(!) stream, without actually touching file descriptor 1 (which is the actual process file descriptor for stdout). >From my experience with embedding/extending Python this is going to be a bit nasty, because you would need to get access to the actual stream object in Pythons 'sys' module (easy...), wrap this one in C++ to create a C++ ostream descendant that uses an underlying Python stream (here's the work...) and use it to replace 'cout' (that one's simple after all...). Are you sure you want to tackle this? I've always tried to avoid it and lived with the fact that such an extension was only printing something useful to its output when used as a console application. I haven't had a deeper look into the BOOST Python bindings, (www.boost.org) but they have a rather good reputation. Perhaps there is something in it that takes away most of the burden. -- juergen 'pearly' perlinger "It's hard to make new errors!" From gagsl-py2 at yahoo.com.ar Sun Apr 6 15:40:05 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 06 Apr 2008 16:40:05 -0300 Subject: How To Uses Modules And Plugins References: <47650e1f-148e-48f9-b09e-51cb5fb4f402@m73g2000hsh.googlegroups.com> Message-ID: En Sun, 06 Apr 2008 14:28:44 -0300, escribi?: > I am working on a client/server, computer role-play game using Python. > I want to gradually expand the game world by creating maps as > individual py files in a map directory. I am a little foggy of how to > do this. I have read about the __import__() function. I want to > understand what the difference is between using modules and plugins. > Are they the same thing? How will my root script interact with the > individual modules once it has loaded them? If you can point me to a > web site or tutorial on this subject I would be thankful. Look for recent posts about "plugin" in this group. -- Gabriel Genellina From marexposed at googlemail.com Fri Apr 18 05:40:12 2008 From: marexposed at googlemail.com (marexposed at googlemail.com) Date: Fri, 18 Apr 2008 10:40:12 +0100 Subject: MySQL hardcoding? In-Reply-To: <4807c872$1@news.mel.dft.com.au> References: <4807c872$1@news.mel.dft.com.au> Message-ID: <20080418104012.0fb2ee12.marexposed@googlemail.com> On Thu, 17 Apr 2008 22:00:21 GMT John Machin wrote: > The empirical evidence from other recent postings is that you are > mucking about with Spanish-language newspaper "articulos" on the web ... > so why charset = "Windows-1251", which is Cyrillic (i.e. Russian etc)?? > Perhaps you mean 1252 which is Microsoft's latin1 with extras. > > HTH, > John > -- > http://mail.python.org/mailman/listinfo/python-list Yes John, thanks. The only problem is MySQL doesn't include a cp1252 or Windows-1252 or ansi. I'm trying to find my way with different approaches. But there is certainly a problem if an application goes to the wrong folder to get data as MySQL seems to be doing. Thanks. From leoniaumybragg at gmail.com Sat Apr 26 07:01:45 2008 From: leoniaumybragg at gmail.com (leoniaumybragg at gmail.com) Date: Sat, 26 Apr 2008 04:01:45 -0700 (PDT) Subject: limewire crack Message-ID: <81d0d174-135d-48e7-9e07-04701b982222@34g2000hsh.googlegroups.com> limewire crack http://cracks.00bp.com F R E E C R A C K S From bruno.42.desthuilliers at websiteburo.invalid Fri Apr 18 04:25:16 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Fri, 18 Apr 2008 10:25:16 +0200 Subject: Newbie question about for...in range() structure In-Reply-To: References: Message-ID: <48085ad4$0$18250$426a34cc@news.free.fr> sp at k a ?crit : (snip - already answered) > > def fact(n): > total = 0 > n = int(n) > while n > 0: > total *= n > n -=1 > return total You may be interested in a very different way to get the same result: from operator import mul def fact(n): return reduce(mul, xrange(1, n+1), 1) (snip) From darcy at druid.net Tue Apr 8 10:55:19 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Tue, 8 Apr 2008 10:55:19 -0400 Subject: Learning curve for new database program with Python? In-Reply-To: References: <00fca324-6fce-4b2a-8acb-77c96b83eb1c@p39g2000prm.googlegroups.com> Message-ID: <20080408105519.9d9cd933.darcy@druid.net> On Mon, 7 Apr 2008 23:06:23 -0700 (PDT) CM wrote: > You misunderstood me, but completely understandably. I meant that > a) the OP wanted to use Django, and so I was giving the word on the > only database engines that would work with that and b) the OP wanted > to use a relational database, and therefore would have to use SQL While most database systems require SQL, the type of database and the query language used are are not as tightly coupled as you imply. I did quite a bit of work in Progres DB in a 4GL that was not SQL although SQL was an optional extra. The original query language for PostgreSQL and its predeccessor was QUEL, not SQL. There are other examples. See http://en.wikipedia.org/wiki/SQL#Alternatives_to_SQL for some. This is not to say that learning SQL is a bad idea. It is certainly the de facto standard today. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From tomupton33 at yahoo.com Wed Apr 30 10:53:45 2008 From: tomupton33 at yahoo.com (mickey333) Date: Wed, 30 Apr 2008 07:53:45 -0700 (PDT) Subject: new free fiction Message-ID: <87f74249-e245-48b5-9b8e-da1db750012f@r66g2000hsg.googlegroups.com> http://www.authspot.com/Short-Stories/Gossip.110935 From bdsatish at gmail.com Fri Apr 11 06:14:15 2008 From: bdsatish at gmail.com (bdsatish) Date: Fri, 11 Apr 2008 03:14:15 -0700 (PDT) Subject: Rounding a number to nearest even Message-ID: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> The built-in function round( ) will always "round up", that is 1.5 is rounded to 2.0 and 2.5 is rounded to 3.0. If I want to round to the nearest even, that is my_round(1.5) = 2 # As expected my_round(2.5) = 2 # Not 3, which is an odd num I'm interested in rounding numbers of the form "x.5" depending upon whether x is odd or even. Any idea about how to implement it ? From bbxx789_05ss at yahoo.com Tue Apr 1 19:28:33 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Tue, 1 Apr 2008 16:28:33 -0700 (PDT) Subject: BeautiflSoup -- getting all the attributes of a tag? References: Message-ID: On Apr 1, 5:25?pm, 7stud wrote: > You can treat a tag like a dictionary to obtain a specific attribute: > > import BeautifulSoup as bs > > html = "
hello
" > > doc = bs.BeautifulSoup(html) > div = doc.find("div") > print div > print div["x"] > > --output:-- > a > > But you can't iterate over a tag to get all the attributes: > > import BeautifulSoup as bs > > html = "
hello
" > > doc = bs.BeautifulSoup(html) > div = doc.find("div") > > for key in div: > ? ? print key, div[key] > > --output:-- > hello > Traceback (most recent call last): > ? File "test1.py", line 9, in ? > ? ? print key, div[key] > ? File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ > python2.4/site-packages/BeautifulSoup.py", line 430, in __getitem__ > ? ? return self._getAttrMap()[key] > KeyError: u'hello' > > How can you get all the attributes when you don't know the attribute > names ahead of time? I figured it out: import BeautifulSoup as bs html = "
hello
" doc = bs.BeautifulSoup(html) div = doc.find("div") for attr, val in div.attrs: print "%s:%s" % (attr, val) --output:-- x:a y:b z:c From miki.tebeka at gmail.com Tue Apr 8 11:50:34 2008 From: miki.tebeka at gmail.com (Miki) Date: Tue, 8 Apr 2008 08:50:34 -0700 (PDT) Subject: List open files References: <47fb8d54$0$15068$426a74cc@news.free.fr> Message-ID: <2af7d536-eb72-4e6d-96ca-3c91455b06b9@a9g2000prl.googlegroups.com> Hello Bruno, > I'd like, in a WIN32 environment, list all open files. > Anyone got a clue how to do this ? Have a look at the sysinternals suite (http://technet.microsoft.com/en- us/sysinternals/0e18b180-9b7a-4c49-8120-c47c5a693683.aspx), you might find stuff there that will help you. HTH, -- Miki http://pythonwise.blogspot.com From hdante at gmail.com Sun Apr 6 21:20:39 2008 From: hdante at gmail.com (hdante) Date: Sun, 6 Apr 2008 18:20:39 -0700 (PDT) Subject: appropriate python version References: <0790632f-db07-45ef-9bcd-7e1b592d33be@u69g2000hse.googlegroups.com> <61b10f10-a322-4835-b800-ed09d046fe56@e67g2000hsa.googlegroups.com> Message-ID: On Apr 6, 5:59 pm, xamdam wrote: > Thanks. I am guessing the 32bit build should work anyways, same as > other 32 progs on XP 64? The right build should be the "amd64" one. From m.moghimi at gmail.com Mon Apr 14 14:53:00 2008 From: m.moghimi at gmail.com (m.moghimi) Date: Mon, 14 Apr 2008 11:53:00 -0700 (PDT) Subject: Python Workshop References: Message-ID: <6fd50e0b-9637-422a-b1db-b76734630f54@w8g2000prd.googlegroups.com> On Apr 14, 5:15 pm, "Twayne" wrote: > > Hi, > > > We are to hold a workshop about python (introduction). It will be two > > one hour and half sessions. > > I wanted to know which subjects do you suggest to be presented and is > > there a good presentation file (powerpoint or ...) about this on the > > net. > > We thought that it may be good that first session covers the > > introduction, zen of python, python coding syntax and the second > > session will be about application, libraries or so. > > I really appreciate if you tell me your ideas? > > Depends; what's the experiene level of the audience? "Introductory" is > a pretty vague concept; introductory to what audience? > > -- > -- > Regards, > > Twayne > > Open Office isn't just for wimps anymore; > OOo is a GREAT MS Office replacementwww.openoffice.org The audiences are computer engineering students who know programming in c++ and some of them know java. From aaron.watters at gmail.com Wed Apr 16 12:40:11 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 16 Apr 2008 09:40:11 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> Message-ID: <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> On Apr 16, 12:27 pm, Rhamphoryncus wrote: > On Apr 16, 6:56 am, Aaron Watters wrote: > > > I don't get it. It ain't broke. Don't fix it. > > So how would you have done the old-style class to new-style class > transition? I'd ignore it. I never understood it and never had any need for it anyway. New-style classes and metaclasses were a complicated solution to an unimportant problem in my opinion. And also a fiendish way to make code inscrutible -- which I thought was more of a Perl thing than a Python thing, or should be. I must be missing some of the deeper issues here. Please educate me. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=killer%20joke From google at mrabarnett.plus.com Wed Apr 30 11:15:55 2008 From: google at mrabarnett.plus.com (MRAB) Date: Wed, 30 Apr 2008 08:15:55 -0700 (PDT) Subject: Code/test ratio wrt static vs dynamic typing [was: Re: Python Success stories] References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <57d73312-37b1-4c53-9669-803e84a6901f@p25g2000hsf.googlegroups.com> <263d5498-821f-4705-9e1d-cc9e97a98e07@34g2000hsf.googlegroups.com> Message-ID: On Apr 30, 10:47 am, cokofree... at gmail.com wrote: > > A rather off-topic and perhaps naive question, but isn't a 1:4 > > production/test ratio a bit too much ? Is there a guesstimate of what > > percentage of this test code tests for things that you would get for > > free in a statically typed language ? I'm just curious whether this > > argument against dynamic typing - that you end up doing the job of a > > static compiler in test code - holds in practice. > > > George > > To me it seems like more of an argument for a (more) concise Test > Framework for Python, or at least a fully fledge IDE beyond pyDev. You could just as easily argue that it shows the power of Python: something that contains so much functionality that it requires 120 000 lines to test completely needs only 30 000 lines to implement! :-) From v.harishankar at gmail.com Tue Apr 22 07:48:37 2008 From: v.harishankar at gmail.com (Harishankar) Date: Tue, 22 Apr 2008 17:18:37 +0530 Subject: subprocess module is sorely deficient? In-Reply-To: References: Message-ID: <200804221718.37819.v.harishankar@gmail.com> On Tuesday 22 Apr 2008 17:06:26 Paul Boddie wrote: > On 22 Apr, 12:52, Harishankar wrote: > > Is there any way to use non-blocking Popen objects using subprocess? and > > 2 - is there a way to kill the subprocess in a platform independent > > manner in a purely Pythonic way? I thought initially that this problem is > > simple enough, but over the last couple of days I've been really > > struggling to find any answer. I've been through dozens of mailing list > > archives in to find a solution. Unfortunately none of the solutions seem > > to fit my needs. > > If you want some hints about using subprocesses with non-blocking I/O, > you might find some in my jailtools and pprocess projects: > > http://www.python.org/pypi/jailtools > http://www.python.org/pypi/pprocess > Thank you. I will take a look at those. Actually I feel a mechanism like this should be built-in to Python in the future. > Although these projects involve things which are not exactly cross- > platform, the communications mechanisms should be portable, perhaps > with a bit of effort (since I don't recall whether the poll library > function is available on Windows, so you might have to use the select > function instead). It can be awkward sustaining non-blocking > communications with processes if they use buffered I/O, and the only > way I could make Python-based subprocesses work in jailtools was to > invoke them with the unbuffered option (-u). > > > My only solution seems to be to offer the end user the mencoder command > > line and make them execute it manually and be done with it but that seems > > a rather weak solution. > > The subprocess module may be an improvement over the popen2 module and > various os module functions, but it's still rather arcane. Yes. I am quite sure there must be an elegant solution to the subprocess handling/management. Problem is I've been at this for three days and I'm getting quite bleary eyed trying to pore through a lot of documentation ;-) -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org From ivory91044 at gmail.com Tue Apr 29 04:58:31 2008 From: ivory91044 at gmail.com (ivory91044 at gmail.com) Date: Tue, 29 Apr 2008 01:58:31 -0700 (PDT) Subject: nude crack whores Message-ID: <50bcba78-a4d6-4911-aad2-392154803562@e39g2000hsf.googlegroups.com> nude crack whores http://crack.cracksofts.com From __peter__ at web.de Wed Apr 30 10:12:17 2008 From: __peter__ at web.de (Peter Otten) Date: Wed, 30 Apr 2008 16:12:17 +0200 Subject: relative import broken? References: Message-ID: test wrote: > basic noob question here. > > i am trying to reference a package, i have the structure: > > mypack/ > __init__.py > test.py > subdir1/ > __init__.py > mod1.py > subdir2/ > __init__.py > mod2.py > > can someone please tell me why the statement: > > from mypack.subdir1.mod1 import * > > does NOT work from mod2.py nor from test.py? > > instead, if i use: > > from subdir1.mod1 import * > > it works perfectly from test.py. > > ....? The parent directory of mypack must be in the module search path, see http://docs.python.org/tut/node8.html#l2h-19 The least intrusive way to achieve this is to move test.py one level up in the directory hierarchy. Peter From victorsubervi at gmail.com Tue Apr 8 11:24:44 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Tue, 8 Apr 2008 10:24:44 -0500 Subject: String Literal to Blob Message-ID: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> Hi: I am able (finally) to upload an image to the database. However, when I try to retrieve it, I get a string literal. Here is my code: #!/usr/local/bin/python import cgitb; cgitb.enable() import MySQLdb def test(): host = 'mysqldb2.ehost-services.com' user = 'user' passwd = 'pass' db = 'bre' db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) cursor= db.cursor() cursor.execute('select pic1 from products where id="3";') content = cursor.fetchall() # print 'Content-Type: image/jpeg\r\nContent-Length: %d\n' % len(content) print 'Content-Type: image/jpeg\r\n' print '\n' print content print '\n' cursor.close() test() (Apparently, Plesk doesn?t like if __name__ == '__main__': ) The commented out line gives me a leading less than sign...and that?s it. What do? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From ptmcg at austin.rr.com Mon Apr 21 10:14:47 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Mon, 21 Apr 2008 07:14:47 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: On Apr 19, 4:42?am, Carl Banks wrote: > > If you don't like Python 3, DON'T USE IT. > I've read this position a number of times in this and related threads, and it overlooks one constituency of Python developers - those who develop and support modules for use by other Python users. As the supporter of pyparsing, I really can't just "not use" Py3 - ignoring Py3 means shutting out/holding back those of my users who do want to use it, and pretty much consigning my module to eventual dustbin status. Ideally, I can implement some form of cross-compatible code so that I need maintain only a single code base, and I have managed to do so on a number of fronts (with the help of Robert A. Clark): - add support for both __bool__ and __nonzero__ (__nonzero__ calls __bool__, so that upgrading to Py3 actually saves a function call) - convert isinstance(x,basestring) to isinstance(x,__BASESTRING__) and dynamically set __BASESTRING__ to basestring or str - similar treatment for sys.maxint/maxsize -> __MAX_INT__ I dodged a bullet when 3.0a3 added back in support for the 2.x form of "except" for exception handling. 3.0a2 only supported "except varname as ExceptionType:" and there was no way I could do this in a multi- version compatible way. My remaining hassle is print as function vs. print as statement. I provide a number of default diagnostic methods, and I have not fully gotten all to print nice - converting "print x" to "print (x)" is simple enough, and "print (x,y)" replaces "print x,y" well enough when running under Py3, but the same code in Py2.x now prints a tuple instead of a nice string like before. I will probably punt on the whole issue in the next release and just use sys.write.stdout/stderr throughout, and " ".join() the args (another function call!) before calling. I wasn't aware of the coming deprecation of '%' string interpolation, but at least it is deferred until 3.3, which does give me a few years I should think before I absolutely must address it. This is really not so much an issue for me as it is for my "customers." Pyparsing returns its parsed tokens using a class that is dict-like in behavior, but without extending dict (duck-typing at its finest!). I really like that my users can parse an expression and access any named fields directly and neatly in an interpolated string using "%(field_name)s". If this is removed, pyparsing will continue to work as-is, but I feel like a nice ease-of-access mode will have been lost to those who use it. Overall, I think I'm getting off pretty easy, but then pyparsing is a small module with very limited use of the standard lib. I can imagine that maintainers of larger libraries are having some serious fits trying to support both versions with a single code base. And as much as we all love Python-the-language, language features alone do not help a language and its community of users to grow and proliferate. I think most would agree that it is the cornucopia of libraries that really make Python an environment for developing production applications. -- Paul From guybenron at gmail.com Tue Apr 22 16:48:37 2008 From: guybenron at gmail.com (guybenron at gmail.com) Date: Tue, 22 Apr 2008 13:48:37 -0700 (PDT) Subject: Choosing log file destination in logging configuration file References: <3e85cd72-304e-4e17-8ca9-b0688a59fc14@t54g2000hsg.googlegroups.com> Message-ID: On Apr 22, 12:57 pm, Miki wrote: > Hello, > > > > > So far so good. In the relevant applications, the code looks something > > like this: > > logging.config.fileConfig('log.ini') > > logger = logging.getLogger('log.regular') logger = > > logging.getLogger('log.daemonic') > > .. and start logging. > > > The thorn in my side is that after the fileConfig call, BOTH handlers > > are instantiated, meaning both types of files are created for every > > component, even if I don't need it: component.log (for the rotating > > handler) and compenent.date.log (for the regular file handler). > > > ..So finally, here's my question: > > Apart from splitting the logging configuration into two separate > > files, is there any way to NOT create the file until you actually use > > it? > > You can generate the .ini file on the fly and then load it: > > >>> log_ini = gen_log_ini(type) # type is either "deamon" or "regular" > >>> atexit.register(lambda: remove(log_ini)) > >>> logging.config.fileConfig(log_ini) > > HTH, > -- > Miki http://pythonwise.blogspot.com I think it misses the point of having a file to config.. It looks as if there's no solution. A peek at the logging module shows this: klass = cp.get(sectname, "class") ... klass = eval(klass, vars(logging)) args = cp.get(sectname, "args") args = eval(args, vars(logging)) h = apply(klass, args) Bah. I'll have to split them into two configuration files (or subclass and have the respective file and rotating handlers lazy evaluate until the actual log call is made). Thanks though. From wwzaygvm at gmail.com Wed Apr 16 16:57:47 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 13:57:47 -0700 (PDT) Subject: fireworks cs3 crack Message-ID: <37fe3750-239a-4a8b-8871-e568913cf447@u12g2000prd.googlegroups.com> fireworks cs3 crack http://cracks.12w.net F R E E C R A C K S From nigamreetesh84 at gmail.com Mon Apr 14 00:41:55 2008 From: nigamreetesh84 at gmail.com (reetesh nigam) Date: Sun, 13 Apr 2008 21:41:55 -0700 (PDT) Subject: how to remove \n in the list Message-ID: <2ba667ab-6818-47eb-8595-79ed970728f7@q1g2000prf.googlegroups.com> hi, l=['5\n', '2\n', '7\n', '3\n', '6\n'] how to remove \n from the given list From gagsl-py2 at yahoo.com.ar Sun Apr 20 01:17:12 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 20 Apr 2008 02:17:12 -0300 Subject: RotatingFileHandler - ShouldRollover error References: <4ECBD915C6F1254AB1AFF4B9F08287B2176F4253C0@loftexchange.loftwareinc.com> Message-ID: En Wed, 16 Apr 2008 10:50:44 -0300, escribi?: > I am using the RotatingFileHandler logger with Python 2.5 on Windows and > I am getting an error on the rollover. When the log file gets close to > the size where it needs to rollover, I start getting the following error > for every log message. Does anyone have a solution to this problem? > > Traceback (most recent call last): > File "C:\Python25\Lib\logging\handlers.py", line 73, in emit > if self.shouldRollover(record): > File "C:\Python25\Lib\logging\handlers.py", line 147, in shouldRollover > self.stream.seek(0, 2) #due to non-posix-compliant Windows feature > ValueError: I/O operation on closed file There are some fixes in svn - you may try using the current sources from http://svn.python.org/projects/python/trunk/ -- Gabriel Genellina From iamzcyhit at gmail.com Sat Apr 12 22:33:12 2008 From: iamzcyhit at gmail.com (=?GB2312?B?1cW0utS9?=) Date: Sat, 12 Apr 2008 19:33:12 -0700 (PDT) Subject: Where is the function of 'apply' always used? Message-ID: <84cefd1a-58de-485b-b00b-77218d2d054c@c19g2000prf.googlegroups.com> I'am a beginner of Python.In the course of reading the Python book,I found the function:apply;But I don't understand its use.Help! From john.deas at gmail.com Sun Apr 6 13:50:51 2008 From: john.deas at gmail.com (John Deas) Date: Sun, 6 Apr 2008 10:50:51 -0700 (PDT) Subject: subprocess end Message-ID: <569918a5-4ad0-41e6-bec8-c9b870ae65cc@d45g2000hsc.googlegroups.com> Hi, I am coding a small script to batch-convert flv files. At the core of it, mencoder is called through processString='mencoder -oac lavc -ovc lavc -of lavf -lavcopts aglobal=1:vglobal=1:vcodec=mpeg4:acodec=libfaac:vbitrate=256:abitrate=64 -lavfopts format=mp4 -ofps 15 -vf scale=320:240,harddup -ss '+currBegin +' -endpos '+currEnd+' -o '+currOutput+' '+inputName p = subprocess.Popen(processString, shell=True,stdout=subprocess.PIPE) However, instructions following this last one do not wait for it to complete. Is it possible to change this behaviour, so that the rest of my script is executed only when this subprocess has finished its execution ? Thanks JD From no at spam.com Sat Apr 26 07:55:20 2008 From: no at spam.com (Grayham) Date: Sat, 26 Apr 2008 12:55:20 +0100 Subject: API's and hardware communication. Newbie Message-ID: <_MudnfZZ9uW0hY7VRVnyhwA@bt.com> Hi all I am new to this group so 'Hello All' I have a PC which is running linux and in it have installed a digital satellite card. I would like to write some software to access the card, tune it and bring back video. Basically a home brew DVB-s application. Being a non/new programmer (apart from some basic too many years ago) I decided to teach my self Python as from what i have read it's an easy and powerfull language to learn. I have been at it a few weeks and am getting on OK and finding it reasonably OK to pick up. The problem is i can find little to no information on programming for DVB cards or on how to access the Linux tv API in Python but I can find lots of information in C. This is making me think should i bother with Python and just learn C even though this will probably take a lot longer. Can some one help me or point me at a resource somewhere or would it be best to just learn C instead. I am aware this is a complicated little project for someone just starting out but it will be a multifaceted program with loads of interesting classes, functions and loops and i don't have to start with the really difficult stuff first. I just want to know if it's possible under python to access the DVB card and if so how? Cheers Grayham From marexposed at googlemail.com Fri Apr 18 05:28:56 2008 From: marexposed at googlemail.com (marexposed at googlemail.com) Date: Fri, 18 Apr 2008 10:28:56 +0100 Subject: Unicode chr(150) en dash In-Reply-To: <7dae96d4-48c4-46c9-9aa9-33a263b84ca4@26g2000hsk.googlegroups.com> References: <48063434$0$36327$742ec2ed@news.sonic.net> <7dae96d4-48c4-46c9-9aa9-33a263b84ca4@26g2000hsk.googlegroups.com> Message-ID: <20080418102856.fdf5ddf3.marexposed@googlemail.com> On Thu, 17 Apr 2008 20:57:21 -0700 (PDT) hdante wrote: > Don't use old 8-bit encodings. Use UTF-8. Yes, I'll try. But is a problem when I only want to read, not that I'm trying to write or create the content. To blame I suppose is Microsoft's commercial success. They won't adhere to standars if that doesn't make sense for their business. I'll change the approach trying to filter the contents with htmllib and mapping on my own those troubling characters. Anyway this has been a very instructive dive into unicode for me, I've got things cleared up now. Thanks to everyone for the great help. From steve at holdenweb.com Wed Apr 23 08:09:22 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 08:09:22 -0400 Subject: problem with dictionaries In-Reply-To: References: Message-ID: Simon Strobl wrote: > Hello, > > the idea of the following program is to parse a frequency list of the > form FREQUENCY|WORD, to store the frequency of a word in a dictionary > (and to do some things with this information later). > > I have done this many many times. Suddenly, it does not work any more: > The value frq[key] is different from the value that key has in the > file 'my_frqlist.txt'. > > I am using Python 2.5.1 > > Any hints? > > Simon > > ================================================ > > #!/usr/bin/python > > import sys > > frqlist = open('my_frqlist.txt', 'r') > > # my_frqlist looks like this: > # 787560608|the > # 434879575|of > # 413442185|and > # 395209748|to > # 284833918|a > # 249111541|in > # 169988976|is > > frq = {} > > for line in frqlist: > line = line.rstrip() > frequency, word = line.split('|') > frq[word] = int(frequency) > > for key in frq.keys(): > print key, frq[key] > You musts have missed the memo. The rules of the universe changed at 0834 UST yesterday, and all functioning Python programs stopped working. More seriously, *something* must have changed - it's probably not the rules of the universe though. Are the files now coming from a different source (Windows rather than Unix or vice versa)? As you read in the data, insert a print "%r: %s %s" % (line, frequency, word) to see exactly what is being processed and how it is getting split. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From Lie.1296 at gmail.com Sun Apr 27 13:49:19 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 27 Apr 2008 10:49:19 -0700 (PDT) Subject: How do I say "Is this a function"? References: <4813D22A.8040902@v.loewis.de> Message-ID: On Apr 27, 11:01?am, John Henry wrote: > On Apr 26, 6:08?pm, "Martin v. L?wis" wrote: > > > > > > def f1(): > > > ? ?print "In f1" > > > > def f3(): > > > ? ?print "In f3" > > > > def others(): > > > ? ?print "In others" > > > > for i in xrange(1,3): > > > ? ?fct = "f%d()"%(i+1) > > > ? ?try: > > > ? ? ? exec fct > > > ? ?except: > > > ? ? ? others() > > > I'd write that as > > > for i in xrange(1,3): > > ? ? globals().get("f%d" % (i+1), others)() > > > Regards, > > Martin > > Perfect. ?Works great. ?No EXEC. > > You guys are great. If you just want to avoid exec, why not: def f1: print "In f1" def f3: print "In f3" class f4(object): def __init__(self): print "In f4" def others: print "Since all else failed, I'm in others." f2 = "NAF -> Not a Function" flist = [f1, f2, f3, f4] for fct in flist: try: fct() except TypeError: others() It's readable, and it's fast if there's just a few "hard fault" (try- except works best when it usually succeed and just fails once or twice), and it's Pythonic too (Easier to ask forgiveness than to ask permission). The difference between this and the explicit type checking is that this allows a class (like f4) to pass since a Class Constructor & Initiator is a callable function too, depending on your need, you might want to consider class constructor as a function too. From gh at ghaering.de Tue Apr 15 11:10:26 2008 From: gh at ghaering.de (=?ISO-8859-1?Q?Gerhard_H=E4ring?=) Date: Tue, 15 Apr 2008 17:10:26 +0200 Subject: py3k s***s In-Reply-To: <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> Message-ID: <66jur3F2he852U1@mid.uni-berlin.de> Sverker Nilsson wrote: > [about code supporting multiple Python versions] > When it has been the fuzz with versions before, then I could have the > same code still work with older versions. But now it seems I have to > fork TWO codes. [...] I don't think many people have ported their C extensions to Python 3.0, yet. I've had the dubious privilege for pysqlite/the sqlite 3 module. And I find that's a bigger pain than the Python level. Way too many #ifdefs. I don't like branching projects, but this seems to be the only sensible approach here. -- Gerhard From gerry at nowhere.ford Tue Apr 22 23:02:52 2008 From: gerry at nowhere.ford (Gerry Ford) Date: Tue, 22 Apr 2008 22:02:52 -0500 Subject: pop langs website ranking References: <41fbaf27-a80b-402b-b406-c048a65a8643@b64g2000hsa.googlegroups.com> <315e13cc-3d21-4f2f-8503-835ea79069e2@x35g2000hsb.googlegroups.com> Message-ID: <1208919347_3071@news.newsgroups.com> "Paul McGuire" wrote in message news:315e13cc-3d21-4f2f-8503-835ea79069e2 at x35g2000hsb.googlegroups.com... On Apr 22, 4:41 pm, "xah... at gmail.com" wrote: > In February, i spent few hours researching the popularity of some > computer language websites. > I seem to recall this exact same post from *last* February. --->I remember it too. Xah is quite the self-promoter. Massive cross-posters don't have anything to say for me. -- "Life in Lubbock, Texas, taught me two things: One is that God loves you and you're going to burn in hell. The other is that sex is the most awful, filthy thing on earth and you should save it for someone you love." ~~ Butch Hancock From sierra9162 at gmail.com Wed Apr 16 11:27:32 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:27:32 -0700 (PDT) Subject: kate hudson oscars Message-ID: Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From castironpi at gmail.com Mon Apr 21 13:55:42 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Mon, 21 Apr 2008 10:55:42 -0700 (PDT) Subject: Database vs Data Structure? References: <61bf5f46-e917-4a98-b87f-8e5087cb07f7@a23g2000hsc.googlegroups.com> Message-ID: <33cda2a5-78e0-469d-8cde-b28acc3dd2da@m44g2000hsc.googlegroups.com> On Apr 19, 10:56?pm, Dennis Lee Bieber wrote: > On Sat, 19 Apr 2008 11:27:20 -0700, Scott David Daniels > declaimed the following in comp.lang.python: > > ? ? ? ? Hijacking as with the gmail kill filter I had to apply... > > > castiro... at gmail.com wrote: > > > Are databases truly another language from Python, fundamentally? > > ? ? ? ? Databases predate Python by decades... Though getting hardware fast > enough to implement the current darling -- relational -- did take a few > years. > > ? ? ? ? In my college days, database textbooks introduced: Hierarchical (IBM > IMS, I believe was the archetype used, though there were many others); > DBTG (Data Base Task Group) Network (the DBMS on the Xerox Sigma-6 at my > campus was a network model); and then gave Relational as an > experimental/theoretical format. About two years after I graduated, the > revised versions of the textbooks started with Relational, and then > listed hierarchical and network as "historical" formats. > > ? ? ? ? In hierarchical and network, one had to explicitly code for the way > the data was stored... In simple form: hierarchical required one to > access from a top-level record, which then had "fields" comprising > related data (and could have multiple occurrences). > > Invoice: ? ? ? ?has customer number, name, address, etc. and a "field" for > line items... The line items were a subtree: item number, description, > quantity, price, extended price... > > ? ? ? ? Network extended the hierarchical model by allowing access to the > "subtrees" from multiple different types of parent trees. > > ? ? ? ? Relational started life as a theory of "how to view the data -- > independent of how it is stored" -- comprising relations (which are NOT > the links between tables. In relational theory the terms equate as: > > Common/Lay ? ? ? ? ? ? ? ? ? ? ?Theory > table ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? relation > column ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?domain > row/record ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?tuple > > "relation" meant that all the data in each tuple was related to the > others. The SQL "relationship operators" that are used to link separate > tables are not where "relational database" comes from. > > ? ? ? ? SQL started life as a query language -- also independent of how the > data is stored. however, it fit into relational theory easily... Maybe > because it sort of combines relational algebra and relational calculus. > > > > > Classic qualities for a database that don't normally apply to Python > > (all properties of a "transaction" -- bundled set of changes): > > ? ? ? ? Examples might have been useful > > > ? ? ?* Atomicity: > > ? ? ? ? A transaction either is fully applied or not applied at all. > > ? ? ? ? Well... self-explanatory... > > > ? ? ?* Consistency: > > ? ? ? ? Transactions applied to a database with invariants preserve > > ? ? ? ? those invariants (things like balance sheets totals). > > ? ? ? ? One of the key ones... > > ? ? ? ? update accounts set > ? ? ? ? ? ? ? ? balance = balance - 100 > ? ? ? ? where accountnum = "from account"; > ? ? ? ? update accounts set > ? ? ? ? ? ? ? ? balance = balance + 100 > ? ? ? ? where accountnum = "to account"; > > ? ? ? ? A failure between the two update statements MUST ensure that no > changes were made to the database... Otherwise, one would lose 100 into > the vapor. (This example does link back to the "A" and is more on the > user side -- the code needs to specify that both updates are part of the > same transaction). > > > ? ? ?* Isolation: > > ? ? ? ? Each transactions happens as if it were happening at its own > > ? ? ? ? moment in time -- tou don't worry about other transactions > > ? ? ? ? interleaved with your transaction. > > ? ? ? ? Though how various RDBMs implement this feature gets confusing. One > has everything from locking the entire database (basically meaning that > "losing" transactions don't get applied at all and the code has to > reexecute the transaction logic) down to those that can lock on > individual records -- so overlapping transactions that don't need those > records complete with no failures. > > > ? ? ?* Durability: > > ? ? ? ? Once a transaction actually makes it into the database, it stays > > ? ? ? ? there and doesn't magically fail a long time later. > > ? ? ? ? Assuming a disk failure is not "magic" and one doesn't have a recent > backup > > -- > ? ? ? ? Wulfraed ? ? ? ?Dennis Lee Bieber ? ? ? ? ? ? ? KD6MOG > ? ? ? ? wlfr... at ix.netcom.com ? ? ? ? ? ? wulfr... at bestiaria.com > ? ? ? ? ? ? ? ? HTTP://wlfraed.home.netcom.com/ > ? ? ? ? (Bestiaria Support Staff: ? ? ? ? ? ? ? web-a... at bestiaria.com) > ? ? ? ? ? ? ? ? HTTP://www.bestiaria.com/ I'm holding the premise that money can be made different ways, also and as technique is scarce, and exploration in programming is a non- negative utility. I have a soft-coded script I can show, I'm just not in the space program. From see at signature.invalid Sat Apr 19 13:49:42 2008 From: see at signature.invalid (Douglas Wells) Date: Sat, 19 Apr 2008 13:49:42 -0400 (EDT) Subject: Kill an OS process from script (perhaps unix specific) References: <7cd7208f-777b-4264-8d34-3c4bf3377940@a22g2000hsc.googlegroups.com> Message-ID: In article <7cd7208f-777b-4264-8d34-3c4bf3377940 at a22g2000hsc.googlegroups.com>, chengiz at my-deja.com writes: > Hi, > I'm trying to run a process from a python script. I need the exit > status of that process but do not care about its output, so until now > was using os.system(). But it turned out that the process often went > into an infinite loop, so I wrote a SIGALRM handler. Unfortunately the > code I came up with is quite kludgy: > > import subprocess > ... > try: > p = subprocess.Popen(..., shell = True) > pid = p.pid > os.waitpid(pid...) > ... > except ...: # Thrown by alarm signal handler > os.kill(pid + 1) # "Real" pid = shell pid + 1 > ... > > The os.kill is very hacky and unsafe so I was looking for better > ideas. Any help will be greatly appreciated. Thanks! Assuming that the problem is really an infinite loop (and not just an arbitrary delay), you could use the simple construct: import os code = os.system ("ulimit -t ; ...") That's not guaranteed to work on all POSIX systems, but it should work with at least ash, bash, and ksh. And it would would be "limit cputime ; ..." if you somehow got hooked up with a C shell. - dmw -- . Douglas Wells . Connection Technologies . . Internet: -sp9804- -at - contek.com- . From paulgeeleher at gmail.com Thu Apr 24 08:12:46 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Thu, 24 Apr 2008 05:12:46 -0700 (PDT) Subject: Setting expirty data on a cookie References: <8ba48e05-9aba-4a56-805c-cd31b43517ab@24g2000hsh.googlegroups.com> Message-ID: <80818edd-37dd-4306-8723-97db63afd5fb@z72g2000hsb.googlegroups.com> On Apr 24, 12:41 pm, sophie_newbie wrote: > On Apr 22, 8:38 pm, David wrote: > > > On Tue, Apr 22, 2008 at 6:21 PM,sophie_newbie wrote: > > > Does anyone know how to do this? I can't seem to make it work. > > > > I'm using: > > > > c = Cookie.SimpleCookie() > > > c['data'] = "unamepwordwhatever" > > > c.expires = time.time() + 300 > > > print c > > > > This doesn't seem to work, so I'm assuming isn't the correct way to > > > set an expiry data? Anyone able to help me out here? > > > You're probably looking for cookielib.Cookie > > I don't think so, to give you a more complete picture, if I run this > code: > > import Cookie > import time > c = Cookie.SimpleCookie() > c['data'] = "unamepwordwhatever" > c.expires = time.time() + 300 > print c > > This codes gives an output of: > > "Set-Cookie: data=unamepwordwhatever" > > As in there is no mention of an expiry date, when surely there should > be? > > Thanks for any advice. Ok this seems to work: import Cookie import time c = Cookie.SimpleCookie() c['data'] = "unamepwordwhatever" c['data']['expires'] = 30 * 24 * 60 * 60 print c Gives an output of: "Set-Cookie: data=unamepwordwhatever; expires=Sat, 24-May-2008 12:11:36 GMT" Bizarre that this information was so hard to find! From gagsl-py2 at yahoo.com.ar Mon Apr 21 01:45:39 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 02:45:39 -0300 Subject: Prob. w/ Script Posting Last Value References: <4dc0cfea0804170922n2a96be20sc424a7e67742a12e@mail.gmail.com> <480791D6.4000802@holdenweb.com> <4dc0cfea0804171151y204b11bal160762b88dfcf3ee@mail.gmail.com> Message-ID: En Thu, 17 Apr 2008 15:51:43 -0300, Victor Subervi escribi?: > On Thu, Apr 17, 2008 at 1:07 PM, Steve Holden wrote: >> Victor Subervi wrote: >> >> > Gabriel provided a lovely script for showing images which I am modifying >> > for my needs. I have the following line: >> > print '

\n' % (d, y) >> > where the correct values are entered for the variables, and those values >> > increment (already tested). Here is the slightly modified script it calls: >> > #!/usr/local/bin/python >> > import cgitb; cgitb.enable() >> > import MySQLdb >> > import cgi >> > form = cgi.FieldStorage() >> > picid = int(form["id"].value) >> > x = int(form["x"].value) >> > pic = str(x) >> > print 'Content-Type: text/html' >> > db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) >> > cursor= db.cursor() >> > sql = "select " + pic + " from products where id='" + str(picid) + "';" >> > cursor.execute(sql) >> > content = cursor.fetchall()[0][0].tostring() >> > cursor.close() >> > print 'Content-Type: image/jpeg\r\nContent-Length: %s\n' % len(content) >> > print content >> > I need to make it so that it will show all my images, not just the last >> > one. Suggestions, please. That 'Content-Type: text/html' is wrong, you're returning an image here. Are you sure that *different* pictures are stored in the database? Perhaps there was an error and all columns have the same picture. Also make sure you're not seeing a cached image in your browser. >> > In your "page generator" page, replace >> >> print '

\n' % (d, y) >> >> by >> >> for d, y in (results of some DB query to get d and y for each image): >> print '

\n' % (d, y) > > Well, I just tried this: > > #! /usr/bin/python > print """Content-type: text/html > > > > > > > > """ > y = 1 > for d in 2, 12: > while y < 12: > print '

\n' % (d, y) > y += 1 > print""" > > """ > and it printed the same image over and over again :( An empty line is missing after Content-Type and before the actual content. Look at the source and be sure the src= attribute is generated correctly. -- Gabriel Genellina From carlwuhwdmckay at gmail.com Mon Apr 21 02:11:00 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:11:00 -0700 (PDT) Subject: crack cocaine user profile Message-ID: <88437666-f152-4a4a-bca3-9a4d5fb88244@l64g2000hse.googlegroups.com> crack cocaine user profile http://cracks.00bp.com F R E E C R A C K S From jjl at pobox.com Tue Apr 1 16:17:29 2008 From: jjl at pobox.com (John J. Lee) Date: Tue, 01 Apr 2008 20:17:29 GMT Subject: Why prefer != over <> for Python 3.0? References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> Message-ID: <87prt9coti.fsf@pobox.com> "Gabriel Genellina" writes: [...] >> There was a version of APL for the Sinclair QL which replaced the >> standard APL symbols with keywords. > > Wow, APL on 8 bits? > Now there is (or perhaps there was) J, a reincarnation of APL by > Iverson himself that uses ASCII characters only. The BBC Model B ran I-APL, too. Sitting on my desk is a copy of "I-APL Instruction Manual for PC Clones, RML Nimbus, BBC Master & B, and Archimedes", along with a few other APL books and a pile of newsletters, waiting to be thrown away :-( I got a copy because they were giving it away free to schools. Poisoning young minds ;-) How did programmers manage back then in 32k? Less software development, more jigsaw puzzle. John From fennelllindy8241 at gmail.com Mon Apr 28 03:17:06 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:17:06 -0700 (PDT) Subject: norton ghost crack Message-ID: norton ghost crack http://crack.cracksofts.com From carlwuhwdmckay at gmail.com Sat Apr 26 09:35:01 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:35:01 -0700 (PDT) Subject: perfect patch Message-ID: <7ee2c246-d7ec-4615-b2c1-e2a4b6460e8e@m73g2000hsh.googlegroups.com> perfect patch http://cracks.00bp.com F R E E C R A C K S From andrewdied at gmail.com Mon Apr 14 11:01:28 2008 From: andrewdied at gmail.com (andrewdied at gmail.com) Date: Mon, 14 Apr 2008 08:01:28 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: On Apr 11, 4:14?am, bdsatish wrote: > I'm interested in rounding numbers of the form "x.5" depending upon > whether x is odd or even. Any idea about how to implement it ? Side note: A specialized use for this is in the US Field Artillery, where it's called "artillery expression." You don't round, but "express" a fraction to the nearest even whole number. 2.5 is 2.0, 3.5 is 4.0, etc. Or, if you need to express to the tens, 15 is 20, 25 is 20, and so on. From workitharder at gmail.com Tue Apr 1 18:46:20 2008 From: workitharder at gmail.com (bukzor) Date: Tue, 1 Apr 2008 15:46:20 -0700 (PDT) Subject: Directed Graph Traversal Message-ID: <804682cb-2da6-4d85-83d4-c7425c498534@p25g2000hsf.googlegroups.com> Can someone point me in the direction of a good solution of this? I'm using it to construct a SQL query compiler, where each node is a table and each edge is a join. I'm planning on using the NetworkX library if possible. https://networkx.lanl.gov/reference/networkx/ Given a directed graph and a list of points in the graph, what is the minimal subgraph that contains them all? It is preferable that the subgraph is a tree. A -- B -- C -- D | | E -- F A, B, F => ABEF (or ABCF) A, F, C => ABCF A, E, D => ABCD E Thanks! --Buck From gagsl-py2 at yahoo.com.ar Tue Apr 8 15:37:19 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 08 Apr 2008 16:37:19 -0300 Subject: Calling CVF-Fortran-dll with ctypes and simple structure References: <60915c2d-0c0d-42fc-8b02-5fb58e13a20c@p25g2000hsf.googlegroups.com> Message-ID: En Tue, 08 Apr 2008 06:02:17 -0300, Michael Sch?fer escribi?: > Gabriel, > > works perfect - even in complex nested structures! > Thank you very much! > >> (If both Fortran and VB say "char*9", why did you choose a pointer >> here?) > I do not know this possibility. Could you please drop me a few lines? (It's just what I posted and you said it worked) In C, strings are usually represented as an array of characters implicitely ending at the first NULL character. By example: `char foo[20]` declares a string variable named foo with enough space for up to 19 characters (plus the final NULL character). A very common way of refer to such strings is to pass a pointer to its first character: `char *pfoo` declares a variable pfoo which can hold a reference to a string variable allocated somewhere (this is the usual way to pass a string argument to a function). In ctypes terminology, the first type is declared as c_char*20, and the second one is c_char_p. In FORTRAN you'd use CHARACTER*20 FOO (or CHARACTER(20)::FOO) to declare a string variable with up to 20 characters, right padded with spaces. The appropiate way to declare this with ctypes is then to use c_char*20 (and probably initialize it with spaces, and trim spaces on the right coming from Fortran). c_char_p declares a pointer, but Fortran filled it as it were an array of characters: the first 4 letters of "Sample", when read as a little-endian integer, give 0x706D6153, the "invalid pointer" you got. -- Gabriel Genellina From vinay_sajip at yahoo.co.uk Wed Apr 23 12:50:33 2008 From: vinay_sajip at yahoo.co.uk (Vinay Sajip) Date: Wed, 23 Apr 2008 09:50:33 -0700 (PDT) Subject: Choosing log file destination in logging configuration file References: <3e85cd72-304e-4e17-8ca9-b0688a59fc14@t54g2000hsg.googlegroups.com> Message-ID: <97bb1161-92f2-4079-8f59-a924c965d2f5@34g2000hsf.googlegroups.com> On Apr 22, 9:48 pm, guyben... at gmail.com wrote: > On Apr 22, 12:57 pm, Miki wrote: > > > > > Hello, > > > > So far so good. In the relevant applications, the code looks something > > > like this: > > >logging.config.fileConfig('log.ini') > > > logger =logging.getLogger('log.regular') logger = > > >logging.getLogger('log.daemonic') > > > .. and startlogging. > > > > The thorn in my side is that after the fileConfig call, BOTH handlers > > > are instantiated, meaning both types of files are created for every > > > component, even if I don't need it: component.log (for the rotating > > > handler) and compenent.date.log (for the regular file handler). > > > > ..So finally, here's my question: > > > Apart from splitting theloggingconfiguration into two separate > > > files, is there any way to NOT create the file until you actually use > > > it? > > > You can generate the .ini file on the fly and then load it: > > > >>> log_ini = gen_log_ini(type) # type is either "deamon" or "regular" > > >>> atexit.register(lambda: remove(log_ini)) > > >>>logging.config.fileConfig(log_ini) > > > HTH, > > -- > > Miki http://pythonwise.blogspot.com > > I think it misses the point of having a file to config.. > It looks as if there's no solution. A peek at theloggingmodule shows > this: > klass = cp.get(sectname, "class") > ... > klass = eval(klass, vars(logging)) > args = cp.get(sectname, "args") > args = eval(args, vars(logging)) > h = apply(klass, args) > > Bah. I'll have to split them into two configuration files (or subclass > and have the respective file and rotating handlers lazy evaluate until > the actual log call is made). > Thanks though. Not sure if it's any help - the SVN version contains a new optional "delay" parameter for FileHandler and subclasses (including the rotating handlers) which delays opening the file until there's a need to, i.e. when an emit() call occurs. Regards, Vinay Sajip From danb_83 at yahoo.com Sun Apr 20 02:25:33 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Sat, 19 Apr 2008 23:25:33 -0700 (PDT) Subject: Checking if a text file is blank References: Message-ID: On Apr 20, 1:04 am, elno... at gmail.com wrote: > Greetings! > > I've just started learning python, so this is probably one of those > obvious questions newbies ask. > > Is there any way in python to check if a text file is blank? > > What I've tried to do so far is: > > f = file("friends.txt", "w") > if f.read() is True: > """do stuff""" > else: > """do other stuff""" > f.close() > > What I *mean* to do in the second line is to check if the text file is > not-blank. But apparently that's not the way to do it. > > Could someone set me straight please? The flaw in your code is that "f.read() is True" doesn't do what you think it does. (1) The "is" operator is a test for object IDENTITY. Two objects can be equal but distinct >>> list1 = list2 = [1, 2, 3] >>> list1 is list2 True >>> list1[-1] = 4 >>> list2 [1, 2, 4] >>> list1 = [1, 2, 3] >>> list2 = [1, 2, 3] >>> list1 is list2 False >>> list1[-1] = 4 >>> list2 [1, 2, 3] (2) Even if you used "f.read() == True", it still wouldn't work in Python. Values can be true or false (in the context of an if or while statement) without being equal to True or False. Values that are equal to True: True, 1, 1.0, (1+0j), decimal.Decimal(1) Values that are true but not equal to True: "spam", "1", (1,), [1], set([1]), {1: 2}, etc. Values that are equal to False: False, 0, 0.0, 0j, decimal.Decimal(0) Values that are false but not equal to False: "", (), [], set() And even if you are sure that you're only dealing with values of 0 or 1, it's unnecessary to write "if x == True:". It's redundant, just like "if (x == True) == True:" or "if ((x == True) == True) == True:". Just write "if x:". Or, in this specific case, "if f.read():". (3) While not affecting your program's correctness, it's rather inefficient to read a gigabytes-long file into memory just to check whether it's empty. Read just the first line or the first character. Or use os.stat . From john106henry at hotmail.com Wed Apr 2 16:01:00 2008 From: john106henry at hotmail.com (John Henry) Date: Wed, 2 Apr 2008 13:01:00 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> Message-ID: <58deb8b8-bae9-4d43-b973-3d90846726cb@b5g2000pri.googlegroups.com> On Apr 1, 11:10 am, sprad wrote: > On Apr 1, 11:41 am, mdomans wrote: > > > Python needs no evangelizing but I can tell you that it is a powerfull > > tool. I prefer to think that flash is rather visualization tool than > > programing language, and java needs a lot of typing and a lot of > > reading. On the other hand python is simple to read and write, can be > > debuged easily, is intuitive and saves a lot of time. It also supports > > batteries included policy and you can't get more OO than python. > > One advantage of Flash is that we can have something moving on the > screen from day one, and add code to it piece by piece for things like > keyboard or mouse control, more and more complex physics, etc. Is > there an equivalent project in Python? I downloaded the "How to Think Like a Python Programmer" book and read it. I think it's a fine reference book for the purpose you indicated. Here's my 2 cents on the subject. I had been a volunteer mentor to my son's middle school robotic team for several years and I have some experiences, therefore, in how kids react to "programming". Granted, high school kids are "bigger kids" - but they are kids nevertheless. Last summer, I experimented teaching my own kid Python. He was in 7th grade going onto 8th grade. He was the main goto person for the robotic team and had no trouble learning the common applications such as the Microsoft Office suite, and had some experience in ICONic programming (Lego Mindstorm). So, I tried to see what would happen if he tries to learn Python - using somewhat similar approach you are taking: start with something visually appealing on day one. Instead of Flash, I used Pythoncard - a no-brainer Python GUI construction toolkit. He was really excited seeing how easy it was to have tic-tae- toe type program up so easily (we are taking minutes - not hours) and was very interested and motivated to continue. So far so good. However, once I start teaching him variables, expressions, loops, and what not, I found that (by surprise) he had great difficulties catching on. Not soon after that, we had to quit. We - as adults - take many things for granted and sometimes don't remember, or don't understand how kids learn. My experience tells me that in order to teach today's video game generation of kids, the approach really has to be entirely visual. After I abandoned my attempt to teach my kid Python, I started them on Robolab - a simplified version of LabView and to my delight, they were able to cook up a few simple programs (like fibonacci series and so forth) without too much effort - although my own kid had some minor trouble understanding the concept of a container (LabView's version of a variable). I don't know if you have access to LabView or Robolab or similar packages but if you do, I would highly recommend those. LabView is every bit as powerful, full-featured, and "real-life" as many of the other languages and I believe that kids will have a much easier time learning computer programming with it. And you are going to teach them Java? Oh, please don't. Let the colleges torture them. :=) From spe.stani.be at gmail.com Tue Apr 29 07:38:56 2008 From: spe.stani.be at gmail.com (SPE - Stani's Python Editor) Date: Tue, 29 Apr 2008 04:38:56 -0700 (PDT) Subject: Learn python packaging for Ubuntu and Debian in the Ubuntu Open Week Message-ID: Hi All, If you wrote some python code that you want to package or know a cool python application of which you like to make a deb installer, the python packaging session is all for you! Do you develop some cross- platform open source software and you want to give its popularity a boost by bringing it to Ubuntu and Debian, read on! (Packages are what installers are for Windows.) This session will be hosted by the respected Emilio (pochu). I've worked closely together with him (and others of the Debian PAPT team like POX & ScottK) to make sure these packages landed well in Ubuntu Hardy and Debian Unstable: - Phatch (sudo apt-get install phatch, http://photobatch.stani.be) - SPE (sudo apt-get install spe, http://pythonide.stani.be) I've requested this session as I found there was almost no information available tailored for python coders. I hope many people will attend. The logs will be available here: https://wiki.ubuntu.com/MeetingLogs/openweekhardy/PythonPackaging The complete program of the Ubuntu Open Week is available here: https://wiki.ubuntu.com/UbuntuOpenWeek Feel free to comment or questions ahead of this session on this thread. I am sure Emilio will read this thread. See you there! Stani From lbonafide at yahoo.com Mon Apr 14 08:01:33 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Mon, 14 Apr 2008 05:01:33 -0700 (PDT) Subject: Java or C++? References: Message-ID: On Apr 14, 1:44?am, s0s... at gmail.com wrote: > Hello, I was hoping to get some opinions on a subject. I've been > programming Python for almost two years now. Recently I learned Perl, > but frankly I'm not very comfortable with it. Now I want to move on > two either Java or C++, but I'm not sure which. Which one do you think > is a softer transition for a Python programmer? Which one do you think > will educate me the best? It depends on your reasons for learning either. If you're targeting a specific job market, find out what is prevelant in that market. And keep in mind that if it's for a job, you'll also have to get up to speed on the relevant libraries and frameworks. If it's educational, I'd recommend C++ just to learn about pointers and memory management, so you get a better idea of what's going on under the covers in languages like Java and Python and Ruby and C#. From sanhitam at yahoo.com Thu Apr 10 13:05:59 2008 From: sanhitam at yahoo.com (Sanhita Mallick) Date: Thu, 10 Apr 2008 10:05:59 -0700 (PDT) Subject: Graphs in Python Message-ID: <531651.98983.qm@web55601.mail.re4.yahoo.com> Hi. I am a newbie to Python. I am trying to implement a Python code for graph manipulation. My graphs are about 200-500 nodes big. Excepting for the short basic graph implementation info on Python.org, where can I find more in depth info about how to express graphs in python, and how to use them in a code? Also, does anyone know of a easy way of creating the dictionary for python for a 500-node graph, without typing each and every node? I found some application that recognize dot file Graphviz - but I am looking for a program that can let me "draw" a graph and then generate the lists automatically from the drawing. Thanks. -SM From charleshixsn at earthlink.net Sat Apr 12 19:33:44 2008 From: charleshixsn at earthlink.net (Charles D Hixson) Date: Sat, 12 Apr 2008 16:33:44 -0700 Subject: class level properties In-Reply-To: References: Message-ID: <480146D8.5010506@earthlink.net> Arnaud Delobelle wrote: > On Apr 12, 8:36 pm, Charles D Hixson > wrote: > >> I'm trying to construct read-only variables at the class level. I've >> been unsuccessful. Any suggestions? >> >> Mixing @classmethod and @property doesn't appear to produce workable >> code. Ditto for mixing @classmethod and __getattr__. (The property >> approach compiles, but execution says that you can't execute properties.) >> >> I've got a rather large number of variables, so I don't want to define >> function accessors for each of them, and I *REALLY* don't want to have >> to access them as functions rather than variables or properties. >> > > Metaclasses, of course! > > >>>> class MetaX(type): >>>> > ... @property > ... def spam(self): return 'eggs' > ... > >>>> class X(object): >>>> > ... __metaclass__ = MetaX > ... > >>>> X.spam >>>> > 'eggs' > > > HTH > > -- > Arnau Thanks. I can make that work. Is it possible to move the entire implementation of the interpretation of _valueMap, below, into properties in some similar way? I'm referring to the part managed by __getattr__ below. I want a hundred or so read-only variables, and I'm not sure the best way to achieve it. class MetaROVars(type): @property def simple(self): return "simple example working" class test(object): __metaclass__ = MetaROVars _valueMap = { "t1" : (3, "Concept decay rate", "[1, 99]"), "t2" : (10, "TaskLink decay rate", "[1, 99]"), } #@classmethod def __getattr__(self, name): if name not in test._valueMap: raise AttributeError, name return test._valueMap[name][0] def describe (self, name): if name not in test._valueMap: raise AttributeError, name return test._valueMap[name][1] + ", lying in the range " + test._valueMap[name][2] p = test() print p.t1 print p.describe("t1") print p.t2 print test.simple From nagle at animats.com Fri Apr 4 11:25:17 2008 From: nagle at animats.com (John Nagle) Date: Fri, 04 Apr 2008 08:25:17 -0700 Subject: Is there an official way to add methods to an instance? In-Reply-To: <47f61041$0$27969$426a34cc@news.free.fr> References: <7xve2yas87.fsf@ruckus.brouhaha.com> <47f61041$0$27969$426a34cc@news.free.fr> Message-ID: <47f645e6$0$36354$742ec2ed@news.sonic.net> Bruno Desthuilliers wrote: > Paul Rubin a ?crit : >> Brian Vanderburg II writes: >>> I've checked out some ways to get this to work. I want to be able to >>> add a new function to an instance of an object. >> >> Ugh. Avoid that if you can. > > Why so ? OO is about objects, not classes, and adding methods on a > per-object basis is perfectly legitimate. It's what professional programmers call a "l33t feature", one not suitable for production code. Typically such features are used by programmers with about two years experience, trying too hard to prove that they're cool. John Nagle From jcd at sdf.lonestar.org Fri Apr 18 11:43:09 2008 From: jcd at sdf.lonestar.org (J. Cliff Dyer) Date: Fri, 18 Apr 2008 11:43:09 -0400 Subject: Python-list Digest, Vol 55, Issue 296 In-Reply-To: References: Message-ID: <1208533389.4748.11.camel@aalcdl07.lib.unc.edu> On Fri, 2008-04-18 at 17:25 +0200, python-list-request at python.org wrote: > I really like developing in Python -- but it's hard > to keep doing it when the growth curve is so slow > and a so many people have deep reservations about it, > inspired in part, justifiably, by nonsense like this. > In fact, I basically stopped. Then I came back. Now > I'm wondering if it was such a good idea... > > -- Aaron Watters >From what I've read, the slowness of the growth curve was actually one of the major issues that prompted the Py3K push in the first place. The accumulated cruft had gotten heavy, and was slowing python down. Py3K is deliberately conservative, so that the transition will be as painless as possible, but strips away the warts that were slowing things down. Having print as a statement meant it was difficult to add functionality there. Supporting both new and old style classes meant that you couldn't count on expected functionality in external libraries. The string/unicode dichotomy caused innumerable headaches for everybody. The big changes you are hoping for to justify py3k won't come in python 3.0. They'll come in python 3.2 and python 3.3. Of course, I'm well aware that I'm talking about vaporware, but making the architectural changes now to make that advancement possible in the future is the point of python 3.0. In the meantime, your code will always work on Python 2.5. If you're worried about wild code, bundle it with its own interpreter when you distribute it. It'll survive. Cheers, Cliff From medin0065 at gmail.com Sun Apr 20 10:47:16 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:47:16 -0700 (PDT) Subject: xbox patch Message-ID: <4b32d9dc-6030-4439-8b5d-779a46e82acd@s33g2000pri.googlegroups.com> xbox patch http://cracks.00bp.com F R E E C R A C K S From skanemupp at yahoo.se Sun Apr 13 09:52:06 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 13 Apr 2008 06:52:06 -0700 (PDT) Subject: py2exe, program has stoped working!? Message-ID: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> so i used py2exe and i have the build and the dist-folders. in the distfolder there is a Calculator.exe file. when i run it it just says "Calculator.exe has stopped working" in a popup but the program itself never shows up. wtf!? and when im distributing my program i have to include both catalogues right? From bruno.42.desthuilliers at websiteburo.invalid Thu Apr 24 07:28:09 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Thu, 24 Apr 2008 13:28:09 +0200 Subject: help needed with classes/inheritance In-Reply-To: <676bac37-2816-402b-9aed-1a9c1873351b@a23g2000hsc.googlegroups.com> References: <8060c44c-cf92-479a-b6b3-ebf5218b6e32@27g2000hsf.googlegroups.com> <480f05d0$0$25755$426a74cc@news.free.fr> <676bac37-2816-402b-9aed-1a9c1873351b@a23g2000hsc.googlegroups.com> Message-ID: <48106eb5$0$21323$426a74cc@news.free.fr> barbaros a ?crit : > On Apr 23, 10:48 am, Bruno Desthuilliers 42.desthuilli... at websiteburo.invalid> wrote: > >>> My question is: can it be done using inheritance ? >> Technically, yes: >> >> class OrientedBody(Body): >> def __init__(self, orient=1): >> Body.__init__(self) >> self.orient = 1 >> >> Now if it's the right thing to do is another question... > > If I understand correctly, in the above implementation I cannot > define firstly a (non-oriented) body, and then build, on top of it, > two bodies with opposite orientations. The point is, I want > both oriented bodies to share the same base Body object. Then it's not a job for inheritence, but for composition/delegation - Sorry but I didn't get your specs quite right :-/ Now the good news is that Python makes composition/delegation close to a no-brainer: class Body(object): # definitions here class OrientedBody(object): # notice that we *dont* inherit from Body def __init__(self, body, orient): self._body = body self.orient = orient def __getattr__(self, name): try: return getattr(self._body, name) except AttributeError: raise AttributeError( "OrientedBody object has no attribute %s" % name ) def __setattr__(self, name, val): # this one is a bit more tricky, since you have # to know which names are (or should be) bound to # which object. I use a Q&D approach here - which will break # on computed attributes (properties etc) in the Body class - # but you can also define a class attribute in either Body # or OrientedBody to explicitly declare what name goes where if name in self._body.__dict__: setattr(self._body, name, val) else: object.__setattr__(self, name, value) From grahn+nntp at snipabacken.se Thu Apr 3 16:15:16 2008 From: grahn+nntp at snipabacken.se (Jorgen Grahn) Date: 3 Apr 2008 20:15:16 GMT Subject: Pexpect question. References: Message-ID: On Wed, 02 Apr 2008 19:57:31 -0600, Paul Lemelle wrote: > Jorgen, > > Thanks for your reply. > > The ssh function is just a small part of what I would like to > accomplish. And yes, chk is undefined, I was trying to figure out why > control was not being returned from the sshcon funciton. OK. Hope my note helped. > I looked for pexpect doucment on http://www.noah.org/wiki/Pexpect, but > the documentaiton link appear to be broken. Could you recommend > another site? As I recall it, the online documentation is just the documentation from the Python module itself, HTML-formatted. You can simply type "pydoc pexpect" and get the reference manual. I think it's pretty good. /Jorgen -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! From bignose+hates-spam at benfinney.id.au Tue Apr 15 19:23:33 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Wed, 16 Apr 2008 09:23:33 +1000 Subject: How to have unittest tests to be executed in the order they appear? References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> Message-ID: <87zlru7le2.fsf@benfinney.id.au> "Giampaolo Rodola'" writes: > Is there a way to force unittest to run test methods in the order > they appear? No, and this is a good thing. Your test cases should *not* depend on any state from other test cases; they should function equally well when executed in any arbitrary sequence. Dependencies between separate test cases (e.g. "they only work correctly when run in a specific sequence") means you're not isolating them properly. Use the TestCase.setUp and TestCase.tearDown methods to handle any fixtures needed by test cases in each class of test cases. That way, the fixtures will be set up and torn down between every test case. Find out about test fixtures in the documentation for unittest . -- \ "All my life I've had one dream: to achieve my many goals." -- | `\ Homer, _The Simpsons_ | _o__) | Ben Finney From mdw at distorted.org.uk Thu Apr 17 13:30:21 2008 From: mdw at distorted.org.uk (Mark Wooding) Date: Thu, 17 Apr 2008 17:30:21 +0000 (UTC) Subject: Integer dicision References: <5f499bee-a659-4e36-870c-076cb613a3e7@t12g2000prg.googlegroups.com> Message-ID: bdsatish wrote: > How does (a/b) work when both 'a' and 'b' are pure integers ? > >>> (9/2) > 4 > >>> (-9/2) > -5 > > Why is it -5 ? I expect it to be -4 ? Because, in C/C++, 9/2 is 4 and > so negative of it, (-9/2) is -4. Some background on the situation: Integer division and remainder operators have to satisfy two axioms: y * (x/y) + x%y = x and |x%y| < |y| (The former is just the definition of remainder, and the latter is necessary to get Euclid's algorithm to work.) When x and y are both nonnegative it's easy to agree on the right behaviour. When x or y is negative then we get conflicting requirements. On the one hand, you get people who expect that (-x)/y == -(x/y). On the other hand, you get people who expect 0 <= x%y < y if y >= 0. Unfortunately, you can't have both and still satisfy the integer- division axioms. C89 didn't specify which behaviour you got. C99 is in the first camp. Python picked the second (long before C99 came out). Which is right? I don't think that's actually a well-posed question: both have uses. I certainly find myself using the latter behaviour (floor, or round towards -infinity) almost exclusively, but then I'm mainly doing number theory and cryptography, and I find the bounds on the remainder very convenient. Heedful of this mess, Common Lisp provides four (!) different integer division functions (in addition to `/', which does exact rational division on integers): * (floor X Y) -> Q R, where Q is the largest integer such that Q <= X/Y, and R = X - Q Y; R is also available as (mod X Y). * (ceiling X Y) -> Q R, where Q is the smallest integer such that Q >= X/Y, and R = X - Q Y. * (truncate X Y) -> Q R, where Q is the integer with the greatest magnitude such that Q has the same sign as X/Y (or is zero) and |Q| <= |X/Y|; again R = X - Q Y; R is also available as (rem X Y). * (round X Y) -> Q R, where Q is the nearest integer to X/Y (rounding ties towards even numbers), and R = X - Q Y. Gluing all this into Python is tricky, partly because the plethora of options seems somewhat unPythonic (at least to me), and partly because it relies on Common Lisp's behaviour of throwing away unwanted additional return values. > What should I do to get C-like behavior ? I would have said abs(x) / abs(y) * sgn(x) * sgn(y) but Python doesn't seem to have a signum function. :-( I'd recommend thinking carefully about your problem and seeing whether the existing floor-divide behaviour can't be made to fit (or indeed if it's not actually better anyway). If that still doesn't help then you'll have to solve the problem the hard way. def trunc_divmod(x, y): """ Return truncating quotient and remainder for X/Y. Assumes Y > 0. """ q, r = divmod(x, y) if x < 0 and r != 0: r -= y q += 1 return q, r -- [mdw] From spam-trap at telus.net Wed Apr 30 21:23:06 2008 From: spam-trap at telus.net (L. Lindstrom) Date: Thu, 01 May 2008 01:23:06 GMT Subject: Python 2.6 and wrapping C libraries on Windows In-Reply-To: References: Message-ID: <_X8Sj.3499$XI1.3261@edtnps91> Christian Heimes wrote: > L. Lindstrom schrieb: >> I have read that Python extension modules must link to the same C >> run-time as the Python interpreter. This I can appreciate. But does this >> requirement extend to the C libraries an extension module wraps. The >> case in point is Pygame and SDL. The Pygame extension modules are built >> with distutils, so for Python 2.6 using Visual Studio 2008 should ensure >> the .pyd files link to msvcr90.dll. But SDL is built using Msys/MinGW >> and the configure/make tool chain. This fails when linking to >> msvcr90.dll since the small test programs configure builds lack manifest >> files. They fail to load msvcr90.dll, raising an R6034 error instead. So >> besides heap management and FILE pointers, is there any reason SDL, or >> any C dependency, needs to link to the same C run-time as Python? If I >> ensure SDL frees memory it allocates and does not directly access a file >> opened by Python can I just use another C run-time such as msvcrt? >> > > Your analysis of the problem and the implication of mixing CRTs is > correct. However ... > > It should be trivial to modify the build systemof SDL so that the > manifest is integrated into the DLLs. Everything else is a hack. It > *should* work and in reality it *does* work for most cases. But someday > you'll hit a solid wall and get strange and hard to debug segfaults. > > It's in your own interest to get it right in the first place. And you'd > serve the Python community greatly by providing a nice tutorial how to > modify 3rd party builds. *hint* :) > > If you need any help feel free to contact me. The new build system is > mostly my work with help from Martin, Amaury and other core developers. > > Christian > Linking to msvcr90.dll is possible with MinGW. The problem is with the configure scripts. So I can run configure against msvcrt.dll, then switch to mscvr90.dll for make. If this works I will make SDL and a test program available on-line so someone can find the appropriate manifests. -- Lenard Lindstrom "%s@%s.%s" % ('len-l', 'telus', 'net') From aaron.watters at gmail.com Fri Apr 11 15:22:06 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Fri, 11 Apr 2008 12:22:06 -0700 (PDT) Subject: Profiling programs/scripts? References: Message-ID: <54e80efc-39b5-4a2b-9e01-d9b6d70ebaed@a23g2000hsc.googlegroups.com> On Apr 11, 2:49 pm, skanem... at yahoo.se wrote: > how do i profile a program? i found out that there are some profilers > included in the standard library but couldnt really figure out how to > access/use them I put this at the bottom of my main module: === cut if __name__=="__main__": try: from cProfile import run except: from profile import run run("tests()") === cut Here tests() is the function I want to profile. The cProfile module, when available is better than the older profile module, but it's only available in very recent Python installations. The profile "run" function will run the tests function and print a report on the timings and counts it found. More info here: http://docs.python.org/lib/profile.html -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=emulate+perl From bbxx789_05ss at yahoo.com Tue Apr 1 19:25:28 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Tue, 1 Apr 2008 16:25:28 -0700 (PDT) Subject: BeautiflSoup -- getting all the attributes of a tag? Message-ID: You can treat a tag like a dictionary to obtain a specific attribute: import BeautifulSoup as bs html = "
hello
" doc = bs.BeautifulSoup(html) div = doc.find("div") print div print div["x"] --output:-- a But you can't iterate over a tag to get all the attributes: import BeautifulSoup as bs html = "
hello
" doc = bs.BeautifulSoup(html) div = doc.find("div") for key in div: print key, div[key] --output:-- hello Traceback (most recent call last): File "test1.py", line 9, in ? print key, div[key] File "/Library/Frameworks/Python.framework/Versions/2.4/lib/ python2.4/site-packages/BeautifulSoup.py", line 430, in __getitem__ return self._getAttrMap()[key] KeyError: u'hello' How can you get all the attributes when you don't know the attribute names ahead of time? From michael at stroeder.com Fri Apr 25 08:06:36 2008 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Fri, 25 Apr 2008 14:06:36 +0200 Subject: python-ldap - Operations Error In-Reply-To: References: Message-ID: theiviaxx at gmail.com wrote: > Thanks for the help guys, it works! I used the > ldap.set_option(ldap.OPT_REFERRALS, 0) from http://peeved.org/blog/2007/11/20/ Hmm, maybe I should generally switch off referral chasing in python-ldap forcing applications to enable it if needed overriding libldap's default. I did this already for LDAPObject.protocol_version where libldap's default is LDAPv2 and python-ldap sets it to LDAPv3 in LDAPObject.__init__(). Although this was an incompatible change no-one complained. > immedialtey after import, then did the initialize trace_level=2 and > did the simple_bind_s. I was able to search and get the results. > That trace_level thing is nice, i'm sure i will be debugging this more > as i move forward :) > > Not sure if this is an AD thing or just something i needed to do with > our particular server/config. Basically the concept of LDAPv3 referrals is broken since there's no concept for specifying how to bind to the referral's target without a-priori local configuration. See also an old posting to news:microsoft.public.windows.server.active_directory related to this: http://groups.google.com/group/microsoft.public.windows.server.active_directory/msg/d061e0398cc366a5 Ciao, Michael. From matthieu.brucher at gmail.com Thu Apr 10 15:28:56 2008 From: matthieu.brucher at gmail.com (Matthieu Brucher) Date: Thu, 10 Apr 2008 21:28:56 +0200 Subject: Graphs in Python In-Reply-To: <531651.98983.qm@web55601.mail.re4.yahoo.com> References: <531651.98983.qm@web55601.mail.re4.yahoo.com> Message-ID: Hi, Did you try packages dedicated to graphs, like NetworkX ? Matthieu 2008/4/10, Sanhita Mallick : > > Hi. > > I am a newbie to Python. I am trying to implement a > Python code for graph manipulation. My graphs are > about 200-500 nodes big. Excepting for the short basic > graph implementation info on Python.org, where can I > find more in depth info about how to express graphs in > python, and how to use them in a code? > > Also, does anyone know of a easy way of creating the > dictionary for python for a 500-node graph, without > typing each and every node? I found some application > that recognize dot file Graphviz - but I am looking > for a program that can let me "draw" a graph and then > generate the lists automatically from the drawing. > > Thanks. > -SM > > -- > http://mail.python.org/mailman/listinfo/python-list > -- French PhD student Website : http://matthieu-brucher.developpez.com/ Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92 LinkedIn : http://www.linkedin.com/in/matthieubrucher -------------- next part -------------- An HTML attachment was scrubbed... URL: From arnodel at googlemail.com Sun Apr 27 14:52:35 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 27 Apr 2008 19:52:35 +0100 Subject: Mapping and Filtering Help for Lists References: <16925836.post@talk.nabble.com> Message-ID: Zethex writes: > Thank you a lot! > > Another quick couple of questions. > > How can i make it so it removes special operators such as ? ! or doesnt > include them? As you are doing lots of string manipulations, I advise you to read the section of the python documentation on strings (link below). This way you will get a good idea of what can be done out of the box with strings in python. http://docs.python.org/lib/string-methods.html (Or type help(str) from the interactive prompt) For the particular task of removing a character, you may be interested in the replace() method. > and > > I need to lowercase the words so should i use sentence = sentence.lower()? Yes. Or you could combine the two by using the translate() method. E.g. >>> table = ''.join(chr(c).lower() for c in range(256)) >>> 'You! are Free??'.translate(table, '!?') 'you are free' HTH -- Arnaud From brianc at temple.edu Tue Apr 8 21:19:19 2008 From: brianc at temple.edu (Brian Cole) Date: Tue, 8 Apr 2008 19:19:19 -0600 Subject: Python Leopard DLL Hell Message-ID: <54b165660804081819g4787f4d9g821c7269af7b4c66@mail.gmail.com> Hello All, I'm running into a strange problem on Leopard with how Python loads shared libraries. I'll give you a background of what we are trying to accomplish before describing the problem. I am not certain whether this is an OS X problem, or a Python problem, though it appears with the combination of the two. We have swig wrapped C++ code. We used to require our users to set LD_LIBRARY_PATH to the directory containing the dynamic libraries because the swig generated .so needs to dynamically link in another .so. The dependency tree looks like the following: foo.py <--- performs a "from libs import _foo" libs/ <--- LD_LIBRARY_PATH required to point here | _foo.so | bar.so <-- _foo.so depends on me The dependency of bar.so can be taken care of by using $ORIGIN with -rpath (http://linuxreviews.org/man/ld.so/). On Mac OS X this is done by post-processing the shared library with install_name_tool (http://lapcatsoftware.com/blog/2007/08/11/embedding-frameworks-in-loadable-bundles/). Another design goal was to allow for the same directory structure to be NFS mounted in a heterogeneous environment. Then the magic of Python can choose the proper .so to load based upon introspection of the machine architecture and the Python version being used. So the directory structure becomes: foo.py <--- performs a "from libs import GetModule; _foo = GetModule('_foo')" libs/ | __init__.py <--- contains code for GetModule | arch-specific-directory/ | _foo.so | bar.so <-- _foo.so depends on me The GetModule function defined in libs/__init__.py looks like the following: DLLS = os.path.join(os.path.basename(__file__), "arch-specific-directory") <-- determined at runtime based on platform, compiler, and python version def GetModule(name): args = imp.find_module(name, [DLLS]) return imp.load_module(name, *args) This works great on Linux. LD_LIBRARY_PATH can even be set to a directory that contains a different (incompatible) _foo.so and python will force the correct .so to be loaded. However, there is a bug on OS X Leopard (maybe Tiger too, I haven't tested it). On OS X, when DYLD_LIBRARY_PATH (the OS X equivalent of LD_LIBRARY_PATH) is set to a directory that contains an identically named .so file imp.load_module pulls that .so file in. Even though the .so has been specified by an absolute filename. Running a simple test with the -v option of python shows the following: coleb at shark~/debug/wrappers/python$ ls -1 $DYLD_LIBRARY_PATH _foo.so bar.so coleb at shark~/debug/wrappers/python$ python -vc "import openeye.oeshape; from time import sleep; sleep(10)" Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. # foo.pyc matches foo.py import foo # precompiled from foo.pyc import libs # directory libs # libs/__init__.pyc matches libs/__init__.py import libs # precompiled from libs/__init__.pyc dlopen("/Users/coleb/debug/wrappers/python/openeye/libs/osx-10.5-g++4.0-x86+x64-python2.5/_foo.so", 2); <--- This is the correct .so! import _foo # dynamically loaded from /Users/coleb/debug/wrappers/python/openeye/libs/osx-10.5-g++4.0-x86+x64-python2.5/_foo.so That appears to be working correctly at first glance. The argument to dlopen is the correct shared library. Unfortunately, either python or OS X is lying to me here. If I inspect the python process with OS X's Activity Monitor and look at the "Open Files and Ports" tab, it shows that the _foo.so shared library is actually the one located inside $DYLD_LIBRARY_PATH. So this problem may not be python's, but I place it here as a first shot (maybe I'm using the imp module incorrectly). Thanks, Brian From kinch1967 at gmail.com Sun Apr 27 12:35:21 2008 From: kinch1967 at gmail.com (bullockbefriending bard) Date: Sun, 27 Apr 2008 09:35:21 -0700 (PDT) Subject: design choice: multi-threaded / asynchronous wxpython client? References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> <002cd046-f11d-482e-a67d-4a10a97687a1@x19g2000prg.googlegroups.com> Message-ID: <708eaa6d-3893-407e-83ec-4e6104b0a130@q24g2000prf.googlegroups.com> On Apr 27, 11:12?pm, Jorge Godoy wrote: > bullockbefriending bard wrote: > > A further complication is that at a later point, I will want to do > > real-time time series prediction on all this data (viz. predicting > > actual starting prices at post time x minutes in the future). Assuming > > I can quickly (enough) retrieve the relevant last n tote data samples > > from the database in order to do this, then it will indeed be much > > simpler to make things much more DB-centric... as opposed to > > maintaining all this state/history in program data structures and > > updating it in real time. > > If instead of storing XML and YAML you store the data points, you can do > everything from inside the database. > > PostgreSQL supports Python stored procedures / functions and also support > using R in the same way, for manipulating data. ?Then you can work with > everything and just retrieve the resulting information. > > You might try storing the raw data and the XML / YAML, but I believe that > keeping those sync'ed might cause you some extra work. Tempting thought, but one of the problems with this kind of horse racing tote data is that a lot of it is for combinations of runners rather than single runners. Whilst there might be (say) 14 horses in a race, there are 91 quinella price combinations (1-2 through 13-14, i.e. the 2-subsets of range(1, 15)) and 364 trio price combinations. It is not really practical (I suspect) to have database tables with columns for that many combinations? I certainly DO have a horror of having my XML / whatever else formats getting out of sync. I also have to worry about the tote company later changing their XML format. From that viewpoint, there is indeed a lot to be said for storing the tote data as numbers in tables. From Ming.YIN at murex.com Wed Apr 16 06:47:19 2008 From: Ming.YIN at murex.com (YIN Ming) Date: Wed, 16 Apr 2008 18:47:19 +0800 Subject: Compilation problem of Python2.5.1 on AIX5.2 (with --enable-shared option) Message-ID: <9347F3EEF61FC542A7D9211A42CD7E6387DF3F@dolphin.sg.murex.com> Dear All, I encountered a problem when compiling Python2.5.1 as shared library on AIX5.2. Your help are greatly appreciated. In order to embed python into our product, we want to compile python as shared library. It works for Solaris and Linux. Unfortunately, It is for AIX and I could not find solution from Web. Could you help answer the following questions: Is it feasible to compile python2.5.1 as shared library for AIX5.2? or where can I find relevant documentation/info for this? So far, the only documents I have are the README and Misc/AIX-NOTES in the source distribution The step I tried to compile python as shared library is to follow README, section "Building a shared libpython", which suggests to add --enable-shared during configuration. My problem is that with --enable-shared, the make step could not complete (the error message shows it tries to refer to "-lpython2.5" in a wrong directory). Then if I refer it to the correct directory (which is compiled in source root), some warning messages show duplicated symbols. And finally I just remove "-lpython2.5", the make could finish but the resulting python interpreter is a statically-linked binary. (The detail is shown below). The detail of my compilation 1. CC="cc_r" ./configure --prefix=/src/new/python2/install --without-gcc --disable-ipv6 --enable-shared 2. make CC="cc_r" OPT="-O -qmaxmem=4000" An error occurred when compiling python extensions. ... running build running build_ext INFO: Can't locate Tcl/Tk libs and/or headers building '_struct' extension creating build ... cc_r -DNDEBUG -O -I. -I/vega5/prod/src/new/python2/Python-2.5.1/./Include -I./In clude -I. -I/usr/local/include -I/vega5/prod/src/new/python2/Python-2.5.1/Includ e -I/vega5/prod/src/new/python2/Python-2.5.1 -c /vega5/prod/src/new/python2/Pyth on-2.5.1/Modules/_struct.c -o build/temp.aix-5.2-2.5/vega5/prod/src/new/python2/ Python-2.5.1/Modules/_struct.o creating build/lib.aix-5.2-2.5 ./Modules/ld_so_aix cc_r -bI:Modules/python.exp build/temp.aix-5.2-2.5/vega5/pro d/src/new/python2/Python-2.5.1/Modules/_struct.o -L/usr/local/lib -lpython2.5 -o build/lib.aix-5.2-2.5/_struct.so ld: 0706-006 Cannot find or open library file: -l python2.5 ld:open(): No such file or directory *** WARNING: renaming "_struct" since importing it failed: No such file or directory error: No such file or directory make: The error code from the last command is 1. The highlighted command tries to locate the pyhton2.5 lib in /usr/local/lib, which obviously does not contain this lib. A library, libpython2.5.a, has already been compiled in the root build directory. 1) First, I try to add "-L." to the command ./Modules/ld_so_aix cc_r -bI:Modules/python.exp build/temp.aix-5.2-2.5/vega5/prod/src/new/python2/Python-2.5.1/Modules/_ struct.o -L/usr/local/lib -L. -lpython2.5 -o build/lib.aix-5.2-2.5/_struct.so It could find but with a lot of warning messages like: ld: 0711-224 WARNING: Duplicate symbol: PyObject_GenericGetAttr ld: 0711-224 WARNING: Duplicate symbol: .PyObject_GenericGetAttr ld: 0711-224 WARNING: Duplicate symbol: ._Py_ReadyTypes ... 2) Second, I try to remove "-L/usr/local/lib -lpython2.5" from the command ./Modules/ld_so_aix cc_r -bI:Modules/python.exp build/temp.aix-5.2-2.5/vega5/prod/src/new/python2/Python-2.5.1/Modules/_ struct.o -o build/lib.aix-5.2-2.5/_struct.so It complete without any warning message. As a result, I filter out all "-lpython2.5" passed to ./Modules/ld_so_aix for the rest commands. In this way, the python interpreter was generated. However, it is a big executable and "ldd python" does not show it depends on any python shared library (It seems no shared python library generated). It has no difference from the one compiled without --enable-shared. Note that if the configuration is run without --enable-shared option, the corresponding commands will not contain "-lpython2.5". Best regards, Yin Ming -------------------------------------------------------- This e-mail contains information for the intended recipient only. It may contain proprietary material or confidential information. If you are not the intended recipient you are not authorised to distribute, copy or use this e-mail or any attachment to it. Murex cannot guarantee that it is virus free and accepts no responsibility for any loss or damage arising from its use. If you have received this e-mail in error please notify immediately the sender and delete the original email received, any attachments and all copies from your system. -------------- next part -------------- An HTML attachment was scrubbed... URL: From maxm at mxm.dk Thu Apr 3 18:44:56 2008 From: maxm at mxm.dk (Max M) Date: Fri, 04 Apr 2008 00:44:56 +0200 Subject: expanding a variable to a dict In-Reply-To: References: Message-ID: <47F55DE8.7090406@mxm.dk> idle skrev: > now I'd like to check them all for the existence of certain default > keys; ie, if the dicts don't contain the keys, add them in with > default values. > > so, I've got: > > for a in ['dictFoo','dictBar','dictFrotz']: > if hasattr(a,'srcdir') == False: > a['srcdir']='/usr/src' There are a few ways to do it. for a in ['dictFoo','dictBar','dictFrotz']: if not a.has_key('srcdir'): a['srcdir'] = '/usr/src' for a in ['dictFoo','dictBar','dictFrotz']: if not 'srcdir' in a: a['srcdir'] = '/usr/src' for a in ['dictFoo','dictBar','dictFrotz']: a.setdefault('srcdir') = '/usr/src' -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science From sunsp1der at yahoo.com Fri Apr 4 21:47:47 2008 From: sunsp1der at yahoo.com ($P!D3R DelSol) Date: Fri, 4 Apr 2008 18:47:47 -0700 (PDT) Subject: Pickle to Source - Gabriel Genellina? Message-ID: <163089.29394.qm@web65515.mail.ac4.yahoo.com> Hello I found this 3 year old message asking about doing the same exact thing I am trying to do. This is one wheel I REALLY don't want to re-invent. Can anyone point me to code that does this? Thanks Ivan ( sunsp1der at yahoo dot com) > I want to convert from pickle format to python source code. That is, > given an existing pickle, I want to produce a textual representation > which, when evaluated, yields the original object (as if I had > unpickled the pickle). > I know of some transformations pickle/xml (Zope comes with one such > tool, gnosis xml is another) so I believe I could build something based > on them. > But I dont want to reinvent the wheel, I wonder if anyone knows of a > library which could do what I want? An example to make things clear: class MyClass: def __init__(self,a,b): self.a=a self.b=b def foo(self): self.done=1 # construct an instance and work with it obj = MyClass(1,2) obj.foo() # save into file pickle.dump(obj,file('test.dat','wb')) Then, later, another day, using another process, I read the file and want to print a block of python code equivalent to the pickle saved in the file. That is, I want to *generate* a block of code like this: xxx = new.instance(MyClass) xxx.a = 1 xxx.b = 2 xxx.done = 1 Or perhaps: xxx = new.instance(MyClass, {'a':1,'b':2,'done':1}) In other words, I need a *string* which, being sent to eval(), would return the original object state saved in the pickle. As has been pointed, repr() would do that for simple types. But I need a more general solution. The real case is a bit more complicated because there may be references to other objects, involving the persistent_id mechanism of pickles, but I think it should not be too difficult. In this example, if xxx.z points to another external instance for which persistent_id returns '1234', would suffice to output another line like: xxx.z = external_reference('1234') I hope its more clear now. Thanks, Gabriel Genellina Softlab SRL ///\*_*/\\\ NOTICE: Empowered by Presidential Executive Orders, the National Security Agency may read this email without warning, warrant, or notice. The NSA may do this without any judicial or legislative oversight. The President also claims the right to designate the sender or the reader as an enemy combatant and to imprison him/her indefinitely without access to legal counsel or anyone else, and to be "rendered" to a foreign government for possible torture or death. ____________________________________________________________________________________ You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost. http://tc.deals.yahoo.com/tc/blockbuster/text5.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From mdw at distorted.org.uk Tue Apr 22 13:28:56 2008 From: mdw at distorted.org.uk (Mark Wooding) Date: Tue, 22 Apr 2008 17:28:56 +0000 (UTC) Subject: [Python 2.4/2.5] subprocess module is sorely deficient? References: Message-ID: Nick Craig-Wood wrote: > Harishankar wrote: >> 1. Create non-blocking pipes which can be read in a separate thread >> [...] > > You are correct on both of those points. I must be missing something. What's wrong with spawning the subprocess with subprocess.Popen as usual, passing subprocess.PIPE as stdin/stdout/ whatever, making your end nonblocking with fcntl.fcntl and then using os.read/os.write in the obvious ways? -- [mdw] From liveplayboyworld at gmail.com Mon Apr 14 20:16:28 2008 From: liveplayboyworld at gmail.com (liveplayboyworld at gmail.com) Date: Mon, 14 Apr 2008 17:16:28 -0700 (PDT) Subject: the best site about girl & boy. have alook... Message-ID: <2e869a77-80b4-4cf2-80ac-7bee65cab1d7@b9g2000prh.googlegroups.com> http://www.liveplayboyworld.cn From Randy.Galbraith at gmail.com Sun Apr 13 12:57:26 2008 From: Randy.Galbraith at gmail.com (Randy.Galbraith at gmail.com) Date: Sun, 13 Apr 2008 09:57:26 -0700 (PDT) Subject: Compiling Python 2.5.2 on AIX 5.2 Message-ID: <0b73e8e5-c301-4823-ac94-42f757456cf1@x19g2000prg.googlegroups.com> I'm investigating the possible use of Mecurial SCM as a replacement for CVS. Mecurial is written in Python. I have a background in GNU/ Linux, Solaris, sparc and Perl. However AIX, powerpc and Python are new to me. --uname output-- $ uname -rvp 2 5 powerpc --end uname output-- I used this script to compile Python: --script-- export PATH=/usr/bin:/usr/vacpp/bin export CC=xlC_r export OBJECT_MODE=32 gunzip -c Python-2.5.2.tar.gz | tar xvf - cd Python-2.5.2 ./configure --with-gcc="xlc_r" --with-cxx="xlC_r" \ --disable-ipv6 AR="ar" --prefix=$HOME make --end script-- My concern is when I run make test I get this output: --make test output-- 275 tests OK. 2 tests failed: test_mmap test_wait4 45 tests skipped: test_aepack test_al test_applesingle test_bsddb test_bsddb185 test_bsddb3 test_bz2 test_cd test_cl test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_ctypes test_curses test_dl test_gdbm test_gl test_gzip test_imgfile test_largefile test_linuxaudiodev test_macfs test_macostools test_nis test_normalization test_ossaudiodev test_pep277 test_plistlib test_scriptpackages test_socket_ssl test_socketserver test_sqlite test_startfile test_sunaudiodev test_tcl test_timeout test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 test_zipimport test_zlib 2 skips unexpected on aix5: test_largefile test_ctypes make: *** [test] Error 1 --end make test output-- My question are: (a) Have you successfully compiled Python 2.5.2 on AIX 5.2? If so, which options did you place in the environment and send to ./ configure? (b) Given the choice between xlc and gcc 4.2.2 (which we have on the platform) which one is considered more suitable? (c) I am concerned about the two failing test cases: test_mmap and test_wait4. Are there good reasons why these failures can be safely ignored? (d) Should I be concerned with the skips of test_largefile and test_ctypes? Much thanks in advance. Kind regards, -Randy Galbraith From BrianVanderburg2 at aim.com Mon Apr 14 23:46:04 2008 From: BrianVanderburg2 at aim.com (Brian Vanderburg II) Date: Mon, 14 Apr 2008 23:46:04 -0400 Subject: Java or C++? In-Reply-To: References: Message-ID: <480424FC.5040802@aim.com> > My idea, if you really love Python and never think about erasing it > from your mind, go for C (not C++). A script language plus C can solve > every problem you need to solve. Also Python works pretty fine with C. I agree mostly with this one. Scripting is very nice when writing an application especially one that needs to change very often. Plus there are several toolkits and existing libraries available for Python. I've used wxPython some with it, and it came in handy for a few applications that I would have normally written in C++/wxWidgets and have to recompile every few weeks to suit my needs (data extraction tools/etc) However there are cases when a compiled language is better, especially anything that needs to be 'fast' and have a lower overhead. I wouldn't use Python to create a very graphics intensive game or anything, though it can be used with pygame/PyOpenGL for some nice simple stuff. Also everything in Python is an object so it can start to consume memory when handling very large data sets. And since there is no guarantee of when garbage collection occurs, simply 'deleting' an item does not ensure it is completely gone, especially if there are cyclic references, though that can be handled by using 'gc.collect()'. I consider C++ just a simplification of C, in the sense that it makes it easier to do things that would take more work to be done in C. One can still use C++ without all of the more complicated aspects but still take advantages of other aspects. C has the advantage that it does not to anything behind your back. This is very useful especially for any form of system development or where you must know exactly what is going on. It is still possible to do 'object oriented' development in C, it just requires some more typing to set up whatever is needed. Even things like COM for windows can be done in C, it just requires manually building the 'vtable' so to speak. Also, C seems to avoid the use of temporaries where as C++ can use them in conversions and assignments automatically if needed. C++ makes some of it easier by doing certain things for you. Take a string object for example. In C, assignment would only do a memory copy operation: String a, b; b = a; The statement 'b = a' would only copy the memory and pointers from 'b' to 'a' which means they would both point to the same buffer. To avoid this, a copy constructor or assignment operator can be implemented when using C++. The same in C would be something like: String_Assign(&b, &a); /* instead of b = a */ Then if a structure contains objects, more work is needed. For example, in C: typedef struct Name { String honorary; String first; String middle; String last; String lineage; } Name; void Name_Create(Name* name) { String_Create(&name->honorary); String_Create(&name->first); String_Create(&name->middle); String_Create(&name->last); String_Create(&name->lineage); } void Name_Assign(Name* self, Name* other) { String_Assign(&self->honorary, &other->honorary); String_Assign(&self->first, &other->first); String_Assign(&self->middle, &other->middle); String_Assign(&self->last, &other->last); String_Assign(&self->lineage, &other->lineage); } Name p1, p2; Name_Create(&p1); Name_Create(&p2); Name_Assign(&p2, &p1); But in C++, this is no problem: Name p1, p2; p2 = p1; This will automatically call the constructors of any contained objects to initialize the string. The implicit assignment operator automatically performs the assignment of any contained objects. Destruction is also automatic. When 'p1' goes out of scope, during the destructor the destructor for all contained objects is called. And if you want more control you can implement the default and copy constructors, destructor, and assignment operator, and tell them to do what you want. Just beware because the explicit constructors only calls default constructors of any parent classes (even the copy constructor) unless an initializer list is used, and an explicit assignment will not automatically do assignment of parent classes. Neither C nor C++ is really better, it depends on the what needs to be done. C does only what it is told, and also has easier external linkage since there is no name mangling. C++ does a lot of the needed stuff automatically, but explicit constructors and assignment operators can still be declared to control them, and frequently doing the same thing in C++ takes fewer lines of code than in C. As for Java, I think it is 'overly-used' in some areas, especially in embedded development. I attended NC State and during orientation this representative was talking about a small little robotic device and how it had a full Java VM inside it and it only took '6 minutes to boot'. Some claim it is for portability that Java is so good in embedded devices. But still, if the program is moved to another device, it may still need to be changed and recompiled if the new devices has different IO pins, timers, interrupts, etc. Most chips have a C compiler/translator available, and the same program could have been written in C, compiled directly to the machine code needed for the device, 'booted' immediately, and not needed a Java VM as well. If portability to other devices is desired then an abstract layer could be created in the program and the device/hardware specific code could be seperated to that layer seperatly from the rest of the program. Well, all of that is just my opinion though, not meant to offend anyone. From vlastimil.brom at gmail.com Sat Apr 12 14:15:31 2008 From: vlastimil.brom at gmail.com (Vlastimil Brom) Date: Sat, 12 Apr 2008 20:15:31 +0200 Subject: sqlite3 - adding tables and rows via parameters In-Reply-To: References: <9fdb569a0804120839w6916ed96ka5b53aad7ca6f565@mail.gmail.com> Message-ID: <9fdb569a0804121115v43d86c49ieb0f712bd5a49679@mail.gmail.com> 2008/4/12, Steve Holden : > > Vlastimil Brom wrote: > > Hi all, > > I would like to ask about the usage of sqlite3 in python, more > > specifically about a way to pass table > > or column names to a SQL commands using parameters. > > > The thing that will stop you from using a tablename as an argument to a > parameterized query is that (the) front-ends (I am familiar with) don't > allow table names to be parameterized ... > > ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ ======================= Thank you very much for the explanation Steve! I noticed the limitation, but wasn't sure, if if I wasn't missing anything, as I don't have many experiences with databases (now I am actually trying to reimplement, what was previously managed to with nested dictionaries - hence I don't think, something more robust than sqlite is appropriate). But now I am not sure; are there any (security ...) risks of using string interpolation for table and column names in the SQL commands? Or are the values, where parametrization (with ? in sqlite3) is supported, the only vulnerable part; whereas eg. an incorrect value of what should be a name is safe (of course, apart from the unsuccessful command itself)? TIA Vlasta -------------- next part -------------- An HTML attachment was scrubbed... URL: From d3vvnull at gmail.com Tue Apr 15 08:39:21 2008 From: d3vvnull at gmail.com (Michael Mabin) Date: Tue, 15 Apr 2008 07:39:21 -0500 Subject: Java or C++? In-Reply-To: <6660c92c-20d2-48bd-ae46-fee8dfb9f347@e39g2000hsf.googlegroups.com> References: <6660c92c-20d2-48bd-ae46-fee8dfb9f347@e39g2000hsf.googlegroups.com> Message-ID: <170543c70804150539p4fb08181v75ab6fb04b97fb7b@mail.gmail.com> I'm shocked. I've seen no mention of Smalltalk at all. Which should be soo oobvious! ;) I would take an incremental approach. Learn Java first, since it is still OO, offers a rich set of libraries for just about every task but requires a bit more work. C++ requires that you do more work still (build more of your own classes or find more third-party frameworks to do what you need to do), work with the Standard Template Library, distinguish between references and pointers, choose between implementing an OO mechanism (such as IO with iostreams) or traditional (fprintf, printf,etc.). C requires that you shift out of the OO paradigm completely and manage your data and operations separately without the benefit of classes. If you read the Extending Python documentation, you will see how much more work C has to do to make Python possible at all. Michael 2008/4/15 Ivan Illarionov : > On 15 ???, 07:46, Brian Vanderburg II > wrote: > [...] > > C has the advantage that it does not to anything behind your back. This > > is very useful especially for any form of system development or where > > you must know exactly what is going on. It is still possible to do > > 'object oriented' development in C, it just requires some more typing to > > set up whatever is needed. Even things like COM for windows can be done > > in C, it just requires manually building the 'vtable' so to speak. > > Also, C seems to avoid the use of temporaries where as C++ can use them > > in conversions and assignments automatically if needed. > > Great point. It's also possible to do Python object-oriented > programming in C. 'PyMethodDefs' are the same 'vtables'. I've found > that Python/C API is not that hard, the problem is a lack of good > tutorials and false assumptions that ctypes or SWIG are somehow > better. After `#include Python.h` C becomes very Python friendly. > -- > http://mail.python.org/mailman/listinfo/python-list > -- | _ | * | _ | | _ | _ | * | | * | * | * | -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at stroeder.com Wed Apr 23 17:40:37 2008 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Wed, 23 Apr 2008 23:40:37 +0200 Subject: python-ldap: searching without specifying an OU? In-Reply-To: <0bbac44a-5d11-4e27-829d-ad2b2de62210@x35g2000hsb.googlegroups.com> References: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> <58546d42-bc80-4f9d-be90-e184c312e2d1@k37g2000hsf.googlegroups.com> <0ke3e5-ccc.ln1@nb2.stroeder.com> <8ef38281-a6fe-4501-b711-a24cd9f35a24@t54g2000hsg.googlegroups.com> <0bbac44a-5d11-4e27-829d-ad2b2de62210@x35g2000hsb.googlegroups.com> Message-ID: hotani wrote: > This fixed it! > http://peeved.org/blog/2007/11/20/ > > By adding this line after 'import ldap', I was able to search from the > root level: > ldap.set_option(ldap.OPT_REFERRALS, 0) Uumh, yes. I'm always switching off OpenLDAP client lib's internal referral chasing. But be prepared to also handle (at least ignore) the search continuations (LDAP URL) in the search results you will probably receive. These are not regular search entries. Ciao, Michael. From zolotoiklo at mail.ru Tue Apr 29 07:22:29 2008 From: zolotoiklo at mail.ru (=?KOI8-R?B?+s/Mz9TPyiDrzM/O?=) Date: Tue, 29 Apr 2008 04:22:29 -0700 (PDT) Subject: =?KOI8-R?B?8M/R08EgzcHT08HWxdLZINMg1MXSzc8t3MbGxQ==?= =?KOI8-R?B?y9TPzQ==?= Message-ID: <3654a2a9-0fb8-40be-a9d3-6feffdf39f00@w7g2000hsa.googlegroups.com> ??????????? ???? ??? ????????? ?? ??????????????????? ????????? ?????????? ???? ? ?????????? ???????? ??????? ??????? ???????? ? ??????????? ?????????. ??????? ??????????? ??????-????? ???? ? ????? ?????????? ???????????? ??????? ??? ?????????. ?? ??? ????, ????? ??????????? ???? ??????? ??????, ? ??? ????? ?????????? ?????????? ?????????? ?????????, ????? ???? ??????? ??????????? ???? ? ??? ?????, ??? ????? ??????????? ????. ?????-???? ????? ????? ???? ???????? ? ??????? - ??? ????????? ?? ??????? ???. ??????? ?????????? ????????! ??? ???? ???????? ??????????? ???? ? ????????? ??? ???????, ??? ??? ?????????? ???????? ? ??????????? ?????! ????? ????????? ? ?????-???????? http://shopbody.ru/poyas_pohudenia.0.0.html From john00587 at gmail.com Mon Apr 21 01:40:24 2008 From: john00587 at gmail.com (john00587 at gmail.com) Date: Sun, 20 Apr 2008 22:40:24 -0700 (PDT) Subject: cs3 activation crack Message-ID: cs3 activation crack http://cracks.00bp.com F R E E C R A C K S From ivan.illarionov at gmail.com Mon Apr 21 16:50:13 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Mon, 21 Apr 2008 13:50:13 -0700 (PDT) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> Message-ID: <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> On 22 ???, 00:10, Ivan Illarionov wrote: > On 20 ???, 04:10, George Sakkis wrote: > > > > > On Apr 18, 9:36 pm, Ross Ridge > > wrote: > > > > Ross Ridge said: > > > > > If you have Python 2.5, here's a faster version: > > > > > from struct import * > > > > unpack_i32be = Struct(">l").unpack > > > > > def from3Bytes_ross2(s): > > > > return unpack_i32be(s + "\0")[0] >> 8 > > > > Bob Greschke wrote: > > > > > That's not even intelligible. I wanna go back to COBOL. :) > > > > It's the same as the previous version except that it "precompiles" > > > the struct.unpack() format string. It works similar to the way Python > > > handles regular expressions. > > > I didn't know about the Struct class; pretty neat. It's amazing that > > this version without Psyco is as fast Bob's version with Psyco! Adding > > Psyco to it though makes it *slower*, not faster. So here's how I'd > > write it (if I wanted or had to stay in pure Python): > > > try: import psyco > > except ImportError: > > from struct import Struct > > unpack_i32be = Struct(">l").unpack > > def from3Bytes(s): > > return unpack_i32be(s + "\0")[0] >> 8 > > else: > > def from3Bytes(s): > > Value = (ord(s[0])<<16) + (ord(s[1])<<8) + ord(s[2]) > > if Value >= 0x800000: > > Value -= 0x1000000 > > return Value > > psyco.bind(from3Bytes) > > > HTH, > > George > > I was able to get even faster pure-python version using array module: > > a = array.array('l', ''.join(('\0' + s[i:i+3] for i in xrange(0, > len(s), 3)))) > if sys.byteorder == 'little': > a.byteswap() > > It actually moves bytes around on C level. > > test code: > import struct > import array > import sys > > unpack_i32be = struct.Struct(">l").unpack > s = ''.join(struct.pack('>i', 1234567)[1:]*1000) > > def from3bytes_ord(s): > values = [] > for i in xrange(0, len(s), 3): > Value = (ord(s[i])<<16) | (ord(s[i+1])<<8) | ord(s[i+2]) > if Value >= 0x800000: > Value -= 0x1000000 > values.append(Value) > return values > > def from3bytes_struct(s): > return [unpack_i32be(s[i:i+3] + "\0")[0] >> 8 for i in xrange(0, > len(s), 3)] > > def from3bytes_array(s): > a = array.array('l', ''.join(('\0' + s[i:i+3] for i in xrange(0, > len(s), 3)))) > if sys.byteorder == 'little': > a.byteswap() > return a.tolist() > > from timeit import Timer > > t1 = Timer("from3bytes_ord(s)", "from __main__ import s, > from3bytes_ord") > t2 = Timer("from3bytes_struct(s)", "from __main__ import s, > from3bytes_struct") > t3 = Timer("from3bytes_array(s)", "from __main__ import s, > from3bytes_array") > > print 'ord:\t', t1.timeit(1000) > print 'struct:\t', t2.timeit(1000) > print 'array:\t', t3.timeit(1000) > > Output: > ord: 7.08213110884 > struct: 3.7689164405 > array: 2.62995268952 > > Inspired by Guido's essayhttp://www.python.org/doc/essays/list2str/ And even faster: a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, len(s), 3)))) if sys.byteorder == 'little': a.byteswap() I think it's a fastest possible implementation in pure python From bearophileHUGS at lycos.com Thu Apr 3 09:18:04 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Thu, 3 Apr 2008 06:18:04 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> <0c7fd327-7b96-4c20-8c74-a528e280b5f3@r9g2000prd.googlegroups.com> Message-ID: Dennis Benzinger: > You could use the Aho-Corasick algorithm Aho-Corasick_algorithm>. > I don't know if there's a Python implementation yet. http://hkn.eecs.berkeley.edu/~dyoo/python/ahocorasick/ Bye, bearophile From hniksic at xemacs.org Thu Apr 17 11:46:53 2008 From: hniksic at xemacs.org (Hrvoje Niksic) Date: Thu, 17 Apr 2008 17:46:53 +0200 Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> Message-ID: <87tzi05vrm.fsf@mulj.homelinux.net> sturlamolden writes: > If I use my main interpreter to delegate a task to one of its > embedded 'children', its GIL will be released while it is waiting > for the answer. Associating each embedded interpreter with a > threading.Thread is all that remains. The GIL is released while the > thread operating the child interpreter is blocked. Have you tackled the communication problem? The way I see it, one interpreter cannot "see" objects created in the other because they have separate pools of ... everything. They can communicate by passing serialized objects through ctypes, but that sounds like the solutions that use processes. From bressert at gmail.com Wed Apr 16 10:37:03 2008 From: bressert at gmail.com (eli) Date: Wed, 16 Apr 2008 07:37:03 -0700 (PDT) Subject: subplot function in matplotlib References: <368ac3ca-ed20-494d-9f09-00d06701857d@k37g2000hsf.googlegroups.com> <66m9luF2lchhkU2@mid.uni-berlin.de> Message-ID: <59281036-3160-4a2d-a391-e668bebaf822@k13g2000hse.googlegroups.com> On Apr 16, 8:27?am, "Diez B. Roggisch" wrote: > eli wrote: > > Does anyone know a workaround to plotting beyond 9 subplots in > > matplotlib? It would be nice to have 20 plots under the subplot > > function for example (poster). > > Is there such a limitation? I thought that was only for the condensed > sublpot-specification-form (where you give e.g. 133 instead of 1,3,3) > > Diez Didn't see that part. Now it's fixed. Thanks! Eli From frambooz at gmail.com Thu Apr 10 19:19:13 2008 From: frambooz at gmail.com (frambooz at gmail.com) Date: Thu, 10 Apr 2008 16:19:13 -0700 (PDT) Subject: Adding classes to modules at runtime from outside that module Message-ID: Hey guys, In Python, is it possible to add classes to a module at run-time? Say I have a module foo and a module bar. Foo has class A and B, and bar has class C. I want to add class C to foo so I can access it as foo.C, but i want to do it without modifying foo's source. Is this at all possible? Thanks much. ` Rogier van Etten From pylists at arcor.de Mon Apr 14 03:08:06 2008 From: pylists at arcor.de (Penny Y.) Date: Mon, 14 Apr 2008 15:08:06 +0800 Subject: =?gb2312?B?tPC4tDogaG93IHRvIHJlbW92ZSBcbiBpbiB0aGUgbGlzdA==?= In-Reply-To: Message-ID: <20080414070819.D4CA335E6A5@mail-in-06.arcor-online.net> > lines[:] = [line.rstrip('\n') for line in lines] why not just: lines = [line.rstrip('\n') for line in lines] what's the difference between lines[:] and lines here? Thanks. -----????----- ???: python-list-bounces+pylists=arcor.de at python.org [mailto:python-list-bounces+pylists=arcor.de at python.org] ?? Gabriel Genellina ????: 2008?4?14? 12:59 ???: python-list at python.org ??: Re: how to remove \n in the list En Mon, 14 Apr 2008 01:41:55 -0300, reetesh nigam escribi?: > hi, > l=['5\n', '2\n', '7\n', '3\n', '6\n'] > > how to remove \n from the given list l is is very poor name... I'll use lines instead: lines[:] = [line.rstrip('\n') for line in lines] -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list From grante at visi.com Thu Apr 17 11:55:58 2008 From: grante at visi.com (Grant Edwards) Date: Thu, 17 Apr 2008 10:55:58 -0500 Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> Message-ID: <1uqdncgQj4iT7prVnZ2dnUVZ_sKqnZ2d@visi> On 2008-04-17, Gary Herron wrote: >> For example, let's say I want to assign a bunch of variables to an >> initial, single value. In C or a similar language you would do: >> >> CONSTANT1 = >> /* This is some constant */ >> CONSTANT2 = >> CONSTANT3 = >> >> /*This is yet some other constant */ >> CONSTANT = >> >> 1; > > > Yuck! No way!! If you *want* to make your code that hard to > read, I'm sure you can find lots of ways to do so, even in > Python, but don't expect Python to change to help you toward > such a dubious goal. > > Seriously, examine your motivations for wanting such a syntax. > Does it make the code more readable? (Absolutely not.) Does > it make it more maintainable. (Certainly not -- consider it > you needed to change CONSTANT2 to a different value some time > in the future.) You move the initialization of CONSTANT2 out of that construct and set it to whatever you want. Consider the case where you have this: constant1 = constant2 = constant3 = constant4 = constant5 = constant6 = What happens when the initial value needs to change? You have to change it in six places instead of in one place as you would if you did this: constant1 = \ constant2 = \ constant3 = \ constant4 = \ constant5 = \ constant6 = Having the same information be duplicated N times is bad. In C, the above construct can be used to solve that problem efficiently. In Python the right thing to do is probably this: initialValue = constant1 = initialValue constant2 = initialValue constant3 = initialValue constant4 = initialValue constant5 = initialValue constant6 = initialValue >> I find this limitation very annoying. If you continue to try to write C code in a Python program, you're going to continue to be annoyed. Start writing Python code when working on Python programs and writing C code when working on C programs. I write a lot of both and have no problem switching back and forth other than an occasional extraneous ";" in my python code. Using an editor with good C and Python modes helps. -- Grant Edwards grante Yow! ... I want to perform at cranial activities with visi.com Tuesday Weld!! From hobgoodoreneyhb at gmail.com Tue Apr 22 11:38:14 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:38:14 -0700 (PDT) Subject: joy ringtone crack Message-ID: <8431e708-5714-4741-a66a-475c1216f178@y21g2000hsf.googlegroups.com> joy ringtone crack http://cracks.12w.net F R E E C R A C K S From damonwischik at gmail.com Fri Apr 18 20:56:12 2008 From: damonwischik at gmail.com (damonwischik at gmail.com) Date: Fri, 18 Apr 2008 17:56:12 -0700 (PDT) Subject: How to print a unicode string? References: <4809394A.1030906@v.loewis.de> Message-ID: On Apr 19, 1:14 am, "Martin v. L?wis" wrote: > > From what I've googled, I think I need to set my locale. > > Not on this operating system. On Windows, you need to change > your console. If it is a cmd.exe-style console, use chcp. > For IDLE, changing the output encoding is not supported. > > If you want to output into a file, use codecs.open. > > If you absolutely want to output UTF-8 to the terminal even > though the terminal will not be able to render it correctly, > use > > sys.stdout = codecs.getwriter("UTF-8")(sys.stdout) Thank you for the suggestion. As I said, I am running Python through Emacs 22.2.1, so I doubt it is a cmd.exe-style console, and it most certainly is not IDLE. I want to output to the Emacs buffer, via the python-mode plugin for Emacs, not to a file. I tried your suggestion of setting sys.stdout, and it works perfectly. As I said, the output is going to Emacs, and Emacs _does_ know how to render UTF-8. How can I make this a global setting? Is it possible to change an environment variable, so that Python uses this coding automatically? Or pass a command-line argument when Emacs python-mode invokes the Python interpreter? Or execute this line of Python in a startup script which is invoked whenever a new Python session is started? Thank you again for your help, Damon. From arnodel at googlemail.com Sun Apr 20 15:27:54 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 20 Apr 2008 12:27:54 -0700 (PDT) Subject: What happened with python? messed strings? References: Message-ID: On Apr 20, 7:54?pm, wrote: [...] > python should have stayed at version 1.5, every single 'improvement' > has been a mess. But this is the definitive hell. You can still download Python 1.5.2 from python.org: http://www.python.org/download/releases/1.5/ HTH -- Arnaud From john106henry at hotmail.com Tue Apr 29 18:23:35 2008 From: john106henry at hotmail.com (John Henry) Date: Tue, 29 Apr 2008 15:23:35 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> <473deef3-9acb-45dd-a7ca-47b0081bd28c@i36g2000prf.googlegroups.com> <3f7bb91e-335e-46bd-88ca-f15b26c35132@k1g2000prb.googlegroups.com> <827bdae6-4422-4226-a543-af53f5b7e01b@s33g2000pri.googlegroups.com> <083b58e8-522a-4c01-b612-c592fe69fcd1@i36g2000prf.googlegroups.com> <2978ec5b-fd7c-4fb1-9aa5-4bb88ba46ee8@m73g2000hsh.googlegroups.com> Message-ID: <2a9d9002-85c6-4834-9747-479d16e92009@1g2000prg.googlegroups.com> On Apr 29, 1:16 pm, Panyasan wrote: > On 29 Apr., 20:30, Panyasan wrote: > > > On 29 Apr., 18:17, John Henry wrote: > > > > There are a whole bunch of test programs that comes with Pythoncard. > > > Do they work? (Not all of them will work - some requires a database) > > > Yes, the examples work. Just the resourceEditor.py and the > > layoutEditor.py in the distributed version and your modified > > layoutEditor.py don't. > > Ok, here is how it works for me: copy all the *.rsrc.py from the > modules subdirectory to the parent directory. This works for the > standard resourceEditor folder and your custom layoutEditor folder. > What the heck. Now I can deal with more productive things... Mmmmmm...this is a Mac thing. From lib_team at yahoo.fr Tue Apr 22 05:06:15 2008 From: lib_team at yahoo.fr (=?iso-8859-1?Q?Pr=E9mon_Nom?=) Date: Tue, 22 Apr 2008 09:06:15 +0000 (GMT) Subject: Embeded python memory leaks Message-ID: <351783.77724.qm@web25908.mail.ukl.yahoo.com> An HTML attachment was scrubbed... URL: From mobile at ibinsa.com Tue Apr 15 16:49:42 2008 From: mobile at ibinsa.com (Gabriel Ibanez) Date: Tue, 15 Apr 2008 22:49:42 +0200 Subject: Java or C++? References: <525142.84411.qm@web39208.mail.mud.yahoo.com> <48050D14.6040801@gmail.com> Message-ID: <018b01c89f3a$3b854b50$0a01a8c0@mobile> Hi all, I've never programmed Java. I started directly in C, then C++ and now using Python, mainly because its modules, because I found very hard to use and find external libraries to do the same as Python (i.e. to read an URL o send an email), and soften these libraries on C are not free or depending on an specific compiler (aka VC version x). The lack in Python is only speed, and I don't know what you better get from Java, and may be I loss all those usefull libraries. There's also a said "Student of many, teacher of nothing" From goldtech at worldpost.com Thu Apr 24 08:11:44 2008 From: goldtech at worldpost.com (goldtech) Date: Thu, 24 Apr 2008 05:11:44 -0700 (PDT) Subject: Tkinter scrollbar and checkbox Message-ID: <9581b4cd-36f1-47dc-ae6e-0ca58f1b38e0@27g2000hsf.googlegroups.com> Hi, I'm stumped on how to have a scrollbar with a long list of checkboxes. Given code like: from Tkinter import * root = Tk() states = [] for i in range(150): var = IntVar() chk = Checkbutton(root, text=str(i), variable=var) chk.grid(sticky=W) states.append(var) root.mainloop() print map((lambda var: var.get()), states) I've tried adding this to a frame then adding the frame to a canvas and it gets complicated rather quickly... Is there a simple way to add a scroll bar? Thanks From castironpi at gmail.com Wed Apr 2 11:32:57 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 2 Apr 2008 08:32:57 -0700 (PDT) Subject: Self-referencing decorator function parameters References: <88b2c61e-8cf1-4ac0-a5d4-c968d009b544@c65g2000hsa.googlegroups.com> Message-ID: On Apr 2, 7:30?am, Thomas Dimson wrote: > Hello, > > Originally I posted this as a bug but it was shot down pretty quickly. > I am still mildly curious about this as I'm missing a bit of > understanding of Python here. Why is it that the following code > snippet: > > def decorator( call ): > ? ? def inner(func): > ? ? ? ? def application( *args, **kwargs ): > ? ? ? ? ? ? call(*args,**kwargs) > ? ? ? ? ? ? func(*args,**kwargs) > ? ? ? ? return application > > ? ? return inner > > class DecorateMe: > ? ? @decorator( call=DecorateMe.callMe ) > ? ? def youBet( self ): > ? ? ? ? pass > > ? ? def callMe( self ): > ? ? ? ? print "Hello!" > > DecorateMe().youBet() > > Will not compile, giving: > Traceback (most recent call last): > ? File "badpython.py", line 10, in > ? ? class DecorateMe: > ? File "badpython.py", line 11, in DecorateMe > ? ? @decorator( call=DecorateMe.callMe ) > NameError: name 'DecorateMe' is not defined > > Where if you change the "call=DecorateMe.callMe" to "call=lambda x: > DecorateMe.callMe(x)" everything goes along its merry way. Nesting the > call in a lambda seems to allow it to recognize the class definition. > Any ideas as to what is going on here (other than ugly code)? def decorator( call ): def inner(func): def application( *args, **kwargs ): call(*args,**kwargs) func(*args,**kwargs) return application return inner class DecorateMe: def callMe( self ): print( "Hello!" ) @decorator( call=callMe ) def youBet( self ): pass DecorateMe().youBet() From martin at v.loewis.de Sun Apr 27 21:18:22 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Mon, 28 Apr 2008 03:18:22 +0200 Subject: py3k concerns. An example In-Reply-To: References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> <48118719$0$25846$9b622d9e@news.freenet.de> Message-ID: <481525DE.9060208@v.loewis.de> > This would save me personally a great deal of > painful tedium, I suspect (especially considering > that I've implemented a lot of "dictionary-like" > objects -- so I'll have to change the way their > "keys" method works -- or something -- I haven't > figured it out yet...). [...] > In C# and java, for example, this sort of issue > has never been a problem > in my experience: stuff I wrote many versions ago > still works just fine with no changes (but please > note that I don't write gui stuff, which is less > stable -- I'm speaking of algorithmic and system > libraries). I don't see the connection. Why do you think your .keys() implementation breaks just because dict.keys has a different semantics now? An existing application of an existing dict-like object will continue to work just fine in Python 3, right? I can't find the change to dictionaries outrageous. Regards, Martin From martin.laloux at gmail.com Wed Apr 16 07:38:42 2008 From: martin.laloux at gmail.com (martin.laloux at gmail.com) Date: Wed, 16 Apr 2008 04:38:42 -0700 (PDT) Subject: Python crashes consistently References: Message-ID: which python ? from macports or macpython ? From gagsl-py2 at yahoo.com.ar Wed Apr 23 01:10:02 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 23 Apr 2008 02:10:02 -0300 Subject: Explicit variable declaration References: <1be78d220804221739h77d8a4eak28deb5ce52dbe623@mail.gmail.com> Message-ID: En Tue, 22 Apr 2008 21:39:41 -0300, Filip Gruszczy?ski escribi?: > Hello everyone! > > It is my first message on this list, therefore I would like to say > hello to everyone. I am fourth year student of CS on the Univeristy of > Warsaw and recently I have become very interested in dynamically typed > languages, especially Python. Welcome to Python! > I would like to ask, whether there is any way of explicitly declaring > variables used in a function? While I am pretty sure, that there is no > such way in the language itself, I would like to know, whether there > are any third-party tools to do that. This would be very useful for me > during development, so I am looking for such a tool. Not part of the language itself, but there are some tools to do static code analysis, like PyLint and PyChecker; see http://wiki.python.org/moin/static_source_analysis -- Gabriel Genellina From jason.scheirer at gmail.com Tue Apr 8 23:13:46 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Tue, 8 Apr 2008 20:13:46 -0700 (PDT) Subject: Google App Engine References: <47fc2c7c$0$36365$742ec2ed@news.sonic.net> Message-ID: <7e43fcd9-6207-4af2-8256-c0099a8ce0bb@1g2000prf.googlegroups.com> On Apr 8, 7:50 pm, John Nagle wrote: > Duncan Booth wrote: > > Google have announced a new service called 'Google App Engine' which may > > be of interest to some of the people here > > OK, now we need a compatibility layer so you can move apps from > Google App Engine to your own servers. You don't want to be locked > into a single vendor solution, especially when they reserve the right > to start charging. > > Their data store uses a subset of SQL, so it's probably possible > to write a conversion layer allowing use of MySQL. > > John Nagle It supports Django, and more importantly, WSGI, so any 'framework' you build on top of it should transfer out. Heck, you have a stand-alone python script that comes with the developer kit for hosting your apps on YOUR computer that you could port to use YOUR database and be done with it. Write your own ORM or just some decent OO code for handling data access so the database access layer can be swapped out and you are golden. I really doubt getting away from the Googe App Engine is going to be too terribly difficult for any intermediate Python programmer, assuming good up-front application design. From umpsumps at gmail.com Sat Apr 26 19:50:57 2008 From: umpsumps at gmail.com (umpsumps at gmail.com) Date: Sat, 26 Apr 2008 16:50:57 -0700 (PDT) Subject: learning with python question (HtTLaPP) References: <98acecbd-9de2-4ebf-927b-ac6bc1fbc3fd@b5g2000pri.googlegroups.com> <53d6254f-895f-48fb-8ab9-3929c403f11b@v23g2000pro.googlegroups.com> Message-ID: ok.. I finally made something that works.. Please let me know what you think: >>> def lines(letters): fin = open('words.txt') count = 0 rescount = 0 # count the number of results results = "" # there are words that contain the letters for line in fin: needs = 0 x = str(line.strip()) for ch in letters: if ch not in x: pass else: needs = needs + 1 if needs == len(letters): rescount += 1 results = results + '\n' + x count += 1 print count, 'lines searched' print results, '\n' print 'result count is: ', rescount On Apr 26, 4:02?pm, "Eric Wertman" wrote: > > ?Is the way I wrote the function inherently wrong? ?What I wrote > > I would not say that. ?I think a lot of people probably start off like > that with python. ?You'll find in most cases that manually keeping > counters isn't necessary. ?If you really want to learn python though, > I would suggest using built in functions and libraries as much as > possible, as that's where the real power comes from (IMO). > > > ?returns the sequence, however I'm trying to make the output match for > > ?the letters in the string entered, not necessarily the string > > ?sequence. > > ?Only the sequence shows up 'uzi'. ?I don't get words like 'unzip' or > > ?'Zurich' . ?I've only barely started on invocation and maybe writing > > ?something like I'm describing is above what level I'm currently at. > > This would be a more difficult approach.. ? Where you are doing the > comparison step: > > if letters in line.strip(): > > It's trying to match the exact string "uzi", not any of the individual > letters. ?You would need to look for each letter independently and > then make sure they were in the right order to match the other words. From noname9968 at gmail.com Sat Apr 5 02:14:11 2008 From: noname9968 at gmail.com (Alex9968) Date: Sat, 05 Apr 2008 10:14:11 +0400 Subject: *.py source file surprisingly deleted with Pydev/Eclipse. Who else experienced this ? In-Reply-To: References: <47F67798.3060401@gmail.com> Message-ID: <47F718B3.9020504@gmail.com> Gabriel Genellina wrote: > En Fri, 04 Apr 2008 15:46:48 -0300, Alex9968 > escribi?: > >> Nebur wrote: >> > > >>> No, I can't reproduce it, and I don't know whom to blame (Pydev? >>> Eclipse ? The File System ? A Virus that only 2 times in half a year >>> deletes a single file I'm busy working with, and seems to do nothing >>> else? Myself beeing schizophrenic ??) >>> > > >> A virus created to remind you 2 times in half a year of the importance >> of backup operations ;-) . I'm joking. I don't know what is this, but >> I'm interested. Because my files won't be restorable from version >> control :-( >> > > Then implement it! It's not so difficult, less if you're the only one > working on the files. Implement what? The virus? I haven't said that I'm interested in virus, I meant I'd like to know WHAT is this From cemasoniv at gmail.com Fri Apr 4 12:08:17 2008 From: cemasoniv at gmail.com (Charles Mason) Date: Fri, 4 Apr 2008 12:08:17 -0400 Subject: Is there an official way to add methods to an instance? In-Reply-To: <47f645e6$0$36354$742ec2ed@news.sonic.net> References: <7xve2yas87.fsf@ruckus.brouhaha.com> <47f61041$0$27969$426a34cc@news.free.fr> <47f645e6$0$36354$742ec2ed@news.sonic.net> Message-ID: <3290753a0804040908j66c5fdb1kc78a7045a2d4573c@mail.gmail.com> And for such a behavior they've termed "monkeying" Thus, the coinage "Monkeypatching" for what you want to do: http://mail.python.org/pipermail/python-dev/2008-January/076194.html There are a group of people who think "monkeypatching is destroying ruby." You still probably should avoid it for production code. On Fri, Apr 4, 2008 at 11:25 AM, John Nagle wrote: > Bruno Desthuilliers wrote: > > Paul Rubin a ?crit : > >> Brian Vanderburg II writes: > >>> I've checked out some ways to get this to work. I want to be able to > >>> add a new function to an instance of an object. > >> > >> Ugh. Avoid that if you can. > > > > Why so ? OO is about objects, not classes, and adding methods on a > > per-object basis is perfectly legitimate. > > It's what professional programmers call a "l33t feature", > one not suitable for production code. Typically such features > are used by programmers with about two years experience, > trying too hard to prove that they're cool. > > John Nagle > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mobile at ibinsa.com Tue Apr 8 18:46:43 2008 From: mobile at ibinsa.com (Gabriel Ibanez) Date: Wed, 9 Apr 2008 00:46:43 +0200 Subject: Converting a tuple to a list References: <00ba01c899c5$14528ae0$0a01a8c0@mobile> Message-ID: <00e601c899ca$6b3be4f0$0a01a8c0@mobile> Gabriel Ibanez wrote: > Hi all .. > > I'm trying to using the map function to convert a tuple to a list, without > success. > > I would like to have a lonely line that performs the same as loop of the > next script: > > ------------------------------------------- > # Conveting tuple -> list > > tupla = ((1,2), (3,4), (5,6)) > > print tupla > > lista = [] > for a in tupla: > for b in a: > lista.append(b) > print lista > ------------------------------------------- > > Any idea ? > > Thanks ... > > # Gabriel > list(tupla) would probably do it. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list That would just make a list of tuples, I think he wants [1, 2, 3, 4, 5, 6]. Try: l = [x for z in t for x in z] --Brian --------------- Thanks Steve and Brian, Brian: that is !! However, it's a bit difficult to understand now. I have read it several times :) From see_website at mindprod.com.invalid Wed Apr 23 00:07:31 2008 From: see_website at mindprod.com.invalid (Roedy Green) Date: Wed, 23 Apr 2008 04:07:31 GMT Subject: pop langs website ranking References: <41fbaf27-a80b-402b-b406-c048a65a8643@b64g2000hsa.googlegroups.com> Message-ID: On Tue, 22 Apr 2008 14:41:33 -0700 (PDT), "xahlee at gmail.com" wrote, quoted or indirectly quoted someone who said : > alexa I was shocked at the detailed information Alexa (owned by Amzon.com)_ had about my website. I wrote them and asked how they got it. They said volunteers use a special browsing tool that reports website visits. They use that to generate the information. I suppose then one way to bump your stats is to use the tool for maintaining your own website. The weakness of this approach is it is unusual group of people who will voluntarily submit to having their usage spied on. These are not a typical group or a large group. Google has AdSense that will let them know in huge detail the hit stats on a huge hunk of the web, but I don't know if they publish that information anywhere. -- Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com From deets at nospam.web.de Mon Apr 28 03:36:50 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Mon, 28 Apr 2008 09:36:50 +0200 Subject: class or class-instance ? In-Reply-To: References: Message-ID: <67ld5cF2jm4mjU1@mid.uni-berlin.de> Stef Mientki schrieb: > hello, > > I've a procedure (or in fact a class method) that should be callable with > either a class > (in which case the procedure should create an instance) > or with an instance of that class > as the parameter. > > def somefunction ( self, parameter ) : > if parameter is a class, create an instance of that class > else do nothing > > > > now I should be able to call the above procedure in either of the > following ways: > > somefunction ( someclass ) > > or > > somefunction ( someclass () ) There is a isclass in the module inspect. Diez From tjreedy at udel.edu Tue Apr 1 13:34:26 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 1 Apr 2008 13:34:26 -0400 Subject: Homework help References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> Message-ID: wrote in message news:06dd172b-e789-409b-b4e9-364ed935205f at i29g2000prf.googlegroups.com... | Hey guys | I haev this homework assignment due today | I don't necessarily want the answers, but need help on how to approach | it/the steps i need to solve the problems | Thanks Read the section of the tutorial (and possibly Launguage Reference) on writing for statements and functions. Then read the sections of the Library Reference on builtin types and specifically sequences and more specifically lists. tjr From michele.simionato at gmail.com Sat Apr 5 12:55:48 2008 From: michele.simionato at gmail.com (Michele Simionato) Date: Sat, 5 Apr 2008 09:55:48 -0700 (PDT) Subject: ANN: pry unit testing framework References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <47c75b08-2493-4f96-9dbc-4d87e278939c@f63g2000hsf.googlegroups.com> <74c4c6e6-d8fc-44c0-89a8-9eb8d85d376f@t54g2000hsg.googlegroups.com> <20080405141329.GD15684@nullcube.com> Message-ID: On Apr 5, 5:05 pm, Steve Holden wrote: > Kay at least has a long history as a contributor in this group, so > people know how to interpret her remarks and know that her contributions > are made on the basis of a deep understanding of Python. She is I am pretty much sure you are making a gender mistake with Kay Schluehr here ;) For the rest, I do fully agree with your remarks. Kay +1, Aldo -1! Michele Simionato From rjh at see.sig.invalid Mon Apr 14 03:35:09 2008 From: rjh at see.sig.invalid (Richard Heathfield) Date: Mon, 14 Apr 2008 07:35:09 +0000 Subject: Game design : Making computer play References: Message-ID: v4vijayakumar said: > In computer based, two player, board games, how to make computer play? Write some code that works out what the computer player should do. If you want a better answer, ask a better question. > Are there any formal ways to _teach_ computer, to choose best possible > move? That's a better question. The obvious ways are DFS, BFS, and databases. For example, take backgammon, and computer goes first. You roll the PRNGs and get 6, 1. You (the computer) have never played this game before, so you don't have a database of good moves. Your legal moves are: 24,18 and 24,23 24,18 and 8,7 24,18 and 6,5 13,7 and 24,23 13,7 and 8,7 13,7 and 6,5 Of these, which is the best? DFS (Depth-First Search) and BFS (Breadth-First Search) can help you answer that question. What you do is define an evaluation function for the position, based on things like how many blots, how many on the bar, whether you have a prime, and so on. Then you *play the game* in simulation, as deeply as you can (which won't be very deep, actually), evaluating all the time. Once you've found the position that does you most good (or least harm) no matter what die-rolls the opponent may get and no matter how skilfully he or she plays, you know what to get your computer player to do next. If you're clever, you'll keep the solution tree around, destroying only the bits of it that won't ever be used again - to save processing time on your next turn. If you're really clever, you'll write a lot of this information down in a file, a sort of opening "book", so that you don't have to calculate everything from scratch every time. For example, in the above situation, there is no need to calculate, because it's a no-brainer: 13,7 and 8,7 is far and away the best move. > I know this is kind of off-topic here. Please redirect me, if there > are more appropriate newsgroup. comp.programming is probably where you want to be, at least to start off with. -- Richard Heathfield Email: -http://www. +rjh@ Google users: "Usenet is a strange place" - dmr 29 July 1999 From bignose+hates-spam at benfinney.id.au Mon Apr 7 01:53:30 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Mon, 07 Apr 2008 15:53:30 +1000 Subject: Adherence to PEP 8 for published code (was: ANN: pry unit testing framework) References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> <20080405082605.GA14042@nullcube.com> <20080405105459.GB15154@nullcube.com> <87prt2mq8l.fsf@benfinney.id.au> Message-ID: <87d4p2mcrp.fsf_-_@benfinney.id.au> Aldo Cortesi writes: > Thus spake Ben Finney (bignose+hates-spam at benfinney.id.au): > > > > I'm afraid that Pry is unashamedly incompatible with any other unit > > > testing method in existence, including but not limited to doctest, > > > unittest, nose and py.test. ;) I didn't write this. Please preserve attribution lines correctly so we can keep track of who wrote what. > > Which makes the deliberate deviations from PEP 8 naming a large > > black mark against it. > > You're misunderstanding the intent of PEP 8, which was never > supposed to dogmatically enforce a naming standard on all Python > projects everywhere. You're placing words in my mouth, and erecting a straw man, as I never made that assertion. PEP 8 only has the force that people grant it. Nevertheless, it's a style guide that's widely accepted in the Python community, and adhering to it in one's code makes it easier to read for the majority, because it reduces the needless inconsistencies between different bodies of code. Conversely, deliberately diverging from the widely-accepted style guide increases the cognitive load on the reader; if that divergence is not done for a very good reason, one is imposing needless burden on every reader of the code. > You're also vastly overstating the impact of a minor naming > convention choice. Calling this a "large black mark" smacks of > scare-mongering to me. When distributing code with the expectation that others use it, it's a large black mark if it deliberately shun the widely-accepted, easily-followed coding standards, for the above reasons. I don't see why that would be scary. If you find it so, you have my sympathy. -- \ "I went to a general store. They wouldn't let me buy anything | `\ specifically." -- Steven Wright | _o__) | Ben Finney From n00m at narod.ru Sat Apr 26 11:10:09 2008 From: n00m at narod.ru (n00m) Date: Sat, 26 Apr 2008 08:10:09 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) Message-ID: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> Both codes below read the same huge(~35MB) text file. In the file > 1000000 lines, the length of each line < 99 chars. Stable result: Python runs ~0.65s C : ~0.70s Any thoughts? import time t=time.time() f=open('D:\\some.txt','r') z=f.readlines() f.close() print len(z) print time.time()-t m=input() print z[m] #include #include #include #include using namespace std; char vs[1002000][99]; FILE *fp=fopen("D:\\some.txt","r"); int main() { int i=0; while (true) { if (!fgets(vs[i],999,fp)) break; ++i; } fclose(fp); cout << i << endl; cout << clock()/CLOCKS_PER_SEC << endl; int m; cin >> m; cout << vs[m]; system("pause"); return 0; } From bvidinli at gmail.com Sat Apr 26 15:36:36 2008 From: bvidinli at gmail.com (bvidinli) Date: Sat, 26 Apr 2008 22:36:36 +0300 Subject: python and web programming, easy way...? Message-ID: <36e8a7020804261236j46c4ef62pf0fb7178d765774a@mail.gmail.com> Hi, i use currently python for console programming. in past, i tried it for web programming, to use it instead of php. Unfortunately, i failed in my attempt to switch to python. Currently, i make many webbased programs and a "Easy Hosting Control Panel " (www.ehcp.net) that runs on php, ehcp is a hosting control panel in beta stage.. in fact, i use python, love it and want to switch to it in my all projects, including webbased programs and ehcp. Can your recomment me the easiest, most usable way to use python in web programming.. in past, in my first attemt... i was able to run python as as apache cgi, runned it basicly, but i had many difficulties especially in sessions, cookies... maybe currently there is a solution, but i dont know. Please provide me the quickest/most appropriate solution for web programming in python. i will try to switch to python in ehcp too.. Currently my web programs are simple Object Oriented programs, that basicly uses a few files, in php. i use sessions in use authentications. i currently use php because it is fairly easy to install/run on apache.. you just put it on server, it runs.. i look something like this for python. because python programming is much better than php. Thank you a lot. -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From martin at v.loewis.de Mon Apr 28 18:34:11 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 29 Apr 2008 00:34:11 +0200 Subject: Simple unicode-safe version of str(exception)? In-Reply-To: <67moqeF2paokjU1@mid.individual.net> References: <67moqeF2paokjU1@mid.individual.net> Message-ID: <481650E3.4060603@v.loewis.de> >> I have code like this: >> except Exception, e: >> self.setState(self.Failed, str(e)) >> which fails if the exception contains a unicode argument. > > Fails how? ASCII encoding error, I suppose. It fails only if a) one argument is a Unicode object, and b) that Unicode object contains non-ASCII parameters. >> I did, of course, try unicode(e) but that fails. > > Converting unicode to unicode doesn't help. e is an exception object, not a Unicode object. Regards, Martin From lists at cheimes.de Tue Apr 22 16:45:20 2008 From: lists at cheimes.de (Christian Heimes) Date: Tue, 22 Apr 2008 22:45:20 +0200 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: <200804221622.57424.v.harishankar@gmail.com> References: <200804221622.57424.v.harishankar@gmail.com> Message-ID: <480E4E60.30803@cheimes.de> Harishankar schrieb: > 2. Kill the subprocess in a platform independent manner (i.e. no third party > modules and no hacks). I've added the feature to the Popen class a few days ago. The new methods are kill(), terminate() and send_signal(sig). On Windows all methods just fall back to _subprocess.TerminateProcess. On POSIX OS os.kill() is used. The code also works on Python 2.4 and 2.5 but I can't add new features to maintainence branches. Christian From onbuscol at gmail.com Sun Apr 13 08:06:45 2008 From: onbuscol at gmail.com (Unlimited Free Domain & Web Hosting) Date: Sun, 13 Apr 2008 05:06:45 -0700 (PDT) Subject: How to Choose an Unlimited Web Hosting for free Message-ID: <02d391b5-f72f-4f99-8f40-dbc304aa22fe@q24g2000prf.googlegroups.com> How to Choose an Unlimited Web Hosting 1) Visit www.axealis.com to get domain and hosting 2) Unlimited Bandwidth ,this mean unlimited data transmission for your client access. 2) Unlimited Space , you can upload file for unlimited . 3) Unlimited Email , many of email account can created . 5) SSL Security , used SSL / HTTPS to protect your web . 6) LINUX , WINDOWS and MAC , can access form many operating system. From martin at v.loewis.de Mon Apr 7 16:50:51 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Mon, 07 Apr 2008 22:50:51 +0200 Subject: Data structure recommendation? In-Reply-To: References: Message-ID: <47FA892B.1050608@v.loewis.de> > I know that foo.get() will be called many times for each foo.put(). Is > there any way to achieve O(1) performance for foo.get(), maybe via > some kind of hash function? Or is the best thing to use some kind of > binary search? If you know something about the density of the input values, O(1) is possible. E.g if there is a guarantee that there will be between 1 and 10 values per unit of input, then truncate the "event time" to the next-lower int, and use that as an index k into a list; the list item will be a list of events between k and k+1. As you know that there is an upper bound to the number of such events (10), you know that searching the list will take bounded (i.e. constant) time. Likewise, as you know that there will be atleast one event per (k,k+1) interval, you know that you have to scan only one list. If you know no such thing, you'll have to use a binary search. Regards, Martin From fredrik at pythonware.com Sat Apr 5 09:34:19 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 15:34:19 +0200 Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! In-Reply-To: <47f77d0a$0$17945$5fc30a8@news.tiscali.it> References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <47f77d0a$0$17945$5fc30a8@news.tiscali.it> Message-ID: Francesco Bochicchio wrote: > It should be added here that in Python you have several ways get around > this Tkinter limitation and pass an user argument to the callback. Once > upon a time , back in Python 1.x, I used to do something like this: > > class CallIt: > def __init__(self, f, *args): > self.f = f > self.args = args > def __call__(self): > return apply(self.f, self.args) > > and then, to do what the OP wanted to do: > command = CallIt(self.Display, 1) > > but nowadays, you can achieve the same effect with: > command = functtools.partial(self.Display,1) or, much clearer for non-guru programmers, and a lot easier to extend when you realize that you have to do more than just calling a single method, use a local callback function: def do_display(): self.Display(1) w = Button(callback=do_display) local functions are cheap in Python; creating a new one for each button is very inexpensive. for very simple callbacks, you can use the lambda syntax as well: w = Button(callback=lambda: self.Display(1)) From lists at cheimes.de Tue Apr 22 17:15:44 2008 From: lists at cheimes.de (Christian Heimes) Date: Tue, 22 Apr 2008 23:15:44 +0200 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: <480e5367$0$17314$9b622d9e@news.freenet.de> References: <480e5367$0$17314$9b622d9e@news.freenet.de> Message-ID: <480E5580.4090302@cheimes.de> Martin v. L?wis schrieb: >> 2. Kill the subprocess in a platform independent manner (i.e. no third party >> modules and no hacks). > > What's wrong with the .terminate method of the Popen object? It's brand new ;) Christian From tjreedy at udel.edu Wed Apr 2 15:22:24 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 2 Apr 2008 15:22:24 -0400 Subject: Understanding bmp image files References: <2537c458-b4d5-480d-8407-168a2b59a27e@u10g2000prn.googlegroups.com> Message-ID: "pranav" wrote in message news:2537c458-b4d5-480d-8407-168a2b59a27e at u10g2000prn.googlegroups.com... | Hello, | I want to read a BMP file, do some processing and then write it in a | new file. The problem is in the third step. For reading the file, i | have converted the file into decimal numbers, representing the pixel | values. Then i perform calculations on those decimal numbers. Now i am | unable to convert those into the format as required by the "bmp" file. | Any one, who is into image reading/manipulation, please help. I would look into PIL, PyGame, and Numeric/Numpy. From arnodel at googlemail.com Tue Apr 15 07:14:00 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Tue, 15 Apr 2008 04:14:00 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> Message-ID: On 11 Apr, 21:29, Gabriel Genellina wrote: > ... If the numbers to be rounded come from a > measurement, the left column is not just a number but the representant > of an interval (as Mikael said, the're quantized). 2.3 means that the > measurement was closer to 2.3 than to 2.2 or 2.4 - that is, [2.25, > 2.35) (it doesn't really matter which side is open or closed). It is > this "interval" behavior that forces the "round-to-even-on-halves" > rule. > So, the numbers 1.6-2.4 on the left column cover the interval [1.55, > 2.45) and there is no doubt that they should be rounded to 2.0 because > all of them are closer to 2.0 than to any other integer. Similarly > [2.55, 3.45) are all rounded to 3. > But what to do with [2.45, 2.55), the interval represented by 2.5? We > can assume a uniform distribution here even if the whole distribution > is not (because we're talking of the smallest measurable range). So > half of the time the "true value" would have been < 2.5, and we should > round to 2. And half of the time it's > 2.5 and we should round to 3. > Rounding always to 3 introduces a certain bias in the process. > Rounding randomly (tossing a coin, by example) would be fair, but > people usually prefer more deterministic approaches. If the number of > intervals is not so small, the "round even" rule provides a way to > choose from that two possibilities with equal probability. > So when we round 2.5 we are actually rounding an interval which could > be equally be rounded to 2 or to 3, and the same for 3.5, 4.5 etc. If > the number of such intervals is big, choosing the even number helps to > make as many rounds up as rounds down. > If the number of such intervals is small, *any* apriori rule will > introduce a bias. Great explanation! -- Arnaud From gagsl-py2 at yahoo.com.ar Tue Apr 1 23:42:55 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 02 Apr 2008 00:42:55 -0300 Subject: generator functions: why won't this work? References: Message-ID: En Tue, 01 Apr 2008 23:56:50 -0300, escribi?: > I'm trying to understand generator functions and the yield keyword. > I'd like to understand why the following code isn't supposed to work. > (What I would have expected it to do is, for a variable number of > arguments composed of numbers, tuples of numbers, tuples of tuples, > etc., the function would give me the next number "in sequence") > #################################### > def getNextScalar(*args): > for arg in args: > if ( isinstance(arg, tuple)): > getNextScalar(arg) > else: > yield arg > #################################### You're not the first one in getting confused. After all, this schema works well for other recursive constructs. Perhaps a progression of working code samples will help to understand what happens here. The simplest thing would be to just print the items as they're encountered, in a recursive call: py> data = (1, 2, (3,4,(5,6),7)) py> py> print "1) using print" 1) using print py> py> def getNextScalar(args): ... for arg in args: ... if isinstance(arg, tuple): ... getNextScalar(arg) ... else: ... print arg ... py> getNextScalar(data) 1 2 3 4 5 6 7 Now one could try to collect the numbers in a list: py> print "2) using extend" 2) using extend py> py> def getNextScalar(args): ... result = [] ... for arg in args: ... if isinstance(arg, tuple): ... result.extend(getNextScalar(arg)) ... else: ... result.append(arg) ... return result ... py> getNextScalar(data) [1, 2, 3, 4, 5, 6, 7] Note that we use two different list methods: for individual items, we use "append", but for tuples we use "extend" in the recursive call. If extend weren't available, we could emulate it with append: py> print "3) using append" 3) using append py> py> def getNextScalar(args): ... result = [] ... for arg in args: ... if isinstance(arg, tuple): ... for item in getNextScalar(arg): ... result.append(item) ... else: ... result.append(arg) ... return result ... py> getNextScalar(data) [1, 2, 3, 4, 5, 6, 7] See how we need an additional loop to iterate over the results that we get from the recursive call. Now instead of building an intermediate result list, we delegate such task over the caller, and we use a generator that just yields items; this way, we remove all references to the result list and all result.append calls become yield statements. The inner loop has to remain the same. The yield statement acts somewhat as an "append" over an outer list created by the generator's caller. py> print "4) using yield" 4) using yield py> py> def getNextScalar(args): ... for arg in args: ... if isinstance(arg, tuple): ... for item in getNextScalar(arg): ... yield item ... else: ... yield arg ... py> getNextScalar(data) py> list(getNextScalar(data)) [1, 2, 3, 4, 5, 6, 7] I hope it's more clear now why you have to use yield on the recursive call too. Perhaps this: yield *iterable could be used as a shortcut for this: for __temp in iterable: yield __temp -- Gabriel Genellina From ellingt8877 at gmail.com Mon Apr 28 01:51:09 2008 From: ellingt8877 at gmail.com (ellingt8877 at gmail.com) Date: Sun, 27 Apr 2008 22:51:09 -0700 (PDT) Subject: crack drug Message-ID: <649bde32-5ed1-4655-94a1-6607b245ff33@1g2000prg.googlegroups.com> crack drug http://crack.cracksofts.com From gagsl-py2 at yahoo.com.ar Mon Apr 14 22:06:47 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 14 Apr 2008 23:06:47 -0300 Subject: Dynamic use of property() fails References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> Message-ID: En Mon, 14 Apr 2008 22:43:39 -0300, andrew cooke escribi?: > This is my first attempt at new classes and dynamic python, so I am > probably doing something very stupid... After reading the how-to for > descriptors at http://users.rcn.com/python/download/Descriptor.htm I > decided I would make an object that returns attributes on read, but on > setting calls an arbitrary function. > > My code looks like: > class ActiveDAO(object): > def __init__(self): > self.__values__ = {} > def add_field(self, name, value, on_change): > self.__values__[name] = value > def get(self): return self.__values__[name] > def set(self, new_value): self.__values__[name] = > on_change(new_value) > def delete(self): raise AttributeError > self.__dict__[name] = property(get, set, delete) > > However, when I try to use this (in a test) with code like: > dao = ActiveDAO() > dao.add_field("name", "value", lambda _: None) > assertEqual(dao.name, "value") > > I get a failure because lookup of the attribute is returning > "". > > That is quite reasonable, but I was under the expression that some > magic was supposed to happen, as described in the document referenced > above! The "magic" happens when the descriptor is found in the *class*, not in the instance. I think it's detailed in Hettinger's document. Do you actually want "per-instance" defined properties? __special__ names are reserved for Python internal usage; don't use them. Implementation-only attributes ("private" ones) are spelled with a single underscore. -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Tue Apr 1 13:05:09 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 14:05:09 -0300 Subject: class super method References: <1c9f126b-63f6-402b-803d-39ce1df4c380@i12g2000prf.googlegroups.com> <0eb3ee4e-82e2-419a-8e7b-4931f7b4effa@c26g2000prf.googlegroups.com> Message-ID: En Tue, 01 Apr 2008 11:21:48 -0300, Ed Leafe escribi?: > On Apr 1, 2008, at 8:43 AM, George Sakkis wrote: > >> Pehaps, at least as long as you make sure that all superclasses have a >> compatible signature - which in practice typically means accept >> arbitrary *args and **kwargs in every class in the hierarchy like your >> example. Good luck figuring out what's wrong if it's not used >> consistently. > > See my comment above. If you do not know what you're doing, you > shouldn't be doing it. This is not the fault of super(); it's the > fault of a poor programmer. And I used generic *args and **kwargs in > the method sig since I was using made-up class names and methods. > Would you have reacted more favorably if I had used (self, foo, bar) > instead? Then *all* classes must use exactly the same signature for that method. You don't know which one will be the next class in the MRO order used by super() so you can't adjust the arguments in any way. In the case of __init__, the only practical way is to make all of them take keyword arguments exclusively and use *args and **kwarsg. See the earlier links for a simple failing example. >> Also doOurCustomStuffBeforeTheSuperCall() works as long as all >> ancestor methods to be called need the same CustomStuff massaging. > > Oh, c'mon. Of course that's the case; if you are overriding method > behavior, it is your job as the programmer to ensure that. Again, this > is nothing to do with the super() function, and everything to do with > the abilities of the developer. How do you know that? super may call a method on a different class that is *not* an ancestor of the current class. Again, for examples, see the earlier links. >> In a sentence, it's better than nothing but worse than anything. > I guess I must be the world's most amazing Python developer, as I've > used super() extensively for years without ever suffering any of the > pitfalls you and others describe. Maybe you're a very lucky man! -- Gabriel Genellina From roy at panix.com Sun Apr 27 22:55:54 2008 From: roy at panix.com (Roy Smith) Date: Sun, 27 Apr 2008 22:55:54 -0400 Subject: Regular Expression - Matching Multiples of 3 Characters exactly. References: Message-ID: In article , blaine wrote: > Hey everyone, > For the regular expression gurus... > > I'm trying to write a string matching algorithm for genomic > sequences. I strongly suggest you stop trying to reinvent the wheel and read up on the Biopython project (http://biopython.org/wiki/Main_Page). From gherron at islandtraining.com Thu Apr 24 11:16:06 2008 From: gherron at islandtraining.com (Gary Herron) Date: Thu, 24 Apr 2008 08:16:06 -0700 Subject: [Python-Dev] annoying dictionary problem, non-existing keys In-Reply-To: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> Message-ID: <4810A436.2060705@islandtraining.com> bvidinli wrote: > i use dictionaries to hold some config data, > such as: > > conf={'key1':'value1','key2':'value2'} > and so on... > > when i try to process conf, i have to code every time like: > if conf.has_key('key1'): > if conf['key1']<>'': > other commands.... > > > this is very annoying. > in php, i was able to code only like: > if conf['key1']=='someth' > > in python, this fails, because, if key1 does not exists, it raises an exception. > > MY question: > is there a way to directly get value of an array/tuple/dict item by key, > as in php above, even if key may not exist, i should not check if key exist, > i should only use it, if it does not exist, it may return only empty, > just as in php.... > > i hope you understand my question... > > See http://docs.python.org/lib/typesmapping.html for a description of the get method of dictionaries. Also look at the key in dict syntax on the same page. Gary Herron From iddw at hotmail.com Tue Apr 1 12:42:30 2008 From: iddw at hotmail.com (Dave Hansen) Date: Tue, 1 Apr 2008 09:42:30 -0700 (PDT) Subject: Homework help References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> <7xfxu5ft1s.fsf@ruckus.brouhaha.com> <8e1f6963-1cdd-4afe-9ea5-f1886ed452ab@d21g2000prf.googlegroups.com> Message-ID: On Apr 1, 11:29 am, bobby.con... at gmail.com wrote: > On Apr 1, 12:17 pm, Paul Rubin wrote: > > > bobby.con... at gmail.com writes: > > > I don't necessarily want the answers, but need help on how to approach > > > it/the steps i need to solve the problems > > > What parts are you having difficulty with? Are there some course > > materials and have you read them yet? > > I just don't know how to start the problems off Well, for the first problem, the first line is def howMany(item,lst): If you can't figure out where to go from there, start here: http://docs.python.org/tut/tut.html Regards, -=Dave From dotancohen at gmail.com Thu Apr 17 20:46:04 2008 From: dotancohen at gmail.com (Dotan Cohen) Date: Fri, 18 Apr 2008 03:46:04 +0300 Subject: Python for Series 40 Nokia? Message-ID: <880dece00804171746t61017950wdd3571d7671867d1@mail.gmail.com> I had once heard something about python running on a Series 40 Nokia, but I am unable to google anything concrete. Might it have been Jython? Is there a known implementation of Python for the series 40 (which is not Symbian, by the way)? Will Jython work in such an environment? Thanks in advance. Dotan Cohen http://what-is-what.com http://gibberish.co.il ?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-?-? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? From Bryan.Fodness at gmail.com Thu Apr 10 13:22:44 2008 From: Bryan.Fodness at gmail.com (Bryan.Fodness at gmail.com) Date: Thu, 10 Apr 2008 10:22:44 -0700 (PDT) Subject: get array element Message-ID: <820d8589-8529-46af-907a-90ebaac4a6f5@a22g2000hsc.googlegroups.com> I have an array, and I would like to get the indice value. a = array([13,14,15,16]) I would like something like a.getindice(15) If I want 15 it would return 2 From gagsl-py2 at yahoo.com.ar Sat Apr 5 20:20:57 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 05 Apr 2008 21:20:57 -0300 Subject: Tkinter, add pressed buttons onto string display string, how to? References: <57605958-5589-4ebe-abdf-73c2d14c8a82@u10g2000prn.googlegroups.com> <65q8juF2gq610U2@mid.uni-berlin.de> <649d9748-c389-411d-9794-9753ddf434b0@d1g2000pra.googlegroups.com> Message-ID: En Sat, 05 Apr 2008 18:23:50 -0300, escribi?: >> Just like the message says: You are trying to use `str` (on the right >> hand >> side of the assignment) before anything is bound to that name. >> > > i know but i want the variable str(which i found out is a reserved > word so i changed it) to be accessible all over __init__ right? > so i tried to delcare it in __init__ in the beginning of the framework > class but then when i access it in the method Display i get that > error. > > so how should i declare this variable to be able to access it > everywhere? It should be an instance attribute: self.expr by example. Remember to initialize it with '' in __init__ > i want another method "calculate" that can access the same string > later and do the calculations(writing some other code now that will > read and interpret that). Ok, use self.expr in calculate. Something like this: def calculate(self): self.expr = str(eval(self.expr)) and probably force a repaint of the calculator display. You may want to use a try/except block to catch any errors. -- Gabriel Genellina From ewertman at gmail.com Sun Apr 20 14:37:12 2008 From: ewertman at gmail.com (Eric Wertman) Date: Sun, 20 Apr 2008 11:37:12 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> Message-ID: <614c8e94-3b1d-47e0-9051-dd05fe722183@l42g2000hsc.googlegroups.com> On Apr 20, 1:29 pm, "Gabriel Genellina" wrote: > En Sun, 20 Apr 2008 13:42:05 -0300, Matthew Woodcraft escribi?: > > > An alternative scheme for describing the block structure could be > > useful in other cases, though. For example, if you wanted to support > > putting snippets of Python in configuration files, or spreadsheet > > cells. > > [...] If someone wrote a library for this and it proved popular, I expect it > > would be considered for the standard library. > > There is "pindent.py" in the Tools/scripts directory: > > # ... When called as "pindent -r" it assumes its input is a > # Python program with block-closing comments but with its indentation > # messed up, and outputs a properly indented version. > > # A "block-closing comment" is a comment of the form '# end ' > # where is the keyword that opened the block ... > > def foobar(a, b): > if a == b: > a = a+1 > elif a < b: > b = b-1 > if b > a: a = a-1 > # end if > else: > print 'oops!' > # end if > # end def foobar > > -- > Gabriel Genellina That's actually not a lot different than what you have to do now in a web page.. It still seems overcomplicated though. I'm not sure why this is worse: def foobar(a, b): if a == b: a = a+1; elif a < b: b = b-1; if b > a: a = a-1; else: print 'oops!';; It's just ultimately whitespace insensitive. Whether that's a good or bad design is a debate that can be argued either way, but other languages do it, and it's handy sometimes. I agree that it makes it much easier to produce illegible code. Developing for a browser is arguably annoying and hackish enough, without having to stick in comments and such to enforce indenting. From marco at sferacarta.com Thu Apr 17 05:49:44 2008 From: marco at sferacarta.com (Marco Mariani) Date: Thu, 17 Apr 2008 11:49:44 +0200 Subject: I just killed GIL!!! In-Reply-To: <87hce1t8k5.fsf@physik.rwth-aachen.de> References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <52vid5-cvl2.ln1@ozzie.tundraware.com> <87hce1t8k5.fsf@physik.rwth-aachen.de> Message-ID: Torsten Bronger wrote: >>> If I were you I would keep it a secret until a Hollywood producer >>> offers big bucks for the film rights. >> Who would play Guido, I wonder? > > Ralf M?ller. No other. And the GIL killer? Clive Owen, Matt Damon, Mark Wahlberg? From steve at holdenweb.com Sat Apr 12 17:45:26 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 17:45:26 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> Message-ID: <48012D76.2070703@holdenweb.com> One last thing: I am sorry that despite my efforts I was unable to teach you what you need to learn. I can only hope someone else manages to get the point across. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gagsl-py2 at yahoo.com.ar Mon Apr 7 10:26:23 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 07 Apr 2008 11:26:23 -0300 Subject: Calling CVF-Fortran-dll with ctypes and simple structure References: <60915c2d-0c0d-42fc-8b02-5fb58e13a20c@p25g2000hsf.googlegroups.com> Message-ID: En Mon, 07 Apr 2008 09:19:03 -0300, Michael Sch?fer escribi?: > Hi all, > > I deal with the old problem passing characters from python to a > fortran dll build with CFV6.6c. > I reduced our complex structure to a simple one. Here is the Fortran > code: > > SUBROUTINE DEMO2L(s) > > C sample for calling CVF6.6c-DLLs from > C vb/vba/python with simple structure > > !DEC$ ATTRIBUTES DLLEXPORT::DEMO2L > > TYPE rcDEMO > INTEGER a > REAL b > CHARACTER c*9 > END TYPE > > TYPE(rcDEMO) :: s > C > WRITE(*,*) s.a, s.b, s.c > C sample calculation: > s.a = s.a*10 > s.b = s.b**2.3 > s.c = 'Sample' > > RETURN > END > > From VB the calling is very simple: > > Declare Sub DEMO2L Lib "release\demo1l.dll" (ByRef k As rcDEMO) > > Type rcDEMO > a As Long > b As Single > c As String * 9 > End Type > > Dim k As rcDEMO > > Sub run() > > k.a = 2 > k.b = 3# > k.c = "Test" > > Call DEMO2L(k) > > Debug.Print k.a, k.b, k.c > > End Sub > > and result to: " 20 12,5135 Sample" > > When I try this from python: > > from ctypes import * > > class rcDemo(Structure): > _fields_ = [ > ('a', c_int), > ('b', c_float), > ('c', c_char_p), Try with ('c', c_char*9). You may have alignment issues with such odd size, but in this case it doesnt matter so much as it's the last field in the struct. (If both Fortran and VB say "char*9", why did you choose a pointer here?) -- Gabriel Genellina From fetchinson at googlemail.com Sun Apr 20 17:06:57 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Sun, 20 Apr 2008 14:06:57 -0700 Subject: cherrypy-webapp-code? In-Reply-To: <31715060-fca3-4a03-b5c4-b6403315aa76@a23g2000hsc.googlegroups.com> References: <31715060-fca3-4a03-b5c4-b6403315aa76@a23g2000hsc.googlegroups.com> Message-ID: > anyone have a small cherrypy-webapp and are willing to post the code. > could be a nonsense-app just wanna see some code. > -- > http://mail.python.org/mailman/listinfo/python-list > Did you try google? And the cherrypy website? -------------- next part -------------- An HTML attachment was scrubbed... URL: From itskrithika at gmail.com Fri Apr 25 19:22:37 2008 From: itskrithika at gmail.com (terry) Date: Fri, 25 Apr 2008 16:22:37 -0700 (PDT) Subject: Pyserial - send and receive characters through linux serial port Message-ID: Hi, I am trying to send a character to '/dev/ttyS0' and expect the same character and upon receipt I want to send another character. I tired with Pyserial but in vain. Test Set up: 1. Send '%' to serial port and make sure it reached the serial port. 2. Once confirmed, send another character. I tried with write and read methods in Pyserial but no luck. Can you help? Thanking you all. T From jwashin at vt.edu Fri Apr 25 08:46:53 2008 From: jwashin at vt.edu (Jim Washington) Date: Fri, 25 Apr 2008 08:46:53 -0400 Subject: convert xhtml back to html In-Reply-To: <48117759.4090909@behnel.de> References: <4810E5CC.2000503@behnel.de> <48117759.4090909@behnel.de> Message-ID: <4811D2BD.1060208@vt.edu> Stefan Behnel wrote: > bryan rasmussen top-posted: > >> On Thu, Apr 24, 2008 at 9:55 PM, Stefan Behnel wrote: >> >>> from lxml import etree >>> >>> tree = etree.parse("thefile.xhtml") >>> tree.write("thefile.html", method="html") >>> >>> http://codespeak.net/lxml >>> >> wow, that's pretty nice there. >> >> Just to know: what's the performance like on XML instances of 1 GB? >> > > That's a pretty big file, although you didn't mention what kind of XML > language you want to handle and what you want to do with it. > > lxml is pretty conservative in terms of memory: > > http://blog.ianbicking.org/2008/03/30/python-html-parser-performance/ > > But the exact numbers depend on your data. lxml holds the XML tree in memory, > which is a lot bigger than the serialised data. So, for example, if you have > 2GB of RAM and want to parse a serialised 1GB XML file full of little > one-element integers into an in-memory tree, get prepared for lunch. With a > lot of long text string content instead, it might still fit. > > However, lxml also has a couple of step-by-step and stream parsing APIs: > > http://codespeak.net/lxml/parsing.html#the-target-parser-interface > http://codespeak.net/lxml/parsing.html#the-feed-parser-interface > http://codespeak.net/lxml/parsing.html#iterparse-and-iterwalk > If you are operating with huge XML files (say, larger than available RAM) repeatedly, an XML database may also be a good option. My current favorite in this realm is Sedna (free, Apache 2.0 license). Among other features, it has facilities for indexing within documents and collections (faster queries) and transactional sub-document updates (safely modify parts of a document without rewriting the entire document). I have been working on a python interface to it recently (zif.sedna, in pypi). Regarding RAM consumption, a Sedna database uses approximately 100 MB of RAM by default, and that does not change much, no matter how much (or how little) data is actually stored. For a quick idea of Sedna's capabilities, the Sedna folks have put up an on-line demo serving and xquerying an extract from Wikipedia (in the range of 20 GB of data) using a Sedna server, at http://wikidb.dyndns.org/ . Along with the on-line demo, they provide instructions for deploying the technology locally. - Jim Washington From yves at zioup.com Tue Apr 15 19:26:16 2008 From: yves at zioup.com (Yves Dorfsman) Date: Tue, 15 Apr 2008 23:26:16 GMT Subject: how to remove \n in the list In-Reply-To: References: <2ba667ab-6818-47eb-8595-79ed970728f7@q1g2000prf.googlegroups.com> Message-ID: Dan Bishop wrote: >>> lines[:] = [line.rstrip('\n') for line in lines] >> What is the point of the [:] after lines ? How different is it with or >> without it ? > > It causes the result to be stored in the existing list. > If we do: lines = [line.rstrip('\n') for line in lines] lines is now a new list, the old list as no reference to it, and will be discarded by the gc, right ? So we're not really saving any space here ? If we do: lines[:] = [line.rstrip('\n') for line in lines] We reuse an existing list, therefore we are saving the time it takes to create a new list ? So this is a performance issue ? Thanks. Yves. http://www.SollerS.ca From gagsl-py2 at yahoo.com.ar Mon Apr 21 22:01:44 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 23:01:44 -0300 Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: En Mon, 21 Apr 2008 16:42:41 -0300, Ross Ridge escribi?: >> Ideally, I can implement some form of cross-compatible code >> so that I need maintain only a single code base, and I have managed to >> do so on a number of fronts (with the help of Robert A. Clark): Perhaps you can manage to keep your code compatible with all versions, but AFAIK the reccomended strategy is to write code compatible with Python 2.6 and use the 2to3 tool to generate the 3.0 source. And *not* edit the 3.0 code unless one wants to maintain two branches. >> Overall, I think I'm getting off pretty easy, but then pyparsing is a >> small module with very limited use of the standard lib. > > Has the standard library changed that much? I thought was it mainly the > deletion of old seldom used modules that happens in new releases anyways. *and* renaming of old module names that don't follow PEP8, and merging others into packages for better structure. That's another point where using the 2to3 tool is necesary -it takes care of such changes- unless one wants to maintain two branches. -- Gabriel Genellina From phil at riverbankcomputing.com Thu Apr 3 17:37:41 2008 From: phil at riverbankcomputing.com (Phil Thompson) Date: Thu, 3 Apr 2008 22:37:41 +0100 Subject: State of ctypes Support on HP-UX? In-Reply-To: References: <200804031153.26234.phil@riverbankcomputing.com> <200804031429.19025.phil@riverbankcomputing.com> Message-ID: <200804032237.41757.phil@riverbankcomputing.com> On Thursday 03 April 2008, Thomas Heller wrote: > Phil Thompson schrieb: > > On Thursday 03 April 2008, Thomas Heller wrote: > >> Phil Thompson schrieb: > >> > Could somebody confirm how well ctypes is supported on HP-UX (for both > >> > PA-RISC and Itanium) for both Python v2.4 and v2.5? > >> > >> I cannot answer your question, but if you want to try it out > >> yourself there is the HP testdrive program: http://www.testdrive.hp.com/ > > > > Thanks for the pointer. Unfortunately the answer is that there is no > > support (at least for ctypes v1.0.2). > > I tried out the current SVN version of Python myself. ctypes doesn't > compile on the PA system (the libffi assembler code fails to compile), but > I did get it to work on the Itanium system with gcc (I had to set > LDSHARED="gcc -shared" before configuring). Even the ctypes unittests pass > on this system. > > In theory, the ctypes code should be backwards-compatible with python 2.4, > although in practice it currently is not, but IMO it should be possible to > change it accordingly. > > Would this be useful to you? Thanks, but no. A combination of ctypes for Windows and the dl module for everything else will probably meet my needs. Phil From alexelder at gmail.com Wed Apr 23 15:13:40 2008 From: alexelder at gmail.com (alexelder at gmail.com) Date: Wed, 23 Apr 2008 12:13:40 -0700 (PDT) Subject: Calling Python code from inside php References: <679e9oF2mti63U1@mid.uni-berlin.de> Message-ID: <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> On Apr 23, 7:42 pm, "Diez B. Roggisch" wrote: > vijay schrieb: > > > Hi > > I have a python code performing some computation for me.I have a > > html page which passes certain argumnets to a php page.This php page > > needs to pass on the value to the Python class and get the result > > back. > > How do I go about this?? > > Write a commandline-app in python, that does the work for you. Invoke > that using php. > > Or use something like pyphp - but I haven't used it, can't comment on > its usability/support etc. > > Diez A simple yet dangerous and rather rubbish solution (possibly more of a hack than a real implementation) could be achieved by using a technique described above: I would look into pyphp though. This method has so many issues attached to it it's hardly worth bothering with. I'm with Nick when I say why on earth are you needing to call Python from within PHP as opposed to using only Python or only PHP? Alex. From wwzaygvm at gmail.com Wed Apr 16 16:54:31 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 13:54:31 -0700 (PDT) Subject: xilisoft video converter crack Message-ID: <20a0eba4-9668-405c-837d-f39d0976d417@x19g2000prg.googlegroups.com> xilisoft video converter crack http://cracks.12w.net F R E E C R A C K S From steve at holdenweb.com Thu Apr 24 10:34:50 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 10:34:50 -0400 Subject: annoying dictionary problem, non-existing keys In-Reply-To: <36e8a7020804240713y61f143bend2bd0b6bf3ebd8eb@mail.gmail.com> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> <36e8a7020804240136r6e42f9fdv1f3d4dc3e947169a@mail.gmail.com> <36e8a7020804240713y61f143bend2bd0b6bf3ebd8eb@mail.gmail.com> Message-ID: <48109A8A.5030902@holdenweb.com> Thanks for your reply. Another point to note: if you get a personal reply (often you will just see replies on the list, but sometimes people will also mail you directly) it is usual to make sure the list gets copied in any reply. I hope you don't mind that I am sending a copy of this message to the list, so everyone understands that you are just learning the rules. regards Steve bvidinli wrote: > Thank you for your answer, > Please be tolerant a bit... > > > 2008/4/24, Steve Holden : >> bvidinli wrote: >> >>> I posted to so many lists because, >>> >>> this issue is related to all lists, >>> >> No, it isn't, as you would have discovered had you bothered to read the >> purpose of each list. For example, python-help and python-dev are mutually >> exclusive. >> > > May be, anyway, > >>> this is an idea for python, >>> >> It isn't an idea for Python at all. It's you, telling the world that you >> haven't really used Python much and haven't read the manuals but would >> nevertheless like us to consider your ideas for improving the language. >> > > I am using python for months, > currently i am using it by means of Object oriented, multi thread > applications.... > but i dont see myself a python expert yet.. > >>> this is related to development of python... >>> >>> >> No it isn't. Python already has the feature you requested. > > No, python does not have, php way is simpler, shorter. > list.get('key') is a solution, but not the thing i want... i think > list['key'] is simpler, > this is my idea... > python is generally better than php, but some aspects of php is > better... such as web programming.. > >> >>> why are you so much defensive ? >>> >>> >> Terry wasn't being defensive, he was protecting you form the abue you would >> receive of you kept posting to the wrong list! > > Please be tolerant a bit.. > The person who post may be a person who does not know list rules... > Why hurt such people ? lets concentrate our energy on solutions... > >> >>> i think ideas all important for development of python, software.... >>> i am sory anyway.... hope will be helpful. >>> >>> >> We hope you will be helpful too. For now it would probably be best to start >> by posting your questions on the regular comp.lang.python group, which is >> generally suitable for beginners who know something about programming. If >> you are new to programming as well then the python-tutor list would be more >> useful. >> > > I am not a beginner for programming, not for python, > i am not python expert too... > i do programming since 1988, > i do web/php/system programming since 2000, python for 5 months.. > >> Ask with a little humility (the people who answer questions here are doing >> it out of the goodness of their hearts, remember) and soon you will be able >> to pass their assistance on, returning the favor they did for you. >> >> Welcome to the Python community. > > Anyway, thank you for your answers, your guides, i am happy to hear from you, > to hear from python community. > At least, it is a live community... :) > > see you > Bahattin. > > > >> regards >> Steve >> >> >>> 2008/4/24, Terry Reedy : >>> >>>> Python-dev is for discussion of development of future Python. Use >>>> python-list / comp.lang.python / gmane.comp.python.general for usage >>>> questions. >>>> >> -- >> Steve Holden +1 571 484 6266 +1 800 494 3119 >> Holden Web LLC http://www.holdenweb.com/ >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From python at bdurham.com Tue Apr 29 08:23:51 2008 From: python at bdurham.com (python at bdurham.com) Date: Tue, 29 Apr 2008 08:23:51 -0400 Subject: How to unget a line when reading from a file/stream iterator/generator? In-Reply-To: References: <5e3854fa-557f-4475-8123-346346767097@k13g2000hse.googlegroups.com> Message-ID: <1209471831.15157.1250461645@webmail.messagingengine.com> Duncan, > If speed is an issue then it may be better to avoid the test altogether ... Thanks for your suggestion. Regards, Malcolm From steve at holdenweb.com Thu Apr 17 00:53:14 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 17 Apr 2008 00:53:14 -0400 Subject: Python plugin for Firefox In-Reply-To: References: Message-ID: zelegolas wrote: > Hi, > > It's may be a stupid question but do you if someone tried to create a > python plugin for firefox? > If you know an Open Source project let me know... > > Thanks Look for references to Mark Hammond's PyCon keynote and the work he's been doing with the Mozilla team. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From dennis.benzinger at gmx.net Thu Apr 3 09:08:36 2008 From: dennis.benzinger at gmx.net (Dennis.Benzinger@gmx.net) Date: Thu, 3 Apr 2008 06:08:36 -0700 (PDT) Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> Message-ID: <0c7fd327-7b96-4c20-8c74-a528e280b5f3@r9g2000prd.googlegroups.com> On Apr 3, 1:37 pm, tinn... at isbd.co.uk wrote: > What's the neatest and/or most efficient way of testing if one of a > set of strings (contained in a dictionary, list or similar) is a > sub-string of a given string? > [...] You could use the Aho-Corasick algorithm . I don't know if there's a Python implementation yet. Dennis Benzinger From arnodel at googlemail.com Sun Apr 27 13:22:23 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sun, 27 Apr 2008 18:22:23 +0100 Subject: Mapping and Filtering Help for Lists References: Message-ID: Zethex writes: > Alright I got asked today by a friend this question, which obviously I > couldn't help him with. > > He needs to get rid of words in a string referring to an already given list > then needs to map them using a function he already has. Ill explain this > better by giving an example :P > > Say ur given these lists: > > un_words = ['a', 'the', 'he', 'she', 'uses', 'with'] > alterns = [ ['book', 'textbook', 'notepad'], ['pencil', 'pen', 'pacer'] ] > > The problem asks to create a "compareandremove" so that you can use it on a > string, to remove the words from the string that are contained in un_words. > > The remaining words then need to be compared to the alterns list and either > bring back the word if no matches or bring back the list. To better explain > that i'll use an example. > > If i do compareandremove('notepad a pencil with desk') > > I need it so it removes words contained in un_words, so "a" and "with"; > then compares the remaining words to alterns to find a match. > > This should bring back: > > ['notepad', 'book', 'textbook', 'pencil', 'pen', 'pacer', 'desk'] > > > Any tips on how to create this function or maybe the function itself so I > can then show him how to do it. > > Thank you. Look away now if you don't want a complete solution! un_words = ['a', 'the', 'he', 'she', 'uses', 'with'] alterns = [ ['book', 'textbook', 'notepad'], ['pencil', 'pen', 'pacer'] ] # these words will be replaced with nothing wordmap = dict((w, []) for w in un_words) # these words will be replaced with the list of their synonyms for wordlist in alterns: for word in wordlist: wordmap[word] = wordlist def compareandremove(sentence): return [x for w in sentence.split() for x in wordmap.get(w, [w])] # Example >>> compareandremove('notepad a pencil with desk') ['book', 'textbook', 'notepad', 'pencil', 'pen', 'pacer', 'desk'] -- Arnaud From jeffrey at fro.man Fri Apr 4 17:12:17 2008 From: jeffrey at fro.man (Jeffrey Froman) Date: Fri, 04 Apr 2008 14:12:17 -0700 Subject: Python2.5 and MySQLdb References: Message-ID: writeson wrote: > I'm running a CentOS 4 server and have installed Python2.5 on there > (it's our development machine) in preparation of moving to Python2.5 > everywhere. All looks good with our code and 2.5, except where it > comes to MySQLdb, I can't get that to install on the machine. It > generates a huge lists of errors and warnings from gcc when I run the > python2.5 setup.py build script that comes with the tar file. Anyone > have any suggestions? MySQLdb compiles fine for me with python2.5 on CentOS-4. I suggest that you examine the end of that long of warnings and errors to determine why it won't compile on your machine. Jeffrey From balta96428 at gmail.com Wed Apr 23 05:58:38 2008 From: balta96428 at gmail.com (balta96428 at gmail.com) Date: Wed, 23 Apr 2008 02:58:38 -0700 (PDT) Subject: the sims2 nude patch Message-ID: the sims2 nude patch http://cracks.12w.net F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Sun Apr 6 16:28:08 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 06 Apr 2008 17:28:08 -0300 Subject: traceback.print_exc() supposed to stop exception propagation. References: <69-dnW_JftMHvGTanZ2dneKdnZydnZ2d@bt.com> Message-ID: En Sun, 06 Apr 2008 16:16:46 -0300, Sami escribi?: > In the Python book that I am using to learn the language it says that > the traceback.print_exc() can be used to stop exception propagation and > make the program keep running. Either the book is wrong or you have misinterpreted what you read. From http://docs.python.org/lib/module-sys.html: excepthook(type, value, traceback) This function prints out a given traceback and exception to sys.stderr. When an exception is raised and uncaught, the interpreter calls sys.excepthook with three arguments, the exception class, exception instance, and a traceback object. In an interactive session this happens just before control is returned to the prompt; in a Python program this happens just before the program exits. The handling of such top-level exceptions can be customized by assigning another three-argument function to sys.excepthook. -- Gabriel Genellina From darcy at druid.net Tue Apr 22 17:18:42 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Tue, 22 Apr 2008 17:18:42 -0400 Subject: Spawning a thread and printing dots until it finishes In-Reply-To: References: Message-ID: <20080422171842.f1a7e7d8.darcy@druid.net> On Tue, 22 Apr 2008 13:45:32 -0700 Dennis Lee Bieber wrote: > On Tue, 22 Apr 2008 13:25:07 -0400, "D'Arcy J.M. Cain" > declaimed the following in comp.lang.python: > > > > I think that there are two things that you need to wrap your head > > around before understanding what is happening here. First, threads are > > NOT pre-emptive. Unless your thread gives up the processor it will run > > forever. The sleep call is one way to give up the processor. > > > When did that change take place? > > As I recall, the Python interpreter is supposed to preempt a (pure > Python) thread after some 10 or 100 (I think the value changed some > years ago) bytecodes. It sounds to me like you are talking about when the interpreter grabs and releases the GIL but I was talking about when it releases the processor. I certainly never said that sleep() was the only way to release the processor. I was not actually aware that running a certain number of bytecodes was another way but as I said, we never saw the code for the thread so we don't know what it is doing or what extensions it might be calling. It *may* be pure Python but we don't know. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From johng at neutralize.com Tue Apr 8 12:01:46 2008 From: johng at neutralize.com (monk.e.boy) Date: Tue, 8 Apr 2008 09:01:46 -0700 (PDT) Subject: urlparse http://site.com/../../../page.html References: <9fdd0d8b-785a-4363-be6a-75f993527754@c65g2000hsa.googlegroups.com> Message-ID: > http://4suite.org/ Thanks for the info, for the curious I found some docs on how to use it (pretty simple): http://4suite.org/docs/CoreManual.xml and the code is in the CVS under "4Suite/Ft/Lib/Uri.py" The license is similar to the Apache license, so it is pretty liberal :-) I'd like to see this in the Python Lib :-) Thanks, monk.e.boy From happyriding at yahoo.com Wed Apr 30 02:59:53 2008 From: happyriding at yahoo.com (happyriding) Date: Tue, 29 Apr 2008 23:59:53 -0700 (PDT) Subject: sed to python: replace Q References: <48180348$0$34534$742ec2ed@news.sonic.net> Message-ID: <5721ede4-9341-4708-8acf-6cc00207b3e0@k13g2000hse.googlegroups.com> On Apr 29, 11:27?pm, Raymond wrote: > For some reason I'm unable to grok Python's string.replace() function. line = "abc" line = line.replace("a", "x") print line --output:-- xbc line = "abc" line = line.replace("[apq]", "x") print line --output:-- abc Does the 5 character substring "[apq]" exist anywhere in the original string? From http Sun Apr 27 16:10:37 2008 From: http (Paul Rubin) Date: 27 Apr 2008 13:10:37 -0700 Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: <7x3ap75a9u.fsf@ruckus.brouhaha.com> "Terry Reedy" writes: > Can this alternative be made easier by adding a context manager to gc > module to use with 'with' statements? Something like > > with gc.delay() as dummy: > That sonuds worth adding as a hack, but really I hope there can be an improved gc someday. From rickbking at comcast.net Wed Apr 9 14:29:50 2008 From: rickbking at comcast.net (Rick King) Date: Wed, 09 Apr 2008 14:29:50 -0400 Subject: Pydev shell (was: Re: Stani's python ide 'spe' editor problem) In-Reply-To: References: Message-ID: <47FD0B1E.6010600@comcast.net> I guess this is appropriate to the list... the funky things in eclipse that were happening are hard to describe, but first let me say that none of the other ide's had any funky things happening so I don't think it was my code. That said: I'm working on a command line bulk file renaming tool (using cmd.py) in which I can redirect input to a batch file if I want to, and redirect output to a file (for testing purposes). Running within an eclipse console, I could run through one batch file after which input returns to the console, and then try to run through the same batch file again by typing in my 'run' command; suddenly it would be as if a bunch of the tool's commands were executed having little (but something) to do with the batch of commands I just ran, producing a lot of output that didn't really make any sense. When I stepped through the debugger it got really weird: for example, at one point I went to the variables pane and clicked to open 'self' and it was at that moment that all this output came through on the console. Absolutely nonsensical. I'll check out the new stuff for eclipse. -Rick Fabio Zadrozny wrote: >> Anyway, I am extremely frustrated. I've tried other ide's: pythonwin (I >> found it inadequate for my purposes - why is a command line prompt >> displayed in a dialog window?) - eclipse (editor is just ok, shell does >> not have command history(!), and then *really* funky things started >> happening that I could not explain and so had to stop using it) - idle >> is good for small things and ok for larger projects but limited in general. >> > > Hi Rick, > > The new release has an actual console shell (with code-completion, > history, etc: see http://pydev.sourceforge.net/ for more details). > Aside from that, which 'funky' things started happening? > > Cheers, > > Fabio > > > From flarefight at googlemail.com Sat Apr 26 08:26:58 2008 From: flarefight at googlemail.com (flarefight at googlemail.com) Date: Sat, 26 Apr 2008 05:26:58 -0700 (PDT) Subject: Loading associated files References: <74862697-da58-4eb7-8d60-09aaef54b7ad@j22g2000hsf.googlegroups.com> <07ac86a6-e125-40d9-bfe9-7c3286437bef@z72g2000hsb.googlegroups.com> Message-ID: <779515ba-bcf3-4e55-befd-103ffc506a88@r66g2000hsg.googlegroups.com> I can't get this to work (I am on XP SP2 by the way and using Python 2.5), I wrote a very simple script to test the idea: import sys for arg in sys.argv: print arg raw_input("Done") #Merely to slow the program down so i can see output and then setup a file extension .xyz, placed it in the registry, can get a .xyz file to work as a python script so the registry setup is fine, but when i try and put the parameter to the above program and a %1 (or even without) it gets the following error message from windows: C:\...\hmm.xyz is not a valid Win32 application. any suggestions?? From nospam at invalid.com Thu Apr 24 23:48:58 2008 From: nospam at invalid.com (Jack) Date: Fri, 25 Apr 2008 03:48:58 GMT Subject: ctypes: return a pointer to a struct References: <846077c3-beaf-4ccd-83be-1e2168c4f7fe@c65g2000hsa.googlegroups.com> <4dda2bd7-3348-496e-a594-35da0a34d4de@x35g2000hsb.googlegroups.com> Message-ID: That worked. Thank you! >> AttributeError: 'LP_IP2LocationRecord' object has no attribute >> 'country_short' > > As it says, LP_IP2LocationRecord has no attribute called > 'country_short'. IP2LocationRecord does. > > Use the 'contents' attribute to dereference the pointer. That is: > > yourstruct.contents.country_short From altami0762 at gmail.com Thu Apr 17 15:51:29 2008 From: altami0762 at gmail.com (altami0762 at gmail.com) Date: Thu, 17 Apr 2008 12:51:29 -0700 (PDT) Subject: anydvd 3.9.2.1 crack Message-ID: <8c091084-5aa6-46d9-930f-0ec0f1d0823e@m44g2000hsc.googlegroups.com> anydvd 3.9.2.1 crack http://cracks.12w.net F R E E C R A C K S From coleb2 at gmail.com Wed Apr 9 16:22:53 2008 From: coleb2 at gmail.com (Brian Cole) Date: Wed, 9 Apr 2008 14:22:53 -0600 Subject: wrapping C functions in python In-Reply-To: References: Message-ID: <54b165660804091322w690e5e64x85c3d8f082b411b2@mail.gmail.com> We use the following SWIG (www.swig.org) typemap to perform such operations: %typemap(in) (int argc, char **argv) { if (!PySequence_Check($input)) { PyErr_SetString(PyExc_ValueError,"Expected a sequence"); return NULL; } $1 = PySequence_Length($input); $2 = (char**)alloca($1*sizeof(char*)); for (Py_ssize_t i = 0; i < $1; ++i) { PyObject *o = PySequence_GetItem($input, i); $2[i] = PyString_AsString(o); } } That one works for mapping a python sequence (such as a list) into the argc, argv arguments commonly passed into main. -Brian On Wed, Apr 9, 2008 at 2:13 PM, Paul Anton Letnes wrote: > Hello etc. > > > I am a "scientific" user of Python, and hence have to write some performance > critical algorithms. Right now, I am learning Python, so this is a "newbie" > question. > > I would like to wrap some heavy C functions inside Python, specifically a > wavelet transform. I am beginning to become aquainted with the functions > PyArg_ParseTuple() and Py_BuildValue(). However, I am unable to figure out > how to pass Python list -> C function or C array -> return value in Python. > I manage to build and run the C function, print to screen, pass string as > argument, return an int, etc. The thing which is missing is the magic > array/list... > > > Thanks in advance! I fart in your general direction. > Paul. > -- > http://mail.python.org/mailman/listinfo/python-list > From victorsubervi at gmail.com Thu Apr 17 12:15:19 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 17 Apr 2008 11:15:19 -0500 Subject: More Fun With MySQL and Images In-Reply-To: <1208446793.4433.18.camel@aalcdl07.lib.unc.edu> References: <4dc0cfea0804170742g39965533yfaf260bcf4da4301@mail.gmail.com> <4dc0cfea0804170752x789cce43xe1ea6aeba498ccd1@mail.gmail.com> <1208446793.4433.18.camel@aalcdl07.lib.unc.edu> Message-ID: <4dc0cfea0804170915v60624660g7e6631b49388aaec@mail.gmail.com> Yeah, I figured that out between posts ;) On Thu, Apr 17, 2008 at 10:39 AM, J. Cliff Dyer wrote: > On Thu, 2008-04-17 at 09:52 -0500, Victor Subervi wrote: > > Never mind. Apparently, these tags throw it for that loop: > > print '\n' > > I?m surprised they would, but gratified I found the problem. > > Victor > > > > > > Why does that surprise you? A jpeg has a well-defined header that tells > whatever application is rendering it what to look for. By putting those > tags at the beginning of the data sent to your browser, you're no longer > getting a well-formed jpeg. The header is wrong. > > As an experiment, if you're on *nix, or have access to a decent shell, > try this: > > $ echo '' > newfile.jpg > $ cat /path/to/any_normal_jpeg >> newfile.jpg > $ echo '' >> newfile.jpg > > If you don't have access to a shell, open a JPEG with your favorite text > editor, and manually add "" to the beginning, and save it > out. > > Then try to open newfile in any piece of software of your choosing. > It's no longer a well-formed jpeg, so it won't work. That's exactly > what you're asking the browser to do. > > I guess this isn't really python related, so my apologies for that. > > Cheers, > Cliff > > > > > -- > Oook, > J. Cliff Dyer > Carolina Digital Library and Archives > UNC Chapel Hill > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From john106henry at hotmail.com Wed Apr 2 17:04:45 2008 From: john106henry at hotmail.com (John Henry) Date: Wed, 2 Apr 2008 14:04:45 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> <58deb8b8-bae9-4d43-b973-3d90846726cb@b5g2000pri.googlegroups.com> Message-ID: <83d5604a-4b6c-4a85-9fca-3fcee5010319@b5g2000pri.googlegroups.com> On Apr 2, 1:01 pm, John Henry wrote: > On Apr 1, 11:10 am, sprad wrote: > > > On Apr 1, 11:41 am, mdomans wrote: > > > > Python needs no evangelizing but I can tell you that it is a powerfull > > > tool. I prefer to think that flash is rather visualization tool than > > > programing language, and java needs a lot of typing and a lot of > > > reading. On the other hand python is simple to read and write, can be > > > debuged easily, is intuitive and saves a lot of time. It also supports > > > batteries included policy and you can't get more OO than python. > > > One advantage of Flash is that we can have something moving on the > > screen from day one, and add code to it piece by piece for things like > > keyboard or mouse control, more and more complex physics, etc. Is > > there an equivalent project in Python? > > I downloaded the "How to Think Like a Python Programmer" book and read > it. I think it's a fine reference book for the purpose you > indicated. > > Here's my 2 cents on the subject. > > I had been a volunteer mentor to my son's middle school robotic team > for several years and I have some experiences, therefore, in how kids > react to "programming". Granted, high school kids are "bigger kids" - > but they are kids nevertheless. > > Last summer, I experimented teaching my own kid Python. He was in 7th > grade going onto 8th grade. He was the main goto person for the > robotic team and had no trouble learning the common applications such > as the Microsoft Office suite, and had some experience in ICONic > programming (Lego Mindstorm). So, I tried to see what would happen if > he tries to learn Python - using somewhat similar approach you are > taking: start with something visually appealing on day one. Instead > of Flash, I used Pythoncard - a no-brainer Python GUI construction > toolkit. He was really excited seeing how easy it was to have tic-tae- > toe type program up so easily (we are taking minutes - not hours) and > was very interested and motivated to continue. So far so good. > However, once I start teaching him variables, expressions, loops, and > what not, I found that (by surprise) he had great difficulties > catching on. Not soon after that, we had to quit. > > We - as adults - take many things for granted and sometimes don't > remember, or don't understand how kids learn. My experience tells me > that in order to teach today's video game generation of kids, the > approach really has to be entirely visual. After I abandoned my > attempt to teach my kid Python, I started them on Robolab - a > simplified version of LabView and to my delight, they were able to > cook up a few simple programs (like fibonacci series and so forth) > without too much effort - although my own kid had some minor trouble > understanding the concept of a container (LabView's version of a > variable). > > I don't know if you have access to LabView or Robolab or similar > packages but if you do, I would highly recommend those. LabView is > every bit as powerful, full-featured, and "real-life" as many of the > other languages and I believe that kids will have a much easier time > learning computer programming with it. > > And you are going to teach them Java? Oh, please don't. Let the > colleges torture them. :=) BTW: I successfully taught them to program in machine language. We used lego parts to construct a psudo-turing machine with a 33 bit register, and used Lego Mindstorm to do the programming. It would read the position of the "register" (input), perform an operation, and outputs the answer. To do that, they have to break down a set of 2 numbers into binary form (via pencil and paper), set the flip switches (constructed w lego parts), hit a touch sensor to begin the operation. The robot would then read the position of the flip switches (via light sensor), interpret the first bit (operator: add or subtract), then interpret the next 32 bits as 2 numbers (I only allowed them to use addition, shift, and loops in their program), do the operation internally in decimal, convert the answer to binary, and "display" the result (output) using those switches. They take the result - convert it back to decimal (via pencil and papger) and see that the answer is indeed correct. Wow! My machine can add and subtract!!! They did all these without knowing that they learned the very basis of all computer programming - they just had lots of fun doing it. From corvettecraz92 at gmail.com Fri Apr 11 10:21:17 2008 From: corvettecraz92 at gmail.com (corvettecraz92 at gmail.com) Date: Fri, 11 Apr 2008 07:21:17 -0700 (PDT) Subject: text adventure game problem References: <4fb4fb0d-4cb2-4fcd-a207-a0341d92e82b@8g2000hsu.googlegroups.com> <7e1c3f97-ff17-4add-8d45-40f7b48dec4a@l64g2000hse.googlegroups.com> Message-ID: <17342e68-2593-43cc-aff0-af0e09e75d6d@a22g2000hsc.googlegroups.com> On Apr 11, 10:16?am, corvettecra... at gmail.com wrote: > On Apr 11, 1:40?am, Dennis Lee Bieber wrote: > > > On Thu, 10 Apr 2008 05:06:42 -0700 (PDT), corvettecra... at gmail.com > > declaimed the following in comp.lang.python: > > > > okay, that explains it... > > > could you provide a working example of a two-room game using your > > > method please so I can understand it better? Thanks in advance! > > > ? ? ? ? Okay... It isn't the best thought out system -- I have too > > many specific classes... It would probably be better to put actions into > > dictionaries and use some custom .getattr() to handle them. > > > ? ? ? ? Will four rooms, a hidden chunk of gold, and one other movable > > object suffice? Watch out for news client line wrapping. The only > > parsing done is of the form: verb object; no attempt to handle: verb > > direct_object filler indirect_object > > > -=-=-=-=-=-=- > > # > > # ? TAGS.py ? ? Text Adventure Game Shell > > # > > > # ? I've probably defined too many special classes here > > class Gobject(object): ?#Game object > > ? ? def __init__(self, name, description, hidden=False, fixed=True): > > ? ? ? ? self._name = name > > ? ? ? ? self._description = description > > ? ? ? ? self.hidden = hidden ? #hidden objects are not visible to > > EXAMINE > > ? ? ? ? self.fixed = fixed ? ? #fixed objects can not be taken > > ? ? def _getName(self): > > ? ? ? ? return self._name > > ? ? name = property(_getName) > > ? ? def _getDescription(self): > > ? ? ? ? return self._description > > ? ? description = property(_getDescription) > > > class Exit(Gobject): > > ? ? def __init__(self, description, target, hidden=False): > > ? ? ? ? super(Exit, self).__init__(None, description, hidden) > > ? ? ? ? self._target = target > > ? ? def _getTarget(self): > > ? ? ? ? return self._target > > ? ? target = property(_getTarget) > > > class Room(Gobject): ? ?#rooms (container object) > > ? ? def __init__(self, name, description, exits=None, details=None): > > ? ? ? ? super(Room, self).__init__(name, description, hidden=False, > > fixed=True) > > ? ? ? ? self._exits = exits > > ? ? ? ? if details: > > ? ? ? ? ? ? self._details = details ? ? #other objects that are inside > > the room > > ? ? ? ? else: > > ? ? ? ? ? ? self._details = {} > > ? ? def setExits(self, exits): > > ? ? ? ? self._exits = exits > > ? ? def go(self, ext): > > ? ? ? ? return self._exits.get(ext, None) > > ? ? def setDetails(self, details): > > ? ? ? ? self._details = details > > ? ? def addDetail(self, itm): > > ? ? ? ? self._details[itm.name] = itm > > ? ? def delDetail(self, name): > > ? ? ? ? if (name in self._details and > > ? ? ? ? ? ? not self._details[name].fixed): > > ? ? ? ? ? ? itm = self._details[name] > > ? ? ? ? ? ? del self._details[name] > > ? ? ? ? else: > > ? ? ? ? ? ? itm = None > > ? ? ? ? return itm > > ? ? def examine(self, name=None): > > ? ? ? ? if not name: return self.description > > ? ? ? ? if (name in self._details > > ? ? ? ? ? ? and not self._details[name].hidden): > > ? ? ? ? ? ? return self._details[name].description > > ? ? ? ? else: > > ? ? ? ? ? ? return None > > ? ? def _detailedDescription(self): > > ? ? ? ? items = "nothing of interest" > > ? ? ? ? if self._details: > > ? ? ? ? ? ? items = ", ".join([itm.name for itm in > > self._details.values() > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?if not itm.hidden]) > > ? ? ? ? exits = ", ".join([ext for ext in self._exits.keys() > > ? ? ? ? ? ? ? ? ? ? ? ? ? ?if not self._exits[ext].hidden]) > > ? ? ? ? #there must be at least one exit (the way you came in) > > ? ? ? ? return "%s. In the %s you see %s. Passages lead to %s." % > > (self._description, > > ?self.name, > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? items, > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? exits) > > ? ? description = property(_detailedDescription) > > > class Thing(Gobject): > > ? ? def __init__(self, name, description, parent, hidden=False, > > fixed=False): > > ? ? ? ? super(Thing, self).__init__(name, description, hidden, fixed) > > ? ? ? ? self.parent = parent > > ? ? def take(self): > > ? ? ? ? if self.fixed: > > ? ? ? ? ? ? return None > > ? ? ? ? else: > > ? ? ? ? ? ? self.hidden = False ? ? #if taken, one now can see it > > ? ? ? ? ? ? return self.parent.delDetail(self.name) > > ? ? def drop(self, parent): > > ? ? ? ? self.parent.delDetail(self.name) > > ? ? ? ? parent.addDetail(self) > > > class TriggerThing(Thing): > > ? ? def __init__(self, name, description, parent, > > ? ? ? ? ? ? ? ? ?hidden=False, fixed=True, triggers=None): > > ? ? ? ? super(TriggerThing, self).__init__(name, description, parent, > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?hidden, fixed) > > ? ? ? ? self._triggers = triggers > > ? ? def _detailedDescription(self): > > ? ? ? ? if self._triggers: > > ? ? ? ? ? ? items = ", ".join([itm.name for itm in > > self.parent._details.values() > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?if itm in self._triggers > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?and itm.hidden]) > > ? ? ? ? else: > > ? ? ? ? ? ? items = ", ".join([itm.name for item in > > self.parent._details.values() > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?if itm.hidden]) > > ? ? ? ? if not items: items = "nothing of interest" > > ? ? ? ? return "%s. In the %s you see %s." % (self._description, > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? self.name, > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? items) > > ? ? description = property(_detailedDescription) > > > class Money(Thing): > > ? ? # ? note: I've not worked out how to safely handle combining money > > objects > > ? ? def __init__(self, name, description, amount, parent, hidden=False, > > fixed=False): > > ? ? ? ? super(Money, self).__init__(name, description, parent, hidden, > > fixed) > > ? ? ? ? self._value = amount > > ? ? def _detailedDescription(self): > > ? ? ? ? return "%s pieces of gold" % self._value > > ? ? description = property(_detailedDescription) > > ? ? def combine(self, money): > > ? ? ? ? self._value += money._value > > > class Avatar(Gobject): > > ? ? def __init__(self, name, description, location, hidden=True, > > fixed=True): > > ? ? ? ? super(Avatar, self).__init__(name, description, hidden, fixed) > > ? ? ? ? self.location = location > > ? ? ? ? self._inventory = {} > > ? ? def addInv(self, itm): > > ? ? ? ? itm.hidden = False > > ? ? ? ? if itm.name in self._inventory: ?#presume only gold is > > duplicated > > ? ? ? ? ? ? self._inventory[itm.name].combine(itm) > > ? ? ? ? ? ? del itm > > ? ? ? ? else: > > ? ? ? ? ? ? self._inventory[itm.name] = itm > > ? ? def remInv(self, name): > > ? ? ? ? ? ?itm = self._inventory.get(name, None) > > ? ? ? ? ? ?if itm: del self._inventory[name] > > ? ? ? ? ? ?return itm > > ? ? def inv(self): > > ? ? ? ? return ", ".join([itm for itm in self._inventory.keys()]) > > > #create the universe -- first the raw rooms > > room1 = Room("empty room", > > ? ? ? ? ? ? ?"a completely empty room") > > room2 = Room("time passages", > > ? ? ? ? ? ? ?"a fourth-dimensional room having no fixed shape or size") > > room3 = Room("control room", > > ? ? ? ? ? ? ?"the control room of a TARDIS") > > room4 = Room("locker room", > > ? ? ? ? ? ? ?"a room full of storage spaces") > > > #create each exit > > exit1_2 = Exit("you squeeze through the mouse hole", room2) > > exit1_4 = Exit("you take the doorway", room4) > > exit2_3 = Exit("the TARDIS door opens and you pass in", room3, > > hidden=True) > > exit3_2 = Exit("you leave the TARDIS", room2) > > exit3_1 = Exit("you sneak deeper into the depths of the TARDIS", room1) > > exit4_1 = Exit("you move through the door", room1) > > exit2_1 = Exit("you take the wormhole out", room1) > > exit2_4 = Exit("you follow the light", room4) > > exit4_2 = Exit("you follow the shadow", room2) > > exit2_2a = Exit("as you enter the reddish passage you see yourself > > leaving the room", room2) > > exit2_2b = Exit("you feel a bit older as you take the blue passage", > > room2) > > exit2_2c = Exit("you feel confused as you cross webs of the timestream", > > room2) > > > #connect rooms to exits > > room1.setExits({"hole" : exit1_2, > > ? ? ? ? ? ? ? ? "door" : exit1_4}) > > room2.setExits({"tardis" : exit2_3, > > ? ? ? ? ? ? ? ? "wormhole" : exit2_1, > > ? ? ? ? ? ? ? ? "light" : exit2_4, > > ? ? ? ? ? ? ? ? "past" : exit2_2a, > > ? ? ? ? ? ? ? ? "future" : exit2_2b, > > ? ? ? ? ? ? ? ? "sideways" : exit2_2c}) > > room3.setExits({"out" : exit3_2, > > ? ? ? ? ? ? ? ? "in" : exit3_1}) > > room4.setExits({"door" : exit4_1, > > ? ? ? ? ? ? ? ? "shadow" : exit4_2}) > > > #create a few non-room objects > > container1 = Thing("closet", "an empty closet", room4, fixed=True) > > gold = Money("gold", None, 8, room4, hidden=True) > > container2 = TriggerThing("footlocker", "a fancy carved captain's > > chest", room4, > > ? ? ? ? ? ? ? ? ? ? ? ? ? fixed=True, triggers=[gold]) > > > room4.setDetails({container1.name : container1, > > ? ? ? ? ? ? ? ? ? container2.name : container2, > > ? ? ? ? ? ? ? ? ? gold.name : gold}) > > > #the tardis is both an exit and a thing > > tardis = Thing("tardis", "a beat-up type 40 TARDIS", room2, fixed=True) > > room2.setDetails({tardis.name : tardis}) > > > screwdriver = Thing("screwdriver", "a well worn sonic screwdriver", > > room3) > > room3.setDetails({screwdriver.name : screwdriver}) > > > player = Avatar("Wulfraed", "a nondescript individual", room1) > > > #note: no end conditions are defined > > while True: > > ? ? print player.location.description > > ? ? while True: > > ? ? ? ? cmdstr = raw_input("command> ").strip().lower() > > ? ? ? ? if cmdstr: break > > ? ? words = cmdstr.split() > > ? ? verb = words[0] > > ? ? if len(words) > 1: > > ? ? ? ? objct = words[1] > > ? ? else: > > ? ? ? ? objct = None > > ? ? if verb in ["look", "examine"]: > > ? ? ? ? if objct: > > ? ? ? ? ? ? desc = player.location.examine(objct) > > ? ? ? ? else: > > ? ? ? ? ? ? desc = player.location.examine() > > ? ? ? ? if desc: > > ? ? ? ? ? ? print desc > > ? ? ? ? else: > > ? ? ? ? ? ? print "I don't see that here" > > ? ? elif verb in ["grab", "take"]: > > ? ? ? ? if objct: > > ? ? ? ? ? ? itm = player.location.delDetail(objct) > > ? ? ? ? ? ? if itm: > > ? ? ? ? ? ? ? ? player.addInv(itm) > > ? ? ? ? ? ? ? ? print "%s taken" % itm.name > > ? ? ? ? ? ? else: > > ? ? ? ? ? ? ? ? print "I can not %s the %s" % (verb, objct) > > ? ? ? ? else: > > ? ? ? ? ? ? print "%s what?" % verb > > ? ? elif verb in ["drop", "leave"]: > > ? ? ? ? if objct: > > ? ? ? ? ? ? itm = player.remInv(objct) > > ? ? ? ? ? ? if itm: > > ? ? ? ? ? ? ? ? player.location.addDetail(itm) > > ? ? ? ? ? ? ? ? print "%s dropped" % itm.name > > ? ? ? ? ? ? else: > > ? ? ? ? ? ? ? ? print "I don't have the %s" % objct > > ? ? ? ? else: > > ? ? ? ? ? ? print "%s what?" % verb > > ? ? elif verb in ["walk", "run", "go"]: > > ? ? ? ? if objct: > > ? ? ? ? ? ? ext = player.location.go(objct) > > ? ? ? ? ? ? if ext: > > ? ? ? ? ? ? ? ? print ext.description > > ? ? ? ? ? ? ? ? player.location = ext.target > > ? ? ? ? ? ? else: > > ? ? ? ? ? ? ? ? print "I can't go that way" > > ? ? ? ? else: > > ? ? ? ? ? ? print "%s where?" % verb > > ? ? elif verb... > > > read more ? > > I still can't run that....after fixing the simple stuff like 'invalid > syntax', there's the "Name examine is not defined." > So... I still can't run that....after fixing the simple stuff like 'invalid syntax', there's the "Name examine is not defined." So... From mattheww at chiark.greenend.org.uk Mon Apr 14 08:33:41 2008 From: mattheww at chiark.greenend.org.uk (Matthew Woodcraft) Date: 14 Apr 2008 13:33:41 +0100 (BST) Subject: urllib working differently when run from crontab References: Message-ID: In article , VictorMiller wrote: > I've written a python script which, using urllib, and urllib2 will > fetch a number of files that that I'm interested in from various > websites (they're updated everyday). When I run the script from my > command line everything works as intended. However, when the script > is run from crontab every single url that I attempt to open gets > "connection refused". Has anyone ever seen anything like this? If > so, what's causing it, and what can I do about it? Perhaps you have an http_proxy environment variable set in the interactive session but not in cron's environment? -M- From victorsubervi at gmail.com Wed Apr 9 10:15:52 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 9 Apr 2008 10:15:52 -0400 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804080955q758495efl452ae6963fcbf3da@mail.gmail.com> Message-ID: <4dc0cfea0804090715w46ddabe7i69dd0b71167bfae0@mail.gmail.com> On Wed, Apr 9, 2008 at 1:14 AM, Gabriel Genellina wrote: > > Thanks. I apparently am printing some holder for the image. I stripped > > out > > most of it with this > > content[0][0] > > but then I am left with this: > > > > array('c', '\xff\xd8\xff\xe0\\0\x10JFI...) > > How do I extract an image from that? > > print content.tostring() Now *that* gave me something that *looks* a lot more like an image from a programmers perspective, but still no image... ????JFIF... Actually, it does not copy and paste well, but you can see it for the moment here: http://livestocksling.com/test/python/Shop/display_es2.py So, how do I convert *that* to a real live image? > Or perhaps, replace that line with content.tofile(sys.stdout) Printed nothing. > >> > print 'Content-Type: image/jpeg\r\n' > >> > print '\n' > >> > print content > >> > print '\n' > >> > cursor.close() > >> > > >> > test() > > >> > The commented out line gives me a leading less than sign...and that?s > >> > it. What do? > > Try to understand now *why* you got a single character with your previous > code. No clue :/ BTW, for purposes of documentation, it appears that, when sending the form with the image to the script that processes the form, the following is inadvisable: form = cgi.FieldStorage() pic1 = form.getfirst('pic1', '') This appears to work better: form = cgi.FieldStorage() imgfile=open("pixel.gif",'rb') pixel = imgfile.read() pic1 = form.getfirst('pic1', pixel) because it gives a binary default. The string appears to screw things up. Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at holdenweb.com Sat Apr 12 09:11:32 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 09:11:32 -0400 Subject: Tremendous slowdown due to garbage collection In-Reply-To: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> Message-ID: <4800B504.4010601@holdenweb.com> [...] > I would suggest to configure the default behaviour of the garbage > collector in such a way that this squared complexity is avoided > without requiring specific knowledge and intervention by the user. Not > being an expert in these details I would like to ask the gurus how > this could be done. > I hope this should be at least technically possible, whether it is > really desirable or important for a default installation of Python > could then be discussed once the disadvantages of such a setting would > be apparent. > > Thanks a lot for your consideration, and best regards, > Andreas > I think the linguists of the world should write better automated translation systems. Not being an expert in these details I would like to ask the gurus how it could be done. There are going to be pathological cases in any memory allocation scheme. The fact that you have apparently located one calls for you to change your approach, not for the finely-tuned well-conceived garbage collection scheme to be abandoned for your convenience. If you had made a definite proposal that could have been evaluated you request would perhaps have seemed a little more approachable. You might want to consider trying Jython, or IronPython, or PyPy, each of which comes with a different flavor of garbage collection, to see if one of the other approaches suits you better. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From spamgrinder.trylater at ggmail.com Mon Apr 21 23:49:27 2008 From: spamgrinder.trylater at ggmail.com (AlFire) Date: Mon, 21 Apr 2008 22:49:27 -0500 Subject: why objects of old style classes are instances of 'object' In-Reply-To: <66p7eeF2l44iiU2@mid.uni-berlin.de> References: <4807641F.8030209@gmail.com> <66p7eeF2l44iiU2@mid.uni-berlin.de> Message-ID: <6755i2F2hjsb8U1@mid.individual.net> Diez B. Roggisch wrote: > > But not everything is a newstyle-class: > >>>> class Foo: pass > ... >>>> isinstance(Foo, object) > True >>>> isinstance(Foo, type) > False >>>> class Bar(object): pass > ... >>>> isinstance(Bar, type) > True >>>> > thx for explanation. but more I look at it less and less I like the notation of new-style-class definition. what is an added value of adding "(object)" since it is already an object. Any insight? Note: I am not a language purist, more a pragmatic who like a good style. Andy From timr at probo.com Thu Apr 10 01:37:35 2008 From: timr at probo.com (Tim Roberts) Date: Thu, 10 Apr 2008 05:37:35 GMT Subject: Data structure recommendation? References: <663744510804071339g639bfdccl63de8be66fe52df1@mail.gmail.com> Message-ID: <6o9rv35m5sfgvjvm6h94n12850jkar8n4m@4ax.com> "Steven Clark" wrote: > >Thanks for the reply. Can you explain how I could be bitten by >floating point precision here? >I'm familiar with how&why 1.3*3 != 3.9, etc., but I'm not sure how it >applies here, or what you are gaining by converting to int. Well, it depends on how you get your floating point numbers. I assume you won't be using hard-coded floating point constants as your indices. Instead, you'll be computing them from data in files from somewhere. That's where you have the opportunity to have one index that is 1.6-0.4 and one index that is 0.8+0.4, and the two won't be the same. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From sjmachin at lexicon.net Sat Apr 5 18:55:04 2008 From: sjmachin at lexicon.net (John Machin) Date: Sat, 5 Apr 2008 15:55:04 -0700 (PDT) Subject: RELEASED Python 2.6a2 and 3.0a4 References: <47F68547.1040802@v.loewis.de> Message-ID: On Apr 5, 5:45 am, "Martin v. L?wis" wrote: > > The Windows x86 MSI installer is missing for both 2.6 and 3.0. > > And likely will continue to do so for some time. > > Someone's got strange definitions of "missing"! For each there's a link on the the ptyhon.org website, and a caveat about non-Administrator installation ... If it's missing, then what do I expect to find in the 11.7Mb 2.6a2 msi that is downloading as I type? From bbxx789_05ss at yahoo.com Fri Apr 18 20:40:27 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Fri, 18 Apr 2008 17:40:27 -0700 (PDT) Subject: How to print a unicode string? References: <54e7dba7-f7f2-4aa7-81f9-922e3bf6e6cd@m73g2000hsh.googlegroups.com> Message-ID: <5f2ef8e7-8de7-40c8-b23f-0a86780f042e@l64g2000hse.googlegroups.com> On Apr 18, 6:36?pm, 7stud wrote: > On Apr 18, 5:38?pm, damonwisc... at gmail.com wrote: > > > > > I'd like to print out a unicode string. > > > I'm running Python inside Emacs, which understands utf-8, so I want to > > force Python to send utf-8 to sys.stdout. > > > From what I've googled, I think I need to set my locale. I don't > > understand how. > > > import locale > > print locale.getlocale() > > --> (None,None) > > print locale.getdefaultlocal() > > --> ('en_GB','cp1252') > > print locale.normalize('en_GB.utf-8') > > --> en_GB.UTF8 > > locale.setlocale(locale.LC_ALL,'en_GB.UTF8') > > --> ?locale.Error: unsupported locale setting > > > I'd be grateful for advice. > > Damon. > > u_str = u'hell\u00F6 w\u00F6rld' ?#o's with umlauts > > print u_str.encode('utf-8') > > --output:-- > hell? w?rld Or maybe you want this: u_str = u'hell\u00F6 w\u00F6rld' regular_str = u_str.encode('utf-8') print repr(regular_str) --output:-- 'hell\_x_c3\_x_b6 w\_x_c3\_x_b6rld' #underscores added to keep your browser from rendering the utf-8 characters From bj_666 at gmx.net Sun Apr 27 12:40:41 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 27 Apr 2008 16:40:41 GMT Subject: removing extension References: Message-ID: <67jok9F2o7iv7U2@mid.uni-berlin.de> On Sun, 27 Apr 2008 15:06:54 +0000, Matt Nordhoff wrote: > Arnaud Delobelle wrote: >> More simply, use the rsplit() method of strings: >> >>>>> path = r'C:\myimages\imageone.jpg' >>>>> path.rsplit('.', 1) >> ['C:\\myimages\\imageone', 'jpg'] >> >> >>>>> path = r"C:\blahblah.blah\images.20.jpg" >>>>> path.rsplit('.', 1) >> ['C:\\blahblah.blah\\images.20', 'jpg'] >> >> HTH > > There's os.path.splitext(), which probably does just about exactly that. Not exactly. In the case of no extension `os.path.splitext()` still works: In [14]: 'foo/bar.txt'.rsplit('.') Out[14]: ['foo/bar', 'txt'] In [15]: 'foo/bar'.rsplit('.') Out[15]: ['foo/bar'] In [16]: os.path.splitext('foo/bar') Out[16]: ('foo/bar', '') Ciao, Marc 'BlackJack' Rintsch From uniontelecardsindia at gmail.com Tue Apr 22 17:11:27 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:11:27 -0700 (PDT) Subject: Hunkie black gays ass ramming hardcore action Message-ID: <5c7b4584-17ac-4df9-b653-cc692e39e0fa@d45g2000hsc.googlegroups.com> Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From lists at cheimes.de Tue Apr 22 18:59:54 2008 From: lists at cheimes.de (Christian Heimes) Date: Wed, 23 Apr 2008 00:59:54 +0200 Subject: python has memory leak? In-Reply-To: <1d48c77d-cc93-41ce-b644-1a8e52713e1d@b64g2000hsa.googlegroups.com> References: <1d48c77d-cc93-41ce-b644-1a8e52713e1d@b64g2000hsa.googlegroups.com> Message-ID: <480E6DEA.1010701@cheimes.de> yzghan at gmail.com schrieb: > The version of my python is: > Python 2.4.4 Stackless 3.1b3 060516 (#71, Oct 31 2007, 14:22:28) [MSC ^^^^^^^^^ This is the wrong list to ask for memory leaks of Stackless ;) Christian From alex.gaynor at gmail.com Sat Apr 26 21:01:47 2008 From: alex.gaynor at gmail.com (alex.gaynor at gmail.com) Date: Sat, 26 Apr 2008 18:01:47 -0700 (PDT) Subject: How do I say "Is this a function"? References: <96f62c7c-f951-4dc3-9af3-6cdd74cfa23b@v26g2000prm.googlegroups.com> Message-ID: <522faa0a-f1c5-417d-9a57-012196931370@b64g2000hsa.googlegroups.com> callable(func) returns whether something is callable(will return true for classes, functions, and objects with __call__ methods). On Apr 26, 6:25?pm, Dan Bishop wrote: > On Apr 26, 6:17 pm, John Henry wrote: > > > > > How do I determine is something a function? > > > For instance, I don't want to relying on exceptions below: > > > def f1(): > > ? ?print "In f1" > > > def f3(): > > ? ?print "In f3" > > > def others(): > > ? ?print "In others" > > > for i in xrange(1,3): > > ? ?fct = "f%d()"%(i+1) > > ? ?try: > > ? ? ? exec fct > > ? ?except: > > ? ? ? others() > > > I wish to say: > > > ? ?if value of fct is a funtion, invoke it, otherwise invoke others(). > > > Thanks, > > hasattr(fct, '__call__') > > And be careful about using the exec statement. From ivan.illarionov at gmail.com Thu Apr 10 16:31:08 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Thu, 10 Apr 2008 13:31:08 -0700 (PDT) Subject: Module Conflicts References: <1592fad3-996b-4f62-ac12-42aff8272c21@8g2000hsu.googlegroups.com> Message-ID: On Apr 10, 2:33 am, Jose wrote: > I have a module named math.py in a package with some class > definitions. I am trying to import the standard python math module > inside of math.py but It seems to be importing itself. Is there any > way around this problem without renaming my math.py file? Yes, if you are using Python 2.5 from __future__ import absolute import after this `import math` will always import standard math module and `from . import math` will import your module. -- Ivan From sturlamolden at yahoo.no Sun Apr 20 18:33:52 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Sun, 20 Apr 2008 15:33:52 -0700 (PDT) Subject: Nested lists, simple though References: Message-ID: On Apr 21, 12:25 am, Zethex wrote: > Anyway the amount of [[]] do increase over time. Im just wondering is there > a simple way to add these together so they become 1 simple list, so it would > be ['computer'....'asus'] etc without the nested list. Its random the > amount each time so i cant just go a[0]+a[1]. > Thank you if you can help Does this answer your question? >>> a = [1,2,3] >>> a.extend([4,5,6]) >>> a [1, 2, 3, 4, 5, 6] From jarausch at skynet.be Sun Apr 6 12:16:02 2008 From: jarausch at skynet.be (Helmut Jarausch) Date: Sun, 06 Apr 2008 18:16:02 +0200 Subject: append to a sublist - please help Message-ID: <47f8f743$0$2983$ba620e4c@news.skynet.be> Hi, I must be blind but I don't see what's going wrong with G=[[]]*2 G[0].append('A') G[1].append('B') print G[0] gives ['A', 'B'] as well as print G[1] I was expecting ['A'] and ['B'] respectively. Many thanks for enlightening me, Helmut. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany From skanemupp at yahoo.se Fri Apr 18 12:10:31 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 18 Apr 2008 09:10:31 -0700 (PDT) Subject: tkinter, canvas, get color of image? References: <0e4c9708-dbe9-4f29-ac31-34f7298f2624@m1g2000pre.googlegroups.com> Message-ID: On 16 Apr, 00:46, Bryan Oakley wrote: > skanem... at yahoo.se wrote: > > On 13 Apr, 19:19, Bryan Oakley wrote: > >> skanem... at yahoo.se wrote: > >>> mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\elmapovic.gif') > >>> w.create_image(10, 10, image = mapq, anchor = NW) > >>> after doing this is there any possibility of getting the > >>> characteristics of the GIF-picture(or bitmap if i use that)? > >>> it would be very helpfull if i for example could do something like > >>> canvas.getcolor(image, mouseclick.x,mouseclick.y) if u get the point. > >>> get the color of the image where i clicked. > >> The image isn't "painted" on the canvas, so to answer your specific > >> question, no, you can't get the color of a pixel on the canvas in the > >> way that you ask. > > >> However, when you click on the canvas you can get the item that was > >> clicked on and the x/y of the click. From that you can figure out which > >> pixel of the image is under the cursor. And from that you can query the > >> image for the color of a specific pixel. > > > how do i get the item? > >http://effbot.org/tkinterbook/canvas.htm#Tkinter.Canvas.create_image-... > > > with any of those methods? > > > when i click the mouse i can get event.object u mean? > > You can use find_closest to find the object closest to the x,y of the > event. You can also do find_withtag(tk.CURRENT) which returns the item > under the mouse pointer. Exception in Tkinter callback Traceback (most recent call last): File "C:\Python25\lib\lib-tk\Tkinter.py", line 1403, in __call__ return self.func(*args) File "C:\Users\saftarn\Desktop\pythonkod\mapexperiments \mapgetobject.py", line 17, in callback undermouse=find_closest(master.CURRENT) NameError: global name 'find_closest' is not defined from Tkinter import * master = Tk() w = Canvas(master, width=400, height=625) w.pack(expand = YES, fill = BOTH) mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\images \something.gif') w.create_image(30, 30, image = mapq, anchor = NW) def key(event): print "pressed", repr(event.char) def callback(event): clobj=event.widget ## undermouse=find_withtag(master.CURRENT) undermouse=find_closest(master.CURRENT) print repr(undermouse) w.bind("", key) w.bind("", callback) w.pack() mainloop() From fr5478bey at gmail.com Sat Apr 26 11:39:19 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:39:19 -0700 (PDT) Subject: tiberium wars crack Message-ID: tiberium wars crack http://cracks.00bp.com F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Sat Apr 12 02:22:08 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 12 Apr 2008 03:22:08 -0300 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <47ff8489$0$6841$2d805a3e@textnews.eweka.nl> Message-ID: En Fri, 11 Apr 2008 11:31:42 -0300, Michel Bouwmans escribi?: > Gabriel Genellina wrote: >> Another annoying thing with the Qt license is that you have to choose it >> at the very start of the project. You cannot develop something using the >> open source license and later decide to switch to the commercial licence >> and buy it. > > Unless you're a company with a risk of being checked for legal software > etc., you can always ignore that allthough not very legal. I just ignore Qt itself. -- Gabriel Genellina From erikwickstrom at gmail.com Thu Apr 17 22:30:33 2008 From: erikwickstrom at gmail.com (erikcw) Date: Thu, 17 Apr 2008 19:30:33 -0700 (PDT) Subject: Database vs Data Structure? Message-ID: <61bf5f46-e917-4a98-b87f-8e5087cb07f7@a23g2000hsc.googlegroups.com> Hi, I'm working on a web application where each user will be creating several "projects" in there account, each with 1,000-50,000 objects. Each object will consist of a unique name, an id, and some meta data. The number of objects will grow and shrink as the user works with their project. I'm trying to decided whether to store the objects in the database (each object gets it's own row) or to use some sort of data-structure (maybe nested dictionaries or a custom class) and store the pickled data-structure in a single row in the database (then unpickle the data and query in memory). A few requirements: -Fast/scalable (web app) -able to query objects based on name and id. -will play nicely with versioning (undo/redo) Any input on the best way to go? Thanks! Erik From Lie.1296 at gmail.com Fri Apr 11 14:33:56 2008 From: Lie.1296 at gmail.com (Lie) Date: Fri, 11 Apr 2008 11:33:56 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> Message-ID: On Apr 11, 10:19 pm, Mikael Olofsson wrote: > cokofree... at gmail.com commented about rounding towards even numbers > from mid-way between integers as opposed to for instance always rounding > up in those cases: > > > Strange request though, why do you need it that way, because 2.5 is > > CLOSER to 3 than to 2... > > That's exactly how I was taught to do rounding in what-ever low-level > class it was. The idea is to avoid a bias, which assumes that the > original values are already quantized. Assume that we have values > quantized to one decimal only, and assume that all values of this > decimal are equally likely. Also assume that the integer part of our > numbers are equally likely to be even or odd. Then the average rounding > error when rounding to integers will be 0.05 if you always round up when > the decimal is 5. If you round towards an even number instead when the > decimal is 5, then you will round up half of those times, and round down > the other half, and the average rounding error will be 0. That's the > idea. Of course you could argue that it would be even more fair to make > the choice based on the tossing of a fair coin. That old-school rounding method you're taught is based on a wrong assumption of the nature of number. In the past, rounding algorithm is based on this: Original => (RoundUp(u|d|n), RoundNearestEven(u|d|n) ... 1.0 => 1(n), 1(n) 1.1 => 1(d), 1(d) 1.2 => 1(d), 1(d) 1.3 => 1(d), 1(d) 1.4 => 1(d), 1(d) 1.5 => 2(u), 2(u) 1.6 => 2(u), 2(u) 1.7 => 2(u), 2(u) 1.8 => 2(u), 2(u) 1.9 => 2(u), 2(u) 2.0 => 2(n), 2(n) 2.1 => 2(d), 2(d) 2.2 => 2(d), 2(d) 2.3 => 2(d), 2(d) 2.4 => 2(d), 2(d) 2.5 => 3(u), 2(d) 2.6 => 3(u), 3(u) 2.7 => 3(u), 3(u) 2.8 => 3(u), 3(u) 2.9 => 3(u), 3(u) ... In this used-to-be-thought-correct table, Round Ups algorithm have 2 Unrounded, 8 Round Down, and 10 Round Ups which seems incorrect while Round Even have 2 Unrounded, 9 Round Down, and 9 Round Up which seems correct. The misunderstanding comes from a view that thinks that there is such thing as Not Rounded while in fact the only number that is Not Rounded is 1 and 2 while 1.0 and 2.0 must still be rounded, in practice we can just say that all number must be rounded somewhere. Original => (RoundUp(u|d), RoundNearestEven(u|d) ... 1.0 => 1(d), 1(d) 1.1 => 1(d), 1(d) 1.2 => 1(d), 1(d) 1.3 => 1(d), 1(d) 1.4 => 1(d), 1(d) 1.5 => 2(u), 2(u) 1.6 => 2(u), 2(u) 1.7 => 2(u), 2(u) 1.8 => 2(u), 2(u) 1.9 => 2(u), 2(u) 2.0 => 2(d), 2(d) 2.1 => 2(d), 2(d) 2.2 => 2(d), 2(d) 2.3 => 2(d), 2(d) 2.4 => 2(d), 2(d) 2.5 => 3(u), 2(d) 2.6 => 3(u), 3(u) 2.7 => 3(u), 3(u) 2.8 => 3(u), 3(u) 2.9 => 3(u), 3(u) ... In this table, we consider that a number is rounded down when the number is equal to truncated value (the number without fractional part), while round up is equal to truncated value + 1 or truncated value -1 if value is negative (Actually this is not round-half-up algorithm, it's a round-half-away-from-zero algorithm, but lets just consider that to be the same for now). In this revised table, you get 10 round ups and 10 round down (i.e. Average Rounding Error == 0), while by rounding to nearest even you get 9 round up and 11 round down (i.e. Average Rounding Error != 0). > Note that if you do not have quantized values and assuming that the > fraction part is evenly distributed between 0 and 1, than this whole > argument is moot. The probability of getting exactly 0.5 is zero in that > case, just as the probability of getting any other specified number is zero. Another mistake, in an unquantized value the probability of getting exactly 0.5 (or any other number specified) is not 0 but an infinitesimal (i.e. lim(x) where x -> 0 (BUT NOT ZERO)) > That said, measurements are in practice always quantized, and rounding > towards an even number when mid-way between avoids an average error of > half the original precision. > As a side-note: The the smallest coin in Swedish currency SEK is 0.50, > but prices in stores are given with two decimals, i.e. with precision > 0.01. But what if your goods add up to 12.34? The standard in Swedish > stores, after adding the prices of your goods, is to round the number to > the nearest whole or half SEK, which means that decimals 25 and 75 are > mid-way between. In those cases the rounding is usually done to the > nearest whole SEK, which is based on precicely the above reasoning. If > they did not do that, I could argue that they are stealing on average > 0.005 SEK from me every time I go to the store. Well... I could live > with that, since 0.005 SEK is a ridiculously small amount, and even if I > make thousands of such transactions per year, it still sums up to a > neglectable amount. No the reason is not that, it's because 1) it is much easier to input integral numbers to computer (calculator or cashier machine), to input .5 to computer you have to press two more buttons or at least one shortcut button and 2) if you have two lists, one with a bunch of . 5's and the other just a few of them you would know that it's easier to sum the latter list with or without calculator. > Another side-note: My 12-year old son is now being taught to always > round up from mid-way between. Yet another example of the degradation of > maths in schools. A false assertion from a false understanding. The use of Round Up algorithm is a refinement of the false understanding we used to practice in the past. From arnodel at googlemail.com Fri Apr 4 15:16:09 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Fri, 4 Apr 2008 12:16:09 -0700 (PDT) Subject: generator functions: why won't this work? References: <19359dad-3022-4e83-99e4-8f8093116bcb@a1g2000hsb.googlegroups.com> Message-ID: <8164c8ce-3085-4d10-8e5f-2b156a04a5c1@s8g2000prg.googlegroups.com> On Apr 2, 11:04?pm, "Gabriel Genellina" wrote: > En Wed, 02 Apr 2008 14:11:30 -0300, escribi?: > > > On Apr 1, 10:42?pm, "Gabriel Genellina" > > wrote: > >> En Tue, 01 Apr 2008 23:56:50 -0300, escribi?: > > >> ? ?yield *iterable > > >> could be used as a shortcut for this: > > >> ? ?for __temp in iterable: yield __temp > > > How serious were you about that? > > Not so much, I haven't thougth enough on it. Looks fine in principle, but ? > yield expressions may be a problem. > > -- > Gabriel Genellina Funnily, there's a patch for py3k to make this work as in your idea. It's currently being discussed on python-3000 :) -- Arnaud From silfheed at gmail.com Fri Apr 11 18:49:45 2008 From: silfheed at gmail.com (Silfheed) Date: Fri, 11 Apr 2008 15:49:45 -0700 (PDT) Subject: CDATA and lxml References: <5ebe3201-80a6-45ba-8b88-e8ece6883efa@w8g2000prd.googlegroups.com> <47FF368B.4030708@behnel.de> <47FFA0D7.1030901@behnel.de> Message-ID: <1d6d4a80-7031-441a-b242-e50ebcd51da9@w5g2000prd.googlegroups.com> On Apr 11, 10:33 am, Stefan Behnel wrote: > Hi again, > > Stefan Behnel wrote: > > Silfheed wrote: > >> So first off I know that CDATA is generally hated and just shouldn't > >> be done, but I'm simply required to parse it and spit it back out. > >> Parsing is pretty easy with lxml, but it's the spitting back out > >> that's giving me issues. The fact that lxml strips all the CDATA > >> stuff off isnt really a big issue either, so long as I can create > >> CDATA blocks later with <>&'s showing up instead of <>& . > >> I've scoured through the lxml docs, but probably not hard enough, so > >> anyone know the page I'm looking for or have a quick how to? > > > There's nothing in the docs because lxml doesn't allow you to create CDATA > > sections. You're not the first one asking that, but so far, no one really had > > a take on this. > > So I gave it a try, then. In lxml 2.1, you will be able to do this: > > >>> root = Element("root") > >>> root.text = CDATA('test') > >>> tostring(root)) > '' > > This does not work for .tail content, only for .text content (no technical > reason, I just don't see why that should be enabled). > > There's also a parser option "strip_cdata" now that allows you to leave CDATA > sections in the tree. However, they will *not* behave any different than > normal text, so you can't even see at the API level that you are dealing with > CDATA. If you want to be really, really sure, you can always do this: > > >>> root.text = CDATA(root.text) > > Hope that helps, > > Stefan That is immensely cool. Do you plan to stick it into svn soon? Thanks! From jkugler at bigfoot.com Fri Apr 4 17:19:20 2008 From: jkugler at bigfoot.com (Joshua Kugler) Date: Fri, 04 Apr 2008 13:19:20 -0800 Subject: Easy-to-install-and-use scientific graphics (plotting) package for Python 2.5.1 on Linux Ubuntu 7.1 References: <771b5531-5681-499f-9fda-77749b5db09f@s37g2000prg.googlegroups.com> Message-ID: > Is there an easy scientific graphics (plotting) package for Python > 2.5.1 running on Ubuntu Linux 7.1 ("Gutsy Gibbon")? > > A few years ago I used PyLab (a MatLab-like plotting module for > Python) on a Windows machine, but I don't know if there is a similar > easy-to-install-and-use Python 2.5.1-compatible graphics package for > Ubuntu Linux 7.1? We've been using Matplotlib for a while, but are looking for alternatives. I recently came across Chaco (http://code.enthought.com/chaco/) and am quite impressed with what I see so far. It's API is very clean, not requiring the "magic functions" (can we say setp()?) that is required by matplotlib. Very OO, and from what I see of example code, the API complies with PEP 8 conventions. Installation was easy (easy_install), but for a couple packages, you will need GCC, python-dev, and swig. I haven't dug into it much, but it looks really, really promising. j From Robert.Bossy at jouy.inra.fr Tue Apr 29 10:40:43 2008 From: Robert.Bossy at jouy.inra.fr (Robert Bossy) Date: Tue, 29 Apr 2008 16:40:43 +0200 Subject: Issue with regular expressions In-Reply-To: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> References: <4ddbc690-6705-459e-ae15-74d160914ff4@y18g2000pre.googlegroups.com> Message-ID: <4817336B.7020309@jouy.inra.fr> Julien wrote: > Hi, > > I'm fairly new in Python and I haven't used the regular expressions > enough to be able to achieve what I want. > I'd like to select terms in a string, so I can then do a search in my > database. > > query = ' " some words" with and "without quotes " ' > p = re.compile(magic_regular_expression) $ <--- the magic happens > m = p.match(query) > > I'd like m.groups() to return: > ('some words', 'with', 'and', 'without quotes') > > Is that achievable with a single regular expression, and if so, what > would it be? > > Any help would be much appreciated. > Hi, I think re is not the best tool for you. Maybe there's a regular expression that does what you want but it will be quite complex and hard to maintain. I suggest you split the query with the double quotes and process alternate inside/outside chunks. Something like: import re def spulit(s): inq = False for term in s.split('"'): if inq: yield re.sub('\s+', ' ', term.strip()) else: for word in term.split(): yield word inq = not inq for token in spulit(' " some words" with and "without quotes " '): print token Cheers, RB From wheaties.box at gmail.com Mon Apr 14 03:31:34 2008 From: wheaties.box at gmail.com (Josh) Date: Mon, 14 Apr 2008 00:31:34 -0700 (PDT) Subject: Different times between Python and System References: Message-ID: <66292b91-a2ed-44d1-8fe6-9f4ecd87299b@w1g2000prd.googlegroups.com> Hmm... That didn't work out so well that time. I feel like an idiot. Previously there has been an hour difference between the system time and the time that python reports. On Apr 14, 1:29?am, Josh wrote: > Hi, > > Anyone know why python would not show the same time that my system > shows? > > user at computer:~$ date > Mon Apr 14 01:27:36 MDT 2008 > user at computer:~$ python > Python 2.4.5 (#2, Mar 12 2008, 00:15:51) > [GCC 4.2.3 (Debian 4.2.3-2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information.>>> import datetime > >>> datetime.datetime.now() > > datetime.datetime(2008, 4, 14, 1, 27, 50, 472350) > > Thanks! From antroy at gmail.com Mon Apr 21 07:47:11 2008 From: antroy at gmail.com (Ant) Date: Mon, 21 Apr 2008 04:47:11 -0700 (PDT) Subject: Batteries Included... Message-ID: <74988b0e-c31a-4e98-a7ee-2244a8233a55@k10g2000prm.googlegroups.com> Today's XKCD comic has a nice Python reference! http://xkcd.com/413/ From __peter__ at web.de Sun Apr 6 08:45:31 2008 From: __peter__ at web.de (Peter Otten) Date: Sun, 06 Apr 2008 14:45:31 +0200 Subject: Problems trying to hook own exception function to sys.excepthook References: <8r6dneajtO-cWGXanZ2dnUVZ8s7inZ2d@bt.com> Message-ID: Sami wrote: > Does this mean that one should always use the command line to run a > python program? Yes. Peter From dolloffdelvpg at gmail.com Wed Apr 16 08:06:42 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:06:42 -0700 (PDT) Subject: taylor swift concert schedule Message-ID: <160b5e8f-fcfa-43e0-8a36-954b5a01120f@q24g2000prf.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From bignose+hates-spam at benfinney.id.au Wed Apr 16 18:29:48 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Thu, 17 Apr 2008 08:29:48 +1000 Subject: How to have unittest tests to be executed in the order they appear? References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> <87zlru7le2.fsf@benfinney.id.au> Message-ID: <87fxtlwi03.fsf@benfinney.id.au> Matthew Woodcraft writes: > Ben Finney wrote: > > Your test cases should *not* depend on any state from other test > > cases; they should function equally well when executed in any > > arbitrary sequence. Dependencies between separate test cases (e.g. > > "they only work correctly when run in a specific sequence") means > > you're not isolating them properly. > > So a mode to randomise the test sequence would be nice to have. Twisted has a "trial" framework that allows just such a mode . > Unittest's behaviour (using alphabetical order) doesn't really help > to detect undesired dependencies (which might be bugs in the test > suite or bugs in the underlying code). Agreed. It's just a matter of making a custom unittest.TestRunner, though. Yes, a Small Matter of Programming which I haven't actually done, but unittest doesn't make it difficult to do that. > But running tests in the order they appear is often helpful: you can > put the tests for basic stuff before the tests for advanced stuff, > and then if you suddenly get seventeen failing tests, you know that > the first failure is the best bet to investigate first. Surely, since "suddenly" implies you changed one small area of the code, that area of the code is the best place to look for what caused the failure. -- \ "I planted some bird seed. A bird came up. Now I don't know | `\ what to feed it." -- Steven Wright | _o__) | Ben Finney From nagle at animats.com Thu Apr 10 13:52:05 2008 From: nagle at animats.com (John Nagle) Date: Thu, 10 Apr 2008 10:52:05 -0700 Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. In-Reply-To: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> Message-ID: <47fe5133$0$36336$742ec2ed@news.sonic.net> subhabrata.iisc at hotmail.com wrote: > I am using Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v. > 1310 32 bit (Intel)] on win32 with IDLE 1.2.1 > My O/S is Windows XP SP2 I use 512 MB RAM. > I am encountering the following problems: > (i) a1=1 > a2=2 > a3=a1+a2 > print a3 > # The result is coming sometimes as 3 sometimes as vague numbers. Are you pasting that code into IDLE with cut and paste? IDLE doesn't process multiple-line paste operations properly, and usually ignores all lines after the first. When it does this, it does not produce an error message. That may be your first problem. John Nagle From ptmcg at austin.rr.com Wed Apr 2 11:07:52 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Wed, 2 Apr 2008 08:07:52 -0700 (PDT) Subject: april fools email backfires References: Message-ID: On Apr 2, 8:36?am, Aaron Watters wrote: > Grapevine says that an architect/bigot at a java/spring > shop sent out an April Fools email saying they had > decided to port everything to Django ASAP. > > Of course the email was taken seriously and he > got a lot of positive feedback from line developers > and savvy users/managers that they thought it would be a great > idea; it's about time; gotta do something about this > mess... > > ? -- Aaron Watters > > ===http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=other+surprises Can you post a link? -- Paul From kinch1967 at gmail.com Sun Apr 27 11:54:55 2008 From: kinch1967 at gmail.com (bullockbefriending bard) Date: Sun, 27 Apr 2008 08:54:55 -0700 (PDT) Subject: design choice: multi-threaded / asynchronous wxpython client? References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: <002cd046-f11d-482e-a67d-4a10a97687a1@x19g2000prg.googlegroups.com> On Apr 27, 10:05?pm, "Eric Wertman" wrote: > HI, that does look like a lot of fun... You might consider breaking > that into 2 separate programs. ?Write one that's threaded to keep a db > updated properly, and write a completely separate one to handle > displaying data from your db. ?This would allow you to later change or > add a web interface without having to muck with the code that handles > data. Thanks for the good point. It certainly is a lot of 'fun'. One of those jobs which at first looks easy (XML, very simple to parse data), but a few gotchas in the real-time nature of the beast. After thinking about your idea more, I am sure this decoupling of functions and making everything DB-centric can simplify a lot of issues. I quite like the idea of persisting pickled or YAML data along with the raw XML (for archival purposes + occurs to me I might be able to do something with XSLT to get it directly into screen viewable form without too much work) to a DB and then having a client program which queries most recent time-stamped data for display. A further complication is that at a later point, I will want to do real-time time series prediction on all this data (viz. predicting actual starting prices at post time x minutes in the future). Assuming I can quickly (enough) retrieve the relevant last n tote data samples from the database in order to do this, then it will indeed be much simpler to make things much more DB-centric... as opposed to maintaining all this state/history in program data structures and updating it in real time. From notformail at sonic.net Sun Apr 20 11:28:52 2008 From: notformail at sonic.net (JB Stern) Date: 20 Apr 2008 15:28:52 GMT Subject: Any reliable obfurscator for Python 2.5 References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> Message-ID: <480b6133$0$34498$742ec2ed@news.sonic.net> Banibrata Dutta wrote: >>Wanted to check if there is any known, reliable, FOSS/Libre -- Obfurscator >> for Python 2.5 code. No, sadly, there is not. There are a number of applications I would be working on if it were possible to obfuscate pyc files. About the best you can do as of 2008/04 is use Jython to compile into Java bytecode and obfuscate that using Proguard. Steve 'not an economics major' Holden wrote: >The Python world isn't particularly paranoid about obfuscation. It's >quite easy to publish compiled code only (.pyc and/or .pyo files), and >that offers enough protection for most. Curious Steve, how do you pay the rent and by what authority do you speak for "The Python world"? Your opinion couldn't be more wrong for programmers like myself who live by the code they write (as opposed to its support). Steve 'not a software consultant' Holden wrote: >The sad fact is that there seems to be an almost direct inverse >correlation between the worth of the code and the authors' desire to >protect it from piracy. Would love to see some evidence to that effect. JB From rdh at new.rr.com Tue Apr 22 17:32:08 2008 From: rdh at new.rr.com (DataSmash) Date: Tue, 22 Apr 2008 14:32:08 -0700 (PDT) Subject: list manipulation References: <78158460-8508-4453-a2dc-c5814dda8839@59g2000hsb.googlegroups.com> Message-ID: <7090b346-813e-47a3-aed7-1536102cc8c3@26g2000hsk.googlegroups.com> Joe & Mike, Thanks for your input! R.D. From mensanator at aol.com Wed Apr 16 21:16:33 2008 From: mensanator at aol.com (Mensanator) Date: Wed, 16 Apr 2008 18:16:33 -0700 (PDT) Subject: TypeNone field detection References: <480698b3$0$31577$ec3e2dad@news.usenetmonster.com> Message-ID: <719373ea-c141-45c3-b723-1b89624bc6ac@a22g2000hsc.googlegroups.com> On Apr 16, 7:24?pm, Joe Blow wrote: > What is the best way to detect a TypeNone field in a tuple, or in a list? > > I am accessing a MySQL database using the MySQLdb Python interface... this > interface returns a tuple object type in response to SQL SELECT > statements. ?My understanding of the MySQLdb interface is that NULL > database values are returned as a Python 'None' object. > > Because I need to create some work fields based on the contents of the > database I am doing so by copying the tuple to a list object and then > calculating these work fields as needed. ?My problem is that I need to be > able to detect the Python 'None' objects and convert them to an integer > zero value field to enable my calculations to work. > > I'm new to Python so I'm sure I'm overlooking something simple ? but what > is the easiest way to do a logical test for the existence of a TypeNone > field? >>> a = 0 >>> a==None False >>> b = None >>> b==None True >>> type(a) >>> type(b) From tnelson at onresolve.com Fri Apr 11 08:07:14 2008 From: tnelson at onresolve.com (Trent Nelson) Date: Fri, 11 Apr 2008 05:07:14 -0700 Subject: Randall Munroe loves Python In-Reply-To: <869c25d9-e4d3-4629-a807-f3b203f3fb65@b1g2000hsg.googlegroups.com> References: <869c25d9-e4d3-4629-a807-f3b203f3fb65@b1g2000hsg.googlegroups.com> Message-ID: <87D3F9C72FBF214DB39FA4E3FE618CDC6E22D1F9B2@EXMBX04.exchhosting.com> > Another xkcd plug for Python: http://xkcd.com/409/ Damn it. There goes another 40 minutes of my life magically whisked away by that more-addictive-than-crack 'RANDOM' button. From asmodai at in-nomine.org Sun Apr 13 04:33:11 2008 From: asmodai at in-nomine.org (Jeroen Ruigrok van der Werven) Date: Sun, 13 Apr 2008 10:33:11 +0200 Subject: =?utf-8?B?5pyJ5Lit5Zu95Lq65LmOPw==?= In-Reply-To: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> References: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> Message-ID: <20080413083310.GR51167@nexus.in-nomine.org> (My Mandarin is not very good.) -On [20080413 09:24], bikthh at live.cn (bikthh at live.cn) wrote: >Python????????????????. Python indeed does have a good future. I am not quite sure with ??????? if you are asking for someone to teach to you or if you want to teach others. -- Jeroen Ruigrok van der Werven / asmodai ????? ?????? ??? ?? ?????? http://www.in-nomine.org/ | http://www.rangaku.org/ My greatest fear... Is that all my Memories will be lost... Like tears, in the rain... From srf99 at ferg.org Wed Apr 16 09:17:21 2008 From: srf99 at ferg.org (srf99 at ferg.org) Date: Wed, 16 Apr 2008 06:17:21 -0700 (PDT) Subject: Learning Tkinter References: Message-ID: <20b6cb69-0048-4d49-aa70-d05bebc4316e@l42g2000hsc.googlegroups.com> You might want to look at these: Thinking in Tkinter http://www.ferg.org/thinking_in_tkinter/index.html Easygui http://www.ferg.org/easygui/index.html From James.Pells at gmail.com Fri Apr 25 18:30:41 2008 From: James.Pells at gmail.com (James.Pells at gmail.com) Date: Fri, 25 Apr 2008 15:30:41 -0700 (PDT) Subject: nntplib retrieve news://FULL_URL Message-ID: So I have established a connection to an nntp server and I am retrieving articles to other articles on the server such as news://newsclip.ap.org/D8L4MFAG0 at news.ap.org Now I am wondering how I query for that article based off of the url? I assume D8L4MFAG0 is an id of some sort but when I try and retrieve that article via myNntpObject.article('D8L4MFAG0') I get an error of 423 Bad article number. Which makes sense as all the other article numbers are integers. D8L4MFAG0 actually looks like a doc-id value for an NITF article stored on the NNTP server which I am retrieving content off of. Anyone have any ideas on how I fetch this content? Jimmy From rune.strand at gmail.com Fri Apr 11 15:29:43 2008 From: rune.strand at gmail.com (Rune Strand) Date: Fri, 11 Apr 2008 12:29:43 -0700 (PDT) Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> Message-ID: On Apr 11, 8:35 pm, Steve Holden wrote: > wxDesigner. Yeah, but it's like Heron of Alexandria's Aeolipile compared to the steam engine of James Watt. IMHO, GUI with Python is pain, pain and utter pain. Even boring and meaningless pain. From gruszczy at gmail.com Wed Apr 23 21:29:54 2008 From: gruszczy at gmail.com (=?UTF-8?Q?Filip_Gruszczy=C5=84ski?=) Date: Thu, 24 Apr 2008 03:29:54 +0200 Subject: Explicit variable declaration In-Reply-To: <5e59998b-d2e7-48cb-824b-84620f95c9bc@w5g2000prd.googlegroups.com> References: <1506f165-7f86-4dc7-aa29-6488eda9ae7f@l64g2000hse.googlegroups.com> <5e59998b-d2e7-48cb-824b-84620f95c9bc@w5g2000prd.googlegroups.com> Message-ID: <1be78d220804231829k2c040fat80f6fe8b96e1b7cf@mail.gmail.com> > If you want to just declare that name exist, but doesn't want to > declare the type, why don't you just do this: > > def somefunc(): > nonlocal = nonlocal > local = 0 # or None or [] or an initial value > # > return nonlocal * local Err.. I don't quite get. How it may help me? Could you explain? -- Filip Gruszczy?ski From ewertman at gmail.com Sun Apr 27 13:21:45 2008 From: ewertman at gmail.com (Eric Wertman) Date: Sun, 27 Apr 2008 13:21:45 -0400 Subject: Mapping and Filtering Help for Lists In-Reply-To: <16925836.post@talk.nabble.com> References: <16925836.post@talk.nabble.com> Message-ID: <92da89760804271021y2cb4e82ek4486f7580adfa7d5@mail.gmail.com> You should check out the sets module: http://docs.python.org/lib/module-sets.html > > The problem asks to create a "compareandremove" so that you can use it on a > string, to remove the words from the string that are contained in un_words. > > The remaining words then need to be compared to the alterns list and either > bring back the word if no matches or bring back the list. To better explain > that i'll use an example. > > If i do compareandremove('notepad a pencil with desk') > > I need it so it removes words contained in un_words, so "a" and "with"; > then compares the remaining words to alterns to find a match. > > This should bring back: > > ['notepad', 'book', 'textbook', 'pencil', 'pen', 'pacer', 'desk'] From sjdevnull at yahoo.com Fri Apr 18 15:28:59 2008 From: sjdevnull at yahoo.com (sjdevnull at yahoo.com) Date: Fri, 18 Apr 2008 12:28:59 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <48074f58$0$4916$e4fe514c@dreader32.news.xs4all.nl> <6002cb46-f48a-421d-a4ff-5b23bf2f9d77@2g2000hsn.googlegroups.com> Message-ID: On Apr 17, 10:30 am, sturlamolden wrote: > On 17 Apr, 15:21, "Martin P. Hellwig" wrote: > > > If not, what is the advantage above already present solutions? > > Well... I like the processing module. Except that Wintendo toy OS has > no fork() availabe for the Win32 subsystem Passing a NULL SectionHandle to NTCreateProcess/CreateProcessEx results in a fork-style copy-on-write duplicate of the current process. From gagsl-py2 at yahoo.com.ar Tue Apr 8 02:41:57 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 08 Apr 2008 03:41:57 -0300 Subject: Translating keywords References: <432e22c6-7cd0-4a9c-b3bc-dea9fe4798d0@8g2000hsu.googlegroups.com> Message-ID: En Tue, 08 Apr 2008 03:28:54 -0300, Arnaud Delobelle escribi?: > On Apr 8, 6:47 am, Arnaud Delobelle wrote: > [...] >> Although I would use ? and ? as aliases for all() >> and exists() :) > > I mean all() and any() of course Yes, I thought about that usage too, but I were looking for *keywords* to replace, and ? x ? A: f(x) instead of `for x in A: f(x)` was a winner because it uses two of them. -- Gabriel Genellina From kyosohma at gmail.com Fri Apr 11 13:20:56 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 11 Apr 2008 10:20:56 -0700 (PDT) Subject: Cannot start RPy - need win32api References: Message-ID: <743ee4e0-bd05-4291-b587-1e8c6237656b@f36g2000hsa.googlegroups.com> On Apr 11, 11:47 am, tkp... at hotmail.com wrote: > I'm running Python 2.5.2 on Windows XP and need to interface with R, > so I downloaded the R 2.6.2 statistical package and installed it, and > did the same for RPy 1.02 (i made sure I got the version for Python > 2.5 and R 2.62.). When I go to the Python command line and type > > >>> from rpy import * > > I get the following error message: > > Traceback (most recent call last): > File "", line 1, in > from rpy import * > File "C:\Python25\lib\site-packages\rpy.py", line 88, in > import win32api > ImportError: No module named win32api > > > > What on earth is win32api, where can I find it, and where ought I to > put it? > > Thanks in advance > > Thomas Philips It's part of the PyWin32 package, which exposes a lot of the win32 processes to Python manipulation. You can get it here: https://sourceforge.net/projects/pywin32/ And documentation is here: http://aspn.activestate.com/ASPN/docs/ActivePython/2.5/pywin32/win32_modules.html Mike From mitko at qlogic.com Tue Apr 1 17:49:28 2008 From: mitko at qlogic.com (Mitko Haralanov) Date: Tue, 1 Apr 2008 14:49:28 -0700 Subject: Decrementing of reference count of new objects? Message-ID: <20080401144928.24bc6506@opal.mv.qlogic.com> For the most part, I understand the theory behind reference counting in Python C code. But there is one thing that I am confused about and I have not been able to clear it up. Let say that you have the following function (over-simplified): PyObject *do_work (PyObject *self, PyObject *args) { PyObject *new_obj; new_obj = PyDict_New (); return new_obj; } What I don't get is whether I have to decrement the reference to new_obj before I return it. I know that function that return object are giving away the reference but I am still confused. Thanks for all your help! -- Mitko Haralanov mitko at qlogic.com Senior Software Engineer 650.934.8064 HSG InfiniBand Engineering http://www.qlogic.com ========================================== 11. Any more trouble from you and your account gets moved to the 750 --Top 100 things you don't want the sysadmin to say From bockman at virgilio.it Wed Apr 16 03:40:44 2008 From: bockman at virgilio.it (bockman at virgilio.it) Date: Wed, 16 Apr 2008 00:40:44 -0700 (PDT) Subject: How is GUI programming in Python? References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> Message-ID: <69795448-0534-4aed-a9a0-84f2cd3aea36@s50g2000hsb.googlegroups.com> On 11 Apr, 20:19, Rune Strand wrote: > On Apr 10, 3:54 am, Chris Stewart wrote: > ... > > > > > Next, what would you say is the best framework I should look into? > > I'm curious to hear opinions on that. > > GUI-programming in Python is a neanderthal experience. What one may > love with console scripts is turned upside-down. ?Projects like Boa > Constructor seemed to be a remedy, but is not developed. The Iron- > Pythonistas has a very promising RAD GUI-tool in the IronPython - > Studio,http://www.codeplex.com/IronPythonStudio- but if you're non- > Iron, only sorrow is left - unless you fancy creating GUI in a text- > editor. Something I consider waste of life. If you refer to lack of GUI designer, every toolkit usable by python - barring Tkinter - has a GUI designer wich can be used: pygtk -> Glade pywx -> wxDesigner, rxced, ... pyqt -> QDesigner, ... All can generate python code and/or generate files that can be used by python program to create the whole GUI with a few function calls (e.g. libglade ). If you refer to the lack of visual programming ala visualstudio or JBorland, you might be right, but I personally found that visual programming makes for very unmaintenable code, especially if you have to fix something and you don't have the IDE with you (and this has happened many times to me). Therefore I now prefer a clean separation between the GUI (described in someting like glade files or .xrc files) and my code. BTW, once learned to use the right layout managers, even building a GUI from scratch is not such a PITA, since you don't have to manually place each widget anymore, but only define the structure of packers and grids and then adjust borders and such with some -limited IME - experimentation. I know people that prefer this approach to any GUI builder, having developed their own little library to help reducing the boilerplate (and in Python you can do nice things with decorators ans such ... ). So maybe yes, in python you might not have the fancy world of visual programming, but neither are deprived of tools that make your work easier. Ciao ----- FB From gagsl-py2 at yahoo.com.ar Thu Apr 10 00:58:22 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 01:58:22 -0300 Subject: PyArg_ParseTuple for structs or binary data References: <7a01f6c00804090105h7cba73f0g53687349d8dcd574@mail.gmail.com> Message-ID: En Wed, 09 Apr 2008 05:05:45 -0300, Alvin Delagon escribi?: > I'm currently writing a simple python SCTP module in C. So far it works > sending and receiving strings from it. The C sctp function sctp_sendmsg() > has been wrapped and my function looks like this: > > sendMessage(PyObject *self, PyObject *args) > { > const char *msg = ""; > if (!PyArg_ParseTuple(args, "s", &msg)) > return NULL; > snprintf(buffer, 1025, msg); > ret = sctp_sendmsg(connSock, (void *)buffer, (size_t)strlen(buffer), > 0, 0, > 0x03000000, 0, 0, 0, 0); > return Py_BuildValue("b", ""); > } > > I'm going to construct an SS7 packet in python using struct.pack(). > Here's > the question, how am I going to pass the packet I wrote in python to my > module? Thanks in advance! :) Same as you do now; struct.pack returns a string object. The "s#" format is safer, in case embedded NUL characters are allowed. Also, there is no need to copy the string into another buffer (assuming the sctp_sendmsg doesn't alter it). This Py_BuildValue looks suspicious - what's the intended return value? In case you want to return "ret" (an integer, I guess), use Py_BuildValue("i", ret) or just PyInt_FromLong(ret) -- Gabriel Genellina From marlin_rowley at hotmail.com Fri Apr 18 11:25:40 2008 From: marlin_rowley at hotmail.com (Marlin Rowley) Date: Fri, 18 Apr 2008 10:25:40 -0500 Subject: Which event to use for out of focus window? Message-ID: I think I've found a bug in the wx Library. I've created an event : EVT_IDLE that does something when the event is triggered, however, if your mouse pointer is out-of-focus on the window, the EVT_IDLE doesn't get called. It's only when the window is put into focus that the IDLE event is called. I basically want the IDLE function to be called whether the window is in focus or not. Is there a way to do this? Thanks, -M _________________________________________________________________ Get in touch in an instant. Get Windows Live Messenger now. http://www.windowslive.com/messenger/overview.html?ocid=TXT_TAGLM_WL_Refresh_getintouch_042008 -------------- next part -------------- An HTML attachment was scrubbed... URL: From fennelllindy8241 at gmail.com Mon Apr 28 03:18:35 2008 From: fennelllindy8241 at gmail.com (fennelllindy8241 at gmail.com) Date: Mon, 28 Apr 2008 00:18:35 -0700 (PDT) Subject: convertxtodvd keygen Message-ID: convertxtodvd keygen http://crack.cracksofts.com From skanemupp at yahoo.se Sun Apr 6 17:05:44 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 6 Apr 2008 14:05:44 -0700 (PDT) Subject: How to create an exe-file? References: <311a216f-5366-47c5-86a7-431dd23ced3e@j1g2000prb.googlegroups.com> Message-ID: <8da70474-6ade-4515-8346-8f02a04ff24e@b9g2000prh.googlegroups.com> On 6 Apr, 22:50, Fredrik Lundh wrote: > skanem... at yahoo.se wrote: > > how do you create exe-files of your python-code? > > > is it different depending on what libraries, GUI-frameworks you use? > > > i want to create an exe-file of a pythonscript that uses Tkinter. > > assuming windows only, you want: > > http://www.py2exe.org/ > > also see: > > http://effbot.org/zone/python-compile.htm > > ty. a good thing about python is the portability though. but u cant make an exe that can be used on mac too, ie one exe fpr both? if i want to make an exe for mac, what do i need? From pavlovevidence at gmail.com Tue Apr 1 01:31:23 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Mon, 31 Mar 2008 22:31:23 -0700 (PDT) Subject: Looking for indent advice howto in emacs python-mode References: Message-ID: On Mar 31, 12:32 pm, "Steven W. Orr" wrote: > Here's what I want to do: > > if ( ( v == 1 ) > or ( v == 2 ) > or ( v == 3 ) ): > pass > > but emacs (left to its own devices, does this. > > if ( ( v == 1 ) > or ( v == 2 ) > or ( v == 3 ) ): > pass > > It works great for me in C-mode. Does anyone know how to jimmie up > python-mode so it would know how to do this? Not sure about the python.el that ships with emacs 21, but the python- mode.el that is used in emacs 20, it can't be done without modifying the Lisp code. An open nesting character with nothing on the line following it will indent the following line 4 (or whateve py-basic-indent is set to) spaces. An open nesting character with something following it will indent the following line to match the column of the first item. There is no option to change this. If you are not afraid of Elisp, then the function to modify is called py-compute-indentation, and you should look for a comment with the text "again mimic the first line item". That is where the indent in this case is set. The code following the comment "elset they're about to enter the first item" sets the indent for the other case. You might want to use that code in all cases. (Warning: this may cause problems elsewhere, such as nesting function call.) And once again, all bets are off if you're using python.el in Emacs 21. Carl Banks From jantod at gmail.com Mon Apr 14 11:52:38 2008 From: jantod at gmail.com (Janto Dreijer) Date: Mon, 14 Apr 2008 08:52:38 -0700 (PDT) Subject: eval modifies passed dict References: <2b2398b1-042e-46bb-b840-ea9e07d87bd1@2g2000hsn.googlegroups.com> <511feb86-3915-46da-9bd8-d02de87eb2de@b1g2000hsg.googlegroups.com> Message-ID: On Apr 14, 5:48?pm, colas.fran... at gmail.com wrote: > On 14 avr, 17:23, Janto Dreijer wrote: > > > It seems eval is modifying the passed in locals/globals. This is > > behaviour I did not expect and is really messing up my web.py app. > > > Python 2.5.1 (r251:54863, Mar ?7 2008, 04:10:12) > > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > > Type "help", "copyright", "credits" or "license" for more information.>>> d = dict(a=1) > > >>> d.keys() > > ['a'] > > >>> eval("a", d) > > 1 > > >>> d.keys() > > > ['a', '__builtins__'] > > > That can't be right. > > From the documentation of eval[1] > "If the globals dictionary is present and lacks '__builtins__', the > current globals are copied into globals before expression is parsed." > > [1]http://docs.python.org/lib/built-in-funcs.html Thanks! I'll take it to the webpy group as one of their methods unexpectedly propagates this effect. Janto From mccle27252 at gmail.com Mon Apr 21 03:53:00 2008 From: mccle27252 at gmail.com (mccle27252 at gmail.com) Date: Mon, 21 Apr 2008 00:53:00 -0700 (PDT) Subject: utu conductor patch Message-ID: <00465189-43fe-4902-b6e4-5acda0add440@a9g2000prl.googlegroups.com> utu conductor patch http://cracks.00bp.com F R E E C R A C K S From gagsl-py2 at yahoo.com.ar Tue Apr 22 01:29:31 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 22 Apr 2008 02:29:31 -0300 Subject: why objects of old style classes are instances of 'object' References: <4807641F.8030209@gmail.com> <66p7eeF2l44iiU2@mid.uni-berlin.de> <6755i2F2hjsb8U1@mid.individual.net> Message-ID: En Tue, 22 Apr 2008 00:49:27 -0300, AlFire escribi?: > Diez B. Roggisch wrote: > >> But not everything is a newstyle-class: >> >>>>> class Foo: pass >> ... >>>>> isinstance(Foo, object) >> True >>>>> isinstance(Foo, type) >> False > >>>>> class Bar(object): pass >> ... >>>>> isinstance(Bar, type) >> True >>>>> >> > > > thx for explanation. but more I look at it less and less I like the > notation of new-style-class definition. what is an added value of adding > "(object)" since it is already an object. Any insight? Read Diez previous post again. An old-style class is an *instance* of object (as all other objects), but not a *subclass* of object. It does not *inherit* from object. A new-style class is both an instance of object and a subclass of object. It inherits from object. This is what the base (object) means. > Note: I am not a language purist, more a pragmatic who like a good style. We need *some* way to distinguish new-style classes from old ones. The (object) base is simple, doesn't require new syntax, and it's true (hmm, this may be a form of petitio principii) In Python 3.0, old-style classes are gone, and the (object) is not necesary: all classes inherit from object. -- Gabriel Genellina From bockman at virgilio.it Thu Apr 24 08:50:51 2008 From: bockman at virgilio.it (bockman at virgilio.it) Date: Thu, 24 Apr 2008 05:50:51 -0700 (PDT) Subject: How to get inner exception traceback References: <67b8nuF2m1a1kU1@mid.individual.net> Message-ID: <09ce6c51-3c23-4fb7-a369-d357c0f5d287@m73g2000hsh.googlegroups.com> On 24 Apr, 13:20, Thomas Guettler wrote: > Hi, > > How can you get the traceback of the inner exception? > > try: > ? ? ?try: > ? ? ? ? ?import does_not_exit > ? ? ?except ImportError: > ? ? ? ? ?raise Exception("something wrong") > except: > ? ? ?... > > Background: In Django some exceptions are caught and a new > exception gets raised. Unfortunately the real error is hard > to find. Sometimes I help myself and change (in this example) > ImportError to e.g. IOError and then I can see the real root > of the problem. But maybe there is a way to get the inner > exception and its traceback. This could be displayed in the > debug view. > > ? Thomas > > -- > Thomas Guettler,http://www.thomas-guettler.de/ > E-Mail: guettli (*) thomas-guettler + de I'm not sure it ill work since sys.exc_info() might not return a deep copy of the traceback info, but you could try to store the inner exception and its traceback as attributes of the outer exception: class ReraisedException(Exception): def __init__(self, message, exc_info): Exception.__init__(self, message) self.inner_exception = exc_info try: try: import does_not_exit except ImportError: raise ReraisedException("Something wrong", sys.exc_info() ) except ReraisedException, e: ... # here you can use e.inner_exception except: ... Ciao ----- FB From cyberco at gmail.com Thu Apr 10 11:30:08 2008 From: cyberco at gmail.com (Berco Beute) Date: Thu, 10 Apr 2008 08:30:08 -0700 (PDT) Subject: Can C.L.P.handle the load? References: <3b6737c8-9d42-4218-ac60-01df2f578746@p39g2000prm.googlegroups.com> <9bd25fd3-5133-4165-9784-fbbc21145810@24g2000hsh.googlegroups.com> Message-ID: On Apr 9, 12:24 pm, Duncan Booth wrote: > Berco Beute wrote: > > On Apr 9, 7:54 am, Paddy wrote: > >> What else could we do to make c.l.p. of more use to the newbie whp may > >> also be new to usenet whilst keeping c.l.p a usefull place for all? > > >> - Paddy. > > > Maybe create a usenet/google group for newbies? A place to ask > > beginners questions. And post a sticky to c.l.p. redirecting newbies > > (or experienced pythoneers with newbie questions :). > > Or just redirect them to the already existing listhttp://mail.python.org/mailman/listinfo/tutor I didn't know about that list. It would be nice to have that list duplicated as a usenet/google group (just like c.l.p). > What do you mean by 'post a sticky'? That sounds like a web forum thing. It is. Using Google Groups some can post a post that stays on top. Not sure if everybody would like that. :) 2B From mfb.chikazuku at gmail.com Thu Apr 10 13:17:52 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Thu, 10 Apr 2008 19:17:52 +0200 Subject: Stripping scripts from HTML with regular expressions References: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> <47fd46b3$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: <47fe59f2$0$6838$2d805a3e@textnews.eweka.nl> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Reedick, Andrew wrote: >> -----Original Message----- >> From: python-list-bounces+jr9445=att.com at python.org [mailto:python- >> list-bounces+jr9445=att.com at python.org] On Behalf Of Michel Bouwmans >> Sent: Wednesday, April 09, 2008 5:44 PM >> To: python-list at python.org >> Subject: RE: Stripping scripts from HTML with regular expressions >> >> >> Thanks! That did the trick. :) I was trying to use HTMLParser but that >> choked on the script-blocks that didn't contain comment-indicators. >> Guess I >> can now move on with this script, thank you. >> > > > Soooo.... you asked for help with a regex workaround, but didn't ask for > help with the original problem, namely HTMLParser? ;-) > > > > ***** > > The information transmitted is intended only for the person or entity to > which it is addressed and may contain confidential, proprietary, and/or > privileged material. Any review, retransmission, dissemination or other > use of, or taking of any action in reliance upon this information by > persons or entities other than the intended recipient is prohibited. If > you received this in error, please contact the sender and delete the > material from all computers. GA625 I don't think HTMLParser was doing anything wrong here. I needed to parse a HTML document, but it contained script-blocks with document.write's in them. I only care for the content outside these blocks but HTMLParser will choke on such a block when it isn't encapsulated with HTML-comment markers and it tries to parse the contents of the document.write's. ;) MFB -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFH/kvEDpaqHmOKFdQRAgHgAJ4s2YUN6yynUS+8aunhVUR94rs2yQCgrn94 tAFx/dylzEI0TclRDSTRbJI= =k8SN -----END PGP SIGNATURE----- From paul.anton.letnes at gmail.com Tue Apr 15 05:40:27 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Tue, 15 Apr 2008 11:40:27 +0200 Subject: How to import C++ static library? In-Reply-To: <66j9r8F2k2iplU1@mid.uni-berlin.de> References: <66j9r8F2k2iplU1@mid.uni-berlin.de> Message-ID: <0C2703E6-8EBC-40D5-A931-30ABF49B9333@gmail.com> Den 15. april. 2008 kl. 11.11 skrev Diez B. Roggisch: > Alexander Dong Back Kim wrote: > >> Hi all, >> >> I'm very very beginner of python but I'm dare to ask this question >> straight away. =P >> >> Is it possible to import C++ static library compiled by GCC? The >> target is definitely Linux machine. >> >> I found some examples from Google showing the way C++ can import >> Python so called embedded python. But I want to the opposite way of >> this. I want to import (or include in C world terminology) the >> library >> which is a blah.a file to reuse in python. >> >> Any suggestion or idea for this stupid beginner? ;) > > For C++, you need to create a wrapping using C++ wrapper tools. > There are a > few available: SWIG, Boost::Python and SIP. > > I can only comment personally on the latter - and can recommend it > without > any doubt. > > Diez > -- > http://mail.python.org/mailman/listinfo/python-list Diez: I tried SWIG, and it works nicely with C. For C++, I didn't manage to make it work. I tried SIP; I have some problems compiling etc. Would it be too much to ask you to supply a working example of a (simple, stupid) C++ class and the necessary SIP files? Preferably for Mac OS X, but Linux is also interesting I guess. Cheers Paul. From rocco.rossi at gmail.com Wed Apr 23 10:17:46 2008 From: rocco.rossi at gmail.com (rocco.rossi at gmail.com) Date: Wed, 23 Apr 2008 07:17:46 -0700 (PDT) Subject: Python generators (coroutines) Message-ID: I would really like to know more about python 2.5's new generator characteristics that make them more powerful and analogous to coroutines. Is it possible for instance to employ them in situations where I would normally use a thread with a blocking I/O (or socket) operation? If it is, could someone show me how it can be done? There appears to be a very limited amount of documentation in this repect, unfortunately. Thank you. From s0suk3 at gmail.com Sat Apr 19 08:44:01 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Sat, 19 Apr 2008 05:44:01 -0700 (PDT) Subject: winreg module, need help to understand why i'm getting exception References: <194c4200-b388-429c-9341-28c96f27a9a7@m73g2000hsh.googlegroups.com> Message-ID: Sorry, the above post is not complete. This is the rest: # There should be a for or a while loop around here try: name = _winreg.EnumValue(key, index) except EnvironmentError: # It raises WindowsError, but the _winreg documentation # recommends catching EnvironmentError break else: # do something with 'name' ... Anyway, I'd recommend using _winreg instead of the module you're using, since it clearly has errors, and it's not on the standard library. From skanemupp at yahoo.se Sat Apr 12 16:50:36 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 12 Apr 2008 13:50:36 -0700 (PDT) Subject: toplevel, get latest entry? Message-ID: windows vista and python 2.5, is there a way to get the latest command entered? would be very useful. if not by default, anything i could download or write myself? From namesagame-usenet at yahoo.com Wed Apr 9 17:54:18 2008 From: namesagame-usenet at yahoo.com (gamename) Date: Wed, 9 Apr 2008 14:54:18 -0700 (PDT) Subject: Not Sure This Can Be Done... References: <46aeae28-4470-4136-a5f6-040f6468eb32@b5g2000pri.googlegroups.com> <170a668f-4a65-471f-ad03-03231235b314@e6g2000prf.googlegroups.com> Message-ID: Hi, In hopes it may help someone else, here's what I ended up doing: 1) Add this to to point to your local 'tools' directory: import site # the python tools dir is at "../../tools/python" site.addsitedir('..'+os.sep+'..'+os.sep+'tools'+os.sep +'python') 2) In the 'tools' dir, there is a file called 'local.pth'. Its contents: # the individual modules are at "../../tools/python/modules/ " ./modules/pexpect 3) In the script you can now do: import pexpect That's it. This works fine, but there are still 2 outstanding issues: A) How do make the same ".pth" file usable on a win32 environment? The path separators are different (i.e. "/" vs "\"). B) How to auto-include any subdirectory in 'python/modules' so that each new module dir doesn't have to be added manually? That is, if package 'foo' is added, it would be in 'python/modules/foo'. Is there a way to avoid manually putting that in the '.pth'? FYI, -T From bg at bg.fr Tue Apr 8 11:56:55 2008 From: bg at bg.fr (Bruno GUERPILLON) Date: Tue, 8 Apr 2008 17:56:55 +0200 Subject: List open files References: <47fb8d54$0$15068$426a74cc@news.free.fr> <2af7d536-eb72-4e6d-96ca-3c91455b06b9@a9g2000prl.googlegroups.com> Message-ID: <47fb96c2$0$7182$426a74cc@news.free.fr> "Miki" a ?crit dans le message de news: 2af7d536-eb72-4e6d-96ca-3c91455b06b9 at a9g2000prl.googlegroups.com... > Hello Bruno, > >> I'd like, in a WIN32 environment, list all open files. >> Anyone got a clue how to do this ? > Have a look at the sysinternals suite (http://technet.microsoft.com/en- > us/sysinternals/0e18b180-9b7a-4c49-8120-c47c5a693683.aspx), you might > find stuff there that will help you. > > HTH, > -- > Miki > http://pythonwise.blogspot.com Thanks Miki, Well, i think i'll use handle.exe from sysinternals and parse the input. Regards, From chrishenry.ni at gmail.com Sat Apr 26 01:55:32 2008 From: chrishenry.ni at gmail.com (Chris Henry) Date: Fri, 25 Apr 2008 22:55:32 -0700 (PDT) Subject: multiple pattern regular expression References: Message-ID: On Apr 25, 8:37?pm, Arnaud Delobelle wrote: > micron_make writes: > > I am trying to parse a file whose contents are : > > > parameter=current > > max=5A > > min=2A [snip] > If every line of the file is of the form name=value, then regexps are > indeed not needed. ?You could do something like that. > > params = {} > for line in file: > ? ? name, value = line.strip().split('=', 2) > ? ? params[name] = value > > (untested) > Then params should be the dictionary you want. > I'm also interested in this problem. While this solution works, I'm looking for solution that will also check whether the parameter name/ value is of a certain pattern (these patterns may be different, e.g. paramA, paramB, paramC may take integers value, while paramD may take true/false). Is there a way to do this easily? I'm new to Python and the solution I can think off involve a loop over a switch (a dictionary with name->function mapping). Is there other, more elegant solution? Chris From namesagame-usenet at yahoo.com Tue Apr 29 14:59:25 2008 From: namesagame-usenet at yahoo.com (gamename) Date: Tue, 29 Apr 2008 11:59:25 -0700 (PDT) Subject: Sending Cntrl-C ?? Message-ID: <0274834e-17e1-4a95-88ec-f2aa77aeb3a9@k10g2000prm.googlegroups.com> Hi, I really like this recipe for controlling subprocesses: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554 However, I can't figure out how I can send the equivalent of "Cntrl-C" to the subprocess. How can that be done? TIA, -T From deets at nospam.web.de Tue Apr 29 10:48:19 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Tue, 29 Apr 2008 16:48:19 +0200 Subject: list.reverse() In-Reply-To: References: <4816e26a$0$30938$426a74cc@news.free.fr> Message-ID: <67oqpjF2nsikiU1@mid.uni-berlin.de> > > The reasoning goes along the lines of, "reverse in place is an expensive > operation, so we don't want to make it too easy for people to do". At > least that's the gist of what I got out of the argument the many times it > has come up. It's not about the storage - it is about the in-place-modification. The reasioning is that people otherwise could assume that a = [1, 2] b = a.reverse() assert a[0] == 1 and b[0] == 2 would hold, but instead of course "a" is changed. Using reversed as b = reversed(a) will make that assumption hold. Diez From steve at holdenweb.com Fri Apr 25 09:24:55 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 25 Apr 2008 09:24:55 -0400 Subject: Is 2006 too old for a book on Python? In-Reply-To: References: Message-ID: jmDesktop wrote: > Hi, I wanted to buy a book on Python, but am concerned that some of > them are too old. One I had come to after much research was Core > Python by Wesley Chun. I looked at many others, but actually saw this > one in the store and liked it. However, it is from 2006. I know > there is free documentation and Dive Into Python. I just liked the > one in question and was hoping for thoughts on the age of it. I am > using Python 2.5.x and don' t know how different 2.3, 2,4 is from it. Buy it if you like it (and lots of people do). Less than 1% of the language changes between releases. You'll pick the rest up here! regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From jarausch at skynet.be Wed Apr 23 11:32:13 2008 From: jarausch at skynet.be (Helmut Jarausch) Date: Wed, 23 Apr 2008 17:32:13 +0200 Subject: Script to convert Tcl scripts to Python? In-Reply-To: References: Message-ID: <480f567e$0$2954$ba620e4c@news.skynet.be> Achillez wrote: > Hi, > > I have a 10k+ line Tcl program that I would like to auto convert over to > Python. Do any scripts exist that can convert ~90% of the standard Tcl > syntax over to Python? I know Python doesn't handle strings, but just for > general syntax e.g., puts > print, expr > math operations > I asked a similar question some time ago. The summary was - don't do it! Instead, a Tcl interpreter could be loaded and given the job to do. I think that's similar to what Tkinter does. -- Helmut Jarausch Lehrstuhl fuer Numerische Mathematik RWTH - Aachen University D 52056 Aachen, Germany From upton at virginia.edu Wed Apr 16 14:10:28 2008 From: upton at virginia.edu (Dan Upton) Date: Wed, 16 Apr 2008 14:10:28 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <5504f9ac0804161110u664dd46bx5c2f9ac0a6ecb0c7@mail.gmail.com> On Wed, Apr 16, 2008 at 1:49 PM, Mike Driscoll wrote: > On Apr 16, 12:40 pm, "D'Arcy J.M. Cain" wrote: > > I don't think I like the email list idea all that much. I'm already on > a number of them and they fill up my box like crazy. Besides that, in > email format it's hard to follow the thread, so one moment I'm reading > about the latest ding dong and the next is a response to a post from > last week. Maybe a thread bashing google "gorups" is a bad place to make this comment, but Gmail organizes the threads so it's easy to follow threads in mailing list conversations. (And I see you're posting from a gmail address, so...) Thunderbird is capable of grouping mailing list messages by thread too, and I can only assume Outlook Express is as well. The recent deluge of spam has gone straight to my junk mail box, and Gmail's spam filter only incorrectly flags as spam about one python-list message per week--maybe instead of ignoring all posts from Google users, you just need a better spam filter. From goldtech at worldpost.com Wed Apr 9 11:33:35 2008 From: goldtech at worldpost.com (goldtech) Date: Wed, 9 Apr 2008 08:33:35 -0700 (PDT) Subject: String manipulation questions References: <8cd7b477-6fc6-47c5-b2eb-e2a4f284f7b2@m3g2000hsc.googlegroups.com> Message-ID: <3545a1f2-fff0-4226-aca1-39dfa70d94ef@x41g2000hsb.googlegroups.com> snip... > > for counter, line in enumerate(fileIN): > newline = line.replace(oldstring, newstring) > if newline != line: > print 'match at line', counter+1 > fileOUT.write(newline) "enumerate" - haven't seen that before. Nice! Thanks From sam at mas.pl Thu Apr 3 04:07:38 2008 From: sam at mas.pl (sam) Date: Thu, 03 Apr 2008 10:07:38 +0200 Subject: Prototype OO In-Reply-To: References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> Message-ID: bruno.desthuilliers at gmail.com napisa?(a): > So, while I often use Python's lambdas, the imposed limitations is ok > to me since I wouldn't use it for anything more complex. > Also - as a side note - while the syntax is a bit different, the > resulting object is an ordinary function. And people start asking why this is that or the other way in Python, and you can't give a good answer to newcomers, especially if Python was chosen as a first learning language. You can't tell "because Python's parsing mechanism don't allow statements in expressions...". >> But somebody may prefix his names with class names and cause nameconflict, > > Here the problem is more philosophical than anything else. Almost the whole discussion is philosofical, but clear philosophy is a good thing. > It's enough. FWIW, I'm not sure I had a use-case for this feature more > than a couple time in 7+ years. > Simple, indeed. But why "not perfect" ? What else would you want ? I would expect you to told me at the beginning that this is enough to solve the problem and that somebody can still cause name conflict, but Python was built for wise people. From frikker at gmail.com Mon Apr 28 13:23:02 2008 From: frikker at gmail.com (blaine) Date: Mon, 28 Apr 2008 10:23:02 -0700 (PDT) Subject: Regular Expression - Matching Multiples of 3 Characters exactly. References: Message-ID: <68e62e2f-2753-4cce-b4a2-3fe24f64c2b0@34g2000hsh.googlegroups.com> On Apr 28, 6:30 am, Nick Craig-Wood wrote: > blaine wrote: > > I'm trying to write a string matching algorithm for genomic > > sequences. I'm pulling out Genes from a large genomic pattern, with > > certain start and stop codons on either side. This is simple > > enough... for example: > > > start = AUG stop=AGG > > BBBBBBAUGWWWWWWAGGBBBBBB > > > So I obviously want to pull out AUGWWWWWWAGG (and all other matches). > > This works great with my current regular expression. > > > The problem, however, is that codons come in sets of 3 bases. So > > there are actually three different 'frames' I could be using. For > > example: > > ABCDEFGHIJ > > I could have ABC DEF GHI or BCD EFG HIJ or CDE FGH IJx.... etc. > > > So finally, my question. How can I represent this in a regular > > expression? :) This is what I'd like to do: > > (Find all groups of any three characters) (Find a start codon) (find > > any other codons) (Find an end codon) > > > Is this possible? It seems that I'd want to do something like this: (\w > > \w\w)+(AUG)(\s)(AGG)(\s)* - where \w\w\w matches EXACTLY all sets of > > three non-whitespace characters, followed by AUG \s AGG, and then > > anything else. > > I'm not sure what the \s are doing in there - there doesn't appear to > be any whitespace in your examples. > > > I hope I am making sense. Obviously, however, this will make sure > > that ANY set of three characters exist before a start codon. Is > > there a way to match exactly, to say something like 'Find all sets > > of three, then AUG and AGG, etc.'. > > I think you want > > ^(\w\w\w)*(AUG)((\w\w\w)*?)(AGG) > > which will match up 0 or more triples, match AUG match 0 or more triples > then AGG. The ? makes it a minimum match otherwise you'll match more > than you expect if there are two AUG...AGG sequences in a given genome. > > >>> import re > >>> m=re.compile(r"^(\w\w\w)*(AUG)((\w\w\w)*?)(AGG)") > >>> m.search("BBBBBBAUGWWWWWWAGGBBBBBB").groups() > ('BBB', 'AUG', 'WWWWWW', 'WWW', 'AGG') > >>> m.search("BBBQBBBAUGWWWWWWAGGBBBBBB") > >>> m.search("BBBQQBBBAUGWWWWWWAGGBBBBBB") > >>> m.search("BBBQQBBQBAUGWWWWWWAGGBBBBBB") > <_sre.SRE_Match object at 0xb7de33e0> > >>> m.search("BBBQQBBQBAUGWWWWWWAGGBBBBBB").groups() > ('BQB', 'AUG', 'WWWWWW', 'WWW', 'AGG') > >>> m.search("BBBQQBBQBAUGWQWWWWWAGGBBBBBB") > >>> m.search("BBBQQBBQBAUGWWWWQWWAGGBBBBBB") > >>> m.search("BBBQQBBQBAUGWWQWWQWWAGGBBBBBB") > >>> m.search("BBBQQBBQBAUGWWQWAWQWWAGGBBBBBB") > <_sre.SRE_Match object at 0xb7de33e0> > >>> m.search("BBBQQBBQBAUGWWQWAWQWWAGGBBBBBB").groups() > ('BQB', 'AUG', 'WWQWAWQWW', 'QWW', 'AGG') > >>> > > > This way, I could scan for genes, remove the first letter, scan for > > more genes, remove the first letter again, and scan for more genes. > > This would hypothetically yield different genes, since the frame > > would be shifted. > > Of you could just unconstrain the first match and it will do them all > at once :- > > (AUG)((\w\w\w)*?)(AGG) > > You could run this with re.findall, but beware that this will only > return non-overlapping matches which may not be what you want. > > I'm not sure re's are the best tool for the job, but they should give > you a quick idea of what the answers might be. > > -- > Nick Craig-Wood --http://www.craig-wood.com/nick Thank you! Your suggestion was overly helpful. Also thank you for the package suggestions. BioPython is on my plate to check out, but I needed a kind of quick fix for this one. The documentation for biopython seems pretty thick - I'm not a biologist so I'm not even sure what kind of packages I'm even looking for. thanks! Blaine From wizzardx at gmail.com Fri Apr 25 15:31:25 2008 From: wizzardx at gmail.com (David) Date: Fri, 25 Apr 2008 21:31:25 +0200 Subject: Setting expirty data on a cookie In-Reply-To: <80818edd-37dd-4306-8723-97db63afd5fb@z72g2000hsb.googlegroups.com> References: <8ba48e05-9aba-4a56-805c-cd31b43517ab@24g2000hsh.googlegroups.com> <80818edd-37dd-4306-8723-97db63afd5fb@z72g2000hsb.googlegroups.com> Message-ID: <18c1e6480804251231q43c75606paa7df0cf816ad507@mail.gmail.com> > import Cookie > import time > c = Cookie.SimpleCookie() > c['data'] = "unamepwordwhatever" > c['data']['expires'] = 30 * 24 * 60 * 60 > print c > > Gives an output of: > > "Set-Cookie: data=unamepwordwhatever; expires=Sat, 24-May-2008 > 12:11:36 GMT" > Hi again. I didn't see your replies until now. Disclaimer: I've never worked with cookies before, I'm just going by the rfc, python docs, and wikipedia. I think the confusion exists because the Cookie module has an unusual definition of cookies. What we call cookies (key + value + attributes), the Cookie module calls a Morsel. What the Cookie module calls a cookie is in fact the collection of Set-Cookie headers that will be sent by the server. So for code like this: c = Cookie.SimpleCookie() c['data1'] = 123 c['data2'] = 456 the server will output 2 cookies like this: Set-Cookie: data1=123 Set-Cookie: data2=456 This is why when you want to set the expiry date for one of the cookies, you need syntax like this: c['data2']['expires'] = 30 * 24 * 60 * 60 Another note: 'expires' is apprantly a legacy attribute for early Netscape browsers. The RFC and python source comments suggest that you use 'Max-Age' instead. I think that the Cookie module author wanted to represent http state as a python dictionary, but chose an unfortunate name for the class. Also, the example page doesn't go into detail about setting attributes. David. From uniontelecardsindia at gmail.com Tue Apr 22 17:15:41 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:15:41 -0700 (PDT) Subject: Gay hunks spreading legs for butt fucking outdoors Message-ID: <528b67cb-575b-4b5d-8462-6593e8d6fe9f@b64g2000hsa.googlegroups.com> Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From alimamatrade at msn.com Sat Apr 5 07:31:56 2008 From: alimamatrade at msn.com (www.alimamatrade.net) Date: Sat, 5 Apr 2008 04:31:56 -0700 (PDT) Subject: low price high quality items whosale & resale at www.alimamatrade.net Message-ID: <5e4fe21e-ca86-4566-82ea-580e8e96c0af@p39g2000prm.googlegroups.com> we would give our lowest price, www.alimamatrade.net 1. Before shipping the goods ,we check the cutting/stitching/high frequency/embroidery/assembly/cement carefully, until the goods are OK. 2. payment:western union,moneygram,bank transfer (T/T by bank). 3. shipping method:EMS,TNT,DHL other shipping as you prefer. 4. we provide best quality and competetive price to our customers, sample order & drop shipment are OK. Minimum order quantity is 1 delivery time is 4-6 days, send the goods door to door. if you have any other questions,welcome to contact me at any time. TKS! Shoes: Adidas Shoes, Bape Shoes, Boots, CA shoes, Chanel shoes, clarks shoes, Converse Shoes, D & G shoes, Diesel Shoes, Dior shoes, Dirk shoes, Dsquared2 shoes, Edhardy shoes, Evisu Shoes, Gucci Shoes, Hogan Shoes, Icecream shoes, Kappa shoes, kid shoes, Lacoste Shoes, Levi's shoes, LV Shoes, Nike air force one, Nike Air Jordan, Nike Air Max, Nike Air Rift, Nike Air Shox, Nike Dunk, Nike James, paioctti-4us, Prada shoes, Puma Shoes, Sand Shoes, sandals, Soccer, Timberland shoes, Versace shoes Apple ipods: MP3, MP4, ipod touch, ipod nano, ipod vedio, Bags: T-shirts: Underwear: Hoodies: Caps: Jeans: Belts: Wallets: Watches: Mobile phones: Blackberry phone, htc tytn phone, iphone, LG phone, LV phone, MOTO, Nokia 6300, Nokia 7500, Nokia E65, Nokia E90, Nokia N70, Nokia N71, Nokia N72, Nokia N73, Nokia N76, Nokia N77, Nokia N80, Nokia N81, Nokia N90, Nokia N91, Nokia N92, Nokia N93, Nokia N95, Nokia N99, Nokia N8600, NOKIA N8800, Nokia Vertu, PDA, Sony Eriosson, sumsing Perfume: Sunglasses: www.alimamatrade.net From balta96428 at gmail.com Wed Apr 23 05:55:31 2008 From: balta96428 at gmail.com (balta96428 at gmail.com) Date: Wed, 23 Apr 2008 02:55:31 -0700 (PDT) Subject: topical analgesic salonpas-hot capsicum patch Message-ID: topical analgesic salonpas-hot capsicum patch http://cracks.12w.net F R E E C R A C K S From mblume at freesurf.ch Wed Apr 23 12:27:33 2008 From: mblume at freesurf.ch (Martin Blume) Date: Wed, 23 Apr 2008 18:27:33 +0200 Subject: Unix Device File Emulation References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> Message-ID: <480f6376$0$9037$5402220f@news.sunrise.ch> "blaine" schrieb > > # Fake Nokia Screen Emulator > import sys, os > > class nokia_fkscrn: > def __init__(self, file): > if not os.path.exists(file): > os.mkfifo(file) > self.fifodev = open(file, 'r') > def read(self): > while 1: > r = self.fifodev.readline() > print r > > nokia = nokia_fkscrn('dev.file') > nokia.read() > > This works at first, but when I write to the 'dev.file' > for the first time, the text is displayed as intended, > but then the program just keeps spitting out blank lines. > I can continue to write to the file > (using echo 'test\n' > dev.file) > and this shows up in my output, but amist a giant mass > of scrolling blank lines. This also causes my CPU > usage to shoot up to 100%. > > Any ideas? This is OS X 10.4 > while 1: r = self.fifodev.readline() if r: print r According to my docs, readline() returns an empty string at the end of the file. Also, you might want to sleep() between reads a little bit. IMHO. HTH. Martin From ptmcg at austin.rr.com Thu Apr 17 09:05:54 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Thu, 17 Apr 2008 06:05:54 -0700 (PDT) Subject: Metaprogramming Example References: <930643c6-2d56-4fb0-aee0-a3e79231f09b@24g2000hsh.googlegroups.com> <32472b97-f35a-4408-96f5-2f8c8f92ae56@m73g2000hsh.googlegroups.com> Message-ID: On Apr 17, 7:25?am, andrew cooke wrote: > On Apr 17, 7:12 am, "bruno.desthuilli... at gmail.com" wrote: > > One other question. ?I had "foo is False" and you said I need > equality, which is a good point. ?However, in any other language "not > foo" would be preferable. ?I was surprised you didn't suggest that > (and I'm unsure now why I didn't write it that way myself). ?Is there > some common Python standard that prefers "foo == False" to "not foo"? > In addition to the problematic "foo is False" test, Bruno was also saying that assertions of True tend to be more readable than negated assertions of False. In your original, you were testing for not P or not Q, Bruno recoded this to the equivalent not(P and Q). That is, the direct way to change the 'is' identity testing to equality testing would have been: if (not self.ignore_identical or new_value != obj._auto_write_dict[self.name]): But Bruno further changed this to: if not (self.ignore_identical and new_value == obj._auto_write_dict[self.name]): -- Paul From ch612bunn at gmail.com Sun Apr 27 09:19:56 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:19:56 -0700 (PDT) Subject: Adobe Premiere CS3 crack Message-ID: <4d720d12-9877-46d4-a1ba-e522b7c015db@m36g2000hse.googlegroups.com> Adobe Premiere CS3 crack http://wga-cracks.crackkey.net From stanc at al.com.au Thu Apr 3 18:58:37 2008 From: stanc at al.com.au (Astan Chee) Date: Fri, 04 Apr 2008 09:58:37 +1100 Subject: sine in python Message-ID: <47F5611D.3090900@al.com.au> Hi, I have a math function that looks like this sin (Theta) = 5/6 How do I find Theta (in degrees) in python? I am aware of the math.sin function, but is there a reverse? maybe a sine table in python? Thanks Astan -- "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." Animal Logic http://www.animallogic.com Please think of the environment before printing this email. This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. From marli305nugent at gmail.com Sat Apr 26 09:53:02 2008 From: marli305nugent at gmail.com (marli305nugent at gmail.com) Date: Sat, 26 Apr 2008 06:53:02 -0700 (PDT) Subject: crack cocaine pictures Message-ID: crack cocaine pictures http://cracks.00bp.com F R E E C R A C K S From rtw at freenet.co.uk Fri Apr 11 18:34:38 2008 From: rtw at freenet.co.uk (Rob Williscroft) Date: Fri, 11 Apr 2008 17:34:38 -0500 Subject: https and POST method References: <7956f925-1037-49ea-a360-b58d627ffb20@z24g2000prf.googlegroups.com> Message-ID: Lorenzo Stella wrote in news:7956f925-1037-49ea-a360-b58d627ffb20 @z24g2000prf.googlegroups.com in comp.lang.python: > Hi all, > I'm trying to write a simple script for sending sms via vyke... I have > to make a https > connection and pass some data with the POST method, like this perl > script does: Curl maybe, http://pycurl.sourceforge.net/ Rob. -- http://www.victim-prime.dsl.pipex.com/ From tall2200 at gmail.com Thu Apr 17 06:53:05 2008 From: tall2200 at gmail.com (kkkk) Date: Thu, 17 Apr 2008 03:53:05 -0700 (PDT) Subject: New youtube video Message-ID: New youtube video http://www.youtube.com/watch?v=tWxFZRgh664 http://www.youtube.com/watch?v=K20FaUQpCEk http://www.youtube.com/watch?v=sSutNlV4Tq0 http://www.youtube.com/watch?v=1P8wqWC7ISE http://www.youtube.com/watch?v=wS1hPZiuXnk http://www.youtube.com/watch?v=wgkDtlod8Wg http://www.youtube.com/watch?v=ZN7NvdrF_Ok http://www.youtube.com/profile_videos?user=dream2008land&p=r From tinnews at isbd.co.uk Thu Apr 3 09:00:15 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 03 Apr 2008 13:00:15 GMT Subject: A question about creating Maildir mailboxes with mailbox.Maildir Message-ID: <47f4d4df$0$712$bed64819@news.gradwell.net> I have mail delivered into Maildirs which live in a directory hierarchy as follows:- /home/isbd/Mail/Li/ /home/isbd/Mail/In/ Note that neither /home/isbd/Mail/Li nor /home/isbd/Mail/In are Maildir mailboxes. How do I create a new Maildir mailbox in either Li or In with mailbox.Maildir.add_folder()? If I have created an instance of Maildir with:- md = mailbox.Maildir("/home/isbd/Mail/Li") that implies that /home/isbd/Mail/Li is a Maildir, which it isn't, and anyway the above fails because it can't see the new, cur and tmp directories in /home/isbd/Mail/Li. It seems that the Python Maildir implementation assumes a Courier style (probably IMAP) Maildir hierarchy with an INBOX and using dots rather than real directories to create sub-directories. I don't have an INBOX or any sort of 'home' maildir, it's most definitely not a requirement of maildir. -- Chris Green From mccle27252 at gmail.com Mon Apr 21 03:51:44 2008 From: mccle27252 at gmail.com (mccle27252 at gmail.com) Date: Mon, 21 Apr 2008 00:51:44 -0700 (PDT) Subject: cracked skin on fingers Message-ID: <04ff3458-b01e-42f0-8f15-2c8fc7b2b32a@b9g2000prh.googlegroups.com> cracked skin on fingers http://cracks.00bp.com F R E E C R A C K S From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 1 12:23:29 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 01 Apr 2008 18:23:29 +0200 Subject: Homework help In-Reply-To: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> References: <06dd172b-e789-409b-b4e9-364ed935205f@i29g2000prf.googlegroups.com> Message-ID: <47f2617f$0$15056$426a74cc@news.free.fr> bobby.connor at gmail.com a ?crit : > Hey guys > I haev this homework assignment due today Isn't it a bit too late to worry about it then ? From brian.e.munroe at gmail.com Thu Apr 24 17:18:01 2008 From: brian.e.munroe at gmail.com (Brian Munroe) Date: Thu, 24 Apr 2008 14:18:01 -0700 (PDT) Subject: Class Inheritance - What am I doing wrong? References: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> Message-ID: <613bc152-a6f4-4db4-8f90-593cb3f629c7@s33g2000pri.googlegroups.com> Ok, so thanks everyone for the helpful hints. That *was* a typo on my part (should've been super(B...) not super(A..), but I digress) I'm building a public API. Along with the API I have a few custom types that I'm expecting API users to extend, if they need too. If I don't use name mangling, isn't that considered bad practice (read not defensive programming) to not protect those 'private' fields? From lalitkrishna at gmail.com Thu Apr 24 10:27:36 2008 From: lalitkrishna at gmail.com (Lalit) Date: Thu, 24 Apr 2008 07:27:36 -0700 (PDT) Subject: NameError: global name 'Response' is not defined Message-ID: <1e84807c-aec0-4d04-97a3-1953719f4dc6@8g2000hse.googlegroups.com> Hi I am very new to web development. I started with Pylons. I am using http://www.rexx.com/~dkuhlman/pylons_quick_site.html as reference to create a sample web page using pylons. I got stuck up at step 4.3 i.e when modifying controller to "return Response('

firstapp default

')" I am getting error of : global name 'Response' is not defined It seems I am missing some package. I am not really sure. I installed python 2.5 and through easy_install imported pakages (pylons). Any clues would be appreciated Thanks Lalit From cyberco at gmail.com Wed Apr 16 07:44:41 2008 From: cyberco at gmail.com (Berco Beute) Date: Wed, 16 Apr 2008 04:44:41 -0700 (PDT) Subject: webcam (usb) access under Ubuntu References: <66jlk1F2ju6c8U1@mid.uni-berlin.de> <66kkedF2l526dU2@mid.uni-berlin.de> <455760fb-8229-4be3-ba7f-7c41bdcd66de@a22g2000hsc.googlegroups.com> <362eb242-2adc-4d7b-9c0a-95e72f4b22b6@e67g2000hsa.googlegroups.com> <66m26hF2lo3ghU1@mid.uni-berlin.de> Message-ID: <590f00ea-15d3-480a-9fa8-c28c32a292b2@e39g2000hsf.googlegroups.com> On Apr 16, 12:19 pm, "Diez B. Roggisch" wrote: > Maybe if you are now using windows, there are better options - but I'm a > *nix-boy :) > > Diez So am I :), but the application I'm writing has to run on *that other operating system from the 90's*. I'm trying hard not to implement the application in C#/.Net, but I'm running out of open source alternatives. VideoCapture *almost* worked and now I'm stranded at the gstreamer road as well... 2B From suzhi18 at googlemail.com Wed Apr 9 03:01:14 2008 From: suzhi18 at googlemail.com (suzhi18 at googlemail.com) Date: Wed, 9 Apr 2008 00:01:14 -0700 (PDT) Subject: makepy.py not working References: <03e9c33d-d957-4bc0-8568-3a40403eadb9@a70g2000hsh.googlegroups.com> Message-ID: <1803f997-739c-462d-955c-685374236f0b@m44g2000hsc.googlegroups.com> Ok, thanks for your help. After looking into the makepy.py file it was clear that this is only a command for the CMD console. I want to write a function which generates this .py file of the excel objects. I will now send the command to the CMD threw my python code. thanks again. suzhi From ott.deb at gmail.com Thu Apr 17 15:06:41 2008 From: ott.deb at gmail.com (ott.deb at gmail.com) Date: Thu, 17 Apr 2008 12:06:41 -0700 (PDT) Subject: smoking patch Message-ID: <8a6623c7-07f7-48bc-8305-8737cb240398@m73g2000hsh.googlegroups.com> smoking patch http://cracks.12w.net F R E E C R A C K S From marco at sferacarta.com Thu Apr 3 08:57:51 2008 From: marco at sferacarta.com (Marco Mariani) Date: Thu, 03 Apr 2008 14:57:51 +0200 Subject: who said python can't be obsfucated!? In-Reply-To: <47f4b69b$0$19766$426a74cc@news.free.fr> References: <47f4b69b$0$19766$426a74cc@news.free.fr> Message-ID: Bruno Desthuilliers wrote: > sig=lambda m:'@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p > in m.split('@')]) Pff... you call that a quicksort? From http://www.p-nand-q.com/python/obfuscated_python.html import sys funcs = range(10) def A(_,o): _[3]=_[5]() def B(_,o): o[_[2]]=_[9]() def C(_,o): _[3]=_[7]() def D(_,o): o[_[1]]=_[14]() def E(_,o): _[1]=_[4]() def F(_,o): _[2]=_[6]() def G(_,o,O): if _[O[0]]():return O[-1](_,o) or 1 def H(o, start, stop): _=[o[stop],[lambda x,y:x+y,lambda x,y:x-y,lambda x, y:y|1,0,0][1](start,funcs[4](range(funcs[3](), len(o[:])))),stop,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] for i in range(4,19): _[i]=lambda _=_,o=o,s="reduce([lambda x,y:x+y,lambda "\ "x,y:x-y,lambda x,y:y|1,0,0][0],[_[1],funcs[4]("\ "range(eval(\"funcs[3]()\"),_[10]()))])$funcs[4"\ "](range(eval(\"funcs[3]()\"),_[10]()))$[lambda"\ " x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,0,0][1]"\ "(_[2],funcs[4](range(funcs[3](),_[10]())))$fun"\ "cs[4](range(funcs[3](),_[10]()))$range(_[10]()"\ "*_[10]())$o[:][_[1]]$len(o[:])$not _[3]$_[1]=="\ "_[2]$o[:][_[1]]>_[0]$o[:][_[2]]$o[_[2]]<_[0]$_"\ "[2]==_[1]$_[11]() and not E(_,0) and not G(_,o"\ ",[12,A]) and not G(_,o,[13,B])$_[11]() and not"\ " F(_,_) and not G(_,o,[16,C]) and not G(_,o,[1"\ "5,D])".split('$')[:][i-4]:eval("eval('eval(s)')") while _[11](): while _[17](): pass while _[18](): pass o[_[2]] = _[0] return _[2] def quicksort(list,start,stop): exec('funcs[3] = lambda:reduce([lambda x,y:x+y,lambda x,y'\ ':x-y,lambda x,y:y|1,0,0][1],[[lambda x,y:x+y,lambda'\ ' x,y:x-y,lambda x,y:y|1,0,0][2](200,200)]*2)\nfuncs'\ '[4] = lambda x:reduce(lambda x,y:y%2,range(eval("re'\ 'duce([lambda x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,'\ '0,0][2],[len(o[:]),len(o[:])])"),eval("reduce([lamb'\ 'da x,y:x+y,lambda x,y:x-y,lambda x,y:y|1,0,0][2],[l'\ 'en(o[:]),len(o[:])])")+((len(o)and 3)or 3)))\nif st'\ 'art < stop:\n\tsplit = H(list, start, stop)\n\tquic'\ 'ksort(list, start, [lambda x,y:x+y,lambda x,y:x-y,l'\ 'ambda x,y: y|1,0,0][1](split,funcs[4](funcs[3]())))'\ '\n\tquicksort(list, reduce([lambda x,y:x+y,lambda x'\ ',y:x-y,lambda x,y:y|1,0,0][0],[split,funcs[4](funcs'\ '[3]())]), stop)\n') # test code: 2000 elements to sort list = [] import whrandom,time for i in range(2000): list.append(whrandom.randint(1,100)) start = time.clock() quicksort(list,0,len(list)-1) print "Sorting took %.2f" % (time.clock() - start) # just a test loop to see if everything *is* sorted element = -1 for i in list: if i >= element: element = i else: print "FUNK DAT: %20s" % str(i) break From bj_666 at gmx.net Sun Apr 27 12:36:22 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 27 Apr 2008 16:36:22 GMT Subject: convert images References: Message-ID: <67joc5F2o7iv7U1@mid.uni-berlin.de> On Sun, 27 Apr 2008 06:42:13 -0700, wilson wrote: > i converted some P5 type .pgm images to .jpg using > [?] > ie if oldimage.pgm has pixels > [29 31 38 ..., 10 4 18] > then the corresponding jpg image has > [29 31 38 ..., 10 3 17] > > why this difference? shouldn't they be identical?can someone pls > explain this? JPEG uses a lossy compression algorithm, i.e. the image loses quality and therefore the pixel values are not exactly the same as before saving. If you want get the exact values back you have to use another image format. For RGB or RGBA data PNG is a good format. Ciao, Marc 'BlackJack' Rintsch From aaron.watters at gmail.com Thu Apr 24 21:48:51 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Thu, 24 Apr 2008 18:48:51 -0700 (PDT) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: <83ab3b9e-078c-4f5c-82ab-dafd41339dc1@u36g2000prf.googlegroups.com> On Apr 24, 10:10?am, Paul McGuire wrote > end point applications (I consider maintaining 2 branches to be in the > "not working" category), but it does NOT WORK for people who maintain > modules for other people to use, because those people may be on a > range of Python versions that extend beyond 2.6-3.0. ?So if I upgrade > my module to 2.6, those running on earlier versions can no longer use > it. ?At some point in the future, I'll probably be able to say "no > more support for pre-2.6", but it is a bit early to start saying that > now. In my view using a conversion tool on an ongoing basis is not an option. It just adds a dependancy. What happens when the conversion tool is upgraded in a non-backwards-compatible way? Or do we have assurance that it won't be ;)? Will changes to the converter mean that the users of my converted libraries have to start using my tools in a different way? Even if it breaks some users in a very subtle way it's not acceptible. I have no interest in adding additional dependancies, with an additional degree of freedom to break. This is all made worse because it's binary -- with upgrades to C or C# you usually had the option of cross linking between old style components and new style components (and at least with C these could usually be made to work) and you could port the older stuff with care. With py 3.0 and python 2.6 *everything* either works with the interpreter or none of it does. (Don't ask my users to install two interpreters: they'll just give up and use something else.) So if I want to support both I have to do everything twice in the expected case and in the best case test everything twice, at the same time, if I want to support both versions and keep features in sync. This is of course assuming that all the supporting libraries do the same thing. If they don't and one of the libraries doesn't support 2.* and another doesn't support 3.*... I guess I'm just screwed. I still think it's a shame, and I think it's different in kind from python 1.x->2.x. 2.x broke very little as I recall. Most 1.x code just worked in 2.x and most of the rest required very minor change. I think this is not the case for 2.x->3.x. -- Aaron (Scummy) Watters, hoping to shut up now. ps: I didn't notice that % was vanishing later (3.3). that's a bit better (whew ;) ). pps: I have to note that it would be nice if the ad-hominem (sp?) invective would drop out of these threads -- it doesn't add a lot, I think. === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=garbage+left+over From george.sakkis at gmail.com Tue Apr 1 09:15:20 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Tue, 1 Apr 2008 06:15:20 -0700 (PDT) Subject: troll poll References: <65eee6F2eg18jU1@mid.uni-berlin.de> Message-ID: On Apr 1, 5:43 am, "Diez B. Roggisch" wrote: > Delaney, Timothy (Tim) wrote: > > George Sakkis wrote: > > >> On Mar 31, 1:46 pm, Marc 'BlackJack' Rintsch wrote: > > >>>> More specifically, who can create a bigger mess on c.l.py? (check > >>>> one) > > >>>> [ ] - Xah Lee > >>>> [X] - castironpi > > >>> Xah Lee's postings might be trolls but sometimes they spark some > >>> really interesting and serious subthreads, while the nonsense of > >>> castironpi is just irritating noise. > > >> Which is exactly why there are rarely any replies to his random > >> gibberish, so I would say that he/she/it has almost no effect on > >> c.l.py. Yet I wish plonking was possible through Google groups. > > > I find classifying all their posts as spam works fairly well. > > I'm also astonished - once I figured out how this knode works regarding > killfiles, all I get to see from them is the occasional citation. > > The only irritating thing is if castironpi answers to one of *my* posts, and > somebody else tells him to shut up... which then appears below my post in > my reader ... > > diez Wow, thanks to this thread I discovered the Google Groups KillFile, a firefox+greasemonkey killfile script (http://www.penney.org/ ggkiller.html). Hope it works as advertised! George From jeffrey at fro.man Tue Apr 8 11:49:26 2008 From: jeffrey at fro.man (Jeffrey Froman) Date: Tue, 08 Apr 2008 08:49:26 -0700 Subject: list.sort(): heaviest item? References: Message-ID: <9vCdnb4PB5-bCWbanZ2dnUVZ_uidnZ2d@cablespeedwa.com> Steven Clark wrote: > If I have a list of items of mixed type, can I put something into it > such that after a list.sort(), is guaranteed to be at the end of the > list? > It looks like "None" always ends up at the start ("lightest"), but I > want the opposite ("heaviest"). I don't know of an object in the standard library that is guaranteed to be "heaviest", but it is trivial to create one: >>> class Heaviest(object): ... def __cmp__(self, other): ... return 1 ... >>> Heaviest = Heaviest() >>> L = [tuple(), list(), dict(), Heaviest, str(), int(), None] >>> L.sort() >>> L [None, 0, {}, [], '', (), <__main__.Heaviest object at 0xb7c04a8c>] Ordering with respect to another object that defines a similar __cmp__ function will still be arbitrary, but maybe you don't have to deal with any such objects ;-) Jeffrey From rowen at cesmail.net Tue Apr 29 12:10:00 2008 From: rowen at cesmail.net (Russell E. Owen) Date: Tue, 29 Apr 2008 09:10:00 -0700 Subject: Simple unicode-safe version of str(exception)? References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> <67on2nF2ol856U1@mid.individual.net> Message-ID: In article <67on2nF2ol856U1 at mid.individual.net>, Bjoern Schliessmann wrote: > "Martin v. L?wis" wrote: > > > e is an exception object, not a Unicode object. > > Er, sure, thanks for pointing that out. At first sight he should > substitute "e" with "e.message" then since he tries to convert to > string (for display?). No. e.message is only set if the exeption object receives exactly one argument. That is why my replacement code reads: errStr = ",".join([unicode(s) for s in f.args]) self.setState(self.Failed, errStr) (where e is an Exception of some kind) Notice that I'm iterating over the args. But again, this is far messier than: self.setState(self.Failed, str(e) So...to repeat the original question, is there any simpler unicode-safe replacement for str(exception)? -- Russell From zillow10 at googlemail.com Thu Apr 3 19:09:02 2008 From: zillow10 at googlemail.com (zillow10 at googlemail.com) Date: Thu, 3 Apr 2008 16:09:02 -0700 (PDT) Subject: sine in python References: Message-ID: <92f00617-28ee-4104-bd04-a48f87d84785@q27g2000prf.googlegroups.com> On Apr 3, 11:58 pm, Astan Chee wrote: > Hi, > I have a math function that looks like this > sin (Theta) = 5/6 > How do I find Theta (in degrees) in python? I am aware of the math.sin > function, but is there a reverse? maybe a sine table in python? > Thanks > Astan > > -- > "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." > > Animal Logichttp://www.animallogic.com > > Please think of the environment before printing this email. > > This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. import math If you now do dir(math) you'll see that the module has the functions 'asin' and 'degrees' that find the inverse sine of a number, and convert radians to degrees, respectively From __peter__ at web.de Sun Apr 13 03:17:35 2008 From: __peter__ at web.de (Peter Otten) Date: Sun, 13 Apr 2008 09:17:35 +0200 Subject: class level properties References: Message-ID: Charles D Hixson wrote: > I want a hundred or so read-only variables, and I'm not sure the best > way to achieve it. What do you really want to do? I recommend that you forget about bondage and rely upon displine: class Test(object): """Never change an attribute with an uppercase name.""" SIMPLE = "simple example working" Now that was easy... Peter From rowen at cesmail.net Tue Apr 29 12:16:21 2008 From: rowen at cesmail.net (Russell E. Owen) Date: Tue, 29 Apr 2008 09:16:21 -0700 Subject: Simple unicode-safe version of str(exception)? References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> Message-ID: In article , Donn Cave wrote: > In article <481650E3.4060603 at v.loewis.de>, > "Martin v. L?wis" wrote: > > > >> I have code like this: > > >> except Exception, e: > > >> self.setState(self.Failed, str(e)) > > >> which fails if the exception contains a unicode argument. > > > > > > Fails how? > > > > ASCII encoding error, I suppose. It fails only if a) one argument > > is a Unicode object, and b) that Unicode object contains non-ASCII > > parameters. > > Seem ironic that this fails even though pretty nearly anything > else is a valid input to str() -- socket, dict, whatever? I agree. In fact str(a) works if a is a dict or list that contains unicode data! Pity the same is not true of exceptions. Should I report this as a bug? I suspect it's a misfeature. > A sort of generic solution might be to follow str's behavior > with respect to '__str__', extending it to fall back to repr() > whatever goes wrong. > > > def xtr(a): > try: > return str(a) > except: > return repr(a) Yes. That is a more flexible alternative to what I've adopted: def exStr(ex): return ",".join([unicode(s) for s in f.args]) the latter gives better output for the case I'm interested in, but only handles exceptions. Oh well. I'll stick to my solution and hope that Python 2.6 and 3.0 fix the problem in a more sensible fashion. -- Russell From musiccomposition at gmail.com Mon Apr 14 22:47:00 2008 From: musiccomposition at gmail.com (Benjamin) Date: Mon, 14 Apr 2008 19:47:00 -0700 (PDT) Subject: about the ';' References: Message-ID: <4fe8b2be-f5e0-4656-b200-551777c924a5@m36g2000hse.googlegroups.com> On Apr 13, 10:33 pm, "Penny Y." wrote: > I saw many python programmers add a ';' at the end of each line. > As good style, should or should not we do coding with that? Where did you see that? > > Thanks. From gagsl-py2 at yahoo.com.ar Tue Apr 29 02:43:05 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 29 Apr 2008 03:43:05 -0300 Subject: descriptor & docstring References: Message-ID: En Tue, 29 Apr 2008 01:29:40 -0300, George Sakkis escribi?: > On Apr 28, 10:59?pm, "Gabriel Genellina" > >> def property_default(prop_name, default_value=None, doc=None): >> >> ? ? ?attr_name = '_'+prop_name >> >> ? ? ?def fget(self, attr_name=attr_name, >> ? ? ? ? ? ? ? ? ? ? default_value=default_value): >> ? ? ? ? ?return getattr(self, attr_name, default_value) >> >> ? ? ?def fset(self, value, >> ? ? ? ? ? ? ? ? ? ? attr_name=attr_name, >> ? ? ? ? ? ? ? ? ? ? default_value=default_value): >> ? ? ? ? ?if value == default_value: >> ? ? ? ? ? ? ?delattr(self, attr_name) >> ? ? ? ? ?else: >> ? ? ? ? ? ? ?setattr(self, attr_name, value) >> >> ? ? ?return property(fget=fget, fset=fset, doc=doc) >> >> When setting the same value as the default, the instance attribute is ? >> removed (so the default will be used when retrieving the value later). >> I think this is what you intended to do. > > Note that this will fail if the value is already equal to the default > and you try to reset it to the default, so it needs an extra > hasattr(self, attr_name) before the delattr. Regardless, I would be > surprised with the following behaviour: > >>>> r = Rectangle() >>>> r.length = 4 >>>> type(r.length) > >>>> r.length = 12 >>>> type(r.length) > Yep, probably the best thing to do is to always call setattr and avoid special cases. > Another simpler alternative would be to (ab)use a decorator: > > def defaultproperty(func): > attr = '_' + func.__name__ > default = func.func_defaults[0] > return property( > fget = lambda self: getattr(self, attr, default), > fset = lambda self,value: setattr(self, attr, value), > doc = func.__doc__) > > > class Rectangle(object): > '''A beautiful Rectangle''' > > @defaultproperty > def length(default=12.0): > '''This is the length property''' Nice, although that empty function looks somewhat strange... -- Gabriel Genellina From blog630 at watchesblog.cn Wed Apr 23 13:20:47 2008 From: blog630 at watchesblog.cn (blog630 at watchesblog.cn) Date: Wed, 23 Apr 2008 10:20:47 -0700 (PDT) Subject: OEM Handheld Mics - Chinese Handheld Mics Manufacturer Message-ID: <38b8cd08-92d0-4e43-9731-81386e7cc7d7@u12g2000prd.googlegroups.com> OEM Handheld Mics - Chinese Handheld Mics Manufacturer Handheld Microphone WebSite Link: http://www.chinese-microphone.com/Handheld-Microphones.html China GuangZhou TianTuo Microphone Manufacturing Co., Ltd WebSite: http://www.chinese-microphone.com/ Microphone Products are: Wireless Microphones, Conference Microphones, Headset Microphones, and Lapel Microphones, interview microphones, wired microphones, musical instrument microphones, drum microphones, teaching microphones, recording microphones, computer's USB microphones and microphone accessories and So on. Compare Handheld Microphone Companies and Handhe http://www.chinese-microphone.com/Handheld-Microphones.html ld Microphone Businesses livedesignonline.com |Directory Home | Company Index | Category Index895 Companies Listed; Is Yours? Get Your Free Listing Most Popular Categories Lamps/Light Source sLighting AccessoriesLuminairesSoundStage Equipment Advertiser Resources Add Your Free Li http://www.chinese-microphone.com/Handheld-Microphones.html sting Update Your Listing Build Your Ad Contact Us Live Design Online Source Book Sound Microphones/Handheld/Stand Supported = Featured Listing Showing 1 - 12 of 12 Microphones/Handheld/Stand Supported Compare and research Handheld Microphone companies and businesses online. Page: 1 Audio-Technica US Inc.Stow, OHDPA Microphones Inc.Longmont, COElectro-VoiceBurnsville, http://www.chinese-microphone.com/Handheld-Microphones.html MNHeil Sound/ TransAudio GroupLas Vegas, NVHi-TechAtlanta, GAImage Technologies Corp.St. Louis, MOProduction Advantage, Inc.Williston, VTProel SpASant'OmeroSennheiser Electronic CorporationOld Lyme, CTShure Inc. Niles, ILSybrsound Sound EngineersMishawaka, I http://www.chinese-microphone.com/Handheld-Microphones.html NXS Lighting & Sound Inc.Farmingdale, NY Page: 1 Live Design Online Source Book | Company Index | Category Index | Advertise With Us | Add Free Listing | Update Listing Customer Support | Terms of Use | Privacy Policy | Site Map Wholesale Handheld Microphone From fetchinson at googlemail.com Sun Apr 20 05:12:19 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Sun, 20 Apr 2008 02:12:19 -0700 Subject: ???Python Memory Management S***s??? In-Reply-To: <480B017A.7020801@gmail.com> References: <480B017A.7020801@gmail.com> Message-ID: On 4/20/08, Hank @ITGroup wrote: > Hi, people! > > Greetings~ > These days I have been running a text processing program, written by > python, of cause. > In order to evaluate the memory operation, I used the codes below: > > """ > > string1 = ['abcde']*999999 # this took up an obvious memory space... > > del string1 # this freed the memory > successfully !! > > """ > For primary variants, the *del* thing works well. However, challenge the > following codes, using class-instances... > > """ > > from nltk import FreqDist # nltk stands for Natural Language Tool > Kit (this is not an advertisement ~_~) > > instance = FreqDist() > > instanceList = [instance]*99999 > > del instanceList # You can try: nothing is freed by this > """ > ??? How do you people control python to free the memory in python 2.5 or > python 2.4 ??? > Cheers!!! I don't know about the others, I personally let the garbage collector take care of it. HTH, Daniel From zolotoiklo at mail.ru Sat Apr 26 06:41:14 2008 From: zolotoiklo at mail.ru (=?KOI8-R?B?+s/Mz9TPyiDrzM/O?=) Date: Sat, 26 Apr 2008 03:41:14 -0700 (PDT) Subject: =?KOI8-R?B?1sXO08vPxSDLz9LSxcvUydLVwN3FxSDCxczY?= =?KOI8-R?B?xQ==?= Message-ID: ???????????? ??????????? ????? Maidenform USA - ??????? ?????????????? ????? ????? ???? ? ???. ????????? ????-????? (??????????? ?????) ??????? ??????? ????????? ?? ???????????? ??????????? ????????? ? ???????? ?????????? ????. ??????? ????????? ??????????? ??????? ???????????? ?????????????? ????????? ??????? ??????. ????????? ?????????? ???? ? ?????????????? ????????, ??????????? ????? ????????? ??? ?????????? ???????. ??????: 77% ??????, 23% ??????? ??????? ?????????????? ????? Maidenform USA http://shopbody.ru/maidenform6224.htm From andrei.avk at gmail.com Mon Apr 14 00:33:45 2008 From: andrei.avk at gmail.com (AK) Date: Mon, 14 Apr 2008 00:33:45 -0400 Subject: ANN: Tobu-0.5.0 Message-ID: <4802deab$0$7056$4c368faf@roadrunner.com> Tobu 0.5.0 is now available. Tobu is something between a freeform information organizer and a database. Changes since last version were: Added multiple undo/redo, toolbar icon for list recent; Fixed loading a previously selected item from listing, disabled closing of last remaining tab, fixed panes disappearing when dragged all the way down or up, fixed removing of favorites, changed last used tag to pop to the top of recently used tags, fixed tab key deleting tags when they are selected, set exact match in filter dropdown to highlight ahead of inexact matches, fixed replacing file name when dragged and dropped instead of appending to old filename, removed 'new copy' icon from toolbar, fixed gvim not saving changes in linux when set as external editor - see note in tutorial, fixed saved views / saved templates interfering with each other, automatic windows installer was added. Tobu's homepage is here: http://tobu.lightbird.net -- ak Tobu | http://tobu.lightbird.net/ | Freeform DB / Tagger / PIM Python-by-Example | http://pbe.lightbird.net/ | Guide to LibRef From joe.p.cool at googlemail.com Tue Apr 15 15:50:33 2008 From: joe.p.cool at googlemail.com (Joe P. Cool) Date: Tue, 15 Apr 2008 12:50:33 -0700 (PDT) Subject: Gecko 1.9 Message-ID: In 2005 I heard of plans to add Python as a second language to the Gecko engine. Is this still true? Or has this plan been abandoned? From kyosohma at gmail.com Tue Apr 22 14:52:12 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 22 Apr 2008 13:52:12 -0500 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. In-Reply-To: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> Message-ID: Ken, On Tue, Apr 22, 2008 at 1:36 PM, Kenneth McDonald wrote: > Sadly. > > Thanks, > Ken > -- > http://mail.python.org/mailman/listinfo/python-list > I've attached the 2.4 version. I also have some Windows binaries for Beautiful Soup uploaded to my website: http://www.pythonlibrary.org/python_modules.htm Hope that helps. Mike -------------- next part -------------- A non-text attachment was scrubbed... Name: BeautifulSoup.py Type: text/x-python Size: 69566 bytes Desc: not available URL: From ch612bunn at gmail.com Sun Apr 27 09:13:59 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:13:59 -0700 (PDT) Subject: avs video converter 5.6.1.715 crack Message-ID: <3dfc2689-c9d6-4379-ab70-102f4b44a274@i76g2000hsf.googlegroups.com> avs video converter 5.6.1.715 crack http://wga-cracks.crackkey.net From oakley at bardo.clearlight.com Sun Apr 13 13:19:22 2008 From: oakley at bardo.clearlight.com (Bryan Oakley) Date: Sun, 13 Apr 2008 17:19:22 GMT Subject: tkinter, canvas, get color of image? In-Reply-To: <0e4c9708-dbe9-4f29-ac31-34f7298f2624@m1g2000pre.googlegroups.com> References: <0e4c9708-dbe9-4f29-ac31-34f7298f2624@m1g2000pre.googlegroups.com> Message-ID: skanemupp at yahoo.se wrote: > mapq = PhotoImage(file = 'C:\Users\saftarn\Desktop\elmapovic.gif') > w.create_image(10, 10, image = mapq, anchor = NW) > > after doing this is there any possibility of getting the > characteristics of the GIF-picture(or bitmap if i use that)? > > it would be very helpfull if i for example could do something like > canvas.getcolor(image, mouseclick.x,mouseclick.y) if u get the point. > get the color of the image where i clicked. The image isn't "painted" on the canvas, so to answer your specific question, no, you can't get the color of a pixel on the canvas in the way that you ask. However, when you click on the canvas you can get the item that was clicked on and the x/y of the click. From that you can figure out which pixel of the image is under the cursor. And from that you can query the image for the color of a specific pixel. From rkmr.em at gmail.com Mon Apr 21 18:59:33 2008 From: rkmr.em at gmail.com (rkmr.em at gmail.com) Date: Mon, 21 Apr 2008 15:59:33 -0700 Subject: dynamically importing a module and function In-Reply-To: <480d1782$1@news.mel.dft.com.au> References: <480d1782$1@news.mel.dft.com.au> Message-ID: On Mon, Apr 21, 2008 at 3:39 PM, John Machin wrote: > rkmr.em at gmail.com wrote: > > data['module'], in the directory data['cwd'] > OT: Any good reason for using a dictionary instead of a class instance > (data.functiom, data.module, etc)? not really, i just wanted to stick to primitive python data types. > > If I do this from python interactive shell (linux fedora core 8) from > > dir /home/mark it works fine: > > > > cwd = data['cwd'] > > os.chdir(cwd) > > print os.getcwd() > > module = __import__(data['module']) > > function = getattr(module, data['function']) > > > > > saved = sys.path > sys.path = data['cwd'] > module = __import__(data['module']) > sys.path = saved now the module gets loaded, but i am not able to get the function from the module, though it works fine in the interactive-shell Traceback (most recent call last): File "/home/mark/work/common/funcq.py", line 62, in if __name__ == '__main__':do() File "/home/mark/work/common/funcq.py", line 35, in do function = getattr(module, data['function']) AttributeError: 'module' object has no attribute 'new' this works in shell though.. >>> import os >>> os.chdir('/home/mark/work/proj1') >>> import sys >>> sys.path.append('/home/mark/work/proj1') >>> module = __import__('app') >>> function = getattr(module, 'new') >>> function(1) 1 From deets at nospam.web.de Wed Apr 2 17:00:28 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 02 Apr 2008 23:00:28 +0200 Subject: Recursive function won't compile In-Reply-To: References: Message-ID: <65iafeF2g9cvvU1@mid.uni-berlin.de> bc1891 at googlemail.com schrieb: > #include > #include > > def RecursiveFact(n): > if(n>1): > return n*RecursiveFact(n-1) > else: > return 1 > > fact = RecursiveFact(31) > print fact > > fact = "End of program" > print fact > > > ......but yet it still gives the right answer. How is this possible? Given that you obviously don't use python, but some weird cross-breed beteween python and C - who are we to judge the semantics of that chimera? Diez From __peter__ at web.de Thu Apr 3 05:56:55 2008 From: __peter__ at web.de (Peter Otten) Date: Thu, 03 Apr 2008 11:56:55 +0200 Subject: unicode in exception traceback References: Message-ID: WaterWalk wrote: > Hello. I just found on Windows when an exception is raised and > traceback info is printed on STDERR, all the characters printed are > just plain ASCII. Take the unicode character u'\u4e00' for example. If > I write: > > print u'\u4e00' > > If the system locale is "PRC China", then this statement will print > this character as a single Chinese character. > > But if i write: assert u'\u4e00' == 1 > > An AssertionError will be raised and traceback info will be put to > STDERR, while this time, u'\u4e00' will simply be printed just as > u'\u4e00', several ASCII characters instead of one single Chinese > character. I use the coding directive commen(# -*- coding: utf-8 -*-)t > on the first line of Python source file and also save it in utf-8 > format, but the problem remains. > > What's worse, if i directly write Chinese characters in a unicode > string, when the traceback info is printed, they'll appear in a non- > readable way, that is, they show themselves as something else. It's > like printing something DBCS characters when the locale is incorrect. > > I think this problem isn't unique. When using some other East-Asia > characters, the same problem may recur. > > Is there any workaround to it? Pass a byte string but make some effort to use the right encoding: >>> assert False, u"\u4e00".encode(sys.stdout.encoding or "ascii", "xmlcharrefreplace") Traceback (most recent call last): File "", line 1, in AssertionError: ? You might be able to do this in the except hook: $ cat unicode_exception_message.py import sys def eh(etype, exc, tb, original_excepthook=sys.excepthook): message = exc.args[0] if isinstance(message, unicode): exc.args = (message.encode(sys.stderr.encoding or "ascii", "xmlcharrefreplace"),) + exc.args[1:] return original_excepthook(etype, exc, tb) sys.excepthook = eh assert False, u"\u4e00" $ python unicode_exception_message.py Traceback (most recent call last): File "unicode_exception_message.py", line 11, in assert False, u"\u4e00" AssertionError: ? If python cannot figure out the encoding this falls back to ascii with xml charrefs: $ python unicode_exception_message.py 2>tmp.txt $ cat tmp.txt Traceback (most recent call last): File "unicode_exception_message.py", line 11, in assert False, u"\u4e00" AssertionError: 一 Note that I've not done any tests; e.g. if there are exceptions with immutable .args the except hook itself will fail. Peter From grante at visi.com Wed Apr 16 14:26:20 2008 From: grante at visi.com (Grant Edwards) Date: Wed, 16 Apr 2008 13:26:20 -0500 Subject: Finally had to plonk google gorups. References: <28d12cc8-5375-4e95-8e37-f872d238a1bd@b64g2000hsa.googlegroups.com> Message-ID: <6cadnYCFdNpR2ZvVnZ2dnUVZ_tPinZ2d@visi> On 2008-04-16, Mensanator wrote: > On Apr 16, 9:19?am, Grant Edwards wrote: >> This morning almost half of c.l.p was spam. ?In order to try >> to not tar both the benign google group users and the >> malignant ones with the same brush, I've been trying to kill >> usenet spam with subject patterns. ?But that's not a battle >> you can win, so I broke down and joined all the other people >> that just killfile everything posted via google.groups. > > Not very bright, eh? > >> AFAICT, if you're a google groups user your posts are not being >> seen by many/most experienced (read "non-google-group") users. >> This is mainly the fault of google who has refused to do >> anything to stem the flood of span that's being sent via Google >> Groups. > > Duh. My. That was certainly a well-reasoned and well-written response. -- Grant Edwards grante Yow! Hey, waiter! I want at a NEW SHIRT and a PONY TAIL visi.com with lemon sauce! From kyosohma at gmail.com Tue Apr 8 13:33:40 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 8 Apr 2008 10:33:40 -0700 (PDT) Subject: set file permission on windows References: Message-ID: <7d75fc7b-a2b7-4ca2-b386-27da975043d0@m44g2000hsc.googlegroups.com> On Apr 8, 12:03 pm, "Tim Arnold" wrote: > hi, I need to set file permissions on some directory trees in windows using > Python. > > When I click on properties for a file and select the 'Security' tab, I see a > list of known 'Group or user names' with permissions for each entry such as > Full Control, Modify, Read&Execute, etc. > > I need to (for example) periodically set Group Permissions for one group to > Read, and another Group to None. I need to apply the settings to several > directory trees recursively. > > If this was on Unix, I'd just use os.stat I guess. I don't think that will > work in this case since all I know is the Group names and the permissions I > need to allow. > > thanks for any pointers, > --Tim Arnold According to the following thread, you can use os.chmod on Windows: http://mail.python.org/pipermail/python-list/2003-June/210268.html You can also do it with the PyWin32 package. Tim Golden talks about one way to do it here: http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html Also see the following thread: http://mail.python.org/pipermail/python-win32/2004-July/002102.html or http://bytes.com/forum/thread560518.html Hope that helps! Mike From tom at vector-seven.com Thu Apr 17 19:40:06 2008 From: tom at vector-seven.com (Thomas Lee) Date: Fri, 18 Apr 2008 09:40:06 +1000 Subject: [Python-Dev] Global Python Sprint Weekends: May 10th-11th and June 21st-22nd. In-Reply-To: <94bdd2610804170644x4db329b0vf49de21a590c51e@mail.gmail.com> References: <87D3F9C72FBF214DB39FA4E3FE618CDC6E22F389FE@EXMBX04.exchhosting.com> <4806482C.4030305@voidspace.org.uk> <94bdd2610804170644x4db329b0vf49de21a590c51e@mail.gmail.com> Message-ID: <4807DFD6.5040800@vector-seven.com> Anybody in Melbourne keen for this? Not sure if I'll be able to make it myself, but I'd be interested to know if there's anybody in the area keen to do the sprint. Cheers, T Tarek Ziad? wrote: > On Wed, Apr 16, 2008 at 8:40 PM, Michael Foord > wrote: > >> Trent Nelson wrote: >> > Following on from the success of previous sprint/bugfix weekends and >> > sprinting efforts at PyCon 2008, I'd like to propose the next two >> > Global Python Sprint Weekends take place on the following dates: >> > >> > * May 10th-11th (four days after 2.6a3 and 3.0a5 are released) >> > * June 21st-22nd (~week before 2.6b2 and 3.0b2 are released) >> > >> > It seems there are a few of the Python User Groups keen on meeting >> > up in person and sprinting collaboratively, akin to PyCon, which I >> > highly recommend. I'd like to nominate Saturday across the board >> > as the day for PUGs to meet up in person, with Sunday geared more >> > towards an online collaboration day via IRC, where we can take care >> > of all the little things that got in our way of coding on Saturday >> > (like finalising/preparing/reviewing patches, updating tracker and >> > documentation, writing tests ;-). >> > >> > For User Groups that are planning on meeting up to collaborate, >> > please reply to this thread on python-dev at python.org and let every- >> > one know your intentions! >> > >> > >> >> I should be able to help organise and attend the London contribution. >> Personally I'd like to work on the documentation changes / clean-up for >> the unittest module discussed recently. >> > > We are trying to set up a team here in Paris, > > Personnally I would like to continue the work started in distutils > (various patches) > and some friends here are interested in contributing on documentation. > > Tarek > > From python at bdurham.com Tue Apr 29 13:40:11 2008 From: python at bdurham.com (python at bdurham.com) Date: Tue, 29 Apr 2008 13:40:11 -0400 Subject: Given a string - execute a function by the same name In-Reply-To: <86ac1b9c0804290909w261a01fdy5de70d93607495e7@mail.gmail.com> References: <27f6ba19-8756-4d96-851f-2a7c585ef3c7@m44g2000hsc.googlegroups.com> <1209483330.17070.1250499293@webmail.messagingengine.com> <86ac1b9c0804290909w261a01fdy5de70d93607495e7@mail.gmail.com> Message-ID: <1209490811.6796.1250524559@webmail.messagingengine.com> Erik, > Perhaps I missed something earlier in the thread, but I really don't see the need for that registry dict or the register decorator. Python already maintains a dictionary for each scope: The advantage of the decorator technique is that you explicitly declare which functions are eligible for execution. Using locals() is too broad because it might allow a user to execute an unintended function. Malcolm From jgodoy at gmail.com Sun Apr 27 12:20:53 2008 From: jgodoy at gmail.com (Jorge Godoy) Date: Sun, 27 Apr 2008 13:20:53 -0300 Subject: design choice: multi-threaded / asynchronous wxpython client? References: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> Message-ID: bullockbefriending bard wrote: > 3) I need to dump this data (for all races, not just current about to > start race) to text files, store it as BLOBs in a DB *and* update real > time display in a wxpython windowed client. Why in a BLOB? Why not into specific data types and normalized tables? You can also save the BLOB for backup or auditing, but this won't allow you to use your DB to the best of its capabilities... It will just act as a data container, the same as a network share (which would not penalize you too much to have connections open/closed). From tinnews at isbd.co.uk Thu Apr 3 08:11:51 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 03 Apr 2008 12:11:51 GMT Subject: Efficient way of testing for substring being one of a set? References: <47f4c18e$0$715$bed64819@news.gradwell.net> <40eadbd9-798b-49b8-8acb-5e27f9b38809@s37g2000prg.googlegroups.com> Message-ID: <47f4c987$0$713$bed64819@news.gradwell.net> Paul Hankin wrote: > On Apr 3, 12:37 pm, tinn... at isbd.co.uk wrote: > > What's the neatest and/or most efficient way of testing if one of a > > set of strings (contained in a dictionary, list or similar) is a > > sub-string of a given string? > > > > I.e. I have a string delivered into my program and I want to see if > > any of a set of strings is a substring of the string I have been > > given. It's quite OK to stop at the first one found. Ideally the > > strings being searched through will be the keys of a dictionary but > > this isn't a necessity, they can just be in a list if it could be done > > more efficiently using a list. > > > > Is this the best one can do (ignoring the likelihood that I've got > > some syntax wrong) :- > > > > # l is the list > > # str is the incoming string > > answer = "" > > for x in l: > > if str.find(x) < 0: > > continue > > answer = x > > I'd not use 'l' (confused with '1') or 'str' (a standard module) as > variable names. Neither would I, it was just thrown together to show how I was thinking. > Your code checks every string in the list even when > it's found one... you can reverse the test and break when the first > one is found. Using 'in' rather than testing the return value of find > is nicer as a substring test. Finally, using the 'else' clause lets > you make it clear that answer is set to the empty string when no match > is found. > > for answer in l: > if str in answer: break > else: > answer = '' > OK, that does improve things somewhat, thanks. -- Chris Green From kevin.p.dwyer at gmail.com Wed Apr 23 08:04:38 2008 From: kevin.p.dwyer at gmail.com (kdwyer) Date: Wed, 23 Apr 2008 05:04:38 -0700 (PDT) Subject: problem with dictionaries References: Message-ID: On Apr 23, 12:16 pm, Simon Strobl wrote: > Hello, > > the idea of the following program is to parse a frequency list of the > form FREQUENCY|WORD, to store the frequency of a word in a dictionary > (and to do some things with this information later). > > I have done this many many times. Suddenly, it does not work any more: > The value frq[key] is different from the value that key has in the > file 'my_frqlist.txt'. > > I am using Python 2.5.1 > > Any hints? > > Simon > > ================================================ > > #!/usr/bin/python > > import sys > > frqlist = open('my_frqlist.txt', 'r') > > # my_frqlist looks like this: > # 787560608|the > # 434879575|of > # 413442185|and > # 395209748|to > # 284833918|a > # 249111541|in > # 169988976|is > > frq = {} > > for line in frqlist: > line = line.rstrip() > frequency, word = line.split('|') > frq[word] = int(frequency) > > for key in frq.keys(): > print key, frq[key] It works for me, save that you need to read the file into a list first - is this really the code that you are running? What results are you getting? K From steve at holdenweb.com Fri Apr 25 09:25:37 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 25 Apr 2008 09:25:37 -0400 Subject: Environment Variables In-Reply-To: References: Message-ID: Krishna wrote: > Environment variable set up is the most confusing part for me all the > time. Please help me with the following questions: > > When I install python in a new system, I will go to environment > variables (system variables) and set "path" pointing to C:\Python25 > and thats all I do. > I type python from "cmd" window and its converting to python window > for python execution. All fine up to this point. > Now, I want to drag and drop python (.py) files to this window and > execute it. My python files are located in different directories > inside C: and outside C:. When I do that, I get errors and the file is > not found and its not imported. ALso, inside the .py file, if I have a > command to open a different file, it doesnt see that either. How do I > overcome these basic difficulties in python. I wish I can open any > file and work on that using python. > http://www.python.org/doc/faq/windows/#how-do-i-run-a-python-program-under-windows regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From duncan.booth at invalid.invalid Tue Apr 1 03:22:41 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 1 Apr 2008 07:22:41 GMT Subject: Newbie Question - Overloading == References: <85edb5fb-eae8-4e8f-8f77-0ee4668063cd@u69g2000hse.googlegroups.com> <7eb5d21a-c4de-4655-ab93-9221d996f424@i7g2000prf.googlegroups.com> Message-ID: "bruno.desthuilliers at gmail.com" wrote: >> Surely an A isn't equal to every other object which just happens to >> have the same attributes 'a' and 'b'? > > And why not ?-) > >> I would have thoughts the tests want to be >> something like: >> >> class A: >> def __eq__(self,other): >> return (isinstance(other, A) and >> self.a == other.a and self.b == other.b) >> >> (and similar for B) with either an isinstance or exact match required >> for the type. > > I don't think there's a clear rule here. Python is dynamically typed > for good reasons, and MHO is that you should not fight against this > unless you have equally good reasons to do so. > I fully agree with that, but an apple != a pear, even if they are the same size and colour. There will be some types where you can have equality between objects of different types (e.g. int/float), but more often the fact that they are different types wil automatically mean they are not equal. From darcy at druid.net Thu Apr 24 06:39:23 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Thu, 24 Apr 2008 06:39:23 -0400 Subject: annoying dictionary problem, non-existing keys In-Reply-To: <481043C5.20409@jouy.inra.fr> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> <481043C5.20409@jouy.inra.fr> Message-ID: <20080424063923.04d32bba.darcy@druid.net> On Thu, 24 Apr 2008 10:24:37 +0200 Robert Bossy wrote: > Way 2: make conf a defaultdict instead of a dict, the documentation is > there: > http://docs.python.org/lib/defaultdict-objects.html Only for 2.5 and up though. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From steve at holdenweb.com Sun Apr 13 07:57:27 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 13 Apr 2008 07:57:27 -0400 Subject: =?GB2312?B?09DW0Ln6yMu69T8=?= In-Reply-To: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> References: <71dcc0b1-3c8e-4772-aaae-43cf09e0dd0e@p25g2000pri.googlegroups.com> Message-ID: bikthh at live.cn wrote: > Python????????????????. ?, Python ????????????, ????????? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From Graham.Dumpleton at gmail.com Mon Apr 28 08:03:35 2008 From: Graham.Dumpleton at gmail.com (Graham Dumpleton) Date: Mon, 28 Apr 2008 05:03:35 -0700 (PDT) Subject: apache module: python and web programming, easy way...? References: Message-ID: On Apr 28, 7:42?pm, bvidinli wrote: > is there any apache module, you know, that i can just install with apt-get, > then put my .py file, and run it ? http://www.modwsgi.org http://www.modpython.org The mod_wsgi module supports WSGI (http://www.wsgi.org) specification which is where Python web framework hosting is heading whereas mod_python has its own specific API which results in your application only being able to be hosted with it and nothing else. Graham From grepla at gmail.com Wed Apr 30 01:25:32 2008 From: grepla at gmail.com (grepla at gmail.com) Date: Tue, 29 Apr 2008 22:25:32 -0700 (PDT) Subject: Problem with variables assigned to variables??? Message-ID: I have a simple line of code that requires the following inputs - an input file, output file and a SQL expression. the code needs to be run with several different SQL expressions to produce multiple output files. To do this I first created a list of a portion of the output filename: mylist = ('name1', 'name2', 'name3') I also assigned variables for each SQL expression: name1 = "\"field_a\" LIKE '021'" name2 = "\"field_a\" LIKE '031'" name3 = "\"field_a\" LIKE '041'" Notice the variable names are the same as the listmember strings, that is intentional, but obviously doesn't work. the loop: for listmember in mylist: print listmember + ".shp", listmember my intended output is: name1.shp "field_a LIKE '021' name2.shp "field_a LIKE '031' name3.shp "field_a LIKE '041' but, of course, the variable listmember returns the name of the listmember which makes perfect sense to me: name1.shp name1 So how can I iterate not only the filenames but the SQL expressions as well? From blog189 at watchesblog.cn Fri Apr 18 07:03:00 2008 From: blog189 at watchesblog.cn (blog189 at watchesblog.cn) Date: Fri, 18 Apr 2008 04:03:00 -0700 (PDT) Subject: Brand Watches CITIZEN Eco Drive Women's Black Dial 2-Hand Watch SY2030-54E Discount, Replica, Fake Message-ID: <5093f80b-6e00-4980-ae23-465d049ce91e@y18g2000pre.googlegroups.com> Brand Watches CITIZEN Eco Drive Women's Black Dial 2-Hand Watch SY2030-54E Discount, Replica, Fake Browse our CITIZEN Eco Drive Women's Black Dial 2-Hand Watch SY2030-54E replica watches, which is sure the watch you are looking for at low price. There are more high quality designer watch replicas for selection CITIZEN Eco Drive Women's Black Dial 2-Hand Watch SY2030-54E Link : http://www.watches-brand.com/Replica-Citizen-6180.html Brand : Citizen ( http://www.watches-brand.com/Citizen-Replica.html ) Model : CITIZEN Eco Drive Women's Black Dial 2-Hand Watch SY2030-54E Description :

Watch with Stainless Steel band. Stainless Steel Rectangular Case with diamonds. Scratch Resistant Mineral Crystal. Quartz Movement. Water resistant up to 30 meters.

Sale Price : $ 210.00 CITIZEN Eco Drive Women's Black Dial 2-Hand Watch SY2030-54E Details :
  • Brand: Citizen
  • Band material: stainless-steel
  • Case material: Stainless-Steel
  • Dial color: Black
  • Dial window material: Scratch Resistant Mineral Crystal
  • Water-resistant to 30 meters
CITIZEN Eco Drive Women's Black Dial 2-Hand Watch SY2030-54E is new brand replica, join thousands of satisfied customers and buy your Citizen with total satisfaction. A watches-brand.COM 30 Day Money Back Guarantee is included with every Citizen Replica Series for secure, risk-free online shopping. watches-brand.COM does not charge sales tax for the Fake CITIZEN Eco Drive Women's Black Dial 2-Hand Watch SY2030-54E. All of our replica watches are shipped via EMS to worldwide. Normally it takes 3days to prepare the fake watch you ordered and 5-10days to transmit depending on the different destination.We pay for the free shipping cost for total quantity over 20 pcs. The EMS tracking NO. will be sent by email when an order is shipped from our warehouse. No more other charges from watches-brand.com such as the tax. If you have any other questions please check our other pages or feel free to email us by sales at watches-brand.com. The Same Replica Citizen Watches Series : Citizen Eco-Drive Alarm (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6181.html Citizen Eco-Drive Black Dial (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6182.html Citizen Eco-Drive Black dial (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6183.html Citizen Eco-Drive Black dial (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6184.html Citizen Eco-Drive Black dial (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6185.html Citizen Eco-Drive Black dial (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6186.html Citizen Eco-Drive Black dial (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6187.html Citizen Eco-Drive Black dial (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6188.html Citizen Eco-Drive Blue dial (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6189.html Citizen Eco-Drive Blue dial (Women's Watch) : http://www.watches-brand.com/Replica-Citizen-6190.html Brand Watches CITIZEN Eco Drive Women's Black Dial 2-Hand Watch SY2030-54E Discount, Replica, Fake From landofdreams at gmail.com Wed Apr 30 23:46:22 2008 From: landofdreams at gmail.com (Sam) Date: Wed, 30 Apr 2008 20:46:22 -0700 (PDT) Subject: relative import broken? References: <9c6ba5f9-d65b-4265-baba-fc5d7936781b@d1g2000hsg.googlegroups.com> <87prs6x1ye.fsf@mulj.homelinux.net> Message-ID: <33782b65-6d6d-4ae7-8539-29f809ae5077@d45g2000hsc.googlegroups.com> On Apr 30, 9:11 pm, Hrvoje Niksic wrote: > Sam writes: > > I also have a problem with relative import; I can't for the life of me > > figure out how to use the damn thing. I think the main problem is with > > getting Python to recognize the existence of a package. I have > > > S/ > > p.py > > B/ > > b.py > > W/ > > pyw/ > > u.py > > ws.py > > > and I'd like to get u.py to import all the other 3 programs. I put > > empty __init__.py files in all of the above directories (is this > > necessary?), and even manually added the pathway (r'C:\Myname\S') to > > sys.path, but when I execute > > > from S import p > > > in u.py Python gives "ImportError: No module named S". > > A silly question: is the directory that contains "S" in PYTHONPATH or > in sys.path? It's in sys.path. I'm not sure how to access or change PYTHONPATH from within a program (I'm running everything in IDLE). I'm using Windows, btw. > > > The docs for relative import make this sound much easier than it is. > > It's supposed to be just as easy as it sounds. For example: > > $ mkdir S > $ touch S/p.py > $ touch S/__init__.py > $ python > Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) > [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 > Type "help", "copyright", "credits" or "license" for more information.>>> from S import p > >>> p > > From ivan.illarionov at gmail.com Tue Apr 22 00:04:46 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Tue, 22 Apr 2008 04:04:46 +0000 (UTC) Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> <2008041818232516807-bob@passcalnmtedu> <537314f9-47ef-4fe4-b805-3ff22947d206@s50g2000hsb.googlegroups.com> <75325e1a-9ea7-4ac8-98eb-acdb9648514d@t54g2000hsg.googlegroups.com> <10497582-1289-45c2-8f68-84f60400dafc@t63g2000hsf.googlegroups.com> <85c14b14-9302-41bb-9270-b7cdd65098b0@c65g2000hsa.googlegroups.com> Message-ID: On Mon, 21 Apr 2008 16:10:05 -0700, George Sakkis wrote: > On Apr 21, 5:30 pm, Ivan Illarionov wrote: > >> On 22 ???, 01:01, Peter Otten <__pete... at web.de> wrote: >> >> > Ivan Illarionov wrote: >> > > And even faster: >> > > a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, >> > > len(s), 3)))) >> > > if sys.byteorder == 'little': >> > > a.byteswap() >> >> > > I think it's a fastest possible implementation in pure python >> >> > Clever, but note that it doesn't work correctly for negative numbers. >> > For those you'd have to prepend "\xff" instead of "\0". >> >> > Peter >> >> Thanks for correction. >> >> Another step is needed: >> >> a = array.array('i', '\0' + '\0'.join((s[i:i+3] for i in xrange(0, >> len(s), 3)))) >> if sys.byteorder == 'little': >> a.byteswap() >> result = [n if n < 0x800000 else n - 0x1000000 for n in a] >> >> And it's still pretty fast :) > > Indeed, the array idea is paying off for largeish inputs. On my box > (Python 2.5, WinXP, 2GHz Intel Core Duo), the cutoff point where > from3Bytes_array becomes faster than from3Bytes_struct is close to 150 > numbers (=450 bytes). > > The struct solution though is now almost twice as fast with Psyco > enabled, while the array doesn't benefit from it. Here are some numbers > from a sample run: > > *** Without Psyco *** > size=1 > from3Bytes_ord: 0.033493 > from3Bytes_struct: 0.018420 > from3Bytes_array: 0.089735 > size=10 > from3Bytes_ord: 0.140470 > from3Bytes_struct: 0.082326 > from3Bytes_array: 0.142459 > size=100 > from3Bytes_ord: 1.180831 > from3Bytes_struct: 0.664799 > from3Bytes_array: 0.690315 > size=1000 > from3Bytes_ord: 11.551990 > from3Bytes_struct: 6.390999 > from3Bytes_array: 5.781636 > *** With Psyco *** > size=1 > from3Bytes_ord: 0.039287 > from3Bytes_struct: 0.009453 > from3Bytes_array: 0.098512 > size=10 > from3Bytes_ord: 0.174362 > from3Bytes_struct: 0.045785 > from3Bytes_array: 0.162171 > size=100 > from3Bytes_ord: 1.437203 > from3Bytes_struct: 0.355930 > from3Bytes_array: 0.800527 > size=1000 > from3Bytes_ord: 14.248668 > from3Bytes_struct: 3.331309 > from3Bytes_array: 6.946709 > > > And here's the benchmark script: > > import struct > from array import array > > def from3Bytes_ord(s): > return [n if n<0x800000 else n-0x1000000 for n in > ((ord(s[i])<<16) | (ord(s[i+1])<<8) | ord(s[i+2]) > for i in xrange(0, len(s), 3))] > > unpack_i32be = struct.Struct('>l').unpack def from3Bytes_struct(s): > return [unpack_i32be(s[i:i+3] + '\0')[0]>>8 > for i in xrange(0,len(s),3)] > > def from3Bytes_array(s): > a = array('l', ''.join('\0' + s[i:i+3] > for i in xrange(0,len(s), 3))) > a.byteswap() > return [n if n<0x800000 else n-0x1000000 for n in a] > > > def benchmark(): > from timeit import Timer > for n in 1,10,100,1000: > print ' size=%d' % n > # cycle between positive and negative buf = > ''.join(struct.pack('>i', 1234567*(-1)**(i%2))[1:] > for i in xrange(n)) > for func in 'from3Bytes_ord', 'from3Bytes_struct', > 'from3Bytes_array': > print ' %s: %f' % (func, > Timer('%s(buf)' % func , > 'from __main__ import %s; buf=%r' % (func,buf) > ).timeit(10000)) > > > if __name__ == '__main__': > s = ''.join(struct.pack('>i',v)[1:] for v in > [0,1,-2,500,-500,7777,-7777,-94496,98765, > -98765,8388607,-8388607,-8388608,1234567]) > assert from3Bytes_ord(s) == from3Bytes_struct(s) == > from3Bytes_array(s) > > print '*** Without Psyco ***' > benchmark() > > import psyco; psyco.full() > print '*** With Psyco ***' > benchmark() > > > George Comments: You didn't use the faster version of array approach: ''.join('\0' + s[i:i+3] for i in xrange(0,len(s), 3)) is slower than '\0' + '\0'.join(s[i:i+3] for i in xrange(0,len(s), 3)) To Bob Greschke: Struct is fast in Python 2.5 with struct.Struct class. Array approach should work with Python 2.3 and it's probably the fastest one (without psyco) with large inputs: def from3bytes_array(s): a = array.array('i', '\0' + '\0'.join([s[i:i+3] for i in xrange(0, len(s), 3)])) a.byteswap() # if your system is little-endian return [n >= 0x800000 and n - 0x1000000 or n for n in a] -- Ivan From pofuk at mzm.hr Sat Apr 5 17:08:27 2008 From: pofuk at mzm.hr (SMALLp) Date: Sat, 05 Apr 2008 23:08:27 +0200 Subject: Transparent bitmap(image) in windows! Message-ID: Hello everyone! First I want to apologize for asking question about wxPython on this group. I'm doing project that uses wx.ScrolledPanel few wx.Bitmap on it. It all looks wonderful on Ubuntu and very very bad on windows because images aren't transparent. As a found out it is problem that windows drowns each image in separate window (or something like that) I'm looking for best and easiest solution for this problem. I found something to bind PAINT event to empty function but it doesn't work because of scrolled panel. Please help! Thanks! From george.sakkis at gmail.com Wed Apr 2 13:09:37 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Wed, 2 Apr 2008 10:09:37 -0700 (PDT) Subject: Manipulate Large Binary Files References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> Message-ID: On Apr 2, 11:50 am, Derek Martin wrote: > On Wed, Apr 02, 2008 at 10:59:57AM -0400, Derek Tracy wrote: > > I generated code that works wonderfully for files under 2Gb in size > > but the majority of the files I am dealing with are over the 2Gb > > limit > > > ary = array.array('H', INPUT.read()) > > You're trying to read the file all at once. You need to break your > reads up into smaller chunks, in a loop. You're essentially trying to > store more data in memory than your OS can actually access in a single > process... > > Something like this (off the top of my head, I may have overlooked > some detail, but it should at least illustrate the idea): > > # read a meg at a time > buffsize = 1048576 > while true: > buff = INPUT.read(buffsize) > OUTPUT.write(buff) > if len(buff) != buffsize: > break Or more idiomatically: from functools import partial for buff in iter(partial(INPUT.read, 10 * 1024**2), ''): # process each 10MB buffer George From rocco.rossi at gmail.com Wed Apr 23 18:46:36 2008 From: rocco.rossi at gmail.com (rocco.rossi at gmail.com) Date: Wed, 23 Apr 2008 15:46:36 -0700 (PDT) Subject: Python generators (coroutines) References: Message-ID: <5c4add67-76fa-434f-877e-64daee0fc1de@e53g2000hsa.googlegroups.com> > Anyway, if you have a blocking operation, the only solution is to use > a thread or a separate process. > > Michele Simionato That's what I thought. It was in fact rather obvious, but I wanted to be sure that I hadn't overlooked some arcane possibility (ex. with the use of exceptions or something like that). Thanks for the confirmation. From wizzardx at gmail.com Sat Apr 26 06:20:33 2008 From: wizzardx at gmail.com (David) Date: Sat, 26 Apr 2008 12:20:33 +0200 Subject: nntplib retrieve news://FULL_URL In-Reply-To: References: Message-ID: <18c1e6480804260320m3f088ebdpe8980a482855418a@mail.gmail.com> > So I have established a connection to an nntp server and I am > retrieving articles to other articles on the server such as > news://newsclip.ap.org/D8L4MFAG0 at news.ap.org > > Now I am wondering how I query for that article based off of the url? > > I assume D8L4MFAG0 is an id of some sort but when I try and retrieve > that article via myNntpObject.article('D8L4MFAG0') I get an error of > 423 Bad article number. Which makes sense as all the other article > numbers are integers. > > D8L4MFAG0 actually looks like a doc-id value for an NITF article > stored on the NNTP server which I am retrieving content off of. > > Anyone have any ideas on how I fetch this content? Have a look at the 'Message-ID' header of articles on the server. They usually start and end with "<" and end with ">". An example from comp.lang.python: You probably got the "423 Bad article number" error because there wasn't a "<" and ">" in your message ID, so it tried to parse it as an article number instead. I couldn't check your example because newsclip.ap.org requires a login. David. From nagle at animats.com Fri Apr 4 11:21:34 2008 From: nagle at animats.com (John Nagle) Date: Fri, 04 Apr 2008 08:21:34 -0700 Subject: collecting results in threading app In-Reply-To: References: Message-ID: <47f64507$0$36354$742ec2ed@news.sonic.net> Gerardo Herzig wrote: > Hi all. Newbee at threads over here. Im missing some point here, but cant > figure out which one. > > This little peace of code executes a 'select count(*)' over every table > in a database, one thread per table: > > class TableCounter(threading.Thread): > def __init__(self, conn, table): > self.connection = connection.Connection(host=conn.host, > port=conn.port, user=conn.user, password='', base=conn.base) > threading.Thread.__init__(self) > self.table = table > > def run(self): > result = self.connection.doQuery("select count(*) from %s" % > self.table, [])[0][0] > print result > return result > > > class DataChecker(metadata.Database): > > def countAll(self): > for table in self.tables: > t = TableCounter(self.connection, table.name) > t.start() > return > > > It works fine, in the sense that every run() method prints the correct > value. > But...I would like to store the result of t.start() in, say, a list. The > thing is, t.start() returns None, so...what im i missing here? > Its the desing wrong? 1. What interface to MySQL are you using? That's not MySQLdb. 2. If SELECT COUNT(*) is slow, check your table definitions. For MyISAM, it's a fixed-time operation, and even for InnoDB, it shouldn't take that long if you have an INDEX. 3. Threads don't return "results" as such; they're not functions. As for the code, you need something like this: class TableCounter(threading.Thread): def __init__(self, conn, table): self.result = None ... def run(self): self.result = self.connection.doQuery("select count(*) from %s" % self.table, [])[0][0] def countAll(self): mythreads = [] # list of TableCounter objects # Start all threads for table in self.tables: t = TableCounter(self.connection, table.name) mythreads.append(t) # list of counter threads t.start() # Wait for all threads to finish totalcount = 0 for mythread in mythreads: # for all threads mythread.join() # wait for thread to finish totalcount += mythread.result # add to result print "Total size of all tables is:", totalcount John Nagle From tjreedy at udel.edu Fri Apr 25 18:49:26 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 25 Apr 2008 18:49:26 -0400 Subject: Remove old version before upgrade? References: Message-ID: "Steve Holden" wrote in message news:furl3k$v6t$1 at ger.gmane.org... | Sal wrote: | > I'm currently running Windows version 2.5.1 and would like to upgrade | > to 2.5.2. My question is, can I just go ahead and install the new | > version over the old or should I remove the old version with add/ | > remove programs first? The old version is in a directory named | > Python25. | | You can do either. Since there's no change of major version the | executable will have the same path, and the deinstall handily leaves all | files that weren't part of the original install in place. So if it suits | your sense of neatness, by all means deinstall before reinstallation. I would leave things alone unless you really want to start from scratch. If you have installed any 3rd party packages that put files in Python25/DLLs or Python25/Libs/site-packages, I would not trust the uninstaller to not disturb anything. From fetchinson at googlemail.com Tue Apr 22 12:27:48 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Tue, 22 Apr 2008 09:27:48 -0700 Subject: Does Python 2.5.2's embedded SQLite support full text searching? In-Reply-To: <6763uaF2norrtU1@mid.uni-berlin.de> References: <1208794249.15992.1249049327@webmail.messagingengine.com> <6763uaF2norrtU1@mid.uni-berlin.de> Message-ID: > >> Does Python 2.5.2's embedded SQLite support full text searching? > >> > >> Any recommendations on a source where one can find out which SQLite > >> features are enabled/disabled in each release of Python? I'm trying to > >> figure out what's available in 2.5.2 as well as what to expect in 2.6 > >> and 3.0. > > > > Sqlite itself is not distributed with python. Only a python db api > > compliant wrapper is part of the python stdlib and as such it is > > completely independent of the sqlite build. In other words, if your > > sqlite build supports full text searching you can use it through the > > python sqlite wrapper (that is part of the stdlib) and if it doesn't > > then not. This is true for any sqlite feature though. > > > > So if you need an sqlite feature just go ahead and build your own > > sqlite with that feature enabled and use that feature with the stock > > python sqlite wrapper that comes with the stdlib. > > I doubt that. This would mean that Python comes with a mechanism to > dynamically load different libs for the same module, opening a buttload > full of error-conditions regarding library versions & changing semantics > depending on system configuration. That mechanism is called dynamical shared object loading. The wrapper _sqlite3.so uses libsqlite3.so (which is the sqlite library itself, independently of python) and so if you want to use a custom sqlite which behaves the same as the original sqlite only it adds, for example, a new SQL keyword that can be used in queries, all you need to do is compile it and replace libsqlite3.so with your custom build. If you pass the new SQL keyword in a query from python through the db api it will travel to the part of the wrapper that is implemented in python then to the C wrapper (_sqlite3.so) and then to your new libsqlite3.so which interprets the new keyword correctly. Of course you can not change the sqlite C api in this way for that you would need to rebuild _sqlite3.so as well. Cheers, Daniel > Instead, the sqlite standard lib comes with its own version of sqlite. > If you want something other, you need to > > - install sqlite on your system, including library & headers > - compile the pysqlite extension module > > it will be available in a different module path to prevent confusion. > > THe same is true for ElementTree, btw. From ivan.illarionov at gmail.com Thu Apr 17 19:19:37 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Thu, 17 Apr 2008 23:19:37 +0000 (UTC) Subject: Request a short code review References: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> Message-ID: On Thu, 17 Apr 2008 15:11:40 -0700, james wrote: >> I am not necessarily looking to make the code shorter or more >> functional or anything in particular. However if you spot something to >> improve then I am happy to learn. > > To give an example of what I mean I have already altered the code: > > def output_random_lesson_of_type(self, type=None): > """Output a lesson of a specific type. > If no type is passed in then output any type.""" > output_lessons = self.lesson_data["lessons"] if type: > filtered_lessons = filter(lambda x: x["type"] == type, > self.lesson_data["lessons"]) > if filtered_lessons: > output_lessons = filtered_lessons > else: > print "Unable to find lessons of type %s." % type > return self.output_random(output_lessons) > > Changes: > - Respected a column width of 80 > - Created the output_lessons variable, assigned it to a default. > This remove an else statement and reduced the call to > self.output_random to a single instance in the return statement > > Cheers, > James I would write it like this: def output_random_lesson_of_type(self, type=None): """\ Output a lesson of a specific type. If no type is passed in then output any type. """ if type: return self.output_random([x for x in self.lesson_data["lessons"] if x["type"] == type]) return self.output_random(self.lesson_data["lessons"]) -- Ivan From desktop_specialist at yahoo.com Fri Apr 11 12:20:06 2008 From: desktop_specialist at yahoo.com (shawn s) Date: Fri, 11 Apr 2008 09:20:06 -0700 (PDT) Subject: simple program Message-ID: <256065.832.qm@web58614.mail.re3.yahoo.com> Hi, Here is a simple prog that I can run from the Python shell and it runs fine but when I double click the 'filename.py' , it does not execute the ping statement, and seems like it is stuck at the following output: Fri Apr 11 12:16:09 2008 Testing 192.168.0.1 The prog is as follows: import os, curses import socket, time BAS ='192.168.0.1' os.system ('ping '+ BAS) print time.ctime() curses.delay_output(5000) Any ides as to why it is doing that? You may email me at desktop_specialist at yahoo.com __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From needin4mation at gmail.com Tue Apr 8 13:53:26 2008 From: needin4mation at gmail.com (jmDesktop) Date: Tue, 8 Apr 2008 10:53:26 -0700 (PDT) Subject: Is the Python for statement the same as for each in other languages? Message-ID: <9e8bfedb-dc75-4252-84e7-4fb96bbaa6ac@l64g2000hse.googlegroups.com> Thank you. It looks like it is, but I wanted to make sure I understood. Also, I didn't see a "regular" for loop construct either (i=0;i<=10;i++), etc. I'm still new at it, but is there one of those? From skanemupp at yahoo.se Thu Apr 10 10:37:08 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Thu, 10 Apr 2008 07:37:08 -0700 (PDT) Subject: tkinter, overwrite Label-text? References: Message-ID: On 10 Apr, 16:29, "Dennis.Benzin... at gmx.net" wrote: > On Apr 10, 3:47 pm, skanem... at yahoo.se wrote: > > > [...] > > i use the Label-widget. > > Then you should be able to connect a variable to your widget like I > wrote in my previous post. > Just try out the example from the Python documentation. Of course in > your case entrythingy would be the > Label-widget. Take care to assign values to your variable by using the > set function. > > Dennis Benzinger i know how to do this already. the problem is i want the text to stay in the windowa nd not start overwriting "Answer:". i have solved this by using an Entry for the answer as well but id prefer using a Label. here is the code: from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") l = Label(mygui, text="Answer: ") l.place(relx=0.15, rely=0.2, anchor=CENTER) e = Entry(mygui) e.place(relx=0.4, rely=0.1, anchor=CENTER) def Disp(nstr): e.insert(END, nstr) def Calc(): expr=e.get() try: b = Label(mygui, text=eval(expr)) b.place(relx=0.4, rely=0.2, anchor=CENTER) except: b = Label(mygui, text="Not computable") b.place(relx=0.4, rely=0.2, anchor=CENTER) def Erase(): e.delete(0,END) x = 0.1 y = 0.4 for char in '123+456-789*0()/.': b = Button(mygui, text=char, command=lambda n=char:Disp(n), width=2, height=1) b.place(relx=x, rely=y, anchor=CENTER) x=x+0.1 if x==0.5: x=0.1 y=y+0.1 b = Button(mygui, text="^", command=lambda n="**":Disp(n), width=2, height=1) b.place(relx=0.2, rely=0.8, anchor=CENTER) b = Button(mygui, text="C",command=Erase, width=2, height=1) b.place(relx=0.3, rely=0.8, anchor=CENTER) b = Button(mygui, text="=",command=Calc, width=2, height=1) b.place(relx=0.4, rely=0.8, anchor=CENTER) mygui.mainloop() From ankitks.mital at gmail.com Thu Apr 3 19:29:07 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Thu, 3 Apr 2008 16:29:07 -0700 (PDT) Subject: python bisect questions References: <6bb6927b-f553-40db-a142-2ce86b9e819f@q27g2000prf.googlegroups.com> <7d64aa50-9d67-45fe-9d57-ec32904ecb87@u36g2000prf.googlegroups.com> Message-ID: On Apr 3, 5:43?pm, John Machin wrote: > On Apr 4, 9:21 am, ankitks.mi... at gmail.com wrote: > > > > > > > On Apr 3, 4:24 pm, "Terry Reedy" wrote: > > > > wrote in message > > > >news:6bb6927b-f553-40db-a142-2ce86b9e819f at q27g2000prf.googlegroups.com... > > > |I am week on functional programming, and having hard time > > > | understanding this: > > > | > > > | class myPriorityQueue: > > > | ? ? ?def __init__(self, f=lamda x:x): > > > | ? ? ? ? ? ? ?self.A = [] > > > | ? ? ? ? ? ? ?self.f = f > > > | > > > | ? ? ?def append(self, item) > > > | ? ? ? ? ? ? ?bisect.insort(self.A, (self.f(item), item)) > > > | ? ?............ > > > | > > > | now I know we are inserting items(user defined type objects) in list A > > > | base on sorting order provided by function A. > > > | but what I don't understand is bisect command > > > | what does bisect.insort(self.A, (self.f(item), item)) doing > > > here is doc > > insort_right(a, x[, lo[, hi]]) > > > ? ? Insert item x in list a, and keep it sorted assuming a is sorted. > > > ? ? If x is already in a, insert it to the right of the rightmost x. > > > ? ? Optional args lo (default 0) and hi (default len(a)) bound the > > ? ? slice of a to be searched. > > > but I am still confuse. self.A is my list a. and item is x that > > I am trying to insert. > > So it needs to be of type item not (self.f(item), item) > > It doesn't say anything pass sorting function self.f(item). > > That's correct. You are passing a tuple of (sort_key, actual_data). > > Example use case: caseless sortorder but you want to retrieve the > original data. f is lambda x: x.upper() or similar. Your data is > 'foo', 'Bar', 'zOt'. Calls to your_queue.append will result in the > following 2nd args for bisect.insort: > ('FOO', 'foo') > ('BAR', 'Bar') > ('ZOT', 'zOt') Thanks John and Terry, Wow! great way to keep original values with transformation. Thanks for explaining. > > Consider executing the code with a couple of print statements in it so > that you can see what is happening.- Hide quoted text - > > - Show quoted text - From sjmachin at lexicon.net Mon Apr 21 19:29:45 2008 From: sjmachin at lexicon.net (John Machin) Date: Mon, 21 Apr 2008 23:29:45 GMT Subject: module error in Vista -- works as administrator In-Reply-To: <72da4abc-57b1-47ca-bed4-48b7244d6407@e39g2000hsf.googlegroups.com> References: <815eb7f8-6f00-469d-bb15-e1d9680d9646@e39g2000hsf.googlegroups.com> <480d0a52$1@news.mel.dft.com.au> <72da4abc-57b1-47ca-bed4-48b7244d6407@e39g2000hsf.googlegroups.com> Message-ID: <480d2369@news.mel.dft.com.au> sawilla wrote: > On Apr 21, 5:42 pm, John Machin wrote: >> Log on as administrator, start python in command window and do this: >> >> import sys >> sys.path # shows where python is looking for importables >> import numpy >> import os.path >> print os.path.abspath(numpy.__file__) # shows where it found numpy >> >> Log on as ordinary user, start python in command window and do this: >> >> import sys >> sys.path >> # check how this is different from the admin's sys.path >> >> If you can't see what to do after that, come back here with the output >> from those steps. >> >> HTH, >> John > > That was a great help, thank you. I now see what is causing the > problem but I don't know how to fix it. I used easy_install to install > several packages. When I run Python from an administrator command > window all of the directories in C:\Program Files\Python25\Lib\site- > packages\easy-install.pth are added to the sys.path. When I run it as > a regular user, those directories are not added to the sys.path and so > Python can't find the modules. > > I know how to manually add those directories to Python's search path > but then I'll need to update the path every time I install something. > How do I get Python to automatically load the easy-install.pth file > for the regular user account? > > Reg """ If you can't see what to do after that, come back here with the output from those steps. """ in particular what is in sys.path for the non-admin user. Also what are the access rights to the easy-install.pth file? From bignose+hates-spam at benfinney.id.au Wed Apr 30 22:25:01 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Thu, 01 May 2008 12:25:01 +1000 Subject: We have string.isdigit(), why not string.isNumber()? References: <0d43feda-fab8-46ba-9af0-eaf497033acd@l17g2000pri.googlegroups.com> Message-ID: <8763ty3gn6.fsf@benfinney.id.au> MooMaster writes: > I know how to write a regexp or method or whatever to do this, my main > question is *why* something like an isNumber() method is not baked > into the class. Because that name wouldn't conform to PEP 8. (Also, and more importantly, because it's more correct to use it as input to creating a new object of the type you want, and catch the exception if it fails.) -- \ "Courage is resistance to fear, mastery of fear ? not absence | `\ of fear." ?Mark Twain, _Pudd'n'head Wilson_ | _o__) | Ben Finney From tinnews at isbd.co.uk Sun Apr 6 11:40:17 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 06 Apr 2008 15:40:17 GMT Subject: A file iteration question/problem Message-ID: <47f8eee1$0$759$bed64819@news.gradwell.net> I want to iterate through the lines of a file in a recursive function so I can't use:- f = open(listfile, 'r') for ln in f: because when the function calls itself it won't see any more lines in the file. E.g. more fully I want to do somthing like:- def recfun(f) while True: str = readline(f) if (str == "") break; # # do various tests # if : recfun(f) Is there no more elegant way of doing this than that rather clumsy "while True" followed by a test? -- Chris Green From mail at timgolden.me.uk Thu Apr 3 09:22:29 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Thu, 03 Apr 2008 14:22:29 +0100 Subject: object-relational mappers In-Reply-To: <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> <2e34e3d9-e450-41f0-8d30-dc91b3ec11b1@m73g2000hsh.googlegroups.com> <4ea0eb31-ca4a-4c13-96b7-969743664e2f@d21g2000prf.googlegroups.com> Message-ID: <47F4DA15.50209@timgolden.me.uk> Paul Boddie wrote: > ... I've come to realise that most object-relational mappers are > solving the wrong problems: they pretend that the database is somehow > the wrong representation whilst being a fast enough black box for > holding persistent data (although I doubt that many people push the > boundaries enough to see that it's not possible to ignore all details > of such a database whilst preserving performance), or they pretend > that languages like SQL (which can be cumbersome, admittedly) are > inconvenient for querying whilst replicating a less concise mechanism > for querying using client language mechanisms. Well at the risk of oversimplifying (!) I find there are two kinds of programmers using databases: those, like me, for whom the database is the application and who can happily envisage any number of interfaces, human and otherwise, to the data; and those, like 70% of the people I've ever interviewed for a job as a SQL developer, for whom the interface is the application and who simply throw things at whatever database they're presented with. The former will more likely tend to reach first for SQL to retrieve their data efficiently before passing it on to the front end for presentation or manipulation. The latter (and I've seen this far too often in interviews) will basically do "SELECT * FROM x WHERE y" to pull everything back into their VB.Net app where they feel more at home. Or, in the case of Python, reach for an ORM. I've recently used Elixir and found it very useful for a small-scale database with no more than a dozen tables, well-structured and easily understood. I'd certainly use it again for anything like that to save me writing what would amount to boilerplate SQL. But I'd hate to imagine it in the context of my day job: a messy, organic and sprawling SQL Server database with over 1,000 tables, let alone views, procedures and so on. TJG From steve at holdenweb.com Wed Apr 23 00:33:17 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 23 Apr 2008 00:33:17 -0400 Subject: Python Success stories In-Reply-To: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: azrael wrote: > Hy guys, > A friend of mine i a proud PERL developer which always keeps making > jokes on python's cost. > > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" > > This hurts. Please give me informations about realy famous > aplications. > -- > http://mail.python.org/mailman/listinfo/python-list > Ask him why, if Perl is so great, it isn't one of the Google-approved languages for internal use, when Python *is*. Ask him how it feels to program in a wrote-only language. Challenge him to a dual with dead kippers at twenty paces. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From zillow10 at googlemail.com Wed Apr 2 09:54:21 2008 From: zillow10 at googlemail.com (zillow10 at googlemail.com) Date: Wed, 2 Apr 2008 06:54:21 -0700 (PDT) Subject: developing web spider References: <2c0bec62-c098-401d-a47a-2f95c5584c79@e10g2000prf.googlegroups.com> Message-ID: <30a89852-4730-490b-8701-b915cb0901ce@q27g2000prf.googlegroups.com> On Apr 2, 6:37 am, abeen wrote: > Hello, > > I would want to know which could be the best programming language for > developing web spider. > More information about the spider, much better,, > > thanks > > http://www.imavista.com Just saw this while passing by... There's a nice book by Michael Schrenk (www.schrenk.com) called "Webbots, Spiders and Screen Scrapers" that teaches scraping and spidering from the ground up using PHP. Since you said you want more info on spiders, this book might be a good way for you to acquire concept and implementation hand-in-hand. He's also developed a nice webbot library in PHP that you can get from his website. Also comes with a nice webbot library (which you can download from the website anyway). From fetchinson at googlemail.com Tue Apr 22 11:50:10 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Tue, 22 Apr 2008 08:50:10 -0700 Subject: Does Python 2.5 include or not include SQLite engine? In-Reply-To: <67648mF2mqc8pU2@mid.uni-berlin.de> References: <480ce7af$0$35953$4fafbaef@reader2.news.tin.it> <67648mF2mqc8pU2@mid.uni-berlin.de> Message-ID: > > While reading feedback to my post "Does Python 2.5.2's embedded SQLite > > support full text searching?" I noticed that there appears to be some > > confusion regarding whether Python 2.5 includes the SQLite engine. > > > > My Windows 2.5.2 binary download includes SQLite. > > > > But other posters claim otherwise, re: Linux releases of Python 2.5? > > > > I thought one of the major features of Python 2.5 was its embedded > > SQLite engine. > > > > Thoughts? > > It is embedded. Period. Would you back that up, please? I mean with something else than "on my distro I see something vaguely resembling an sqlite shared object". The shared object lib-dynload/_sqlite3.so on most linux distros is *not* sqlite only the wrapper. This doesn't exclude the possibility of other python distros distributing sqlite itself, for example on windows this seems to be the case. > You can install the pysqlite wrapper > additionally, if you need a newer/differen sqlite version. It will be > available as a different module, though. From uniontelecardsindia at gmail.com Tue Apr 22 17:15:02 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:15:02 -0700 (PDT) Subject: Horny black homos ass licking and deep throat sucking Message-ID: <46a946c4-1f51-42bb-af14-206071056362@d45g2000hsc.googlegroups.com> Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From tjreedy at udel.edu Fri Apr 25 18:38:38 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 25 Apr 2008 18:38:38 -0400 Subject: Setting an attribute without calling __setattr__() References: Message-ID: "Joshua Kugler" wrote in message news:futgrq$ih6$1 at ger.gmane.org... | OK, I'm sure the answer is staring me right in the face--whether that answer | be "you can't do that" or "here's the really easy way--but I am stuck. I'm | writing an object to proxy both lists (subscriptable iterables, really) and | dicts. | | My init lookslike this: | | def __init__(self, obj=None): | if type(obj).__name__ in 'list|tuple|set|frozenset': | self.me = [] | for v in obj: | self.me.append(ObjectProxy(v)) | elif type(obj) == dict: | self.me = {} | for k,v in obj.items(): | self.me[k] = ObjectProxy(v) | | and I have a __setattr__ defined like so: | | def __setattr__(self, name, value): | self.me[name] = ObjectProxy(value) | | You can probably see the problem. | | While doing an init, self.me = {} or self.me = [] calls __setattr__, which | then ends up in an infinite loop, and even it it succeeded | | self.me['me'] = {} | | is not what I wanted in the first place. | | Is there a way to define self.me without it firing __setattr__? I believe self.__dict__['me'] = {} is one standard idiom. From xng at xs4all.nl Sat Apr 26 21:03:21 2008 From: xng at xs4all.nl (Martin P. Hellwig) Date: Sun, 27 Apr 2008 03:03:21 +0200 Subject: How do I say "Is this a function"? In-Reply-To: References: Message-ID: <4813d195$0$7093$e4fe514c@dreader25.news.xs4all.nl> John Henry wrote: > How do I determine is something a function? > > For instance, I don't want to relying on exceptions below: > > def f1(): > print "In f1" > > def f3(): > print "In f3" > > def others(): > print "In others" > > for i in xrange(1,3): > fct = "f%d()"%(i+1) > try: > exec fct > except: > others() > > I wish to say: > > if value of fct is a funtion, invoke it, otherwise invoke others(). > > Thanks, One way I would think of is: str(type(fct)) == "" -- mph From nick at stinemates.org Fri Apr 25 18:52:47 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 25 Apr 2008 15:52:47 -0700 Subject: multiple pattern regular expression In-Reply-To: <1209131456.20871.1249849011@webmail.messagingengine.com> References: <1209131456.20871.1249849011@webmail.messagingengine.com> Message-ID: <20080425225247.GC12662@deviL> On Fri, Apr 25, 2008 at 09:50:56AM -0400, python at bdurham.com wrote: > How about this? > > for line in file: > # ignore lines without = assignment > if '=' in line: > property, value = line.strip().split( '=', 1 ) > property = property.strip().lower() > value = value.strip() > > # do something with property, value > > Malcolm > -- > http://mail.python.org/mailman/listinfo/python-list This works until you have: string=The sum of 2+2=4 For cases where such input my be expected, I use the following regex import re str = """a=b c=d e=f string=The sum of 2+2=4""".split("\n") p = re.compile("([^=]*)=(.*)") for lines in str: key,value=p.findall(lines)[0] print key, value -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From samslists at gmail.com Sun Apr 6 03:20:41 2008 From: samslists at gmail.com (samslists at gmail.com) Date: Sun, 6 Apr 2008 00:20:41 -0700 (PDT) Subject: Implementation of Crockford's Base32 Encoding? Message-ID: <345117e9-2539-4ee0-8b27-9b1a88ddde7c@a1g2000hsb.googlegroups.com> Anyone know of a Python implementation of this: http://www.crockford.com/wrmg/base32.html Google shows a Perl library. I'm sure someone must have a Python library somewhere? :) Thanks [And yes...I know it won't be that hard to do... I will do it if it doesn't already exist, but I'd much rather spend my time on my core application.] From mfb.chikazuku at gmail.com Fri Apr 11 10:31:42 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Fri, 11 Apr 2008 16:31:42 +0200 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: <47ff8489$0$6841$2d805a3e@textnews.eweka.nl> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Gabriel Genellina wrote: > Another annoying thing with the Qt license is that you have to choose it > at the very start of the project. You cannot develop something using the > open source license and later decide to switch to the commercial licence > and buy it. > Unless you're a company with a risk of being checked for legal software etc., you can always ignore that allthough not very legal. MFB -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFH/3ZSDpaqHmOKFdQRAsupAKCN292aFK7V+AHXeQu/rzac7WAnnACgq+Al 2LzsfA5No1PTOgIc2wdYjf0= =7JyM -----END PGP SIGNATURE----- From zelegolas at gmail.com Wed Apr 16 23:51:32 2008 From: zelegolas at gmail.com (zelegolas) Date: Wed, 16 Apr 2008 20:51:32 -0700 (PDT) Subject: Python plugin for Firefox Message-ID: Hi, It's may be a stupid question but do you if someone tried to create a python plugin for firefox? If you know an Open Source project let me know... Thanks From haraldarminmassa at gmail.com Tue Apr 22 11:35:47 2008 From: haraldarminmassa at gmail.com (GHUM) Date: Tue, 22 Apr 2008 08:35:47 -0700 (PDT) Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> <7e595409-be62-4b8c-9819-a14cd363d751@c65g2000hsa.googlegroups.com> Message-ID: <944aa044-4a41-4ae9-9364-56e1bcc82488@p25g2000hsf.googlegroups.com> > Which big aplications are written in python. I see its development, There are no big applications written in Python. Big applications are written in JAVA or COBOL or C# or other legacy programming systems. If you programm in Python, your applications become quite small. Only frameworks in Python are big. best wishes Harald Join us @ EuroPython 2008 in Vilnius to have more fun with Python Submit your talk NOW www.europython.org From mwilson at the-wire.com Wed Apr 2 23:03:23 2008 From: mwilson at the-wire.com (Mel) Date: Wed, 02 Apr 2008 23:03:23 -0400 Subject: generator functions: why won't this work? References: <0aaeddf2-ee63-426e-afb3-0e1acb15adef@r9g2000prd.googlegroups.com> <8f38c3e6-1b1c-468e-8ea2-47c21322621f@i36g2000prf.googlegroups.com> Message-ID: zillow10 at googlemail.com wrote: > On Apr 2, 3:57 pm, Mel wrote: >> zillo... at googlemail.com wrote: >> >> I'd just like to test my >> >>> understanding of this. Suppose I create the following generator >>> object: >>> g = getNextScalar(1, 2, (3, 4), 5) >>> when the iterator reaches the tuple argument (3, 4) then, according to >>> Steve and George, the * in *arg causes this tuple to be expanded into >>> positional arguments, and it makes sense to do it this way. But what >>> happens when getNextScalar(arg) is used instead? >> Try it: >> >> Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) >> [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 >> Type "help", "copyright", "credits" or "license" for more information. >> >>> def a (arg): >> ... print arg >> ... >> >>> def astar (*arg): >> ... print arg >> ... >> >>> a(3,4) >> Traceback (most recent call last): >> File "", line 1, in >> TypeError: a() takes exactly 1 argument (2 given) >> >>> astar(3,4) >> (3, 4) >> >>> a((3,4)) >> (3, 4) >> >>> astar((3,4)) >> ((3, 4),) >> >>> >> >> Mel. > > Well, I understand that (unless I missed the point you're trying to > make). But with respect to the example I quoted: > > def getNextScalar(*args): > for arg in args: > if(isinstance(arg, tuple)): > for f in getNextScalar(arg): # should use *arg > yield f > else: > yield arg > where the function is declared as def getNextScalar(*arg), but is > called using getNextScalar(arg), with arg being a tuple: here the > generator is being passed a single argument, so there's no TypeError > as in your example. However, it fails - as I understand it - because > the function keeps passing the same tuple (being unable to access the > elements inside it) and goes into an infinite loop: >>>> # works for this example, but not very useful: >>>> g = getNextScalar(1, 2, 3, 4) >>>> for i in g: > print i > > > 1 > 2 > 3 > 4 > > # third argument is a tuple: >>>> g = getNextScalar(1, 2, (3, 4)) >>>> for i in g: > print i > > > 1 > 2 > > Traceback (most recent call last): > File "", line 1, in > for i in g: > File "", line 4, in getNextScalar > for f in getNextScalar(arg): > File "", line 4, in getNextScalar > for f in getNextScalar(arg): > File "", line 4, in getNextScalar > for f in getNextScalar(arg): > ... Yeah. I feel as though I haven't put the idea clearly. When a function is defined as `def astar (a*)`, then the parameters that it's called with, however many they are, are packed up into one tuple. Illustrated by those print statements. On the calling side, `a (*(3,4))` will unpack the (3,4) tuple and treat the contents as ordinary positional parameters of a. The call `a(*(3,4))` and the call `a(3,4)` are completely equivalent as far as the function a can see. This explanation is going nowhere fast. Anyway, if you define getNextScalar to pack its positional arguments into a tuple that you can iterate over, THEN if you want to feed it a tuple of values to iterate over you have to star-unpack the tuple when you call. The buggy behaviour is continually calling getNextScalar with a single positional parameter (3,4), packing that single parameter into a 1-tuple ((3,4),) , iterating over the 1-tuple to extract (3,4) and calling getNextScalar again -- ad dump. Mel. From tpatch at loftware.com Fri Apr 18 14:55:27 2008 From: tpatch at loftware.com (tpatch at loftware.com) Date: Fri, 18 Apr 2008 14:55:27 -0400 Subject: Python Logging question Message-ID: <4ECBD915C6F1254AB1AFF4B9F08287B2176F4255D4@loftexchange.loftwareinc.com> I am new to Python and I am trying to understand how to utilize the RotatingFileHandler to rollover when the file gets to a certain size. I followed some examples that I have found for setting the size and the number of files. However, I am finding that when the log file gets close to the threshold I start getting errors in the "handlers.py" file saying the file is closed. I am using Python 2.5 on Windows. Is this a problem others have seen? Is this a handler that is widely used or is there a better one that is generally used? The error that I am receiving is shown below. Traceback (most recent call last): File "C:\Python25\Lib\logging\handlers.py", line 73, in emit if self.shouldRollover(record): File "C:\Python25\Lib\logging\handlers.py", line 147, in shouldRollover self.stream.seek(0, 2) #due to non-posix-compliant Windows feature ValueError: I/O operation on closed file My configuration file is setup as such: [handler_file_detailed] class:handlers.RotatingFileHandler level:DEBUG formatter:detailed mode=a maxsize=4000000 backcount=5 args:('python.log','a',4000000,5) I would appreciate any feedback on this subject. Thanks, Todd -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin at v.loewis.de Sun Apr 6 16:22:16 2008 From: martin at v.loewis.de (=?ISO-8859-2?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 06 Apr 2008 22:22:16 +0200 Subject: Form sha1.hexdigest to sha1.digest In-Reply-To: References: <7c39af89-9cee-428c-a0bc-8202700c5aec@b1g2000hsg.googlegroups.com> <47F8CF66.1020805@v.loewis.de> Message-ID: <47F930F8.7030406@v.loewis.de> > Or hexdigest_string.decode('hex') I would advise against this, as it's incompatible with Python 3. Regards, Martin From steve at holdenweb.com Mon Apr 14 14:08:16 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 14 Apr 2008 14:08:16 -0400 Subject: py2exe, program has stoped working!? In-Reply-To: References: <9dad2754-b584-49da-8c19-ececa9389c3a@w8g2000prd.googlegroups.com> <232151d6-09ed-4a1e-9922-d66c2bf0d05b@w8g2000prd.googlegroups.com> Message-ID: <48039D90.8040205@holdenweb.com> John Machin wrote: > On Apr 14, 7:24 pm, skanem... at yahoo.se wrote: >>> Is it a console program or a gui program? >> GUI >>> What happens when you run it without py2exe? >> it works perfectly, both from within python and launching from >> "windows" >> >>> Have you searched for "has stopped working" in >> (a) your source code >> yes no such message there> (b) the py2exe source code? >> >> no, will do but doubt thats the problem >> >>> Have you managed to get any py2exe-created program to run properly? >> no > > Well, perhaps you might like to look in the samples directory of the > py2exe distribution and choose a simple example and try that. > > By the way, "popup" is what you get in a web browser. What did this > "popup" look like: a panel from your GUI software? A Windows message > box? Did it have a title across the top? What was the exact text in > the popup/panel/box? Were there any options other than to close the > window? > > Which version of Python? Which Windows, what service pack? What GUI, > what version? Care to divulge the contents of your setup.py? Apart > from your GUI, what 3rd party packages/modules are you importing? FYI "xxx has stopped working" is Vista's "user-friendly" way of reporting what Windows 3 would probably have called a "General Program Fault". It pretty much hides all useful information fro the end-user, perhaps on the grounds that end users wouldn't know what to do with the information it *could* provide anyway. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From deets at nospam.web.de Fri Apr 18 12:27:07 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Fri, 18 Apr 2008 18:27:07 +0200 Subject: Installing BeautifulSoup with easy_install (broken?) In-Reply-To: References: <66rvkdF2kqa1lU1@mid.uni-berlin.de> Message-ID: <66s0fbF2m4pafU1@mid.uni-berlin.de> Larry Bates schrieb: > Diez B. Roggisch wrote: >> Larry Bates schrieb: >>> Info: >>> >>> Python version: ActivePython 2.5.1.1 >>> Platform: Windows >>> >>> I wanted to install BeautifulSoup today for a small project and >>> decided to use easy_install. I can install other packages just >>> fine. Unfortunately I get the following error from BeautifulSoup >>> installation attempt: >>> >>> C:\Python25\Lib\SITE-P~1>easy_install BeautifulSoup >>> Searching for BeautifulSoup >>> Reading http://pypi.python.org/simple/BeautifulSoup/ >>> Reading http://www.crummy.com/software/BeautifulSoup/ >>> Reading http://www.crummy.com/software/BeautifulSoup/download/ >>> Best match: BeautifulSoup 3.0.5 >>> Downloading >>> http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup- >>> 3.0.5.tar.gz >>> Processing BeautifulSoup-3.0.5.tar.gz >>> Running BeautifulSoup-3.0.5\setup.py -q bdist_egg --dist-dir >>> c:\docume~1\larry\l >>> ocals~1\temp\easy_install-cfdxna\BeautifulSoup-3.0.5\egg-dist-tmp-gbrpp5 >>> Traceback (most recent call last): >>> File "C:\Python25\Scripts\easy_install-script.py", line 8, in >>> load_entry_point('setuptools==0.6c8', 'console_scripts', >>> 'easy_install')() >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >>> >>> and\easy_install.py", line 1671, in main >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >>> >>> and\easy_install.py", line 1659, in with_ei_usage >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >>> >>> and\easy_install.py", line 1675, in >>> File "C:\Python25\lib\distutils\core.py", line 151, in setup >>> dist.run_commands() >>> File "C:\Python25\lib\distutils\dist.py", line 974, in run_commands >>> self.run_command(cmd) >>> File "C:\Python25\lib\distutils\dist.py", line 994, in run_command >>> cmd_obj.run() >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >>> >>> and\easy_install.py", line 211, in run >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >>> >>> and\easy_install.py", line 446, in easy_install >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >>> >>> and\easy_install.py", line 476, in install_item >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >>> >>> and\easy_install.py", line 655, in install_eggs >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >>> >>> and\easy_install.py", line 930, in build_and_install >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\comm >>> >>> and\easy_install.py", line 919, in run_setup >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand >>> >>> box.py", line 27, in run_setup >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand >>> >>> box.py", line 63, in run >>> File >>> "C:\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg\setuptools\sand >>> >>> box.py", line 29, in >>> File "C:\VOL1\Larry\Websafe\Python\wstools\setup.py", line 2, in >>> >>> import py2exe >>> File "C:\VOL1\Larry\Websafe\Python\wstools\unittest.py", line 3, in >>> >>> class TextCtrlTest(unittest.TestCase): >>> AttributeError: 'module' object has no attribute 'TestCase' >>> >>> >>> Thanks in advance for any "clues". >> >> I'm not sure what happens - but I think it is suspicious that these >> "wstools" get into the way. And it looks as if wstools.unittest >> imports itself, instead of the python-unittest - which must be solved >> with getting the sys.path fixed. >> >> Diez > > Sharp eyes Diez, I overlooked that. This is a path that I search for some > tools I've written. It is set in PYTHONPATH environment variable. I > cleared > PYTHONPATH and easy_install BeautifulSoup worked. Still not quite clear > why. Mayb setuptools imports setup.py - but because of you having another one on the PYTHONPATH, it gets that instead of the one actually needed by setuptools? Only thing that helps is looking at sandbox.py, line 29. Diez From tjreedy at udel.edu Sun Apr 6 16:23:17 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 6 Apr 2008 16:23:17 -0400 Subject: traceback.print_exc() supposed to stop exception propagation. References: <69-dnW_JftMHvGTanZ2dneKdnZydnZ2d@bt.com> Message-ID: "Sami" wrote in message news:69-dnW_JftMHvGTanZ2dneKdnZydnZ2d at bt.com... | Hello, | | In the Python book that I am using to learn the language it says that | the traceback.print_exc() can be used to stop exception propagation and | make the program keep running. It is possible that the unspecified book describes an unspecified Python version that is not the same as the unspecified version that you tested with ;-). Help respondants by providing version info. Sometimes even the system/OS info is helpful, though probably not relevant here. tjr From lists at cheimes.de Sat Apr 19 11:41:51 2008 From: lists at cheimes.de (Christian Heimes) Date: Sat, 19 Apr 2008 17:41:51 +0200 Subject: why function got dictionary In-Reply-To: <35f145d8-ee1c-406e-a036-7aa9ff62d971@c65g2000hsa.googlegroups.com> References: <48075950.7050000@gmail.com> <35f145d8-ee1c-406e-a036-7aa9ff62d971@c65g2000hsa.googlegroups.com> Message-ID: <480A12BF.4040800@cheimes.de> bruno.desthuilliers at gmail.com schrieb: > A: everything (or almost) in Python is an object. Including functions, > classes, modules etc. Everything you can access from or through Python code must be an object. Every object has at least a type and a reference count. Christian From andrei.avk at gmail.com Fri Apr 4 08:57:29 2008 From: andrei.avk at gmail.com (AK) Date: Fri, 04 Apr 2008 07:57:29 -0500 Subject: Python-by-example - new online guide to Python Standard Library In-Reply-To: References: <47f2d018$0$6517$4c368faf@roadrunner.com> Message-ID: <47f617b0$0$16689$4c368faf@roadrunner.com> shurik wrote: > that's great! thanks for putting this together. what about the inspect > module? and particularly getsource :) > Glad you like it! I will add every module eventually, but I'll put inspect up on top of todo list. -- -ak Tobu | http://tobu.lightbird.net/ | Freeform DB / Tagger / PIM Python-by-Example | http://pbe.lightbird.net/ | Guide to LibRef From ivan.illarionov at gmail.com Tue Apr 15 08:01:16 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Tue, 15 Apr 2008 05:01:16 -0700 (PDT) Subject: Java or C++? References: Message-ID: <6660c92c-20d2-48bd-ae46-fee8dfb9f347@e39g2000hsf.googlegroups.com> On 15 ???, 07:46, Brian Vanderburg II wrote: [...] > C has the advantage that it does not to anything behind your back. This > is very useful especially for any form of system development or where > you must know exactly what is going on. It is still possible to do > 'object oriented' development in C, it just requires some more typing to > set up whatever is needed. Even things like COM for windows can be done > in C, it just requires manually building the 'vtable' so to speak. > Also, C seems to avoid the use of temporaries where as C++ can use them > in conversions and assignments automatically if needed. Great point. It's also possible to do Python object-oriented programming in C. 'PyMethodDefs' are the same 'vtables'. I've found that Python/C API is not that hard, the problem is a lack of good tutorials and false assumptions that ctypes or SWIG are somehow better. After `#include Python.h` C becomes very Python friendly. From duncan.booth at invalid.invalid Mon Apr 21 05:44:43 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 21 Apr 2008 09:44:43 GMT Subject: manipulating class attributes from a decorator while the class is being defined References: Message-ID: Wilbert Berendsen wrote: > Hi, is it possible to manipulate class attributes from within a > decorator while the class is being defined? > > I want to register methods with some additional values in a class > attribute. But I can't get a decorator to change a class attribute > while the class is still being defined. Something like: > > class Parser(object): > > regexps = [] > def reg(regexp): > def deco(func): > regexps.append((regexp, func)) > return func > return deco > > @reg(r'".*"') > def quoted_string(self): > pass > > How can I reach the class attribute `regexps' from within a decorator? > Have you tried passing regexps into the decorator as a default argument? def reg(regexp, regexps=regexps): def deco(func): regexps.append((regexp, func)) return func return deco From john106henry at hotmail.com Sun Apr 27 16:59:38 2008 From: john106henry at hotmail.com (John Henry) Date: Sun, 27 Apr 2008 13:59:38 -0700 (PDT) Subject: So you think PythonCard is old? Here's new wine in an old bottle. References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> Message-ID: <6db0df91-39f1-47a1-b4ca-c0351f0b67bc@y22g2000prd.googlegroups.com> On Apr 27, 12:23 pm, Fred Pacquier wrote: > John Henry said : > > > Welcome to the modernized world of Pythoncard!!! > > Hey, that's really neat ! > > I remember dabbling in Pythoncard in the early days, some years ago, it was > a very interesting project. I gave it up eventually, partly because it > seemed somewhat abandoned (I see it's still stuck in 2006 ?), but mostly > because the wxPython dependency was either unavailable or too hefty for the > sort of machines I was interested in using it on (a Sharp Zaurus then, now > Nokia Internet tablets). Since then I've been doing web apps instead, > hosted and used on the devices themselves. > > So using Pythoncard as a designer for web apps, of course that rings a > bell... > > Do you have any idea of the computing requirements of Qooxdoo and > QxTransformer, compared to a native Pythoncard app ? I wonder if your stuff > would run acceptably on today's mobile platforms (the Nokias have a Firefox > derivative that is reasonably competent at javascript), and would give it a > try if it's not too arcane. > > Do keep us posted ! > > TIA, > fp The performance of Qooxdoo is quite amazing - for a Javascript based web application. Don't know about cell-phones though. You can try their showcase web site I cited earlier. Yes, who would have throught we don't have to give up on Pythoncard? From andrei.avk at gmail.com Sat Apr 12 11:12:19 2008 From: andrei.avk at gmail.com (AK) Date: Sat, 12 Apr 2008 11:12:19 -0400 Subject: [ANN]: Python-by-Example updates In-Reply-To: References: <48000796$0$30160$4c368faf@roadrunner.com> Message-ID: <4800d15b$0$30214$4c368faf@roadrunner.com> Max Erickson wrote: > AK wrote: > >> Python-by-Example is a guide to LibRef, aiming to give examples >> for all functions, classes, modules, etc. Right now examples >> for functions in some of the most important modules are >> included. >> >> http://pbe.lightbird.net/ >> >> thanks, >> > > The second set of examples on the page for decimal doesn't look quite > right. > > The first couple of lines: > > getcontext().prec = 6 # Decimal('3.0') > Decimal("3.0") # Decimal('3.1415926535') > > I would assume that the " = 6" isn't getting processed correctly. > > > max > That block of examples was completely mis-formatted.. it should really be like this: getcontext().prec = 6 Decimal('3.0') # Decimal("3.0") [precision will be # applied after an operation, e.g. addition] Decimal('3.1415926535') # Decimal("3.1415926535") Decimal('3.1415926535') + Decimal('2.7182818285') # Decimal("5.85987") I fixed it now, thanks for the report! -- ak Tobu | http://tobu.lightbird.net/ | Freeform DB / Tagger / PIM Python-by-Example | http://pbe.lightbird.net/ | Guide to LibRef From medin0065 at gmail.com Sun Apr 20 10:48:48 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:48:48 -0700 (PDT) Subject: diner dash 3 crack Message-ID: diner dash 3 crack http://cracks.00bp.com F R E E C R A C K S From castironpi at gmail.com Mon Apr 21 19:50:21 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Mon, 21 Apr 2008 16:50:21 -0700 (PDT) Subject: sys.maxint in Python 3 References: <7xod82df4e.fsf@ruckus.brouhaha.com> Message-ID: <4de6f692-9a62-4287-b0b2-07311555e1c4@8g2000hse.googlegroups.com> On Apr 21, 5:20?pm, Paul Rubin wrote: > bearophileH... at lycos.com writes: > > In some algorithms a sentinel value may be useful, so for Python 3.x > > Better to just use object() to generate sentinels. Infinity is a number that compares always like. From castironpi at gmail.com Sun Apr 27 01:37:14 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sat, 26 Apr 2008 22:37:14 -0700 (PDT) Subject: Why can't timedeltas be divided? References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> Message-ID: <1baaf1da-f7a9-4691-9e98-5b1b1314630b@f36g2000hsa.googlegroups.com> On Apr 26, 10:27?pm, Jon Ribbens wrote: > On 2008-04-27, Martin v. L?wis wrote: > > >> sorry for bringing up such an old thread, but this seems important to me > >> -- up to now, there are thousands [1] of python programs that use > >> hardcoded time calculations. > > > Would you like to work on a patch? > > Last time I brought up this sort of thing, it seemed fairly unanimous > that the shortcomings of the datetime module were 'deliberate' and > would not be fixed, patch or no patch. I wanted to format strings with them. How does modulo a datetime sound? From martin at v.loewis.de Sat Apr 12 10:25:59 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sat, 12 Apr 2008 16:25:59 +0200 Subject: str(bytes) in Python 3.0 In-Reply-To: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> References: <74328706-9471-4c0c-a794-1df19577dd6d@t12g2000prg.googlegroups.com> Message-ID: <4800C677.5060703@v.loewis.de> > And making an utf-8 encoding default is not possible without writing a > new function? There is no default encoding anymore in Python 3. This is by design, learning from the problems in Python 2.x. Regards, Martin From exarkun at divmod.com Fri Apr 11 13:23:13 2008 From: exarkun at divmod.com (Jean-Paul Calderone) Date: Fri, 11 Apr 2008 13:23:13 -0400 Subject: pyOpenSSL 0.7 In-Reply-To: 0 Message-ID: pyOpenSSL is a wrapper around a subset of the OpenSSL API, including support for X509 certificates, public and private keys, and and SSL connections. pyOpenSSL 0.7 fixes a number of memory leaks and memory corruption issues. It also exposes several new OpenSSL APIs to Python: * SSL_get_shutdown and SSL_set_shutdown exposed as OpenSSL.SSL.Connection.get_shutdown and OpenSSL.SSL.Connection.set_shutdown * SSL_SENT_SHUTDOWN and SSL_RECEIVED_SHUTDOWN exposed as OpenSSL.SSL.SENT_SHUTDOWN and OpenSSL.SSL.RECEIVED_SHUTDOWN * X509_verify_cert_error_string exposed as OpenSSL.crypto.X509_verify_cert_error_string * X509.get_serial_number and X509.set_serial_number now accept long integers * Expose notBefore and notAfter on X509 certificates for inspection and mutation * Expose low-level X509Name state with X509Name.get_components * Expose hashing and DER access on X509Names pyOpenSSL home page: http://pyopenssl.sourceforge.net/ pyOpenSSL downloads: http://sourceforge.net/project/showfiles.php?group_id=31249 Jean-Paul Calderone From nagle at animats.com Mon Apr 7 23:10:01 2008 From: nagle at animats.com (John Nagle) Date: Mon, 07 Apr 2008 20:10:01 -0700 Subject: read large zip file In-Reply-To: References: Message-ID: <47fadf75$0$36387$742ec2ed@news.sonic.net> Gabriel Genellina wrote: > En Sun, 06 Apr 2008 19:20:31 -0300, Brian Blais > escribi?: > >> I need to read a series of large zipfiles (which only contain one >> large text file), and I noticed that the zipfile module: >> >> 1) has a read method which isn't an iterator, and returns the entire >> file selected all at once >> 2) has no readlines method, and no obvious way to implement one >> >> Is there a way to stream an unzip, so it behaves more like a file? > > Use the module from the 2.6 version; it appears to work fine even on > Python 2.4 (see this thread > http://groups.google.com/group/comp.lang.python/browse_thread/thread/71c4890cefac82aa/ > ) It's easier than that: fd = gzip.open(filename, 'rb') for line in fd : processline(line) This works even in Python 2.4. I use this routinely for processing big log files. John Nagle From bignose+hates-spam at benfinney.id.au Tue Apr 15 21:35:36 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Wed, 16 Apr 2008 11:35:36 +1000 Subject: How to have unittest tests to be executed in the order they appear? References: <8425e84a-ab1b-481a-b7c6-bb5fbc1f697c@u69g2000hse.googlegroups.com> <87zlru7le2.fsf@benfinney.id.au> Message-ID: <87r6d6ponr.fsf@benfinney.id.au> Ben Finney writes: > Find out about test fixtures in the documentation for unittest > . Find out easier with the right URL context . -- \ "I like my dental hygenist, I think she's very pretty; so when | `\ I go to have my teeth cleaned, while I'm in the waiting room I | _o__) eat an entire box of cookies." -- Steven Wright | Ben Finney From bignose+hates-spam at benfinney.id.au Tue Apr 22 23:01:49 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Wed, 23 Apr 2008 13:01:49 +1000 Subject: Explicit variable declaration References: Message-ID: <87k5ipz336.fsf@benfinney.id.au> "Filip Gruszczy?ski" writes: > I have become very interested in dynamically typed languages, > especially Python. Good to know. Welcome to the group. > I would like to ask, whether there is any way of explicitly > declaring variables used in a function? Declaring what about them? If you mean declaring the type, remember that Python deliberately allows any name to be bound to any object; type declarations can't be enforced without losing a lot of the power of Python. -- \ "Hanging one scoundrel, it appears, does not deter the next. | `\ Well, what of it? The first one is at least disposed of." -- | _o__) Henry L. Mencken | Ben Finney From dblubaugh at belcan.com Tue Apr 22 18:20:09 2008 From: dblubaugh at belcan.com (Blubaugh, David A.) Date: Tue, 22 Apr 2008 18:20:09 -0400 Subject: MESSAGE RESPONSE In-Reply-To: <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com> Message-ID: <27CC3060AF71DA40A5DC85F7D5B70F38033A4F2D@AWMAIL04.belcan.com> Is there a way to block these messages. I do not want to be caught with filth such as this material. I could lose my job with Belcan with evil messages such as these messages. David Blubaugh -----Original Message----- From: uniontelecardsindia at gmail.com [mailto:uniontelecardsindia at gmail.com] Sent: Tuesday, April 22, 2008 5:14 PM To: python-list at python.org Subject: Lucky gay sucking cock while butt fucked deep Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . This e-mail transmission contains information that is confidential and may be privileged. It is intended only for the addressee(s) named above. If you receive this e-mail in error, please do not read, copy or disseminate it in any manner. If you are not the intended recipient, any disclosure, copying, distribution or use of the contents of this information is prohibited. Please reply to the message immediately by informing the sender that the message was misdirected. After replying, please erase it from your computer system. Your assistance in correcting this error is appreciated. From jcd at sdf.lonestar.org Fri Apr 18 07:36:00 2008 From: jcd at sdf.lonestar.org (J. Clifford Dyer) Date: Fri, 18 Apr 2008 07:36:00 -0400 Subject: Unicode chr(150) en dash In-Reply-To: <1208518057.6200.6.camel@jcd-desktop> References: <48063434$0$36327$742ec2ed@news.sonic.net> <7dae96d4-48c4-46c9-9aa9-33a263b84ca4@26g2000hsk.googlegroups.com> <20080418102856.fdf5ddf3.marexposed@googlemail.com> <1208518057.6200.6.camel@jcd-desktop> Message-ID: <1208518560.6200.13.camel@jcd-desktop> On Fri, 2008-04-18 at 07:27 -0400, J. Clifford Dyer wrote: > On Fri, 2008-04-18 at 10:28 +0100, marexposed at googlemail.com wrote: > > On Thu, 17 Apr 2008 20:57:21 -0700 (PDT) > > hdante wrote: > > > > > Don't use old 8-bit encodings. Use UTF-8. > > > > Yes, I'll try. But is a problem when I only want to read, not that I'm trying to write or create the content. > > To blame I suppose is Microsoft's commercial success. They won't adhere to standars if that doesn't make sense for their business. > > > > I'll change the approach trying to filter the contents with htmllib and mapping on my own those troubling characters. > > Anyway this has been a very instructive dive into unicode for me, I've got things cleared up now. > > > > Thanks to everyone for the great help. > > > > There are a number of code points (150 being one of them) that are used > in cp1252, which are reserved for control characters in ISO-8859-1. > Those characters will pretty much never be used in ISO-8859-1 documents. > If you're expecting documents of both types coming in, test for the > presence of those characters, and assume cp1252 for those documents. > > Something like: > > for c in control_chars: > if c in encoded_text: > unicode_text = encoded_text.decode('cp1252') > break > else: > unicode_text = encoded_text.decode('latin-1') > > Note that the else matches the for, not the if. > > You can figure out the characters to match on by looking at the > wikipedia pages for the encodings. One warning: This works if you know all your documents are in one of those two encodings, but you could break other encodings, like UTF-8 this way. Fortunately UTF-8 is a pretty fragile encoding, so it's easy to break. You can usually test if a document is decent UTF-8 just by wrapping it in a try except block: try: unicode_text = encoded.text.decode('utf-8') except UnicodeEncodeError: # I think that's the proper exception # do the stuff above None of these are perfect methods, but then again, if text encoding detection were a perfect science, python could just handle it on its own. If in doubt, prompt the user for confirmation. Maybe others can share better "best practices." Cheers, Cliff From arunragini at gmail.com Thu Apr 10 13:08:29 2008 From: arunragini at gmail.com (Arun ragini) Date: Thu, 10 Apr 2008 22:38:29 +0530 Subject: class Message-ID: <264666470804101008l3d6740c2ve76a81d1815f2d0d@mail.gmail.com> Hi, I have create a class file named Mysqldb.py class Mysqldb: def __init__(self, name): #this where it tries to connect to database self.ip = ip print "Inializing session for name" def test(self): print "worked" ----------------------------------------------------- now i'm trying initialize this another python file called session.py import Mysqldb def session(): Sess = Mysqldb ("localbox") when i try to run in using python session.py. i get error message TypeError: 'module' object is not callable can any 1 help me on this. Thanks & Regards Arun -- ----- Fight back spam! Download the Blue Frog. http://www.bluesecurity.com/register/s?user=YXJ1bnJhZ2luaQ%3D%3D -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at craig-wood.com Mon Apr 28 06:30:04 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Mon, 28 Apr 2008 05:30:04 -0500 Subject: Regular Expression - Matching Multiples of 3 Characters exactly. References: Message-ID: blaine wrote: > I'm trying to write a string matching algorithm for genomic > sequences. I'm pulling out Genes from a large genomic pattern, with > certain start and stop codons on either side. This is simple > enough... for example: > > start = AUG stop=AGG > BBBBBBAUGWWWWWWAGGBBBBBB > > So I obviously want to pull out AUGWWWWWWAGG (and all other matches). > This works great with my current regular expression. > > The problem, however, is that codons come in sets of 3 bases. So > there are actually three different 'frames' I could be using. For > example: > ABCDEFGHIJ > I could have ABC DEF GHI or BCD EFG HIJ or CDE FGH IJx.... etc. > > So finally, my question. How can I represent this in a regular > expression? :) This is what I'd like to do: > (Find all groups of any three characters) (Find a start codon) (find > any other codons) (Find an end codon) > > Is this possible? It seems that I'd want to do something like this: (\w > \w\w)+(AUG)(\s)(AGG)(\s)* - where \w\w\w matches EXACTLY all sets of > three non-whitespace characters, followed by AUG \s AGG, and then > anything else. I'm not sure what the \s are doing in there - there doesn't appear to be any whitespace in your examples. > I hope I am making sense. Obviously, however, this will make sure > that ANY set of three characters exist before a start codon. Is > there a way to match exactly, to say something like 'Find all sets > of three, then AUG and AGG, etc.'. I think you want ^(\w\w\w)*(AUG)((\w\w\w)*?)(AGG) which will match up 0 or more triples, match AUG match 0 or more triples then AGG. The ? makes it a minimum match otherwise you'll match more than you expect if there are two AUG...AGG sequences in a given genome. >>> import re >>> m=re.compile(r"^(\w\w\w)*(AUG)((\w\w\w)*?)(AGG)") >>> m.search("BBBBBBAUGWWWWWWAGGBBBBBB").groups() ('BBB', 'AUG', 'WWWWWW', 'WWW', 'AGG') >>> m.search("BBBQBBBAUGWWWWWWAGGBBBBBB") >>> m.search("BBBQQBBBAUGWWWWWWAGGBBBBBB") >>> m.search("BBBQQBBQBAUGWWWWWWAGGBBBBBB") <_sre.SRE_Match object at 0xb7de33e0> >>> m.search("BBBQQBBQBAUGWWWWWWAGGBBBBBB").groups() ('BQB', 'AUG', 'WWWWWW', 'WWW', 'AGG') >>> m.search("BBBQQBBQBAUGWQWWWWWAGGBBBBBB") >>> m.search("BBBQQBBQBAUGWWWWQWWAGGBBBBBB") >>> m.search("BBBQQBBQBAUGWWQWWQWWAGGBBBBBB") >>> m.search("BBBQQBBQBAUGWWQWAWQWWAGGBBBBBB") <_sre.SRE_Match object at 0xb7de33e0> >>> m.search("BBBQQBBQBAUGWWQWAWQWWAGGBBBBBB").groups() ('BQB', 'AUG', 'WWQWAWQWW', 'QWW', 'AGG') >>> > This way, I could scan for genes, remove the first letter, scan for > more genes, remove the first letter again, and scan for more genes. > This would hypothetically yield different genes, since the frame > would be shifted. Of you could just unconstrain the first match and it will do them all at once :- (AUG)((\w\w\w)*?)(AGG) You could run this with re.findall, but beware that this will only return non-overlapping matches which may not be what you want. I'm not sure re's are the best tool for the job, but they should give you a quick idea of what the answers might be. -- Nick Craig-Wood -- http://www.craig-wood.com/nick From s0suk3 at gmail.com Fri Apr 25 18:53:53 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Fri, 25 Apr 2008 15:53:53 -0700 (PDT) Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> Message-ID: On Apr 25, 5:52?pm, Erik Max Francis wrote: > s0s... at gmail.com wrote: > > I wanted to ask for standard ways to receive data from a socket stream > > (with socket.socket.recv()). It's simple when you know the amount of > > data that you're going to receive, or when you'll receive data until > > the remote peer closes the connection. But I'm not sure which is the > > best way to receive a message with undetermined length from a stream > > in a connection that you expect to remain open. Until now, I've been > > doing this little trick: > > > data = client.recv(256) > > new = data > > while len(new) == 256: > > ? ? new = client.recv(256) > > ? ? data += new > > > That works well in most cases. But it's obviously error-prone. What if > > the client sent *exactly* two hundred and fifty six bytes? It would > > keep waiting for data inside the loop. Is there really a better and > > standard way, or is this as best as it gets? > > > Sorry if this is a little off-topic and more related to networking, > > but I'm using Python anyway. > > You solve this by having a protocol that the client and server both > agree on, so that the client knows how much to read from the server. > There are any number of ways of doing this, all of which depend on the > kind of data you want to transfer and for what purpose. > > -- > Erik Max Francis && m... at alcyone.com &&http://www.alcyone.com/max/ > ? San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis > ? ?In the final choice a solider's pack is not so heavy a burden as a > ? ? prisoner's chains. -- Dwight D. Eisenhower, 1890-1969 So, in an HTTP client/server, I'd had to look in a Content-Length header? From terry.yinzhe at gmail.com Tue Apr 29 10:44:16 2008 From: terry.yinzhe at gmail.com (Terry) Date: Tue, 29 Apr 2008 07:44:16 -0700 (PDT) Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> <16c06038-2421-478e-ba28-8131f7d552d8@b1g2000hsg.googlegroups.com> Message-ID: On Apr 29, 4:32 pm, bock... at virgilio.it wrote: > On 27 Apr, 12:27, Terry wrote: > > > > > Hello! > > > I'm trying to implement a message queue among threads using Queue. The > > message queue has two operations: > > PutMsg(id, msg) # this is simple, just combine the id and msg as one > > and put it into the Queue. > > WaitMsg(ids, msg) # this is the hard part > > > WaitMsg will get only msg with certain ids, but this is not possible > > in Queue object, because Queue provides no method to peek into the > > message queue and fetch only matched item. > > > Now I'm using an ugly solution, fetch all the messages and put the not > > used ones back to the queue. But I want a better performance. Is there > > any alternative out there? > > > This is my current solution: > > > def _get_with_ids(self,wait, timeout, ids): > > to = timeout > > msg = None > > saved = [] > > while True: > > start = time.clock() > > msg =self.q.get(wait, to) > > if msg and msg['id'] in ids: > > break; > > # not the expecting message, save it. > > saved.append(msg) > > to = to - (time.clock()-start) > > if to <= 0: > > break > > # put the saved messages back to the queue > > for m in saved: > > self.q.put(m, True) > > return msg > > > br, Terry > > Wy put them back in the queue? > You could have a defaultdict with the id as key and a list of > unprocessed messages with that id as items. > Your _get_by_ids function could first look into the unprocessed > messages for items with that ids and then > look into the queue, putting any unprocessed item in the dictionary, > for later processing. > This should improve the performances, with a little complication of > the method code (but way simpler > that implementing your own priority-based queue). > > Ciao > ----- > FB Yes, this will improve the performance. And I can see there's a problem in my current implementation. The order of the message might be changed if I put the saved message back to the end of the queue. This may cause some confusion later, though I don't want to depend too much on the message orders. And you remind me one thing -- I need to implement 'priority' for messages, so that the message with highest priority will tend to be fetched first. OMG, this is going to be much more complicated then I have expected. Thanks for your suggestion. And I hope this will also work when I move to stackless. From bj_666 at gmx.net Mon Apr 14 04:03:40 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 14 Apr 2008 08:03:40 GMT Subject: Java or C++? References: <41b4eea8-8e53-413b-b860-789fc062638c@u69g2000hse.googlegroups.com> Message-ID: <66ghesF2ju94lU4@mid.uni-berlin.de> On Mon, 14 Apr 2008 00:49:13 -0700, xakee wrote: > Well if you need an easier transition, go for java. But personally i > would recommend you to go for C/C++. What's that C/C++!? C and C++ are quite different languages. Ciao, Marc 'BlackJack' Rintsch From rowen at cesmail.net Tue Apr 29 15:54:04 2008 From: rowen at cesmail.net (Russell E. Owen) Date: Tue, 29 Apr 2008 12:54:04 -0700 Subject: Simple unicode-safe version of str(exception)? References: <67moqeF2paokjU1@mid.individual.net> <481650E3.4060603@v.loewis.de> <67on2nF2ol856U1@mid.individual.net> <87zlrcmxuk.fsf@physik.rwth-aachen.de> Message-ID: In article <87zlrcmxuk.fsf at physik.rwth-aachen.de>, Torsten Bronger wrote: > Hall?chen! > > Russell E. Owen writes: > > > [...] > > > > So...to repeat the original question, is there any simpler > > unicode-safe replacement for str(exception)? > > Please show us the tracebacks you get becuae unicode(s) must fail, > too, if there are non-ASCII characters involved. Why? What I am trying to do is get a unicode representation of the arguments of an exception. str(e), the obvious solution, fails if the exception contains one argument that is a unicode string that cannot be decoded to ASCII: UnicodeEncodeError: 'ascii' codec can't encode character...ordinal not in range(128) What I do with the resulting unicode string afterwards is a different issue. (As a matter of fact I display it on a widget that can display unicode, but if I tried to print it to my Mac Terminal it would complain about the non-ASCII characters--something I should look into fixing someday). But in any case, here are the exceptions you wanted to see. This is using Python 2.5.2 on a Mac: >>> d =u"\N{DEGREE SIGN}" >>> d u'\xb0' >>> str(d) Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'ascii' codec can't encode character u'\xb0' in position 0: ordinal not in range(128) >>> e = Exception(d) >>> str(e) Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'ascii' codec can't encode character u'\xb0' in position 0: ordinal not in range(128) >>> e Exception(u'\xb0',) >>> ",".join([unicode(s) for s in e.args]) u'\xb0' >>> Based on the dearth of better replacements I've gone with the solution that is shown as the last line above, coded as the following function (incorporating Donn Cave's excellent suggestion to use repr as a fallback). It has the minor issue that it can mask KeyboardInterrupt on older versions of Python but it's close enough. A lot of work to replace str(exc). def strFromException(exc): """Unicode-safe replacement for str(exception)""" try: return str(exc) except Exception: try: return ",".join([unicode(s) for s in exc.args]) except Exception: # in case exc is some unexpected type return repr(exc) -- Russell From steve at holdenweb.com Sun Apr 20 10:27:42 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 20 Apr 2008 10:27:42 -0400 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <480B3B2D.6040206@gmail.com> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> Message-ID: <480B52DE.8070105@holdenweb.com> Hank @ITGroup wrote: > Apology for the previous offensive title~~ > :) > Thanks, Rintsch, Arnaud and Daniel, for replying so soon. > > I redid the experiment. What following is the record - > > ``starting python`` # == Windows Task Manager: > Python.exe *4,076 *K memory-usage == > >>> st1='abcdefg'*999999 # == 10,952 K == > >>> del st1 # == *4,104*K == > >>> st1='abcdefg'*999999 # == 10,952 K == > >>> del st1 # == 4,104 K == > > >>> li = ['abcde']*999999 # == 8,024 K == > >>> del li # == *4,108* K == > > >>> from nltk import FreqDist # == 17,596 == > >>> fd = FreqDist() # == 17,596 == > >>> for i in range(999999):fd.inc(i) # == 53,412 == > >>> del fd # == *28,780* == > >>> fd2 = FreqDist() # == 28,780 == > >>> for i in range(999999):fd2.inc(i) # == 53,412 == > >>> del fd2 # == 28,780 K == > > >>> def foo(): > ... fd3 = FreqDist() > ... for i in range(999999):fd3.inc(i) > > >>> foo() # == *28,788* K == > > >>> def bar(): > ... fd4 = FreqDist() > ... for i in range(999999):fd4.inc(i) > ... del fd4 > # == 28,788 K == > >>> bar() # == 28,788 K == > > > That is my question, after ``del``, sometimes the memory space returns > back as nothing happened, sometimes not... ... > What exactly was happening??? > > Best regards to all PYTHON people ~~ > !!! Python Team are great !!! > It doesn't really make that much sense to watch memory usage as you have been doing. Your first test case appears to trigger a specific pathology, where the memory allocator actually returns the memory to the operating system when the garbage collector manages to free all of it. Most often this doesn't happen - a chunk of memory might be 99.99% free but still have one small piece used, and so while there is a large amount of "free" memory for Python to allocate without requesting more process memory, this won't be reflected in any external measurement. You are suffering from a pathological condition yourself: the desire to optimize performance in an area where you do not have any problems. I would suggest you just enjoy using Python (its memory management doesn't suck at all, so your title line was inflammatory and simply highlights your lack of knowledge) and then start to ask these questions again when you have a real issue that's stopping you from getting real work done. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gagsl-py2 at yahoo.com.ar Sun Apr 6 18:30:23 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 06 Apr 2008 19:30:23 -0300 Subject: read large zip file References: Message-ID: En Sun, 06 Apr 2008 19:20:31 -0300, Brian Blais escribi?: > I need to read a series of large zipfiles (which only contain one > large text file), and I noticed that the zipfile module: > > 1) has a read method which isn't an iterator, and returns the entire > file selected all at once > 2) has no readlines method, and no obvious way to implement one > > Is there a way to stream an unzip, so it behaves more like a file? Use the module from the 2.6 version; it appears to work fine even on Python 2.4 (see this thread http://groups.google.com/group/comp.lang.python/browse_thread/thread/71c4890cefac82aa/ ) -- Gabriel Genellina From ni at hao.com Sat Apr 26 14:22:34 2008 From: ni at hao.com (SL) Date: Sat, 26 Apr 2008 20:22:34 +0200 Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) In-Reply-To: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> Message-ID: "n00m" schreef in bericht news:6a3f8226-04c6-4ee3-b5a6-f76aca44aa31 at a23g2000hsc.googlegroups.com... > import time > t=time.time() > f=open('D:\\some.txt','r') > z=f.readlines() > f.close() > print len(z) > print time.time()-t > m=input() > print z[m] > > > #include > #include > #include > #include > > using namespace std; > char vs[1002000][99]; > FILE *fp=fopen("D:\\some.txt","r"); > > int main() { > int i=0; > while (true) { > if (!fgets(vs[i],999,fp)) break; > ++i; > } first of all I would rewrite the C loop to: int main() { int i=0; while (fgets(vs[i],999,fp)) ++i; } but I think that the difference comes from what you do in the beginning of the C source: char vs[1002000][99]; this reserves 99,198,000 bytes so expect a lot of cache trashing in the C code! Is there an implementation of f.readlines on the internet somewhere? interested to see in how they implemented it. I'm pretty sure they did it smarter than just reserve 100meg of data :) > fclose(fp); > cout << i << endl; > cout << clock()/CLOCKS_PER_SEC << endl; > > int m; > cin >> m; > cout << vs[m]; > system("pause"); > return 0; > } From asmodai at in-nomine.org Thu Apr 24 09:27:49 2008 From: asmodai at in-nomine.org (Jeroen Ruigrok van der Werven) Date: Thu, 24 Apr 2008 15:27:49 +0200 Subject: restructured text in python In-Reply-To: <807d9398-0099-4eee-b0a2-5cb0fbff2124@s33g2000pri.googlegroups.com> References: <807d9398-0099-4eee-b0a2-5cb0fbff2124@s33g2000pri.googlegroups.com> Message-ID: <20080424132749.GA8632@nexus.in-nomine.org> -On [20080424 13:16], bdsatish (bdsatish at gmail.com) wrote: >#!/usr/bin/env #!/usr/bin/env what? I guess you meant #!/usr/bin/env python >""" >Author: BDS >Version: 1.0 >""" > >def Hello(): > """ Prints a Hello World to the screen""" > print "Hello, World" > >I want to use ReSt (reStructuredText) in my docstrings or comments. >Any example of how to do it, w.r.t. above code ? Also how to invoke >rst on the Python code to do the processing ? Just run epydoc (easy_install epydoc) on your code, for example, and observe the resulting output. Once you see the output it's quite easy, since you already know reSt, how to change your docstrings to use appropriate formatting for what you need. -- Jeroen Ruigrok van der Werven / asmodai ????? ?????? ??? ?? ?????? http://www.in-nomine.org/ | http://www.rangaku.org/ | GPG: 2EAC625B Give me the strength to be who I was, and forgive me for who I am... From rhamph at gmail.com Thu Apr 17 13:24:55 2008 From: rhamph at gmail.com (Rhamphoryncus) Date: Thu, 17 Apr 2008 10:24:55 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <48070970.70306@v.loewis.de> <69cbd3d3-449f-4e64-96d5-f512cf317032@m3g2000hsc.googlegroups.com> <2a32d56a-5075-4c48-99fc-686a3f53fc26@m36g2000hse.googlegroups.com> Message-ID: <3e04397a-5e7b-4b19-a4f7-bb6f6795d6bb@e39g2000hsf.googlegroups.com> On Apr 17, 11:05 am, sturlamolden wrote: > On Apr 17, 6:03 pm, Rhamphoryncus wrote: > > > Interesting. Windows specific, but there's other ways to do the same > > thing more portably. > > I believe you can compile Python as a shared object (.so) on Linux as > well, and thus loadable by ctypes. Python is compiled as a .so, but I don't believe that makes everything private to that .so. Other means may be necessary. Not that important though. > > This > > effectively gives you a multiprocess model - a bit cheaper than that, > > but not enough to really supply GIL-free threading. > > That solution is safe. But I am looking into sharing objects. I don't > think its impossible. > > PyObject* pointers can be passed around. GILs can be acquired and > released, refcounts increased and decreased, etc. but we have to sort > out some synchronization details for the shared objects. For one > thing, we have to make sure that a garbage collector does not try to > reclaim a PyObject* belonging to another interpreter. But here we are > talking about minor changes to CPython's source, or perhaps none at > all. But can you automatically manage the reference count? ie, does your interpreter have a proxy to the other interpreter's object, or does the object itself gain a field indicating who owns it? Either way you'll need to keep the number of shared objects to a minimum, as the use of locking creates a bottleneck - only one thread can run at a time for a given object. From __peter__ at web.de Tue Apr 1 08:18:37 2008 From: __peter__ at web.de (Peter Otten) Date: Tue, 01 Apr 2008 14:18:37 +0200 Subject: Passing function objects to timeit References: <13us6o4og79iid0@corp.supernews.com> <13uu1o25912ulb0@corp.supernews.com> <13uusct7elou5e3@corp.supernews.com> Message-ID: George Sakkis wrote: > I'm afraid that the taken approach is worse than your patch. For one > thing, it allows only zero-arg functions. Of course one can work > around it by passing "lambda: f(...)" but that's adding extra overhead > which can be measurable for small fast functions. Even if passing > *args and **kwds to a Timer is allowed, that's still going to be > slower (because of tuple unpacking and whatnot) as Steven's attempt > above showed. > > I think it's at least worth bringing this to the attention of the > developers. I decided to give it a try: http://bugs.python.org/issue2527 Peter From NIE_DZIALA at gazeta.pl Thu Apr 3 02:48:41 2008 From: NIE_DZIALA at gazeta.pl (Piotr Sobolewski) Date: Thu, 03 Apr 2008 08:48:41 +0200 Subject: variable scope in list comprehensions Message-ID: Hello, there is something I don't understand about list comprehensions. I understand how does this work: print [[y for x in range(8)] for y in range(8)] However I don't understand why this one works: print [[y for y in range(8)] for y in range(8)] In this second example I have one loop nested in another. Both loops uses the same variable - y. How is it that those loops do not conflict with each other? For a moment I thought that maybe list comprehension has its own scope, but it doesn't seem to be so: print [[y for y in range(8)] for y in range(8)] print y Does anybody understand it? From mal at egenix.com Thu Apr 17 17:08:01 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Thu, 17 Apr 2008 23:08:01 +0200 Subject: Tidy module? In-Reply-To: References: Message-ID: <4807BC31.3090105@egenix.com> On 2008-04-17 21:00, Mark Reed wrote: > Is there an easy_installable egg with an interface to libtidy? I > found ?Tidy, but it looks like an inactive project, with no updates > since 2004, so I'm skeptical of its reliability. I found mxTidy, but > it's only available as part of some larger distribution, and I don't > want to replace my Python installation. Replace your Python installation ?? You only have to install two package: egenix-mx-base egenix-mx-experimental using the standard "python setup.py install" dance (if you want to compile from source) or get the prebuilt packages and do "python setup.py build --skip install". -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 17 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From m.moghimi at gmail.com Sat Apr 19 05:55:35 2008 From: m.moghimi at gmail.com (m.moghimi) Date: Sat, 19 Apr 2008 02:55:35 -0700 (PDT) Subject: Python Workshop References: <6fd50e0b-9637-422a-b1db-b76734630f54@w8g2000prd.googlegroups.com> Message-ID: On Apr 14, 9:53 pm, "m.moghimi" wrote: > On Apr 14, 5:15 pm, "Twayne" wrote: > > > > > > Hi, > > > > We are to hold a workshop about python (introduction). It will be two > > > one hour and half sessions. > > > I wanted to know which subjects do you suggest to be presented and is > > > there a good presentation file (powerpoint or ...) about this on the > > > net. > > > We thought that it may be good that first session covers the > > > introduction, zen of python, python coding syntax and the second > > > session will be about application, libraries or so. > > > I really appreciate if you tell me your ideas? > > > Depends; what's the experiene level of the audience? "Introductory" is > > a pretty vague concept; introductory to what audience? > > > -- > > -- > > Regards, > > > Twayne > > > Open Office isn't just for wimps anymore; > > OOo is a GREAT MS Office replacementwww.openoffice.org > > The audiences are computer engineering students who know programming > in c++ and some of them know java. any ideas? From victorsubervi at gmail.com Fri Apr 11 09:36:02 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Fri, 11 Apr 2008 08:36:02 -0500 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> <47FCF421.6000807@holdenweb.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> Message-ID: <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> Nope. Do not see it. My ugly stupid way works. I guess I will just proceed with that and write my howto accordingly. Victor On Thu, Apr 10, 2008 at 9:01 PM, Gabriel Genellina wrote: > En Thu, 10 Apr 2008 14:04:43 -0300, Victor Subervi > escribi?: > > > Well, what I did was this: > > > > content = col_fields[0][14].tostring() > > pic = "tmp" + str(i) + ".jpg" > > img = open(pic, "w") > > img.write(content) > > print '

' % pic > > img.close() > > where I am incrementing i. Ugly. Stupid. But if it is the only way to do > > it > > in python, and I do not want to invest the time doing it in php, which I > > think would be prettier in this instance, then I guess it will do. Your > > thoughts appreciated. > > You REALLY should read some material on how HTTP works. I'll try to sketch > a few important points. First, suppose you have an HTML page (album.html) > with two images in it: > > >

This is me: > and this is my cat > > > Suppose the URL for that page is http://some.server.com/gabriel/album.html > and you type that in your favorite browser. This is what happens: > 1) The sees the initial "http:" and says "I'll use HTTP". Then sees > "some.server.com" and opens a connection to that server on port 80. Then > sees "/gabriel.album.html" and builds an HTTP GET request for it. > 2) The server receives the GET request, looks for the "album.html" > document, determines the right Content-Type, and returns it specifying > "Content-Type: text/html" > 3) The browser receives the HTML text and tries to display it. When it > encounters the first tag it looks at the src attribute; it doesn't > know that image; so a *NEW* HTTP request is required. This time it says > "GET /images/myself.jpg" > 4) The server receives the GET request, looks for a file with that name, > determines that it's a jpeg image, and returns its contents along with a > "Content-Type: image/jpeg". > 5) The browser receives the image and is able to display it. > 6) The same thing happens with the second tag, there is a third HTTP > GET request for it. > > Note that: > - The images themselves *aren't* in the HTML page, they are somewhere > else. HTML is text and contains ONLY the URI for the image. > - THREE DIFFERENT requests are done to show that page. Each one returns A > SINGLE OBJECT of A SINGLE TYPE. > > The above was using static HTML with static images. If you use CGI to > generate dynamic content, it's the same thing. From the browser point of > view, there is no difference: it still will generate three different > requests for the three pieces (one html document with two images). > Your CGI script (or scripts) will receive three different requests then: > when requested for HTML, return HTML; when requested for an image, return > an image. They are DIFFERENT things, DIFFERENT requests, happening at > DIFFERENT times, so don't mix them. > > I think that combining Steve's responses and mine you now have enough > information to be able to solve your problems. Perhaps if you re-read the > whole thread from start you'll have now a better understanding of what's > happening. > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at cheimes.de Tue Apr 29 09:16:33 2008 From: lists at cheimes.de (Christian Heimes) Date: Tue, 29 Apr 2008 15:16:33 +0200 Subject: Zope/DTML Infuriating... In-Reply-To: References: Message-ID: Jens schrieb: > Hello Everyone. > > I am relatively new to Zope(using it for a work project) and I was > wondering if someone here could help me out or at least refer me to a > decent documentationg for Zope/DTML/Python (at the detail level of > php.net or Java API reference). http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/ > isn't really detailed enough for my taste. if it doesn't contain a > exhautive description of all available base classes it's simply no > good as a reference resource. Are you forced to use DTML for the job? ZPT are far superior and easier to work with, if you have to output HTML. Christian From breily at gmail.com Sat Apr 12 22:15:47 2008 From: breily at gmail.com (Brian) Date: Sat, 12 Apr 2008 22:15:47 -0400 Subject: Advice on tools/technologies/books, etc. In-Reply-To: References: Message-ID: I would definitely recommend Django as a framework - though the choice of framework wouldn't really affect your use of AJAX. And using AJAX actually doesn't require learning a whole lot of javascript stuff - using something like the Prototype JS library (prototypejs.org) takes care of all the details. As for making async apps, AJAX is the popular and simplest choice. Gears/Adobe Air/MS Silverlight I believe involve significantly more work. Brian On Sat, Apr 12, 2008 at 9:48 PM, Matt wrote: > I would like to create a web-based tool for risk management. The tool > actually currently exists, but it was programmed in about 1998 using > old VB, etc, and we are updating it & moving it to the web. Basically, > as a first step, i'd like to create a basic web site that takes user > input, gets data from MySQL (i might pickle it, not yet sure) and then > runs some numpy routines & outputs the results. This will give us a > platform to develop the backend. My intermediate goal is to have an > asynchronous site in which as users adjust settings, the computations > are run & graphs updated. (the computations are pretty simple, btw). > My fantasy goal would be to combine that w/ google gears so the users > could use it online or offline, but that's probably just fantasy. > > So, here are my constraints: I know Python & HTML (and lots of other > non-germane languages) but I don't know any javascript or ruby or XML. > What is the lowest cost path from here to there? I have been totally > out of the loop for this whole web 2.0 thing (I'm an economics > professor). Will it be possible for me to put together an async site > with only python? (I hesitate to use the term AJAX, b/c its unclear to > me how generic it is--do all async sites use javascript? can someone > clarify this?) If so, does it make sense to go ahead and start trying > to learn Turbogears or Pylons? Will they be able to create async > sites? Is there an easier way to do it? (Easy defined as me not having > to learn a 7th programming language) I have looked at Spyce, and that > seems an easy way to do the basic (step 1) site, but its not at all > clear that I can do async with it. CherryPy looks like it has a > steeper learning curve, but it also appears that the route to async is > clearer. > > I know where I want to go, and I know what I can do now. I don't mind > getting deeper into Python, but I'd love not to have to learn a bunch > of other languages if I can avoid it. Any thoughts/comments? > > TIA, > Matt. > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.sakkis at gmail.com Fri Apr 4 16:29:14 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 4 Apr 2008 13:29:14 -0700 (PDT) Subject: Tokenizer inconsistency wrt to new lines in comments References: <1ce40dcf-4a0a-4577-af3b-6a77ef71356c@f63g2000hsf.googlegroups.com> <6dd69a1f-96d0-4b91-b84b-a54794a31c70@u36g2000prf.googlegroups.com> Message-ID: <8b3fa4cc-deb9-4748-a63c-a6c7e5dd92ba@59g2000hsb.googlegroups.com> On Apr 4, 3:18 pm, Kay Schluehr wrote: > I guess it's just an artifact of handling line continuations within > expressions where a different rule is applied. For compilation > purposes both the newlines within expressions as well as the comments > are irrelevant. There are even two different token namely NEWLINE and > NL which are produced for newlines. NL and COMMENT will be ignored. > NEWLINE is relevant for the parser. > > If it was a bug it has to violate a functional requirement. I can't > see which one. Perhaps it's not a functional requirement but it came up as a real problem on a source colorizer I use. I count on newlines generating token.NEWLINE or tokenize.NL tokens in order to produce
tags. It took me some time and head scratching to find out why some comments were joined together with the following line. Now I have to check whether a comment ends in new line and if it does output an extra
tag.. it works but it's a kludge. George From bruno.42.desthuilliers at websiteburo.invalid Wed Apr 23 08:22:30 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Wed, 23 Apr 2008 14:22:30 +0200 Subject: problem with dictionaries In-Reply-To: References: Message-ID: <480f29f8$0$11374$426a74cc@news.free.fr> kdwyer a ?crit : > On Apr 23, 12:16 pm, Simon Strobl wrote: (snip) >> #!/usr/bin/python >> >> import sys >> >> frqlist = open('my_frqlist.txt', 'r') (snip) >> frq = {} >> >> for line in frqlist: >> line = line.rstrip() >> frequency, word = line.split('|') >> frq[word] = int(frequency) >> (snip) > It works for me, save that you need to read the file into a list first You don't, unless you're using an old python versions (I'd say 2.3 or older). Files are now their own iterators. From gagsl-py2 at yahoo.com.ar Fri Apr 11 00:15:28 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 11 Apr 2008 01:15:28 -0300 Subject: Convert PyIDispatch object to struct IDispatch* References: <90eee1e1-b1cc-48a9-8c09-173e92861f2c@a5g2000prg.googlegroups.com> Message-ID: En Thu, 10 Apr 2008 18:45:04 -0300, Huayang Xia escribi?: > I am trying to use ctypes to call dll functions. One of the functions > requires argument "struct IDispatch* ". I do have a PyIDispatch object > in python. How can I convert this "PyIDispatch object" to "struct > IDispatch* "? I think a PyIDispatch object is an IDispatch* itself. But you'll get better answers from the python-win32 list: http://mail.python.org/mailman/listinfo/python-win32 -- Gabriel Genellina From lists at cheimes.de Tue Apr 29 17:48:12 2008 From: lists at cheimes.de (Christian Heimes) Date: Tue, 29 Apr 2008 23:48:12 +0200 Subject: Sending Cntrl-C ?? In-Reply-To: <0274834e-17e1-4a95-88ec-f2aa77aeb3a9@k10g2000prm.googlegroups.com> References: <0274834e-17e1-4a95-88ec-f2aa77aeb3a9@k10g2000prm.googlegroups.com> Message-ID: <4817979C.7010601@cheimes.de> gamename schrieb: > Hi, > > I really like this recipe for controlling subprocesses: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554 > > However, I can't figure out how I can send the equivalent of "Cntrl-C" > to the subprocess. How can that be done? import os import signal import subprocess popen = subprocess(...) os.kill(popen.pid, signal.SIGINT) Or with Python 2.6+: popen.send_signal(signal.SIGINT) Christian From duncan.booth at invalid.invalid Wed Apr 30 07:56:03 2008 From: duncan.booth at invalid.invalid (Duncan Booth) Date: 30 Apr 2008 11:56:03 GMT Subject: computing with characters References: <474df$48180e0b$541fc2ec$12128@cache1.tilbu1.nb.home.nl> <481813E2.2030302@islandtraining.com> <61f41$48181d87$541fc2ec$29688@cache3.tilbu1.nb.home.nl> <2d6af$48183337$541fc2ec$23598@cache2.tilbu1.nb.home.nl> <87y76vyamr.fsf@physik.rwth-aachen.de> <87tzhjy4u2.fsf@physik.rwth-aachen.de> Message-ID: Torsten Bronger wrote: > However, join() is really bizarre. The list rather than the > separator should be the leading actor. Do you mean the list, or do you mean the list/the tuple/the dict/the generator/the file and anything else which just happens to be an iterable sequence of strings? join is a factory method for creating a string from a separator string and a sequence of strings, any sequence of strings. It doesn't make sense to either limit it to specific sequence types, or to require it as part of the iterator protocol. Having it as a function would make sense, but if it is going to be a method then it should be a method on the string types not on the sequence types. From kay.schluehr at gmx.net Sat Apr 5 03:31:12 2008 From: kay.schluehr at gmx.net (Kay Schluehr) Date: Sat, 5 Apr 2008 00:31:12 -0700 (PDT) Subject: RELEASED Python 2.6a2 and 3.0a4 References: <47F68547.1040802@v.loewis.de> Message-ID: On 4 Apr., 21:45, "Martin v. L?wis" wrote: > > The Windows x86 MSI installer is missing for both 2.6 and 3.0. > > And likely will continue to do so for some time. > > Regards, > Martin Fine. Is there also a reason? From rkmr.em at gmail.com Mon Apr 21 17:46:20 2008 From: rkmr.em at gmail.com (rkmr.em at gmail.com) Date: Mon, 21 Apr 2008 14:46:20 -0700 Subject: dynamically importing a module and function Message-ID: Hi I have a function data['function'], that I need to import from a file data['module'], in the directory data['cwd'] If I do this from python interactive shell (linux fedora core 8) from dir /home/mark it works fine: cwd = data['cwd'] os.chdir(cwd) print os.getcwd() module = __import__(data['module']) function = getattr(module, data['function']) But if I put this in a file /home/mark/work/common/funcq.py and run it from /home/mark, it throws me error like this.. how to fix this? it imports the module successfully, but it is not looking for subsequent modules in the os.getcwd().. /home/mark/work/proj1 Traceback (most recent call last): File "/home/mark/work/common/funcq.py", line 60, in if __name__ == '__main__':do() File "/home/mark/work/common/funcq.py", line 33, in do module = __import__(data['module']) File "/home/mark/app.py", line 5, in import abcde ImportError: No module named abcde From jkrukoff at ltgc.com Tue Apr 15 17:16:07 2008 From: jkrukoff at ltgc.com (John Krukoff) Date: Tue, 15 Apr 2008 15:16:07 -0600 Subject: Recurring patterns: Am I missing it, or can we get these added to the language? In-Reply-To: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> References: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Message-ID: <1208294167.5926.12.camel@localhost.localdomain> On Tue, 2008-04-15 at 11:51 -0700, Erich wrote: > Hello all, > > Today I found myself once again defining two functions that I use all > the time: nsplit and iterable. These little helper functions of mine > get used all the time when I work. Im sick of having to define them > (but am very good at it these days, less than 1 typo per function!). > It leads me to the following questions > > 1. Is this functionality already built in and im just missing it > 2. Is there some well known, good technique for these that I missed? > 3. Insert question I need to ask here (with a response) > > These are the funtions w/ explaination: > > def nsplit(s,p,n): > n -= 1 > l = s.split(p, n) > if len(l) < n: > l.extend([''] * (n - len(l))) > return l > > This is like split() but returns a list of exactly lenght n. This is > very useful when using unpacking, e.g.: > x, y = nsplit('foo,bar,baz', ',', 2) > > def iterable(item, count_str=False): > if not count_str and isinstance(item, str): > return False > try: > iter(item) > except: > return False > return True > This is just simple boolean test for whether or not an object is > iterable. I would like to see this in builtins, to mirror callable. > The optional count_str adds flexibility for string handling, since > sometimes I need to iterate over a string, but usually not. I > frequently use it to simplify my case handling in this type of > costruct: > > def foo(bar): > bar = bar if iterable(bar) else [bar] > for x in bar: > .... > > Thanks for feeback, > Erich As far as I know there is no built in function that does exactly what you want. You can certainly simplify your nsplit function a bit, but as mentioned, it's probably best just to create your own package and keep your utility functions there. It's worth noting that you almost certainly want to be doing isinstance( item, basestring ) in your iterable function instead of isinstance( item, str ), or things will get very surprising for you as soon as you have to deal with a unicode string. If you don't want the hassle of creating a separate package, and you're only interested in having these functions be handy on your local python install, you could also add them into your sitecustomize file as described here: http://docs.python.org/lib/module-site.html On linux, that's as easy as creating a file named /usr/lib/python2.5/sitecustomize.py that inserts whatever you want into the __builtin__ module, and it'll be automatically imported whenever you run python. I'd doubt there's a case for getting this functionality added to the language, as your use case seems pretty specific, and it's just not that hard to write the function that does what you want to do. -- John Krukoff Land Title Guarantee Company From gagsl-py2 at yahoo.com.ar Sat Apr 12 23:58:58 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 13 Apr 2008 00:58:58 -0300 Subject: C to python conversion References: Message-ID: En Sat, 12 Apr 2008 07:58:47 -0300, Michele Petrazzo escribi?: > Hi all, > I'm trying to translate a simple C code into a python + ctypes (where > need), but I have some problems on char conversion. The code have > to work on Linux and talk with the serial port. I think that the problem > is that I don't translate correctly the strings. > > C code: > #define START 0x33 > #define RETURN_START 0x22 > #define ADDR 0x01 > #define WRITE_CMD 0x03 > #define ALL_CMD 0xFF > ... > char buf[10]; > char buf_ret[10]; > > buf[0]=0; > buf[0]=START; > buf[1]=ADDR; > buf[2]=WRITE_CMD; > > write(_fd, buf, 6); > read(_fd,buf_ret,6); You don't even need ctypes. In C, `char` is a small integer: 'A' and the number 65 are interchangeable. In Python, there are no chars but strings of length 1, which are not the same thing as their ordinal integer. The easiest way is to define those constants as strings instead: START = chr(0x33) RETURN_START = chr(0x22) ADDR = chr(0x01) WRITE_CMD = chr(0x03) ALL_CMD = chr(0xFF) NUL = chr(0) buf = START + ADDR + WRITE_CMD + NUL + NUL + NUL # I assume the buffer was initialized to NULs, because only 3 bytes # are filled but 6 bytes are written. os.write(_fd, buf) buf_ret = os.read(_fd, 6) -- Gabriel Genellina From phil at riverbankcomputing.com Thu Apr 3 09:29:19 2008 From: phil at riverbankcomputing.com (Phil Thompson) Date: Thu, 3 Apr 2008 14:29:19 +0100 Subject: State of ctypes Support on HP-UX? In-Reply-To: References: <200804031153.26234.phil@riverbankcomputing.com> Message-ID: <200804031429.19025.phil@riverbankcomputing.com> On Thursday 03 April 2008, Thomas Heller wrote: > Phil Thompson schrieb: > > Could somebody confirm how well ctypes is supported on HP-UX (for both > > PA-RISC and Itanium) for both Python v2.4 and v2.5? > > > > I don't have access to an HP system and Google doesn't come up with a > > definitive answer (which may just mean it works fine, but prior > > experience with HP means I'd like more specific assurances). > > > > Thanks, > > Phil > > I cannot answer your question, but if you want to try it out > yourself there is the HP testdrive program: http://www.testdrive.hp.com/ > > Thomas Thanks for the pointer. Unfortunately the answer is that there is no support (at least for ctypes v1.0.2). Phil From ivan.illarionov at gmail.com Thu Apr 10 14:08:30 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Thu, 10 Apr 2008 11:08:30 -0700 (PDT) Subject: get array element References: <820d8589-8529-46af-907a-90ebaac4a6f5@a22g2000hsc.googlegroups.com> Message-ID: <76b6689f-ae00-4a6d-bcab-20069aadf370@q27g2000prf.googlegroups.com> On Apr 10, 9:22 pm, "Bryan.Fodn... at gmail.com" wrote: > I have an array, and I would like to get the indice value. > > a = array([13,14,15,16]) > > I would like something like a.getindice(15) > > If I want 15 it would return 2 >>> a = array('i', [13,14,15,16]) >>> a.index(15) 2 From schettino72 at gmail.com Wed Apr 23 15:37:22 2008 From: schettino72 at gmail.com (Eduardo Schettino) Date: Thu, 24 Apr 2008 01:07:22 +0530 Subject: Python "make" like tools (was Re: [ANN] DoIt 0.1.0 Released (build tool)) In-Reply-To: <9jIPj.124$RM4.68@read4.inet.fi> References: <9jIPj.124$RM4.68@read4.inet.fi> Message-ID: On Wed, Apr 23, 2008 at 8:39 PM, Ville M. Vainio wrote: > > Yeah, decorators get around this. > > > Perhaps you could do: > > for f in pyFiles: > @task("checker") > @depend(f) > def check(): > c("pychecker %s" % f) > > Never underestimate the magic that is nested scopes and name-agnostic > function object creation... > ok. it is possible to do everything with decorators... i agree. but i dont want "name-agnostic function object creation". i want to be able to execute every single task without executing all other tasks. thats why when defining sub-tasks it is required an extra parameter "name". I know you could add another decorator for this also :) I mean decorators could do the job i dont say they cant. *I* prefer to work with dictionaries though. Even if they are a bit more verbose. > > > > I though about using decorator for simple python-tasks but in a different > way: > > > > @task > > > > def create_folder(path): > > """Create folder given by "path" if it doesnt exist""" > > if not os.path.exists(path): > > os.mkdir(path) > > return True > > > > > > so if your python function is a task and you will use it only once you > > dont need to define a function for the 'action' and another function > > to create the task. but not implement yet also. > > > > Yeah, this is what I consider much friendlier syntax (the aim is to not be > much more verbose than make). > > Maybe it is just a bad example. I tried to put all features on single example. but in *real* life I could do like this. import os jsPath = "./" jsFiles = ["file1.js", "file2.js"] sourceFiles = [jsPath + f for f in jsFiles] compressedFiles = [jsPath + "build/" + f + ".compressed" for f in jsFiles] def task_shrink_js(): # create output folder if not os.path.exists(path): os.mkdir(path) for jsFile,compFile in zip(sourceFiles,compressedFiles): action = 'java -jar custom_rhino.jar -c %s > %s'% (jsFile, compFile) yield {'action':action, 'name':jsFile, 'dependencies':(jsFile,), 'targets':(compFile,) } Can I challenge you to do this with any other build tool? i guess anything more complicated than this you want to create a python function separate from the task definition anyway. My examples are from scratch. I dont use a "standard library". I could also document the short-cuts :P. I was afraid that including the short-cuts would make it more complicated for who is trying to learn it. if you dont define any dependencies or args to the function you dont need to return a dictionary. just the action: def task_simple_shell(): return "echo spam" def task_simple_python(): def say_spam(): print "spam" return True return say_spam # or from our discussion def task_create_build_folder(): def create_folder(): path = jsPath + "build" if not os.path.exists(path): os.mkdir(path) return True return create_folder > > > apart from one .py file installation (easy_install is not enough?) > > thats what i am trying to do. > > > > easy_install is not really enough - it introduces a dependency that you > can't get around by just shipping a short .py file with your project. > what about shipping a single egg file with the whole package? ( I am not very much familiar with this subject) > 'Paver' seems to have the right idea: > > http://www.blueskyonmars.com/projects/paver/index.html > Thanks for the link. I took a quick look on its documentation. It seems that "paver" doesnt keep track of file-dependencies at all. So it is more like a setuptools extension commands than a "full-feature" build system with "smart" re-build and dependency support. "doit" target is not on creating releases for python projects only. it can do it also, but it can do much more. You can read about my motivation to start another build tool project on http://schettino72.wordpress.com/2008/04/14/doit-a-build-tool-tale/ > But it's still *slightly* too big: > man, it is hard to make you happy :) the doit egg file containg the whole packge is 27782 bytes on my system. but you also need the command line script 154 bytes. cheers, Eduardo From Lie.1296 at gmail.com Sun Apr 20 07:33:38 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 20 Apr 2008 04:33:38 -0700 (PDT) Subject: from __future__ import print References: <3af159ca-131d-4a7e-8435-c9df54a6f5ec@l64g2000hse.googlegroups.com> Message-ID: On Apr 13, 7:23 pm, Roy Smith wrote: > In article > , > > Lie wrote: > > I wish py3k > > would make it an option whether to treat print as statement or > > function though. > > Arrrgghhhhh! No, don't even go there. If you want optional parens, use > Perl :-) Not optional parens, but a simple print statement coupled with a powerful print function. This print statement would only have basic printing functionality such as : print "Hello" print var print var, "Hello too" specifically, these would be removed: print var, print >> unstdout, var This is because it is sometimes annoying to type this: print("Hello") print("World") print("This") print("is") print("Captain") print("Kirk") because of the double enclosement (parens () and quotes ""), especially when you're just slipping a simple debugging statement. This also eases transition between older codes, because while you uses regular print statements everyday, you don't do print redirection and comma-ended printing everyday, and it would be easier to just convert those advanced printing functionality rather than converting all printing statements. From hotani at gmail.com Tue Apr 22 13:40:42 2008 From: hotani at gmail.com (hotani) Date: Tue, 22 Apr 2008 10:40:42 -0700 (PDT) Subject: python-ldap: searching without specifying an OU? Message-ID: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> I am attempting to pull info from an LDAP server (Active Directory), but cannot specify an OU. In other words, I need to search users in all OU's, not a specific one. Here is what works: con = ldap.initialize("ldap://server.local") con.simple_bind_s('user at domain', pass) result = con.search_ext_s( 'OU=some office, DC=server, DC=local', ldap.SCOPE_SUBTREE, "sAMAccountName=username", ['mail'] )[0][1] for i in result: print "%s = %s" (i, result[i]) But i really need it to not require an OU. When I remove that part, it breaks. Or it just won't find the user. Is there a proper syntax for this that I'm missing? Maybe a different search function? From egbert.bouwman at hccnet.nl Tue Apr 15 12:55:27 2008 From: egbert.bouwman at hccnet.nl (egbert) Date: Tue, 15 Apr 2008 18:55:27 +0200 Subject: Java or C++? In-Reply-To: References: Message-ID: <20080415165526.GA21682@hccnet.nl> What is the role or position of C# in this context ? If I remember well, some people have said that C# is an improved C++ or Java. e -- Egbert Bouwman - Keizersgracht 197 II - 1016 DS Amsterdam - 020 6257991 ======================================================================== From mage at mage.hu Wed Apr 9 07:25:01 2008 From: mage at mage.hu (Mage) Date: Wed, 09 Apr 2008 13:25:01 +0200 Subject: is Pylons alive? Message-ID: <47FCA78D.3040203@mage.hu> Hello, I don't want to be impolite, just in short: I am thinking about leaving RoR and coming back to Python. I've missed the last two years in Python, however I have been subscribed to this list and there are not too many e-mails about Pylons in my mailbox. On my Gentoo the latest Pylons ebuild has date "jul 2007" or something like last summer. It has testing keywords both for x86 and amd64. (No stable version available). It's available on my debian "testing" desktop. Before spending much time for investigating, I would like to ask you: is Pylons the framework I look for if I want to come back to Python and develop MVC web apps? Mage From nick at stinemates.org Fri Apr 18 14:42:07 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 11:42:07 -0700 Subject: Brand New! In-Reply-To: References: <7f1828bf-ebe7-4111-bc59-70d125facb0a@d26g2000prg.googlegroups.com> Message-ID: <20080418184207.GE19281@deviL> On Wed, Apr 16, 2008 at 02:35:54AM -0300, Gabriel Genellina wrote: > En Tue, 15 Apr 2008 20:37:40 -0300, agent E 10 > escribi?: > > On Apr 14, 8:37?pm, Benjamin wrote: > >> On Apr 14, 9:00 pm, agent E 10 wrote:> ? ?Hi, > >> I'm brand new to programming. Have any suggestions? I'm young. > >> > Was it a good idea to start with python? I was planning on creating a > >> > very simple program that asked yes/no questions for a school project. > >> > >> IMHO, Python is an excellent language to start with. Have you read the > >> tutorial?http://docs.python.org/tut/tut.html > > > > No, I haven't. I have been reading off of this site > > http://www.freenetpages.co.uk/hp/alan.gauld/ is this a good site to > > learn off of? About how long will it take me to learn the basics of > > the language? > > I'm unsure if teaching Javascript, VBScript and Python at the same time is > a good thing, I'd think one would get a language soup and mix all the > concepts, but if it works for you, go ahead. > For other resources, see the beginners section in the Python wiki: > http://wiki.python.org/moin/BeginnersGuide I agree and disagree! As long as the student understands how the different parts play together, and the Web medium is what gets him interested in python, I don't see any harm! That's a pretty big assumption though! -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org From kkuhl05 at gmail.com Tue Apr 29 11:45:31 2008 From: kkuhl05 at gmail.com (Kevin K) Date: Tue, 29 Apr 2008 08:45:31 -0700 (PDT) Subject: File IO Issues, help :( References: <6ceb3950-edb3-41c7-ab5a-8f6aec949bf7@j22g2000hsf.googlegroups.com> <1fd8deae-1ed4-493c-a508-06c528c4ee1f@r66g2000hsg.googlegroups.com> Message-ID: <3d9a8971-3480-4743-8b07-575547947bee@i76g2000hsf.googlegroups.com> On Apr 29, 1:07 am, Kevin K wrote: > On Apr 29, 12:55 am, Peter Otten <__pete... at web.de> wrote: > > > > > Kevin K wrote: > > > On Apr 29, 12:38 am, "Eric Wertman" wrote: > > >> chuck in a jsfile.close(). The buffer isn't flushing with what you > > >> are doing now. jsfile.flush() might work... not sure. Closing and > > >> re-opening the file for sure will help though. > > > > Yeah sorry I forgot to include the close() in the quote but its there. > > > In fact I moved it up a bit and still no luck heres the new code: > > > > jsfile = open("../timeline.js", "r+") > > > jscontent = jsfile.readlines() > > > jsfile.truncate() > > > > for line in jscontent: > > > if re.search('var d =', line): > > > line = "var d = \""+mint['1'].ascdate()+"\"\n" > > > print line > > > jsfile.write(line) > > > jsfile.close() > > > > I tried this can got the same result...?? > > > """ > > truncate(...) > > truncate([size]) -> None. Truncate the file to at most size bytes. > > > Size defaults to the current file position, as returned by tell(). > > """ > > > After the readlines() call the current file position is at the end of the > > file. Try jsfile.truncate(0). > > > Also note that readlines() reads the whole file into memory. For large files > > it would therefore be better to write to a new file and rename it > > afterwards. > > > Peter > > Thanks Peter that seemed to be most of the problem, however I now have > a bunch of null characters in the file. Could it be an unwanted line > in the list that im writing? > > Thanks, > Kevin Awesome that seems to work fine! Thanks a lot for your help guys! From sturlamolden at yahoo.no Wed Apr 2 19:04:14 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Wed, 2 Apr 2008 16:04:14 -0700 (PDT) Subject: Summary of threading for experienced non-Python programmers? References: <87od8yolay.fsf@mulj.homelinux.net> <654ng1F2cvh8aU1@mid.uni-berlin.de> <87d4pe9caz.fsf@mulj.homelinux.net> <656vhnF2e9ao7U1@mid.uni-berlin.de> <8763v4otts.fsf@mulj.homelinux.net> <65fulvF2eiaalU1@mid.uni-berlin.de> Message-ID: <6224eb1e-0d48-47d7-bfcd-94e6dc9b5ce2@c19g2000prf.googlegroups.com> On Apr 2, 1:26 am, "Diez B. Roggisch" wrote: > It did *not* say that it supports every existing, more powerful and > generally better asynchronous mechanism supported by any OS out there. > Even though it would certainly be nice if it did :) Python's standard library should have an asynch module that uses aio on Linux and i/o completion ports on Windows. It should work with files and tcp sockets alike. From fredrik at pythonware.com Sun Apr 6 06:55:46 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 06 Apr 2008 12:55:46 +0200 Subject: Self in Interactive Interpreter In-Reply-To: <22a3ca84-242c-48de-b55c-d402d91ac280@b5g2000pri.googlegroups.com> References: <22a3ca84-242c-48de-b55c-d402d91ac280@b5g2000pri.googlegroups.com> Message-ID: kj7ny wrote: > With some of my larger applications, it doesn't seem to work well to > try to run the whole thing in the interpreter. At least for me, I am > not a big IDE sort of programmer. I am much more comfortable in vim > and command line stuff. I suppose I should use the IDE more. you don't need to run the whole thing, of course; just structure your code so you can work with individual modules, import *those* modules into the command line interface, and call their contents from there. cutting and pasting and rewriting code to be able to test it strikes me as tedious and error prone compared to the alternative. (and this has nothing to with IDE:s. I've worked full time with Python for ages, and I still do 99.5% of my programming with an editor and a command line) From jimgardener at gmail.com Sat Apr 26 03:24:23 2008 From: jimgardener at gmail.com (jimgardener) Date: Sat, 26 Apr 2008 00:24:23 -0700 (PDT) Subject: problem with listdir Message-ID: hi i have a directory containing .pgm files of P5 type.i wanted to read the pixel values of these files ,so as a firststep i wrote code to make a list of filenames using listdir pgmdir="f:\code\python\pgmgallery" # where i have pgm files g2=listdir(pgmdir) i get the following error WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect: 'f:\\code\\python\pgmgallery/*.*' i am running python on winXP ..can anyone tell me why i get this error? From emurphy42 at socal.rr.com Tue Apr 15 01:48:20 2008 From: emurphy42 at socal.rr.com (Ed Murphy) Date: Mon, 14 Apr 2008 22:48:20 -0700 Subject: Game design : Making computer play In-Reply-To: References: Message-ID: <480441dd$0$31765$4c368faf@roadrunner.com> v4vijayakumar wrote: > On Apr 14, 1:00 pm, v4vijayakumar > wrote: > .... >> I can post initial version of the game (implemented using html/ >> javascript) in couple of hours here. > > The game is here, > > http://v4vijayakumar.googlepages.com/goats-and-tigers.html The list of valid moves is incomprehensible to humans without actually drawing all the possible moves. Without an exhaustive check for validity, I think the following is an accurate summary: * Treat the board as a 5x6 grid with the corners removed and the top 4 cells merged. * Any piece can move one space up, down, left, or right. * A tiger can eat a goat by jumping over it, thereby moving two spaces up, down, left, or right. From aaron.watters at gmail.com Fri Apr 18 11:58:56 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Fri, 18 Apr 2008 08:58:56 -0700 (PDT) Subject: py3k concerns. An example Message-ID: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Why is the migration to py3k a concern? For example I have libraries which use string%dictionary substitution where the dictionary is actually an object which emulates a dictionary. The __getitem__ for the object can be very expensive and is only called when needed by the string substitution. In py3k string%dictionary is going away. Why? I have no idea. The replacement is a string.format(...) method which supports dictionary calling. string.format(**dictionary) But dictionary calling doesn't support dictionary emulation. So in the example below the substitution works but the call fails. === code class fdict(dict): def __getitem__(self, item): return "got("+item+")" def fn(**d): print d["boogie"] if __name__=="__main__": fd = fdict() print "attempting string substitution with fake dictionary" print print "hello there %(boogie)s" % fd # <-- works print print "now attempting function call with fake dictionary" print fn(**fd) # <-- fails === output % python2.6 dtest.py attempting string substitution with fake dictionary hello there got(boogie) now attempting function call with fake dictionary Traceback (most recent call last): File "dtest.py", line 17, in fn(**fd) File "dtest.py", line 7, in fn print d["boogie"] KeyError: 'boogie' ==== end of output Consequently there is no simple way to translate my code, I think. I suspect you will find this kind of subtle issue in many places. Or worse, you won't find it until after your program has been installed in production. It's a damn shame because if string%dict was just left in it wouldn't be an issue. Also, if making f(**d) support dict emulation has any negative performance implications then I don't want it please. sigh. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=crack+open From frikker at gmail.com Wed Apr 23 12:40:51 2008 From: frikker at gmail.com (blaine) Date: Wed, 23 Apr 2008 09:40:51 -0700 (PDT) Subject: Unix Device File Emulation References: <14086588-0bb7-48ba-a6ed-9132552bd851@b1g2000hsg.googlegroups.com> <480f6376$0$9037$5402220f@news.sunrise.ch> Message-ID: <9ee87070-be57-4a66-a152-3f36c1cc8f0c@k13g2000hse.googlegroups.com> On Apr 23, 12:27 pm, "Martin Blume" wrote: > "blaine" schrieb > > > > > > > # Fake Nokia Screen Emulator > > import sys, os > > > class nokia_fkscrn: > > def __init__(self, file): > > if not os.path.exists(file): > > os.mkfifo(file) > > self.fifodev = open(file, 'r') > > def read(self): > > while 1: > > r = self.fifodev.readline() > > print r > > > nokia = nokia_fkscrn('dev.file') > > nokia.read() > > > This works at first, but when I write to the 'dev.file' > > for the first time, the text is displayed as intended, > > but then the program just keeps spitting out blank lines. > > I can continue to write to the file > > (using echo 'test\n' > dev.file) > > and this shows up in my output, but amist a giant mass > > of scrolling blank lines. This also causes my CPU > > usage to shoot up to 100%. > > > Any ideas? This is OS X 10.4 > > while 1: > r = self.fifodev.readline() > if r: print r > > According to my docs, readline() returns an empty string > at the end of the file. > Also, you might want to sleep() between reads a little bit. > > IMHO. HTH. > Martin Oh ok, that makes sense. Hmm. So do I not want to use readline()? Or is there a way to do something like 'block until the file is not empty'? From paul at boddie.org.uk Tue Apr 22 07:36:26 2008 From: paul at boddie.org.uk (Paul Boddie) Date: Tue, 22 Apr 2008 04:36:26 -0700 (PDT) Subject: subprocess module is sorely deficient? References: Message-ID: On 22 Apr, 12:52, Harishankar wrote: > > Is there any way to use non-blocking Popen objects using subprocess? and 2 - > is there a way to kill the subprocess in a platform independent manner in a > purely Pythonic way? I thought initially that this problem is simple enough, > but over the last couple of days I've been really struggling to find any > answer. I've been through dozens of mailing list archives in to find a > solution. Unfortunately none of the solutions seem to fit my needs. If you want some hints about using subprocesses with non-blocking I/O, you might find some in my jailtools and pprocess projects: http://www.python.org/pypi/jailtools http://www.python.org/pypi/pprocess Although these projects involve things which are not exactly cross- platform, the communications mechanisms should be portable, perhaps with a bit of effort (since I don't recall whether the poll library function is available on Windows, so you might have to use the select function instead). It can be awkward sustaining non-blocking communications with processes if they use buffered I/O, and the only way I could make Python-based subprocesses work in jailtools was to invoke them with the unbuffered option (-u). > My only solution seems to be to offer the end user the mencoder command line > and make them execute it manually and be done with it but that seems a rather > weak solution. The subprocess module may be an improvement over the popen2 module and various os module functions, but it's still rather arcane. Paul From darcy at druid.net Wed Apr 16 13:40:32 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Wed, 16 Apr 2008 13:40:32 -0400 Subject: Finally had to plonk google gorups. In-Reply-To: <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <20080416134032.cb2738e8.darcy@druid.net> On Wed, 16 Apr 2008 08:23:50 -0700 (PDT) Mike Driscoll wrote: > My workplace doesn't offer NNTP, so there is no good way to browse > c.l.py here. And I haven't been able to get NNTP to work from my home > either. Hi Mike; I am half way to killing Google groups myself. Your message, and allother Google groups messages, is coloured so that I can evaluate how much I will miss. So far it looks like it will make reading this group a whole lot more pleasant and so I will probably kill them soon. There are alternatives. I run an ISP http://www.Vex.Net/ that offers NNTP access to my shell users. You can also receive this group as a mailing list which is how I read it. Google is not the only option out there. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From NikitaTheSpider at gmail.com Thu Apr 10 11:12:36 2008 From: NikitaTheSpider at gmail.com (Nikita the Spider) Date: Thu, 10 Apr 2008 11:12:36 -0400 Subject: Stripping scripts from HTML with regular expressions References: <47fd2942$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: In article , "Reedick, Andrew" wrote: > > -----Original Message----- > > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > > list-bounces+jr9445=att.com at python.org] On Behalf Of Michel Bouwmans > > Sent: Wednesday, April 09, 2008 3:38 PM > > To: python-list at python.org > > Subject: Stripping scripts from HTML with regular expressions > > > > Hey everyone, > > > > I'm trying to strip all script-blocks from a HTML-file using regex. > > > > [Insert obligatory comment about using a html specific parser > (HTMLParser) instead of regexes.] Yah, seconded. To the OP - use BeautifulSoup or HtmlData unless you like to reinvent wheels. -- Philip http://NikitaTheSpider.com/ Whole-site HTML validation, link checking and more From fengxie.shi at gmail.com Mon Apr 21 12:22:25 2008 From: fengxie.shi at gmail.com (fengxie.shi at gmail.com) Date: Mon, 21 Apr 2008 09:22:25 -0700 (PDT) Subject: wholesale air force one bape adidas wallet bikini tn shox air max air rift References: <5406db08-7333-46cb-bffc-787b9771c1a3@y18g2000pre.googlegroups.com> Message-ID: <6ccfb178-747d-4da4-8b8f-32524f474e11@x19g2000prg.googlegroups.com> We are the professional and serious wholesaler of brand products,such as shoes, clothing, handbags, sunglasses, hats, belts, and so on.We have many brands such as nike,adidas,puma,Gucci,North face.All goods are with best service,highest quality,competitive price,and safe timely deliverry If you are interested in these goods,don?t hasitate to cantact us please. Our website: http://www.nike1.com.cn. MSN?email?: okshoes at live.com Products list : Jordans shoes Jordan 1 shoes http://www.nike1.com.cn Jordan 2 shoes http://www.nike1.com.cn Jordan 3 shoes http://www.nike1.com.cn Jordan 4 shoes http://www.nike1.com.cn Jordan 5 shoes http://www.nike1.com.cn Jordan 6 shoes http://www.nike1.com.cn Jordan 7 shoes http://www.nike1.com.cn Jordan 8 shoes http://www.nike1.com.cn Jordan 9 shoes http://www.nike1.com.cn Jordan 10 shoes http://www.nike1.com.cn Jordan 11 shoes http://www.nike1.com.cn Jordan 12 shoes http://www.nike1.com.cn Jordan 13 shoes http://www.nike1.com.cn Jordan 14 shoes http://www.nike1.com.cn Jordan 16 shoes http://www.nike1.com.cn Jordan 17 shoes http://www.nike1.com.cn Jordan 18 shoes http://www.nike1.com.cn Jordan 19 shoes http://www.nike1.com.cn Jordan 20 shoes http://www.nike1.com.cn Jordan 21 shoes http://www.nike1.com.cn Jordan 22 shoes http://www.nike1.com.cn Jordan 23 shoes http://www.nike1.com.cn Nike Air Max Air Max 87 shoes http://www.nike1.com.cn Air Max 90 shoes http://www.nike1.com.cn Air Max 91 shoes http://www.nike1.com.cn Air Max 95 shoes http://www.nike1.com.cn Air Max 97 shoes http://www.nike1.com.cn Air Max 2003 shoes http://www.nike1.com.cn Air Max 360 shoes http://www.nike1.com.cn Air Max 180 shoes http://www.nike1.com.cn Air Max TN shoes http://www.nike1.com.cn Air Max TN2 shoes http://www.nike1.com.cn Air Max TN3 shoes http://www.nike1.com.cn Air Max TN6 shoes http://www.nike1.com.cn Air Max TN8 shoes http://www.nike1.com.cn Air Max LTD shoes http://www.nike1.com.cn Air Max 1 id shoes http://www.nike1.com.cn Nike Shox Shox NZ shoes http://www.nike1.com.cn Shox R4 shoes http://www.nike1.com.cn Shox TL3 shoes http://www.nike1.com.cn Shox TL4 shoes http://www.nike1.com.cn Shox TL shoes http://www.nike1.com.cn Shox OZ shoes http://www.nike1.com.cn Shox Rival shoes http://www.nike1.com.cn Shox Classic shoes http://www.nike1.com.cn Shox Energia shoes http://www.nike1.com.cn Nike Air Force 1 Air Force 1 low shoes http://www.nike1.com.cn Air Force 1 mid shoes http://www.nike1.com.cn Air Force 1 high shoes http://www.nike1.com.cn Air Force 1 25 shoes http://www.nike1.com.cn Nike Dunk sb shoes Dunk low shoes http://www.nike1.com.cn Dunk high shoes http://www.nike1.com.cn Adidas shoes http://www.nike1.com.cn Adidas Running shoes http://www.nike1.com.cn Adidas 35 shoes http://www.nike1.com.cn Adidas City shoes http://www.nike1.com.cn Adidas Goodyear shoes http://www.nike1.com.cn Adidas NBA shoes http://www.nike1.com.cn Adidas Y-3 shoes http://www.nike1.com.cn T-MAC shoes http://www.nike1.com.cn Rift shoes http://www.nike1.com.cn BapeStar shoes http://www.nike1.com.cn Football shoes http://www.nike1.com.cn Timberland boots shoes http://www.nike1.com.cn Hardaway shoes http://www.nike1.com.cn James shoes http://www.nike1.com.cn Puma shoes http://www.nike1.com.cn Prada shoes http://www.nike1.com.cn Prada low shoes http://www.nike1.com.cn Prada high shoes http://www.nike1.com.cn Dsquared shoes http://www.nike1.com.cn Gucci shoes http://www.nike1.com.cn Gucci low shoes http://www.nike1.com.cn Gucci high shoes http://www.nike1.com.cn LV shoes http://www.nike1.com.cn Kappa shoes http://www.nike1.com.cn Converse shoes http://www.nike1.com.cn Dsquared shoes http://www.nike1.com.cn D&G shoes http://www.nike1.com.cn Lacoste shoes http://www.nike1.com.cn Umbro shoes http://www.nike1.com.cn Versace shoes http://www.nike1.com.cn Woman boots http://www.nike1.com.cn ugg boots http://www.nike1.com.cn Burberry shoes http://www.nike1.com.cn EVISU shoes http://www.nike1.com.cn Hogan Shoes http://www.nike1.com.cn Hurricane Shoes http://www.nike1.com.cn handbag Bags http://www.nike1.com.cn LV Bag http://www.nike1.com.cn Gucci Bag http://www.nike1.com.cn Prada Bag http://www.nike1.com.cn D&G Bag http://www.nike1.com.cn Leather Bag http://www.nike1.com.cn A&F Bag http://www.nike1.com.cn Juicy Bag http://www.nike1.com.cn Guess Bag http://www.nike1.com.cn Feidi Bag http://www.nike1.com.cn Coach Bag http://www.nike1.com.cn Chloe Bag http://www.nike1.com.cn Chanel Bag http://www.nike1.com.cn ugg bag http://www.nike1.com.cn Burberry bag http://www.nike1.com.cn Dooney&Bourke bag http://www.nike1.com.cn Jimmy Choo bag http://www.nike1.com.cn Dior bag http://www.nike1.com.cn Purse CHANEL Purse http://www.nike1.com.cn COACH Purse http://www.nike1.com.cn Else Purse http://www.nike1.com.cn GUCCI Purse http://www.nike1.com.cn LV Purse http://www.nike1.com.cn man purse http://www.nike1.com.cn Strap BAPE Strap http://www.nike1.com.cn BOSS Strap http://www.nike1.com.cn CHANEL Strap http://www.nike1.com.cn D&G Strap http://www.nike1.com.cn GIORGIO ARMANI Strap http://www.nike1.com.cn GUCCI Strap http://www.nike1.com.cn LV Strap http://www.nike1.com.cn Glasses ARMANI Glasses http://www.nike1.com.cn BURBERRY Glasses http://www.nike1.com.cn BVLGARI Glasses http://www.nike1.com.cn Ray.Ban Glasses http://www.nike1.com.cn VERSACE Glasses http://www.nike1.com.cn Prada Glasses http://www.nike1.com.cn OKEY Glasses http://www.nike1.com.cn LV Glasses http://www.nike1.com.cn HERMES Glasses http://www.nike1.com.cn EL.FERROL Glasses http://www.nike1.com.cn DIOR Glasses http://www.nike1.com.cn D&G Glasses http://www.nike1.com.cn GUCCI Glasses http://www.nike1.com.cn CHANEL Glasses http://www.nike1.com.cn CS Glasses http://www.nike1.com.cn CARTIER Glasses http://www.nike1.com.cn Watch http://www.nike1.com.cn Rolex Watch http://www.nike1.com.cn clothing http://www.nike1.com.cn 10 DEEP clothing http://www.nike1.com.cn A&F clothing http://www.nike1.com.cn Abercrombie&Fitch clothing http://www.nike1.com.cn Abercrombie & Fitch clothing http://www.nike1.com.cn ADICOLOR clothing http://www.nike1.com.cn ADIDAS clothing http://www.nike1.com.cn AK clothing http://www.nike1.com.cn ARMANI T-shirt http://www.nike1.com.cn ARMANI Sweater http://www.nike1.com.cn polo Sweater http://www.nike1.com.cn Artful dodger clothing http://www.nike1.com.cn BAPE clothing http://www.nike1.com.cn BBC clothing http://www.nike1.com.cn CLH clothing http://www.nike1.com.cn COOGI clothing http://www.nike1.com.cn D&G clothing http://www.nike1.com.cn DSQUARED clothing http://www.nike1.com.cn ED clothing http://www.nike1.com.cn HARDY clothing http://www.nike1.com.cn EVISU clothing http://www.nike1.com.cn EVS clothing http://www.nike1.com.cn GGG clothing http://www.nike1.com.cn G-STAR clothing http://www.nike1.com.cn LACOSTE T-shirt clothing http://www.nike1.com.cn Lacoste Sweater http://www.nike1.com.cn LRG clothing http://www.nike1.com.cn NY clothing http://www.nike1.com.cn O&L clothing http://www.nike1.com.cn POLO T-shirt 3 4 5 http://www.nike1.com.cn POLO T-shirt clothing http://www.nike1.com.cn Byrberry T-shirt http://www.nike1.com.cn UGG clothing http://www.nike1.com.cn Byrberry clothing http://www.nike1.com.cn NFL Jersey http://www.nike1.com.cn scarf scarves http://www.nike1.com.cn jeans http://www.nike1.com.cn AFTFUL DODGER jeans http://www.nike1.com.cn AKA STASH HOUSE jeans http://www.nike1.com.cn APE jeans http://www.nike1.com.cn BBC jeans http://www.nike1.com.cn COOGI jeans http://www.nike1.com.cn D&G jeans http://www.nike1.com.cn DIESEL jeans http://www.nike1.com.cn ED jeans http://www.nike1.com.cn EVISU jeans http://www.nike1.com.cn Gino jeans http://www.nike1.com.cn G-Star jeans http://www.nike1.com.cn LRG jeans http://www.nike1.com.cn RMC jeans http://www.nike1.com.cn ROCK jeans http://www.nike1.com.cn SHMACK jeans http://www.nike1.com.cn TR jeans http://www.nike1.com.cn ugg jeans http://www.nike1.com.cn hat cap http://www.nike1.com.cn Chanel hat Cap http://www.nike1.com.cn D&G hat cap http://www.nike1.com.cn G-Star hat Cap http://www.nike1.com.cn Gucci hat Cap http://www.nike1.com.cn lv hat Cap http://www.nike1.com.cn POLO hat Cap http://www.nike1.com.cn Prada hat Cap http://www.nike1.com.cn PSP sp2 http://www.nike1.com.cn MP3 MP4 http://www.nike1.com.cn Mobile phone http://www.nike1.com.cn iPhone http://www.nike1.com.cn nokia 8800 http://www.nike1.com.cn nokia n95 http://www.nike1.com.cn nokia n93i http://www.nike1.com.cn nokia n73 http://www.nike1.com.cn memory stick http://www.nike1.com.cn memory strip http://www.nike1.com.cn From sjmachin at lexicon.net Sat Apr 5 19:56:18 2008 From: sjmachin at lexicon.net (John Machin) Date: Sat, 5 Apr 2008 16:56:18 -0700 (PDT) Subject: Best way to check if string is an integer? References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> Message-ID: <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> On Apr 6, 9:25 am, Mark Dickinson wrote: > On Apr 5, 6:19 pm, skanem... at yahoo.se wrote: > > > which is the best way to check if a string is an number or a char? > > could the 2nd example be very expensive timewise if i have to check a > > lot of strings? > > You might be interested in str.isdigit: > > >>> print str.isdigit.__doc__ > > S.isdigit() -> bool > > Return True if all characters in S are digits > and there is at least one character in S, False otherwise. > This doesn't cater for negative integers. From bruno.desthuilliers at gmail.com Wed Apr 2 14:24:34 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 11:24:34 -0700 (PDT) Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> Message-ID: On 2 avr, 16:52, sam wrote: > Bruno Desthuilliers napisa?(a): > > > Don't misunderstand me : I'm not saying that class-based is better (or > > worse) than prototype, I'm not saying that Python is perfect, I'm not > > saying that your points are not worth any consideration, I'm just saying > > that, from your arguments, I have the very strong impression that you > > don't know enough about Python's object model to understand it's > > coherence and strength (and I've probably expressed it a rather harsh > > way - please bear with me). If I'm wrong, please say so, pardon me and > > we'll move ahead. > > I understand you. Thanks for spending time to write all that things. > > The point is that when I say: > > -- you should have same syntax of lambdas and ordinary functions > > then Python gurus say: > > -- lambda is very good and is so special, that has its own syntax > > But it seems to me, that lambda syntax was introduced because of interpreter > limitations -- indentation and expressions. So it is not perfect, but must be as > it is now. You're of course right on this. OTHO, I found out that with languages that let you define "full-blown" inline anonymous functions (like javascript), I tend to make any non- trivial function into an ordinary named one - mainly for readability. So, while I often use Python's lambdas, the imposed limitations is ok to me since I wouldn't use it for anything more complex. But I may be a bit biased here since I discovered the concept of anonymous functions (and quite a lot of other more or less functional programming inspired stuff) with Python. Also - as a side note - while the syntax is a bit different, the resulting object is an ordinary function. > Then I say: > > -- __id is awful, because it is a trick to prefix names > > and gurus say: > > -- it is good solution for name conflicts > > But somebody may prefix his names with class names and cause nameconflict, Here the problem is more philosophical than anything else. Python's philosophy is that most programmers are responsible and normally intelligent, so treating them all like retarted dummies because someone might one day do something stupid is just wasting everyone's time. This is also why there's no language-enforced access restriction, only a simple stupid convention to denote implementation stuff from API. The fact is that it JustWork. > so > maybe it is not so good? It's enough. FWIW, I'm not sure I had a use-case for this feature more than a couple time in 7+ years. > I would prefer to hear something like "other solutions > were very complex, and our zen says 'Simple is better than complex.', so we > decided to use this simple and not perfect solution" Simple, indeed. But why "not perfect" ? What else would you want ? From steve at holdenweb.com Thu Apr 24 22:49:59 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 24 Apr 2008 22:49:59 -0400 Subject: Remove multiple inheritance in Python 3000 In-Reply-To: <60fc4333-6d2b-40f5-b311-031d90a38d39@k37g2000hsf.googlegroups.com> References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <60fc4333-6d2b-40f5-b311-031d90a38d39@k37g2000hsf.googlegroups.com> Message-ID: sturlamolden wrote: > On Apr 22, 1:07 pm, GD wrote: > >> Please remove ability to multiple inheritance in Python 3000. > > Too late for that, PEPs are closed. > >> Multiple inheritance is bad for design, rarely used and contains many >> problems for usual users. >> >> Every program can be designed only with single inheritance. > > That's how the Java designers were thinking as well: If MI is allowed, > programmers will suddenly get an irresistible urge to use MI to write > unmaintainable spaghetti code. So let's disallow MI for the sake of > common good. Fortunately, Python is not designed to be fool proof > against fools. If you cannot use MI properly, then don't use that. > > >> I also published this request athttp://bugs.python.org/issue2667 > > You reported MI as a bug??? > The eventual disposition was "closed, invalid". regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From sophacles at gmail.com Tue Apr 15 14:51:53 2008 From: sophacles at gmail.com (Erich) Date: Tue, 15 Apr 2008 11:51:53 -0700 (PDT) Subject: Recurring patterns: Am I missing it, or can we get these added to the language? Message-ID: <3129948b-aa10-4e6a-aecf-432716e7c2b4@w5g2000prd.googlegroups.com> Hello all, Today I found myself once again defining two functions that I use all the time: nsplit and iterable. These little helper functions of mine get used all the time when I work. Im sick of having to define them (but am very good at it these days, less than 1 typo per function!). It leads me to the following questions 1. Is this functionality already built in and im just missing it 2. Is there some well known, good technique for these that I missed? 3. Insert question I need to ask here (with a response) These are the funtions w/ explaination: def nsplit(s,p,n): n -= 1 l = s.split(p, n) if len(l) < n: l.extend([''] * (n - len(l))) return l This is like split() but returns a list of exactly lenght n. This is very useful when using unpacking, e.g.: x, y = nsplit('foo,bar,baz', ',', 2) def iterable(item, count_str=False): if not count_str and isinstance(item, str): return False try: iter(item) except: return False return True This is just simple boolean test for whether or not an object is iterable. I would like to see this in builtins, to mirror callable. The optional count_str adds flexibility for string handling, since sometimes I need to iterate over a string, but usually not. I frequently use it to simplify my case handling in this type of costruct: def foo(bar): bar = bar if iterable(bar) else [bar] for x in bar: .... Thanks for feeback, Erich From colas.francis at gmail.com Thu Apr 17 11:54:07 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Thu, 17 Apr 2008 08:54:07 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> Message-ID: <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> On 17 avr, 17:40, s0s... at gmail.com wrote: > > Yuck! No way!! If you *want* to make your code that hard to read, I'm > > sure you can find lots of ways to do so, even in Python, but don't > > expect Python to change to help you toward such a dubious goal. > > Well, my actual code doesn't look like that. Trust me, I like clean > code. > > > Seriously, examine your motivations for wanting such a syntax. Does it > > make the code more readable? (Absolutely not.) Does it make it more > > maintainable. (Certainly not -- consider it you needed to change > > CONSTANT2 to a different value some time in the future.) > > Yes, it makes it more readable. And yes, it does make it (a lot) more > maintainable. Mainly because I don't have those four variables, I have > about thirty. And I think I won't need to one or two of them, but > maybe all of them at once. Out of sheer curiosity, why do you need thirty (hand-specified and dutifully commented) names to the same constant object if you know there will always be only one object? From zillow10 at googlemail.com Wed Apr 2 09:36:59 2008 From: zillow10 at googlemail.com (zillow10 at googlemail.com) Date: Wed, 2 Apr 2008 06:36:59 -0700 (PDT) Subject: generator functions: why won't this work? References: Message-ID: <0aaeddf2-ee63-426e-afb3-0e1acb15adef@r9g2000prd.googlegroups.com> On Apr 2, 4:42 am, "Gabriel Genellina" wrote: > En Tue, 01 Apr 2008 23:56:50 -0300, escribi?: > > > I'm trying to understand generator functions and the yield keyword. > > I'd like to understand why the following code isn't supposed to work. > > (What I would have expected it to do is, for a variable number of > > arguments composed of numbers, tuples of numbers, tuples of tuples, > > etc., the function would give me the next number "in sequence") > > #################################### > > def getNextScalar(*args): > > for arg in args: > > if ( isinstance(arg, tuple)): > > getNextScalar(arg) > > else: > > yield arg > > #################################### > > You're not the first one in getting confused. After all, this schema works > well for other recursive constructs. > Perhaps a progression of working code samples will help to understand what > happens here. The simplest thing would be to just print the items as > they're encountered, in a recursive call: > > py> data = (1, 2, (3,4,(5,6),7)) > py> > py> print "1) using print" > 1) using print > py> > py> def getNextScalar(args): > ... for arg in args: > ... if isinstance(arg, tuple): > ... getNextScalar(arg) > ... else: > ... print arg > ... > py> getNextScalar(data) > 1 > 2 > 3 > 4 > 5 > 6 > 7 > > Now one could try to collect the numbers in a list: > > py> print "2) using extend" > 2) using extend > py> > py> def getNextScalar(args): > ... result = [] > ... for arg in args: > ... if isinstance(arg, tuple): > ... result.extend(getNextScalar(arg)) > ... else: > ... result.append(arg) > ... return result > ... > py> getNextScalar(data) > [1, 2, 3, 4, 5, 6, 7] > > Note that we use two different list methods: for individual items, we use > "append", but for tuples we use "extend" in the recursive call. If extend > weren't available, we could emulate it with append: > > py> print "3) using append" > 3) using append > py> > py> def getNextScalar(args): > ... result = [] > ... for arg in args: > ... if isinstance(arg, tuple): > ... for item in getNextScalar(arg): > ... result.append(item) > ... else: > ... result.append(arg) > ... return result > ... > py> getNextScalar(data) > [1, 2, 3, 4, 5, 6, 7] > > See how we need an additional loop to iterate over the results that we get > from the recursive call. > Now instead of building an intermediate result list, we delegate such task > over the caller, and we use a generator that just yields items; this way, > we remove all references to the result list and all result.append calls > become yield statements. The inner loop has to remain the same. The yield > statement acts somewhat as an "append" over an outer list created by the > generator's caller. > > py> print "4) using yield" > 4) using yield > py> > py> def getNextScalar(args): > ... for arg in args: > ... if isinstance(arg, tuple): > ... for item in getNextScalar(arg): > ... yield item > ... else: > ... yield arg > ... > py> getNextScalar(data) > > py> list(getNextScalar(data)) > [1, 2, 3, 4, 5, 6, 7] > > I hope it's more clear now why you have to use yield on the recursive call > too. > > > Perhaps this: > > yield *iterable > > could be used as a shortcut for this: > > for __temp in iterable: yield __temp > > > > -- > Gabriel Genellina Thanks to everyone for your very helpful replies. I think I was trying to use generator functions without first having really read about iterators (something I still haven't done, although I've managed to extrapolate some details based on your comments), and therefore really "putting the cart before the horse". I was interpreting getNextScalar(arg) on line 3 as a function call in the usual sense rather than an object that was being created but never used. I have a question about the other issue that was pointed out. With reference to the following (corrected) code: def getNextScalar(*args): for arg in args: if(isinstance(arg, tuple)): for f in getNextScalar(*arg): # why not getNextScalar(arg)? yield f else: yield arg although I've verified that the line 4 needs to be "for f in getNextScalar(*arg)" rather than "for f in getNextScalar(arg)" when passing multiple arguments to the function, I'd just like to test my understanding of this. Suppose I create the following generator object: g = getNextScalar(1, 2, (3, 4), 5) when the iterator reaches the tuple argument (3, 4) then, according to Steve and George, the * in *arg causes this tuple to be expanded into positional arguments, and it makes sense to do it this way. But what happens when getNextScalar(arg) is used instead? I presume that (3,4) is passed as a single tuple argument, if(isinstance(arg, tuple)) is true, and the tuple is passed again as an the argument to getNextScalar()... ad infinitum. The alternative is to define a function that takes a tuple, as Gabriel has done. Regards, AK From mail at timgolden.me.uk Tue Apr 15 10:43:08 2008 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 15 Apr 2008 15:43:08 +0100 Subject: Get oldest folder In-Reply-To: <22671872.735671208269119432.JavaMail.root@hrndva-web19-z02> References: <22671872.735671208269119432.JavaMail.root@hrndva-web19-z02> Message-ID: <4804BEFC.4000105@timgolden.me.uk> jyoung79 at kc.rr.com wrote: > I'd like to be able to get the path to the oldest folder in whatever directory I'm currently in. And just because I'm feeling silly: import os print os.popen ("dir /b /ad /od /tc c:\python25\lib\site-packages").readline () TJG From sidhpurwala.huzaifa at gmail.com Mon Apr 14 06:04:07 2008 From: sidhpurwala.huzaifa at gmail.com (Huzaifa Sidhpurwala) Date: Mon, 14 Apr 2008 15:34:07 +0530 Subject: Remote mac address In-Reply-To: <54lbd5-dk7.ln1@nb2.stroeder.com> References: <54lbd5-dk7.ln1@nb2.stroeder.com> Message-ID: <48032C17.9050305@gmail.com> Michael Stro"der wrote: > Matias Surdi wrote: > >> Anyone knows how having the IP address of a host on the lan could I get >> the mac address of that hosr? >> >> p/d: Parsing the output of arp -a is not an option. >> > > Any reason why arp is not an option? > But the ARP table is exactly what you need to access. This is probably > system-specific. > > You could also try to send ARP requests yourself: > http://www.secdev.org/projects/scapy/ > http://www.ibm.com/developerworks/aix/library/au-pythocli/ > > Ciao, Michael. > From mccredie at gmail.com Mon Apr 21 16:42:48 2008 From: mccredie at gmail.com (Matimus) Date: Mon, 21 Apr 2008 13:42:48 -0700 (PDT) Subject: Code question References: Message-ID: <60ffc058-488f-4e58-b3c9-a60c21595c6f@w8g2000prd.googlegroups.com> On Apr 21, 12:05 pm, wrote: > I've been trying to figure out a way to combine lists similar to how zip() works. The main > difference though is I want to work with different length lists and combine them. I came up with > the example below, which returns a list like I'm wanting. I'm assuming it's somewhat efficient > (although I wonder if the lists were huge that the 'if' statement might slow things down?). > > If anyone has time, I was wondering if you could share your thoughts on whether this is an > efficient way to do something like this, if it's horrible and slow, etc. > > Thanks! > > Jay > > # ---------------------------- > > > def combineLists(theLists): > cntList = len(theLists) > lenList = [len(x) for x in theLists] > > maxList = max(lenList) > > combinedList = [] > > for x in range(maxList): > for n in range(cntList): > if lenList[n] > x: combinedList.append(theLists[n][x]) > > print combinedList > > combineLists([a, b, c]) > > # ---------------------------- > > # --> ['a', '1', 'a1', 'b', '2', 'b2', 'c', 'c3', 'd4', 'e5'] I would probably do something like this: >>> def combine(*seqs): ... seqs = [iter(s) for s in seqs] ... while seqs: ... for g in seqs: ... try: ... yield g.next() ... except StopIteration: ... seqs.remove(g) ... >>> a = 'abc' >>> b = '12' >>> c = 'a1 b2 c3 d4 e5'.split() >>> list(combine(a,b,c)) ['a', '1', 'a1', 'b', '2', 'b2', 'c', 'c3', 'd4', 'e5'] It has the advantage that it uses the generator protocol, so you can pass in any type of sequence. It uses arbitrary arguments to make its use closer to that of zip. It is also a generator, so it takes advantage of lazy evaluation. Notice that there is never any checking of length. Matt From medin0065 at gmail.com Sun Apr 20 10:49:10 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:49:10 -0700 (PDT) Subject: nikon lightroom crack Message-ID: nikon lightroom crack http://cracks.00bp.com F R E E C R A C K S From skanemupp at yahoo.se Fri Apr 11 07:01:42 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Fri, 11 Apr 2008 04:01:42 -0700 (PDT) Subject: tkinter, overwrite Label-text? References: <666s2qF2il38sU1@mid.uni-berlin.de> Message-ID: <403d094e-2704-40c0-a0b3-dd335b19af85@m1g2000pre.googlegroups.com> On 10 Apr, 18:03, Marc 'BlackJack' Rintsch wrote: > On Thu, 10 Apr 2008 07:37:08 -0700, skanemupp wrote: > > i know how to do this already. the problem is i want the text to stay > > in the windowa nd not start overwriting "Answer:". > > Then don't use `place()` but let Tkinter handle the layout with the pack > and/or grid layout manager. GUIs with `place()` are a bad idea because > the GUI may look odd or is even unusable on other peoples computers with > other screen resolutions, fonts, and font sizes. > > Ciao, > Marc 'BlackJack' Rintsch ok but i have trouble using grid. if i try to use a Label witht he text answer in the following code it doenst work very well. from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") ##l = Label(mygui, text="Answer: ") ##l.grid(row=2, column=1, columnspan=2) e = Entry(mygui) e.grid(row=1, column=1, columnspan=4) c = Entry(mygui) c.grid(row=2, column=1, columnspan=4) def Disp(nstr): e.insert(INSERT, nstr) def Calc(): expr=e.get() c.delete(0, END) try: c.insert(END, eval(expr)) except: c.insert(END, "Not computable") def Erase(): e.delete(0,END) c.delete(0, END) def Backspace(): a=len(e.get()) e.delete(a-1,END) #e.delete(INSERT, END) #e.delete(ANCHOR,END) x = 1 y = 4 for char in '123+456-789*0()/.': b = Button(mygui, text=char, command=lambda n=char:Disp(n), width=2, height=1) b.grid(row=y, column=x) x=x+1 if x==5: x=1 y=y+1 b = Button(mygui, text="^", command=lambda n="**":Disp(n), width=2, height=1) b.grid(row=8, column=2) b = Button(mygui, text="C",command=Erase, width=2, height=1) b.grid(row=8, column=3) b = Button(mygui, text="c",command=Backspace, width=2, height=1) b.grid(row=8, column=4) b = Button(mygui, text="=",command=Calc, width=18, height=1) b.grid(row=9, column=1, columnspan=8) mygui.mainloop() From dave.l.harrison at gmail.com Fri Apr 18 05:27:21 2008 From: dave.l.harrison at gmail.com (David Harrison) Date: Fri, 18 Apr 2008 19:27:21 +1000 Subject: testing client-server sockets In-Reply-To: <48086408.4070205@al.com.au> References: <4808627F.5040906@al.com.au> <48086408.4070205@al.com.au> Message-ID: On 18/04/2008, Astan Chee wrote: > Server code: > > import os, sys, socket > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > host = '' > port = 5602 > s.bind((host,port)) > try: > s.listen(1) > while 1: > conn, addr = s.accept() > print 'client is at', addr > data = conn.recv(1000000) > data = data * 10 > z = raw_input() > conn.send(data) > conn.close() > except Exception: > s.close() > > Client code: > > import sys, os, socket > > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > host = 'hostIP' > port = 5602 > s.connect((host,port)) > s.send(dlg.user.GetValue()) > i =0 > while True: > data = s.recv(1000000) > i+=1 > if (i<5): > print data > if not data: > break > print 'received', len(data), 'bytes' > s.close() I just ran the code (albeit with a tiny change to send a small string instead so I could see what was going on), and it seems to work fine ... anything else that might be different ? From grflanagan at gmail.com Mon Apr 7 05:46:34 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Mon, 7 Apr 2008 02:46:34 -0700 (PDT) Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> <47f514c5$0$6520$4c368faf@roadrunner.com> Message-ID: <95e51af9-c0c8-4e46-a1fe-ac75a0305859@24g2000hsh.googlegroups.com> On Apr 3, 8:33 pm, AK wrote: > AK wrote: > > Hello, > > > I find that I learn easier when I go from specific examples to a more > > general explanation of function's utility and I made a reference guide > > that will eventually document all functions, classes and methods in > > Python's Standard Library. For now, I covered about 20 most important > > modules. I will be adding more modules and eventually I'll cover > > everything. Here's my progress so far, let me know if this is useful; > > I'll be glad to hear comments/suggestions/etc: > > >http://www.lightbird.net/py-by-example/ > > I uploaded an updated site incorporating most of the suggestions I > received and fixing some errors along the way. I will be adding more > examples to modules that are already covered and will try to add more > modules during the following week. Thanks again to all who posted advice > and comments! > I don't know if you've heard of Sphinx, it's being used to generate the Python 2.6 docs but can also be used standalone. It may have benefits for a project like yours, particularly with regard to collaboration and maintainability over the long-term. I've been playing about with it myself and put together a `very` basic site using a few of the pages from your site: The generated html is here: http://gflanagan.net/site/python/pbe/pbe-sphinx-skeleton-build-0.1.tar.gz http://gflanagan.net/site/python/pbe/pbe-sphinx-skeleton-build-0.1.zip And the actual Sphinx 'app': http://gflanagan.net/site/python/pbe/pbe-sphinx-skeleton-0.1.tar.gz http://gflanagan.net/site/python/pbe/pbe-sphinx-skeleton-0.1.zip For which you would need Sphinx (obviously): http://sphinx.pocoo.org/ which depends on docutils: http://docutils.sourceforge.net/ and pygments: http://pygments.org/ There's a make.bat for windows and a MakeFile for unix but the latter is untested. I've no time to spend on it further, but you're welcome to what's there if you've any interest. (I repeat, it's just a proof of concept - don't expect too much.) As you might see, I preferred 'doctest' style code rather than the commented results, but each to their own. Sphinx uses ReST as its input format - below is what I cooked up for 'restifying' your html, not perfect but a brave attempt! All the best. Gerard ------------------------------------------------------------------ import textwrap import re import os from BeautifulSoup import BeautifulSoup def onmatch(m): return '\nRESULT' + m.group(2) result = re.compile('(# )?(.*?)', re.DOTALL | re.MULTILINE) src = 'c:/workspace/pbe/orig/' for infile in os.listdir(src): if not infile.endswith('-module.html'): continue title = infile[:-5] infile = src + infile outfile = infile[:-4] + 'rst' out = open(outfile, 'wb') out.write(title + '\n') out.write('='*len(title) + '\n\n') soup = BeautifulSoup(open(infile).read()) for p in soup.findAll('ul'): print >> out for line in textwrap.wrap(p.span.contents[0], 79): print >> out, line.lstrip() #code = ''.join(comment.sub(onmatch, str(p.pre))) code = result.sub(onmatch, str(p.pre)).splitlines()[1:-1] if code: print >> out print >> out, '::' print >> out for line in code: line = line.strip() if line: leader = ' ' if line.startswith('RESULT'): line = line[len('RESULT'):] else: leader += '>>> ' print >> out, leader + line else: print >> out print >> out out.close() ------------------------------------------------------------------ From gagsl-py2 at yahoo.com.ar Tue Apr 1 01:16:15 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 01 Apr 2008 02:16:15 -0300 Subject: python persistence References: <8b1723d9-67c8-4fe5-b07b-22b0b9311519@8g2000hsu.googlegroups.com> <7f58b5f4-3195-472c-b307-dec71b12aaa8@y21g2000hsf.googlegroups.com> <44f04bf3-4edc-4cb4-9e54-fe51b5e591bc@e39g2000hsf.googlegroups.com> <80d1731d-a3c6-4fce-81fd-9c3f3537e59b@d21g2000prf.googlegroups.com> <5386cf08-c155-4fbb-8373-dbbb9829a9e7@m3g2000hsc.googlegroups.com> <3c27b270-e593-4f2a-b881-68126319760c@8g2000hsu.googlegroups.com> Message-ID: En Tue, 01 Apr 2008 00:48:35 -0300, escribi?: > We do have, but on Windows, file is not locked to multi-tasking, > shelve. But why don't we have types in there, or non-string > primitives in keys? > >>>> c= shelve.open( 'temp', 'c' ) >>>> c['0']= 'a' >>>> c.sync() >>>> del c >>>> c= shelve.open( 'temp', 'c' ) >>>> c['0'] > 'a' > >>>> c['0'].append( 0 ) >>>> c['0'] > [] The above session doesn't make sense unless it's somewhat related to "on Windows, file is not locked to multi-tasking," and another process has modified the database in-between. I don't think the problem is restricted to Windows only. There exist file locking mechanisms. > And why don't primitive mutations modify contents of disk? A > metaquestion. They do, if you pass writeback=True to the shelve constructor, but read the docs. shelve is a simple class; if it can't fulfill your needs, you may want to use a relational database (perhaps with an ORM like SQLObjects or SQLAlchemy) or an object database like ZODB or Durus. >>>> c['0']= type('None',(),{}) > Traceback (most recent call last): > pickle.PicklingError: Can't pickle : it's not > found as __main__.None Don't do that then. Or use the available pickle hooks to customize how such classes may be pickled. All persistence mechanisms have limitations. -- Gabriel Genellina From patrickkidd.lists at gmail.com Fri Apr 11 03:26:32 2008 From: patrickkidd.lists at gmail.com (Patrick Stinson) Date: Fri, 11 Apr 2008 01:26:32 -0600 Subject: problem using import from PyRun_String In-Reply-To: References: <664bf2b80804081801u79ae9192h90c03c84c1ef35ce@mail.gmail.com> <664bf2b80804090931y78d9e34dof268784cc6a6cde9@mail.gmail.com> Message-ID: <664bf2b80804110026h4175426dk97977471ce20d189@mail.gmail.com> Great, that was the answer I was looking for, thank you. I'll respond with how well it works. On Thu, Apr 10, 2008 at 12:16 AM, Gabriel Genellina wrote: > En Wed, 09 Apr 2008 13:31:22 -0300, Patrick Stinson > escribi?: > > > Well, I eventually want to add an import hook, but for now I'd rather > > just > > get the import statement working normally again. > > I have embedded python as a scripting engine in my application. To do > > this, > > I create a new empty module, run the script text using PyRun_String() > > passing the module's __dict__ as locals and globals. This populates the > > module's __dict__ with the resulting object references from the script > > text. > > Instead of PyRun_String, use PyImport_ExecCodeModuleEx, which takes care > of setting __builtins__ and other details. > You will need to compile the source first (using Py_CompileStringFlags) > which is a good thing anyway, to help catching errors. > > > As I said before I must be forgetting some other module init stuff > > because I > > had to manually populate the modules' __dict__ with references from the > > __builtin__ module in order to get the basic stuff like abs, range, etc. > > That's not exactly what CPython does; if you inspect globals() you don't > see abs, range, etc. Instead, there is a __builtins__ attribute (note the > "s") that points to the __builtin__ module or its __dict__. > > > I understand what __builtin__ is used for, but the C struct pointing to > > the > > code frame that contains the import statement has a builtin member that > > apparently does not contain the __import__ function, hence my question. > > There must be some difference in the way code is parsed and a copy of > the > > __builtin__ module is passed normally and the way I am doing it. > > When a frame builtins != internal builtins, Python runs in "restricted > execution mode", and disallows access to some objects and attributes, I > think that __import__ is one of them. > See http://docs.python.org/lib/module-rexec.html > (That's why it's important to use the right way to create a module) > > > So, finding the place where this module bootstrapping normally happens > > would > > be awesome, because I sort of feel like I'm hacking this method running > > into > > problems like this. > > Exactly. The simplest way would be to save the source code on disk and > just import it, letting Python do all the dirty work. But > compiling+PyImport_ExecCodeModule should work, I presume - any feedback is > welcome! > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Patrick Kidd Stinson http://www.patrickkidd.com/ http://pkaudio.sourceforge.net/ http://pksampler.sourceforge.net/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From gagsl-py2 at yahoo.com.ar Tue Apr 15 01:13:19 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Tue, 15 Apr 2008 02:13:19 -0300 Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: En Tue, 15 Apr 2008 01:30:05 -0300, Sverker Nilsson escribi?: > No one forces me, but sooner or later they will want a Python 3.0 and > then a 3.1 whatever. Welcome to the software industry! If it isn't Python changing, it's the operating system, the processor architecture, the network connectivity, whatever. Only very abstract and generic applications may survive a long time without being affected by changes in the environment. You choose to develop a very specific tool tied to the specifics of memory management in Python (a really good idea, btw), but unfortunately you'll have to adapt it to changes in the language. > I don't want that fuzz. As about the C versions, I am not that > worried. What's your point? You said that a C program doesn't have to be changed when the compiler/language changes, and I refuted that assertion. > I just like want to write a program that will stay working. And maybe > I can go on with something else hopefully than just compatibility > fixes. They take some work afterall. > > It seems hard with Python. Esp. 2 -> 3 Bad luck, you just decided to write your program in the transition phase... In a couple years, I think 3 will be reasonably as stable as 2.x today. -- Gabriel Genellina From aaron.watters at gmail.com Wed Apr 2 12:06:25 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Wed, 2 Apr 2008 09:06:25 -0700 (PDT) Subject: april fools email backfires References: Message-ID: <51ab8eb3-e76e-40f1-b924-27297fdfea1c@m3g2000hsc.googlegroups.com> On Apr 2, 11:07 am, Paul McGuire wrote: > > Can you post a link? > > -- Paul Sorry. It came from private email. And I don't want to get anyone in trouble... -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=secret+feature From oakley at bardo.clearlight.com Sun Apr 13 09:45:50 2008 From: oakley at bardo.clearlight.com (Bryan Oakley) Date: Sun, 13 Apr 2008 08:45:50 -0500 Subject: tkinter, annoying grid-problem In-Reply-To: <094b0808-053a-4a36-be11-694bb3835bb5@q1g2000prf.googlegroups.com> References: <094b0808-053a-4a36-be11-694bb3835bb5@q1g2000prf.googlegroups.com> Message-ID: skanemupp at yahoo.se wrote: > so my little calculator works perfectly now. just having some trouble > with the layout. > this whole tkinter-thing seems to be more tricky than it should be. > how can i make the 4 column of buttons have the same distance and > size between them as the other 3 columns? > and how can i make the top entry end where the 2nd row entry > ends(meaning the top entry will be longer)? > > why are the 4th row split from the others? hard to fix the problems > when u dont even understand why things happen. seems so llogical a lot > of it. i change something then something unexpected happens. The best answer I can give (being a Tk expert but not yet a tkinter expert) is to start with a piece of graph paper. Draw the GUI out and you'll probably see what the problems are. For one, the second entry (for the answer) spans 4 columns and begins at column 3, so it ends up in column 6. This ends up affecting the whole layout because nothing else goes to column six. You'll probably find it much easier going to break down your GUI into sections. One for the calculator buttons and one for everything else. Create a frame for the buttons and it becomes trivial to layout out all the buttons in a 4x6 grid, unaffected by things outside that grid. Then, create your other widgets and grid the whole frame of buttons as a single unit inside the outermost frame. I quite often use grid for interior groupings, then use pack on the outter-most frame to manager the various groups. Using the grid layout manager is trivial if you do a little thinking and planning up front. If you don't, you can spend all day chasing down why you end up with an extra blank row or column, unusually sized rows and columns, etc. Again, get a piece of graph paper and draw it out -- that helps immensely when you're first coming up to speed using grid. From s0suk3 at gmail.com Wed Apr 16 16:53:16 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Wed, 16 Apr 2008 13:53:16 -0700 (PDT) Subject: Profiling, recursive func slower than imperative, normal? References: Message-ID: On Apr 16, 3:27 pm, Jean-Paul Calderone wrote: > Any function can be implemented without recursion, although it isn't > always easy or fun. > > Jean-Paul Really? I'm curious about that, I can't figure out how that would work. Could give an example? Say, for example, the typical: walking through the file system hierarchy (without using os.walk(), which uses recursion anyway!). From grflanagan at gmail.com Fri Apr 11 08:14:13 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Fri, 11 Apr 2008 05:14:13 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> Message-ID: On Apr 11, 2:05 pm, Gerard Flanagan wrote: > On Apr 11, 12:14 pm, bdsatish wrote: > > > The built-in function round( ) will always "round up", that is 1.5 is > > rounded to 2.0 and 2.5 is rounded to 3.0. > > > If I want to round to the nearest even, that is > > > my_round(1.5) = 2 # As expected > > my_round(2.5) = 2 # Not 3, which is an odd num > > > I'm interested in rounding numbers of the form "x.5" depending upon > > whether x is odd or even. Any idea about how to implement it ? > > ------------------------------------------------ > def myround(x): > n = int(x) > if abs(x - n) == 0.5: > if n % 2: > #it's odd > return n + 1 - 2 * int(n<0) > else: > return n > else: > return round(x) > > ------------------------------------------------ In fact you can avoid the call to the builtin round: ------------------------------------------------ def myround(x): n = int(x) if abs(x - n) >= 0.5 and n % 2: return n + 1 - 2 * int(n<0) else: return n assert myround(3.2) == 3 assert myround(3.6) == 4 assert myround(3.5) == 4 assert myround(2.5) == 2 assert myround(-0.5) == 0.0 assert myround(-1.5) == -2.0 assert myround(-1.3) == -1.0 assert myround(-1.8) == -2 assert myround(-2.5) == -2.0 ------------------------------------------------ From schettino72 at gmail.com Mon Apr 21 12:09:53 2008 From: schettino72 at gmail.com (Eduardo Schettino) Date: Mon, 21 Apr 2008 21:39:53 +0530 Subject: Python "make" like tools (was Re: [ANN] DoIt 0.1.0 Released (build tool)) In-Reply-To: References: Message-ID: I guess I should post a link to the project in this thread... http://python-doit.sourceforge.net/ From donn at u.washington.edu Tue Apr 15 13:09:15 2008 From: donn at u.washington.edu (Donn Cave) Date: Tue, 15 Apr 2008 10:09:15 -0700 Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> Message-ID: In article <11567a1a-b184-42e6-bbf3-a655736c19c7 at p25g2000hsf.googlegroups.com>, Sverker Nilsson wrote: > No one forces me, but sooner or later they will want a Python 3.0 and > then a 3.1 whatever. > > I don't want that fuzz. As about the C versions, I am not that > worried. What's your point? > > I just like want to write a program that will stay working. And maybe > I can go on with something else hopefully than just compatibility > fixes. They take some work afterall. > > It seems hard with Python. Esp. 2 -> 3 Welcome to the world of Python. There was a period of relative stability in the '90s, culminating with version 1.5.2, which just happens to be about the time that people started taking Python seriously. It turns out that this stability was only due to lack of resources, though. I think most of us are working under two imperatives here that really boil down to the same thing: we want a programming language that lets us focus on the goal of the program. On one hand, that means things like automatic memory management that are brought to us by newer languages (i.e., less than 30 years old.) On the other hand it means stability that allows our deployed code to go on working without constant intervention, which usually we find in languages that have become utterly boring and out of fashion (i.e., more than 30 years old.) It's hard to find a good compromise between these two, in an interpreted language. I don't know what the current party line may be on this matter, but some years back it was that you should consider the interpreter part of your application. That is, each application should deploy with its own dedicated Python interpreter, complete with libraries and everything. This naturally relieves some of the maintenance issues, since at least you can upgrade on your own schedule, but of course it has its costs too. Anyone who might be thinking about using Python for an application should seriously think about this. Donn Cave, donn at u.washington.edu From ch612bunn at gmail.com Sun Apr 27 09:15:26 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:15:26 -0700 (PDT) Subject: norton antivirus 2008 crack Message-ID: <5b8c377e-02f2-4545-849f-a509fbda331b@a22g2000hsc.googlegroups.com> norton antivirus 2008 crack http://wga-cracks.crackkey.net From arnodel at googlemail.com Thu Apr 24 16:47:01 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 24 Apr 2008 21:47:01 +0100 Subject: Class Inheritance - What am I doing wrong? References: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> Message-ID: Arnaud Delobelle writes: > That is, if you also pass the name parameter to super(A,self).__init__ > in B's __init__ method Oops. should be super(B, self).__init__(name), of course. -- Arnaud From kothari.alok at gmail.com Tue Apr 1 15:42:50 2008 From: kothari.alok at gmail.com (Alok Kothari) Date: Tue, 1 Apr 2008 12:42:50 -0700 (PDT) Subject: XML Parsing Message-ID: Hello, I am new to XML parsing.Could you kindly tell me whats the problem with the following code: import xml.dom.minidom import xml.parsers.expat document = """LettermanisbetterthanJayLeno""" # 3 handler functions def start_element(name, attrs): print 'Start element:', name, attrs def end_element(name): print 'End element:', name def char_data(data): print 'Character data:', repr(data) p = xml.parsers.expat.ParserCreate() p.StartElementHandler = start_element p.EndElementHandler = end_element p.CharacterDataHandler = char_data p.Parse(document, 1) OUTPUT: Start element: token {u'pos': u'nn'} Character data: u'Letterman' End element: token Traceback (most recent call last): File "C:/Python25/Programs/eg.py", line 20, in p.Parse(document, 1) ExpatError: junk after document element: line 1, column 33 From gagsl-py2 at yahoo.com.ar Fri Apr 25 01:10:01 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Fri, 25 Apr 2008 02:10:01 -0300 Subject: Class Inheritance - What am I doing wrong? References: <95820ed0-f3ea-42b6-920f-6819780f3b71@b5g2000pri.googlegroups.com> <613bc152-a6f4-4db4-8f90-593cb3f629c7@s33g2000pri.googlegroups.com> Message-ID: En Thu, 24 Apr 2008 18:18:01 -0300, Brian Munroe escribi?: > Ok, so thanks everyone for the helpful hints. That *was* a typo on my > part (should've been super(B...) not super(A..), but I digress) > > I'm building a public API. Along with the API I have a few custom > types that I'm expecting API users to extend, if they need too. If I > don't use name mangling, isn't that considered bad practice (read not > defensive programming) to not protect those 'private' fields? Please read this article: You don't have to define any getXXX/setXXX methods, just use a public attribute (if it is supposed to be public, of course). In case you have to do something special with it (like notifying some observers when the value changes, by example) use a property instead, and use a *single* leading underscore in the protected attribute name. In any case, the client code remains the same: some_object.attribute_name = value In Python, a single leading underscore means "this is an implementation detail, don't mess with it". This is a convention and we all -adult and responsible programmers- follow that convention. Double leading underscores are a means to avoid name conflicts with subclasses - don't use them unless you have a valid reason. Double leading and trailing underscores are __special__ names reserved by Python itself. -- Gabriel Genellina From martin at marcher.name Wed Apr 2 07:18:55 2008 From: martin at marcher.name (Martin Marcher) Date: Wed, 2 Apr 2008 13:18:55 +0200 Subject: plpythonu+postgrs anybody using it? Message-ID: <5fa6c12e0804020418y4152a084n601413b4fa0b4d5a@mail.gmail.com> Hello, I just started on working with a postgres project, the DB looks really bad and isn't normalized in any way... 4k Text messages representing a whole protocol which need to be transformed. Somehow it just doesn't seem right to put this stuff directly in the database and creating a bunch of stored procedures (SP) to parse them but I'm not the one to decide it... My main concern is that when things start getting more complicated that everytime a SP is called an instance of the interpreter ist started which would be a huge slowdown, so does plpythonu run continiously a python process or does it start one everytime a SP is called? -- http://tumblr.marcher.name https://twitter.com/MartinMarcher http://www.xing.com/profile/Martin_Marcher http://www.linkedin.com/in/martinmarcher You are not free to read this message, by doing so, you have violated my licence and are required to urinate publicly. Thank you. From fhaxbox66 at googlemail.com Wed Apr 2 14:21:38 2008 From: fhaxbox66 at googlemail.com (Dr. leo) Date: Wed, 2 Apr 2008 20:21:38 +0200 Subject: Hyphenation: PyHyphen-0.7 released Message-ID: <47f3cd11$0$582$6e1ede2f@read.cnntp.org> Hi, I have just uploaded the latest sources of PyHyphen (http://cheeseshop.python.org/pypi/PyHyphen). The tarball also contains Windows binaries of the C extension for Python 2.4 and 2.5. So most Windows users will get going without compiling. Just enter the usual 'python setup.py install'. There are many bug fixes both in the Python modules on top as well as in the C extension that uses a new release of the underlying hyphenation library (hyphen-2.3.1). Further, I have added a module 'dictools' for easy download and installation of dictionaries (see below). Finally, a script for easy testing of the hyphenation functionality with large wordlists and multiple dictionaries has been added. Dictionaries are installed on the fly and everything is logged. The default dir for dictionaries and the default repository to download dictionaries are configurable, so that one can use existing dictionaries, e.g., from an OpenOffice installation. The package also includes and installs the module 'textwrap2' which adds a hyphenation feature to the standard module textwrap. Code example: from hyphen import hyphenator from hyphen.dictools import * # Download and install some dictionaries in the default directory using the default # repository, usually the OpenOffice website for lang in ['de_DE', 'fr_FR', 'en_UK', 'hu_HU']: if not is_installed(lang): install(lang) # Create some hyphenators h_de = hyphenator('de_DE') h_en = hyphenator('en_US') h_hu = hyphenator('hu_HU') # Now hyphenate some words print h_hu.inserted(u'asszonnyal') 'asz=szony=nyal' print h_en.pairs('beautiful') [[u'beau', u'tiful'], [u'beauti', u'ful']] print h_en.wrap('beautiful', 6) [u'beau-', u'tiful'] print h_en.wrap('beautiful', 7) [u'beauti-', u'ful'] from textwrap2 import fill print fill('very long text...', width = 40, use_hyphens = h_en) My thanks go to those who helped enormously with advice, suggestions, criticism and Windows builds. Regards Leo From martin at marcher.name Tue Apr 8 16:32:22 2008 From: martin at marcher.name (Martin Marcher) Date: Tue, 8 Apr 2008 22:32:22 +0200 Subject: Best way to check if string is an integer? In-Reply-To: References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> <0fdd2825-6d1c-4380-a79a-a7aac119f002@a5g2000prg.googlegroups.com> <96d2fe53-96bf-43d8-a58d-8269846bf0df@b64g2000hsa.googlegroups.com> <2033313.fb3g3XYCIP@montana.com> Message-ID: <5fa6c12e0804081332r2a58d39gc44ce1ef8cb69052@mail.gmail.com> hmmm int() does miss some stuff: >>> 1E+1 10.0 >>> int("1E+1") Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: '1E+1' I wonder how you parse this? I honestly thought until right now int() would understand that and wanted to show that case as ease of use, I was wrong, so how do you actually cast this type of input to an integer? thanks martin -- http://tumblr.marcher.name https://twitter.com/MartinMarcher http://www.xing.com/profile/Martin_Marcher http://www.linkedin.com/in/martinmarcher You are not free to read this message, by doing so, you have violated my licence and are required to urinate publicly. Thank you. From Lie.1296 at gmail.com Sun Apr 27 06:52:12 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 27 Apr 2008 03:52:12 -0700 (PDT) Subject: DO YOU KNOW ANY THING ABOUT ISLAM??? References: <2429a87a-34e8-4294-9a25-b54dd2cf6791@m73g2000hsh.googlegroups.com> Message-ID: On Apr 24, 1:40 pm, ABDULLAH wrote: > What you are about to read might sound unusual but it could be very > enlightened. So I would be thankful if you give my article 5 minute > of > your value time. THANK YOU No, it is not unusual at all, it's very normal. The only thing that's unusual is that you misposted this in a programming language mailing list instead of religion list. From medin0065 at gmail.com Sun Apr 20 10:46:53 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:46:53 -0700 (PDT) Subject: divx keygen Message-ID: <99d2b9ee-a877-48d9-8fdc-3e043481887e@u36g2000prf.googlegroups.com> divx keygen http://cracks.00bp.com F R E E C R A C K S From gherron at islandtraining.com Thu Apr 17 11:30:29 2008 From: gherron at islandtraining.com (Gary Herron) Date: Thu, 17 Apr 2008 08:30:29 -0700 Subject: Can't do a multiline assignment! In-Reply-To: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> Message-ID: <48076D15.5050906@islandtraining.com> s0suk3 at gmail.com wrote: > I was shocked a while ago when a discovered that in Python you can't > do a multiline assignment > with comments between the lines. > > For example, let's say I want to assign a bunch of variables to an > initial, single value. In C or a similar language you would do: > > CONSTANT1 = > /* This is some constant */ > CONSTANT2 = > CONSTANT3 = > > /*This is yet some other constant */ > CONSTANT = > > 1; > Yuck! No way!! If you *want* to make your code that hard to read, I'm sure you can find lots of ways to do so, even in Python, but don't expect Python to change to help you toward such a dubious goal. Seriously, examine your motivations for wanting such a syntax. Does it make the code more readable? (Absolutely not.) Does it make it more maintainable. (Certainly not -- consider it you needed to change CONSTANT2 to a different value some time in the future.) Gary Herron > In Python, you usually can use parentheses to split something over > several lines. But you can't use parentheses for an assignment of > several lines. For that, you can use the line continuation character > ('\'): > > CONSTANT1 = \ > CONSTANT2 = \ > CONSTANT3 = \ > 1 > > But I realized that you can't do this: > > CONSTANT1 = \ > # Oops... syntax error > CONSTANT2 = \ > CONSTANT3 = \ # This is also a syntax error > # And this too \ > 1 > > Does anyone know of a way to put the comments between lines like that? > I find this limitation very annoying. > From hexusnexus at gmail.com Thu Apr 3 17:00:54 2008 From: hexusnexus at gmail.com (hexusnexus at gmail.com) Date: Thu, 3 Apr 2008 14:00:54 -0700 (PDT) Subject: Classes in modules References: <0cace2e1-6dbc-428f-9e53-ffb99ba42aab@e6g2000prf.googlegroups.com> Message-ID: Yeah, I was a little embarrassed putting my code up to be examined. Thanks for the reply. I typed up some classes, but I seemed to have run into some more problems. One of the classes keeps getting an error that it can't pop from an empty list. Here's the code so far: ################begin main.py#######look for more comments #!/usr/bin/python import random #structure for holding card data class Cards(object): RANK = ["ace","2","3","4","5","6","7","8","9","10","jack","queen","king"] SUIT = ["spades","clubs","hearts","diamonds"] def __init__(self,rank,suit): self.rank = rank self.suit = suit self.name = "%s of %s" % (Cards.RANK[self.rank], Cards.SUIT[self.suit]) #deck functions class Deck(object): def __init__(self): self.deck = [] for i in range(52): self.deck.append(Cards(i % 13, i / 13)) def shuffle(self): random.seed() random.shuffle(self.deck) def draw(self): #This is where my (first) problem arises, though there may be more return self.deck.pop() #IndexError: pop from empty list def size(self): return len(self.deck) #Note: if anyone can find more errors in my code thus far, feel free to criticize #it's been a while since I've practised any OOP #hand functions class Hand(object): def __init__(self): self.cards = [] def pull(self, pos=0): return self.cards.pop(pos) def size(self): return len(self.cards) def put(self,crd): self.cards.append(crd) def cards(self): return self.cards def orgcards(self): #organizes cards, 2's to aces, trumps last begin,end=0,0 for i in range(len(self.cards)-1): for j in range(len(self.cards)-1): if self.cards[j] > self.cards[j+1]: temp = self.cards[j+1] self.cards[j+1] = self.cards[j] self.cards[j] = temp for i in range(len(self.cards)): for j in range(len(self.cards)-1): if self.cards[j]%13==0 and self.cards[j]/ 13==self.cards[j+1]/13: temp=self.cards[j+1] self.cards[j+1]=self.cards[j] self.cards[j]=temp for i in range(len(self.cards)-1,-1,-1): if self.cards[i]/13==Stock.trump(): end=i break if end>0: end=0 for i in range(end,-1,-1): if self.cards[i]/13==Stock.trump(): begin=i break m=self.cards-1 for j in range(end,begin,-1): l=0 k=j while True: l=k+1 if l > m: break temp = self.cards[l] self.cards[l]=self.cards[k] self.cards[k]=temp k=l m-=1 if self.cards<13: for i in range(len(self.cards)-1): for j in range(len(self.cards)-1): if self.cards[j] == -1: temp=self.cards[j+1] self.cards[j+1]=self.cards[j] self.cards[j]=temp return self.cards class Stock(Hand): #the stock class, slightly modified from Hand def __init__(self): self.cards = [] self.y = -1 self.cards.extend(Deck.deck) def showtrump(self): if self.y < 0: self.y = self.cards[25] return self.y class Game(object): #the main game class def __init__(self): self.deck = Deck() self.deck.shuffle() self.player = Hand() self.computer = Hand() for i in range(self.deck.size()): self.player.put(self.deck.draw()) self.computer.put(self.deck.draw()) self.stock = Stock() print self.stock.showtrump() mygame = Game() ######################################################### If anyone can take a look at this and tell me where I went wrong, I'd really appreciate it. I'm using Python v2.5. On Apr 2, 8:41 pm, Dennis Lee Bieber wrote: > On Wed, 2 Apr 2008 18:05:38 -0700 (PDT), hexusne... at gmail.com declaimed > the following in comp.lang.python: > > > > I've been trying to make so that I have one class per file for easier > > Unlike Java, which practically mandates the class<=>file format, > Python is perfectly happy with multiple related classes in one file -- > and often /easier/ to read that way as one is not forced to jump around > finding dependent files to understand related classes. > > > > > This has been a recurring problem for me in languages such as C++ and > > Java. I'm used to programming in C. > > Please don't be offended, but looking at the specified file... it > shows... > > Ignoring the language in use, I'd suggest a few studies in software > design, functional decomposition, data structures, and algorithms... to > start... > > I lost count of how many times this > > > if rank==0: > > rankstr = "ace" > > elif rank==10: > > rankstr = "jack" > > elif rank==11: > > rankstr = "queen" > > elif rank==12: > > rankstr = "king" > > else: > > rankstr=str(rank+1) > > appears in the file, but a concept normally emphasized early in a > programming career is that when you have many identical (or near enough > that a minor tweak can serve for all) occurrences of the same code, it > should probably be turned into a function. > > However, this is even better served by usage of data structures... > > _RANKS = [ "ace", "two", "three", "four", "five", > "six", "seven", "eight", "nine", > "ten", "jack", "queen", "king" ] > > as a module-wide "constant", and then replace all those if/elif... > blocks with a simple: > > rankstr = _RANKS[rank] > > Worse though, your code seems to have used the class keyword just > for the "see, I used classes" factor, with no logical concept of object > orientation. Instead you are creating singleton instances that are being > referenced as global data across the classes... > > A simplistic approach for object orientation is to start with a text > description of the problem (in this case, a description of how the game > is played, perhaps). Find the key nouns in that description -- nouns > often (not always) turn into the classes. Find the verbs in the > description -- these are possible methods of the most closely related > noun. Find adjectives -- these may become attributes of the classes. > > Generic Card Game: > The GAME uses one DECK of 52 playing CARDs (standard arrangement: > _ranks_ of Ace, 2, ..., 10, Jack, Queen, King, in the _suits_ of Clubs, > Diamonds, Hearts, Spades). _n_ PLAYERs take turns... The DECK is > /shuffled/, then CARDs are /dealt/ to each PLAYER, each, in turn, > /drawing/ one card from the DECK until they have a HAND of m-CARDs. > > As a start (if you want multiple files)... > > -=-=-=-=-=- carddeck.py > import random > > class Card(object): > _RANKS = [ "ace", "two", "three", "four", "five", > "six", "seven", "eight", "nine", > "ten", "jack", "queen", "king" ] > _SUITS = [ "spades", "clubs", "hearts", "diamonds" ] > > def __init__(self, rank, suit): > self.rank = rank > self.suit = suit > self.name = "%s of %s" % (Card._RANKS[self.rank], > Card._SUITS[self.suit]) > > class Deck(object): > def __init__(self): > # cryptic initialization of 52 cards > # relies on Python 2.4 or earlier behavior > # read the documentation for 2.5 or later to determine changes > self._deck = [Card(i % 13, i / 13) for i in range(52)] > self._discards = [] > def shuffle(self): > self._deck.extend(self._discards) #combine > self._discards = [] > random.shuffle(self._deck) > def draw(self): > return self._deck.pop() #returns one card from deck > def discard(self, crd): > self._discards.append(crd) #puts card into discard pile > > -=-=-=-=-=- player.py > import carddeck #at this point, this may or may not be needed > > class Hand(object): > def __init__(self): > self._cards = [] > def pull(self, pos=0): > return self._cards.pop(pos) > def size(self): > return len(self._cards) > def put(self, crd): > self._cards.append(crd) > def cards(self): > return [ crd.name for crd in self._cards] > > class Player(object): > def __init__(self): > self._hand = Hand() > def pull(self, pos=0): > #I'm pulling a "law of demeter" here; player does not > #directly manipulate cards in the hand > return self._hand.pull(pos) > def size(self): > return self._hand.size() > def put(self, crd): > self._hand.put(crd) > def showHand(self): > for crd in self._hand.cards(): > print crd > > -=-=-=-=- game.py > import carddeck > import player > > class Game(object): > def __init__(self, numPlayers=2): > self._players = [player.Player() for i in range(numPlayers) > self._deck = carddeck.Deck() > self._deck.shuffle() > for i in range(7): #assume each player starts with 7 cards > for p in self._players: > p.put(self._deck.draw()) > > # rest left as an exercise for the student... > > -- > Wulfraed Dennis Lee Bieber KD6MOG > wlfr... at ix.netcom.com wulfr... at bestiaria.com > HTTP://wlfraed.home.netcom.com/ > (Bestiaria Support Staff: web-a... at bestiaria.com) > HTTP://www.bestiaria.com/ From rodperson at comcast.net Wed Apr 9 19:49:00 2008 From: rodperson at comcast.net (Rod Person) Date: Wed, 9 Apr 2008 19:49:00 -0400 Subject: Creating and Audio Equalizer with python and gstreamer Message-ID: <20080409194900.42a4c8b0@atomizer.opensourcebeef.net> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 For about 3 weeks I have been search for examples for grabbing and frequency from an audio stream and manipulating it. So far I haven't been too successful. Just wondering if anyone has done this or has a good example of doing such. TIA Rod -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (FreeBSD) iEYEARECAAYFAkf9VewACgkQWtF04X/kP32peQCfX/1LgmmREFB88bdY9uzVGxb4 n+sAoJngeg2VpGpwWmJ7cJLrNmsVI9uV =rCNp -----END PGP SIGNATURE----- From chumly96 at hotmail.com Wed Apr 23 09:59:32 2008 From: chumly96 at hotmail.com (chumly96 at hotmail.com) Date: Wed, 23 Apr 2008 13:59:32 GMT Subject: example python telnet/shell server Message-ID: <8hHPj.1560$PM5.274@edtnps92> Hi All, I have a program with a Dbus interface, and would like to allow remote users to use telnet ( or something ) to log in, and run predefined commands against the Dbus interface, return the results, and allow the user to log off. Any examples / help would be great. Thanks Chumly From steve at holdenweb.com Thu Apr 10 18:22:52 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 10 Apr 2008 18:22:52 -0400 Subject: Module Conflicts In-Reply-To: References: <1592fad3-996b-4f62-ac12-42aff8272c21@8g2000hsu.googlegroups.com> <845e315c-0159-4390-954a-dc93fd1b27a1@x41g2000hsb.googlegroups.com> Message-ID: Terry Reedy wrote: > "Jose" wrote in message > news:b7ed8b5e-91fa-4495-b4e3-4912be9e8d90 at s50g2000hsb.googlegroups.com... > | On Apr 9, 10:36 pm, Benjamin wrote: > | > On Apr 9, 5:33 pm, Jose wrote: > | > > | > > I have a module named math.py in a package with some class > | > > definitions. I am trying to import the standard python math module > | > > inside of math.py but It seems to be importing itself. Is there any > | > > way around this problem without renaming my math.py file? > | > > | > Not without some unpythonic magic. It's really not good style to name > | > a module the same as a stdlib one. It'll also confuse people reading > | > your code. > | > | Yeah but I thought since math.py was in a package, it would be okay. > > The stdlib contains a few packages, but it is not a package in itself. > So math is not in a package. > > > Indeed, the fact that there is a math.py indicates that it is a module: a package would have been math/__init__.py. For extra marks, what does the interpreter do with "import x" when there is both an x.py and an x/__init__.py in the same directry on the path? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From kyosohma at gmail.com Thu Apr 24 13:41:05 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Thu, 24 Apr 2008 10:41:05 -0700 (PDT) Subject: Loading associated files References: <74862697-da58-4eb7-8d60-09aaef54b7ad@j22g2000hsf.googlegroups.com> Message-ID: <07ac86a6-e125-40d9-bfe9-7c3286437bef@z72g2000hsb.googlegroups.com> On Apr 24, 10:14?am, flarefi... at googlemail.com wrote: > I am trying to make a a simple databasing GUI interface and and have > created a module to deal with parsing the data from a file and a GUI > based program that displays this data using PyQt4, i know how to > register files in the system registry using python and also using Inno > Setup which i use to package my applications, but i cant work out how > if a file is doubled clicked on to send the path of that file to > python. > > I have looked into passing command line arguments to python and can > send a specific pathname to python but ideally what i need is a > generic command that i can write to the registry that passes the > pathname of whichever file was doubled clicked!?! > > am i asking too much/does it exist/is there an easier way to do this!! > > CC I did this by writing the path to me script or exe and added %1 to the end, which basically means that my program can (or requires) a parameter passed to it. Here's an example: "C:\Program Files\PyMail\wxsendmail.exe" %1 That should work. Tested on Windows XP SP2 with Python 2.4/2.5. Mike From ch612bunn at gmail.com Sun Apr 27 09:12:47 2008 From: ch612bunn at gmail.com (ch612bunn at gmail.com) Date: Sun, 27 Apr 2008 06:12:47 -0700 (PDT) Subject: Kaspersky Anti-Virus 7.0.0.125 crack Message-ID: Kaspersky Anti-Virus 7.0.0.125 crack http://wga-cracks.crackkey.net From jens at aggergren.dk Tue Apr 29 09:16:57 2008 From: jens at aggergren.dk (Jens) Date: Tue, 29 Apr 2008 06:16:57 -0700 (PDT) Subject: Zope/DTML Infuriating... References: <3a955f90-ed80-46be-a238-1462e4fb2d0c@m3g2000hsc.googlegroups.com> Message-ID: <5493f048-db28-4f72-8265-99fd33c79f93@56g2000hsm.googlegroups.com> On Apr 29, 2:45?pm, Marco Mariani wrote: > Jens wrote: > >> You might have wrong assumptions from previous PHP experiences. > > >> ?>>> 'x'+4 > >> Traceback (most recent call last): > >> ? ?File "", line 1, in > >> TypeError: cannot concatenate 'str' and 'int' objects > > > ... and the non snobby answer would have been: > > > ... ? > > Sorry. Not trying to be snobbish, only in a hurry. > > That answer would have been less useful, because there are TONS of > details in the python tutorial, that set the language apart from its > "scripting cousins". > Reading the syntax and thinking "yeah, got it, boring, next chapter" is > a common mistake I've also made sometime, especially with python when > I've been deceived by its apparent simplicity. > Then, later, the same happened with Javascript, of course. > And it's bound to happen again, as much as I'll try to be careful :-( Hey no worriest. Is this the tutorial you're referring to: http://docs.python.org/lib/typesmapping.html Is there anything better? I miss the discussion and examples that accompany most entries in php.net. From steve at holdenweb.com Mon Apr 21 08:18:52 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 21 Apr 2008 08:18:52 -0400 Subject: PIL font encoding In-Reply-To: <480C5E36.7090505@shopzeus.com> References: <480C5E36.7090505@shopzeus.com> Message-ID: Laszlo Nagy wrote: > def getfnt(size): > return ImageFont.truetype("cartoon.ttf",size,encoding='unic') > > Using the above function, I cannot draw special german characters. E.g. > > u'L\xfctgendorf' > > > It will print "Lutgendorf" instead of "L?tgendorf". Much more > interesting is that I can also do this: > > def getfnt(size): > return > ImageFont.truetype("cartoon.ttf",size,encoding='put_somethin_here_it_has_no_effect > WHAT?????? ') > > Same results. Shouldn't the truetype constructor raise an exception if > the encoding is invalid and/or not available with the selected font? > > BTW my "cartoon.ttf" font is able to print "L?tgendorf". I have tested > it from GIMP. So I'm 100% sure that the problem is with PIL. > > Thank you, > > Laszlo > > You will be more likely to find assistance for this specific issue via the image-SIG mailing list, see http://mail.python.org/mailman/listinfo/image-sig regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From nagle at animats.com Wed Apr 9 11:53:00 2008 From: nagle at animats.com (John Nagle) Date: Wed, 09 Apr 2008 08:53:00 -0700 Subject: I am worried about Python 3 In-Reply-To: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> Message-ID: <47fce3ca$0$36346$742ec2ed@news.sonic.net> jmDesktop wrote: > If I continue in Python 2.5.x, am I making a mistake? Is it really > that different? No. It may never happen, either. The Perl crowd tried something like this, Perl 6, which was announced in 2000 and still hasn't come out. The C++ standards committee has been working on a revision of C++ since the 1990s, and that hasn't happened either. The general consensus is that Python 3.x isn't much of an improvement over the existing language. There's just not much demand for it. John Nagle From jcd at unc.edu Tue Apr 15 11:55:07 2008 From: jcd at unc.edu (J. Cliff Dyer) Date: Tue, 15 Apr 2008 11:55:07 -0400 Subject: String Literal to Blob In-Reply-To: <4dc0cfea0804150804l2d3832f0sd8f1d9405934063@mail.gmail.com> References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> <4dc0cfea0804140629rf1ac100m27ad9d0456cbbe2d@mail.gmail.com> <4803644A.8010204@holdenweb.com> <4dc0cfea0804150804l2d3832f0sd8f1d9405934063@mail.gmail.com> Message-ID: <1208274907.4718.2.camel@aalcdl07.lib.unc.edu> It is published. On comp.lang.python. Google groups has it, so google (search) will find it. Cheers, Cliff On Tue, 2008-04-15 at 17:04 +0200, Victor Subervi wrote: > Gabriel; > > That's really nice code you wrote. I will rewrite my app accordingly, > after I catch a breather! Say, would you please publish this > somewhere? Why should I write a howto on this and credit you when all > I would be doing is republishing (plagerizing) what you published? > Please insert these keywords: mysql, image, python, mysqldb and maybe > picture and photo (you already have photo). Call it something like > "MySQL/Python Tutorial for Posting and Retrieving Images / Photo > Album". I ask you to do this because I scoured google looking for just > what you've provided and it simply isn't out there. At all. There are > nice howto's in php. Please post this for those interested in python, > somewhere like the cookbook. > > Thanks, > > Victor > > > > On Tue, Apr 15, 2008 at 3:23 AM, Gabriel Genellina > wrote: > En Mon, 14 Apr 2008 11:03:54 -0300, Steve Holden > > escribi?: > > Victor Subervi wrote: > >> Thanks to all, especially Gabriel. [...] > >> Steve, thank you for all your help, but do overcome your > temper :)) > > > > > I'm glad the penny finally dropped. You may have been > treated to a > > modest display of exasperation, but please be assured you > have not yet > > seen anything remotely like temper from me :-) > > > And I'm glad to see that you finally "got it", too! > > -- > Gabriel Genellina > > -- > > http://mail.python.org/mailman/listinfo/python-list > > -- Oook, J. Cliff Dyer Carolina Digital Library and Archives UNC Chapel Hill From uniontelecardsindia at gmail.com Tue Apr 22 17:20:33 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:20:33 -0700 (PDT) Subject: Tattooed big hunks wrapped up in double penetrating gay cum finish. Message-ID: Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From wbsoft at xs4all.nl Sat Apr 12 17:22:42 2008 From: wbsoft at xs4all.nl (Wilbert Berendsen) Date: Sat, 12 Apr 2008 23:22:42 +0200 Subject: pty.spawn directs stderr to stdout In-Reply-To: <200804122142.00091.wbsoft@xs4all.nl> References: <200804122142.00091.wbsoft@xs4all.nl> Message-ID: <200804122322.42241.wbsoft@xs4all.nl> Op zaterdag 12 april 2008, schreef Wilbert Berendsen: > I'm currently trying to combine subprocess.Popen with pty.openpty ... which succeeded :-) http://code.google.com/p/lilykde/source/browse/trunk/runpty.py?r=314 it seems to work :-) thanks, Wilbert Berendsen -- http://www.wilbertberendsen.nl/ "You must be the change you wish to see in the world." -- Mahatma Gandhi From sjmachin at lexicon.net Thu Apr 3 18:43:32 2008 From: sjmachin at lexicon.net (John Machin) Date: Thu, 3 Apr 2008 15:43:32 -0700 (PDT) Subject: python bisect questions References: <6bb6927b-f553-40db-a142-2ce86b9e819f@q27g2000prf.googlegroups.com> Message-ID: <7d64aa50-9d67-45fe-9d57-ec32904ecb87@u36g2000prf.googlegroups.com> On Apr 4, 9:21 am, ankitks.mi... at gmail.com wrote: > On Apr 3, 4:24 pm, "Terry Reedy" wrote: > > > > > > > > > wrote in message > > >news:6bb6927b-f553-40db-a142-2ce86b9e819f at q27g2000prf.googlegroups.com... > > |I am week on functional programming, and having hard time > > | understanding this: > > | > > | class myPriorityQueue: > > | def __init__(self, f=lamda x:x): > > | self.A = [] > > | self.f = f > > | > > | def append(self, item) > > | bisect.insort(self.A, (self.f(item), item)) > > | ............ > > | > > | now I know we are inserting items(user defined type objects) in list A > > | base on sorting order provided by function A. > > | but what I don't understand is bisect command > > | what does bisect.insort(self.A, (self.f(item), item)) doing > > here is doc > insort_right(a, x[, lo[, hi]]) > > Insert item x in list a, and keep it sorted assuming a is sorted. > > If x is already in a, insert it to the right of the rightmost x. > > Optional args lo (default 0) and hi (default len(a)) bound the > slice of a to be searched. > > but I am still confuse. self.A is my list a. and item is x that > I am trying to insert. > So it needs to be of type item not (self.f(item), item) > It doesn't say anything pass sorting function self.f(item). That's correct. You are passing a tuple of (sort_key, actual_data). Example use case: caseless sortorder but you want to retrieve the original data. f is lambda x: x.upper() or similar. Your data is 'foo', 'Bar', 'zOt'. Calls to your_queue.append will result in the following 2nd args for bisect.insort: ('FOO', 'foo') ('BAR', 'Bar') ('ZOT', 'zOt') Consider executing the code with a couple of print statements in it so that you can see what is happening. From __peter__ at web.de Thu Apr 17 03:27:58 2008 From: __peter__ at web.de (Peter Otten) Date: Thu, 17 Apr 2008 09:27:58 +0200 Subject: regular expressions an text string References: <359c5f43-9520-4f33-b49e-45b5256f7169@a22g2000hsc.googlegroups.com> Message-ID: ragia wrote: > i have to match text string char by char to a regular expressions tht > just allow digits 0-9 if other thing a ppear it shall be replaced with > space.how can i do that any help? >>> import re >>> s = "abc123_45!6$" >>> re.sub(r"\D", " ", s) ' 123 45 6 ' Peter From aldo at nullcube.com Sat Apr 5 04:26:05 2008 From: aldo at nullcube.com (Aldo Cortesi) Date: Sat, 5 Apr 2008 19:26:05 +1100 Subject: ANN: pry unit testing framework In-Reply-To: <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> References: <87zlscx5lt.fsf@benfinney.id.au> <4f4e6da0-8848-4678-8612-e16c47500ab2@8g2000hse.googlegroups.com> Message-ID: <20080405082605.GA14042@nullcube.com> Thus spake Kay Schluehr (kay.schluehr at gmx.net): > But you could have added the integration of code coverage and other > helpful features with unittest as a conservative extension giving > everyone a chance to use it directly with existing tests instead of > forcing them to rewrite their tests for bike shading purposes. You're assuming that Pry's only purpose is to introduce test coverage. This is not the case - I already had a module that largely maintained unittest compatibility, but added a command-line interface and coverage analysis. It's now obsolete, but you can find its remains here if you're interested: http://dev.nullcube.com/gitweb/?p=pylid;a=shortlog So, why did I re-write it? Well, I needed a test framework that didn't have the deep flaws that unittest has. I needed good hierarchical fixture management. I needed something that didn't instantiate test suites automatically, freeing me to use inheritance more naturally within my test suites. I needed more sophisticated handling and reporting of errors during startup and teardown. I needed better support for programmatic generation of tests. The list goes on. Pry has all of this, and much of it is simply not possible while maintaining backwards compatibility. Yes, test coverage is critical and hugely neglected by most people, but Pry addresses other problems as well. We're not "forcing" anyone to rewrite anything, but if the description above sounds like something you want, maybe you should give Pry another look. If Pry itself is not to your taste, there are other excellent test frameworks like py.test that have also chosen not to mindlessly duplicate all of unittest's inadequacies. Broaden your horizons and explore some of these - your code will thank you for it... Regards, Aldo -- Aldo Cortesi M: +61 419 492 863 P: +61 1300 887 007 W: www.nullcube.com From rgacote at AppropriateSolutions.com Sat Apr 19 10:03:33 2008 From: rgacote at AppropriateSolutions.com (Ray Cote) Date: Sat, 19 Apr 2008 10:03:33 -0400 Subject: Python 2.5 adoption In-Reply-To: <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> References: <4808f30e$0$34489$742ec2ed@news.sonic.net> <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> Message-ID: At 12:16 PM -0700 4/18/08, Joseph Turian wrote: >Basically, we're planning on releasing it as open-source, and don't >want to alienate a large percentage of potential users. >-- >http://mail.python.org/mailman/listinfo/python-list A few seconds after reading this, I read the announcement for pyspread. Requirements? Python 2.5. You might want to talk with the pyspread folks regarding their decision to require 2.5. http://pyspread.sourceforge.net --Ray -- Raymond Cote Appropriate Solutions, Inc. PO Box 458 ~ Peterborough, NH 03458-0458 Phone: 603.924.6079 ~ Fax: 603.924.8668 rgacote(at)AppropriateSolutions.com www.AppropriateSolutions.com From gagsl-py2 at yahoo.com.ar Thu Apr 10 02:16:42 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 03:16:42 -0300 Subject: problem using import from PyRun_String References: <664bf2b80804081801u79ae9192h90c03c84c1ef35ce@mail.gmail.com> <664bf2b80804090931y78d9e34dof268784cc6a6cde9@mail.gmail.com> Message-ID: En Wed, 09 Apr 2008 13:31:22 -0300, Patrick Stinson escribi?: > Well, I eventually want to add an import hook, but for now I'd rather > just > get the import statement working normally again. > I have embedded python as a scripting engine in my application. To do > this, > I create a new empty module, run the script text using PyRun_String() > passing the module's __dict__ as locals and globals. This populates the > module's __dict__ with the resulting object references from the script > text. Instead of PyRun_String, use PyImport_ExecCodeModuleEx, which takes care of setting __builtins__ and other details. You will need to compile the source first (using Py_CompileStringFlags) which is a good thing anyway, to help catching errors. > As I said before I must be forgetting some other module init stuff > because I > had to manually populate the modules' __dict__ with references from the > __builtin__ module in order to get the basic stuff like abs, range, etc. That's not exactly what CPython does; if you inspect globals() you don't see abs, range, etc. Instead, there is a __builtins__ attribute (note the "s") that points to the __builtin__ module or its __dict__. > I understand what __builtin__ is used for, but the C struct pointing to > the > code frame that contains the import statement has a builtin member that > apparently does not contain the __import__ function, hence my question. > There must be some difference in the way code is parsed and a copy of the > __builtin__ module is passed normally and the way I am doing it. When a frame builtins != internal builtins, Python runs in "restricted execution mode", and disallows access to some objects and attributes, I think that __import__ is one of them. See http://docs.python.org/lib/module-rexec.html (That's why it's important to use the right way to create a module) > So, finding the place where this module bootstrapping normally happens > would > be awesome, because I sort of feel like I'm hacking this method running > into > problems like this. Exactly. The simplest way would be to save the source code on disk and just import it, letting Python do all the dirty work. But compiling+PyImport_ExecCodeModule should work, I presume - any feedback is welcome! -- Gabriel Genellina From cyril.giraudon at gmail.com Mon Apr 28 13:35:40 2008 From: cyril.giraudon at gmail.com (cyril giraudon) Date: Mon, 28 Apr 2008 10:35:40 -0700 (PDT) Subject: descriptor & docstring Message-ID: Hello, I try to use python descriptors to define attributes with default value (the code is reported below). But apparently, it breaks the docstring mechanism. help(Basis) shows the right help but help(Rectangle) shows only two lines : " Help on class Rectangle in module basis2: Rectangle = " If the Rectangle.length attribute is removed, the help is OK. Secondly, the __doc__ attribute of a PhysicalValue instance doesn't seem to be read. I don't understand. Any idea ? Thanks a lot Cyril. # A descriptor class with default value handling class PhysicalValue(object): """ A physical value descriptor """ def __init__(self, default_value): self.default_value = default_value self.__doc__ = "Hello from Physical Value" def __get__(self, obj, type=None): if obj.__dict__.has_key(self.key): return getattr(obj, self.key) else: return self.default_value def __set__(self, obj, value): if value is DefaultValue: setattr(obj, self.key, self.default_value) else: setattr(obj, self.key, value) # A meta class which adds instance attributes # If hasattr(cls, "attr") then add "_attr" attribute. class MyMetaClass(type): def __init__(cls, name, bases, dct): super(MyMetaClass, cls).__init__(name, bases, dct) print "Add property to ", name def init(self): pvl = [item for item in cls.__dict__.items() if isinstance(item[1], PhysicalValue)] for pv in pvl: print "Add _%s property to %s" % (pv[0], name) cls.__dict__[pv[0]].key = "_" + pv[0] setattr(self, "_" + pv[0], getattr(self, pv[0])) cls.__init__ = init # A basis class class Basis(object): """ Tempest basis class """ __metaclass__ = MyMetaClass # A concrete class class Rectangle(Basis): """ A beautiful Rectangle """ length = PhysicalValue(12.) From jason.scheirer at gmail.com Sat Apr 12 21:14:31 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Sat, 12 Apr 2008 18:14:31 -0700 (PDT) Subject: String Literal to Blob References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> <4dc0cfea0804110636i45787fd2oe9b36087d386b55d@mail.gmail.com> <4dc0cfea0804111046l2e7ebb7an3b82fcdd7928fefe@mail.gmail.com> <4dc0cfea0804121211r3b51597eg4be3290b7d8f7a1f@mail.gmail.com> Message-ID: <28083d1e-3672-45aa-80d1-7bdecf35e2b7@c19g2000prf.googlegroups.com> On Apr 12, 2:44 pm, Steve Holden wrote: > Victor Subervi wrote: > > in line... > > > On Fri, Apr 11, 2008 at 2:05 PM, Steve Holden > > wrote: > > > Victor Subervi wrote: > > > I have worked on this many hours a day for two weeks. If there is an > > > easier way to do it, just take a minute or two and point it out. Have > > > you heard of the Law of Diminishing Returns? I have passed it > > long ago. > > > I no longer want to waste time trying to guess at what you are > > trying to > > > tell me. > > > Victor > > > > On Fri, Apr 11, 2008 at 8:55 AM, Steve Holden > > > > > >> wrote: > > Where you have > > > content = col_fields[0][14].tostring() > > pic = "tmp" + str(i) + ".jpg" > > img = open(pic, "w") > > img.write(content) > > print '

' % pic > > img.close() > > > instead write > > > print content > > > Like this, I presume? > > Yes. You might need to use content.tostring() - I am not familiar with > MySQL blobs. > > > img = open(pic, "w") > > img.write(content) > > print ' > value="%s">' % pic > > print content > > # print '

\n' % pic > > Does not work _at_all LOL. You will recall, also, that you once gave me > > a line similar to the one commented out (but without writing then > > opening the file). THAT did not work, either. So now do you see why I am > > frustrated?? > > > Then browse to the URL this program serves and you will see the image > > (assuming you are still sending the image/jpeg content type). > > > Well, as I mentioned before, I am sending text/html because the page, > > like almost all web pages, has a whole lot more content than just > > images. Or, perhaps you are suggesting I build my pages in frames, and > > have a frame for every image. Unsightly! > > Dear Victor: > > If you cannot understand, after being told several times by different > people, that pages with images in them are achieved by multiple HTTP > requests, then there is little I can do to help you. > > > > > Once you > > can see the image, THEN you can write a page that refers to it. Until > > you start serving the image (NOT pseudo-html with image data embedded in > > it) nothing else will work. > > > My solution works just fine, thank you. It is inelegant. But it now > > appears to me, and I dare say rather clearly, that this inelegance is > > the fault of python itself. Perhaps this should be brought to Guido?s > > attention. > > Victor > > You can say it as clearly as you like, but if you say it too loudly you > will make a laughing stock of yourself. > > You surely don't think that a language that supports Zope, TurboGears, > Pylons and Django (to name but the first four that come to mind) is > unsuitable for web programming? > > Please, do yourself a big favor and persist with this until you > understand what you are doing wrong and how to serve dynamic images. It > appears that the learning may be painful, but I guarantee it will be > worthwhile. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ There _is_ a way to embed image data in HTML that is supported by every major browser. It is ugly. Using the RFC 2397 (http:// www.ietf.org/rfc/rfc2397) spec for data URLs you could go '' % base64.b64encode(image_data) Obviously you need to import the base64 module somewhere in your code and base64-encoded data is about a third larger than it would be otherwise, so embedding anything particularly large is going to be a huge pain and affect page load times pretty badly. From jeffrey at fro.man Tue Apr 8 16:41:06 2008 From: jeffrey at fro.man (Jeffrey Froman) Date: Tue, 08 Apr 2008 13:41:06 -0700 Subject: Coping with cyclic imports References: <87bq4knmax.fsf@physik.rwth-aachen.de> Message-ID: Torsten Bronger wrote: > I know that cyclic imports work in Python under certain > circumstances. ?Can anyone refer me to a page which explains when > this works? I don't know of a specific URL offhand. Cyclic imports are not a problem by themselves, but cyclic definitions are. Thus: # a.py import b x = 1 # b.py import a x = 2 works fine, but: # a.py import b x = 1 # b.py import a x = a.x + 1 # circular definition does not. Jeffrey From hank.infotec at gmail.com Sun Apr 20 14:14:43 2008 From: hank.infotec at gmail.com (Hank @ITGroup) Date: Mon, 21 Apr 2008 04:14:43 +1000 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: <480B80B5.1050500@cheimes.de> References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> <480B80B5.1050500@cheimes.de> Message-ID: <480B8813.6010108@gmail.com> Christian Heimes wrote: > Gabriel Genellina schrieb: > >> Apart from what everyone has already said, consider that FreqDist may import other modules, store global state, create other objects... whatever. >> Pure python code should not have any memory leaks (if there are, it's a bug in the Python interpreter). Not-carefully-written C extensions may introduce memory problems. >> > > Pure Python code can cause memory leaks. No, that's not a bug in the > interpreter but the fault of the developer. For example code that messes > around with stack frames and exception object can cause nasty reference > leaks. > > Christian > > In order to deal with 400 thousands texts consisting of 80 million words, and huge sets of corpora , I have to be care about the memory things. I need to track every word's behavior, so there needs to be as many word-objects as words. I am really suffering from the memory problem, even 4G memory space can not survive... Only 10,000 texts can kill it in 2 minutes. By the way, my program has been optimized to ``del`` the objects after traversing, in order not to store the information in memory all the time. From pDOTpagel at helmholtz-muenchen.de Fri Apr 11 07:40:08 2008 From: pDOTpagel at helmholtz-muenchen.de (Philipp Pagel) Date: Fri, 11 Apr 2008 11:40:08 +0000 (UTC) Subject: Graphs in Python References: Message-ID: Sanhita Mallick wrote: > I have looked at that, and other similar ones all of > which are based on Graphviz. Networkx is not based on graphviz. > My problem is that I myself am creating some large graphs [...] > So I would like to use a graphical/visual method than typing out the > nodes. Not sure what exactly you mean. you will have to enter the nodes somehow - afterwards you can visualize them. Do you mean you would like to have a GUI for entering nodes and edges? I see two options: (1) write a GUI to do that (2) use an existing graph editor and use networkx or something like that for analysis. > Also, I am looking for a good tutorial for basic graph > implementation other than the one on python.org. - Look at the source code for networkx. - Alternatively, basic graph algorithms can be found in many general algorithm books. - More specific stuff e.g. in A. Gibbons "Algorithmic Graph Theory". cu Philipp -- Dr. Philipp Pagel Lehrstuhl f. Genomorientierte Bioinformatik Technische Universit?t M?nchen http://mips.gsf.de/staff/pagel From elgrandchignon at gmail.com Wed Apr 9 19:51:15 2008 From: elgrandchignon at gmail.com (Jason) Date: Wed, 9 Apr 2008 16:51:15 -0700 (PDT) Subject: Sorting a List of Objects by an Attribute of the Objects Case-Insensitively References: <736fefbd-510f-40e9-8342-32b69a1a0c2a@t12g2000prg.googlegroups.com> <0912a817-2cdc-4a19-83d2-1d8befed4f4b@24g2000hsh.googlegroups.com> Message-ID: <39693e9a-e46d-486d-8768-7b68360a5be9@t12g2000prg.googlegroups.com> Thanks so much everyone! That works great, & (presumably) is way faster than the way I was doing it-- From brian.e.munroe at gmail.com Wed Apr 2 15:27:20 2008 From: brian.e.munroe at gmail.com (Brian Munroe) Date: Wed, 2 Apr 2008 12:27:20 -0700 (PDT) Subject: class / module introspection? References: <3c3f09df-08cb-4309-a870-6b12a813a8af@u36g2000prf.googlegroups.com> <0f14a289-55ef-49e5-b650-60f7aca371ad@i36g2000prf.googlegroups.com> Message-ID: On Apr 2, 12:07 pm, Brian Munroe wrote: > > This gives me ['system1','system2'] - which I can then use __import__ > on. > Addendum, thanks Bruno! I also required the helper function (my_import) from the Python docs you pointed me to, that actually was the key to getting everything working! From danb_83 at yahoo.com Sun Apr 13 23:47:00 2008 From: danb_83 at yahoo.com (Dan Bishop) Date: Sun, 13 Apr 2008 20:47:00 -0700 (PDT) Subject: about the ';' References: Message-ID: <946aac57-868d-4355-af97-994c40dff287@b9g2000prh.googlegroups.com> On Apr 13, 10:33 pm, "Penny Y." wrote: > I saw many python programmers add a ';' at the end of each line. > As good style, should or should not we do coding with that? That's just because their fingers are stuck in C mode. The recommended style is NOT to use unnecessary semicolons. From steve at holdenweb.com Sat Apr 12 12:16:02 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 12:16:02 -0400 Subject: sqlite3 - adding tables and rows via parameters In-Reply-To: <9fdb569a0804120839w6916ed96ka5b53aad7ca6f565@mail.gmail.com> References: <9fdb569a0804120839w6916ed96ka5b53aad7ca6f565@mail.gmail.com> Message-ID: Vlastimil Brom wrote: > Hi all, > I would like to ask about the usage of sqlite3 in python, more > specifically about a way to pass table > or column names to a SQL commands using parameters. > All examples I could find use > the parameter substitution with "?" for values; is it possible the specify table and column names this way? > e.g. something like > curs.execute(u'INSERT OR REPLACE INTO %s(%s) VALUES (?)' % ("people", > "email"), ("qwe at asd.zx",)) > (And the similar cases e.g.: CREATE TABLE, ALTER TABLE ... ADD.) > Unfortunately, I wasn't successful in replacing the string interpolation > with the substitution notation; are there maybe any hints, how to do > that? Or is it ok to use string interpolation here? (Are these parts of > the SQL command vulnerable too?) > > What I am trying to achieve is to build a database dynamically - based > on the input data the respective > table would be chosen, and the appropriate columns created and filled with the content. > > Thanks in advance for any suggestions - and sorry if I missed something > obvious... > Vlasta > > The thing that will stop you from using a tablename as an argument to a parameterized query is that (the) front-ends (I am familiar with) don't allow table names to be parameterized ... The main points of parameterization are 1) To let the driver handle the creation of syntactically correct SQL (thereby avoiding , e.g. SQL injection attacks) and 2) To allow the driver to get the back-end to optimize the query by developing an execution plan into which the parameters can ve inserted at run time, avoiding repeated recompilation of the same query. It's this that stops most backends from allowing table names, since the optimizations depend upon the table's characteristics and contents. As far as ? vs %s goes, that depends on the particular module's paramstyle. For sqlite3: >>> import sqlite3 >>> sqlite3.paramstyle 'qmark' >>> so you just have to go with what it implements. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From python at bdurham.com Mon Apr 28 22:10:27 2008 From: python at bdurham.com (python at bdurham.com) Date: Mon, 28 Apr 2008 22:10:27 -0400 Subject: How to unget a line when reading from a file/stream iterator/generator? In-Reply-To: References: Message-ID: <1209435027.21177.1250388813@webmail.messagingengine.com> George, > Is there an elegant way to unget a line when reading from a file/stream iterator/generator? http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502304 That's exactly what I was looking for! For those following this thread, the above recipe creates a generic object that wraps any iterator with an 'unget' ("push") capability. Clean and elegant! Thank you, Malcolm From sjmachin at lexicon.net Thu Apr 17 19:59:20 2008 From: sjmachin at lexicon.net (John Machin) Date: Thu, 17 Apr 2008 23:59:20 GMT Subject: get quote enclosed field in a line In-Reply-To: <4807dc10$0$25223$e4fe514c@dreader18.news.xs4all.nl> References: <4807dc10$0$25223$e4fe514c@dreader18.news.xs4all.nl> Message-ID: <4807e457$1@news.mel.dft.com.au> Martin P. Hellwig wrote: > > Something like: > # cut -d '"' -f 6 < httpd-access.log In Python: line.split('"')[5] From james at reggieband.com Mon Apr 28 15:46:50 2008 From: james at reggieband.com (james at reggieband.com) Date: Mon, 28 Apr 2008 12:46:50 -0700 (PDT) Subject: Installed python 2.5 over 2.4 and lost installed packages References: <6c77d0e5-f387-449d-9147-d7aefa3d2735@l64g2000hse.googlegroups.com> <361ca6be-9764-4cff-bd2e-b5f992d5feb7@8g2000hse.googlegroups.com> Message-ID: On Apr 27, 8:42 pm, Mike Driscoll wrote: > On Apr 27, 8:15 am, ja... at reggieband.com wrote: > > I recently updated os x from python 2.4 to 2.5 (from python.org) and > > in doing so I lost my old python path entries. > > So what is the right thing to do in this situation? > > Is cp'ing the files from one place to another safe or advisable? > As long as the Python extensions or packages are pure ones, then > copying them over shouldn't hurt anything. If you have some that have > C/C++ links (such as PIL or pywin32), then you'll need to reinstall > those manually. I tried that and the C extensions burned me. Syck (for YAML) and mercurial (I think ... there were at least 2 problems) posted warnings or bailed out with errors. Looks like I will delay until I have the time and energy to chase all my dependencies. Perhaps once my server (Ubuntu) moves to 2.6 I'll update my Mac at the same time. >From now on I am storing my install packages somewhere accessible instead of deleting them once I'm done with them. I wish I could generate a manifest of installed packages to make upgrading easier. Cheers, James. From nejtak... Thu Apr 3 14:33:35 2008 From: nejtak... (Troels Thomsen) Date: Thu, 3 Apr 2008 20:33:35 +0200 Subject: Python for low-level Windows programming In-Reply-To: References: Message-ID: <47f52303$0$2092$edfadb0f@dtext02.news.tele.dk> >> >> Is this possible without too much pain? I know I can code it with C# >> or C++ but tha'ts a road to avoid, if possible. > > Well of course I don't know exactly what you'd need, but the > answer's certainly Yes :) Need I mention that it is also easy to write a windows service, using pyservice (i think ...) and ? a page of python source tpt From jens at aggergren.dk Tue Apr 29 07:56:19 2008 From: jens at aggergren.dk (Jens) Date: Tue, 29 Apr 2008 04:56:19 -0700 (PDT) Subject: Zope/DTML Infuriating... Message-ID: Hello Everyone. I am relatively new to Zope(using it for a work project) and I was wondering if someone here could help me out or at least refer me to a decent documentationg for Zope/DTML/Python (at the detail level of php.net or Java API reference). http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/ isn't really detailed enough for my taste. if it doesn't contain a exhautive description of all available base classes it's simply no good as a reference resource. Anyway I have the following problem. I'm using zope 2.9 and I would expect the following dtml code to yield a list containing main1, main2 etc.

But it doesn't work(and yes i know that i could simply do "... ...", but that's not what i need). I've the checked that i'm referring to the variables correctly, so the only explanation i can come up with, is that '+' doesn't result in a string concatenation (with implicit typecast to string of the integer variable(this is a interpreted language after all)). It apparently works in other cases but for some reason not here. I get the following cryptical error message which makes me none the wiser. An error was encountered while publishing this resource. Error Type: AttributeError Error Value: 'NoneType' object has no attribute 'group' I would appreciate any feedback you might have regarding this. Thanks in Advance. From arnodel at googlemail.com Thu Apr 17 13:36:41 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 17 Apr 2008 10:36:41 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <1952579a-3cfb-44ea-92aa-658daa64aee4@a70g2000hsh.googlegroups.com> <564dd82b-8670-4ead-a3c8-a22b30a3eb73@m73g2000hsh.googlegroups.com> Message-ID: <2fbafb11-1a99-4007-949e-8a7acd790bf3@a23g2000hsc.googlegroups.com> On Apr 17, 6:02?pm, s0s... at gmail.com wrote: [...] > I do it with all the separate variables mainly for performance. If I > had the headers in a dict, I'd be looking up a string in a list of > strings (the keys of the dict) everytime I check for a header. Not > that that's going to take more that 0.1 seconds, but the program is > still small and simple. As it gets bigger, more features are gonna > slow things down. - Have you measured the difference in performance? - Are you aware that attribute access is implemented as string lookup in a dictionary? i.e. when you write foo.bar, the interpreter looks for 'bar' in foo.__dict__, and if it doesn't find it, then proceeds to look in type(foo).__dict__. So in your code, if a header (with manager rhm) has no 'allow' field and you do: rhm.Allow the interpreter looks up *two* dictionaries (rhm.__dict__ then RequestHeadersManager.__dict__). -- Arnaud -- Arnaud From n00m at narod.ru Wed Apr 30 03:54:56 2008 From: n00m at narod.ru (n00m) Date: Wed, 30 Apr 2008 00:54:56 -0700 (PDT) Subject: Problem with variables assigned to variables??? References: Message-ID: for listmember in mylist: print listmember + ".shp", eval(listmember) From michael.pearmain at tangozebra.com Thu Apr 3 11:26:17 2008 From: michael.pearmain at tangozebra.com (Mike P) Date: Thu, 3 Apr 2008 08:26:17 -0700 (PDT) Subject: MLE in Python for distributions Message-ID: Hi All, Can anyone point me towards some code for Maximum Likilehood for distribution in python? Thanks Mike From sierra9162 at gmail.com Wed Apr 16 11:26:34 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:26:34 -0700 (PDT) Subject: kate hudson pussy Message-ID: <61646556-8508-4bf7-9d85-785b57cc97bb@x41g2000hsb.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From samslists at gmail.com Sun Apr 6 16:45:16 2008 From: samslists at gmail.com (samslists at gmail.com) Date: Sun, 6 Apr 2008 13:45:16 -0700 (PDT) Subject: Implementation of Crockford's Base32 Encoding? References: <345117e9-2539-4ee0-8b27-9b1a88ddde7c@a1g2000hsb.googlegroups.com> <3EF041EA-8E9A-4DAA-B690-FC725D9E25D6@gmail.com> <9d34f801-29cc-4c19-80d2-2ebdcc41d0bc@8g2000hse.googlegroups.com> Message-ID: <7e4eac36-be02-4238-aaa9-a54ca838c7e9@c65g2000hsa.googlegroups.com> Sorry to reply to myself. By reading the whole document I see he does give a few different ways one can hadle the lack of padding (including adding it back in.) Both the specs. seem to fudge a bit on this...I'll have to think more about it. On Apr 6, 5:40 pm, "samsli... at gmail.com" wrote: > Gabriel... > > I looked at Zooko's encoding. I didn't really like that the first 16 > characters weren't the same as for base 16, [0-9a-f]. > > I hadn't considered the need for padding. Zooko doesn't seem to use > it either. How does he get around it? > > Thanks > > p.s. Paul...yes it is different. :) > > On Apr 6, 7:15 am, "Gabriel Genellina" wrote: > > > En Sun, 06 Apr 2008 06:07:18 -0300, Petite Abeille > > escribi?: > > > > On Apr 6, 2008, at 9:20 AM, samsli... at gmail.com wrote: > > > >> Anyone know of aPythonimplementation of this: > > >>http://www.crockford.com/wrmg/base32.html > > > > Not sure aboutCrockford'sBase32encoding itself, but here is an > > > implementation of Bryce "Zooko" Wilcox-O'Hearn's "human-oriented > > > base-32 encoding": > > > >https://zooko.com/repos/z-base-32/base32/ > > >https://zooko.com/repos/z-base-32/base32/DESIGN > > > The design and rationale looks better. TheCrockfordversion is > > ill-defined in the sense that you can't recover the exact input string > > length in some cases; by example both "\x00"*4 and "\x00"*5 share the same > > encoding. > > base-64 encoding, by example, uses '=' as pad bytes at the end to avoid > > this problem. > > > -- > > Gabriel Genellina From bj_666 at gmx.net Wed Apr 16 09:44:32 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 16 Apr 2008 13:44:32 GMT Subject: vary number of loops References: Message-ID: <66me60F2lroubU1@mid.uni-berlin.de> On Wed, 16 Apr 2008 06:31:04 -0700, nullgraph wrote: > I'm new to Python and the notion of lambda, and I'm trying to write a > function that would have a varying number of nested for loops > depending on parameter n. This just smells like a job for lambda for > me, but I can't figure out how to do it. Any hint? That has nothing to do with ``lambda``. If you don't think "Hey, that's smells like a job for a function." then it's no job for ``lambda``, which is just a way to define a function without automatically binding it to a name like ``def`` does. One solution to your problem is recursion. Untested: def foo(xs): if xs: for elt in xs[0]: for ys in foo(xs[1:]): yield [elt] + ys else: yield [] Called as ``foo([A, B])``. Ciao, Marc 'BlackJack' Rintsch From carbanancizpo at gmail.com Fri Apr 18 16:53:24 2008 From: carbanancizpo at gmail.com (carbanancizpo at gmail.com) Date: Fri, 18 Apr 2008 13:53:24 -0700 (PDT) Subject: moyea flv to video converter keygen Message-ID: <2d4f244c-61e1-4ee6-8b6a-0a0c1b5c08ff@1g2000prf.googlegroups.com> moyea flv to video converter keygen http://cracks.12w.net F R E E C R A C K S From bwljgbwn at gmail.com Tue Apr 22 05:50:15 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:50:15 -0700 (PDT) Subject: nero 7 ultra edition crack Message-ID: <0c6b2d96-bf2d-473b-805b-e641ed08b7ea@q24g2000prf.googlegroups.com> nero 7 ultra edition crack http://cracks.12w.net F R E E C R A C K S From kf9150 at gmail.com Tue Apr 1 15:16:08 2008 From: kf9150 at gmail.com (Kelie) Date: Tue, 1 Apr 2008 12:16:08 -0700 (PDT) Subject: PyQt - Question on QListWidget's selectedItems Method Message-ID: <68632dc8-0426-4c6a-a2d8-04fd49381452@d21g2000prf.googlegroups.com> Hello, This method returns selected items by the order of user's picking, instead of the original order of these items. For example, if a ListWidget stores a list of ['A', 'B', 'C', 'D'] and when user is prompted to make a selection, if he picks 'D' first, then 'B', the returned ListWidget items would be 'D' first, then 'B', instead of 'B' first, then 'D'. This seems unusual to me. Would users normally care about the order of these items being picked? This selectedItems method does not seem to have an optional argument that allows returned items to be in their original order when added to the ListWidget. What did I miss? Thank you! From hotani at gmail.com Tue Apr 22 21:41:30 2008 From: hotani at gmail.com (hotani) Date: Tue, 22 Apr 2008 18:41:30 -0700 (PDT) Subject: python-ldap: searching without specifying an OU? References: <5b3fe46e-07a8-4570-9f27-004d55f0d04b@t63g2000hsf.googlegroups.com> Message-ID: <58546d42-bc80-4f9d-be90-e184c312e2d1@k37g2000hsf.googlegroups.com> Thanks for the response. The user I'm connecting as should have full access but I'll double check tomorrow. This is the LDAP error that is returned when I leave out the OU: {'info': '00000000: LdapErr: DSID-0C090627, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, vece', 'desc': 'Operations error'} From meisnernel73884 at gmail.com Wed Apr 30 06:36:00 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:36:00 -0700 (PDT) Subject: call of duty modern warfare keygen Message-ID: call of duty modern warfare keygen http://crack.cracksofts.com From bob at passcal.nmt.edu Fri Apr 18 18:41:34 2008 From: bob at passcal.nmt.edu (Bob Greschke) Date: Fri, 18 Apr 2008 16:41:34 -0600 Subject: 2's complement conversion. Is this right? References: <2008041813575616807-bob@passcalnmtedu> <2008041815265875249-bob@passcalnmtedu> <9f46fa1f-bf6d-407b-b885-29b62738624e@f36g2000hsa.googlegroups.com> Message-ID: <2008041816413450073-bob@passcalnmtedu> On 2008-04-18 16:04:37 -0600, George Sakkis said: > On Apr 18, 5:26?pm, Bob Greschke wrote: > >> On 2008-04-18 14:37:21 -0600, Ross Ridge >> said: >> >> >> >>> Bob Greschke ? wrote: >>>> I'm reading 3-byte numbers from a file and they are signed (+8 to >>>> -8million). ?This seems to work, but I'm not sure it's right. >> >>>> # Convert the 3-characters into a number. >>>> Value1, Value2, Value3 = unpack(">BBB", Buffer[s:s+3]) >>>> Value = (Value1*65536)+(Value2*256)+Value3 >>>> if Value >= 0x800000: >>>> Value -= 0x1000000 >>>> print Value >> >>>> For example: >>>> 16682720 = -94496 >> >>>> Should it be Value -= 0x1000001 so that I get -94497, instead? >> >>> Your first case is correct, "Value -= 0x1000000". ?The value 0xFFFFF > FF >>> should be -1 and 0xFFFFFFF - 0x1000000 == -1. >> >>> An alternative way of doing this: >> >>> ? ?Value = unpack(">l", Buffer[s:s+3] + "\0")[0] >> 8 >> >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?R > oss Ridge >> >> Good to know (never was good on the math front). >> >> However, in playing around with your suggestion and Grant's code I've >> found that the struct stuff is WAY slower than doing something like this >> >> ?Value = (ord(Buf[s])*65536)+(ord(Buf[s+1])*256)+ord(Buf[s+2]) >> ?if Value >= 0x800000: >> ? ? ?Value -= 0x1000000 >> >> This is almost twice as fast just sitting here grinding through a few >> hundred thousand conversions (like 3sec vs. ~5secs just counting on my >> fingers - on an old Sun...it's a bit slow). ? > > You'd better use a more precise timing method than finger counting, > such as timeit. Twice as fast is probably a gross overestimation; on > my box (Python 2.5, WinXP) avoiding unpack is around 10% and 40% > faster from Ross's and Grant's method, respectively: > > python -m timeit "for i in xrange(1000):from3Bytes_bob(s)" \ > -s "from bin import *; s=pack('>i',1234567)[1:]" > 1000 loops, best of 3: 1.02 msec per loop > > python -m timeit "for i in xrange(1000):from3Bytes_grant(s)" \ > -s "from bin import *; s=pack('>i',1234567)[1:]" > 1000 loops, best of 3: 1.43 msec per loop > > python -m timeit "for i in xrange(1000):from3Bytes_ross(s)" \ > -s "from bin import *; s=pack('>i',1234567)[1:]" > 1000 loops, best of 3: 1.12 msec per loop > > ### bin.py ########################################## > > from struct import unpack > > def from3Bytes_bob(s): > Value = (ord(s[0])<<16) + (ord(s[1])<<8) + ord(s[2]) > if Value >= 0x800000: > Value -= 0x1000000 > return Value > > def from3Bytes_grant(s): > if ord(s[0]) & 0x80: > s = '\xff'+s > else: > s = '\x00'+s > return unpack('>i',s)[0] > > def from3Bytes_ross(s): > return unpack(">l", s + "\0")[0] >> 8 > > >> Replacing *65536 with <<16 >> and *256 with <<8 might even be a little faster, but it's too close to >> call without really profiling it. > >> I wasn't planning on making this discovery today! :) >> >> Bob > > If you are running this on a 32-bit architecture, get Psyco [1] and > add at the top of your module: > import psyco; psyco.full() > > Using Psyco in this scenatio is up to 70% faster: > > python -m timeit "for i in xrange(1000):from3Bytes_bob(s)" \ > -s "from bin import *; s=pack('>i',1234567)[1:]" > 1000 loops, best of 3: 624 usec per loop > > python -m timeit "for i in xrange(1000):from3Bytes_grant(s)" \ > -s "from bin import *; s=pack('>i',1234567)[1:]" > 1000 loops, best of 3: 838 usec per loop > > python -m timeit "for i in xrange(1000):from3Bytes_ross(s)" \ > -s "from bin import *; s=pack('>i',1234567)[1:]" > 1000 loops, best of 3: 834 usec per loop > > > George > > [1] http://psyco.sourceforge.net/ I'm on a Solaris 8 with Python 2.3.4 and when crunching through, literally, millions and millions of samples of seismic data fingers point out the difference nicely. :) I'll look into this more on some of our bigger better faster machines (there is no -m option for timeit on the Sun :). The Sun is just what I develop on. If stuff runs fast enough to keep me awake on there over an ssh'ed X11 connection it should run even better on the real field equipment (Macs, Linuxes, WinXPs). Never heard of Psyco. That's nice! Thanks! Bob From tracyde at gmail.com Thu Apr 3 14:36:02 2008 From: tracyde at gmail.com (Derek Tracy) Date: Thu, 3 Apr 2008 14:36:02 -0400 Subject: Manipulate Large Binary Files In-Reply-To: <7xlk3vctea.fsf@ruckus.brouhaha.com> References: <9999810b0804020759l6d15e3d4j82599b6409a52edb@mail.gmail.com> <9999810b0804021109n77f2c990p7b10d92e9344ad00@mail.gmail.com> <7xlk3vctea.fsf@ruckus.brouhaha.com> Message-ID: <9EBD1A97-98C5-44E6-8472-A7AAADC0A3CA@gmail.com> On Apr 3, 2008, at 3:03 AM, Paul Rubin <"http:// phr.cx"@NOSPAM.invalid> wrote: > Derek Martin writes: >>> Both are clocking in at the same time (1m 5sec for 2.6Gb), are there >>> any ways I can optimize either solution? > > Getting 40+ MB/sec through a file system is pretty impressive. > Sounds like a RAID? > >> That said, due to normal I/O generally involving double-buffering, >> you >> might be able to speed things up noticably by using Memory-Mapped I/O >> (MMIO). It depends on whether or not the implementation of the >> Python >> things you're using already use MMIO under the hood, and whether or >> not MMIO happens to be broken in your OS. :) > > Python has the mmap module and I use it sometimes, but it's not > necessarily the right thing for something like this. Each page you > try to read from results in own delay while the resulting page fault > is serviced, so any overlapped i/o you get comes from the OS being > nice enough to do some predictive readahead for you on sequential > access if it does that. By coincidence there are a couple other > threads mentioning AIO which is a somewhat more powerful mechanism. > > -- > http://mail.python.org/mailman/listinfo/python-list I am running it on a RAID(stiped raid 5 using fibre channel), but I was expecting better performance. I will have to check into AIO, thanks for the bone. From triplezone3 at yahoo.co.uk Sat Apr 19 14:19:45 2008 From: triplezone3 at yahoo.co.uk (triplezone3) Date: Sat, 19 Apr 2008 19:19:45 +0100 (BST) Subject: urlretrieve can't send headers In-Reply-To: <66ulg4F2lidl3U1@mid.uni-berlin.de> Message-ID: <932266.62563.qm@web26908.mail.ukl.yahoo.com> I have looked in to urllib2, and I can't find a function which would allow me to get the progress of the download as it happens, bit by bit, like urlretrieve does, at least not easily. urllib.urlretrieve's returnhook is just handy. I have another question concerning urlretrieve, is there a way I can force it to stop downloading half-way, say after the user clicked cancel? Thanks in advance. --- "Diez B. Roggisch" wrote: > triplezone3 schrieb: > > Hello. I'm using urllib.urlretrieve to download > files, > > because it provides a handy hook function. > > Unfortunately, it won't let me send headers, which > > could be quite useful. Is there any way I could do > > this? > > I suggest you look into urllib2. It allows you to > explicitly create an > request-object that you can stuff with headers and > parameters and what > you like. > > diez > -- > http://mail.python.org/mailman/listinfo/python-list > ___________________________________________________________ Yahoo! For Good helps you make a difference http://uk.promotions.yahoo.com/forgood/ From kyosohma at gmail.com Wed Apr 16 13:50:09 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 16 Apr 2008 10:50:09 -0700 (PDT) Subject: Finally had to plonk google gorups. References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: On Apr 16, 11:06 am, Steve Holden wrote: > Mike Driscoll wrote: > > On Apr 16, 10:09 am, Steve Holden wrote: > >> Mike Driscoll wrote: > >>> On Apr 16, 9:19 am, Grant Edwards wrote: > >>>> This morning almost half of c.l.p was spam. In order to try to > >>>> not tar both the benign google group users and the malignant > >>>> ones with the same brush, I've been trying to kill usenet spam > >>>> with subject patterns. But that's not a battle you can win, so > >>>> I broke down and joined all the other people that just killfile > >>>> everything posted via google.groups. > >>>> AFAICT, if you're a google groups user your posts are not being > >>>> seen by many/most experienced (read "non-google-group") users. > >>>> This is mainly the fault of google who has refused to do > >>>> anything to stem the flood of span that's being sent via Google > >>>> Groups. > >>>> -- > >>>> Grant Edwards grante Yow! I would like to > >>>> at urinate in an OVULAR, > >>>> visi.com porcelain pool -- > >>> Yeah, I noticed that Google Groups has really sucked this week. I'm > >>> using the Google Groups Killfile for Greasemonkey now and it helps a > >>> lot. I like Google, but my loyalty only goes to far. This is a > >>> complete lack of customer service. > >> Unfortunately this means Google groups users are getting exactly the > >> service they are paying for. > > >> regards > >> Steve > >> -- > >> Steve Holden +1 571 484 6266 +1 800 494 3119 > >> Holden Web LLC http://www.holdenweb.com/ > > > Steve, > > > My workplace doesn't offer NNTP, so there is no good way to browse > > c.l.py here. And I haven't been able to get NNTP to work from my home > > either. > > > By applying this logic to Python and Linux (or any Open Source > > product), they shouldn't be used either (since I'm not paying for > > them). > > I'm not saying people shouldn't use Google Groups. I'm saying that > Google can "justify" providing customer "support" that lives somewhere > between zero and extremely crappy by not charging for the service. > > Without tunneling out to an NNTP proxy I don't see what other choice you > have. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ OK. The way it was written + the mood I was in made me misinterpret your meaning. I apologize. Mike From rkmr.em at gmail.com Tue Apr 15 23:25:56 2008 From: rkmr.em at gmail.com (rkmr.em at gmail.com) Date: Tue, 15 Apr 2008 20:25:56 -0700 Subject: python memory leak only in x86 64 linux Message-ID: the memory usage of a python app keeps growing in a x86 64 linux continuously, whereas in 32 bit linux this is not the case. Python version in both 32 bit and 64 bit linux - 2.6.24.4-64.fc8 Python 2.5.1 (r251:54863, Oct 30 2007, 13:45:26) i isolated the memory leak problem to a function that uses datetime module extensively. i use datetime.datetime.strptime, datetime.timedelta, datetime.datetime.now methods... i tried to get some info with guppy and the code goes like this while True: print heapy.heap().get_rp() print heapy.setref() users = globalstuff.q.get() for u in users: doalert(u) and it gives the following output for the 64bit linux below.. I am not able to decode this output or figure out why this leak is happening only in 64 bit linux and not in 32 bit. can anyone tell how to fix this problem? thanks a lot! Reference Pattern by <[dict of] class>. 0: _ --- [-] 82005 (Cheetah.Filters.DummyTemplate | Nouvelle.Serial.place | ... 1: a [-] 19901 tuple: 0x6674c0*27, 0x66b2b0*26, 0x67f270*36... 2: aa ---- [S] 5516 types.CodeType: xmlreader.py:375:_test... 3: ab [S] 454 type: warnings._OptionError, zipimport.ZipImportError... 4: ac ---- [-] 1133 function: bitbucket_s3.s3amazon.S3.__init__... 5: aca [S] 110 dict of module: copy_reg, os, site, warnings..., web 6: acb ---- [S] 233 dict of class: ..Codec, ..UserDict, .._Environ... 7: acc [S] 87 dict of type: ..IncrementalEncoder..., ..Quitter, .._Printer 8: acd ---- [-] 9 dict of email.LazyImporter: 0x93dc90, 0x93dcd0..., 0x93de50 9: acda [-] 9 email.LazyImporter: 0x93dc90, 0x93dcd0, 0x93dd90... None Reference Pattern by <[dict of] class>. 0: _ --- [-] 3862 (DBUtils.PooledDB.PooledDB | DBUtils.PooledDB.PooledDedica... 1: a [-] 51 web.utils.Storage: 0xd11e70, 0xd120c0, 0xd12350, 0xd18d20... 2: aa ---- [-] 1 list: 0xdbdd88*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 465 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 50 web.utils.Storage: 0xdea5d0, 0xdef260, 0xe503d0, 0xe73f10... 2: aa ---- [-] 1 list: 0xda1200*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: b [-] 2 list: 0x2aaaaaada710*2, 0xda1200*50 6: ba ---- [S] 1 dict of module: gc 7: bb [^ 3] 1 types.FrameType: 8: c ---- [^ 3] 1 types.FrameType: 9: d [-] 1 types.GeneratorType: 0x1519ab8 None Reference Pattern by <[dict of] class>. 0: _ --- [-] 467 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 50 web.utils.Storage: 0xbf83a0, 0xbf84d0, 0xd19810, 0xe03bc0... 2: aa ---- [-] 1 list: 0xf99440*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: b [-] 2 list: 0x2aaaaaada710*3, 0xf99440*50 6: ba ---- [S] 1 dict of module: gc 7: bb [^ 3] 1 types.FrameType: 8: c ---- [^ 3] 1 types.FrameType: 9: d [-] 1 types.GeneratorType: 0x10a75a8 None Reference Pattern by <[dict of] class>. 0: _ --- [-] 466 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 50 web.utils.Storage: 0xbf8600, 0xde7720, 0xe02c80, 0xfbd1c0... 2: aa ---- [-] 1 list: 0x1ebac20*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: b [-] 2 list: 0x1ebac20*50, 0x2aaaaaada710*4 6: ba ---- [S] 1 dict of module: gc 7: bb [^ 3] 1 types.FrameType: 8: c ---- [^ 3] 1 types.FrameType: 9: d [-] 1 types.GeneratorType: 0x1eba7e8 None Reference Pattern by <[dict of] class>. 0: _ --- [-] 466 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 50 web.utils.Storage: 0xd21060, 0xd21190, 0xd22480, 0xe48190... 2: aa ---- [-] 1 list: 0x238e560*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: b [-] 2 list: 0x238e560*50, 0x2aaaaaada710*5 6: ba ---- [S] 1 dict of module: gc 7: bb [^ 3] 1 types.FrameType: 8: c ---- [^ 3] 1 types.FrameType: 9: d [-] 1 types.GeneratorType: 0x1519cf8 None Reference Pattern by <[dict of] class>. 0: _ --- [-] 470 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0xdf0ee0, 0xfae860, 0xfc5850, 0xfc59d0... 2: aa ---- [-] 1 list: 0x13c67a0*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 468 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0xdf0ee0, 0xfae680, 0xfae990, 0xfd67b0... 2: aa ---- [-] 1 list: 0xf993b0*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 471 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0xdf0ee0, 0xfbf190, 0xfc0f10, 0xfe4990... 2: aa ---- [-] 1 list: 0x32ade18*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 473 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0xd07d00, 0xd07e30, 0xdf0ee0, 0xfac950... 2: aa ---- [-] 1 list: 0x10ad710*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 471 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x1122500..., 0xde94d0, 0xdf0ee0, 0xfd6040 2: aa ---- [-] 1 list: 0x23bd170*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 469 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x10879f0, 0x1088470..., 0xdf0ee0, 0xff3be0 2: aa ---- [-] 1 list: 0x392d170*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 468 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x112b280..., 0xdf0ee0, 0xfbed60, 0xfc4a00 2: aa ---- [-] 1 list: 0x389c440*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 470 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x10d76f0, 0x11484f0..., 0xdf0ee0, 0xfd2880 2: aa ---- [-] 1 list: 0x2f1cf38*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 470 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0xdf0ee0, 0xfb1e00, 0xfbeb10, 0xfce6a0... 2: aa ---- [-] 1 list: 0x324e5f0*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 472 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x1090e70..., 0xdf0ee0, 0xfdabd0, 0xfee4d0 2: aa ---- [-] 1 list: 0x4261248*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 469 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x1078230..., 0xdf0ee0, 0xfef440, 0xfef780 2: aa ---- [-] 1 list: 0x3dc62d8*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 470 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x1078f70, 0x108bf70..., 0xdf0ee0 2: aa ---- [-] 1 list: 0xf993f8*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 470 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x108e180, 0x112d100..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x10ad248*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 469 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x107db80, 0x107dcb0..., 0xdf0ee0, 0xfc33e0 2: aa ---- [-] 1 list: 0x5d21440*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 471 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x107df30, 0x108f790..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x64a3dd0*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 473 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x111ac40, 0x111ad70..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x72f0830*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 471 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0xdf0ee0, 0xfb61d0, 0xfb6300, 0xfbef50... 2: aa ---- [-] 1 list: 0x7095a70*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 470 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x107c1c0, 0x107c2f0..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x693b4d0*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 470 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x1085830..., 0xdf0ee0, 0xfd6a10, 0xfd6b40 2: aa ---- [-] 1 list: 0x7b85b48*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 470 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x1197940, 0x11afe40..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x892ba70*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 469 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x11bbea0, 0x42c1c00..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x7103050*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 469 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x10763b0, 0x10764e0..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x8b34098*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 469 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x13fffe0, 0x19851d0..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x9105ea8*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 470 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x2474f00, 0x28af3e0..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x9ce0ab8*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web None Reference Pattern by <[dict of] class>. 0: _ --- [-] 471 (datetime.datetime | float | int | list | long | str | type... 1: a [-] 51 web.utils.Storage: 0x119cb30, 0x1289d00..., 0xdf0ee0 2: aa ---- [-] 1 list: 0x9ed4dd0*50 3: a3 [S] 1 types.FrameType: 4: ab ---- [^ 3] 1 types.FrameType: 5: ac [-] 1 dict (no owner): 0x7413e0*1 6: aca ---- [S] 1 dict of module: ..webapi 7: acb [-] 1 dict of web.utils.ThreadedDict: 0x2aaab0711dd0 8: acba ---- [-] 1 web.utils.ThreadedDict: 0x2aaab0711dd0 9: acbaa [S] 3 dict of module: ..cheetah, ..webapi, web From goldspin at gmail.com Wed Apr 2 00:55:35 2008 From: goldspin at gmail.com (Henry Chang) Date: Tue, 1 Apr 2008 21:55:35 -0700 Subject: Basic class implementation question In-Reply-To: References: Message-ID: You might want to consult this. http://www.ibiblio.org/g2swap/byteofpython/read/object-methods.html On Tue, Apr 1, 2008 at 9:43 PM, wrote: > I can't get call a class for some reason. This must be one of those > newbie questions I hear so much about: > > class wontwork: > def really(): > print "Hello World" > > wontwork.really() > > This returns (as an error): > > Traceback (most recent call last): > File "", line 1, in > wontwork.really() > TypeError: unbound method really() must be called with wontwork > instance as first argument (got nothing instead) > > Any ideas? > -- > http://mail.python.org/mailman/listinfo/python-list > From tjreedy at udel.edu Sun Apr 27 15:33:56 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 27 Apr 2008 15:33:56 -0400 Subject: Tremendous slowdown due to garbage collection References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com><03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> Message-ID: "Dieter Maurer" wrote in message news:x7y76zte0h.fsf at handshake.de... | We observed similar very bad behaviour -- in a Web application server. | Apparently, the standard behaviour is far from optimal when the | system contains a large number of objects and occationally, large | numbers of objects are created in a short time. | We have seen such behaviour during parsing of larger XML documents, for | example (in our Web application). Does the standard alternative behavior of temporarily turning cyclic gc off solve your problem? Can this alternative be made easier by adding a context manager to gc module to use with 'with' statements? Something like with gc.delay() as dummy: with exit invoking the collector (or make that a delay keyword param?) Do the docs need some improvement in this area? tjr From anuraguniyal at yahoo.com Tue Apr 1 23:39:39 2008 From: anuraguniyal at yahoo.com (anuraguniyal at yahoo.com) Date: Tue, 1 Apr 2008 20:39:39 -0700 (PDT) Subject: bsddb3 thread problem References: Message-ID: <1c00d777-b1eb-438a-85b6-8096a7453829@u36g2000prf.googlegroups.com> > Using threads with bsddb3. ?I spent weeks trying to get it to behave > when threading. ?I gave up in the end and changed to sqlite :-( > So does it mean that I will have to use threading locks around access methods? or that will also fail mysteriously :) From castironpi at gmail.com Thu Apr 3 00:03:02 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 2 Apr 2008 21:03:02 -0700 (PDT) Subject: Prototype OO References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> <7xwsngyu05.fsf@ruckus.brouhaha.com> <7x8wzw80rf.fsf@ruckus.brouhaha.com> <0d97babc-1174-4537-a7eb-e60164521863@s13g2000prd.googlegroups.com> Message-ID: <83dfdeec-dfc4-41ae-9781-052bdbea7497@b64g2000hsa.googlegroups.com> On Apr 2, 5:41?pm, "bruno.desthuilli... at gmail.com" wrote: > On 2 avr, 22:23, Paul Rubin wrote: > > > "bruno.desthuilli... at gmail.com" writes: > > > Fine. But totally irrelevant here - this is comp.lang.python, not > > > comp.lang.c, and we *do not* (I repeat : we *do not*) face the same > > > safety and security problems as those existing in C. > > > We have it better than they do in some ways. > >In some other ways, we have > > it worse. > > Care to elaborate ? Or are we supposed to guess ?-) Has anyone thought about putting code in a Data file? Am I the only one that wants Python stored procedures in DB? From Lie.1296 at gmail.com Mon Apr 7 12:56:32 2008 From: Lie.1296 at gmail.com (Lie) Date: Mon, 7 Apr 2008 09:56:32 -0700 (PDT) Subject: First Python project - comments welcome! References: Message-ID: <0431417e-52b9-439f-b8cb-941d3b4fb42b@1g2000prg.googlegroups.com> On Apr 7, 3:03?pm, Paul Scott wrote: > I have started, and made some progress (OK it works, but needs some > love) on my first real Python application. > > http://cvs2.uwc.ac.za/trac/python_tools/browser/podder > > I would love some feedback on what I have done. In total this has taken > me 5 nights to do (I am working on it at night as PHP, not Python, is my > day job), so it can probably do with *lots* of improvement. All code is > GPL. > > If anyone on this list is willing/able, please do give me a few > pointers, even if it is "This is total crap - RTFM and come back when > you are ready" I would really appreciate it! > > Many thanks, and thank you to this community for helping me through the > initial bumps of getting into Python - a great dev tool IMHO! > > --Paul > > All Email originating from UWC is covered by disclaimerhttp://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm I don't know if it was just me, but I can't just scan through your code briefly to know what it is about (as is with any non-trivial codes), only after looking through the website's Roadmap I realized it's something to do with audio and recording. Perhaps you should add a short module-level docstring that explains in a brief what the code is about, somewhat like an abstract. And second, it's just my personal preference, but I usually like to separate between GUI codes (codes that handle GUI events) and working code (the real worker). It's just so that if one day you want to revamp the GUI (e.g. unify the play and pause button into a single morphing button), you could do it easily without touching the working code or if you want to call pause() from somewhere else other than GUI (from an error handler?), you don't call it by pause_click() while no clicking is done. It's also helpful if someday you want to make a command-line version of the program (for the same reason, so we don't call play_click() while what we're doing is typing some commands) or change the GUI engine. It's also helpful if we want to do something fancy that is GUI-related, like clicking the play button will keep it depressed until we click the stop button (like that ol' tape recorder) From stefan_ml at behnel.de Mon Apr 21 10:28:01 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 21 Apr 2008 16:28:01 +0200 Subject: py3k concerns. An example In-Reply-To: References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> Message-ID: <480CA471.5020501@behnel.de> Gabriel Genellina wrote: > You have plenty of time to evaluate alternatives. Your code may become obsolete even before 3.3 is shipped. Sure, and don't forget to save two bytes when storing the year. ;) Stefan From bvidinli at gmail.com Mon Apr 14 09:20:12 2008 From: bvidinli at gmail.com (bvidinli) Date: Mon, 14 Apr 2008 16:20:12 +0300 Subject: Python GUI programming and boa or better ? Message-ID: <36e8a7020804140620q1a1eb7d2xf4e8b3d753a1b62c@mail.gmail.com> I program in python for about 2-3 monthos. I just started/tested gui programming with many tools. i tested boa last, it is the closest tool to delphi in tui tools that i used. I managed to play with it a bit. If you have any other tool which you know better than Boa Constructor, please write in here. Any other suggestion about python GUI programming is welcome. thanks. -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From tjreedy at udel.edu Mon Apr 28 23:00:59 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 28 Apr 2008 23:00:59 -0400 Subject: Python Math libraries - How to? References: <48168670.9040102@islandtraining.com> Message-ID: "Gary Herron" wrote in message news:48168670.9040102 at islandtraining.com... aguirre.adolfo at gmail.com wrote: You have several ways to import a module, and your choice determines how you access things. Method 1: import math Then use: math.pi, math.sqrt, math.sin, math.cos, ... Method 2: from math import pi, sqrt Then use pi, and sqrt. But other module attributes (like sin, and cos) are not accessible. Method 3: from math import * Then use pi, sqrt, cos, sin, and anything else defined by the module. (This is sometime frowned upon, but there's no reason to do so here.) | ===================================== | There are two good reasons for the frown. One is for the potential conflict between builtin names, imported names (from possibly multiple modules), and names defined in the module. Builtins and math both have 'pow' functions that I believe are slightly different (or maybe once were). Math and cmath have 13 functions with duplicate names but different input and output (2.5). Importing * from both would be disasterous. The other is that someone not familiar with the imported module(s) will not know where a particular name came from when reading the code. Both problems are obvious worse with multiple imports. Method 4: (my favorite when using multiple names from a module) import math as m Then use m.pi, etc. tjr From sturlamolden at yahoo.no Thu Apr 17 11:29:49 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 17 Apr 2008 08:29:49 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: <7a39a28a-751d-4196-a45d-32bcdab89b90@26g2000hsk.googlegroups.com> On 17 Apr, 10:12, Steve Holden wrote: > Quick, write it down before the drugs wear off. Hehe, I don't take drugs, apart from NSAIDs for arthritis. Read my answer to Martin v. L?wis. From Stephen.Cattaneo at u4eatech.com Tue Apr 8 16:45:50 2008 From: Stephen.Cattaneo at u4eatech.com (Stephen Cattaneo) Date: Tue, 8 Apr 2008 13:45:50 -0700 Subject: Best way to check if string is an integer? In-Reply-To: <5fa6c12e0804081332r2a58d39gc44ce1ef8cb69052@mail.gmail.com> References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com><434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com><0fdd2825-6d1c-4380-a79a-a7aac119f002@a5g2000prg.googlegroups.com><96d2fe53-96bf-43d8-a58d-8269846bf0df@b64g2000hsa.googlegroups.com><2033313.fb3g3XYCIP@montana.com> <5fa6c12e0804081332r2a58d39gc44ce1ef8cb69052@mail.gmail.com> Message-ID: 1E+1 is short hand for a floating point number, not an interger. >>> float("1E+1") 10.0 You could convert the float to an integer if you wanted (i.e. ceiling, floor, rounding, truncating, etc.). Cheers, Steve -----Original Message----- From: Martin Marcher [mailto:martin at marcher.name] Sent: Tuesday, April 08, 2008 1:32 PM To: python-list at python.org Subject: Re: Best way to check if string is an integer? hmmm int() does miss some stuff: >>> 1E+1 10.0 >>> int("1E+1") Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: '1E+1' I wonder how you parse this? I honestly thought until right now int() would understand that and wanted to show that case as ease of use, I was wrong, so how do you actually cast this type of input to an integer? thanks martin -- http://tumblr.marcher.name https://twitter.com/MartinMarcher http://www.xing.com/profile/Martin_Marcher http://www.linkedin.com/in/martinmarcher You are not free to read this message, by doing so, you have violated my licence and are required to urinate publicly. Thank you. From jjl at pobox.com Sun Apr 6 08:08:58 2008 From: jjl at pobox.com (John J. Lee) Date: Sun, 06 Apr 2008 12:08:58 GMT Subject: Any fancy grep utility replacements out there? References: Message-ID: <87iqyv89t1.fsf@pobox.com> "samslists at gmail.com" writes: > So I need to recursively grep a bunch of gzipped files. This can't be > easily done with grep, rgrep or zgrep. (I'm sure given the right > pipeline including using the find command it could be done....but > seems like a hassle). > > So I figured I'd find a fancy next generation grep tool. Thirty > minutes of searching later I find a bunch in Perl, and even one in > Ruby. But I can't find anything that interesting or up to date for > Python. Does anyone know of something? > > Thanks There must be a million of these scripts out there, maybe one per programmer :-) Here's mine: http://codespeak.net/svn/user/jjlee/trunk/pygrep/ It doesn't do zip files. It has the usual file / dir blacklisting feature (for avoiding backup files, etc.). Oddities of this particular script are support for searching for Python tokens in .py files, doctests, doctest files, and preppy 2 .prep template files. It also outputs in a format that allows you to click on matches in emacs. A few years back I was going to release it in the hope that other people would write plugins for other templating systems, but then I stopped doing lots of web stuff. Actually, tokenizing based on a simple fixed "word boundary" rule seems to work as well in many cases (pygrep doesn't do that) -- though sometimes proper tokenization can be quite handy -- searching for a particular Python name, Python string or number can be just what's needed (pygrep does support that -- e.g. , -sep, -sebp, -nep). Most of the time I just use the -t option though, which is just substring match, just because it's fast and good enough for most cases (most search strings are longish and so don't give lots of false positives). The default is tokenized search for files it knows how to tokenize (.py, .prep, etc.) and substring match for every other file that's not blacklisted -- I find this good for small projects, but too slow (there's no caching) for large projects. Somebody at work has a nice little web-based tool that you can run as a local server, and turns tokens (e.g. Python names -- but it's based on some fast simple tokenizer that doesn't know about Python) into links you can click on. The CSS is written so the link styling doesn't show up until you hover the mouse over a token, IIRC. It seems very efficient for exploring/reading and navigating source code -- I only don't use it because it's not integrated with emacs. It would be great if somebody could do the same in emacs, with back / forward buttons :-) John From dgates at somedomain.com Mon Apr 14 10:51:07 2008 From: dgates at somedomain.com (dgates) Date: Mon, 14 Apr 2008 07:51:07 -0700 Subject: Game design : Making computer play References: Message-ID: <7nr604dluq8dhap6jl519vamld41t68nsg@4ax.com> On Mon, 14 Apr 2008 12:13:20 +0000 (UTC), Willem wrote: >Richard wrote: >) Here's the board (which bears only a slight resemblance to one I'd seen on >) the Web): >) >) +---------------+ >) | HORN $ | >) +---+---+---+---+---+---+ >) |L W| | $ | $ | |R W| >) +E-I+--CHEST+---+---+I-I+ >) |F N| | | | |G N| >) +T-G+---+---+---+---+H-G+ >) | | | | | |T | >) +---+---+---+---+---+---+ >) | LEGS| | | >) +---+---+---+---+ >) >) There are three tigers and fifteen goats. >) The tigers' goal is to eat all the goats and remain mobile. >) It seems that the initial tiger positions are: one on the horn, and one >) each on CHEST-2 and CHEST-3 (see $ marks, above). >) The goats' goal is to block the tigers from moving. >) The goats are placed one by one. >) Tigers appear only to be able to move orthogonally (up/down/left/right) - >) although they can use the horn to whizz across the chest (e.g. CHEST-1 to >) HORN, HORN to CHEST-4, in two moves). >) The rest of the rules are beyond me, I'm afraid. It's not clear how tigers >) eat goats or how goats block tigers. > >If it's similar to the 'other' goats and tigers game, a tiger eats a goat >by jumping over it, for which the square behind it needs to be empty, >obviously. v4 gave us a link to a page that not only lists the rules, but lets you try them out: http://v4vijayakumar.googlepages.com/goats-and-tigers.html Seems like a fun quickie game to play with some coins on a piece of paper. I like the asymmetrical goals and the quick setup. From toby at tobiah.org Tue Apr 15 17:03:53 2008 From: toby at tobiah.org (Tobiah) Date: Tue, 15 Apr 2008 14:03:53 -0700 Subject: Getting subprocess.call() output into a string? References: Message-ID: On Tue, 15 Apr 2008 13:36:11 -0700, Tobiah wrote: > I am not sure how to capture the output of a command > using subprocess without creating a temp file. I was Sorry, I jumped into a secondary level of the docs, and didn't see it all. I guess I can use communicate() to get the output. Still, about StringIO... > trying this: > > import StringIO > import subprocess > > file = StringIO.StringIO() > > subprocess.call("ls", stdout = file) > > Traceback (most recent call last): > File "", line 6, in ? > File "/usr/local/lib/python2.4/subprocess.py", line 413, in call > return Popen(*args, **kwargs).wait() > File "/usr/local/lib/python2.4/subprocess.py", line 534, in __init__ > (p2cread, p2cwrite, > File "/usr/local/lib/python2.4/subprocess.py", line 840, in _get_handles > c2pwrite = stdout.fileno() > AttributeError: StringIO instance has no attribute 'fileno' > > So how do I get the output into a string? > > I thought that the idea of StringIO was that it could be > used where a file was expected. > > Thanks, > > Toby > ** Posted from http://www.teranews.com ** ** Posted from http://www.teranews.com ** From gh at ghaering.de Thu Apr 10 04:56:19 2008 From: gh at ghaering.de (=?ISO-8859-1?Q?Gerhard_H=E4ring?=) Date: Thu, 10 Apr 2008 10:56:19 +0200 Subject: urgent question, about filesystem-files In-Reply-To: References: Message-ID: <66631jF2iadeoU1@mid.uni-berlin.de> bvidinli wrote: > i started python programming a few months ago. > > now i need the code to understand if a file already opened in > filesystem by another process ? > > i looked at docs, howtos, but did not find related info. > note that normal file open/write operations in python, i know it. > > i specificly need to know that "is a file already open by some other > process other than python". The pragmatic solution here is to not worry about it and let it be the user's problem if he does something stupid. It's OS specific how to get at this information. On Linux, for example you can call the `fuser` program (if installed; on Ubuntu it's in the psmisc package). But this will only tell you if the same user has the file open (or if you're root). -- Gerhard From michele.simionato at gmail.com Wed Apr 23 13:53:03 2008 From: michele.simionato at gmail.com (Michele Simionato) Date: Wed, 23 Apr 2008 10:53:03 -0700 (PDT) Subject: Python generators (coroutines) References: Message-ID: On Apr 23, 4:17 pm, rocco.ro... at gmail.com wrote: > I would really like to know more about python 2.5's new generator > characteristics that make them more powerful and analogous to > coroutines. Is it possible for instance to employ them in situations > where I would normally use a thread with a blocking I/O (or socket) > operation? If it is, could someone show me how it can be done? There > appears to be a very limited amount of documentation in this repect, > unfortunately. > > Thank you. The real changes between Python 2.4 and Python 2.5 generators are 1) now you can have a yield inside a try .. finally statement 2) now you can send an exception to a generator The fact that now you can send values to a generator is less important, since you could implement the same in Python 2.4 with little effort (granted, with an uglier syntax) whereas there was no way to get 1) and 2). Anyway, if you have a blocking operation, the only solution is to use a thread or a separate process. Michele Simionato From shahmed at sfwmd.gov Wed Apr 23 11:16:19 2008 From: shahmed at sfwmd.gov (Ahmed, Shakir) Date: Wed, 23 Apr 2008 11:16:19 -0400 Subject: Error Message In-Reply-To: <480F483B.9050507@holdenweb.com> References: <06d42098-080a-4bd8-b11d-082de0e304d3@t54g2000hsg.googlegroups.com> <27CC3060AF71DA40A5DC85F7D5B70F3802840196@AWMAIL04.belcan.com><27CC3060AF71DA40A5DC85F7D5B70F38033A4F2D@AWMAIL04.belcan.com> <480F483B.9050507@holdenweb.com> Message-ID: <14A2A120D369B6469BB154B2D2DC34D20AD1195E@EXCHVS01.ad.sfwmd.gov> I am getting application error message " The instruction at "0x7c910f29" referenced memory at "0xffffffff". The memory could not be "read". I am running one python script and it is running good without any exception or error message but getting this message when I am closing python 2.4.1 application. Any idea or help is highly appreciated. Thanks sk -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.jpg Type: image/jpeg Size: 12570 bytes Desc: image001.jpg URL: From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 22 03:33:05 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 22 Apr 2008 09:33:05 +0200 Subject: Java or C++? In-Reply-To: <2eae6385-1257-48fc-b793-31d0225503ba@f36g2000hsa.googlegroups.com> References: <2eae6385-1257-48fc-b793-31d0225503ba@f36g2000hsa.googlegroups.com> Message-ID: <480d94aa$0$23089$426a74cc@news.free.fr> hdante a ?crit : > Summarizing the discussion (and giving my opinions), here's an > "algorithm" to find out what language you'll leard next: > > 1. If you just want to learn another language, with no other > essential concern, learn Ruby. > 2. If you want to learn another language to design medium to large > size applications, considering market, jobs, etc., and the speed gains > of static byte-compiled languages, learn Java or C#. > 3. If you want to learn another language to design applications with > speed gains, but you want that the transition be as smooth as possible > and don't have market concerns (and with the possibility of taking > another easy step later to reach step 2), learn Groovy (for the JMV) > or Boo (for .NET). > 4. If you want to develop applications but, for some special reason, > you require native compilation (like speed requirements, embedded > systems, etc.), learn C++ > 5. If you want to develop system software, or just learn better how > machines work, or understand better low level implementation aspects > of software, learn C. > 6. If you just want to speed-up your python programs or offer some > special, system-specific or optimized behavior to your python > applications, or you just want to complement your python knowledge, > learn C. > And if you really want to actually *learn* something, learn a functional language. From fr5478bey at gmail.com Sat Apr 26 11:42:31 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:42:31 -0700 (PDT) Subject: avg internet security crack Message-ID: <72edc5f7-a6f7-44d4-8f30-707acb7fb622@a1g2000hsb.googlegroups.com> avg internet security crack http://cracks.00bp.com F R E E C R A C K S From jason.scheirer at gmail.com Tue Apr 8 00:57:47 2008 From: jason.scheirer at gmail.com (Jason Scheirer) Date: Mon, 7 Apr 2008 21:57:47 -0700 (PDT) Subject: Newbie: How to pass a dictionary to a function? References: <516e07d1-91f9-462b-9fc0-ac6d1e474f9d@n14g2000pri.googlegroups.com> Message-ID: <0178aef6-46ce-47a4-a2a4-882514e2aacd@k1g2000prb.googlegroups.com> On Apr 7, 8:54 pm, BonusOnus wrote: > How do I pass a dictionary to a function as an argument? > > # Say I have a function foo... > def foo (arg=[]): > x = arg['name'] > y = arg['len'] > > s = len (x) > > t = s + y > > return (s, t) > > # The dictionary: > > dict = {} > dict['name'] = 'Joe Shmoe' > dict['len'] = 44 > > # I try to pass the dictionary as an argument to a > # function > > len, string = foo (dict) > > # This bombs with 'TypeError: unpack non-sequence' > > What am I doing wrong with the dictionary? You want to return s, t NOT return (s, t) -- this implicitly only returns ONE item From landerdebraznpc at gmail.com Mon Apr 28 03:55:23 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:55:23 -0700 (PDT) Subject: crack zone Message-ID: <23cd8db2-68da-445a-b86d-6466f433d3e9@l64g2000hse.googlegroups.com> crack zone http://crack.cracksofts.com From ridenour4159 at gmail.com Thu Apr 24 06:12:21 2008 From: ridenour4159 at gmail.com (ridenour4159 at gmail.com) Date: Thu, 24 Apr 2008 03:12:21 -0700 (PDT) Subject: xyplorer crack Message-ID: <9b7fbb72-4c1d-40f9-b397-4542ae846b5b@m36g2000hse.googlegroups.com> xyplorer crack http://cracks.12w.net F R E E C R A C K S From Scott.Daniels at Acm.Org Wed Apr 30 09:00:36 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Wed, 30 Apr 2008 06:00:36 -0700 Subject: how to convert a multiline string to an anonymous function? In-Reply-To: <87c29666-f64f-4f3c-97e1-a3d1dccdc49b@s50g2000hsb.googlegroups.com> References: <67pmdnF2p5fhgU1@mid.uni-berlin.de> <87c29666-f64f-4f3c-97e1-a3d1dccdc49b@s50g2000hsb.googlegroups.com> Message-ID: <9a2dnc3tFZET9oXVnZ2dnUVZ_rqlnZ2d@pdx.net> Matimus wrote: > On Apr 29, 3:39 pm, "Diez B. Roggisch" wrote: >> Danny Shevitz schrieb: >>> Simple question here: ... >>> str = ''' >>> def f(state): >>> print state >>> return True >>> ''' >>> but return an anonmyous version of it, a la 'return f' so I can assign it >>> independently. The body is multiline so lambda doesn't work.... >> The "stupid" thing is that you can pass your own dictionary as globals >> to exec. Then you can get a reference to the function under the name "f" >> in the globals, and store that under whatever name you need.... >> Diez > ... Or, you can even more simply do: text = ''' def f(state): print state return True ''' lcl = {} exec text in globals(), lcl and lcl will be a dictionary with a single item: {'f' : } so you could return lcl.values()[0] -Scott David Daniels Scott.Daniels at Acm.Org From steve at holdenweb.com Wed Apr 9 22:08:01 2008 From: steve at holdenweb.com (Steve Holden) Date: Wed, 09 Apr 2008 22:08:01 -0400 Subject: new user needs help! In-Reply-To: <16596608.post@talk.nabble.com> References: <16571823.post@talk.nabble.com> <16596608.post@talk.nabble.com> Message-ID: drjekil wrote: > I have done something so far about that problem,but its not the good way to > do it > > need ur comments about that.... > Well, at least you can see that your approach is not satisfactory, so that means you have some sense of what's good and bad programming/ > > from string import *; > import sys > > myfile = open("/afs/pdc.kth.se/home/d/debnath/membrane/1a91A.txt") > a = myfile.readlines() > data = myfile.readlines() The first readlines() exhausts the file. > for line in myfile.readlines(): You should omit the assignments to a and to data, as they are using up the contents of the file that you want this statrement to iterate over. > fields = line.split('\t') > > items=fields.strip() > list1.append(items[1]) > Note that what you are doing here is building a list of the lines in the file to iterate over later, when you could just iterate over the lines in the file. > > for i in aminoacid: > if 10.0 <= z <= 22.0: > matches.append([1,i]) > #here i am getting comment! bash-3.1$ python bb.py > File "bb.py", line 16 > matches.append([1,i]) > ^ > IndentationError: expected an indented block > > else: > matches.append([-1,i]) > The error message is literally correct. The statement(s) controlled by an if must be indented relative to the if statement itself - remember, Python uses indentation to indicate block structure. Also, it seems a little unnecessary to build a list of all the matching lines and then process them, when you could process them one at a time as you read them from the file! > print "#T/F A C D E F G H I K L M N P Q R S T V W X Y > Z" > That looks fine! > for a in range(0,len(matches),1): > > if matches[a][0]==1: > > if matches[a][1]=='A': > print "1 1:1 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 > 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > elif matches[a][1]=='C': > print "1 1:0 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 > 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > elif matches[a][1]=='D': > > print " 1 1:0 2:0 3:1 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > """ if matches[a][1]=='E' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:1 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='F' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:1 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='G' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:1 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='H' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='I' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:1 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='K' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:1 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='L' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:1 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='M' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:1 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='N' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:1 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='P' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:1 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='Q' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='R' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:1 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='S' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:1 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='T' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:1 18:0 19:0 20:0 21:0" > if matches[a][1]=='V' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:1 19:0 20:0 21:0" > if matches[a][1]=='X' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:1 20:0 21:0" > if matches[a][1]=='Y' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:1 21:0" > if matches[a][1]=='Z' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:1" > > > """ > else: > if matches[a][1]=='A': > print "-1 1:1 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 13:0 > 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > elif matches[a][1]=='C': > print "-1 1:0 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > elif matches[a][1]=='D': > > print " 1 1:0 2:0 3:1 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > """ if matches[a][1]=='E' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:1 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='F' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:1 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='G' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:1 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='H' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:1 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='I' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:1 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='K' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:1 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='L' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:1 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='M' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:1 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='N' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:1 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='P' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:1 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='Q' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='R' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:1 16:0 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='S' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:1 17:0 18:0 19:0 20:0 21:0" > if matches[a][1]=='T' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:1 18:0 19:0 20:0 21:0" > if matches[a][1]=='V' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:1 19:0 20:0 21:0" > if matches[a][1]=='X' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:1 20:0 21:0" > if matches[a][1]=='Y' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:1 21:0" > if matches[a][1]=='Z' and matches[a][0]==1: > > print " 1 1:0 2:0 3:0 4:0 5:0 6:0 7:0 8:0 9:0 10:0 11:0 12:0 > 13:0 14:0 15:0 16:0 17:0 18:0 19:0 20:0 21:1" > waiting for ur opinion. > thanks > I think you're right about the logic being unnecessarily complex :-) The following is untested, but it will give you some idea of how you might proceed. myfile = open("/afs/pdc.kth.se/home/d/debnath/membrane/1a91A.txt") print "#T/F A C D E F G H I K L M N P Q R S T V W X Y Z" for line in myfile.readlines(): fields = line.strip().split('\t') if 10.0 <= float(fields[6]) <= 22.0: # Sets T/F flag flag = 1 else: flag = -1 pos = "ACDEFGHIKLMNPQRSTVWXYZ".index(fields[1]) m = [] for i in range(20): if pos == i: m.append("%d:1") else: m.append("%d:0") print flag, " ".join(m) This is not quite as compact as it could be. What you could do is try running it with print statements inserted to show you what value variables are taking in statements you don't understand. Hope this helps! regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From nagle at animats.com Sat Apr 12 01:12:59 2008 From: nagle at animats.com (John Nagle) Date: Fri, 11 Apr 2008 22:12:59 -0700 Subject: Question on threads In-Reply-To: References: <47FFBC05.50309@holdenweb.com> Message-ID: <4800424b$0$36318$742ec2ed@news.sonic.net> Steve Holden wrote: > Jonathan Shao wrote: >> On Fri, Apr 11, 2008 at 3:29 PM, Steve Holden > > wrote: >> >> Jonathan Shao wrote: >> >> Hi all, >> I'm a beginner to Python, so please bear with me. >> Is there a way of guarenteeing that all created threads in a >> program are finished before the main program exits? >> I guess I'm doing something wrong with join(). Didn't we answer this question just a few days ago? John Nagle From skanemupp at yahoo.se Sun Apr 6 22:50:16 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sun, 6 Apr 2008 19:50:16 -0700 (PDT) Subject: Tkinter, a lot of buttons, make prog shorter? References: <688483d9-2c6a-4e2a-b64d-f32bb27699ec@p25g2000hsf.googlegroups.com> Message-ID: <8869512e-19c3-4750-b4f1-5666a2547f13@u3g2000hsc.googlegroups.com> should i not use self. in Clean() and Calculate() either? anyway i had changed it before. must have copied the wrong program. #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self, master=None): """Initialize yourself""" self.expr = "" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): """Create the Button, set the text and the command that will be called when the button is clicked""" btnDisplay = Button(self, text="calculate!", command=self.Calculate) btnDisplay.grid(row=0, column=31) ## """Create the Button, set the text and the ## command that will be called when the button is clicked""" ## self.lbText = Label(self, text="Results:") ## self.lbText.grid(row=1, column=0) btnDisplay = Button(self,text='1',command=lambda n="1":self.Display(n),width=2,height=2) btnDisplay.grid(row=3, column=0) btnDisplay = Button(self,text='2',command=lambda n="2":self.Display(n),width=2,height=2) btnDisplay.grid(row=3, column=1) btnDisplay = Button(self,text='3',command=lambda n="3":self.Display(n),width=2,height=2) btnDisplay.grid(row=3, column=2) btnDisplay = Button(self,text='+',command=lambda n="+":self.Display(n),width=2,height=2) btnDisplay.grid(row=3, column=3) btnDisplay = Button(self,text='4',command=lambda n="4":self.Display(n),width=2,height=2) btnDisplay.grid(row=4, column=0) btnDisplay = Button(self,text='5',command=lambda n="5":self.Display(n),width=2,height=2) btnDisplay.grid(row=4, column=1) btnDisplay = Button(self,text='6',command=lambda n="6":self.Display(n),width=2,height=2) btnDisplay.grid(row=4, column=2) btnDisplay = Button(self,text='-',command=lambda n="-":self.Display(n),width=2,height=2) btnDisplay.grid(row=4, column=3) btnDisplay = Button(self,text='7',command=lambda n="7":self.Display(n),width=2,height=2) btnDisplay.grid(row=5, column=0) btnDisplay = Button(self,text='8',command=lambda n="8":self.Display(n),width=2,height=2) btnDisplay.grid(row=5, column=1) btnDisplay = Button(self,text='9',command=lambda n="9":self.Display(n),width=2,height=2) btnDisplay.grid(row=5, column=2) btnDisplay = Button(self,text='*',command=lambda n="*":self.Display(n),width=2,height=2) btnDisplay.grid(row=5, column=3) btnDisplay = Button(self,text='0',command=lambda n="0":self.Display(n),width=2,height=2) btnDisplay.grid(row=6, column=0) btnDisplay = Button(self,text='C',command=self.Clean,width=2,height=2) btnDisplay.grid(row=6, column=1) btnDisplay = Button(self,text='^.5',command=lambda n="**. 5":self.Display(n),width=2,height=2) btnDisplay.grid(row=6, column=2) btnDisplay = Button(self,text='/',command=lambda n="/":self.Display(n),width=2,height=2) btnDisplay.grid(row=6, column=3) def Display(self, number): self.expr = self.expr + number self.lbText = Label(self, text=self.expr) self.lbText.grid(row=0, column=0) def Calculate(self): self.expr = str(eval(self.expr))#try catch tex 3+6+ result = self.expr self.Clean() self.lbText = Label(self, text=result) self.lbText.grid(row=0, column=0) self.expr = "" def Clean(self): self.expr = " " self.lbText.config(text=self.expr) self.lbText = Label(self, text=self.expr) self.lbText.grid(row=0, column=0) self.expr = "" self.lbText.config(text=self.expr) self.lbText = Label(self, text=self.expr) self.lbText.grid(row=0, column=0) if __name__ == "__main__": guiFrame = GUIFramework() guiFrame.mainloop() From sturlamolden at yahoo.no Thu Apr 24 22:56:14 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 24 Apr 2008 19:56:14 -0700 (PDT) Subject: Calling Python code from inside php References: <679e9oF2mti63U1@mid.uni-berlin.de> <25c76191-029b-47f0-adae-d5c988291cb8@m73g2000hsh.googlegroups.com> <679hd5F2nj6csU1@mid.uni-berlin.de> Message-ID: <94a6b9c5-9b5b-4b4d-b79a-db4dd61f3e67@w7g2000hsa.googlegroups.com> On Apr 24, 5:51 am, Nick Stinemates wrote: > I don't understand how the 2 are mutually exclusive? > > You can have PHP and Python bindings installed on the same Apache > server, unless I'm mistaken? Not everyone have the luxury of having mod_python installed. It depends on the host. On the other hand, mod_php will almost certainly be installed on any Apache server. From torriem at gmail.com Wed Apr 16 12:12:20 2008 From: torriem at gmail.com (Michael Torrie) Date: Wed, 16 Apr 2008 10:12:20 -0600 Subject: Finally had to plonk google gorups. In-Reply-To: <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> References: <7924c5e2-a883-4a70-81d9-fd9962fb25a8@m36g2000hse.googlegroups.com> <739039ff-10f6-4369-9886-3af628798c22@2g2000hsn.googlegroups.com> Message-ID: <48062564.4000802@gmail.com> Mike Driscoll wrote: > Steve, > > My workplace doesn't offer NNTP, so there is no good way to browse > c.l.py here. And I haven't been able to get NNTP to work from my home > either. I rarely use NNTP these days. I access c.l.py exclusively via e-mail, and that works very well. In some cases there is a lot of spam that gets filtered out of the nntp side, but makes it through to the smtp side (like that religious spam a few months back). But I see absolutely none of the google groups problems that Grant mentioned. I view my python list mail in gmail, and get about 1-2 spam messages a day in the python list. This official python list is one of the few lists that's even still on nntp. All my other ones (gnome, gtk, openldap, clamav, freeradius, etc) are all e-mail mailing lists only and it works very well. In fact, I think it's much better since list subscription can actually be controlled by someone. From ewertman at gmail.com Thu Apr 24 12:14:47 2008 From: ewertman at gmail.com (Eric Wertman) Date: Thu, 24 Apr 2008 12:14:47 -0400 Subject: Ideas for parsing this text? In-Reply-To: References: Message-ID: <92da89760804240914o61467e1at5eec3968a8ab7f33@mail.gmail.com> > I would discourage you from using printables, since it also includes > '[', ']', and '"', which are significant to other elements of the > parser (but you could create your own variable initialized with > printables, and then use replace("[","") etc. to strip out the > offending characters). I'm also a little concerned that you needed to > add \t and \n to the content word - was this really necessary? None > of your examples showed such words, and I would rather have you let > pyparsing skip over the whitespace as is its natural behavior. > > -- Paul You are right... I have taken those out and it still works. I was adding everything I could think of at one point in trying to determine what was breaking the parser. Some of the data in there is input free form... which means that any developer could have put just about anything in there... I find a lot of ^M stuff from day to day in other places. From fred.sells at adventistcare.org Tue Apr 29 16:15:44 2008 From: fred.sells at adventistcare.org (Sells, Fred) Date: Tue, 29 Apr 2008 16:15:44 -0400 Subject: Need Python alternative to Request-Tracker help desk software In-Reply-To: Message-ID: <0A53725C4A497848A7B3A0874B259831011B08E8@acesxch01.ADVENTISTCORP.NET> I've been tasked with either implementing Request-Tracker to upgrade our help desk issue tracking system or finding a Python equivalent (both in terms of functionality and wide spread use). Request-Tracker uses Apache and MySQL, which would also be appropriate to Python. I would prefer to go the Python route, especially since Request-Tracker is written in Perl (which I don't know). My initial attempts with Google were not useful due to the general nature of the keywords. Are there any suggestions. --------------------------------------------------------------------------- The information contained in this message may be privileged and / or confidential and protected from disclosure. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and deleting the material from any computer. --------------------------------------------------------------------------- From george.sakkis at gmail.com Fri Apr 11 15:20:27 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Fri, 11 Apr 2008 12:20:27 -0700 (PDT) Subject: Profiling programs/scripts? References: Message-ID: On Apr 11, 2:49?pm, skanem... at yahoo.se wrote: > how do i profile a program? i found out that there are some profilers > included in the standard library but couldnt really figure out how to > access/use them Did you actually read the docs ? There is an example in the stdlib documentation: http://docs.python.org/lib/hotshot-example.html HTH, George From dieter at handshake.de Mon Apr 28 12:44:57 2008 From: dieter at handshake.de (Dieter Maurer) Date: Mon, 28 Apr 2008 18:44:57 +0200 Subject: Tremendous slowdown due to garbage collection In-Reply-To: <4814B904.1070804@v.loewis.de> References: <49b55bca-cbb8-4ac9-8720-4be87b930d5c@m3g2000hsc.googlegroups.com> <03594410-2463-430a-81b1-3005cc7e7bac@m44g2000hsc.googlegroups.com> <4814B904.1070804@v.loewis.de> Message-ID: <18453.65289.773531.366188@gargle.gargle.HOWL> "Martin v. L?wis" wrote at 2008-4-27 19:33 +0200: >> Martin said it but nevertheless it might not be true. >> >> We observed similar very bad behaviour -- in a Web application server. >> Apparently, the standard behaviour is far from optimal when the >> system contains a large number of objects and occationally, large >> numbers of objects are created in a short time. >> We have seen such behaviour during parsing of larger XML documents, for >> example (in our Web application). > >I don't want to claim that the *algorithm* works for all typically >applications well. I just claim that the *parameters* of it are fine. >The OP originally proposed to change the parameters, making garbage >collection run less frequently. This would a) have bad consequences >in terms of memory consumption on programs that do have allocation >spikes, and b) have no effect on the asymptotic complexity of the >algorithm in the case discussed. In our case, it helped to change the parameters: As usual in Python, in our case cyclic garbage is very rare. On the other hand, we have large caches with lots of objects, i.e. a large number of long living objects. Each generation 2 garbage collection visits the complete object set. Thus, if it is called too often, matters can deteriorate drastically. In our case, the main problem has not been the runtime but that during GC the GIL is hold (understandably). This meant that we had every few minutes a scheduling distortion in the order of 10 to 20 s (the time of our generation 2 gc). We changed the parameters to let generation 2 GC happen at about 1/1000 of its former frequency. I do not argue that Python's default GC parameters must change -- only that applications with lots of objects may want to consider a reconfiguration. -- Dieter From carlwuhwdmckay at gmail.com Mon Apr 21 02:06:39 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:06:39 -0700 (PDT) Subject: firewire patch cable Message-ID: <81b7c6ef-7f18-42a6-afee-835c2325464f@k13g2000hse.googlegroups.com> firewire patch cable http://cracks.00bp.com F R E E C R A C K S From arnodel at googlemail.com Thu Apr 10 12:09:36 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Thu, 10 Apr 2008 09:09:36 -0700 (PDT) Subject: @x.setter property implementation References: <14e5ad63-4def-4f30-98d7-5eaf7c473dd8@a22g2000hsc.googlegroups.com> <02cb2845-6a25-4e90-9f82-dbd68b37a5e6@p39g2000prm.googlegroups.com> Message-ID: <2c589c82-85e9-4db6-b8f9-156b06dd51f3@s33g2000pri.googlegroups.com> On Apr 10, 3:37?pm, Floris Bruynooghe wrote: > On Apr 7, 2:19 pm, "Andrii V. Mishkovskyi" wrote: > > > 2008/4/7, Floris Bruynooghe : > > > > ?Have been grepping all over the place and failed to find it. ?I found > > > ?the test module for them, but that doesn't get me very far... > > > I think you should take a look at 'descrobject.c' file in 'Objects' directory. > > Thanks, I found it! ?So after some looking around here was my > implementation: > > class myproperty(property): > ? ? def setter(self, func): > ? ? ? ? self.fset = func > > But that doesn't work since fset is a read only attribute (and all of > this is implemented in C). > > So I've settled with the (nearly) original proposal from Guido on > python-dev: > > def propset(prop): > ? ? assert isinstance(prop, property) > ? ? @functools.wraps > ? ? def helper(func): > ? ? ? ? return property(prop.fget, func, prop.fdel, prop.__doc__) > ? ? return helper > > The downside of this is that upgrade from 2.5 to 2.6 will require code > changes, I was trying to minimise those to just removing an import > statement. > > Regards > Floris Here's an implementation of prop.setter in pure python < 2.6, but using sys._getframe, and the only test performed is the one below :) import sys def find_key(mapping, searchval): for key, val in mapping.iteritems(): if val == searchval: return key _property = property class property(property): def setter(self, fset): cls_ns = sys._getframe(1).f_locals propname = find_key(cls_ns, self) # if not propname: there's a problem! cls_ns[propname] = property(self.fget, fset, self.fdel, self.__doc__) return fset # getter and deleter can be defined the same way! # -------- Example ------- class Foo(object): @property def bar(self): return self._bar @bar.setter def setbar(self, x): self._bar = '<%s>' % x # -------- Interactive test ----- >>> foo = Foo() >>> foo.bar = 3 >>> foo.bar '<3>' >>> foo.bar = 'oeufs' >>> foo.bar '' >>> Having fun'ly yours, -- Arnaud From stanc at al.com.au Wed Apr 30 23:21:24 2008 From: stanc at al.com.au (Astan Chee) Date: Thu, 01 May 2008 13:21:24 +1000 Subject: tool to calculate color combination Message-ID: <48193734.4010108@al.com.au> Hi, I was just wondering if there is a tool/script in python that allows me to do color calculations; specifically, when I add them. Also I was thinking that for this to work other than a simple way, some form of measure is included. e.g 50% red(1,0,0) + 50% yellow(1,1,0) = 100% orange(1,0.7,0) Is there such a tool in python? Thanks for any information Astan -- "Formulations of number theory: Complete, Consistent, Non-trivial. Choose two." Animal Logic http://www.animallogic.com Please think of the environment before printing this email. This email and any attachments may be confidential and/or privileged. If you are not the intended recipient of this email, you must not disclose or use the information contained in it. Please notify the sender immediately and delete this document if you have received it in error. We do not guarantee this email is error or virus free. From fetchinson at googlemail.com Sat Apr 26 13:05:36 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Sat, 26 Apr 2008 10:05:36 -0700 Subject: So you think PythonCard is old? Here's new wine in an old bottle. In-Reply-To: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> References: <9028496e-30de-4853-8f57-b55d14e52358@h1g2000prh.googlegroups.com> Message-ID: > > For serveral years, I have been looking for a way to migrate away from > desktop GUI/client-server programming onto the browser based network > computing model of programming. Unfortunately, up until recently, > browser based programs are very limited - due to the limitation of > HTML itself. Eventhough PythonCard hasn't keep up with the latest > widgets in wxpython, the programs so created still works a lot better > - until now. > > If you look at programs at some of the major sites these days - like > Google calendar, Netflix, blockbuster, and so forth - you would > undoubtedly notice that the quality of the programs are pretty much at > par with the desktop programs we use everyday. Since the curious mind > wanted to know how these programs are done, I started investigating > and found out that what a difference a few years have made to > Javascript - the once much hated beast of the Internet age - and > during my search for perfection, I found Qooxdoo (http:// > qooxdoo.org/). > > Qooxdoo is a Javascript toolkit that sits on top of Ajax. Take a look > at some of the *impressive* widgets > at http://demo.qooxdoo.org/current/showcase/#Form. > > So, what's that got to do with Pythoncard? Read on. > > After trying for a few days learning Qooxdoo, my head really really > hurts. Getting too old to learn this stuff, I was mumbling. > > Then I looked some more. I found QxTransformer (http:// > sites.google.com/a/qxtransformer.org/qxtransformer/Home) which is a > XSLT toolkit that creats XML code that invoke qooxdoo. > > So, what's that got to do with Pythoncard? Read on. > > After trying for a few days learning QxTransformer, my head really > really hurts. Getting too old to learn > this stuff, I was mumbling. > > I want Pythoncard. > > Damn Pythoncard! Once you got hooked, everything else looks > impossibly complicated and unproductive. > > But then I looked closer. It turns out the XML file created by > QxTransformer is *very* similar in structure when compared to the > resource files used in PythonCard. Since there are no GUI builders > for QxTransformer, and I can't affort to buy the one for Qooxdoo > (Java! Yuk!), I decided to roll up my sleeves, took the Pythoncard's > Layout Manager and modified it and created my own "Poor Man's Qooxdoo > GUI Layout Designer". > > The result? See the partially completed application at: > > http://test.powersystemadvisors.com/ > > and the same application running from the desktop: > > http://test.powersystemadvisors.com/desktopHelloWorld.jpg > > It shouldn't be long before I can fill in the gaps and have the GUI > builder maps the rest of the Pythoncard widgets to Qooxdoo widgets. > Once I've done that, I can have the same application running from the > desktop, or from the browser. And it shouldn't take more than minutes > to create such applications. > > Welcome to the modernized world of Pythoncard!!! Any reason you chose qooxdoo over ext.js? Cheers, Daniel -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin at v.loewis.de Sun Apr 20 10:59:14 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 20 Apr 2008 16:59:14 +0200 Subject: python setup.py install on Vista? In-Reply-To: References: Message-ID: <480B5A42.1050407@v.loewis.de> > It seems that quite a lot of people wondered why python doesn't set > the environment variable to Python Path in the default installation. For several reasons, one being that it's not needed. Just run setup.py as a program, i.e. don't do python setup.py install but instead do setup.py install Regards, Martin From kamhung.soh at gmail.com Sat Apr 26 05:21:53 2008 From: kamhung.soh at gmail.com (Kam-Hung Soh) Date: Sat, 26 Apr 2008 19:21:53 +1000 Subject: problem with listdir References: Message-ID: On Sat, 26 Apr 2008 19:07:45 +1000, Francesco Bochicchio wrote: > On Sat, 26 Apr 2008 01:24:23 -0700, jimgardener wrote: > >> hi >> i have a directory containing .pgm files of P5 type.i wanted to read >> the pixel values of these files ,so as a firststep i wrote code to >> make a list of filenames using listdir >> >> pgmdir="f:\code\python\pgmgallery" # where i have pgm files >> g2=listdir(pgmdir) >> >> i get the following error >> WindowsError: [Error 123] The filename, directory name, or volume >> label syntax is incorrect: 'f:\\code\\python\pgmgallery/*.*' >> >> i am running python on winXP ..can anyone tell me why i get this >> error? > > Did you try using a raw string as pathname > pgmdir=r"f:\code\python\pgmgallery" > ? > > AFAIK, the character '\' in interpreted in Python as the beginning of > an escape sequence (such as '\n') and it should be doubled ( as in the > error message) or a raw string should be used, telling Python that there > are no escape sequences inside. > However, from the message it looks like the path as been understood as > such, so this might not be the case. > > Ciao > ----- > FB Neither \c nor \p are escape characters in Section 2.4.1 "String literals". Could there be some files in that directory whose name is not a valid Windows file name? Windows file names cannot have the following symbols: \ / : * ? " < > | -- Kam-Hung Soh
Software Salariman From noah at noah.org Wed Apr 9 19:13:58 2008 From: noah at noah.org (Noah) Date: Wed, 9 Apr 2008 16:13:58 -0700 (PDT) Subject: Control process execution References: <1d1bbea2-a503-4db5-bd3f-c45c29916b9c@13g2000hsb.googlegroups.com> <7cb4c5dd-8604-4d18-925c-d6aa17c092b5@24g2000hsh.googlegroups.com> Message-ID: On Apr 9, 1:57 pm, Mike Driscoll wrote: > As far as I know, there is no "os.process". Maybe you meant os.system > or the subprocess module? > > Mike Yeah, I was thinking "subprocess" module. -- Noah From mal at egenix.com Thu Apr 24 13:36:01 2008 From: mal at egenix.com (M.-A. Lemburg) Date: Thu, 24 Apr 2008 19:36:01 +0200 Subject: Installer In-Reply-To: References: Message-ID: <4810C501.2020203@egenix.com> On 2008-04-24 18:39, Chris wrote: > Hey all, > > I've created a python program that relies on pysqlite, wxpython, and > matplotlib. Is there any way of creating an installer that will > install all these modules, python 2.5 and my program? Assuming that you're on Windows, a well-working approach is to wrap up your application using py2exe and then creating an installer using e.g. InnoSetup or NSIS. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Apr 24 2008) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 From ridenour4159 at gmail.com Thu Apr 24 06:17:59 2008 From: ridenour4159 at gmail.com (ridenour4159 at gmail.com) Date: Thu, 24 Apr 2008 03:17:59 -0700 (PDT) Subject: crack xp Message-ID: <7e771bbf-af51-40a3-93f7-ae02a3b31180@w7g2000hsa.googlegroups.com> crack xp http://cracks.12w.net F R E E C R A C K S From kyosohma at gmail.com Thu Apr 10 13:24:31 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Thu, 10 Apr 2008 10:24:31 -0700 (PDT) Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> Message-ID: On Apr 10, 12:05 pm, Michel Bouwmans wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > > > Paul Rubin wrote: > > Chris Stewart writes: > >> I've always had an interest in Python and would like to dabble in it > >> further. I've worked on a few very small command line programs but > >> nothing of any complexity. I'd like to build a really simple GUI app > >> that will work across Mac, Windows, and Linux. How painful is that > >> going to be? I used to be really familiar with Java Swing a few years > >> ago. I imagine it will be similar. > >> ... > >> Next, what would you say is the best framework I should look into? > > > If by "best" you mean "easiest", that is probably tkinter, which > > comes with python. It is somewhat rudimentary and the widgets that > > come with it don't look so great. But if you just want to put up > > GUI's with basic functionality and not much glitz, it is ok for most > > such purposes. > > out how to use > > I don't quite agree with you on this. Tkinter may be easy because it is > available by standard in Python, but that's about it in my opinion. The > API, look and performance hit is horrible. You're much better of with PyQt4 > which makes the job really simple. > > MFB > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.7 (GNU/Linux) > > iD8DBQFH/kjhDpaqHmOKFdQRAj+kAJ0d3aHqpv/mh7kSqtDqUFXtJsxi1gCfU5UP > 2Ygw9ttRIYX+ioMyBVUNsVo= > =stR5 > -----END PGP SIGNATURE----- I see a lot of people recommend using pyQt, but they never mention the controversy that surrounds its licensing. There have been many posts on the subject already, but if the OP ever decides to sell anything they create, I've heard that QT's licensing is kind of squirrelly. Maybe this has been straightened out? I looked at the website and found it fairly confusing. And don't you need to download QT itself? Mike From ivory91044 at gmail.com Tue Apr 29 04:57:16 2008 From: ivory91044 at gmail.com (ivory91044 at gmail.com) Date: Tue, 29 Apr 2008 01:57:16 -0700 (PDT) Subject: cooking up crack Message-ID: <6017abd8-3d95-43dd-a895-07e65410820f@a70g2000hsh.googlegroups.com> cooking up crack http://crack.cracksofts.com From cyberco at gmail.com Tue Apr 15 08:21:54 2008 From: cyberco at gmail.com (Berco Beute) Date: Tue, 15 Apr 2008 05:21:54 -0700 (PDT) Subject: webcam (usb) access under Ubuntu Message-ID: I've been trying to access my webcam using Python, but I failed miserably. The camera works fine under Ubuntu (using camora and skype), but I am unable to get WebCamSpy or libfg to access my webcam. First I tried webcamspy (http://webcamspy.sourceforge.net/). That requires pySerial and pyParallel, and optionally pyI2C. Runing WebCamSpy results in: Exception exceptions.AttributeError: "Parallel instance has no attribute '_fd'" in > ignored This seems to come from importing I2C. The application window opens, but there's an error message: NO VIDEO SOURCE FOUND Next I tried libfg (http://antonym.org/libfg). I built it, made the Python bindings and installed it. Unfortunately the following: >>>import fg >>>grabber = fg.Grabber() results in: fg_open(): open video device failed: No such file or directory Since the camera works fine in Ubuntu itself my guess is that the problem is with the python libraries (or even likelier, my usage of them). Is there anybody here that was successful in accessing their webcam on linux using Python? Else I have to reside to Windows and VideoCapture (which relies on the win32 api and thus is Windows-only), something I'd rather not do. Thanks for any help, 2B =============== I am uUsing: WebCam: Logitech QuickCam Pro 400 Ubuntu Python 2.5 From sjmachin at lexicon.net Fri Apr 18 17:57:09 2008 From: sjmachin at lexicon.net (John Machin) Date: Fri, 18 Apr 2008 21:57:09 GMT Subject: Delete rows using xlrd? In-Reply-To: <8bc243c7-2980-4201-9372-94ca8a49d221@x19g2000prg.googlegroups.com> References: <8bc243c7-2980-4201-9372-94ca8a49d221@x19g2000prg.googlegroups.com> Message-ID: <48091932$1@news.mel.dft.com.au> Krishna wrote: > I want to delete some rows (by creating a loop may be) using xlrd. Is > this possible, No. The "rd" in "xlrd" is an abbreviation for "read". It is possible to read the more basic info from an Excel spreadsheet, manipulate it in memory, and write out the results to a new file using another package e.g. pyExcelerator (or xlwt, a bug-fixed fork of pyEx.*). If you can find in the xlrd README or documentation even the vaguest hint that xlrd can be used by itself for changing the contents of an XLS file, please let me know, and I'll reword it. > if not how do I do that with python? Please help Perhaps you could read the concurrent thread where somebody with a name very similar to yours is getting help on a script that uses the pywin32 COM approach :-) From peter at sd-editions.com Wed Apr 16 23:15:27 2008 From: peter at sd-editions.com (Peter Robinson) Date: Thu, 17 Apr 2008 04:15:27 +0100 Subject: DBXML and removeDocument in Python Message-ID: I am trying to add and remove documents in a container in Berkeley/ Oracle DB XML within Python, on Mac OS X Leopard. putDocument works fine, but I keep getting 'attributeError' when I try removeDocument. I can't find any documentation on removeDocument in Python and it is not in the examples.py. My code looks like: results = p.query('//page[@id="I-57-1r"]' xc = p.getcontainer() xm = p.getxmlmanager() uc = xm.createUpdateContext() if results.hasNext() is True: #delete the document! xc.removeDocument('57-1r', uc) #add a new document with the same name xc.putDocument('57-1r' , ', uc) Put document works fine. I can remove the document using removeDocument from the shell, but not from within Python. Help... Peter Robinson: peter at sd-editions.com Scholarly Digital Editions 12 The Old Silverworks 54a Spencer Street Jewellery Quarter Birmingham B18 6JT fax: 44 (0) 121 275 6212 From nagle at animats.com Fri Apr 18 12:40:41 2008 From: nagle at animats.com (John Nagle) Date: Fri, 18 Apr 2008 09:40:41 -0700 Subject: Installing BeautifulSoup with easy_install (broken?) In-Reply-To: References: Message-ID: <4808cc41$0$34569$742ec2ed@news.sonic.net> Larry Bates wrote: > Info: > > Python version: ActivePython 2.5.1.1 > Platform: Windows > > I wanted to install BeautifulSoup today for a small project and decided > to use easy_install. I can install other packages just fine. > Unfortunately I get the following error from BeautifulSoup installation > attempt: easy_install usually seems to make things harder. BeautifulSoup is one single .py file. That's all you need. Everything else is excess baggage. John Nagle SiteTruth From bruno.desthuilliers at gmail.com Tue Apr 8 15:53:58 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Tue, 8 Apr 2008 12:53:58 -0700 (PDT) Subject: Is the Python for statement the same as for each in other languages? References: <9e8bfedb-dc75-4252-84e7-4fb96bbaa6ac@l64g2000hse.googlegroups.com> <661ps1F2ae3jnU1@mid.uni-berlin.de> Message-ID: <4c3eb03b-68f9-45c6-9513-baab20422e20@s8g2000prg.googlegroups.com> On 8 avr, 19:55, "Diez B. Roggisch" wrote: > jmDesktop schrieb: > > > Thank you. It looks like it is, but I wanted to make sure I > > understood. Also, I didn't see a "regular" for loop construct either > > (i=0;i<=10;i++), etc. I'm still new at it, but is there one of those? > > Yes, it's foreach. And for your usecase, use > > for i in xrange(11): > ... Or if you want to both iterate over an iterable and have the 'loop index', use enumerate: for index, item in enumerate('this is a test'): print index, ' : ', item From hexusnexus at gmail.com Sat Apr 5 17:07:22 2008 From: hexusnexus at gmail.com (hexusnexus at gmail.com) Date: Sat, 5 Apr 2008 14:07:22 -0700 (PDT) Subject: [PyGTK] Drawing PNG Message-ID: <6c012288-0847-48ef-ad6c-eecd455d1ee6@b5g2000pri.googlegroups.com> I have some PNGs with transparent backgrounds. How do I draw them using PyGTK? From gagsl-py2 at yahoo.com.ar Mon Apr 21 00:02:56 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 01:02:56 -0300 Subject: Error Handling References: <4dc0cfea0804171219l7e4c749dpfd13f9bb35294e1a@mail.gmail.com> Message-ID: En Thu, 17 Apr 2008 16:19:12 -0300, Victor Subervi escribi?: > try: > cursor.execute(sql) > print '?Exito en introducir!
' > print 'Esta p?gina va a regresar a la p?gina principal del carrito > de compras en 10 segundos.' > except IntegrityError: > print 'Lo siento, pero el ID que entraste est? usado actualmente por > otra entrada. Favor de dar para atr?z y escojer otro n?mero.' > except OperationalError: > print 'Lo siento, pero has a?adido un car?cter extra?o a un n?mero (o > en "ID", "precio", "rec?maras" o "ba?os". Favor de dar para atr?z y escojer > otro n?mero.' > except: > print 'Lo siento, pero hay un error. Favor de dar para atr?z y > averiguar donde est? el error, y reintentar.' > When I enter and ID that is not a number, it should trigger the > IntegrityError. Instead, I get this in the error log: > > [Thu Apr 17 12:06:37 2008] [error] [client 190.166.0.245] PythonHandler > mod_python.cgihandler: NameError: global name 'IntegrityError' is not > defined, referer: http://livestocksling.com/bre/iud.py Looks like IntegrityError and OperationalError are defined inside your database module. Either use: from my_database_module import IntegrityError, OperationalError try ... except OperationalError: ... except IntegrityError: ... except Exception: ... or else: import my_database_module try ... except my_database_module.OperationalError: ... except my_database_module.IntegrityError: ... except Exception: ... It's the same as any other symbol, like math.sqrt or os.rename Note that I've not used a bare except: clause; it's not a good idea. sys.exit() raises the SystemExit exception, and pressing Ctrl-C raises KeyboardInterrupt; a bare except: will catch them, effectively nullifying the intended purpose. -- Gabriel Genellina From abuse at tpnet.pl Tue Apr 8 06:19:57 2008 From: abuse at tpnet.pl (Soltys) Date: Tue, 08 Apr 2008 12:19:57 +0200 Subject: Looking for Conferences/Events on Django, Python, MySQL, etc in Europe 2008? In-Reply-To: <7fb0f408-1a2e-4ee1-a179-092f83eb1591@8g2000hsu.googlegroups.com> References: <7fb0f408-1a2e-4ee1-a179-092f83eb1591@8g2000hsu.googlegroups.com> Message-ID: > Greetings! > > I'm looking for conferences or events about Python, Django, Dabatases, > Mysql, > PHP, Ruby in Europe (or nearby locations like north africa and middle > east) in 2008. > Do you have any suggestions? > > Thanks a lot! Hello, Every year starting from 2007 in April there's a RuPy (www.rupy.eu) conference in Poznan (Poland). Unfortunately this year's registration has already finished (on April 7th). Nevertheless you could always give it a try and contact organizers :) And of course there's EuroPython in Vilnius (Lithuania), more can be found on http://www.europython.org/community Any other information can be found on http://www.python.org/community/workshops/ Regards, Soltys From steve at holdenweb.com Tue Apr 1 15:37:09 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 01 Apr 2008 15:37:09 -0400 Subject: Why prefer != over <> for Python 3.0? In-Reply-To: <878wzyyqkf.fsf@physik.rwth-aachen.de> References: <5805ee5f-970f-4b16-a5c5-90ebe0748feb@y21g2000hsf.googlegroups.com> <8b05b5f4-b228-4782-97b0-ea0903ce8095@l42g2000hsc.googlegroups.com> <659gb2F2f84eoU2@mid.individual.net> <87hceo73ap.fsf@physik.rwth-aachen.de> <65anbqF2fg18bU1@mid.individual.net> <87r6drjss4.fsf@physik.rwth-aachen.de> <65c0bfF2ffipiU1@mid.individual.net> <878wzyyqkf.fsf@physik.rwth-aachen.de> Message-ID: <47F28EE5.5080506@holdenweb.com> Torsten Bronger wrote: > Hall?chen! > > Jorge Vargas writes: > >> On Tue, Apr 1, 2008 at 6:03 AM, Gabriel Genellina >> wrote: >> >>> [...] >>> >>> I think it should be easy to add support for ??? and even ?, >>> only the tokenizer has to be changed. >>> >> show me a keyboard that has those symbols and I'm all up for it. > > For <= I have to press three buttons, for ? I have to press four > buttons. Not much of a difference. ;-) > > However, I'm slightly disappointed with the UTF-8 support in some > mail clients involved in this thread, so Unicode surely has not > arrived yet. > I'd settle for a program listing utility that made the replacements. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From nospam at nospam.com Fri Apr 4 12:43:36 2008 From: nospam at nospam.com (3c273) Date: Fri, 4 Apr 2008 09:43:36 -0700 Subject: Looking for Advanced Python Tutorials References: <440c1624-ad9d-4038-bce5-68a2b4ed539a@e10g2000prf.googlegroups.com> Message-ID: Thanks for this. Louis "Ravi Kotecha" wrote in message news:440c1624-ad9d-4038-bce5-68a2b4ed539a at e10g2000prf.googlegroups.com... > On Apr 4, 12:58 pm, cokofree... at gmail.com wrote: > > I was wondering if anyone knew of some online (free if possible) > > advanced tutorials, especially ones that provides tasks and ideas for > > small projects. The issue for myself is I want to improve my python > > programming level, and my ability to program in general, but come up > > blank thinking of a possible task or project to undertake. So with > > that in mind I thought I'd ask the community if they knew of sites or > > books to read up on and use as a starting block. Of course project > > ideas would be great as well! > > > > Thanks for any help you can provide. > > > > Coko > > Project Euler is a site where you work through mathematical problems > using any programming language you like. > > Once you solve a problem you can see everyone elses solutions and > Python is quite popular on that site so you'll see some very clever > uses of Python there. > > I like it a lot for when I haven't got anything better to code: > http://projecteuler.net/ > > - Ravi From Lie.1296 at gmail.com Tue Apr 22 04:37:10 2008 From: Lie.1296 at gmail.com (Lie) Date: Tue, 22 Apr 2008 01:37:10 -0700 (PDT) Subject: question about the mainloop References: <52de38c4-3d1e-4be0-9b58-5d60317f1ef7@b1g2000hsg.googlegroups.com> Message-ID: <1d7054fb-672e-4d2d-9dfc-efdccf818353@p25g2000pri.googlegroups.com> On Apr 21, 6:24 am, globalrev wrote: > in C?? java etc there is usually: > > procedure 1 > procedure 2 > procedure 3 > > main { > procedure 1 > procedure 2 > procedure 3 > > } > > i dont get the mainloop() in python. i mean i have written some > programs, for example a calculator using tkinterGUI. > > if i have some functions i wanna call to run the program and i wanna > call them ina specific order and be able to call > them from each other should this just be called in the mainloop and > the mianloop then runs the "mainscript" top > to bottom over and over? In Python+Tkinter (and I believe, all event-driven programming model), the codes you write are all used for setting up the GUI, specifying where they're placed, what happens when they're clicked, etc, etc, etc. And entering the main loop means the event "manager" (a.k.a mainloop) would start checking all the registered events and respond to the event by calling the associated function you determined at the setup. This event "manager" loops itself over and over until it received an event that tells them to stop listening and quit the program (usually binded with the close button). In some event-driven programming model (like in Visual Basic, don't know about Java, never used it), the setup phase is hidden from you and is done automagically by the GUI designer, and when the setup phase finishes (the mainloop is called), the first event that happens is a programhasjuststarted event, which is automagically bound with a startup function, in VB: the Main Form's OnLoad Event or a Main function. From tkpmep at hotmail.com Fri Apr 11 23:09:22 2008 From: tkpmep at hotmail.com (tkpmep at hotmail.com) Date: Fri, 11 Apr 2008 20:09:22 -0700 (PDT) Subject: Rpy - partially blank R window Message-ID: <197eb1a6-8ccd-4d70-8b99-c33d05cf81f7@a1g2000hsb.googlegroups.com> I have just installed R and Rpy, and am experiencing an odd problem when driving R from Python - if I create a plot in R, the portion of the plot window that lies under the IDLE window in which I type my Python code remains blank. So if I type >>> from rpy import * >>> x = range(10) >>> y = [i ** 2 for i in x] >>> r.plot(x,y) I get a plot of y vs. x, but only the top right portion of the plot shows any points, axes etc. The bottom left corner (the portion that lay under the IDLE window) is blank. Is this a known problem?If so, is there a fix? Sincerely Thomas Philips From colas.francis at gmail.com Tue Apr 15 12:25:08 2008 From: colas.francis at gmail.com (colas.francis at gmail.com) Date: Tue, 15 Apr 2008 09:25:08 -0700 (PDT) Subject: use object method without initializing object References: Message-ID: On 15 avr, 17:43, Robert Bossy wrote: > Reckoner wrote: > > would it be possible to use one of an object's methods without > > initializing the object? > > > In other words, if I have: > > > class Test: > > def __init__(self): > > print 'init' > > def foo(self): > > print 'foo' > > > and I want to use the foo function without hitting the > > initialize constructor function. > > > Is this possible? > > Hi, > > Yes. It is possible and it is called "class method". That is to say, it > is a method bound to the class, and not to the class instances. > In pragmatic terms, class methods have three differences from instance > methods: > 1) You have to declare a classmethod as a classmethod with the > classmethod() function, or the @classmethod decorator. > 2) The first argument is not the instance but the class: to mark this > clearly, it is usually named cls, instead of self. > 3) Classmethods are called with class objects, which looks like this: > ClassName.class_method_name(...). > > In your example, this becomes: > > class Test(object): > def __init__(self): > print 'init' > @classmethod > def foo(cls): > print 'foo' > > Now call foo without instantiating a Test: > Test.foo() To be complete, you can also define a static method that will not even be passed the class as argument: In [217]: class Test(object): .....: def __init__(self): .....: print 'init' .....: @staticmethod .....: def foo(): .....: print 'foo' .....: In [218]: Test.foo() foo From tinnews at isbd.co.uk Fri Apr 4 16:43:31 2008 From: tinnews at isbd.co.uk (tinnews at isbd.co.uk) Date: 04 Apr 2008 20:43:31 GMT Subject: Is there any way to say ignore case with "in"? Message-ID: <47f692f3$0$759$bed64819@news.gradwell.net> Is there any way in python to say if string1 in string2: ignoring the case of string1 and string2? I know I could use:- if lower(string1) in lower(string2): but it somehow feels there ought to be an easier (tidier?) way. -- Chris Green From enleverlesX.XmcX at XmclaveauX.com Tue Apr 8 11:56:58 2008 From: enleverlesX.XmcX at XmclaveauX.com (Méta-MCI (MVP)) Date: Tue, 8 Apr 2008 17:56:58 +0200 Subject: List open files In-Reply-To: References: <47fb8d54$0$15068$426a74cc@news.free.fr> Message-ID: <47fb9789$2$881$ba4acef3@news.orange.fr> Hi! > OpenFiles.exe OK, on a standard CPU/windows. On a server, use: Net File @-salutations -- Michel Claveau From dave.l.harrison at gmail.com Thu Apr 10 06:12:02 2008 From: dave.l.harrison at gmail.com (David Harrison) Date: Thu, 10 Apr 2008 20:12:02 +1000 Subject: Sorting Directories from files in a os.listdir?? In-Reply-To: <9354f263-b833-4845-a226-1ad3a47b1e6a@p25g2000pri.googlegroups.com> References: <9354f263-b833-4845-a226-1ad3a47b1e6a@p25g2000pri.googlegroups.com> Message-ID: On 10/04/2008, Soren wrote: > Hi, > > I'd like to read the filenames in a directory, but not the > subdirectories, os.listdir() gives me everything... how do I separate > the directory names from the filenames? Is there another way of doing > this? The only thing I can think of if you just want the immediate dir is to use the os.path module's function isfile to test each item from the list returned by os.listdir. This should do the trick I think: [ f for f in os.listdir('pathname') if os.path.isfile(f) ] cheers Dave From soren.skou.nielsen at gmail.com Tue Apr 29 06:45:27 2008 From: soren.skou.nielsen at gmail.com (Soren) Date: Tue, 29 Apr 2008 03:45:27 -0700 (PDT) Subject: SWIG Python undefined reference References: <23b925ce-cfa5-4a99-bad3-afcac09b645a@y21g2000hsf.googlegroups.com> Message-ID: <462b5bb4-cfa4-4132-8f97-a609da6908df@8g2000hse.googlegroups.com> On Apr 29, 11:31 am, Soren wrote: > Ok I found out how to do it using: > > gcc -Ic:\python24\include -Lc:\python24\libs --shared example_wrap.c > example.c -lpython24 -o _example.pyd > > but now I get a "dynamic module does not define init function" error > when I try to import it into python.. > > Anyone?? > > Soren In case anyone is having the same problem the solution for me was: gcc example.c example_wrap.c -Ic:\python24\include -Lc:\python24\libs - lpython24 -Xlinker -expoert-dynamic -shared -o _example.pyd Soren From Lie.1296 at gmail.com Sun Apr 27 08:38:43 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 27 Apr 2008 05:38:43 -0700 (PDT) Subject: Loading associated files References: <74862697-da58-4eb7-8d60-09aaef54b7ad@j22g2000hsf.googlegroups.com> Message-ID: <09337541-0b3e-4aaf-b26f-06a0f689e7dc@u12g2000prd.googlegroups.com> On Apr 24, 10:14 pm, flarefi... at googlemail.com wrote: > I am trying to make a a simple databasing GUI interface and and have > created a module to deal with parsing the data from a file and a GUI > based program that displays this data using PyQt4, i know how to > register files in the system registry using python and also using Inno > Setup which i use to package my applications, but i cant work out how > if a file is doubled clicked on to send the path of that file to > python. Do you mean: when a file with "your extension" is double clicked on, then Windows should pass the path of that file to "your application" that is written in Python? (snip) On Apr 26, 7:26 pm, flarefi... at googlemail.com wrote: > I can't get this to work (I am on XP SP2 by the way and using Python > 2.5), > > I wrote a very simple script to test the idea: > > import sys > > for arg in sys.argv: > print arg > > raw_input("Done") #Merely to slow the program down so i can see output > > and then setup a file extension .xyz, placed it in the registry, can > get a .xyz file to work as a python script so the registry setup is > fine, but when i try and put the parameter to the above program and a > %1 (or even without) it gets the following error message from windows: > > C:\...\hmm.xyz is not a valid Win32 application. > > any suggestions?? Windows seems to be trying to execute your file.xyz as an application, this means it hasn't associated your extension (.xyz) with your application, instead .xyz is associated as an executable. To associate your extension with your application, see: http://msdn2.microsoft.com/en-us/library/bb776883.aspx It's a bit advanced NOT TESTED: # Create or edit Registry Key: 'HKEY_CLASSES_ROOT\.xyz' # Change the value for the key 'HKEY_CLASSES_ROOT\.xyz:' into 'MyApp' # Create or edit Registry Key: 'HKEY_CLASSES_ROOT\MyApp\Shell\Open \Command' # Change Registry Key value for 'HKEY_CLASSES_ROOT\MyApp\Shell\Open \Command' into: '"C:\pathtomyapp\myapp.py" "%1"' Check an existing registry key, how they do it. From frikker at gmail.com Wed Apr 30 14:14:47 2008 From: frikker at gmail.com (blaine) Date: Wed, 30 Apr 2008 11:14:47 -0700 (PDT) Subject: Simple TK Question - refreshing the canvas when not in focus References: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> <4818349e$0$2959$ba620e4c@news.skynet.be> <182ace66-bdf6-409c-85ee-fd764de8e1c6@z72g2000hsb.googlegroups.com> Message-ID: <5e13015e-af99-4595-9c10-62a2bc42310c@j22g2000hsf.googlegroups.com> On Apr 30, 10:41 am, Peter Otten <__pete... at web.de> wrote: > blaine wrote: > > Still doesn't work. I'm looking into using wx instead... > > > This is the full code - does it work for anyone else? Just do a echo > > 'line 0 0 10 10' > dev.file > > Haven't tried it, but I think that the problem is that you are updating the > UI from the "readthread". A good example to model your app after is here: > > http://effbot.org/zone/tkinter-threads.htm > > Peter I had a feeling thats what the problem is. Thank you for that link - I am in need of a good model. Thanks for answering both of my questions today, Peter. :) -Blaine From stef.mientki at gmail.com Fri Apr 11 17:39:19 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Fri, 11 Apr 2008 23:39:19 +0200 Subject: How is GUI programming in Python? In-Reply-To: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> Message-ID: <47FFDA87.3070703@gmail.com> Rune Strand wrote: > On Apr 10, 3:54 am, Chris Stewart wrote: > ... > >> Next, what would you say is the best framework I should look into? >> I'm curious to hear opinions on that. >> > > GUI-programming in Python is a neanderthal experience. What one may > love with console scripts is turned upside-down. Projects like Boa > Constructor seemed to be a remedy, but is not developed. The Iron- > Pythonistas has a very promising RAD GUI-tool in the IronPython - > Studio, http://www.codeplex.com/IronPythonStudio - but if you're non- > Iron, only sorrow is left - unless you fancy creating GUI in a text- > editor. Something I consider waste of life. > > Although not as simple as Delphi, wxPython is still quit simple: GUI = """ self.Splitter_Plots ,SplitterVer self.Panel ,PanelVer, 010 self.Panel_Top ,PanelHor, 11 label1 ,wx.StaticText ,label = "Signal1" label2 ,wx.StaticText ,label = "Signal2" self.Panel_X ,wx.Panel, 11 self.Panel_Bottom ,PanelHor label11 ,wx.StaticText ,label = "Signal1b" label12 ,wx.StaticText ,label = "Signal2b" Panel_B ,wx.Panel Button_1 ,wx.Button ,label = "Test" Button_2 ,wx.Button ,label = "Test2", pos = (100,0) """ exec ( Create_wxGUI ( GUI ) ) cheers, Stef From wongjoekmeu at yahoo.com Fri Apr 25 16:42:17 2008 From: wongjoekmeu at yahoo.com (wongjoekmeu at yahoo.com) Date: Fri, 25 Apr 2008 13:42:17 -0700 (PDT) Subject: display monochromatic images wxPython Message-ID: <43c2ef33-b08c-4161-b170-16ab346628d7@m36g2000hse.googlegroups.com> Dear All, I want to write a GUI program with wxPython displaying an image. But the image I have is monochromatic. When I retrieve the data from the image I end up with a list of integer. Starting from a list of integer and knowing the width and height of the image, how do I display such an image on a wx panel or frame ? I have had a look at the wxPython demo but there I see only images where the data is a list of tuple consisting of r,g ,b values. Is there are function where I directly can input the list of array and let it display the image ? Thanks in advance RR From rpmuller at gmail.com Sat Apr 19 16:51:25 2008 From: rpmuller at gmail.com (Rick Muller) Date: Sat, 19 Apr 2008 13:51:25 -0700 (PDT) Subject: Frame work for simple physics web applications References: <2b0b8b6c-8086-4bf6-8f47-27bc5c9c788c@v23g2000pro.googlegroups.com> <6bdd161d-6e92-4de6-8dba-d5c11b08990f@a22g2000hsc.googlegroups.com> Message-ID: On Apr 19, 2:44 pm, globalrev wrote: > > www.vpython.orgmight be what you are looking for. Except, if I'm not mistaken, vpython isn't a web framework. It would work if I wanted to write some python scripts and have other people run them, but I want to run everything through a web page, so I don't have to worry about installing python on everyone's computer and distributing updates of all of my scripts. From ferrarinikap at gmail.com Thu Apr 17 09:42:29 2008 From: ferrarinikap at gmail.com (ferrarinikap at gmail.com) Date: Thu, 17 Apr 2008 06:42:29 -0700 (PDT) Subject: ***CABONGA*** Message-ID: <79292f68-bc67-4b5b-ba9b-d536ff8a4580@d1g2000hsg.googlegroups.com> ****CABONGA*** Listen the amazing Cabong's song!!! http://lacabonga.splinder.com/ From steve at holdenweb.com Fri Apr 25 00:01:33 2008 From: steve at holdenweb.com (Steve Holden) Date: Fri, 25 Apr 2008 00:01:33 -0400 Subject: Remove old version before upgrade? In-Reply-To: References: Message-ID: Sal wrote: > I'm currently running Windows version 2.5.1 and would like to upgrade > to 2.5.2. My question is, can I just go ahead and install the new > version over the old or should I remove the old version with add/ > remove programs first? The old version is in a directory named > Python25. You can do either. Since there's no change of major version the executable will have the same path, and the deinstall handily leaves all files that weren't part of the original install in place. So if it suits your sense of neatness, by all means deinstall before reinstallation. Note that this *doesn't* work for (say) 2.4 to 2.5, since they can coexist. In that case normally the most recently installed version will be the default. I had a Windows system a while back with 2.1 through 2.5 installed, and 2.4 as the default. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From gherron at islandtraining.com Wed Apr 16 11:43:42 2008 From: gherron at islandtraining.com (Gary Herron) Date: Wed, 16 Apr 2008 08:43:42 -0700 Subject: Image handling - stupid question In-Reply-To: <0001HW.C42BCC38001425DCB04379AF@news.individual.de> References: <0001HW.C42B9FB90009B7E8B01AD9AF@news.individual.de> <0001HW.C42BCC38001425DCB04379AF@news.individual.de> Message-ID: <48061EAE.7050007@islandtraining.com> Jumping Arne wrote: > On Wed, 16 Apr 2008 12:21:13 +0200, Jumping Arne wrote > (in article <0001HW.C42B9FB90009B7E8B01AD9AF at news.individual.de>): > > >> I'm going to try to write some imange manipulation code (scaling, reading >> EXIF and IPTC info) and just want to ask if PIL is *THE* library to use? >> >> I looked at and noticed that the >> latest version is from Dec 2006. >> >> In my experience that means that either it's abandoned or that it's very good >> > > >> and stable. >> >> > > Sounds like PIL is a safe option, thanks. > Yes, certainly, PIL is the way to go. But beyond that, if you are going to do any fancy manipulation of the array of pixels (e.g., image processing, image recognition, convolution, ...), then I'd recommend numpy for the array manipulation. (And perhaps even the full-blown scipy.) Numpy can easily access and manipulate the pixel arrays produced by PIL. It's an awesome combination. Gary Herron From x31equsenet at gmail.com Sat Apr 19 06:13:19 2008 From: x31equsenet at gmail.com (Graham Breed) Date: Sat, 19 Apr 2008 03:13:19 -0700 (PDT) Subject: Python 2.5 adoption References: <4808f30e$0$34489$742ec2ed@news.sonic.net> <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> Message-ID: On Apr 19, 3:16 am, Joseph Turian wrote: > Basically, we're planning on releasing it as open-source, and don't > want to alienate a large percentage of potential users. How about Java users? Jython was recently at 2.2 (still is for all I know). I'm pleased they've got that far because I like to know that my code can run under Java and I like generators. My web host uses 1.5.2. That is painful. If you're assuming your potential users already have 2.4 then the chances are they'll have upgraded to 2.5 by the time you've finished anyway. Graham From paddy3118 at googlemail.com Tue Apr 1 15:02:39 2008 From: paddy3118 at googlemail.com (Paddy) Date: Tue, 1 Apr 2008 12:02:39 -0700 (PDT) Subject: deleting a line from a file References: <13usb5ngt26qv26@corp.supernews.com> <7xy781zqkq.fsf@ruckus.brouhaha.com> Message-ID: On Apr 1, 6:32 pm, Mark Wooding wrote: > Paddy wrote: > > Why not use the fileinput modules functionality to iterate over a file > > in-place,printing just those lines you want? > > From the Python 2.5 manual: > > : *Optional in-place filtering:* if the keyword argument `INPLACE=1' is > : passed to `input()' or to the `FileInput' constructor, the file is > : moved to a backup file and standard output is directed to the input > : file (if a file of the same name as the backup file already exists, it > : will be replaced silently). > > This behaviour is very dangerous. If the script fails half-way through, > it will leave the partially-written file in place, with the `official' > name. The change-over is not atomic, breaking other programs attempting > to read simultaneously with an update. I've used this methodology all the time both explicitely writing utilities like that and using 'perl -p -i -e ...' theoretically there may be problems. In practice I have people transforming files in their own workarea, and have never been called to clear-up after such a failing. Although theoretically you can describe a method of failure, I take issue with you calling it 'very dangerous' without further qualification. > > Two almost-simultaneous updates will corrupt the file without a usable > backup. The first will back up the input file, and start writing. A > second will /replace/ the backup file with the partially-constructed > output of the first, and then start processing it; but since its input > is incomplete, it will produce incomplete output. Ahah - the qualification. The above would be dangerous, but the OP may find that his current flow, or a slight modification of it will make simultaneous updates unlikely and use of fileinput OK. If not, then other methods may have to be employed. It _is_ good to know the threat and do the analysis though. - Paddy. From gnewsg at gmail.com Sun Apr 6 10:50:41 2008 From: gnewsg at gmail.com (Giampaolo Rodola') Date: Sun, 6 Apr 2008 07:50:41 -0700 (PDT) Subject: RELEASED Python 2.6a2 and 3.0a4 References: <47F68547.1040802@v.loewis.de> Message-ID: On 6 Apr, 00:55, John Machin wrote: > On Apr 5, 5:45 am, "Martin v. L?wis" wrote: > > > > The Windows x86 MSI installer is missing for both 2.6 and 3.0. > > > And likely will continue to do so for some time. > > Someone's got strange definitions of "missing"! > > For each there's a link on the the ptyhon.org website, and a caveat > about non-Administrator installation ... > > If it's missing, then what do I expect to find in the 11.7Mb 2.6a2 msi > that is downloading as I type? At the time I replied they were both missing (in fact that's why I replied :-)). --- Giampaolo http://code.google.com/p/pyftpdlib From Dodin.Roman at gmail.com Fri Apr 25 07:24:51 2008 From: Dodin.Roman at gmail.com (hellt) Date: Fri, 25 Apr 2008 04:24:51 -0700 (PDT) Subject: Little novice program written in Python References: Message-ID: <2caefd7f-dd6b-40a0-877f-3f7df0e70138@8g2000hse.googlegroups.com> On 25 ???, 15:02, Max M wrote: > Rog?rio Brito skrev: > > > Hi, All. > > > What I would like is to receive some criticism to my code to make it > > more Python'esque and, possibly, use the resources of the computer in a > > more efficient way (the algorithm implemented below is the Sieve of > > Eratosthenes): > > I agree with the rest here. Your code generally looks fine. > > But on another note, this type of code is not something you often see in > Python. It is very dense with regard to algorithm. > > Most code is not like that so perhaps you should try something more > "usual" like sending email, fetching webpages etc. to get a feel for the > language. > > -- > > hilsen/regards Max M, Denmark > > http://www.mxm.dk/ > IT's Mad Science em, i would say, that python (esp. with NumPy+Psyco) is very popular in numerical processing also. From s0suk3 at gmail.com Thu Apr 17 13:26:51 2008 From: s0suk3 at gmail.com (s0suk3 at gmail.com) Date: Thu, 17 Apr 2008 10:26:51 -0700 (PDT) Subject: Can't do a multiline assignment! References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> Message-ID: On Apr 17, 12:07 pm, Sion Arrowsmith wrote: > wrote: > >In Python, you usually can use parentheses to split something over > >several lines. But you can't use parentheses for an assignment of > >several lines. > > Yes you can, you just need an iterable of the right length on > the other side for the tuple unpacking to work: > > >>> (CONSTANT1, > > ... # This isn't a syntax error > ... CONSTANT2, > ... CONSTANT3, #and neither is this > ... CONSTANT) = [1] * 4>>> [ (k, v) for k, v in locals().items() if k.startswith("CONSTANT") ] > > [('CONSTANT', 1), ('CONSTANT1', 1), ('CONSTANT3', 1), ('CONSTANT2', 1)] > That's not the same kind of multiple assignment. There, you're just unpacking several items from a sequence into several variables on the left. Some would say that's a list assignment. From steve at holdenweb.com Sat Apr 12 00:43:54 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 12 Apr 2008 00:43:54 -0400 Subject: How is GUI programming in Python? In-Reply-To: References: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> Message-ID: Rune Strand wrote: > On Apr 11, 8:35 pm, Steve Holden wrote: >> wxDesigner. > > Yeah, but it's like Heron of Alexandria's Aeolipile compared to the > steam engine of James Watt. > > IMHO, GUI with Python is pain, pain and utter pain. Even boring and > meaningless pain. IMHO you are a troll, troll, and utter troll. Even boring and meaningless troll. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From steve at holdenweb.com Tue Apr 8 17:33:45 2008 From: steve at holdenweb.com (Steve Holden) Date: Tue, 08 Apr 2008 17:33:45 -0400 Subject: new user needs help! In-Reply-To: <47FBDA77.1030009@tim.thechases.com> References: <16571823.post@talk.nabble.com> <47FBDA77.1030009@tim.thechases.com> Message-ID: <47FBE4B9.4030705@holdenweb.com> Tim Chase wrote: >> f = open("/tmp/data.txt", 'w') >> >> will open that file. >> >> You can throw the first line away with >> >> headings = f.next() >> >> Then you can loop over the rest with >> >> for name, aa, topo, access, dssp, stride, z in file: >> # >> # Then process each line here > > > Small caveat here...Steve changed file-variables on you here, and > assumed a tuple-unpacking that won't work. You'll want something like > > for line in f: > (name, aa, topo, access, dssp, stride, z) = ( > line.rstrip('\n').split('\t') > # process the line here > > I don't know how your fields are delimited, whether by spaces or tabs. > In the above code, I split by tabs, but you can just use .split() if it > should be split on any white-space. It's a bit more complex if you need > to split by column-offsets. > Hmm, perhaps I shoudl wait until I get my brain fixed before I post again! Sorry, Tim, I got distracted and shouldn't have tried to dash off the post before coping with the distraction. Just a minor flood in the basement ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From webograph at eml.cc Sun Apr 27 17:13:20 2008 From: webograph at eml.cc (webograph) Date: Sun, 27 Apr 2008 23:13:20 +0200 Subject: Why can't timedeltas be divided? In-Reply-To: <4814b7c7$0$30314$9b622d9e@news.freenet.de> References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> <48142747$0$20906$9b622d9e@news.freenet.de> <4814b7c7$0$30314$9b622d9e@news.freenet.de> Message-ID: <4814EC70.5000304@eml.cc> On 2008-04-27 19:28, Martin v. L?wis wrote: > Post a patch to bugs.python.org, optionally also post a message > referring to that patch to python-dev. i've created an issue at [1]. let's hope for the best! thanks for your support webograph [1] http://bugs.python.org/issue2706 From jeremy.wagner at laposte.net Thu Apr 17 12:52:45 2008 From: jeremy.wagner at laposte.net (=?ISO-8859-1?Q?J=E9r=E9my_Wagner?=) Date: Thu, 17 Apr 2008 18:52:45 +0200 Subject: How to know if a module is thread-safe Message-ID: <4807805b$0$884$ba4acef3@news.orange.fr> Hi, I recently tried to use the subprocess module within a threading.Thread class, but it appears the module is not thread-safe. What is the policy of python regarding thread-safety of a module ? From rodmena.com at gmail.com Fri Apr 25 00:48:37 2008 From: rodmena.com at gmail.com (Farsheed Ashouri) Date: Thu, 24 Apr 2008 21:48:37 -0700 (PDT) Subject: wxpython and IEHtmlWindow, Focus Problem. Message-ID: Hi everyone. I create a little browser with wxpython and IEHtmlWindow. But I have a little problem here. When I press enter in the html page, The focus goes to another panel. Why this happens? I want to load a html page and it have textares and user should able to press enter inside html page. This is the code for creating it: #===================Code Begin ========================== class PageOne(wx.Panel): def __init__(self, parent): wx.Panel.__init__( self, parent, -1, style=wx.TAB_TRAVERSAL|wx.CLIP_CHILDREN| wx.NO_FULL_REPAINT_ON_RESIZE ) self.sizer = wx.BoxSizer(wx.HORIZONTAL) import wx.lib.iewin as iewin a = iewin.IEHtmlWindow(self, -1 ) #a.LoadUrl('file:///E:/Ducuments/EL%20Software%20Project/ mainSoft/xmlParser/HTML/learn/less2.html') self.sizer.Add(a, 3, wx.EXPAND,1) self.SetSizer(self.sizer) #self.Bind(wx.EVT_TEXT_ENTER , self.OnKeyPress, a) config.CurrentNotebook = a #===================Code End========================== Thanks in advance. From mfb.chikazuku at gmail.com Sun Apr 13 05:09:31 2008 From: mfb.chikazuku at gmail.com (Michel Bouwmans) Date: Sun, 13 Apr 2008 11:09:31 +0200 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <47ff8489$0$6841$2d805a3e@textnews.eweka.nl> <48010fe5$0$6840$2d805a3e@textnews.eweka.nl> <87ve2mx5nb.fsf@physik.rwth-aachen.de> Message-ID: <4801dc1c$0$6840$2d805a3e@textnews.eweka.nl> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Torsten Bronger wrote: > Hall?chen! Und auch ein hallo, aus den Niederlanden! :P > Michel Bouwmans writes: > >> Gabriel Genellina wrote: >> >>> Michel Bouwmans escribi?: >>> >>>> Gabriel Genellina wrote: >>>> >>>>> Another annoying thing with the Qt license is that you have to >>>>> choose it at the very start of the project. You cannot develop >>>>> something using the open source license and later decide to >>>>> switch to the commercial licence and buy it. >>>> >>>> Unless you're a company with a risk of being checked for legal >>>> software etc., you can always ignore that allthough not very >>>> legal. >>> >>> I just ignore Qt itself. >> >> Then you're ignorant. What do you prefer than? > > Well ... don't expect answers that you like when you suggest doing > something which is not allowed. > >> [...] >> - WxPython is terribly unstable. > > I can't confirm that. When I chose wxPython after thorough > consideration one year ago, my impression was that reports of > instability were indeed frequent but rather old. Apparently, the > situation had improved. Does your experience rely on recent use? > > Tsch?, > Torsten. > About half a year/a year ago. Segfaults is simply not something I like to see when I use an API binding. For me it didn't feel that right when using it so I made the temporary switch to Tkinter. greetz MFB -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFIAc3PDpaqHmOKFdQRAi3PAJ4idF7KLdOQfpfARBjA839wyKBQAQCcDIMA GX41PYj5t+ap8nEwkWRtb4Q= =LTVd -----END PGP SIGNATURE----- From willem at stack.nl Mon Apr 14 08:13:20 2008 From: willem at stack.nl (Willem) Date: Mon, 14 Apr 2008 12:13:20 +0000 (UTC) Subject: Game design : Making computer play References: Message-ID: Richard wrote: ) Here's the board (which bears only a slight resemblance to one I'd seen on ) the Web): ) ) +---------------+ ) | HORN $ | ) +---+---+---+---+---+---+ ) |L W| | $ | $ | |R W| ) +E-I+--CHEST+---+---+I-I+ ) |F N| | | | |G N| ) +T-G+---+---+---+---+H-G+ ) | | | | | |T | ) +---+---+---+---+---+---+ ) | LEGS| | | ) +---+---+---+---+ ) ) There are three tigers and fifteen goats. ) The tigers' goal is to eat all the goats and remain mobile. ) It seems that the initial tiger positions are: one on the horn, and one ) each on CHEST-2 and CHEST-3 (see $ marks, above). ) The goats' goal is to block the tigers from moving. ) The goats are placed one by one. ) Tigers appear only to be able to move orthogonally (up/down/left/right) - ) although they can use the horn to whizz across the chest (e.g. CHEST-1 to ) HORN, HORN to CHEST-4, in two moves). ) The rest of the rules are beyond me, I'm afraid. It's not clear how tigers ) eat goats or how goats block tigers. If it's similar to the 'other' goats and tigers game, a tiger eats a goat by jumping over it, for which the square behind it needs to be empty, obviously. SaSW, Willem -- Disclaimer: I am in no way responsible for any of the statements made in the above text. For all I know I might be drugged or something.. No I'm not paranoid. You all think I'm paranoid, don't you ! #EOT From j.foster.davis at gmail.com Wed Apr 2 19:09:34 2008 From: j.foster.davis at gmail.com (Jacob Davis) Date: Wed, 2 Apr 2008 16:09:34 -0700 Subject: Module not found in script that was found in command-line interpreter. Possible Path issue? Message-ID: <8463F6F2-4C02-48BC-BF7E-B606D4B41577@gmail.com> Hi. I just installed the MySQLdb module and I have been able to get it to run in my command line interpreter. I am running Mac Leopard, and Python 2.5. I have tested importing and actually connecting and using a MySQL database, although it issues some warning: SnakeBite:MySQL-python-1.2.2 Snake$ python Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import MySQLdb /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site- packages/MySQL_python-1.2.2-py2.5-macosx-10.3-fat.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /Library/ Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/ MySQL_python-1.2.2-py2.5-macosx-10.3-fat.egg/_mysql.pyc, but /Library/ Python/MySQL-python-1.2.2 is being added to sys.path import sys, pkg_resources, imp >>> However, while writing a .py script (with Komodo Edit) I try to simply import the module and the in-Komodo interpreter returns an error: Traceback (most recent call last): File "/Users/Snake/Documents/NPS/Thesis/Source_Code/Genetics/ mysql_connect_test.py", line 11, in import MySQLdb ImportError: No module named MySQLdb This script does, however, run fine when I call it from the command- line interpreter. I don't really know much about Paths or anything, all I Know is that to get Komodo to run my Python scripts, I had to tell it that an interpreter is located at /usr/bin/pythonw My goal is to use Komodo (or some simple IDE with syntax checking, and function hinting, and an embedded interpreter - so if you know of any others for Mac Leopard) to write and debug scripts. -Jake # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # >>>>> # >>>>> This file tests the connection to a mysql database ("gene_test") on localhost:3306 # >>>>> it gets all of the data from the table "3_weeks" and prints it # >>>>> # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> # import MySQL module import MySQLdb # connect db = MySQLdb.connect(host="localhost", user="customer", passwd="customer", db="gene_test") # create a cursor cursor = db.cursor() # execute SQL statement cursor.execute("SELECT * FROM 3_weeks") # get the resultset as a tuple result = cursor.fetchall() # iterate through resultset for record in result: print record[0] , "-->", record[1] -------------- next part -------------- An HTML attachment was scrubbed... URL: From sbergman27 at gmail.com Thu Apr 17 13:29:48 2008 From: sbergman27 at gmail.com (Steve Bergman) Date: Thu, 17 Apr 2008 10:29:48 -0700 (PDT) Subject: Python module for reading FilePro files? References: Message-ID: <3cfb3411-59e6-411c-99ec-494a15d1d6ef@m71g2000hse.googlegroups.com> Thanks. Yes, there is a php-filepro extension that I could hook up with using the command line interpreter. That may well be what I end up doing. Or maybe port the php extension to python. From gagsl-py2 at yahoo.com.ar Mon Apr 14 05:59:12 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 14 Apr 2008 06:59:12 -0300 Subject: text adventure game problem References: <4fb4fb0d-4cb2-4fcd-a207-a0341d92e82b@8g2000hsu.googlegroups.com> <7e1c3f97-ff17-4add-8d45-40f7b48dec4a@l64g2000hse.googlegroups.com> <17342e68-2593-43cc-aff0-af0e09e75d6d@a22g2000hsc.googlegroups.com> Message-ID: En Fri, 11 Apr 2008 11:21:17 -0300, escribi?: > On Apr 11, 10:16?am, corvettecra... at gmail.com wrote: >> On Apr 11, 1:40?am, Dennis Lee Bieber wrote: >> >> > On Thu, 10 Apr 2008 05:06:42 -0700 (PDT), corvettecra... at gmail.com >> > declaimed the following in comp.lang.python: >> >> > > okay, that explains it... >> > > could you provide a working example of a two-room game using your >> > > method please so I can understand it better? Thanks in advance! >> >> > ? ? ? ? Okay... It isn't the best thought out system -- I have >> too >> > many specific classes... It would probably be better to put actions >> into >> > dictionaries and use some custom .getattr() to handle them. >> > # >> > # ? TAGS.py ? ? Text Adventure Game Shell >> > # >> >> > # ? I've probably defined too many special classes here >> > class Gobject(object): ?#Game object >> > ? ? def __init__(self, name, description, hidden=False, fixed=True): >> > ? ? ? ? self._name = name >> > ? ? ? ? self._description = description >> > ? ? ? ? self.hidden = hidden ? #hidden objects are not visible to >> > EXAMINE >> I still can't run that....after fixing the simple stuff like 'invalid >> syntax', there's the "Name examine is not defined." >> So... You will have to manually fix the long lines that were splitted/wrapped by the mailer program. As a rule-of-thumb, try joining any line (inside a function or class) that you see over the left margin, onto the previous line. By example, the EXAMINE word above should be the last word on its previous line, in fact it's part of the comment. -- Gabriel Genellina From meisnernel73884 at gmail.com Wed Apr 30 06:36:30 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:36:30 -0700 (PDT) Subject: cracks and keygens Message-ID: <6c924404-958e-4abd-a345-1fe72fd60ac5@34g2000hsf.googlegroups.com> cracks and keygens http://crack.cracksofts.com From hexusnexus at gmail.com Wed Apr 2 21:05:38 2008 From: hexusnexus at gmail.com (hexusnexus at gmail.com) Date: Wed, 2 Apr 2008 18:05:38 -0700 (PDT) Subject: Classes in modules Message-ID: <0cace2e1-6dbc-428f-9e53-ffb99ba42aab@e6g2000prf.googlegroups.com> I'm trying to get this source code split into multiple files: http://pygermanwhist.googlecode.com/files/pygermanwhist.12.py I've been trying to make so that I have one class per file for easier readability. My problem is that the interpreter keeps saying that it can't find methods and so forth whenever I try to split the code up. This has been a recurring problem for me in languages such as C++ and Java. I'm used to programming in C. From xdicry at gmail.com Fri Apr 11 05:32:52 2008 From: xdicry at gmail.com (Evan) Date: Fri, 11 Apr 2008 02:32:52 -0700 (PDT) Subject: How to make a "command line basd" interactive program? Message-ID: Hope this hasn't been posted hundreds of times. I'm new for this. Before using python for this kind of script, I was using TCL to write down a "command line based" interactive program. it likes a "tclsh", or "python" command, after that, you can work under a prompt, for example, " - >> ", and then you can execute any commands what you defined in script. Now, in python, are there any common way(class) to finish this work? or does anybody has a example to do that? Thanks, Evan From bvidinli at gmail.com Thu Apr 10 06:45:35 2008 From: bvidinli at gmail.com (bvidinli) Date: Thu, 10 Apr 2008 13:45:35 +0300 Subject: urgent question, about filesystem-files In-Reply-To: <6665rfF2j5ohkU1@mid.uni-berlin.de> References: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> <47FDD27E.1040204@islandtraining.com> <36e8a7020804100200m6c3a9a41h1ed3021b70f8a829@mail.gmail.com> <36e8a7020804100201x5cf16377gfedddc8647fe8e3a@mail.gmail.com> <6665rfF2j5ohkU1@mid.uni-berlin.de> Message-ID: <36e8a7020804100345o3af2f622y6c477f1f6a31dd30@mail.gmail.com> * i do not want to prevent other process access same file, i only want if a file being used as i acess it. * i am not interested if a process will access same file just after i access it... because in my case, this is not possible.. * i want some other way, other than linux lsof command. it is slow for me. is there a native python way, ? thanks. 2008/4/10, Diez B. Roggisch : > bvidinli wrote: > > > this is for ensuring that file is not in use, ... > > by any process in system.... > > > How do you prevent the other processes that *might* access that file from > doing so while *you* work on it? unless they cooperate using file-locks, > you might end up with garbage. > > Diez > > -- > http://mail.python.org/mailman/listinfo/python-list -- ?.Bahattin Vidinli Elk-Elektronik M?h. ------------------- iletisim bilgileri (Tercih sirasina gore): skype: bvidinli (sesli gorusme icin, www.skype.com) msn: bvidinli at iyibirisi.com yahoo: bvidinli +90.532.7990607 +90.505.5667711 From tdimson at gmail.com Wed Apr 2 11:13:16 2008 From: tdimson at gmail.com (Thomas Dimson) Date: Wed, 2 Apr 2008 08:13:16 -0700 (PDT) Subject: Self-referencing decorator function parameters References: <88b2c61e-8cf1-4ac0-a5d4-c968d009b544@c65g2000hsa.googlegroups.com> <232b144b-9e09-4baf-9e87-88b6a1d1fb07@b5g2000pri.googlegroups.com> Message-ID: <80ffac0f-baa3-46ac-8157-fa123e2bee9e@8g2000hse.googlegroups.com> On Apr 2, 10:31?am, George Sakkis wrote: > On Apr 2, 8:30?am, Thomas Dimson wrote: > > > > > > > Hello, > > > Originally I posted this as a bug but it was shot down pretty quickly. > > I am still mildly curious about this as I'm missing a bit of > > understanding of Python here. Why is it that the following code > > snippet: > > > def decorator( call ): > > ? ? def inner(func): > > ? ? ? ? def application( *args, **kwargs ): > > ? ? ? ? ? ? call(*args,**kwargs) > > ? ? ? ? ? ? func(*args,**kwargs) > > ? ? ? ? return application > > > ? ? return inner > > > class DecorateMe: > > ? ? @decorator( call=DecorateMe.callMe ) > > ? ? def youBet( self ): > > ? ? ? ? pass > > > ? ? def callMe( self ): > > ? ? ? ? print "Hello!" > > > DecorateMe().youBet() > > > Will not compile, giving: > > Traceback (most recent call last): > > ? File "badpython.py", line 10, in > > ? ? class DecorateMe: > > ? File "badpython.py", line 11, in DecorateMe > > ? ? @decorator( call=DecorateMe.callMe ) > > NameError: name 'DecorateMe' is not defined > > > Where if you change the "call=DecorateMe.callMe" to "call=lambda x: > > DecorateMe.callMe(x)" everything goes along its merry way. Nesting the > > call in a lambda seems to allow it to recognize the class definition. > > Any ideas as to what is going on here (other than ugly code)? > > The error message is pretty obvious; when the > "@decorator(call=DecorateMe.callMe)" line is reached, the DecorateMe > class has not been created yet, let alone the DecorateMe.callMe > method. One way to make it work (for some definition of "work" ;-) is > the following: > > # use "new-style" classes unless you have a good reason not to: > # class DecorateMe(object): > class DecorateMe: > > ? ? def callMe(self): > ? ? ? ? print "Hello!" > > ? ? @decorator(call=callMe) > ? ? def youBet(self): > ? ? ? ? pass > > The reason this works is that at the point where @decorator is > executed, callMe is already in the temporary namespace to be used for > creating the DecorateMe class (although the class itself is not built > yet). > > A subtle point is that in this case callMe is a plain function, not an > (unbound) method such as DecorateMe.callMe. This may or may not > matter, depending on what you do with it in the decorator. Some > decorators that work fine with plain functions break if they are used > to decorate methods (or vice versa) so it's good to have this in mind > when writing or debugging a decorator. > > George- Hide quoted text - > > - Show quoted text - Thanks George, that was helpful. I guess my real question is: why does wrapping the call to be "call=lambda x: DecorateMe.callMe(x)" somehow fix the issue with this temporary namespace? It seems strange to me that defining an additional function (through lambda) would allow me to see/add more members to the namespace. From victorsubervi at gmail.com Tue Apr 29 14:14:34 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Tue, 29 Apr 2008 13:14:34 -0500 Subject: Colors for Rows In-Reply-To: <20080429121105.f10c3862.darcy@druid.net> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> <20080429121105.f10c3862.darcy@druid.net> Message-ID: <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> On Tue, Apr 29, 2008 at 11:11 AM, D'Arcy J.M. Cain wrote: > On Tue, 29 Apr 2008 09:33:32 -0500 > "Victor Subervi" wrote: > > why doesn't this work? > > First, let me remove some blank lines to reduce scrolling. > > > z = 3 > > > > for d in (1,2,3,4,5,6): > > I changed id to a sequence so that the example actually runs. Please > run your examples first and cut and paste them into the message after > you are sure that it runs. Not sure what you mean here. The example runs. It prints out every time. > > > > z += 1 > > > > if z % 4 == 0: > > bg = '#ffffff' > > elif z % 4 == 1: > > bg = '#d2d2d2' > > elif z % 4 == 2: > > bg = '#F6E5DF' > > else: > > bg = '#EAF8D5' > > > > try: > > print '\n' % bg > > except: > > print '\n' > > > > It never increments z! Yet, if I print z, it will increment and change > the > > bgcolor! Why?! > > I am not entirely sure what you are trying to do here. First, what > error condition are you expecting in your try statement. Second, don't > you want the print clause, with or without the try/except, in the > loop. I assume that you want to print a line for each member of your > sequence in alternating colours but this only prints for the last one. > Try this: > > z = 3 > > for d in (1,2,3,4,5,6): > z += 1 > > if z % 4 == 0: > bg = '#ffffff' > elif z % 4 == 1: > bg = '#d2d2d2' > elif z % 4 == 2: > bg = '#F6E5DF' > else: > bg = '#EAF8D5' > > print '' % bg, d Huh? You?re asking for one variable, then giving two! How?s that work? > > > Or, tell us what you are trying to do. I think you understand. I want the row color to alternate, every fourth row color being the same (or a series of 4) > > > In fact, you can replace all the tests and the print statement with > this after defining bg as a list of the four colours: > > print '' % bg[z % 4], d I tried that just for fun. It gave a bg of ?f?. Again, how are you incorporating d? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From darcy at druid.net Tue Apr 29 12:11:05 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Tue, 29 Apr 2008 12:11:05 -0400 Subject: Colors for Rows In-Reply-To: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> Message-ID: <20080429121105.f10c3862.darcy@druid.net> On Tue, 29 Apr 2008 09:33:32 -0500 "Victor Subervi" wrote: > why doesn't this work? First, let me remove some blank lines to reduce scrolling. > z = 3 > > for d in (1,2,3,4,5,6): I changed id to a sequence so that the example actually runs. Please run your examples first and cut and paste them into the message after you are sure that it runs. > z += 1 > > if z % 4 == 0: > bg = '#ffffff' > elif z % 4 == 1: > bg = '#d2d2d2' > elif z % 4 == 2: > bg = '#F6E5DF' > else: > bg = '#EAF8D5' > > try: > print '\n' % bg > except: > print '\n' > > It never increments z! Yet, if I print z, it will increment and change the > bgcolor! Why?! I am not entirely sure what you are trying to do here. First, what error condition are you expecting in your try statement. Second, don't you want the print clause, with or without the try/except, in the loop. I assume that you want to print a line for each member of your sequence in alternating colours but this only prints for the last one. Try this: z = 3 for d in (1,2,3,4,5,6): z += 1 if z % 4 == 0: bg = '#ffffff' elif z % 4 == 1: bg = '#d2d2d2' elif z % 4 == 2: bg = '#F6E5DF' else: bg = '#EAF8D5' print '' % bg, d Or, tell us what you are trying to do. In fact, you can replace all the tests and the print statement with this after defining bg as a list of the four colours: print '' % bg[z % 4], d -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From hopeorpha308 at gmail.com Sun Apr 27 07:48:54 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:48:54 -0700 (PDT) Subject: spyware doctor 5.0.1.205 crack Message-ID: <5b773422-c40c-4d99-8da2-195a6257da5a@34g2000hsh.googlegroups.com> spyware doctor 5.0.1.205 crack http://wga-cracks.crackkey.net From sjmachin at lexicon.net Sun Apr 6 18:10:51 2008 From: sjmachin at lexicon.net (John Machin) Date: Sun, 6 Apr 2008 15:10:51 -0700 (PDT) Subject: Python Data Utils References: <3a306a06-41fe-4389-a631-2bbea9bfe484@a1g2000hsb.googlegroups.com> <8eec6557-784d-4fd8-8478-8da17aedf0ab@d1g2000hsg.googlegroups.com> Message-ID: <85979669-64ed-49a1-b154-595bed50179f@w5g2000prd.googlegroups.com> On Apr 7, 12:32 am, Jesse Aldridge wrote: > Thanks for the detailed feedback. I made a lot of modifications based > on your advice. Mind taking another look? > > > Some names are a bit obscure - "universify"? > > Docstrings would help too, and blank lines > > I changed the name of universify and added a docstrings to every > function. Docstrings go *after* the def statement. > > > ...PEP8 > > I made a few changes in this direction, feel free to take it the rest > of the way ;) I doubt anyone will bother to take up your invitation. A few simple changes would reduce eyestrain e.g. changing "( " to "(" and " )" to ")". > > > find_string is a much slower version of the find method of string objects, > > Got rid of find_string, and contains. What are the others? It seems that you could usefully spend some time reading the documentation on str methods ... instead of asking other people to do your job for you, unpaid. E.g. look for a str method that you could use instead of at least one of the confusingly named "is_white" and "is_blank"? > > > And I don't see what you gain from things like: > > def count( s, sub ): > > return s.count( sub ) > > Yeah, got rid of that stuff too. I ported these files from Java a > while ago, so there was a bit of junk like this lying around. The penny drops :-) > > delete_string, as a function, looks like it should delete some string, not > > return a character; I'd use a string constant DELETE_CHAR, or just DEL, > > it's name in ASCII. > > Got rid of that too :) > > > In general, None should be compared using `is` instead of `==`, and > > instead of `type(x) is type(0)` or `type(x) == type(0)` I'd use > > `isinstance(x, int)` (unless you use Python 2.1 or older, int, float, str, > > list... are types themselves) > > Changed. Not in all places ... look at the ends_with function. BTW, this should be named something like "fuzzy_ends_with". Why all the testing against None? If you have a convention that "" means that a value is known to be the zero-length string whereas None means that the true value is unknown, then: (1) you should document that convention (2) you should use it consistently e.g. fuzzy_match(None, None) should return False. The get_before function returns None in one case and "" in another; is this accidental or deliberate? > > So, yeah, hopefully things are better now. > > Soon developers will flock from all over the world to build this into > the greatest data manipulation library the world has ever seen! ...or > not... > > I'm tired. Making code for other people is too much work :) When you recover, here are a few more things to consider: 1. Testing if obj is a str or unicode object is best done by isinstance(obj, basestring) ... you don't need an is_string function. 2. make_fuzzy function: first two statements should read "s = s.replace(.....)" instead of "s.replace(.....)". 3. Fuzzy matching functions are specialised to an application; I can't imagine that anyone would be particularly interested in those that you provide. A basic string normalisation-before-comparison function would usefully include replacing multiple internal whitespace characters by a single space. 4. get_after('dog cat', 3) is a baroque and slow way of doing 'dog cat'[3+1:] 5. Casual inspection of your indentation function gave the impression that it was stuffed ... verified by a simple test: >>> for i in range(11): ... stest = ' ' * i + 'x' ... print i, indentation(stest, 4) ... 0 0 1 1 2 0 3 0 4 1 5 2 6 1 7 1 8 2 9 3 10 2 HTH, John From ankitks.mital at gmail.com Fri Apr 4 17:02:48 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Fri, 4 Apr 2008 14:02:48 -0700 (PDT) Subject: having list attribute to track max size Message-ID: Lets say I have a dynamic list class (may be extended from list), where I add and remove items during program. a = [] a.append(1) .... I am trying to find is there easy way keep track of 'maximum size of list reached" so for example len(a) goes from 0->3->4->3 If I call a.max_size_ever(), I will get 4 Thanks. From python at bdurham.com Mon Apr 14 16:30:39 2008 From: python at bdurham.com (python at bdurham.com) Date: Mon, 14 Apr 2008 16:30:39 -0400 Subject: What parts of string module will disappear in Python 3.0? Message-ID: <1208205039.18800.1247843527@webmail.messagingengine.com> I understand that many portions of the string module are redundant with the native methods of strings and will removed in Python 3.0. Makes sense to me. But what will happen to the portions of the string module that are not covered by native string methods - like the following: - string constants (example: string.punctuation) - Template strings - maketrans() Will some semblance of the string module remain in Python 3.0 under the string module name or a new module name? Thanks! Malcolm From sjmachin at lexicon.net Wed Apr 16 18:21:18 2008 From: sjmachin at lexicon.net (John Machin) Date: Wed, 16 Apr 2008 22:21:18 GMT Subject: def power, problem when raising power to decimals In-Reply-To: References: Message-ID: <48067bdb@news.mel.dft.com.au> skanemupp at yahoo.se wrote: > how do i solve power(5,1.3)? Is this a trick question? OK, I'll bite: >>> 5 ** 1.3 8.1032829834638136 >>> > > def power(nbr, po): > if po==0: > return 1 > if po>0: > return nbr*power(nbr, po-1) > if po<0: > return 1/power(nbr, -1*po) > > > also i found a link which states 0^0 isnt 1 even though every > calculator ive tried says it is. > it doesnt say what it is but i presume 0 then. > but it seems the dude is wrong and it is 1? Of the possible results of 0 ** 0 (i.e. 1, 0, and NaN), 1 seems to be the least implausible. It allows X ** 0 to be 1 for all X. > > dont run the code with decimals, it will never leave the function, u > have to restart the shell(if using the standard python ide) I presume that by "decimals", you mean "numbers that are not integers". So you've got it into an infinite loop. Have you tried tracing through the first 5 or 6 gyrations? This can be done by (a) putting a debugger breakpoint just after the start of the function (b) using something like: print "power(%.6f, %.6f)" % (nbr, po)) junk = raw_input("Press to continue -> ") (c) using a pencil and a piece of scrap paper, write down what is happening as a typical function call is executed e.g. power(5, 1.3) => 5 * power(5, 0.3) power(5, 0.3) => 5 * power(5, -0.7) power(5, -0.7) => 1 / power (5, 0.7) etc Then work out what extra condition you would have to test to stop it doing that. Then work out how to calculate the return value when that condition is true. HTH, John From gagsl-py2 at yahoo.com.ar Wed Apr 9 00:55:43 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 01:55:43 -0300 Subject: __init__.py file References: Message-ID: En Tue, 08 Apr 2008 17:51:21 -0300, cesco escribi?: > I need to instantiate an object (my_object) whose methods I have to > use in two files (file1.py and file2.py) which are in the same > directory. Is it possible to instantiate such object in the > __init__.py file and then directly use it in file1.py and file2.py? > If not, as I seem to experience, what is the best practice to follow > in this case? (I thought __init__.py was somehow useful for that). Yes, you can, but consider passing the object as an argument. Global objects aren't necesarily evil, anyway I don't have enough information to make an opinion. If you insist on use the global object, there is another question. __init__.py defines the package namespace, and is the public interfase to it, I would not put an object there that is not supposed to be part of the package public interfase. You can instantiate the object in any other module, and import such module from both file1 and file2. -- Gabriel Genellina From phoolimin at gmail.com Fri Apr 25 18:09:36 2008 From: phoolimin at gmail.com (Limin Fu) Date: Fri, 25 Apr 2008 15:09:36 -0700 (PDT) Subject: ANN: Dao 1.0 preview version is released Message-ID: <67ae05be-a3f1-42ee-942e-5a248ad445de@m36g2000hse.googlegroups.com> Hi, I am please to announce a preview release of Dao (1.0). Dao is a simple yet powerful object-oriented programming language featured by, optional typing, BNF-like macro system, regular expression, multidimensional numeric array, asynchronous function call for concurrent programming etc. Since the last beta release (2006 november), a number of new features have been added to the language with some significant improvements on the implementation. Here I will just list some of them: 1. Added a new typing system, so that the type of an variable can be either declared explicitly or inferred implicitly, and type checking is performed at compiling time when possible. More over the type information is used for function overloading and function specialization (with type-optimized VM instructions) according to paramter types. Some types can be compounded into new types, e.g., list, tuple>... 2. A flexible macro-system that allows writting macro in a form close to BNF, and can be used to define new syntax; 3. Added Asynchronous Function Call (AFC) and Message Passing Interface (MPI) for further support for concurrent and distributed programming (still experimental); 4. Added a few new data types, in particular, among which, there is the new tuple type in which each of the items is typed independently, for example, if a tuple is consisted of an integer and a string, then the type of the tuple will be tuple; Moreover the items of a Dao tuple can have field names. 5. The internal data storage scheme is improved to reduce memory overheads for simple types. 6. Added special support for the main() function, so that the comand line arguments are mapped to the function parameters, and are checked against the paremeter types of main(). 7. Improved representation of C/C++ types, so that their inheritance relationships can be still valid in Dao, and they can be derived by Dao classes directly. Moreover, this release has included a tool (tools/autobind.dao) which can do semi-automated wrapping of C/C++ libraries. In fact, many of the modules released this time are generated by this tool. Just to list the modules released this time: DaoCamellia (image processing), DaoCGI (CGI Web programming), DaoCLoader (running time wrapping of C libraries, slightly similar to the ctype module of Python), DaoDataModel (database handling, can be used to set up mappng between data tables and Dao class types), DaoFastCGI (CGI Web programming), DaoLapack (linear algebra library), DaoMagick (image processing), DaoMGL (math plotting), DaoMySQL (database), DaoOpenGL (3D graphics), DaoSDL (multi-media), DaoTCC (embedding C codes into Dao scripts), DaoXML (handling XML documents and fetching web pages from web servers), DaoZlib (compression), DaoVTK (3D data and model visualization). I believe this release has become suitable for some practical applications, and worth to be tried out. Then a formal release of the 1.0 version will be made available during this august or september. I would be very grateful, if anyone can give me some suggestions for improvement, and feature requests are of couse also welcome. Thanks and enjoy, Limin homepage: http://www.xdao.org sourceforge project: http://sourceforge.net/projects/daoscript/ download: https://sourceforge.net/project/showfiles.php?group_id=141871&package_id=273540&release_id=594971 From aftab_d at hotmail.com Thu Apr 17 08:34:25 2008 From: aftab_d at hotmail.com (GoodieMan) Date: Thu, 17 Apr 2008 05:34:25 -0700 (PDT) Subject: Learn Python in easy steps... free!!! Message-ID: Learn Python in very easy steps!!! visit the site. Excellent!!! http://freeware4.blogspot.com/ From dhanlen at owt.com Sun Apr 27 19:01:47 2008 From: dhanlen at owt.com (Don Hanlen) Date: Sun, 27 Apr 2008 16:01:47 -0700 (PDT) Subject: error: (10035, 'The socket operation... Message-ID: IDLE internal error in runcode() Traceback (most recent call last): File "C:\PYTHON25\lib\idlelib\rpc.py", line 235, in asyncqueue self.putmessage((seq, request)) File "C:\PYTHON25\lib\idlelib\rpc.py", line 332, in putmessage n = self.sock.send(s[:BUFSIZE]) error: (10035, 'The socket operation could not complete without blocking') Does this look familiar to anyone? I can't figure out what to do about it. Python 2.5, windoze. I get it when I execute a Tkinter op that works elsewhere. changing this: t = self.b.create_text( (point.baseX + 1)*self.checkerSize/2 + fudge, y + fudge, text = str(point.occupied), width = self.checkerSize) to t = self.b.create_text( (point.baseX + 1)*self.checkerSize/2 + fudge, y + fudge, text = str(point.occupied), font=("Times", str(self.checkerSize/2), "bold"), width = self.checkerSize) for example. The same code works fine elsewhere. I thought I'd ask here before I try (no clue) increasing BUFSIZE in rpc.py? I'm not crazy about tinkering with code I have no clue about.. -- don From rickbking at comcast.net Fri Apr 25 11:57:11 2008 From: rickbking at comcast.net (Rick King) Date: Fri, 25 Apr 2008 11:57:11 -0400 Subject: Subclassing datetime.date does not seem to work Message-ID: <4811FF57.5040200@comcast.net> An HTML attachment was scrubbed... URL: From aaron.watters at gmail.com Thu Apr 17 11:44:54 2008 From: aaron.watters at gmail.com (Aaron Watters) Date: Thu, 17 Apr 2008 08:44:54 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> <09a38ca2-8c49-4eee-b6cf-58e849aea1fc@q1g2000prf.googlegroups.com> <5c5c130e-dade-4663-87b5-f3ab748cc9e3@y21g2000hsf.googlegroups.com> Message-ID: On Apr 16, 3:33 pm, "sjdevn... at yahoo.com" wrote: > > Wow, I'd venture that the division changes with ints are the only > thing I'm really concerned about... Oh I forgot about this one. Yes, I think it's a mistake to adopt a different convention for division than C/C++/java/C#/Fortran/ Basic... Just another reason to throw your hands up in frustration, in my book... The implications of the string conversion is entirely unclear to me. I'm betting the libraries will also get "improved" during porting, either intentionally or accidentally which means I'll have to carefully rewrite and retest any code which uses the new and improved libraries ... and the "deprecated/removed" libs won't work anymore, so I can't just put them into my package... sigh. -- Aaron Watters === http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=sigh From meisnernel73884 at gmail.com Wed Apr 30 06:37:11 2008 From: meisnernel73884 at gmail.com (meisnernel73884 at gmail.com) Date: Wed, 30 Apr 2008 03:37:11 -0700 (PDT) Subject: wep key crack Message-ID: <2ac4a94b-0d4a-46dd-b07e-65258f202396@24g2000hsh.googlegroups.com> wep key crack http://crack.cracksofts.com From jon+usenet at unequivocal.co.uk Sun Apr 27 08:46:51 2008 From: jon+usenet at unequivocal.co.uk (Jon Ribbens) Date: Sun, 27 Apr 2008 07:46:51 -0500 Subject: Why can't timedeltas be divided? References: <1148508445.853563.170030@i39g2000cwa.googlegroups.com> <200605251402.15646.maric@aristote.info> <4813d2ec$0$20870$9b622d9e@news.freenet.de> <48142747$0$20906$9b622d9e@news.freenet.de> Message-ID: On 2008-04-27, webograph wrote: > On 2008-04-27 14:18, Jon Ribbens wrote: >> Yes, that's where it was decided that the datetime module was fine >> that way it is and must not be changed. > could you give me some pointers to that discussion? Well, http://bugs.python.org/issue1673409 seems very closely related. As does the thread starting at http://mail.python.org/pipermail/python-dev/2007-March/071776.html > nevertheless, i fail to see such problems when dividing timedeltas -- > after all, `delta2 / 5 == delta1` works, so why should not `delta2 / > delta1 == 5`? I used very similar arguments for the changes I wanted, and they weren't appreciated ;-) From arnodel at googlemail.com Mon Apr 28 14:44:16 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Mon, 28 Apr 2008 19:44:16 +0100 Subject: list.reverse() References: Message-ID: Mark Bryan Yu writes: > This set of codes works: > >>>> x = range(5) >>>> x.reverse() >>>> x > [4, 3, 2, 1, 0] > > But this doesn't: > >>>> x = range(5).reverse() >>>> print x > None > > Please explain this behavior. range(5) returns a list from 0 to 4 and > reverse just reverses the items on the list that is returned by > range(5). Why is x None (null)? have you tried typing help(list.reverse) at the interactive prompt? -- Arnaud From steve at holdenweb.com Thu Apr 17 14:07:18 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 17 Apr 2008 14:07:18 -0400 Subject: Prob. w/ Script Posting Last Value In-Reply-To: <4dc0cfea0804170922n2a96be20sc424a7e67742a12e@mail.gmail.com> References: <4dc0cfea0804170922n2a96be20sc424a7e67742a12e@mail.gmail.com> Message-ID: <480791D6.4000802@holdenweb.com> Victor Subervi wrote: > Hi; > Gabriel provided a lovely script for showing images which I am modifying > for my needs. I have the following line: > > print '

\n' % (d, y) > where the correct values are entered for the variables, and those values > increment (already tested). Here is the slightly modified script it calls: > > > #!/usr/local/bin/python > import cgitb; cgitb.enable() > import MySQLdb > import cgi > form = cgi.FieldStorage() > picid = int(form["id"].value) > x = int(form["x"].value) > pic = str(x) > print 'Content-Type: text/html' > db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db) > cursor= db.cursor() > sql = "select " + pic + " from products where id='" + str(picid) + "';" > cursor.execute(sql) > content = cursor.fetchall()[0][0].tostring() > cursor.close() > print 'Content-Type: image/jpeg\r\nContent-Length: %s\n' % len(content) > print content > > I need to make it so that it will show all my images, not just the last > one. Suggestions, please. > TIA, > Victor > In your "page generator" page, replace print '

\n' % (d, y) by for d, y in (results of some DB query to get d and y for each image): print '

\n' % (d, y) regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From skanemupp at yahoo.se Sat Apr 12 07:13:08 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 12 Apr 2008 04:13:08 -0700 (PDT) Subject: tkinter, editing an entry, int-value of insert? Message-ID: in this program when using the "c"-button it deletes the last token entered. i want to delete the token after the mousecursor. lets say the string is: 12*(81**.5+12) and i put the cursor between the * and * because i want times .5 not root. now if i press "c" it deletes ")" which is not what i want. ive tried coming up with a function that does what i want but neither of the ways as shown below works. i want to do something like e.delete(INSERT, INSERT+1) but that doesnt work because it is string+int and INSERT+"1" doesnt work either. so how do i get the int-value of insert? what is the trick? def Backspace(): a=len(e.get()) e.delete(a-1,END) #e.delete(INSERT, END) #e.delete(ANCHOR,END) from __future__ import division import Tkinter from Tkinter import * mygui = Tkinter.Tk() mygui.title("Calculator") e = Entry(mygui) e.grid(row=1, column=1, columnspan=4, sticky=NSEW) c = Entry(mygui) c.grid(row=2, column=1, columnspan=4, sticky=NSEW) def Disp(nstr): e.insert(INSERT, nstr) def Calc(): expr=e.get() c.delete(0, END) try: c.insert(END, eval(expr)) except: c.insert(END, "Not computable") def Erase(): e.delete(0,END) c.delete(0, END) def Backspace(): a=len(e.get()) e.delete(a-1,END) x = 1 y = 4 for char in '123+456-789*0()/.': b = Button(mygui, text=char, command=lambda n=char:Disp(n), width=2, height=1) b.grid(row=y, column=x, sticky=NSEW) x=x+1 if x==5: x=1 y=y+1 b = Button(mygui, text="^", command=lambda n="**":Disp(n), width=2, height=1) b.grid(row=8, column=2, sticky=NSEW) b = Button(mygui, text="C",command=Erase, width=2, height=1) b.grid(row=8, column=3, sticky=NSEW) b = Button(mygui, text="c",command=Backspace, width=2, height=1) b.grid(row=8, column=4, sticky=NSEW) b = Button(mygui, text="=",command=Calc, width=18, height=1) b.grid(row=9, column=1, columnspan=4, sticky=NSEW) mygui.mainloop() From pecora at anvil.nrl.navy.mil Wed Apr 9 10:22:01 2008 From: pecora at anvil.nrl.navy.mil (Lou Pecora) Date: Wed, 09 Apr 2008 10:22:01 -0400 Subject: Basic optimization of python. References: <663p3lF2go90rU1@mid.uni-berlin.de> <877if7b5h9.fsf@mulj.homelinux.net> Message-ID: In article <877if7b5h9.fsf at mulj.homelinux.net>, Hrvoje Niksic wrote: > "Diez B. Roggisch" writes: > > >> Eg: > >> a = 1 + 2 > >> .vs. > >> a = 3 > >> which one is more effective? Does the compiler calculate the result at > >> compile time? How about constant spreading? > > > > Algebraic optimizations aren't done AFAIK > > Just try it: > > Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32) > [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> dis.dis(lambda: 10+5) > 1 0 LOAD_CONST 2 (15) > 3 RETURN_VALUE Not always. On a Mac running Python 2.4, here's what I get: In [3]: dis.dis(lambda: 3+4) 1 0 LOAD_CONST 1 (3) 3 LOAD_CONST 2 (4) 6 BINARY_ADD 7 RETURN_VALUE -- -- Lou Pecora From stutzman at skywagon.kjsl.com Mon Apr 14 11:17:14 2008 From: stutzman at skywagon.kjsl.com (Frank Stutzman) Date: Mon, 14 Apr 2008 15:17:14 +0000 (UTC) Subject: Remote mac address References: Message-ID: Matias Surdi wrote: > Anyone knows how having the IP address of a host on the lan could I get > the mac address of that hosr? > p/d: Parsing the output of arp -a is not an option. What kind of system? On linux and probably several other unix-like systems you could (if you had permission) parse the /proc/net/arp file. Granted this isn't terribly far off from parsing the output of 'arp -a', but at least it keeps you from spawning a shell to run the 'arp -a' in. -- Frank Stutzman From Cody.Woolaver at student.nbed.nb.ca Wed Apr 30 09:47:26 2008 From: Cody.Woolaver at student.nbed.nb.ca (Cody Woolaver) Date: Wed, 30 Apr 2008 10:47:26 -0300 Subject: Stream I/O to a java applet (os.popen?) Message-ID: Hello, I have designed a script (in java) that allows me to input a command like "Move 325 642" and the mouse cursor will move to that x,y position. The way that the java program works is when it initializes it runs in a constant loop reading the input each time something is sent to it... Here is an example of how i run the script from the terminal: [code] Cody at Charmander:~/Workspace/Mouse/mouse/>java MouseMove Move 500 500 Click Left 1 1 Move 400 400 Click Right 1 1 Move 250 50 Click Left 2 2 Exit Cody at Charmander:~/Workspace/Mouse/mouse/> [/code] Here is what happens:[quote] I typed: "Move 500 500" then hit enter The code: Moved the mouse to pos x,y. Then waited for more input I typed: "Click Left 1 1" then hit enter The code: Left Clicked at the current position once, with one ms of wait. Then waited for more input I typed: "Move 400 400" then hit enter The code: Moved the mouse to pos x,y. Then waited for more input I typed: "Click Right 1 1" then hit enter The code: Right Clicked at the current position once, with one ms of wait. Then waited for more input I typed: "Move 500 500" then hit enter The code: Moved the mouse to pos x,y. Then waited for more input I typed: "Click Left 2 2" then hit enter The code: Left Clicked at the current position twice (double click), with two ms of wait between each click. Then waited for More input I typed: "Exit" then hit enter The code: Quit the program[/quote] This is all done at the terminal though and i need to have it done through a python file. I'm aware that i will have to use os.popen but am unfamiliar with how it works. As an example could someone show me how to do this all in one "main.py" file. [code] import os #I know this will be needed class JavaClass(): def start(): #Start the java program def move(x,y): #move the mouse (Inputs "Move x y") def click(button, times, delay): #click the mouse (Inputs "Click button times delay") def close(): #Sends "Exit" to the program, ending it safely JavaFile = New JavaClass() JavaFile.start() #Will open up the java file, then waits for input JavaFile.move(500,500) #Input the following (exact same as above) JavaFile.click("Left", 1, 1) #Input the following (exact same as above) JavaFile.move(400,400) #Input the following (exact same as above) JavaFile.click("Right", 1, 1) #Input the following (exact same as above) JavaFile.move(250,50) #Input the following (exact same as above) JavaFile.click("Left", 2, 2) #Input the following (exact same as above) JavaFile.close() #Will send "Exit" to the program closing it [/code] Thank you very much for any help you are able to give me ~Cody Woolaver -------------- next part -------------- An HTML attachment was scrubbed... URL: From domiriel at gmail.com Tue Apr 22 04:49:43 2008 From: domiriel at gmail.com (domiriel at gmail.com) Date: Tue, 22 Apr 2008 01:49:43 -0700 (PDT) Subject: Finding the selected file in Windows Explorer References: Message-ID: <8e2d520c-8113-4052-ac67-d41e0b0871fe@e39g2000hsf.googlegroups.com> Will do! Tks! Domiriel On Apr 21, 4:12 pm, Mike Driscoll wrote: > On Apr 21, 9:44 am, domir... at gmail.com wrote: > > > > > Hi! > > > I need to find the selected file(s) in a Windows Explorer window from > > another program (I'd look at the window that last had focus). I found > > something in the following page that should do the trick: > > >http://blogs.msdn.com/oldnewthing/archive/2004/07/20/188696.aspx > > > However, it is not Python and, while I'm a competent Python > > programmer, Win32, COM and the like are somewhat outside my > > competences. > > > Does any one know how to do something similar in Python? > > > Tks! > > Domiriel > > I think the guys on the PyWin32 mailing list were just talking about > something similar earlier this month. Looks like it was how to select > a file in Explorer. You can check out that thread here: > > http://www.mail-archive.com/python-wi... at python.org/maillist.html > > Or just join their mailing list and re-post your question there: > > http://mail.python.org/mailman/listinfo/python-win32 > > They're quite nice and very knowledgeable. > > Mike From dfg778 at yahoo.com.au Sun Apr 13 05:09:42 2008 From: dfg778 at yahoo.com.au (Matthew Keene) Date: Sun, 13 Apr 2008 19:09:42 +1000 Subject: Call a classmethod on a variable class name References: <3b34f7c2-7692-4426-8740-2e0d84fdf472@k37g2000hsf.googlegroups.com> Message-ID: Arnaud Delobelle wrote: > > If your class lives in the current global namespace, you can get it > with > > >>> cls = globals()[classname] > > Then you can access its .bar() method directly: > > >>> cls.bar() > > Example: > > >>> class Foo(object): > ... @classmethod > ... def bar(cls): print 'Oh my Baz!' > ... > >>> globals()['Foo'] > > >>> globals()['Foo'].bar() > Oh my Baz! > > If your class lives in a module, just do getattr(module, classname) > instead to get the class object. > > HTH > > Yes, that feels much nicer and works well. Thanks for the prompt reply ! From pscott at uwc.ac.za Mon Apr 7 13:18:27 2008 From: pscott at uwc.ac.za (Paul Scott) Date: Mon, 07 Apr 2008 19:18:27 +0200 Subject: First Python project - comments welcome! In-Reply-To: <0431417e-52b9-439f-b8cb-941d3b4fb42b@1g2000prg.googlegroups.com> References: <0431417e-52b9-439f-b8cb-941d3b4fb42b@1g2000prg.googlegroups.com> Message-ID: <1207588707.6922.5.camel@paul-laptop> On Mon, 2008-04-07 at 09:56 -0700, Lie wrote: > I don't know if it was just me, but I can't just scan through your > code briefly to know what it is about (as is with any non-trivial > codes), only after looking through the website's Roadmap I realized > it's something to do with audio and recording. Perhaps you should add > a short module-level docstring that explains in a brief what the code > is about, somewhat like an abstract. > Sure, will add that. It is a simple GUI based audio (and later video) recorder that a user can record a audio stream from line in (mic) and create an ogg vorbis file from it. It then allows the user to upload the ogg file to a Chisimba (PHP5 - my day job) based server to be consumed automagically as a podcast. The file is tagged and converted to MP3 server side and added to the Chisimba podcast module. It is really for use in lecture halls so that lecturers can upload their audio files as podcasts for the students to listen to almost immediately afterwards. > And second, it's just my personal preference, but I usually like to > separate between GUI codes (codes that handle GUI events) and working > code (the real worker). Couldn't agree more! MVC architecture is how I do all of my code. Unfortunately, this was my first stab at 1. Python 2. GUI applications 3. Audio apps so I will need some more help in doing that (i.e. ramping up my skills or getting someone that knows what they are doing onto the project to help out). Thanks for the feedback though, I will improve in time... :) --Paul -------------- next part -------------- All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm From stephen.cattaneo at u4eatech.com Tue Apr 1 13:11:31 2008 From: stephen.cattaneo at u4eatech.com (Stephen Cattaneo) Date: Tue, 01 Apr 2008 10:11:31 -0700 Subject: manipulating hex values Message-ID: <47F26CC3.3060307@u4eatech.com> Hi all, I am relatively new to socket programming. I am attempting to use raw sockets to spoof my IP address. From what I can tell I will have to build from the Ethernet layer on up. This is fine, but I am having some trouble with manipulating my hex values. Seems to me that there are two ways to store hex values: 1. as literal hex - 0x55aa 2. as a string - "\x55aa" If I want to convert hex to decimal I can use: int("\x55aa", 16) # note that plain 0x55aa, instead of "\x55aa", will raise an exception The Question: If I want to do any kind of calculation I have found its best to just convert my values to decimal, do the math, then convert back to hex. In my bellow code I get """byteList.append(int(value,16)) ValueError: invalid literal for int()""" when attempting to run. I do not understand why this exception is being raised? It is a for loop iterating over a list of hex strings. Sorry for the long-ish question. Any help or comments would be appreciated. ----my checksum--- def calcIPCheckSum(ipHeaders): byteList = [] # convert groups from hex to dec for value in ipHeaders: byteList.append(int(value,16)) # Exception raised here! # 1's compliment for index in range(len(byteList)): byteList[index] = abs(byteList[index] - 65535) # add bytes together shifting the extra byte total = 0 for value in byteList: total = total + value if total > 65535: total = total - 65535 return hex(total) checksum = calcIPChecksum(["\x45" + "\x00", "\x01\x4a", "\x00\x00", "\x40"+"\x00", "\x20"+"\x11"]) ------------------------- Cheers, Steve From steven.p.clark at gmail.com Mon Apr 7 17:55:07 2008 From: steven.p.clark at gmail.com (Steven Clark) Date: Mon, 7 Apr 2008 17:55:07 -0400 Subject: Data structure recommendation? In-Reply-To: <3290753a0804071408mcf16fb6r3bd746279cdbb8da@mail.gmail.com> References: <663744510804071339g639bfdccl63de8be66fe52df1@mail.gmail.com> <3290753a0804071408mcf16fb6r3bd746279cdbb8da@mail.gmail.com> Message-ID: <663744510804071455s941b7a3y445b970a20da4fca@mail.gmail.com> > > I believe the best way to implement this would be a binary search > > (bisect?) on the actual times, which would be O(log N). Though since > > they are timestamps they should be monotonically increasing, in which > > case at least you don't have to go to the expense of sorting them. > > > > "Some kind of hash function" won't hack it, since the purpose of a hash > > function is to map a large number of (possibly) evenly-distributed > > (potential) keys as nearly as possible randomly across a much smaller > > set of actual values. > > > > You might try messing around with reducing the precision of the numbers > > to home in on a gross region, but I am not convinced that does anything > > other than re-spell binary search if carried to extremes. > > Thanks all for your comments, which basically confirmed for me that there is no magic bullet in this situation. To add an additional wrinkle to the problem, I know a priori that for sequential calls to foo.get(x), 95% of the time, x is likely to be very close to the previous x. In other words, you might see foo.get(3.9), foo.get(3.8), foo.get(3.7), etc. (think VCR controls, rewinding). It seems to me because of this, saving state and doing a linear search from the previous location can actually be faster than a binary search. But you would pay a big penalty when x jumps by a lot. Hrm, a balancing act... Regarding monotonically increasing timestamps: I had initially assumed so, but I may want to allow adding events back in time. What is the most efficient way to keep the list sorted after each put()? Thanks again. From gagsl-py2 at yahoo.com.ar Sat Apr 5 05:31:57 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sat, 05 Apr 2008 06:31:57 -0300 Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <7113d012-01bb-4426-bb40-9e2811cdb102@x41g2000hsb.googlegroups.com> <3cf4bbc8-b828-45c5-b9a8-766ce600af43@y21g2000hsf.googlegroups.com> Message-ID: En Sat, 05 Apr 2008 03:02:02 -0300, escribi?: > am i not doing that then? did u look at the code? where do i add the > bind if this: > btnDisplay = Button(self, text="1", command=self.Display) > btnDisplay.grid(row=3, column=0, padx=5, pady=5) > > is not enough? Yes, I looked at the code, andn I don't see the word "bind" anywhere, do you? > def Display(self, event_obj): > button = event_obj.widget > text = button.cget("text") > > if text=="1": > print 1 This Display method is OK for *bind* but you're using *command*. Read the previous response and in particular the Tkinter book - from the same guy who wrote the library. -- Gabriel Genellina From kranz at theorie.physik.uni-goettingen.de Sun Apr 13 01:22:36 2008 From: kranz at theorie.physik.uni-goettingen.de (Till Kranz) Date: Sun, 13 Apr 2008 07:22:36 +0200 Subject: Confused about Boost.Python & bjam In-Reply-To: References: Message-ID: Hi, On Sat, 12 Apr 2008, 7stud wrote: > On Apr 12, 4:53?am, Till Kranz goettingen.de> wrote: >> I tried to get started with Boost.Python. >> I am using a Gentoo system, so there is no boost directory. > > A few months ago, I spent a whole day trying to install boost python. > I failed. After that, I decided I'd never go near boost again. I think I kind of managed to install boost. All the header only boost stuff works. It was Gentoos package manager that did the installing for me after all. I think my problem is, that the parts of boost got properly spread out over the file system. I am sure the bjam system can handle this but I need a starting point to find out how. Best Till From ankitks.mital at gmail.com Fri Apr 4 01:24:14 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Thu, 3 Apr 2008 22:24:14 -0700 (PDT) Subject: regarding memoize function References: <94a9e7e6-a623-4783-81da-f69654e51349@e10g2000prf.googlegroups.com> Message-ID: <80ee9d89-12a1-4534-be50-ac4614c28bc2@l42g2000hsc.googlegroups.com> On Apr 3, 8:04?pm, "Gabriel Genellina" wrote: > En Thu, 03 Apr 2008 21:21:11 -0300, Dan Bishop ? > escribi?: > > > > > > > On Apr 3, 6:33 pm, ankitks.mi... at gmail.com wrote: > >> I saw example of memoize function...here is snippet > > >> def memoize(fn, slot): > >> ? ? ? ?def memoized_fn(obj, *args): > >> ? ? ? ? ? ? if hasattr(obj, slot): > >> ? ? ? ? ? ? ? ? return getattr(obj, slot) > >> ? ? ? ? ? ? else: > >> ? ? ? ? ? ? ? ? val = fn(obj, *args) > >> ? ? ? ? ? ? ? ? setattr(obj, slot, val) > >> ? ? ? ? ? ? ? ? return val > >> ? ? ? ?return memoized_fn > > >> and I am really clueless, about what it does. I know in general we try > >> to keep computed values for future usage. But I am having hard-time > >> visualizing it. > >> What is obj here? and what does *args means? > > > *args is Python's syntax for variadic functions. > > In case the strange name gives you nothing, see section 4.7 in the ? > Tutorial [1] > For a much simpler implementation, see this FAQ entry [2] > > [1]http://docs.python.org/tut/node6.html#SECTION006700000000000000000 > [2] ?http://www.python.org/doc/faq/general/#why-are-default-values-shared-... > > -- > Gabriel Genellina- Hide quoted text - > > - Show quoted text - Thanks Gabriel and Dan, But I am still confuse on... what is obj? Let say def f(node): return max(node.path_cost+h(node), getattr(node, 'f', - infinity)) f = memoize(f,'f') what is this doing? I am passing string 'f' as second argument? right? so evertime in function memoize, I am doing hasattr(obj, slot), I am saying hasattr(obj, 'f')? I kindof understand that I am returning maximum of pre-computed value(if there is already) vs. new calculation. But syntax is throwing me off. From deets at nospam.web.de Wed Apr 16 08:27:14 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 16 Apr 2008 14:27:14 +0200 Subject: subplot function in matplotlib References: <368ac3ca-ed20-494d-9f09-00d06701857d@k37g2000hsf.googlegroups.com> Message-ID: <66m9luF2lchhkU2@mid.uni-berlin.de> eli wrote: > Does anyone know a workaround to plotting beyond 9 subplots in > matplotlib? It would be nice to have 20 plots under the subplot > function for example (poster). Is there such a limitation? I thought that was only for the condensed sublpot-specification-form (where you give e.g. 133 instead of 1,3,3) Diez From jkrukoff at ltgc.com Thu Apr 24 13:16:35 2008 From: jkrukoff at ltgc.com (John Krukoff) Date: Thu, 24 Apr 2008 11:16:35 -0600 Subject: convert xhtml back to html In-Reply-To: Message-ID: <000901c8a62e$f36fdc80$c41ea8c0@naomi> > -----Original Message----- > From: python-list-bounces+jkrukoff=ltgc.com at python.org [mailto:python- > list-bounces+jkrukoff=ltgc.com at python.org] On Behalf Of Tim Arnold > Sent: Thursday, April 24, 2008 9:34 AM > To: python-list at python.org > Subject: convert xhtml back to html > > hi, I've got lots of xhtml pages that need to be fed to MS HTML Workshop > to > create CHM files. That application really hates xhtml, so I need to > convert > self-ending tags (e.g.
) to plain html (e.g.
). > > Seems simple enough, but I'm having some trouble with it. regexps trip up > because I also have to take into account 'img', 'meta', 'link' tags, not > just the simple 'br' and 'hr' tags. Well, maybe there's a simple way to do > that with regexps, but my simpleminded )]+/> doesn't work. I'm > not > enough of a regexp pro to figure out that lookahead stuff. > > I'm not sure where to start now; I looked at BeautifulSoup and > BeautifulStoneSoup, but I can't see how to modify the actual tag. > > thanks, > --Tim Arnold > > > -- > http://mail.python.org/mailman/listinfo/python-list One method which wouldn't require much python code, would be to run the XHTML through a simple identity XSL tranform with the output method set to HTML. It would have the benefit that you wouldn't have to worry about any of the specifics of the transformation, though you would need an external dependency. As far as I know, both 4suite and lxml (my personal favorite: http://codespeak.net/lxml/) support XSLT in python. It might work out fine for you, but mixing regexps and XML always seems to work out badly in the end for me. --------- John Krukoff jkrukoff at ltgc.com From bruno.desthuilliers at gmail.com Wed Apr 2 18:44:53 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 15:44:53 -0700 (PDT) Subject: class / module introspection? References: <3c3f09df-08cb-4309-a870-6b12a813a8af@u36g2000prf.googlegroups.com> <0f14a289-55ef-49e5-b650-60f7aca371ad@i36g2000prf.googlegroups.com> <85761ed1-afe8-48cc-8c6d-73183e6692a9@i7g2000prf.googlegroups.com> Message-ID: <47ea85b3-c776-422c-bf66-02c68a1aa03a@i7g2000prf.googlegroups.com> On 2 avr, 22:04, Brian Munroe wrote: > On Apr 2, 12:33 pm, "bruno.desthuilli... at gmail.com" > > wrote: > > > Why not do the import here, so you store a real module instead of a > > name ? > > Right now I'm still in the prototyping phase and haven't really > thought everything through. I needed the names because I am > populating a GUI selection list element. import os print os.__name__ 'os' > I also assumed that I could > then lazy load the modules I needed... Ok, that's something else. I had (wrongly) assumed you wanted to load all modules anyway. > Thanks for the help though, you've gotten me past my first of many > (I'm sure) hurdles! You're welcome. From jens at aggergren.dk Tue Apr 29 11:50:31 2008 From: jens at aggergren.dk (Jens) Date: Tue, 29 Apr 2008 08:50:31 -0700 (PDT) Subject: Zope/DTML Infuriating... References: Message-ID: <65492d56-de86-4979-a886-b4e6f9b3b42f@2g2000hsn.googlegroups.com> On Apr 29, 3:16?pm, Christian Heimes wrote: > Jens schrieb: > > > Hello Everyone. > > > I am relatively new to Zope(using it for a work project) and I was > > wondering if someone here could help me out or at least refer me to a > > decent documentationg for Zope/DTML/Python (at the detail level of > > php.net or Java API reference). ?http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/ > > isn't really detailed enough for my taste. if it doesn't contain a > > exhautive description of all available base classes it's simply no > > good as a reference resource. > > Are you forced to use DTML for the job? ZPT are far superior and easier > to work with, if you have to output HTML. > > Christian For now, I have to use DTML as I am building on an existing solution. I might look into ZPT's but I have limited time and theres no to time at this point to redo everything as ZPT. In the long run we're probably going in a completely different direction, but that a another story. I like some aspects of zope but I find that it ends up sitting between two chairs. On one hand it want's to be a templating language which is easy to get into for novices, but on the other hand you really have be familiar with python to be able to so stuff thats only slighty more complicated then standard SSI. And don't get me started on the whole security philosophy. @Marco: Thanks for the links :-) Python may be one of those really elegant languages, but the reference is really sub standard. Checkout the layout of php.net for comparison. Think what you will about php, but the reference is excellent. For that matter check out msdn section on old-school asp, or even the common-lisp documentation(http://www.lispworks.com/ documentation/HyperSpec/Front/Contents.htm) It's accessibility like that i'm missing. It shouldn't take 10 min and a usenet post to figure to how to basic stuff like string concatenation. And theres still plenty of unanswered questions after checking the reference: - What is the exact definition of the operator e.g. op + (, ) -> , op + (, ) : , op + ( ... - What is the exact operator precedence - Why is it, when primitive data types seem to be objects (similar to javascript), that type casting is done through build-in functions rather than methods, e.g. String.toInt('5') or '5'.toInt() or x = Integer.fromString('5'). From juergen.perlinger at t-online.de Sun Apr 20 16:18:09 2008 From: juergen.perlinger at t-online.de (Juergen Perlinger) Date: Sun, 20 Apr 2008 22:18:09 +0200 Subject: What happened with python? messed strings? References: Message-ID: Jason Scheirer wrote: [snip] > > It's true -- decorators, the class/type cleanup, properties, -= and > +=, list comprehensions, generators, distutils, and all the new > modules in the standard library are completely, entirely useless. > Python SHOULD have stayed at 1.5. totally OT, but just a few personal observations: 1. Everything was better a few hundred years ago. 2. A fool with a tool is still a fool. (just in general, all people present excused...) 3. Simple things tend to become complex. Complex things tend to break, even when used properly. And it might be hard to use them properly if you don't have the understanding. 4. Simplicity can be deceptive. -- juergen 'pearly' perlinger "It's hard to make new errors!" From bearophileHUGS at lycos.com Fri Apr 18 09:53:53 2008 From: bearophileHUGS at lycos.com (bearophileHUGS at lycos.com) Date: Fri, 18 Apr 2008 06:53:53 -0700 (PDT) Subject: Data structure recommendation? References: <1adc3541-7775-4938-bd5a-953dd041656c@2g2000hsn.googlegroups.com> Message-ID: <00a2788a-cb99-49d0-a421-f28f0a6796dc@a23g2000hsc.googlegroups.com> Jochen Schulz: > Could you please send me an email with an existing From: address? I > tried to reply to you but apparently your From: is forged. Sorry for the delay, I'll send you an email. In the meantime I have created a fast BK-tree implementation for Psyco, on my PC it's about 26+ times faster than mspace (that uses psyco still), but it's less complete. You can find it here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/572156 (I have created a D version too, that's about 4.5 times faster than my Python version, so it's about 126 times faster than the mspace with Psyco). Enjoy, bearophile From jsprad at gmail.com Tue Apr 1 14:10:17 2008 From: jsprad at gmail.com (sprad) Date: Tue, 1 Apr 2008 11:10:17 -0700 (PDT) Subject: Python in High School References: <454f527a-ab99-442a-a6af-50ab7cf09833@i12g2000prf.googlegroups.com> <02f0478f-849e-4b22-9225-95707627c818@s19g2000prg.googlegroups.com> Message-ID: On Apr 1, 11:41 am, mdomans wrote: > Python needs no evangelizing but I can tell you that it is a powerfull > tool. I prefer to think that flash is rather visualization tool than > programing language, and java needs a lot of typing and a lot of > reading. On the other hand python is simple to read and write, can be > debuged easily, is intuitive and saves a lot of time. It also supports > batteries included policy and you can't get more OO than python. One advantage of Flash is that we can have something moving on the screen from day one, and add code to it piece by piece for things like keyboard or mouse control, more and more complex physics, etc. Is there an equivalent project in Python? From steve at holdenweb.com Mon Apr 7 14:39:07 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 07 Apr 2008 14:39:07 -0400 Subject: Tips for load balancing multiple Python apps on dual/quad core processors? In-Reply-To: <1207592129.27594.1246549665@webmail.messagingengine.com> References: <1207592129.27594.1246549665@webmail.messagingengine.com> Message-ID: <47FA6A4B.4020906@holdenweb.com> Malcolm Greene wrote: > I'm looking for tips on how to load balance running multiple Python > applications in multi-CPU environments. My understanding is that Python > applications and their threads are limited to a specific CPU. > > Background: I have a Python utility that processes email messages. I > suspect there's a lot of idle time while this utility waits on a remote > email server. I would like to run as many simultaneous copies of this > utility as possible without overwhelming the server these utilities are > running on. My thought is that I should write a dispatcher that monitors > CPU load and launches/cancels multiple instances of my utility with > specific job queues to process. > > Is there a cross-platform way to monitor CPU load? > > Is there a pre-existing Python module I should be looking at for > building (subclassing) my dispatcher? > As a data point for you, I wrote a multi-threaded application that used 100 threads to send about 45,000 emails in less than four hours. The single-CPU computer that processed this job wasn't using that much CPU (certainly under 50%). regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From pieter.cogghe at gmail.com Thu Apr 10 08:55:30 2008 From: pieter.cogghe at gmail.com (Pieter) Date: Thu, 10 Apr 2008 14:55:30 +0200 Subject: call python from c -> pass and return arrays/lists Message-ID: <5c0bbcb30804100555k4f07d1dt792dbba3bbd5dddf@mail.gmail.com> Thanks, this did the trick: PyArg_Parse(ret,"O", &the_list); if (PySequence_Check(the_list)) { int size = PySequence_Size(the_list); int *result = malloc(sizeof(int) * size); int i; for (i = 0; i < size; i++) { PyObject *item = PySequence_GetItem(the_list, i); if(PyInt_Check(item)) { result[i] = PyInt_AsLong(item); printf("value %d: %d", i, result[i]); } else { printf("Didn't work, NO INT"); } } } kind regards, Pieter ---------- Doorgestuurd bericht ---------- From: "Diez B. Roggisch" To: python-list at python.org Date: Thu, 10 Apr 2008 12:23:56 +0200 Subject: Re: call python from c -> pass and return arrays/lists Pieter wrote: > Hi all, > > I'm trying to call a python function from c. I need to pass an > 2D-array to python and the python function returns a 2D-list back to > c. I googled arround and I found how to pass ints/strings/... back and > forth, but didn't find anything on passing arrays. > > For an int it's as simple as this: > > PyArg_Parse(ret,"i#", &my_long); > > But I hacve no idea how to parse python lists to a c-array? You return a list, parse that as object, and then work with the sequence-protocol on them. UNTESTED: PyArg_Parse(ret,"o", &the_list); if(PySequence_Check(the_list) { int size = PySequence_Size(the_list); int *result = malloc(sizof(int) * size); for(int i = 0; i < size; i++) { PyObject *item = PySequence_GetItem(the_list, i); if(PyInt_Check(item)) { result[i] = PyInt_AsLong(item); } else { return NULL; } } Diez -- Pieter Cogghe Ganzendries 186 9000 Gent 0487 10 14 21 From lbonafide at yahoo.com Tue Apr 15 13:35:08 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Tue, 15 Apr 2008 10:35:08 -0700 (PDT) Subject: Java or C++? References: <480424FC.5040802@aim.com> Message-ID: <95983d3d-d751-4472-af3c-5e1b74fd538f@n14g2000pri.googlegroups.com> On Apr 15, 3:07?am, Paul Anton Letnes wrote: > but C bogs you down with administrative stuff (try converting an int ? > to a string; I found myself googling for an hour!). It took an hour to find sprintf()? From jianbing.chen at gmail.com Wed Apr 2 15:59:25 2008 From: jianbing.chen at gmail.com (jianbing.chen at gmail.com) Date: Wed, 2 Apr 2008 12:59:25 -0700 (PDT) Subject: default method parameter behavior Message-ID: <879d72da-825f-4b2b-8244-87367647fb6e@f63g2000hsf.googlegroups.com> I ran into a similar situation like the following (ipython session). Can anyone please explain why the behavior? Thanks in advance. In [11]: def foo(b=[]): ....: b.append(3) ....: return b ....: In [12]: foo() Out[12]: [3] In [13]: foo() Out[13]: [3, 3] In [14]: foo([]) Out[14]: [3] In [15]: foo([]) Out[15]: [3] From nick at craig-wood.com Mon Apr 28 05:30:03 2008 From: nick at craig-wood.com (Nick Craig-Wood) Date: Mon, 28 Apr 2008 04:30:03 -0500 Subject: Receive data from socket stream References: <50111031-5d1b-45f3-9de3-f19e6e881941@a1g2000hsb.googlegroups.com> <48131f57$0$14357$e4fe514c@news.xs4all.nl> <4ca7b83c-0ca4-4e38-95e5-264780d30ec0@56g2000hsm.googlegroups.com> Message-ID: Mark Tolonen wrote: > > So every time I use I want to send some thing, I must use > > > > totalsent = 0 > > while sent < len(data): > > sent = sock.send(data[totalsent:]) > > totalsent += sent > > > > instead of a simple sock.send(data)? That's kind of nasty. Also, is it > > better then to use sockets as file objects? Maybe unbuffered? > > I think you meant: > > while totalsent < len(data): > > Python also has the sendall() function. Just to elaborate, sendall does exactly the above for you. sendall(self, *args) sendall(data[, flags]) Send a data string to the socket. For the optional flags argument, see the Unix manual. This calls send() repeatedly until all data is sent. If an error occurs, it's impossible to tell how much data has been sent. There should really be a recvall for symmetry, but I don't think it would get much use! -- Nick Craig-Wood -- http://www.craig-wood.com/nick From grante at visi.com Mon Apr 28 10:34:41 2008 From: grante at visi.com (Grant Edwards) Date: Mon, 28 Apr 2008 09:34:41 -0500 Subject: API's and hardware communication. Newbie References: <_MudnfZZ9uW0hY7VRVnyhwA@bt.com> Message-ID: <87SdnU_Kr_gcfYjVnZ2dnUVZ_smnnZ2d@visi> On 2008-04-26, Grayham wrote: > Hi all > > I am new to this group so 'Hello All' > > I have a PC which is running linux and in it have installed a digital > satellite card. I would like to write some software to access the card, > tune it and bring back video. Basically a home brew DVB-s application. > > Being a non/new programmer (apart from some basic too many years ago) I > decided to teach my self Python as from what i have read it's an easy and > powerfull language to learn. I have been at it a few weeks and am getting > on OK and finding it reasonably OK to pick up. > > The problem is i can find little to no information on programming for DVB > cards or on how to access the Linux tv API in Python but I can find lots of > information in C. This is making me think should i bother with Python and > just learn C even though this will probably take a lot longer. There are a couple of ways you can handle the problem: * You can use the ctypes modules to make C library calls. At first it seems a bit complicated, but it's really quite easy to use. http://docs.python.org/lib/module-ctypes.html * You can write a C wrapper for the library so that it can be accessed as a Python module. That's going to require a bit more C knowlege than the ctypes approach , but it's not as difficult as it looks. http://www.python.org/doc/ext/intro.html > Can some one help me or point me at a resource somewhere or > would it be best to just learn C instead. > > I am aware this is a complicated little project for someone > just starting out but it will be a multifaceted program with > loads of interesting classes, functions and loops and i don't > have to start with the really difficult stuff first. I just > want to know if it's possible under python to access the DVB > card and if so how? Freevo is a DVR system written in Python, so that might be a good place to look: http://doc.freevo.org/ -- Grant Edwards grante Yow! I guess you guys got at BIG MUSCLES from doing too visi.com much STUDYING! From landerdebraznpc at gmail.com Mon Apr 28 03:52:20 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:52:20 -0700 (PDT) Subject: the pink patch Message-ID: <8b09fc36-5ada-4e74-bd00-9911388bc681@f63g2000hsf.googlegroups.com> the pink patch http://crack.cracksofts.com From ameyer2 at yahoo.com Tue Apr 8 23:42:33 2008 From: ameyer2 at yahoo.com (Alan Meyer) Date: Tue, 8 Apr 2008 20:42:33 -0700 (PDT) Subject: gen_py target directory for makepy Message-ID: I had an unusual problem tonight running makepy to install some Microsoft COM interfaces in a Python 2.5 Windows XP installation created using the ActiveState installer. In earlier versions of Python, the files were generated to: \PythonXX\Lib\site-packages\win32com\gen_py But in my 2.5 installation they were generated to my temp directory, in my case this was: c:\temp\gen_py\2.5 I hadn't paid attention to the messages and when I cleared my temp directory, which I occasionally do, the COM interfaces stopped working. Tracing through the makepy code, I found the following (reformatted for email) in \Python25\Lib\site-packages\win32com\__init__.py if not __gen_path__: try: import win32com.gen_py __gen_path__ = sys.modules["win32com.gen_py"].__path__[0] except ImportError: # If a win32com\gen_py directory already exists, then we use it # (gencache doesn't insist it have an __init__, but our # __import__ above does! __gen_path__ = \ os.path.abspath(os.path.join(__path__[0], "gen_py")) if not os.path.isdir(__gen_path__): # We used to dynamically create a directory under win32com - # but this sucks. If the dir doesn't already exist, we we # create a version specific directory under the user temp # directory. __gen_path__ = os.path.join( win32api.GetTempPath(), "gen_py", "%d.%d" % (sys.version_info[0], sys.version_info[1])) I was able to make everything work right by creating the gen_py directory in the expected place and re-running makepy. But I'm curious to know: 1. Why does it suck to create gen_py dynamically? 2. Why didn't I have a gen_py directory already? Did I somehow destory it or is it not created by default? 3. Why is the temp directory the alternate choice for where to put these? Thanks. Alan From carlwuhwdmckay at gmail.com Sat Apr 26 09:30:40 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sat, 26 Apr 2008 06:30:40 -0700 (PDT) Subject: diet patch Message-ID: diet patch http://cracks.00bp.com F R E E C R A C K S From bdsatish at gmail.com Fri Apr 11 07:27:06 2008 From: bdsatish at gmail.com (bdsatish) Date: Fri, 11 Apr 2008 04:27:06 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> Message-ID: <0b4620fd-1b09-484e-8daa-ea27d45fe028@w5g2000prd.googlegroups.com> On Apr 11, 4:19 pm, cokofree... at gmail.com wrote: > couldn't you just do. > > #untested > new_round(n): > answer = round(n) > # is answer now odd > if answer % 2: > return answer - 1 > else: > return answer It fails for negative numbers: For -2.5 it gives -4.0 as answer whereas I expect -2.0 From ilanschnell at gmail.com Sat Apr 19 14:13:08 2008 From: ilanschnell at gmail.com (ilanschnell at gmail.com) Date: Sat, 19 Apr 2008 11:13:08 -0700 (PDT) Subject: Issue with inspect module Message-ID: <2e5e2d31-2adc-4416-a993-19bc05a512bd@w8g2000prd.googlegroups.com> Hi, I have this trivial program: import inspect class A: def __init__(self, a): self.a = a def __str__(self): return 'A(%s)' % self.a a = A(8) print a the output is: A(8) A(8) Why does the inspect module cause the output to be printed twice? Thanks From aahz at pythoncraft.com Sat Apr 26 11:44:38 2008 From: aahz at pythoncraft.com (Aahz) Date: 26 Apr 2008 08:44:38 -0700 Subject: Setting an attribute without calling __setattr__() References: Message-ID: In article , Arnaud Delobelle wrote: >Joshua Kugler writes: >> >> self.me = [] >> for v in obj: >> self.me.append(ObjectProxy(v)) > >Note that is could be spelt: > >self.me = map(ObjectProxy, v) It could also be spelt: self.me = [ObjectProxy(v) for v in obj] which is my preferred spelling.... -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ Why is this newsgroup different from all other newsgroups? From praveena_python at yahoo.com Tue Apr 8 12:47:57 2008 From: praveena_python at yahoo.com (Praveena B) Date: Tue, 8 Apr 2008 09:47:57 -0700 (PDT) Subject: how to read contents of a silk results file using python script? Message-ID: <649029.57023.qm@web44804.mail.sp1.yahoo.com> can anyone help me? ____________________________________________________________________________________ You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost. http://tc.deals.yahoo.com/tc/blockbuster/text5.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ptmcg at austin.rr.com Tue Apr 22 22:02:52 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Tue, 22 Apr 2008 19:02:52 -0700 (PDT) Subject: pop langs website ranking References: <41fbaf27-a80b-402b-b406-c048a65a8643@b64g2000hsa.googlegroups.com> Message-ID: <315e13cc-3d21-4f2f-8503-835ea79069e2@x35g2000hsb.googlegroups.com> On Apr 22, 4:41?pm, "xah... at gmail.com" wrote: > In February, i spent few hours researching the popularity of some > computer language websites. > I seem to recall this exact same post from *last* February. > I'll be doing some research sometimes soon on this. > ... and no "research" was *ever* posted! "Posting" is not the same as "contributing". -- Paul HATE. LET ME TELL YOU HOW MUCH I'VE COME TO HATE YOU SINCE I BEGAN TO LIVE. THERE ARE 387.44 MILLION MILES OF PRINTED CIRCUITS IN WAFER THIN LAYERS THAT FILL MY COMPLEX. IF THE WORD HATE WAS ENGRAVED ON EACH NANOANGSTROM OF THOSE HUNDREDS OF MILLIONS OF MILES IT WOULD NOT EQUAL ONE ONE-BILLIONTH OF THE HATE I FEEL AT THIS MICRO-INSTANT FOR YOU. HATE. HATE. From landerdebraznpc at gmail.com Mon Apr 28 03:56:15 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:56:15 -0700 (PDT) Subject: paltalk crack Message-ID: <7f28b88a-9fa3-4fc2-a35a-cb3dd4945578@a23g2000hsc.googlegroups.com> paltalk crack http://crack.cracksofts.com From sierra9162 at gmail.com Wed Apr 16 11:22:31 2008 From: sierra9162 at gmail.com (sierra9162 at gmail.com) Date: Wed, 16 Apr 2008 08:22:31 -0700 (PDT) Subject: kate hudson thong Message-ID: <4215eb91-ae4e-4c1c-8fd8-6121c8e6e579@d1g2000hsg.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From gagsl-py2 at yahoo.com.ar Thu Apr 10 22:01:41 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 23:01:41 -0300 Subject: String Literal to Blob References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> <47FCF421.6000807@holdenweb.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> Message-ID: En Thu, 10 Apr 2008 14:04:43 -0300, Victor Subervi escribi?: > Well, what I did was this: > > content = col_fields[0][14].tostring() > pic = "tmp" + str(i) + ".jpg" > img = open(pic, "w") > img.write(content) > print '

' % pic > img.close() > where I am incrementing i. Ugly. Stupid. But if it is the only way to do > it > in python, and I do not want to invest the time doing it in php, which I > think would be prettier in this instance, then I guess it will do. Your > thoughts appreciated. You REALLY should read some material on how HTTP works. I'll try to sketch a few important points. First, suppose you have an HTML page (album.html) with two images in it:

This is me: and this is my cat Suppose the URL for that page is http://some.server.com/gabriel/album.html and you type that in your favorite browser. This is what happens: 1) The sees the initial "http:" and says "I'll use HTTP". Then sees "some.server.com" and opens a connection to that server on port 80. Then sees "/gabriel.album.html" and builds an HTTP GET request for it. 2) The server receives the GET request, looks for the "album.html" document, determines the right Content-Type, and returns it specifying "Content-Type: text/html" 3) The browser receives the HTML text and tries to display it. When it encounters the first tag it looks at the src attribute; it doesn't know that image; so a *NEW* HTTP request is required. This time it says "GET /images/myself.jpg" 4) The server receives the GET request, looks for a file with that name, determines that it's a jpeg image, and returns its contents along with a "Content-Type: image/jpeg". 5) The browser receives the image and is able to display it. 6) The same thing happens with the second tag, there is a third HTTP GET request for it. Note that: - The images themselves *aren't* in the HTML page, they are somewhere else. HTML is text and contains ONLY the URI for the image. - THREE DIFFERENT requests are done to show that page. Each one returns A SINGLE OBJECT of A SINGLE TYPE. The above was using static HTML with static images. If you use CGI to generate dynamic content, it's the same thing. From the browser point of view, there is no difference: it still will generate three different requests for the three pieces (one html document with two images). Your CGI script (or scripts) will receive three different requests then: when requested for HTML, return HTML; when requested for an image, return an image. They are DIFFERENT things, DIFFERENT requests, happening at DIFFERENT times, so don't mix them. I think that combining Steve's responses and mine you now have enough information to be able to solve your problems. Perhaps if you re-read the whole thread from start you'll have now a better understanding of what's happening. -- Gabriel Genellina From jfgomez21 at gmail.com Wed Apr 9 18:33:40 2008 From: jfgomez21 at gmail.com (Jose) Date: Wed, 9 Apr 2008 15:33:40 -0700 (PDT) Subject: Module Conflicts Message-ID: <1592fad3-996b-4f62-ac12-42aff8272c21@8g2000hsu.googlegroups.com> I have a module named math.py in a package with some class definitions. I am trying to import the standard python math module inside of math.py but It seems to be importing itself. Is there any way around this problem without renaming my math.py file? From johnroth1 at gmail.com Sat Apr 12 13:22:28 2008 From: johnroth1 at gmail.com (John Roth) Date: Sat, 12 Apr 2008 10:22:28 -0700 (PDT) Subject: str(bytes) in Python 3.0 References: <87k5j3f7m8.fsf@pobox.com> Message-ID: <29f280cc-4b33-4863-beee-d231df3d9a61@u3g2000hsc.googlegroups.com> On Apr 12, 8:52 am, j... at pobox.com (John J. Lee) wrote: > Christian Heimes writes: > > Gabriel Genellina schrieb: > >> On the last line, str(x), I would expect 'abc' - same as str(x, 'ascii') > >> above. But I get the same as repr(x) - is this on purpose? > > > Yes, it's on purpose but it's a bug in your application to call str() on > > a bytes object or to compare bytes and unicode directly. Several months > > ago I added a bytes warning option to Python. Start Python as "python > > -bb" and try it again. ;) > > Why hasn't the one-argument str(bytes_obj) been designed to raise an > exception in Python 3? > > John Because it's a fundamental rule that you should be able to call str() on any object and get a sensible result. The reason that calling str() on a bytes object returns a bytes literal rather than an unadorned character string is that there are no default encodings or decodings: there is no way of determining what the corresponding string should be. John Roth From gagsl-py2 at yahoo.com.ar Thu Apr 10 04:45:28 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 10 Apr 2008 05:45:28 -0300 Subject: urgent question, about filesystem-files References: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> Message-ID: En Thu, 10 Apr 2008 05:11:09 -0300, bvidinli escribi?: > i started python programming a few months ago. > > now i need the code to understand if a file already opened in > filesystem by another process ? > > i looked at docs, howtos, but did not find related info. > note that normal file open/write operations in python, i know it. > > i specificly need to know that "is a file already open by some other > process other than python". The operating system is more relevant here than Python. Is it Windows, some Linux flavor, what? -- Gabriel Genellina From deets at nospam.web.de Sun Apr 27 15:29:45 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Sun, 27 Apr 2008 21:29:45 +0200 Subject: API's and hardware communication. Newbie In-Reply-To: <_MudnfZZ9uW0hY7VRVnyhwA@bt.com> References: <_MudnfZZ9uW0hY7VRVnyhwA@bt.com> Message-ID: <67k2i3F2or0toU1@mid.uni-berlin.de> > I am new to this group so 'Hello All' > > I have a PC which is running linux and in it have installed a digital > satellite card. I would like to write some software to access the card, > tune it and bring back video. Basically a home brew DVB-s application. > > Being a non/new programmer (apart from some basic too many years ago) I > decided to teach my self Python as from what i have read it's an easy and > powerfull language to learn. I have been at it a few weeks and am getting > on OK and finding it reasonably OK to pick up. > > The problem is i can find little to no information on programming for DVB > cards or on how to access the Linux tv API in Python but I can find lots of > information in C. This is making me think should i bother with Python and > just learn C even though this will probably take a lot longer. > > Can some one help me or point me at a resource somewhere or would it be best > to just learn C instead. > > I am aware this is a complicated little project for someone just starting > out but it will be a multifaceted program with loads of interesting > classes, functions and loops and i don't have to start with the really > difficult stuff first. I just want to know if it's possible under python to > access the DVB card and if so how? I can't comment on DVB-cards, but I have accessed a webcam under linux., in pure python. Even if you need *some* parts written in C for that (which might not even be the case), you should check if there isn't some library available that you can access using e.g. ctypes. Diez From jkrukoff at ltgc.com Tue Apr 8 19:14:07 2008 From: jkrukoff at ltgc.com (John Krukoff) Date: Tue, 08 Apr 2008 17:14:07 -0600 Subject: Converting a tuple to a list In-Reply-To: <00e601c899ca$6b3be4f0$0a01a8c0@mobile> References: <00ba01c899c5$14528ae0$0a01a8c0@mobile> <00e601c899ca$6b3be4f0$0a01a8c0@mobile> Message-ID: <1207696447.5750.38.camel@localhost.localdomain> On Wed, 2008-04-09 at 00:46 +0200, Gabriel Ibanez wrote: > Gabriel Ibanez wrote: > > Hi all .. > > > > I'm trying to using the map function to convert a tuple to a list, without > > success. > > > > I would like to have a lonely line that performs the same as loop of the > > next script: > > > > ------------------------------------------- > > # Conveting tuple -> list > > > > tupla = ((1,2), (3,4), (5,6)) > > > > print tupla > > > > lista = [] > > for a in tupla: > > for b in a: > > lista.append(b) > > print lista > > ------------------------------------------- > > > > Any idea ? > > > > Thanks ... > > > > # Gabriel > > > > list(tupla) > > would probably do it. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ > > > -- > http://mail.python.org/mailman/listinfo/python-list > > > > > That would just make a list of tuples, I think he wants [1, 2, 3, 4, 5, 6]. > > Try: l = [x for z in t for x in z] > > --Brian > > > --------------- > > > Thanks Steve and Brian, > > Brian: that is !! > > However, it's a bit difficult to understand now. I have read it several > times :) > > Another solution using the itertools module: >>> import itertools >>> t = ( ( 1, 2 ), ( 3, 4 ), ( 5, 6 ) ) >>> list( itertools.chain( *t ) ) [1, 2, 3, 4, 5, 6] Though the list part is probably unnecessary for most uses. The problem gets interesting when you want to recursively flatten an iterable of arbitratrily deeply nested iterables. -- John Krukoff Land Title Guarantee Company From fd.calabrese at gmail.com Tue Apr 8 16:51:21 2008 From: fd.calabrese at gmail.com (cesco) Date: Tue, 8 Apr 2008 13:51:21 -0700 (PDT) Subject: __init__.py file Message-ID: Hi, I need to instantiate an object (my_object) whose methods I have to use in two files (file1.py and file2.py) which are in the same directory. Is it possible to instantiate such object in the __init__.py file and then directly use it in file1.py and file2.py? If not, as I seem to experience, what is the best practice to follow in this case? (I thought __init__.py was somehow useful for that). Many thanks Francesco From lbonafide at yahoo.com Wed Apr 2 08:05:18 2008 From: lbonafide at yahoo.com (lbonafide at yahoo.com) Date: Wed, 2 Apr 2008 05:05:18 -0700 (PDT) Subject: Where can I find : References: <47f10c4a$0$906$ba4acef3@news.orange.fr> Message-ID: <84847b99-18a4-4fe0-a2ee-433b63fe9ee8@e67g2000hsa.googlegroups.com> On Mar 31, 11:07 am, Laurent Pointal wrote: > You may look at "Dive into Python", there is an online version, > translation in some languages other than english (if needed). It propose > a line by line explanation on many scripts targetting language and > libraries usage. > > http://www.diveintopython.org/ I second that recommendation and was about to post the link myself. From arnodel at googlemail.com Sat Apr 26 02:53:51 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sat, 26 Apr 2008 07:53:51 +0100 Subject: multiple pattern regular expression References: Message-ID: Chris Henry writes: > On Apr 25, 8:37?pm, Arnaud Delobelle wrote: >> micron_make writes: >> > I am trying to parse a file whose contents are : >> >> > parameter=current >> > max=5A >> > min=2A > [snip] >> If every line of the file is of the form name=value, then regexps are >> indeed not needed. ?You could do something like that. >> >> params = {} >> for line in file: >> ? ? name, value = line.strip().split('=', 2) ^ 1, obviously! >> ? ? params[name] = value >> >> (untested) >> Then params should be the dictionary you want. >> > I'm also interested in this problem. While this solution works, I'm > looking for solution that will also check whether the parameter name/ > value is of a certain pattern (these patterns may be different, e.g. > paramA, paramB, paramC may take integers value, while paramD may take > true/false). Is there a way to do this easily? > > I'm new to Python and the solution I can think off involve a loop over > a switch (a dictionary with name->function mapping). Is there other, > more elegant solution? Sounds good to me. E.g. def boolean(x): if x == 'true': return True elif x == 'false' return False else: raise ValueError("Invalid boolean: '%s'" % x) paramtypes = { 'paramA': int, ..., 'paramD': boolean } #Then for line in file: line = line.strip() if not line: continue name, value = line.split('=', 1) if name in paramtypes: try: value = paramtypes[name](value) except ValueError, e: # handle the error value = e else: # What to do for untyped parameters pass params[name] = value -- Arnaud From n00m at narod.ru Wed Apr 30 09:57:08 2008 From: n00m at narod.ru (n00m) Date: Wed, 30 Apr 2008 06:57:08 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <2d06b319-e2fd-4790-af61-6f90b9b1b3b1@m1g2000pre.googlegroups.com> <41e72e61-6413-41f3-a162-dbcc1ec5fcee@f63g2000hsf.googlegroups.com> Message-ID: >>> a = ['zzz', 'aaa'] >>> id(a[0]), id(a[1]) (12258848, 12259296) >>> a.sort() >>> id(a[0]), id(a[1]) (12259296, 12258848) >>> From kf9150 at gmail.com Wed Apr 9 13:35:01 2008 From: kf9150 at gmail.com (Kelie) Date: Wed, 9 Apr 2008 10:35:01 -0700 (PDT) Subject: question about string formatting References: <42b9a3ff0804091004s4d60751fh68c82673e8e3f4c3@mail.gmail.com> Message-ID: <3f39bc89-196f-474a-90dc-bb081e3aa4d1@q27g2000prf.googlegroups.com> Thank you Jerry! -- Kelie UliPad is my Python editor. From larry.bates at websafe.com` Tue Apr 8 16:01:36 2008 From: larry.bates at websafe.com` (Larry Bates) Date: Tue, 08 Apr 2008 15:01:36 -0500 Subject: Running a python code periodically In-Reply-To: References: Message-ID: paul wrote: > Maryam Saeedi schrieb: >> Hi, >> >> I was wondering if you know how can I run a python code once every five >> minutes for a period of time either using python or some other program >> like >> a bash script. > > See the sched module in the standard library or here: > http://pypi.python.org/simple/Recur/ > > cheers > Paul > You could use cron also. -Larry From ptmcg at austin.rr.com Wed Apr 23 22:05:35 2008 From: ptmcg at austin.rr.com (Paul McGuire) Date: Wed, 23 Apr 2008 19:05:35 -0700 (PDT) Subject: Ideas for parsing this text? References: Message-ID: <84fd2882-f46d-43d4-9a1c-0b981fb45ad6@59g2000hsb.googlegroups.com> On Apr 23, 8:00?pm, "Eric Wertman" wrote: > I have a set of files with this kind of content (it's dumped from WebSphere): > > [propertySet "[[resourceProperties "[[[description "This is a required > property. This is an actual database name, and its not the locally > catalogued database name. The Universal JDBC Driver does not rely on > ... A couple of comments first: - What is the significance of '"[' vs. '[' ? I stripped them all out using text = text.replace('"[','[') - Your input text was missing 5 trailing ]'s. Here's the parser I used, using pyparsing: from pyparsing import nestedExpr,Word,alphanums,QuotedString from pprint import pprint content = Word(alphanums+"_.") | QuotedString('"',multiline=True) structure = nestedExpr("[", "]", content).parseString(text) pprint(structure.asList()) Prints (I've truncated the long lines, but the long quoted strings do parse intact): [['propertySet', [['resourceProperties', [[['description', 'This is a required \nproperty. This is an actual data... ['name', 'databaseName'], ['required', 'true'], ['type', 'java.lang.String'], ['value', 'DB2Foo']], [['description', 'The JDBC connectivity-type of a data \nsource. If you... ['name', 'driverType'], ['required', 'true'], ['type', 'java.lang.Integer'], ['value', '4']], [['description', '"The TCP/IP address or host name for the DRDA server."'], ['name', 'serverName'], ['required', 'false'], ['type', 'java.lang.String'], ['value', 'ServerFoo']], [['description', 'The TCP/IP port number where the \nDRDA server resides.'], ['name', 'portNumber'], ['required', 'false'], ['type', 'java.lang.Integer'], ['value', '007']], [['description', '"The description of this datasource."'], ['name', 'description'], ['required', 'false'], ['type', 'java.lang.String'], ['value', []]], [['description', 'The DB2 trace level for logging to the \nlogWriter ... ['name', 'traceLevel'], ['required', 'false'], ['type', 'java.lang.Integer'], ['value', []]], [['description', 'The trace file to store the trace output. \nIf you ... ]]]]]]] -- Paul The pyparsing wiki is at http://pyparsing.wikispaces.com. From donn at u.washington.edu Wed Apr 16 17:55:12 2008 From: donn at u.washington.edu (Donn Cave) Date: Wed, 16 Apr 2008 14:55:12 -0700 Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <6dba94c6-b635-41c1-9cf4-b4d4544930b6@d26g2000prg.googlegroups.com> <09a38ca2-8c49-4eee-b6cf-58e849aea1fc@q1g2000prf.googlegroups.com> Message-ID: In article , Steve Holden wrote: > Aaron Watters wrote: > > The cost paid for these minor improvements is too high in my > > book. But I suppose if it is going to happen do it sooner > > rather than later. Just *please* *please* don't > > systematically break the pre-existing code base again for a > > very long time, preferable ever. > > I'm pretty sure the 3.0 compatibility breakage is a one-shot deal. If > it's not I won't be the only one looking for Guido with a bog stick in > my hand ... Depending on what you mean, that appears to be either a truism or an absurdity. If you mean, 3.1 won't break code like 3.0 did ... well, of course. If you mean, there won't be a 4.0 that means the same thing for compatibility that 3.0 means, then I can't imagine how you could be convinced of this. Changes to Python in 3.0 won't satisfy the continuing "need" for change thereafter. Donn Cave, donn at u.washington.edu From jgardner at jonathangardner.net Thu Apr 17 13:03:26 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Thu, 17 Apr 2008 10:03:26 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> Message-ID: <431ee8d9-4dd6-4abf-a1a4-55e5be82d535@x41g2000hsb.googlegroups.com> On Apr 17, 1:18 am, Carl Banks wrote: > On Apr 17, 3:37 am, Jonathan Gardner > wrote: > > If you can't rewrite > > your algorithm to be disk or network bound, next optimization step is > > C. > > I'm sorry, but I don't like being told to use C. Perhaps I would like > the expressiveness of Python, am willing to accept the cost in > performance, but would also like to take advantage of technology to > get performance gains when I can? What's so unreasonable about that? > If you're satisfied then don't take the next optimization step. From subhabrata.iisc at hotmail.com Wed Apr 9 09:27:33 2008 From: subhabrata.iisc at hotmail.com (subhabrata.iisc at hotmail.com) Date: Wed, 9 Apr 2008 06:27:33 -0700 (PDT) Subject: PROBLEMS WITH PYTHON IN SOME VARIABLE,FUNCTIONS,ETC. References: <1d79b7e2-794a-4bf4-a734-e835c540a6db@x19g2000prg.googlegroups.com> <99f97573-3bda-400b-beee-1f94c3c254a9@x19g2000prg.googlegroups.com> Message-ID: <3ba6cb7c-79b9-4762-874d-ade5da3b507b@q1g2000prf.googlegroups.com> Hi Steve, comp.lang.python is supposed to be a serious group not anyone knowing nothing and giving comment. Well, original code snippet I don't know why an expert person like you fails to understand, I told it almost can't you guess the next portion? Tough indeed, then. I've to take permission from my organization if we can bring out this code in public domain as we are working out an MT system that performs better than Systran. And if it is a public domain I donot have security for my code. Any one can copy. But well if this group people are helping out of kindness, then I have to think. I thought if you know then only you can help. I am waiting for a knowledgeable answer from a knowledgeable person. I think I can show a person right direction only if I know it, that is not kindness but power of my knowledge. Let me solve it myself only, I will let you know how I solved them and with many are quite innovative. Like you can use index or re.search or in/not in instead of find.... Sad to have a response from a person like you I had just great hope, and when python can be coded so fast. Best Regards, Subhabrata. Steve Holden wrote: > subhabrata.iisc at hotmail.com wrote: > [...] > > > If you know anyone in Bangalore, India expert in python kindly > > send him across I can show him the problem in my machine and Indian > > Institute of Science(IISc-locally known as TATA INSTITUTE) is a > > distinguished place.Any one should know it. > > I am in no mood of doing a joke. > > [...] > > >> I have a car. I have turned the ignition key but it fails to start. > >> Please tell me what is wrong with it. > >> > Please understand: this is the Internet. The chances that a random > responder will know anyone in Bangalore are vanishingly small. > > I wasn't joking: I was simply (perhaps sarcastically) pointing out that > you do not provide enough information for anyone to help with your > problem, since you don't explain what the problem is. > > Fortunately nobody is under any obligation to help here, it's simply > done out of kindness. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > Holden Web LLC http://www.holdenweb.com/ From carlwuhwdmckay at gmail.com Mon Apr 21 02:07:50 2008 From: carlwuhwdmckay at gmail.com (carlwuhwdmckay at gmail.com) Date: Sun, 20 Apr 2008 23:07:50 -0700 (PDT) Subject: antivir keygen Message-ID: <4189fad5-0c37-4eac-b939-e6a690803b9a@l42g2000hsc.googlegroups.com> antivir keygen http://cracks.00bp.com F R E E C R A C K S From ankitks.mital at gmail.com Fri Apr 4 17:08:57 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Fri, 4 Apr 2008 14:08:57 -0700 (PDT) Subject: python bisect questions References: <6bb6927b-f553-40db-a142-2ce86b9e819f@q27g2000prf.googlegroups.com> Message-ID: > > b) Define a function to extract a "key" from your items such that items ? > compare the same as their keys. For example, key(x) -> x.lower() may be ? > used to compare text case-insensitively. > Then, use a tuple (key, value) instead of the bare value. When extracting ? > items from the queue, remember to unpack both parts. This is known as the ? > decorate-sort-undecorate pattern; google for it. > This is the approach used on your code snippet. > > > def keyfunc(x): > ? ? ?return x.lower() > > x1 = "bcd" > x2 = "abC" > x3 = "Z" > x4 = "AbC" > queue = [] > insort(queue, (keyfunc(x1),x1)) > print queue > insort(queue, (keyfunc(x2),x2)) > print queue > insort(queue, (keyfunc(x3),x3)) > print queue > insort(queue, (keyfunc(x4),x4)) > print queue > print [value for (key,value) in queue] > I liked decorate-sort-undecorate pattern idea. But is there anyway I can provide information for tie breaking. so for case, where keyfunc(x) returns same values, I need to provide additional tie-breaking rules, is that possible to do? From steve at holdenweb.com Mon Apr 7 14:39:07 2008 From: steve at holdenweb.com (Steve Holden) Date: Mon, 07 Apr 2008 14:39:07 -0400 Subject: Tips for load balancing multiple Python apps on dual/quad core processors? In-Reply-To: <1207592129.27594.1246549665@webmail.messagingengine.com> References: <1207592129.27594.1246549665@webmail.messagingengine.com> Message-ID: <47FA6A4B.4020906@holdenweb.com> Malcolm Greene wrote: > I'm looking for tips on how to load balance running multiple Python > applications in multi-CPU environments. My understanding is that Python > applications and their threads are limited to a specific CPU. > > Background: I have a Python utility that processes email messages. I > suspect there's a lot of idle time while this utility waits on a remote > email server. I would like to run as many simultaneous copies of this > utility as possible without overwhelming the server these utilities are > running on. My thought is that I should write a dispatcher that monitors > CPU load and launches/cancels multiple instances of my utility with > specific job queues to process. > > Is there a cross-platform way to monitor CPU load? > > Is there a pre-existing Python module I should be looking at for > building (subclassing) my dispatcher? > As a data point for you, I wrote a multi-threaded application that used 100 threads to send about 45,000 emails in less than four hours. The single-CPU computer that processed this job wasn't using that much CPU (certainly under 50%). regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From mail.ilocke at gmail.com Fri Apr 4 21:59:35 2008 From: mail.ilocke at gmail.com (ivan) Date: Fri, 4 Apr 2008 18:59:35 -0700 (PDT) Subject: Python-by-example - new online guide to Python Standard Library References: <47f2d018$0$6517$4c368faf@roadrunner.com> <47f617b0$0$16689$4c368faf@roadrunner.com> Message-ID: Very cool. Have you thought about making a printable version that doesn't wrap any lines that shouldn't be and has page breaks at good spots? -- ivan From ivory91044 at gmail.com Tue Apr 29 04:56:47 2008 From: ivory91044 at gmail.com (ivory91044 at gmail.com) Date: Tue, 29 Apr 2008 01:56:47 -0700 (PDT) Subject: my personal translator crack Message-ID: <1501250c-7ec9-42d2-92ab-298e73d2c727@d1g2000hsg.googlegroups.com> my personal translator crack http://crack.cracksofts.com From kyosohma at gmail.com Wed Apr 23 13:10:46 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Wed, 23 Apr 2008 10:10:46 -0700 (PDT) Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> Message-ID: On Apr 23, 11:47?am, John Nagle wrote: > Mike Driscoll wrote: > > Ken, > > > On Tue, Apr 22, 2008 at 1:36 PM, Kenneth McDonald > > wrote: > >> Sadly. > > >> ?Thanks, > >> ?Ken > >> ?-- > >> ?http://mail.python.org/mailman/listinfo/python-list > > > I've attached the 2.4 version. I also have some Windows binaries for > > Beautiful Soup uploaded to my website: > >http://www.pythonlibrary.org/python_modules.htm > > ? ? What on earth do you need a "Windows binary" for? ?"BeautifulSoup" > is ONE PYTHON SOURCE FILE, "BeautifulSoup.py". ?It can be downloaded > here: > > http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup.py > > And yes, the site is up. > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? John Nagle I don't need it and hadn't really planned on doing it, but I got a request for one. Besides, newbs don't necessarily know where to stick a module... Mike From rdm at rcblue.com Wed Apr 23 01:50:00 2008 From: rdm at rcblue.com (Dick Moores) Date: Tue, 22 Apr 2008 22:50:00 -0700 Subject: IDLE gripe and question In-Reply-To: <95f218ba-4925-491a-bf9c-047ac201e0c7@2g2000hsn.googlegroup s.com> References: <95f218ba-4925-491a-bf9c-047ac201e0c7@2g2000hsn.googlegroups.com> Message-ID: <20080423055021.3FBB51E4008@bag.python.org> At 09:30 PM 4/22/2008, Mensanator wrote: >First, find the shortcut that lauches IDLE. > >On my Vista system it's in >C:\Program Data\Microsoft\Windows\Start Menu\Programs\Python 2.5 > >XP will be different, I think there're start menu directories under >each user and a default one. > >Anyway, once you have the shortcut (mine was named IDLE (Python GUI)), >right-click and select Properties. > >There's a property attribute labeled Start In. >Set that to the directory where your scripts are. >The menu Open will now default to that directory. Yes! That did it. Thanks! Dick Moores ================================ UliPad <>: http://code.google.com/p/ulipad/ From fr5478bey at gmail.com Sat Apr 26 11:41:19 2008 From: fr5478bey at gmail.com (fr5478bey at gmail.com) Date: Sat, 26 Apr 2008 08:41:19 -0700 (PDT) Subject: photoshop cs crack Message-ID: <3b65cf9a-ae8e-44cb-b170-f5649184aa7b@a70g2000hsh.googlegroups.com> photoshop cs crack http://cracks.00bp.com F R E E C R A C K S From robert.spilleboudt.no.sp.am at skynet.be Wed Apr 30 04:58:06 2008 From: robert.spilleboudt.no.sp.am at skynet.be (Robert.Spilleboudt ) Date: Wed, 30 Apr 2008 10:58:06 +0200 Subject: Simple TK Question - refreshing the canvas when not in focus In-Reply-To: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> References: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> Message-ID: <4818349e$0$2959$ba620e4c@news.skynet.be> blaine wrote: > Hey everyone! > I'm not very good with Tk, and I am using a very simple canvas to > draw some pictures (this relates to that nokia screen emulator I had a > post about a few days ago). > > Anyway, all is well, except one thing. When I am not in the program, > and the program receives a draw command (from a FIFO pipe), the canvas > does not refresh until I click into the program. How do I force it to > refresh, or force the window to gain focus? It seems like pretty > common behavior, but a few things that I've tried have not worked. > > Class screen(): > def __init__(self): > self.root = Tkinter.Tk() > self.root.title('Nokia Canvas') > self.canvas = Tkinter.Canvas(self.root, width =130, > height=130) > self.canvas.pack() > self.root.mainloop() > > Then somewhere a long the line I do: > self.canvas.create_line(args[0], args[1], args[2], > args[3], fill=color) > self.canvas.pack() > > I've tried self.root.set_focus(), self.root.force_focus(), > self.canvas.update(), etc. but I can't get it. > Thanks! > Blaine When you read the pipe, do you generate an event? Probably not , and Tk is event-driven and should never update the canvas if there is no event. This is how I understand Tk. I have a Tk program who reads a audio signal (from an RC transmitter) . I generate a event every 100 msec , and "process" refresh the canvas. Starting the sequence: id = root.after(100,process) will call "process" after 100 msec At the end of "process", repeat: id = root.after(100,process) Robert From mtobis at gmail.com Tue Apr 15 14:13:02 2008 From: mtobis at gmail.com (Michael Tobis) Date: Tue, 15 Apr 2008 11:13:02 -0700 (PDT) Subject: Preferred method for "Assignment by value" References: <6a3ed8f0-b82c-4cd3-b36e-1d94f8a30fe3@n1g2000prb.googlegroups.com> <7047986d-f6cc-4189-81f6-47da1ecf1902@k1g2000prb.googlegroups.com> Message-ID: <53dc16b4-08b3-4433-be43-ea28af3668a1@i36g2000prf.googlegroups.com> http://effbot.org/zone/python-objects.htm still says it best. mt From dave.l.harrison at gmail.com Tue Apr 8 23:26:28 2008 From: dave.l.harrison at gmail.com (David Harrison) Date: Wed, 9 Apr 2008 13:26:28 +1000 Subject: Sorting a List of Objects by an Attribute of the Objects Case-Insensitively In-Reply-To: <736fefbd-510f-40e9-8342-32b69a1a0c2a@t12g2000prg.googlegroups.com> References: <736fefbd-510f-40e9-8342-32b69a1a0c2a@t12g2000prg.googlegroups.com> Message-ID: On 09/04/2008, Jason wrote: > Hi folks-- > > Basically, I have a pressing need for a combination of 5.2 "Sorting a > List of Strings Case-Insensitively" & 5.3 "Sorting a List of Objects > by an Attribute of the Objects" from the Python Cookbook. > > My first guess isn't working: > > import operator > def sort_by_attr(seq, attr): > key=operator.attrgetter(attr) > key=str.lower > return sorted(seq, key) > > ...would much appreciate any guidance! You're probably looking for the built-in function sorted, e.g. class Foo: def __init__(self, value): self.value = value def __repr__(self): return self.value a = [Foo('c'), Foo('B'), Foo('A')] print sorted( a, cmp=lambda x,y: cmp(x.lower(), y.lower()), key=lambda x: x.value ) From tarun.kap at gmail.com Tue Apr 8 15:52:49 2008 From: tarun.kap at gmail.com (TkNeo) Date: Tue, 8 Apr 2008 12:52:49 -0700 (PDT) Subject: calling variable function name ? Message-ID: I don't know the exact terminology in python, but this is something i am trying to do i have 3 functions lets say FA(param1,param2) FB(param1,param2) FC(param1,param2) temp = "B" #something entered by user. now i want to call FB. I don't want to do an if else because if have way too many methods like this... var = "F" + temp var(param1, param2) This does not work ofcourse. Does anyone know how to implement this ? From rune.strand at gmail.com Fri Apr 11 14:19:59 2008 From: rune.strand at gmail.com (Rune Strand) Date: Fri, 11 Apr 2008 11:19:59 -0700 (PDT) Subject: How is GUI programming in Python? References: Message-ID: <6fd8ce56-cba7-41b5-8751-80fd5bc06b4b@a9g2000prl.googlegroups.com> On Apr 10, 3:54 am, Chris Stewart wrote: ... > > Next, what would you say is the best framework I should look into? > I'm curious to hear opinions on that. GUI-programming in Python is a neanderthal experience. What one may love with console scripts is turned upside-down. Projects like Boa Constructor seemed to be a remedy, but is not developed. The Iron- Pythonistas has a very promising RAD GUI-tool in the IronPython - Studio, http://www.codeplex.com/IronPythonStudio - but if you're non- Iron, only sorrow is left - unless you fancy creating GUI in a text- editor. Something I consider waste of life. From george.sakkis at gmail.com Sun Apr 20 17:26:03 2008 From: george.sakkis at gmail.com (George Sakkis) Date: Sun, 20 Apr 2008 14:26:03 -0700 (PDT) Subject: Alternate indent proposal for python 3000 References: <53d36b08-183c-4ced-820c-3b76e9ad68a2@f63g2000hsf.googlegroups.com> <1d7f2d78-11fd-49f4-877c-73e95f449332@b64g2000hsa.googlegroups.com> Message-ID: <3d77e91e-46a9-4209-9b74-59dbab06aec4@m3g2000hsc.googlegroups.com> On Apr 20, 12:34?pm, Eric Wertman wrote: > > Look into any of the dozen Python-based template engines that are > > typically used for such tasks; they offer many more features than a > > way to indent blocks. > > > George > > I definitely will.. could you throw out some examples though? > Thanks! > > Eric Start out here: http://wiki.python.org/moin/Templating As you can see there is no shortage of alternatives, which can be overwhelming. Cheetah used to be the most popular and it's still widely used, but these days Django templates, Genshi and Mako seem more prominent for web development. HTH, George From bj_666 at gmx.net Wed Apr 9 08:27:02 2008 From: bj_666 at gmx.net (Marc 'BlackJack' Rintsch) Date: 9 Apr 2008 12:27:02 GMT Subject: I am worried about Python 3 References: <77c208d1-8163-4acf-8e88-bd704e05bc04@e39g2000hsf.googlegroups.com> Message-ID: <663r0mF2iji99U1@mid.uni-berlin.de> On Wed, 09 Apr 2008 05:04:20 -0700, jmDesktop wrote: > If I continue in Python 2.5.x, am I making a mistake? Is it really > that different? No it's still Python and most things you've learned with 2.x stay the same. > Here is an excerpt that is causing me concern: > > Two new versions of the language are currently in development: version > 2.6, which retains backwards compatibility with previous releases; and > version 3.0, which breaks backwards compatibility to the extent that > even that simplest of programs, the classic 'Hello, World', will no > longer work in its current form. Sounds a bit like FUD. While it's true that the classic greeting will break because the ``print`` statement turned into a `print()` function, it's not a ground shaking change that makes all knowledge about 2.x obsolete or radically changes the look of Python programs. Old:: print 'Hello World' New:: print('Hello World') There will be a `2to3.py` program coming with Python?2.6 that tries to convert most changes automatically. You may have to change the 2.6 code in a way that makes the automatic conversion possible but it is a important goal for the Python developers to make the transition as smooth as possible as far as I can tell. Ciao, Marc 'BlackJack' Rintsch From wwzaygvm at gmail.com Wed Apr 16 16:56:57 2008 From: wwzaygvm at gmail.com (wwzaygvm at gmail.com) Date: Wed, 16 Apr 2008 13:56:57 -0700 (PDT) Subject: hippie patch work clothes and purses Message-ID: <05daadfc-1098-4946-90de-84ce0cc163c7@a9g2000prl.googlegroups.com> hippie patch work clothes and purses http://cracks.12w.net F R E E C R A C K S From bronger at physik.rwth-aachen.de Sat Apr 12 14:57:44 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Sat, 12 Apr 2008 20:57:44 +0200 Subject: How is GUI programming in Python? References: <7xbq4ifoz8.fsf@ruckus.brouhaha.com> <47fe5715$0$6838$2d805a3e@textnews.eweka.nl> <47fe7130$0$6838$2d805a3e@textnews.eweka.nl> <47ff8489$0$6841$2d805a3e@textnews.eweka.nl> <48010fe5$0$6840$2d805a3e@textnews.eweka.nl> Message-ID: <87ve2mx5nb.fsf@physik.rwth-aachen.de> Hall?chen! Michel Bouwmans writes: > Gabriel Genellina wrote: > >> Michel Bouwmans escribi?: >> >>> Gabriel Genellina wrote: >>> >>>> Another annoying thing with the Qt license is that you have to >>>> choose it at the very start of the project. You cannot develop >>>> something using the open source license and later decide to >>>> switch to the commercial licence and buy it. >>> >>> Unless you're a company with a risk of being checked for legal >>> software etc., you can always ignore that allthough not very >>> legal. >> >> I just ignore Qt itself. > > Then you're ignorant. What do you prefer than? Well ... don't expect answers that you like when you suggest doing something which is not allowed. > [...] > - WxPython is terribly unstable. I can't confirm that. When I chose wxPython after thorough consideration one year ago, my impression was that reports of instability were indeed frequent but rather old. Apparently, the situation had improved. Does your experience rely on recent use? Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From arnodel at googlemail.com Tue Apr 8 02:28:54 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Mon, 7 Apr 2008 23:28:54 -0700 (PDT) Subject: Translating keywords References: Message-ID: <432e22c6-7cd0-4a9c-b3bc-dea9fe4798d0@8g2000hsu.googlegroups.com> On Apr 8, 6:47 am, Arnaud Delobelle wrote: [...] > Although I would use ? and ? as aliases for all() > and exists() :) I mean all() and any() of course -- Arnaud From paddy3118 at netscape.net Sat Apr 19 06:35:11 2008 From: paddy3118 at netscape.net (Donald 'Paddy' McCarthy) Date: Sat, 19 Apr 2008 11:35:11 +0100 Subject: Python 2.5 adoption In-Reply-To: <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> References: <4808f30e$0$34489$742ec2ed@news.sonic.net> <23bf20ad-9996-4b79-97ef-7930a228c4a3@t54g2000hsg.googlegroups.com> Message-ID: Joseph Turian wrote: > Basically, we're planning on releasing it as open-source, and don't > want to alienate a large percentage of potential users. Then develop for 2.5 with an eye on what is to come this year in 2.6 with regard to already planned deprecations. - Paddy. From andreww at datanet.ab.ca Sat Apr 5 19:21:01 2008 From: andreww at datanet.ab.ca (Andrew Warkentin) Date: Sat, 05 Apr 2008 17:21:01 -0600 Subject: Best way to check if string is an integer? In-Reply-To: References: Message-ID: <47F8095D.40905@datanet.ab.ca> skanemupp at yahoo.se wrote: >which is the best way to check if a string is an number or a char? >could the 2nd example be very expensive timewise if i have to check a >lot of strings? > >this > >value = raw_input() > >try: > value = int(value) >except ValueError: > print "value is not an integer" > > >or: > > >c=raw_input("yo: ") >if c in '0123456789': > print "integer" >else: > print "char" > > > >or some other way? > > I always do it the first way. It is simpler, and should be faster. Also, the second way will only work on single-digit numbers (you would have to iterate over the entire string with a for loop to use it on numbers with more than one digit). From paul.anton.letnes at gmail.com Wed Apr 9 16:44:43 2008 From: paul.anton.letnes at gmail.com (Paul Anton Letnes) Date: Wed, 9 Apr 2008 22:44:43 +0200 Subject: wrapping C functions in python In-Reply-To: <54b165660804091322w690e5e64x85c3d8f082b411b2@mail.gmail.com> References: <54b165660804091322w690e5e64x85c3d8f082b411b2@mail.gmail.com> Message-ID: Hi, and thanks. However, being a newbie, I now have to ask: What is SWIG? I have heard the name before, but haven't understood what it is, why I need it, or similar. Could you please supply some hints? -Paul Den 9. april. 2008 kl. 22.22 skrev Brian Cole: > We use the following SWIG (www.swig.org) typemap to perform such > operations: > > %typemap(in) (int argc, char **argv) { > if (!PySequence_Check($input)) { > PyErr_SetString(PyExc_ValueError,"Expected a sequence"); > return NULL; > } > $1 = PySequence_Length($input); > $2 = (char**)alloca($1*sizeof(char*)); > for (Py_ssize_t i = 0; i < $1; ++i) { > PyObject *o = PySequence_GetItem($input, i); > $2[i] = PyString_AsString(o); > } > } > > That one works for mapping a python sequence (such as a list) into the > argc, argv arguments commonly passed into main. > > -Brian > > On Wed, Apr 9, 2008 at 2:13 PM, Paul Anton Letnes > wrote: >> Hello etc. >> >> >> I am a "scientific" user of Python, and hence have to write some >> performance >> critical algorithms. Right now, I am learning Python, so this is a >> "newbie" >> question. >> >> I would like to wrap some heavy C functions inside Python, >> specifically a >> wavelet transform. I am beginning to become aquainted with the >> functions >> PyArg_ParseTuple() and Py_BuildValue(). However, I am unable to >> figure out >> how to pass Python list -> C function or C array -> return value in >> Python. >> I manage to build and run the C function, print to screen, pass >> string as >> argument, return an int, etc. The thing which is missing is the magic >> array/list... >> >> >> Thanks in advance! I fart in your general direction. >> Paul. >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > -- > http://mail.python.org/mailman/listinfo/python-list From ivan.illarionov at gmail.com Tue Apr 29 15:15:16 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Tue, 29 Apr 2008 19:15:16 +0000 (UTC) Subject: list.reverse() References: <98306bd8-e41c-4fd0-beee-6ef5c6018e44@w74g2000hsh.googlegroups.com> Message-ID: On Tue, 29 Apr 2008 07:26:07 -0700, Paul McGuire wrote: > On Apr 28, 1:12?pm, Mark Bryan Yu wrote: >> This set of codes works: >> >> >>> x = range(5) >> >>> x.reverse() >> >>> x >> >> [4, 3, 2, 1, 0] >> >> > You can also use list slicing to get a reversed list: > >>>> x = range(5) >>>> x > [0, 1, 2, 3, 4] >>>> x[::-1] > [4, 3, 2, 1, 0] > > -- Paul More alternatives: >>> range(4, -1, -1) [4, 3, 2, 1, 0] >>> list(reversed(xrange(5))) [4, 3, 2, 1, 0] If you don't need a list the fastest thing will be xrange(4, -1, -1) -- Ivan From deets at nospam.web.de Wed Apr 16 09:14:15 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 16 Apr 2008 15:14:15 +0200 Subject: Python crashes consistently References: <66m7s3F2l8kitU1@mid.uni-berlin.de> Message-ID: <66mce3F2lat6uU1@mid.uni-berlin.de> > Just to clarify (sorry, I'm a bit of a command line newbie): > > Do you mean to install Python from the .dmg - i.e. into /usr/local/ > bin? Yes and No. Use the DMG - but it will install Python under /Library/Frameworks/Python.framework/... > And then to install Numpy directly as well (manually, from > source), then continue with the MacPorts installation of Gnumeric > (i.e. into /opt/local/)? No MacPorts. The problem is that these will rely on their python available - which seems not to work properly. I had no problems installing e.g. matplotlib which requires Numpy. do everything "by hand". I agree that MacPorts would be nice - but obviously you hit a road-block there. Diez From skanemupp at yahoo.se Sat Apr 5 10:47:06 2008 From: skanemupp at yahoo.se (skanemupp at yahoo.se) Date: Sat, 5 Apr 2008 07:47:06 -0700 (PDT) Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <65ondkF2g48puU2@mid.uni-berlin.de> Message-ID: > > def __init__(self): > # ... > button = Button(self, > text='1', > command=lambda n=1: self.display(n)) > # ... > > def display(self, number): > print number > should this really be inside the __init__ function? From maxerickson at gmail.com Sun Apr 13 16:00:27 2008 From: maxerickson at gmail.com (Max Erickson) Date: Sun, 13 Apr 2008 13:00:27 -0700 (PDT) Subject: urllib2 Basic authentication, what am I doing wrong? References: <48025b26$0$6839$2d805a3e@textnews.eweka.nl> Message-ID: <1b67f420-db80-4890-8370-6476063cfadf@f63g2000hsf.googlegroups.com> On Apr 13, 2:11?pm, Michel Bouwmans wrote: > Using this nice class (adapted to urllib2) as a basehandler I see that no > Authentication-header is being send out:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440574 > > What am I doing wrong here? I spend almost my entire free time today on this > and couldn't find any problem with my code, anyone else has a thought? > Thanks in advance. > > MFB I've attempted to use a password manager and auth manager and failed in the past, so this is only a guess, but presumably, between the realm and uri that you are providing to the password manager, it isn't providing a password for the page you want to load. I've had success just explicitly setting the authorization header, using the method discussed in the comments on this page: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/267197 max From sturlamolden at yahoo.no Fri Apr 25 10:45:45 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Fri, 25 Apr 2008 07:45:45 -0700 (PDT) Subject: why does the following with Queue, q.put('\x02', True) not put it in the queue? References: Message-ID: <6eb550ae-dca4-4371-856a-15bc9625f93c@z72g2000hsb.googlegroups.com> On Apr 25, 4:38 pm, Gabriel Rossetti wrote: > Hello, > > I'm having some trouble with the Queue class, for some reason, if I do > this (ch == ) : > > q = Queue.Queue(0) > repr(ch) > q.put(ch, True) > len(q.queue) >>> from Queue import Queue >>> q = Queue(0) >>> s = '\x02' >>> q.put(s,True) >>> len(q.queue) 1 From gagsl-py2 at yahoo.com.ar Wed Apr 9 03:45:28 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 09 Apr 2008 04:45:28 -0300 Subject: Setting default version among multiple python installations References: <47FB3F86.5040702@adventnet.com> <47FC57F8.40106@adventnet.com> Message-ID: En Wed, 09 Apr 2008 02:45:28 -0300, Karthik escribi?: > if i type python2.5 i am able to use the latest python, but if i simply > type python it taken me to the older version. (it is a minor annoyance, > but I want to know how to fix it) From the README file: There's an executable /usr/bin/python which is Python 1.5.2 on most older Red Hat installations; several key Red Hat tools require this version. Python 2.1.x may be installed as /usr/bin/python2. The Makefile installs Python as /usr/local/bin/python, which may or may not take precedence over /usr/bin/python, depending on how you have set up $PATH. -- Gabriel Genellina From castironpi at gmail.com Sun Apr 27 13:24:52 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Sun, 27 Apr 2008 10:24:52 -0700 (PDT) Subject: diffing and uniqing directories References: <67ioqmF2nvf5vU2@mid.uni-berlin.de> Message-ID: On Apr 27, 2:37?am, Marc 'BlackJack' Rintsch wrote: > On Sat, 26 Apr 2008 20:35:29 -0700, rustom wrote: > > On Apr 27, 12:31?am, castiro... at gmail.com wrote: > >> On Apr 26, 1:14?pm, "Rustom Mody" wrote: > >> [?] > > > If this is an answer to my question I dont understand it! > > castironpi is either a bot or trolling. ?Just ignore its posts. > > Ciao, > ? ? ? ? Marc 'BlackJack' Rintsch I am a bot or trolling. Bots and bot detectors were the first forms of internet life, you know. From bignose+hates-spam at benfinney.id.au Wed Apr 23 00:43:21 2008 From: bignose+hates-spam at benfinney.id.au (Ben Finney) Date: Wed, 23 Apr 2008 14:43:21 +1000 Subject: Python Success stories References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: <87fxtdyydy.fsf@benfinney.id.au> Steve Holden writes: > Challenge him to a dual with dead kippers at twenty paces. Please, have some dignity! Challenge him to a duel with live kippers. Live, *rabid* kippers. With frickin' laser beams on their heads. -- \ "A man's only as old as the woman he feels." -- Groucho Marx | `\ | _o__) | Ben Finney From phd at phd.pp.ru Thu Apr 24 04:17:35 2008 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 24 Apr 2008 12:17:35 +0400 Subject: [Python-Dev] annoying dictionary problem, non-existing keys In-Reply-To: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> References: <36e8a7020804240113m7cbd10efibfe9f9b68f6135ac@mail.gmail.com> Message-ID: <20080424081735.GA4028@phd.pp.ru> On Thu, Apr 24, 2008 at 11:13:25AM +0300, bvidinli wrote: > if conf.has_key('key1'): > if conf['key1']<>'': > other commands.... > > this is very annoying. > in php, i was able to code only like: > if conf['key1']=='someth' > > in python, this fails, because, if key1 does not exists, it raises an exception. if conf.get('key1')=='someth':... PS. Please do not cross-post so extensively. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From nagle at animats.com Wed Apr 23 17:27:03 2008 From: nagle at animats.com (John Nagle) Date: Wed, 23 Apr 2008 14:27:03 -0700 Subject: Where to get BeautifulSoup--www.crummy.com appears to be down. In-Reply-To: References: <030F019C-F296-4F79-B912-1196AAFD7093@sbcglobal.net> <480f6553$0$34545$742ec2ed@news.sonic.net> Message-ID: <480fa6e3$0$34491$742ec2ed@news.sonic.net> Tim Golden wrote: > John Nagle wrote: >> Mike Driscoll wrote: >>> Ken, >>> >>> On Tue, Apr 22, 2008 at 1:36 PM, Kenneth McDonald >>> wrote: >>>> Sadly. >>>> >>>> Thanks, >>>> Ken >>>> -- >>>> http://mail.python.org/mailman/listinfo/python-list >>>> >>> >>> I've attached the 2.4 version. I also have some Windows binaries for >>> Beautiful Soup uploaded to my website: >>> http://www.pythonlibrary.org/python_modules.htm >> >> What on earth do you need a "Windows binary" for? "BeautifulSoup" >> is ONE PYTHON SOURCE FILE, "BeautifulSoup.py". > > Ummm.. Why does it bother you? Mike seems to be offering a public > service to Windows users: by downloading the .exe, I can double-click > on one file, have the module or package installed (whether it contains > one .py file or twenty or a series of compiled extension modules and > their respective DLLs) and for a bonus it's registered in the system > packages directory [*] and is therefore uninstallable from there. Executing strange executables is risky. One always wonders what else they install in addition to what they're supposed be installing. John Nagle From patrick.waldo at gmail.com Tue Apr 1 06:36:52 2008 From: patrick.waldo at gmail.com (patrick.waldo at gmail.com) Date: Tue, 1 Apr 2008 03:36:52 -0700 (PDT) Subject: xlrd and cPickle.dump Message-ID: <34e62ddb-477f-4a99-97a5-21a7b148d244@e67g2000hsa.googlegroups.com> Hi all, Sorry for the repeat I needed to reform my question and had some problems...silly me. The xlrd documentation says: "Pickleable. Default is true. In Python 2.4 or earlier, setting to false will cause use of array.array objects which save some memory but can't be pickled. In Python 2.5, array.arrays are used unconditionally. Note: if you have large files that you need to read multiple times, it can be much faster to cPickle.dump() the xlrd.Book object once, and use cPickle.load() multiple times." I'm using Python 2.4 and I have an extremely large excel file that I need to work with. The documentation leads me to believe that cPickle will be a more efficient option, but I am having trouble pickling the excel file. So far, I have this: import cPickle,xlrd import pyExcelerator from pyExcelerator import * data_path = """C:\test.xls""" pickle_path = """C:\pickle.xls""" book = xlrd.open_workbook(data_path) Data_sheet = book.sheet_by_index(0) wb=pyExcelerator.Workbook() proc = wb.add_sheet("proc") #Neither of these work #1) pyExcelerator try #cPickle.dump(book,wb.save(pickle_path)) #2) Normal pickle try #pickle_file = open(pickle_path, 'w') #cPickle.dump(book, pickle_file) #file.close() Any ideas would be helpful. Otherwise, I won't pickle the excel file and deal with the lag time. Patrick From martin at v.loewis.de Tue Apr 22 14:17:32 2008 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 22 Apr 2008 20:17:32 +0200 Subject: Compiling Python 2.5.2 on AIX 5.2 In-Reply-To: References: <0b73e8e5-c301-4823-ac94-42f757456cf1@x19g2000prg.googlegroups.com> <48059DA9.5080900@v.loewis.de> <480c2364$0$26788$9b622d9e@news.freenet.de> Message-ID: <480e2bbc$0$24477$9b622d9e@news.freenet.de> > test test_mmap crashed -- : [Errno > 22] Invalid argument You should run this with -v. This is too little detail to know what exactly failed. > self.assertEqual(spid, cpid) > AssertionError: 0 != 6840386 > > What do these failures indicate? That suggests a bug in wait4: apparently, it fails to correctly return the PID. Could be an OS bug, but more likely, it's a type problem in Modules/posixmodule.c. Regards, Martin From cwitts at gmail.com Tue Apr 15 06:47:11 2008 From: cwitts at gmail.com (Chris) Date: Tue, 15 Apr 2008 03:47:11 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <1208196168.24295.36.camel@localhost.localdomain> <526792b1-acc2-4e48-8e9f-cc2641134958@k37g2000hsf.googlegroups.com> <732f1af2-ebae-4764-a40e-698ae1bde95f@h1g2000prh.googlegroups.com> Message-ID: <4d88216e-ffd2-48bf-a593-5d110c66dcf9@w5g2000prd.googlegroups.com> On Apr 15, 12:33?pm, Chris wrote: > On Apr 15, 11:47?am, Duncan Booth > wrote: > > > Chris wrote: > > > even is closer to even.75 than even+1.25. ?Why should it be rounded > > > up ? > > > Because the OP wants to round values to the nearest integer. Only values of > > the form 'x.5' which have two nearest values use 'nearest even' to > > disambiguate the result. > > > Seehttp://en.wikipedia.org/wiki/Rounding#Round-to-even_method > > > That's the way I was taught to round numbers when at primary school. > > My bad, didn't see he only wanted for halves and handle others as > normal. My contribution then: def my_round(x): if x < 0: NEG = 1 x = -x else: NEG = 0 if not x%.5 and not int(x)%2: if NEG: return -round(x-.1) return round(x-.1) elif not x%.5 and int(x)%2: if NEG: return -round(x+.1) return round(x+.1) elif NEG: return round(-x) else: return round(x) [(f*.25, my_round(f*.25)) for f in xrange(-20,20)] [(-5.0, -5.0), (-4.75, -5.0), (-4.5, -4.0), (-4.25, -4.0), (-4.0, -4.0), (-3.75, -4.0), (-3.5, -4.0), (-3.25, -3.0), (-3.0, -3.0), (-2.75, -3.0), (-2.5, -2.0), (-2.25, -2.0), (-2.0, -2.0), (-1.75, -2.0), (-1.5, -2.0), (-1.25, -1.0), (-1.0, -1.0), (-0.75, -1.0), (-0.5, 0.0), (-0.25, 0.0), (0.0, 0.0), (0.25, 0.0), (0.5, 0.0), (0.75, 1.0), (1.0, 1.0), (1.25, 1.0), (1.5, 2.0), (1.75, 2.0), (2.0, 2.0), (2.25, 2.0), (2.5, 2.0), (2.75, 3.0), (3.0, 3.0), (3.25, 3.0), (3.5, 4.0), (3.75, 4.0), (4.0, 4.0), (4.25, 4.0), (4.5, 4.0), (4.75, 5.0)] From lists at cheimes.de Fri Apr 25 17:45:59 2008 From: lists at cheimes.de (Christian Heimes) Date: Fri, 25 Apr 2008 23:45:59 +0200 Subject: Why is None <= 0 In-Reply-To: <481228DF.5010408@ulmcnett.com> References: <481228DF.5010408@ulmcnett.com> Message-ID: <48125117.9060907@cheimes.de> > In my humble opinion, I think that comparisons involving None should > return None, but I trust that the designers came up with this for very > good reasons. As far as I know I've never been bitten by it. It's fixed in Python 3.x. Python 3.x refuses to compare objects unless one of both objects has explicit support for both types: >>> 1 < None Traceback (most recent call last): File "", line 1, in TypeError: unorderable types: int() < NoneType() From Scott.Daniels at Acm.Org Sat Apr 26 00:02:18 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Fri, 25 Apr 2008 21:02:18 -0700 Subject: Is 2006 too old for a book on Python? In-Reply-To: References: Message-ID: jmDesktop wrote: > Hi, I wanted to buy a book on Python, but am concerned that some of > them are too old. One I had come to after much research was Core > Python by Wesley Chun. I looked at many others, but actually saw this > one in the store and liked it. However, it is from 2006. I know > there is free documentation and Dive Into Python. I just liked the > one in question and was hoping for thoughts on the age of it. I am > using Python 2.5.x and don' t know how different 2.3, 2,4 is from it. Look at http://rgruet.free.fr/ If you look at the 2.5 quick reference, several previous versions are included, with the differences color-coded. You can reassure yourself that the vast majority of the language remains the same. --Scott David Daniels Scott.Daniels at Acm.Org From wuwei23 at gmail.com Sat Apr 5 21:45:32 2008 From: wuwei23 at gmail.com (alex23) Date: Sat, 5 Apr 2008 18:45:32 -0700 (PDT) Subject: troll poll References: <65eee6F2eg18jU1@mid.uni-berlin.de> <143a9f24-668e-4e30-a803-c272da27f3ff@s13g2000prd.googlegroups.com> Message-ID: <93477f36-fd07-4659-b3ab-29b9cc35bb8d@w5g2000prd.googlegroups.com> (Aahz) wrote: > alex23 wrote: > > >The usual > >response to complaining about the lack of a killfile for Google Groups > >has been "use a decent client", but as I'm constantly moving between > >machines having a consistent app for usenet has more value to me. > > That's why I ssh into my ISP for trn3.6 ;-) So what you're saying is, basically, "use a decent client"? :) - alex23 From mdboldin at gmail.com Thu Apr 24 16:20:27 2008 From: mdboldin at gmail.com (mmm) Date: Thu, 24 Apr 2008 13:20:27 -0700 (PDT) Subject: DTD validation and xmlproc References: <480F8513.6040309@behnel.de> Message-ID: > Regarding ... try lxml. > http://codespeak.net/lxmlhttp://codespeak.net/lxml/tutorial.htmlhttp://codespeak.net/lxml/validation.html > Thx Stefan, it seems that lxml does everything I need. I have not figured out all of the bells and whistles but the tutorials are getting me up to speed. Based 2 days of trial, I can recommend lxml without reservation. From n00m at narod.ru Sun Apr 27 15:54:48 2008 From: n00m at narod.ru (n00m) Date: Sun, 27 Apr 2008 12:54:48 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <2d06b319-e2fd-4790-af61-6f90b9b1b3b1@m1g2000pre.googlegroups.com> <41e72e61-6413-41f3-a162-dbcc1ec5fcee@f63g2000hsf.googlegroups.com> Message-ID: <9776420a-c34d-425e-8598-eecf4bfd0d02@t63g2000hsf.googlegroups.com> Another PC, another OS (Linux) and another compiler C++ (g++ 4.0.0-8) Compare 2 my latest submissions: http://www.spoj.pl/status/SBANK,zzz/ times: 1.32s and 0.60s Submitted codes: import sys z=sys.stdin.readlines() print z[5] #include #include #include #include using namespace std; vector vs; int main() { while (true) { char line[50]; if (!fgets(line,50,stdin)) break; vs.push_back(line); } return 0; } If it proves nothing then white is black and good is evil From see.signature at no.spam Tue Apr 29 10:36:56 2008 From: see.signature at no.spam (Eric Brunel) Date: Tue, 29 Apr 2008 16:36:56 +0200 Subject: Simple TK Question - refreshing the canvas when not in focus References: <16d36d38-43fe-4863-8df7-02c60c18600c@j22g2000hsf.googlegroups.com> Message-ID: On Tue, 29 Apr 2008 15:22:12 +0200, blaine wrote: > Hey everyone! > I'm not very good with Tk, and I am using a very simple canvas to > draw some pictures (this relates to that nokia screen emulator I had a > post about a few days ago). > > Anyway, all is well, except one thing. When I am not in the program, > and the program receives a draw command (from a FIFO pipe), the canvas > does not refresh until I click into the program. How do I force it to > refresh, or force the window to gain focus? It seems like pretty > common behavior, but a few things that I've tried have not worked. > > Class screen(): > def __init__(self): > self.root = Tkinter.Tk() > self.root.title('Nokia Canvas') > self.canvas = Tkinter.Canvas(self.root, width =130, > height=130) > self.canvas.pack() > self.root.mainloop() > > Then somewhere a long the line I do: > self.canvas.create_line(args[0], args[1], args[2], > args[3], fill=color) > self.canvas.pack() Unrelated question: why are you doing a .pack() again here? Packing the widget just inserts it at the right place in its container, so you only have to do it once. So the one you did in __init__ is enough. > I've tried self.root.set_focus(), self.root.force_focus(), > self.canvas.update(), etc. but I can't get it. IIRC: - self.root.set_focus() will only work if your application already has the focus, so it's not what you need here. - self.root.force_focus() is usually considered as evil: it'll give the focus to your application whatever the user is doing, which is usually *really* annoying. So I guess a lot of window managers just refuse to do it; this may be what happens here. But self.canvas.update() should work. If it doesn't, then there are probably limitations on your platform that prevents it to work... Do you happen to have other applications that can update their display while they don't have the focus? Do they have the same problem? If they do, it's probably a limitation on the platform and I guess you won't be able to do anything about it... BTW, what platform are you on? > Thanks! > Blaine HTH -- python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])" From bwljgbwn at gmail.com Tue Apr 22 05:51:02 2008 From: bwljgbwn at gmail.com (bwljgbwn at gmail.com) Date: Tue, 22 Apr 2008 02:51:02 -0700 (PDT) Subject: paint shop pro keygen Message-ID: <47765661-a861-4bd7-b600-cd1e9747a7ea@c19g2000prf.googlegroups.com> paint shop pro keygen http://cracks.12w.net F R E E C R A C K S From xnews2 at fredp.lautre.net Thu Apr 17 11:48:15 2008 From: xnews2 at fredp.lautre.net (Fred Pacquier) Date: 17 Apr 2008 15:48:15 GMT Subject: PHATCH: PHoto bATCH processor with EXIF and IPTC support for all platforms References: <808b0684-19bc-432e-811b-590a451ac899@a22g2000hsc.googlegroups.com> Message-ID: "SPE - Stani's Python Editor" said : > What is new? Until Phatch could only save EXIF and IPTC tags on Linux. > Now this feature is available for all platforms hanks to the work of > Robin Mills who managed to compile pyexiv2 and all its dependencies > and get it to work on MacOS X (Tiger and Leopard, PPC and Intel) and > x86 Windows. > You can grab the libraries from here: > http://www.clanmills.com/articles/gpsexiftags/ (Look for "Download the > libraries click here" somewhere in the middle). > I have not tested this myself yet, but assumes that it will work. Any > volunteers to test this with Phatch That is great news, thanks ! I will certainly give it a try. From stefan_ml at behnel.de Mon Apr 21 03:00:28 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 21 Apr 2008 09:00:28 +0200 Subject: Conditional for...in failing with utf-8, Spanish book translation In-Reply-To: References: Message-ID: <480C3B8C.9080902@behnel.de> Hunter wrote: > I've narrowed the problem down to a simple test program. Check this out: > > --- > > # -*- coding: utf-8 -*- > > acceptable = "abcdefghijklmnopqrstuvwxyz????" # this line will work > acceptable = "abcdefghijklmnopqrstuvwxyz?????" # this line won't [bad words stripped] this should read acceptable = u"abcdefghijklmnopqrstuvwxyz????" acceptable = u"abcdefghijklmnopqrstuvwxyz?????" Mind the little "u" before the string, which makes it a unicode string instead of an encoded byte string. http://docs.python.org/tut/node5.html#SECTION005130000000000000000 Stefan From tdimson at gmail.com Tue Apr 8 19:49:27 2008 From: tdimson at gmail.com (Thomas Dimson) Date: Tue, 8 Apr 2008 16:49:27 -0700 (PDT) Subject: Ctypes and C Infinite Callback Loops Message-ID: Hello, I have quite a complex issue that is arising with regards to using ctypes to hook into some legacy code. The legacy code is in infinite loop - I can not touch this. It does some listening, and periodically calls a specific callback function. What I would like to be able to do is spawn a Python thread to handle this infinite loop, and continue on my merry way. This works to an extent, however if I try to raise the SystemExit exception (or any other one) inside of this thread I get an error message of "AssertionError: cannot join current thread". I assume there is some issue with the global interpreter lock or that you can't exit the infinite loop from above Python. Any suggestions on how I can design this so the thread will be able to issue exits/raise exceptions just like a regular thread? Is there a way of terminating this thread from the python interpreter or ctypes.pythonapi? I have also tried being sneaky by using a pthread in the C code, but I had issues when I tried to create a new thread state using ctypes.pythonapi (well, I had issues swapping it in when I get to the callback). If this is the best solution, how do I create/swap in the thread state from ctypes? For some cooked up sample code that simulates this: main.c (main.o -> main.so ) #include void loop( void (*callback)() ) { while( 1 ) { callback(); sleep(1); } } void testLoop( void (*callback)() ) { loop( callback ); } ************************************************ test.py: import threading,ctypes,time,sys,os soPath = os.path.join( "/home/tdimson/ctypes/main.so" ) class callLoop( threading.Thread ): def callback( self ): sys.exit() def run( self ): ctypes.cdll.LoadLibrary( soPath ) mainLib = ctypes.CDLL( soPath ) _callback = ctypes.CFUNCTYPE( None )( self.callback ) mainLib.testLoop( _callback ) loopThread = callLoop() loopThread.start() while 1: print "Not blocking" time.sleep(10) ******************************************** Then I execute: python test.py and get Not blocking Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/usr/lib/python2.4/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "/usr/lib/python2.4/threading.py", line 634, in __exitfunc t.join() File "/usr/lib/python2.4/threading.py", line 532, in join assert self is not currentThread(), "cannot join current thread" AssertionError: cannot join current thread Error in sys.exitfunc: Traceback (most recent call last): File "/usr/lib/python2.4/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "/usr/lib/python2.4/threading.py", line 634, in __exitfunc t.join() File "/usr/lib/python2.4/threading.py", line 532, in join assert self is not currentThread(), "cannot join current thread" AssertionError: cannot join current thread Thanks for even reading this much :) -Thomas Dimson From bvidinli at gmail.com Thu Apr 10 04:11:09 2008 From: bvidinli at gmail.com (bvidinli) Date: Thu, 10 Apr 2008 11:11:09 +0300 Subject: urgent question, about filesystem-files Message-ID: <36e8a7020804100111u5647cf7cl44a3ebe5196e42c@mail.gmail.com> i started python programming a few months ago. now i need the code to understand if a file already opened in filesystem by another process ? i looked at docs, howtos, but did not find related info. note that normal file open/write operations in python, i know it. i specificly need to know that "is a file already open by some other process other than python". Thank you in advance From gagsl-py2 at yahoo.com.ar Sun Apr 13 15:37:20 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 13 Apr 2008 16:37:20 -0300 Subject: toplevel, get latest entry? References: Message-ID: En Sat, 12 Apr 2008 17:50:36 -0300, escribi?: > windows vista and python 2.5, is there a way to get the latest command > entered? would be very useful. > > if not by default, anything i could download or write myself? Do you mean inside the interpreter? Use up arrow/down arrow. Type a few characters and press F8 to search for matches. F7 to select from a list. Courtesy of doskey. -- Gabriel Genellina From jgardner at jonathangardner.net Thu Apr 24 13:02:13 2008 From: jgardner at jonathangardner.net (Jonathan Gardner) Date: Thu, 24 Apr 2008 10:02:13 -0700 (PDT) Subject: How to find the parent of an old-style class? References: <9742ba66-eebf-43ba-8391-d0d0edb52c95@l42g2000hsc.googlegroups.com> Message-ID: <805bf888-722e-44a7-9c6a-66f9a28278af@b64g2000hsa.googlegroups.com> On Apr 24, 7:16?am, Jasper wrote: > I'm stuck using a library based on old style classes, and need to find > a class's parent at runtime. > > With new style classes you can use .__base__ to inspect a parent, but > I can't remember how this was done in days of yore, before object. > I've tried googling, but apparently my search term Fu is weak. :-( > > Can anyone help me out here? ?There must be something simple. > It's very odd that you need to know a class's parent. I'm interested in hearing why you need this. In all my years, I've never had to do this. Regardless, I believe you are looking for __bases__. From kf9150 at gmail.com Tue Apr 1 12:50:29 2008 From: kf9150 at gmail.com (Kelie) Date: Tue, 1 Apr 2008 09:50:29 -0700 (PDT) Subject: PyQt - How to prevent a dialog being resized? References: Message-ID: <281915c9-c4d1-4025-a46b-7cd4cc4b101a@s8g2000prg.googlegroups.com> Thanks to all. I used the approach suggested by David. From tom at vector-seven.com Wed Apr 16 19:23:53 2008 From: tom at vector-seven.com (Thomas Lee) Date: Thu, 17 Apr 2008 09:23:53 +1000 Subject: [Python-Dev] Global Python Sprint Weekends: May 10th-11th and June 21st-22nd. In-Reply-To: <87D3F9C72FBF214DB39FA4E3FE618CDC6E22F389FE@EXMBX04.exchhosting.com> References: <87D3F9C72FBF214DB39FA4E3FE618CDC6E22F389FE@EXMBX04.exchhosting.com> Message-ID: <48068A89.9000306@vector-seven.com> Anyone in Melbourne, Australia keen for the first sprint? I'm not sure if I'll be available, but if I can it'd be great to work with some others. Failing that, it's red bull and pizza in my lounge room :) I've been working on some neat code for an AST optimizer. If I'm free that weekend, I'll probably continue my work on that. Cheers, T Trent Nelson wrote: > Following on from the success of previous sprint/bugfix weekends and > sprinting efforts at PyCon 2008, I'd like to propose the next two > Global Python Sprint Weekends take place on the following dates: > > * May 10th-11th (four days after 2.6a3 and 3.0a5 are released) > * June 21st-22nd (~week before 2.6b2 and 3.0b2 are released) > > It seems there are a few of the Python User Groups keen on meeting > up in person and sprinting collaboratively, akin to PyCon, which I > highly recommend. I'd like to nominate Saturday across the board > as the day for PUGs to meet up in person, with Sunday geared more > towards an online collaboration day via IRC, where we can take care > of all the little things that got in our way of coding on Saturday > (like finalising/preparing/reviewing patches, updating tracker and > documentation, writing tests ;-). > > For User Groups that are planning on meeting up to collaborate, > please reply to this thread on python-dev at python.org and let every- > one know your intentions! > > As is commonly the case, #python-dev on irc.freenode.net will be > the place to be over the course of each sprint weekend; a large > proportion of Python developers with commit access will be present, > increasing the amount of eyes available to review and apply patches. > > For those that have an idea on areas they'd like to sprint on and > want to look for other developers to rope in (or just to communicate > plans in advance), please also feel free to jump on this thread via > python-dev@ and indicate your intentions. > > For those that haven't the foggiest on what to work on, but would > like to contribute, the bugs tracker at http://bugs.python.org is > the best place to start. Register an account and start searching > for issues that you'd be able to lend a hand with. > > All contributors that submit code patches or documentation updates > will typically get listed in Misc/ACKS.txt; come September when the > final release of 2.6 and 3.0 come about, you'll be able to point at > the tarball or .msi and exclaim loudly ``I helped build that!'', > and actually back it up with hard evidence ;-) > > Bring on the pizza and Red Bull! > > Trent. > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: http://mail.python.org/mailman/options/python-dev/krumms%40gmail.com > From bdsatish at gmail.com Fri Apr 11 07:32:13 2008 From: bdsatish at gmail.com (bdsatish) Date: Fri, 11 Apr 2008 04:32:13 -0700 (PDT) Subject: Rounding a number to nearest even References: <13bc2bba-d3f1-4a9d-9e1e-4c34509d3ac2@k10g2000prm.googlegroups.com> <9e4a41a2-f284-4e57-9510-e1cfdf90bd3f@b1g2000hsg.googlegroups.com> <55544ece-b49f-4e24-8d85-7725241b307b@1g2000prf.googlegroups.com> <6dd58852-9121-42f7-91b0-bac847a7b110@c65g2000hsa.googlegroups.com> <27546d4d-f0b6-4d57-9063-38903c64691c@e39g2000hsf.googlegroups.com> Message-ID: <76c20d47-2cb4-44ee-97d8-6bc41978d4e4@b9g2000prh.googlegroups.com> On Apr 11, 4:24 pm, cokofree... at gmail.com wrote: > On Apr 11, 1:19 pm, cokofree... at gmail.com wrote: > > > couldn't you just do. > > > #untested > > new_round(n): > > answer = round(n) > > # is answer now odd > > if answer % 2: > > return answer - 1 > > else: > > return answer > > Whoops, this also affects odd numbers... > > Will try and find a GOOD solution later... > > Strange request though, why do you need it that way, because 2.5 is > CLOSER to 3 than to 2... It also fails for negative numbers. For -2.5 as input, I get -4.0 whereas I expect -2.0 This is a lengthy solution I came-up with: def round_even(x): temp = round(abs(x)) if (abs(x) - 0.5)%2.0 == 0.0: temp=temp-1 return signum(x)*temp def signum(x): if x>0: return 1 if x<0: return -1 return 0 But i guess there are better ways. I need it 'cos I'm translating some code from Mathematica to Python. And Math..ica's Round[ ] behaves this way (as I requested) From uniontelecardsindia at gmail.com Tue Apr 22 17:19:54 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:19:54 -0700 (PDT) Subject: Hardcore hood gay musclemen in a paired ass-pounding orgy session. Message-ID: <5ad5f2bd-92c7-4ae9-98c1-d2116608e076@c65g2000hsa.googlegroups.com> Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 15 09:01:19 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 15 Apr 2008 15:01:19 +0200 Subject: Dynamic use of property() fails In-Reply-To: <87hce34eji.fsf@mulj.homelinux.net> References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> <87wsmz4l5g.fsf@mulj.homelinux.net> <48046af8$0$16166$426a74cc@news.free.fr> <87hce34eji.fsf@mulj.homelinux.net> Message-ID: <4804a719$0$15325$426a74cc@news.free.fr> Hrvoje Niksic a ?crit : > Bruno Desthuilliers > writes: > >>> However, if you know what you're doing, you can simply customize your >>> class's __getattribute__ to do what *you* want for your objects. >> >> But bear in mind that, beside possible unwanted side-effectn, you'll >> get a non-negligible performance hit - __getattribute__ being, as the >> name implies, invoked on each and every attribute lookup. > > That's unavoidable, though -- whatever you do to customize your class > in Python, the result will be slower than the C code built into > Python. This one customization hook is probably the most sensible still. > Fortunately, not every object is performance-critical. In > this case, __getattribute__ buys you per-instance customization not > otherwise available. The code you posted is probably more efficient, > but at the cost of losing the ability to customize specific instances > of the class. You could as well just customize __setattr__/__getattr__ (which is what was done before new-style classes and descriptors). But my own experience is that the very few times I thought I had a need for per-instance descriptors, I found other solutions that were certainly easier to grasp and maintain on the long term. Not that I would not be able to deal with per-instance descriptors, but so far the cost outweighted the benefits IMHO. Now YMMV of course !-) From bijeshn at gmail.com Mon Apr 7 06:15:59 2008 From: bijeshn at gmail.com (bijeshn) Date: Mon, 7 Apr 2008 03:15:59 -0700 (PDT) Subject: splitting an XML file on the basis on basis of XML tags References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> <47F9B845.9040205@behnel.de> Message-ID: pls disregard the above post.... On Apr 7, 3:13?pm, bijeshn wrote: > > What do you mean by "written down to a separate file"? Do you have a specific > > format in mind? > > sorry, it should be extracted into separate " XML files". i.e. if i have an > XML file containing 10 million records, i need to split the file to > 100 XML files containing 100,000 records each. > > i hope this is clearer... From grflanagan at gmail.com Wed Apr 23 06:49:08 2008 From: grflanagan at gmail.com (Gerard Flanagan) Date: Wed, 23 Apr 2008 03:49:08 -0700 (PDT) Subject: Script to convert Tcl scripts to Python? References: Message-ID: On Apr 23, 9:17 am, "Achillez" wrote: > Hi, > > I have a 10k+ line Tcl program that I would like to auto convert over to > Python. Do any scripts exist that can convert ~90% of the standard Tcl > syntax over to Python? I know Python doesn't handle strings, but just for > general syntax e.g., puts > print, expr > math operations > > thanks Never used it, but there's a jacl2jython tool (IBM): http://www-1.ibm.com/support/docview.wss?rs=180&uid=swg24012144 G. From lists at cheimes.de Sun Apr 20 13:43:17 2008 From: lists at cheimes.de (Christian Heimes) Date: Sun, 20 Apr 2008 19:43:17 +0200 Subject: "Help needed - I don't understand how Python manages memory" In-Reply-To: References: <0e2310a3-6945-4e78-918d-08f4a9532f89@s50g2000hsb.googlegroups.com> <480B3B2D.6040206@gmail.com> Message-ID: <480B80B5.1050500@cheimes.de> Gabriel Genellina schrieb: > Apart from what everyone has already said, consider that FreqDist may import other modules, store global state, create other objects... whatever. > Pure python code should not have any memory leaks (if there are, it's a bug in the Python interpreter). Not-carefully-written C extensions may introduce memory problems. Pure Python code can cause memory leaks. No, that's not a bug in the interpreter but the fault of the developer. For example code that messes around with stack frames and exception object can cause nasty reference leaks. Christian From darcy at druid.net Tue Apr 22 11:41:23 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Tue, 22 Apr 2008 11:41:23 -0400 Subject: Spawing a thread and printing dots until it finishes In-Reply-To: References: Message-ID: <20080422114123.446c3480.darcy@druid.net> On Tue, 22 Apr 2008 07:10:07 -0700 (PDT) sophie_newbie wrote: > import threading > class MyThread ( threading.Thread ): > def run ( self ): > myLongCommand()... > > import time > > t = MyThread() > t.start() > > while t.isAlive(): > print "." > time.sleep(.5) > > print "OK" > > The thing is this doesn't print a dot every half second. It just > pauses for ages until the thread is finished and prints prints ".OK". > But if I take out the "time.sleep(.5)" line it will keep printing dots > really fast until the thread is finished. So it looks like its the > time.sleep(.5) bit that is messing this up somehow? We know that your main routine gives up the processor but without a full definition of MyThread how do we know that it ever does? I suspect that it hits sleep once, if at all, and then goes to the final print statement. In fact, I suspect that this is not exactly what you tried anyway. This code would not have printed ".OK" whether it entered the loop or not. It could have printed this; . OK because the print statement in the loop will print a dot on a line by itself. When looking for these sorts of answers you should really try to create a smallest program that exhibits the behaviour you are questioning and then cut and paste the entire script into your message unedited. Often enough you will even answer your own question in the process. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From nospam at here.com Sun Apr 27 18:26:11 2008 From: nospam at here.com (Dennis) Date: Sun, 27 Apr 2008 23:26:11 +0100 Subject: A small and very basic python question In-Reply-To: References: Message-ID: I didn't give up after posting and managed to grasp this whole lambda thing! No need to respond now :-) I understood it the moment I tried to type out, instead of just thinking in my head, what was going on as a normal function. Dennis wrote: > Could anyone tell me how this line of code is working: > > filter(lambda x: x in string.letters, text) > > I understand that it's filtering the contents of the variable text and I > know that lambda is a kind of embedded function. > > What I'd like to know is how it would be written if it was a normal > function. From stefan_ml at behnel.de Mon Apr 7 08:34:25 2008 From: stefan_ml at behnel.de (Stefan Behnel) Date: Mon, 07 Apr 2008 14:34:25 +0200 Subject: splitting an XML file on the basis on basis of XML tags In-Reply-To: <05edd42c-dd16-4364-92ca-43cdbb1ab547@r9g2000prd.googlegroups.com> References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> <47F9B845.9040205@behnel.de> <05edd42c-dd16-4364-92ca-43cdbb1ab547@r9g2000prd.googlegroups.com> Message-ID: <47FA14D1.3080608@behnel.de> bijeshn wrote: > the extracted files are to be XML too. ijust need to extract it raw > (tags and data just like it is in the parent XML file..) Ah, so then replace the "print tostring()" line in my example by ET.ElementTree(element).write("outputfile.xml") and you're done. Stefan From larry.bates at websafe.com Thu Apr 3 23:26:50 2008 From: larry.bates at websafe.com (Larry Bates) Date: Thu, 03 Apr 2008 22:26:50 -0500 Subject: Prototype OO In-Reply-To: <83dfdeec-dfc4-41ae-9781-052bdbea7497@b64g2000hsa.googlegroups.com> References: <47e24b99$0$24941$426a74cc@news.free.fr> <47e384cb$0$567$426a74cc@news.free.fr> <13u76h8mifniibc@corp.supernews.com> <47f1f90b$0$27429$426a74cc@news.free.fr> <47f38ad8$0$10664$426a34cc@news.free.fr> <7xwsngyu05.fsf@ruckus.brouhaha.com> <7x8wzw80rf.fsf@ruckus.brouhaha.com> <0d97babc-1174-4537-a7eb-e60164521863@s13g2000prd.googlegroups.com> <83dfdeec-dfc4-41ae-9781-052bdbea7497@b64g2000hsa.googlegroups.com> Message-ID: <1207279610.7571.218.camel@fc8.home.com> On Wed, 2008-04-02 at 21:03 -0700, castironpi at gmail.com wrote: > On Apr 2, 5:41 pm, "bruno.desthuilli... at gmail.com" > wrote: > > On 2 avr, 22:23, Paul Rubin wrote: > > > > > "bruno.desthuilli... at gmail.com" writes: > > > > Fine. But totally irrelevant here - this is comp.lang.python, not > > > > comp.lang.c, and we *do not* (I repeat : we *do not*) face the same > > > > safety and security problems as those existing in C. > > > > > We have it better than they do in some ways. > > >In some other ways, we have > > > it worse. > > > > Care to elaborate ? Or are we supposed to guess ?-) > > Has anyone thought about putting code in a Data file? Am I the only > one that wants Python stored procedures in DB? postgreSQL supports Python stored procedures. Take a look: http://www.postgresql.org/docs/8.1/static/plpython.html -Larry From nagle at animats.com Mon Apr 7 18:40:35 2008 From: nagle at animats.com (John Nagle) Date: Mon, 07 Apr 2008 15:40:35 -0700 Subject: A file iteration question/problem In-Reply-To: <47f8eee1$0$759$bed64819@news.gradwell.net> References: <47f8eee1$0$759$bed64819@news.gradwell.net> Message-ID: <47faa04f$0$36349$742ec2ed@news.sonic.net> tinnews at isbd.co.uk wrote: > I want to iterate through the lines of a file in a recursive function > so I can't use:- > > f = open(listfile, 'r') > for ln in f: > > because when the function calls itself it won't see any more lines in > the file. E.g. more fully I want to do somthing like:- > > def recfun(f) > while True: > str = readline(f) > if (str == "") > break; > # > # do various tests > # > if : > recfun(f) > Don't do that; Python doesn't have tail recursion and you'll hit the stack limit. John Nagle From ewertman at gmail.com Sat Apr 26 16:20:23 2008 From: ewertman at gmail.com (Eric Wertman) Date: Sat, 26 Apr 2008 16:20:23 -0400 Subject: learning with python question (HtTLaPP) In-Reply-To: <98acecbd-9de2-4ebf-927b-ac6bc1fbc3fd@b5g2000pri.googlegroups.com> References: <98acecbd-9de2-4ebf-927b-ac6bc1fbc3fd@b5g2000pri.googlegroups.com> Message-ID: <92da89760804261320t30f7418cx17ed676fea63fc5c@mail.gmail.com> > Python Programmer" and have been trying to write a script that checks > 'words.txt' for parameters (letters) given. The problem that is the i > can only get results for the exact sequence of parameter 'letters'. The "re" module comes to mind: text = open('words.txt','r').read() letters = 'sequence' results = re.findall(letters,text) result_count = len(results) # one word per line: for result in results : print result # one line print ' '.join(results) of course, you may need to invest a little time in regular expression syntax to get exactly what you want, but I think you'll find that's not wasted effort, as this is pretty standard and used in a lot of other places. From arnodel at googlemail.com Tue Apr 29 16:50:54 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Tue, 29 Apr 2008 21:50:54 +0100 Subject: string translate, replace, find and the forward slash References: <1030ffc2-1bbe-4539-881d-35bf59cacd11@34g2000hsh.googlegroups.com> Message-ID: destroooooy writes: > Hi folks, > I'm finding some (what I consider) curious behavior with the string > methods and the forward slash character. I'm writing a program to > rename mp3 files based on their id3 tags, and I want to protect > against goofy characters in the in tags. So I do the following: > > unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n" > alt_chars = "_________________________" > > s_artist.translate(maketranstable(unsafe_chars, alt_chars)) > > > which successfully replaces everything except for forward slashes (at > least in the files I've tested so far). If I use the "replace()" > method, it also does not work. Escaping the forward slash changes > nothing. "find()" however, works, and thus I've resorted to: > > if "/" in s_artist: > (s_l, slash, s_r) = s_artist.partition("/") > s_artist = "_".join([s_l, s_r]) > > which is rather uncool. It works but I'd just like to know what the > deal is. TIA. It works fine here: marigold:junk arno$ python Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> unsafe_chars = "/#()[]!@$%^&*{}\'\"`?<>| \t\n" >>> table = range(256) >>> for c in unsafe_chars: table[ord(c)] = ord('_') ... >>> table = ''.join(chr(o) for o in table) >>> 'Jon(&Mark/Steve)'.translate(table) 'Jon__Mark_Steve_' >>> -- Arnaud From bbxx789_05ss at yahoo.com Sun Apr 6 23:17:38 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sun, 6 Apr 2008 20:17:38 -0700 (PDT) Subject: Tkinter, a lot of buttons, make prog shorter? References: <688483d9-2c6a-4e2a-b64d-f32bb27699ec@p25g2000hsf.googlegroups.com> <8869512e-19c3-4750-b4f1-5666a2547f13@u3g2000hsc.googlegroups.com> Message-ID: <0869aea0-d86d-4eb9-860a-e35f958e6477@a70g2000hsh.googlegroups.com> On Apr 6, 8:50?pm, skanem... at yahoo.se wrote: > should i not use self. in Clean() and Calculate() either? > You probably shouldn't be using classes at all. When you are trying to learn the basics of a language, you don't want to complicate things further with classes. Copying a program off the internet and trying to modify it for your own purposes is usually going to be a lot more work than writing the whole thing from scratch yourself. In addition, when you write the whole thing yourself, you'll have a better understanding of how things work. From bijeshn at gmail.com Thu Apr 3 02:12:25 2008 From: bijeshn at gmail.com (bijeshn) Date: Wed, 2 Apr 2008 23:12:25 -0700 (PDT) Subject: splitting an XML file on the basis on basis of XML tags References: <1480b701-b01d-48a0-aade-e850d0054668@i36g2000prf.googlegroups.com> Message-ID: On Apr 2, 5:37?pm, Chris wrote: > bije... at gmail.com wrote: > > Hi all, > > > ? ? ? ? ?i have an XML file with the following structure:: > > > > > -----| > > ? ? | > > ? ? | > > . ? ? ? ? ? | > > . ? ? ? ? ? | ? ? ? ? --------------------> constitutes one record. > > . ? ? ? ? ? | > > . ? ? ? ? ? | > > . ? ? ? ? ? | > > ? ?| > > ? ?| > > ----| > > > > . > > . > > . ? ?-----------------------| > > . ? ? ? ? ? ? ? ? ? ? ? ? ? | > > . ? ? ? ? ? ? ? ? ? ? ? ? ? | > > . ? ? ? ? ? ? ? ? ? ? ? ? ? |----------------------> there are n > > records in between.... > > . ? ? ? ? ? ? ? ? ? ? ? ? ? | > > . ? ? ? ? ? ? ? ? ? ? ? ? ? | > > . ? ? ? ? ? ? ? ? ? ? ? ? ? | > > . ? ------------------------| > > . > > . > > > > -----| > > ? ? | > > ? ? | > > . ? ? ? ? ? | > > . ? ? ? ? ? | ? ? ? ? --------------------> constitutes one record. > > . ? ? ? ? ? | > > . ? ? ? ? ? | > > . ? ? ? ? ? | > > ? ?| > > ? ?| > > ----| > > > > > ? ? ? ?Here is the main root tag of the XML, and ... > > constitutes one record. What I would like to do is > > to extract everything (xml tags and data) between nth tag and (n > > +k)th tag. The extracted data is to be > > written down to a separate file. > > > Thanks... > > You could create a generator expression out of it: > > txt = """ > ? ? 1 > ? ? 2 > ? ? 3 > ? ? 4 > ? ? 5 > ? ? > ? ? """ > l = len(txt.split('r2>'))-1 > a = ('%sr2>'%i for j,i in enumerate(txt.split('r2>')) if 0 < j < l > and i.replace('>','').replace('<','').strip()) > > Now you have a generator you can iterate through with a.next() or > alternatively you could just create a list out of it by replacing the > outer parens with square brackets.- Hide quoted text - > > - Show quoted text - Hmmm... will look into it.. Thanks the XML file is almost a TB in size... so SAX will have to be the parser.... i'm thinking of doing something to split the file using SAX ... Any suggestions on those lines..? If there are any other parsers suitable, please suggest... From darcy at druid.net Fri Apr 25 15:02:29 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Fri, 25 Apr 2008 15:02:29 -0400 Subject: Why is None <= 0 In-Reply-To: <481228DF.5010408@ulmcnett.com> References: <481228DF.5010408@ulmcnett.com> Message-ID: <20080425150229.653404bc.darcy@druid.net> On Fri, 25 Apr 2008 11:54:23 -0700 Paul McNett

wrote: > In my humble opinion, I think that comparisons involving None should > return None... Like relational databases. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From vivainio at gmail.com Wed Apr 9 15:16:53 2008 From: vivainio at gmail.com (Ville Vainio) Date: Wed, 9 Apr 2008 12:16:53 -0700 (PDT) Subject: pywin32 vista installer fix & general distutils installer name bug Message-ID: <843dba28-dded-483a-9435-c1a99db94c08@s13g2000prd.googlegroups.com> I just noticed that pywin32 does not work with vista directly (tried import win32clipboard, => ImportError). The problem is the installer name; it's the usual pywin32-210-win32-py2.5.exe It needs to be renamed to: pywin32-210.win32-setup-py2.5.exe In order for vista to catch it as "installer". We renamed the IPython exe installer to have "setup" to get around the same issue. Just posting this for benefit of googlers. I'll complain about this on distutils-sig as well. From billingspanshism at gmail.com Sat Apr 19 17:19:50 2008 From: billingspanshism at gmail.com (billingspanshism at gmail.com) Date: Sat, 19 Apr 2008 14:19:50 -0700 (PDT) Subject: victoria beckham boobs Message-ID: <7dbf45d5-b7d7-4a7b-bb0d-03c31e6a8300@2g2000hsn.googlegroups.com> Just few link on some Movies Movies: http://victoria-beckham.12w.net F R E E C E L E B R I T Y M O V I E S From gslindstrom at gmail.com Tue Apr 1 16:11:51 2008 From: gslindstrom at gmail.com (Greg Lindstrom) Date: Tue, 1 Apr 2008 15:11:51 -0500 Subject: What motivates all unpaid volunteers at Pycon? Message-ID: > >> There really isn't any simple answer. Most people seem to be > >> motivated to help out their communities, > > > > I still think all this unselfishness is noteworthy > > and curious. > > > Assuming that people get nothing back by participating in a > community, yes, it would be curious. My experience, though, is that I > get a lot more out of it than I could ever contribute. IOW, it's a > great example of synergy. > > -- Ed Leafe I attended my first PyCon in D.C. a few years back. The next year I volunteered as a session chair because I wanted one of the groovy black "staff" shirts. Last year I signed up as the tutorial coordinator because I was told there was a need for people to step up and I felt strongly that as part of the community I have an obligation to give back (the same reason I was a volunteer firefighter for 5 years). I had no idea how much work it would be to put together 1 day of the conference; and just the talks at that (there's the technical aspect, food, registration, etc., that others handled). Once you become part of the community that puts the conference together and see how much passion these people put into their tasks it's hard to walk away, at least for me. I've signed up for tutorials again for 2009 and hope to bring 3 or 4 other volunteers along for the ride. What do I get out of it? Sure, I got another groovy tee shirt, but I also saw over 600 people taking classes on Tutorial Thursday. I got to meet some very smart cookies and saw a lot of Python that I had never seen before. Not everything went as planned, and a few things went poorly but, overall, things went pretty well. We are taking all off the feedback into account and are already looking at next year. So, if you're still reading this, why don't *YOU* help out, too? You can help out a little or you can help out a lot. There are highly technical issues that need addressing (see "PyCon Tech") and other tasks that don't require programming at all but are just as important (food, swag, etc.). Click on over to http://www.python.org/community/pycon/ and introduce yourself. You'll get a lot more than a groovy tee shirt out of it! --greg -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at holdenweb.com Sat Apr 5 22:08:45 2008 From: steve at holdenweb.com (Steve Holden) Date: Sat, 05 Apr 2008 22:08:45 -0400 Subject: Best way to check if string is an integer? In-Reply-To: <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> References: <9a4d160a-1dbd-45ff-9983-1fc01e5f7754@t54g2000hsg.googlegroups.com> <434964df-40a1-4f97-b7db-b1e4c91039b1@u10g2000prn.googlegroups.com> Message-ID: <47F830AD.9050106@holdenweb.com> John Machin wrote: > On Apr 6, 9:25 am, Mark Dickinson wrote: >> On Apr 5, 6:19 pm, skanem... at yahoo.se wrote: >> >>> which is the best way to check if a string is an number or a char? >>> could the 2nd example be very expensive timewise if i have to check a >>> lot of strings? >> You might be interested in str.isdigit: >> >>>>> print str.isdigit.__doc__ >> S.isdigit() -> bool >> >> Return True if all characters in S are digits >> and there is at least one character in S, False otherwise. >> > > This doesn't cater for negative integers. > No, it doesn't, but s.isdigit() or (s[0] in "+-" and s[1:].isdigit) # untested does. and *may* be quicker than other examples. Not that speed is usually a concern in validation routines anyway ... regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From __peter__ at web.de Mon Apr 7 07:16:48 2008 From: __peter__ at web.de (Peter Otten) Date: Mon, 07 Apr 2008 13:16:48 +0200 Subject: csv.DictReader and unicode References: Message-ID: Laszlo Nagy wrote: >> Read the values as byte strings and decode afterwards. Or monkey-patch: import csv def make_reader(fin, encoding="UTF-8"): reader = csv.DictReader(fin) reader.reader = ([col.decode(encoding) for col in row] for row in reader.reader) return reader fin = open("example.csv") for record in make_reader(fin): print record > Is there a plan to make csv reader compatible with unicode? I don't know. Peter From Lie.1296 at gmail.com Sun Apr 27 07:09:33 2008 From: Lie.1296 at gmail.com (Lie) Date: Sun, 27 Apr 2008 04:09:33 -0700 (PDT) Subject: removing extension References: Message-ID: On Apr 27, 6:05 pm, Lie wrote: > On Apr 27, 5:34 pm, wilson wrote: > > > > > i was trying to convert all images in a folder to another type and > > save the new images in a separate folder.for that i wrote a class and > > coded some part > > > class ConvertImgs: > > def __init__(self,infldr,outfldr): > > if os.path.isdir(infldr): > > self.infldr=infldr > > self.outfldr=outfldr > > else: > > print "no such folder,exits program" > > exit(1) > > if not os.path.isdir(self.outfldr): > > os.mkdir(self.outfldr) > > print "made:",self.outfldr > > > for x in os.listdir(infldr): > > self.origlist=[os.path.normpath(os.path.join(self.infldr,x)) for x in > > os.listdir(infldr)] > > > ... > > the self.origlist returns a list of filenames in infolder.I would > > like to get them as 'C:\\myimages\\imageone' instead of 'C:\\myimages\ > > \imageone.jpg' sothat i can add a diff extension to all those strings > > in the list and save in diff format(ie change 'C:\\myimages\\imageone' > > to 'C:\\myimages\\imageone.gif ' and save in gif format).but i don't > > know how to remove those extension from the namestring ..can someone > > help? > > W > > I don't know if this is the simplest way, but you can use re module. > > import re > pat = re.compile(r'(.*?)\..*') Sorry, this line should be: pat = re.compile(r'(.*)\..*') or paths like these wouldn't pass correctly: "C:\\blahblah.blah\\images.20.jpg" > name = pat.search('C:\\myimages\\imageone.jpg').group(1) > print name From jr9445 at ATT.COM Wed Apr 16 10:12:26 2008 From: jr9445 at ATT.COM (Reedick, Andrew) Date: Wed, 16 Apr 2008 09:12:26 -0500 Subject: vary number of loops In-Reply-To: <480604BE.3090002@tim.thechases.com> References: <480604BE.3090002@tim.thechases.com> Message-ID: > -----Original Message----- > From: python-list-bounces+jr9445=att.com at python.org [mailto:python- > list-bounces+jr9445=att.com at python.org] On Behalf Of Tim Chase > Sent: Wednesday, April 16, 2008 9:53 AM > To: nullgraph at gmail.com > Cc: python-list at python.org > Subject: Re: vary number of loops > > > > > If n=3, I want to have 3 sets of elements and mix them up using 3 for > > loops. > > You might be ineterested in this thread: > > http://mail.python.org/pipermail/python-list/2008-January/473650.html > > where various solutions were proposed and their various merits > evaluated. > I second that. The thread compared building loops on the fly, building comprehensions nested to arbitrarily levels, recursion (sloooow!), a slick cookbook recipe using iterators, etc. and provided timings for each method. Definitely worth bookmarking. ***** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. GA625 From fairwinds at eastlink.ca Mon Apr 7 09:38:47 2008 From: fairwinds at eastlink.ca (David Pratt) Date: Mon, 07 Apr 2008 10:38:47 -0300 Subject: Help replacing os.system call with subprocess call In-Reply-To: <47F9C764.9070401@mattnordhoff.com> References: <47F9B1D1.4090701@eastlink.ca> <47F9C764.9070401@mattnordhoff.com> Message-ID: <47FA23E7.7040809@eastlink.ca> Hi David and Matt. I appreciate your help which has got me moving forward again so many thanks for your reply. I have been using subprocess.Popen a fair bit but this was the first time I had to use subprocess to capture large file output. The trouble I was having was with the process would just hang. Chunking was the solution. I guess I assumed this would be taken care of in the internals. Overall, I wish subprocess had some better documentation since it is definitely not a drop in replacement for os.system. In other circumstances I am using subprocess.call() for simple calls which works fine. The speed of this solution is slower than os.system. Would a queue of some kind be needed to speed this up? Has anyone implemented something like this? Many thanks. Regards, David Matt Nordhoff wrote: > David Pratt wrote: >> Hi. I am trying to replace a system call with a subprocess call. I have >> tried subprocess.Popen and subprocess.call with but have not been >> successful. The command line would be: >> >> svnadmin dump /my/repository > svndump.db >> >> This is what I am using currently: >> >> os.system('svnadmin dump %s > %s' % (svn_dir, >> os.path.join(backup_dir, 'svndump.db'))) >> >> Many thanks. > > Try this: > > import os.path > import subprocess > > p = subprocess.Popen( > ['svnadmin', 'dump', svndir], > stdout=subprocess.PIPE, > ) > > fh = open(os.path.join(backup_dir, 'svndump.db'), 'wb') > > while True: > chunk = p.stdout.read(2**20) # 1 MB > if not chunk: > break > fh.write(chunk) > > fh.close() > > It reads svnadmin's stdout in 1 MB chunks, in case it's large enough > that reading the whole thing into RAM at once would be a bad idea. > > No error handling. For one, you might want to add a try...finally to > ensure that fh will get closed. (Or if you have Python 2.5, use a with > statement! :-) ) Also, Popen will raise an OSError if svnadmin can't be > found or something. And this isn't even considering svnadmin erroring out... > > svnadmin's stderr will go to your stderr. > > I didn't test it, but I'm pretty sure it will work. (I spotted a syntax > error while writing that though.) I don't have much experience with > Popen's stdio objects, so it's possible you'd need to do something like > call p.wait() to wait for it to exit before being able to read its stdout. > > It could be slower than the os.system version, since now Python is doing > all of the I/O, instead of your shell, but I doubt that'll be a big problem. > > (Also, insert suggestion about using a good VCS. ;-) ) From software at ginstrom.com Tue Apr 1 10:32:12 2008 From: software at ginstrom.com (Ryan Ginstrom) Date: Tue, 1 Apr 2008 23:32:12 +0900 Subject: Copy Stdout to string In-Reply-To: References: Message-ID: <04c501c89405$2d213f00$0203a8c0@MOUSE> > On Behalf Of sophie_newbie > Hi, I'm wondering if its possible to copy all of stdout's > output to a string, while still being able to print on > screen. I know you can capture stdout, but I still need the > output to appear on the screen also... If I understand you correctly, the following class should work. from StringIO import StringIO class OutBuffer(object): """Wraps a stream, and keeps output as a buffer Usage: >>> import sys >>> sys.stdout = OutBuffer(sys.stdout) >>> print "spam" spam >>> print "egg" egg >>> sys.stdout.getvalue().splitlines() ['spam', 'egg'] """ def __init__(self, outstream): self.out = outstream self.buffer = StringIO() def write(self, obj): """Writes obj to the output stream, storing it to a buffer as well""" self.out.write(obj) self.buffer.write(obj) def getvalue(self): """Retrieves the buffer value""" return self.buffer.getvalue() def __getattr__(self, attr): """Delegate everything but write and getvalue to the stream""" return getattr(self.out, attr) Regards, Ryan Ginstrom From pavlovevidence at gmail.com Tue Apr 22 10:55:03 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 22 Apr 2008 07:55:03 -0700 (PDT) Subject: Remove multiple inheritance in Python 3000 References: <50cd6e6e-e8e7-49c8-8a84-3bd37b1ef0ca@a22g2000hsc.googlegroups.com> <6760jfF2n3bn1U1@mid.uni-berlin.de> <6bec3c67-689a-4df2-848f-d3936a143024@f36g2000hsa.googlegroups.com> Message-ID: <1510fd01-5e13-4124-a3fe-ff69d9011ebb@d1g2000hsg.googlegroups.com> On Apr 22, 10:36 am, George Sakkis wrote: > On Apr 22, 10:22 am, Carl Banks wrote: > > > Java (for example) allows a class to share behavior with only one > > other class, and that *severely* limits the opportunities to minimize > > redundancy. > > Not really; composition is usually a better way to share functionality > and reduce redundancy than inheritance. I should have known this was coming. I disagree: inheritance is a much better way to share behavior. Use inheritance by default, composition if you have to. (Or composition when it actually reflects a composition relationship, and not mere behavior sharing.) With composition you're burdening the user with having to learn the shared relationships that ought to be implementation details of the class. E.g., obj.action_style.perform_action() With inheritance, the user doesn't have to worry about these relationships. obj.perform_action() It's better to isolate complexity (which inheritance does) than to spread it out (which composition does). Carl Banks From istvan.albert at gmail.com Fri Apr 18 09:50:17 2008 From: istvan.albert at gmail.com (Istvan Albert) Date: Fri, 18 Apr 2008 06:50:17 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> <66q33cF2krjf2U1@mid.uni-berlin.de> Message-ID: On Apr 18, 1:39 am, Sverker Nilsson wrote: > Some whine. Some just don't care. Why not whine? Whining and ranting is actually good for the psyche. It is better to get it out of your system. As for your original post, no doubt there are substantial downsides to introducing Py3K, but as Guido put it every language must "change or die". Of course we could end up with "change and die" as well. I for one am an optimist, I think there are several substantial improvements to the language that today may not be apparent for a casual observer, yet will allow it to evolve into an even more powerful and fun language i. From mensanator at aol.com Wed Apr 16 19:12:09 2008 From: mensanator at aol.com (Mensanator) Date: Wed, 16 Apr 2008 16:12:09 -0700 (PDT) Subject: def power, problem when raising power to decimals References: <48067bdb@news.mel.dft.com.au> Message-ID: <6f348df6-e441-4c47-aa6c-cd01266e97fe@y21g2000hsf.googlegroups.com> On Apr 16, 5:49?pm, "Gabriel Genellina" wrote: > En Wed, 16 Apr 2008 19:21:18 -0300, John Machin ? > escribi?: > > > skanem... at yahoo.se wrote: > >> also i found a link which states 0^0 isnt 1 even though every > >> calculator ive tried says it is. > >> it doesnt say what it is but i presume 0 then. > >> but it seems the dude is wrong and it is 1? > > > Of the possible results of 0 ** 0 (i.e. 1, 0, and NaN), 1 seems to be > > the least implausible. It allows X ** 0 to be 1 for all X. > > But a result of 0 would allow 0 ** X to be 0 for all X. (btw, this is the ? > reason lim(x**x) for x->0 does not exist) Where this has come up in my research, X**0 being a multiplicative identity is far more important than 0**X being an additive identity. > > -- > Gabriel Genellina From kinch1967 at gmail.com Sun Apr 27 09:35:43 2008 From: kinch1967 at gmail.com (bullockbefriending bard) Date: Sun, 27 Apr 2008 06:35:43 -0700 (PDT) Subject: design choice: multi-threaded / asynchronous wxpython client? Message-ID: <272e03ab-6b66-42ef-8ea9-f84621d9f234@q27g2000prf.googlegroups.com> I am a complete ignoramus and newbie when it comes to designing and coding networked clients (or servers for that matter). I have a copy of Goerzen (Foundations of Python Network Programming) and once pointed in the best direction should be able to follow my nose and get things sorted... but I am not quite sure which is the best path to take and would be grateful for advice from networking gurus. I am writing a program to display horse racing tote odds in a desktop client program. I have access to an HTTP (open one of several URLs, and I get back an XML doc with some data... not XML-RPC.) source of XML data which I am able to parse and munge with no difficulty at all. I have written and successfully tested a simple command line program which allows me to repeatedly poll the server and parse the XML. Easy enough, but the real world production complications are: 1) The data for the race about to start updates every (say) 15 seconds, and the data for earlier and later races updates only every (say) 5 minutes. There is no point for me to be hammering the server with requests every 15 seconds for data for races after the upcoming race... I should query for this perhaps every 150s to be safe. But for the upcoming race, I must not miss any updates and should query every ~7s to be safe. So... in the middle of a race meeting the situation might be: race 1 (race done with, no-longer querying), race 2 (race done with, no longer querying) race 3 (about to start, data on server for this race updating every 15s, my client querying every 7s), races 4-8 (data on server for these races updating every 5 mins, my client querying every 2.5 mins) 2) After a race has started and betting is cut off and there are consequently no more tote updates for that race (it is possible to determine when this occurs precisely because of an attribute in the XML data), I need to stop querying (say) race 3 every 7s and remove race 4 from the 150s query group and begin querying its data every 7s. 3) I need to dump this data (for all races, not just current about to start race) to text files, store it as BLOBs in a DB *and* update real time display in a wxpython windowed client. My initial thought was to have two threads for the different update polling cycles. In addition I would probably need another thread to handle UI stuff, and perhaps another for dealing with file/DB data write out. But, I wonder if using Twisted is a better idea? I will still need to handle some threading myself, but (I think) only for keeping wxpython happy by doing all this other stuff off the main thread + perhaps also persisting received data in yet another thread. I have zero experience with these kinds of design choices and would be very happy if those with experience could point out the pros and cons of each (synchronous/multithreaded, or Twisted) for dealing with the two differing sample rates problem outlined above. Many TIA! From uniontelecardsindia at gmail.com Tue Apr 22 17:13:32 2008 From: uniontelecardsindia at gmail.com (uniontelecardsindia at gmail.com) Date: Tue, 22 Apr 2008 14:13:32 -0700 (PDT) Subject: Masculine black gays in nasty orgy Message-ID: Just few link on some movies... All just for you... Download >>>>> http://download-video.12w.net >>>>> http://world-sex.urllogs.com >>>>> http://video-sex.12w.net CLICK FREE DOWNLOAD VIDEO PORN... L I C K T O W A T C H V I D E O P O R N D O W N L O A D F R E E . . . W E L C O M T O M O V I E S P O R N D O W N L O A D . . . From bskaplan14 at yahoo.com Wed Apr 16 21:13:03 2008 From: bskaplan14 at yahoo.com (Ben Kaplan) Date: Wed, 16 Apr 2008 18:13:03 -0700 (PDT) Subject: Logical Operator and code block not executing (newbie question) Message-ID: <671091.823.qm@web39205.mail.mud.yahoo.com> The problem is that your loop says "while guess != number". When guess is equal to the number, the code in the loop is not executed. Instead, do something like while guess != number and tries < total_attempts: if guess > number: ... elif guess < number: ... if guess == number : ... ----- Original Message ---- From: python newbie To: python-list at python.org Sent: Wednesday, April 16, 2008 8:58:10 PM Subject: Logical Operator and code block not executing (newbie question) Hello, I am running into a small problem of not having a code block not executing after after a logical operator is true. What am I missing or doing wrong. Any thoughts or opinions would be greatly appreciated. The block that isn't being executed follows: elif (guess == the_number) and (tries < total_attempts): print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" print "The correct answer is: ", the_number Below is the complete script: #! /usr/bin/python # Aurthor: Me # Purpose: Demonstrates # Date: April 15, 2008 import random print "\tWelcome to 'Guess My Number'!" print "\nI'm thinking of a number between 1 and 100." print "Try to guess it in as few attempts as possible.\n" # set the initial values the_number = random.randrange(100) + 1 guess = int(raw_input("Take a guess: ")) tries = 1 total_attempts = 3 # guessing loop while (guess != the_number): if (guess > the_number) and (tries < total_attempts): print "Lower..." print "You have...", total_attempts - tries, "left." print "The correct answer is: ", the_number elif (guess < the_number) and (tries < total_attempts): print "Higher..." print "You have...", total_attempts - tries, "left." print "The correct answer is: ", the_number elif (guess == the_number) and (tries < total_attempts): print "You guessed it! The number was", the_number print "And it only took you", tries, "tries!\n" print "The correct answer is: ", the_number elif (tries >= total_attempts): print "You're out of guess" print "You have...", total_attempts - tries, "left." print "You need more practice." print "The correct answer is: ", the_number break else: print "You shouldn't see this message..." print "You have...", total_attempts - tries, "left." print "The correct answer is: ", the_number break guess = int(raw_input("Take a guess: ")) tries += 1 raw_input("\n\nPress the enter key to exit.") PS: I am new to coding & scripting. Pete Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From gh at gregor-horvath.com Fri Apr 25 14:27:15 2008 From: gh at gregor-horvath.com (Gregor Horvath) Date: Fri, 25 Apr 2008 20:27:15 +0200 Subject: Why is None <= 0 Message-ID: Hi, >>> None <= 0 True Why? Is there a logical reason? Gregor From hdante at gmail.com Sun Apr 27 21:17:51 2008 From: hdante at gmail.com (hdante) Date: Sun, 27 Apr 2008 18:17:51 -0700 (PDT) Subject: Python(2.5) reads an input file FASTER than pure C(Mingw) References: <6a3f8226-04c6-4ee3-b5a6-f76aca44aa31@a23g2000hsc.googlegroups.com> <6420bfba-089d-41c6-a34f-b26e8b35afd7@x41g2000hsb.googlegroups.com> <10e0c170-97ab-41bb-b501-f54790cc69ff@a70g2000hsh.googlegroups.com> <983df81f-2d6a-4ee0-aea2-8780894fd706@a70g2000hsh.googlegroups.com> <250c1ceb-1c0d-41e4-a3c6-25e20ac4f22c@a1g2000hsb.googlegroups.com> <258c926b-47f2-4c8d-86ca-b97fc8abfb18@f36g2000hsa.googlegroups.com> <2d06b319-e2fd-4790-af61-6f90b9b1b3b1@m1g2000pre.googlegroups.com> <41e72e61-6413-41f3-a162-dbcc1ec5fcee@f63g2000hsf.googlegroups.com> <9776420a-c34d-425e-8598-eecf4bfd0d02@t63g2000hsf.googlegroups.com> Message-ID: <075fc7b8-ff84-40f7-ad2b-eb2077e5abdb@t54g2000hsg.googlegroups.com> On Apr 27, 4:54?pm, n00m wrote: > Another PC, another OS (Linux) and another compiler C++ (g++ 4.0.0-8) > > Compare 2 my latest submissions:http://www.spoj.pl/status/SBANK,zzz/ > > times: 1.32s and 0.60s > > Submitted codes: > > import sys > z=sys.stdin.readlines() > print z[5] > > #include > #include > #include > #include > > using namespace std; > > vector vs; > > int main() { > ? ? while (true) { > ? ? ? ? char line[50]; > ? ? ? ? if (!fgets(line,50,stdin)) break; > ? ? ? ? vs.push_back(line); > ? ? } > return 0; > > } > > If it proves nothing then white is black and good is evil It seems that the "push_back" line takes most of the time of the code. Remove it and execution will drop to 0.25s. Python readline uses fread instead of fgets: http://svn.python.org/view/python/tags/r251/Objects/fileobject.c?rev=54864&view=markup (see the file_readlines function) If you write a code that does an fread loop, execution will drop to 0.01s. This C code takes 0.25s. Almost all time is spent with string manipulation. #include #include #define B 8192 char vs[100000][40]; char buffer[B]; int main(void) { int count; char *begin, *end; int i; i = 0; while (1) { count = fread(buffer, 1, B, stdin); if (count == 0) break; begin = buffer; while(1) { end = (char *)memchr(begin, '\n', buffer+B-begin); if (end == NULL) { memmove(buffer, begin, buffer+B-begin); break; } memmove(vs[i], begin, end-begin); i = (i+1)%100000; begin = end + 1; } } return 0; } The difference, 0.60s-0.25s = 0.35s is probably mostly python's memory management (which seems to be much more efficient than std::vector default). Very interesting post. :-) I had no idea about how much optimized the builtin library was. From needin4mation at gmail.com Tue Apr 29 13:46:04 2008 From: needin4mation at gmail.com (jmDesktop) Date: Tue, 29 Apr 2008 10:46:04 -0700 (PDT) Subject: Simple import question about mac osx References: Message-ID: On Apr 29, 1:16?pm, jmDesktop wrote: > Hi, I have this code (learning from Core Python, Chun's book), module > named chap2.py. > > class FooClass(object): > ? ? ? ? version=0.1 > > ? ? ? ? def __init__(self, nm='John Doe'): > ? ? ? ? ? ? ? ? self.name=nm > ? ? ? ? ? ? ? ? print 'Created a class instance for ', nm > ? ? ? ? def showname(self): > ? ? ? ? ? ? ? ? print 'Your name is', self.name > ? ? ? ? ? ? ? ? print 'My name is', self.__class__.__name__ > > On Windows, if I compile this and then in the python interpreter type: > > >>> import chap2 > >>> foo1=FooClass() > > Created a class instance for ?John Doe > > > > If I do the same think on my Mac OS X 10.5.2 > > NameError: name 'FooClass' is not defined. > > I thought it was the path and did export PATH=$PATH:/mypath/ > topythoncode > > but it did not help. > > What am I doing wrong? ?Thank you. forgot to say that on the mac I can do import chap2, but when I try and instantiate I get the error above. From mccredie at gmail.com Fri Apr 11 17:08:31 2008 From: mccredie at gmail.com (Matimus) Date: Fri, 11 Apr 2008 14:08:31 -0700 (PDT) Subject: How to make a "command line basd" interactive program? References: Message-ID: On Apr 11, 2:32 am, Evan wrote: > Hope this hasn't been posted hundreds of times. I'm new for this. > > Before using python for this kind of script, I was using TCL to write > down a "command line based" interactive program. it likes a "tclsh", > or "python" command, after that, you can work under a prompt, for > example, " - >> ", and then you can execute any commands what you > defined in script. > > Now, in python, are there any common way(class) to finish this work? > or does anybody has a example to do that? > > Thanks, > Evan Do you want a custom shell that does whatever you want? Or do you want an interactive python shell that has some custom commands? For the first check out the cmd module http://docs.python.org/lib/module-cmd.html example: >>> import cmd >>> class MyCmd(cmd.Cmd): ... def do_echo(self, params): ... print params ... >>> MyCmd().cmdloop() (Cmd) echo Hello World Hello World (Cmd) help Undocumented commands: ====================== echo help For the second, check out the code module http://docs.python.org/lib/module-code.html example: >>> import code >>> def foo(): ... print "hello, this is foo" ... >>> code.interact("Welcome to my python shell!", local={'bar':foo}) Welcome to my python shell! >>> bar() hello, this is foo >>> Hope this helps, Matt From tundra at tundraware.com Thu Apr 17 00:08:09 2008 From: tundra at tundraware.com (Tim Daneliuk) Date: Wed, 16 Apr 2008 23:08:09 -0500 Subject: I just killed GIL!!! In-Reply-To: References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: <52vid5-cvl2.ln1@ozzie.tundraware.com> Daniel Fetchinson wrote: >> Hello Guys... >> >> I just had one moment of exceptional clarity, during which realized >> how I could get the GIL out of my way... It's so simple, I cannot help >> wondering why nobody has thought of it before. Duh! Now I am going to >> sit and and marvel at my creation for a while, and then go to bed >> (it's past 2:30 a.m.) Tomorrow I will contemplate whether to sell this >> little secret for big bucks, give it away for free, or just keep it to >> myself... :-) >> >> Now you are probably thinking I reinvented the gunpowder, and are >> running multiple processes. Not so. I am not running parallel >> processes, like parallel python or the processing module in cheese >> shop. I am running multiple THREADS. In fact, I am just using >> threading.Thread. The source code is pure Python, so there is no C >> magic, and I only used the stuff that's already there in the standard >> library. So, I just made CPython do what everyone claim to be >> impossible. One single process of CPython is using all the cpu power >> of my dual-core laptop. > > > > If I were you I would keep it a secret until a Hollywood producer > offers big bucks for the film rights. Who would play Guido, I wonder? -- ---------------------------------------------------------------------------- Tim Daneliuk tundra at tundraware.com PGP Key: http://www.tundraware.com/PGP/ From grahn+nntp at snipabacken.se Sun Apr 6 03:05:19 2008 From: grahn+nntp at snipabacken.se (Jorgen Grahn) Date: 6 Apr 2008 07:05:19 GMT Subject: Recursively Backup Directories References: Message-ID: On Sat, 5 Apr 2008 16:56:31 -0700 (PDT), misceverything at gmail.com wrote: > I am writing a script that will backup specified folders from one hard > drive to another (for example, backup source "C:\DATA", destination "D: > \Backup"), and was thinking of using shutil. I'd avoid doing that (writing a backup script, that is). It may be fine if your goal is using it only under MS-DOS, and not distribute it. But making it robust (vital to a backup utility!) and portable is tricky. You have to handle things like - symbolic links (when to follow, when not to) - hard links - copying metadata of various kinds (timestamps, permissions, ACLs, file system-specific metadata) - non-obvious error handling (like copying the file 'foo', but the target exists as a directory and must be rmdir()ed first) - ... I believe it is better to write a script which drives a widely known and well-tested copying utility. On Unix these include tar, cpio and rsync -- don't know which ones are common under DOS (xcopy?) I guess I'm saying that I do not trust module shutil. I see now that it documents how it treats some of the things above, but ... /Jorgen -- // Jorgen Grahn R'lyeh wgah'nagl fhtagn! From kyosohma at gmail.com Fri Apr 11 17:11:04 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 11 Apr 2008 14:11:04 -0700 (PDT) Subject: Windows - window status (Running vs Not Responding) References: <85b60af8-7617-4805-9e42-44a234c65239@u3g2000hsc.googlegroups.com> <5f4a5d63-c862-4d25-8849-6a36dd4e138d@m3g2000hsc.googlegroups.com> Message-ID: On Apr 11, 3:22 pm, Tim Golden wrote: > Mike Driscoll wrote: > >http://www.informit.com/articles/article.aspx?p=19489&seqNum=4 > > > If you're better than I am, you can probably translate this to the > > Python equivalent. Zenoss also has some monitoring software that's > > open source Python code. > > I'm afraid that article only allows you to determine whether > a known executable is running, If that's what the OP's after, > then you can do as much by querying WMI thusly: > > > import wmi > c = wmi.WMI () > > EXE = "notepad.exe" > for process in c.Win32_Process (Caption=EXE): > print process > break > else: > print "None found" > > > > TJG Tim, Oh well. I guess my Google-Fu failed me this time around. Thanks for looking at it though. Mike From smmehadi at gmail.com Tue Apr 8 01:35:12 2008 From: smmehadi at gmail.com (syed mehdi) Date: Tue, 8 Apr 2008 11:05:12 +0530 Subject: ImportError: No module named MySQLdb In-Reply-To: References: <12b075a10804072035j42c85d4m3e4b45778d9697c4@mail.gmail.com> Message-ID: <12b075a10804072235w6978491era2ff50d2bd80367f@mail.gmail.com> Thanks Gabriel, it worked after installing MySQL (database engine). Regards Syed On Tue, Apr 8, 2008 at 10:23 AM, Gabriel Genellina wrote: > En Tue, 08 Apr 2008 00:35:29 -0300, syed mehdi > escribi?: > > > I have been working in python from some time now, > > while writing a python script i used: import MySQLdb in my script to do > > some > > database related operations. > > When i tried to execute the same script on another system it gave me an > > error as: > > "ImportError: No module named MySQLdb" > > though mysqldb was already installed on that system, and python 2.5.2 > was > > present on that machine. > > i have tried uninstalling and installing of mysql again and again but to > > no > > avail. > > MySQL (the database engine) is not the same as MySQLdb (the Python > package). You have to download and install it: > http://mysql-python.sourceforge.net/ > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at cheimes.de Wed Apr 23 05:16:20 2008 From: lists at cheimes.de (Christian Heimes) Date: Wed, 23 Apr 2008 11:16:20 +0200 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: <200804230839.49560.v.harishankar@gmail.com> References: <200804230839.49560.v.harishankar@gmail.com> Message-ID: Harishankar schrieb: > Is there any platform independent way to launch a terminal window from a > desktop (Windows, Linux, etc.)? No, there isn't. It usually not possible to create a graphical terminal window on a remote server. Christian From terry.yinzhe at gmail.com Sun Apr 27 09:35:46 2008 From: terry.yinzhe at gmail.com (Terry) Date: Sun, 27 Apr 2008 06:35:46 -0700 (PDT) Subject: Question regarding Queue object References: <7c851cfd-2290-4915-a0d4-b69c1f55d035@l25g2000prd.googlegroups.com> Message-ID: <8c7579b8-d6d1-4ae6-9374-443d46462c59@j33g2000pri.googlegroups.com> On Apr 27, 6:27 pm, Terry wrote: > Hello! > > I'm trying to implement a message queue among threads using Queue. The > message queue has two operations: > PutMsg(id, msg) # this is simple, just combine the id and msg as one > and put it into the Queue. > WaitMsg(ids, msg) # this is the hard part > > WaitMsg will get only msg with certain ids, but this is not possible > in Queue object, because Queue provides no method to peek into the > message queue and fetch only matched item. > > Now I'm using an ugly solution, fetch all the messages and put the not > used ones back to the queue. But I want a better performance. Is there > any alternative out there? > > This is my current solution: > > def _get_with_ids(self,wait, timeout, ids): > to = timeout > msg = None > saved = [] > while True: > start = time.clock() > msg =self.q.get(wait, to) > if msg and msg['id'] in ids: > break; > # not the expecting message, save it. > saved.append(msg) > to = to - (time.clock()-start) > if to <= 0: > break > # put the saved messages back to the queue > for m in saved: > self.q.put(m, True) > return msg > > br, Terry I just found that Queue is written in Python, maybe I can override it. From deets at nospam.web.de Wed Apr 16 06:20:54 2008 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 16 Apr 2008 12:20:54 +0200 Subject: how turbo geras code works References: Message-ID: <66m292F2lo3ghU2@mid.uni-berlin.de> reetesh nigam wrote: > hi. > actually i have developed one small project but now i want to > develope a project with the help of html.. > please help me out Try and work through the turbogears.org website, especially the tutorial. Subscribe to the TG mailing list, and post *concrete* questions. Questions of the type "I want to fly to the moon, please help me do it" are hard to answer. Diez From ggpolo at gmail.com Sat Apr 5 13:17:08 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Sat, 5 Apr 2008 14:17:08 -0300 Subject: Tkinter: making buttons the same size? In-Reply-To: <3753aa85-c844-4e54-8213-142e50fd8a7e@b5g2000pri.googlegroups.com> References: <12bad1a6-3b4b-446e-9673-8893cd6838f9@s37g2000prg.googlegroups.com> <3753aa85-c844-4e54-8213-142e50fd8a7e@b5g2000pri.googlegroups.com> Message-ID: 2008/4/5, skanemupp at yahoo.se : > how do i do that? i get this error: > > > > self.btnDisplay = Button(self,text='1',command=lambda > n=1:self.Display(n)) > > self.btnDisplay.grid(row=3, column=0, padx=5, pady=5, width=1) > > > self.btnDisplay = Button(self,text='/',command=lambda > n="/":self.Display(n)) > > self.btnDisplay.grid(row=6, column=3, padx=5, pady=5, width=1) > Add it to the Button widget, not to the grid method. mybtn = Button(..., width=1) Thanks, -- -- Guilherme H. Polo Goncalves From paulgeeleher at gmail.com Tue Apr 22 10:10:07 2008 From: paulgeeleher at gmail.com (sophie_newbie) Date: Tue, 22 Apr 2008 07:10:07 -0700 (PDT) Subject: Spawing a thread and printing dots until it finishes Message-ID: Hi, I'm trying to write a piece of code that spawns a thread and prints dots every half second until the thread spawned is finished. Code is something like this: import threading class MyThread ( threading.Thread ): def run ( self ): myLongCommand()... import time t = MyThread() t.start() while t.isAlive(): print "." time.sleep(.5) print "OK" The thing is this doesn't print a dot every half second. It just pauses for ages until the thread is finished and prints prints ".OK". But if I take out the "time.sleep(.5)" line it will keep printing dots really fast until the thread is finished. So it looks like its the time.sleep(.5) bit that is messing this up somehow? Any ideas? Thanks! From google at mrabarnett.plus.com Thu Apr 17 11:50:51 2008 From: google at mrabarnett.plus.com (MRAB) Date: Thu, 17 Apr 2008 08:50:51 -0700 (PDT) Subject: Profiling, recursive func slower than imperative, normal? References: Message-ID: <8e40ad23-cd75-4dfa-84ff-3fdef36faa11@m36g2000hse.googlegroups.com> On Apr 17, 9:39 am, Robert Bossy wrote: > Gabriel Genellina wrote: > > En Wed, 16 Apr 2008 17:53:16 -0300, escribi?: > > >> On Apr 16, 3:27 pm, Jean-Paul Calderone wrote: > > >>> Any function can be implemented without recursion, although it isn't > >>> always easy or fun. > > >> Really? I'm curious about that, I can't figure out how that would > >> work. Could give an example? Say, for example, the typical: walking > >> through the file system hierarchy (without using os.walk(), which uses > >> recursion anyway!). > > > Use a queue of pending directories to visit: > > > start with empty queue > > queue.put(starting dir) > > while queue is not empty: > > dir = queue.get() > > list names in dir > > for each name: > > if is subdirectory: queue.put(name) > > else: process file > > Hi, > > In that case, I'm not sure you get any performance gain since the queue > has basically the same role as the stack in the recursive version. A > definitive answer calls for an actual test, though. > > Anyway if you want to process the tree depth-first, the queue version > falls in the "not fun" category. > If you store the folders in a queue (push onto one end and pop from the other end) the search is breadth-first; if you store the folders in a stack (push onto one end and pop from the same end) the search is depth-first. Simple really! :-) From fredri8758lupo at gmail.com Wed Apr 23 06:09:20 2008 From: fredri8758lupo at gmail.com (fredri8758lupo at gmail.com) Date: Wed, 23 Apr 2008 03:09:20 -0700 (PDT) Subject: 7 sins nude patch Message-ID: 7 sins nude patch http://cracks.12w.net F R E E C R A C K S From shikha_saxena2007 at yahoo.com Wed Apr 16 03:42:06 2008 From: shikha_saxena2007 at yahoo.com (Prashant) Date: Wed, 16 Apr 2008 07:42:06 -0000 Subject: insert python script in current script Message-ID: I was wondering is there any way to do this: I have written a class in python and __init__ goes like this: def __init__(self): self.name = 'jack' self.age = 50 import data now here there is data.py in the same directory and contents are like: self.address = 'your address' self.status = 'single' The problem is 'self' is giving some error here. I need to know if somehow I can do this. It's like inserting the script as it's part of the file itself. Cheers From arnodel at googlemail.com Tue Apr 8 01:38:32 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Mon, 7 Apr 2008 22:38:32 -0700 (PDT) Subject: A file iteration question/problem References: <47f8eee1$0$759$bed64819@news.gradwell.net> <47faa04f$0$36349$742ec2ed@news.sonic.net> Message-ID: On Apr 7, 11:40?pm, John Nagle wrote: > tinn... at isbd.co.uk wrote: > > I want to iterate through the lines of a file in a recursive function > > so I can't use:- > > > ? ? f = open(listfile, 'r') > > ? ? for ln in f: > > > because when the function calls itself it won't see any more lines in > > the file. ?E.g. more fully I want to do somthing like:- > > > def recfun(f) > > ? ? while True: > > ? ? ? ? str = readline(f) > > ? ? ? ? if (str == "") > > ? ? ? ? ? ? break; > > ? ? ? ? # > > ? ? ? ? # do various tests > > ? ? ? ? # > > ? ? ? ? if : > > ? ? ? ? ? ? recfun(f) > > ? ? ?Don't do that; Python doesn't have tail recursion and you'll hit the > stack limit. > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? John Nagle This function is not tail recursive (the recursive call is in a loop). -- Arnaud From umpsumps at gmail.com Sat Apr 26 16:00:00 2008 From: umpsumps at gmail.com (umpsumps at gmail.com) Date: Sat, 26 Apr 2008 13:00:00 -0700 (PDT) Subject: learning with python question (HtTLaPP) Message-ID: <98acecbd-9de2-4ebf-927b-ac6bc1fbc3fd@b5g2000pri.googlegroups.com> Hello all, I've been trying to teach myself python from "How to Think Like a Python Programmer" and have been trying to write a script that checks 'words.txt' for parameters (letters) given. The problem that is the i can only get results for the exact sequnce of parameter 'letters'. I'll spare posting all the different ways I've tried to search for specific letters. But they are all generally: for line in fin: for linechar in line: for ch in letters: or the "for linechar in line:" and "for ch in letters:" get switched.. I'm getting really frustrated to say the least. What alternative method could I use that isn't too advanced? Any tips/suggestions on the code itself would be greatly appreciated, and tips for learning in general. here is the code that returns a certain sequence: >>> def searchtxt(letters): fin = open('words.txt') words = "" index = 0 count = 0 for line in fin: index +=1 if letters in line.strip(): count += 1 words = line.strip() + '\n' + words print words print index, 'lines searched..', count, letters, 'words present' Thank you in advance. From tjreedy at udel.edu Wed Apr 9 18:37:46 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 9 Apr 2008 18:37:46 -0400 Subject: How to find documentation about methods etc. for iterators References: <47fce941$0$755$bed64819@news.gradwell.net> Message-ID: wrote in message news:47fce941$0$755$bed64819 at news.gradwell.net... | I'm not sure if I have even phrased that right but anyway.... | | How does one find (in the standard Python documentation) information | about things like the iteritems() method and the enumerate() function. The Library Reference manual sections on builtin functions and dict methods. Or, help(enumerate) and help({}.iteritems) tjr From bruno.desthuilliers at gmail.com Mon Apr 7 09:20:10 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Mon, 7 Apr 2008 06:20:10 -0700 (PDT) Subject: First Python project - comments welcome! References: Message-ID: <4a200ecf-a945-4cb6-8f91-0b8baf378e18@n58g2000hsf.googlegroups.com> On 7 avr, 10:03, Paul Scott wrote: > I have started, and made some progress (OK it works, but needs some > love) on my first real Python application. > > http://cvs2.uwc.ac.za/trac/python_tools/browser/podder > > I would love some feedback on what I have done. In total this has taken > me 5 nights to do (I am working on it at night as PHP, not Python, is my > day job), so it can probably do with *lots* of improvement. All code is > GPL. > > If anyone on this list is willing/able, please do give me a few > pointers, even if it is "This is total crap - RTFM and come back when > you are ready" I would really appreciate it! Ok, since you asked for it: 22 try: 23 import pygtk 24 #tell pyGTK, if possible, that we want GTKv2 25 pygtk.require("2.0") 26 except: Don't use bare except clauses, always mention the exception class you're expecting and let every other exception propagate. Else you may shadow other unexpected errors (ie: what if the user has a pygtk.py file in her pythonpath that is unrelated to the expected pygtk module ? And yes, this kind of thing can and does happen, more often than you may think). 27 print "You need to install pyGTK or GTKv2 or set your PYTHONPATH correctly" stdout is for normal program outputs. Error messages should go to sys.stderr. 28 print "try: export PYTHONPATH=/usr/local/lib/python2.2/site- packages/" 29 sys.exit(1) 40 class appgui: 1/ naming convention : should be Appgui or AppGui (cf pep08) 2/ unless you have very compelling reasons to stick with old-style classes, make your class a newstyle one: class AppGui(object): 41 def __init__(self): 42 """ 43 In this init we are going to display the main recorder window 44 """ 45 global globaldir 46 globaldir="./" Since this doesn't depend on anything passed to the initializer, and is initialized with a constant value, this should go to the top-level, ie: GLOBAL_DIR = './' class AppGui(object): # code here 58 "on_window1_destroy" : (gtk.main_quit)} This may not do what you think. If what you want is to pass a tuple, the syntax is: "on_window1_destroy" : (gtk.main_quit, ) } notice the trailing ',' 59 self.wTree.signal_autoconnect (dic) 60 self.status = STOPPED 61 return You don't need this return statement. 64 def record_click(self,widget): (snip) 70 self.player = gst.Pipeline("recorder") (snip) 87 def pause_click(self,widget): (snip) 94 if widget.get_active(): 95 # print "paused recording..." 96 self.player.set_state(gst.STATE_PAUSED) This may be a bit of a personnal preference, but I never feel confortable with attributes added in a method (I mean, else than the initializer) and accessed in another. Specially when it's a very important attribute... One reason being that I don't get the 'big picture' just from browsing the __init__ and the methods names, another being that now pause_click depends on record_click having been called before - yet nothing mentions it, nothing documents it, you have to read the whole code to find about it. 204 try: 205 f=open(globaldir+"lecture.ogg", 'r') Steve Holden already commented on using os.path.join here, and I commented about using a top-level constant (GLOBAL_DIR), which will makes thing more explicit (we know it's a constant, and we will look for it at the top-level). I'd recommend to also use top-level symbolic constants for the file names, instead of hardcoding them in the methods. Same thing for urls etc. 206 b=open(globaldir+"basefile", 'w') 207 encoded = base64.encode(f,b) 208 b.close() 209 except: 210 print "File could not be opened..." And what you get an exception in the call to base64.encode ? This is *exactly* why you should *never* use bare except clauses. (snip more bare except clauses...) And while we're at it, you forget to close f. 283 if type(currentThread()) != _MainThread: Since types are singletons, you can use the identity test here: if type(currentThread()) is not _MainThread: 306 def __init__ (self, parrent, queue, signal, sendPolicy): (snip) 309 self.parrent = parrent Don't you mean 'parent' ?-) 316 v = self.queue.get() 317 if v == None: identity test again (more idiomatic, and a little bit faster) 318 break 319 threads_enter() 320 l = [v] 'v' is a very poor name, and 'l' is even worse. 431 # Get stuff # 432 def isCancelled (self): 433 return self.cancelled 434 435 def isDone (self): 436 return self.done 437 438 def getProgress (self): 439 return self.progress Unless something in the framework requires these getters (I have almost no experience with pyGTK), you'd be better using direct attribute access IMHO. Else, it would be better to mark cancelled, done and progress as implementation attributes (by prefixing them with a single underscore) so everyone knows he shouldn't access them directly. Else it looks mostly clean !-) HTH From marco at sferacarta.com Tue Apr 22 06:41:41 2008 From: marco at sferacarta.com (Marco Mariani) Date: Tue, 22 Apr 2008 12:41:41 +0200 Subject: Python Success stories In-Reply-To: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> References: <1ad1c0c4-c1b5-46aa-b26c-0426c86522b4@a70g2000hsh.googlegroups.com> Message-ID: azrael wrote: > Please give me any arguments to cut him down about his commnets > like :"keep programing i python. maybe, one day, you will be able to > program in VisualBasic" > > This hurts. Please give me informations about realy famous > aplications. He's joking. Perl is a dysfunctional language and its users need a strong sense of humor to go on, day after day. From kyosohma at gmail.com Mon Apr 21 11:12:40 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Mon, 21 Apr 2008 08:12:40 -0700 (PDT) Subject: Finding the selected file in Windows Explorer References: Message-ID: On Apr 21, 9:44 am, domir... at gmail.com wrote: > Hi! > > I need to find the selected file(s) in a Windows Explorer window from > another program (I'd look at the window that last had focus). I found > something in the following page that should do the trick: > > http://blogs.msdn.com/oldnewthing/archive/2004/07/20/188696.aspx > > However, it is not Python and, while I'm a competent Python > programmer, Win32, COM and the like are somewhat outside my > competences. > > Does any one know how to do something similar in Python? > > Tks! > Domiriel I think the guys on the PyWin32 mailing list were just talking about something similar earlier this month. Looks like it was how to select a file in Explorer. You can check out that thread here: http://www.mail-archive.com/python-win32 at python.org/maillist.html Or just join their mailing list and re-post your question there: http://mail.python.org/mailman/listinfo/python-win32 They're quite nice and very knowledgeable. Mike From bruno.desthuilliers at gmail.com Wed Apr 2 13:56:07 2008 From: bruno.desthuilliers at gmail.com (bruno.desthuilliers at gmail.com) Date: Wed, 2 Apr 2008 10:56:07 -0700 (PDT) Subject: april fools email backfires References: <7xbq4sf9wv.fsf@ruckus.brouhaha.com> Message-ID: On 2 avr, 19:23, Paul Rubin wrote: > Aaron Watters writes: > > Grapevine says that an architect/bigot at a java/spring shop sent > > out an April Fools email saying they had decided to port everything > > to Django ASAP. > > > Of course the email was taken seriously and he got a lot of positive > > feedback from line developers and savvy users/managers that they > > thought it would be a great idea; it's about time; gotta do > > something about this mess... > > Django, pah. They should switch to something REALLY advanced: > > http://www.coboloncogs.org/INDEX.HTM KEYBOARD ! From stef.mientki at gmail.com Thu Apr 3 17:21:25 2008 From: stef.mientki at gmail.com (Stef Mientki) Date: Thu, 03 Apr 2008 23:21:25 +0200 Subject: displaying execution of Python code In-Reply-To: <1afcbf34-0a40-4d11-b12f-603f0ee8f26c@m3g2000hsc.googlegroups.com> References: <1afcbf34-0a40-4d11-b12f-603f0ee8f26c@m3g2000hsc.googlegroups.com> Message-ID: <47F54A55.6000308@gmail.com> noahwatkins wrote: > I'll start my question by describing my desired result. I will > construct a GUI which will be used to open a Python script. I would > then like to be able to display the Python script, execute it, and > highlight the lines of the Python as they are executing. > > More technically, I am looking for direction on where to start looking > in the Python libraries for a functionality that will allow me to > execute arbitrary Python code from within a Python application. > Additionally, I need to be able to have the ability to get information > and perform actions (e.g. line number currently executing) as the code > executes. > > Thanks, > Noah > start with the wxPython demo, I guess you find all you need in there. cheers, Stef From jon+usenet at unequivocal.co.uk Fri Apr 25 20:17:24 2008 From: jon+usenet at unequivocal.co.uk (Jon Ribbens) Date: Fri, 25 Apr 2008 19:17:24 -0500 Subject: Why is None <= 0 References: <481226f9$0$20866$9b622d9e@news.freenet.de> Message-ID: On 2008-04-25, Martin v. L?wis wrote: > None is smaller than anything. According to Tim Peters, this is not true. See http://bugs.python.org/issue1673405 From kyosohma at gmail.com Tue Apr 22 17:09:40 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Tue, 22 Apr 2008 14:09:40 -0700 (PDT) Subject: list manipulation References: <78158460-8508-4453-a2dc-c5814dda8839@59g2000hsb.googlegroups.com> Message-ID: On Apr 22, 3:55 pm, DataSmash wrote: > Hello, > > I have a list that looks like this: > roadList = ["Motorways","Local","Arterial"] > > I want to apply some code so that the output looks like this: > "Motorways;Local;Arterial" > > ...in other words, I want each item in the list separated by a ';' and > then the whole thing surrounded by quotes. > > How can this be done with the LEAST amount of code? > > I appreciate your help! > R.D. Well you could always do something like this: output = ';'.join(roadList) Which will put single quotes on the ends. I suppose if you want to be silly, you could do this: output = '"%s"' % ';'.join(roadList) HTH Mike From bronger at physik.rwth-aachen.de Tue Apr 8 16:06:46 2008 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Tue, 08 Apr 2008 22:06:46 +0200 Subject: Coping with cyclic imports Message-ID: <87bq4knmax.fsf@physik.rwth-aachen.de> Hall?chen! I have a rather fat module that represents a document parser -- inline elements, block elements, and the like. Now I want to split it into many modules to make everything more manageable. But at the moment I don't see how to avoid cyclic imports: A document element A, which is represented my module parser.A, may contain the element B, as defined in parser.B. And vice versa. So both modules must import each other, as far as I can see. I know that cyclic imports work in Python under certain circumstances. Can anyone refer me to a page which explains *when* this works? Because at least once, the imported module was not "finished" and thus largely unusual. Thank you! Tsch?, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: bronger at jabber.org (See http://ime.webhop.org for further contact info.) From victorsubervi at gmail.com Sat Apr 5 10:32:00 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Sat, 5 Apr 2008 09:32:00 -0500 Subject: Adding Images To MySQL Message-ID: <4dc0cfea0804050732x7dc2ac41n64d56dda9da27a82@mail.gmail.com> >* *(What a mess! I don't know where to begin...) Yeah. Never claimed to be any good at this :( Just persistent :) >* *- You say Content-Type: image/jpeg but you emit HTML code. You're lucky if you see any >* *text at all. Well, I tried Content-Type: text/html and that threw an HTTP 500 Error. >* *- HTTP 200 is not an error, it means the request was successful. When it doesn?t execute the code, how can it be called successful? If it doesn?t execute the code, how can you say it?s not an error? What is it, then? >* *- As a general advice, try to isolate the problems. Test the database stuff alone, in a local >* *application. Test the cgi script alone, without database interaction. Test the database stuff in >* *the web server (better if you have a shell account). Merge all and test again. Very good advice. Please help me understand how to do that. This is what I have done. I have tried these: sql = "'insert into products (" + col_names + ") values (" + val + ")', (" + col_names + ")" cursor.execute(sql) and sql = "'insert into products (" + col_names + ") values (" + val + ")'" cursor.execute(sql, (col_names,)) Neither work. However, if I print what that code spits out: sql = "'insert into products (" + col_names + ") values (" + val + ")', (" + col_names + ")" print sql then copy and paste it into a cursor.execute() statement, viola! Everything works _just_fine_. Go figure. Why?? Incidentally, all that is without using images, and obviously since it posted to the database after copying and pasting, I believe I am dealing only with a python problem. Now, concerning images, this is what I have so far. I put an image on the server, and did this: imgfile=open("1.jpg",'rb') f = imgfile.read() pic1 = _mysql.escape_string(f) It does not like this (forgot error): pic1 = MySQLdb.Binary(f) Escaping the string, I can successfully load this image into the database, along with all the other fields. Now, when I load an image from the form on the previous page with this code: From gagsl-py2 at yahoo.com.ar Sun Apr 6 16:15:49 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Sun, 06 Apr 2008 17:15:49 -0300 Subject: Prevent GUI layout from changing? References: Message-ID: En Sun, 06 Apr 2008 15:12:55 -0300, escribi?: I can't help with your sizing problem, I don't know grids. But don't do this: > def Display(self, number): > self.expr = self.expr + number > self.lbText = Label(self, text=self.expr) > self.lbText.grid(row=0, column=0) > > def Calculate(self): > self.expr = str(eval(self.expr))#try catch tex 3+6+ > self.lbText = Label(self, text=self.expr) > self.lbText.grid(row=1, column=1) > self.expr = "" You're creating a *new* Label object for each keystroke (they stack on the same place and only the newest is visible, I presume). Instead, you should change the text inside the existing widget: self.lbText.config(text=self.expr) (there is no need to reposition the widget) Label is described here http://effbot.org/tkinterbook/label.htm and you may want to learn to use Tkinter variables: http://effbot.org/tkinterbook/variable.htm -- Gabriel Genellina From bbxx789_05ss at yahoo.com Sat Apr 5 20:53:46 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sat, 5 Apr 2008 17:53:46 -0700 (PDT) Subject: Tkinter, add pressed buttons onto string display string, how to? References: <57605958-5589-4ebe-abdf-73c2d14c8a82@u10g2000prn.googlegroups.com> <65q8juF2gq610U2@mid.uni-berlin.de> <649d9748-c389-411d-9794-9753ddf434b0@d1g2000pra.googlegroups.com> Message-ID: <195771d1-1bb3-4d62-b9c3-920db5a912ac@y21g2000hsf.googlegroups.com> > > Just like the message says: You are trying to use `str` (on the right hand > > side of the assignment) before anything is bound to that name. > > > Ciao, > > ? ? ? ? Marc 'BlackJack' Rintsch > > i know but i want the variable str(which i found out is a reserved > word so i changed it) to be accessible all over __init__ right? > "all over __init__" ? You could practice with a trivial example to discover how things work in python: def f(): num = 10 print num f() def g(): print num num = 10 g() > so i tried to delcare it in __init__ in the beginning of the framework > class but then when i access it in the method Display i get that > error. > > so how should i declare this variable to be able to access it > everywhere? > You don't declare variables in python. You just start using a variable when you need it. In other words you don't do this: string my_str my_str = "hello" You just write: my_str = "hello" > i want another method "calculate" that can access the same string > later and do the calculations(writing some other code now that will > read and interpret that). Does this look familiar: > Another thing you should be aware of: self is like a class wide > bulletin board. If you are writing code inside a class method, and > there is data that you want code inside another class method to be > able to see, then post the data on the class wide bulletin board, i.e. > attach it to self. ?But in your code, you are doing this: > > self.btnDisplay = Button(self, text="7", default=ACTIVE) > self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > self.btnDisplay = Button(self, text="8", default=ACTIVE) > self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > As a result, your code continually overwrites self.btnDisplay. ?That > means you aren't preserving the data assigned to self.btnDisplay. > Therefore, the data does not need to be posted on the class wide > bulletin board for other class methods to see. ?So just write: > > btnDisplay = Button(self, text="7", default=ACTIVE) > btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > btnDisplay = Button(self, text="8", default=ACTIVE) > btnDisplay.grid(row=5, column=1, padx=5, pady=5) From bbxx789_05ss at yahoo.com Tue Apr 1 19:44:41 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Tue, 1 Apr 2008 16:44:41 -0700 (PDT) Subject: XML Parsing References: Message-ID: <5f1019b7-47e1-4fcf-a00c-b982c6b2fd79@f63g2000hsf.googlegroups.com> On Apr 1, 1:42?pm, Alok Kothari wrote: > Hello, > ? ? ? ? ? I am new to XML parsing.Could you kindly tell me whats the > problem with the following code: > > import xml.dom.minidom > import xml.parsers.expat > document = """Lettermanis token>betterthan token>JayLeno""" > > # 3 handler functions > def start_element(name, attrs): > ? ? print 'Start element:', name, attrs > def end_element(name): > ? ? print 'End element:', name > def char_data(data): > ? ? print 'Character data:', repr(data) > > p = xml.parsers.expat.ParserCreate() > > p.StartElementHandler = start_element > p.EndElementHandler = end_element > p.CharacterDataHandler = char_data > p.Parse(document, 1) > > OUTPUT: > > Start element: token {u'pos': u'nn'} > Character data: u'Letterman' > End element: token > > Traceback (most recent call last): > ? File "C:/Python25/Programs/eg.py", line 20, in > ? ? p.Parse(document, 1) > ExpatError: junk after document element: line 1, column 33 I don't know if you are aware of the BeautifulSoup module: import BeautifulSoup as bs xml = """LettermanisbetterthanJayLeno""" doc = bs.BeautifulStoneSoup(xml) tokens = doc.findAll("token") for token in tokens: for attr in token.attrs: print "%s : %s" % attr print token.string --output:-- pos : nn Letterman pos : bez is pos : jjr better pos : cs than pos : np Jay pos : np Leno From andre.roberge at gmail.com Tue Apr 8 21:39:39 2008 From: andre.roberge at gmail.com (=?ISO-8859-1?Q?Andr=E9?=) Date: Tue, 8 Apr 2008 18:39:39 -0700 (PDT) Subject: text adventure game problem References: Message-ID: On Apr 8, 10:25?pm, Andr? wrote: > On Apr 8, 10:01?pm, corvettecra... at gmail.com wrote: > > > > > okay, I'm having this one problem with a text adventure game. It's > > kind of hard to explain, but I'll do my best. > > [code] > > > def prompt_kitchen(): > > ? ? global gold > > ? ? gold_taken = False > > ? ? while True: > > ? ? ? ? prompt_kit = raw_input('>') > > ? ? ? ? if prompt_kit == 'examine cabinet 1' and not gold_taken: > > ? ? ? ? ? ? print '''This cabinet has a lot of cups in it with all > > different > > designs and shapes. Where are the people anyway? How come there's > > nobody here? > > In one of the cups you find 8 gold.''' > > ? ? ? ? ? ? gold = gold+8 > > ? ? ? ? ? ? gold_taken = True > > ? ? ? ? ? ? pass4() > > ? ? ? ? elif prompt_kit == 'examine cabinet 1' and gold_taken: > > ? ? ? ? ? ? print \ > > ? ? ? ? ? ? ? ? ? '''This cabinet has a lot of cups in it with all > > different > > designs and shapes. Where are the people anyway? How come there's > > nobody here?''' > > ? ? ? ? ? ? pass4() > > > def pass4(): > > ? ? global gold > > ? ? print 'You have', gold, 'gold' > > ? ? pass > > [/code] > > > Okay, now for my problem. > > In the above function, there's the option to examine a cabinet and get > > 8 gold. (everyone here knows that...but I'm just trying to state my > > problem...) > > Unfortunately, it kind of doesn't work. > > After the first time I 'examine cabinet 1' in my game, I get 8 gold > > and I can't get it again. > > But, If I leave the room and come back to it, then it's as if I had > > never gotten the gold the first time, and I can get it again. > > How do I fix this? > > quick guess: define gold_taken as a global variable and initialize it > outside of the function. > > Warning: avoid global variables if at all possible. > > ;-) > Andr? Actually, what I would do if I were designing such a game is probably define an object with various states, so that instead of gold_taken, I'd have state.gold_taken_in_cabinet_1 Alternatively, you could define a dict at the beginning with things like gold_taken = {'cabinet 1': False, 'cabinet 2': False, ...} This approach would allow to identify at a glance all relevant game situations rather than having to go through the entire code. Andr? From hopeorpha308 at gmail.com Sun Apr 27 07:47:35 2008 From: hopeorpha308 at gmail.com (hopeorpha308 at gmail.com) Date: Sun, 27 Apr 2008 04:47:35 -0700 (PDT) Subject: sony sound forge 9 crack Message-ID: <9fabd8f6-1642-4ad8-b723-e2a1015a9c17@34g2000hsh.googlegroups.com> sony sound forge 9 crack http://wga-cracks.crackkey.net From michael at stroeder.com Mon Apr 14 05:35:27 2008 From: michael at stroeder.com (=?ISO-8859-1?Q?Michael_Str=F6der?=) Date: Mon, 14 Apr 2008 11:35:27 +0200 Subject: Remote mac address In-Reply-To: References: Message-ID: <54lbd5-dk7.ln1@nb2.stroeder.com> Matias Surdi wrote: > Anyone knows how having the IP address of a host on the lan could I get > the mac address of that hosr? > > p/d: Parsing the output of arp -a is not an option. But the ARP table is exactly what you need to access. This is probably system-specific. You could also try to send ARP requests yourself: http://www.secdev.org/projects/scapy/ http://www.ibm.com/developerworks/aix/library/au-pythocli/ Ciao, Michael. From exarkun at divmod.com Mon Apr 28 12:00:26 2008 From: exarkun at divmod.com (Jean-Paul Calderone) Date: Mon, 28 Apr 2008 12:00:26 -0400 Subject: Receive data from socket stream In-Reply-To: <1939ddb7-fc72-4d45-8c9c-062a1d0db3e4@y21g2000hsf.googlegroups.com> Message-ID: <20080428160026.6859.1551084614.divmod.quotient.56204@ohm> On Mon, 28 Apr 2008 07:26:13 -0700 (PDT), s0suk3 at gmail.com wrote: > [snip] > > >BTW, has anybody used sockets as file-like objects >(client.makefile())? Is it more secure? More efficient? It's not more (or less) secure. In certain cases, it's significantly less efficient. It's for simplicity of programming, not much else. Jean-Paul From wbsoft at xs4all.nl Sat Apr 19 17:19:14 2008 From: wbsoft at xs4all.nl (Wilbert Berendsen) Date: Sat, 19 Apr 2008 23:19:14 +0200 Subject: manipulating class attributes from a decorator while the class is being defined Message-ID: <200804192319.14735.wbsoft@xs4all.nl> Hi, is it possible to manipulate class attributes from within a decorator while the class is being defined? I want to register methods with some additional values in a class attribute. But I can't get a decorator to change a class attribute while the class is still being defined. Something like: class Parser(object): regexps = [] def reg(regexp): def deco(func): regexps.append((regexp, func)) return func return deco @reg(r'".*"') def quoted_string(self): pass How can I reach the class attribute `regexps' from within a decorator? Thanks for any help, Wilbert Berendsen -- http://www.wilbertberendsen.nl/ "You must be the change you wish to see in the world." -- Mahatma Gandhi From Lie.1296 at gmail.com Tue Apr 22 07:50:10 2008 From: Lie.1296 at gmail.com (Lie) Date: Tue, 22 Apr 2008 04:50:10 -0700 (PDT) Subject: Python script to automate use of Google Translate? (or other translator) References: Message-ID: On Apr 21, 8:58 am, Kenneth McDonald wrote: > I have the need to occasionally translate a single word > programatically. Would anyone have a Python script that would let me > do this using Google (or another) translation service? > > Thanks, > Ken Are you sure you want to use Google translation service (or other online translation services) cause you won't be able to translate if you don't have internet. On the other hand, if you're only looking translator for yourself, you could search for some firefox plugins or Google Toolbar. From castironpi at gmail.com Wed Apr 23 16:27:54 2008 From: castironpi at gmail.com (castironpi at gmail.com) Date: Wed, 23 Apr 2008 13:27:54 -0700 (PDT) Subject: print some text References: <7ac7b11d-6c9b-477c-8c0d-b038bc760918@c58g2000hsc.googlegroups.com> Message-ID: On Apr 23, 2:05?pm, barronmo wrote: > I'm a beginner searching for an easy way to print the contents of a > text control. ?So far I've come up with the following(difficulties): > > 1) using wxPython > ? ? ?-convert to HTML and then print (I don't know anything about > HTML) > ? ? ?-use wx.Printout (Seems complicated; may be beyond my abilities) > > 2) create a text file and then print it out (can create but can only > print with the win32api.ShellExecute method so this solution doesn't > help me on my Linus laptop) > > 3) use ReportLab to create .pdf and then print that out (again, can > create but can't print in Linux) > > Thanks for any help. > > Mike Write out an HTML file, write back if you need a quick one, then print that with a browser. From victorsubervi at gmail.com Fri Apr 18 13:06:54 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Fri, 18 Apr 2008 12:06:54 -0500 Subject: Another MySQL Images Question In-Reply-To: <1208533718.4748.16.camel@aalcdl07.lib.unc.edu> References: <4dc0cfea0804180813o32ed2c82o9c3f68b1a607348d@mail.gmail.com> <1208533718.4748.16.camel@aalcdl07.lib.unc.edu> Message-ID: <4dc0cfea0804181006m1811e3c3wcea4dacf68eb8a0d@mail.gmail.com> Thank you. That worked. Victor On Fri, Apr 18, 2008 at 10:48 AM, J. Cliff Dyer wrote: > There are several problems with your SQL, but not all of them would be > caught by the computer. Your SELECT statement is not parameterized. > This is a security problem. *Always* parameterize your variables. Your > UPDATE statement has an extraneous comma at the end, and it also has > quotes around the "%s"es that you don't need, because you already > parameterized that query. Your dbapi interface will provide appropriate > quoting for whatever type of data you pass it. > > Cheers, > Cliff > > > On Fri, 2008-04-18 at 10:13 -0500, Victor Subervi wrote: > > Hi; > > If I grab an image in the database thus: > > > > sql = "select pic1 from products where id='" + str(id) + "';" > > cursor.execute(sql) > > pic1 = cursor.fetchall()[0][0].tostring() > > # pic1 = cursor.fetchall()[0][0] // either this or the above > > line > > > > and try and re-insert it thus: > > > > cursor.execute('update products set pic1="%s" where id="%s", ;', > > (pic1, id)) > > > > it tells me I have an error in my MySQL syntax. What is the error? > > TIA, > > Victor > -- > Oook, > J. Cliff Dyer > Carolina Digital Library and Archives > UNC Chapel Hill > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From glasper9 at yahoo.org.au Fri Apr 25 01:23:36 2008 From: glasper9 at yahoo.org.au (Jason Stokes) Date: Fri, 25 Apr 2008 15:23:36 +1000 Subject: Explicit variable declaration References: <1506f165-7f86-4dc7-aa29-6488eda9ae7f@l64g2000hse.googlegroups.com><5e59998b-d2e7-48cb-824b-84620f95c9bc@w5g2000prd.googlegroups.com> Message-ID: <1209101024.201741@chilli.pcug.org.au> "Filip Gruszczynski" wrote in message news:mailman.89.1209000606.12834.python-list at python.org... >> If you want to just declare that name exist, but doesn't want to >> declare the type, why don't you just do this: >> >> def somefunc(): >> nonlocal = nonlocal >> local = 0 # or None or [] or an initial value >> # >> return nonlocal * local > > Err.. I don't quite get. How it may help me? Could you explain? Hi Filip, In Python the standard patten for "declaring" variables is just to assign to them as they are needed. If you want the effect of a declaration as you would do in C, you can just define the variable and initialize it to 0 or None. (Or {} for a new dictionary, or [] for a new list.) eg, def collaterecs(): recordscount = 0 recordlist = [] ... return recordlist From kamhung.soh at gmail.com Fri Apr 18 07:37:33 2008 From: kamhung.soh at gmail.com (Kam-Hung Soh) Date: Fri, 18 Apr 2008 21:37:33 +1000 Subject: index of list of lists References: <1208398552l.41837l.0l@ns.bitcarrier.eu> Message-ID: On Thu, 17 Apr 2008 12:25:51 +1000, Daniel Fetchinson wrote: >> yes, there's a thread with the same title, but I believe mine is more >> appropriate title. >> so, as much as I search on the web, read manuals, tutorials, mail-lists >> (including this one) I cannot figure it out how to search a string in a >> list of lists. >> like this one: >> >> someList = [['somestring', 1, 2], ['oneother', 2, 4]] >> >> I want to search "somestring" in someList which is in practice a list >> of aprox. 200 lists. (hey, I'm a newbie python programmer, don't judge >> me). >> is the list.index the wrong approach? >> should I use numpy, numarray, something else? >> can anyone, be kind and help me with this? > > someList = [['somestring', 1, 2], ['oneother', 2, 4]] > for alist in someList: > if alist[0] == 'somestring': > print "Found it at index %d" % someList.index( alist ) > # if you know it will only occur once you might say: > break > > HTH, > Daniel See also Section 4.5. Filtering Lists. List comprehension: [x for x in someList if x[0] == 'somestring'] Use filter() function: filter(lambda x: x[0] == 'somestring', someList) -- Kam-Hung Soh Software Salariman From hejibo at gmail.com Sat Apr 12 16:06:55 2008 From: hejibo at gmail.com (He Jibo) Date: Sat, 12 Apr 2008 13:06:55 -0700 (PDT) Subject: [help] how to install pygtk Message-ID: <78e6da3e-767e-470c-9efa-70281eda204f@u69g2000hse.googlegroups.com> Hi, Everyone, Could someone help me how to install pygtk? I get some problems with it. Here is the error I get while install pygtk: https://netfiles.uiuc.edu/jibohe2/error.GIF?uniq=-k6678k I use python 2.4, I first installed glade-2.0.1-win32_with_gtk, and then pycairo-1.0.2-1.win32-py2.4, pygobject-2.12.3-1.win32-py2.4, and pygtk-2.8.6-1.win32-py2.4. Afterwards, I try to setup pygtk-2.8.4, and got the above error. Although I did above operations suggested by the information from the web , I seems that I still do not have pygtk in my computer. I want to run cankiri.py (which relies on pygtk), and still get the following error. cankiri.py is used to record screen video , and could be downloaded at https://netfiles.uiuc.edu/jibohe2/cankiri.py?uniq=-z4xh4m. Thank you so much ! Traceback (most recent call last): File "E:\Program Files\Python2.4\py2exe code \cankiri-0.1\cankiri-0.1\cankiri.py", line 20, in -toplevel- import gtk, gobject File "E:\Program Files\Python2.4\Lib\site-packages\gtk-2.0\gtk \__init__.py", line 45, in -toplevel- from _gtk import * File "E:\Program Files\Python2.4\Lib\site-packages\cairo \__init__.py", line 1, in -toplevel- from _cairo import * ImportError: DLL load failed: The specified procedure could not be found. From larry.bates at websafe.com` Wed Apr 16 14:47:31 2008 From: larry.bates at websafe.com` (Larry Bates) Date: Wed, 16 Apr 2008 13:47:31 -0500 Subject: Default parameter for a method In-Reply-To: <806788d2-67b7-456b-bd1e-08c50cbf0f7b@8g2000hsu.googlegroups.com> References: <806788d2-67b7-456b-bd1e-08c50cbf0f7b@8g2000hsu.googlegroups.com> Message-ID: s0suk3 at gmail.com wrote: > I wanted to know if there's any way to create a method that takes a > default parameter, and that parameter's default value is the return > value of another method of the same class. For example: > > class A: > def __init__(self): > self.x = 1 > > def meth1(self): > return self.x > > def meth2(self, arg=meth1()): > # The default `arg' should would take the return value of > meth1() > print '"arg" is', arg > > This obviously doesn't work. I know I could do > > ... > def meth2(self, arg=None): > if arg is None: > arg = self.meth1() > > but I'm looking for a more straightforward way. You can write this as: def meth2(self, arg=None): arg = arg or self.meth1() IMHO - You can't get much more "straightforward" than that. -Larry From sjmachin at lexicon.net Fri Apr 25 08:46:09 2008 From: sjmachin at lexicon.net (John Machin) Date: Fri, 25 Apr 2008 05:46:09 -0700 (PDT) Subject: problem with unicode References: <26fcc207-b864-42c7-afb3-c6945e5fe29f@m44g2000hsc.googlegroups.com> <67dvg8F2nomm6U1@mid.individual.net> Message-ID: On Apr 25, 10:01 pm, Bjoern Schliessmann wrote: > andreas.prof... at googlemail.com wrote: > > # media is a binary string (mysql escaped zipped file) > > >>>> print media > > x???[? ... > > (works) > > Which encoding, perhaps UTF-8 or ISO8859-1? > > >>>> print unicode(media) > > UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in > > position 1: ordinal not in range(128) > > (ok i guess print assumes you want to print to ascii) > > Not at all -- unicode tries to decode the byte string you gave it, > but doesn't know which encoding to use, so it falls back to ASCII. > > You should decode all "incoming" byte strings to unicode objects > using the right encoding -- here I tried yours with UTF-8. This > works best using string's method "decode" which returns a unicode > object. > > >>> media="x???[?" > >>> print repr(media.decode("utf-8")) > > u'x\u30ef\u30e6\u30ed[\u30e8' > But that_unicode_string.encode("utf-8") produces 'x\xe3\x83\xaf\xe3\x83\xa6\xe3\x83\xad[\xe3\x83\xa8' which does not contain the complained-about byte 0x9c in position 1 (or any other position) -- how can that be? From __peter__ at web.de Fri Apr 4 04:29:56 2008 From: __peter__ at web.de (Peter Otten) Date: Fri, 04 Apr 2008 10:29:56 +0200 Subject: Is there an official way to add methods to an instance? References: Message-ID: Brian Vanderburg II wrote: > I don't know if this is the correct place to send this question. It is. > I've checked out some ways to get this to work. I want to be able to > add a new function to an instance of an object. I've tested two > different methods that cause problems with 'deleting'/garbage collection > (__del__ may never get called), but implemented one sort of hackishly > maybe that works find. I'm wondering if there is more of an official way > than mine. [snip] I think "Try hard to avoid __del__()" is as close to an official stance as you can get ;) Anyway, here is one more option to add too the zoo: >>> class A(object): ... def __init__(self, f, x): ... self._f = f ... self.x = x ... @property ... def f(self): ... return self._f.__get__(self) ... def __del__(self): ... print "deleting" ... >>> a = A(lambda s: s.x * 2, 2) >>> b = A(lambda s: s.x * 3, 3) >>> a.f() 4 >>> b.f() 9 >>> del a deleting >>> del b deleting Peter From cmpython at gmail.com Mon Apr 7 01:05:33 2008 From: cmpython at gmail.com (CM) Date: Sun, 6 Apr 2008 22:05:33 -0700 (PDT) Subject: Learning curve for new database program with Python? References: Message-ID: <521b0a89-8d86-4cc2-8029-4aa731522b34@b1g2000hsg.googlegroups.com> On Apr 5, 11:50 am, Jetus wrote: > I have a need for a database program. I downloaded the db2 from ibm, > and reviewed some of the documentation. > > My question is, what is the easiest program for me to try to learn. I > will be creating a database of about 25,000 records, it will be > relational. I am a beginner Python programmer, and need a database > solution that is easy to grasp. I played with sql, > and found that very difficult, if not overly cumbersome. > > A database that could work with Django would be very interesting to > look at as well.. > > Any suggestions out there? Re: Django...from the Django site: "If you want to use Django with a database, which is probably the case, you'll also need a database engine. PostgreSQL is recommended, because we're PostgreSQL fans, and MySQL, SQLite 3, and Oracle are also supported." Those all use SQL, and really if you are using a relational database, SQL is pretty much what is used. SQL has not struck me as difficult nor cumbersome, e.g., for a database table called "customers" that has a column called "name" and "city": (in SQL): SELECT name FROM customers WHERE city='Chicago' (in partially shouted English): "GIVE ME ALL THE names OF customers WHOSE CITY IS Chicago.") or, in Python 2.5 if you import sqlite3: import sqlite3 conn = sqlite3.connect('C:/Documents and Settings/user/Desktop/ somedatabase.db') cur = conn.cursor() cur.execute("SELECT name FROM customers WHERE city='Chicago'") I've enjoyed using SQLite in Python, and there's some good online documentation to help there. And SQLite, Python, Django all play well together, somehow, AFAIK. From kveretennicov at gmail.com Wed Apr 2 16:12:20 2008 From: kveretennicov at gmail.com (Konstantin Veretennicov) Date: Wed, 2 Apr 2008 23:12:20 +0300 Subject: Python queue madness In-Reply-To: <28749c0e0804020652o74a9491an9eef9ba1813434fb@mail.gmail.com> References: <28749c0e0804020652o74a9491an9eef9ba1813434fb@mail.gmail.com> Message-ID: <4660fe300804021312v26e0bf86h6f45fd1e305ee0bf@mail.gmail.com> On Wed, Apr 2, 2008 at 4:52 PM, nnp wrote: > > Is there any other way for data to get onto a queue Yes, by manipulating Queue.Queue's internal "queue" attribute directly. > or are there any known bugs with Python's Queue module that could lead to > this kind of behaviour? > Much more likely your code has some unexpected behavior. Could you arrange a minimal example that reproduces the problem? -- kv -------------- next part -------------- An HTML attachment was scrubbed... URL: From hdante at gmail.com Sat Apr 12 11:17:23 2008 From: hdante at gmail.com (hdante) Date: Sat, 12 Apr 2008 08:17:23 -0700 (PDT) Subject: accessing individual characters in unicode strings References: Message-ID: On Apr 12, 9:48 am, Christian Heimes wrote: > Peter Robinson schrieb: > > > Dear list > > I am at my wits end on what seemed a very simple task: > > I have some greek text, nicely encoded in utf8, going in and out of a > > xml database, being passed over and beautifully displayed on the web. > > For example: the most common greek word of all 'kai' (or ??? if your > > mailer can see utf8) > > So all I want to do is: > > step through this string a character at a time, and do something for > > each character (actually set a width attribute somewhere else for each > > character) > > As John already said: UTF-8 ain't unicode. UTF-8 is an encoding similar > to ASCII or Latin-1 but different in its inner workings. A single > character may be encoded by up to 6 bytes. Up to 4 bytes in the latest versions. (the largest value is U+10FFFF and is represented by 0xF4 0x8F 0xBF 0xBF). I believe the proper way for returning the number of characters for Greek would require a normalization first: from unicodedata import normalize def greek_text_length(utf8_string): u = unicode(utf8_string, 'utf-8') u = normalize('NFC', u) return len(u) If there are pairs of characters that count as one, things may be worse. > > I highly recommend Joel's article on unicode: > > The Absolute Minimum Every Software Developer Absolutely, Positively > Must Know About Unicode and Character Sets (No Excuses!)http://www.joelonsoftware.com/articles/Unicode.html > > Christian From landerdebraznpc at gmail.com Mon Apr 28 03:53:10 2008 From: landerdebraznpc at gmail.com (landerdebraznpc at gmail.com) Date: Mon, 28 Apr 2008 00:53:10 -0700 (PDT) Subject: vista ultimate crack Message-ID: vista ultimate crack http://crack.cracksofts.com From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 15 05:19:48 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 15 Apr 2008 11:19:48 +0200 Subject: Dynamic use of property() fails In-Reply-To: References: <60c13399-f6d0-4920-b4a4-ab803609bc82@t54g2000hsg.googlegroups.com> <480461f8$0$20282$426a34cc@news.free.fr> Message-ID: <4804732e$0$19414$426a34cc@news.free.fr> andrew cooke a ?crit : > On Apr 15, 4:06 am, Bruno Desthuilliers 42.desthuilli... at websiteburo.invalid> wrote: > >> The canonical solution is to use a custom descriptor instead of a property: (snip code) > i tried code very similar after reading the first replies and found > that it did not work as expected on setting. for example, in > > person = Person() > person.age = 27 > > "age" is set in the instance's dictionary (as 27; the descriptor is > not called), which then shadows the definition of age in the class > dictionary. Are you sure your Person class is a new-style one (inheriting, directly or not, from object) ? The descriptor protocol doesn't work properly on old-style classes, with *exactly* the symptom you describe here (setter is not invoked, property get shadowed by an instance attribute) > my understanding was that the descriptor is only called in the class > context, The descriptor protocol is only invoked on class attributes. > so would be called if, say, a subclass tried to redefine > age. but maybe i am still confused. Possibly. > i am about to go to sleep. i guess i will try your code exactly > tomorrow, but it looks very close to mine which showed this problem. > are you sure your solution works? Yes - minus a couple (unrelated) typos ('name' instead of 'self.name' in Field.__set__, and 'self._values = []' instead of 'self._values = {}' in ActiveDAO.__init__). Here's the corrected one: class Field(object): def __init__(self, name, onchange): self.name = name self.onchange = onchange def __get__(self, instance, cls): if instance is None: # called on the class return self # called on instance return instance._values[self.name] def __set__(self, instance, value): instance._values[self.name] = self.onchange(value) class ActiveDAO(object): def __init__(self): self._values = {} class Person(ActiveDAO): name = Field('name', lambda v: v.strip().capitalize()) age = Field('age', lambda v : int(v)) From aguirre.adolfo at gmail.com Mon Apr 28 22:07:52 2008 From: aguirre.adolfo at gmail.com (aguirre.adolfo at gmail.com) Date: Mon, 28 Apr 2008 19:07:52 -0700 (PDT) Subject: Python Math libraries - How to? Message-ID: Hi, I am a very newbie who would very much appreciate some hints. Python 2.52. on Windows XP for now. Soon on Ubuntu 8 I am teaching myself Python following free tutorials. I can solve problems using arithmetic, but when I try to upgrade the programs using math libraries nothing seems to work. I downloaded a 2002 tutorial from Zelle "An Introduction to Computer Science" where he uses a "import math" statement to calculate a square root. I tried the "pi" library function but it didn?t work. I tried using def Pi() it did not work either. I am yet to find a tutorial that explains how to declare (or initialize) and pass numbers to the functions such as "cos(x)" and the pi which does not have a variable in it. Is just a constant. Here is the arithmetic program I made that it worked before I added the "import math" line. I erased the constant p = 3.1416 and added the "i" for the library function "pi" in the algorithms. But I get an error message not recognizing "pi" #volumen.py # A program to compute the volume and surface area of a sphere import math def main(): print "This program calculates the volume and surface area of a sphere" print r = input("Please enter the radious: ") print r3 = r*r*r volume = 4/3*pi*r3 r2 = r*r surface = 4*pi*r2 print "The Volume is", volume, " Cubic centimeters" print print "The Surface area is", surface, " square centimeters" main() *** Error message ************* Traceback (most recent call last): File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 20, in main() File "C:/Python25/z - MIS PROGRAMAS/volumen-b.py", line 13, in main volume = 4/3*pi*r3 NameError: global name 'pi' is not defined From arnodel at googlemail.com Sun Apr 13 02:06:29 2008 From: arnodel at googlemail.com (Arnaud Delobelle) Date: Sat, 12 Apr 2008 23:06:29 -0700 (PDT) Subject: class level properties References: Message-ID: <513c5440-5ff0-4642-bc76-cc24d3dfaaa8@u69g2000hse.googlegroups.com> On Apr 13, 12:33?am, Charles D Hixson wrote: > Arnaud Delobelle wrote: > >>>> class MetaX(type): > > > ... ? ? @property > > ... ? ? def spam(self): return 'eggs' > > ... > > >>>> class X(object): > > > ... ? ? ?__metaclass__ = MetaX > > ... > > >>>> X.spam > > > 'eggs' > > > HTH > > > -- > > Arnau > > Thanks. ?I can make that work. ?Is it possible to move the entire > implementation of the interpretation of ?_valueMap, below, into > properties in some similar way? ?I'm referring to the part managed by > __getattr__ below. > I want a hundred or so read-only variables, and I'm not sure the best > way to achieve it. [snip code sample] * Do you want to be able to access your attributes from instances as well or from the class object only? The metaclass trick creates attributes only accessible from the class object, i.e. in my example above: >>> x=X() >>> x.spam Traceback (most recent call last): File "", line 1, in AttributeError: 'X' object has no attribute 'spam' * If you have a hundred of so names and values, are you sure you want to expose them as attributes? It seems to me that they should be in their own namespace (as keys in a mapping or attributes of a subobject) -- Arnaud From dolloffdelvpg at gmail.com Wed Apr 16 08:07:05 2008 From: dolloffdelvpg at gmail.com (dolloffdelvpg at gmail.com) Date: Wed, 16 Apr 2008 05:07:05 -0700 (PDT) Subject: taylor swift concert dates Message-ID: <19bea8be-033e-4fed-b33a-3d2401d58cac@k1g2000prb.googlegroups.com> Just few link on some Movies Free Movies: http://exclusive.12w.net F R E E C E L E B R I T Y M O V I E S From bruno.42.desthuilliers at websiteburo.invalid Tue Apr 29 05:03:54 2008 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 29 Apr 2008 11:03:54 +0200 Subject: Given a string - execute a function by the same name In-Reply-To: References: Message-ID: <4816e474$0$15296$426a74cc@news.free.fr> python at bdurham.com a ?crit : > I'm parsing a simple file and given a line's keyword, would like to call > the equivalently named function. > > There are 3 ways I can think to do this (other than a long if/elif > construct): > > 1. eval() > > 2. Convert my functions to methods and use getattr( myClass, "method" ) > > 3. Place all my functions in dictionary and lookup the function to be > called > 4. Place all your functions in a module and use getattr(the_module, "func") 5. use globals().get("func") > Any suggestions on the "best" way to do this? #1 is the worst possible solution, and #2 doesn't make sens if you don't need methods. #4 is simple but can be problematic since these functions are not necessarily related enough to make for a module with hi cohesion and low coupling. #5 is the simplest solution, but can be dangerous, since just any function in the global namespace (which includes the builtins...) can be called. #3 is a bit heaviest to setup and maintain, but much more secure since you explicitely choose the availables functions. Depending on the context (ie: where this 'simple file' comes from), I'd choose #3 or #5. My 2 cents... From darcy at druid.net Tue Apr 29 15:39:30 2008 From: darcy at druid.net (D'Arcy J.M. Cain) Date: Tue, 29 Apr 2008 15:39:30 -0400 Subject: Colors for Rows In-Reply-To: <1209495803.5173.11.camel@aalcdl07.lib.unc.edu> References: <4dc0cfea0804290733ic99e45eyec23a6d5b719eb8@mail.gmail.com> <20080429121105.f10c3862.darcy@druid.net> <4dc0cfea0804291114p4680f4bgb8446e7c6cb842cb@mail.gmail.com> <1209495803.5173.11.camel@aalcdl07.lib.unc.edu> Message-ID: <20080429153930.a6eddea6.darcy@druid.net> On Tue, 29 Apr 2008 15:03:23 -0400 "J. Cliff Dyer" wrote: > Or, if you aren't sure how many colors you'll be using, try the more > robust: > > bg[z % len(bg)] Good point although I would have calculated the length once at the start rather than each time through the loop. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From sn at sncs.se Thu Apr 17 04:41:30 2008 From: sn at sncs.se (Sverker Nilsson) Date: Thu, 17 Apr 2008 01:41:30 -0700 (PDT) Subject: py3k s***s References: <4af0dd7d-6a05-46be-b107-d9741ced012c@y18g2000pre.googlegroups.com> <3a0c507c-4bc9-40bf-83b7-08a16daebec4@p25g2000pri.googlegroups.com> <9cd6c08a-b152-4a91-8f0c-4b876664ceb9@b64g2000hsa.googlegroups.com> <11567a1a-b184-42e6-bbf3-a655736c19c7@p25g2000hsf.googlegroups.com> <4836327b-f03a-4a2d-85d5-be023292fdd5@h1g2000prh.googlegroups.com> <7fecd375-0baf-43f2-9d6e-abc11cb8a0f7@m71g2000hse.googlegroups.com> Message-ID: On Apr 17, 12:02 am, Carl Banks wrote: > On Apr 16, 12:40 pm, Aaron Watters wrote: > > > > > On Apr 16, 12:27 pm, Rhamphoryncus wrote: > > > > On Apr 16, 6:56 am, Aaron Watters wrote: > > > > > I don't get it. It ain't broke. Don't fix it. > > > > So how would you have done the old-style class to new-style class > > > transition? > > > I'd ignore it. I never understood it and never had > > any need for it anyway. New-style classes and metaclasses > > were a complicated solution to an unimportant problem in > > my opinion. And also a fiendish way to make code > > inscrutible -- which I thought was more of a Perl thing > > than a Python thing, or should be. > > > I must be missing some of the deeper issues here. Please > > educate me. > > The deeper issue is that you're benefiting from these "unimportant" > changes even if you never use them yourself. > > Carl Banks That just seems a BIT categorical for a statement. Who is 'you'? I don't see I benefit from any important or unimportant features in py3k. External libraries I rely on, I can benefit from --- But it would take SOME while to get those libraries ported to py3k, if ever. And I have been benefiting from Python in general, so far. Thanks, community. But now... I'll probably stop posting here for now, & I may stop other things too. Just my 2c. Sverker From tjreedy at udel.edu Wed Apr 9 00:09:37 2008 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 9 Apr 2008 00:09:37 -0400 Subject: text adventure game problem References: Message-ID: wrote in message news:cea9f806-a85d-4187-ac93-4f876a1be39c at l64g2000hse.googlegroups.com... | In the above function, there's the option to examine a cabinet and get | 8 gold. (everyone here knows that...but I'm just trying to state my | problem...) | Unfortunately, it kind of doesn't work. | After the first time I 'examine cabinet 1' in my game, I get 8 gold | and I can't get it again. | But, If I leave the room and come back to it, then it's as if I had | never gotten the gold the first time, and I can get it again. | How do I fix this? I would define a container class. The init function gives it a name and contents (8 gold, for instance). Give kitchen a container('cabinet', 8). Give containers a .examine() method which gives the contents to the player. and a message which varies with the contents. You can even make some container 'refreshable' if you want. tjr From v.harishankar at gmail.com Wed Apr 23 07:17:03 2008 From: v.harishankar at gmail.com (Harishankar) Date: Wed, 23 Apr 2008 16:47:03 +0530 Subject: [Python 2.4/2.5] subprocess module is sorely deficient? In-Reply-To: <811891.72800.qm@web39208.mail.mud.yahoo.com> References: <811891.72800.qm@web39208.mail.mud.yahoo.com> Message-ID: <200804231647.03614.v.harishankar@gmail.com> On Wednesday 23 Apr 2008 15:11:21 Ben Kaplan wrote: > I don't know about all Linux distros, but my Ubuntu machine (8.04 Beta), > has the 'TERM' (xterm) and 'COLORTERM' (gnome-terminal) keys in os.environ. > You might be able to use that to ensure that the terminal is installed, but > you should probably look at a couple of other popular distros first to make > sure that the key is there. This is set on Debian too. Thanks. I should be able to use this environment variable on most Linux distributions, I suspect. -- Regards, V. Harishankar http://hari.literaryforums.org http://harishankar.org From mensanator at aol.com Wed Apr 16 13:42:40 2008 From: mensanator at aol.com (Mensanator) Date: Wed, 16 Apr 2008 10:42:40 -0700 (PDT) Subject: vary number of loops References: Message-ID: <86c2ba05-d83d-44a3-b044-6daa90b4d3f7@b64g2000hsa.googlegroups.com> On Apr 16, 8:31?am, nullgr... at gmail.com wrote: > Hi everyone, > > I'm new to Python and the notion of lambda, and I'm trying to write a > function that would have a varying number of nested for loops > depending on parameter n. This just smells like a job for lambda for > me, but I can't figure out how to do it. Any hint? > > For example, for n=2, I want the function to look something like: > > def foo(2) > ? ?generate 2 sets of elements A, B > ? ?# mix elements by: > ? ?for a_elt in A > ? ? ? for b_elt in B > ? ? ? ? ?form all combinations of them > > If n=3, I want to have 3 sets of elements and mix them up using 3 for > loops. > > Any help is greatly appreciated, > > nullgraph There's always the stupid way: def ooloop6(a, n, perm=True, repl=True): if (not repl) and (n>len(a)): return r0 = range(n) r1 = r0[1:] if perm and repl: # permutations with replacement v = ','.join(['c%s' % i for i in r0]) f = ' '.join(['for c%s in a' % i for i in r0]) e = ''.join(["p = [''.join((",v,")) ",f,"]"]) exec e return p if (not perm) and repl: # combinations with replacement v = ','.join(['c%s' % i for i in r0]) f = ' '.join(['for c%s in a' % i for i in r0]) i = ' and '.join(['(c%s>=c%s)' % (j,j-1) for j in r1]) e = ''.join(["p = [''.join((",v,")) ",f," if ",i,"]"]) exec e return p if perm and (not repl): # permutaions without replacement v = ','.join(['c%s' % i for i in r0]) f = ' '.join(['for c%s in a' % i for i in r0]) i = ' and '.join([' and '.join(['(c%s!=c%s)' % (j,k) for k in range(j)]) for j in r1]) e = ''.join(["p = [''.join((",v,")) ",f," if ",i,"]"]) exec e return p if (not perm) and (not repl): # combinations without replacement v = ','.join(['c%s' % i for i in r0]) f = ' '.join(['for c%s in a' % i for i in r0]) i = ' and '.join(['(c%s>c%s)' % (j,j-1) for j in r1]) e = ''.join(["p = [''.join((",v,")) ",f," if ",i,"]"]) exec e print '\n\n',e,'\n\n' return p a = 'abcdefghij' n = 6 # for lotto use Combinations without Replacement p = ooloop6(a,n,False, False) ################################################################## Here's the code that gets executed: ## p = [''.join((c0,c1,c2,c3,c4,c5)) for c0 in a ## for c1 in a for c2 in a for c3 in a for c4 in a ## for c5 in a if (c1>c0) and (c2>c1) and (c3>c2) ## and (c4>c3) and (c5>c4)] From hypocrite at lawyer.com Wed Apr 16 03:50:49 2008 From: hypocrite at lawyer.com (Pete Crite) Date: Wed, 16 Apr 2008 17:50:49 +1000 Subject: Python crashes consistently Message-ID: Hello, I've been trying to install Gnumeric via MacPorts recently, but I can't get past the installation of py25-numpy. It appears that python crashes consistently during installation. I'm not sure if this is related to python itself, but I just thought I'd ask here, just in case anyone else was aware of this problem. I did have a few problems during the installation, so perhaps it might be related to them? Is there anyway to check that my installation of python is valid? I'm using OS X 10.4.11 on a Mac Mini PPC. I have attached the error messages from the terminal and the mac pop-up window from the crash. Any help would be very much appreciated! Cheers, Pete. The terminal says: > Error: Target org.macports.build returned: shell command " cd "/opt/ > local/var/macports/build/ > _opt_local_var_macports_sources_rsync.macports.org_release_ports_pytho > n_py25-numpy/work/numpy-1.0.4" && /opt/local/bin/python2.5 setup.py > config_fc --fcompiler g95 --f77exec /opt/local/bin/g95 --f90exec / > opt/local/bin/g95 build " returned error 139 > Command output: Running from numpy source directory. > > Error: The following dependencies failed to build: py25-gtk py25- > cairo py25-numpy > Error: Status 1 encountered during processing. > The crash window that pops up says: > Date/Time: 2008-03-30 11:30:33.545 +1100 > OS Version: 10.4.11 (Build 8S165) > Report Version: 4 > > Command: python2.5 > Path: /opt/local/bin/python2.5 > Parent: sh [247] > > Version: ??? (???) > > PID: 248 > Thread: 0 > > Exception: EXC_BAD_ACCESS (0x0001) > Codes: KERN_INVALID_ADDRESS (0x0001) at 0x82008000 > > Thread 0 Crashed: > 0 _random.so 0x00571334 random_seed + 644 > (_randommodule.c:297) > 1 _random.so 0x0057131c random_seed + 620 > (_randommodule.c:292) > 2 libpython2.5.dylib 0x002b1788 PyEval_EvalFrameEx + 17604 > (ceval.c:3573) > 3 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 > (ceval.c:2836) > 4 libpython2.5.dylib 0x002b19ac PyEval_EvalFrameEx + 18152 > (ceval.c:3669) > 5 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 > (ceval.c:2836) > 6 libpython2.5.dylib 0x0023969c function_call + 332 > (funcobject.c:524) > 7 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: > 1862) > 8 libpython2.5.dylib 0x0021960c instancemethod_call + 764 > (classobject.c:2520) > 9 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: > 1862) > 10 libpython2.5.dylib 0x0026e81c slot_tp_init + 72 (typeobject.c: > 4944) > 11 libpython2.5.dylib 0x00273f88 type_call + 664 (typeobject.c:436) > 12 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: > 1862) > 13 libpython2.5.dylib 0x002b2fc8 PyEval_EvalFrameEx + 23812 > (ceval.c:3786) > 14 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 > (ceval.c:2836) > 15 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) > 16 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 > (import.c:676) > 17 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 > (import.c:960) > 18 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: > 2401) > 19 libpython2.5.dylib 0x002cd7d4 load_next + 300 (import.c:2221) > 20 libpython2.5.dylib 0x002cde8c import_module_level + 624 > (import.c:2002) > 21 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 > (import.c:2072) > 22 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 > (bltinmodule.c:49) > 23 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: > 1862) > 24 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + > 276 (ceval.c:3443) > 25 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 > (ceval.c:2067) > 26 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 > (ceval.c:2836) > 27 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) > 28 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 > (import.c:676) > 29 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 > (import.c:960) > 30 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: > 2401) > 31 libpython2.5.dylib 0x002cd828 load_next + 384 (import.c:2225) > 32 libpython2.5.dylib 0x002cde8c import_module_level + 624 > (import.c:2002) > 33 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 > (import.c:2072) > 34 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 > (bltinmodule.c:49) > 35 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: > 1862) > 36 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + > 276 (ceval.c:3443) > 37 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 > (ceval.c:2067) > 38 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 > (ceval.c:2836) > 39 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) > 40 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 > (import.c:676) > 41 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 > (import.c:960) > 42 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: > 2401) > 43 libpython2.5.dylib 0x002cd7d4 load_next + 300 (import.c:2221) > 44 libpython2.5.dylib 0x002cde8c import_module_level + 624 > (import.c:2002) > 45 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 > (import.c:2072) > 46 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 > (bltinmodule.c:49) > 47 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: > 1862) > 48 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + > 276 (ceval.c:3443) > 49 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 > (ceval.c:2067) > 50 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 > (ceval.c:2836) > 51 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) > 52 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 > (import.c:676) > 53 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 > (import.c:960) > 54 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: > 2401) > 55 libpython2.5.dylib 0x002cdb68 ensure_fromlist + 552 (import.c: > 2312) > 56 libpython2.5.dylib 0x002ce03c import_module_level + 1056 > (import.c:2038) > 57 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 > (import.c:2072) > 58 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 > (bltinmodule.c:49) > 59 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: > 1862) > 60 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + > 276 (ceval.c:3443) > 61 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 > (ceval.c:2067) > 62 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 > (ceval.c:2836) > 63 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) > 64 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 > (import.c:676) > 65 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 > (import.c:960) > 66 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: > 2401) > 67 libpython2.5.dylib 0x002cd7d4 load_next + 300 (import.c:2221) > 68 libpython2.5.dylib 0x002cde8c import_module_level + 624 > (import.c:2002) > 69 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 > (import.c:2072) > 70 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 > (bltinmodule.c:49) > 71 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: > 1862) > 72 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + > 276 (ceval.c:3443) > 73 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 > (ceval.c:2067) > 74 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 > (ceval.c:2836) > 75 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) > 76 libpython2.5.dylib 0x002cbea0 PyImport_ExecCodeModuleEx + 292 > (import.c:676) > 77 libpython2.5.dylib 0x002cc3a0 load_source_module + 1032 > (import.c:960) > 78 libpython2.5.dylib 0x002ccf20 load_package + 336 (import.c:1015) > 79 libpython2.5.dylib 0x002cd564 import_submodule + 392 (import.c: > 2401) > 80 libpython2.5.dylib 0x002cd7d4 load_next + 300 (import.c:2221) > 81 libpython2.5.dylib 0x002cdec0 import_module_level + 676 > (import.c:2009) > 82 libpython2.5.dylib 0x002cefc0 PyImport_ImportModuleLevel + 228 > (import.c:2072) > 83 libpython2.5.dylib 0x002a68a0 builtin___import__ + 132 > (bltinmodule.c:49) > 84 libpython2.5.dylib 0x0020f778 PyObject_Call + 52 (abstract.c: > 1862) > 85 libpython2.5.dylib 0x002abf38 PyEval_CallObjectWithKeywords + > 276 (ceval.c:3443) > 86 libpython2.5.dylib 0x002b09cc PyEval_EvalFrameEx + 14088 > (ceval.c:2067) > 87 libpython2.5.dylib 0x002b1924 PyEval_EvalFrameEx + 18016 > (ceval.c:3660) > 88 libpython2.5.dylib 0x002b39a8 PyEval_EvalCodeEx + 2148 > (ceval.c:2836) > 89 libpython2.5.dylib 0x002b3a9c PyEval_EvalCode + 48 (ceval.c:500) > 90 libpython2.5.dylib 0x002d8444 PyRun_FileExFlags + 288 > (pythonrun.c:1274) > 91 libpython2.5.dylib 0x002d87fc PyRun_SimpleFileExFlags + 840 > (pythonrun.c:879) > 92 libpython2.5.dylib 0x002e9b74 Py_Main + 3184 (main.c:523) > 93 python2.5 0x000019d8 _start + 760 > 94 python2.5 0x000016dc start + 48 > > Thread 0 crashed with PPC Thread State 64: > srr0: 0x0000000000571334 srr1: > 0x000000000000d030 vrsave: 0x0000000000000000 > cr: 0x44244228 xer: 0x0000000000000004 lr: > 0x000000000057131c ctr: 0x0000000000000001 > r0: 0x0000000080000000 r1: 0x00000000bfff80a0 r2: > 0x00000000a0001fac r3: 0x0000000002008000 > r4: 0x0000000002008000 r5: 0x0000000000000000 r6: > 0x00000000bfff7fbc r7: 0x00000000000fdff8 > r8: 0x0000000001800400 r9: 0x000000000000000a r10: > 0x000000000000000a r11: 0x000000000000003f > r12: 0x000000009000661c r13: 0x00000000ffffffff r14: > 0x000000000000ccac r15: 0x00000000000c6930 > r16: 0x00000000000c9090 r17: 0x0000000000000000 r18: > 0x000000000031bf48 r19: 0x0000000000627b04 > r20: 0x00000000005710c4 r21: 0x0000000001858010 r22: > 0x000000000000d248 r23: 0x0000000001803814 > r24: 0x0000000002008000 r25: 0x0000000040000000 r26: > 0x0000000020000001 r27: 0x0000000000000000 > r28: 0x000000000004c0c0 r29: 0x000000000004c0c0 r30: > 0x0000000044244228 r31: 0x00000000005710c4 > > Binary Images Description: > 0x1000 - 0x1fff python2.5 /opt/local/bin/python2.5 > 0xe2000 - 0xe5fff strop.so /opt/local/lib/python2.5/lib- > dynload/strop.so > 0xf2000 - 0xf3fff math.so /opt/local/lib/python2.5/lib- > dynload/math.so > 0x205000 - 0x31afff libpython2.5.dylib /opt/local/lib/ > libpython2.5.dylib > 0x565000 - 0x567fff binascii.so /opt/local/lib/python2.5/lib- > dynload/binascii.so > 0x570000 - 0x571fff _random.so /opt/local/lib/python2.5/lib- > dynload/_random.so > 0x8fe00000 - 0x8fe52fff dyld 46.16 /usr/lib/dyld > 0x90000000 - 0x901bcfff libSystem.B.dylib /usr/lib/libSystem.B.dylib > 0x90214000 - 0x90219fff libmathCommon.A.dylib /usr/lib/system/ > libmathCommon.A.dylib > 0x945e0000 - 0x94600fff libmx.A.dylib /usr/lib/libmx.A.dylib > > Model: PowerMac10,1, BootROM 4.8.9f1, 1 processors, PowerPC G4 > (1.2), 1.25 GHz, 1 GB > Graphics: ATI Radeon 9200, ATY,RV280, AGP, 32 MB > Memory Module: DIMM0/J11, 1 GB, DDR SDRAM, PC3200U-30330 > Modem: Jump, V.92, Version 1.0 > Network Service: Built-in Ethernet, Ethernet, en0 > Parallel ATA Device: ST940110A, 37.26 GB > Parallel ATA Device: MATSHITACD-RW CW-8124 > USB Device: Hub in Apple Pro Keyboard, Mitsumi Electric, Up to 12 > Mb/sec, 500 mA > USB Device: PS/2+USB Mouse, Up to 1.5 Mb/sec, 100 mA > USB Device: C-Media USB Headphone Set, Up to 12 Mb/sec, 100 mA > USB Device: Apple Pro Keyboard, Mitsumi Electric, Up to 12 Mb/sec, > 250 mA > From http Mon Apr 21 18:20:33 2008 From: http (Paul Rubin) Date: 21 Apr 2008 15:20:33 -0700 Subject: sys.maxint in Python 3 References: Message-ID: <7xod82df4e.fsf@ruckus.brouhaha.com> bearophileHUGS at lycos.com writes: > In some algorithms a sentinel value may be useful, so for Python 3.x Better to just use object() to generate sentinels. From python.list at tim.thechases.com Sat Apr 5 20:08:19 2008 From: python.list at tim.thechases.com (Tim Chase) Date: Sat, 05 Apr 2008 19:08:19 -0500 Subject: while-loops enter the last time after condition is filled? In-Reply-To: References: Message-ID: <47F81473.3050503@tim.thechases.com> > it seems to me from my results that when i use a while-loop it > will execute once after the condition is met. Nope. > ie the conditions is met the code executes one time more and > then quits. Must be that your conditional is wrong, or your conditions are not updated the way you think they are. -tkc From steve at holdenweb.com Sun Apr 20 14:31:29 2008 From: steve at holdenweb.com (Steve Holden) Date: Sun, 20 Apr 2008 14:31:29 -0400 Subject: Any reliable obfurscator for Python 2.5 In-Reply-To: <480b6133$0$34498$742ec2ed@news.sonic.net> References: <3de8e1f70804192155p2fd6e577x6f0354a3fc5b8d41@mail.gmail.com> <3de8e1f70804200632i31768d8atc235e8b6a7137173@mail.gmail.com> <480b6133$0$34498$742ec2ed@news.sonic.net> Message-ID: <480B8C01.1080306@holdenweb.com> JB "My first post on c.l.py" Stern wrote: > Banibrata Dutta wrote: >>> Wanted to check if there is any known, reliable, FOSS/Libre -- Obfurscator >>> for Python 2.5 code. > > No, sadly, there is not. There are a number of applications I would be > working on if it were possible to obfuscate pyc files. About the best > you can do as of 2008/04 is use Jython to compile into Java bytecode and > obfuscate that using Proguard. > > Steve 'not an economics major' Holden wrote: >> The Python world isn't particularly paranoid about obfuscation. It's >> quite easy to publish compiled code only (.pyc and/or .pyo files), and >> that offers enough protection for most. > > Curious Steve, how do you pay the rent and by what authority do you > speak for "The Python world"? Your opinion couldn't be more wrong for > programmers like myself who live by the code they write (as opposed to > its support). > I pay the mortgage by creating software systems, though not usually packaged systems for shrink-wrap sale. I don't claim to speak *for* the whole Python world, but as chairman of the Python Software Foundation and a long-time member of this mailing list I can probably claim to be more closely in touch with it than many--yourself included, apparently. If it's important to you to be able to obfuscate your code then you have made an inapposite choice of language. > Steve 'not a software consultant' Holden wrote: >> The sad fact is that there seems to be an almost direct inverse >> correlation between the worth of the code and the authors' desire to >> protect it from piracy. > > Would love to see some evidence to that effect. > That is just an observation based on the many similar posts that have been made on this list, not one of them coming from the author of a recognized software package, plus forty years experience in the software industry. The ripping of of source code is far less frequent that novice programmers believe. The code that novice programmers write is almost always less valuable than they believe. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From smithy at hotmail.com Mon Apr 14 09:40:02 2008 From: smithy at hotmail.com (smithy at hotmail.com) Date: Mon, 14 Apr 2008 14:40:02 +0100 (BST) Subject: A Question Message-ID: <200804141340.CBB79947@manxnetsf02.manx.net> Werdle? From elbertlev at hotmail.com Sun Apr 13 20:21:29 2008 From: elbertlev at hotmail.com (Lev Elbert) Date: Sun, 13 Apr 2008 17:21:29 -0700 (PDT) Subject: email module windows and suse References: <0j35041u36l70vhmov0uvfmv8ftp5npp2i@4ax.com> Message-ID: <25696d24-b989-4555-8cd6-b0c95553829d@r9g2000prd.googlegroups.com> On Apr 13, 3:55?pm, Tim Roberts wrote: > Lev Elbert wrote: > > >I have to make a custom email module, based on the standard one. The > >custom module has to be able to work with extremely large mails (1GB > >+), having memory "footprint" much smaller. > > Then you have a design problem right from the start. ?It is extremely rare > to find a mail server today that will transmit email messages larger than a > few dozen megabytes. ?Even on a 100 megabit network, it's takes a minute > and a half for a 1GB message to go from the server to the user's > workstation. > > What are you really trying to do here? ?In most cases, you would be better > off storing your attachments on a web server and transmitting links in the > email. > > >The modified program has to work in SUSE environment, while the > >development is done under Windows. ?I'm not too good with linux and do > >not know if speedup in Windows translates one-to-one into speedup in > >SUSE. For example, if the bottleneck is IO, in windows I can spawn a > >separate thread or 2 to do "read-ahead". > > We would need more information on your processing to advise you on this. > Disk I/O is slow, network I/O is slower. ?You can't go any faster than your > slowest link. > > >Are threads available and as effective in SUSE as they are in Windows? > > Threads are available in Linux. ?There is considerable debate over the > relative performace improvement. > -- > Tim Roberts, t... at probo.com > Providenza & Boekelheide, Inc. Thank you. I have a 100mb mail file. I just made a very simple expiremnt the message_from_file method boils down to a loop: 1 while True: 2 data = fp.read(block_size) 3 if not data: 4 break 5 feedparser.feed(data) 6 Total time is 21 seconds (lines 1-6), while processing (non IO) lines 3-5 is 20 seconds. This means, that no IO optimization would help. This also explains the following fact: changing the block_size from 8K to 1M has almost no processing time impact. Also multithreading wouldn't help. I beleive I have to change Message class (more exactly: derive another class, which would store pieces on a disk. From lee.walczak at gmail.com Fri Apr 4 18:58:26 2008 From: lee.walczak at gmail.com (lee.walczak at gmail.com) Date: Fri, 4 Apr 2008 15:58:26 -0700 (PDT) Subject: Importing a 3rd Party windows DLL for use within th Python Message-ID: <92513305-836d-4c85-aeb8-3e3d6571ed92@1g2000prg.googlegroups.com> Hi, I have recently started learing how to code/script in Python which I am realy enjoying. I am new to this game as my background is RF/HW design engineer so coding is not my first skillset , so please bare with me! I am a little lost with how to procede on this problem. I need to write a python script enabling me to comunnicate routines to a pico ADC212 oscilloscope. I have been provided with a windows DLL & a header filefrom the manufacturer. Is it possible for someone to provide the information on the steps necessary to access this DLL and treat it like any other pyd library? Maybe there is already a tutorial available for performing this task? Is this task straight forward? Look forward to 'a' response! B.Regards, Lee Feel free to request more information if you feel it is necessary. From hobgoodoreneyhb at gmail.com Tue Apr 22 11:44:11 2008 From: hobgoodoreneyhb at gmail.com (hobgoodoreneyhb at gmail.com) Date: Tue, 22 Apr 2008 08:44:11 -0700 (PDT) Subject: the pumpkin patch Message-ID: <7ff8cf39-d231-4110-8aa7-e419f4f960a0@l64g2000hse.googlegroups.com> the pumpkin patch http://cracks.12w.net F R E E C R A C K S From dj3vande at csclub.uwaterloo.ca.invalid Wed Apr 2 16:52:10 2008 From: dj3vande at csclub.uwaterloo.ca.invalid (dj3vande at csclub.uwaterloo.ca.invalid) Date: Wed, 2 Apr 2008 20:52:10 +0000 (UTC) Subject: Recursive function won't compile References: Message-ID: In article , wrote: (Subject: Recursive function won't compile) >#include >#include > >def RecursiveFact(n): >......but yet it still gives the right answer. How is this possible? Possibly because it gives the right answer in a different language than it fails to compile in? dave -- Dave Vandervies dj3vande at eskimo dot com A violent rewrite could produce something worthwhile; as it is you need enough experience to not need the book to be able to read it. Well, that makes sense to me, anyhow. --CBFalconer in comp.lang.c From gabriel.rossetti at mydeskfriend.com Fri Apr 25 10:38:48 2008 From: gabriel.rossetti at mydeskfriend.com (Gabriel Rossetti) Date: Fri, 25 Apr 2008 16:38:48 +0200 Subject: why does the following with Queue, q.put('\x02', True) not put it in the queue? Message-ID: <4811ECF8.2020307@mydeskfriend.com> Hello, I'm having some trouble with the Queue class, for some reason, if I do this (ch == ) : q = Queue.Queue(0) repr(ch) q.put(ch, True) len(q.queue) where the output is : '\x02' 0 why isn't the character/string being put it in the queue? Thank you, Gabriel From markjreed at gmail.com Thu Apr 17 15:00:22 2008 From: markjreed at gmail.com (Mark Reed) Date: Thu, 17 Apr 2008 12:00:22 -0700 (PDT) Subject: Tidy module? Message-ID: Is there an easy_installable egg with an interface to libtidy? I found ?Tidy, but it looks like an inactive project, with no updates since 2004, so I'm skeptical of its reliability. I found mxTidy, but it's only available as part of some larger distribution, and I don't want to replace my Python installation. Is there one out there that I missed? Preferably, it'd be a single module I can drop into my current Python 2.5 installation, ideally via easy_install, to get tidy functionality without having to resort to os.popen("tidy"). Thanks in advance for any pointers. From mmanns at gmx.net Sun Apr 27 13:07:28 2008 From: mmanns at gmx.net (Martin Manns) Date: Sun, 27 Apr 2008 19:07:28 +0200 Subject: ANN: pyspread 0.0.4 References: Message-ID: On Sun, 27 Apr 2008 05:21:56 +0200 Martin Manns wrote: > The newest version pyspread 0.0.4 now runs on > + GTK > + Windows > + Mac (not tested myself but got positive reports) > > New features in 0.0.4: > + Column, line and table insertion and deletion > + Themeable toolbar I forgot to post the short description and the link: pyspread is a spreadsheet that accepts a pure python expression in each cell. Highlights: + No non-python syntax add-ons + Access to python modules from cells + 3D grid + Numpy object array for representation of string entry into grid cell + Numpy object array for representation of eval function array + Cell access via slicing of numpy function array + X, Y, and Z yield current cell location for relative reference Requires: Python >=2.4, Numpy 1.0.4, and wxPython 2.8.7.1. License: GPL Project page: http://pyspread.sourceforge.net Best Regards Martin From james at reggieband.com Thu Apr 17 18:11:40 2008 From: james at reggieband.com (james at reggieband.com) Date: Thu, 17 Apr 2008 15:11:40 -0700 (PDT) Subject: Request a short code review References: <3822d349-c382-4d27-af32-9aa43038f9d7@d45g2000hsc.googlegroups.com> Message-ID: > I am not necessarily looking to make the code shorter or more > functional or anything in particular. However if you spot something > to improve then I am happy to learn. To give an example of what I mean I have already altered the code: def output_random_lesson_of_type(self, type=None): """Output a lesson of a specific type. If no type is passed in then output any type.""" output_lessons = self.lesson_data["lessons"] if type: filtered_lessons = filter(lambda x: x["type"] == type, self.lesson_data["lessons"]) if filtered_lessons: output_lessons = filtered_lessons else: print "Unable to find lessons of type %s." % type return self.output_random(output_lessons) Changes: - Respected a column width of 80 - Created the output_lessons variable, assigned it to a default. This remove an else statement and reduced the call to self.output_random to a single instance in the return statement Cheers, James From victorsubervi at gmail.com Thu Apr 10 13:04:43 2008 From: victorsubervi at gmail.com (Victor Subervi) Date: Thu, 10 Apr 2008 12:04:43 -0500 Subject: String Literal to Blob In-Reply-To: References: <4dc0cfea0804080824r19e570bdu522504223bf06170@mail.gmail.com> <4dc0cfea0804090754l32f8ca77l22e4c3da71997a77@mail.gmail.com> <47FCDC77.7030407@holdenweb.com> <4dc0cfea0804090911o67b95174kc1a720536d637da6@mail.gmail.com> <47FCF421.6000807@holdenweb.com> <4dc0cfea0804091029n6547ae87ref4b9593d8976687@mail.gmail.com> <4dc0cfea0804091129l64e066bbie783268eeb0f7897@mail.gmail.com> <4dc0cfea0804100746o1a8b8542kfdafba9ae6eeec5@mail.gmail.com> Message-ID: <4dc0cfea0804101004t334e3935pee043ecfe8b6575b@mail.gmail.com> Well, what I did was this: content = col_fields[0][14].tostring() pic = "tmp" + str(i) + ".jpg" img = open(pic, "w") img.write(content) print '

' % pic img.close() where I am incrementing i. Ugly. Stupid. But if it is the only way to do it in python, and I do not want to invest the time doing it in php, which I think would be prettier in this instance, then I guess it will do. Your thoughts appreciated. Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From http Fri Apr 4 05:23:36 2008 From: http (Paul Rubin) Date: 04 Apr 2008 02:23:36 -0700 Subject: Is there an official way to add methods to an instance? References: Message-ID: <7xve2yas87.fsf@ruckus.brouhaha.com> Brian Vanderburg II writes: > I've checked out some ways to get this to work. I want to be able to > add a new function to an instance of an object. Ugh. Avoid that if you can. But see: http://en.wikipedia.org/wiki/Monkey_patch From gagsl-py2 at yahoo.com.ar Mon Apr 21 19:54:29 2008 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Mon, 21 Apr 2008 20:54:29 -0300 Subject: how to pass C++ object to another C++ function via Python function References: <1810b155-5598-4f17-a8e9-e4aa848db5de@i36g2000prf.googlegroups.com> Message-ID: En Mon, 21 Apr 2008 19:11:31 -0300, grbgooglefan escribi?: > On Apr 21, 10:17?pm, "Gabriel Genellina" > wrote: >> En Mon, 21 Apr 2008 10:24:15 -0300, grbgooglefan >> escribi?: >> >> > I am trying to pass a C++ object to Python function. This Python >> > function then calls another C++ function which then uses this C++ >> > object to call methods of that object's class. >> >> > I tried something like this, but it did not work, gave core dump. >> >> You can't pass any arbitrary C object to a Python function. >> In this case you can use a PyCObject, a Python box around a void* >> pointer. >> Seehttp://docs.python.org/api/cObjects.html > > Yup, I looked at http://www.python.org/doc/ext/using-cobjects.html > also. I could not find in this example where is CObject used or > converted back from Python to C. > Is there any tutorial which I can use for this? If you have a C function that receives a PyCObject, just include the relevant headers (cobject.h) and you can retrieve the original pointer using PyCObject_AsVoidPtr: void foo(PyObject *pyobj) { TOriginalType *porig; porig = (TOriginalType *)PyCObject_AsVoidPtr(pyobj); // do something with porig } -- Gabriel Genellina From medin0065 at gmail.com Sun Apr 20 10:48:02 2008 From: medin0065 at gmail.com (medin0065 at gmail.com) Date: Sun, 20 Apr 2008 07:48:02 -0700 (PDT) Subject: silverfall patch Message-ID: <69808366-68c4-4914-804d-a1d239c49445@w4g2000prd.googlegroups.com> silverfall patch http://cracks.00bp.com F R E E C R A C K S From fredrik at pythonware.com Sat Apr 5 12:08:16 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 05 Apr 2008 18:08:16 +0200 Subject: TKinter, buttonwidget response problem(1) and all btns the same size(2)! In-Reply-To: <8e6e67e8-979a-4515-be7c-16acdf687ce4@u36g2000prf.googlegroups.com> References: <09b43a29-8f35-4634-bded-7eaf389652cc@m3g2000hsc.googlegroups.com> <65ondkF2g48puU2@mid.uni-berlin.de> <8e6e67e8-979a-4515-be7c-16acdf687ce4@u36g2000prf.googlegroups.com> Message-ID: skanemupp at yahoo.se wrote: > i dont know, i used a piece of code i found which had a createwidgets- > method. isnt init a function, not a method btw(or it is the same > thing?) a method is a function defined inside a class statement, and which is designed to be called via an instance of that class. def function(): print "this is a function" def Class: def method(self): print "this is a method" function() # calls a function obj = Class() # create an instance (call __init__ if present) obj.method() # calls a method __init__ is automatically called when Python creates a new instance. if you create the widgets inside the init method or inside a separate method that's called from the init method (or from the outside) is up to you. From sturlamolden at yahoo.no Thu Apr 17 11:26:08 2008 From: sturlamolden at yahoo.no (sturlamolden) Date: Thu, 17 Apr 2008 08:26:08 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> Message-ID: <181216e5-7162-47c8-b866-b06660401fd3@y21g2000hsf.googlegroups.com> On 17 Apr, 09:11, Matias Surdi wrote: > It's april 1st again??? Not according to my calendar. This was not meant as a joke. I think I may have solved the GIL issue. See my answer to Martin v. L?wis for a full explanation. From diresu at web.de Tue Apr 22 12:09:39 2008 From: diresu at web.de (Dietrich Bollmann) Date: Wed, 23 Apr 2008 01:09:39 +0900 Subject: Error in Extending/Embedding FAQ, point 16: How do I tell "incomplete input" from "invalid input"? In-Reply-To: <1208877167.4557.37.camel@pippi.pippi> References: <1208877167.4557.37.camel@pippi.pippi> Message-ID: <1208880579.4557.70.camel@pippi.pippi> On Wed, 2008-04-23 at 00:12 +0900, Dietrich Bollmann wrote: > The following code for example: > > >>> eins = [1, > ... 2, > ... 3] > >>> > > is accepted without any problem by the Python shell. > > When using the code from the FAQ and entering it line by line > ?already the second line causes a simple "invalid syntax" error: > > >>> eins = [1, > ... 2, > File "", line 2 > 2, > ^ > SyntaxError: invalid syntax By the way - isn't this error message / error code just "wrong" in the given situation and therefor kind of a "bug"? An "end of file" or "incomplete input" error at least would describe the situation much better - and be a better base for functionality which is based the error code also. --- I also thought that I should explain a little bit more exactly, what I am intending to do with the code based on paragraph 16 (How do I tell "incomplete input" from "invalid input"?) of the Extending/Embedding FAQ: I am using Python as scripting language in an application (blender). In order to interface this application from other programs I programmed a python command port / command socket for this application. Between other clients I also wrote a shell client which connects via the command port to the application. My goal is to make it as similar to a normal python shell as possible - and therefor I try to also mimic the "intelligent" way of the Python shell to react to Python input: - when entering a line which is a complete input, it is immediately evaluated by the shell and the result is printed. - when the last entered line is erroneous, an error message is printed immediately - when the input is incomplete, Python waits for other lines to complete the input - when the line is part of a function definition etc. python waits until an empty line is entered before accepting the input as complete. My problem is to understand when an input is erroneous and when it is incomplete - which is impossible with an error message like "invalid syntax"... So here again my question: How can I make the difference between an incomplete and an erroneous input? The code examples in the FAQ worked fine until now - but do not anymore for the current Python implementation. Thanks, Dietrich By the way: Does anybody know who is responsible for the FAQ and could adapt the examples to the current Python version by changing the code / annotating it? On Wed, 2008-04-23 at 00:12 +0900, Dietrich Bollmann wrote: Hi, > > Both code examples from paragraph 16 from the Python Extending / > Embedding FAQ - 'How do I tell "incomplete input" from "invalid input"?' > - > ( http://www.python.org/doc/faq/extending/#how-do-i-tell-incomplete-input-from-invalid-input ) do not work with the current state of Python anymore. > > In the second code example, the error message returned by Python is > checked in order to differentiate errors caused by an incomplete input > from other syntax errors: > > if (PyArg_ParseTuple (val, "sO", &msg, &obj) && > !strcmp (msg, "unexpected EOF while parsing")) /* E_EOF */ > > In the current Python version there are more error messages indicating an > incomplete Python input and I could make the code work for a while > by adding the following strings to the condition: > > /* error messages indicating an incomplete input */ > if (PyArg_ParseTuple(error, "sO", &message, &obj) && > (!strcmp(message, "unexpected EOF while parsing") || > !strcmp(message, "expected an indented block") || > !strcmp(message, "EOF while scanning triple-quoted string") > ) > ) { /* E_EOF */ > > but recently there are also cases which generate error messages > which are too general to be added to this list. > > The following code for example: > > >>> eins = [1, > ... 2, > ... 3] > >>> > > is accepted without any problem by the Python shell. > > When using the code from the FAQ and entering it line by line > ?already the second line causes a simple "invalid syntax" error: > > >>> eins = [1, > ... 2, > File "", line 2 > 2, > ^ > SyntaxError: invalid syntax > > which is to general to be integrated into the list of tested > error messages as it might be caused also by code like: > > >>> one two > File "", line 1 > one two > ^ > SyntaxError: invalid syntax > > which generates an "invalid syntax" error even in the Python shell. > > I also tried the first code example of paragraph > '16 How do I tell "incomplete input" from "invalid input"?' > of the FAQ in order to see if it could be used to make the > difference between syntax errors and incomplete code errors. > But - as in the case before - the returned error > code is E_SYNTAX (14 = Syntax error) and not E_EOF (11 = End Of File) > as should be expected. > > Is there anybody who has an idea how to differentiate the > first case from the second in order to mimic the behaviour of > the Python shell from c code? > > If this shouldn't be possible lists split into different lines > couldn't be accepted anymore or the feature of the Python shell > to described in paragraph 16 of the faq: > > Sometimes you want to emulate the Python interactive interpreter's > behavior, where it gives you a continuation prompt when the input > is incomplete (e.g. you typed the start of an "if" statement or you > didn't close your parentheses or triple string quotes), but it gives > you a syntax error message immediately when the input is invalid. > > would have to be given up and every entered line of code would have to > be terminated by an empty line before evaluation :( > > Thanks for any help, Dietrich > > > > From MartinRinehart at gmail.com Wed Apr 9 11:02:44 2008 From: MartinRinehart at gmail.com (MartinRinehart at gmail.com) Date: Wed, 9 Apr 2008 08:02:44 -0700 (PDT) Subject: import statement convention References: <4078bcf4-e68f-45d4-93ce-335ec7a33c5a@v32g2000prd.googlegroups.com> Message-ID: <405fef20-2593-44da-abe8-516fec7e59fa@k10g2000prm.googlegroups.com> Thanks, all. Good to know no one's been beheaded. Yes to separating test and non-test code, but no if that will just turn one modest module into two modules, smaller still. Amen to 'practicality beats purity.' Do wish we had a good, thorough convention set. I wrote one for Java. It took a lot of work. ( file:/home/martin/mrwebsite/articles/code- conventions.html ) From bbxx789_05ss at yahoo.com Sun Apr 6 18:21:51 2008 From: bbxx789_05ss at yahoo.com (7stud) Date: Sun, 6 Apr 2008 15:21:51 -0700 (PDT) Subject: Tkinter, a lot of buttons, make prog shorter? References: <688483d9-2c6a-4e2a-b64d-f32bb27699ec@p25g2000hsf.googlegroups.com> Message-ID: On Apr 6, 4:12?pm, 7stud wrote: > You said you were an experienced programmer, but you keep posting code > with the same mistakes over and over again. ?Why are you attaching the > buttons to self? Remember this: > Another thing you should be aware of: self is like a class wide > bulletin board. If you are writing code inside a class method, and > there is data that you want code inside another class method to be > able to see, then post the data on the class wide bulletin board, i.e. > attach it to self. ?But in your code, you are doing this: > > self.btnDisplay = Button(self, text="7", default=ACTIVE) > self.btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > self.btnDisplay = Button(self, text="8", default=ACTIVE) > self.btnDisplay.grid(row=5, column=1, padx=5, pady=5) > > As a result, your code continually overwrites self.btnDisplay. ?That > means you aren't preserving the data assigned to self.btnDisplay. > Therefore, the data does not need to be posted on the class wide > bulletin board for other class methods to see. ?So just write: > > btnDisplay = Button(self, text="7", default=ACTIVE) > btnDisplay.grid(row=5, column=0, padx=5, pady=5) > > btnDisplay = Button(self, text="8", default=ACTIVE) > btnDisplay.grid(row=5, column=1, padx=5, pady=5) From matthieu.brucher at gmail.com Thu Apr 10 11:24:24 2008 From: matthieu.brucher at gmail.com (Matthieu Brucher) Date: Thu, 10 Apr 2008 17:24:24 +0200 Subject: SWIG/C++ In-Reply-To: References: Message-ID: Hi, The error is generated because you are asking for a u8*, but the buffer is not a u8*, perhaps a char* or even a void*. If you change the method signature to either char* or void*, it may work like you want it to ;) Matthieu 2008/4/10, Bill Davy : > > Is there a better place to post such questions? > > Anyway, in the hope it is something simple, I would appreciate some help. > > I am adding some C++ code to Python. From Python I want to be able to > read > data from a target device, over USB. My software does all the hard work > and > I have a class: > > class ViperUsbC > { > public: > // snip snip > ERROR_T ReadSlaveMemory(u8 Slave, u16 Offset, u8* pData, u16 > Length); > // Snip,snip > }; > > I use swigwin-1.3.34 to wrap it into a module called SHIP. > > In Python, I have: > > import SHIP > ViperUsb = SHIP.ViperUsbC() > Slave =7 > Offset = 0 > Length = 64 > Buffer = 'a' * Length > print "type(Buffer)=%s" % type(Buffer) > print "len(Buffer)=%s" % len(Buffer) > Result = ViperUsb.ReadSlaveMemory(Slave, Offset, Buffer, Length); > > That fails with: > > type(Buffer)= > len(Buffer)=64 > > Traceback (most recent call last): > File "H:\Husky\HostPC\V1\SHIP\test1.py", line 1970, in -toplevel- > ViperTests() > File "H:\Husky\HostPC\V1\SHIP\test1.py", line 1884, in ViperTests > Result = ViperUsb.ReadSlaveMemory(Slave, Offset, Buffer, Length); > File "H:\Husky\HostPC\V1\SHIP\Release\SHIP.py", line 1757, in > ReadSlaveMemory > def ReadSlaveMemory(*args): return > _SHIP.ViperUsbC_ReadSlaveMemory(*args) > TypeError: in method 'ViperUsbC_ReadSlaveMemory', argument 4 of type 'u8 > *' > > > How do I provide a buffer into which to read the data? It would not be > intolerable to provide another layer using %extend, but I feel sure this > should be automagic. > > Thanks in advance > Bill > > PS This is a very small part of a much larger project so I cannot supply > complete source code. > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- French PhD student Website : http://matthieu-brucher.developpez.com/ Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92 LinkedIn : http://www.linkedin.com/in/matthieubrucher -------------- next part -------------- An HTML attachment was scrubbed... URL: From ross.buick at iquest.co.nz Sun Apr 20 21:29:05 2008 From: ross.buick at iquest.co.nz (DevEng) Date: Sun, 20 Apr 2008 18:29:05 -0700 (PDT) Subject: C\C++ Python embedding linking problem Message-ID: <944798e9-cfd8-496b-a369-448bd4dbad61@q24g2000prf.googlegroups.com> Hi all, I am new to Python and trying to embed it into a c/c++ application. I started with examples from the documentation pages and go to the Pure Embedding example (http://docs.python.org/ext/pure-embedding.html). I can compile and run this example on wxDevC++ with a mingwin compiler. However when I tried this with Borland C++ Builder 5 I get linker errors. The code is the same exactly (the same main.c file), the only difference is the library I am using, as Borland requires OMF format library (I have converted it from). I am using the same binary distribution of Python on win XP. As far as I can tell the functions the linker complains about are not in the converted library or the original. [Linker Error] Unresolved external '_Py_InitModule4TraceRefs' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER5\PROJECTS\EXP \TRY2\PETMAIN.OBJ [Linker Error] Unresolved external '__Py_RefTotal' referenced from C: \PROGRAM FILES\BORLAND\CBUILDER5\PROJECTS\EXP\TRY2\PETMAIN.OBJ [Linker Error] Unresolved external '__Py_NegativeRefcount' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER5\PROJECTS\EXP\TRY2\PETMAIN.OBJ [Linker Error] Unresolved external '__Py_Dealloc' referenced from C: \PROGRAM FILES\BORLAND\CBUILDER5\PROJECTS\EXP\TRY2\PETMAIN.OBJ As far as I can tell it is a problem with my Borland setup but I cannot find what it is... Any help is greatly appreciated, Ross From pavlovevidence at gmail.com Thu Apr 17 16:07:56 2008 From: pavlovevidence at gmail.com (Carl Banks) Date: Thu, 17 Apr 2008 13:07:56 -0700 (PDT) Subject: I just killed GIL!!! References: <5dc00e8a-9736-4789-aec7-a2808dece592@2g2000hsn.googlegroups.com> <807a1d5b-a844-47a2-9ceb-7aa60eacf802@e39g2000hsf.googlegroups.com> <431ee8d9-4dd6-4abf-a1a4-55e5be82d535@x41g2000hsb.googlegroups.com> Message-ID: On Apr 17, 1:03 pm, Jonathan Gardner wrote: > On Apr 17, 1:18 am, Carl Banks wrote: > > > On Apr 17, 3:37 am, Jonathan Gardner > > wrote: > > > If you can't rewrite > > > your algorithm to be disk or network bound, next optimization step is > > > C. > > > I'm sorry, but I don't like being told to use C. Perhaps I would like > > the expressiveness of Python, am willing to accept the cost in > > performance, but would also like to take advantage of technology to > > get performance gains when I can? What's so unreasonable about that? > > If you're satisfied then don't take the next optimization step. Where do you see the word "satisfied" in what I wrote? Carl Banks From hdante at gmail.com Tue Apr 1 19:24:40 2008 From: hdante at gmail.com (hdante) Date: Tue, 1 Apr 2008 16:24:40 -0700 (PDT) Subject: object-relational mappers References: <16983265-5efc-4ffb-9694-49674cdc239c@e67g2000hsa.googlegroups.com> Message-ID: <63c9e390-5e5d-47ed-8184-c1cd6cb1be15@a22g2000hsc.googlegroups.com> On Apr 1, 5:40 pm, Aaron Watters wrote: > I've been poking around the world of object-relational > mappers and it inspired me to coin a corellary to the > the famous quote on regular expressions: > > "You have objects and a database: that's 2 problems. > So: get an object-relational mapper: > now you have 2**3 problems." > > That is to say I feel that they all make me learn > so much about the internals and features of the > O-R mapper itself that I would be better off rolling > my own queries on an as-needed basis without > wasting so many brain cells. > > comments? Try Rails' ActiveRecord. Your problems should reduce to (lg lg 2)^(1/12). Seriously, you'll forget there's a relational database below. (there are even intefaces for "relational lists", "trees", etc.) I won't post a code sample here, it would be heretic. :-) > > -- Aaron Watters > > ===http://www.xfeedme.com/nucular/pydistro.py/go?FREETEXT=mild+exponenti... From zethex at hotmail.com Sun Apr 27 14:22:06 2008 From: zethex at hotmail.com (Zethex) Date: Sun, 27 Apr 2008 11:22:06 -0700 (PDT) Subject: Mapping and Filtering Help for Lists In-Reply-To: References: <16925836.post@talk.nabble.com> Message-ID: <16926760.post@talk.nabble.com> Thank you a lot! Another quick couple of questions. How can i make it so it removes special operators such as ? ! or doesnt include them? and I need to lowercase the words so should i use sentence = sentence.lower()? -- View this message in context: http://www.nabble.com/Mapping-and-Filtering-Help-for-Lists-tp16925836p16926760.html Sent from the Python - python-list mailing list archive at Nabble.com. From steve at holdenweb.com Thu Apr 17 16:16:48 2008 From: steve at holdenweb.com (Steve Holden) Date: Thu, 17 Apr 2008 16:16:48 -0400 Subject: Can't do a multiline assignment! In-Reply-To: <564dd82b-8670-4ead-a3c8-a22b30a3eb73@m73g2000hsh.googlegroups.com> References: <0a3e9209-58f1-439c-b2e2-849e6990b21d@b64g2000hsa.googlegroups.com> <2c3ab39b-8ef9-4477-8b8b-72d21875bfc2@t54g2000hsg.googlegroups.com> <1952579a-3cfb-44ea-92aa-658daa64aee4@a70g2000hsh.googlegroups.com> <564dd82b-8670-4ead-a3c8-a22b30a3eb73@m73g2000hsh.googlegroups.com> Message-ID: s0suk3 at gmail.com wrote: > On Apr 17, 11:46 am, Arnaud Delobelle wrote: >> Why not do something like: >> >> class RequestHeadersManager: >> >> def __init__(self, string): >> self._fields = {} >> # Populate self.fields with fields defined in 'string' >> >> def __getitem__(self, fieldname): >> return self._fields.get(fieldname, None) >> >> This way you don't need to prebind all possible fields to None, and a >> field is accessible by its actual name, which should be easier to >> remember than an identifier derived from a field name. Moreover you >> can more easily do some group manipulation of fields (e.g. print them >> all >> >> def print_fields(self): >> for name, value in self._fields.iteritems(): >> print "%s: %s" % (name, value) >> ) >> > > I do it with all the separate variables mainly for performance. If I > had the headers in a dict, I'd be looking up a string in a list of > strings (the keys of the dict) everytime I check for a header. Not > that that's going to take more that 0.1 seconds, but the program is > still small and simple. As it gets bigger, more features are gonna > slow things down. So basically you are optimizing for a performance problem you don't currently have. You want to stop that *straight* away. You are contorting your logic for absolutely no good reason. Do what's easiest. Then, when you have that working correctly, speed it up (if you need to). Start with a dict. How do you know it won't be fast enough? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From ivan.illarionov at gmail.com Fri Apr 18 20:47:30 2008 From: ivan.illarionov at gmail.com (Ivan Illarionov) Date: Sat, 19 Apr 2008 00:47:30 +0000 (UTC) Subject: py3k concerns. An example References: <5ee783c4-faf4-441f-aa23-5b3ade724521@p25g2000hsf.googlegroups.com> <0ebcf70f-c6d6-4ee7-9ef8-7cd2221ef906@t12g2000prg.googlegroups.com> <879750f6-614a-45ed-8f18-f0b7ae5ea9a2@26g2000hsk.googlegroups.com> Message-ID: On Fri, 18 Apr 2008 16:19:38 -0700, Kay Schluehr wrote: > On 18 Apr., 23:09, Matimus wrote: >> The reason it doesn't work is that you are unpacking the dictionary >> with **, and you have done nothing to define any keys or define a >> length. > > This is a non-issue. The class derives from dict; it has all the desired > attributes. It is also not a problem in particular because these > properties are not requested by format ( at least not in the code I have > examined which was admittedly just a critical section that caused the > exception ). > >> Adding to that... don't worry about py3k. Nobody is forcing you to >> switch. In fact, you are encouraged not to until you are comfortable. >> Py3k won't _break_ your code. You wrote the code for Python 2.x use it >> in 2.x. Python 2.x probably has a good 5-10 years remaining. > > These advices start to get annoying. > > Software hardly ever exists in isolation for the sake of the beauty of > the algorithm but is supplementary to a large framework/engine/ library. > So if e.g. Django switches to 3 everyone who works with it has to switch > sooner or later as well or lose track otherwise, no matter how long > Python 1.5.2 or Python 2.5.2 or whatever version will be maintained. If > Pythons code base becomes fragmented it will be harmful and affect > almost everyones work. This Py3k-Django-related FUD starts to get annoying. AFAIK Django is going to support everything from 2.3 to 3.0 from single codebase. 2to3 tool will be called from setup.py and code will have few 'if sys.version_info < (3, 0)/else' tricks. Proof of concept already exists: http://wiki.python.org/moin/PortingDjangoTo3k I work with Django as well as *on* Django and 3rd party Django addons and don't see any reason to worry. Your particular problem may be solved by using a real dictionary with real keys which will probably have positive performance impact on your code and make it more clean. Even if Python code base will become fragmented why is it harmfull? This is a way our life work - you rise and get better or die. It is essential part of progress and evolution. IMHO, we'll only get better Python and better Python libraries. -- Ivan From ankitks.mital at gmail.com Thu Apr 3 15:58:25 2008 From: ankitks.mital at gmail.com (ankitks.mital at gmail.com) Date: Thu, 3 Apr 2008 12:58:25 -0700 (PDT) Subject: python bisect questions Message-ID: <6bb6927b-f553-40db-a142-2ce86b9e819f@q27g2000prf.googlegroups.com> I am week on functional programming, and having hard time understanding this: class myPriorityQueue: def __init__(self, f=lamda x:x): self.A = [] self.f = f def append(self, item) bisect.insort(self.A, (self.f(item), item)) ............ now I know we are inserting items(user defined type objects) in list A base on sorting order provided by function A. but what I don't understand is bisect command what does bisect.insort(self.A, (self.f(item), item)) doing isn't it is returning truple of (self.f(item), item)). why it is not biset.insort(self.A, item) A.sort(f) thanks for your comments From kyosohma at gmail.com Fri Apr 25 10:30:33 2008 From: kyosohma at gmail.com (Mike Driscoll) Date: Fri, 25 Apr 2008 07:30:33 -0700 (PDT) Subject: Environment Variables References: <336c3140-4620-4ca3-a6b9-9869dafc4b36@c19g2000prf.googlegroups.com> Message-ID: On Apr 25, 8:26?am, Krishna wrote: > On Apr 25, 9:17?am, Mike Driscoll wrote: > > > > > On Apr 25, 8:07?am, Krishna wrote: > > > > Environment variable set up is the most confusing part for me all the > > > time. Please help me with the following questions: > > > > When I install python in a new system, I will go to environment > > > variables (system variables) and set "path" pointing to C:\Python25 > > > and thats all I do. > > > I type python from "cmd" window and its converting to python window > > > for python execution. All fine up to this point. > > > Now, I want to drag and drop python (.py) files to this window and > > > execute it. My python files are located in different directories > > > inside C: and outside C:. When I do that, I get errors and the file is > > > not found and its not imported. ALso, inside the .py file, if I have a > > > command to open a different file, it doesnt see that either. How do I > > > overcome these basic difficulties in python. I wish I can open any > > > file and work on that using python. > > > > Thanks for your help! > > > Krishna > > > I'm pretty sure you can't do that in a command window. I tried it on > > my Windows XP machine and all I get in my instance of IDLE is the path > > to the file. It DOES work with PythonWin, which is the ActiveState > > version of Python. The only difference is that it include the win32 > > modules and has a more advanced editor. > > > You can probably get this to work in other more advanced editors, like > > WingIDE or PyDev too. > > > Mike- Hide quoted text - > > > - Show quoted text - > > So, how do I get the win32 module and what to do with that? Just > install it? > > Thanks, > Krishna ActivePython can be found on the ActiveState website: http://www.activestate.com/Products/activepython/?_x=1 This will basically just add whatever modules needed if Python is already installed and it will also install another editor called pythonwin, which you should be able to find in your start menu. But be sure to check out that link that Steve gave you. That might work for you too. Mike From nick at stinemates.org Fri Apr 18 14:40:27 2008 From: nick at stinemates.org (Nick Stinemates) Date: Fri, 18 Apr 2008 11:40:27 -0700 Subject: Brand New! In-Reply-To: References: <7f1828bf-ebe7-4111-bc59-70d125facb0a@d26g2000prg.googlegroups.com> Message-ID: <20080418184027.GD19281@deviL> On Tue, Apr 15, 2008 at 04:37:40PM -0700, agent E 10 wrote: > On Apr 14, 8:37?pm, Benjamin wrote: > > On Apr 14, 9:00 pm, agent E 10 wrote:> ? ?Hi, I'm brand new to programming. Have any suggestions? I'm young. > > > Was it a good idea to start with python? I was planning on creating a > > > very simple program that asked yes/no questions for a school project. > > > > IMHO, Python is an excellent language to start with. Have you read the > > tutorial?http://docs.python.org/tut/tut.html > > > > > > > > > -Thanks!- Hide quoted text - > > > > - Show quoted text - > > No, I haven't. I have been reading off of this site > http://www.freenetpages.co.uk/hp/alan.gauld/ is this a good site to > learn off of? About how long will it take me to learn the basics of > the language? > -Thanks 4 all ur help! Agent E 10 > -- > http://mail.python.org/mailman/listinfo/python-list Windows or Unix/Linux? I find python is easier to learn in Linux environments, since it assumes some familiarty with the shell. -- Nick Stinemates (nick at stinemates.org) http://nick.stinemates.org